@seclai/sdk 1.8.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 CHANGED
@@ -1,5 +1,43 @@
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
+
19
+ ## [1.9.0] - 2026-11-05
20
+
21
+ ### Changed
22
+
23
+ - Sync the bundled OpenAPI spec and regenerate the types. Existing responses gain properties: `result_reported_at` on `AgentRunResponse`, set once the run's answer is in `output`, and `alias` on `SlackTriggerConfigResponse`
24
+ - Move `SeclaiApiVersion.Latest` to `2026-11-04`. Nothing is sent unless `apiVersion` is set, so a client that passes `SeclaiApiVersion.Latest` now opts into `2026-11-04`. From `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), where older versions declare the key as optional; from `2026-11-04`, `createEvaluationResult()` rejects `retry_triggered: true`, `updateAgent()` rejects `evaluation_mode` `eval_and_retry`, and `createEvaluationCriteria()` and `updateEvaluationCriteria()` reject a `step_id` that does not name a `display_result` or `streaming_result` step, each with a 400
25
+ - Note API changes that apply on every API version, whatever `apiVersion` is set: a run started with `runAgent()`, `runStreamingAgent()` or the helpers built on them is refused with a 400 when its `metadata` sends a custom key the trigger does not declare, or lacks a required one, so declare custom keys with `setMetadataKeys()` before sending them; `updateAgentDefinition()` rejects a definition holding a `gate` or `retry` step (use `if_else`, or `repeat_until` to run steps again until a condition holds); the `agent_eval_fail` rollback trigger is accepted and never fires, and the default rollback triggers no longer include it; `max_retries` and `retry_on_failure` on `updateAgent()` are accepted and have no effect; and `evaluation_mode` on `AgentSummaryResponse` defaults to `sample_and_flag` instead of `eval_and_retry`
26
+ - Check the `runAgent()` response in `runAgentAndPoll()` before polling, so a run that ended at once is returned without waiting one `pollIntervalMs`. After an abort through `signal` during the start request, that run is now returned instead of throwing `Polling aborted.`, and with `includeStepOutputs` it comes back without step outputs. When `timeoutMs` elapses during the start request, that run is also returned, where `SeclaiStreamingError` was thrown
27
+ - Mark `input` on `SetSlackTriggerConfigRequest` deprecated. The API ignores it: a Slack run's input is the text after `/seclai <alias>`, or the message the shortcut was used on. It stays on the type so existing calls still compile
28
+ - Mark `max_retries` and `retry_on_failure` on `UpdateAgentRequest`, and `retry_count` and `retry_triggered` on `CreateEvaluationResultRequest`, deprecated. They have no effect, and from `2026-11-04` `retry_triggered: true` returns a 400. They stay on the types so existing calls still compile
29
+
30
+ ### Added
31
+
32
+ - Add `getMetadataKeys()` and `setMetadataKeys()` to read and replace the run metadata keys an agent trigger declares, which steps reference as `{{metadata.<key>}}`. A key's `required` defaults to `false` and can be omitted
33
+ - Add `getKnowledgeBaseMetadataKeyStats()` to see which item-metadata keys a knowledge base's content carries, with item counts and top values for all time and the last 30 and 7 days
34
+ - Accept `alias` on `setSlackTriggerConfig()`, the name people type after `/seclai` to run the agent
35
+ - Add the `returnOnResult` option to `runAgentAndPoll()` and `runStreamingAgentAndWait()`, to return as soon as a run has `result_reported_at` set (from `runAgent()` or a poll), or a `result` event arrives, without waiting for later steps. The run may still be in progress and can still fail
36
+ - Add the `throwOnIncomplete` option to `runStreamingAgentAndWait()`, to throw `SeclaiStreamingError`, with the latest snapshot in `run`, when the stream ends or breaks before `done`, or the server answers with plain JSON for a run that has not finished, instead of returning a run that has not finished or throwing the fetch error. It will become the default in the next major version
37
+ - Add `run` to `SeclaiStreamingError`: the latest snapshot of the unfinished run when `runStreamingAgentAndWait()` or `runAgentAndPoll()` gives up, so a reported answer in `output` is not lost
38
+ - Add the `SeclaiApiVersion.V2026_11_02` and `SeclaiApiVersion.V2026_11_04` constants, so those versions are accepted as `apiVersion`
39
+ - Add the type exports `MetadataOrigin`, `MetadataKeyDeclaration`, `MetadataKeyDeclarationInput`, `SetMetadataKeysRequest`, `DeclarableMetadataKey`, `MetadataKeysResponse`, `KnowledgeBaseMetadataKeyStatsResponse`, `MetadataKeyWindowResponse`, `MetadataKeyCountResponse` and `MetadataValueCountResponse`
40
+
3
41
  ## [1.8.0] - 2026-10-31
4
42
 
5
43
  ### Changed
@@ -270,6 +308,8 @@ _Stable release. No functional changes since 0.0.1._
270
308
 
271
309
  _Initial release._
272
310
 
311
+ [1.10.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.10.0
312
+ [1.9.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.9.0
273
313
  [1.8.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.8.0
274
314
  [1.7.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.7.0
275
315
  [1.6.1]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.1
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.8.0/
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 `V2026_10_28`,
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.
@@ -190,6 +190,18 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
190
190
  returns `null` `score` and `passed` for one.
191
191
  - `2026-10-28` changes what an `if_else` or `switch` step's `output` contains.
192
192
  Read the arm it took from the step's `decision`, which is set on every version.
193
+ - `2026-11-02` refuses an agent write that references a metadata key no trigger
194
+ declares, where older versions declare the key for you.
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()`.
193
205
 
