@cuylabs/channel-slack-agent-core 0.5.1 → 0.7.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 (89) hide show
  1. package/README.md +20 -39
  2. package/dist/{adapter.d.ts → adapter/index.d.ts} +7 -5
  3. package/dist/adapter/index.js +9 -0
  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 +5 -7
  7. package/dist/app.d.ts +9 -4
  8. package/dist/app.js +6 -9
  9. package/dist/artifacts/index.d.ts +57 -0
  10. package/dist/artifacts/index.js +6 -0
  11. package/dist/{assistant.d.ts → assistant/index.d.ts} +6 -4
  12. package/dist/{assistant.js → assistant/index.js} +3 -5
  13. package/dist/{chunk-CYEBGC6G.js → chunk-76SRS54H.js} +5 -5
  14. package/dist/{chunk-M64Z6TYL.js → chunk-7DUO5BMW.js} +16 -6
  15. package/dist/{chunk-NIPAN4KA.js → chunk-A2PLAVW6.js} +2 -3
  16. package/dist/chunk-C7CHMYV6.js +226 -0
  17. package/dist/chunk-C7VSW4ZM.js +548 -0
  18. package/dist/{chunk-JMLB7A2V.js → chunk-DJPKRKGP.js} +5 -5
  19. package/dist/chunk-ELR6MQD7.js +12 -0
  20. package/dist/{chunk-FDRQOG7Q.js → chunk-FQWFB54C.js} +26 -15
  21. package/dist/{chunk-BFUPAJON.js → chunk-MGBNGG4D.js} +59 -37
  22. package/dist/chunk-NNCVHQC4.js +94 -0
  23. package/dist/chunk-P7PFQ3SQ.js +396 -0
  24. package/dist/{chunk-WO4BJMF3.js → chunk-TCNJY7QA.js} +5 -5
  25. package/dist/{chunk-DHPD4XH5.js → chunk-TMADMHBN.js} +210 -29
  26. package/dist/{chunk-IWUYIAY5.js → chunk-VMVQIDNR.js} +5 -7
  27. package/dist/{chunk-IXY3BXU5.js → chunk-X7ILLZZP.js} +359 -2
  28. package/dist/context-fragments-CQEDcjYR.d.ts +30 -0
  29. package/dist/express-assistant.d.ts +6 -3
  30. package/dist/express-assistant.js +4 -7
  31. package/dist/express.d.ts +7 -3
  32. package/dist/express.js +3 -6
  33. package/dist/feedback/index.d.ts +1 -0
  34. package/dist/feedback/index.js +10 -0
  35. package/dist/history/index.d.ts +61 -0
  36. package/dist/history/index.js +8 -0
  37. package/dist/index.d.ts +23 -16
  38. package/dist/index.js +81 -160
  39. package/dist/interactive/index.d.ts +71 -0
  40. package/dist/{interactive.js → interactive/index.js} +9 -4
  41. package/dist/mcp.js +0 -1
  42. package/dist/{options-C7OYeNR-.d.ts → options-BcDReOJv.d.ts} +48 -0
  43. package/dist/{options-Uf-qmQKN.d.ts → options-CdqBABcM.d.ts} +26 -1
  44. package/dist/{shared.d.ts → shared/index.d.ts} +24 -36
  45. package/dist/{shared.js → shared/index.js} +2 -6
  46. package/dist/socket.d.ts +9 -4
  47. package/dist/socket.js +6 -9
  48. package/dist/source/index.d.ts +154 -0
  49. package/dist/source/index.js +38 -0
  50. package/dist/{types-BqRzb_Cd.d.ts → types-CRWzJB5G.d.ts} +35 -0
  51. package/dist/types-CiwGU6zC.d.ts +56 -0
  52. package/dist/views/index.d.ts +8 -0
  53. package/dist/views/index.js +10 -0
  54. package/docs/README.md +18 -0
  55. package/docs/concepts/final-response-artifacts.md +39 -0
  56. package/docs/concepts/interactive-requests.md +43 -0
  57. package/docs/concepts/tool-task-rendering.md +46 -0
  58. package/docs/concepts/view-workflows.md +52 -0
  59. package/docs/reference/boundary.md +22 -0
  60. package/docs/reference/exports.md +26 -0
  61. package/package.json +36 -50
  62. package/dist/adapter.js +0 -13
  63. package/dist/bolt.d.ts +0 -8
  64. package/dist/bolt.js +0 -10
  65. package/dist/chunk-2SUAW6MV.js +0 -12
  66. package/dist/chunk-645NNJIM.js +0 -12
  67. package/dist/chunk-ANIZ5NT4.js +0 -12
  68. package/dist/chunk-GNXWTKQ6.js +0 -48
  69. package/dist/chunk-HFT2FXJP.js +0 -12
  70. package/dist/chunk-I2KLQ2HA.js +0 -22
  71. package/dist/chunk-K2E6A377.js +0 -12
  72. package/dist/chunk-NDVXBI7Z.js +0 -12
  73. package/dist/chunk-PX4RGO3N.js +0 -12
  74. package/dist/chunk-VHGV66M7.js +0 -12
  75. package/dist/diagnostics.d.ts +0 -1
  76. package/dist/diagnostics.js +0 -10
  77. package/dist/feedback.d.ts +0 -1
  78. package/dist/feedback.js +0 -10
  79. package/dist/history.d.ts +0 -1
  80. package/dist/history.js +0 -10
  81. package/dist/interactive.d.ts +0 -30
  82. package/dist/policy.d.ts +0 -1
  83. package/dist/policy.js +0 -10
  84. package/dist/setup.d.ts +0 -1
  85. package/dist/setup.js +0 -10
  86. package/dist/targets.d.ts +0 -1
  87. package/dist/targets.js +0 -10
  88. package/dist/users.d.ts +0 -1
  89. package/dist/users.js +0 -10
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # @cuylabs/channel-slack-agent-core
2
2
 
