@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,189 @@
1
+ /**
2
+ * `CommandExecutionPort` over a `xeno-use` sandbox — the CONFINING implementation.
3
+ *
4
+ * Reached through `RunExecutionEnvironment`, which is what a composition wires
5
+ * and what decides — in ONE lookup — both that this executor serves a run and
6
+ * that the run reports `sandboxed`. Nothing constructs this directly.
7
+ *
8
+ * ⚠️ What remains before a run is actually confined is the BINDING: no
9
+ * composition yet spawns a sandbox the agent RUNS in. `XenoUseRunObserver`
10
+ * spawns an OBSERVATION sandbox, and binding execution to that one is exactly
11
+ * the convenient wrong turn `isolationIsNotObservation.test.ts` exists to pin —
12
+ * a sandbox that is watched is not a sandbox that confines. Everything
13
+ * downstream of the binding is now live, so that step is a spawn plus a
14
+ * `bind({ sandbox })`, not a rewrite.
15
+ *
16
+ * This is the other half of the port `LocalCommandExecutor` exists beside, and
17
+ * the reason the port was built at all: adopting a sandbox becomes a composition
18
+ * change rather than a rewrite at each call site. Where the local executor
19
+ * starts a real process on the user's machine as the signed-in user, this one
20
+ * runs the command inside a container with `--network none`, `--read-only`,
21
+ * `--cap-drop ALL`, a non-root uid, and only the mounts it was given.
22
+ *
23
+ * ## 🔒 Out of process, always — a licensing boundary before a design preference
24
+ *
25
+ * `xeno-use` is AGPL-3.0 and this package is proprietary, so nothing here
26
+ * imports `@xeno-use/*` or links its N-API binding. The request and response
27
+ * shapes are written out by hand and reached over `/v1/use/*` — exactly what
28
+ * `RunObservationSource` and `XenoUseRunObserver` already do, for exactly the
29
+ * same reason. It looks like duplication and is the boundary.
30
+ *
31
+ * ## 🔴 It NEVER falls back to local execution
32
+ *
33
+ * The single most important property in this file, and the one most likely to
34
+ * be "fixed" in later. If the sandbox is unreachable, this returns a FAILED
35
+ * result — it does not quietly run the command on the host instead. A fallback
36
+ * would mean a run reporting itself contained while executing with the user's
37
+ * full privileges, which is strictly worse than having no sandbox at all:
38
+ * without one the report says `none` and the user knows where they stand.
39
+ *
40
+ * Same shape as the convenient wrong turn `isolationIsNotObservation.test.ts`
41
+ * pins one directory over. A sandbox that is watched is not a sandbox that
42
+ * confines; a sandbox that silently degrades to the host does not confine
43
+ * either, and lies about it.
44
+ *
45
+ * ## Why the executor is bound to ONE sandbox
46
+ *
47
+ * `CommandExecutionRequest` carries no run id, deliberately — a call site asks
48
+ * to run a command, not to route one. So the binding happens at construction:
49
+ * the composition makes an executor per run, against that run's sandbox. A
50
+ * resolver taking a run id would put routing in the hot path and make "which
51
+ * sandbox did this actually run in?" a question with a computed answer.
52
+ */
53
+ const DEFAULT_MAX_OUTPUT_BYTES = 200_000;
54
+ /**
55
+ * Maps a host path into container terms.
56
+ *
57
+ * Returns `undefined` when the path is not under the mount — which is not a
58
+ * security check. Confinement comes from the sandbox's filesystem namespace,
59
+ * not from a rule applied at the call: a process can `chdir` after it starts,
60
+ * so a path rule enforced on entry decides nothing. This is a REPRESENTABILITY
61
+ * question — a host directory outside the mount has no name inside the
62
+ * container, so the request cannot be expressed and must be refused rather than
63
+ * silently rewritten to the mount root.
64
+ *
65
+ * Case-insensitive on the host segment because Windows paths are, and the run
66
+ * directory reaching us from a UI and from a config may differ only in case.
67
+ * The CONTAINER half preserves case exactly — Linux paths are case-sensitive
68
+ * and folding them would produce a path that does not exist.
69
+ */
70
+ export function toContainerPath(mount, hostPath) {
71
+ const normalize = (value) => value.replaceAll('\\', '/').replace(/\/+$/, '');
72
+ const root = normalize(mount.hostDirectory);
73
+ const target = normalize(hostPath);
74
+ const container = normalize(mount.containerDirectory);
75
+ if (target.toLowerCase() === root.toLowerCase())
76
+ return container;
77
+ const prefix = `${root.toLowerCase()}/`;
78
+ if (!target.toLowerCase().startsWith(prefix))
79
+ return undefined;
80
+ // Slice from the ORIGINAL, not the lowercased copy: the remainder names real
81
+ // files inside a Linux container, where `Source_File.ts` and `source_file.ts`
82
+ // are different files.
83
+ return `${container}/${target.slice(root.length + 1)}`;
84
+ }
85
+ export class SandboxCommandExecutor {
86
+ #baseUrl;
87
+ #token;
88
+ #sandboxId;
89
+ #mount;
90
+ #fetch;
91
+ constructor(options) {
92
+ this.#baseUrl = options.baseUrl.replace(/\/+$/, '');
93
+ this.#token = options.token;
94
+ this.#sandboxId = options.sandboxId;
95
+ this.#mount = options.mount;
96
+ this.#fetch = options.fetch ?? globalThis.fetch;
97
+ }
98
+ async execute(request) {
99
+ const cwd = toContainerPath(this.#mount, request.cwd);
100
+ if (cwd === undefined) {
101
+ // Refused, not rewritten. Running in the mount root "because the real cwd
102
+ // was outside it" would execute a command somewhere the caller never
103
+ // asked for, and it would look like it worked.
104
+ return this.#failed(`The working directory ${request.cwd} is not inside the sandbox mount ${this.#mount.hostDirectory}.`);
105
+ }
106
+ let response;
107
+ try {
108
+ response = await this.#fetch(`${this.#baseUrl}/v1/use/sandbox/${encodeURIComponent(this.#sandboxId)}/exec`, {
109
+ method: 'POST',
110
+ headers: {
111
+ authorization: `Bearer ${this.#token}`,
112
+ 'content-type': 'application/json',
113
+ },
114
+ body: JSON.stringify({
115
+ // A LIST, unchanged. The port and the substrate agree on this, so
116
+ // there is nothing to translate — which is the point of both.
117
+ argv: [...request.argv],
118
+ cwd,
119
+ timeout_ms: request.timeoutMs,
120
+ }),
121
+ });
122
+ }
123
+ catch (error) {
124
+ // 🔴 The sandbox is unreachable. This is where a fallback to local
125
+ // execution would go, and where it must not.
126
+ return this.#failed(`The sandbox could not be reached: ${error instanceof Error ? error.message : String(error)}`);
127
+ }
128
+ if (!response.ok) {
129
+ return this.#failed(`The sandbox refused to run the command (HTTP ${response.status}).`);
130
+ }
131
+ let wire;
132
+ try {
133
+ const body = (await response.json());
134
+ if (!body.data)
135
+ throw new Error('the response carried no result');
136
+ wire = body.data;
137
+ }
138
+ catch (error) {
139
+ return this.#failed(`The sandbox returned an unreadable result: ${error instanceof Error ? error.message : String(error)}`);
140
+ }
141
+ const outputLimit = request.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
142
+ const { stdout, stderr, truncated } = trim(wire.stdout, wire.stderr, outputLimit);
143
+ return {
144
+ stdout,
145
+ stderr,
146
+ // 🔴 Passed through INCLUDING null, exactly as the local executor does.
147
+ // The substrate already refuses to invent a code for a killed process;
148
+ // coercing here would throw that honesty away at the last hop.
149
+ exitCode: wire.exit_code,
150
+ timedOut: wire.timed_out,
151
+ truncated,
152
+ ...(wire.timed_out
153
+ ? { error: `Command timed out after ${request.timeoutMs}ms.` }
154
+ : {}),
155
+ };
156
+ }
157
+ /**
158
+ * A result for a command that could not be run.
159
+ *
160
+ * `exitCode: null` because there is no exit code — the same meaning it
161
+ * carries everywhere on this type — and `error` is what distinguishes this
162
+ * from a process that was killed. `commandSucceeded` answers false on both
163
+ * counts, so no caller can read an unreachable sandbox as a passing command.
164
+ */
165
+ #failed(reason) {
166
+ return {
167
+ stdout: '',
168
+ stderr: '',
169
+ exitCode: null,
170
+ timedOut: false,
171
+ truncated: false,
172
+ error: reason,
173
+ };
174
+ }
175
+ }
176
+ /** Bounds the output the same way the local executor does, so a caller cannot
177
+ * tell the two apart by how much it gets back. */
178
+ function trim(rawStdout, rawStderr, limit) {
179
+ if (rawStdout.length + rawStderr.length <= limit) {
180
+ return { stdout: rawStdout, stderr: rawStderr, truncated: false };
181
+ }
182
+ const keep = Math.max(4_000, Math.floor(limit / 2));
183
+ return {
184
+ stdout: rawStdout.slice(-keep),
185
+ stderr: rawStderr.slice(-keep),
186
+ truncated: true,
187
+ };
188
+ }
189
+ //# sourceMappingURL=SandboxCommandExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SandboxCommandExecutor.js","sourceRoot":"","sources":["../../src/isolation/SandboxCommandExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAwCH,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC7B,KAA0B,EAC1B,QAAgB;IAEhB,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC5F,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAC3C,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAErD,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE;QAAE,OAAO,SAAS,CAAA;IACjE,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,CAAA;IAC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C;QAC9B,SAAS,EAAE,IAAI;KAChB,CAAA;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Workspace knowledge — ADE §5.8, the host half.
3
+ *
4
+ * `core/workspaceKnowledge` owns the rules; this owns the store. Facts are
5
+ * per-workspace and DURABLE by intent: §5.8's whole point is that a session
6
+ * ending does not undo what the workspace learned.
7
+ *
8
+ * ## 🔴 Recording is idempotent on (workspace, subject, fact)
9
+ *
10
+ * An agent that re-establishes a fact it already knows — because it re-read the
11
+ * same file, or because a retry replayed the turn — must not create a second
12
+ * copy. Without this, "we use pnpm" accumulates once per run and eventually
13
+ * fills the whole prompt budget with the same sentence, pushing out everything
14
+ * else. The identical fact re-recorded returns the ORIGINAL entry, so its
15
+ * provenance still names the run that first established it.
16
+ *
17
+ * ## Persistence is injected
18
+ *
19
+ * The store is a port. In-memory is the honest default for a host with nothing
20
+ * configured — the alternative, silently writing somewhere, is how knowledge
21
+ * ends up in a directory nobody knows to back up.
22
+ */
23
+ import { type KnowledgeSelectionOptions, type WorkspaceKnowledgeEntry } from '@xenosystem/agent-interface-core';
24
+ /** Where facts live between sessions. */
25
+ export interface WorkspaceKnowledgeStore {
26
+ load(workspaceId: string): Promise<WorkspaceKnowledgeEntry[]> | WorkspaceKnowledgeEntry[];
27
+ save(workspaceId: string, entries: WorkspaceKnowledgeEntry[]): Promise<void> | void;
28
+ }
29
+ /** The default: remembers for this process and says nothing about durability. */
30
+ export declare class InMemoryWorkspaceKnowledgeStore implements WorkspaceKnowledgeStore {
31
+ #private;
32
+ load(workspaceId: string): WorkspaceKnowledgeEntry[];
33
+ save(workspaceId: string, entries: WorkspaceKnowledgeEntry[]): void;
34
+ }
35
+ export interface RecordKnowledgeInput {
36
+ workspaceId: string;
37
+ subject: string;
38
+ fact: string;
39
+ pinned?: boolean;
40
+ runId: string;
41
+ providerId?: string;
42
+ }
43
+ export interface WorkspaceKnowledgeServiceOptions {
44
+ store?: WorkspaceKnowledgeStore;
45
+ now?: () => number;
46
+ /** Injected so ids are deterministic in tests rather than random. */
47
+ nextId?: () => string;
48
+ /** True when the configured store survives a restart. Reported, never assumed:
49
+ * a surface promising durable memory over an in-memory store would be lying. */
50
+ durable?: boolean;
51
+ }
52
+ export declare class WorkspaceKnowledgeService {
53
+ #private;
54
+ constructor(options?: WorkspaceKnowledgeServiceOptions);
55
+ get durable(): boolean;
56
+ list(workspaceId: string): Promise<WorkspaceKnowledgeEntry[]>;
57
+ /**
58
+ * Establishes a fact.
59
+ *
60
+ * Returns the entry, which may be one that already existed — see the header:
61
+ * the same fact recorded twice keeps the FIRST provenance, because the run
62
+ * that discovered it is the interesting one.
63
+ */
64
+ record(input: RecordKnowledgeInput): Promise<WorkspaceKnowledgeEntry>;
65
+ /** Removes a fact outright. Superseding is what happens naturally; this is for
66
+ * a fact that was simply WRONG, which no later truth supersedes. */
67
+ forget(workspaceId: string, entryId: string): Promise<boolean>;
68
+ /** What should go into a prompt for this workspace. */
69
+ context(workspaceId: string, options?: KnowledgeSelectionOptions): Promise<import("@xenosystem/agent-interface-core").KnowledgeSelection>;
70
+ }
71
+ //# sourceMappingURL=WorkspaceKnowledgeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceKnowledgeService.d.ts","sourceRoot":"","sources":["../../src/knowledge/WorkspaceKnowledgeService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AAEzC,yCAAyC;AACzC,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,GAAG,uBAAuB,EAAE,CAAA;IACzF,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACpF;AAED,iFAAiF;AACjF,qBAAa,+BAAgC,YAAW,uBAAuB;;IAG7E,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,uBAAuB,EAAE;IAIpD,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,IAAI;CAGpE;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gCAAgC;IAC/C,KAAK,CAAC,EAAE,uBAAuB,CAAA;IAC/B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,MAAM,CAAA;IACrB;qFACiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,qBAAa,yBAAyB;;gBAOxB,OAAO,GAAE,gCAAqC;IAS1D,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAInE;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA+B3E;yEACqE;IAC/D,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQpE,uDAAuD;IACjD,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B;CAG3E"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Workspace knowledge — ADE §5.8, the host half.
3
+ *
4
+ * `core/workspaceKnowledge` owns the rules; this owns the store. Facts are
5
+ * per-workspace and DURABLE by intent: §5.8's whole point is that a session
6
+ * ending does not undo what the workspace learned.
7
+ *
8
+ * ## 🔴 Recording is idempotent on (workspace, subject, fact)
9
+ *
10
+ * An agent that re-establishes a fact it already knows — because it re-read the
11
+ * same file, or because a retry replayed the turn — must not create a second
12
+ * copy. Without this, "we use pnpm" accumulates once per run and eventually
13
+ * fills the whole prompt budget with the same sentence, pushing out everything
14
+ * else. The identical fact re-recorded returns the ORIGINAL entry, so its
15
+ * provenance still names the run that first established it.
16
+ *
17
+ * ## Persistence is injected
18
+ *
19
+ * The store is a port. In-memory is the honest default for a host with nothing
20
+ * configured — the alternative, silently writing somewhere, is how knowledge
21
+ * ends up in a directory nobody knows to back up.
22
+ */
23
+ import { selectWorkspaceKnowledge, } from '@xenosystem/agent-interface-core';
24
+ /** The default: remembers for this process and says nothing about durability. */
25
+ export class InMemoryWorkspaceKnowledgeStore {
26
+ #byWorkspace = new Map();
27
+ load(workspaceId) {
28
+ return [...(this.#byWorkspace.get(workspaceId) ?? [])];
29
+ }
30
+ save(workspaceId, entries) {
31
+ this.#byWorkspace.set(workspaceId, [...entries]);
32
+ }
33
+ }
34
+ export class WorkspaceKnowledgeService {
35
+ #store;
36
+ #now;
37
+ #nextId;
38
+ #durable;
39
+ #sequence = 0;
40
+ constructor(options = {}) {
41
+ this.#store = options.store ?? new InMemoryWorkspaceKnowledgeStore();
42
+ this.#now = options.now ?? (() => Date.now());
43
+ this.#nextId = options.nextId ?? (() => `k${++this.#sequence}`);
44
+ // Defaults to FALSE with the default store, because the default store is
45
+ // not durable. Claiming otherwise is the failure this flag exists to stop.
46
+ this.#durable = options.durable ?? Boolean(options.store);
47
+ }
48
+ get durable() {
49
+ return this.#durable;
50
+ }
51
+ async list(workspaceId) {
52
+ return [...(await this.#store.load(workspaceId))];
53
+ }
54
+ /**
55
+ * Establishes a fact.
56
+ *
57
+ * Returns the entry, which may be one that already existed — see the header:
58
+ * the same fact recorded twice keeps the FIRST provenance, because the run
59
+ * that discovered it is the interesting one.
60
+ */
61
+ async record(input) {
62
+ const entries = await this.list(input.workspaceId);
63
+ const existing = entries.find((entry) => entry.subject === input.subject && entry.fact === input.fact);
64
+ if (existing) {
65
+ // Pinning an existing fact is a real update rather than a duplicate: it
66
+ // changes how the fact behaves under budget without changing the fact.
67
+ if (input.pinned && !existing.pinned) {
68
+ existing.pinned = true;
69
+ await this.#store.save(input.workspaceId, entries);
70
+ }
71
+ return existing;
72
+ }
73
+ const entry = {
74
+ id: this.#nextId(),
75
+ workspaceId: input.workspaceId,
76
+ subject: input.subject,
77
+ fact: input.fact,
78
+ ...(input.pinned ? { pinned: true } : {}),
79
+ provenance: {
80
+ runId: input.runId,
81
+ ...(input.providerId ? { providerId: input.providerId } : {}),
82
+ at: this.#now(),
83
+ },
84
+ };
85
+ await this.#store.save(input.workspaceId, [...entries, entry]);
86
+ return entry;
87
+ }
88
+ /** Removes a fact outright. Superseding is what happens naturally; this is for
89
+ * a fact that was simply WRONG, which no later truth supersedes. */
90
+ async forget(workspaceId, entryId) {
91
+ const entries = await this.list(workspaceId);
92
+ const remaining = entries.filter((entry) => entry.id !== entryId);
93
+ if (remaining.length === entries.length)
94
+ return false;
95
+ await this.#store.save(workspaceId, remaining);
96
+ return true;
97
+ }
98
+ /** What should go into a prompt for this workspace. */
99
+ async context(workspaceId, options = {}) {
100
+ return selectWorkspaceKnowledge(await this.list(workspaceId), options);
101
+ }
102
+ }
103
+ //# sourceMappingURL=WorkspaceKnowledgeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceKnowledgeService.js","sourceRoot":"","sources":["../../src/knowledge/WorkspaceKnowledgeService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,wBAAwB,GAGzB,MAAM,kCAAkC,CAAA;AAQzC,iFAAiF;AACjF,MAAM,OAAO,+BAA+B;IACjC,YAAY,GAAG,IAAI,GAAG,EAAqC,CAAA;IAEpE,IAAI,CAAC,WAAmB;QACtB,OAAO,CAAC,GAAG,CAAC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QAC/C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,CAAA;QACjE,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QACrD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QAC9C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,UAAqC,EAAE;QACxE,OAAO,wBAAwB,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAA;IACxE,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import { type AgentHostTransport } from '@xenosystem/agent-interface-contract';
2
+ import { LocalAgentHostAuthoritySession } from '@xenosystem/agent-interface-client/local';
3
+ /**
4
+ * Becoming the per-user Agent host authority — the half a surface must not have.
5
+ *
6
+ * Attaching moved to `@xenosystem/agent-interface-client` (ADE §2.7). Acquiring the
7
+ * lease and serving the host stays here, in the private package, so a thin client cannot take
8
+ * ownership: the code to do it is in a package it does not depend on.
9
+ */
10
+ export interface StartLocalAgentHostAuthorityOptions {
11
+ rootDirectory: string;
12
+ instanceId: string;
13
+ createHostTransport: () => AgentHostTransport | Promise<AgentHostTransport>;
14
+ protocolVersion?: number;
15
+ endpointScope?: string;
16
+ staleAfterMs?: number;
17
+ heartbeatIntervalMs?: number;
18
+ connectTimeoutMs?: number;
19
+ requestTimeoutMs?: number;
20
+ onAuthorityLost?: (error: Error) => void;
21
+ }
22
+ export declare function startLocalAgentHostAuthority(options: StartLocalAgentHostAuthorityOptions): Promise<LocalAgentHostAuthoritySession>;
23
+ export { attachToLocalAgentHost, LocalAgentHostAuthoritySession, type AttachToLocalAgentHostOptions, type AttachLocalAgentHostResult, type AttachLocalAgentHostRefusal, type LocalAgentHostAuthorityRole, } from '@xenosystem/agent-interface-client/local';
24
+ //# sourceMappingURL=localHostAuthority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localHostAuthority.d.ts","sourceRoot":"","sources":["../src/localHostAuthority.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,8BAA8B,EAK/B,MAAM,0CAA0C,CAAA;AAIjD;;;;;;GAMG;AAEH,MAAM,WAAW,mCAAmC;IAClD,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACzC;AACD,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,8BAA8B,CAAC,CAkFzC;AAGD,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,0CAA0C,CAAA"}
@@ -0,0 +1,87 @@
1
+ import { XENO_AGENT_HOST_PROTOCOL_VERSION, } from '@xenosystem/agent-interface-contract';
2
+ import { LocalAgentHostAuthoritySession, LocalAgentHostRpcClientTransport, connectBeforeDeadline, positiveInteger, readLocalAgentHostLeaseConnection, } from '@xenosystem/agent-interface-client/local';
3
+ import { acquireLocalAgentHostLease } from './localHostLease.js';
4
+ import { LocalAgentHostRpcServer, resolveLocalAgentHostEndpoint } from './localRpcTransport.js';
5
+ export async function startLocalAgentHostAuthority(options) {
6
+ const protocolVersion = positiveInteger(options.protocolVersion) || XENO_AGENT_HOST_PROTOCOL_VERSION;
7
+ const staleAfterMs = positiveInteger(options.staleAfterMs) || 15_000;
8
+ const heartbeatIntervalMs = positiveInteger(options.heartbeatIntervalMs)
9
+ || Math.max(1_000, Math.floor(staleAfterMs / 3));
10
+ const connectTimeoutMs = positiveInteger(options.connectTimeoutMs) || 5_000;
11
+ const requestTimeoutMs = positiveInteger(options.requestTimeoutMs) || 30_000;
12
+ const endpoint = resolveLocalAgentHostEndpoint(options.rootDirectory, options.endpointScope || 'default');
13
+ const acquisition = await acquireLocalAgentHostLease({
14
+ rootDirectory: options.rootDirectory,
15
+ instanceId: options.instanceId,
16
+ endpoint,
17
+ protocolVersion,
18
+ staleAfterMs,
19
+ });
20
+ if (acquisition.acquired) {
21
+ let server;
22
+ let transport;
23
+ try {
24
+ const hostTransport = await options.createHostTransport();
25
+ server = new LocalAgentHostRpcServer({
26
+ transport: hostTransport,
27
+ endpoint,
28
+ transportToken: acquisition.lease.transportToken,
29
+ protocolVersion,
30
+ removeStaleEndpoint: true,
31
+ });
32
+ await server.start();
33
+ transport = new LocalAgentHostRpcClientTransport({
34
+ endpoint,
35
+ transportToken: acquisition.lease.transportToken,
36
+ protocolVersion,
37
+ requestTimeoutMs,
38
+ });
39
+ await connectBeforeDeadline(transport, connectTimeoutMs);
40
+ return new LocalAgentHostAuthoritySession({
41
+ role: 'owner',
42
+ descriptor: acquisition.lease.descriptor,
43
+ transport,
44
+ server,
45
+ lease: acquisition.lease,
46
+ heartbeatIntervalMs,
47
+ ...(options.onAuthorityLost ? { onAuthorityLost: options.onAuthorityLost } : {}),
48
+ });
49
+ }
50
+ catch (error) {
51
+ transport?.close();
52
+ await server?.close().catch(() => undefined);
53
+ await acquisition.lease.release().catch(() => undefined);
54
+ throw error;
55
+ }
56
+ }
57
+ if (acquisition.owner.protocolVersion !== protocolVersion) {
58
+ throw new Error(`Existing local Agent host protocol ${acquisition.owner.protocolVersion} is incompatible with requested ${protocolVersion}.`);
59
+ }
60
+ const connection = await readLocalAgentHostLeaseConnection(options.rootDirectory);
61
+ if (!connection
62
+ || connection.descriptor.instanceId !== acquisition.owner.instanceId
63
+ || connection.descriptor.endpoint !== acquisition.owner.endpoint) {
64
+ throw new Error('Local Agent host authority changed during connection discovery; retry startup.');
65
+ }
66
+ const transport = new LocalAgentHostRpcClientTransport({
67
+ endpoint: connection.descriptor.endpoint,
68
+ transportToken: connection.transportToken,
69
+ protocolVersion,
70
+ requestTimeoutMs,
71
+ });
72
+ try {
73
+ await connectBeforeDeadline(transport, connectTimeoutMs);
74
+ }
75
+ catch (error) {
76
+ transport.close();
77
+ throw error;
78
+ }
79
+ return new LocalAgentHostAuthoritySession({
80
+ role: 'attached-client',
81
+ descriptor: connection.descriptor,
82
+ transport,
83
+ });
84
+ }
85
+ // Re-exported so existing importers of this module are unaffected by the extraction.
86
+ export { attachToLocalAgentHost, LocalAgentHostAuthoritySession, } from '@xenosystem/agent-interface-client/local';
87
+ //# sourceMappingURL=localHostAuthority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localHostAuthority.js","sourceRoot":"","sources":["../src/localHostAuthority.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,GAEjC,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,qBAAqB,EACrB,eAAe,EACf,iCAAiC,GAClC,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAA;AAsB/F,MAAM,CAAC,KAAK,U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QAAQ,EAChE,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;IACnG,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,gCAAgC,CAAC;QACrD,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,QAAQ;QACxC,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,eAAe;QACf,gBAAgB;KACjB,CAAC,CAAA;IACF,IAAI,CAAC;QACH,MAAM,qBAAqB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,KAAK,EAAE,CAAA;QACjB,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,IAAI,8BAA8B,CAAC;QACxC,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,SAAS;KACV,CAAC,CAAA;AACJ,CAAC;AAED,qFAAqF;AACrF,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAK/B,MAAM,0CAA0C,CAAA"}
@@ -0,0 +1,51 @@
1
+ import { type LocalAgentHostLeaseDescriptor, type LocalAgentHostLeaseRecord } from '@xenosystem/agent-interface-client/local';
2
+ /**
3
+ * Lease ACQUISITION — the half a surface must not have.
4
+ *
5
+ * Reading a lease moved to the client package (ADE §2.7); taking one stays here. The separation
6
+ * is structural rather than documented: a client cannot acquire because the code to acquire is
7
+ * in a package it does not depend on.
8
+ */
9
+ export interface AcquireLocalAgentHostLeaseOptions {
10
+ rootDirectory: string;
11
+ instanceId: string;
12
+ endpoint: string;
13
+ protocolVersion: number;
14
+ pid?: number;
15
+ staleAfterMs?: number;
16
+ now?: () => number;
17
+ isProcessAlive?: (pid: number) => boolean;
18
+ /**
19
+ * Does anything accept a connection on the owner's endpoint? Injectable so both halves of
20
+ * the ambiguous case are testable: a crashed host whose pid was recycled (nothing listening
21
+ * -> take over) versus a HUNG host that still holds its listener (the OS backlog answers
22
+ * even though the process is wedged -> stand down, because it still owns the durable state).
23
+ */
24
+ probeEndpoint?: (endpoint: string, timeoutMs: number) => Promise<boolean>;
25
+ }
26
+ export type AcquireLocalAgentHostLeaseResult = {
27
+ acquired: true;
28
+ lease: LocalAgentHostLease;
29
+ } | {
30
+ acquired: false;
31
+ owner: LocalAgentHostLeaseDescriptor;
32
+ };
33
+ /**
34
+ * Exclusive, per-user authority lease. The lock record doubles as local
35
+ * transport discovery; its bearer token is returned only to the lease owner.
36
+ */
37
+ export declare class LocalAgentHostLease {
38
+ private readonly path;
39
+ private readonly record;
40
+ private readonly now;
41
+ private released;
42
+ constructor(path: string, record: LocalAgentHostLeaseRecord, now: () => number);
43
+ get descriptor(): LocalAgentHostLeaseDescriptor;
44
+ get transportToken(): string;
45
+ heartbeat(): Promise<LocalAgentHostLeaseDescriptor>;
46
+ release(): Promise<boolean>;
47
+ private assertActive;
48
+ }
49
+ export declare function acquireLocalAgentHostLease(options: AcquireLocalAgentHostLeaseOptions): Promise<AcquireLocalAgentHostLeaseResult>;
50
+ export { DEFAULT_LEASE_STALE_AFTER_MS, isLeaseOwnerGone, inspectLocalAgentHostLease, readLocalAgentHostLeaseConnection, type LocalAgentHostLeaseDescriptor, type LocalAgentHostLeaseConnectionInfo, } from '@xenosystem/agent-interface-client/local';
51
+ //# sourceMappingURL=localHostLease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localHostLease.d.ts","sourceRoot":"","sources":["../src/localHostLease.ts"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC/B,MAAM,0CAA0C,CAAA;AAEjD;;;;;;GAMG;AAEH,MAAM,WAAW,iCAAiC;IAChD,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MA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