@nanobpm/engine-wasm 0.8.7 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,27 +78,26 @@ export type AdvancedAgentInstanceStatusFilter = {
78
78
  };
79
79
 
80
80
  /**
81
- * The type of a single content block.
82
- */
83
- export type AgentInstanceContentTypeEnum = 'TEXT' | 'DOCUMENT' | 'OBJECT';
84
-
85
- /**
86
- * The outcome of appending a single history item from an update request's history batch.
81
+ * The outcome of appending a single history item from an update request's
82
+ * history batch.
83
+ *
87
84
  */
88
85
  export type AgentInstanceCreatedHistoryItem = {
89
86
  /**
90
- * The historyItemId of the corresponding request item, echoed back for correlation.
87
+ * The historyItemId of the corresponding item in the request, echoed back
88
+ * so callers can correlate response entries with request items by id.
89
+ *
91
90
  */
92
91
  historyItemId: string;
93
92
  /**
94
- * The system-generated key for the history item. When isDuplicate is true, this is
95
- * the key of the original entry, not a new one.
93
+ * The system-generated key for the history item. When isDuplicate is true,
94
+ * this is the key of the original entry, not a new one.
96
95
  *
97
96
  */
98
- historyItemKey: AgentHistoryKey;
97
+ historyItemKey: AgentHistoryItemKey;
99
98
  /**
100
- * True if this item had already been recorded and no new AGENT_HISTORY event was
101
- * created for it; false if a new event was created.
99
+ * True if this item had already been recorded and no new AGENT_HISTORY event
100
+ * was created for it; false if a new event was created.
102
101
  *
103
102
  */
104
103
  isDuplicate: boolean;
@@ -109,44 +108,35 @@ export type AgentInstanceCreatedHistoryItem = {
109
108
  */
110
109
  export type AgentInstanceCreationRequest = {
111
110
  /**
112
- * The key of the AHSP or AI Agent Task element instance.
111
+ * The key of the AI Agent Sub-process or AI Agent Task element instance.
113
112
  * The engine uses this key to infer processInstanceKey, elementId,
114
113
  * processDefinitionKey, and tenantId.
115
114
  *
116
115
  */
117
116
  elementInstanceKey: ElementInstanceKey;
118
117
  /**
119
- * Static definition set once at creation.
120
- */
121
- definition: AgentInstanceDefinition;
122
- /**
123
- * Limits for the agent execution. When omitted, all limits default to -1
124
- * (no limit).
118
+ * The key of the job activation during which this creation is being made.
119
+ * A creation must always be attributed to the active job that produced it.
125
120
  *
126
121
  */
127
- limits?: AgentInstanceLimits;
122
+ jobKey: JobKey;
128
123
  /**
129
- * The key of the agent job whose activation authorizes this create. Optional:
130
- * supply it for an `external` (job-backed) agent element to lease-gate the
131
- * create, and the server then rejects the create unless it references that
132
- * element's ACTIVATED job with a matching lease token and elementInstanceKey.
133
- * A jobless create (omit, or `0`) is always allowed on this REST create surface,
134
- * which carries no history batch; when supplied it is always validated. Omit (or `0`) for the engine-native
135
- * `aiAgentTask` / `aiAgentSubProcess` variants, whose AgentInstance is auto-minted
136
- * at activation.
124
+ * Opaque lease token received from the job activation response. Disambiguates
125
+ * this activation from any other activation of the same job: if the job is
126
+ * later retried, history items submitted under a superseded lease are discarded
127
+ * rather than committed.
137
128
  *
138
129
  */
139
- jobKey?: JobKey;
130
+ jobLease: string;
140
131
  /**
141
- * Lease token received from the job activation response, disambiguating this
142
- * activation from any other of the same job. A per-activation staleness handle
143
- * (a monotonic value distinct from the job's lease deadline, not a
144
- * cryptographically unguessable secret), serialized as a decimal string (an
145
- * unsigned 64-bit integer), so the server rejects any non-numeric value with 400.
146
- * Required alongside `jobKey` whenever a `jobKey` is supplied.
132
+ * A batch of history items to append to the agent instance's conversation
133
+ * history, in request order. Each created item is echoed back in the
134
+ * response's createdHistory, positionally correlated. Must include a
135
+ * CONFIGURATION item establishing model, provider, and systemPrompt (and,
136
+ * if needed, limits).
147
137
  *
148
138
  */
149
- jobLease?: string;
139
+ history: Array<AgentInstanceHistoryItem>;
150
140
  };
151
141
 
152
142
  /**
@@ -157,12 +147,19 @@ export type AgentInstanceCreationResult = {
157
147
  * The system-generated key for the created agent instance.
158
148
  */
159
149
  agentInstanceKey: AgentInstanceKey;
150
+ /**
151
+ * One entry per history item submitted in the request, in request order.
152
+ *
153
+ */
154
+ createdHistory: Array<AgentInstanceCreatedHistoryItem>;
160
155
  };
161
156
 
162
157
  /**
163
- * The static definition of an agent instance, set once at creation.
158
+ * The definition of an agent instance. Set at creation, but can change later via a
159
+ * CONFIGURATION history item.
160
+ *
164
161
  */
165
- export type AgentInstanceDefinition = {
162
+ export type AgentInstanceDefinitionResult = {
166
163
  /**
167
164
  * The LLM model identifier (for example, gpt-4o).
168
165
  */
@@ -172,9 +169,25 @@ export type AgentInstanceDefinition = {
172
169
  */
173
170
  provider: string;
174
171
  /**
175
- * The system prompt configured for this agent instance.
172
+ * The system prompt configured for this agent instance, as content blocks.
176
173
  */
177
- systemPrompt: string;
174
+ systemPrompt: Array<AgentInstanceMessageContent>;
175
+ };
176
+
177
+ /**
178
+ * Document content
179
+ *
180
+ * A Camunda Document Store reference content block.
181
+ */
182
+ export type AgentInstanceDocumentContent = {
183
+ /**
184
+ * The content type discriminator.
185
+ */
186
+ contentType: string;
187
+ /**
188
+ * A reference to a document stored in the Camunda Document Store.
189
+ */
190
+ documentReference: DocumentReference;
178
191
  };
179
192
 
180
193
  /**
@@ -185,6 +198,10 @@ export type AgentInstanceFilter = {
185
198
  * The unique key of the agent instance.
186
199
  */
187
200
  agentInstanceKey?: AgentInstanceKeyFilterProperty;
201
+ /**
202
+ * The key of the agent definition this agent instance is an instance of.
203
+ */
204
+ agentDefinitionKey?: AgentDefinitionKeyFilterProperty;
188
205
  /**
189
206
  * The current status of the agent instance.
190
207
  */
@@ -197,6 +214,13 @@ export type AgentInstanceFilter = {
197
214
  * The key of the process instance that owns this agent instance.
198
215
  */
199
216
  processInstanceKey?: ProcessInstanceKeyFilterProperty;
217
+ /**
218
+ * The key of the root process instance. Filters agent instances belonging to a specific
219
+ * call hierarchy. The root process instance is the top-level ancestor in the process
220
+ * instance hierarchy.
221
+ *
222
+ */
223
+ rootProcessInstanceKey?: ProcessInstanceKeyFilterProperty;
200
224
  /**
201
225
  * The key of the process definition associated with this agent instance.
202
226
  */
@@ -238,6 +262,10 @@ export type AgentInstanceFilter = {
238
262
 
239
263
  /**
240
264
  * The commit status of a history item.
265
+ * COMMITTED: the producing job completed successfully.
266
+ * PENDING: the producing job is still active (in-flight).
267
+ * DISCARDED: the producing job failed; this item was superseded by a later activation.
268
+ *
241
269
  */
242
270
  export type AgentInstanceHistoryCommitStatusEnum = 'COMMITTED' | 'PENDING' | 'DISCARDED';
243
271
 
@@ -247,15 +275,25 @@ export type AgentInstanceHistoryCommitStatusEnum = 'COMMITTED' | 'PENDING' | 'DI
247
275
  export type AgentInstanceHistoryCommitStatusFilterProperty = AgentInstanceHistoryCommitStatusEnum | AdvancedAgentInstanceHistoryCommitStatusFilter;
248
276
 
249
277
  /**
250
- * Agent instance history item search filter. When commitStatus is omitted, only
251
- * COMMITTED history items are returned.
252
- *
278
+ * Agent instance history item search filter.
253
279
  */
254
280
  export type AgentInstanceHistoryFilter = {
281
+ /**
282
+ * The unique key of the history item.
283
+ */
284
+ historyItemKey?: AgentHistoryItemKeyFilterProperty;
255
285
  /**
256
286
  * The role of the history item.
257
287
  */
258
288
  role?: AgentInstanceHistoryRoleFilterProperty;
289
+ /**
290
+ * The key of the element instance under which the history item was produced.
291
+ */
292
+ elementInstanceKey?: ElementInstanceKeyFilterProperty;
293
+ /**
294
+ * The key of the job activation that produced the history item.
295
+ */
296
+ jobKey?: JobKeyFilterProperty;
259
297
  /**
260
298
  * Filter by loop iteration number.
261
299
  */
@@ -279,15 +317,17 @@ export type AgentInstanceHistoryFilter = {
279
317
  */
280
318
  export type AgentInstanceHistoryItem = {
281
319
  /**
282
- * Caller-assigned identifier used to detect and dedupe retries of the same item.
283
- * Must be non-blank.
320
+ * Caller-assigned identifier used to detect and dedupe retries of the same
321
+ * item. For example, when a retried job activation resubmits history items
322
+ * it already sent in an earlier attempt, those items are not rejected; they
323
+ * are flagged via isDuplicate in the response instead. Must be non-blank.
284
324
  *
285
325
  */
286
326
  historyItemId: string;
287
327
  /**
288
328
  * The loop iteration this item belongs to.
289
329
  */
290
- loopIteration: number;
330
+ loopIteration: LoopIterationId;
291
331
  /**
292
332
  * The role of this history item in the conversation.
293
333
  */
@@ -298,6 +338,10 @@ export type AgentInstanceHistoryItem = {
298
338
  content: Array<AgentInstanceMessageContent>;
299
339
  /**
300
340
  * Tool calls associated with this history item.
341
+ * For ASSISTANT items: tool calls dispatched by this LLM response.
342
+ * For TOOL_RESULT items: single-entry array referencing the originating tool call.
343
+ * Omit for USER items.
344
+ *
301
345
  */
302
346
  toolCalls?: Array<AgentInstanceToolCall> | null;
303
347
  /**
@@ -309,25 +353,36 @@ export type AgentInstanceHistoryItem = {
309
353
  */
310
354
  producedAt: string;
311
355
  /**
312
- * The complete list of tools available to the agent as of this entry. CONFIGURATION items only.
356
+ * The complete list of tools available to the agent as of this entry. CONFIGURATION
357
+ * items only; omit for other roles. Omit to leave the tool list unchanged; send an
358
+ * empty array to clear it.
359
+ *
313
360
  */
314
361
  tools?: Array<AgentTool> | null;
315
362
  /**
316
- * The LLM model identifier as of this entry. CONFIGURATION items only.
363
+ * The LLM model identifier as of this entry. CONFIGURATION items only; omit for other
364
+ * roles.
365
+ *
317
366
  */
318
- model?: string | null;
367
+ model?: string;
319
368
  /**
320
- * The LLM provider as of this entry. CONFIGURATION items only.
369
+ * The LLM provider as of this entry. CONFIGURATION items only; omit for other roles.
370
+ *
321
371
  */
322
- provider?: string | null;
372
+ provider?: string;
323
373
  /**
324
- * The operational limits as of this entry. CONFIGURATION items only.
374
+ * The operational limits as of this entry. CONFIGURATION items only; omit for other
375
+ * roles.
376
+ *
325
377
  */
326
378
  limits?: AgentInstanceLimits;
327
379
  /**
328
- * The system prompt as of this entry. CONFIGURATION items only.
380
+ * The system prompt, as content blocks, as of this entry. CONFIGURATION items only;
381
+ * omit for other roles. Omit to leave the system prompt unchanged; when present, must
382
+ * be non-empty.
383
+ *
329
384
  */
330
- systemPrompt?: string | null;
385
+ systemPrompt?: Array<AgentInstanceMessageContent> | null;
331
386
  };
332
387
 
333
388
  /**
@@ -335,15 +390,15 @@ export type AgentInstanceHistoryItem = {
335
390
  */
336
391
  export type AgentInstanceHistoryItemMetrics = {
337
392
  /**
338
- * Input tokens consumed by this LLM call.
393
+ * Input tokens consumed by this LLM call. Null when not provided.
339
394
  */
340
395
  inputTokens: number | null;
341
396
  /**
342
- * Output tokens produced by this LLM call.
397
+ * Output tokens produced by this LLM call. Null when not provided.
343
398
  */
344
399
  outputTokens: number | null;
345
400
  /**
346
- * Wall-clock duration of the LLM call in milliseconds.
401
+ * Wall-clock duration of the LLM call in milliseconds. Null when not provided.
347
402
  */
348
403
  durationMs: number | null;
349
404
  };
@@ -355,9 +410,11 @@ export type AgentInstanceHistoryItemResult = {
355
410
  /**
356
411
  * The unique key for this history item. Stable and sortable by creation order.
357
412
  */
358
- historyItemKey: AgentHistoryKey;
413
+ historyItemKey: AgentHistoryItemKey;
359
414
  /**
360
- * The client-supplied identifier this item was created with. Empty when none.
415
+ * The client-supplied identifier this item was created with. Empty for items that don't
416
+ * carry one.
417
+ *
361
418
  */
362
419
  historyItemId: string;
363
420
  /**
@@ -365,37 +422,21 @@ export type AgentInstanceHistoryItemResult = {
365
422
  */
366
423
  agentInstanceKey: AgentInstanceKey;
367
424
  /**
368
- * The element instance under which this item was produced.
425
+ * The key of the AI Agent Task or ad-hoc sub-process element instance under which this item was produced.
369
426
  */
370
427
  elementInstanceKey: ElementInstanceKey;
371
- /**
372
- * The owning process instance key.
373
- */
374
- processInstanceKey: ProcessInstanceKey;
375
- /**
376
- * The root process instance key.
377
- */
378
- rootProcessInstanceKey: ProcessInstanceKey;
379
- /**
380
- * The process definition key.
381
- */
382
- processDefinitionKey: ProcessDefinitionKey;
383
- /**
384
- * The BPMN process ID of the process definition.
385
- */
386
- processDefinitionId: ProcessDefinitionId;
387
- /**
388
- * The tenant ID of this history item.
389
- */
390
- tenantId: TenantId;
391
428
  /**
392
429
  * The key of the job activation during which this item was produced.
393
430
  */
394
431
  jobKey: JobKey;
432
+ /**
433
+ * The lease token of the activation that produced this item.
434
+ */
435
+ jobLease: string;
395
436
  /**
396
437
  * The loop iteration this item belongs to.
397
438
  */
398
- loopIteration: number;
439
+ loopIteration: LoopIterationId;
399
440
  /**
400
441
  * The role of this history item in the conversation.
401
442
  */
@@ -405,11 +446,14 @@ export type AgentInstanceHistoryItemResult = {
405
446
  */
406
447
  content: Array<AgentInstanceMessageContent>;
407
448
  /**
408
- * Tool calls for this item.
449
+ * Tool calls for this item. Empty for USER items and ASSISTANT items with no tool dispatches.
450
+ * ASSISTANT items: dispatched tool calls.
451
+ * TOOL_RESULT items: single-entry array referencing the originating tool call.
452
+ *
409
453
  */
410
454
  toolCalls: Array<AgentInstanceToolCall>;
411
455
  /**
412
- * Per-call token and latency metrics. Present on ASSISTANT items (zeroed when the request omitted metrics at creation time); null for USER, TOOL_RESULT, and CONFIGURATION turns.
456
+ * Per-call token and latency metrics. Null when metrics were not provided at creation time.
413
457
  */
414
458
  metrics: AgentInstanceHistoryItemMetrics | null;
415
459
  /**
@@ -421,21 +465,34 @@ export type AgentInstanceHistoryItemResult = {
421
465
  */
422
466
  producedAt: string;
423
467
  /**
424
- * The complete list of tools available to the agent as of this entry.
468
+ * The complete list of tools available to the agent as of this entry. CONFIGURATION
469
+ * items only; empty for other roles.
470
+ *
425
471
  */
426
472
  tools: Array<AgentTool>;
427
473
  /**
428
- * The LLM model identifier as of this entry.
474
+ * The LLM model identifier as of this entry. CONFIGURATION items only; null for other
475
+ * roles.
476
+ *
429
477
  */
430
478
  model: string | null;
431
479
  /**
432
- * The LLM provider as of this entry.
480
+ * The LLM provider as of this entry. CONFIGURATION items only; null for other roles.
481
+ *
433
482
  */
434
483
  provider: string | null;
435
484
  /**
436
- * Whether this item was recorded as a duplicate of an earlier one.
485
+ * The operational limits as of this entry. CONFIGURATION items only; -1 on any field
486
+ * means "no limit configured" for other roles.
487
+ *
437
488
  */
438
- isDuplicate: boolean;
489
+ limits: AgentInstanceLimits;
490
+ /**
491
+ * The system prompt, as content blocks, as of this entry. CONFIGURATION items only;
492
+ * empty for other roles.
493
+ *
494
+ */
495
+ systemPrompt: Array<AgentInstanceMessageContent>;
439
496
  };
440
497
 
441
498
  /**
@@ -499,29 +556,15 @@ export type AgentInstanceLimits = {
499
556
  };
500
557
 
501
558
  /**
502
- * A single content block within a history item. The `contentType` discriminator selects which
503
- * payload field carries the content: TEXT → `text`, DOCUMENT → `documentReference`,
504
- * OBJECT → `object`.
505
- *
559
+ * A single content block within a history item. Discriminated by `contentType`.
506
560
  */
507
- export type AgentInstanceMessageContent = {
508
- /**
509
- * Which payload field carries this block's content.
510
- */
511
- contentType: AgentInstanceContentTypeEnum;
512
- /**
513
- * The plain-text payload. Present when contentType is TEXT.
514
- */
515
- text?: string | null;
516
- /**
517
- * An opaque reference to a stored document. Present when contentType is DOCUMENT.
518
- */
519
- documentReference?: string | null;
520
- /**
521
- * Arbitrary structured content (any valid JSON value). Present when contentType is OBJECT.
522
- */
523
- object?: unknown;
524
- };
561
+ export type AgentInstanceMessageContent = ({
562
+ contentType: 'TEXT';
563
+ } & AgentInstanceTextContent) | ({
564
+ contentType: 'DOCUMENT';
565
+ } & AgentInstanceDocumentContent) | ({
566
+ contentType: 'OBJECT';
567
+ } & AgentInstanceObjectContent);
525
568
 
526
569
  /**
527
570
  * Aggregated metrics for an agent instance across all model calls.
@@ -546,28 +589,23 @@ export type AgentInstanceMetrics = {
546
589
  };
547
590
 
548
591
  /**
549
- * Metric increments to apply to the agent instance aggregate counters. The engine
550
- * accumulates these deltas into running totals on each UPDATED event. All fields
551
- * are optional; omit a field to leave the corresponding counter unchanged.
592
+ * Object content
593
+ *
594
+ * An arbitrary structured content block. Accepts any valid JSON value:
595
+ * objects, arrays, numbers, booleans, or strings.
596
+ * Use TEXT content for human-readable natural language;
597
+ * use OBJECT content for machine-readable structured data.
552
598
  *
553
599
  */
554
- export type AgentInstanceMetricsDelta = {
555
- /**
556
- * Increment to apply to the total input token counter.
557
- */
558
- inputTokens?: number;
600
+ export type AgentInstanceObjectContent = {
559
601
  /**
560
- * Increment to apply to the total output token counter.
602
+ * The content type discriminator.
561
603
  */
562
- outputTokens?: number;
563
- /**
564
- * Increment to apply to the total model call counter.
565
- */
566
- modelCalls?: number;
604
+ contentType: string;
567
605
  /**
568
- * Increment to apply to the total tool call counter.
606
+ * Arbitrary structured content — any valid JSON value (object, array, number, boolean, or string).
569
607
  */
570
- toolCalls?: number;
608
+ object: unknown;
571
609
  };
572
610
 
573
611
  export type AgentInstanceResult = {
@@ -575,13 +613,19 @@ export type AgentInstanceResult = {
575
613
  * The unique key for this agent instance.
576
614
  */
577
615
  agentInstanceKey: AgentInstanceKey;
616
+ /**
617
+ * The key of the agent definition this agent instance is an instance of.
618
+ */
619
+ agentDefinitionKey: AgentDefinitionKey;
578
620
  status: AgentInstanceStatusEnum;
579
621
  /**
580
- * The static definition of the agent, including model, provider, and system prompt.
622
+ * The definition of the agent, including model, provider, and system prompt. Set at
623
+ * creation, but can change later via a CONFIGURATION history item.
624
+ *
581
625
  */
582
- definition: AgentInstanceDefinition;
626
+ definition: AgentInstanceDefinitionResult;
583
627
  /**
584
- * Aggregated metrics across all iterations of this agent instance.
628
+ * Aggregated metrics across all loopIterations of this agent instance.
585
629
  */
586
630
  metrics: AgentInstanceMetrics;
587
631
  /**
@@ -687,11 +731,28 @@ export type AgentInstanceStatusEnum = 'UNKNOWN' | 'COMPLETED' | 'IDLE' | 'INITIA
687
731
  export type AgentInstanceStatusFilterProperty = AgentInstanceStatusEnum | AdvancedAgentInstanceStatusFilter;
688
732
 
689
733
  /**
690
- * A tool call associated with a history item.
734
+ * Text content
735
+ *
736
+ * A plain-text content block.
737
+ */
738
+ export type AgentInstanceTextContent = {
739
+ /**
740
+ * The content type discriminator.
741
+ */
742
+ contentType: string;
743
+ /**
744
+ * The text content.
745
+ */
746
+ text: string;
747
+ };
748
+
749
+ /**
750
+ * A tool call associated with a history item. Used in both ASSISTANT and TOOL_RESULT items.
751
+ *
691
752
  */
692
753
  export type AgentInstanceToolCall = {
693
754
  /**
694
- * The LLM-assigned tool call ID.
755
+ * The LLM-assigned tool call ID. Correlates ASSISTANT items to their matching TOOL_RESULT items.
695
756
  */
696
757
  toolCallId: string;
697
758
  /**
@@ -703,7 +764,9 @@ export type AgentInstanceToolCall = {
703
764
  */
704
765
  elementId: string | null;
705
766
  /**
706
- * The tool call arguments as provided by the LLM.
767
+ * The tool call arguments as provided by the LLM. May be null or populated on
768
+ * any item, including TOOL_RESULT.
769
+ *
707
770
  */
708
771
  arguments: {
709
772
  [key: string]: unknown;
@@ -711,9 +774,7 @@ export type AgentInstanceToolCall = {
711
774
  };
712
775
 
713
776
  /**
714
- * Request to update the mutable state of an agent instance: advance its status and
715
- * append a batch of history items to its conversation history. Each created history
716
- * item is echoed back in the response's createdHistory, positionally correlated.
777
+ * Request to update the mutable state of an agent instance.
717
778
  *
718
779
  */
719
780
  export type AgentInstanceUpdateRequest = {
@@ -722,7 +783,10 @@ export type AgentInstanceUpdateRequest = {
722
783
  * Used for ownership/equality validation against the stored agent instance
723
784
  * and, when the supplied key differs from the previous association (re-entry
724
785
  * of an ad-hoc sub-process or AI Agent task), appended to elementInstanceKeys
725
- * with the reverse link updated on the supplied element instance.
786
+ * with the reverse link updated on the supplied element instance. Only one
787
+ * element instance may hold this write claim at a time: any update from a
788
+ * different element instance is rejected while the current writer's job is
789
+ * still active.
726
790
  *
727
791
  */
728
792
  elementInstanceKey: ElementInstanceKey;
@@ -731,45 +795,23 @@ export type AgentInstanceUpdateRequest = {
731
795
  */
732
796
  status?: AgentInstanceUpdateStatusEnum;
733
797
  /**
734
- * The key of the job activation during which this update is being made. Attributed
735
- * to each appended history item so a later retry can supersede in-flight items.
736
- * Required when the request carries a history batch (a history-bearing update needs
737
- * a job context); may be omitted for a history-free update (a pure status/metrics
738
- * advance). When supplied it is always validated against the element's ACTIVATED
739
- * job and matching lease token.
798
+ * The key of the job activation during which this update is being made.
799
+ * An update must always be attributed to the active job that produced it.
740
800
  *
741
801
  */
742
- jobKey?: JobKey;
743
- /**
744
- * Lease token received from the job activation response, disambiguating this
745
- * activation from any other of the same job. A per-activation staleness handle
746
- * (a monotonic value distinct from the job's lease deadline, not a
747
- * cryptographically unguessable secret), serialized as a decimal string (an
748
- * unsigned 64-bit integer), so the server rejects any non-numeric value with 400.
749
- * Required alongside `jobKey` whenever a `jobKey` is supplied, and validated then.
750
- *
751
- */
752
- jobLease?: string;
753
- /**
754
- * Metric increments to apply to the aggregate counters.
755
- */
756
- metrics?: AgentInstanceMetricsDelta;
802
+ jobKey: JobKey;
757
803
  /**
758
- * The complete list of tools available to the agent. Interpreted as a nullable
759
- * changeset with three distinct cases:
760
- * * omitted (field absent) — no change; the stored tool list is left untouched.
761
- * * null — clears the tool set, replacing any previously stored tools with an
762
- * empty list.
763
- * * array — replaces the existing tool list with exactly this value.
764
- * Note that null and an empty array are equivalent (both clear the set); omitting
765
- * the field is the only way to leave the existing tools unchanged.
804
+ * Opaque lease token received from the job activation response. Disambiguates
805
+ * this activation from any other activation of the same job: if the job is
806
+ * later retried, history items submitted under a superseded lease are discarded
807
+ * rather than committed.
766
808
  *
767
809
  */
768
- tools?: Array<AgentTool> | null;
810
+ jobLease: string;
769
811
  /**
770
- * A batch of history items to append to the agent instance's conversation history,
771
- * in request order. Each created item is echoed back in the response's createdHistory,
772
- * positionally correlated.
812
+ * A batch of history items to append to the agent instance's conversation
813
+ * history, in request order. Each created item is echoed back in the
814
+ * response's createdHistory, positionally correlated.
773
815
  *
774
816
  */
775
817
  history?: Array<AgentInstanceHistoryItem> | null;
@@ -4669,6 +4711,18 @@ export type GlobalListenerId = string;
4669
4711
  */
4670
4712
  export type GroupId = string;
4671
4713
 
4714
+ /**
4715
+ * A client-provided sequential integer identifying a loop iteration: one pass
4716
+ * through an AI agent's loop, during which the model reasons, selects tools,
4717
+ * evaluates the result, and decides whether to continue. One iteration covers
4718
+ * the input for the LLM call, the call itself, and the tools it dispatches;
4719
+ * the results of those tool calls are input to the next iteration. Must be a
4720
+ * positive integer, increasing with each loopIteration. Established by the
4721
+ * connector when appending the first history item of a loopIteration.
4722
+ *
4723
+ */
4724
+ export type LoopIterationId = number;
4725
+
4672
4726
  /**
4673
4727
  * The unique identifier of a mapping rule.
4674
4728
  */
@@ -5410,6 +5464,11 @@ export type ActivatedJobResult = {
5410
5464
  *
5411
5465
  */
5412
5466
  priority: number;
5467
+ /**
5468
+ * The lease token identifying this activation. This is null when the job was activated without a lease.
5469
+ *
5470
+ */
5471
+ leaseToken: string | null;
5413
5472
  };
5414
5473
 
5415
5474
  /**
@@ -5523,6 +5582,11 @@ export type JobActivationRequest = {
5523
5582
  *
5524
5583
  */
5525
5584
  tenantFilter?: TenantFilterEnum;
5585
+ /**
5586
+ * Whether to activate the jobs with a lease. When true, each activated job is assigned a distinct, opaque lease token, returned as ActivatedJobResult.leaseToken. The lease fences the complete, fail, and throw-error commands against a superseded activation of the same job. Once a job has been activated with a lease, it is served only to leasing workers of that job type. Omit or set to false to activate jobs without a lease.
5587
+ *
5588
+ */
5589
+ withLease?: boolean | null;
5526
5590
  };
5527
5591
 
5528
5592
  /**
@@ -5571,6 +5635,11 @@ export type JobCompletionRequest = {
5571
5635
  [key: string]: unknown;
5572
5636
  } | null;
5573
5637
  result?: JobResult;
5638
+ /**
5639
+ * The token identifying a leased job's activation, obtained from ActivatedJobResult.leaseToken. A leased job requires its matching token; missing or stale tokens are rejected. A job activated without a lease requires no token.
5640
+ *
5641
+ */
5642
+ leaseToken?: string | null;
5574
5643
  };
5575
5644
 
5576
5645
  export type JobErrorRequest = {
@@ -5591,6 +5660,11 @@ export type JobErrorRequest = {
5591
5660
  variables?: {
5592
5661
  [key: string]: unknown;
5593
5662
  } | null;
5663
+ /**
5664
+ * The token identifying a leased job's activation, obtained from ActivatedJobResult.leaseToken. A leased job requires its matching token; missing or stale tokens are rejected. A job activated without a lease requires no token.
5665
+ *
5666
+ */
5667
+ leaseToken?: string | null;
5594
5668
  };
5595
5669
 
5596
5670
  export type JobFailRequest = {
@@ -5613,6 +5687,11 @@ export type JobFailRequest = {
5613
5687
  variables?: {
5614
5688
  [key: string]: unknown;
5615
5689
  };
5690
+ /**
5691
+ * The token identifying a leased job's activation, obtained from ActivatedJobResult.leaseToken. A leased job requires its matching token; missing or stale tokens are rejected. A job activated without a lease requires no token.
5692
+ *
5693
+ */
5694
+ leaseToken?: string | null;
5616
5695
  };
5617
5696
 
5618
5697
  /**
@@ -6018,6 +6097,11 @@ export type JobUpdateBatchOperationRequest = {
6018
6097
  export type JobUpdateRequest = {
6019
6098
  changeset: JobChangeset;
6020
6099
  operationReference?: OperationReference;
6100
+ /**
6101
+ * The token identifying a leased job's activation, obtained from ActivatedJobResult.leaseToken. A supplied token is validated against the current lease. An update without a token applies to support operator and bulk updates, unlike complete, fail, and throw-error requests, which require a token for leased jobs.
6102
+ *
6103
+ */
6104
+ leaseToken?: string | null;
6021
6105
  };
6022
6106
 
6023
6107
  /**
@@ -6086,6 +6170,62 @@ export type _1Jobs1JobKey1Error = unknown;
6086
6170
 
6087
6171
  export type _1Jobs1JobKey1Failure = unknown;
6088
6172
 
6173
+ /**
6174
+ * Advanced filter
6175
+ *
6176
+ * Advanced AgentDefinitionKey filter.
6177
+ */
6178
+ export type AdvancedAgentDefinitionKeyFilter = {
6179
+ /**
6180
+ * Checks for equality with the provided value.
6181
+ */
6182
+ $eq?: AgentDefinitionKey;
6183
+ /**
6184
+ * Checks for inequality with the provided value.
6185
+ */
6186
+ $neq?: AgentDefinitionKey;
6187
+ /**
6188
+ * Checks if the current property exists.
6189
+ */
6190
+ $exists?: boolean;
6191
+ /**
6192
+ * Checks if the property matches any of the provided values.
6193
+ */
6194
+ $in?: Array<AgentDefinitionKey>;
6195
+ /**
6196
+ * Checks if the property matches none of the provided values.
6197
+ */
6198
+ $notIn?: Array<AgentDefinitionKey>;
6199
+ };
6200
+
6201
+ /**
6202
+ * Advanced filter
6203
+ *
6204
+ * Advanced AgentHistoryItemKey filter.
6205
+ */
6206
+ export type AdvancedAgentHistoryItemKeyFilter = {
6207
+ /**
6208
+ * Checks for equality with the provided value.
6209
+ */
6210
+ $eq?: AgentHistoryItemKey;
6211
+ /**
6212
+ * Checks for inequality with the provided value.
6213
+ */
6214
+ $neq?: AgentHistoryItemKey;
6215
+ /**
6216
+ * Checks if the current property exists.
6217
+ */
6218
+ $exists?: boolean;
6219
+ /**
6220
+ * Checks if the property matches any of the provided values.
6221
+ */
6222
+ $in?: Array<AgentHistoryItemKey>;
6223
+ /**
6224
+ * Checks if the property matches none of the provided values.
6225
+ */
6226
+ $notIn?: Array<AgentHistoryItemKey>;
6227
+ };
6228
+
6089
6229
  /**
6090
6230
  * Advanced filter
6091
6231
  *
@@ -6451,9 +6591,24 @@ export type AdvancedVariableKeyFilter = {
6451
6591
  };
6452
6592
 
6453
6593
  /**
6454
- * System-generated key for an agent instance history item.
6594
+ * System-generated key for an agent definition.
6595
+ */
6596
+ export type AgentDefinitionKey = LongKey;
6597
+
6598
+ /**
6599
+ * AgentDefinitionKey property with full advanced search capabilities.
6600
+ */
6601
+ export type AgentDefinitionKeyFilterProperty = AgentDefinitionKey | AdvancedAgentDefinitionKeyFilter;
6602
+
6603
+ /**
6604
+ * System-generated key for an agent history item.
6605
+ */
6606
+ export type AgentHistoryItemKey = LongKey;
6607
+
6608
+ /**
6609
+ * AgentHistoryItemKey property with full advanced search capabilities.
6455
6610
  */
6456
- export type AgentHistoryKey = LongKey;
6611
+ export type AgentHistoryItemKeyFilterProperty = AgentHistoryItemKey | AdvancedAgentHistoryItemKeyFilter;
6457
6612
 
6458
6613
  /**
6459
6614
  * System-generated key for an agent instance.
@@ -10065,12 +10220,15 @@ export type CreateAgentInstanceErrors = {
10065
10220
  */
10066
10221
  403: ProblemDetail;
10067
10222
  /**
10068
- * The elementInstanceKey does not correspond to an active element instance, or —
10069
- * for a lease-gated `external` create — the referenced job is not active or its
10070
- * lease token does not match. More details are provided in the response body.
10223
+ * The elementInstanceKey does not correspond to an active element instance.
10224
+ * More details are provided in the response body.
10071
10225
  *
10072
10226
  */
10073
10227
  404: ProblemDetail;
10228
+ /**
10229
+ * An agent instance already exists for the given element instance.
10230
+ */
10231
+ 409: ProblemDetail;
10074
10232
  /**
10075
10233
  * An internal error occurred while processing the request.
10076
10234
  */
@@ -10172,9 +10330,8 @@ export type UpdateAgentInstanceErrors = {
10172
10330
  */
10173
10331
  403: ProblemDetail;
10174
10332
  /**
10175
- * The agent instance with the given key was not found, or the job context
10176
- * supplied with the update references a job that is not active or whose lease
10177
- * token does not match. More details are provided in the response body.
10333
+ * The agent instance with the given key was not found.
10334
+ * More details are provided in the response body.
10178
10335
  *
10179
10336
  */
10180
10337
  404: ProblemDetail;
@@ -10257,6 +10414,12 @@ export type SearchAgentInstanceHistoryErrors = {
10257
10414
  * Forbidden. The request is not allowed.
10258
10415
  */
10259
10416
  403: ProblemDetail;
10417
+ /**
10418
+ * The agent instance with the given key was not found.
10419
+ * More details are provided in the response body.
10420
+ *
10421
+ */
10422
+ 404: ProblemDetail;
10260
10423
  /**
10261
10424
  * An internal error occurred while processing the request.
10262
10425
  */