3
- Slack adapter for `@cuylabs/agent-core`, built on `@cuylabs/channel-slack`
4
- primitives.
3
+ Slack adapter for `@cuylabs/agent-core`, built on
4
+ `@cuylabs/channel-slack`.
5
5
 
6
- Use this package when your agent runtime is `@cuylabs/agent-core` and you want
7
- ready-to-mount Slack surfaces for Bolt, Express, Socket Mode, Slack Assistant,
8
- classic app mentions, DMs, and in-channel interactive approval or human-input
9
- requests.
6
+ Use this package when an Agent Core application needs ready-to-mount Slack
7
+ surfaces for Express Events API, Socket Mode, Slack Assistant, app mentions,
8
+ DMs, feedback, approvals, or human input.
10
9
 
11
- Use `@cuylabs/channel-slack` directly when you want Slack parsing, policy,
12
- history, setup, auth, or formatting primitives for another agent runtime.
10
+ Generic Slack mechanics such as parsing, policy, history, setup, auth, targets,
11
+ users, entrypoints, artifacts, and transports live in `@cuylabs/channel-slack`.
13
12
 
14
13
  ## Install
15
14
 
@@ -23,29 +22,13 @@ Install Slack peer dependencies for the surfaces you use:
23
22
  npm install @slack/bolt @slack/web-api express
