From 1b1b21464b45d4a459f87dc76610679be75e2f48 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 23 Sep 2026 13:23:38 -0700 Subject: [PATCH 1/4] feat(web-api): add agents.conversations.* code channel methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the 9 Slack Code (code channel) Web API methods to @slack/web-api: create, archive, setProperties, setView, setCommands, listViews, removeView, getCanvas, setCanvasContent — all requiring the code_channels:manage bot scope. Argument interfaces are hand-typed from the docs #816 method schemas. Per those schemas, getCanvas and setCanvasContent use `channel` (not `channel_id`); the other seven use `channel_id`. Response types follow the repo's auto-generated shape; since these are net-new methods with no java-slack-sdk samples yet, they are hand-written minimal WebAPICallResult extensions rather than codegen output. Only agents.conversations.* names are added — the legacy codeChannels.* names are intentionally not shipped (decision 2026-09-23). Co-Authored-By: Claude Co-Authored-By: Claude Opus 4.8 (1M context) --- .changeset/agents-conversations-methods.md | 5 + packages/web-api/src/methods.ts | 92 ++++++++++ packages/web-api/src/types/request/agents.ts | 173 ++++++++++++++++++ packages/web-api/src/types/request/index.ts | 14 +- .../AgentsConversationsArchiveResponse.ts | 17 ++ .../AgentsConversationsCreateResponse.ts | 18 ++ .../AgentsConversationsGetCanvasResponse.ts | 19 ++ .../AgentsConversationsListViewsResponse.ts | 25 +++ .../AgentsConversationsRemoveViewResponse.ts | 17 ++ ...tsConversationsSetCanvasContentResponse.ts | 17 ++ .../AgentsConversationsSetCommandsResponse.ts | 17 ++ ...gentsConversationsSetPropertiesResponse.ts | 17 ++ .../AgentsConversationsSetViewResponse.ts | 18 ++ packages/web-api/src/types/response/index.ts | 9 + 14 files changed, 457 insertions(+), 1 deletion(-) create mode 100644 .changeset/agents-conversations-methods.md create mode 100644 packages/web-api/src/types/response/AgentsConversationsArchiveResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsCreateResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsGetCanvasResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsListViewsResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsRemoveViewResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsSetCanvasContentResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsSetCommandsResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsSetPropertiesResponse.ts create mode 100644 packages/web-api/src/types/response/AgentsConversationsSetViewResponse.ts diff --git a/.changeset/agents-conversations-methods.md b/.changeset/agents-conversations-methods.md new file mode 100644 index 000000000..ea4dd4cf2 --- /dev/null +++ b/.changeset/agents-conversations-methods.md @@ -0,0 +1,5 @@ +--- +"@slack/web-api": minor +--- + +feat: add the `agents.conversations.*` Slack Code channel methods (`create`, `archive`, `setProperties`, `setView`, `setCommands`, `listViews`, `removeView`, `getCanvas`, `setCanvasContent`), all requiring the `code_channels:manage` bot scope diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index f307dff90..95a37b5c1 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -98,6 +98,15 @@ import type { AdminWorkflowsPermissionsLookupArguments, AdminWorkflowsSearchArguments, AdminWorkflowsUnpublishArguments, + AgentsConversationsArchiveArguments, + AgentsConversationsCreateArguments, + AgentsConversationsGetCanvasArguments, + AgentsConversationsListViewsArguments, + AgentsConversationsRemoveViewArguments, + AgentsConversationsSetCanvasContentArguments, + AgentsConversationsSetCommandsArguments, + AgentsConversationsSetPropertiesArguments, + AgentsConversationsSetViewArguments, AgentsSessionsRenameArguments, AgentsSessionsSetStatusArguments, APITestArguments, @@ -371,6 +380,15 @@ import type { AdminWorkflowsPermissionsLookupResponse, AdminWorkflowsSearchResponse, AdminWorkflowsUnpublishResponse, + AgentsConversationsArchiveResponse, + AgentsConversationsCreateResponse, + AgentsConversationsGetCanvasResponse, + AgentsConversationsListViewsResponse, + AgentsConversationsRemoveViewResponse, + AgentsConversationsSetCanvasContentResponse, + AgentsConversationsSetCommandsResponse, + AgentsConversationsSetPropertiesResponse, + AgentsConversationsSetViewResponse, AgentsSessionsRenameResponse, AgentsSessionsSetStatusResponse, ApiTestResponse, @@ -1381,6 +1399,80 @@ export abstract class Methods extends EventEmitter { }; public readonly agents = { + conversations: { + /** + * @description Create a dedicated code channel for an agent session. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.create `agents.conversations.create` API reference}. + */ + create: bindApiCallWithOptionalArgument( + this, + 'agents.conversations.create', + ), + /** + * @description Archive a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.archive `agents.conversations.archive` API reference}. + */ + archive: bindApiCallWithOptionalArgument( + this, + 'agents.conversations.archive', + ), + /** + * @description Set properties on a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setProperties `agents.conversations.setProperties` API reference}. + */ + setProperties: bindApiCallWithOptionalArgument< + AgentsConversationsSetPropertiesArguments, + AgentsConversationsSetPropertiesResponse + >(this, 'agents.conversations.setProperties'), + /** + * @description Create or update a view in a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setView `agents.conversations.setView` API reference}. + */ + setView: bindApiCallWithOptionalArgument( + this, + 'agents.conversations.setView', + ), + /** + * @description Register the set of agent-defined slash commands for the calling agent in a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCommands `agents.conversations.setCommands` API reference}. + */ + setCommands: bindApiCall( + this, + 'agents.conversations.setCommands', + ), + /** + * @description List the views currently attached to a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.listViews `agents.conversations.listViews` API reference}. + */ + listViews: bindApiCallWithOptionalArgument< + AgentsConversationsListViewsArguments, + AgentsConversationsListViewsResponse + >(this, 'agents.conversations.listViews'), + /** + * @description Remove a view from a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.removeView `agents.conversations.removeView` API reference}. + */ + removeView: bindApiCallWithOptionalArgument< + AgentsConversationsRemoveViewArguments, + AgentsConversationsRemoveViewResponse + >(this, 'agents.conversations.removeView'), + /** + * @description Fetch a canvas attached to a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.getCanvas `agents.conversations.getCanvas` API reference}. + */ + getCanvas: bindApiCall( + this, + 'agents.conversations.getCanvas', + ), + /** + * @description Replace the full markdown content of a plan canvas attached to a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent `agents.conversations.setCanvasContent` API reference}. + */ + setCanvasContent: bindApiCall< + AgentsConversationsSetCanvasContentArguments, + AgentsConversationsSetCanvasContentResponse + >(this, 'agents.conversations.setCanvasContent'), + }, sessions: { /** * @description Rename an agent session. diff --git a/packages/web-api/src/types/request/agents.ts b/packages/web-api/src/types/request/agents.ts index 1d05f52c3..35f969610 100644 --- a/packages/web-api/src/types/request/agents.ts +++ b/packages/web-api/src/types/request/agents.ts @@ -1,3 +1,5 @@ +import type { Block, KnownBlock } from '@slack/types'; + import type { TokenOverridable } from './common'; // https://docs.slack.dev/reference/methods/agents.sessions.rename @@ -53,3 +55,174 @@ export interface AgentsSessionsSetStatusArguments extends TokenOverridable { */ username?: string; } + +// https://docs.slack.dev/reference/methods/agents.conversations.create +export interface AgentsConversationsCreateArguments extends TokenOverridable { + /** + * @description Encoded team ID to create the channel in. Required for org tokens when `origin_channel_id` is not + * provided. When omitted, the workspace is derived from the token. + */ + team_id?: string; + /** + * @description An opaque identifier for the agent session. When provided, the call is idempotent: if a channel already + * exists for this `session_id`, it is returned instead of creating a new one. + */ + session_id?: string; + /** + * @description A friendly display name for the code channel. Optional when `origin_channel_id` and `origin_message_ts` + * are provided — in that case the channel name is derived from the origin message. + */ + name?: string; + /** @description Create a private channel instead of a public one. */ + is_private?: boolean; + /** + * @description The channel ID where the agent session was initiated from. Must be provided together with + * `origin_message_ts`. The channel must be accessible to the calling app. + */ + origin_channel_id?: string; + /** + * @description The message timestamp in the origin channel that started the agent session. Must be provided together + * with `origin_channel_id`. + */ + origin_message_ts?: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.archive +export interface AgentsConversationsArchiveArguments extends TokenOverridable { + /** @description ID of the code channel to archive. */ + channel_id?: string; + /** + * @description Timestamp of a message in the code channel to share back as a thread reply on the origin message. + * Requires the channel to have an `origin_link`. + */ + summary_message_ts?: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setProperties +export interface AgentsConversationsSetPropertiesArguments extends TokenOverridable { + /** @description ID of the code channel to update. */ + channel_id?: string; + /** @description New display title for the agent session. */ + title?: string; + /** @description New status for the agent session. */ + status?: string; + /** @description Code channel properties to set. Only provided fields are updated. */ + code_channel?: Record; + /** @description Agent resource properties to set. Only provided fields are updated. */ + agent_resource?: Record; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setView +export interface AgentsConversationsSetViewArguments extends TokenOverridable { + /** @description ID of the code channel to render the view in. */ + channel_id?: string; + /** + * @description The kind of view to create or update. Defaults to `html`. Determines which other arguments are + * required: `html` and `diff` require `content`, `block_kit` requires `blocks`, `canvas` requires `canvas_id`, + * `pull_request` requires `pr_url`. + */ + type?: string; + /** + * @description Agent-assigned stable identity for the view (e.g. the source file path on the agent's machine). Used as + * the upsert key: calls with the same `view_key` update the existing view. + */ + view_key?: string; + /** + * @description View content. For `html`, a full self-contained HTML document; for `diff`, raw unified diff text. + * Capped at 1,000,000 bytes — larger content returns an error. + */ + content?: string; + /** @description Block Kit blocks to render in the view tab. Required when `type` is `block_kit`; ignored otherwise. */ + blocks?: (KnownBlock | Block)[]; + /** @description Encoded ID of the canvas to attach as the view. Required when `type` is `canvas`; ignored otherwise. */ + canvas_id?: string; + /** + * @description For canvas views: access level granted to the channel for the canvas tab. Defaults to `write`. Use + * `comment` to grant channel members comment access. + */ + access_level?: string; + /** + * @description For canvas views: hash of the canvas-derived markdown the agent last wrote, recorded so the agent can + * later detect human edits to the canvas. + */ + agent_content_hash?: string; + /** @description For pull_request views: the pull request's URL. Required when `type` is `pull_request`; ignored otherwise. */ + pr_url?: string; + /** @description For diff views: base branch name for display purposes. */ + base_branch?: string; + /** @description For diff views: head branch name for display purposes. */ + head_branch?: string; + /** + * @description Display label for the view tab. Preferred over the legacy `label` argument (`name` wins if both are + * supplied). Defaults to the last path segment of `view_key`. + */ + name?: string; + /** + * @description Deprecated alias for `name`. Display label for the view tab. Defaults to the last path segment of + * `view_key`, stripped of any `.html`/`.htm` extension. + */ + label?: string; + /** + * @description Content-Security-Policy domain declarations for the view. Domains are validated server-side + * (https-only, no private/internal hosts) and persisted with the view. + */ + csp?: Record; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setCommands +export interface AgentsConversationsSetCommandsArguments extends TokenOverridable { + /** @description ID of the code channel to register commands for. */ + channel_id?: string; + /** + * @description Full set of commands to register for the calling agent in this channel, replacing that agent's + * previously registered set. Pass an empty array to clear the agent's commands. + */ + commands: Record[]; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.listViews +export interface AgentsConversationsListViewsArguments extends TokenOverridable { + /** @description ID of the code channel to list views for. */ + channel_id?: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.removeView +export interface AgentsConversationsRemoveViewArguments extends TokenOverridable { + /** @description ID of the code channel to remove the view from. */ + channel_id?: string; + /** @description Agent-assigned key of the view to remove. Provide exactly one of `view_key` or `view_id`. */ + view_key?: string; + /** @description Encoded channel tab ID of the view to remove. Provide exactly one of `view_key` or `view_id`. */ + view_id?: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.getCanvas +export interface AgentsConversationsGetCanvasArguments extends TokenOverridable { + /** + * @description ID of the agent session channel the canvas belongs to. + * @remark Note this method uses `channel`, not `channel_id`. + */ + channel: string; + /** @description Encoded ID of the canvas to fetch. */ + canvas_id: string; + /** @description Format to render the canvas content in. Defaults to `markdown`. */ + content_format?: string; + /** @description Whether to include resolved comment threads in the response. Defaults to `false`. */ + include_resolved?: boolean; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent +export interface AgentsConversationsSetCanvasContentArguments extends TokenOverridable { + /** + * @description ID of the agent session channel the canvas is attached to. + * @remark Note this method uses `channel`, not `channel_id`. + */ + channel: string; + /** @description Encoded ID of the canvas whose content to replace. */ + canvas_id: string; + /** + * @description The full new canvas content as markdown. The server diffs this against the current content and applies + * only the changed sections. + */ + content: string; +} diff --git a/packages/web-api/src/types/request/index.ts b/packages/web-api/src/types/request/index.ts index ef9239bfa..b82e85534 100644 --- a/packages/web-api/src/types/request/index.ts +++ b/packages/web-api/src/types/request/index.ts @@ -118,7 +118,19 @@ export type { AdminWorkflowsSearchArguments, AdminWorkflowsUnpublishArguments, } from './admin/workflows'; -export type { AgentsSessionsRenameArguments, AgentsSessionsSetStatusArguments } from './agents'; +export type { + AgentsConversationsArchiveArguments, + AgentsConversationsCreateArguments, + AgentsConversationsGetCanvasArguments, + AgentsConversationsListViewsArguments, + AgentsConversationsRemoveViewArguments, + AgentsConversationsSetCanvasContentArguments, + AgentsConversationsSetCommandsArguments, + AgentsConversationsSetPropertiesArguments, + AgentsConversationsSetViewArguments, + AgentsSessionsRenameArguments, + AgentsSessionsSetStatusArguments, +} from './agents'; export type { APITestArguments } from './api'; export type { AppsConnectionsOpenArguments, diff --git a/packages/web-api/src/types/response/AgentsConversationsArchiveResponse.ts b/packages/web-api/src/types/response/AgentsConversationsArchiveResponse.ts new file mode 100644 index 000000000..8aef17f97 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsArchiveResponse.ts @@ -0,0 +1,17 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsArchiveResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsCreateResponse.ts b/packages/web-api/src/types/response/AgentsConversationsCreateResponse.ts new file mode 100644 index 000000000..59c0523aa --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsCreateResponse.ts @@ -0,0 +1,18 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsCreateResponse = WebAPICallResult & { + channel_id?: string; + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsGetCanvasResponse.ts b/packages/web-api/src/types/response/AgentsConversationsGetCanvasResponse.ts new file mode 100644 index 000000000..43910ef79 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsGetCanvasResponse.ts @@ -0,0 +1,19 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsGetCanvasResponse = WebAPICallResult & { + canvas_id?: string; + content?: string; + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsListViewsResponse.ts b/packages/web-api/src/types/response/AgentsConversationsListViewsResponse.ts new file mode 100644 index 000000000..bd9b24a97 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsListViewsResponse.ts @@ -0,0 +1,25 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsListViewsResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + views?: View[]; + warning?: string; +}; + +export interface View { + view_id?: string; + view_key?: string; + type?: string; + name?: string; +} diff --git a/packages/web-api/src/types/response/AgentsConversationsRemoveViewResponse.ts b/packages/web-api/src/types/response/AgentsConversationsRemoveViewResponse.ts new file mode 100644 index 000000000..3de6dff62 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsRemoveViewResponse.ts @@ -0,0 +1,17 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsRemoveViewResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsSetCanvasContentResponse.ts b/packages/web-api/src/types/response/AgentsConversationsSetCanvasContentResponse.ts new file mode 100644 index 000000000..6a30dcf8c --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsSetCanvasContentResponse.ts @@ -0,0 +1,17 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsSetCanvasContentResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsSetCommandsResponse.ts b/packages/web-api/src/types/response/AgentsConversationsSetCommandsResponse.ts new file mode 100644 index 000000000..13eeffcd0 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsSetCommandsResponse.ts @@ -0,0 +1,17 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsSetCommandsResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsSetPropertiesResponse.ts b/packages/web-api/src/types/response/AgentsConversationsSetPropertiesResponse.ts new file mode 100644 index 000000000..123ec4bac --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsSetPropertiesResponse.ts @@ -0,0 +1,17 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsSetPropertiesResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/AgentsConversationsSetViewResponse.ts b/packages/web-api/src/types/response/AgentsConversationsSetViewResponse.ts new file mode 100644 index 000000000..8230c7f03 --- /dev/null +++ b/packages/web-api/src/types/response/AgentsConversationsSetViewResponse.ts @@ -0,0 +1,18 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import type { WebAPICallResult } from '../../WebClient'; +export type AgentsConversationsSetViewResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + view_id?: string; + warning?: string; +}; diff --git a/packages/web-api/src/types/response/index.ts b/packages/web-api/src/types/response/index.ts index 2e1937f7e..4413329a5 100644 --- a/packages/web-api/src/types/response/index.ts +++ b/packages/web-api/src/types/response/index.ts @@ -102,6 +102,15 @@ export { AdminWorkflowsCollaboratorsRemoveResponse } from './AdminWorkflowsColla export { AdminWorkflowsPermissionsLookupResponse } from './AdminWorkflowsPermissionsLookupResponse'; export { AdminWorkflowsSearchResponse } from './AdminWorkflowsSearchResponse'; export { AdminWorkflowsUnpublishResponse } from './AdminWorkflowsUnpublishResponse'; +export { AgentsConversationsArchiveResponse } from './AgentsConversationsArchiveResponse'; +export { AgentsConversationsCreateResponse } from './AgentsConversationsCreateResponse'; +export { AgentsConversationsGetCanvasResponse } from './AgentsConversationsGetCanvasResponse'; +export { AgentsConversationsListViewsResponse } from './AgentsConversationsListViewsResponse'; +export { AgentsConversationsRemoveViewResponse } from './AgentsConversationsRemoveViewResponse'; +export { AgentsConversationsSetCanvasContentResponse } from './AgentsConversationsSetCanvasContentResponse'; +export { AgentsConversationsSetCommandsResponse } from './AgentsConversationsSetCommandsResponse'; +export { AgentsConversationsSetPropertiesResponse } from './AgentsConversationsSetPropertiesResponse'; +export { AgentsConversationsSetViewResponse } from './AgentsConversationsSetViewResponse'; export { AgentsSessionsRenameResponse } from './AgentsSessionsRenameResponse'; export { AgentsSessionsSetStatusResponse } from './AgentsSessionsSetStatusResponse'; export { ApiTestResponse } from './ApiTestResponse'; From e9c0cfcebe3b4d3d9b895cebf2c991325d25ec50 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 23 Sep 2026 15:43:31 -0700 Subject: [PATCH 2/4] refactor(web-api): require channel_id/name on agents.conversations.* + drop channel remark Co-Authored-By: Claude Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/web-api/src/types/request/agents.ts | 24 ++++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/web-api/src/types/request/agents.ts b/packages/web-api/src/types/request/agents.ts index 35f969610..18a91a0cf 100644 --- a/packages/web-api/src/types/request/agents.ts +++ b/packages/web-api/src/types/request/agents.ts @@ -72,7 +72,7 @@ export interface AgentsConversationsCreateArguments extends TokenOverridable { * @description A friendly display name for the code channel. Optional when `origin_channel_id` and `origin_message_ts` * are provided — in that case the channel name is derived from the origin message. */ - name?: string; + name: string; /** @description Create a private channel instead of a public one. */ is_private?: boolean; /** @@ -90,7 +90,7 @@ export interface AgentsConversationsCreateArguments extends TokenOverridable { // https://docs.slack.dev/reference/methods/agents.conversations.archive export interface AgentsConversationsArchiveArguments extends TokenOverridable { /** @description ID of the code channel to archive. */ - channel_id?: string; + channel_id: string; /** * @description Timestamp of a message in the code channel to share back as a thread reply on the origin message. * Requires the channel to have an `origin_link`. @@ -101,7 +101,7 @@ export interface AgentsConversationsArchiveArguments extends TokenOverridable { // https://docs.slack.dev/reference/methods/agents.conversations.setProperties export interface AgentsConversationsSetPropertiesArguments extends TokenOverridable { /** @description ID of the code channel to update. */ - channel_id?: string; + channel_id: string; /** @description New display title for the agent session. */ title?: string; /** @description New status for the agent session. */ @@ -115,7 +115,7 @@ export interface AgentsConversationsSetPropertiesArguments extends TokenOverrida // https://docs.slack.dev/reference/methods/agents.conversations.setView export interface AgentsConversationsSetViewArguments extends TokenOverridable { /** @description ID of the code channel to render the view in. */ - channel_id?: string; + channel_id: string; /** * @description The kind of view to create or update. Defaults to `html`. Determines which other arguments are * required: `html` and `diff` require `content`, `block_kit` requires `blocks`, `canvas` requires `canvas_id`, @@ -172,7 +172,7 @@ export interface AgentsConversationsSetViewArguments extends TokenOverridable { // https://docs.slack.dev/reference/methods/agents.conversations.setCommands export interface AgentsConversationsSetCommandsArguments extends TokenOverridable { /** @description ID of the code channel to register commands for. */ - channel_id?: string; + channel_id: string; /** * @description Full set of commands to register for the calling agent in this channel, replacing that agent's * previously registered set. Pass an empty array to clear the agent's commands. @@ -183,13 +183,13 @@ export interface AgentsConversationsSetCommandsArguments extends TokenOverridabl // https://docs.slack.dev/reference/methods/agents.conversations.listViews export interface AgentsConversationsListViewsArguments extends TokenOverridable { /** @description ID of the code channel to list views for. */ - channel_id?: string; + channel_id: string; } // https://docs.slack.dev/reference/methods/agents.conversations.removeView export interface AgentsConversationsRemoveViewArguments extends TokenOverridable { /** @description ID of the code channel to remove the view from. */ - channel_id?: string; + channel_id: string; /** @description Agent-assigned key of the view to remove. Provide exactly one of `view_key` or `view_id`. */ view_key?: string; /** @description Encoded channel tab ID of the view to remove. Provide exactly one of `view_key` or `view_id`. */ @@ -198,10 +198,7 @@ export interface AgentsConversationsRemoveViewArguments extends TokenOverridable // https://docs.slack.dev/reference/methods/agents.conversations.getCanvas export interface AgentsConversationsGetCanvasArguments extends TokenOverridable { - /** - * @description ID of the agent session channel the canvas belongs to. - * @remark Note this method uses `channel`, not `channel_id`. - */ + /** @description ID of the agent session channel the canvas belongs to. */ channel: string; /** @description Encoded ID of the canvas to fetch. */ canvas_id: string; @@ -213,10 +210,7 @@ export interface AgentsConversationsGetCanvasArguments extends TokenOverridable // https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent export interface AgentsConversationsSetCanvasContentArguments extends TokenOverridable { - /** - * @description ID of the agent session channel the canvas is attached to. - * @remark Note this method uses `channel`, not `channel_id`. - */ + /** @description ID of the agent session channel the canvas is attached to. */ channel: string; /** @description Encoded ID of the canvas whose content to replace. */ canvas_id: string; From fe6fcdf0f3d3dd735defbd18ae330ca10d733f89 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 25 Sep 2026 14:15:54 -0700 Subject: [PATCH 3/4] refactor(web-api): alphabetize agents.conversations methods Order the 9 agents.conversations method registrations (methods.ts) and their request-argument interfaces (types/request/agents.ts) alphabetically: archive, create, getCanvas, listViews, removeView, setCanvasContent, setCommands, setProperties, setView. Pure reorder; tsc --noEmit clean. Co-Authored-By: Claude Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/web-api/src/methods.ts | 64 +++++----- packages/web-api/src/types/request/agents.ts | 116 +++++++++---------- 2 files changed, 90 insertions(+), 90 deletions(-) diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 95a37b5c1..a83078c8b 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -1400,14 +1400,6 @@ export abstract class Methods extends EventEmitter { public readonly agents = { conversations: { - /** - * @description Create a dedicated code channel for an agent session. - * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.create `agents.conversations.create` API reference}. - */ - create: bindApiCallWithOptionalArgument( - this, - 'agents.conversations.create', - ), /** * @description Archive a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.archive `agents.conversations.archive` API reference}. @@ -1417,28 +1409,20 @@ export abstract class Methods extends EventEmitter { 'agents.conversations.archive', ), /** - * @description Set properties on a code channel. - * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setProperties `agents.conversations.setProperties` API reference}. - */ - setProperties: bindApiCallWithOptionalArgument< - AgentsConversationsSetPropertiesArguments, - AgentsConversationsSetPropertiesResponse - >(this, 'agents.conversations.setProperties'), - /** - * @description Create or update a view in a code channel. - * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setView `agents.conversations.setView` API reference}. + * @description Create a dedicated code channel for an agent session. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.create `agents.conversations.create` API reference}. */ - setView: bindApiCallWithOptionalArgument( + create: bindApiCallWithOptionalArgument( this, - 'agents.conversations.setView', + 'agents.conversations.create', ), /** - * @description Register the set of agent-defined slash commands for the calling agent in a code channel. - * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCommands `agents.conversations.setCommands` API reference}. + * @description Fetch a canvas attached to a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.getCanvas `agents.conversations.getCanvas` API reference}. */ - setCommands: bindApiCall( + getCanvas: bindApiCall( this, - 'agents.conversations.setCommands', + 'agents.conversations.getCanvas', ), /** * @description List the views currently attached to a code channel. @@ -1456,14 +1440,6 @@ export abstract class Methods extends EventEmitter { AgentsConversationsRemoveViewArguments, AgentsConversationsRemoveViewResponse >(this, 'agents.conversations.removeView'), - /** - * @description Fetch a canvas attached to a code channel. - * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.getCanvas `agents.conversations.getCanvas` API reference}. - */ - getCanvas: bindApiCall( - this, - 'agents.conversations.getCanvas', - ), /** * @description Replace the full markdown content of a plan canvas attached to a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent `agents.conversations.setCanvasContent` API reference}. @@ -1472,6 +1448,30 @@ export abstract class Methods extends EventEmitter { AgentsConversationsSetCanvasContentArguments, AgentsConversationsSetCanvasContentResponse >(this, 'agents.conversations.setCanvasContent'), + /** + * @description Register the set of agent-defined slash commands for the calling agent in a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCommands `agents.conversations.setCommands` API reference}. + */ + setCommands: bindApiCall( + this, + 'agents.conversations.setCommands', + ), + /** + * @description Set properties on a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setProperties `agents.conversations.setProperties` API reference}. + */ + setProperties: bindApiCallWithOptionalArgument< + AgentsConversationsSetPropertiesArguments, + AgentsConversationsSetPropertiesResponse + >(this, 'agents.conversations.setProperties'), + /** + * @description Create or update a view in a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setView `agents.conversations.setView` API reference}. + */ + setView: bindApiCallWithOptionalArgument( + this, + 'agents.conversations.setView', + ), }, sessions: { /** diff --git a/packages/web-api/src/types/request/agents.ts b/packages/web-api/src/types/request/agents.ts index 18a91a0cf..e739a1a88 100644 --- a/packages/web-api/src/types/request/agents.ts +++ b/packages/web-api/src/types/request/agents.ts @@ -56,6 +56,17 @@ export interface AgentsSessionsSetStatusArguments extends TokenOverridable { username?: string; } +// https://docs.slack.dev/reference/methods/agents.conversations.archive +export interface AgentsConversationsArchiveArguments extends TokenOverridable { + /** @description ID of the code channel to archive. */ + channel_id: string; + /** + * @description Timestamp of a message in the code channel to share back as a thread reply on the origin message. + * Requires the channel to have an `origin_link`. + */ + summary_message_ts?: string; +} + // https://docs.slack.dev/reference/methods/agents.conversations.create export interface AgentsConversationsCreateArguments extends TokenOverridable { /** @@ -87,15 +98,56 @@ export interface AgentsConversationsCreateArguments extends TokenOverridable { origin_message_ts?: string; } -// https://docs.slack.dev/reference/methods/agents.conversations.archive -export interface AgentsConversationsArchiveArguments extends TokenOverridable { - /** @description ID of the code channel to archive. */ +// https://docs.slack.dev/reference/methods/agents.conversations.getCanvas +export interface AgentsConversationsGetCanvasArguments extends TokenOverridable { + /** @description ID of the agent session channel the canvas belongs to. */ + channel: string; + /** @description Encoded ID of the canvas to fetch. */ + canvas_id: string; + /** @description Format to render the canvas content in. Defaults to `markdown`. */ + content_format?: string; + /** @description Whether to include resolved comment threads in the response. Defaults to `false`. */ + include_resolved?: boolean; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.listViews +export interface AgentsConversationsListViewsArguments extends TokenOverridable { + /** @description ID of the code channel to list views for. */ channel_id: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.removeView +export interface AgentsConversationsRemoveViewArguments extends TokenOverridable { + /** @description ID of the code channel to remove the view from. */ + channel_id: string; + /** @description Agent-assigned key of the view to remove. Provide exactly one of `view_key` or `view_id`. */ + view_key?: string; + /** @description Encoded channel tab ID of the view to remove. Provide exactly one of `view_key` or `view_id`. */ + view_id?: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent +export interface AgentsConversationsSetCanvasContentArguments extends TokenOverridable { + /** @description ID of the agent session channel the canvas is attached to. */ + channel: string; + /** @description Encoded ID of the canvas whose content to replace. */ + canvas_id: string; /** - * @description Timestamp of a message in the code channel to share back as a thread reply on the origin message. - * Requires the channel to have an `origin_link`. + * @description The full new canvas content as markdown. The server diffs this against the current content and applies + * only the changed sections. */ - summary_message_ts?: string; + content: string; +} + +// https://docs.slack.dev/reference/methods/agents.conversations.setCommands +export interface AgentsConversationsSetCommandsArguments extends TokenOverridable { + /** @description ID of the code channel to register commands for. */ + channel_id: string; + /** + * @description Full set of commands to register for the calling agent in this channel, replacing that agent's + * previously registered set. Pass an empty array to clear the agent's commands. + */ + commands: Record[]; } // https://docs.slack.dev/reference/methods/agents.conversations.setProperties @@ -168,55 +220,3 @@ export interface AgentsConversationsSetViewArguments extends TokenOverridable { */ csp?: Record; } - -// https://docs.slack.dev/reference/methods/agents.conversations.setCommands -export interface AgentsConversationsSetCommandsArguments extends TokenOverridable { - /** @description ID of the code channel to register commands for. */ - channel_id: string; - /** - * @description Full set of commands to register for the calling agent in this channel, replacing that agent's - * previously registered set. Pass an empty array to clear the agent's commands. - */ - commands: Record[]; -} - -// https://docs.slack.dev/reference/methods/agents.conversations.listViews -export interface AgentsConversationsListViewsArguments extends TokenOverridable { - /** @description ID of the code channel to list views for. */ - channel_id: string; -} - -// https://docs.slack.dev/reference/methods/agents.conversations.removeView -export interface AgentsConversationsRemoveViewArguments extends TokenOverridable { - /** @description ID of the code channel to remove the view from. */ - channel_id: string; - /** @description Agent-assigned key of the view to remove. Provide exactly one of `view_key` or `view_id`. */ - view_key?: string; - /** @description Encoded channel tab ID of the view to remove. Provide exactly one of `view_key` or `view_id`. */ - view_id?: string; -} - -// https://docs.slack.dev/reference/methods/agents.conversations.getCanvas -export interface AgentsConversationsGetCanvasArguments extends TokenOverridable { - /** @description ID of the agent session channel the canvas belongs to. */ - channel: string; - /** @description Encoded ID of the canvas to fetch. */ - canvas_id: string; - /** @description Format to render the canvas content in. Defaults to `markdown`. */ - content_format?: string; - /** @description Whether to include resolved comment threads in the response. Defaults to `false`. */ - include_resolved?: boolean; -} - -// https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent -export interface AgentsConversationsSetCanvasContentArguments extends TokenOverridable { - /** @description ID of the agent session channel the canvas is attached to. */ - channel: string; - /** @description Encoded ID of the canvas whose content to replace. */ - canvas_id: string; - /** - * @description The full new canvas content as markdown. The server diffs this against the current content and applies - * only the changed sections. - */ - content: string; -} From 9a1fec4a5835c6a9f3838afad678513dd8685b96 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 25 Sep 2026 14:47:43 -0700 Subject: [PATCH 4/4] fix(web-api): require the argument for agents.conversations methods + add type tests Six agents.conversations methods (archive, create, listViews, removeView, setProperties, setView) were bound with bindApiCallWithOptionalArgument, so calling them with no argument type-checked despite channel_id/name being required. Switch all nine to bindApiCall (required argument) for parity with getCanvas/setCanvasContent/setCommands, and add test/types/methods/agents.test-d.ts covering the sad/happy paths for each (tsd clean; tsc --noEmit clean). Co-Authored-By: Claude Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/web-api/src/methods.ts | 32 +-- .../test/types/methods/agents.test-d.ts | 192 ++++++++++++++++++ 2 files changed, 208 insertions(+), 16 deletions(-) create mode 100644 packages/web-api/test/types/methods/agents.test-d.ts diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index a83078c8b..cb781b931 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -1404,7 +1404,7 @@ export abstract class Methods extends EventEmitter { * @description Archive a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.archive `agents.conversations.archive` API reference}. */ - archive: bindApiCallWithOptionalArgument( + archive: bindApiCall( this, 'agents.conversations.archive', ), @@ -1412,7 +1412,7 @@ export abstract class Methods extends EventEmitter { * @description Create a dedicated code channel for an agent session. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.create `agents.conversations.create` API reference}. */ - create: bindApiCallWithOptionalArgument( + create: bindApiCall( this, 'agents.conversations.create', ), @@ -1428,18 +1428,18 @@ export abstract class Methods extends EventEmitter { * @description List the views currently attached to a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.listViews `agents.conversations.listViews` API reference}. */ - listViews: bindApiCallWithOptionalArgument< - AgentsConversationsListViewsArguments, - AgentsConversationsListViewsResponse - >(this, 'agents.conversations.listViews'), + listViews: bindApiCall( + this, + 'agents.conversations.listViews', + ), /** * @description Remove a view from a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.removeView `agents.conversations.removeView` API reference}. */ - removeView: bindApiCallWithOptionalArgument< - AgentsConversationsRemoveViewArguments, - AgentsConversationsRemoveViewResponse - >(this, 'agents.conversations.removeView'), + removeView: bindApiCall( + this, + 'agents.conversations.removeView', + ), /** * @description Replace the full markdown content of a plan canvas attached to a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent `agents.conversations.setCanvasContent` API reference}. @@ -1460,15 +1460,15 @@ export abstract class Methods extends EventEmitter { * @description Set properties on a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setProperties `agents.conversations.setProperties` API reference}. */ - setProperties: bindApiCallWithOptionalArgument< - AgentsConversationsSetPropertiesArguments, - AgentsConversationsSetPropertiesResponse - >(this, 'agents.conversations.setProperties'), + setProperties: bindApiCall( + this, + 'agents.conversations.setProperties', + ), /** * @description Create or update a view in a code channel. * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.setView `agents.conversations.setView` API reference}. */ - setView: bindApiCallWithOptionalArgument( + setView: bindApiCall( this, 'agents.conversations.setView', ), @@ -1707,7 +1707,7 @@ export abstract class Methods extends EventEmitter { * @description Create Canvas for a user. * @see {@link https://docs.slack.dev/reference/methods/canvases.create `canvases.create` API reference}. */ - create: bindApiCallWithOptionalArgument(this, 'canvases.create'), + create: bindApiCall(this, 'canvases.create'), /** * @description Deletes a canvas. * @see {@link https://docs.slack.dev/reference/methods/canvases.delete `canvases.delete` API reference}. diff --git a/packages/web-api/test/types/methods/agents.test-d.ts b/packages/web-api/test/types/methods/agents.test-d.ts new file mode 100644 index 000000000..986c9309a --- /dev/null +++ b/packages/web-api/test/types/methods/agents.test-d.ts @@ -0,0 +1,192 @@ +import { expectAssignable, expectError } from 'tsd'; +import { WebClient } from '../../../src/WebClient'; + +const web = new WebClient('TOKEN'); + +// agents.conversations.archive +// -- sad path +expectError(web.agents.conversations.archive()); // lacking argument +expectError(web.agents.conversations.archive({})); // missing channel_id +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + }, +]); +expectAssignable>([ + { + channel_id: 'C9876543210', + summary_message_ts: '1717182000.456789', + }, +]); + +// agents.conversations.create +// -- sad path +expectError(web.agents.conversations.create()); // lacking argument +expectError(web.agents.conversations.create({})); // missing name +// -- happy path +expectAssignable>([ + { + name: 'Migrate billing cron to Temporal', + }, +]); +expectAssignable>([ + { + name: 'Migrate billing cron to Temporal', + session_id: 'ses_8675309', + origin_channel_id: 'C0123456789', + origin_message_ts: '1717171717.123456', + }, +]); + +// agents.conversations.getCanvas +// -- sad path +expectError(web.agents.conversations.getCanvas()); // lacking argument +expectError(web.agents.conversations.getCanvas({})); // missing channel and canvas_id +expectError( + web.agents.conversations.getCanvas({ + channel: 'C9876543210', // missing canvas_id + }), + web.agents.conversations.getCanvas({ + canvas_id: 'F1234567890', // missing channel + }), +); +// -- happy path +expectAssignable>([ + { + channel: 'C9876543210', + canvas_id: 'F1234567890', + }, +]); +expectAssignable>([ + { + channel: 'C9876543210', + canvas_id: 'F1234567890', + include_resolved: false, + }, +]); + +// agents.conversations.listViews +// -- sad path +expectError(web.agents.conversations.listViews()); // lacking argument +expectError(web.agents.conversations.listViews({})); // missing channel_id +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + }, +]); + +// agents.conversations.removeView +// -- sad path +expectError(web.agents.conversations.removeView()); // lacking argument +expectError(web.agents.conversations.removeView({})); // missing channel_id +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + view_key: 'reports/coverage.html', + }, +]); +expectAssignable>([ + { + channel_id: 'C9876543210', + view_id: 'Ct1234567890', + }, +]); + +// agents.conversations.setCanvasContent +// -- sad path +expectError(web.agents.conversations.setCanvasContent()); // lacking argument +expectError(web.agents.conversations.setCanvasContent({})); // missing channel, canvas_id, content +expectError( + web.agents.conversations.setCanvasContent({ + channel: 'C9876543210', // missing canvas_id and content + }), + web.agents.conversations.setCanvasContent({ + channel: 'C9876543210', // missing content + canvas_id: 'F1234567890', + }), +); +// -- happy path +expectAssignable>([ + { + channel: 'C9876543210', + canvas_id: 'F1234567890', + content: '# Migration plan\n\n1. Inventory cron jobs\n2. Port billing jobs last\n', + }, +]); + +// agents.conversations.setCommands +// -- sad path +expectError(web.agents.conversations.setCommands()); // lacking argument +expectError(web.agents.conversations.setCommands({})); // missing channel_id and commands +expectError( + web.agents.conversations.setCommands({ + channel_id: 'C9876543210', // missing commands + }), +); +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + commands: [], + }, +]); +expectAssignable>([ + { + 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' }, + ], + }, +]); + +// agents.conversations.setProperties +// -- sad path +expectError(web.agents.conversations.setProperties()); // lacking argument +expectError(web.agents.conversations.setProperties({})); // missing channel_id +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + }, +]); +expectAssignable>([ + { + channel_id: 'C9876543210', + code_channel: { + context_bar_items: [ + { key: 'repo', label: 'borant/billing', icon: 'folder', url: 'https://github.com/borant/billing' }, + ], + }, + }, +]); + +// agents.conversations.setView +// -- sad path +expectError(web.agents.conversations.setView()); // lacking argument +expectError(web.agents.conversations.setView({})); // missing channel_id +// -- happy path +expectAssignable>([ + { + channel_id: 'C9876543210', + view_key: 'reports/coverage.html', + name: 'Coverage', + content: '', + csp: { + resource_domains: ['https://cdn.jsdelivr.net'], + }, + }, +]); +expectAssignable>([ + { + channel_id: 'C9876543210', + type: 'diff', + content: 'diff --git a/cron.py b/cron.py\n--- a/cron.py\n+++ b/cron.py\n@@ ...', + base_branch: 'main', + head_branch: 'agent/migrate-cron', + }, +]);