@axlsdk/axl 0.25.3 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -273,6 +273,17 @@ type ExternalOperationReport = {
273
273
  * second call.
274
274
  */
275
275
  setCost(amountUsd: number, usage?: Partial<AccountingUsage>): void;
276
+ /**
277
+ * Snapshot caller-supplied JSON evidence. Repeated calls merge the supplied
278
+ * request and response independently; omitted fields retain prior values.
279
+ * Capture is diagnostic only: invalid payloads degrade its journal record
280
+ * without changing this operation's result or charge. Outside a capturing
281
+ * accounting scope this is a safe no-op.
282
+ */
283
+ capture(payload: {
284
+ request?: unknown;
285
+ response?: unknown;
286
+ }): void;
276
287
  };
277
288
  /** Descriptor for `withExternalOperation` / {@link externalOperation}. */
278
289
  type ExternalOperationDescriptor = {
@@ -503,6 +514,14 @@ type StreamChunk = {
503
514
  arguments?: string;
504
515
  } | {
505
516
  type: 'done';
517
+ /** Provider-neutral finish reason, when the wire reports one. */
518
+ finishReason?: FinishReason;
519
+ /** Exact vendor finish reason or status used to derive `finishReason`. */
520
+ rawFinishReason?: string;
521
+ /** Response identifier reported by the provider. Never inferred from the request. */
522
+ responseId?: string;
523
+ /** Model reported in the response. Never inferred from the requested model. */
524
+ responseModel?: string;
506
525
  usage?: {
507
526
  prompt_tokens: number;
508
527
  completion_tokens: number;
@@ -1868,9 +1887,11 @@ type ExecutionInfoV1 = {
1868
1887
  * (or `runtime.stream()`'s `options.metadata`). Persisted as part of the
1869
1888
  * `ExecutionInfo` snapshot so callers have a stable, queryable surface for
1870
1889
  * tags like `userId`, `tenantId`, or correlation ids without parsing the
1871
- * event timeline. Filter via `runtime.getExecutions()` + an in-process
1872
- * `.filter()`; secondary indexes on this field are intentionally not
1873
- * provided — `StateStore` is a persistence boundary, not a query engine. */
1890
+ * event timeline. Filter in process while paging with
1891
+ * `runtime.getExecutions({ limit, cursor })` (see
1892
+ * docs/migration/execution-history-retention.md); secondary indexes on this
1893
+ * field are intentionally not provided — `StateStore` is a persistence
1894
+ * boundary, not a query engine. */
1874
1895
  metadata?: Record<string, unknown>;
1875
1896
  };
1876
1897
  /** Stored execution written before explicit event schema versioning. */
@@ -2027,11 +2048,21 @@ type CallTiming = {
2027
2048
  */
2028
2049
  wireMs: number;
2029
2050
  };
2051
+ /** Provider-neutral reason a model call ended. Unrecognized wire reasons map to `other`. */
2052
+ type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'refusal' | 'other';
2030
2053
  /** Provider response */
2031
2054
  type ProviderResponse = {
2032
2055
  content: string;
2033
2056
  thinking_content?: string;
2034
2057
  tool_calls?: ToolCallMessage[];
2058
+ /** Provider-neutral finish reason, when the wire reports a terminal reason or status. */
2059
+ finishReason?: FinishReason;
2060
+ /** Exact vendor finish reason or status used to derive `finishReason`. */
2061
+ rawFinishReason?: string;
2062
+ /** Response identifier reported by the provider. Never inferred from the request. */
2063
+ responseId?: string;
2064
+ /** Model reported in the response. Never inferred from the requested model. */
2065
+ responseModel?: string;
2035
2066
  usage?: {
2036
2067
  prompt_tokens: number;
2037
2068
  completion_tokens: number;
@@ -3762,9 +3793,10 @@ type OpenAIChatMessage = {
3762
3793
  }>;
3763
3794
  };
3764
3795
  type OpenAIChatResponse = {
3796
+ id?: string;
3765
3797
  choices: Array<{
3766
3798
  message: OpenAIChatMessage;
3767
- finish_reason: string;
3799
+ finish_reason?: string | null;
3768
3800
  }>;
3769
3801
  usage?: OpenAIUsage;
3770
3802
  } & OpenAIModelResponse;
@@ -3870,8 +3902,27 @@ interface StateStore {
3870
3902
  saveExecution?(execution: HistoricalExecutionInfo): Promise<void>;
3871
3903
  /** Get a specific execution by ID from history. */
3872
3904
  getExecution?(executionId: string): Promise<HistoricalExecutionInfo | null>;
3873
- /** List recent executions (most recent first). */
3874
- listExecutions?(limit?: number): Promise<HistoricalExecutionInfo[]>;
3905
+ /**
3906
+ * List recent executions, most recent first. The built-in stores order by
3907
+ * `startedAt` descending and break ties by `executionId` descending, so the
3908
+ * order is total and stable across calls.
3909
+ *
3910
+ * `options.cursor` asks for the page that starts strictly after that
3911
+ * position in the same order. The runtime passes it only when the store
3912
+ * sets {@link StateStore.historyPaging}; other stores are listed in full and
3913
+ * paged in process.
3914
+ */
3915
+ listExecutions?(limit?: number, options?: {
3916
+ cursor?: ExecutionCursor;
3917
+ }): Promise<HistoricalExecutionInfo[]>;
3918
+ /**
3919
+ * Set to `true` when `listExecutions` honors `options.cursor` with the
3920
+ * `(startedAt DESC, executionId DESC)` order. The built-in stores set it.
3921
+ * Leave it unset if your store ignores the cursor: the runtime then lists
3922
+ * everything and pages in process, which is correct but reads the whole
3923
+ * history on every page.
3924
+ */
3925
+ readonly historyPaging?: boolean;
3875
3926
  /**
3876
3927
  * Delete an execution from history by ID. Returns `true` if an entry was
3877
3928
  * deleted, `false` if the ID didn't exist. Used for GDPR right-to-be-
@@ -3933,8 +3984,10 @@ interface StateStore {
3933
3984
  * bytes on a timer and at startup. Physical deletion is therefore EVENTUAL,
3934
3985
  * not synchronous with the store's expiry.
3935
3986
  *
3936
- * Built-ins implement it: `MemoryStore` and `SqliteStore` never expire, so
3937
- * `expiresAt` is `undefined`; `RedisStore` reports existence and any live TTL.
3987
+ * Built-ins implement it. `MemoryStore` and `SQLiteStore` report the
3988
+ * absolute expiry they stored when `ttls.evalHistory` was configured at the
3989
+ * row's first write, and no `expiresAt` otherwise; `RedisStore` reports
3990
+ * existence and any live TTL. An expired row reports `{ exists: false }`.
3938
3991
  * A custom store WITHOUT this method cannot host managed artifact capture —
3939
3992
  * `AxlRuntime` rejects that configuration when it is constructed rather than
3940
3993
  * after a run has spent money.
@@ -3943,6 +3996,39 @@ interface StateStore {
3943
3996
  exists: boolean;
3944
3997
  expiresAt?: number;
3945
3998
  }>;
3999
+ /**
4000
+ * Apply the store's configured history retention to records that were
4001
+ * saved without one (for example before an upgrade, or before a retention
4002
+ * was set), and repair the store's listing indexes. Processes one batch and
4003
+ * returns the cursor to continue from; call again with that cursor until it
4004
+ * is `null`. Axl never calls this itself: run it when you choose to.
4005
+ *
4006
+ * For each record in the batch that has no expiry, and only when a
4007
+ * retention is configured for `options.kind`:
4008
+ * - a record whose window has already passed is deleted, with the same
4009
+ * per-run data a normal expiry removes;
4010
+ * - any other record gets the expiry it would have had: the retention
4011
+ * counted from its last save (`completedAt` for executions, falling back
4012
+ * to `startedAt`; `timestamp` for eval rows).
4013
+ *
4014
+ * Records that already have an expiry keep it. With no retention
4015
+ * configured for the kind (unset or `null`), nothing is expired or armed.
4016
+ *
4017
+ * The walk is oldest first, by `(startedAt, executionId)` for executions
4018
+ * and `(timestamp, id)` for eval rows, and the cursor is a position in that
4019
+ * order rather than an offset, so records removed behind it (by this call,
4020
+ * a concurrent delete or an expiry) never cause a record to be skipped.
4021
+ * Running it to completion twice changes nothing the second time.
4022
+ *
4023
+ * **Custom store implementors:** custom stores own their retention and may
4024
+ * implement this with the same contract, or leave it out. Built-ins:
4025
+ * - `MemoryStore` and `SQLiteStore` act on their rows directly; they keep
4026
+ * no separate index, so `indexed` and `deadIndexEntries` are always `0`.
4027
+ * - `RedisStore` also adds records that already carry a TTL to its expiry
4028
+ * index (`indexed`) and removes index entries whose record is gone
4029
+ * (`deadIndexEntries`).
4030
+ */
4031
+ applyHistoryRetention?(options: HistoryRetentionOptions): Promise<HistoryRetentionResult>;
3946
4032
  /** List all session IDs (used by Studio session browser). */
3947
4033
  listSessions?(): Promise<string[]>;
3948
4034
  /**
@@ -3973,6 +4059,71 @@ interface StateStore {
3973
4059
  close?(): Promise<void>;
3974
4060
  deleteCheckpoints?(executionId: string): Promise<void>;
3975
4061
  }
4062
+ /**
4063
+ * Position in execution history, used to fetch the next page. Pages are
4064
+ * ordered by `startedAt` descending, then `executionId` descending; a cursor
4065
+ * built from the last item of one page returns the items strictly after it.
4066
+ */
4067
+ type ExecutionCursor = {
4068
+ startedAt: number;
4069
+ executionId: string;
4070
+ };
4071
+ /**
4072
+ * History retention, in **seconds**, shared by the built-in stores
4073
+ * (`MemoryStore`, `SQLiteStore`, and the matching categories of
4074
+ * `RedisStore`'s `ttls`).
4075
+ *
4076
+ * - A positive number expires the record that many seconds after it is saved.
4077
+ * - `null` or unset keeps it forever.
4078
+ *
4079
+ * Windows differ per category:
4080
+ * - `executionHistory` counts from the record's **last** save; saving the same
4081
+ * execution again restarts the window.
4082
+ * - `evalHistory` counts from the row's **first** write. Saving the same eval
4083
+ * id again keeps the expiry it already had, and `updateEvalResult` never
4084
+ * changes it.
4085
+ *
4086
+ * Retention applies to records saved while it is configured; rows written
4087
+ * before keep whatever expiry they had until you run
4088
+ * {@link StateStore.applyHistoryRetention}. Custom stores own their retention.
4089
+ */
4090
+ type HistoryTtls = {
4091
+ executionHistory?: number | null;
4092
+ evalHistory?: number | null;
4093
+ };
4094
+ /** Which history {@link StateStore.applyHistoryRetention} processes. */
4095
+ type HistoryRetentionKind = 'executions' | 'evals';
4096
+ /**
4097
+ * Where {@link StateStore.applyHistoryRetention} continues from: the last
4098
+ * record of the previous batch, oldest-first. `time` is `startedAt` for
4099
+ * executions and `timestamp` for eval rows. Pass it back unchanged; it is
4100
+ * plain JSON, so it can be stored between runs.
4101
+ */
4102
+ type HistoryRetentionCursor = {
4103
+ time: number;
4104
+ id: string;
4105
+ };
4106
+ /** Options for {@link StateStore.applyHistoryRetention}. */
4107
+ type HistoryRetentionOptions = {
4108
+ kind: HistoryRetentionKind;
4109
+ /** Records examined per call. A positive integer; defaults to 500. */
4110
+ batchSize?: number;
4111
+ /** The `cursor` returned by the previous call. Omit or pass `null` to start. */
4112
+ cursor?: HistoryRetentionCursor | null;
4113
+ };
4114
+ /** What one {@link StateStore.applyHistoryRetention} call did. */
4115
+ type HistoryRetentionResult = {
4116
+ /** Records with no expiry whose window had already passed, now deleted. */
4117
+ expired: number;
4118
+ /** Records with no expiry that now have one. */
4119
+ armed: number;
4120
+ /** Records that already had an expiry, newly added to the store's expiry index (Redis). */
4121
+ indexed: number;
4122
+ /** Index entries whose record no longer exists, now removed (Redis). */
4123
+ deadIndexEntries: number;
4124
+ /** Pass to the next call, or `null` when the walk is finished. */
4125
+ cursor: HistoryRetentionCursor | null;
4126
+ };
3976
4127
  /** Persisted eval history entry. */
3977
4128
  type EvalHistoryEntry = {
3978
4129
  id: string;
@@ -3989,21 +4140,37 @@ type TelemetryConfig = {
3989
4140
  tracerProvider?: unknown;
3990
4141
  /** Tracer name. Defaults to 'axl'. */
3991
4142
  serviceName?: string;
4143
+ /** Opt in to GenAI message and tool content on spans. Defaults to false. Trace redaction wins. */
4144
+ captureContent?: boolean;
4145
+ /**
4146
+ * Per-attribute UTF-8 bound for opted-in content. Defaults to 64 KiB. Larger
4147
+ * attributes are omitted whole and named in `axl.gen_ai.content_omitted`.
4148
+ */
4149
+ maxContentAttributeBytes?: number;
3992
4150
  };
4151
+ /** OpenTelemetry-compatible scalar and native array attribute values. */
4152
+ type SpanAttributeValue = string | number | boolean | string[] | number[] | boolean[];
4153
+ type SpanAttributes = Record<string, SpanAttributeValue>;
3993
4154
  /** A handle to an active span for adding events and attributes. */
3994
4155
  interface SpanHandle {
3995
- setAttribute(key: string, value: string | number | boolean): void;
3996
- addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
4156
+ setAttribute(key: string, value: SpanAttributeValue): void;
4157
+ addEvent(name: string, attributes?: SpanAttributes): void;
3997
4158
  setStatus(code: 'unset' | 'ok' | 'error', message?: string): void;
3998
4159
  end(): void;
3999
4160
  }
4000
4161
  /** Manages span creation and context propagation. */
4001
4162
  interface SpanManager {
4002
4163
  /** Wrap an async function in a span. Child spans created inside auto-nest. */
4003
- withSpanAsync<T>(name: string, attributes: Record<string, string | number | boolean>, fn: (span: SpanHandle) => Promise<T>): Promise<T>;
4164
+ withSpanAsync<T>(name: string, attributes: SpanAttributes, fn: (span: SpanHandle) => Promise<T>): Promise<T>;
4165
+ /** Start a span whose lifetime is controlled by the caller (for streamed calls). Optional for legacy managers. */
4166
+ startSpan?(name: string, attributes: SpanAttributes, options?: {
4167
+ kind?: 'client';
4168
+ /** Epoch milliseconds at logical call initiation. */
4169
+ startTime?: number;
4170
+ }): SpanHandle;
4004
4171
  /** Add an event to the currently active span (if any). */
4005
- addEventToActiveSpan(name: string, attributes?: Record<string, string | number | boolean>): void;
4006
- /** Gracefully shut down (flush pending spans). */
4172
+ addEventToActiveSpan(name: string, attributes?: SpanAttributes): void;
4173
+ /** Release manager-owned resources. External tracer providers remain application-owned. */
4007
4174
  shutdown(): Promise<void>;
4008
4175
  }
4009
4176
 
@@ -4141,8 +4308,21 @@ type TraceConfig = {
4141
4308
  /** State store configuration */
4142
4309
  type StateConfig = {
4143
4310
  store?: StateStore | 'memory' | 'sqlite';
4311
+ /**
4312
+ * Options for the store built by `store: 'sqlite'`: the database file and
4313
+ * optional history retention (seconds; see `HistoryTtls`).
4314
+ */
4144
4315
  sqlite?: {
4145
4316
  path: string;
4317
+ ttls?: HistoryTtls;
4318
+ };
4319
+ /**
4320
+ * Options for the store built by `store: 'memory'` (the default): history
4321
+ * retention in seconds and a maximum number of execution records.
4322
+ */
4323
+ memory?: {
4324
+ ttls?: HistoryTtls;
4325
+ maxExecutions?: number;
4146
4326
  };
4147
4327
  /**
4148
4328
  * Maximum number of events retained in `ExecutionInfo.events` per
@@ -4166,6 +4346,21 @@ type StateConfig = {
4166
4346
  * integer or `Infinity`.
4167
4347
  */
4168
4348
  maxEventsPerExecution?: number;
4349
+ /**
4350
+ * How many recently finished runs the runtime keeps in process when the
4351
+ * state store cannot keep execution history itself, that is, when it lacks
4352
+ * `saveExecution` or `listExecutions`. The cache stands in for the missing
4353
+ * methods: `getExecutions()` lists from it, and `getExecution(id)` falls
4354
+ * back to it when the store cannot fetch by id either. The least recently
4355
+ * used run is dropped first. (A store that saves and lists but has no
4356
+ * `getExecution` needs no cache: by-id reads scan its listing.)
4357
+ *
4358
+ * The built-in stores have all three methods, so the runtime never keeps
4359
+ * this cache for them: history is read through the store on every call.
4360
+ *
4361
+ * Default: 1_000. `0` turns the cache off. Must be a non-negative integer.
4362
+ */
4363
+ recentExecutionsCacheSize?: number;
4169
4364
  /**
4170
4365
  * When to persist execution events to the state store.
4171
4366
  *
@@ -4229,8 +4424,11 @@ type DiagnosticsConfig = {
4229
4424
  schemaOversizedTokens?: number;
4230
4425
  /**
4231
4426
  * Silence the one-time `console.warn` diagnostics (the structured
4232
- * `schema_diagnostic` events still fire). Also silenceable process-wide via
4233
- * `AXL_DIAGNOSTICS_SILENT=true`.
4427
+ * `schema_diagnostic` events still fire). This includes the large-listing
4428
+ * warning and the retention warning of a SQLite store the runtime creates
4429
+ * from `state.store: 'sqlite'`; a store you construct yourself warns before
4430
+ * the runtime exists, so use its `ttls` or the environment variable. Also
4431
+ * silenceable process-wide via `AXL_DIAGNOSTICS_SILENT=true`.
4234
4432
  */
4235
4433
  silent?: boolean;
4236
4434
  /**
@@ -5517,8 +5715,14 @@ type CapturedMessage = {
5517
5715
  /** Bounded descriptor for the non-text parts, when there were any. */
5518
5716
  input?: ModelInputDescriptor;
5519
5717
  name?: string;
5718
+ /** Agent provenance carried by the provider-neutral conversation. */
5719
+ agent?: ChatMessage['agent'];
5720
+ /** Runtime provenance that can affect provider prompt-cache placement. */
5721
+ origin?: ChatMessage['origin'];
5520
5722
  tool_calls?: ToolCallMessage[];
5521
5723
  tool_call_id?: string;
5724
+ /** Opaque response-derived continuity data required for later model turns. */
5725
+ providerMetadata?: Record<string, unknown>;
5522
5726
  };
5523
5727
  /** The provider-neutral request, snapshotted by value at invocation. */
5524
5728
  type CapturedRequest = {
@@ -5528,6 +5732,7 @@ type CapturedRequest = {
5528
5732
  name: string;
5529
5733
  description?: string;
5530
5734
  parameters: unknown;
5735
+ strict?: boolean;
5531
5736
  }>;
5532
5737
  responseFormat?: ResponseFormat;
5533
5738
  /** Allowlisted call options only. Never signals, functions or credentials. */
@@ -5548,7 +5753,13 @@ type CapturedRequest = {
5548
5753
  /** What came back, projected to the fields that explain a turn. */
5549
5754
  type CapturedResponse = {
5550
5755
  content: string;
5756
+ thinking?: string;
5551
5757
  tool_calls?: ToolCallMessage[];
5758
+ finishReason?: ProviderResponse['finishReason'];
5759
+ rawFinishReason?: string;
5760
+ responseId?: string;
5761
+ responseModel?: string;
5762
+ providerMetadata?: Record<string, unknown>;
5552
5763
  usage?: ProviderResponse['usage'];
5553
5764
  cost?: number;
5554
5765
  costProvenance?: string;
@@ -5560,6 +5771,15 @@ type CapturedError = {
5560
5771
  message: string;
5561
5772
  code?: string;
5562
5773
  status?: number;
5774
+ retryable?: boolean;
5775
+ requestId?: string;
5776
+ retryAfterMs?: number;
5777
+ };
5778
+ /** Output observed before a stream ended without a terminal response. */
5779
+ type CapturedPartialResponse = {
5780
+ content?: string;
5781
+ thinking?: string;
5782
+ tool_calls?: ToolCallMessage[];
5563
5783
  };
5564
5784
  /** The gate that rejected the previous turn and the correction fed back in. */
5565
5785
  type CapturedCorrection = {
@@ -5574,30 +5794,47 @@ type CapturedPhase = 'start' | 'attempt' | 'end';
5574
5794
  * One JSONL line. `v: 1` is the codec version; `@axlsdk/eval` re-exports this
5575
5795
  * as `RequestRecord` and owns the bundle/import validation around it.
5576
5796
  *
5577
- * A `start` record carries the request; `attempt` records mark additional
5578
- * transport attempts for the SAME logical operation (a 429 retry is not an
5579
- * output repair); an `end` record carries the response or the error. An
5580
- * operation that never returns therefore leaves a start record with no end —
5581
- * which is exactly the call you most want to inspect.
5797
+ * A model `start` carries the request; `attempt` marks another transport
5798
+ * attempt for that same logical model call; `end` carries its response/error.
5799
+ * An external `start` carries its name after admission; its `end` carries the
5800
+ * caller's optional JSON evidence and reported settlement. A call that never
5801
+ * returns leaves a start without an end.
5582
5802
  */
5583
- type CapturedRequestRecord = {
5803
+ type CapturedRecordBase = {
5584
5804
  v: 1;
5585
5805
  phase: CapturedPhase;
5586
5806
  operationId: string;
5587
- kind: 'chat' | 'stream';
5588
5807
  caseIndex?: number;
5589
5808
  scorer?: string;
5590
5809
  executionId?: string;
5810
+ workflow?: string;
5811
+ agent?: string;
5812
+ depth?: number;
5813
+ sessionId?: string;
5814
+ purpose?: 'ask' | 'summary' | 'judge' | 'direct';
5591
5815
  askId?: string;
5592
5816
  parentAskId?: string;
5593
5817
  turn?: number;
5594
5818
  retryReason?: 'schema' | 'validate' | 'guardrail';
5819
+ rejectedCallId?: string;
5820
+ /** Dispatch and settlement timestamps; absent in older v1 journals. */
5821
+ startedAt?: string;
5822
+ endedAt?: string;
5823
+ durationMs?: number;
5824
+ /** Failed provider timing, if available, without a success response. */
5825
+ timing?: ProviderResponse['timing'];
5595
5826
  /** 1-indexed transport attempt this record describes. */
5596
5827
  transportAttempts: number;
5597
- provider: string;
5598
- model: string;
5599
- request?: CapturedRequest;
5600
- response?: CapturedResponse;
5828
+ /** Structural settlement retained when an oversized end line becomes a stub. */
5829
+ outcomeStatus?: 'ok' | 'error' | 'aborted' | 'stalled' | 'consumer_closed' | 'unfinished';
5830
+ /** The following settlement fields are populated on oversized end stubs. */
5831
+ usage?: ProviderResponse['usage'] | Partial<AccountingUsage>;
5832
+ cost?: number;
5833
+ costProvenance?: string;
5834
+ finishReason?: ProviderResponse['finishReason'];
5835
+ rawFinishReason?: string;
5836
+ responseId?: string;
5837
+ responseModel?: string;
5601
5838
  error?: CapturedError;
5602
5839
  /**
5603
5840
  * Why an operation ended without a response, when it ended deliberately.
@@ -5614,6 +5851,8 @@ type CapturedRequestRecord = {
5614
5851
  redacted: boolean;
5615
5852
  /** `true` when the record was replaced by a stub over `maxRecordBytes`. */
5616
5853
  truncated: boolean;
5854
+ /** New v1 request projection retained opaque continuity data if present. */
5855
+ continuityCaptured?: true;
5617
5856
  /** What could not be represented, e.g. `['media']`. */
5618
5857
  omitted: string[];
5619
5858
  /**
@@ -5630,10 +5869,41 @@ type CapturedRequestRecord = {
5630
5869
  /** Encoded size of the record this stub replaced. Present only on stubs. */
5631
5870
  bytes?: number;
5632
5871
  };
5872
+ /** JSON values accepted from `ExternalOperationReport.capture()`. */
5873
+ type CapturedJsonValue = null | boolean | number | string | CapturedJsonValue[] | {
5874
+ [key: string]: CapturedJsonValue;
5875
+ };
5876
+ /** Model calls retain their existing required provider/model contract. */
5877
+ type CapturedModelRequestRecord = CapturedRecordBase & {
5878
+ kind: 'chat' | 'stream';
5879
+ provider: string;
5880
+ model: string;
5881
+ request?: CapturedRequest;
5882
+ response?: CapturedResponse;
5883
+ partial?: CapturedPartialResponse;
5884
+ name?: never;
5885
+ external?: never;
5886
+ };
5887
+ /** Caller-declared work has a name and no invented provider or model. */
5888
+ type CapturedExternalRequestRecord = CapturedRecordBase & {
5889
+ kind: 'external';
5890
+ name: string;
5891
+ /** Caller JSON, snapshotted when `report.capture()` was called. On the end line. */
5892
+ external?: {
5893
+ request?: CapturedJsonValue;
5894
+ response?: CapturedJsonValue;
5895
+ };
5896
+ provider?: never;
5897
+ model?: never;
5898
+ request?: never;
5899
+ response?: never;
5900
+ partial?: never;
5901
+ };
5902
+ type CapturedRequestRecord = CapturedModelRequestRecord | CapturedExternalRequestRecord;
5633
5903
  /** A pointer from an eval item / scorer to one captured operation. */
5634
5904
  type CapturedOperationRef = {
5635
5905
  operationId: string;
5636
- kind: 'chat' | 'stream';
5906
+ kind: 'chat' | 'stream' | 'external';
5637
5907
  turn?: number;
5638
5908
  attempt?: number;
5639
5909
  status: 'recorded' | 'start_only' | 'truncated' | 'omitted';
@@ -5995,6 +6265,8 @@ declare class AxlRuntime extends EventEmitter {
5995
6265
  /** Raw adapter → its scoped facade. Keyed weakly so a registry that drops an
5996
6266
  * adapter does not pin it here. */
5997
6267
  private scopedProviders;
6268
+ /** Validated at construction so a bad bound fails loudly before any call. */
6269
+ private readonly contentAttributeMaxBytes;
5998
6270
  private transcriptionProviderRegistry;
5999
6271
  private stateStore;
6000
6272
  private executions;
@@ -6004,8 +6276,6 @@ declare class AxlRuntime extends EventEmitter {
6004
6276
  private mcpManager?;
6005
6277
  private memoryManager?;
6006
6278
  private spanManager;
6007
- private historicalExecutions;
6008
- private historicalExecutionsLoadPromise;
6009
6279
  /** Per-session in-process serialization. Each entry is a chain of pending
6010
6280
  * work for that session id — `Session.send` / `Session.stream` await the
6011
6281
  * prior entry before reading history, so concurrent calls produce a
@@ -6041,12 +6311,34 @@ declare class AxlRuntime extends EventEmitter {
6041
6311
  * a delete from resurrecting the (intentionally-removed) row. Entries are
6042
6312
  * removed once the would-be persist has been short-circuited. */
6043
6313
  private pendingDeletedExecutions;
6044
- /** In-flight `persistExecution` chains (save → finalize). `shutdown()`
6045
- * awaits these before closing the StateStore so a workflow whose abort
6314
+ /** In-flight `persistExecution` chains (save → finalize) and crash-
6315
+ * recovery saves. `shutdown()` awaits these before closing the StateStore so a workflow whose abort
6046
6316
  * triggers a persist-during-shutdown isn't racing a closed connection.
6047
6317
  * The Set is mutated by the chain's own `.finally` so entries clear as
6048
6318
  * soon as the work settles. */
6049
6319
  private persistInflight;
6320
+ /** Finished runs whose history save has not settled, keyed by execution
6321
+ * id. Reads serve the snapshot until the save lands, so a run is visible
6322
+ * the moment it finishes (read-your-writes). `deleteExecution()` awaits
6323
+ * the entry before deleting from the store, so a save that lands late
6324
+ * cannot re-create a deleted run. Each entry removes itself when its save
6325
+ * settles (success or failure), but only if it is still the current entry
6326
+ * for that id, so the map holds only in-flight saves. */
6327
+ private pendingSaves;
6328
+ /** Recently finished runs, kept only when the store cannot save, list, or
6329
+ * fetch execution history itself (and the cache size is not `0`).
6330
+ * `undefined` for every built-in store: execution history is read through
6331
+ * the store on every call and never cached here. */
6332
+ private readonly recentRuns;
6333
+ /** Execution ids `recoverIncompleteStreams()` is working on, each with a
6334
+ * promise that settles when recovery is done with that id.
6335
+ * `deleteExecution()` awaits it, so a recovered record cannot land after
6336
+ * the delete. */
6337
+ private recoveringExecutions;
6338
+ /** Execution ids with a `deleteExecution()` in progress, with a count of
6339
+ * concurrent deletes. Recovery skips them: their store sweep removes the
6340
+ * streaming buffer it would otherwise turn back into a record. */
6341
+ private deletingExecutions;
6050
6342
  /** Resolved diagnostic artifact backend, when `diagnostics.artifacts` is set. */
6051
6343
  private artifactStore?;
6052
6344
  private artifactLeaseMs;
@@ -6280,13 +6572,15 @@ declare class AxlRuntime extends EventEmitter {
6280
6572
  private runWorkflowBody;
6281
6573
  /**
6282
6574
  * Persist a completed/failed execution to the state store (fire-and-forget)
6283
- * and move it from the active executions map to the historical cache.
6575
+ * and remove it from the active executions map. Until the save settles the
6576
+ * run is served from `pendingSaves`; afterwards from the store (or, for a
6577
+ * store that cannot keep history, from `recentRuns`).
6284
6578
  *
6285
6579
  * Resurrection guard: if `runtime.deleteExecution(id)` was called while
6286
6580
  * this execution was still running, the id will be in
6287
- * `pendingDeletedExecutions`. In that case we skip the save AND the
6288
- * historical-cache write, and finalize the streaming buffer (if any) so
6289
- * the buffer doesn't outlive the delete.
6581
+ * `pendingDeletedExecutions`. In that case we skip the save AND every
6582
+ * in-process record of the run, and finalize the streaming buffer (if any)
6583
+ * so the buffer doesn't outlive the delete.
6290
6584
  */
6291
6585
  private persistExecution;
6292
6586
  /** Register a workflow with the runtime. */
@@ -6354,7 +6648,6 @@ declare class AxlRuntime extends EventEmitter {
6354
6648
  maxQueueBytes?: number;
6355
6649
  };
6356
6650
  }): Promise<unknown>;
6357
- /** Get all execution info (running + completed + historical). */
6358
6651
  /** Normalize an execution loaded from a `StateStore` so the
6359
6652
  * historical event union holds for downstream consumers
6360
6653
  * (Studio aggregators, REST routes, redaction). Custom or legacy stores
@@ -6363,7 +6656,37 @@ declare class AxlRuntime extends EventEmitter {
6363
6656
  * `exec.events` and takes down dependent features. Returns a normalized
6364
6657
  * copy; logs at most one warning per `executionId`. */
6365
6658
  private normalizeStoredExecution;
6366
- getExecutions(): Promise<HistoricalExecutionInfo[]>;
6659
+ /**
6660
+ * List executions, newest first: running runs, runs whose save is still in
6661
+ * flight, and the history the state store holds. Ordered by `startedAt`,
6662
+ * then `executionId`, both descending.
6663
+ *
6664
+ * With no options, returns every retained run. Pass `limit` for one page,
6665
+ * and `cursor` (built from the last item of the previous page) for the
6666
+ * page after it. Each call reads through the store, so runs finished or
6667
+ * deleted by other runtimes sharing the store are reflected immediately.
6668
+ * A call without `limit` that returns more than 1 000 runs warns once per
6669
+ * process (silenced by `diagnostics.silent`); pass `limit: Infinity` to ask
6670
+ * for everything without the warning.
6671
+ *
6672
+ * @throws {AxlError} `INVALID_ARGUMENT` for a `limit` that is not a positive
6673
+ * integer (`Infinity` means no limit) or a malformed `cursor`.
6674
+ */
6675
+ getExecutions(options?: {
6676
+ limit?: number;
6677
+ cursor?: ExecutionCursor;
6678
+ }): Promise<HistoricalExecutionInfo[]>;
6679
+ /**
6680
+ * Read one page of execution history from the store: the records strictly
6681
+ * after `cursor`, newest first, at least `limit + overlap` of them when the
6682
+ * store holds that many (all of them when `limit` is unset).
6683
+ *
6684
+ * Only a store that declares `historyPaging` is handed the cursor. Any
6685
+ * other store is listed in full and paged here: filtering the output of a
6686
+ * store that ignored the cursor would return its first page again, and an
6687
+ * empty page after that.
6688
+ */
6689
+ private listStoredExecutions;
6367
6690
  /**
6368
6691
  * Create a WorkflowContext for ad-hoc use (evals, tool testing, prototyping).
6369
6692
  * The context has access to the runtime's providers, state store, MCP manager,
@@ -6381,8 +6704,8 @@ declare class AxlRuntime extends EventEmitter {
6381
6704
  * It forwards everything to the adapter — custom properties and accessors,
6382
6705
  * class private-field methods, property writes, capability methods, ordinary
6383
6706
  * `instanceof` — while routing `chat`/`stream` through accounting and budget
6384
- * admission whenever a `trackOutcome` scope is active. Outside a scope it
6385
- * delegates verbatim.
6707
+ * admission whenever a `trackOutcome` scope is active. Optional runtime
6708
+ * telemetry also observes calls outside an accounting scope.
6386
6709
  *
6387
6710
  * Identity is stable per runtime per adapter (repeated calls return the same
6388
6711
  * facade), but `resolveProvider(uri).provider === registeredInstance` is now
@@ -6426,35 +6749,70 @@ declare class AxlRuntime extends EventEmitter {
6426
6749
  * Recover executions whose process died mid-run when `state.persist:
6427
6750
  * 'streaming'` was configured. Synthesizes a partial `ExecutionInfo`
6428
6751
  * from the streaming buffer for each — `status: 'failed'`, error
6429
- * `'process terminated'` — registers them in the historical cache so
6430
- * they show up in `getExecutions()`, persists them via the store's
6431
- * `saveExecution`, and finalizes the streaming buffer.
6752
+ * `'process terminated'` — persists them via the store's
6753
+ * `saveExecution` (so they show up in `getExecutions()`), and finalizes
6754
+ * the streaming buffer.
6432
6755
  *
6433
6756
  * Idempotent — if the streaming buffer is already gone (or
6434
6757
  * `listStreamingExecutions` is empty), this is a no-op. Returns the
6435
6758
  * list of recovered `ExecutionInfo`s for caller introspection.
6436
6759
  *
6437
- * Wire this into your process startup AFTER `runtime.getExecutions()`
6438
- * has lazy-loaded the historical cache. Order matters: completed
6439
- * executions already in the store should not be overwritten by a
6440
- * stale streaming buffer that the previous process didn't get to
6441
- * finalize. The implementation checks the historical store before
6442
- * synthesizing, so a re-run is safe.
6760
+ * A run whose final record already exists is never recovered: for each
6761
+ * buffered id this asks the store's `getExecution(id)` and, when a record
6762
+ * is there, only drops the leftover buffer. It does not list history, so
6763
+ * its cost does not grow with the size of the store. A store without
6764
+ * `getExecution` cannot be checked, and every buffered run is recovered.
6765
+ *
6766
+ * Wire this into process startup, before the process accepts new work:
6767
+ * a run live in another process looks the same as a crashed one.
6768
+ * `deleteExecution(id)` called while recovery is working on that id waits
6769
+ * for recovery to finish with it, so the recovered record cannot outlive
6770
+ * the delete.
6443
6771
  */
6444
6772
  recoverIncompleteStreams(): Promise<HistoricalExecutionInfo[]>;
6773
+ /** Recover one buffered execution. Returns the synthesized record, or
6774
+ * `undefined` when there was nothing to recover. */
6775
+ private recoverStreamingExecution;
6445
6776
  /** Abort a running execution by its ID. */
6446
6777
  abort(executionId: string): void;
6447
- /** Get execution details by ID. */
6778
+ /**
6779
+ * Get execution details by ID. Looks in order at running runs, runs whose
6780
+ * save is still in flight, the state store (its `getExecution`, or a scan
6781
+ * of its listing when it has `listExecutions` but no `getExecution`), and
6782
+ * (only for a store that cannot list or save history) the recent-runs
6783
+ * cache. Nothing read from the store is cached, so a run deleted or
6784
+ * expired elsewhere is gone on the next call, and every run
6785
+ * `getExecutions()` lists can be fetched here.
6786
+ */
6448
6787
  getExecution(executionId: string): Promise<HistoricalExecutionInfo | undefined>;
6788
+ /**
6789
+ * By-id read for a store that lists but cannot fetch by id. A paging store
6790
+ * is scanned page by page with the cursor, stopping at the match; any
6791
+ * other store is listed once in full. Returns `null` when the store cannot
6792
+ * list or does not hold the run.
6793
+ */
6794
+ private findInStoreListing;
6795
+ /** The recent-runs cache stands in for listing when the store cannot list
6796
+ * runs, or never receives them because it cannot save. */
6797
+ private recentRunsServeListing;
6798
+ /** The recent-runs cache stands in for by-id reads when the store cannot
6799
+ * fetch or list runs (it exists only then), or never receives them because
6800
+ * it cannot save. */
6801
+ private recentRunsServeReads;
6449
6802
  /** Save an eval result to history. */
6450
6803
  saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
6451
6804
  /**
6452
6805
  * Delete an execution from history by id. Removes from the active map (if
6453
- * still running), the historical cache, the configured StateStore, AND
6806
+ * still running), the recent-runs cache, the configured StateStore, AND
6454
6807
  * any execution-scoped side state — pending awaitHuman decisions,
6455
6808
  * resolver maps, streaming buffer registration, in-flight abort controller.
6456
- * Returns true if an entry was actually removed from any of the three
6457
- * primary surfaces (active map, historical cache, store).
6809
+ * Returns true if the run was running, had a save in flight, or was
6810
+ * removed from the recent-runs cache or the store.
6811
+ *
6812
+ * If the run has already finished but its history save has not landed
6813
+ * yet, this method waits for that save (whether it succeeds or fails)
6814
+ * before deleting, so the save cannot re-create the deleted record. It
6815
+ * likewise waits for `recoverIncompleteStreams()` to finish with the id.
6458
6816
  *
6459
6817
  * In-flight handling: if the execution is still running, this method
6460
6818
  * **aborts** it (via the registered abort controller) AND marks the id for
@@ -6479,6 +6837,7 @@ declare class AxlRuntime extends EventEmitter {
6479
6837
  * (`defaultTtl` / `ttls.executionHistory`).
6480
6838
  */
6481
6839
  deleteExecution(id: string): Promise<boolean>;
6840
+ private deleteExecutionWhileMarked;
6482
6841
  /**
6483
6842
  * Delete an eval history entry by id. Removes from in-memory cache and
6484
6843
  * the configured StateStore. Returns true if an entry was actually removed.
@@ -6677,6 +7036,1497 @@ declare class AxlRuntime extends EventEmitter {
6677
7036
  private updateHandoffDuration;
6678
7037
  }
6679
7038
 
7039
+ declare const modelSchema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
7040
+ v: z.ZodLiteral<2>;
7041
+ id: z.ZodString;
7042
+ purpose: z.ZodOptional<z.ZodEnum<{
7043
+ ask: "ask";
7044
+ summary: "summary";
7045
+ judge: "judge";
7046
+ direct: "direct";
7047
+ }>>;
7048
+ startedAt: z.ZodOptional<z.ZodString>;
7049
+ endedAt: z.ZodOptional<z.ZodString>;
7050
+ ids: z.ZodObject<{
7051
+ executionId: z.ZodOptional<z.ZodString>;
7052
+ workflow: z.ZodOptional<z.ZodString>;
7053
+ agent: z.ZodOptional<z.ZodString>;
7054
+ askId: z.ZodOptional<z.ZodString>;
7055
+ parentAskId: z.ZodOptional<z.ZodString>;
7056
+ depth: z.ZodOptional<z.ZodNumber>;
7057
+ turn: z.ZodOptional<z.ZodNumber>;
7058
+ sessionId: z.ZodOptional<z.ZodString>;
7059
+ caseIndex: z.ZodOptional<z.ZodNumber>;
7060
+ scorer: z.ZodOptional<z.ZodString>;
7061
+ }, z.core.$strict>;
7062
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
7063
+ gate: z.ZodOptional<z.ZodObject<{
7064
+ retryReason: z.ZodEnum<{
7065
+ schema: "schema";
7066
+ validate: "validate";
7067
+ guardrail: "guardrail";
7068
+ }>;
7069
+ rejectedCallId: z.ZodOptional<z.ZodString>;
7070
+ correction: z.ZodOptional<z.ZodObject<{
7071
+ stage: z.ZodEnum<{
7072
+ schema: "schema";
7073
+ validate: "validate";
7074
+ guardrail: "guardrail";
7075
+ }>;
7076
+ reason: z.ZodOptional<z.ZodString>;
7077
+ feedbackMessage: z.ZodString;
7078
+ }, z.core.$strict>>;
7079
+ }, z.core.$strict>>;
7080
+ timing: z.ZodOptional<z.ZodObject<{
7081
+ queuedMs: z.ZodOptional<z.ZodNumber>;
7082
+ attempts: z.ZodOptional<z.ZodNumber>;
7083
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
7084
+ retryMs: z.ZodOptional<z.ZodNumber>;
7085
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
7086
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
7087
+ wireMs: z.ZodOptional<z.ZodNumber>;
7088
+ durationMs: z.ZodOptional<z.ZodNumber>;
7089
+ }, z.core.$strict>>;
7090
+ cost: z.ZodOptional<z.ZodNumber>;
7091
+ costProvenance: z.ZodOptional<z.ZodEnum<{
7092
+ provider_reported: "provider_reported";
7093
+ price_table_estimate: "price_table_estimate";
7094
+ caller_reported: "caller_reported";
7095
+ adapter_reported: "adapter_reported";
7096
+ }>>;
7097
+ unpriced: z.ZodOptional<z.ZodBoolean>;
7098
+ captured: z.ZodObject<{
7099
+ fidelity: z.ZodLiteral<"runtime_request">;
7100
+ redacted: z.ZodBoolean;
7101
+ truncated: z.ZodBoolean;
7102
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
7103
+ omitted: z.ZodArray<z.ZodString>;
7104
+ replayable: z.ZodBoolean;
7105
+ reason: z.ZodOptional<z.ZodString>;
7106
+ }, z.core.$strict>;
7107
+ kind: z.ZodEnum<{
7108
+ chat: "chat";
7109
+ stream: "stream";
7110
+ }>;
7111
+ provider: z.ZodString;
7112
+ model: z.ZodString;
7113
+ request: z.ZodOptional<z.ZodObject<{
7114
+ messages: z.ZodArray<z.ZodObject<{
7115
+ role: z.ZodString;
7116
+ content: z.ZodNullable<z.ZodString>;
7117
+ input: z.ZodOptional<z.ZodObject<{
7118
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
7119
+ type: z.ZodLiteral<"text">;
7120
+ characters: z.ZodNumber;
7121
+ }, z.core.$strict>, z.ZodObject<{
7122
+ type: z.ZodLiteral<"image">;
7123
+ source: z.ZodEnum<{
7124
+ bytes: "bytes";
7125
+ base64: "base64";
7126
+ "provider-file": "provider-file";
7127
+ url: "url";
7128
+ }>;
7129
+ mediaType: z.ZodOptional<z.ZodString>;
7130
+ bytes: z.ZodOptional<z.ZodNumber>;
7131
+ locator: z.ZodOptional<z.ZodString>;
7132
+ label: z.ZodOptional<z.ZodString>;
7133
+ }, z.core.$strict>, z.ZodObject<{
7134
+ type: z.ZodLiteral<"audio">;
7135
+ source: z.ZodEnum<{
7136
+ bytes: "bytes";
7137
+ base64: "base64";
7138
+ "provider-file": "provider-file";
7139
+ }>;
7140
+ mediaType: z.ZodOptional<z.ZodString>;
7141
+ bytes: z.ZodOptional<z.ZodNumber>;
7142
+ locator: z.ZodOptional<z.ZodString>;
7143
+ label: z.ZodOptional<z.ZodString>;
7144
+ }, z.core.$strict>], "type">>;
7145
+ }, z.core.$strict>>;
7146
+ name: z.ZodOptional<z.ZodString>;
7147
+ agent: z.ZodOptional<z.ZodString>;
7148
+ origin: z.ZodOptional<z.ZodLiteral<"runtime">>;
7149
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7150
+ id: z.ZodString;
7151
+ type: z.ZodLiteral<"function">;
7152
+ function: z.ZodObject<{
7153
+ name: z.ZodString;
7154
+ arguments: z.ZodString;
7155
+ }, z.core.$strict>;
7156
+ }, z.core.$strict>>>;
7157
+ tool_call_id: z.ZodOptional<z.ZodString>;
7158
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7159
+ }, z.core.$strict>>;
7160
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
7161
+ name: z.ZodString;
7162
+ description: z.ZodOptional<z.ZodString>;
7163
+ parameters: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7164
+ strict: z.ZodOptional<z.ZodBoolean>;
7165
+ }, z.core.$strict>>>;
7166
+ responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7167
+ type: z.ZodLiteral<"text">;
7168
+ }, z.core.$strict>, z.ZodObject<{
7169
+ type: z.ZodLiteral<"json_object">;
7170
+ }, z.core.$strict>, z.ZodObject<{
7171
+ type: z.ZodLiteral<"json_schema">;
7172
+ json_schema: z.ZodObject<{
7173
+ name: z.ZodString;
7174
+ strict: z.ZodOptional<z.ZodBoolean>;
7175
+ schema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7176
+ }, z.core.$strict>;
7177
+ }, z.core.$strict>], "type">>;
7178
+ options: z.ZodObject<{
7179
+ model: z.ZodString;
7180
+ temperature: z.ZodOptional<z.ZodNumber>;
7181
+ maxTokens: z.ZodOptional<z.ZodNumber>;
7182
+ effort: z.ZodOptional<z.ZodString>;
7183
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
7184
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
7185
+ toolChoice: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7186
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
7187
+ promptCache: z.ZodOptional<z.ZodBoolean>;
7188
+ }, z.core.$strict>;
7189
+ providerOptionKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
7190
+ }, z.core.$strict>>;
7191
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
7192
+ status: z.ZodLiteral<"ok">;
7193
+ response: z.ZodObject<{
7194
+ content: z.ZodString;
7195
+ thinking: z.ZodOptional<z.ZodString>;
7196
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7197
+ id: z.ZodString;
7198
+ type: z.ZodLiteral<"function">;
7199
+ function: z.ZodObject<{
7200
+ name: z.ZodString;
7201
+ arguments: z.ZodString;
7202
+ }, z.core.$strict>;
7203
+ }, z.core.$strict>>>;
7204
+ finishReason: z.ZodOptional<z.ZodEnum<{
7205
+ length: "length";
7206
+ stop: "stop";
7207
+ tool_calls: "tool_calls";
7208
+ content_filter: "content_filter";
7209
+ refusal: "refusal";
7210
+ other: "other";
7211
+ }>>;
7212
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7213
+ responseId: z.ZodOptional<z.ZodString>;
7214
+ responseModel: z.ZodOptional<z.ZodString>;
7215
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7216
+ }, z.core.$strict>;
7217
+ }, z.core.$strict>, z.ZodObject<{
7218
+ status: z.ZodLiteral<"ok">;
7219
+ payloadOmitted: z.ZodLiteral<true>;
7220
+ finishReason: z.ZodOptional<z.ZodEnum<{
7221
+ length: "length";
7222
+ stop: "stop";
7223
+ tool_calls: "tool_calls";
7224
+ content_filter: "content_filter";
7225
+ refusal: "refusal";
7226
+ other: "other";
7227
+ }>>;
7228
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7229
+ responseId: z.ZodOptional<z.ZodString>;
7230
+ responseModel: z.ZodOptional<z.ZodString>;
7231
+ }, z.core.$strict>, z.ZodObject<{
7232
+ status: z.ZodLiteral<"error">;
7233
+ error: z.ZodObject<{
7234
+ name: z.ZodOptional<z.ZodString>;
7235
+ message: z.ZodString;
7236
+ code: z.ZodOptional<z.ZodString>;
7237
+ status: z.ZodOptional<z.ZodNumber>;
7238
+ retryable: z.ZodOptional<z.ZodBoolean>;
7239
+ requestId: z.ZodOptional<z.ZodString>;
7240
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
7241
+ }, z.core.$strict>;
7242
+ partial: z.ZodOptional<z.ZodObject<{
7243
+ content: z.ZodOptional<z.ZodString>;
7244
+ thinking: z.ZodOptional<z.ZodString>;
7245
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7246
+ id: z.ZodString;
7247
+ type: z.ZodLiteral<"function">;
7248
+ function: z.ZodObject<{
7249
+ name: z.ZodString;
7250
+ arguments: z.ZodString;
7251
+ }, z.core.$strict>;
7252
+ }, z.core.$strict>>>;
7253
+ }, z.core.$strict>>;
7254
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7255
+ termination: z.ZodOptional<z.ZodString>;
7256
+ }, z.core.$strict>, z.ZodObject<{
7257
+ status: z.ZodLiteral<"error">;
7258
+ payloadOmitted: z.ZodLiteral<true>;
7259
+ partial: z.ZodOptional<z.ZodObject<{
7260
+ content: z.ZodOptional<z.ZodString>;
7261
+ thinking: z.ZodOptional<z.ZodString>;
7262
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7263
+ id: z.ZodString;
7264
+ type: z.ZodLiteral<"function">;
7265
+ function: z.ZodObject<{
7266
+ name: z.ZodString;
7267
+ arguments: z.ZodString;
7268
+ }, z.core.$strict>;
7269
+ }, z.core.$strict>>>;
7270
+ }, z.core.$strict>>;
7271
+ termination: z.ZodOptional<z.ZodString>;
7272
+ }, z.core.$strict>, z.ZodObject<{
7273
+ status: z.ZodEnum<{
7274
+ aborted: "aborted";
7275
+ stalled: "stalled";
7276
+ consumer_closed: "consumer_closed";
7277
+ }>;
7278
+ partial: z.ZodOptional<z.ZodObject<{
7279
+ content: z.ZodOptional<z.ZodString>;
7280
+ thinking: z.ZodOptional<z.ZodString>;
7281
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7282
+ id: z.ZodString;
7283
+ type: z.ZodLiteral<"function">;
7284
+ function: z.ZodObject<{
7285
+ name: z.ZodString;
7286
+ arguments: z.ZodString;
7287
+ }, z.core.$strict>;
7288
+ }, z.core.$strict>>>;
7289
+ }, z.core.$strict>>;
7290
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7291
+ termination: z.ZodOptional<z.ZodString>;
7292
+ }, z.core.$strict>, z.ZodObject<{
7293
+ status: z.ZodLiteral<"unfinished">;
7294
+ termination: z.ZodOptional<z.ZodString>;
7295
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7296
+ }, z.core.$strict>]>;
7297
+ usage: z.ZodOptional<z.ZodObject<{
7298
+ prompt_tokens: z.ZodNumber;
7299
+ completion_tokens: z.ZodNumber;
7300
+ total_tokens: z.ZodNumber;
7301
+ reasoning_tokens: z.ZodOptional<z.ZodNumber>;
7302
+ cached_tokens: z.ZodOptional<z.ZodNumber>;
7303
+ cache_write_tokens: z.ZodOptional<z.ZodNumber>;
7304
+ audio_input_tokens: z.ZodOptional<z.ZodNumber>;
7305
+ audio_output_tokens: z.ZodOptional<z.ZodNumber>;
7306
+ }, z.core.$strict>>;
7307
+ }, z.core.$strict>>;
7308
+ declare const externalSchema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
7309
+ v: z.ZodLiteral<2>;
7310
+ id: z.ZodString;
7311
+ purpose: z.ZodOptional<z.ZodEnum<{
7312
+ ask: "ask";
7313
+ summary: "summary";
7314
+ judge: "judge";
7315
+ direct: "direct";
7316
+ }>>;
7317
+ startedAt: z.ZodOptional<z.ZodString>;
7318
+ endedAt: z.ZodOptional<z.ZodString>;
7319
+ ids: z.ZodObject<{
7320
+ executionId: z.ZodOptional<z.ZodString>;
7321
+ workflow: z.ZodOptional<z.ZodString>;
7322
+ agent: z.ZodOptional<z.ZodString>;
7323
+ askId: z.ZodOptional<z.ZodString>;
7324
+ parentAskId: z.ZodOptional<z.ZodString>;
7325
+ depth: z.ZodOptional<z.ZodNumber>;
7326
+ turn: z.ZodOptional<z.ZodNumber>;
7327
+ sessionId: z.ZodOptional<z.ZodString>;
7328
+ caseIndex: z.ZodOptional<z.ZodNumber>;
7329
+ scorer: z.ZodOptional<z.ZodString>;
7330
+ }, z.core.$strict>;
7331
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
7332
+ gate: z.ZodOptional<z.ZodObject<{
7333
+ retryReason: z.ZodEnum<{
7334
+ schema: "schema";
7335
+ validate: "validate";
7336
+ guardrail: "guardrail";
7337
+ }>;
7338
+ rejectedCallId: z.ZodOptional<z.ZodString>;
7339
+ correction: z.ZodOptional<z.ZodObject<{
7340
+ stage: z.ZodEnum<{
7341
+ schema: "schema";
7342
+ validate: "validate";
7343
+ guardrail: "guardrail";
7344
+ }>;
7345
+ reason: z.ZodOptional<z.ZodString>;
7346
+ feedbackMessage: z.ZodString;
7347
+ }, z.core.$strict>>;
7348
+ }, z.core.$strict>>;
7349
+ timing: z.ZodOptional<z.ZodObject<{
7350
+ queuedMs: z.ZodOptional<z.ZodNumber>;
7351
+ attempts: z.ZodOptional<z.ZodNumber>;
7352
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
7353
+ retryMs: z.ZodOptional<z.ZodNumber>;
7354
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
7355
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
7356
+ wireMs: z.ZodOptional<z.ZodNumber>;
7357
+ durationMs: z.ZodOptional<z.ZodNumber>;
7358
+ }, z.core.$strict>>;
7359
+ cost: z.ZodOptional<z.ZodNumber>;
7360
+ unpriced: z.ZodOptional<z.ZodBoolean>;
7361
+ captured: z.ZodObject<{
7362
+ fidelity: z.ZodLiteral<"runtime_request">;
7363
+ redacted: z.ZodBoolean;
7364
+ truncated: z.ZodBoolean;
7365
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
7366
+ omitted: z.ZodArray<z.ZodString>;
7367
+ replayable: z.ZodBoolean;
7368
+ reason: z.ZodOptional<z.ZodString>;
7369
+ }, z.core.$strict>;
7370
+ kind: z.ZodLiteral<"external">;
7371
+ name: z.ZodString;
7372
+ costProvenance: z.ZodOptional<z.ZodLiteral<"caller_reported">>;
7373
+ external: z.ZodOptional<z.ZodObject<{
7374
+ request: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7375
+ response: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7376
+ }, z.core.$strict>>;
7377
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
7378
+ status: z.ZodLiteral<"ok">;
7379
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7380
+ }, z.core.$strict>, z.ZodObject<{
7381
+ status: z.ZodLiteral<"error">;
7382
+ error: z.ZodObject<{
7383
+ name: z.ZodOptional<z.ZodString>;
7384
+ message: z.ZodString;
7385
+ code: z.ZodOptional<z.ZodString>;
7386
+ status: z.ZodOptional<z.ZodNumber>;
7387
+ retryable: z.ZodOptional<z.ZodBoolean>;
7388
+ requestId: z.ZodOptional<z.ZodString>;
7389
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
7390
+ }, z.core.$strict>;
7391
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7392
+ termination: z.ZodOptional<z.ZodString>;
7393
+ }, z.core.$strict>, z.ZodObject<{
7394
+ status: z.ZodLiteral<"error">;
7395
+ payloadOmitted: z.ZodLiteral<true>;
7396
+ termination: z.ZodOptional<z.ZodString>;
7397
+ }, z.core.$strict>, z.ZodObject<{
7398
+ status: z.ZodLiteral<"unfinished">;
7399
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7400
+ termination: z.ZodOptional<z.ZodString>;
7401
+ }, z.core.$strict>]>;
7402
+ usage: z.ZodOptional<z.ZodObject<{
7403
+ inputTokens: z.ZodOptional<z.ZodNumber>;
7404
+ outputTokens: z.ZodOptional<z.ZodNumber>;
7405
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
7406
+ cachedTokens: z.ZodOptional<z.ZodNumber>;
7407
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
7408
+ audioSeconds: z.ZodOptional<z.ZodNumber>;
7409
+ }, z.core.$strict>>;
7410
+ }, z.core.$strict>>;
7411
+ /** Validated v2 model call; historical v1 journals are read through foldJournal. */
7412
+ declare const modelCallRecordSchema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
7413
+ v: z.ZodLiteral<2>;
7414
+ id: z.ZodString;
7415
+ purpose: z.ZodOptional<z.ZodEnum<{
7416
+ ask: "ask";
7417
+ summary: "summary";
7418
+ judge: "judge";
7419
+ direct: "direct";
7420
+ }>>;
7421
+ startedAt: z.ZodOptional<z.ZodString>;
7422
+ endedAt: z.ZodOptional<z.ZodString>;
7423
+ ids: z.ZodObject<{
7424
+ executionId: z.ZodOptional<z.ZodString>;
7425
+ workflow: z.ZodOptional<z.ZodString>;
7426
+ agent: z.ZodOptional<z.ZodString>;
7427
+ askId: z.ZodOptional<z.ZodString>;
7428
+ parentAskId: z.ZodOptional<z.ZodString>;
7429
+ depth: z.ZodOptional<z.ZodNumber>;
7430
+ turn: z.ZodOptional<z.ZodNumber>;
7431
+ sessionId: z.ZodOptional<z.ZodString>;
7432
+ caseIndex: z.ZodOptional<z.ZodNumber>;
7433
+ scorer: z.ZodOptional<z.ZodString>;
7434
+ }, z.core.$strict>;
7435
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
7436
+ gate: z.ZodOptional<z.ZodObject<{
7437
+ retryReason: z.ZodEnum<{
7438
+ schema: "schema";
7439
+ validate: "validate";
7440
+ guardrail: "guardrail";
7441
+ }>;
7442
+ rejectedCallId: z.ZodOptional<z.ZodString>;
7443
+ correction: z.ZodOptional<z.ZodObject<{
7444
+ stage: z.ZodEnum<{
7445
+ schema: "schema";
7446
+ validate: "validate";
7447
+ guardrail: "guardrail";
7448
+ }>;
7449
+ reason: z.ZodOptional<z.ZodString>;
7450
+ feedbackMessage: z.ZodString;
7451
+ }, z.core.$strict>>;
7452
+ }, z.core.$strict>>;
7453
+ timing: z.ZodOptional<z.ZodObject<{
7454
+ queuedMs: z.ZodOptional<z.ZodNumber>;
7455
+ attempts: z.ZodOptional<z.ZodNumber>;
7456
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
7457
+ retryMs: z.ZodOptional<z.ZodNumber>;
7458
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
7459
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
7460
+ wireMs: z.ZodOptional<z.ZodNumber>;
7461
+ durationMs: z.ZodOptional<z.ZodNumber>;
7462
+ }, z.core.$strict>>;
7463
+ cost: z.ZodOptional<z.ZodNumber>;
7464
+ costProvenance: z.ZodOptional<z.ZodEnum<{
7465
+ provider_reported: "provider_reported";
7466
+ price_table_estimate: "price_table_estimate";
7467
+ caller_reported: "caller_reported";
7468
+ adapter_reported: "adapter_reported";
7469
+ }>>;
7470
+ unpriced: z.ZodOptional<z.ZodBoolean>;
7471
+ captured: z.ZodObject<{
7472
+ fidelity: z.ZodLiteral<"runtime_request">;
7473
+ redacted: z.ZodBoolean;
7474
+ truncated: z.ZodBoolean;
7475
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
7476
+ omitted: z.ZodArray<z.ZodString>;
7477
+ replayable: z.ZodBoolean;
7478
+ reason: z.ZodOptional<z.ZodString>;
7479
+ }, z.core.$strict>;
7480
+ kind: z.ZodEnum<{
7481
+ chat: "chat";
7482
+ stream: "stream";
7483
+ }>;
7484
+ provider: z.ZodString;
7485
+ model: z.ZodString;
7486
+ request: z.ZodOptional<z.ZodObject<{
7487
+ messages: z.ZodArray<z.ZodObject<{
7488
+ role: z.ZodString;
7489
+ content: z.ZodNullable<z.ZodString>;
7490
+ input: z.ZodOptional<z.ZodObject<{
7491
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
7492
+ type: z.ZodLiteral<"text">;
7493
+ characters: z.ZodNumber;
7494
+ }, z.core.$strict>, z.ZodObject<{
7495
+ type: z.ZodLiteral<"image">;
7496
+ source: z.ZodEnum<{
7497
+ bytes: "bytes";
7498
+ base64: "base64";
7499
+ "provider-file": "provider-file";
7500
+ url: "url";
7501
+ }>;
7502
+ mediaType: z.ZodOptional<z.ZodString>;
7503
+ bytes: z.ZodOptional<z.ZodNumber>;
7504
+ locator: z.ZodOptional<z.ZodString>;
7505
+ label: z.ZodOptional<z.ZodString>;
7506
+ }, z.core.$strict>, z.ZodObject<{
7507
+ type: z.ZodLiteral<"audio">;
7508
+ source: z.ZodEnum<{
7509
+ bytes: "bytes";
7510
+ base64: "base64";
7511
+ "provider-file": "provider-file";
7512
+ }>;
7513
+ mediaType: z.ZodOptional<z.ZodString>;
7514
+ bytes: z.ZodOptional<z.ZodNumber>;
7515
+ locator: z.ZodOptional<z.ZodString>;
7516
+ label: z.ZodOptional<z.ZodString>;
7517
+ }, z.core.$strict>], "type">>;
7518
+ }, z.core.$strict>>;
7519
+ name: z.ZodOptional<z.ZodString>;
7520
+ agent: z.ZodOptional<z.ZodString>;
7521
+ origin: z.ZodOptional<z.ZodLiteral<"runtime">>;
7522
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7523
+ id: z.ZodString;
7524
+ type: z.ZodLiteral<"function">;
7525
+ function: z.ZodObject<{
7526
+ name: z.ZodString;
7527
+ arguments: z.ZodString;
7528
+ }, z.core.$strict>;
7529
+ }, z.core.$strict>>>;
7530
+ tool_call_id: z.ZodOptional<z.ZodString>;
7531
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7532
+ }, z.core.$strict>>;
7533
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
7534
+ name: z.ZodString;
7535
+ description: z.ZodOptional<z.ZodString>;
7536
+ parameters: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7537
+ strict: z.ZodOptional<z.ZodBoolean>;
7538
+ }, z.core.$strict>>>;
7539
+ responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7540
+ type: z.ZodLiteral<"text">;
7541
+ }, z.core.$strict>, z.ZodObject<{
7542
+ type: z.ZodLiteral<"json_object">;
7543
+ }, z.core.$strict>, z.ZodObject<{
7544
+ type: z.ZodLiteral<"json_schema">;
7545
+ json_schema: z.ZodObject<{
7546
+ name: z.ZodString;
7547
+ strict: z.ZodOptional<z.ZodBoolean>;
7548
+ schema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7549
+ }, z.core.$strict>;
7550
+ }, z.core.$strict>], "type">>;
7551
+ options: z.ZodObject<{
7552
+ model: z.ZodString;
7553
+ temperature: z.ZodOptional<z.ZodNumber>;
7554
+ maxTokens: z.ZodOptional<z.ZodNumber>;
7555
+ effort: z.ZodOptional<z.ZodString>;
7556
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
7557
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
7558
+ toolChoice: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7559
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
7560
+ promptCache: z.ZodOptional<z.ZodBoolean>;
7561
+ }, z.core.$strict>;
7562
+ providerOptionKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
7563
+ }, z.core.$strict>>;
7564
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
7565
+ status: z.ZodLiteral<"ok">;
7566
+ response: z.ZodObject<{
7567
+ content: z.ZodString;
7568
+ thinking: z.ZodOptional<z.ZodString>;
7569
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7570
+ id: z.ZodString;
7571
+ type: z.ZodLiteral<"function">;
7572
+ function: z.ZodObject<{
7573
+ name: z.ZodString;
7574
+ arguments: z.ZodString;
7575
+ }, z.core.$strict>;
7576
+ }, z.core.$strict>>>;
7577
+ finishReason: z.ZodOptional<z.ZodEnum<{
7578
+ length: "length";
7579
+ stop: "stop";
7580
+ tool_calls: "tool_calls";
7581
+ content_filter: "content_filter";
7582
+ refusal: "refusal";
7583
+ other: "other";
7584
+ }>>;
7585
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7586
+ responseId: z.ZodOptional<z.ZodString>;
7587
+ responseModel: z.ZodOptional<z.ZodString>;
7588
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7589
+ }, z.core.$strict>;
7590
+ }, z.core.$strict>, z.ZodObject<{
7591
+ status: z.ZodLiteral<"ok">;
7592
+ payloadOmitted: z.ZodLiteral<true>;
7593
+ finishReason: z.ZodOptional<z.ZodEnum<{
7594
+ length: "length";
7595
+ stop: "stop";
7596
+ tool_calls: "tool_calls";
7597
+ content_filter: "content_filter";
7598
+ refusal: "refusal";
7599
+ other: "other";
7600
+ }>>;
7601
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7602
+ responseId: z.ZodOptional<z.ZodString>;
7603
+ responseModel: z.ZodOptional<z.ZodString>;
7604
+ }, z.core.$strict>, z.ZodObject<{
7605
+ status: z.ZodLiteral<"error">;
7606
+ error: z.ZodObject<{
7607
+ name: z.ZodOptional<z.ZodString>;
7608
+ message: z.ZodString;
7609
+ code: z.ZodOptional<z.ZodString>;
7610
+ status: z.ZodOptional<z.ZodNumber>;
7611
+ retryable: z.ZodOptional<z.ZodBoolean>;
7612
+ requestId: z.ZodOptional<z.ZodString>;
7613
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
7614
+ }, z.core.$strict>;
7615
+ partial: z.ZodOptional<z.ZodObject<{
7616
+ content: z.ZodOptional<z.ZodString>;
7617
+ thinking: z.ZodOptional<z.ZodString>;
7618
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7619
+ id: z.ZodString;
7620
+ type: z.ZodLiteral<"function">;
7621
+ function: z.ZodObject<{
7622
+ name: z.ZodString;
7623
+ arguments: z.ZodString;
7624
+ }, z.core.$strict>;
7625
+ }, z.core.$strict>>>;
7626
+ }, z.core.$strict>>;
7627
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7628
+ termination: z.ZodOptional<z.ZodString>;
7629
+ }, z.core.$strict>, z.ZodObject<{
7630
+ status: z.ZodLiteral<"error">;
7631
+ payloadOmitted: z.ZodLiteral<true>;
7632
+ partial: z.ZodOptional<z.ZodObject<{
7633
+ content: z.ZodOptional<z.ZodString>;
7634
+ thinking: z.ZodOptional<z.ZodString>;
7635
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7636
+ id: z.ZodString;
7637
+ type: z.ZodLiteral<"function">;
7638
+ function: z.ZodObject<{
7639
+ name: z.ZodString;
7640
+ arguments: z.ZodString;
7641
+ }, z.core.$strict>;
7642
+ }, z.core.$strict>>>;
7643
+ }, z.core.$strict>>;
7644
+ termination: z.ZodOptional<z.ZodString>;
7645
+ }, z.core.$strict>, z.ZodObject<{
7646
+ status: z.ZodEnum<{
7647
+ aborted: "aborted";
7648
+ stalled: "stalled";
7649
+ consumer_closed: "consumer_closed";
7650
+ }>;
7651
+ partial: z.ZodOptional<z.ZodObject<{
7652
+ content: z.ZodOptional<z.ZodString>;
7653
+ thinking: z.ZodOptional<z.ZodString>;
7654
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7655
+ id: z.ZodString;
7656
+ type: z.ZodLiteral<"function">;
7657
+ function: z.ZodObject<{
7658
+ name: z.ZodString;
7659
+ arguments: z.ZodString;
7660
+ }, z.core.$strict>;
7661
+ }, z.core.$strict>>>;
7662
+ }, z.core.$strict>>;
7663
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7664
+ termination: z.ZodOptional<z.ZodString>;
7665
+ }, z.core.$strict>, z.ZodObject<{
7666
+ status: z.ZodLiteral<"unfinished">;
7667
+ termination: z.ZodOptional<z.ZodString>;
7668
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7669
+ }, z.core.$strict>]>;
7670
+ usage: z.ZodOptional<z.ZodObject<{
7671
+ prompt_tokens: z.ZodNumber;
7672
+ completion_tokens: z.ZodNumber;
7673
+ total_tokens: z.ZodNumber;
7674
+ reasoning_tokens: z.ZodOptional<z.ZodNumber>;
7675
+ cached_tokens: z.ZodOptional<z.ZodNumber>;
7676
+ cache_write_tokens: z.ZodOptional<z.ZodNumber>;
7677
+ audio_input_tokens: z.ZodOptional<z.ZodNumber>;
7678
+ audio_output_tokens: z.ZodOptional<z.ZodNumber>;
7679
+ }, z.core.$strict>>;
7680
+ }, z.core.$strict>>;
7681
+ declare const externalOperationRecordSchema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
7682
+ v: z.ZodLiteral<2>;
7683
+ id: z.ZodString;
7684
+ purpose: z.ZodOptional<z.ZodEnum<{
7685
+ ask: "ask";
7686
+ summary: "summary";
7687
+ judge: "judge";
7688
+ direct: "direct";
7689
+ }>>;
7690
+ startedAt: z.ZodOptional<z.ZodString>;
7691
+ endedAt: z.ZodOptional<z.ZodString>;
7692
+ ids: z.ZodObject<{
7693
+ executionId: z.ZodOptional<z.ZodString>;
7694
+ workflow: z.ZodOptional<z.ZodString>;
7695
+ agent: z.ZodOptional<z.ZodString>;
7696
+ askId: z.ZodOptional<z.ZodString>;
7697
+ parentAskId: z.ZodOptional<z.ZodString>;
7698
+ depth: z.ZodOptional<z.ZodNumber>;
7699
+ turn: z.ZodOptional<z.ZodNumber>;
7700
+ sessionId: z.ZodOptional<z.ZodString>;
7701
+ caseIndex: z.ZodOptional<z.ZodNumber>;
7702
+ scorer: z.ZodOptional<z.ZodString>;
7703
+ }, z.core.$strict>;
7704
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
7705
+ gate: z.ZodOptional<z.ZodObject<{
7706
+ retryReason: z.ZodEnum<{
7707
+ schema: "schema";
7708
+ validate: "validate";
7709
+ guardrail: "guardrail";
7710
+ }>;
7711
+ rejectedCallId: z.ZodOptional<z.ZodString>;
7712
+ correction: z.ZodOptional<z.ZodObject<{
7713
+ stage: z.ZodEnum<{
7714
+ schema: "schema";
7715
+ validate: "validate";
7716
+ guardrail: "guardrail";
7717
+ }>;
7718
+ reason: z.ZodOptional<z.ZodString>;
7719
+ feedbackMessage: z.ZodString;
7720
+ }, z.core.$strict>>;
7721
+ }, z.core.$strict>>;
7722
+ timing: z.ZodOptional<z.ZodObject<{
7723
+ queuedMs: z.ZodOptional<z.ZodNumber>;
7724
+ attempts: z.ZodOptional<z.ZodNumber>;
7725
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
7726
+ retryMs: z.ZodOptional<z.ZodNumber>;
7727
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
7728
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
7729
+ wireMs: z.ZodOptional<z.ZodNumber>;
7730
+ durationMs: z.ZodOptional<z.ZodNumber>;
7731
+ }, z.core.$strict>>;
7732
+ cost: z.ZodOptional<z.ZodNumber>;
7733
+ unpriced: z.ZodOptional<z.ZodBoolean>;
7734
+ captured: z.ZodObject<{
7735
+ fidelity: z.ZodLiteral<"runtime_request">;
7736
+ redacted: z.ZodBoolean;
7737
+ truncated: z.ZodBoolean;
7738
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
7739
+ omitted: z.ZodArray<z.ZodString>;
7740
+ replayable: z.ZodBoolean;
7741
+ reason: z.ZodOptional<z.ZodString>;
7742
+ }, z.core.$strict>;
7743
+ kind: z.ZodLiteral<"external">;
7744
+ name: z.ZodString;
7745
+ costProvenance: z.ZodOptional<z.ZodLiteral<"caller_reported">>;
7746
+ external: z.ZodOptional<z.ZodObject<{
7747
+ request: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7748
+ response: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7749
+ }, z.core.$strict>>;
7750
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
7751
+ status: z.ZodLiteral<"ok">;
7752
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7753
+ }, z.core.$strict>, z.ZodObject<{
7754
+ status: z.ZodLiteral<"error">;
7755
+ error: z.ZodObject<{
7756
+ name: z.ZodOptional<z.ZodString>;
7757
+ message: z.ZodString;
7758
+ code: z.ZodOptional<z.ZodString>;
7759
+ status: z.ZodOptional<z.ZodNumber>;
7760
+ retryable: z.ZodOptional<z.ZodBoolean>;
7761
+ requestId: z.ZodOptional<z.ZodString>;
7762
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
7763
+ }, z.core.$strict>;
7764
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7765
+ termination: z.ZodOptional<z.ZodString>;
7766
+ }, z.core.$strict>, z.ZodObject<{
7767
+ status: z.ZodLiteral<"error">;
7768
+ payloadOmitted: z.ZodLiteral<true>;
7769
+ termination: z.ZodOptional<z.ZodString>;
7770
+ }, z.core.$strict>, z.ZodObject<{
7771
+ status: z.ZodLiteral<"unfinished">;
7772
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
7773
+ termination: z.ZodOptional<z.ZodString>;
7774
+ }, z.core.$strict>]>;
7775
+ usage: z.ZodOptional<z.ZodObject<{
7776
+ inputTokens: z.ZodOptional<z.ZodNumber>;
7777
+ outputTokens: z.ZodOptional<z.ZodNumber>;
7778
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
7779
+ cachedTokens: z.ZodOptional<z.ZodNumber>;
7780
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
7781
+ audioSeconds: z.ZodOptional<z.ZodNumber>;
7782
+ }, z.core.$strict>>;
7783
+ }, z.core.$strict>>;
7784
+ declare const foldedOperationRecordSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
7785
+ v: z.ZodLiteral<2>;
7786
+ id: z.ZodString;
7787
+ purpose: z.ZodOptional<z.ZodEnum<{
7788
+ ask: "ask";
7789
+ summary: "summary";
7790
+ judge: "judge";
7791
+ direct: "direct";
7792
+ }>>;
7793
+ startedAt: z.ZodOptional<z.ZodString>;
7794
+ endedAt: z.ZodOptional<z.ZodString>;
7795
+ ids: z.ZodObject<{
7796
+ executionId: z.ZodOptional<z.ZodString>;
7797
+ workflow: z.ZodOptional<z.ZodString>;
7798
+ agent: z.ZodOptional<z.ZodString>;
7799
+ askId: z.ZodOptional<z.ZodString>;
7800
+ parentAskId: z.ZodOptional<z.ZodString>;
7801
+ depth: z.ZodOptional<z.ZodNumber>;
7802
+ turn: z.ZodOptional<z.ZodNumber>;
7803
+ sessionId: z.ZodOptional<z.ZodString>;
7804
+ caseIndex: z.ZodOptional<z.ZodNumber>;
7805
+ scorer: z.ZodOptional<z.ZodString>;
7806
+ }, z.core.$strict>;
7807
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
7808
+ gate: z.ZodOptional<z.ZodObject<{
7809
+ retryReason: z.ZodEnum<{
7810
+ schema: "schema";
7811
+ validate: "validate";
7812
+ guardrail: "guardrail";
7813
+ }>;
7814
+ rejectedCallId: z.ZodOptional<z.ZodString>;
7815
+ correction: z.ZodOptional<z.ZodObject<{
7816
+ stage: z.ZodEnum<{
7817
+ schema: "schema";
7818
+ validate: "validate";
7819
+ guardrail: "guardrail";
7820
+ }>;
7821
+ reason: z.ZodOptional<z.ZodString>;
7822
+ feedbackMessage: z.ZodString;
7823
+ }, z.core.$strict>>;
7824
+ }, z.core.$strict>>;
7825
+ timing: z.ZodOptional<z.ZodObject<{
7826
+ queuedMs: z.ZodOptional<z.ZodNumber>;
7827
+ attempts: z.ZodOptional<z.ZodNumber>;
7828
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
7829
+ retryMs: z.ZodOptional<z.ZodNumber>;
7830
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
7831
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
7832
+ wireMs: z.ZodOptional<z.ZodNumber>;
7833
+ durationMs: z.ZodOptional<z.ZodNumber>;
7834
+ }, z.core.$strict>>;
7835
+ cost: z.ZodOptional<z.ZodNumber>;
7836
+ costProvenance: z.ZodOptional<z.ZodEnum<{
7837
+ provider_reported: "provider_reported";
7838
+ price_table_estimate: "price_table_estimate";
7839
+ caller_reported: "caller_reported";
7840
+ adapter_reported: "adapter_reported";
7841
+ }>>;
7842
+ unpriced: z.ZodOptional<z.ZodBoolean>;
7843
+ captured: z.ZodObject<{
7844
+ fidelity: z.ZodLiteral<"runtime_request">;
7845
+ redacted: z.ZodBoolean;
7846
+ truncated: z.ZodBoolean;
7847
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
7848
+ omitted: z.ZodArray<z.ZodString>;
7849
+ replayable: z.ZodBoolean;
7850
+ reason: z.ZodOptional<z.ZodString>;
7851
+ }, z.core.$strict>;
7852
+ kind: z.ZodEnum<{
7853
+ chat: "chat";
7854
+ stream: "stream";
7855
+ }>;
7856
+ provider: z.ZodString;
7857
+ model: z.ZodString;
7858
+ request: z.ZodOptional<z.ZodObject<{
7859
+ messages: z.ZodArray<z.ZodObject<{
7860
+ role: z.ZodString;
7861
+ content: z.ZodNullable<z.ZodString>;
7862
+ input: z.ZodOptional<z.ZodObject<{
7863
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
7864
+ type: z.ZodLiteral<"text">;
7865
+ characters: z.ZodNumber;
7866
+ }, z.core.$strict>, z.ZodObject<{
7867
+ type: z.ZodLiteral<"image">;
7868
+ source: z.ZodEnum<{
7869
+ bytes: "bytes";
7870
+ base64: "base64";
7871
+ "provider-file": "provider-file";
7872
+ url: "url";
7873
+ }>;
7874
+ mediaType: z.ZodOptional<z.ZodString>;
7875
+ bytes: z.ZodOptional<z.ZodNumber>;
7876
+ locator: z.ZodOptional<z.ZodString>;
7877
+ label: z.ZodOptional<z.ZodString>;
7878
+ }, z.core.$strict>, z.ZodObject<{
7879
+ type: z.ZodLiteral<"audio">;
7880
+ source: z.ZodEnum<{
7881
+ bytes: "bytes";
7882
+ base64: "base64";
7883
+ "provider-file": "provider-file";
7884
+ }>;
7885
+ mediaType: z.ZodOptional<z.ZodString>;
7886
+ bytes: z.ZodOptional<z.ZodNumber>;
7887
+ locator: z.ZodOptional<z.ZodString>;
7888
+ label: z.ZodOptional<z.ZodString>;
7889
+ }, z.core.$strict>], "type">>;
7890
+ }, z.core.$strict>>;
7891
+ name: z.ZodOptional<z.ZodString>;
7892
+ agent: z.ZodOptional<z.ZodString>;
7893
+ origin: z.ZodOptional<z.ZodLiteral<"runtime">>;
7894
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7895
+ id: z.ZodString;
7896
+ type: z.ZodLiteral<"function">;
7897
+ function: z.ZodObject<{
7898
+ name: z.ZodString;
7899
+ arguments: z.ZodString;
7900
+ }, z.core.$strict>;
7901
+ }, z.core.$strict>>>;
7902
+ tool_call_id: z.ZodOptional<z.ZodString>;
7903
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7904
+ }, z.core.$strict>>;
7905
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
7906
+ name: z.ZodString;
7907
+ description: z.ZodOptional<z.ZodString>;
7908
+ parameters: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7909
+ strict: z.ZodOptional<z.ZodBoolean>;
7910
+ }, z.core.$strict>>>;
7911
+ responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7912
+ type: z.ZodLiteral<"text">;
7913
+ }, z.core.$strict>, z.ZodObject<{
7914
+ type: z.ZodLiteral<"json_object">;
7915
+ }, z.core.$strict>, z.ZodObject<{
7916
+ type: z.ZodLiteral<"json_schema">;
7917
+ json_schema: z.ZodObject<{
7918
+ name: z.ZodString;
7919
+ strict: z.ZodOptional<z.ZodBoolean>;
7920
+ schema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
7921
+ }, z.core.$strict>;
7922
+ }, z.core.$strict>], "type">>;
7923
+ options: z.ZodObject<{
7924
+ model: z.ZodString;
7925
+ temperature: z.ZodOptional<z.ZodNumber>;
7926
+ maxTokens: z.ZodOptional<z.ZodNumber>;
7927
+ effort: z.ZodOptional<z.ZodString>;
7928
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
7929
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
7930
+ toolChoice: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
7931
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
7932
+ promptCache: z.ZodOptional<z.ZodBoolean>;
7933
+ }, z.core.$strict>;
7934
+ providerOptionKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
7935
+ }, z.core.$strict>>;
7936
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
7937
+ status: z.ZodLiteral<"ok">;
7938
+ response: z.ZodObject<{
7939
+ content: z.ZodString;
7940
+ thinking: z.ZodOptional<z.ZodString>;
7941
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7942
+ id: z.ZodString;
7943
+ type: z.ZodLiteral<"function">;
7944
+ function: z.ZodObject<{
7945
+ name: z.ZodString;
7946
+ arguments: z.ZodString;
7947
+ }, z.core.$strict>;
7948
+ }, z.core.$strict>>>;
7949
+ finishReason: z.ZodOptional<z.ZodEnum<{
7950
+ length: "length";
7951
+ stop: "stop";
7952
+ tool_calls: "tool_calls";
7953
+ content_filter: "content_filter";
7954
+ refusal: "refusal";
7955
+ other: "other";
7956
+ }>>;
7957
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7958
+ responseId: z.ZodOptional<z.ZodString>;
7959
+ responseModel: z.ZodOptional<z.ZodString>;
7960
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
7961
+ }, z.core.$strict>;
7962
+ }, z.core.$strict>, z.ZodObject<{
7963
+ status: z.ZodLiteral<"ok">;
7964
+ payloadOmitted: z.ZodLiteral<true>;
7965
+ finishReason: z.ZodOptional<z.ZodEnum<{
7966
+ length: "length";
7967
+ stop: "stop";
7968
+ tool_calls: "tool_calls";
7969
+ content_filter: "content_filter";
7970
+ refusal: "refusal";
7971
+ other: "other";
7972
+ }>>;
7973
+ rawFinishReason: z.ZodOptional<z.ZodString>;
7974
+ responseId: z.ZodOptional<z.ZodString>;
7975
+ responseModel: z.ZodOptional<z.ZodString>;
7976
+ }, z.core.$strict>, z.ZodObject<{
7977
+ status: z.ZodLiteral<"error">;
7978
+ error: z.ZodObject<{
7979
+ name: z.ZodOptional<z.ZodString>;
7980
+ message: z.ZodString;
7981
+ code: z.ZodOptional<z.ZodString>;
7982
+ status: z.ZodOptional<z.ZodNumber>;
7983
+ retryable: z.ZodOptional<z.ZodBoolean>;
7984
+ requestId: z.ZodOptional<z.ZodString>;
7985
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
7986
+ }, z.core.$strict>;
7987
+ partial: z.ZodOptional<z.ZodObject<{
7988
+ content: z.ZodOptional<z.ZodString>;
7989
+ thinking: z.ZodOptional<z.ZodString>;
7990
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
7991
+ id: z.ZodString;
7992
+ type: z.ZodLiteral<"function">;
7993
+ function: z.ZodObject<{
7994
+ name: z.ZodString;
7995
+ arguments: z.ZodString;
7996
+ }, z.core.$strict>;
7997
+ }, z.core.$strict>>>;
7998
+ }, z.core.$strict>>;
7999
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8000
+ termination: z.ZodOptional<z.ZodString>;
8001
+ }, z.core.$strict>, z.ZodObject<{
8002
+ status: z.ZodLiteral<"error">;
8003
+ payloadOmitted: z.ZodLiteral<true>;
8004
+ partial: z.ZodOptional<z.ZodObject<{
8005
+ content: z.ZodOptional<z.ZodString>;
8006
+ thinking: z.ZodOptional<z.ZodString>;
8007
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
8008
+ id: z.ZodString;
8009
+ type: z.ZodLiteral<"function">;
8010
+ function: z.ZodObject<{
8011
+ name: z.ZodString;
8012
+ arguments: z.ZodString;
8013
+ }, z.core.$strict>;
8014
+ }, z.core.$strict>>>;
8015
+ }, z.core.$strict>>;
8016
+ termination: z.ZodOptional<z.ZodString>;
8017
+ }, z.core.$strict>, z.ZodObject<{
8018
+ status: z.ZodEnum<{
8019
+ aborted: "aborted";
8020
+ stalled: "stalled";
8021
+ consumer_closed: "consumer_closed";
8022
+ }>;
8023
+ partial: z.ZodOptional<z.ZodObject<{
8024
+ content: z.ZodOptional<z.ZodString>;
8025
+ thinking: z.ZodOptional<z.ZodString>;
8026
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
8027
+ id: z.ZodString;
8028
+ type: z.ZodLiteral<"function">;
8029
+ function: z.ZodObject<{
8030
+ name: z.ZodString;
8031
+ arguments: z.ZodString;
8032
+ }, z.core.$strict>;
8033
+ }, z.core.$strict>>>;
8034
+ }, z.core.$strict>>;
8035
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8036
+ termination: z.ZodOptional<z.ZodString>;
8037
+ }, z.core.$strict>, z.ZodObject<{
8038
+ status: z.ZodLiteral<"unfinished">;
8039
+ termination: z.ZodOptional<z.ZodString>;
8040
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8041
+ }, z.core.$strict>]>;
8042
+ usage: z.ZodOptional<z.ZodObject<{
8043
+ prompt_tokens: z.ZodNumber;
8044
+ completion_tokens: z.ZodNumber;
8045
+ total_tokens: z.ZodNumber;
8046
+ reasoning_tokens: z.ZodOptional<z.ZodNumber>;
8047
+ cached_tokens: z.ZodOptional<z.ZodNumber>;
8048
+ cache_write_tokens: z.ZodOptional<z.ZodNumber>;
8049
+ audio_input_tokens: z.ZodOptional<z.ZodNumber>;
8050
+ audio_output_tokens: z.ZodOptional<z.ZodNumber>;
8051
+ }, z.core.$strict>>;
8052
+ }, z.core.$strict>>, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodObject<{
8053
+ v: z.ZodLiteral<2>;
8054
+ id: z.ZodString;
8055
+ purpose: z.ZodOptional<z.ZodEnum<{
8056
+ ask: "ask";
8057
+ summary: "summary";
8058
+ judge: "judge";
8059
+ direct: "direct";
8060
+ }>>;
8061
+ startedAt: z.ZodOptional<z.ZodString>;
8062
+ endedAt: z.ZodOptional<z.ZodString>;
8063
+ ids: z.ZodObject<{
8064
+ executionId: z.ZodOptional<z.ZodString>;
8065
+ workflow: z.ZodOptional<z.ZodString>;
8066
+ agent: z.ZodOptional<z.ZodString>;
8067
+ askId: z.ZodOptional<z.ZodString>;
8068
+ parentAskId: z.ZodOptional<z.ZodString>;
8069
+ depth: z.ZodOptional<z.ZodNumber>;
8070
+ turn: z.ZodOptional<z.ZodNumber>;
8071
+ sessionId: z.ZodOptional<z.ZodString>;
8072
+ caseIndex: z.ZodOptional<z.ZodNumber>;
8073
+ scorer: z.ZodOptional<z.ZodString>;
8074
+ }, z.core.$strict>;
8075
+ attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
8076
+ gate: z.ZodOptional<z.ZodObject<{
8077
+ retryReason: z.ZodEnum<{
8078
+ schema: "schema";
8079
+ validate: "validate";
8080
+ guardrail: "guardrail";
8081
+ }>;
8082
+ rejectedCallId: z.ZodOptional<z.ZodString>;
8083
+ correction: z.ZodOptional<z.ZodObject<{
8084
+ stage: z.ZodEnum<{
8085
+ schema: "schema";
8086
+ validate: "validate";
8087
+ guardrail: "guardrail";
8088
+ }>;
8089
+ reason: z.ZodOptional<z.ZodString>;
8090
+ feedbackMessage: z.ZodString;
8091
+ }, z.core.$strict>>;
8092
+ }, z.core.$strict>>;
8093
+ timing: z.ZodOptional<z.ZodObject<{
8094
+ queuedMs: z.ZodOptional<z.ZodNumber>;
8095
+ attempts: z.ZodOptional<z.ZodNumber>;
8096
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
8097
+ retryMs: z.ZodOptional<z.ZodNumber>;
8098
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
8099
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
8100
+ wireMs: z.ZodOptional<z.ZodNumber>;
8101
+ durationMs: z.ZodOptional<z.ZodNumber>;
8102
+ }, z.core.$strict>>;
8103
+ cost: z.ZodOptional<z.ZodNumber>;
8104
+ unpriced: z.ZodOptional<z.ZodBoolean>;
8105
+ captured: z.ZodObject<{
8106
+ fidelity: z.ZodLiteral<"runtime_request">;
8107
+ redacted: z.ZodBoolean;
8108
+ truncated: z.ZodBoolean;
8109
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
8110
+ omitted: z.ZodArray<z.ZodString>;
8111
+ replayable: z.ZodBoolean;
8112
+ reason: z.ZodOptional<z.ZodString>;
8113
+ }, z.core.$strict>;
8114
+ kind: z.ZodLiteral<"external">;
8115
+ name: z.ZodString;
8116
+ costProvenance: z.ZodOptional<z.ZodLiteral<"caller_reported">>;
8117
+ external: z.ZodOptional<z.ZodObject<{
8118
+ request: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
8119
+ response: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
8120
+ }, z.core.$strict>>;
8121
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
8122
+ status: z.ZodLiteral<"ok">;
8123
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8124
+ }, z.core.$strict>, z.ZodObject<{
8125
+ status: z.ZodLiteral<"error">;
8126
+ error: z.ZodObject<{
8127
+ name: z.ZodOptional<z.ZodString>;
8128
+ message: z.ZodString;
8129
+ code: z.ZodOptional<z.ZodString>;
8130
+ status: z.ZodOptional<z.ZodNumber>;
8131
+ retryable: z.ZodOptional<z.ZodBoolean>;
8132
+ requestId: z.ZodOptional<z.ZodString>;
8133
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
8134
+ }, z.core.$strict>;
8135
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8136
+ termination: z.ZodOptional<z.ZodString>;
8137
+ }, z.core.$strict>, z.ZodObject<{
8138
+ status: z.ZodLiteral<"error">;
8139
+ payloadOmitted: z.ZodLiteral<true>;
8140
+ termination: z.ZodOptional<z.ZodString>;
8141
+ }, z.core.$strict>, z.ZodObject<{
8142
+ status: z.ZodLiteral<"unfinished">;
8143
+ payloadOmitted: z.ZodOptional<z.ZodLiteral<true>>;
8144
+ termination: z.ZodOptional<z.ZodString>;
8145
+ }, z.core.$strict>]>;
8146
+ usage: z.ZodOptional<z.ZodObject<{
8147
+ inputTokens: z.ZodOptional<z.ZodNumber>;
8148
+ outputTokens: z.ZodOptional<z.ZodNumber>;
8149
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
8150
+ cachedTokens: z.ZodOptional<z.ZodNumber>;
8151
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
8152
+ audioSeconds: z.ZodOptional<z.ZodNumber>;
8153
+ }, z.core.$strict>>;
8154
+ }, z.core.$strict>>]>;
8155
+ type ModelCallRecord = z.infer<typeof modelSchema>;
8156
+ type ExternalOperationRecord = z.infer<typeof externalSchema>;
8157
+ type FoldedOperationRecord = ModelCallRecord | ExternalOperationRecord;
8158
+ declare const capturedJournalLineSchema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodUnion<readonly [z.ZodObject<{
8159
+ v: z.ZodLiteral<1>;
8160
+ phase: z.ZodEnum<{
8161
+ start: "start";
8162
+ attempt: "attempt";
8163
+ end: "end";
8164
+ }>;
8165
+ operationId: z.ZodString;
8166
+ caseIndex: z.ZodOptional<z.ZodNumber>;
8167
+ scorer: z.ZodOptional<z.ZodString>;
8168
+ executionId: z.ZodOptional<z.ZodString>;
8169
+ workflow: z.ZodOptional<z.ZodString>;
8170
+ agent: z.ZodOptional<z.ZodString>;
8171
+ depth: z.ZodOptional<z.ZodNumber>;
8172
+ sessionId: z.ZodOptional<z.ZodString>;
8173
+ purpose: z.ZodOptional<z.ZodEnum<{
8174
+ ask: "ask";
8175
+ summary: "summary";
8176
+ judge: "judge";
8177
+ direct: "direct";
8178
+ }>>;
8179
+ askId: z.ZodOptional<z.ZodString>;
8180
+ parentAskId: z.ZodOptional<z.ZodString>;
8181
+ turn: z.ZodOptional<z.ZodNumber>;
8182
+ retryReason: z.ZodOptional<z.ZodEnum<{
8183
+ schema: "schema";
8184
+ validate: "validate";
8185
+ guardrail: "guardrail";
8186
+ }>>;
8187
+ rejectedCallId: z.ZodOptional<z.ZodString>;
8188
+ startedAt: z.ZodOptional<z.ZodString>;
8189
+ endedAt: z.ZodOptional<z.ZodString>;
8190
+ durationMs: z.ZodOptional<z.ZodNumber>;
8191
+ timing: z.ZodOptional<z.ZodObject<{
8192
+ queuedMs: z.ZodOptional<z.ZodNumber>;
8193
+ attempts: z.ZodOptional<z.ZodNumber>;
8194
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
8195
+ retryMs: z.ZodOptional<z.ZodNumber>;
8196
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
8197
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
8198
+ wireMs: z.ZodOptional<z.ZodNumber>;
8199
+ durationMs: z.ZodOptional<z.ZodNumber>;
8200
+ }, z.core.$strict>>;
8201
+ transportAttempts: z.ZodNumber;
8202
+ outcomeStatus: z.ZodOptional<z.ZodEnum<{
8203
+ ok: "ok";
8204
+ error: "error";
8205
+ aborted: "aborted";
8206
+ stalled: "stalled";
8207
+ consumer_closed: "consumer_closed";
8208
+ unfinished: "unfinished";
8209
+ }>>;
8210
+ cost: z.ZodOptional<z.ZodNumber>;
8211
+ costProvenance: z.ZodOptional<z.ZodEnum<{
8212
+ provider_reported: "provider_reported";
8213
+ price_table_estimate: "price_table_estimate";
8214
+ caller_reported: "caller_reported";
8215
+ adapter_reported: "adapter_reported";
8216
+ }>>;
8217
+ finishReason: z.ZodOptional<z.ZodEnum<{
8218
+ length: "length";
8219
+ stop: "stop";
8220
+ tool_calls: "tool_calls";
8221
+ content_filter: "content_filter";
8222
+ refusal: "refusal";
8223
+ other: "other";
8224
+ }>>;
8225
+ rawFinishReason: z.ZodOptional<z.ZodString>;
8226
+ responseId: z.ZodOptional<z.ZodString>;
8227
+ responseModel: z.ZodOptional<z.ZodString>;
8228
+ error: z.ZodOptional<z.ZodObject<{
8229
+ name: z.ZodOptional<z.ZodString>;
8230
+ message: z.ZodString;
8231
+ code: z.ZodOptional<z.ZodString>;
8232
+ status: z.ZodOptional<z.ZodNumber>;
8233
+ retryable: z.ZodOptional<z.ZodBoolean>;
8234
+ requestId: z.ZodOptional<z.ZodString>;
8235
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
8236
+ }, z.core.$strict>>;
8237
+ termination: z.ZodOptional<z.ZodString>;
8238
+ correction: z.ZodOptional<z.ZodObject<{
8239
+ stage: z.ZodEnum<{
8240
+ schema: "schema";
8241
+ validate: "validate";
8242
+ guardrail: "guardrail";
8243
+ }>;
8244
+ reason: z.ZodOptional<z.ZodString>;
8245
+ feedbackMessage: z.ZodString;
8246
+ }, z.core.$strict>>;
8247
+ captured: z.ZodObject<{
8248
+ truncated: z.ZodBoolean;
8249
+ omitted: z.ZodArray<z.ZodString>;
8250
+ reason: z.ZodOptional<z.ZodString>;
8251
+ fidelity: z.ZodLiteral<"runtime_request">;
8252
+ redacted: z.ZodBoolean;
8253
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
8254
+ }, z.core.$strict>;
8255
+ bytes: z.ZodOptional<z.ZodNumber>;
8256
+ kind: z.ZodEnum<{
8257
+ chat: "chat";
8258
+ stream: "stream";
8259
+ }>;
8260
+ provider: z.ZodString;
8261
+ model: z.ZodString;
8262
+ request: z.ZodOptional<z.ZodObject<{
8263
+ messages: z.ZodArray<z.ZodObject<{
8264
+ role: z.ZodString;
8265
+ content: z.ZodNullable<z.ZodString>;
8266
+ input: z.ZodOptional<z.ZodObject<{
8267
+ parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
8268
+ type: z.ZodLiteral<"text">;
8269
+ characters: z.ZodNumber;
8270
+ }, z.core.$strict>, z.ZodObject<{
8271
+ type: z.ZodLiteral<"image">;
8272
+ source: z.ZodEnum<{
8273
+ bytes: "bytes";
8274
+ base64: "base64";
8275
+ "provider-file": "provider-file";
8276
+ url: "url";
8277
+ }>;
8278
+ mediaType: z.ZodOptional<z.ZodString>;
8279
+ bytes: z.ZodOptional<z.ZodNumber>;
8280
+ locator: z.ZodOptional<z.ZodString>;
8281
+ label: z.ZodOptional<z.ZodString>;
8282
+ }, z.core.$strict>, z.ZodObject<{
8283
+ type: z.ZodLiteral<"audio">;
8284
+ source: z.ZodEnum<{
8285
+ bytes: "bytes";
8286
+ base64: "base64";
8287
+ "provider-file": "provider-file";
8288
+ }>;
8289
+ mediaType: z.ZodOptional<z.ZodString>;
8290
+ bytes: z.ZodOptional<z.ZodNumber>;
8291
+ locator: z.ZodOptional<z.ZodString>;
8292
+ label: z.ZodOptional<z.ZodString>;
8293
+ }, z.core.$strict>], "type">>;
8294
+ }, z.core.$strict>>;
8295
+ name: z.ZodOptional<z.ZodString>;
8296
+ agent: z.ZodOptional<z.ZodString>;
8297
+ origin: z.ZodOptional<z.ZodLiteral<"runtime">>;
8298
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
8299
+ id: z.ZodString;
8300
+ type: z.ZodLiteral<"function">;
8301
+ function: z.ZodObject<{
8302
+ name: z.ZodString;
8303
+ arguments: z.ZodString;
8304
+ }, z.core.$strict>;
8305
+ }, z.core.$strict>>>;
8306
+ tool_call_id: z.ZodOptional<z.ZodString>;
8307
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
8308
+ }, z.core.$strict>>;
8309
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
8310
+ name: z.ZodString;
8311
+ description: z.ZodOptional<z.ZodString>;
8312
+ parameters: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
8313
+ strict: z.ZodOptional<z.ZodBoolean>;
8314
+ }, z.core.$strict>>>;
8315
+ responseFormat: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
8316
+ type: z.ZodLiteral<"text">;
8317
+ }, z.core.$strict>, z.ZodObject<{
8318
+ type: z.ZodLiteral<"json_object">;
8319
+ }, z.core.$strict>, z.ZodObject<{
8320
+ type: z.ZodLiteral<"json_schema">;
8321
+ json_schema: z.ZodObject<{
8322
+ name: z.ZodString;
8323
+ strict: z.ZodOptional<z.ZodBoolean>;
8324
+ schema: z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>;
8325
+ }, z.core.$strict>;
8326
+ }, z.core.$strict>], "type">>;
8327
+ options: z.ZodObject<{
8328
+ model: z.ZodString;
8329
+ temperature: z.ZodOptional<z.ZodNumber>;
8330
+ maxTokens: z.ZodOptional<z.ZodNumber>;
8331
+ effort: z.ZodOptional<z.ZodString>;
8332
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
8333
+ includeThoughts: z.ZodOptional<z.ZodBoolean>;
8334
+ toolChoice: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
8335
+ stop: z.ZodOptional<z.ZodArray<z.ZodString>>;
8336
+ promptCache: z.ZodOptional<z.ZodBoolean>;
8337
+ }, z.core.$strict>;
8338
+ providerOptionKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
8339
+ }, z.core.$strict>>;
8340
+ response: z.ZodOptional<z.ZodObject<{
8341
+ content: z.ZodString;
8342
+ thinking: z.ZodOptional<z.ZodString>;
8343
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
8344
+ id: z.ZodString;
8345
+ type: z.ZodLiteral<"function">;
8346
+ function: z.ZodObject<{
8347
+ name: z.ZodString;
8348
+ arguments: z.ZodString;
8349
+ }, z.core.$strict>;
8350
+ }, z.core.$strict>>>;
8351
+ finishReason: z.ZodOptional<z.ZodEnum<{
8352
+ length: "length";
8353
+ stop: "stop";
8354
+ tool_calls: "tool_calls";
8355
+ content_filter: "content_filter";
8356
+ refusal: "refusal";
8357
+ other: "other";
8358
+ }>>;
8359
+ rawFinishReason: z.ZodOptional<z.ZodString>;
8360
+ responseId: z.ZodOptional<z.ZodString>;
8361
+ responseModel: z.ZodOptional<z.ZodString>;
8362
+ providerMetadata: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>>;
8363
+ usage: z.ZodOptional<z.ZodObject<{
8364
+ prompt_tokens: z.ZodNumber;
8365
+ completion_tokens: z.ZodNumber;
8366
+ total_tokens: z.ZodNumber;
8367
+ reasoning_tokens: z.ZodOptional<z.ZodNumber>;
8368
+ cached_tokens: z.ZodOptional<z.ZodNumber>;
8369
+ cache_write_tokens: z.ZodOptional<z.ZodNumber>;
8370
+ audio_input_tokens: z.ZodOptional<z.ZodNumber>;
8371
+ audio_output_tokens: z.ZodOptional<z.ZodNumber>;
8372
+ }, z.core.$strict>>;
8373
+ cost: z.ZodOptional<z.ZodNumber>;
8374
+ costProvenance: z.ZodOptional<z.ZodEnum<{
8375
+ provider_reported: "provider_reported";
8376
+ price_table_estimate: "price_table_estimate";
8377
+ adapter_reported: "adapter_reported";
8378
+ }>>;
8379
+ timing: z.ZodOptional<z.ZodObject<{
8380
+ queuedMs: z.ZodOptional<z.ZodNumber>;
8381
+ attempts: z.ZodOptional<z.ZodNumber>;
8382
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
8383
+ retryMs: z.ZodOptional<z.ZodNumber>;
8384
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
8385
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
8386
+ wireMs: z.ZodOptional<z.ZodNumber>;
8387
+ durationMs: z.ZodOptional<z.ZodNumber>;
8388
+ }, z.core.$strict>>;
8389
+ }, z.core.$strict>>;
8390
+ partial: z.ZodOptional<z.ZodObject<{
8391
+ content: z.ZodOptional<z.ZodString>;
8392
+ thinking: z.ZodOptional<z.ZodString>;
8393
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
8394
+ id: z.ZodString;
8395
+ type: z.ZodLiteral<"function">;
8396
+ function: z.ZodObject<{
8397
+ name: z.ZodString;
8398
+ arguments: z.ZodString;
8399
+ }, z.core.$strict>;
8400
+ }, z.core.$strict>>>;
8401
+ }, z.core.$strict>>;
8402
+ usage: z.ZodOptional<z.ZodObject<{
8403
+ prompt_tokens: z.ZodNumber;
8404
+ completion_tokens: z.ZodNumber;
8405
+ total_tokens: z.ZodNumber;
8406
+ reasoning_tokens: z.ZodOptional<z.ZodNumber>;
8407
+ cached_tokens: z.ZodOptional<z.ZodNumber>;
8408
+ cache_write_tokens: z.ZodOptional<z.ZodNumber>;
8409
+ audio_input_tokens: z.ZodOptional<z.ZodNumber>;
8410
+ audio_output_tokens: z.ZodOptional<z.ZodNumber>;
8411
+ }, z.core.$strict>>;
8412
+ }, z.core.$catchall<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>, z.ZodObject<{
8413
+ v: z.ZodLiteral<1>;
8414
+ phase: z.ZodEnum<{
8415
+ start: "start";
8416
+ attempt: "attempt";
8417
+ end: "end";
8418
+ }>;
8419
+ operationId: z.ZodString;
8420
+ caseIndex: z.ZodOptional<z.ZodNumber>;
8421
+ scorer: z.ZodOptional<z.ZodString>;
8422
+ executionId: z.ZodOptional<z.ZodString>;
8423
+ workflow: z.ZodOptional<z.ZodString>;
8424
+ agent: z.ZodOptional<z.ZodString>;
8425
+ depth: z.ZodOptional<z.ZodNumber>;
8426
+ sessionId: z.ZodOptional<z.ZodString>;
8427
+ purpose: z.ZodOptional<z.ZodEnum<{
8428
+ ask: "ask";
8429
+ summary: "summary";
8430
+ judge: "judge";
8431
+ direct: "direct";
8432
+ }>>;
8433
+ askId: z.ZodOptional<z.ZodString>;
8434
+ parentAskId: z.ZodOptional<z.ZodString>;
8435
+ turn: z.ZodOptional<z.ZodNumber>;
8436
+ retryReason: z.ZodOptional<z.ZodEnum<{
8437
+ schema: "schema";
8438
+ validate: "validate";
8439
+ guardrail: "guardrail";
8440
+ }>>;
8441
+ rejectedCallId: z.ZodOptional<z.ZodString>;
8442
+ startedAt: z.ZodOptional<z.ZodString>;
8443
+ endedAt: z.ZodOptional<z.ZodString>;
8444
+ durationMs: z.ZodOptional<z.ZodNumber>;
8445
+ timing: z.ZodOptional<z.ZodObject<{
8446
+ queuedMs: z.ZodOptional<z.ZodNumber>;
8447
+ attempts: z.ZodOptional<z.ZodNumber>;
8448
+ rateLimitRetries: z.ZodOptional<z.ZodNumber>;
8449
+ retryMs: z.ZodOptional<z.ZodNumber>;
8450
+ ttfbMs: z.ZodOptional<z.ZodNumber>;
8451
+ firstTokenMs: z.ZodOptional<z.ZodNumber>;
8452
+ wireMs: z.ZodOptional<z.ZodNumber>;
8453
+ durationMs: z.ZodOptional<z.ZodNumber>;
8454
+ }, z.core.$strict>>;
8455
+ transportAttempts: z.ZodNumber;
8456
+ outcomeStatus: z.ZodOptional<z.ZodEnum<{
8457
+ ok: "ok";
8458
+ error: "error";
8459
+ aborted: "aborted";
8460
+ stalled: "stalled";
8461
+ consumer_closed: "consumer_closed";
8462
+ unfinished: "unfinished";
8463
+ }>>;
8464
+ cost: z.ZodOptional<z.ZodNumber>;
8465
+ costProvenance: z.ZodOptional<z.ZodEnum<{
8466
+ provider_reported: "provider_reported";
8467
+ price_table_estimate: "price_table_estimate";
8468
+ caller_reported: "caller_reported";
8469
+ adapter_reported: "adapter_reported";
8470
+ }>>;
8471
+ finishReason: z.ZodOptional<z.ZodEnum<{
8472
+ length: "length";
8473
+ stop: "stop";
8474
+ tool_calls: "tool_calls";
8475
+ content_filter: "content_filter";
8476
+ refusal: "refusal";
8477
+ other: "other";
8478
+ }>>;
8479
+ rawFinishReason: z.ZodOptional<z.ZodString>;
8480
+ responseId: z.ZodOptional<z.ZodString>;
8481
+ responseModel: z.ZodOptional<z.ZodString>;
8482
+ error: z.ZodOptional<z.ZodObject<{
8483
+ name: z.ZodOptional<z.ZodString>;
8484
+ message: z.ZodString;
8485
+ code: z.ZodOptional<z.ZodString>;
8486
+ status: z.ZodOptional<z.ZodNumber>;
8487
+ retryable: z.ZodOptional<z.ZodBoolean>;
8488
+ requestId: z.ZodOptional<z.ZodString>;
8489
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
8490
+ }, z.core.$strict>>;
8491
+ termination: z.ZodOptional<z.ZodString>;
8492
+ correction: z.ZodOptional<z.ZodObject<{
8493
+ stage: z.ZodEnum<{
8494
+ schema: "schema";
8495
+ validate: "validate";
8496
+ guardrail: "guardrail";
8497
+ }>;
8498
+ reason: z.ZodOptional<z.ZodString>;
8499
+ feedbackMessage: z.ZodString;
8500
+ }, z.core.$strict>>;
8501
+ captured: z.ZodObject<{
8502
+ truncated: z.ZodBoolean;
8503
+ omitted: z.ZodArray<z.ZodString>;
8504
+ reason: z.ZodOptional<z.ZodString>;
8505
+ fidelity: z.ZodLiteral<"runtime_request">;
8506
+ redacted: z.ZodBoolean;
8507
+ continuityCaptured: z.ZodOptional<z.ZodLiteral<true>>;
8508
+ }, z.core.$strict>;
8509
+ bytes: z.ZodOptional<z.ZodNumber>;
8510
+ kind: z.ZodLiteral<"external">;
8511
+ name: z.ZodString;
8512
+ usage: z.ZodOptional<z.ZodObject<{
8513
+ inputTokens: z.ZodOptional<z.ZodNumber>;
8514
+ outputTokens: z.ZodOptional<z.ZodNumber>;
8515
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
8516
+ cachedTokens: z.ZodOptional<z.ZodNumber>;
8517
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
8518
+ audioSeconds: z.ZodOptional<z.ZodNumber>;
8519
+ }, z.core.$strict>>;
8520
+ external: z.ZodOptional<z.ZodObject<{
8521
+ request: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
8522
+ response: z.ZodOptional<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>;
8523
+ }, z.core.$strict>>;
8524
+ }, z.core.$catchall<z.ZodPipe<z.ZodTransform<CapturedJsonValue, unknown>, z.ZodCustom<CapturedJsonValue, CapturedJsonValue>>>>]>>;
8525
+ /** Assemble interleaved v1 phase lines into one validated v2 operation per id. */
8526
+ declare function foldJournal(lines: Iterable<CapturedRequestRecord | unknown>): FoldedOperationRecord[];
8527
+ /** Return a redacted copy while retaining correlation, timing, usage and cost. */
8528
+ declare function redactModelCallRecord<T extends FoldedOperationRecord>(record: T): T;
8529
+
6680
8530
  /**
6681
8531
  * Module-export resolution helpers for dynamically-imported user modules.
6682
8532
  *
@@ -7268,25 +9118,6 @@ declare const REDACTION_RULES: {
7268
9118
  declare function redactEvent(event: AxlEvent): AxlEvent;
7269
9119
  /** Redact either persisted schema without reinterpreting its lifecycle. */
