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