@seclai/sdk 1.5.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.0] - 2026-10-04
4
+
5
+ ### Changed
6
+
7
+ - Sync the bundled OpenAPI spec and regenerate the types. Existing responses gain properties, among them `attachments` on `AgentRunResponse` and `AgentRunStepResponse`, `trace_purged_at` on a run, `warnings` on a step, `strip_quoted_reply_chains` on memory banks, `effort` on playground experiments, `effort_options` and `chat_capable` on `PromptModelResponse`, and `embedder_warning` on `ContentFileUploadResponse`
8
+ - Move `SeclaiApiVersion.Latest` to `2026-10-03`. Nothing is sent unless `apiVersion` is set, so a client that passes `SeclaiApiVersion.Latest` now opts into the five versions added below
9
+ - Send an array passed in the `query` of `request()` or `requestRaw()` as a repeated parameter, one pair per element. It was joined with commas into a single value
10
+
11
+ ### Added
12
+
13
+ - Add the cloud-drive methods `listCloudDriveProviders()`, `listCloudDrives()`, `getCloudDrive()`, `updateCloudDrive()`, `disconnectCloudDrive()`, `deleteCloudDrive()`, `getAgentsUsingCloudDrive()` and `listCloudDriveRejections()`. The four listings return the items as an array whether the endpoint answers with a bare array or, from `apiVersion` `2026-07-27`, the `{data, pagination}` envelope
14
+ - Add `listSourceContents()` and `getSourceContentStatus()` for the indexing status of a source's content. `contentVersionIds` polls a batch of uploads in one request, and an empty array returns an empty page without calling the API
15
+ - Add `listEmbeddingModels()` and `listRerankerModels()`. The list is under `models` on every API version, with the defaults and pricing beside it
16
+ - Add the `SeclaiApiVersion` constants `V2026_08_03`, `V2026_08_21`, `V2026_09_28`, `V2026_09_30` and `V2026_10_03`, so those versions are accepted as `apiVersion`. The README lists what each one changes
17
+ - Add the type exports for those endpoints, including `CloudDriveResponse`, `CloudDriveProviderResponse`, `CloudDriveRejectionResponse`, `CloudDriveUpdateRequest`, `AgentUsingCloudDriveResponse`, `SourceContentStatusResponse`, `SourceContentStatusListResponse`, `ListSourceContentsOptions`, `EmbeddingModelListResponse` and `RerankerModelListResponse`, plus `AgentRunFileResponse` and `EffortOptionsResponse`
18
+
19
+ ### Fixed
20
+
21
+ - Make `paginate()` work with the list methods. It read `items` and `pagination.total_pages`, while they return `data` and `pagination.pages`, so `client.paginate((opts) => client.listSources(opts))` threw `TypeError: result.items is not iterable`. It now reads the `{data, pagination}` envelope and stops on `has_next`, walks the flat `{data, total, page, limit}` shape of the evaluation listings by `total`, yields a bare array once, still accepts a custom fetcher's `{items, pagination: {total_pages}}`, and throws `SeclaiError` on anything else. The fetcher's page type is exported as `PaginatedPage`
22
+ - Correct the `Seclai` class example, which destructured an `items` property `listAgents()` does not return
23
+
3
24
  ## [1.5.0] - 2026-07-27
4
25
 
5
26
  ### Changed
@@ -185,6 +206,7 @@ _Stable release. No functional changes since 0.0.1._
185
206
 
186
207
  _Initial release._
187
208
 
