@rulvar/core 1.51.0 → 1.53.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +731 -571
  2. package/dist/index.js +438 -15
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -515,7 +515,13 @@ type ChatEvent = {
515
515
  };
516
516
  /** Strictly 'adapterId:model', no query parameters. */
517
517
  type ModelRef = `${string}:${string}`;
518
- type InvocationRole = "orchestrate" | "plan" | "loop" | "finalize" | "extract" | "summarize";
518
+ /**
519
+ * The seven invocation roles. 'synthesize' is the orchestrator's
520
+ * post-fan-in synthesis invocation (RV-211): it fires only when
521
+ * OrchestrateOptions.synthesis is configured, and the routing key picks
522
+ * its model like any other role without ever summoning it.
523
+ */
524
+ type InvocationRole = "orchestrate" | "plan" | "loop" | "finalize" | "extract" | "summarize" | "synthesize";
519
525
  /**
520
526
  * What authors write wherever a model is configurable: a call override, an
521
527
  * agent profile, a workflow default, or an engine default.
@@ -2934,169 +2940,594 @@ declare function validateEscalationReport(report: EscalationReport): Promise<Iss
2934
2940
  */
2935
2941
  declare function countsAgainstLimit(kind: EscalationKind): boolean;
2936
2942
  //#endregion
2937
- //#region src/runtime/no-progress.d.ts
2938
- /**
2939
- * The no-progress abort class (M3-T08): an engine-defined detector
2940
- * journaled as a first-class terminal abort distinct from user
2941
- * cancellation (a cancelled entry always reruns; a no-progress abort
2942
- * must replay, or every resume would re-pay the stuck turns). The
2943
- * interim heuristic is committed: N consecutive
2944
- * turns without tool calls or artifact deltas, N = 3; the broader
2945
- * heuristic stays OQ-15, revisited on dogfood traces.
2946
- *
2947
- * Encoding: the abort is the agent's
2948
- * terminal entry with status 'limit', an error payload carrying
2949
- * abortClass 'no-progress', and memoizeOutcome stamped by the ENGINE on
2950
- * the terminal entry, so the frozen memoize-limit rule replays it on
2951
- * every subsequent resume without a live rerun. In M3 the runtime has no
2952
- * per-turn artifact channel, so the tool-call test subsumes artifact
2953
- * deltas; per-turn artifact producers arrive with M4 compaction.
2954
- */
2955
- /** The committed no-progress detector N. */
2956
- declare const DEFAULT_NO_PROGRESS_TURNS = 3;
2957
- /**
2958
- * The consumer-visible engine-decided abort classes (FR-424).
2959
- * 'no-progress' is the detector below; 'output-truncated' is a
2960
- * schema-less turn that ended at its output token allowance
2961
- * (finish reason 'max-tokens') without visible output (v1.9.0
2962
- * follow-up review). Both stamp memoizeOutcome on the terminal:
2963
- * the work is paid, so every resume replays the abort instead of
2964
- * re-paying the same bounded failure.
2965
- */
2966
- type AbortClass = "no-progress" | "output-truncated";
2967
- /**
2968
- * Counts consecutive progress-free turns. A turn with at least one tool
2969
- * call (or, later, an artifact delta) resets the streak; a turn with
2970
- * neither lengthens it; the detector trips when the streak reaches the
2971
- * threshold AND the loop would otherwise continue.
2972
- */
2973
- declare class NoProgressDetector {
2974
- private streakInternal;
2975
- private readonly threshold;
2976
- constructor(threshold?: number);
2977
- get streak(): number;
2978
- /** Records one completed model turn. */
2979
- recordTurn(progress: {
2980
- toolCalls: number;
2981
- artifactDeltas?: number;
2982
- }): void;
2983
- get tripped(): boolean;
2984
- describe(): string;
2985
- }
2986
- //#endregion
2987
- //#region src/runtime/usage-limits.d.ts
2988
- interface UsageLimits {
2989
- /** Default 32. */
2990
- maxTurns?: number;
2991
- /** Unlimited by default. */
2992
- maxToolCalls?: number;
2993
- /** Unlimited by default (model caps still apply). */
2994
- maxOutputTokensPerTurn?: number;
2995
- /** Per-agent wall clock; unlimited by default. */
2996
- timeoutMs?: number;
2997
- /** Gap between stream events; default 120000. */
2998
- streamIdleTimeoutMs?: number;
2943
+ //#region src/l0/events.d.ts
2944
+ /** Run lifecycle and core telemetry (M1 subset). */
2945
+ type CoreEvents = {
2946
+ type: "run:start";
2947
+ workflow: string;
2948
+ resumed: boolean;
2949
+ } | {
2950
+ type: "run:end";
2951
+ status: "ok" | "error" | "cancelled" | "exhausted" | "suspended";
2952
+ totalUsd: number;
2999
2953
  /**
3000
- * The no-progress detector N (committed at 3):
3001
- * consecutive turns without tool calls or artifact deltas before the
3002
- * engine aborts with the dedicated class (M3-T08).
2954
+ * Present and true when any priced usage folded into totalUsd is
2955
+ * approximate (a transport cut, a stream the ceiling severed, or an
2956
+ * abort left a turn's usage estimated rather than reported by the
2957
+ * provider), so totalUsd is a lower bound estimate, never an exact
2958
+ * charge. Absent means every contributing turn reported exact usage.
3003
2959
  */
3004
- noProgressTurns?: number;
3005
- }
3006
- declare const DEFAULT_MAX_TURNS = 32;
3007
- declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 12e4;
3008
- interface EffectiveUsageLimits {
3009
- maxTurns: number;
3010
- maxToolCalls?: number;
3011
- maxOutputTokensPerTurn?: number;
3012
- timeoutMs?: number;
3013
- streamIdleTimeoutMs: number;
3014
- /** Default DEFAULT_NO_PROGRESS_TURNS. */
3015
- noProgressTurns?: number;
3016
- }
3017
- /**
3018
- * Limits merge per spawn: AgentOpts.limits over profile limits over engine
3019
- * defaults.limits.
3020
- */
3021
- declare function mergeUsageLimits(call?: UsageLimits, profile?: UsageLimits, engine?: UsageLimits): EffectiveUsageLimits;
2960
+ usageApprox?: boolean;
2961
+ } | {
2962
+ type: "phase:start";
2963
+ phase: string;
2964
+ } | {
2965
+ type: "log";
2966
+ level: "debug" | "info" | "warn" | "error";
2967
+ msg: string;
2968
+ data?: Json;
2969
+ } | {
2970
+ type: "budget:update";
2971
+ spentUsd: number;
2972
+ remainingUsd: number | null;
2973
+ committedReserveUsd: number;
2974
+ } | {
2975
+ type: "external:waiting";
2976
+ key: string;
2977
+ entryRef: number;
2978
+ prompt?: string;
2979
+ deadlineAt?: string;
2980
+ } | {
2981
+ type: "approval:pending";
2982
+ toolName: string;
2983
+ entryRef: number;
2984
+ deadlineAt?: string;
2985
+ } | {
2986
+ type: "child:start";
2987
+ workflow: string;
2988
+ scope: string;
2989
+ } | {
2990
+ type: "child:end";
2991
+ workflow: string;
2992
+ scope: string;
2993
+ status: string;
2994
+ };
3022
2995
  /**
3023
- * Validates one UsageLimits layer at its intake boundary (v1.34.0
3024
- * review P2-3): a malformed field (NaN, Infinity, a negative, a
3025
- * fraction) is a typed ConfigError before the merge, before any journal
3026
- * entry, and before any provider dispatch. `site` names the layer in the
3027
- * error text (e.g. `RunOptions.limits`). Counts are positive integers
3028
- * (maxToolCalls may be 0: a spawn that must not call tools).
3029
- * streamIdleTimeoutMs is handed to setTimeout as-is, so it is bounded by
3030
- * the Node timer maximum like RetryPolicy delays; timeoutMs is a
3031
- * wall-clock comparison, so it has no upper bound. Every present field
3032
- * is checked; absent fields keep their defaults.
2996
+ * The structured exploration summary (RV-210): the engine-side tool
2997
+ * exploration counters for one agent invocation. Attached to the full
2998
+ * AgentResult and to the live `agent:end` event whenever any exploration
2999
+ * guard limit is configured; journaled inside the terminal error payload
3000
+ * (and therefore restored on replay) only when the guard itself ended
3001
+ * the invocation (abortClass 'exploration').
3033
3002
  */
