@seclai/sdk 1.6.1 → 1.7.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/dist/index.js CHANGED
@@ -7,10 +7,16 @@ var SeclaiApiVersion = {
7
7
  V2026_09_28: "2026-09-28",
8
8
  V2026_09_30: "2026-09-30",
9
9
  V2026_10_03: "2026-10-03",
10
+ V2026_10_05: "2026-10-05",
11
+ V2026_10_13: "2026-10-13",
12
+ V2026_10_16: "2026-10-16",
13
+ V2026_10_18: "2026-10-18",
14
+ V2026_10_19: "2026-10-19",
15
+ V2026_10_21: "2026-10-21",
10
16
  /** Baseline applied to an unpinned, header-less caller. */
11
17
  Default: "2026-07-01",
12
18
  /** Newest version known to this SDK release. May lag the server. */
13
- Latest: "2026-10-03"
19
+ Latest: "2026-10-21"
14
20
  };
15
21
  var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
16
22
 
@@ -1058,15 +1064,18 @@ var Seclai = class {
1058
1064
  * Run an agent in streaming mode (SSE) and wait for the final result.
1059
1065
  *
1060
1066
  * Consumes the entire SSE stream and returns only the terminal `done` payload.
1061
- * For real-time event access, use {@link runStreamingAgent} instead.
1067
+ * For real-time event access, use {@link runStreamingAgent} instead. The body
1068
+ * takes no `include_reasoning`, and one passed anyway is not sent: this method
1069
+ * returns no `stream_reasoning` events.
1062
1070
  *
1063
1071
  * @param agentId - Agent identifier.
1064
- * @param body - Streaming run request payload.
1072
+ * @param body - Streaming run request payload, without `include_reasoning`.
1065
1073
  * @param opts - Timeout and abort signal options.
1066
1074
  * @returns Final agent run payload from the `done` event.
1067
1075
  * @throws {@link SeclaiStreamingError} If the stream ends before a `done` event.
1068
1076
  */
1069
1077
  async runStreamingAgentAndWait(agentId, body, opts) {
1078
+ const { include_reasoning: _ignored, ...runBody } = body;
1070
1079
  const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
1071
1080
  const authHdrs = await this.authHeaders();
1072
1081
  const headers = this.requestHeaders([
@@ -1084,7 +1093,7 @@ var Seclai = class {
1084
1093
  const signal = anySignal([opts?.signal, timeoutController.signal]);
1085
1094
  let lastSeen;
1086
1095
  try {
1087
- const init = { method: "POST", headers, body: JSON.stringify(body) };
1096
+ const init = { method: "POST", headers, body: JSON.stringify(runBody) };
1088
1097
  if (signal) init.signal = signal;
1089
1098
  const response = await this.fetcher(url, init);
1090
1099
  const contentType = response.headers.get("content-type") ?? "";
@@ -1325,10 +1334,14 @@ var Seclai = class {
1325
1334
  // Agent Input Uploads
1326
1335
  // ═══════════════════════════════════════════════════════════════════════════
1327
1336
  /**
1328
- * Upload a file to use as input for a `dynamic_input` agent run.
1337
+ * Upload a file to use as input for a `dynamic_input` agent run. Any other
1338
+ * agent rejects the upload with HTTP 400. Files are limited to 200 MB.
1329
1339
  *
1330
- * After uploading, poll {@link getAgentInputUploadStatus} until `status` is `ready`,
1331
- * then pass `input_upload_id` to {@link runAgent}.
1340
+ * From API version `2026-10-16` a file of any type is accepted and is `ready`
1341
+ * at once: pass its `id` as `input_upload_id` to {@link runAgent}.
1342
+ * Earlier versions accept only a fixed list of extensions and write each
1343
+ * file's extracted text into the run's `input`, so poll
1344
+ * {@link getAgentInputUploadStatus} until `status` is `ready` before running.
1332
1345
  *
1333
1346
  * @param agentId - Agent identifier.
1334
1347
  * @param opts - File payload and optional metadata.
@@ -1370,12 +1383,16 @@ var Seclai = class {
1370
1383
  * @param runId - Run identifier.
1371
1384
  * @param attachmentId - URL-safe-base64-encoded `storage_key` of the attachment
1372
1385
  * (as surfaced in run output manifests and webhook/email payloads).
1373
- * @param opts - Optional `downloadName` filename hint for the download disposition.
1386
+ * @param opts - Optional `downloadName` filename hint for the download
1387
+ * disposition, and `signal`, which cancels the request; with a standard `fetch` this
1388
+ * includes reading the body, so `AbortSignal.timeout(ms)` bounds the whole
1389
+ * transfer.
1374
1390
  * @returns Raw response with the attachment bytes.
1375
1391
  */
1376
1392
  async downloadAgentRunAttachment(runId, attachmentId, opts = {}) {
1377
1393
  return await this.requestRaw("GET", `/v2/agent-runs/${runId}/attachments/${attachmentId}`, {
1378
- query: { download_name: opts.downloadName }
1394
+ query: { download_name: opts.downloadName },
1395
+ signal: opts.signal
1379
1396
  });
1380
1397
  }
1381
1398
  // ═══════════════════════════════════════════════════════════════════════════
@@ -1620,6 +1637,24 @@ var Seclai = class {
1620
1637
  json: body
1621
1638
  });
1622
1639
  }
1640
+ /**
1641
+ * Replace the input attachments a trigger accepts.
1642
+ *
1643
+ * A run's files are each assigned to one declared attachment before any step
1644
+ * runs, and steps reference one as `{{agent.attachments.<name>}}`. The API
1645
+ * answers 400 when the agent references an attachment the new declaration
1646
+ * leaves out.
1647
+ *
1648
+ * @param agentId - Agent identifier.
1649
+ * @param triggerId - Trigger identifier, as `getAgent()` returns it.
1650
+ * @param body - The full list of accepted attachments; a slot's `min` defaults to 0.
1651
+ * @returns The trigger's accepted attachments.
1652
+ */
1653
+ async setAcceptedAttachments(agentId, triggerId, body) {
1654
+ return await this.request("PUT", `/agents/${agentId}/triggers/${triggerId}/accepted-attachments`, {
1655
+ json: body
1656
+ });
1657
+ }
1623
1658
  // ═══════════════════════════════════════════════════════════════════════════
1624
1659
  // Agent Email Governance
1625
1660
  // ═══════════════════════════════════════════════════════════════════════════
@@ -2069,6 +2104,24 @@ var Seclai = class {
2069
2104
  `/sources/${sourceId}/contents/${contentVersionId}`
2070
2105
  );
2071
2106
  }
2107
+ /**
2108
+ * List mail an email content source refused, newest first.
2109
+ *
2110
+ * Each entry says who sent the message and why it was refused, never its
2111
+ * subject or body. To accept a refused sender, add its `from_address` or that
2112
+ * address's domain to the source's `email_allowed_senders` — which only helps
2113
+ * when `authenticated` is true. Requires an account owner or administrator;
2114
+ * the API answers 404 for a source that is not an email source.
2115
+ *
2116
+ * @param sourceId - Source connection identifier.
2117
+ * @param opts - Pagination options (`limit` 1-100).
2118
+ * @returns The rejections under `data` with `pagination`.
2119
+ */
2120
+ async listEmailSourceRejections(sourceId, opts = {}) {
2121
+ return await this.request("GET", `/sources/${sourceId}/email-rejections`, {
2122
+ query: { page: opts.page, limit: opts.limit }
2123
+ });
2124
+ }
2072
2125
  // ─── Source Exports ────────────────────────────────────────────────────────
2073
2126
  /**
2074
2127
  * List exports for a source.
@@ -2118,10 +2171,15 @@ var Seclai = class {
2118
2171
  *
2119
2172
  * @param sourceId - Source connection identifier.
2120
2173
  * @param exportId - Export identifier.
2174
+ * @param opts - Optional `signal`, which cancels the request; with a standard `fetch` this
2175
+ * includes reading the body, so `AbortSignal.timeout(ms)` bounds the whole
2176
+ * transfer.
2121
2177
  * @returns Raw response with the export file.
2122
2178
  */
2123
- async downloadSourceExport(sourceId, exportId) {
2124
- return await this.requestRaw("GET", `/sources/${sourceId}/exports/${exportId}/download`);
2179
+ async downloadSourceExport(sourceId, exportId, opts = {}) {
2180
+ return await this.requestRaw("GET", `/sources/${sourceId}/exports/${exportId}/download`, {
2181
+ signal: opts.signal
2182
+ });
2125
2183
  }
2126
2184
  /**
2127
2185
  * Estimate a source export.
@@ -2215,6 +2273,79 @@ var Seclai = class {
2215
2273
  query: { page: opts.page ?? 1, limit: opts.limit ?? 20 }
2216
2274
  });
2217
2275
  }
2276
+ /**
2277
+ * List the files attached to a content item.
2278
+ *
2279
+ * Files arrive from an agent's `write_content_attachment` step, with an email
2280
+ * message, from an RSS feed's `feed_attachments`, from a web page's media, or
2281
+ * as the images inside a document. Each entry says whether it is indexed for
2282
+ * search and, when indexing failed, why.
2283
+ *
2284
+ * @param contentVersionId - Content version identifier.
2285
+ * @param opts - Pagination options.
2286
+ * @returns The attachments under `data` with `pagination`.
2287
+ */
2288
+ async listContentAttachments(contentVersionId, opts = {}) {
2289
+ return await this.request("GET", `/contents/${contentVersionId}/attachments`, {
2290
+ query: { page: opts.page, limit: opts.limit }
2291
+ });
2292
+ }
2293
+ /**
2294
+ * Get one file attached to a content item: its indexing status and reason,
2295
+ * its metadata, and the text it is indexed by.
2296
+ *
2297
+ * @param contentVersionId - Content version identifier.
2298
+ * @param attachmentId - The `id` of an entry from {@link listContentAttachments}.
2299
+ * @param opts - `start` and `end` character offsets for paging through long text
2300
+ * (server defaults 0 and 5000). Both are sent as given, so `end: 0` asks for
2301
+ * the metadata without any text. A file that was not indexed has no text.
2302
+ * @returns The attachment with the requested range of its text.
2303
+ * @throws {SeclaiAPIStatusError} 402 when the account has no credits left
2304
+ * (`error.code` `insufficient_credits`).
2305
+ */
2306
+ async getContentAttachment(contentVersionId, attachmentId, opts = {}) {
2307
+ return await this.request("GET", `/contents/${contentVersionId}/attachments/${attachmentId}`, {
2308
+ query: { start: opts.start, end: opts.end }
2309
+ });
2310
+ }
2311
+ /**
2312
+ * List the embeddings (chunk vectors) a content attachment is indexed by.
2313
+ * The list is empty for a file that has no completed index.
2314
+ *
2315
+ * @param contentVersionId - Content version identifier.
2316
+ * @param attachmentId - Attachment identifier.
2317
+ * @param opts - Pagination options (`limit` 1-100).
2318
+ * @returns Paginated list of embeddings.
2319
+ * @throws {SeclaiAPIStatusError} 402 when the account has no credits left
2320
+ * (`error.code` `insufficient_credits`).
2321
+ */
2322
+ async listContentAttachmentEmbeddings(contentVersionId, attachmentId, opts = {}) {
2323
+ return await this.request("GET", `/contents/${contentVersionId}/attachments/${attachmentId}/embeddings`, {
2324
+ query: { page: opts.page, limit: opts.limit }
2325
+ });
2326
+ }
2327
+ /**
2328
+ * Download a content attachment's bytes.
2329
+ *
2330
+ * Returns the raw `Response` so you can stream or save the binary data. The
2331
+ * API answers 403 when the file is withheld — blocked or redacted by a
2332
+ * governance policy, or still being indexed after arriving from outside; the
2333
+ * attachment's `file_withheld` field says which before you ask.
2334
+ *
2335
+ * @param contentVersionId - Content version identifier.
2336
+ * @param attachmentId - Attachment identifier.
2337
+ * @param opts - Optional `signal`, which cancels the request; with a standard `fetch` this
2338
+ * includes reading the body, so `AbortSignal.timeout(ms)` bounds the whole
2339
+ * transfer.
2340
+ * @returns Raw response with the attachment bytes.
2341
+ * @throws {SeclaiAPIStatusError} 403 when the file is withheld, and 402 when
2342
+ * the account has no credits left (`error.code` `insufficient_credits`).
2343
+ */
2344
+ async downloadContentAttachment(contentVersionId, attachmentId, opts = {}) {
2345
+ return await this.requestRaw("GET", `/contents/${contentVersionId}/attachments/${attachmentId}/file`, {
2346
+ signal: opts.signal
2347
+ });
2348
+ }
2218
2349
  /**
2219
2350
  * Upload a file to replace content for an existing content version.
2220
2351
  *