@naturali/sdk 0.268.0 → 0.270.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/dist/index.mjs CHANGED
@@ -838,7 +838,7 @@ var Channels = class {
838
838
  /**
839
839
  * Create a route
840
840
  *
841
- * `action` is required; `agent_id` is required when it is `agent`, `text` when it is `message`; `repeat` is only valid alongside `action: message`. `surface`, when present, must be one this channel's kind serves (`GET /v1/channel-kinds`) — otherwise `400 unknown_surface`. `match` keys must be predicates that kind's registry declares — otherwise `400 unknown_predicate`. Writing a route for a surface whose transport mode is off (e.g. a Discord `guild_thread` route before `mention_threads` is enabled) still succeeds, with `unreachable_surface` in the response `warnings`.
841
+ * `action` is required; `agent_id` is required when it is `agent`, `text` when it is `message`; `repeat` is only valid alongside `action: message`. `surface`, when present, must be one this channel's kind serves (`GET /v1/channel-kinds`) — otherwise `400 UNKNOWN_SURFACE`. `match` keys must be predicates that kind's registry declares — otherwise `400 UNKNOWN_PREDICATE`. Writing a route for a surface whose transport mode is off (e.g. a Discord `guild_thread` route before `mention_threads` is enabled) still succeeds, with `unreachable_surface` in the response `warnings`.
842
842
  *
843
843
  */
844
844
  static createChannelRoute(options) {
@@ -878,7 +878,7 @@ var Channels = class {
878
878
  /**
879
879
  * Replace a route
880
880
  *
881
- * Full replace, the same validation as create: an omitted field takes its create default. Where that default would widen a value the route sets, omission is `400 replace_omits_fields`, naming the fields in `details.fields`, and nothing is written: a set `surface` (the default is any surface), a non-empty `match` (every message), a non-empty `config` (it carries the Discord allowlist), and `status` on a `disabled` route (the default re-activates it). Send the value to keep it, or `"surface": null`, `"match": {}`, `"config": null`, `"status": "active"` to clear it.
881
+ * Full replace, the same validation as create: an omitted field takes its create default. Where that default would widen a value the route sets, omission is `400 REPLACE_OMITS_FIELDS`, naming the fields in `meta.fields`, and nothing is written: a set `surface` (the default is any surface), a non-empty `match` (every message), a non-empty `config` (it carries the Discord allowlist), and `status` on a `disabled` route (the default re-activates it). Send the value to keep it, or `"surface": null`, `"match": {}`, `"config": null`, `"status": "active"` to clear it.
882
882
  *
883
883
  */
884
884
  static replaceChannelRoute(options) {
@@ -918,17 +918,17 @@ var Channels = class {
918
918
  * Connect a channel
919
919
  *
920
920
  * Connect a channel. The required fields depend on `channel`; no credential is ever returned.
921
- * **Discord** (`channel: discord`) — supply `application_id` and `bot_token`, plus the `modes` selecting which Gateway flows to serve (direct messages, and/or @mention-opens-a-thread). The token is checked with Discord first: `400 invalid_bot_token` when Discord rejects it, `400 application_mismatch` when it belongs to another application, `502 discord_unavailable` when Discord cannot be read. Returns `501` when this deployment does not enable Discord channels.
922
- * **X** (`channel: x`) — supply the bot's `bot_token` (X developer portal, Chat bots) and the `consumer_key` and `consumer_secret` of the app that issued it. naturali then registers its own webhook on that app, subscribes it to the bot's incoming direct messages and registers the bot's chat encryption key, keeping the private key sealed: replies are end-to-end encrypted, and the project never handles keys, webhooks or ciphertext. Pass `chat_private_keys` and `chat_key_version` instead to keep a key the bot already registered. `400 invalid_bot_token` or `400 invalid_consumer_credentials` when X rejects a credential, `409 bot_in_use` when another channel holds the bot, `502 x_provisioning_failed` when X refuses the webhook or the subscription (an app holds a limited number of webhooks), `429 x_key_registration_limited` when the bot used its few daily key registrations, `502 x_unavailable` when X cannot be reached. Returns `501` when this deployment does not enable X channels.
921
+ * **Discord** (`channel: discord`) — supply `application_id` and `bot_token`, plus the `modes` selecting which Gateway flows to serve (direct messages, and/or @mention-opens-a-thread). The token is checked with Discord first: `400 INVALID_BOT_TOKEN` when Discord rejects it, `400 APPLICATION_MISMATCH` when it belongs to another application, `502 DISCORD_UNAVAILABLE` when Discord cannot be read. Returns `501` when this deployment does not enable Discord channels.
922
+ * **X** (`channel: x`) — supply the bot's `bot_token` (X developer portal, Chat bots) and the `consumer_key` and `consumer_secret` of the app that issued it. naturali then registers its own webhook on that app, subscribes it to the bot's incoming direct messages and registers the bot's chat encryption key, keeping the private key sealed: replies are end-to-end encrypted, and the project never handles keys, webhooks or ciphertext. Pass `chat_private_keys` and `chat_key_version` instead to keep a key the bot already registered. `400 INVALID_BOT_TOKEN` or `400 INVALID_CONSUMER_CREDENTIALS` when X rejects a credential, `409 BOT_IN_USE` when another channel holds the bot, `502 X_PROVISIONING_FAILED` when X refuses the webhook or the subscription (an app holds a limited number of webhooks), `429 X_KEY_REGISTRATION_LIMITED` when the bot used its few daily key registrations, `502 X_UNAVAILABLE` when X cannot be reached. Returns `501` when this deployment does not enable X channels.
923
923
  * **WhatsApp** (default) — one of two credential paths, both filling the same write-only secret:
924
924
  * * **BYOT** (`credential_source: byot`, default) — supply
925
925
  * `phone_number_id` and `access_token` from your own Meta app. The
926
- * number is read with the token first: `400 invalid_access_token` when
927
- * Meta rejects the token, `400 phone_number_not_accessible` when it
928
- * cannot reach that number, `502 meta_unavailable` when Meta fails.
926
+ * number is read with the token first: `400 INVALID_ACCESS_TOKEN` when
927
+ * Meta rejects the token, `400 PHONE_NUMBER_NOT_ACCESSIBLE` when it
928
+ * cannot reach that number, `502 META_UNAVAILABLE` when Meta fails.
929
929
  * The token's app is then subscribed to the WABA Meta reports as the
930
930
  * number's owner, which is the `waba_id` stored:
931
- * `400 waba_not_manageable` when the token cannot subscribe to it.
931
+ * `400 WABA_NOT_MANAGEABLE` when the token cannot subscribe to it.
932
932
  *
933
933
  * * **Embedded signup** (`credential_source: embedded_signup`) — supply
934
934
  * `code` and `waba_id` from the Meta popup; naturali exchanges the
@@ -938,7 +938,7 @@ var Channels = class {
938
938
  * are not configured.
939
939
  *
940
940
  *
941
- * The project's plan limits how many channels it may hold. At the limit this responds `403` with `plan_limit_reached`, whose `details` carry the `plan` and the `limit`, before any credential is acquired. Only `active` channels count, so disabling one frees allowance without deleting it.
941
+ * The project's plan limits how many channels it may hold. At the limit this responds `403` with `PLAN_LIMIT_REACHED`, whose `meta` carries the `plan` and the `limit`, before any credential is acquired. Only `active` channels count, so disabling one frees allowance without deleting it.
942
942
  *
943
943
  */
944
944
  static createChannel(options) {
@@ -970,7 +970,7 @@ var Channels = class {
970
970
  /**
971
971
  * Complete a WhatsApp signup
972
972
  *
973
- * Finish a signup link: the app's result page receives `pending` and the numbers Meta granted, and sends back the one to connect. The caller must be a member of the project the link was created for (`404` otherwise), so a link opened by anyone else connects nothing. `pending` expires 10 minutes after the dialog returns (`400 link_expired`).
973
+ * Finish a signup link: the app's result page receives `pending` and the numbers Meta granted, and sends back the one to connect. The caller must be a member of the project the link was created for (`404` otherwise), so a link opened by anyone else connects nothing. `pending` expires 10 minutes after the dialog returns (`400 LINK_EXPIRED`).
974
974
  *
975
975
  */
976
976
  static completeWhatsappSignup(options) {
@@ -1010,7 +1010,7 @@ var Channels = class {
1010
1010
  /**
1011
1011
  * Update a channel
1012
1012
  *
1013
- * Rotate the credential, update the kind's config (`waba_id` / `credential_source` for WhatsApp, `modes` for Discord), or flip the naturali-side status. At least one field is required. Rotating a WhatsApp token first reads the number with it, as connect does (`400 invalid_access_token`, `400 phone_number_not_accessible`, `502 meta_unavailable`, keeping the old token), then stores a new write-only secret, repoints the send tool and deletes the old secret; rotating a Discord bot token reseals it and the gateway worker reconnects with it.
1013
+ * Rotate the credential, update the kind's config (`waba_id` / `credential_source` for WhatsApp, `modes` for Discord), or flip the naturali-side status. At least one field is required. Rotating a WhatsApp token first reads the number with it, as connect does (`400 INVALID_ACCESS_TOKEN`, `400 PHONE_NUMBER_NOT_ACCESSIBLE`, `502 META_UNAVAILABLE`, keeping the old token), then stores a new write-only secret, repoints the send tool and deletes the old secret; rotating a Discord bot token reseals it and the gateway worker reconnects with it.
1014
1014
  *
1015
1015
  */
1016
1016
  static updateChannel(options) {
@@ -3499,7 +3499,7 @@ var Generations = class {
3499
3499
  *
3500
3500
  * The transcript is assembled at read time from the generation record and the trace's steps object; nothing is stored, so it cannot outlive the content it projects. Requires `traces:GetTrace` in addition to `generations:GetGeneration`, because the response merges content from both resources.
3501
3501
  *
3502
- * A generation whose content is unavailable — never written under zero-retention, or cleared by a purge — returns `200` with the skeleton rather than an error: `input` and `output` are null, `steps` is empty, and the `content_redacted_*` fields say which happened. `content_redacted_by_principal_id` is `zero_retention` when the content was never stored, and the purging principal's ID when it was erased later. A generation that is still running returns the same shape with an empty `steps`; `status` disambiguates the two.
3502
+ * A generation whose content is unavailable — never written under zero-retention, or cleared by a purge — returns `200` with the skeleton rather than an error: `input` and `output` are null, `steps` is empty, and the `content_redacted_*` fields say which happened. `content_redacted_by_principal_id` is `zero_retention` when the content was never stored, and the purging principal's ID when it was erased later. A generation that is still running returns the steps it has ended so far and its `in_flight_tool_calls`; `status` says it runs. To follow it as it runs, read `GET /v1/projects/{project_id}/generations/{generation_id}/events`.
3503
3503
  *
3504
3504
  */
3505
3505
  static getGenerationTranscript(options) {
@@ -3508,6 +3508,22 @@ var Generations = class {
3508
3508
  ...options
3509
3509
  });
3510
3510
  }
3511
+ /**
3512
+ * List a generation's events
3513
+ *
3514
+ * The generation's transcript, incrementally: its progress rows in `seq` order, after `after_seq`. Each `generations.step_ended` row carries the step it ended as a `TranscriptStep`; the other rows say when a step or a tool call started and ended, and which generation a tool call started.
3515
+ *
3516
+ * Step content and tool names are the trace's content: reading them needs `traces:GetTrace` on the generation's trace beside `generations:GetGeneration`, and is refused with `403` without it. `progress_only=true` asks for the rows alone (`step` is null), which `generations:GetGeneration` alone allows. Content is re-read on every page: once a purge erases it, or under zero-retention, `step` is null.
3517
+ *
3518
+ * `stream=true` answers `text/event-stream` instead and follows the generation until it settles (`completed`, `failed` or `requires_action`), or stops running without a settle row. Each row is one `event: progress` frame whose `id` is its `seq`; the stream ends with `data: [DONE]`. A `: heartbeat` comment is sent every 15 seconds. After 5 minutes the stream ends with `event: end` and `data: {"reason": "max_lifetime", "generation_id": "...", "after_seq": N}`: reconnect with that `after_seq`, or let an `EventSource` reconnect with its `Last-Event-ID` header, which this route reads as `after_seq`. Every reconnect is authorized afresh.
3519
+ *
3520
+ */
3521
+ static listGenerationEvents(options) {
3522
+ return (options.client ?? client).get({
3523
+ url: "/v1/projects/{project_id}/generations/{generation_id}/events",
3524
+ ...options
3525
+ });
3526
+ }
3511
3527
  };
3512
3528
  var Guardrails = class {
3513
3529
  /**
@@ -5173,7 +5189,7 @@ var Projects = class {
5173
5189
  *
5174
5190
  * Creates a project (one per client or per environment).
5175
5191
  *
5176
- * Your plan limits how many projects you may own. At the limit this responds `403` with `plan_limit_reached`, whose `details` carry the `plan` and the `limit`. An archived project still counts — archiving keeps every resource, so it frees nothing; deleting a project does.
5192
+ * Your plan limits how many projects you may own. At the limit this responds `403` with `PLAN_LIMIT_REACHED`, whose `meta` carries the `plan` and the `limit`. An archived project still counts — archiving keeps every resource, so it frees nothing; deleting a project does.
5177
5193
  *
5178
5194
  * A new project starts at the content-retention window your plan sets (`trace_content_retention_days`); `PATCH` it to anything shorter.
5179
5195
  *
@@ -5221,11 +5237,11 @@ var Projects = class {
5221
5237
  * Rename or archive a project, and/or change its content-retention settings (`trace_content_retention_days`, `trace_content_mode`), its execution ceilings (`max_concurrent_runs`, `max_chain_generations`, `max_orchestration_run_depth`), its priced-model gate (`require_priced_model`), its project-scope guardrails (`guardrail_ids`), the policies capping every agent turn in it (`agent_policy_ids`), the tag keys a change of agent-readable text removes (`content_bound_tag_keys`) and managed conversion (`managed_conversion`). Archiving is reversible; resources are retained.
5222
5238
  * Requires the `admin` role in the project (an `owner` has it too). These are the terms every member works under, which is why setting them sits above the role that works under them.
5223
5239
  * The ceilings and the priced-model gate are uncapped by plan: each one only ever narrows what the project may spend, so setting one takes on a restriction rather than claiming an entitlement. On the three ceilings `null` clears the project's own bound and omission leaves it alone — they are different instructions.
5224
- * `guardrail_ids` is the floor under every tool call by every agent in the project, including tools added later. The list is replaced wholesale, so send the ids you want to keep; `[]` detaches every one. An id naming no guardrail in the project responds `400` with `guardrail_not_found`, whose `details.missing` lists the ids. It is uncapped by plan, like the ceilings: a guardrail can only tighten what runs.
5240
+ * `guardrail_ids` is the floor under every tool call by every agent in the project, including tools added later. The list is replaced wholesale, so send the ids you want to keep; `[]` detaches every one. An id naming no guardrail in the project responds `400` with `GUARDRAIL_NOT_FOUND`, whose `meta.missing` lists the ids. It is uncapped by plan, like the ceilings: a guardrail can only tighten what runs.
5225
5241
  * `agent_policy_ids` caps every turn of every agent the project owns: an action they deny is refused even where the agent's own `policy_ids` allow it, and the refusal's `meta.denied_by` is `{ type: project, id: <project_id> }`. `null` or `[]` removes the cap. The credential must hold every grant the policies carry, else `403` with `POLICY_GRANT_NOT_HELD`; an id naming no policy responds `400` with `POLICY_NOT_FOUND`, and a policy of another project `400` with `POLICY_OUTSIDE_PROJECT`.
5226
5242
  * The two retention controls answer different questions. The window bounds how long content *stays* — a daily sweep purges anything past it, leaving auditable skeletons behind. `trace_content_mode: none` means content is never *written*, which is the stronger guarantee: it cannot be missed by a sweep or survive in a backup.
5227
5243
  *
5228
- * Your plan sets the longest window you may keep content for. A wider one — `null` included, which keeps content indefinitely — responds `403` with `plan_limit_reached`, whose `details` carry the `plan` and the `limit` in days. Anything shorter is always allowed. Moving to a plan with a shorter window takes effect at the end of the billing cycle, and content already stored is then purged by age like everything else.
5244
+ * Your plan sets the longest window you may keep content for. A wider one — `null` included, which keeps content indefinitely — responds `403` with `PLAN_LIMIT_REACHED`, whose `meta` carries the `plan` and the `limit` in days. Anything shorter is always allowed. Moving to a plan with a shorter window takes effect at the end of the billing cycle, and content already stored is then purged by age like everything else.
5229
5245
  *
5230
5246
  */
5231
5247
  static updateProject(options) {
@@ -5391,7 +5407,7 @@ var Projects = class {
5391
5407
  *
5392
5408
  * Makes the caller — the member the transfer names — the project's owner.
5393
5409
  *
5394
- * Usage up to this moment is settled on the previous owner's credit; from here on the project's usage is billed to the caller, and its runs count against the caller's allowance. The project counts toward the caller's plan limits at once: its active channels and triggers, and on Free the project itself. A transfer the caller's plan cannot hold is refused with `403 plan_limit_reached`, and the project's retention window is brought within the caller's plan.
5410
+ * Usage up to this moment is settled on the previous owner's credit; from here on the project's usage is billed to the caller, and its runs count against the caller's allowance. The project counts toward the caller's plan limits at once: its active channels and triggers, and on Free the project itself. A transfer the caller's plan cannot hold is refused with `403 PLAN_LIMIT_REACHED`, and the project's retention window is brought within the caller's plan.
5395
5411
  *
5396
5412
  * The previous owner stays in the project as an `admin`. Stops recorded against the project's spend move to the caller. Refused to a connected app.
5397
5413
  *
@@ -5710,7 +5726,7 @@ var Sessions = class {
5710
5726
  /**
5711
5727
  * Trigger agent generation
5712
5728
  *
5713
- * Triggers the agent to generate a response based on the current conversation. Background by default: returns `202 Accepted` with the generation's id once its record exists. Pass ?wait=true to block and receive the assistant reply (or a requires_action status if the agent needs client tool outputs) in the response.
5729
+ * Triggers the agent to generate a response based on the current conversation. Background by default: returns `202 Accepted` with the generation's id once its record exists. Pass ?wait=true to block and receive the assistant reply (or a requires_action status if the agent needs client tool outputs) in the response. Pass `stream: true` in the body to receive the turn's events as SSE, one frame per step and tool call, until it settles; `stream: true` with `?wait=false` is `400`.
5714
5730
  *
5715
5731
  */
5716
5732
  static generateSessionResponse(options) {
@@ -6348,7 +6364,7 @@ var Users = class {
6348
6364
  *
6349
6365
  * The plan the account is on, how long its projects may keep content, how much indexed storage it is holding, and the credit it has left — the figures the platform already enforces against, readable by the account they are enforced against.
6350
6366
  *
6351
- * A managed-model generation is refused with `402 insufficient_credit` while `credit_balance_usd` is negative, and a feature or a resource count outside the plan is refused with `403`, as is a retention window wider than `retention_days` or an ingest past `storage.limit`. Every refusal names what is missing; this is where the numbers behind them are read.
6367
+ * A managed-model generation is refused with `402 INSUFFICIENT_CREDIT` while `credit_balance_usd` is negative, and a feature or a resource count outside the plan is refused with `403`, as is a retention window wider than `retention_days` or an ingest past `storage.limit`. Every refusal names what is missing; this is where the numbers behind them are read.
6352
6368
  *
6353
6369
  * Every figure here is a local read, which is what keeps this route cheap enough to poll — unlike `GET /v1/users/me/usage`, which asks the meter once per project.
6354
6370
  *
@@ -6370,7 +6386,7 @@ var Users = class {
6370
6386
  *
6371
6387
  * Counted across the projects this account is the billing owner of, over the current UTC calendar month, from the meter itself. Archived projects are included: the runs they already made were made.
6372
6388
  *
6373
- * **On the `free` plan the allowance is enforced.** An account that has used it is refused `403 plan_limit_reached` with `resource: "runs"` on everything that starts a generation and on a direct tool call — on its own provider credential as much as on a managed model, because a run is a run — until the billing month turns or it upgrades. On `pro` and `business` nothing is refused: runs past the allowance are billed at the overage rate those plans are sold with. A contract plan is not counted.
6389
+ * **On the `free` plan the allowance is enforced.** An account that has used it is refused `403 PLAN_LIMIT_REACHED` with `resource: "runs"` on everything that starts a generation and on a direct tool call — on its own provider credential as much as on a managed model, because a run is a run — until the billing month turns or it upgrades. On `pro` and `business` nothing is refused: runs past the allowance are billed at the overage rate those plans are sold with. A contract plan is not counted.
6374
6390
  *
6375
6391
  * The other thing that stops a managed-model generation is a negative credit balance, which is `GET /v1/users/me/billing`, and it never applies to your own credential.
6376
6392
  *
@@ -6418,7 +6434,7 @@ var Users = class {
6418
6434
  *
6419
6435
  * Turns one stopped item back on — re-enables the schedule trigger, or resumes the orchestration run or workflow task — and stops listing it. An item that is no longer stopped (resumed already, finished or deleted) is marked restored too.
6420
6436
  *
6421
- * Refused with `409 stop_ceiling_closed` while a ceiling is still closed, naming it in `details.blocked_by`, and with `409 stop_not_restorable` for a cancelled eval run, which can only be dismissed.
6437
+ * Refused with `409 STOP_CEILING_CLOSED` while a ceiling is still closed, naming it in `meta.blocked_by`, and with `409 STOP_NOT_RESTORABLE` for a cancelled eval run, which can only be dismissed.
6422
6438
  *
6423
6439
  */
6424
6440
  static restoreCurrentUserStop(options) {
@@ -6611,7 +6627,7 @@ var Webhooks = class {
6611
6627
  *
6612
6628
  * Register an endpoint and subscribe it to one or more event types.
6613
6629
  * The response carries `secret` — the signing key, in plaintext. **This is the only time it is returned.** Store it where your receiver can read it; if you lose it, rotate rather than re-create, so the endpoint keeps its delivery history. Send `secret` yourself to sign with a key your receiver already holds; the response then returns that one.
6614
- * A project holds at most 20 webhooks, inactive ones included; the 21st is refused with `409 webhook_limit_reached`.
6630
+ * A project holds at most 20 webhooks, inactive ones included; the 21st is refused with `409 WEBHOOK_LIMIT_REACHED`.
6615
6631
  * Returns `501` on a deployment with no credential-sealing key configured, since the secret could not then be stored safely.
6616
6632
  *
6617
6633
  */
@@ -6710,7 +6726,7 @@ var Webhooks = class {
6710
6726
  *
6711
6727
  * Queue the same event at the same endpoint again — the recovery path for a delivery that failed, or one your receiver dropped. This is the `…:redeliver` action; the path segment is `{delivery_id}:redeliver`.
6712
6728
  * A **new** delivery is created and returned; the original record is left untouched, because its attempt history is the evidence you redelivered on. The event's `id` is carried over unchanged, so a receiver deduping on the event sees the same event twice while one deduping on `X-Naturali-Delivery` sees a distinct delivery.
6713
- * An inactive webhook is refused with `409 webhook_inactive`.
6729
+ * An inactive webhook is refused with `409 WEBHOOK_INACTIVE`.
6714
6730
  *
6715
6731
  */
6716
6732
  static redeliverWebhookDelivery(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/sdk",
3
- "version": "0.268.0",
3
+ "version": "0.270.0",
4
4
  "description": "TypeScript SDK for the naturali.ai API, generated from its OpenAPI specs",
5
5
  "keywords": [
6
6
  "naturali",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@hey-api/openapi-ts": "^0.99.0",
41
- "@naturali/api": "0.268.0",
41
+ "@naturali/api": "0.270.0",
42
42
  "@ttoss/openapi-codegen": "^0.10.1",
43
43
  "@types/node": "^26.5.1",
44
44
  "tsdown": "^0.23.0",