@rulvar/core 1.99.1 → 1.101.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 +98 -17
- package/dist/index.js +198 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3636,8 +3636,16 @@ interface ExplorationSummary {
|
|
|
3636
3636
|
* visible BEFORE the terminal 'limit' a starved worker would settle
|
|
3637
3637
|
* with. Attached to the full AgentResult and to the live `agent:end`
|
|
3638
3638
|
* event whenever maxToolCalls, toolUnits, or toolBudgetExtension is
|
|
3639
|
-
* configured.
|
|
3640
|
-
*
|
|
3639
|
+
* configured. The snapshot itself never journals, but since RV509 it
|
|
3640
|
+
* has a durable subset: an extension grant and the finalization-window
|
|
3641
|
+
* entry journal as decision entries the moment they fire, a
|
|
3642
|
+
* crash-resume restores them from the journal, and a replayed result
|
|
3643
|
+
* carries `used` (from the terminal checkpoint), the granted `cap`,
|
|
3644
|
+
* `extensionsGranted`, and `finalizationWindowEntered` whenever the
|
|
3645
|
+
* invocation journaled at least one such decision. Every other field
|
|
3646
|
+
* (unitsUsed/unitsMax, noticesFired, finalizationReserveUsed, limiter,
|
|
3647
|
+
* and the cap of a grant-free run) is live-only fidelity, exactly like
|
|
3648
|
+
* transportRetries, and stays absent on replay.
|
|
3641
3649
|
*/
|
|
3642
3650
|
interface ToolBudgetSummary {
|
|
3643
3651
|
/** Executed tool calls (the loop's own counter). */
|
|
@@ -3999,6 +4007,10 @@ type WorkflowEvent = {
|
|
|
3999
4007
|
replayed?: boolean;
|
|
4000
4008
|
} & WorkflowEventBody;
|
|
4001
4009
|
//#endregion
|
|
4010
|
+
//#region src/runtime/exploration.d.ts
|
|
4011
|
+
/** The budget dimension a finalization window statement names (RV302). */
|
|
4012
|
+
type FinalizationWindowBudget = "tool calls" | "tool units";
|
|
4013
|
+
//#endregion
|
|
4002
4014
|
//#region src/runtime/no-progress.d.ts
|
|
4003
4015
|
/**
|
|
4004
4016
|
* The no-progress abort class (M3-T08): an engine-defined detector
|
|
@@ -4202,8 +4214,11 @@ interface UsageLimits {
|
|
|
4202
4214
|
* set to false, only when at least one novel tool result digest arrived
|
|
4203
4215
|
* since the previous grant (the exploration guard's evidence chain).
|
|
4204
4216
|
* Each grant is announced to the model as a plain user message with the
|
|
4205
|
-
* exact new counts, so pacing stays possible
|
|
4206
|
-
*
|
|
4217
|
+
* exact new counts, so pacing stays possible. Under the engine, each
|
|
4218
|
+
* grant also journals a decision entry the moment it fires (RV509), so
|
|
4219
|
+
* a resume restores granted-but-unspent extensions from the journal
|
|
4220
|
+
* (the conservative executed-call derivation remains the floor beneath
|
|
4221
|
+
* a lost journal tail) and a replayed result reports the grants.
|
|
4207
4222
|
* Extends maxToolCalls only, never toolUnits. Off by default: the
|
|
4208
4223
|
* grant notices enter the conversation, so enabling it changes
|
|
4209
4224
|
* recorded model requests.
|
|
@@ -4227,9 +4242,12 @@ interface UsageLimits {
|
|
|
4227
4242
|
* free bookkeeping tools); the engine terminal tool is always
|
|
4228
4243
|
* admitted regardless. With toolBudgetExtension configured, remaining
|
|
4229
4244
|
* money converts into a grant BEFORE any window refusal, so the
|
|
4230
|
-
* window binds only when the extension is exhausted or denied.
|
|
4231
|
-
*
|
|
4232
|
-
*
|
|
4245
|
+
* window binds only when the extension is exhausted or denied. Under
|
|
4246
|
+
* the engine, the entry journals a decision entry the moment it fires
|
|
4247
|
+
* (RV509), so the summary's finalizationWindowEntered survives resume
|
|
4248
|
+
* and replay even when a later grant moved the counts back out of the
|
|
4249
|
+
* window. Off by default: the refusals and the notice enter the
|
|
4250
|
+
* conversation, so enabling it changes recorded model requests.
|
|
4233
4251
|
*/
|
|
4234
4252
|
finalizationWindow?: {
|
|
4235
4253
|
/** How many trailing executed calls (or units) the window reserves. */reserveCalls: number; /** Tool names allowed inside the window; default: zero-cost tools. */
|
|
@@ -4692,6 +4710,36 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
4692
4710
|
minEntries: number;
|
|
4693
4711
|
enforce?: "warn" | "refuse";
|
|
4694
4712
|
};
|
|
4713
|
+
/**
|
|
4714
|
+
* The durable parallel of the tool budget summary (RV509): the caller
|
|
4715
|
+
* journals an extension grant and the finalization-window entry as
|
|
4716
|
+
* decision entries at the moment each fires, and hands the state read
|
|
4717
|
+
* back from those entries into `restored` on a dangling-dispatch
|
|
4718
|
+
* resume. A restored grant is honored as granted (the model was
|
|
4719
|
+
* already promised the raised cap), never re-admitted or re-announced,
|
|
4720
|
+
* and a restored window entry keeps the summary's
|
|
4721
|
+
* finalizationWindowEntered truthful even when a later grant moved the
|
|
4722
|
+
* counts back out of the window. The hooks are fire-and-forget from
|
|
4723
|
+
* the loop's view; pressure notices stay events and are never
|
|
4724
|
+
* journaled. Absent, the loop is byte-identical to before.
|
|
4725
|
+
*/
|
|
4726
|
+
toolBudgetDurability?: {
|
|
4727
|
+
restored?: {
|
|
4728
|
+
extensionsGranted: number;
|
|
4729
|
+
finalizationWindowEntered: boolean;
|
|
4730
|
+
};
|
|
4731
|
+
onExtensionGrant?: (grant: {
|
|
4732
|
+
grant: number;
|
|
4733
|
+
maxExtensions: number;
|
|
4734
|
+
toolCallsUsed: number;
|
|
4735
|
+
cap: number;
|
|
4736
|
+
}) => void;
|
|
4737
|
+
onWindowEntry?: (entry: {
|
|
4738
|
+
remaining: number;
|
|
4739
|
+
reserveCalls: number;
|
|
4740
|
+
budget: FinalizationWindowBudget;
|
|
4741
|
+
}) => void;
|
|
4742
|
+
};
|
|
4695
4743
|
/** Emits agent:stream deltas when true (telemetry only). */
|
|
4696
4744
|
stream?: boolean;
|
|
4697
4745
|
/** Host or sibling cancellation. */
|
|
@@ -7861,6 +7909,32 @@ interface OrchestrateSynthesis {
|
|
|
7861
7909
|
* accordingly).
|
|
7862
7910
|
*/
|
|
7863
7911
|
context?: "digests" | "full";
|
|
7912
|
+
/**
|
|
7913
|
+
* The conditional synthesis gate (RV510, the ninth comparison
|
|
7914
|
+
* experiment: synthesis returned the byte-identical draft after
|
|
7915
|
+
* 101.3 s and 0.5512 USD, 57.3% of post-fan-in wall time). With
|
|
7916
|
+
* `true`, before the 'single' synthesis span starts the coordination
|
|
7917
|
+
* draft is run through the FULL declared finish contract (the same
|
|
7918
|
+
* `finishValidation.validators` that would bind the synthesis
|
|
7919
|
+
* finish): a draft that passes skips the synthesis invocation
|
|
7920
|
+
* entirely under a journaled 'orchestrator_synthesis_skip' decision
|
|
7921
|
+
* with reason 'synthesis_skipped_by_valid_draft' (the existing skip
|
|
7922
|
+
* vocabulary; the info log and the acceptance envelope carry it), and
|
|
7923
|
+
* a resume rolls the journaled skip forward with zero paid calls. A
|
|
7924
|
+
* draft that fails any validator goes to synthesis exactly as before,
|
|
7925
|
+
* with the repair budget untouched (the gate is a pre-pass, never a
|
|
7926
|
+
* journaled validation verdict). Deterministic by construction: only
|
|
7927
|
+
* the declared contract judges, never a semantic delta heuristic.
|
|
7928
|
+
* Requires `finishValidation` (a ConfigError at intake otherwise:
|
|
7929
|
+
* without a contract there is nothing to judge the draft valid by),
|
|
7930
|
+
* which transitively limits it to mode 'single'. With a configured
|
|
7931
|
+
* `budget.synthesisReserveUsd` the held money is released unconsumed
|
|
7932
|
+
* on the skip and no reserve lifecycle journals: there was no
|
|
7933
|
+
* synthesis invocation to account. Default false: the gate, the
|
|
7934
|
+
* decision entry, and the envelope field are all absent, byte for
|
|
7935
|
+
* byte.
|
|
7936
|
+
*/
|
|
7937
|
+
skipWhenDraftValid?: boolean;
|
|
7864
7938
|
}
|
|
7865
7939
|
/**
|
|
7866
7940
|
* The deterministic reconciliation envelope an 'incremental' synthesis
|
|
@@ -7895,15 +7969,22 @@ interface IncrementalSynthesisResult {
|
|
|
7895
7969
|
* notes were already paid during the run; the skipped step is the free
|
|
7896
7970
|
* deterministic reconciliation). 'synthesis_skipped_by_budget_cap': the
|
|
7897
7971
|
* orchestrator budget cap froze the plan, and a capped run settles
|
|
7898
|
-
* through the reserved finalizer, never synthesis.
|
|
7899
|
-
*
|
|
7900
|
-
*
|
|
7901
|
-
*
|
|
7902
|
-
*
|
|
7903
|
-
*
|
|
7904
|
-
*
|
|
7905
|
-
|
|
7906
|
-
|
|
7972
|
+
* through the reserved finalizer, never synthesis.
|
|
7973
|
+
* 'synthesis_skipped_by_valid_draft' (RV510): the opt-in
|
|
7974
|
+
* `synthesis.skipWhenDraftValid` gate ran the coordination draft
|
|
7975
|
+
* through the full declared finish contract and every validator
|
|
7976
|
+
* passed, so the synthesis invocation had nothing to add and never
|
|
7977
|
+
* started; unlike the other two reasons the run still settles ok with
|
|
7978
|
+
* the draft as its result. The reason is frozen into the journaled
|
|
7979
|
+
* decision that caused the skip (the acceptance decision, the
|
|
7980
|
+
* budget-cap decision, or the 'orchestrator_synthesis_skip' decision),
|
|
7981
|
+
* spread into the typed FailRunError data on the failing paths and
|
|
7982
|
+
* into the acceptance envelope on the valid-draft path, and announced
|
|
7983
|
+
* by an info 'orchestrator synthesis skipped' log event; it is absent
|
|
7984
|
+
* everywhere when synthesis is not configured or actually ran, so
|
|
7985
|
+
* existing runs stay byte identical.
|
|
7986
|
+
*/
|
|
7987
|
+
type OrchestrateSynthesisSkipReason = "synthesis_skipped_by_acceptance" | "synthesis_skipped_by_budget_cap" | "synthesis_skipped_by_valid_draft";
|
|
7907
7988
|
declare const ORCHESTRATE_WORKFLOW_NAME = "rulvar-orchestrate";
|
|
7908
7989
|
/**
|
|
7909
7990
|
* Resolves per-spawn dispatch options against the engine registries
|
|
@@ -10330,4 +10411,4 @@ interface SandboxBridge {
|
|
|
10330
10411
|
declare const SANDBOX_AGENT_OPT_KEYS: readonly string[];
|
|
10331
10412
|
declare function createSandboxBridge(ctx: Ctx<never>, options: SandboxBridgeOptions): SandboxBridge;
|
|
10332
10413
|
//#endregion
|
|
10333
|
-
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, AgentProfileTemplateOptions, AgentResult, AgentResultMeta, AgentStatus, type AppliedPricingRow, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditCategory, AuditRecord, 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_CITATION_SAMPLE, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_CALLS_PER_ENTRY, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_EVIDENCE_OVERHEAD_CALLS, 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, DEFAULT_SYNTHESIS_NOTE_MAX_TURNS, DataKeyProvider, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DedupedClaims, 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, EngineQuotaConfig, EngineQuotaRuntime, EntryBillingFold, EntryBillingUnit, EntryKind, EntryRef, EntryStatus, EnvelopeEncryption, EnvelopeEncryptionOptions, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, EvidenceContract, type EvidenceRef, type ExecKeyDerivation, type ExecutorRegistry, type ExplorationSummary, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FencedCodeMode, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, FinishContract, FinishContractCitations, FinishContractGoldenReject, FinishContractManifest, FinishInfo, FinishSelfTestFailure, FinishSelfTestFixtures, FinishSelfTestReport, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, IMPLEMENTATION_PROFILE_LIMITS, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, IncrementalSynthesisResult, InvalidResolutionError, InvocationRole, type InvocationTable, InvoiceExport, InvoicePricingProvenance, InvoiceReconciliation, InvoiceRow, type IsolatedExecContext, type IsolatedExecRequest, type IsolatedExecutorTag, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JOURNAL_ENVELOPE_MARKER, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, type JournalPricingSnapshot, JournalSerializationContext, 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, MemoryQuotaLimiter, 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, OrchestrateSynthesisSkipReason, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, PROGRESS_REPORT_TOOL_NAME, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PreflightAdmissionRow, PreflightFinding, PreflightInput, PreflightOrchestratorSpec, PreflightReport, PreflightSpawnReport, PreflightSpawnSpec, PreflightToolCeiling, PriceTable, PricedUsage, type Pricing, type PricingTier, ProgressReport, type ProviderAdapter, ProviderCallRecord, QUOTA_WINDOW_MS, QualityFloors, QuotaCounters, type QuotaDecision, type QuotaEstimate, type QuotaLimiter, type QuotaReservationRequest, QuotaRule, QuotaWindowSnapshot, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, RESEARCH_PROFILE_LIMITS, REVIEW_PROFILE_LIMITS, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, RateLimitObservation, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, RepeatedClaim, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, RepositoryResearchToolset, RepositoryResearchToolsetOptions, ResearchAgentProfileOptions, ResearchAgentProfileResult, ResearchEvidenceEntry, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, RunExport, 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, SecretMasker, SectionMatchMode, Semaphore, SerializationHook, Settled, SettlementError, 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, type ToolBudgetSummary, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, type ToolExecutorProvider, 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, compileSecretMasker, compileVerifiedLayer, constantTimeEqual, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createEnvelopeEncryption, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, dedupeRepeatedClaims, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispatchProjectionReserveUsd, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, finishContract, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, headingStructureValidator, identityJcs, implementationAgentProfile, invoiceFromJournal, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, journalPricingSnapshot, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, latestProgressReport, lexShellCommand, liftRetainedParts, lineageWeightOf, localKeyProvider, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, memoryQuotaLimiter, mergeQuotaDenial, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, orchestratorAdmissionEstCostUsd, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, preflightEstimate, priceEntryBilling, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, progressReportTool, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, quotaActualTokens, quotaEstimateTokens, quotaRuleAdmission, quotaRuleMatches, readRunMeta, readTerminationInit, reconcileRunMeta, reduceAuditTrail, reduceCriticalPath, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, repositoryResearchToolset, requiredFieldsValidator, requiredSectionsValidator, researchAgentProfile, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, reviewAgentProfile, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, sectionCitationsValidator, selectStructuredOutputTier, selfTestFinishValidation, shouldCompact, snapshotUsage, spawnDepthOf, stripFencedBlocks, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEngineQuotaConfig, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateQuotaRules, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, wordCountValidator, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
|
10414
|
+
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, AgentProfileTemplateOptions, AgentResult, AgentResultMeta, AgentStatus, type AppliedPricingRow, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditCategory, AuditRecord, 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_CITATION_SAMPLE, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_CALLS_PER_ENTRY, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_EVIDENCE_OVERHEAD_CALLS, 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, DEFAULT_SYNTHESIS_NOTE_MAX_TURNS, DataKeyProvider, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DedupedClaims, 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, EngineQuotaConfig, EngineQuotaRuntime, EntryBillingFold, EntryBillingUnit, EntryKind, EntryRef, EntryStatus, EnvelopeEncryption, EnvelopeEncryptionOptions, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, EvidenceContract, type EvidenceRef, type ExecKeyDerivation, type ExecutorRegistry, type ExplorationSummary, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FencedCodeMode, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, type FinalizationWindowBudget, FinishContract, FinishContractCitations, FinishContractGoldenReject, FinishContractManifest, FinishInfo, FinishSelfTestFailure, FinishSelfTestFixtures, FinishSelfTestReport, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, IMPLEMENTATION_PROFILE_LIMITS, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, IncrementalSynthesisResult, InvalidResolutionError, InvocationRole, type InvocationTable, InvoiceExport, InvoicePricingProvenance, InvoiceReconciliation, InvoiceRow, type IsolatedExecContext, type IsolatedExecRequest, type IsolatedExecutorTag, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JOURNAL_ENVELOPE_MARKER, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, type JournalPricingSnapshot, JournalSerializationContext, 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, MemoryQuotaLimiter, 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, OrchestrateSynthesisSkipReason, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, PROGRESS_REPORT_TOOL_NAME, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PreflightAdmissionRow, PreflightFinding, PreflightInput, PreflightOrchestratorSpec, PreflightReport, PreflightSpawnReport, PreflightSpawnSpec, PreflightToolCeiling, PriceTable, PricedUsage, type Pricing, type PricingTier, ProgressReport, type ProviderAdapter, ProviderCallRecord, QUOTA_WINDOW_MS, QualityFloors, QuotaCounters, type QuotaDecision, type QuotaEstimate, type QuotaLimiter, type QuotaReservationRequest, QuotaRule, QuotaWindowSnapshot, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, RESEARCH_PROFILE_LIMITS, REVIEW_PROFILE_LIMITS, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, RateLimitObservation, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, RepeatedClaim, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, RepositoryResearchToolset, RepositoryResearchToolsetOptions, ResearchAgentProfileOptions, ResearchAgentProfileResult, ResearchEvidenceEntry, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, RunExport, 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, SecretMasker, SectionMatchMode, Semaphore, SerializationHook, Settled, SettlementError, 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, type ToolBudgetSummary, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, type ToolExecutorProvider, 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, compileSecretMasker, compileVerifiedLayer, constantTimeEqual, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createEnvelopeEncryption, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, dedupeRepeatedClaims, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispatchProjectionReserveUsd, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, finishContract, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, headingStructureValidator, identityJcs, implementationAgentProfile, invoiceFromJournal, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, journalPricingSnapshot, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, latestProgressReport, lexShellCommand, liftRetainedParts, lineageWeightOf, localKeyProvider, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, memoryQuotaLimiter, mergeQuotaDenial, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, orchestratorAdmissionEstCostUsd, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, preflightEstimate, priceEntryBilling, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, progressReportTool, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, quotaActualTokens, quotaEstimateTokens, quotaRuleAdmission, quotaRuleMatches, readRunMeta, readTerminationInit, reconcileRunMeta, reduceAuditTrail, reduceCriticalPath, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, repositoryResearchToolset, requiredFieldsValidator, requiredSectionsValidator, researchAgentProfile, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, reviewAgentProfile, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, sectionCitationsValidator, selectStructuredOutputTier, selfTestFinishValidation, shouldCompact, snapshotUsage, spawnDepthOf, stripFencedBlocks, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEngineQuotaConfig, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateQuotaRules, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, wordCountValidator, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
package/dist/index.js
CHANGED
|
@@ -10918,9 +10918,10 @@ async function runAgent(options) {
|
|
|
10918
10918
|
* 84-call cap while 38% of the USD ceiling sat unspent. A grant at the
|
|
10919
10919
|
* expiry converts that headroom into `increment` more executed calls,
|
|
10920
10920
|
* bounded by `maxExtensions`, admitted only with money remaining and
|
|
10921
|
-
* (by default) new evidence since the last grant.
|
|
10922
|
-
*
|
|
10923
|
-
*
|
|
10921
|
+
* (by default) new evidence since the last grant. Each grant reports
|
|
10922
|
+
* through the durable decision hook (RV509) and restores on resume
|
|
10923
|
+
* from the journaled decisions, with the conservative count
|
|
10924
|
+
* derivation as the floor beneath a lost tail.
|
|
10924
10925
|
*/
|
|
10925
10926
|
const extension = limits.toolBudgetExtension;
|
|
10926
10927
|
let extensionGrants = 0;
|
|
@@ -10991,6 +10992,12 @@ async function runAgent(options) {
|
|
|
10991
10992
|
extensionGrants += 1;
|
|
10992
10993
|
extensionEvidenceAtLastGrant = guard?.evidenceCount() ?? 0;
|
|
10993
10994
|
const cap = limits.maxToolCalls + extensionGrants * extension.increment;
|
|
10995
|
+
options.toolBudgetDurability?.onExtensionGrant?.({
|
|
10996
|
+
grant: extensionGrants,
|
|
10997
|
+
maxExtensions: extension.maxExtensions,
|
|
10998
|
+
toolCallsUsed,
|
|
10999
|
+
cap
|
|
11000
|
+
});
|
|
10994
11001
|
pendingExtensionNotices.push(toolBudgetExtensionNoticeText(extensionGrants, extension.maxExtensions, toolCallsUsed, cap));
|
|
10995
11002
|
events?.emit({
|
|
10996
11003
|
type: "log",
|
|
@@ -11053,6 +11060,11 @@ async function runAgent(options) {
|
|
|
11053
11060
|
if (state === void 0) return;
|
|
11054
11061
|
windowEntered = true;
|
|
11055
11062
|
windowNoticeFired = true;
|
|
11063
|
+
options.toolBudgetDurability?.onWindowEntry?.({
|
|
11064
|
+
remaining: state.remaining,
|
|
11065
|
+
reserveCalls: finalizationWindow.reserveCalls,
|
|
11066
|
+
budget: state.budget
|
|
11067
|
+
});
|
|
11056
11068
|
pendingWindowNotices.push(finalizationWindowNoticeText(state.remaining, finalizationWindow.reserveCalls, state.budget));
|
|
11057
11069
|
events?.emit({
|
|
11058
11070
|
type: "log",
|
|
@@ -11115,7 +11127,15 @@ async function runAgent(options) {
|
|
|
11115
11127
|
extensionGrants = Math.min(extension.maxExtensions, Math.ceil((toolCallsUsed - limits.maxToolCalls) / extension.increment));
|
|
11116
11128
|
extensionEvidenceAtLastGrant = guard?.evidenceCount() ?? 0;
|
|
11117
11129
|
}
|
|
11118
|
-
|
|
11130
|
+
const durableRestored = options.toolBudgetDurability?.restored;
|
|
11131
|
+
if (extension !== void 0 && durableRestored !== void 0) {
|
|
11132
|
+
const journaled = Math.min(extension.maxExtensions, durableRestored.extensionsGranted);
|
|
11133
|
+
if (journaled > extensionGrants) {
|
|
11134
|
+
extensionGrants = journaled;
|
|
11135
|
+
extensionEvidenceAtLastGrant = guard?.evidenceCount() ?? 0;
|
|
11136
|
+
}
|
|
11137
|
+
}
|
|
11138
|
+
if (windowActive() !== void 0 || finalizationWindow !== void 0 && durableRestored?.finalizationWindowEntered === true) {
|
|
11119
11139
|
windowEntered = true;
|
|
11120
11140
|
windowNoticeFired = true;
|
|
11121
11141
|
}
|
|
@@ -13977,6 +13997,39 @@ function agentResultWire(result, fallbackMessage) {
|
|
|
13977
13997
|
}
|
|
13978
13998
|
};
|
|
13979
13999
|
}
|
|
14000
|
+
/** The tool-budget decision vocabulary (RV509). */
|
|
14001
|
+
const TOOL_BUDGET_EXTENSION_DECISION = "tool_budget_extension";
|
|
14002
|
+
const FINALIZATION_WINDOW_DECISION = "finalization_window_entry";
|
|
14003
|
+
/**
|
|
14004
|
+
* The durable subset of a dispatch's ToolBudgetSummary, folded from the
|
|
14005
|
+
* decision entries bound to it (RV509). The grant ordinal, not the entry
|
|
14006
|
+
* count, carries the total: a crash can lose an entry's persist while
|
|
14007
|
+
* the count derivation still reproduces the grant, so ordinals may gap
|
|
14008
|
+
* but never repeat, and the highest one is the authoritative tally. The
|
|
14009
|
+
* cap is the effective cap the highest grant announced.
|
|
14010
|
+
*/
|
|
14011
|
+
function readToolBudgetDecisions(entries, targetRef) {
|
|
14012
|
+
let extensionsGranted = 0;
|
|
14013
|
+
let cap;
|
|
14014
|
+
let finalizationWindowEntered = false;
|
|
14015
|
+
for (const entry of entries) {
|
|
14016
|
+
if (entry.kind !== "decision") continue;
|
|
14017
|
+
const value = entry.value;
|
|
14018
|
+
if (value?.targetRef !== targetRef) continue;
|
|
14019
|
+
if (value.decisionType === TOOL_BUDGET_EXTENSION_DECISION && typeof value.grant === "number") {
|
|
14020
|
+
if (value.grant > extensionsGranted) {
|
|
14021
|
+
extensionsGranted = value.grant;
|
|
14022
|
+
cap = typeof value.cap === "number" ? value.cap : void 0;
|
|
14023
|
+
}
|
|
14024
|
+
} else if (value.decisionType === FINALIZATION_WINDOW_DECISION) finalizationWindowEntered = true;
|
|
14025
|
+
}
|
|
14026
|
+
if (extensionsGranted === 0 && !finalizationWindowEntered) return;
|
|
14027
|
+
return {
|
|
14028
|
+
extensionsGranted,
|
|
14029
|
+
...cap === void 0 ? {} : { cap },
|
|
14030
|
+
finalizationWindowEntered
|
|
14031
|
+
};
|
|
14032
|
+
}
|
|
13980
14033
|
/** The workflow-defaults layer a Workflow value contributes, or nothing. */
|
|
13981
14034
|
function workflowLayerOf(wf) {
|
|
13982
14035
|
const layer = {};
|
|
@@ -14355,11 +14408,13 @@ function createCtx(internals, rootWorkflow) {
|
|
|
14355
14408
|
if (stampedData?.exploration !== void 0) result.exploration = stampedData.exploration;
|
|
14356
14409
|
}
|
|
14357
14410
|
let replayedToolResults = [];
|
|
14411
|
+
let replayedToolCallsUsed;
|
|
14358
14412
|
if (matched.kind === "replay" && terminal?.checkpointRef !== void 0) {
|
|
14359
14413
|
const blob = await internals.transcripts.get(terminal.checkpointRef);
|
|
14360
14414
|
const checkpoint = blob === null ? void 0 : decodeCheckpoint(blob);
|
|
14361
14415
|
if (checkpoint !== void 0) {
|
|
14362
14416
|
result.turns = checkpoint.turns;
|
|
14417
|
+
replayedToolCallsUsed = checkpoint.toolCallsUsed;
|
|
14363
14418
|
if (result.status === "limit") {
|
|
14364
14419
|
const partialReport = latestProgressReport(checkpoint.messages);
|
|
14365
14420
|
if (partialReport !== void 0) result.partial = partialReport;
|
|
@@ -14370,6 +14425,16 @@ function createCtx(internals, rootWorkflow) {
|
|
|
14370
14425
|
}));
|
|
14371
14426
|
}
|
|
14372
14427
|
}
|
|
14428
|
+
{
|
|
14429
|
+
const durable = readToolBudgetDecisions(internals.replayer.snapshot(), matched.running.seq);
|
|
14430
|
+
if (durable !== void 0 && replayedToolCallsUsed !== void 0) {
|
|
14431
|
+
const restoredSummary = { used: replayedToolCallsUsed };
|
|
14432
|
+
if (durable.cap !== void 0) restoredSummary.cap = durable.cap;
|
|
14433
|
+
if (durable.extensionsGranted > 0) restoredSummary.extensionsGranted = durable.extensionsGranted;
|
|
14434
|
+
if (durable.finalizationWindowEntered) restoredSummary.finalizationWindowEntered = true;
|
|
14435
|
+
result.toolBudget = restoredSummary;
|
|
14436
|
+
}
|
|
14437
|
+
}
|
|
14373
14438
|
internals.events.emit({
|
|
14374
14439
|
type: "agent:start",
|
|
14375
14440
|
agentType,
|
|
@@ -14421,7 +14486,8 @@ function createCtx(internals, rootWorkflow) {
|
|
|
14421
14486
|
costUsd,
|
|
14422
14487
|
entryRef: terminal?.seq ?? matched.running.seq,
|
|
14423
14488
|
...terminal?.usageApprox === true ? { usageApprox: true } : {},
|
|
14424
|
-
...result.exploration === void 0 ? {} : { exploration: result.exploration }
|
|
14489
|
+
...result.exploration === void 0 ? {} : { exploration: result.exploration },
|
|
14490
|
+
...result.toolBudget === void 0 ? {} : { toolBudget: result.toolBudget }
|
|
14425
14491
|
}, spanId, true);
|
|
14426
14492
|
for (const slice of replayPriced?.priced ?? []) bump(internals.cost.byModel, slice.servedBy, slice.usd);
|
|
14427
14493
|
for (const slice of replayPriced?.unpriced ?? []) internals.cost.unpriced.push({
|
|
@@ -14776,6 +14842,43 @@ function createCtx(internals, rootWorkflow) {
|
|
|
14776
14842
|
runAgentOptions.summarize = summarize;
|
|
14777
14843
|
if (profile?.compaction !== void 0) runAgentOptions.compaction = profile.compaction;
|
|
14778
14844
|
if (profile?.evidenceContract !== void 0) runAgentOptions.evidenceContract = profile.evidenceContract;
|
|
14845
|
+
{
|
|
14846
|
+
const durableRestored = readToolBudgetDecisions(internals.replayer.snapshot(), running.seq);
|
|
14847
|
+
runAgentOptions.toolBudgetDurability = {
|
|
14848
|
+
...durableRestored === void 0 ? {} : { restored: {
|
|
14849
|
+
extensionsGranted: durableRestored.extensionsGranted,
|
|
14850
|
+
finalizationWindowEntered: durableRestored.finalizationWindowEntered
|
|
14851
|
+
} },
|
|
14852
|
+
onExtensionGrant: (grant) => {
|
|
14853
|
+
internals.replayer.appendSinglePhase({
|
|
14854
|
+
scope: state.scope,
|
|
14855
|
+
key: "",
|
|
14856
|
+
kind: "decision",
|
|
14857
|
+
status: "ok",
|
|
14858
|
+
spanId,
|
|
14859
|
+
value: {
|
|
14860
|
+
decisionType: TOOL_BUDGET_EXTENSION_DECISION,
|
|
14861
|
+
targetRef: running.seq,
|
|
14862
|
+
...grant
|
|
14863
|
+
}
|
|
14864
|
+
});
|
|
14865
|
+
},
|
|
14866
|
+
onWindowEntry: (entry) => {
|
|
14867
|
+
internals.replayer.appendSinglePhase({
|
|
14868
|
+
scope: state.scope,
|
|
14869
|
+
key: "",
|
|
14870
|
+
kind: "decision",
|
|
14871
|
+
status: "ok",
|
|
14872
|
+
spanId,
|
|
14873
|
+
value: {
|
|
14874
|
+
decisionType: FINALIZATION_WINDOW_DECISION,
|
|
14875
|
+
targetRef: running.seq,
|
|
14876
|
+
...entry
|
|
14877
|
+
}
|
|
14878
|
+
});
|
|
14879
|
+
}
|
|
14880
|
+
};
|
|
14881
|
+
}
|
|
14779
14882
|
if (loopFallbacks.length > 0) runAgentOptions.fallbacks = loopFallbacks;
|
|
14780
14883
|
if (retryPolicy !== void 0) runAgentOptions.retry = { policy: retryPolicy };
|
|
14781
14884
|
if (internals.quota !== void 0) {
|
|
@@ -16870,6 +16973,11 @@ function validateOrchestrateOptions(opts) {
|
|
|
16870
16973
|
if (synthesis.dedupeClaims !== void 0 && typeof synthesis.dedupeClaims !== "boolean") throw new ConfigError("orchestrate synthesis.dedupeClaims must be a boolean; got " + typeof synthesis.dedupeClaims);
|
|
16871
16974
|
const symmetry = synthesis;
|
|
16872
16975
|
if (symmetry.exposeChildResultTools !== void 0 && typeof symmetry.exposeChildResultTools !== "boolean") throw new ConfigError("orchestrate synthesis.exposeChildResultTools must be a boolean; got " + typeof symmetry.exposeChildResultTools);
|
|
16976
|
+
const conditional = synthesis;
|
|
16977
|
+
if (conditional.skipWhenDraftValid !== void 0) {
|
|
16978
|
+
if (typeof conditional.skipWhenDraftValid !== "boolean") throw new ConfigError("orchestrate synthesis.skipWhenDraftValid must be a boolean; got " + typeof conditional.skipWhenDraftValid);
|
|
16979
|
+
if (conditional.skipWhenDraftValid && opts.finishValidation === void 0) throw new ConfigError("orchestrate synthesis.skipWhenDraftValid requires finishValidation: without a declared finish contract there is nothing to judge the draft valid by");
|
|
16980
|
+
}
|
|
16873
16981
|
if (symmetry.context !== void 0 && symmetry.context !== "digests" && symmetry.context !== "full") throw new ConfigError("orchestrate synthesis.context must be 'digests' or 'full'; got " + JSON.stringify(symmetry.context));
|
|
16874
16982
|
if (synthesis.noteLimits !== void 0) validateUsageLimits(synthesis.noteLimits, "orchestrate synthesis.noteLimits");
|
|
16875
16983
|
if (synthesis.effort !== void 0 && ![
|
|
@@ -17877,6 +17985,24 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
17877
17985
|
if (decision.contractHash !== void 0) return decision.contractHash === hash;
|
|
17878
17986
|
return internals.replayer.snapshot().filter((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.value?.decisionType === "orchestrator_finish_validation_bundle").length <= 1;
|
|
17879
17987
|
};
|
|
17988
|
+
/**
|
|
17989
|
+
* The children snapshot (RV-202): spawn order, pure reads of the
|
|
17990
|
+
* records the orchestrator already tracks, so validators can hold
|
|
17991
|
+
* a finish result (or the RV510 draft pre-pass) against the
|
|
17992
|
+
* evidence the children produced. Only the JOURNALED verdict of
|
|
17993
|
+
* validateFinish survives; on replay the snapshot is never rebuilt
|
|
17994
|
+
* because the entry is read by call id there.
|
|
17995
|
+
*/
|
|
17996
|
+
const validationChildren = () => {
|
|
17997
|
+
const salvageOutputOn = opts?.acceptance?.acceptValidatedTerminalOutputOnLimit === true;
|
|
17998
|
+
return [...records.values()].sort((a, b) => a.spawnOrdinal - b.spawnOrdinal).map((record) => ({
|
|
17999
|
+
handle: record.handle,
|
|
18000
|
+
nodeId: record.nodeId,
|
|
18001
|
+
status: record.settled?.status ?? "running",
|
|
18002
|
+
text: record.settled === void 0 ? "" : serializeChildOutput(record.settled),
|
|
18003
|
+
...salvageOutputOn && record.settled?.status === "limit" && record.settled.output !== null && record.settled.output !== void 0 ? { salvageableOutput: true } : {}
|
|
18004
|
+
}));
|
|
18005
|
+
};
|
|
17880
18006
|
const validateFinish = async (call) => {
|
|
17881
18007
|
if (validationSpec === void 0) return { ok: true };
|
|
17882
18008
|
const maxRepairs = validationSpec.maxRepairs ?? 1;
|
|
@@ -17884,18 +18010,10 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
17884
18010
|
let decision = known.find((candidate) => candidate.callId === call.id);
|
|
17885
18011
|
if (decision === void 0) {
|
|
17886
18012
|
const result = call.result ?? null;
|
|
17887
|
-
const salvageOutputOn = opts?.acceptance?.acceptValidatedTerminalOutputOnLimit === true;
|
|
17888
|
-
const children = [...records.values()].sort((a, b) => a.spawnOrdinal - b.spawnOrdinal).map((record) => ({
|
|
17889
|
-
handle: record.handle,
|
|
17890
|
-
nodeId: record.nodeId,
|
|
17891
|
-
status: record.settled?.status ?? "running",
|
|
17892
|
-
text: record.settled === void 0 ? "" : serializeChildOutput(record.settled),
|
|
17893
|
-
...salvageOutputOn && record.settled?.status === "limit" && record.settled.output !== null && record.settled.output !== void 0 ? { salvageableOutput: true } : {}
|
|
17894
|
-
}));
|
|
17895
18013
|
const input = {
|
|
17896
18014
|
result,
|
|
17897
18015
|
text: typeof result === "string" ? result : JSON.stringify(result),
|
|
17898
|
-
children
|
|
18016
|
+
children: validationChildren()
|
|
17899
18017
|
};
|
|
17900
18018
|
const failed = [];
|
|
17901
18019
|
for (const validator of validationSpec.validators) {
|
|
@@ -18289,11 +18407,75 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
18289
18407
|
* facts; absent everywhere when no reserve is configured.
|
|
18290
18408
|
*/
|
|
18291
18409
|
let synthesisReserveLifecycle;
|
|
18410
|
+
/**
|
|
18411
|
+
* Set exactly when the RV510 gate skipped the synthesis span (live
|
|
18412
|
+
* pass and resume roll-forward alike); the acceptance envelope
|
|
18413
|
+
* reports the machine reason through it.
|
|
18414
|
+
*/
|
|
18415
|
+
let synthesisSkippedByValidDraft = false;
|
|
18292
18416
|
const runSynthesis = async (draft) => {
|
|
18293
18417
|
const spec = opts?.synthesis;
|
|
18294
18418
|
if (spec === void 0) return draft;
|
|
18295
18419
|
await recoveryDone;
|
|
18296
18420
|
if (spec.mode === "incremental") return await reconcileIncremental(draft, spec);
|
|
18421
|
+
if (spec.skipWhenDraftValid === true && validationSpec !== void 0) {
|
|
18422
|
+
const skipKey = "synthesis-draft-valid-skip";
|
|
18423
|
+
const announceSkip = (entryRef) => {
|
|
18424
|
+
internals.events.emit({
|
|
18425
|
+
type: "log",
|
|
18426
|
+
level: "info",
|
|
18427
|
+
msg: "orchestrator synthesis skipped",
|
|
18428
|
+
data: {
|
|
18429
|
+
reason: "synthesis_skipped_by_valid_draft",
|
|
18430
|
+
skipDecisionRef: entryRef
|
|
18431
|
+
}
|
|
18432
|
+
}, callingState.spanId);
|
|
18433
|
+
};
|
|
18434
|
+
const prior = internals.replayer.snapshot().find((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.key === skipKey);
|
|
18435
|
+
if (prior !== void 0) {
|
|
18436
|
+
synthesisSkippedByValidDraft = true;
|
|
18437
|
+
announceSkip(prior.seq);
|
|
18438
|
+
return draft;
|
|
18439
|
+
}
|
|
18440
|
+
const draftValue = draft ?? null;
|
|
18441
|
+
const input = {
|
|
18442
|
+
result: draftValue,
|
|
18443
|
+
text: typeof draftValue === "string" ? draftValue : JSON.stringify(draftValue),
|
|
18444
|
+
children: validationChildren()
|
|
18445
|
+
};
|
|
18446
|
+
let allPassed = true;
|
|
18447
|
+
for (const validator of validationSpec.validators) {
|
|
18448
|
+
let verdict;
|
|
18449
|
+
try {
|
|
18450
|
+
verdict = validator.validate(input);
|
|
18451
|
+
} catch (thrown) {
|
|
18452
|
+
throw new ConfigError(`finish validator '${validator.name}' threw instead of returning a verdict during the skipWhenDraftValid pre-pass: ` + (thrown instanceof Error ? thrown.message : String(thrown)));
|
|
18453
|
+
}
|
|
18454
|
+
if (!verdict.ok) {
|
|
18455
|
+
allPassed = false;
|
|
18456
|
+
break;
|
|
18457
|
+
}
|
|
18458
|
+
}
|
|
18459
|
+
if (allPassed) {
|
|
18460
|
+
const skipEntry = await internals.replayer.appendSinglePhase({
|
|
18461
|
+
scope: callingState.scope,
|
|
18462
|
+
key: skipKey,
|
|
18463
|
+
kind: "decision",
|
|
18464
|
+
status: "ok",
|
|
18465
|
+
spanId: internals.spans.mint(callingState.spanId),
|
|
18466
|
+
site: "orchestrator-synthesis-skip",
|
|
18467
|
+
value: {
|
|
18468
|
+
decisionType: "orchestrator_synthesis_skip",
|
|
18469
|
+
reason: "synthesis_skipped_by_valid_draft",
|
|
18470
|
+
validators: validationSpec.validators.map((validator) => validator.name)
|
|
18471
|
+
}
|
|
18472
|
+
});
|
|
18473
|
+
if (orchestratorAccount !== void 0 && (opts?.budget?.synthesisReserveUsd ?? 0) > 0) internals.budget.releaseSynthesisReserve(orchestratorAccount);
|
|
18474
|
+
synthesisSkippedByValidDraft = true;
|
|
18475
|
+
announceSkip(skipEntry.seq);
|
|
18476
|
+
return draft;
|
|
18477
|
+
}
|
|
18478
|
+
}
|
|
18297
18479
|
const exposeTools = spec.exposeChildResultTools === true;
|
|
18298
18480
|
const fullContext = spec.context === "full";
|
|
18299
18481
|
const synthesisToolNames = /* @__PURE__ */ new Set([FINISH_TOOL_NAME, ...exposeTools ? [GET_CHILD_RESULT_TOOL_NAME, READ_CHILD_ARTIFACT_TOOL_NAME] : []]);
|
|
@@ -18643,7 +18825,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
18643
18825
|
...decision.salvagedPartialChildren === void 0 ? {} : { salvagedPartialChildren: decision.salvagedPartialChildren },
|
|
18644
18826
|
...decision.salvagedTerminalOutputChildren === void 0 ? {} : { salvagedTerminalOutputChildren: decision.salvagedTerminalOutputChildren },
|
|
18645
18827
|
...envelopeSchemaRecovered === 0 ? {} : { schemaRecoveredFinishExchanges: envelopeSchemaRecovered },
|
|
18646
|
-
...synthesisReserveLifecycle === void 0 ? {} : { synthesisReserve: synthesisReserveLifecycle }
|
|
18828
|
+
...synthesisReserveLifecycle === void 0 ? {} : { synthesisReserve: synthesisReserveLifecycle },
|
|
18829
|
+
...synthesisSkippedByValidDraft ? { synthesisSkipped: "synthesis_skipped_by_valid_draft" } : {}
|
|
18647
18830
|
};
|
|
18648
18831
|
});
|
|
18649
18832
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.101.0",
|
|
4
4
|
"description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|