@tangle-network/agent-runtime 0.264.0 → 0.271.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 (68) hide show
  1. package/dist/{activation-Bx4kfVU3.d.ts → activation-BrJmwTLB.d.ts} +4 -4
  2. package/dist/{activation-DHFdvps3.js → activation-DGbFPGR3.js} +2 -2
  3. package/dist/{activation-DHFdvps3.js.map → activation-DGbFPGR3.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-Bz-H17bC.js → coordination-driver-iBGMKDvB.js} +90 -50
  7. package/dist/coordination-driver-iBGMKDvB.js.map +1 -0
  8. package/dist/{delegate-CwbWhX5W.js → delegate-DOqUvaIz.js} +3 -3
  9. package/dist/delegate-DOqUvaIz.js.map +1 -0
  10. package/dist/durable.d.ts +5 -4
  11. package/dist/durable.js +3 -3
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-5NrpTg0h.js → graph-DnMcepkN.js} +12 -7
  14. package/dist/graph-DnMcepkN.js.map +1 -0
  15. package/dist/{improvement-cycle-WRWcFyuO.js → improvement-cycle-1IyRJo5h.js} +9 -9
  16. package/dist/improvement-cycle-1IyRJo5h.js.map +1 -0
  17. package/dist/{index-9wXpbjbX.d.ts → index-CL1dduJd.d.ts} +123 -73
  18. package/dist/index.d.ts +7 -7
  19. package/dist/index.js +7 -7
  20. package/dist/intelligence.d.ts +9 -3
  21. package/dist/intelligence.js +11 -5
  22. package/dist/intelligence.js.map +1 -1
  23. package/dist/kernel.d.ts +4 -4
  24. package/dist/kernel.js +9 -9
  25. package/dist/{loop-runner-bin-DC1Lm0nM.js → loop-runner-bin-BPZ9tt1W.js} +3 -3
  26. package/dist/{loop-runner-bin-DC1Lm0nM.js.map → loop-runner-bin-BPZ9tt1W.js.map} +1 -1
  27. package/dist/{loop-runner-bin-DPewOZMn.d.ts → loop-runner-bin-O_vM1w8Y.d.ts} +3 -3
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +3 -3
  31. package/dist/mcp/index.d.ts +12 -6
  32. package/dist/mcp/index.js +7 -7
  33. package/dist/mcp/memory-bin.js +1 -1
  34. package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
  35. package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
  36. package/dist/{openai-tools-ByTMUJcD.d.ts → openai-tools-DWHxpwx2.d.ts} +2 -2
  37. package/dist/profiles.d.ts +2 -2
  38. package/dist/{provision-supervisor-BZ6_uBGR.js → provision-supervisor-Cy8pqE95.js} +4 -4
  39. package/dist/{provision-supervisor-BZ6_uBGR.js.map → provision-supervisor-Cy8pqE95.js.map} +1 -1
  40. package/dist/{runtime-CUZC75EX.js → runtime-DVjIH1eo.js} +1160 -18
  41. package/dist/runtime-DVjIH1eo.js.map +1 -0
  42. package/dist/{server-KpdpN627.js → server-CN9vzbSe.js} +4 -4
  43. package/dist/{server-KpdpN627.js.map → server-CN9vzbSe.js.map} +1 -1
  44. package/dist/{stream-agent-turn-D1zelVx6.d.ts → stream-agent-turn-DbEsKgb_.d.ts} +200 -3
  45. package/dist/{structural-rollout-D17I5CwF.js → structural-rollout-I92sIfNl.js} +2 -2
  46. package/dist/{structural-rollout-D17I5CwF.js.map → structural-rollout-I92sIfNl.js.map} +1 -1
  47. package/dist/{substrate-qQphD9f0.d.ts → substrate-CbC03Vzo.d.ts} +2 -2
  48. package/dist/{supervise-_DTVHXPC.js → supervise-DJ_1i9vj.js} +85 -30
  49. package/dist/supervise-DJ_1i9vj.js.map +1 -0
  50. package/dist/{supervisor-C26k7X5-.js → supervisor-Cvd5mf7x.js} +1276 -488
  51. package/dist/supervisor-Cvd5mf7x.js.map +1 -0
  52. package/dist/testing.d.ts +2 -2
  53. package/dist/testing.js +14 -14
  54. package/dist/testing.js.map +1 -1
  55. package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
  56. package/dist/tool-server-Dqer2M4_.js.map +1 -0
  57. package/dist/tui/index.d.ts +1 -1
  58. package/dist/tui/index.js +1 -1
  59. package/dist/{types-BV14WTyW.d.ts → types-Bo7z5aG5.d.ts} +311 -75
  60. package/package.json +3 -2
  61. package/dist/coordination-driver-Bz-H17bC.js.map +0 -1
  62. package/dist/delegate-CwbWhX5W.js.map +0 -1
  63. package/dist/graph-5NrpTg0h.js.map +0 -1
  64. package/dist/improvement-cycle-WRWcFyuO.js.map +0 -1
  65. package/dist/runtime-CUZC75EX.js.map +0 -1
  66. package/dist/supervise-_DTVHXPC.js.map +0 -1
  67. package/dist/supervisor-C26k7X5-.js.map +0 -1
  68. package/dist/tool-server-x9NEhvHZ.js.map +0 -1
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $a as SuperviseTestOptions, $t as runGraphWithTestBrain, Ao as supervisorAgentWithTestBrain, Tn as driverAgent, Yt as RunGraphTestOptions, to as superviseWithTestBrain, wn as DriverAgentOptions, xo as SupervisorAgentTestDeps } from "./index-9wXpbjbX.js";
2
- import { On as ToolLoopCallContext, kn as ToolLoopChat } from "./stream-agent-turn-D1zelVx6.js";
1
+ import { $t as RunGraphTestOptions, Co as SupervisorAgentTestDeps, Dn as driverAgent, En as DriverAgentOptions, Mo as supervisorAgentWithTestBrain, rn as runGraphWithTestBrain, ro as superviseWithTestBrain, to as SuperviseTestOptions } from "./index-CL1dduJd.js";
2
+ import { Hn as ToolLoopChat, Vn as ToolLoopCallContext } from "./stream-agent-turn-DbEsKgb_.js";
3
3
  import { AgentImprovementProposal, AgentProfile, AgentProfileImprovementMeasuredComparison, SandboxSizePreset } from "@tangle-network/agent-interface";
