@tangle-network/agent-runtime 0.266.0 → 0.273.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/{activation-BERiJjx5.js → activation-Cx2dKA_l.js} +2 -2
  2. package/dist/{activation-BERiJjx5.js.map → activation-Cx2dKA_l.js.map} +1 -1
  3. package/dist/{activation-VpxSbDKJ.d.ts → activation-IfDlhR3J.d.ts} +4 -4
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/candidate-execution/index.js +2 -2
  7. package/dist/{coordination-driver-DdZ-nh_4.js → coordination-driver-CkcW4dxU.js} +173 -92
  8. package/dist/coordination-driver-CkcW4dxU.js.map +1 -0
  9. package/dist/{delegate-Ajx_PVyu.js → delegate-Dvb1-mE-.js} +2 -2
  10. package/dist/{delegate-Ajx_PVyu.js.map → delegate-Dvb1-mE-.js.map} +1 -1
  11. package/dist/durable.d.ts +3 -571
  12. package/dist/durable.js +93 -19
  13. package/dist/durable.js.map +1 -1
  14. package/dist/{graph-CK50N9vG.js → graph-C69Uxtzt.js} +17 -8
  15. package/dist/graph-C69Uxtzt.js.map +1 -0
  16. package/dist/{improvement-cycle-GRPoHLm1.js → improvement-cycle-CO2HRCQq.js} +10 -10
  17. package/dist/improvement-cycle-CO2HRCQq.js.map +1 -0
  18. package/dist/{index-CU2mlMfc.d.ts → index-D2ipSqkP.d.ts} +4335 -3055
  19. package/dist/index.d.ts +7 -451
  20. package/dist/index.js +14 -11
  21. package/dist/index.js.map +1 -1
  22. package/dist/intelligence.d.ts +9 -3
  23. package/dist/intelligence.js +13 -7
  24. package/dist/intelligence.js.map +1 -1
  25. package/dist/kernel.d.ts +4 -4
  26. package/dist/kernel.js +9 -9
  27. package/dist/{loop-runner-bin-cC16EPUq.js → loop-runner-bin-B9MIq9O7.js} +3 -3
  28. package/dist/{loop-runner-bin-cC16EPUq.js.map → loop-runner-bin-B9MIq9O7.js.map} +1 -1
  29. package/dist/{loop-runner-bin-XKZXM08Q.d.ts → loop-runner-bin-ThlwVkvo.d.ts} +3 -3
  30. package/dist/loop-runner-bin.d.ts +1 -1
  31. package/dist/loop-runner-bin.js +1 -1
  32. package/dist/mcp/bin.js +3 -3
  33. package/dist/mcp/index.d.ts +12 -6
  34. package/dist/mcp/index.js +7 -7
  35. package/dist/mcp/memory-bin.js +1 -1
  36. package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
  37. package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
  38. package/dist/{openai-tools-D3ajI_D2.d.ts → openai-tools-Bb0mAr5z.d.ts} +2 -2
  39. package/dist/{prepare-oHUQdC5-.js → prepare-DVlvGP7V.js} +2 -2
  40. package/dist/{prepare-oHUQdC5-.js.map → prepare-DVlvGP7V.js.map} +1 -1
  41. package/dist/profiles.d.ts +2 -2
  42. package/dist/{protected-model-port-DqF0qDU6.js → protected-model-port-BrWgsCnl.js} +2 -2
  43. package/dist/{protected-model-port-DqF0qDU6.js.map → protected-model-port-BrWgsCnl.js.map} +1 -1
  44. package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-DylCC_ot.js} +14 -20
  45. package/dist/protected-redaction-DylCC_ot.js.map +1 -0
  46. package/dist/{provision-supervisor-Bf_bPaCv.js → provision-supervisor-BKAvsDtP.js} +3 -3
  47. package/dist/{provision-supervisor-Bf_bPaCv.js.map → provision-supervisor-BKAvsDtP.js.map} +1 -1
  48. package/dist/{runtime-hOLlAc1i.js → runtime-CHxXrUeZ.js} +1714 -854
  49. package/dist/runtime-CHxXrUeZ.js.map +1 -0
  50. package/dist/{server-DOb67ohd.js → server-2OeFrEVG.js} +4 -4
  51. package/dist/{server-DOb67ohd.js.map → server-2OeFrEVG.js.map} +1 -1
  52. package/dist/{stream-agent-turn-Gw9hLpBn.d.ts → stream-agent-turn-ewm3BZAp.d.ts} +34 -17
  53. package/dist/{structural-rollout-DV9YoQF6.js → structural-rollout-DCUprNpH.js} +2 -2
  54. package/dist/{structural-rollout-DV9YoQF6.js.map → structural-rollout-DCUprNpH.js.map} +1 -1
  55. package/dist/{substrate-CLt9S9ym.d.ts → substrate-VKjmrksz.d.ts} +2 -2
  56. package/dist/{supervise--njTtSL3.js → supervise-Dej5aSDa.js} +220 -52
  57. package/dist/supervise-Dej5aSDa.js.map +1 -0
  58. package/dist/{supervisor-B8UMAXya.js → supervisor-DdKPGluv.js} +1233 -303
  59. package/dist/supervisor-DdKPGluv.js.map +1 -0
  60. package/dist/testing.d.ts +2 -2
  61. package/dist/testing.js +62 -62
  62. package/dist/testing.js.map +1 -1
  63. package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
  64. package/dist/tool-server-Dqer2M4_.js.map +1 -0
  65. package/dist/tui/index.d.ts +1 -1
  66. package/dist/tui/index.js +1 -1
  67. package/dist/{types-CrnwLVYQ.d.ts → types-DMRc3jru.d.ts} +463 -105
  68. package/package.json +6 -5
  69. package/dist/coordination-driver-DdZ-nh_4.js.map +0 -1
  70. package/dist/graph-CK50N9vG.js.map +0 -1
  71. package/dist/improvement-cycle-GRPoHLm1.js.map +0 -1
  72. package/dist/protected-redaction--F3v1oo8.js.map +0 -1
  73. package/dist/runtime-hOLlAc1i.js.map +0 -1
  74. package/dist/supervise--njTtSL3.js.map +0 -1
  75. package/dist/supervisor-B8UMAXya.js.map +0 -1
  76. package/dist/tool-server-x9NEhvHZ.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { $t as padSpanId, Aa as OpenAIChatTool, Ar as AgentEvalErrorCode, Br as RuntimeRunStateError, Bt as OtelAttribute, Ca as AgentTaskContext, Da as BackendErrorDetail, Ea as AgentTaskStatus, Fa as RuntimeSession, Fr as PlannerError, Ft as EvalRunGeneration, Gt as buildLoopOtelSpans, Ht as OtelExporter, Ia as RuntimeSessionStore, Ir as RetainedInteractiveAdmissionError, It as EvalRunsExportConfig, Jt as createOpenInferenceFileExporter, Kt as buildLoopSpanNodes, La as RuntimeStreamEvent, Lr as RetainedInteractiveBindingError, Lt as EvalRunsExportResult, Ma as RunAgentTaskOptions, Mr as ConfigError, Na as RunAgentTaskStreamOptions, Nr as JudgeError, Oa as KnowledgeReadinessDecision, Pa as RuntimeCanonicalStreamEvent, Pr as NotFoundError, Pt as EvalRunEvent, Qt as loopEventToOtelSpan, Rr as RetainedRunAdmissionError, Rt as INTELLIGENCE_WIRE_VERSION, Sa as AgentRuntimeEventSink, Ta as AgentTaskSpec, Ut as OtelSpan, Vr as ValidationError, Vt as OtelExportConfig, Wt as RuntimeEventOtelOptions, Xt as exportEvalRuns, Yt as createOtelExporter, Zt as generateSpanId, _a as AgentBackendContext, an as RuntimeStreamEventSummary, ba as AgentKnowledgeProvider, ca as RuntimeRunCompleteInput, cn as SanitizedKnowledgeRequirement, da as RuntimeRunOptions, dn as sanitizeAgentRuntimeEvent, en as padTraceId, fa as RuntimeRunPersistenceAdapter, fn as sanitizeKnowledgeReadinessReport, g as ExecutorFactory, ga as AgentAdapter, ha as startRuntimeRun, i as Budget, in as RuntimeStreamEventSink, ja as OpenAIChatToolChoice, jr as BackendTransportError, ka as OpenAIChatResponseFormat, kr as AgentEvalError, la as RuntimeRunCost, ln as createRuntimeEventCollector, lt as SupervisedResult, ma as RuntimeRunStatus, nn as RuntimeEventCollector, on as RuntimeTelemetryOptions, pa as RuntimeRunRow, pn as sanitizeRuntimeStreamEvent, qt as buildRuntimeEventOtelSpans, rn as RuntimeStreamEventCollector, sn as SanitizedKnowledgeReadinessReport, tn as toOtelAttributes, ua as RuntimeRunHandle, un as createRuntimeStreamEventCollector, va as AgentBackendInput, wa as AgentTaskRunResult, xa as AgentRuntimeEvent, ya as AgentExecutionBackend, zr as RetainedRunDispatchBindingError, zt as LoopSpanNode } from "./types-CrnwLVYQ.js";
