@cuylabs/channel-slack-agent-core 0.6.0 → 0.8.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.
Files changed (49) hide show
  1. package/README.md +7 -0
  2. package/dist/adapter/index.d.ts +6 -3
  3. package/dist/adapter/index.js +2 -2
  4. package/dist/{adapter-Cmd2C90g.d.ts → adapter-B3CI611y.d.ts} +1 -1
  5. package/dist/app-surface.d.ts +13 -3
  6. package/dist/app-surface.js +4 -4
  7. package/dist/app.d.ts +7 -3
  8. package/dist/app.js +5 -5
  9. package/dist/artifacts/index.d.ts +57 -0
  10. package/dist/artifacts/index.js +6 -0
  11. package/dist/assistant/index.d.ts +5 -3
  12. package/dist/assistant/index.js +2 -2
  13. package/dist/{chunk-FNT4TXNQ.js → chunk-236WN6JD.js} +1 -1
  14. package/dist/{chunk-5NQYLOAW.js → chunk-2R7B7NJR.js} +1 -1
  15. package/dist/{chunk-P7KK5GQG.js → chunk-6T6N4MRK.js} +13 -25
  16. package/dist/{chunk-ZDVD46RT.js → chunk-7YZWCSML.js} +263 -4
  17. package/dist/chunk-C7CHMYV6.js +226 -0
  18. package/dist/{chunk-TIQGJ52F.js → chunk-FQWFB54C.js} +14 -2
  19. package/dist/chunk-NNCVHQC4.js +94 -0
  20. package/dist/{chunk-VCXPNQRB.js → chunk-TCNJY7QA.js} +1 -1
  21. package/dist/{chunk-NOVWLAVP.js → chunk-TMADMHBN.js} +209 -20
  22. package/dist/{chunk-J6CW2RGO.js → chunk-X7ILLZZP.js} +359 -2
  23. package/dist/{chunk-QEJ7TAZJ.js → chunk-YSDFYHPC.js} +2 -2
  24. package/dist/express-assistant.d.ts +4 -2
  25. package/dist/express-assistant.js +3 -3
  26. package/dist/express.d.ts +5 -2
  27. package/dist/express.js +3 -3
  28. package/dist/history/index.d.ts +7 -3
  29. package/dist/index.d.ts +12 -6
  30. package/dist/index.js +28 -10
  31. package/dist/interactive/index.d.ts +43 -2
  32. package/dist/interactive/index.js +9 -3
  33. package/dist/{options-C7OYeNR-.d.ts → options-BcDReOJv.d.ts} +48 -0
  34. package/dist/{options-Uf-qmQKN.d.ts → options-C7-VXmhD.d.ts} +62 -2
  35. package/dist/shared/index.d.ts +20 -6
  36. package/dist/shared/index.js +1 -1
  37. package/dist/socket.d.ts +7 -3
  38. package/dist/socket.js +5 -5
  39. package/dist/{types-BqRzb_Cd.d.ts → types-CRWzJB5G.d.ts} +35 -0
  40. package/dist/types-CiwGU6zC.d.ts +56 -0
  41. package/dist/views/index.d.ts +8 -0
  42. package/dist/views/index.js +10 -0
  43. package/docs/README.md +7 -0
  44. package/docs/concepts/final-response-artifacts.md +39 -0
  45. package/docs/concepts/interactive-requests.md +43 -0
  46. package/docs/concepts/tool-task-rendering.md +46 -0
  47. package/docs/concepts/view-workflows.md +52 -0
  48. package/docs/reference/exports.md +18 -16
  49. package/package.json +14 -4
package/README.md CHANGED
@@ -22,6 +22,10 @@ Install Slack peer dependencies for the surfaces you use:
22
22
  npm install @slack/bolt @slack/web-api express
