@cuylabs/channel-slack 0.9.0 → 0.10.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/dist/chunk-IAQXQESO.js +1008 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/interactive/index.d.ts +4 -91
- package/dist/runtime/index.d.ts +260 -0
- package/dist/runtime/index.js +10 -0
- package/dist/types-Cywfj8Mj.d.ts +91 -0
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackApp
|
|
|
3
3
|
export { S as SlackApprovalRequest, a as SlackEventInteractiveRequestHandler, b as SlackHumanInputRequest, c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, e as SlackInteractiveRequest, f as SlackInteractiveRequestBaseContext, g as SlackInteractiveRequestContext, h as SlackInteractiveRequestHandler, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from './interactive-CbKYkkc_.js';
|
|
4
4
|
export { RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, SlackTurnCancelActionContext, SlackTurnCancelActionHandler, SlackTurnCancelButtonValue, SlackTurnCancelMessage, SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId } from './turn-controls/index.js';
|
|
5
5
|
export { InMemorySlackThreadParticipationStateStoreOptions, PostgresSlackMessagePolicyPruneResult, PostgresSlackMessagePolicyStateStore, PostgresSlackMessagePolicyStateStoreOptions, PostgresSlackThreadParticipationStateStore, PostgresSlackThreadParticipationStateStoreOptions, SlackAsyncMessagePolicyConfig, SlackAsyncMessagePolicyResolver, SlackChannelMessagePolicy, SlackMentionedThreadState, SlackMessagePolicyAcceptReason, SlackMessagePolicyAcceptedDecision, SlackMessagePolicyConfig, SlackMessagePolicyDecision, SlackMessagePolicyPostgresClient, SlackMessagePolicyRejectReason, SlackMessagePolicyRejectedDecision, SlackMessagePolicyResolver, SlackMessagePolicyStateContext, SlackMessagePolicyStateStore, SlackQuietThreadRejectedDecision, SlackSyncMessagePolicyStateStore, SlackThreadAwareMessagePolicyConfig, SlackThreadAwareMessagePolicyDecision, SlackThreadAwareMessagePolicyResolver, SlackThreadParticipationEligibility, SlackThreadParticipationEligibilityOptions, SlackThreadParticipationMode, SlackThreadParticipationPostgresClient, SlackThreadParticipationPruneResult, SlackThreadParticipationReactivation, SlackThreadParticipationState, SlackThreadParticipationStateContext, SlackThreadParticipationStateStore, SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createAsyncSlackThreadAwareMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createInMemorySlackThreadParticipationStateStore, createPostgresSlackMessagePolicyStateStore, createPostgresSlackThreadParticipationStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, initializePostgresSlackThreadParticipationState, prunePostgresSlackMessagePolicyState, prunePostgresSlackThreadParticipationState, resolveSlackThreadParticipationEligibility, shouldRegisterSlackPassiveChannelMessages } from './policy/index.js';
|
|
6
|
+
export { SlackEventBridgeOptions, SlackFinalResponseArtifactContext, SlackFinalResponseArtifactDeliveryMode, SlackFinalResponseArtifactPublisher, SlackFinalResponseArtifactResult, SlackTurnApprovalRequestEvent, SlackTurnApprovalResolvedEvent, SlackTurnCompleteEvent, SlackTurnErrorEvent, SlackTurnEvent, SlackTurnEventBase, SlackTurnHumanInputRequestEvent, SlackTurnHumanInputResolvedEvent, SlackTurnReasoningEndEvent, SlackTurnReasoningStartEvent, SlackTurnSource, SlackTurnSourceChatOptions, SlackTurnStatus, SlackTurnStatusEvent, SlackTurnSubagentCompleteEvent, SlackTurnSubagentErrorEvent, SlackTurnSubagentEventBase, SlackTurnSubagentEventEvent, SlackTurnSubagentStartEvent, SlackTurnTextDeltaEvent, SlackTurnTextEndEvent, SlackTurnTextStartEvent, SlackTurnToolErrorEvent, SlackTurnToolResultEvent, SlackTurnToolStartEvent, UnsupportedSlackInteractiveRequestError, bridgeSlackTurnEventsToSlack, resolveSlackEventBridgeOptions } from './runtime/index.js';
|
|
6
7
|
export { L as Logger } from './logging-Bl3HfcC8.js';
|
|
7
8
|
import '@slack/types';
|
|
8
9
|
import '@slack/bolt';
|
|
10
|
+
import './types-C8nkPuD4.js';
|
|
11
|
+
import './types-Cywfj8Mj.js';
|
|
12
|
+
import './responses/index.js';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
resolveSlackThreadParticipationEligibility,
|
|
16
16
|
shouldRegisterSlackPassiveChannelMessages
|
|
17
17
|
} from "./chunk-DNVSH7H5.js";
|
|
18
|
+
import {
|
|
19
|
+
UnsupportedSlackInteractiveRequestError,
|
|
20
|
+
bridgeSlackTurnEventsToSlack,
|
|
21
|
+
resolveSlackEventBridgeOptions
|
|
22
|
+
} from "./chunk-IAQXQESO.js";
|
|
18
23
|
import {
|
|
19
24
|
currentSlackTurnContext,
|
|
20
25
|
formatSlackAttributedFollowUp,
|
|
@@ -50,6 +55,8 @@ import {
|
|
|
50
55
|
} from "./chunk-FPCE5V5Y.js";
|
|
51
56
|
export {
|
|
52
57
|
SLACK_TURN_CANCEL_ACTION_ID,
|
|
58
|
+
UnsupportedSlackInteractiveRequestError,
|
|
59
|
+
bridgeSlackTurnEventsToSlack,
|
|
53
60
|
createAsyncSlackMessagePolicyResolver,
|
|
54
61
|
createAsyncSlackThreadAwareMessagePolicyResolver,
|
|
55
62
|
createInMemorySlackMessagePolicyStateStore,
|
|
@@ -80,6 +87,7 @@ export {
|
|
|
80
87
|
prunePostgresSlackThreadParticipationState,
|
|
81
88
|
registerSlackTurnCancelAction,
|
|
82
89
|
resolveSlackChannelType,
|
|
90
|
+
resolveSlackEventBridgeOptions,
|
|
83
91
|
resolveSlackMessageFormatter,
|
|
84
92
|
resolveSlackThreadParticipationEligibility,
|
|
85
93
|
resolveSlackTurnCancelActionId,
|
|
@@ -1,96 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as SlackInteractiveApprovalRequest, S as SlackInteractiveActionIds, e as SlackInteractiveHumanInputRequest, l as SlackInteractiveResolution, i as SlackInteractiveRequestRecord, k as SlackInteractiveRequestStore } from '../types-Cywfj8Mj.js';
|
|
2
|
+
export { a as SlackInteractiveActor, b as SlackInteractiveApprovalAction, d as SlackInteractiveHumanInputOption, f as SlackInteractiveHumanInputResponse, g as SlackInteractiveMessageTarget, h as SlackInteractiveRequestHandler, j as SlackInteractiveRequestStatus, m as SlackInteractiveStoredRequest } from '../types-Cywfj8Mj.js';
|
|
3
3
|
import { View } from '@slack/types';
|
|
4
|
+
export { c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, f as SlackInteractiveRequestBaseContext, g as SlackInteractiveRequestContext, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from '../interactive-CbKYkkc_.js';
|
|
4
5
|
import '../activity-ByrD9Ftr.js';
|
|
5
6
|
|
|
6
|
-
type SlackInteractiveRequestStatus = "pending" | "resolved";
|
|
7
|
-
type SlackInteractiveApprovalAction = "allow" | "deny" | "remember";
|
|
8
|
-
type SlackInteractiveHumanInputResponse = {
|
|
9
|
-
kind: "text";
|
|
10
|
-
text: string;
|
|
11
|
-
} | {
|
|
12
|
-
kind: "confirm";
|
|
13
|
-
confirmed: boolean;
|
|
14
|
-
text: string;
|
|
15
|
-
} | {
|
|
16
|
-
kind: "choice";
|
|
17
|
-
selected: string[];
|
|
18
|
-
text: string;
|
|
19
|
-
};
|
|
20
|
-
interface SlackInteractiveApprovalRequest {
|
|
21
|
-
id: string;
|
|
22
|
-
tool: string;
|
|
23
|
-
args: unknown;
|
|
24
|
-
description: string;
|
|
25
|
-
risk: string;
|
|
26
|
-
rememberScopes?: string[];
|
|
27
|
-
defaultRememberScope?: string;
|
|
28
|
-
}
|
|
29
|
-
interface SlackInteractiveHumanInputOption {
|
|
30
|
-
label: string;
|
|
31
|
-
value?: string;
|
|
32
|
-
description?: string;
|
|
33
|
-
}
|
|
34
|
-
interface SlackInteractiveHumanInputRequest {
|
|
35
|
-
id: string;
|
|
36
|
-
kind: "text" | "confirm" | "choice";
|
|
37
|
-
title: string;
|
|
38
|
-
question: string;
|
|
39
|
-
options?: SlackInteractiveHumanInputOption[];
|
|
40
|
-
allowMultiple?: boolean;
|
|
41
|
-
placeholder?: string;
|
|
42
|
-
confirmLabel?: string;
|
|
43
|
-
denyLabel?: string;
|
|
44
|
-
}
|
|
45
|
-
type SlackInteractiveStoredRequest = SlackInteractiveApprovalRequest | SlackInteractiveHumanInputRequest;
|
|
46
|
-
type SlackInteractiveResolution = {
|
|
47
|
-
kind: "approval";
|
|
48
|
-
action: SlackInteractiveApprovalAction;
|
|
49
|
-
feedback?: string;
|
|
50
|
-
rememberScope?: string;
|
|
51
|
-
} | {
|
|
52
|
-
kind: "human-input";
|
|
53
|
-
response: SlackInteractiveHumanInputResponse;
|
|
54
|
-
};
|
|
55
|
-
interface SlackInteractiveMessageTarget {
|
|
56
|
-
channel: string;
|
|
57
|
-
ts: string;
|
|
58
|
-
threadTs?: string;
|
|
59
|
-
userId: string;
|
|
60
|
-
teamId?: string;
|
|
61
|
-
}
|
|
62
|
-
interface SlackInteractiveRequestRecord {
|
|
63
|
-
id: string;
|
|
64
|
-
kind: SlackInteractiveResolution["kind"];
|
|
65
|
-
request: SlackInteractiveStoredRequest;
|
|
66
|
-
status: SlackInteractiveRequestStatus;
|
|
67
|
-
createdAt: string;
|
|
68
|
-
updatedAt: string;
|
|
69
|
-
target?: SlackInteractiveMessageTarget;
|
|
70
|
-
resolution?: SlackInteractiveResolution;
|
|
71
|
-
}
|
|
72
|
-
interface SlackInteractiveRequestStore {
|
|
73
|
-
get(requestId: string): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
74
|
-
upsert(record: SlackInteractiveRequestRecord): Promise<SlackInteractiveRequestRecord>;
|
|
75
|
-
attachTarget(requestId: string, target: SlackInteractiveMessageTarget): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
76
|
-
resolve(requestId: string, resolution: SlackInteractiveResolution): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
77
|
-
delete(requestId: string): Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
interface SlackInteractiveActionIds {
|
|
80
|
-
approvalAllow: string;
|
|
81
|
-
approvalDeny: string;
|
|
82
|
-
approvalRemember: string;
|
|
83
|
-
humanConfirm: string;
|
|
84
|
-
humanDeny: string;
|
|
85
|
-
humanOpen: string;
|
|
86
|
-
humanSubmit: string;
|
|
87
|
-
}
|
|
88
|
-
interface SlackInteractiveActor {
|
|
89
|
-
userId: string;
|
|
90
|
-
teamId?: string;
|
|
91
|
-
}
|
|
92
|
-
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
93
|
-
|
|
94
7
|
declare function buildApprovalRequestMessage(request: SlackInteractiveApprovalRequest, actionIds: SlackInteractiveActionIds): {
|
|
95
8
|
text: string;
|
|
96
9
|
blocks: unknown[];
|
|
@@ -151,4 +64,4 @@ declare function prunePostgresSlackInteractiveRequestStore({ client, pruneBatchS
|
|
|
151
64
|
tableName?: string;
|
|
152
65
|
}): Promise<PostgresSlackInteractiveRequestPruneResult>;
|
|
153
66
|
|
|
154
|
-
export { type PostgresSlackInteractiveRequestPruneResult, type PostgresSlackInteractiveRequestStore, type PostgresSlackInteractiveRequestStoreOptions,
|
|
67
|
+
export { type PostgresSlackInteractiveRequestPruneResult, type PostgresSlackInteractiveRequestStore, type PostgresSlackInteractiveRequestStoreOptions, SlackInteractiveActionIds, SlackInteractiveApprovalRequest, SlackInteractiveHumanInputRequest, type SlackInteractivePostgresClient, SlackInteractiveRequestRecord, SlackInteractiveRequestStore, SlackInteractiveResolution, buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createPostgresSlackInteractiveRequestStore, decodeActionValue, encodeActionValue, initializePostgresSlackInteractiveRequestStore, nowIso, prunePostgresSlackInteractiveRequestStore };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { d as SlackArtifactClient, g as SlackArtifactPublication } from '../types-C8nkPuD4.js';
|
|
2
|
+
import { c as SlackInteractiveApprovalRequest, e as SlackInteractiveHumanInputRequest } from '../types-Cywfj8Mj.js';
|
|
3
|
+
import { a as SlackEventInteractiveRequestHandler } from '../interactive-CbKYkkc_.js';
|
|
4
|
+
import { SlackResponseSink } from '../responses/index.js';
|
|
5
|
+
import '../activity-ByrD9Ftr.js';
|
|
6
|
+
|
|
7
|
+
interface SlackTurnSourceChatOptions {
|
|
8
|
+
abort?: AbortSignal;
|
|
9
|
+
system?: string;
|
|
10
|
+
}
|
|
11
|
+
interface SlackTurnSource {
|
|
12
|
+
chat(sessionId: string, message: string, options?: SlackTurnSourceChatOptions): AsyncGenerator<SlackTurnEvent>;
|
|
13
|
+
}
|
|
14
|
+
interface SlackFinalResponseArtifactContext {
|
|
15
|
+
text: string;
|
|
16
|
+
formattedText: string;
|
|
17
|
+
client: SlackArtifactClient;
|
|
18
|
+
channelId: string;
|
|
19
|
+
threadTs?: string;
|
|
20
|
+
}
|
|
21
|
+
interface SlackFinalResponseArtifactResult {
|
|
22
|
+
publication: SlackArtifactPublication;
|
|
23
|
+
}
|
|
24
|
+
type SlackFinalResponseArtifactDeliveryMode = "supplemental" | "replace";
|
|
25
|
+
type SlackFinalResponseArtifactPublisher = (context: SlackFinalResponseArtifactContext) => Promise<SlackFinalResponseArtifactResult | undefined>;
|
|
26
|
+
type SlackTurnStatus = "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "waiting-input" | "processing" | "error" | string;
|
|
27
|
+
interface SlackTurnEventBase {
|
|
28
|
+
type: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
interface SlackTurnTextStartEvent extends SlackTurnEventBase {
|
|
32
|
+
type: "text-start";
|
|
33
|
+
}
|
|
34
|
+
interface SlackTurnTextDeltaEvent extends SlackTurnEventBase {
|
|
35
|
+
type: "text-delta";
|
|
36
|
+
text: string;
|
|
37
|
+
}
|
|
38
|
+
interface SlackTurnTextEndEvent extends SlackTurnEventBase {
|
|
39
|
+
type: "text-end";
|
|
40
|
+
}
|
|
41
|
+
interface SlackTurnReasoningStartEvent extends SlackTurnEventBase {
|
|
42
|
+
type: "reasoning-start";
|
|
43
|
+
}
|
|
44
|
+
interface SlackTurnReasoningEndEvent extends SlackTurnEventBase {
|
|
45
|
+
type: "reasoning-end";
|
|
46
|
+
}
|
|
47
|
+
interface SlackTurnToolStartEvent extends SlackTurnEventBase {
|
|
48
|
+
type: "tool-start";
|
|
49
|
+
toolCallId: string;
|
|
50
|
+
toolName: string;
|
|
51
|
+
input?: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface SlackTurnToolResultEvent extends SlackTurnEventBase {
|
|
54
|
+
type: "tool-result";
|
|
55
|
+
toolCallId: string;
|
|
56
|
+
toolName: string;
|
|
57
|
+
result?: unknown;
|
|
58
|
+
}
|
|
59
|
+
interface SlackTurnToolErrorEvent extends SlackTurnEventBase {
|
|
60
|
+
type: "tool-error";
|
|
61
|
+
toolCallId: string;
|
|
62
|
+
toolName: string;
|
|
63
|
+
error: string;
|
|
64
|
+
}
|
|
65
|
+
interface SlackTurnSubagentEventBase extends SlackTurnEventBase {
|
|
66
|
+
dispatchId: string;
|
|
67
|
+
role: string;
|
|
68
|
+
title?: string;
|
|
69
|
+
parentDispatchId?: string;
|
|
70
|
+
agentPath?: string;
|
|
71
|
+
depth?: number;
|
|
72
|
+
}
|
|
73
|
+
interface SlackTurnSubagentStartEvent extends SlackTurnSubagentEventBase {
|
|
74
|
+
type: "subagent-start";
|
|
75
|
+
}
|
|
76
|
+
interface SlackTurnSubagentEventEvent extends SlackTurnSubagentEventBase {
|
|
77
|
+
type: "subagent-event";
|
|
78
|
+
event: SlackTurnEvent;
|
|
79
|
+
}
|
|
80
|
+
interface SlackTurnSubagentCompleteEvent extends SlackTurnSubagentEventBase {
|
|
81
|
+
type: "subagent-complete";
|
|
82
|
+
output?: unknown;
|
|
83
|
+
}
|
|
84
|
+
interface SlackTurnSubagentErrorEvent extends SlackTurnSubagentEventBase {
|
|
85
|
+
type: "subagent-error";
|
|
86
|
+
error: string;
|
|
87
|
+
}
|
|
88
|
+
interface SlackTurnStatusEvent extends SlackTurnEventBase {
|
|
89
|
+
type: "status";
|
|
90
|
+
status: SlackTurnStatus;
|
|
91
|
+
}
|
|
92
|
+
interface SlackTurnCompleteEvent extends SlackTurnEventBase {
|
|
93
|
+
type: "complete";
|
|
94
|
+
output?: string;
|
|
95
|
+
}
|
|
96
|
+
interface SlackTurnErrorEvent extends SlackTurnEventBase {
|
|
97
|
+
type: "error";
|
|
98
|
+
error: unknown;
|
|
99
|
+
}
|
|
100
|
+
interface SlackTurnApprovalRequestEvent extends SlackTurnEventBase {
|
|
101
|
+
type: "approval-request";
|
|
102
|
+
request: SlackInteractiveApprovalRequest;
|
|
103
|
+
}
|
|
104
|
+
interface SlackTurnApprovalResolvedEvent extends SlackTurnEventBase {
|
|
105
|
+
type: "approval-resolved";
|
|
106
|
+
}
|
|
107
|
+
interface SlackTurnHumanInputRequestEvent extends SlackTurnEventBase {
|
|
108
|
+
type: "human-input-request";
|
|
109
|
+
request: SlackInteractiveHumanInputRequest;
|
|
110
|
+
}
|
|
111
|
+
interface SlackTurnHumanInputResolvedEvent extends SlackTurnEventBase {
|
|
112
|
+
type: "human-input-resolved";
|
|
113
|
+
}
|
|
114
|
+
type SlackTurnEvent = SlackTurnTextStartEvent | SlackTurnTextDeltaEvent | SlackTurnTextEndEvent | SlackTurnReasoningStartEvent | SlackTurnReasoningEndEvent | SlackTurnToolStartEvent | SlackTurnToolResultEvent | SlackTurnToolErrorEvent | SlackTurnSubagentStartEvent | SlackTurnSubagentEventEvent | SlackTurnSubagentCompleteEvent | SlackTurnSubagentErrorEvent | SlackTurnStatusEvent | SlackTurnCompleteEvent | SlackTurnErrorEvent | SlackTurnApprovalRequestEvent | SlackTurnApprovalResolvedEvent | SlackTurnHumanInputRequestEvent | SlackTurnHumanInputResolvedEvent;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Event-bridge configuration. The bridge is mode-aware (progressive,
|
|
118
|
+
* accumulate, chat-stream) and these options control formatting, status
|
|
119
|
+
* propagation, interactive-request handling, and chat-stream finalization.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
type ApprovalRequest = SlackTurnApprovalRequestEvent["request"];
|
|
123
|
+
type HumanInputRequest = SlackTurnHumanInputRequestEvent["request"];
|
|
124
|
+
interface SlackEventBridgeOptions {
|
|
125
|
+
showReasoning: boolean;
|
|
126
|
+
/** Render root-agent tool rows/status updates. */
|
|
127
|
+
showToolUsage: boolean;
|
|
128
|
+
/** Render subagent child tool rows in the parent Slack task timeline. */
|
|
129
|
+
showSubagentToolUsage: boolean;
|
|
130
|
+
/** Include full subagent completion output in the subagent task row. */
|
|
131
|
+
showSubagentResultInTask: boolean;
|
|
132
|
+
formatToolTitle?: (toolName: string) => string;
|
|
133
|
+
formatToolUpdate: (toolName: string) => string;
|
|
134
|
+
formatToolDetails?: (event: SlackTurnToolStartEvent) => string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Format the completed tool output shown in Slack task rows.
|
|
137
|
+
*
|
|
138
|
+
* Return `undefined` to use the default generic formatter. Return `null` to
|
|
139
|
+
* intentionally omit task-row output for this tool result.
|
|
140
|
+
*/
|
|
141
|
+
formatToolResultOutput?: (event: SlackTurnToolResultEvent) => string | null | undefined;
|
|
142
|
+
formatToolError: (toolName: string, error: string) => string;
|
|
143
|
+
formatReasoningUpdate: () => string;
|
|
144
|
+
formatMessageText: (text: string) => string;
|
|
145
|
+
streamingMode: "progressive" | "accumulate" | "chat-stream";
|
|
146
|
+
progressiveUpdateThreshold: number;
|
|
147
|
+
progressiveUpdateIntervalMs: number;
|
|
148
|
+
chatStreamBufferSize: number;
|
|
149
|
+
/**
|
|
150
|
+
* Maximum number of Slack task-update chunks the bridge will append to a
|
|
151
|
+
* single chat stream. Task rows are a bounded UI projection, not a durable
|
|
152
|
+
* event log.
|
|
153
|
+
*/
|
|
154
|
+
maxTaskUpdates: number;
|
|
155
|
+
/**
|
|
156
|
+
* Maximum cumulative characters from task titles/details/output that the
|
|
157
|
+
* bridge will append to one chat stream.
|
|
158
|
+
*/
|
|
159
|
+
maxTaskUpdateTextChars: number;
|
|
160
|
+
/**
|
|
161
|
+
* Maximum characters for a single task details/output field.
|
|
162
|
+
*/
|
|
163
|
+
maxTaskUpdateFieldChars: number;
|
|
164
|
+
interactiveMode: "message-and-error" | "ignore";
|
|
165
|
+
handleInteractiveRequest?: SlackEventInteractiveRequestHandler;
|
|
166
|
+
formatApprovalRequired: (request: ApprovalRequest) => string;
|
|
167
|
+
formatHumanInputRequired: (request: HumanInputRequest) => string;
|
|
168
|
+
/**
|
|
169
|
+
* Optional hook called whenever the bridge's status label changes — used by
|
|
170
|
+
* the assistant bridge to update the assistant pane's status line via
|
|
171
|
+
* `assistant.threads.setStatus`. Errors are swallowed by the caller.
|
|
172
|
+
*/
|
|
173
|
+
onStatusChange?: (label: string, event: SlackTurnEvent | undefined) => void | Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Optional final-args passthrough for `chatStream.stop(...)`. When the
|
|
176
|
+
* bridge stops the chat stream on `complete`, these args (e.g. final
|
|
177
|
+
* `blocks` for a feedback widget) are merged into the `stop` call. The
|
|
178
|
+
* existing `markdown_text` final-text fallback always wins on text fields.
|
|
179
|
+
*/
|
|
180
|
+
chatStreamFinalArgs?: {
|
|
181
|
+
blocks?: unknown[];
|
|
182
|
+
} & Record<string, unknown>;
|
|
183
|
+
/**
|
|
184
|
+
* Optional post-processing hook for publishing a rich artifact from the final
|
|
185
|
+
* accumulated response, such as a Slack Canvas for long answers.
|
|
186
|
+
*/
|
|
187
|
+
publishFinalResponseArtifact?: SlackFinalResponseArtifactPublisher;
|
|
188
|
+
/**
|
|
189
|
+
* Controls whether artifact publication is additive or becomes the primary
|
|
190
|
+
* final-answer surface.
|
|
191
|
+
*
|
|
192
|
+
* - `supplemental`: finalize the Slack text normally, then publish artifact.
|
|
193
|
+
* - `replace`: publish artifact first and use a compact Slack final message.
|
|
194
|
+
*
|
|
195
|
+
* @default "supplemental"
|
|
196
|
+
*/
|
|
197
|
+
finalResponseArtifactMode?: SlackFinalResponseArtifactDeliveryMode;
|
|
198
|
+
/**
|
|
199
|
+
* When replacement mode is active, continue streaming text up to this many
|
|
200
|
+
* raw characters, then suppress further text deltas and publish the full
|
|
201
|
+
* answer as an artifact at completion. This preserves normal short-answer
|
|
202
|
+
* streaming without flooding Slack for long answers.
|
|
203
|
+
*
|
|
204
|
+
* @default 4000
|
|
205
|
+
*/
|
|
206
|
+
finalResponseArtifactStreamThreshold?: number;
|
|
207
|
+
/**
|
|
208
|
+
* Notice appended when replacement mode suppresses the remaining text stream.
|
|
209
|
+
*/
|
|
210
|
+
formatFinalResponseArtifactContinuationNotice?: (context: Pick<SlackFinalResponseArtifactContext, "text" | "formattedText">) => string;
|
|
211
|
+
/**
|
|
212
|
+
* Final compact message used when an artifact replaces the full Slack text.
|
|
213
|
+
*/
|
|
214
|
+
formatFinalResponseArtifactMessage?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => string;
|
|
215
|
+
/**
|
|
216
|
+
* Called when `publishFinalResponseArtifact` throws. Errors from this hook
|
|
217
|
+
* are swallowed so artifact publication cannot break a completed turn.
|
|
218
|
+
*/
|
|
219
|
+
onFinalResponseArtifactError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
declare function resolveSlackEventBridgeOptions(partial: Partial<SlackEventBridgeOptions>): SlackEventBridgeOptions;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Event bridge — maps a runtime-neutral `SlackTurnEvent` stream to a Slack
|
|
225
|
+
* conversation via a `SlackResponseSink`.
|
|
226
|
+
*
|
|
227
|
+
* | Mode | Behaviour |
|
|
228
|
+
* |----------------|--------------------------------------------------------|
|
|
229
|
+
* | `progressive` | Posts a placeholder, updates it as text accumulates. |
|
|
230
|
+
* | `accumulate` | Collects the full response then posts it in one shot. |
|
|
231
|
+
* | `chat-stream` | Uses Slack's native `chat.startStream` + append + stop |
|
|
232
|
+
*
|
|
233
|
+
* The three modes share enough state (full-response accumulator, status
|
|
234
|
+
* label, last-update offset) that they live in one function. Per-mode
|
|
235
|
+
* branches are clearly labelled inside the event loop.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Stream runtime-neutral turn events to a Slack conversation via
|
|
240
|
+
* `SlackResponseSink`.
|
|
241
|
+
*
|
|
242
|
+
* @returns The full accumulated response text.
|
|
243
|
+
*/
|
|
244
|
+
declare function bridgeSlackTurnEventsToSlack(events: AsyncGenerator<SlackTurnEvent>, sink: SlackResponseSink, options: SlackEventBridgeOptions): Promise<string>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Interactive-request error type raised when an `approval-request` or
|
|
248
|
+
* `human-input-request` event reaches the Slack transport in a mode that
|
|
249
|
+
* does not support in-channel resolution.
|
|
250
|
+
*
|
|
251
|
+
* Hosts can catch this error to fall back to message-and-error mode, or install
|
|
252
|
+
* `createSlackInteractiveController` to render and resolve requests in Slack.
|
|
253
|
+
*/
|
|
254
|
+
declare class UnsupportedSlackInteractiveRequestError extends Error {
|
|
255
|
+
readonly kind: "approval" | "human-input";
|
|
256
|
+
readonly requestId: string;
|
|
257
|
+
constructor(kind: "approval" | "human-input", requestId: string, message: string);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { type SlackEventBridgeOptions, type SlackFinalResponseArtifactContext, type SlackFinalResponseArtifactDeliveryMode, type SlackFinalResponseArtifactPublisher, type SlackFinalResponseArtifactResult, type SlackTurnApprovalRequestEvent, type SlackTurnApprovalResolvedEvent, type SlackTurnCompleteEvent, type SlackTurnErrorEvent, type SlackTurnEvent, type SlackTurnEventBase, type SlackTurnHumanInputRequestEvent, type SlackTurnHumanInputResolvedEvent, type SlackTurnReasoningEndEvent, type SlackTurnReasoningStartEvent, type SlackTurnSource, type SlackTurnSourceChatOptions, type SlackTurnStatus, type SlackTurnStatusEvent, type SlackTurnSubagentCompleteEvent, type SlackTurnSubagentErrorEvent, type SlackTurnSubagentEventBase, type SlackTurnSubagentEventEvent, type SlackTurnSubagentStartEvent, type SlackTurnTextDeltaEvent, type SlackTurnTextEndEvent, type SlackTurnTextStartEvent, type SlackTurnToolErrorEvent, type SlackTurnToolResultEvent, type SlackTurnToolStartEvent, UnsupportedSlackInteractiveRequestError, bridgeSlackTurnEventsToSlack, resolveSlackEventBridgeOptions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UnsupportedSlackInteractiveRequestError,
|
|
3
|
+
bridgeSlackTurnEventsToSlack,
|
|
4
|
+
resolveSlackEventBridgeOptions
|
|
5
|
+
} from "../chunk-IAQXQESO.js";
|
|
6
|
+
export {
|
|
7
|
+
UnsupportedSlackInteractiveRequestError,
|
|
8
|
+
bridgeSlackTurnEventsToSlack,
|
|
9
|
+
resolveSlackEventBridgeOptions
|
|
10
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { g as SlackInteractiveRequestContext } from './interactive-CbKYkkc_.js';
|
|
2
|
+
|
|
3
|
+
type SlackInteractiveRequestStatus = "pending" | "resolved";
|
|
4
|
+
type SlackInteractiveApprovalAction = "allow" | "deny" | "remember";
|
|
5
|
+
type SlackInteractiveHumanInputResponse = {
|
|
6
|
+
kind: "text";
|
|
7
|
+
text: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "confirm";
|
|
10
|
+
confirmed: boolean;
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "choice";
|
|
14
|
+
selected: string[];
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
interface SlackInteractiveApprovalRequest {
|
|
18
|
+
id: string;
|
|
19
|
+
tool: string;
|
|
20
|
+
args: unknown;
|
|
21
|
+
description: string;
|
|
22
|
+
risk: string;
|
|
23
|
+
rememberScopes?: string[];
|
|
24
|
+
defaultRememberScope?: string;
|
|
25
|
+
}
|
|
26
|
+
interface SlackInteractiveHumanInputOption {
|
|
27
|
+
label: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
interface SlackInteractiveHumanInputRequest {
|
|
32
|
+
id: string;
|
|
33
|
+
kind: "text" | "confirm" | "choice";
|
|
34
|
+
title: string;
|
|
35
|
+
question: string;
|
|
36
|
+
options?: SlackInteractiveHumanInputOption[];
|
|
37
|
+
allowMultiple?: boolean;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
confirmLabel?: string;
|
|
40
|
+
denyLabel?: string;
|
|
41
|
+
}
|
|
42
|
+
type SlackInteractiveStoredRequest = SlackInteractiveApprovalRequest | SlackInteractiveHumanInputRequest;
|
|
43
|
+
type SlackInteractiveResolution = {
|
|
44
|
+
kind: "approval";
|
|
45
|
+
action: SlackInteractiveApprovalAction;
|
|
46
|
+
feedback?: string;
|
|
47
|
+
rememberScope?: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "human-input";
|
|
50
|
+
response: SlackInteractiveHumanInputResponse;
|
|
51
|
+
};
|
|
52
|
+
interface SlackInteractiveMessageTarget {
|
|
53
|
+
channel: string;
|
|
54
|
+
ts: string;
|
|
55
|
+
threadTs?: string;
|
|
56
|
+
userId: string;
|
|
57
|
+
teamId?: string;
|
|
58
|
+
}
|
|
59
|
+
interface SlackInteractiveRequestRecord {
|
|
60
|
+
id: string;
|
|
61
|
+
kind: SlackInteractiveResolution["kind"];
|
|
62
|
+
request: SlackInteractiveStoredRequest;
|
|
63
|
+
status: SlackInteractiveRequestStatus;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
target?: SlackInteractiveMessageTarget;
|
|
67
|
+
resolution?: SlackInteractiveResolution;
|
|
68
|
+
}
|
|
69
|
+
interface SlackInteractiveRequestStore {
|
|
70
|
+
get(requestId: string): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
71
|
+
upsert(record: SlackInteractiveRequestRecord): Promise<SlackInteractiveRequestRecord>;
|
|
72
|
+
attachTarget(requestId: string, target: SlackInteractiveMessageTarget): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
73
|
+
resolve(requestId: string, resolution: SlackInteractiveResolution): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
74
|
+
delete(requestId: string): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
interface SlackInteractiveActionIds {
|
|
77
|
+
approvalAllow: string;
|
|
78
|
+
approvalDeny: string;
|
|
79
|
+
approvalRemember: string;
|
|
80
|
+
humanConfirm: string;
|
|
81
|
+
humanDeny: string;
|
|
82
|
+
humanOpen: string;
|
|
83
|
+
humanSubmit: string;
|
|
84
|
+
}
|
|
85
|
+
interface SlackInteractiveActor {
|
|
86
|
+
userId: string;
|
|
87
|
+
teamId?: string;
|
|
88
|
+
}
|
|
89
|
+
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
90
|
+
|
|
91
|
+
export type { SlackInteractiveActionIds as S, SlackInteractiveActor as a, SlackInteractiveApprovalAction as b, SlackInteractiveApprovalRequest as c, SlackInteractiveHumanInputOption as d, SlackInteractiveHumanInputRequest as e, SlackInteractiveHumanInputResponse as f, SlackInteractiveMessageTarget as g, SlackInteractiveRequestHandler as h, SlackInteractiveRequestRecord as i, SlackInteractiveRequestStatus as j, SlackInteractiveRequestStore as k, SlackInteractiveResolution as l, SlackInteractiveStoredRequest as m };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/channel-slack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Agent-runtime-agnostic Slack channel primitives for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -71,6 +71,11 @@
|
|
|
71
71
|
"import": "./dist/responses/index.js",
|
|
72
72
|
"default": "./dist/responses/index.js"
|
|
73
73
|
},
|
|
74
|
+
"./runtime": {
|
|
75
|
+
"types": "./dist/runtime/index.d.ts",
|
|
76
|
+
"import": "./dist/runtime/index.js",
|
|
77
|
+
"default": "./dist/runtime/index.js"
|
|
78
|
+
},
|
|
74
79
|
"./setup": {
|
|
75
80
|
"types": "./dist/setup/index.d.ts",
|
|
76
81
|
"import": "./dist/setup/index.js",
|
|
@@ -163,9 +168,9 @@
|
|
|
163
168
|
"node": ">=20"
|
|
164
169
|
},
|
|
165
170
|
"scripts": {
|
|
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",
|
|
171
|
+
"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/runtime/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",
|
|
167
172
|
"clean": "rm -rf dist",
|
|
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",
|
|
173
|
+
"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/runtime/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",
|
|
169
174
|
"lint": "eslint \"src/**/*.{ts,tsx}\" \"tests/**/*.{ts,tsx}\" --max-warnings=0",
|
|
170
175
|
"test": "vitest run",
|
|
171
176
|
"test:watch": "vitest",
|