@agimon-ai/po-web-dashboard 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (366) hide show
  1. package/LICENSE +149 -29
  2. package/dist/core.cjs +13 -0
  3. package/dist/core.d.mts +8 -7
  4. package/dist/core.mjs +7 -6
  5. package/dist/index.cjs +17 -1
  6. package/dist/index.d.mts +12 -12
  7. package/dist/index.mjs +10 -10
  8. package/dist/types/hub.cjs +9 -100
  9. package/dist/types/hub.cjs.map +1 -1
  10. package/dist/types/hub.d.mts +12 -110
  11. package/dist/types/hub.d.mts.map +1 -1
  12. package/dist/types/hub.mjs +9 -79
  13. package/dist/types/hub.mjs.map +1 -1
  14. package/dist/types/notification.cjs +4 -4
  15. package/dist/types/notification.cjs.map +1 -1
  16. package/dist/types/notification.d.mts +5 -5
  17. package/dist/types/notification.d.mts.map +1 -1
  18. package/dist/types/notification.mjs +5 -5
  19. package/dist/types/notification.mjs.map +1 -1
  20. package/dist/types/settings.cjs.map +1 -1
  21. package/dist/types/settings.d.mts +1 -1
  22. package/dist/types/settings.mjs.map +1 -1
  23. package/dist/types.cjs +2 -23
  24. package/dist/types.d.mts +3 -3
  25. package/dist/types.mjs +3 -3
  26. package/dist/views.cjs +1 -0
  27. package/dist/views.d.mts +2 -2
  28. package/dist/views.mjs +2 -2
  29. package/dist/web/components/SessionMcp.cjs +17 -17
  30. package/dist/web/components/SessionMcp.cjs.map +1 -1
  31. package/dist/web/components/SessionMcp.mjs +17 -17
  32. package/dist/web/components/SessionMcp.mjs.map +1 -1
  33. package/dist/web/components/Story.fixture.cjs +4 -3
  34. package/dist/web/components/Story.fixture.cjs.map +1 -1
  35. package/dist/web/components/Story.fixture.d.mts.map +1 -1
  36. package/dist/web/components/Story.fixture.mjs +4 -3
  37. package/dist/web/components/Story.fixture.mjs.map +1 -1
  38. package/dist/web/components/Template.fixture.cjs +1 -1
  39. package/dist/web/components/Template.fixture.cjs.map +1 -1
  40. package/dist/web/components/Template.fixture.mjs +1 -1
  41. package/dist/web/components/Template.fixture.mjs.map +1 -1
  42. package/dist/web/components/ToolRendererBoundary.d.mts +1 -0
  43. package/dist/web/features/activity/ActivityDock.cjs +68 -47
  44. package/dist/web/features/activity/ActivityDock.cjs.map +1 -1
  45. package/dist/web/features/activity/ActivityDock.d.mts +2 -1
  46. package/dist/web/features/activity/ActivityDock.d.mts.map +1 -1
  47. package/dist/web/features/activity/ActivityDock.mjs +70 -49
  48. package/dist/web/features/activity/ActivityDock.mjs.map +1 -1
  49. package/dist/web/features/activity/ContextItemDialog.cjs +17 -17
  50. package/dist/web/features/activity/ContextItemDialog.cjs.map +1 -1
  51. package/dist/web/features/activity/ContextItemDialog.d.mts +1 -0
  52. package/dist/web/features/activity/ContextItemDialog.mjs +17 -17
  53. package/dist/web/features/activity/ContextItemDialog.mjs.map +1 -1
  54. package/dist/web/features/activity/ContextPanel.cjs +184 -148
  55. package/dist/web/features/activity/ContextPanel.cjs.map +1 -1
  56. package/dist/web/features/activity/ContextPanel.d.mts +23 -0
  57. package/dist/web/features/activity/ContextPanel.d.mts.map +1 -1
  58. package/dist/web/features/activity/ContextPanel.mjs +186 -151
  59. package/dist/web/features/activity/ContextPanel.mjs.map +1 -1
  60. package/dist/web/features/activity/DockTabs.cjs +1 -1
  61. package/dist/web/features/activity/DockTabs.cjs.map +1 -1
  62. package/dist/web/features/activity/DockTabs.mjs +1 -1
  63. package/dist/web/features/activity/DockTabs.mjs.map +1 -1
  64. package/dist/web/features/connection/RefusedCard.cjs +9 -9
  65. package/dist/web/features/connection/RefusedCard.cjs.map +1 -1
  66. package/dist/web/features/connection/RefusedCard.mjs +9 -9
  67. package/dist/web/features/connection/RefusedCard.mjs.map +1 -1
  68. package/dist/web/features/dialogs/DialogOverlay.cjs +9 -9
  69. package/dist/web/features/dialogs/DialogOverlay.cjs.map +1 -1
  70. package/dist/web/features/dialogs/DialogOverlay.mjs +9 -9
  71. package/dist/web/features/dialogs/DialogOverlay.mjs.map +1 -1
  72. package/dist/web/features/leader/CommandPalette.cjs +23 -23
  73. package/dist/web/features/leader/CommandPalette.cjs.map +1 -1
  74. package/dist/web/features/leader/CommandPalette.mjs +23 -23
  75. package/dist/web/features/leader/CommandPalette.mjs.map +1 -1
  76. package/dist/web/features/remote/DevProxyTargets.cjs +6 -6
  77. package/dist/web/features/remote/DevProxyTargets.cjs.map +1 -1
  78. package/dist/web/features/remote/DevProxyTargets.mjs +6 -6
  79. package/dist/web/features/remote/DevProxyTargets.mjs.map +1 -1
  80. package/dist/web/features/remote/HandoverProgress.cjs +2 -2
  81. package/dist/web/features/remote/HandoverProgress.cjs.map +1 -1
  82. package/dist/web/features/remote/HandoverProgress.mjs +2 -2
  83. package/dist/web/features/remote/HandoverProgress.mjs.map +1 -1
  84. package/dist/web/features/remote/PairedDeviceList.cjs +3 -3
  85. package/dist/web/features/remote/PairedDeviceList.cjs.map +1 -1
  86. package/dist/web/features/remote/PairedDeviceList.mjs +3 -3
  87. package/dist/web/features/remote/PairedDeviceList.mjs.map +1 -1
  88. package/dist/web/features/remote/PairingApprovalDialog.cjs +3 -3
  89. package/dist/web/features/remote/PairingApprovalDialog.cjs.map +1 -1
  90. package/dist/web/features/remote/PairingApprovalDialog.mjs +3 -3
  91. package/dist/web/features/remote/PairingApprovalDialog.mjs.map +1 -1
  92. package/dist/web/features/remote/RemoteAccessDialog.cjs +3 -3
  93. package/dist/web/features/remote/RemoteAccessDialog.cjs.map +1 -1
  94. package/dist/web/features/remote/RemoteAccessDialog.mjs +3 -3
  95. package/dist/web/features/remote/RemoteAccessDialog.mjs.map +1 -1
  96. package/dist/web/features/remote/RemoteAccessOptions.cjs +11 -11
  97. package/dist/web/features/remote/RemoteAccessOptions.cjs.map +1 -1
  98. package/dist/web/features/remote/RemoteAccessOptions.mjs +11 -11
  99. package/dist/web/features/remote/RemoteAccessOptions.mjs.map +1 -1
  100. package/dist/web/features/remote/RemoteAccessPairing.cjs +8 -8
  101. package/dist/web/features/remote/RemoteAccessPairing.cjs.map +1 -1
  102. package/dist/web/features/remote/RemoteAccessPairing.mjs +8 -8
  103. package/dist/web/features/remote/RemoteAccessPairing.mjs.map +1 -1
  104. package/dist/web/features/remote/SandboxWorkspaces.cjs +3 -3
  105. package/dist/web/features/remote/SandboxWorkspaces.cjs.map +1 -1
  106. package/dist/web/features/remote/SandboxWorkspaces.mjs +3 -3
  107. package/dist/web/features/remote/SandboxWorkspaces.mjs.map +1 -1
  108. package/dist/web/features/remote/TrustedDeviceList.cjs +4 -4
  109. package/dist/web/features/remote/TrustedDeviceList.cjs.map +1 -1
  110. package/dist/web/features/remote/TrustedDeviceList.mjs +4 -4
  111. package/dist/web/features/remote/TrustedDeviceList.mjs.map +1 -1
  112. package/dist/web/features/selection/SelectionBar.cjs +40 -37
  113. package/dist/web/features/selection/SelectionBar.cjs.map +1 -1
  114. package/dist/web/features/selection/SelectionBar.d.mts.map +1 -1
  115. package/dist/web/features/selection/SelectionBar.mjs +41 -38
  116. package/dist/web/features/selection/SelectionBar.mjs.map +1 -1
  117. package/dist/web/features/session/AgentLockPanel.cjs +3 -3
  118. package/dist/web/features/session/AgentLockPanel.cjs.map +1 -1
  119. package/dist/web/features/session/AgentLockPanel.mjs +3 -3
  120. package/dist/web/features/session/AgentLockPanel.mjs.map +1 -1
  121. package/dist/web/features/session/Composer.cjs +11 -11
  122. package/dist/web/features/session/Composer.cjs.map +1 -1
  123. package/dist/web/features/session/Composer.mjs +11 -11
  124. package/dist/web/features/session/Composer.mjs.map +1 -1
  125. package/dist/web/features/session/DormantPanel.cjs +4 -4
  126. package/dist/web/features/session/DormantPanel.cjs.map +1 -1
  127. package/dist/web/features/session/DormantPanel.mjs +4 -4
  128. package/dist/web/features/session/DormantPanel.mjs.map +1 -1
  129. package/dist/web/features/session/MentionPreviews.cjs +10 -10
  130. package/dist/web/features/session/MentionPreviews.cjs.map +1 -1
  131. package/dist/web/features/session/MentionPreviews.mjs +10 -10
  132. package/dist/web/features/session/MentionPreviews.mjs.map +1 -1
  133. package/dist/web/features/session/QueueSheet.cjs +28 -35
  134. package/dist/web/features/session/QueueSheet.cjs.map +1 -1
  135. package/dist/web/features/session/QueueSheet.mjs +28 -35
  136. package/dist/web/features/session/QueueSheet.mjs.map +1 -1
  137. package/dist/web/features/session/SessionActivity.cjs +8 -4
  138. package/dist/web/features/session/SessionActivity.cjs.map +1 -1
  139. package/dist/web/features/session/SessionActivity.d.mts +1 -1
  140. package/dist/web/features/session/SessionActivity.d.mts.map +1 -1
  141. package/dist/web/features/session/SessionActivity.mjs +8 -4
  142. package/dist/web/features/session/SessionActivity.mjs.map +1 -1
  143. package/dist/web/features/session/ThreadView.cjs +1 -0
  144. package/dist/web/features/session/ThreadView.cjs.map +1 -1
  145. package/dist/web/features/session/ThreadView.mjs +1 -0
  146. package/dist/web/features/session/ThreadView.mjs.map +1 -1
  147. package/dist/web/features/session/Timeline.cjs +173 -69
  148. package/dist/web/features/session/Timeline.cjs.map +1 -1
  149. package/dist/web/features/session/Timeline.d.mts +3 -1
  150. package/dist/web/features/session/Timeline.d.mts.map +1 -1
  151. package/dist/web/features/session/Timeline.mjs +174 -70
  152. package/dist/web/features/session/Timeline.mjs.map +1 -1
  153. package/dist/web/features/session/ToolCard.cjs +6 -6
  154. package/dist/web/features/session/ToolCard.cjs.map +1 -1
  155. package/dist/web/features/session/ToolCard.mjs +6 -6
  156. package/dist/web/features/session/ToolCard.mjs.map +1 -1
  157. package/dist/web/features/sessions/NewSessionDialog.cjs +3 -3
  158. package/dist/web/features/sessions/NewSessionDialog.cjs.map +1 -1
  159. package/dist/web/features/sessions/NewSessionDialog.mjs +3 -3
  160. package/dist/web/features/sessions/NewSessionDialog.mjs.map +1 -1
  161. package/dist/web/features/sessions/ResumeSessionDialog.cjs +11 -8
  162. package/dist/web/features/sessions/ResumeSessionDialog.cjs.map +1 -1
  163. package/dist/web/features/sessions/ResumeSessionDialog.d.mts +1 -0
  164. package/dist/web/features/sessions/ResumeSessionDialog.mjs +11 -8
  165. package/dist/web/features/sessions/ResumeSessionDialog.mjs.map +1 -1
  166. package/dist/web/features/sessions/WelcomePanel.cjs +29 -15
  167. package/dist/web/features/sessions/WelcomePanel.cjs.map +1 -1
  168. package/dist/web/features/sessions/WelcomePanel.d.mts +3 -0
  169. package/dist/web/features/sessions/WelcomePanel.d.mts.map +1 -1
  170. package/dist/web/features/sessions/WelcomePanel.mjs +29 -15
  171. package/dist/web/features/sessions/WelcomePanel.mjs.map +1 -1
  172. package/dist/web/features/sessions/useSessionRail.cjs +14 -16
  173. package/dist/web/features/sessions/useSessionRail.cjs.map +1 -1
  174. package/dist/web/features/sessions/useSessionRail.d.mts.map +1 -1
  175. package/dist/web/features/sessions/useSessionRail.mjs +16 -18
  176. package/dist/web/features/sessions/useSessionRail.mjs.map +1 -1
  177. package/dist/web/features/settings/AppearanceSettings.cjs +3 -3
  178. package/dist/web/features/settings/AppearanceSettings.cjs.map +1 -1
  179. package/dist/web/features/settings/AppearanceSettings.mjs +3 -3
  180. package/dist/web/features/settings/AppearanceSettings.mjs.map +1 -1
  181. package/dist/web/features/settings/ContributedSettings.cjs +9 -9
  182. package/dist/web/features/settings/ContributedSettings.cjs.map +1 -1
  183. package/dist/web/features/settings/ContributedSettings.d.mts +1 -0
  184. package/dist/web/features/settings/ContributedSettings.mjs +9 -9
  185. package/dist/web/features/settings/ContributedSettings.mjs.map +1 -1
  186. package/dist/web/features/settings/ImageSettings.cjs +2 -2
  187. package/dist/web/features/settings/ImageSettings.cjs.map +1 -1
  188. package/dist/web/features/settings/ImageSettings.d.mts +1 -1
  189. package/dist/web/features/settings/ImageSettings.mjs +2 -2
  190. package/dist/web/features/settings/ImageSettings.mjs.map +1 -1
  191. package/dist/web/features/settings/LoginFlowDialog.cjs +18 -18
  192. package/dist/web/features/settings/LoginFlowDialog.cjs.map +1 -1
  193. package/dist/web/features/settings/LoginFlowDialog.mjs +18 -18
  194. package/dist/web/features/settings/LoginFlowDialog.mjs.map +1 -1
  195. package/dist/web/features/settings/PluginSettings.cjs +1 -1
  196. package/dist/web/features/settings/PluginSettings.cjs.map +1 -1
  197. package/dist/web/features/settings/PluginSettings.mjs +1 -1
  198. package/dist/web/features/settings/PluginSettings.mjs.map +1 -1
  199. package/dist/web/features/settings/ProviderSettings.cjs +18 -18
  200. package/dist/web/features/settings/ProviderSettings.cjs.map +1 -1
  201. package/dist/web/features/settings/ProviderSettings.mjs +18 -18
  202. package/dist/web/features/settings/ProviderSettings.mjs.map +1 -1
  203. package/dist/web/features/settings/RepositorySettings.cjs +6 -6
  204. package/dist/web/features/settings/RepositorySettings.cjs.map +1 -1
  205. package/dist/web/features/settings/RepositorySettings.mjs +6 -6
  206. package/dist/web/features/settings/RepositorySettings.mjs.map +1 -1
  207. package/dist/web/features/settings/RepositoryWorkspace.cjs +3 -3
  208. package/dist/web/features/settings/RepositoryWorkspace.cjs.map +1 -1
  209. package/dist/web/features/settings/RepositoryWorkspace.mjs +3 -3
  210. package/dist/web/features/settings/RepositoryWorkspace.mjs.map +1 -1
  211. package/dist/web/features/settings/SessionMcpSettings.cjs +14 -14
  212. package/dist/web/features/settings/SessionMcpSettings.cjs.map +1 -1
  213. package/dist/web/features/settings/SessionMcpSettings.mjs +14 -14
  214. package/dist/web/features/settings/SessionMcpSettings.mjs.map +1 -1
  215. package/dist/web/features/settings/SettingsMenu.cjs +8 -8
  216. package/dist/web/features/settings/SettingsMenu.cjs.map +1 -1
  217. package/dist/web/features/settings/SettingsMenu.mjs +8 -8
  218. package/dist/web/features/settings/SettingsMenu.mjs.map +1 -1
  219. package/dist/web/features/settings/SettingsPanelHost.d.mts +1 -0
  220. package/dist/web/features/settings/TemplateSettings.cjs +8 -8
  221. package/dist/web/features/settings/TemplateSettings.cjs.map +1 -1
  222. package/dist/web/features/settings/TemplateSettings.mjs +8 -8
  223. package/dist/web/features/settings/TemplateSettings.mjs.map +1 -1
  224. package/dist/web/features/settings/TunnelSettings.cjs +6 -6
  225. package/dist/web/features/settings/TunnelSettings.cjs.map +1 -1
  226. package/dist/web/features/settings/TunnelSettings.mjs +6 -6
  227. package/dist/web/features/settings/TunnelSettings.mjs.map +1 -1
  228. package/dist/web/features/status/TopBar.cjs +6 -6
  229. package/dist/web/features/status/TopBar.cjs.map +1 -1
  230. package/dist/web/features/status/TopBar.mjs +6 -6
  231. package/dist/web/features/status/TopBar.mjs.map +1 -1
  232. package/dist/web/lib/browserNotifications.cjs.map +1 -1
  233. package/dist/web/lib/browserNotifications.d.mts +2 -2
  234. package/dist/web/lib/browserNotifications.d.mts.map +1 -1
  235. package/dist/web/lib/browserNotifications.mjs.map +1 -1
  236. package/dist/web/lib/browserTelemetry.cjs.map +1 -1
  237. package/dist/web/lib/browserTelemetry.d.mts +2 -1
  238. package/dist/web/lib/browserTelemetry.d.mts.map +1 -1
  239. package/dist/web/lib/browserTelemetry.mjs.map +1 -1
  240. package/dist/web/lib/commands.d.mts +1 -0
  241. package/dist/web/lib/composerSubmissions.d.mts +1 -0
  242. package/dist/web/lib/composition.cjs +21 -5
  243. package/dist/web/lib/composition.cjs.map +1 -1
  244. package/dist/web/lib/composition.d.mts +15 -0
  245. package/dist/web/lib/composition.d.mts.map +1 -1
  246. package/dist/web/lib/composition.mjs +21 -6
  247. package/dist/web/lib/composition.mjs.map +1 -1
  248. package/dist/web/lib/contextComposition.cjs +1 -1
  249. package/dist/web/lib/contextComposition.cjs.map +1 -1
  250. package/dist/web/lib/contextComposition.mjs +1 -1
  251. package/dist/web/lib/contextComposition.mjs.map +1 -1
  252. package/dist/web/lib/dashboardRoute.d.mts +1 -0
  253. package/dist/web/lib/hubApi.cjs +62 -1
  254. package/dist/web/lib/hubApi.cjs.map +1 -1
  255. package/dist/web/lib/hubApi.d.mts +19 -0
  256. package/dist/web/lib/hubApi.d.mts.map +1 -1
  257. package/dist/web/lib/hubApi.mjs +59 -3
  258. package/dist/web/lib/hubApi.mjs.map +1 -1
  259. package/dist/web/lib/modelContextAdapter.d.mts +1 -0
  260. package/dist/web/lib/piTransport.cjs +34 -53
  261. package/dist/web/lib/piTransport.cjs.map +1 -1
  262. package/dist/web/lib/piTransport.d.mts +3 -3
  263. package/dist/web/lib/piTransport.d.mts.map +1 -1
  264. package/dist/web/lib/piTransport.mjs +34 -53
  265. package/dist/web/lib/piTransport.mjs.map +1 -1
  266. package/dist/web/lib/pluginRegistry.cjs +53 -4
  267. package/dist/web/lib/pluginRegistry.cjs.map +1 -1
  268. package/dist/web/lib/pluginRegistry.d.mts +15 -1
  269. package/dist/web/lib/pluginRegistry.d.mts.map +1 -1
  270. package/dist/web/lib/pluginRegistry.mjs +53 -5
  271. package/dist/web/lib/pluginRegistry.mjs.map +1 -1
  272. package/dist/web/lib/protocolHubSocket.cjs +151 -89
  273. package/dist/web/lib/protocolHubSocket.cjs.map +1 -1
  274. package/dist/web/lib/protocolHubSocket.d.mts +21 -6
  275. package/dist/web/lib/protocolHubSocket.d.mts.map +1 -1
  276. package/dist/web/lib/protocolHubSocket.mjs +152 -90
  277. package/dist/web/lib/protocolHubSocket.mjs.map +1 -1
  278. package/dist/web/lib/sessionActivityRenderer.d.mts +1 -0
  279. package/dist/web/lib/sessionModel.cjs +120 -20
  280. package/dist/web/lib/sessionModel.cjs.map +1 -1
  281. package/dist/web/lib/sessionModel.d.mts +32 -2
  282. package/dist/web/lib/sessionModel.d.mts.map +1 -1
  283. package/dist/web/lib/sessionModel.mjs +120 -22
  284. package/dist/web/lib/sessionModel.mjs.map +1 -1
  285. package/dist/web/lib/sessionProtocolCommands.cjs +33 -34
  286. package/dist/web/lib/sessionProtocolCommands.cjs.map +1 -1
  287. package/dist/web/lib/sessionProtocolCommands.d.mts +3 -2
  288. package/dist/web/lib/sessionProtocolCommands.d.mts.map +1 -1
  289. package/dist/web/lib/sessionProtocolCommands.mjs +33 -34
  290. package/dist/web/lib/sessionProtocolCommands.mjs.map +1 -1
  291. package/dist/web/lib/sessionRailModel.cjs +2 -1
  292. package/dist/web/lib/sessionRailModel.cjs.map +1 -1
  293. package/dist/web/lib/sessionRailModel.d.mts +1 -1
  294. package/dist/web/lib/sessionRailModel.d.mts.map +1 -1
  295. package/dist/web/lib/sessionRailModel.mjs +2 -1
  296. package/dist/web/lib/sessionRailModel.mjs.map +1 -1
  297. package/dist/web/lib/sessionSelectionApi.cjs +72 -0
  298. package/dist/web/lib/sessionSelectionApi.cjs.map +1 -0
  299. package/dist/web/lib/sessionSelectionApi.d.mts +18 -0
  300. package/dist/web/lib/sessionSelectionApi.d.mts.map +1 -0
  301. package/dist/web/lib/sessionSelectionApi.mjs +72 -0
  302. package/dist/web/lib/sessionSelectionApi.mjs.map +1 -0
  303. package/dist/web/lib/sessionSummary.cjs +1 -0
  304. package/dist/web/lib/sessionSummary.cjs.map +1 -1
  305. package/dist/web/lib/sessionSummary.d.mts +1 -1
  306. package/dist/web/lib/sessionSummary.d.mts.map +1 -1
  307. package/dist/web/lib/sessionSummary.mjs +1 -0
  308. package/dist/web/lib/sessionSummary.mjs.map +1 -1
  309. package/dist/web/lib/sessionTranscriptRenderer.d.mts +1 -0
  310. package/dist/web/lib/statusLine.d.mts +1 -0
  311. package/dist/web/lib/stepUp.d.mts.map +1 -1
  312. package/dist/web/lib/threadRenderer.d.mts +1 -0
  313. package/dist/web/lib/toolCompletionTabs.d.mts +1 -0
  314. package/dist/web/lib/transport.cjs +10 -2
  315. package/dist/web/lib/transport.cjs.map +1 -1
  316. package/dist/web/lib/transport.d.mts +6 -2
  317. package/dist/web/lib/transport.d.mts.map +1 -1
  318. package/dist/web/lib/transport.mjs +10 -3
  319. package/dist/web/lib/transport.mjs.map +1 -1
  320. package/dist/web/stores/captureStore.cjs +22 -4
  321. package/dist/web/stores/captureStore.cjs.map +1 -1
  322. package/dist/web/stores/captureStore.d.mts.map +1 -1
  323. package/dist/web/stores/captureStore.mjs +22 -4
  324. package/dist/web/stores/captureStore.mjs.map +1 -1
  325. package/dist/web/stores/fileLinkModesStore.cjs +27 -10
  326. package/dist/web/stores/fileLinkModesStore.cjs.map +1 -1
  327. package/dist/web/stores/fileLinkModesStore.d.mts +5 -0
  328. package/dist/web/stores/fileLinkModesStore.d.mts.map +1 -1
  329. package/dist/web/stores/fileLinkModesStore.mjs +28 -12
  330. package/dist/web/stores/fileLinkModesStore.mjs.map +1 -1
  331. package/dist/web/stores/pagedTranscriptStore.cjs +29 -37
  332. package/dist/web/stores/pagedTranscriptStore.cjs.map +1 -1
  333. package/dist/web/stores/pagedTranscriptStore.d.mts.map +1 -1
  334. package/dist/web/stores/pagedTranscriptStore.mjs +30 -38
  335. package/dist/web/stores/pagedTranscriptStore.mjs.map +1 -1
  336. package/dist/web/stores/sessionStore.cjs +81 -3
  337. package/dist/web/stores/sessionStore.cjs.map +1 -1
  338. package/dist/web/stores/sessionStore.d.mts +13 -2
  339. package/dist/web/stores/sessionStore.d.mts.map +1 -1
  340. package/dist/web/stores/sessionStore.mjs +80 -5
  341. package/dist/web/stores/sessionStore.mjs.map +1 -1
  342. package/dist/web/stores/sessionsStore.cjs +37 -5
  343. package/dist/web/stores/sessionsStore.cjs.map +1 -1
  344. package/dist/web/stores/sessionsStore.d.mts +10 -0
  345. package/dist/web/stores/sessionsStore.d.mts.map +1 -1
  346. package/dist/web/stores/sessionsStore.mjs +36 -6
  347. package/dist/web/stores/sessionsStore.mjs.map +1 -1
  348. package/dist/web/stores/templateStore.cjs +1 -1
  349. package/dist/web/stores/templateStore.cjs.map +1 -1
  350. package/dist/web/stores/templateStore.d.mts +1 -1
  351. package/dist/web/stores/templateStore.mjs +1 -1
  352. package/dist/web/stores/templateStore.mjs.map +1 -1
  353. package/dist/web/stores/threadStore.cjs +12 -9
  354. package/dist/web/stores/threadStore.cjs.map +1 -1
  355. package/dist/web/stores/threadStore.d.mts +7 -3
  356. package/dist/web/stores/threadStore.d.mts.map +1 -1
  357. package/dist/web/stores/threadStore.mjs +13 -10
  358. package/dist/web/stores/threadStore.mjs.map +1 -1
  359. package/dist/web/stores/transientTabsStore.d.mts +1 -0
  360. package/dist/web/stores/useToolPrompt.cjs +18 -9
  361. package/dist/web/stores/useToolPrompt.cjs.map +1 -1
  362. package/dist/web/stores/useToolPrompt.d.mts +3 -2
  363. package/dist/web/stores/useToolPrompt.d.mts.map +1 -1
  364. package/dist/web/stores/useToolPrompt.mjs +18 -9
  365. package/dist/web/stores/useToolPrompt.mjs.map +1 -1
  366. package/package.json +13 -15