4
4
  //#region src/testing/index.d.ts
5
5
  /** A proposal produced by Runtime's opaque profile-improvement path. */
package/dist/testing.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { C as canonicalCandidateDigest$1, D as immutableCandidateValue } from "./workspace-archive-C9lgf77y.js";
2
- import { f as verifyAgentImprovementProposal } from "./improvement-cycle-WRWcFyuO.js";
2
+ import { f as verifyAgentImprovementProposal } from "./improvement-cycle-1IyRJo5h.js";
3
3
  import { i as applyExactAgentProfileDiff, p as parseExactAgentProfile } from "./profile-D3eXNBQV.js";
4
- import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-_DTVHXPC.js";
5
- import { r as driverAgent } from "./coordination-driver-Bz-H17bC.js";
6
- import { i as runGraphWithTestBrain } from "./graph-5NrpTg0h.js";
7
- import { SANDBOX_SIZE_PRESET_NAMES } from "@tangle-network/agent-interface";
4
+ import { r as driverAgent } from "./coordination-driver-iBGMKDvB.js";
5
+ import { a as superviseWithTestBrain, h as supervisorAgentWithTestBrain } from "./supervise-DJ_1i9vj.js";
6
+ import { i as runGraphWithTestBrain } from "./graph-DnMcepkN.js";
7
+ import { SANDBOX_SIZE_PRESET_NAMES, canonicalAgentProfileDigest } from "@tangle-network/agent-interface";
8
8
  //#region src/testing/fixtures/agent-improvement-proposal.json