3034
- declare function validateUsageLimits(limits: UsageLimits, site: string): void;
3035
- //#endregion
3036
- //#region src/runtime/agent-loop.d.ts
3037
- type AgentStatus = "ok" | "error" | "limit" | "cancelled" | "skipped" | "escalated";
3038
- /** Artifact: the normative shape of AgentResult.artifacts entries. */
3039
- interface Artifact {
3040
- /** Stable within the result. */
3041
- id: string;
3042
- /** Closed in v1. */
3043
- kind: "file" | "patch" | "json" | "text";
3044
- /** Telemetry only. */
3045
- label?: string;
3046
- /** Changed-file list (kind 'patch': worktree collect()). */
3047
- files?: string[];
3048
- /** TranscriptStore blob ref for offloaded content. */
3049
- ref?: string;
3050
- /** Inline JSON content for small values. */
3051
- data?: Json;
3052
- }
3053
- /** The verdict of one mechanical acceptance gate evaluation. */
3054
- interface MechanicalGateVerdict {
3055
- pass: boolean;
3056
- detail?: string;
3003
+ interface ExplorationSummary {
3004
+ /** Tool executions dispatched by the loop (the loop's own counter). */
3005
+ toolCallsUsed: number;
3006
+ /** Distinct (tool name, canonical args) signatures executed. */
3007
+ distinctSignatures: number;
3008
+ /** Executions of a signature that had already executed before. */
3009
+ repeatedCalls: number;
3010
+ /** Successful executions whose result digest was already seen. */
3011
+ duplicateResultCalls: number;
3012
+ /** Calls denied by the repeated-signature guard (never dispatched). */
3013
+ deniedRepeats: number;
3014
+ /** Executions per tool name. */
3015
+ byTool: Record<string, number>;
3057
3016
  }
3058
3017
  /**
3059
- * A mechanical acceptance gate: an engine-registered NAMED pure function
3060
- * over AgentResult.artifacts.
3061
- * The registry is per engine like every other registry; the
3062
- * ladder driver journals each evaluation as a decision entry, so the
3063
- * ladder fold consumes only journaled verdicts, never live re-evaluation.
3018
+ * Agent lifecycle. One logical agent dispatch emits EXACTLY ONE
3019
+ * `agent:start`/`agent:end` pair on its span (the start carries the
3020
+ * primary role), and each model invocation phase inside the span
3021
+ * (`loop`, then possibly `summarize` activations, `finalize`,
3022
+ * `extract`) emits its own `agent:phase:start`/`agent:phase:end` pair,
3023
+ * so durations, per-phase usage, and attempts are derivable without
3024
+ * heuristics (the RV-207 event-model contract; before it, every phase
3025
+ * emitted an unpaired extra `agent:start` and consumers pairing starts
3026
+ * with the single end computed the LAST phase's duration as the
3027
+ * agent's). `reduceInvocationTable` is the official reducer over this
3028
+ * vocabulary.
3064
3029
  */
3065
- type MechanicalGateProfile = (artifacts: readonly Artifact[]) => MechanicalGateVerdict;
3066
- interface AgentResult<T> {
3067
- status: AgentStatus;
3068
- output: T | null;
3069
- usage: Usage;
3070
- costUsd: number;
3071
- turns: number;
3030
+ type AgentEvents = {
3031
+ type: "agent:queued";
3032
+ agentType: string;
3033
+ label?: string;
3034
+ } | {
3035
+ type: "agent:start";
3036
+ agentType: string;
3037
+ label?: string;
3038
+ model: string;
3039
+ role: string;
3040
+ } | {
3041
+ type: "agent:phase:start";
3042
+ agentType: string;
3043
+ label?: string; /** The invocation role this phase activation runs as. */
3044
+ role: string; /** The model the activation resolved to (fallbacks may serve another; the end event reports the server). */
3045
+ model: string;
3072
3046
  /**
3073
- * The model that actually served the loop phase at the end (M4-T04):
3074
- * differs from the requested spec only under transport failover.
3047
+ * 1-based activation ordinal within the span, unique per
3048
+ * activation (a summarize that fires three times gets three
3049
+ * pairs). Key phases by (spanId, invocation).
3075
3050
  */
3076
- servedBy: ModelRef;
3051
+ invocation: number;
3052
+ } | {
3053
+ type: "agent:phase:end";
3054
+ agentType: string;
3055
+ label?: string;
3056
+ role: string; /** The model that actually served the activation's last attempt. */
3057
+ model: string;
3058
+ invocation: number;
3077
3059
  /**
3078
- * Present only when the call spanned MORE THAN ONE (invocation role,
3079
- * serving model) pair (the loop, extract, finalize, and summarize
3080
- * roles resolve independently): usage split per (role, model), so
3081
- * `costUsd` and every cost bucket price each slice at its own rate
3082
- * and `CostReport.byRole` attributes each phase to its own bucket
3083
- * (v1.19.0 review P1-2). Absent for a single-phase single-model call,
3084
- * which (usage, servedBy) already describes exactly.
3060
+ * Wall-clock activation duration. Live telemetry only: replayed
3061
+ * phase pairs (reconstructed from the terminal entry's usage
3062
+ * slices) carry 0.
3085
3063
  */
3086
- usageByModel?: UsageSlice[];
3087
- transcriptRef: string;
3088
- artifacts?: Artifact[];
3089
- error?: AgentError;
3064
+ durationMs: number; /** The usage this activation added to its (role, model) slices. */
3065
+ usage: Usage; /** That usage priced at each serving model's own rate. */
3066
+ costUsd: number;
3067
+ outcome: "ok" | "error";
3090
3068
  /**
3091
- * Human-readable detail behind `error` (provider message, first schema
3092
- * issue): feeds the journaled WireError message. An additive
3093
- * field; never part of identity.
3069
+ * Transport retries inside this activation. Present only when
3070
+ * greater than zero; live telemetry only (absent on replay).
3094
3071
  */
3095
- errorMessage?: string;
3096
- /** Present if and only if status === 'escalated'. */
3097
- escalation?: EscalationReport;
3072
+ retries?: number;
3073
+ } | {
3074
+ type: "agent:end";
3075
+ agentType: string;
3076
+ label?: string;
3077
+ status: string;
3078
+ usage: Usage;
3079
+ costUsd: number;
3080
+ entryRef: number;
3098
3081
  /**
3099
- * Engine-internal: the accepted escalate request before the runtime
3082
+ * Present and true when this agent's usage is approximate rather
3083
+ * than reported by the provider (the turn was cut by a transport
3084
+ * failure, a ceiling that severed the stream, or an abort). Absent
3085
+ * means the provider reported the usage exactly. Mirrors the
3086
+ * terminal journal entry's usageApprox.
3087
+ */
3088
+ usageApprox?: boolean;
3089
+ /**
3090
+ * Total transport retries across the span's activations. Present
3091
+ * only when greater than zero; live telemetry only, never
3092
+ * journaled, so a replayed agent:end omits it (absent means "zero
3093
+ * or unknown").
3094
+ */
3095
+ retryCount?: number;
3096
+ /**
3097
+ * The exploration guard counters (RV-210). Present live whenever
3098
+ * any exploration guard limit was configured for the invocation;
3099
+ * on replay present only when the guard abort journaled it in the
3100
+ * terminal error payload.
3101
+ */
3102
+ exploration?: ExplorationSummary;
3103
+ } | {
3104
+ type: "agent:error";
3105
+ agentType: string;
3106
+ label?: string;
3107
+ error: WireError;
3108
+ willRetry: boolean;
3109
+ } | {
3110
+ type: "agent:schema-retry";
3111
+ agentType: string;
3112
+ attempt: number;
3113
+ maxAttempts: number;
3114
+ } | {
3115
+ type: "agent:stream";
3116
+ delta: string;
3117
+ };
3118
+ /** Tool lifecycle (emitters arrive with the tool system, M3). */
3119
+ type ToolEvents = {
3120
+ type: "tool:start";
3121
+ toolName: string;
3122
+ risk?: Json;
3123
+ } | {
3124
+ type: "tool:end";
3125
+ toolName: string;
3126
+ outcome: "ok" | "error" | "denied";
3127
+ durationMs: number;
3128
+ /**
3129
+ * Audit fields (M5-T05): the chain verdict,
3130
+ * the deciding layer, the matched rule, and advisory domain-rule
3131
+ * matches. Telemetry, never identity; ask verdicts additionally
3132
+ * journal as suspended approvals.
3133
+ */
3134
+ verdict?: "allow" | "deny" | "ask";
3135
+ decidedBy?: string;
3136
+ rule?: Json;
3137
+ advisory?: Json;
3138
+ /**
3139
+ * Present when an exploration guard (RV-210), not the permission
3140
+ * chain, denied the call: the outcome is 'denied' and the call was
3141
+ * never dispatched.
3142
+ */
3143
+ guard?: "repeated-signature";
3144
+ };
3145
+ /**
3146
+ * Bare-nondeterminism detection (RV-209). Emitted LIVE by the segment
3147
+ * that observed the call, at most once per (category, provenance) per
3148
+ * execution segment; never journaled and never re-emitted with the
3149
+ * `replayed` flag. Because replay re-executes the workflow body, a
3150
+ * violation that survives in the code fires again on every replay of
3151
+ * the run, so the event appears organically in both live and replayed
3152
+ * streams. Exempt provenances (installed dependencies under
3153
+ * node_modules and Node runtime frames) never emit: they are
3154
+ * classified and silenced, which is what keeps an SDK's internal
3155
+ * `Math.random()` from branding the run nondeterministic.
3156
+ */
3157
+ type DeterminismEvents = {
3158
+ type: "determinism:warning"; /** Which patched global fired. */
3159
+ category: "bare-date-now" | "bare-math-random";
3160
+ /**
3161
+ * 'workflow': the caller is workflow-origin code (the violation the
3162
+ * guard exists for; rejects the run under `determinism.mode:
3163
+ * 'error'`). 'allowlisted': the caller matched a configured
3164
+ * `determinism.allowlist` pattern and is exempt by explicit host
3165
+ * decision; emitted for visibility, never rejects.
3166
+ */
3167
+ provenance: "workflow" | "allowlisted"; /** The calling stack frame, after the configured redaction hook. */
3168
+ frame: string; /** Parsed location when the frame carries one, after redaction. */
3169
+ file?: string;
3170
+ line?: number;
3171
+ column?: number;
3172
+ };
3173
+ /**
3174
+ * Adaptive orchestration, resolutions, and
3175
+ * accounting: emitted only by runs where the corresponding machinery is
3176
+ * active (applicability per mode:
3177
+ * https://docs.rulvar.com/guide/adaptive-orchestration). The types land as
3178
+ * one closed catalog with M7-T03; emitters arrive with their tasks.
3179
+ */
3180
+ type AdaptiveEvents = {
3181
+ type: "plan:revised";
3182
+ entryRef: number;
3183
+ planHash: string;
3184
+ applied: number;
3185
+ dropped: number;
3186
+ revisionUnitsRemaining: number;
3187
+ } | {
3188
+ type: "node:parked";
3189
+ nodeId: string;
3190
+ logicalTaskId: string;
3191
+ } | {
3192
+ type: "node:cancelled";
3193
+ nodeId: string;
3194
+ logicalTaskId: string;
3195
+ } | {
3196
+ type: "node:linked";
3197
+ nodeId: string;
3198
+ logicalTaskId: string;
3199
+ donorRef: number;
3200
+ reclaimedUsd: number;
3201
+ } | {
3202
+ type: "orchestrator:woke";
3203
+ digestSeq: number;
3204
+ planHash: string;
3205
+ coversToOrdinal: number;
3206
+ renderSize: number;
3207
+ } | {
3208
+ /**
3209
+ * Two emitted shapes share the discriminant: the cap-freeze form
3210
+ * carries { atCap: true, spentUsd, capUsd, finalizeReserveUsd },
3211
+ * and the per-wake digest form carries atCap plus the passive
3212
+ * WakeBudgetBlock fields (runSpentUsd .. softWarning).
3213
+ */
3214
+ type: "orchestrator:budget";
3215
+ atCap: boolean;
3216
+ spentUsd?: number;
3217
+ capUsd?: number;
3218
+ finalizeReserveUsd?: number;
3219
+ runSpentUsd?: number;
3220
+ runCeilingUsd?: number;
3221
+ orchestratorSpentUsd?: number;
3222
+ orchestratorCapUsd?: number;
3223
+ orchestratorShare?: number;
3224
+ softWarning?: boolean;
3225
+ } | {
3226
+ type: "escalation:raised";
3227
+ entryRef: number;
3228
+ kind: "scope_bigger" | "scope_different" | "blocked_with_evidence";
3229
+ logicalTaskId: string;
3230
+ costToDateUsd: number;
3231
+ } | {
3232
+ type: "escalation:decided";
3233
+ entryRef: number;
3234
+ decision: "retry" | "decompose" | "cancel" | "accept";
3235
+ by: ResolutionBy;
3236
+ countsAgainstLimit: boolean;
3237
+ } | {
3238
+ type: "spawn:admitted";
3239
+ entryRef: number; /** The admitting arms of the unified AdmitVerdict union. */
3240
+ verdict: "admit" | "reuse_full" | "admit_graft";
3241
+ agentType: string;
3242
+ logicalTaskId: string;
3243
+ /**
3244
+ * Spawn-unit balance after the budget-layer debit. Present on
3245
+ * budget-layer admissions (the orchestrator spawn tools and
3246
+ * ctx.workflow children); absent on lineage-layer admissions
3247
+ * (ctx.agent roots), whose spawn-unit debit rides the dispatch
3248
+ * itself (v1.22.0 review P2-5).
3249
+ */
3250
+ spawnUnitsAfter?: number;
3251
+ } | {
3252
+ type: "spawn:rejected";
3253
+ /**
3254
+ * The journaled admission decision entry; absent for the
3255
+ * pre-admission config gates (orchestrate maxSpawns), which
3256
+ * reject before anything is journaled.
3257
+ */
3258
+ entryRef?: number;
3259
+ code: string;
3260
+ agentType: string;
3261
+ logicalTaskId?: string;
3262
+ } | {
3263
+ type: "verify:failed";
3264
+ entryRef: number;
3265
+ logicalTaskId: string;
3266
+ rung: number;
3267
+ gate: "mechanical" | "judge" | "spot-check";
3268
+ } | {
3269
+ type: "ledger:op";
3270
+ entryRef: number;
3271
+ op: "brief_set" | "fact_add" | "fact_supersede" | "lesson_add" | "observation_add";
3272
+ } | {
3273
+ type: "stall:detected";
3274
+ logicalTaskId: string;
3275
+ stallStreak: number;
3276
+ } | {
3277
+ type: "guard:oscillation";
3278
+ spawnKeyHash: string;
3279
+ oscillationCount: number;
3280
+ limit: number;
3281
+ } | {
3282
+ type: "resolution:applied";
3283
+ targetRef: number;
3284
+ entryRef: number;
3285
+ by: ResolutionBy;
3286
+ } | {
3287
+ type: "resolution:superseded";
3288
+ targetRef: number;
3289
+ entryRef: number;
3290
+ supersededBy: number;
3291
+ reason: "already_resolved" | "target_abandoned";
3292
+ } | {
3293
+ type: "termination:debit";
3294
+ entryRef: number;
3295
+ counter: string;
3296
+ remaining: number;
3297
+ phi: number;
3298
+ } | {
3299
+ type: "termination:denied";
3300
+ entryRef: number;
3301
+ counter: string;
3302
+ code: string;
3303
+ } | {
3304
+ type: "termination:config-drift";
3305
+ field: string;
3306
+ frozenValue: Json;
3307
+ liveValue: Json;
3308
+ } | {
3309
+ /**
3310
+ * Declared for hosts; not emitted today. The compatibility scan
3311
+ * runs strictly before a run's event stream exists, so the
3312
+ * refusal travels only as the typed JournalCompatibilityError
3313
+ * (which carries the same fields).
3314
+ */
3315
+ type: "journal:compat";
3316
+ code: "HASH_VERSION_TOO_OLD" | "HASH_VERSION_TOO_NEW";
3317
+ found: number;
3318
+ window: [number, number];
3319
+ };
3320
+ type WorkflowEventBody = CoreEvents | AgentEvents | ToolEvents | DeterminismEvents | AdaptiveEvents;
3321
+ /**
3322
+ * The envelope: seq is an independent per-run
3323
+ * telemetry counter, strictly increasing in emission order and DISTINCT
3324
+ * from JournalEntry.seq (never compare or join the two; entryRef fields
3325
+ * carry journal seqs explicitly). ts is wall clock, telemetry only.
3326
+ * replayed is true only on re-emitted journal-backed lifecycle events;
3327
+ * stream deltas are never re-emitted.
3328
+ */
3329
+ type WorkflowEvent = {
3330
+ runId: string;
3331
+ seq: number;
3332
+ ts: string;
3333
+ spanId: string;
3334
+ parentSpanId?: string;
3335
+ replayed?: boolean;
3336
+ } & WorkflowEventBody;
3337
+ //#endregion
3338
+ //#region src/runtime/no-progress.d.ts
3339
+ /**
3340
+ * The no-progress abort class (M3-T08): an engine-defined detector
3341
+ * journaled as a first-class terminal abort distinct from user
3342
+ * cancellation (a cancelled entry always reruns; a no-progress abort
3343
+ * must replay, or every resume would re-pay the stuck turns). The
3344
+ * interim heuristic is committed: N consecutive
3345
+ * turns without tool calls or artifact deltas, N = 3; the broader
3346
+ * heuristic stays OQ-15, revisited on dogfood traces.
3347
+ *
3348
+ * Encoding: the abort is the agent's
3349
+ * terminal entry with status 'limit', an error payload carrying
3350
+ * abortClass 'no-progress', and memoizeOutcome stamped by the ENGINE on
3351
+ * the terminal entry, so the frozen memoize-limit rule replays it on
3352
+ * every subsequent resume without a live rerun. In M3 the runtime has no
3353
+ * per-turn artifact channel, so the tool-call test subsumes artifact
3354
+ * deltas; per-turn artifact producers arrive with M4 compaction.
3355
+ */
3356
+ /** The committed no-progress detector N. */
3357
+ declare const DEFAULT_NO_PROGRESS_TURNS = 3;
3358
+ /**
3359
+ * The consumer-visible engine-decided abort classes (FR-424).
3360
+ * 'no-progress' is the detector below; 'output-truncated' is a
3361
+ * schema-less turn that ended at its output token allowance
3362
+ * (finish reason 'max-tokens') without visible output (v1.9.0
3363
+ * follow-up review); 'exploration' is the tripped no-new-evidence
3364
+ * exploration guard (RV-210), carrying its structured summary in the
3365
+ * terminal error payload. All stamp memoizeOutcome on the terminal:
3366
+ * the work is paid, so every resume replays the abort instead of
3367
+ * re-paying the same bounded failure.
3368
+ */
3369
+ type AbortClass = "no-progress" | "output-truncated" | "exploration";
3370
+ /**
3371
+ * Counts consecutive progress-free turns. A turn with at least one tool
3372
+ * call (or, later, an artifact delta) resets the streak; a turn with
3373
+ * neither lengthens it; the detector trips when the streak reaches the
3374
+ * threshold AND the loop would otherwise continue.
3375
+ */
3376
+ declare class NoProgressDetector {
3377
+ private streakInternal;
3378
+ private readonly threshold;
3379
+ constructor(threshold?: number);
3380
+ get streak(): number;
3381
+ /** Records one completed model turn. */
3382
+ recordTurn(progress: {
3383
+ toolCalls: number;
3384
+ artifactDeltas?: number;
3385
+ }): void;
3386
+ get tripped(): boolean;
3387
+ describe(): string;
3388
+ }
3389
+ //#endregion
3390
+ //#region src/runtime/usage-limits.d.ts
3391
+ interface UsageLimits {
3392
+ /** Default 32. */
3393
+ maxTurns?: number;
3394
+ /** Unlimited by default. */
3395
+ maxToolCalls?: number;
3396
+ /** Unlimited by default (model caps still apply). */
3397
+ maxOutputTokensPerTurn?: number;
3398
+ /** Per-agent wall clock; unlimited by default. */
3399
+ timeoutMs?: number;
3400
+ /** Gap between stream events; default 120000. */
3401
+ streamIdleTimeoutMs?: number;
3402
+ /**
3403
+ * The no-progress detector N (committed at 3):
3404
+ * consecutive turns without tool calls or artifact deltas before the
3405
+ * engine aborts with the dedicated class (M3-T08).
3406
+ */
3407
+ noProgressTurns?: number;
3408
+ /**
3409
+ * Soft 50%/80% thresholds over maxToolCalls (RV-210), surfaced to the
3410
+ * model as a plain user message carrying the exact remaining count.
3411
+ * Inert (with a loud log warning) when maxToolCalls is not set. Off by
3412
+ * default: the notice enters the conversation, so enabling it changes
3413
+ * recorded model requests.
3414
+ */
3415
+ toolBudgetNotices?: boolean;
3416
+ /**
3417
+ * How many times the SAME tool signature (name + canonical JCS args)
3418
+ * may execute per invocation (RV-210). The call that would exceed it
3419
+ * is denied with a typed error tool result instead of dispatched; the
3420
+ * denial is visible to the model and does not consume maxToolCalls.
3421
+ * Unlimited by default.
3422
+ */
3423
+ maxRepeatedToolSignature?: number;
3424
+ /**
3425
+ * How many consecutive successful tool executions may return only
3426
+ * already-seen result digests before the engine aborts the invocation
3427
+ * as status 'limit' with abortClass 'exploration' (RV-210). The
3428
+ * executed work is kept and the terminal memoizes. Unlimited by
3429
+ * default.
3430
+ */
3431
+ maxNoNewEvidenceCalls?: number;
3432
+ }
3433
+ declare const DEFAULT_MAX_TURNS = 32;
3434
+ declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 12e4;
3435
+ interface EffectiveUsageLimits {
3436
+ maxTurns: number;
3437
+ maxToolCalls?: number;
3438
+ maxOutputTokensPerTurn?: number;
3439
+ timeoutMs?: number;
3440
+ streamIdleTimeoutMs: number;
3441
+ /** Default DEFAULT_NO_PROGRESS_TURNS. */
3442
+ noProgressTurns?: number;
3443
+ /** RV-210 exploration guards; absent = off. */
3444
+ toolBudgetNotices?: boolean;
3445
+ maxRepeatedToolSignature?: number;
3446
+ maxNoNewEvidenceCalls?: number;
3447
+ }
3448
+ /**
3449
+ * Limits merge per spawn: AgentOpts.limits over profile limits over engine
3450
+ * defaults.limits.
3451
+ */
3452
+ declare function mergeUsageLimits(call?: UsageLimits, profile?: UsageLimits, engine?: UsageLimits): EffectiveUsageLimits;
3453
+ /**
3454
+ * Validates one UsageLimits layer at its intake boundary (v1.34.0
3455
+ * review P2-3): a malformed field (NaN, Infinity, a negative, a
3456
+ * fraction) is a typed ConfigError before the merge, before any journal
3457
+ * entry, and before any provider dispatch. `site` names the layer in the
3458
+ * error text (e.g. `RunOptions.limits`). Counts are positive integers
3459
+ * (maxToolCalls may be 0: a spawn that must not call tools).
3460
+ * streamIdleTimeoutMs is handed to setTimeout as-is, so it is bounded by
3461
+ * the Node timer maximum like RetryPolicy delays; timeoutMs is a
3462
+ * wall-clock comparison, so it has no upper bound. Every present field
3463
+ * is checked; absent fields keep their defaults.
3464
+ */
3465
+ declare function validateUsageLimits(limits: UsageLimits, site: string): void;
3466
+ //#endregion
3467
+ //#region src/runtime/agent-loop.d.ts
3468
+ type AgentStatus = "ok" | "error" | "limit" | "cancelled" | "skipped" | "escalated";
3469
+ /** Artifact: the normative shape of AgentResult.artifacts entries. */
3470
+ interface Artifact {
3471
+ /** Stable within the result. */
3472
+ id: string;
3473
+ /** Closed in v1. */
3474
+ kind: "file" | "patch" | "json" | "text";
3475
+ /** Telemetry only. */
3476
+ label?: string;
3477
+ /** Changed-file list (kind 'patch': worktree collect()). */
3478
+ files?: string[];
3479
+ /** TranscriptStore blob ref for offloaded content. */
3480
+ ref?: string;
3481
+ /** Inline JSON content for small values. */
3482
+ data?: Json;
3483
+ }
3484
+ /** The verdict of one mechanical acceptance gate evaluation. */
3485
+ interface MechanicalGateVerdict {
3486
+ pass: boolean;
3487
+ detail?: string;
3488
+ }
3489
+ /**
3490
+ * A mechanical acceptance gate: an engine-registered NAMED pure function
3491
+ * over AgentResult.artifacts.
3492
+ * The registry is per engine like every other registry; the
3493
+ * ladder driver journals each evaluation as a decision entry, so the
3494
+ * ladder fold consumes only journaled verdicts, never live re-evaluation.
3495
+ */
3496
+ type MechanicalGateProfile = (artifacts: readonly Artifact[]) => MechanicalGateVerdict;
3497
+ interface AgentResult<T> {
3498
+ status: AgentStatus;
3499
+ output: T | null;
3500
+ usage: Usage;
3501
+ costUsd: number;
3502
+ turns: number;
3503
+ /**
3504
+ * The model that actually served the loop phase at the end (M4-T04):
3505
+ * differs from the requested spec only under transport failover.
3506
+ */
3507
+ servedBy: ModelRef;
3508
+ /**
3509
+ * Present only when the call spanned MORE THAN ONE (invocation role,
3510
+ * serving model) pair (the loop, extract, finalize, and summarize
3511
+ * roles resolve independently): usage split per (role, model), so
3512
+ * `costUsd` and every cost bucket price each slice at its own rate
3513
+ * and `CostReport.byRole` attributes each phase to its own bucket
3514
+ * (v1.19.0 review P1-2). Absent for a single-phase single-model call,
3515
+ * which (usage, servedBy) already describes exactly.
3516
+ */
3517
+ usageByModel?: UsageSlice[];
3518
+ transcriptRef: string;
3519
+ artifacts?: Artifact[];
3520
+ error?: AgentError;
3521
+ /**
3522
+ * Human-readable detail behind `error` (provider message, first schema
3523
+ * issue): feeds the journaled WireError message. An additive
3524
+ * field; never part of identity.
3525
+ */
3526
+ errorMessage?: string;
3527
+ /** Present if and only if status === 'escalated'. */
3528
+ escalation?: EscalationReport;
3529
+ /**
3530
+ * Engine-internal: the accepted escalate request before the runtime
3100
3531
  * fills costToDate and salvage into the full report. The ctx layer
3101
3532
  * consumes and removes it; consumers read `escalation`.
3102
3533
  */
@@ -3114,6 +3545,15 @@ interface AgentResult<T> {
3114
3545
  * result omits it (absent means "zero or unknown").
3115
3546
  */
3116
3547
  transportRetries?: number;
3548
+ /**
3549
+ * The exploration guard counters (RV-210): present whenever any of
3550
+ * the exploration limits (toolBudgetNotices, maxRepeatedToolSignature,
3551
+ * maxNoNewEvidenceCalls) was configured. Journaled inside the terminal
3552
+ * error payload (and restored on replay) only for the guard's own
3553
+ * abort (abortClass 'exploration'); otherwise live telemetry like
3554
+ * transportRetries.
3555
+ */
3556
+ exploration?: ExplorationSummary;
3117
3557
  }
3118
3558
  type EscalatedResult<T> = AgentResult<T> & {
3119
3559
  status: "escalated";
@@ -3333,8 +3773,8 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
3333
3773
  }>;
3334
3774
  };
3335
3775
  agentType?: string;
3336
- /** The primary invocation role of the tool loop; default 'loop' (M6-T05). */
3337
- role?: "loop" | "plan" | "orchestrate";
3776
+ /** The primary invocation role of the tool loop; default 'loop' (M6-T05; RV-211 adds synthesize). */
3777
+ role?: "loop" | "plan" | "orchestrate" | "synthesize";
3338
3778
  label?: string;
3339
3779
  now?: () => number;
3340
3780
  }
@@ -4314,433 +4754,73 @@ declare class AdmissionController {
4314
4754
  evaluateLineage(spec: {
4315
4755
  name: string;
4316
4756
  lineage?: SpawnLineageOpt;
4317
- approach?: string;
4318
- ancestry?: LogicalTaskId[];
4319
- signature?: Partial<ApproachSignatureInputs>;
4320
- }): {
4321
- decision: {
4322
- kind: "ok";
4323
- lineage: SpawnLineage;
4324
- } | {
4325
- kind: "reject";
4326
- reason: {
4327
- code: "lineage_busy" | "lineage_exhausted";
4328
- };
4329
- };
4330
- statsBefore?: LineageStats;
4331
- };
4332
- /**
4333
- * Registers a live lineage admit the moment its caller commits to
4334
- * appending the decision entry, closing the single-live-attempt window
4335
- * until the journal absorbs the entry (DEF-3).
4336
- */
4337
- registerLineageAdmit(logicalTaskId: LogicalTaskId): void;
4338
- /**
4339
- * Evaluates one spawn live, strictly BEFORE its decision entry is
4340
- * appended. On admit the reserve is committed on the whole ancestor
4341
- * account chain atomically with the evaluation; the caller journals the
4342
- * returned decision and only then produces effects (child account,
4343
- * dispatch). On reject nothing is committed and the reject verdict is
4344
- * journaled by the caller so replay re-delivers it without
4345
- * re-evaluation.
4346
- */
4347
- /**
4348
- * The reserve the DISPATCH layer will actually commit for this spec:
4349
- * the estimate (or the flat default) clamped by the explicit child
4350
- * budget when one exists, because only an explicit budget opens a
4351
- * child-allowance account at dispatch; the childBudgetFraction cap
4352
- * never materializes as an account and must not shrink the
4353
- * projection. The token-count-priced estimate of ctx.agent is
4354
- * unreachable here (async); a divergence there lands as a journaled
4355
- * dispatch rejection instead of a strand.
4356
- */
4357
- projectedDispatchReserveUsd(spec: Pick<AdmitSpec, "estCostUsd" | "budgetUsd">): number;
4358
- admit(spec: AdmitSpec, options?: {
4359
- commitReserve?: boolean;
4360
- }): AdmissionDecision;
4361
- /**
4362
- * Resume roll-forward for an orchestrator child (M6-T07): restores the
4363
- * children-quota counter only. The budget seed already counts settled
4364
- * agent dispatches, and an in-flight child re-commits its reserve
4365
- * through the ctx.agent dispatch path.
4366
- */
4367
- recoverChild(nodeKey: string): void;
4368
- /**
4369
- * Resume roll-forward for a child that already SETTLED before the
4370
- * resume: re-registers the counters (maxChildrenPerNode, the lifetime
4371
- * cap, statsBefore fidelity) without committing any reserve; the spend
4372
- * itself sits in the root ledger seed.
4373
- */
4374
- recoverSettled(parentAccountScope: string): void;
4375
- /**
4376
- * Resume roll-forward for an admission whose decision entry exists but
4377
- * whose child has NOT settled: re-applies the recorded reserve and
4378
- * counters without re-evaluating any limit (replay never
4379
- * re-evaluates admission; reserves are recovered, never
4380
- * re-estimated).
4381
- */
4382
- recoverInFlight(parentAccountScope: string, verdict: AdmitVerdict): void;
4383
- }
4384
- //#endregion
4385
- //#region src/l0/events.d.ts
4386
- /** Run lifecycle and core telemetry (M1 subset). */
4387
- type CoreEvents = {
4388
- type: "run:start";
4389
- workflow: string;
4390
- resumed: boolean;
4391
- } | {
4392
- type: "run:end";
4393
- status: "ok" | "error" | "cancelled" | "exhausted" | "suspended";
4394
- totalUsd: number;
4395
- /**
4396
- * Present and true when any priced usage folded into totalUsd is
4397
- * approximate (a transport cut, a stream the ceiling severed, or an
4398
- * abort left a turn's usage estimated rather than reported by the
4399
- * provider), so totalUsd is a lower bound estimate, never an exact
4400
- * charge. Absent means every contributing turn reported exact usage.
4401
- */
4402
- usageApprox?: boolean;
4403
- } | {
4404
- type: "phase:start";
4405
- phase: string;
4406
- } | {
4407
- type: "log";
4408
- level: "debug" | "info" | "warn" | "error";
4409
- msg: string;
4410
- data?: Json;
4411
- } | {
4412
- type: "budget:update";
4413
- spentUsd: number;
4414
- remainingUsd: number | null;
4415
- committedReserveUsd: number;
4416
- } | {
4417
- type: "external:waiting";
4418
- key: string;
4419
- entryRef: number;
4420
- prompt?: string;
4421
- deadlineAt?: string;
4422
- } | {
4423
- type: "approval:pending";
4424
- toolName: string;
4425
- entryRef: number;
4426
- deadlineAt?: string;
4427
- } | {
4428
- type: "child:start";
4429
- workflow: string;
4430
- scope: string;
4431
- } | {
4432
- type: "child:end";
4433
- workflow: string;
4434
- scope: string;
4435
- status: string;
4436
- };
4437
- /**
4438
- * Agent lifecycle. One logical agent dispatch emits EXACTLY ONE
4439
- * `agent:start`/`agent:end` pair on its span (the start carries the
4440
- * primary role), and each model invocation phase inside the span
4441
- * (`loop`, then possibly `summarize` activations, `finalize`,
4442
- * `extract`) emits its own `agent:phase:start`/`agent:phase:end` pair,
4443
- * so durations, per-phase usage, and attempts are derivable without
4444
- * heuristics (the RV-207 event-model contract; before it, every phase
4445
- * emitted an unpaired extra `agent:start` and consumers pairing starts
4446
- * with the single end computed the LAST phase's duration as the
4447
- * agent's). `reduceInvocationTable` is the official reducer over this
4448
- * vocabulary.
4449
- */
4450
- type AgentEvents = {
4451
- type: "agent:queued";
4452
- agentType: string;
4453
- label?: string;
4454
- } | {
4455
- type: "agent:start";
4456
- agentType: string;
4457
- label?: string;
4458
- model: string;
4459
- role: string;
4460
- } | {
4461
- type: "agent:phase:start";
4462
- agentType: string;
4463
- label?: string; /** The invocation role this phase activation runs as. */
4464
- role: string; /** The model the activation resolved to (fallbacks may serve another; the end event reports the server). */
4465
- model: string;
4466
- /**
4467
- * 1-based activation ordinal within the span, unique per
4468
- * activation (a summarize that fires three times gets three
4469
- * pairs). Key phases by (spanId, invocation).
4470
- */
4471
- invocation: number;
4472
- } | {
4473
- type: "agent:phase:end";
4474
- agentType: string;
4475
- label?: string;
4476
- role: string; /** The model that actually served the activation's last attempt. */
4477
- model: string;
4478
- invocation: number;
4479
- /**
4480
- * Wall-clock activation duration. Live telemetry only: replayed
4481
- * phase pairs (reconstructed from the terminal entry's usage
4482
- * slices) carry 0.
4483
- */
4484
- durationMs: number; /** The usage this activation added to its (role, model) slices. */
4485
- usage: Usage; /** That usage priced at each serving model's own rate. */
4486
- costUsd: number;
4487
- outcome: "ok" | "error";
4488
- /**
4489
- * Transport retries inside this activation. Present only when
4490
- * greater than zero; live telemetry only (absent on replay).
4491
- */
4492
- retries?: number;
4493
- } | {
4494
- type: "agent:end";
4495
- agentType: string;
4496
- label?: string;
4497
- status: string;
4498
- usage: Usage;
4499
- costUsd: number;
4500
- entryRef: number;
4501
- /**
4502
- * Present and true when this agent's usage is approximate rather
4503
- * than reported by the provider (the turn was cut by a transport
4504
- * failure, a ceiling that severed the stream, or an abort). Absent
4505
- * means the provider reported the usage exactly. Mirrors the
4506
- * terminal journal entry's usageApprox.
4507
- */
4508
- usageApprox?: boolean;
4509
- /**
4510
- * Total transport retries across the span's activations. Present
4511
- * only when greater than zero; live telemetry only, never
4512
- * journaled, so a replayed agent:end omits it (absent means "zero
4513
- * or unknown").
4514
- */
4515
- retryCount?: number;
4516
- } | {
4517
- type: "agent:error";
4518
- agentType: string;
4519
- label?: string;
4520
- error: WireError;
4521
- willRetry: boolean;
4522
- } | {
4523
- type: "agent:schema-retry";
4524
- agentType: string;
4525
- attempt: number;
4526
- maxAttempts: number;
4527
- } | {
4528
- type: "agent:stream";
4529
- delta: string;
4530
- };
4531
- /** Tool lifecycle (emitters arrive with the tool system, M3). */
4532
- type ToolEvents = {
4533
- type: "tool:start";
4534
- toolName: string;
4535
- risk?: Json;
4536
- } | {
4537
- type: "tool:end";
4538
- toolName: string;
4539
- outcome: "ok" | "error" | "denied";
4540
- durationMs: number;
4757
+ approach?: string;
4758
+ ancestry?: LogicalTaskId[];
4759
+ signature?: Partial<ApproachSignatureInputs>;
4760
+ }): {
4761
+ decision: {
4762
+ kind: "ok";
4763
+ lineage: SpawnLineage;
4764
+ } | {
4765
+ kind: "reject";
4766
+ reason: {
4767
+ code: "lineage_busy" | "lineage_exhausted";
4768
+ };
4769
+ };
4770
+ statsBefore?: LineageStats;
4771
+ };
4541
4772
  /**
4542
- * Audit fields (M5-T05): the chain verdict,
4543
- * the deciding layer, the matched rule, and advisory domain-rule
4544
- * matches. Telemetry, never identity; ask verdicts additionally
4545
- * journal as suspended approvals.
4773
+ * Registers a live lineage admit the moment its caller commits to
4774
+ * appending the decision entry, closing the single-live-attempt window
4775
+ * until the journal absorbs the entry (DEF-3).
4546
4776
  */
