@seclai/sdk 1.5.0 → 1.6.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/CHANGELOG.md +40 -0
- package/README.md +94 -19
- package/dist/index.cjs +417 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1035 -95
- package/dist/index.d.ts +1035 -95
- package/dist/index.js +417 -125
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
var SeclaiApiVersion = {
|
|
3
3
|
V2026_07_01: "2026-07-01",
|
|
4
4
|
V2026_07_27: "2026-07-27",
|
|
5
|
+
V2026_08_03: "2026-08-03",
|
|
6
|
+
V2026_08_21: "2026-08-21",
|
|
7
|
+
V2026_09_28: "2026-09-28",
|
|
8
|
+
V2026_09_30: "2026-09-30",
|
|
9
|
+
V2026_10_03: "2026-10-03",
|
|
5
10
|
/** Baseline applied to an unpinned, header-less caller. */
|
|
6
11
|
Default: "2026-07-01",
|
|
7
12
|
/** Newest version known to this SDK release. May lag the server. */
|
|
8
|
-
Latest: "2026-
|
|
13
|
+
Latest: "2026-10-03"
|
|
9
14
|
};
|
|
10
15
|
var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
|
|
11
16
|
|
|
@@ -356,11 +361,58 @@ function buildURL(baseUrl, path, query) {
|
|
|
356
361
|
if (query) {
|
|
357
362
|
for (const [key, value] of Object.entries(query)) {
|
|
358
363
|
if (value === void 0 || value === null) continue;
|
|
364
|
+
if (Array.isArray(value)) {
|
|
365
|
+
for (const item of value) url.searchParams.append(key, String(item));
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
359
368
|
url.searchParams.set(key, String(value));
|
|
360
369
|
}
|
|
361
370
|
}
|
|
362
371
|
return url;
|
|
363
372
|
}
|
|
373
|
+
function listItems(res) {
|
|
374
|
+
if (Array.isArray(res)) return res;
|
|
375
|
+
if (res !== null && typeof res === "object" && "data" in res) {
|
|
376
|
+
const data = res.data;
|
|
377
|
+
if (Array.isArray(data)) return data;
|
|
378
|
+
if (data === null) return [];
|
|
379
|
+
}
|
|
380
|
+
throw notAList();
|
|
381
|
+
}
|
|
382
|
+
function notAList() {
|
|
383
|
+
return new SeclaiError(
|
|
384
|
+
"Expected a list response: an array, or an object carrying the items under `data` or the endpoint's own key."
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
function keyedList(res, key, flat = []) {
|
|
388
|
+
if (Array.isArray(res)) return { [key]: res };
|
|
389
|
+
if (res === null || typeof res !== "object") throw notAList();
|
|
390
|
+
const body = { ...res };
|
|
391
|
+
if (Array.isArray(body.data)) body[key] = body.data;
|
|
392
|
+
else if ("data" in body && body.data === null) body[key] = [];
|
|
393
|
+
else if (!Array.isArray(body[key])) throw notAList();
|
|
394
|
+
const pagination = body.pagination;
|
|
395
|
+
for (const field of flat) {
|
|
396
|
+
if (body[field] === void 0 && pagination?.[field] !== void 0) body[field] = pagination[field];
|
|
397
|
+
}
|
|
398
|
+
return body;
|
|
399
|
+
}
|
|
400
|
+
var PAGE_COUNTERS = ["total", "page", "limit"];
|
|
401
|
+
function mergeHeaders(...layers) {
|
|
402
|
+
const byName = /* @__PURE__ */ new Map();
|
|
403
|
+
for (const layer of layers) {
|
|
404
|
+
for (const [name, value] of Object.entries(layer ?? {})) {
|
|
405
|
+
if (value === void 0 || value === null) continue;
|
|
406
|
+
const lower = name.toLowerCase();
|
|
407
|
+
byName.delete(lower);
|
|
408
|
+
byName.set(lower, [name, value]);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return Object.fromEntries(byName.values());
|
|
412
|
+
}
|
|
413
|
+
function headerKey(headers, name) {
|
|
414
|
+
return Object.keys(headers ?? {}).filter((key) => key.toLowerCase() === name).pop();
|
|
415
|
+
}
|
|
364
416
|
async function safeText(response) {
|
|
365
417
|
try {
|
|
366
418
|
return await response.clone().text();
|
|
@@ -476,6 +528,7 @@ function inferMimeType(fileName) {
|
|
|
476
528
|
var Seclai = class {
|
|
477
529
|
baseUrl;
|
|
478
530
|
defaultHeaders;
|
|
531
|
+
allowUnknownApiVersion;
|
|
479
532
|
fetcher;
|
|
480
533
|
_authState = null;
|
|
481
534
|
_authInitPromise = null;
|
|
@@ -506,22 +559,13 @@ var Seclai = class {
|
|
|
506
559
|
);
|
|
507
560
|
}
|
|
508
561
|
this.baseUrl = opts.baseUrl ?? getEnv2("SECLAI_API_URL") ?? SECLAI_API_URL;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if (key.toLowerCase() === "seclai-version") versionKey = key;
|
|
517
|
-
}
|
|
518
|
-
const effectiveVersion = versionKey ? merged[versionKey] : void 0;
|
|
519
|
-
if (effectiveVersion && !opts.allowUnknownApiVersion && !KNOWN_API_VERSIONS.includes(effectiveVersion)) {
|
|
520
|
-
const via = versionKey === "Seclai-Version" && merged[versionKey] === opts.apiVersion ? "apiVersion" : `defaultHeaders['${versionKey}']`;
|
|
521
|
-
throw new SeclaiConfigurationError(
|
|
522
|
-
`Unknown API version '${effectiveVersion}' (via ${via}). This release was built against ${KNOWN_API_VERSIONS.join(", ")}. A newer API version can change response shapes, which this client would decode incorrectly rather than reject. Upgrade the package, or set allowUnknownApiVersion to proceed anyway.`
|
|
523
|
-
);
|
|
524
|
-
}
|
|
562
|
+
this.allowUnknownApiVersion = opts.allowUnknownApiVersion ?? false;
|
|
563
|
+
const merged = mergeHeaders(
|
|
564
|
+
opts.apiVersion ? { "Seclai-Version": opts.apiVersion } : void 0,
|
|
565
|
+
opts.defaultHeaders
|
|
566
|
+
);
|
|
567
|
+
const defaultKey = headerKey(opts.defaultHeaders, "seclai-version");
|
|
568
|
+
this.assertKnownApiVersion(merged, defaultKey ? `defaultHeaders['${defaultKey}']` : "apiVersion");
|
|
525
569
|
this.defaultHeaders = merged;
|
|
526
570
|
this.fetcher = fetcher;
|
|
527
571
|
const accessTokenProvider = typeof opts.accessToken === "function" ? opts.accessToken : void 0;
|
|
@@ -560,6 +604,26 @@ var Seclai = class {
|
|
|
560
604
|
}
|
|
561
605
|
return this._authState;
|
|
562
606
|
}
|
|
607
|
+
/** Throw unless the `Seclai-Version` in `headers` is one this release was built against. */
|
|
608
|
+
assertKnownApiVersion(headers, via) {
|
|
609
|
+
const key = headerKey(headers, "seclai-version");
|
|
610
|
+
if (key === void 0 || this.allowUnknownApiVersion) return;
|
|
611
|
+
const version = headers[key] ?? "";
|
|
612
|
+
if (KNOWN_API_VERSIONS.includes(version)) return;
|
|
613
|
+
throw new SeclaiConfigurationError(
|
|
614
|
+
`Unknown API version '${version}' (via ${via}). This release was built against ${KNOWN_API_VERSIONS.join(", ")}. A newer API version can change response shapes, which this client would decode incorrectly rather than reject. Upgrade the package, or set allowUnknownApiVersion to proceed anyway.`
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The headers one request sends: `layers` merged in order, later winning,
|
|
619
|
+
* with the resulting `Seclai-Version` checked against the known versions.
|
|
620
|
+
*/
|
|
621
|
+
requestHeaders(layers, perRequest) {
|
|
622
|
+
const headers = mergeHeaders(...layers);
|
|
623
|
+
const requestKey = headerKey(perRequest, "seclai-version");
|
|
624
|
+
this.assertKnownApiVersion(headers, requestKey ? `headers['${requestKey}']` : "defaultHeaders");
|
|
625
|
+
return headers;
|
|
626
|
+
}
|
|
563
627
|
/** Resolve auth headers for the current request. */
|
|
564
628
|
async authHeaders() {
|
|
565
629
|
const state = await this.ensureAuth();
|
|
@@ -583,16 +647,17 @@ var Seclai = class {
|
|
|
583
647
|
async request(method, path, opts) {
|
|
584
648
|
const url = buildURL(this.baseUrl, path, opts?.query);
|
|
585
649
|
const authHeaders = await this.authHeaders();
|
|
586
|
-
const headers = {
|
|
587
|
-
...this.defaultHeaders,
|
|
588
|
-
...opts?.headers ?? {},
|
|
589
|
-
...authHeaders
|
|
590
|
-
};
|
|
591
650
|
let body;
|
|
592
|
-
if (opts?.json !== void 0)
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
651
|
+
if (opts?.json !== void 0) body = JSON.stringify(opts.json);
|
|
652
|
+
const headers = this.requestHeaders(
|
|
653
|
+
[
|
|
654
|
+
body === void 0 ? void 0 : { "content-type": "application/json" },
|
|
655
|
+
this.defaultHeaders,
|
|
656
|
+
opts?.headers,
|
|
657
|
+
authHeaders
|
|
658
|
+
],
|
|
659
|
+
opts?.headers
|
|
660
|
+
);
|
|
596
661
|
const init = { method, headers };
|
|
597
662
|
if (body !== void 0) {
|
|
598
663
|
init.body = body;
|
|
@@ -644,16 +709,17 @@ var Seclai = class {
|
|
|
644
709
|
async requestRaw(method, path, opts) {
|
|
645
710
|
const url = buildURL(this.baseUrl, path, opts?.query);
|
|
646
711
|
const authHeaders = await this.authHeaders();
|
|
647
|
-
const headers = {
|
|
648
|
-
...this.defaultHeaders,
|
|
649
|
-
...opts?.headers ?? {},
|
|
650
|
-
...authHeaders
|
|
651
|
-
};
|
|
652
712
|
let body;
|
|
653
|
-
if (opts?.json !== void 0)
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
713
|
+
if (opts?.json !== void 0) body = JSON.stringify(opts.json);
|
|
714
|
+
const headers = this.requestHeaders(
|
|
715
|
+
[
|
|
716
|
+
body === void 0 ? void 0 : { "content-type": "application/json" },
|
|
717
|
+
this.defaultHeaders,
|
|
718
|
+
opts?.headers,
|
|
719
|
+
authHeaders
|
|
720
|
+
],
|
|
721
|
+
opts?.headers
|
|
722
|
+
);
|
|
657
723
|
const init = { method, headers };
|
|
658
724
|
if (body !== void 0) init.body = body;
|
|
659
725
|
if (opts?.signal) init.signal = opts.signal;
|
|
@@ -685,12 +751,9 @@ var Seclai = class {
|
|
|
685
751
|
async uploadFile(path, opts) {
|
|
686
752
|
const url = buildURL(this.baseUrl, path);
|
|
687
753
|
const authHeaders = await this.authHeaders();
|
|
688
|
-
const headers =
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
};
|
|
692
|
-
delete headers["content-type"];
|
|
693
|
-
delete headers["Content-Type"];
|
|
754
|
+
const headers = this.requestHeaders([this.defaultHeaders, authHeaders]);
|
|
755
|
+
const contentType = headerKey(headers, "content-type");
|
|
756
|
+
if (contentType !== void 0) delete headers[contentType];
|
|
694
757
|
const form = new FormData();
|
|
695
758
|
const mimeType = opts.mimeType ?? inferMimeType(opts.fileName);
|
|
696
759
|
const blob = toBlob(opts.file, mimeType);
|
|
@@ -857,7 +920,7 @@ var Seclai = class {
|
|
|
857
920
|
* @returns The calling agents.
|
|
858
921
|
*/
|
|
859
922
|
async getAgentCallers(agentId) {
|
|
860
|
-
return await this.request("GET", `/agents/${agentId}/callers`);
|
|
923
|
+
return listItems(await this.request("GET", `/agents/${agentId}/callers`));
|
|
861
924
|
}
|
|
862
925
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
863
926
|
// Agent Export / Import
|
|
@@ -1006,12 +1069,11 @@ var Seclai = class {
|
|
|
1006
1069
|
async runStreamingAgentAndWait(agentId, body, opts) {
|
|
1007
1070
|
const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
|
|
1008
1071
|
const authHdrs = await this.authHeaders();
|
|
1009
|
-
const headers =
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
accept: "text/event-stream",
|
|
1013
|
-
|
|
1014
|
-
};
|
|
1072
|
+
const headers = this.requestHeaders([
|
|
1073
|
+
this.defaultHeaders,
|
|
1074
|
+
authHdrs,
|
|
1075
|
+
{ accept: "text/event-stream", "content-type": "application/json" }
|
|
1076
|
+
]);
|
|
1015
1077
|
const timeoutMs = opts?.timeoutMs ?? 6e4;
|
|
1016
1078
|
const timeoutController = new AbortController();
|
|
1017
1079
|
let timedOut = false;
|
|
@@ -1116,12 +1178,11 @@ var Seclai = class {
|
|
|
1116
1178
|
async *runStreamingAgent(agentId, body, opts) {
|
|
1117
1179
|
const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
|
|
1118
1180
|
const authHdrs = await this.authHeaders();
|
|
1119
|
-
const headers =
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
accept: "text/event-stream",
|
|
1123
|
-
|
|
1124
|
-
};
|
|
1181
|
+
const headers = this.requestHeaders([
|
|
1182
|
+
this.defaultHeaders,
|
|
1183
|
+
authHdrs,
|
|
1184
|
+
{ accept: "text/event-stream", "content-type": "application/json" }
|
|
1185
|
+
]);
|
|
1125
1186
|
const timeoutMs = opts?.timeoutMs ?? 6e4;
|
|
1126
1187
|
const timeoutController = new AbortController();
|
|
1127
1188
|
let timedOut = false;
|
|
@@ -1252,10 +1313,13 @@ var Seclai = class {
|
|
|
1252
1313
|
* @returns Paginated list of evaluation results.
|
|
1253
1314
|
*/
|
|
1254
1315
|
async listRunEvaluationResults(agentId, runId, opts = {}) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1316
|
+
return keyedList(
|
|
1317
|
+
await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
|
|
1318
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1319
|
+
}),
|
|
1320
|
+
"data",
|
|
1321
|
+
PAGE_COUNTERS
|
|
1322
|
+
);
|
|
1259
1323
|
}
|
|
1260
1324
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1261
1325
|
// Agent Input Uploads
|
|
@@ -1383,20 +1447,21 @@ var Seclai = class {
|
|
|
1383
1447
|
/**
|
|
1384
1448
|
* List evaluation criteria for an agent, with pagination metadata.
|
|
1385
1449
|
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
* when the endpoint answers with a bare array.
|
|
1450
|
+
* The endpoint answers with a bare array by default and with `{data,
|
|
1451
|
+
* pagination}` once `apiVersion` is 2026-07-27 or later; `pagination` is
|
|
1452
|
+
* absent on the bare array.
|
|
1390
1453
|
*
|
|
1391
1454
|
* @param agentId - Agent identifier.
|
|
1392
1455
|
* @param opts - Pagination options.
|
|
1393
1456
|
* @returns The criteria under `data`, plus the page metadata when present.
|
|
1394
1457
|
*/
|
|
1395
1458
|
async listEvaluationCriteriaPage(agentId, opts = {}) {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1459
|
+
return keyedList(
|
|
1460
|
+
await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
|
|
1461
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1462
|
+
}),
|
|
1463
|
+
"data"
|
|
1464
|
+
);
|
|
1400
1465
|
}
|
|
1401
1466
|
/**
|
|
1402
1467
|
* Create evaluation criteria for an agent.
|
|
@@ -1451,9 +1516,13 @@ var Seclai = class {
|
|
|
1451
1516
|
* @param opts - Pagination options.
|
|
1452
1517
|
*/
|
|
1453
1518
|
async listEvaluationResults(criteriaId, opts = {}) {
|
|
1454
|
-
return
|
|
1455
|
-
|
|
1456
|
-
|
|
1519
|
+
return keyedList(
|
|
1520
|
+
await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/results`, {
|
|
1521
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1522
|
+
}),
|
|
1523
|
+
"data",
|
|
1524
|
+
PAGE_COUNTERS
|
|
1525
|
+
);
|
|
1457
1526
|
}
|
|
1458
1527
|
/**
|
|
1459
1528
|
* Create a manual evaluation result for a criteria.
|
|
@@ -1472,9 +1541,13 @@ var Seclai = class {
|
|
|
1472
1541
|
* @param opts - Pagination options.
|
|
1473
1542
|
*/
|
|
1474
1543
|
async listCompatibleRuns(criteriaId, opts = {}) {
|
|
1475
|
-
return
|
|
1476
|
-
|
|
1477
|
-
|
|
1544
|
+
return keyedList(
|
|
1545
|
+
await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/compatible-runs`, {
|
|
1546
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1547
|
+
}),
|
|
1548
|
+
"data",
|
|
1549
|
+
PAGE_COUNTERS
|
|
1550
|
+
);
|
|
1478
1551
|
}
|
|
1479
1552
|
/**
|
|
1480
1553
|
* Test a draft evaluation criteria without persisting it.
|
|
@@ -1493,9 +1566,13 @@ var Seclai = class {
|
|
|
1493
1566
|
* @param opts - Pagination options.
|
|
1494
1567
|
*/
|
|
1495
1568
|
async listAgentEvaluationResults(agentId, opts = {}) {
|
|
1496
|
-
return
|
|
1497
|
-
|
|
1498
|
-
|
|
1569
|
+
return keyedList(
|
|
1570
|
+
await this.request("GET", `/agents/${agentId}/evaluation-results`, {
|
|
1571
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1572
|
+
}),
|
|
1573
|
+
"data",
|
|
1574
|
+
PAGE_COUNTERS
|
|
1575
|
+
);
|
|
1499
1576
|
}
|
|
1500
1577
|
/**
|
|
1501
1578
|
* List evaluation run summaries for an agent.
|
|
@@ -1504,9 +1581,13 @@ var Seclai = class {
|
|
|
1504
1581
|
* @param opts - Pagination options.
|
|
1505
1582
|
*/
|
|
1506
1583
|
async listEvaluationRuns(agentId, opts = {}) {
|
|
1507
|
-
return
|
|
1508
|
-
|
|
1509
|
-
|
|
1584
|
+
return keyedList(
|
|
1585
|
+
await this.request("GET", `/agents/${agentId}/evaluation-runs`, {
|
|
1586
|
+
query: { page: opts.page, limit: opts.limit }
|
|
1587
|
+
}),
|
|
1588
|
+
"data",
|
|
1589
|
+
PAGE_COUNTERS
|
|
1590
|
+
);
|
|
1510
1591
|
}
|
|
1511
1592
|
/**
|
|
1512
1593
|
* Get a summary of non-manual evaluations across an agent's runs.
|
|
@@ -1552,9 +1633,13 @@ var Seclai = class {
|
|
|
1552
1633
|
* @returns The page of opt-outs plus the total count.
|
|
1553
1634
|
*/
|
|
1554
1635
|
async listAgentEmailOptOuts(opts = {}) {
|
|
1555
|
-
return
|
|
1556
|
-
|
|
1557
|
-
|
|
1636
|
+
return keyedList(
|
|
1637
|
+
await this.request("GET", "/agents/agent-email-optouts", {
|
|
1638
|
+
query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
|
|
1639
|
+
}),
|
|
1640
|
+
"items",
|
|
1641
|
+
["total"]
|
|
1642
|
+
);
|
|
1558
1643
|
}
|
|
1559
1644
|
/**
|
|
1560
1645
|
* Revoke an opt-out, opting the recipient back in to agent emails.
|
|
@@ -1573,9 +1658,13 @@ var Seclai = class {
|
|
|
1573
1658
|
* @param opts.offset - Rows to skip (default 0).
|
|
1574
1659
|
*/
|
|
1575
1660
|
async listBlockedEmailSenders(opts = {}) {
|
|
1576
|
-
return
|
|
1577
|
-
|
|
1578
|
-
|
|
1661
|
+
return keyedList(
|
|
1662
|
+
await this.request("GET", "/agents/blocked-email-senders", {
|
|
1663
|
+
query: { limit: opts.limit, offset: opts.offset }
|
|
1664
|
+
}),
|
|
1665
|
+
"items",
|
|
1666
|
+
["total"]
|
|
1667
|
+
);
|
|
1579
1668
|
}
|
|
1580
1669
|
/**
|
|
1581
1670
|
* Add a sender address or a whole domain to the account blocklist.
|
|
@@ -1610,9 +1699,11 @@ var Seclai = class {
|
|
|
1610
1699
|
* @returns The updated blocked-sender list.
|
|
1611
1700
|
*/
|
|
1612
1701
|
async setAutoBlockMode(body) {
|
|
1613
|
-
return
|
|
1614
|
-
json: body
|
|
1615
|
-
|
|
1702
|
+
return keyedList(
|
|
1703
|
+
await this.request("PUT", "/agents/blocked-email-senders/mode", { json: body }),
|
|
1704
|
+
"items",
|
|
1705
|
+
["total"]
|
|
1706
|
+
);
|
|
1616
1707
|
}
|
|
1617
1708
|
/**
|
|
1618
1709
|
* List recent inbound emails that were quietly discarded before running an
|
|
@@ -1623,9 +1714,11 @@ var Seclai = class {
|
|
|
1623
1714
|
* @param opts.limit - Maximum results (1-200, default 50).
|
|
1624
1715
|
*/
|
|
1625
1716
|
async listInboundEmailRejections(opts = {}) {
|
|
1626
|
-
return
|
|
1627
|
-
|
|
1628
|
-
|
|
1717
|
+
return listItems(
|
|
1718
|
+
await this.request("GET", "/agents/inbound-email-rejections", {
|
|
1719
|
+
query: { agent_id: opts.agentId, limit: opts.limit }
|
|
1720
|
+
})
|
|
1721
|
+
);
|
|
1629
1722
|
}
|
|
1630
1723
|
/**
|
|
1631
1724
|
* Get the account's inbound-email overload status — whether the circuit
|
|
@@ -1667,9 +1760,13 @@ var Seclai = class {
|
|
|
1667
1760
|
* @returns Paginated list of knowledge bases.
|
|
1668
1761
|
*/
|
|
1669
1762
|
async listKnowledgeBases(opts = {}) {
|
|
1670
|
-
return
|
|
1671
|
-
|
|
1672
|
-
|
|
1763
|
+
return keyedList(
|
|
1764
|
+
await this.request("GET", "/knowledge_bases", {
|
|
1765
|
+
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
|
|
1766
|
+
}),
|
|
1767
|
+
"knowledge_bases",
|
|
1768
|
+
PAGE_COUNTERS
|
|
1769
|
+
);
|
|
1673
1770
|
}
|
|
1674
1771
|
/**
|
|
1675
1772
|
* Create a new knowledge base.
|
|
@@ -1717,9 +1814,13 @@ var Seclai = class {
|
|
|
1717
1814
|
* @returns Paginated list of memory banks.
|
|
1718
1815
|
*/
|
|
1719
1816
|
async listMemoryBanks(opts = {}) {
|
|
1720
|
-
return
|
|
1721
|
-
|
|
1722
|
-
|
|
1817
|
+
return keyedList(
|
|
1818
|
+
await this.request("GET", "/memory_banks", {
|
|
1819
|
+
query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
|
|
1820
|
+
}),
|
|
1821
|
+
"memory_banks",
|
|
1822
|
+
PAGE_COUNTERS
|
|
1823
|
+
);
|
|
1723
1824
|
}
|
|
1724
1825
|
/**
|
|
1725
1826
|
* Create a new memory bank.
|
|
@@ -1766,7 +1867,7 @@ var Seclai = class {
|
|
|
1766
1867
|
* @param memoryBankId - Memory bank identifier.
|
|
1767
1868
|
*/
|
|
1768
1869
|
async getAgentsUsingMemoryBank(memoryBankId) {
|
|
1769
|
-
return await this.request("GET", `/memory_banks/${memoryBankId}/agents`);
|
|
1870
|
+
return listItems(await this.request("GET", `/memory_banks/${memoryBankId}/agents`));
|
|
1770
1871
|
}
|
|
1771
1872
|
/**
|
|
1772
1873
|
* Get stats for a memory bank.
|
|
@@ -1813,7 +1914,7 @@ var Seclai = class {
|
|
|
1813
1914
|
* List available memory bank templates.
|
|
1814
1915
|
*/
|
|
1815
1916
|
async listMemoryBankTemplates() {
|
|
1816
|
-
return await this.request("GET", "/memory_banks/templates");
|
|
1917
|
+
return listItems(await this.request("GET", "/memory_banks/templates"));
|
|
1817
1918
|
}
|
|
1818
1919
|
// ─── Memory Bank AI Assistant ──────────────────────────────────────────────
|
|
1819
1920
|
/**
|
|
@@ -1919,6 +2020,55 @@ var Seclai = class {
|
|
|
1919
2020
|
async uploadInlineTextToSource(sourceId, body) {
|
|
1920
2021
|
return await this.request("POST", `/sources/${sourceId}`, { json: body });
|
|
1921
2022
|
}
|
|
2023
|
+
/**
|
|
2024
|
+
* List a source's content items and their indexing status.
|
|
2025
|
+
*
|
|
2026
|
+
* @param sourceId - Source connection identifier.
|
|
2027
|
+
* @param opts - Pagination, sorting, and filters. Pass the `content_version_id`
|
|
2028
|
+
* values the upload methods return as `contentVersionIds` to poll a batch of
|
|
2029
|
+
* uploads in one request — about 100 at a time, since the ids travel in the
|
|
2030
|
+
* query string and a URL over 8,192 bytes is rejected with a 414. An empty
|
|
2031
|
+
* `contentVersionIds` matches nothing, so it returns an empty page without
|
|
2032
|
+
* sending a request.
|
|
2033
|
+
* @returns The items under `data` with `pagination`, on every API version.
|
|
2034
|
+
*/
|
|
2035
|
+
async listSourceContents(sourceId, opts = {}) {
|
|
2036
|
+
if (opts.contentVersionIds?.length === 0) {
|
|
2037
|
+
return {
|
|
2038
|
+
data: [],
|
|
2039
|
+
pagination: {
|
|
2040
|
+
page: opts.page ?? 1,
|
|
2041
|
+
limit: opts.limit ?? 20,
|
|
2042
|
+
total: 0,
|
|
2043
|
+
pages: 0,
|
|
2044
|
+
has_next: false,
|
|
2045
|
+
has_prev: false
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
return await this.request("GET", `/sources/${sourceId}/contents`, {
|
|
2050
|
+
query: {
|
|
2051
|
+
page: opts.page,
|
|
2052
|
+
limit: opts.limit,
|
|
2053
|
+
sort: opts.sort,
|
|
2054
|
+
order: opts.order,
|
|
2055
|
+
status: opts.status,
|
|
2056
|
+
content_version_id: opts.contentVersionIds
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Get one content item's indexing status.
|
|
2062
|
+
*
|
|
2063
|
+
* @param sourceId - Source connection identifier.
|
|
2064
|
+
* @param contentVersionId - The `content_version_id` an upload returned.
|
|
2065
|
+
*/
|
|
2066
|
+
async getSourceContentStatus(sourceId, contentVersionId) {
|
|
2067
|
+
return await this.request(
|
|
2068
|
+
"GET",
|
|
2069
|
+
`/sources/${sourceId}/contents/${contentVersionId}`
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
1922
2072
|
// ─── Source Exports ────────────────────────────────────────────────────────
|
|
1923
2073
|
/**
|
|
1924
2074
|
* List exports for a source.
|
|
@@ -2194,7 +2344,9 @@ var Seclai = class {
|
|
|
2194
2344
|
* @returns List of conversations.
|
|
2195
2345
|
*/
|
|
2196
2346
|
async listSolutionConversations(solutionId) {
|
|
2197
|
-
return
|
|
2347
|
+
return listItems(
|
|
2348
|
+
await this.request("GET", `/solutions/${solutionId}/conversations`)
|
|
2349
|
+
);
|
|
2198
2350
|
}
|
|
2199
2351
|
/**
|
|
2200
2352
|
* Add a conversation turn to a solution.
|
|
@@ -2283,7 +2435,9 @@ var Seclai = class {
|
|
|
2283
2435
|
* List governance AI conversations.
|
|
2284
2436
|
*/
|
|
2285
2437
|
async listGovernanceAiConversations() {
|
|
2286
|
-
return
|
|
2438
|
+
return listItems(
|
|
2439
|
+
await this.request("GET", "/governance/ai-assistant/conversations")
|
|
2440
|
+
);
|
|
2287
2441
|
}
|
|
2288
2442
|
/**
|
|
2289
2443
|
* Accept a governance AI plan.
|
|
@@ -2367,15 +2521,15 @@ var Seclai = class {
|
|
|
2367
2521
|
* @returns Paginated list of alert configs.
|
|
2368
2522
|
*/
|
|
2369
2523
|
/**
|
|
2370
|
-
*
|
|
2371
|
-
*
|
|
2372
|
-
* returns the canonical `{data, pagination}` envelope instead, so the
|
|
2373
|
-
* top-level key changes.
|
|
2524
|
+
* `configs` and `total` are populated on every API version; `data` and
|
|
2525
|
+
* `pagination` are also present once `apiVersion` is 2026-07-27 or later.
|
|
2374
2526
|
*/
|
|
2375
2527
|
async listAlertConfigs(opts = {}) {
|
|
2376
|
-
return
|
|
2377
|
-
query: { page: opts.page, limit: opts.limit }
|
|
2378
|
-
|
|
2528
|
+
return keyedList(
|
|
2529
|
+
await this.request("GET", "/alerts/configs", { query: { page: opts.page, limit: opts.limit } }),
|
|
2530
|
+
"configs",
|
|
2531
|
+
["total"]
|
|
2532
|
+
);
|
|
2379
2533
|
}
|
|
2380
2534
|
/**
|
|
2381
2535
|
* Create an alert configuration.
|
|
@@ -2418,7 +2572,11 @@ var Seclai = class {
|
|
|
2418
2572
|
* List organization alert preferences.
|
|
2419
2573
|
*/
|
|
2420
2574
|
async listOrganizationAlertPreferences() {
|
|
2421
|
-
return
|
|
2575
|
+
return keyedList(
|
|
2576
|
+
await this.request("GET", "/alerts/organization-preferences/list"),
|
|
2577
|
+
"preferences",
|
|
2578
|
+
["total"]
|
|
2579
|
+
);
|
|
2422
2580
|
}
|
|
2423
2581
|
/**
|
|
2424
2582
|
* Update an organization alert preference.
|
|
@@ -2445,9 +2603,11 @@ var Seclai = class {
|
|
|
2445
2603
|
async listModelAlerts(opts = {}) {
|
|
2446
2604
|
const limit = opts.limit ?? 50;
|
|
2447
2605
|
const offset = opts.page && opts.page > 1 ? (opts.page - 1) * limit : void 0;
|
|
2448
|
-
return
|
|
2449
|
-
query: { offset, limit: opts.limit }
|
|
2450
|
-
|
|
2606
|
+
return keyedList(
|
|
2607
|
+
await this.request("GET", "/models/alerts", { query: { offset, limit: opts.limit } }),
|
|
2608
|
+
"alerts",
|
|
2609
|
+
["total"]
|
|
2610
|
+
);
|
|
2451
2611
|
}
|
|
2452
2612
|
/**
|
|
2453
2613
|
* Mark all model alerts as read.
|
|
@@ -2483,7 +2643,7 @@ var Seclai = class {
|
|
|
2483
2643
|
* @param opts - Optional filters.
|
|
2484
2644
|
*/
|
|
2485
2645
|
async listModels(opts = {}) {
|
|
2486
|
-
return await this.request("GET", "/models", {
|
|
2646
|
+
return listItems(await this.request("GET", "/models", {
|
|
2487
2647
|
query: {
|
|
2488
2648
|
provider: opts.provider,
|
|
2489
2649
|
supports_tool_use: opts.supportsToolUse,
|
|
@@ -2491,7 +2651,7 @@ var Seclai = class {
|
|
|
2491
2651
|
supports_input_media: opts.supportsInputMedia,
|
|
2492
2652
|
supports_output_media: opts.supportsOutputMedia
|
|
2493
2653
|
}
|
|
2494
|
-
});
|
|
2654
|
+
}));
|
|
2495
2655
|
}
|
|
2496
2656
|
/**
|
|
2497
2657
|
* Get full details for a specific model.
|
|
@@ -2513,7 +2673,33 @@ var Seclai = class {
|
|
|
2513
2673
|
* Global routing/pricing (the same for every account); read-only.
|
|
2514
2674
|
*/
|
|
2515
2675
|
async getGenerationTiers() {
|
|
2516
|
-
return await this.request("GET", "/models/generation-tiers");
|
|
2676
|
+
return keyedList(await this.request("GET", "/models/generation-tiers"), "tiers");
|
|
2677
|
+
}
|
|
2678
|
+
/**
|
|
2679
|
+
* List the embedding models a source can index with, and their pricing.
|
|
2680
|
+
*
|
|
2681
|
+
* The endpoint lists the embedders under `models` by default and under `data`
|
|
2682
|
+
* once the caller opts in with `apiVersion` 2026-07-27 or later; `models` is
|
|
2683
|
+
* populated on either, with the defaults and pricing beside it.
|
|
2684
|
+
*
|
|
2685
|
+
* @param opts.supportsInputMedia - Keep only embedders that can index this
|
|
2686
|
+
* input modality — a coarse kind (text, image, video, audio) or a full MIME.
|
|
2687
|
+
*/
|
|
2688
|
+
async listEmbeddingModels(opts = {}) {
|
|
2689
|
+
return keyedList(
|
|
2690
|
+
await this.request("GET", "/models/embedders", {
|
|
2691
|
+
query: { supports_input_media: opts.supportsInputMedia }
|
|
2692
|
+
}),
|
|
2693
|
+
"models"
|
|
2694
|
+
);
|
|
2695
|
+
}
|
|
2696
|
+
/**
|
|
2697
|
+
* List the reranker models a knowledge base can use, and their pricing.
|
|
2698
|
+
*
|
|
2699
|
+
* `models` is populated on either wire shape, as for {@link Seclai.listEmbeddingModels}.
|
|
2700
|
+
*/
|
|
2701
|
+
async listRerankerModels() {
|
|
2702
|
+
return keyedList(await this.request("GET", "/models/rerankers"), "models");
|
|
2517
2703
|
}
|
|
2518
2704
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2519
2705
|
// Model Playground Experiments
|
|
@@ -2524,9 +2710,13 @@ var Seclai = class {
|
|
|
2524
2710
|
* @param opts - Optional filters and pagination.
|
|
2525
2711
|
*/
|
|
2526
2712
|
async listExperiments(opts = {}) {
|
|
2527
|
-
return
|
|
2528
|
-
|
|
2529
|
-
|
|
2713
|
+
return keyedList(
|
|
2714
|
+
await this.request("GET", "/models/playground/experiments", {
|
|
2715
|
+
query: { days: opts.days, start_date: opts.startDate, end_date: opts.endDate, limit: opts.limit, offset: opts.offset }
|
|
2716
|
+
}),
|
|
2717
|
+
"experiments",
|
|
2718
|
+
["total"]
|
|
2719
|
+
);
|
|
2530
2720
|
}
|
|
2531
2721
|
/**
|
|
2532
2722
|
* Create a model playground experiment.
|
|
@@ -2564,6 +2754,88 @@ var Seclai = class {
|
|
|
2564
2754
|
await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
|
|
2565
2755
|
}
|
|
2566
2756
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2757
|
+
// Cloud Drives
|
|
2758
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2759
|
+
/**
|
|
2760
|
+
* List the cloud-drive providers this deployment has configured.
|
|
2761
|
+
*
|
|
2762
|
+
* @returns The providers, read from either wire shape.
|
|
2763
|
+
*/
|
|
2764
|
+
async listCloudDriveProviders() {
|
|
2765
|
+
return listItems(await this.request("GET", "/cloud-drives/providers"));
|
|
2766
|
+
}
|
|
2767
|
+
/**
|
|
2768
|
+
* List the account's cloud-drive connections.
|
|
2769
|
+
*
|
|
2770
|
+
* @returns The connections, read from either wire shape.
|
|
2771
|
+
*/
|
|
2772
|
+
async listCloudDrives() {
|
|
2773
|
+
return listItems(await this.request("GET", "/cloud-drives"));
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* Get a cloud-drive connection.
|
|
2777
|
+
*
|
|
2778
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2779
|
+
*/
|
|
2780
|
+
async getCloudDrive(connectionId) {
|
|
2781
|
+
return await this.request("GET", `/cloud-drives/${connectionId}`);
|
|
2782
|
+
}
|
|
2783
|
+
/**
|
|
2784
|
+
* Update a cloud-drive connection.
|
|
2785
|
+
*
|
|
2786
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2787
|
+
* @param body - Fields to change — `name` and/or `folder_path`.
|
|
2788
|
+
* @returns The updated connection.
|
|
2789
|
+
*/
|
|
2790
|
+
async updateCloudDrive(connectionId, body) {
|
|
2791
|
+
return await this.request("PATCH", `/cloud-drives/${connectionId}`, { json: body });
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Disconnect a cloud-drive connection, keeping the connection itself.
|
|
2795
|
+
*
|
|
2796
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2797
|
+
* @returns The connection in its disconnected state.
|
|
2798
|
+
*/
|
|
2799
|
+
async disconnectCloudDrive(connectionId) {
|
|
2800
|
+
return await this.request("POST", `/cloud-drives/${connectionId}/disconnect`);
|
|
2801
|
+
}
|
|
2802
|
+
/**
|
|
2803
|
+
* Delete a cloud-drive connection.
|
|
2804
|
+
*
|
|
2805
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2806
|
+
*/
|
|
2807
|
+
async deleteCloudDrive(connectionId) {
|
|
2808
|
+
await this.request("DELETE", `/cloud-drives/${connectionId}`);
|
|
2809
|
+
}
|
|
2810
|
+
/**
|
|
2811
|
+
* List the agents that use a cloud-drive connection.
|
|
2812
|
+
*
|
|
2813
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2814
|
+
* @returns The agents, read from either wire shape.
|
|
2815
|
+
*/
|
|
2816
|
+
async getAgentsUsingCloudDrive(connectionId) {
|
|
2817
|
+
return listItems(
|
|
2818
|
+
await this.request("GET", `/cloud-drives/${connectionId}/agents`)
|
|
2819
|
+
);
|
|
2820
|
+
}
|
|
2821
|
+
/**
|
|
2822
|
+
* List the files a cloud-drive connection skipped, newest first.
|
|
2823
|
+
*
|
|
2824
|
+
* A skipped file fires no trigger, so this is where to look when an agent
|
|
2825
|
+
* did not run for a file.
|
|
2826
|
+
*
|
|
2827
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2828
|
+
* @param opts.limit - Maximum number of rejections (1-200, default 50).
|
|
2829
|
+
* @returns The rejections with their reasons, read from either wire shape.
|
|
2830
|
+
*/
|
|
2831
|
+
async listCloudDriveRejections(connectionId, opts = {}) {
|
|
2832
|
+
return listItems(
|
|
2833
|
+
await this.request("GET", `/cloud-drives/${connectionId}/rejections`, {
|
|
2834
|
+
query: { limit: opts.limit }
|
|
2835
|
+
})
|
|
2836
|
+
);
|
|
2837
|
+
}
|
|
2838
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2567
2839
|
// Search
|
|
2568
2840
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2569
2841
|
/**
|
|
@@ -2621,7 +2893,7 @@ var Seclai = class {
|
|
|
2621
2893
|
* Requires a user-bound credential; an account-only API key is refused with 403.
|
|
2622
2894
|
*/
|
|
2623
2895
|
async listEmailDomains() {
|
|
2624
|
-
return await this.request("GET", "/email-domains");
|
|
2896
|
+
return keyedList(await this.request("GET", "/email-domains"), "domains");
|
|
2625
2897
|
}
|
|
2626
2898
|
/**
|
|
2627
2899
|
* Add and provision a new agent-email domain.
|
|
@@ -2802,18 +3074,20 @@ var Seclai = class {
|
|
|
2802
3074
|
/**
|
|
2803
3075
|
* Auto-paginate through a list endpoint.
|
|
2804
3076
|
*
|
|
2805
|
-
* Yields individual items from each page,
|
|
2806
|
-
*
|
|
3077
|
+
* Yields individual items from each page, fetching the next page until the
|
|
3078
|
+
* response reports there is none. A fetcher that answers with a bare array has
|
|
3079
|
+
* no further pages, so its items are yielded once.
|
|
2807
3080
|
*
|
|
2808
3081
|
* @param fetchPage - A function that fetches a single page given `{ page, limit }`.
|
|
2809
3082
|
* @param opts - Page size (default: 50).
|
|
3083
|
+
* @throws {@link SeclaiError} When a page carries its items under neither `data` nor `items`.
|
|
2810
3084
|
*
|
|
2811
3085
|
* @example
|
|
2812
3086
|
* ```ts
|
|
2813
3087
|
* for await (const agent of client.paginate(
|
|
2814
3088
|
* (opts) => client.listAgents(opts),
|
|
2815
3089
|
* )) {
|
|
2816
|
-
* console.log(agent);
|
|
3090
|
+
* console.log(agent.name);
|
|
2817
3091
|
* }
|
|
2818
3092
|
* ```
|
|
2819
3093
|
*/
|
|
@@ -2822,11 +3096,29 @@ var Seclai = class {
|
|
|
2822
3096
|
let page = 1;
|
|
2823
3097
|
while (true) {
|
|
2824
3098
|
const result = await fetchPage({ page, limit });
|
|
2825
|
-
|
|
2826
|
-
yield
|
|
3099
|
+
if (Array.isArray(result)) {
|
|
3100
|
+
yield* result;
|
|
3101
|
+
return;
|
|
3102
|
+
}
|
|
3103
|
+
const body = result ?? {};
|
|
3104
|
+
const items = "data" in body ? body.data ?? [] : body.items;
|
|
3105
|
+
if (!Array.isArray(items)) {
|
|
3106
|
+
throw new SeclaiError(
|
|
3107
|
+
"paginate() could not find the page's items: expected an array, or an object with a `data` or `items` array."
|
|
3108
|
+
);
|
|
2827
3109
|
}
|
|
2828
|
-
|
|
2829
|
-
|
|
3110
|
+
yield* items;
|
|
3111
|
+
const pagination = body.pagination;
|
|
3112
|
+
if (items.length === 0) return;
|
|
3113
|
+
if (!pagination) {
|
|
3114
|
+
if (typeof body.total !== "number") return;
|
|
3115
|
+
const pageSize = typeof body.limit === "number" && body.limit > 0 ? body.limit : limit;
|
|
3116
|
+
if (page * pageSize >= body.total) return;
|
|
3117
|
+
} else if (typeof pagination.has_next === "boolean") {
|
|
3118
|
+
if (!pagination.has_next) return;
|
|
3119
|
+
} else {
|
|
3120
|
+
const pages = pagination.pages ?? pagination.total_pages;
|
|
3121
|
+
if (items.length < limit || pages === void 0 || page >= pages) return;
|
|
2830
3122
|
}
|
|
2831
3123
|
page++;
|
|
2832
3124
|
}
|