24
23
  ```
25
24
 
26
- ## Import Map
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.
27
28
 
28
- Use feature-specific imports when you only need one adapter surface.
29
+ ## Quick Start
29
30
 
30
- | Import | Use for |
31
- | --- | --- |
32
- | `@cuylabs/channel-slack-agent-core/adapter` | Classic app mention, DM, and passive channel-message adapter |
33
- | `@cuylabs/channel-slack-agent-core/assistant` | Slack Assistant bridge and lifecycle handlers |
34
- | `@cuylabs/channel-slack-agent-core/express` | Express Events API mounting for classic Slack surfaces |
35
- | `@cuylabs/channel-slack-agent-core/express-assistant` | Express Events API mounting for Slack Assistant |
36
- | `@cuylabs/channel-slack-agent-core/socket` | Socket Mode mounting helpers |
37
- | `@cuylabs/channel-slack-agent-core/interactive` | Agent-core approval and human-input binding for Slack |
38
- | `@cuylabs/channel-slack-agent-core/shared` | Agent-core context fragments and event bridge plus Slack core primitives |
39
- | `@cuylabs/channel-slack-agent-core/bolt` | Re-exported Bolt helpers from `@cuylabs/channel-slack/bolt` |
40
- | `@cuylabs/channel-slack-agent-core/history` | Re-exported history helpers from `@cuylabs/channel-slack/history` |
41
- | `@cuylabs/channel-slack-agent-core/policy` | Re-exported message policy helpers from `@cuylabs/channel-slack/policy` |
42
-
43
- The package root re-exports the full adapter surface for compatibility and
44
- convenience. Reusable Slack mechanics continue to live in
45
- `@cuylabs/channel-slack`; this package only adds the `@cuylabs/agent-core`
46
- binding.
47
-
48
- ## Socket Mode
31
+ Socket Mode:
49
32
 
50
33
  ```typescript
51
34
  import { mountSlackAssistantAgentSocket } from "@cuylabs/channel-slack-agent-core";
@@ -57,7 +40,7 @@ await mountSlackAssistantAgentSocket({
57
40
  });
58
41
  ```
59
42
 
60
- ## Express Events API
43
+ Express Events API:
61
44
 
62
45
  ```typescript
63
46
  import { mountSlackAgent } from "@cuylabs/channel-slack-agent-core";
@@ -68,13 +51,11 @@ await mountSlackAgent(agent, {
68
51
  });