194
206
  | Version | What it changes |
195
207
  | --- | --- |
@@ -205,6 +217,12 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
205
217
  | `2026-10-19` | `createSource()` rejects `polling_max_items` on any source type but an RSS feed with a 400. Below it the value is stored |
206
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 |
207
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 |
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 |
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` |
208
226
 
209
227
  **`Latest` moves with the SDK.** `SeclaiApiVersion.Latest` is the newest version
210
228
  the installed release knows, so upgrading the package can opt a client that
@@ -212,8 +230,13 @@ passes it into every version added since — `1.6.0` moved it from `2026-07-27`
212
230
  `2026-10-03`, across the `2026-09-30` output change, and `1.7.0` moves it to
213
231
  `2026-10-21`, across the `2026-10-05` status change, the `2026-10-13` and
214
232
  `2026-10-19` source-setting rejections, the `2026-10-16` input change and the
215
- `2026-10-21` evaluation change, and `1.8.0` moves it to `2026-10-28`,
216
- across the `if_else` / `switch` step-output change. Pass a
233
+ `2026-10-21` evaluation change, `1.8.0` moves it to `2026-10-28`,
234
+ across the `if_else` / `switch` step-output change, `1.9.0` moves it to
235
+ `2026-11-04`, across the `2026-11-02` undeclared-metadata-key refusal and the
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
217
240
  dated constant such as `SeclaiApiVersion.V2026_07_27` to keep behaviour fixed
218
241
  across upgrades.
219
242
 
@@ -354,13 +377,25 @@ await client.deleteAgentRun("run_id");
354
377
 
355
378
  The SDK provides two streaming patterns over the SSE `/runs/stream` endpoint:
356
379
 
357
- **Block until done** — returns the final `done` payload or throws on timeout:
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.
358
384
 
385
+ 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.
388
+ Pass `throwOnIncomplete: true` to throw `SeclaiStreamingError`, with the snapshot
389
+ in `run`, in both cases instead, and also when the server answers with plain
390
+ JSON for a run that has not finished. It is recommended, and becomes the default in
391
+ the next major version:
392
+
393
+ <!-- sdksync:check -->
359
394
  ```ts
360
395
  const result = await client.runStreamingAgentAndWait(
361
396
  "agent_id",
362
397
  { input: "Hello", metadata: {} },
363
- { timeoutMs: 60_000 },
398
+ { timeoutMs: 60_000, throwOnIncomplete: true },
364
399
  );
365
400
  ```
366
401
 
@@ -377,24 +412,65 @@ for await (const event of client.runStreamingAgent(
377
412
  }
378
413
  ```