7270
9120
  declare function redactHistoricalEvent(event: HistoricalAxlEvent): HistoricalAxlEvent;
7271
- /**
7272
- * Scrub a captured request record before it reaches a diagnostics sink.
7273
- *
7274
- * The same policy `agent_call_start` / `agent_call_end` / the gate events
7275
- * already apply, expressed over the capture record's shape: prompts, responses,
7276
- * gate reasons and correction text are user/LLM content and become
7277
- * `[redacted]`; roles, tool NAMES, JSON-Schema parameters, option scalars,
7278
- * usage, cost, timing and the `providerOptions` key list are structural and
7279
- * survive, because a compliance-mode reader still has to be able to tell a
7280
- * tool-choice bug from a token-budget bug.
7281
- *
7282
- * Rich media never had bytes in the record to begin with (the projection in
7283
- * `diagnostics/capture.ts` replaces them with descriptors), but a descriptor's
7284
- * `locator` and `label` can name a file or a URL, so they are scrubbed here
7285
- * exactly as `redactInputDescriptor` scrubs them on the trace rail.
7286
- *
7287
- * Pure, like every other rule in this file: the caller decides whether
7288
- * redaction is on, and this function unconditionally scrubs when called.
7289
- */
7290
9121
  declare function redactCapturedRequest(record: CapturedRequestRecord): CapturedRequestRecord;
