@mono-agent/slack-adapter 0.3.0 β 0.4.1
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 +12 -1
- package/dist/adapter.d.ts +276 -4
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +706 -27
- package/dist/adapter.js.map +1 -1
- package/dist/config.d.ts +58 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +213 -78
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/message-stream.d.ts +78 -29
- package/dist/message-stream.d.ts.map +1 -1
- package/dist/message-stream.js +184 -136
- package/dist/message-stream.js.map +1 -1
- package/dist/slack-client.d.ts +22 -2
- package/dist/slack-client.d.ts.map +1 -1
- package/dist/slack-client.js +165 -4
- package/dist/slack-client.js.map +1 -1
- package/dist/socket-mode-runner.d.ts +110 -1
- package/dist/socket-mode-runner.d.ts.map +1 -1
- package/dist/socket-mode-runner.js +287 -22
- package/dist/socket-mode-runner.js.map +1 -1
- package/dist/start.d.ts +27 -3
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +49 -0
- package/dist/start.js.map +1 -1
- package/dist/types.d.ts +157 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -20,6 +20,17 @@ Adapter settings can be loaded from nested JSON under `slack` or explicit enviro
|
|
|
20
20
|
|
|
21
21
|
The adapter is opt-in: `slack.enabled` / `MONO_AGENT_SLACK_ENABLED` defaults to `false`. While disabled the loader skips token validation and the channel reports `disabled` rather than `waiting_for_config`. Set `enabled: true` to turn it on; missing tokens or allowlist then surface as a real `waiting_for_config` reason.
|
|
22
22
|
|
|
23
|
+
## Activity indicator (assistant status / π)
|
|
24
|
+
|
|
25
|
+
While the agent works, the message stream surfaces progress in the thread. It
|
|
26
|
+
prefers Slack's official assistant-thread status β `assistant.threads.setStatus`
|
|
27
|
+
("App is _thinkingβ¦_"), which Slack auto-clears when the next message posts β and
|
|
28
|
+
falls back to a π "seen" reaction on the triggering message. The status path only
|
|
29
|
+
applies inside a Slack **AI-assistant thread** and requires the app to have the
|
|
30
|
+
**Agents & AI Apps** feature enabled plus the **`assistant:write`** scope; in
|
|
31
|
+
regular channels/DMs (or without the scope) the call errors and the adapter uses
|
|
32
|
+
the reaction instead β no configuration needed for the fallback.
|
|
33
|
+
|
|
23
34
|
## Public API
|
|
24
35
|
|
|
25
36
|
- `slackFieldGroup`
|
|
@@ -30,7 +41,7 @@ The adapter is opt-in: `slack.enabled` / `MONO_AGENT_SLACK_ENABLED` defaults to
|
|
|
30
41
|
|
|
31
42
|
## Dependency Boundary
|
|
32
43
|
|
|
33
|
-
This package may depend on
|
|
44
|
+
This package may depend on `@mono-agent/agent-contracts` plus Slack transport dependencies. It must not depend on the agent harness, runtime adapter, operator surfaces, other communication adapters, or host/demo code.
|
|
34
45
|
|
|
35
46
|
## What This Package Does Not Own
|
|
36
47
|
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AgentRequestBase, type AgentResponder as SharedAgentResponder, type AgentResponse } from "@mono-agent/agent-contracts";
|
|
1
|
+
import { type AgentAttachment, type AgentRequestBase, type AgentResponder as SharedAgentResponder, type AgentResponse } from "@mono-agent/agent-contracts";
|
|
2
2
|
import { type AgentMessageStream, type SlackMessageStreamLogger } from "./message-stream.js";
|
|
3
|
-
import type { SlackChannelId, SlackEventCallback, SlackMessageTs, SlackUserId, SlackWebApi } from "./types.js";
|
|
3
|
+
import type { SlackBlockActionsPayload, SlackChannelId, SlackEventCallback, SlackInteractivityPayload, SlackMessageTs, SlackShortcutPayload, SlackUserId, SlackWebApi } from "./types.js";
|
|
4
4
|
export type SlackTriggerKind = "direct" | "app_mention";
|
|
5
5
|
export interface AgentRequest extends AgentRequestBase {
|
|
6
6
|
conversationId: string;
|
|
@@ -13,11 +13,25 @@ export interface AgentRequest extends AgentRequestBase {
|
|
|
13
13
|
text: string;
|
|
14
14
|
trigger: SlackTriggerKind;
|
|
15
15
|
abortSignal: AbortSignal;
|
|
16
|
+
attachments?: readonly AgentAttachment[];
|
|
16
17
|
metadata: {
|
|
17
18
|
slack: SlackRequestMetadata;
|
|
18
19
|
[key: string]: unknown;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
22
|
+
/** Tunes how inbound Slack file attachments are downloaded. */
|
|
23
|
+
export interface SlackAttachmentOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Maximum decoded bytes to accept per file. Files whose advertised size
|
|
26
|
+
* exceeds this β or whose download exceeds it β are skipped. Default 10 MiB.
|
|
27
|
+
*/
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Allowed file mimetypes. A file whose mimetype is not listed is skipped.
|
|
31
|
+
* Defaults to a conservative allowlist of common image and document types.
|
|
32
|
+
*/
|
|
33
|
+
allowedMimeTypes?: readonly string[];
|
|
34
|
+
}
|
|
21
35
|
export interface SlackRequestMetadata {
|
|
22
36
|
teamId?: string;
|
|
23
37
|
apiAppId?: string;
|
|
@@ -39,6 +53,25 @@ export interface SlackRequestMetadata {
|
|
|
39
53
|
}
|
|
40
54
|
export type { AgentResponse };
|
|
41
55
|
export type AgentResponder = SharedAgentResponder<AgentRequest, AgentMessageStream, AgentResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Outcome of a proactive {@link SlackAdapter.notify} delivery. `delivered` is
|
|
58
|
+
* true only when the answer reached the channel; otherwise `reason` carries a
|
|
59
|
+
* short, human-readable cause for the silent drop (e.g. concurrency cap, the
|
|
60
|
+
* agent produced no answer, a cancelled or failed run).
|
|
61
|
+
*/
|
|
62
|
+
export interface SlackNotifyResult {
|
|
63
|
+
readonly delivered: boolean;
|
|
64
|
+
readonly reason?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Options for {@link SlackAdapter.notify}. With `verbatim`, `text` is posted to
|
|
68
|
+
* the destination UNCHANGED with no model call (native cron/webhook notification
|
|
69
|
+
* β the producing run already wrote the message) and recorded to history so a
|
|
70
|
+
* reply resumes with it in context. Without it, `text` is run as a turn.
|
|
71
|
+
*/
|
|
72
|
+
export interface SlackNotifyOptions {
|
|
73
|
+
readonly verbatim?: boolean;
|
|
74
|
+
}
|
|
42
75
|
export interface SlackAdapterMessages {
|
|
43
76
|
welcomeText?: string;
|
|
44
77
|
helpText?: string;
|
|
@@ -52,11 +85,85 @@ export interface SlackAdapterStreamOptions {
|
|
|
52
85
|
initialStatusText?: string;
|
|
53
86
|
editDebounceMs?: number;
|
|
54
87
|
maxMessageChars?: number;
|
|
88
|
+
maxSendRetries?: number;
|
|
89
|
+
retryCapMs?: number;
|
|
90
|
+
retryBaseDelayMs?: number;
|
|
91
|
+
showHints?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Deliver only the final answer with a π "seen" reaction while working,
|
|
94
|
+
* instead of streaming interim edits. Defaults to true for the Slack adapter.
|
|
95
|
+
*/
|
|
96
|
+
finalOnly?: boolean;
|
|
55
97
|
}
|
|
56
98
|
export interface SlackAdapterLogger extends SlackMessageStreamLogger {
|
|
57
99
|
debug?(message: string, metadata?: Record<string, unknown>): void;
|
|
58
100
|
info?(message: string, metadata?: Record<string, unknown>): void;
|
|
59
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Binds a Slack shortcut `callback_id` to a prompt. When a user invokes that
|
|
104
|
+
* shortcut, the adapter runs the prompt as a proactive turn β the same machinery
|
|
105
|
+
* as a cron/webhook nudge β making the shortcut a persistent one-click trigger
|
|
106
|
+
* for an agent routine. A GLOBAL shortcut carries no channel, so `channelId`
|
|
107
|
+
* must say where the reply goes; a MESSAGE shortcut falls back to its source
|
|
108
|
+
* channel when `channelId` is omitted.
|
|
109
|
+
*/
|
|
110
|
+
export interface SlackShortcutBinding {
|
|
111
|
+
readonly callbackId: string;
|
|
112
|
+
readonly prompt: string;
|
|
113
|
+
/**
|
|
114
|
+
* Destination channel for the run's reply. Required for global shortcuts.
|
|
115
|
+
* For a MESSAGE shortcut this falls back to the invoking channel β so under
|
|
116
|
+
* `allowAllChannels` the invoker chooses where operator-authored output lands;
|
|
117
|
+
* pin `channelId` to bound the destination.
|
|
118
|
+
*/
|
|
119
|
+
readonly channelId?: SlackChannelId;
|
|
120
|
+
/**
|
|
121
|
+
* Optional message posted immediately when the shortcut is invoked, before the
|
|
122
|
+
* run starts β instant feedback for an action whose result lands seconds later
|
|
123
|
+
* (e.g. "π Syncingβ¦"). Best-effort: a failed ack post does not block the run.
|
|
124
|
+
*/
|
|
125
|
+
readonly ackText?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Outcome of routing an interaction (a shortcut or a Home-tab button). `id` is
|
|
129
|
+
* the shortcut's `callback_id` or the button's `action_id`. `triggered` means a
|
|
130
|
+
* bound interaction ran (`delivered` mirrors the proactive turn's outcome); the
|
|
131
|
+
* other kinds explain why nothing ran, for logging.
|
|
132
|
+
*/
|
|
133
|
+
export type SlackInteractionHandlingResult = {
|
|
134
|
+
kind: "triggered";
|
|
135
|
+
id: string;
|
|
136
|
+
channelId: SlackChannelId;
|
|
137
|
+
delivered: boolean;
|
|
138
|
+
reason?: string;
|
|
139
|
+
} | {
|
|
140
|
+
kind: "ignored";
|
|
141
|
+
reason: "no_action" | "unbound" | "missing_channel";
|
|
142
|
+
id?: string;
|
|
143
|
+
} | {
|
|
144
|
+
kind: "unauthorized";
|
|
145
|
+
id: string;
|
|
146
|
+
channelId: SlackChannelId;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* A button rendered on the App Home tab. Clicking it runs `prompt` as a proactive
|
|
150
|
+
* turn (same machinery as a shortcut), replying in `channelId` (the Home tab
|
|
151
|
+
* carries no channel of its own, so this β or the first allowlisted channel β is
|
|
152
|
+
* where the result lands). `label` is the button text; `ackText` posts instantly.
|
|
153
|
+
*/
|
|
154
|
+
export interface SlackHomeButton {
|
|
155
|
+
readonly actionId: string;
|
|
156
|
+
readonly label: string;
|
|
157
|
+
readonly prompt: string;
|
|
158
|
+
readonly channelId?: SlackChannelId;
|
|
159
|
+
readonly ackText?: string;
|
|
160
|
+
}
|
|
161
|
+
/** App Home tab options: whether to publish it, an optional header, and its buttons. */
|
|
162
|
+
export interface SlackHomeTabOptions {
|
|
163
|
+
readonly enabled: boolean;
|
|
164
|
+
readonly headerText?: string;
|
|
165
|
+
readonly buttons: readonly SlackHomeButton[];
|
|
166
|
+
}
|
|
60
167
|
export interface SlackAdapterOptions {
|
|
61
168
|
api: SlackWebApi;
|
|
62
169
|
responder: AgentResponder;
|
|
@@ -67,9 +174,37 @@ export interface SlackAdapterOptions {
|
|
|
67
174
|
stripMentionText?: boolean;
|
|
68
175
|
stream?: SlackAdapterStreamOptions;
|
|
69
176
|
messages?: SlackAdapterMessages;
|
|
177
|
+
attachments?: SlackAttachmentOptions;
|
|
178
|
+
/**
|
|
179
|
+
* Shortcut bindings (callback_id β prompt). Invoking a bound shortcut in/for an
|
|
180
|
+
* authorized channel runs its prompt as a proactive turn. Omitted/empty means
|
|
181
|
+
* no shortcuts are wired (interactions are ignored).
|
|
182
|
+
*/
|
|
183
|
+
shortcuts?: readonly SlackShortcutBinding[];
|
|
184
|
+
/**
|
|
185
|
+
* App Home tab configuration. When `enabled`, the adapter publishes a persistent
|
|
186
|
+
* panel of action buttons whenever a user opens the Home tab, and a button click
|
|
187
|
+
* runs its bound prompt as a proactive turn. Omitted/disabled means no Home tab.
|
|
188
|
+
*/
|
|
189
|
+
homeTab?: SlackHomeTabOptions;
|
|
70
190
|
logger?: SlackAdapterLogger;
|
|
191
|
+
/**
|
|
192
|
+
* Resolve an in-thread reply back to the conversation that produced the message
|
|
193
|
+
* it threads off. When set and an inbound threaded reply's `(channel, threadTs)`
|
|
194
|
+
* matches a recorded post, the run continues that producing conversation instead
|
|
195
|
+
* of a fresh `slack:<channel>:<threadTs>` (which would have no history). Injected
|
|
196
|
+
* by the host so this package stays free of the artifact store.
|
|
197
|
+
*/
|
|
198
|
+
resolvePostIndex?: (channelId: string, ts: string) => Promise<string | undefined>;
|
|
199
|
+
/**
|
|
200
|
+
* Record that this adapter posted a message at `(channel, ts)` for conversation
|
|
201
|
+
* `conversationId`, so a later in-thread reply can be resolved back to it. Used
|
|
202
|
+
* for top-level proactive posts (a fresh thread root with no prior history).
|
|
203
|
+
* Fire-and-forget; best-effort.
|
|
204
|
+
*/
|
|
205
|
+
recordPostedMessage?: (channelId: string, ts: string, conversationId: string) => void;
|
|
71
206
|
}
|
|
72
|
-
export type SlackEventIgnoredReason = "unsupported_event" | "unsupported_message" | "empty_text" | "from_bot" | "from_self";
|
|
207
|
+
export type SlackEventIgnoredReason = "unsupported_event" | "unsupported_message" | "empty_text" | "no_usable_attachments" | "from_bot" | "from_self";
|
|
73
208
|
export type SlackEventHandlingResult = {
|
|
74
209
|
kind: "handled";
|
|
75
210
|
eventId: string;
|
|
@@ -100,7 +235,39 @@ export type SlackEventHandlingResult = {
|
|
|
100
235
|
eventId: string;
|
|
101
236
|
channelId?: SlackChannelId;
|
|
102
237
|
error: unknown;
|
|
238
|
+
} | {
|
|
239
|
+
kind: "home_published";
|
|
240
|
+
eventId: string;
|
|
241
|
+
userId: SlackUserId;
|
|
103
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* Thrown synchronously by {@link SerialQueue.run} when the queue is already at
|
|
245
|
+
* its depth cap. The adapter catches this sentinel to answer with the busy
|
|
246
|
+
* terminal instead of admitting an unbounded backlog.
|
|
247
|
+
*/
|
|
248
|
+
export declare class SerialQueueFullError extends Error {
|
|
249
|
+
readonly code: "serial_queue_full";
|
|
250
|
+
constructor(maxDepth: number);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Minimal per-conversation serial queue: each submitted task runs only after the
|
|
254
|
+
* previous one settles, preserving arrival order. A task's failure does not
|
|
255
|
+
* poison the queue (the chain swallows it; the caller still sees the rejection).
|
|
256
|
+
*
|
|
257
|
+
* The queue is bounded by {@link maxDepth}: once `depth` reaches the cap, `run`
|
|
258
|
+
* rejects synchronously with a {@link SerialQueueFullError} BEFORE incrementing
|
|
259
|
+
* or chaining, so an over-cap task never enters the chain (mirroring the harness
|
|
260
|
+
* LiveSessionManager's maxPendingPerConversation rejection).
|
|
261
|
+
*/
|
|
262
|
+
export declare class SerialQueue {
|
|
263
|
+
private tail;
|
|
264
|
+
private depth;
|
|
265
|
+
private readonly maxDepth;
|
|
266
|
+
constructor(maxDepth?: number);
|
|
267
|
+
run<T>(task: () => Promise<T>): Promise<T>;
|
|
268
|
+
/** True when no task is queued or running. */
|
|
269
|
+
get idle(): boolean;
|
|
270
|
+
}
|
|
104
271
|
export declare class SlackAdapter {
|
|
105
272
|
private readonly api;
|
|
106
273
|
private readonly responder;
|
|
@@ -112,11 +279,116 @@ export declare class SlackAdapter {
|
|
|
112
279
|
private readonly stripMentionText;
|
|
113
280
|
private readonly streamOptions;
|
|
114
281
|
private readonly messages;
|
|
282
|
+
private readonly attachmentMaxBytes;
|
|
283
|
+
private readonly allowedMimeTypes;
|
|
284
|
+
/** callback_id β shortcut binding for registered Slack shortcuts. */
|
|
285
|
+
private readonly shortcuts;
|
|
286
|
+
/** action_id β button binding for App Home tab buttons. */
|
|
287
|
+
private readonly homeButtons;
|
|
288
|
+
/** Ordered Home tab buttons (for rendering the view in config order). */
|
|
289
|
+
private readonly homeButtonOrder;
|
|
290
|
+
private readonly homeTabEnabled;
|
|
291
|
+
private readonly homeTabHeaderText;
|
|
292
|
+
/** First allowlisted channel (original case), used as a global interaction's default reply destination. */
|
|
293
|
+
private readonly defaultShortcutChannelId;
|
|
115
294
|
private readonly logger;
|
|
116
|
-
private readonly
|
|
295
|
+
private readonly resolvePostIndex;
|
|
296
|
+
private readonly recordPostedMessage;
|
|
297
|
+
/**
|
|
298
|
+
* In-flight abort controllers per thread. The harness serializes runs for a
|
|
299
|
+
* conversation, so several may be queued/active concurrently; /cancel aborts
|
|
300
|
+
* every controller for the thread (and clears the harness queue via
|
|
301
|
+
* responder.cancel).
|
|
302
|
+
*/
|
|
303
|
+
private readonly activeControllers;
|
|
304
|
+
/**
|
|
305
|
+
* Per-conversation admission queue. Socket Mode dispatches envelopes
|
|
306
|
+
* concurrently, and pre-submit work (status + file download) is variable
|
|
307
|
+
* latency, so without this a later same-thread message could reach
|
|
308
|
+
* responder.respond() (and the harness FIFO) before an earlier one. We
|
|
309
|
+
* serialize respondToEvent per conversation to preserve message order.
|
|
310
|
+
* /cancel stays out-of-band (handled before this queue).
|
|
311
|
+
*/
|
|
312
|
+
private readonly admissionQueues;
|
|
117
313
|
constructor(options: SlackAdapterOptions);
|
|
118
314
|
handleEventCallback(callback: SlackEventCallback): Promise<SlackEventHandlingResult>;
|
|
315
|
+
/**
|
|
316
|
+
* Deliver a proactive notification to a Slack destination by running it as a
|
|
317
|
+
* turn on that destination's OWN harness (shared session/history + the same
|
|
318
|
+
* per-conversation admission queue as inbound messages) and posting the answer
|
|
319
|
+
* through the normal stream. `threadTs` targets an existing thread (clean
|
|
320
|
+
* continuity β the user's in-thread replies share the session); omitting it
|
|
321
|
+
* posts top-level (fire-and-forget: a fresh top-level post has no pre-existing
|
|
322
|
+
* thread to share continuity with). Used by cron/webhook nudges. Best-effort:
|
|
323
|
+
* a failed or empty turn posts nothing.
|
|
324
|
+
*/
|
|
325
|
+
notify(channelId: SlackChannelId, threadTs: SlackMessageTs | undefined, text: string, options?: SlackNotifyOptions): Promise<SlackNotifyResult>;
|
|
326
|
+
/**
|
|
327
|
+
* Route any interactivity payload to the right handler: a shortcut/message
|
|
328
|
+
* action by `callback_id`, or a Block Kit button click by `action_id`.
|
|
329
|
+
*/
|
|
330
|
+
handleInteraction(payload: SlackInteractivityPayload): Promise<SlackInteractionHandlingResult>;
|
|
331
|
+
/**
|
|
332
|
+
* Route a Slack shortcut payload. When its `callback_id` is bound to a prompt
|
|
333
|
+
* and the resolved destination channel is authorized, run that prompt as a
|
|
334
|
+
* proactive turn. The destination is the binding's `channelId`, else the
|
|
335
|
+
* payload's own channel (message shortcuts), else the first allowlisted channel.
|
|
336
|
+
*/
|
|
337
|
+
handleShortcut(payload: SlackShortcutPayload): Promise<SlackInteractionHandlingResult>;
|
|
338
|
+
/**
|
|
339
|
+
* Route a Block Kit `block_actions` payload (a clicked button β typically on the
|
|
340
|
+
* App Home tab). Acts on the first action whose `action_id` is a bound Home
|
|
341
|
+
* button. A Home-tab click carries no channel, so the reply goes to the button's
|
|
342
|
+
* `channelId` (or the first allowlisted channel).
|
|
343
|
+
*/
|
|
344
|
+
handleBlockActions(payload: SlackBlockActionsPayload): Promise<SlackInteractionHandlingResult>;
|
|
345
|
+
/**
|
|
346
|
+
* Shared interaction run path: resolve the destination channel, enforce the
|
|
347
|
+
* allowlist, post the optional instant ack, then run the bound prompt as a
|
|
348
|
+
* proactive turn. The returned result is for logging.
|
|
349
|
+
*/
|
|
350
|
+
private runBoundInteraction;
|
|
351
|
+
/**
|
|
352
|
+
* Publish the App Home tab for a user when they open it. Best-effort: a publish
|
|
353
|
+
* failure is logged, not thrown, so opening Home never surfaces an error.
|
|
354
|
+
*/
|
|
355
|
+
private handleAppHomeOpened;
|
|
356
|
+
/** Build the App Home tab Block Kit: an optional header plus one button per configured Home button. */
|
|
357
|
+
private buildHomeTabBlocks;
|
|
358
|
+
/**
|
|
359
|
+
* Build the stream options shared by both proactive delivery paths
|
|
360
|
+
* ({@link runProactiveTurn} and {@link runVerbatimDelivery}): a threaded post
|
|
361
|
+
* targets the existing thread; a top-level post records its ts β this
|
|
362
|
+
* conversation so a user's in-thread reply resolves back here.
|
|
363
|
+
*/
|
|
364
|
+
private buildProactiveStreamOptions;
|
|
365
|
+
/**
|
|
366
|
+
* Deliver `text` VERBATIM to a Slack destination: post it unchanged through the
|
|
367
|
+
* normal stream with NO model call (the producing cron/webhook run already wrote
|
|
368
|
+
* the message), then record it to the destination's durable history via the
|
|
369
|
+
* responder so a later reply resumes with it in context. Best-effort: a
|
|
370
|
+
* history-record failure never fails an already-delivered post.
|
|
371
|
+
*/
|
|
372
|
+
private runVerbatimDelivery;
|
|
373
|
+
private runProactiveTurn;
|
|
374
|
+
/**
|
|
375
|
+
* The conversation the run should continue. A genuine in-thread reply
|
|
376
|
+
* (`threadTs !== messageTs`) whose `(channel, threadTs)` matches a message we
|
|
377
|
+
* posted resolves to that producing conversation; everything else uses the
|
|
378
|
+
* default `slack:<channel>:<threadTs>`. Best-effort: a lookup error falls back.
|
|
379
|
+
*/
|
|
380
|
+
private resolveConversationId;
|
|
119
381
|
private respondToEvent;
|
|
382
|
+
/**
|
|
383
|
+
* Download each inbound Slack file's bytes into an {@link AgentAttachment}.
|
|
384
|
+
* Files with a missing/disallowed mimetype, no private URL, or an advertised
|
|
385
|
+
* size over the cap are skipped before any network call. The byte cap is also
|
|
386
|
+
* enforced during the download. A failed download skips that file and
|
|
387
|
+
* continues; downloads are tied to the request abort signal.
|
|
388
|
+
*/
|
|
389
|
+
private downloadAttachments;
|
|
390
|
+
private registerController;
|
|
391
|
+
private unregisterController;
|
|
120
392
|
private normalizeEventCallback;
|
|
121
393
|
private prepareText;
|
|
122
394
|
private isAuthorized;
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,cAAc,IAAI,oBAAoB,EAC3C,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,c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