69
52
  ```
70
53
 
71
- ## Boundary
72
-
73
- This package owns only the `@cuylabs/agent-core` binding:
74
-
75
- - mapping Slack turns to `AgentTurnSource.chat(...)`
76
- - creating agent-core scopes and context fragments
77
- - converting `AgentEvent` streams to Slack messages or chat streams
78
- - handling agent-core approval and human-input requests in Slack
54
+ ## Documentation
79
55
 
80
- Reusable Slack mechanics live in `@cuylabs/channel-slack`.
56
+ - [Package boundary](docs/reference/boundary.md)
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)
61
+ - [Docs index](docs/README.md)
@@ -1,10 +1,12 @@
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
- export { resolveThreadAwareSlackSessionId } from '@cuylabs/channel-slack/core';
6
5
  import '@cuylabs/agent-core';
7
- import './interactive-o_NZb-Xg.js';
6
+ import '../options-BcDReOJv.js';
7
+ import '../artifacts/index.js';
8
+ import '@cuylabs/channel-slack/artifacts';
9
+ import '../interactive-o_NZb-Xg.js';
8
10
 
9
11
  /**
10
12
  * Session mapping — Slack activity info to agent-core session IDs.
@@ -0,0 +1,9 @@
1
+ import {
2
+ createSlackChannelAdapter,
3
+ createSlackSessionMap
4
+ } from "../chunk-FQWFB54C.js";
5
+ import "../chunk-TMADMHBN.js";
6
+ export {
7
+ createSlackChannelAdapter,
8
+ createSlackSessionMap
9
+ };
@@ -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, b as SlackAssistantFeedbackConfig, S as SlackAssistantBridge } from './options-CdqBABcM.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,12 +1,10 @@
1
1
  import {
2
2
  installSlackAgentAppSurface
3
- } from "./chunk-M64Z6TYL.js";
4
- import "./chunk-BFUPAJON.js";
5
- import "./chunk-VHGV66M7.js";
6
- import "./chunk-FDRQOG7Q.js";
7
- import "./chunk-GNXWTKQ6.js";
8
- import "./chunk-DHPD4XH5.js";
9
- import "./chunk-I2KLQ2HA.js";
3
+ } from "./chunk-7DUO5BMW.js";
4
+ import "./chunk-MGBNGG4D.js";
5
+ import "./chunk-ELR6MQD7.js";
6
+ import "./chunk-FQWFB54C.js";
7
+ import "./chunk-TMADMHBN.js";
10
8
  export {
11
9
  installSlackAgentAppSurface
12
10
  };
package/dist/app.d.ts CHANGED
@@ -1,18 +1,23 @@
1
1
  import { Server } from 'node:http';
2
2
  import { Application } from 'express';
3
3
  import { App, ExpressReceiver } from '@slack/bolt';
4
- import { CreateSlackBoltAppOptions, SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/bolt';
4
+ import { CreateSlackBoltAppOptions } from '@cuylabs/channel-slack/transports/http';
5
+ import { SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/auth';
5
6
  import { SlackAgentAppSurfaceOptions } from './app-surface.js';
6
7
  export { MountSlackAgentAppTurnRequestContext } from './app-surface.js';
7
- import { S as SlackAssistantBridge } from './options-Uf-qmQKN.js';
8
+ import { S as SlackAssistantBridge } from './options-CdqBABcM.js';
8
9
  import '@cuylabs/agent-core';
9
10
  import '@slack/web-api';
10
- import './types-BqRzb_Cd.js';
11
+ import './types-CRWzJB5G.js';
11
12
  import '@cuylabs/channel-slack/core';
13
+ import './options-BcDReOJv.js';
14
+ import './artifacts/index.js';
15
+ import '@cuylabs/channel-slack/artifacts';
12
16
  import './interactive-o_NZb-Xg.js';
13
17
  import '@cuylabs/channel-slack/feedback';
14
18
  import './types-Crpil4kb.js';
15
- import './options-C7OYeNR-.js';
19
+ import './types-CiwGU6zC.js';
20
+ import '@cuylabs/channel-slack/views';
16
21
  import '@cuylabs/channel-slack/assistant';
17
22
 
18
23
  /**
package/dist/app.js CHANGED
@@ -1,14 +1,11 @@
1
1
  import {
2
2
  mountSlackAgentApp
3
- } from "./chunk-CYEBGC6G.js";
4
- import "./chunk-M64Z6TYL.js";
5
- import "./chunk-BFUPAJON.js";
6
- import "./chunk-VHGV66M7.js";
7
- import "./chunk-FDRQOG7Q.js";
8
- import "./chunk-GNXWTKQ6.js";
9
- import "./chunk-DHPD4XH5.js";
10
- import "./chunk-ANIZ5NT4.js";
11
- import "./chunk-I2KLQ2HA.js";
3
+ } from "./chunk-76SRS54H.js";
4
+ import "./chunk-7DUO5BMW.js";
5
+ import "./chunk-MGBNGG4D.js";
6
+ import "./chunk-ELR6MQD7.js";
7
+ import "./chunk-FQWFB54C.js";
8
+ import "./chunk-TMADMHBN.js";
12
9
  export {
13
10
  mountSlackAgentApp
14
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-CdqBABcM.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-CdqBABcM.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
- import './interactive-o_NZb-Xg.js';
9
- import './options-C7OYeNR-.js';
8
+ import '../interactive-o_NZb-Xg.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,11 +3,9 @@ import {
3
3
  createSlackAssistantThreadContextStore,
4
4
  parseSlackMessageActivityFromMessageEvent,
5
5
  resolveAssistantSessionId
6
- } from "./chunk-BFUPAJON.js";
7
- import "./chunk-VHGV66M7.js";
8
- import "./chunk-GNXWTKQ6.js";
9
- import "./chunk-DHPD4XH5.js";
10
- import "./chunk-I2KLQ2HA.js";
6
+ } from "../chunk-MGBNGG4D.js";
7
+ import "../chunk-ELR6MQD7.js";
8
+ import "../chunk-TMADMHBN.js";
11
9
  export {
12
10
  createSlackAssistantBridge,
13
11
  createSlackAssistantThreadContextStore,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  installSlackAgentAppSurface
3
- } from "./chunk-M64Z6TYL.js";
4
- import {
5
- bolt_exports
6
- } from "./chunk-ANIZ5NT4.js";
3
+ } from "./chunk-7DUO5BMW.js";
7
4
 
8
5
  // src/app.ts
6
+ import {
7
+ createSlackBoltApp
8
+ } from "@cuylabs/channel-slack/transports/http";
9
9
  async function mountSlackAgentApp(options) {
10
10
  const {
11
11
  botToken,
@@ -27,7 +27,7 @@ async function mountSlackAgentApp(options) {
27
27
  app: expressApp,
28
28
  authMode,
29
29
  routePath
30
- } = await (0, bolt_exports.createSlackBoltApp)({
30
+ } = await createSlackBoltApp({
31
31
  signingSecret,
32
32
  path,
33
33
  botToken,
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  createSlackAssistantBridge
3
- } from "./chunk-BFUPAJON.js";
3
+ } from "./chunk-MGBNGG4D.js";
4
4
  import {
5
- feedback_exports
6
- } from "./chunk-VHGV66M7.js";
5
+ createSlackFeedbackBlock,
6
+ registerSlackFeedbackAction
7
+ } from "./chunk-ELR6MQD7.js";
7
8
  import {
8
9
  createSlackChannelAdapter
9
- } from "./chunk-FDRQOG7Q.js";
10
+ } from "./chunk-FQWFB54C.js";
10
11
 
11
12
  // src/app-surface.ts
12
13
  var DEFAULT_TIMEOUT_MS = 12e4;
@@ -25,11 +26,12 @@ function installSlackAgentAppSurface(boltApp, options) {
25
26
  prepareTurn,
26
27
  resolveSession,
27
28
  interactive,
29
+ viewWorkflows,
28
30
  ...assistantBridgeOptions
29
31
  } = options;
30
32
  const feedbackConfig = feedbackOption === false ? void 0 : feedbackOption ?? (onFeedback ? { onFeedback } : {});
31
33
  const assistantFeedback = feedbackOption === false ? false : feedbackConfig;
32
- const feedbackBlock = feedbackConfig ? (0, feedback_exports.createSlackFeedbackBlock)(feedbackConfig) : void 0;
34
+ const feedbackBlock = feedbackConfig ? createSlackFeedbackBlock(feedbackConfig) : void 0;
33
35
  const formatStreamError = assistantBridgeOptions.formatStreamError ?? (() => DEFAULT_STREAM_ERROR_MESSAGE);
34
36
  const formatting = assistantBridgeOptions.formatChatMarkdown;
35
37
  const channelSource = createErrorTranslatingSource(source, formatStreamError);
@@ -62,6 +64,7 @@ function installSlackAgentAppSurface(boltApp, options) {
62
64
  formatToolTitle: assistantBridgeOptions.formatToolTitle,
63
65
  formatToolUpdate: assistantBridgeOptions.formatToolUpdate,
64
66
  formatToolDetails: assistantBridgeOptions.formatToolDetails,
67
+ formatToolResultOutput: assistantBridgeOptions.formatToolResultOutput,
65
68
  formatToolError: assistantBridgeOptions.formatToolError,
66
69
  formatReasoningUpdate: assistantBridgeOptions.formatReasoningUpdate,
67
70
  chatStreamBufferSize: assistantBridgeOptions.chatStreamBufferSize,
@@ -69,6 +72,12 @@ function installSlackAgentAppSurface(boltApp, options) {
69
72
  ...assistantBridgeOptions.chatStreamStartArgs ?? {},
70
73
  task_display_mode: assistantBridgeOptions.taskDisplayMode ?? "timeline"
71
74
  },
75
+ publishFinalResponseArtifact: assistantBridgeOptions.publishFinalResponseArtifact,
76
+ finalResponseArtifactMode: assistantBridgeOptions.finalResponseArtifactMode,
77
+ finalResponseArtifactStreamThreshold: assistantBridgeOptions.finalResponseArtifactStreamThreshold,
78
+ formatFinalResponseArtifactContinuationNotice: assistantBridgeOptions.formatFinalResponseArtifactContinuationNotice,
79
+ formatFinalResponseArtifactMessage: assistantBridgeOptions.formatFinalResponseArtifactMessage,
80
+ onFinalResponseArtifactError: assistantBridgeOptions.onFinalResponseArtifactError,
72
81
  ...typeof assistantBridgeOptions.initialStatus === "object" && assistantBridgeOptions.initialStatus !== null ? { initialStatus: assistantBridgeOptions.initialStatus } : {},
73
82
  ...formatting?.formatChatMarkdown !== void 0 ? { formatChatMarkdown: formatting.formatChatMarkdown } : {},
74
83
  ...formatting?.formatMessageText ? { formatMessageText: formatting.formatMessageText } : {},
@@ -92,7 +101,7 @@ function installSlackAgentAppSurface(boltApp, options) {
92
101
  channelAdapter.mount(boltApp);
93
102
  if (feedbackConfig) {
94
103
  const feedbackSessionStrategy = assistantBridgeOptions.sessionStrategy ?? "thread-aware";
95
- (0, feedback_exports.registerSlackFeedbackAction)(boltApp, {
104
+ registerSlackFeedbackAction(boltApp, {
96
105
  ...feedbackConfig,
97
106
  resolveSessionId: (ctx) => resolveFeedbackSessionId(ctx, feedbackSessionStrategy),
98
107
  onFeedback: feedbackConfig.onFeedback ?? (async (_ctx) => {
@@ -100,6 +109,7 @@ function installSlackAgentAppSurface(boltApp, options) {
100
109
  });
101
110
  }
102
111
  interactive?.install(boltApp);
112
+ viewWorkflows?.install(boltApp);
103
113
  return { bridge };
104
114
  }
105
115
  function mergeChatStreamFinalArgs(base, feedbackBlock) {
@@ -1,8 +1,7 @@
1
+ // src/shared/context-fragments.ts
1
2
  import {
2
3
  currentSlackTurnContext
3
- } from "./chunk-DHPD4XH5.js";
4
-
5
- // src/shared/context-fragments.ts
4
+ } from "@cuylabs/channel-slack/core";
6
5
  var DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY = "slackContextFragment";
7
6
  function isRecord(value) {
8
7
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -0,0 +1,226 @@
1
+ // src/views/controller.ts
2
+ import { registerSlackViewWorkflow } from "@cuylabs/channel-slack/views";
3
+
4
+ // src/views/state.ts
5
+ function extractSlackAgentViewStateValues(viewOrState) {
6
+ const state = isRecord(viewOrState) ? isRecord(viewOrState.state) ? viewOrState.state : viewOrState : {};
7
+ const rawValues = isRecord(state.values) ? state.values : {};
8
+ const values = {};
9
+ for (const [blockId, rawActions] of Object.entries(rawValues)) {
10
+ if (!isRecord(rawActions)) {
11
+ continue;
12
+ }
13
+ const actions = {};
14
+ for (const [actionId, rawAction] of Object.entries(rawActions)) {
15
+ actions[actionId] = extractSlackAgentViewActionValue(rawAction);
16
+ }
17
+ values[blockId] = actions;
18
+ }
19
+ return values;
20
+ }
21
+ function readSlackAgentViewStateValue(valuesOrView, blockId, actionId) {
22
+ const values = looksLikeExtractedStateValues(valuesOrView) ? valuesOrView : extractSlackAgentViewStateValues(valuesOrView);
23
+ return values[blockId]?.[actionId];
24
+ }
25
+ function extractSlackAgentViewActionValue(rawAction) {
26
+ if (!isRecord(rawAction)) {
27
+ return void 0;
28
+ }
29
+ if ("value" in rawAction && typeof rawAction.value !== "undefined") {
30
+ return normalizeValue(rawAction.value);
31
+ }
32
+ if (isRecord(rawAction.selected_option)) {
33
+ return readOptionValue(rawAction.selected_option);
34
+ }
35
+ if (Array.isArray(rawAction.selected_options)) {
36
+ return rawAction.selected_options.map(readOptionValue).filter(isString);
37
+ }
38
+ for (const field of [
39
+ "selected_user",
40
+ "selected_users",
41
+ "selected_channel",
42
+ "selected_channels",
43
+ "selected_conversation",
44
+ "selected_conversations",
45
+ "selected_date",
46
+ "selected_time",
47
+ "selected_date_time"
48
+ ]) {
49
+ const value = rawAction[field];
50
+ if (typeof value !== "undefined") {
51
+ return normalizeValue(value);
52
+ }
53
+ }
54
+ if (typeof rawAction.checked === "boolean") {
55
+ return rawAction.checked;
56
+ }
57
+ return rawAction;
58
+ }
59
+ function readOptionValue(option) {
60
+ if (!isRecord(option)) {
61
+ return "";
62
+ }
63
+ if (typeof option.value === "string") {
64
+ return option.value;
65
+ }
66
+ const text = option.text;
67
+ if (isRecord(text) && typeof text.text === "string") {
68
+ return text.text;
69
+ }
70
+ return "";
71
+ }
72
+ function normalizeValue(value) {
73
+ if (typeof value === "string" || typeof value === "boolean" || typeof value === "number") {
74
+ return value;
75
+ }
76
+ if (Array.isArray(value)) {
77
+ return value.filter(isString);
78
+ }
79
+ return isRecord(value) ? value : void 0;
80
+ }
81
+ function looksLikeExtractedStateValues(value) {
82
+ if (!isRecord(value) || "state" in value || "values" in value) {
83
+ return false;
84
+ }
85
+ return Object.values(value).every(isRecord);
86
+ }
87
+ function isRecord(value) {
88
+ return typeof value === "object" && value !== null;
89
+ }
90
+ function isString(value) {
91
+ return typeof value === "string";
92
+ }
93
+
94
+ // src/views/controller.ts
95
+ var DEFAULT_NAMESPACE = "agent_slack_view";
96
+ var installedCallbackIds = /* @__PURE__ */ new WeakMap();
97
+ function createSlackAgentViewWorkflowController({
98
+ namespace = DEFAULT_NAMESPACE,
99
+ workflows = [],
100
+ onError
101
+ } = {}) {
102
+ const normalizedNamespace = normalizeIdentifier(namespace, "namespace");
103
+ const registeredWorkflows = /* @__PURE__ */ new Map();
104
+ const installedApps = /* @__PURE__ */ new Set();
105
+ function register(workflow) {
106
+ const workflowId = normalizeIdentifier(workflow.id, "workflow id");
107
+ if (!workflow.onSubmission && !workflow.onClose) {
108
+ throw new Error(
109
+ `Slack agent view workflow '${workflowId}' must define onSubmission or onClose.`
110
+ );
111
+ }
112
+ if (registeredWorkflows.has(workflowId)) {
113
+ throw new Error(`Duplicate Slack agent view workflow id: ${workflowId}`);
114
+ }
115
+ const callbackId = normalizeOptionalIdentifier(workflow.callbackId) ?? callbackIdFromWorkflowId(normalizedNamespace, workflowId);
116
+ if ([...registeredWorkflows.values()].some(
117
+ (item) => item.callbackId === callbackId
118
+ )) {
119
+ throw new Error(`Duplicate Slack view callback id: ${callbackId}`);
120
+ }
121
+ const registered = {
122
+ ...workflow,
123
+ id: workflowId,
124
+ callbackId
125
+ };
126
+ registeredWorkflows.set(workflowId, registered);
127
+ for (const app of installedApps) {
128
+ installWorkflow(app, registered);
129
+ }
130
+ return callbackId;
131
+ }
132
+ function callbackIdFor(workflowId) {
133
+ const normalizedWorkflowId = normalizeIdentifier(workflowId, "workflow id");
134
+ return registeredWorkflows.get(normalizedWorkflowId)?.callbackId ?? callbackIdFromWorkflowId(normalizedNamespace, normalizedWorkflowId);
135
+ }
136
+ function list() {
137
+ return [...registeredWorkflows.values()].map(({ id, callbackId }) => ({
138
+ id,
139
+ callbackId
140
+ }));
141
+ }
142
+ function install(app) {
143
+ installedApps.add(app);
144
+ for (const workflow of registeredWorkflows.values()) {
145
+ installWorkflow(app, workflow);
146
+ }
147
+ }
148
+ function installWorkflow(app, workflow) {
149
+ const callbackIds = callbackIdsForApp(app);
150
+ if (callbackIds.has(workflow.callbackId)) {
151
+ throw new Error(
152
+ `Slack view callback id '${workflow.callbackId}' is already installed on this Bolt app.`
153
+ );
154
+ }
155
+ callbackIds.add(workflow.callbackId);
156
+ registerSlackViewWorkflow({
157
+ boltApp: app,
158
+ callbackId: workflow.callbackId,
159
+ ...workflow.decodePrivateMetadata ? { decodePrivateMetadata: workflow.decodePrivateMetadata } : {},
160
+ ...workflow.onSubmission ? {
161
+ onSubmission: async (context) => await workflow.onSubmission(enrichContext(workflow, context))
162
+ } : {},
163
+ ...workflow.onClose ? {
164
+ onClose: async (context) => await workflow.onClose(enrichContext(workflow, context))
165
+ } : {},
166
+ onError: async (error, context) => {
167
+ const enriched = enrichContext(workflow, {
168
+ ...context,
169
+ metadata: context.metadata
170
+ });
171
+ if (workflow.onError) {
172
+ await workflow.onError(error, enriched);
173
+ return;
174
+ }
175
+ await onError?.(error, enriched);
176
+ }
177
+ });
178
+ }
179
+ for (const workflow of workflows) {
180
+ register(workflow);
181
+ }
182
+ return {
183
+ namespace: normalizedNamespace,
184
+ register,
185
+ callbackIdFor,
186
+ list,
187
+ install
188
+ };
189
+ }
190
+ function enrichContext(workflow, context) {
191
+ const stateValues = extractSlackAgentViewStateValues(context.view);
192
+ return {
193
+ ...context,
194
+ workflow: { id: workflow.id, callbackId: workflow.callbackId },
195
+ stateValues,
196
+ getStateValue: (blockId, actionId) => readSlackAgentViewStateValue(stateValues, blockId, actionId)
197
+ };
198
+ }
199
+ function callbackIdsForApp(app) {
200
+ let callbackIds = installedCallbackIds.get(app);
201
+ if (!callbackIds) {
202
+ callbackIds = /* @__PURE__ */ new Set();
203
+ installedCallbackIds.set(app, callbackIds);
204
+ }
205
+ return callbackIds;
206
+ }
207
+ function callbackIdFromWorkflowId(namespace, workflowId) {
208
+ return `${namespace}_${workflowId}`;
209
+ }
210
+ function normalizeOptionalIdentifier(value) {
211
+ const normalized = value?.trim();
212
+ return normalized ? normalized : void 0;
213
+ }
214
+ function normalizeIdentifier(value, label) {
215
+ const normalized = value.trim().replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "");
216
+ if (!normalized) {
217
+ throw new Error(`Slack agent view workflow ${label} cannot be empty.`);
218
+ }
219
+ return normalized;
220
+ }
221
+
222
+ export {
223
+ extractSlackAgentViewStateValues,
224
+ readSlackAgentViewStateValue,
225
+ createSlackAgentViewWorkflowController
226
+ };