@seclai/sdk 1.7.0 → 1.9.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/CHANGELOG.md +48 -0
- package/README.md +204 -19
- package/dist/index.cjs +322 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +988 -112
- package/dist/index.d.ts +988 -112
- package/dist/index.js +322 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -64,10 +64,13 @@ var SeclaiApiVersion = {
|
|
|
64
64
|
V2026_10_18: "2026-10-18",
|
|
65
65
|
V2026_10_19: "2026-10-19",
|
|
66
66
|
V2026_10_21: "2026-10-21",
|
|
67
|
+
V2026_10_28: "2026-10-28",
|
|
68
|
+
V2026_11_02: "2026-11-02",
|
|
69
|
+
V2026_11_04: "2026-11-04",
|
|
67
70
|
/** Baseline applied to an unpinned, header-less caller. */
|
|
68
71
|
Default: "2026-07-01",
|
|
69
72
|
/** Newest version known to this SDK release. May lag the server. */
|
|
70
|
-
Latest: "2026-
|
|
73
|
+
Latest: "2026-11-04"
|
|
71
74
|
};
|
|
72
75
|
var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
|
|
73
76
|
|
|
@@ -114,10 +117,17 @@ var SeclaiAPIValidationError = class extends SeclaiAPIStatusError {
|
|
|
114
117
|
var SeclaiStreamingError = class extends SeclaiError {
|
|
115
118
|
/** The run ID associated with the failed stream, when available. */
|
|
116
119
|
runId;
|
|
117
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Set by `runStreamingAgentAndWait()` and `runAgentAndPoll()` to the latest
|
|
122
|
+
* run they had, if any (when it has `result_reported_at` set, its `output`
|
|
123
|
+
* is the answer). The run may still be in progress, and can still fail.
|
|
124
|
+
*/
|
|
125
|
+
run;
|
|
126
|
+
constructor(message, runId, run) {
|
|
118
127
|
super(message);
|
|
119
128
|
this.name = "SeclaiStreamingError";
|
|
120
129
|
this.runId = runId;
|
|
130
|
+
this.run = run;
|
|
121
131
|
}
|
|
122
132
|
};
|
|
123
133
|
|
|
@@ -901,6 +911,20 @@ var Seclai = class {
|
|
|
901
911
|
query: { page: opts.page, limit: opts.limit }
|
|
902
912
|
});
|
|
903
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* List the agent gallery: example agents to start from.
|
|
916
|
+
*
|
|
917
|
+
* Pass an entry's `key` as `agent_template` to {@link createAgent}, with
|
|
918
|
+
* `resource_bindings` for the resources it needs.
|
|
919
|
+
*
|
|
920
|
+
* @param opts - Text search, use-case filter and pagination.
|
|
921
|
+
* @returns A page of gallery entries.
|
|
922
|
+
*/
|
|
923
|
+
async listAgentExamples(opts = {}) {
|
|
924
|
+
return await this.request("GET", "/agents/examples", {
|
|
925
|
+
query: { query: opts.query, use_case: opts.useCase, page: opts.page, limit: opts.limit }
|
|
926
|
+
});
|
|
927
|
+
}
|
|
904
928
|
/**
|
|
905
929
|
* Create a new agent.
|
|
906
930
|
*
|
|
@@ -1119,11 +1143,46 @@ var Seclai = class {
|
|
|
1119
1143
|
* takes no `include_reasoning`, and one passed anyway is not sent: this method
|
|
1120
1144
|
* returns no `stream_reasoning` events.
|
|
1121
1145
|
*
|
|
1146
|
+
* A `result` event carries the run's answer in `output` once
|
|
1147
|
+
* `result_reported_at` is set, and can arrive while later steps still run.
|
|
1148
|
+
* Pass `returnOnResult: true` to return that `result` snapshot as soon as it
|
|
1149
|
+
* arrives, without waiting for `done`. Such a run may still be in progress:
|
|
1150
|
+
* its `status` is not terminal and the run can still fail, so check
|
|
1151
|
+
* `result_reported_at`, not `status`.
|
|
1152
|
+
*
|
|
1153
|
+
* If `timeoutMs` elapses, this throws {@link SeclaiStreamingError} with the
|
|
1154
|
+
* latest snapshot in `run`: the `result` snapshot if one arrived, else the
|
|
1155
|
+
* `init` snapshot. An abort from `signal` rethrows the abort error.
|
|
1156
|
+
*
|
|
1157
|
+
* By default, a stream that ends before `done` returns the latest snapshot
|
|
1158
|
+
* when its status is not `pending`, so the run returned may not have
|
|
1159
|
+
* finished: check `status` and `result_reported_at`. A stream that breaks
|
|
1160
|
+
* throws the fetch error. Pass `throwOnIncomplete: true` to throw
|
|
1161
|
+
* {@link SeclaiStreamingError} with the snapshot in `run` in both cases
|
|
1162
|
+
* instead; it is recommended, and becomes the default in the next major
|
|
1163
|
+
* version.
|
|
1164
|
+
*
|
|
1122
1165
|
* @param agentId - Agent identifier.
|
|
1123
1166
|
* @param body - Streaming run request payload, without `include_reasoning`.
|
|
1124
|
-
* @param opts - Timeout
|
|
1125
|
-
* @returns
|
|
1126
|
-
*
|
|
1167
|
+
* @param opts - Timeout, abort signal and `returnOnResult` options.
|
|
1168
|
+
* @returns The run from the `done` event; with `returnOnResult`, the
|
|
1169
|
+
* `result` snapshot; without `throwOnIncomplete`, possibly an unfinished
|
|
1170
|
+
* snapshot (see above).
|
|
1171
|
+
* @throws {@link SeclaiStreamingError} If `timeoutMs` elapses, or, with
|
|
1172
|
+
* `throwOnIncomplete`, the stream ends or breaks, before the run finished.
|
|
1173
|
+
* Its `run` holds the latest snapshot.
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* ```ts
|
|
1177
|
+
* try {
|
|
1178
|
+
* const run = await client.runStreamingAgentAndWait("agent-id", { input: "Hello" }, { throwOnIncomplete: true });
|
|
1179
|
+
* console.log(run.output);
|
|
1180
|
+
* } catch (err) {
|
|
1181
|
+
* if (err instanceof SeclaiStreamingError && err.run?.result_reported_at) {
|
|
1182
|
+
* console.log("Answer (run not finished):", err.run.output);
|
|
1183
|
+
* } else throw err;
|
|
1184
|
+
* }
|
|
1185
|
+
* ```
|
|
1127
1186
|
*/
|
|
1128
1187
|
async runStreamingAgentAndWait(agentId, body, opts) {
|
|
1129
1188
|
const { include_reasoning: _ignored, ...runBody } = body;
|
|
@@ -1143,6 +1202,7 @@ var Seclai = class {
|
|
|
1143
1202
|
}, timeoutMs);
|
|
1144
1203
|
const signal = anySignal([opts?.signal, timeoutController.signal]);
|
|
1145
1204
|
let lastSeen;
|
|
1205
|
+
let reported;
|
|
1146
1206
|
try {
|
|
1147
1207
|
const init = { method: "POST", headers, body: JSON.stringify(runBody) };
|
|
1148
1208
|
if (signal) init.signal = signal;
|
|
@@ -1171,7 +1231,14 @@ var Seclai = class {
|
|
|
1171
1231
|
});
|
|
1172
1232
|
}
|
|
1173
1233
|
if (isJson) {
|
|
1174
|
-
|
|
1234
|
+
const run2 = await response.json();
|
|
1235
|
+
const status = run2.status;
|
|
1236
|
+
const finished = status === "completed" || status === "failed" || status === "cancelled" || Boolean(opts?.returnOnResult && run2.result_reported_at);
|
|
1237
|
+
if (opts?.throwOnIncomplete && !finished) {
|
|
1238
|
+
const state2 = run2.result_reported_at ? "A result had been reported; see `run`." : "No result had been reported.";
|
|
1239
|
+
throw new SeclaiStreamingError(`The server answered with JSON for a run that has not finished. ${state2}`, run2.run_id, run2);
|
|
1240
|
+
}
|
|
1241
|
+
return run2;
|
|
1175
1242
|
}
|
|
1176
1243
|
if (!response.body) {
|
|
1177
1244
|
throw new SeclaiConfigurationError(
|
|
@@ -1183,31 +1250,48 @@ var Seclai = class {
|
|
|
1183
1250
|
let final;
|
|
1184
1251
|
const parser = createSseParser((msg) => {
|
|
1185
1252
|
if (!msg.data) return;
|
|
1186
|
-
if (msg.event === "init" || msg.event === "done") {
|
|
1253
|
+
if (msg.event === "init" || msg.event === "result" || msg.event === "done") {
|
|
1187
1254
|
try {
|
|
1188
1255
|
const parsed = JSON.parse(msg.data);
|
|
1189
1256
|
lastSeen = parsed;
|
|
1257
|
+
if (msg.event === "result") reported = parsed;
|
|
1190
1258
|
if (msg.event === "done") final = parsed;
|
|
1191
1259
|
} catch {
|
|
1192
1260
|
}
|
|
1193
1261
|
}
|
|
1194
1262
|
});
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1263
|
+
let readFailure;
|
|
1264
|
+
try {
|
|
1265
|
+
while (!final && !(opts?.returnOnResult && reported)) {
|
|
1266
|
+
const { value, done } = await reader.read();
|
|
1267
|
+
if (done) break;
|
|
1268
|
+
if (value) parser.feed(decoder.decode(value, { stream: true }));
|
|
1269
|
+
}
|
|
1270
|
+
} catch (err) {
|
|
1271
|
+
if (opts?.signal?.aborted || !opts?.throwOnIncomplete && !timedOut) throw err;
|
|
1272
|
+
readFailure = err instanceof Error ? err.message : String(err);
|
|
1199
1273
|
}
|
|
1274
|
+
parser.feed(decoder.decode());
|
|
1200
1275
|
parser.end();
|
|
1201
1276
|
if (final) return final;
|
|
1202
|
-
if (
|
|
1277
|
+
if (opts?.returnOnResult && reported) {
|
|
1278
|
+
reader.cancel().catch(() => {
|
|
1279
|
+
});
|
|
1280
|
+
return reported;
|
|
1281
|
+
}
|
|
1282
|
+
if (!opts?.throwOnIncomplete && !timedOut && lastSeen?.status && lastSeen.status !== "pending") {
|
|
1203
1283
|
return lastSeen;
|
|
1204
1284
|
}
|
|
1205
|
-
|
|
1285
|
+
const run = reported ?? lastSeen;
|
|
1286
|
+
const state = reported ? "A result had been reported; see `run`." : "No result had been reported.";
|
|
1287
|
+
const reason = timedOut ? `Timed out after ${timeoutMs}ms before the streaming agent run finished.` : readFailure !== void 0 ? `Stream failed before the run finished: ${readFailure}.` : "Stream ended before receiving a 'done' event.";
|
|
1288
|
+
throw new SeclaiStreamingError(`${reason} ${state}`, run?.run_id, run);
|
|
1206
1289
|
} catch (err) {
|
|
1207
|
-
if (timedOut) {
|
|
1290
|
+
if (timedOut && !opts?.signal?.aborted && !(err instanceof SeclaiStreamingError)) {
|
|
1208
1291
|
throw new SeclaiStreamingError(
|
|
1209
1292
|
`Timed out after ${timeoutMs}ms waiting for streaming agent run to complete.`,
|
|
1210
|
-
lastSeen?.run_id
|
|
1293
|
+
lastSeen?.run_id,
|
|
1294
|
+
reported ?? lastSeen
|
|
1211
1295
|
);
|
|
1212
1296
|
}
|
|
1213
1297
|
throw err;
|
|
@@ -1229,6 +1313,10 @@ var Seclai = class {
|
|
|
1229
1313
|
* @example
|
|
1230
1314
|
* ```ts
|
|
1231
1315
|
* for await (const event of client.runStreamingAgent("agent-id", { input: "Hello!" })) {
|
|
1316
|
+
* // `result` carries the answer in `output`, possibly before later steps finish.
|
|
1317
|
+
* if (event.event === "result") {
|
|
1318
|
+
* console.log("Answer:", (event.data as AgentRunResponse).output);
|
|
1319
|
+
* }
|
|
1232
1320
|
* if (event.event === "done") {
|
|
1233
1321
|
* console.log("Final:", event.data);
|
|
1234
1322
|
* }
|
|
@@ -1332,11 +1420,38 @@ var Seclai = class {
|
|
|
1332
1420
|
*
|
|
1333
1421
|
* This is useful in environments where SSE streaming is unavailable.
|
|
1334
1422
|
*
|
|
1423
|
+
* A run's answer can be ready before its last step finishes: once
|
|
1424
|
+
* `result_reported_at` is set, `output` holds the answer. Pass
|
|
1425
|
+
* `returnOnResult: true` to return as soon as a run has it set, the run
|
|
1426
|
+
* `runAgent()` returns included. With `includeStepOutputs`, when that run
|
|
1427
|
+
* would end the poll and `signal` is not aborted, it is fetched again at
|
|
1428
|
+
* once for its step outputs.
|
|
1429
|
+
* Such a run may still be in progress: its `status` is not terminal and the
|
|
1430
|
+
* run can still fail, so check `result_reported_at`, not `status`.
|
|
1431
|
+
*
|
|
1432
|
+
* When `timeoutMs` elapses first, this throws {@link SeclaiStreamingError}
|
|
1433
|
+
* with the latest run it has (the `runAgent()` response if no poll ran) in
|
|
1434
|
+
* `run`. If that run has `result_reported_at`
|
|
1435
|
+
* set, its `output` is the answer.
|
|
1436
|
+
*
|
|
1437
|
+
* `signal` is checked at the top of each poll, after the check for a run
|
|
1438
|
+
* that ends the poll. A run that has ended the poll by then, whether the
|
|
1439
|
+
* start run or a polled one, is returned even after an abort; the start run
|
|
1440
|
+
* then comes back without step outputs, even when `includeStepOutputs` is
|
|
1441
|
+
* set. Otherwise an abort throws `SeclaiError("Polling aborted.")`, which is
|
|
1442
|
+
* not an `AbortError` and does not carry `signal.reason`.
|
|
1443
|
+
*
|
|
1335
1444
|
* @param agentId - Agent identifier.
|
|
1336
1445
|
* @param body - Run request payload.
|
|
1337
1446
|
* @param opts - Polling configuration and abort signal.
|
|
1338
|
-
* @returns The terminal agent run
|
|
1339
|
-
*
|
|
1447
|
+
* @returns The terminal agent run, or, with `returnOnResult`, the first run
|
|
1448
|
+
* with `result_reported_at` set.
|
|
1449
|
+
* @throws {@link SeclaiStreamingError} If `timeoutMs` elapses before the run
|
|
1450
|
+
* finished. Its `run` holds the latest run it has (the `runAgent()`
|
|
1451
|
+
* response if no poll ran).
|
|
1452
|
+
* @throws {@link SeclaiError} `"Polling aborted."` If `signal` is aborted and,
|
|
1453
|
+
* at the next poll's check, the run has not ended the poll. It is not an
|
|
1454
|
+
* `AbortError` and does not carry `signal.reason`.
|
|
1340
1455
|
*/
|
|
1341
1456
|
async runAgentAndPoll(agentId, body, opts) {
|
|
1342
1457
|
const pollInterval = opts?.pollIntervalMs ?? 2e3;
|
|
@@ -1345,20 +1460,29 @@ var Seclai = class {
|
|
|
1345
1460
|
const run = await this.runAgent(agentId, body);
|
|
1346
1461
|
const runId = run.id ?? run.run_id;
|
|
1347
1462
|
if (!runId) throw new SeclaiError("Agent run response did not contain an id.");
|
|
1463
|
+
let current = run;
|
|
1464
|
+
if (opts?.includeStepOutputs) {
|
|
1465
|
+
const status = run.status;
|
|
1466
|
+
if (status === "completed" || status === "failed" || status === "cancelled" || opts.returnOnResult && run.result_reported_at) {
|
|
1467
|
+
if (!opts.signal?.aborted) current = await this.getAgentRun(runId, { includeStepOutputs: true });
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1348
1470
|
while (true) {
|
|
1471
|
+
const status = current.status;
|
|
1472
|
+
if (status === "completed" || status === "failed" || status === "cancelled") {
|
|
1473
|
+
return current;
|
|
1474
|
+
}
|
|
1475
|
+
if (opts?.returnOnResult && current.result_reported_at) return current;
|
|
1349
1476
|
if (opts?.signal?.aborted) throw new SeclaiError("Polling aborted.");
|
|
1350
1477
|
if (Date.now() - startTime > timeout) {
|
|
1351
|
-
|
|
1478
|
+
const state = current.result_reported_at ? "A result had been reported; see `run`." : "No result had been reported.";
|
|
1479
|
+
throw new SeclaiStreamingError(`Polling timed out after ${timeout}ms. ${state}`, runId, current);
|
|
1352
1480
|
}
|
|
1353
1481
|
await new Promise((r) => setTimeout(r, pollInterval));
|
|
1354
|
-
|
|
1482
|
+
current = await this.getAgentRun(
|
|
1355
1483
|
runId,
|
|
1356
1484
|
opts?.includeStepOutputs ? { includeStepOutputs: true } : void 0
|
|
1357
1485
|
);
|
|
1358
|
-
const status = current.status;
|
|
1359
|
-
if (status === "completed" || status === "failed" || status === "cancelled") {
|
|
1360
|
-
return current;
|
|
1361
|
-
}
|
|
1362
1486
|
}
|
|
1363
1487
|
}
|
|
1364
1488
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -1581,12 +1705,19 @@ var Seclai = class {
|
|
|
1581
1705
|
* List evaluation results for a specific criteria.
|
|
1582
1706
|
*
|
|
1583
1707
|
* @param criteriaId - Criteria identifier.
|
|
1584
|
-
* @param opts - Pagination
|
|
1708
|
+
* @param opts - Pagination, status, flag and time-range filters.
|
|
1585
1709
|
*/
|
|
1586
1710
|
async listEvaluationResults(criteriaId, opts = {}) {
|
|
1587
1711
|
return keyedList(
|
|
1588
1712
|
await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/results`, {
|
|
1589
|
-
query: {
|
|
1713
|
+
query: {
|
|
1714
|
+
page: opts.page,
|
|
1715
|
+
limit: opts.limit,
|
|
1716
|
+
status: opts.status,
|
|
1717
|
+
flagged_only: opts.flaggedOnly,
|
|
1718
|
+
time_from: opts.timeFrom,
|
|
1719
|
+
time_to: opts.timeTo
|
|
1720
|
+
}
|
|
1590
1721
|
}),
|
|
1591
1722
|
"data",
|
|
1592
1723
|
PAGE_COUNTERS
|
|
@@ -1606,12 +1737,12 @@ var Seclai = class {
|
|
|
1606
1737
|
* List runs compatible with a specific evaluation criteria.
|
|
1607
1738
|
*
|
|
1608
1739
|
* @param criteriaId - Criteria identifier.
|
|
1609
|
-
* @param opts - Pagination
|
|
1740
|
+
* @param opts - Pagination and a `startedAfter` filter.
|
|
1610
1741
|
*/
|
|
1611
1742
|
async listCompatibleRuns(criteriaId, opts = {}) {
|
|
1612
1743
|
return keyedList(
|
|
1613
1744
|
await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/compatible-runs`, {
|
|
1614
|
-
query: { page: opts.page, limit: opts.limit }
|
|
1745
|
+
query: { page: opts.page, limit: opts.limit, started_after: opts.startedAfter }
|
|
1615
1746
|
}),
|
|
1616
1747
|
"data",
|
|
1617
1748
|
PAGE_COUNTERS
|
|
@@ -1631,12 +1762,20 @@ var Seclai = class {
|
|
|
1631
1762
|
* List all evaluation results for an agent.
|
|
1632
1763
|
*
|
|
1633
1764
|
* @param agentId - Agent identifier.
|
|
1634
|
-
* @param opts - Pagination
|
|
1765
|
+
* @param opts - Pagination, status, step, flag and time-range filters.
|
|
1635
1766
|
*/
|
|
1636
1767
|
async listAgentEvaluationResults(agentId, opts = {}) {
|
|
1637
1768
|
return keyedList(
|
|
1638
1769
|
await this.request("GET", `/agents/${agentId}/evaluation-results`, {
|
|
1639
|
-
query: {
|
|
1770
|
+
query: {
|
|
1771
|
+
page: opts.page,
|
|
1772
|
+
limit: opts.limit,
|
|
1773
|
+
status: opts.status,
|
|
1774
|
+
step: opts.step,
|
|
1775
|
+
flagged_only: opts.flaggedOnly,
|
|
1776
|
+
time_from: opts.timeFrom,
|
|
1777
|
+
time_to: opts.timeTo
|
|
1778
|
+
}
|
|
1640
1779
|
}),
|
|
1641
1780
|
"data",
|
|
1642
1781
|
PAGE_COUNTERS
|
|
@@ -1646,25 +1785,35 @@ var Seclai = class {
|
|
|
1646
1785
|
* List evaluation run summaries for an agent.
|
|
1647
1786
|
*
|
|
1648
1787
|
* @param agentId - Agent identifier.
|
|
1649
|
-
* @param opts - Pagination
|
|
1788
|
+
* @param opts - Pagination, status, step and time-range filters.
|
|
1650
1789
|
*/
|
|
1651
1790
|
async listEvaluationRuns(agentId, opts = {}) {
|
|
1652
1791
|
return keyedList(
|
|
1653
1792
|
await this.request("GET", `/agents/${agentId}/evaluation-runs`, {
|
|
1654
|
-
query: {
|
|
1793
|
+
query: {
|
|
1794
|
+
page: opts.page,
|
|
1795
|
+
limit: opts.limit,
|
|
1796
|
+
status: opts.status,
|
|
1797
|
+
step: opts.step,
|
|
1798
|
+
time_from: opts.timeFrom,
|
|
1799
|
+
time_to: opts.timeTo
|
|
1800
|
+
}
|
|
1655
1801
|
}),
|
|
1656
1802
|
"data",
|
|
1657
1803
|
PAGE_COUNTERS
|
|
1658
1804
|
);
|
|
1659
1805
|
}
|
|
1660
1806
|
/**
|
|
1661
|
-
* Get a summary of non-manual evaluations
|
|
1807
|
+
* Get a summary of non-manual evaluations, for one agent or the whole account.
|
|
1662
1808
|
*
|
|
1663
|
-
* @param agentId - Agent identifier.
|
|
1809
|
+
* @param agentId - Agent identifier. Omit (pass `undefined`) for the account-wide summary.
|
|
1810
|
+
* @param opts - Date range. `startDate` and `endDate` together set the range;
|
|
1811
|
+
* `startDate` alone runs from it through today; otherwise the last `days`
|
|
1812
|
+
* days apply (server default 30), and an `endDate` without `startDate` is ignored.
|
|
1664
1813
|
*/
|
|
1665
|
-
async getNonManualEvaluationSummary(agentId) {
|
|
1814
|
+
async getNonManualEvaluationSummary(agentId, opts = {}) {
|
|
1666
1815
|
return await this.request("GET", "/agents/evaluation-results/non-manual-summary", {
|
|
1667
|
-
query: { agent_id: agentId }
|
|
1816
|
+
query: { agent_id: agentId, days: opts.days, start_date: opts.startDate, end_date: opts.endDate }
|
|
1668
1817
|
});
|
|
1669
1818
|
}
|
|
1670
1819
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -1688,6 +1837,27 @@ var Seclai = class {
|
|
|
1688
1837
|
json: body
|
|
1689
1838
|
});
|
|
1690
1839
|
}
|
|
1840
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1841
|
+
// Agent Slack Triggers
|
|
1842
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1843
|
+
/**
|
|
1844
|
+
* Configure an agent's `SLACK_COMMAND` trigger, which people run from Slack
|
|
1845
|
+
* with `/seclai` or the message shortcut.
|
|
1846
|
+
*
|
|
1847
|
+
* Sets the Slack connection, `alias` (the name people type after `/seclai`),
|
|
1848
|
+
* form, channels, reply visibility and conversation settings. Omitted fields
|
|
1849
|
+
* are left unchanged. `input` is deprecated and ignored by the API.
|
|
1850
|
+
*
|
|
1851
|
+
* @param agentId - Agent identifier.
|
|
1852
|
+
* @param triggerId - Trigger identifier.
|
|
1853
|
+
* @param body - The fields to set.
|
|
1854
|
+
* @returns The trigger's full Slack config, including any `missing_scopes`.
|
|
1855
|
+
*/
|
|
1856
|
+
async setSlackTriggerConfig(agentId, triggerId, body) {
|
|
1857
|
+
return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/slack-config`, {
|
|
1858
|
+
json: body
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1691
1861
|
/**
|
|
1692
1862
|
* Replace the input attachments a trigger accepts.
|
|
1693
1863
|
*
|
|
@@ -1706,6 +1876,40 @@ var Seclai = class {
|
|
|
1706
1876
|
json: body
|
|
1707
1877
|
});
|
|
1708
1878
|
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Get the run metadata keys a trigger declares.
|
|
1881
|
+
*
|
|
1882
|
+
* Steps may reference a declared key as `{{metadata.<key>}}`. The response
|
|
1883
|
+
* also lists the system and source keys the trigger's type can declare.
|
|
1884
|
+
*
|
|
1885
|
+
* @param agentId - Agent identifier.
|
|
1886
|
+
* @param triggerId - Trigger identifier, as `getAgent()` returns it.
|
|
1887
|
+
* @returns The trigger's declared and declarable metadata keys.
|
|
1888
|
+
*/
|
|
1889
|
+
async getMetadataKeys(agentId, triggerId) {
|
|
1890
|
+
return await this.request(
|
|
1891
|
+
"GET",
|
|
1892
|
+
`/agents/${agentId}/triggers/${triggerId}/metadata-keys`
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Replace the run metadata keys a trigger declares.
|
|
1897
|
+
*
|
|
1898
|
+
* The body is the whole declaration and replaces the current one. The API
|
|
1899
|
+
* answers 400 when the agent references a key that no trigger of its branch
|
|
1900
|
+
* declares.
|
|
1901
|
+
*
|
|
1902
|
+
* @param agentId - Agent identifier.
|
|
1903
|
+
* @param triggerId - Trigger identifier, as `getAgent()` returns it.
|
|
1904
|
+
* @param body - The full declaration; each key's `required` defaults to `false`.
|
|
1905
|
+
* @returns The trigger's metadata keys, with `warnings` naming agents whose
|
|
1906
|
+
* `call_agent` mapping no longer fits.
|
|
1907
|
+
*/
|
|
1908
|
+
async setMetadataKeys(agentId, triggerId, body) {
|
|
1909
|
+
return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/metadata-keys`, {
|
|
1910
|
+
json: body
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1709
1913
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1710
1914
|
// Agent Email Governance
|
|
1711
1915
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -1872,6 +2076,21 @@ var Seclai = class {
|
|
|
1872
2076
|
async getKnowledgeBase(knowledgeBaseId) {
|
|
1873
2077
|
return await this.request("GET", `/knowledge_bases/${knowledgeBaseId}`);
|
|
1874
2078
|
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Get the item-metadata keys seen in a knowledge base's content.
|
|
2081
|
+
*
|
|
2082
|
+
* Reports, for all time and the last 30 and 7 days, each key's item count,
|
|
2083
|
+
* number of distinct values and five most frequent values.
|
|
2084
|
+
*
|
|
2085
|
+
* @param knowledgeBaseId - Knowledge base identifier.
|
|
2086
|
+
* @returns The key statistics per window.
|
|
2087
|
+
*/
|
|
2088
|
+
async getKnowledgeBaseMetadataKeyStats(knowledgeBaseId) {
|
|
2089
|
+
return await this.request(
|
|
2090
|
+
"GET",
|
|
2091
|
+
`/knowledge_bases/${knowledgeBaseId}/metadata-key-stats`
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
1875
2094
|
/**
|
|
1876
2095
|
* Update a knowledge base.
|
|
1877
2096
|
*
|
|
@@ -1896,13 +2115,13 @@ var Seclai = class {
|
|
|
1896
2115
|
/**
|
|
1897
2116
|
* List memory banks.
|
|
1898
2117
|
*
|
|
1899
|
-
* @param opts - Pagination and
|
|
2118
|
+
* @param opts - Pagination, sorting and a `type` filter.
|
|
1900
2119
|
* @returns Paginated list of memory banks.
|
|
1901
2120
|
*/
|
|
1902
2121
|
async listMemoryBanks(opts = {}) {
|
|
1903
2122
|
return keyedList(
|
|
1904
2123
|
await this.request("GET", "/memory_banks", {
|
|
1905
|
-
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
|
|
2124
|
+
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order, type: opts.type }
|
|
1906
2125
|
}),
|
|
1907
2126
|
"memory_banks",
|
|
1908
2127
|
PAGE_COUNTERS
|
|
@@ -1959,9 +2178,13 @@ var Seclai = class {
|
|
|
1959
2178
|
* Get stats for a memory bank.
|
|
1960
2179
|
*
|
|
1961
2180
|
* @param memoryBankId - Memory bank identifier.
|
|
2181
|
+
* @param opts - Date range. Only `startDate` and `endDate` together replace
|
|
2182
|
+
* `days`; either one alone is ignored and the last `days` days apply (server default 30).
|
|
1962
2183
|
*/
|
|
1963
|
-
async getMemoryBankStats(memoryBankId) {
|
|
1964
|
-
return await this.request("GET", `/memory_banks/${memoryBankId}/stats
|
|
2184
|
+
async getMemoryBankStats(memoryBankId, opts = {}) {
|
|
2185
|
+
return await this.request("GET", `/memory_banks/${memoryBankId}/stats`, {
|
|
2186
|
+
query: { days: opts.days, start_date: opts.startDate, end_date: opts.endDate }
|
|
2187
|
+
});
|
|
1965
2188
|
}
|
|
1966
2189
|
/**
|
|
1967
2190
|
* Compact a memory bank (trigger compaction).
|
|
@@ -2014,9 +2237,13 @@ var Seclai = class {
|
|
|
2014
2237
|
}
|
|
2015
2238
|
/**
|
|
2016
2239
|
* Get the last AI conversation for memory banks.
|
|
2240
|
+
*
|
|
2241
|
+
* @param opts - Turns to return (server default 5) and most-recent turns to skip (default 0).
|
|
2017
2242
|
*/
|
|
2018
|
-
async getMemoryBankAiLastConversation() {
|
|
2019
|
-
return await this.request("GET", "/memory_banks/ai-assistant/last-conversation"
|
|
2243
|
+
async getMemoryBankAiLastConversation(opts = {}) {
|
|
2244
|
+
return await this.request("GET", "/memory_banks/ai-assistant/last-conversation", {
|
|
2245
|
+
query: { limit: opts.limit, offset: opts.offset }
|
|
2246
|
+
});
|
|
2020
2247
|
}
|
|
2021
2248
|
/**
|
|
2022
2249
|
* Accept a memory bank AI suggestion.
|
|
@@ -2413,12 +2640,12 @@ var Seclai = class {
|
|
|
2413
2640
|
/**
|
|
2414
2641
|
* List solutions.
|
|
2415
2642
|
*
|
|
2416
|
-
* @param opts - Pagination and
|
|
2643
|
+
* @param opts - Pagination, sorting and a name `search`.
|
|
2417
2644
|
* @returns Paginated list of solutions.
|
|
2418
2645
|
*/
|
|
2419
2646
|
async listSolutions(opts = {}) {
|
|
2420
2647
|
return await this.request("GET", "/solutions", {
|
|
2421
|
-
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
|
|
2648
|
+
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order, search: opts.search }
|
|
2422
2649
|
});
|
|
2423
2650
|
}
|
|
2424
2651
|
/**
|
|
@@ -2615,10 +2842,12 @@ var Seclai = class {
|
|
|
2615
2842
|
}
|
|
2616
2843
|
/**
|
|
2617
2844
|
* List governance AI conversations.
|
|
2845
|
+
*
|
|
2846
|
+
* @param opts - `limit`: how many conversations (the server defaults to 20).
|
|
2618
2847
|
*/
|
|
2619
|
-
async listGovernanceAiConversations() {
|
|
2848
|
+
async listGovernanceAiConversations(opts = {}) {
|
|
2620
2849
|
return listItems(
|
|
2621
|
-
await this.request("GET", "/governance/ai-assistant/conversations")
|
|
2850
|
+
await this.request("GET", "/governance/ai-assistant/conversations", { query: { limit: opts.limit } })
|
|
2622
2851
|
);
|
|
2623
2852
|
}
|
|
2624
2853
|
/**
|
|
@@ -2649,7 +2878,15 @@ var Seclai = class {
|
|
|
2649
2878
|
*/
|
|
2650
2879
|
async listAlerts(opts = {}) {
|
|
2651
2880
|
return await this.request("GET", "/alerts", {
|
|
2652
|
-
query: {
|
|
2881
|
+
query: {
|
|
2882
|
+
page: opts.page,
|
|
2883
|
+
limit: opts.limit,
|
|
2884
|
+
status: opts.status,
|
|
2885
|
+
agent_id: opts.agentId,
|
|
2886
|
+
source_connection_id: opts.sourceConnectionId,
|
|
2887
|
+
time_from: opts.timeFrom,
|
|
2888
|
+
time_to: opts.timeTo
|
|
2889
|
+
}
|
|
2653
2890
|
});
|
|
2654
2891
|
}
|
|
2655
2892
|
/**
|
|
@@ -2708,7 +2945,15 @@ var Seclai = class {
|
|
|
2708
2945
|
*/
|
|
2709
2946
|
async listAlertConfigs(opts = {}) {
|
|
2710
2947
|
return keyedList(
|
|
2711
|
-
await this.request("GET", "/alerts/configs", {
|
|
2948
|
+
await this.request("GET", "/alerts/configs", {
|
|
2949
|
+
query: {
|
|
2950
|
+
page: opts.page,
|
|
2951
|
+
limit: opts.limit,
|
|
2952
|
+
agent_id: opts.agentId,
|
|
2953
|
+
source_connection_id: opts.sourceConnectionId,
|
|
2954
|
+
scope: opts.scope
|
|
2955
|
+
}
|
|
2956
|
+
}),
|
|
2712
2957
|
"configs",
|
|
2713
2958
|
["total"]
|
|
2714
2959
|
);
|
|
@@ -2752,10 +2997,14 @@ var Seclai = class {
|
|
|
2752
2997
|
// ─── Organization Alert Preferences ────────────────────────────────────────
|
|
2753
2998
|
/**
|
|
2754
2999
|
* List organization alert preferences.
|
|
3000
|
+
*
|
|
3001
|
+
* @param opts - Organization filter, and whether to include default subscriptions.
|
|
2755
3002
|
*/
|
|
2756
|
-
async listOrganizationAlertPreferences() {
|
|
3003
|
+
async listOrganizationAlertPreferences(opts = {}) {
|
|
2757
3004
|
return keyedList(
|
|
2758
|
-
await this.request("GET", "/alerts/organization-preferences/list"
|
|
3005
|
+
await this.request("GET", "/alerts/organization-preferences/list", {
|
|
3006
|
+
query: { organization_id: opts.organizationId, include_defaults: opts.includeDefaults }
|
|
3007
|
+
}),
|
|
2759
3008
|
"preferences",
|
|
2760
3009
|
["total"]
|
|
2761
3010
|
);
|
|
@@ -2780,13 +3029,15 @@ var Seclai = class {
|
|
|
2780
3029
|
/**
|
|
2781
3030
|
* List model alerts.
|
|
2782
3031
|
*
|
|
2783
|
-
* @param opts - Pagination
|
|
3032
|
+
* @param opts - Pagination, an agent filter and `unreadOnly`.
|
|
2784
3033
|
*/
|
|
2785
3034
|
async listModelAlerts(opts = {}) {
|
|
2786
3035
|
const limit = opts.limit ?? 50;
|
|
2787
3036
|
const offset = opts.page && opts.page > 1 ? (opts.page - 1) * limit : void 0;
|
|
2788
3037
|
return keyedList(
|
|
2789
|
-
await this.request("GET", "/models/alerts", {
|
|
3038
|
+
await this.request("GET", "/models/alerts", {
|
|
3039
|
+
query: { offset, limit: opts.limit, agent_id: opts.agentId, unread_only: opts.unreadOnly }
|
|
3040
|
+
}),
|
|
2790
3041
|
"alerts",
|
|
2791
3042
|
["total"]
|
|
2792
3043
|
);
|
|
@@ -2815,9 +3066,18 @@ var Seclai = class {
|
|
|
2815
3066
|
* Get model recommendations.
|
|
2816
3067
|
*
|
|
2817
3068
|
* @param modelId - Model identifier.
|
|
3069
|
+
* @param opts - Capabilities and limits a recommended model must have.
|
|
2818
3070
|
*/
|
|
2819
|
-
async getModelRecommendations(modelId) {
|
|
2820
|
-
return await this.request("GET", `/models/${modelId}/recommendations
|
|
3071
|
+
async getModelRecommendations(modelId, opts = {}) {
|
|
3072
|
+
return await this.request("GET", `/models/${modelId}/recommendations`, {
|
|
3073
|
+
query: {
|
|
3074
|
+
require_tool_use: opts.requireToolUse,
|
|
3075
|
+
require_structured_output: opts.requireStructuredOutput,
|
|
3076
|
+
require_thinking: opts.requireThinking,
|
|
3077
|
+
min_context_tokens: opts.minContextTokens,
|
|
3078
|
+
min_output_tokens: opts.minOutputTokens
|
|
3079
|
+
}
|
|
3080
|
+
});
|
|
2821
3081
|
}
|
|
2822
3082
|
/**
|
|
2823
3083
|
* List all enabled LLM models grouped by provider.
|
|
@@ -2889,7 +3149,9 @@ var Seclai = class {
|
|
|
2889
3149
|
/**
|
|
2890
3150
|
* List model playground experiments.
|
|
2891
3151
|
*
|
|
2892
|
-
* @param opts -
|
|
3152
|
+
* @param opts - Date range and offset paging. Only `startDate` and `endDate`
|
|
3153
|
+
* together replace `days`; either one alone is ignored and the last `days`
|
|
3154
|
+
* days apply (server default 30).
|
|
2893
3155
|
*/
|
|
2894
3156
|
async listExperiments(opts = {}) {
|
|
2895
3157
|
return keyedList(
|
|
@@ -3220,9 +3482,13 @@ var Seclai = class {
|
|
|
3220
3482
|
}
|
|
3221
3483
|
/**
|
|
3222
3484
|
* Get AI assistant memory bank conversation history.
|
|
3485
|
+
*
|
|
3486
|
+
* @param opts - Turns to return (server default 5) and most-recent turns to skip (default 0).
|
|
3223
3487
|
*/
|
|
3224
|
-
async getAiAssistantMemoryBankHistory() {
|
|
3225
|
-
return await this.request("GET", "/ai-assistant/memory-bank/last-conversation"
|
|
3488
|
+
async getAiAssistantMemoryBankHistory(opts = {}) {
|
|
3489
|
+
return await this.request("GET", "/ai-assistant/memory-bank/last-conversation", {
|
|
3490
|
+
query: { limit: opts.limit, offset: opts.offset }
|
|
3491
|
+
});
|
|
3226
3492
|
}
|
|
3227
3493
|
/**
|
|
3228
3494
|
* Accept an AI assistant suggestion.
|