@soat/sdk 0.22.1 → 0.24.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
@@ -1017,6 +1017,8 @@ var AiProviders = class {
1017
1017
  * Asks the provider which models it can run, using this provider record's own credentials and configuration, and returns provider-native model ids — the same strings `default_model` and an agent's `model` carry.
1018
1018
  * Which models are reachable is a property of the credential, not of the provider type: a Vertex provider sees only the publisher models its Google Cloud project and location serve, and a Bedrock provider only the foundation models enabled in its region. Reading the list is how a caller avoids pinning a model that fails at generation time.
1019
1019
  * Not every provider type can answer. `azure` lists deployments an operator named rather than models, and `ollama` lists whatever was pulled onto that host, so both return `400 MODEL_LISTING_UNSUPPORTED`.
1020
+ * Listing resolves credentials the same way generation does, so a record that can generate can list. The API-key types (`openai`, `groq`, `xai`, `gateway`, `custom`, `anthropic`, `google`) use the record's linked secret and cannot list without one. `bedrock` and `vertex` use the linked secret when there is one — IAM keys or a Bedrock API key, a Google service-account key — and otherwise fall back to the server environment (the AWS default credential chain, Google Application Default Credentials), so a record with no `secret_id` can still list.
1021
+ * A Vertex record needs no `config.project` when its secret is a service-account key, since the key file names its own project. A Vertex record in express mode (API key) cannot list at all: express mode is a global, project-less endpoint and the publisher-model catalogue is per-project, so it returns `400 MODEL_LISTING_UNSUPPORTED`.
1020
1022
  *
1021
1023
  */
1022
1024
  static listAiProviderModels(options) {
@@ -1058,7 +1060,7 @@ var ApiKeys = class {
1058
1060
  /**
1059
1061
  * List API keys
1060
1062
  *
1061
- * Lists API keys accessible to the caller. - JWT admin: returns all API keys. - JWT regular user: returns only the user's own API keys. - API key: returns only API keys scoped to the key's project.
1063
+ * Lists API keys accessible to the caller. - JWT admin: returns all API keys. - JWT regular user: returns only the user's own API keys. - Project-scoped credential (API key or OAuth token): returns only API keys scoped to that project.
1062
1064
  *
1063
1065
  */
1064
1066
  static listApiKeys(options) {
@@ -1074,7 +1076,7 @@ var ApiKeys = class {
1074
1076
  /**
1075
1077
  * Create an API key
1076
1078
  *
1077
- * Creates a new API key for the authenticated user. - `project_id` is optional. When set, the key is scoped to that single project. When omitted or null, the key is **unscoped** and spans every project its owner can reach. - If `policy_ids` is provided, the key's effective permissions are the intersection of the user's policies and the key's policies. - Otherwise the key inherits the user's permissions (confined to the key's project when scoped).
1079
+ * Creates a new API key for the authenticated user. - `project_id` is optional. When set, the key is scoped to that single project. When omitted or null, the key is **unscoped** and spans every project its owner can reach. - If `policy_ids` is provided, the key's effective permissions are the intersection of the user's policies and the key's policies. - Otherwise the key inherits the user's permissions (confined to the key's project when scoped). - When the request is authenticated with a **project-scoped credential**, the new key is confined to that same project: omitting `project_id` defaults to it, naming a different project returns `403 API_KEY_PROJECT_SCOPE`, and `project_id: null` (an unscoped key) is likewise refused. Minting an unscoped key requires an unscoped credential.
1078
1080
  *
1079
1081
  */
1080
1082
  static createApiKey(options) {
@@ -1090,7 +1092,7 @@ var ApiKeys = class {
1090
1092
  /**
1091
1093
  * Delete an API key
1092
1094
  *
1093
- * Deletes an API key. Only the owner or an admin can delete it.
1095
+ * Deletes an API key. Only the owner or an admin can delete it, and a project-scoped credential can only delete keys in its own project.
1094
1096
  */
1095
1097
  static deleteApiKey(options) {
1096
1098
  return (options.client ?? client).delete({
@@ -1101,7 +1103,7 @@ var ApiKeys = class {
1101
1103
  /**
1102
1104
  * Get an API key
1103
1105
  *
1104
- * Returns details of an API key. Only the owner or an admin can access it.
1106
+ * Returns details of an API key. Only the owner or an admin can access it, and a project-scoped credential can only reach keys in its own project.
1105
1107
  */
1106
1108
  static getApiKey(options) {
1107
1109
  return (options.client ?? client).get({
@@ -1112,7 +1114,7 @@ var ApiKeys = class {
1112
1114
  /**
1113
1115
  * Update an API key
1114
1116
  *
1115
- * Updates an API key's name, project scope, or policies. The project scope can be changed to another project, set (scoping a previously unscoped key), or cleared with null (unscoping the key). Only the owner or an admin can update it.
1117
+ * Updates an API key's name, project scope, or policies. The project scope can be changed to another project, set (scoping a previously unscoped key), or cleared with null (unscoping the key). Only the owner or an admin can update it. A project-scoped credential can only update keys in its own project, and cannot move a key to another project or unscope it.
1116
1118
  */
1117
1119
  static updateApiKey(options) {
1118
1120
  return (options.client ?? client).put({
@@ -1275,25 +1277,15 @@ var Chats = class {
1275
1277
  });
1276
1278
  }
1277
1279
  /**
1278
- * Create a chat completion for a stored chat
1280
+ * Create a chat completion
1279
1281
  *
1280
- * Runs a completion using the AI provider and settings stored in the chat. Pass `stream: true` for SSE streaming. A system message in `messages` overrides the chat's stored system message for this call only. Messages may use `documentId` instead of `content`.
1282
+ * OpenAI Chat Completions-compatible endpoint. Mirrors OpenAI's `POST /v1/chat/completions` path so an OpenAI SDK can target it by base URL alone.
1281
1283
  *
1282
- */
1283
- static createChatCompletionForChat(options) {
1284
- return (options.client ?? client).post({
1285
- url: "/api/v1/chats/{chat_id}/completions",
1286
- ...options,
1287
- headers: {
1288
- "Content-Type": "application/json",
1289
- ...options.headers
1290
- }
1291
- });
1292
- }
1293
- /**
1294
- * Create a chat completion (stateless)
1284
+ * Names exactly one target. With `ai_provider_id` the completion is stateless: the provider's secret is decrypted and the appropriate Vercel AI SDK provider is called, with no server-side model fallback. With `chat_id` the stored chat supplies the provider (or the project's `default_model_route_id`), model and instructions.
1285
+ *
1286
+ * System content travels only in `instructions` — a `role: "system"` entry in `messages` is refused with `400 SYSTEM_MESSAGE_NOT_ALLOWED`. With `chat_id`, a request `instructions` replaces the chat's stored one for this call only; the stored value applies when the request carries none, and the two are never merged.
1295
1287
  *
1296
- * OpenAI Chat Completions-compatible endpoint. Mirrors OpenAI's `POST /v1/chat/completions` path so an OpenAI SDK can target it by base URL alone. Resolves the AI provider from `ai_provider_id`, decrypts its secret, and calls the appropriate Vercel AI SDK provider. `ai_provider_id` is required — there is no server-side model fallback.
1288
+ * Messages may use `document_id` instead of `content` with either target. Chats hold no message history send the full `messages` array every time.
1297
1289
  *
1298
1290
  */
1299
1291
  static createChatCompletion(options) {
@@ -1781,6 +1773,27 @@ var Evaluations = class {
1781
1773
  });
1782
1774
  }
1783
1775
  /**
1776
+ * Curate a dataset item from a generation
1777
+ *
1778
+ * Promotes a real, completed generation into a test case: its input messages become the item's `input`, and its own answer becomes `expected_output` unless you supply one. Use it to build an evaluation set out of production traffic rather than hand-authoring fixtures.
1779
+ *
1780
+ * The item is a **copy**, not a view. It keeps working after the source generation's content is purged, and `source_generation_id` goes null if that generation is deleted — a purge can never quietly stop a suite from being runnable.
1781
+ *
1782
+ * Requires both `evaluations:CreateDataset` and `generations:GetGeneration`: the call copies content out of a generation, so a principal that may not read that generation may not curate it either.
1783
+ *
1784
+ * Only a **completed** generation can be promoted (`409 GENERATION_NOT_COMPLETED`), and only while its content is still available: an agent or project running with `trace_content_mode: none` never stored the input, and a purged or expired generation no longer has it (`409 GENERATION_CONTENT_UNAVAILABLE`). Generations that predate input recording answer the same way.
1785
+ */
1786
+ static createDatasetItemFromGeneration(options) {
1787
+ return (options.client ?? client).post({
1788
+ url: "/api/v1/datasets/{dataset_id}/items/from-generation",
1789
+ ...options,
1790
+ headers: {
1791
+ "Content-Type": "application/json",
1792
+ ...options.headers
1793
+ }
1794
+ });
1795
+ }
1796
+ /**
1784
1797
  * Delete a dataset item
1785
1798
  *
1786
1799
  * Deletes a test case. Results of runs that already scored it stay readable; their `dataset_item_id` becomes null.
@@ -2231,6 +2244,8 @@ var Formations = class {
2231
2244
  *
2232
2245
  * Validates the template, creates the formation record, then provisions all declared resources in dependency order.
2233
2246
  *
2247
+ * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `201` and `status: "failed"`, and `error` explains why (the resources created before the failure are rolled back). Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `soat` CLI exits non-zero on that body so `create-formation && …` does not lie.
2248
+ *
2234
2249
  */
2235
2250
  static createFormation(options) {
2236
2251
  return (options.client ?? client).post({
@@ -2247,6 +2262,10 @@ var Formations = class {
2247
2262
  *
2248
2263
  * Deletes the formation stack and all its managed resources in reverse dependency order.
2249
2264
  *
2265
+ * A resource the platform refuses to delete on its own — most often an agent that has generation or trace history — fails the teardown with `409 FORMATION_DELETE_FAILED`, naming every blocking resource in `error.meta.failures`. Resolve the blockers (for an agent, `DELETE /api/v1/agents/{agent_id}?force=true` also removes its generations and traces, and `deletion_policy: retain` exempts it from teardown entirely) and delete the formation again.
2266
+ *
2267
+ * A refusal the platform can foresee is found by a pre-flight, before the first delete: nothing is removed, and the formation stays `active` and intact for the retry. An unforeseeable error surfaces mid-teardown instead, where resources deleted before the blocker stay deleted and the formation is left in `delete_failed`. The error message states which happened.
2268
+ *
2250
2269
  */
2251
2270
  static deleteFormation(options) {
2252
2271
  return (options.client ?? client).delete({
@@ -2270,6 +2289,8 @@ var Formations = class {
2270
2289
  *
2271
2290
  * Applies a new template to the formation. Resources are created, updated, or deleted to reconcile the current state with the desired state.
2272
2291
  *
2292
+ * A **template-shape** error is refused with `400`. A **deploy** failure is not: the operation ran, so the formation is returned with `200` and `status: "failed"`, and `error` explains why. Read `status` — a `2xx` here means the deploy was attempted, not that it worked. The `soat` CLI exits non-zero on that body so `update-formation && …` does not lie.
2293
+ *
2273
2294
  */
2274
2295
  static updateFormation(options) {
2275
2296
  return (options.client ?? client).put({
@@ -2353,6 +2374,22 @@ var Generations = class {
2353
2374
  ...options
2354
2375
  });
2355
2376
  }
2377
+ /**
2378
+ * Get a generation's transcript
2379
+ *
2380
+ * Returns one generation's turn read back as an ordered sequence of steps: what it was asked, each model step with its tool calls and results, and how it ended.
2381
+ *
2382
+ * 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.
2383
+ *
2384
+ * 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.
2385
+ *
2386
+ */
2387
+ static getGenerationTranscript(options) {
2388
+ return (options.client ?? client).get({
2389
+ url: "/api/v1/generations/{generation_id}/transcript",
2390
+ ...options
2391
+ });
2392
+ }
2356
2393
  };
2357
2394
  var Guardrails = class {
2358
2395
  /**
@@ -2908,7 +2945,7 @@ var Orchestrations = class {
2908
2945
  /**
2909
2946
  * Start an orchestration run
2910
2947
  *
2911
- * Creates a new run for the orchestration named by orchestration_id. By default the run executes durably in the background: the response returns immediately with status "queued" (a worker then claims it and moves it to "running") and progress is observed via get-orchestration-run or run lifecycle webhook events (orchestration_runs.started/awaiting_input/succeeded/failed). Delay and poll waits park the run as "sleeping" and are woken by a background scheduler, surviving restarts. Pass wait=true to block until the run reaches a terminal or awaiting_input state (the legacy synchronous behaviour).
2948
+ * Creates a new run for the orchestration named by orchestration_id. By default the run executes durably in the background: the response returns immediately with status "queued" (a worker then claims it and moves it to "running") and progress is observed via get-orchestration-run or run lifecycle webhook events (orchestration_runs.started/awaiting_input/succeeded/failed). Delay and poll waits park the run as "sleeping" and are woken by a background scheduler, surviving restarts. Pass wait=true to block until the run reaches a terminal or awaiting_input state.
2912
2949
  */
2913
2950
  static startOrchestrationRun(options) {
2914
2951
  return (options.client ?? client).post({
@@ -3379,6 +3416,38 @@ var Sessions = class {
3379
3416
  });
3380
3417
  }
3381
3418
  /**
3419
+ * Fork a session
3420
+ *
3421
+ * Branches a new session from a point in this session's history: same context, different continuation.
3422
+ *
3423
+ * The fork gets its own conversation whose messages **reference the same documents** as the parent rather than copying them, so there is one stored copy of the content and a retention purge erases it from both. Recorded tool results ride along on those messages and are **replayed** as model input on the fork's next turn — forking never re-invokes a tool, so exploring a "what if" cannot send an email or charge a card a second time. The consequence to accept is that a forked turn sees the tool data as it was, not as it is now.
3424
+ *
3425
+ * The fork is created **inert**: `auto_generate` is false and no generation is triggered. Drive it with the normal message and generate endpoints. The fork has no actor — attach one only if the branch is meant to be driven by the same end user, since `single_session_per_actor` agents allow one open session per actor.
3426
+ *
3427
+ */
3428
+ static forkSession(options) {
3429
+ return (options.client ?? client).post({
3430
+ url: "/api/v1/sessions/{session_id}/fork",
3431
+ ...options,
3432
+ headers: {
3433
+ "Content-Type": "application/json",
3434
+ ...options.headers
3435
+ }
3436
+ });
3437
+ }
3438
+ /**
3439
+ * List a session's forks
3440
+ *
3441
+ * Returns the sessions forked directly from this one. One level of lineage: a fork of a fork is listed under its own parent.
3442
+ *
3443
+ */
3444
+ static listSessionForks(options) {
3445
+ return (options.client ?? client).get({
3446
+ url: "/api/v1/sessions/{session_id}/forks",
3447
+ ...options
3448
+ });
3449
+ }
3450
+ /**
3382
3451
  * Get session tags
3383
3452
  *
3384
3453
  * Returns the session's tags object.
@@ -3774,7 +3843,7 @@ var Usage = class {
3774
3843
  /**
3775
3844
  * List usage meters
3776
3845
  *
3777
- * Returns the raw usage-meter rows the caller can access, most recent first, optionally filtered by agent, generation, trace, actor, or session. Each row is the per-generation token usage as reported by the provider, for audit and reconciliation.
3846
+ * Returns the raw usage-meter rows the caller can access, most recent first, optionally filtered by agent, generation, trace, actor, session, or `source`. Each row is the per-generation token usage as reported by the provider, for audit and reconciliation.
3778
3847
  *
3779
3848
  */
3780
3849
  static listUsageMeters(options) {
@@ -4069,6 +4138,22 @@ var Webhooks = class {
4069
4138
  });
4070
4139
  }
4071
4140
  /**
4141
+ * Redeliver a webhook delivery
4142
+ *
4143
+ * Queues the stored payload of an existing delivery to be sent again.
4144
+ *
4145
+ * A new delivery record is created rather than the original being reset,
4146
+ * so the original attempt stays in the history. The send happens in the
4147
+ * background: poll the returned delivery to observe its outcome.
4148
+ *
4149
+ */
4150
+ static redeliverWebhookDelivery(options) {
4151
+ return (options.client ?? client).post({
4152
+ url: "/api/v1/webhook-deliveries/{delivery_id}/redeliver",
4153
+ ...options
4154
+ });
4155
+ }
4156
+ /**
4072
4157
  * Get webhook secret
4073
4158
  *
4074
4159
  * Retrieves the signing secret for the specified webhook
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soat/sdk",
3
- "version": "0.22.1",
3
+ "version": "0.24.0",
4
4
  "description": "TypeScript SDK for the SOAT API",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",