@cuylabs/channel-slack-agent-core 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -39
- package/dist/{adapter.d.ts → adapter/index.d.ts} +7 -5
- package/dist/adapter/index.js +9 -0
- package/dist/{adapter-Cmd2C90g.d.ts → adapter-B3CI611y.d.ts} +1 -1
- package/dist/app-surface.d.ts +13 -3
- package/dist/app-surface.js +5 -7
- package/dist/app.d.ts +9 -4
- package/dist/app.js +6 -9
- package/dist/artifacts/index.d.ts +57 -0
- package/dist/artifacts/index.js +6 -0
- package/dist/{assistant.d.ts → assistant/index.d.ts} +6 -4
- package/dist/{assistant.js → assistant/index.js} +3 -5
- package/dist/{chunk-CYEBGC6G.js → chunk-76SRS54H.js} +5 -5
- package/dist/{chunk-M64Z6TYL.js → chunk-7DUO5BMW.js} +16 -6
- package/dist/{chunk-NIPAN4KA.js → chunk-A2PLAVW6.js} +2 -3
- package/dist/chunk-C7CHMYV6.js +226 -0
- package/dist/chunk-C7VSW4ZM.js +548 -0
- package/dist/{chunk-JMLB7A2V.js → chunk-DJPKRKGP.js} +5 -5
- package/dist/chunk-ELR6MQD7.js +12 -0
- package/dist/{chunk-FDRQOG7Q.js → chunk-FQWFB54C.js} +26 -15
- package/dist/{chunk-BFUPAJON.js → chunk-MGBNGG4D.js} +59 -37
- package/dist/chunk-NNCVHQC4.js +94 -0
- package/dist/chunk-P7PFQ3SQ.js +396 -0
- package/dist/{chunk-WO4BJMF3.js → chunk-TCNJY7QA.js} +5 -5
- package/dist/{chunk-DHPD4XH5.js → chunk-TMADMHBN.js} +210 -29
- package/dist/{chunk-IWUYIAY5.js → chunk-VMVQIDNR.js} +5 -7
- package/dist/{chunk-IXY3BXU5.js → chunk-X7ILLZZP.js} +359 -2
- package/dist/context-fragments-CQEDcjYR.d.ts +30 -0
- package/dist/express-assistant.d.ts +6 -3
- package/dist/express-assistant.js +4 -7
- package/dist/express.d.ts +7 -3
- package/dist/express.js +3 -6
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.js +10 -0
- package/dist/history/index.d.ts +61 -0
- package/dist/history/index.js +8 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.js +81 -160
- package/dist/interactive/index.d.ts +71 -0
- package/dist/{interactive.js → interactive/index.js} +9 -4
- package/dist/mcp.js +0 -1
- package/dist/{options-C7OYeNR-.d.ts → options-BcDReOJv.d.ts} +48 -0
- package/dist/{options-Uf-qmQKN.d.ts → options-CdqBABcM.d.ts} +26 -1
- package/dist/{shared.d.ts → shared/index.d.ts} +24 -36
- package/dist/{shared.js → shared/index.js} +2 -6
- package/dist/socket.d.ts +9 -4
- package/dist/socket.js +6 -9
- package/dist/source/index.d.ts +154 -0
- package/dist/source/index.js +38 -0
- package/dist/{types-BqRzb_Cd.d.ts → types-CRWzJB5G.d.ts} +35 -0
- package/dist/types-CiwGU6zC.d.ts +56 -0
- package/dist/views/index.d.ts +8 -0
- package/dist/views/index.js +10 -0
- package/docs/README.md +18 -0
- package/docs/concepts/final-response-artifacts.md +39 -0
- package/docs/concepts/interactive-requests.md +43 -0
- package/docs/concepts/tool-task-rendering.md +46 -0
- package/docs/concepts/view-workflows.md +52 -0
- package/docs/reference/boundary.md +22 -0
- package/docs/reference/exports.md +26 -0
- package/package.json +36 -50
- package/dist/adapter.js +0 -13
- package/dist/bolt.d.ts +0 -8
- package/dist/bolt.js +0 -10
- package/dist/chunk-2SUAW6MV.js +0 -12
- package/dist/chunk-645NNJIM.js +0 -12
- package/dist/chunk-ANIZ5NT4.js +0 -12
- package/dist/chunk-GNXWTKQ6.js +0 -48
- package/dist/chunk-HFT2FXJP.js +0 -12
- package/dist/chunk-I2KLQ2HA.js +0 -22
- package/dist/chunk-K2E6A377.js +0 -12
- package/dist/chunk-NDVXBI7Z.js +0 -12
- package/dist/chunk-PX4RGO3N.js +0 -12
- package/dist/chunk-VHGV66M7.js +0 -12
- package/dist/diagnostics.d.ts +0 -1
- package/dist/diagnostics.js +0 -10
- package/dist/feedback.d.ts +0 -1
- package/dist/feedback.js +0 -10
- package/dist/history.d.ts +0 -1
- package/dist/history.js +0 -10
- package/dist/interactive.d.ts +0 -30
- package/dist/policy.d.ts +0 -1
- package/dist/policy.js +0 -10
- package/dist/setup.d.ts +0 -1
- package/dist/setup.js +0 -10
- package/dist/targets.d.ts +0 -1
- package/dist/targets.js +0 -10
- package/dist/users.d.ts +0 -1
- package/dist/users.js +0 -10
|
@@ -70,6 +70,358 @@ function cloneResolution(resolution) {
|
|
|
70
70
|
return structuredClone(resolution);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// src/interactive/postgres-store.ts
|
|
74
|
+
var DEFAULT_TABLE = "channel_slack_interactive_requests";
|
|
75
|
+
var DEFAULT_RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
76
|
+
var DEFAULT_PRUNE_BATCH_SIZE = 1e3;
|
|
77
|
+
var DEFAULT_PRUNE_INTERVAL_MS = 6 * 60 * 60 * 1e3;
|
|
78
|
+
function createPostgresSlackInteractiveRequestStore({
|
|
79
|
+
client,
|
|
80
|
+
connectionString,
|
|
81
|
+
ensureSchema = true,
|
|
82
|
+
onPruneError,
|
|
83
|
+
pruneBatchSize = DEFAULT_PRUNE_BATCH_SIZE,
|
|
84
|
+
pruneIntervalMs = DEFAULT_PRUNE_INTERVAL_MS,
|
|
85
|
+
retentionMs = DEFAULT_RETENTION_MS,
|
|
86
|
+
schema,
|
|
87
|
+
tableName = DEFAULT_TABLE
|
|
88
|
+
}) {
|
|
89
|
+
let activeClient = client;
|
|
90
|
+
let ownsClient = false;
|
|
91
|
+
let initialized;
|
|
92
|
+
let pruneTimer;
|
|
93
|
+
async function getClient() {
|
|
94
|
+
if (activeClient) {
|
|
95
|
+
return activeClient;
|
|
96
|
+
}
|
|
97
|
+
if (!connectionString) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
"connectionString is required when a Postgres Slack interactive request client is not provided"
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const Pool = await importPostgresPoolConstructor();
|
|
103
|
+
activeClient = new Pool({ connectionString });
|
|
104
|
+
ownsClient = true;
|
|
105
|
+
return activeClient;
|
|
106
|
+
}
|
|
107
|
+
async function ensureInitialized() {
|
|
108
|
+
const currentClient = await getClient();
|
|
109
|
+
initialized ??= initializePostgresSlackInteractiveRequestStore({
|
|
110
|
+
client: currentClient,
|
|
111
|
+
ensureSchema,
|
|
112
|
+
schema,
|
|
113
|
+
tableName
|
|
114
|
+
});
|
|
115
|
+
await initialized;
|
|
116
|
+
startPruneTimer();
|
|
117
|
+
return currentClient;
|
|
118
|
+
}
|
|
119
|
+
function startPruneTimer() {
|
|
120
|
+
if (pruneTimer || pruneIntervalMs <= 0) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
pruneTimer = setInterval(() => {
|
|
124
|
+
void prune().catch((error) => {
|
|
125
|
+
onPruneError?.(error);
|
|
126
|
+
});
|
|
127
|
+
}, pruneIntervalMs);
|
|
128
|
+
pruneTimer.unref?.();
|
|
129
|
+
}
|
|
130
|
+
async function prune() {
|
|
131
|
+
const currentClient = await ensureInitialized();
|
|
132
|
+
return prunePostgresSlackInteractiveRequestStore({
|
|
133
|
+
client: currentClient,
|
|
134
|
+
pruneBatchSize,
|
|
135
|
+
retentionMs,
|
|
136
|
+
schema,
|
|
137
|
+
tableName
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
async get(requestId) {
|
|
142
|
+
const currentClient = await ensureInitialized();
|
|
143
|
+
const result = await currentClient.query(
|
|
144
|
+
`SELECT * FROM ${qualifiedTableName({
|
|
145
|
+
schema,
|
|
146
|
+
tableName
|
|
147
|
+
})} WHERE id = $1::text LIMIT 1`,
|
|
148
|
+
[requestId]
|
|
149
|
+
);
|
|
150
|
+
return rowToRecord(result.rows[0]);
|
|
151
|
+
},
|
|
152
|
+
async upsert(record) {
|
|
153
|
+
const currentClient = await ensureInitialized();
|
|
154
|
+
const result = await currentClient.query(
|
|
155
|
+
`INSERT INTO ${qualifiedTableName({
|
|
156
|
+
schema,
|
|
157
|
+
tableName
|
|
158
|
+
})} (
|
|
159
|
+
id,
|
|
160
|
+
kind,
|
|
161
|
+
request,
|
|
162
|
+
status,
|
|
163
|
+
created_at,
|
|
164
|
+
updated_at,
|
|
165
|
+
target,
|
|
166
|
+
resolution
|
|
167
|
+
)
|
|
168
|
+
VALUES (
|
|
169
|
+
$1::text,
|
|
170
|
+
$2::text,
|
|
171
|
+
$3::jsonb,
|
|
172
|
+
$4::text,
|
|
173
|
+
$5::timestamptz,
|
|
174
|
+
$6::timestamptz,
|
|
175
|
+
$7::jsonb,
|
|
176
|
+
$8::jsonb
|
|
177
|
+
)
|
|
178
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
179
|
+
kind = CASE
|
|
180
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
181
|
+
THEN ${qualifiedTableName({ schema, tableName })}.kind
|
|
182
|
+
ELSE EXCLUDED.kind
|
|
183
|
+
END,
|
|
184
|
+
request = CASE
|
|
185
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
186
|
+
THEN ${qualifiedTableName({ schema, tableName })}.request
|
|
187
|
+
ELSE EXCLUDED.request
|
|
188
|
+
END,
|
|
189
|
+
status = CASE
|
|
190
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
191
|
+
THEN ${qualifiedTableName({ schema, tableName })}.status
|
|
192
|
+
ELSE EXCLUDED.status
|
|
193
|
+
END,
|
|
194
|
+
target = CASE
|
|
195
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
196
|
+
THEN ${qualifiedTableName({ schema, tableName })}.target
|
|
197
|
+
ELSE COALESCE(EXCLUDED.target, ${qualifiedTableName({
|
|
198
|
+
schema,
|
|
199
|
+
tableName
|
|
200
|
+
})}.target)
|
|
201
|
+
END,
|
|
202
|
+
resolution = CASE
|
|
203
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
204
|
+
THEN ${qualifiedTableName({ schema, tableName })}.resolution
|
|
205
|
+
ELSE COALESCE(EXCLUDED.resolution, ${qualifiedTableName({
|
|
206
|
+
schema,
|
|
207
|
+
tableName
|
|
208
|
+
})}.resolution)
|
|
209
|
+
END,
|
|
210
|
+
updated_at = CASE
|
|
211
|
+
WHEN ${qualifiedTableName({ schema, tableName })}.status = 'resolved'
|
|
212
|
+
THEN ${qualifiedTableName({ schema, tableName })}.updated_at
|
|
213
|
+
ELSE now()
|
|
214
|
+
END
|
|
215
|
+
RETURNING *`,
|
|
216
|
+
[
|
|
217
|
+
record.id,
|
|
218
|
+
record.kind,
|
|
219
|
+
JSON.stringify(record.request),
|
|
220
|
+
record.status,
|
|
221
|
+
record.createdAt,
|
|
222
|
+
record.updatedAt,
|
|
223
|
+
record.target ? JSON.stringify(record.target) : null,
|
|
224
|
+
record.resolution ? JSON.stringify(record.resolution) : null
|
|
225
|
+
]
|
|
226
|
+
);
|
|
227
|
+
return requireReturnedRecord(result.rows[0], record.id);
|
|
228
|
+
},
|
|
229
|
+
async attachTarget(requestId, target) {
|
|
230
|
+
const currentClient = await ensureInitialized();
|
|
231
|
+
const result = await currentClient.query(
|
|
232
|
+
`UPDATE ${qualifiedTableName({ schema, tableName })}
|
|
233
|
+
SET target = $2::jsonb, updated_at = now()
|
|
234
|
+
WHERE id = $1::text
|
|
235
|
+
RETURNING *`,
|
|
236
|
+
[requestId, JSON.stringify(target)]
|
|
237
|
+
);
|
|
238
|
+
return rowToRecord(result.rows[0]);
|
|
239
|
+
},
|
|
240
|
+
async resolve(requestId, resolution) {
|
|
241
|
+
const currentClient = await ensureInitialized();
|
|
242
|
+
const result = await currentClient.query(
|
|
243
|
+
`UPDATE ${qualifiedTableName({ schema, tableName })}
|
|
244
|
+
SET status = 'resolved',
|
|
245
|
+
resolution = $2::jsonb,
|
|
246
|
+
updated_at = now()
|
|
247
|
+
WHERE id = $1::text AND status <> 'resolved'
|
|
248
|
+
RETURNING *`,
|
|
249
|
+
[requestId, JSON.stringify(resolution)]
|
|
250
|
+
);
|
|
251
|
+
const resolved = rowToRecord(result.rows[0]);
|
|
252
|
+
if (resolved) {
|
|
253
|
+
return resolved;
|
|
254
|
+
}
|
|
255
|
+
const existing = await currentClient.query(
|
|
256
|
+
`SELECT * FROM ${qualifiedTableName({
|
|
257
|
+
schema,
|
|
258
|
+
tableName
|
|
259
|
+
})} WHERE id = $1::text LIMIT 1`,
|
|
260
|
+
[requestId]
|
|
261
|
+
);
|
|
262
|
+
return rowToRecord(existing.rows[0]);
|
|
263
|
+
},
|
|
264
|
+
async delete(requestId) {
|
|
265
|
+
const currentClient = await ensureInitialized();
|
|
266
|
+
await currentClient.query(
|
|
267
|
+
`DELETE FROM ${qualifiedTableName({
|
|
268
|
+
schema,
|
|
269
|
+
tableName
|
|
270
|
+
})} WHERE id = $1::text`,
|
|
271
|
+
[requestId]
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
prune,
|
|
275
|
+
async close() {
|
|
276
|
+
if (pruneTimer) {
|
|
277
|
+
clearInterval(pruneTimer);
|
|
278
|
+
pruneTimer = void 0;
|
|
279
|
+
}
|
|
280
|
+
if (ownsClient) {
|
|
281
|
+
await activeClient?.end?.();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async function initializePostgresSlackInteractiveRequestStore({
|
|
287
|
+
client,
|
|
288
|
+
ensureSchema = true,
|
|
289
|
+
schema,
|
|
290
|
+
tableName = DEFAULT_TABLE
|
|
291
|
+
}) {
|
|
292
|
+
if (schema && ensureSchema) {
|
|
293
|
+
await client.query(
|
|
294
|
+
`CREATE SCHEMA IF NOT EXISTS ${quoteIdentifier(schema)}`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
const table = qualifiedTableName({ schema, tableName });
|
|
298
|
+
await client.query(`
|
|
299
|
+
CREATE TABLE IF NOT EXISTS ${table} (
|
|
300
|
+
id text PRIMARY KEY,
|
|
301
|
+
kind text NOT NULL CHECK (kind IN ('approval', 'human-input')),
|
|
302
|
+
request jsonb NOT NULL,
|
|
303
|
+
status text NOT NULL CHECK (status IN ('pending', 'resolved')),
|
|
304
|
+
target jsonb,
|
|
305
|
+
resolution jsonb,
|
|
306
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
307
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
308
|
+
)
|
|
309
|
+
`);
|
|
310
|
+
const indexPrefix = interactiveIndexPrefix({ schema, tableName });
|
|
311
|
+
await client.query(
|
|
312
|
+
`CREATE INDEX IF NOT EXISTS ${quoteIdentifier(
|
|
313
|
+
`${indexPrefix}_status_updated_idx`
|
|
314
|
+
)} ON ${table} (status, updated_at DESC)`
|
|
315
|
+
);
|
|
316
|
+
await client.query(
|
|
317
|
+
`CREATE INDEX IF NOT EXISTS ${quoteIdentifier(
|
|
318
|
+
`${indexPrefix}_updated_idx`
|
|
319
|
+
)} ON ${table} (updated_at DESC)`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
async function prunePostgresSlackInteractiveRequestStore({
|
|
323
|
+
client,
|
|
324
|
+
pruneBatchSize = DEFAULT_PRUNE_BATCH_SIZE,
|
|
325
|
+
retentionMs = DEFAULT_RETENTION_MS,
|
|
326
|
+
schema,
|
|
327
|
+
tableName = DEFAULT_TABLE
|
|
328
|
+
}) {
|
|
329
|
+
if (retentionMs <= 0) {
|
|
330
|
+
return { deleted: 0 };
|
|
331
|
+
}
|
|
332
|
+
const batchSize = Math.max(1, Math.floor(pruneBatchSize));
|
|
333
|
+
const result = await client.query(
|
|
334
|
+
`WITH expired AS (
|
|
335
|
+
SELECT id
|
|
336
|
+
FROM ${qualifiedTableName({ schema, tableName })}
|
|
337
|
+
WHERE updated_at < now() - ($1::bigint * interval '1 millisecond')
|
|
338
|
+
ORDER BY updated_at ASC
|
|
339
|
+
LIMIT $2::integer
|
|
340
|
+
)
|
|
341
|
+
DELETE FROM ${qualifiedTableName({ schema, tableName })} target
|
|
342
|
+
USING expired
|
|
343
|
+
WHERE target.id = expired.id`,
|
|
344
|
+
[Math.max(1, Math.floor(retentionMs)), batchSize]
|
|
345
|
+
);
|
|
346
|
+
return { deleted: result.rowCount ?? 0 };
|
|
347
|
+
}
|
|
348
|
+
function rowToRecord(row) {
|
|
349
|
+
if (!row) return void 0;
|
|
350
|
+
return cloneRecord({
|
|
351
|
+
id: row.id,
|
|
352
|
+
kind: row.kind,
|
|
353
|
+
request: readJsonValue(
|
|
354
|
+
row.request
|
|
355
|
+
),
|
|
356
|
+
status: row.status,
|
|
357
|
+
createdAt: toIsoString(row.created_at),
|
|
358
|
+
updatedAt: toIsoString(row.updated_at),
|
|
359
|
+
...row.target ? {
|
|
360
|
+
target: readJsonValue(
|
|
361
|
+
row.target
|
|
362
|
+
)
|
|
363
|
+
} : {},
|
|
364
|
+
...row.resolution ? {
|
|
365
|
+
resolution: readJsonValue(
|
|
366
|
+
row.resolution
|
|
367
|
+
)
|
|
368
|
+
} : {}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function requireReturnedRecord(row, requestId) {
|
|
372
|
+
const record = rowToRecord(row);
|
|
373
|
+
if (!record) {
|
|
374
|
+
throw new Error(
|
|
375
|
+
`Postgres Slack interactive request store did not return request ${requestId}.`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
return record;
|
|
379
|
+
}
|
|
380
|
+
function readJsonValue(value) {
|
|
381
|
+
if (typeof value === "string") {
|
|
382
|
+
return JSON.parse(value);
|
|
383
|
+
}
|
|
384
|
+
return value;
|
|
385
|
+
}
|
|
386
|
+
function toIsoString(value) {
|
|
387
|
+
return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
|
|
388
|
+
}
|
|
389
|
+
function qualifiedTableName({
|
|
390
|
+
schema,
|
|
391
|
+
tableName
|
|
392
|
+
}) {
|
|
393
|
+
return schema ? `${quoteIdentifier(schema)}.${quoteIdentifier(tableName)}` : quoteIdentifier(tableName);
|
|
394
|
+
}
|
|
395
|
+
function quoteIdentifier(value) {
|
|
396
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
397
|
+
}
|
|
398
|
+
function interactiveIndexPrefix({
|
|
399
|
+
schema,
|
|
400
|
+
tableName
|
|
401
|
+
}) {
|
|
402
|
+
const raw = [schema, tableName].filter(Boolean).join("_");
|
|
403
|
+
return raw.replace(/[^A-Za-z0-9_]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 40) || "channel_slack_interactive";
|
|
404
|
+
}
|
|
405
|
+
async function importPostgresPoolConstructor() {
|
|
406
|
+
const dynamicImport = new Function(
|
|
407
|
+
"specifier",
|
|
408
|
+
"return import(specifier)"
|
|
409
|
+
);
|
|
410
|
+
try {
|
|
411
|
+
const pg = await dynamicImport("pg");
|
|
412
|
+
return pg.Pool;
|
|
413
|
+
} catch (error) {
|
|
414
|
+
throw new Error(
|
|
415
|
+
`The "pg" package is required when using connectionString with createPostgresSlackInteractiveRequestStore. Install pg or pass a client. ${formatImportError(
|
|
416
|
+
error
|
|
417
|
+
)}`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function formatImportError(error) {
|
|
422
|
+
return error instanceof Error ? error.message : String(error);
|
|
423
|
+
}
|
|
424
|
+
|
|
73
425
|
// src/interactive/blocks.ts
|
|
74
426
|
var MAX_BLOCK_TEXT = 2800;
|
|
75
427
|
function buildApprovalRequestMessage(request, actionIds) {
|
|
@@ -284,6 +636,7 @@ function escapeMrkdwn(value) {
|
|
|
284
636
|
}
|
|
285
637
|
|
|
286
638
|
// src/interactive/controller.ts
|
|
639
|
+
import { openSlackModal } from "@cuylabs/channel-slack/views";
|
|
287
640
|
var DEFAULT_NAMESPACE = "agent_slack";
|
|
288
641
|
var DEFAULT_REQUEST_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
289
642
|
var installedActionIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -501,8 +854,9 @@ function createSlackInteractiveController(options = {}) {
|
|
|
501
854
|
);
|
|
502
855
|
return;
|
|
503
856
|
}
|
|
504
|
-
await
|
|
505
|
-
|
|
857
|
+
await openSlackModal({
|
|
858
|
+
client: actionArgs.client,
|
|
859
|
+
triggerId: actionArgs.body.trigger_id,
|
|
506
860
|
view: buildHumanInputModal(
|
|
507
861
|
record.request,
|
|
508
862
|
actionIds
|
|
@@ -679,6 +1033,9 @@ export {
|
|
|
679
1033
|
createInMemorySlackInteractiveRequestStore,
|
|
680
1034
|
nowIso,
|
|
681
1035
|
cloneRecord,
|
|
1036
|
+
createPostgresSlackInteractiveRequestStore,
|
|
1037
|
+
initializePostgresSlackInteractiveRequestStore,
|
|
1038
|
+
prunePostgresSlackInteractiveRequestStore,
|
|
682
1039
|
buildApprovalRequestMessage,
|
|
683
1040
|
buildHumanInputRequestMessage,
|
|
684
1041
|
buildResolvedMessage,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AgentContextFragmentInput, AgentContextFragmentBuildContext, AgentContextFragmentKind, AgentContextFragmentRole, AgentContextFragmentPlacement, AgentContextFragmentLifetime, AgentContextFragmentBudgetBehavior, AgentMiddleware } from '@cuylabs/agent-core';
|
|
2
|
+
import { SlackAmbientTurnContext } from '@cuylabs/channel-slack/core';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY = "slackContextFragment";
|
|
5
|
+
interface SlackContextFragmentPayload extends Partial<Pick<AgentContextFragmentInput, "budgetBehavior" | "dedupeKey" | "kind" | "lifetime" | "maxChars" | "metadata" | "placement" | "role" | "source" | "title">> {
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
interface SlackContextFragmentResolverContext {
|
|
9
|
+
slack: Readonly<SlackAmbientTurnContext>;
|
|
10
|
+
step: AgentContextFragmentBuildContext;
|
|
11
|
+
}
|
|
12
|
+
type SlackContextFragmentResolver = (context: SlackContextFragmentResolverContext) => AgentContextFragmentInput | SlackContextFragmentPayload | string | undefined | Promise<AgentContextFragmentInput | SlackContextFragmentPayload | string | undefined>;
|
|
13
|
+
interface SlackContextFragmentMiddlewareOptions {
|
|
14
|
+
name?: string;
|
|
15
|
+
contextKey?: string;
|
|
16
|
+
resolve?: SlackContextFragmentResolver;
|
|
17
|
+
kind?: AgentContextFragmentKind;
|
|
18
|
+
role?: AgentContextFragmentRole;
|
|
19
|
+
placement?: AgentContextFragmentPlacement;
|
|
20
|
+
lifetime?: AgentContextFragmentLifetime;
|
|
21
|
+
title?: string;
|
|
22
|
+
source?: string;
|
|
23
|
+
budgetBehavior?: AgentContextFragmentBudgetBehavior;
|
|
24
|
+
maxChars?: number;
|
|
25
|
+
dedupeKey?: string | ((context: SlackContextFragmentResolverContext) => string | undefined);
|
|
26
|
+
metadata?: Record<string, unknown> | ((context: SlackContextFragmentResolverContext) => Record<string, unknown> | undefined);
|
|
27
|
+
}
|
|
28
|
+
declare function createSlackContextFragmentMiddleware(options?: SlackContextFragmentMiddlewareOptions): AgentMiddleware;
|
|
29
|
+
|
|
30
|
+
export { DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY as D, type SlackContextFragmentMiddlewareOptions as S, type SlackContextFragmentPayload as a, type SlackContextFragmentResolver as b, type SlackContextFragmentResolverContext as c, createSlackContextFragmentMiddleware as d };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Server } from 'node:http';
|
|
2
2
|
import { Application } from 'express';
|
|
3
3
|
import { App, ExpressReceiver } from '@slack/bolt';
|
|
4
|
-
import { CreateSlackBoltAppOptions
|
|
5
|
-
import {
|
|
4
|
+
import { CreateSlackBoltAppOptions } from '@cuylabs/channel-slack/transports/http';
|
|
5
|
+
import { SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/auth';
|
|
6
|
+
import { C as CreateSlackAssistantBridgeOptions, b as SlackAssistantFeedbackConfig, S as SlackAssistantBridge } from './options-CdqBABcM.js';
|
|
6
7
|
import { SlackFeedbackHandler } from '@cuylabs/channel-slack/feedback';
|
|
7
8
|
import '@cuylabs/agent-core';
|
|
8
9
|
import '@slack/web-api';
|
|
9
10
|
import '@cuylabs/channel-slack/core';
|
|
10
11
|
import './interactive-o_NZb-Xg.js';
|
|
11
|
-
import './options-
|
|
12
|
+
import './options-BcDReOJv.js';
|
|
13
|
+
import './artifacts/index.js';
|
|
14
|
+
import '@cuylabs/channel-slack/artifacts';
|
|
12
15
|
import '@cuylabs/channel-slack/assistant';
|
|
13
16
|
|
|
14
17
|
/**
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountSlackAssistantAgent
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-DHPD4XH5.js";
|
|
8
|
-
import "./chunk-ANIZ5NT4.js";
|
|
9
|
-
import "./chunk-I2KLQ2HA.js";
|
|
3
|
+
} from "./chunk-DJPKRKGP.js";
|
|
4
|
+
import "./chunk-MGBNGG4D.js";
|
|
5
|
+
import "./chunk-ELR6MQD7.js";
|
|
6
|
+
import "./chunk-TMADMHBN.js";
|
|
10
7
|
export {
|
|
11
8
|
mountSlackAssistantAgent
|
|
12
9
|
};
|
package/dist/express.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import * as _slack_bolt from '@slack/bolt';
|
|
|
2
2
|
import { Server } from 'node:http';
|
|
3
3
|
import { AgentTurnSource } from '@cuylabs/agent-core';
|
|
4
4
|
import { Application } from 'express';
|
|
5
|
-
import { c as createSlackChannelAdapter } from './adapter-
|
|
6
|
-
import { a as SlackChannelOptions } from './types-
|
|
7
|
-
import { CreateSlackBoltAppOptions
|
|
5
|
+
import { c as createSlackChannelAdapter } from './adapter-B3CI611y.js';
|
|
6
|
+
import { a as SlackChannelOptions } from './types-CRWzJB5G.js';
|
|
7
|
+
import { CreateSlackBoltAppOptions } from '@cuylabs/channel-slack/transports/http';
|
|
8
|
+
import { SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/auth';
|
|
8
9
|
import '@cuylabs/channel-slack/core';
|
|
10
|
+
import './options-BcDReOJv.js';
|
|
11
|
+
import './artifacts/index.js';
|
|
12
|
+
import '@cuylabs/channel-slack/artifacts';
|
|
9
13
|
import './interactive-o_NZb-Xg.js';
|
|
10
14
|
|
|
11
15
|
interface MountSlackAgentOptions extends Omit<SlackChannelOptions, "agent" | "source">, Omit<CreateSlackBoltAppOptions, "app" | "path" | "botToken" | "signingSecret" | "auth"> {
|
package/dist/express.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountSlackAgent
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-DHPD4XH5.js";
|
|
7
|
-
import "./chunk-ANIZ5NT4.js";
|
|
8
|
-
import "./chunk-I2KLQ2HA.js";
|
|
3
|
+
} from "./chunk-TCNJY7QA.js";
|
|
4
|
+
import "./chunk-FQWFB54C.js";
|
|
5
|
+
import "./chunk-TMADMHBN.js";
|
|
9
6
|
export {
|
|
10
7
|
mountSlackAgent
|
|
11
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RegisterSlackFeedbackOptions, SLACK_FEEDBACK_ACTION_ID, SlackFeedbackBlockOptions, SlackFeedbackButtonConfig, SlackFeedbackContext, SlackFeedbackContextBlock, SlackFeedbackHandler, SlackFeedbackVerdict, createSlackFeedbackBlock, registerSlackFeedbackAction } from '@cuylabs/channel-slack/feedback';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Logger } from '@cuylabs/agent-core';
|
|
2
|
+
import { SlackHistoryUnavailable, SlackSupplementalHistoryVisibilityMode } from '@cuylabs/channel-slack/history';
|
|
3
|
+
import { MountSlackAgentAppTurnRequestContext } from '../app-surface.js';
|
|
4
|
+
import { a as SlackContextFragmentPayload } from '../context-fragments-CQEDcjYR.js';
|
|
5
|
+
import '@slack/bolt';
|
|
6
|
+
import '@slack/web-api';
|
|
7
|
+
import '../options-CdqBABcM.js';
|
|
8
|
+
import '@cuylabs/channel-slack/core';
|
|
9
|
+
import '../interactive-o_NZb-Xg.js';
|
|
10
|
+
import '../options-BcDReOJv.js';
|
|
11
|
+
import '../artifacts/index.js';
|
|
12
|
+
import '@cuylabs/channel-slack/artifacts';
|
|
13
|
+
import '@cuylabs/channel-slack/feedback';
|
|
14
|
+
import '@cuylabs/channel-slack/assistant';
|
|
15
|
+
import '../types-CRWzJB5G.js';
|
|
16
|
+
import '../types-Crpil4kb.js';
|
|
17
|
+
import '../types-CiwGU6zC.js';
|
|
18
|
+
import '@cuylabs/channel-slack/views';
|
|
19
|
+
|
|
20
|
+
interface SlackAgentTurnHistoryOptions {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
limit: number;
|
|
23
|
+
maxCharacters: number;
|
|
24
|
+
unavailableNoteFormatter?: (issue: SlackHistoryUnavailable) => string | undefined;
|
|
25
|
+
visibilityAllowedUserIds?: readonly string[];
|
|
26
|
+
visibilityMode?: SlackSupplementalHistoryVisibilityMode;
|
|
27
|
+
}
|
|
28
|
+
interface SlackAgentTurnHistoryProfileResolver {
|
|
29
|
+
resolve(options: {
|
|
30
|
+
botToken?: string;
|
|
31
|
+
teamId?: string;
|
|
32
|
+
userId: string;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
displayName?: string;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
interface LoadSlackAgentTurnHistoryContextOptions {
|
|
38
|
+
history: SlackAgentTurnHistoryOptions;
|
|
39
|
+
logger?: Pick<Logger, "debug" | "info" | "warn">;
|
|
40
|
+
originChannelId?: string;
|
|
41
|
+
profileResolver?: SlackAgentTurnHistoryProfileResolver;
|
|
42
|
+
request: MountSlackAgentAppTurnRequestContext;
|
|
43
|
+
}
|
|
44
|
+
type SlackAgentTurnHistoryContextResult = {
|
|
45
|
+
fragment?: SlackContextFragmentPayload;
|
|
46
|
+
originChannelMessageCount: number;
|
|
47
|
+
originChannelUnavailableReason?: string;
|
|
48
|
+
originChannelVisibilityOmittedMessageCount: number;
|
|
49
|
+
prompt?: string;
|
|
50
|
+
threadMessageCount: number;
|
|
51
|
+
threadUnavailableReason?: string;
|
|
52
|
+
threadVisibilityOmittedMessageCount: number;
|
|
53
|
+
topLevelChannelMessageCount: number;
|
|
54
|
+
topLevelChannelUnavailableReason?: string;
|
|
55
|
+
topLevelChannelVisibilityOmittedMessageCount: number;
|
|
56
|
+
visibilityOmittedMessageCount: number;
|
|
57
|
+
};
|
|
58
|
+
declare function loadSlackAgentTurnHistoryContext({ history, logger, originChannelId: providedOriginChannelId, profileResolver, request, }: LoadSlackAgentTurnHistoryContextOptions): Promise<SlackAgentTurnHistoryContextResult>;
|
|
59
|
+
declare function emptySlackAgentTurnHistoryContextResult(): SlackAgentTurnHistoryContextResult;
|
|
60
|
+
|
|
61
|
+
export { type LoadSlackAgentTurnHistoryContextOptions, type SlackAgentTurnHistoryContextResult, type SlackAgentTurnHistoryOptions, type SlackAgentTurnHistoryProfileResolver, emptySlackAgentTurnHistoryContextResult, loadSlackAgentTurnHistoryContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
export {
|
|
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 { SlackArtifactPublicationTarget, SlackChatStream, SlackResponseSink, SlackStreamChunk, SlackStreamTaskStatus, UnsupportedSlackInteractiveRequestError, bridgeAgentEventsToSlack } from './shared/index.js';
|
|
3
|
+
export { S as SlackEventBridgeOptions, r as resolveSlackEventBridgeOptions } from './options-BcDReOJv.js';
|
|
2
4
|
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-o_NZb-Xg.js';
|
|
3
|
-
export {
|
|
4
|
-
export { S as
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export { SlackSessionMap, createSlackSessionMap } from './adapter.js';
|
|
9
|
-
export { createSlackAssistantBridge } from './assistant.js';
|
|
10
|
-
export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, C as CreateSlackAssistantBridgeOptions, M as MaybePromise, S as SlackAssistantBridge, b as SlackAssistantFeedbackConfig, c as SlackAssistantSessionStrategy, d as SlackAssistantStatusContext, e as SlackAssistantThreadContextStoreLike, f as SlackAssistantThreadStartedContext, g as SlackAssistantTurnPreparation, h as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from './options-Uf-qmQKN.js';
|
|
5
|
+
export { c as createSlackChannelAdapter } from './adapter-B3CI611y.js';
|
|
6
|
+
export { S as SlackChannelAdapter, a as SlackChannelOptions, b as SlackSessionStrategy, c as SlackStreamingMode, d as SlackToolStartEvent } from './types-CRWzJB5G.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 SlackAssistantFeedbackConfig, c as SlackAssistantSessionStrategy, d as SlackAssistantStatusContext, e as SlackAssistantThreadContextStoreLike, f as SlackAssistantThreadStartedContext, g as SlackAssistantTurnPreparation, h as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from './options-CdqBABcM.js';
|
|
11
10
|
export { ParsedAssistantUserMessage, createSlackAssistantThreadContextStore, parseSlackMessageActivityFromMessageEvent } from '@cuylabs/channel-slack/assistant';
|
|
12
|
-
export {
|
|
11
|
+
export { CreateSlackFinalResponseArtifactPublisherOptions, SlackFinalResponseArtifactContext, SlackFinalResponseArtifactDeliveryMode, SlackFinalResponseArtifactPublisher, SlackFinalResponseArtifactResult, SlackFinalResponseArtifactValueResolver, createSlackFinalResponseArtifactPublisher } from './artifacts/index.js';
|
|
12
|
+
export { LoadSlackAgentTurnHistoryContextOptions, SlackAgentTurnHistoryContextResult, SlackAgentTurnHistoryOptions, SlackAgentTurnHistoryProfileResolver, emptySlackAgentTurnHistoryContextResult, loadSlackAgentTurnHistoryContext } from './history/index.js';
|
|
13
13
|
export { S as SlackInteractiveActionIds, a as SlackInteractiveActor, b as SlackInteractiveApprovalRequest, c as SlackInteractiveController, d as SlackInteractiveControllerOptions, e as SlackInteractiveHumanInputRequest, f as SlackInteractiveMessageTarget, g as SlackInteractivePendingWaiter, h as SlackInteractivePostedMessage, i as SlackInteractiveRequestRecord, j as SlackInteractiveRequestStatus, k as SlackInteractiveRequestStore, l as SlackInteractiveRequestWaitOptions, m as SlackInteractiveResolution, n as SlackInteractiveStoredRequest } from './types-Crpil4kb.js';
|
|
14
|
-
export { buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createSlackInteractiveController, decodeActionValue, encodeActionValue, nowIso } from './interactive.js';
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export * from '@cuylabs/channel-slack/setup';
|
|
19
|
-
export * from '@cuylabs/channel-slack/targets';
|
|
14
|
+
export { PostgresSlackInteractiveRequestPruneResult, PostgresSlackInteractiveRequestStore, PostgresSlackInteractiveRequestStoreOptions, SlackInteractivePostgresClient, buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createPostgresSlackInteractiveRequestStore, createSlackInteractiveController, decodeActionValue, encodeActionValue, initializePostgresSlackInteractiveRequestStore, nowIso, prunePostgresSlackInteractiveRequestStore } 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
|
+
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';
|
|
20
18
|
export { MountSlackAgentOptions, MountSlackAgentResult, mountSlackAgent } from './express.js';
|
|
21
19
|
export { MountSlackAssistantAgentOptions, MountSlackAssistantAgentResult, mountSlackAssistantAgent } from './express-assistant.js';
|
|
22
20
|
export { MountSlackAgentAppSocketOptions, MountSlackAgentAppSocketResult, MountSlackAssistantAgentSocketOptions, MountSlackAssistantAgentSocketResult, mountSlackAgentAppSocket, mountSlackAssistantAgentSocket } from './socket.js';
|
|
@@ -24,9 +22,18 @@ export { MountSlackAgentAppOptions, MountSlackAgentAppResult, mountSlackAgentApp
|
|
|
24
22
|
export { CreateSlackMcpServerConfigOptions, SLACK_MCP_URL, createSlackMcpServerConfig } from './mcp.js';
|
|
25
23
|
export { MountSlackAgentAppTurnRequestContext } from './app-surface.js';
|
|
26
24
|
import '@cuylabs/agent-core';
|
|
25
|
+
import '@cuylabs/channel-slack/core';
|
|
26
|
+
import '@cuylabs/channel-slack/artifacts';
|
|
27
27
|
import '@slack/bolt';
|
|
28
28
|
import '@slack/web-api';
|
|
29
29
|
import '@cuylabs/channel-slack/feedback';
|
|
30
|
+
import '@cuylabs/channel-slack/history';
|
|
31
|
+
import '@slack/types';
|
|
32
|
+
import '@cuylabs/channel-slack/views';
|
|
33
|
+
import '@cuylabs/agent-core/dispatch';
|
|
30
34
|
import 'node:http';
|
|
31
35
|
import 'express';
|
|
36
|
+
import '@cuylabs/channel-slack/transports/http';
|
|
37
|
+
import '@cuylabs/channel-slack/auth';
|
|
38
|
+
import '@cuylabs/channel-slack/transports/socket';
|
|
32
39
|
import '@cuylabs/agent-core/mcp';
|