Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/agents-conversations-methods.md
Original file line number Diff line number Diff line change
@@ -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
94 changes: 93 additions & 1 deletion packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ import type {
AdminWorkflowsPermissionsLookupArguments,
AdminWorkflowsSearchArguments,
AdminWorkflowsUnpublishArguments,
AgentsConversationsArchiveArguments,
AgentsConversationsCreateArguments,
AgentsConversationsGetCanvasArguments,
AgentsConversationsListViewsArguments,
AgentsConversationsRemoveViewArguments,
AgentsConversationsSetCanvasContentArguments,
AgentsConversationsSetCommandsArguments,
AgentsConversationsSetPropertiesArguments,
AgentsConversationsSetViewArguments,
AgentsSessionsRenameArguments,
AgentsSessionsSetStatusArguments,
APITestArguments,
Expand Down Expand Up @@ -371,6 +380,15 @@ import type {
AdminWorkflowsPermissionsLookupResponse,
AdminWorkflowsSearchResponse,
AdminWorkflowsUnpublishResponse,
AgentsConversationsArchiveResponse,
AgentsConversationsCreateResponse,
AgentsConversationsGetCanvasResponse,
AgentsConversationsListViewsResponse,
AgentsConversationsRemoveViewResponse,
AgentsConversationsSetCanvasContentResponse,
AgentsConversationsSetCommandsResponse,
AgentsConversationsSetPropertiesResponse,
AgentsConversationsSetViewResponse,
AgentsSessionsRenameResponse,
AgentsSessionsSetStatusResponse,
ApiTestResponse,
Expand Down Expand Up @@ -1381,6 +1399,80 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
};

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<AgentsConversationsArchiveArguments, AgentsConversationsArchiveResponse>(
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<AgentsConversationsCreateArguments, AgentsConversationsCreateResponse>(
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<AgentsConversationsGetCanvasArguments, AgentsConversationsGetCanvasResponse>(
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<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: bindApiCall<AgentsConversationsRemoveViewArguments, AgentsConversationsRemoveViewResponse>(
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<AgentsConversationsSetCommandsArguments, AgentsConversationsSetCommandsResponse>(
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<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: bindApiCall<AgentsConversationsSetViewArguments, AgentsConversationsSetViewResponse>(
this,
'agents.conversations.setView',
),
},
sessions: {
/**
* @description Rename an agent session.
Expand Down Expand Up @@ -1615,7 +1707,7 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
* @description Create Canvas for a user.
* @see {@link https://docs.slack.dev/reference/methods/canvases.create `canvases.create` API reference}.
*/
create: bindApiCallWithOptionalArgument<CanvasesCreateArguments, CanvasesCreateResponse>(this, 'canvases.create'),
create: bindApiCall<CanvasesCreateArguments, CanvasesCreateResponse>(this, 'canvases.create'),
/**
* @description Deletes a canvas.
* @see {@link https://docs.slack.dev/reference/methods/canvases.delete `canvases.delete` API reference}.
Expand Down
167 changes: 167 additions & 0 deletions packages/web-api/src/types/request/agents.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<string, unknown>[];
}

// 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<string, unknown>;
/** @description Agent resource properties to set. Only provided fields are updated. */
agent_resource?: Record<string, unknown>;
}

// 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<string, unknown>;
}
14 changes: 13 additions & 1 deletion packages/web-api/src/types/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -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;
};
Loading
Loading