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..cb781b931 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 Archive a code channel. + * @see {@link https://docs.slack.dev/reference/methods/agents.conversations.archive `agents.conversations.archive` API reference}. + */ + archive: bindApiCall( + this, + 'agents.conversations.archive', + ), + /** + * @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: bindApiCall( + this, + 'agents.conversations.create', + ), + /** + * @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 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: 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: 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}. + */ + setCanvasContent: bindApiCall< + 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: 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: bindApiCall( + this, + 'agents.conversations.setView', + ), + }, sessions: { /** * @description Rename an agent session. @@ -1615,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/src/types/request/agents.ts b/packages/web-api/src/types/request/agents.ts index 1d05f52c3..e739a1a88 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,168 @@ 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 { + /** + * @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.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 The full new canvas content as markdown. The server diffs this against the current content and applies + * only the changed sections. + */ + 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 +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; +} 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'; 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', + }, +]);