23
23
  ```
24
24
 
25
+ Postgres-backed interactive request storage lazy-loads `pg` when you pass a
26
+ connection string. Install `pg` only when your application uses that helper
27
+ without injecting its own client.
28
+
25
29
  ## Quick Start
26
30
 
27
31
  Socket Mode:
@@ -51,4 +55,7 @@ await mountSlackAgent(agent, {
51
55
 
52
56
  - [Package boundary](docs/reference/boundary.md)
53
57
  - [Exports and peer expectations](docs/reference/exports.md)
58
+ - [Interactive requests](docs/concepts/interactive-requests.md)
59
+ - [Final response artifacts](docs/concepts/final-response-artifacts.md)
60
+ - [Tool task rendering](docs/concepts/tool-task-rendering.md)
54
61
  - [Docs index](docs/README.md)
@@ -1,8 +1,11 @@
1
- export { c as createSlackChannelAdapter } from '../adapter-Cmd2C90g.js';
2
- import { a as SlackChannelOptions } from '../types-BqRzb_Cd.js';
3
- export { S as SlackChannelAdapter, b as SlackSessionStrategy, c as SlackStreamingMode, d as SlackToolStartEvent } from '../types-BqRzb_Cd.js';
1
+ export { c as createSlackChannelAdapter } from '../adapter-B3CI611y.js';
2
+ import { a as SlackChannelOptions } from '../types-CRWzJB5G.js';
3
+ export { S as SlackChannelAdapter, b as SlackSessionStrategy, c as SlackStreamingMode, d as SlackToolStartEvent } from '../types-CRWzJB5G.js';
4
4
  import { SlackActivityInfo } from '@cuylabs/channel-slack/core';
5
5
  import '@cuylabs/agent-core';
6
+ import '../options-BcDReOJv.js';
7
+ import '../artifacts/index.js';
8
+ import '@cuylabs/channel-slack/artifacts';
6
9
  import '../interactive-o_NZb-Xg.js';
7
10
 
8
11
  /**
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createSlackChannelAdapter,
3
3
  createSlackSessionMap
4
- } from "../chunk-TIQGJ52F.js";
5
- import "../chunk-NOVWLAVP.js";
4
+ } from "../chunk-FQWFB54C.js";
5
+ import "../chunk-TMADMHBN.js";
6
6
  export {
7
7
  createSlackChannelAdapter,
8
8
  createSlackSessionMap
@@ -1,4 +1,4 @@
1
- import { a as SlackChannelOptions, S as SlackChannelAdapter } from './types-BqRzb_Cd.js';
1
+ import { a as SlackChannelOptions, S as SlackChannelAdapter } from './types-CRWzJB5G.js';
2
2
 
3
3
  /**
4
4
  * Slack Channel Adapter
@@ -1,14 +1,18 @@
1
1
  import { AgentTurnSource, Logger } from '@cuylabs/agent-core';
2
2
  import { App } from '@slack/bolt';
3
3
  import { WebClient } from '@slack/web-api';
4
- import { C as CreateSlackAssistantBridgeOptions, b as SlackAssistantFeedbackConfig, S as SlackAssistantBridge } from './options-Uf-qmQKN.js';
5
- import { a as SlackChannelOptions } from './types-BqRzb_Cd.js';
4
+ import { C as CreateSlackAssistantBridgeOptions, d as SlackAssistantFeedbackConfig, S as SlackAssistantBridge } from './options-C7-VXmhD.js';
5
+ import { a as SlackChannelOptions } from './types-CRWzJB5G.js';
6
6
  import { SlackTurnRequestContext, SlackAssistantUtilities, SlackTurnPreparation } from '@cuylabs/channel-slack/core';
7
7
  import { SlackFeedbackHandler } from '@cuylabs/channel-slack/feedback';
8
8
  import { c as SlackInteractiveController } from './types-Crpil4kb.js';
9
+ import { d as SlackAgentViewWorkflowController } from './types-CiwGU6zC.js';
9
10
  import './interactive-o_NZb-Xg.js';
10
- import './options-C7OYeNR-.js';
11
+ import './options-BcDReOJv.js';
12
+ import './artifacts/index.js';
13
+ import '@cuylabs/channel-slack/artifacts';
11
14
  import '@cuylabs/channel-slack/assistant';
15
+ import '@cuylabs/channel-slack/views';
12
16
 
13
17
  /**
14
18
  * Shared installer for the direct Slack app surfaces.
@@ -62,6 +66,12 @@ interface SlackAgentAppSurfaceOptions extends Omit<CreateSlackAssistantBridgeOpt
62
66
  * the agent config, or with `interactive.onResolve` for server-backed turns.
63
67
  */
64
68
  interactive?: SlackInteractiveController;
69
+ /**
70
+ * Product/agent Slack modal workflow controller. Use this for workflows that
71
+ * are richer than approval/human-input, such as incident triage forms or
72
+ * report-generation setup modals.
73
+ */
74
+ viewWorkflows?: SlackAgentViewWorkflowController;
65
75
  }
66
76
  interface SlackAgentAppSurfaceResult {
67
77
  bridge: SlackAssistantBridge;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  installSlackAgentAppSurface
3
- } from "./chunk-P7KK5GQG.js";
4
- import "./chunk-ZDVD46RT.js";
3
+ } from "./chunk-6T6N4MRK.js";
4
+ import "./chunk-7YZWCSML.js";
5
5
  import "./chunk-ELR6MQD7.js";
6
- import "./chunk-TIQGJ52F.js";
7
- import "./chunk-NOVWLAVP.js";
6
+ import "./chunk-FQWFB54C.js";
7
+ import "./chunk-TMADMHBN.js";
8
8
  export {
9
9
  installSlackAgentAppSurface
10
10
  };
package/dist/app.d.ts CHANGED
@@ -5,15 +5,19 @@ import { CreateSlackBoltAppOptions } from '@cuylabs/channel-slack/transports/htt
5
5
  import { SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/auth';
6
6
  import { SlackAgentAppSurfaceOptions } from './app-surface.js';
7
7
  export { MountSlackAgentAppTurnRequestContext } from './app-surface.js';
8
- import { S as SlackAssistantBridge } from './options-Uf-qmQKN.js';
8
+ import { S as SlackAssistantBridge } from './options-C7-VXmhD.js';
9
9
  import '@cuylabs/agent-core';
10
10
  import '@slack/web-api';
11
- import './types-BqRzb_Cd.js';
11
+ import './types-CRWzJB5G.js';
12
12
  import '@cuylabs/channel-slack/core';
13
+ import './options-BcDReOJv.js';
14
+ import './artifacts/index.js';
15
+ import '@cuylabs/channel-slack/artifacts';
13
16
  import './interactive-o_NZb-Xg.js';
14
17
  import '@cuylabs/channel-slack/feedback';
15
18
  import './types-Crpil4kb.js';
16
- import './options-C7OYeNR-.js';
19
+ import './types-CiwGU6zC.js';
20
+ import '@cuylabs/channel-slack/views';
17
21
  import '@cuylabs/channel-slack/assistant';
18
22
 
19
23
  /**
package/dist/app.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  mountSlackAgentApp
3
- } from "./chunk-FNT4TXNQ.js";
4
- import "./chunk-P7KK5GQG.js";
5
- import "./chunk-ZDVD46RT.js";
3
+ } from "./chunk-236WN6JD.js";
4
+ import "./chunk-6T6N4MRK.js";
5
+ import "./chunk-7YZWCSML.js";
6
6
  import "./chunk-ELR6MQD7.js";
7
- import "./chunk-TIQGJ52F.js";
8
- import "./chunk-NOVWLAVP.js";
7
+ import "./chunk-FQWFB54C.js";
8
+ import "./chunk-TMADMHBN.js";
9
9
  export {
10
10
  mountSlackAgentApp
11
11
  };
@@ -0,0 +1,57 @@
1
+ import { SlackArtifactClient, SlackArtifactPublication } from '@cuylabs/channel-slack/artifacts';
2
+
3
+ interface SlackFinalResponseArtifactContext {
4
+ text: string;
5
+ formattedText: string;
6
+ client: SlackArtifactClient;
7
+ channelId: string;
8
+ threadTs?: string;
9
+ }
10
+ interface SlackFinalResponseArtifactResult {
11
+ publication: SlackArtifactPublication;
12
+ }
13
+ type SlackFinalResponseArtifactDeliveryMode = "supplemental" | "replace";
14
+ type SlackFinalResponseArtifactPublisher = (context: SlackFinalResponseArtifactContext) => Promise<SlackFinalResponseArtifactResult | undefined>;
15
+ type SlackFinalResponseArtifactValueResolver<T> = T | ((context: SlackFinalResponseArtifactContext) => T | Promise<T>);
16
+ interface CreateSlackFinalResponseArtifactPublisherOptions {
17
+ /**
18
+ * Minimum raw-response characters required before publishing an artifact.
19
+ *
20
+ * @default 4000
21
+ */
22
+ minCharacters?: number;
23
+ /**
24
+ * Canvas/file title.
25
+ *
26
+ * @default "Agent response"
27
+ */
28
+ title?: SlackFinalResponseArtifactValueResolver<string | undefined>;
29
+ /**
30
+ * Optional Slack artifact summary.
31
+ */
32
+ summary?: SlackFinalResponseArtifactValueResolver<string | undefined>;
33
+ /**
34
+ * Prefer creating a channel canvas when the Slack client exposes
35
+ * `conversations.canvases.create`.
36
+ *
37
+ * @default true
38
+ */
39
+ channelCanvas?: boolean;
40
+ /**
41
+ * Fallback when Canvas publication fails.
42
+ *
43
+ * @default "file"
44
+ */
45
+ fallback?: "file" | "none";
46
+ /**
47
+ * Called after a Canvas or fallback file is published.
48
+ */
49
+ onPublished?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
50
+ /**
51
+ * Called when Canvas publication fails and no fallback publication succeeds.
52
+ */
53
+ onError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
54
+ }
55
+ declare function createSlackFinalResponseArtifactPublisher({ minCharacters, title, summary, channelCanvas, fallback, onPublished, onError, }?: CreateSlackFinalResponseArtifactPublisherOptions): SlackFinalResponseArtifactPublisher;
56
+
57
+ export { type CreateSlackFinalResponseArtifactPublisherOptions, type SlackFinalResponseArtifactContext, type SlackFinalResponseArtifactDeliveryMode, type SlackFinalResponseArtifactPublisher, type SlackFinalResponseArtifactResult, type SlackFinalResponseArtifactValueResolver, createSlackFinalResponseArtifactPublisher };
@@ -0,0 +1,6 @@
1
+ import {
2
+ createSlackFinalResponseArtifactPublisher
3
+ } from "../chunk-NNCVHQC4.js";
4
+ export {
5
+ createSlackFinalResponseArtifactPublisher
6
+ };
@@ -1,12 +1,14 @@
1
- import { C as CreateSlackAssistantBridgeOptions, S as SlackAssistantBridge } from '../options-Uf-qmQKN.js';
2
- export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, M as MaybePromise, b as SlackAssistantFeedbackConfig, c as SlackAssistantSessionStrategy, d as SlackAssistantStatusContext, e as SlackAssistantThreadContextStoreLike, f as SlackAssistantThreadStartedContext, g as SlackAssistantTurnPreparation, h as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from '../options-Uf-qmQKN.js';
1
+ import { C as CreateSlackAssistantBridgeOptions, S as SlackAssistantBridge } from '../options-C7-VXmhD.js';
2
+ export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, M as MaybePromise, b as SlackAssistantCancelControlOptions, c as SlackAssistantCancelControlVisibleWhen, d as SlackAssistantFeedbackConfig, e as SlackAssistantSessionStrategy, f as SlackAssistantStatusContext, g as SlackAssistantThreadContextStoreLike, h as SlackAssistantThreadStartedContext, i as SlackAssistantTurnCancelContext, j as SlackAssistantTurnControlsOptions, k as SlackAssistantTurnPreparation, l as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from '../options-C7-VXmhD.js';
3
3
  export { ParsedAssistantUserMessage, createSlackAssistantThreadContextStore, parseSlackMessageActivityFromMessageEvent } from '@cuylabs/channel-slack/assistant';
4
4
  import '@cuylabs/agent-core';
5
5
  import '@slack/bolt';
6
6
  import '@slack/web-api';
7
7
  import '@cuylabs/channel-slack/core';
8
8
  import '../interactive-o_NZb-Xg.js';
9
- import '../options-C7OYeNR-.js';
9
+ import '../options-BcDReOJv.js';
10
+ import '../artifacts/index.js';
11
+ import '@cuylabs/channel-slack/artifacts';
10
12
  import '@cuylabs/channel-slack/feedback';
11
13
 
12
14
  /**
@@ -3,9 +3,9 @@ import {
3
3
  createSlackAssistantThreadContextStore,
4
4
  parseSlackMessageActivityFromMessageEvent,
5
5
  resolveAssistantSessionId
6
- } from "../chunk-ZDVD46RT.js";
6
+ } from "../chunk-7YZWCSML.js";
7
7
  import "../chunk-ELR6MQD7.js";
8
- import "../chunk-NOVWLAVP.js";
8
+ import "../chunk-TMADMHBN.js";
9
9
  export {
10
10
  createSlackAssistantBridge,
11
11
  createSlackAssistantThreadContextStore,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  installSlackAgentAppSurface
3
- } from "./chunk-P7KK5GQG.js";
3
+ } from "./chunk-6T6N4MRK.js";
4
4
 
5
5
  // src/app.ts
6
6
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createSlackAssistantBridge
3
- } from "./chunk-ZDVD46RT.js";
3
+ } from "./chunk-7YZWCSML.js";
4
4
 
5
5
  // src/express-assistant.ts
6
6
  import {
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  createSlackAssistantBridge
3
- } from "./chunk-ZDVD46RT.js";
3
+ } from "./chunk-7YZWCSML.js";
4
4
  import {
5
- createSlackFeedbackBlock,
6
- registerSlackFeedbackAction
5
+ createSlackFeedbackBlock
7
6
  } from "./chunk-ELR6MQD7.js";
8
7
  import {
9
8
  createSlackChannelAdapter
10
- } from "./chunk-TIQGJ52F.js";
9
+ } from "./chunk-FQWFB54C.js";
11
10
 
12
11
  // src/app-surface.ts
13
12
  var DEFAULT_TIMEOUT_MS = 12e4;
@@ -26,6 +25,7 @@ function installSlackAgentAppSurface(boltApp, options) {
26
25
  prepareTurn,
27
26
  resolveSession,
28
27
  interactive,
28
+ viewWorkflows,
29
29
  ...assistantBridgeOptions
30
30
  } = options;
31
31
  const feedbackConfig = feedbackOption === false ? void 0 : feedbackOption ?? (onFeedback ? { onFeedback } : {});
@@ -48,7 +48,7 @@ function installSlackAgentAppSurface(boltApp, options) {
48
48
  ...resolveSession ? { resolveSession: toAssistantResolveSession(resolveSession) } : {},
49
49
  ...interactive ? { handleInteractiveRequest: interactive.handleInteractiveRequest } : {}
50
50
  });
51
- boltApp.assistant(bridge.assistant);
51
+ bridge.install(boltApp);
52
52
  const channelAdapter = createSlackChannelAdapter({
53
53
  source: channelSource,
54
54
  sessionStrategy: assistantBridgeOptions.sessionStrategy,
@@ -63,6 +63,7 @@ function installSlackAgentAppSurface(boltApp, options) {
63
63
  formatToolTitle: assistantBridgeOptions.formatToolTitle,
64
64
  formatToolUpdate: assistantBridgeOptions.formatToolUpdate,
65
65
  formatToolDetails: assistantBridgeOptions.formatToolDetails,
66
+ formatToolResultOutput: assistantBridgeOptions.formatToolResultOutput,
66
67
  formatToolError: assistantBridgeOptions.formatToolError,
67
68
  formatReasoningUpdate: assistantBridgeOptions.formatReasoningUpdate,
68
69
  chatStreamBufferSize: assistantBridgeOptions.chatStreamBufferSize,
@@ -70,6 +71,12 @@ function installSlackAgentAppSurface(boltApp, options) {
70
71
  ...assistantBridgeOptions.chatStreamStartArgs ?? {},
71
72
  task_display_mode: assistantBridgeOptions.taskDisplayMode ?? "timeline"
72
73
  },
74
+ publishFinalResponseArtifact: assistantBridgeOptions.publishFinalResponseArtifact,
75
+ finalResponseArtifactMode: assistantBridgeOptions.finalResponseArtifactMode,
76
+ finalResponseArtifactStreamThreshold: assistantBridgeOptions.finalResponseArtifactStreamThreshold,
77
+ formatFinalResponseArtifactContinuationNotice: assistantBridgeOptions.formatFinalResponseArtifactContinuationNotice,
78
+ formatFinalResponseArtifactMessage: assistantBridgeOptions.formatFinalResponseArtifactMessage,
79
+ onFinalResponseArtifactError: assistantBridgeOptions.onFinalResponseArtifactError,
73
80
  ...typeof assistantBridgeOptions.initialStatus === "object" && assistantBridgeOptions.initialStatus !== null ? { initialStatus: assistantBridgeOptions.initialStatus } : {},
74
81
  ...formatting?.formatChatMarkdown !== void 0 ? { formatChatMarkdown: formatting.formatChatMarkdown } : {},
75
82
  ...formatting?.formatMessageText ? { formatMessageText: formatting.formatMessageText } : {},
@@ -91,16 +98,8 @@ function installSlackAgentAppSurface(boltApp, options) {
91
98
  } : {}
92
99
  });
93
100
  channelAdapter.mount(boltApp);
94
- if (feedbackConfig) {
95
- const feedbackSessionStrategy = assistantBridgeOptions.sessionStrategy ?? "thread-aware";
96
- registerSlackFeedbackAction(boltApp, {
97
- ...feedbackConfig,
98
- resolveSessionId: (ctx) => resolveFeedbackSessionId(ctx, feedbackSessionStrategy),
99
- onFeedback: feedbackConfig.onFeedback ?? (async (_ctx) => {
100
- })
101
- });
102
- }
103
101
  interactive?.install(boltApp);
102
+ viewWorkflows?.install(boltApp);
104
103
  return { bridge };
105
104
  }
106
105
  function mergeChatStreamFinalArgs(base, feedbackBlock) {
@@ -182,17 +181,6 @@ function formatErrorForLog(error) {
182
181
  }
183
182
  return String(error);
184
183
  }
185
- function resolveFeedbackSessionId(context, strategy) {
186
- const threadTs = context.threadTs ?? context.messageTs;
187
- switch (strategy) {
188
- case "channel-id":
189
- return context.channelId;
190
- case "user-per-thread":
191
- return `${context.channelId}:${threadTs}:${context.userId}`;
192
- default:
193
- return `${context.channelId}:${threadTs}`;
194
- }
195
- }
196
184
 
197
185
  export {
198
186
  installSlackAgentAppSurface