@cuylabs/channel-slack-agent-core 0.10.0 → 0.12.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.
- package/README.md +18 -11
- package/dist/{chunk-L5RAGYVJ.js → chunk-U6RC4SXN.js} +87 -1
- package/dist/history/index.d.ts +7 -17
- package/dist/index.d.ts +2 -29
- package/dist/index.js +12 -64
- package/dist/shared/index.d.ts +146 -10
- package/dist/shared/index.js +4 -4
- package/docs/README.md +2 -4
- package/docs/concepts/final-response-artifacts.md +9 -7
- package/docs/concepts/interactive-requests.md +31 -26
- package/docs/concepts/tool-task-rendering.md +2 -0
- package/docs/reference/boundary.md +6 -4
- package/docs/reference/exports.md +14 -20
- package/package.json +4 -59
- package/dist/adapter/index.d.ts +0 -26
- package/dist/adapter/index.js +0 -9
- package/dist/adapter-vbqtraAr.d.ts +0 -31
- package/dist/app-surface.d.ts +0 -82
- package/dist/app-surface.js +0 -10
- package/dist/app.d.ts +0 -60
- package/dist/app.js +0 -11
- package/dist/artifacts/index.d.ts +0 -57
- package/dist/artifacts/index.js +0 -6
- package/dist/assistant/index.d.ts +0 -22
- package/dist/assistant/index.js +0 -14
- package/dist/chunk-6EMFBOXD.js +0 -67
- package/dist/chunk-A2PLAVW6.js +0 -75
- package/dist/chunk-C7CHMYV6.js +0 -226
- package/dist/chunk-DS6E5OEJ.js +0 -85
- package/dist/chunk-ELR6MQD7.js +0 -12
- package/dist/chunk-GEFK72VO.js +0 -921
- package/dist/chunk-KQPUQJ57.js +0 -482
- package/dist/chunk-NNCVHQC4.js +0 -94
- package/dist/chunk-OP27SSZU.js +0 -409
- package/dist/chunk-P2DIC42J.js +0 -77
- package/dist/chunk-Q2GU4QLZ.js +0 -187
- package/dist/chunk-QFDXKCAQ.js +0 -82
- package/dist/express-assistant.d.ts +0 -106
- package/dist/express-assistant.js +0 -9
- package/dist/express.d.ts +0 -103
- package/dist/express.js +0 -8
- package/dist/feedback/index.d.ts +0 -1
- package/dist/feedback/index.js +0 -10
- package/dist/interactive/index.d.ts +0 -11
- package/dist/interactive/index.js +0 -6
- package/dist/interactive-BigrPKnu.d.ts +0 -30
- package/dist/options-ByNm2o89.d.ts +0 -323
- package/dist/options-CGUfVStV.d.ts +0 -119
- package/dist/socket.d.ts +0 -143
- package/dist/socket.js +0 -13
- package/dist/types-BeGPexio.d.ts +0 -381
- package/dist/types-Bz4OYEAV.d.ts +0 -87
- package/dist/types-CiwGU6zC.d.ts +0 -56
- package/dist/views/index.d.ts +0 -8
- package/dist/views/index.js +0 -10
- package/docs/concepts/view-workflows.md +0 -52
package/README.md
CHANGED
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
Slack adapter for `@cuylabs/agent-core`, built on
|
|
4
4
|
`@cuylabs/channel-slack`.
|
|
5
5
|
|
|
6
|
-
Use this package when an Agent Core application needs
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Use this package when an Agent Core application needs Agent Core-specific Slack
|
|
7
|
+
bindings: event mapping, source adaptation, context fragments, history helpers,
|
|
8
|
+
or MCP token bridging.
|
|
9
9
|
|
|
10
|
-
Generic Slack mechanics
|
|
11
|
-
|
|
12
|
-
transports live in `@cuylabs/channel-slack`.
|
|
10
|
+
Generic Slack mechanics, mounts, Assistant rendering, classic message routing,
|
|
11
|
+
feedback, artifacts, interactive request rendering/storage and controller
|
|
12
|
+
wiring, response sinks, and transports live in `@cuylabs/channel-slack`.
|
|
13
|
+
|
|
14
|
+
For Slack-native approvals and human input, import the controller from
|
|
15
|
+
`@cuylabs/channel-slack/interactive`; this package does not provide an
|
|
16
|
+
`interactive` subpath.
|
|
13
17
|
|
|
14
18
|
## Install
|
|
15
19
|
|
|
@@ -33,10 +37,11 @@ without injecting its own client.
|
|
|
33
37
|
Socket Mode:
|
|
34
38
|
|
|
35
39
|
```typescript
|
|
36
|
-
import {
|
|
40
|
+
import { mountSlackAppSocket } from "@cuylabs/channel-slack/socket";
|
|
41
|
+
import { adaptAgentTurnSourceToSlackTurnSource } from "@cuylabs/channel-slack-agent-core";
|
|
37
42
|
|
|
38
|
-
await
|
|
39
|
-
source: agent,
|
|
43
|
+
await mountSlackAppSocket({
|
|
44
|
+
source: adaptAgentTurnSourceToSlackTurnSource(agent),
|
|
40
45
|
appToken: process.env.SLACK_APP_TOKEN,
|
|
41
46
|
botToken: process.env.SLACK_BOT_TOKEN,
|
|
42
47
|
});
|
|
@@ -45,9 +50,11 @@ await mountSlackAssistantAgentSocket({
|
|
|
45
50
|
Express Events API:
|
|
46
51
|
|
|
47
52
|
```typescript
|
|
48
|
-
import {
|
|
53
|
+
import { mountSlackApp } from "@cuylabs/channel-slack/app";
|
|
54
|
+
import { adaptAgentTurnSourceToSlackTurnSource } from "@cuylabs/channel-slack-agent-core";
|
|
49
55
|
|
|
50
|
-
await
|
|
56
|
+
await mountSlackApp({
|
|
57
|
+
source: adaptAgentTurnSourceToSlackTurnSource(agent),
|
|
51
58
|
botToken: process.env.SLACK_BOT_TOKEN,
|
|
52
59
|
signingSecret: process.env.SLACK_SIGNING_SECRET,
|
|
53
60
|
});
|
|
@@ -1,3 +1,74 @@
|
|
|
1
|
+
// src/shared/context-fragments.ts
|
|
2
|
+
import {
|
|
3
|
+
currentSlackTurnContext
|
|
4
|
+
} from "@cuylabs/channel-slack/core";
|
|
5
|
+
var DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY = "slackContextFragment";
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function isPayload(value) {
|
|
10
|
+
return isRecord(value) && typeof value.content === "string";
|
|
11
|
+
}
|
|
12
|
+
function resolveContextBagValue(slack, key) {
|
|
13
|
+
const value = slack.context?.[key];
|
|
14
|
+
if (typeof value === "string") {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
if (isPayload(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function resolveDedupeKey(options, context) {
|
|
23
|
+
return typeof options.dedupeKey === "function" ? options.dedupeKey(context) : options.dedupeKey;
|
|
24
|
+
}
|
|
25
|
+
function resolveMetadata(options, context) {
|
|
26
|
+
return typeof options.metadata === "function" ? options.metadata(context) : options.metadata;
|
|
27
|
+
}
|
|
28
|
+
function normalizeFragment(resolved, options, context) {
|
|
29
|
+
const payload = typeof resolved === "string" ? { content: resolved } : isPayload(resolved) ? resolved : void 0;
|
|
30
|
+
if (!payload) {
|
|
31
|
+
return resolved;
|
|
32
|
+
}
|
|
33
|
+
if (payload.content.trim().length === 0) {
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
const dedupeKey = payload.dedupeKey ?? resolveDedupeKey(options, context);
|
|
37
|
+
const metadata = payload.metadata ?? resolveMetadata(options, context);
|
|
38
|
+
const maxChars = payload.maxChars ?? options.maxChars;
|
|
39
|
+
return {
|
|
40
|
+
kind: payload.kind ?? options.kind ?? "slack-context",
|
|
41
|
+
content: payload.content,
|
|
42
|
+
role: payload.role ?? options.role ?? "user",
|
|
43
|
+
placement: payload.placement ?? options.placement ?? "after-latest-user",
|
|
44
|
+
lifetime: payload.lifetime ?? options.lifetime ?? "turn",
|
|
45
|
+
source: payload.source ?? options.source ?? "slack",
|
|
46
|
+
title: payload.title ?? options.title ?? "Slack Context",
|
|
47
|
+
budgetBehavior: payload.budgetBehavior ?? options.budgetBehavior ?? "droppable",
|
|
48
|
+
...maxChars !== void 0 ? { maxChars } : {},
|
|
49
|
+
...dedupeKey ? { dedupeKey } : {},
|
|
50
|
+
...metadata ? { metadata } : {}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createSlackContextFragmentMiddleware(options = {}) {
|
|
54
|
+
const contextKey = options.contextKey ?? DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY;
|
|
55
|
+
return {
|
|
56
|
+
name: options.name ?? "slack-context-fragment",
|
|
57
|
+
async contextFragments(step) {
|
|
58
|
+
const slack = currentSlackTurnContext();
|
|
59
|
+
if (!slack) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
const context = { slack, step };
|
|
63
|
+
const resolved = options.resolve ? await options.resolve(context) : resolveContextBagValue(slack, contextKey);
|
|
64
|
+
if (resolved === void 0) {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
return normalizeFragment(resolved, options, context);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
1
72
|
// src/shared/event-bridge/agent-event-mapper.ts
|
|
2
73
|
function mapAgentEventToSlackTurnEvent(event) {
|
|
3
74
|
switch (event.type) {
|
|
@@ -236,10 +307,25 @@ var UnsupportedSlackInteractiveRequestError = class extends Error {
|
|
|
236
307
|
}
|
|
237
308
|
};
|
|
238
309
|
|
|
310
|
+
// src/shared/event-bridge/turn-source.ts
|
|
311
|
+
function adaptAgentTurnSourceToSlackTurnSource(source) {
|
|
312
|
+
return {
|
|
313
|
+
async *chat(sessionId, message, options) {
|
|
314
|
+
const events = source.chat(sessionId, message, options);
|
|
315
|
+
for await (const event of events) {
|
|
316
|
+
yield mapAgentEventToSlackTurnEvent(event);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
239
322
|
export {
|
|
323
|
+
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
324
|
+
createSlackContextFragmentMiddleware,
|
|
240
325
|
mapAgentEventToSlackTurnEvent,
|
|
241
326
|
mapAgentSlackEventBridgeOptionsToRuntimeOptions,
|
|
242
327
|
bridgeAgentEventsToSlack,
|
|
243
328
|
resolveSlackEventBridgeOptions,
|
|
244
|
-
UnsupportedSlackInteractiveRequestError
|
|
329
|
+
UnsupportedSlackInteractiveRequestError,
|
|
330
|
+
adaptAgentTurnSourceToSlackTurnSource
|
|
245
331
|
};
|
package/dist/history/index.d.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { Logger } from '@cuylabs/agent-core';
|
|
2
2
|
import { SlackHistoryUnavailable, SlackSupplementalHistoryVisibilityMode } from '@cuylabs/channel-slack/history';
|
|
3
|
-
import {
|
|
3
|
+
import { SlackTurnRequestContext, SlackAssistantUtilities } from '@cuylabs/channel-slack/core';
|
|
4
|
+
import { WebClient } from '@slack/web-api';
|
|
4
5
|
import { a as SlackContextFragmentPayload } from '../context-fragments-CQEDcjYR.js';
|
|
5
|
-
import '@slack/bolt';
|
|
6
|
-
import '@slack/web-api';
|
|
7
|
-
import '../options-ByNm2o89.js';
|
|
8
|
-
import '@cuylabs/channel-slack/core';
|
|
9
|
-
import '../interactive-BigrPKnu.js';
|
|
10
|
-
import '@cuylabs/channel-slack/interactive';
|
|
11
|
-
import '../options-CGUfVStV.js';
|
|
12
|
-
import '../artifacts/index.js';
|
|
13
|
-
import '@cuylabs/channel-slack/artifacts';
|
|
14
|
-
import '@cuylabs/channel-slack/feedback';
|
|
15
|
-
import '@cuylabs/channel-slack/assistant';
|
|
16
|
-
import '../types-BeGPexio.js';
|
|
17
|
-
import '../types-Bz4OYEAV.js';
|
|
18
|
-
import '../types-CiwGU6zC.js';
|
|
19
|
-
import '@cuylabs/channel-slack/views';
|
|
20
6
|
|
|
7
|
+
interface SlackAgentHistoryTurnRequestContext extends SlackTurnRequestContext {
|
|
8
|
+
assistant?: SlackAssistantUtilities;
|
|
9
|
+
client?: WebClient;
|
|
10
|
+
}
|
|
21
11
|
interface SlackAgentTurnHistoryOptions {
|
|
22
12
|
enabled: boolean;
|
|
23
13
|
limit: number;
|
|
@@ -40,7 +30,7 @@ interface LoadSlackAgentTurnHistoryContextOptions {
|
|
|
40
30
|
logger?: Pick<Logger, "debug" | "info" | "warn">;
|
|
41
31
|
originChannelId?: string;
|
|
42
32
|
profileResolver?: SlackAgentTurnHistoryProfileResolver;
|
|
43
|
-
request:
|
|
33
|
+
request: SlackAgentHistoryTurnRequestContext;
|
|
44
34
|
}
|
|
45
35
|
type SlackAgentTurnHistoryContextResult = {
|
|
46
36
|
fragment?: SlackContextFragmentPayload;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
export { D as DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY, S as SlackContextFragmentMiddlewareOptions, a as SlackContextFragmentPayload, b as SlackContextFragmentResolver, c as SlackContextFragmentResolverContext, d as createSlackContextFragmentMiddleware } from './context-fragments-CQEDcjYR.js';
|
|
2
|
-
export { UnsupportedSlackInteractiveRequestError, bridgeAgentEventsToSlack, mapAgentEventToSlackTurnEvent, mapAgentSlackEventBridgeOptionsToRuntimeOptions } from './shared/index.js';
|
|
3
|
-
export { S as SlackEventBridgeOptions, r as resolveSlackEventBridgeOptions } from './options-CGUfVStV.js';
|
|
4
|
-
export { S as SlackApprovalRequest, a as SlackEventInteractiveRequestHandler, b as SlackHumanInputRequest, c as SlackInteractiveRequest, d as SlackInteractiveRequestBaseContext, e as SlackInteractiveRequestContext, f as SlackInteractiveRequestHandler } from './interactive-BigrPKnu.js';
|
|
5
|
-
export { c as createSlackChannelAdapter } from './adapter-vbqtraAr.js';
|
|
6
|
-
export { S as SlackChannelAdapter, a as SlackChannelOptions, b as SlackSessionStrategy, c as SlackStreamingMode, d as SlackToolStartEvent } from './types-BeGPexio.js';
|
|
7
|
-
export { SlackSessionMap, createSlackSessionMap } from './adapter/index.js';
|
|
8
|
-
export { createSlackAssistantBridge } from './assistant/index.js';
|
|
9
|
-
export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, C as CreateSlackAssistantBridgeOptions, M as MaybePromise, S as SlackAssistantBridge, 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-ByNm2o89.js';
|
|
10
|
-
export { ParsedAssistantUserMessage, createSlackAssistantThreadContextStore, parseSlackMessageActivityFromMessageEvent } from '@cuylabs/channel-slack/assistant';
|
|
11
|
-
export { CreateSlackFinalResponseArtifactPublisherOptions, SlackFinalResponseArtifactContext, SlackFinalResponseArtifactDeliveryMode, SlackFinalResponseArtifactPublisher, SlackFinalResponseArtifactResult, SlackFinalResponseArtifactValueResolver, createSlackFinalResponseArtifactPublisher } from './artifacts/index.js';
|
|
2
|
+
export { SlackApprovalRequest, SlackEventBridgeOptions, SlackEventInteractiveRequestHandler, SlackHumanInputRequest, SlackInteractiveRequest, SlackInteractiveRequestBaseContext, SlackInteractiveRequestContext, SlackInteractiveRequestHandler, UnsupportedSlackInteractiveRequestError, adaptAgentTurnSourceToSlackTurnSource, bridgeAgentEventsToSlack, mapAgentEventToSlackTurnEvent, mapAgentSlackEventBridgeOptionsToRuntimeOptions, resolveSlackEventBridgeOptions } from './shared/index.js';
|
|
12
3
|
export { LoadSlackAgentTurnHistoryContextOptions, SlackAgentTurnHistoryContextResult, SlackAgentTurnHistoryOptions, SlackAgentTurnHistoryProfileResolver, emptySlackAgentTurnHistoryContextResult, loadSlackAgentTurnHistoryContext } from './history/index.js';
|
|
13
|
-
export { S as SlackInteractiveApprovalRequest, a as SlackInteractiveController, b as SlackInteractiveControllerOptions, c as SlackInteractiveHumanInputRequest, d as SlackInteractivePendingWaiter, e as SlackInteractivePostedMessage, f as SlackInteractiveRequestWaitOptions, g as SlackInteractiveResolution } from './types-Bz4OYEAV.js';
|
|
14
|
-
export { createSlackInteractiveController } from './interactive/index.js';
|
|
15
|
-
export { createSlackAgentViewWorkflowController } from './views/index.js';
|
|
16
|
-
export { C as CreateSlackAgentViewWorkflowControllerOptions, S as SlackAgentViewStateValue, a as SlackAgentViewStateValues, b as SlackAgentViewWorkflow, c as SlackAgentViewWorkflowContext, d as SlackAgentViewWorkflowController, e as SlackAgentViewWorkflowDefinition, f as extractSlackAgentViewStateValues, r as readSlackAgentViewStateValue } from './types-CiwGU6zC.js';
|
|
17
4
|
export { InspectSlackTurnStatusVisibilityOptions, ResolvedSlackTurnStatusVisibilityOptions, RouteSlackAgentEventOptions, SlackActiveToolCall, SlackAgentEventQueue, SlackAgentEventQueueState, SlackSubagentCompletionMessage, SlackSubagentCompletionMessageFormatterOptions, SlackSubagentCompletionNotifierOptions, SlackSubagentCompletionPoster, SlackSubagentCompletionRun, SlackSubagentCompletionSlackContext, SlackSubagentCompletionTurnContext, SlackTurnActivityState, SlackTurnPhase, SlackTurnStatusVisibilityOptions, SlackTurnStatusVisibilityState, SlackTurnStatusVisibilityWarning, SlackTypedApprovalAction, coalesceSlackAgentEvents, createSlackSubagentCompletionNotifier, formatDefaultSlackSubagentCompletionMessage, immediateSlackTextResponse, inspectSlackTurnStatusVisibility, isAbortLikeError, isRunningAgentTurnError, isSlackCancelMessage, isSlackSubagentTerminalEvent, isSlackTerminalTurnPhase, isSlackWaitingForHumanTurnPhase, recordSlackTurnActivity, resolveSlackTurnStatusVisibilityOptions, resolveSlackTypedApprovalAction, routeSlackAgentEvent, shouldInspectSlackTurnStatusVisibility, shouldQueueSlackAgentEvent } from './source/index.js';
|
|
18
|
-
export { MountSlackAgentOptions, MountSlackAgentResult, mountSlackAgent } from './express.js';
|
|
19
|
-
export { MountSlackAssistantAgentOptions, MountSlackAssistantAgentResult, mountSlackAssistantAgent } from './express-assistant.js';
|
|
20
|
-
export { MountSlackAgentAppSocketOptions, MountSlackAgentAppSocketResult, MountSlackAssistantAgentSocketOptions, MountSlackAssistantAgentSocketResult, mountSlackAgentAppSocket, mountSlackAssistantAgentSocket } from './socket.js';
|
|
21
|
-
export { MountSlackAgentAppOptions, MountSlackAgentAppResult, mountSlackAgentApp } from './app.js';
|
|
22
5
|
export { CreateSlackMcpServerConfigOptions, SLACK_MCP_URL, createSlackMcpServerConfig } from './mcp.js';
|
|
23
|
-
export { MountSlackAgentAppTurnRequestContext } from './app-surface.js';
|
|
24
6
|
import '@cuylabs/agent-core';
|
|
25
7
|
import '@cuylabs/channel-slack/core';
|
|
26
8
|
import '@cuylabs/channel-slack/responses';
|
|
27
9
|
import '@cuylabs/channel-slack/runtime';
|
|
28
10
|
import '@cuylabs/channel-slack/interactive';
|
|
29
|
-
import '@slack/bolt';
|
|
30
|
-
import '@slack/web-api';
|
|
31
|
-
import '@cuylabs/channel-slack/feedback';
|
|
32
|
-
import '@cuylabs/channel-slack/artifacts';
|
|
33
11
|
import '@cuylabs/channel-slack/history';
|
|
34
|
-
import '@
|
|
12
|
+
import '@slack/web-api';
|
|
35
13
|
import '@cuylabs/agent-core/dispatch';
|
|
36
|
-
import 'node:http';
|
|
37
|
-
import 'express';
|
|
38
|
-
import '@cuylabs/channel-slack/transports/http';
|
|
39
|
-
import '@cuylabs/channel-slack/auth';
|
|
40
|
-
import '@cuylabs/channel-slack/transports/socket';
|
|
41
14
|
import '@cuylabs/agent-core/mcp';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
SLACK_MCP_URL,
|
|
3
|
+
createSlackMcpServerConfig
|
|
4
|
+
} from "./chunk-RFHXERNL.js";
|
|
4
5
|
import {
|
|
5
6
|
emptySlackAgentTurnHistoryContextResult,
|
|
6
7
|
loadSlackAgentTurnHistoryContext
|
|
7
8
|
} from "./chunk-P7PFQ3SQ.js";
|
|
8
|
-
import {
|
|
9
|
-
createSlackInteractiveController
|
|
10
|
-
} from "./chunk-OP27SSZU.js";
|
|
11
9
|
import {
|
|
12
10
|
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
UnsupportedSlackInteractiveRequestError,
|
|
12
|
+
adaptAgentTurnSourceToSlackTurnSource,
|
|
13
|
+
bridgeAgentEventsToSlack,
|
|
14
|
+
createSlackContextFragmentMiddleware,
|
|
15
|
+
mapAgentEventToSlackTurnEvent,
|
|
16
|
+
mapAgentSlackEventBridgeOptionsToRuntimeOptions,
|
|
17
|
+
resolveSlackEventBridgeOptions
|
|
18
|
+
} from "./chunk-U6RC4SXN.js";
|
|
15
19
|
import {
|
|
16
20
|
coalesceSlackAgentEvents,
|
|
17
21
|
createSlackSubagentCompletionNotifier,
|
|
@@ -31,65 +35,17 @@ import {
|
|
|
31
35
|
shouldInspectSlackTurnStatusVisibility,
|
|
32
36
|
shouldQueueSlackAgentEvent
|
|
33
37
|
} from "./chunk-C7VSW4ZM.js";
|
|
34
|
-
import {
|
|
35
|
-
createSlackAgentViewWorkflowController,
|
|
36
|
-
extractSlackAgentViewStateValues,
|
|
37
|
-
readSlackAgentViewStateValue
|
|
38
|
-
} from "./chunk-C7CHMYV6.js";
|
|
39
|
-
import {
|
|
40
|
-
mountSlackAgentApp
|
|
41
|
-
} from "./chunk-P2DIC42J.js";
|
|
42
|
-
import {
|
|
43
|
-
mountSlackAssistantAgent
|
|
44
|
-
} from "./chunk-DS6E5OEJ.js";
|
|
45
|
-
import {
|
|
46
|
-
mountSlackAgent
|
|
47
|
-
} from "./chunk-QFDXKCAQ.js";
|
|
48
|
-
import {
|
|
49
|
-
SLACK_MCP_URL,
|
|
50
|
-
createSlackMcpServerConfig
|
|
51
|
-
} from "./chunk-RFHXERNL.js";
|
|
52
|
-
import {
|
|
53
|
-
mountSlackAgentAppSocket,
|
|
54
|
-
mountSlackAssistantAgentSocket
|
|
55
|
-
} from "./chunk-6EMFBOXD.js";
|
|
56
|
-
import "./chunk-Q2GU4QLZ.js";
|
|
57
|
-
import {
|
|
58
|
-
createSlackAssistantBridge,
|
|
59
|
-
createSlackAssistantThreadContextStore,
|
|
60
|
-
parseSlackMessageActivityFromMessageEvent,
|
|
61
|
-
resolveAssistantSessionId
|
|
62
|
-
} from "./chunk-GEFK72VO.js";
|
|
63
|
-
import "./chunk-ELR6MQD7.js";
|
|
64
|
-
import {
|
|
65
|
-
createSlackChannelAdapter,
|
|
66
|
-
createSlackSessionMap
|
|
67
|
-
} from "./chunk-KQPUQJ57.js";
|
|
68
|
-
import {
|
|
69
|
-
UnsupportedSlackInteractiveRequestError,
|
|
70
|
-
bridgeAgentEventsToSlack,
|
|
71
|
-
mapAgentEventToSlackTurnEvent,
|
|
72
|
-
mapAgentSlackEventBridgeOptionsToRuntimeOptions,
|
|
73
|
-
resolveSlackEventBridgeOptions
|
|
74
|
-
} from "./chunk-L5RAGYVJ.js";
|
|
75
38
|
export {
|
|
76
39
|
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
77
40
|
SLACK_MCP_URL,
|
|
78
41
|
UnsupportedSlackInteractiveRequestError,
|
|
42
|
+
adaptAgentTurnSourceToSlackTurnSource,
|
|
79
43
|
bridgeAgentEventsToSlack,
|
|
80
44
|
coalesceSlackAgentEvents,
|
|
81
|
-
createSlackAgentViewWorkflowController,
|
|
82
|
-
createSlackAssistantBridge,
|
|
83
|
-
createSlackAssistantThreadContextStore,
|
|
84
|
-
createSlackChannelAdapter,
|
|
85
45
|
createSlackContextFragmentMiddleware,
|
|
86
|
-
createSlackFinalResponseArtifactPublisher,
|
|
87
|
-
createSlackInteractiveController,
|
|
88
46
|
createSlackMcpServerConfig,
|
|
89
|
-
createSlackSessionMap,
|
|
90
47
|
createSlackSubagentCompletionNotifier,
|
|
91
48
|
emptySlackAgentTurnHistoryContextResult,
|
|
92
|
-
extractSlackAgentViewStateValues,
|
|
93
49
|
formatDefaultSlackSubagentCompletionMessage,
|
|
94
50
|
immediateSlackTextResponse,
|
|
95
51
|
inspectSlackTurnStatusVisibility,
|
|
@@ -102,15 +58,7 @@ export {
|
|
|
102
58
|
loadSlackAgentTurnHistoryContext,
|
|
103
59
|
mapAgentEventToSlackTurnEvent,
|
|
104
60
|
mapAgentSlackEventBridgeOptionsToRuntimeOptions,
|
|
105
|
-
mountSlackAgent,
|
|
106
|
-
mountSlackAgentApp,
|
|
107
|
-
mountSlackAgentAppSocket,
|
|
108
|
-
mountSlackAssistantAgent,
|
|
109
|
-
mountSlackAssistantAgentSocket,
|
|
110
|
-
parseSlackMessageActivityFromMessageEvent,
|
|
111
|
-
readSlackAgentViewStateValue,
|
|
112
61
|
recordSlackTurnActivity,
|
|
113
|
-
resolveAssistantSessionId,
|
|
114
62
|
resolveSlackEventBridgeOptions,
|
|
115
63
|
resolveSlackTurnStatusVisibilityOptions,
|
|
116
64
|
resolveSlackTypedApprovalAction,
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,14 +1,148 @@
|
|
|
1
1
|
export { D as DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY, S as SlackContextFragmentMiddlewareOptions, a as SlackContextFragmentPayload, b as SlackContextFragmentResolver, c as SlackContextFragmentResolverContext, d as createSlackContextFragmentMiddleware } from '../context-fragments-CQEDcjYR.js';
|
|
2
|
-
import { AgentEvent } from '@cuylabs/agent-core';
|
|
2
|
+
import { AgentEvent, ApprovalEvent, AgentTurnSource } from '@cuylabs/agent-core';
|
|
3
3
|
import { SlackResponseSink } from '@cuylabs/channel-slack/responses';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { SlackFinalResponseArtifactPublisher, SlackFinalResponseArtifactDeliveryMode, SlackFinalResponseArtifactContext, SlackFinalResponseArtifactResult, SlackTurnEvent, SlackEventBridgeOptions as SlackEventBridgeOptions$1, SlackTurnSource } from '@cuylabs/channel-slack/runtime';
|
|
5
|
+
import { SlackInteractiveRequestBaseContext as SlackInteractiveRequestBaseContext$1, SlackInteractiveRequestContext as SlackInteractiveRequestContext$1 } from '@cuylabs/channel-slack/interactive';
|
|
6
|
+
import { SlackActivityInfo, SlackUserIdentity } from '@cuylabs/channel-slack/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Agent Core interactive request contracts for the Slack event bridge.
|
|
10
|
+
*
|
|
11
|
+
* Generic Slack message/responder primitives live in `@cuylabs/channel-slack`.
|
|
12
|
+
* This module narrows the request payloads to Agent Core events.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
type SlackApprovalRequest = Extract<AgentEvent, {
|
|
16
|
+
type: "approval-request";
|
|
17
|
+
}>["request"];
|
|
18
|
+
type SlackHumanInputRequest = Extract<AgentEvent, {
|
|
19
|
+
type: "human-input-request";
|
|
20
|
+
}>["request"];
|
|
21
|
+
type SlackInteractiveRequest = SlackApprovalRequest | SlackHumanInputRequest;
|
|
22
|
+
interface SlackInteractiveRequestBaseContext extends Omit<SlackInteractiveRequestBaseContext$1, "request"> {
|
|
23
|
+
request: SlackInteractiveRequest;
|
|
24
|
+
}
|
|
25
|
+
interface SlackInteractiveRequestContext extends Omit<SlackInteractiveRequestContext$1, "request"> {
|
|
26
|
+
slackActivity: SlackActivityInfo;
|
|
27
|
+
user: SlackUserIdentity;
|
|
28
|
+
request: SlackInteractiveRequest;
|
|
29
|
+
}
|
|
30
|
+
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
31
|
+
type SlackEventInteractiveRequestHandler = (context: SlackInteractiveRequestBaseContext) => boolean | void | Promise<boolean | void>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Event-bridge configuration. The bridge is mode-aware (progressive,
|
|
35
|
+
* accumulate, chat-stream) and these options control formatting, status
|
|
36
|
+
* propagation, interactive-request handling, and chat-stream finalization.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
type HumanInputEvent = Extract<AgentEvent, {
|
|
40
|
+
type: "human-input-request";
|
|
41
|
+
}>["request"];
|
|
42
|
+
type ToolStartEvent = Extract<AgentEvent, {
|
|
43
|
+
type: "tool-start";
|
|
44
|
+
}>;
|
|
45
|
+
type ToolResultEvent = Extract<AgentEvent, {
|
|
46
|
+
type: "tool-result";
|
|
47
|
+
}>;
|
|
48
|
+
interface SlackEventBridgeOptions {
|
|
49
|
+
showReasoning: boolean;
|
|
50
|
+
/** Render root-agent tool rows/status updates. */
|
|
51
|
+
showToolUsage: boolean;
|
|
52
|
+
/** Render subagent child tool rows in the parent Slack task timeline. */
|
|
53
|
+
showSubagentToolUsage: boolean;
|
|
54
|
+
/** Include full subagent completion output in the subagent task row. */
|
|
55
|
+
showSubagentResultInTask: boolean;
|
|
56
|
+
formatToolTitle?: (toolName: string) => string;
|
|
57
|
+
formatToolUpdate: (toolName: string) => string;
|
|
58
|
+
formatToolDetails?: (event: ToolStartEvent) => string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Format the completed tool output shown in Slack task rows.
|
|
61
|
+
*
|
|
62
|
+
* Return `undefined` to use the default generic formatter. Return `null` to
|
|
63
|
+
* intentionally omit task-row output for this tool result.
|
|
64
|
+
*/
|
|
65
|
+
formatToolResultOutput?: (event: ToolResultEvent) => string | null | undefined;
|
|
66
|
+
formatToolError: (toolName: string, error: string) => string;
|
|
67
|
+
formatReasoningUpdate: () => string;
|
|
68
|
+
formatMessageText: (text: string) => string;
|
|
69
|
+
streamingMode: "progressive" | "accumulate" | "chat-stream";
|
|
70
|
+
progressiveUpdateThreshold: number;
|
|
71
|
+
progressiveUpdateIntervalMs: number;
|
|
72
|
+
chatStreamBufferSize: number;
|
|
73
|
+
/**
|
|
74
|
+
* Maximum number of Slack task-update chunks the bridge will append to a
|
|
75
|
+
* single chat stream. Task rows are a bounded UI projection, not a durable
|
|
76
|
+
* event log.
|
|
77
|
+
*/
|
|
78
|
+
maxTaskUpdates: number;
|
|
79
|
+
/**
|
|
80
|
+
* Maximum cumulative characters from task titles/details/output that the
|
|
81
|
+
* bridge will append to one chat stream.
|
|
82
|
+
*/
|
|
83
|
+
maxTaskUpdateTextChars: number;
|
|
84
|
+
/**
|
|
85
|
+
* Maximum characters for a single task details/output field.
|
|
86
|
+
*/
|
|
87
|
+
maxTaskUpdateFieldChars: number;
|
|
88
|
+
interactiveMode: "message-and-error" | "ignore";
|
|
89
|
+
handleInteractiveRequest?: SlackEventInteractiveRequestHandler;
|
|
90
|
+
formatApprovalRequired: (request: ApprovalEvent) => string;
|
|
91
|
+
formatHumanInputRequired: (request: HumanInputEvent) => string;
|
|
92
|
+
/**
|
|
93
|
+
* Optional hook called whenever the bridge's status label changes — used by
|
|
94
|
+
* the assistant bridge to update the assistant pane's status line via
|
|
95
|
+
* `assistant.threads.setStatus`. Errors are swallowed by the caller.
|
|
96
|
+
*/
|
|
97
|
+
onStatusChange?: (label: string, event: AgentEvent | undefined) => void | Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Optional final-args passthrough for `chatStream.stop(...)`. When the
|
|
100
|
+
* bridge stops the chat stream on `complete`, these args (e.g. final
|
|
101
|
+
* `blocks` for a feedback widget) are merged into the `stop` call. The
|
|
102
|
+
* existing `markdown_text` final-text fallback always wins on text fields.
|
|
103
|
+
*/
|
|
104
|
+
chatStreamFinalArgs?: {
|
|
105
|
+
blocks?: unknown[];
|
|
106
|
+
} & Record<string, unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* Optional post-processing hook for publishing a rich artifact from the final
|
|
109
|
+
* accumulated response, such as a Slack Canvas for long answers.
|
|
110
|
+
*/
|
|
111
|
+
publishFinalResponseArtifact?: SlackFinalResponseArtifactPublisher;
|
|
112
|
+
/**
|
|
113
|
+
* Controls whether artifact publication is additive or becomes the primary
|
|
114
|
+
* final-answer surface.
|
|
115
|
+
*
|
|
116
|
+
* - `supplemental`: finalize the Slack text normally, then publish artifact.
|
|
117
|
+
* - `replace`: publish artifact first and use a compact Slack final message.
|
|
118
|
+
*
|
|
119
|
+
* @default "supplemental"
|
|
120
|
+
*/
|
|
121
|
+
finalResponseArtifactMode?: SlackFinalResponseArtifactDeliveryMode;
|
|
122
|
+
/**
|
|
123
|
+
* When replacement mode is active, continue streaming text up to this many
|
|
124
|
+
* raw characters, then suppress further text deltas and publish the full
|
|
125
|
+
* answer as an artifact at completion. This preserves normal short-answer
|
|
126
|
+
* streaming without flooding Slack for long answers.
|
|
127
|
+
*
|
|
128
|
+
* @default 4000
|
|
129
|
+
*/
|
|
130
|
+
finalResponseArtifactStreamThreshold?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Notice appended when replacement mode suppresses the remaining text stream.
|
|
133
|
+
*/
|
|
134
|
+
formatFinalResponseArtifactContinuationNotice?: (context: Pick<SlackFinalResponseArtifactContext, "text" | "formattedText">) => string;
|
|
135
|
+
/**
|
|
136
|
+
* Final compact message used when an artifact replaces the full Slack text.
|
|
137
|
+
*/
|
|
138
|
+
formatFinalResponseArtifactMessage?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => string;
|
|
139
|
+
/**
|
|
140
|
+
* Called when `publishFinalResponseArtifact` throws. Errors from this hook
|
|
141
|
+
* are swallowed so artifact publication cannot break a completed turn.
|
|
142
|
+
*/
|
|
143
|
+
onFinalResponseArtifactError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
declare function resolveSlackEventBridgeOptions(partial: Partial<SlackEventBridgeOptions>): SlackEventBridgeOptions;
|
|
12
146
|
|
|
13
147
|
/**
|
|
14
148
|
* Agent Core compatibility bridge.
|
|
@@ -57,4 +191,6 @@ declare class UnsupportedSlackInteractiveRequestError extends Error {
|
|
|
57
191
|
constructor(kind: "approval" | "human-input", requestId: string, message: string);
|
|
58
192
|
}
|
|
59
193
|
|
|
60
|
-
|
|
194
|
+
declare function adaptAgentTurnSourceToSlackTurnSource(source: AgentTurnSource): SlackTurnSource;
|
|
195
|
+
|
|
196
|
+
export { type SlackApprovalRequest, type SlackEventBridgeOptions, type SlackEventInteractiveRequestHandler, type SlackHumanInputRequest, type SlackInteractiveRequest, type SlackInteractiveRequestBaseContext, type SlackInteractiveRequestContext, type SlackInteractiveRequestHandler, UnsupportedSlackInteractiveRequestError, adaptAgentTurnSourceToSlackTurnSource, bridgeAgentEventsToSlack, mapAgentEventToSlackTurnEvent, mapAgentSlackEventBridgeOptionsToRuntimeOptions, resolveSlackEventBridgeOptions };
|
package/dist/shared/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
3
|
-
createSlackContextFragmentMiddleware
|
|
4
|
-
} from "../chunk-A2PLAVW6.js";
|
|
5
|
-
import {
|
|
6
3
|
UnsupportedSlackInteractiveRequestError,
|
|
4
|
+
adaptAgentTurnSourceToSlackTurnSource,
|
|
7
5
|
bridgeAgentEventsToSlack,
|
|
6
|
+
createSlackContextFragmentMiddleware,
|
|
8
7
|
mapAgentEventToSlackTurnEvent,
|
|
9
8
|
mapAgentSlackEventBridgeOptionsToRuntimeOptions,
|
|
10
9
|
resolveSlackEventBridgeOptions
|
|
11
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-U6RC4SXN.js";
|
|
12
11
|
export {
|
|
13
12
|
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
14
13
|
UnsupportedSlackInteractiveRequestError,
|
|
14
|
+
adaptAgentTurnSourceToSlackTurnSource,
|
|
15
15
|
bridgeAgentEventsToSlack,
|
|
16
16
|
createSlackContextFragmentMiddleware,
|
|
17
17
|
mapAgentEventToSlackTurnEvent,
|
package/docs/README.md
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`@cuylabs/channel-slack-agent-core` is the `@cuylabs/agent-core` runtime binding
|
|
4
4
|
for direct Slack traffic. It composes `@cuylabs/channel-slack` primitives with
|
|
5
|
-
Agent Core turn sources, event streams, scopes, context fragments
|
|
6
|
-
and human-input requests.
|
|
5
|
+
Agent Core turn sources, event streams, scopes, and context fragments.
|
|
7
6
|
|
|
8
7
|
## Reference
|
|
9
8
|
|
|
@@ -12,7 +11,6 @@ and human-input requests.
|
|
|
12
11
|
|
|
13
12
|
## Concepts
|
|
14
13
|
|
|
15
|
-
- [Final response artifacts](concepts/final-response-artifacts.md)
|
|
16
14
|
- [Interactive requests](concepts/interactive-requests.md)
|
|
15
|
+
- [Final response artifacts](concepts/final-response-artifacts.md)
|
|
17
16
|
- [Tool task rendering](concepts/tool-task-rendering.md)
|
|
18
|
-
- [View workflows](concepts/view-workflows.md)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Final Response Artifacts
|
|
2
2
|
|
|
3
|
-
Final response artifacts let a Slack host publish a rich surface from
|
|
4
|
-
completed
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Final response artifacts let a Slack host publish a rich surface from a
|
|
4
|
+
completed Slack turn response. The built-in publisher creates a Slack Canvas
|
|
5
|
+
for long answers and can fall back to a text file when Canvas publication is
|
|
6
|
+
unavailable.
|
|
7
7
|
|
|
8
8
|
```typescript
|
|
9
|
-
import {
|
|
9
|
+
import { mountSlackApp } from "@cuylabs/channel-slack/app";
|
|
10
|
+
import { createSlackFinalResponseArtifactPublisher } from "@cuylabs/channel-slack/artifacts";
|
|
11
|
+
import { adaptAgentTurnSourceToSlackTurnSource } from "@cuylabs/channel-slack-agent-core";
|
|
10
12
|
|
|
11
13
|
const publishFinalResponseArtifact = createSlackFinalResponseArtifactPublisher({
|
|
12
14
|
minCharacters: 4000,
|
|
@@ -14,8 +16,8 @@ const publishFinalResponseArtifact = createSlackFinalResponseArtifactPublisher({
|
|
|
14
16
|
fallback: "file",
|
|
15
17
|
});
|
|
16
18
|
|
|
17
|
-
await
|
|
18
|
-
source,
|
|
19
|
+
await mountSlackApp({
|
|
20
|
+
source: adaptAgentTurnSourceToSlackTurnSource(agent),
|
|
19
21
|
publishFinalResponseArtifact,
|
|
20
22
|
finalResponseArtifactMode: "replace",
|
|
21
23
|
finalResponseArtifactStreamThreshold: 4000,
|