@seclai/sdk 1.9.0 → 1.10.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 +17 -0
- package/README.md +80 -12
- package/dist/index.cjs +127 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -34
- package/dist/index.d.ts +124 -34
- package/dist/index.js +127 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.10.0] - 2026-11-27
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Sync the bundled OpenAPI spec and regenerate the types. `PendingProcessingCompletedFailedStatus`, the `status` of `AgentRunResponse`, `AgentRunStepResponse` and `AgentRunAttemptResponse`, gains `cancelled`. The run status union can gain values in a minor release, so an exhaustive `switch` or a `Record` keyed by it should handle values it does not know. A tier `getGenerationTiers()` returns can now carry `aspect_ratios`, the aspect ratios an image tier's model can be asked for
|
|
8
|
+
- Move `SeclaiApiVersion.Latest` to `2026-11-19`. Nothing is sent unless `apiVersion` is set, so a client that passes `SeclaiApiVersion.Latest` now opts into the four versions added below: from `2026-11-08`, a run cancelled with `cancelAgentRun()` or `cancelQueuedEmailRuns()` ends with `status` `cancelled` instead of `failed`; from `2026-11-09`, `listAgentExamples()` reads `query` as a description of what the agent should do and returns entries ranked by how well they match it, best first, where older versions return only entries containing every word; from `2026-11-14`, `runAgent()`, `runStreamingAgent()` and the helpers built on them are refused with a 409, and no run is created, for an agent whose definition fails to validate, where older versions return the run already failed with the validation error as its cause; and from `2026-11-19`, `createAlertConfig()` accepts the agent alert type `step_failure_continued`
|
|
9
|
+
- Note API changes that apply on every API version, whatever `apiVersion` is set: `cancelAgentRun()` also cancels a `pending`, `waiting_human` or `waiting_scheduled` run, and cancelling a run started by another agent's `call_agent` step that is still waiting for it ends the outermost calling run, and every run below it that has not reported its result
|
|
10
|
+
- Describe a run's answer as the output of the step carrying `run_result`, as the API reference now does, in place of a `streaming_result` or `display_result` step: from `2026-11-04` the `step_id` of a criterion passed to `createEvaluationCriteria()` or `updateEvaluationCriteria()` must name the step carrying `run_result`
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add the `rangeStart`, `rangeEnd` and `rangeSuffix` options to `downloadAgentRunAttachment()`, to download one byte range of an attachment: `rangeStart` alone reads to the end of the file, with `rangeEnd` (inclusive) it reads that span, and `rangeSuffix` alone reads the last that many bytes. The server answers with status 206 and `Content-Range`, or 200 and the whole file when the file is empty, and a range starting at or past the end of a non-empty file throws `SeclaiAPIStatusError` with `statusCode` 416. Any other combination, a `rangeEnd` below `rangeStart`, a negative `rangeStart` or `rangeEnd`, a `rangeSuffix` below 1, or a value that is not a safe integer (`Number.isSafeInteger`), throws `SeclaiConfigurationError` before a request is sent. With none set, the request is unchanged and the SDK adds no `Range` header
|
|
15
|
+
- Add `headers` to `SeclaiAPIStatusError` and `SeclaiAPIValidationError`: the error response's headers as a `Headers` object, such as `Retry-After` on a 503, or on a 416 from a ranged `downloadAgentRunAttachment()` a `Content-Range` ending in `/<size>`, the file's size in bytes. It is set on every request path, including uploads, raw downloads and streaming runs, and is an empty `Headers` when the error is constructed without them. In a browser, only the headers the server's CORS policy exposes are present
|
|
16
|
+
- Add `include_commentary` to the `runStreamingAgent()` request, to receive `stream_commentary` events carrying the text a model on OpenAI's Responses API writes outside its final answer, for a `prompt_call` step whose `run_result` enables `show_commentary`. `runStreamingAgentAndWait()`, which returns no such events, does not take it and does not send one passed anyway
|
|
17
|
+
- Add the `SeclaiApiVersion.V2026_11_08`, `SeclaiApiVersion.V2026_11_09`, `SeclaiApiVersion.V2026_11_14` and `SeclaiApiVersion.V2026_11_19` constants, so those versions are accepted as `apiVersion`
|
|
18
|
+
|
|
3
19
|
## [1.9.0] - 2026-11-05
|
|
4
20
|
|
|
5
21
|
### Changed
|
|
@@ -292,6 +308,7 @@ _Stable release. No functional changes since 0.0.1._
|
|
|
292
308
|
|
|
293
309
|
_Initial release._
|
|
294
310
|
|
|
311
|
+
[1.10.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.10.0
|
|
295
312
|
[1.9.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.9.0
|
|
296
313
|
[1.8.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.8.0
|
|
297
314
|
[1.7.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.7.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.
|
|
107
|
+
https://seclai.github.io/seclai-javascript/1.10.0/
|
|
108
108
|
|
|
109
109
|
Release history is in [`CHANGELOG.md`](CHANGELOG.md).
|
|
110
110
|
|
|
@@ -127,7 +127,7 @@ 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` through `
|
|
130
|
+
Known versions are on `SeclaiApiVersion` (`V2026_07_01` through `V2026_11_19`,
|
|
131
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.
|
|
@@ -193,6 +193,15 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
|
|
|
193
193
|
- `2026-11-02` refuses an agent write that references a metadata key no trigger
|
|
194
194
|
declares, where older versions declare the key for you.
|
|
195
195
|
- `2026-11-04` rejects with a 400 evaluation settings that were accepted before.
|
|
196
|
+
- `2026-11-08` changes a value you may branch on: a cancelled agent run reports
|
|
197
|
+
`status` `cancelled` instead of `failed`.
|
|
198
|
+
- `2026-11-09` changes which gallery entries `listAgentExamples()` returns for a
|
|
199
|
+
`query`, and their order.
|
|
200
|
+
- `2026-11-14` refuses with a 409, and no run, a run of an agent whose
|
|
201
|
+
definition fails to validate, where older versions return a run that has
|
|
202
|
+
already failed.
|
|
203
|
+
- `2026-11-19` accepts a new agent alert type, `step_failure_continued`, in
|
|
204
|
+
`createAlertConfig()`.
|
|
196
205
|
|
|
197
206
|
| Version | What it changes |
|
|
198
207
|
| --- | --- |
|
|
@@ -209,7 +218,11 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
|
|
|
209
218
|
| `2026-10-21` | An evaluation result whose evaluator returned no verdict (`error`) is left out of `failed` and of `pass_rate` / `failure_rate` in `getNonManualEvaluationSummary()`, and `getEvaluationCriteriaSummary()` averages `average_score` over passed and failed results only. `testDraftEvaluation()` returns `score` and `passed` as `null` for an `error` result. Below it the summary counts `error` results in `failed` and the rates, `average_score` includes their stored scores, and the test draft returns `score` 0.5 and `passed: false`. The summary's `error` count is returned on every version |
|
|
210
219
|
| `2026-10-28` | An `if_else` or `switch` step's `output` is the result of the arm it took, or its input when that arm is empty or it took none. Below it the `output` is a `{"branch": ...}` marker naming the arm, with no `attachments`. The step's `decision` names the arm on every version |
|
|
211
220
|
| `2026-11-02` | `updateAgentDefinition()`, and `updateAgent()` when it sets `sampling_config`, refuse a definition or sampling rule that references a metadata key no trigger declares, with a 400 and a 422 respectively. Declare the key first with `setMetadataKeys()`. An `agent_definition` import through `createAgent()` or `updateAgent()` is not refused and still declares the keys it reads. Below it each such key is declared on the trigger as optional |
|
|
212
|
-
| `2026-11-04` | `createEvaluationResult()` rejects `retry_triggered: true` and `updateAgent()` rejects `evaluation_mode` `eval_and_retry` with a 400: evaluations never retry a step. `createEvaluationCriteria()`, and `updateEvaluationCriteria()` when it changes `step_id`, reject a `step_id` that does not name
|
|
221
|
+
| `2026-11-04` | `createEvaluationResult()` rejects `retry_triggered: true` and `updateAgent()` rejects `evaluation_mode` `eval_and_retry` with a 400: evaluations never retry a step. `createEvaluationCriteria()`, and `updateEvaluationCriteria()` when it changes `step_id`, reject a `step_id` that does not name the step carrying `run_result` with a 400. Below it `eval_and_retry` is stored as `sample_and_flag` |
|
|
222
|
+
| `2026-11-08` | An agent run cancelled with `cancelAgentRun()` or `cancelQueuedEmailRuns()` ends with `status` `cancelled`. Below it the run ends `failed`. `runAgentAndPoll()` and `runStreamingAgentAndWait()` treat both as the end of the run |
|
|
223
|
+
| `2026-11-09` | `listAgentExamples()` reads `query` as a description of what the agent should do and returns entries ranked by how well they match it, in words and meaning, best first; a query of several words that are all filler ("create an agent") counts as no query. Below it only entries containing every word of `query` are returned |
|
|
224
|
+
| `2026-11-14` | `runAgent()`, `runStreamingAgent()` and the helpers built on them are refused with a 409, and no run is created, for an agent whose definition fails to validate. Below it the run is returned, already failed with the validation error as its cause |
|
|
225
|
+
| `2026-11-19` | `createAlertConfig()` accepts the agent alert type `step_failure_continued` |
|
|
213
226
|
|
|
214
227
|
**`Latest` moves with the SDK.** `SeclaiApiVersion.Latest` is the newest version
|
|
215
228
|
the installed release knows, so upgrading the package can opt a client that
|
|
@@ -218,9 +231,12 @@ passes it into every version added since — `1.6.0` moved it from `2026-07-27`
|
|
|
218
231
|
`2026-10-21`, across the `2026-10-05` status change, the `2026-10-13` and
|
|
219
232
|
`2026-10-19` source-setting rejections, the `2026-10-16` input change and the
|
|
220
233
|
`2026-10-21` evaluation change, `1.8.0` moves it to `2026-10-28`,
|
|
221
|
-
across the `if_else` / `switch` step-output change,
|
|
234
|
+
across the `if_else` / `switch` step-output change, `1.9.0` moves it to
|
|
222
235
|
`2026-11-04`, across the `2026-11-02` undeclared-metadata-key refusal and the
|
|
223
|
-
`2026-11-04` evaluation-setting rejections.
|
|
236
|
+
`2026-11-04` evaluation-setting rejections, and `1.10.0` moves it to
|
|
237
|
+
`2026-11-19`, across the `2026-11-08` `cancelled` run status, the `2026-11-09`
|
|
238
|
+
gallery ranking, the `2026-11-14` refusal of an agent that fails to
|
|
239
|
+
validate and the `2026-11-19` `step_failure_continued` alert type. Pass a
|
|
224
240
|
dated constant such as `SeclaiApiVersion.V2026_07_27` to keep behaviour fixed
|
|
225
241
|
across upgrades.
|
|
226
242
|
|
|
@@ -431,23 +447,30 @@ try {
|
|
|
431
447
|
```
|
|
432
448
|
|
|
433
449
|
Pass `include_reasoning: true` to also receive `stream_reasoning` events carrying
|
|
434
|
-
the model's reasoning while it thinks
|
|
435
|
-
`
|
|
436
|
-
|
|
450
|
+
the model's reasoning while it thinks, and `include_commentary: true` to receive
|
|
451
|
+
`stream_commentary` events carrying the text a model on OpenAI's Responses API
|
|
452
|
+
writes outside its final answer, with its `phase` and `message` number. They are
|
|
453
|
+
sent only for a `prompt_call` step whose `run_result` enables `show_reasoning`
|
|
454
|
+
or `show_commentary` respectively, never when a governance policy redacts that
|
|
455
|
+
step, and neither is part of `output`. `runStreamingAgentAndWait()` returns no
|
|
456
|
+
such events and does not send either key:
|
|
437
457
|
|
|
438
458
|
<!-- sdksync:check -->
|
|
439
459
|
```ts
|
|
440
460
|
for await (const event of client.runStreamingAgent("agent_id", {
|
|
441
461
|
input: "Hello",
|
|
442
462
|
include_reasoning: true,
|
|
463
|
+
include_commentary: true,
|
|
443
464
|
})) {
|
|
444
465
|
if (event.event === "stream_reasoning") console.log(event.data);
|
|
466
|
+
if (event.event === "stream_commentary") console.log(event.data);
|
|
445
467
|
}
|
|
446
468
|
```
|
|
447
469
|
|
|
448
470
|
### Polling
|
|
449
471
|
|
|
450
|
-
For environments where SSE is not practical, poll
|
|
472
|
+
For environments where SSE is not practical, poll until the run ends with
|
|
473
|
+
`status` `completed`, `failed` or `cancelled`:
|
|
451
474
|
|
|
452
475
|
```ts
|
|
453
476
|
const result = await client.runAgentAndPoll(
|
|
@@ -506,12 +529,57 @@ Only a `dynamic_input` agent takes uploads; any other agent rejects one with a
|
|
|
506
529
|
|
|
507
530
|
<!-- sdksync:check -->
|
|
508
531
|
```ts
|
|
509
|
-
// Download a file
|
|
510
|
-
// URL-safe-base64
|
|
532
|
+
// Download a file of an agent run. attachment_id is the `id` of an entry in the
|
|
533
|
+
// run's or a step's `attachments`, or the URL-safe-base64 storage key that
|
|
534
|
+
// webhook and email links carry.
|
|
511
535
|
const resp = await client.downloadAgentRunAttachment("run_id", "attachment_id");
|
|
512
536
|
const blob = await resp.blob(); // raw Response — stream or save the bytes
|
|
513
537
|
```
|
|
514
538
|
|
|
539
|
+
To fetch part of a file, set a byte range. Offsets are zero-based and
|
|
540
|
+
`rangeEnd` is inclusive: `rangeStart` alone reads to the end of the file,
|
|
541
|
+
`rangeStart` with `rangeEnd` reads that span, and `rangeSuffix` alone reads the
|
|
542
|
+
last that many bytes. The server answers a range with status 206 and a
|
|
543
|
+
`Content-Range` header, and a range of an empty file with 200 and the whole
|
|
544
|
+
(empty) file, so check `status` before treating the body as the whole file.
|
|
545
|
+
|
|
546
|
+
<!-- sdksync:check -->
|
|
547
|
+
```ts
|
|
548
|
+
const part = await client.downloadAgentRunAttachment("run_id", "attachment_id", {
|
|
549
|
+
rangeStart: 0,
|
|
550
|
+
rangeEnd: 1023, // the first 1 KiB
|
|
551
|
+
});
|
|
552
|
+
if (part.status === 206) {
|
|
553
|
+
console.log(part.headers.get("content-range")); // e.g. "bytes 0-1023/52341"
|
|
554
|
+
}
|
|
555
|
+
const tail = await client.downloadAgentRunAttachment("run_id", "attachment_id", {
|
|
556
|
+
rangeSuffix: 512, // the last 512 bytes
|
|
557
|
+
});
|
|
558
|
+
console.log((await tail.arrayBuffer()).byteLength);
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
A range that starts at or past the end of a non-empty file throws
|
|
562
|
+
`SeclaiAPIStatusError` with `statusCode` 416. The error's `headers` field holds
|
|
563
|
+
the response headers, and its `Content-Range` ends in `/<size>`, the file's size
|
|
564
|
+
in bytes (in a browser, only if the server's CORS policy exposes it).
|
|
565
|
+
|
|
566
|
+
```ts
|
|
567
|
+
import { SeclaiAPIStatusError } from "@seclai/sdk";
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
await client.downloadAgentRunAttachment("run_id", "attachment_id", { rangeStart: 52341 });
|
|
571
|
+
} catch (err) {
|
|
572
|
+
if (err instanceof SeclaiAPIStatusError && err.statusCode === 416) {
|
|
573
|
+
console.log(err.headers.get("content-range")); // e.g. "bytes */52341"
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Any other combination (`rangeEnd` without `rangeStart`, `rangeSuffix` with
|
|
579
|
+
either, `rangeEnd` below `rangeStart`, a negative `rangeStart` or `rangeEnd`, a
|
|
580
|
+
`rangeSuffix` below 1, or a value that is not a safe integer) throws `SeclaiConfigurationError` before a request is
|
|
581
|
+
sent.
|
|
582
|
+
|
|
515
583
|
### Agent email triggers
|
|
516
584
|
|
|
517
585
|
Configure the inbound address and handling rules on an agent's `EMAIL_RECEIVED`
|
|
@@ -626,7 +694,7 @@ const rejections = await client.listInboundEmailRejections({ agentId: "agent_id"
|
|
|
626
694
|
|
|
627
695
|
// Account-wide overload circuit breaker
|
|
628
696
|
const status = await client.getInboundEmailStatus(); // { paused, queued_backlog }
|
|
629
|
-
await client.cancelQueuedEmailRuns(); //
|
|
697
|
+
await client.cancelQueuedEmailRuns(); // cancel all QUEUED (over-quota parked) runs
|
|
630
698
|
await client.resumeInboundEmail(); // one-shot override; re-arms if still overloaded
|
|
631
699
|
```
|
|
632
700
|
|
package/dist/index.cjs
CHANGED
|
@@ -67,10 +67,14 @@ var SeclaiApiVersion = {
|
|
|
67
67
|
V2026_10_28: "2026-10-28",
|
|
68
68
|
V2026_11_02: "2026-11-02",
|
|
69
69
|
V2026_11_04: "2026-11-04",
|
|
70
|
+
V2026_11_08: "2026-11-08",
|
|
71
|
+
V2026_11_09: "2026-11-09",
|
|
72
|
+
V2026_11_14: "2026-11-14",
|
|
73
|
+
V2026_11_19: "2026-11-19",
|
|
70
74
|
/** Baseline applied to an unpinned, header-less caller. */
|
|
71
75
|
Default: "2026-07-01",
|
|
72
76
|
/** Newest version known to this SDK release. May lag the server. */
|
|
73
|
-
Latest: "2026-11-
|
|
77
|
+
Latest: "2026-11-19"
|
|
74
78
|
};
|
|
75
79
|
var KNOWN_API_VERSIONS = Object.entries(SeclaiApiVersion).filter(([k]) => k.startsWith("V")).map(([, v]) => v);
|
|
76
80
|
|
|
@@ -96,6 +100,14 @@ var SeclaiAPIStatusError = class extends SeclaiError {
|
|
|
96
100
|
url;
|
|
97
101
|
/** Best-effort response body text (if available). */
|
|
98
102
|
responseText;
|
|
103
|
+
/**
|
|
104
|
+
* Headers of the error response, such as `Retry-After` on a 503, or
|
|
105
|
+
* `Content-Range` on a 416 from a ranged `downloadAgentRunAttachment()`, whose
|
|
106
|
+
* value ends in `/<size>`, the file's size in bytes. Empty when the response
|
|
107
|
+
* headers are unknown. In a browser, only the headers the server's CORS policy
|
|
108
|
+
* exposes are present.
|
|
109
|
+
*/
|
|
110
|
+
headers;
|
|
99
111
|
constructor(opts) {
|
|
100
112
|
super(opts.message);
|
|
101
113
|
this.name = "SeclaiAPIStatusError";
|
|
@@ -103,6 +115,7 @@ var SeclaiAPIStatusError = class extends SeclaiError {
|
|
|
103
115
|
this.method = opts.method;
|
|
104
116
|
this.url = opts.url;
|
|
105
117
|
this.responseText = opts.responseText;
|
|
118
|
+
this.headers = opts.headers ?? new Headers();
|
|
106
119
|
}
|
|
107
120
|
};
|
|
108
121
|
var SeclaiAPIValidationError = class extends SeclaiAPIStatusError {
|
|
@@ -480,6 +493,34 @@ function mergeHeaders(...layers) {
|
|
|
480
493
|
function headerKey(headers, name) {
|
|
481
494
|
return Object.keys(headers ?? {}).filter((key) => key.toLowerCase() === name).pop();
|
|
482
495
|
}
|
|
496
|
+
function byteRangeHeader(start, end, suffix) {
|
|
497
|
+
const hasStart = start !== void 0 && start !== null;
|
|
498
|
+
const hasEnd = end !== void 0 && end !== null;
|
|
499
|
+
const hasSuffix = suffix !== void 0 && suffix !== null;
|
|
500
|
+
if (!hasStart && !hasEnd && !hasSuffix) return void 0;
|
|
501
|
+
const fail = (why) => {
|
|
502
|
+
throw new SeclaiConfigurationError(`Invalid byte range: ${why}`);
|
|
503
|
+
};
|
|
504
|
+
if (hasSuffix) {
|
|
505
|
+
if (hasStart || hasEnd) fail("rangeSuffix cannot be combined with rangeStart or rangeEnd.");
|
|
506
|
+
if (!Number.isSafeInteger(suffix) || suffix < 1) {
|
|
507
|
+
fail(`rangeSuffix must be a whole number of at least 1, got ${String(suffix)}.`);
|
|
508
|
+
}
|
|
509
|
+
return `bytes=-${suffix}`;
|
|
510
|
+
}
|
|
511
|
+
if (!hasStart) fail("rangeEnd requires rangeStart; use rangeSuffix for the last bytes of the file.");
|
|
512
|
+
if (!Number.isSafeInteger(start) || start < 0) {
|
|
513
|
+
fail(`rangeStart must be a whole number of at least 0, got ${String(start)}.`);
|
|
514
|
+
}
|
|
515
|
+
if (!hasEnd) return `bytes=${start}-`;
|
|
516
|
+
if (!Number.isSafeInteger(end) || end < 0) {
|
|
517
|
+
fail(`rangeEnd must be a whole number of at least 0, got ${String(end)}.`);
|
|
518
|
+
}
|
|
519
|
+
if (end < start) {
|
|
520
|
+
fail(`rangeEnd (${end}) must not be less than rangeStart (${start}).`);
|
|
521
|
+
}
|
|
522
|
+
return `bytes=${start}-${end}`;
|
|
523
|
+
}
|
|
483
524
|
async function safeText(response) {
|
|
484
525
|
try {
|
|
485
526
|
return await response.clone().text();
|
|
@@ -746,6 +787,7 @@ var Seclai = class {
|
|
|
746
787
|
method,
|
|
747
788
|
url: url.toString(),
|
|
748
789
|
responseText,
|
|
790
|
+
headers: new Headers(response.headers),
|
|
749
791
|
validationError: validation
|
|
750
792
|
});
|
|
751
793
|
}
|
|
@@ -754,7 +796,8 @@ var Seclai = class {
|
|
|
754
796
|
statusCode: response.status,
|
|
755
797
|
method,
|
|
756
798
|
url: url.toString(),
|
|
757
|
-
responseText
|
|
799
|
+
responseText,
|
|
800
|
+
headers: new Headers(response.headers)
|
|
758
801
|
});
|
|
759
802
|
}
|
|
760
803
|
if (!response.body) return null;
|
|
@@ -801,6 +844,7 @@ var Seclai = class {
|
|
|
801
844
|
method,
|
|
802
845
|
url: url.toString(),
|
|
803
846
|
responseText,
|
|
847
|
+
headers: new Headers(response.headers),
|
|
804
848
|
validationError: validation
|
|
805
849
|
});
|
|
806
850
|
}
|
|
@@ -809,7 +853,8 @@ var Seclai = class {
|
|
|
809
853
|
statusCode: response.status,
|
|
810
854
|
method,
|
|
811
855
|
url: url.toString(),
|
|
812
|
-
responseText
|
|
856
|
+
responseText,
|
|
857
|
+
headers: new Headers(response.headers)
|
|
813
858
|
});
|
|
814
859
|
}
|
|
815
860
|
return response;
|
|
@@ -840,6 +885,7 @@ var Seclai = class {
|
|
|
840
885
|
method: "POST",
|
|
841
886
|
url: url.toString(),
|
|
842
887
|
responseText,
|
|
888
|
+
headers: new Headers(response.headers),
|
|
843
889
|
validationError: validation
|
|
844
890
|
});
|
|
845
891
|
}
|
|
@@ -848,7 +894,8 @@ var Seclai = class {
|
|
|
848
894
|
statusCode: response.status,
|
|
849
895
|
method: "POST",
|
|
850
896
|
url: url.toString(),
|
|
851
|
-
responseText
|
|
897
|
+
responseText,
|
|
898
|
+
headers: new Headers(response.headers)
|
|
852
899
|
});
|
|
853
900
|
}
|
|
854
901
|
return await response.json();
|
|
@@ -914,6 +961,10 @@ var Seclai = class {
|
|
|
914
961
|
/**
|
|
915
962
|
* List the agent gallery: example agents to start from.
|
|
916
963
|
*
|
|
964
|
+
* From `apiVersion` `2026-11-09`, `query` describes what the agent should do
|
|
965
|
+
* and entries come back ranked by how well they match it, best first. Before
|
|
966
|
+
* it, only entries containing every word of `query` are returned.
|
|
967
|
+
*
|
|
917
968
|
* Pass an entry's `key` as `agent_template` to {@link createAgent}, with
|
|
918
969
|
* `resource_bindings` for the resources it needs.
|
|
919
970
|
*
|
|
@@ -1067,6 +1118,11 @@ var Seclai = class {
|
|
|
1067
1118
|
/**
|
|
1068
1119
|
* Start an agent run.
|
|
1069
1120
|
*
|
|
1121
|
+
* From `apiVersion` `2026-11-14`, an agent whose definition fails to validate
|
|
1122
|
+
* is refused with HTTP 409 ({@link SeclaiAPIStatusError}) and no run is
|
|
1123
|
+
* created; earlier versions return the run, already failed with the
|
|
1124
|
+
* validation error as its cause.
|
|
1125
|
+
*
|
|
1070
1126
|
* @param agentId - Agent identifier.
|
|
1071
1127
|
* @param body - Run request payload (`input`, `metadata`, `priority`, etc.).
|
|
1072
1128
|
* @returns The created agent run.
|
|
@@ -1120,14 +1176,17 @@ var Seclai = class {
|
|
|
1120
1176
|
await this.cancelAgentRun(runId);
|
|
1121
1177
|
}
|
|
1122
1178
|
/**
|
|
1123
|
-
* Cancel
|
|
1179
|
+
* Cancel an agent run that has not ended: `queued`, `pending`, `processing`,
|
|
1180
|
+
* `waiting_human` or `waiting_scheduled`.
|
|
1124
1181
|
*
|
|
1125
1182
|
* Cancellation is `DELETE` on the run resource — the API exposes no
|
|
1126
1183
|
* `POST .../cancel` route, and no operation that deletes a run. Rejected when
|
|
1127
|
-
* the run has already
|
|
1184
|
+
* the run has already ended (`completed`, `failed` or `cancelled`). From
|
|
1185
|
+
* `apiVersion` `2026-11-08` the cancelled run ends with status `cancelled`;
|
|
1186
|
+
* on earlier versions it ends `failed`.
|
|
1128
1187
|
*
|
|
1129
1188
|
* @param runId - Run identifier.
|
|
1130
|
-
* @returns
|
|
1189
|
+
* @returns The updated run.
|
|
1131
1190
|
*/
|
|
1132
1191
|
async cancelAgentRun(runId) {
|
|
1133
1192
|
return await this.request("DELETE", `/agents/runs/${runId}`);
|
|
@@ -1140,8 +1199,9 @@ var Seclai = class {
|
|
|
1140
1199
|
*
|
|
1141
1200
|
* Consumes the entire SSE stream and returns only the terminal `done` payload.
|
|
1142
1201
|
* For real-time event access, use {@link runStreamingAgent} instead. The body
|
|
1143
|
-
* takes no `include_reasoning`, and one passed anyway
|
|
1144
|
-
* returns no `stream_reasoning`
|
|
1202
|
+
* takes no `include_reasoning` or `include_commentary`, and one passed anyway
|
|
1203
|
+
* is not sent: this method returns no `stream_reasoning` or
|
|
1204
|
+
* `stream_commentary` events.
|
|
1145
1205
|
*
|
|
1146
1206
|
* A `result` event carries the run's answer in `output` once
|
|
1147
1207
|
* `result_reported_at` is set, and can arrive while later steps still run.
|
|
@@ -1163,7 +1223,8 @@ var Seclai = class {
|
|
|
1163
1223
|
* version.
|
|
1164
1224
|
*
|
|
1165
1225
|
* @param agentId - Agent identifier.
|
|
1166
|
-
* @param body - Streaming run request payload, without `include_reasoning
|
|
1226
|
+
* @param body - Streaming run request payload, without `include_reasoning`
|
|
1227
|
+
* or `include_commentary`.
|
|
1167
1228
|
* @param opts - Timeout, abort signal and `returnOnResult` options.
|
|
1168
1229
|
* @returns The run from the `done` event; with `returnOnResult`, the
|
|
1169
1230
|
* `result` snapshot; without `throwOnIncomplete`, possibly an unfinished
|
|
@@ -1185,7 +1246,11 @@ var Seclai = class {
|
|
|
1185
1246
|
* ```
|
|
1186
1247
|
*/
|
|
1187
1248
|
async runStreamingAgentAndWait(agentId, body, opts) {
|
|
1188
|
-
const {
|
|
1249
|
+
const {
|
|
1250
|
+
include_reasoning: _reasoning,
|
|
1251
|
+
include_commentary: _commentary,
|
|
1252
|
+
...runBody
|
|
1253
|
+
} = body;
|
|
1189
1254
|
const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);
|
|
1190
1255
|
const authHdrs = await this.authHeaders();
|
|
1191
1256
|
const headers = this.requestHeaders([
|
|
@@ -1219,6 +1284,7 @@ var Seclai = class {
|
|
|
1219
1284
|
method: "POST",
|
|
1220
1285
|
url: url.toString(),
|
|
1221
1286
|
responseText,
|
|
1287
|
+
headers: new Headers(response.headers),
|
|
1222
1288
|
validationError: validation
|
|
1223
1289
|
});
|
|
1224
1290
|
}
|
|
@@ -1227,7 +1293,8 @@ var Seclai = class {
|
|
|
1227
1293
|
statusCode: response.status,
|
|
1228
1294
|
method: "POST",
|
|
1229
1295
|
url: url.toString(),
|
|
1230
|
-
responseText
|
|
1296
|
+
responseText,
|
|
1297
|
+
headers: new Headers(response.headers)
|
|
1231
1298
|
});
|
|
1232
1299
|
}
|
|
1233
1300
|
if (isJson) {
|
|
@@ -1303,7 +1370,13 @@ var Seclai = class {
|
|
|
1303
1370
|
* Run an agent in streaming mode and yield each SSE event as it arrives.
|
|
1304
1371
|
*
|
|
1305
1372
|
* This is an `AsyncGenerator` suitable for real-time UIs that want to render
|
|
1306
|
-
* step progress as it happens.
|
|
1373
|
+
* step progress as it happens. Set `include_reasoning` or
|
|
1374
|
+
* `include_commentary` in `body` to also receive `stream_reasoning` or
|
|
1375
|
+
* `stream_commentary` events.
|
|
1376
|
+
*
|
|
1377
|
+
* From `apiVersion` `2026-11-14`, an agent whose definition fails to validate
|
|
1378
|
+
* is refused with HTTP 409 ({@link SeclaiAPIStatusError}) before any event,
|
|
1379
|
+
* and no run is created.
|
|
1307
1380
|
*
|
|
1308
1381
|
* @param agentId - Agent identifier.
|
|
1309
1382
|
* @param body - Streaming run request payload.
|
|
@@ -1355,6 +1428,7 @@ var Seclai = class {
|
|
|
1355
1428
|
method: "POST",
|
|
1356
1429
|
url: url.toString(),
|
|
1357
1430
|
responseText,
|
|
1431
|
+
headers: new Headers(response.headers),
|
|
1358
1432
|
validationError: validation
|
|
1359
1433
|
});
|
|
1360
1434
|
}
|
|
@@ -1363,7 +1437,8 @@ var Seclai = class {
|
|
|
1363
1437
|
statusCode: response.status,
|
|
1364
1438
|
method: "POST",
|
|
1365
1439
|
url: url.toString(),
|
|
1366
|
-
responseText
|
|
1440
|
+
responseText,
|
|
1441
|
+
headers: new Headers(response.headers)
|
|
1367
1442
|
});
|
|
1368
1443
|
}
|
|
1369
1444
|
if (isJson) {
|
|
@@ -1551,22 +1626,50 @@ var Seclai = class {
|
|
|
1551
1626
|
return await this.request("GET", `/agents/${agentId}/attachment-references`);
|
|
1552
1627
|
}
|
|
1553
1628
|
/**
|
|
1554
|
-
* Download a file
|
|
1629
|
+
* Download a file of an agent run (one a step emitted or one the run started
|
|
1630
|
+
* with), or one byte range of it.
|
|
1555
1631
|
*
|
|
1556
1632
|
* Returns the raw `Response` so you can stream or save the binary data.
|
|
1557
1633
|
*
|
|
1634
|
+
* To fetch part of the file, set a byte range. Offsets are zero-based and
|
|
1635
|
+
* `rangeEnd` is inclusive:
|
|
1636
|
+
*
|
|
1637
|
+
* - `rangeStart` alone sends `Range: bytes=<rangeStart>-`, from that byte to the end.
|
|
1638
|
+
* - `rangeStart` and `rangeEnd` send `Range: bytes=<rangeStart>-<rangeEnd>`.
|
|
1639
|
+
* - `rangeSuffix` alone sends `Range: bytes=-<rangeSuffix>`, the last that many bytes.
|
|
1640
|
+
*
|
|
1641
|
+
* With none of them set, the SDK adds no `Range` header. The server answers a range
|
|
1642
|
+
* with status 206 and a `Content-Range` header, so check `resp.status` before
|
|
1643
|
+
* treating the body as the whole file. A range of an empty file is answered with
|
|
1644
|
+
* 200 and the whole (empty) file. A range that starts at or past the end of a
|
|
1645
|
+
* non-empty file throws {@link SeclaiAPIStatusError} with `statusCode` 416,
|
|
1646
|
+
* and its `headers.get("content-range")` ends in `/<size>`, the file's size in
|
|
1647
|
+
* bytes.
|
|
1648
|
+
*
|
|
1558
1649
|
* @param runId - Run identifier.
|
|
1559
|
-
* @param attachmentId -
|
|
1560
|
-
*
|
|
1650
|
+
* @param attachmentId - The `id` of an entry in the run's or a step's
|
|
1651
|
+
* `attachments`, or the URL-safe-base64-encoded storage key that webhook and
|
|
1652
|
+
* email links carry.
|
|
1561
1653
|
* @param opts - Optional `downloadName` filename hint for the download
|
|
1562
|
-
* disposition
|
|
1654
|
+
* disposition; `rangeStart`, `rangeEnd` and `rangeSuffix`, the byte range
|
|
1655
|
+
* described above; and `signal`, which cancels the request; with a standard `fetch` this
|
|
1563
1656
|
* includes reading the body, so `AbortSignal.timeout(ms)` bounds the whole
|
|
1564
1657
|
* transfer.
|
|
1565
|
-
* @returns Raw response with the attachment bytes
|
|
1658
|
+
* @returns Raw response with the attachment bytes: status 200 with the whole
|
|
1659
|
+
* file, or 206 with the requested range.
|
|
1660
|
+
* @throws {@link SeclaiConfigurationError} Before any request, when the range
|
|
1661
|
+
* options are not one of the three forms above: `rangeEnd` without
|
|
1662
|
+
* `rangeStart`, `rangeSuffix` with either of them, `rangeEnd` less than
|
|
1663
|
+
* `rangeStart`, a negative `rangeStart` or `rangeEnd`, a `rangeSuffix` below
|
|
1664
|
+
* 1, or a value that is not a safe integer (`Number.isSafeInteger`).
|
|
1665
|
+
* @throws {@link SeclaiAPIStatusError} On a non-2xx response, including 416
|
|
1666
|
+
* when the range cannot be satisfied.
|
|
1566
1667
|
*/
|
|
1567
1668
|
async downloadAgentRunAttachment(runId, attachmentId, opts = {}) {
|
|
1669
|
+
const range = byteRangeHeader(opts.rangeStart, opts.rangeEnd, opts.rangeSuffix);
|
|
1568
1670
|
return await this.requestRaw("GET", `/v2/agent-runs/${runId}/attachments/${attachmentId}`, {
|
|
1569
1671
|
query: { download_name: opts.downloadName },
|
|
1672
|
+
...range === void 0 ? {} : { headers: { Range: range } },
|
|
1570
1673
|
signal: opts.signal
|
|
1571
1674
|
});
|
|
1572
1675
|
}
|
|
@@ -2019,11 +2122,12 @@ var Seclai = class {
|
|
|
2019
2122
|
return await this.request("GET", "/agents/inbound-email-status");
|
|
2020
2123
|
}
|
|
2021
2124
|
/**
|
|
2022
|
-
*
|
|
2023
|
-
* once.
|
|
2125
|
+
* Cancel all of the account's QUEUED (over-quota parked) inbound-email runs
|
|
2126
|
+
* at once.
|
|
2024
2127
|
*
|
|
2025
|
-
* A queued run consumed no quota or credits at queue time
|
|
2026
|
-
*
|
|
2128
|
+
* A queued run consumed no quota or credits at queue time. Each ends
|
|
2129
|
+
* `cancelled`, or `failed` with an `apiVersion` before `2026-11-08`.
|
|
2130
|
+
* Requires an account owner/admin.
|
|
2027
2131
|
*
|
|
2028
2132
|
* @returns The count cancelled.
|
|
2029
2133
|
*/
|