@xenosystem/agent-interface-host 0.1.3

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 (482) hide show
  1. package/LICENSE +67 -0
  2. package/dist/acp/AcpAgentRegistryService.d.ts +77 -0
  3. package/dist/acp/AcpAgentRegistryService.d.ts.map +1 -0
  4. package/dist/acp/AcpAgentRegistryService.js +754 -0
  5. package/dist/acp/AcpAgentRegistryService.js.map +1 -0
  6. package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts +56 -0
  7. package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts.map +1 -0
  8. package/dist/acp/AcpAgentTurnExecutionAdapter.js +323 -0
  9. package/dist/acp/AcpAgentTurnExecutionAdapter.js.map +1 -0
  10. package/dist/acp/AcpApprovalPortAdapter.d.ts +41 -0
  11. package/dist/acp/AcpApprovalPortAdapter.d.ts.map +1 -0
  12. package/dist/acp/AcpApprovalPortAdapter.js +82 -0
  13. package/dist/acp/AcpApprovalPortAdapter.js.map +1 -0
  14. package/dist/acp/AcpCoordinationBridge.d.ts +13 -0
  15. package/dist/acp/AcpCoordinationBridge.d.ts.map +1 -0
  16. package/dist/acp/AcpCoordinationBridge.js +13 -0
  17. package/dist/acp/AcpCoordinationBridge.js.map +1 -0
  18. package/dist/acp/AcpDiagnosticsService.d.ts +61 -0
  19. package/dist/acp/AcpDiagnosticsService.d.ts.map +1 -0
  20. package/dist/acp/AcpDiagnosticsService.js +203 -0
  21. package/dist/acp/AcpDiagnosticsService.js.map +1 -0
  22. package/dist/acp/AcpExternalCertificationHarness.d.ts +47 -0
  23. package/dist/acp/AcpExternalCertificationHarness.d.ts.map +1 -0
  24. package/dist/acp/AcpExternalCertificationHarness.js +176 -0
  25. package/dist/acp/AcpExternalCertificationHarness.js.map +1 -0
  26. package/dist/acp/AcpHostBridge.d.ts +81 -0
  27. package/dist/acp/AcpHostBridge.d.ts.map +1 -0
  28. package/dist/acp/AcpHostBridge.js +101 -0
  29. package/dist/acp/AcpHostBridge.js.map +1 -0
  30. package/dist/acp/AcpInteractivePermissionBridge.d.ts +77 -0
  31. package/dist/acp/AcpInteractivePermissionBridge.d.ts.map +1 -0
  32. package/dist/acp/AcpInteractivePermissionBridge.js +127 -0
  33. package/dist/acp/AcpInteractivePermissionBridge.js.map +1 -0
  34. package/dist/acp/AcpPermissionBridge.d.ts +19 -0
  35. package/dist/acp/AcpPermissionBridge.d.ts.map +1 -0
  36. package/dist/acp/AcpPermissionBridge.js +110 -0
  37. package/dist/acp/AcpPermissionBridge.js.map +1 -0
  38. package/dist/acp/AcpPermissionPolicy.d.ts +111 -0
  39. package/dist/acp/AcpPermissionPolicy.d.ts.map +1 -0
  40. package/dist/acp/AcpPermissionPolicy.js +167 -0
  41. package/dist/acp/AcpPermissionPolicy.js.map +1 -0
  42. package/dist/acp/AcpProcessSupervisor.d.ts +134 -0
  43. package/dist/acp/AcpProcessSupervisor.d.ts.map +1 -0
  44. package/dist/acp/AcpProcessSupervisor.js +674 -0
  45. package/dist/acp/AcpProcessSupervisor.js.map +1 -0
  46. package/dist/acp/AcpProviderApprovalService.d.ts +27 -0
  47. package/dist/acp/AcpProviderApprovalService.d.ts.map +1 -0
  48. package/dist/acp/AcpProviderApprovalService.js +128 -0
  49. package/dist/acp/AcpProviderApprovalService.js.map +1 -0
  50. package/dist/acp/AcpProviderCatalogService.d.ts +69 -0
  51. package/dist/acp/AcpProviderCatalogService.d.ts.map +1 -0
  52. package/dist/acp/AcpProviderCatalogService.js +707 -0
  53. package/dist/acp/AcpProviderCatalogService.js.map +1 -0
  54. package/dist/acp/AcpProviderModelService.d.ts +6 -0
  55. package/dist/acp/AcpProviderModelService.d.ts.map +1 -0
  56. package/dist/acp/AcpProviderModelService.js +274 -0
  57. package/dist/acp/AcpProviderModelService.js.map +1 -0
  58. package/dist/acp/AcpProviderVersionReadiness.d.ts +6 -0
  59. package/dist/acp/AcpProviderVersionReadiness.d.ts.map +1 -0
  60. package/dist/acp/AcpProviderVersionReadiness.js +100 -0
  61. package/dist/acp/AcpProviderVersionReadiness.js.map +1 -0
  62. package/dist/acp/AcpRuntimeEventMapper.d.ts +16 -0
  63. package/dist/acp/AcpRuntimeEventMapper.d.ts.map +1 -0
  64. package/dist/acp/AcpRuntimeEventMapper.js +326 -0
  65. package/dist/acp/AcpRuntimeEventMapper.js.map +1 -0
  66. package/dist/acp/AcpSessionService.d.ts +65 -0
  67. package/dist/acp/AcpSessionService.d.ts.map +1 -0
  68. package/dist/acp/AcpSessionService.js +931 -0
  69. package/dist/acp/AcpSessionService.js.map +1 -0
  70. package/dist/acp/DurableAcpPermissionPolicyStore.d.ts +25 -0
  71. package/dist/acp/DurableAcpPermissionPolicyStore.d.ts.map +1 -0
  72. package/dist/acp/DurableAcpPermissionPolicyStore.js +100 -0
  73. package/dist/acp/DurableAcpPermissionPolicyStore.js.map +1 -0
  74. package/dist/acp/acpCommandSafety.d.ts +63 -0
  75. package/dist/acp/acpCommandSafety.d.ts.map +1 -0
  76. package/dist/acp/acpCommandSafety.js +90 -0
  77. package/dist/acp/acpCommandSafety.js.map +1 -0
  78. package/dist/acp/acpErrors.d.ts +47 -0
  79. package/dist/acp/acpErrors.d.ts.map +1 -0
  80. package/dist/acp/acpErrors.js +93 -0
  81. package/dist/acp/acpErrors.js.map +1 -0
  82. package/dist/acp/acpRedaction.d.ts +9 -0
  83. package/dist/acp/acpRedaction.d.ts.map +1 -0
  84. package/dist/acp/acpRedaction.js +69 -0
  85. package/dist/acp/acpRedaction.js.map +1 -0
  86. package/dist/acp/acpSessionResume.d.ts +8 -0
  87. package/dist/acp/acpSessionResume.d.ts.map +1 -0
  88. package/dist/acp/acpSessionResume.js +31 -0
  89. package/dist/acp/acpSessionResume.js.map +1 -0
  90. package/dist/acp/acpTypes.d.ts +467 -0
  91. package/dist/acp/acpTypes.d.ts.map +1 -0
  92. package/dist/acp/acpTypes.js +2 -0
  93. package/dist/acp/acpTypes.js.map +1 -0
  94. package/dist/agent/chooseDirectoryBridge.d.ts +29 -0
  95. package/dist/agent/chooseDirectoryBridge.d.ts.map +1 -0
  96. package/dist/agent/chooseDirectoryBridge.js +116 -0
  97. package/dist/agent/chooseDirectoryBridge.js.map +1 -0
  98. package/dist/agent/permissionProfiles.d.ts +29 -0
  99. package/dist/agent/permissionProfiles.d.ts.map +1 -0
  100. package/dist/agent/permissionProfiles.js +107 -0
  101. package/dist/agent/permissionProfiles.js.map +1 -0
  102. package/dist/agent/runtimeAuthorityPrompt.d.ts +13 -0
  103. package/dist/agent/runtimeAuthorityPrompt.d.ts.map +1 -0
  104. package/dist/agent/runtimeAuthorityPrompt.js +45 -0
  105. package/dist/agent/runtimeAuthorityPrompt.js.map +1 -0
  106. package/dist/agent/runtimeModeOutputGuard.d.ts +6 -0
  107. package/dist/agent/runtimeModeOutputGuard.d.ts.map +1 -0
  108. package/dist/agent/runtimeModeOutputGuard.js +40 -0
  109. package/dist/agent/runtimeModeOutputGuard.js.map +1 -0
  110. package/dist/agent/workspacePlacementBridge.d.ts +29 -0
  111. package/dist/agent/workspacePlacementBridge.d.ts.map +1 -0
  112. package/dist/agent/workspacePlacementBridge.js +143 -0
  113. package/dist/agent/workspacePlacementBridge.js.map +1 -0
  114. package/dist/agentSearch/AgentSearchService.d.ts +81 -0
  115. package/dist/agentSearch/AgentSearchService.d.ts.map +1 -0
  116. package/dist/agentSearch/AgentSearchService.js +1038 -0
  117. package/dist/agentSearch/AgentSearchService.js.map +1 -0
  118. package/dist/agentSearch/JsonInvertedIndexAdapter.d.ts +44 -0
  119. package/dist/agentSearch/JsonInvertedIndexAdapter.d.ts.map +1 -0
  120. package/dist/agentSearch/JsonInvertedIndexAdapter.js +307 -0
  121. package/dist/agentSearch/JsonInvertedIndexAdapter.js.map +1 -0
  122. package/dist/agentSearch/SearchIndexAdapter.d.ts +33 -0
  123. package/dist/agentSearch/SearchIndexAdapter.d.ts.map +1 -0
  124. package/dist/agentSearch/SearchIndexAdapter.js +2 -0
  125. package/dist/agentSearch/SearchIndexAdapter.js.map +1 -0
  126. package/dist/agentSearch/SearchSourceWatcher.d.ts +29 -0
  127. package/dist/agentSearch/SearchSourceWatcher.d.ts.map +1 -0
  128. package/dist/agentSearch/SearchSourceWatcher.js +150 -0
  129. package/dist/agentSearch/SearchSourceWatcher.js.map +1 -0
  130. package/dist/agentSearch/SqliteFtsIndexAdapter.d.ts +58 -0
  131. package/dist/agentSearch/SqliteFtsIndexAdapter.d.ts.map +1 -0
  132. package/dist/agentSearch/SqliteFtsIndexAdapter.js +420 -0
  133. package/dist/agentSearch/SqliteFtsIndexAdapter.js.map +1 -0
  134. package/dist/agentSearch/conversationIndexer.d.ts +69 -0
  135. package/dist/agentSearch/conversationIndexer.d.ts.map +1 -0
  136. package/dist/agentSearch/conversationIndexer.js +313 -0
  137. package/dist/agentSearch/conversationIndexer.js.map +1 -0
  138. package/dist/agentSearch/searchTypes.d.ts +264 -0
  139. package/dist/agentSearch/searchTypes.d.ts.map +1 -0
  140. package/dist/agentSearch/searchTypes.js +2 -0
  141. package/dist/agentSearch/searchTypes.js.map +1 -0
  142. package/dist/agentSearch/searchUtils.d.ts +12 -0
  143. package/dist/agentSearch/searchUtils.d.ts.map +1 -0
  144. package/dist/agentSearch/searchUtils.js +125 -0
  145. package/dist/agentSearch/searchUtils.js.map +1 -0
  146. package/dist/agentSearch/workspaceMetadataIndexer.d.ts +3 -0
  147. package/dist/agentSearch/workspaceMetadataIndexer.d.ts.map +1 -0
  148. package/dist/agentSearch/workspaceMetadataIndexer.js +125 -0
  149. package/dist/agentSearch/workspaceMetadataIndexer.js.map +1 -0
  150. package/dist/cli/CliControlPlaneService.d.ts +269 -0
  151. package/dist/cli/CliControlPlaneService.d.ts.map +1 -0
  152. package/dist/cli/CliControlPlaneService.js +1874 -0
  153. package/dist/cli/CliControlPlaneService.js.map +1 -0
  154. package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts +91 -0
  155. package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts.map +1 -0
  156. package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js +379 -0
  157. package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js.map +1 -0
  158. package/dist/codebase/CodebaseIntelligenceService.d.ts +68 -0
  159. package/dist/codebase/CodebaseIntelligenceService.d.ts.map +1 -0
  160. package/dist/codebase/CodebaseIntelligenceService.js +1717 -0
  161. package/dist/codebase/CodebaseIntelligenceService.js.map +1 -0
  162. package/dist/codebase/LanguageServerProcessManager.d.ts +85 -0
  163. package/dist/codebase/LanguageServerProcessManager.d.ts.map +1 -0
  164. package/dist/codebase/LanguageServerProcessManager.js +607 -0
  165. package/dist/codebase/LanguageServerProcessManager.js.map +1 -0
  166. package/dist/codebase/codeTypes.d.ts +485 -0
  167. package/dist/codebase/codeTypes.d.ts.map +1 -0
  168. package/dist/codebase/codeTypes.js +2 -0
  169. package/dist/codebase/codeTypes.js.map +1 -0
  170. package/dist/codebase/codeUtils.d.ts +24 -0
  171. package/dist/codebase/codeUtils.d.ts.map +1 -0
  172. package/dist/codebase/codeUtils.js +177 -0
  173. package/dist/codebase/codeUtils.js.map +1 -0
  174. package/dist/codebase/contextPacks.d.ts +18 -0
  175. package/dist/codebase/contextPacks.d.ts.map +1 -0
  176. package/dist/codebase/contextPacks.js +180 -0
  177. package/dist/codebase/contextPacks.js.map +1 -0
  178. package/dist/codebase/dependencyGraph.d.ts +3 -0
  179. package/dist/codebase/dependencyGraph.d.ts.map +1 -0
  180. package/dist/codebase/dependencyGraph.js +209 -0
  181. package/dist/codebase/dependencyGraph.js.map +1 -0
  182. package/dist/codebase/fileIndexer.d.ts +27 -0
  183. package/dist/codebase/fileIndexer.d.ts.map +1 -0
  184. package/dist/codebase/fileIndexer.js +167 -0
  185. package/dist/codebase/fileIndexer.js.map +1 -0
  186. package/dist/codebase/symbolIndexer.d.ts +3 -0
  187. package/dist/codebase/symbolIndexer.d.ts.map +1 -0
  188. package/dist/codebase/symbolIndexer.js +184 -0
  189. package/dist/codebase/symbolIndexer.js.map +1 -0
  190. package/dist/codebase/whatChanged.d.ts +4 -0
  191. package/dist/codebase/whatChanged.d.ts.map +1 -0
  192. package/dist/codebase/whatChanged.js +138 -0
  193. package/dist/codebase/whatChanged.js.map +1 -0
  194. package/dist/coordination/CoordinationService.d.ts +166 -0
  195. package/dist/coordination/CoordinationService.d.ts.map +1 -0
  196. package/dist/coordination/CoordinationService.js +247 -0
  197. package/dist/coordination/CoordinationService.js.map +1 -0
  198. package/dist/coordination/claims.d.ts +122 -0
  199. package/dist/coordination/claims.d.ts.map +1 -0
  200. package/dist/coordination/claims.js +196 -0
  201. package/dist/coordination/claims.js.map +1 -0
  202. package/dist/coordination/coordinationTools.d.ts +40 -0
  203. package/dist/coordination/coordinationTools.d.ts.map +1 -0
  204. package/dist/coordination/coordinationTools.js +92 -0
  205. package/dist/coordination/coordinationTools.js.map +1 -0
  206. package/dist/coordination/laneBridge.d.ts +84 -0
  207. package/dist/coordination/laneBridge.d.ts.map +1 -0
  208. package/dist/coordination/laneBridge.js +86 -0
  209. package/dist/coordination/laneBridge.js.map +1 -0
  210. package/dist/coordination/messages.d.ts +225 -0
  211. package/dist/coordination/messages.d.ts.map +1 -0
  212. package/dist/coordination/messages.js +335 -0
  213. package/dist/coordination/messages.js.map +1 -0
  214. package/dist/coordination/permissionWaitRegistry.d.ts +32 -0
  215. package/dist/coordination/permissionWaitRegistry.d.ts.map +1 -0
  216. package/dist/coordination/permissionWaitRegistry.js +59 -0
  217. package/dist/coordination/permissionWaitRegistry.js.map +1 -0
  218. package/dist/coordination/query.d.ts +187 -0
  219. package/dist/coordination/query.d.ts.map +1 -0
  220. package/dist/coordination/query.js +138 -0
  221. package/dist/coordination/query.js.map +1 -0
  222. package/dist/coordination/renderInbox.d.ts +15 -0
  223. package/dist/coordination/renderInbox.d.ts.map +1 -0
  224. package/dist/coordination/renderInbox.js +19 -0
  225. package/dist/coordination/renderInbox.js.map +1 -0
  226. package/dist/coordination/runtimeEvents.d.ts +53 -0
  227. package/dist/coordination/runtimeEvents.d.ts.map +1 -0
  228. package/dist/coordination/runtimeEvents.js +112 -0
  229. package/dist/coordination/runtimeEvents.js.map +1 -0
  230. package/dist/detachedHostService.d.ts +77 -0
  231. package/dist/detachedHostService.d.ts.map +1 -0
  232. package/dist/detachedHostService.js +66 -0
  233. package/dist/detachedHostService.js.map +1 -0
  234. package/dist/detachedHostSupervisor.d.ts +102 -0
  235. package/dist/detachedHostSupervisor.d.ts.map +1 -0
  236. package/dist/detachedHostSupervisor.js +168 -0
  237. package/dist/detachedHostSupervisor.js.map +1 -0
  238. package/dist/durableRuntimeEventStore.d.ts +49 -0
  239. package/dist/durableRuntimeEventStore.d.ts.map +1 -0
  240. package/dist/durableRuntimeEventStore.js +364 -0
  241. package/dist/durableRuntimeEventStore.js.map +1 -0
  242. package/dist/engineering/EngineeringWorkbenchService.d.ts +142 -0
  243. package/dist/engineering/EngineeringWorkbenchService.d.ts.map +1 -0
  244. package/dist/engineering/EngineeringWorkbenchService.js +2301 -0
  245. package/dist/engineering/EngineeringWorkbenchService.js.map +1 -0
  246. package/dist/engineering/LandingService.d.ts +112 -0
  247. package/dist/engineering/LandingService.d.ts.map +1 -0
  248. package/dist/engineering/LandingService.js +239 -0
  249. package/dist/engineering/LandingService.js.map +1 -0
  250. package/dist/engineering/engineeringTypes.d.ts +2 -0
  251. package/dist/engineering/engineeringTypes.d.ts.map +1 -0
  252. package/dist/engineering/engineeringTypes.js +2 -0
  253. package/dist/engineering/engineeringTypes.js.map +1 -0
  254. package/dist/engineering/patchReview.d.ts +11 -0
  255. package/dist/engineering/patchReview.d.ts.map +1 -0
  256. package/dist/engineering/patchReview.js +174 -0
  257. package/dist/engineering/patchReview.js.map +1 -0
  258. package/dist/index.d.ts +834 -0
  259. package/dist/index.d.ts.map +1 -0
  260. package/dist/index.js +3242 -0
  261. package/dist/index.js.map +1 -0
  262. package/dist/intake/IntakeService.d.ts +84 -0
  263. package/dist/intake/IntakeService.d.ts.map +1 -0
  264. package/dist/intake/IntakeService.js +117 -0
  265. package/dist/intake/IntakeService.js.map +1 -0
  266. package/dist/intake/RepositoryTodoIntakeSource.d.ts +72 -0
  267. package/dist/intake/RepositoryTodoIntakeSource.d.ts.map +1 -0
  268. package/dist/intake/RepositoryTodoIntakeSource.js +168 -0
  269. package/dist/intake/RepositoryTodoIntakeSource.js.map +1 -0
  270. package/dist/intake/WorkspaceTodoIntakeSource.d.ts +53 -0
  271. package/dist/intake/WorkspaceTodoIntakeSource.d.ts.map +1 -0
  272. package/dist/intake/WorkspaceTodoIntakeSource.js +81 -0
  273. package/dist/intake/WorkspaceTodoIntakeSource.js.map +1 -0
  274. package/dist/isolation/CommandExecution.d.ts +132 -0
  275. package/dist/isolation/CommandExecution.d.ts.map +1 -0
  276. package/dist/isolation/CommandExecution.js +48 -0
  277. package/dist/isolation/CommandExecution.js.map +1 -0
  278. package/dist/isolation/LocalCommandExecutor.d.ts +27 -0
  279. package/dist/isolation/LocalCommandExecutor.d.ts.map +1 -0
  280. package/dist/isolation/LocalCommandExecutor.js +97 -0
  281. package/dist/isolation/LocalCommandExecutor.js.map +1 -0
  282. package/dist/isolation/RunExecutionEnvironment.d.ts +135 -0
  283. package/dist/isolation/RunExecutionEnvironment.d.ts.map +1 -0
  284. package/dist/isolation/RunExecutionEnvironment.js +206 -0
  285. package/dist/isolation/RunExecutionEnvironment.js.map +1 -0
  286. package/dist/isolation/RunIsolationService.d.ts +90 -0
  287. package/dist/isolation/RunIsolationService.d.ts.map +1 -0
  288. package/dist/isolation/RunIsolationService.js +86 -0
  289. package/dist/isolation/RunIsolationService.js.map +1 -0
  290. package/dist/isolation/SandboxCommandExecutor.d.ts +93 -0
  291. package/dist/isolation/SandboxCommandExecutor.d.ts.map +1 -0
  292. package/dist/isolation/SandboxCommandExecutor.js +189 -0
  293. package/dist/isolation/SandboxCommandExecutor.js.map +1 -0
  294. package/dist/knowledge/WorkspaceKnowledgeService.d.ts +71 -0
  295. package/dist/knowledge/WorkspaceKnowledgeService.d.ts.map +1 -0
  296. package/dist/knowledge/WorkspaceKnowledgeService.js +103 -0
  297. package/dist/knowledge/WorkspaceKnowledgeService.js.map +1 -0
  298. package/dist/localHostAuthority.d.ts +24 -0
  299. package/dist/localHostAuthority.d.ts.map +1 -0
  300. package/dist/localHostAuthority.js +87 -0
  301. package/dist/localHostAuthority.js.map +1 -0
  302. package/dist/localHostLease.d.ts +51 -0
  303. package/dist/localHostLease.d.ts.map +1 -0
  304. package/dist/localHostLease.js +167 -0
  305. package/dist/localHostLease.js.map +1 -0
  306. package/dist/localHostPaths.d.ts +30 -0
  307. package/dist/localHostPaths.d.ts.map +1 -0
  308. package/dist/localHostPaths.js +60 -0
  309. package/dist/localHostPaths.js.map +1 -0
  310. package/dist/localRpcTransport.d.ts +21 -0
  311. package/dist/localRpcTransport.d.ts.map +1 -0
  312. package/dist/localRpcTransport.js +423 -0
  313. package/dist/localRpcTransport.js.map +1 -0
  314. package/dist/node.d.ts +104 -0
  315. package/dist/node.d.ts.map +1 -0
  316. package/dist/node.js +103 -0
  317. package/dist/node.js.map +1 -0
  318. package/dist/observation/DirectoryBaselineScanner.d.ts +44 -0
  319. package/dist/observation/DirectoryBaselineScanner.d.ts.map +1 -0
  320. package/dist/observation/DirectoryBaselineScanner.js +112 -0
  321. package/dist/observation/DirectoryBaselineScanner.js.map +1 -0
  322. package/dist/observation/MountContentReader.d.ts +63 -0
  323. package/dist/observation/MountContentReader.d.ts.map +1 -0
  324. package/dist/observation/MountContentReader.js +158 -0
  325. package/dist/observation/MountContentReader.js.map +1 -0
  326. package/dist/observation/RunObservationService.d.ts +229 -0
  327. package/dist/observation/RunObservationService.d.ts.map +1 -0
  328. package/dist/observation/RunObservationService.js +248 -0
  329. package/dist/observation/RunObservationService.js.map +1 -0
  330. package/dist/observation/XenoUseObservationSource.d.ts +42 -0
  331. package/dist/observation/XenoUseObservationSource.d.ts.map +1 -0
  332. package/dist/observation/XenoUseObservationSource.js +104 -0
  333. package/dist/observation/XenoUseObservationSource.js.map +1 -0
  334. package/dist/observation/XenoUseRunObserver.d.ts +140 -0
  335. package/dist/observation/XenoUseRunObserver.d.ts.map +1 -0
  336. package/dist/observation/XenoUseRunObserver.js +256 -0
  337. package/dist/observation/XenoUseRunObserver.js.map +1 -0
  338. package/dist/pluginMcp/PluginMcpManagerService.d.ts +141 -0
  339. package/dist/pluginMcp/PluginMcpManagerService.d.ts.map +1 -0
  340. package/dist/pluginMcp/PluginMcpManagerService.js +1821 -0
  341. package/dist/pluginMcp/PluginMcpManagerService.js.map +1 -0
  342. package/dist/pluginMcp/pluginMcpTypes.d.ts +349 -0
  343. package/dist/pluginMcp/pluginMcpTypes.d.ts.map +1 -0
  344. package/dist/pluginMcp/pluginMcpTypes.js +2 -0
  345. package/dist/pluginMcp/pluginMcpTypes.js.map +1 -0
  346. package/dist/policy/WorkspacePolicyService.d.ts +83 -0
  347. package/dist/policy/WorkspacePolicyService.d.ts.map +1 -0
  348. package/dist/policy/WorkspacePolicyService.js +809 -0
  349. package/dist/policy/WorkspacePolicyService.js.map +1 -0
  350. package/dist/policy/policyGuard.d.ts +27 -0
  351. package/dist/policy/policyGuard.d.ts.map +1 -0
  352. package/dist/policy/policyGuard.js +143 -0
  353. package/dist/policy/policyGuard.js.map +1 -0
  354. package/dist/policy/policyTypes.d.ts +190 -0
  355. package/dist/policy/policyTypes.d.ts.map +1 -0
  356. package/dist/policy/policyTypes.js +2 -0
  357. package/dist/policy/policyTypes.js.map +1 -0
  358. package/dist/runtime/RuntimeEventStore.d.ts +42 -0
  359. package/dist/runtime/RuntimeEventStore.d.ts.map +1 -0
  360. package/dist/runtime/RuntimeEventStore.js +412 -0
  361. package/dist/runtime/RuntimeEventStore.js.map +1 -0
  362. package/dist/runtime/RuntimeEventStoreRepositoryAdapter.d.ts +21 -0
  363. package/dist/runtime/RuntimeEventStoreRepositoryAdapter.d.ts.map +1 -0
  364. package/dist/runtime/RuntimeEventStoreRepositoryAdapter.js +41 -0
  365. package/dist/runtime/RuntimeEventStoreRepositoryAdapter.js.map +1 -0
  366. package/dist/runtime/RuntimeTimelineProjection.d.ts +5 -0
  367. package/dist/runtime/RuntimeTimelineProjection.d.ts.map +1 -0
  368. package/dist/runtime/RuntimeTimelineProjection.js +705 -0
  369. package/dist/runtime/RuntimeTimelineProjection.js.map +1 -0
  370. package/dist/runtime/runtimeEventTypes.d.ts +73 -0
  371. package/dist/runtime/runtimeEventTypes.d.ts.map +1 -0
  372. package/dist/runtime/runtimeEventTypes.js +2 -0
  373. package/dist/runtime/runtimeEventTypes.js.map +1 -0
  374. package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts +117 -0
  375. package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts.map +1 -0
  376. package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js +214 -0
  377. package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js.map +1 -0
  378. package/dist/session/AgentSessionService.d.ts +285 -0
  379. package/dist/session/AgentSessionService.d.ts.map +1 -0
  380. package/dist/session/AgentSessionService.js +444 -0
  381. package/dist/session/AgentSessionService.js.map +1 -0
  382. package/dist/session/bufferedSessionPty.d.ts +27 -0
  383. package/dist/session/bufferedSessionPty.d.ts.map +1 -0
  384. package/dist/session/bufferedSessionPty.js +49 -0
  385. package/dist/session/bufferedSessionPty.js.map +1 -0
  386. package/dist/session/renderSupport.d.ts +53 -0
  387. package/dist/session/renderSupport.d.ts.map +1 -0
  388. package/dist/session/renderSupport.js +41 -0
  389. package/dist/session/renderSupport.js.map +1 -0
  390. package/dist/session/runtimeEventChannel.d.ts +56 -0
  391. package/dist/session/runtimeEventChannel.d.ts.map +1 -0
  392. package/dist/session/runtimeEventChannel.js +53 -0
  393. package/dist/session/runtimeEventChannel.js.map +1 -0
  394. package/dist/state/JsonAgentStateRepository.d.ts +29 -0
  395. package/dist/state/JsonAgentStateRepository.d.ts.map +1 -0
  396. package/dist/state/JsonAgentStateRepository.js +165 -0
  397. package/dist/state/JsonAgentStateRepository.js.map +1 -0
  398. package/dist/state/SqliteAgentStateRepository.d.ts +58 -0
  399. package/dist/state/SqliteAgentStateRepository.d.ts.map +1 -0
  400. package/dist/state/SqliteAgentStateRepository.js +777 -0
  401. package/dist/state/SqliteAgentStateRepository.js.map +1 -0
  402. package/dist/state/createAgentStateRepository.d.ts +4 -0
  403. package/dist/state/createAgentStateRepository.d.ts.map +1 -0
  404. package/dist/state/createAgentStateRepository.js +12 -0
  405. package/dist/state/createAgentStateRepository.js.map +1 -0
  406. package/dist/state/stateSanitizers.d.ts +7 -0
  407. package/dist/state/stateSanitizers.d.ts.map +1 -0
  408. package/dist/state/stateSanitizers.js +87 -0
  409. package/dist/state/stateSanitizers.js.map +1 -0
  410. package/dist/subagents/AcpSubagentExecutionAdapter.d.ts +12 -0
  411. package/dist/subagents/AcpSubagentExecutionAdapter.d.ts.map +1 -0
  412. package/dist/subagents/AcpSubagentExecutionAdapter.js +119 -0
  413. package/dist/subagents/AcpSubagentExecutionAdapter.js.map +1 -0
  414. package/dist/subagents/CliSubagentExecutionAdapter.d.ts +13 -0
  415. package/dist/subagents/CliSubagentExecutionAdapter.d.ts.map +1 -0
  416. package/dist/subagents/CliSubagentExecutionAdapter.js +217 -0
  417. package/dist/subagents/CliSubagentExecutionAdapter.js.map +1 -0
  418. package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts +78 -0
  419. package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts.map +1 -0
  420. package/dist/subagents/HostTurnSubagentExecutionAdapter.js +160 -0
  421. package/dist/subagents/HostTurnSubagentExecutionAdapter.js.map +1 -0
  422. package/dist/subagents/SubagentRunService.d.ts +103 -0
  423. package/dist/subagents/SubagentRunService.d.ts.map +1 -0
  424. package/dist/subagents/SubagentRunService.js +1183 -0
  425. package/dist/subagents/SubagentRunService.js.map +1 -0
  426. package/dist/subagents/SubagentScheduler.d.ts +167 -0
  427. package/dist/subagents/SubagentScheduler.d.ts.map +1 -0
  428. package/dist/subagents/SubagentScheduler.js +530 -0
  429. package/dist/subagents/SubagentScheduler.js.map +1 -0
  430. package/dist/subagents/TeamAgentRouter.d.ts +104 -0
  431. package/dist/subagents/TeamAgentRouter.d.ts.map +1 -0
  432. package/dist/subagents/TeamAgentRouter.js +435 -0
  433. package/dist/subagents/TeamAgentRouter.js.map +1 -0
  434. package/dist/subagents/capabilityMatcher.d.ts +3 -0
  435. package/dist/subagents/capabilityMatcher.d.ts.map +1 -0
  436. package/dist/subagents/capabilityMatcher.js +127 -0
  437. package/dist/subagents/capabilityMatcher.js.map +1 -0
  438. package/dist/subagents/subagentRunPort.d.ts +43 -0
  439. package/dist/subagents/subagentRunPort.d.ts.map +1 -0
  440. package/dist/subagents/subagentRunPort.js +24 -0
  441. package/dist/subagents/subagentRunPort.js.map +1 -0
  442. package/dist/subagents/subagentTypes.d.ts +330 -0
  443. package/dist/subagents/subagentTypes.d.ts.map +1 -0
  444. package/dist/subagents/subagentTypes.js +2 -0
  445. package/dist/subagents/subagentTypes.js.map +1 -0
  446. package/dist/subagents/subagentWorkspaceAuthority.d.ts +29 -0
  447. package/dist/subagents/subagentWorkspaceAuthority.d.ts.map +1 -0
  448. package/dist/subagents/subagentWorkspaceAuthority.js +173 -0
  449. package/dist/subagents/subagentWorkspaceAuthority.js.map +1 -0
  450. package/dist/support/SupportDiagnosticsService.d.ts +87 -0
  451. package/dist/support/SupportDiagnosticsService.d.ts.map +1 -0
  452. package/dist/support/SupportDiagnosticsService.js +1199 -0
  453. package/dist/support/SupportDiagnosticsService.js.map +1 -0
  454. package/dist/turns/DurableInterruptedTurnStore.d.ts +14 -0
  455. package/dist/turns/DurableInterruptedTurnStore.d.ts.map +1 -0
  456. package/dist/turns/DurableInterruptedTurnStore.js +63 -0
  457. package/dist/turns/DurableInterruptedTurnStore.js.map +1 -0
  458. package/dist/turns/interruptedTurns.d.ts +50 -0
  459. package/dist/turns/interruptedTurns.d.ts.map +1 -0
  460. package/dist/turns/interruptedTurns.js +54 -0
  461. package/dist/turns/interruptedTurns.js.map +1 -0
  462. package/dist/turns/turnAdmission.d.ts +113 -0
  463. package/dist/turns/turnAdmission.d.ts.map +1 -0
  464. package/dist/turns/turnAdmission.js +136 -0
  465. package/dist/turns/turnAdmission.js.map +1 -0
  466. package/dist/workspace/WorkspaceHostService.d.ts +126 -0
  467. package/dist/workspace/WorkspaceHostService.d.ts.map +1 -0
  468. package/dist/workspace/WorkspaceHostService.js +841 -0
  469. package/dist/workspace/WorkspaceHostService.js.map +1 -0
  470. package/dist/workspace/WorkspaceShellService.d.ts +71 -0
  471. package/dist/workspace/WorkspaceShellService.d.ts.map +1 -0
  472. package/dist/workspace/WorkspaceShellService.js +273 -0
  473. package/dist/workspace/WorkspaceShellService.js.map +1 -0
  474. package/dist/workspace/fileAssociations.d.ts +12 -0
  475. package/dist/workspace/fileAssociations.d.ts.map +1 -0
  476. package/dist/workspace/fileAssociations.js +202 -0
  477. package/dist/workspace/fileAssociations.js.map +1 -0
  478. package/dist/workspace/scrollbackBuffer.d.ts +48 -0
  479. package/dist/workspace/scrollbackBuffer.d.ts.map +1 -0
  480. package/dist/workspace/scrollbackBuffer.js +94 -0
  481. package/dist/workspace/scrollbackBuffer.js.map +1 -0
  482. package/package.json +42 -0
