@tangle-network/agent-runtime 0.105.0 → 0.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/README.md +2 -2
  2. package/dist/activation-CRjVfOiy.js +203 -0
  3. package/dist/activation-CRjVfOiy.js.map +1 -0
  4. package/dist/activation-DyWB0K6E.d.ts +98 -0
  5. package/dist/agent.d.ts +216 -234
  6. package/dist/agent.js +615 -547
  7. package/dist/agent.js.map +1 -1
  8. package/dist/analyst-loop-DGdtVENg.js +517 -0
  9. package/dist/analyst-loop-DGdtVENg.js.map +1 -0
  10. package/dist/analyst-loop.d.ts +10 -43
  11. package/dist/analyst-loop.js +2 -11
  12. package/dist/backends-Dy8NujB4.js +713 -0
  13. package/dist/backends-Dy8NujB4.js.map +1 -0
  14. package/dist/candidate-execution/index.d.ts +4 -192
  15. package/dist/candidate-execution/index.js +5 -66
  16. package/dist/candidate-execution-DqMbv1rU.js +488 -0
  17. package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
  18. package/dist/coder-yhVWbdWc.js +40 -0
  19. package/dist/coder-yhVWbdWc.js.map +1 -0
  20. package/dist/conversation-XucG_K3l.js +1265 -0
  21. package/dist/conversation-XucG_K3l.js.map +1 -0
  22. package/dist/conversation.d.ts +2 -804
  23. package/dist/conversation.js +2 -55
  24. package/dist/environment-provider-CfLUmKmf.js +1168 -0
  25. package/dist/environment-provider-CfLUmKmf.js.map +1 -0
  26. package/dist/environment-provider-IUGU3epE.d.ts +964 -0
  27. package/dist/environment-provider.d.ts +2 -78
  28. package/dist/environment-provider.js +2 -18
  29. package/dist/errors-DEAvWQPy.js +111 -0
  30. package/dist/errors-DEAvWQPy.js.map +1 -0
  31. package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
  32. package/dist/improvement-cycle-C095kS_g.js +2624 -0
  33. package/dist/improvement-cycle-C095kS_g.js.map +1 -0
  34. package/dist/index-BGdxAwfO.d.ts +838 -0
  35. package/dist/index-C-FYUuFG.d.ts +193 -0
  36. package/dist/index-CbNM40xG.d.ts +140 -0
  37. package/dist/index-DruSKs3Z.d.ts +7224 -0
  38. package/dist/index-Efjb3nrQ.d.ts +671 -0
  39. package/dist/index.d.ts +14 -1058
  40. package/dist/index.js +2106 -2082
  41. package/dist/index.js.map +1 -1
  42. package/dist/intelligence.d.ts +768 -889
  43. package/dist/intelligence.js +1466 -1367
  44. package/dist/intelligence.js.map +1 -1
  45. package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
  46. package/dist/kb-gate-DpaSwXVx.js +80 -0
  47. package/dist/kb-gate-DpaSwXVx.js.map +1 -0
  48. package/dist/knowledge-Ku-mPP4f.js +433 -0
  49. package/dist/knowledge-Ku-mPP4f.js.map +1 -0
  50. package/dist/knowledge.d.ts +2 -150
  51. package/dist/knowledge.js +2 -40
  52. package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
  53. package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
  54. package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
  55. package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
  56. package/dist/loop-runner-bin.d.ts +2 -15
  57. package/dist/loop-runner-bin.js +2 -24
  58. package/dist/loops.d.ts +5 -4164
  59. package/dist/loops.js +8 -419
  60. package/dist/mcp/bin.d.ts +1 -1
  61. package/dist/mcp/bin.js +116 -146
  62. package/dist/mcp/bin.js.map +1 -1
  63. package/dist/mcp/index.d.ts +295 -436
  64. package/dist/mcp/index.js +1242 -1177
  65. package/dist/mcp/index.js.map +1 -1
  66. package/dist/mcp/memory-bin.d.ts +1 -1
  67. package/dist/mcp/memory-bin.js +37 -16
  68. package/dist/mcp/memory-bin.js.map +1 -1
  69. package/dist/memory-server-DL6cE2Ag.js +234 -0
  70. package/dist/memory-server-DL6cE2Ag.js.map +1 -0
  71. package/dist/model-resolution-Btd9iIKV.js +98 -0
  72. package/dist/model-resolution-Btd9iIKV.js.map +1 -0
  73. package/dist/openai-tools-B68JaOCx.d.ts +24 -0
  74. package/dist/openai-tools-CKLy1C7M.js +44 -0
  75. package/dist/openai-tools-CKLy1C7M.js.map +1 -0
  76. package/dist/otel-export-D34IQW1C.js +843 -0
  77. package/dist/otel-export-D34IQW1C.js.map +1 -0
  78. package/dist/platform.d.ts +188 -185
  79. package/dist/platform.js +185 -218
  80. package/dist/platform.js.map +1 -1
  81. package/dist/prepare-B53sPV7M.js +4292 -0
  82. package/dist/prepare-B53sPV7M.js.map +1 -0
  83. package/dist/primeintellect/index.d.ts +149 -145
  84. package/dist/primeintellect/index.js +626 -1003
  85. package/dist/primeintellect/index.js.map +1 -1
  86. package/dist/profiles.d.ts +296 -490
  87. package/dist/profiles.js +722 -749
  88. package/dist/profiles.js.map +1 -1
  89. package/dist/protected-model-port-BLPH5VVv.js +722 -0
  90. package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
  91. package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
  92. package/dist/protected-redaction--F3v1oo8.js +200 -0
  93. package/dist/protected-redaction--F3v1oo8.js.map +1 -0
  94. package/dist/redact-D-u-rrcn.js +82 -0
  95. package/dist/redact-D-u-rrcn.js.map +1 -0
  96. package/dist/redact-kbIOjfjM.d.ts +452 -0
  97. package/dist/researcher-CoVqNhfI.js +433 -0
  98. package/dist/researcher-CoVqNhfI.js.map +1 -0
  99. package/dist/runtime-BG0BziaP.js +5408 -0
  100. package/dist/runtime-BG0BziaP.js.map +1 -0
  101. package/dist/sandbox-events-DeI5xX8P.js +316 -0
  102. package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
  103. package/dist/spawn-journal-CwPvKUTa.js +456 -0
  104. package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
  105. package/dist/structural-rollout-IXUEplky.js +1445 -0
  106. package/dist/structural-rollout-IXUEplky.js.map +1 -0
  107. package/dist/substrate-B0TYNrXn.js +27 -0
  108. package/dist/substrate-B0TYNrXn.js.map +1 -0
  109. package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
  110. package/dist/supervise-BiRutHS9.js +7321 -0
  111. package/dist/supervise-BiRutHS9.js.map +1 -0
  112. package/dist/supervisor-DTKhF-RV.js +3826 -0
  113. package/dist/supervisor-DTKhF-RV.js.map +1 -0
  114. package/dist/testing.d.ts +4 -3
  115. package/dist/testing.js +2478 -2637
  116. package/dist/testing.js.map +1 -1
  117. package/dist/tool-server-RcWgLIsL.js +141 -0
  118. package/dist/tool-server-RcWgLIsL.js.map +1 -0
  119. package/dist/trace-propagation-CJJC7SVB.js +57 -0
  120. package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
  121. package/dist/types-BaIpb0XT.d.ts +492 -0
  122. package/dist/types-BevOjfTY.d.ts +765 -0
  123. package/dist/types-C9j4qg6l.d.ts +500 -0
  124. package/dist/types-Cja5OTGh.d.ts +190 -0
  125. package/dist/util-MVgdwuIS.js +145 -0
  126. package/dist/util-MVgdwuIS.js.map +1 -0
  127. package/dist/workspace-archive-BosQiotA.js +575 -0
  128. package/dist/workspace-archive-BosQiotA.js.map +1 -0
  129. package/package.json +43 -56
  130. package/skills/build-with-agent-runtime/SKILL.md +1 -0
  131. package/dist/activation-Cm-9MMX1.d.ts +0 -69
  132. package/dist/analyst-loop.js.map +0 -1
  133. package/dist/backends-BO4Jqoe2.d.ts +0 -134
  134. package/dist/candidate-execution/index.js.map +0 -1
  135. package/dist/chunk-2KGAN2HM.js +0 -1256
  136. package/dist/chunk-2KGAN2HM.js.map +0 -1
  137. package/dist/chunk-2VZYRB55.js +0 -834
  138. package/dist/chunk-2VZYRB55.js.map +0 -1
  139. package/dist/chunk-3MDZX7YU.js +0 -125
  140. package/dist/chunk-3MDZX7YU.js.map +0 -1
  141. package/dist/chunk-5IBQAPVB.js +0 -29
  142. package/dist/chunk-5IBQAPVB.js.map +0 -1
  143. package/dist/chunk-5QOB7H74.js +0 -387
  144. package/dist/chunk-5QOB7H74.js.map +0 -1
  145. package/dist/chunk-C5RTIBNZ.js +0 -48
  146. package/dist/chunk-C5RTIBNZ.js.map +0 -1
  147. package/dist/chunk-CTRA64LY.js +0 -680
  148. package/dist/chunk-CTRA64LY.js.map +0 -1
  149. package/dist/chunk-DPEUKJRO.js +0 -27
  150. package/dist/chunk-DPEUKJRO.js.map +0 -1
  151. package/dist/chunk-FD2MBMOH.js +0 -494
  152. package/dist/chunk-FD2MBMOH.js.map +0 -1
  153. package/dist/chunk-H5QPIZNX.js +0 -907
  154. package/dist/chunk-H5QPIZNX.js.map +0 -1
  155. package/dist/chunk-HLKC4UYB.js +0 -3514
  156. package/dist/chunk-HLKC4UYB.js.map +0 -1
  157. package/dist/chunk-HNP72PNU.js +0 -192
  158. package/dist/chunk-HNP72PNU.js.map +0 -1
  159. package/dist/chunk-ISPWRSEC.js +0 -408
  160. package/dist/chunk-ISPWRSEC.js.map +0 -1
  161. package/dist/chunk-KRBFHMV6.js +0 -1228
  162. package/dist/chunk-KRBFHMV6.js.map +0 -1
  163. package/dist/chunk-M22PL4GH.js +0 -171
  164. package/dist/chunk-M22PL4GH.js.map +0 -1
  165. package/dist/chunk-NURIQBJQ.js +0 -72
  166. package/dist/chunk-NURIQBJQ.js.map +0 -1
  167. package/dist/chunk-OPVWXJ2H.js +0 -75
  168. package/dist/chunk-OPVWXJ2H.js.map +0 -1
  169. package/dist/chunk-PZZKQVQV.js +0 -52
  170. package/dist/chunk-PZZKQVQV.js.map +0 -1
  171. package/dist/chunk-Q2JSAVQ3.js +0 -671
  172. package/dist/chunk-Q2JSAVQ3.js.map +0 -1
  173. package/dist/chunk-RDOAVVHY.js +0 -699
  174. package/dist/chunk-RDOAVVHY.js.map +0 -1
  175. package/dist/chunk-SGKPNBXE.js +0 -60
  176. package/dist/chunk-SGKPNBXE.js.map +0 -1
  177. package/dist/chunk-SMQXZGLZ.js +0 -351
  178. package/dist/chunk-SMQXZGLZ.js.map +0 -1
  179. package/dist/chunk-UHEZW5BU.js +0 -2918
  180. package/dist/chunk-UHEZW5BU.js.map +0 -1
  181. package/dist/chunk-UPWGXKXB.js +0 -254
  182. package/dist/chunk-UPWGXKXB.js.map +0 -1
  183. package/dist/chunk-VISA6CI3.js +0 -200
  184. package/dist/chunk-VISA6CI3.js.map +0 -1
  185. package/dist/chunk-WMTCUOQL.js +0 -474
  186. package/dist/chunk-WMTCUOQL.js.map +0 -1
  187. package/dist/chunk-WRTOVNN4.js +0 -4728
  188. package/dist/chunk-WRTOVNN4.js.map +0 -1
  189. package/dist/chunk-WSTRQZYQ.js +0 -5576
  190. package/dist/chunk-WSTRQZYQ.js.map +0 -1
  191. package/dist/chunk-XBG2W2VW.js +0 -6434
  192. package/dist/chunk-XBG2W2VW.js.map +0 -1
  193. package/dist/chunk-YEJR7IXO.js +0 -68
  194. package/dist/chunk-YEJR7IXO.js.map +0 -1
  195. package/dist/chunk-YJZA2BIK.js +0 -1338
  196. package/dist/chunk-YJZA2BIK.js.map +0 -1
  197. package/dist/completion-gate-BMy5LGoP.d.ts +0 -256
  198. package/dist/conversation.js.map +0 -1
  199. package/dist/coordination-BZZSVYpZ.d.ts +0 -2570
  200. package/dist/environment-provider.js.map +0 -1
  201. package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
  202. package/dist/knowledge.js.map +0 -1
  203. package/dist/local-harness-BDNcl6jI.d.ts +0 -175
  204. package/dist/loop-runner-bin-68aoM9-7.d.ts +0 -199
  205. package/dist/loop-runner-bin.js.map +0 -1
  206. package/dist/loops.js.map +0 -1
  207. package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
  208. package/dist/protected-model-port-B4t-OQjL.d.ts +0 -271
  209. package/dist/redact-BuFjxBUJ.d.ts +0 -481
  210. package/dist/sanitize-DEbPNtyI.d.ts +0 -328
  211. package/dist/structural-rollout-DEh6CEsa.d.ts +0 -446
  212. package/dist/supervise-4_48wwvy.d.ts +0 -379
  213. package/dist/types-BCoemcXU.d.ts +0 -802
  214. package/dist/types-BwoZWq-i.d.ts +0 -510
  215. package/dist/types-Cbp72qyu.d.ts +0 -491
  216. package/dist/types-CmYCMbFT.d.ts +0 -203
  217. package/dist/types-CvNwMzQt.d.ts +0 -957
  218. package/dist/worktree-fanout-DxhAWr5Z.d.ts +0 -999