4547
- verdict?: "allow" | "deny" | "ask";
4548
- decidedBy?: string;
4549
- rule?: Json;
4550
- advisory?: Json;
4551
- };
4552
- /**
4553
- * Bare-nondeterminism detection (RV-209). Emitted LIVE by the segment
4554
- * that observed the call, at most once per (category, provenance) per
4555
- * execution segment; never journaled and never re-emitted with the
4556
- * `replayed` flag. Because replay re-executes the workflow body, a
4557
- * violation that survives in the code fires again on every replay of
4558
- * the run, so the event appears organically in both live and replayed
4559
- * streams. Exempt provenances (installed dependencies under
4560
- * node_modules and Node runtime frames) never emit: they are
4561
- * classified and silenced, which is what keeps an SDK's internal
4562
- * `Math.random()` from branding the run nondeterministic.
4563
- */
4564
- type DeterminismEvents = {
4565
- type: "determinism:warning"; /** Which patched global fired. */
4566
- category: "bare-date-now" | "bare-math-random";
4777
+ registerLineageAdmit(logicalTaskId: LogicalTaskId): void;
4567
4778
  /**
4568
- * 'workflow': the caller is workflow-origin code (the violation the
4569
- * guard exists for; rejects the run under `determinism.mode:
4570
- * 'error'`). 'allowlisted': the caller matched a configured
4571
- * `determinism.allowlist` pattern and is exempt by explicit host
4572
- * decision; emitted for visibility, never rejects.
4779
+ * Evaluates one spawn live, strictly BEFORE its decision entry is
4780
+ * appended. On admit the reserve is committed on the whole ancestor
4781
+ * account chain atomically with the evaluation; the caller journals the
4782
+ * returned decision and only then produces effects (child account,
4783
+ * dispatch). On reject nothing is committed and the reject verdict is
4784
+ * journaled by the caller so replay re-delivers it without
4785
+ * re-evaluation.
4573
4786
  */
4574
- provenance: "workflow" | "allowlisted"; /** The calling stack frame, after the configured redaction hook. */
4575
- frame: string; /** Parsed location when the frame carries one, after redaction. */
4576
- file?: string;
4577
- line?: number;
4578
- column?: number;
4579
- };
4580
- /**
4581
- * Adaptive orchestration, resolutions, and
4582
- * accounting: emitted only by runs where the corresponding machinery is
4583
- * active (applicability per mode:
4584
- * https://docs.rulvar.com/guide/adaptive-orchestration). The types land as
4585
- * one closed catalog with M7-T03; emitters arrive with their tasks.
4586
- */
4587
- type AdaptiveEvents = {
4588
- type: "plan:revised";
4589
- entryRef: number;
4590
- planHash: string;
4591
- applied: number;
4592
- dropped: number;
4593
- revisionUnitsRemaining: number;
4594
- } | {
4595
- type: "node:parked";
4596
- nodeId: string;
4597
- logicalTaskId: string;
4598
- } | {
4599
- type: "node:cancelled";
4600
- nodeId: string;
4601
- logicalTaskId: string;
4602
- } | {
4603
- type: "node:linked";
4604
- nodeId: string;
4605
- logicalTaskId: string;
4606
- donorRef: number;
4607
- reclaimedUsd: number;
4608
- } | {
4609
- type: "orchestrator:woke";
4610
- digestSeq: number;
4611
- planHash: string;
4612
- coversToOrdinal: number;
4613
- renderSize: number;
4614
- } | {
4615
4787
  /**
4616
- * Two emitted shapes share the discriminant: the cap-freeze form
4617
- * carries { atCap: true, spentUsd, capUsd, finalizeReserveUsd },
4618
- * and the per-wake digest form carries atCap plus the passive
4619
- * WakeBudgetBlock fields (runSpentUsd .. softWarning).
4788
+ * The reserve the DISPATCH layer will actually commit for this spec:
4789
+ * the estimate (or the flat default) clamped by the explicit child
4790
+ * budget when one exists, because only an explicit budget opens a
4791
+ * child-allowance account at dispatch; the childBudgetFraction cap
4792
+ * never materializes as an account and must not shrink the
4793
+ * projection. The token-count-priced estimate of ctx.agent is
4794
+ * unreachable here (async); a divergence there lands as a journaled
4795
+ * dispatch rejection instead of a strand.
4620
4796
  */
4621
- type: "orchestrator:budget";
4622
- atCap: boolean;
4623
- spentUsd?: number;
4624
- capUsd?: number;
4625
- finalizeReserveUsd?: number;
4626
- runSpentUsd?: number;
4627
- runCeilingUsd?: number;
4628
- orchestratorSpentUsd?: number;
4629
- orchestratorCapUsd?: number;
4630
- orchestratorShare?: number;
4631
- softWarning?: boolean;
4632
- } | {
4633
- type: "escalation:raised";
4634
- entryRef: number;
4635
- kind: "scope_bigger" | "scope_different" | "blocked_with_evidence";
4636
- logicalTaskId: string;
4637
- costToDateUsd: number;
4638
- } | {
4639
- type: "escalation:decided";
4640
- entryRef: number;
4641
- decision: "retry" | "decompose" | "cancel" | "accept";
4642
- by: ResolutionBy;
4643
- countsAgainstLimit: boolean;
4644
- } | {
4645
- type: "spawn:admitted";
4646
- entryRef: number; /** The admitting arms of the unified AdmitVerdict union. */
4647
- verdict: "admit" | "reuse_full" | "admit_graft";
4648
- agentType: string;
4649
- logicalTaskId: string;
4797
+ projectedDispatchReserveUsd(spec: Pick<AdmitSpec, "estCostUsd" | "budgetUsd">): number;
4798
+ admit(spec: AdmitSpec, options?: {
4799
+ commitReserve?: boolean;
4800
+ }): AdmissionDecision;
4650
4801
  /**
4651
- * Spawn-unit balance after the budget-layer debit. Present on
4652
- * budget-layer admissions (the orchestrator spawn tools and
4653
- * ctx.workflow children); absent on lineage-layer admissions
4654
- * (ctx.agent roots), whose spawn-unit debit rides the dispatch
4655
- * itself (v1.22.0 review P2-5).
4802
+ * Resume roll-forward for an orchestrator child (M6-T07): restores the
4803
+ * children-quota counter only. The budget seed already counts settled
4804
+ * agent dispatches, and an in-flight child re-commits its reserve
4805
+ * through the ctx.agent dispatch path.
4656
4806
  */
4657
- spawnUnitsAfter?: number;
4658
- } | {
4659
- type: "spawn:rejected";
4807
+ recoverChild(nodeKey: string): void;
4660
4808
  /**
4661
- * The journaled admission decision entry; absent for the
4662
- * pre-admission config gates (orchestrate maxSpawns), which
4663
- * reject before anything is journaled.
4809
+ * Resume roll-forward for a child that already SETTLED before the
4810
+ * resume: re-registers the counters (maxChildrenPerNode, the lifetime
4811
+ * cap, statsBefore fidelity) without committing any reserve; the spend
4812
+ * itself sits in the root ledger seed.
4664
4813
  */
4665
- entryRef?: number;
4666
- code: string;
4667
- agentType: string;
4668
- logicalTaskId?: string;
4669
- } | {
4670
- type: "verify:failed";
4671
- entryRef: number;
4672
- logicalTaskId: string;
4673
- rung: number;
4674
- gate: "mechanical" | "judge" | "spot-check";
4675
- } | {
4676
- type: "ledger:op";
4677
- entryRef: number;
4678
- op: "brief_set" | "fact_add" | "fact_supersede" | "lesson_add" | "observation_add";
4679
- } | {
4680
- type: "stall:detected";
4681
- logicalTaskId: string;
4682
- stallStreak: number;
4683
- } | {
4684
- type: "guard:oscillation";
4685
- spawnKeyHash: string;
4686
- oscillationCount: number;
4687
- limit: number;
4688
- } | {
4689
- type: "resolution:applied";
4690
- targetRef: number;
4691
- entryRef: number;
4692
- by: ResolutionBy;
4693
- } | {
4694
- type: "resolution:superseded";
4695
- targetRef: number;
4696
- entryRef: number;
4697
- supersededBy: number;
4698
- reason: "already_resolved" | "target_abandoned";
4699
- } | {
4700
- type: "termination:debit";
4701
- entryRef: number;
4702
- counter: string;
4703
- remaining: number;
4704
- phi: number;
4705
- } | {
4706
- type: "termination:denied";
4707
- entryRef: number;
4708
- counter: string;
4709
- code: string;
4710
- } | {
4711
- type: "termination:config-drift";
4712
- field: string;
4713
- frozenValue: Json;
4714
- liveValue: Json;
4715
- } | {
4814
+ recoverSettled(parentAccountScope: string): void;
4716
4815
  /**
4717
- * Declared for hosts; not emitted today. The compatibility scan
4718
- * runs strictly before a run's event stream exists, so the
4719
- * refusal travels only as the typed JournalCompatibilityError
4720
- * (which carries the same fields).
4816
+ * Resume roll-forward for an admission whose decision entry exists but
4817
+ * whose child has NOT settled: re-applies the recorded reserve and
4818
+ * counters without re-evaluating any limit (replay never
4819
+ * re-evaluates admission; reserves are recovered, never
4820
+ * re-estimated).
4721
4821
  */
4722
- type: "journal:compat";
4723
- code: "HASH_VERSION_TOO_OLD" | "HASH_VERSION_TOO_NEW";
4724
- found: number;
4725
- window: [number, number];
4726
- };
4727
- type WorkflowEventBody = CoreEvents | AgentEvents | ToolEvents | DeterminismEvents | AdaptiveEvents;
4728
- /**
4729
- * The envelope: seq is an independent per-run
4730
- * telemetry counter, strictly increasing in emission order and DISTINCT
4731
- * from JournalEntry.seq (never compare or join the two; entryRef fields
4732
- * carry journal seqs explicitly). ts is wall clock, telemetry only.
4733
- * replayed is true only on re-emitted journal-backed lifecycle events;
4734
- * stream deltas are never re-emitted.
4735
- */
4736
- type WorkflowEvent = {
4737
- runId: string;
4738
- seq: number;
4739
- ts: string;
4740
- spanId: string;
4741
- parentSpanId?: string;
4742
- replayed?: boolean;
4743
- } & WorkflowEventBody;
4822
+ recoverInFlight(parentAccountScope: string, verdict: AdmitVerdict): void;
4823
+ }
4744
4824
  //#endregion