9
9
  var agent_improvement_proposal_default = {
10
10
  changedSurfaces: ["prompt"],
11
- digest: "sha256:5c3c11af3324f4b128365b2408c9533a5587252a664305b3aec1b79cfb1c1b37",
11
+ digest: "sha256:413fe1dbf8ef096c3466ce18d419991ee6cedc8a52db4ffe2bd0dec92cea08a9",
12
12
  evaluation: {
13
13
  "decision": {
14
14
  "contributingChecks": [
@@ -4579,7 +4579,7 @@ var agent_improvement_proposal_default = {
4579
4579
  ],
4580
4580
  "metadata": {
4581
4581
  "fixture": "agent-improvement-proposal",
4582
- "runtimeVersion": "0.264.0"
4582
+ "runtimeVersion": "0.271.0"
4583
4583
  },
4584
4584
  "objectives": [
4585
4585
  {
@@ -4690,8 +4690,8 @@ var agent_improvement_proposal_default = {
4690
4690
  "baselineContentHash": "sha256:5c21ee53e513fc604cb09754e21c392b24a424da0ef37dbf8f1ee4a8a0b08f09",
4691
4691
  "candidateContentHash": "sha256:60fcbb1c728194bd51d7d19cb732d1c3f1881dce7e0a6266b41c8b98cfd65693",
4692
4692
  "kind": "agent-eval-loop",
4693
- "recordDigest": "sha256:1e3ffbd7311c57d272af9e9b4ad9f06e20498e346a9d50bad8021ed88a5d19ec",
4694
- "runId": "agent-runtime-0.264.0-proposal-fixture",
4693
+ "recordDigest": "sha256:af7f71837ca1fe6a313b9148c03c2a7b392bd78850a1f50b3cff812bb6c38edf",
4694
+ "runId": "agent-runtime-0.271.0-proposal-fixture",
4695
4695
  "schema": "agent-candidate-experiment"
4696
4696
  }
4697
4697
  },
@@ -4714,13 +4714,13 @@ var agent_improvement_proposal_default = {
4714
4714
  }],
4715
4715
  kind: "agent-improvement-proposal",
4716
4716
  proposedAt: "2026-07-10T01:00:00.000Z",
4717
- runId: "agent-runtime-0.264.0-proposal-fixture"
4717
+ runId: "agent-runtime-0.271.0-proposal-fixture"
4718
4718
  };
4719
4719
  //#endregion
4720
4720
  //#region src/testing/fixtures/agent-profile-improvement-proposal.json
4721
4721
  var agent_profile_improvement_proposal_default = {
4722
4722
  changedSurfaces: ["prompt", "skills"],
4723
- digest: "sha256:f5381cf72fdd214af2414e22244a1b5aa3b8b6fbc0467060e0db92c2e90a8a7c",
4723
+ digest: "sha256:3b05c402ea2f3e11b27026a375a54dde3d992f741c3821c35cae65e342993dfd",
4724
4724
  evaluation: {
4725
4725
  "decision": {
4726
4726
  "contributingChecks": [
@@ -6354,7 +6354,7 @@ var agent_profile_improvement_proposal_default = {
6354
6354
  ],
6355
6355
  "metadata": {
6356
6356
  "fixture": "agent-profile-improvement-proposal",
6357
- "runtimeVersion": "0.264.0"
6357
+ "runtimeVersion": "0.271.0"
6358
6358
  },
6359
6359
  "objectives": [
6360
6360
  {
@@ -6465,7 +6465,7 @@ var agent_profile_improvement_proposal_default = {
6465
6465
  "baselineContentHash": "sha256:21c495a37c418c10bde64fbaa188beddeed31f1f051ea60a6a6582a9ee0db704",
6466
6466
  "candidateContentHash": "sha256:103f77bc8481601eef1ad5fe6ba84a40dffabc3a44f421f8c8559121edab84e9",
6467
6467
  "kind": "agent-eval-loop",
6468
- "recordDigest": "sha256:880a8c1435b315ab59ffc7cad1162a14cedd798b32faa6bd094045da84abe129",
6468
+ "recordDigest": "sha256:8c5ca0d396134ff0e55451baf5a0c439375ac64a7533526723a42d4fe5fc7b81",
6469
6469
  "runId": "profile-improvement-1",
6470
6470
  "schema": "agent-profile-improvement-experiment"
6471
6471
  }
@@ -6521,7 +6521,7 @@ function loadAgentProfileImprovementFixture() {
6521
6521
  const baselineStateDigest = profileStateDigest(state.baselineProfile, state.recommendedSize);
6522
6522
  const candidateStateDigest = profileStateDigest(state.candidateProfile, state.recommendedSize);
6523
6523
  if (baselineStateDigest !== experiment.baseline.stateDigest || candidateStateDigest !== experiment.candidate.stateDigest) throw new Error("profile improvement fixture state does not match its proposal");
6524
- if (canonicalCandidateDigest$1(experiment.change.reduce((profile, change, index) => applyExactAgentProfileDiff(profile, change, `profile improvement fixture change ${index}`), state.baselineProfile)) !== canonicalCandidateDigest$1(state.candidateProfile)) throw new Error("profile improvement fixture candidate does not match its proposal changes");
6524
+ if (canonicalAgentProfileDigest(experiment.change.reduce((profile, change, index) => applyExactAgentProfileDiff(profile, change, `profile improvement fixture change ${index}`), state.baselineProfile)) !== canonicalAgentProfileDigest(state.candidateProfile)) throw new Error("profile improvement fixture candidate does not match its proposal changes");
6525
6525
  return immutableCandidateValue({
6526
6526
  proposal,
6527
6527
  ...state
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":["canonicalAgentImprovementProposalFixture","canonicalAgentProfileImprovementProposalFixture","canonicalAgentProfileImprovementStateFixture","canonicalCandidateDigest"],"sources":["../src/testing/fixtures/agent-improvement-proposal.json","../src/testing/fixtures/agent-profile-improvement-proposal.json","../src/testing/fixtures/agent-profile-improvement-state.json","../src/testing/index.ts"],"sourcesContent":["","","","import {\n type AgentImprovementProposal,\n type AgentProfile,\n type AgentProfileImprovementMeasuredComparison,\n SANDBOX_SIZE_PRESET_NAMES,\n type SandboxSizePreset,\n} from '@tangle-network/agent-interface'\n\nimport { canonicalCandidateDigest, immutableCandidateValue } from '../candidate-execution/digest'\nimport { applyExactAgentProfileDiff, parseExactAgentProfile } from '../candidate-execution/profile'\nimport { verifyAgentImprovementProposal } from '../intelligence/improvement-cycle'\nimport canonicalAgentImprovementProposalFixture from './fixtures/agent-improvement-proposal.json'\nimport canonicalAgentProfileImprovementProposalFixture from './fixtures/agent-profile-improvement-proposal.json'\nimport canonicalAgentProfileImprovementStateFixture from './fixtures/agent-profile-improvement-state.json'\n\nexport {\n type DriverAgentOptions,\n driverAgent,\n} from '../runtime/supervise/coordination-driver'\nexport {\n type RunGraphTestOptions,\n runGraphWithTestBrain,\n} from '../runtime/supervise/graph'\nexport {\n type SuperviseTestOptions,\n superviseWithTestBrain,\n} from '../runtime/supervise/supervise'\nexport {\n type SupervisorAgentTestDeps,\n supervisorAgentWithTestBrain,\n} from '../runtime/supervise/supervisor-agent'\nexport type { ToolLoopCallContext, ToolLoopChat } from '../runtime/tool-loop'\n\nconst serializedAgentImprovementProposalFixture = JSON.stringify(\n canonicalAgentImprovementProposalFixture,\n)\nconst serializedAgentProfileImprovementProposalFixture = JSON.stringify(\n canonicalAgentProfileImprovementProposalFixture,\n)\nconst serializedAgentProfileImprovementStateFixture = JSON.stringify(\n canonicalAgentProfileImprovementStateFixture,\n)\n\n/** A proposal produced by Runtime's opaque profile-improvement path. */\nexport type AgentProfileImprovementProposalFixture = Omit<\n AgentImprovementProposal,\n 'evaluation'\n> & {\n evaluation: AgentProfileImprovementMeasuredComparison\n}\n\n/** Complete private state for exercising profile activation and restore in consumer tests. */\nexport interface AgentProfileImprovementFixture {\n proposal: AgentProfileImprovementProposalFixture\n baselineProfile: AgentProfile\n candidateProfile: AgentProfile\n recommendedSize: SandboxSizePreset\n}\n\n/** Load an isolated, production-validated Runtime proposal for consumer tests. */\nexport function loadAgentImprovementProposalFixture(): AgentImprovementProposal {\n return verifyAgentImprovementProposal(JSON.parse(serializedAgentImprovementProposalFixture))\n}\n\n/** Load an isolated profile proposal and its private activation state for consumer tests. */\nexport function loadAgentProfileImprovementFixture(): AgentProfileImprovementFixture {\n const proposal = loadAgentProfileImprovementProposal()\n const state = parseAgentProfileImprovementState(\n JSON.parse(serializedAgentProfileImprovementStateFixture),\n )\n const experiment = proposal.evaluation.experiment\n const baselineStateDigest = profileStateDigest(state.baselineProfile, state.recommendedSize)\n const candidateStateDigest = profileStateDigest(state.candidateProfile, state.recommendedSize)\n if (\n baselineStateDigest !== experiment.baseline.stateDigest ||\n candidateStateDigest !== experiment.candidate.stateDigest\n ) {\n throw new Error('profile improvement fixture state does not match its proposal')\n }\n const appliedCandidate = experiment.change.reduce(\n (profile, change, index) =>\n applyExactAgentProfileDiff(profile, change, `profile improvement fixture change ${index}`),\n state.baselineProfile,\n )\n if (\n canonicalCandidateDigest(appliedCandidate) !== canonicalCandidateDigest(state.candidateProfile)\n ) {\n throw new Error('profile improvement fixture candidate does not match its proposal changes')\n }\n return immutableCandidateValue({ proposal, ...state })\n}\n\nfunction loadAgentProfileImprovementProposal(): AgentProfileImprovementProposalFixture {\n const proposal = verifyAgentImprovementProposal(\n JSON.parse(serializedAgentProfileImprovementProposalFixture),\n )\n if (proposal.evaluation.kind !== 'agent-profile-improvement-measured-comparison') {\n throw new Error('profile improvement fixture contains a sealed candidate comparison')\n }\n return { ...proposal, evaluation: proposal.evaluation }\n}\n\nfunction parseAgentProfileImprovementState(\n input: unknown,\n): Omit<AgentProfileImprovementFixture, 'proposal'> {\n if (typeof input !== 'object' || input === null || Array.isArray(input)) {\n throw new Error('profile improvement fixture state must be an object')\n }\n const record = input as Record<string, unknown>\n const fields = Object.keys(record).sort()\n const expectedFields = ['baselineProfile', 'candidateProfile', 'recommendedSize']\n if (\n fields.length !== expectedFields.length ||\n fields.some((field, i) => field !== expectedFields[i])\n ) {\n throw new Error('profile improvement fixture state contains unsupported fields')\n }\n const recommendedSize = SANDBOX_SIZE_PRESET_NAMES.find((size) => size === record.recommendedSize)\n if (!recommendedSize) {\n throw new Error('profile improvement fixture has an invalid recommended size')\n }\n return {\n baselineProfile: parseExactAgentProfile(\n record.baselineProfile,\n 'profile improvement fixture baseline',\n ),\n candidateProfile: parseExactAgentProfile(\n record.candidateProfile,\n 'profile improvement fixture candidate',\n ),\n recommendedSize,\n }\n}\n\nfunction profileStateDigest(\n profile: AgentProfile,\n recommendedSize: SandboxSizePreset,\n): ReturnType<typeof canonicalCandidateDigest> {\n return canonicalCandidateDigest({ definition: profile, recommendedSize })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"testing.js","names":["canonicalAgentImprovementProposalFixture","canonicalAgentProfileImprovementProposalFixture","canonicalAgentProfileImprovementStateFixture","canonicalCandidateDigest"],"sources":["../src/testing/fixtures/agent-improvement-proposal.json","../src/testing/fixtures/agent-profile-improvement-proposal.json","../src/testing/fixtures/agent-profile-improvement-state.json","../src/testing/index.ts"],"sourcesContent":["","","","import {\n type AgentImprovementProposal,\n type AgentProfile,\n type AgentProfileImprovementMeasuredComparison,\n canonicalAgentProfileDigest,\n SANDBOX_SIZE_PRESET_NAMES,\n type SandboxSizePreset,\n} from '@tangle-network/agent-interface'\n\nimport { canonicalCandidateDigest, immutableCandidateValue } from '../candidate-execution/digest'\nimport { applyExactAgentProfileDiff, parseExactAgentProfile } from '../candidate-execution/profile'\nimport { verifyAgentImprovementProposal } from '../intelligence/improvement-cycle'\nimport canonicalAgentImprovementProposalFixture from './fixtures/agent-improvement-proposal.json'\nimport canonicalAgentProfileImprovementProposalFixture from './fixtures/agent-profile-improvement-proposal.json'\nimport canonicalAgentProfileImprovementStateFixture from './fixtures/agent-profile-improvement-state.json'\n\nexport {\n type DriverAgentOptions,\n driverAgent,\n} from '../runtime/supervise/coordination-driver'\nexport {\n type RunGraphTestOptions,\n runGraphWithTestBrain,\n} from '../runtime/supervise/graph'\nexport {\n type SuperviseTestOptions,\n superviseWithTestBrain,\n} from '../runtime/supervise/supervise'\nexport {\n type SupervisorAgentTestDeps,\n supervisorAgentWithTestBrain,\n} from '../runtime/supervise/supervisor-agent'\nexport type { ToolLoopCallContext, ToolLoopChat } from '../runtime/tool-loop'\n\nconst serializedAgentImprovementProposalFixture = JSON.stringify(\n canonicalAgentImprovementProposalFixture,\n)\nconst serializedAgentProfileImprovementProposalFixture = JSON.stringify(\n canonicalAgentProfileImprovementProposalFixture,\n)\nconst serializedAgentProfileImprovementStateFixture = JSON.stringify(\n canonicalAgentProfileImprovementStateFixture,\n)\n\n/** A proposal produced by Runtime's opaque profile-improvement path. */\nexport type AgentProfileImprovementProposalFixture = Omit<\n AgentImprovementProposal,\n 'evaluation'\n> & {\n evaluation: AgentProfileImprovementMeasuredComparison\n}\n\n/** Complete private state for exercising profile activation and restore in consumer tests. */\nexport interface AgentProfileImprovementFixture {\n proposal: AgentProfileImprovementProposalFixture\n baselineProfile: AgentProfile\n candidateProfile: AgentProfile\n recommendedSize: SandboxSizePreset\n}\n\n/** Load an isolated, production-validated Runtime proposal for consumer tests. */\nexport function loadAgentImprovementProposalFixture(): AgentImprovementProposal {\n return verifyAgentImprovementProposal(JSON.parse(serializedAgentImprovementProposalFixture))\n}\n\n/** Load an isolated profile proposal and its private activation state for consumer tests. */\nexport function loadAgentProfileImprovementFixture(): AgentProfileImprovementFixture {\n const proposal = loadAgentProfileImprovementProposal()\n const state = parseAgentProfileImprovementState(\n JSON.parse(serializedAgentProfileImprovementStateFixture),\n )\n const experiment = proposal.evaluation.experiment\n const baselineStateDigest = profileStateDigest(state.baselineProfile, state.recommendedSize)\n const candidateStateDigest = profileStateDigest(state.candidateProfile, state.recommendedSize)\n if (\n baselineStateDigest !== experiment.baseline.stateDigest ||\n candidateStateDigest !== experiment.candidate.stateDigest\n ) {\n throw new Error('profile improvement fixture state does not match its proposal')\n }\n const appliedCandidate = experiment.change.reduce(\n (profile, change, index) =>\n applyExactAgentProfileDiff(profile, change, `profile improvement fixture change ${index}`),\n state.baselineProfile,\n )\n if (\n canonicalAgentProfileDigest(appliedCandidate) !==\n canonicalAgentProfileDigest(state.candidateProfile)\n ) {\n throw new Error('profile improvement fixture candidate does not match its proposal changes')\n }\n return immutableCandidateValue({ proposal, ...state })\n}\n\nfunction loadAgentProfileImprovementProposal(): AgentProfileImprovementProposalFixture {\n const proposal = verifyAgentImprovementProposal(\n JSON.parse(serializedAgentProfileImprovementProposalFixture),\n )\n if (proposal.evaluation.kind !== 'agent-profile-improvement-measured-comparison') {\n throw new Error('profile improvement fixture contains a sealed candidate comparison')\n }\n return { ...proposal, evaluation: proposal.evaluation }\n}\n\nfunction parseAgentProfileImprovementState(\n input: unknown,\n): Omit<AgentProfileImprovementFixture, 'proposal'> {\n if (typeof input !== 'object' || input === null || Array.isArray(input)) {\n throw new Error('profile improvement fixture state must be an object')\n }\n const record = input as Record<string, unknown>\n const fields = Object.keys(record).sort()\n const expectedFields = ['baselineProfile', 'candidateProfile', 'recommendedSize']\n if (\n fields.length !== expectedFields.length ||\n fields.some((field, i) => field !== expectedFields[i])\n ) {\n throw new Error('profile improvement fixture state contains unsupported fields')\n }\n const recommendedSize = SANDBOX_SIZE_PRESET_NAMES.find((size) => size === record.recommendedSize)\n if (!recommendedSize) {\n throw new Error('profile improvement fixture has an invalid recommended size')\n }\n return {\n baselineProfile: parseExactAgentProfile(\n record.baselineProfile,\n 'profile improvement fixture baseline',\n ),\n candidateProfile: parseExactAgentProfile(\n record.candidateProfile,\n 'profile improvement fixture candidate',\n ),\n recommendedSize,\n }\n}\n\nfunction profileStateDigest(\n profile: AgentProfile,\n recommendedSize: SandboxSizePreset,\n): ReturnType<typeof canonicalCandidateDigest> {\n return canonicalCandidateDigest({ definition: profile, recommendedSize })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,MAAM,SAAS,SAAS,OAAO,eAAe;CAChG,IAAI,CAAC,iBACH,MAAM,IAAI,MAAM,6DAA6D;CAE/E,OAAO;EACL,iBAAiB,uBACf,OAAO,iBACP,sCACF;EACA,kBAAkB,uBAChB,OAAO,kBACP,uCACF;EACA;CACF;AACF;AAEA,SAAS,mBACP,SACA,iBAC6C;CAC7C,OAAOC,2BAAyB;EAAE,YAAY;EAAS;CAAgB,CAAC;AAC1E"}
@@ -4,7 +4,9 @@ import { createInterface } from "node:readline";
4
4
  /**
5
5
  * `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP
6
6
  * server core: `initialize` / `notifications/initialized` / `tools/list` /
7
- * `tools/call` over a stdio-shaped transport, protocol 2024-11-05.
7
+ * `ping` / `tools/call` over a stdio-shaped transport. It answers the
8
+ * client's protocol version when listed in `SUPPORTED_PROTOCOL_VERSIONS`,
9
+ * else 2024-11-05, and publishes tool annotations when a tool declares them.
8
10
  *
9
11
  * Extracted from `createMcpServer` (server.ts) so every in-repo MCP server —
10
12
  * the delegation server, the memory server — serves the ONE wire protocol the
@@ -15,6 +17,17 @@ import { createInterface } from "node:readline";
15
17
  * @experimental
16
18
  */
17
19
  const PROTOCOL_VERSION = "2024-11-05";
20
+ /**
21
+ * Protocol versions this server speaks, newest first. `initialize` answers with
22
+ * the client's requested version when it is listed here, and otherwise with
23
+ * `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.
24
+ */
25
+ const SUPPORTED_PROTOCOL_VERSIONS = [
26
+ "2025-11-25",
27
+ "2025-06-18",
28
+ "2025-03-26",
29
+ PROTOCOL_VERSION
30
+ ];
18
31
  /** Build the generic stdio JSON-RPC tool server. */
19
32
  function createStdioToolServer(options) {
20
33
  const tools = /* @__PURE__ */ new Map();
@@ -26,19 +39,24 @@ function createStdioToolServer(options) {
26
39
  let activeReadline;
27
40
  async function handle(message) {
28
41
  if (stopped) return rpcError(message.id ?? null, -32099, "server stopped");
29
- if (message.method === "initialize") return rpcResult(message.id ?? null, {
30
- protocolVersion: PROTOCOL_VERSION,
31
- capabilities: { tools: {} },
32
- serverInfo: {
33
- name: options.serverName,
34
- version: options.serverVersion
35
- }
36
- });
42
+ if (message.method === "initialize") {
43
+ const requested = message.params?.protocolVersion;
44
+ return rpcResult(message.id ?? null, {
45
+ protocolVersion: typeof requested === "string" && SUPPORTED_PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSION,
46
+ capabilities: { tools: {} },
47
+ serverInfo: {
48
+ name: options.serverName,
49
+ version: options.serverVersion
50
+ }
51
+ });
52
+ }
37
53
  if (message.method === "notifications/initialized") return null;
54
+ if (message.method === "ping") return rpcResult(message.id ?? null, {});
38
55
  if (message.method === "tools/list") return rpcResult(message.id ?? null, { tools: [...tools.values()].map((tool) => ({
39
56
  name: tool.name,
40
57
  description: tool.description,
41
- inputSchema: tool.inputSchema
58
+ inputSchema: tool.inputSchema,
59
+ ...tool.annotations ? { annotations: tool.annotations } : {}
42
60
  })) });
43
61
  if (message.method === "tools/call") {
44
62
  const params = message.params ?? {};
@@ -149,6 +167,6 @@ function writeResponse(output, response) {
149
167
  output.write(`${JSON.stringify(response)}\n`);
150
168
  }
151
169
  //#endregion
152
- export { createStdioToolServer as n, PROTOCOL_VERSION as t };
170
+ export { SUPPORTED_PROTOCOL_VERSIONS as n, createStdioToolServer as r, PROTOCOL_VERSION as t };
153
171
 
154
- //# sourceMappingURL=tool-server-x9NEhvHZ.js.map
172
+ //# sourceMappingURL=tool-server-Dqer2M4_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-server-Dqer2M4_.js","names":[],"sources":["../src/mcp/tool-server.ts"],"sourcesContent":["/**\n * `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP\n * server core: `initialize` / `notifications/initialized` / `tools/list` /\n * `ping` / `tools/call` over a stdio-shaped transport. It answers the\n * client's protocol version when listed in `SUPPORTED_PROTOCOL_VERSIONS`,\n * else 2024-11-05, and publishes tool annotations when a tool declares them.\n *\n * Extracted from `createMcpServer` (server.ts) so every in-repo MCP server —\n * the delegation server, the memory server — serves the ONE wire protocol the\n * same-host client (`connectStdioMcp`, runtime/stdio-mcp-client.ts) speaks.\n * A second hand-rolled serve loop could drift from what the client expects;\n * this core makes that impossible by construction.\n *\n * @experimental\n */\n\nimport { createInterface, type Interface as ReadlineInterface } from 'node:readline'\nimport { ValidationError } from '../errors'\nimport type { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } from './protocol'\n\nexport type {\n JsonRpcMessage,\n JsonRpcResponse,\n McpToolAnnotations,\n McpToolDescriptor,\n McpTransport,\n} from './protocol'\n\nexport const PROTOCOL_VERSION = '2024-11-05'\n\n/**\n * Protocol versions this server speaks, newest first. `initialize` answers with\n * the client's requested version when it is listed here, and otherwise with\n * `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.\n */\nexport const SUPPORTED_PROTOCOL_VERSIONS: readonly string[] = [\n '2025-11-25',\n '2025-06-18',\n '2025-03-26',\n PROTOCOL_VERSION,\n]\n\n/** @experimental */\nexport interface StdioToolServerOptions {\n /** Server display name surfaced via `initialize`. */\n serverName: string\n /** Server version surfaced via `initialize`. */\n serverVersion: string\n /** The tools to serve. Duplicate names throw — a silent shadow would hide a tool. */\n tools: readonly McpToolDescriptor[]\n}\n\n/** @experimental */\nexport interface StdioToolServer {\n /** Tools currently registered, keyed by name. */\n readonly tools: ReadonlyMap<string, McpToolDescriptor>\n /** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */\n handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>\n /** Drive the server on a stdio-shaped transport until `stop()` is called. */\n serve(transport?: McpTransport): Promise<void>\n /** Stop a `serve` call. Subsequent requests are rejected. */\n stop(): void\n}\n\n/** Build the generic stdio JSON-RPC tool server. */\nexport function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer {\n const tools = new Map<string, McpToolDescriptor>()\n for (const tool of options.tools) {\n if (tools.has(tool.name)) {\n throw new ValidationError(`createStdioToolServer: duplicate tool name \"${tool.name}\"`)\n }\n tools.set(tool.name, tool)\n }\n\n let stopped = false\n let activeReadline: ReadlineInterface | undefined\n\n async function handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null> {\n if (stopped) {\n return rpcError(message.id ?? null, -32099, 'server stopped')\n }\n if (message.method === 'initialize') {\n const requested = (message.params as { protocolVersion?: unknown } | undefined)\n ?.protocolVersion\n return rpcResult(message.id ?? null, {\n protocolVersion:\n typeof requested === 'string' && SUPPORTED_PROTOCOL_VERSIONS.includes(requested)\n ? requested\n : PROTOCOL_VERSION,\n capabilities: { tools: {} },\n serverInfo: { name: options.serverName, version: options.serverVersion },\n })\n }\n if (message.method === 'notifications/initialized') {\n // MCP clients send this after the handshake; it has no id and expects\n // no response.\n return null\n }\n if (message.method === 'ping') {\n return rpcResult(message.id ?? null, {})\n }\n if (message.method === 'tools/list') {\n return rpcResult(message.id ?? null, {\n tools: [...tools.values()].map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n ...(tool.annotations ? { annotations: tool.annotations } : {}),\n })),\n })\n }\n if (message.method === 'tools/call') {\n const params = (message.params ?? {}) as { name?: unknown; arguments?: unknown }\n const name = typeof params.name === 'string' ? params.name : ''\n const tool = tools.get(name)\n if (!tool) {\n return rpcError(message.id ?? null, -32601, `unknown tool: ${name}`)\n }\n try {\n const output = await tool.handler(params.arguments ?? {})\n return rpcResult(message.id ?? null, toolCallResult(output))\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err)\n const code = err instanceof TypeError || err instanceof RangeError ? -32602 : -32000\n return rpcError(message.id ?? null, code, reason)\n }\n }\n if (message.id === undefined || message.id === null) return null\n return rpcError(message.id, -32601, `unknown method: ${message.method}`)\n }\n\n async function serve(transport?: McpTransport): Promise<void> {\n const input = transport?.input ?? process.stdin\n const output = transport?.output ?? process.stdout\n const rl = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY })\n activeReadline = rl\n return new Promise<void>((resolve, reject) => {\n rl.on('line', (line) => {\n const trimmed = line.trim()\n if (!trimmed) return\n let parsed: JsonRpcMessage | undefined\n try {\n parsed = JSON.parse(trimmed) as JsonRpcMessage\n } catch (err) {\n writeResponse(output, rpcError(null, -32700, `parse error: ${(err as Error).message}`))\n return\n }\n if (parsed?.jsonrpc !== '2.0' || typeof parsed.method !== 'string') {\n writeResponse(output, rpcError(parsed?.id ?? null, -32600, 'invalid request'))\n return\n }\n void handle(parsed).then((response) => {\n if (response) writeResponse(output, response)\n })\n })\n rl.on('close', () => resolve())\n rl.on('error', (err) => reject(err))\n if (stopped) {\n rl.close()\n resolve()\n }\n })\n }\n\n function stop(): void {\n stopped = true\n activeReadline?.close()\n activeReadline = undefined\n }\n\n return { tools, handle, serve, stop }\n}\n\nfunction toolCallResult(output: unknown): {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n} {\n let json: string | undefined\n try {\n json = JSON.stringify(output)\n } catch (err) {\n const reason = err instanceof Error ? `: ${err.message}` : ''\n throw new TypeError(`MCP tool result must be JSON-serializable${reason}`, { cause: err })\n }\n if (json === undefined) {\n throw new TypeError('MCP tool result must be JSON-serializable')\n }\n\n const serialized = JSON.parse(json) as unknown\n // Preserve string content verbatim. MCP clients pass this text directly to the calling agent.\n const result: {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n } = {\n content: [{ type: 'text', text: typeof serialized === 'string' ? serialized : json }],\n isError: false,\n }\n if (serialized !== null && typeof serialized === 'object' && !Array.isArray(serialized)) {\n result.structuredContent = serialized as Record<string, unknown>\n }\n return result\n}\n\nfunction rpcResult(id: number | string | null, result: unknown): JsonRpcResponse {\n return { jsonrpc: '2.0', id, result }\n}\n\nfunction rpcError(\n id: number | string | null,\n code: number,\n message: string,\n data?: unknown,\n): JsonRpcResponse {\n return {\n jsonrpc: '2.0',\n id,\n error: data === undefined ? { code, message } : { code, message, data },\n }\n}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;AAC9C"}
@@ -1,4 +1,4 @@
1
- import { Ct as ProvisionedSupervisor, St as ProvisionSupervisorRequest, Tt as provisionSupervisor, wt as SupervisorCleanupReceipt, xt as ProvisionSupervisorConnection } from "../index-9wXpbjbX.js";
1
+ import { Dt as ProvisionedSupervisor, Et as ProvisionSupervisorRequest, Ot as SupervisorCleanupReceipt, Tt as ProvisionSupervisorConnection, kt as provisionSupervisor } from "../index-CL1dduJd.js";
2
2
  //#region src/tui/top-app.d.ts
3
3
  /**
4
4
  * The interactive side of the supervisor-run TUI: a keypress/mouse loop over the frames
package/dist/tui/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as provisionSupervisor } from "../provision-supervisor-BZ6_uBGR.js";
1
+ import { t as provisionSupervisor } from "../provision-supervisor-Cy8pqE95.js";
2
2
  import { a as renderTopFrameWithLayout, i as renderTopFrame, n as runTopApp, r as loadTopSnapshot, t as renderTopOnce } from "../top-app-VAOrBskv.js";
3
3
  export { loadTopSnapshot, provisionSupervisor, renderTopFrame, renderTopFrameWithLayout, renderTopOnce, runTopApp };