@seclai/sdk 1.10.0 → 1.11.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,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.11.0] - 2026-11-27
4
+
5
+ ### Changed
6
+
7
+ - **Breaking:** Return `GenerationTierListResponse` from `getGenerationTiers()` in place of `Record<string, unknown>`, so a tier's `aspect_ratios` and other fields are typed. An `as` cast from the old type to an unrelated one, or an assignment that relied on `Record<string, unknown>`, may no longer compile
8
+ - Make an abort through `signal` in `runAgentAndPoll()` throw `signal.reason`, as `signal.throwIfAborted()` does (an `AbortError` unless the caller aborted with a reason of its own, and for a signal that has no `reason`, such as a polyfill's), instead of `SeclaiError("Polling aborted.")`. `signal` now also reaches the start request, each poll and the wait between polls: an already-aborted signal starts no run, an abort during the wait stops it without sending another poll, and with a `fetch` that honours `signal`, an abort during the start request throws, where a start run that had already ended the poll was returned. A run that has ended the poll is still returned after an abort, and with `includeStepOutputs` and a `fetch` that honours `signal`, an abort during the fetch for its step outputs returns the start run without them. `runAgentAndPoll()` now sends its requests itself and no longer calls `runAgent()` or `getAgentRun()`
9
+ - Return the `result` snapshot from `runStreamingAgentAndWait()` with `returnOnResult` when a `result` event and the `done` event arrive in one chunk, where the `done` run was returned
10
+
11
+ ### Added
12
+
13
+ - Add the type exports `GenerationTierListResponse` and `GenerationTierResponse`
14
+
15
+ ### Fixed
16
+
17
+ - Throw the caller's abort reason from `runStreamingAgent()` and `runStreamingAgentAndWait()` when `signal` is aborted with one (`controller.abort(reason)`) and the `fetch` rejects with the signal's reason, as the standard `fetch` does, where a generic `AbortError` was thrown. An abort without a reason still throws an `AbortError`
18
+ - Throw `SeclaiStreamingError` from `runStreamingAgentAndWait()` when the server sends an `error` event, with the server's error text in the message, or a `timeout` event, each with the latest snapshot in `run`, with or without `throwOnIncomplete`. Both were read as the stream ending early: without `throwOnIncomplete`, the latest snapshot was returned when its status was not `pending`, so a run that failed on the server came back looking like an unfinished success, without the server's message; with it, the error said only that `done` never arrived
19
+ - Parse a final SSE line that has no trailing newline, in `runStreamingAgent()` and `runStreamingAgentAndWait()`, where it was dropped
20
+ - Close the response body on every way out of `runStreamingAgentAndWait()`, after `done` included, and when a caller leaves a `runStreamingAgent()` loop early
21
+ - Remove the abort listeners `runStreamingAgent()` and `runStreamingAgentAndWait()` add to the caller's `signal` when the call ends, so a signal reused across calls no longer collects one per call
22
+ - Throw one `SeclaiStreamingError` from `runStreamingAgentAndWait()` whether `timeoutMs` elapses during the request or during the read: `Timed out after <n>ms waiting for streaming agent run to complete.`, then whether a result had been reported, with the latest snapshot in `run` and, when the request or read was cut off, the error it ended with as its `cause`. A timeout during the read said `Timed out after <n>ms before the streaming agent run finished.`
23
+ - Keep an event whose lines were read in full before a stream broke or timed out, unless the caller aborted `signal`: `runStreamingAgent()` yields it before throwing, and `runStreamingAgentAndWait()` returns a `done` event read so, or with `returnOnResult` a `result` event, where without `throwOnIncomplete` it threw the fetch error
24
+ - Stop waiting for a run in `runAgentAndPoll()` at the deadline: a wait between polls that reaches it ends the call with the timeout `SeclaiStreamingError`, and with a `fetch` that honours `signal`, a poll still in flight then is aborted and the call throws the same error, with the latest run in `run`. `timeoutMs` could overshoot by up to one `pollIntervalMs`, and a poll the server never answered kept the call waiting without limit, whether or not a `signal` was passed. No poll is sent at or after the deadline, so a run that ends during the last interval now times out, and a `timeoutMs` no greater than `pollIntervalMs` sends no poll. Any other error a poll ends with once the deadline has passed, the abort of a poll in flight included, is the timeout's `cause`, except a caller abort, which throws `signal.reason`, and an HTTP error status a poll gets after the deadline, such as a 500, is thrown as itself. `timeoutMs` does not cut off the start request, since the server may already have created the run, nor the fetch for an ended start run's step outputs; only `signal` does. A request is not cut off while more than 2^31-1 ms remain ([#25](https://github.com/seclai/seclai-javascript/issues/25))
25
+ - Wait out a `pollIntervalMs` over 2^31-1 ms in `runAgentAndPoll()`, which polled in a tight loop because `setTimeout` fires at once for a longer delay
26
+ - Throw an HTTP error status that `runStreamingAgent()` or `runStreamingAgentAndWait()` gets as `timeoutMs` elapses (for example, a 401 whose body is still being read) as `SeclaiAPIStatusError`, as `runAgentAndPoll()` does, where it was thrown as the timeout `SeclaiStreamingError`
27
+
3
28
  ## [1.10.0] - 2026-11-27
4
29
 
5
30
  ### Changed
@@ -308,6 +333,7 @@ _Stable release. No functional changes since 0.0.1._
308
333
 
309
334
  _Initial release._
310
335
 
336
+ [1.11.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.11.0
311
337
  [1.10.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.10.0
312
338
  [1.9.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.9.0
313
339
  [1.8.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.8.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.10.0/
107
+ https://seclai.github.io/seclai-javascript/1.11.0/
108
108
 
109
109
  Release history is in [`CHANGELOG.md`](CHANGELOG.md).
110
110
 
@@ -377,14 +377,19 @@ await client.deleteAgentRun("run_id");
377
377
 
378
378
  The SDK provides two streaming patterns over the SSE `/runs/stream` endpoint:
379
379
 
380
- **Block until done** — returns the run from the `done` event. If `timeoutMs`
381
- elapses first, it throws `SeclaiStreamingError`, whose `run` holds the latest
382
- snapshot: the `result` snapshot if one arrived, else the `init` snapshot. An
383
- abort through `signal` rethrows the abort error.
380
+ **Block until done** — returns the run from the `done` event. When the server
381
+ sends an `error` event (the run's stream failed on the server) it throws
382
+ `SeclaiStreamingError` with the server's error text in its message, and when the
383
+ server sends a `timeout` event, or `timeoutMs` elapses first, it throws
384
+ `SeclaiStreamingError` too. Its `run` holds the latest snapshot: the `result`
385
+ snapshot if one arrived, else the `init` snapshot. An HTTP error status that
386
+ arrives as `timeoutMs` elapses is thrown as itself, as `SeclaiAPIStatusError`.
387
+ An abort through `signal` rethrows the abort error.
384
388
 
385
389
  By default, a stream that ends before `done` returns the latest snapshot when
386
- its status is not `pending`, so the run returned may not have finished: check
387
- `status` and `result_reported_at`. A stream that breaks throws the fetch error.
390
+ its status is not `pending`, so the run returned may not have finished: check `status` and `result_reported_at`. A stream that breaks
391
+ throws the fetch error, unless a `done` event, or with `returnOnResult` a `result`
392
+ event, was read in full before it broke.
388
393
  Pass `throwOnIncomplete: true` to throw `SeclaiStreamingError`, with the snapshot
389
394
  in `run`, in both cases instead, and also when the server answers with plain
390
395
  JSON for a run that has not finished. It is recommended, and becomes the default in
@@ -413,7 +418,9 @@ for await (const event of client.runStreamingAgent(
413
418
  ```
414
419
 
415
420
  When the server answers with plain JSON instead of an SSE stream,
416
- `runStreamingAgent` yields only a `done` event, so read the answer from it.
421
+ `runStreamingAgent` yields only a `done` event, so read the answer from it. The
422
+ iterator yields the server's `error` and `timeout` events like any other, and
423
+ leaving the loop early closes the response body.
417
424
 
418
425
  A `result` event carries the run's answer in `output` once `result_reported_at`
419
426
  is set. It comes before `done`, and for an agent that reports its result early it
@@ -484,12 +491,21 @@ A run's answer can be ready before its last step finishes: once
484
491
  `result_reported_at` is set on `getAgentRun()`, `output` holds the answer. Pass
485
492
  `returnOnResult: true` to return as soon as a run has it set, the one
486
493
  `runAgent()` returns included. With `includeStepOutputs`, when that run would end
487
- the poll and `signal` is not aborted, it is fetched again at once, because the
488
- `runAgent()` response carries no step outputs; after an abort it comes back
489
- without step outputs. Such a run may still be in progress: its `status`
490
- is not terminal and the run can still fail, so check `result_reported_at`, not
491
- `status`. If `timeoutMs` elapses first, it throws `SeclaiStreamingError` with the
492
- latest run it has (the `runAgent()` response if no poll ran) in `run`.
494
+ the poll, it is fetched again at once, because the `runAgent()` response carries
495
+ no step outputs; when `signal` aborts before that fetch answers (with a `fetch`
496
+ that honours `signal`), the run comes back without step outputs. Such a run may still be in
497
+ progress: its `status` is not terminal and the run can still fail, so check
498
+ `result_reported_at`, not `status`. If `timeoutMs` elapses first, it throws
499
+ `SeclaiStreamingError` with the latest run it has (the `runAgent()` response if
500
+ no poll answered) in `run`. No poll is sent at or after the deadline: a wait
501
+ that reaches it ends the call, so a `timeoutMs` no greater than `pollIntervalMs`
502
+ sends no poll, and with a `fetch` that honours `signal` a poll in flight at the
503
+ deadline is aborted. `timeoutMs` does not cut off the start request (the server
504
+ may already have created the run) or the step-outputs fetch; only `signal` does.
505
+ A request is not cut off while more than 2^31-1 ms remain.
506
+ `signal` is passed to every request and to the wait between polls, and an abort
507
+ throws `signal.reason`, as `signal.throwIfAborted()` does (an `AbortError` for a
508
+ signal that has no `reason`), unless a run has already ended the poll.
493
509
 
494
510
  <!-- sdksync:check -->
495
511
  ```ts