@@ -1,27 +1,19 @@
1
- import { AgentProfileDiff, AgentProfile, AgentImprovementProposal, AgentProfileMcpServer, AgentImprovementActivationTarget, Sha256Digest, AgentImprovementSurface, AgentCandidateExperiment, AgentImprovementActivationIntent, AgentCandidateExperimentMaterial, AgentImprovementMeasuredComparison, AgentCandidateExperimentMeasurement, AgentImprovementReviewDecision, AgentCandidateBenchmarkCellRef, AgentImprovementReview, AgentImprovementActivation, CandidateExecutionEvidence, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition } from '@tangle-network/agent-interface';
2
- export { AgentImprovementActivation, AgentImprovementActivationIntent, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementMeasuredComparison, AgentImprovementProposal, AgentImprovementReview, AgentImprovementReviewDecision, CandidateExecutionEvidence, AgentCandidateProfileActivation as CandidateProfileMaterialization } from '@tangle-network/agent-interface';
3
- import { I as ImproveOptions, a as ImproveResult, b as ImproveMethodResult, R as Redactor } from './redact-BuFjxBUJ.js';
4
- export { d as defaultRedactor, r as resolveRedactor } from './redact-BuFjxBUJ.js';
5
- import { c as LoopTraceEvent } from './types-BCoemcXU.js';
6
- import { b as ToolSpec, c as RuntimeTelemetryOptions } from './sanitize-DEbPNtyI.js';
7
- import { R as RuntimeStreamEvent } from './types-BwoZWq-i.js';
8
- import { P as PrepareAgentCandidateExecutionOptions, E as ExecutePreparedAgentCandidateOptions, A as AgentCandidateExecutionClaimStore, C as CreateProtectedAgentCandidateModelPortOptions } from './protected-model-port-B4t-OQjL.js';
9
- export { p as parseCandidateProfileMaterialization } from './protected-model-port-B4t-OQjL.js';
10
- import { A as AgentImprovementActivationTargetPlan } from './activation-Cm-9MMX1.js';
11
- export { a as AgentImprovementActivationReconciliation, b as AgentImprovementActivationResultStore, c as AgentImprovementActivationTransition, d as AgentImprovementActivationTransitionInput, C as CreateAgentImprovementActivationResultOptions, E as ExecuteAgentImprovementActivationInput, e as ExecuteAgentImprovementActivationOptions, f as createAgentImprovementActivationResult, g as executeAgentImprovementActivation, v as verifyAgentImprovementActivationResult } from './activation-Cm-9MMX1.js';
12
- import { TraceStore } from '@tangle-network/agent-eval';
13
- import { CandidateExperimentExecutionInput, Scenario, CompareCandidateExperimentOptions } from '@tangle-network/agent-eval/contract';
14
- import { AgentExactProcessResources } from '@tangle-network/agent-interface/environment-provider';
15
- import { c as AgentCandidateRunFinalization, d as AgentCandidateTaskExecution, e as AgentCandidateExecutionPorts, a as AgentCandidateBenchmarkGraderPort, b as AgentCandidateOutputArtifactPort, A as AgentCandidateExecutorPort } from './types-Cbp72qyu.js';
16
- import { AgentEnvironmentProviderRef, AgentEnvironmentProviderRegistry } from './environment-provider.js';
17
- import { AnalystFinding } from '@tangle-network/agent-eval/analyst';
18
- import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-CmYCMbFT.js';
19
- import { OptimizationPackageSource, OptimizationMethodComparison, OptimizationTokenUsage } from '@tangle-network/agent-eval/campaign';
20
- import './local-harness-BDNcl6jI.js';
21
- import 'node:child_process';
22
- import '@tangle-network/sandbox';
23
- import './types-CvNwMzQt.js';
24
-
1
+ import { x as RuntimeStreamEvent } from "./types-C9j4qg6l.js";
2
+ import { d as RunAnalystLoopOpts, f as RunAnalystLoopResult } from "./types-Cja5OTGh.js";
3
+ import { b as LoopTraceEvent } from "./types-BevOjfTY.js";
4
+ import { a as AgentEnvironmentProviderRef, o as AgentEnvironmentProviderRegistry } from "./environment-provider-IUGU3epE.js";
5
+ import { D as RuntimeTelemetryOptions, m as ToolSpec } from "./local-harness-Dh8PJ0ot.js";
6
+ import { h as ExecutePreparedAgentCandidateOptions, o as CreateProtectedAgentCandidateModelPortOptions, p as PrepareAgentCandidateExecutionOptions, u as parseAgentCandidateProfileActivation, x as AgentCandidateExecutionClaimStore } from "./protected-model-port-BP6Z4eau.js";
7
+ import { D as AgentCandidateTaskExecution, E as AgentCandidateRunFinalization, a as AgentCandidateExecutionPorts, c as AgentCandidateExecutorPort, r as AgentCandidateBenchmarkGraderPort, y as AgentCandidateOutputArtifactPort } from "./types-BaIpb0XT.js";
8
+ import { S as ImproveResult, h as ImproveMethodResult, n as defaultRedactor, r as resolveRedactor, t as Redactor, v as ImproveOptions } from "./redact-kbIOjfjM.js";
9
+ import { a as AgentImprovementActivationTransitionInput, c as CreateAgentImprovementActivationResultOptions, d as ProfileImprovementActivationTransitionInput, f as SealedCandidateActivationTransitionInput, h as verifyAgentImprovementActivationResult, i as AgentImprovementActivationTransition, l as ExecuteAgentImprovementActivationInput, m as executeAgentImprovementActivation, n as AgentImprovementActivationResultStore, o as AgentProfileImprovementActivationOperation, p as createAgentImprovementActivationResult, r as AgentImprovementActivationTargetPlan, s as AgentProfileImprovementActivationTargetPlan, t as AgentImprovementActivationReconciliation, u as ExecuteAgentImprovementActivationOptions } from "./activation-DyWB0K6E.js";
10
+ import { TraceStore } from "@tangle-network/agent-eval";
11
+ import { OptimizationMethodComparison, OptimizationPackageSource, OptimizationTokenUsage } from "@tangle-network/agent-eval/campaign";
12
+ import { AgentCandidateBenchmarkCellRef, AgentCandidateBundle, AgentCandidateExperiment, AgentCandidateExperimentMaterial, AgentCandidateExperimentMeasurement, AgentCandidateProfileActivation as CandidateProfileMaterialization, AgentImprovementActivation, AgentImprovementActivation as AgentImprovementActivation$1, AgentImprovementActivationIntent, AgentImprovementActivationIntent as AgentImprovementActivationIntent$1, AgentImprovementActivationOutcome, AgentImprovementActivationResult, AgentImprovementActivationTarget, AgentImprovementActivationTargetState, AgentImprovementActivationTargetTransition, AgentImprovementEvaluation, AgentImprovementEvaluation as AgentImprovementEvaluation$1, AgentImprovementMeasuredComparison, AgentImprovementMeasuredComparison as AgentImprovementMeasuredComparison$1, AgentImprovementProposal, AgentImprovementProposal as AgentImprovementProposal$1, AgentImprovementReview, AgentImprovementReview as AgentImprovementReview$1, AgentImprovementReviewDecision, AgentImprovementReviewDecision as AgentImprovementReviewDecision$1, AgentImprovementSurface, AgentProfile as AgentProfile$1, AgentProfileDiff, AgentProfileImprovementChange, AgentProfileImprovementExperiment, AgentProfileMcpServer, CandidateExecutionEvidence, CandidateExecutionEvidence as CandidateExecutionEvidence$1, Sha256Digest } from "@tangle-network/agent-interface";
13
+ import { CandidateExperimentExecutionInput, CompareCandidateExperimentOptions, Scenario as Scenario$1 } from "@tangle-network/agent-eval/contract";
14
+ import { AnalystFinding as AnalystFinding$1 } from "@tangle-network/agent-eval/analyst";
15
+ import { AgentExactProcessResources } from "@tangle-network/agent-interface/environment-provider";
16
+ //#region src/intelligence/effort.d.ts
25
17
  /**
26
18
  *
27
19
  * EffortPolicy — pure data, no execution. Resolves a named tier into a flat
@@ -51,21 +43,21 @@ type CorpusAccess = 'off' | 'read' | 'read-write';
51
43
  * self-executing.
52
44
  */
53
45
  interface EffortSettings {
54
- /** Whether trace-derived analyst diagnosis may spawn. `false` ⇒ no analyst. */
55
- analysts: boolean;
56
- /** Cross-run corpus access this tier permits. */
57
- corpus: CorpusAccess;
58
- /** Parallel candidate width. `1` ⇒ single-shot, no breadth. */
59
- fanout: number;
60
- /** Whether multi-step improvement loops (refine / fanout-vote) may run. */
61
- loops: boolean;
62
- /**
63
- * Ceiling, in USD, for INTELLIGENCE-class spawns only (analysts, corpus,
64
- * loops) — NOT base inference. `0` refuses every intelligence spawn; `null`
65
- * means uncapped (the spend lands on the Pareto receipt). Base-stream
66
- * inference is billed on its own channel and is never constrained here.
67
- */
68
- intelligenceBudgetUsd: number | null;
46
+ /** Whether trace-derived analyst diagnosis may spawn. `false` ⇒ no analyst. */
47
+ analysts: boolean;
48
+ /** Cross-run corpus access this tier permits. */
49
+ corpus: CorpusAccess;
50
+ /** Parallel candidate width. `1` ⇒ single-shot, no breadth. */
51
+ fanout: number;
52
+ /** Whether multi-step improvement loops (refine / fanout-vote) may run. */
53
+ loops: boolean;
54
+ /**
55
+ * Ceiling, in USD, for INTELLIGENCE-class spawns only (analysts, corpus,
56
+ * loops) — NOT base inference. `0` refuses every intelligence spawn; `null`
57
+ * means uncapped (the spend lands on the Pareto receipt). Base-stream
58
+ * inference is billed on its own channel and is never constrained here.
59
+ */
60
+ intelligenceBudgetUsd: number | null;
69
61
  }
70
62
  /** Per-field overrides applied on top of a tier preset. Any subset of the
71
63
  * resolved settings; each provided field wins over the preset. */
@@ -113,14 +105,14 @@ declare function isIntelligenceOff(settings: EffortSettings): boolean;
113
105
  * the billing clamp (passed verbatim; `0` refuses every intelligence spawn).
114
106
  */
115
107
  interface EffortOverridesCompiled {
116
- /** Construct + pass a `ScopeAnalyst`? `false` ⇒ omit it (degrade to the base agent). */
117
- withAnalyst: boolean;
118
- /** `ShapeBudget.fanout` width to pass to `runPersonified`. */
119
- fanout: number;
120
- /** Run the multi-step improvement cycle, or no-op it for this run? */
121
- withLoops: boolean;
122
- /** Intelligence-class spend ceiling. `0` refuses every intelligence spawn; `null` uncapped. */
123
- intelligenceBudgetUsd: number | null;
108
+ /** Construct + pass a `ScopeAnalyst`? `false` ⇒ omit it (degrade to the base agent). */
109
+ withAnalyst: boolean;
110
+ /** `ShapeBudget.fanout` width to pass to `runPersonified`. */
111
+ fanout: number;
112
+ /** Run the multi-step improvement cycle, or no-op it for this run? */
113
+ withLoops: boolean;
114
+ /** Intelligence-class spend ceiling. `0` refuses every intelligence spawn; `null` uncapped. */
115
+ intelligenceBudgetUsd: number | null;
124
116
  }
125
117
  /**
126
118
  * Compile resolved `EffortSettings` into the orchestration overrides above. Pure: same
@@ -134,60 +126,33 @@ interface EffortOverridesCompiled {
134
126
  * compile to `withAnalyst: true`, the tier's `fanout`, and `withLoops: true`.
135
127
  */
136
128
  declare function compileEffort(settings: EffortSettings): EffortOverridesCompiled;
137
-
138
- /**
139
- *
140
- * Tangle Intelligence — the RECEIVE half of the loop (pull-by-default).
141
- *
142
- * The sibling Observe path (`./index`) sends run records UP to the plane. This
143
- * module pulls certified artifacts DOWN: it reads the tenant's promoted,
144
- * gate-certified profile from the deployed Intelligence plane so an approved
145
- * improvement actually reaches the running agent. The pull carries three things
146
- * the plane already composes:
147
- * - the certified PROMPT surface + prompt-folding artifacts (delivered into the
148
- * system prompt via {@link composeCertifiedPrompt} — the promoted prompt);
149
- * - the typed profile DIFFS the plane has promoted, each with its held-out
150
- * provenance (surfaced as PROPOSALS — never auto-applied at runtime);
151
- * - the composed `agentProfile` those diffs fold to, for inspection.
152
- *
153
- * Pull contract (deployed plane): GET /v1/profiles/:target/composed →
154
- * { target, generatedAt,
155
- * promptSurface: {surface,surfaceHash,version,lift}|null,
156
- * artifacts: { <artifactType>: [{path,content,contentHash,version,lift,promotedAt}] },
157
- * capabilities: [{id,iface:{surface},binding:{path,content},provenance}],
158
- * agentProfileDiffs: [{diff, provenance:{version,lift,contentHash,promotedAt}}],
159
- * agentProfile: AgentProfile|null }
160
- * Auth: Bearer <apiKey> (the one TANGLE_API_KEY shared by router + sandbox +
161
- * intelligence), resolved to a tenant by platform-api's key-verify S2S contract.
162
- *
163
- * @experimental
164
- */
165
-
129
+ //#endregion
130
+ //#region src/intelligence/delivery.d.ts
166
131
  /** A promoted, certified artifact (one entry in the composed profile). */
167
132
  interface CertifiedArtifact {
168
- path: string | null;
169
- content: string;
170
- contentHash: string;
171
- version: number | null;
172
- /** Held-out gate lift attached at certification, e.g. "+3.1pp" — never a
173
- * within-run claim. `null` when the promotion carried no lift record. */
174
- lift: string | null;
175
- promotedAt: string;
133
+ path: string | null;
134
+ content: string;
135
+ contentHash: string;
136
+ version: number | null;
137
+ /** Held-out gate lift attached at certification, e.g. "+3.1pp" — never a
138
+ * within-run claim. `null` when the promotion carried no lift record. */
139
+ lift: string | null;
140
+ promotedAt: string;
176
141
  }
177
142
  /** The active promoted prompt surface for a target. */
178
143
  interface CertifiedPromptSurface {
179
- surface: string;
180
- surfaceHash: string;
181
- version: number | null;
182
- lift: string | null;
144
+ surface: string;
145
+ surfaceHash: string;
146
+ version: number | null;
147
+ lift: string | null;
183
148
  }
184
149
  /** The held-out provenance the plane's certify step stamps on a promoted diff.
185
150
  * `lift` is the held-out gate lift (e.g. "+3.1pp"), never a within-run claim. */
186
151
  interface DiffProvenance {
187
- version: number | null;
188
- lift: string | null;
189
- contentHash: string;
190
- promotedAt: string;
152
+ version: number | null;
153
+ lift: string | null;
154
+ contentHash: string;
155
+ promotedAt: string;
191
156
  }
192
157
  /**
193
158
  * A gate-certified profile diff the plane has already promoted, plus the
@@ -197,61 +162,61 @@ interface DiffProvenance {
197
162
  * into a shipped profile. It is NEVER auto-applied at runtime.
198
163
  */
199
164
  interface ProposedProfileDiff {
200
- diff: AgentProfileDiff;
201
- provenance: DiffProvenance;
165
+ diff: AgentProfileDiff;
166
+ provenance: DiffProvenance;
202
167
  }
203
168
  /** The composed endpoint's per-capability summary — the narrow shape on the
204
169
  * wire (id + surface + path/content + provenance). Distinct from the richer
205
170
  * `CertifiedCapability` the capability resolver lowers a manifest into. */
206
171
  interface CertifiedCapabilitySummary {
207
- id: string;
208
- iface: {
209
- surface: string;
210
- };
211
- binding: {
212
- path: string | null;
213
- content: string;
214
- };
215
- provenance: DiffProvenance;
172
+ id: string;
173
+ iface: {
174
+ surface: string;
175
+ };
176
+ binding: {
177
+ path: string | null;
178
+ content: string;
179
+ };
180
+ provenance: DiffProvenance;
216
181
  }
217
182
  /** The composed certified profile — exactly the shape the plane's
218
183
  * `GET /v1/profiles/:target/composed` returns. */
219
184
  interface CertifiedProfile {
220
- target: string;
221
- generatedAt: string;
222
- promptSurface: CertifiedPromptSurface | null;
223
- artifacts: Record<string, CertifiedArtifact[]>;
224
- /** The typed profile diffs the plane has promoted, each with held-out
225
- * provenance. Surfaced as proposals; never auto-applied. Empty when none. */
226
- agentProfileDiffs: ProposedProfileDiff[];
227
- /** The composed capability summaries the plane returns. Empty when none. */
228
- capabilities: CertifiedCapabilitySummary[];
229
- /** The composed profile the promoted diffs fold to, for inspection. `null`
230
- * when no diffs are promoted. */
231
- agentProfile: AgentProfile | null;
185
+ target: string;
186
+ generatedAt: string;
187
+ promptSurface: CertifiedPromptSurface | null;
188
+ artifacts: Record<string, CertifiedArtifact[]>;
189
+ /** The typed profile diffs the plane has promoted, each with held-out
190
+ * provenance. Surfaced as proposals; never auto-applied. Empty when none. */
191
+ agentProfileDiffs: ProposedProfileDiff[];
192
+ /** The composed capability summaries the plane returns. Empty when none. */
193
+ capabilities: CertifiedCapabilitySummary[];
194
+ /** The composed profile the promoted diffs fold to, for inspection. `null`
195
+ * when no diffs are promoted. */
196
+ agentProfile: AgentProfile$1 | null;
232
197
  }
233
198
  /** Typed outcome for the pull — inspect `succeeded` before `value`. A 404
234
199
  * (nothing promoted yet) is a normal, non-error `succeeded: false`. */
235
200
  type PullOutcome = {
236
- succeeded: true;
237
- value: CertifiedProfile;
201
+ succeeded: true;
202
+ value: CertifiedProfile;
238
203
  } | {
239
- succeeded: false;
240
- error: string;
241
- status?: number;
204
+ succeeded: false;
205
+ error: string;
206
+ status?: number;
242
207
  };
243
208
  interface PullCertifiedOptions {
244
- /** The agent target certified artifacts are promoted under. */
245
- target: string;
246
- /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
247
- apiKey?: string;
248
- /** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
249
- * `https://intelligence.tangle.tools`. */
250
- baseUrl?: string;
251
- /** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
252
- fetchImpl?: typeof fetch;
253
- /** Abort the request after this many ms. Default 10000. */
254
- timeoutMs?: number;
209
+ /** The agent target certified artifacts are promoted under. */
210
+ target: string;
211
+ /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
212
+ apiKey?: string;
213
+ /** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
214
+ * `https://intelligence.tangle.tools`. */
215
+ baseUrl?: string;
216
+ /** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
217
+ fetchImpl?: typeof fetch;
218
+ /** Abort the request after this many ms. Default 10000. */
219
+ timeoutMs?: number;
255
220
  }
