@1mcp/agent 0.39.6 → 0.40.0-beta.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 (488) hide show
  1. package/README.md +14 -7
  2. package/build/admin/assets/{admin-BackendLogsWorkspace-BKavXT9B.js → admin-BackendLogsWorkspace-DnPzXW3E.js} +1 -1
  3. package/build/admin/assets/{admin-InstructionTemplatesWorkspace-CvG4EPdZ.js → admin-InstructionTemplatesWorkspace-B7beKEgz.js} +1 -1
  4. package/build/admin/assets/{admin-OAuthServicesWorkspace-BKqTW6r0.js → admin-OAuthServicesWorkspace-Bu74Bzt5.js} +1 -1
  5. package/build/admin/assets/{admin-PresetAuthoringWorkspace-BboJVBFl.js → admin-PresetAuthoringWorkspace-053b1zwU.js} +1 -1
  6. package/build/admin/assets/{admin-console-BwfDrlgF.js → admin-console-DVuqABnE.js} +3 -3
  7. package/build/admin/assets/admin-icons-wOzB38gm.js +1 -0
  8. package/build/admin/assets/admin-vendor-BLZ1Mauf.js +3 -0
  9. package/build/admin/assets/admin-vendor-BdHKHno1.js +1 -0
  10. package/build/admin/assets/admin-vendor-BqYiU41k.js +51 -0
  11. package/build/admin/assets/admin-vendor-C291Vs-N.js +3 -0
  12. package/build/admin/assets/admin-vendor-VzhcFgoy.js +1 -0
  13. package/build/admin/index.html +7 -5
  14. package/build/application/backendPreparationAdmission.d.ts +77 -0
  15. package/build/application/backendPreparationAdmission.d.ts.map +1 -0
  16. package/build/application/backendPreparationAdmission.js +423 -0
  17. package/build/application/backendPreparationAdmission.js.map +1 -0
  18. package/build/application/backendPreparationCoordinator.d.ts +122 -0
  19. package/build/application/backendPreparationCoordinator.d.ts.map +1 -0
  20. package/build/application/backendPreparationCoordinator.js +885 -0
  21. package/build/application/backendPreparationCoordinator.js.map +1 -0
  22. package/build/application/projectLifecycle.d.ts +49 -0
  23. package/build/application/projectLifecycle.d.ts.map +1 -0
  24. package/build/application/projectLifecycle.js +228 -0
  25. package/build/application/projectLifecycle.js.map +1 -0
  26. package/build/cli.d.ts.map +1 -1
  27. package/build/cli.js +39 -17
  28. package/build/cli.js.map +1 -1
  29. package/build/commands/admin/index.d.ts.map +1 -1
  30. package/build/commands/admin/index.js +2 -6
  31. package/build/commands/admin/index.js.map +1 -1
  32. package/build/commands/app/index.d.ts.map +1 -1
  33. package/build/commands/app/index.js +5 -17
  34. package/build/commands/app/index.js.map +1 -1
  35. package/build/commands/auth/index.d.ts.map +1 -1
  36. package/build/commands/auth/index.js +2 -7
  37. package/build/commands/auth/index.js.map +1 -1
  38. package/build/commands/bootstrap/bootstrap.d.ts +38 -0
  39. package/build/commands/bootstrap/bootstrap.d.ts.map +1 -0
  40. package/build/commands/bootstrap/bootstrap.js +265 -0
  41. package/build/commands/bootstrap/bootstrap.js.map +1 -0
  42. package/build/commands/bootstrap/bootstrapOwnership.d.ts +13 -0
  43. package/build/commands/bootstrap/bootstrapOwnership.d.ts.map +1 -0
  44. package/build/commands/bootstrap/bootstrapOwnership.js +112 -0
  45. package/build/commands/bootstrap/bootstrapOwnership.js.map +1 -0
  46. package/build/commands/bootstrap/index.d.ts +3 -0
  47. package/build/commands/bootstrap/index.d.ts.map +1 -0
  48. package/build/commands/bootstrap/index.js +22 -0
  49. package/build/commands/bootstrap/index.js.map +1 -0
  50. package/build/commands/cliSetup/index.d.ts.map +1 -1
  51. package/build/commands/cliSetup/index.js +3 -4
  52. package/build/commands/cliSetup/index.js.map +1 -1
  53. package/build/commands/cliSetup/installPreparationSkill.d.ts +8 -0
  54. package/build/commands/cliSetup/installPreparationSkill.d.ts.map +1 -0
  55. package/build/commands/cliSetup/installPreparationSkill.js +201 -0
  56. package/build/commands/cliSetup/installPreparationSkill.js.map +1 -0
  57. package/build/commands/cliSetup/preparationSkill.generated.d.ts +2 -0
  58. package/build/commands/cliSetup/preparationSkill.generated.d.ts.map +1 -0
  59. package/build/commands/cliSetup/preparationSkill.generated.js +8 -0
  60. package/build/commands/cliSetup/preparationSkill.generated.js.map +1 -0
  61. package/build/commands/cliSetup/setupFiles.d.ts +5 -1
  62. package/build/commands/cliSetup/setupFiles.d.ts.map +1 -1
  63. package/build/commands/cliSetup/setupFiles.js +54 -37
  64. package/build/commands/cliSetup/setupFiles.js.map +1 -1
  65. package/build/commands/inspect/index.d.ts.map +1 -1
  66. package/build/commands/inspect/index.js +4 -4
  67. package/build/commands/inspect/index.js.map +1 -1
  68. package/build/commands/inspect/inspect.d.ts +2 -1
  69. package/build/commands/inspect/inspect.d.ts.map +1 -1
  70. package/build/commands/inspect/inspect.js +10 -5
  71. package/build/commands/inspect/inspect.js.map +1 -1
  72. package/build/commands/inspect/inspectUtils.js +3 -0
  73. package/build/commands/inspect/inspectUtils.js.map +1 -1
  74. package/build/commands/instructions/index.d.ts.map +1 -1
  75. package/build/commands/instructions/index.js +8 -3
  76. package/build/commands/instructions/index.js.map +1 -1
  77. package/build/commands/instructions/instructions.d.ts +3 -1
  78. package/build/commands/instructions/instructions.d.ts.map +1 -1
  79. package/build/commands/instructions/instructions.js +24 -0
  80. package/build/commands/instructions/instructions.js.map +1 -1
  81. package/build/commands/instructions/instructionsUtils.d.ts +2 -0
  82. package/build/commands/instructions/instructionsUtils.d.ts.map +1 -1
  83. package/build/commands/instructions/instructionsUtils.js +14 -4
  84. package/build/commands/instructions/instructionsUtils.js.map +1 -1
  85. package/build/commands/mcp/index.d.ts.map +1 -1
  86. package/build/commands/mcp/index.js +16 -21
  87. package/build/commands/mcp/index.js.map +1 -1
  88. package/build/commands/mcp/installSource.d.ts +3 -1
  89. package/build/commands/mcp/installSource.d.ts.map +1 -1
  90. package/build/commands/mcp/installSource.js +2 -2
  91. package/build/commands/mcp/installSource.js.map +1 -1
  92. package/build/commands/mcp/knownServerSetup.d.ts +4 -0
  93. package/build/commands/mcp/knownServerSetup.d.ts.map +1 -0
  94. package/build/commands/mcp/knownServerSetup.js +102 -0
  95. package/build/commands/mcp/knownServerSetup.js.map +1 -0
  96. package/build/commands/mcp/setup.d.ts +28 -0
  97. package/build/commands/mcp/setup.d.ts.map +1 -0
  98. package/build/commands/mcp/setup.js +56 -0
  99. package/build/commands/mcp/setup.js.map +1 -0
  100. package/build/commands/mcp/tools.d.ts.map +1 -1
  101. package/build/commands/mcp/tools.js +3 -3
  102. package/build/commands/mcp/tools.js.map +1 -1
  103. package/build/commands/preparation/index.d.ts +3 -0
  104. package/build/commands/preparation/index.d.ts.map +1 -0
  105. package/build/commands/preparation/index.js +55 -0
  106. package/build/commands/preparation/index.js.map +1 -0
  107. package/build/commands/preparation/preparation.d.ts +18 -0
  108. package/build/commands/preparation/preparation.d.ts.map +1 -0
  109. package/build/commands/preparation/preparation.js +102 -0
  110. package/build/commands/preparation/preparation.js.map +1 -0
  111. package/build/commands/preset/index.d.ts.map +1 -1
  112. package/build/commands/preset/index.js +4 -51
  113. package/build/commands/preset/index.js.map +1 -1
  114. package/build/commands/project/index.d.ts +3 -0
  115. package/build/commands/project/index.d.ts.map +1 -0
  116. package/build/commands/project/index.js +40 -0
  117. package/build/commands/project/index.js.map +1 -0
  118. package/build/commands/project/project.d.ts +34 -0
  119. package/build/commands/project/project.d.ts.map +1 -0
  120. package/build/commands/project/project.js +119 -0
  121. package/build/commands/project/project.js.map +1 -0
  122. package/build/commands/proxy/index.d.ts +2 -1
  123. package/build/commands/proxy/index.d.ts.map +1 -1
  124. package/build/commands/proxy/index.js +6 -46
  125. package/build/commands/proxy/index.js.map +1 -1
  126. package/build/commands/proxy/proxy.d.ts.map +1 -1
  127. package/build/commands/proxy/proxy.js +7 -1
  128. package/build/commands/proxy/proxy.js.map +1 -1
  129. package/build/commands/registry/index.d.ts.map +1 -1
  130. package/build/commands/registry/index.js +16 -20
  131. package/build/commands/registry/index.js.map +1 -1
  132. package/build/commands/run/index.d.ts.map +1 -1
  133. package/build/commands/run/index.js +9 -3
  134. package/build/commands/run/index.js.map +1 -1
  135. package/build/commands/run/run.d.ts +4 -1
  136. package/build/commands/run/run.d.ts.map +1 -1
  137. package/build/commands/run/run.js +80 -14
  138. package/build/commands/run/run.js.map +1 -1
  139. package/build/commands/serve/cooperativeRuntime.d.ts.map +1 -1
  140. package/build/commands/serve/cooperativeRuntime.js +2 -1
  141. package/build/commands/serve/cooperativeRuntime.js.map +1 -1
  142. package/build/commands/serve/index.d.ts.map +1 -1
  143. package/build/commands/serve/index.js +57 -39
  144. package/build/commands/serve/index.js.map +1 -1
  145. package/build/commands/shared/agentSession.d.ts +5 -0
  146. package/build/commands/shared/agentSession.d.ts.map +1 -0
  147. package/build/commands/shared/agentSession.js +75 -0
  148. package/build/commands/shared/agentSession.js.map +1 -0
  149. package/build/commands/shared/apiClient.d.ts +2 -0
  150. package/build/commands/shared/apiClient.d.ts.map +1 -1
  151. package/build/commands/shared/apiClient.js +10 -6
  152. package/build/commands/shared/apiClient.js.map +1 -1
  153. package/build/commands/shared/cliContext.d.ts +2 -1
  154. package/build/commands/shared/cliContext.d.ts.map +1 -1
  155. package/build/commands/shared/cliContext.js +2 -1
  156. package/build/commands/shared/cliContext.js.map +1 -1
  157. package/build/commands/shared/clientSurfaceAttachment.d.ts +7 -1
  158. package/build/commands/shared/clientSurfaceAttachment.d.ts.map +1 -1
  159. package/build/commands/shared/clientSurfaceAttachment.js +221 -140
  160. package/build/commands/shared/clientSurfaceAttachment.js.map +1 -1
  161. package/build/commands/shared/projectOwnerStorage.d.ts +8 -0
  162. package/build/commands/shared/projectOwnerStorage.d.ts.map +1 -0
  163. package/build/commands/shared/projectOwnerStorage.js +63 -0
  164. package/build/commands/shared/projectOwnerStorage.js.map +1 -0
  165. package/build/commands/shared/projectOwnerStore.d.ts +78 -0
  166. package/build/commands/shared/projectOwnerStore.d.ts.map +1 -0
  167. package/build/commands/shared/projectOwnerStore.js +482 -0
  168. package/build/commands/shared/projectOwnerStore.js.map +1 -0
  169. package/build/commands/shared/projectSelectionOptions.d.ts +24 -0
  170. package/build/commands/shared/projectSelectionOptions.d.ts.map +1 -0
  171. package/build/commands/shared/projectSelectionOptions.js +20 -0
  172. package/build/commands/shared/projectSelectionOptions.js.map +1 -0
  173. package/build/commands/shared/serveTargetResolver.d.ts +7 -1
  174. package/build/commands/shared/serveTargetResolver.d.ts.map +1 -1
  175. package/build/commands/shared/serveTargetResolver.js +99 -4
  176. package/build/commands/shared/serveTargetResolver.js.map +1 -1
  177. package/build/commands/target/index.d.ts.map +1 -1
  178. package/build/commands/target/index.js +6 -13
  179. package/build/commands/target/index.js.map +1 -1
  180. package/build/commands/wait/index.d.ts.map +1 -1
  181. package/build/commands/wait/index.js +3 -3
  182. package/build/commands/wait/index.js.map +1 -1
  183. package/build/commands/wait/wait.d.ts +2 -1
  184. package/build/commands/wait/wait.d.ts.map +1 -1
  185. package/build/commands/wait/wait.js.map +1 -1
  186. package/build/config/configLoader.d.ts.map +1 -1
  187. package/build/config/configLoader.js +5 -1
  188. package/build/config/configLoader.js.map +1 -1
  189. package/build/config/configManager.d.ts.map +1 -1
  190. package/build/config/configManager.js +5 -1
  191. package/build/config/configManager.js.map +1 -1
  192. package/build/config/projectConfigLoader.d.ts +4 -0
  193. package/build/config/projectConfigLoader.d.ts.map +1 -1
  194. package/build/config/projectConfigLoader.js +129 -28
  195. package/build/config/projectConfigLoader.js.map +1 -1
  196. package/build/config/projectConfigTypes.d.ts +7 -0
  197. package/build/config/projectConfigTypes.d.ts.map +1 -1
  198. package/build/config/projectConfigTypes.js +1 -0
  199. package/build/config/projectConfigTypes.js.map +1 -1
  200. package/build/constants/cliTimeouts.d.ts +4 -0
  201. package/build/constants/cliTimeouts.d.ts.map +1 -0
  202. package/build/constants/cliTimeouts.js +4 -0
  203. package/build/constants/cliTimeouts.js.map +1 -0
  204. package/build/constants/mcp.d.ts +1 -1
  205. package/build/constants/mcp.d.ts.map +1 -1
  206. package/build/constants/mcp.js +1 -1
  207. package/build/constants/mcp.js.map +1 -1
  208. package/build/core/capabilities/capabilityCatalog.d.ts +7 -0
  209. package/build/core/capabilities/capabilityCatalog.d.ts.map +1 -1
  210. package/build/core/capabilities/capabilityCatalog.js +58 -2
  211. package/build/core/capabilities/capabilityCatalog.js.map +1 -1
  212. package/build/core/capabilities/capabilityPagination.d.ts +12 -4
  213. package/build/core/capabilities/capabilityPagination.d.ts.map +1 -1
  214. package/build/core/capabilities/capabilityPagination.js +15 -2
  215. package/build/core/capabilities/capabilityPagination.js.map +1 -1
  216. package/build/core/capabilities/capabilityVisibility.d.ts +3 -0
  217. package/build/core/capabilities/capabilityVisibility.d.ts.map +1 -1
  218. package/build/core/capabilities/capabilityVisibility.js.map +1 -1
  219. package/build/core/capabilities/lazyLoadingOrchestrator.d.ts +2 -1
  220. package/build/core/capabilities/lazyLoadingOrchestrator.d.ts.map +1 -1
  221. package/build/core/capabilities/lazyLoadingOrchestrator.js +2 -2
  222. package/build/core/capabilities/lazyLoadingOrchestrator.js.map +1 -1
  223. package/build/core/capabilities/metaToolProvider.d.ts +2 -2
  224. package/build/core/capabilities/metaToolProvider.d.ts.map +1 -1
  225. package/build/core/capabilities/metaToolProvider.js +2 -2
  226. package/build/core/capabilities/metaToolProvider.js.map +1 -1
  227. package/build/core/capabilities/runtimeCapabilityCatalog.d.ts +1 -0
  228. package/build/core/capabilities/runtimeCapabilityCatalog.d.ts.map +1 -1
  229. package/build/core/capabilities/runtimeCapabilityCatalog.js +23 -9
  230. package/build/core/capabilities/runtimeCapabilityCatalog.js.map +1 -1
  231. package/build/core/context/projectOwner.d.ts +16 -0
  232. package/build/core/context/projectOwner.d.ts.map +1 -0
  233. package/build/core/context/projectOwner.js +33 -0
  234. package/build/core/context/projectOwner.js.map +1 -0
  235. package/build/core/context/projectPreparationAuthority.d.ts +37 -0
  236. package/build/core/context/projectPreparationAuthority.d.ts.map +1 -0
  237. package/build/core/context/projectPreparationAuthority.js +113 -0
  238. package/build/core/context/projectPreparationAuthority.js.map +1 -0
  239. package/build/core/instructions/inspectionGuidance.d.ts +2 -0
  240. package/build/core/instructions/inspectionGuidance.d.ts.map +1 -0
  241. package/build/core/instructions/inspectionGuidance.js +2 -0
  242. package/build/core/instructions/inspectionGuidance.js.map +1 -0
  243. package/build/core/instructions/instructionAggregator.d.ts +1 -0
  244. package/build/core/instructions/instructionAggregator.d.ts.map +1 -1
  245. package/build/core/instructions/instructionAggregator.js +2 -2
  246. package/build/core/instructions/instructionAggregator.js.map +1 -1
  247. package/build/core/instructions/instructionsDistribution.d.ts +5 -0
  248. package/build/core/instructions/instructionsDistribution.d.ts.map +1 -1
  249. package/build/core/instructions/instructionsDistribution.js +72 -15
  250. package/build/core/instructions/instructionsDistribution.js.map +1 -1
  251. package/build/core/instructions/preparationGuidance.d.ts +3 -0
  252. package/build/core/instructions/preparationGuidance.d.ts.map +1 -0
  253. package/build/core/instructions/preparationGuidance.js +14 -0
  254. package/build/core/instructions/preparationGuidance.js.map +1 -0
  255. package/build/core/instructions/sessionGuidance.d.ts +3 -0
  256. package/build/core/instructions/sessionGuidance.d.ts.map +1 -0
  257. package/build/core/instructions/sessionGuidance.js +25 -0
  258. package/build/core/instructions/sessionGuidance.js.map +1 -0
  259. package/build/core/instructions/templateTypes.d.ts +3 -1
  260. package/build/core/instructions/templateTypes.d.ts.map +1 -1
  261. package/build/core/instructions/templateTypes.js +15 -5
  262. package/build/core/instructions/templateTypes.js.map +1 -1
  263. package/build/core/protocol/requestHandlerUtils.d.ts.map +1 -1
  264. package/build/core/protocol/requestHandlerUtils.js +23 -4
  265. package/build/core/protocol/requestHandlerUtils.js.map +1 -1
  266. package/build/core/server/connectionResolver.d.ts +5 -0
  267. package/build/core/server/connectionResolver.d.ts.map +1 -1
  268. package/build/core/server/connectionResolver.js +11 -0
  269. package/build/core/server/connectionResolver.js.map +1 -1
  270. package/build/core/server/runtimeLaunchIpc.d.ts +167 -2
  271. package/build/core/server/runtimeLaunchIpc.d.ts.map +1 -1
  272. package/build/core/server/runtimeReplacementConfig.d.ts +167 -2
  273. package/build/core/server/runtimeReplacementConfig.d.ts.map +1 -1
  274. package/build/core/tools/handlers/serverManagementHandler.d.ts +413 -7
  275. package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
  276. package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +59 -1
  277. package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts.map +1 -1
  278. package/build/core/types/server.d.ts +7 -1
  279. package/build/core/types/server.d.ts.map +1 -1
  280. package/build/core/types/transport.d.ts +249 -3
  281. package/build/core/types/transport.d.ts.map +1 -1
  282. package/build/core/types/transport.js +27 -0
  283. package/build/core/types/transport.js.map +1 -1
  284. package/build/domains/admin/adminInstructionPreviewRuntime.d.ts.map +1 -1
  285. package/build/domains/admin/adminInstructionPreviewRuntime.js +4 -1
  286. package/build/domains/admin/adminInstructionPreviewRuntime.js.map +1 -1
  287. package/build/domains/backend-preparation/adapterRegistry.d.ts +8 -0
  288. package/build/domains/backend-preparation/adapterRegistry.d.ts.map +1 -0
  289. package/build/domains/backend-preparation/adapterRegistry.js +15 -0
  290. package/build/domains/backend-preparation/adapterRegistry.js.map +1 -0
  291. package/build/domains/backend-preparation/builtInIntegrationDefinitions.d.ts +4 -0
  292. package/build/domains/backend-preparation/builtInIntegrationDefinitions.d.ts.map +1 -0
  293. package/build/domains/backend-preparation/builtInIntegrationDefinitions.js +3 -0
  294. package/build/domains/backend-preparation/builtInIntegrationDefinitions.js.map +1 -0
  295. package/build/domains/backend-preparation/configuredCommandAdapter.d.ts +88 -0
  296. package/build/domains/backend-preparation/configuredCommandAdapter.d.ts.map +1 -0
  297. package/build/domains/backend-preparation/configuredCommandAdapter.js +196 -0
  298. package/build/domains/backend-preparation/configuredCommandAdapter.js.map +1 -0
  299. package/build/domains/backend-preparation/configuredCommandProcess.d.ts +27 -0
  300. package/build/domains/backend-preparation/configuredCommandProcess.d.ts.map +1 -0
  301. package/build/domains/backend-preparation/configuredCommandProcess.js +183 -0
  302. package/build/domains/backend-preparation/configuredCommandProcess.js.map +1 -0
  303. package/build/domains/backend-preparation/contracts.d.ts +131 -0
  304. package/build/domains/backend-preparation/contracts.d.ts.map +1 -0
  305. package/build/domains/backend-preparation/contracts.js +2 -0
  306. package/build/domains/backend-preparation/contracts.js.map +1 -0
  307. package/build/domains/backend-preparation/integrationDefinitions.d.ts +171 -0
  308. package/build/domains/backend-preparation/integrationDefinitions.d.ts.map +1 -0
  309. package/build/domains/backend-preparation/integrationDefinitions.js +246 -0
  310. package/build/domains/backend-preparation/integrationDefinitions.js.map +1 -0
  311. package/build/domains/backend-preparation/policy.d.ts +50 -0
  312. package/build/domains/backend-preparation/policy.d.ts.map +1 -0
  313. package/build/domains/backend-preparation/policy.js +58 -0
  314. package/build/domains/backend-preparation/policy.js.map +1 -0
  315. package/build/domains/backend-preparation/scheduler.d.ts +18 -0
  316. package/build/domains/backend-preparation/scheduler.d.ts.map +1 -0
  317. package/build/domains/backend-preparation/scheduler.js +62 -0
  318. package/build/domains/backend-preparation/scheduler.js.map +1 -0
  319. package/build/domains/backend-preparation/service.d.ts +67 -0
  320. package/build/domains/backend-preparation/service.d.ts.map +1 -0
  321. package/build/domains/backend-preparation/service.js +709 -0
  322. package/build/domains/backend-preparation/service.js.map +1 -0
  323. package/build/domains/config-change/configChange.js +5 -5
  324. package/build/domains/config-change/configChange.js.map +1 -1
  325. package/build/domains/installation/knownServerCatalog.d.ts +14 -0
  326. package/build/domains/installation/knownServerCatalog.d.ts.map +1 -0
  327. package/build/domains/installation/knownServerCatalog.js +56 -0
  328. package/build/domains/installation/knownServerCatalog.js.map +1 -0
  329. package/build/domains/installation/knownServerSetup.d.ts +21 -0
  330. package/build/domains/installation/knownServerSetup.d.ts.map +1 -0
  331. package/build/domains/installation/knownServerSetup.js +330 -0
  332. package/build/domains/installation/knownServerSetup.js.map +1 -0
  333. package/build/domains/installation/knownServerSetupTypes.d.ts +34 -0
  334. package/build/domains/installation/knownServerSetupTypes.d.ts.map +1 -0
  335. package/build/domains/installation/knownServerSetupTypes.js +2 -0
  336. package/build/domains/installation/knownServerSetupTypes.js.map +1 -0
  337. package/build/domains/project-selection/projectBindingScope.d.ts +7 -0
  338. package/build/domains/project-selection/projectBindingScope.d.ts.map +1 -0
  339. package/build/domains/project-selection/projectBindingScope.js +9 -0
  340. package/build/domains/project-selection/projectBindingScope.js.map +1 -0
  341. package/build/domains/project-selection/projectPolicy.d.ts +11 -0
  342. package/build/domains/project-selection/projectPolicy.d.ts.map +1 -0
  343. package/build/domains/project-selection/projectPolicy.js +104 -0
  344. package/build/domains/project-selection/projectPolicy.js.map +1 -0
  345. package/build/domains/project-selection/projectSelection.d.ts +30 -0
  346. package/build/domains/project-selection/projectSelection.d.ts.map +1 -0
  347. package/build/domains/project-selection/projectSelection.js +124 -0
  348. package/build/domains/project-selection/projectSelection.js.map +1 -0
  349. package/build/globalOptions.d.ts +9 -0
  350. package/build/globalOptions.d.ts.map +1 -1
  351. package/build/globalOptions.js +13 -11
  352. package/build/globalOptions.js.map +1 -1
  353. package/build/observability/events/registry.d.ts +7 -1
  354. package/build/observability/events/registry.d.ts.map +1 -1
  355. package/build/observability/events/registry.js +7 -1
  356. package/build/observability/events/registry.js.map +1 -1
  357. package/build/sdk/legacy/client/runtime/backendDispatchLifetime.d.ts.map +1 -1
  358. package/build/sdk/legacy/client/runtime/backendDispatchLifetime.js +8 -2
  359. package/build/sdk/legacy/client/runtime/backendDispatchLifetime.js.map +1 -1
  360. package/build/sdk/legacy/client/runtime/legacyTransport.d.ts +2 -0
  361. package/build/sdk/legacy/client/runtime/legacyTransport.d.ts.map +1 -1
  362. package/build/sdk/legacy/client/runtime/serveClient.d.ts +6 -1
  363. package/build/sdk/legacy/client/runtime/serveClient.d.ts.map +1 -1
  364. package/build/sdk/legacy/client/runtime/serveClient.js +16 -5
  365. package/build/sdk/legacy/client/runtime/serveClient.js.map +1 -1
  366. package/build/sdk/legacy/commands/serve.d.ts.map +1 -1
  367. package/build/sdk/legacy/commands/serve.js +11 -5
  368. package/build/sdk/legacy/commands/serve.js.map +1 -1
  369. package/build/sdk/legacy/server/protocol/projectAdmission.d.ts +4 -0
  370. package/build/sdk/legacy/server/protocol/projectAdmission.d.ts.map +1 -0
  371. package/build/sdk/legacy/server/protocol/projectAdmission.js +24 -0
  372. package/build/sdk/legacy/server/protocol/projectAdmission.js.map +1 -0
  373. package/build/sdk/legacy/server/protocol/promptRequestHandlers.d.ts.map +1 -1
  374. package/build/sdk/legacy/server/protocol/promptRequestHandlers.js +6 -3
  375. package/build/sdk/legacy/server/protocol/promptRequestHandlers.js.map +1 -1
  376. package/build/sdk/legacy/server/protocol/resourceRequestHandlers.d.ts.map +1 -1
  377. package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js +6 -4
  378. package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js.map +1 -1
  379. package/build/sdk/legacy/server/protocol/resourceSubscriptions.d.ts +1 -1
  380. package/build/sdk/legacy/server/protocol/resourceSubscriptions.d.ts.map +1 -1
  381. package/build/sdk/legacy/server/protocol/resourceSubscriptions.js +193 -41
  382. package/build/sdk/legacy/server/protocol/resourceSubscriptions.js.map +1 -1
  383. package/build/sdk/legacy/server/protocol/toolRequestHandlers.d.ts.map +1 -1
  384. package/build/sdk/legacy/server/protocol/toolRequestHandlers.js +93 -17
  385. package/build/sdk/legacy/server/protocol/toolRequestHandlers.js.map +1 -1
  386. package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts +12 -0
  387. package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts.map +1 -1
  388. package/build/sdk/legacy/server/runtime/clientInstancePool.js +117 -4
  389. package/build/sdk/legacy/server/runtime/clientInstancePool.js.map +1 -1
  390. package/build/sdk/legacy/server/runtime/connectionManager.d.ts.map +1 -1
  391. package/build/sdk/legacy/server/runtime/connectionManager.js +2 -0
  392. package/build/sdk/legacy/server/runtime/connectionManager.js.map +1 -1
  393. package/build/sdk/legacy/server/runtime/requestContextPreparation.d.ts +19 -1
  394. package/build/sdk/legacy/server/runtime/requestContextPreparation.d.ts.map +1 -1
  395. package/build/sdk/legacy/server/runtime/requestContextPreparation.js +40 -7
  396. package/build/sdk/legacy/server/runtime/requestContextPreparation.js.map +1 -1
  397. package/build/sdk/legacy/server/runtime/serverManager.d.ts +6 -2
  398. package/build/sdk/legacy/server/runtime/serverManager.d.ts.map +1 -1
  399. package/build/sdk/legacy/server/runtime/serverManager.js +85 -17
  400. package/build/sdk/legacy/server/runtime/serverManager.js.map +1 -1
  401. package/build/sdk/legacy/server/runtime/templateServerManager.d.ts +26 -4
  402. package/build/sdk/legacy/server/runtime/templateServerManager.d.ts.map +1 -1
  403. package/build/sdk/legacy/server/runtime/templateServerManager.js +260 -14
  404. package/build/sdk/legacy/server/runtime/templateServerManager.js.map +1 -1
  405. package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js +1 -1
  406. package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js.map +1 -1
  407. package/build/sdk/legacy/transport/http/streamableSessionLifecycle.d.ts.map +1 -1
  408. package/build/sdk/legacy/transport/http/streamableSessionLifecycle.js +14 -3
  409. package/build/sdk/legacy/transport/http/streamableSessionLifecycle.js.map +1 -1
  410. package/build/sdk/legacy/transport/stdioProxyTransport.d.ts +1 -0
  411. package/build/sdk/legacy/transport/stdioProxyTransport.d.ts.map +1 -1
  412. package/build/sdk/legacy/transport/stdioProxyTransport.js +2 -0
  413. package/build/sdk/legacy/transport/stdioProxyTransport.js.map +1 -1
  414. package/build/template/handlebarsTemplateRenderer.d.ts.map +1 -1
  415. package/build/template/handlebarsTemplateRenderer.js +3 -0
  416. package/build/template/handlebarsTemplateRenderer.js.map +1 -1
  417. package/build/transport/http/middlewares/projectAdmission.d.ts +5 -0
  418. package/build/transport/http/middlewares/projectAdmission.d.ts.map +1 -0
  419. package/build/transport/http/middlewares/projectAdmission.js +33 -0
  420. package/build/transport/http/middlewares/projectAdmission.js.map +1 -0
  421. package/build/transport/http/routes/apiRoutes.d.ts.map +1 -1
  422. package/build/transport/http/routes/apiRoutes.js +4 -0
  423. package/build/transport/http/routes/apiRoutes.js.map +1 -1
  424. package/build/transport/http/routes/inspectHelpers.d.ts +1 -0
  425. package/build/transport/http/routes/inspectHelpers.d.ts.map +1 -1
  426. package/build/transport/http/routes/inspectHelpers.js +2 -0
  427. package/build/transport/http/routes/inspectHelpers.js.map +1 -1
  428. package/build/transport/http/routes/inspectRequestContext.d.ts +5 -2
  429. package/build/transport/http/routes/inspectRequestContext.d.ts.map +1 -1
  430. package/build/transport/http/routes/inspectRequestContext.js +41 -19
  431. package/build/transport/http/routes/inspectRequestContext.js.map +1 -1
  432. package/build/transport/http/routes/inspectRoutes.d.ts +11 -2
  433. package/build/transport/http/routes/inspectRoutes.d.ts.map +1 -1
  434. package/build/transport/http/routes/inspectRoutes.js +94 -24
  435. package/build/transport/http/routes/inspectRoutes.js.map +1 -1
  436. package/build/transport/http/routes/instructionsRoutes.d.ts.map +1 -1
  437. package/build/transport/http/routes/instructionsRoutes.js +20 -8
  438. package/build/transport/http/routes/instructionsRoutes.js.map +1 -1
  439. package/build/transport/http/routes/modernHttpRoutes.d.ts.map +1 -1
  440. package/build/transport/http/routes/modernHttpRoutes.js +96 -13
  441. package/build/transport/http/routes/modernHttpRoutes.js.map +1 -1
  442. package/build/transport/http/routes/modernInteractionBinding.d.ts.map +1 -1
  443. package/build/transport/http/routes/modernInteractionBinding.js +3 -9
  444. package/build/transport/http/routes/modernInteractionBinding.js.map +1 -1
  445. package/build/transport/http/routes/modernSubscriptions.d.ts.map +1 -1
  446. package/build/transport/http/routes/modernSubscriptions.js +7 -5
  447. package/build/transport/http/routes/modernSubscriptions.js.map +1 -1
  448. package/build/transport/http/routes/modernTemplateContext.d.ts +2 -1
  449. package/build/transport/http/routes/modernTemplateContext.d.ts.map +1 -1
  450. package/build/transport/http/routes/modernTemplateContext.js +14 -3
  451. package/build/transport/http/routes/modernTemplateContext.js.map +1 -1
  452. package/build/transport/http/routes/modernToolHeaderRegistry.d.ts.map +1 -1
  453. package/build/transport/http/routes/modernToolHeaderRegistry.js +2 -2
  454. package/build/transport/http/routes/modernToolHeaderRegistry.js.map +1 -1
  455. package/build/transport/http/routes/preparationRoutes.d.ts +26 -0
  456. package/build/transport/http/routes/preparationRoutes.d.ts.map +1 -0
  457. package/build/transport/http/routes/preparationRoutes.js +132 -0
  458. package/build/transport/http/routes/preparationRoutes.js.map +1 -0
  459. package/build/transport/http/routes/projectRoutes.d.ts +18 -0
  460. package/build/transport/http/routes/projectRoutes.d.ts.map +1 -0
  461. package/build/transport/http/routes/projectRoutes.js +159 -0
  462. package/build/transport/http/routes/projectRoutes.js.map +1 -0
  463. package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
  464. package/build/transport/http/routes/streamableHttpRoutes.js +24 -4
  465. package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
  466. package/build/transport/http/routes/toolRoutes.d.ts.map +1 -1
  467. package/build/transport/http/routes/toolRoutes.js +163 -20
  468. package/build/transport/http/routes/toolRoutes.js.map +1 -1
  469. package/build/transport/http/utils/contextExtractor.d.ts +2 -0
  470. package/build/transport/http/utils/contextExtractor.d.ts.map +1 -1
  471. package/build/transport/http/utils/contextExtractor.js +11 -0
  472. package/build/transport/http/utils/contextExtractor.js.map +1 -1
  473. package/build/transport/http/utils/templateContextAuthority.d.ts +2 -0
  474. package/build/transport/http/utils/templateContextAuthority.d.ts.map +1 -1
  475. package/build/transport/http/utils/templateContextAuthority.js +23 -2
  476. package/build/transport/http/utils/templateContextAuthority.js.map +1 -1
  477. package/build/types/context.d.ts +13 -0
  478. package/build/types/context.d.ts.map +1 -1
  479. package/build/types/context.js.map +1 -1
  480. package/build/utils/cli/help.d.ts +7 -0
  481. package/build/utils/cli/help.d.ts.map +1 -0
  482. package/build/utils/cli/help.js +57 -0
  483. package/build/utils/cli/help.js.map +1 -0
  484. package/package.json +20 -22
  485. package/build/admin/assets/admin-icons-CYGTDZA5.js +0 -1
  486. package/build/admin/assets/admin-vendor-62eL-qdH.js +0 -1
  487. package/build/admin/assets/admin-vendor-BbMrl7MK.js +0 -3
  488. package/build/admin/assets/admin-vendor-DpjVwd81.js +0 -62
