@naturali/sdk 0.78.5 → 0.79.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.cjs CHANGED
@@ -3122,7 +3122,9 @@ var Orchestrations = class {
3122
3122
  /**
3123
3123
  * List orchestration runs
3124
3124
  *
3125
- * Returns orchestration runs the caller can access, optionally filtered by orchestration.
3125
+ * Returns orchestration runs the caller can access, optionally filtered by orchestration, by parent run, or by whether the run has a parent at all.
3126
+ *
3127
+ * Note when aggregating: a run's `usage` covers its whole subtree, so summing it over a list that contains both a parent and its children counts the children more than once. Pass `nested=false` to sum over runs a caller started.
3126
3128
  */
3127
3129
  static listOrchestrationRuns(options) {
3128
3130
  return (options.client ?? client).get({
@@ -3772,7 +3774,7 @@ var Tools = class {
3772
3774
  *
3773
3775
  * Directly invokes a tool and returns its output. Supported for `http`, `mcp`, and `pipeline` tools. `client` tools cannot be invoked server-side and will return 422. A `pipeline` tool runs its declared steps in order and returns the mapped `output` (or the last step's output); `action` is ignored and `input` is the pipeline input.
3774
3776
  * For `mcp` tools the `action` field is required and identifies which tool name to invoke. For `http` tools `action` is ignored. When an `mcp` tool declares an `actions` allowlist, an action outside it is rejected with `400 VALIDATION_FAILED` ("not available on this tool") before any outbound request is made.
3775
- * `preset_parameters` stored on the tool are merged with the caller-supplied `input` before execution; preset keys take lower precedence.
3777
+ * `preset_parameters` stored on the tool are pinned over the caller-supplied `input` before execution: a key the tool presets keeps its preset value even when `input` sets it. Keys the presets do not name are taken from `input` as sent.
3776
3778
  *
3777
3779
  */
3778
3780
  static callTool(options) {
package/dist/index.d.cts CHANGED
@@ -1125,7 +1125,9 @@ type CreateToolRequest = {
1125
1125
  */
1126
1126
  context_keys?: Array<string> | null;
1127
1127
  /**
1128
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
1128
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
1129
+ *
1130
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
1129
1131
  */
1130
1132
  preset_parameters?: {
1131
1133
  [key: string]: unknown;
@@ -2398,6 +2400,12 @@ type EvalRun = {
2398
2400
  item_count?: number;
2399
2401
  completed_count?: number;
2400
2402
  errored_count?: number;
2403
+ /**
2404
+ * The caller-owned key/value metadata supplied when the run was started, returned verbatim. Null when the run was started without any (a trigger-started run included — see `trigger_id` for that provenance). The server writes nothing here.
2405
+ */
2406
+ metadata?: {
2407
+ [key: string]: unknown;
2408
+ } | null;
2401
2409
  started_at?: Date | null;
2402
2410
  finished_at?: Date | null;
2403
2411
  created_at?: Date;
@@ -2435,7 +2443,7 @@ type ExceptionItem = {
2435
2443
  /**
2436
2444
  * How the exception was filed
2437
2445
  */
2438
- kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'manual';
2446
+ kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'event_trigger_loop' | 'manual';
2439
2447
  /**
2440
2448
  * Human-readable one-line summary
2441
2449
  */
@@ -3770,6 +3778,20 @@ type OrchestrationRun = {
3770
3778
  tool_context?: {
3771
3779
  [key: string]: string;
3772
3780
  } | null;
3781
+ /**
3782
+ * The caller-owned key/value metadata supplied at run creation, returned verbatim. Null when the run was started without any. The server writes nothing here and no key is reserved; the bag is never merged into `state`, so nothing in it reaches the graph.
3783
+ */
3784
+ metadata?: {
3785
+ [key: string]: unknown;
3786
+ } | null;
3787
+ /**
3788
+ * The run whose node started this one — set only on a child a `loop` or `sub_orchestration` node spawned, null for a run a caller started. A child is its own run with its own usage events, so this is what makes a delegated run's spend attributable to the run that ordered it.
3789
+ */
3790
+ parent_orchestration_run_id?: string | null;
3791
+ /**
3792
+ * The node within `parent_orchestration_run_id` that started this run. Null when `parent_orchestration_run_id` is null.
3793
+ */
3794
+ parent_node_id?: string | null;
3773
3795
  /**
3774
3796
  * Terminal node artifact(s) when the run has succeeded.
3775
3797
  */
@@ -3781,9 +3803,17 @@ type OrchestrationRun = {
3781
3803
  */
3782
3804
  node_executions?: Array<NodeExecution>;
3783
3805
  /**
3784
- * Usage roll-up (token counts and cost_usd) summed across every metered generation the run produced. Present on the single-run read; omitted from run list responses.
3806
+ * What the run cost: token counts and `cost_usd` summed across every metered generation it produced **and every run it started** through `loop` / `sub_orchestration` nodes, at any depth. Present on the single-run read; omitted from run list responses.
3807
+ *
3808
+ * A nested child is a run record of its own, so this figure spans several of them. Two consequences: summing `usage` across a list that mixes parents and children double-counts (filter with `nested=false`), and the per-event receipt at `/v1/projects/{project_id}/usage/receipt` stays scoped to one run — its line items carry a `node_id` from one graph only.
3785
3809
  */
3786
3810
  usage?: RunUsageTotals;
3811
+ /**
3812
+ * The same roll-up restricted to **this run's own nodes**, excluding every nested run it started. Equal to `usage` for a run with no children; below it for a run that delegates. Present on the single-run read; omitted from run list responses.
3813
+ *
3814
+ * This is the field to read to see where cost sits in a run tree — own versus subtree — without walking the children.
3815
+ */
3816
+ usage_own?: RunUsageTotals;
3787
3817
  required_action?: RequiredAction | null;
3788
3818
  started_at?: Date | null;
3789
3819
  completed_at?: Date | null;
@@ -3908,6 +3938,16 @@ type StartRunRequest = {
3908
3938
  tool_context?: {
3909
3939
  [key: string]: string;
3910
3940
  };
3941
+ /**
3942
+ * Caller-supplied key/value metadata attached to the run record for per-run attribution (e.g. which of your own tenants this run belongs to, or the dispatch batch that started it). Round-trips verbatim on every read of the run, on the list as well as the single read.
3943
+ *
3944
+ * The bag is caller-owned and no key is reserved: server-owned state (status, the pinned orchestration version, the trace, usage, artifacts, the run's own `input` and accumulated `state`) lives in its own top-level field and cannot be written from here.
3945
+ *
3946
+ * It is **not** merged into run state: no graph node sees it, and an `input_schema` never has to tolerate it — which is what makes it the place for an infrastructural label, rather than `input`. Keys are never transformed. It is not inherited by the child runs a `loop` or `sub_orchestration` node starts; each child carries whatever the graph gives it, which today is nothing.
3947
+ */
3948
+ metadata?: {
3949
+ [key: string]: unknown;
3950
+ };
3911
3951
  /**
3912
3952
  * When true, block until the run reaches a terminal (succeeded/failed) or awaiting_input state and return the settled run. When false (default), return immediately with status "queued" and execute the run in the background.
3913
3953
  */
@@ -4419,6 +4459,12 @@ type Task = {
4419
4459
  payload?: {
4420
4460
  [key: string]: unknown;
4421
4461
  };
4462
+ /**
4463
+ * The caller-owned key/value metadata supplied when the task was created, returned verbatim. Null when the task was created without any. Unlike `payload` it is invisible to guards and to `payload_writes`, so it is the place for an attribution label rather than task data.
4464
+ */
4465
+ metadata?: {
4466
+ [key: string]: unknown;
4467
+ } | null;
4422
4468
  /**
4423
4469
  * Server-owned. The result of the current state's last completed dispatch, overwritten on every dispatch. Read-only — exposed to transition guards and `on_complete`/`payload_writes` expressions as `task.last_result`, a namespace a caller cannot write.
4424
4470
  */
@@ -4498,6 +4544,16 @@ type CreateTaskRequest = {
4498
4544
  tool_context?: {
4499
4545
  [key: string]: string;
4500
4546
  };
4547
+ /**
4548
+ * Caller-supplied key/value metadata attached to the task record for attribution — which of your own tenants the task belongs to, the ticket that raised it, the import batch that created it. Round-trips verbatim on every read of the task, the list included, and survives every transition (a transition supplies no metadata of its own).
4549
+ *
4550
+ * The bag is caller-owned and no key is reserved: everything the engine decides about a task (`state`, `status`, `workflow_version`, `last_result`, `active_dispatch`, the automation fields) is a field of its own and cannot be written from here.
4551
+ *
4552
+ * Prefer this over `payload` for anything that is not task data: `payload` is read by every guard as `task.payload` and may be written by the workflow's declared `payload_writes`, so a label parked there is neither invisible to the state machine nor safe from it. A non-object is rejected with `400 VALIDATION_FAILED` and no task is created.
4553
+ */
4554
+ metadata?: {
4555
+ [key: string]: unknown;
4556
+ };
4501
4557
  };
4502
4558
  type UpdateTaskRequest = {
4503
4559
  title?: string;
@@ -4584,7 +4640,9 @@ type Tool = {
4584
4640
  */
4585
4641
  context_keys?: Array<string> | null;
4586
4642
  /**
4587
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
4643
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
4644
+ *
4645
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
4588
4646
  */
4589
4647
  preset_parameters?: {
4590
4648
  [key: string]: unknown;
@@ -4650,7 +4708,9 @@ type UpdateToolRequest = {
4650
4708
  */
4651
4709
  context_keys?: Array<string> | null;
4652
4710
  /**
4653
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
4711
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
4712
+ *
4713
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
4654
4714
  */
4655
4715
  preset_parameters?: {
4656
4716
  [key: string]: unknown;
@@ -4679,7 +4739,7 @@ type CallToolRequest = {
4679
4739
  */
4680
4740
  action?: string;
4681
4741
  /**
4682
- * Input parameters for the tool call. These are merged with the tool's `preset_parameters` before execution (caller-supplied values take precedence).
4742
+ * Input parameters for the tool call. These are merged with the tool's `preset_parameters` before execution; a preset value wins over the same key sent here.
4683
4743
  *
4684
4744
  */
4685
4745
  input?: {
@@ -4795,7 +4855,7 @@ type Trigger = {
4795
4855
  project_id?: string;
4796
4856
  name?: string;
4797
4857
  description?: string | null;
4798
- type?: 'manual' | 'webhook' | 'schedule';
4858
+ type?: 'manual' | 'webhook' | 'schedule' | 'event';
4799
4859
  target_type?: 'orchestration' | 'agent' | 'tool' | 'eval';
4800
4860
  /**
4801
4861
  * Public ID of the target resource (orchestration, agent, tool, or eval)
@@ -4815,6 +4875,10 @@ type Trigger = {
4815
4875
  * 5-field cron expression (UTC). Present only for schedule triggers
4816
4876
  */
4817
4877
  cron?: string | null;
4878
+ /**
4879
+ * Internal-event subscription pattern. Present only for event triggers: `*`, `prefix.*`, or an exact event name
4880
+ */
4881
+ event_pattern?: string | null;
4818
4882
  active?: boolean;
4819
4883
  /**
4820
4884
  * Optional boundary policy that further restricts firings
@@ -4836,7 +4900,7 @@ type TriggerWithSecret = Trigger & {
4836
4900
  type CreateTriggerRequest = {
4837
4901
  name: string;
4838
4902
  description?: string;
4839
- type: 'manual' | 'webhook' | 'schedule';
4903
+ type: 'manual' | 'webhook' | 'schedule' | 'event';
4840
4904
  target_type: 'orchestration' | 'agent' | 'tool' | 'eval';
4841
4905
  target_id: string;
4842
4906
  /**
@@ -4850,6 +4914,10 @@ type CreateTriggerRequest = {
4850
4914
  * 5-field cron expression (UTC). Required when type is schedule
4851
4915
  */
4852
4916
  cron?: string;
4917
+ /**
4918
+ * Internal-event subscription pattern. Required when type is event, rejected otherwise. `*` matches every event, `prefix.*` a namespace, or give an exact event name such as `documents.ingested`
4919
+ */
4920
+ event_pattern?: string;
4853
4921
  active?: boolean;
4854
4922
  policy_id?: string;
4855
4923
  };
@@ -4863,6 +4931,7 @@ type UpdateTriggerRequest = {
4863
4931
  [key: string]: unknown;
4864
4932
  } | null;
4865
4933
  cron?: string | null;
4934
+ event_pattern?: string | null;
4866
4935
  active?: boolean;
4867
4936
  policy_id?: string | null;
4868
4937
  };
@@ -4881,7 +4950,7 @@ type TriggerFiring = {
4881
4950
  id?: string;
4882
4951
  trigger_id?: string;
4883
4952
  project_id?: string;
4884
- source?: 'manual' | 'webhook' | 'schedule';
4953
+ source?: 'manual' | 'webhook' | 'schedule' | 'event';
4885
4954
  status?: 'pending' | 'running' | 'succeeded' | 'failed';
4886
4955
  input?: {
4887
4956
  [key: string]: unknown;
@@ -10398,6 +10467,14 @@ type StartEvalRunData = {
10398
10467
  * A terminal run of the same eval to compare against. The finished run's `aggregate_scores.baseline` reports per-scorer deltas over the item intersection. A run of a different eval is rejected with 400.
10399
10468
  */
10400
10469
  baseline_run_id?: string | null;
10470
+ /**
10471
+ * Caller-supplied key/value metadata attached to the run record for attribution — what this measurement was of (the commit or release candidate being scored, the CI job that asked for it). Round-trips verbatim on every read of the run, the list included.
10472
+ *
10473
+ * The bag is caller-owned and no key is reserved: everything the platform decides about a run (`status`, `agent_version`, `baseline_run_id`, `aggregate_scores`, `passed`, the counts) is a field of its own and cannot be written from here. Nothing in the scoring path reads it. A non-object is rejected with `400 VALIDATION_FAILED` and no run is created.
10474
+ */
10475
+ metadata?: {
10476
+ [key: string]: unknown;
10477
+ };
10401
10478
  };
10402
10479
  path: {
10403
10480
  /**
@@ -10603,7 +10680,7 @@ type ListExceptionsData = {
10603
10680
  /**
10604
10681
  * Filter by how the exception was filed
10605
10682
  */
10606
- kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'manual';
10683
+ kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'event_trigger_loop' | 'manual';
10607
10684
  /**
10608
10685
  * Maximum number of results to return
10609
10686
  */
@@ -13444,6 +13521,16 @@ type ListOrchestrationRunsData = {
13444
13521
  * Filter by orchestration public ID (orch_...)
13445
13522
  */
13446
13523
  orchestration_id?: string;
13524
+ /**
13525
+ * Filter to the runs one specific parent run's `loop` / `sub_orchestration` nodes started (run_...). This is how a caller holding a parent names the individual children behind its `usage`.
13526
+ */
13527
+ parent_orchestration_run_id?: string;
13528
+ /**
13529
+ * Filter by whether the run was started by another run. `false` returns only the runs a caller started (no parent), which is the set to sum `usage` over; `true` returns only the runs a `loop` / `sub_orchestration` node started, across every parent. Omit to return both.
13530
+ *
13531
+ * Contradicting `parent_orchestration_run_id` with `nested=false` is a `400`; any value other than `true` or `false` is a `400`.
13532
+ */
13533
+ nested?: boolean;
13447
13534
  /**
13448
13535
  * Maximum number of results to return
13449
13536
  */
@@ -13490,7 +13577,7 @@ type StartOrchestrationRunData = {
13490
13577
  };
13491
13578
  type StartOrchestrationRunErrors = {
13492
13579
  /**
13493
- * Validation error
13580
+ * Validation error (e.g. a `tool_context` key that cannot become a header, or `metadata` that is not a JSON object). No run is created.
13494
13581
  */
13495
13582
  400: unknown;
13496
13583
  /**
@@ -15615,7 +15702,7 @@ type ListTriggersData = {
15615
15702
  project_id: string;
15616
15703
  };
15617
15704
  query?: {
15618
- type?: 'manual' | 'webhook' | 'schedule';
15705
+ type?: 'manual' | 'webhook' | 'schedule' | 'event';
15619
15706
  target_type?: 'orchestration' | 'agent' | 'tool' | 'eval';
15620
15707
  /**
15621
15708
  * Maximum number of results to return
@@ -17978,7 +18065,9 @@ declare class Orchestrations {
17978
18065
  /**
17979
18066
  * List orchestration runs
17980
18067
  *
17981
- * Returns orchestration runs the caller can access, optionally filtered by orchestration.
18068
+ * Returns orchestration runs the caller can access, optionally filtered by orchestration, by parent run, or by whether the run has a parent at all.
18069
+ *
18070
+ * Note when aggregating: a run's `usage` covers its whole subtree, so summing it over a list that contains both a parent and its children counts the children more than once. Pass `nested=false` to sum over runs a caller started.
17982
18071
  */
17983
18072
  static listOrchestrationRuns<ThrowOnError extends boolean = false>(options: Options<ListOrchestrationRunsData, ThrowOnError>): RequestResult<ListOrchestrationRunsResponses, ListOrchestrationRunsErrors, ThrowOnError>;
17984
18073
  /**
@@ -18304,7 +18393,7 @@ declare class Tools {
18304
18393
  *
18305
18394
  * Directly invokes a tool and returns its output. Supported for `http`, `mcp`, and `pipeline` tools. `client` tools cannot be invoked server-side and will return 422. A `pipeline` tool runs its declared steps in order and returns the mapped `output` (or the last step's output); `action` is ignored and `input` is the pipeline input.
18306
18395
  * For `mcp` tools the `action` field is required and identifies which tool name to invoke. For `http` tools `action` is ignored. When an `mcp` tool declares an `actions` allowlist, an action outside it is rejected with `400 VALIDATION_FAILED` ("not available on this tool") before any outbound request is made.
18307
- * `preset_parameters` stored on the tool are merged with the caller-supplied `input` before execution; preset keys take lower precedence.
18396
+ * `preset_parameters` stored on the tool are pinned over the caller-supplied `input` before execution: a key the tool presets keeps its preset value even when `input` sets it. Keys the presets do not name are taken from `input` as sent.
18308
18397
  *
18309
18398
  */
18310
18399
  static callTool<ThrowOnError extends boolean = false>(options: Options<CallToolData, ThrowOnError>): RequestResult<CallToolResponses, CallToolErrors, ThrowOnError>;
package/dist/index.d.mts CHANGED
@@ -1125,7 +1125,9 @@ type CreateToolRequest = {
1125
1125
  */
1126
1126
  context_keys?: Array<string> | null;
1127
1127
  /**
1128
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
1128
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
1129
+ *
1130
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
1129
1131
  */
1130
1132
  preset_parameters?: {
1131
1133
  [key: string]: unknown;
@@ -2398,6 +2400,12 @@ type EvalRun = {
2398
2400
  item_count?: number;
2399
2401
  completed_count?: number;
2400
2402
  errored_count?: number;
2403
+ /**
2404
+ * The caller-owned key/value metadata supplied when the run was started, returned verbatim. Null when the run was started without any (a trigger-started run included — see `trigger_id` for that provenance). The server writes nothing here.
2405
+ */
2406
+ metadata?: {
2407
+ [key: string]: unknown;
2408
+ } | null;
2401
2409
  started_at?: Date | null;
2402
2410
  finished_at?: Date | null;
2403
2411
  created_at?: Date;
@@ -2435,7 +2443,7 @@ type ExceptionItem = {
2435
2443
  /**
2436
2444
  * How the exception was filed
2437
2445
  */
2438
- kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'manual';
2446
+ kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'event_trigger_loop' | 'manual';
2439
2447
  /**
2440
2448
  * Human-readable one-line summary
2441
2449
  */
@@ -3770,6 +3778,20 @@ type OrchestrationRun = {
3770
3778
  tool_context?: {
3771
3779
  [key: string]: string;
3772
3780
  } | null;
3781
+ /**
3782
+ * The caller-owned key/value metadata supplied at run creation, returned verbatim. Null when the run was started without any. The server writes nothing here and no key is reserved; the bag is never merged into `state`, so nothing in it reaches the graph.
3783
+ */
3784
+ metadata?: {
3785
+ [key: string]: unknown;
3786
+ } | null;
3787
+ /**
3788
+ * The run whose node started this one — set only on a child a `loop` or `sub_orchestration` node spawned, null for a run a caller started. A child is its own run with its own usage events, so this is what makes a delegated run's spend attributable to the run that ordered it.
3789
+ */
3790
+ parent_orchestration_run_id?: string | null;
3791
+ /**
3792
+ * The node within `parent_orchestration_run_id` that started this run. Null when `parent_orchestration_run_id` is null.
3793
+ */
3794
+ parent_node_id?: string | null;
3773
3795
  /**
3774
3796
  * Terminal node artifact(s) when the run has succeeded.
3775
3797
  */
@@ -3781,9 +3803,17 @@ type OrchestrationRun = {
3781
3803
  */
3782
3804
  node_executions?: Array<NodeExecution>;
3783
3805
  /**
3784
- * Usage roll-up (token counts and cost_usd) summed across every metered generation the run produced. Present on the single-run read; omitted from run list responses.
3806
+ * What the run cost: token counts and `cost_usd` summed across every metered generation it produced **and every run it started** through `loop` / `sub_orchestration` nodes, at any depth. Present on the single-run read; omitted from run list responses.
3807
+ *
3808
+ * A nested child is a run record of its own, so this figure spans several of them. Two consequences: summing `usage` across a list that mixes parents and children double-counts (filter with `nested=false`), and the per-event receipt at `/v1/projects/{project_id}/usage/receipt` stays scoped to one run — its line items carry a `node_id` from one graph only.
3785
3809
  */
3786
3810
  usage?: RunUsageTotals;
3811
+ /**
3812
+ * The same roll-up restricted to **this run's own nodes**, excluding every nested run it started. Equal to `usage` for a run with no children; below it for a run that delegates. Present on the single-run read; omitted from run list responses.
3813
+ *
3814
+ * This is the field to read to see where cost sits in a run tree — own versus subtree — without walking the children.
3815
+ */
3816
+ usage_own?: RunUsageTotals;
3787
3817
  required_action?: RequiredAction | null;
3788
3818
  started_at?: Date | null;
3789
3819
  completed_at?: Date | null;
@@ -3908,6 +3938,16 @@ type StartRunRequest = {
3908
3938
  tool_context?: {
3909
3939
  [key: string]: string;
3910
3940
  };
3941
+ /**
3942
+ * Caller-supplied key/value metadata attached to the run record for per-run attribution (e.g. which of your own tenants this run belongs to, or the dispatch batch that started it). Round-trips verbatim on every read of the run, on the list as well as the single read.
3943
+ *
3944
+ * The bag is caller-owned and no key is reserved: server-owned state (status, the pinned orchestration version, the trace, usage, artifacts, the run's own `input` and accumulated `state`) lives in its own top-level field and cannot be written from here.
3945
+ *
3946
+ * It is **not** merged into run state: no graph node sees it, and an `input_schema` never has to tolerate it — which is what makes it the place for an infrastructural label, rather than `input`. Keys are never transformed. It is not inherited by the child runs a `loop` or `sub_orchestration` node starts; each child carries whatever the graph gives it, which today is nothing.
3947
+ */
3948
+ metadata?: {
3949
+ [key: string]: unknown;
3950
+ };
3911
3951
  /**
3912
3952
  * When true, block until the run reaches a terminal (succeeded/failed) or awaiting_input state and return the settled run. When false (default), return immediately with status "queued" and execute the run in the background.
3913
3953
  */
@@ -4419,6 +4459,12 @@ type Task = {
4419
4459
  payload?: {
4420
4460
  [key: string]: unknown;
4421
4461
  };
4462
+ /**
4463
+ * The caller-owned key/value metadata supplied when the task was created, returned verbatim. Null when the task was created without any. Unlike `payload` it is invisible to guards and to `payload_writes`, so it is the place for an attribution label rather than task data.
4464
+ */
4465
+ metadata?: {
4466
+ [key: string]: unknown;
4467
+ } | null;
4422
4468
  /**
4423
4469
  * Server-owned. The result of the current state's last completed dispatch, overwritten on every dispatch. Read-only — exposed to transition guards and `on_complete`/`payload_writes` expressions as `task.last_result`, a namespace a caller cannot write.
4424
4470
  */
@@ -4498,6 +4544,16 @@ type CreateTaskRequest = {
4498
4544
  tool_context?: {
4499
4545
  [key: string]: string;
4500
4546
  };
4547
+ /**
4548
+ * Caller-supplied key/value metadata attached to the task record for attribution — which of your own tenants the task belongs to, the ticket that raised it, the import batch that created it. Round-trips verbatim on every read of the task, the list included, and survives every transition (a transition supplies no metadata of its own).
4549
+ *
4550
+ * The bag is caller-owned and no key is reserved: everything the engine decides about a task (`state`, `status`, `workflow_version`, `last_result`, `active_dispatch`, the automation fields) is a field of its own and cannot be written from here.
4551
+ *
4552
+ * Prefer this over `payload` for anything that is not task data: `payload` is read by every guard as `task.payload` and may be written by the workflow's declared `payload_writes`, so a label parked there is neither invisible to the state machine nor safe from it. A non-object is rejected with `400 VALIDATION_FAILED` and no task is created.
4553
+ */
4554
+ metadata?: {
4555
+ [key: string]: unknown;
4556
+ };
4501
4557
  };
4502
4558
  type UpdateTaskRequest = {
4503
4559
  title?: string;
@@ -4584,7 +4640,9 @@ type Tool = {
4584
4640
  */
4585
4641
  context_keys?: Array<string> | null;
4586
4642
  /**
4587
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
4643
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
4644
+ *
4645
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
4588
4646
  */
4589
4647
  preset_parameters?: {
4590
4648
  [key: string]: unknown;
@@ -4650,7 +4708,9 @@ type UpdateToolRequest = {
4650
4708
  */
4651
4709
  context_keys?: Array<string> | null;
4652
4710
  /**
4653
- * Fixed parameters merged into every action-based tool call. Keys matching fields in the action's input schema are removed from the schema shown to the model and injected automatically at execution time.
4711
+ * Fixed parameters pinned on every call this tool makes, whatever its type. Keys matching fields in the input schema are removed from the schema shown to the model, and a pinned value wins over one the model or a direct caller supplies for the same key.
4712
+ *
4713
+ * Values accept `{{context:<key>}}` references, resolved per call from the caller's `tool_context`, so a pin can be the run's own value — the one account this run may act on — rather than one fixed when the tool was created. A resolved value is retyped to the parameter's declared schema type; a key missing from the call's `tool_context` fails the call with `MISSING_TOOL_CONTEXT_KEY` rather than sending the literal placeholder. `{{secret:...}}` is not resolved here. See the Tool Context reference.
4654
4714
  */
4655
4715
  preset_parameters?: {
4656
4716
  [key: string]: unknown;
@@ -4679,7 +4739,7 @@ type CallToolRequest = {
4679
4739
  */
4680
4740
  action?: string;
4681
4741
  /**
4682
- * Input parameters for the tool call. These are merged with the tool's `preset_parameters` before execution (caller-supplied values take precedence).
4742
+ * Input parameters for the tool call. These are merged with the tool's `preset_parameters` before execution; a preset value wins over the same key sent here.
4683
4743
  *
4684
4744
  */
4685
4745
  input?: {
@@ -4795,7 +4855,7 @@ type Trigger = {
4795
4855
  project_id?: string;
4796
4856
  name?: string;
4797
4857
  description?: string | null;
4798
- type?: 'manual' | 'webhook' | 'schedule';
4858
+ type?: 'manual' | 'webhook' | 'schedule' | 'event';
4799
4859
  target_type?: 'orchestration' | 'agent' | 'tool' | 'eval';
4800
4860
  /**
4801
4861
  * Public ID of the target resource (orchestration, agent, tool, or eval)
@@ -4815,6 +4875,10 @@ type Trigger = {
4815
4875
  * 5-field cron expression (UTC). Present only for schedule triggers
4816
4876
  */
4817
4877
  cron?: string | null;
4878
+ /**
4879
+ * Internal-event subscription pattern. Present only for event triggers: `*`, `prefix.*`, or an exact event name
4880
+ */
4881
+ event_pattern?: string | null;
4818
4882
  active?: boolean;
4819
4883
  /**
4820
4884
  * Optional boundary policy that further restricts firings
@@ -4836,7 +4900,7 @@ type TriggerWithSecret = Trigger & {
4836
4900
  type CreateTriggerRequest = {
4837
4901
  name: string;
4838
4902
  description?: string;
4839
- type: 'manual' | 'webhook' | 'schedule';
4903
+ type: 'manual' | 'webhook' | 'schedule' | 'event';
4840
4904
  target_type: 'orchestration' | 'agent' | 'tool' | 'eval';
4841
4905
  target_id: string;
4842
4906
  /**
@@ -4850,6 +4914,10 @@ type CreateTriggerRequest = {
4850
4914
  * 5-field cron expression (UTC). Required when type is schedule
4851
4915
  */
4852
4916
  cron?: string;
4917
+ /**
4918
+ * Internal-event subscription pattern. Required when type is event, rejected otherwise. `*` matches every event, `prefix.*` a namespace, or give an exact event name such as `documents.ingested`
4919
+ */
4920
+ event_pattern?: string;
4853
4921
  active?: boolean;
4854
4922
  policy_id?: string;
4855
4923
  };
@@ -4863,6 +4931,7 @@ type UpdateTriggerRequest = {
4863
4931
  [key: string]: unknown;
4864
4932
  } | null;
4865
4933
  cron?: string | null;
4934
+ event_pattern?: string | null;
4866
4935
  active?: boolean;
4867
4936
  policy_id?: string | null;
4868
4937
  };
@@ -4881,7 +4950,7 @@ type TriggerFiring = {
4881
4950
  id?: string;
4882
4951
  trigger_id?: string;
4883
4952
  project_id?: string;
4884
- source?: 'manual' | 'webhook' | 'schedule';
4953
+ source?: 'manual' | 'webhook' | 'schedule' | 'event';
4885
4954
  status?: 'pending' | 'running' | 'succeeded' | 'failed';
4886
4955
  input?: {
4887
4956
  [key: string]: unknown;
@@ -10398,6 +10467,14 @@ type StartEvalRunData = {
10398
10467
  * A terminal run of the same eval to compare against. The finished run's `aggregate_scores.baseline` reports per-scorer deltas over the item intersection. A run of a different eval is rejected with 400.
10399
10468
  */
10400
10469
  baseline_run_id?: string | null;
10470
+ /**
10471
+ * Caller-supplied key/value metadata attached to the run record for attribution — what this measurement was of (the commit or release candidate being scored, the CI job that asked for it). Round-trips verbatim on every read of the run, the list included.
10472
+ *
10473
+ * The bag is caller-owned and no key is reserved: everything the platform decides about a run (`status`, `agent_version`, `baseline_run_id`, `aggregate_scores`, `passed`, the counts) is a field of its own and cannot be written from here. Nothing in the scoring path reads it. A non-object is rejected with `400 VALIDATION_FAILED` and no run is created.
10474
+ */
10475
+ metadata?: {
10476
+ [key: string]: unknown;
10477
+ };
10401
10478
  };
10402
10479
  path: {
10403
10480
  /**
@@ -10603,7 +10680,7 @@ type ListExceptionsData = {
10603
10680
  /**
10604
10681
  * Filter by how the exception was filed
10605
10682
  */
10606
- kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'manual';
10683
+ kind?: 'run_failed' | 'guardrail_tripwire' | 'approval_expired' | 'quota_unpriced' | 'event_trigger_loop' | 'manual';
10607
10684
  /**
10608
10685
  * Maximum number of results to return
10609
10686
  */
@@ -13444,6 +13521,16 @@ type ListOrchestrationRunsData = {
13444
13521
  * Filter by orchestration public ID (orch_...)
13445
13522
  */
13446
13523
  orchestration_id?: string;
13524
+ /**
13525
+ * Filter to the runs one specific parent run's `loop` / `sub_orchestration` nodes started (run_...). This is how a caller holding a parent names the individual children behind its `usage`.
13526
+ */
13527
+ parent_orchestration_run_id?: string;
13528
+ /**
13529
+ * Filter by whether the run was started by another run. `false` returns only the runs a caller started (no parent), which is the set to sum `usage` over; `true` returns only the runs a `loop` / `sub_orchestration` node started, across every parent. Omit to return both.
13530
+ *
13531
+ * Contradicting `parent_orchestration_run_id` with `nested=false` is a `400`; any value other than `true` or `false` is a `400`.
13532
+ */
13533
+ nested?: boolean;
13447
13534
  /**
13448
13535
  * Maximum number of results to return
13449
13536
  */
@@ -13490,7 +13577,7 @@ type StartOrchestrationRunData = {
13490
13577
  };
13491
13578
  type StartOrchestrationRunErrors = {
13492
13579
  /**
13493
- * Validation error
13580
+ * Validation error (e.g. a `tool_context` key that cannot become a header, or `metadata` that is not a JSON object). No run is created.
13494
13581
  */
13495
13582
  400: unknown;
13496
13583
  /**
@@ -15615,7 +15702,7 @@ type ListTriggersData = {
15615
15702
  project_id: string;
15616
15703
  };
15617
15704
  query?: {
15618
- type?: 'manual' | 'webhook' | 'schedule';
15705
+ type?: 'manual' | 'webhook' | 'schedule' | 'event';
15619
15706
  target_type?: 'orchestration' | 'agent' | 'tool' | 'eval';
15620
15707
  /**
15621
15708
  * Maximum number of results to return
@@ -17978,7 +18065,9 @@ declare class Orchestrations {
17978
18065
  /**
17979
18066
  * List orchestration runs
17980
18067
  *
17981
- * Returns orchestration runs the caller can access, optionally filtered by orchestration.
18068
+ * Returns orchestration runs the caller can access, optionally filtered by orchestration, by parent run, or by whether the run has a parent at all.
18069
+ *
18070
+ * Note when aggregating: a run's `usage` covers its whole subtree, so summing it over a list that contains both a parent and its children counts the children more than once. Pass `nested=false` to sum over runs a caller started.
17982
18071
  */
17983
18072
  static listOrchestrationRuns<ThrowOnError extends boolean = false>(options: Options<ListOrchestrationRunsData, ThrowOnError>): RequestResult<ListOrchestrationRunsResponses, ListOrchestrationRunsErrors, ThrowOnError>;
17984
18073
  /**
@@ -18304,7 +18393,7 @@ declare class Tools {
18304
18393
  *
18305
18394
  * Directly invokes a tool and returns its output. Supported for `http`, `mcp`, and `pipeline` tools. `client` tools cannot be invoked server-side and will return 422. A `pipeline` tool runs its declared steps in order and returns the mapped `output` (or the last step's output); `action` is ignored and `input` is the pipeline input.
18306
18395
  * For `mcp` tools the `action` field is required and identifies which tool name to invoke. For `http` tools `action` is ignored. When an `mcp` tool declares an `actions` allowlist, an action outside it is rejected with `400 VALIDATION_FAILED` ("not available on this tool") before any outbound request is made.
18307
- * `preset_parameters` stored on the tool are merged with the caller-supplied `input` before execution; preset keys take lower precedence.
18396
+ * `preset_parameters` stored on the tool are pinned over the caller-supplied `input` before execution: a key the tool presets keeps its preset value even when `input` sets it. Keys the presets do not name are taken from `input` as sent.
18308
18397
  *
18309
18398
  */
18310
18399
  static callTool<ThrowOnError extends boolean = false>(options: Options<CallToolData, ThrowOnError>): RequestResult<CallToolResponses, CallToolErrors, ThrowOnError>;
package/dist/index.mjs CHANGED
@@ -3121,7 +3121,9 @@ var Orchestrations = class {
3121
3121
  /**
3122
3122
  * List orchestration runs
3123
3123
  *
3124
- * Returns orchestration runs the caller can access, optionally filtered by orchestration.
3124
+ * Returns orchestration runs the caller can access, optionally filtered by orchestration, by parent run, or by whether the run has a parent at all.
3125
+ *
3126
+ * Note when aggregating: a run's `usage` covers its whole subtree, so summing it over a list that contains both a parent and its children counts the children more than once. Pass `nested=false` to sum over runs a caller started.
3125
3127
  */
3126
3128
  static listOrchestrationRuns(options) {
3127
3129
  return (options.client ?? client).get({
@@ -3771,7 +3773,7 @@ var Tools = class {
3771
3773
  *
3772
3774
  * Directly invokes a tool and returns its output. Supported for `http`, `mcp`, and `pipeline` tools. `client` tools cannot be invoked server-side and will return 422. A `pipeline` tool runs its declared steps in order and returns the mapped `output` (or the last step's output); `action` is ignored and `input` is the pipeline input.
3773
3775
  * For `mcp` tools the `action` field is required and identifies which tool name to invoke. For `http` tools `action` is ignored. When an `mcp` tool declares an `actions` allowlist, an action outside it is rejected with `400 VALIDATION_FAILED` ("not available on this tool") before any outbound request is made.
3774
- * `preset_parameters` stored on the tool are merged with the caller-supplied `input` before execution; preset keys take lower precedence.
3776
+ * `preset_parameters` stored on the tool are pinned over the caller-supplied `input` before execution: a key the tool presets keeps its preset value even when `input` sets it. Keys the presets do not name are taken from `input` as sent.
3775
3777
  *
3776
3778
  */
3777
3779
  static callTool(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/sdk",
3
- "version": "0.78.5",
3
+ "version": "0.79.0",
4
4
  "description": "TypeScript SDK for the naturali.ai API, generated from its OpenAPI specs",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "tsx": "^4.23.1",
38
38
  "typescript": "~6.0.3",
39
39
  "vitest": "^4.1.10",
40
- "@naturali/api": "0.78.5"
40
+ "@naturali/api": "0.79.0"
41
41
  },
42
42
  "scripts": {
43
43
  "generate": "tsx scripts/generate.ts",