@@ -1 +1 @@
1
- {"version":3,"file":"hubApi.mjs","names":[],"sources":["../../../src/web/lib/hubApi.ts"],"sourcesContent":["import type { TranscriptPage, TranscriptPageRequest } from '@agimon-ai/po-core/sessionProtocol';\nimport { sessionApiPath } from '@agimon-ai/po-core/web';\n\nimport {\n DIRECTORIES_API_ROUTE,\n DIRECTORY_CHILDREN_API_ROUTE,\n WORKSPACES_API_ROUTE,\n type DirectoryListing,\n type PiSessionHistoryItem,\n type SessionSummary,\n type WorkspaceSummary,\n} from '../../types/hub';\nimport { sealedHttpSession } from './sealedSession';\nimport { fetchWithStepUp } from './stepUp';\n\nexport type CreateSessionResult = { sessionId: string; session?: SessionSummary } | { error: string };\nexport type WorkspaceResult = { workspace: WorkspaceSummary } | { error: string };\nexport type WorkspacesResult = { workspaces: WorkspaceSummary[] } | { error: string };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Lists one server folder's visible child directories for the workspace folder browser. */\nexport async function listDirectory(folder?: string): Promise<DirectoryListing | { error: string }> {\n try {\n const query = folder === undefined ? '' : `?path=${encodeURIComponent(folder)}`;\n const response = await sealedHttpSession.fetch(`${DIRECTORY_CHILDREN_API_ROUTE}${query}`);\n const body: unknown = await response.json().catch(() => undefined);\n if (response.ok && isRecord(body) && typeof body.path === 'string' && Array.isArray(body.directories)) {\n return {\n path: body.path,\n ...(typeof body.parent === 'string' ? { parent: body.parent } : {}),\n directories: body.directories.filter((entry): entry is string => typeof entry === 'string'),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\nfunction asWorkspace(value: unknown): WorkspaceSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || typeof value.root !== 'string') return undefined;\n return {\n id: value.id,\n root: value.root,\n ...(typeof value.name === 'string' && value.name !== '' ? { name: value.name } : {}),\n ...(typeof value.available === 'boolean' ? { available: value.available } : {}),\n ...(typeof value.error === 'string' ? { error: value.error } : {}),\n };\n}\n\nexport async function listWorkspaces(): Promise<WorkspacesResult> {\n try {\n const response = await sealedHttpSession.fetch(WORKSPACES_API_ROUTE);\n const body: unknown = await response.json().catch(() => undefined);\n if (response.ok && isRecord(body) && Array.isArray(body.workspaces)) {\n return {\n workspaces: body.workspaces.map(asWorkspace).filter((entry): entry is WorkspaceSummary => entry !== undefined),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/**\n * Admits a server-side repository root without starting a session. A name alone\n * asks the server to create the workspace in its default folder.\n */\nexport async function admitWorkspace(input: { root?: string; name?: string }): Promise<WorkspaceResult> {\n try {\n const response = await fetchWithStepUp(WORKSPACES_API_ROUTE, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(input),\n });\n const body: unknown = await response.json().catch(() => undefined);\n const workspace = isRecord(body) ? asWorkspace(body.workspace) : undefined;\n if (response.ok && workspace !== undefined) return { workspace };\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\nexport type RemoveWorkspaceResult = { ok: true } | { error: string };\n\n/** Unregisters a workspace from Po without touching its files on disk. */\nexport async function removeWorkspace(workspaceId: string): Promise<RemoveWorkspaceResult> {\n try {\n const response = await sealedHttpSession.fetch(`${WORKSPACES_API_ROUTE}/${encodeURIComponent(workspaceId)}`, {\n method: 'DELETE',\n });\n if (response.ok) return { ok: true };\n const body: unknown = await response.json().catch(() => undefined);\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Starts a session in an already admitted workspace. */\nexport async function createWorkspaceSession(\n workspaceId: string,\n input: { name?: string } = {},\n): Promise<CreateSessionResult> {\n let response: Response;\n try {\n response = await fetchWithStepUp(`/api/workspaces/${encodeURIComponent(workspaceId)}/sessions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ name: input.name }),\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n const body: unknown = await response.json().catch(() => undefined);\n if (!response.ok || !isRecord(body) || typeof body.sessionId !== 'string') {\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n }\n const sessionId = body.sessionId;\n try {\n const detail = await sealedHttpSession.fetch(\n `/api/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}`,\n );\n const session: unknown = await detail.json().catch(() => undefined);\n if (detail.ok && isRecord(session) && session.id === sessionId) {\n return { sessionId, session: session as unknown as SessionSummary };\n }\n } catch {\n // The socket can still deliver the summary; this read only closes a missed-event race.\n }\n return { sessionId };\n}\n\n/** Compatibility flow for callers that have not admitted a workspace yet. */\nexport async function createSession(input: { cwd: string; name?: string }): Promise<CreateSessionResult> {\n const admission = await admitWorkspace({ root: input.cwd });\n if ('error' in admission) return admission;\n return createWorkspaceSession(admission.workspace.id, { name: input.name });\n}\n\nexport type StopSessionResult = { ok: true } | { error: string };\n\n/** Asks the hub to stop a session's server; the rail card leaves once the server withdraws its record. */\nexport async function stopSession(sessionId: string): Promise<StopSessionResult> {\n let response: Response;\n try {\n response = await sealedHttpSession.fetch(`${sessionApiPath(sessionId)}`, {\n method: 'DELETE',\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport type RestartSessionResult = { ok: true } | { error: string };\n\n/**\n * Asks the hub to replace a session's server, keeping its id.\n *\n * A running server reads the composition once. Restart syncs workspace changes\n * before reopening the session, so changed extensions and APIs take effect.\n */\nexport async function restartSession(sessionId: string): Promise<RestartSessionResult> {\n let response: Response;\n try {\n response = await sealedHttpSession.fetch(`${sessionApiPath(sessionId)}/restart`, {\n method: 'POST',\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport type ReviveSessionResult = { ok: true } | { error: string };\n\n/**\n * Asks the hub to reopen a recorded session it has not started yet.\n *\n * Step-up gated like creating one, because it is the same act: an agent begins\n * running in a directory. The card turns live when the resulting upsert lands.\n */\nexport async function reviveSession(sessionId: string): Promise<ReviveSessionResult> {\n let response: Response;\n try {\n response = await fetchWithStepUp(`${sessionApiPath(sessionId)}/revive`, { method: 'POST' });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport async function readDormantTranscriptPage(\n sessionId: string,\n request: TranscriptPageRequest,\n signal?: AbortSignal,\n): Promise<TranscriptPage> {\n const params = new URLSearchParams();\n if (request.cursor !== undefined) params.set('cursor', request.cursor);\n if (request.direction !== undefined) params.set('direction', request.direction);\n if (request.limit !== undefined) params.set('limit', String(request.limit));\n const query = params.toString();\n const response = await sealedHttpSession.fetch(\n `${sessionApiPath(sessionId)}/transcript${query === '' ? '' : `?${query}`}`,\n signal === undefined ? {} : { signal },\n );\n const body: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const message =\n isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n throw new Error(message);\n }\n if (!isRecord(body) || !Array.isArray(body.entries)) throw new Error('The saved transcript response was invalid.');\n return body as unknown as TranscriptPage;\n}\nexport type SessionHistoryResult = { sessions: PiSessionHistoryItem[] } | { error: string };\n\n/** Lists the Pi threads saved for a live session's workspace. */\nexport function listSessionHistory(sessionId: string): Promise<SessionHistoryResult> {\n return listHistoryAt(`${sessionApiPath(sessionId)}/history`);\n}\n\nexport type ResumeSessionResult = { sessionId: string; session?: SessionSummary } | { error: string };\n\nasync function listHistoryAt(path: string): Promise<SessionHistoryResult> {\n try {\n const response = await sealedHttpSession.fetch(path);\n const body = (await response.json()) as unknown;\n if (response.ok && isRecord(body) && Array.isArray(body.sessions)) {\n return {\n sessions: body.sessions.filter(\n (session): session is PiSessionHistoryItem =>\n isRecord(session) &&\n typeof session.id === 'string' &&\n (session.name === undefined || typeof session.name === 'string') &&\n typeof session.firstMessage === 'string' &&\n typeof session.createdAt === 'string' &&\n typeof session.updatedAt === 'string' &&\n typeof session.messageCount === 'number',\n ),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Lists saved history without requiring a live session in the workspace. */\nexport function listWorkspaceHistory(workspaceId: string): Promise<SessionHistoryResult> {\n return listHistoryAt(`/api/workspaces/${encodeURIComponent(workspaceId)}/history`);\n}\n\n/** Starts one saved thread without replacing another live session. */\nexport async function resumeWorkspaceSession(\n workspaceId: string,\n targetSessionId: string,\n): Promise<ResumeSessionResult> {\n try {\n const response = await fetchWithStepUp(`/api/workspaces/${encodeURIComponent(workspaceId)}/resume`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ targetSessionId }),\n });\n const body = (await response.json()) as unknown;\n if (!response.ok || !isRecord(body) || typeof body.sessionId !== 'string') {\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n }\n const sessionId = body.sessionId;\n try {\n const detail = await sealedHttpSession.fetch(\n `/api/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}`,\n );\n const session: unknown = await detail.json().catch(() => undefined);\n if (detail.ok && isRecord(session) && session.id === sessionId) {\n return { sessionId, session: session as unknown as SessionSummary };\n }\n } catch {\n // The socket can still deliver the summary; this read only closes a missed-event race.\n }\n return { sessionId };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Replaces one live card with a selected Pi thread from the same workspace. */\nexport async function resumeSession(sessionId: string, targetSessionId: string): Promise<ResumeSessionResult> {\n try {\n const response = await fetchWithStepUp(`${sessionApiPath(sessionId)}/resume`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ targetSessionId }),\n });\n const body = (await response.json()) as unknown;\n if (response.ok && isRecord(body) && typeof body.sessionId === 'string') return { sessionId: body.sessionId };\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n/** File paths under a session's cwd matching the query, for @ completion. */\nexport async function searchSessionFiles(sessionId: string, query: string): Promise<string[]> {\n try {\n const response = await sealedHttpSession.fetch(\n `${sessionApiPath(sessionId)}/plugins/files/?q=${encodeURIComponent(query)}`,\n );\n if (!response.ok) return [];\n const body = (await response.json()) as { files?: unknown };\n return Array.isArray(body.files) ? body.files.filter((file): file is string => typeof file === 'string') : [];\n } catch {\n return []; // Completion is a convenience; a failed lookup just shows nothing.\n }\n}\n\n/**\n * Directories the typed path could complete to, for the new-session picker.\n * The hub lists the parent directory's children and filters them by the\n * trailing segment as a regular expression.\n */\nexport async function searchDirectories(query: string): Promise<string[]> {\n try {\n const response = await sealedHttpSession.fetch(`${DIRECTORIES_API_ROUTE}?q=${encodeURIComponent(query)}`);\n if (!response.ok) return [];\n const body = (await response.json()) as { directories?: unknown };\n return Array.isArray(body.directories)\n ? body.directories.filter((directory): directory is string => typeof directory === 'string')\n : [];\n } catch {\n return []; // Suggestions are a convenience; a failed lookup just shows nothing.\n }\n}\n"],"mappings":";;;;;AAmBA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,eAAsB,cAAc,QAAgE;CAClG,IAAI;EACF,MAAM,QAAQ,WAAW,KAAA,IAAY,KAAK,SAAS,mBAAmB,MAAM;EAC5E,MAAM,WAAW,MAAM,kBAAkB,MAAM,GAAG,+BAA+B,OAAO;EACxF,MAAM,OAAgB,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;EACjE,IAAI,SAAS,MAAM,SAAS,IAAI,KAAK,OAAO,KAAK,SAAS,YAAY,MAAM,QAAQ,KAAK,WAAW,GAClG,OAAO;GACL,MAAM,KAAK;GACX,GAAI,OAAO,KAAK,WAAW,WAAW,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;GACjE,aAAa,KAAK,YAAY,QAAQ,UAA2B,OAAO,UAAU,QAAQ;EAC5F;EAEF,OAAO,EACL,OAAO,SAAS,IAAI,KAAK,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,oBAAoB,SAAS,OAAO,GAC7G;CACF,QAAQ;EACN,OAAO,EAAE,OAAO,kCAAkC;CACpD;AACF;AAEA,SAAS,YAAY,OAA8C;CACjE,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,OAAO,YAAY,OAAO,MAAM,SAAS,UAAU,OAAO,KAAA;CAC/F,OAAO;EACL,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,GAAI,OAAO,MAAM,SAAS,YAAY,MAAM,SAA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GAAG;EACxG,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC;EAC1B,MAAM,OAAQ,MAAM,SAAS,KAAK;EAClC,OAAO,MAAM,QAAQ,KAAK,WAAW,IACjC,KAAK,YAAY,QAAQ,cAAmC,OAAO,cAAc,QAAQ,IACzF,CAAC;CACP,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"hubApi.mjs","names":[],"sources":["../../../src/web/lib/hubApi.ts"],"sourcesContent":["import type { TranscriptPage, TranscriptPageRequest } from '@agimon-ai/po-core/sessionProtocol';\nimport { sessionApiPath } from '@agimon-ai/po-core/web';\n\nimport {\n DIRECTORIES_API_ROUTE,\n DIRECTORY_CHILDREN_API_ROUTE,\n PO_FOLDERS_API_ROUTE,\n WORKSPACES_API_ROUTE,\n type DirectoryListing,\n type PiSessionHistoryItem,\n type SessionSummary,\n type WorkspaceSummary,\n} from '../../types/hub';\nimport { sealedHttpSession } from './sealedSession';\nimport { fetchWithStepUp } from './stepUp';\n\nexport type CreateSessionResult = { sessionId: string; session?: SessionSummary } | { error: string };\nexport type WorkspaceResult = { workspace: WorkspaceSummary } | { error: string };\nexport type WorkspacesResult = { workspaces: WorkspaceSummary[] } | { error: string };\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Lists one server folder's visible child directories for the workspace folder browser. */\nexport async function listDirectory(folder?: string): Promise<DirectoryListing | { error: string }> {\n try {\n const query = folder === undefined ? '' : `?path=${encodeURIComponent(folder)}`;\n const response = await sealedHttpSession.fetch(`${DIRECTORY_CHILDREN_API_ROUTE}${query}`);\n const body: unknown = await response.json().catch(() => undefined);\n if (response.ok && isRecord(body) && typeof body.path === 'string' && Array.isArray(body.directories)) {\n return {\n path: body.path,\n ...(typeof body.parent === 'string' ? { parent: body.parent } : {}),\n directories: body.directories.filter((entry): entry is string => typeof entry === 'string'),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\nfunction asWorkspace(value: unknown): WorkspaceSummary | undefined {\n if (!isRecord(value) || typeof value.id !== 'string' || typeof value.root !== 'string') return undefined;\n return {\n id: value.id,\n root: value.root,\n ...(typeof value.name === 'string' && value.name !== '' ? { name: value.name } : {}),\n ...(typeof value.available === 'boolean' ? { available: value.available } : {}),\n ...(typeof value.error === 'string' ? { error: value.error } : {}),\n };\n}\n\nexport async function listWorkspaces(): Promise<WorkspacesResult> {\n try {\n const response = await sealedHttpSession.fetch(WORKSPACES_API_ROUTE);\n const body: unknown = await response.json().catch(() => undefined);\n if (response.ok && isRecord(body) && Array.isArray(body.workspaces)) {\n return {\n workspaces: body.workspaces.map(asWorkspace).filter((entry): entry is WorkspaceSummary => entry !== undefined),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Every live and dormant session of these workspaces, over HTTP; one failed workspace fails the whole list. */\nexport async function listSessions(\n workspaceIds: readonly string[],\n): Promise<{ sessions: unknown[] } | { error: string }> {\n try {\n const lists = await Promise.all(\n workspaceIds.map(async (workspaceId) => {\n const response = await sealedHttpSession.fetch(\n `${WORKSPACES_API_ROUTE}/${encodeURIComponent(workspaceId)}/sessions`,\n );\n const body: unknown = await response.json().catch(() => undefined);\n if (response.ok && isRecord(body) && Array.isArray(body.sessions)) return body.sessions as unknown[];\n throw new Error(\n isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n );\n }),\n );\n return { sessions: lists.flat() };\n } catch (error) {\n return { error: error instanceof Error ? error.message : 'The cockpit hub is unreachable.' };\n }\n}\n/**\n * Admits a server-side repository root without starting a session. A name alone\n * asks the server to create the workspace in its default folder.\n */\nexport async function admitWorkspace(input: { root?: string; name?: string }): Promise<WorkspaceResult> {\n try {\n const response = await fetchWithStepUp(WORKSPACES_API_ROUTE, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(input),\n });\n const body: unknown = await response.json().catch(() => undefined);\n const workspace = isRecord(body) ? asWorkspace(body.workspace) : undefined;\n if (response.ok && workspace !== undefined) return { workspace };\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\nexport type RemoveWorkspaceResult = { ok: true } | { error: string };\n\n/** Unregisters a workspace from Po without touching its files on disk. */\nexport async function removeWorkspace(workspaceId: string): Promise<RemoveWorkspaceResult> {\n try {\n const response = await sealedHttpSession.fetch(`${WORKSPACES_API_ROUTE}/${encodeURIComponent(workspaceId)}`, {\n method: 'DELETE',\n });\n if (response.ok) return { ok: true };\n const body: unknown = await response.json().catch(() => undefined);\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Starts a session in an already admitted workspace. */\nexport async function createWorkspaceSession(\n workspaceId: string,\n input: { name?: string } = {},\n): Promise<CreateSessionResult> {\n let response: Response;\n try {\n response = await fetchWithStepUp(`/api/workspaces/${encodeURIComponent(workspaceId)}/sessions`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ name: input.name }),\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n const body: unknown = await response.json().catch(() => undefined);\n if (!response.ok || !isRecord(body) || typeof body.sessionId !== 'string') {\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n }\n const sessionId = body.sessionId;\n try {\n const detail = await sealedHttpSession.fetch(\n `/api/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}`,\n );\n const session: unknown = await detail.json().catch(() => undefined);\n if (detail.ok && isRecord(session) && session.id === sessionId) {\n return { sessionId, session: session as unknown as SessionSummary };\n }\n } catch {\n // The socket can still deliver the summary; this read only closes a missed-event race.\n }\n return { sessionId };\n}\n\n/** Compatibility flow for callers that have not admitted a workspace yet. */\nexport async function createSession(input: { cwd: string; name?: string }): Promise<CreateSessionResult> {\n const admission = await admitWorkspace({ root: input.cwd });\n if ('error' in admission) return admission;\n return createWorkspaceSession(admission.workspace.id, { name: input.name });\n}\n\nexport type StopSessionResult = { ok: true } | { error: string };\n\n/** Asks the hub to stop a session's server; the rail card leaves once the server withdraws its record. */\nexport async function stopSession(sessionId: string): Promise<StopSessionResult> {\n let response: Response;\n try {\n response = await sealedHttpSession.fetch(`${sessionApiPath(sessionId)}`, {\n method: 'DELETE',\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport type RestartSessionResult = { ok: true } | { error: string };\n\n/**\n * Asks the hub to replace a session's server, keeping its id.\n *\n * A running server reads the composition once. Restart syncs workspace changes\n * before reopening the session, so changed extensions and APIs take effect.\n */\nexport async function restartSession(sessionId: string): Promise<RestartSessionResult> {\n let response: Response;\n try {\n response = await sealedHttpSession.fetch(`${sessionApiPath(sessionId)}/restart`, {\n method: 'POST',\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport type ReviveSessionResult = { ok: true } | { error: string };\n\n/**\n * Asks the hub to reopen a recorded session it has not started yet.\n *\n * Step-up gated like creating one, because it is the same act: an agent begins\n * running in a directory. The card turns live when the resulting upsert lands.\n */\nexport async function reviveSession(sessionId: string): Promise<ReviveSessionResult> {\n let response: Response;\n try {\n response = await fetchWithStepUp(`${sessionApiPath(sessionId)}/revive`, { method: 'POST' });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n body = undefined;\n }\n const error = isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n return { error };\n}\n\nexport type SessionGroupsResult = { ok: true } | { error: string };\n\nasync function groupsRequest(path: string, init: RequestInit): Promise<SessionGroupsResult> {\n let response: Response;\n try {\n response = await sealedHttpSession.fetch(path, {\n ...init,\n ...(init.body === undefined ? {} : { headers: { 'Content-Type': 'application/json' } }),\n });\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n if (response.ok) return { ok: true };\n const body: unknown = await response.json().catch(() => undefined);\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n}\n\n/** Replaces one session's groups, live or dormant. The rail card updates when the hub's upsert lands. */\nexport function setSessionGroups(sessionId: string, groups: readonly string[]): Promise<SessionGroupsResult> {\n return groupsRequest(`${sessionApiPath(sessionId)}/groups`, { method: 'PUT', body: JSON.stringify({ groups }) });\n}\n\n/** Renames a group on every session in it. */\nexport function renameSessionGroup(from: string, to: string): Promise<SessionGroupsResult> {\n return groupsRequest(`/api/session-groups/${encodeURIComponent(from)}`, {\n method: 'PATCH',\n body: JSON.stringify({ name: to }),\n });\n}\n\n/** Takes a group off every session in it. */\nexport function deleteSessionGroup(name: string): Promise<SessionGroupsResult> {\n return groupsRequest(`/api/session-groups/${encodeURIComponent(name)}`, { method: 'DELETE' });\n}\nexport async function readDormantTranscriptPage(\n sessionId: string,\n request: TranscriptPageRequest,\n signal?: AbortSignal,\n): Promise<TranscriptPage> {\n const params = new URLSearchParams();\n if (request.cursor !== undefined) params.set('cursor', request.cursor);\n if (request.direction !== undefined) params.set('direction', request.direction);\n if (request.limit !== undefined) params.set('limit', String(request.limit));\n const query = params.toString();\n const response = await sealedHttpSession.fetch(\n `${sessionApiPath(sessionId)}/transcript${query === '' ? '' : `?${query}`}`,\n signal === undefined ? {} : { signal },\n );\n const body: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const message =\n isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`;\n throw new Error(message);\n }\n if (!isRecord(body) || !Array.isArray(body.entries)) throw new Error('The saved transcript response was invalid.');\n return body as unknown as TranscriptPage;\n}\nexport type SessionHistoryResult = { sessions: PiSessionHistoryItem[] } | { error: string };\n\n/** Lists the Pi threads saved for a live session's workspace. */\nexport function listSessionHistory(sessionId: string): Promise<SessionHistoryResult> {\n return listHistoryAt(`${sessionApiPath(sessionId)}/history`);\n}\n\nexport type ResumeSessionResult = { sessionId: string; session?: SessionSummary } | { error: string };\n\nasync function listHistoryAt(path: string): Promise<SessionHistoryResult> {\n try {\n const response = await sealedHttpSession.fetch(path);\n const body = (await response.json()) as unknown;\n if (response.ok && isRecord(body) && Array.isArray(body.sessions)) {\n return {\n sessions: body.sessions.filter(\n (session): session is PiSessionHistoryItem =>\n isRecord(session) &&\n typeof session.id === 'string' &&\n (session.name === undefined || typeof session.name === 'string') &&\n typeof session.firstMessage === 'string' &&\n typeof session.createdAt === 'string' &&\n typeof session.updatedAt === 'string',\n ),\n };\n }\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Lists saved history without requiring a live session in the workspace. */\nexport function listWorkspaceHistory(workspaceId: string): Promise<SessionHistoryResult> {\n return listHistoryAt(`/api/workspaces/${encodeURIComponent(workspaceId)}/history`);\n}\n\n/** Starts one saved thread without replacing another live session. */\nexport async function resumeWorkspaceSession(\n workspaceId: string,\n targetSessionId: string,\n): Promise<ResumeSessionResult> {\n try {\n const response = await fetchWithStepUp(`/api/workspaces/${encodeURIComponent(workspaceId)}/resume`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ targetSessionId }),\n });\n const body = (await response.json()) as unknown;\n if (!response.ok || !isRecord(body) || typeof body.sessionId !== 'string') {\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n }\n const sessionId = body.sessionId;\n try {\n const detail = await sealedHttpSession.fetch(\n `/api/workspaces/${encodeURIComponent(workspaceId)}/sessions/${encodeURIComponent(sessionId)}`,\n );\n const session: unknown = await detail.json().catch(() => undefined);\n if (detail.ok && isRecord(session) && session.id === sessionId) {\n return { sessionId, session: session as unknown as SessionSummary };\n }\n } catch {\n // The socket can still deliver the summary; this read only closes a missed-event race.\n }\n return { sessionId };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n\n/** Replaces one live card with a selected Pi thread from the same workspace. */\nexport async function resumeSession(sessionId: string, targetSessionId: string): Promise<ResumeSessionResult> {\n try {\n const response = await fetchWithStepUp(`${sessionApiPath(sessionId)}/resume`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ targetSessionId }),\n });\n const body = (await response.json()) as unknown;\n if (response.ok && isRecord(body) && typeof body.sessionId === 'string') return { sessionId: body.sessionId };\n return {\n error: isRecord(body) && typeof body.error === 'string' ? body.error : `The hub answered ${response.status}.`,\n };\n } catch {\n return { error: 'The cockpit hub is unreachable.' };\n }\n}\n/** File paths under a session's cwd matching the query, for @ completion. */\nexport async function searchSessionFiles(sessionId: string, query: string): Promise<string[]> {\n try {\n const response = await sealedHttpSession.fetch(\n `${sessionApiPath(sessionId)}/plugins/files/?q=${encodeURIComponent(query)}`,\n );\n if (!response.ok) return [];\n const body = (await response.json()) as { files?: unknown };\n return Array.isArray(body.files) ? body.files.filter((file): file is string => typeof file === 'string') : [];\n } catch {\n return []; // Completion is a convenience; a failed lookup just shows nothing.\n }\n}\n\n/**\n * Directories the typed path could complete to, for the new-session picker.\n * The hub lists the parent directory's children and filters them by the\n * trailing segment as a regular expression.\n */\nexport async function searchDirectories(query: string): Promise<string[]> {\n try {\n const response = await sealedHttpSession.fetch(`${DIRECTORIES_API_ROUTE}?q=${encodeURIComponent(query)}`);\n if (!response.ok) return [];\n const body = (await response.json()) as { directories?: unknown };\n return Array.isArray(body.directories)\n ? body.directories.filter((directory): directory is string => typeof directory === 'string')\n : [];\n } catch {\n return []; // Suggestions are a convenience; a failed lookup just shows nothing.\n }\n}\n\n/** Folders under home that already hold Po settings; empty when the hub cannot say. */\nexport async function listPoFolders(): Promise<string[]> {\n try {\n const response = await sealedHttpSession.fetch(PO_FOLDERS_API_ROUTE);\n if (!response.ok) return [];\n const body = (await response.json()) as { directories?: unknown };\n return Array.isArray(body.directories)\n ? body.directories.filter((directory): directory is string => typeof directory === 'string')\n : [];\n } catch {\n return []; // Found folders are a shortcut; naming or browsing still works without them.\n }\n}\n"],"mappings":";;;;;AAoBA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,eAAsB,cAAc,QAAgE;CAClG,IAAI;EACF,MAAM,QAAQ,WAAW,KAAA,IAAY,KAAK,SAAS,mBAAmB,MAAM;EAC5E,MAAM,WAAW,MAAM,kBAAkB,MAAM,GAAG,+BAA+B,OAAO;EACxF,MAAM,OAAgB,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;EACjE,IAAI,SAAS,MAAM,SAAS,IAAI,KAAK,OAAO,KAAK,SAAS,YAAY,MAAM,QAAQ,KAAK,WAAW,GAClG,OAAO;GACL,MAAM,KAAK;GACX,GAAI,OAAO,KAAK,WAAW,WAAW,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;GACjE,aAAa,KAAK,YAAY,QAAQ,UAA2B,OAAO,UAAU,QAAQ;EAC5F;EAEF,OAAO,EACL,OAAO,SAAS,IAAI,KAAK,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,oBAAoB,SAAS,OAAO,GAC7G;CACF,QAAQ;EACN,OAAO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AEA,eAAsB,mBAAmB,WAAmB,OAAkC;CAC5F,IAAI;EACF,MAAM,WAAW,MAAM,kBAAkB,MACvC,GAAG,eAAe,SAAS,EAAE,oBAAoB,mBAAmB,KAAK,GAC3E;EACA,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC;EAC1B,MAAM,OAAQ,MAAM,SAAS,KAAK;EAClC,OAAO,MAAM,QAAQ,KAAK,KAAK,IAAI,KAAK,MAAM,QAAQ,SAAyB,OAAO,SAAS,QAAQ,IAAI,CAAC;CAC9G,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;;;;;AAOA,eAAsB,kBAAkB,OAAkC;CACxE,IAAI;EACF,MAAM,WAAW,MAAM,kBAAkB,MAAM,GAAG,sBAAsB,KAAK,mBAAmB,KAAK,GAAG;EACxG,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC;EAC1B,MAAM,OAAQ,MAAM,SAAS,KAAK;EAClC,OAAO,MAAM,QAAQ,KAAK,WAAW,IACjC,KAAK,YAAY,QAAQ,cAAmC,OAAO,cAAc,QAAQ,IACzF,CAAC;CACP,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;AAGA,eAAsB,gBAAmC;CACvD,IAAI;EACF,MAAM,WAAW,MAAM,kBAAkB,MAAM,oBAAoB;EACnE,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC;EAC1B,MAAM,OAAQ,MAAM,SAAS,KAAK;EAClC,OAAO,MAAM,QAAQ,KAAK,WAAW,IACjC,KAAK,YAAY,QAAQ,cAAmC,OAAO,cAAc,QAAQ,IACzF,CAAC;CACP,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
@@ -8,4 +8,5 @@ export declare function acquireModelContext(host?: ModelContextDocument): Promis
8
8
  /** Releases the fallback surface during root teardown. Native browser state remains browser-owned. */
9
9
  export declare function disposeModelContextAdapter(): void;
10
10
  //#endregion
11
+ export {};
11
12
  //# sourceMappingURL=modelContextAdapter.d.mts.map
@@ -1,14 +1,16 @@
1
1
  const require_sealedSession = require("./sealedSession.cjs");
2
+ let _agimon_ai_po_core_sessionProtocol = require("@agimon-ai/po-core/sessionProtocol");
2
3
  //#region src/web/lib/piTransport.ts
3
4
  const PROTOCOL_PATH = "/api/ws";
4
5
  const MAX_PENDING_BYTES = 67108864;
6
+ const OPEN = 1;
5
7
  /** The cockpit's protocol endpoint for this page. */
6
8
  function protocolSocketUrl(location) {
7
9
  return `${location.protocol === "https:" ? "wss:" : "ws:"}//${location.host}${PROTOCOL_PATH}`;
8
10
  }
9
- /** Ordered, bounded bytes over the cockpit's purpose-bound sealed channel. */
10
- function createProtocolTransport(url) {
11
- return async (handlers) => {
11
+ /** Ordered, bounded Chord frames over the cockpit's purpose-bound sealed channel. */
12
+ function createProtocolLink(url) {
13
+ return async () => {
12
14
  const socket = new WebSocket(url);
13
15
  socket.binaryType = "arraybuffer";
14
16
  await new Promise((resolve, reject) => {
@@ -30,74 +32,53 @@ function createProtocolTransport(url) {
30
32
  socket.addEventListener("error", onError, { once: true });
31
33
  socket.addEventListener("close", onError, { once: true });
32
34
  });
33
- let terminal = false;
34
35
  let incoming = Promise.resolve();
35
36
  let outgoing = Promise.resolve();
36
37
  let incomingBytes = 0;
37
38
  let outgoingBytes = 0;
38
- const stop = (error) => {
39
- if (terminal) return;
40
- terminal = true;
41
- socket.close();
42
- if (error) handlers.onError(error);
43
- else handlers.onClose();
44
- };
45
- const failure = (error) => error instanceof Error ? error : /* @__PURE__ */ new Error("The sealed protocol channel failed.");
39
+ const decoder = new TextDecoder();
40
+ const channel = (0, _agimon_ai_po_core_sessionProtocol.createTextLink)({
41
+ send(text) {
42
+ if (outgoingBytes + socket.bufferedAmount + text.length > MAX_PENDING_BYTES) {
43
+ channel.ended("Protocol send queue exhausted.");
44
+ return;
45
+ }
46
+ outgoingBytes += text.length;
47
+ outgoing = outgoing.then(async () => {
48
+ const sealed = await require_sealedSession.sealedProtocolSession.sealText(text);
49
+ if (socket.readyState === OPEN) socket.send(sealed);
50
+ }).catch(() => channel.ended("The sealed protocol channel failed.")).finally(() => {
51
+ outgoingBytes -= text.length;
52
+ });
53
+ },
54
+ close() {
55
+ socket.close();
56
+ }
57
+ });
46
58
  socket.addEventListener("message", (event) => {
47
- if (terminal) return;
48
59
  const data = event.data;
49
- if (typeof data === "string") {
50
- stop(/* @__PURE__ */ new Error("Expected binary protocol bytes."));
51
- return;
52
- }
53
- const size = data instanceof ArrayBuffer ? data.byteLength : data.size;
60
+ const size = typeof data === "string" ? data.length : data instanceof ArrayBuffer ? data.byteLength : data.size;
54
61
  if (incomingBytes + size > MAX_PENDING_BYTES) {
55
- stop(/* @__PURE__ */ new Error("Protocol receive queue exhausted."));
62
+ channel.ended("Protocol receive queue exhausted.");
56
63
  return;
57
64
  }
58
65
  incomingBytes += size;
59
66
  incoming = incoming.then(async () => {
60
- if (terminal) return;
61
- const buffer = data instanceof ArrayBuffer ? data : await data.arrayBuffer();
62
- const plaintext = await require_sealedSession.sealedProtocolSession.openBinary(new Uint8Array(buffer));
63
- if (terminal) return;
67
+ const text = typeof data === "string" ? data : decoder.decode(data instanceof ArrayBuffer ? data : await data.arrayBuffer());
68
+ const plaintext = await require_sealedSession.sealedProtocolSession.openText(text);
64
69
  if (plaintext === void 0) throw new Error("The sealed protocol frame could not be opened.");
65
- handlers.onData(plaintext);
66
- }).catch((error) => stop(failure(error))).finally(() => {
70
+ channel.deliver(plaintext);
71
+ }).catch(() => channel.ended("The sealed protocol channel failed.")).finally(() => {
67
72
  incomingBytes -= size;
68
73
  });
69
74
  });
70
- socket.addEventListener("close", () => stop());
71
- socket.addEventListener("error", () => stop(/* @__PURE__ */ new Error("The cockpit protocol socket failed")));
72
- return {
73
- async send(chunk) {
74
- if (terminal) throw new Error("The protocol socket is closed.");
75
- if (outgoingBytes + socket.bufferedAmount + chunk.byteLength > MAX_PENDING_BYTES) {
76
- const error = /* @__PURE__ */ new Error("Protocol send queue exhausted.");
77
- stop(error);
78
- throw error;
79
- }
80
- outgoingBytes += chunk.byteLength;
81
- const next = outgoing.then(async () => {
82
- if (terminal) throw new Error("The protocol socket is closed.");
83
- const sealed = await require_sealedSession.sealedProtocolSession.sealBinary(chunk);
84
- if (terminal) throw new Error("The protocol socket is closed.");
85
- if (socket.bufferedAmount + sealed.byteLength > MAX_PENDING_BYTES) throw new Error("Protocol send queue exhausted.");
86
- socket.send(sealed.slice().buffer);
87
- }).finally(() => {
88
- outgoingBytes -= chunk.byteLength;
89
- });
90
- outgoing = next.catch((error) => stop(failure(error)));
91
- return next;
92
- },
93
- close() {
94
- stop();
95
- }
96
- };
75
+ socket.addEventListener("close", () => channel.ended("socket closed"));
76
+ socket.addEventListener("error", () => channel.ended("The cockpit protocol socket failed"));
77
+ return channel.link;
97
78
  };
98
79
  }
99
80
  //#endregion
100
- exports.createProtocolTransport = createProtocolTransport;
81
+ exports.createProtocolLink = createProtocolLink;
101
82
  exports.protocolSocketUrl = protocolSocketUrl;
102
83
 
103
84
  //# sourceMappingURL=piTransport.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"piTransport.cjs","names":["sealedProtocolSession"],"sources":["../../../src/web/lib/piTransport.ts"],"sourcesContent":["import type { ByteTransport, ByteTransportFactory, ByteTransportHandlers } from '@earendil-works/pi-client';\n\nimport { sealedProtocolSession } from './sealedSession';\n\nconst PROTOCOL_PATH = '/api/ws';\nconst MAX_PENDING_BYTES = 64 * 1024 * 1024;\n\n/** The cockpit's protocol endpoint for this page. */\nexport function protocolSocketUrl(location: Location): string {\n const scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';\n return `${scheme}//${location.host}${PROTOCOL_PATH}`;\n}\n\n/** Ordered, bounded bytes over the cockpit's purpose-bound sealed channel. */\nexport function createProtocolTransport(url: string): ByteTransportFactory {\n return async (handlers: ByteTransportHandlers): Promise<ByteTransport> => {\n const socket = new WebSocket(url);\n socket.binaryType = 'arraybuffer';\n await new Promise<void>((resolve, reject) => {\n const clean = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('error', onError);\n socket.removeEventListener('close', onError);\n };\n const onOpen = (): void => {\n clean();\n resolve();\n };\n const onError = (): void => {\n clean();\n socket.close();\n reject(new Error('The cockpit protocol socket failed to open'));\n };\n socket.addEventListener('open', onOpen, { once: true });\n socket.addEventListener('error', onError, { once: true });\n socket.addEventListener('close', onError, { once: true });\n });\n\n let terminal = false;\n let incoming = Promise.resolve();\n let outgoing = Promise.resolve();\n let incomingBytes = 0;\n let outgoingBytes = 0;\n const stop = (error?: Error): void => {\n if (terminal) return;\n terminal = true;\n socket.close();\n if (error) handlers.onError(error);\n else handlers.onClose();\n };\n const failure = (error: unknown): Error =>\n error instanceof Error ? error : new Error('The sealed protocol channel failed.');\n socket.addEventListener('message', (event: MessageEvent<ArrayBuffer | Blob | string>) => {\n if (terminal) return;\n const data = event.data;\n if (typeof data === 'string') {\n stop(new Error('Expected binary protocol bytes.'));\n return;\n }\n const size = data instanceof ArrayBuffer ? data.byteLength : data.size;\n if (incomingBytes + size > MAX_PENDING_BYTES) {\n stop(new Error('Protocol receive queue exhausted.'));\n return;\n }\n incomingBytes += size;\n incoming = incoming\n .then(async () => {\n if (terminal) return;\n const buffer = data instanceof ArrayBuffer ? data : await data.arrayBuffer();\n const plaintext = await sealedProtocolSession.openBinary(new Uint8Array(buffer));\n if (terminal) return;\n if (plaintext === undefined) throw new Error('The sealed protocol frame could not be opened.');\n handlers.onData(plaintext);\n })\n .catch((error: unknown) => stop(failure(error)))\n .finally(() => {\n incomingBytes -= size;\n });\n });\n socket.addEventListener('close', () => stop());\n socket.addEventListener('error', () => stop(new Error('The cockpit protocol socket failed')));\n\n return {\n async send(chunk) {\n if (terminal) throw new Error('The protocol socket is closed.');\n if (outgoingBytes + socket.bufferedAmount + chunk.byteLength > MAX_PENDING_BYTES) {\n const error = new Error('Protocol send queue exhausted.');\n stop(error);\n throw error;\n }\n outgoingBytes += chunk.byteLength;\n const next = outgoing\n .then(async () => {\n if (terminal) throw new Error('The protocol socket is closed.');\n const sealed = await sealedProtocolSession.sealBinary(chunk);\n if (terminal) throw new Error('The protocol socket is closed.');\n if (socket.bufferedAmount + sealed.byteLength > MAX_PENDING_BYTES)\n throw new Error('Protocol send queue exhausted.');\n socket.send(sealed.slice().buffer as ArrayBuffer);\n })\n .finally(() => {\n outgoingBytes -= chunk.byteLength;\n });\n // The caller receives the rejection; the queue also closes the connection.\n outgoing = next.catch((error: unknown) => stop(failure(error)));\n return next;\n },\n close() {\n stop();\n },\n };\n };\n}\n"],"mappings":";;AAIA,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;;AAG1B,SAAgB,kBAAkB,UAA4B;CAE5D,OAAO,GADQ,SAAS,aAAa,WAAW,SAAS,MACxC,IAAI,SAAS,OAAO;AACvC;;AAGA,SAAgB,wBAAwB,KAAmC;CACzE,OAAO,OAAO,aAA4D;EACxE,MAAM,SAAS,IAAI,UAAU,GAAG;EAChC,OAAO,aAAa;EACpB,MAAM,IAAI,SAAe,SAAS,WAAW;GAC3C,MAAM,cAAc;IAClB,OAAO,oBAAoB,QAAQ,MAAM;IACzC,OAAO,oBAAoB,SAAS,OAAO;IAC3C,OAAO,oBAAoB,SAAS,OAAO;GAC7C;GACA,MAAM,eAAqB;IACzB,MAAM;IACN,QAAQ;GACV;GACA,MAAM,gBAAsB;IAC1B,MAAM;IACN,OAAO,MAAM;IACb,uBAAO,IAAI,MAAM,4CAA4C,CAAC;GAChE;GACA,OAAO,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,KAAK,CAAC;GACtD,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;GACxD,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAC1D,CAAC;EAED,IAAI,WAAW;EACf,IAAI,WAAW,QAAQ,QAAQ;EAC/B,IAAI,WAAW,QAAQ,QAAQ;EAC/B,IAAI,gBAAgB;EACpB,IAAI,gBAAgB;EACpB,MAAM,QAAQ,UAAwB;GACpC,IAAI,UAAU;GACd,WAAW;GACX,OAAO,MAAM;G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,MAAM,gCAAgC;KAC9D,MAAM,SAAS,MAAMA,sBAAAA,sBAAsB,WAAW,KAAK;KAC3D,IAAI,UAAU,MAAM,IAAI,MAAM,gCAAgC;KAC9D,IAAI,OAAO,iBAAiB,OAAO,aAAa,mBAC9C,MAAM,IAAI,MAAM,gCAAgC;KAClD,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,MAAqB;IAClD,CAAC,CAAC,CACD,cAAc;KACb,iBAAiB,MAAM;IACzB,CAAC;IAEH,WAAW,KAAK,OAAO,UAAmB,KAAK,QAAQ,KAAK,CAAC,CAAC;IAC9D,OAAO;GACT;GACA,QAAQ;IACN,KAAK;GACP;EACF;CACF;AACF"}
1
+ {"version":3,"file":"piTransport.cjs","names":["createTextLink","sealedProtocolSession"],"sources":["../../../src/web/lib/piTransport.ts"],"sourcesContent":["import { createTextLink } from '@agimon-ai/po-core/sessionProtocol';\nimport type { Link } from '@earendil-works/chord';\n\nimport { sealedProtocolSession } from './sealedSession';\n\nconst PROTOCOL_PATH = '/api/ws';\nconst MAX_PENDING_BYTES = 64 * 1024 * 1024;\nconst OPEN = 1;\n\n/** The cockpit's protocol endpoint for this page. */\nexport function protocolSocketUrl(location: Location): string {\n const scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';\n return `${scheme}//${location.host}${PROTOCOL_PATH}`;\n}\n\n/** Ordered, bounded Chord frames over the cockpit's purpose-bound sealed channel. */\nexport function createProtocolLink(url: string): () => Promise<Link> {\n return async () => {\n const socket = new WebSocket(url);\n socket.binaryType = 'arraybuffer';\n await new Promise<void>((resolve, reject) => {\n const clean = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('error', onError);\n socket.removeEventListener('close', onError);\n };\n const onOpen = (): void => {\n clean();\n resolve();\n };\n const onError = (): void => {\n clean();\n socket.close();\n reject(new Error('The cockpit protocol socket failed to open'));\n };\n socket.addEventListener('open', onOpen, { once: true });\n socket.addEventListener('error', onError, { once: true });\n socket.addEventListener('close', onError, { once: true });\n });\n\n let incoming = Promise.resolve();\n let outgoing = Promise.resolve();\n let incomingBytes = 0;\n let outgoingBytes = 0;\n const decoder = new TextDecoder();\n const channel = createTextLink({\n send(text) {\n if (outgoingBytes + socket.bufferedAmount + text.length > MAX_PENDING_BYTES) {\n channel.ended('Protocol send queue exhausted.');\n return;\n }\n outgoingBytes += text.length;\n outgoing = outgoing\n .then(async () => {\n const sealed = await sealedProtocolSession.sealText(text);\n if (socket.readyState === OPEN) socket.send(sealed);\n })\n .catch(() => channel.ended('The sealed protocol channel failed.'))\n .finally(() => {\n outgoingBytes -= text.length;\n });\n },\n close() {\n socket.close();\n },\n });\n socket.addEventListener('message', (event: MessageEvent<ArrayBuffer | Blob | string>) => {\n const data = event.data;\n const size = typeof data === 'string' ? data.length : data instanceof ArrayBuffer ? data.byteLength : data.size;\n if (incomingBytes + size > MAX_PENDING_BYTES) {\n channel.ended('Protocol receive queue exhausted.');\n return;\n }\n incomingBytes += size;\n incoming = incoming\n .then(async () => {\n const text =\n typeof data === 'string'\n ? data\n : decoder.decode(data instanceof ArrayBuffer ? data : await data.arrayBuffer());\n const plaintext = await sealedProtocolSession.openText(text);\n if (plaintext === undefined) throw new Error('The sealed protocol frame could not be opened.');\n channel.deliver(plaintext);\n })\n .catch(() => channel.ended('The sealed protocol channel failed.'))\n .finally(() => {\n incomingBytes -= size;\n });\n });\n socket.addEventListener('close', () => channel.ended('socket closed'));\n socket.addEventListener('error', () => channel.ended('The cockpit protocol socket failed'));\n return channel.link;\n };\n}\n"],"mappings":";;;AAKA,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,OAAO;;AAGb,SAAgB,kBAAkB,UAA4B;CAE5D,OAAO,GADQ,SAAS,aAAa,WAAW,SAAS,MACxC,IAAI,SAAS,OAAO;AACvC;;AAGA,SAAgB,mBAAmB,KAAkC;CACnE,OAAO,YAAY;EACjB,MAAM,SAAS,IAAI,UAAU,GAAG;EAChC,OAAO,aAAa;EACpB,MAAM,IAAI,SA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AO,mBAAmB;IAC5C,QAAQ,MAAM,mCAAmC;IACjD;GACF;GACA,iBAAiB;GACjB,WAAW,SACR,KAAK,YAAY;IAChB,MAAM,OACJ,OAAO,SAAS,WACZ,OACA,QAAQ,OAAO,gBAAgB,cAAc,OAAO,MAAM,KAAK,YAAY,CAAC;IAClF,MAAM,YAAY,MAAMA,sBAAAA,sBAAsB,SAAS,IAAI;IAC3D,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,gDAAgD;IAC7F,QAAQ,QAAQ,SAAS;GAC3B,CAAC,CAAC,CACD,YAAY,QAAQ,MAAM,qCAAqC,CAAC,CAAC,CACjE,cAAc;IACb,iBAAiB;GACnB,CAAC;EACL,CAAC;EACD,OAAO,iBAAiB,eAAe,QAAQ,MAAM,eAAe,CAAC;EACrE,OAAO,iBAAiB,eAAe,QAAQ,MAAM,oCAAoC,CAAC;EAC1F,OAAO,QAAQ;CACjB;AACF"}
@@ -1,8 +1,8 @@
1
- import { ByteTransportFactory } from "@earendil-works/pi-client";
1
+ import { Link } from "@earendil-works/chord";
2
2
  //#region src/web/lib/piTransport.d.ts
3
3
  /** The cockpit's protocol endpoint for this page. */
4
4
  export declare function protocolSocketUrl(location: Location): string;
5
- /** Ordered, bounded bytes over the cockpit's purpose-bound sealed channel. */
6
- export declare function createProtocolTransport(url: string): ByteTransportFactory;
5
+ /** Ordered, bounded Chord frames over the cockpit's purpose-bound sealed channel. */
6
+ export declare function createProtocolLink(url: string): () => Promise<Link>;
7
7
  //#endregion
8
8
  //# sourceMappingURL=piTransport.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"piTransport.d.mts","names":[],"sources":["../../../src/web/lib/piTransport.ts"],"mappings":";;;wBAQgB,kBAAkB,UAAU;;wBAM5B,wBAAwB,cAAc"}
1
+ {"version":3,"file":"piTransport.d.mts","names":[],"sources":["../../../src/web/lib/piTransport.ts"],"mappings":";;;wBAUgB,kBAAkB,UAAU;;wBAM5B,mBAAmB,oBAAoB,QAAQ"}
@@ -1,14 +1,16 @@
1
1
  import { sealedProtocolSession } from "./sealedSession.mjs";
2
+ import { createTextLink } from "@agimon-ai/po-core/sessionProtocol";
2
3
  //#region src/web/lib/piTransport.ts
3
4
  const PROTOCOL_PATH = "/api/ws";
4
5
  const MAX_PENDING_BYTES = 67108864;
6
+ const OPEN = 1;
5
7
  /** The cockpit's protocol endpoint for this page. */
6
8
  function protocolSocketUrl(location) {
7
9
  return `${location.protocol === "https:" ? "wss:" : "ws:"}//${location.host}${PROTOCOL_PATH}`;
8
10
  }
9
- /** Ordered, bounded bytes over the cockpit's purpose-bound sealed channel. */
10
- function createProtocolTransport(url) {
11
- return async (handlers) => {
11
+ /** Ordered, bounded Chord frames over the cockpit's purpose-bound sealed channel. */
12
+ function createProtocolLink(url) {
13
+ return async () => {
12
14
  const socket = new WebSocket(url);
13
15
  socket.binaryType = "arraybuffer";
14
16
  await new Promise((resolve, reject) => {
@@ -30,73 +32,52 @@ function createProtocolTransport(url) {
30
32
  socket.addEventListener("error", onError, { once: true });
31
33
  socket.addEventListener("close", onError, { once: true });
32
34
  });
33
- let terminal = false;
34
35
  let incoming = Promise.resolve();
35
36
  let outgoing = Promise.resolve();
36
37
  let incomingBytes = 0;
37
38
  let outgoingBytes = 0;
38
- const stop = (error) => {
39
- if (terminal) return;
40
- terminal = true;
41
- socket.close();
42
- if (error) handlers.onError(error);
43
- else handlers.onClose();
44
- };
45
- const failure = (error) => error instanceof Error ? error : /* @__PURE__ */ new Error("The sealed protocol channel failed.");
39
+ const decoder = new TextDecoder();
40
+ const channel = createTextLink({
41
+ send(text) {
42
+ if (outgoingBytes + socket.bufferedAmount + text.length > MAX_PENDING_BYTES) {
43
+ channel.ended("Protocol send queue exhausted.");
44
+ return;
45
+ }
46
+ outgoingBytes += text.length;
47
+ outgoing = outgoing.then(async () => {
48
+ const sealed = await sealedProtocolSession.sealText(text);
49
+ if (socket.readyState === OPEN) socket.send(sealed);
50
+ }).catch(() => channel.ended("The sealed protocol channel failed.")).finally(() => {
51
+ outgoingBytes -= text.length;
52
+ });
53
+ },
54
+ close() {
55
+ socket.close();
56
+ }
57
+ });
46
58
  socket.addEventListener("message", (event) => {
47
- if (terminal) return;
48
59
  const data = event.data;
49
- if (typeof data === "string") {
50
- stop(/* @__PURE__ */ new Error("Expected binary protocol bytes."));
51
- return;
52
- }
53
- const size = data instanceof ArrayBuffer ? data.byteLength : data.size;
60
+ const size = typeof data === "string" ? data.length : data instanceof ArrayBuffer ? data.byteLength : data.size;
54
61
  if (incomingBytes + size > MAX_PENDING_BYTES) {
55
- stop(/* @__PURE__ */ new Error("Protocol receive queue exhausted."));
62
+ channel.ended("Protocol receive queue exhausted.");
56
63
  return;
57
64
  }
58
65
  incomingBytes += size;
59
66
  incoming = incoming.then(async () => {
60
- if (terminal) return;
61
- const buffer = data instanceof ArrayBuffer ? data : await data.arrayBuffer();
62
- const plaintext = await sealedProtocolSession.openBinary(new Uint8Array(buffer));
63
- if (terminal) return;
67
+ const text = typeof data === "string" ? data : decoder.decode(data instanceof ArrayBuffer ? data : await data.arrayBuffer());
68
+ const plaintext = await sealedProtocolSession.openText(text);
64
69
  if (plaintext === void 0) throw new Error("The sealed protocol frame could not be opened.");
65
- handlers.onData(plaintext);
66
- }).catch((error) => stop(failure(error))).finally(() => {
70
+ channel.deliver(plaintext);
71
+ }).catch(() => channel.ended("The sealed protocol channel failed.")).finally(() => {
67
72
  incomingBytes -= size;
68
73
  });
69
74
  });
70
- socket.addEventListener("close", () => stop());
71
- socket.addEventListener("error", () => stop(/* @__PURE__ */ new Error("The cockpit protocol socket failed")));
72
- return {
73
- async send(chunk) {
74
- if (terminal) throw new Error("The protocol socket is closed.");
75
- if (outgoingBytes + socket.bufferedAmount + chunk.byteLength > MAX_PENDING_BYTES) {
76
- const error = /* @__PURE__ */ new Error("Protocol send queue exhausted.");
77
- stop(error);
78
- throw error;
79
- }
80
- outgoingBytes += chunk.byteLength;
81
- const next = outgoing.then(async () => {
82
- if (terminal) throw new Error("The protocol socket is closed.");
83
- const sealed = await sealedProtocolSession.sealBinary(chunk);
84
- if (terminal) throw new Error("The protocol socket is closed.");
85
- if (socket.bufferedAmount + sealed.byteLength > MAX_PENDING_BYTES) throw new Error("Protocol send queue exhausted.");
86
- socket.send(sealed.slice().buffer);
87
- }).finally(() => {
88
- outgoingBytes -= chunk.byteLength;
89
- });
90
- outgoing = next.catch((error) => stop(failure(error)));
91
- return next;
92
- },
93
- close() {
94
- stop();
95
- }
96
- };
75
+ socket.addEventListener("close", () => channel.ended("socket closed"));
76
+ socket.addEventListener("error", () => channel.ended("The cockpit protocol socket failed"));
77
+ return channel.link;
97
78
  };
98
79
  }
99
80
  //#endregion
100
- export { createProtocolTransport, protocolSocketUrl };
81
+ export { createProtocolLink, protocolSocketUrl };
101
82
 
102
83
  //# sourceMappingURL=piTransport.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"piTransport.mjs","names":[],"sources":["../../../src/web/lib/piTransport.ts"],"sourcesContent":["import type { ByteTransport, ByteTransportFactory, ByteTransportHandlers } from '@earendil-works/pi-client';\n\nimport { sealedProtocolSession } from './sealedSession';\n\nconst PROTOCOL_PATH = '/api/ws';\nconst MAX_PENDING_BYTES = 64 * 1024 * 1024;\n\n/** The cockpit's protocol endpoint for this page. */\nexport function protocolSocketUrl(location: Location): string {\n const scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';\n return `${scheme}//${location.host}${PROTOCOL_PATH}`;\n}\n\n/** Ordered, bounded bytes over the cockpit's purpose-bound sealed channel. */\nexport function createProtocolTransport(url: string): ByteTransportFactory {\n return async (handlers: ByteTransportHandlers): Promise<ByteTransport> => {\n const socket = new WebSocket(url);\n socket.binaryType = 'arraybuffer';\n await new Promise<void>((resolve, reject) => {\n const clean = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('error', onError);\n socket.removeEventListener('close', onError);\n };\n const onOpen = (): void => {\n clean();\n resolve();\n };\n const onError = (): void => {\n clean();\n socket.close();\n reject(new Error('The cockpit protocol socket failed to open'));\n };\n socket.addEventListener('open', onOpen, { once: true });\n socket.addEventListener('error', onError, { once: true });\n socket.addEventListener('close', onError, { once: true });\n });\n\n let terminal = false;\n let incoming = Promise.resolve();\n let outgoing = Promise.resolve();\n let incomingBytes = 0;\n let outgoingBytes = 0;\n const stop = (error?: Error): void => {\n if (terminal) return;\n terminal = true;\n socket.close();\n if (error) handlers.onError(error);\n else handlers.onClose();\n };\n const failure = (error: unknown): Error =>\n error instanceof Error ? error : new Error('The sealed protocol channel failed.');\n socket.addEventListener('message', (event: MessageEvent<ArrayBuffer | Blob | string>) => {\n if (terminal) return;\n const data = event.data;\n if (typeof data === 'string') {\n stop(new Error('Expected binary protocol bytes.'));\n return;\n }\n const size = data instanceof ArrayBuffer ? data.byteLength : data.size;\n if (incomingBytes + size > MAX_PENDING_BYTES) {\n stop(new Error('Protocol receive queue exhausted.'));\n return;\n }\n incomingBytes += size;\n incoming = incoming\n .then(async () => {\n if (terminal) return;\n const buffer = data instanceof ArrayBuffer ? data : await data.arrayBuffer();\n const plaintext = await sealedProtocolSession.openBinary(new Uint8Array(buffer));\n if (terminal) return;\n if (plaintext === undefined) throw new Error('The sealed protocol frame could not be opened.');\n handlers.onData(plaintext);\n })\n .catch((error: unknown) => stop(failure(error)))\n .finally(() => {\n incomingBytes -= size;\n });\n });\n socket.addEventListener('close', () => stop());\n socket.addEventListener('error', () => stop(new Error('The cockpit protocol socket failed')));\n\n return {\n async send(chunk) {\n if (terminal) throw new Error('The protocol socket is closed.');\n if (outgoingBytes + socket.bufferedAmount + chunk.byteLength > MAX_PENDING_BYTES) {\n const error = new Error('Protocol send queue exhausted.');\n stop(error);\n throw error;\n }\n outgoingBytes += chunk.byteLength;\n const next = outgoing\n .then(async () => {\n if (terminal) throw new Error('The protocol socket is closed.');\n const sealed = await sealedProtocolSession.sealBinary(chunk);\n if (terminal) throw new Error('The protocol socket is closed.');\n if (socket.bufferedAmount + sealed.byteLength > MAX_PENDING_BYTES)\n throw new Error('Protocol send queue exhausted.');\n socket.send(sealed.slice().buffer as ArrayBuffer);\n })\n .finally(() => {\n outgoingBytes -= chunk.byteLength;\n });\n // The caller receives the rejection; the queue also closes the connection.\n outgoing = next.catch((error: unknown) => stop(failure(error)));\n return next;\n },\n close() {\n stop();\n },\n };\n };\n}\n"],"mappings":";;AAIA,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;;AAG1B,SAAgB,kBAAkB,UAA4B;CAE5D,OAAO,GADQ,SAAS,aAAa,WAAW,SAAS,MACxC,IAAI,SAAS,OAAO;AACvC;;AAGA,SAAgB,wBAAwB,KAAmC;CACzE,OAAO,OAAO,aAA4D;EACxE,MAAM,SAAS,IAAI,UAAU,GAAG;EAChC,OAAO,aAAa;EACpB,MAAM,IAAI,SAAe,SAAS,WAAW;GAC3C,MAAM,cAAc;IAClB,OAAO,oBAAoB,QAAQ,MAAM;IACzC,OAAO,oBAAoB,SAAS,OAAO;IAC3C,OAAO,oBAAoB,SAAS,OAAO;GAC7C;GACA,MAAM,eAAqB;IACzB,MAAM;IACN,QAAQ;GACV;GACA,MAAM,gBAAsB;IAC1B,MAAM;IACN,OAAO,MAAM;IACb,uBAAO,IAAI,MAAM,4CAA4C,CAAC;GAChE;GACA,OAAO,iBAAiB,QAAQ,QAAQ,EAAE,MAAM,KAAK,CAAC;GACtD,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;GACxD,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAC1D,CAAC;EAED,IAAI,WAAW;EACf,IAAI,WAAW,QAAQ,QAAQ;EAC/B,IAAI,WAAW,QAAQ,QAAQ;EAC/B,IAAI,gBAAgB;EACpB,IAAI,gBAAgB;EACpB,MAAM,QAAQ,UAAwB;GACpC,IAAI,UAAU;GACd,WAAW;GACX,OAAO,MAAM;GACb,IAAI,OAAO,SAAS,QAAQ,KAAK;QAC5B,SAAS,QAAQ;EACxB;EACA,MAAM,WAAW,UACf,iB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AM,gCAAgC;KAC9D,IAAI,OAAO,iBAAiB,OAAO,aAAa,mBAC9C,MAAM,IAAI,MAAM,gCAAgC;KAClD,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,MAAqB;IAClD,CAAC,CAAC,CACD,cAAc;KACb,iBAAiB,MAAM;IACzB,CAAC;IAEH,WAAW,KAAK,OAAO,UAAmB,KAAK,QAAQ,KAAK,CAAC,CAAC;IAC9D,OAAO;GACT;GACA,QAAQ;IACN,KAAK;GACP;EACF;CACF;AACF"}
1
+ {"version":3,"file":"piTransport.mjs","names":[],"sources":["../../../src/web/lib/piTransport.ts"],"sourcesContent":["import { createTextLink } from '@agimon-ai/po-core/sessionProtocol';\nimport type { Link } from '@earendil-works/chord';\n\nimport { sealedProtocolSession } from './sealedSession';\n\nconst PROTOCOL_PATH = '/api/ws';\nconst MAX_PENDING_BYTES = 64 * 1024 * 1024;\nconst OPEN = 1;\n\n/** The cockpit's protocol endpoint for this page. */\nexport function protocolSocketUrl(location: Location): string {\n const scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';\n return `${scheme}//${location.host}${PROTOCOL_PATH}`;\n}\n\n/** Ordered, bounded Chord frames over the cockpit's purpose-bound sealed channel. */\nexport function createProtocolLink(url: string): () => Promise<Link> {\n return async () => {\n const socket = new WebSocket(url);\n socket.binaryType = 'arraybuffer';\n await new Promise<void>((resolve, reject) => {\n const clean = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('error', onError);\n socket.removeEventListener('close', onError);\n };\n const onOpen = (): void => {\n clean();\n resolve();\n };\n const onError = (): void => {\n clean();\n socket.close();\n reject(new Error('The cockpit protocol socket failed to open'));\n };\n socket.addEventListener('open', onOpen, { once: true });\n socket.addEventListener('error', onError, { once: true });\n socket.addEventListener('close', onError, { once: true });\n });\n\n let incoming = Promise.resolve();\n let outgoing = Promise.resolve();\n let incomingBytes = 0;\n let outgoingBytes = 0;\n const decoder = new TextDecoder();\n const channel = createTextLink({\n send(text) {\n if (outgoingBytes + socket.bufferedAmount + text.length > MAX_PENDING_BYTES) {\n channel.ended('Protocol send queue exhausted.');\n return;\n }\n outgoingBytes += text.length;\n outgoing = outgoing\n .then(async () => {\n const sealed = await sealedProtocolSession.sealText(text);\n if (socket.readyState === OPEN) socket.send(sealed);\n })\n .catch(() => channel.ended('The sealed protocol channel failed.'))\n .finally(() => {\n outgoingBytes -= text.length;\n });\n },\n close() {\n socket.close();\n },\n });\n socket.addEventListener('message', (event: MessageEvent<ArrayBuffer | Blob | string>) => {\n const data = event.data;\n const size = typeof data === 'string' ? data.length : data instanceof ArrayBuffer ? data.byteLength : data.size;\n if (incomingBytes + size > MAX_PENDING_BYTES) {\n channel.ended('Protocol receive queue exhausted.');\n return;\n }\n incomingBytes += size;\n incoming = incoming\n .then(async () => {\n const text =\n typeof data === 'string'\n ? data\n : decoder.decode(data instanceof ArrayBuffer ? data : await data.arrayBuffer());\n const plaintext = await sealedProtocolSession.openText(text);\n if (plaintext === undefined) throw new Error('The sealed protocol frame could not be opened.');\n channel.deliver(plaintext);\n })\n .catch(() => channel.ended('The sealed protocol channel failed.'))\n .finally(() => {\n incomingBytes -= size;\n });\n });\n socket.addEventListener('close', () => channel.ended('socket closed'));\n socket.addEventListener('error', () => channel.ended('The cockpit protocol socket failed'));\n return channel.link;\n };\n}\n"],"mappings":";;;AAKA,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,OAAO;;AAGb,SAAgB,kBAAkB,UAA4B;CAE5D,OAAO,GADQ,SAAS,aAAa,WAAW,SAAS,MACxC,IAAI,SAAS,OAAO;AACvC;;AAGA,SAAgB,mBAAmB,KAAkC;CACnE,OAAO,YAAY;EACjB,MAAM,SAAS,IAAI,UAAU,GAAG;EAChC,OAAO,aAAa;EACpB,MAAM,IAAI,SAAe,SAAS,WAAW;GAC3C,MAAM,cAAc;IAClB,OAAO,oBAAoB,QAAQ,MAAM;IACzC,OAAO,oBAAoB,SAAS,OAAO;IAC3C,OAAO,oBAAoB,S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cAAc,OAAO,MAAM,KAAK,YAAY,CAAC;IAClF,MAAM,YAAY,MAAM,sBAAsB,SAAS,IAAI;IAC3D,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,gDAAgD;IAC7F,QAAQ,QAAQ,SAAS;GAC3B,CAAC,CAAC,CACD,YAAY,QAAQ,MAAM,qCAAqC,CAAC,CAAC,CACjE,cAAc;IACb,iBAAiB;GACnB,CAAC;EACL,CAAC;EACD,OAAO,iBAAiB,eAAe,QAAQ,MAAM,eAAe,CAAC;EACrE,OAAO,iBAAiB,eAAe,QAAQ,MAAM,oCAAoC,CAAC;EAC1F,OAAO,QAAQ;CACjB;AACF"}
@@ -1,9 +1,11 @@
1
1
  const require_leaderTree = require("./leaderTree.cjs");
2
2
  const require_pluginScopes = require("./pluginScopes.cjs");
3
3
  const require_templateCatalog = require("./templateCatalog.cjs");
4
+ let _agimon_ai_po_core_web = require("@agimon-ai/po-core/web");
4
5
  //#region src/web/lib/pluginRegistry.ts
5
6
  /** The slots the host itself declares; a plugin's own slots are namespaced by its id instead. */
6
7
  const HOST_SLOTS = {
8
+ home: "home",
7
9
  overlay: "overlay",
8
10
  rail: "rail",
9
11
  context: "context",
@@ -103,12 +105,12 @@ function rebuildSession(sessionId) {
103
105
  return state;
104
106
  }
105
107
  function installGlobalWebPlugins(plugins) {
106
- defaultState = buildWebPluginState(require_pluginScopes.pluginsAtScope(plugins, "global"));
108
+ defaultState = buildWebPluginState(require_pluginScopes.pluginsAtScope(plugins, "global"), plugins);
107
109
  for (const id of sessionPlugins.keys()) rebuildSession(id);
108
110
  emitRegistryChange();
109
111
  }
110
112
  function installWorkspaceWebPlugins(workspaceId, plugins) {
111
- const state = buildWebPluginState(require_pluginScopes.pluginsAtScope(plugins, "workspace"));
113
+ const state = buildWebPluginState(require_pluginScopes.pluginsAtScope(plugins, "workspace"), plugins);
112
114
  workspaceStates.set(workspaceId, state);
113
115
  for (const [id, owner] of sessionWorkspaces) if (owner === workspaceId) rebuildSession(id);
114
116
  emitRegistryChange();
@@ -255,7 +257,7 @@ function resolveLeaderConflicts(bindings) {
255
257
  });
256
258
  }
257
259
  }
258
- function buildWebPluginState(plugins) {
260
+ function buildWebPluginState(plugins, definitions = plugins) {
259
261
  const previous = installingState;
260
262
  installingState = emptyState();
261
263
  try {
@@ -375,6 +377,10 @@ function buildWebPluginState(plugins) {
375
377
  }
376
378
  installingState.diagnostics.push(...require_templateCatalog.collectWebTemplates(installingState.plugins).diagnostics);
377
379
  for (const slot of Object.values(HOST_SLOTS)) installingState.slots.set(slot, { slot });
380
+ installingState.slots.set(HOST_SLOTS.home, {
381
+ slot: HOST_SLOTS.home,
382
+ parse: _agimon_ai_po_core_web.parseHomeContribution
383
+ });
378
384
  for (const group of installingState.activityGroups) installingState.slots.set(activityGroupSlot(group.name), { slot: activityGroupSlot(group.name) });
379
385
  for (const declaration of pendingSlots) installingState.slots.set(declaration.slot, declaration);
380
386
  for (const { pluginId, section } of pendingSections) {
@@ -384,7 +390,27 @@ function buildWebPluginState(plugins) {
384
390
  fill: surfaceFill(installingState.slots.has(keyed) ? keyed : HOST_SLOTS.activity, section)
385
391
  });
386
392
  }
387
- for (const { pluginId, fill } of pendingFills) placeFill(pluginId, fill);
393
+ for (const { pluginId, fill } of pendingFills) {
394
+ if (fill.slot === HOST_SLOTS.home) {
395
+ const data = (0, _agimon_ai_po_core_web.parseHomeContribution)(fill.data);
396
+ const definition = definitions.find((plugin) => plugin.id === pluginId);
397
+ const sources = [
398
+ definition,
399
+ definition?.global,
400
+ definition?.workspace,
401
+ definition?.session
402
+ ].flatMap((contribution) => contribution?.channels ?? []);
403
+ if (data === null || !sources.some((channel) => channel.channel === data.source)) {
404
+ installingState.diagnostics.push({
405
+ pluginId,
406
+ kind: "rejected-fill",
407
+ message: `Web plugin '${pluginId}' Home fill '${fill.id}' needs valid data and an owned source channel.`
408
+ });
409
+ continue;
410
+ }
411
+ }
412
+ placeFill(pluginId, fill);
413
+ }
388
414
  for (const list of installingState.fills.values()) list.sort(byFillOrder);
389
415
  resolveLeaderConflicts(pendingBindings);
390
416
  installingState.leaderBindings.push(...pendingBindings.map((entry) => entry.binding));
@@ -521,6 +547,28 @@ function slotFills(slot, sessionId) {
521
547
  function workspaceSlotFills(workspaceId, slot) {
522
548
  return workspaceStates.get(workspaceId)?.fills.get(slot) ?? [];
523
549
  }
550
+ /** Home reads an explicit host mount, never the focused session or workspace. */
551
+ function pluginHomeContributions(mount) {
552
+ const global = defaultState.fills.get(HOST_SLOTS.home) ?? [];
553
+ const workspace = mount.scope === "workspace" ? workspaceStates.get(mount.workspaceId)?.fills.get(HOST_SLOTS.home) ?? [] : [];
554
+ const seen = /* @__PURE__ */ new Set();
555
+ const contributions = [];
556
+ for (const fill of [...global, ...workspace]) {
557
+ const data = (0, _agimon_ai_po_core_web.parseHomeContribution)(fill.data);
558
+ if (data === null) continue;
559
+ const key = `${fill.pluginId}\0${data.source}`;
560
+ if (seen.has(key)) continue;
561
+ seen.add(key);
562
+ contributions.push({
563
+ pluginId: fill.pluginId,
564
+ id: fill.id,
565
+ order: fill.order,
566
+ data,
567
+ mount: global.includes(fill) ? { scope: "global" } : mount
568
+ });
569
+ }
570
+ return contributions.sort((left, right) => left.order - right.order || left.pluginId.localeCompare(right.pluginId) || left.id.localeCompare(right.id));
571
+ }
524
572
  function paletteCommands() {
525
573
  return activeState().commands;
526
574
  }
@@ -664,6 +712,7 @@ exports.pluginActivityGroups = pluginActivityGroups;
664
712
  exports.pluginContextActions = pluginContextActions;
665
713
  exports.pluginDockFaces = pluginDockFaces;
666
714
  exports.pluginFileLinks = pluginFileLinks;
715
+ exports.pluginHomeContributions = pluginHomeContributions;
667
716
  exports.pluginLeaderBindings = pluginLeaderBindings;
668
717
  exports.pluginMinorModes = pluginMinorModes;
669
718
  exports.pluginRepositorySettingsPanels = pluginRepositorySettingsPanels;