@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,444 @@
1
+ /**
2
+ * The session substrate — ADE spec §2.8, build-order step 0.
3
+ *
4
+ * > "The terminal belongs to us, not to the agent. We do not attach to an
5
+ * > agent's terminal; we *give* every session a terminal and own both ends of
6
+ * > it. That part is unconditional — every session has a PTY, and input
7
+ * > routing, attach and takeover work identically regardless of what is running
8
+ * > inside."
9
+ *
10
+ * §9 calls this "not a step so much as the floor the others stand on", and it is
11
+ * the floor §5.5's attach and takeover were found to be waiting on: §4.6's two
12
+ * process worlds — an agent spawned as a stdio JSON-RPC child with no terminal,
13
+ * and a PTY belonging to the user — meet here or nowhere.
14
+ *
15
+ * ## One session, TWO channels — measured, not assumed
16
+ *
17
+ * A PTY is **not** a byte-transparent pipe. Measured 2026-08-13 against real
18
+ * `node-pty` on Windows/ConPTY (`scripts/probe-pty-framing.mjs`): a
19
+ * `Content-Length` header survives, and the `\r\n\r\n` that separates it from
20
+ * the body is **re-rendered as a cursor-position escape**. A framed reader never
21
+ * finds the separator, so it never begins counting. `\n` is rewritten to `\r\n`
22
+ * as well.
23
+ *
24
+ * That is not a bug to harden around — a terminal's job is to render a screen,
25
+ * so it is free to express the same visual result as different bytes, which is
26
+ * exactly what breaks a byte-counted protocol.
27
+ *
28
+ * So a session owns a PTY **and**, when the agent speaks a protocol, a separate
29
+ * channel for framed messages. The two are distinct types here with no
30
+ * conversion between them, so "just send the JSON-RPC through the terminal"
31
+ * cannot be written by accident.
32
+ *
33
+ * ## What renders is a MODE, and the modes are exclusive
34
+ *
35
+ * §2.8: *"The two modes are not simultaneous for one process: a CLI in
36
+ * interactive TUI mode is not also serving ACP."* That is enforced at open time
37
+ * rather than documented: a `native-tui` session with a protocol channel is a
38
+ * contradiction, and an `acp` session without one has nothing to render.
39
+ */
40
+ import { agentMayWrite, deliveryFor, humanReleasesWriteLease, humanTakesWriteLease, openWriteLease, routeHumanInput, selectSessionRenderMode, } from '@xenosystem/agent-interface-core';
41
+ /**
42
+ * How much terminal output a session retains.
43
+ *
44
+ * Bounded because a session can run for hours and a build can print megabytes,
45
+ * and an unbounded buffer per session turns a long-lived host into a memory
46
+ * leak that only shows up on the busiest run. 256 KiB is roughly a few thousand
47
+ * lines — enough to see what an agent just did, which is what attach is for.
48
+ */
49
+ const MAX_SESSION_OUTPUT = 256 * 1024;
50
+ /**
51
+ * The neutral rendering: one compact line per message.
52
+ *
53
+ * Deliberately dull. A substrate that formatted an agent's stream prettily would
54
+ * be making product decisions on behalf of every surface, and a surface that
55
+ * wants better passes `renderProtocolMessage`. What it must NOT do is show
56
+ * nothing, which is what it did before.
57
+ */
58
+ function defaultProtocolRender(message) {
59
+ if (typeof message === 'string')
60
+ return `${message}\r\n`;
61
+ try {
62
+ return `${JSON.stringify(message)}\r\n`;
63
+ }
64
+ catch {
65
+ // Circular or otherwise unserialisable. Saying so beats saying nothing.
66
+ return '[unrenderable protocol message]\r\n';
67
+ }
68
+ }
69
+ /** Keeps the TAIL: the newest output is the output a viewer wants. */
70
+ function capOutput(value) {
71
+ return value.length <= MAX_SESSION_OUTPUT ? value : value.slice(value.length - MAX_SESSION_OUTPUT);
72
+ }
73
+ export class AgentSessionService {
74
+ #sessions = new Map();
75
+ #now;
76
+ /** Takeovers refused because another human held the lease. Kept so a surface
77
+ * can explain why a keystroke did nothing, rather than dropping it silently. */
78
+ #refusals = [];
79
+ #emit;
80
+ #record;
81
+ constructor(options = {}) {
82
+ this.#now = options.now ?? Date.now;
83
+ this.#emit = options.emit ?? (() => { });
84
+ this.#record = options.record ?? (() => { });
85
+ }
86
+ /** Where interventions become a durable transcript entry. */
87
+ setInterventionSink(record) {
88
+ this.#record = record;
89
+ }
90
+ /** Takeovers refused because someone else was typing. */
91
+ refusals() {
92
+ return [...this.#refusals];
93
+ }
94
+ /** Mirrors the coordination and observation services — see either for why a
95
+ * sink fixed at construction cannot be the host that owns the service. */
96
+ setEventSink(emit) {
97
+ this.#emit = emit;
98
+ }
99
+ /**
100
+ * Gives a run a session: a terminal always, a protocol channel when the mode
101
+ * needs one.
102
+ *
103
+ * Every refusal is NAMED. An unopenable session that reports success would
104
+ * hand a caller a terminal that renders nothing, which is the failure §7.1
105
+ * exists to prevent.
106
+ */
107
+ open(request) {
108
+ if (this.#sessions.has(request.sessionId)) {
109
+ return {
110
+ ok: false,
111
+ code: 'session_exists',
112
+ reason: 'a session with that id is already open',
113
+ };
114
+ }
115
+ const selection = selectSessionRenderMode(request.support, request.preference);
116
+ if (!selection.ok) {
117
+ return { ok: false, code: 'mode_unavailable', reason: selection.reason };
118
+ }
119
+ // §2.8's exclusivity, enforced rather than documented.
120
+ if (selection.mode === 'acp' && !request.protocol) {
121
+ return {
122
+ ok: false,
123
+ code: 'protocol_channel_required',
124
+ reason: 'an acp session renders the structured stream and has none to render',
125
+ };
126
+ }
127
+ if (selection.mode === 'native-tui' && request.protocol) {
128
+ return {
129
+ ok: false,
130
+ code: 'protocol_channel_forbidden',
131
+ reason: 'a CLI in interactive TUI mode is not also serving ACP; the two modes are not simultaneous for one process',
132
+ };
133
+ }
134
+ const record = {
135
+ sessionId: request.sessionId,
136
+ runId: request.runId,
137
+ mode: selection.mode,
138
+ switchable: selection.switchable,
139
+ hasProtocolChannel: Boolean(request.protocol),
140
+ openedAt: this.#now(),
141
+ viewers: [],
142
+ lease: openWriteLease(this.#now()),
143
+ };
144
+ const live = {
145
+ record,
146
+ pty: request.pty,
147
+ protocol: request.protocol,
148
+ support: request.support,
149
+ viewers: new Map(),
150
+ lease: record.lease,
151
+ output: '',
152
+ /**
153
+ * 🔴 Subscribed HERE, at open, not on first attach.
154
+ *
155
+ * A session outlives its viewers (see `detach`), and the whole point of a
156
+ * detached host is that a run keeps working with no window. If retention
157
+ * began at the first attach, the output produced while nobody was
158
+ * watching — which is precisely the output someone attaches in order to
159
+ * read — would be gone. Attaching would show an empty terminal for a
160
+ * session that had been busy for an hour.
161
+ */
162
+ unsubscribe: request.pty.onData((chunk) => {
163
+ live.output = capOutput(live.output + chunk);
164
+ }),
165
+ };
166
+ /**
167
+ * 🔴 The structured stream is RENDERED into the PTY.
168
+ *
169
+ * Without this the channel was stored and never read: `open` REQUIRED one
170
+ * for an `acp` session on the grounds that such a session "renders the
171
+ * structured stream", then subscribed to nothing. Every message the agent
172
+ * sent was dropped and the terminal stayed empty for the entire run — a
173
+ * pane indistinguishable, to the person looking at it, from a broken one.
174
+ *
175
+ * The channel was read only by `sendProtocol` and `close`, both OUTBOUND.
176
+ * `onMessage` — the half that carries what there is to show — had no
177
+ * subscriber anywhere in the repo.
178
+ */
179
+ if (request.protocol) {
180
+ const render = request.renderProtocolMessage ?? defaultProtocolRender;
181
+ const stopRendering = request.protocol.onMessage((message) => {
182
+ // Rendering must never take the session down. A message this renderer
183
+ // cannot handle is one line lost, not a dead terminal.
184
+ try {
185
+ const text = render(message);
186
+ /**
187
+ * 🔴 Appended to the session's own output, NOT written to the PTY.
188
+ *
189
+ * `SessionPty.write` is the INPUT direction — bytes toward the process
190
+ * — and this is the agent SPEAKING. The port has no "inject output"
191
+ * method because a real terminal's output arrives through `onData`
192
+ * from the process itself; there is no process here, so the rendered
193
+ * text IS the session's output and belongs on the same path
194
+ * retention already feeds.
195
+ *
196
+ * The first version called `pty.write(text)` and the rendered line
197
+ * never reached a snapshot, so a viewer attaching mid-run saw an
198
+ * empty terminal — the exact symptom this whole fix exists to remove.
199
+ */
200
+ if (text)
201
+ live.output = capOutput(live.output + text);
202
+ }
203
+ catch {
204
+ // Deliberately silent HERE and reported nowhere else, because there is
205
+ // nowhere honest to report it to: the caller is the agent's own
206
+ // stream, not a person. A malformed frame is the agent's problem.
207
+ }
208
+ });
209
+ const stopRetention = live.unsubscribe;
210
+ live.unsubscribe = () => {
211
+ stopRendering();
212
+ stopRetention();
213
+ };
214
+ }
215
+ this.#sessions.set(request.sessionId, live);
216
+ this.#emit({
217
+ type: 'session.opened',
218
+ sessionId: record.sessionId,
219
+ runId: record.runId,
220
+ mode: record.mode,
221
+ });
222
+ return { ok: true, session: { ...record, viewers: [], lease: { ...record.lease } } };
223
+ }
224
+ /**
225
+ * Adds a live view. §5.5: *"two surfaces can hold the same running session at
226
+ * once and both see it move"* — so this is plural by construction rather than
227
+ * a handoff, and it is NOT resume: joining a live session and replaying a
228
+ * stored one are different operations.
229
+ */
230
+ attach(sessionId, viewerId, onData) {
231
+ const session = this.#sessions.get(sessionId);
232
+ if (!session || session.viewers.has(viewerId))
233
+ return false;
234
+ session.viewers.set(viewerId, session.pty.onData(onData));
235
+ session.record.viewers = [...session.viewers.keys()];
236
+ this.#emit({
237
+ type: 'session.attached',
238
+ sessionId,
239
+ viewerId,
240
+ viewers: session.viewers.size,
241
+ });
242
+ return true;
243
+ }
244
+ detach(sessionId, viewerId) {
245
+ const session = this.#sessions.get(sessionId);
246
+ const unsubscribe = session?.viewers.get(viewerId);
247
+ if (!session || !unsubscribe)
248
+ return false;
249
+ unsubscribe();
250
+ session.viewers.delete(viewerId);
251
+ session.record.viewers = [...session.viewers.keys()];
252
+ this.#emit({
253
+ type: 'session.detached',
254
+ sessionId,
255
+ viewerId,
256
+ viewers: session.viewers.size,
257
+ });
258
+ // The session outlives its viewers. §3 of the coordination spec makes the
259
+ // same point about runs: a session no window is attached to is still live,
260
+ // because it lives in the host and not in a window.
261
+ return true;
262
+ }
263
+ /**
264
+ * Routes human input into a session.
265
+ *
266
+ * The disposition comes from `routeHumanInput` (§2.8), which has no `drop`
267
+ * case — typing never falls into a void. **Both dispositions write to the
268
+ * PTY**: steering is delivered by writing to the terminal we own, which the
269
+ * agent cannot distinguish from the user typing, and a queued instruction is
270
+ * still recorded as a human intervention.
271
+ */
272
+ /**
273
+ * Puts the human's keystrokes where the agent will actually see them.
274
+ *
275
+ * 🔴 ONE callee for both doors. `routeInput` and `takeOver` each wrote to
276
+ * the PTY unconditionally, and for an `acp` session that PTY has no process
277
+ * behind it — it is a render target for the structured stream. So the
278
+ * keystrokes went nowhere, which is precisely the void `InputRouting` has no
279
+ * value for. The type made dropping inexpressible and the delivery did it
280
+ * anyway.
281
+ *
282
+ * What this does NOT do is deliver an `acp` steer itself. That travels
283
+ * `turn.steer`, where acknowledgement, idempotency and the named refusal
284
+ * already live; a second path from inside the substrate would be the
285
+ * unacknowledged one §5.5 measured to be wrong. It reports the sink instead,
286
+ * so the caller knows whether delivery is still owed.
287
+ */
288
+ #deliver(session, data, routing) {
289
+ const delivery = deliveryFor(session.record.mode, routing);
290
+ // Nothing typed is nothing to deliver — and reporting `delivered: true` for
291
+ // an empty string would tell a caller the agent received something it never
292
+ // did. Takeover reaches here with no data at all: §5.5's first keystroke IS
293
+ // the takeover, so taking the lease without typing is an ordinary case.
294
+ if (!data)
295
+ return { ...delivery, delivered: false };
296
+ if (delivery.sink === 'pty')
297
+ session.pty.write(data);
298
+ return delivery;
299
+ }
300
+ routeInput(sessionId, viewerId, data, context) {
301
+ const session = this.#sessions.get(sessionId);
302
+ if (!session)
303
+ return { ok: false, code: 'no_such_session' };
304
+ /**
305
+ * 🔴 The lease governs THIS door too.
306
+ *
307
+ * `takeOver` already refuses a second human, on the grounds that
308
+ * interleaving two of them produces a command neither typed. This method
309
+ * writes to the same PTY, so leaving it ungated meant the rule held at one
310
+ * entrance and not the other — and the ungated one is the ordinary
311
+ * typing path, so it is the one a second surface would actually use.
312
+ *
313
+ * A free lease permits anyone: that is the normal case, one human at a
314
+ * terminal, and requiring a takeover to type would make every session
315
+ * start with a ceremony.
316
+ */
317
+ const holder = session.lease.holder;
318
+ if (holder.kind === 'human' && holder.viewerId !== viewerId) {
319
+ this.#refusals.push({ sessionId, viewerId, code: 'lease_held' });
320
+ return { ok: false, code: 'lease_held', holder: holder.viewerId };
321
+ }
322
+ const routing = routeHumanInput(context);
323
+ const delivery = this.#deliver(session, data, routing);
324
+ this.#emit({ type: 'session.input', sessionId, disposition: routing.disposition });
325
+ return { ok: true, routing, delivery };
326
+ }
327
+ /**
328
+ * Recent terminal output for a session — the READ half of attach.
329
+ *
330
+ * A SNAPSHOT, deliberately, not a stream. The host protocol is
331
+ * request/response and its event feed is a broadcast to every connected
332
+ * client; PTY bytes must not go on it, because output is per-viewer and can
333
+ * be large. So a surface polls this, exactly as `workspace.pty.snapshot`
334
+ * already works in this repo — the mechanism is not new here, only its
335
+ * application to sessions.
336
+ *
337
+ * ⚠️ Returns what is RETAINED, which is bounded. `truncated` says when older
338
+ * output has already been dropped, so a surface can say "earlier output is
339
+ * gone" rather than presenting a terminal that appears to start mid-sentence
340
+ * for no reason.
341
+ */
342
+ snapshot(sessionId) {
343
+ const session = this.#sessions.get(sessionId);
344
+ if (!session)
345
+ return undefined;
346
+ return { output: session.output, truncated: session.output.length >= MAX_SESSION_OUTPUT };
347
+ }
348
+ /**
349
+ * A human types into the agent's terminal. **This is the takeover** — §5.5
350
+ * has no request-and-wait step, because the case it exists for is an agent
351
+ * going wrong now.
352
+ *
353
+ * The input is written to the PTY whether or not this call TOOK the lease,
354
+ * because a human who already holds it is simply still typing. What changes
355
+ * on the first keystroke is the arbitration state and the record.
356
+ */
357
+ takeOver(sessionId, viewerId, data) {
358
+ const session = this.#sessions.get(sessionId);
359
+ if (!session)
360
+ return undefined;
361
+ const transition = humanTakesWriteLease(session.lease, viewerId, this.#now());
362
+ if (!transition.ok) {
363
+ // Refused: another human is typing. Their keystrokes are NOT written —
364
+ // interleaving two humans produces a command neither of them typed, which
365
+ // is the corruption this whole model exists to prevent.
366
+ this.#refusals.push({ sessionId, viewerId, code: transition.code });
367
+ return undefined;
368
+ }
369
+ session.lease = transition.state;
370
+ session.record.lease = transition.state;
371
+ // 🔴 The SAME callee as `routeInput`. This used to write to the PTY
372
+ // directly, which meant the mode rule held at one entrance and not the
373
+ // other — and takeover is the entrance used when an agent is going wrong
374
+ // NOW, so it is the worse one to get silently wrong.
375
+ const delivery = this.#deliver(session, data, { disposition: 'steer', recordedAs: 'human-intervention' });
376
+ if (transition.agentYielded) {
377
+ this.#emit({
378
+ type: 'session.takeover',
379
+ sessionId,
380
+ viewerId,
381
+ interventions: transition.state.interventions,
382
+ });
383
+ // The durable half. §5.5's gate is "see the human intervention in the
384
+ // timeline", and the live feed carries counts rather than the typed text
385
+ // — the same split coordination makes between its feed and its record.
386
+ this.#record({ sessionId, viewerId, kind: 'takeover', at: transition.state.since, data });
387
+ }
388
+ return { lease: transition.state, delivery };
389
+ }
390
+ /** The human hands the session back. Only the holder may. */
391
+ releaseTakeOver(sessionId, viewerId) {
392
+ const session = this.#sessions.get(sessionId);
393
+ if (!session)
394
+ return false;
395
+ const transition = humanReleasesWriteLease(session.lease, viewerId, this.#now());
396
+ if (!transition.ok)
397
+ return false;
398
+ session.lease = transition.state;
399
+ session.record.lease = transition.state;
400
+ this.#emit({ type: 'session.released', sessionId, viewerId });
401
+ this.#record({ sessionId, viewerId, kind: 'released', at: transition.state.since });
402
+ return true;
403
+ }
404
+ /**
405
+ * Whether the host may inject agent-side input right now.
406
+ *
407
+ * ⚠️ INPUT only. Agent OUTPUT is never gated: the agent is a running process
408
+ * we cannot silence, and its output during a takeover is exactly the evidence
409
+ * a reviewer needs to see what the human interrupted.
410
+ */
411
+ agentMayWrite(sessionId) {
412
+ const session = this.#sessions.get(sessionId);
413
+ return session ? agentMayWrite(session.lease) : false;
414
+ }
415
+ session(sessionId) {
416
+ const record = this.#sessions.get(sessionId)?.record;
417
+ return record ? { ...record, viewers: [...record.viewers], lease: { ...record.lease } } : undefined;
418
+ }
419
+ sessions() {
420
+ return [...this.#sessions.values()]
421
+ .map((session) => ({
422
+ ...session.record,
423
+ viewers: [...session.record.viewers],
424
+ lease: { ...session.record.lease },
425
+ }))
426
+ .sort((left, right) => left.sessionId.localeCompare(right.sessionId));
427
+ }
428
+ close(sessionId) {
429
+ const session = this.#sessions.get(sessionId);
430
+ if (!session)
431
+ return false;
432
+ for (const unsubscribe of session.viewers.values())
433
+ unsubscribe();
434
+ // The retention listener too, or a closed session keeps a subscription on a
435
+ // PTY nobody owns and its buffer is never collected.
436
+ session.unsubscribe();
437
+ session.protocol?.close();
438
+ session.pty.close();
439
+ this.#sessions.delete(sessionId);
440
+ this.#emit({ type: 'session.closed', sessionId });
441
+ return true;
442
+ }
443
+ }
444
+ //# sourceMappingURL=AgentSessionService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentSessionService.js","sourceRoot":"","sources":["../../src/session/AgentSessionService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,uBAAuB,GAMxB,MAAM,kCAAkC,CAAA;AAgKzC;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAA;AAErC;;;;;;;GAOG;AACH,SA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
+ /**
3
+ * A terminal with no process behind it.
4
+ *
5
+ * An `acp` session's PTY is a RENDER TARGET, not a terminal: what appears in it
6
+ * is our rendering of the agent's structured stream, and the agent itself is
7
+ * driven over the protocol. So there is nothing to spawn, nothing to attach,
8
+ * and no native module involved — which is why this lives in the host rather
9
+ * than in the Electron composition, and why a session can be opened for a run
10
+ * without a tty existing anywhere.
11
+ *
12
+ * 🔴 `write` THROWS, and that is deliberate.
13
+ *
14
+ * The obvious implementation is a silent no-op, and it would recreate the exact
15
+ * defect this file exists downstream of: keystrokes disappearing into a PTY
16
+ * nobody reads. `AgentSessionService` already guarantees this is unreachable —
17
+ * its `#deliver` writes to a PTY only in `native-tui` mode, and a `native-tui`
18
+ * session is never given one of these. So being called means a mode rule has
19
+ * broken, and the useful behaviour then is to fail loudly at the surface rather
20
+ * than lose what someone typed.
21
+ *
22
+ * `resize` is accepted and ignored, which is not the same thing: a render
23
+ * target genuinely has no dimensions to change, and refusing a resize would
24
+ * make an ordinary window drag throw.
25
+ */
26
+ export declare function createBufferedSessionPty(): SessionPty;
27
+ //# sourceMappingURL=bufferedSessionPty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferedSessionPty.d.ts","sourceRoot":"","sources":["../../src/session/bufferedSessionPty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,IAAI,UAAU,CAyBrD"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A terminal with no process behind it.
3
+ *
4
+ * An `acp` session's PTY is a RENDER TARGET, not a terminal: what appears in it
5
+ * is our rendering of the agent's structured stream, and the agent itself is
6
+ * driven over the protocol. So there is nothing to spawn, nothing to attach,
7
+ * and no native module involved — which is why this lives in the host rather
8
+ * than in the Electron composition, and why a session can be opened for a run
9
+ * without a tty existing anywhere.
10
+ *
11
+ * 🔴 `write` THROWS, and that is deliberate.
12
+ *
13
+ * The obvious implementation is a silent no-op, and it would recreate the exact
14
+ * defect this file exists downstream of: keystrokes disappearing into a PTY
15
+ * nobody reads. `AgentSessionService` already guarantees this is unreachable —
16
+ * its `#deliver` writes to a PTY only in `native-tui` mode, and a `native-tui`
17
+ * session is never given one of these. So being called means a mode rule has
18
+ * broken, and the useful behaviour then is to fail loudly at the surface rather
19
+ * than lose what someone typed.
20
+ *
21
+ * `resize` is accepted and ignored, which is not the same thing: a render
22
+ * target genuinely has no dimensions to change, and refusing a resize would
23
+ * make an ordinary window drag throw.
24
+ */
25
+ export function createBufferedSessionPty() {
26
+ const listeners = new Set();
27
+ let closed = false;
28
+ return {
29
+ write() {
30
+ throw new Error('This session renders a structured stream and has no process to write to. '
31
+ + 'Input for an acp session travels turn.steer; reaching here means a render-mode rule broke.');
32
+ },
33
+ resize() {
34
+ // No dimensions to change. Ignored rather than refused — a window drag
35
+ // must not throw.
36
+ },
37
+ onData(listener) {
38
+ if (closed)
39
+ return () => { };
40
+ listeners.add(listener);
41
+ return () => { listeners.delete(listener); };
42
+ },
43
+ close() {
44
+ closed = true;
45
+ listeners.clear();
46
+ },
47
+ };
48
+ }
49
+ //# sourceMappingURL=bufferedSessionPty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferedSessionPty.js","sourceRoot":"","sources":["../../src/session/bufferedSessionPty.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAA;IACpD,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,OAAO;QACL,KAAK;YACH,MAAM,IAAI,KAAK,CACb,2EAA2E;kBACvE,4FAA4F,CACjG,CAAA;QACH,CAAC;QACD,MAAM;YACJ,uEAAuE;YACvE,kBAAkB;QACpB,CAAC;QACD,MAAM,CAAC,QAAQ;YACb,IAAI,MAAM;gBAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;YAC3B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACvB,OAAO,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAC,CAAA;QAC7C,CAAC;QACD,KAAK;YACH,MAAM,GAAG,IAAI,CAAA;YACb,SAAS,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { AgentRuntimeProviderDescriptor } from '@xenosystem/agent-interface-contract';
2
+ import type { AgentRenderSupport } from '@xenosystem/agent-interface-core';
3
+ /**
4
+ * Whether the host can attach an agent's OWN interactive TUI to a PTY.
5
+ *
6
+ * 🔴 Always false, and that is a measurement rather than a placeholder.
7
+ *
8
+ * §2.8's `native-tui` mode runs the vendor's real interface — Claude Code's
9
+ * actual TUI, not a reproduction — and nothing in this repo spawns a vendor
10
+ * binary in interactive mode attached to a terminal. Every lane that exists
11
+ * today drives its agent headless: ACP over stdio, the SDK loop in-process,
12
+ * Cloud over HTTP. So there is no TUI to render, for any provider.
13
+ *
14
+ * Declaring it here rather than writing `false` inline is the point. When the
15
+ * PTY lane is built it replaces this function, and `renderSupportFor`'s tests
16
+ * already prove a `true` answer flows through — so the day it lands, the mode
17
+ * becomes available by construction instead of by someone remembering.
18
+ */
19
+ export declare function noNativeTuiLane(): boolean;
20
+ export interface RenderSupportOptions {
21
+ /**
22
+ * The registered turn adapters. Asked, not listed.
23
+ *
24
+ * 🔴 The alternative was a kind→support table, and it would have been wrong
25
+ * within a release. `cli-app-server` and `cli-remote` are declared provider
26
+ * kinds with NO adapter — a run on either cannot execute, so it emits no
27
+ * runtime events and there is nothing for a session to render. A table would
28
+ * have had to restate that, and would have kept saying it after someone built
29
+ * the adapter. Asking the adapters means the answer is derived from the same
30
+ * fact that decides whether the run happens at all.
31
+ */
32
+ adapters: readonly {
33
+ supports(provider: AgentRuntimeProviderDescriptor): boolean;
34
+ }[];
35
+ /** Injected so the PTY lane can turn the mode on without editing this file. */
36
+ nativeTuiLane?: (provider: AgentRuntimeProviderDescriptor) => boolean;
37
+ }
38
+ /**
39
+ * What a run on this provider can render into a terminal.
40
+ *
41
+ * The `acp` half is not "the provider speaks ACP" — it is "we can render this
42
+ * agent's structured stream", which is what §2.8's mode of that name means. The
43
+ * stream is the run's runtime events (see `createRuntimeEventSessionChannel`),
44
+ * and every lane that can execute produces them. So the question reduces to
45
+ * whether ANY adapter can run this provider, which is checkable rather than
46
+ * asserted.
47
+ *
48
+ * A provider no adapter supports gets `{ nativeTui: false, acp: false }`, and
49
+ * `selectSessionRenderMode` REFUSES it by name. That is the honest outcome: the
50
+ * alternative is a session that opens, renders nothing, and reports no error.
51
+ */
52
+ export declare function renderSupportFor(provider: AgentRuntimeProviderDescriptor, options: RenderSupportOptions): AgentRenderSupport;
53
+ //# sourceMappingURL=renderSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderSupport.d.ts","sourceRoot":"","sources":["../../src/session/renderSupport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAA;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAE1E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,SAAS;QAAE,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,GAAG,OAAO,CAAA;KAAE,EAAE,CAAA;IACpF,+EAA+E;IAC/E,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,8BAA8B,KAAK,OAAO,CAAA;CACtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,8BAA8B,EACxC,OAAO,EAAE,oBAAoB,GAC5B,kBAAkB,CAMpB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Whether the host can attach an agent's OWN interactive TUI to a PTY.
3
+ *
4
+ * 🔴 Always false, and that is a measurement rather than a placeholder.
5
+ *
6
+ * §2.8's `native-tui` mode runs the vendor's real interface — Claude Code's
7
+ * actual TUI, not a reproduction — and nothing in this repo spawns a vendor
8
+ * binary in interactive mode attached to a terminal. Every lane that exists
9
+ * today drives its agent headless: ACP over stdio, the SDK loop in-process,
10
+ * Cloud over HTTP. So there is no TUI to render, for any provider.
11
+ *
12
+ * Declaring it here rather than writing `false` inline is the point. When the
13
+ * PTY lane is built it replaces this function, and `renderSupportFor`'s tests
14
+ * already prove a `true` answer flows through — so the day it lands, the mode
15
+ * becomes available by construction instead of by someone remembering.
16
+ */
17
+ export function noNativeTuiLane() {
18
+ return false;
19
+ }
20
+ /**
21
+ * What a run on this provider can render into a terminal.
22
+ *
23
+ * The `acp` half is not "the provider speaks ACP" — it is "we can render this
24
+ * agent's structured stream", which is what §2.8's mode of that name means. The
25
+ * stream is the run's runtime events (see `createRuntimeEventSessionChannel`),
26
+ * and every lane that can execute produces them. So the question reduces to
27
+ * whether ANY adapter can run this provider, which is checkable rather than
28
+ * asserted.
29
+ *
30
+ * A provider no adapter supports gets `{ nativeTui: false, acp: false }`, and
31
+ * `selectSessionRenderMode` REFUSES it by name. That is the honest outcome: the
32
+ * alternative is a session that opens, renders nothing, and reports no error.
33
+ */
34
+ export function renderSupportFor(provider, options) {
35
+ const nativeTuiLane = options.nativeTuiLane ?? noNativeTuiLane;
36
+ return {
37
+ nativeTui: nativeTuiLane(provider),
38
+ acp: options.adapters.some((adapter) => adapter.supports(provider)),
39
+ };
40
+ }
41
+ //# sourceMappingURL=renderSupport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderSupport.js","sourceRoot":"","sources":["../../src/session/renderSupport.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,CAAA;AACd,CAAC;AAmBD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAwC,EACxC,OAA6B;IAE7B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,eAAe,CAAA;IAC9D,OAAO;QACL,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;QAClC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpE,CAAA;AACH,CAAC"}