@axlsdk/axl 0.19.0 → 0.20.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/README.md +31 -10
- package/dist/{chunk-JBLQKU6X.js → chunk-NVPA4RY6.js} +6 -4
- package/dist/chunk-NVPA4RY6.js.map +1 -0
- package/dist/index.cjs +2005 -791
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +518 -251
- package/dist/index.d.ts +518 -251
- package/dist/index.js +1988 -784
- package/dist/index.js.map +1 -1
- package/dist/span-manager-74ZCGELO.js +7 -0
- package/package.json +2 -2
- package/dist/chunk-JBLQKU6X.js.map +0 -1
- package/dist/span-manager-3IKXXUTZ.js +0 -7
- /package/dist/{span-manager-3IKXXUTZ.js.map → span-manager-74ZCGELO.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -354,9 +354,13 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
354
354
|
* derive `AxlEventType` from this tuple and use it to validate stream filters,
|
|
355
355
|
* redaction tables, and exhaustiveness assertions.
|
|
356
356
|
*/
|
|
357
|
-
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "
|
|
357
|
+
declare const AXL_EVENT_TYPES: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
358
358
|
/** Discriminator union derived from `AXL_EVENT_TYPES`. */
|
|
359
359
|
type AxlEventType = (typeof AXL_EVENT_TYPES)[number];
|
|
360
|
+
/** Backward-compatible name for the canonical v2 writer discriminator list. */
|
|
361
|
+
declare const AXL_EVENT_TYPES_V2: readonly ["workflow_start", "workflow_end", "ask_start", "ask_end", "agent_call_start", "agent_call_end", "token", "tool_call_start", "tool_call_end", "tool_call_rejected", "tool_approval", "delegate", "handoff_start", "handoff_return", "pipeline", "partial_object", "string_delta", "verify", "schema_diagnostic", "log", "memory_remember", "memory_recall", "memory_forget", "checkpoint_save", "checkpoint_replay", "await_human", "await_human_resolved", "guardrail", "schema_check", "validate", "done", "error"];
|
|
362
|
+
/** Accepted/rejected tool lifecycle discriminators in event schema v2. */
|
|
363
|
+
declare const AXL_TOOL_LIFECYCLE_TYPES_V2: readonly ["tool_call_start", "tool_call_end", "tool_call_rejected"];
|
|
360
364
|
/** Resolved model parameters sent to the provider for an LLM call. */
|
|
361
365
|
type AgentCallParams = {
|
|
362
366
|
temperature?: number;
|
|
@@ -431,18 +435,142 @@ type ToolCallData = {
|
|
|
431
435
|
type ToolCallStartData = {
|
|
432
436
|
args: unknown;
|
|
433
437
|
};
|
|
438
|
+
/** Data shape for a v2 tool start. The event's `tool` is canonical; this field
|
|
439
|
+
* retains the provider-visible request name only when it differs. */
|
|
440
|
+
type ToolCallStartDataV2 = {
|
|
441
|
+
args: unknown;
|
|
442
|
+
requestedTool?: string;
|
|
443
|
+
};
|
|
434
444
|
/** Data shape for `tool_approval` events. Emitted by the approval gate on both outcomes. */
|
|
435
445
|
type ToolApprovalData = {
|
|
436
446
|
approved: boolean;
|
|
437
447
|
args: unknown;
|
|
438
448
|
reason?: string;
|
|
439
449
|
};
|
|
440
|
-
/**
|
|
450
|
+
/** Historical v1 data shape for `tool_denied` events. V2 writers emit
|
|
451
|
+
* `tool_call_rejected` for unavailable provider requests instead. */
|
|
441
452
|
type ToolDeniedData = {
|
|
442
453
|
args?: unknown;
|
|
443
454
|
reason?: string;
|
|
444
455
|
callId?: string;
|
|
445
456
|
};
|
|
457
|
+
/** A validation issue for a provider-issued tool invocation.
|
|
458
|
+
*
|
|
459
|
+
* Values are deliberately omitted: paths and validator codes are sufficient
|
|
460
|
+
* for correction without copying application data into diagnostic channels.
|
|
461
|
+
*/
|
|
462
|
+
type ToolArgumentIssue = {
|
|
463
|
+
path: readonly (string | number)[];
|
|
464
|
+
code: string;
|
|
465
|
+
message?: string;
|
|
466
|
+
};
|
|
467
|
+
/** Data shape for a v2 tool request rejected before execution starts. */
|
|
468
|
+
type ToolCallRejectedData = {
|
|
469
|
+
reason: 'unavailable';
|
|
470
|
+
requestedTool: string;
|
|
471
|
+
availableTools: string[];
|
|
472
|
+
} | {
|
|
473
|
+
reason: 'invalid_json';
|
|
474
|
+
requestedTool: string;
|
|
475
|
+
message: string;
|
|
476
|
+
} | {
|
|
477
|
+
reason: 'invalid_arguments';
|
|
478
|
+
requestedTool: string;
|
|
479
|
+
args: unknown;
|
|
480
|
+
issues: readonly ToolArgumentIssue[];
|
|
481
|
+
};
|
|
482
|
+
/** Host-observable error details for a terminal tool outcome. */
|
|
483
|
+
type ToolEventError = {
|
|
484
|
+
name: string;
|
|
485
|
+
message: string;
|
|
486
|
+
code?: string;
|
|
487
|
+
/** Optional host-only diagnostic cause. Redaction removes this at every
|
|
488
|
+
* untrusted observation boundary. */
|
|
489
|
+
cause?: unknown;
|
|
490
|
+
};
|
|
491
|
+
/** Constructor input for the next-major model-safe thrown tool failure. */
|
|
492
|
+
type ToolFailureOptions = {
|
|
493
|
+
message: string;
|
|
494
|
+
modelMessage: string;
|
|
495
|
+
code?: string;
|
|
496
|
+
cause?: unknown;
|
|
497
|
+
};
|
|
498
|
+
/** Failure details for an accepted v2 tool invocation. */
|
|
499
|
+
type ToolCallFailure = {
|
|
500
|
+
phase: 'approval';
|
|
501
|
+
kind: 'infrastructure';
|
|
502
|
+
disposition: 'abort';
|
|
503
|
+
error: ToolEventError;
|
|
504
|
+
} | {
|
|
505
|
+
phase: 'before_hook';
|
|
506
|
+
kind: 'tool_failure';
|
|
507
|
+
disposition: 'continue';
|
|
508
|
+
error: ToolEventError;
|
|
509
|
+
} | {
|
|
510
|
+
phase: 'before_hook';
|
|
511
|
+
kind: 'unexpected';
|
|
512
|
+
disposition: 'abort';
|
|
513
|
+
error: ToolEventError;
|
|
514
|
+
} | {
|
|
515
|
+
phase: 'handler';
|
|
516
|
+
kind: 'tool_failure' | 'mcp_error';
|
|
517
|
+
disposition: 'continue';
|
|
518
|
+
error: ToolEventError;
|
|
519
|
+
attempts: number;
|
|
520
|
+
} | {
|
|
521
|
+
phase: 'handler';
|
|
522
|
+
kind: 'unexpected';
|
|
523
|
+
disposition: 'abort';
|
|
524
|
+
error: ToolEventError;
|
|
525
|
+
attempts: number;
|
|
526
|
+
} | {
|
|
527
|
+
phase: 'after_hook';
|
|
528
|
+
kind: 'tool_failure';
|
|
529
|
+
disposition: 'continue';
|
|
530
|
+
error: ToolEventError;
|
|
531
|
+
result: unknown;
|
|
532
|
+
} | {
|
|
533
|
+
phase: 'after_hook';
|
|
534
|
+
kind: 'unexpected';
|
|
535
|
+
disposition: 'abort';
|
|
536
|
+
error: ToolEventError;
|
|
537
|
+
result: unknown;
|
|
538
|
+
} | {
|
|
539
|
+
phase: 'projection' | 'serialization';
|
|
540
|
+
kind: 'output';
|
|
541
|
+
disposition: 'abort';
|
|
542
|
+
error: ToolEventError;
|
|
543
|
+
result: unknown;
|
|
544
|
+
};
|
|
545
|
+
/** Cancellation details for an accepted v2 tool invocation. */
|
|
546
|
+
type ToolCallCancellation = {
|
|
547
|
+
phase: 'approval' | 'before_hook' | 'handler';
|
|
548
|
+
reason?: string;
|
|
549
|
+
} | {
|
|
550
|
+
phase: 'after_handler' | 'after_hook' | 'projection' | 'serialization';
|
|
551
|
+
result: unknown;
|
|
552
|
+
reason?: string;
|
|
553
|
+
};
|
|
554
|
+
/** Terminal state of an accepted v2 tool invocation. */
|
|
555
|
+
type ToolCallOutcome = {
|
|
556
|
+
status: 'succeeded';
|
|
557
|
+
result: unknown;
|
|
558
|
+
} | {
|
|
559
|
+
status: 'failed';
|
|
560
|
+
failure: ToolCallFailure;
|
|
561
|
+
} | {
|
|
562
|
+
status: 'denied';
|
|
563
|
+
reason?: string;
|
|
564
|
+
} | {
|
|
565
|
+
status: 'cancelled';
|
|
566
|
+
cancellation: ToolCallCancellation;
|
|
567
|
+
};
|
|
568
|
+
/** Data shape for a v2 `tool_call_end` event. */
|
|
569
|
+
type ToolCallEndData = {
|
|
570
|
+
args: unknown;
|
|
571
|
+
requestedTool?: string;
|
|
572
|
+
outcome: ToolCallOutcome;
|
|
573
|
+
};
|
|
446
574
|
/** Data shape for `handoff_start` events (always emitted, pre-transition). */
|
|
447
575
|
type HandoffStartData = {
|
|
448
576
|
source: string;
|
|
@@ -586,6 +714,26 @@ type WorkflowStartData = {
|
|
|
586
714
|
/** The validated input passed to the workflow handler. */
|
|
587
715
|
input: unknown;
|
|
588
716
|
};
|
|
717
|
+
/** Machine-readable completeness of an observation surface or execution trace. */
|
|
718
|
+
type ObservationStatus = {
|
|
719
|
+
complete: true;
|
|
720
|
+
} | {
|
|
721
|
+
complete: false;
|
|
722
|
+
reason: 'queue_overflow';
|
|
723
|
+
droppedEvents: number;
|
|
724
|
+
} | {
|
|
725
|
+
complete: false;
|
|
726
|
+
reason: 'branch_drain_timeout';
|
|
727
|
+
pendingContinuations: number;
|
|
728
|
+
timeoutMs: number;
|
|
729
|
+
} | {
|
|
730
|
+
complete: false;
|
|
731
|
+
reason: 'persistence_truncated';
|
|
732
|
+
maxEvents: number;
|
|
733
|
+
} | {
|
|
734
|
+
complete: false;
|
|
735
|
+
reason: 'process_interrupted';
|
|
736
|
+
};
|
|
589
737
|
/** Data shape for `workflow_end` events. Emitted once per workflow execution
|
|
590
738
|
* on completion, failure, or cancellation. Distinguish cancellation via `aborted`. */
|
|
591
739
|
type WorkflowEndData = {
|
|
@@ -598,6 +746,9 @@ type WorkflowEndData = {
|
|
|
598
746
|
/** True when the failure was an `AbortError` (user cancellation, budget hard_stop,
|
|
599
747
|
* or consumer disconnect on streaming workflows). */
|
|
600
748
|
aborted?: boolean;
|
|
749
|
+
/** Completeness of the terminal trace. Present on new executions; absent
|
|
750
|
+
* on historical events written before completeness signaling shipped. */
|
|
751
|
+
observation?: ObservationStatus;
|
|
601
752
|
};
|
|
602
753
|
/** Data shape for `checkpoint_save` / `checkpoint_replay` events.
|
|
603
754
|
* Emitted by `ctx.checkpoint(name, fn)` — `save` on first execution,
|
|
@@ -723,22 +874,6 @@ type AskScoped = {
|
|
|
723
874
|
* events that predate agent resolution. */
|
|
724
875
|
agent?: string;
|
|
725
876
|
};
|
|
726
|
-
/**
|
|
727
|
-
* Meta carried alongside callback invocations (`onToken`, `onAgentStart`,
|
|
728
|
-
* `onToolCall`) so consumers can group/route by ask.
|
|
729
|
-
*
|
|
730
|
-
* Note: `agent` is **required** here (the callback is always invoked
|
|
731
|
-
* inside an ALS frame that has the agent name already resolved). On the
|
|
732
|
-
* event side (`AskScoped.agent`) the field is optional — events emitted
|
|
733
|
-
* before agent resolution (e.g., `ask_start` is fired before the
|
|
734
|
-
* dynamic agent selector runs) can land without it.
|
|
735
|
-
*/
|
|
736
|
-
type CallbackMeta = {
|
|
737
|
-
askId: string;
|
|
738
|
-
parentAskId?: string;
|
|
739
|
-
depth: number;
|
|
740
|
-
agent: string;
|
|
741
|
-
};
|
|
742
877
|
/**
|
|
743
878
|
* Unified event union. Replaces the old `TraceEvent` (rich, persisted) and
|
|
744
879
|
* `StreamEvent` (lean, wire) by emitting a single rich event from one site
|
|
@@ -757,7 +892,7 @@ type CallbackMeta = {
|
|
|
757
892
|
* exhaustiveness fixture in `__tests__/axl-event-exhaustive.test-d.ts` will
|
|
758
893
|
* also fail until the new case is handled.
|
|
759
894
|
*/
|
|
760
|
-
type
|
|
895
|
+
type LegacyAxlEventPayloadV1 = (AxlEventBase & {
|
|
761
896
|
type: 'workflow_start';
|
|
762
897
|
workflow: string;
|
|
763
898
|
data: WorkflowStartData;
|
|
@@ -934,6 +1069,59 @@ type AxlEvent = (AxlEventBase & {
|
|
|
934
1069
|
code?: string;
|
|
935
1070
|
};
|
|
936
1071
|
});
|
|
1072
|
+
/** Tool lifecycle variants written by the v2 event schema. */
|
|
1073
|
+
type ToolLifecycleEventV2 = (AxlEventBase & AskScoped & {
|
|
1074
|
+
schemaVersion: 2;
|
|
1075
|
+
type: 'tool_call_start';
|
|
1076
|
+
agent: string;
|
|
1077
|
+
tool: string;
|
|
1078
|
+
callId: string;
|
|
1079
|
+
data: ToolCallStartDataV2;
|
|
1080
|
+
}) | (AxlEventBase & AskScoped & {
|
|
1081
|
+
schemaVersion: 2;
|
|
1082
|
+
type: 'tool_call_end';
|
|
1083
|
+
agent: string;
|
|
1084
|
+
tool: string;
|
|
1085
|
+
callId: string;
|
|
1086
|
+
duration: number;
|
|
1087
|
+
cost?: number;
|
|
1088
|
+
data: ToolCallEndData;
|
|
1089
|
+
}) | (AxlEventBase & AskScoped & {
|
|
1090
|
+
schemaVersion: 2;
|
|
1091
|
+
type: 'tool_call_rejected';
|
|
1092
|
+
agent: string;
|
|
1093
|
+
tool: string;
|
|
1094
|
+
callId: string;
|
|
1095
|
+
data: ToolCallRejectedData;
|
|
1096
|
+
});
|
|
1097
|
+
/** Event persisted by the legacy unversioned writer. Readers may normalize the
|
|
1098
|
+
* absent marker to an explicit `1` without reinterpreting its payload. */
|
|
1099
|
+
type LegacyAxlEventV1 = LegacyAxlEventPayloadV1 & {
|
|
1100
|
+
schemaVersion?: 1;
|
|
1101
|
+
};
|
|
1102
|
+
/** Named v2 rejection event for consumers that do not need the full union. */
|
|
1103
|
+
type ToolCallRejectedEvent = Extract<ToolLifecycleEventV2, {
|
|
1104
|
+
type: 'tool_call_rejected';
|
|
1105
|
+
}>;
|
|
1106
|
+
/** Event contract written by the next breaking runtime.
|
|
1107
|
+
*
|
|
1108
|
+
* This additive prototype lets consumers and type tests lock the schema before
|
|
1109
|
+
* the runtime writer switches. Every v2 event carries the version directly;
|
|
1110
|
+
* `tool_denied` and the v1 tool end shape cannot be represented.
|
|
1111
|
+
*/
|
|
1112
|
+
type AxlEventV2 = ToolLifecycleEventV2 | (Exclude<LegacyAxlEventPayloadV1, {
|
|
1113
|
+
type: 'tool_call_start' | 'tool_call_end' | 'tool_denied';
|
|
1114
|
+
}> & {
|
|
1115
|
+
schemaVersion: 2;
|
|
1116
|
+
});
|
|
1117
|
+
/** Current live event contract. Every emitted event is explicitly v2. */
|
|
1118
|
+
type AxlEvent = AxlEventV2;
|
|
1119
|
+
/** Event returned by state-store and recovery readers during the migration. */
|
|
1120
|
+
type HistoricalAxlEvent = LegacyAxlEventV1 | AxlEventV2;
|
|
1121
|
+
/** Convenience: extract a v2 union member by discriminator. */
|
|
1122
|
+
type AxlEventV2Of<T extends AxlEventV2['type']> = Extract<AxlEventV2, {
|
|
1123
|
+
type: T;
|
|
1124
|
+
}>;
|
|
937
1125
|
/** Convenience: extract the union member matching a given `type` discriminator. */
|
|
938
1126
|
type AxlEventOf<T extends AxlEventType> = Extract<AxlEvent, {
|
|
939
1127
|
type: T;
|
|
@@ -975,14 +1163,14 @@ type OutputValidator<T = unknown> = (output: T, ctx: {
|
|
|
975
1163
|
metadata: Record<string, unknown>;
|
|
976
1164
|
}) => ValidateResult | Promise<ValidateResult>;
|
|
977
1165
|
/** Execution info */
|
|
978
|
-
type
|
|
1166
|
+
type ExecutionInfoV1 = {
|
|
979
1167
|
executionId: string;
|
|
980
1168
|
workflow: string;
|
|
981
1169
|
status: ExecutionStatus;
|
|
982
1170
|
/** Full event timeline. Tokens and `partial_object` events are NOT persisted
|
|
983
1171
|
* here (stream-only); aggregate `tokens: { input, output, reasoning? }`
|
|
984
1172
|
* on `agent_call_end` is the persisted token representation. */
|
|
985
|
-
events:
|
|
1173
|
+
events: LegacyAxlEventV1[];
|
|
986
1174
|
/** Total spend for the execution. A LOWER BOUND when an unpriced model ran
|
|
987
1175
|
* (those calls contribute nothing) — read {@link ExecutionInfo.unpriced} to
|
|
988
1176
|
* know whether it's exact, rather than scanning the event timeline. */
|
|
@@ -999,6 +1187,9 @@ type ExecutionInfo = {
|
|
|
999
1187
|
duration: number;
|
|
1000
1188
|
result?: unknown;
|
|
1001
1189
|
error?: string;
|
|
1190
|
+
/** Completeness of the persisted event timeline. Absent on historical
|
|
1191
|
+
* rows written before completeness signaling shipped. */
|
|
1192
|
+
observation?: ObservationStatus;
|
|
1002
1193
|
/** Caller-supplied metadata threaded verbatim from `ExecuteOptions.metadata`
|
|
1003
1194
|
* (or `runtime.stream()`'s `options.metadata`). Persisted as part of the
|
|
1004
1195
|
* `ExecutionInfo` snapshot so callers have a stable, queryable surface for
|
|
@@ -1008,6 +1199,19 @@ type ExecutionInfo = {
|
|
|
1008
1199
|
* provided — `StateStore` is a persistence boundary, not a query engine. */
|
|
1009
1200
|
metadata?: Record<string, unknown>;
|
|
1010
1201
|
};
|
|
1202
|
+
/** Stored execution written before explicit event schema versioning. */
|
|
1203
|
+
type LegacyExecutionInfoV1 = ExecutionInfoV1 & {
|
|
1204
|
+
eventSchemaVersion?: 1;
|
|
1205
|
+
};
|
|
1206
|
+
/** Stored or live execution written by the v2 event writer. */
|
|
1207
|
+
type ExecutionInfoV2 = Omit<ExecutionInfoV1, 'events'> & {
|
|
1208
|
+
eventSchemaVersion: 2;
|
|
1209
|
+
events: AxlEventV2[];
|
|
1210
|
+
};
|
|
1211
|
+
/** Current live execution contract. Historical reads retain their explicit union. */
|
|
1212
|
+
type ExecutionInfo = ExecutionInfoV2;
|
|
1213
|
+
/** Honest state-store read contract: missing version metadata means v1. */
|
|
1214
|
+
type HistoricalExecutionInfo = LegacyExecutionInfoV1 | ExecutionInfoV2;
|
|
1011
1215
|
/** Record of an agent handoff event (persisted in session metadata).
|
|
1012
1216
|
*
|
|
1013
1217
|
* `duration` semantics:
|
|
@@ -1098,6 +1302,82 @@ type ProviderResponse = {
|
|
|
1098
1302
|
providerMetadata?: Record<string, unknown>;
|
|
1099
1303
|
};
|
|
1100
1304
|
|
|
1305
|
+
/** Base error class for all Axl errors */
|
|
1306
|
+
declare class AxlError extends Error {
|
|
1307
|
+
readonly code: string;
|
|
1308
|
+
constructor(code: string, message: string);
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Strict observation overflow. Kept in the shared error module so every
|
|
1312
|
+
* recovery boundary can identify the same non-recoverable control error.
|
|
1313
|
+
* Thrown at the producer when an event queue configured with
|
|
1314
|
+
* `onOverflow: 'throw'` exceeds `maxQueued`.
|
|
1315
|
+
*/
|
|
1316
|
+
declare class EventStreamOverflowError extends Error {
|
|
1317
|
+
readonly maxQueued: number;
|
|
1318
|
+
readonly eventType: string;
|
|
1319
|
+
readonly cause?: unknown;
|
|
1320
|
+
constructor(maxQueued: number, eventType: string, cause?: unknown);
|
|
1321
|
+
}
|
|
1322
|
+
/** A known tool failure whose author-provided model message is safe to expose. */
|
|
1323
|
+
declare class ToolFailure extends AxlError {
|
|
1324
|
+
readonly modelMessage: string;
|
|
1325
|
+
readonly cause?: unknown;
|
|
1326
|
+
constructor(options: ToolFailureOptions);
|
|
1327
|
+
}
|
|
1328
|
+
type ToolFailureConstructor = typeof ToolFailure;
|
|
1329
|
+
/** Thrown when a tool's model-facing output cannot be projected safely. */
|
|
1330
|
+
declare class ToolModelOutputError extends AxlError {
|
|
1331
|
+
readonly toolName: string;
|
|
1332
|
+
readonly cause: unknown;
|
|
1333
|
+
constructor(toolName: string, cause: unknown);
|
|
1334
|
+
}
|
|
1335
|
+
/** Thrown when schema validation fails after all retries exhausted */
|
|
1336
|
+
declare class VerifyError extends AxlError {
|
|
1337
|
+
readonly lastOutput: unknown;
|
|
1338
|
+
readonly zodError: ZodError;
|
|
1339
|
+
readonly retries: number;
|
|
1340
|
+
constructor(lastOutput: unknown, zodError: ZodError, retries: number);
|
|
1341
|
+
}
|
|
1342
|
+
/** Thrown when quorum is not met in spawn */
|
|
1343
|
+
declare class QuorumNotMet extends AxlError {
|
|
1344
|
+
readonly results: Result<unknown>[];
|
|
1345
|
+
constructor(required: number, actual: number, results: Result<unknown>[]);
|
|
1346
|
+
}
|
|
1347
|
+
/** Thrown when vote cannot reach consensus */
|
|
1348
|
+
declare class NoConsensus extends AxlError {
|
|
1349
|
+
constructor(reason: string);
|
|
1350
|
+
}
|
|
1351
|
+
/** Thrown when an operation exceeds its timeout */
|
|
1352
|
+
declare class TimeoutError extends AxlError {
|
|
1353
|
+
constructor(operation: string, timeoutMs: number);
|
|
1354
|
+
}
|
|
1355
|
+
/** Thrown when a budget limit is exceeded */
|
|
1356
|
+
declare class BudgetExceededError extends AxlError {
|
|
1357
|
+
readonly limit: number;
|
|
1358
|
+
readonly spent: number;
|
|
1359
|
+
readonly policy: string;
|
|
1360
|
+
constructor(limit: number, spent: number, policy: string);
|
|
1361
|
+
}
|
|
1362
|
+
/** Thrown when an agent exceeds its maximum number of tool-calling turns */
|
|
1363
|
+
declare class MaxTurnsError extends AxlError {
|
|
1364
|
+
readonly maxTurns: number;
|
|
1365
|
+
constructor(operation: string, maxTurns: number);
|
|
1366
|
+
}
|
|
1367
|
+
/** Thrown when a guardrail blocks a request/response and the policy is 'throw'. */
|
|
1368
|
+
declare class GuardrailError extends AxlError {
|
|
1369
|
+
readonly guardrailType: 'input' | 'output';
|
|
1370
|
+
readonly reason: string;
|
|
1371
|
+
constructor(guardrailType: 'input' | 'output', reason: string);
|
|
1372
|
+
}
|
|
1373
|
+
/** Thrown when post-schema business rule validation fails after all retries exhausted */
|
|
1374
|
+
declare class ValidationError extends AxlError {
|
|
1375
|
+
readonly lastOutput: unknown;
|
|
1376
|
+
readonly reason: string;
|
|
1377
|
+
readonly retries: number;
|
|
1378
|
+
constructor(lastOutput: unknown, reason: string, retries: number);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1101
1381
|
/** Descriptor for a handoff target agent with optional description. */
|
|
1102
1382
|
type HandoffDescriptor = {
|
|
1103
1383
|
agent: Agent;
|
|
@@ -1165,11 +1445,13 @@ type Agent = {
|
|
|
1165
1445
|
declare function agent(config: AgentConfig): Agent;
|
|
1166
1446
|
|
|
1167
1447
|
/** Options shared between `AxlEventBus` (and therefore `AxlStream` and
|
|
1168
|
-
* `ctx.events`). Controls the overflow safety net on the iterator queue
|
|
1448
|
+
* `ctx.events`). Controls the overflow safety net on the main iterator queue
|
|
1449
|
+
* and each listener-based `stringStream()` subscriber queue. */
|
|
1169
1450
|
interface EventStreamOptions {
|
|
1170
|
-
/** Soft cap on the number of events held
|
|
1171
|
-
*
|
|
1172
|
-
* `workflow_end`) are exempt
|
|
1451
|
+
/** Soft cap on the number of events held while waiting for a consumer,
|
|
1452
|
+
* including distinct pending fields in each `stringStream()` subscriber.
|
|
1453
|
+
* Terminal events (`done`, `error`, `workflow_end`) are exempt from the
|
|
1454
|
+
* main iterator cap and always pass through. Default 10_000.
|
|
1173
1455
|
*
|
|
1174
1456
|
* Set to `Infinity` to disable the cap (matches pre-0.x behavior). */
|
|
1175
1457
|
maxQueued?: number;
|
|
@@ -1216,7 +1498,8 @@ type CoalescedPartialObject = {
|
|
|
1216
1498
|
/**
|
|
1217
1499
|
* The shape yielded by `AxlEventBus.stringStream` (and `AxlStream.stringStream`).
|
|
1218
1500
|
*
|
|
1219
|
-
* A live `string_delta` event carries `delta` (the new chars
|
|
1501
|
+
* A live `string_delta` event carries `delta` (the new chars since this
|
|
1502
|
+
* subscriber's previous yield; slow subscribers may coalesce source chunks)
|
|
1220
1503
|
* and `accumulated` (every char emitted so far for this ask + path,
|
|
1221
1504
|
* i.e. `delta1 + delta2 + ...`). Consumers rendering full-field state set
|
|
1222
1505
|
* their UI text to `accumulated`; consumers rendering incrementally use
|
|
@@ -1240,8 +1523,9 @@ type StringStreamEvent = {
|
|
|
1240
1523
|
agent?: string;
|
|
1241
1524
|
/** RFC 6901 JSON Pointer; matches the source `string_delta.data.path`. */
|
|
1242
1525
|
path: string;
|
|
1243
|
-
/** Chars added
|
|
1244
|
-
*
|
|
1526
|
+
/** Chars added since this subscriber's previous yield. May combine several
|
|
1527
|
+
* source chunks when the subscriber is slow. For seeded events, equals
|
|
1528
|
+
* `accumulated` (the full text-so-far). */
|
|
1245
1529
|
delta: string;
|
|
1246
1530
|
/** Concatenation of every delta this ask + path has emitted in the
|
|
1247
1531
|
* current attempt. Cleared on `pipeline(failed)` and `ask_end`. */
|
|
@@ -1266,29 +1550,6 @@ type StringStreamFilter = {
|
|
|
1266
1550
|
path?: string;
|
|
1267
1551
|
askId?: string;
|
|
1268
1552
|
};
|
|
1269
|
-
/**
|
|
1270
|
-
* Thrown when an `AxlEventBus` queue exceeds `maxQueued` and `onOverflow`
|
|
1271
|
-
* is set to `'throw'`. Surfaced as a typed error so the runtime's emit
|
|
1272
|
-
* pipeline can distinguish a legitimate overflow signal (which must
|
|
1273
|
-
* propagate to fail the workflow) from a buggy trace-listener exception
|
|
1274
|
-
* (which gets swallowed).
|
|
1275
|
-
*
|
|
1276
|
-
* Consumers using `instanceof` to handle overflow specifically:
|
|
1277
|
-
* ```typescript
|
|
1278
|
-
* try {
|
|
1279
|
-
* await runtime.execute('wf', input, { events: { onOverflow: 'throw' } });
|
|
1280
|
-
* } catch (err) {
|
|
1281
|
-
* if (err instanceof EventStreamOverflowError) {
|
|
1282
|
-
* // overflow — back off, retry, or surface to user
|
|
1283
|
-
* }
|
|
1284
|
-
* }
|
|
1285
|
-
* ```
|
|
1286
|
-
*/
|
|
1287
|
-
declare class EventStreamOverflowError extends Error {
|
|
1288
|
-
readonly maxQueued: number;
|
|
1289
|
-
readonly eventType: string;
|
|
1290
|
-
constructor(maxQueued: number, eventType: string);
|
|
1291
|
-
}
|
|
1292
1553
|
/**
|
|
1293
1554
|
* Iterable + EventEmitter event bus carrying `AxlEvent`.
|
|
1294
1555
|
*
|
|
@@ -1319,6 +1580,7 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1319
1580
|
private readonly maxQueued;
|
|
1320
1581
|
private readonly onOverflow;
|
|
1321
1582
|
private overflowWarned;
|
|
1583
|
+
private droppedEvents;
|
|
1322
1584
|
/** Callbacks fired exactly once when `_finish()` is called. Used by
|
|
1323
1585
|
* curated views (e.g., `partialObjects`) that are listener-based and
|
|
1324
1586
|
* need a termination signal independent of any synthetic `done` event. */
|
|
@@ -1364,6 +1626,10 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1364
1626
|
* can be 4 KB+ each, hence the more aggressive cleanup here).
|
|
1365
1627
|
*/
|
|
1366
1628
|
private stringStreamByAsk;
|
|
1629
|
+
/** Internal fan-out for `stringStream()` subscribers. Kept separate from
|
|
1630
|
+
* the public EventEmitter so strict curated-view overflow is a runtime
|
|
1631
|
+
* signal, not mistaken for (and swallowed as) a buggy user listener. */
|
|
1632
|
+
private stringStreamSubscribers;
|
|
1367
1633
|
/**
|
|
1368
1634
|
* Hook fired when an iterator obtained from `[Symbol.asyncIterator]`
|
|
1369
1635
|
* is `await using`-disposed. Set via the second constructor argument.
|
|
@@ -1385,6 +1651,10 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1385
1651
|
* Used by `AxlStream` to forward to `Readable.destroy()`.
|
|
1386
1652
|
*/
|
|
1387
1653
|
constructor(options?: EventStreamOptions, onIteratorDispose?: () => void);
|
|
1654
|
+
/** Machine-readable completeness across this bus's bounded iterable views.
|
|
1655
|
+
* EventEmitter listener delivery is independent and is not described by
|
|
1656
|
+
* this status. */
|
|
1657
|
+
get observationStatus(): ObservationStatus;
|
|
1388
1658
|
private unknownEventWarned;
|
|
1389
1659
|
/** Subscribe to an `AxlEvent` variant by type. Names outside
|
|
1390
1660
|
* `AXL_EVENT_TYPES` are dropped (the bus only emits those names) but
|
|
@@ -1519,6 +1789,7 @@ declare class AxlEventBus implements AsyncIterable<AxlEvent> {
|
|
|
1519
1789
|
* non-terminal event arrives. Terminal events bypass this path entirely
|
|
1520
1790
|
* (checked by the caller). */
|
|
1521
1791
|
private handleOverflow;
|
|
1792
|
+
private warnOverflow;
|
|
1522
1793
|
/**
|
|
1523
1794
|
* Mark the bus as finished. Wakes any pending iterators with `done: true`
|
|
1524
1795
|
* and drops further `_push` calls. Idempotent.
|
|
@@ -1928,7 +2199,8 @@ type PendingDecision = {
|
|
|
1928
2199
|
metadata?: Record<string, unknown>;
|
|
1929
2200
|
createdAt: string;
|
|
1930
2201
|
};
|
|
1931
|
-
/**
|
|
2202
|
+
/** Legacy application-managed execution state. Axl does not automatically
|
|
2203
|
+
* resume workflow continuations from this record. */
|
|
1932
2204
|
type ExecutionState = {
|
|
1933
2205
|
workflow: string;
|
|
1934
2206
|
input: unknown;
|
|
@@ -1968,11 +2240,11 @@ interface StateStore {
|
|
|
1968
2240
|
/** Delete a memory entry by key. */
|
|
1969
2241
|
deleteMemory?(scope: string, key: string): Promise<void>;
|
|
1970
2242
|
/** Save a completed/failed execution to history. */
|
|
1971
|
-
saveExecution?(execution:
|
|
2243
|
+
saveExecution?(execution: HistoricalExecutionInfo): Promise<void>;
|
|
1972
2244
|
/** Get a specific execution by ID from history. */
|
|
1973
|
-
getExecution?(executionId: string): Promise<
|
|
2245
|
+
getExecution?(executionId: string): Promise<HistoricalExecutionInfo | null>;
|
|
1974
2246
|
/** List recent executions (most recent first). */
|
|
1975
|
-
listExecutions?(limit?: number): Promise<
|
|
2247
|
+
listExecutions?(limit?: number): Promise<HistoricalExecutionInfo[]>;
|
|
1976
2248
|
/**
|
|
1977
2249
|
* Delete an execution from history by ID. Returns `true` if an entry was
|
|
1978
2250
|
* deleted, `false` if the ID didn't exist. Used for GDPR right-to-be-
|
|
@@ -2029,7 +2301,7 @@ interface StateStore {
|
|
|
2029
2301
|
* Read the events accumulated in the streaming buffer for an execution.
|
|
2030
2302
|
* Returns `[]` if no buffer exists.
|
|
2031
2303
|
*/
|
|
2032
|
-
getStreamingEvents?(executionId: string): Promise<
|
|
2304
|
+
getStreamingEvents?(executionId: string): Promise<HistoricalAxlEvent[]>;
|
|
2033
2305
|
close?(): Promise<void>;
|
|
2034
2306
|
deleteCheckpoints?(executionId: string): Promise<void>;
|
|
2035
2307
|
}
|
|
@@ -2054,7 +2326,7 @@ type TelemetryConfig = {
|
|
|
2054
2326
|
interface SpanHandle {
|
|
2055
2327
|
setAttribute(key: string, value: string | number | boolean): void;
|
|
2056
2328
|
addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
2057
|
-
setStatus(code: 'ok' | 'error', message?: string): void;
|
|
2329
|
+
setStatus(code: 'unset' | 'ok' | 'error', message?: string): void;
|
|
2058
2330
|
end(): void;
|
|
2059
2331
|
}
|
|
2060
2332
|
/** Manages span creation and context propagation. */
|
|
@@ -2214,7 +2486,8 @@ type StateConfig = {
|
|
|
2214
2486
|
* `log` event with `data.event === 'events_truncated'` is appended
|
|
2215
2487
|
* recording the truncation. The trace channel (`runtime.on('trace')`)
|
|
2216
2488
|
* and WS broadcast continue to receive every event — only the
|
|
2217
|
-
* in-memory `ExecutionInfo.events` array is bounded.
|
|
2489
|
+
* in-memory `ExecutionInfo.events` array is bounded. The execution's
|
|
2490
|
+
* `observation` becomes `persistence_truncated`.
|
|
2218
2491
|
*
|
|
2219
2492
|
* Default: 50_000. Set to `Infinity` to disable the cap (legacy
|
|
2220
2493
|
* behavior; only safe for short-lived executions). Must be a positive
|
|
@@ -2235,7 +2508,8 @@ type StateConfig = {
|
|
|
2235
2508
|
* terminal exit. If the process crashes mid-run, call
|
|
2236
2509
|
* `runtime.recoverIncompleteStreams()` on the next process to reconstruct
|
|
2237
2510
|
* the partial `ExecutionInfo` from the streaming buffer (status: `'failed'`,
|
|
2238
|
-
* error: `'process terminated'`). Use
|
|
2511
|
+
* error: `'process terminated'`, observation: `process_interrupted`). Use
|
|
2512
|
+
* this in production when you need to
|
|
2239
2513
|
* know "what did the workflow do up to the crash."
|
|
2240
2514
|
*
|
|
2241
2515
|
* Excluded from streaming flush even in `'streaming'` mode: `token`,
|
|
@@ -2554,6 +2828,16 @@ declare class MemoryManager {
|
|
|
2554
2828
|
close(): Promise<void>;
|
|
2555
2829
|
}
|
|
2556
2830
|
|
|
2831
|
+
type BranchDrainState = {
|
|
2832
|
+
pending: Set<Promise<unknown>>;
|
|
2833
|
+
overflow?: EventStreamOverflowError;
|
|
2834
|
+
timeoutMs: number;
|
|
2835
|
+
deadline?: number;
|
|
2836
|
+
};
|
|
2837
|
+
type WorkflowLifecycleState = {
|
|
2838
|
+
startEmitted: boolean;
|
|
2839
|
+
endEmitted: boolean;
|
|
2840
|
+
};
|
|
2557
2841
|
/** Convert a Zod schema to JSON Schema. Exported for Studio tool introspection.
|
|
2558
2842
|
* Wraps Zod v4's built-in `z.toJSONSchema()`, stripping the `$schema` key
|
|
2559
2843
|
* since tool parameter schemas are embedded objects, not standalone documents.
|
|
@@ -2599,6 +2883,15 @@ type BudgetContextState = {
|
|
|
2599
2883
|
/** Dedup guard so the unpriced warning fires at most once per budget block. */
|
|
2600
2884
|
unpricedWarned: boolean;
|
|
2601
2885
|
};
|
|
2886
|
+
/** Structured host signal emitted when approval compensation cannot remove a
|
|
2887
|
+
* persisted pending request. This is deliberately a runtime event rather than
|
|
2888
|
+
* an `AxlEvent`: it describes control-plane store health, not workflow work. */
|
|
2889
|
+
type DecisionCleanupFailedEvent = {
|
|
2890
|
+
executionId: string;
|
|
2891
|
+
workflow?: string;
|
|
2892
|
+
operation: 'resolveDecision_compensation';
|
|
2893
|
+
error: unknown;
|
|
2894
|
+
};
|
|
2602
2895
|
type WorkflowContextInit = {
|
|
2603
2896
|
input: unknown;
|
|
2604
2897
|
executionId: string;
|
|
@@ -2607,17 +2900,10 @@ type WorkflowContextInit = {
|
|
|
2607
2900
|
providerRegistry: ProviderRegistry;
|
|
2608
2901
|
sessionHistory?: ChatMessage[];
|
|
2609
2902
|
onTrace?: (event: AxlEvent) => void;
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
*
|
|
2613
|
-
|
|
2614
|
-
/** Pre-execution tool-call callback. `meta` carries the ask correlation. */
|
|
2615
|
-
onToolCall?: (call: {
|
|
2616
|
-
name: string;
|
|
2617
|
-
args: unknown;
|
|
2618
|
-
callId?: string;
|
|
2619
|
-
}, meta: CallbackMeta) => void;
|
|
2620
|
-
pendingDecisions?: Map<string, (d: HumanDecision) => void>;
|
|
2903
|
+
pendingDecisions?: Map<string, PendingDecisionResolver>;
|
|
2904
|
+
/** Internal: root-shared guard because pending decisions are currently
|
|
2905
|
+
* keyed by executionId rather than requestId. */
|
|
2906
|
+
awaitHumanClaims?: Map<string, AbortController>;
|
|
2621
2907
|
budgetContext?: BudgetContextState;
|
|
2622
2908
|
stateStore?: StateStore;
|
|
2623
2909
|
signal?: AbortSignal;
|
|
@@ -2627,19 +2913,14 @@ type WorkflowContextInit = {
|
|
|
2627
2913
|
spanManager?: SpanManager;
|
|
2628
2914
|
/** MemoryManager for ctx.remember() / ctx.recall() operations. */
|
|
2629
2915
|
memoryManager?: MemoryManager;
|
|
2630
|
-
/** When true, the context replays from checkpoints before executing. */
|
|
2631
|
-
resumeMode?: boolean;
|
|
2632
2916
|
/** Override tool handlers by name. Bypasses normal tool lookup in executeAgentCall. */
|
|
2633
2917
|
toolOverrides?: Map<string, (args: unknown) => Promise<unknown>>;
|
|
2634
2918
|
/** Handler for awaitHuman — when set, returns immediately instead of waiting for pendingDecisions. */
|
|
2635
2919
|
awaitHumanHandler?: (options: AwaitHumanOptions) => HumanDecision | Promise<HumanDecision>;
|
|
2636
|
-
/** Callback fired when an agent LLM call is about to start. */
|
|
2637
|
-
onAgentStart?: (info: {
|
|
2638
|
-
agent: string;
|
|
2639
|
-
model: string;
|
|
2640
|
-
}, meta: CallbackMeta) => void;
|
|
2641
2920
|
/** Callback fired after each ctx.ask() completes (once per ask invocation). */
|
|
2642
2921
|
onAgentCallComplete?: (call: AgentCallInfo) => void;
|
|
2922
|
+
/** Internal: reports approval compensation failures to the owning runtime. */
|
|
2923
|
+
_onDecisionCleanupFailed?: (event: DecisionCleanupFailedEvent) => void;
|
|
2643
2924
|
/** Options for the lazy `ctx.events` `AxlEventBus`. Forwarded by
|
|
2644
2925
|
* `runtime.createContext({ events })` / `runtime.execute(name, input,
|
|
2645
2926
|
* { events })` / `runtime.stream(name, input, { events })`. If unset,
|
|
@@ -2656,6 +2937,9 @@ type WorkflowContextInit = {
|
|
|
2656
2937
|
_busRef?: {
|
|
2657
2938
|
current: AxlEventBus | undefined;
|
|
2658
2939
|
};
|
|
2940
|
+
/** Internal: force provider streaming for runtime.stream(). Inherited by
|
|
2941
|
+
* child contexts. */
|
|
2942
|
+
_forceStreaming?: boolean;
|
|
2659
2943
|
/** Internal: shared auto-checkpoint counters. Set by `createChildContext`
|
|
2660
2944
|
* so parent + child share the same number space, preventing checkpoint
|
|
2661
2945
|
* store key collisions across nested `WorkflowContext` instances.
|
|
@@ -2673,6 +2957,31 @@ type WorkflowContextInit = {
|
|
|
2673
2957
|
byAgent: Map<string, number>;
|
|
2674
2958
|
root: number;
|
|
2675
2959
|
};
|
|
2960
|
+
/** Internal: root-shared state for branch continuations that must settle
|
|
2961
|
+
* before the runtime emits the workflow terminal and snapshots cost. */
|
|
2962
|
+
branchDrainState?: BranchDrainState;
|
|
2963
|
+
/** Internal: root-shared lifecycle state. Prevents child contexts from
|
|
2964
|
+
* emitting trace events after the workflow terminal. */
|
|
2965
|
+
workflowLifecycleState?: WorkflowLifecycleState;
|
|
2966
|
+
/** Runtime terminal barrier for abort-ignoring race/quorum branches. */
|
|
2967
|
+
branchDrainTimeoutMs?: number;
|
|
2968
|
+
};
|
|
2969
|
+
/** @internal Coordination gate shared between WorkflowContext and AxlRuntime. */
|
|
2970
|
+
type PendingDecisionResolver = {
|
|
2971
|
+
resolve: (decision: HumanDecision) => void;
|
|
2972
|
+
ready: Promise<void>;
|
|
2973
|
+
state: 'preparing' | 'pending' | 'resolving' | 'resolved' | 'failed';
|
|
2974
|
+
/** Set synchronously by the abort listener so no new public resolution can
|
|
2975
|
+
* claim the request while cleanup remains discoverable to deleteExecution. */
|
|
2976
|
+
cancelled: boolean;
|
|
2977
|
+
/** Present while runtime.resolveDecision owns the durable store mutation.
|
|
2978
|
+
* Cancellation waits for this result before deciding whether compensation
|
|
2979
|
+
* is still needed, so custom stores never receive contradictory writes in
|
|
2980
|
+
* parallel for the same request. */
|
|
2981
|
+
resolution?: Promise<boolean>;
|
|
2982
|
+
/** Resolves after cancellation compensation and resolver cleanup finish.
|
|
2983
|
+
* deleteExecution joins this barrier before its total store sweep. */
|
|
2984
|
+
cleanupFinished: Promise<void>;
|
|
2676
2985
|
};
|
|
2677
2986
|
/**
|
|
2678
2987
|
* The central coordination object for all Axl primitives.
|
|
@@ -2692,9 +3001,8 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2692
3001
|
private providerRegistry;
|
|
2693
3002
|
private sessionHistory;
|
|
2694
3003
|
private onTrace?;
|
|
2695
|
-
private onToken?;
|
|
2696
|
-
private onToolCall?;
|
|
2697
3004
|
private pendingDecisions?;
|
|
3005
|
+
private readonly awaitHumanClaims;
|
|
2698
3006
|
private budgetContext?;
|
|
2699
3007
|
private stateStore?;
|
|
2700
3008
|
/** Root step counter for this execution. Inherited by every ctx.ask()
|
|
@@ -2715,27 +3023,27 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2715
3023
|
* the caller-supplied key.
|
|
2716
3024
|
*/
|
|
2717
3025
|
private autoCheckpointCounters;
|
|
2718
|
-
|
|
3026
|
+
private readonly branchDrainState;
|
|
3027
|
+
/** Root-shared idempotency guards for workflow lifecycle emission.
|
|
2719
3028
|
* Both `runtime.execute()` and `runtime.stream()` have paths where a
|
|
2720
3029
|
* post-emit side-effect (checkpoint deletion, state-store persistence)
|
|
2721
3030
|
* can throw AFTER `_emitWorkflowEnd({status: 'completed'})` has already
|
|
2722
3031
|
* fired — the outer catch would then fire `_emitWorkflowEnd({status:
|
|
2723
3032
|
* 'failed'})` for a second time. These flags make both emitters
|
|
2724
3033
|
* single-fire so consumers never see paired-then-conflicting terminal
|
|
2725
|
-
* events for one execution.
|
|
2726
|
-
|
|
2727
|
-
private
|
|
3034
|
+
* events for one execution. Sharing the state with child contexts also
|
|
3035
|
+
* suppresses late branch events after bounded finalization. */
|
|
3036
|
+
private readonly workflowLifecycleState;
|
|
2728
3037
|
private signal?;
|
|
2729
3038
|
private summaryCache?;
|
|
2730
3039
|
private workflowName?;
|
|
2731
3040
|
private mcpManager?;
|
|
2732
3041
|
private spanManager?;
|
|
2733
3042
|
private memoryManager?;
|
|
2734
|
-
private resumeMode;
|
|
2735
3043
|
private toolOverrides?;
|
|
2736
3044
|
private awaitHumanHandler?;
|
|
2737
|
-
private onAgentStart?;
|
|
2738
3045
|
private onAgentCallComplete?;
|
|
3046
|
+
private _onDecisionCleanupFailed?;
|
|
2739
3047
|
/** Shared mutable slot for the lazy `AxlEventBus`. The slot is shared
|
|
2740
3048
|
* by reference across parent/child contexts so a late allocation
|
|
2741
3049
|
* (consumer subscribes after a child context exists) is visible
|
|
@@ -2744,6 +3052,7 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2744
3052
|
* contexts that never observe). */
|
|
2745
3053
|
private readonly _busRef;
|
|
2746
3054
|
private readonly _eventStreamOptions?;
|
|
3055
|
+
private readonly _forceStreaming;
|
|
2747
3056
|
/** Removes the constructor-registered `'abort'` listener from
|
|
2748
3057
|
* `this.signal` so a long-lived signal (e.g., a request-scoped or
|
|
2749
3058
|
* process-wide signal reused across many `runtime.createContext()` /
|
|
@@ -2763,8 +3072,7 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2763
3072
|
* *between* asks. `ctx.events.partialObjects` is the coalescing view
|
|
2764
3073
|
* designed for streaming-structured-output UIs.
|
|
2765
3074
|
* - **Ad-hoc contexts** from `runtime.createContext()`: the same
|
|
2766
|
-
* iterable
|
|
2767
|
-
* `onAgentStart` callbacks.
|
|
3075
|
+
* iterable provides typed per-context observation.
|
|
2768
3076
|
* - **Cross-execution**: prefer `runtime.on('trace', …)` instead — that
|
|
2769
3077
|
* fans out across all executions, while `ctx.events` is per-context.
|
|
2770
3078
|
*
|
|
@@ -2779,9 +3087,9 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2779
3087
|
*
|
|
2780
3088
|
* **Subscribe before the first `ctx.ask()`.** The streaming code
|
|
2781
3089
|
* path inside `ctx.ask()` activates only when an observer is
|
|
2782
|
-
* present at the time the ask starts (`_streamingEnabled` —
|
|
2783
|
-
*
|
|
2784
|
-
*
|
|
3090
|
+
* present at the time the ask starts (`_streamingEnabled` — an explicit
|
|
3091
|
+
* runtime streaming mode or allocated `ctx.events`). If you allocate
|
|
3092
|
+
* `ctx.events` AFTER a `ctx.ask()` has
|
|
2785
3093
|
* begun, that in-flight ask will not stream `token` /
|
|
2786
3094
|
* `partial_object` events at all (the agent loop went through
|
|
2787
3095
|
* `provider.chat` instead of `provider.stream`). Subsequent asks
|
|
@@ -2809,11 +3117,9 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2809
3117
|
* long-lived `signal` reused across many ad-hoc contexts doesn't
|
|
2810
3118
|
* accumulate listeners. */
|
|
2811
3119
|
disposeEvents(): void;
|
|
2812
|
-
/** True
|
|
2813
|
-
*
|
|
2814
|
-
*
|
|
2815
|
-
* been allocated (a workflow-handler consumer subscribed before
|
|
2816
|
-
* the ask). `ctx.ask` reads this to decide whether to enter the
|
|
3120
|
+
/** True when asks should use provider streaming: `runtime.stream()` set an
|
|
3121
|
+
* explicit internal mode or `ctx.events` has been allocated. `ctx.ask`
|
|
3122
|
+
* reads this to decide whether to enter the
|
|
2817
3123
|
* streaming code path; the gate is re-checked per ask, so a
|
|
2818
3124
|
* consumer subscribing AFTER the first ask started still gets
|
|
2819
3125
|
* streaming on the next one. The check `_busRef.current !== undefined`
|
|
@@ -2825,16 +3131,9 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2825
3131
|
* Create a child context for nested agent invocations (e.g., agent-as-tool).
|
|
2826
3132
|
* Shares: budget tracking, abort signals, trace emission, provider registry,
|
|
2827
3133
|
* state store, span manager, memory manager, MCP manager, config,
|
|
2828
|
-
* awaitHuman handler, pending decisions, tool overrides,
|
|
2829
|
-
* streaming callbacks (onToken / onAgentStart / onToolCall).
|
|
3134
|
+
* awaitHuman handler, pending decisions, tool overrides, and event bus.
|
|
2830
3135
|
* Isolates: session history.
|
|
2831
3136
|
*
|
|
2832
|
-
* Streaming callbacks now propagate into nested asks because every callback
|
|
2833
|
-
* invocation carries `meta.askId`/`meta.parentAskId`/`meta.depth` so
|
|
2834
|
-
* consumers that want root-only behavior can filter on `meta.depth === 0`
|
|
2835
|
-
* instead of relying on the runtime to drop nested events. This is the
|
|
2836
|
-
* "nested ask visibility" fix from spec §3.2.
|
|
2837
|
-
*
|
|
2838
3137
|
* The shared step counter lives in `askStorage` (ALS), so there is no
|
|
2839
3138
|
* per-context counter to pass through anymore. Nested events are
|
|
2840
3139
|
* correlated to their parent via `parentAskId` (set on every nested ask
|
|
@@ -2848,18 +3147,15 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2848
3147
|
* take priority over the instance-level signal.
|
|
2849
3148
|
*/
|
|
2850
3149
|
private get currentSignal();
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
*
|
|
2854
|
-
*
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
*
|
|
2858
|
-
*
|
|
2859
|
-
|
|
2860
|
-
* and can ignore those events.
|
|
2861
|
-
*/
|
|
2862
|
-
private currentCallbackMeta;
|
|
3150
|
+
private _registerBranchDrain;
|
|
3151
|
+
/** Wait for race/quorum losers (including nested branch work) to settle.
|
|
3152
|
+
* Primitive calls still resolve as soon as their winner/quorum is known;
|
|
3153
|
+
* this is only the runtime's terminal/persistence barrier. */
|
|
3154
|
+
_drainBranchWork(): Promise<ObservationStatus>;
|
|
3155
|
+
/** Resolve, execute, and observe one non-handoff tool request. Rejections
|
|
3156
|
+
* never start. Every accepted request emits one terminal event before a
|
|
3157
|
+
* continuation message or abort escapes this coordinator. */
|
|
3158
|
+
private observeToolInvocation;
|
|
2863
3159
|
ask<T = string>(agent: Agent, prompt: string, options?: AskOptions<T>): Promise<T>;
|
|
2864
3160
|
private executeAgentCall;
|
|
2865
3161
|
/**
|
|
@@ -2895,12 +3191,12 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
2895
3191
|
* Execute a function with checkpoint-replay semantics.
|
|
2896
3192
|
*
|
|
2897
3193
|
* On first execution, runs `fn()`, saves the result under `name`, and
|
|
2898
|
-
* returns it.
|
|
2899
|
-
* without re-executing.
|
|
2900
|
-
*
|
|
3194
|
+
* returns it. A later evaluation in the same explicit execution scope
|
|
3195
|
+
* returns the saved result without re-executing. Axl does not restart or
|
|
3196
|
+
* resume workflow continuations across processes.
|
|
2901
3197
|
*
|
|
2902
3198
|
* `name` must be a stable, caller-supplied identifier — the same call
|
|
2903
|
-
* site MUST pass the same name across
|
|
3199
|
+
* site MUST pass the same name across evaluations of the same execution for
|
|
2904
3200
|
* replay to work. Names are scoped to a single execution and must be
|
|
2905
3201
|
* unique within it; reusing a name (e.g. inside a loop) gives
|
|
2906
3202
|
* last-write-wins behavior. For loops, compose names from the iterator:
|
|
@@ -3015,6 +3311,7 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
3015
3311
|
result?: unknown;
|
|
3016
3312
|
error?: string;
|
|
3017
3313
|
aborted?: boolean;
|
|
3314
|
+
observation?: ObservationStatus;
|
|
3018
3315
|
}): void;
|
|
3019
3316
|
log(event: string, data?: unknown): void;
|
|
3020
3317
|
/**
|
|
@@ -3066,6 +3363,10 @@ type ToolHooks<TInput = unknown, TOutput = unknown> = {
|
|
|
3066
3363
|
/** Transform output after the handler runs. Receives handler result and workflow context. */
|
|
3067
3364
|
after?(output: TOutput, ctx: WorkflowContext): TOutput | Promise<TOutput>;
|
|
3068
3365
|
};
|
|
3366
|
+
/** JSON-compatible content that a tool may explicitly expose to the model. */
|
|
3367
|
+
type ToolModelOutput = string | number | boolean | null | readonly ToolModelOutput[] | {
|
|
3368
|
+
readonly [key: string]: ToolModelOutput | undefined;
|
|
3369
|
+
};
|
|
3069
3370
|
/** Tool configuration */
|
|
3070
3371
|
type ToolConfig<TInput extends z.ZodType, TOutput = unknown> = {
|
|
3071
3372
|
name: string;
|
|
@@ -3080,6 +3381,8 @@ type ToolConfig<TInput extends z.ZodType, TOutput = unknown> = {
|
|
|
3080
3381
|
requireApproval?: boolean;
|
|
3081
3382
|
/** Lifecycle hooks: before/after the handler. */
|
|
3082
3383
|
hooks?: ToolHooks<z.infer<TInput>, TOutput>;
|
|
3384
|
+
/** Select the subset of a successful result that is sent back to the model. */
|
|
3385
|
+
toModelOutput?(this: void, output: Readonly<TOutput>): ToolModelOutput;
|
|
3083
3386
|
};
|
|
3084
3387
|
/** A defined tool instance */
|
|
3085
3388
|
type Tool<TInput extends z.ZodType = z.ZodType, TOutput = unknown> = {
|
|
@@ -3090,6 +3393,8 @@ type Tool<TInput extends z.ZodType = z.ZodType, TOutput = unknown> = {
|
|
|
3090
3393
|
readonly retry: RetryPolicy;
|
|
3091
3394
|
readonly requireApproval: boolean;
|
|
3092
3395
|
readonly hooks?: ToolHooks<z.infer<TInput>, TOutput>;
|
|
3396
|
+
/** Select the subset of a successful result that is sent back to the model. */
|
|
3397
|
+
toModelOutput?(this: void, output: Readonly<TOutput>): ToolModelOutput;
|
|
3093
3398
|
/** Run the tool directly from workflow code */
|
|
3094
3399
|
run(ctx: WorkflowContext, input: z.infer<TInput>): Promise<TOutput>;
|
|
3095
3400
|
/** Execute the handler (internal use — includes retry logic) */
|
|
@@ -3202,6 +3507,9 @@ declare class AxlStream extends Readable implements AsyncIterable<AxlEvent> {
|
|
|
3202
3507
|
text: string;
|
|
3203
3508
|
}>;
|
|
3204
3509
|
get lifecycle(): AsyncIterable<AxlEvent>;
|
|
3510
|
+
/** Completeness of this stream's iterator queue. Check after consumption
|
|
3511
|
+
* before treating an unmatched lifecycle event as a producer defect. */
|
|
3512
|
+
get observationStatus(): ObservationStatus;
|
|
3205
3513
|
/** Coalescing iterator over `partial_object` events — yields the latest
|
|
3206
3514
|
* object payload per `askId`. Designed for streaming-structured-output
|
|
3207
3515
|
* UIs: when the producer outpaces the consumer, intermediate snapshots
|
|
@@ -3375,6 +3683,9 @@ type ExecuteOptions = {
|
|
|
3375
3683
|
* defaults are `maxQueued: 10_000` and `onOverflow:
|
|
3376
3684
|
* 'drop-oldest-non-terminal'`. */
|
|
3377
3685
|
events?: EventStreamOptions;
|
|
3686
|
+
/** Maximum terminal wait for abort-ignoring race/quorum branches. Once
|
|
3687
|
+
* exceeded, finalization proceeds with observation.complete=false. */
|
|
3688
|
+
branchDrainTimeoutMs?: number;
|
|
3378
3689
|
};
|
|
3379
3690
|
/**
|
|
3380
3691
|
* Shape of events forwarded to an eval `onProgress` callback. Mirrors
|
|
@@ -3418,23 +3729,6 @@ type CreateContextOptions = {
|
|
|
3418
3729
|
signal?: AbortSignal;
|
|
3419
3730
|
/** Prior conversation history for multi-turn eval testing. */
|
|
3420
3731
|
sessionHistory?: ChatMessage[];
|
|
3421
|
-
/** Token streaming callback. `meta` carries `askId`/`parentAskId`/`depth`/`agent`
|
|
3422
|
-
* so consumers can route or filter by ask correlation (e.g.,
|
|
3423
|
-
* `meta.depth === 0` for root-only chat UIs). */
|
|
3424
|
-
onToken?: (token: string, meta: CallbackMeta) => void;
|
|
3425
|
-
/** Fires when an agent invokes a tool. `meta` carries the same ask
|
|
3426
|
-
* correlation shape as `onToken`. */
|
|
3427
|
-
onToolCall?: (call: {
|
|
3428
|
-
name: string;
|
|
3429
|
-
args: unknown;
|
|
3430
|
-
callId?: string;
|
|
3431
|
-
}, meta: CallbackMeta) => void;
|
|
3432
|
-
/** Fires when an agent begins processing a turn. `meta` carries the
|
|
3433
|
-
* same ask correlation shape as `onToken`. */
|
|
3434
|
-
onAgentStart?: (info: {
|
|
3435
|
-
agent: string;
|
|
3436
|
-
model?: string;
|
|
3437
|
-
}, meta: CallbackMeta) => void;
|
|
3438
3732
|
/** Handler for tool approval requests. Called when an agent invokes a tool with requireApproval. */
|
|
3439
3733
|
awaitHumanHandler?: (options: AwaitHumanOptions) => Promise<HumanDecision>;
|
|
3440
3734
|
/** Configuration for the lazy `ctx.events` bus on the returned context.
|
|
@@ -3539,9 +3833,7 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3539
3833
|
* → parse output → emit `workflow_end` → delete checkpoints → persist.
|
|
3540
3834
|
*
|
|
3541
3835
|
* Shared between `execute()` and `stream()`. Centralizes the
|
|
3542
|
-
* "start iff end" pairing invariant
|
|
3543
|
-
* (e.g., `resumeExecution`) can inherit correct behavior by routing
|
|
3544
|
-
* through this helper. Also factors out the AbortError detection.
|
|
3836
|
+
* "start iff end" pairing invariant and AbortError detection.
|
|
3545
3837
|
*
|
|
3546
3838
|
* Side effects on `execInfo`: sets `status` / `completedAt` /
|
|
3547
3839
|
* `duration` / `result` (or `error`) before emitting `workflow_end`.
|
|
@@ -3631,15 +3923,15 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3631
3923
|
captureTraces?: boolean;
|
|
3632
3924
|
}): Promise<unknown>;
|
|
3633
3925
|
/** Get all execution info (running + completed + historical). */
|
|
3634
|
-
/** Normalize an
|
|
3635
|
-
*
|
|
3926
|
+
/** Normalize an execution loaded from a `StateStore` so the
|
|
3927
|
+
* historical event union holds for downstream consumers
|
|
3636
3928
|
* (Studio aggregators, REST routes, redaction). Custom or legacy stores
|
|
3637
3929
|
* may persist rows without `events` (or with a non-array value) — without
|
|
3638
3930
|
* this guard, a single malformed row crashes every iterator over
|
|
3639
|
-
* `exec.events` and takes down dependent features.
|
|
3640
|
-
*
|
|
3931
|
+
* `exec.events` and takes down dependent features. Returns a normalized
|
|
3932
|
+
* copy; logs at most one warning per `executionId`. */
|
|
3641
3933
|
private normalizeStoredExecution;
|
|
3642
|
-
getExecutions(): Promise<
|
|
3934
|
+
getExecutions(): Promise<HistoricalExecutionInfo[]>;
|
|
3643
3935
|
/**
|
|
3644
3936
|
* Create a WorkflowContext for ad-hoc use (evals, tool testing, prototyping).
|
|
3645
3937
|
* The context has access to the runtime's providers, state store, MCP manager,
|
|
@@ -3700,11 +3992,11 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3700
3992
|
* finalize. The implementation checks the historical store before
|
|
3701
3993
|
* synthesizing, so a re-run is safe.
|
|
3702
3994
|
*/
|
|
3703
|
-
recoverIncompleteStreams(): Promise<
|
|
3995
|
+
recoverIncompleteStreams(): Promise<HistoricalExecutionInfo[]>;
|
|
3704
3996
|
/** Abort a running execution by its ID. */
|
|
3705
3997
|
abort(executionId: string): void;
|
|
3706
3998
|
/** Get execution details by ID. */
|
|
3707
|
-
getExecution(executionId: string): Promise<
|
|
3999
|
+
getExecution(executionId: string): Promise<HistoricalExecutionInfo | undefined>;
|
|
3708
4000
|
/** Save an eval result to history. */
|
|
3709
4001
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
3710
4002
|
/**
|
|
@@ -3759,18 +4051,6 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
3759
4051
|
getPendingDecisions(): Promise<PendingDecision[]>;
|
|
3760
4052
|
/** Resolve a pending human decision. */
|
|
3761
4053
|
resolveDecision(executionId: string, decision: HumanDecision): Promise<void>;
|
|
3762
|
-
/**
|
|
3763
|
-
* Resume a specific execution that was waiting for a human decision.
|
|
3764
|
-
* Re-runs the workflow from scratch; the workflow should use checkpoint-replay
|
|
3765
|
-
* to skip already-completed steps and pick up from the awaitHuman point.
|
|
3766
|
-
*/
|
|
3767
|
-
resumeExecution(executionId: string): Promise<unknown>;
|
|
3768
|
-
/**
|
|
3769
|
-
* Resume all pending executions that were waiting for human decisions.
|
|
3770
|
-
* Call this on startup to resume workflows that were interrupted by a restart.
|
|
3771
|
-
* Returns the execution IDs that were resumed.
|
|
3772
|
-
*/
|
|
3773
|
-
resumePending(): Promise<string[]>;
|
|
3774
4054
|
/**
|
|
3775
4055
|
* Summarize a list of chat messages into a concise summary string.
|
|
3776
4056
|
* Used by Session to summarize dropped messages when history.summarize is enabled.
|
|
@@ -4207,7 +4487,7 @@ declare function isUsableCost(cost: unknown): cost is number;
|
|
|
4207
4487
|
* `ask_end.cost` directly — that field is populated whether or not
|
|
4208
4488
|
* the leaf events were summed separately. Spec decision 10.
|
|
4209
4489
|
*/
|
|
4210
|
-
declare function eventCostContribution(event:
|
|
4490
|
+
declare function eventCostContribution(event: HistoricalAxlEvent): number;
|
|
4211
4491
|
/**
|
|
4212
4492
|
* True when the event is a cost-bearing leaf (contributes directly to
|
|
4213
4493
|
* totals) — used by internal emitters that need to know whether to
|
|
@@ -4217,7 +4497,7 @@ declare function eventCostContribution(event: AxlEvent): number;
|
|
|
4217
4497
|
* with `cost: 0` is still a leaf (produced by a free / cached turn),
|
|
4218
4498
|
* just one that happens to contribute zero.
|
|
4219
4499
|
*/
|
|
4220
|
-
declare function isCostBearingLeaf(event:
|
|
4500
|
+
declare function isCostBearingLeaf(event: HistoricalAxlEvent): boolean;
|
|
4221
4501
|
/**
|
|
4222
4502
|
* True when the event is the "unpriced lower-bound" signal: a cost-bearing leaf
|
|
4223
4503
|
* that did measurable, billable work (POSITIVE tokens) but produced no usable
|
|
@@ -4257,7 +4537,7 @@ declare function isUnpricedLeaf(event: {
|
|
|
4257
4537
|
* (out-of-ask lifecycle events, synthesized terminals) are treated
|
|
4258
4538
|
* as root-level — they're never at depth ≥ 1.
|
|
4259
4539
|
*/
|
|
4260
|
-
declare function isRootLevel(event:
|
|
4540
|
+
declare function isRootLevel(event: HistoricalAxlEvent): boolean;
|
|
4261
4541
|
|
|
4262
4542
|
/**
|
|
4263
4543
|
* Tolerant JSON parser for progressive structured-output streaming.
|
|
@@ -4291,6 +4571,25 @@ declare function isRootLevel(event: AxlEvent): boolean;
|
|
|
4291
4571
|
/** Parse a JSON-shaped string that may be truncated mid-stream. */
|
|
4292
4572
|
declare function parsePartialJson(input: string): unknown;
|
|
4293
4573
|
|
|
4574
|
+
declare class UnsupportedEventSchemaVersionError extends Error {
|
|
4575
|
+
readonly version: unknown;
|
|
4576
|
+
constructor(version: unknown);
|
|
4577
|
+
}
|
|
4578
|
+
/** Missing event metadata is the documented v1 sentinel. */
|
|
4579
|
+
declare function getEventSchemaVersion(event: {
|
|
4580
|
+
schemaVersion?: unknown;
|
|
4581
|
+
}): 1 | 2;
|
|
4582
|
+
/** Missing execution metadata is the documented v1 sentinel. */
|
|
4583
|
+
declare function getExecutionEventSchemaVersion(execution: {
|
|
4584
|
+
eventSchemaVersion?: unknown;
|
|
4585
|
+
}): 1 | 2;
|
|
4586
|
+
/**
|
|
4587
|
+
* Normalize one state-store row without reinterpreting event payloads.
|
|
4588
|
+
* Every event must agree with the execution carrier; mixed-version traces fail
|
|
4589
|
+
* loudly instead of being guessed into either reducer.
|
|
4590
|
+
*/
|
|
4591
|
+
declare function normalizeStoredExecution(execution: HistoricalExecutionInfo): HistoricalExecutionInfo;
|
|
4592
|
+
|
|
4294
4593
|
/**
|
|
4295
4594
|
* Per-variant redaction rules for `AxlEvent`.
|
|
4296
4595
|
*
|
|
@@ -4325,88 +4624,52 @@ declare function parsePartialJson(input: string): unknown;
|
|
|
4325
4624
|
*/
|
|
4326
4625
|
|
|
4327
4626
|
declare const REDACTED = "[redacted]";
|
|
4328
|
-
/** Type-safe rule signature: takes a specific event variant, returns the same variant. */
|
|
4329
4627
|
type RuleFor<T extends AxlEventType> = (event: AxlEventOf<T>) => AxlEventOf<T>;
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
*
|
|
4338
|
-
* silent omission.
|
|
4339
|
-
*/
|
|
4628
|
+
type V2ToolEventType = ToolLifecycleEventV2['type'];
|
|
4629
|
+
type V2ToolRule<T extends V2ToolEventType> = (event: Extract<ToolLifecycleEventV2, {
|
|
4630
|
+
type: T;
|
|
4631
|
+
}>) => Extract<ToolLifecycleEventV2, {
|
|
4632
|
+
type: T;
|
|
4633
|
+
}>;
|
|
4634
|
+
/** Current-writer redaction rules. The mapped type makes every live event
|
|
4635
|
+
* discriminator an explicit compile-time redaction decision. */
|
|
4340
4636
|
declare const REDACTION_RULES: {
|
|
4341
|
-
|
|
4637
|
+
tool_call_start: V2ToolRule<"tool_call_start">;
|
|
4638
|
+
tool_call_end: V2ToolRule<"tool_call_end">;
|
|
4639
|
+
tool_call_rejected: V2ToolRule<"tool_call_rejected">;
|
|
4640
|
+
workflow_start: RuleFor<"workflow_start">;
|
|
4641
|
+
workflow_end: RuleFor<"workflow_end">;
|
|
4642
|
+
ask_start: RuleFor<"ask_start">;
|
|
4643
|
+
ask_end: RuleFor<"ask_end">;
|
|
4644
|
+
agent_call_start: RuleFor<"agent_call_start">;
|
|
4645
|
+
agent_call_end: RuleFor<"agent_call_end">;
|
|
4646
|
+
token: RuleFor<"token">;
|
|
4647
|
+
tool_approval: RuleFor<"tool_approval">;
|
|
4648
|
+
delegate: RuleFor<"delegate">;
|
|
4649
|
+
handoff_start: RuleFor<"handoff_start">;
|
|
4650
|
+
handoff_return: RuleFor<"handoff_return">;
|
|
4651
|
+
pipeline: RuleFor<"pipeline">;
|
|
4652
|
+
partial_object: RuleFor<"partial_object">;
|
|
4653
|
+
string_delta: RuleFor<"string_delta">;
|
|
4654
|
+
verify: RuleFor<"verify">;
|
|
4655
|
+
schema_diagnostic: RuleFor<"schema_diagnostic">;
|
|
4656
|
+
log: RuleFor<"log">;
|
|
4657
|
+
memory_remember: RuleFor<"memory_remember">;
|
|
4658
|
+
memory_recall: RuleFor<"memory_recall">;
|
|
4659
|
+
memory_forget: RuleFor<"memory_forget">;
|
|
4660
|
+
checkpoint_save: RuleFor<"checkpoint_save">;
|
|
4661
|
+
checkpoint_replay: RuleFor<"checkpoint_replay">;
|
|
4662
|
+
await_human: RuleFor<"await_human">;
|
|
4663
|
+
await_human_resolved: RuleFor<"await_human_resolved">;
|
|
4664
|
+
guardrail: RuleFor<"guardrail">;
|
|
4665
|
+
schema_check: RuleFor<"schema_check">;
|
|
4666
|
+
validate: RuleFor<"validate">;
|
|
4667
|
+
done: RuleFor<"done">;
|
|
4668
|
+
error: RuleFor<"error">;
|
|
4342
4669
|
};
|
|
4343
|
-
/**
|
|
4344
|
-
* Apply the redaction rule for `event.type` and return a new event with
|
|
4345
|
-
* user-content fields scrubbed. Pure: never mutates the input.
|
|
4346
|
-
*
|
|
4347
|
-
* Caller responsibility: only invoke when redaction is enabled. The rules
|
|
4348
|
-
* unconditionally scrub — they don't gate on `config.trace.redact`. Both
|
|
4349
|
-
* `WorkflowContext.emitEvent` (core) and `redactStreamEvent` (Studio)
|
|
4350
|
-
* check the flag before calling this function.
|
|
4351
|
-
*/
|
|
4352
4670
|
declare function redactEvent(event: AxlEvent): AxlEvent;
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
declare class AxlError extends Error {
|
|
4356
|
-
readonly code: string;
|
|
4357
|
-
constructor(code: string, message: string);
|
|
4358
|
-
}
|
|
4359
|
-
/** Thrown when schema validation fails after all retries exhausted */
|
|
4360
|
-
declare class VerifyError extends AxlError {
|
|
4361
|
-
readonly lastOutput: unknown;
|
|
4362
|
-
readonly zodError: ZodError;
|
|
4363
|
-
readonly retries: number;
|
|
4364
|
-
constructor(lastOutput: unknown, zodError: ZodError, retries: number);
|
|
4365
|
-
}
|
|
4366
|
-
/** Thrown when quorum is not met in spawn */
|
|
4367
|
-
declare class QuorumNotMet extends AxlError {
|
|
4368
|
-
readonly results: Result<unknown>[];
|
|
4369
|
-
constructor(required: number, actual: number, results: Result<unknown>[]);
|
|
4370
|
-
}
|
|
4371
|
-
/** Thrown when vote cannot reach consensus */
|
|
4372
|
-
declare class NoConsensus extends AxlError {
|
|
4373
|
-
constructor(reason: string);
|
|
4374
|
-
}
|
|
4375
|
-
/** Thrown when an operation exceeds its timeout */
|
|
4376
|
-
declare class TimeoutError extends AxlError {
|
|
4377
|
-
constructor(operation: string, timeoutMs: number);
|
|
4378
|
-
}
|
|
4379
|
-
/** Thrown when a budget limit is exceeded */
|
|
4380
|
-
declare class BudgetExceededError extends AxlError {
|
|
4381
|
-
readonly limit: number;
|
|
4382
|
-
readonly spent: number;
|
|
4383
|
-
readonly policy: string;
|
|
4384
|
-
constructor(limit: number, spent: number, policy: string);
|
|
4385
|
-
}
|
|
4386
|
-
/** Thrown when an agent exceeds its maximum number of tool-calling turns */
|
|
4387
|
-
declare class MaxTurnsError extends AxlError {
|
|
4388
|
-
readonly maxTurns: number;
|
|
4389
|
-
constructor(operation: string, maxTurns: number);
|
|
4390
|
-
}
|
|
4391
|
-
/** Thrown when a guardrail blocks a request/response and the policy is 'throw'. */
|
|
4392
|
-
declare class GuardrailError extends AxlError {
|
|
4393
|
-
readonly guardrailType: 'input' | 'output';
|
|
4394
|
-
readonly reason: string;
|
|
4395
|
-
constructor(guardrailType: 'input' | 'output', reason: string);
|
|
4396
|
-
}
|
|
4397
|
-
/** Thrown when post-schema business rule validation fails after all retries exhausted */
|
|
4398
|
-
declare class ValidationError extends AxlError {
|
|
4399
|
-
readonly lastOutput: unknown;
|
|
4400
|
-
readonly reason: string;
|
|
4401
|
-
readonly retries: number;
|
|
4402
|
-
constructor(lastOutput: unknown, reason: string, retries: number);
|
|
4403
|
-
}
|
|
4404
|
-
/** Internal: thrown when an agent tries to call a tool not in its ACL */
|
|
4405
|
-
declare class ToolDenied extends AxlError {
|
|
4406
|
-
readonly toolName: string;
|
|
4407
|
-
readonly agentName: string;
|
|
4408
|
-
constructor(toolName: string, agentName: string);
|
|
4409
|
-
}
|
|
4671
|
+
/** Redact either persisted schema without reinterpreting its lifecycle. */
|
|
4672
|
+
declare function redactHistoricalEvent(event: HistoricalAxlEvent): HistoricalAxlEvent;
|
|
4410
4673
|
|
|
4411
4674
|
/**
|
|
4412
4675
|
* Typed provider errors + shared HTTP-failure classification.
|
|
@@ -4838,9 +5101,9 @@ declare class MemoryStore implements StateStore {
|
|
|
4838
5101
|
value: unknown;
|
|
4839
5102
|
}>>;
|
|
4840
5103
|
deleteMemory(scope: string, key: string): Promise<void>;
|
|
4841
|
-
saveExecution(execution:
|
|
4842
|
-
getExecution(executionId: string): Promise<
|
|
4843
|
-
listExecutions(limit?: number): Promise<
|
|
5104
|
+
saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
|
|
5105
|
+
getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
|
|
5106
|
+
listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
|
|
4844
5107
|
deleteExecution(executionId: string): Promise<boolean>;
|
|
4845
5108
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
4846
5109
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
@@ -4850,7 +5113,7 @@ declare class MemoryStore implements StateStore {
|
|
|
4850
5113
|
appendStreamingEvents(executionId: string, events: AxlEvent[]): Promise<void>;
|
|
4851
5114
|
finalizeStreamingEvents(executionId: string): Promise<void>;
|
|
4852
5115
|
listStreamingExecutions(): Promise<string[]>;
|
|
4853
|
-
getStreamingEvents(executionId: string): Promise<
|
|
5116
|
+
getStreamingEvents(executionId: string): Promise<HistoricalAxlEvent[]>;
|
|
4854
5117
|
close(): Promise<void>;
|
|
4855
5118
|
deleteCheckpoints(executionId: string): Promise<void>;
|
|
4856
5119
|
private persistAwaitHumanState;
|
|
@@ -4891,6 +5154,10 @@ declare class SQLiteStore implements StateStore {
|
|
|
4891
5154
|
* column (TEXT, nullable, JSON-serialized) so caller-supplied
|
|
4892
5155
|
* `ExecuteOptions.metadata` round-trips through history. Existing
|
|
4893
5156
|
* rows get `NULL`, deserialized as `metadata: undefined`.
|
|
5157
|
+
* - v4 (event schema): add `execution_history.event_schema_version`.
|
|
5158
|
+
* Existing rows remain `NULL`, the documented v1 sentinel.
|
|
5159
|
+
* - v5 (observation completeness): add `execution_history.observation`.
|
|
5160
|
+
* Existing rows remain `NULL`, meaning they predate the contract.
|
|
4894
5161
|
*
|
|
4895
5162
|
* Applied BEFORE `initTables()` so the subsequent `CREATE TABLE
|
|
4896
5163
|
* IF NOT EXISTS` runs against the post-migration column name. Fresh
|
|
@@ -4922,9 +5189,9 @@ declare class SQLiteStore implements StateStore {
|
|
|
4922
5189
|
saveExecutionState(executionId: string, state: ExecutionState): Promise<void>;
|
|
4923
5190
|
getExecutionState(executionId: string): Promise<ExecutionState | null>;
|
|
4924
5191
|
listPendingExecutions(): Promise<string[]>;
|
|
4925
|
-
saveExecution(execution:
|
|
4926
|
-
getExecution(executionId: string): Promise<
|
|
4927
|
-
listExecutions(limit?: number): Promise<
|
|
5192
|
+
saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
|
|
5193
|
+
getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
|
|
5194
|
+
listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
|
|
4928
5195
|
deleteExecution(executionId: string): Promise<boolean>;
|
|
4929
5196
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
4930
5197
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
@@ -5153,9 +5420,9 @@ declare class RedisStore implements StateStore {
|
|
|
5153
5420
|
value: unknown;
|
|
5154
5421
|
}>>;
|
|
5155
5422
|
deleteMemory(scope: string, key: string): Promise<void>;
|
|
5156
|
-
saveExecution(execution:
|
|
5157
|
-
getExecution(executionId: string): Promise<
|
|
5158
|
-
listExecutions(limit?: number): Promise<
|
|
5423
|
+
saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
|
|
5424
|
+
getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
|
|
5425
|
+
listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
|
|
5159
5426
|
deleteExecution(executionId: string): Promise<boolean>;
|
|
5160
5427
|
saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
|
|
5161
5428
|
listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
|
|
@@ -5172,7 +5439,7 @@ declare class RedisStore implements StateStore {
|
|
|
5172
5439
|
appendStreamingEvents(executionId: string, events: AxlEvent[]): Promise<void>;
|
|
5173
5440
|
finalizeStreamingEvents(executionId: string): Promise<void>;
|
|
5174
5441
|
listStreamingExecutions(): Promise<string[]>;
|
|
5175
|
-
getStreamingEvents(executionId: string): Promise<
|
|
5442
|
+
getStreamingEvents(executionId: string): Promise<HistoricalAxlEvent[]>;
|
|
5176
5443
|
/** Close the Redis connection. */
|
|
5177
5444
|
close(): Promise<void>;
|
|
5178
5445
|
deleteCheckpoints(executionId: string): Promise<void>;
|
|
@@ -5244,4 +5511,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
5244
5511
|
*/
|
|
5245
5512
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
5246
5513
|
|
|
5247
|
-
export { AXL_EVENT_TYPES, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type
|
|
5514
|
+
export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type AskOptions, type AskScoped, type AuthHeader, type AwaitHumanData, type AwaitHumanOptions, type AwaitHumanResolvedData, type AxlConfig, AxlError, type AxlEvent, type AxlEventBase, AxlEventBus, type AxlEventOf, type AxlEventType, type AxlEventV2, type AxlEventV2Of, AxlRuntime, AxlStream, BEDROCK_PROFILE, BUILTIN_PROFILES, BudgetExceededError, type BudgetOptions, type BudgetResult, CONFIG_CANDIDATES, COST_BEARING_LEAF_TYPES, type CapabilityFlags, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CreateContextOptions, DEEPSEEK_PROFILE, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type Effort, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, GROQ_PROFILE, GeminiProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HumanDecision, InMemoryVectorStore, type InputGuardrail, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type Provider, type ProviderAdapter, ProviderError, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, RedisStore, type RememberOptions, type RememberResult, type ResolvedThinkingOptions, type Result, type RetryPolicy, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, TimeoutError, type Tool, type ToolApprovalData, type ToolArgumentIssue, type ToolCallCancellation, type ToolCallData, type ToolCallEndData, type ToolCallFailure, type ToolCallMessage, type ToolCallOutcome, type ToolCallRejectedData, type ToolCallRejectedEvent, type ToolCallStartData, type ToolCallStartDataV2, type ToolChoice, type ToolConfig, type ToolDeniedData, type ToolEventError, ToolFailure, type ToolFailureConstructor, type ToolFailureOptions, type ToolHooks, type ToolLifecycleEventV2, type ToolModelOutput, ToolModelOutputError, UnsupportedEventSchemaVersionError, VLLM_PROFILE, type ValidateData, type ValidateResult, ValidationError, type VectorEntry, type VectorResult, type VectorStore, type VerifyData, VerifyError, type VerifyOptions, type VerifyRetry, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, type WorkflowEndData, type WorkflowStartData, XAI_PROFILE, agent, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveTokens, importModule, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, tool, workflow, zodToJsonSchema };
|