209
+ [1.6.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.0
188
210
  [1.5.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.5.0
189
211
  [1.4.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.4.0
190
212
  [1.3.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.3.0
package/README.md CHANGED
@@ -104,7 +104,7 @@ or set environment variables:
104
104
 
105
105
  Online API documentation (latest):
106
106
 
107
- https://seclai.github.io/seclai-javascript/1.5.0/
107
+ https://seclai.github.io/seclai-javascript/1.6.0/
108
108
 
109
109
  Release history is in [`CHANGELOG.md`](CHANGELOG.md).
110
110
 
@@ -127,8 +127,8 @@ Leave `apiVersion` unset and the header is omitted, so the account's pinned
127
127
  baseline applies and responses keep their current shapes. Upgrading this package
128
128
  alone never changes the wire contract.
129
129
 
130
- Known versions are on `SeclaiApiVersion` (`V2026_07_01`, `V2026_07_27`, plus
131
- `Default` and `Latest`), imported from `@seclai/sdk`. A version this release was
130
+ Known versions are on `SeclaiApiVersion` (`V2026_07_01` through `V2026_10_03`,
131
+ plus `Default` and `Latest`), imported from `@seclai/sdk`. A version this release was
132
132
  **not** built against throws at construction: a newer version can reshape
133
133
  responses, and this client would decode them incorrectly rather than reject them.
134
134
  Upgrade the package to adopt a new version, or set `allowUnknownApiVersion` if
@@ -156,6 +156,23 @@ last two with `res.data ?? res.configs` / `res.data ?? res.alerts`. The legacy
156
156
  keys will be deprecated and then removed once the canonical envelope is the
157
157
  default.
158
158
 
159
+ The cloud-drive listings (`listCloudDriveProviders()`, `listCloudDrives()`,
160
+ `getAgentsUsingCloudDrive()`, `listCloudDriveRejections()`) follow the same rule
161
+ and return the items as an array on either shape. `listEmbeddingModels()` and
162
+ `listRerankerModels()` move their list from `models` to `data`; both methods
163
+ populate `models` on either shape, with the defaults and pricing beside it.
164
+
165
+ **Later versions.** Each is cumulative, and none changes a response shape this
166
+ client decodes:
167
+
168
+ | Version | What it changes |
169
+ | --- | --- |
170
+ | `2026-08-03` | `createMemoryBank()` rejects `max_age_days` with a 400, and an omitted `retention_days` resolves per bank type instead of to 30 |
171
+ | `2026-08-21` | `createSource()` rejects an embedding dimension its embedder does not support with a 400 — `listEmbeddingModels()` reports the supported ones |
172
+ | `2026-09-28` | Agent-definition writes use the current file-list grammar: an omitted `attachments` keeps the stored list and `[]` means no files |
173
+ | `2026-09-30` | A run's and a step's `output`, and a step's `input`, are the text rather than a JSON manifest; files are in `attachments` on every version |
174
+ | `2026-10-03` | A new LLM step written without `attachments` takes its parent's files, and a new retrieval step's matched media are its files |
175
+
159
176
  ## Resources
160
177
 
161
178
  ### Identity
@@ -427,6 +444,40 @@ await client.updateSource("source_id", { name: "Renamed" });
427
444
  await client.deleteSource("source_id");
428
445
  ```
429
446
 
447
+ Indexing status of a source's content, keyed by the `content_version_id` the
448
+ upload methods return:
449
+
450
+ <!-- sdksync:check -->
451
+ ```ts
452
+ const failed = await client.listSourceContents("source_id", { status: "failed" });
453
+ const batch = await client.listSourceContents("source_id", {
454
+ contentVersionIds: ["cv_1", "cv_2"],
455
+ });
456
+ console.log(batch.pagination.total, failed.data.map((item) => item.error));
457
+
458
+ const one = await client.getSourceContentStatus("source_id", "cv_1");
459
+ console.log(one.content_status);
460
+ ```
461
+
462
+ ### Cloud drives
463
+
464
+ <!-- sdksync:check -->
465
+ ```ts
466
+ const providers = await client.listCloudDriveProviders();
467
+ const drives = await client.listCloudDrives();
468
+ const drive = await client.getCloudDrive(drives[0].id);
469
+ await client.updateCloudDrive(drive.id, { name: "Contracts" });
470
+
471
+ // Which agents depend on it, and which files it skipped and why
472
+ const agents = await client.getAgentsUsingCloudDrive(drive.id);
473
+ const skipped = await client.listCloudDriveRejections(drive.id, { limit: 20 });
474
+ console.log(providers.length, agents.length, skipped.map((r) => r.reason));
475
+
476
+ const disconnected = await client.disconnectCloudDrive(drive.id); // keeps the connection
477
+ console.log(disconnected.connected);
478
+ await client.deleteCloudDrive(drive.id);
479
+ ```
480
+
430
481
  ### File uploads
431
482
 
432
483
  Upload a file to a source (max 200 MiB). The SDK infers MIME type from the file extension when `mimeType` is not provided.
@@ -575,6 +626,11 @@ const model = await client.getModel("model_id");
575
626
  // Media-generation quality tiers (fast/balanced/thorough) and what each resolves to
576
627
  const tiers = await client.getGenerationTiers();
577
628
 
629
+ // Embedding and reranker models, with their pricing
630
+ const embedders = await client.listEmbeddingModels({ supportsInputMedia: "image" });
631
+ const rerankers = await client.listRerankerModels();
632
+ console.log(embedders.models, embedders.default_model_type, rerankers.models);
633
+
578
634
  const alerts = await client.listModelAlerts();
579
635
  await client.markModelAlertRead("alert_id");
580
636
  await client.markAllModelAlertsRead();
@@ -674,8 +730,9 @@ await client.submitAiFeedback({ ... });
674
730
 
675
731
  ## Pagination helper
676
732
 
677
- Automatically iterate through all pages:
733
+ Automatically iterate through all pages of a list method:
678
734
 
735
+ <!-- sdksync:check -->
679
736
  ```ts
680
737
  for await (const source of client.paginate(
681
738
  (opts) => client.listSources(opts),
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,23 @@ 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
+ 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
+ }
415
432
  async function safeText(response) {
416
433
  try {
417
434
  return await response.clone().text();
@@ -1970,6 +1987,55 @@ var Seclai = class {
1970
1987
  async uploadInlineTextToSource(sourceId, body) {
1971
1988
  return await this.request("POST", `/sources/${sourceId}`, { json: body });
1972
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
+ }
1973
2039
  // ─── Source Exports ────────────────────────────────────────────────────────
1974
2040
  /**
1975
2041
  * List exports for a source.
@@ -2566,6 +2632,31 @@ var Seclai = class {
2566
2632
  async getGenerationTiers() {
2567
2633
  return await this.request("GET", "/models/generation-tiers");
2568
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
+ }
2569
2660
  // ═══════════════════════════════════════════════════════════════════════════
2570
2661
  // Model Playground Experiments
2571
2662
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2615,6 +2706,88 @@ var Seclai = class {
2615
2706
  await this.request("DELETE", `/models/playground/experiments/${experimentId}`);
2616
2707
  }
2617
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
+ // ═══════════════════════════════════════════════════════════════════════════
2618
2791
  // Search
2619
2792
  // ═══════════════════════════════════════════════════════════════════════════
2620
2793
  /**
@@ -2853,18 +3026,20 @@ var Seclai = class {
2853
3026
  /**
2854
3027
  * Auto-paginate through a list endpoint.
2855
3028
  *
2856
- * Yields individual items from each page, automatically fetching the next page
2857
- * until all items have been returned.
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.
2858
3032
  *
2859
3033
  * @param fetchPage - A function that fetches a single page given `{ page, limit }`.
2860
3034
  * @param opts - Page size (default: 50).
3035
+ * @throws {@link SeclaiError} When a page carries its items under neither `data` nor `items`.
2861
3036
  *
2862
3037
  * @example
2863
3038
  * ```ts
2864
3039
  * for await (const agent of client.paginate(
2865
3040
  * (opts) => client.listAgents(opts),
2866
3041
  * )) {
2867
- * console.log(agent);
3042
+ * console.log(agent.name);
2868
3043
  * }
2869
3044
  * ```
2870
3045
  */
@@ -2873,11 +3048,29 @@ var Seclai = class {
2873
3048
  let page = 1;
2874
3049
  while (true) {
2875
3050
  const result = await fetchPage({ page, limit });
2876
- for (const item of result.items) {
2877
- yield item;
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
+ );
2878
3061
  }
2879
- if (!result.pagination || result.items.length < limit || page >= result.pagination.total_pages) {
2880
- break;
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;
2881
3074
  }
2882
3075
  page++;
2883
3076
  }