@rulvar/core 1.52.0 → 1.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +93 -7
- package/dist/index.js +160 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -515,7 +515,13 @@ type ChatEvent = {
|
|
|
515
515
|
};
|
|
516
516
|
/** Strictly 'adapterId:model', no query parameters. */
|
|
517
517
|
type ModelRef = `${string}:${string}`;
|
|
518
|
-
|
|
518
|
+
/**
|
|
519
|
+
* The seven invocation roles. 'synthesize' is the orchestrator's
|
|
520
|
+
* post-fan-in synthesis invocation (RV-211): it fires only when
|
|
521
|
+
* OrchestrateOptions.synthesis is configured, and the routing key picks
|
|
522
|
+
* its model like any other role without ever summoning it.
|
|
523
|
+
*/
|
|
524
|
+
type InvocationRole = "orchestrate" | "plan" | "loop" | "finalize" | "extract" | "summarize" | "synthesize";
|
|
519
525
|
/**
|
|
520
526
|
* What authors write wherever a model is configurable: a call override, an
|
|
521
527
|
* agent profile, a workflow default, or an engine default.
|
|
@@ -3767,8 +3773,8 @@ interface RunAgentOptions<S extends SchemaSpec = JsonSchema> {
|
|
|
3767
3773
|
}>;
|
|
3768
3774
|
};
|
|
3769
3775
|
agentType?: string;
|
|
3770
|
-
/** The primary invocation role of the tool loop; default 'loop' (M6-T05). */
|
|
3771
|
-
role?: "loop" | "plan" | "orchestrate";
|
|
3776
|
+
/** The primary invocation role of the tool loop; default 'loop' (M6-T05; RV-211 adds synthesize). */
|
|
3777
|
+
role?: "loop" | "plan" | "orchestrate" | "synthesize";
|
|
3772
3778
|
label?: string;
|
|
3773
3779
|
now?: () => number;
|
|
3774
3780
|
}
|
|
@@ -5934,6 +5940,11 @@ interface OrchestrateAcceptance {
|
|
|
5934
5940
|
/** How many rejected finishes are repaired by default: the plan's repair once. */
|
|
5935
5941
|
declare const DEFAULT_FINISH_MAX_REPAIRS = 1;
|
|
5936
5942
|
/**
|
|
5943
|
+
* Default maxTurns of the synthesize invocation (RV-211): the finish
|
|
5944
|
+
* call plus headroom for one validator repair exchange.
|
|
5945
|
+
*/
|
|
5946
|
+
declare const DEFAULT_SYNTHESIS_MAX_TURNS = 4;
|
|
5947
|
+
/**
|
|
5937
5948
|
* The opt in deterministic validation of the orchestrator finish result
|
|
5938
5949
|
* (the v1.40.0 improvement plan's RV-204 slice). Every SCHEMA valid
|
|
5939
5950
|
* finish({ result }) call first passes the configured host validators;
|
|
@@ -6022,6 +6033,51 @@ interface OrchestrateOptions {
|
|
|
6022
6033
|
* unchanged.
|
|
6023
6034
|
*/
|
|
6024
6035
|
exposeChildResultTools?: boolean;
|
|
6036
|
+
/**
|
|
6037
|
+
* The opt in post-fan-in synthesis invocation (RV-211): with this set,
|
|
6038
|
+
* the coordination loop's finish({ result }) becomes a DRAFT, and a
|
|
6039
|
+
* SEPARATE fresh invocation with role 'synthesize' (its own model,
|
|
6040
|
+
* effort, and limits through the ordinary resolution chain; the
|
|
6041
|
+
* routing key 'synthesize' picks its model and never summons it)
|
|
6042
|
+
* composes the final run result from the goal, the draft, and the
|
|
6043
|
+
* settled child digest, on the finish-only toolset. When
|
|
6044
|
+
* finishValidation is configured its validators bind the SYNTHESIS
|
|
6045
|
+
* finish (the final output), not the draft. See
|
|
6046
|
+
* {@link OrchestrateSynthesis}.
|
|
6047
|
+
*/
|
|
6048
|
+
synthesis?: OrchestrateSynthesis;
|
|
6049
|
+
}
|
|
6050
|
+
/**
|
|
6051
|
+
* The synthesis invocation's own knobs (RV-211). Everything else about
|
|
6052
|
+
* the invocation is deterministic: the prompt derives from the journaled
|
|
6053
|
+
* draft and the settled child digest, the toolset is the single finish
|
|
6054
|
+
* tool (a distinct toolsetHash, exactly like the reserved cap
|
|
6055
|
+
* finalizer), the invocation journals as an ordinary agent entry (a
|
|
6056
|
+
* resume replays it with zero paid calls), and its telemetry is a full
|
|
6057
|
+
* agent span with role 'synthesize' phase pairs, so
|
|
6058
|
+
* `CostReport.byRole.synthesize` and `reduceCriticalPath` attribute it
|
|
6059
|
+
* without heuristics. Failure posture: with finishValidation configured
|
|
6060
|
+
* a failed synthesis fails the run typed (the validated path is
|
|
6061
|
+
* mandatory); without validators the run falls back to the coordination
|
|
6062
|
+
* draft under a journaled 'orchestrator_synthesis_fallback' decision and
|
|
6063
|
+
* a warn log, never silently.
|
|
6064
|
+
*/
|
|
6065
|
+
interface OrchestrateSynthesis {
|
|
6066
|
+
/** Model override for the synthesize invocation; the routing key and chain apply otherwise. */
|
|
6067
|
+
model?: ModelSpec;
|
|
6068
|
+
/** Canonical effort of the synthesize invocation. */
|
|
6069
|
+
effort?: Effort;
|
|
6070
|
+
/** UsageLimits of the synthesize invocation; default { maxTurns: 4 }. */
|
|
6071
|
+
limits?: UsageLimits;
|
|
6072
|
+
/** Extra deterministic instruction lines appended to the synthesis prompt. */
|
|
6073
|
+
instructions?: string;
|
|
6074
|
+
/**
|
|
6075
|
+
* Admission estimate for the synthesize invocation, like
|
|
6076
|
+
* AgentOpts.estCost: under a tight orchestrator cap the default
|
|
6077
|
+
* reserve (full maxOutputTokens pricing) can refuse the dispatch; an
|
|
6078
|
+
* explicit estimate is the host speaking.
|
|
6079
|
+
*/
|
|
6080
|
+
estCost?: number;
|
|
6025
6081
|
}
|
|
6026
6082
|
declare const ORCHESTRATE_WORKFLOW_NAME = "rulvar-orchestrate";
|
|
6027
6083
|
/**
|
|
@@ -6285,10 +6341,12 @@ interface AgentOpts<S extends SchemaSpec = SchemaSpec> {
|
|
|
6285
6341
|
* The primary invocation role of the agent's tool loop; default
|
|
6286
6342
|
* 'loop'. The plan and orchestrate entry points set it so the
|
|
6287
6343
|
* resolution chain, role effort defaults, quality floors, and cost
|
|
6288
|
-
* buckets see the right role
|
|
6289
|
-
*
|
|
6344
|
+
* buckets see the right role, and the orchestrator's post-fan-in
|
|
6345
|
+
* synthesis invocation (RV-211) runs as 'synthesize';
|
|
6346
|
+
* extract/finalize/summarize stay trigger-derived and are never
|
|
6347
|
+
* settable here (M6-T05 amendment).
|
|
6290
6348
|
*/
|
|
6291
|
-
role?: "loop" | "plan" | "orchestrate";
|
|
6349
|
+
role?: "loop" | "plan" | "orchestrate" | "synthesize";
|
|
6292
6350
|
/** Overrides all roles at once. */
|
|
6293
6351
|
model?: ModelSpec;
|
|
6294
6352
|
/** Per-role, wins over profile.routing. */
|
|
@@ -7597,6 +7655,34 @@ interface InvocationTable {
|
|
|
7597
7655
|
* replayed one produce the same usage and cost columns.
|
|
7598
7656
|
*/
|
|
7599
7657
|
declare function reduceInvocationTable(events: Iterable<WorkflowEvent>): InvocationTable;
|
|
7658
|
+
/**
|
|
7659
|
+
* The critical-path summary of one run (RV-211): the plan's post-fan-in
|
|
7660
|
+
* gate ("synthesis takes at most 40% of wall time with four settled
|
|
7661
|
+
* workers") computed as a pure fold over the same vocabulary, no
|
|
7662
|
+
* heuristics beyond the role tags. Post-fan-in is the interval from the
|
|
7663
|
+
* LAST settled non-coordination agent (any span whose primary role is
|
|
7664
|
+
* neither 'orchestrate' nor 'synthesize') to run:end; the synthesis wall
|
|
7665
|
+
* is the summed span wall of 'synthesize' spans. Wall numbers are LIVE
|
|
7666
|
+
* fidelity: a replayed stream re-stamps emission times, so its intervals
|
|
7667
|
+
* are degenerate, exactly like phase durations. Absent pieces (no
|
|
7668
|
+
* run:end, no worker spans) leave the corresponding fields undefined
|
|
7669
|
+
* rather than guessed at.
|
|
7670
|
+
*/
|
|
7671
|
+
interface CriticalPath {
|
|
7672
|
+
/** run:start to run:end; absent while the run is open. */
|
|
7673
|
+
runWallMs?: number;
|
|
7674
|
+
/** Last non-coordination agent:end to run:end; absent without both. */
|
|
7675
|
+
postFanInMs?: number;
|
|
7676
|
+
/** Summed wall of completed 'synthesize' spans (0 when none). */
|
|
7677
|
+
synthesisMs: number;
|
|
7678
|
+
/** postFanInMs / runWallMs when both are defined and the wall is > 0. */
|
|
7679
|
+
postFanInShare?: number;
|
|
7680
|
+
/** synthesisMs / runWallMs under the same conditions. */
|
|
7681
|
+
synthesisShare?: number;
|
|
7682
|
+
/** Settled non-coordination agent spans that anchored the fan-in. */
|
|
7683
|
+
workerSpans: number;
|
|
7684
|
+
}
|
|
7685
|
+
declare function reduceCriticalPath(events: Iterable<WorkflowEvent>): CriticalPath;
|
|
7600
7686
|
//#endregion
|
|
7601
7687
|
//#region src/runner/sandbox-bridge.d.ts
|
|
7602
7688
|
/** Methods a sandbox script may proxy to the host ctx. */
|
|
@@ -7670,4 +7756,4 @@ interface SandboxBridge {
|
|
|
7670
7756
|
declare const SANDBOX_AGENT_OPT_KEYS: readonly string[];
|
|
7671
7757
|
declare function createSandboxBridge(ctx: Ctx<never>, options: SandboxBridgeOptions): SandboxBridge;
|
|
7672
7758
|
//#endregion
|
|
7673
|
-
export { AWAIT_SCHEMA, AbandonAttempt, AbandonFold, AbandonPayload, AbandonedSpendView, AbortClass, type AdaptiveEvents, AdmissionController, AdmissionDecision, AdmissionRejectedError, AdmissionStatsBefore, AdmitLineage, AdmitRejectReason, AdmitSpec, AdmitVerdict, AgentCallError, AgentError, type AgentEvents, AgentIdentityInput, type AgentInvocationRow, AgentOpts, AgentProfile, AgentProfilePermissions, AgentResult, AgentResultMeta, AgentStatus, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditRunsOptions, BUDGET_ABORT_REASON, BaseAppend, BriefOpts, BudgetAccountView, BudgetDefaults, BudgetExhaustedError, BudgetExhaustionDiagnostics, BudgetHooks, BudgetReserve, type Bytes, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, CacheHint, CacheTtl, CanUseTool, CanonicalId, CanonicalIdentity, CanonicalLadderSpec, CanonicalModelSpec, ChatEvent, ChatRequest, CheckpointState, ChildArtifactPage, ChildIdentityInput, ChildResultPage, type ClaimClass, type ClaimOp, type ClaimStatus, ClaimValidationOptions, CollectOpts, CollectedTurn, CompactionConfig, CompiledPermissionChain, CompiledWorkflow, ConfigError, type CoreEvents, CostAttribution, CostAttributionFacts, CostReport, CreateEngineOptions, Ctx, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DerivedKey, DeriverRegistry, type DeterminismConfig, DeterminismError, type DeterminismEvents, type DeterminismMode, DispositionRule, DispositionTable, DonorCandidate, DonorRef, DroppedItem, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EffectiveUsageLimits, Effort, Engine, EngineDefaults, EntryKind, EntryRef, EntryStatus, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, type EvidenceRef, type ExplorationSummary, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, FinishInfo, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, InvocationRole, type InvocationTable, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, JournalSerializationHook, type JournalStore, type Json, JsonSchema, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, type KbProposal, type KbProposalTrigger, KeyDeriver, KeyRing, KeyedLimiter, KnowledgeCasError, type KnowledgeSnapshot, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LadderSpec, type LeasableStore, type Lease, LeaseHeldError, Ledger, LineageCounters, LineageIndex, LineageRef, LineageRelation, LineageStats, LogicalTaskId, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, MatchResult, McpConfig, McpToolSource, MechanicalGateProfile, MechanicalGateVerdict, type MetaLookupStore, type ModelCaps, ModelChoice, type ModelClaim, ModelEpochInputs, type ModelKnowledgeHandle, type ModelKnowledgeStore, ModelListConstraint, ModelRef, ModelRetry, ModelSpec, Msg, NoProgressDetector, NodeId, NodeLinkValue, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OnEscalation, OperationDisposition, OrchestrateAcceptance, OrchestrateOptions, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PriceTable, PricedUsage, type Pricing, type PricingTier, type ProviderAdapter, QualityFloors, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, type RunFilter, RunHandle, RunInternals, type RunMeta, RunOptions, RunOutcome, RunProfile, RunStateAudit, RunStatus, RuntimeEventSink, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxBridge, SandboxBridgeOptions, SandboxError, SandboxHostToWorker, SandboxMethod, SandboxWorkerToHost, SchemaPair, SchemaSpec, SchemaValidationResult, ScopeSegment, ScriptRejected, ScriptRunner, ScrubNote, Semaphore, SerializationHook, Settled, ShellPatternRules, ShellSegment, ShellVerdict, SinglePhaseAppend, SpanMinter, SpanRegistry, SpawnAdmissionValue, SpawnAgentParams, SpawnKey, SpawnLineage, SpawnLineageOpt, SpawnOrigin, SpawnRecord, Spend, Stage, type StandardJSONSchemaV1, type StandardSchemaV1, StepIdentityInput, StructuredOutputTier, SuspendedAppend, SuspensionState, TOOL_NAME_PATTERN, type TaskClass, TaskDigest, TaskSpec, TerminalPatch, TerminationAccount, TerminationAccountSnapshot, TerminationDeniedValue, TerminationDeniedWriter, TerminationInitValue, TerminationLimits, TerminationResource, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, ToolInit, type ToolRisk, ToolRuntime, type ToolSource, type ToolSourceSession, ToolsOption, TranscriptSerializationHook, type TranscriptStore, TriggerClass, TtlState, Usage, UsageLimits, UsageSlice, VerifiedRecommendation, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, WakeBudgetBlock, WakeDigest, WakeTrigger, WireError, Workflow, WorkflowCallOpts, type WorkflowEvent, type WorkflowEventBody, WorkflowRegistry, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
|
7759
|
+
export { AWAIT_SCHEMA, AbandonAttempt, AbandonFold, AbandonPayload, AbandonedSpendView, AbortClass, type AdaptiveEvents, AdmissionController, AdmissionDecision, AdmissionRejectedError, AdmissionStatsBefore, AdmitLineage, AdmitRejectReason, AdmitSpec, AdmitVerdict, AgentCallError, AgentError, type AgentEvents, AgentIdentityInput, type AgentInvocationRow, AgentOpts, AgentProfile, AgentProfilePermissions, AgentResult, AgentResultMeta, AgentStatus, ApproachSignatureInputs, ApprovalDecision, ApprovalIdentityInput, Artifact, AttemptOutcomeClass, AuditRunsOptions, BUDGET_ABORT_REASON, BaseAppend, BriefOpts, BudgetAccountView, BudgetDefaults, BudgetExhaustedError, BudgetExhaustionDiagnostics, BudgetHooks, BudgetReserve, type Bytes, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, CacheHint, CacheTtl, CanUseTool, CanonicalId, CanonicalIdentity, CanonicalLadderSpec, CanonicalModelSpec, ChatEvent, ChatRequest, CheckpointState, ChildArtifactPage, ChildIdentityInput, ChildResultPage, type ClaimClass, type ClaimOp, type ClaimStatus, ClaimValidationOptions, CollectOpts, CollectedTurn, CompactionConfig, CompiledPermissionChain, CompiledWorkflow, ConfigError, type CoreEvents, CostAttribution, CostAttributionFacts, CostReport, CreateEngineOptions, type CriticalPath, Ctx, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_SYNTHESIS_MAX_TURNS, DebitResult, DeclaredLadder, DedupIndex, DedupNote, DerivedKey, DeriverRegistry, type DeterminismConfig, DeterminismError, type DeterminismEvents, type DeterminismMode, DispositionRule, DispositionTable, DonorCandidate, DonorRef, DroppedItem, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EffectiveUsageLimits, Effort, Engine, EngineDefaults, EntryKind, EntryRef, EntryStatus, ErrorClass, ErrorCode, ErrorPolicy, EscalatedResult, EscalationDecision, EscalationDecisionAbortedError, EscalationDigest, EscalationKind, EscalationLimits, EscalationOptions, EscalationReport, EscalationRequest, EventBus, type EvidenceRef, type ExplorationSummary, ExtensionAppendInput, ExtensionDispatchSpec, ExternalIdentityInput, ExternalRegistry, ExtractNecessityInput, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FailoverTarget, FailoverTrigger, FallbackField, FallbackTrigger, FileModelKnowledgeStore, FileModelKnowledgeStoreOptions, FileTranscriptStore, FinishInfo, FinishValidationChild, FinishValidationInput, FinishValidationSpec, FinishValidationVerdict, FinishValidator, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, Gate, GateAudit, type GateRecord, GitWorktreeProvider, GitWorktreeProviderOptions, GraftBoot, HashVersion, HookVerdict, INBOX_PROPOSAL_TTL_DAYS, IdentityInput, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, InvocationRole, type InvocationTable, type IsolationProvider, type IsolationSpec, Issue$1 as Issue, JournalCompatSubCode, JournalCompatibilityError, JournalEntry, JournalMatcher, JournalMissError, JournalOperation, JournalOrderViolation, JournalSerializationHook, type JournalStore, type Json, JsonSchema, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, type KbProposal, type KbProposalTrigger, KeyDeriver, KeyRing, KeyedLimiter, KnowledgeCasError, type KnowledgeSnapshot, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LadderSpec, type LeasableStore, type Lease, LeaseHeldError, Ledger, LineageCounters, LineageIndex, LineageRef, LineageRelation, LineageStats, LogicalTaskId, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, MatchResult, McpConfig, McpToolSource, MechanicalGateProfile, MechanicalGateVerdict, type MetaLookupStore, type ModelCaps, ModelChoice, type ModelClaim, ModelEpochInputs, type ModelKnowledgeHandle, type ModelKnowledgeStore, ModelListConstraint, ModelRef, ModelRetry, ModelSpec, Msg, NoProgressDetector, NodeId, NodeLinkValue, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OnEscalation, OperationDisposition, OrchestrateAcceptance, OrchestrateOptions, OrchestrateSynthesis, OrchestratorBudgetSpec, OrchestratorCapConfigError, OrchestratorExtension, OrchestratorExtensionIO, OrchestratorRuntime, Out, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, Part, PendingExternal, PendingToolTurn, PermissionConfig, PermissionGate, PermissionHook, PermissionPreset, PermissionRule, PermissionVerdict, type PhaseRow, PhaseTarget, PipelineCollected, PipelineOpts, PlanInvariantError, PriceTable, PricedUsage, type Pricing, type PricingTier, type ProviderAdapter, QualityFloors, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, RandIdentityInput, RandPayload, ReconcileOptions, ReconcileResult, RefEntryAppender, RefEntryClassification, RefusalInfo, ReplayDisposition, ReplayMode, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionAttempt, ResolutionBy, ResolutionFold, ResolutionLayer, ResolutionOutcome, ResolutionPayload, ResolvedInvocation, ResolvedToolset, ResumeHandle, ResumeOptions, ResumePreview, ResumeReport, RetryClass, RetryPolicy, ReuseConfig, RiskRuleValue, Role, RulvarError, RulvarErrorCode, RunAgentOptions, RunAuditVerdict, RunBudget, RunEventSink, type RunFilter, RunHandle, RunInternals, type RunMeta, RunOptions, RunOutcome, RunProfile, RunStateAudit, RunStatus, RuntimeEventSink, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxBridge, SandboxBridgeOptions, SandboxError, SandboxHostToWorker, SandboxMethod, SandboxWorkerToHost, SchemaPair, SchemaSpec, SchemaValidationResult, ScopeSegment, ScriptRejected, ScriptRunner, ScrubNote, Semaphore, SerializationHook, Settled, ShellPatternRules, ShellSegment, ShellVerdict, SinglePhaseAppend, SpanMinter, SpanRegistry, SpawnAdmissionValue, SpawnAgentParams, SpawnKey, SpawnLineage, SpawnLineageOpt, SpawnOrigin, SpawnRecord, Spend, Stage, type StandardJSONSchemaV1, type StandardSchemaV1, StepIdentityInput, StructuredOutputTier, SuspendedAppend, SuspensionState, TOOL_NAME_PATTERN, type TaskClass, TaskDigest, TaskSpec, TerminalPatch, TerminationAccount, TerminationAccountSnapshot, TerminationDeniedValue, TerminationDeniedWriter, TerminationInitValue, TerminationLimits, TerminationResource, ToolCallRequest, ToolChoice, type ToolContext, ToolContextSeed, ToolContract, type ToolDef, type ToolEvents, type ToolExecutor, ToolInit, type ToolRisk, ToolRuntime, type ToolSource, type ToolSourceSession, ToolsOption, TranscriptSerializationHook, type TranscriptStore, TriggerClass, TtlState, Usage, UsageLimits, UsageSlice, VerifiedRecommendation, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, WakeBudgetBlock, WakeDigest, WakeTrigger, WireError, Workflow, WorkflowCallOpts, type WorkflowEvent, type WorkflowEventBody, WorkflowRegistry, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceCriticalPath, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
package/dist/index.js
CHANGED
|
@@ -13286,6 +13286,11 @@ async function executeWorkflow(internals, wf, args) {
|
|
|
13286
13286
|
*/
|
|
13287
13287
|
/** How many rejected finishes are repaired by default: the plan's repair once. */
|
|
13288
13288
|
const DEFAULT_FINISH_MAX_REPAIRS = 1;
|
|
13289
|
+
/**
|
|
13290
|
+
* Default maxTurns of the synthesize invocation (RV-211): the finish
|
|
13291
|
+
* call plus headroom for one validator repair exchange.
|
|
13292
|
+
*/
|
|
13293
|
+
const DEFAULT_SYNTHESIS_MAX_TURNS = 4;
|
|
13289
13294
|
const ORCHESTRATE_WORKFLOW_NAME = "rulvar-orchestrate";
|
|
13290
13295
|
/**
|
|
13291
13296
|
* One page of a string, for the child result evidence tools: maxChars is
|
|
@@ -13343,6 +13348,19 @@ function validateOrchestrateOptions(opts) {
|
|
|
13343
13348
|
}
|
|
13344
13349
|
if (fv.maxRepairs !== void 0) requireNonNegativeInteger(fv.maxRepairs, "orchestrate finishValidation.maxRepairs");
|
|
13345
13350
|
}
|
|
13351
|
+
if (opts.synthesis !== void 0) {
|
|
13352
|
+
const synthesis = opts.synthesis;
|
|
13353
|
+
if (synthesis.effort !== void 0 && ![
|
|
13354
|
+
"low",
|
|
13355
|
+
"medium",
|
|
13356
|
+
"high",
|
|
13357
|
+
"xhigh",
|
|
13358
|
+
"max"
|
|
13359
|
+
].includes(synthesis.effort)) throw new ConfigError(`orchestrate synthesis.effort must be one of 'low' | 'medium' | 'high' | 'xhigh' | 'max'; got ${JSON.stringify(synthesis.effort)}`);
|
|
13360
|
+
if (synthesis.limits !== void 0) validateUsageLimits(synthesis.limits, "orchestrate synthesis.limits");
|
|
13361
|
+
if (synthesis.instructions !== void 0 && typeof synthesis.instructions !== "string") throw new ConfigError(`orchestrate synthesis.instructions must be a string; got ${typeof synthesis.instructions}`);
|
|
13362
|
+
if (synthesis.estCost !== void 0) requireNonNegativeNumber(synthesis.estCost, "orchestrate synthesis.estCost");
|
|
13363
|
+
}
|
|
13346
13364
|
const spec = opts.budget;
|
|
13347
13365
|
if (spec === void 0) return;
|
|
13348
13366
|
if (spec.capUsd !== void 0) requireNonNegativeNumber(spec.capUsd, "orchestrate budget.capUsd");
|
|
@@ -14330,7 +14348,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
14330
14348
|
},
|
|
14331
14349
|
[kTerminalTool]: {
|
|
14332
14350
|
name: FINISH_TOOL_NAME,
|
|
14333
|
-
...validationSpec === void 0 ? {} : { validate: validateFinish }
|
|
14351
|
+
...validationSpec === void 0 || opts?.synthesis !== void 0 ? {} : { validate: validateFinish }
|
|
14334
14352
|
},
|
|
14335
14353
|
...(() => {
|
|
14336
14354
|
const priorCancelledRoot = internals.replayer.snapshot().filter((entry) => entry.kind === "agent" && entry.scope === callingState.scope && entry.status === "cancelled" && entry.checkpointRef !== void 0).at(-1);
|
|
@@ -14407,6 +14425,96 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
14407
14425
|
};
|
|
14408
14426
|
};
|
|
14409
14427
|
/**
|
|
14428
|
+
* The post-fan-in synthesis invocation (RV-211): a FRESH agent entry
|
|
14429
|
+
* with role 'synthesize' on the finish-only toolset (a distinct
|
|
14430
|
+
* toolsetHash, the reserved-finalizer precedent), its prompt derived
|
|
14431
|
+
* deterministically from the goal, the journaled coordination draft,
|
|
14432
|
+
* and the settled child digest, so a resume replays it by identity
|
|
14433
|
+
* with zero paid calls. Runs strictly AFTER the acceptance verdict
|
|
14434
|
+
* (a rejected run never pays for synthesis) and owns the finish
|
|
14435
|
+
* validators when they are configured. Failure posture: with
|
|
14436
|
+
* validators the run fails typed (the validated path is mandatory);
|
|
14437
|
+
* without them the run falls back to the draft under a journaled
|
|
14438
|
+
* decision and a warn log, never silently.
|
|
14439
|
+
*/
|
|
14440
|
+
const runSynthesis = async (draft) => {
|
|
14441
|
+
const spec = opts?.synthesis;
|
|
14442
|
+
if (spec === void 0) return draft;
|
|
14443
|
+
await recoveryDone;
|
|
14444
|
+
const finishOnly = buildOrchestratorTools(orchestratorRuntime, fullCardText).filter((tool) => tool.name === FINISH_TOOL_NAME);
|
|
14445
|
+
const settledDigests = [...records.values()].filter((record) => record.settled !== void 0).sort((a, b) => a.spawnOrdinal - b.spawnOrdinal).map((record) => digestOf(record, record.settled));
|
|
14446
|
+
const draftJson = JSON.stringify(draft ?? null);
|
|
14447
|
+
const digestJson = JSON.stringify(settledDigests);
|
|
14448
|
+
const prompt = [
|
|
14449
|
+
"You are the synthesis invocation of an orchestrated run. Compose the FINAL result of the run from the goal, the coordination draft, and the settled child evidence below by calling finish({ result }) EXACTLY once. Preserve the evidence and citations the draft relies on; do not invent findings. No other tool exists.",
|
|
14450
|
+
...spec.instructions === void 0 ? [] : [spec.instructions],
|
|
14451
|
+
...finishValidationPromptLines(validationSpec),
|
|
14452
|
+
`GOAL: ${goal}`,
|
|
14453
|
+
`DRAFT: ${draftJson}`,
|
|
14454
|
+
`DIGEST: ${digestJson}`
|
|
14455
|
+
].join("\n");
|
|
14456
|
+
internals.events.emit({
|
|
14457
|
+
type: "log",
|
|
14458
|
+
level: "debug",
|
|
14459
|
+
msg: "orchestrator synthesis context",
|
|
14460
|
+
data: {
|
|
14461
|
+
children: settledDigests.length,
|
|
14462
|
+
draftChars: draftJson.length,
|
|
14463
|
+
digestChars: digestJson.length,
|
|
14464
|
+
promptChars: prompt.length,
|
|
14465
|
+
perChild: settledDigests.map((entry) => ({
|
|
14466
|
+
nodeId: entry.nodeId,
|
|
14467
|
+
chars: JSON.stringify(entry).length
|
|
14468
|
+
}))
|
|
14469
|
+
}
|
|
14470
|
+
}, callingState.spanId);
|
|
14471
|
+
const synthesisState = { ...callingState };
|
|
14472
|
+
if (orchestratorAccount !== void 0) synthesisState.budgetScope = orchestratorAccount;
|
|
14473
|
+
const synthesisBreak = validationSpec === void 0 ? void 0 : validationAbort.signal;
|
|
14474
|
+
if (synthesisBreak !== void 0) synthesisState.signal = callingState.signal === void 0 ? synthesisBreak : AbortSignal.any([callingState.signal, synthesisBreak]);
|
|
14475
|
+
const synthesisOpts = {
|
|
14476
|
+
role: "synthesize",
|
|
14477
|
+
result: "full",
|
|
14478
|
+
tools: finishOnly,
|
|
14479
|
+
limits: spec.limits ?? { maxTurns: 4 },
|
|
14480
|
+
...spec.model === void 0 ? {} : { model: spec.model },
|
|
14481
|
+
...spec.effort === void 0 ? {} : { effort: spec.effort },
|
|
14482
|
+
...spec.estCost === void 0 ? {} : { estCost: spec.estCost },
|
|
14483
|
+
[kTerminalTool]: {
|
|
14484
|
+
name: FINISH_TOOL_NAME,
|
|
14485
|
+
...validationSpec === void 0 ? {} : { validate: validateFinish }
|
|
14486
|
+
}
|
|
14487
|
+
};
|
|
14488
|
+
const synthesized = await runtime.runInScope(synthesisState, () => ctx.agent(prompt, synthesisOpts));
|
|
14489
|
+
if (validationTermination !== void 0) throw validationTermination;
|
|
14490
|
+
if (synthesized.status === "ok") return synthesized.output;
|
|
14491
|
+
if (validationSpec !== void 0) throw new FailRunError(`the synthesis invocation terminated with status '${synthesized.status}'` + (synthesized.errorMessage === void 0 ? "" : `: ${synthesized.errorMessage}`) + "; finish validators are configured, so the unvalidated draft cannot stand", { data: {
|
|
14492
|
+
source: "orchestrator_synthesis",
|
|
14493
|
+
status: synthesized.status,
|
|
14494
|
+
turnsUsed: synthesized.turns
|
|
14495
|
+
} });
|
|
14496
|
+
const fallbackKey = deriverV2.deriveKey({ kind: "orchestrator-synthesis-fallback" });
|
|
14497
|
+
if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === fallbackKey)) await internals.replayer.appendSinglePhase({
|
|
14498
|
+
scope: callingState.scope,
|
|
14499
|
+
key: fallbackKey,
|
|
14500
|
+
kind: "decision",
|
|
14501
|
+
status: "ok",
|
|
14502
|
+
spanId: internals.spans.mint(callingState.spanId),
|
|
14503
|
+
site: "orchestrator-synthesis",
|
|
14504
|
+
value: {
|
|
14505
|
+
decisionType: "orchestrator_synthesis_fallback",
|
|
14506
|
+
status: synthesized.status,
|
|
14507
|
+
turnsUsed: synthesized.turns
|
|
14508
|
+
}
|
|
14509
|
+
});
|
|
14510
|
+
internals.events.emit({
|
|
14511
|
+
type: "log",
|
|
14512
|
+
level: "warn",
|
|
14513
|
+
msg: `the synthesis invocation terminated with status '${synthesized.status}'; falling back to the coordination draft (journaled decision 'orchestrator_synthesis_fallback')`
|
|
14514
|
+
}, callingState.spanId);
|
|
14515
|
+
return draft;
|
|
14516
|
+
};
|
|
14517
|
+
/**
|
|
14410
14518
|
* The settle at the cap: the JOURNALED cap decision drives the policy
|
|
14411
14519
|
* branch (its `fallback` field froze budget.atCap when the cap
|
|
14412
14520
|
* tripped), so a crash between the decision and its effect rolls the
|
|
@@ -14440,7 +14548,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
14440
14548
|
if (validationTermination !== void 0) throw validationTermination;
|
|
14441
14549
|
if (orchestratorAccount !== void 0) internals.cost.orchestrator.spentUsd = internals.budget.accountView(orchestratorAccount)?.spentUsd ?? 0;
|
|
14442
14550
|
if (result.status !== "ok") throw new ConfigError(`the orchestrator agent terminated with status '${result.status}'` + (result.errorMessage === void 0 ? "" : `: ${result.errorMessage}`));
|
|
14443
|
-
if (opts?.acceptance === void 0) return result.output;
|
|
14551
|
+
if (opts?.acceptance === void 0) return await runSynthesis(result.output);
|
|
14444
14552
|
const acceptanceKey = "acceptance";
|
|
14445
14553
|
const priorAcceptance = internals.replayer.snapshot().find((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.key === acceptanceKey);
|
|
14446
14554
|
let decision;
|
|
@@ -14484,7 +14592,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
14484
14592
|
} });
|
|
14485
14593
|
}
|
|
14486
14594
|
return {
|
|
14487
|
-
result: result.output,
|
|
14595
|
+
result: await runSynthesis(result.output),
|
|
14488
14596
|
completion: decision.completion,
|
|
14489
14597
|
childStatusCounts: decision.childStatusCounts,
|
|
14490
14598
|
degradedReasons: decision.degradedReasons
|
|
@@ -14806,6 +14914,54 @@ function reduceInvocationTable(events) {
|
|
|
14806
14914
|
totalCostUsd
|
|
14807
14915
|
};
|
|
14808
14916
|
}
|
|
14917
|
+
function reduceCriticalPath(events) {
|
|
14918
|
+
let runStart;
|
|
14919
|
+
let runEnd;
|
|
14920
|
+
const startBySpan = /* @__PURE__ */ new Map();
|
|
14921
|
+
let lastWorkerEnd;
|
|
14922
|
+
let workerSpans = 0;
|
|
14923
|
+
let synthesisMs = 0;
|
|
14924
|
+
for (const event of events) {
|
|
14925
|
+
const at = Date.parse(event.ts);
|
|
14926
|
+
if (!Number.isFinite(at)) continue;
|
|
14927
|
+
switch (event.type) {
|
|
14928
|
+
case "run:start":
|
|
14929
|
+
runStart ??= at;
|
|
14930
|
+
break;
|
|
14931
|
+
case "run:end":
|
|
14932
|
+
runEnd = at;
|
|
14933
|
+
break;
|
|
14934
|
+
case "agent:start":
|
|
14935
|
+
startBySpan.set(event.spanId, {
|
|
14936
|
+
role: event.role,
|
|
14937
|
+
at
|
|
14938
|
+
});
|
|
14939
|
+
break;
|
|
14940
|
+
case "agent:end": {
|
|
14941
|
+
const started = startBySpan.get(event.spanId);
|
|
14942
|
+
if (started === void 0) break;
|
|
14943
|
+
if (started.role === "synthesize") synthesisMs += Math.max(0, at - started.at);
|
|
14944
|
+
else if (started.role !== "orchestrate") {
|
|
14945
|
+
workerSpans += 1;
|
|
14946
|
+
lastWorkerEnd = lastWorkerEnd === void 0 ? at : Math.max(lastWorkerEnd, at);
|
|
14947
|
+
}
|
|
14948
|
+
break;
|
|
14949
|
+
}
|
|
14950
|
+
default: break;
|
|
14951
|
+
}
|
|
14952
|
+
}
|
|
14953
|
+
const path = {
|
|
14954
|
+
synthesisMs,
|
|
14955
|
+
workerSpans
|
|
14956
|
+
};
|
|
14957
|
+
if (runStart !== void 0 && runEnd !== void 0) path.runWallMs = Math.max(0, runEnd - runStart);
|
|
14958
|
+
if (runEnd !== void 0 && lastWorkerEnd !== void 0) path.postFanInMs = Math.max(0, runEnd - lastWorkerEnd);
|
|
14959
|
+
if (path.runWallMs !== void 0 && path.runWallMs > 0) {
|
|
14960
|
+
if (path.postFanInMs !== void 0) path.postFanInShare = path.postFanInMs / path.runWallMs;
|
|
14961
|
+
path.synthesisShare = synthesisMs / path.runWallMs;
|
|
14962
|
+
}
|
|
14963
|
+
return path;
|
|
14964
|
+
}
|
|
14809
14965
|
//#endregion
|
|
14810
14966
|
//#region src/l0/run-id.ts
|
|
14811
14967
|
/**
|
|
@@ -15933,4 +16089,4 @@ function createSandboxBridge(ctx, options) {
|
|
|
15933
16089
|
};
|
|
15934
16090
|
}
|
|
15935
16091
|
//#endregion
|
|
15936
|
-
export { AWAIT_SCHEMA, AdmissionController, AdmissionRejectedError, AgentCallError, BUDGET_ABORT_REASON, BudgetExhaustedError, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, ConfigError, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DedupIndex, DeterminismError, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EscalationDecisionAbortedError, EventBus, ExternalRegistry, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FileModelKnowledgeStore, FileTranscriptStore, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, GitWorktreeProvider, INBOX_PROPOSAL_TTL_DAYS, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, JournalCompatibilityError, JournalMatcher, JournalMissError, JournalOrderViolation, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, KeyedLimiter, KnowledgeCasError, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LeaseHeldError, LineageIndex, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, ModelRetry, NoProgressDetector, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OrchestratorCapConfigError, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, PlanInvariantError, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionFold, RulvarError, RunBudget, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxError, ScriptRejected, Semaphore, SpanRegistry, TOOL_NAME_PATTERN, TerminationAccount, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
|
16092
|
+
export { AWAIT_SCHEMA, AdmissionController, AdmissionRejectedError, AgentCallError, BUDGET_ABORT_REASON, BudgetExhaustedError, CANCEL_AGENT_SCHEMA, CHECKPOINT_FORMAT_V1, CLAIM_STATEMENT_MAX_CHARS, CLAIM_TTL_DAYS, COMPACTION_SUMMARY_PREFIX, CURRENT_HASH_VERSION, ConfigError, DEFAULT_CHILD_BUDGET_FRACTION, DEFAULT_CHILD_RESULT_PAGE_CHARS, DEFAULT_CITATION_PATTERN, DEFAULT_COMPACTION_THRESHOLD, DEFAULT_ESCALATION_LIMITS, DEFAULT_EVIDENCE_MIN_SHARE, DEFAULT_FINISH_MAX_REPAIRS, DEFAULT_FLAT_RESERVE_USD, DEFAULT_MAX_CHILDREN_PER_NODE, DEFAULT_MAX_DEPTH, DEFAULT_MAX_OSCILLATIONS_PER_KEY, DEFAULT_MAX_PINNED_WORKTREES, DEFAULT_MAX_REVISIONS_PER_RUN, DEFAULT_MAX_TOTAL_SPAWNS, DEFAULT_MAX_TURNS, DEFAULT_MODEL_RETRY_ATTEMPTS, DEFAULT_NO_PROGRESS_TURNS, DEFAULT_PER_RUN_CONCURRENCY, DEFAULT_RETRY_POLICY, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_SYNTHESIS_MAX_TURNS, DedupIndex, DeterminismError, EMIT_RESULT_TOOL, EMPTY_SCHEMA_HASH, EMPTY_TOOLSET_HASH, ESCALATE_TOOL_NAME, ESCALATION_REPORT_SCHEMA, ESCALATION_REQUEST_SCHEMA, EVENT_SEGMENT_STRIDE, EscalationDecisionAbortedError, EventBus, ExternalRegistry, FINALIZE_SYNTHESIS_INSTRUCTION, FINISH_SCHEMA, FINISH_TOOL_NAME, FailRunError, FileModelKnowledgeStore, FileTranscriptStore, GET_CHILD_RESULT_SCHEMA, GET_CHILD_RESULT_TOOL_NAME, GitWorktreeProvider, INBOX_PROPOSAL_TTL_DAYS, InMemoryStore, InMemoryTranscriptStore, InProcessRunner, InvalidResolutionError, JournalCompatibilityError, JournalMatcher, JournalMissError, JournalOrderViolation, JsonlFileStore, KB_ACTIVE_CLAIMS_CAP, KB_CARD_RENDER_BUDGET_CHARS, KeyedLimiter, KnowledgeCasError, LARGE_VALUE_WARN_BYTES, LEGACY_LTID_PREFIX, LEGACY_SIGNATURE_INPUTS, LINEAGE_SIG_VERSION, LeaseHeldError, LineageIndex, MASKED_SECRET, MAX_CHILD_RESULT_PAGE_CHARS, MAX_DEPTH_CEILING, ModelRetry, NoProgressDetector, NonSerializableValueError, ORCHESTRATE_WORKFLOW_NAME, OrchestratorCapConfigError, PARALLEL_AGENTS_SCHEMA, ParallelSiteCounter, PlanInvariantError, READ_CHILD_ARTIFACT_SCHEMA, READ_CHILD_ARTIFACT_TOOL_NAME, ROLE_EFFORT_DEFAULTS, ROOT_ACCOUNT, ROOT_SCOPE, RUN_PROFILES, RUN_SETTLE_DECISION_TYPE, ReplayPlanHashMismatch, Replayer, ResolutionArbiter, ResolutionFold, RulvarError, RunBudget, SANDBOX_AGENT_OPT_KEYS, SPAWN_AGENT_SCHEMA, SandboxError, ScriptRejected, Semaphore, SpanRegistry, TOOL_NAME_PATTERN, TerminationAccount, WAIT_FOR_EVENTS_SCHEMA, WAIT_FOR_EVENTS_TOOL_NAME, WAKE_SUMMARY_RENDER_BUDGET_CHARS, admissionReserveUsd, affordableOutputTokens, agentErrorFromWire, agentErrorToWire, agentResultWire, agentScope, applyClaimOps, applyStructuredOutputTier, approachSigCoarse, approachSigOf, archiveDeprecatedModelOps, assertFencedWrites, atCompactionThreshold, auditRun, auditRuns, buildAbandonFold, buildAdapterRegistry, buildCostReport, buildDeriverRegistry, buildOrchestratorTools, buildTerminationInitValue, buildToolContext, canRideLoopTurn, canonicalIsolationTag, canonicalizeLadder, canonicalizeSchema, capIssues, capsHashOf, checkFloors, checkpointRefFor, childCoveragePrefix, claimExpired, claimExpiry, claimIssues, claimOpIssues, classifyAgentError, classifyAttemptOutcome, collectDeclaredLadders, compactMessages, compilePermissionChain, compilePermissionPreset, compileVerifiedLayer, costReportFromJournal, countsAgainstLimit, createCanonicalIdMinter, createCtx, createEngine, createSandboxBridge, currentOnlyKeyRing, decodeCheckpoint, defineWorkflow, deriveContentKey, deriverV1, deriverV2, digestOf, dispositionHook, emptyDigestBlocks, emptyToolset, encodeCheckpoint, entryUsageSlices, escalateTool, evaluatePermission, evaluateReuse, evidencePreservedValidator, executeWorkflow, exhaustionCodeOf, extractCandidate, failoverTriggerOf, fallbackTriggerOf, filterClaimsForRun, finalizeFires, foldTermination, formatRePrompt, formatScopePath, hasFencedWrites, hasMetaLookup, hashRunArgs, hashRunOutput, hashWorkflowBody, hashWorkflowSource, identityJcs, isEscalated, isSchemaPairSpec, isStandardSchemaSpec, isStrictCompatibleSchema, kMaxOf, knowledgeHash, ladderLengthOf, ladderRungChoice, lastRunSettle, lexShellCommand, liftRetainedParts, lineageWeightOf, makeOrchestratorWorkflow, maskSecrets, maskSecretsDeep, maskSecretsJson, matchArgvPattern, matchShellCommand, mcp, mergeUsageLimits, metaMatchesFilter, minMatchesValidator, modelEpochOf, modelKnowledgeCard, modelSpecIdentity, needsSeparateExtract, nextFailover, nodeLinkKey, normalizeApproachTag, normalizeEntry, normalizeFallbacks, orchestrate, parallelScope, parseModelRef, parseScopePath, phiInitialOf, pipelineScope, planNodeScope, priceEntryUsage, priceUsdOf, profileCard, profileRegistrySnapshotHash, projectHistory, projectIdentity, projectToJsonSchema, proposalStatement, providerOf, readRunMeta, readTerminationInit, reconcileRunMeta, reduceCriticalPath, reduceInvocationTable, registryKeyRing, remeasureQueue, replayDisposition, requiredFieldsValidator, requiredSectionsValidator, resolveModelInvocation, resolvePricing, resolveToolset, retryClassOf, retryDelayMs, roleConfiguredInRouting, roundOneDisposition, runAgent, runProfile, sanitizeTerminalText, sanitizeTokenCount, sanitizeUsage, sanitizeUsageDelta, scanJournalCompatibility, schemaHash, schemaHashOfSpec, selectStructuredOutputTier, shouldCompact, snapshotUsage, spawnDepthOf, summarizeInstruction, summarizeOutput, terminationConfigDrift, tierWithinCaps, toApprovalDecision, toJournalValue, tool, toolContract, toolsetHash, ttlState, usageViolations, validateEditorialCommit, validateEntryShape, validateEscalationLimits, validateEscalationReport, validateRetryPolicy, validateSchemaSpec, validateTerminationLimits, validateUsageLimits, workflowScope, workflowSourceRef, wrapJournalStore, wrapTranscriptStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.53.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",
|