379
414
 
415
+ 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.
417
+
418
+ A `result` event carries the run's answer in `output` once `result_reported_at`
419
+ is set. It comes before `done`, and for an agent that reports its result early it
420
+ can arrive while later steps still run. Pass `returnOnResult: true` to
421
+ `runStreamingAgentAndWait` to return that `result` snapshot without waiting for
422
+ `done`. Such a run may still be in progress: its `status` is not terminal and the
423
+ run can still fail, so check `result_reported_at`, not `status`:
424
+
425
+ <!-- sdksync:check -->
426
+ ```ts
427
+ const run = await client.runStreamingAgentAndWait("agent_id", { input: "Hello" }, { returnOnResult: true });
428
+ if (run.result_reported_at) console.log(run.output);
429
+ ```
430
+
431
+ On a timeout, or with `throwOnIncomplete` on a cut stream, read the answer, if
432
+ one was reported, from the error's `run`:
433
+
434
+ ```ts
435
+ import { SeclaiStreamingError } from "@seclai/sdk";
436
+
437
+ try {
438
+ const run = await client.runStreamingAgentAndWait("agent_id", { input: "Hello" }, { throwOnIncomplete: true });
439
+ console.log(run.output);
440
+ } catch (err) {
441
+ if (err instanceof SeclaiStreamingError && err.run?.result_reported_at) {
442
+ console.log("Answer, run not finished:", err.run.output);
443
+ } else {
444
+ throw err;
445
+ }
446
+ }
447
+ ```
448
+
380
449
  Pass `include_reasoning: true` to also receive `stream_reasoning` events carrying
381
- the model's reasoning while it thinks. They are sent only for a
382
- `streaming_result` step whose author enabled `show_reasoning`, and reasoning is
383
- never part of `output`:
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:
384
457
 
385
458
  <!-- sdksync:check -->
386
459
  ```ts
387
460
  for await (const event of client.runStreamingAgent("agent_id", {
388
461
  input: "Hello",
389
462
  include_reasoning: true,
463
+ include_commentary: true,
390
464
  })) {
391
465
  if (event.event === "stream_reasoning") console.log(event.data);
466
+ if (event.event === "stream_commentary") console.log(event.data);
392
467
  }
393
468
  ```
394
469
 
395
470
  ### Polling
396
471
 
397
- For environments where SSE is not practical, poll for a completed run:
472
+ For environments where SSE is not practical, poll until the run ends with
473
+ `status` `completed`, `failed` or `cancelled`:
398
474
 
399
475
  ```ts
400
476
  const result = await client.runAgentAndPoll(
@@ -404,6 +480,23 @@ const result = await client.runAgentAndPoll(
404
480
  );
405
481
  ```
406
482
 
483
+ A run's answer can be ready before its last step finishes: once
484
+ `result_reported_at` is set on `getAgentRun()`, `output` holds the answer. Pass
485
+ `returnOnResult: true` to return as soon as a run has it set, the one
486
+ `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`.
493
+
494
+ <!-- sdksync:check -->
495
+ ```ts
496
+ const run = await client.runAgentAndPoll("agent_id", { input: "Hello" }, { returnOnResult: true });
497
+ if (run.result_reported_at) console.log(run.output);
498
+ ```
499
+
407
500
  ### Agent input uploads
408
501
 
409
502
  <!-- sdksync:check -->
@@ -436,12 +529,57 @@ Only a `dynamic_input` agent takes uploads; any other agent rejects one with a
436
529
 
437
530
  <!-- sdksync:check -->
438
531
  ```ts
439
- // Download a file emitted by a step in an agent run. The attachment_id is the
440
- // URL-safe-base64 storage_key surfaced in run output manifests / webhooks.
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.
441
535
  const resp = await client.downloadAgentRunAttachment("run_id", "attachment_id");
442
536
  const blob = await resp.blob(); // raw Response — stream or save the bytes
443
537
  ```
444
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
+
445
583
  ### Agent email triggers
446
584
 
447
585
  Configure the inbound address and handling rules on an agent's `EMAIL_RECEIVED`