4745
4825
  //#region src/engine/cost-report.d.ts
4746
4826
  /** Folds the per-run attribution buckets into the normative CostReport. */
@@ -5860,6 +5940,11 @@ interface OrchestrateAcceptance {
5860
5940
  /** How many rejected finishes are repaired by default: the plan's repair once. */
5861
5941
  declare const DEFAULT_FINISH_MAX_REPAIRS = 1;
5862
5942
  /**
5943
+ * Default maxTurns of the synthesize invocation (RV-211): the finish
5944
+ * call plus headroom for one validator repair exchange.
5945
+ */
5946
+ declare const DEFAULT_SYNTHESIS_MAX_TURNS = 4;
5947
+ /**
5863
5948
  * The opt in deterministic validation of the orchestrator finish result
5864
5949
  * (the v1.40.0 improvement plan's RV-204 slice). Every SCHEMA valid
5865
5950
  * finish({ result }) call first passes the configured host validators;
@@ -5948,6 +6033,51 @@ interface OrchestrateOptions {
5948
6033
  * unchanged.
5949
6034
  */
5950
6035
  exposeChildResultTools?: boolean;
6036
+ /**
6037
+ * The opt in post-fan-in synthesis invocation (RV-211): with this set,
6038
+ * the coordination loop's finish({ result }) becomes a DRAFT, and a
6039
+ * SEPARATE fresh invocation with role 'synthesize' (its own model,
6040
+ * effort, and limits through the ordinary resolution chain; the
6041
+ * routing key 'synthesize' picks its model and never summons it)
6042
+ * composes the final run result from the goal, the draft, and the
6043
+ * settled child digest, on the finish-only toolset. When
6044
+ * finishValidation is configured its validators bind the SYNTHESIS
6045
+ * finish (the final output), not the draft. See
6046
+ * {@link OrchestrateSynthesis}.
6047
+ */
6048
+ synthesis?: OrchestrateSynthesis;
6049
+ }
6050
+ /**
6051
+ * The synthesis invocation's own knobs (RV-211). Everything else about
6052
+ * the invocation is deterministic: the prompt derives from the journaled
6053
+ * draft and the settled child digest, the toolset is the single finish
6054
+ * tool (a distinct toolsetHash, exactly like the reserved cap
6055
+ * finalizer), the invocation journals as an ordinary agent entry (a
6056
+ * resume replays it with zero paid calls), and its telemetry is a full
6057
+ * agent span with role 'synthesize' phase pairs, so
6058
+ * `CostReport.byRole.synthesize` and `reduceCriticalPath` attribute it
6059
+ * without heuristics. Failure posture: with finishValidation configured
6060
+ * a failed synthesis fails the run typed (the validated path is
6061
+ * mandatory); without validators the run falls back to the coordination
6062
+ * draft under a journaled 'orchestrator_synthesis_fallback' decision and
6063
+ * a warn log, never silently.
6064
+ */
6065
+ interface OrchestrateSynthesis {
6066
+ /** Model override for the synthesize invocation; the routing key and chain apply otherwise. */
6067
+ model?: ModelSpec;
6068
+ /** Canonical effort of the synthesize invocation. */
6069
+ effort?: Effort;
6070
+ /** UsageLimits of the synthesize invocation; default { maxTurns: 4 }. */
6071
+ limits?: UsageLimits;
6072
+ /** Extra deterministic instruction lines appended to the synthesis prompt. */
6073
+ instructions?: string;
6074
+ /**
6075
+ * Admission estimate for the synthesize invocation, like
6076
+ * AgentOpts.estCost: under a tight orchestrator cap the default
6077
+ * reserve (full maxOutputTokens pricing) can refuse the dispatch; an
6078
+ * explicit estimate is the host speaking.
6079
+ */
6080
+ estCost?: number;
5951
6081
  }
