@rulvar/core 1.99.1 → 1.100.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 +56 -8
- package/dist/index.js +108 -5
- 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. */
|
|
@@ -10330,4 +10378,4 @@ interface SandboxBridge {
|
|
|
10330
10378
|
declare const SANDBOX_AGENT_OPT_KEYS: readonly string[];
|
|
10331
10379
|
declare function createSandboxBridge(ctx: Ctx<never>, options: SandboxBridgeOptions): SandboxBridge;
|
|
10332
10380
|
//#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 };
|
|
10381
|
+
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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.100.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",
|