@@ -0,0 +1,423 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { createHash } from 'node:crypto';
3
+ import path from 'node:path';
4
+ import { getVerifiedProjectOwner } from './projectLifecycle.js';
5
+ import { ConfigManager } from '../config/configManager.js';
6
+ import { getConfiguredServerTargets } from '../config/configuredServerTargets.js';
7
+ import { MCP_URI_SEPARATOR } from '../constants.js';
8
+ import { readConfiguredToolSnapshot } from '../core/capabilities/configuredToolSnapshot.js';
9
+ import { ToolInvokeInputSchema } from '../core/capabilities/schemas/metaToolSchemas.js';
10
+ import { getProjectPreparationAuthorityIdentity, validateProjectPreparationAuthority, } from '../core/context/projectPreparationAuthority.js';
11
+ import { TemplateFilteringService } from '../core/filtering/templateFilteringService.js';
12
+ import { RuntimeIdentityService } from '../core/runtime/runtimeIdentityService.js';
13
+ import { AgentConfigManager } from '../core/server/agentConfig.js';
14
+ import { createConnectionResolver } from '../core/server/connectionResolver.js';
15
+ import { getDisabledSourceToolError } from '../core/server/disabledTools.js';
16
+ import { admitToolSchemas, prepareToolValidation } from '../core/validation/toolSchemaBoundary.js';
17
+ import { PreparationConfigurationError, validatePreparationConfig, } from '../domains/backend-preparation/integrationDefinitions.js';
18
+ import { PresetManager } from '../domains/preset/manager/presetManager.js';
19
+ import { projectToolArguments } from '../domains/project-selection/projectPolicy.js';
20
+ import { isProjectBackendVisible, resolveProjectPolicies } from '../domains/project-selection/projectPolicy.js';
21
+ import { requireProjectTarget } from '../domains/project-selection/projectSelection.js';
22
+ import { getBackendPreparationCoordinator, PreparationAuthorizationChangedError, refreshPreparedBackendCapabilities, } from './backendPreparationCoordinator.js';
23
+ const requestScopes = new AsyncLocalStorage();
24
+ class PreparationCallerStopped extends Error {
25
+ reason;
26
+ constructor(reason) {
27
+ super(reason);
28
+ this.reason = reason;
29
+ }
30
+ }
31
+ async function withinRequestBudget(scope, signal, action) {
32
+ const remaining = Math.max(0, scope.expiresAt - Date.now());
33
+ if (signal?.aborted || remaining === 0)
34
+ throw new PreparationCallerStopped(signal?.aborted ? 'caller_disconnected' : 'inspection_timeout');
35
+ const controller = new AbortController();
36
+ let timer;
37
+ let rejectStopped = () => undefined;
38
+ const stopped = new Promise((_, reject) => {
39
+ rejectStopped = reject;
40
+ });
41
+ const stop = () => {
42
+ controller.abort();
43
+ rejectStopped(new PreparationCallerStopped('caller_disconnected'));
44
+ };
45
+ signal?.addEventListener('abort', stop, { once: true });
46
+ timer = setTimeout(() => {
47
+ controller.abort();
48
+ rejectStopped(new PreparationCallerStopped('inspection_timeout'));
49
+ }, remaining);
50
+ try {
51
+ return await Promise.race([Promise.resolve().then(() => action(controller.signal)), stopped]);
52
+ }
53
+ finally {
54
+ clearTimeout(timer);
55
+ signal?.removeEventListener('abort', stop);
56
+ }
57
+ }
58
+ /** Share only the request budget and caller identity. Every admission rechecks native readiness. */
59
+ export function withPreparationRequestScope(input, operation) {
60
+ if (requestScopes.getStore())
61
+ return operation();
62
+ const waitMs = ConfigManager.getInstance().getAppConfig?.().preparation?.requestWaitMs ?? 5000;
63
+ return requestScopes.run({ ...input, expiresAt: Date.now() + waitMs }, operation);
64
+ }
65
+ /** Missing bearer credentials grant preparation only while runtime authentication is explicitly disabled. */
66
+ export function revalidatePreparationAuthentication(auth, revalidate) {
67
+ if (auth)
68
+ return Promise.resolve(revalidate());
69
+ return Promise.resolve(!AgentConfigManager.getInstance().isAuthEnabled());
70
+ }
71
+ /** Controls and tool admission expose handles to the same exact authorization owner. */
72
+ export function createPreparationOwnerIdentity(runtimeScopeId, authentication, filter, projectOwnerId) {
73
+ filter = normalizePreparationFilterConfig(filter);
74
+ const selection = {
75
+ tags: filter.tags,
76
+ tagExpression: filter.tagExpression,
77
+ tagFilterMode: filter.tagFilterMode,
78
+ tagQuery: filter.tagQuery,
79
+ presetName: filter.presetName,
80
+ projectFilterMode: filter.projectFilterMode ?? filter.tagFilterMode,
81
+ };
82
+ return createHash('sha256')
83
+ .update(JSON.stringify([
84
+ runtimeScopeId,
85
+ authentication ?? 'verified-local-owner',
86
+ selection,
87
+ ...(projectOwnerId ? [projectOwnerId] : []),
88
+ ]))
89
+ .digest('hex');
90
+ }
91
+ function normalizePreparationFilterConfig(filter) {
92
+ if (filter.tagFilterMode === 'none' && filter.tags?.length) {
93
+ return { ...filter, tagFilterMode: 'simple-or', projectFilterMode: filter.projectFilterMode ?? 'none' };
94
+ }
95
+ return filter;
96
+ }
97
+ function preparationToolResult(preparation, server, tool) {
98
+ const pending = { preparation, operationExecuted: false, operationQueued: false };
99
+ const payload = server && tool ? { result: pending, server, tool } : pending;
100
+ return { content: [{ type: 'text', text: JSON.stringify(payload) }], structuredContent: payload };
101
+ }
102
+ function nativeTarget(request, backendNames) {
103
+ if (request.name === 'tool_invoke') {
104
+ const parsed = ToolInvokeInputSchema.safeParse(request.arguments);
105
+ if (!parsed.success)
106
+ return;
107
+ return { backendName: parsed.data.server, toolName: parsed.data.toolName, arguments: parsed.data.args, meta: true };
108
+ }
109
+ const backendName = backendNames
110
+ .sort((a, b) => b.length - a.length)
111
+ .find((name) => request.name.startsWith(`${name}${MCP_URI_SEPARATOR}`));
112
+ if (!backendName)
113
+ return;
114
+ return {
115
+ backendName,
116
+ toolName: request.name.slice(backendName.length + MCP_URI_SEPARATOR.length),
117
+ arguments: request.arguments,
118
+ meta: false,
119
+ };
120
+ }
121
+ function isPreparationAffected(config, toolName) {
122
+ if (!config)
123
+ return false;
124
+ let affectedTools = config.affectedTools;
125
+ if (config.definition) {
126
+ try {
127
+ affectedTools = validatePreparationConfig(config).affectedTools;
128
+ }
129
+ catch {
130
+ // Route an unreadable recipe through admission so the backend fails closed.
131
+ return true;
132
+ }
133
+ }
134
+ if (!affectedTools)
135
+ return true;
136
+ if (affectedTools === 'all')
137
+ return true;
138
+ return affectedTools.includes(toolName);
139
+ }
140
+ export async function admitBackendPreparationTool(input, ports = {}) {
141
+ const configured = getConfiguredServerTargets();
142
+ const candidate = nativeTarget(input.request, Object.keys(configured));
143
+ if (!candidate || !isPreparationAffected(configured[candidate.backendName]?.preparation, candidate.toolName))
144
+ return { kind: 'unaffected' };
145
+ if (!requestScopes.getStore())
146
+ return withPreparationRequestScope({}, () => admitBackendPreparationTool(input, ports));
147
+ try {
148
+ return await admitScopedPreparationTool(input, ports);
149
+ }
150
+ catch (error) {
151
+ if (error instanceof PreparationConfigurationError)
152
+ return {
153
+ kind: 'blocked',
154
+ result: preparationToolResult({
155
+ state: 'forbidden',
156
+ instructions: 'Preparation configuration is unavailable. Repair the recipe before invoking again.',
157
+ }),
158
+ };
159
+ if (error instanceof PreparationAuthorizationChangedError)
160
+ return { kind: 'blocked', result: preparationToolResult({ state: 'forbidden', instructions: error.message }) };
161
+ if (!(error instanceof PreparationCallerStopped))
162
+ throw error;
163
+ return {
164
+ kind: 'blocked',
165
+ result: preparationToolResult({
166
+ state: 'unknown',
167
+ reason: error.reason,
168
+ instructions: 'Invoke again with a live caller and available inspection budget.',
169
+ }),
170
+ };
171
+ }
172
+ }
173
+ async function admitScopedPreparationTool(input, ports) {
174
+ const declared = ConfigManager.getInstance().loadDeclaredServerConfigs();
175
+ const configs = { ...declared.staticServers, ...declared.templateServers };
176
+ const target = nativeTarget(input.request, Object.keys(configs));
177
+ if (!target)
178
+ return { kind: 'unaffected' };
179
+ const definition = configs[target.backendName];
180
+ if (!isPreparationAffected(definition?.preparation, target.toolName))
181
+ return { kind: 'unaffected' };
182
+ const blocked = (preparation) => ({
183
+ kind: 'blocked',
184
+ result: preparationToolResult(preparation, target.meta ? target.backendName : undefined, target.meta ? target.toolName : undefined),
185
+ });
186
+ const scope = requestScopes.getStore();
187
+ const filterConfig = normalizePreparationFilterConfig(scope.filterConfig ?? input.filterConfig);
188
+ const presetRevision = filterConfig.presetName
189
+ ? JSON.stringify(PresetManager.getInstance().getPreset(filterConfig.presetName))
190
+ : undefined;
191
+ const authentication = scope.authentication ?? input.authentication;
192
+ const revalidateAuth = scope?.revalidateAuth ?? input.revalidateAuth;
193
+ const ownerSessionId = scope?.ownerSessionId ?? input.ownerSessionId;
194
+ const serverManager = typeof input.serverManager === 'function' ? input.serverManager() : input.serverManager;
195
+ const manager = serverManager.getTemplateServerManager();
196
+ const context = input.bindingId ? manager.getBindingContexts().get(input.bindingId) : undefined;
197
+ const authority = input.bindingId ? manager.getBindingAuthority(input.bindingId) : undefined;
198
+ if (input.bindingId && !context)
199
+ return blocked({ state: 'forbidden', instructions: 'The selected request binding is no longer available.' });
200
+ // Existing remote, legacy and STDIO query grants keep their normal dispatch path. They gain no local preparation reads or writes.
201
+ if (!authority)
202
+ return { kind: 'unaffected' };
203
+ let authorityIdentity;
204
+ try {
205
+ authorityIdentity = getProjectPreparationAuthorityIdentity(authority, context);
206
+ }
207
+ catch {
208
+ return blocked({ state: 'forbidden', instructions: 'The selected binding authority is invalid.' });
209
+ }
210
+ const preparationRevision = definition.preparation?.definition
211
+ ? validatePreparationConfig(definition.preparation).effectiveRevision
212
+ : undefined;
213
+ const synchronousAuthorization = () => {
214
+ if (!input.bindingId || !context || !authority || !ownerSessionId)
215
+ return false;
216
+ const currentContext = manager.getBindingContexts().get(input.bindingId);
217
+ const currentAuthority = manager.getBindingAuthority(input.bindingId);
218
+ if (!currentContext || !currentAuthority)
219
+ return false;
220
+ try {
221
+ if (getProjectPreparationAuthorityIdentity(currentAuthority, currentContext) !== authorityIdentity)
222
+ return false;
223
+ }
224
+ catch {
225
+ return false;
226
+ }
227
+ if (!validateProjectPreparationAuthority(currentAuthority, {
228
+ bindingId: input.bindingId,
229
+ context: currentContext,
230
+ ownerSessionId,
231
+ }))
232
+ return false;
233
+ if (!authentication && AgentConfigManager.getInstance().isAuthEnabled())
234
+ return false;
235
+ const current = ConfigManager.getInstance().loadDeclaredServerConfigs();
236
+ if (current.errors.length)
237
+ return false;
238
+ const currentDefinition = current.templateServers[target.backendName] ?? current.staticServers[target.backendName];
239
+ if (JSON.stringify(currentDefinition) !== JSON.stringify(definition))
240
+ return false;
241
+ if (preparationRevision !== undefined) {
242
+ try {
243
+ if (validatePreparationConfig(currentDefinition?.preparation).effectiveRevision !== preparationRevision)
244
+ return false;
245
+ }
246
+ catch {
247
+ return false;
248
+ }
249
+ }
250
+ if (currentDefinition?.disabled ||
251
+ getDisabledSourceToolError({ ...current.staticServers, ...current.templateServers }, target.backendName, target.toolName))
252
+ return false;
253
+ const grantedTags = authentication?.[3];
254
+ if (Array.isArray(grantedTags) && grantedTags.length) {
255
+ if (!grantedTags.every((tag) => typeof tag === 'string'))
256
+ return false;
257
+ if (TemplateFilteringService.getMatchingTemplates([[target.backendName, definition]], {
258
+ tags: grantedTags,
259
+ tagFilterMode: 'simple-or',
260
+ }).length !== 1)
261
+ return false;
262
+ }
263
+ if (TemplateFilteringService.getMatchingTemplates([[target.backendName, definition]], filterConfig).length !== 1)
264
+ return false;
265
+ if (filterConfig.presetName) {
266
+ const preset = PresetManager.getInstance().getPreset(filterConfig.presetName);
267
+ if (JSON.stringify(preset) !== presetRevision)
268
+ return false;
269
+ if (preset && JSON.stringify(preset.tagQuery) !== JSON.stringify(filterConfig.tagQuery))
270
+ return false;
271
+ }
272
+ return true;
273
+ };
274
+ const authorized = async () => {
275
+ if (!synchronousAuthorization())
276
+ return false;
277
+ if (!(await withinRequestBudget(scope, input.signal, async () => revalidateAuth())))
278
+ return false;
279
+ if (!synchronousAuthorization())
280
+ return false;
281
+ const policies = await withinRequestBudget(scope, input.signal, async () => resolveProjectPolicies(context, filterConfig));
282
+ if (!(await withinRequestBudget(scope, input.signal, async () => revalidateAuth())))
283
+ return false;
284
+ return (synchronousAuthorization() &&
285
+ isProjectBackendVisible({ ...definition, projectTarget: { mode: 'single' } }, context, policies));
286
+ };
287
+ if (declared.errors.length || !(await authorized()))
288
+ return blocked({
289
+ state: 'forbidden',
290
+ instructions: 'A current verified local checkout grant and visible backend are required.',
291
+ });
292
+ // No checkout filesystem access precedes the receipt, current auth, configured filter, and disabled-tool checks.
293
+ const checkoutPath = requireProjectTarget(context, 'single')[0].path;
294
+ const coordinator = ports?.coordinator ?? getBackendPreparationCoordinator(serverManager);
295
+ const runtimeScopeId = new RuntimeIdentityService({
296
+ storageDir: AgentConfigManager.getInstance().get('runtimeScopeStoragePath'),
297
+ }).getRuntimeScopeId();
298
+ const grant = await withinRequestBudget(scope, input.signal, async () => coordinator.resolveGrant({
299
+ backendName: target.backendName,
300
+ checkoutPath,
301
+ owner: createPreparationOwnerIdentity(runtimeScopeId, authentication, filterConfig, context ? getVerifiedProjectOwner(context)?.ownerId : undefined),
302
+ filterConfig,
303
+ }));
304
+ const args = projectToolArguments(definition, context, target.arguments);
305
+ if (args && typeof args === 'object' && !Array.isArray(args) && Object.hasOwn(args, 'projectPath')) {
306
+ const projectPath = args.projectPath;
307
+ // Compare without reading any caller-selected path. The configured native helper repeats this fence before SDK dispatch.
308
+ if (typeof projectPath !== 'string' ||
309
+ !path.isAbsolute(projectPath) ||
310
+ path.normalize(projectPath) !== grant.target.checkoutRoot)
311
+ return blocked({ state: 'forbidden', instructions: 'projectPath conflicts with the verified Project Checkout.' });
312
+ }
313
+ const expiresAt = scope?.expiresAt ?? Date.now() + (ConfigManager.getInstance().getAppConfig().preparation?.requestWaitMs ?? 5000);
314
+ const remaining = () => Math.max(0, expiresAt - Date.now());
315
+ if (input.signal?.aborted || remaining() === 0)
316
+ return blocked({ state: 'unknown', reason: input.signal?.aborted ? 'caller_disconnected' : 'inspection_timeout' });
317
+ // Validate an already-discovered source schema when available. Empty cold discovery
318
+ // must not prevent preparation; the caller's later explicit invocation validates its schema.
319
+ let nativeDefinition;
320
+ if (ports?.toolDefinition) {
321
+ nativeDefinition = await withinRequestBudget(scope, input.signal, async (signal) => ports.toolDefinition({ toolName: target.toolName }, { signal, executionDeadlineMs: remaining() }));
322
+ if (!nativeDefinition)
323
+ return blocked({ state: 'unsupported', instructions: 'The configured backend does not expose this operation.' });
324
+ }
325
+ else {
326
+ const resolver = createConnectionResolver(serverManager.getClients(), {
327
+ getBindingContext: (id) => manager.getBindingContexts().get(id),
328
+ getBindingPolicies: (id) => manager.getBindingPolicies(id),
329
+ getRenderedHashForSession: (id, backend) => manager.getRenderedHashForSession(id, backend),
330
+ getAllRenderedHashesForSession: (id) => manager.getAllRenderedHashesForSession(id),
331
+ });
332
+ const connection = resolver.resolve(target.backendName, input.bindingId);
333
+ if (connection) {
334
+ const snapshot = readConfiguredToolSnapshot(connection);
335
+ const found = snapshot?.find((tool) => tool.name === target.toolName);
336
+ nativeDefinition = found ? { ...found } : undefined;
337
+ if (snapshot?.length && !nativeDefinition)
338
+ return blocked({
339
+ state: 'unsupported',
340
+ instructions: 'The configured backend does not expose this operation.',
341
+ });
342
+ }
343
+ }
344
+ if (nativeDefinition)
345
+ await withinRequestBudget(scope, input.signal, async (signal) => {
346
+ if (ports?.validateArguments)
347
+ return ports.validateArguments(nativeDefinition, args, signal);
348
+ const validationBinding = {
349
+ routeKey: `${target.backendName}/${target.toolName}`,
350
+ generation: grant.target.configurationKey,
351
+ signal,
352
+ };
353
+ const contracts = await admitToolSchemas(nativeDefinition, validationBinding);
354
+ await prepareToolValidation(contracts, args, validationBinding);
355
+ });
356
+ if (!(await authorized()))
357
+ return blocked({ state: 'forbidden', instructions: 'Preparation authorization changed.' });
358
+ const result = await coordinator.admit(grant, target.toolName, {
359
+ waitMs: remaining(),
360
+ signal: input.signal,
361
+ validateAdmission: authorized,
362
+ assertAdmission: () => {
363
+ if (!synchronousAuthorization())
364
+ throw new PreparationAuthorizationChangedError();
365
+ },
366
+ });
367
+ if (result.state !== 'ready')
368
+ return blocked(result);
369
+ if (!(await authorized()))
370
+ return blocked({ state: 'forbidden', instructions: 'Preparation authorization changed.' });
371
+ await withinRequestBudget(scope, input.signal, async () => (ports?.refresh ?? refreshPreparedBackendCapabilities)(serverManager, grant.target, {
372
+ missingTool: target.toolName,
373
+ }));
374
+ if (!(await authorized()))
375
+ return blocked({ state: 'forbidden', instructions: 'Preparation authorization changed.' });
376
+ const beforeDispatch = async () => {
377
+ const defer = (preparation) => ({ result: preparationToolResult(preparation).structuredContent });
378
+ try {
379
+ if (!(await authorized()))
380
+ return defer({ state: 'forbidden', instructions: 'Preparation authorization changed.' });
381
+ const current = await coordinator.admit(grant, target.toolName, {
382
+ waitMs: remaining(),
383
+ signal: input.signal,
384
+ validateAdmission: authorized,
385
+ assertAdmission: () => {
386
+ if (!synchronousAuthorization())
387
+ throw new PreparationAuthorizationChangedError();
388
+ },
389
+ });
390
+ if (current.state !== 'ready')
391
+ return defer(current);
392
+ // No asynchronous policy or catalog work follows this fresh native barrier.
393
+ if (!synchronousAuthorization())
394
+ return defer({ state: 'forbidden', instructions: 'Preparation authorization changed.' });
395
+ if (input.signal?.aborted || remaining() === 0)
396
+ return defer({
397
+ state: 'unknown',
398
+ reason: input.signal?.aborted ? 'caller_disconnected' : 'inspection_timeout',
399
+ });
400
+ return {
401
+ assertCurrent: () => synchronousAuthorization() && !input.signal?.aborted && remaining() > 0,
402
+ };
403
+ }
404
+ catch (error) {
405
+ if (error instanceof PreparationCallerStopped)
406
+ return defer({ state: 'unknown', reason: error.reason });
407
+ if (error instanceof PreparationAuthorizationChangedError)
408
+ return defer({ state: 'forbidden', instructions: error.message });
409
+ throw error;
410
+ }
411
+ };
412
+ const setupDeadline = () => {
413
+ const controller = new AbortController();
414
+ const timer = setTimeout(() => controller.abort(), Math.max(0, remaining()));
415
+ timer.unref();
416
+ return {
417
+ signal: input.signal ? AbortSignal.any([input.signal, controller.signal]) : controller.signal,
418
+ stop: () => clearTimeout(timer),
419
+ };
420
+ };
421
+ return { kind: 'ready', setupDeadline, revalidate: authorized, beforeDispatch };
422
+ }
423
+ //# sourceMappingURL=backendPreparationAdmission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backendPreparationAdmission.js","sourceRoot":"","sources":["../../src/application/backendPreparationAdmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IA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EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAC7E,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM;YAC7F,IAAI,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;SAChC,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAClF,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { type ProjectBlocker } from './projectLifecycle.js';
2
+ import type { ProjectConfig } from '../config/projectConfigTypes.js';
3
+ import type { ServerManager } from '../core/server/serverManager.js';
4
+ import type { InboundConnectionConfig } from '../core/types/server.js';
5
+ import type { BackendPolicy, BackendPreparationAdapter, BackendReadiness, PreparationResult, PreparationStatus, PreparationTarget } from '../domains/backend-preparation/contracts.js';
6
+ import { type EffectivePreparationConfig } from '../domains/backend-preparation/integrationDefinitions.js';
7
+ import { PreparationOptionsSchema } from '../domains/backend-preparation/policy.js';
8
+ import { BackendPreparationService } from '../domains/backend-preparation/service.js';
9
+ import { z } from 'zod';
10
+ type RuntimePreparationConfig = EffectivePreparationConfig;
11
+ type OwnedAdapter = BackendPreparationAdapter & {
12
+ dispose?: () => void | Promise<void>;
13
+ };
14
+ export type PreparationControl = 'inspect' | 'prepare' | 'status' | 'wait' | 'cancel' | 'retry';
15
+ export interface PreparationGrant {
16
+ readonly owner: string;
17
+ readonly target: PreparationTarget;
18
+ readonly policy: BackendPolicy;
19
+ readonly preferences: NonNullable<ProjectConfig['preparation']>;
20
+ readonly integrationAvailable?: boolean;
21
+ }
22
+ export interface PreparationControlRequest {
23
+ readonly action: PreparationControl;
24
+ readonly id?: string;
25
+ readonly operation?: string;
26
+ readonly waitMs?: number;
27
+ readonly signal?: AbortSignal;
28
+ readonly validateAdmission?: () => Promise<boolean>;
29
+ readonly assertAdmission?: () => void;
30
+ }
31
+ export declare class PreparationAuthorizationChangedError extends Error {
32
+ constructor();
33
+ }
34
+ export type PublicPreparationStatus = Omit<PreparationStatus, 'target'> & {
35
+ readonly target: {
36
+ readonly checkoutRoot: string;
37
+ readonly backendName: string;
38
+ };
39
+ };
40
+ export type PublicPreparationResult = Exclude<PreparationResult, {
41
+ state: 'job';
42
+ }> | {
43
+ readonly state: 'job';
44
+ readonly status: PublicPreparationStatus;
45
+ };
46
+ export type PublicPreparationAdmission = PublicPreparationResult | {
47
+ readonly state: 'pending';
48
+ readonly status: PublicPreparationStatus;
49
+ readonly operationExecuted: false;
50
+ readonly operationQueued: false;
51
+ readonly instructions: string;
52
+ };
53
+ export type PreparationControlResult = BackendReadiness | PublicPreparationAdmission | PublicPreparationStatus | undefined;
54
+ /** One coordinator and scheduler per Aggregated Runtime, independent of advertised tools. */
55
+ export declare class BackendPreparationCoordinator {
56
+ private readonly ports;
57
+ private readonly grantInputs;
58
+ private readonly namedGrants;
59
+ readonly service: BackendPreparationService;
60
+ private readonly registry;
61
+ private readonly adapters;
62
+ private readonly registered;
63
+ private readonly handles;
64
+ private readonly monitored;
65
+ private readonly refreshedJobs;
66
+ private readonly readinessRefreshes;
67
+ private readonly latestAdapters;
68
+ private readonly adapterCalls;
69
+ private readonly failureAdapters;
70
+ private readonly disposing;
71
+ private readonly disposalFailures;
72
+ private readonly store;
73
+ private closed;
74
+ private shutdownPromise?;
75
+ constructor(ports?: {
76
+ options?: Partial<z.infer<typeof PreparationOptionsSchema>>;
77
+ storagePath?: string;
78
+ adapterFactory?: (config: RuntimePreparationConfig) => OwnedAdapter;
79
+ onReady?: (target: PreparationTarget) => Promise<void>;
80
+ });
81
+ /** Caller must authorize the target context before this function performs any filesystem access. */
82
+ resolveGrant(input: {
83
+ backendName: string;
84
+ checkoutPath: string;
85
+ owner: string;
86
+ filterConfig: InboundConnectionConfig;
87
+ }): Promise<PreparationGrant>;
88
+ control(grant: PreparationGrant, request: PreparationControlRequest): Promise<PreparationControlResult>;
89
+ admit(grant: PreparationGrant, operation: string, options?: {
90
+ waitMs?: number;
91
+ signal?: AbortSignal;
92
+ validateAdmission?: () => Promise<boolean>;
93
+ assertAdmission?: () => void;
94
+ }): Promise<PublicPreparationAdmission | BackendReadiness>;
95
+ getProjectBlockers(checkout: string): ProjectBlocker[];
96
+ private withReservation;
97
+ private assertNamedGrantCurrent;
98
+ private assertGrantCurrent;
99
+ private revalidateGrant;
100
+ shutdown(): Promise<void>;
101
+ private stop;
102
+ private register;
103
+ private publish;
104
+ private publishStatus;
105
+ private presentStatus;
106
+ private currentStatus;
107
+ private trackAdapter;
108
+ private recycle;
109
+ private monitor;
110
+ private refreshReadyStatus;
111
+ }
112
+ export declare function refreshPreparedBackendCapabilities(serverManager: ServerManager, target: PreparationTarget, options?: {
113
+ missingTool?: string;
114
+ onlyEmptyInventory?: boolean;
115
+ }): Promise<void>;
116
+ export declare function getBackendPreparationCoordinator(serverManager: ServerManager): BackendPreparationCoordinator;
117
+ /** Read-only lookup: lifecycle status must never initialize preparation. */
118
+ export declare function peekBackendPreparationCoordinator(serverManager: ServerManager): BackendPreparationCoordinator | undefined;
119
+ /** A restarted runtime cannot infer that an advisory active job's external writer has exited. */
120
+ export declare function persistedProjectPreparationBlockers(checkout: string): ProjectBlocker[];
121
+ export {};
122
+ //# sourceMappingURL=backendPreparationCoordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backendPreparationCoordinator.d.ts","sourceRoot":"","sources":["../../src/application/backendPreparationCoordinator.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAGxH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAQvE,OAAO,KAAK,EAAE,aAAa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