1
+ import { $a as RunAgentTaskOptions, $r as ConfigError, $t as loopEventToOtelSpan, Aa as RuntimeRunCost, Ba as AgentExecutionBackend, Bt as OtelAttribute, Fa as RuntimeRunStatus, Ft as EvalRunGeneration, Ga as AgentTaskRunResult, Gt as RuntimeEventOtelOptions, Ha as AgentRuntimeEvent, Ht as OtelExportStats, Ia as startRuntimeRun, It as EvalRunsExportConfig, Ja as BackendErrorDetail, Jt as buildRuntimeEventOtelSpans, Ka as AgentTaskSpec, Kt as buildLoopOtelSpans, La as AgentAdapter, Lt as EvalRunsExportResult, Ma as RuntimeRunOptions, Na as RuntimeRunPersistenceAdapter, Pa as RuntimeRunRow, Pt as EvalRunEvent, Qa as OpenAIChatToolChoice, Qr as BackendTransportError, Qt as generateSpanId, Ra as AgentBackendContext, Rt as INTELLIGENCE_WIRE_VERSION, Ua as AgentRuntimeEventSink, Ut as OtelExporter, Va as AgentKnowledgeProvider, Vt as OtelExportConfig, Wa as AgentTaskContext, Wt as OtelSpan, Xa as OpenAIChatResponseFormat, Xr as AgentEvalError, Xt as createOtelExporter, Ya as KnowledgeReadinessDecision, Yt as createOpenInferenceFileExporter, Za as OpenAIChatTool, Zr as AgentEvalErrorCode, Zt as exportEvalRuns, ai as RetainedRunAdmissionError, an as RuntimeStreamEventSink, ci as ValidationError, cn as SanitizedKnowledgeReadinessReport, dn as createRuntimeStreamEventCollector, ei as JudgeError, en as padSpanId, eo as RunAgentTaskStreamOptions, fn as sanitizeAgentRuntimeEvent, g as ExecutorFactory, i as Budget, ii as RetainedInteractiveBindingError, in as RuntimeStreamEventCollector, io as RuntimeStreamEvent, ja as RuntimeRunHandle, ka as RuntimeRunCompleteInput, ln as SanitizedKnowledgeRequirement, lt as SupervisedResult, mn as sanitizeRuntimeStreamEvent, ni as PlannerError, nn as toOtelAttributes, no as RuntimeSession, oi as RetainedRunDispatchBindingError, on as RuntimeStreamEventSummary, pn as sanitizeKnowledgeReadinessReport, qa as AgentTaskStatus, qt as buildLoopSpanNodes, ri as RetainedInteractiveAdmissionError, rn as RuntimeEventCollector, ro as RuntimeSessionStore, si as RuntimeRunStateError, sn as RuntimeTelemetryOptions, ti as NotFoundError, tn as padTraceId, to as RuntimeCanonicalStreamEvent, un as createRuntimeEventCollector, za as AgentBackendInput, zt as LoopSpanNode } from "./types-DMRc3jru.js";
2
2
  import { i as SurfaceImprovementEdit } from "./improvement-adapter-D5gwwoXQ.js";
3
3
  import { o as ImprovementProposalSource } from "./types-zWfqDjeL.js";
4
- import { Hp as DeliverableSpec, Xa as SuperviseOptions, nr as StructuralRolloutPolicy, wo as SupervisorProfile } from "./index-CU2mlMfc.js";
4
+ import { Ch as BackendCallPolicy, Eh as RetryableErrorPredicate, Km as DeliverableSpec, Nc as SuperviseOptions, Sh as TurnOrder, Th as RetryBackoff, _h as HaltContext, ah as ConversationJournal, bh as HaltSignal, ch as InMemoryConversationJournal, dh as ConversationDriveState, eh as D1DatabaseLike, fh as ConversationParticipant, gh as ConversationTurn, hh as ConversationStreamEvent, ih as d1ToSqlAdapter, lh as AuthSource, mh as ConversationResult, nh as SqlAdapter, nr as StructuralRolloutPolicy, oh as ConversationJournalEntry, ph as ConversationPolicy, rh as SqlConversationJournal, sh as FileConversationJournal, th as D1StmtLike, uh as Conversation, vh as HaltPredicate, wh as CircuitBreakerConfig, xh as RunConversationOptions, yh as HaltReason, yl as SupervisorProfile } from "./index-D2ipSqkP.js";
5
5
  import { a as RuntimeHookErrorContext, c as RuntimeHookTarget, d as defineRuntimeHooks, f as notifyRuntimeDecisionPoint, i as RuntimeHookContext, l as RuntimeHooks, n as RuntimeDecisionKind, o as RuntimeHookEvent, p as notifyRuntimeHookEvent, r as RuntimeDecisionPoint, s as RuntimeHookPhase, t as RuntimeDecisionEvidenceRef, u as composeRuntimeHooks } from "./runtime-hooks-Bj6wJHlH.js";
6
- import { f as ExecutorConfig, hr as Redactor, mn as WorktreeCheckRunner } from "./stream-agent-turn-Gw9hLpBn.js";
6
+ import { f as ExecutorConfig, gr as Redactor, mn as WorktreeCheckRunner } from "./stream-agent-turn-ewm3BZAp.js";
7
7
  import { y as AgentCandidateOutputArtifactPort } from "./types-CuXu5zuS.js";
