@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/dist/index.cjs CHANGED
@@ -53,10 +53,15 @@ module.exports = __toCommonJS(index_exports);
53
53
  var SeclaiApiVersion = {
54
54
  V2026_07_01: "2026-07-01",
55
55
  V2026_07_27: "2026-07-27",
56
+ V2026_08_03: "2026-08-03",
57
+ V2026_08_21: "2026-08-21",
58
+ V2026_09_28: "2026-09-28",
59
+ V2026_09_30: "2026-09-30",
60
+ V2026_10_03: "2026-10-03",
56
61
  /** Baseline applied to an unpinned, header-less caller. */
57
62
  Default: "2026-07-01",
58
63
  /** Newest version known to this SDK release. May lag the server. */
59
- Latest: "2026-07-27"
64
+ Latest: "2026-10-03"
60
65
  };
61
66
  var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
62
67
 
@@ -407,11 +412,58 @@ function buildURL(baseUrl, path, query) {
407
412
  if (query) {
408
413
  for (const [key, value] of Object.entries(query)) {
409
414
  if (value === void 0 || value === null) continue;
415
+ if (Array.isArray(value)) {
416
+ for (const item of value) url.searchParams.append(key, String(item));
417
+ continue;
418
+ }
410
419
  url.searchParams.set(key, String(value));
411
420
  }
412
421
  }
413
422
  return url;
414
423
  }