256
221
  /** What Runtime knows about a failed proposal submission.
257
222
  * `not-sent` means no request began, `rejected` means Intelligence returned a
@@ -260,29 +225,29 @@ interface PullCertifiedOptions {
260
225
  type AgentImprovementProposalSubmissionState = 'not-sent' | 'rejected' | 'unconfirmed';
261
226
  /** Submit a completed measured proposal for product-side review. */
262
227
  interface SubmitAgentImprovementProposalOptions {
263
- proposal: AgentImprovementProposal;
264
- /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
265
- apiKey?: string;
266
- /** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
267
- * `https://intelligence.tangle.tools`. */
268
- baseUrl?: string;
269
- /** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
270
- fetchImpl?: typeof fetch;
271
- /** Abort the request after this many ms. Default 10000. */
272
- timeoutMs?: number;
228
+ proposal: AgentImprovementProposal$1;
229
+ /** Bearer key. Defaults to `process.env.TANGLE_API_KEY`. */
230
+ apiKey?: string;
231
+ /** Plane base URL. Defaults to `process.env.TANGLE_INTELLIGENCE_URL` then
232
+ * `https://intelligence.tangle.tools`. */
233
+ baseUrl?: string;
234
+ /** fetch impl (tests / non-global-fetch runtimes). Defaults to global fetch. */
235
+ fetchImpl?: typeof fetch;
236
+ /** Abort the request after this many ms. Default 10000. */
237
+ timeoutMs?: number;
273
238
  }
274
239
  /** Typed result for proposal submission. A successful result contains the
275
240
  * exact immutable proposal Intelligence recorded. */
276
241
  type SubmitAgentImprovementProposalOutcome = {
277
- succeeded: true;
278
- value: AgentImprovementProposal;
279
- status: number;
242
+ succeeded: true;
243
+ value: AgentImprovementProposal$1;
244
+ status: number;
280
245
  } | {
281
- succeeded: false;
282
- submission: AgentImprovementProposalSubmissionState;
283
- error: string;
284
- status?: number;
285
- code?: string;
246
+ succeeded: false;
247
+ submission: AgentImprovementProposalSubmissionState;
248
+ error: string;
249
+ status?: number;
250
+ code?: string;
286
251
  };
287
252
  /** Resolve the ONE Intelligence base URL — the single knob both the send and
288
253
  * receive paths derive from. Env fallback: `TANGLE_INTELLIGENCE_URL`. */
