@seclai/sdk 1.7.0 → 1.9.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 +48 -0
- package/README.md +204 -19
- package/dist/index.cjs +322 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +988 -112
- package/dist/index.d.ts +988 -112
- package/dist/index.js +322 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.9.0] - 2026-11-05
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- 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`
|
|
8
|
+
- 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
|
|
9
|
+
- 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`
|
|
10
|
+
- 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
|
|
11
|
+
- 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
|
|
12
|
+
- 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
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- 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
|
|
17
|
+
- 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
|
|
18
|
+
- Accept `alias` on `setSlackTriggerConfig()`, the name people type after `/seclai` to run the agent
|
|
19
|
+
- 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
|
|
20
|
+
- 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
|
|
21
|
+
- 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
|
|
22
|
+
- Add the `SeclaiApiVersion.V2026_11_02` and `SeclaiApiVersion.V2026_11_04` constants, so those versions are accepted as `apiVersion`
|
|
23
|
+
- Add the type exports `MetadataOrigin`, `MetadataKeyDeclaration`, `MetadataKeyDeclarationInput`, `SetMetadataKeysRequest`, `DeclarableMetadataKey`, `MetadataKeysResponse`, `KnowledgeBaseMetadataKeyStatsResponse`, `MetadataKeyWindowResponse`, `MetadataKeyCountResponse` and `MetadataValueCountResponse`
|
|
24
|
+
|
|
25
|
+
## [1.8.0] - 2026-10-31
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Sync the bundled OpenAPI spec and regenerate the types. Existing responses gain properties: `decision` on `AgentRunStepResponse`, `created_resources`, `solution_id` and the run and credit limits `max_runs_total`, `max_runs_per_day`, `max_runs_per_hour`, `max_credits_per_run` and `max_credits_per_period` on `AgentSummaryResponse`, `max_credits_per_period`, `spend_cap_action`, `spend_cap_delete_order` and `spend_cap_reached` on `SourceResponse`, and `release_waiting_reason` on `SourceContentStatusResponse`
|
|
30
|
+
- Move `SeclaiApiVersion.Latest` to `2026-10-28`. Nothing is sent unless `apiVersion` is set, so a client that passes `SeclaiApiVersion.Latest` now opts into `2026-10-28`: an `if_else` or `switch` step's `output` is the result of the arm it took, where it was a `{"branch": ...}` marker naming the arm. Read the arm from the step's new `decision`, which is set on every version
|
|
31
|
+
- Mark `severity` on `listAlerts()` deprecated. It has never been sent, because `GET /alerts` has no severity filter
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Add `listAgentExamples()` for the agent gallery, searchable with `query` and filterable by `useCase`, returning typed `AgentExample` entries with the `resources` each needs, and accept `agent_template` entries from it on `createAgent()` with `resource_bindings` and `create_missing_resources`
|
|
36
|
+
- Add `setSlackTriggerConfig()` to configure an agent's `SLACK_COMMAND` trigger: its Slack connection, form, channels, activation, reply visibility and conversation settings
|
|
37
|
+
- Accept the run and credit limits on `updateAgent()`: `max_runs_total`, `max_runs_per_day`, `max_runs_per_hour`, `max_credits_per_run` and `max_credits_per_period`, a `set_max_*` flag for each to remove it, and `apply_import_run_limits`
|
|
38
|
+
- Accept a spend limit on `updateSource()`: `max_credits_per_period`, `spend_cap_action` and `spend_cap_delete_order`
|
|
39
|
+
- Accept the query filters the API declares and no method sent: `status`, `flaggedOnly`, `timeFrom` and `timeTo` on `listEvaluationResults()` and `listAgentEvaluationResults()`, which also takes `step`; `status`, `step`, `timeFrom` and `timeTo` on `listEvaluationRuns()`; `startedAfter` on `listCompatibleRuns()`; `days`, `startDate` and `endDate` on `getNonManualEvaluationSummary()` and `getMemoryBankStats()` (each method documents how the dates combine with `days`); `limit` and `offset` on `getMemoryBankAiLastConversation()` and `getAiAssistantMemoryBankHistory()`; `agentId`, `sourceConnectionId`, `timeFrom` and `timeTo` on `listAlerts()`; `agentId`, `sourceConnectionId` and `scope` on `listAlertConfigs()`; `organizationId` and `includeDefaults` on `listOrganizationAlertPreferences()`; `limit` on `listGovernanceAiConversations()`; `type` on `listMemoryBanks()`; `agentId` and `unreadOnly` on `listModelAlerts()`; `requireToolUse`, `requireStructuredOutput`, `requireThinking`, `minContextTokens` and `minOutputTokens` on `getModelRecommendations()`; and `search` on `listSolutions()`
|
|
40
|
+
- Let `getNonManualEvaluationSummary()` omit `agentId` for the account-wide summary
|
|
41
|
+
- Add the `SeclaiApiVersion.V2026_10_28` constant, so that version is accepted as `apiVersion`
|
|
42
|
+
- Add the type exports `AgentExampleListResponse`, `AgentExample`, `AgentExampleResource`, `SetSlackTriggerConfigRequest`, `SlackTriggerConfigResponse`, `SlackTriggerActivation`, `SlackTriggerScope`, `SlackReplyVisibility`, `SpendCapAction` and `SpendCapDeleteOrder`, and the option types `ListAgentExamplesOptions`, `ListEvaluationResultsOptions`, `ListAgentEvaluationResultsOptions`, `ListEvaluationRunsOptions`, `ListCompatibleRunsOptions`, `DateRangeOptions`, `OffsetPageOptions`, `ListAlertsOptions`, `ListAlertConfigsOptions`, `ListOrganizationAlertPreferencesOptions`, `ListMemoryBanksOptions`, `ListModelAlertsOptions`, `ModelRecommendationsOptions` and `ListSolutionsOptions`
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- Make every field of `UpdateAgentRequest` optional. `updateAgent()` required `set_default_evaluation_tier`, `set_prompt_model_auto_rollback_triggers` and `set_sampling_config`, which the server defaults to `false`, so `updateAgent(id, { name })` did not compile
|
|
47
|
+
- Make server-defaulted fields optional on the request types that required them, so a call can leave them to the server: `description` on `CreateSolutionRequest` (`createSolution({ name })` did not compile), `priority` on `AgentRunRequest`, `enabled` and `distribution_type` on `CreateAlertConfigRequest`, `mode`, `type` and `strip_quoted_reply_chains` on `CreateMemoryBankBody`, `enabled` and `pass_threshold` on `CreateEvaluationCriteriaRequest`, `flagged`, `retry_count` and `retry_triggered` on `CreateEvaluationResultRequest`, `content_type` on `InlineTextUploadRequest` and `InlineTextReplaceRequest`, `entry_count` on `TestCompactionRequest`, `entry_count` and `bank_type` on `StandaloneTestCompactionRequest`, `match_type` on `BlockEmailSenderRequest`, `delegated` on `AddEmailDomainRequest`, `mode` on `GenerateAgentStepsRequest`, `pass_threshold` on `TestDraftEvaluationRequest`, `top_n` on `AgentTraceSearchRequest`, `confirm_deletions` on `AiAssistantAcceptRequest`, and the playground settings on `PlaygroundCreateRequest`. Response types are unchanged
|
|
48
|
+
|
|
3
49
|
## [1.7.0] - 2026-10-21
|
|
4
50
|
|
|
5
51
|
### Changed
|
|
@@ -246,6 +292,8 @@ _Stable release. No functional changes since 0.0.1._
|
|
|
246
292
|
|
|
247
293
|
_Initial release._
|
|
248
294
|
|
|
295
|
+
[1.9.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.9.0
|
|
296
|
+
[1.8.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.8.0
|
|
249
297
|
[1.7.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.7.0
|
|
250
298
|
[1.6.1]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.1
|
|
251
299
|
[1.6.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.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.9.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_04`,
|
|
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.
|
|
@@ -188,6 +188,11 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
|
|
|
188
188
|
- `2026-10-21` changes evaluation numbers you may be reading: an `error` result
|
|
189
189
|
no longer counts as `failed` or toward the rates, and `testDraftEvaluation()`
|
|
190
190
|
returns `null` `score` and `passed` for one.
|
|
191
|
+
- `2026-10-28` changes what an `if_else` or `switch` step's `output` contains.
|
|
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.
|
|
191
196
|
|
|
192
197
|
| Version | What it changes |
|
|
193
198
|
| --- | --- |
|
|
@@ -202,6 +207,9 @@ a request that used to succeed, or (from `2026-10-21`) which fields can be
|
|
|
202
207
|
| `2026-10-18` | A source's `document_images` defaults to `true` on every embedder. Below it it defaults to `false` on a text-only embedder |
|
|
203
208
|
| `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 |
|
|
204
209
|
| `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
|
+
| `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
|
+
| `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 a `display_result` or `streaming_result` step with a 400. Below it `eval_and_retry` is stored as `sample_and_flag` |
|
|
205
213
|
|
|
206
214
|
**`Latest` moves with the SDK.** `SeclaiApiVersion.Latest` is the newest version
|
|
207
215
|
the installed release knows, so upgrading the package can opt a client that
|
|
@@ -209,7 +217,10 @@ passes it into every version added since — `1.6.0` moved it from `2026-07-27`
|
|
|
209
217
|
`2026-10-03`, across the `2026-09-30` output change, and `1.7.0` moves it to
|
|
210
218
|
`2026-10-21`, across the `2026-10-05` status change, the `2026-10-13` and
|
|
211
219
|
`2026-10-19` source-setting rejections, the `2026-10-16` input change and the
|
|
212
|
-
`2026-10-21` evaluation change.
|
|
220
|
+
`2026-10-21` evaluation change, `1.8.0` moves it to `2026-10-28`,
|
|
221
|
+
across the `if_else` / `switch` step-output change, and `1.9.0` moves it to
|
|
222
|
+
`2026-11-04`, across the `2026-11-02` undeclared-metadata-key refusal and the
|
|
223
|
+
`2026-11-04` evaluation-setting rejections. Pass a
|
|
213
224
|
dated constant such as `SeclaiApiVersion.V2026_07_27` to keep behaviour fixed
|
|
214
225
|
across upgrades.
|
|
215
226
|
|
|
@@ -270,6 +281,10 @@ const fetched = await client.getAgent("agent_id");
|
|
|
270
281
|
const updated = await client.updateAgent("agent_id", { name: "Renamed" });
|
|
271
282
|
await client.deleteAgent("agent_id");
|
|
272
283
|
|
|
284
|
+
// Run and credit limits. To remove one, send its set_max_* flag and omit the value.
|
|
285
|
+
await client.updateAgent("agent_id", { max_runs_per_hour: 60, max_credits_per_period: 500 });
|
|
286
|
+
await client.updateAgent("agent_id", { set_max_runs_per_hour: true });
|
|
287
|
+
|
|
273
288
|
// Pause / resume — a disabled agent stops firing from every trigger path
|
|
274
289
|
const callers = await client.getAgentCallers("agent_id"); // live agents calling this one
|
|
275
290
|
await client.disableAgent("agent_id"); // 409 if any caller above is still live
|
|
@@ -299,6 +314,31 @@ const imported = await client.createAgent({
|
|
|
299
314
|
// `imported.import_warnings` lists any items that couldn't be applied.
|
|
300
315
|
```
|
|
301
316
|
|
|
317
|
+
### Agent examples
|
|
318
|
+
|
|
319
|
+
The agent gallery lists example agents to start from. Pass an entry's `key` as
|
|
320
|
+
`agent_template` to `createAgent()`. Bind each resource the template needs with
|
|
321
|
+
`resource_bindings`, or set `create_missing_resources` to have the API create the
|
|
322
|
+
ones you leave out; `created_resources` reports what it made.
|
|
323
|
+
|
|
324
|
+
<!-- sdksync:check -->
|
|
325
|
+
```ts
|
|
326
|
+
const examples = await client.listAgentExamples({ query: "support", useCase: "customer_support", limit: 10 });
|
|
327
|
+
const example = examples.data[0];
|
|
328
|
+
console.log(example.key, example.title, examples.pagination.total);
|
|
329
|
+
for (const slot of example.resources) {
|
|
330
|
+
console.log(slot.slot, slot.kind, slot.creatable); // what resource_bindings can bind
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const agent = await client.createAgent({
|
|
334
|
+
name: "Support triage",
|
|
335
|
+
agent_template: example.key,
|
|
336
|
+
resource_bindings: { [example.resources[0].slot]: "kb_id" },
|
|
337
|
+
create_missing_resources: true,
|
|
338
|
+
});
|
|
339
|
+
console.log(agent.created_resources); // { slot: resource_id } for each resource it created
|
|
340
|
+
```
|
|
341
|
+
|
|
302
342
|
### Agent runs
|
|
303
343
|
|
|
304
344
|
```ts
|
|
@@ -321,13 +361,25 @@ await client.deleteAgentRun("run_id");
|
|
|
321
361
|
|
|
322
362
|
The SDK provides two streaming patterns over the SSE `/runs/stream` endpoint:
|
|
323
363
|
|
|
324
|
-
**Block until done** — returns the
|
|
364
|
+
**Block until done** — returns the run from the `done` event. If `timeoutMs`
|
|
365
|
+
elapses first, it throws `SeclaiStreamingError`, whose `run` holds the latest
|
|
366
|
+
snapshot: the `result` snapshot if one arrived, else the `init` snapshot. An
|
|
367
|
+
abort through `signal` rethrows the abort error.
|
|
325
368
|
|
|
369
|
+
By default, a stream that ends before `done` returns the latest snapshot when
|
|
370
|
+
its status is not `pending`, so the run returned may not have finished: check
|
|
371
|
+
`status` and `result_reported_at`. A stream that breaks throws the fetch error.
|
|
372
|
+
Pass `throwOnIncomplete: true` to throw `SeclaiStreamingError`, with the snapshot
|
|
373
|
+
in `run`, in both cases instead, and also when the server answers with plain
|
|
374
|
+
JSON for a run that has not finished. It is recommended, and becomes the default in
|
|
375
|
+
the next major version:
|
|
376
|
+
|
|
377
|
+
<!-- sdksync:check -->
|
|
326
378
|
```ts
|
|
327
379
|
const result = await client.runStreamingAgentAndWait(
|
|
328
380
|
"agent_id",
|
|
329
381
|
{ input: "Hello", metadata: {} },
|
|
330
|
-
{ timeoutMs: 60_000 },
|
|
382
|
+
{ timeoutMs: 60_000, throwOnIncomplete: true },
|
|
331
383
|
);
|
|
332
384
|
```
|
|
333
385
|
|
|
@@ -344,6 +396,40 @@ for await (const event of client.runStreamingAgent(
|
|
|
344
396
|
}
|
|
345
397
|
```
|
|
346
398
|
|
|
399
|
+
When the server answers with plain JSON instead of an SSE stream,
|
|
400
|
+
`runStreamingAgent` yields only a `done` event, so read the answer from it.
|
|
401
|
+
|
|
402
|
+
A `result` event carries the run's answer in `output` once `result_reported_at`
|
|
403
|
+
is set. It comes before `done`, and for an agent that reports its result early it
|
|
404
|
+
can arrive while later steps still run. Pass `returnOnResult: true` to
|
|
405
|
+
`runStreamingAgentAndWait` to return that `result` snapshot without waiting for
|
|
406
|
+
`done`. Such a run may still be in progress: its `status` is not terminal and the
|
|
407
|
+
run can still fail, so check `result_reported_at`, not `status`:
|
|
408
|
+
|
|
409
|
+
<!-- sdksync:check -->
|
|
410
|
+
```ts
|
|
411
|
+
const run = await client.runStreamingAgentAndWait("agent_id", { input: "Hello" }, { returnOnResult: true });
|
|
412
|
+
if (run.result_reported_at) console.log(run.output);
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
On a timeout, or with `throwOnIncomplete` on a cut stream, read the answer, if
|
|
416
|
+
one was reported, from the error's `run`:
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
import { SeclaiStreamingError } from "@seclai/sdk";
|
|
420
|
+
|
|
421
|
+
try {
|
|
422
|
+
const run = await client.runStreamingAgentAndWait("agent_id", { input: "Hello" }, { throwOnIncomplete: true });
|
|
423
|
+
console.log(run.output);
|
|
424
|
+
} catch (err) {
|
|
425
|
+
if (err instanceof SeclaiStreamingError && err.run?.result_reported_at) {
|
|
426
|
+
console.log("Answer, run not finished:", err.run.output);
|
|
427
|
+
} else {
|
|
428
|
+
throw err;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
347
433
|
Pass `include_reasoning: true` to also receive `stream_reasoning` events carrying
|
|
348
434
|
the model's reasoning while it thinks. They are sent only for a
|
|
349
435
|
`streaming_result` step whose author enabled `show_reasoning`, and reasoning is
|
|
@@ -371,6 +457,23 @@ const result = await client.runAgentAndPoll(
|
|
|
371
457
|
);
|
|
372
458
|
```
|
|
373
459
|
|
|
460
|
+
A run's answer can be ready before its last step finishes: once
|
|
461
|
+
`result_reported_at` is set on `getAgentRun()`, `output` holds the answer. Pass
|
|
462
|
+
`returnOnResult: true` to return as soon as a run has it set, the one
|
|
463
|
+
`runAgent()` returns included. With `includeStepOutputs`, when that run would end
|
|
464
|
+
the poll and `signal` is not aborted, it is fetched again at once, because the
|
|
465
|
+
`runAgent()` response carries no step outputs; after an abort it comes back
|
|
466
|
+
without step outputs. Such a run may still be in progress: its `status`
|
|
467
|
+
is not terminal and the run can still fail, so check `result_reported_at`, not
|
|
468
|
+
`status`. If `timeoutMs` elapses first, it throws `SeclaiStreamingError` with the
|
|
469
|
+
latest run it has (the `runAgent()` response if no poll ran) in `run`.
|
|
470
|
+
|
|
471
|
+
<!-- sdksync:check -->
|
|
472
|
+
```ts
|
|
473
|
+
const run = await client.runAgentAndPoll("agent_id", { input: "Hello" }, { returnOnResult: true });
|
|
474
|
+
if (run.result_reported_at) console.log(run.output);
|
|
475
|
+
```
|
|
476
|
+
|
|
374
477
|
### Agent input uploads
|
|
375
478
|
|
|
376
479
|
<!-- sdksync:check -->
|
|
@@ -429,6 +532,32 @@ Set `run_on_attachment_mismatch: true` to run an email whose attachments do not
|
|
|
429
532
|
fit what the agent accepts: files it cannot take are left out and the problems
|
|
430
533
|
are listed in the run's `email_attachment_issues` metadata. By default the run fails.
|
|
431
534
|
|
|
535
|
+
### Agent Slack triggers
|
|
536
|
+
|
|
537
|
+
Configure an agent's `SLACK_COMMAND` trigger, which people run from Slack with
|
|
538
|
+
`/seclai <alias>` or the message shortcut. Omitted fields are left unchanged.
|
|
539
|
+
`alias` is generated from the agent's name when not set; the text after the alias,
|
|
540
|
+
or the message the shortcut was used on, is the run's input. `input` is
|
|
541
|
+
deprecated and ignored by the API.
|
|
542
|
+
|
|
543
|
+
<!-- sdksync:check -->
|
|
544
|
+
```ts
|
|
545
|
+
const slack = await client.setSlackTriggerConfig("agent_id", "trigger_id", {
|
|
546
|
+
alias: "support", // people run `/seclai support`
|
|
547
|
+
scope: "selected_channels", // or "bot_channels"
|
|
548
|
+
channel_ids: ["C0123456789"],
|
|
549
|
+
activation: "everywhere", // or "channel_opt_in"
|
|
550
|
+
visibility: "private", // or "channel"
|
|
551
|
+
allow_dms: true,
|
|
552
|
+
turns_enabled: true, // let people keep the conversation going
|
|
553
|
+
max_turns: 5,
|
|
554
|
+
form: [{ key: "ticket", label: "Ticket ID", type: "short_text", required: true }],
|
|
555
|
+
});
|
|
556
|
+
console.log(slack.missing_scopes); // Slack scopes the connection lacks for optional features
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Each form value reaches the run as `{{metadata.<key>}}`.
|
|
560
|
+
|
|
432
561
|
### Accepted attachments
|
|
433
562
|
|
|
434
563
|
Declare the input attachments a trigger accepts. A run's files are each assigned
|
|
@@ -450,6 +579,33 @@ const { accepted_attachments } = await client.setAcceptedAttachments("agent_id",
|
|
|
450
579
|
console.log(accepted_attachments.map((slot) => `${slot.name}: ${slot.min}..${slot.max ?? "any"}`));
|
|
451
580
|
```
|
|
452
581
|
|
|
582
|
+
### Trigger metadata keys
|
|
583
|
+
|
|
584
|
+
Declare the run metadata keys a trigger provides, which steps reference as
|
|
585
|
+
`{{metadata.<key>}}`. `system` and `source` keys are written by the platform;
|
|
586
|
+
`custom` keys are sent by the caller or set on the trigger, and only a `custom`
|
|
587
|
+
key can be `required` (default `false`): a caller-started run without it is
|
|
588
|
+
refused. A run is also refused with a 400 when its `metadata` sends a custom key
|
|
589
|
+
the trigger does not declare, on every API version, so declare custom keys with
|
|
590
|
+
`setMetadataKeys()` before sending them in a run's `metadata`. The call replaces
|
|
591
|
+
the whole declaration, and is refused with a 400 when the agent references a key
|
|
592
|
+
no trigger of its branch declares.
|
|
593
|
+
|
|
594
|
+
<!-- sdksync:check -->
|
|
595
|
+
```ts
|
|
596
|
+
const agent = await client.getAgent("agent_id");
|
|
597
|
+
const current = await client.getMetadataKeys("agent_id", agent.trigger_id!);
|
|
598
|
+
console.log(current.declarable_keys.map((k) => `${k.key} (${k.origin})`));
|
|
599
|
+
|
|
600
|
+
const updated = await client.setMetadataKeys("agent_id", agent.trigger_id!, {
|
|
601
|
+
metadata_keys: [
|
|
602
|
+
{ key: "customer_id", origin: "custom", required: true },
|
|
603
|
+
{ key: "region", origin: "custom" },
|
|
604
|
+
],
|
|
605
|
+
});
|
|
606
|
+
console.log(updated.warnings); // agents whose `call_agent` mapping no longer fits
|
|
607
|
+
```
|
|
608
|
+
|
|
453
609
|
### Agent email governance
|
|
454
610
|
|
|
455
611
|
```ts
|
|
@@ -503,18 +659,21 @@ const draft = await client.testDraftEvaluation("agent_id", { step_output: "...",
|
|
|
503
659
|
if (draft.status !== "error") console.log(draft.score, draft.passed);
|
|
504
660
|
|
|
505
661
|
// Results by criteria
|
|
506
|
-
const results = await client.listEvaluationResults("criteria_id");
|
|
662
|
+
const results = await client.listEvaluationResults("criteria_id", { flaggedOnly: true, timeFrom: "2026-10-01T00:00:00Z" });
|
|
507
663
|
const summary = await client.getEvaluationCriteriaSummary("criteria_id");
|
|
508
664
|
await client.createEvaluationResult("criteria_id", { ... });
|
|
509
665
|
|
|
510
666
|
// Results by run
|
|
511
667
|
const runResults = await client.listRunEvaluationResults("agent_id", "run_id");
|
|
668
|
+
const agentResults = await client.listAgentEvaluationResults("agent_id", { status: "failed", step: "step_id" });
|
|
669
|
+
const evalRuns = await client.listEvaluationRuns("agent_id", { timeFrom: "2026-10-01T00:00:00Z" });
|
|
512
670
|
|
|
513
|
-
// Non-manual evaluation summary
|
|
514
|
-
const nonManual = await client.getNonManualEvaluationSummary("agent_id");
|
|
671
|
+
// Non-manual evaluation summary, for one agent or the whole account
|
|
672
|
+
const nonManual = await client.getNonManualEvaluationSummary("agent_id", { days: 7 });
|
|
673
|
+
const accountWide = await client.getNonManualEvaluationSummary(undefined, { startDate: "2026-10-01", endDate: "2026-10-31" });
|
|
515
674
|
|
|
516
675
|
// Compatible runs for a criteria
|
|
517
|
-
const compatible = await client.listCompatibleRuns("criteria_id");
|
|
676
|
+
const compatible = await client.listCompatibleRuns("criteria_id", { startedAfter: "2026-10-01T00:00:00Z" });
|
|
518
677
|
```
|
|
519
678
|
|
|
520
679
|
### Knowledge bases
|
|
@@ -527,17 +686,28 @@ await client.updateKnowledgeBase("kb_id", { name: "Renamed KB" });
|
|
|
527
686
|
await client.deleteKnowledgeBase("kb_id");
|
|
528
687
|
```
|
|
529
688
|
|
|
689
|
+
See which item-metadata keys a knowledge base's content carries, for all time
|
|
690
|
+
and the last 30 and 7 days:
|
|
691
|
+
|
|
692
|
+
<!-- sdksync:check -->
|
|
693
|
+
```ts
|
|
694
|
+
const stats = await client.getKnowledgeBaseMetadataKeyStats("kb_id");
|
|
695
|
+
for (const w of stats.windows) {
|
|
696
|
+
console.log(w.window, w.total_items, w.keys.map((k) => `${k.key}: ${k.items}`));
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
530
700
|
### Memory banks
|
|
531
701
|
|
|
532
702
|
```ts
|
|
533
|
-
const banks = await client.listMemoryBanks();
|
|
703
|
+
const banks = await client.listMemoryBanks({ type: "conversation" });
|
|
534
704
|
const bank = await client.createMemoryBank({ name: "Chat Memory", type: "conversation" });
|
|
535
705
|
const fetched = await client.getMemoryBank("mb_id");
|
|
536
706
|
await client.updateMemoryBank("mb_id", { name: "Renamed" });
|
|
537
707
|
await client.deleteMemoryBank("mb_id");
|
|
538
708
|
|
|
539
709
|
// Stats & compaction
|
|
540
|
-
const stats = await client.getMemoryBankStats("mb_id");
|
|
710
|
+
const stats = await client.getMemoryBankStats("mb_id", { startDate: "2026-10-01", endDate: "2026-10-31" });
|
|
541
711
|
await client.compactMemoryBank("mb_id");
|
|
542
712
|
|
|
543
713
|
// Test compaction
|
|
@@ -550,7 +720,7 @@ const agents = await client.getAgentsUsingMemoryBank("mb_id");
|
|
|
550
720
|
|
|
551
721
|
// AI assistant
|
|
552
722
|
const suggestion = await client.generateMemoryBankConfig({ user_input: "..." });
|
|
553
|
-
const history = await client.getMemoryBankAiLastConversation();
|
|
723
|
+
const history = await client.getMemoryBankAiLastConversation({ limit: 5 });
|
|
554
724
|
await client.acceptMemoryBankAiSuggestion("conv_id", { ... });
|
|
555
725
|
|
|
556
726
|
// Source management
|
|
@@ -567,6 +737,21 @@ await client.updateSource("source_id", { name: "Renamed" });
|
|
|
567
737
|
await client.deleteSource("source_id");
|
|
568
738
|
```
|
|
569
739
|
|
|
740
|
+
A spend limit caps the credits a source may commit per billing period. When it is
|
|
741
|
+
reached, `stop` refuses new uploads and email, and `delete` removes entries in
|
|
742
|
+
`spend_cap_delete_order` to make room. Send `null` to remove the limit.
|
|
743
|
+
|
|
744
|
+
<!-- sdksync:check -->
|
|
745
|
+
```ts
|
|
746
|
+
const capped = await client.updateSource("source_id", {
|
|
747
|
+
max_credits_per_period: 1000,
|
|
748
|
+
spend_cap_action: "delete",
|
|
749
|
+
spend_cap_delete_order: "oldest_published",
|
|
750
|
+
});
|
|
751
|
+
console.log(capped.spend_cap_reached);
|
|
752
|
+
await client.updateSource("source_id", { max_credits_per_period: null });
|
|
753
|
+
```
|
|
754
|
+
|
|
570
755
|
Indexing status of a source's content, keyed by the `content_version_id` the
|
|
571
756
|
upload methods return:
|
|
572
757
|
|
|
@@ -728,7 +913,7 @@ const bytes = new Uint8Array(await file.arrayBuffer());
|
|
|
728
913
|
### Solutions
|
|
729
914
|
|
|
730
915
|
```ts
|
|
731
|
-
const solutions = await client.listSolutions();
|
|
916
|
+
const solutions = await client.listSolutions({ search: "billing" });
|
|
732
917
|
const sol = await client.createSolution({ name: "My Solution" });
|
|
733
918
|
const fetched = await client.getSolution("solution_id");
|
|
734
919
|
await client.updateSolution("solution_id", { name: "Renamed" });
|
|
@@ -761,7 +946,7 @@ await client.markSolutionConversationTurn("solution_id", "conversation_id", { ..
|
|
|
761
946
|
|
|
762
947
|
```ts
|
|
763
948
|
const plan = await client.generateGovernanceAiPlan({ user_input: "Add a toxicity policy" });
|
|
764
|
-
const convs = await client.listGovernanceAiConversations();
|
|
949
|
+
const convs = await client.listGovernanceAiConversations({ limit: 10 });
|
|
765
950
|
await client.acceptGovernanceAiPlan("conversation_id");
|
|
766
951
|
await client.declineGovernanceAiPlan("conversation_id");
|
|
767
952
|
```
|
|
@@ -769,7 +954,7 @@ await client.declineGovernanceAiPlan("conversation_id");
|
|
|
769
954
|
### Alerts
|
|
770
955
|
|
|
771
956
|
```ts
|
|
772
|
-
const alerts = await client.listAlerts({ status: "active" });
|
|
957
|
+
const alerts = await client.listAlerts({ status: "active", agentId: "agent_id", timeFrom: "2026-10-01T00:00:00Z" });
|
|
773
958
|
const alert = await client.getAlert("alert_id");
|
|
774
959
|
await client.changeAlertStatus("alert_id", { status: "resolved" });
|
|
775
960
|
await client.addAlertComment("alert_id", { text: "Investigating" });
|
|
@@ -779,14 +964,14 @@ await client.subscribeToAlert("alert_id");
|
|
|
779
964
|
await client.unsubscribeFromAlert("alert_id");
|
|
780
965
|
|
|
781
966
|
// Alert configs
|
|
782
|
-
const configs = await client.listAlertConfigs();
|
|
967
|
+
const configs = await client.listAlertConfigs({ agentId: "agent_id" });
|
|
783
968
|
await client.createAlertConfig({ ... });
|
|
784
969
|
await client.getAlertConfig("config_id");
|
|
785
970
|
await client.updateAlertConfig("config_id", { ... });
|
|
786
971
|
await client.deleteAlertConfig("config_id");
|
|
787
972
|
|
|
788
973
|
// Organization preferences
|
|
789
|
-
const prefs = await client.listOrganizationAlertPreferences();
|
|
974
|
+
const prefs = await client.listOrganizationAlertPreferences({ includeDefaults: true });
|
|
790
975
|
await client.updateOrganizationAlertPreference("org_id", "alert_type", { ... });
|
|
791
976
|
```
|
|
792
977
|
|
|
@@ -807,11 +992,11 @@ const embedders = await client.listEmbeddingModels({ supportsInputMedia: "image"
|
|
|
807
992
|
const rerankers = await client.listRerankerModels();
|
|
808
993
|
console.log(embedders.models, embedders.default_model_type, rerankers.models);
|
|
809
994
|
|
|
810
|
-
const alerts = await client.listModelAlerts();
|
|
995
|
+
const alerts = await client.listModelAlerts({ unreadOnly: true });
|
|
811
996
|
await client.markModelAlertRead("alert_id");
|
|
812
997
|
await client.markAllModelAlertsRead();
|
|
813
998
|
const unread = await client.getUnreadModelAlertCount();
|
|
814
|
-
const recs = await client.getModelRecommendations("model_id");
|
|
999
|
+
const recs = await client.getModelRecommendations("model_id", { requireToolUse: true, minContextTokens: 100_000 });
|
|
815
1000
|
|
|
816
1001
|
// Model playground experiments
|
|
817
1002
|
const experiment = await client.createExperiment({ model_ids: ["model_id"], prompt: "..." });
|