@@ -0,0 +1,674 @@
1
+ import { isAbsolute } from 'path';
2
+ import packageJson from '../../package.json' with { type: 'json' };
3
+ import { AgentProcess, createLogger } from '@xenosystem/acp-core';
4
+ import { AcpCancelledError, AcpProcessExitedError, AcpProtocolError, AcpTimeoutError, AcpVersionMismatchError, acpErrorCode, } from './acpErrors.js';
5
+ import { assertAcpProviderVersionReadyAsync } from './AcpProviderVersionReadiness.js';
6
+ import { isAcpShellCommandLine, isAcpShellExecutable } from './acpCommandSafety.js';
7
+ import { FailClosedAcpPermissionBridge, cancelAcpPermissionBridge, handleAcpPermissionRequest, } from './AcpPermissionBridge.js';
8
+ import { FailClosedAcpHostBridge, XENO_ACP_META_KEY, cancelAcpHostBridge, handleAcpHostExtensionRequest, } from './AcpHostBridge.js';
9
+ import { UnavailableCoordinationLaneBridge } from '../coordination/laneBridge.js';
10
+ import { xenoAcpHostRequestAdvertisement } from './AcpHostBridge.js';
11
+ import { boundedPush, redactAcpArgs, redactAcpEnvKeys, redactAcpPath, redactAcpText } from './acpRedaction.js';
12
+ import { normalizeAcpSessionResumeState, XENO_ACP_SESSION_RESUME_META_KEY, } from './acpSessionResume.js';
13
+ export const XENO_ACP_CONTEXT_META_KEY = 'xeno.dev/context';
14
+ /**
15
+ * What `initialize` actually sends. Exported so the advertisement can be
16
+ * asserted where it is TRANSMITTED rather than where it is computed — a test
17
+ * against the helper alone stays green while this object hand-lists something
18
+ * else, which is exactly how the list fell behind the dispatcher before.
19
+ */
20
+ export const DEFAULT_CLIENT_CAPABILITIES = {
21
+ fs: {
22
+ readTextFile: false,
23
+ writeTextFile: false,
24
+ },
25
+ terminal: false,
26
+ _meta: {
27
+ [XENO_ACP_META_KEY]: {
28
+ chooseDirectory: true,
29
+ /**
30
+ * 🔴 DERIVED from the dispatch table, never listed here.
31
+ *
32
+ * `initialize` sends this, and it is the whole difference between a
33
+ * method that is reachable and one that is merely implemented. Hand-listed,
34
+ * it silently fell behind the dispatcher — exactly the shape this repo has
35
+ * hit five times. Now a method cannot be dispatched without being
36
+ * advertised, because both read the same array.
37
+ */
38
+ hostRequests: xenoAcpHostRequestAdvertisement(),
39
+ },
40
+ },
41
+ };
42
+ // These rules used to be a second, character-for-character copy of the registry
43
+ // service's. They are now one shared rule in ./acpCommandSafety — the launch
44
+ // check and the admission check are still BOTH performed (defence in depth: a
45
+ // config can reach disk without passing through the registry), but they can no
46
+ // longer disagree about what "shell command line" means.
47
+ /**
48
+ * Hub-facing facade over `@xenosystem/acp-core`.
49
+ *
50
+ * Hub owns policy, redacted diagnostics, and UI bridges. Core owns spawning, the official
51
+ * ACP SDK connection, session lifecycle, cancellation, and transport validation.
52
+ */
53
+ export class AcpProcessSupervisor {
54
+ config;
55
+ runtime = null;
56
+ sessions = new Map();
57
+ status = 'stopped';
58
+ lifecycle = [];
59
+ stderrTail = [];
60
+ protocolVersion;
61
+ agentInfo;
62
+ agentCapabilities;
63
+ lastErrorCode;
64
+ permissionBridge;
65
+ hostBridge;
66
+ coordinationBridge;
67
+ requestTimeoutMs;
68
+ constructor(config, options = {}) {
69
+ this.config = config;
70
+ this.permissionBridge = options.permissionBridge || new FailClosedAcpPermissionBridge();
71
+ this.hostBridge = options.hostBridge || new FailClosedAcpHostBridge();
72
+ this.coordinationBridge = options.coordinationBridge || new UnavailableCoordinationLaneBridge();
73
+ this.requestTimeoutMs = options.requestTimeoutMs || 30_000;
74
+ this.validateConfig(config);
75
+ }
76
+ getStatus() {
77
+ const coreState = this.runtime?.status().state;
78
+ if (coreState === 'stopped' && this.status !== 'stopping' && this.status !== 'stopped')
79
+ return 'exited';
80
+ return this.status;
81
+ }
82
+ async initialize() {
83
+ if (this.runtime && this.status === 'ready' && this.protocolVersion && this.agentInfo) {
84
+ return {
85
+ protocolVersion: this.protocolVersion,
86
+ agentCapabilities: this.agentCapabilities || {},
87
+ agentInfo: this.agentInfo,
88
+ authMethods: [],
89
+ };
90
+ }
91
+ this.validateConfig(this.config);
92
+ try {
93
+ await assertAcpProviderVersionReadyAsync(this.config);
94
+ }
95
+ catch (error) {
96
+ this.lastErrorCode = acpErrorCode(error);
97
+ this.transition('failed', 'ACP provider CLI version blocked.');
98
+ throw error;
99
+ }
100
+ this.transition('starting', 'Starting ACP subprocess through @xenosystem/acp-core.');
101
+ this.runtime = new AgentProcess({
102
+ def: {
103
+ id: this.config.id,
104
+ name: this.config.name,
105
+ cmd: this.config.command,
106
+ args: [...this.config.args],
107
+ ...(this.config.env ? { env: { ...this.config.env } } : {}),
108
+ ...(this.config.cwd ? { cwd: this.config.cwd } : {}),
109
+ initTimeoutMs: this.requestTimeoutMs,
110
+ permission: 'deny',
111
+ },
112
+ workspaceRoot: this.config.cwd || process.cwd(),
113
+ keepWorkspaces: true,
114
+ logger: createLogger('xeno-hub-acp', 'silent'),
115
+ clientInfo: {
116
+ name: 'xeno-hub',
117
+ title: 'XENO Hub',
118
+ version: String(packageJson.version || '0.0.0'),
119
+ },
120
+ clientCapabilities: DEFAULT_CLIENT_CAPABILITIES,
121
+ requestPermission: async (request) => handleAcpPermissionRequest(request, this.permissionBridge),
122
+ extMethod: async (method, params) => handleAcpHostExtensionRequest(method, params, this.hostBridge, this.coordinationBridge),
123
+ onStderr: (chunk) => this.captureStderr(chunk),
124
+ skipVersionCheck: true,
125
+ inheritedEnvKeys: [
126
+ 'APPDATA', 'HOME', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'PATH', 'PATHEXT',
127
+ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP', 'USERPROFILE', 'WINDIR',
128
+ ],
129
+ });
130
+ this.transition('initializing', 'Initializing ACP protocol through @xenosystem/acp-core.');
131
+ try {
132
+ await this.runtime.ensureReady();
133
+ const initialization = this.runtime.diagnostics().initialization;
134
+ if (!initialization)
135
+ throw new AcpProtocolError('ACP initialize returned an invalid response.');
136
+ if (initialization.protocolVersion !== 1) {
137
+ this.lastErrorCode = 'ACP_VERSION_MISMATCH';
138
+ await this.stop();
139
+ throw new AcpVersionMismatchError(`Unsupported ACP protocol version: ${initialization.protocolVersion}`, {
140
+ diagnostics: { expected: 1, received: initialization.protocolVersion },
141
+ });
142
+ }
143
+ this.protocolVersion = initialization.protocolVersion;
144
+ this.agentInfo = initialization.agentInfo;
145
+ this.agentCapabilities = initialization.agentCapabilities;
146
+ this.transition('ready', 'ACP protocol initialized by @xenosystem/acp-core.');
147
+ return {
148
+ protocolVersion: this.protocolVersion,
149
+ agentCapabilities: this.agentCapabilities || {},
150
+ agentInfo: this.agentInfo,
151
+ authMethods: initialization.authMethods || [],
152
+ };
153
+ }
154
+ catch (error) {
155
+ const classified = this.classifyCoreError(error);
156
+ this.lastErrorCode = classified.code;
157
+ this.transition(classified instanceof AcpVersionMismatchError ? 'exited' : 'failed', 'ACP initialization failed.');
158
+ throw classified;
159
+ }
160
+ }
161
+ async createSession(options = {}) {
162
+ if (!this.runtime || this.status !== 'ready')
163
+ await this.initialize();
164
+ const params = this.buildSessionNewRequest(options);
165
+ try {
166
+ const session = await this.runtime.createSession({
167
+ workspace: params.cwd,
168
+ mcpServers: params.mcpServers,
169
+ ...(params.additionalDirectories ? { additionalDirectories: params.additionalDirectories } : {}),
170
+ ...(params._meta ? { _meta: params._meta } : {}),
171
+ });
172
+ this.sessions.set(session.id, session);
173
+ return { sessionId: session.id };
174
+ }
175
+ catch (error) {
176
+ throw this.classifyCoreError(error);
177
+ }
178
+ }
179
+ supportsResumeSession() {
180
+ const sessionCapabilities = this.agentCapabilities?.sessionCapabilities;
181
+ const resume = sessionCapabilities && typeof sessionCapabilities === 'object' && !Array.isArray(sessionCapabilities)
182
+ ? sessionCapabilities.resume
183
+ : undefined;
184
+ return !!resume
185
+ && typeof resume === 'object'
186
+ && !Array.isArray(resume)
187
+ && typeof this.runtime?.resumeSession === 'function';
188
+ }
189
+ /**
190
+ * XENO ACP compatibility path for embedding cores that predate `AgentProcess.resumeSession`.
191
+ * The provider-native continuation id is rebound to a fresh ACP session via bounded `_meta`.
192
+ */
193
+ supportsSessionNewResumeState() {
194
+ const meta = this.agentCapabilities?._meta;
195
+ if (!meta || typeof meta !== 'object' || Array.isArray(meta))
196
+ return false;
197
+ const xeno = meta[XENO_ACP_META_KEY];
198
+ if (!xeno || typeof xeno !== 'object' || Array.isArray(xeno))
199
+ return false;
200
+ const capability = xeno.sessionResume;
201
+ return !!capability
202
+ && typeof capability === 'object'
203
+ && !Array.isArray(capability)
204
+ && capability.schemaVersion === 1
205
+ && capability.sessionNewMetaFallback === true;
206
+ }
207
+ async resumeSession(sessionId, options = {}) {
208
+ if (!this.runtime || this.status !== 'ready')
209
+ await this.initialize();
210
+ const runtime = this.runtime;
211
+ if (!this.supportsResumeSession() || !runtime?.resumeSession) {
212
+ throw new AcpProtocolError('ACP agent does not support session/resume.');
213
+ }
214
+ const params = this.buildSessionNewRequest(options);
215
+ try {
216
+ const session = await runtime.resumeSession(sessionId, {
217
+ workspace: params.cwd,
218
+ mcpServers: params.mcpServers,
219
+ additionalDirectories: params.additionalDirectories,
220
+ _meta: params._meta,
221
+ });
222
+ this.sessions.set(session.id, session);
223
+ return { sessionId: session.id };
224
+ }
225
+ catch (error) {
226
+ throw this.classifyCoreError(error);
227
+ }
228
+ }
229
+ async prompt(sessionId, prompt, options = {}) {
230
+ const session = this.sessions.get(sessionId);
231
+ if (!session || !this.runtime)
232
+ throw new AcpProtocolError(`Unknown ACP session: ${sessionId}`);
233
+ const updates = [];
234
+ const cancelInteractiveBridges = () => {
235
+ cancelAcpPermissionBridge(this.permissionBridge);
236
+ cancelAcpHostBridge(this.hostBridge);
237
+ };
238
+ if (options.signal?.aborted) {
239
+ cancelInteractiveBridges();
240
+ }
241
+ else {
242
+ options.signal?.addEventListener('abort', cancelInteractiveBridges, { once: true });
243
+ }
244
+ this.transition('running', 'Running ACP prompt through @xenosystem/acp-core.');
245
+ try {
246
+ const promptOptions = {
247
+ timeoutMs: options.timeoutMs || this.requestTimeoutMs,
248
+ signal: options.signal,
249
+ model: options.model,
250
+ systemPrompt: options.systemPrompt,
251
+ execution: options.execution,
252
+ onUpdate: (notification) => {
253
+ const update = this.normalizeSessionUpdate(notification);
254
+ if (!update)
255
+ return;
256
+ updates.push(update);
257
+ options.onUpdate?.(update);
258
+ },
259
+ };
260
+ const result = await this.runtime.promptSession(session, [{ type: 'text', text: prompt }], promptOptions);
261
+ this.transition('ready', 'ACP prompt completed.');
262
+ const responseMeta = result._meta && typeof result._meta === 'object' && !Array.isArray(result._meta)
263
+ ? result._meta
264
+ : undefined;
265
+ const resumeState = normalizeAcpSessionResumeState(responseMeta?.[XENO_ACP_SESSION_RESUME_META_KEY]);
266
+ return {
267
+ result: {
268
+ stopReason: result.stopReason,
269
+ ...(resumeState ? { resumeState } : {}),
270
+ },
271
+ updates,
272
+ };
273
+ }
274
+ catch (error) {
275
+ if (this.runtime?.diagnostics().exitCode === undefined) {
276
+ await this.waitForExitDiagnostics();
277
+ }
278
+ const classified = this.classifyCoreError(error);
279
+ this.lastErrorCode = classified.code;
280
+ if (classified instanceof AcpProcessExitedError)
281
+ this.transition('exited', 'ACP subprocess exited.');
282
+ else if (classified instanceof AcpTimeoutError)
283
+ this.transition('exited', 'ACP prompt timed out; connection invalidated.');
284
+ else
285
+ this.transition('ready', 'ACP prompt ended with an error.');
286
+ throw classified;
287
+ }
288
+ finally {
289
+ options.signal?.removeEventListener('abort', cancelInteractiveBridges);
290
+ }
291
+ }
292
+ async cancelSession(sessionId) {
293
+ cancelAcpPermissionBridge(this.permissionBridge);
294
+ cancelAcpHostBridge(this.hostBridge);
295
+ if (!this.runtime)
296
+ throw new AcpProtocolError('ACP process is not initialized.');
297
+ await this.runtime.cancelSession(sessionId);
298
+ return { cancelled: true };
299
+ }
300
+ async restart() {
301
+ await this.stop();
302
+ return this.initialize();
303
+ }
304
+ /**
305
+ * Wait, briefly, for a transport that is going away to actually be gone.
306
+ *
307
+ * This exists because `getStatus()` is a LIVE READ of a value that is still settling right
308
+ * after a cancellation, and three separate decisions were each sampling it at one arbitrary
309
+ * instant: whether to emit `acp.agent.exited` against the cancelled request, whether to discard
310
+ * the conversation session, and whether the next prompt may reuse the process.
311
+ *
312
+ * ⚠️ What that costs is ATTRIBUTION, not the event: a missed sample defers the exit to
313
+ * `closeConversationSession`, which reports it under the synthetic id `acp-session-close`. The
314
+ * first draft of this note claimed the event could be lost entirely; it cannot, and the
315
+ * distinction matters to anyone consuming these events.
316
+ *
317
+ * A cancelled prompt aborts the connection mid-flight, so "is it dead yet" is genuinely
318
+ * unanswerable in that same tick. This gives the answer a bounded chance to arrive instead of
319
+ * guessing, and returns what was actually established.
320
+ *
321
+ * ⚠️ INTERIM, with a named exit condition. The right mechanism is a push: `AgentProcess`
322
+ * (`@xenosystem/acp-core`, which we own) exposes `onStderr` and `status()` and **no exit
323
+ * callback**, so there is nothing to subscribe to and polling is the only honest option from
324
+ * this side. Adding `onExit` upstream and reporting the exit when it is OBSERVED — rather than
325
+ * when someone thinks to look — removes both the poll and the deadline. Raised as a cross-repo
326
+ * requirement rather than worked around silently.
327
+ */
328
+ async waitForExit(timeoutMs) {
329
+ const deadline = Date.now() + Math.max(0, timeoutMs);
330
+ for (;;) {
331
+ const status = this.getStatus();
332
+ if (status === 'exited' || status === 'stopped')
333
+ return true;
334
+ if (Date.now() >= deadline)
335
+ return false;
336
+ await new Promise((resolve) => { setTimeout(resolve, 5); });
337
+ }
338
+ }
339
+ async stop() {
340
+ if (!this.runtime) {
341
+ this.sessions.clear();
342
+ this.transition('stopped', 'ACP process already stopped.');
343
+ return;
344
+ }
345
+ this.transition('stopping', 'Stopping ACP subprocess through @xenosystem/acp-core.');
346
+ await this.runtime.dispose();
347
+ this.sessions.clear();
348
+ this.runtime = null;
349
+ this.transition('stopped', 'ACP subprocess stopped.');
350
+ }
351
+ diagnostics() {
352
+ const coreStatus = this.runtime?.status();
353
+ const coreDiagnostics = this.runtime?.diagnostics();
354
+ return {
355
+ agentConfigId: this.config.id,
356
+ command: redactAcpPath(this.config.command) || '[redacted-command]',
357
+ args: redactAcpArgs(this.config.args),
358
+ cwd: redactAcpPath(this.config.cwd),
359
+ envKeys: redactAcpEnvKeys(this.config.env),
360
+ status: this.getStatus(),
361
+ pid: coreStatus?.pid,
362
+ protocolVersion: this.protocolVersion,
363
+ agentInfo: this.agentInfo,
364
+ agentCapabilities: this.agentCapabilities,
365
+ activeSessionCount: coreStatus?.activeSessions || 0,
366
+ pendingRequestCount: 0,
367
+ lifecycle: this.lifecycle,
368
+ stderrTail: this.stderrTail,
369
+ malformedMessageCount: coreDiagnostics?.malformedMessageCount || 0,
370
+ unsupportedMethodCount: coreDiagnostics?.unsupportedMethodCount || 0,
371
+ lastErrorCode: this.lastErrorCode,
372
+ exitCode: coreDiagnostics?.exitCode,
373
+ signal: coreDiagnostics?.signal,
374
+ };
375
+ }
376
+ validateConfig(config) {
377
+ if (!config.id.trim())
378
+ throw new AcpProtocolError('ACP agent config id is required.');
379
+ if (!config.name.trim())
380
+ throw new AcpProtocolError('ACP agent config name is required.');
381
+ if (!config.command.trim())
382
+ throw new AcpProtocolError('ACP command must be a non-empty string.');
383
+ if (!isAbsolute(config.command))
384
+ throw new AcpProtocolError('ACP command must be an absolute executable path.');
385
+ if (isAcpShellCommandLine(config.command)) {
386
+ throw new AcpProtocolError('ACP command must be an executable path, not a shell command line.');
387
+ }
388
+ if (isAcpShellExecutable(config.command)) {
389
+ throw new AcpProtocolError('ACP command cannot be a shell executable.');
390
+ }
391
+ if (!config.enabled)
392
+ throw new AcpProtocolError('ACP agent config must be enabled before launch.');
393
+ if (config.trustLevel !== 'restricted' && config.trustLevel !== 'workspace') {
394
+ throw new AcpProtocolError('ACP trustLevel must be restricted or workspace.');
395
+ }
396
+ if (!Array.isArray(config.args) || config.args.some((arg) => typeof arg !== 'string')) {
397
+ throw new AcpProtocolError('ACP args must be an array of strings.');
398
+ }
399
+ if (config.cwd !== undefined && (!config.cwd.trim() || !isAbsolute(config.cwd))) {
400
+ throw new AcpProtocolError('ACP cwd must be an absolute path when provided.');
401
+ }
402
+ for (const [key, value] of Object.entries(config.env || {})) {
403
+ if (typeof value !== 'string')
404
+ throw new AcpProtocolError(`ACP env value must be a string: ${key}`);
405
+ }
406
+ }
407
+ buildSessionNewRequest(options) {
408
+ const cwd = options.cwd?.trim() || this.config.cwd?.trim();
409
+ if (!cwd || !isAbsolute(cwd))
410
+ throw new AcpProtocolError('ACP session/new cwd must be an absolute path.');
411
+ if (options.mcpServers !== undefined && !Array.isArray(options.mcpServers)) {
412
+ throw new AcpProtocolError('ACP session/new mcpServers must be an array.');
413
+ }
414
+ if (options._meta !== undefined && (!options._meta || typeof options._meta !== 'object' || Array.isArray(options._meta))) {
415
+ throw new AcpProtocolError('ACP session/new _meta must be an object when provided.');
416
+ }
417
+ if (options.additionalDirectories !== undefined
418
+ && (!Array.isArray(options.additionalDirectories)
419
+ || options.additionalDirectories.some((directory) => typeof directory !== 'string' || !isAbsolute(directory)))) {
420
+ throw new AcpProtocolError('ACP session/new additionalDirectories must contain only absolute paths.');
421
+ }
422
+ return {
423
+ cwd,
424
+ mcpServers: options.mcpServers ? [...options.mcpServers] : [],
425
+ ...(options._meta ? { _meta: { ...options._meta } } : {}),
426
+ ...(options.additionalDirectories ? { additionalDirectories: [...new Set(options.additionalDirectories)] } : {}),
427
+ };
428
+ }
429
+ classifyCoreError(error) {
430
+ if (error instanceof AcpProtocolError
431
+ || error instanceof AcpTimeoutError
432
+ || error instanceof AcpCancelledError
433
+ || error instanceof AcpProcessExitedError
434
+ || error instanceof AcpVersionMismatchError)
435
+ return error;
436
+ const message = error instanceof Error ? error.message : String(error);
437
+ if (/unsupported ACP protocol version/i.test(message)) {
438
+ return new AcpVersionMismatchError(redactAcpText(message), { cause: error });
439
+ }
440
+ if (/timed out/i.test(message))
441
+ return new AcpTimeoutError(redactAcpText(message), { cause: error });
442
+ if (/cancel/i.test(message))
443
+ return new AcpCancelledError(redactAcpText(message), { cause: error });
444
+ if (this.runtime?.status().state === 'stopped' || /process exited|connection.*closed|stream.*closed/i.test(message)) {
445
+ return new AcpProcessExitedError(redactAcpText(message), { processId: this.runtime?.status().pid, cause: error });
446
+ }
447
+ return new AcpProtocolError(redactAcpText(message), { cause: error });
448
+ }
449
+ transition(status, message) {
450
+ this.status = status;
451
+ this.lifecycle = boundedPush(this.lifecycle, { timestamp: new Date().toISOString(), status, message }, 25);
452
+ }
453
+ captureStderr(chunk) {
454
+ for (const line of chunk.split(/\r?\n/)) {
455
+ if (!line)
456
+ continue;
457
+ this.stderrTail = boundedPush(this.stderrTail, redactAcpText(line, 1000), 50);
458
+ }
459
+ }
460
+ normalizeSessionUpdate(value) {
461
+ if (!value || typeof value !== 'object' || Array.isArray(value))
462
+ return undefined;
463
+ const record = value;
464
+ if (!record.update || typeof record.update !== 'object' || Array.isArray(record.update))
465
+ return undefined;
466
+ const update = this.normalizeUpdate(record.update, typeof record.sessionId === 'string' ? record.sessionId : undefined);
467
+ if (!update)
468
+ return undefined;
469
+ return { ...(typeof record.sessionId === 'string' ? { sessionId: record.sessionId } : {}), update };
470
+ }
471
+ normalizeUpdate(value, sessionId) {
472
+ if (!value || typeof value !== 'object' || Array.isArray(value))
473
+ return undefined;
474
+ const record = value;
475
+ const updateType = typeof record.type === 'string'
476
+ ? record.type
477
+ : typeof record.sessionUpdate === 'string' ? record.sessionUpdate : undefined;
478
+ if (!updateType)
479
+ return undefined;
480
+ if (updateType === 'plan') {
481
+ const entries = this.normalizePlanEntries(record.entries);
482
+ return {
483
+ type: 'plan',
484
+ content: typeof record.content === 'string'
485
+ ? redactAcpText(record.content, 32_000)
486
+ : entries.map((entry) => entry.content).join('\n'),
487
+ ...(entries.length ? { entries } : {}),
488
+ };
489
+ }
490
+ if (updateType === 'agent_message_chunk') {
491
+ const content = record.content;
492
+ const text = typeof content === 'string'
493
+ ? content
494
+ : content && typeof content === 'object' && !Array.isArray(content) && typeof content.text === 'string'
495
+ ? String(content.text)
496
+ : '';
497
+ return {
498
+ type: 'agent_message_chunk',
499
+ messageId: typeof record.messageId === 'string'
500
+ ? redactAcpText(record.messageId, 500)
501
+ : `${sessionId || 'acp'}-message`,
502
+ content: text,
503
+ };
504
+ }
505
+ if (updateType === 'tool_call') {
506
+ const toolCallId = typeof record.toolCallId === 'string'
507
+ ? redactAcpText(record.toolCallId.trim(), 500)
508
+ : undefined;
509
+ if (!toolCallId)
510
+ return undefined;
511
+ return {
512
+ type: 'tool_call',
513
+ toolCallId,
514
+ title: typeof record.title === 'string' ? redactAcpText(record.title, 500) : 'ACP Tool',
515
+ kind: typeof record.kind === 'string' ? redactAcpText(record.kind, 100) : 'unknown',
516
+ status: this.normalizeToolStatus(record.status),
517
+ content: this.normalizeToolContent(record.content),
518
+ locations: this.normalizeToolLocations(record.locations),
519
+ rawInput: this.normalizeToolPayload(record.rawInput),
520
+ rawOutput: this.normalizeToolPayload(record.rawOutput),
521
+ };
522
+ }
523
+ if (updateType === 'tool_call_update') {
524
+ const toolCallId = typeof record.toolCallId === 'string'
525
+ ? redactAcpText(record.toolCallId.trim(), 500)
526
+ : undefined;
527
+ const status = this.normalizeToolStatus(record.status);
528
+ if (!toolCallId || !status)
529
+ return undefined;
530
+ const rawOutput = this.normalizeToolPayload(record.rawOutput);
531
+ return {
532
+ type: 'tool_call_update',
533
+ toolCallId,
534
+ // Carried, not dropped. The mapper had nothing to name the tool with, so it substituted a
535
+ // constant — the normalizer is where the information was actually being lost.
536
+ title: typeof record.title === 'string' ? redactAcpText(record.title, 500) : undefined,
537
+ status,
538
+ content: this.normalizeToolContent(record.content),
539
+ rawOutput,
540
+ error: typeof record.error === 'string'
541
+ ? redactAcpText(record.error, 2_000)
542
+ : rawOutput && typeof rawOutput === 'object' && !Array.isArray(rawOutput)
543
+ && typeof rawOutput.error === 'string'
544
+ ? String(rawOutput.error)
545
+ : undefined,
546
+ _meta: record._meta && typeof record._meta === 'object' && !Array.isArray(record._meta)
547
+ ? record._meta
548
+ : undefined,
549
+ };
550
+ }
551
+ if (updateType === 'usage_update') {
552
+ const used = typeof record.used === 'number' && Number.isFinite(record.used) ? record.used : undefined;
553
+ const meta = record._meta && typeof record._meta === 'object' && !Array.isArray(record._meta)
554
+ ? record._meta
555
+ : {};
556
+ return {
557
+ type: 'usage_update',
558
+ inputTokens: typeof record.inputTokens === 'number'
559
+ ? record.inputTokens
560
+ : typeof meta.inputTokens === 'number' ? meta.inputTokens : undefined,
561
+ outputTokens: typeof record.outputTokens === 'number'
562
+ ? record.outputTokens
563
+ : typeof meta.outputTokens === 'number' ? meta.outputTokens : undefined,
564
+ totalTokens: typeof record.totalTokens === 'number'
565
+ ? record.totalTokens
566
+ : typeof meta.totalTokens === 'number' ? meta.totalTokens : used,
567
+ };
568
+ }
569
+ return undefined;
570
+ }
571
+ normalizeToolStatus(value) {
572
+ return value === 'pending' || value === 'in_progress' || value === 'completed' || value === 'failed' ? value : undefined;
573
+ }
574
+ normalizePlanEntries(value) {
575
+ if (!Array.isArray(value))
576
+ return [];
577
+ return value.slice(0, 100).flatMap((entry) => {
578
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry))
579
+ return [];
580
+ const record = entry;
581
+ if (typeof record.content !== 'string' || !record.content.trim())
582
+ return [];
583
+ return [{
584
+ content: redactAcpText(record.content.trim(), 1_000),
585
+ priority: record.priority === 'high' || record.priority === 'low' ? record.priority : 'medium',
586
+ status: record.status === 'in_progress' || record.status === 'completed' ? record.status : 'pending',
587
+ }];
588
+ });
589
+ }
590
+ normalizeToolContent(value) {
591
+ if (!Array.isArray(value))
592
+ return undefined;
593
+ const normalized = value.slice(0, 50).flatMap((entry) => {
594
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry))
595
+ return [];
596
+ const outer = entry;
597
+ const record = outer.type === 'content'
598
+ && outer.content
599
+ && typeof outer.content === 'object'
600
+ && !Array.isArray(outer.content)
601
+ ? outer.content
602
+ : outer;
603
+ if (record.type === 'text' && typeof record.text === 'string') {
604
+ return [{ type: 'text', text: redactAcpText(record.text, 32_000) }];
605
+ }
606
+ if (record.type === 'diff'
607
+ && typeof record.path === 'string'
608
+ && typeof record.oldText === 'string'
609
+ && typeof record.newText === 'string') {
610
+ return [{
611
+ type: 'diff',
612
+ path: redactAcpText(record.path, 2_000),
613
+ oldText: redactAcpText(record.oldText, 32_000),
614
+ newText: redactAcpText(record.newText, 32_000),
615
+ }];
616
+ }
617
+ if (record.type === 'terminal' && typeof record.terminalId === 'string') {
618
+ return [{
619
+ type: 'terminal',
620
+ terminalId: redactAcpText(record.terminalId, 500),
621
+ ...(typeof record.text === 'string' ? { text: redactAcpText(record.text, 32_000) } : {}),
622
+ }];
623
+ }
624
+ return [];
625
+ });
626
+ return normalized.length ? normalized : undefined;
627
+ }
628
+ normalizeToolLocations(value) {
629
+ if (!Array.isArray(value))
630
+ return undefined;
631
+ const normalized = value.slice(0, 100).flatMap((entry) => {
632
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry))
633
+ return [];
634
+ const record = entry;
635
+ if (typeof record.path !== 'string' || !record.path.trim())
636
+ return [];
637
+ return [{
638
+ path: redactAcpText(record.path, 2_000),
639
+ ...(typeof record.line === 'number' && Number.isFinite(record.line)
640
+ ? { line: Math.max(1, Math.trunc(record.line)) }
641
+ : {}),
642
+ ...(typeof record.column === 'number' && Number.isFinite(record.column)
643
+ ? { column: Math.max(1, Math.trunc(record.column)) }
644
+ : {}),
645
+ }];
646
+ });
647
+ return normalized.length ? normalized : undefined;
648
+ }
649
+ normalizeToolPayload(value) {
650
+ if (value === undefined)
651
+ return undefined;
652
+ try {
653
+ const serialized = JSON.stringify(value);
654
+ if (serialized === undefined)
655
+ return undefined;
656
+ const redacted = redactAcpText(serialized, 32_000);
657
+ if (redacted.endsWith('...[truncated]')) {
658
+ return { truncated: true, preview: redacted };
659
+ }
660
+ return JSON.parse(redacted);
661
+ }
662
+ catch {
663
+ return { invalid: true };
664
+ }
665
+ }
666
+ async waitForExitDiagnostics() {
667
+ for (let attempt = 0; attempt < 10; attempt += 1) {
668
+ if (this.runtime?.diagnostics().exitCode !== undefined)
669
+ return;
670
+ await new Promise((resolve) => setTimeout(resolve, 10));
671
+ }
672
+ }
673
+ }
674
+ //# sourceMappingURL=AcpProcessSupervisor.js.map