@@ -326,19 +291,19 @@ declare function composeCertifiedPrompt(base: string, certified: Pick<CertifiedP
326
291
  * `refreshMs`, coalesces concurrent pulls, keeps the last-known profile on a
327
292
  * failed/404 pull, never throws, never blocks past the pull timeout. */
328
293
  interface CertifiedPromptSource {
329
- /** Refresh (window-respecting) then fold the certified additions into a
330
- * base system prompt. Returns `base` unchanged when nothing is promoted. */
331
- compose(base: string): Promise<string>;
332
- /** The certified profile currently in effect (`null` = none pulled yet). */
333
- current(): CertifiedProfile | null;
334
- /** Pull now if the refresh window has elapsed; coalesced and fail-closed. */
335
- refresh(): Promise<void>;
294
+ /** Refresh (window-respecting) then fold the certified additions into a
295
+ * base system prompt. Returns `base` unchanged when nothing is promoted. */
296
+ compose(base: string): Promise<string>;
297
+ /** The certified profile currently in effect (`null` = none pulled yet). */
298
+ current(): CertifiedProfile | null;
299
+ /** Pull now if the refresh window has elapsed; coalesced and fail-closed. */
300
+ refresh(): Promise<void>;
336
301
  }
337
302
  /** Options for {@link createCertifiedPromptSource} — the pull coordinates plus
338
303
  * the refresh cadence. */
339
304
  interface CertifiedPromptSourceOptions extends PullCertifiedOptions {
340
- /** Min interval between certified-profile pulls. Default 5m. */
341
- refreshMs?: number;
305
+ /** Min interval between certified-profile pulls. Default 5m. */
306
+ refreshMs?: number;
342
307
  }
343
308
  /**
344
309
  * Create the cached certified-prompt source — the ONE module-scope-cache +
@@ -347,35 +312,8 @@ interface CertifiedPromptSourceOptions extends PullCertifiedOptions {
347
312
  * `withIntelligence` hook rides this same source for its prompt delivery.
348
313
  */
349
314
  declare function createCertifiedPromptSource(opts: CertifiedPromptSourceOptions): CertifiedPromptSource;
350
-
351
- /**
352
- *
353
- * The Capability-Delivery Manifest — the unified, future-proof structure for
354
- * delivering ONE certified unit of agent power = `{ interface, binding }`.
355
- *
356
- * The law that makes it future-proof: **interfaces are closed; bindings are
357
- * open.** The interface is the only thing the agent and the certify lane ever
358
- * reason about (a tool / an MCP toolset / a prompt-context / a retrieval surface
359
- * / a hook / a subagent). The binding is a tagged union over runtime kinds that
360
- * the resolver collapses (inline / file / http / sandbox-code / mcp-stdio /
361
- * mcp-remote / process-on-infra / rag-index / memory-store / wasm / a2a). A new
362
- * runtime kind = one new binding arm + one resolver case; nothing else moves.
363
- *
364
- * This module owns the manifest TYPES and the lowering of TODAY's wire
365
- * (`CertifiedProfile`) into a `CapabilityManifest`. The resolver — the single
366
- * place that knows binding kinds and produces a uniform `ResolvedSurface` — lives
367
- * in `./resolver`. The shipped prompt-only path (`composeCertifiedPrompt` in
368
- * `./delivery`) is preserved verbatim: a prompt is a `Capability{ surface:
369
- * 'context', binding:{ kind:'inline' } }`, so the existing
370
- * `pullCertified → composeCertifiedPrompt → fail-closed` lane is a strict subset.
371
- *
372
- * Layering: this depends DOWN on `@tangle-network/sandbox` (the SDK
373
- * `AgentProfileMcpServer` shape the mcp binding lowers to) and on the runtime's
374
- * own `ToolSpec`. It never imports agent-eval and never reaches upward.
375
- *
376
- * @experimental
377
- */
378
-
315
+ //#endregion
316
+ //#region src/intelligence/capability.d.ts
379
317
  /** A JSON Schema object describing a tool's parameters. Kept structural — the
380
318
  * resolver forwards it verbatim into a `ToolSpec` / MCP `tools/list` check. */
381
319
  type JsonSchema = Record<string, unknown>;
@@ -384,32 +322,32 @@ type JsonSchema = Record<string, unknown>;
384
322
  * arm maps slot-for-slot onto `AgentProfile` + the host `RouterToolsSeam`.
385
323
  */
386
324
  type CapabilityInterface = {
387
- surface: 'tool';
388
- name: string;
389
- description?: string;
390
- parameters: JsonSchema;
391
- returns?: JsonSchema;
325
+ surface: 'tool';
326
+ name: string;
327
+ description?: string;
328
+ parameters: JsonSchema;
329
+ returns?: JsonSchema;
392
330
  } | {
393
- surface: 'mcp';
394
- serverName: string;
395
- toolset?: string[];
331
+ surface: 'mcp';
332
+ serverName: string;
333
+ toolset?: string[];
396
334
  } | {
397
- surface: 'context';
398
- kind: 'prompt-surface' | 'skill' | 'instructions';
399
- name: string;
335
+ surface: 'context';
336
+ kind: 'prompt-surface' | 'skill' | 'instructions';
337
+ name: string;
400
338
  } | {
401
- surface: 'retrieval';
402
- name: string;
403
- description?: string;
404
- topK?: number;
339
+ surface: 'retrieval';
340
+ name: string;
341
+ description?: string;
342
+ topK?: number;
405
343
  } | {
406
- surface: 'hook';
407
- event: string;
408
- matcher?: string;
344
+ surface: 'hook';
345
+ event: string;
346
+ matcher?: string;
409
347
  } | {
410
- surface: 'subagent';
411
- name: string;
412
- description?: string;
348
+ surface: 'subagent';
349
+ name: string;
350
+ description?: string;
413
351
  };
414
352
  /** Every interface surface tag — the closed set the resolver fans into slots. */
415
353
  type CapabilitySurface = CapabilityInterface['surface'];
@@ -418,22 +356,22 @@ type CapabilitySurface = CapabilityInterface['surface'];
418
356
  * no inlined blob: `github`/`blob` are pointers resolved at provision time.
419
357
  */
420
358
  type ContentRef = {
421
- kind: 'inline';
422
- content: string;
359
+ kind: 'inline';
360
+ content: string;
423
361
  } | {
424
- kind: 'github';
425
- repository?: string;
426
- path: string;
427
- ref?: string;
362
+ kind: 'github';
363
+ repository?: string;
364
+ path: string;
365
+ ref?: string;
428
366
  } | {
429
- kind: 'blob';
430
- uri: string;
431
- sha256: string;
432
- bytes?: number;
367
+ kind: 'blob';
368
+ uri: string;
369
+ sha256: string;
370
+ bytes?: number;
433
371
  };
434
372
  /** A named secret a binding requires — declared, never carried. */
435
373
  interface CredentialRef {
436
- key: string;
374
+ key: string;
437
375
  }
438
376
  /**
439
377
  * How a binding authenticates at resolve time. Declared as a REQUIREMENT in the
@@ -441,16 +379,16 @@ interface CredentialRef {
441
379
  * never inlined here.
442
380
  */
443
381
  type CapabilityAuth = {
444
- mode: 'none';
382
+ mode: 'none';
445
383
  } | {
446
- mode: 'tangle-key';
384
+ mode: 'tangle-key';
447
385
  } | {
448
- mode: 'hub-connection';
449
- providerId: string;
450
- scopes?: string[];
386
+ mode: 'hub-connection';
387
+ providerId: string;
388
+ scopes?: string[];
451
389
  } | {
452
- mode: 'secret-ref';
453
- key: string;
390
+ mode: 'secret-ref';
391
+ key: string;
454
392
  };
455
393
  /**
456
394
  * The host a `process-on-infra` binding provisions before its inner binding.
@@ -459,12 +397,12 @@ type CapabilityAuth = {
459
397
  * cost; `ports` are the inner server's listen ports the host must expose.
460
398
  */
461
399
  interface HostSpec {
462
- backend: 'sandbox' | 'router' | 'cli';
463
- image?: string;
464
- ports?: number[];
465
- warm?: boolean;
466
- idleTtlMs?: number;
467
- costTag?: string;
400
+ backend: 'sandbox' | 'router' | 'cli';
401
+ image?: string;
402
+ ports?: number[];
403
+ warm?: boolean;
404
+ idleTtlMs?: number;
405
+ costTag?: string;
468
406
  }
469
407
  /**
470
408
  * How a capability is backed. OPEN tagged union — THE extension point. All arms
@@ -472,57 +410,57 @@ interface HostSpec {
472
410
  * throws {@link CapabilityNotAdmittedError} at resolve, never silently no-ops.
473
411
  */
474
412
  type DeliveryBinding = {
475
- kind: 'inline';
476
- content: ContentRef;
413
+ kind: 'inline';
414
+ content: ContentRef;
477
415
  } | {
478
- kind: 'file';
479
- path: string;
480
- content: ContentRef;
481
- executable?: boolean;
416
+ kind: 'file';
417
+ path: string;
418
+ content: ContentRef;
419
+ executable?: boolean;
482
420
  } | {
483
- kind: 'http';
484
- url: string;
485
- method?: string;
486
- auth?: CapabilityAuth;
421
+ kind: 'http';
422
+ url: string;
423
+ method?: string;
424
+ auth?: CapabilityAuth;
487
425
  } | {
488
- kind: 'sandbox-code';
489
- entry: string;
490
- code: ContentRef;
491
- runtime?: string;
492
- harness?: string;
426
+ kind: 'sandbox-code';
427
+ entry: string;
428
+ code: ContentRef;
429
+ runtime?: string;
430
+ harness?: string;
493
431
  } | {
494
- kind: 'mcp-stdio';
495
- command: string;
496
- args?: string[];
497
- env?: Record<string, string>;
498
- cwd?: string;
432
+ kind: 'mcp-stdio';
433
+ command: string;
434
+ args?: string[];
435
+ env?: Record<string, string>;
436
+ cwd?: string;
499
437
  } | {
500
- kind: 'mcp-remote';
501
- url: string;
502
- transport: 'http' | 'sse';
503
- headers?: Record<string, string>;
438
+ kind: 'mcp-remote';
439
+ url: string;
440
+ transport: 'http' | 'sse';
441
+ headers?: Record<string, string>;
504
442
  } | {
505
- kind: 'process-on-infra';
506
- host: HostSpec;
507
- inner: DeliveryBinding;
443
+ kind: 'process-on-infra';
444
+ host: HostSpec;
445
+ inner: DeliveryBinding;
508
446
  } | {
509
- kind: 'rag-index';
510
- index: ContentRef;
511
- embedModel: string;
512
- topK?: number;
447
+ kind: 'rag-index';
448
+ index: ContentRef;
449
+ embedModel: string;
450
+ topK?: number;
513
451
  } | {
514
- kind: 'memory-store';
515
- provision: 'sqlite' | 'neo4j' | 'vector';
516
- seed?: ContentRef;
452
+ kind: 'memory-store';
453
+ provision: 'sqlite' | 'neo4j' | 'vector';
454
+ seed?: ContentRef;
517
455
  } | {
518
- kind: 'wasm';
519
- module: ContentRef;
520
- exports: string[];
456
+ kind: 'wasm';
457
+ module: ContentRef;
458
+ exports: string[];
521
459
  } | {
522
- kind: 'a2a';
523
- endpoint: string;
524
- card: ContentRef;
525
- auth?: CapabilityAuth;
460
+ kind: 'a2a';
461
+ endpoint: string;
462
+ card: ContentRef;
463
+ auth?: CapabilityAuth;
526
464
  };
527
465
  /** Every binding kind — the open set the resolver dispatches over. */
528
466
  type DeliveryBindingKind = DeliveryBinding['kind'];
@@ -540,19 +478,19 @@ type DeliveryBindingKind = DeliveryBinding['kind'];
540
478
  * mix of null-path and non-null-path artifacts.
541
479
  */
542
480
  interface CertProvenance {
543
- contentHash: string;
544
- version: number | null;
545
- lift: string | null;
546
- promotedAt: string;
547
- sourcePath: string | null;
481
+ contentHash: string;
482
+ version: number | null;
483
+ lift: string | null;
484
+ promotedAt: string;
485
+ sourcePath: string | null;
548
486
  }
549
487
  /** One certified unit of agent power. */
550
488
  interface CertifiedCapability {
551
- id: string;
552
- iface: CapabilityInterface;
553
- binding: DeliveryBinding;
554
- auth: CapabilityAuth;
555
- provenance: CertProvenance;
489
+ id: string;
490
+ iface: CapabilityInterface;
491
+ binding: DeliveryBinding;
492
+ auth: CapabilityAuth;
493
+ provenance: CertProvenance;
556
494
  }
557
495
  /**
558
496
  * The strict generalization of `CertifiedProfile`. `promptSurface` is kept
@@ -560,31 +498,31 @@ interface CertifiedCapability {
560
498
  * capabilities live in `capabilities`.
561
499
  */
562
500
  interface CapabilityManifest {
563
- target: string;
564
- generatedAt: string;
565
- promptSurface: CertifiedPromptSurface | null;
566
- capabilities: CertifiedCapability[];
501
+ target: string;
502
+ generatedAt: string;
503
+ promptSurface: CertifiedPromptSurface | null;
504
+ capabilities: CertifiedCapability[];
567
505
  }
568
506
  /** One retrieval handle. The agent never learns vector vs graph vs index. */
569
507
  interface ResolvedRetrieval {
570
- name: string;
571
- retrieve(query: string, k?: number): Promise<Array<{
572
- text: string;
573
- score?: number;
574
- }>>;
508
+ name: string;
509
+ retrieve(query: string, k?: number): Promise<Array<{
510
+ text: string;
511
+ score?: number;
512
+ }>>;
575
513
  }
576
514
  /** One resolved hook — event + the command/matcher the seam folds into
577
515
  * `AgentProfile.hooks`. */
578
516
  interface ResolvedHook {
579
- event: string;
580
- command: string;
581
- matcher?: string;
517
+ event: string;
518
+ command: string;
519
+ matcher?: string;
582
520
  }
583
521
  /** One resolved subagent — folded into `AgentProfile.subagents`. */
584
522
  interface ResolvedSubagent {
585
- name: string;
586
- description?: string;
587
- prompt?: string;
523
+ name: string;
524
+ description?: string;
525
+ prompt?: string;
588
526
  }
589
527
  /**
590
528
  * What `composeCertifiedProfile` produces. Every binding fans into the same
@@ -593,32 +531,32 @@ interface ResolvedSubagent {
593
531
  * `dispose()` tears provisioned hosts down in REVERSE dependency order.
594
532
  */
595
533
  interface ResolvedSurface {
596
- /** Host-side tool defs → `RouterToolsSeam.tools` / agent-app `extraTools`. */
597
- tools: ToolSpec[];
598
- /** Host-side dispatch for a resolved tool. Throws when `name` is unknown so a
599
- * mis-dispatch is loud, never a silent empty string. */
600
- execute(name: string, args: Record<string, unknown>, task: unknown): Promise<string>;
601
- /** Sandbox-side tool delivery → `AgentProfile.mcp` / in-proc `createMcpEnvironment`. */
602
- mcpConnections: Record<string, AgentProfileMcpServer>;
603
- /** Prompt-context additions, byte-stable-ordered → folded system prompt. */
604
- promptAdditions: string[];
605
- /** Workspace files → `AgentProfile.resources.files`. */
606
- files: Array<{
607
- path: string;
608
- content: string;
609
- executable?: boolean;
610
- }>;
611
- /** Uniform retrieval handles. */
612
- retrieval: ResolvedRetrieval[];
613
- /** Hooks → `AgentProfile.hooks`. */
614
- hooks: ResolvedHook[];
615
- /** Subagents → `AgentProfile.subagents`. */
616
- subagents: ResolvedSubagent[];
617
- /** The folded system prompt — base + the byte-stable prompt additions, exactly
618
- * as `composeCertifiedPrompt` renders the inline/context capabilities. */
619
- systemPrompt: string;
620
- /** Tear down provisioned hosts (reverse dependency order). */
621
- dispose(): Promise<void>;
534
+ /** Host-side tool defs → `RouterToolsSeam.tools` / agent-app `extraTools`. */
535
+ tools: ToolSpec[];
536
+ /** Host-side dispatch for a resolved tool. Throws when `name` is unknown so a
537
+ * mis-dispatch is loud, never a silent empty string. */
538
+ execute(name: string, args: Record<string, unknown>, task: unknown): Promise<string>;
539
+ /** Sandbox-side tool delivery → `AgentProfile.mcp` / in-proc `createMcpEnvironment`. */
540
+ mcpConnections: Record<string, AgentProfileMcpServer>;
541
+ /** Prompt-context additions, byte-stable-ordered → folded system prompt. */
542
+ promptAdditions: string[];
543
+ /** Workspace files → `AgentProfile.resources.files`. */
544
+ files: Array<{
545
+ path: string;
546
+ content: string;
547
+ executable?: boolean;
548
+ }>;
549
+ /** Uniform retrieval handles. */
550
+ retrieval: ResolvedRetrieval[];
551
+ /** Hooks → `AgentProfile.hooks`. */
552
+ hooks: ResolvedHook[];
553
+ /** Subagents → `AgentProfile.subagents`. */
554
+ subagents: ResolvedSubagent[];
555
+ /** The folded system prompt — base + the byte-stable prompt additions, exactly
556
+ * as `composeCertifiedPrompt` renders the inline/context capabilities. */
557
+ systemPrompt: string;
558
+ /** Tear down provisioned hosts (reverse dependency order). */
559
+ dispose(): Promise<void>;
622
560
  }
623
561
  /**
624
562
  * A binding kind whose resolver case is typed but not yet admitted (rag-index,
@@ -627,31 +565,32 @@ interface ResolvedSurface {
627
565
  * resolver grows them later behind their lifecycle + admission gate.
628
566
  */
629
567
  declare class CapabilityNotAdmittedError extends Error {
630
- readonly kind: DeliveryBindingKind;
631
- readonly capabilityId: string;
632
- constructor(kind: DeliveryBindingKind, capabilityId: string, reason: string);
568
+ readonly kind: DeliveryBindingKind;
569
+ readonly capabilityId: string;
570
+ constructor(kind: DeliveryBindingKind, capabilityId: string, reason: string);
633
571
  }
634
572
  /**
635
573
  * Lower the EXISTING plane wire (`CertifiedProfile`) into a `CapabilityManifest`.
636
574
  * `prompt-surface`/`skill` artifacts → `context`/inline capabilities (the
637
575
  * shipped fold, generalized); any other artifact type → best-effort binding
638
- * inference (see {@link inferCapability}). `promptSurface` is carried through so
576
+ * inference. `promptSurface` is carried through so
639
577
  * the resolver folds it first, exactly as `composeCertifiedPrompt` does today.
640
578
  * This delivers the spine against today's wire before the plane changes.
641
579
  */
642
580
  declare function manifestFromProfile(profile: CertifiedProfile): CapabilityManifest;
643
-
581
+ //#endregion
582
+ //#region src/intelligence/improvement-surfaces.d.ts
644
583
  /** Agent improvement surfaces delivered as exact `AgentProfileDiff` replacements. */
645
584
  declare const AGENT_IMPROVEMENT_PROFILE_SURFACES: readonly ["prompt", "skills", "tools", "mcp", "hooks", "subagents"];
646
585
  type AgentImprovementProfileSurface = (typeof AGENT_IMPROVEMENT_PROFILE_SURFACES)[number];
647
586
  interface AgentImprovementTargetProfileDiffOptions {
648
- id: string;
649
- source?: AgentProfileDiff['source'];
650
- metadata?: Record<string, unknown>;
587
+ id: string;
588
+ source?: AgentProfileDiff['source'];
589
+ metadata?: Record<string, unknown>;
651
590
  }
652
591
  type AgentImprovementActivationTargetIdentity = Pick<AgentImprovementActivationTarget, 'surface' | 'identity'>;
653
592
  /** Bind caller-owned target identities to the exact source state Runtime measured. */
654
- declare function buildAgentImprovementActivationTargets(surfaces: readonly AgentImprovementSurface[], experiment: AgentCandidateExperiment, intent: AgentImprovementActivationIntent, identities: readonly AgentImprovementActivationTargetIdentity[]): [AgentImprovementActivationTarget, ...AgentImprovementActivationTarget[]];
593
+ declare function buildAgentImprovementActivationTargets(surfaces: readonly AgentImprovementSurface[], experiment: AgentImprovementEvaluation$1['experiment'], intent: AgentImprovementActivationIntent$1, identities: readonly AgentImprovementActivationTargetIdentity[]): [AgentImprovementActivationTarget, ...AgentImprovementActivationTarget[]];
655
594
  /** Return whether a measured surface can be delivered through an agent profile. */
656
595
  declare function isAgentImprovementProfileSurface(surface: AgentImprovementSurface): surface is AgentImprovementProfileSurface;
657
596
  /**
@@ -660,168 +599,169 @@ declare function isAgentImprovementProfileSurface(surface: AgentImprovementSurfa
660
599
  * Unrelated profile fields are excluded. The result matches `agentImprovementTargetInput` for the
661
600
  * same profile inside a candidate bundle.
662
601
  */
663
- declare function agentImprovementProfileSurfaceInput(profile: AgentProfile, surface: AgentImprovementProfileSurface): unknown;
602
+ declare function agentImprovementProfileSurfaceInput(profile: AgentProfile$1, surface: AgentImprovementProfileSurface): unknown;
664
603
  /** Return the `Sha256Digest` of one profile surface using Runtime's canonical candidate digest. */
665
- declare function agentImprovementProfileSurfaceDigest(profile: AgentProfile, surface: AgentImprovementProfileSurface): Sha256Digest;
604
+ declare function agentImprovementProfileSurfaceDigest(profile: AgentProfile$1, surface: AgentImprovementProfileSurface): Sha256Digest;
666
605
  /**
667
606
  * Replace one measured profile surface exactly, including array-valued resources.
668
607
  * Apply the returned diffs in order: a diff applies its set before its removal,
669
608
  * so exact replacement requires a reset record followed by a set record.
670
609
  */
671
610
  declare function agentImprovementTargetProfileDiffs(target: {
672
- surface: AgentImprovementProfileSurface;
673
- desiredInput: unknown;
611
+ surface: AgentImprovementProfileSurface;
612
+ desiredInput: unknown;
674
613
  }, options: AgentImprovementTargetProfileDiffOptions): [AgentProfileDiff, ...AgentProfileDiff[]];
675
-
614
+ //#endregion
615
+ //#region src/intelligence/improvement-cycle.d.ts
676
616
  interface AgentCandidateExperimentCellPlacement {
677
- executionId: string;
678
- attempt?: number;
679
- executionRoots: AgentCandidateTaskExecution['executionRoots'];
680
- stagingRoots: AgentCandidateTaskExecution['stagingRoots'];
681
- ports: AgentCandidateExecutionPorts;
682
- preparation?: PrepareAgentCandidateExecutionOptions;
683
- execution: ExecutePreparedAgentCandidateOptions;
617
+ executionId: string;
618
+ attempt?: number;
619
+ executionRoots: AgentCandidateTaskExecution['executionRoots'];
620
+ stagingRoots: AgentCandidateTaskExecution['stagingRoots'];
621
+ ports: AgentCandidateExecutionPorts;
622
+ preparation?: PrepareAgentCandidateExecutionOptions;
623
+ execution: ExecutePreparedAgentCandidateOptions;
684
624
  }
685
625
  interface RunAgentCandidateExperimentOptions extends Omit<CompareCandidateExperimentOptions, 'experiment' | 'measurements'> {
686
- experiment: AgentCandidateExperiment;
687
- placeCell: (input: CandidateExperimentExecutionInput) => AgentCandidateExperimentCellPlacement | Promise<AgentCandidateExperimentCellPlacement>;
688
- maxConcurrency?: number;
689
- signal?: AbortSignal;
626
+ experiment: AgentCandidateExperiment;
627
+ placeCell: (input: CandidateExperimentExecutionInput) => AgentCandidateExperimentCellPlacement | Promise<AgentCandidateExperimentCellPlacement>;
628
+ maxConcurrency?: number;
629
+ signal?: AbortSignal;
690
630
  }
691
631
  interface RunAgentCandidateExperimentResult {
692
- experiment: AgentCandidateExperiment;
693
- measurements: AgentCandidateExperimentMeasurement[];
694
- evaluation: AgentImprovementMeasuredComparison;
695
- }
696
- interface ExecuteAgentCandidateExperimentCellOptions extends CandidateExperimentExecutionInput, AgentCandidateExperimentCellPlacement {
632
+ experiment: AgentCandidateExperiment;
633
+ measurements: AgentCandidateExperimentMeasurement[];
634
+ evaluation: AgentImprovementMeasuredComparison$1;
697
635
  }
636
+ interface ExecuteAgentCandidateExperimentCellOptions extends CandidateExperimentExecutionInput, AgentCandidateExperimentCellPlacement {}
698
637
  interface VerifyCandidateExecutionEvidenceOptions {
699
- experiment: AgentCandidateExperiment;
700
- arm: 'baseline' | 'candidate';
701
- benchmarkCell: AgentCandidateBenchmarkCellRef;
702
- seed: number;
703
- attempt?: number;
704
- resolvedResources?: ReadonlyMap<Sha256Digest, string>;
638
+ experiment: AgentCandidateExperiment;
639
+ arm: 'baseline' | 'candidate';
640
+ benchmarkCell: AgentCandidateBenchmarkCellRef;
641
+ seed: number;
642
+ attempt?: number;
643
+ resolvedResources?: ReadonlyMap<Sha256Digest, string>;
705
644
  }
706
645
  /** A failed baseline or candidate cell with its complete Runtime failure result. */
707
646
  declare class AgentCandidateExperimentCellExecutionError extends Error {
708
- readonly finalization: Extract<AgentCandidateRunFinalization, {
709
- succeeded: false;
710
- }>;
711
- constructor(finalization: Extract<AgentCandidateRunFinalization, {
712
- succeeded: false;
713
- }>);
647
+ readonly finalization: Extract<AgentCandidateRunFinalization, {
648
+ succeeded: false;
649
+ }>;
650
+ constructor(finalization: Extract<AgentCandidateRunFinalization, {
651
+ succeeded: false;
652
+ }>);
714
653
  }
715
654
  interface CreateAgentImprovementProposalOptions {
716
- runId: string;
717
- findings: readonly AnalystFinding[];
718
- evaluation: AgentImprovementMeasuredComparison;
719
- now?: () => Date;
655
+ runId: string;
656
+ findings: readonly AnalystFinding$1[];
657
+ evaluation: AgentImprovementEvaluation$1;
658
+ now?: () => Date;
720
659
  }
721
660
  type CreateAgentImprovementMeasuredComparisonOptions = CompareCandidateExperimentOptions;
722
661
  interface ReviewAgentImprovementInput {
723
- decision: AgentImprovementReviewDecision;
724
- reviewedBy: string;
725
- reason: string;
726
- feedback?: string;
727
- now?: () => Date;
662
+ decision: AgentImprovementReviewDecision$1;
663
+ reviewedBy: string;
664
+ reason: string;
665
+ feedback?: string;
666
+ now?: () => Date;
728
667
  }
729
668
  interface CreateAgentImprovementActivationOptions {
730
- intent: AgentImprovementActivationIntent;
731
- /** Runtime derives each exact source digest; callers identify only the records to change. */
732
- targets: [AgentImprovementActivationTargetIdentity, ...AgentImprovementActivationTargetIdentity[]];
733
- fundingOwner: string;
734
- authorizedBy: string;
735
- expiresAt: string;
736
- now?: () => Date;
669
+ intent: AgentImprovementActivationIntent$1;
670
+ /** Runtime derives each exact source digest; callers identify only the records to change. */
671
+ targets: [AgentImprovementActivationTargetIdentity, ...AgentImprovementActivationTargetIdentity[]];
672
+ fundingOwner: string;
673
+ authorizedBy: string;
674
+ expiresAt: string;
675
+ now?: () => Date;
737
676
  }
738
- interface ProposeAgentImprovementOptions<TScenario extends Scenario, TArtifact> {
739
- runId: string;
740
- profile: AgentProfile;
741
- analysis: Omit<RunAnalystLoopOpts, 'runId' | 'improvementProposalSource'>;
742
- improvement: ImproveOptions<TScenario, TArtifact>;
743
- buildExperiment: (input: {
744
- analysis: RunAnalystLoopResult;
745
- improvement: ImproveResult<TScenario, TArtifact>;
746
- }) => AgentImprovementExperimentMaterial | Promise<AgentImprovementExperimentMaterial>;
747
- placeCell: RunAgentCandidateExperimentOptions['placeCell'];
748
- maxConcurrency?: number;
749
- signal?: AbortSignal;
750
- candidate?: AgentImprovementMeasuredComparison['candidate'];
751
- metadata?: AgentImprovementMeasuredComparison['metadata'];
752
- now?: () => Date;
677
+ interface ProposeAgentImprovementOptions<TScenario extends Scenario$1, TArtifact> {
678
+ runId: string;
679
+ profile: AgentProfile$1;
680
+ analysis: Omit<RunAnalystLoopOpts, 'runId' | 'improvementProposalSource'>;
681
+ improvement: ImproveOptions<TScenario, TArtifact>;
682
+ buildExperiment: (input: {
683
+ analysis: RunAnalystLoopResult;
684
+ improvement: ImproveResult<TScenario, TArtifact>;
685
+ }) => AgentImprovementExperimentMaterial | Promise<AgentImprovementExperimentMaterial>;
686
+ placeCell: RunAgentCandidateExperimentOptions['placeCell'];
687
+ maxConcurrency?: number;
688
+ signal?: AbortSignal;
689
+ candidate?: AgentImprovementMeasuredComparison$1['candidate'];
690
+ metadata?: AgentImprovementMeasuredComparison$1['metadata'];
691
+ now?: () => Date;
753
692
  }
754
693
  /** Product-supplied experiment material. Runtime supplies optimizer ancestry and the final digest. */
755
694
  type AgentImprovementExperimentMaterial = Omit<AgentCandidateExperimentMaterial, 'candidateLineage'>;
756
- interface ProposeAgentImprovementResult<TScenario extends Scenario, TArtifact> {
757
- analysis: RunAnalystLoopResult;
758
- improvement: ImproveResult<TScenario, TArtifact>;
759
- experiment: AgentCandidateExperiment;
760
- measurements: AgentCandidateExperimentMeasurement[];
761
- proposal: AgentImprovementProposal;
695
+ interface ProposeAgentImprovementResult<TScenario extends Scenario$1, TArtifact> {
696
+ analysis: RunAnalystLoopResult;
697
+ improvement: ImproveResult<TScenario, TArtifact>;
698
+ experiment: AgentCandidateExperiment;
699
+ measurements: AgentCandidateExperimentMeasurement[];
700
+ proposal: AgentImprovementProposal$1;
762
701
  }
763
702
  /** Execute both arms of one immutable experiment and derive its paired result. */
764
703
  declare function runAgentCandidateExperiment(options: RunAgentCandidateExperimentOptions): Promise<RunAgentCandidateExperimentResult>;
765
704
  /** Execute one exact arm, task, repetition, seed, and attempt through Runtime. */
766
- declare function executeAgentCandidateExperimentCell(options: ExecuteAgentCandidateExperimentCellOptions): Promise<CandidateExecutionEvidence>;
705
+ declare function executeAgentCandidateExperimentCell(options: ExecuteAgentCandidateExperimentCellOptions): Promise<CandidateExecutionEvidence$1>;
767
706
  /** Delegate all statistics and promotion checks to agent-eval's receipt-based comparison. */
768
- declare function createAgentImprovementMeasuredComparison(options: CreateAgentImprovementMeasuredComparisonOptions): AgentImprovementMeasuredComparison;
707
+ declare function createAgentImprovementMeasuredComparison(options: CreateAgentImprovementMeasuredComparisonOptions): AgentImprovementMeasuredComparison$1;
769
708
  /** Analyze, search, then remeasure the resulting exact candidate before proposing it. */
770
- declare function proposeAgentImprovement<TScenario extends Scenario, TArtifact>(options: ProposeAgentImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentImprovementResult<TScenario, TArtifact>>;
709
+ declare function proposeAgentImprovement<TScenario extends Scenario$1, TArtifact>(options: ProposeAgentImprovementOptions<TScenario, TArtifact>): Promise<ProposeAgentImprovementResult<TScenario, TArtifact>>;
771
710
  /** Create the reviewable record only from a complete, recomputable experiment result. */
772
- declare function createAgentImprovementProposal(options: CreateAgentImprovementProposalOptions): AgentImprovementProposal;
711
+ declare function createAgentImprovementProposal(options: CreateAgentImprovementProposalOptions): AgentImprovementProposal$1;
773
712
  /** Persist a human or tenant-policy decision bound to one exact proposal. */
774
- declare function reviewAgentImprovementProposal(inputProposal: AgentImprovementProposal, input: ReviewAgentImprovementInput): AgentImprovementReview;
713
+ declare function reviewAgentImprovementProposal(inputProposal: AgentImprovementProposal$1, input: ReviewAgentImprovementInput): AgentImprovementReview$1;
775
714
  /** Authorize product-owned writes only after the exact candidate was measured and approved. */
776
- declare function createAgentImprovementActivation(inputProposal: AgentImprovementProposal, inputReview: AgentImprovementReview, options: CreateAgentImprovementActivationOptions): AgentImprovementActivation;
715
+ declare function createAgentImprovementActivation(inputProposal: AgentImprovementProposal$1, inputReview: AgentImprovementReview$1, options: CreateAgentImprovementActivationOptions): AgentImprovementActivation$1;
777
716
  /** Validate a proposal and recompute every binding to its measured experiment. */
778
- declare function verifyAgentImprovementProposal(input: unknown): AgentImprovementProposal;
717
+ declare function verifyAgentImprovementProposal(input: unknown): AgentImprovementProposal$1;
779
718
  /** Validate the canonical identity and wire shape of an improvement review. */
780
- declare function verifyAgentImprovementReview(input: unknown): AgentImprovementReview;
719
+ declare function verifyAgentImprovementReview(input: unknown): AgentImprovementReview$1;
781
720
  /** Validate activation authority against the exact proposal, review, experiment, and base state. */
782
721
  declare function verifyAgentImprovementActivation(input: {
783
- proposal: unknown;
784
- review: unknown;
785
- activation: unknown;
786
- }): AgentImprovementActivation;
722
+ proposal: unknown;
723
+ review: unknown;
724
+ activation: unknown;
725
+ }): AgentImprovementActivation$1;
787
726
  /** Recheck one Runtime receipt against its exact signed experiment cell. */
788
- declare function verifyCandidateExecutionEvidence(input: unknown, options: VerifyCandidateExecutionEvidenceOptions): CandidateExecutionEvidence;
789
-
727
+ declare function verifyCandidateExecutionEvidence(input: unknown, options: VerifyCandidateExecutionEvidenceOptions): CandidateExecutionEvidence$1;
728
+ //#endregion
729
+ //#region src/intelligence/exact-process-candidate.d.ts
790
730
  /** Candidate surfaces implemented by the neutral exact-process executor. */
791
731
  declare const exactProcessCandidateExperimentExecutionSupport: Readonly<{
792
- outcomes: readonly ["output"];
793
- outputMediaTypes: readonly ["text/*", "application/json", "*+json"];
794
- code: readonly ["disabled"];
795
- memory: readonly ["disabled"];
796
- knowledge: true;
797
- profile: Readonly<{
798
- mcpTransports: readonly ["stdio"];
799
- remoteMcp: false;
800
- tools: false;
801
- permissions: false;
802
- modes: false;
803
- confidential: false;
804
- }>;
805
- isolation: Readonly<{
806
- freshEnvironment: true;
807
- exactProcess: true;
808
- egress: readonly ["blocked", "strict"];
809
- }>;
732
+ outcomes: readonly ["output"];
733
+ outputMediaTypes: readonly ["text/*", "application/json", "*+json"];
734
+ code: readonly ["disabled"];
735
+ memory: readonly ["disabled"];
736
+ knowledge: true;
737
+ profile: Readonly<{
738
+ mcpTransports: readonly ["stdio"];
739
+ remoteMcp: false;
740
+ tools: false;
741
+ permissions: false;
742
+ modes: false;
743
+ confidential: false;
744
+ }>;
745
+ isolation: Readonly<{
746
+ freshEnvironment: true;
747
+ exactProcess: true;
748
+ egress: readonly ["blocked", "strict"];
749
+ }>;
810
750
  }>;
811
751
  interface CreateExactProcessCandidateExperimentExecutorOptions {
812
- provider: AgentEnvironmentProviderRef;
813
- providerRegistry?: AgentEnvironmentProviderRegistry;
814
- resources: AgentExactProcessResources;
815
- providerOptions?: Record<string, unknown>;
816
- provisionTimeoutMs?: number;
817
- recoveryRetentionMs?: number;
818
- ports: AgentCandidateExecutionPorts;
819
- grader: AgentCandidateBenchmarkGraderPort;
820
- outputArtifacts: AgentCandidateOutputArtifactPort;
821
- traceStore: TraceStore;
822
- claimStore: AgentCandidateExecutionClaimStore;
823
- cleanupTimeoutMs?: number;
824
- resultTimeoutMs?: number;
752
+ provider: AgentEnvironmentProviderRef;
753
+ providerRegistry?: AgentEnvironmentProviderRegistry;
754
+ resources: AgentExactProcessResources;
755
+ providerOptions?: Record<string, unknown>;
756
+ provisionTimeoutMs?: number;
757
+ recoveryRetentionMs?: number;
758
+ ports: AgentCandidateExecutionPorts;
759
+ grader: AgentCandidateBenchmarkGraderPort;
760
+ outputArtifacts: AgentCandidateOutputArtifactPort;
761
+ traceStore: TraceStore;
762
+ claimStore: AgentCandidateExecutionClaimStore;
763
+ cleanupTimeoutMs?: number;
764
+ resultTimeoutMs?: number;
825
765
  }
826
766
  /** Product-owned candidate ports other than protected model access. */
827
767
  type AgentCandidateExecutionHostPorts = Omit<AgentCandidateExecutionPorts, 'models'>;
@@ -830,148 +770,138 @@ type AgentCandidateExecutionHostPorts = Omit<AgentCandidateExecutionPorts, 'mode
830
770
  * metered, and settled by the caller's grant service.
831
771
  */
832
772
  interface CreateProtectedExactProcessCandidateExperimentExecutorOptions extends Omit<CreateExactProcessCandidateExperimentExecutorOptions, 'ports'> {
833
- hostPorts: AgentCandidateExecutionHostPorts;
834
- model: CreateProtectedAgentCandidateModelPortOptions;
773
+ hostPorts: AgentCandidateExecutionHostPorts;
774
+ model: CreateProtectedAgentCandidateModelPortOptions;
835
775
  }
836
776
  interface ExactProcessCandidateExperimentExecution extends CandidateExperimentExecutionInput {
837
- executionId: string;
838
- attempt?: number;
839
- executionRoots: AgentCandidateExperimentCellPlacement['executionRoots'];
840
- stagingRoots: AgentCandidateExperimentCellPlacement['stagingRoots'];
841
- preparation?: PrepareAgentCandidateExecutionOptions;
777
+ executionId: string;
778
+ attempt?: number;
779
+ executionRoots: AgentCandidateExperimentCellPlacement['executionRoots'];
780
+ stagingRoots: AgentCandidateExperimentCellPlacement['stagingRoots'];
781
+ preparation?: PrepareAgentCandidateExecutionOptions;
842
782
  }
843
783
  interface ExactProcessCandidateExperimentExecutor {
844
- /** Runtime's expired-attempt path reuses this port only to stop and dispose. */
845
- readonly executor: AgentCandidateExecutorPort;
846
- execute(input: ExactProcessCandidateExperimentExecution): Promise<CandidateExecutionEvidence>;
784
+ /** Runtime's expired-attempt path reuses this port only to stop and dispose. */
785
+ readonly executor: AgentCandidateExecutorPort;
786
+ execute(input: ExactProcessCandidateExperimentExecution): Promise<CandidateExecutionEvidence$1>;
847
787
  }
848
788
  /** Exact-process executor plus the ports required for durable recovery. */
849
789
  interface ProtectedExactProcessCandidateExperimentExecutor extends ExactProcessCandidateExperimentExecutor {
850
- readonly recoveryPorts: Pick<AgentCandidateExecutionPorts, 'models' | 'memory'>;
790
+ readonly recoveryPorts: Pick<AgentCandidateExecutionPorts, 'models' | 'memory'>;
851
791
  }
852
792
  /** Execute one signed experiment cell through any declared exact-process provider. */
853
793
  declare function createExactProcessCandidateExperimentExecutor(options: CreateExactProcessCandidateExperimentExecutorOptions): ExactProcessCandidateExperimentExecutor;
854
794
  /** Compose host-owned execution ports with protected model access for one exact-process run. */
855
795
  declare function createProtectedExactProcessCandidateExperimentExecutor(options: CreateProtectedExactProcessCandidateExperimentExecutorOptions): ProtectedExactProcessCandidateExperimentExecutor;
856
-
796
+ //#endregion
797
+ //#region src/intelligence/optimization-receipt.d.ts
857
798
  type OptimizationProvenance = NonNullable<OptimizationMethodComparison['best']['provenance']>;
858
799
  interface OptimizationActivationReceipt {
859
- kind: 'optimization-activation-receipt';
860
- method: string;
861
- source: OptimizationPackageSource;
862
- bridge?: OptimizationPackageSource;
863
- modules?: OptimizationProvenance['modules'];
864
- python?: OptimizationProvenance['python'];
865
- models?: {
866
- candidate?: NonNullable<AgentProfile['model']>;
867
- optimizer?: string;
868
- };
869
- usage: {
870
- optimizerEvaluations: number;
871
- optimizerTokens?: OptimizationTokenUsage;
872
- };
873
- cost: {
874
- optimization: OptimizationReceiptCost;
875
- finalTest: OptimizationReceiptCost;
876
- total: OptimizationReceiptCost;
877
- };
878
- invocation: {
879
- runtimeInvocationId: string;
880
- optimizerRunId: string;
881
- compatibleOptimizerRunId?: string;
882
- resumed: boolean;
883
- artifactDir: string;
884
- };
885
- developmentDataDigest: Sha256Digest;
886
- digest: Sha256Digest;
800
+ kind: 'optimization-activation-receipt';
801
+ method: string;
802
+ source: OptimizationPackageSource;
803
+ bridge?: OptimizationPackageSource;
804
+ modules?: OptimizationProvenance['modules'];
805
+ python?: OptimizationProvenance['python'];
806
+ models?: {
807
+ candidate?: NonNullable<AgentProfile$1['model']>;
808
+ optimizer?: string;
809
+ };
810
+ usage: {
811
+ optimizerEvaluations: number;
812
+ optimizerTokens?: OptimizationTokenUsage;
813
+ };
814
+ cost: {
815
+ optimization: OptimizationReceiptCost;
816
+ finalTest: OptimizationReceiptCost;
817
+ total: OptimizationReceiptCost;
818
+ };
819
+ invocation: {
820
+ runtimeInvocationId: string;
821
+ optimizerRunId: string;
822
+ compatibleOptimizerRunId?: string;
823
+ resumed: boolean;
824
+ artifactDir: string;
825
+ };
826
+ developmentDataDigest: Sha256Digest;
827
+ digest: Sha256Digest;
887
828
  }
888
829
  interface OptimizationReceiptCost {
889
- totalUsd: number;
890
- accountingComplete: boolean;
891
- incompleteReasons: string[];
830
+ totalUsd: number;
831
+ accountingComplete: boolean;
832
+ incompleteReasons: string[];
892
833
  }
893
834
  /** Build a detached receipt only for methods backed by an identified external optimizer. */
894
835
  declare function createOptimizationActivationReceipt(improvement: ImproveMethodResult): OptimizationActivationReceipt | undefined;
895
836
  /** Read and verify the optimizer evidence carried by a measured proposal. */
896
- declare function optimizationActivationReceiptFromMetadata(metadata: AgentImprovementMeasuredComparison['metadata']): OptimizationActivationReceipt | undefined;
897
-
837
+ declare function optimizationActivationReceiptFromMetadata(metadata: AgentImprovementMeasuredComparison$1['metadata']): OptimizationActivationReceipt | undefined;
838
+ //#endregion
839
+ //#region src/intelligence/profile-activation.d.ts
898
840
  type AgentImprovementProfileActivationTarget = Omit<AgentImprovementActivationTargetPlan, 'surface'> & {
899
- surface: AgentImprovementProfileSurface;
841
+ surface: AgentImprovementProfileSurface;
900
842
  };
901
843
  type AgentImprovementProfileTargetState = Omit<AgentImprovementActivationTargetState, 'surface'> & {
902
- surface: AgentImprovementProfileSurface;
844
+ surface: AgentImprovementProfileSurface;
903
845
  };
904
846
  type AgentImprovementProfileTargetTransition = Omit<AgentImprovementActivationTargetTransition, 'surface'> & {
905
- surface: AgentImprovementProfileSurface;
847
+ surface: AgentImprovementProfileSurface;
906
848
  };
907
849
  interface AgentImprovementProfileReplacement {
908
- identity: string;
909
- profile: AgentProfile;
850
+ identity: string;
851
+ profile: AgentProfile$1;
910
852
  }
853
+ interface AgentImprovementProfileStateDigestInput {
854
+ identity: string;
855
+ profile: AgentProfile$1;
856
+ }
857
+ /** Product-defined hash of the complete profile state that actually runs. */
858
+ type AgentImprovementProfileStateDigest = (input: AgentImprovementProfileStateDigestInput) => Sha256Digest;
859
+ interface AgentImprovementProfileStateResolverInput {
860
+ identity: string;
861
+ stateDigest: Sha256Digest;
862
+ }
863
+ /** Product-owned retained-state lookup used only for an explicit restore. */
864
+ type AgentImprovementProfileStateResolver = (input: AgentImprovementProfileStateResolverInput) => AgentProfile$1 | undefined;
865
+ type AgentImprovementProfileActivationInput = {
866
+ currentByIdentity: ReadonlyMap<string, AgentProfile$1>;
867
+ targets: readonly [AgentImprovementProfileActivationTarget, ...AgentImprovementProfileActivationTarget[]];
868
+ } | {
869
+ currentByIdentity: ReadonlyMap<string, AgentProfile$1>;
870
+ profileTransition: ProfileImprovementActivationTransitionInput;
871
+ stateDigest: AgentImprovementProfileStateDigest;
872
+ resolveState?: AgentImprovementProfileStateResolver;
873
+ };
911
874
  type AgentImprovementProfileActivationPreparation = {
912
- status: 'missing';
913
- identities: readonly string[];
875
+ status: 'missing';
876
+ identities: readonly string[];
914
877
  } | {
915
- status: 'already-applied' | 'conflict';
916
- targets: [AgentImprovementProfileTargetState, ...AgentImprovementProfileTargetState[]];
878
+ status: 'unavailable';
879
+ code: 'PROFILE_STATE_UNAVAILABLE';
880
+ identities: readonly string[];
881
+ requiredStateDigest: Sha256Digest;
917
882
  } | {
918
- status: 'apply';
919
- replacements: [AgentImprovementProfileReplacement, ...AgentImprovementProfileReplacement[]];
920
- targets: [
921
- AgentImprovementProfileTargetTransition,
922
- ...AgentImprovementProfileTargetTransition[]
923
- ];
883
+ status: 'already-applied' | 'conflict';
884
+ targets: [AgentImprovementProfileTargetState, ...AgentImprovementProfileTargetState[]];
885
+ } | {
886
+ status: 'apply';
887
+ replacements: [AgentImprovementProfileReplacement, ...AgentImprovementProfileReplacement[]];
888
+ targets: [AgentImprovementProfileTargetTransition, ...AgentImprovementProfileTargetTransition[]];
924
889
  };
925
890
  /**
926
891
  * Compare product-owned profiles with an exact measured transition and prepare
927
- * the all-or-none replacements. The caller owns locking, persistence, and the
928
- * durable activation receipt; this function owns profile semantics only.
929
- * Profiles stay in product-owned stores, so this returns replacements instead
930
- * of owning the transition callbacks used by Runtime-owned knowledge stores.
931
- */
932
- declare function prepareAgentImprovementProfileActivation(input: {
933
- currentByIdentity: ReadonlyMap<string, AgentProfile>;
934
- targets: readonly [
935
- AgentImprovementProfileActivationTarget,
936
- ...AgentImprovementProfileActivationTarget[]
937
- ];
938
- }): AgentImprovementProfileActivationPreparation;
939
-
940
- /**
941
- *
942
- * The capability resolver — the ONLY place that knows binding kinds. It lowers a
943
- * `CapabilityManifest` into a uniform `ResolvedSurface` consumed identically by
944
- * the in-process seam (`RouterToolsSeam.{tools, executeToolCall}` + a folded
945
- * prompt) and the sandbox seam (`AgentProfile`).
946
- *
947
- * The spine (zero new infra) resolves inline/file, mcp-stdio/mcp-remote, and
948
- * http tools for BOTH seams, reusing shipped primitives:
949
- * - inline/context → `composeCertifiedPrompt` (delivery.ts) — byte-stable order;
950
- * - http → a `ToolSpec` + a host-side fetch `execute`;
951
- * - mcp-stdio/remote → an `AgentProfileMcpServer` (the strict union widens to
952
- * the SDK's flat shape — an always-valid lowering).
953
- *
954
- * The ladder rungs that need infra are INJECTED capabilities of the resolve
955
- * context (`runSandboxCode`, `provisionHost`), so the substrate-free caller wires
956
- * only what it can host — a binding that needs an absent provider throws loudly,
957
- * it is NEVER faked into a working surface. The not-yet-admitted arms (rag-index,
958
- * memory-store, wasm, a2a) throw {@link CapabilityNotAdmittedError}.
959
- *
960
- * Fail-closed by construction (mirroring `pullCertified`): a `null` manifest
961
- * returns the base surface only; a per-capability resolve failure DROPS that
962
- * capability (never a half-wired tool); a post-resolve drift check drops any tool
963
- * whose live names diverge from the certified interface.
964
- *
965
- * @experimental
892
+ * all-or-none replacements. The product owns locking, persistence, and retained
893
+ * state; Runtime owns the profile diff semantics and digest checks.
966
894
  */
967
-
895
+ declare function prepareAgentImprovementProfileActivation(input: AgentImprovementProfileActivationInput): AgentImprovementProfileActivationPreparation;
896
+ //#endregion
897
+ //#region src/intelligence/resolver.d.ts
968
898
  /** A live, provisioned host the resolver tore up for a `process-on-infra` arm.
969
899
  * `teardown()` runs at `dispose()` in reverse provisioning order. */
970
900
  interface ProvisionedHost {
971
- /** Lower the inner binding's mcp connection now that the host is up; the URL/
972
- * command points at the host. Absent when the host serves a non-mcp inner. */
973
- mcpConnection?: AgentProfileMcpServer;
974
- teardown(): Promise<void>;
901
+ /** Lower the inner binding's mcp connection now that the host is up; the URL/
902
+ * command points at the host. Absent when the host serves a non-mcp inner. */
903
+ mcpConnection?: AgentProfileMcpServer;
904
+ teardown(): Promise<void>;
975
905
  }
976
906
  /**
977
907
  * Per-call, per-tenant context the resolver reads. Everything that touches the
@@ -979,52 +909,52 @@ interface ProvisionedHost {
979
909
  * no live secret and the substrate-free caller wires only what it can host.
980
910
  */
981
911
  interface ResolveCtx {
982
- /** Stable tenant id — namespaces billing + teardown (`tenant#target`). */
983
- tenant?: string;
984
- /** fetch impl for http tools. Defaults to global fetch; absent ⇒ http tools fail loud. */
985
- fetchImpl?: typeof fetch;
986
- /**
987
- * Resolve a declared credential to a live secret for THIS tenant. Returns a
988
- * typed outcome — inspect `succeeded` before `value`. Absent ⇒ a binding that
989
- * declares non-`none` auth fails loud (never a request with no credential).
990
- */
991
- resolveSecret?: (auth: CapabilityAuth, tenant: string | undefined) => Promise<{
992
- succeeded: true;
993
- value: string;
994
- } | {
995
- succeeded: false;
996
- error: string;
997
- }>;
998
- /**
999
- * Run a `sandbox-code` body per call. Injected by the host that owns a sandbox
1000
- * client (the spine does not import the sandbox executor). Absent ⇒
1001
- * `sandbox-code` bindings fail loud.
1002
- */
1003
- runSandboxCode?: (code: ContentRef, entry: string, args: Record<string, unknown>, task: unknown) => Promise<string>;
1004
- /**
1005
- * Provision a host for a `process-on-infra` binding, then serve the inner
1006
- * binding inside it. Injected by the host that owns `createExecutor`. Absent ⇒
1007
- * `process-on-infra` bindings fail loud. The provider resolves the inner
1008
- * binding INSIDE the host and returns the connection + a teardown.
1009
- */
1010
- provisionHost?: (host: HostSpec, inner: DeliveryBinding, costTag: string) => Promise<ProvisionedHost>;
1011
- /**
1012
- * Drift probe: return the LIVE tool names a resolved surface exposes for a
1013
- * given capability id (a `tools/list` over an mcp connection, the agent's
1014
- * actual registered tool names for a host tool). When present, the post-resolve
1015
- * drift check drops any tool/mcp whose live names diverge from the certified
1016
- * interface — the only callable surfaces are gate-blessed ones. Absent ⇒ the
1017
- * check enforces only the host-side executor↔spec parity (no live probe).
1018
- */
1019
- probeLiveToolNames?: (capabilityId: string) => Promise<string[]>;
1020
- /**
1021
- * Observe a DROPPED capability — a per-capability resolve failure that is
1022
- * fail-closed (the capability is omitted, never half-wired). The drop is the
1023
- * contract; this surfaces the diagnostic so it is never silently erased. NOT
1024
- * called for {@link CapabilityNotAdmittedError} (that rethrows — a manifest
1025
- * carrying an un-admitted binding kind is a hard error, not a soft drop).
1026
- */
1027
- onDrop?: (capabilityId: string, error: Error) => void;
912
+ /** Stable tenant id — namespaces billing + teardown (`tenant#target`). */
913
+ tenant?: string;
914
+ /** fetch impl for http tools. Defaults to global fetch; absent ⇒ http tools fail loud. */
915
+ fetchImpl?: typeof fetch;
916
+ /**
917
+ * Resolve a declared credential to a live secret for THIS tenant. Returns a
918
+ * typed outcome — inspect `succeeded` before `value`. Absent ⇒ a binding that
919
+ * declares non-`none` auth fails loud (never a request with no credential).
920
+ */
921
+ resolveSecret?: (auth: CapabilityAuth, tenant: string | undefined) => Promise<{
922
+ succeeded: true;
923
+ value: string;
924
+ } | {
925
+ succeeded: false;
926
+ error: string;
927
+ }>;
928
+ /**
929
+ * Run a `sandbox-code` body per call. Injected by the host that owns a sandbox
930
+ * client (the spine does not import the sandbox executor). Absent ⇒
931
+ * `sandbox-code` bindings fail loud.
932
+ */
933
+ runSandboxCode?: (code: ContentRef, entry: string, args: Record<string, unknown>, task: unknown) => Promise<string>;
934
+ /**
935
+ * Provision a host for a `process-on-infra` binding, then serve the inner
936
+ * binding inside it. Injected by the host that owns `createExecutor`. Absent ⇒
937
+ * `process-on-infra` bindings fail loud. The provider resolves the inner
938
+ * binding INSIDE the host and returns the connection + a teardown.
939
+ */
940
+ provisionHost?: (host: HostSpec, inner: DeliveryBinding, costTag: string) => Promise<ProvisionedHost>;
941
+ /**
942
+ * Drift probe: return the LIVE tool names a resolved surface exposes for a
943
+ * given capability id (a `tools/list` over an mcp connection, the agent's
944
+ * actual registered tool names for a host tool). When present, the post-resolve
945
+ * drift check drops any tool/mcp whose live names diverge from the certified
946
+ * interface — the only callable surfaces are gate-blessed ones. Absent ⇒ the
947
+ * check enforces only the host-side executor↔spec parity (no live probe).
948
+ */
949
+ probeLiveToolNames?: (capabilityId: string) => Promise<string[]>;
950
+ /**
951
+ * Observe a DROPPED capability — a per-capability resolve failure that is
952
+ * fail-closed (the capability is omitted, never half-wired). The drop is the
953
+ * contract; this surfaces the diagnostic so it is never silently erased. NOT
954
+ * called for {@link CapabilityNotAdmittedError} (that rethrows — a manifest
955
+ * carrying an un-admitted binding kind is a hard error, not a soft drop).
956
+ */
957
+ onDrop?: (capabilityId: string, error: Error) => void;
1028
958
  }
1029
959
  /**
1030
960
  * Compose a certified profile into a uniform `ResolvedSurface`. Additive over
@@ -1036,73 +966,41 @@ interface ResolveCtx {
1036
966
  * Fail-closed: a `null` manifest returns the base surface only.
1037
967
  */
1038
968
  declare function composeCertifiedProfile(base: {
1039
- systemPrompt: string;
969
+ systemPrompt: string;
1040
970
  }, manifest: CapabilityManifest | null, ctx?: ResolveCtx): Promise<ResolvedSurface>;
1041
971
  /** Lower a plane `CertifiedProfile` straight into a `ResolvedSurface` via
1042
972
  * `manifestFromProfile` — the convenience the shipped pull lane calls when it
1043
973
  * already holds a `CertifiedProfile` (today's wire) rather than a manifest. */
1044
974
  declare function composeCertifiedProfileFromWire(base: {
1045
- systemPrompt: string;
975
+ systemPrompt: string;
1046
976
  }, profile: CertifiedProfile | null, ctx?: ResolveCtx): Promise<ResolvedSurface>;
1047
-
1048
- /**
1049
- *
1050
- * `withIntelligence` — the ONE agent-runtime hook that unifies Tangle
1051
- * Intelligence send + receive.
1052
- *
1053
- * It does two things per call, both fail-open:
1054
- * 1. RECEIVE — pull the tenant's certified profile from the deployed plane
1055
- * (cached + refreshed), hand the agent the certified prompt surface to fold
1056
- * (`applied.composePrompt`) and the promoted, gate-certified profile DIFFS
1057
- * as PROPOSALS (`applied.proposals` / `applied.applyProfile`).
1058
- * 2. SEND — serialize a typed {@link RunRecord} for the call through the shipped
1059
- * OTLP builders to the plane's `/v1/otlp` ingest, best-effort.
1060
- *
1061
- * SAFETY — observe + deliver ONLY. This hook NEVER auto-applies a received diff
1062
- * at runtime. A promoted diff is surfaced as a proposal; a human, or the gated
1063
- * local `improve()` loop, turns a proposal into a shipped profile. That
1064
- * preserves the held-out invariant the plane enforces — a runtime that silently
1065
- * folded an un-gated diff into itself would defeat the very gate the diff cleared.
1066
- *
1067
- * import { withIntelligence } from '@tangle-network/agent-runtime/intelligence'
1068
- *
1069
- * export const agent = withIntelligence(
1070
- * async (input, applied) => {
1071
- * const out = await myAgent(input, { systemPrompt: applied.composePrompt(BASE) })
1072
- * applied.record({ success: true, usage: { inferenceUsd: 0.002, intelligenceUsd: 0 } })
1073
- * return out
1074
- * },
1075
- * { project: 'support-agent', target: 'support-agent' },
1076
- * )
1077
- *
1078
- * @experimental
1079
- */
1080
-
977
+ //#endregion
978
+ //#region src/intelligence/with-intelligence.d.ts
1081
979
  /** What the hook hands the agent each run. Additive over the prompt-only
1082
980
  * delivery: `composePrompt` folds the certified prompt surface (as before);
1083
981
  * `proposals`/`applyProfile` surface the promoted profile DIFFS — never
1084
982
  * auto-applied; `record` enriches the {@link RunRecord} that is sent. */
1085
983
  interface AppliedIntelligence {
1086
- /** Stable ids shared by the run span and every nested runtime/loop span. */
1087
- runId: string;
1088
- traceId: string;
1089
- /** The certified profile in effect (null when none promoted / pull failed —
1090
- * fail-closed: the agent runs on its base surface). */
1091
- certified: CertifiedProfile | null;
1092
- /** Fold the certified prompt surface into a base system prompt (the promoted
1093
- * prompt). The consumer opts in by calling it. */
1094
- composePrompt(base: string): string;
1095
- /** The promoted, gate-certified profile diffs — surfaced for a human or the
1096
- * gated `improve()` loop. NEVER auto-applied by this hook. Empty when none. */
1097
- proposals: ProposedProfileDiff[];
1098
- /** Fold every proposal into `base` via `applyAgentProfileDiff`, in promotion
1099
- * order, and return the result. The caller invokes this EXPLICITLY (it is the
1100
- * human/gated apply step) — the hook never calls it on the run path. */
1101
- applyProfile(base: AgentProfile): AgentProfile;
1102
- /** Enrich the {@link RunRecord} sent for this call — outcome, usage split,
1103
- * model/provider, and the loop event stream. Optional; an un-recorded run
1104
- * still sends input/output with an inference-only zero usage split. */
1105
- record(report: RunReport): void;
984
+ /** Stable ids shared by the run span and every nested runtime/loop span. */
985
+ runId: string;
986
+ traceId: string;
987
+ /** The certified profile in effect (null when none promoted / pull failed —
988
+ * fail-closed: the agent runs on its base surface). */
989
+ certified: CertifiedProfile | null;
990
+ /** Fold the certified prompt surface into a base system prompt (the promoted
991
+ * prompt). The consumer opts in by calling it. */
992
+ composePrompt(base: string): string;
993
+ /** The promoted, gate-certified profile diffs — surfaced for a human or the
994
+ * gated `improve()` loop. NEVER auto-applied by this hook. Empty when none. */
995
+ proposals: ProposedProfileDiff[];
996
+ /** Fold every proposal into `base` via `applyAgentProfileDiff`, in promotion
997
+ * order, and return the result. The caller invokes this EXPLICITLY (it is the
998
+ * human/gated apply step) — the hook never calls it on the run path. */
999
+ applyProfile(base: AgentProfile$1): AgentProfile$1;
1000
+ /** Enrich the {@link RunRecord} sent for this call — outcome, usage split,
1001
+ * model/provider, and the loop event stream. Optional; an un-recorded run
1002
+ * still sends input/output with an inference-only zero usage split. */
1003
+ record(report: RunReport): void;
1106
1004
  }
1107
1005
  /** An agent wrapped by {@link withIntelligence}: receives the input plus the
1108
1006
  * intelligence delivered for this run. */
@@ -1111,25 +1009,25 @@ type IntelligenceAgent<I, O> = (input: I, applied: AppliedIntelligence) => Promi
1111
1009
  * cadence, and a proposals callback. One base URL (`baseUrl` /
1112
1010
  * `TANGLE_INTELLIGENCE_URL`) drives both the send and receive paths. */
1113
1011
  interface IntelligenceHookConfig extends IntelligenceConfig {
1114
- /** Pull target. Defaults to `project`. */
1115
- target?: string;
1116
- /** Min interval between certified-profile pulls. Default 5m. */
1117
- refreshMs?: number;
1118
- /** Per-pull timeout in ms (fail-closed on a hung plane). Default 10000. */
1119
- timeoutMs?: number;
1120
- /** fetch impl for the pull (tests). Defaults to global fetch. */
1121
- fetchImpl?: typeof fetch;
1122
- /** Notified when a refresh delivers a NEW set of promoted proposals (by
1123
- * provenance content hash). Surfaces diffs without auto-applying them. */
1124
- onProposals?: (proposals: ProposedProfileDiff[]) => void;
1012
+ /** Pull target. Defaults to `project`. */
1013
+ target?: string;
1014
+ /** Min interval between certified-profile pulls. Default 5m. */
1015
+ refreshMs?: number;
1016
+ /** Per-pull timeout in ms (fail-closed on a hung plane). Default 10000. */
1017
+ timeoutMs?: number;
1018
+ /** fetch impl for the pull (tests). Defaults to global fetch. */
1019
+ fetchImpl?: typeof fetch;
1020
+ /** Notified when a refresh delivers a NEW set of promoted proposals (by
1021
+ * provenance content hash). Surfaces diffs without auto-applying them. */
1022
+ onProposals?: (proposals: ProposedProfileDiff[]) => void;
1125
1023
  }
1126
1024
  /** The wrapped agent — same `(input) => Promise<output>` shape, plus a manual
1127
1025
  * `refresh()` and a `proposals()` accessor for the currently-promoted diffs. */
1128
1026
  type IntelligenceWrapped<I, O> = ((input: I) => Promise<O>) & {
1129
- refresh(): Promise<void>;
1130
- proposals(): ProposedProfileDiff[];
1131
- /** Flush buffered trace spans before a short-lived process exits. */
1132
- flush(): Promise<void>;
1027
+ refresh(): Promise<void>;
1028
+ proposals(): ProposedProfileDiff[];
1029
+ /** Flush buffered trace spans before a short-lived process exits. */
1030
+ flush(): Promise<void>;
1133
1031
  };
1134
1032
  /**
1135
1033
  * Wrap an agent so it (a) RECEIVES the tenant's certified profile — the prompt
@@ -1141,28 +1039,8 @@ type IntelligenceWrapped<I, O> = ((input: I) => Promise<O>) & {
1141
1039
  * thrown by the agent itself propagates unchanged.
1142
1040
  */
1143
1041
  declare function withIntelligence<I, O>(agent: IntelligenceAgent<I, O>, config: IntelligenceHookConfig): IntelligenceWrapped<I, O>;
1144
-
1145
- /**
1146
- *
1147
- * Tangle Intelligence SDK — trace capture plus reviewable improvement.
1148
- *
1149
- * The client keeps live-agent trace delivery best-effort. The separate
1150
- * improvement-cycle exports analyze completed traces, run a signed baseline
1151
- * versus candidate experiment, bind review to its result, and activate only
1152
- * the exact measured candidate.
1153
- *
1154
- * 1. OBSERVE — wrap a generic agent and export one trace span per call to
1155
- * Tangle Intelligence, swallowing every export failure so a live agent
1156
- * never fails because Intelligence is down.
1157
- * 2. MODE 0 / OFF — at `effort: 'off'`, run the agent as PURE PASSTHROUGH
1158
- * (zero intelligence spawns) with best-effort telemetry still on. The
1159
- * exported trace tags usage by class `{ inferenceUsd, intelligenceUsd }`,
1160
- * and at OFF `intelligenceUsd` is provably `0` — the mechanism that proves
1161
- * an OFF customer paid inference-only.
1162
- *
1163
- * @experimental
1164
- */
1165
-
1042
+ //#endregion
1043
+ //#region src/intelligence/index.d.ts
1166
1044
  /** Usage class for billing. Base-stream tokens bill `'inference'`; every
1167
1045
  * intelligence spawn (analyst, corpus, loop) bills `'intelligence'`. The
1168
1046
  * billing line falls on the spawn line. */
@@ -1173,10 +1051,10 @@ type UsageClass = 'inference' | 'intelligence';
1173
1051
  * bill. This is a classification on the trace, NOT a budget-pool split.
1174
1052
  */
1175
1053
  interface UsageSplit {
1176
- /** Base-stream (model) spend in USD. */
1177
- inferenceUsd: number;
1178
- /** Intelligence-spawn spend in USD. Provably `0` at the OFF tier. */
1179
- intelligenceUsd: number;
1054
+ /** Base-stream (model) spend in USD. */
1055
+ inferenceUsd: number;
1056
+ /** Intelligence-spawn spend in USD. Provably `0` at the OFF tier. */
1057
+ intelligenceUsd: number;
1180
1058
  }
1181
1059
  /**
1182
1060
  * The typed record `withIntelligence` sends per call — serialized through the
@@ -1186,44 +1064,44 @@ interface UsageSplit {
1186
1064
  * tree under the same `traceId`.
1187
1065
  */
1188
1066
  interface RunRecord {
1189
- runId: string;
1190
- traceId: string;
1191
- project: string;
1192
- target: string;
1193
- input: unknown;
1194
- output: unknown;
1195
- outcome: {
1196
- success?: boolean;
1197
- score?: number;
1198
- usage: UsageSplit;
1199
- };
1200
- model?: string;
1201
- provider?: string;
1202
- loopEvents?: LoopTraceEvent[];
1203
- runtimeEvents?: RuntimeStreamEvent[];
1204
- profile?: AgentProfile;
1205
- sessionId?: string;
1206
- harness?: string;
1207
- repository?: string;
1208
- commitSha?: string;
1209
- timing?: {
1210
- startedAt: number;
1211
- completedAt: number;
1212
- durationMs: number;
1213
- };
1214
- tokens?: {
1215
- input: number;
1216
- output: number;
1217
- cachedInput?: number;
1218
- reasoning?: number;
1219
- };
1220
- error?: {
1221
- name: string;
1222
- message: string;
1223
- code?: string;
1224
- };
1225
- /** Exact proposal → review → execution → receipt linkage for candidate runs. */
1226
- candidateExecution?: CandidateExecutionEvidence;
1067
+ runId: string;
1068
+ traceId: string;
1069
+ project: string;
1070
+ target: string;
1071
+ input: unknown;
1072
+ output: unknown;
1073
+ outcome: {
1074
+ success?: boolean;
1075
+ score?: number;
1076
+ usage: UsageSplit;
1077
+ };
1078
+ model?: string;
1079
+ provider?: string;
1080
+ loopEvents?: LoopTraceEvent[];
1081
+ runtimeEvents?: RuntimeStreamEvent[];
1082
+ profile?: AgentProfile$1;
1083
+ sessionId?: string;
1084
+ harness?: string;
1085
+ repository?: string;
1086
+ commitSha?: string;
1087
+ timing?: {
1088
+ startedAt: number;
1089
+ completedAt: number;
1090
+ durationMs: number;
1091
+ };
1092
+ tokens?: {
1093
+ input: number;
1094
+ output: number;
1095
+ cachedInput?: number;
1096
+ reasoning?: number;
1097
+ };
1098
+ error?: {
1099
+ name: string;
1100
+ message: string;
1101
+ code?: string;
1102
+ };
1103
+ /** Exact proposal → review → execution → receipt linkage for candidate runs. */
1104
+ candidateExecution?: CandidateExecutionEvidence$1;
1227
1105
  }
1228
1106
  /**
1229
1107
  * What an agent reports (via `applied.record`) to enrich the {@link RunRecord}
@@ -1232,91 +1110,91 @@ interface RunRecord {
1232
1110
  * as pure inference (the base stream).
1233
1111
  */
1234
1112
  interface RunReport {
1235
- success?: boolean;
1236
- score?: number;
1237
- usage?: Partial<UsageSplit>;
1238
- costUsd?: number;
1239
- model?: string;
1240
- provider?: string;
1241
- loopEvents?: LoopTraceEvent[];
1242
- runtimeEvents?: RuntimeStreamEvent[];
1243
- profile?: AgentProfile;
1244
- sessionId?: string;
1245
- harness?: string;
1246
- commitSha?: string;
1247
- tokens?: RunRecord['tokens'];
1248
- error?: RunRecord['error'];
1249
- candidateExecution?: CandidateExecutionEvidence;
1113
+ success?: boolean;
1114
+ score?: number;
1115
+ usage?: Partial<UsageSplit>;
1116
+ costUsd?: number;
1117
+ model?: string;
1118
+ provider?: string;
1119
+ loopEvents?: LoopTraceEvent[];
1120
+ runtimeEvents?: RuntimeStreamEvent[];
1121
+ profile?: AgentProfile$1;
1122
+ sessionId?: string;
1123
+ harness?: string;
1124
+ commitSha?: string;
1125
+ tokens?: RunRecord['tokens'];
1126
+ error?: RunRecord['error'];
1127
+ candidateExecution?: CandidateExecutionEvidence$1;
1250
1128
  }
1251
1129
  /** Repo coordinates a product may declare for the (later) Gated-PR mode. The
1252
1130
  * Observe slice only records their PRESENCE for `doctor()`; it never touches
1253
1131
  * the repo. */
1254
1132
  interface RepoConfig {
1255
- owner: string;
1256
- name: string;
1257
- baseBranch: string;
1133
+ owner: string;
1134
+ name: string;
1135
+ baseBranch: string;
1258
1136
  }
1259
1137
  /** Client configuration. `project` + `apiKey` are the Observe minimum; the
1260
1138
  * rest tune effort, endpoint, redaction, and (for `doctor()` readiness)
1261
1139
  * declare the surfaces/checks/repo a later PR mode would need. */
1262
1140
  interface IntelligenceConfig {
1263
- /** Stable project id — the tenant dimension every trace is tagged with. */
1264
- project: string;
1265
- /** Bearer key for the Intelligence ingest. Reads `TANGLE_API_KEY` when omitted. */
1266
- apiKey?: string;
1267
- /** Effort tier (default `'standard'`) plus optional per-field overrides. */
1268
- effort?: EffortTier | {
1269
- tier: EffortTier;
1270
- overrides?: EffortOverrides;
1271
- };
1272
- /**
1273
- * The ONE Tangle Intelligence base URL — both the send (OTLP `/v1/otlp`) and
1274
- * receive (`/v1/profiles/:target/composed`) paths derive from it. Reads
1275
- * `TANGLE_INTELLIGENCE_URL` when omitted, else `https://intelligence.tangle.tools`.
1276
- * Send is best-effort and only ships when an `apiKey` is present (the tenant
1277
- * key the ingest requires); absent a key, export is a no-op.
1278
- */
1279
- baseUrl?: string;
1280
- /**
1281
- * Redaction hook run over every exported input/output. A function replaces
1282
- * the default scrubber; `false` opts out entirely (raw fidelity, caller has
1283
- * sanitized upstream); omitted ⇒ the built-in `defaultRedactor`.
1284
- */
1285
- redact?: Redactor | false;
1286
- /** Mutable surfaces a later PR mode would edit. Recorded for `doctor()` only. */
1287
- surfaces?: string[];
1288
- /** Verification checks a later PR mode would gate on. Recorded for `doctor()` only. */
1289
- checks?: string[];
1290
- /** Repo access a later PR mode would need. Recorded for `doctor()` only. */
1291
- repo?: RepoConfig;
1292
- /** Full canonical profile used for this agent. Exported redacted with a stable hash. */
1293
- profile?: AgentProfile;
1294
- /** Commit that produced the running agent, when known. */
1295
- commitSha?: string;
1296
- /** Runtime-event payload policy. Tool inputs/results remain off unless explicitly enabled. */
1297
- runtimeTelemetry?: RuntimeTelemetryOptions;
1298
- /**
1299
- * Payloads are metadata-only by default: the run span carries a stable hash
1300
- * and UTF-8 byte count, but not the redacted content. Set `full` only when
1301
- * the configured OTLP destination is approved to receive complete redacted
1302
- * inputs, outputs, and profiles.
1303
- */
1304
- payloadAttributes?: 'metadata' | 'full';
1141
+ /** Stable project id — the tenant dimension every trace is tagged with. */
1142
+ project: string;
1143
+ /** Bearer key for the Intelligence ingest. Reads `TANGLE_API_KEY` when omitted. */
1144
+ apiKey?: string;
1145
+ /** Effort tier (default `'standard'`) plus optional per-field overrides. */
1146
+ effort?: EffortTier | {
1147
+ tier: EffortTier;
1148
+ overrides?: EffortOverrides;
1149
+ };
1150
+ /**
1151
+ * The ONE Tangle Intelligence base URL — both the send (OTLP `/v1/otlp`) and
1152
+ * receive (`/v1/profiles/:target/composed`) paths derive from it. Reads
1153
+ * `TANGLE_INTELLIGENCE_URL` when omitted, else `https://intelligence.tangle.tools`.
1154
+ * Send is best-effort and only ships when an `apiKey` is present (the tenant
1155
+ * key the ingest requires); absent a key, export is a no-op.
1156
+ */
1157
+ baseUrl?: string;
1158
+ /**
1159
+ * Redaction hook run over every exported input/output. A function replaces
1160
+ * the default scrubber; `false` opts out entirely (raw fidelity, caller has
1161
+ * sanitized upstream); omitted ⇒ the built-in `defaultRedactor`.
1162
+ */
1163
+ redact?: Redactor | false;
1164
+ /** Mutable surfaces a later PR mode would edit. Recorded for `doctor()` only. */
1165
+ surfaces?: string[];
1166
+ /** Verification checks a later PR mode would gate on. Recorded for `doctor()` only. */
1167
+ checks?: string[];
1168
+ /** Repo access a later PR mode would need. Recorded for `doctor()` only. */
1169
+ repo?: RepoConfig;
1170
+ /** Full canonical profile used for this agent. Exported redacted with a stable hash. */
1171
+ profile?: AgentProfile$1;
1172
+ /** Commit that produced the running agent, when known. */
1173
+ commitSha?: string;
1174
+ /** Runtime-event payload policy. Tool inputs/results remain off unless explicitly enabled. */
1175
+ runtimeTelemetry?: RuntimeTelemetryOptions;
1176
+ /**
1177
+ * Payloads are metadata-only by default: the run span carries a stable hash
1178
+ * and UTF-8 byte count, but not the redacted content. Set `full` only when
1179
+ * the configured OTLP destination is approved to receive complete redacted
1180
+ * inputs, outputs, and profiles.
1181
+ */
1182
+ payloadAttributes?: 'metadata' | 'full';
1305
1183
  }
1306
1184
  /** Metadata describing one traced run. `runId`/`traceId` default to fresh ids. */
1307
1185
  interface TraceMeta {
1308
- /** The run's input — exported through the redactor. */
1309
- input?: unknown;
1310
- /** Stable run id. Defaults to a fresh id. */
1311
- runId?: string;
1312
- /** 32-hex trace id. Defaults to a fresh id. */
1313
- traceId?: string;
1314
- /** Model id, when known — stamped on the span. */
1315
- model?: string;
1316
- /** Provider name, when known — stamped on the span. */
1317
- provider?: string;
1318
- /** Arbitrary extra labels (string/number/boolean) stamped on the span. */
1319
- labels?: Record<string, string | number | boolean>;
1186
+ /** The run's input — exported through the redactor. */
1187
+ input?: unknown;
1188
+ /** Stable run id. Defaults to a fresh id. */
1189
+ runId?: string;
1190
+ /** 32-hex trace id. Defaults to a fresh id. */
1191
+ traceId?: string;
1192
+ /** Model id, when known — stamped on the span. */
1193
+ model?: string;
1194
+ /** Provider name, when known — stamped on the span. */
1195
+ provider?: string;
1196
+ /** Arbitrary extra labels (string/number/boolean) stamped on the span. */
1197
+ labels?: Record<string, string | number | boolean>;
1320
1198
  }
1321
1199
  /**
1322
1200
  * The trace handle a `traceRun` body records into. `recordOutput` captures the
@@ -1325,104 +1203,104 @@ interface TraceMeta {
1325
1203
  * an un-recorded run still exports a span with whatever was set.
1326
1204
  */
1327
1205
  interface TraceHandle {
1328
- /** Capture the run's output. Exported through the redactor. */
1329
- recordOutput(output: unknown): void;
1330
- /**
1331
- * Capture the run's outcome. `usage` defaults to inference-only
1332
- * (`intelligenceUsd: 0`) — the OFF baseline; an intelligence-enabled run
1333
- * fills `intelligenceUsd` itself. `costUsd`, when given without a split, is
1334
- * treated as pure inference.
1335
- */
1336
- recordOutcome(outcome: {
1337
- success?: boolean;
1338
- score?: number;
1339
- costUsd?: number;
1340
- usage?: Partial<UsageSplit>;
1341
- }): void;
1206
+ /** Capture the run's output. Exported through the redactor. */
1207
+ recordOutput(output: unknown): void;
1208
+ /**
1209
+ * Capture the run's outcome. `usage` defaults to inference-only
1210
+ * (`intelligenceUsd: 0`) — the OFF baseline; an intelligence-enabled run
1211
+ * fills `intelligenceUsd` itself. `costUsd`, when given without a split, is
1212
+ * treated as pure inference.
1213
+ */
1214
+ recordOutcome(outcome: {
1215
+ success?: boolean;
1216
+ score?: number;
1217
+ costUsd?: number;
1218
+ usage?: Partial<UsageSplit>;
1219
+ }): void;
1342
1220
  }
1343
1221
  /** Metadata for {@link IntelligenceClient.recordTrace}. */
1344
1222
  interface RecordTraceMeta {
1345
- /** 32-hex trace id to anchor every span to. Defaults to a fresh id. */
1346
- traceId?: string;
1347
- /** Span id of an enclosing span the loop root should parent under (e.g. a
1348
- * `traceRun` span). Omitted ⇒ the loop root is the trace root. */
1349
- rootParentSpanId?: string;
1223
+ /** 32-hex trace id to anchor every span to. Defaults to a fresh id. */
1224
+ traceId?: string;
1225
+ /** Span id of an enclosing span the loop root should parent under (e.g. a
1226
+ * `traceRun` span). Omitted ⇒ the loop root is the trace root. */
1227
+ rootParentSpanId?: string;
1350
1228
  }
1351
1229
  /** The resolved outcome of one traced run, surfaced on the export span and
1352
1230
  * available to the caller for downstream billing assertions. */
1353
1231
  interface TraceOutcome {
1354
- runId: string;
1355
- traceId: string;
1356
- project: string;
1357
- /** The resolved effort settings this run executed under. */
1358
- effort: EffortSettings;
1359
- /** True when this run ran as pure passthrough (the OFF floor). */
1360
- intelligenceOff: boolean;
1361
- success?: boolean;
1362
- score?: number;
1363
- /** Per-class billing split. `intelligenceUsd` is `0` at the OFF tier. */
1364
- usage: UsageSplit;
1232
+ runId: string;
1233
+ traceId: string;
1234
+ project: string;
1235
+ /** The resolved effort settings this run executed under. */
1236
+ effort: EffortSettings;
1237
+ /** True when this run ran as pure passthrough (the OFF floor). */
1238
+ intelligenceOff: boolean;
1239
+ success?: boolean;
1240
+ score?: number;
1241
+ /** Per-class billing split. `intelligenceUsd` is `0` at the OFF tier. */
1242
+ usage: UsageSplit;
1365
1243
  }
1366
1244
  /** The Observe-mode Intelligence client. */
1367
1245
  interface IntelligenceClient {
1368
- /** The resolved project id. */
1369
- readonly project: string;
1370
- /** The resolved effort settings. */
1371
- readonly effort: EffortSettings;
1372
- /**
1373
- * Run `fn` under a trace, export one span best-effort, and return whatever
1374
- * `fn` returns. Telemetry-export failures are swallowed; an error THROWN by
1375
- * `fn` propagates to the caller (the agent's own failures are not masked).
1376
- */
1377
- traceRun<T>(meta: TraceMeta, fn: (trace: TraceHandle) => Promise<T>): Promise<T>;
1378
- /**
1379
- * Export a run's full loop topology — the ordered `LoopTraceEvent` stream a
1380
- * `runAgentRounds`/`Supervisor` run emits — as a nested OTLP span tree (loop → round →
1381
- * iteration) into ONE trace. Reuses the shipped `buildLoopOtelSpans` builder
1382
- * (NO second span builder), so the topology a viewer renders matches the
1383
- * kernel's. `traceId` defaults to a fresh id; `rootParentSpanId` parents the
1384
- * loop root under an enclosing span (e.g. a `traceRun` span) when given.
1385
- * Best-effort: export failures are swallowed. Returns the resolved `traceId`.
1386
- */
1387
- recordTrace(events: ReadonlyArray<LoopTraceEvent>, meta?: RecordTraceMeta): string;
1388
- /**
1389
- * Send one typed {@link RunRecord} — the run's flat span (input/output/outcome/
1390
- * usage/model/provider, redacted) plus, when `loopEvents` are present, the
1391
- * nested loop topology under the same `traceId`. Reuses the shipped
1392
- * `flatOtelSpan` + `buildLoopOtelSpans` builders (no second builder).
1393
- * Best-effort: export failures are swallowed. Returns the record's `traceId`.
1394
- */
1395
- exportRunRecord(record: RunRecord): string;
1396
- /** Mint a fresh run id (`run-<hex>`). */
1397
- freshRunId(): string;
1398
- /** Mint a fresh 32-hex trace id. */
1399
- freshTraceId(): string;
1400
- /**
1401
- * Network-free readiness report: which adoption modes are reachable given
1402
- * this config. Observe is always reachable; Recommend needs outcomes; PR
1403
- * needs checks + surfaces + repo.
1404
- */
1405
- doctor(): DoctorReport;
1406
- /** Flush any pending export spans. Best-effort; resolves even if export fails. */
1407
- flush(): Promise<void>;
1246
+ /** The resolved project id. */
1247
+ readonly project: string;
1248
+ /** The resolved effort settings. */
1249
+ readonly effort: EffortSettings;
1250
+ /**
1251
+ * Run `fn` under a trace, export one span best-effort, and return whatever
1252
+ * `fn` returns. Telemetry-export failures are swallowed; an error THROWN by
1253
+ * `fn` propagates to the caller (the agent's own failures are not masked).
1254
+ */
1255
+ traceRun<T>(meta: TraceMeta, fn: (trace: TraceHandle) => Promise<T>): Promise<T>;
1256
+ /**
1257
+ * Export a run's full loop topology — the ordered `LoopTraceEvent` stream a
1258
+ * `runAgentRounds`/`Supervisor` run emits — as a nested OTLP span tree (loop → round →
1259
+ * iteration) into ONE trace. Reuses the shipped `buildLoopOtelSpans` builder
1260
+ * (NO second span builder), so the topology a viewer renders matches the
1261
+ * kernel's. `traceId` defaults to a fresh id; `rootParentSpanId` parents the
1262
+ * loop root under an enclosing span (e.g. a `traceRun` span) when given.
1263
+ * Best-effort: export failures are swallowed. Returns the resolved `traceId`.
1264
+ */
1265
+ recordTrace(events: ReadonlyArray<LoopTraceEvent>, meta?: RecordTraceMeta): string;
1266
+ /**
1267
+ * Send one typed {@link RunRecord} — the run's flat span (input/output/outcome/
1268
+ * usage/model/provider, redacted) plus, when `loopEvents` are present, the
1269
+ * nested loop topology under the same `traceId`. Reuses the shipped
1270
+ * `flatOtelSpan` + `buildLoopOtelSpans` builders (no second builder).
1271
+ * Best-effort: export failures are swallowed. Returns the record's `traceId`.
1272
+ */
1273
+ exportRunRecord(record: RunRecord): string;
1274
+ /** Mint a fresh run id (`run-<hex>`). */
1275
+ freshRunId(): string;
1276
+ /** Mint a fresh 32-hex trace id. */
1277
+ freshTraceId(): string;
1278
+ /**
1279
+ * Network-free readiness report: which adoption modes are reachable given
1280
+ * this config. Observe is always reachable; Recommend needs outcomes; PR
1281
+ * needs checks + surfaces + repo.
1282
+ */
1283
+ doctor(): DoctorReport;
1284
+ /** Flush any pending export spans. Best-effort; resolves even if export fails. */
1285
+ flush(): Promise<void>;
1408
1286
  }
1409
1287
  /** One mode's readiness verdict. */
1410
1288
  interface ModeReadiness {
1411
- ready: boolean;
1412
- /** Inputs this mode still needs, when not ready. Empty when ready. */
1413
- missing: string[];
1289
+ ready: boolean;
1290
+ /** Inputs this mode still needs, when not ready. Empty when ready. */
1291
+ missing: string[];
1414
1292
  }
1415
1293
  /** The `doctor()` readiness report — Mode-readiness without any network call. */
1416
1294
  interface DoctorReport {
1417
- project: string;
1418
- effort: EffortSettings;
1419
- /** True when an OTLP endpoint is configured (export will actually ship). */
1420
- exportConfigured: boolean;
1421
- modes: {
1422
- observe: ModeReadiness;
1423
- recommend: ModeReadiness;
1424
- pr: ModeReadiness;
1425
- };
1295
+ project: string;
1296
+ effort: EffortSettings;
1297
+ /** True when an OTLP endpoint is configured (export will actually ship). */
1298
+ exportConfigured: boolean;
1299
+ modes: {
1300
+ observe: ModeReadiness;
1301
+ recommend: ModeReadiness;
1302
+ pr: ModeReadiness;
1303
+ };
1426
1304
  }
1427
1305
  /**
1428
1306
  * Create an Observe-mode Intelligence client. Resolves effort, the base URL, and
@@ -1431,5 +1309,6 @@ interface DoctorReport {
1431
1309
  * and best-effort export must never spam an unauthenticated plane).
1432
1310
  */
1433
1311
  declare function createIntelligenceClient(config: IntelligenceConfig): IntelligenceClient;
1434
-
1435
- export { AGENT_IMPROVEMENT_PROFILE_SURFACES, type AgentCandidateExecutionHostPorts, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivationTargetIdentity, AgentImprovementActivationTargetPlan, type AgentImprovementExperimentMaterial, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementProposalSubmissionState, type AgentImprovementTargetProfileDiffOptions, type AppliedIntelligence, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CreateAgentImprovementActivationOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, type DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type HostSpec, type IntelligenceAgent, type IntelligenceClient, type IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, type ModeReadiness, type OptimizationActivationReceipt, type OptimizationReceiptCost, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, type RecordTraceMeta, Redactor, type RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, type RunRecord, type RunReport, type SubmitAgentImprovementProposalOptions, type SubmitAgentImprovementProposalOutcome, type TraceHandle, type TraceMeta, type TraceOutcome, type UsageClass, type UsageSplit, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, buildAgentImprovementActivationTargets, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementMeasuredComparison, createAgentImprovementProposal, createCertifiedPromptSource, createExactProcessCandidateExperimentExecutor, createIntelligenceClient, createOptimizationActivationReceipt, createProtectedExactProcessCandidateExperimentExecutor, defaultEffortTier, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, optimizationActivationReceiptFromMetadata, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, reviewAgentImprovementProposal, runAgentCandidateExperiment, submitAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
1312
+ //#endregion
1313
+ export { AGENT_IMPROVEMENT_PROFILE_SURFACES, type AgentCandidateExecutionHostPorts, AgentCandidateExperimentCellExecutionError, type AgentCandidateExperimentCellPlacement, type AgentImprovementActivation, type AgentImprovementActivationIntent, type AgentImprovementActivationOutcome, type AgentImprovementActivationReconciliation, type AgentImprovementActivationResult, type AgentImprovementActivationResultStore, type AgentImprovementActivationTargetIdentity, type AgentImprovementActivationTargetPlan, type AgentImprovementActivationTransition, type AgentImprovementActivationTransitionInput, type AgentImprovementEvaluation, type AgentImprovementExperimentMaterial, type AgentImprovementMeasuredComparison, type AgentImprovementProfileActivationInput, type AgentImprovementProfileActivationPreparation, type AgentImprovementProfileActivationTarget, type AgentImprovementProfileReplacement, type AgentImprovementProfileStateDigest, type AgentImprovementProfileStateDigestInput, type AgentImprovementProfileStateResolver, type AgentImprovementProfileStateResolverInput, type AgentImprovementProfileSurface, type AgentImprovementProfileTargetState, type AgentImprovementProfileTargetTransition, type AgentImprovementProposal, type AgentImprovementProposalSubmissionState, type AgentImprovementReview, type AgentImprovementReviewDecision, type AgentImprovementTargetProfileDiffOptions, type AgentProfileImprovementActivationOperation, type AgentProfileImprovementActivationTargetPlan, type AppliedIntelligence, type CandidateExecutionEvidence, type CandidateProfileMaterialization, type CapabilityAuth, type CapabilityInterface, type CapabilityManifest, CapabilityNotAdmittedError, type CapabilitySurface, type CertProvenance, type CertifiedArtifact, type CertifiedCapability, type CertifiedCapabilitySummary, type CertifiedProfile, type CertifiedPromptSource, type CertifiedPromptSourceOptions, type CertifiedPromptSurface, type ContentRef, type CorpusAccess, type CreateAgentImprovementActivationOptions, type CreateAgentImprovementActivationResultOptions, type CreateAgentImprovementProposalOptions, type CreateExactProcessCandidateExperimentExecutorOptions, type CreateProtectedExactProcessCandidateExperimentExecutorOptions, type CredentialRef, type DeliveryBinding, type DeliveryBindingKind, type DiffProvenance, DoctorReport, type EffortOverrides, type EffortOverridesCompiled, type EffortSettings, type EffortTier, type ExactProcessCandidateExperimentExecution, type ExactProcessCandidateExperimentExecutor, type ExecuteAgentCandidateExperimentCellOptions, type ExecuteAgentImprovementActivationInput, type ExecuteAgentImprovementActivationOptions, type HostSpec, type IntelligenceAgent, IntelligenceClient, IntelligenceConfig, type IntelligenceHookConfig, type IntelligenceWrapped, type JsonSchema, ModeReadiness, type OptimizationActivationReceipt, type OptimizationReceiptCost, type ProfileImprovementActivationTransitionInput, type ProposeAgentImprovementOptions, type ProposeAgentImprovementResult, type ProposedProfileDiff, type ProtectedExactProcessCandidateExperimentExecutor, type ProvisionedHost, type PullCertifiedOptions, type PullOutcome, RecordTraceMeta, type Redactor, RepoConfig, type ResolveCtx, type ResolvedHook, type ResolvedRetrieval, type ResolvedSubagent, type ResolvedSurface, type ReviewAgentImprovementInput, type RunAgentCandidateExperimentOptions, type RunAgentCandidateExperimentResult, RunRecord, RunReport, type SealedCandidateActivationTransitionInput, type SubmitAgentImprovementProposalOptions, type SubmitAgentImprovementProposalOutcome, TraceHandle, TraceMeta, TraceOutcome, UsageClass, UsageSplit, type VerifyCandidateExecutionEvidenceOptions, agentImprovementProfileSurfaceDigest, agentImprovementProfileSurfaceInput, agentImprovementTargetProfileDiffs, buildAgentImprovementActivationTargets, compileEffort, composeCertifiedProfile, composeCertifiedProfileFromWire, composeCertifiedPrompt, createAgentImprovementActivation, createAgentImprovementActivationResult, createAgentImprovementMeasuredComparison, createAgentImprovementProposal, createCertifiedPromptSource, createExactProcessCandidateExperimentExecutor, createIntelligenceClient, createOptimizationActivationReceipt, createProtectedExactProcessCandidateExperimentExecutor, defaultEffortTier, defaultRedactor, exactProcessCandidateExperimentExecutionSupport, executeAgentCandidateExperimentCell, executeAgentImprovementActivation, isAgentImprovementProfileSurface, isIntelligenceOff, manifestFromProfile, normalizeCertifiedProfile, optimizationActivationReceiptFromMetadata, parseAgentCandidateProfileActivation as parseCandidateProfileMaterialization, prepareAgentImprovementProfileActivation, proposeAgentImprovement, pullCertified, resolveEffort, resolveIntelligenceBaseUrl, resolveRedactor, reviewAgentImprovementProposal, runAgentCandidateExperiment, submitAgentImprovementProposal, verifyAgentImprovementActivation, verifyAgentImprovementActivationResult, verifyAgentImprovementProposal, verifyAgentImprovementReview, verifyCandidateExecutionEvidence, withIntelligence };
1314
+ //# sourceMappingURL=intelligence.d.ts.map