5952
6082
  declare const ORCHESTRATE_WORKFLOW_NAME = "rulvar-orchestrate";
5953
6083
  /**
@@ -6211,10 +6341,12 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
6211
6341
  * The primary invocation role of the agent's tool loop; default
6212
6342
  * 'loop'. The plan and orchestrate entry points set it so the
6213
6343
  * resolution chain, role effort defaults, quality floors, and cost
6214
- * buckets see the right role; extract/finalize/summarize stay
6215
- * trigger-derived and are never settable here (M6-T05 amendment).
6344
+ * buckets see the right role, and the orchestrator's post-fan-in
6345
+ * synthesis invocation (RV-211) runs as 'synthesize';
6346
+ * extract/finalize/summarize stay trigger-derived and are never
6347
+ * settable here (M6-T05 amendment).
6216
6348
  */
6217
- role?: "loop" | "plan" | "orchestrate";
6349
+ role?: "loop" | "plan" | "orchestrate" | "synthesize";
6218
6350
  /** Overrides all roles at once. */
6219
6351
  model?: ModelSpec;
6220
6352
  /** Per-role, wins over profile.routing. */
@@ -7523,6 +7655,34 @@ interface InvocationTable {
7523
7655
  * replayed one produce the same usage and cost columns.
7524
7656
  */
7525
7657
  declare function reduceInvocationTable(events: Iterable<WorkflowEvent>): InvocationTable;
7658
+ /**
7659
+ * The critical-path summary of one run (RV-211): the plan's post-fan-in
7660
+ * gate ("synthesis takes at most 40% of wall time with four settled
7661
+ * workers") computed as a pure fold over the same vocabulary, no
7662
+ * heuristics beyond the role tags. Post-fan-in is the interval from the
7663
+ * LAST settled non-coordination agent (any span whose primary role is
7664
+ * neither 'orchestrate' nor 'synthesize') to run:end; the synthesis wall
7665
+ * is the summed span wall of 'synthesize' spans. Wall numbers are LIVE
7666
+ * fidelity: a replayed stream re-stamps emission times, so its intervals
7667
+ * are degenerate, exactly like phase durations. Absent pieces (no
7668
+ * run:end, no worker spans) leave the corresponding fields undefined
7669
+ * rather than guessed at.
7670
+ */
7671
+ interface CriticalPath {
7672
+ /** run:start to run:end; absent while the run is open. */
7673
+ runWallMs?: number;
7674
+ /** Last non-coordination agent:end to run:end; absent without both. */
7675
+ postFanInMs?: number;
7676
+ /** Summed wall of completed 'synthesize' spans (0 when none). */
7677
+ synthesisMs: number;
7678
+ /** postFanInMs / runWallMs when both are defined and the wall is > 0. */
7679
+ postFanInShare?: number;
7680
+ /** synthesisMs / runWallMs under the same conditions. */
7681
+ synthesisShare?: number;
7682
+ /** Settled non-coordination agent spans that anchored the fan-in. */
7683
+ workerSpans: number;
7684
+ }
7685
+ declare function reduceCriticalPath(events: Iterable<WorkflowEvent>): CriticalPath;
7526
7686
  //#endregion
7527
7687
  //#region src/runner/sandbox-bridge.d.ts
7528
7688
  /** Methods a sandbox script may proxy to the host ctx. */
@@ -7596,4 +7756,4 @@ interface SandboxBridge {
7596
7756
  declare const SANDBOX_AGENT_OPT_KEYS: readonly string[];
7597
7757
  declare function createSandboxBridge(ctx: Ctx<never>, options: SandboxBridgeOptions): SandboxBridge;
7598
7758
  //#endregion
7599
- export { AWAIT_SCHEMA, AbandonAttempt, AbandonFold, AbandonPayload, AbandonedSpendView, AbortClass, type AdaptiveEvents, AdmissionController, AdmissionDecision, AdmissionRejectedError, AdmissionStatsBefore, AdmitLineage, AdmitRejectReason, AdmitSpec, AdmitVerdict, AgentCallError, AgentError, type AgentEvents, AgentIdentityInput, type AgentInvocationRow, AgentOpts, AgentProfile, AgentProfilePermissions, AgentResult, AgentResultMeta, AgentStatus, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditRunsOptions, BUDGET_ABORT_REASON, BaseAppend, BriefOpts, BudgetAccountView, BudgetDefaults, BudgetExhaustedError, BudgetExhaustionDiagnostics, BudgetHooks, BudgetReserve, type Bytes, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, CacheHint, CacheTtl, CanUseTool, CanonicalId, CanonicalIdentity, CanonicalLadderSpec, CanonicalModelSpec, ChatEvent, ChatRequest, CheckpointState, ChildArtifactPage, ChildIdentityInput, ChildResultPage, type ClaimClass, type ClaimOp, type ClaimStatus, ClaimValidationOptions, CollectOpts, CollectedTurn, CompactionConfig, CompiledPermissionChain, CompiledWorkflow, ConfigError, type CoreEvents, CostAttribution, CostAttributionFacts, CostReport, CreateEngineOptions, Ctx, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DerivedKey, DeriverRegistry, type DeterminismConfig, DeterminismError, type DeterminismEvents, type DeterminismMode, DispositionRule, DispositionTable, DonorCandidate, DonorRef, DroppedItem, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EffectiveUsageLimits, Effort, Engine, EngineDefaults, EntryKind, EntryRef, EntryStatus, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, type EvidenceRef, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, FinishInfo, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, InvocationRole, type InvocationTable, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, JournalSerializationHook, type JournalStore, type Json, JsonSchema, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, type KbProposal, type KbProposalTrigger, KeyDeriver, KeyRing, KeyedLimiter, KnowledgeCasError, type KnowledgeSnapshot, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LadderSpec, type LeasableStore, type Lease, LeaseHeldError, Ledger, LineageCounters, LineageIndex, LineageRef, LineageRelation, LineageStats, LogicalTaskId, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, MatchResult, McpConfig, McpToolSource, MechanicalGateProfile, MechanicalGateVerdict, type MetaLookupStore, type ModelCaps, ModelChoice, type ModelClaim, ModelEpochInputs, type ModelKnowledgeHandle, type ModelKnowledgeStore, ModelListConstraint, ModelRef, ModelRetry, ModelSpec, Msg, NoProgressDetector, NodeId, NodeLinkValue, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OnEscalation, OperationDisposition, OrchestrateAcceptance, OrchestrateOptions, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PriceTable, PricedUsage, type Pricing, type PricingTier, type ProviderAdapter, QualityFloors, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, type RunFilter, RunHandle, RunInternals, type RunMeta, RunOptions, RunOutcome, RunProfile, RunStateAudit, RunStatus, RuntimeEventSink, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxBridge, SandboxBridgeOptions, SandboxError, SandboxHostToWorker, SandboxMethod, SandboxWorkerToHost, SchemaPair, SchemaSpec, SchemaValidationResult, ScopeSegment, ScriptRejected, ScriptRunner, ScrubNote, Semaphore, SerializationHook, Settled, ShellPatternRules, ShellSegment, ShellVerdict, SinglePhaseAppend, SpanMinter, SpanRegistry, SpawnAdmissionValue, SpawnAgentParams, SpawnKey, SpawnLineage, SpawnLineageOpt, SpawnOrigin, SpawnRecord, Spend, Stage, type StandardJSONSchemaV1, type StandardSchemaV1, StepIdentityInput, StructuredOutputTier, SuspendedAppend, SuspensionState, TOOL_NAME_PATTERN, type TaskClass, TaskDigest, TaskSpec, TerminalPatch, TerminationAccount, TerminationAccountSnapshot, TerminationDeniedValue, TerminationDeniedWriter, TerminationInitValue, TerminationLimits, TerminationResource, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, ToolInit, type ToolRisk, ToolRuntime, type ToolSource, type ToolSourceSession, ToolsOption, TranscriptSerializationHook, type TranscriptStore, TriggerClass, TtlState, Usage, UsageLimits, UsageSlice, VerifiedRecommendation, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, WakeBudgetBlock, WakeDigest, WakeTrigger, WireError, Workflow, WorkflowCallOpts, type WorkflowEvent, type WorkflowEventBody, WorkflowRegistry, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
7759
+ export { AWAIT_SCHEMA, AbandonAttempt, AbandonFold, AbandonPayload, AbandonedSpendView, AbortClass, type AdaptiveEvents, AdmissionController, AdmissionDecision, AdmissionRejectedError, AdmissionStatsBefore, AdmitLineage, AdmitRejectReason, AdmitSpec, AdmitVerdict, AgentCallError, AgentError, type AgentEvents, AgentIdentityInput, type AgentInvocationRow, AgentOpts, AgentProfile, AgentProfilePermissions, AgentResult, AgentResultMeta, AgentStatus, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditRunsOptions, BUDGET_ABORT_REASON, BaseAppend, BriefOpts, BudgetAccountView, BudgetDefaults, BudgetExhaustedError, BudgetExhaustionDiagnostics, BudgetHooks, BudgetReserve, type Bytes, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, CacheHint, CacheTtl, CanUseTool, CanonicalId, CanonicalIdentity, CanonicalLadderSpec, CanonicalModelSpec, ChatEvent, ChatRequest, CheckpointState, ChildArtifactPage, ChildIdentityInput, ChildResultPage, type ClaimClass, type ClaimOp, type ClaimStatus, ClaimValidationOptions, CollectOpts, CollectedTurn, CompactionConfig, CompiledPermissionChain, CompiledWorkflow, ConfigError, type CoreEvents, CostAttribution, CostAttributionFacts, CostReport, CreateEngineOptions, type CriticalPath, Ctx, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_SYNTHESIS_MAX_TURNS, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DerivedKey, DeriverRegistry, type DeterminismConfig, DeterminismError, type DeterminismEvents, type DeterminismMode, DispositionRule, DispositionTable, DonorCandidate, DonorRef, DroppedItem, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EffectiveUsageLimits, Effort, Engine, EngineDefaults, EntryKind, EntryRef, EntryStatus, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, type EvidenceRef, type ExplorationSummary, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, FinishInfo, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, InvocationRole, type InvocationTable, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, JournalSerializationHook, type JournalStore, type Json, JsonSchema, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, type KbProposal, type KbProposalTrigger, KeyDeriver, KeyRing, KeyedLimiter, KnowledgeCasError, type KnowledgeSnapshot, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LadderSpec, type LeasableStore, type Lease, LeaseHeldError, Ledger, LineageCounters, LineageIndex, LineageRef, LineageRelation, LineageStats, LogicalTaskId, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, MatchResult, McpConfig, McpToolSource, MechanicalGateProfile, MechanicalGateVerdict, type MetaLookupStore, type ModelCaps, ModelChoice, type ModelClaim, ModelEpochInputs, type ModelKnowledgeHandle, type ModelKnowledgeStore, ModelListConstraint, ModelRef, ModelRetry, ModelSpec, Msg, NoProgressDetector, NodeId, NodeLinkValue, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OnEscalation, OperationDisposition, OrchestrateAcceptance, OrchestrateOptions, OrchestrateSynthesis, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PriceTable, PricedUsage, type Pricing, type PricingTier, type ProviderAdapter, QualityFloors, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, type RunFilter, RunHandle, RunInternals, type RunMeta, RunOptions, RunOutcome, RunProfile, RunStateAudit, RunStatus, RuntimeEventSink, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxBridge, SandboxBridgeOptions, SandboxError, SandboxHostToWorker, SandboxMethod, SandboxWorkerToHost, SchemaPair, SchemaSpec, SchemaValidationResult, ScopeSegment, ScriptRejected, ScriptRunner, ScrubNote, Semaphore, SerializationHook, Settled, ShellPatternRules, ShellSegment, ShellVerdict, SinglePhaseAppend, SpanMinter, SpanRegistry, SpawnAdmissionValue, SpawnAgentParams, SpawnKey, SpawnLineage, SpawnLineageOpt, SpawnOrigin, SpawnRecord, Spend, Stage, type StandardJSONSchemaV1, type StandardSchemaV1, StepIdentityInput, StructuredOutputTier, SuspendedAppend, SuspensionState, TOOL_NAME_PATTERN, type TaskClass, TaskDigest, TaskSpec, TerminalPatch, TerminationAccount, TerminationAccountSnapshot, TerminationDeniedValue, TerminationDeniedWriter, TerminationInitValue, TerminationLimits, TerminationResource, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, ToolInit, type ToolRisk, ToolRuntime, type ToolSource, type ToolSourceSession, ToolsOption, TranscriptSerializationHook, type TranscriptStore, TriggerClass, TtlState, Usage, UsageLimits, UsageSlice, VerifiedRecommendation, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, WakeBudgetBlock, WakeDigest, WakeTrigger, WireError, Workflow, WorkflowCallOpts, type WorkflowEvent, type WorkflowEventBody, WorkflowRegistry, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceCriticalPath, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };