@seclai/sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +209 -33
- package/dist/index.cjs +365 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +750 -84
- package/dist/index.d.ts +750 -84
- package/dist/index.js +365 -135
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.7.0] - 2026-10-21
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **Breaking:** Type `score` and `passed` on `TestDraftEvaluationResponse` as `number | null` and `boolean | null` when `status` is `error`. From `apiVersion` `2026-10-21`, which an account created after it ships gets even without setting `apiVersion`, an evaluator that returns no verdict sends them as `null`. Under `strictNullChecks`, code that reads them without first checking `status` no longer compiles: check `result.status !== "error"` before reading them, after which they are `number` and `boolean` again. See [Upgrading to 1.7](https://github.com/seclai/seclai-javascript#upgrading-to-17)
|
|
8
|
+
- Sync the bundled OpenAPI spec and regenerate the types. Existing responses gain properties: `email_address`, `email_allowed_senders`, `feed_attachments`, `document_images` and the `cloud_drive_*` settings on `SourceResponse`, `trigger_id` on `AgentSummaryResponse`, `accepted_attachments` on `AgentAttachmentRefsApiResponse`, `email_run_on_attachment_mismatch` on `EmailTriggerConfigResponse`, `held_for_review` on `SourceContentStatusResponse`, `skipped_attachments` on `ContentDetailResponse`, `error` on `NonManualEvaluationSummaryResponse` and `NonManualEvaluationModeStatResponse`, and `status` on `TestDraftEvaluationResponse`
|
|
9
|
+
- Move `SeclaiApiVersion.Latest` to `2026-10-21`. Nothing is sent unless `apiVersion` is set, so a client that passes `SeclaiApiVersion.Latest` now opts into the six versions added below: `2026-10-05` reports an item held for review by a governance policy as `content_status` `completed` instead of `failed`, so code that looks for holds among failed items must read `held_for_review`; `2026-10-13` rejects a `media_types` value other than `images` or `video`, or any value on a source that is not a website or RSS feed, on `createSource()` and `updateSource()` with a 400 where it was dropped; `2026-10-16` accepts an upload of any type as `ready` at once and stops writing its extracted text into a run's `input`; `2026-10-18` defaults a source's `document_images` to `true` on a text-only embedder; `2026-10-19` rejects `polling_max_items` on `createSource()` for any source but an RSS feed with a 400 where it was stored; and `2026-10-21` leaves an evaluation result whose evaluator returned no verdict (`error`) out of `failed` and the rates in `getNonManualEvaluationSummary()` and out of `average_score` in `getEvaluationCriteriaSummary()`, and returns its `score` and `passed` from `testDraftEvaluation()` as `null` instead of 0.5 and `false`
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Add `setAcceptedAttachments()` to declare the named input attachments a trigger accepts, and `accepted_attachments` on `createAgent()` and `updateAgentDefinition()`. A slot's server-defaulted `min` can be omitted: the slots are typed `AcceptedAttachmentSlotInput`, and the request `SetAcceptedAttachmentsInput`
|
|
14
|
+
- Add `listContentAttachments()`, `getContentAttachment()`, `listContentAttachmentEmbeddings()` and `downloadContentAttachment()` for the files attached to a content item, with their indexing status, text and embeddings. `downloadContentAttachment()` takes a `signal`
|
|
15
|
+
- Add `listEmailSourceRejections()` for the mail an email source refused
|
|
16
|
+
- Add `include_reasoning` to the `runStreamingAgent()` request, to receive `stream_reasoning` events. It stays optional although the schema gives it a default. `runStreamingAgentAndWait()`, which returns no such events, does not take it and does not send one passed anyway
|
|
17
|
+
- Accept the new source settings on `createSource()` and `updateSource()`: `email_allowed_senders`, `feed_attachments`, `document_images` and `cloud_drive_connection_id`, `cloud_drive_folder_path`, `cloud_drive_path_pattern`, `cloud_drive_content_types` and `cloud_drive_max_file_mb`, and `run_on_attachment_mismatch` on `setEmailTriggerConfig()`
|
|
18
|
+
- Add the `SeclaiApiVersion` constants `V2026_10_05`, `V2026_10_13`, `V2026_10_16`, `V2026_10_18`, `V2026_10_19` and `V2026_10_21`, so those versions are accepted as `apiVersion`. The README lists what each one changes
|
|
19
|
+
- Accept a `signal` on `downloadSourceExport()` and `downloadAgentRunAttachment()`
|
|
20
|
+
- Add the type exports `AcceptedAttachmentSlot`, `AcceptedAttachmentSlotInput`, `AcceptedAttachmentsResponse`, `SetAcceptedAttachmentsRequest`, `SetAcceptedAttachmentsInput`, `ContentAttachmentResponse`, `ContentAttachmentsListResponse`, `ContentAttachmentDetailResponse`, `SkippedAttachmentResponse`, `SkippedAttachmentReason`, `EmailSourceRejectionResponse` and `EmailSourceRejectionListResponse`
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Correct `InsufficientCreditsResponse` and `InsufficientCreditsDetail` to the 402 body the API sends: the detail is under `error`, not `detail`, and its machine-readable code is `code`, not `error`. Code that cast a 402 body to this type and read `body.detail.error` threw on every real 402; read `body.error.code` instead
|
|
25
|
+
|
|
26
|
+
## [1.6.1] - 2026-10-05
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Throw `SeclaiError` from the list methods of version-gated endpoints when a successful response is not a list — an error-shaped object, text, or an empty body. Most of them handed that body back as if it were the list; the cloud-drive listings returned `[]`, which reads as "no results". An explicit `data: null` is still an empty list
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Return the declared type from every list method once `apiVersion` is `2026-07-27` or later. The API then answers list endpoints with `{data, pagination}`, and the methods that cast the body handed that object back as their array or keyed type: `getAgentCallers()`, `listModels()`, `listInboundEmailRejections()`, `listGovernanceAiConversations()` and `listSolutionConversations()` returned an object instead of an array, and `listAgentEmailOptOuts()`, `listBlockedEmailSenders()`, `setAutoBlockMode()`, `listAlertConfigs()`, `listOrganizationAlertPreferences()`, `listEmailDomains()`, `listKnowledgeBases()`, `listMemoryBanks()`, `getGenerationTiers()`, `listModelAlerts()` and `listExperiments()` lost their `items`, `configs`, `preferences`, `domains`, `knowledge_bases`, `memory_banks`, `tiers`, `alerts` or `experiments` key. The items are now where each type declares them on both shapes, and `data` and `pagination` stay on the object types, which declare them as optional fields ([#14](https://github.com/seclai/seclai-javascript/issues/14))
|
|
35
|
+
- Fill the flat `total`, `page` and `limit` from `pagination` when `apiVersion` is `2026-07-27` or later, on `listEvaluationResults()`, `listAgentEvaluationResults()`, `listRunEvaluationResults()`, `listEvaluationRuns()`, `listCompatibleRuns()`, `listKnowledgeBases()`, `listMemoryBanks()` and the `total` of the keyed listings above. They were `undefined` although several of those types declare them required ([#14](https://github.com/seclai/seclai-javascript/issues/14))
|
|
36
|
+
- Return an array from `listMemoryBankTemplates()` and `getAgentsUsingMemoryBank()` when `apiVersion` is `2026-07-27` or later, as they do by default. Both are typed `unknown` and returned the `{data, pagination}` object; code that worked around it by reading `.data` must now read the array itself ([#14](https://github.com/seclai/seclai-javascript/issues/14))
|
|
37
|
+
- Reject an unknown `Seclai-Version` passed in the per-request `headers` of `request()` or `requestRaw()` with `SeclaiConfigurationError`, in any letter case. It was sent unchecked, bypassing the guard on `apiVersion`; a caller who relied on that to send a version this release does not know must now set `allowUnknownApiVersion` ([#15](https://github.com/seclai/seclai-javascript/issues/15))
|
|
38
|
+
- Reject an empty `Seclai-Version` in `defaultHeaders` or per-request `headers`. It passed the guard and replaced the configured version with an empty header ([#15](https://github.com/seclai/seclai-javascript/issues/15))
|
|
39
|
+
- Send exactly one value per header on the plain, download, upload and streaming paths. A default or per-request header that differed only in case from another layer's was sent beside it and joined by `fetch`: a default `X-API-Key` went out as `other, real`, a default `Authorization` beside the bearer token, and a per-request `Content-Type` could not replace the JSON one. Which layer wins is unchanged ([#15](https://github.com/seclai/seclai-javascript/issues/15))
|
|
40
|
+
- Keep the multipart boundary on uploads when `defaultHeaders` sets a content type in any case other than `content-type` or `Content-Type` ([#15](https://github.com/seclai/seclai-javascript/issues/15))
|
|
41
|
+
- Correct the README's API-versioning section: `2026-08-03` also rejects a non-zero `max_age_days` on `updateMemoryBank()`; `2026-09-30` breaks code that parses a run's or step's `output` as a JSON manifest; and `SeclaiApiVersion.Latest` moves with each SDK release — `1.6.0` moved it across that `2026-09-30` change — so pin a dated constant to keep behaviour fixed
|
|
42
|
+
|
|
3
43
|
## [1.6.0] - 2026-10-04
|
|
4
44
|
|
|
5
45
|
### Changed
|
|
@@ -206,6 +246,8 @@ _Stable release. No functional changes since 0.0.1._
|
|
|
206
246
|
|
|
207
247
|
_Initial release._
|
|
208
248
|
|
|
249
|
+
[1.7.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.7.0
|
|
250
|
+
[1.6.1]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.1
|
|
209
251
|
[1.6.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.6.0
|
|
210
252
|
[1.5.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.5.0
|
|
211
253
|
[1.4.0]: https://github.com/seclai/seclai-javascript/releases/tag/1.4.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.7.0/
|
|
108
108
|
|
|
109
109
|
Release history is in [`CHANGELOG.md`](CHANGELOG.md).
|
|
110
110
|
|
|
@@ -127,12 +127,14 @@ 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_10_21`,
|
|
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.
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
The same check applies to a `Seclai-Version` set through `defaultHeaders` or the
|
|
135
|
+
per-request `headers` of `request()` / `requestRaw()`, in any letter case, and an
|
|
136
|
+
empty value is rejected. Upgrade the package to adopt a new version, or set
|
|
137
|
+
`allowUnknownApiVersion` if you have to move first and accept that risk.
|
|
136
138
|
|
|
137
139
|
The guard only covers the header. An account pinned server-side can still be
|
|
138
140
|
newer than this release — `getApiVersion()` reports the `effective_version` the
|
|
@@ -140,38 +142,104 @@ request resolved to, and comparing it against `SeclaiApiVersion.Latest` is how
|
|
|
140
142
|
you detect the gap.
|
|
141
143
|
|
|
142
144
|
**What `2026-07-27` changes.** Undeclared query parameters become a 422 instead
|
|
143
|
-
of being ignored, and list
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
of being ignored, and every list endpoint that answered with a bare array or
|
|
146
|
+
under a per-resource key moves to the canonical `{data, pagination}` envelope.
|
|
147
|
+
The methods for those endpoints return their declared type on either shape, so
|
|
148
|
+
code written against the default still reads the result after you opt in. Four
|
|
149
|
+
of them return fewer rows once you do, covered below the table:
|
|
146
150
|
|
|
147
|
-
|
|
|
151
|
+
| Declared return | Methods | From 2026-07-27 |
|
|
148
152
|
| --- | --- | --- |
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
152
|
-
| `
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
| An array | `listEvaluationCriteria()`, `getAgentCallers()`, `listInboundEmailRejections()`, `listGovernanceAiConversations()`, `listSolutionConversations()`, `listModels()`, `listMemoryBankTemplates()`, `getAgentsUsingMemoryBank()`, `listCloudDriveProviders()`, `listCloudDrives()`, `getAgentsUsingCloudDrive()`, `listCloudDriveRejections()` | Still the array of items; the page metadata is not returned |
|
|
154
|
+
| `data`, bare array by default | `listEvaluationCriteriaPage()`, `listRunEvaluationResults()` | `data`, plus `pagination` |
|
|
155
|
+
| `data` with flat `total`/`page`/`limit` | `listEvaluationResults()`, `listAgentEvaluationResults()`, `listEvaluationRuns()`, `listCompatibleRuns()` | Unchanged, plus `pagination` |
|
|
156
|
+
| A per-resource key | `listAgentEmailOptOuts()` and `listBlockedEmailSenders()` / `setAutoBlockMode()` (`items`), `listAlertConfigs()` (`configs`), `listOrganizationAlertPreferences()` (`preferences`), `listEmailDomains()` (`domains`), `listKnowledgeBases()` (`knowledge_bases`), `listMemoryBanks()` (`memory_banks`), `getGenerationTiers()` (`tiers`), `listModelAlerts()` (`alerts`), `listExperiments()` (`experiments`), `listEmbeddingModels()` and `listRerankerModels()` (`models`) | The same key and any flat `total`/`page`/`limit`, plus `data` and `pagination` |
|
|
157
|
+
|
|
158
|
+
Where a type declares flat `total`, `page` or `limit`, the client fills them
|
|
159
|
+
from `pagination` after you opt in. `listRunEvaluationResults()` has no counters
|
|
160
|
+
on its default bare array, and gains them with `pagination`. Fields that sit
|
|
161
|
+
beside a list, such as `auto_block_mode` or the email-domain plan capabilities,
|
|
162
|
+
are present on both shapes.
|
|
163
|
+
|
|
164
|
+
Opting in also turns paging on for endpoints that returned everything by
|
|
165
|
+
default, so the same call can return fewer rows:
|
|
166
|
+
|
|
167
|
+
- `listEvaluationCriteria()` and `listRunEvaluationResults()` return every item
|
|
168
|
+
by default and one page (20 unless you pass `limit`) after you opt in. The
|
|
169
|
+
array from `listEvaluationCriteria()` carries no sign of that; use
|
|
170
|
+
`listEvaluationCriteriaPage()` to see `pagination`.
|
|
171
|
+
- `listAlertConfigs()` ignores `page` and `limit` by default and returns every
|
|
172
|
+
config; after you opt in it returns one page.
|
|
173
|
+
- `setAutoBlockMode()` reports the account's full `total` by default, and the
|
|
174
|
+
number of rows it returned after you opt in.
|
|
175
|
+
|
|
176
|
+
**Later versions.** Each is cumulative. Some change a value you may be reading,
|
|
177
|
+
a request that used to succeed, or (from `2026-10-21`) which fields can be
|
|
178
|
+
`null`:
|
|
179
|
+
|
|
180
|
+
- `2026-09-30` and `2026-10-16` change what a string you may be parsing
|
|
181
|
+
contains — a run's `output`, and a run's `input` when it has uploads.
|
|
182
|
+
- `2026-10-05` changes a value you may branch on: an item held for review
|
|
183
|
+
reports `content_status` `completed` instead of `failed`, so code that looks
|
|
184
|
+
for governance holds among `failed` items stops finding them. Check
|
|
185
|
+
`held_for_review` instead.
|
|
186
|
+
- `2026-10-13` and `2026-10-19` reject with a 400 source settings that were
|
|
187
|
+
accepted before.
|
|
188
|
+
- `2026-10-21` changes evaluation numbers you may be reading: an `error` result
|
|
189
|
+
no longer counts as `failed` or toward the rates, and `testDraftEvaluation()`
|
|
190
|
+
returns `null` `score` and `passed` for one.
|
|
167
191
|
|
|
168
192
|
| Version | What it changes |
|
|
169
193
|
| --- | --- |
|
|
170
|
-
| `2026-08-03` | `createMemoryBank()`
|
|
194
|
+
| `2026-08-03` | `createMemoryBank()` and `updateMemoryBank()` reject a non-zero `max_age_days` with a 400, and a memory bank's `max_age_days` reads as `null`. On create, an omitted `retention_days` resolves per bank type instead of to 30 |
|
|
171
195
|
| `2026-08-21` | `createSource()` rejects an embedding dimension its embedder does not support with a 400 — `listEmbeddingModels()` reports the supported ones |
|
|
172
196
|
| `2026-09-28` | Agent-definition writes use the current file-list grammar: an omitted `attachments` keeps the stored list and `[]` means no files |
|
|
173
|
-
| `2026-09-30` | A run's and a step's `output`, and a step's `input`, are the text
|
|
197
|
+
| `2026-09-30` | **Breaks code that parses `output`.** A run's and a step's `output`, and a step's `input`, are the plain text; below this version an output that has files is a JSON manifest string (`{schema, text, attachments}`). Read files from `attachments`, which is populated on every version |
|
|
174
198
|
| `2026-10-03` | A new LLM step written without `attachments` takes its parent's files, and a new retrieval step's matched media are its files |
|
|
199
|
+
| `2026-10-05` | An item held for review by an Enforce governance policy reports `content_status` `completed` (with `held_for_review: true`) from `listSourceContents()` and `getSourceContentStatus()`. Below it the item reports `failed` with the hold as the `error` |
|
|
200
|
+
| `2026-10-13` | `createSource()` and `updateSource()` reject a `media_types` value other than `images` or `video`, or any value on a source that is not a website or RSS feed, with a 400. Below it an unknown value is dropped |
|
|
201
|
+
| `2026-10-16` | `uploadAgentInput()` accepts a file of any type and it is `ready` at once. Each step receives the file itself when its model reads that type, and its text otherwise; a run's `input` carries only a `# filename` heading per file. Below it only a fixed list of extensions is accepted and each file's extracted text is written into `input`, so poll `getAgentInputUploadStatus()` before running |
|
|
202
|
+
| `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
|
+
| `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
|
+
| `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 |
|
|
205
|
+
|
|
206
|
+
**`Latest` moves with the SDK.** `SeclaiApiVersion.Latest` is the newest version
|
|
207
|
+
the installed release knows, so upgrading the package can opt a client that
|
|
208
|
+
passes it into every version added since — `1.6.0` moved it from `2026-07-27` to
|
|
209
|
+
`2026-10-03`, across the `2026-09-30` output change, and `1.7.0` moves it to
|
|
210
|
+
`2026-10-21`, across the `2026-10-05` status change, the `2026-10-13` and
|
|
211
|
+
`2026-10-19` source-setting rejections, the `2026-10-16` input change and the
|
|
212
|
+
`2026-10-21` evaluation change. Pass a
|
|
213
|
+
dated constant such as `SeclaiApiVersion.V2026_07_27` to keep behaviour fixed
|
|
214
|
+
across upgrades.
|
|
215
|
+
|
|
216
|
+
## Upgrading to 1.7
|
|
217
|
+
|
|
218
|
+
Two type changes can stop existing code compiling. If you pass
|
|
219
|
+
`SeclaiApiVersion.Latest`, it now sends `2026-10-21`; the table above lists
|
|
220
|
+
what each version changes.
|
|
221
|
+
|
|
222
|
+
**`testDraftEvaluation()` can return `null` scores.** When the evaluator
|
|
223
|
+
returns no verdict, `status` is `error`. From API version `2026-10-21`, `score`
|
|
224
|
+
and `passed` are then `null`. An account created after `2026-10-21` ships gets
|
|
225
|
+
that version even without setting `apiVersion`. Check `status` before reading
|
|
226
|
+
them, in JavaScript too; under `strictNullChecks` the type enforces it:
|
|
227
|
+
|
|
228
|
+
<!-- sdksync:check -->
|
|
229
|
+
```ts
|
|
230
|
+
const result = await client.testDraftEvaluation("agent_id", { step_output: "...", pass_threshold: 0.7 });
|
|
231
|
+
|
|
232
|
+
// 1.6 and earlier: console.log(result.score.toFixed(2), result.passed);
|
|
233
|
+
if (result.status === "error") {
|
|
234
|
+
console.log("No verdict:", result.explanation);
|
|
235
|
+
} else {
|
|
236
|
+
console.log(result.score.toFixed(2), result.passed); // number and boolean here
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**`InsufficientCreditsResponse` matches the 402 body.** Read the code at
|
|
241
|
+
`error.code`, not `detail.error`. Code that cast a 402 body to this type threw
|
|
242
|
+
on every real 402 before, so this only fixes it.
|
|
175
243
|
|
|
176
244
|
## Resources
|
|
177
245
|
|
|
@@ -276,6 +344,21 @@ for await (const event of client.runStreamingAgent(
|
|
|
276
344
|
}
|
|
277
345
|
```
|
|
278
346
|
|
|
347
|
+
Pass `include_reasoning: true` to also receive `stream_reasoning` events carrying
|
|
348
|
+
the model's reasoning while it thinks. They are sent only for a
|
|
349
|
+
`streaming_result` step whose author enabled `show_reasoning`, and reasoning is
|
|
350
|
+
never part of `output`:
|
|
351
|
+
|
|
352
|
+
<!-- sdksync:check -->
|
|
353
|
+
```ts
|
|
354
|
+
for await (const event of client.runStreamingAgent("agent_id", {
|
|
355
|
+
input: "Hello",
|
|
356
|
+
include_reasoning: true,
|
|
357
|
+
})) {
|
|
358
|
+
if (event.event === "stream_reasoning") console.log(event.data);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
279
362
|
### Polling
|
|
280
363
|
|
|
281
364
|
For environments where SSE is not practical, poll for a completed run:
|
|
@@ -290,6 +373,7 @@ const result = await client.runAgentAndPoll(
|
|
|
290
373
|
|
|
291
374
|
### Agent input uploads
|
|
292
375
|
|
|
376
|
+
<!-- sdksync:check -->
|
|
293
377
|
```ts
|
|
294
378
|
// Discover which files (if any) the agent expects before staging uploads
|
|
295
379
|
const refs = await client.getAgentAttachmentReferences("agent_id");
|
|
@@ -298,14 +382,26 @@ if (refs.requires_uploads) {
|
|
|
298
382
|
}
|
|
299
383
|
|
|
300
384
|
const upload = await client.uploadAgentInput("agent_id", {
|
|
301
|
-
file: new Uint8Array([
|
|
385
|
+
file: new Uint8Array([/* file bytes */]),
|
|
302
386
|
fileName: "input.pdf",
|
|
303
387
|
});
|
|
304
|
-
|
|
388
|
+
// From API version 2026-10-16 the upload is `ready` at once. Below it, poll
|
|
389
|
+
// until `status` is `ready` before running.
|
|
390
|
+
let status = await client.getAgentInputUploadStatus("agent_id", upload.id);
|
|
391
|
+
while (status.status !== "ready") {
|
|
392
|
+
if (status.status === "failed") throw new Error(`Upload failed: ${status.error}`);
|
|
393
|
+
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
394
|
+
status = await client.getAgentInputUploadStatus("agent_id", upload.id);
|
|
395
|
+
}
|
|
396
|
+
const run = await client.runAgent("agent_id", { input_upload_id: upload.id, priority: false });
|
|
305
397
|
```
|
|
306
398
|
|
|
399
|
+
Only a `dynamic_input` agent takes uploads; any other agent rejects one with a
|
|
400
|
+
400.
|
|
401
|
+
|
|
307
402
|
### Agent run attachments
|
|
308
403
|
|
|
404
|
+
<!-- sdksync:check -->
|
|
309
405
|
```ts
|
|
310
406
|
// Download a file emitted by a step in an agent run. The attachment_id is the
|
|
311
407
|
// URL-safe-base64 storage_key surfaced in run output manifests / webhooks.
|
|
@@ -329,6 +425,31 @@ const config = await client.setEmailTriggerConfig("agent_id", "trigger_id", {
|
|
|
329
425
|
console.log(config.email_addresses); // ["support.<accountID>@agent.seclai.com", ...]
|
|
330
426
|
```
|
|
331
427
|
|
|
428
|
+
Set `run_on_attachment_mismatch: true` to run an email whose attachments do not
|
|
429
|
+
fit what the agent accepts: files it cannot take are left out and the problems
|
|
430
|
+
are listed in the run's `email_attachment_issues` metadata. By default the run fails.
|
|
431
|
+
|
|
432
|
+
### Accepted attachments
|
|
433
|
+
|
|
434
|
+
Declare the input attachments a trigger accepts. A run's files are each assigned
|
|
435
|
+
to one named slot before any step runs, and steps reference a slot as
|
|
436
|
+
`{{agent.attachments.<name>}}`. The call replaces the whole declaration, and is
|
|
437
|
+
refused with a 400 when the agent references a slot it leaves out. `min` defaults
|
|
438
|
+
to 0. The same slots can be set as `accepted_attachments` on `createAgent()` and
|
|
439
|
+
`updateAgentDefinition()`.
|
|
440
|
+
|
|
441
|
+
<!-- sdksync:check -->
|
|
442
|
+
```ts
|
|
443
|
+
const agent = await client.getAgent("agent_id");
|
|
444
|
+
const { accepted_attachments } = await client.setAcceptedAttachments("agent_id", agent.trigger_id!, {
|
|
445
|
+
accepted_attachments: [
|
|
446
|
+
{ name: "invoice", content_types: ["application/pdf"], min: 1, max: 1 },
|
|
447
|
+
{ name: "photos", content_types: ["image/*"], label: "Photos of the damage" },
|
|
448
|
+
],
|
|
449
|
+
});
|
|
450
|
+
console.log(accepted_attachments.map((slot) => `${slot.name}: ${slot.min}..${slot.max ?? "any"}`));
|
|
451
|
+
```
|
|
452
|
+
|
|
332
453
|
### Agent email governance
|
|
333
454
|
|
|
334
455
|
```ts
|
|
@@ -376,8 +497,10 @@ const detail = await client.getEvaluationCriteria("criteria_id");
|
|
|
376
497
|
await client.updateEvaluationCriteria("criteria_id", { ... });
|
|
377
498
|
await client.deleteEvaluationCriteria("criteria_id");
|
|
378
499
|
|
|
379
|
-
// Test a draft
|
|
380
|
-
|
|
500
|
+
// Test a draft. Check status first: an "error" result has no verdict, and its
|
|
501
|
+
// score and passed can be null.
|
|
502
|
+
const draft = await client.testDraftEvaluation("agent_id", { step_output: "...", pass_threshold: 0.7 });
|
|
503
|
+
if (draft.status !== "error") console.log(draft.score, draft.passed);
|
|
381
504
|
|
|
382
505
|
// Results by criteria
|
|
383
506
|
const results = await client.listEvaluationResults("criteria_id");
|
|
@@ -456,9 +579,40 @@ const batch = await client.listSourceContents("source_id", {
|
|
|
456
579
|
console.log(batch.pagination.total, failed.data.map((item) => item.error));
|
|
457
580
|
|
|
458
581
|
const one = await client.getSourceContentStatus("source_id", "cv_1");
|
|
459
|
-
console.log(one.content_status);
|
|
582
|
+
console.log(one.content_status, one.held_for_review);
|
|
460
583
|
```
|
|
461
584
|
|
|
585
|
+
An item an Enforce governance policy blocked at import is held for review:
|
|
586
|
+
`held_for_review` is `true` until a reviewer releases it. Its `content_status` is
|
|
587
|
+
`completed` from API version `2026-10-05`, and `failed` with the hold as the
|
|
588
|
+
`error` below it.
|
|
589
|
+
|
|
590
|
+
An email source stores mail from `email_allowed_senders` only, and lists what it
|
|
591
|
+
refused. Each entry names the sender and the reason, never the subject or body;
|
|
592
|
+
adding a refused sender to `email_allowed_senders` helps only when `authenticated`
|
|
593
|
+
is `true`. Listing rejections requires an account owner or administrator.
|
|
594
|
+
|
|
595
|
+
<!-- sdksync:check -->
|
|
596
|
+
```ts
|
|
597
|
+
const inbox = await client.createSource({
|
|
598
|
+
name: "Newsletters",
|
|
599
|
+
source_type: "email",
|
|
600
|
+
email_allowed_senders: ["news@example.com", "example.org"],
|
|
601
|
+
});
|
|
602
|
+
console.log(inbox.email_address); // send mail here
|
|
603
|
+
|
|
604
|
+
const rejections = await client.listEmailSourceRejections(inbox.id, { page: 1, limit: 50 });
|
|
605
|
+
for (const r of rejections.data) console.log(r.from_address, r.reason, r.authenticated);
|
|
606
|
+
|
|
607
|
+
// Index the images inside documents, and an RSS feed's enclosures
|
|
608
|
+
await client.updateSource("source_id", { document_images: true, feed_attachments: ["enclosures"] });
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
A `cloud_drive` source takes `cloud_drive_connection_id` (from `listCloudDrives()`)
|
|
612
|
+
on create, and `cloud_drive_folder_path`, `cloud_drive_path_pattern`,
|
|
613
|
+
`cloud_drive_content_types` and `cloud_drive_max_file_mb` to choose which files
|
|
614
|
+
it indexes.
|
|
615
|
+
|
|
462
616
|
### Cloud drives
|
|
463
617
|
|
|
464
618
|
<!-- sdksync:check -->
|
|
@@ -549,6 +703,28 @@ await client.uploadFileToContent("content_id", {
|
|
|
549
703
|
});
|
|
550
704
|
```
|
|
551
705
|
|
|
706
|
+
A content item's attachments are the files an agent step, an email, a feed, a
|
|
707
|
+
web page's media or a document's images added to it. Each says whether it is
|
|
708
|
+
indexed for search and, if indexing failed, why. An email item's
|
|
709
|
+
`skipped_attachments` (on `getContentDetail()`) lists the parts that were not
|
|
710
|
+
stored, with the reason.
|
|
711
|
+
|
|
712
|
+
<!-- sdksync:check -->
|
|
713
|
+
```ts
|
|
714
|
+
const attachments = await client.listContentAttachments("content_id", { limit: 50 });
|
|
715
|
+
for (const att of attachments.data) {
|
|
716
|
+
console.log(att.id, att.content_type, att.indexed, att.indexing_error);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const att = await client.getContentAttachment("content_id", "attachment_id", { start: 0, end: 2000 });
|
|
720
|
+
console.log(att.text_content, att.file_withheld);
|
|
721
|
+
const vectors = await client.listContentAttachmentEmbeddings("content_id", "attachment_id");
|
|
722
|
+
|
|
723
|
+
// Raw Response; 403 while the file is withheld (see `file_withheld`).
|
|
724
|
+
const file = await client.downloadContentAttachment("content_id", "attachment_id");
|
|
725
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
726
|
+
```
|
|
727
|
+
|
|
552
728
|
### Solutions
|
|
553
729
|
|
|
554
730
|
```ts
|