@@ -465,11 +603,15 @@ are listed in the run's `email_attachment_issues` metadata. By default the run f
465
603
  ### Agent Slack triggers
466
604
 
467
605
  Configure an agent's `SLACK_COMMAND` trigger, which people run from Slack with
468
- `/seclai` or the message shortcut. Omitted fields are left unchanged.
606
+ `/seclai <alias>` or the message shortcut. Omitted fields are left unchanged.
607
+ `alias` is generated from the agent's name when not set; the text after the alias,
608
+ or the message the shortcut was used on, is the run's input. `input` is
609
+ deprecated and ignored by the API.
469
610
 
470
611
  <!-- sdksync:check -->
471
612
  ```ts
472
613
  const slack = await client.setSlackTriggerConfig("agent_id", "trigger_id", {
614
+ alias: "support", // people run `/seclai support`
473
615
  scope: "selected_channels", // or "bot_channels"
474
616
  channel_ids: ["C0123456789"],
475
617
  activation: "everywhere", // or "channel_opt_in"
@@ -505,6 +647,33 @@ const { accepted_attachments } = await client.setAcceptedAttachments("agent_id",
505
647
  console.log(accepted_attachments.map((slot) => `${slot.name}: ${slot.min}..${slot.max ?? "any"}`));
506
648
  ```
507
649
 
650
+ ### Trigger metadata keys
651
+
652
+ Declare the run metadata keys a trigger provides, which steps reference as
653
+ `{{metadata.<key>}}`. `system` and `source` keys are written by the platform;
654
+ `custom` keys are sent by the caller or set on the trigger, and only a `custom`
655
+ key can be `required` (default `false`): a caller-started run without it is
656
+ refused. A run is also refused with a 400 when its `metadata` sends a custom key
657
+ the trigger does not declare, on every API version, so declare custom keys with
658
+ `setMetadataKeys()` before sending them in a run's `metadata`. The call replaces
659
+ the whole declaration, and is refused with a 400 when the agent references a key
660
+ no trigger of its branch declares.
661
+
662
+ <!-- sdksync:check -->
663
+ ```ts
664
+ const agent = await client.getAgent("agent_id");
665
+ const current = await client.getMetadataKeys("agent_id", agent.trigger_id!);
666
+ console.log(current.declarable_keys.map((k) => `${k.key} (${k.origin})`));
667
+
668
+ const updated = await client.setMetadataKeys("agent_id", agent.trigger_id!, {
669
+ metadata_keys: [
670
+ { key: "customer_id", origin: "custom", required: true },
671
+ { key: "region", origin: "custom" },
672
+ ],
673
+ });
674
+ console.log(updated.warnings); // agents whose `call_agent` mapping no longer fits
675
+ ```
676
+
508
677
  ### Agent email governance
509
678
 
510
679
  ```ts
@@ -525,7 +694,7 @@ const rejections = await client.listInboundEmailRejections({ agentId: "agent_id"
525
694
 
526
695
  // Account-wide overload circuit breaker
527
696
  const status = await client.getInboundEmailStatus(); // { paused, queued_backlog }
528
- await client.cancelQueuedEmailRuns(); // fail all QUEUED (over-quota parked) runs
697
+ await client.cancelQueuedEmailRuns(); // cancel all QUEUED (over-quota parked) runs
529
698
  await client.resumeInboundEmail(); // one-shot override; re-arms if still overloaded
530
699
  ```
531
700
 
@@ -585,6 +754,17 @@ await client.updateKnowledgeBase("kb_id", { name: "Renamed KB" });
585
754
  await client.deleteKnowledgeBase("kb_id");
586
755
  ```
587
756
 
757
+ See which item-metadata keys a knowledge base's content carries, for all time
758
+ and the last 30 and 7 days:
759
+
760
+ <!-- sdksync:check -->
761
+ ```ts
762
+ const stats = await client.getKnowledgeBaseMetadataKeyStats("kb_id");
763
+ for (const w of stats.windows) {
764
+ console.log(w.window, w.total_items, w.keys.map((k) => `${k.key}: ${k.items}`));
765
+ }
766
+ ```
767
+
588
768
  ### Memory banks
589
769
 
590
770
  ```ts