424
+ function listItems(res) {
425
+ if (Array.isArray(res)) return res;
426
+ if (res !== null && typeof res === "object" && "data" in res) {
427
+ const data = res.data;
428
+ if (Array.isArray(data)) return data;
429
+ if (data === null) return [];
430
+ }
431
+ throw notAList();
432
+ }
433
+ function notAList() {
434
+ return new SeclaiError(
435
+ "Expected a list response: an array, or an object carrying the items under `data` or the endpoint's own key."
436
+ );
437
+ }
438
+ function keyedList(res, key, flat = []) {
439
+ if (Array.isArray(res)) return { [key]: res };
440
+ if (res === null || typeof res !== "object") throw notAList();
441
+ const body = { ...res };
442
+ if (Array.isArray(body.data)) body[key] = body.data;
443
+ else if ("data" in body && body.data === null) body[key] = [];
444
+ else if (!Array.isArray(body[key])) throw notAList();
445
+ const pagination = body.pagination;
446
+ for (const field of flat) {
447
+ if (body[field] === void 0 && pagination?.[field] !== void 0) body[field] = pagination[field];
448
+ }
449
+ return body;
450
+ }
451
+ var PAGE_COUNTERS = ["total", "page", "limit"];
452
+ function mergeHeaders(...layers) {
453
+ const byName = /* @__PURE__ */ new Map();
454
+ for (const layer of layers) {
455
+ for (const [name, value] of Object.entries(layer ?? {})) {
456
+ if (value === void 0 || value === null) continue;
457
+ const lower = name.toLowerCase();
458
+ byName.delete(lower);
459
+ byName.set(lower, [name, value]);
460
+ }
461
+ }
462
+ return Object.fromEntries(byName.values());
463
+ }
464
+ function headerKey(headers, name) {
465
+ return Object.keys(headers ?? {}).filter((key) => key.toLowerCase() === name).pop();
466
+ }
415
467
  async function safeText(response) {
416
468
  try {
417
469
  return await response.clone().text();
@@ -527,6 +579,7 @@ function inferMimeType(fileName) {
527
579
  var Seclai = class {
528
580
  baseUrl;
529
581
  defaultHeaders;
582
+ allowUnknownApiVersion;
530
583
  fetcher;
531
584
  _authState = null;
532
585
  _authInitPromise = null;
@@ -557,22 +610,13 @@ var Seclai = class {
557
610
  );
558
611
  }
559
612
  this.baseUrl = opts.baseUrl ?? getEnv2("SECLAI_API_URL") ?? SECLAI_API_URL;
560
- const merged = opts.apiVersion ? { "Seclai-Version": opts.apiVersion } : {};
561
- let versionKey = opts.apiVersion ? "Seclai-Version" : void 0;
562
- for (const [key, value] of Object.entries(opts.defaultHeaders ?? {})) {
563
- for (const existing of Object.keys(merged)) {
564
- if (existing.toLowerCase() === key.toLowerCase()) delete merged[existing];
565
- }
566
- merged[key] = value;
567
- if (key.toLowerCase() === "seclai-version") versionKey = key;
568
- }
569
- const effectiveVersion = versionKey ? merged[versionKey] : void 0;
570
- if (effectiveVersion && !opts.allowUnknownApiVersion && !KNOWN_API_VERSIONS.includes(effectiveVersion)) {
571
- const via = versionKey === "Seclai-Version" && merged[versionKey] === opts.apiVersion ? "apiVersion" : `defaultHeaders['${versionKey}']`;
572
- throw new SeclaiConfigurationError(
573
- `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.`
574
- );
575
- }
613
+ this.allowUnknownApiVersion = opts.allowUnknownApiVersion ?? false;
614
+ const merged = mergeHeaders(
615
+ opts.apiVersion ? { "Seclai-Version": opts.apiVersion } : void 0,
616
+ opts.defaultHeaders
617
+ );
618
+ const defaultKey = headerKey(opts.defaultHeaders, "seclai-version");
619
+ this.assertKnownApiVersion(merged, defaultKey ? `defaultHeaders['${defaultKey}']` : "apiVersion");
576
620
  this.defaultHeaders = merged;
577
621
  this.fetcher = fetcher;
578
622
  const accessTokenProvider = typeof opts.accessToken === "function" ? opts.accessToken : void 0;
@@ -611,6 +655,26 @@ var Seclai = class {
611
655
  }
612
656
  return this._authState;
613
657
  }
658
+ /** Throw unless the `Seclai-Version` in `headers` is one this release was built against. */
659
+ assertKnownApiVersion(headers, via) {
660
+ const key = headerKey(headers, "seclai-version");
661
+ if (key === void 0 || this.allowUnknownApiVersion) return;
662
+ const version = headers[key] ?? "";
663
+ if (KNOWN_API_VERSIONS.includes(version)) return;
664
+ throw new SeclaiConfigurationError(
665
+ `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.`
666
+ );
667
+ }
668
+ /**
669
+ * The headers one request sends: `layers` merged in order, later winning,
670
+ * with the resulting `Seclai-Version` checked against the known versions.
671
+ */
672
+ requestHeaders(layers, perRequest) {
673
+ const headers = mergeHeaders(...layers);
674
+ const requestKey = headerKey(perRequest, "seclai-version");
675
+ this.assertKnownApiVersion(headers, requestKey ? `headers['${requestKey}']` : "defaultHeaders");
676
+ return headers;
677
+ }
614
678
  /** Resolve auth headers for the current request. */
615
679
  async authHeaders() {
616
680
  const state = await this.ensureAuth();
@@ -634,16 +698,17 @@ var Seclai = class {
634
698
  async request(method, path, opts) {
635
699
  const url = buildURL(this.baseUrl, path, opts?.query);
636
700
  const authHeaders = await this.authHeaders();
637
- const headers = {
638
- ...this.defaultHeaders,
639
- ...opts?.headers ?? {},
640
- ...authHeaders
641
- };
642
701
  let body;
643
- if (opts?.json !== void 0) {
644
- headers["content-type"] = headers["content-type"] ?? "application/json";
645
- body = JSON.stringify(opts.json);
646
- }
702
+ if (opts?.json !== void 0) body = JSON.stringify(opts.json);
703
+ const headers = this.requestHeaders(
704
+ [
705
+ body === void 0 ? void 0 : { "content-type": "application/json" },
706
+ this.defaultHeaders,
707
+ opts?.headers,
708
+ authHeaders
709
+ ],
710
+ opts?.headers
711
+ );
647
712
  const init = { method, headers };
648
713
  if (body !== void 0) {
649
714
  init.body = body;
@@ -695,16 +760,17 @@ var Seclai = class {
695
760
  async requestRaw(method, path, opts) {
696
761
  const url = buildURL(this.baseUrl, path, opts?.query);
697
762
  const authHeaders = await this.authHeaders();
698
- const headers = {
699
- ...this.defaultHeaders,
700
- ...opts?.headers ?? {},
701
- ...authHeaders
702
- };
703
763
  let body;
704
- if (opts?.json !== void 0) {
705
- headers["content-type"] = headers["content-type"] ?? "application/json";
706
- body = JSON.stringify(opts.json);
707
- }
764
+ if (opts?.json !== void 0) body = JSON.stringify(opts.json);
765
+ const headers = this.requestHeaders(
766
+ [
767
+ body === void 0 ? void 0 : { "content-type": "application/json" },
768
+ this.defaultHeaders,
769
+ opts?.headers,
770
+ authHeaders
771
+ ],
772
+ opts?.headers
773
+ );
708
774
  const init = { method, headers };
709
775
  if (body !== void 0) init.body = body;
710
776
  if (opts?.signal) init.signal = opts.signal;
@@ -736,12 +802,9 @@ var Seclai = class {
736
802
  async uploadFile(path, opts) {
737
803
  const url = buildURL(this.baseUrl, path);
738
804
  const authHeaders = await this.authHeaders();
739
- const headers = {
740
- ...this.defaultHeaders,
741
- ...authHeaders
742
- };
743
- delete headers["content-type"];
744
- delete headers["Content-Type"];
805
+ const headers = this.requestHeaders([this.defaultHeaders, authHeaders]);
806
+ const contentType = headerKey(headers, "content-type");
807
+ if (contentType !== void 0) delete headers[contentType];
745
808
  const form = new FormData();
746
809
  const mimeType = opts.mimeType ?? inferMimeType(opts.fileName);
747
810
  const blob = toBlob(opts.file, mimeType);
@@ -908,7 +971,7 @@ var Seclai = class {
908
971
  * @returns The calling agents.
909
972
  */
910
973
  async getAgentCallers(agentId) {
911
- return await this.request("GET", `/agents/${agentId}/callers`);
974
+ return listItems(await this.request("GET", `/agents/${agentId}/callers`));
912
975
  }
913
976
  // ═══════════════════════════════════════════════════════════════════════════
914
977
  // Agent Export / Import
@@ -1057,12 +1120,11 @@ var Seclai = class {
1057
1120
  async runStreamingAgentAndWait(agentId, body, opts) {
1058
1121
  const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
1059
1122
  const authHdrs = await this.authHeaders();
1060
- const headers = {
1061
- ...this.defaultHeaders,
1062
- ...authHdrs,
1063
- accept: "text/event-stream",
1064
- "content-type": "application/json"
1065
- };
1123
+ const headers = this.requestHeaders([
1124
+ this.defaultHeaders,
1125
+ authHdrs,
1126
+ { accept: "text/event-stream", "content-type": "application/json" }
1127
+ ]);
1066
1128
  const timeoutMs = opts?.timeoutMs ?? 6e4;
1067
1129
  const timeoutController = new AbortController();
1068
1130
  let timedOut = false;
@@ -1167,12 +1229,11 @@ var Seclai = class {
1167
1229
  async *runStreamingAgent(agentId, body, opts) {
1168
1230
  const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
1169
1231
  const authHdrs = await this.authHeaders();
1170
- const headers = {
1171
- ...this.defaultHeaders,
1172
- ...authHdrs,
1173
- accept: "text/event-stream",
1174
- "content-type": "application/json"
1175
- };
1232
+ const headers = this.requestHeaders([
1233
+ this.defaultHeaders,
1234
+ authHdrs,
1235
+ { accept: "text/event-stream", "content-type": "application/json" }
1236
+ ]);
1176
1237
  const timeoutMs = opts?.timeoutMs ?? 6e4;
1177
1238
  const timeoutController = new AbortController();
1178
1239
  let timedOut = false;
@@ -1303,10 +1364,13 @@ var Seclai = class {
1303
1364
  * @returns Paginated list of evaluation results.
1304
1365
  */
1305
1366
  async listRunEvaluationResults(agentId, runId, opts = {}) {
1306
- const res = await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
1307
- query: { page: opts.page, limit: opts.limit }
1308
- });
1309
- return Array.isArray(res) ? { data: res } : res;
1367
+ return keyedList(
1368
+ await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
1369
+ query: { page: opts.page, limit: opts.limit }
1370
+ }),
1371
+ "data",
1372
+ PAGE_COUNTERS
1373
+ );
1310
1374
  }
1311
1375
  // ═══════════════════════════════════════════════════════════════════════════
1312
1376
  // Agent Input Uploads
@@ -1434,20 +1498,21 @@ var Seclai = class {
1434
1498
  /**
1435
1499
  * List evaluation criteria for an agent, with pagination metadata.
1436
1500
  *
1437
- * Accepts either wire shape. The endpoint answered with a bare array before
1438
- * 2026-07 and with a paginated envelope after, so a client that decodes only
1439
- * one breaks the day the other ships. `total`, `page` and `limit` are absent
1440
- * when the endpoint answers with a bare array.
1501
+ * The endpoint answers with a bare array by default and with `{data,
1502
+ * pagination}` once `apiVersion` is 2026-07-27 or later; `pagination` is
1503
+ * absent on the bare array.
1441
1504
  *
1442
1505
  * @param agentId - Agent identifier.
1443
1506
  * @param opts - Pagination options.
1444
1507
  * @returns The criteria under `data`, plus the page metadata when present.
1445
1508
  */
1446
1509
  async listEvaluationCriteriaPage(agentId, opts = {}) {
1447
- const res = await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
1448
- query: { page: opts.page, limit: opts.limit }
1449
- });
1450
- return Array.isArray(res) ? { data: res } : res;
1510
+ return keyedList(
1511
+ await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
1512
+ query: { page: opts.page, limit: opts.limit }
1513
+ }),
1514
+ "data"
1515
+ );
1451
1516
  }
1452
1517
  /**
1453
1518
  * Create evaluation criteria for an agent.
@@ -1502,9 +1567,13 @@ var Seclai = class {
1502
1567
  * @param opts - Pagination options.
1503
1568
  */
1504
1569
  async listEvaluationResults(criteriaId, opts = {}) {
1505
- return await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/results`, {
1506
- query: { page: opts.page, limit: opts.limit }
1507
- });
1570
+ return keyedList(
1571
+ await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/results`, {
1572
+ query: { page: opts.page, limit: opts.limit }
1573
+ }),
1574
+ "data",
1575
+ PAGE_COUNTERS
1576
+ );
1508
1577
  }
1509
1578
  /**
1510
1579
  * Create a manual evaluation result for a criteria.
@@ -1523,9 +1592,13 @@ var Seclai = class {
1523
1592
  * @param opts - Pagination options.
1524
1593
  */
1525
1594
  async listCompatibleRuns(criteriaId, opts = {}) {
1526
- return await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/compatible-runs`, {
1527
- query: { page: opts.page, limit: opts.limit }
1528
- });
1595
+ return keyedList(
1596
+ await this.request("GET", `/agents/evaluation-criteria/${criteriaId}/compatible-runs`, {
1597
+ query: { page: opts.page, limit: opts.limit }
1598
+ }),
1599
+ "data",
1600
+ PAGE_COUNTERS
1601
+ );
1529
1602
  }
1530
1603
  /**
1531
1604
  * Test a draft evaluation criteria without persisting it.
@@ -1544,9 +1617,13 @@ var Seclai = class {
1544
1617
  * @param opts - Pagination options.
1545
1618
  */
1546
1619
  async listAgentEvaluationResults(agentId, opts = {}) {
1547
- return await this.request("GET", `/agents/${agentId}/evaluation-results`, {
1548
- query: { page: opts.page, limit: opts.limit }
1549
- });
1620
+ return keyedList(
1621
+ await this.request("GET", `/agents/${agentId}/evaluation-results`, {
1622
+ query: { page: opts.page, limit: opts.limit }
1623
+ }),
1624
+ "data",
1625
+ PAGE_COUNTERS
1626
+ );
1550
1627
  }
1551
1628
  /**
1552
1629
  * List evaluation run summaries for an agent.
@@ -1555,9 +1632,13 @@ var Seclai = class {
1555
1632
  * @param opts - Pagination options.
1556
1633
  */
1557
1634
  async listEvaluationRuns(agentId, opts = {}) {
1558
- return await this.request("GET", `/agents/${agentId}/evaluation-runs`, {
1559
- query: { page: opts.page, limit: opts.limit }
1560
- });
1635
+ return keyedList(
1636
+ await this.request("GET", `/agents/${agentId}/evaluation-runs`, {
1637
+ query: { page: opts.page, limit: opts.limit }
1638
+ }),
1639
+ "data",
1640
+ PAGE_COUNTERS
1641
+ );
1561
1642
  }
1562
1643
  /**
1563
1644
  * Get a summary of non-manual evaluations across an agent's runs.
@@ -1603,9 +1684,13 @@ var Seclai = class {
1603
1684
  * @returns The page of opt-outs plus the total count.
1604
1685
  */
1605
1686
  async listAgentEmailOptOuts(opts = {}) {
1606
- return await this.request("GET", "/agents/agent-email-optouts", {
1607
- query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
1608
- });
1687
+ return keyedList(
1688
+ await this.request("GET", "/agents/agent-email-optouts", {
1689
+ query: { agent_id: opts.agentId, limit: opts.limit, offset: opts.offset }
1690
+ }),
1691
+ "items",
1692
+ ["total"]
1693
+ );
1609
1694
  }
1610
1695
  /**
1611
1696
  * Revoke an opt-out, opting the recipient back in to agent emails.
@@ -1624,9 +1709,13 @@ var Seclai = class {
1624
1709
  * @param opts.offset - Rows to skip (default 0).
1625
1710
  */
1626
1711
  async listBlockedEmailSenders(opts = {}) {
1627
- return await this.request("GET", "/agents/blocked-email-senders", {
1628
- query: { limit: opts.limit, offset: opts.offset }
1629
- });
1712
+ return keyedList(
1713
+ await this.request("GET", "/agents/blocked-email-senders", {
1714
+ query: { limit: opts.limit, offset: opts.offset }
1715
+ }),
1716
+ "items",
1717
+ ["total"]
1718
+ );
1630
1719
  }
1631
1720
  /**
1632
1721
  * Add a sender address or a whole domain to the account blocklist.
@@ -1661,9 +1750,11 @@ var Seclai = class {
1661
1750
  * @returns The updated blocked-sender list.
1662
1751
  */
1663
1752
  async setAutoBlockMode(body) {
1664
- return await this.request("PUT", "/agents/blocked-email-senders/mode", {
1665
- json: body
1666
- });
1753
+ return keyedList(
1754
+ await this.request("PUT", "/agents/blocked-email-senders/mode", { json: body }),
1755
+ "items",
1756
+ ["total"]
1757
+ );
1667
1758
  }
1668
1759
  /**
1669
1760
  * List recent inbound emails that were quietly discarded before running an
@@ -1674,9 +1765,11 @@ var Seclai = class {
1674
1765
  * @param opts.limit - Maximum results (1-200, default 50).
1675
1766
  */
1676
1767
  async listInboundEmailRejections(opts = {}) {
1677
- return await this.request("GET", "/agents/inbound-email-rejections", {
1678
- query: { agent_id: opts.agentId, limit: opts.limit }
1679
- });
1768
+ return listItems(
1769
+ await this.request("GET", "/agents/inbound-email-rejections", {
1770
+ query: { agent_id: opts.agentId, limit: opts.limit }
1771
+ })
1772
+ );
1680
1773
  }
1681
1774
  /**
1682
1775
  * Get the account's inbound-email overload status — whether the circuit
@@ -1718,9 +1811,13 @@ var Seclai = class {
1718
1811
  * @returns Paginated list of knowledge bases.
1719
1812
  */
1720
1813
  async listKnowledgeBases(opts = {}) {
1721
- return await this.request("GET", "/knowledge_bases", {
1722
- query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
1723
- });
1814
+ return keyedList(
1815
+ await this.request("GET", "/knowledge_bases", {
1816
+ query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
1817
+ }),
1818
+ "knowledge_bases",
1819
+ PAGE_COUNTERS
1820
+ );
1724
1821
  }
1725
1822
  /**
1726
1823
  * Create a new knowledge base.
@@ -1768,9 +1865,13 @@ var Seclai = class {
1768
1865
  * @returns Paginated list of memory banks.
1769
1866
  */
1770
1867
  async listMemoryBanks(opts = {}) {
1771
- return await this.request("GET", "/memory_banks", {
1772
- query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
1773
- });
1868
+ return keyedList(
1869
+ await this.request("GET", "/memory_banks", {
1870
+ query: { page: opts.page, limit: opts.limit, sort: opts.sort, order: opts.order }
1871
+ }),
1872
+ "memory_banks",
1873
+ PAGE_COUNTERS
1874
+ );
1774
1875
  }
1775
1876
  /**
1776
1877
  * Create a new memory bank.
@@ -1817,7 +1918,7 @@ var Seclai = class {
1817
1918
  * @param memoryBankId - Memory bank identifier.
1818
1919
  */
1819
1920
  async getAgentsUsingMemoryBank(memoryBankId) {
1820
- return await this.request("GET", `/memory_banks/${memoryBankId}/agents`);
1921
+ return listItems(await this.request("GET", `/memory_banks/${memoryBankId}/agents`));
1821
1922
  }
1822
1923
  /**
1823
1924
  * Get stats for a memory bank.
@@ -1864,7 +1965,7 @@ var Seclai = class {
1864
1965
  * List available memory bank templates.
1865
1966
  */
1866
1967
  async listMemoryBankTemplates() {
1867
- return await this.request("GET", "/memory_banks/templates");
1968
+ return listItems(await this.request("GET", "/memory_banks/templates"));
1868
1969
  }
1869
1970
  // ─── Memory Bank AI Assistant ──────────────────────────────────────────────
1870
1971
  /**
@@ -1970,6 +2071,55 @@ var Seclai = class {
1970
2071
  async uploadInlineTextToSource(sourceId, body) {
1971
2072
  return await this.request("POST", `/sources/${sourceId}`, { json: body });
1972
2073
  }
2074
+ /**
2075
+ * List a source's content items and their indexing status.
2076
+ *
2077
+ * @param sourceId - Source connection identifier.
2078
+ * @param opts - Pagination, sorting, and filters. Pass the `content_version_id`
2079
+ * values the upload methods return as `contentVersionIds` to poll a batch of
2080
+ * uploads in one request — about 100 at a time, since the ids travel in the
2081
+ * query string and a URL over 8,192 bytes is rejected with a 414. An empty
2082
+ * `contentVersionIds` matches nothing, so it returns an empty page without
2083
+ * sending a request.
2084
+ * @returns The items under `data` with `pagination`, on every API version.
2085
+ */
2086
+ async listSourceContents(sourceId, opts = {}) {
2087
+ if (opts.contentVersionIds?.length === 0) {
2088
+ return {
2089
+ data: [],
2090
+ pagination: {
2091
+ page: opts.page ?? 1,
2092
+ limit: opts.limit ?? 20,
2093
+ total: 0,
2094
+ pages: 0,
2095
+ has_next: false,
2096
+ has_prev: false
2097
+ }
2098
+ };
2099
+ }
2100
+ return await this.request("GET", `/sources/${sourceId}/contents`, {
2101
+ query: {
2102
+ page: opts.page,
2103
+ limit: opts.limit,
2104
+ sort: opts.sort,
2105
+ order: opts.order,
2106
+ status: opts.status,
2107
+ content_version_id: opts.contentVersionIds
2108
+ }
2109
+ });
2110
+ }
2111
+ /**
2112
+ * Get one content item's indexing status.
2113
+ *
2114
+ * @param sourceId - Source connection identifier.
2115
+ * @param contentVersionId - The `content_version_id` an upload returned.
2116
+ */
2117
+ async getSourceContentStatus(sourceId, contentVersionId) {
2118
+ return await this.request(
2119
+ "GET",
2120
+ `/sources/${sourceId}/contents/${contentVersionId}`
2121
+ );
2122
+ }
1973
2123
  // ─── Source Exports ────────────────────────────────────────────────────────
1974
2124
  /**
1975
2125
  * List exports for a source.
@@ -2245,7 +2395,9 @@ var Seclai = class {
2245
2395
  * @returns List of conversations.
2246
2396
  */
2247
2397
  async listSolutionConversations(solutionId) {
2248
- return await this.request("GET", `/solutions/${solutionId}/conversations`);
2398
+ return listItems(
2399
+ await this.request("GET", `/solutions/${solutionId}/conversations`)
2400
+ );
2249
2401
  }
2250
2402
  /**
2251
2403
  * Add a conversation turn to a solution.
@@ -2334,7 +2486,9 @@ var Seclai = class {
2334
2486
  * List governance AI conversations.
2335
2487
  */
2336
2488
  async listGovernanceAiConversations() {
2337
- return await this.request("GET", "/governance/ai-assistant/conversations");
2489
+ return listItems(
2490
+ await this.request("GET", "/governance/ai-assistant/conversations")
2491
+ );
2338
2492
  }
2339
2493
  /**
2340
2494
  * Accept a governance AI plan.
@@ -2418,15 +2572,15 @@ var Seclai = class {
2418
2572
  * @returns Paginated list of alert configs.
2419
2573
  */
2420
2574
  /**
2421
- * The configurations arrive under `configs` alongside `total` by default.
2422
- * Once the caller opts in with `apiVersion` 2026-07-27 or later the endpoint
2423
- * returns the canonical `{data, pagination}` envelope instead, so the
2424
- * top-level key changes.
2575
+ * `configs` and `total` are populated on every API version; `data` and
2576
+ * `pagination` are also present once `apiVersion` is 2026-07-27 or later.
2425
2577
  */
2426
2578
  async listAlertConfigs(opts = {}) {
2427
- return await this.request("GET", "/alerts/configs", {
2428
- query: { page: opts.page, limit: opts.limit }
2429
- });
2579
+ return keyedList(
2580
+ await this.request("GET", "/alerts/configs", { query: { page: opts.page, limit: opts.limit } }),
2581
+ "configs",
2582
+ ["total"]
2583
+ );
2430
2584
  }
2431
2585
  /**
2432
2586
  * Create an alert configuration.
@@ -2469,7 +2623,11 @@ var Seclai = class {
2469
2623
  * List organization alert preferences.
2470
2624
  */
2471
2625
  async listOrganizationAlertPreferences() {
2472
- return await this.request("GET", "/alerts/organization-preferences/list");
2626
+ return keyedList(
2627
+ await this.request("GET", "/alerts/organization-preferences/list"),
2628
+ "preferences",
2629
+ ["total"]
2630
+ );
2473
2631
  }
2474
2632
  /**
2475
2633
  * Update an organization alert preference.
@@ -2496,9 +2654,11 @@ var Seclai = class {
2496
2654
  async listModelAlerts(opts = {}) {
2497
2655
  const limit = opts.limit ?? 50;
2498
2656
  const offset = opts.page && opts.page > 1 ? (opts.page - 1) * limit : void 0;
2499
- return await this.request("GET", "/models/alerts", {
2500
- query: { offset, limit: opts.limit }
2501
- });
2657
+ return keyedList(
2658
+ await this.request("GET", "/models/alerts", { query: { offset, limit: opts.limit } }),
2659
+ "alerts",
2660
+ ["total"]
2661
+ );
2502
2662
  }
2503
2663
  /**
2504
2664
  * Mark all model alerts as read.
@@ -2534,7 +2694,7 @@ var Seclai = class {
2534
2694
  * @param opts - Optional filters.
2535
2695
  */
2536
2696
  async listModels(opts = {}) {
2537
- return await this.request("GET", "/models", {
2697
+ return listItems(await this.request("GET", "/models", {
2538
2698
  query: {
2539
2699
  provider: opts.provider,
2540
2700
  supports_tool_use: opts.supportsToolUse,
@@ -2542,7 +2702,7 @@ var Seclai = class {
2542
2702
  supports_input_media: opts.supportsInputMedia,
2543
2703
  supports_output_media: opts.supportsOutputMedia
2544
2704
  }
2545
- });
2705
+ }));
2546
2706
  }
2547
2707
  /**
2548
2708
  * Get full details for a specific model.
@@ -2564,7 +2724,33 @@ var Seclai = class {
2564
2724
  * Global routing/pricing (the same for every account); read-only.
2565
2725
  */
2566
2726
  async getGenerationTiers() {
2567
- return await this.request("GET", "/models/generation-tiers");
2727
+ return keyedList(await this.request("GET", "/models/generation-tiers"), "tiers");
2728
+ }
2729
+ /**
2730
+ * List the embedding models a source can index with, and their pricing.
2731
+ *
2732
+ * The endpoint lists the embedders under `models` by default and under `data`
2733
+ * once the caller opts in with `apiVersion` 2026-07-27 or later; `models` is
2734
+ * populated on either, with the defaults and pricing beside it.
2735
+ *
2736
+ * @param opts.supportsInputMedia - Keep only embedders that can index this
2737
+ * input modality — a coarse kind (text, image, video, audio) or a full MIME.
2738
+ */
2739
+ async listEmbeddingModels(opts = {}) {
2740
+ return keyedList(
2741
+ await this.request("GET", "/models/embedders", {
2742
+ query: { supports_input_media: opts.supportsInputMedia }
2743
+ }),
2744
+ "models"
2745
+ );
2746
+ }
2747
+ /**
2748
+ * List the reranker models a knowledge base can use, and their pricing.
2749
+ *
2750
+ * `models` is populated on either wire shape, as for {@link Seclai.listEmbeddingModels}.
2751
+ */
2752
+ async listRerankerModels() {
2753
+ return keyedList(await this.request("GET", "/models/rerankers"), "models");
2568
2754
  }
2569
2755
  // ═══════════════════════════════════════════════════════════════════════════
2570
2756
  // Model Playground Experiments
@@ -2575,9 +2761,13 @@ var Seclai = class {
2575
2761
  * @param opts - Optional filters and pagination.
2576
2762
  */
2577
2763
  async listExperiments(opts = {}) {
2578
- return await this.request("GET", "/models/playground/experiments", {
2579
- query: { days: opts.days, start_date: opts.startDate, end_date: opts.endDate, limit: opts.limit, offset: opts.offset }
2580
- });
2764
+ return keyedList(
2765
+ await this.request("GET", "/models/playground/experiments", {
2766
+ query: { days: opts.days, start_date: opts.startDate, end_date: opts.endDate, limit: opts.limit, offset: opts.offset }
2767
+ }),
2768
+ "experiments",
2769
+ ["total"]
2770
+ );
2581
2771
  }
2582
2772
  /**
2583
2773
  * Create a model playground experiment.
@@ -2615,6 +2805,88 @@ var Seclai = class {
2615
2805
  await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
2616
2806
  }
2617
2807
  // ═══════════════════════════════════════════════════════════════════════════
2808
+ // Cloud Drives
2809
+ // ═══════════════════════════════════════════════════════════════════════════
2810
+ /**
2811
+ * List the cloud-drive providers this deployment has configured.
2812
+ *
2813
+ * @returns The providers, read from either wire shape.
2814
+ */
2815
+ async listCloudDriveProviders() {
2816
+ return listItems(await this.request("GET", "/cloud-drives/providers"));
2817
+ }
2818
+ /**
2819
+ * List the account's cloud-drive connections.
2820
+ *
2821
+ * @returns The connections, read from either wire shape.
2822
+ */
2823
+ async listCloudDrives() {
2824
+ return listItems(await this.request("GET", "/cloud-drives"));
2825
+ }
2826
+ /**
2827
+ * Get a cloud-drive connection.
2828
+ *
2829
+ * @param connectionId - Cloud-drive connection identifier.
2830
+ */
2831
+ async getCloudDrive(connectionId) {
2832
+ return await this.request("GET", `/cloud-drives/${connectionId}`);
2833
+ }
2834
+ /**
2835
+ * Update a cloud-drive connection.
2836
+ *
2837
+ * @param connectionId - Cloud-drive connection identifier.
2838
+ * @param body - Fields to change — `name` and/or `folder_path`.
2839
+ * @returns The updated connection.
2840
+ */
2841
+ async updateCloudDrive(connectionId, body) {
2842
+ return await this.request("PATCH", `/cloud-drives/${connectionId}`, { json: body });
2843
+ }
2844
+ /**
2845
+ * Disconnect a cloud-drive connection, keeping the connection itself.
2846
+ *
2847
+ * @param connectionId - Cloud-drive connection identifier.
2848
+ * @returns The connection in its disconnected state.
2849
+ */
2850
+ async disconnectCloudDrive(connectionId) {
2851
+ return await this.request("POST", `/cloud-drives/${connectionId}/disconnect`);
2852
+ }
2853
+ /**
2854
+ * Delete a cloud-drive connection.
2855
+ *
2856
+ * @param connectionId - Cloud-drive connection identifier.
2857
+ */
2858
+ async deleteCloudDrive(connectionId) {
2859
+ await this.request("DELETE", `/cloud-drives/${connectionId}`);
2860
+ }
2861
+ /**
2862
+ * List the agents that use a cloud-drive connection.
2863
+ *
2864
+ * @param connectionId - Cloud-drive connection identifier.
2865
+ * @returns The agents, read from either wire shape.
2866
+ */
2867
+ async getAgentsUsingCloudDrive(connectionId) {
2868
+ return listItems(
2869
+ await this.request("GET", `/cloud-drives/${connectionId}/agents`)
2870
+ );
2871
+ }
2872
+ /**
2873
+ * List the files a cloud-drive connection skipped, newest first.
2874
+ *
2875
+ * A skipped file fires no trigger, so this is where to look when an agent
2876
+ * did not run for a file.
2877
+ *
2878
+ * @param connectionId - Cloud-drive connection identifier.
2879
+ * @param opts.limit - Maximum number of rejections (1-200, default 50).
2880
+ * @returns The rejections with their reasons, read from either wire shape.
2881
+ */
2882
+ async listCloudDriveRejections(connectionId, opts = {}) {
2883
+ return listItems(
2884
+ await this.request("GET", `/cloud-drives/${connectionId}/rejections`, {
2885
+ query: { limit: opts.limit }
2886
+ })
2887
+ );
2888
+ }
2889
+ // ═══════════════════════════════════════════════════════════════════════════
2618
2890
  // Search
2619
2891
  // ═══════════════════════════════════════════════════════════════════════════
2620
2892
  /**
@@ -2672,7 +2944,7 @@ var Seclai = class {
2672
2944
  * Requires a user-bound credential; an account-only API key is refused with 403.
2673
2945
  */
2674
2946
  async listEmailDomains() {
2675
- return await this.request("GET", "/email-domains");
2947
+ return keyedList(await this.request("GET", "/email-domains"), "domains");
2676
2948
  }
2677
2949
  /**
2678
2950
  * Add and provision a new agent-email domain.
@@ -2853,18 +3125,20 @@ var Seclai = class {
2853
3125
  /**
2854
3126
  * Auto-paginate through a list endpoint.
2855
3127
  *
2856
- * Yields individual items from each page, automatically fetching the next page
2857
- * until all items have been returned.
3128
+ * Yields individual items from each page, fetching the next page until the
3129
+ * response reports there is none. A fetcher that answers with a bare array has
3130
+ * no further pages, so its items are yielded once.
2858
3131
  *
2859
3132
  * @param fetchPage - A function that fetches a single page given `{ page, limit }`.
2860
3133
  * @param opts - Page size (default: 50).
3134
+ * @throws {@link SeclaiError} When a page carries its items under neither `data` nor `items`.
2861
3135
  *
2862
3136
  * @example
2863
3137
  * ```ts
2864
3138
  * for await (const agent of client.paginate(
2865
3139
  * (opts) => client.listAgents(opts),
2866
3140
  * )) {
2867
- * console.log(agent);
3141
+ * console.log(agent.name);
2868
3142
  * }
2869
3143
  * ```
2870
3144
  */
@@ -2873,11 +3147,29 @@ var Seclai = class {
2873
3147
  let page = 1;
2874
3148
  while (true) {
2875
3149
  const result = await fetchPage({ page, limit });
2876
- for (const item of result.items) {
2877
- yield item;
3150
+ if (Array.isArray(result)) {
3151
+ yield* result;
3152
+ return;
3153
+ }
3154
+ const body = result ?? {};
3155
+ const items = "data" in body ? body.data ?? [] : body.items;
3156
+ if (!Array.isArray(items)) {
3157
+ throw new SeclaiError(
3158
+ "paginate() could not find the page's items: expected an array, or an object with a `data` or `items` array."
3159
+ );
2878
3160
  }
2879
- if (!result.pagination || result.items.length < limit || page >= result.pagination.total_pages) {
2880
- break;
3161
+ yield* items;
3162
+ const pagination = body.pagination;
3163
+ if (items.length === 0) return;
3164
+ if (!pagination) {
3165
+ if (typeof body.total !== "number") return;
3166
+ const pageSize = typeof body.limit === "number" && body.limit > 0 ? body.limit : limit;
3167
+ if (page * pageSize >= body.total) return;
3168
+ } else if (typeof pagination.has_next === "boolean") {
3169
+ if (!pagination.has_next) return;
3170
+ } else {
3171
+ const pages = pagination.pages ?? pagination.total_pages;
3172
+ if (items.length < limit || pages === void 0 || page >= pages) return;
2881
3173
  }
2882
3174
  page++;
2883
3175
  }