@cuylabs/channel-slack 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ import { d as SlackArtifactClient } from '../types-C8nkPuD4.js';
2
+
3
+ /**
4
+ * Slack response-sink contracts consumed by the event bridge.
5
+ *
6
+ * The adapter constructs a `SlackResponseSink` from the Bolt `say` function
7
+ * and `WebClient` instance available in each handler. Keeping the sink
8
+ * interface separate makes the bridge testable without a live Slack
9
+ * connection.
10
+ */
11
+
12
+ type SlackStreamTaskStatus = "pending" | "in_progress" | "complete" | "error";
13
+ type SlackStreamChunk = {
14
+ type: "markdown_text";
15
+ text: string;
16
+ } | {
17
+ type: "plan_update";
18
+ title: string;
19
+ } | {
20
+ type: "task_update";
21
+ id: string;
22
+ title: string;
23
+ status: SlackStreamTaskStatus;
24
+ details?: string;
25
+ output?: string;
26
+ };
27
+ interface SlackChatStream {
28
+ append(args: {
29
+ markdown_text?: string;
30
+ chunks?: SlackStreamChunk[];
31
+ }): Promise<unknown>;
32
+ stop(args?: {
33
+ markdown_text?: string;
34
+ chunks?: SlackStreamChunk[];
35
+ }): Promise<unknown>;
36
+ }
37
+ /**
38
+ * Minimal Slack posting interface consumed by the event bridge.
39
+ */
40
+ interface SlackArtifactPublicationTarget {
41
+ channelId: string;
42
+ threadTs?: string;
43
+ }
44
+ interface SlackResponseSink {
45
+ /**
46
+ * Slack Web API surface used by optional artifact publishers.
47
+ */
48
+ artifactClient?: SlackArtifactClient;
49
+ /**
50
+ * Channel/thread target used by optional artifact publishers.
51
+ */
52
+ artifactTarget?: SlackArtifactPublicationTarget;
53
+ /**
54
+ * Post a new message to the channel / thread.
55
+ * Returns the channel ID and message timestamp needed for updates.
56
+ */
57
+ postMessage(text: string): Promise<{
58
+ channel: string;
59
+ ts: string;
60
+ }>;
61
+ /**
62
+ * Update an existing message by channel + ts.
63
+ */
64
+ updateMessage(channel: string, ts: string, text: string): Promise<void>;
65
+ /**
66
+ * Create a native Slack chat stream. Required when `streamingMode` is
67
+ * `"chat-stream"`.
68
+ */
69
+ createChatStream?(options: {
70
+ bufferSize: number;
71
+ }): SlackChatStream;
72
+ }
73
+
74
+ export type { SlackArtifactPublicationTarget, SlackChatStream, SlackResponseSink, SlackStreamChunk, SlackStreamTaskStatus };
File without changes
@@ -0,0 +1,51 @@
1
+ import { SectionBlock, ActionsBlock, KnownBlock } from '@slack/types';
2
+ import { App } from '@slack/bolt';
3
+
4
+ declare const SLACK_TURN_CANCEL_ACTION_ID = "agent_turn_cancel";
5
+ interface SlackTurnCancelButtonValue {
6
+ action: "cancel";
7
+ controlId: string;
8
+ sessionId?: string;
9
+ turnId?: string;
10
+ }
11
+ interface SlackTurnCancelMessageOptions {
12
+ controlId: string;
13
+ actionId?: string;
14
+ buttonText?: string;
15
+ messageText?: string;
16
+ sessionId?: string;
17
+ turnId?: string;
18
+ }
19
+ interface SlackTurnCancelMessage {
20
+ text: string;
21
+ blocks: [SectionBlock, ActionsBlock];
22
+ }
23
+ declare function createSlackTurnCancelMessage(options: SlackTurnCancelMessageOptions): SlackTurnCancelMessage;
24
+ declare function encodeSlackTurnCancelButtonValue(value: SlackTurnCancelButtonValue): string;
25
+ declare function decodeSlackTurnCancelButtonValue(rawValue: unknown): SlackTurnCancelButtonValue | undefined;
26
+ declare function resolveSlackTurnCancelActionId(actionId?: string): string;
27
+
28
+ interface SlackTurnCancelActionContext extends SlackTurnCancelButtonValue {
29
+ channelId: string;
30
+ userId: string;
31
+ messageTs: string;
32
+ threadTs?: string;
33
+ teamId?: string;
34
+ triggerId?: string;
35
+ acknowledgeEphemeral: (text: string) => Promise<void>;
36
+ deleteMessage: () => Promise<void>;
37
+ updateMessage: (message: {
38
+ text: string;
39
+ blocks?: KnownBlock[];
40
+ }) => Promise<void>;
41
+ }
42
+ type SlackTurnCancelActionHandler = (context: SlackTurnCancelActionContext) => void | Promise<void>;
43
+ interface RegisterSlackTurnCancelActionOptions {
44
+ actionId?: string;
45
+ onCancel: SlackTurnCancelActionHandler;
46
+ }
47
+ declare function registerSlackTurnCancelAction(app: App, options: RegisterSlackTurnCancelActionOptions): {
48
+ actionId: string;
49
+ };
50
+
51
+ export { type RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, type SlackTurnCancelActionContext, type SlackTurnCancelActionHandler, type SlackTurnCancelButtonValue, type SlackTurnCancelMessage, type SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId };
@@ -0,0 +1,16 @@
1
+ import {
2
+ SLACK_TURN_CANCEL_ACTION_ID,
3
+ createSlackTurnCancelMessage,
4
+ decodeSlackTurnCancelButtonValue,
5
+ encodeSlackTurnCancelButtonValue,
6
+ registerSlackTurnCancelAction,
7
+ resolveSlackTurnCancelActionId
8
+ } from "../chunk-3KP3CBCC.js";
9
+ export {
10
+ SLACK_TURN_CANCEL_ACTION_ID,
11
+ createSlackTurnCancelMessage,
12
+ decodeSlackTurnCancelButtonValue,
13
+ encodeSlackTurnCancelButtonValue,
14
+ registerSlackTurnCancelAction,
15
+ resolveSlackTurnCancelActionId
16
+ };
@@ -0,0 +1,111 @@
1
+ type SlackArtifactPublishMethod = "message" | "file" | "canvas";
2
+ type SlackArtifactBinaryData = string | Uint8Array | ArrayBuffer;
3
+ interface SlackArtifactBase {
4
+ kind: string;
5
+ title: string;
6
+ summary?: string;
7
+ metadata?: Record<string, unknown>;
8
+ }
9
+ interface SlackTextArtifact extends SlackArtifactBase {
10
+ kind: "text";
11
+ text: string;
12
+ filename?: string;
13
+ mimeType?: string;
14
+ publishAs?: "message" | "file";
15
+ }
16
+ interface SlackFileArtifact extends SlackArtifactBase {
17
+ kind: "file";
18
+ filename: string;
19
+ data?: SlackArtifactBinaryData;
20
+ filePath?: string;
21
+ mimeType?: string;
22
+ initialComment?: string;
23
+ }
24
+ interface SlackImageArtifact extends SlackArtifactBase {
25
+ kind: "image";
26
+ filename: string;
27
+ altText: string;
28
+ data?: SlackArtifactBinaryData;
29
+ filePath?: string;
30
+ initialComment?: string;
31
+ }
32
+ interface SlackLinkArtifact extends SlackArtifactBase {
33
+ kind: "link";
34
+ url: string;
35
+ }
36
+ interface SlackCanvasArtifact extends SlackArtifactBase {
37
+ kind: "canvas";
38
+ markdown: string;
39
+ /**
40
+ * When set, updates an existing canvas instead of creating one.
41
+ */
42
+ canvasId?: string;
43
+ /**
44
+ * Create a channel canvas when a channel is available.
45
+ *
46
+ * @default true
47
+ */
48
+ channelCanvas?: boolean;
49
+ }
50
+ type SlackArtifact = SlackTextArtifact | SlackFileArtifact | SlackImageArtifact | SlackLinkArtifact | SlackCanvasArtifact;
51
+ interface SlackArtifactPostMessageResponse {
52
+ ok?: boolean;
53
+ channel?: string;
54
+ ts?: string;
55
+ [key: string]: unknown;
56
+ }
57
+ interface SlackArtifactFileUploadResponse {
58
+ ok?: boolean;
59
+ file?: {
60
+ id?: string;
61
+ [key: string]: unknown;
62
+ };
63
+ files?: Array<{
64
+ id?: string;
65
+ [key: string]: unknown;
66
+ }>;
67
+ [key: string]: unknown;
68
+ }
69
+ interface SlackArtifactCanvasResponse {
70
+ ok?: boolean;
71
+ canvas_id?: string;
72
+ [key: string]: unknown;
73
+ }
74
+ interface SlackArtifactClient {
75
+ chat?: {
76
+ postMessage(args: Record<string, unknown>): Promise<SlackArtifactPostMessageResponse>;
77
+ };
78
+ files?: {
79
+ uploadV2(args: Record<string, unknown>): Promise<SlackArtifactFileUploadResponse>;
80
+ };
81
+ canvases?: {
82
+ create(args?: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
83
+ edit?(args: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
84
+ };
85
+ conversations?: {
86
+ canvases?: {
87
+ create(args: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
88
+ };
89
+ };
90
+ }
91
+ interface PublishSlackArtifactOptions {
92
+ client: SlackArtifactClient;
93
+ artifact: SlackArtifact;
94
+ channelId?: string;
95
+ threadTs?: string;
96
+ token?: string;
97
+ unfurlLinks?: boolean;
98
+ unfurlMedia?: boolean;
99
+ }
100
+ interface SlackArtifactPublication {
101
+ artifact: SlackArtifact;
102
+ method: SlackArtifactPublishMethod;
103
+ response: unknown;
104
+ channelId?: string;
105
+ threadTs?: string;
106
+ messageTs?: string;
107
+ fileId?: string;
108
+ canvasId?: string;
109
+ }
110
+
111
+ export type { PublishSlackArtifactOptions as P, SlackArtifact as S, SlackArtifactBase as a, SlackArtifactBinaryData as b, SlackArtifactCanvasResponse as c, SlackArtifactClient as d, SlackArtifactFileUploadResponse as e, SlackArtifactPostMessageResponse as f, SlackArtifactPublication as g, SlackArtifactPublishMethod as h, SlackCanvasArtifact as i, SlackFileArtifact as j, SlackImageArtifact as k, SlackLinkArtifact as l, SlackTextArtifact as m };
@@ -24,6 +24,9 @@ contracts.
24
24
  - User profile and mention helpers.
25
25
  - Target parsing and resolution.
26
26
  - Feedback blocks and action handler.
27
+ - Slack response sink and chat stream contracts for runtime adapters.
28
+ - Slack interactive request Block Kit/modal builders and in-memory/Postgres
29
+ stores.
27
30
  - Slack message policy resolver and in-memory/Postgres state stores.
28
31
  - Supplemental history reader, context loader, and visibility policy.
29
32
  - Assistant message parser and thread-context store.
@@ -33,8 +36,8 @@ contracts.
33
36
  - Agent runtime execution.
34
37
  - Agent-runtime scopes and context-fragment middleware.
35
38
  - Runtime-specific mapping from Slack entrypoints into an agent turn.
36
- - Agent event stream rendering.
37
- - Agent-specific approval and human-input request contracts.
39
+ - Agent event stream rendering and runtime-specific response orchestration.
40
+ - Agent-specific approval and human-input controllers.
38
41
  - Product prompts, tools, audit policy, and deployment policy.
39
42
 
40
43
  Those pieces belong in runtime-specific adapters or product applications.
@@ -8,9 +8,11 @@ keep application code close to the package boundary it uses.
8
8
  | `@cuylabs/channel-slack/core` | no Slack SDK runtime imports | Transport-neutral parsing, formatting, types, sessions, turn context |
9
9
  | `@cuylabs/channel-slack/policy` | `pg` only when using connection-string Postgres state | Message admission and in-memory/Postgres policy state |
10
10
  | `@cuylabs/channel-slack/history` | `@slack/web-api` types | History reader accepts a Slack WebClient or minimal conversations client |
11
+ | `@cuylabs/channel-slack/interactive` | `@slack/types`; `pg` only when using connection-string Postgres storage | Slack interactive Block Kit/modal builders and request stores |
11
12
  | `@cuylabs/channel-slack/app-home` | `@slack/bolt`, `@slack/types` | Slack App Home registration helper |
12
13
  | `@cuylabs/channel-slack/artifacts` | no Slack SDK runtime imports; requires a Web API-like client at call time | Text, file, image, link, and Canvas artifact publishing |
13
14
  | `@cuylabs/channel-slack/auth` | no Slack SDK runtime imports; `pg` is not required | Auth option types, auth resolution, OAuth installation stores |
15
+ | `@cuylabs/channel-slack/responses` | no Slack SDK runtime imports | Slack response sink and chat stream contracts for runtime adapters |
14
16
  | `@cuylabs/channel-slack/transports` | `@slack/bolt`, `express`; `pg` only when using connection-string Postgres locks | HTTP and Socket Mode transport helpers |
15
17
  | `@cuylabs/channel-slack/transports/http` | `@slack/bolt`, `express` | HTTP Events API Bolt app factory |
16
18
  | `@cuylabs/channel-slack/transports/socket` | `@slack/bolt`; `pg` only when using connection-string Postgres locks | Socket Mode app factory, runtime guard, process/Postgres locks |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuylabs/channel-slack",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Agent-runtime-agnostic Slack channel primitives for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,11 +56,21 @@
56
56
  "import": "./dist/history/index.js",
57
57
  "default": "./dist/history/index.js"
58
58
  },
59
+ "./interactive": {
60
+ "types": "./dist/interactive/index.d.ts",
61
+ "import": "./dist/interactive/index.js",
62
+ "default": "./dist/interactive/index.js"
63
+ },
59
64
  "./policy": {
60
65
  "types": "./dist/policy/index.d.ts",
61
66
  "import": "./dist/policy/index.js",
62
67
  "default": "./dist/policy/index.js"
63
68
  },
69
+ "./responses": {
70
+ "types": "./dist/responses/index.d.ts",
71
+ "import": "./dist/responses/index.js",
72
+ "default": "./dist/responses/index.js"
73
+ },
64
74
  "./setup": {
65
75
  "types": "./dist/setup/index.d.ts",
66
76
  "import": "./dist/setup/index.js",
@@ -71,6 +81,11 @@
71
81
  "import": "./dist/targets/index.js",
72
82
  "default": "./dist/targets/index.js"
73
83
  },
84
+ "./turn-controls": {
85
+ "types": "./dist/turn-controls/index.d.ts",
86
+ "import": "./dist/turn-controls/index.js",
87
+ "default": "./dist/turn-controls/index.js"
88
+ },
74
89
  "./transports": {
75
90
  "types": "./dist/transports/index.d.ts",
76
91
  "import": "./dist/transports/index.js",
@@ -148,9 +163,9 @@
148
163
  "node": ">=20"
149
164
  },
150
165
  "scripts": {
151
- "build": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --clean",
166
+ "build": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/interactive/index.ts src/policy/index.ts src/responses/index.ts src/setup/index.ts src/targets/index.ts src/turn-controls/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --clean",
152
167
  "clean": "rm -rf dist",
153
- "dev": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --watch",
168
+ "dev": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/interactive/index.ts src/policy/index.ts src/responses/index.ts src/setup/index.ts src/targets/index.ts src/turn-controls/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --watch",
154
169
  "lint": "eslint \"src/**/*.{ts,tsx}\" \"tests/**/*.{ts,tsx}\" --max-warnings=0",
155
170
  "test": "vitest run",
156
171
  "test:watch": "vitest",
File without changes