@tangle-network/agent-runtime 0.349.0 → 0.352.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/{activation-wBipBkCf.d.ts → activation-BidzGkUQ.d.ts} +2 -24
  2. package/dist/{activation-tNGW73Y9.js → activation-C6zNC2kx.js} +12 -14
  3. package/dist/{activation-tNGW73Y9.js.map → activation-C6zNC2kx.js.map} +1 -1
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-1xaJEgjq.js → bundle-DeDkJbsr.js} +3 -4
  12. package/dist/{bundle-1xaJEgjq.js.map → bundle-DeDkJbsr.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/chat-turn.d.ts +2 -0
  17. package/dist/chat-turn.js +1 -0
  18. package/dist/{coordination-manager-B2Z_MmL9.js → coordination-manager-B7QadgrI.js} +101 -132
  19. package/dist/{coordination-manager-B2Z_MmL9.js.map → coordination-manager-B7QadgrI.js.map} +1 -1
  20. package/dist/{delegate-Dr-63jFl.js → delegate-CoscoyEo.js} +19 -21
  21. package/dist/delegate-CoscoyEo.js.map +1 -0
  22. package/dist/durable.d.ts +16 -149
  23. package/dist/durable.js +57 -980
  24. package/dist/durable.js.map +1 -1
  25. package/dist/{errors-DodWX-cb.js → errors-AzSuGI23.js} +5 -3
  26. package/dist/errors-AzSuGI23.js.map +1 -0
  27. package/dist/execution-handle-Bd2_nUB6.js +167 -0
  28. package/dist/execution-handle-Bd2_nUB6.js.map +1 -0
  29. package/dist/execution-handle-CujvqgCn.d.ts +130 -0
  30. package/dist/{graph-DPejYB3C.js → graph-mojMML8e.js} +192 -14
  31. package/dist/graph-mojMML8e.js.map +1 -0
  32. package/dist/{improve-DwSahPi1.js → improve-Dm5ZE8mr.js} +36 -53
  33. package/dist/{improve-DwSahPi1.js.map → improve-Dm5ZE8mr.js.map} +1 -1
  34. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  35. package/dist/index.d.ts +41 -89
  36. package/dist/index.js +45 -61
  37. package/dist/index.js.map +1 -1
  38. package/dist/intelligence.d.ts +39 -59
  39. package/dist/intelligence.js +24 -33
  40. package/dist/intelligence.js.map +1 -1
  41. package/dist/journal-store-BJPMUydp.js +3925 -0
  42. package/dist/journal-store-BJPMUydp.js.map +1 -0
  43. package/dist/kernel.d.ts +5 -5
  44. package/dist/kernel.js +12 -11
  45. package/dist/{loop-runner-CP6MfO1b.js → loop-runner-5cL_vZi0.js} +5 -6
  46. package/dist/{loop-runner-CP6MfO1b.js.map → loop-runner-5cL_vZi0.js.map} +1 -1
  47. package/dist/{loop-runner-C6pGq-2l.d.ts → loop-runner-DyLD-aNb.d.ts} +3 -5
  48. package/dist/loop-runner-bin.d.ts +5 -8
  49. package/dist/loop-runner-bin.js +2 -3
  50. package/dist/mcp/bin.js +6 -8
  51. package/dist/mcp/bin.js.map +1 -1
  52. package/dist/mcp/index.d.ts +8 -18
  53. package/dist/mcp/index.js +17 -25
  54. package/dist/mcp/index.js.map +1 -1
  55. package/dist/mcp/memory-bin.js +4 -6
  56. package/dist/mcp/memory-bin.js.map +1 -1
  57. package/dist/{model-policy-CyCUwHed.js → model-policy-C-RGAUW4.js} +11 -13
  58. package/dist/{model-policy-CyCUwHed.js.map → model-policy-C-RGAUW4.js.map} +1 -1
  59. package/dist/placement.d.ts +12 -14
  60. package/dist/placement.js +1 -2
  61. package/dist/platform.d.ts +7 -13
  62. package/dist/platform.js +3 -6
  63. package/dist/platform.js.map +1 -1
  64. package/dist/{prepare-B9wWffjO.js → prepare-XWwsOh8O.js} +50 -69
  65. package/dist/{prepare-B9wWffjO.js.map → prepare-XWwsOh8O.js.map} +1 -1
  66. package/dist/{profile-JLJd2wFG.js → profile-C01SQZKa.js} +58 -92
  67. package/dist/profile-C01SQZKa.js.map +1 -0
  68. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  69. package/dist/profiles.d.ts +25 -12
  70. package/dist/profiles.js +52 -11
  71. package/dist/profiles.js.map +1 -1
  72. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  73. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  74. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  75. package/dist/{provision-supervisor-C4v2vqDo.js → provision-supervisor-D9pO-iPl.js} +11 -15
  76. package/dist/{provision-supervisor-C4v2vqDo.js.map → provision-supervisor-D9pO-iPl.js.map} +1 -1
  77. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-CoJRKvih.js} +6 -7
  78. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-CoJRKvih.js.map} +1 -1
  79. package/dist/{runtime-CsvGCQpl.js → runtime-BJPXHWbc.js} +652 -215
  80. package/dist/runtime-BJPXHWbc.js.map +1 -0
  81. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  82. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  83. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  84. package/dist/{sandbox-profile-compat-DtuJWFrM.js → sandbox-profile-compat-CXjozdWL.js} +52 -653
  85. package/dist/sandbox-profile-compat-CXjozdWL.js.map +1 -0
  86. package/dist/{search-executor-CCb82Umc.js → search-executor-CQEHMXoT.js} +12 -15
  87. package/dist/{search-executor-CCb82Umc.js.map → search-executor-CQEHMXoT.js.map} +1 -1
  88. package/dist/{server-CKPwZU-I.js → server-U9NGgudQ.js} +19 -30
  89. package/dist/{server-CKPwZU-I.js.map → server-U9NGgudQ.js.map} +1 -1
  90. package/dist/{structural-rollout-DylC_fwU.js → structural-rollout-wMSxE7bn.js} +71 -70
  91. package/dist/structural-rollout-wMSxE7bn.js.map +1 -0
  92. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  93. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  94. package/dist/{supervise-BGfm2GlY.js → supervise-CNNhX0ab.js} +460 -195
  95. package/dist/supervise-CNNhX0ab.js.map +1 -0
  96. package/dist/supervision-discovery-CewADdEs.js +772 -0
  97. package/dist/supervision-discovery-CewADdEs.js.map +1 -0
  98. package/dist/{supervisor-wS9Ehz_x.js → supervisor-rK5Y8en6.js} +521 -4320
  99. package/dist/supervisor-rK5Y8en6.js.map +1 -0
  100. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  101. package/dist/task-queue.d.ts +1 -1
  102. package/dist/task-queue.js +1 -2
  103. package/dist/testing.d.ts +7 -15
  104. package/dist/testing.js +241 -244
  105. package/dist/testing.js.map +1 -1
  106. package/dist/tool-loop.d.ts +16 -19
  107. package/dist/tool-loop.js +2 -3
  108. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CZWd_Opp.js} +3 -4
  109. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CZWd_Opp.js.map} +1 -1
  110. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-DcV7VG4m.js} +179 -163
  111. package/dist/top-snapshot-DcV7VG4m.js.map +1 -0
  112. package/dist/tui/bin.js +50 -81
  113. package/dist/tui/bin.js.map +1 -1
  114. package/dist/tui/index.d.ts +27 -58
  115. package/dist/tui/index.js +2 -2
  116. package/dist/{types-C8BGOCBn.d.ts → types-0uzVKtFW.d.ts} +388 -484
  117. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  118. package/dist/util-ebWMWzY0.js +624 -0
  119. package/dist/util-ebWMWzY0.js.map +1 -0
  120. package/dist/workspace-store/index.d.ts +12 -22
  121. package/dist/workspace-store/index.js +13 -10
  122. package/dist/workspace-store/index.js.map +1 -1
  123. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  124. package/package.json +31 -26
  125. package/skills/agent-graphs/SKILL.md +17 -4
  126. package/skills/be-ambitious/SKILL.md +46 -0
  127. package/skills/graph-designer/SKILL.md +9 -2
  128. package/dist/delegate-Dr-63jFl.js.map +0 -1
  129. package/dist/errors-DodWX-cb.js.map +0 -1
  130. package/dist/graph-DPejYB3C.js.map +0 -1
  131. package/dist/profile-JLJd2wFG.js.map +0 -1
  132. package/dist/record-events-D93DkpAx.js +0 -263
  133. package/dist/record-events-D93DkpAx.js.map +0 -1
  134. package/dist/runtime-CsvGCQpl.js.map +0 -1
  135. package/dist/sandbox-profile-compat-DtuJWFrM.js.map +0 -1
  136. package/dist/structural-rollout-DylC_fwU.js.map +0 -1
  137. package/dist/supervise-BGfm2GlY.js.map +0 -1
  138. package/dist/supervisor-wS9Ehz_x.js.map +0 -1
  139. package/dist/top-snapshot-CflmaDgk.js.map +0 -1