7291
9122
 
7292
9123
  /**
@@ -7884,6 +9715,24 @@ declare class OpenRouterTranscriptionProvider implements TranscriptionProvider {
7884
9715
  private resolveKey;
7885
9716
  }
7886
9717
 
9718
+ /** Options for {@link MemoryStore}. */
9719
+ type MemoryStoreOptions = {
9720
+ /**
9721
+ * History retention in seconds. A positive number expires a record that
9722
+ * many seconds after it is saved; `null` or unset keeps it. See
9723
+ * {@link HistoryTtls} for how each category's window is counted.
9724
+ */
9725
+ ttls?: HistoryTtls;
9726
+ /**
9727
+ * Maximum number of execution-history records kept. When a save goes over
9728
+ * the limit, the oldest records in listing order (earliest `startedAt`,
9729
+ * then lowest `executionId`) are removed. A positive integer or `Infinity`
9730
+ * (no limit). Default: 1 000.
9731
+ */
9732
+ maxExecutions?: number;
9733
+ /** Clock in epoch milliseconds, used for retention. Defaults to `Date.now`. */
9734
+ now?: () => number;
9735
+ };
7887
9736
  /**
7888
9737
  * In-memory implementation of StateStore.
7889
9738
  * Fast for development and testing, but lost on process restart.
@@ -7892,6 +9741,11 @@ declare class OpenRouterTranscriptionProvider implements TranscriptionProvider {
7892
9741
  * status "waiting") is persisted to a temporary file so it survives restarts.
7893
9742
  * This is the one exception to "memory means ephemeral" — because a human
7894
9743
  * could take hours to respond, and losing that state is unacceptable.
9744
+ *
9745
+ * History can be bounded by time (`ttls`) and by count (`maxExecutions`,
9746
+ * which keeps the newest 1 000 runs by default).
9747
+ * Expired records are never returned and are physically removed, a bounded
9748
+ * batch at a time, on later saves of the same kind.
7895
9749
  */