8
- import { $ as ImprovementMaterializedProfilePopulationCandidate, A as ImproveCodeResult, B as ImproveMethodSource, C as TrainingBoundaryResult, Ct as CandidateGenerator, D as ImproveCandidateValidator, E as ImproveCandidateValidationInput, F as ImproveMethodContext, G as ImproveProfileSurface, H as ImproveOptions, I as ImproveMethodFactory, J as ImproveScenarioPartitions, K as ImproveResult, L as ImproveMethodLineage, M as ImproveCost, N as ImproveCustomCodeGeneratorOptions, O as ImproveCodeBaseOptions, P as ImproveLineage, Q as ImprovementCodeCandidate, R as ImproveMethodOptions, S as ProfileTrainerRequest, St as defaultBuildPrompt, T as createCommandProfileTrainer, U as ImproveProfileAgent, V as ImproveOptimizationRunOptions, W as ImproveProfileComponents, X as ImproveSurface, Y as ImproveSkillsOptions, Z as ImprovementCandidate, _ as CheckpointServingPort, _t as AgenticGeneratorShotReceipt, at as ImprovementProfilePopulationCandidate, b as ImproveTrainingResult, bt as agenticGenerator, ct as ImprovementProfilePopulationLineageNode, dt as DeepReadonly, et as ImprovementProfileCandidate, ft as ReadonlyAgentProfile, g as improve, gt as AgenticGeneratorShotExecution, ht as AgenticGeneratorShotDisposition, i as AgentImprovementActivationTransition, it as ImprovementProfilePopulationArtifactSource, j as ImproveCodeRunOptions, k as ImproveCodeOptions, lt as ImprovementProfilePopulationObservationSource, mt as AgenticGeneratorOptions, n as AgentImprovementActivationResultStore, nt as ImprovementProfileCandidatePopulationAvailable, ot as ImprovementProfilePopulationCandidateSource, pt as AgenticGeneratorExecutorForWorktree, q as ImproveRuntimeCodeGeneratorOptions, rt as ImprovementProfileCandidatePopulationUnavailable, st as ImprovementProfilePopulationLineage, t as AgentImprovementActivationReconciliation, tt as ImprovementProfileCandidatePopulation, ut as ImprovementRefusedProfilePopulationCandidate, v as ControlledTrainingCommand, vt as Verifier, w as TrainingDatasetDocument, x as ProfileTrainer, xt as commandVerifier, y as ImproveTrainingOptions, yt as VerifyResult, z as ImproveMethodResult } from "./activation-VpxSbDKJ.js";
9
- import { _ as researchLoopRunner, a as DELEGATED_LOOP_MODES, c as DelegatedLoopResult, d as ResearchLoopRunnerOptions, f as RunDelegatedLoopOptions, g as isDelegatedLoopMode, h as auditLoopRunner, i as runLoopRunnerCli, l as DelegatedLoopRunner, m as WorktreeLoopRunnerOptions, n as LoopRunnerCliResult, o as DelegatedLoopMode, p as VetoedFact, r as parseLoopRunnerArgv, s as DelegatedLoopRegistry, t as LoopRunnerCliArgs, u as ResearchLoopResult, v as runDelegatedLoop, y as worktreeLoopRunner } from "./loop-runner-bin-XKZXM08Q.js";
10
- import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-D3ajI_D2.js";
8
+ import { $ as ImprovementMaterializedProfilePopulationCandidate, A as ImproveCodeResult, B as ImproveMethodSource, C as TrainingBoundaryResult, Ct as CandidateGenerator, D as ImproveCandidateValidator, E as ImproveCandidateValidationInput, F as ImproveMethodContext, G as ImproveProfileSurface, H as ImproveOptions, I as ImproveMethodFactory, J as ImproveScenarioPartitions, K as ImproveResult, L as ImproveMethodLineage, M as ImproveCost, N as ImproveCustomCodeGeneratorOptions, O as ImproveCodeBaseOptions, P as ImproveLineage, Q as ImprovementCodeCandidate, R as ImproveMethodOptions, S as ProfileTrainerRequest, St as defaultBuildPrompt, T as createCommandProfileTrainer, U as ImproveProfileAgent, V as ImproveOptimizationRunOptions, W as ImproveProfileComponents, X as ImproveSurface, Y as ImproveSkillsOptions, Z as ImprovementCandidate, _ as CheckpointServingPort, _t as AgenticGeneratorShotReceipt, at as ImprovementProfilePopulationCandidate, b as ImproveTrainingResult, bt as agenticGenerator, ct as ImprovementProfilePopulationLineageNode, dt as DeepReadonly, et as ImprovementProfileCandidate, ft as ReadonlyAgentProfile, g as improve, gt as AgenticGeneratorShotExecution, ht as AgenticGeneratorShotDisposition, i as AgentImprovementActivationTransition, it as ImprovementProfilePopulationArtifactSource, j as ImproveCodeRunOptions, k as ImproveCodeOptions, lt as ImprovementProfilePopulationObservationSource, mt as AgenticGeneratorOptions, n as AgentImprovementActivationResultStore, nt as ImprovementProfileCandidatePopulationAvailable, ot as ImprovementProfilePopulationCandidateSource, pt as AgenticGeneratorExecutorForWorktree, q as ImproveRuntimeCodeGeneratorOptions, rt as ImprovementProfileCandidatePopulationUnavailable, st as ImprovementProfilePopulationLineage, t as AgentImprovementActivationReconciliation, tt as ImprovementProfileCandidatePopulation, ut as ImprovementRefusedProfilePopulationCandidate, v as ControlledTrainingCommand, vt as Verifier, w as TrainingDatasetDocument, x as ProfileTrainer, xt as commandVerifier, y as ImproveTrainingOptions, yt as VerifyResult, z as ImproveMethodResult } from "./activation-IfDlhR3J.js";
9
+ import { _ as researchLoopRunner, a as DELEGATED_LOOP_MODES, c as DelegatedLoopResult, d as ResearchLoopRunnerOptions, f as RunDelegatedLoopOptions, g as isDelegatedLoopMode, h as auditLoopRunner, i as runLoopRunnerCli, l as DelegatedLoopRunner, m as WorktreeLoopRunnerOptions, n as LoopRunnerCliResult, o as DelegatedLoopMode, p as VetoedFact, r as parseLoopRunnerArgv, s as DelegatedLoopRegistry, t as LoopRunnerCliArgs, u as ResearchLoopResult, v as runDelegatedLoop, y as worktreeLoopRunner } from "./loop-runner-bin-ThlwVkvo.js";
10
+ import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-Bb0mAr5z.js";
11
11
  import { AgentCandidateBundle, AgentCandidateCapturedArtifact, AgentCandidateKnowledge, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
12
12
  import { AgentProfile as AgentProfile$1, ControlBudget, ControlDecision, ControlEvalResult, ControlEvalResult as ControlEvalResult$1, ControlRunResult, ControlStep, DataAcquisitionPlan, KnowledgeReadinessReport, KnowledgeReadinessReport as KnowledgeReadinessReport$1, KnowledgeRequirement, MaximumCharge, ProposalFinding, RunRecord, RunRecord as RunRecord$1 } from "@tangle-network/agent-eval";
13
13
  import { GepaOptimizationMethodConfig, ProfileDispatchFn, Scenario, SkillOptOptimizationMethodConfig } from "@tangle-network/agent-eval/campaign";
@@ -48,386 +48,6 @@ declare function createProfileExecutionBackend(options: {
48
48
  executor: ExecutorFactory<unknown>;
49
49
  }): AgentExecutionBackend;
50
50
  //#endregion
51
- //#region src/conversation/call-policy.d.ts
52
- /**
53
- *
54
- * Per-call resilience policy for participant backends: deadline, retry with
55
- * backoff, and a circuit breaker. Each policy is applied *around* a single
56
- * turn's backend invocation, not across the whole conversation — the
57
- * conversation-level credit cap and `maxTurns` bound the broader run.
58
- *
59
- * Deadlines abort the underlying backend stream via `AbortSignal` linkage so
60
- * the OpenAI/SDK clients tear down their HTTP request cleanly instead of
61
- * leaking sockets. Retries replay the same logical turn (same `turnId`) so
62
- * any caching gateway can dedupe. Circuit breakers are *per participant*: A's
63
- * failures don't open B's breaker.
64
- *
65
- * @stable
66
- */
67
- /** Pure judgment of whether an error is worth retrying. Defaults: TimeoutError, AbortError, fetch-level network errors. */
68
- type RetryableErrorPredicate = (err: unknown) => boolean;
69
- /** Backoff between attempts. Constant ms, or `(attempt: 1-indexed) => ms`. */
70
- type RetryBackoff = number | ((attempt: number) => number);
71
- /** Circuit-breaker tuning. `failuresToOpen` consecutive failures opens it; closed only after `cooldownMs`. */
72
- interface CircuitBreakerConfig {
73
- failuresToOpen: number;
74
- cooldownMs: number;
75
- }
76
- interface BackendCallPolicy {
77
- /** Per-attempt wall clock limit. Exceeding fires an AbortSignal and is treated as a retryable failure. */
78
- perAttemptDeadlineMs?: number;
79
- /** Number of retries after the first attempt; total attempts = 1 + maxRetries. Default 0. */
80
- maxRetries?: number;
81
- /** Backoff between attempts. Default 250ms with jitter. */
82
- retryBackoffMs?: RetryBackoff;
83
- /** Custom retry classifier. Defaults to retrying transport failures and retryable HTTP statuses. */
84
- isRetryable?: RetryableErrorPredicate;
85
- /** Circuit breaker that opens after N consecutive failures per participant. */
86
- circuitBreaker?: CircuitBreakerConfig;
87
- }
88
- //#endregion
89
- //#region src/conversation/headers.d.ts
90
- /**
91
- * Header bag carried through `AgentBackendContext.propagatedHeaders` so
92
- * backends that opt in can merge them into their outbound HTTP requests.
93
- * Distinct from `buildForwardHeaders` so callers can attach extra
94
- * non-protocol headers (e.g. tracing) without colliding.
95
- */
96
- type PropagatedHeaders = Readonly<Record<string, string>>;
97
- //#endregion
98
- //#region src/conversation/journal.d.ts
99
- interface ConversationJournalEntry {
100
- runId: string;
101
- startedAt: string;
102
- /** Set when the run reaches a terminal state. */
103
- halted?: HaltReason;
104
- endedAt?: string;
105
- turns: ConversationTurn[];
106
- }
107
- interface ConversationJournal {
108
- /**
109
- * Load any prior state for `runId`. Returns `undefined` for a fresh run.
110
- * Implementations MUST NOT mutate the returned object — the runner clones
111
- * before continuing — but the runtime treats absence and emptiness
112
- * identically, so a journal with zero turns is equivalent to "fresh."
113
- */
114
- loadRun(runId: string): Promise<ConversationJournalEntry | undefined>;
115
- /**
116
- * Initialise journal state for a fresh run. Called once per run, before any
117
- * `appendTurn`. Idempotent: calling with an existing runId is a no-op if
118
- * the entry already exists with the same `startedAt`.
119
- */
120
- beginRun(runId: string, startedAt: string): Promise<void>;
121
- /**
122
- * Append a committed turn. The runner only calls this AFTER the turn's
123
- * backend stream completed and the credit total has been updated, so an
124
- * appended turn is observed-committed and never speculative.
125
- */
126
- appendTurn(runId: string, turn: ConversationTurn): Promise<void>;
127
- /**
128
- * Record the run's terminal halt reason + end time. Once called, the run
129
- * is observed-final; subsequent `loadRun` returns the same halt.
130
- */
131
- recordHalt(runId: string, halt: HaltReason, endedAt: string): Promise<void>;
132
- }
133
- /** In-memory `ConversationJournal` — suitable for testing and single-process runs. */
134
- declare class InMemoryConversationJournal implements ConversationJournal {
135
- private readonly entries;
136
- loadRun(runId: string): Promise<ConversationJournalEntry | undefined>;
137
- beginRun(runId: string, startedAt: string): Promise<void>;
138
- appendTurn(runId: string, turn: ConversationTurn): Promise<void>;
139
- recordHalt(runId: string, halt: HaltReason, endedAt: string): Promise<void>;
140
- }
141
- /**
142
- * JSONL on disk. One line per record; first line is the `begin`, subsequent
143
- * lines are `turn` records, terminal line is `halt`. Replays the whole file
144
- * on `loadRun` — cheap for the conversation sizes this is designed for
145
- * (thousands of turns, not millions). For huge runs, plug in a real DB
146
- * adapter; the interface is small.
147
- *
148
- * Reads and appends over the shared append-only spine (`durable/jsonl-file`): each
149
- * `appendTurn` / `recordHalt` finishes a short write and calls `fsync`, so a process
150
- * crash between writes never loses an acknowledged turn, and a crash DURING one leaves
151
- * an uncommitted final line that the next read skips and the next append truncates.
152
- */
153
- declare class FileConversationJournal implements ConversationJournal {
154
- private readonly path;
155
- constructor(path: string);
156
- loadRun(runId: string): Promise<ConversationJournalEntry | undefined>;
157
- beginRun(runId: string, startedAt: string): Promise<void>;
158
- appendTurn(runId: string, turn: ConversationTurn): Promise<void>;
159
- recordHalt(runId: string, halt: HaltReason, endedAt: string): Promise<void>;
160
- private appendRecord;
161
- }
162
- //#endregion
163
- //#region src/conversation/types.d.ts
164
- /** @stable */
165
- interface ConversationParticipant {
166
- /**
167
- * Stable name used as the speaker label in the transcript. Must be unique
168
- * within a `Conversation`.
169
- */
170
- name: string;
171
- /**
172
- * Backend that runs this participant's turn. Reuses the existing
173
- * `AgentExecutionBackend` contract from `runAgentTaskStream`, so an iterable,
174
- * sandbox, or profile-backed Runtime executor works through the same runner.
175
- */
176
- backend: AgentExecutionBackend;
177
- /**
178
- * Optional human label for traces / dashboards. Distinct from `name`, which
179
- * is the addressing key.
180
- */
181
- label?: string;
182
- /**
183
- * Optional per-participant override of the conversation's default
184
- * `callPolicy`. Use to tighten the deadline or raise the retry budget for
185
- * a participant known to be slow or flaky.
186
- */
187
- callPolicy?: BackendCallPolicy;
188
- /**
189
- * Who pays for THIS participant's outbound calls?
190
- *
191
- * - `'forward-user'` (default) — propagate the caller's
192
- * `X-Tangle-Forwarded-Authorization` so the downstream gateway bills the
193
- * original user. Right for pass-through agents that aggregate/route
194
- * without taking economic risk.
195
- * - `'agent-owned'` — DO NOT forward the user's auth; the participant's
196
- * backend uses its own credentials (typically a sk-tan-AGENT or x402
197
- * wallet baked into the backend at construction). Downstream charges
198
- * land on the agent, not the user. Right for resold-bundle agents that
199
- * take margin between their inbound price and their sub-agent costs.
200
- * - `(state) => AuthSource` — per-turn / per-condition decision, e.g. base
201
- * sub-services are agent-owned but premium add-ons forward the user.
202
- *
203
- * The agent's own credentials live on its caller-owned backend or
204
- * profile-bound Runtime executor; this field is purely about *whether to
205
- * also forward the user's identity downstream*.
206
- */
207
- authSource?: AuthSource;
208
- }
209
- /** @stable */
210
- type AuthSource = 'forward-user' | 'agent-owned' | ((state: ConversationDriveState) => 'forward-user' | 'agent-owned');
211
- /** @stable */
212
- type TurnOrder = 'alternate' | 'round-robin' | ((state: ConversationDriveState) => number);
213
- /** @stable */
214
- interface ConversationDriveState {
215
- transcript: readonly ConversationTurn[];
216
- turnIndex: number;
217
- spentCreditsCents: number;
218
- }
219
- /** @stable */
220
- interface HaltContext extends ConversationDriveState {
221
- lastTurn: ConversationTurn;
222
- }
223
- /** @stable */
224
- interface HaltSignal {
225
- halted: true;
226
- reason: string;
227
- }
228
- /** @stable */
229
- type HaltPredicate = (ctx: HaltContext) => boolean | HaltSignal | Promise<boolean | HaltSignal>;
230
- /** @stable */
231
- type HaltReason = {
232
- kind: 'max_turns';
233
- turns: number;
234
- } | {
235
- kind: 'max_credits';
236
- spentCents: number;
237
- capCents: number;
238
- } | {
239
- kind: 'predicate';
240
- reason: string;
241
- } | {
242
- kind: 'abort';
243
- } | {
244
- kind: 'participant_error';
245
- participant: string;
246
- message: string;
247
- };
248
- /** @stable */
249
- interface ConversationPolicy {
250
- /** Hard cap on speaker-turns. Each call into a participant's backend counts as 1. */
251
- maxTurns: number;
252
- /**
253
- * Hard cap on aggregate credit spend across all participants, in cents.
254
- * Computed by summing `llm_call.costUsd` from every participant's stream.
255
- * Unset (`undefined`) means no credit ceiling — the run is bounded only by
256
- * `maxTurns` and `haltOn`.
257
- */
258
- maxCreditsCents?: number;
259
- /**
260
- * Speaker selection. Defaults to `'alternate'` for two-participant
261
- * conversations and `'round-robin'` for any other arity.
262
- */
263
- turnOrder?: TurnOrder;
264
- /**
265
- * Optional convergence / content-based halt. Called after every turn ends;
266
- * returning truthy stops the loop with `{ kind: 'predicate', ... }`.
267
- */
268
- haltOn?: HaltPredicate;
269
- /**
270
- * Default per-turn resilience policy applied to every participant call
271
- * (deadline, retries, circuit breaker). Individual participants may
272
- * override via `ConversationParticipant.callPolicy`.
273
- */
274
- defaultCallPolicy?: BackendCallPolicy;
275
- }
276
- /** @stable */
277
- interface ConversationTurn {
278
- index: number;
279
- speaker: string;
280
- /**
281
- * Deterministic turn identifier — stable across retries of the same logical
282
- * turn so caching gateways and trace backends can dedupe. Shape:
283
- * `${runId}.t${index}.${speakerSlug}`.
284
- */
285
- turnId: string;
286
- /** Backend session used for this turn. Present on turns recorded by session-aware runners. */
287
- sessionId?: string;
288
- text: string;
289
- /**
290
- * Aggregated backend usage for this turn alone. Populated from any
291
- * `llm_call` stream events the backend emitted; `undefined` when the
292
- * backend reports no usage.
293
- */
294
- usage?: {
295
- tokensIn?: number;
296
- tokensOut?: number;
297
- costUsd?: number;
298
- latencyMs?: number;
299
- model?: string;
300
- };
301
- /**
302
- * Number of attempts that ran before this turn committed. `1` is the
303
- * common case; higher means the call policy retried after transient
304
- * failures.
305
- */
306
- attempts: number;
307
- startedAt: string;
308
- endedAt: string;
309
- }
310
- /** @stable */
311
- interface Conversation {
312
- participants: readonly ConversationParticipant[];
313
- policy: ConversationPolicy;
314
- }
315
- /** @stable */
316
- interface RunConversationOptions {
317
- /** First message kicking off the conversation. Routes to the first speaker. */
318
- seed: string;
319
- /**
320
- * Optional run identifier for cross-participant trace correlation. Auto-
321
- * generated when omitted. Reusing a runId against the same `journal`
322
- * resumes the prior run — the runner replays the persisted transcript and
323
- * continues from the first un-recorded turn.
324
- */
325
- runId?: string;
326
- /** Cancellation signal — aborts mid-stream and halts with `{ kind: 'abort' }`. */
327
- signal?: AbortSignal;
328
- /**
329
- * Event sink for per-turn micro-events. Distinct from the result transcript:
330
- * the sink fires for every text-delta, every turn-start/end, and the
331
- * conversation-start/end markers. Used to drive SSE / dashboard updates
332
- * without waiting for the conversation to finish.
333
- */
334
- onEvent?: (event: ConversationStreamEvent) => void | Promise<void>;
335
- /**
336
- * Optional durable transcript. When set, the runner persists every
337
- * committed turn before yielding `turn_end`. Reusing the same `runId`
338
- * against the same journal resumes from the last committed turn — so a
339
- * driver process crash mid-run loses zero acknowledged turns.
340
- */
341
- journal?: ConversationJournal;
342
- /**
343
- * Stores each participant's backend session. The runner keeps an in-memory
344
- * store for one invocation when omitted. Reuse a durable store with the same
345
- * `runId` and journal after a process restart. Backends implementing `resume`
346
- * continue their provider session; other backends receive the full transcript.
347
- */
348
- sessionStore?: RuntimeSessionStore;
349
- /**
350
- * Headers to forward verbatim to every participant backend call (gateway
351
- * propagation: `X-Tangle-Forwarded-Authorization`, run/turn correlation,
352
- * depth counter). Backends opt in by reading `propagatedHeaders` from
353
- * their `AgentBackendContext`; backends that ignore the field still work.
354
- */
355
- propagatedHeaders?: PropagatedHeaders;
356
- /**
357
- * Inbound depth at the point this driver was invoked. The runner
358
- * increments it on every outbound participant call; gateways refuse at
359
- * `DEFAULT_MAX_DEPTH`. Default 0 (origin caller).
360
- */
361
- inboundDepth?: number;
362
- /**
363
- * Parent turn id when this conversation is *inside* another turn (i.e. the
364
- * driver is itself a participant via `createConversationBackend`). The
365
- * runner stamps each outbound call with this as `X-Tangle-Parent-TurnId`
366
- * so trace stitching survives nested orchestration.
367
- */
368
- parentTurnId?: string;
369
- }
370
- /** @stable */
371
- interface ConversationResult {
372
- runId: string;
373
- transcript: ConversationTurn[];
374
- turns: number;
375
- spentCreditsCents: number;
376
- halted: HaltReason;
377
- durationMs: number;
378
- startedAt: string;
379
- endedAt: string;
380
- }
381
- /** @stable */
382
- type ConversationStreamEvent = {
383
- type: 'conversation_start';
384
- runId: string;
385
- participants: readonly string[];
386
- seed: string;
387
- timestamp: string;
388
- } | {
389
- type: 'conversation_resumed';
390
- runId: string;
391
- participants: readonly string[];
392
- transcript: readonly ConversationTurn[];
393
- timestamp: string;
394
- } | {
395
- type: 'turn_start';
396
- runId: string;
397
- index: number;
398
- speaker: string;
399
- turnId: string;
400
- attempt: number;
401
- timestamp: string;
402
- } | {
403
- type: 'turn_text_delta';
404
- runId: string;
405
- index: number;
406
- speaker: string;
407
- turnId: string;
408
- text: string;
409
- timestamp?: string;
410
- } | {
411
- type: 'turn_retry';
412
- runId: string;
413
- index: number;
414
- speaker: string;
415
- turnId: string;
416
- attempt: number;
417
- reason: string;
418
- timestamp: string;
419
- } | {
420
- type: 'turn_end';
421
- runId: string;
422
- turn: ConversationTurn;
423
- timestamp: string;
424
- } | {
425
- type: 'conversation_end';
426
- runId: string;
427
- result: ConversationResult;
428
- timestamp: string;
429
- };
430
- //#endregion
431
51
  //#region src/conversation/conversation-backend.d.ts
432
52
  /** Adapt a multi-participant conversation into the standard execution backend contract. */
433
53
  declare function createConversationBackend(options: {
@@ -443,70 +63,6 @@ declare function defineConversation(input: {
443
63
  policy: ConversationPolicy;
444
64
  }): Conversation;
445
65
  //#endregion
446
- //#region src/conversation/journal-sql.d.ts
447
- /**
448
- * Minimal SQL driver shape. Implementations forward to whichever client the
449
- * deployment already uses; agent-runtime takes no opinion on which.
450
- *
451
- * Parameter placeholders MUST be `?` (positional). All adapters listed in the
452
- * file header accept this convention.
453
- */
454
- interface SqlAdapter {
455
- /** Execute a write statement (INSERT/UPDATE/DELETE/DDL). */
456
- exec(sql: string, params?: readonly unknown[]): Promise<{
457
- rowsAffected: number;
458
- }>;
459
- /** Execute a read statement (SELECT). Returns rows as plain objects. */
460
- query<TRow = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<TRow[]>;
461
- }
462
- /**
463
- * Adapt a Cloudflare D1 binding to the SqlAdapter shape. Lives here so D1
464
- * consumers don't have to write the wrapper themselves; the runtime never
465
- * imports `@cloudflare/workers-types` directly (peer-style typing).
466
- */
467
- declare function d1ToSqlAdapter(db: D1DatabaseLike): SqlAdapter;
468
- /**
469
- * Structural type matching the surface of `D1Database` we depend on, so the
470
- * SDK never imports `@cloudflare/workers-types`. Consumers pass their real
471
- * `D1Database` from `env.DB` and TS structural compatibility lines it up.
472
- */
473
- interface D1DatabaseLike {
474
- prepare(sql: string): D1StmtLike;
475
- }
476
- interface D1StmtLike {
477
- bind(...params: unknown[]): D1StmtLike;
478
- run(): Promise<unknown>;
479
- all<TRow = unknown>(): Promise<{
480
- results?: TRow[];
481
- }>;
482
- }
483
- /**
484
- * SQL-backed ConversationJournal. Two tables — runs (one row per runId, holds
485
- * start/halt timestamps + halt reason) and turns (one row per committed turn,
486
- * payload is the ConversationTurn JSON). Replays the turns table on
487
- * `loadRun` and writes append-only per `appendTurn`.
488
- */
489
- declare class SqlConversationJournal implements ConversationJournal {
490
- private readonly db;
491
- private readonly table;
492
- /**
493
- * @param db SQL adapter (D1, postgres, sqlite, libSQL — all work)
494
- * @param table Table-name prefix; the journal creates `${table}_runs` and
495
- * `${table}_turns`. Lets multiple journals share a database
496
- * without colliding (e.g. one per product surface).
497
- */
498
- constructor(db: SqlAdapter, table?: string);
499
- /**
500
- * Create the journal's tables if absent. Idempotent. Call once at deploy
501
- * (or at app boot) — running on every request is harmless but adds latency.
502
- */
503
- migrate(): Promise<void>;
504
- loadRun(runId: string): Promise<ConversationJournalEntry | undefined>;
505
- beginRun(runId: string, startedAt: string): Promise<void>;
506
- appendTurn(runId: string, turn: ConversationTurn): Promise<void>;
507
- recordHalt(runId: string, halt: HaltReason, endedAt: string): Promise<void>;
508
- }
509
- //#endregion
510
66
  //#region src/conversation/run-conversation.d.ts
511
67
  /** Run a conversation to completion and return its terminal result. */
512
68
  declare function runConversation(conversation: Conversation, options: RunConversationOptions): Promise<ConversationResult>;
@@ -1109,5 +665,5 @@ declare function readinessServerSentEvent(report: KnowledgeReadinessReport$1, op
1109
665
  /** Serialize a `RuntimeStreamEvent` as a Server-Sent Event string. @stable */
1110
666
  declare function runtimeStreamServerSentEvent(event: RuntimeStreamEvent, options?: RuntimeTelemetryOptions & ServerSentEventOptions): string;
1111
667
  //#endregion
1112
- export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, AgentEvalError, type AgentEvalErrorCode, type AgentExecutionBackend, type AgentKnowledgeProvider, type AgentKnowledgeReadinessCheckOptions, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskSpec, type AgentTaskStatus, type AgenticGeneratorExecutorForWorktree, type AgenticGeneratorOptions, type AgenticGeneratorShotDisposition, type AgenticGeneratorShotExecution, type AgenticGeneratorShotReceipt, type AuthSource, type BackendCallPolicy, type BackendErrorDetail, BackendTransportError, type BuildPromptFindingsInput, type CandidateGenerator, type ChatModelCandidate, type ChatModelValidation, type CheckpointServingPort, type CircuitBreakerConfig, ConfigError, type ControlBudget, type ControlDecision, type ControlEvalResult, type ControlRunResult, type ControlStep, type ControlledTrainingCommand, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type CreateKnowledgeImprovementActivationExecutorOptions, type CreateProfileImprovementHarnessOptions, type D1DatabaseLike, type D1StmtLike, DEFAULT_ROUTER_BASE_URL, DELEGATED_LOOP_MODES, type DataAcquisitionPlan, type DeepReadonly, type DelegatedLoopMode, type DelegatedLoopRegistry, type DelegatedLoopResult, type DelegatedLoopRunner, type EvalRunEvent, type EvalRunGeneration, type EvalRunsExportConfig, type EvalRunsExportResult, FileConversationJournal, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, INTELLIGENCE_WIRE_VERSION, type ImproveCandidateValidationInput, type ImproveCandidateValidator, type ImproveCodeBaseOptions, type ImproveCodeOptions, type ImproveCodeResult, type ImproveCodeRunOptions, type ImproveCost, type ImproveCustomCodeGeneratorOptions, type ImproveLineage, type ImproveMethodContext, type ImproveMethodFactory, type ImproveMethodLineage, type ImproveMethodOptions, type ImproveMethodResult, type ImproveMethodSource, type ImproveOptimizationRunOptions, type ImproveOptions, type ImproveProfileAgent, type ImproveProfileComponents, type ImproveProfileSurface, type ImproveResult, type ImproveRuntimeCodeGeneratorOptions, type ImproveScenarioPartitions, type ImproveSkillsOptions, type ImproveSurface, type ImproveTrainingOptions, type ImproveTrainingResult, type ImprovementCandidate, type ImprovementCodeCandidate, type ImprovementMaterializedProfilePopulationCandidate, type ImprovementProfileCandidate, type ImprovementProfileCandidatePopulation, type ImprovementProfileCandidatePopulationAvailable, type ImprovementProfileCandidatePopulationUnavailable, type ImprovementProfilePopulationArtifactSource, type ImprovementProfilePopulationCandidate, type ImprovementProfilePopulationCandidateSource, type ImprovementProfilePopulationLineage, type ImprovementProfilePopulationLineageNode, type ImprovementProfilePopulationObservationSource, type ImprovementRefusedProfilePopulationCandidate, InMemoryConversationJournal, InMemoryRuntimeSessionStore, JudgeError, type KnowledgeImprovementActivationExecutor, type KnowledgeImprovementCandidatePair, type KnowledgeImprovementExperimentBundles, type KnowledgeImprovementJobMeasurement, type KnowledgeImprovementJobResult, type KnowledgeReadinessCheck, type KnowledgeReadinessCheckInput, type KnowledgeReadinessCheckResult, type KnowledgeReadinessDecision, type KnowledgeReadinessReport, type KnowledgeRequirement, type LoopRunnerCliArgs, type LoopRunnerCliResult, type LoopSpanNode, type McpServeSpec, type ModelInfo, NotFoundError, type OfficialGepaOptions, type OfficialOptimizerContextOptions, OfficialOptimizerUnavailableError, type OfficialSensitiveCandidateInput, type OfficialSkillOptOptions, type OpenAIChatResponseFormat, type OpenAIChatTool, type OpenAIChatToolChoice, type OtelAttribute, type OtelExportConfig, type OtelExporter, type OtelSpan, PROMPT_INSTRUCTION_COMPONENT_PREFIX, type PersonaConversationResult, type PersonaDriver, PlannerError, type ProfileImprovementHarness, type ProfileImprovementHarnessRunOptions, type ProfileImprovementHarnessTrainOptions, type ProfileTrainer, type ProfileTrainerRequest, RESEARCH_SUPERVISOR_SYSTEM_PROMPT, ROLLOUT_POLICY_EXTENSION, type RawTraceDistillerOptions, type ReadonlyAgentProfile, type ReflectiveGeneratorOptions, type ResearchLoopResult, type ResearchLoopRunnerOptions, type ResolvedChatModel, RetainedInteractiveAdmissionError, RetainedInteractiveBindingError, RetainedRunAdmissionError, RetainedRunDispatchBindingError, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunConversationOptions, type RunDelegatedLoopOptions, type RunKnowledgeImprovementJobOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunRecord, type RuntimeCanonicalStreamEvent, type RuntimeDecisionEvidenceRef, type RuntimeDecisionKind, type RuntimeDecisionPoint, type RuntimeEventCollector, type RuntimeEventOtelOptions, type RuntimeHookContext, type RuntimeHookErrorContext, type RuntimeHookEvent, type RuntimeHookPhase, type RuntimeHookTarget, type RuntimeHooks, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, type SqlAdapter, SqlConversationJournal, type SupervisedKnowledgeUpdateInput, type SupervisedKnowledgeUpdateOptions, type SupervisedKnowledgeUpdateResult, type SupervisedKnowledgeUpdater, type TrainingBoundaryResult, type TrainingDatasetDocument, type TurnOrder, ValidationError, type Verifier, type VerifyResult, type VetoedFact, type WorktreeCheckRunner, type WorktreeLoopRunnerOptions, agenticGenerator, applyRolloutPolicyToProfile, applyRunRecordDefaults, auditLoopRunner, buildKnowledgeImprovementExperimentBundles, buildLoopOtelSpans, buildLoopSpanNodes, buildRuntimeEventOtelSpans, cleanModelId, commandVerifier, composeRuntimeHooks, createAgentKnowledgeReadinessCheck, createCommandProfileTrainer, createConversationBackend, createIterableBackend, createKnowledgeImprovementActivationExecutor, createOpenInferenceFileExporter, createOtelExporter, createProfileExecutionBackend, createProfileImprovementHarness, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createSupervisedKnowledgeUpdater, d1ToSqlAdapter, decideKnowledgeReadiness, defaultBuildPrompt, defineConversation, defineRuntimeHooks, exportEvalRuns, findingLines, formatSupervisedKnowledgeTask, generateSpanId, getModels, improve, isDelegatedLoopMode, knowledgeReadinessDeliverable, loopEventToOtelSpan, mcpBuildPrompt, mcpServeVerifier, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, normalizeRolloutPolicy, notifyRuntimeDecisionPoint, notifyRuntimeHookEvent, officialGepa, officialSkillOpt, optimizerMethod, padSpanId, padTraceId, parseLoopRunnerArgv, parseRolloutPolicy, promptInstructionsProfileComponents, rawTraceDistiller, readinessServerSentEvent, reflectiveGenerator, researchLoopRunner, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runDelegatedLoop, runKnowledgeImprovementJob, runLoopRunnerCli, runPersonaConversation, runPersonaDispatch, runSupervisedKnowledgeUpdate, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, serializeRolloutPolicy, startRuntimeRun, strategyAuthorMethod, structuralRolloutPolicyFromProfile, toOtelAttributes, toolBuildPrompt, validateChatModelId, worktreeLoopRunner };
668
+ export { type AgentAdapter, type AgentBackendContext, type AgentBackendInput, AgentEvalError, type AgentEvalErrorCode, type AgentExecutionBackend, type AgentKnowledgeProvider, type AgentKnowledgeReadinessCheckOptions, type AgentRuntimeEvent, type AgentRuntimeEventSink, type AgentTaskContext, type AgentTaskRunResult, type AgentTaskSpec, type AgentTaskStatus, type AgenticGeneratorExecutorForWorktree, type AgenticGeneratorOptions, type AgenticGeneratorShotDisposition, type AgenticGeneratorShotExecution, type AgenticGeneratorShotReceipt, type AuthSource, type BackendCallPolicy, type BackendErrorDetail, BackendTransportError, type BuildPromptFindingsInput, type CandidateGenerator, type ChatModelCandidate, type ChatModelValidation, type CheckpointServingPort, type CircuitBreakerConfig, ConfigError, type ControlBudget, type ControlDecision, type ControlEvalResult, type ControlRunResult, type ControlStep, type ControlledTrainingCommand, type Conversation, type ConversationDriveState, type ConversationJournal, type ConversationJournalEntry, type ConversationParticipant, type ConversationPolicy, type ConversationResult, type ConversationStreamEvent, type ConversationTurn, type CreateKnowledgeImprovementActivationExecutorOptions, type CreateProfileImprovementHarnessOptions, type D1DatabaseLike, type D1StmtLike, DEFAULT_ROUTER_BASE_URL, DELEGATED_LOOP_MODES, type DataAcquisitionPlan, type DeepReadonly, type DelegatedLoopMode, type DelegatedLoopRegistry, type DelegatedLoopResult, type DelegatedLoopRunner, type EvalRunEvent, type EvalRunGeneration, type EvalRunsExportConfig, type EvalRunsExportResult, FileConversationJournal, type HaltContext, type HaltPredicate, type HaltReason, type HaltSignal, INTELLIGENCE_WIRE_VERSION, type ImproveCandidateValidationInput, type ImproveCandidateValidator, type ImproveCodeBaseOptions, type ImproveCodeOptions, type ImproveCodeResult, type ImproveCodeRunOptions, type ImproveCost, type ImproveCustomCodeGeneratorOptions, type ImproveLineage, type ImproveMethodContext, type ImproveMethodFactory, type ImproveMethodLineage, type ImproveMethodOptions, type ImproveMethodResult, type ImproveMethodSource, type ImproveOptimizationRunOptions, type ImproveOptions, type ImproveProfileAgent, type ImproveProfileComponents, type ImproveProfileSurface, type ImproveResult, type ImproveRuntimeCodeGeneratorOptions, type ImproveScenarioPartitions, type ImproveSkillsOptions, type ImproveSurface, type ImproveTrainingOptions, type ImproveTrainingResult, type ImprovementCandidate, type ImprovementCodeCandidate, type ImprovementMaterializedProfilePopulationCandidate, type ImprovementProfileCandidate, type ImprovementProfileCandidatePopulation, type ImprovementProfileCandidatePopulationAvailable, type ImprovementProfileCandidatePopulationUnavailable, type ImprovementProfilePopulationArtifactSource, type ImprovementProfilePopulationCandidate, type ImprovementProfilePopulationCandidateSource, type ImprovementProfilePopulationLineage, type ImprovementProfilePopulationLineageNode, type ImprovementProfilePopulationObservationSource, type ImprovementRefusedProfilePopulationCandidate, InMemoryConversationJournal, InMemoryRuntimeSessionStore, JudgeError, type KnowledgeImprovementActivationExecutor, type KnowledgeImprovementCandidatePair, type KnowledgeImprovementExperimentBundles, type KnowledgeImprovementJobMeasurement, type KnowledgeImprovementJobResult, type KnowledgeReadinessCheck, type KnowledgeReadinessCheckInput, type KnowledgeReadinessCheckResult, type KnowledgeReadinessDecision, type KnowledgeReadinessReport, type KnowledgeRequirement, type LoopRunnerCliArgs, type LoopRunnerCliResult, type LoopSpanNode, type McpServeSpec, type ModelInfo, NotFoundError, type OfficialGepaOptions, type OfficialOptimizerContextOptions, OfficialOptimizerUnavailableError, type OfficialSensitiveCandidateInput, type OfficialSkillOptOptions, type OpenAIChatResponseFormat, type OpenAIChatTool, type OpenAIChatToolChoice, type OtelAttribute, type OtelExportConfig, type OtelExportStats, type OtelExporter, type OtelSpan, PROMPT_INSTRUCTION_COMPONENT_PREFIX, type PersonaConversationResult, type PersonaDriver, PlannerError, type ProfileImprovementHarness, type ProfileImprovementHarnessRunOptions, type ProfileImprovementHarnessTrainOptions, type ProfileTrainer, type ProfileTrainerRequest, RESEARCH_SUPERVISOR_SYSTEM_PROMPT, ROLLOUT_POLICY_EXTENSION, type RawTraceDistillerOptions, type ReadonlyAgentProfile, type ReflectiveGeneratorOptions, type ResearchLoopResult, type ResearchLoopRunnerOptions, type ResolvedChatModel, RetainedInteractiveAdmissionError, RetainedInteractiveBindingError, RetainedRunAdmissionError, RetainedRunDispatchBindingError, type RetryBackoff, type RetryableErrorPredicate, type RouterEnv, type RunAgentTaskOptions, type RunAgentTaskStreamOptions, type RunConversationOptions, type RunDelegatedLoopOptions, type RunKnowledgeImprovementJobOptions, type RunPersonaConfig, type RunPersonaConversationOptions, type RunRecord, type RuntimeCanonicalStreamEvent, type RuntimeDecisionEvidenceRef, type RuntimeDecisionKind, type RuntimeDecisionPoint, type RuntimeEventCollector, type RuntimeEventOtelOptions, type RuntimeHookContext, type RuntimeHookErrorContext, type RuntimeHookEvent, type RuntimeHookPhase, type RuntimeHookTarget, type RuntimeHooks, type RuntimeRunCompleteInput, type RuntimeRunCost, type RuntimeRunHandle, type RuntimeRunOptions, type RuntimeRunPersistenceAdapter, type RuntimeRunRow, RuntimeRunStateError, type RuntimeRunStatus, type RuntimeSession, type RuntimeSessionStore, type RuntimeStreamEvent, type RuntimeStreamEventCollector, type RuntimeStreamEventSink, type RuntimeStreamEventSummary, type RuntimeTelemetryOptions, type SanitizedKnowledgeReadinessReport, type SanitizedKnowledgeRequirement, type ServerSentEventOptions, type SqlAdapter, SqlConversationJournal, type SupervisedKnowledgeUpdateInput, type SupervisedKnowledgeUpdateOptions, type SupervisedKnowledgeUpdateResult, type SupervisedKnowledgeUpdater, type TrainingBoundaryResult, type TrainingDatasetDocument, type TurnOrder, ValidationError, type Verifier, type VerifyResult, type VetoedFact, type WorktreeCheckRunner, type WorktreeLoopRunnerOptions, agenticGenerator, applyRolloutPolicyToProfile, applyRunRecordDefaults, auditLoopRunner, buildKnowledgeImprovementExperimentBundles, buildLoopOtelSpans, buildLoopSpanNodes, buildRuntimeEventOtelSpans, cleanModelId, commandVerifier, composeRuntimeHooks, createAgentKnowledgeReadinessCheck, createCommandProfileTrainer, createConversationBackend, createIterableBackend, createKnowledgeImprovementActivationExecutor, createOpenInferenceFileExporter, createOtelExporter, createProfileExecutionBackend, createProfileImprovementHarness, createRuntimeEventCollector, createRuntimeStreamEventCollector, createSandboxPromptBackend, createSupervisedKnowledgeUpdater, d1ToSqlAdapter, decideKnowledgeReadiness, defaultBuildPrompt, defineConversation, defineRuntimeHooks, exportEvalRuns, findingLines, formatSupervisedKnowledgeTask, generateSpanId, getModels, improve, isDelegatedLoopMode, knowledgeReadinessDeliverable, loopEventToOtelSpan, mcpBuildPrompt, mcpServeVerifier, mcpToolsForRuntimeMcp, mcpToolsForRuntimeMcpSubset, normalizeRolloutPolicy, notifyRuntimeDecisionPoint, notifyRuntimeHookEvent, officialGepa, officialSkillOpt, optimizerMethod, padSpanId, padTraceId, parseLoopRunnerArgv, parseRolloutPolicy, promptInstructionsProfileComponents, rawTraceDistiller, readinessServerSentEvent, reflectiveGenerator, researchLoopRunner, resolveChatModel, resolveRouterBaseUrl, runAgentTask, runAgentTaskStream, runConversation, runConversationStream, runDelegatedLoop, runKnowledgeImprovementJob, runLoopRunnerCli, runPersonaConversation, runPersonaDispatch, runSupervisedKnowledgeUpdate, runtimeStreamServerSentEvent, sanitizeAgentRuntimeEvent, sanitizeKnowledgeReadinessReport, sanitizeRuntimeStreamEvent, serializeRolloutPolicy, startRuntimeRun, strategyAuthorMethod, structuralRolloutPolicyFromProfile, toOtelAttributes, toolBuildPrompt, validateChatModelId, worktreeLoopRunner };
1113
669
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { Ar as createRuntimeEventCollector, Cr as exportEvalRuns, Dr as padSpanId, Er as loopEventToOtelSpan, Mr as sanitizeAgentRuntimeEvent, Ni as executableAgentProfileSnapshot, Nr as sanitizeKnowledgeReadinessReport, Or as padTraceId, Pr as sanitizeRuntimeStreamEvent, Sr as createOtelExporter, Tr as generateSpanId, _r as INTELLIGENCE_WIRE_VERSION, br as buildRuntimeEventOtelSpans, cr as resolveRedactor, fi as prepareJsonlAppend, jr as createRuntimeStreamEventCollector, kr as toOtelAttributes, mi as writeAllBytes, or as defaultRedactor, pi as readCommittedJsonLines, sr as defaultRedactorIdentityMaterial, vr as buildLoopOtelSpans, wa as providerMessageText, xr as createOpenInferenceFileExporter, yr as buildLoopSpanNodes } from "./supervisor-B8UMAXya.js";
1
+ import { Ai as readCommittedJsonLines, Br as exportEvalRuns, Cr as defaultRedactorIdentityMaterial, Fr as buildLoopOtelSpans, Gr as padTraceId, Hr as generateSpanId, Ir as buildLoopSpanNodes, Jr as createRuntimeStreamEventCollector, Kr as toOtelAttributes, Lr as buildRuntimeEventOtelSpans, Pr as INTELLIGENCE_WIRE_VERSION, Rr as createOpenInferenceFileExporter, Ur as loopEventToOtelSpan, Va as providerMessageText, Wr as padSpanId, Xi as executableAgentProfileSnapshot, Xr as sanitizeKnowledgeReadinessReport, Yr as sanitizeAgentRuntimeEvent, Zr as sanitizeRuntimeStreamEvent, ji as writeAllBytes, ki as prepareJsonlAppend, qr as createRuntimeEventCollector, wr as resolveRedactor, zr as createOtelExporter } from "./supervisor-DdKPGluv.js";
2
2
  import { a as JudgeError, c as RetainedInteractiveAdmissionError, d as RetainedRunDispatchBindingError, f as RuntimeRunStateError, i as ConfigError, l as RetainedInteractiveBindingError, m as ValidationError, o as NotFoundError, r as BackendTransportError, s as PlannerError, t as AgentEvalError, u as RetainedRunAdmissionError } from "./errors-DodWX-cb.js";
3
- import { F as InMemoryRuntimeSessionStore, I as newRuntimeSession, L as nowIso, M as createIterableBackend, N as createSandboxPromptBackend, O as optimizerMethod, P as normalizeBackendStreamEvent, R as startOrResumeRuntimeSession, j as streamAgentTurn, k as strategyAuthorMethod, z as touchSession } from "./structural-rollout-DV9YoQF6.js";
3
+ import { F as InMemoryRuntimeSessionStore, I as newRuntimeSession, L as nowIso, M as createIterableBackend, N as createSandboxPromptBackend, O as optimizerMethod, P as normalizeBackendStreamEvent, R as startOrResumeRuntimeSession, j as streamAgentTurn, k as strategyAuthorMethod, z as touchSession } from "./structural-rollout-DCUprNpH.js";
4
4
  import { t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
5
- import { a as createRuntimeUsageTotals, i as addRuntimeUsage, o as isUsageAmount, t as createAgentImprovementActivationResult } from "./activation-BERiJjx5.js";
5
+ import { a as createRuntimeUsageTotals, i as addRuntimeUsage, o as isUsageAmount, t as createAgentImprovementActivationResult } from "./activation-Cx2dKA_l.js";
6
6
  import { C as canonicalCandidateDigest$1, D as immutableCandidateValue, E as embeddedCandidateArtifact, O as omitTopLevelDigest, S as canonicalCandidateBytes$1, a as persistCandidateOutputArtifact, t as captureAgentCandidateWorkspace } from "./workspace-archive-C9lgf77y.js";
7
- import { Ut as McpSpawnFault, Wt as connectStdioMcp } from "./runtime-hOLlAc1i.js";
7
+ import { nn as connectStdioMcp, tn as McpSpawnFault } from "./runtime-CHxXrUeZ.js";
8
8
  import { i as notifyRuntimeHookEvent, n as defineRuntimeHooks, r as notifyRuntimeDecisionPoint, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
9
- import { B as assertCandidateValidator, G as applyRolloutPolicyToProfile, H as parseExecutionRef, J as serializeRolloutPolicy, K as normalizeRolloutPolicy, L as improve, Q as defaultBuildPrompt, R as createCommandProfileTrainer, U as rawTraceDistiller, W as ROLLOUT_POLICY_EXTENSION, X as agenticGenerator, Y as structuralRolloutPolicyFromProfile, Z as commandVerifier, q as parseRolloutPolicy, z as withMethodRuntimeControls } from "./improvement-cycle-GRPoHLm1.js";
9
+ import { B as assertCandidateValidator, G as applyRolloutPolicyToProfile, H as parseExecutionRef, J as serializeRolloutPolicy, K as normalizeRolloutPolicy, L as improve, Q as defaultBuildPrompt, R as createCommandProfileTrainer, U as rawTraceDistiller, W as ROLLOUT_POLICY_EXTENSION, X as agenticGenerator, Y as structuralRolloutPolicyFromProfile, Z as commandVerifier, q as parseRolloutPolicy, z as withMethodRuntimeControls } from "./improvement-cycle-CO2HRCQq.js";
10
10
  import { t as sealAgentCandidateBundle } from "./bundle-CvLGRVO-.js";
11
- import { r as supervise } from "./supervise--njTtSL3.js";
12
- import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-cC16EPUq.js";
11
+ import { r as supervise } from "./supervise-Dej5aSDa.js";
12
+ import { a as isDelegatedLoopMode, c as worktreeLoopRunner, i as auditLoopRunner, n as runLoopRunnerCli, o as researchLoopRunner, r as DELEGATED_LOOP_MODES, s as runDelegatedLoop, t as parseLoopRunnerArgv } from "./loop-runner-bin-B9MIq9O7.js";
13
13
  import { n as mcpToolsForRuntimeMcpSubset, t as mcpToolsForRuntimeMcp } from "./openai-tools-DoQ32vpe.js";
14
14
  import { agentCandidateKnowledgeSchema, agentProfileSchema, canonicalAgentProfileDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
15
15
  import { FAILURE_CLASSES, acquisitionPlansForKnowledgeGaps, blockingKnowledgeEval, canonicalJson, runAgentControlLoop, scoreKnowledgeReadiness, userQuestionsForKnowledgeGaps } from "@tangle-network/agent-eval";
@@ -18,7 +18,7 @@ import { spawnSync } from "node:child_process";
18
18
  import { readFileSync, realpathSync } from "node:fs";
19
19
  import { isAbsolute, relative, resolve, sep } from "node:path";
20
20
  import { realpath } from "node:fs/promises";
21
- import { isDeepStrictEqual } from "node:util";
21
+ import { redact } from "@tangle-network/agent-eval/traces";
22
22
  import { gepaOptimizationMethod, skillOptOptimizationMethod } from "@tangle-network/agent-eval/campaign";
23
23
  import { evaluateKnowledgeBaseReadiness, fromAgentCandidateKnowledgeRef, improveKnowledgeBase, knowledgeImprovementCandidateRef, loadKnowledgeImprovementActivationResult, normalizeKnowledgeStateScope, promoteKnowledgeCandidate, restoreKnowledgeCandidateBaseline, toAgentCandidateKnowledgeRef, withKnowledgeImprovementComparison } from "@tangle-network/agent-knowledge";
24
24
  //#region src/runtime/profile-execution-backend.ts
@@ -1563,9 +1563,8 @@ function methodBackground(options) {
1563
1563
  return sections.join("\n\n");
1564
1564
  }
1565
1565
  function assertSafeOptimizerCandidate(label, input, authorizeSensitiveCandidate) {
1566
- const redactedValue = defaultRedactor(input.value);
1567
- const redactedSurface = defaultRedactor(input.candidateSurface);
1568
- if (!isDeepStrictEqual(input.value, redactedValue) || !isDeepStrictEqual(input.candidateSurface, redactedSurface)) throw new ConfigError(`${label}: the selected profile surface contains a common credential or private value. Store live credentials as provider references, or remove private data before starting an external optimizer.`);
1566
+ const privatePaths = [...new Set([input.value, input.candidateSurface].flatMap((value) => redact(value).report.findings.map((finding) => jsonPathOf(finding.path))))];
1567
+ if (privatePaths.length > 0) throw new ConfigError(`${label}: the selected profile surface contains a common credential or private value at ${privatePaths.slice(0, 8).join(", ")}. Store live credentials as provider references, or remove private data before starting an external optimizer.`);
1569
1568
  const sensitivePaths = sensitiveProfileSurfacePaths(input);
1570
1569
  if (sensitivePaths.length === 0) return;
1571
1570
  let authorized = false;
@@ -1579,6 +1578,10 @@ function assertSafeOptimizerCandidate(label, input, authorizeSensitiveCandidate)
1579
1578
  }
1580
1579
  if (!authorized) throw new ConfigError(`${label}: the selected profile surface contains fields that may carry private values: ${sensitivePaths.slice(0, 8).join(", ")}. Remove them, replace values with safe references, or authorize the exact profile with authorizeSensitiveCandidate.`);
1581
1580
  }
1581
+ /** `/remote/url` or `/tools/0/env` as `$.remote.url` or `$.tools[0].env`. */
1582
+ function jsonPathOf(pointer) {
1583
+ return pointer.split("/").slice(1).map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~")).reduce((path, segment) => /^\d+$/.test(segment) ? `${path}[${segment}]` : `${path}.${segment}`, "$");
1584
+ }
1582
1585
  function sensitiveProfileSurfacePaths(input) {
1583
1586
  const paths = /* @__PURE__ */ new Set();
1584
1587
  if (input.surface === "tools" || input.surface === "mcp" || input.surface === "hooks" || input.surface === "subagents" || input.surface === "agent-profile") paths.add("$");