@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,4 +1,5 @@
1
- import { applySessionLifecycle, beginSessionReplay, bindHistoryReader, endSessionReplay, releaseProtocolTranscript, resetSessionStore, setHasNewerHistory } from "./sessionStore.mjs";
1
+ import { hasSessionProtocol } from "../lib/sessionProtocolCommands.mjs";
2
+ import { applySessionLifecycle, beginSessionReplay, bindHistoryReader, endSessionReplay, refreshSessionSelection, releaseProtocolTranscript, resetSessionStore, setHasNewerHistory, setSessionStreamed } from "./sessionStore.mjs";
2
3
  //#region src/web/stores/pagedTranscriptStore.ts
3
4
  const MAX_PAGES = 5;
4
5
  const PAGE_SIZE = 100;
@@ -13,9 +14,27 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
13
14
  let reloadPending = false;
14
15
  let buffered = [];
15
16
  let latestState;
16
- let drafts = [];
17
17
  const emit = (frame, replay = false) => onFrame(sessionId, frame, replay);
18
18
  const atLatest = () => pages.at(-1)?.newerCursor === null;
19
+ const emitLive = (live, previous, replay) => {
20
+ if (live?.message && live.message !== previous?.message) emit({
21
+ type: "message_update",
22
+ message: live.message
23
+ }, replay);
24
+ for (const tool of Object.values(live?.tools ?? {})) {
25
+ if (replay) emit({
26
+ type: "tool_execution_start",
27
+ toolCallId: tool.toolCallId,
28
+ toolName: tool.toolName,
29
+ args: tool.args
30
+ }, true);
31
+ if (tool.partialResult && tool.partialResult !== previous?.tools[tool.toolCallId]?.partialResult) emit({
32
+ type: "tool_execution_update",
33
+ toolCallId: tool.toolCallId,
34
+ partialResult: tool.partialResult
35
+ }, replay);
36
+ }
37
+ };
19
38
  const rebuild = () => {
20
39
  const started = performance.now();
21
40
  releaseProtocolTranscript(sessionId);
@@ -31,39 +50,9 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
31
50
  entry
32
51
  }, true);
33
52
  for (const event of latestState?.presentation?.projections ?? []) emit(event.frame, true);
34
- if (atLatest()) {
35
- for (const draft of drafts) if (draft.role === "assistant") for (const part of draft.content) {
36
- if (part.type === "text") emit({
37
- type: "message_update",
38
- assistantMessageEvent: {
39
- type: "text_delta",
40
- delta: part.text
41
- }
42
- }, true);
43
- if (part.type === "thinking") emit({
44
- type: "message_update",
45
- assistantMessageEvent: {
46
- type: "thinking_delta",
47
- delta: part.thinking
48
- }
49
- }, true);
50
- }
51
- else if (draft.role === "tool") {
52
- emit({
53
- type: "tool_execution_start",
54
- toolCallId: draft.toolCallId,
55
- toolName: draft.toolName,
56
- args: draft.input
57
- }, true);
58
- emit({
59
- type: "tool_execution_update",
60
- toolCallId: draft.toolCallId,
61
- partialResult: { content: draft.content }
62
- }, true);
63
- }
64
- }
53
+ if (atLatest()) emitLive(latestState?.live, void 0, true);
65
54
  if (latestState?.snapshot.lifecycle) applySessionLifecycle(sessionId, latestState.snapshot.lifecycle);
66
- else if (latestState?.snapshot.phase === "turn") emit({ type: "agent_start" }, true);
55
+ else if (latestState?.live?.phase === "turn") emit({ type: "agent_start" }, true);
67
56
  setHasNewerHistory(sessionId, !atLatest());
68
57
  } finally {
69
58
  endSessionReplay(sessionId);
@@ -102,14 +91,13 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
102
91
  if (!pages.some((page) => page.entries.some((item) => item && typeof item === "object" && !Array.isArray(item) && item.id === entry.id))) {
103
92
  let tail = pages.at(-1);
104
93
  if (tail && tail.entries.length >= PAGE_SIZE) {
105
- const identity = [...tail.context, ...tail.entries].findLast((item) => item && typeof item === "object" && !Array.isArray(item) && item.customType === "doom-profile-identity");
94
+ const identity = [...tail.context, ...tail.entries].findLast((item) => item && typeof item === "object" && !Array.isArray(item) && item.customType === "po-profile-identity");
106
95
  tail = {
107
96
  ...tail,
108
97
  context: identity ? [identity] : [],
109
98
  entries: [],
110
99
  olderCursor: tail.endCursor,
111
- startCursor: null,
112
- drafts: []
100
+ startCursor: null
113
101
  };
114
102
  pages.push(tail);
115
103
  if (pages.length > MAX_PAGES) pages.shift();
@@ -156,9 +144,10 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
156
144
  if (direction !== "latest") {
157
145
  for (const event of buffered) if (event.sequence <= page.revision) apply(event);
158
146
  }
159
- drafts = page.drafts;
160
147
  revision = Math.max(revision, page.revision);
161
148
  rebuild();
149
+ setSessionStreamed(sessionId, true);
150
+ if (hasSessionProtocol(sessionId)) refreshSessionSelection(sessionId);
162
151
  } finally {
163
152
  loading = false;
164
153
  const events = buffered;
@@ -205,6 +194,7 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
205
194
  type: "agent_lock_changed",
206
195
  locked
207
196
  });
197
+ const previousLive = latestState?.live;
208
198
  latestState = state;
209
199
  if (state.snapshot.lifecycle) applySessionLifecycle(sessionId, state.snapshot.lifecycle, previous === void 0);
210
200
  if (previous !== void 0 && state.presentation && state.presentation.revision < previous) {
@@ -220,9 +210,11 @@ function createPagedTranscript(sessionId, service, onFrame, context, record = ()
220
210
  buffered = buffered.slice(-512);
221
211
  }
222
212
  } else apply(event);
213
+ if (!loading && pages.length > 0 && atLatest()) emitLive(state.live, previousLive, false);
223
214
  },