7896
9750
  declare class MemoryStore implements StateStore {
7897
9751
  private checkpoints;
@@ -7900,9 +9754,23 @@ declare class MemoryStore implements StateStore {
7900
9754
  private decisions;
7901
9755
  private executionStates;
7902
9756
  private memories;
9757
+ /**
9758
+ * Iteration order is last-save order: a save deletes and re-inserts its key.
9759
+ * With one retention per store and a clock that does not run backwards, that
9760
+ * is also expiry order, which lets the prune stop at the first live record.
9761
+ */
7903
9762
  private executionHistory;
9763
+ /** Every key in `executionHistory`, sorted oldest first in listing order. */
9764
+ private executionOrder;
9765
+ /**
9766
+ * Iteration order is first-write order (a re-save keeps the key's position
9767
+ * and its expiry), which is also expiry order for the same reason as above.
9768
+ */
7904
9769
  private evalHistory;
7905
- constructor();
9770
+ private readonly ttls;
9771
+ private readonly maxExecutions;
9772
+ private readonly now;
9773
+ constructor(options?: MemoryStoreOptions);
7906
9774
  saveCheckpoint(executionId: string, name: string, data: unknown): Promise<void>;
7907
9775
  getCheckpoint(executionId: string, name: string): Promise<unknown | null>;
7908
9776
  saveSession(sessionId: string, history: ChatMessage[]): Promise<void>;
@@ -7925,18 +9793,64 @@ declare class MemoryStore implements StateStore {
7925
9793
  deleteMemory(scope: string, key: string): Promise<void>;
7926
9794
  saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
7927
9795
  getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
7928
- listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
9796
+ /** Supports `listExecutions(limit, { cursor })`. */
9797
+ readonly historyPaging = true;
9798
+ listExecutions(limit?: number, options?: {
9799
+ cursor?: ExecutionCursor;
9800
+ }): Promise<HistoricalExecutionInfo[]>;
7929
9801
  deleteExecution(executionId: string): Promise<boolean>;
9802
+ /**
9803
+ * Write an eval history row. Retention counts from the row's first write:
9804
+ * re-saving a live row keeps its expiry (and its position in expiry order).
9805
+ * A row that has already expired is replaced as a new one.
9806
+ */
7930
9807
  saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
7931
- /** Update-only write: see `StateStore.updateEvalResult`. */
9808
+ /** Update-only write: see `StateStore.updateEvalResult`. Never changes retention. */
7932
9809
  updateEvalResult(entry: EvalHistoryEntry): Promise<boolean>;
7933
9810
  listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
7934
9811
  deleteEvalResult(id: string): Promise<boolean>;
7935
- /** In-memory history never expires on its own — only existence is meaningful. */
9812
+ /** Existence plus the expiry stored at the row's first write, if any. */
7936
9813
  getEvalRetention(id: string): Promise<{
7937
9814
  exists: boolean;
7938
9815
  expiresAt?: number;
7939
9816
  }>;
9817
+ /**
9818
+ * See `StateStore.applyHistoryRetention`. Every record this store holds was
9819
+ * saved under the retention it was constructed with, so in practice a run
9820
+ * finds nothing to expire or arm; the method exists so the same maintenance
9821
+ * code works against every built-in store. There is no separate index, so
9822
+ * `indexed` and `deadIndexEntries` are always `0`.
9823
+ *
9824
+ * An armed record keeps its place in last-save order, which is also where
9825
+ * its expiry (last save + retention) belongs, so the prune-on-save order
9826
+ * still holds.
9827
+ */
9828
+ applyHistoryRetention(options: HistoryRetentionOptions): Promise<HistoryRetentionResult>;
9829
+ /** Index of the first order key not older than `key` (binary search). */
9830
+ private executionOrderLowerBound;
9831
+ private insertExecutionOrder;
9832
+ /** Remove a history record and its listing-index key. Returns whether one existed. */
9833
+ private removeExecutionRecord;
9834
+ /**
9835
+ * A run leaving history through retention (expiry or `maxExecutions`) takes
9836
+ * its leftover per-run data with it: checkpoints (kept today when a run
9837
+ * fails), saved execution state and any streaming buffer. Pending decisions
9838
+ * are not touched. The runtime never writes execution state, and a run is
9839
+ * only saved to history once it has finished, so nothing still running
9840
+ * depends on what is removed here.
9841
+ */
9842
+ private expireExecutionRecord;
9843
+ /**
9844
+ * Remove up to `PRUNE_BATCH` expired execution records, oldest save first.
9845
+ * Stops at the first live record: Map order is last-save order, which is
9846
+ * expiry order while the clock moves forward. If the clock steps back, a
9847
+ * few expired records wait for a later save; reads still filter them.
9848
+ */
9849
+ private pruneExpiredExecutions;
9850
+ /** Evict the oldest records in listing order until the count bound holds. */
9851
+ private evictOverflowExecutions;
9852
+ /** Remove up to `PRUNE_BATCH` expired eval rows, oldest first write first. */
9853
+ private pruneExpiredEvals;
7940
9854
  listSessions(): Promise<string[]>;
7941
9855
  private streamingEvents;
7942
9856
  appendStreamingEvents(executionId: string, events: AxlEvent[]): Promise<void>;
@@ -7949,6 +9863,19 @@ declare class MemoryStore implements StateStore {
7949
9863
  private loadPersistedState;
7950
9864
  }
7951
9865
 
9866
+ /** Options for {@link SQLiteStore}. */
9867
+ type SQLiteStoreOptions = {
9868
+ /**
9869
+ * History retention in seconds. A positive number expires a record that
9870
+ * many seconds after it is saved; `null` or unset keeps it. See
9871
+ * {@link HistoryTtls} for how each category's window is counted. With
9872
+ * `executionHistory` unset, the store warns once per process; set it (to
9873
+ * `null` to keep history forever) to silence the warning.
9874
+ */
9875
+ ttls?: HistoryTtls;
9876
+ /** Clock in epoch milliseconds, used for retention. Defaults to `Date.now`. */
9877
+ now?: () => number;
9878
+ };
7952
9879
  /**
7953
9880
  * SQLite-backed StateStore using better-sqlite3.
7954
9881
  *
@@ -7960,7 +9887,9 @@ declare class MemoryStore implements StateStore {
7960
9887
  */
7961
9888
  declare class SQLiteStore implements StateStore {
7962
9889
  private db;
7963
- constructor(filePath: string);
9890
+ private readonly ttls;
9891
+ private readonly now;
9892
+ constructor(filePath: string, options?: SQLiteStoreOptions);
7964
9893
  /**
7965
9894
  * Idempotent schema migration. Tracks version via `PRAGMA user_version`
7966
9895
  * so reopens skip applied steps. Wrapped in `BEGIN IMMEDIATE` so
@@ -7987,6 +9916,11 @@ declare class SQLiteStore implements StateStore {
7987
9916
  * Existing rows remain `NULL`, the documented v1 sentinel.
7988
9917
  * - v5 (observation completeness): add `execution_history.observation`.
7989
9918
  * Existing rows remain `NULL`, meaning they predate the contract.
9919
+ * - v6 (history retention): add nullable `expires_at` (epoch ms) to
9920
+ * `execution_history` and `eval_history`. Existing rows remain `NULL`
9921
+ * (never expire), so an upgrade deletes nothing. The single-column
9922
+ * `started_at` index is replaced by `(started_at, execution_id)`, which
9923
+ * serves the tie-safe listing order.
7990
9924
  *
7991
9925
  * Applied BEFORE `initTables()` so the subsequent `CREATE TABLE
7992
9926
  * IF NOT EXISTS` runs against the post-migration column name. Fresh
@@ -8019,24 +9953,52 @@ declare class SQLiteStore implements StateStore {
8019
9953
  getExecutionState(executionId: string): Promise<ExecutionState | null>;
8020
9954
  listPendingExecutions(): Promise<string[]>;
8021
9955
  saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
9956
+ /**
9957
+ * Remove up to `PRUNE_BATCH` expired execution-history rows, together with
9958
+ * each run's leftover checkpoints and saved execution state, inside the
9959
+ * caller's transaction. Pending decisions are not touched. The runtime
9960
+ * never writes execution state, and a run is only saved to history once it
9961
+ * has finished, so nothing still running depends on what is removed here.
9962
+ */
9963
+ private pruneExpiredExecutions;
9964
+ /** Remove up to `PRUNE_BATCH` expired eval-history rows (caller's transaction). */
9965
+ private pruneExpiredEvals;
8022
9966
  getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
8023
- listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
9967
+ /** Supports `listExecutions(limit, { cursor })`. */
9968
+ readonly historyPaging = true;
9969
+ listExecutions(limit?: number, options?: {
9970
+ cursor?: ExecutionCursor;
9971
+ }): Promise<HistoricalExecutionInfo[]>;
8024
9972
  deleteExecution(executionId: string): Promise<boolean>;
9973
+ /**
9974
+ * Write an eval history row. Retention counts from the row's first write:
9975
+ * re-saving a live row keeps its `expires_at` (including none, for a row
9976
+ * written without retention). A row that has already expired is replaced
9977
+ * as a new one.
9978
+ */
8025
9979
  saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
8026
9980
  /**
8027
9981
  * Update-only write: see `StateStore.updateEvalResult`. `UPDATE ... WHERE id`
8028
- * touches nothing when the row is gone, where `INSERT OR REPLACE` would
8029
- * resurrect it — and SQLite history has no expiry, so a resurrection here is
8030
- * permanent.
9982
+ * touches nothing when the row is gone or expired, where `INSERT OR REPLACE`
9983
+ * would resurrect it. `expires_at` is left as it was.
8031
9984
  */
8032
9985
  updateEvalResult(entry: EvalHistoryEntry): Promise<boolean>;
8033
9986
  listEvalResults(limit?: number): Promise<EvalHistoryEntry[]>;
8034
9987
  deleteEvalResult(id: string): Promise<boolean>;
8035
- /** SQLite history has no automatic expiry — only existence is meaningful. */
9988
+ /** Existence plus the expiry stored at the row's first write, if any. */
8036
9989
  getEvalRetention(id: string): Promise<{
8037
9990
  exists: boolean;
8038
9991
  expiresAt?: number;
8039
9992
  }>;
9993
+ /**
9994
+ * See `StateStore.applyHistoryRetention`. One batch runs in one immediate
9995
+ * transaction, so no other writer can change a row between this call
9996
+ * reading it and acting on it. Only rows whose `expires_at` is `NULL` are
9997
+ * touched. An expired execution takes its checkpoints and saved execution
9998
+ * state with it, as a normal expiry does. There is no separate index, so
9999
+ * `indexed` and `deadIndexEntries` are always `0`.
10000
+ */
10001
+ applyHistoryRetention(options: HistoryRetentionOptions): Promise<HistoryRetentionResult>;
8040
10002
  listSessions(): Promise<string[]>;
8041
10003
  saveMemory(scope: string, key: string, value: unknown): Promise<void>;
8042
10004
  getMemory(scope: string, key: string): Promise<unknown | null>;
@@ -8128,11 +10090,19 @@ interface RedisStoreOptions {
8128
10090
  * new ones) eventually ages out. If you need read-activity to count
8129
10091
  * as "active," issue a no-op `ctx.remember` against a sentinel key
8130
10092
  * per session turn.
8131
- * - **Fixed window**: `checkpoint`, `executionState`, `executionHistory`,
8132
- * `evalHistory`. The TTL is set on the first write and isn't extended
8133
- * on subsequent writes (via `EXPIRE ... NX`). Designed for runtime-
8134
- * controlled lifecycles like executions, where the data should age
8135
- * out on a schedule from creation.
10093
+ * - **Fixed from the first write**: `checkpoint`, `streamingEvents`
10094
+ * (`EXPIRE ... NX`) and `evalHistory` (a re-save re-applies the remaining
10095
+ * `PTTL`; `updateEvalResult` uses `KEEPTTL`). Later writes never extend
10096
+ * the window, and an eval row that exists without a TTL stays untimed.
10097
+ * - **Restarted on every save**: `executionState`, `executionHistory`
10098
+ * (`SET ... EX`). An execution record is kept for the full window after
10099
+ * its last save, which is normally when the run finished.
10100
+ *
10101
+ * `executionHistory` and `evalHistory` have the same meaning as the
10102
+ * `ttls` option of `MemoryStore` and `SQLiteStore` (see `HistoryTtls`).
10103
+ * With neither `executionHistory` (any value, `null` included) nor
10104
+ * {@link defaultTtl} set, `create()` warns once per process that
10105
+ * execution history is kept forever.
8136
10106
  */
8137
10107
  ttls?: {
8138
10108
  session?: number | null;
@@ -8173,6 +10143,18 @@ declare class RedisStore implements StateStore {
8173
10143
  private keyPrefix;
8174
10144
  private ttls;
8175
10145
  private constructor();
10146
+ /**
10147
+ * History kinds with a prune running in this process. A save skips its
10148
+ * prune while another one of the same kind is in flight: the running one
10149
+ * already covers the oldest expired entries. Created lazily so the
10150
+ * instance needs no constructor state.
10151
+ */
10152
+ private prunesInFlight?;
10153
+ /**
10154
+ * Supports `listExecutions(limit, { cursor })`. A getter rather than a
10155
+ * field so it lives on the prototype.
10156
+ */
10157
+ get historyPaging(): boolean;
8176
10158
  /**
8177
10159
  * Resolve the TTL for a given storage category. Returns `undefined` when
8178
10160
  * no TTL applies (category is `null` in resolved config, the value is
@@ -8238,6 +10220,8 @@ declare class RedisStore implements StateStore {
8238
10220
  private evalHistorySetKey;
8239
10221
  /** Sorted-set index for eval history, scored by `timestamp`. See above. */
8240
10222
  private evalHistoryZsetKey;
10223
+ /** Keys and blob parsing for one kind of history. See {@link HistoryIndex}. */
10224
+ private historyIndex;
8241
10225
  private memoryKey;
8242
10226
  private streamingEventsKey;
8243
10227
  private streamingIdsKey;
@@ -8263,7 +10247,9 @@ declare class RedisStore implements StateStore {
8263
10247
  deleteMemory(scope: string, key: string): Promise<void>;
8264
10248
  saveExecution(execution: HistoricalExecutionInfo): Promise<void>;
8265
10249
  getExecution(executionId: string): Promise<HistoricalExecutionInfo | null>;
8266
- listExecutions(limit?: number): Promise<HistoricalExecutionInfo[]>;
10250
+ listExecutions(limit?: number, options?: {
10251
+ cursor?: ExecutionCursor;
10252
+ }): Promise<HistoricalExecutionInfo[]>;
8267
10253
  deleteExecution(executionId: string): Promise<boolean>;
8268
10254
  /**
8269
10255
  * Write an eval history row.
@@ -8286,7 +10272,9 @@ declare class RedisStore implements StateStore {
8286
10272
  * lifetime, so the race costs at most one window's length, never the window
8287
10273
  * itself. It also carries no Redis version floor, where `KEEPTTL` needs 6.0.
8288
10274
  *
8289
- * The index entries carry no TTL and age out lazily, as with `saveExecution`.
10275
+ * As with `saveExecution`, a timed row is also scored in the expiry sorted
10276
+ * set (by the expiry it carries, so a re-save keeps its score), an untimed
10277
+ * one is taken out of it, and a bounded prune follows the save.
8290
10278
  */
8291
10279
  saveEvalResult(entry: EvalHistoryEntry): Promise<void>;
8292
10280
  /**
@@ -8330,13 +10318,70 @@ declare class RedisStore implements StateStore {
8330
10318
  expiresAt?: number;
8331
10319
  }>;
8332
10320
  /**
8333
- * Shared list-by-sorted-set implementation. Uses ZREVRANGEBYSCORE +
8334
- * MGET when the ZSET is populated (post-migration). Falls back to the
8335
- * legacy SET + N×GET + JS-sort path when the ZSET is empty or smaller
8336
- * than the SET (covers users that constructed with `skipMigration: true`
8337
- * before calling backfill).
10321
+ * Shared list-by-sorted-set implementation, newest first by
10322
+ * `(score DESC, member DESC)`, starting strictly after `cursor` when given.
10323
+ *
10324
+ * Fast path (the time sorted set is at least as large as the id set): walk
10325
+ * the sorted set in chunks and MGET each chunk's blobs. Index entries whose
10326
+ * blob is gone (expired, or deleted before the prune caught up) are skipped,
10327
+ * and the walk keeps reading until it has `limit` live records or the set
10328
+ * runs out, however many dead entries are in the way. Each chunk restarts
10329
+ * at the last member read, by score and member, rather than at an offset,
10330
+ * so entries added or removed meanwhile cannot shift the walk.
10331
+ *
10332
+ * Slow path (the time sorted set is behind the id set: backfill has not
10333
+ * run): read every id with GET, then sort and apply the cursor in process.
8338
10334
  */
8339
10335
  private listHistoryByZset;
10336
+ /**
10337
+ * Run one prune of `index`'s kind after a save. A prune failure does not
10338
+ * fail the save, whose MULTI already committed the record: it is reported
10339
+ * once per process and the next save of that kind tries again. That also
10340
+ * covers a Redis user whose ACL denies `EVAL`.
10341
+ */
10342
+ private pruneHistoryAfterSave;
10343
+ private pruneHistory;
10344
+ /**
10345
+ * Run {@link PRUNE_HISTORY_INDEX_SCRIPT} over `ids`, at most PRUNE_BATCH
10346
+ * per call so one script never blocks the server for long.
10347
+ */
10348
+ private runPruneScript;
10349
+ /**
10350
+ * See `StateStore.applyHistoryRetention`. One call:
10351
+ *
10352
+ * 1. On the first call of a walk (no cursor), backfills the time sorted
10353
+ * set from the id set if it is behind (see `backfillExecutionIndex`).
10354
+ * 2. Reads the next `batchSize` ids from the time sorted set, oldest first
10355
+ * by `(score, member)`, strictly after the cursor. The read restarts at
10356
+ * the cursor's position by value, never by offset.
10357
+ * 3. MGETs their blobs and reads each live blob's PTTL.
10358
+ * 4. In one MULTI, for each live blob:
10359
+ * - a TTL (`PTTL > 0`): `ZADD NX` to the expiry set at now + PTTL. A
10360
+ * record already in the expiry set keeps its entry (`indexed` counts
10361
+ * only new entries).
10362
+ * - no TTL (`-1`), with a retention configured: `PEXPIREAT … NX` at last
10363
+ * save + retention. `NX` applies only to a key that still has no TTL,
10364
+ * so a record re-saved meanwhile keeps the fresh window its save gave
10365
+ * it. A window that has already passed uses a timestamp in the past,
10366
+ * which makes Redis delete the key, again only if it is still untimed.
10367
+ * 5. Adds each newly armed record to the expiry set (`ZADD NX`).
10368
+ * 6. Runs the prune script (`PRUNE_HISTORY_INDEX_SCRIPT`) over ids whose
10369
+ * blob is gone and ids just deleted in step 4. It checks each blob
10370
+ * atomically, so a record re-saved at any point stays listed and a
10371
+ * deleted one is never re-indexed.
10372
+ *
10373
+ * Blobs are never written. A record deleted while the call runs can leave
10374
+ * an entry in the expiry set only; the next prune removes it.
10375
+ */
10376
+ applyHistoryRetention(options: HistoryRetentionOptions): Promise<HistoryRetentionResult>;
10377
+ /**
10378
+ * Up to `count` members of the time sorted set strictly after `cursor`,
10379
+ * oldest first by `(score, member)`. The members sharing the cursor's score
10380
+ * are read in full and filtered by member; the rest start just above that
10381
+ * score. Neither read uses an offset, so entries removed or added
10382
+ * meanwhile cannot shift the walk.
10383
+ */
10384
+ private readRetentionBatch;
8340
10385
  listSessions(): Promise<string[]>;
8341
10386
  appendStreamingEvents(executionId: string, events: AxlEvent[]): Promise<void>;
8342
10387
  finalizeStreamingEvents(executionId: string): Promise<void>;
@@ -8422,4 +10467,4 @@ declare class NoopSpanManager implements SpanManager {
8422
10467
  */
8423
10468
  declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
8424
10469
 
8425
- export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Accounting, type AccountingCompleteness, type AccountingReason, type AccountingUsage, AdmissionController, AdmissionDeniedError, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type ArtifactManifest, type ArtifactOwner, type ArtifactStatus, type ArtifactWriteResult, 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 CallTiming, type CapabilityFlags, type CaptureCorrelation, type CapturedCorrection, type CapturedError, type CapturedMessage, type CapturedOperationRef, type CapturedPhase, type CapturedRequest, type CapturedRequestRecord, type CapturedResponse, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CostProvenance, type CreateContextOptions, DEEPSEEK_PROFILE, DEFAULT_MAX_QUEUE_BYTES, DEFAULT_MAX_RECORD_BYTES, DEFAULT_MAX_RUN_BYTES, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type DiagnosticArtifactStore, type DiagnosticArtifactsConfig, type DiagnosticsConfig, type DispatchAdmission, type Effort, type EffortResolution, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EvalProgressEventShape, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, type ExternalOperationDescriptor, type ExternalOperationReport, FileDiagnosticArtifactStore, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, 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 InputAudioPart, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type ModelInput, type ModelInputDescriptor, type ModelTimingRollup, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OpenedArtifact, type OperationKind, type OperationPurpose, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type ProfileInputModalities, type Provider, type ProviderAdapter, type ProviderDiagnosticData, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningContextReset, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, RequestCaptureChannel, type RequestCaptureOptions, type RequestCaptureSink, type RequestCaptureStatus, type ResolvedThinkingOptions, type Result, type RetryFeedbackHook, type RetryFeedbackInfo, type RetryFeedbackResult, type RetryPolicy, type RuntimeEvalConfigShape, SGLANG_PROFILE, SQLiteStore, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StagedArtifact, StallTimeoutError, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, type TimeoutBreakdown, 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, type TrackExecutionMetadata, type TrackExecutionResult, type TrackOutcomeOptions, type TrackedOutcome, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedModelOptionError, UnsupportedTranscriptionInputError, 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, externalOperation, extractJson, extractThinkTags, findConfig, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isAdmissionDeniedError, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactCapturedRequest, redactEvent, redactHistoricalEvent, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, summarizeModelInput, tool, workflow, zodToJsonSchema };
10470
+ export { AXL_EVENT_TYPES, AXL_EVENT_TYPES_V2, AXL_TOOL_LIFECYCLE_TYPES_V2, AZURE_PROFILE, type Accounting, type AccountingCompleteness, type AccountingReason, type AccountingUsage, AdmissionController, AdmissionDeniedError, type Agent, type AgentCallEndData, type AgentCallInfo, type AgentCallParams, type AgentCallStartData, type AgentConfig, AnthropicProvider, type AnyWorkflow, type ApiKeySource, type ArtifactManifest, type ArtifactOwner, type ArtifactStatus, type ArtifactWriteResult, 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 CallTiming, type CapabilityFlags, type CaptureCorrelation, type CapturedCorrection, type CapturedError, type CapturedExternalRequestRecord, type CapturedJsonValue, type CapturedMessage, type CapturedModelRequestRecord, type CapturedOperationRef, type CapturedPhase, type CapturedRequest, type CapturedRequestRecord, type CapturedResponse, type ChatMessage, type ChatOptions, type CheckpointEventData, type CoalescedPartialObject, type CostProvenance, type CreateContextOptions, DEEPSEEK_PROFILE, DEFAULT_MAX_QUEUE_BYTES, DEFAULT_MAX_RECORD_BYTES, DEFAULT_MAX_RUN_BYTES, type DecisionCleanupFailedEvent, type DelegateData, type DelegateOptions, type DiagnosticArtifactStore, type DiagnosticArtifactsConfig, type DiagnosticsConfig, type DispatchAdmission, type Effort, type EffortResolution, type EmbedResult, type EmbedUsage, type Embedder, type EvalExecuteWorkflow, type EvalHistoryEntry, type EvalProgressEventShape, type EventStreamOptions, EventStreamOverflowError, type ExecuteOptions, type ExecutionCursor, type ExecutionInfo, type ExecutionInfoV1, type ExecutionInfoV2, type ExecutionState, type ExternalOperationDescriptor, type ExternalOperationRecord, type ExternalOperationReport, FileDiagnosticArtifactStore, type FinishReason, type FoldedOperationRecord, GROQ_PROFILE, GeminiProvider, GeminiTranscriptionProvider, type GuardrailBlockHandler, type GuardrailData, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HandoffReturnData, type HandoffStartData, type HistoricalAxlEvent, type HistoricalExecutionInfo, type HistoryRetentionCursor, type HistoryRetentionKind, type HistoryRetentionOptions, type HistoryRetentionResult, type HistoryTtls, type HumanDecision, InMemoryVectorStore, type InputAudioPart, type InputContentPart, type InputGuardrail, type InputImagePart, type InputMediaSource, type InputModalitySupport, type InputTextPart, InvalidModelInputError, InvalidTranscriptionInputError, LLAMACPP_PROFILE, LMSTUDIO_PROFILE, type LegacyAxlEventV1, type LegacyExecutionInfoV1, MAX_INLINE_MODEL_INPUT_BYTES, MAX_INLINE_TRANSCRIPTION_BYTES, MISTRAL_PROFILE, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, type MemoryEventData, MemoryManager, MemoryStore, type MemoryStoreOptions, type ModelCallRecord, type ModelInput, type ModelInputDescriptor, type ModelTimingRollup, NoConsensus, NoopSpanManager, OLLAMA_PROFILE, OPENAI_PRICING, OPENAI_PROFILE, OPENROUTER_PROFILE, type ObservationStatus, type OpenAICompatibleOptions, OpenAICompatibleProvider, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, OpenAITranscriptionProvider, OpenRouterTranscriptionProvider, type OpenedArtifact, type OperationKind, type OperationPurpose, type OutputGuardrail, type OutputValidator, type PendingDecision, type PerModel, type PricingSource, type PricingTable, type ProfileInputModalities, type Provider, type ProviderAdapter, type ProviderDiagnosticData, ProviderError, type ProviderInputValidationRequest, type ProviderInputValidationResult, type ProviderProfile, ProviderRegistry, type ProviderResponse, QuorumNotMet, REDACTED, REDACTION_RULES, type RaceOptions, type RateLimitConfig, RateLimiter, type ReasoningCapture, type ReasoningContextReset, type ReasoningEmit, type ReasoningProfile, type ReasoningRoundTrip, type RecallOptions, type RecallResult, type RecordedAudioSource, RedisStore, type RememberOptions, type RememberResult, RequestCaptureChannel, type RequestCaptureOptions, type RequestCaptureSink, type RequestCaptureStatus, type ResolvedThinkingOptions, type Result, type RetryFeedbackHook, type RetryFeedbackInfo, type RetryFeedbackResult, type RetryPolicy, type RuntimeEvalConfigShape, SGLANG_PROFILE, SQLiteStore, type SQLiteStoreOptions, type SchemaCheckData, type SchemaDiagnosticData, type SchemaPromptOption, Session, type SessionOptions, type SpanAttributeValue, type SpanAttributes, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StagedArtifact, StallTimeoutError, type StateStore, type StreamChunk, type StringDeltaData, type StringStreamEvent, type StringStreamFilter, type TelemetryConfig, ThinkTagScanner, type TimeoutBreakdown, 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, type TrackExecutionMetadata, type TrackExecutionResult, type TrackOutcomeOptions, type TrackedOutcome, type Transcript, type TranscriptionCapabilities, TranscriptionOperationError, type TranscriptionProvider, TranscriptionProviderRegistry, type TranscriptionProviderRequest, type TranscriptionProviderResult, type TranscriptionRequest, UnsupportedEventSchemaVersionError, UnsupportedModelInputError, UnsupportedModelOptionError, UnsupportedTranscriptionInputError, 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, capturedJournalLineSchema, createSpanManager, defineConfig, estimateOpenAICost, eventCostContribution, expandGlob, externalOperation, externalOperationRecordSchema, extractJson, extractThinkTags, findConfig, foldJournal, foldedOperationRecordSchema, getEventSchemaVersion, getExecutionEventSchemaVersion, hasPositiveBillableWork, hasPositiveTokens, importModule, inputText, isAdmissionDeniedError, isCostBearingLeaf, isRetryableStatus, isRootLevel, isUnpricedLeaf, isUsableCost, modelCallRecordSchema, needsTsxLoader, normalizeStoredExecution, openaiReasoningEmit, parsePartialJson, pickDefault, pickExport, priceFromTable, reasoningEffortEmit, reasoningObjectEmit, redactCapturedRequest, redactEvent, redactHistoricalEvent, redactModelCallRecord, registerConditions, resolveApiKey, resolvePerModel, resolveRuntime, resolveThinkingOptions, stringStreamFromEvents, summarizeModelInput, tool, workflow, zodToJsonSchema };