@seclai/sdk 1.4.0 → 1.6.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 +54 -0
- package/README.md +112 -3
- package/dist/index.cjs +313 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1678 -107
- package/dist/index.d.ts +1678 -107
- package/dist/index.js +312 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
Seclai: () => Seclai,
|
|
38
38
|
SeclaiAPIStatusError: () => SeclaiAPIStatusError,
|
|
39
39
|
SeclaiAPIValidationError: () => SeclaiAPIValidationError,
|
|
40
|
+
SeclaiApiVersion: () => SeclaiApiVersion,
|
|
40
41
|
SeclaiConfigurationError: () => SeclaiConfigurationError,
|
|
41
42
|
SeclaiError: () => SeclaiError,
|
|
42
43
|
SeclaiStreamingError: () => SeclaiStreamingError,
|
|
@@ -48,6 +49,22 @@ __export(index_exports, {
|
|
|
48
49
|
});
|
|
49
50
|
module.exports = __toCommonJS(index_exports);
|
|
50
51
|
|
|
52
|
+
// src/versions.ts
|
|
53
|
+
var SeclaiApiVersion = {
|
|
54
|
+
V2026_07_01: "2026-07-01",
|
|
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",
|
|
61
|
+
/** Baseline applied to an unpinned, header-less caller. */
|
|
62
|
+
Default: "2026-07-01",
|
|
63
|
+
/** Newest version known to this SDK release. May lag the server. */
|
|
64
|
+
Latest: "2026-10-03"
|
|
65
|
+
};
|
|
66
|
+
var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
|
|
67
|
+
|
|
51
68
|
// src/errors.ts
|
|
52
69
|
var SeclaiError = class extends Error {
|
|
53
70
|
constructor(message) {
|
|
@@ -395,11 +412,23 @@ function buildURL(baseUrl, path, query) {
|
|
|
395
412
|
if (query) {
|
|
396
413
|
for (const [key, value] of Object.entries(query)) {
|
|
397
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
|
+
}
|
|
398
419
|
url.searchParams.set(key, String(value));
|
|
399
420
|
}
|
|
400
421
|
}
|
|
401
422
|
return url;
|
|
402
423
|
}
|
|
424
|
+
function listItems(res) {
|
|
425
|
+
if (Array.isArray(res)) return res;
|
|
426
|
+
return res?.data ?? [];
|
|
427
|
+
}
|
|
428
|
+
function withModels(res) {
|
|
429
|
+
const body = res;
|
|
430
|
+
return Array.isArray(body.models) || !Array.isArray(body.data) ? body : { ...body, models: body.data };
|
|
431
|
+
}
|
|
403
432
|
async function safeText(response) {
|
|
404
433
|
try {
|
|
405
434
|
return await response.clone().text();
|
|
@@ -545,7 +574,23 @@ var Seclai = class {
|
|
|
545
574
|
);
|
|
546
575
|
}
|
|
547
576
|
this.baseUrl = opts.baseUrl ?? getEnv2("SECLAI_API_URL") ?? SECLAI_API_URL;
|
|
548
|
-
|
|
577
|
+
const merged = opts.apiVersion ? { "Seclai-Version": opts.apiVersion } : {};
|
|
578
|
+
let versionKey = opts.apiVersion ? "Seclai-Version" : void 0;
|
|
579
|
+
for (const [key, value] of Object.entries(opts.defaultHeaders ?? {})) {
|
|
580
|
+
for (const existing of Object.keys(merged)) {
|
|
581
|
+
if (existing.toLowerCase() === key.toLowerCase()) delete merged[existing];
|
|
582
|
+
}
|
|
583
|
+
merged[key] = value;
|
|
584
|
+
if (key.toLowerCase() === "seclai-version") versionKey = key;
|
|
585
|
+
}
|
|
586
|
+
const effectiveVersion = versionKey ? merged[versionKey] : void 0;
|
|
587
|
+
if (effectiveVersion && !opts.allowUnknownApiVersion && !KNOWN_API_VERSIONS.includes(effectiveVersion)) {
|
|
588
|
+
const via = versionKey === "Seclai-Version" && merged[versionKey] === opts.apiVersion ? "apiVersion" : `defaultHeaders['${versionKey}']`;
|
|
589
|
+
throw new SeclaiConfigurationError(
|
|
590
|
+
`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.`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
this.defaultHeaders = merged;
|
|
549
594
|
this.fetcher = fetcher;
|
|
550
595
|
const accessTokenProvider = typeof opts.accessToken === "function" ? opts.accessToken : void 0;
|
|
551
596
|
const accessTokenStatic = typeof opts.accessToken === "string" ? opts.accessToken : void 0;
|
|
@@ -763,6 +808,34 @@ var Seclai = class {
|
|
|
763
808
|
return await this.request("GET", "/me");
|
|
764
809
|
}
|
|
765
810
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
811
|
+
// API Version
|
|
812
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
813
|
+
/**
|
|
814
|
+
* Read the API version this request resolved to, and the versions available.
|
|
815
|
+
*
|
|
816
|
+
* Resolution order is the `Seclai-Version` header, then the account pin, then
|
|
817
|
+
* the default — so `effective_version` reflects the client's `apiVersion`
|
|
818
|
+
* option when that is set.
|
|
819
|
+
*
|
|
820
|
+
* @returns The pinned, effective, default and latest versions.
|
|
821
|
+
*/
|
|
822
|
+
async getApiVersion() {
|
|
823
|
+
return await this.request("GET", "/version");
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Pin the account to a dated API version, or clear the pin.
|
|
827
|
+
*
|
|
828
|
+
* Owner/admin only. The pin applies to later header-less requests; a
|
|
829
|
+
* `Seclai-Version` header still overrides it, so `effective_version` in the
|
|
830
|
+
* response describes this request rather than the pin just written.
|
|
831
|
+
*
|
|
832
|
+
* @param version - A `YYYY-MM-DD` date to pin to, or `null` to clear the pin.
|
|
833
|
+
* @returns The updated version state.
|
|
834
|
+
*/
|
|
835
|
+
async updateApiVersion(version) {
|
|
836
|
+
return await this.request("PUT", "/version", { json: { version } });
|
|
837
|
+
}
|
|
838
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
766
839
|
// Agents — CRUD
|
|
767
840
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
768
841
|
/**
|
|
@@ -959,21 +1032,29 @@ var Seclai = class {
|
|
|
959
1032
|
} : void 0);
|
|
960
1033
|
}
|
|
961
1034
|
/**
|
|
962
|
-
*
|
|
1035
|
+
* Cancel an agent run.
|
|
1036
|
+
*
|
|
1037
|
+
* @deprecated This never deleted anything — the endpoint it calls is documented
|
|
1038
|
+
* as "Cancel an agent run", and the API has no delete-a-run operation. It also
|
|
1039
|
+
* discards the returned run state. Use {@link cancelAgentRun} instead.
|
|
963
1040
|
*
|
|
964
1041
|
* @param runId - Run identifier.
|
|
965
1042
|
*/
|
|
966
1043
|
async deleteAgentRun(runId) {
|
|
967
|
-
await this.
|
|
1044
|
+
await this.cancelAgentRun(runId);
|
|
968
1045
|
}
|
|
969
1046
|
/**
|
|
970
1047
|
* Cancel a running agent run.
|
|
971
1048
|
*
|
|
1049
|
+
* Cancellation is `DELETE` on the run resource — the API exposes no
|
|
1050
|
+
* `POST .../cancel` route, and no operation that deletes a run. Rejected when
|
|
1051
|
+
* the run has already reached a terminal state.
|
|
1052
|
+
*
|
|
972
1053
|
* @param runId - Run identifier.
|
|
973
1054
|
* @returns Updated run (with cancelled status).
|
|
974
1055
|
*/
|
|
975
1056
|
async cancelAgentRun(runId) {
|
|
976
|
-
return await this.request("
|
|
1057
|
+
return await this.request("DELETE", `/agents/runs/${runId}`);
|
|
977
1058
|
}
|
|
978
1059
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
979
1060
|
// Agent Runs — Streaming
|
|
@@ -1239,9 +1320,10 @@ var Seclai = class {
|
|
|
1239
1320
|
* @returns Paginated list of evaluation results.
|
|
1240
1321
|
*/
|
|
1241
1322
|
async listRunEvaluationResults(agentId, runId, opts = {}) {
|
|
1242
|
-
|
|
1323
|
+
const res = await this.request("GET", `/agents/${agentId}/runs/${runId}/evaluation-results`, {
|
|
1243
1324
|
query: { page: opts.page, limit: opts.limit }
|
|
1244
1325
|
});
|
|
1326
|
+
return Array.isArray(res) ? { data: res } : res;
|
|
1245
1327
|
}
|
|
1246
1328
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
1247
1329
|
// Agent Input Uploads
|
|
@@ -1329,8 +1411,20 @@ var Seclai = class {
|
|
|
1329
1411
|
* @param agentId - Agent identifier.
|
|
1330
1412
|
* @returns Conversation history.
|
|
1331
1413
|
*/
|
|
1332
|
-
async getAgentAiConversationHistory(agentId) {
|
|
1333
|
-
|
|
1414
|
+
async getAgentAiConversationHistory(agentId, opts = {}) {
|
|
1415
|
+
if (!opts.stepType) {
|
|
1416
|
+
throw new SeclaiConfigurationError(
|
|
1417
|
+
'getAgentAiConversationHistory requires opts.stepType; the API rejects the request without it. Pass e.g. { stepType: "llm" }.'
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
return await this.request("GET", `/agents/${agentId}/ai-assistant/conversations`, {
|
|
1421
|
+
query: {
|
|
1422
|
+
step_type: opts.stepType,
|
|
1423
|
+
step_id: opts.stepId,
|
|
1424
|
+
limit: opts.limit,
|
|
1425
|
+
offset: opts.offset
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1334
1428
|
}
|
|
1335
1429
|
/**
|
|
1336
1430
|
* Mark an AI suggestion as accepted or rejected.
|
|
@@ -1352,9 +1446,25 @@ var Seclai = class {
|
|
|
1352
1446
|
* @param opts - Pagination options.
|
|
1353
1447
|
*/
|
|
1354
1448
|
async listEvaluationCriteria(agentId, opts = {}) {
|
|
1355
|
-
return await this.
|
|
1449
|
+
return (await this.listEvaluationCriteriaPage(agentId, opts)).data ?? [];
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* List evaluation criteria for an agent, with pagination metadata.
|
|
1453
|
+
*
|
|
1454
|
+
* Accepts either wire shape. The endpoint answered with a bare array before
|
|
1455
|
+
* 2026-07 and with a paginated envelope after, so a client that decodes only
|
|
1456
|
+
* one breaks the day the other ships. `total`, `page` and `limit` are absent
|
|
1457
|
+
* when the endpoint answers with a bare array.
|
|
1458
|
+
*
|
|
1459
|
+
* @param agentId - Agent identifier.
|
|
1460
|
+
* @param opts - Pagination options.
|
|
1461
|
+
* @returns The criteria under `data`, plus the page metadata when present.
|
|
1462
|
+
*/
|
|
1463
|
+
async listEvaluationCriteriaPage(agentId, opts = {}) {
|
|
1464
|
+
const res = await this.request("GET", `/agents/${agentId}/evaluation-criteria`, {
|
|
1356
1465
|
query: { page: opts.page, limit: opts.limit }
|
|
1357
1466
|
});
|
|
1467
|
+
return Array.isArray(res) ? { data: res } : res;
|
|
1358
1468
|
}
|
|
1359
1469
|
/**
|
|
1360
1470
|
* Create evaluation criteria for an agent.
|
|
@@ -1808,7 +1918,7 @@ var Seclai = class {
|
|
|
1808
1918
|
* @returns Paginated list of sources.
|
|
1809
1919
|
*/
|
|
1810
1920
|
async listSources(opts = {}) {
|
|
1811
|
-
return await this.request("GET", "/sources
|
|
1921
|
+
return await this.request("GET", "/sources", {
|
|
1812
1922
|
query: {
|
|
1813
1923
|
page: opts.page,
|
|
1814
1924
|
limit: opts.limit,
|
|
@@ -1877,6 +1987,55 @@ var Seclai = class {
|
|
|
1877
1987
|
async uploadInlineTextToSource(sourceId, body) {
|
|
1878
1988
|
return await this.request("POST", `/sources/${sourceId}`, { json: body });
|
|
1879
1989
|
}
|
|
1990
|
+
/**
|
|
1991
|
+
* List a source's content items and their indexing status.
|
|
1992
|
+
*
|
|
1993
|
+
* @param sourceId - Source connection identifier.
|
|
1994
|
+
* @param opts - Pagination, sorting, and filters. Pass the `content_version_id`
|
|
1995
|
+
* values the upload methods return as `contentVersionIds` to poll a batch of
|
|
1996
|
+
* uploads in one request — about 100 at a time, since the ids travel in the
|
|
1997
|
+
* query string and a URL over 8,192 bytes is rejected with a 414. An empty
|
|
1998
|
+
* `contentVersionIds` matches nothing, so it returns an empty page without
|
|
1999
|
+
* sending a request.
|
|
2000
|
+
* @returns The items under `data` with `pagination`, on every API version.
|
|
2001
|
+
*/
|
|
2002
|
+
async listSourceContents(sourceId, opts = {}) {
|
|
2003
|
+
if (opts.contentVersionIds?.length === 0) {
|
|
2004
|
+
return {
|
|
2005
|
+
data: [],
|
|
2006
|
+
pagination: {
|
|
2007
|
+
page: opts.page ?? 1,
|
|
2008
|
+
limit: opts.limit ?? 20,
|
|
2009
|
+
total: 0,
|
|
2010
|
+
pages: 0,
|
|
2011
|
+
has_next: false,
|
|
2012
|
+
has_prev: false
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
return await this.request("GET", `/sources/${sourceId}/contents`, {
|
|
2017
|
+
query: {
|
|
2018
|
+
page: opts.page,
|
|
2019
|
+
limit: opts.limit,
|
|
2020
|
+
sort: opts.sort,
|
|
2021
|
+
order: opts.order,
|
|
2022
|
+
status: opts.status,
|
|
2023
|
+
content_version_id: opts.contentVersionIds
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Get one content item's indexing status.
|
|
2029
|
+
*
|
|
2030
|
+
* @param sourceId - Source connection identifier.
|
|
2031
|
+
* @param contentVersionId - The `content_version_id` an upload returned.
|
|
2032
|
+
*/
|
|
2033
|
+
async getSourceContentStatus(sourceId, contentVersionId) {
|
|
2034
|
+
return await this.request(
|
|
2035
|
+
"GET",
|
|
2036
|
+
`/sources/${sourceId}/contents/${contentVersionId}`
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
1880
2039
|
// ─── Source Exports ────────────────────────────────────────────────────────
|
|
1881
2040
|
/**
|
|
1882
2041
|
* List exports for a source.
|
|
@@ -2271,7 +2430,7 @@ var Seclai = class {
|
|
|
2271
2430
|
*/
|
|
2272
2431
|
async listAlerts(opts = {}) {
|
|
2273
2432
|
return await this.request("GET", "/alerts", {
|
|
2274
|
-
query: { page: opts.page, limit: opts.limit, status: opts.status
|
|
2433
|
+
query: { page: opts.page, limit: opts.limit, status: opts.status }
|
|
2275
2434
|
});
|
|
2276
2435
|
}
|
|
2277
2436
|
/**
|
|
@@ -2324,6 +2483,12 @@ var Seclai = class {
|
|
|
2324
2483
|
* @param opts - Pagination options.
|
|
2325
2484
|
* @returns Paginated list of alert configs.
|
|
2326
2485
|
*/
|
|
2486
|
+
/**
|
|
2487
|
+
* The configurations arrive under `configs` alongside `total` by default.
|
|
2488
|
+
* Once the caller opts in with `apiVersion` 2026-07-27 or later the endpoint
|
|
2489
|
+
* returns the canonical `{data, pagination}` envelope instead, so the
|
|
2490
|
+
* top-level key changes.
|
|
2491
|
+
*/
|
|
2327
2492
|
async listAlertConfigs(opts = {}) {
|
|
2328
2493
|
return await this.request("GET", "/alerts/configs", {
|
|
2329
2494
|
query: { page: opts.page, limit: opts.limit }
|
|
@@ -2395,8 +2560,10 @@ var Seclai = class {
|
|
|
2395
2560
|
* @param opts - Pagination options.
|
|
2396
2561
|
*/
|
|
2397
2562
|
async listModelAlerts(opts = {}) {
|
|
2563
|
+
const limit = opts.limit ?? 50;
|
|
2564
|
+
const offset = opts.page && opts.page > 1 ? (opts.page - 1) * limit : void 0;
|
|
2398
2565
|
return await this.request("GET", "/models/alerts", {
|
|
2399
|
-
query: {
|
|
2566
|
+
query: { offset, limit: opts.limit }
|
|
2400
2567
|
});
|
|
2401
2568
|
}
|
|
2402
2569
|
/**
|
|
@@ -2465,6 +2632,31 @@ var Seclai = class {
|
|
|
2465
2632
|
async getGenerationTiers() {
|
|
2466
2633
|
return await this.request("GET", "/models/generation-tiers");
|
|
2467
2634
|
}
|
|
2635
|
+
/**
|
|
2636
|
+
* List the embedding models a source can index with, and their pricing.
|
|
2637
|
+
*
|
|
2638
|
+
* The endpoint lists the embedders under `models` by default and under `data`
|
|
2639
|
+
* once the caller opts in with `apiVersion` 2026-07-27 or later; `models` is
|
|
2640
|
+
* populated on either, with the defaults and pricing beside it.
|
|
2641
|
+
*
|
|
2642
|
+
* @param opts.supportsInputMedia - Keep only embedders that can index this
|
|
2643
|
+
* input modality — a coarse kind (text, image, video, audio) or a full MIME.
|
|
2644
|
+
*/
|
|
2645
|
+
async listEmbeddingModels(opts = {}) {
|
|
2646
|
+
return withModels(
|
|
2647
|
+
await this.request("GET", "/models/embedders", {
|
|
2648
|
+
query: { supports_input_media: opts.supportsInputMedia }
|
|
2649
|
+
})
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* List the reranker models a knowledge base can use, and their pricing.
|
|
2654
|
+
*
|
|
2655
|
+
* `models` is populated on either wire shape, as for {@link Seclai.listEmbeddingModels}.
|
|
2656
|
+
*/
|
|
2657
|
+
async listRerankerModels() {
|
|
2658
|
+
return withModels(await this.request("GET", "/models/rerankers"));
|
|
2659
|
+
}
|
|
2468
2660
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2469
2661
|
// Model Playground Experiments
|
|
2470
2662
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -2514,6 +2706,88 @@ var Seclai = class {
|
|
|
2514
2706
|
await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
|
|
2515
2707
|
}
|
|
2516
2708
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2709
|
+
// Cloud Drives
|
|
2710
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2711
|
+
/**
|
|
2712
|
+
* List the cloud-drive providers this deployment has configured.
|
|
2713
|
+
*
|
|
2714
|
+
* @returns The providers, read from either wire shape.
|
|
2715
|
+
*/
|
|
2716
|
+
async listCloudDriveProviders() {
|
|
2717
|
+
return listItems(await this.request("GET", "/cloud-drives/providers"));
|
|
2718
|
+
}
|
|
2719
|
+
/**
|
|
2720
|
+
* List the account's cloud-drive connections.
|
|
2721
|
+
*
|
|
2722
|
+
* @returns The connections, read from either wire shape.
|
|
2723
|
+
*/
|
|
2724
|
+
async listCloudDrives() {
|
|
2725
|
+
return listItems(await this.request("GET", "/cloud-drives"));
|
|
2726
|
+
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Get a cloud-drive connection.
|
|
2729
|
+
*
|
|
2730
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2731
|
+
*/
|
|
2732
|
+
async getCloudDrive(connectionId) {
|
|
2733
|
+
return await this.request("GET", `/cloud-drives/${connectionId}`);
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Update a cloud-drive connection.
|
|
2737
|
+
*
|
|
2738
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2739
|
+
* @param body - Fields to change — `name` and/or `folder_path`.
|
|
2740
|
+
* @returns The updated connection.
|
|
2741
|
+
*/
|
|
2742
|
+
async updateCloudDrive(connectionId, body) {
|
|
2743
|
+
return await this.request("PATCH", `/cloud-drives/${connectionId}`, { json: body });
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* Disconnect a cloud-drive connection, keeping the connection itself.
|
|
2747
|
+
*
|
|
2748
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2749
|
+
* @returns The connection in its disconnected state.
|
|
2750
|
+
*/
|
|
2751
|
+
async disconnectCloudDrive(connectionId) {
|
|
2752
|
+
return await this.request("POST", `/cloud-drives/${connectionId}/disconnect`);
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Delete a cloud-drive connection.
|
|
2756
|
+
*
|
|
2757
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2758
|
+
*/
|
|
2759
|
+
async deleteCloudDrive(connectionId) {
|
|
2760
|
+
await this.request("DELETE", `/cloud-drives/${connectionId}`);
|
|
2761
|
+
}
|
|
2762
|
+
/**
|
|
2763
|
+
* List the agents that use a cloud-drive connection.
|
|
2764
|
+
*
|
|
2765
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2766
|
+
* @returns The agents, read from either wire shape.
|
|
2767
|
+
*/
|
|
2768
|
+
async getAgentsUsingCloudDrive(connectionId) {
|
|
2769
|
+
return listItems(
|
|
2770
|
+
await this.request("GET", `/cloud-drives/${connectionId}/agents`)
|
|
2771
|
+
);
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* List the files a cloud-drive connection skipped, newest first.
|
|
2775
|
+
*
|
|
2776
|
+
* A skipped file fires no trigger, so this is where to look when an agent
|
|
2777
|
+
* did not run for a file.
|
|
2778
|
+
*
|
|
2779
|
+
* @param connectionId - Cloud-drive connection identifier.
|
|
2780
|
+
* @param opts.limit - Maximum number of rejections (1-200, default 50).
|
|
2781
|
+
* @returns The rejections with their reasons, read from either wire shape.
|
|
2782
|
+
*/
|
|
2783
|
+
async listCloudDriveRejections(connectionId, opts = {}) {
|
|
2784
|
+
return listItems(
|
|
2785
|
+
await this.request("GET", `/cloud-drives/${connectionId}/rejections`, {
|
|
2786
|
+
query: { limit: opts.limit }
|
|
2787
|
+
})
|
|
2788
|
+
);
|
|
2789
|
+
}
|
|
2790
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2517
2791
|
// Search
|
|
2518
2792
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
2519
2793
|
/**
|
|
@@ -2752,18 +3026,20 @@ var Seclai = class {
|
|
|
2752
3026
|
/**
|
|
2753
3027
|
* Auto-paginate through a list endpoint.
|
|
2754
3028
|
*
|
|
2755
|
-
* Yields individual items from each page,
|
|
2756
|
-
*
|
|
3029
|
+
* Yields individual items from each page, fetching the next page until the
|
|
3030
|
+
* response reports there is none. A fetcher that answers with a bare array has
|
|
3031
|
+
* no further pages, so its items are yielded once.
|
|
2757
3032
|
*
|
|
2758
3033
|
* @param fetchPage - A function that fetches a single page given `{ page, limit }`.
|
|
2759
3034
|
* @param opts - Page size (default: 50).
|
|
3035
|
+
* @throws {@link SeclaiError} When a page carries its items under neither `data` nor `items`.
|
|
2760
3036
|
*
|
|
2761
3037
|
* @example
|
|
2762
3038
|
* ```ts
|
|
2763
3039
|
* for await (const agent of client.paginate(
|
|
2764
3040
|
* (opts) => client.listAgents(opts),
|
|
2765
3041
|
* )) {
|
|
2766
|
-
* console.log(agent);
|
|
3042
|
+
* console.log(agent.name);
|
|
2767
3043
|
* }
|
|
2768
3044
|
* ```
|
|
2769
3045
|
*/
|
|
@@ -2772,11 +3048,29 @@ var Seclai = class {
|
|
|
2772
3048
|
let page = 1;
|
|
2773
3049
|
while (true) {
|
|
2774
3050
|
const result = await fetchPage({ page, limit });
|
|
2775
|
-
|
|
2776
|
-
yield
|
|
3051
|
+
if (Array.isArray(result)) {
|
|
3052
|
+
yield* result;
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
const body = result ?? {};
|
|
3056
|
+
const items = "data" in body ? body.data ?? [] : body.items;
|
|
3057
|
+
if (!Array.isArray(items)) {
|
|
3058
|
+
throw new SeclaiError(
|
|
3059
|
+
"paginate() could not find the page's items: expected an array, or an object with a `data` or `items` array."
|
|
3060
|
+
);
|
|
2777
3061
|
}
|
|
2778
|
-
|
|
2779
|
-
|
|
3062
|
+
yield* items;
|
|
3063
|
+
const pagination = body.pagination;
|
|
3064
|
+
if (items.length === 0) return;
|
|
3065
|
+
if (!pagination) {
|
|
3066
|
+
if (typeof body.total !== "number") return;
|
|
3067
|
+
const pageSize = typeof body.limit === "number" && body.limit > 0 ? body.limit : limit;
|
|
3068
|
+
if (page * pageSize >= body.total) return;
|
|
3069
|
+
} else if (typeof pagination.has_next === "boolean") {
|
|
3070
|
+
if (!pagination.has_next) return;
|
|
3071
|
+
} else {
|
|
3072
|
+
const pages = pagination.pages ?? pagination.total_pages;
|
|
3073
|
+
if (items.length < limit || pages === void 0 || page >= pages) return;
|
|
2780
3074
|
}
|
|
2781
3075
|
page++;
|
|
2782
3076
|
}
|
|
@@ -2791,6 +3085,7 @@ var Seclai = class {
|
|
|
2791
3085
|
Seclai,
|
|
2792
3086
|
SeclaiAPIStatusError,
|
|
2793
3087
|
SeclaiAPIValidationError,
|
|
3088
|
+
SeclaiApiVersion,
|
|
2794
3089
|
SeclaiConfigurationError,
|
|
2795
3090
|
SeclaiError,
|
|
2796
3091
|
SeclaiStreamingError,
|