@tangle-network/agent-runtime 0.340.0 → 0.342.1

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 (70) hide show
  1. package/dist/{activation-DGDl4wwI.d.ts → activation-CXqtijue.d.ts} +2 -2
  2. package/dist/{activation-D2PVljaw.js → activation-DOH7Fnyp.js} +4 -4
  3. package/dist/{activation-D2PVljaw.js.map → activation-DOH7Fnyp.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-DNUq-OPW.js → bundle-Cwpit6Tg.js} +2 -2
  7. package/dist/{bundle-DNUq-OPW.js.map → bundle-Cwpit6Tg.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +4 -4
  9. package/dist/{driver-control-acknowledgers-MTrs8HAF.js → coordination-manager-HQE0bIav.js} +4852 -4539
  10. package/dist/coordination-manager-HQE0bIav.js.map +1 -0
  11. package/dist/{delegate-CtJIS-tp.js → delegate-DmShSdjy.js} +2 -2
  12. package/dist/{delegate-CtJIS-tp.js.map → delegate-DmShSdjy.js.map} +1 -1
  13. package/dist/durable.d.ts +1 -1
  14. package/dist/durable.js +451 -358
  15. package/dist/durable.js.map +1 -1
  16. package/dist/{graph-DfWqp_1e.js → graph-BCghJFlS.js} +5 -5
  17. package/dist/{graph-DfWqp_1e.js.map → graph-BCghJFlS.js.map} +1 -1
  18. package/dist/{improve-CKRVQqzt.js → improve-Dga6OYt-.js} +837 -704
  19. package/dist/improve-Dga6OYt-.js.map +1 -0
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +9 -9
  22. package/dist/intelligence.d.ts +2 -2
  23. package/dist/intelligence.js +205 -191
  24. package/dist/intelligence.js.map +1 -1
  25. package/dist/kernel.d.ts +1 -1
  26. package/dist/kernel.js +9 -9
  27. package/dist/{loop-runner-DNWbTcVm.js → loop-runner-CW87Vqoj.js} +2 -2
  28. package/dist/{loop-runner-DNWbTcVm.js.map → loop-runner-CW87Vqoj.js.map} +1 -1
  29. package/dist/{loop-runner-C4EWEcXf.d.ts → loop-runner-CuhbgVGo.d.ts} +2 -2
  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 +1 -1
  34. package/dist/mcp/index.js +5 -5
  35. package/dist/{prepare-FzJoS68l.js → prepare-C-cWCyt3.js} +988 -735
  36. package/dist/prepare-C-cWCyt3.js.map +1 -0
  37. package/dist/{profile-DToH0XEs.js → profile-CbMw5hAn.js} +2 -2
  38. package/dist/{profile-DToH0XEs.js.map → profile-CbMw5hAn.js.map} +1 -1
  39. package/dist/profiles.d.ts +1 -1
  40. package/dist/{provision-supervisor-DqvWXmAE.js → provision-supervisor-BWR_TJFg.js} +444 -419
  41. package/dist/provision-supervisor-BWR_TJFg.js.map +1 -0
  42. package/dist/{runtime-C55Zgo1R.js → runtime-CuRTZFe6.js} +1245 -1028
  43. package/dist/runtime-CuRTZFe6.js.map +1 -0
  44. package/dist/{sandbox-profile-compat-DRr3JwDx.js → sandbox-profile-compat-FN2kab2-.js} +72 -72
  45. package/dist/{sandbox-profile-compat-DRr3JwDx.js.map → sandbox-profile-compat-FN2kab2-.js.map} +1 -1
  46. package/dist/{search-executor-ChOlRBgg.js → search-executor-0-SjHAao.js} +3 -3
  47. package/dist/{search-executor-ChOlRBgg.js.map → search-executor-0-SjHAao.js.map} +1 -1
  48. package/dist/{server-DkVBSN_S.js → server-DTUK2wW1.js} +4 -4
  49. package/dist/{server-DkVBSN_S.js.map → server-DTUK2wW1.js.map} +1 -1
  50. package/dist/{structural-rollout-C1LEk_zq.js → structural-rollout-kfaZgAkd.js} +3 -3
  51. package/dist/{structural-rollout-C1LEk_zq.js.map → structural-rollout-kfaZgAkd.js.map} +1 -1
  52. package/dist/{supervise-CaUAxZZP.js → supervise-C_GAgiJU.js} +6346 -5447
  53. package/dist/supervise-C_GAgiJU.js.map +1 -0
  54. package/dist/{supervisor-VXuN2OHT.js → supervisor-C_03z693.js} +13823 -12826
  55. package/dist/supervisor-C_03z693.js.map +1 -0
  56. package/dist/testing.d.ts +1 -1
  57. package/dist/testing.js +13 -13
  58. package/dist/tui/index.d.ts +1 -1
  59. package/dist/tui/index.js +1 -1
  60. package/dist/{types-DZ6L0Bv3.d.ts → types-Cgs89PQd.d.ts} +266 -356
  61. package/dist/workspace-store/index.js +273 -265
  62. package/dist/workspace-store/index.js.map +1 -1
  63. package/package.json +10 -10
  64. package/dist/driver-control-acknowledgers-MTrs8HAF.js.map +0 -1
  65. package/dist/improve-CKRVQqzt.js.map +0 -1
  66. package/dist/prepare-FzJoS68l.js.map +0 -1
  67. package/dist/provision-supervisor-DqvWXmAE.js.map +0 -1
  68. package/dist/runtime-C55Zgo1R.js.map +0 -1
  69. package/dist/supervise-CaUAxZZP.js.map +0 -1
  70. package/dist/supervisor-VXuN2OHT.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { A_ as OtelSpan, B_ as RuntimeTelemetryOptions, C as RuntimeFailureCause, D_ as OtelExportConfig, E_ as OtelAttribute, F_ as padTraceId, G_ as sanitizeKnowledgeReadinessReport, H_ as SanitizedKnowledgeRequirement, I_ as RuntimeEventCollector, Ju as SuperviseOptions, Kl as IsolatedCheckResult, L_ as RuntimeStreamEventCollector, M as Budget, M_ as createOtelExporter, N_ as loopEventToOtelSpan, O_ as OtelExportStats, P_ as padSpanId, Qy as Redactor, R_ as RuntimeStreamEventSink, S as RuntimeStreamEvent, T as RuntimeFailureOwner, U_ as createRuntimeEventCollector, V_ as SanitizedKnowledgeReadinessReport, W_ as createRuntimeStreamEventCollector, Wl as IsolatedCheckBoxEvidence, _ as RunAgentTaskOptions, a as AgentKnowledgeProvider, ab as NotFoundError, b as RuntimeSession, c as AgentTaskContext, d as AgentTaskStatus, dS as RuntimeRunHandle, eb as AgentEvalError, fS as RuntimeRunOptions, g as OpenAIChatToolChoice, gS as startRuntimeRun, h as OpenAIChatTool, hS as RuntimeRunStatus, i as AgentExecutionBackend, ib as JudgeError, it as SupervisedResult, j_ as buildLoopOtelSpans, jp as ExecutorConfig, k_ as OtelExporter, l as AgentTaskRunResult, lS as RuntimeRunCompleteInput, lb as ExecutorFactory, m as OpenAIChatResponseFormat, mS as RuntimeRunRow, n as AgentBackendContext, nb as BackendTransportError, o as AgentRuntimeEvent, ob as ValidationError, p as KnowledgeReadinessDecision, pS as RuntimeRunPersistenceAdapter, r as AgentBackendInput, rb as ConfigError, s as AgentRuntimeEventSink, t as AgentAdapter, tb as AgentEvalErrorCode, u as AgentTaskSpec, uS as RuntimeRunCost, v as RunAgentTaskStreamOptions, w as RuntimeFailureCode, x as RuntimeSessionStore, y as RuntimeCanonicalStreamEvent, yf as SupervisorProfile, z_ as RuntimeStreamEventSummary } from "./types-DZ6L0Bv3.js";
1
+ import { A_ as OtelSpan, B_ as RuntimeTelemetryOptions, C as RuntimeFailureCause, D_ as OtelExportConfig, E_ as OtelAttribute, F_ as padTraceId, G_ as sanitizeKnowledgeReadinessReport, H_ as SanitizedKnowledgeRequirement, I_ as RuntimeEventCollector, Kl as IsolatedCheckResult, L_ as RuntimeStreamEventCollector, M as Budget, M_ as createOtelExporter, N_ as loopEventToOtelSpan, O_ as OtelExportStats, P_ as padSpanId, Qy as Redactor, R_ as RuntimeStreamEventSink, S as RuntimeStreamEvent, T as RuntimeFailureOwner, U_ as createRuntimeEventCollector, V_ as SanitizedKnowledgeReadinessReport, W_ as createRuntimeStreamEventCollector, Wl as IsolatedCheckBoxEvidence, _ as RunAgentTaskOptions, a as AgentKnowledgeProvider, ab as NotFoundError, b as RuntimeSession, c as AgentTaskContext, cd as SuperviseOptions, d as AgentTaskStatus, dS as RuntimeRunHandle, eb as AgentEvalError, fS as RuntimeRunOptions, g as OpenAIChatToolChoice, gS as startRuntimeRun, h as OpenAIChatTool, hS as RuntimeRunStatus, i as AgentExecutionBackend, ib as JudgeError, it as SupervisedResult, j_ as buildLoopOtelSpans, jp as ExecutorConfig, k_ as OtelExporter, l as AgentTaskRunResult, lS as RuntimeRunCompleteInput, lb as ExecutorFactory, m as OpenAIChatResponseFormat, mS as RuntimeRunRow, n as AgentBackendContext, nb as BackendTransportError, o as AgentRuntimeEvent, ob as ValidationError, p as KnowledgeReadinessDecision, pS as RuntimeRunPersistenceAdapter, r as AgentBackendInput, rb as ConfigError, s as AgentRuntimeEventSink, t as AgentAdapter, tb as AgentEvalErrorCode, u as AgentTaskSpec, uS as RuntimeRunCost, v as RunAgentTaskStreamOptions, w as RuntimeFailureCode, x as RuntimeSessionStore, y as RuntimeCanonicalStreamEvent, yf as SupervisorProfile, z_ as RuntimeStreamEventSummary } from "./types-Cgs89PQd.js";
2
2
  import { a as RuntimeHookErrorContext, c as RuntimeHookTarget, d as defineRuntimeHooks, i as RuntimeHookContext, l as RuntimeHooks, o as RuntimeHookEvent, s as RuntimeHookPhase, u as composeRuntimeHooks } from "./runtime-hooks-nsqxSUFL.js";
3
3
  import { N as AgentCandidateOutputArtifactPort } from "./workspace-streams-BiS4ABah.js";
4
4
  import { a as ImprovementProposalSource } from "./types-Cwrea-bU.js";
5
5
  import { i as SurfaceImprovementEdit } from "./improvement-adapter-sIthWkcN.js";
6
- import { $ as ImproveCodeBaseOptions, $t as CandidateGenerator, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorOptions, H as decideSearchImprovement, Ht as DeepReadonly, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as AgenticGeneratorShotReceipt, K as ImproveTrainingResult, Kt as AgenticGeneratorShotDisposition, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, Qt as commandVerifier, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as ReadonlyAgentProfile, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorExecutorForWorktree, X as createCommandProfileTrainer, Xt as VerifyResult, Y as TrainingBoundaryResult, Yt as Verifier, Z as ImproveCandidateValidationInput, Zt as agenticGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as AgenticGeneratorShotExecution, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-DGDl4wwI.js";
7
- import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-C4EWEcXf.js";
6
+ import { $ as ImproveCodeBaseOptions, $t as CandidateGenerator, At as SearchPromotion, B as DecideSearchImprovementOptions, Bt as sharedBoxLane, Ct as ImproveSearchOptions, Dt as ImprovementCodeCandidate, Et as ImproveSurface, Ft as SearchLaneOptions, G as ImproveTrainingOptions, Gt as AgenticGeneratorOptions, H as decideSearchImprovement, Ht as DeepReadonly, It as SearchTraceOptions, J as ProfileTrainerRequest, Jt as AgenticGeneratorShotReceipt, K as ImproveTrainingResult, Kt as AgenticGeneratorShotDisposition, L as improve, Lt as SharedBoxSearchLane, Mt as SearchEnvironmentFault, Nt as SearchLane, Ot as ImprovementProfileCandidate, Pt as SearchLaneKind, Q as ImproveCandidateValidator, Qt as commandVerifier, R as SearchMethodOptions, Rt as dedicatedLane, St as ImproveSearchMethod, Tt as ImproveSkillsOptions, U as CheckpointServingPort, Ut as ReadonlyAgentProfile, V as SearchImprovementDecision, Vt as subscriptionLane, W as ControlledTrainingCommand, Wt as AgenticGeneratorExecutorForWorktree, X as createCommandProfileTrainer, Xt as VerifyResult, Y as TrainingBoundaryResult, Yt as Verifier, Z as ImproveCandidateValidationInput, Zt as agenticGenerator, at as ImproveLineage, bt as ImproveSearchAgent, ct as ImproveMethodLineage, dt as ImproveMethodSource, et as ImproveCodeOptions, ft as ImproveOptimizationRunOptions, gt as ImproveProfileSurface, ht as ImproveProfileComponents, i as AgentImprovementActivationTransition, it as ImproveCustomCodeGeneratorOptions, jt as SearchCellContext, kt as SearchDispatchContext, lt as ImproveMethodOptions, mt as ImproveProfileAgent, n as AgentImprovementActivationResultStore, nt as ImproveCodeRunOptions, ot as ImproveMethodContext, q as ProfileTrainer, qt as AgenticGeneratorShotExecution, rt as ImproveCost, st as ImproveMethodFactory, t as AgentImprovementActivationReconciliation, tt as ImproveCodeResult, ut as ImproveMethodResult, vt as ImproveRuntimeCodeGeneratorOptions, wt as ImproveSearchResult, xt as ImproveSearchIdentity, yt as ImproveScenarioPartitions, z as searchMethod, zt as routerLane } from "./activation-CXqtijue.js";
7
+ import { i as auditLoopRunner, r as DelegatedLoopRunner } from "./loop-runner-CuhbgVGo.js";
8
8
  import { AgentCandidateBundle, AgentCandidateCapturedArtifact, AgentCandidateKnowledge, AgentProfile, Sha256Digest } from "@tangle-network/agent-interface";
9
9
  import { AgentProfile as AgentProfile$1, ControlBudget, ControlDecision, ControlEvalResult, ControlEvalResult as ControlEvalResult$1, ControlRunResult, ControlStep, CustomTokenPricing, DataAcquisitionPlan, KnowledgeReadinessReport, KnowledgeReadinessReport as KnowledgeReadinessReport$1, KnowledgeRequirement, MaximumCharge, ProposalFinding, RunRecord, RunRecord as RunRecord$1 } from "@tangle-network/agent-eval";
10
10
  import { ZodType } from "zod";
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { Ji as providerMessageText, Mi as defaultRedactorIdentityMaterial, Ni as resolveRedactor, _n as sanitizeKnowledgeReadinessReport, ci as runtimeFailureCause, cn as createOtelExporter, dn as loopEventToOtelSpan, fn as padSpanId, gn as createRuntimeStreamEventCollector, hn as createRuntimeEventCollector, ii as executableAgentProfileSnapshot, in as buildLoopOtelSpans, or as priceTokens, pn as padTraceId, sr as ROUTER_PRICE_SOURCE, vn as sanitizeRuntimeStreamEvent } from "./supervisor-VXuN2OHT.js";
1
+ import { Ji as providerMessageText, Mi as defaultRedactorIdentityMaterial, Ni as resolveRedactor, _n as sanitizeKnowledgeReadinessReport, ci as runtimeFailureCause, cn as createOtelExporter, cr as priceTokens, dn as loopEventToOtelSpan, fn as padSpanId, gn as createRuntimeStreamEventCollector, hn as createRuntimeEventCollector, ii as executableAgentProfileSnapshot, in as buildLoopOtelSpans, lr as ROUTER_PRICE_SOURCE, pn as padTraceId, vn as sanitizeRuntimeStreamEvent } from "./supervisor-C_03z693.js";
2
2
  import { a as JudgeError, f as RuntimeRunStateError, i as ConfigError, m as ValidationError, o as NotFoundError, r as BackendTransportError, t as AgentEvalError } from "./errors-DodWX-cb.js";
3
- import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-C1LEk_zq.js";
4
- import { L as embeddedCandidateArtifact, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, l as captureAgentCandidateWorkspace, ot as sleep, v as persistCandidateOutputArtifact, z as omitTopLevelDigest } from "./sandbox-profile-compat-DRr3JwDx.js";
3
+ import { B as InMemoryRuntimeSessionStore, C as optimizerMethod, H as nowIso, I as streamAgentTurn, L as createIterableBackend, R as createSandboxPromptBackend, U as startOrResumeRuntimeSession, V as newRuntimeSession, W as touchSession, z as normalizeBackendStreamEvent } from "./structural-rollout-kfaZgAkd.js";
4
+ import { L as embeddedCandidateArtifact, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, b as persistCandidateOutputArtifact, l as captureAgentCandidateWorkspace, ot as sleep, z as omitTopLevelDigest } from "./sandbox-profile-compat-FN2kab2-.js";
5
5
  import { t as assertExecutableAgentProfile } from "./model-policy-CyCUwHed.js";
6
- import { c as withMethodRuntimeControls, d as commandVerifier, f as addRuntimeUsage, i as assertCandidateValidator, m as isUsageAmount, n as createCommandProfileTrainer, o as parseExecutionRef, p as createRuntimeUsageTotals, r as searchMethod, s as privateValuePaths, t as improve, u as agenticGenerator } from "./improve-CKRVQqzt.js";
6
+ import { c as withMethodRuntimeControls, d as commandVerifier, f as addRuntimeUsage, i as assertCandidateValidator, m as isUsageAmount, n as createCommandProfileTrainer, o as parseExecutionRef, p as createRuntimeUsageTotals, r as searchMethod, s as privateValuePaths, t as improve, u as agenticGenerator } from "./improve-Dga6OYt-.js";
7
7
  import { n as defineRuntimeHooks, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
8
- import { t as supervise } from "./supervise-CaUAxZZP.js";
9
- import { n as createAgentImprovementActivationResult } from "./activation-D2PVljaw.js";
10
- import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-ChOlRBgg.js";
11
- import { t as sealAgentCandidateBundle } from "./bundle-DNUq-OPW.js";
12
- import { n as auditLoopRunner } from "./loop-runner-DNWbTcVm.js";
8
+ import { t as supervise } from "./supervise-C_GAgiJU.js";
9
+ import { n as createAgentImprovementActivationResult } from "./activation-DOH7Fnyp.js";
10
+ import { l as sharedBoxLane, o as routerLane, r as dedicatedLane, t as SearchEnvironmentFault, u as subscriptionLane, y as decideSearchImprovement } from "./search-executor-0-SjHAao.js";
11
+ import { t as sealAgentCandidateBundle } from "./bundle-Cwpit6Tg.js";
12
+ import { n as auditLoopRunner } from "./loop-runner-CW87Vqoj.js";
13
13
  import { agentCandidateKnowledgeSchema, agentCandidateWorkspaceManifestMaterialSchema, agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256DigestSchema } from "@tangle-network/agent-interface";
14
14
  import { FAILURE_CLASSES, acquisitionPlansForKnowledgeGaps, blockingKnowledgeEval, canonicalJson, runAgentControlLoop, scoreKnowledgeReadiness, userQuestionsForKnowledgeGaps } from "@tangle-network/agent-eval";
15
15
  import { z } from "zod";
@@ -1,8 +1,8 @@
1
- import { $x as LoopTraceEvent, $y as defaultRedactor, B_ as RuntimeTelemetryOptions, O_ as OtelExportStats, Qy as Redactor, S as RuntimeStreamEvent, cm as AgentEnvironmentProviderRef, lm as AgentEnvironmentProviderRegistry } from "./types-DZ6L0Bv3.js";
1
+ import { $x as LoopTraceEvent, $y as defaultRedactor, B_ as RuntimeTelemetryOptions, O_ as OtelExportStats, Qy as Redactor, S as RuntimeStreamEvent, cm as AgentEnvironmentProviderRef, lm as AgentEnvironmentProviderRegistry } from "./types-Cgs89PQd.js";
2
2
  import { H as AgentCandidateTaskExecution, N as AgentCandidateOutputArtifactPort, S as AgentCandidateExecutorPort, _ as AgentCandidateBenchmarkGraderPort, y as AgentCandidateExecutionPorts } from "./workspace-streams-BiS4ABah.js";
3
3
  import { d as RunAnalystLoopResult, u as RunAnalystLoopOpts } from "./types-Cwrea-bU.js";
4
4
  import { b as AgentCandidateExecutionClaimStore, f as PrepareAgentCandidateExecutionOptions, i as CreateProtectedAgentCandidateModelPortOptions, m as ExecutePreparedAgentCandidateOptions, u as parseAgentCandidateProfileActivation } from "./protected-model-port-DVVh-hEk.js";
5
- import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-DGDl4wwI.js";
5
+ import { A as AgentProfileMeasuredSurface, C as verifyAgentImprovementProposal, D as AgentImprovementActivationTargetIdentity, E as AGENT_PROFILE_MEASURED_SURFACES, F as isAgentImprovementProfileSurface, I as isAgentProfileMeasuredSurface, M as agentImprovementProfileSurfaceDigest, N as agentImprovementProfileSurfaceInput, O as AgentImprovementProfileSurface, P as agentImprovementTargetProfileDiffs, S as verifyAgentImprovementActivationResult, T as AGENT_IMPROVEMENT_PROFILE_SURFACES, _ as createAgentImprovementActivationResult, _t as ImproveResult, a as AgentImprovementActivationTransitionInput, b as reviewAgentImprovementProposal, c as CreateAgentImprovementActivationOptions, d as ExecuteAgentImprovementActivationInput, f as ExecuteAgentImprovementActivationOptions, g as createAgentImprovementActivation, h as SealedCandidateActivationTransitionInput, j as agentImprovementProfileDiffs, k as AgentImprovementTargetProfileDiffOptions, l as CreateAgentImprovementActivationResultOptions, lt as ImproveMethodOptions, m as ReviewAgentImprovementInput, o as AgentProfileImprovementActivationOperation, p as ProfileImprovementActivationTransitionInput, pt as ImproveOptions, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, u as CreateAgentImprovementProposalOptions, ut as ImproveMethodResult, v as createAgentImprovementProposal, w as verifyAgentImprovementReview, x as verifyAgentImprovementActivation, y as executeAgentImprovementActivation, yt as ImproveScenarioPartitions } from "./activation-CXqtijue.js";
6
6
  import { AgentCandidateBenchmarkCellRef, AgentCandidateEvaluationPolicy, AgentCandidateExperiment, AgentCandidateExperimentMaterial, AgentCandidateExperimentMeasurement, AgentCandidateLineage, AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition, AgentImprovementEvaluation, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementProposal as AgentImprovementProposal$1, AgentImprovementReview, AgentImprovementReviewDecision, AgentImprovementSource, AgentProfile, AgentProfileDiff, AgentProfileImprovementExecutionRef, AgentProfileImprovementExperiment, AgentProfileImprovementMeasuredComparison, AgentProfileImprovementMeasurement, AgentProfileImprovementRunReceipt, AgentProfileImprovementTaskMaterial, CandidateExecutionEvidence, CandidateExecutionEvidence as CandidateExecutionEvidence$1, Sha256Digest } from "@tangle-network/agent-interface";
7
7
  import { CostLedgerHandle, TraceStore } from "@tangle-network/agent-eval";
8
8
  import { ProposalFinding as ProposalFinding$1 } from "@tangle-network/agent-eval/analyst";
@@ -1,10 +1,10 @@
1
- import { Ni as resolveRedactor, Pt as resolveAgentEnvironmentProvider, Vr as authoredAgentIdentity, cn as createOtelExporter, in as buildLoopOtelSpans, ji as defaultRedactor, ln as flatOtelSpan, mn as toOtelAttributes, on as buildRuntimeEventOtelSpans } from "./supervisor-VXuN2OHT.js";
2
- import { F as canonicalCandidateDocument, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, V as verifyCanonicalCandidateDocument, z as omitTopLevelDigest } from "./sandbox-profile-compat-DRr3JwDx.js";
3
- import { a as assertProfileTrainingIsHeldOut, f as addRuntimeUsage, l as rethrowAfterCleanup, m as isUsageAmount, p as createRuntimeUsageTotals, t as improve } from "./improve-CKRVQqzt.js";
4
- import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-D2PVljaw.js";
5
- import { _ as parseAgentCandidateProfileActivation, a as applyExactAgentProfileDiff, d as createAgentCandidateProfileActivation, g as omitUndefinedObjectFields, m as materializeAgentCandidateProfilePlan, o as assertCandidateProfileBinding, v as parseExactAgentProfile } from "./profile-DToH0XEs.js";
1
+ import { Ni as resolveRedactor, Pt as resolveAgentEnvironmentProvider, Vr as authoredAgentIdentity, cn as createOtelExporter, in as buildLoopOtelSpans, ji as defaultRedactor, ln as flatOtelSpan, mn as toOtelAttributes, on as buildRuntimeEventOtelSpans } from "./supervisor-C_03z693.js";
2
+ import { F as canonicalCandidateDocument, N as canonicalCandidateBytes$1, P as canonicalCandidateDigest$1, R as immutableCandidateValue, V as verifyCanonicalCandidateDocument, z as omitTopLevelDigest } from "./sandbox-profile-compat-FN2kab2-.js";
3
+ import { a as assertProfileTrainingIsHeldOut, f as addRuntimeUsage, l as rethrowAfterCleanup, m as isUsageAmount, p as createRuntimeUsageTotals, t as improve } from "./improve-Dga6OYt-.js";
4
+ import { _ as agentImprovementTargetProfileDiffs, a as reviewAgentImprovementProposal, b as isAgentProfileMeasuredSurface, c as verifyAgentImprovementProposal, d as attachOptimizationActivationReceipt, f as createOptimizationActivationReceipt, g as agentImprovementProfileSurfaceInput, h as agentImprovementProfileSurfaceDigest, i as executeAgentImprovementActivation, l as verifyAgentImprovementReview, m as agentImprovementProfileDiffs, n as createAgentImprovementActivationResult, o as verifyAgentImprovementActivation, p as optimizationActivationReceiptFromMetadata, r as createAgentImprovementProposal, s as verifyAgentImprovementActivationResult, t as createAgentImprovementActivation, u as assertNoCallerOptimizationReceipt, v as assertProfileImprovementTargetsShareIdentity, y as isAgentImprovementProfileSurface } from "./activation-DOH7Fnyp.js";
5
+ import { _ as parseAgentCandidateProfileActivation, a as applyExactAgentProfileDiff, d as createAgentCandidateProfileActivation, g as omitUndefinedObjectFields, m as materializeAgentCandidateProfilePlan, o as assertCandidateProfileBinding, v as parseExactAgentProfile } from "./profile-CbMw5hAn.js";
6
6
  import { t as runAnalystLoop } from "./analyst-loop-DZw5QWT9.js";
7
- import { C as verifiedResourceTextByDigest, S as AGENT_CANDIDATE_EXECUTION_SUPPORT, n as executePreparedAgentCandidate, t as prepareAgentCandidateExecution, w as verifyAgentCandidateBundle, x as exactProcessProviderAsCandidateExecutor, y as createProtectedAgentCandidateModelPort } from "./prepare-FzJoS68l.js";
7
+ import { C as verifiedResourceTextByDigest, S as AGENT_CANDIDATE_EXECUTION_SUPPORT, n as executePreparedAgentCandidate, t as prepareAgentCandidateExecution, w as verifyAgentCandidateBundle, x as exactProcessProviderAsCandidateExecutor, y as createProtectedAgentCandidateModelPort } from "./prepare-C-cWCyt3.js";
8
8
  import { AGENT_IMPROVEMENT_SOURCE_METADATA_KEY, agentCandidateMaterializationReceiptSchema, agentCandidateRunReceiptSchema, agentImprovementSourceMetadata, agentImprovementSourceSchema, agentProfileImprovementArmSchema, applyAgentProfileDiff, candidateExecutionEvidenceSchema, numbersApproximatelyEqual } from "@tangle-network/agent-interface";
9
9
  import { CostLedger, contentHash } from "@tangle-network/agent-eval";
10
10
  import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
@@ -331,6 +331,158 @@ function normalizeReportedUsage(usage, intelligenceOff = false) {
331
331
  };
332
332
  }
333
333
  //#endregion
334
+ //#region src/intelligence/otel-run-export.ts
335
+ /**
336
+ * The OTLP spans Tangle Intelligence receives for one traced run or run record.
337
+ * Attribute keys are verbatim: the plane's session, model and cost readers
338
+ * exact-match them. Redaction applies to every customer payload before it is
339
+ * hashed or attached.
340
+ */
341
+ function usageAttributes(usage, intelligenceOff) {
342
+ const normalized = normalizeReportedUsage(usage, intelligenceOff);
343
+ return {
344
+ "tangle.usage.inference_usd": normalized.inferenceUsd,
345
+ "tangle.usage.intelligence_usd": normalized.intelligenceUsd,
346
+ ...normalized.inferenceUsdKnown === false ? { "tangle.usage.inference_usd_known": false } : {},
347
+ ...normalized.intelligenceUsdKnown === false ? { "tangle.usage.intelligence_usd_known": false } : {},
348
+ ...normalized.estimatedInferenceUsd !== void 0 ? { "tangle.usage.inference_usd_estimated": normalized.estimatedInferenceUsd } : {}
349
+ };
350
+ }
351
+ /** Serialize a redacted value without dropping customer trace content. */
352
+ function serializeJson(value) {
353
+ let s;
354
+ if (typeof value === "string") s = value;
355
+ else try {
356
+ s = JSON.stringify(value) ?? String(value);
357
+ } catch {
358
+ s = String(value);
359
+ }
360
+ return s;
361
+ }
362
+ function addPayloadAttributes(labels, key, value, includeFullPayload) {
363
+ const serialized = serializeJson(value);
364
+ labels[`${key}_hash`] = contentHash(serialized);
365
+ labels[`${key}_bytes`] = Buffer.byteLength(serialized, "utf8");
366
+ if (includeFullPayload) labels[key] = serialized;
367
+ }
368
+ /** Export one flat run span for a traced call. */
369
+ function exportTraceSpan(exporter, settings, meta, outcome, output) {
370
+ const labels = {
371
+ project: settings.project,
372
+ "tangle.effort.intelligence_off": outcome.intelligenceOff,
373
+ ...usageAttributes(outcome.usage, settings.intelligenceOff),
374
+ ...meta.model ? { "gen_ai.request.model": meta.model } : {},
375
+ ...meta.provider ? { "provider.name": meta.provider } : {},
376
+ ...typeof outcome.success === "boolean" ? { "tangle.outcome.success": outcome.success } : {},
377
+ ...typeof outcome.score === "number" ? { "tangle.outcome.score": outcome.score } : {},
378
+ ...meta.labels ?? {}
379
+ };
380
+ const redactedInput = meta.input !== void 0 ? settings.redactor(meta.input) : void 0;
381
+ const redactedOutput = output !== void 0 ? settings.redactor(output) : void 0;
382
+ if (redactedInput !== void 0) addPayloadAttributes(labels, "tangle.input", redactedInput, settings.includeFullPayload);
383
+ if (redactedOutput !== void 0) addPayloadAttributes(labels, "tangle.output", redactedOutput, settings.includeFullPayload);
384
+ exporter.exportSpan(flatOtelSpan("tangle.intelligence.run", {
385
+ "tangle.runId": outcome.runId,
386
+ ...labels,
387
+ [ATTR.spanKind]: "AGENT"
388
+ }, outcome.traceId, Date.now()));
389
+ }
390
+ /** The run span's attributes that come straight from the record. */
391
+ function runRecordAttributes(settings, record) {
392
+ const repository = record.repository ?? (settings.repo ? `${settings.repo.owner}/${settings.repo.name}` : void 0);
393
+ return {
394
+ project: record.project,
395
+ "tangle.target": record.target,
396
+ "tangle.effort.intelligence_off": settings.intelligenceOff,
397
+ ...usageAttributes(record.outcome.usage, settings.intelligenceOff),
398
+ ...record.model ? { "gen_ai.request.model": record.model } : {},
399
+ ...record.provider ? { "provider.name": record.provider } : {},
400
+ ...record.sessionId ? {
401
+ "tangle.sessionId": record.sessionId,
402
+ "gen_ai.conversation.id": record.sessionId
403
+ } : {},
404
+ ...record.harness ? { "tangle.agent.harness": record.harness } : {},
405
+ ...repository ? { "vcs.repository.name": repository } : {},
406
+ ...record.commitSha ? { "vcs.ref.head.revision": record.commitSha } : {},
407
+ ...record.timing ? {
408
+ "tangle.started_at_ms": record.timing.startedAt,
409
+ "tangle.completed_at_ms": record.timing.completedAt,
410
+ "tangle.duration_ms": record.timing.durationMs
411
+ } : {},
412
+ ...record.tokens ? {
413
+ "gen_ai.usage.input_tokens": record.tokens.input,
414
+ "gen_ai.usage.output_tokens": record.tokens.output,
415
+ ...record.tokens.tokensKnown === false ? { "tangle.usage.tokens_known": false } : {},
416
+ ...record.tokens.cachedInput !== void 0 ? { "gen_ai.usage.cache_read_input_tokens": record.tokens.cachedInput } : {},
417
+ ...record.tokens.reasoning !== void 0 ? { "gen_ai.usage.reasoning_tokens": record.tokens.reasoning } : {}
418
+ } : {},
419
+ ...typeof record.outcome.success === "boolean" ? { "tangle.outcome.success": record.outcome.success } : {},
420
+ ...typeof record.outcome.score === "number" ? { "tangle.outcome.score": record.outcome.score } : {},
421
+ ...record.error ? {
422
+ "error.type": record.error.code ?? record.error.name,
423
+ "error.message": serializeJson(settings.redactor(record.error.message))
424
+ } : {},
425
+ ...record.runtimeEvents ? { "tangle.runtime.event_count": record.runtimeEvents.length } : {},
426
+ ...record.candidateExecution ? {
427
+ "tangle.candidate.bundle_digest": record.candidateExecution.receipt.bundleDigest,
428
+ "tangle.candidate.experiment_digest": record.candidateExecution.materializationReceipt.executionPlan.material.runCell.experimentDigest,
429
+ "tangle.candidate.execution_id": record.candidateExecution.materializationReceipt.executionPlan.material.executionId,
430
+ "tangle.candidate.execution_plan_digest": record.candidateExecution.receipt.executionPlanDigest,
431
+ "tangle.candidate.materialization_receipt_digest": record.candidateExecution.receipt.materializationReceiptDigest,
432
+ "tangle.candidate.succeeded": record.candidateExecution.receipt.termination.kind === "exit" && record.candidateExecution.receipt.termination.exitCode === 0 && record.candidateExecution.receipt.benchmarkResult.material.passed,
433
+ "tangle.candidate.run_receipt_digest": record.candidateExecution.receipt.digest
434
+ } : {}
435
+ };
436
+ }
437
+ /** Export the loop → round → iteration span tree with the shipped topology builder, never a second one. */
438
+ function exportLoopSpans(exporter, events, traceId, parentSpanId, redactor, decorate = (span) => span) {
439
+ const spans = buildLoopOtelSpans(events, traceId, parentSpanId, redactor);
440
+ for (const span of spans) exporter.exportSpan(decorate(span));
441
+ }
442
+ /** Export a run record: its run span, then its runtime-event and loop spans under the same trace. */
443
+ function exportRunRecordSpans(exporter, settings, record) {
444
+ const labels = runRecordAttributes(settings, record);
445
+ if (record.profile) {
446
+ addPayloadAttributes(labels, "tangle.agent.profile", settings.redactor(record.profile), settings.includeFullPayload);
447
+ if (record.profile.name) labels["gen_ai.agent.name"] = record.profile.name;
448
+ }
449
+ const identity = agentIdentityAttributes({
450
+ ...authoredAgentIdentity(record.profile),
451
+ ...record.harness ? { harness: record.harness } : {}
452
+ });
453
+ const attributed = (span) => withMissingAttributes(span, identity);
454
+ Object.assign(labels, identity);
455
+ const redactedInput = record.input !== void 0 ? settings.redactor(record.input) : void 0;
456
+ const redactedOutput = record.output !== void 0 ? settings.redactor(record.output) : void 0;
457
+ if (redactedInput !== void 0) addPayloadAttributes(labels, "tangle.input", redactedInput, settings.includeFullPayload);
458
+ if (redactedOutput !== void 0) addPayloadAttributes(labels, "tangle.output", redactedOutput, settings.includeFullPayload);
459
+ const now = Date.now();
460
+ const runSpan = flatOtelSpan("tangle.intelligence.run", {
461
+ "tangle.runId": record.runId,
462
+ ...labels,
463
+ [ATTR.spanKind]: "AGENT"
464
+ }, record.traceId, record.timing?.startedAt ?? now, void 0, record.timing?.completedAt ?? now);
465
+ exporter.exportSpan(runSpan);
466
+ if (record.runtimeEvents && record.runtimeEvents.length > 0) {
467
+ const spans = buildRuntimeEventOtelSpans(record.runtimeEvents, record.traceId, runSpan.spanId, {
468
+ ...settings.runtimeTelemetry,
469
+ redact: settings.redactor
470
+ });
471
+ for (const span of spans) exporter.exportSpan(attributed(span));
472
+ }
473
+ if (record.loopEvents && record.loopEvents.length > 0) exportLoopSpans(exporter, record.loopEvents, record.traceId, runSpan.spanId, settings.redactor, attributed);
474
+ }
475
+ /** `span` plus each of `attributes` it does not already carry; its own values win. */
476
+ function withMissingAttributes(span, attributes) {
477
+ const present = new Set((span.attributes ?? []).map((attribute) => attribute.key));
478
+ const missing = Object.fromEntries(Object.entries(attributes).filter(([key]) => !present.has(key)));
479
+ if (Object.keys(missing).length === 0) return span;
480
+ return {
481
+ ...span,
482
+ attributes: [...span.attributes ?? [], ...toOtelAttributes(missing)]
483
+ };
484
+ }
485
+ //#endregion
334
486
  //#region src/intelligence/profile-improvement-experiment.ts
335
487
  function createProfileImprovementCostLedger(budgetUsd, context = "profile improvement") {
336
488
  if (!Number.isFinite(budgetUsd) || budgetUsd < 0) throw new Error(`${context} budgetUsd must be a non-negative finite number`);
@@ -1517,37 +1669,6 @@ function withIntelligence(agent, config) {
1517
1669
  }
1518
1670
  //#endregion
1519
1671
  //#region src/intelligence/index.ts
1520
- /**
1521
- *
1522
- * Tangle Intelligence SDK — trace capture plus reviewable improvement.
1523
- *
1524
- * The client keeps live-agent trace delivery best-effort. The separate
1525
- * improvement-cycle exports analyze completed traces and run a signed baseline
1526
- * versus candidate experiment. Activation exports bind review to its result
1527
- * and activate only the exact measured candidate.
1528
- *
1529
- * 1. OBSERVE — wrap a generic agent and export one trace span per call to
1530
- * Tangle Intelligence, swallowing every export failure so a live agent
1531
- * never fails because Intelligence is down.
1532
- * 2. MODE 0 / OFF — at `effort: 'off'`, run the agent as PURE PASSTHROUGH
1533
- * (zero intelligence spawns) with best-effort telemetry still on. The
1534
- * exported trace tags usage by class `{ inferenceUsd, intelligenceUsd }`,
1535
- * and at OFF `intelligenceUsd` is provably `0` — the mechanism that proves
1536
- * an OFF customer paid inference-only.
1537
- *
1538
- * @module
1539
- * @stable
1540
- */
1541
- function usageAttributes(usage, intelligenceOff) {
1542
- const normalized = normalizeReportedUsage(usage, intelligenceOff);
1543
- return {
1544
- "tangle.usage.inference_usd": normalized.inferenceUsd,
1545
- "tangle.usage.intelligence_usd": normalized.intelligenceUsd,
1546
- ...normalized.inferenceUsdKnown === false ? { "tangle.usage.inference_usd_known": false } : {},
1547
- ...normalized.intelligenceUsdKnown === false ? { "tangle.usage.intelligence_usd_known": false } : {},
1548
- ...normalized.estimatedInferenceUsd !== void 0 ? { "tangle.usage.inference_usd_estimated": normalized.estimatedInferenceUsd } : {}
1549
- };
1550
- }
1551
1672
  function resolveEffortConfig(effort) {
1552
1673
  if (effort === void 0) return resolveEffort(defaultEffortTier);
1553
1674
  if (typeof effort === "string") return resolveEffort(effort);
@@ -1559,29 +1680,43 @@ function freshTraceId() {
1559
1680
  function freshRunId() {
1560
1681
  return `run-${randomHex(16)}`;
1561
1682
  }
1562
- /** Serialize a redacted value without dropping customer trace content. */
1563
- function serializeJson(value) {
1564
- let s;
1565
- if (typeof value === "string") s = value;
1566
- else try {
1567
- s = JSON.stringify(value) ?? String(value);
1568
- } catch {
1569
- s = String(value);
1570
- }
1571
- return s;
1572
- }
1573
- function addPayloadAttributes(labels, key, value, includeFullPayload) {
1574
- const serialized = serializeJson(value);
1575
- labels[`${key}_hash`] = contentHash(serialized);
1576
- labels[`${key}_bytes`] = Buffer.byteLength(serialized, "utf8");
1577
- if (includeFullPayload) labels[key] = serialized;
1578
- }
1579
1683
  function randomHex(chars) {
1580
1684
  const bytes = new Uint8Array(Math.ceil(chars / 2));
1581
1685
  if (typeof globalThis.crypto?.getRandomValues === "function") globalThis.crypto.getRandomValues(bytes);
1582
1686
  else for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);
1583
1687
  return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, chars);
1584
1688
  }
1689
+ /** The `doctor()` readiness report for a client's config, with no network call. */
1690
+ function doctorReport(config, effort, apiKey) {
1691
+ const hasRepo = Boolean(config.repo?.owner && config.repo?.name && config.repo?.baseBranch);
1692
+ const hasChecks = Boolean(config.checks && config.checks.length > 0);
1693
+ const hasSurfaces = Boolean(config.surfaces && config.surfaces.length > 0);
1694
+ const prMissing = [];
1695
+ if (!hasChecks) prMissing.push("checks");
1696
+ if (!hasSurfaces) prMissing.push("surfaces");
1697
+ if (!hasRepo) prMissing.push("repo");
1698
+ const recommendMissing = [];
1699
+ if (isIntelligenceOff(effort)) recommendMissing.push("effort above off");
1700
+ return {
1701
+ project: config.project,
1702
+ effort,
1703
+ exportConfigured: Boolean(apiKey),
1704
+ modes: {
1705
+ observe: {
1706
+ ready: true,
1707
+ missing: []
1708
+ },
1709
+ recommend: {
1710
+ ready: recommendMissing.length === 0,
1711
+ missing: recommendMissing
1712
+ },
1713
+ pr: {
1714
+ ready: prMissing.length === 0,
1715
+ missing: prMissing
1716
+ }
1717
+ }
1718
+ };
1719
+ }
1585
1720
  /**
1586
1721
  * Create an Observe-mode Intelligence client. Resolves effort, the base URL, and
1587
1722
  * the redactor up front; the exporter is built lazily and is `undefined` when no
@@ -1596,6 +1731,18 @@ function createIntelligenceClient(config) {
1596
1731
  const includeFullPayload = config.payloadAttributes === "full";
1597
1732
  const apiKey = config.apiKey ?? (typeof process !== "undefined" ? process.env.TANGLE_API_KEY : void 0);
1598
1733
  const otlpEndpoint = `${resolveIntelligenceBaseUrl(config.baseUrl)}/v1/otlp`;
1734
+ const exportSettings = {
1735
+ project: config.project,
1736
+ intelligenceOff,
1737
+ redactor,
1738
+ includeFullPayload,
1739
+ get repo() {
1740
+ return config.repo;
1741
+ },
1742
+ get runtimeTelemetry() {
1743
+ return config.runtimeTelemetry;
1744
+ }
1745
+ };
1599
1746
  let exporter;
1600
1747
  let exporterResolved = false;
1601
1748
  function getExporter() {
@@ -1614,107 +1761,14 @@ function createIntelligenceClient(config) {
1614
1761
  const ex = getExporter();
1615
1762
  if (!ex) return;
1616
1763
  try {
1617
- const labels = {
1618
- project: config.project,
1619
- "tangle.effort.intelligence_off": outcome.intelligenceOff,
1620
- ...usageAttributes(outcome.usage, intelligenceOff),
1621
- ...meta.model ? { "gen_ai.request.model": meta.model } : {},
1622
- ...meta.provider ? { "provider.name": meta.provider } : {},
1623
- ...typeof outcome.success === "boolean" ? { "tangle.outcome.success": outcome.success } : {},
1624
- ...typeof outcome.score === "number" ? { "tangle.outcome.score": outcome.score } : {},
1625
- ...meta.labels ?? {}
1626
- };
1627
- const redactedInput = meta.input !== void 0 ? redactor(meta.input) : void 0;
1628
- const redactedOutput = output !== void 0 ? redactor(output) : void 0;
1629
- if (redactedInput !== void 0) addPayloadAttributes(labels, "tangle.input", redactedInput, includeFullPayload);
1630
- if (redactedOutput !== void 0) addPayloadAttributes(labels, "tangle.output", redactedOutput, includeFullPayload);
1631
- ex.exportSpan(flatOtelSpan("tangle.intelligence.run", {
1632
- "tangle.runId": outcome.runId,
1633
- ...labels,
1634
- [ATTR.spanKind]: "AGENT"
1635
- }, outcome.traceId, Date.now()));
1764
+ exportTraceSpan(ex, exportSettings, meta, outcome, output);
1636
1765
  } catch {}
1637
1766
  }
1638
1767
  function exportRunRecord(record) {
1639
1768
  const ex = getExporter();
1640
1769
  if (!ex) return record.traceId;
1641
1770
  try {
1642
- const repository = record.repository ?? (config.repo ? `${config.repo.owner}/${config.repo.name}` : void 0);
1643
- const labels = {
1644
- project: record.project,
1645
- "tangle.target": record.target,
1646
- "tangle.effort.intelligence_off": intelligenceOff,
1647
- ...usageAttributes(record.outcome.usage, intelligenceOff),
1648
- ...record.model ? { "gen_ai.request.model": record.model } : {},
1649
- ...record.provider ? { "provider.name": record.provider } : {},
1650
- ...record.sessionId ? {
1651
- "tangle.sessionId": record.sessionId,
1652
- "gen_ai.conversation.id": record.sessionId
1653
- } : {},
1654
- ...record.harness ? { "tangle.agent.harness": record.harness } : {},
1655
- ...repository ? { "vcs.repository.name": repository } : {},
1656
- ...record.commitSha ? { "vcs.ref.head.revision": record.commitSha } : {},
1657
- ...record.timing ? {
1658
- "tangle.started_at_ms": record.timing.startedAt,
1659
- "tangle.completed_at_ms": record.timing.completedAt,
1660
- "tangle.duration_ms": record.timing.durationMs
1661
- } : {},
1662
- ...record.tokens ? {
1663
- "gen_ai.usage.input_tokens": record.tokens.input,
1664
- "gen_ai.usage.output_tokens": record.tokens.output,
1665
- ...record.tokens.tokensKnown === false ? { "tangle.usage.tokens_known": false } : {},
1666
- ...record.tokens.cachedInput !== void 0 ? { "gen_ai.usage.cache_read_input_tokens": record.tokens.cachedInput } : {},
1667
- ...record.tokens.reasoning !== void 0 ? { "gen_ai.usage.reasoning_tokens": record.tokens.reasoning } : {}
1668
- } : {},
1669
- ...typeof record.outcome.success === "boolean" ? { "tangle.outcome.success": record.outcome.success } : {},
1670
- ...typeof record.outcome.score === "number" ? { "tangle.outcome.score": record.outcome.score } : {},
1671
- ...record.error ? {
1672
- "error.type": record.error.code ?? record.error.name,
1673
- "error.message": serializeJson(redactor(record.error.message))
1674
- } : {},
1675
- ...record.runtimeEvents ? { "tangle.runtime.event_count": record.runtimeEvents.length } : {},
1676
- ...record.candidateExecution ? {
1677
- "tangle.candidate.bundle_digest": record.candidateExecution.receipt.bundleDigest,
1678
- "tangle.candidate.experiment_digest": record.candidateExecution.materializationReceipt.executionPlan.material.runCell.experimentDigest,
1679
- "tangle.candidate.execution_id": record.candidateExecution.materializationReceipt.executionPlan.material.executionId,
1680
- "tangle.candidate.execution_plan_digest": record.candidateExecution.receipt.executionPlanDigest,
1681
- "tangle.candidate.materialization_receipt_digest": record.candidateExecution.receipt.materializationReceiptDigest,
1682
- "tangle.candidate.succeeded": record.candidateExecution.receipt.termination.kind === "exit" && record.candidateExecution.receipt.termination.exitCode === 0 && record.candidateExecution.receipt.benchmarkResult.material.passed,
1683
- "tangle.candidate.run_receipt_digest": record.candidateExecution.receipt.digest
1684
- } : {}
1685
- };
1686
- if (record.profile) {
1687
- addPayloadAttributes(labels, "tangle.agent.profile", redactor(record.profile), includeFullPayload);
1688
- if (record.profile.name) labels["gen_ai.agent.name"] = record.profile.name;
1689
- }
1690
- const identity = agentIdentityAttributes({
1691
- ...authoredAgentIdentity(record.profile),
1692
- ...record.harness ? { harness: record.harness } : {}
1693
- });
1694
- const attributed = (span) => withMissingAttributes(span, identity);
1695
- Object.assign(labels, identity);
1696
- const redactedInput = record.input !== void 0 ? redactor(record.input) : void 0;
1697
- const redactedOutput = record.output !== void 0 ? redactor(record.output) : void 0;
1698
- if (redactedInput !== void 0) addPayloadAttributes(labels, "tangle.input", redactedInput, includeFullPayload);
1699
- if (redactedOutput !== void 0) addPayloadAttributes(labels, "tangle.output", redactedOutput, includeFullPayload);
1700
- const now = Date.now();
1701
- const runSpan = flatOtelSpan("tangle.intelligence.run", {
1702
- "tangle.runId": record.runId,
1703
- ...labels,
1704
- [ATTR.spanKind]: "AGENT"
1705
- }, record.traceId, record.timing?.startedAt ?? now, void 0, record.timing?.completedAt ?? now);
1706
- ex.exportSpan(runSpan);
1707
- if (record.runtimeEvents && record.runtimeEvents.length > 0) {
1708
- const spans = buildRuntimeEventOtelSpans(record.runtimeEvents, record.traceId, runSpan.spanId, {
1709
- ...config.runtimeTelemetry,
1710
- redact: redactor
1711
- });
1712
- for (const span of spans) ex.exportSpan(attributed(span));
1713
- }
1714
- if (record.loopEvents && record.loopEvents.length > 0) {
1715
- const spans = buildLoopOtelSpans(record.loopEvents, record.traceId, runSpan.spanId, redactor);
1716
- for (const span of spans) ex.exportSpan(attributed(span));
1717
- }
1771
+ exportRunRecordSpans(ex, exportSettings, record);
1718
1772
  } catch {}
1719
1773
  return record.traceId;
1720
1774
  }
@@ -1758,41 +1812,11 @@ function createIntelligenceClient(config) {
1758
1812
  const ex = getExporter();
1759
1813
  if (!ex || events.length === 0) return traceId;
1760
1814
  try {
1761
- const spans = buildLoopOtelSpans(events, traceId, meta?.rootParentSpanId);
1762
- for (const span of spans) ex.exportSpan(span);
1815
+ exportLoopSpans(ex, events, traceId, meta?.rootParentSpanId);
1763
1816
  } catch {}
1764
1817
  return traceId;
1765
1818
  },
1766
- doctor() {
1767
- const hasRepo = Boolean(config.repo?.owner && config.repo?.name && config.repo?.baseBranch);
1768
- const hasChecks = Boolean(config.checks && config.checks.length > 0);
1769
- const hasSurfaces = Boolean(config.surfaces && config.surfaces.length > 0);
1770
- const prMissing = [];
1771
- if (!hasChecks) prMissing.push("checks");
1772
- if (!hasSurfaces) prMissing.push("surfaces");
1773
- if (!hasRepo) prMissing.push("repo");
1774
- const recommendMissing = [];
1775
- if (intelligenceOff) recommendMissing.push("effort above off");
1776
- return {
1777
- project: config.project,
1778
- effort,
1779
- exportConfigured: Boolean(apiKey),
1780
- modes: {
1781
- observe: {
1782
- ready: true,
1783
- missing: []
1784
- },
1785
- recommend: {
1786
- ready: recommendMissing.length === 0,
1787
- missing: recommendMissing
1788
- },
1789
- pr: {
1790
- ready: prMissing.length === 0,
1791
- missing: prMissing
1792
- }
1793
- }
1794
- };
1795
- },
1819
+ doctor: () => doctorReport(config, effort, apiKey),
1796
1820
  async flush() {
1797
1821
  const ex = getExporter();
1798
1822
  if (!ex) return;
@@ -1805,16 +1829,6 @@ function createIntelligenceClient(config) {
1805
1829
  }
1806
1830
  };
1807
1831
  }
1808
- /** `span` plus each of `attributes` it does not already carry; its own values win. */
1809
- function withMissingAttributes(span, attributes) {
1810
- const present = new Set((span.attributes ?? []).map((attribute) => attribute.key));
1811
- const missing = Object.fromEntries(Object.entries(attributes).filter(([key]) => !present.has(key)));
1812
- if (Object.keys(missing).length === 0) return span;
1813
- return {
1814
- ...span,
1815
- attributes: [...span.attributes ?? [], ...toOtelAttributes(missing)]
1816
- };
1817
- }
1818
1832
  //#endregion
1819
1833
  export { CapabilityNotAdmittedError, agentImprovementProfileDiffs, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, compileEffort, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementActivationResult, createAgentImprovementProposal, createCertifiedPromptSource, createExactProcessCandidateExperimentExecutor, createIntelligenceClient, createOptimizationActivationReceipt, createProtectedExactProcessCandidateExperimentExecutor, defaultRedactor, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, executeAgentImprovementActivation, isAgentImprovementProfileSurface, isAgentProfileMeasuredSurface, isIntelligenceOff, manifestFromProfile, optimizationActivationReceiptFromMetadata, parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization, prepareAgentImprovementProfileActivation, proposeAgentImprovement, proposeAgentProfileImprovement, proposeAuthoredAgentProfileImprovement, pullCertified, resolveEffort, reviewAgentImprovementProposal, runAgentCandidateExperiment, verifyAgentImprovementActivation, verifyAgentImprovementActivationResult, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
1820
1834