224
215
  dispose() {
225
216
  disposed = true;
217
+ setSessionStreamed(sessionId, false);
226
218
  unbind();
227
219
  pages = [];
228
220
  buffered = [];
@@ -1 +1 @@
1
- {"version":3,"file":"pagedTranscriptStore.mjs","names":[],"sources":["../../../src/web/stores/pagedTranscriptStore.ts"],"sourcesContent":["import type {\n ProtocolEvent,\n SessionService,\n SessionServiceState,\n TranscriptPage,\n} from '@agimon-ai/po-core/sessionProtocol';\nimport { type Context } from '@earendil-works/chord';\n\nimport type { BrowserPerformanceEvent } from '../lib/browserTelemetry';\nimport {\n applySessionLifecycle,\n bindHistoryReader,\n resetSessionStore,\n beginSessionReplay,\n endSessionReplay,\n releaseProtocolTranscript,\n setHasNewerHistory,\n} from './sessionStore';\n\nconst MAX_PAGES = 5;\nconst PAGE_SIZE = 100;\nconst MAX_BUFFER = 512;\ntype Direction = 'older' | 'newer' | 'latest';\n\n/** A bounded history window with a separate live event subscription. */\nexport function createPagedTranscript(\n sessionId: string,\n service: Pick<SessionService, 'readTranscriptPage'>,\n onFrame: (sessionId: string, frame: Record<string, unknown>, replay: boolean) => void,\n context: Context,\n record: (event: BrowserPerformanceEvent) => void = () => {},\n) {\n let pages: TranscriptPage[] = [];\n let revision = 0;\n let loading = false;\n let disposed = false;\n let overflow = false;\n let reloadPending = false;\n let buffered: ProtocolEvent[] = [];\n let latestState: SessionServiceState | undefined;\n let drafts: TranscriptPage['drafts'] = [];\n const emit = (frame: Record<string, unknown>, replay = false) => onFrame(sessionId, frame, replay);\n const atLatest = () => pages.at(-1)?.newerCursor === null;\n const rebuild = () => {\n const started = performance.now();\n releaseProtocolTranscript(sessionId);\n beginSessionReplay(sessionId);\n try {\n resetSessionStore(sessionId);\n for (const entry of pages[0]?.context ?? []) emit({ type: 'entry_appended', entry }, true);\n for (const page of pages) for (const entry of page.entries) emit({ type: 'entry_appended', entry }, true);\n // Current projections win over historical configuration in the transcript page.\n for (const event of latestState?.presentation?.projections ?? []) emit(event.frame, true);\n if (atLatest())\n for (const draft of drafts) {\n if (draft.role === 'assistant') {\n for (const part of draft.content) {\n if (part.type === 'text')\n emit({ type: 'message_update', assistantMessageEvent: { type: 'text_delta', delta: part.text } }, true);\n if (part.type === 'thinking')\n emit(\n { type: 'message_update', assistantMessageEvent: { type: 'thinking_delta', delta: part.thinking } },\n true,\n );\n }\n } else if (draft.role === 'tool') {\n emit(\n {\n type: 'tool_execution_start',\n toolCallId: draft.toolCallId,\n toolName: draft.toolName,\n args: draft.input,\n },\n true,\n );\n emit(\n {\n type: 'tool_execution_update',\n toolCallId: draft.toolCallId,\n partialResult: { content: draft.content },\n },\n true,\n );\n }\n }\n if (latestState?.snapshot.lifecycle) applySessionLifecycle(sessionId, latestState.snapshot.lifecycle);\n else if (latestState?.snapshot.phase === 'turn') emit({ type: 'agent_start' }, true);\n setHasNewerHistory(sessionId, !atLatest());\n } finally {\n endSessionReplay(sessionId);\n record({\n name: 'web.browser.transcript_render',\n duration_ms: performance.now() - started,\n count: pages.reduce((count, page) => count + page.entries.length, 0),\n });\n }\n };\n const apply = (event: ProtocolEvent) => {\n if (event.sequence <= revision) return;\n if (revision > 0 && event.sequence > revision + 1) {\n request('latest');\n return;\n }\n revision = event.sequence;\n const frame = event.frame;\n if (frame.type === 'navigation_end' || frame.type === 'message_end') {\n if (frame.type === 'message_end') emit(frame);\n request('latest');\n return;\n }\n if (\n !atLatest() &&\n [\n 'message_start',\n 'message_update',\n 'message_end',\n 'entry_appended',\n 'tool_execution_start',\n 'tool_execution_update',\n 'tool_execution_end',\n 'agent_settled',\n ].includes(frame.type)\n )\n return;\n if (\n frame.type === 'entry_appended' &&\n frame.entry &&\n typeof frame.entry === 'object' &&\n !Array.isArray(frame.entry)\n ) {\n const entry = frame.entry;\n if (\n !pages.some((page) =>\n page.entries.some((item) => item && typeof item === 'object' && !Array.isArray(item) && item.id === entry.id),\n )\n ) {\n let tail = pages.at(-1);\n if (tail && tail.entries.length >= PAGE_SIZE) {\n const identity = [...tail.context, ...tail.entries].findLast(\n (item) =>\n item && typeof item === 'object' && !Array.isArray(item) && item.customType === 'doom-profile-identity',\n );\n tail = {\n ...tail,\n context: identity ? [identity] : [],\n entries: [],\n olderCursor: tail.endCursor,\n startCursor: null,\n drafts: [],\n };\n pages.push(tail);\n if (pages.length > MAX_PAGES) pages.shift();\n }\n if (tail) {\n tail.entries.push(entry);\n tail.endCursor = typeof frame.transcriptCursor === 'string' ? frame.transcriptCursor : tail.endCursor;\n tail.startCursor ??= tail.endCursor;\n }\n }\n }\n emit(frame);\n };\n const load = async (direction: Direction): Promise<void> => {\n loading = true;\n const cursor = direction === 'older' ? pages[0]?.olderCursor : pages.at(-1)?.newerCursor;\n try {\n const started = performance.now();\n const page = await service.readTranscriptPage(\n direction === 'latest' ? {} : { cursor: cursor!, direction },\n context,\n );\n record({\n name: 'web.browser.transcript_page',\n duration_ms: performance.now() - started,\n count: page.entries.length,\n });\n if (disposed) return;\n if (direction === 'latest') pages = [page];\n else if (direction === 'older') {\n pages.unshift(page);\n if (pages.length > MAX_PAGES) {\n pages.pop();\n const tail = pages.at(-1)!;\n tail.newerCursor = tail.endCursor;\n }\n } else {\n pages.push(page);\n if (pages.length > MAX_PAGES) {\n pages.shift();\n pages[0]!.olderCursor = pages[0]!.startCursor;\n }\n }\n if (direction !== 'latest') for (const event of buffered) if (event.sequence <= page.revision) apply(event);\n drafts = page.drafts;\n revision = Math.max(revision, page.revision);\n rebuild();\n } finally {\n loading = false;\n const events = buffered;\n buffered = [];\n if (!disposed) {\n if (overflow || reloadPending) {\n overflow = false;\n reloadPending = false;\n request('latest');\n } else for (const event of events) apply(event);\n }\n }\n };\n const request = (direction: Direction): boolean => {\n if (disposed) return false;\n if (loading) {\n if (direction === 'latest') reloadPending = true;\n return false;\n }\n if (direction === 'older' && !pages[0]?.olderCursor) return false;\n if (direction === 'newer' && !pages.at(-1)?.newerCursor) return false;\n void load(direction).catch((error: unknown) => {\n if (disposed) return;\n if (String(error).includes('STALE_TRANSCRIPT_CURSOR') && direction !== 'latest') request('latest');\n else emit({ type: 'error', message: error instanceof Error ? error.message : String(error) });\n });\n return true;\n };\n const unbind = bindHistoryReader(sessionId, request, () => pages.length > 0);\n return {\n initialize: () => load('latest'),\n publish(state: SessionServiceState) {\n const previous = latestState?.presentation?.revision;\n const fastMode = state.snapshot.fastMode === true;\n if (!latestState || fastMode !== (latestState.snapshot.fastMode === true)) {\n emit({ type: 'fast_mode_changed', enabled: fastMode });\n }\n const locked = state.snapshot.locked === true;\n if (!latestState || locked !== (latestState.snapshot.locked === true)) {\n emit({ type: 'agent_lock_changed', locked });\n }\n latestState = state;\n if (state.snapshot.lifecycle) applySessionLifecycle(sessionId, state.snapshot.lifecycle, previous === undefined);\n if (previous !== undefined && state.presentation && state.presentation.revision < previous) {\n revision = 0;\n request('latest');\n return;\n }\n for (const event of state.presentation?.events ?? []) {\n if (loading || pages.length === 0) {\n if (event.sequence <= revision || event.sequence <= (buffered.at(-1)?.sequence ?? -1)) continue;\n buffered.push(event);\n if (buffered.length > MAX_BUFFER) {\n overflow = true;\n buffered = buffered.slice(-MAX_BUFFER);\n }\n } else apply(event);\n }\n },\n dispose() {\n disposed = true;\n unbind();\n pages = [];\n buffered = [];\n },\n };\n}\n"],"mappings":";;AAmBA,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,aAAa;;AAInB,SAAgB,sBACd,WACA,SACA,SACA,SACA,eAAyD,CAAC,GAC1D;CACA,IAAI,QAA0B,CAAC;CAC/B,IAAI,WAAW;CACf,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI,WAAW;CACf,IAAI,gBAAgB;CACpB,IAAI,WAA4B,CAAC;CACjC,IAAI;CACJ,IAAI,SAAmC,CAAC;CACxC,MAAM,QAAQ,OAAgC,SAAS,UAAU,QAAQ,WAAW,OAAO,MAAM;CACjG,MAAM,iBAAiB,MAAM,GAAG,EAAE,CAAC,EAAE,gBAAgB;CACrD,MAAM,gBAAgB;EACpB,MAAM,UAAU,YAAY,IAAI;EAChC,0BAA0B,SAAS;EACnC,mBAAmB,SAAS;EAC5B,IAAI;GACF,kBAAkB,SAAS;GAC3B,KAAK,MAAM,SAAS,MAAM,EAAE,EAAE,WAAW,CAAC,GAAG,KAAK;IAAE,MAAM;IAAkB;GAAM,GAAG,IAAI;GACzF,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM,SAAS,KAAK,SAAS,KAAK;IAAE,MAAM;IAAkB;GAAM,GAAG,IAAI;GAExG,KAAK,MAAM,SAAS,aAAa,cAAc,eAAe,CAAC,GAAG,KAAK,MAAM,OAAO,IAAI;GACxF,IAA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QAAQ;QAC5F,KAAK;IAAE,MAAM;IAAS,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE,CAAC;EAC9F,CAAC;EACD,OAAO;CACT;CACA,MAAM,SAAS,kBAAkB,WAAW,eAAe,MAAM,SAAS,CAAC;CAC3E,OAAO;EACL,kBAAkB,KAAK,QAAQ;EAC/B,QAAQ,OAA4B;GAClC,MAAM,WAAW,aAAa,cAAc;GAC5C,MAAM,WAAW,MAAM,SAAS,aAAa;GAC7C,IAAI,CAAC,eAAe,cAAc,YAAY,SAAS,aAAa,OAClE,KAAK;IAAE,MAAM;IAAqB,SAAS;GAAS,CAAC;GAEvD,MAAM,SAAS,MAAM,SAAS,WAAW;GACzC,IAAI,CAAC,eAAe,YAAY,YAAY,SAAS,WAAW,OAC9D,KAAK;IAAE,MAAM;IAAsB;GAAO,CAAC;GAE7C,cAAc;GACd,IAAI,MAAM,SAAS,WAAW,sBAAsB,WAAW,MAAM,SAAS,WAAW,aAAa,KAAA,CAAS;GAC/G,IAAI,aAAa,KAAA,KAAa,MAAM,gBAAgB,MAAM,aAAa,WAAW,UAAU;IAC1F,WAAW;IACX,QAAQ,QAAQ;IAChB;GACF;GACA,KAAK,MAAM,SAAS,MAAM,cAAc,UAAU,CAAC,GACjD,IAAI,WAAW,MAAM,WAAW,GAAG;IACjC,IAAI,MAAM,YAAY,YAAY,MAAM,aAAa,SAAS,GAAG,EAAE,CAAC,EAAE,YAAY,KAAK;IACvF,SAAS,KAAK,KAAK;IACnB,IAAI,SAAS,SAAS,YAAY;KAChC,WAAW;KACX,WAAW,SAAS,MAAM,IAAW;IACvC;GACF,OAAO,MAAM,KAAK;EAEtB;EACA,UAAU;GACR,WAAW;GACX,OAAO;GACP,QAAQ,CAAC;GACT,WAAW,CAAC;EACd;CACF;AACF"}
1
+ {"version":3,"file":"pagedTranscriptStore.mjs","names":[],"sources":["../../../src/web/stores/pagedTranscriptStore.ts"],"sourcesContent":["import type {\n ProtocolEvent,\n SessionLive,\n SessionService,\n SessionServiceState,\n TranscriptPage,\n} from '@agimon-ai/po-core/sessionProtocol';\nimport { type Context } from '@earendil-works/chord';\n\nimport type { BrowserPerformanceEvent } from '../lib/browserTelemetry';\nimport { hasSessionProtocol } from '../lib/sessionProtocolCommands';\nimport {\n applySessionLifecycle,\n bindHistoryReader,\n resetSessionStore,\n refreshSessionSelection,\n beginSessionReplay,\n endSessionReplay,\n releaseProtocolTranscript,\n setHasNewerHistory,\n setSessionStreamed,\n} from './sessionStore';\n\nconst MAX_PAGES = 5;\nconst PAGE_SIZE = 100;\nconst MAX_BUFFER = 512;\ntype Direction = 'older' | 'newer' | 'latest';\n\n/** A bounded history window with a separate live event subscription. */\nexport function createPagedTranscript(\n sessionId: string,\n service: Pick<SessionService, 'readTranscriptPage'>,\n onFrame: (sessionId: string, frame: Record<string, unknown>, replay: boolean) => void,\n context: Context,\n record: (event: BrowserPerformanceEvent) => void = () => {},\n) {\n let pages: TranscriptPage[] = [];\n let revision = 0;\n let loading = false;\n let disposed = false;\n let overflow = false;\n let reloadPending = false;\n let buffered: ProtocolEvent[] = [];\n let latestState: SessionServiceState | undefined;\n const emit = (frame: Record<string, unknown>, replay = false) => onFrame(sessionId, frame, replay);\n const atLatest = () => pages.at(-1)?.newerCursor === null;\n // `live` holds whole values, so each change folds in as one replacing frame.\n const emitLive = (live: SessionLive | undefined, previous: SessionLive | undefined, replay: boolean) => {\n if (live?.message && live.message !== previous?.message)\n emit({ type: 'message_update', message: live.message }, replay);\n for (const tool of Object.values(live?.tools ?? {})) {\n if (replay)\n emit(\n { type: 'tool_execution_start', toolCallId: tool.toolCallId, toolName: tool.toolName, args: tool.args },\n true,\n );\n if (tool.partialResult && tool.partialResult !== previous?.tools[tool.toolCallId]?.partialResult)\n emit({ type: 'tool_execution_update', toolCallId: tool.toolCallId, partialResult: tool.partialResult }, replay);\n }\n };\n const rebuild = () => {\n const started = performance.now();\n releaseProtocolTranscript(sessionId);\n beginSessionReplay(sessionId);\n try {\n resetSessionStore(sessionId);\n for (const entry of pages[0]?.context ?? []) emit({ type: 'entry_appended', entry }, true);\n for (const page of pages) for (const entry of page.entries) emit({ type: 'entry_appended', entry }, true);\n // Current projections win over historical configuration in the transcript page.\n for (const event of latestState?.presentation?.projections ?? []) emit(event.frame, true);\n if (atLatest()) emitLive(latestState?.live, undefined, true);\n if (latestState?.snapshot.lifecycle) applySessionLifecycle(sessionId, latestState.snapshot.lifecycle);\n else if (latestState?.live?.phase === 'turn') emit({ type: 'agent_start' }, true);\n setHasNewerHistory(sessionId, !atLatest());\n } finally {\n endSessionReplay(sessionId);\n record({\n name: 'web.browser.transcript_render',\n duration_ms: performance.now() - started,\n count: pages.reduce((count, page) => count + page.entries.length, 0),\n });\n }\n };\n const apply = (event: ProtocolEvent) => {\n if (event.sequence <= revision) return;\n if (revision > 0 && event.sequence > revision + 1) {\n request('latest');\n return;\n }\n revision = event.sequence;\n const frame = event.frame;\n if (frame.type === 'navigation_end' || frame.type === 'message_end') {\n if (frame.type === 'message_end') emit(frame);\n request('latest');\n return;\n }\n if (\n !atLatest() &&\n [\n 'message_start',\n 'message_update',\n 'message_end',\n 'entry_appended',\n 'tool_execution_start',\n 'tool_execution_update',\n 'tool_execution_end',\n 'agent_settled',\n ].includes(frame.type)\n )\n return;\n if (\n frame.type === 'entry_appended' &&\n frame.entry &&\n typeof frame.entry === 'object' &&\n !Array.isArray(frame.entry)\n ) {\n const entry = frame.entry;\n if (\n !pages.some((page) =>\n page.entries.some((item) => item && typeof item === 'object' && !Array.isArray(item) && item.id === entry.id),\n )\n ) {\n let tail = pages.at(-1);\n if (tail && tail.entries.length >= PAGE_SIZE) {\n const identity = [...tail.context, ...tail.entries].findLast(\n (item) =>\n item && typeof item === 'object' && !Array.isArray(item) && item.customType === 'po-profile-identity',\n );\n tail = {\n ...tail,\n context: identity ? [identity] : [],\n entries: [],\n olderCursor: tail.endCursor,\n startCursor: null,\n };\n pages.push(tail);\n if (pages.length > MAX_PAGES) pages.shift();\n }\n if (tail) {\n tail.entries.push(entry);\n tail.endCursor = typeof frame.transcriptCursor === 'string' ? frame.transcriptCursor : tail.endCursor;\n tail.startCursor ??= tail.endCursor;\n }\n }\n }\n emit(frame);\n };\n const load = async (direction: Direction): Promise<void> => {\n loading = true;\n const cursor = direction === 'older' ? pages[0]?.olderCursor : pages.at(-1)?.newerCursor;\n try {\n const started = performance.now();\n const page = await service.readTranscriptPage(\n direction === 'latest' ? {} : { cursor: cursor!, direction },\n context,\n );\n record({\n name: 'web.browser.transcript_page',\n duration_ms: performance.now() - started,\n count: page.entries.length,\n });\n if (disposed) return;\n if (direction === 'latest') pages = [page];\n else if (direction === 'older') {\n pages.unshift(page);\n if (pages.length > MAX_PAGES) {\n pages.pop();\n const tail = pages.at(-1)!;\n tail.newerCursor = tail.endCursor;\n }\n } else {\n pages.push(page);\n if (pages.length > MAX_PAGES) {\n pages.shift();\n pages[0]!.olderCursor = pages[0]!.startCursor;\n }\n }\n if (direction !== 'latest') for (const event of buffered) if (event.sequence <= page.revision) apply(event);\n revision = Math.max(revision, page.revision);\n rebuild();\n setSessionStreamed(sessionId, true);\n if (hasSessionProtocol(sessionId)) void refreshSessionSelection(sessionId);\n } finally {\n loading = false;\n const events = buffered;\n buffered = [];\n if (!disposed) {\n if (overflow || reloadPending) {\n overflow = false;\n reloadPending = false;\n request('latest');\n } else for (const event of events) apply(event);\n }\n }\n };\n const request = (direction: Direction): boolean => {\n if (disposed) return false;\n if (loading) {\n if (direction === 'latest') reloadPending = true;\n return false;\n }\n if (direction === 'older' && !pages[0]?.olderCursor) return false;\n if (direction === 'newer' && !pages.at(-1)?.newerCursor) return false;\n void load(direction).catch((error: unknown) => {\n if (disposed) return;\n if (String(error).includes('STALE_TRANSCRIPT_CURSOR') && direction !== 'latest') request('latest');\n else emit({ type: 'error', message: error instanceof Error ? error.message : String(error) });\n });\n return true;\n };\n const unbind = bindHistoryReader(sessionId, request, () => pages.length > 0);\n return {\n initialize: () => load('latest'),\n publish(state: SessionServiceState) {\n const previous = latestState?.presentation?.revision;\n const fastMode = state.snapshot.fastMode === true;\n if (!latestState || fastMode !== (latestState.snapshot.fastMode === true)) {\n emit({ type: 'fast_mode_changed', enabled: fastMode });\n }\n const locked = state.snapshot.locked === true;\n if (!latestState || locked !== (latestState.snapshot.locked === true)) {\n emit({ type: 'agent_lock_changed', locked });\n }\n const previousLive = latestState?.live;\n latestState = state;\n if (state.snapshot.lifecycle) applySessionLifecycle(sessionId, state.snapshot.lifecycle, previous === undefined);\n if (previous !== undefined && state.presentation && state.presentation.revision < previous) {\n revision = 0;\n request('latest');\n return;\n }\n for (const event of state.presentation?.events ?? []) {\n if (loading || pages.length === 0) {\n if (event.sequence <= revision || event.sequence <= (buffered.at(-1)?.sequence ?? -1)) continue;\n buffered.push(event);\n if (buffered.length > MAX_BUFFER) {\n overflow = true;\n buffered = buffered.slice(-MAX_BUFFER);\n }\n } else apply(event);\n }\n if (!loading && pages.length > 0 && atLatest()) emitLive(state.live, previousLive, false);\n },\n dispose() {\n disposed = true;\n setSessionStreamed(sessionId, false);\n unbind();\n pages = [];\n buffered = [];\n },\n };\n}\n"],"mappings":";;;AAuBA,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,aAAa;;AAInB,SAAgB,sBACd,WACA,SACA,SACA,SACA,eAAyD,CAAC,GAC1D;CACA,IAAI,QAA0B,CAAC;CAC/B,IAAI,WAAW;CACf,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI,WAAW;CACf,IAAI,gBAAgB;CACpB,IAAI,WAA4B,CAAC;CACjC,IAAI;CACJ,MAAM,QAAQ,OAAgC,SAAS,UAAU,QAAQ,WAAW,OAAO,MAAM;CACjG,MAAM,iBAAiB,MAAM,GAAG,EAAE,CAAC,EAAE,gBAAgB;CAErD,MAAM,YAAY,MAA+B,UAAmC,WAAoB;EACtG,IAAI,MAAM,WAAW,KAAK,YAAY,UAAU,SAC9C,KAAK;GAAE,MAAM;GAAkB,SAAS,KAAK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AAE,YAAY,KAAK;IACvF,SAAS,KAAK,KAAK;IACnB,IAAI,SAAS,SAAS,YAAY;KAChC,WAAW;KACX,WAAW,SAAS,MAAM,IAAW;IACvC;GACF,OAAO,MAAM,KAAK;GAEpB,IAAI,CAAC,WAAW,MAAM,SAAS,KAAK,SAAS,GAAG,SAAS,MAAM,MAAM,cAAc,KAAK;EAC1F;EACA,UAAU;GACR,WAAW;GACX,mBAAmB,WAAW,KAAK;GACnC,OAAO;GACP,QAAQ,CAAC;GACT,WAAW,CAAC;EACd;CACF;AACF"}
@@ -1,8 +1,10 @@
1
1
  const require_commands = require("../lib/commands.cjs");
2
2
  const require_hub = require("../../types/hub.cjs");
3
+ const require_sessionProtocolCommands = require("../lib/sessionProtocolCommands.cjs");
3
4
  const require_transport = require("../lib/transport.cjs");
4
5
  const require_sessionModel = require("../lib/sessionModel.cjs");
5
6
  const require_sessionsStore = require("./sessionsStore.cjs");
7
+ const require_sessionSelectionApi = require("../lib/sessionSelectionApi.cjs");
6
8
  let _tanstack_store = require("@tanstack/store");
7
9
  let _tanstack_react_store = require("@tanstack/react-store");
8
10
  //#region src/web/stores/sessionStore.ts
@@ -13,6 +15,36 @@ let _tanstack_react_store = require("@tanstack/react-store");
13
15
  * subscribed to; the rail runs on hub summaries alone.
14
16
  */
15
17
  const stores = /* @__PURE__ */ new Map();
18
+ const selectionRequests = /* @__PURE__ */ new Map();
19
+ const selectionVersions = /* @__PURE__ */ new Map();
20
+ const SELECTION_STATUS_KEYS = /* @__PURE__ */ new Set([
21
+ "po-major-mode",
22
+ "po-domain",
23
+ "po-profile"
24
+ ]);
25
+ /** Newer reads and live projections supersede each independently fetched part. */
26
+ async function refreshSessionSelection(sessionId) {
27
+ const token = {};
28
+ selectionRequests.set(sessionId, token);
29
+ const versions = selectionVersions.get(sessionId) ?? {
30
+ selection: 0,
31
+ context: 0,
32
+ minor: 0
33
+ };
34
+ selectionVersions.set(sessionId, versions);
35
+ const before = { ...versions };
36
+ const answer = await require_sessionSelectionApi.fetchSessionSelection(sessionId);
37
+ if (selectionRequests.get(sessionId) !== token) return;
38
+ selectionRequests.delete(sessionId);
39
+ if (before.selection !== versions.selection) {
40
+ delete answer.majorMode;
41
+ delete answer.domains;
42
+ delete answer.profile;
43
+ }
44
+ if (before.context !== versions.context) delete answer.context;
45
+ if (before.minor !== versions.minor) delete answer.minorModes;
46
+ sessionStoreFor(sessionId).setState((state) => require_sessionModel.applySelectionAnswer(state, answer));
47
+ }
16
48
  const MAX_CACHED_ENTRIES = 500;
17
49
  function setHasNewerHistory(sessionId, value) {
18
50
  sessionStoreFor(sessionId).setState((state) => state.hasNewerHistory === value ? state : {
@@ -31,6 +63,17 @@ const PROTOCOL_ENTRY_KINDS = /* @__PURE__ */ new Set([
31
63
  ]);
32
64
  /** Read-only stand-in while no session is focused, so hooks stay unconditional. */
33
65
  const detachedStore = new _tanstack_store.Store(require_sessionModel.initialSessionState);
66
+ /** Sessions a live transcript stream currently feeds; any other store may hold stale facts. */
67
+ const streamedSessions = new _tanstack_store.Store(/* @__PURE__ */ new Set());
68
+ function setSessionStreamed(sessionId, streamed) {
69
+ if (streamedSessions.state.has(sessionId) === streamed) return;
70
+ streamedSessions.setState((state) => {
71
+ const next = new Set(state);
72
+ if (streamed) next.add(sessionId);
73
+ else next.delete(sessionId);
74
+ return next;
75
+ });
76
+ }
34
77
  function isRecord(value) {
35
78
  return typeof value === "object" && value !== null && !Array.isArray(value);
36
79
  }
@@ -61,6 +104,22 @@ function projectionKey(frame) {
61
104
  }
62
105
  /** Presentation frames from the Pi protocol, or from bounded replay when replay is true. */
63
106
  function applySessionFrame(sessionId, frame, options = {}) {
107
+ if (!options.replay) {
108
+ const versions = selectionVersions.get(sessionId) ?? {
109
+ selection: 0,
110
+ context: 0,
111
+ minor: 0
112
+ };
113
+ selectionVersions.set(sessionId, versions);
114
+ if (frame.type === "extension_ui_request" && frame.method === "setStatus" && SELECTION_STATUS_KEYS.has(String(frame.statusKey))) versions.selection++;
115
+ if (frame.type === "entry_appended" && isRecord(frame.entry) && frame.entry.type === "custom") {
116
+ if (frame.entry.customType === "po-context") {
117
+ versions.context++;
118
+ versions.selection++;
119
+ }
120
+ if (frame.entry.customType === "po-minor-modes") versions.minor++;
121
+ }
122
+ }
64
123
  const projection = projectionKey(frame);
65
124
  const guard = replayGuards.get(sessionId);
66
125
  if (projection !== void 0 && guard !== void 0) {
@@ -303,6 +362,8 @@ function endSessionReplay(sessionId) {
303
362
  replayGuards.delete(sessionId);
304
363
  }
305
364
  function resetSessionStore(sessionId, options = {}) {
365
+ selectionRequests.delete(sessionId);
366
+ selectionVersions.delete(sessionId);
306
367
  const guard = replayGuards.get(sessionId);
307
368
  const preservePages = options.source === "hub" && hasReadyHistoryReader(sessionId);
308
369
  sessionStoreFor(sessionId).setState((state) => {
@@ -313,9 +374,11 @@ function resetSessionStore(sessionId, options = {}) {
313
374
  stats: state.stats,
314
375
  commands: state.commands,
315
376
  models: state.models,
316
- thinkingLevels: state.thinkingLevels
377
+ thinkingLevels: state.thinkingLevels,
378
+ context: state.context,
379
+ minorModes: state.minorModes
317
380
  };
318
- const preservedStatuses = guard === void 0 ? {} : Object.fromEntries(Object.entries(state.statuses).filter(([key]) => guard.statuses.has(key)));
381
+ const preservedStatuses = Object.fromEntries(Object.entries(state.statuses).filter(([key]) => SELECTION_STATUS_KEYS.has(key) || guard?.statuses.has(key)));
319
382
  const preservedWidgets = guard === void 0 ? [] : state.widgets.filter((key) => guard.widgets.has(key));
320
383
  if (preservePages) return {
321
384
  ...state,
@@ -348,18 +411,30 @@ function resetSessionStore(sessionId, options = {}) {
348
411
  });
349
412
  }
350
413
  function dropSessionStore(sessionId) {
414
+ selectionRequests.delete(sessionId);
415
+ selectionVersions.delete(sessionId);
351
416
  stores.delete(sessionId);
352
417
  protocolTranscripts.delete(sessionId);
353
418
  replayGuards.delete(sessionId);
354
419
  }
355
420
  function resetSessionStores() {
421
+ selectionRequests.clear();
422
+ selectionVersions.clear();
356
423
  stores.clear();
357
424
  protocolTranscripts.clear();
358
425
  replayGuards.clear();
426
+ streamedSessions.setState(() => /* @__PURE__ */ new Set());
359
427
  detachedStore.setState(() => require_sessionModel.initialSessionState);
360
428
  }
361
- /** Asks for the facts the cockpit shows but Pi only reports on request. */
429
+ /**
430
+ * Asks for the facts the cockpit shows but Pi only reports on request.
431
+ *
432
+ * A session with no live protocol is skipped: it asks for these itself when it
433
+ * connects, and a caller refreshing every listed session (after a settings save,
434
+ * say) must not fail on one that is not open.
435
+ */
362
436
  function refreshSessionFacts(sessionId) {
437
+ if (!require_sessionProtocolCommands.hasSessionProtocol(sessionId)) return;
363
438
  require_transport.sendFrame(sessionId, require_commands.getStateCommand());
364
439
  require_transport.sendFrame(sessionId, require_commands.getSessionStatsCommand());
365
440
  require_transport.sendFrame(sessionId, require_commands.getCommandsCommand());
@@ -584,6 +659,7 @@ exports.promoteQueuedMessage = promoteQueuedMessage;
584
659
  exports.queueFollowUp = queueFollowUp;
585
660
  exports.queueFollowUpWithAck = queueFollowUpWithAck;
586
661
  exports.refreshSessionFacts = refreshSessionFacts;
662
+ exports.refreshSessionSelection = refreshSessionSelection;
587
663
  exports.refreshSessionStats = refreshSessionStats;
588
664
  exports.releaseProtocolTranscript = releaseProtocolTranscript;
589
665
  exports.renameSession = renameSession;
@@ -602,6 +678,8 @@ exports.selectThinkingLevel = selectThinkingLevel;
602
678
  exports.sessionStoreFor = sessionStoreFor;
603
679
  exports.setAgentLock = setAgentLock;
604
680
  exports.setHasNewerHistory = setHasNewerHistory;
681
+ exports.setSessionStreamed = setSessionStreamed;
682
+ exports.streamedSessions = streamedSessions;
605
683
  exports.submitMessage = submitMessage;
606
684
  exports.submitMessageWithAck = submitMessageWithAck;
607
685
  exports.useActiveSession = useActiveSession;
@@ -1 +1 @@
1
- {"version":3,"file":"sessionStore.cjs","names":["Store","initialSessionState","useStore","sessionsStore","reduceSession","HISTORY_REQUEST_TYPE","prependHistory","replaceQueuedEntries","getStateCommand","getSessionStatsCommand","getCommandsCommand","activeSessionId","getAvailableModelsCommand","getAvailableThinkingLevelsCommand","setModelCommand","setThinkingLevelCommand","builtinCommandFrame","appendUserPrompt","isSupportedImageMimeType","steerCommand","promptCommand","sendFrameWithAck","rewindCommand","enqueueAutomaticCommand","clearQueueCommand","removeQueuedCommand","promoteQueuedCommand","resumeQueueCommand","setSessionNameCommand","abortCommand","dialogValue","clearDialog","dialogConfirmed","dialogCancelled"],"sources":["../../../src/web/stores/sessionStore.ts"],"sourcesContent":["import type { SessionLifecycle } from '@agimon-ai/po-core/sessionProtocol';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport { HISTORY_REQUEST_TYPE } from '../../types/hub';\nimport {\n abortCommand,\n builtinCommandFrame,\n clearQueueCommand,\n dialogCancelled,\n dialogConfirmed,\n dialogValue,\n enqueueAutomaticCommand,\n promoteQueuedCommand,\n removeQueuedCommand,\n resumeQueueCommand,\n getAvailableModelsCommand,\n getAvailableThinkingLevelsCommand,\n getCommandsCommand,\n getSessionStatsCommand,\n getStateCommand,\n promptCommand,\n type RpcImage,\n rewindCommand,\n setModelCommand,\n setSessionNameCommand,\n setThinkingLevelCommand,\n steerCommand,\n} from '../lib/commands';\nimport {\n appendUserPrompt,\n clearDialog,\n isSupportedImageMimeType,\n initialSessionState,\n prependHistory,\n reduceSession,\n replaceQueuedEntries,\n type QueuedEntry,\n type SessionState,\n type TimelineEntry,\n} from '../lib/sessionModel';\nimport { sendFrame, sendFrameWithAck, sendHubFrame } from '../lib/transport';\nimport { activeSessionId, sessionsStore } from './sessionsStore';\n\n/**\n * One store per session, created on first touch.\n *\n * The heavyweight timeline state only exists for sessions this page has\n * subscribed to; the rail runs on hub summaries alone.\n */\nconst stores = new Map<string, Store<SessionState>>();\nconst MAX_CACHED_ENTRIES = 500;\n\nexport function setHasNewerHistory(sessionId: string, value: boolean): void {\n sessionStoreFor(sessionId).setState((state) =>\n state.hasNewerHistory === value ? state : { ...state, hasNewerHistory: value },\n );\n}\n/** Sessions whose visible transcript is currently supplied by Pi's protocol. */\nconst protocolTranscripts = new Set<string>();\n/** Projection keys changed after a subscription snapshot was requested. */\nconst replayGuards = new Map<string, { statuses: Set<string>; widgets: Set<string> }>();\nconst PROTOCOL_ENTRY_KINDS = new Set<TimelineEntry['kind']>(['user', 'assistant', 'tool']);\n/** Read-only stand-in while no session is focused, so hooks stay unconditional. */\nconst detachedStore = new Store<SessionState>(initialSessionState);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function sessionStoreFor(sessionId: string | null): Store<SessionState> {\n if (sessionId === null) return detachedStore;\n const existing = stores.get(sessionId);\n if (existing) return existing;\n const created = new Store<SessionState>(initialSessionState);\n stores.set(sessionId, created);\n return created;\n}\n\n/** Reads the focused session's state; components stay on the useStore idiom. */\nexport function useActiveSession<T>(selector: (state: SessionState) => T): T {\n const activeId = useStore(sessionsStore, (state) => state.activeId);\n return useStore(sessionStoreFor(activeId), selector);\n}\n\nfunction projectionKey(frame: Record<string, unknown>): { kind: 'status' | 'widget'; key: string } | undefined {\n const projected = frame.type === 'replay' && isRecord(frame.frame) ? frame.frame : frame;\n if (projected.type !== 'extension_ui_request') return undefined;\n if (typeof projected.statusKey === 'string' && projected.method === 'setStatus') {\n return { kind: 'status', key: projected.statusKey };\n }\n if (typeof projected.widgetKey === 'string' && projected.method === 'setWidget') {\n return { kind: 'widget', key: projected.widgetKey };\n }\n return undefined;\n}\n\n/** Presentation frames from the Pi protocol, or from bounded replay when replay is true. */\nexport function applySessionFrame(\n sessionId: string,\n frame: Record<string, unknown>,\n options: { replay?: boolean; source?: 'hub' } = {},\n): void {\n const projection = projectionKey(frame);\n const guard = replayGuards.get(sessionId);\n if (projection !== undefined && guard !== undefined) {\n const keys = projection.kind === 'status' ? guard.statuses : guard.widgets;\n if (options.replay && keys.has(projection.key)) return;\n if (!options.replay) keys.add(projection.key);\n }\n // The presentation stream owns live and replay projection until the typed session\n // service publishes a snapshot. Once it does, only Po-specific frames reduce here.\n const transcriptFromProtocol =\n protocolTranscripts.has(sessionId) || (options.source === 'hub' && hasReadyHistoryReader(sessionId));\n sessionStoreFor(sessionId).setState((state) => {\n const next = reduceSession(state, frame, { transcriptFromProtocol });\n if (!historyReaders.has(sessionId)) return next;\n return {\n ...next,\n entries: next.entries.length > MAX_CACHED_ENTRIES ? next.entries.slice(-MAX_CACHED_ENTRIES) : next.entries,\n restoredIds:\n next.restoredIds.length > MAX_CACHED_ENTRIES ? next.restoredIds.slice(-MAX_CACHED_ENTRIES) : next.restoredIds,\n };\n });\n}\n\n/** Lets the presentation stream resume transcript ownership after a typed service failure. */\nexport function releaseProtocolTranscript(sessionId: string): void {\n protocolTranscripts.delete(sessionId);\n}\n\n/** A thread has no protocol session, so its journal remains its authoritative transcript. */\nexport function applyThreadFrame(threadKey: string, frame: Record<string, unknown>): void {\n sessionStoreFor(threadKey).setState((state) => reduceSession(state, frame));\n}\n\n/**\n * One session's paging state: how far back the page has read, and whether a\n * request is already in flight. Kept beside the timeline rather than inside it\n * because it describes the reading, not the session.\n */\ninterface HistoryState {\n cursor: string | null;\n hasMore: boolean;\n loading: boolean;\n /** Pages taken so far; also what keeps prepended entry ids unique. */\n pages: number;\n}\n\nconst history = new Map<string, HistoryState>();\nconst historyReaders = new Map<\n string,\n {\n read: (direction: 'older' | 'newer' | 'latest') => boolean;\n ready: () => boolean;\n }\n>();\n\nfunction hasReadyHistoryReader(sessionId: string): boolean {\n return historyReaders.get(sessionId)?.ready() === true;\n}\n\nexport function bindHistoryReader(\n sessionId: string,\n reader: (direction: 'older' | 'newer' | 'latest') => boolean,\n ready: () => boolean = () => false,\n): () => void {\n const binding = { read: reader, ready };\n historyReaders.set(sessionId, binding);\n return () => {\n if (historyReaders.get(sessionId) === binding) historyReaders.delete(sessionId);\n };\n}\n\nexport function requestNewerHistory(sessionId: string | null): boolean {\n return sessionId !== null && (historyReaders.get(sessionId)?.read('newer') ?? false);\n}\n\nexport function requestLatestHistory(sessionId: string | null): boolean {\n return sessionId !== null && (historyReaders.get(sessionId)?.read('latest') ?? false);\n}\nconst historyStore = new Store<Record<string, HistoryState>>({});\nconst NO_HISTORY: HistoryState = { cursor: null, hasMore: true, loading: false, pages: 0 };\n\nfunction historyFor(sessionId: string): HistoryState {\n return history.get(sessionId) ?? NO_HISTORY;\n}\n\nfunction setHistory(sessionId: string, next: HistoryState): void {\n history.set(sessionId, next);\n historyStore.setState((state) => ({ ...state, [sessionId]: next }));\n}\n\n/** Whether more transcript exists above what this session's page holds. */\nexport function useHasOlderHistory(sessionId: string | null): boolean {\n return useStore(historyStore, (state) => (sessionId === null ? false : (state[sessionId] ?? NO_HISTORY).hasMore));\n}\n\n/**\n * Asks the hub for the window above what this page holds.\n *\n * One request at a time: a reader flicking upwards would otherwise ask for the\n * same window repeatedly before the first answer lands, and every copy would\n * be prepended.\n */\nexport function requestOlderHistory(sessionId: string | null): boolean {\n if (sessionId === null) return false;\n const reader = historyReaders.get(sessionId);\n if (reader) return reader.read('older');\n const current = historyFor(sessionId);\n if (current.loading || !current.hasMore) return false;\n setHistory(sessionId, { ...current, loading: true });\n sendHubFrame({\n type: HISTORY_REQUEST_TYPE,\n sessionId,\n ...(current.cursor === null ? {} : { before: current.cursor }),\n });\n return true;\n}\n\n/** Folds one answered window above the timeline and records how far back it reached. */\nexport function applyHistoryPage(sessionId: string, frames: Record<string, unknown>[], next: HistoryPage): void {\n const current = historyFor(sessionId);\n const pages = current.pages + 1;\n sessionStoreFor(sessionId).setState((state) => prependHistory(state, frames, pages));\n setHistory(sessionId, { cursor: next.cursor, hasMore: next.hasMore, loading: false, pages });\n}\n\nexport interface HistoryPage {\n cursor: string | null;\n hasMore: boolean;\n}\n\n/** The oldest entry the page holds, which is where the next window ends. */\nexport function seedHistoryCursor(sessionId: string, cursor: string | null): void {\n setHistory(sessionId, { ...NO_HISTORY, cursor });\n}\n\n/** Keeps Po-only and optimistic entries beside the protocol items that preceded them. */\nfunction mergeProtocolEntries(\n previous: TimelineEntry[],\n protocol: TimelineEntry[],\n pendingUserIds: ReadonlySet<string>,\n reconciledUserIds: ReadonlySet<string>,\n): TimelineEntry[] {\n const localByAnchor = new Map<string | null, TimelineEntry[]>();\n let anchor: string | null = null;\n for (const entry of previous) {\n const protocolOwned =\n (PROTOCOL_ENTRY_KINDS.has(entry.kind) || reconciledUserIds.has(entry.id)) && !pendingUserIds.has(entry.id);\n if (protocolOwned) {\n anchor = entry.id;\n continue;\n }\n const local = localByAnchor.get(anchor) ?? [];\n local.push(entry);\n localByAnchor.set(anchor, local);\n }\n\n const merged = [...(localByAnchor.get(null) ?? [])];\n const used = new Set<string | null>([null]);\n for (const entry of protocol) {\n merged.push(entry, ...(localByAnchor.get(entry.id) ?? []));\n used.add(entry.id);\n }\n for (const [entryAnchor, local] of localByAnchor) {\n if (!used.has(entryAnchor)) merged.push(...local);\n }\n return merged;\n}\n\n/**\n * Replaces protocol-owned transcript items with the authoritative snapshot.\n *\n * Local echoes disappear when the protocol publishes them. Po-only entries,\n * such as notices, queued messages, and run dividers, retain their place beside\n * the protocol item that preceded them.\n */\nexport function applyProtocolTranscript(sessionId: string, entries: TimelineEntry[], streaming: boolean): void {\n protocolTranscripts.add(sessionId);\n sessionStoreFor(sessionId).setState((state) => {\n const pendingUserEntries = [...state.pendingUserEntries];\n const pendingUserIdsBeforeReconciliation = new Set(pendingUserEntries.map((pending) => pending.id));\n const knownProtocolIds = new Set(\n state.entries\n .filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind) && !pendingUserIdsBeforeReconciliation.has(entry.id))\n .map((entry) => entry.id),\n );\n const protocolUserEntryIds = { ...state.protocolUserEntryIds };\n const normalizedEntries = [...entries];\n // Claimed prompts are remembered rather than dropped: the journal reports\n // the same message on its own channel, and that copy has to fold into this\n // entry instead of arriving as a new one.\n const reconciledUserEntries = [...state.reconciledUserEntries];\n\n // Work backwards so repeated text binds to the newest matching prompt. The\n // local id keeps React from mounting the same message again when Pi publishes\n // its authoritative transcript copy at the end of a run.\n for (let index = entries.length - 1; index >= 0; index -= 1) {\n const entry = entries[index];\n if (entry?.kind !== 'user') continue;\n const localId = protocolUserEntryIds[entry.id];\n if (localId !== undefined) {\n normalizedEntries[index] = { ...entry, id: localId };\n continue;\n }\n if (knownProtocolIds.has(entry.id)) continue;\n const pendingIndex = pendingUserEntries.findLastIndex((pending) => pending.text === entry.text);\n if (pendingIndex === -1) continue;\n const [pending] = pendingUserEntries.splice(pendingIndex, 1);\n if (pending === undefined) continue;\n protocolUserEntryIds[entry.id] = pending.id;\n reconciledUserEntries.push(pending);\n normalizedEntries[index] = { ...entry, id: pending.id };\n }\n\n const pendingUserIds = new Set(pendingUserEntries.map((pending) => pending.id));\n const reconciledUserIds = new Set(Object.values(protocolUserEntryIds));\n return {\n ...state,\n entries: mergeProtocolEntries(state.entries, normalizedEntries, pendingUserIds, reconciledUserIds),\n streaming: state.lifecycle === null ? streaming : state.lifecycle.operation !== null,\n settled: state.lifecycle === null ? !streaming : state.lifecycle.operation === null,\n pendingUserEntries,\n reconciledUserEntries,\n protocolUserEntryIds,\n };\n });\n}\n\nfunction protocolQueueMatches(state: SessionState, queue: readonly QueuedEntry[]): boolean {\n const current = state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued');\n return (\n current.length === queue.length &&\n current.every((entry, index) => {\n const next = queue[index];\n if (\n next === undefined ||\n entry.id !== next.id ||\n entry.text !== next.text ||\n entry.delivery !== next.delivery ||\n entry.scheduling !== next.scheduling ||\n entry.disposition !== next.disposition\n )\n return false;\n const images = entry.images ?? [];\n const nextImages = next.images ?? [];\n return (\n images.length === nextImages.length &&\n images.every((image, imageIndex) => {\n const nextImage = nextImages[imageIndex];\n return nextImage !== undefined && image.data === nextImage.data && image.mimeType === nextImage.mimeType;\n })\n );\n })\n );\n}\n\n/** Applies execution and retained-input state from the server, never from replayed history. */\nexport function applySessionLifecycle(sessionId: string, lifecycle: SessionLifecycle, newBinding = false): void {\n sessionStoreFor(sessionId).setState((state) => {\n const current = state.lifecycle;\n if (!newBinding && current !== null && lifecycle.revision < current.revision) return state;\n const queue: QueuedEntry[] = lifecycle.queue.map(({ id, text, images, delivery, scheduling, disposition }) => ({\n kind: 'queued',\n id,\n text,\n delivery,\n scheduling,\n disposition,\n ...(images === undefined ? {} : { images: images.map(({ data, mimeType }) => ({ data, mimeType })) }),\n }));\n const streaming = lifecycle.operation !== null;\n const updated = protocolQueueMatches(state, queue) ? state : replaceQueuedEntries(state, queue);\n return {\n ...updated,\n lifecycle,\n streaming,\n settled: !streaming,\n ...(state.agent === null ? {} : { agent: { ...state.agent, isStreaming: streaming } }),\n };\n });\n}\n\n/** Replaces composer queue rows with the protocol server's authoritative queue. */\nexport function applyProtocolQueue(sessionId: string, queue: readonly QueuedEntry[]): void {\n sessionStoreFor(sessionId).setState((state) =>\n protocolQueueMatches(state, queue) ? state : replaceQueuedEntries(state, queue),\n );\n}\n/** Marks the start of a subscription replay, so live projections beat an older snapshot. */\nexport function beginSessionReplay(sessionId: string): void {\n replayGuards.set(sessionId, { statuses: new Set(), widgets: new Set() });\n}\n\nexport function endSessionReplay(sessionId: string): void {\n replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStore(sessionId: string, options: { source?: 'hub' } = {}): void {\n const guard = replayGuards.get(sessionId);\n const preservePages = options.source === 'hub' && hasReadyHistoryReader(sessionId);\n sessionStoreFor(sessionId).setState((state) => {\n // Transcript pages do not contain facts returned by the session commands.\n // Keep those facts even when their response arrives before a page reload.\n const reset = {\n ...initialSessionState,\n agent: state.agent,\n lifecycle: state.lifecycle,\n stats: state.stats,\n commands: state.commands,\n models: state.models,\n thinkingLevels: state.thinkingLevels,\n };\n const preservedStatuses =\n guard === undefined\n ? {}\n : Object.fromEntries(Object.entries(state.statuses).filter(([key]) => guard.statuses.has(key)));\n const preservedWidgets = guard === undefined ? [] : state.widgets.filter((key) => guard.widgets.has(key));\n // A bounded hub backlog is not a canonical page. Keep durable entries,\n // their deduplication ids, and custom projections while replaying hub state.\n if (preservePages) return { ...state, statuses: preservedStatuses, widgets: preservedWidgets };\n if (!protocolTranscripts.has(sessionId)) {\n return {\n ...reset,\n statuses: preservedStatuses,\n widgets: preservedWidgets,\n };\n }\n // A legacy socket reconnect replays its backlog. Keep the protocol snapshot\n // visible while that replay rebuilds Po-only state around it.\n const entries = state.entries.filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind));\n return {\n ...reset,\n entries,\n statuses: preservedStatuses,\n widgets: preservedWidgets,\n streaming: state.streaming,\n settled: state.settled,\n pendingUserEntries: state.pendingUserEntries,\n reconciledUserEntries: state.reconciledUserEntries,\n protocolUserEntryIds: state.protocolUserEntryIds,\n };\n });\n if (preservePages) return;\n history.delete(sessionId);\n historyStore.setState((state) => {\n const { [sessionId]: _dropped, ...rest } = state;\n return rest;\n });\n}\n\nexport function dropSessionStore(sessionId: string): void {\n stores.delete(sessionId);\n protocolTranscripts.delete(sessionId);\n replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStores(): void {\n stores.clear();\n protocolTranscripts.clear();\n replayGuards.clear();\n detachedStore.setState(() => initialSessionState);\n}\n\n/** Asks for the facts the cockpit shows but Pi only reports on request. */\nexport function refreshSessionFacts(sessionId: string): void {\n sendFrame(sessionId, getStateCommand());\n sendFrame(sessionId, getSessionStatsCommand());\n sendFrame(sessionId, getCommandsCommand());\n}\n\n/**\n * Asks only for the usage figures, cheap enough to run once per message.\n *\n * `refreshSessionFacts` costs three round trips because it also re-reads the\n * state and the command list, and neither of those changes mid-turn.\n */\nexport function refreshSessionStats(sessionId: string): void {\n sendFrame(sessionId, getSessionStatsCommand());\n}\n\n/** Asks what the model picker lists; Pi's answer depends on the current model. */\nexport function loadModelChoices(sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, getAvailableModelsCommand());\n sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/**\n * Switches the model, then re-reads the facts Pi adjusts alongside it: the\n * thinking level gets clamped to what the new model accepts, and the level\n * list changes with it.\n */\nexport function selectModel(provider: string, modelId: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, setModelCommand(provider, modelId));\n sendFrame(sessionId, getStateCommand());\n sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/** Read back server state rather than optimistically enabling priority. */\nexport function selectFastMode(enabled: boolean, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n const agent = sessionStoreFor(sessionId).state.agent;\n if (agent?.provider !== 'openai-codex') return;\n sendFrame(sessionId, { type: 'set_fast_mode', enabled });\n sendFrame(sessionId, getStateCommand());\n}\n\n/** Locking aborts a running local turn; the snapshot reports the new state back. */\nexport function setAgentLock(locked: boolean, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, { type: 'set_agent_lock', locked });\n sendFrame(sessionId, getStateCommand());\n}\n\n/** The set reply carries nothing back, so get_state is what updates the chip. */\nexport function selectThinkingLevel(level: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, setThinkingLevelCommand(level));\n sendFrame(sessionId, getStateCommand());\n}\n\n/**\n * Sends a prompt, or steers the run when one is already in flight.\n *\n * Pi rejects a prompt while the agent is working, so the composer picks the\n * verb from the run state rather than making the reader remember which is\n * legal. Every action defaults to the focused session and is a no-op when\n * nothing is focused.\n */\nexport function submitMessage(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): void {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return;\n const store = sessionStoreFor(sessionId);\n // A built-in is an action, not something to say: steering the run with the\n // text, or prompting with it, would reach the model as literal characters.\n const builtin = builtinCommandFrame(trimmed);\n if (builtin) {\n store.setState((state) => appendUserPrompt(state, trimmed));\n sendFrame(sessionId, builtin);\n return;\n }\n const streaming = store.state.streaming;\n const userImages = images\n .filter((image) => isSupportedImageMimeType(image.mimeType))\n .map(({ data, mimeType }) => ({ data, mimeType }));\n store.setState((state) => appendUserPrompt(state, trimmed, userImages));\n sendFrame(sessionId, streaming ? steerCommand(trimmed, images) : promptCommand(trimmed, images));\n}\n\n/** The composer retains its draft until the server acknowledges admission. */\nexport async function submitMessageWithAck(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return false;\n const store = sessionStoreFor(sessionId);\n const builtin = builtinCommandFrame(trimmed);\n const active = store.state.lifecycle === null ? store.state.streaming : store.state.lifecycle.operation !== null;\n const userImages = (builtin ? [] : images)\n .filter((image) => isSupportedImageMimeType(image.mimeType))\n .map(({ data, mimeType }) => ({ data, mimeType }));\n const localId = `u${store.state.nextId}`;\n // Echo before sending so even an early transcript publication reconciles this row.\n store.setState((state) => appendUserPrompt(state, trimmed, userImages));\n let accepted = false;\n try {\n const response = await sendFrameWithAck(\n sessionId,\n builtin ?? (active ? steerCommand(trimmed, images) : promptCommand(trimmed, images)),\n );\n accepted = response.success;\n if (!accepted && response.error?.includes('uncertain'))\n store.setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n return accepted;\n } finally {\n if (!accepted)\n store.setState((state) =>\n state.pendingUserEntries.some(({ id }) => id === localId)\n ? {\n ...state,\n entries: state.entries.filter(({ id }) => id !== localId),\n pendingUserEntries: state.pendingUserEntries.filter(({ id }) => id !== localId),\n }\n : state,\n );\n }\n}\n\nexport function rewindToMessage(itemId: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || itemId === '') return;\n sendFrame(sessionId, rewindCommand(itemId));\n}\n\nexport function queueFollowUp(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): void {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return;\n sendFrame(sessionId, enqueueAutomaticCommand(trimmed, images));\n}\n\n/** A queued submission is acknowledged by the server; consumption is a later lifecycle event. */\nexport async function queueFollowUpWithAck(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return false;\n const response = await sendFrameWithAck(sessionId, enqueueAutomaticCommand(trimmed, images));\n if (!response.success && response.error?.includes('uncertain'))\n sessionStoreFor(sessionId).setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n return response.success;\n}\n\nexport async function clearQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, clearQueueCommand());\n if (!response.success) throw new Error(response.error ?? 'Could not clear queued messages.');\n}\n\n/** Requests server-owned removal; the authoritative snapshot removes the row on success. */\nexport async function deleteQueuedMessage(\n id: string,\n _knownQueueCount: number,\n sessionId: string | null = activeSessionId(),\n): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, removeQueuedCommand(id));\n if (!response.success) throw new Error(response.error ?? 'Could not delete the queued message.');\n switch (response.data) {\n case 'removed':\n return;\n case 'in_flight':\n throw new Error('This message is already being delivered and cannot be deleted.');\n case 'already_consumed':\n throw new Error('This message has already been sent.');\n case 'not_found':\n throw new Error('This message is no longer queued. Refresh the session.');\n default:\n throw new Error('Deletion uncertain. Check the queue before trying again.');\n }\n}\n\n/** The caller captures the active target at click time; absent means expected idle. */\nexport async function promoteQueuedMessage(\n id: string,\n operationId?: string,\n sessionId: string | null = activeSessionId(),\n): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, promoteQueuedCommand(id, operationId));\n if (!response.success) throw new Error(response.error ?? 'Could not send the queued message.');\n switch (response.data) {\n case 'promoted':\n return;\n case 'target_changed':\n throw new Error('The active run changed. Check the session before sending this message.');\n case 'in_flight':\n throw new Error('This message is already being delivered.');\n case 'not_found':\n throw new Error('This message is no longer queued. Refresh the session.');\n default:\n throw new Error('Delivery uncertain. Check the conversation before trying again.');\n }\n}\n\nexport async function resumeQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, resumeQueueCommand());\n if (!response.success) throw new Error(response.error ?? 'Could not resume queued messages.');\n}\n\n/**\n * Renames the session where the name actually lives: in the agent. Pi keeps\n * it in the session file and reports it back through get_state, which is\n * what the hub folds into every page's rail card.\n */\nexport function renameSession(name: string, sessionId: string | null = activeSessionId()): void {\n const trimmed = name.trim();\n if (!trimmed || sessionId === null) return;\n sendFrame(sessionId, setSessionNameCommand(trimmed));\n sendFrame(sessionId, getStateCommand());\n}\n\nexport function abortRun(sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, abortCommand(sessionStoreFor(sessionId).state.lifecycle?.operation?.id));\n}\n\nexport function runCommand(name: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n const slashed = name.startsWith('/') ? name : `/${name}`;\n sendFrame(sessionId, builtinCommandFrame(slashed) ?? promptCommand(slashed));\n}\n\nexport function answerDialogValue(id: string, value: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogValue(id, value));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function answerDialogConfirm(\n id: string,\n confirmed: boolean,\n sessionId: string | null = activeSessionId(),\n): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogConfirmed(id, confirmed));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function cancelDialog(id: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogCancelled(id));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,MAAM,yBAAS,IAAI,IAAiC;AACpD,MAAM,qBAAqB;AAE3B,SAAgB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AS;CAC3F,IAAI,cAAc,QAAQ,gBAAgB,SAAS,CAAC,CAAC,MAAM,QAAQ,OAAO,IAAI;CAC9E,kBAAA,UAAU,WAAWsB,iBAAAA,gBAAgB,EAAE,CAAC;CACxC,gBAAgB,SAAS,CAAC,CAAC,SAASF,qBAAAA,WAAW;AACjD"}
1
+ {"version":3,"file":"sessionStore.cjs","names":["fetchSessionSelection","applySelectionAnswer","Store","initialSessionState","useStore","sessionsStore","reduceSession","HISTORY_REQUEST_TYPE","prependHistory","replaceQueuedEntries","hasSessionProtocol","getStateCommand","getSessionStatsCommand","getCommandsCommand","activeSessionId","getAvailableModelsCommand","getAvailableThinkingLevelsCommand","setModelCommand","setThinkingLevelCommand","builtinCommandFrame","appendUserPrompt","isSupportedImageMimeType","steerCommand","promptCommand","sendFrameWithAck","rewindCommand","enqueueAutomaticCommand","clearQueueCommand","removeQueuedCommand","promoteQueuedCommand","resumeQueueCommand","setSessionNameCommand","abortCommand","dialogValue","clearDialog","dialogConfirmed","dialogCancelled"],"sources":["../../../src/web/stores/sessionStore.ts"],"sourcesContent":["import type { SessionLifecycle } from '@agimon-ai/po-core/sessionProtocol';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\n\nimport { CONTEXT_ENTRY_TYPE, MINOR_MODE_ENTRY_TYPE, HISTORY_REQUEST_TYPE } from '../../types/hub';\nimport {\n abortCommand,\n builtinCommandFrame,\n clearQueueCommand,\n dialogCancelled,\n dialogConfirmed,\n dialogValue,\n enqueueAutomaticCommand,\n promoteQueuedCommand,\n removeQueuedCommand,\n resumeQueueCommand,\n getAvailableModelsCommand,\n getAvailableThinkingLevelsCommand,\n getCommandsCommand,\n getSessionStatsCommand,\n getStateCommand,\n promptCommand,\n type RpcImage,\n rewindCommand,\n setModelCommand,\n setSessionNameCommand,\n setThinkingLevelCommand,\n steerCommand,\n} from '../lib/commands';\nimport {\n appendUserPrompt,\n applySelectionAnswer,\n clearDialog,\n isSupportedImageMimeType,\n initialSessionState,\n prependHistory,\n reduceSession,\n replaceQueuedEntries,\n type QueuedEntry,\n type SessionState,\n type TimelineEntry,\n} from '../lib/sessionModel';\nimport { hasSessionProtocol } from '../lib/sessionProtocolCommands';\nimport { fetchSessionSelection } from '../lib/sessionSelectionApi';\nimport { sendFrame, sendFrameWithAck, sendHubFrame } from '../lib/transport';\nimport { activeSessionId, sessionsStore } from './sessionsStore';\n\n/**\n * One store per session, created on first touch.\n *\n * The heavyweight timeline state only exists for sessions this page has\n * subscribed to; the rail runs on hub summaries alone.\n */\nconst stores = new Map<string, Store<SessionState>>();\nconst selectionRequests = new Map<string, object>();\nconst selectionVersions = new Map<string, { selection: number; context: number; minor: number }>();\nconst SELECTION_STATUS_KEYS = new Set(['po-major-mode', 'po-domain', 'po-profile']);\n\n/** Newer reads and live projections supersede each independently fetched part. */\nexport async function refreshSessionSelection(sessionId: string): Promise<void> {\n const token = {};\n selectionRequests.set(sessionId, token);\n const versions = selectionVersions.get(sessionId) ?? { selection: 0, context: 0, minor: 0 };\n selectionVersions.set(sessionId, versions);\n const before = { ...versions };\n const answer = await fetchSessionSelection(sessionId);\n if (selectionRequests.get(sessionId) !== token) return;\n selectionRequests.delete(sessionId);\n if (before.selection !== versions.selection) {\n delete answer.majorMode;\n delete answer.domains;\n delete answer.profile;\n }\n if (before.context !== versions.context) delete answer.context;\n if (before.minor !== versions.minor) delete answer.minorModes;\n sessionStoreFor(sessionId).setState((state) => applySelectionAnswer(state, answer));\n}\n\nconst MAX_CACHED_ENTRIES = 500;\n\nexport function setHasNewerHistory(sessionId: string, value: boolean): void {\n sessionStoreFor(sessionId).setState((state) =>\n state.hasNewerHistory === value ? state : { ...state, hasNewerHistory: value },\n );\n}\n/** Sessions whose visible transcript is currently supplied by Pi's protocol. */\nconst protocolTranscripts = new Set<string>();\n/** Projection keys changed after a subscription snapshot was requested. */\nconst replayGuards = new Map<string, { statuses: Set<string>; widgets: Set<string> }>();\nconst PROTOCOL_ENTRY_KINDS = new Set<TimelineEntry['kind']>(['user', 'assistant', 'tool']);\n/** Read-only stand-in while no session is focused, so hooks stay unconditional. */\nconst detachedStore = new Store<SessionState>(initialSessionState);\n/** Sessions a live transcript stream currently feeds; any other store may hold stale facts. */\nexport const streamedSessions = new Store<ReadonlySet<string>>(new Set<string>());\n\nexport function setSessionStreamed(sessionId: string, streamed: boolean): void {\n if (streamedSessions.state.has(sessionId) === streamed) return;\n streamedSessions.setState((state) => {\n const next = new Set(state);\n if (streamed) next.add(sessionId);\n else next.delete(sessionId);\n return next;\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function sessionStoreFor(sessionId: string | null): Store<SessionState> {\n if (sessionId === null) return detachedStore;\n const existing = stores.get(sessionId);\n if (existing) return existing;\n const created = new Store<SessionState>(initialSessionState);\n stores.set(sessionId, created);\n return created;\n}\n\n/** Reads the focused session's state; components stay on the useStore idiom. */\nexport function useActiveSession<T>(selector: (state: SessionState) => T): T {\n const activeId = useStore(sessionsStore, (state) => state.activeId);\n return useStore(sessionStoreFor(activeId), selector);\n}\n\nfunction projectionKey(frame: Record<string, unknown>): { kind: 'status' | 'widget'; key: string } | undefined {\n const projected = frame.type === 'replay' && isRecord(frame.frame) ? frame.frame : frame;\n if (projected.type !== 'extension_ui_request') return undefined;\n if (typeof projected.statusKey === 'string' && projected.method === 'setStatus') {\n return { kind: 'status', key: projected.statusKey };\n }\n if (typeof projected.widgetKey === 'string' && projected.method === 'setWidget') {\n return { kind: 'widget', key: projected.widgetKey };\n }\n return undefined;\n}\n\n/** Presentation frames from the Pi protocol, or from bounded replay when replay is true. */\nexport function applySessionFrame(\n sessionId: string,\n frame: Record<string, unknown>,\n options: { replay?: boolean; source?: 'hub' } = {},\n): void {\n if (!options.replay) {\n const versions = selectionVersions.get(sessionId) ?? { selection: 0, context: 0, minor: 0 };\n selectionVersions.set(sessionId, versions);\n if (\n frame.type === 'extension_ui_request' &&\n frame.method === 'setStatus' &&\n SELECTION_STATUS_KEYS.has(String(frame.statusKey))\n )\n versions.selection++;\n if (frame.type === 'entry_appended' && isRecord(frame.entry) && frame.entry.type === 'custom') {\n if (frame.entry.customType === CONTEXT_ENTRY_TYPE) {\n versions.context++;\n versions.selection++;\n }\n if (frame.entry.customType === MINOR_MODE_ENTRY_TYPE) versions.minor++;\n }\n }\n const projection = projectionKey(frame);\n const guard = replayGuards.get(sessionId);\n if (projection !== undefined && guard !== undefined) {\n const keys = projection.kind === 'status' ? guard.statuses : guard.widgets;\n if (options.replay && keys.has(projection.key)) return;\n if (!options.replay) keys.add(projection.key);\n }\n // The presentation stream owns live and replay projection until the typed session\n // service publishes a snapshot. Once it does, only Po-specific frames reduce here.\n const transcriptFromProtocol =\n protocolTranscripts.has(sessionId) || (options.source === 'hub' && hasReadyHistoryReader(sessionId));\n sessionStoreFor(sessionId).setState((state) => {\n const next = reduceSession(state, frame, { transcriptFromProtocol });\n if (!historyReaders.has(sessionId)) return next;\n return {\n ...next,\n entries: next.entries.length > MAX_CACHED_ENTRIES ? next.entries.slice(-MAX_CACHED_ENTRIES) : next.entries,\n restoredIds:\n next.restoredIds.length > MAX_CACHED_ENTRIES ? next.restoredIds.slice(-MAX_CACHED_ENTRIES) : next.restoredIds,\n };\n });\n}\n\n/** Lets the presentation stream resume transcript ownership after a typed service failure. */\nexport function releaseProtocolTranscript(sessionId: string): void {\n protocolTranscripts.delete(sessionId);\n}\n\n/** A thread has no protocol session, so its journal remains its authoritative transcript. */\nexport function applyThreadFrame(threadKey: string, frame: Record<string, unknown>): void {\n sessionStoreFor(threadKey).setState((state) => reduceSession(state, frame));\n}\n\n/**\n * One session's paging state: how far back the page has read, and whether a\n * request is already in flight. Kept beside the timeline rather than inside it\n * because it describes the reading, not the session.\n */\ninterface HistoryState {\n cursor: string | null;\n hasMore: boolean;\n loading: boolean;\n /** Pages taken so far; also what keeps prepended entry ids unique. */\n pages: number;\n}\n\nconst history = new Map<string, HistoryState>();\nconst historyReaders = new Map<\n string,\n {\n read: (direction: 'older' | 'newer' | 'latest') => boolean;\n ready: () => boolean;\n }\n>();\n\nfunction hasReadyHistoryReader(sessionId: string): boolean {\n return historyReaders.get(sessionId)?.ready() === true;\n}\n\nexport function bindHistoryReader(\n sessionId: string,\n reader: (direction: 'older' | 'newer' | 'latest') => boolean,\n ready: () => boolean = () => false,\n): () => void {\n const binding = { read: reader, ready };\n historyReaders.set(sessionId, binding);\n return () => {\n if (historyReaders.get(sessionId) === binding) historyReaders.delete(sessionId);\n };\n}\n\nexport function requestNewerHistory(sessionId: string | null): boolean {\n return sessionId !== null && (historyReaders.get(sessionId)?.read('newer') ?? false);\n}\n\nexport function requestLatestHistory(sessionId: string | null): boolean {\n return sessionId !== null && (historyReaders.get(sessionId)?.read('latest') ?? false);\n}\nconst historyStore = new Store<Record<string, HistoryState>>({});\nconst NO_HISTORY: HistoryState = { cursor: null, hasMore: true, loading: false, pages: 0 };\n\nfunction historyFor(sessionId: string): HistoryState {\n return history.get(sessionId) ?? NO_HISTORY;\n}\n\nfunction setHistory(sessionId: string, next: HistoryState): void {\n history.set(sessionId, next);\n historyStore.setState((state) => ({ ...state, [sessionId]: next }));\n}\n\n/** Whether more transcript exists above what this session's page holds. */\nexport function useHasOlderHistory(sessionId: string | null): boolean {\n return useStore(historyStore, (state) => (sessionId === null ? false : (state[sessionId] ?? NO_HISTORY).hasMore));\n}\n\n/**\n * Asks the hub for the window above what this page holds.\n *\n * One request at a time: a reader flicking upwards would otherwise ask for the\n * same window repeatedly before the first answer lands, and every copy would\n * be prepended.\n */\nexport function requestOlderHistory(sessionId: string | null): boolean {\n if (sessionId === null) return false;\n const reader = historyReaders.get(sessionId);\n if (reader) return reader.read('older');\n const current = historyFor(sessionId);\n if (current.loading || !current.hasMore) return false;\n setHistory(sessionId, { ...current, loading: true });\n sendHubFrame({\n type: HISTORY_REQUEST_TYPE,\n sessionId,\n ...(current.cursor === null ? {} : { before: current.cursor }),\n });\n return true;\n}\n\n/** Folds one answered window above the timeline and records how far back it reached. */\nexport function applyHistoryPage(sessionId: string, frames: Record<string, unknown>[], next: HistoryPage): void {\n const current = historyFor(sessionId);\n const pages = current.pages + 1;\n sessionStoreFor(sessionId).setState((state) => prependHistory(state, frames, pages));\n setHistory(sessionId, { cursor: next.cursor, hasMore: next.hasMore, loading: false, pages });\n}\n\nexport interface HistoryPage {\n cursor: string | null;\n hasMore: boolean;\n}\n\n/** The oldest entry the page holds, which is where the next window ends. */\nexport function seedHistoryCursor(sessionId: string, cursor: string | null): void {\n setHistory(sessionId, { ...NO_HISTORY, cursor });\n}\n\n/** Keeps Po-only and optimistic entries beside the protocol items that preceded them. */\nfunction mergeProtocolEntries(\n previous: TimelineEntry[],\n protocol: TimelineEntry[],\n pendingUserIds: ReadonlySet<string>,\n reconciledUserIds: ReadonlySet<string>,\n): TimelineEntry[] {\n const localByAnchor = new Map<string | null, TimelineEntry[]>();\n let anchor: string | null = null;\n for (const entry of previous) {\n const protocolOwned =\n (PROTOCOL_ENTRY_KINDS.has(entry.kind) || reconciledUserIds.has(entry.id)) && !pendingUserIds.has(entry.id);\n if (protocolOwned) {\n anchor = entry.id;\n continue;\n }\n const local = localByAnchor.get(anchor) ?? [];\n local.push(entry);\n localByAnchor.set(anchor, local);\n }\n\n const merged = [...(localByAnchor.get(null) ?? [])];\n const used = new Set<string | null>([null]);\n for (const entry of protocol) {\n merged.push(entry, ...(localByAnchor.get(entry.id) ?? []));\n used.add(entry.id);\n }\n for (const [entryAnchor, local] of localByAnchor) {\n if (!used.has(entryAnchor)) merged.push(...local);\n }\n return merged;\n}\n\n/**\n * Replaces protocol-owned transcript items with the authoritative snapshot.\n *\n * Local echoes disappear when the protocol publishes them. Po-only entries,\n * such as notices, queued messages, and run dividers, retain their place beside\n * the protocol item that preceded them.\n */\nexport function applyProtocolTranscript(sessionId: string, entries: TimelineEntry[], streaming: boolean): void {\n protocolTranscripts.add(sessionId);\n sessionStoreFor(sessionId).setState((state) => {\n const pendingUserEntries = [...state.pendingUserEntries];\n const pendingUserIdsBeforeReconciliation = new Set(pendingUserEntries.map((pending) => pending.id));\n const knownProtocolIds = new Set(\n state.entries\n .filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind) && !pendingUserIdsBeforeReconciliation.has(entry.id))\n .map((entry) => entry.id),\n );\n const protocolUserEntryIds = { ...state.protocolUserEntryIds };\n const normalizedEntries = [...entries];\n // Claimed prompts are remembered rather than dropped: the journal reports\n // the same message on its own channel, and that copy has to fold into this\n // entry instead of arriving as a new one.\n const reconciledUserEntries = [...state.reconciledUserEntries];\n\n // Work backwards so repeated text binds to the newest matching prompt. The\n // local id keeps React from mounting the same message again when Pi publishes\n // its authoritative transcript copy at the end of a run.\n for (let index = entries.length - 1; index >= 0; index -= 1) {\n const entry = entries[index];\n if (entry?.kind !== 'user') continue;\n const localId = protocolUserEntryIds[entry.id];\n if (localId !== undefined) {\n normalizedEntries[index] = { ...entry, id: localId };\n continue;\n }\n if (knownProtocolIds.has(entry.id)) continue;\n const pendingIndex = pendingUserEntries.findLastIndex((pending) => pending.text === entry.text);\n if (pendingIndex === -1) continue;\n const [pending] = pendingUserEntries.splice(pendingIndex, 1);\n if (pending === undefined) continue;\n protocolUserEntryIds[entry.id] = pending.id;\n reconciledUserEntries.push(pending);\n normalizedEntries[index] = { ...entry, id: pending.id };\n }\n\n const pendingUserIds = new Set(pendingUserEntries.map((pending) => pending.id));\n const reconciledUserIds = new Set(Object.values(protocolUserEntryIds));\n return {\n ...state,\n entries: mergeProtocolEntries(state.entries, normalizedEntries, pendingUserIds, reconciledUserIds),\n streaming: state.lifecycle === null ? streaming : state.lifecycle.operation !== null,\n settled: state.lifecycle === null ? !streaming : state.lifecycle.operation === null,\n pendingUserEntries,\n reconciledUserEntries,\n protocolUserEntryIds,\n };\n });\n}\n\nfunction protocolQueueMatches(state: SessionState, queue: readonly QueuedEntry[]): boolean {\n const current = state.entries.filter((entry): entry is QueuedEntry => entry.kind === 'queued');\n return (\n current.length === queue.length &&\n current.every((entry, index) => {\n const next = queue[index];\n if (\n next === undefined ||\n entry.id !== next.id ||\n entry.text !== next.text ||\n entry.delivery !== next.delivery ||\n entry.scheduling !== next.scheduling ||\n entry.disposition !== next.disposition\n )\n return false;\n const images = entry.images ?? [];\n const nextImages = next.images ?? [];\n return (\n images.length === nextImages.length &&\n images.every((image, imageIndex) => {\n const nextImage = nextImages[imageIndex];\n return nextImage !== undefined && image.data === nextImage.data && image.mimeType === nextImage.mimeType;\n })\n );\n })\n );\n}\n\n/** Applies execution and retained-input state from the server, never from replayed history. */\nexport function applySessionLifecycle(sessionId: string, lifecycle: SessionLifecycle, newBinding = false): void {\n sessionStoreFor(sessionId).setState((state) => {\n const current = state.lifecycle;\n if (!newBinding && current !== null && lifecycle.revision < current.revision) return state;\n const queue: QueuedEntry[] = lifecycle.queue.map(({ id, text, images, delivery, scheduling, disposition }) => ({\n kind: 'queued',\n id,\n text,\n delivery,\n scheduling,\n disposition,\n ...(images === undefined ? {} : { images: images.map(({ data, mimeType }) => ({ data, mimeType })) }),\n }));\n const streaming = lifecycle.operation !== null;\n const updated = protocolQueueMatches(state, queue) ? state : replaceQueuedEntries(state, queue);\n return {\n ...updated,\n lifecycle,\n streaming,\n settled: !streaming,\n ...(state.agent === null ? {} : { agent: { ...state.agent, isStreaming: streaming } }),\n };\n });\n}\n\n/** Replaces composer queue rows with the protocol server's authoritative queue. */\nexport function applyProtocolQueue(sessionId: string, queue: readonly QueuedEntry[]): void {\n sessionStoreFor(sessionId).setState((state) =>\n protocolQueueMatches(state, queue) ? state : replaceQueuedEntries(state, queue),\n );\n}\n/** Marks the start of a subscription replay, so live projections beat an older snapshot. */\nexport function beginSessionReplay(sessionId: string): void {\n replayGuards.set(sessionId, { statuses: new Set(), widgets: new Set() });\n}\n\nexport function endSessionReplay(sessionId: string): void {\n replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStore(sessionId: string, options: { source?: 'hub' } = {}): void {\n selectionRequests.delete(sessionId);\n selectionVersions.delete(sessionId);\n const guard = replayGuards.get(sessionId);\n const preservePages = options.source === 'hub' && hasReadyHistoryReader(sessionId);\n sessionStoreFor(sessionId).setState((state) => {\n // Transcript pages do not contain facts returned by the session commands.\n // Keep those facts even when their response arrives before a page reload.\n const reset = {\n ...initialSessionState,\n agent: state.agent,\n lifecycle: state.lifecycle,\n stats: state.stats,\n commands: state.commands,\n models: state.models,\n thinkingLevels: state.thinkingLevels,\n context: state.context,\n minorModes: state.minorModes,\n };\n const preservedStatuses = Object.fromEntries(\n Object.entries(state.statuses).filter(([key]) => SELECTION_STATUS_KEYS.has(key) || guard?.statuses.has(key)),\n );\n const preservedWidgets = guard === undefined ? [] : state.widgets.filter((key) => guard.widgets.has(key));\n // A bounded hub backlog is not a canonical page. Keep durable entries,\n // their deduplication ids, and custom projections while replaying hub state.\n if (preservePages) return { ...state, statuses: preservedStatuses, widgets: preservedWidgets };\n if (!protocolTranscripts.has(sessionId)) {\n return {\n ...reset,\n statuses: preservedStatuses,\n widgets: preservedWidgets,\n };\n }\n // A legacy socket reconnect replays its backlog. Keep the protocol snapshot\n // visible while that replay rebuilds Po-only state around it.\n const entries = state.entries.filter((entry) => PROTOCOL_ENTRY_KINDS.has(entry.kind));\n return {\n ...reset,\n entries,\n statuses: preservedStatuses,\n widgets: preservedWidgets,\n streaming: state.streaming,\n settled: state.settled,\n pendingUserEntries: state.pendingUserEntries,\n reconciledUserEntries: state.reconciledUserEntries,\n protocolUserEntryIds: state.protocolUserEntryIds,\n };\n });\n if (preservePages) return;\n history.delete(sessionId);\n historyStore.setState((state) => {\n const { [sessionId]: _dropped, ...rest } = state;\n return rest;\n });\n}\n\nexport function dropSessionStore(sessionId: string): void {\n selectionRequests.delete(sessionId);\n selectionVersions.delete(sessionId);\n stores.delete(sessionId);\n protocolTranscripts.delete(sessionId);\n replayGuards.delete(sessionId);\n}\n\nexport function resetSessionStores(): void {\n selectionRequests.clear();\n selectionVersions.clear();\n stores.clear();\n protocolTranscripts.clear();\n replayGuards.clear();\n streamedSessions.setState(() => new Set<string>());\n detachedStore.setState(() => initialSessionState);\n}\n\n/**\n * Asks for the facts the cockpit shows but Pi only reports on request.\n *\n * A session with no live protocol is skipped: it asks for these itself when it\n * connects, and a caller refreshing every listed session (after a settings save,\n * say) must not fail on one that is not open.\n */\nexport function refreshSessionFacts(sessionId: string): void {\n if (!hasSessionProtocol(sessionId)) return;\n sendFrame(sessionId, getStateCommand());\n sendFrame(sessionId, getSessionStatsCommand());\n sendFrame(sessionId, getCommandsCommand());\n}\n\n/**\n * Asks only for the usage figures, cheap enough to run once per message.\n *\n * `refreshSessionFacts` costs three round trips because it also re-reads the\n * state and the command list, and neither of those changes mid-turn.\n */\nexport function refreshSessionStats(sessionId: string): void {\n sendFrame(sessionId, getSessionStatsCommand());\n}\n\n/** Asks what the model picker lists; Pi's answer depends on the current model. */\nexport function loadModelChoices(sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, getAvailableModelsCommand());\n sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/**\n * Switches the model, then re-reads the facts Pi adjusts alongside it: the\n * thinking level gets clamped to what the new model accepts, and the level\n * list changes with it.\n */\nexport function selectModel(provider: string, modelId: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, setModelCommand(provider, modelId));\n sendFrame(sessionId, getStateCommand());\n sendFrame(sessionId, getAvailableThinkingLevelsCommand());\n}\n\n/** Read back server state rather than optimistically enabling priority. */\nexport function selectFastMode(enabled: boolean, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n const agent = sessionStoreFor(sessionId).state.agent;\n if (agent?.provider !== 'openai-codex') return;\n sendFrame(sessionId, { type: 'set_fast_mode', enabled });\n sendFrame(sessionId, getStateCommand());\n}\n\n/** Locking aborts a running local turn; the snapshot reports the new state back. */\nexport function setAgentLock(locked: boolean, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, { type: 'set_agent_lock', locked });\n sendFrame(sessionId, getStateCommand());\n}\n\n/** The set reply carries nothing back, so get_state is what updates the chip. */\nexport function selectThinkingLevel(level: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, setThinkingLevelCommand(level));\n sendFrame(sessionId, getStateCommand());\n}\n\n/**\n * Sends a prompt, or steers the run when one is already in flight.\n *\n * Pi rejects a prompt while the agent is working, so the composer picks the\n * verb from the run state rather than making the reader remember which is\n * legal. Every action defaults to the focused session and is a no-op when\n * nothing is focused.\n */\nexport function submitMessage(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): void {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return;\n const store = sessionStoreFor(sessionId);\n // A built-in is an action, not something to say: steering the run with the\n // text, or prompting with it, would reach the model as literal characters.\n const builtin = builtinCommandFrame(trimmed);\n if (builtin) {\n store.setState((state) => appendUserPrompt(state, trimmed));\n sendFrame(sessionId, builtin);\n return;\n }\n const streaming = store.state.streaming;\n const userImages = images\n .filter((image) => isSupportedImageMimeType(image.mimeType))\n .map(({ data, mimeType }) => ({ data, mimeType }));\n store.setState((state) => appendUserPrompt(state, trimmed, userImages));\n sendFrame(sessionId, streaming ? steerCommand(trimmed, images) : promptCommand(trimmed, images));\n}\n\n/** The composer retains its draft until the server acknowledges admission. */\nexport async function submitMessageWithAck(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return false;\n const store = sessionStoreFor(sessionId);\n const builtin = builtinCommandFrame(trimmed);\n const active = store.state.lifecycle === null ? store.state.streaming : store.state.lifecycle.operation !== null;\n const userImages = (builtin ? [] : images)\n .filter((image) => isSupportedImageMimeType(image.mimeType))\n .map(({ data, mimeType }) => ({ data, mimeType }));\n const localId = `u${store.state.nextId}`;\n // Echo before sending so even an early transcript publication reconciles this row.\n store.setState((state) => appendUserPrompt(state, trimmed, userImages));\n let accepted = false;\n try {\n const response = await sendFrameWithAck(\n sessionId,\n builtin ?? (active ? steerCommand(trimmed, images) : promptCommand(trimmed, images)),\n );\n accepted = response.success;\n if (!accepted && response.error?.includes('uncertain'))\n store.setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n return accepted;\n } finally {\n if (!accepted)\n store.setState((state) =>\n state.pendingUserEntries.some(({ id }) => id === localId)\n ? {\n ...state,\n entries: state.entries.filter(({ id }) => id !== localId),\n pendingUserEntries: state.pendingUserEntries.filter(({ id }) => id !== localId),\n }\n : state,\n );\n }\n}\n\nexport function rewindToMessage(itemId: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || itemId === '') return;\n sendFrame(sessionId, rewindCommand(itemId));\n}\n\nexport function queueFollowUp(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): void {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return;\n sendFrame(sessionId, enqueueAutomaticCommand(trimmed, images));\n}\n\n/** A queued submission is acknowledged by the server; consumption is a later lifecycle event. */\nexport async function queueFollowUpWithAck(\n text: string,\n images: RpcImage[] = [],\n sessionId: string | null = activeSessionId(),\n): Promise<boolean> {\n const trimmed = text.trim();\n if (!trimmed || sessionId === null) return false;\n const response = await sendFrameWithAck(sessionId, enqueueAutomaticCommand(trimmed, images));\n if (!response.success && response.error?.includes('uncertain'))\n sessionStoreFor(sessionId).setState((state) => reduceSession(state, { type: 'error', message: response.error }));\n return response.success;\n}\n\nexport async function clearQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, clearQueueCommand());\n if (!response.success) throw new Error(response.error ?? 'Could not clear queued messages.');\n}\n\n/** Requests server-owned removal; the authoritative snapshot removes the row on success. */\nexport async function deleteQueuedMessage(\n id: string,\n _knownQueueCount: number,\n sessionId: string | null = activeSessionId(),\n): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, removeQueuedCommand(id));\n if (!response.success) throw new Error(response.error ?? 'Could not delete the queued message.');\n switch (response.data) {\n case 'removed':\n return;\n case 'in_flight':\n throw new Error('This message is already being delivered and cannot be deleted.');\n case 'already_consumed':\n throw new Error('This message has already been sent.');\n case 'not_found':\n throw new Error('This message is no longer queued. Refresh the session.');\n default:\n throw new Error('Deletion uncertain. Check the queue before trying again.');\n }\n}\n\n/** The caller captures the active target at click time; absent means expected idle. */\nexport async function promoteQueuedMessage(\n id: string,\n operationId?: string,\n sessionId: string | null = activeSessionId(),\n): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, promoteQueuedCommand(id, operationId));\n if (!response.success) throw new Error(response.error ?? 'Could not send the queued message.');\n switch (response.data) {\n case 'promoted':\n return;\n case 'target_changed':\n throw new Error('The active run changed. Check the session before sending this message.');\n case 'in_flight':\n throw new Error('This message is already being delivered.');\n case 'not_found':\n throw new Error('This message is no longer queued. Refresh the session.');\n default:\n throw new Error('Delivery uncertain. Check the conversation before trying again.');\n }\n}\n\nexport async function resumeQueuedMessages(sessionId: string | null = activeSessionId()): Promise<void> {\n if (sessionId === null) throw new Error('The session protocol is not connected.');\n const response = await sendFrameWithAck(sessionId, resumeQueueCommand());\n if (!response.success) throw new Error(response.error ?? 'Could not resume queued messages.');\n}\n\n/**\n * Renames the session where the name actually lives: in the agent. Pi keeps\n * it in the session file and reports it back through get_state, which is\n * what the hub folds into every page's rail card.\n */\nexport function renameSession(name: string, sessionId: string | null = activeSessionId()): void {\n const trimmed = name.trim();\n if (!trimmed || sessionId === null) return;\n sendFrame(sessionId, setSessionNameCommand(trimmed));\n sendFrame(sessionId, getStateCommand());\n}\n\nexport function abortRun(sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n sendFrame(sessionId, abortCommand(sessionStoreFor(sessionId).state.lifecycle?.operation?.id));\n}\n\nexport function runCommand(name: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null) return;\n const slashed = name.startsWith('/') ? name : `/${name}`;\n sendFrame(sessionId, builtinCommandFrame(slashed) ?? promptCommand(slashed));\n}\n\nexport function answerDialogValue(id: string, value: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogValue(id, value));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function answerDialogConfirm(\n id: string,\n confirmed: boolean,\n sessionId: string | null = activeSessionId(),\n): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogConfirmed(id, confirmed));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n\nexport function cancelDialog(id: string, sessionId: string | null = activeSessionId()): void {\n if (sessionId === null || sessionStoreFor(sessionId).state.dialog?.id !== id) return;\n sendFrame(sessionId, dialogCancelled(id));\n sessionStoreFor(sessionId).setState(clearDialog);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,MAAM,yBAAS,IAAI,IAAiC;AACpD,MAAM,oCAAoB,IAAI,IAAoB;AAClD,MAAM,oCAAoB,IAAI,IAAmE;AACjG,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAiB;CAAa;AAAY,CAAC;;AAGlF,eAAsB,wBAAwB,WAAkC;CAC9E,MAAM,QAAQ,CAAC;CACf,kBAAkB,IAAI,WAAW,KAAK;CACtC,MAAM,WAAW,kBAAkB,IAAI,SAAS,KAAK;EAAE,WAAW;EAAG,SAAS;EAAG,OAAO;CAAE;CAC1F,kBAAkB,IAAI,WAAW,QAAQ;CACzC,MAAM,SAAS,EAAE,GAAG,SAAS;CAC7B,MAAM,SAAS,MAAMA,4BAAAA,sBAAsB,SAAS;CACpD,IAAI,kBAAkB,IAAI,SAAS,MAAM,OAAO;CAChD,kBAAkB,OAAO,SAAS;CAClC,IAAI,OAAO,cAAc,SAAS,WAAW;EAC3C,OAAO,OAAO;EACd,OA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EA,SAAgB,aAAa,IAAY,YAA2BpB,sBAAAA,gBAAgB,GAAS;CAC3F,IAAI,cAAc,QAAQ,gBAAgB,SAAS,CAAC,CAAC,MAAM,QAAQ,OAAO,IAAI;CAC9E,kBAAA,UAAU,WAAWsB,iBAAAA,gBAAgB,EAAE,CAAC;CACxC,gBAAgB,SAAS,CAAC,CAAC,SAASF,qBAAAA,WAAW;AACjD"}
@@ -1,9 +1,14 @@
1
1
  import { QueuedEntry, SessionState, TimelineEntry } from "../lib/sessionModel.mjs";
2
2
  import { RpcImage } from "../lib/commands.mjs";
3
- import { Store } from "@tanstack/store";
4
3
  import { SessionLifecycle } from "@agimon-ai/po-core/sessionProtocol";
4
+ import { Store } from "@tanstack/store";
5
5
  //#region src/web/stores/sessionStore.d.ts
6
+ /** Newer reads and live projections supersede each independently fetched part. */
7
+ export declare function refreshSessionSelection(sessionId: string): Promise<void>;
6
8
  export declare function setHasNewerHistory(sessionId: string, value: boolean): void;
9
+ /** Sessions a live transcript stream currently feeds; any other store may hold stale facts. */
10
+ export declare const streamedSessions: Store<ReadonlySet<string>, never>;
11
+ export declare function setSessionStreamed(sessionId: string, streamed: boolean): void;
7
12
  export declare function sessionStoreFor(sessionId: string | null): Store<SessionState>;
8
13
  /** Reads the focused session's state; components stay on the useStore idiom. */
9
14
  export declare function useActiveSession<T>(selector: (state: SessionState) => T): T;
@@ -57,7 +62,13 @@ export declare function resetSessionStore(sessionId: string, options?: {
57
62
  }): void;
58
63
  export declare function dropSessionStore(sessionId: string): void;
59
64
  export declare function resetSessionStores(): void;
60
- /** Asks for the facts the cockpit shows but Pi only reports on request. */
65
+ /**
66
+ * Asks for the facts the cockpit shows but Pi only reports on request.
67
+ *
68
+ * A session with no live protocol is skipped: it asks for these itself when it
69
+ * connects, and a caller refreshing every listed session (after a settings save,
70
+ * say) must not fail on one that is not open.
71
+ */
61
72
  export declare function refreshSessionFacts(sessionId: string): void;
62
73
  /**
63
74
  * Asks only for the usage figures, cheap enough to run once per message.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