diff --git a/methods/README.md b/methods/README.md index dde58d7..5044596 100644 --- a/methods/README.md +++ b/methods/README.md @@ -18,6 +18,15 @@ $ slack run chat_post_message.py # Make the request ### agents +- **[agents.conversations.archive](https://docs.slack.dev/reference/methods/agents.conversations.archive)**: Archive a code channel. [Implementation](./src/agents/conversations/agents_conversations_archive.py). +- **[agents.conversations.create](https://docs.slack.dev/reference/methods/agents.conversations.create)**: Create a dedicated code channel for an agent session. [Implementation](./src/agents/conversations/agents_conversations_create.py). +- **[agents.conversations.getCanvas](https://docs.slack.dev/reference/methods/agents.conversations.getCanvas)**: Fetch a canvas attached to a code channel. [Implementation](./src/agents/conversations/agents_conversations_get_canvas.py). +- **[agents.conversations.listViews](https://docs.slack.dev/reference/methods/agents.conversations.listViews)**: List the views currently attached to a code channel. [Implementation](./src/agents/conversations/agents_conversations_list_views.py). +- **[agents.conversations.removeView](https://docs.slack.dev/reference/methods/agents.conversations.removeView)**: Remove a view from a code channel. [Implementation](./src/agents/conversations/agents_conversations_remove_view.py). +- **[agents.conversations.setCanvasContent](https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent)**: Replace the full markdown content of a plan canvas attached to a code channel. [Implementation](./src/agents/conversations/agents_conversations_set_canvas_content.py). +- **[agents.conversations.setCommands](https://docs.slack.dev/reference/methods/agents.conversations.setCommands)**: Register the set of agent-defined slash commands for the calling agent in a code channel. [Implementation](./src/agents/conversations/agents_conversations_set_commands.py). +- **[agents.conversations.setProperties](https://docs.slack.dev/reference/methods/agents.conversations.setProperties)**: Set properties on a code channel. [Implementation](./src/agents/conversations/agents_conversations_set_properties.py). +- **[agents.conversations.setView](https://docs.slack.dev/reference/methods/agents.conversations.setView)**: Create or update a view in a code channel. [Implementation](./src/agents/conversations/agents_conversations_set_view.py). - **[agents.sessions.rename](https://docs.slack.dev/reference/methods/agents.sessions.rename)**: Rename an agent session. [Implementation](./src/agents/sessions/agents_sessions_rename.py). - **[agents.sessions.setStatus](https://docs.slack.dev/reference/methods/agents.sessions.setStatus)**: Set an agent session's lifecycle status, creating the session if needed. [Implementation](./src/agents/sessions/agents_sessions_set_status.py). diff --git a/methods/src/agents/conversations/.slack/.gitignore b/methods/src/agents/conversations/.slack/.gitignore new file mode 100644 index 0000000..973ba60 --- /dev/null +++ b/methods/src/agents/conversations/.slack/.gitignore @@ -0,0 +1,2 @@ +apps.dev.json +cache/ diff --git a/methods/src/agents/conversations/.slack/config.json b/methods/src/agents/conversations/.slack/config.json new file mode 100644 index 0000000..909afbe --- /dev/null +++ b/methods/src/agents/conversations/.slack/config.json @@ -0,0 +1,6 @@ +{ + "manifest": { + "source": "local" + }, + "project_id": "00000000-0000-0000-0000-000000000000" +} diff --git a/methods/src/agents/conversations/.slack/hooks.json b/methods/src/agents/conversations/.slack/hooks.json new file mode 100644 index 0000000..ce474c9 --- /dev/null +++ b/methods/src/agents/conversations/.slack/hooks.json @@ -0,0 +1,5 @@ +{ + "hooks": { + "get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks" + } +} diff --git a/methods/src/agents/conversations/__init__.py b/methods/src/agents/conversations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/methods/src/agents/conversations/agents_conversations_archive.py b/methods/src/agents/conversations/agents_conversations_archive.py new file mode 100644 index 0000000..e7178f7 --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_archive.py @@ -0,0 +1,18 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.archive method +response = client.agents_conversations_archive( + channel_id="C9876543210", + summary_message_ts="1717182000.456789", +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_create.py b/methods/src/agents/conversations/agents_conversations_create.py new file mode 100644 index 0000000..791f780 --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_create.py @@ -0,0 +1,20 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.create method +response = client.agents_conversations_create( + name="Migrate billing cron to Temporal", + session_id="ses_8675309", + origin_channel_id="C0123456789", + origin_message_ts="1717171717.123456", +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_get_canvas.py b/methods/src/agents/conversations/agents_conversations_get_canvas.py new file mode 100644 index 0000000..d20456e --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_get_canvas.py @@ -0,0 +1,19 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.getCanvas method +response = client.agents_conversations_getCanvas( + channel="C9876543210", + canvas_id="F1234567890", + include_resolved=False, +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_list_views.py b/methods/src/agents/conversations/agents_conversations_list_views.py new file mode 100644 index 0000000..4d6c06d --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_list_views.py @@ -0,0 +1,17 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.listViews method +response = client.agents_conversations_listViews( + channel_id="C9876543210", +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_remove_view.py b/methods/src/agents/conversations/agents_conversations_remove_view.py new file mode 100644 index 0000000..187bb56 --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_remove_view.py @@ -0,0 +1,18 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.removeView method +response = client.agents_conversations_removeView( + channel_id="C9876543210", + view_key="reports/coverage.html", +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_set_canvas_content.py b/methods/src/agents/conversations/agents_conversations_set_canvas_content.py new file mode 100644 index 0000000..8721507 --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_set_canvas_content.py @@ -0,0 +1,19 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.setCanvasContent method +response = client.agents_conversations_setCanvasContent( + channel="C9876543210", + canvas_id="F1234567890", + content="# Migration plan\n\n1. Inventory cron jobs\n2. Port billing jobs last\n", +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_set_commands.py b/methods/src/agents/conversations/agents_conversations_set_commands.py new file mode 100644 index 0000000..7fed97f --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_set_commands.py @@ -0,0 +1,32 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.setCommands method +response = client.agents_conversations_setCommands( + channel_id="C9876543210", + commands=[ + { + "name": "create-pr", + "description": "Open a pull request for the current branch", + "argument_hint": "[title]", + }, + { + "name": "run-tests", + "description": "Run the test suite and report back", + }, + { + "name": "summarize", + "description": "Post a summary of the work so far", + }, + ], +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_set_properties.py b/methods/src/agents/conversations/agents_conversations_set_properties.py new file mode 100644 index 0000000..3366362 --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_set_properties.py @@ -0,0 +1,44 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.setProperties method +response = client.agents_conversations_setProperties( + channel_id="C9876543210", + code_channel={ + "context_bar_items": [ + { + "key": "repo", + "label": "borant/billing", + "icon": "folder", + "url": "https://github.com/borant/billing", + }, + { + "key": "branch", + "label": "agent/migrate-cron", + "icon": "branch", + "url": "https://github.com/borant/billing/tree/agent/migrate-cron", + }, + { + "key": "pr", + "label": "PR #42 is open", + "icon": "hierarchy", + "url": "https://github.com/borant/billing/pull/42", + }, + { + "key": "ci", + "label": "Tests pending", + "icon": "terminal", + }, + ] + }, +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/agents_conversations_set_view.py b/methods/src/agents/conversations/agents_conversations_set_view.py new file mode 100644 index 0000000..858e71b --- /dev/null +++ b/methods/src/agents/conversations/agents_conversations_set_view.py @@ -0,0 +1,23 @@ +import os + +from slack_sdk import WebClient + +# Read a token from an environment variable +token = os.environ.get("SLACK_TOKEN") + +# Initialize +client = WebClient(token=token) + +# Call the agents.conversations.setView method +response = client.agents_conversations_setView( + channel_id="C9876543210", + view_key="reports/coverage.html", + name="Coverage", + content="……", + csp={ + "resource_domains": ["https://cdn.jsdelivr.net"], + }, +) + +# Inspect the response +print(response) diff --git a/methods/src/agents/conversations/manifest.json b/methods/src/agents/conversations/manifest.json new file mode 100644 index 0000000..8e6a0c1 --- /dev/null +++ b/methods/src/agents/conversations/manifest.json @@ -0,0 +1,25 @@ +{ + "display_information": { + "name": "Slack API Methods", + "description": "Example implementations to call \"agents.conversations\" methods" + }, + "features": { + "bot_user": { + "display_name": "Slack API Methods", + "always_online": true + }, + "code_channels": { + "enabled": true + } + }, + "oauth_config": { + "scopes": { + "bot": ["code_channels:manage"] + } + }, + "settings": { + "org_deploy_enabled": true, + "socket_mode_enabled": true, + "token_rotation_enabled": false + } +}