@@ -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 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/activation'\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 type { DriverAgentOptions } from '../runtime/supervise/driver-agent-options'\nexport { driverAgent } from '../runtime/supervise/driver-brain-agent'\nexport { type RunGraphTestOptions, runGraphWithTestBrain } from '../runtime/supervise/graph'\nexport { superviseWithTestBrain } from '../runtime/supervise/supervise'\nexport { supervisorAgentWithTestBrain } 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\nexport type {\n GraphSubtaskPreparation,\n GraphSubtasks,\n PeerAuditAccess,\n SpawnPreflight,\n SpawnPreflightContext,\n SpawnRefusal,\n} from '../mcp/tools/coordination-contracts'\nexport type { AuthorizeDownMessage } from '../mcp/tools/coordination-messages'\nexport type { ChildQuestionInbox } from '../mcp/tools/coordination-questions'\nexport type {\n CoordinationDeliveryEvidence,\n PriorCoordination,\n} from '../runtime/supervise/coordination-log'\nexport type { SuperviseTestOptions } from '../runtime/supervise/supervise-options'\nexport type { SupervisorAgentTestDeps } from '../runtime/supervise/supervisor-agent-contracts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CAEjF,MAAM,kBAAkB,0BAA0B,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"}
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 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/activation'\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 type { DriverAgentOptions } from '../runtime/supervise/driver-agent-options'\nexport { driverAgent } from '../runtime/supervise/driver-brain-agent'\nexport { type RunGraphTestOptions, runGraphWithTestBrain } from '../runtime/supervise/graph'\nexport { superviseWithTestBrain } from '../runtime/supervise/supervise'\nexport { supervisorAgentWithTestBrain } 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\nexport type {\n GraphSubtaskPreparation,\n GraphSubtasks,\n PeerAuditAccess,\n SpawnPreflight,\n SpawnPreflightContext,\n SpawnRefusal,\n} from '../mcp/tools/coordination-contracts'\nexport type { AuthorizeDownMessage } from '../mcp/tools/coordination-messages'\nexport type { ChildQuestionInbox } from '../mcp/tools/coordination-questions'\nexport type {\n CoordinationDeliveryEvidence,\n PriorCoordination,\n} from '../runtime/supervise/coordination-log'\nexport type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AgB,GAElD,MAAM,IAAI,MAAM,2EAA2E;CAE7F,OAAO,wBAAwB;EAAE;EAAU,GAAG;CAAM,CAAC;AACvD;AAEA,SAAS,sCAA8E;CACrF,MAAM,WAAW,+BACf,KAAK,MAAM,gDAAgD,CAC7D;CACA,IAAI,SAAS,WAAW,SAAS,iDAC/B,MAAM,IAAI,MAAM,oEAAoE;CAEtF,OAAO;EAAE,GAAG;EAAU,YAAY,SAAS;CAAW;AACxD;AAEA,SAAS,kCACP,OACkD;CAClD,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,MAAM,IAAI,MAAM,qDAAqD;CAEvE,MAAM,SAAS;CACf,MAAM,SAAS,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK;CACxC,MAAM,iBAAiB;EAAC;EAAmB;EAAoB;CAAiB;CAChF,IACE,OAAO,WAAW,eAAe,UACjC,OAAO,MAAM,OAAO,MAAM,UAAU,eAAe,EAAE,GAErD,MAAM,IAAI,MAAM,+DAA+D;CAEjF,MAAM,kBAAkB,0BAA0B,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"}
@@ -1,6 +1,5 @@
1
- import { l as RuntimeHooks } from "./runtime-hooks-nsqxSUFL.js";
2
- //#region src/tool-loop.d.ts
3
- interface ToolLoopCall {
1
+ import { l as RuntimeHooks } from "./runtime-hooks-ZQqPw-0g.js";
2
+ export interface ToolLoopCall {
4
3
  toolCallId?: string;
5
4
  toolName: string;
6
5
  args: Record<string, unknown>;
@@ -14,7 +13,7 @@ interface ToolLoopCall {
14
13
  }
15
14
  /** Outcome of one tool dispatch — structurally compatible with a hub/integration
16
15
  * tool-outcome union, so callers can fold either through the loop. */
17
- type ToolCallOutcome = {
16
+ export type ToolCallOutcome = {
18
17
  ok: true;
19
18
  result: unknown;
20
19
  } | {
@@ -25,7 +24,7 @@ type ToolCallOutcome = {
25
24
  };
26
25
  /** One OpenAI-shaped tool-call entry carried on an assistant message, plus any
27
26
  * provider-specific fields the model attached to the call (`ToolLoopCall.providerFields`). */
28
- interface ToolLoopAssistantToolCall {
27
+ export interface ToolLoopAssistantToolCall {
29
28
  [providerField: string]: unknown;
30
29
  id: string;
31
30
  type: 'function';
@@ -51,7 +50,7 @@ interface ToolLoopAssistantToolCall {
51
50
  * works; one that forwards the whole message to an OpenAI-compatible endpoint
52
51
  * now sends correct tool history.
53
52
  */
54
- type ToolLoopMessage = {
53
+ export type ToolLoopMessage = {
55
54
  role: string;
56
55
  content: string | null;
57
56
  tool_calls?: ToolLoopAssistantToolCall[];
@@ -62,14 +61,14 @@ type ToolLoopMessage = {
62
61
  * payload: a free-text `message`, a monotonic `progress` count with an optional
63
62
  * `total`, and any structured `data` the caller's UI understands.
64
63
  */
65
- interface ToolProgressUpdate {
64
+ export interface ToolProgressUpdate {
66
65
  message?: string;
67
66
  progress?: number;
68
67
  total?: number;
69
68
  data?: unknown;
70
69
  }
71
70
  /** What the loop hands a running tool besides its call. */
72
- interface ToolCallContext {
71
+ export interface ToolCallContext {
73
72
  /**
74
73
  * Report progress while the call runs. The streaming loop yields each update as a
75
74
  * `tool_progress` step, in order, before the call's `tool_result`; updates sent after
@@ -78,8 +77,8 @@ interface ToolCallContext {
78
77
  progress: (update: ToolProgressUpdate) => void;
79
78
  }
80
79
  /** Executes one tool call. Implementations that take only the call stay valid. */
81
- type ToolCallExecutor = (call: ToolLoopCall, context: ToolCallContext) => Promise<ToolCallOutcome>;
82
- type ToolLoopEvent = {
80
+ export type ToolCallExecutor = (call: ToolLoopCall, context: ToolCallContext) => Promise<ToolCallOutcome>;
81
+ export type ToolLoopEvent = {
83
82
  type: 'text';
84
83
  text: string;
85
84
  } | {
@@ -94,8 +93,8 @@ type ToolLoopEvent = {
94
93
  * runaway-backstop cap (200 by default); `deadline` = wall-clock deadlineMs
95
94
  * exceeded; `budget` = maxCostUsd exhausted. Non-`completed` stops are infra /
96
95
  * resource outcomes — eval scoring must distinguish them from capability failure. */
97
- type ToolLoopStopReason = 'completed' | 'stuck-loop' | 'backstop' | 'deadline' | 'budget';
98
- interface ToolLoopResult {
96
+ export type ToolLoopStopReason = 'completed' | 'stuck-loop' | 'backstop' | 'deadline' | 'budget';
97
+ export interface ToolLoopResult {
99
98
  finalText: string;
100
99
  toolResults: Array<{
101
100
  call: ToolLoopCall;
@@ -107,7 +106,7 @@ interface ToolLoopResult {
107
106
  /** @deprecated Use `stopReason !== 'completed'` instead. */
108
107
  cappedOut: boolean;
109
108
  }
110
- interface RunToolLoopOptions {
109
+ export interface RunToolLoopOptions {
111
110
  systemPrompt: string;
112
111
  userMessage: string;
113
112
  priorMessages?: ToolLoopMessage[];
@@ -135,8 +134,8 @@ interface RunToolLoopOptions {
135
134
  /** Run the bounded tool loop and return the final text + every executed tool
136
135
  * outcome. Awaitable — callers needing to stream events to a UI use
137
136
  * {@link streamToolLoop}. */
138
- declare function runToolLoop(opts: RunToolLoopOptions): Promise<ToolLoopResult>;
139
- type StreamToolLoopYield<Raw> = {
137
+ export declare function runToolLoop(opts: RunToolLoopOptions): Promise<ToolLoopResult>;
138
+ export type StreamToolLoopYield<Raw> = {
140
139
  kind: 'event';
141
140
  event: Raw;
142
141
  } | {
@@ -158,7 +157,7 @@ type StreamToolLoopYield<Raw> = {
158
157
  * Passing it back as `priorMessages` with no `userMessage` continues the same turn. */
159
158
  messages?: ToolLoopMessage[];
160
159
  };
161
- interface StreamToolLoopOptions<Raw> {
160
+ export interface StreamToolLoopOptions<Raw> {
162
161
  systemPrompt: string;
163
162
  /** Omit to continue a checkpointed turn whose `priorMessages` already end with tool results. */
164
163
  userMessage?: string;
@@ -186,7 +185,5 @@ interface StreamToolLoopOptions<Raw> {
186
185
  * telemetries + re-emits it), each `tool_progress` a running tool reports, and
187
186
  * each executed `tool_result`; emits one `capped` if it stops for any
188
187
  * non-completed reason with calls still pending. */
189
- declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
190
- //#endregion
191
- export { RunToolLoopOptions, StreamToolLoopOptions, StreamToolLoopYield, ToolCallContext, ToolCallExecutor, ToolCallOutcome, ToolLoopAssistantToolCall, ToolLoopCall, ToolLoopEvent, ToolLoopMessage, ToolLoopResult, ToolLoopStopReason, ToolProgressUpdate, runToolLoop, streamToolLoop };
188
+ export declare function streamToolLoop<Raw>(opts: StreamToolLoopOptions<Raw>): AsyncGenerator<StreamToolLoopYield<Raw>, void, unknown>;
192
189
  //# sourceMappingURL=tool-loop.d.ts.map
package/dist/tool-loop.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as notifyRuntimeHookEvent, r as notifyRuntimeDecisionPoint } from "./runtime-hooks-tXpAarhW.js";
2
- //#region src/tool-loop.ts
1
+ import { i as notifyRuntimeHookEvent, r as notifyRuntimeDecisionPoint } from "./runtime-hooks-CsW2pfFk.js";
2
+ // src/tool-loop.ts
3
3
  /** Runaway-backstop: stops an infinite tool loop where cost is unmetered. Set
4
4
  * far above any legitimate workflow — this is a watchdog, not a policy cap.
5
5
  * Legitimate per-call budgets come from `maxCostUsd` + `costOf`. */
@@ -652,7 +652,6 @@ function trimText(text, max) {
652
652
  function randomSuffix(len = 8) {
653
653
  return Math.random().toString(36).slice(2, 2 + len);
654
654
  }
655
- //#endregion
656
655
  export { runToolLoop, streamToolLoop };
657
656
 
658
657
  //# sourceMappingURL=tool-loop.js.map
@@ -1,6 +1,6 @@
1
- import { m as ValidationError } from "./errors-DodWX-cb.js";
1
+ import { m as ValidationError } from "./errors-AzSuGI23.js";
2
2
  import { createInterface } from "node:readline";
3
- //#region src/mcp/tool-server.ts
3
+ // src/mcp/tool-server.ts
4
4
  /**
5
5
  * `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP
6
6
  * server core: `initialize` / `notifications/initialized` / `tools/list` /
@@ -166,7 +166,6 @@ function rpcError(id, code, message, data) {
166
166
  function writeResponse(output, response) {
167
167
  output.write(`${JSON.stringify(response)}\n`);
168
168
  }
169
- //#endregion
170
169
  export { createStdioToolServer as n, PROTOCOL_VERSION as t };
171
170
 
172
- //# sourceMappingURL=tool-server-XV4aJwoQ.js.map
171
+ //# sourceMappingURL=tool-server-CZWd_Opp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-server-XV4aJwoQ.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 { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } 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 */\nconst 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}\n\nfunction writeResponse(output: NodeJS.WritableStream, response: JsonRpcResponse): void {\n output.write(`${JSON.stringify(response)}\\n`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB;;;;;;AAOhC,MAAM,8BAAiD;CACrD;CACA;CACA;CACA;AACF;;AAyBA,SAAgB,sBAAsB,SAAkD;CACtF,MAAM,wBAAQ,IAAI,IAA+B;CACjD,KAAK,MAAM,QAAQ,QAAQ,OAAO;EAChC,IAAI,MAAM,IAAI,KAAK,IAAI,GACrB,MAAM,IAAI,gBAAgB,+CAA+C,KAAK,KAAK,EAAE;EAEvF,MAAM,IAAI,KAAK,MAAM,IAAI;CAC3B;CAEA,IAAI,UAAU;CACd,IAAI;CAEJ,eAAe,OAAO,SAA0D;EAC9E,IAAI,SACF,OAAO,SAAS,QAAQ,MAAM,MAAM,QAAQ,gBAAgB;EAE9D,IAAI,QAAQ,WAAW,cAAc;GACnC,MAAM,YAAa,QAAQ,QACvB;GACJ,OAAO,UA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,MAAM,IAAI,UAAU,2CAA2C;CAGjE,MAAM,aAAa,KAAK,MAAM,IAAI;CAElC,MAAM,SAIF;EACF,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,OAAO,eAAe,WAAW,aAAa;EAAK,CAAC;EACpF,SAAS;CACX;CACA,IAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,CAAC,MAAM,QAAQ,UAAU,GACpF,OAAO,oBAAoB;CAE7B,OAAO;AACT;AAEA,SAAS,UAAU,IAA4B,QAAkC;CAC/E,OAAO;EAAE,SAAS;EAAO;EAAI;CAAO;AACtC;AAEA,SAAS,SACP,IACA,MACA,SACA,MACiB;CACjB,OAAO;EACL,SAAS;EACT;EACA,OAAO,SAAS,KAAA,IAAY;GAAE;GAAM;EAAQ,IAAI;GAAE;GAAM;GAAS;EAAK;CACxE;AACF;AAEA,SAAS,cAAc,QAA+B,UAAiC;CACrF,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,EAAE,GAAG;AAC9C"}
1
+ {"version":3,"file":"tool-server-CZWd_Opp.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 { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } 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 */\nconst 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}\n\nfunction writeResponse(output: NodeJS.WritableStream, response: JsonRpcResponse): void {\n output.write(`${JSON.stringify(response)}\\n`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB;;;;;;AAOhC,MAAM,8BAAiD;CACrD;CACA;CACA;CACA;AACF;;AAyBA,SAAgB,sBAAsB,SAAkD;CACtF,MAAM,wBAAQ,IAAI,IAA+B;CACjD,KAAK,MAAM,QAAQ,QAAQ,OAAO;EAChC,IAAI,MAAM,IAAI,KAAK,IAAI,GACrB,MAAM,IAAI,gBAAgB,+CAA+C,KAAK,KAAK,EAAE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