@opengeni/react 0.48.0 → 0.57.0

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 (325) hide show
  1. package/README.md +138 -2
  2. package/dist/artifacts-document.d.ts +3 -0
  3. package/dist/artifacts-document.js +17 -0
  4. package/dist/artifacts-document.js.map +1 -0
  5. package/dist/artifacts-presentation.d.ts +3 -0
  6. package/dist/artifacts-presentation.js +17 -0
  7. package/dist/artifacts-presentation.js.map +1 -0
  8. package/dist/artifacts-spreadsheet.d.ts +3 -0
  9. package/dist/artifacts-spreadsheet.js +17 -0
  10. package/dist/artifacts-spreadsheet.js.map +1 -0
  11. package/dist/artifacts.d.ts +2 -0
  12. package/dist/artifacts.js +199 -0
  13. package/dist/artifacts.js.map +1 -0
  14. package/dist/{chunk-NJ7M2B6Z.js → chunk-5UQPNLIO.js} +16 -8
  15. package/dist/{chunk-NJ7M2B6Z.js.map → chunk-5UQPNLIO.js.map} +1 -1
  16. package/dist/{chunk-LHLYWG5R.js → chunk-6KLX2RH5.js} +461 -38
  17. package/dist/chunk-6KLX2RH5.js.map +1 -0
  18. package/dist/chunk-7WCLAEFV.js +2828 -0
  19. package/dist/chunk-7WCLAEFV.js.map +1 -0
  20. package/dist/{chunk-I4MPFDRP.js → chunk-B6WPZSTT.js} +104 -104
  21. package/dist/{chunk-I4MPFDRP.js.map → chunk-B6WPZSTT.js.map} +1 -1
  22. package/dist/{chunk-EKZH6IDG.js → chunk-C5ZPSSS5.js} +111 -1
  23. package/dist/chunk-C5ZPSSS5.js.map +1 -0
  24. package/dist/{chunk-OL6QVXGF.js → chunk-HA46CYQK.js} +152 -8
  25. package/dist/chunk-HA46CYQK.js.map +1 -0
  26. package/dist/chunk-HUIKIDM5.js +2148 -0
  27. package/dist/chunk-HUIKIDM5.js.map +1 -0
  28. package/dist/{chunk-FWXGSNXT.js → chunk-IGC6A2ZI.js} +585 -34
  29. package/dist/chunk-IGC6A2ZI.js.map +1 -0
  30. package/dist/chunk-JVYQRRC4.js +53 -0
  31. package/dist/chunk-JVYQRRC4.js.map +1 -0
  32. package/dist/chunk-KCGXPP5V.js +157 -0
  33. package/dist/chunk-KCGXPP5V.js.map +1 -0
  34. package/dist/chunk-LLOLUHVG.js +5937 -0
  35. package/dist/chunk-LLOLUHVG.js.map +1 -0
  36. package/dist/{chunk-WYA65Y3F.js → chunk-MKPIAGVL.js} +13 -3
  37. package/dist/chunk-MKPIAGVL.js.map +1 -0
  38. package/dist/chunk-PEI6RANI.js +3234 -0
  39. package/dist/chunk-PEI6RANI.js.map +1 -0
  40. package/dist/chunk-R3AZOAB5.js +933 -0
  41. package/dist/chunk-R3AZOAB5.js.map +1 -0
  42. package/dist/{chunk-O4VXOBGF.js → chunk-WSK7G5LE.js} +70 -2
  43. package/dist/chunk-WSK7G5LE.js.map +1 -0
  44. package/dist/{chunk-23EJ676W.js → chunk-XBZWOM2K.js} +9 -4
  45. package/dist/chunk-XBZWOM2K.js.map +1 -0
  46. package/dist/{chunk-XCNTXWBB.js → chunk-Y7OEDUJ5.js} +856 -338
  47. package/dist/chunk-Y7OEDUJ5.js.map +1 -0
  48. package/dist/client.d.ts +10 -2
  49. package/dist/clipboard.d.ts +1 -0
  50. package/dist/clipboard.js +7 -0
  51. package/dist/clipboard.js.map +1 -0
  52. package/dist/commands/index.d.ts +3 -3
  53. package/dist/commands/registry.d.ts +1 -1
  54. package/dist/commands/types.d.ts +1 -1
  55. package/dist/components/approval-surface.d.ts +2 -2
  56. package/dist/components/artifacts/artifact-surface.d.ts +18 -0
  57. package/dist/components/artifacts/document-editor.d.ts +172 -0
  58. package/dist/components/artifacts/editable-artifact-ui.d.ts +13 -0
  59. package/dist/components/artifacts/editable-artifact-workbench.d.ts +49 -0
  60. package/dist/components/artifacts/editable-document.d.ts +24 -0
  61. package/dist/components/artifacts/editable-presentation.d.ts +24 -0
  62. package/dist/components/artifacts/editable-spreadsheet.d.ts +32 -0
  63. package/dist/components/artifacts/index.d.ts +9 -0
  64. package/dist/components/artifacts/presentation-editor.d.ts +297 -0
  65. package/dist/components/artifacts/published-html-artifact-frame.d.ts +14 -0
  66. package/dist/components/artifacts/spreadsheet-canvas.d.ts +120 -0
  67. package/dist/components/artifacts/spreadsheet-grid.d.ts +113 -0
  68. package/dist/components/browser-input.d.ts +7 -0
  69. package/dist/components/browser-viewer.d.ts +30 -0
  70. package/dist/components/chat-composer.d.ts +8 -8
  71. package/dist/components/code-editor.d.ts +25 -3
  72. package/dist/components/command-palette.d.ts +2 -2
  73. package/dist/components/composer-transcription-control.d.ts +2 -2
  74. package/dist/components/composer.d.ts +17 -17
  75. package/dist/components/computer-viewer.d.ts +24 -0
  76. package/dist/components/copy-button.d.ts +2 -2
  77. package/dist/components/desktop-viewer.d.ts +50 -22
  78. package/dist/components/diff-view.d.ts +1 -1
  79. package/dist/components/enrollment-consent.d.ts +1 -1
  80. package/dist/components/enrollment-device-flow.d.ts +1 -1
  81. package/dist/components/file-browser.d.ts +2 -2
  82. package/dist/components/fleet-tile.d.ts +1 -1
  83. package/dist/components/generated-video-player.d.ts +10 -0
  84. package/dist/components/human-input-form.d.ts +1 -1
  85. package/dist/components/human-input-surface.d.ts +2 -2
  86. package/dist/components/interaction-intervention-banner.d.ts +11 -0
  87. package/dist/components/interactive-workbench-viewers.d.ts +2 -0
  88. package/dist/components/machine-card.d.ts +2 -2
  89. package/dist/components/machine-dock-bar.d.ts +3 -3
  90. package/dist/components/machine-health-pill.d.ts +2 -2
  91. package/dist/components/machine-input-display.d.ts +1 -1
  92. package/dist/components/machine-metrics.d.ts +2 -2
  93. package/dist/components/machine-status-pill.d.ts +4 -4
  94. package/dist/components/machines/health.d.ts +1 -1
  95. package/dist/components/machines/machine-detail.d.ts +3 -3
  96. package/dist/components/machines/metric-history-chart.d.ts +1 -1
  97. package/dist/components/machines/metric-sparkline.d.ts +2 -2
  98. package/dist/components/machines/series.d.ts +2 -2
  99. package/dist/components/machines-dashboard.d.ts +2 -2
  100. package/dist/components/markdown.d.ts +1 -1
  101. package/dist/components/message-timeline.d.ts +12 -5
  102. package/dist/components/model-picker.d.ts +2 -2
  103. package/dist/components/model-policy-picker.d.ts +7 -7
  104. package/dist/components/pierre-diff.d.ts +1 -1
  105. package/dist/components/pierre-file.d.ts +1 -1
  106. package/dist/components/queue-draft-policy.d.ts +1 -1
  107. package/dist/components/queue-surface-implementation.d.ts +3 -3
  108. package/dist/components/queue-surface-state.d.ts +4 -4
  109. package/dist/components/queue-surface.d.ts +5 -5
  110. package/dist/components/sandbox-files.d.ts +3 -3
  111. package/dist/components/sandbox-terminal.d.ts +24 -4
  112. package/dist/components/sandbox-workspace.d.ts +28 -9
  113. package/dist/components/session-chrome.d.ts +4 -4
  114. package/dist/components/session-status.d.ts +2 -2
  115. package/dist/components/timeline-annotation-selection.d.ts +9 -0
  116. package/dist/components/timeline-annotations-dialog.d.ts +16 -0
  117. package/dist/components/timeline-annotations.d.ts +13 -0
  118. package/dist/components/tooltip.d.ts +4 -4
  119. package/dist/components/user-message-body.d.ts +2 -2
  120. package/dist/components/workbench-changes.d.ts +2 -2
  121. package/dist/components/workspace-dock.d.ts +1 -1
  122. package/dist/composer.d.ts +11 -11
  123. package/dist/composer.js +7 -7
  124. package/dist/hooks/internal.d.ts +1 -1
  125. package/dist/hooks/use-attached-browsers.d.ts +21 -0
  126. package/dist/hooks/use-auth-runs.d.ts +32 -0
  127. package/dist/hooks/use-available-models.d.ts +2 -2
  128. package/dist/hooks/use-billing-usage.d.ts +1 -1
  129. package/dist/hooks/use-browser-downloads.d.ts +25 -0
  130. package/dist/hooks/use-browser-frame-stream.d.ts +28 -0
  131. package/dist/hooks/use-browser-identities.d.ts +30 -0
  132. package/dist/hooks/use-browser-session.d.ts +29 -0
  133. package/dist/hooks/use-browser-sessions.d.ts +32 -0
  134. package/dist/hooks/use-channels.d.ts +26 -0
  135. package/dist/hooks/use-codex-accounts.d.ts +2 -2
  136. package/dist/hooks/use-composer.d.ts +36 -9
  137. package/dist/hooks/use-computer-frame-stream.d.ts +24 -0
  138. package/dist/hooks/use-computer-session.d.ts +29 -0
  139. package/dist/hooks/use-computer-sessions.d.ts +28 -0
  140. package/dist/hooks/use-desktop-stream.d.ts +5 -1
  141. package/dist/hooks/use-environments.d.ts +1 -1
  142. package/dist/hooks/use-file-attachments.d.ts +1 -1
  143. package/dist/hooks/use-goal.d.ts +2 -2
  144. package/dist/hooks/use-human-input.d.ts +2 -2
  145. package/dist/hooks/use-interaction-interventions.d.ts +27 -0
  146. package/dist/hooks/use-interaction-invalidation.d.ts +19 -0
  147. package/dist/hooks/use-last-started-turn-policy.d.ts +2 -2
  148. package/dist/hooks/use-machine-chip.d.ts +2 -2
  149. package/dist/hooks/use-machines.d.ts +4 -4
  150. package/dist/hooks/use-network-routes.d.ts +25 -0
  151. package/dist/hooks/use-packs.d.ts +7 -2
  152. package/dist/hooks/use-rigs.d.ts +1 -1
  153. package/dist/hooks/use-sandbox-files.d.ts +6 -4
  154. package/dist/hooks/use-sandbox-git.d.ts +6 -5
  155. package/dist/hooks/use-sandbox-terminal.d.ts +1 -1
  156. package/dist/hooks/use-scheduled-tasks.d.ts +1 -1
  157. package/dist/hooks/use-session-capabilities.d.ts +5 -4
  158. package/dist/hooks/use-session-control.d.ts +1 -1
  159. package/dist/hooks/use-session-events.d.ts +2 -2
  160. package/dist/hooks/use-session-lineage.d.ts +1 -1
  161. package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
  162. package/dist/hooks/use-session.d.ts +2 -2
  163. package/dist/hooks/use-site-auth-connections.d.ts +25 -0
  164. package/dist/hooks/use-slash-commands.d.ts +1 -1
  165. package/dist/hooks/use-supergrok-accounts.d.ts +26 -0
  166. package/dist/hooks/use-terminal-stream.d.ts +11 -2
  167. package/dist/hooks/use-turn-queue.d.ts +2 -2
  168. package/dist/hooks/use-video-artifact-playback.d.ts +9 -0
  169. package/dist/hooks/use-voice-input.d.ts +1 -1
  170. package/dist/hooks/use-workspace-capture.d.ts +1 -1
  171. package/dist/hooks/use-workspace-edit.d.ts +1 -1
  172. package/dist/hooks/use-workspace-sessions.d.ts +1 -1
  173. package/dist/hooks/use-workspaces.d.ts +1 -1
  174. package/dist/index.d.ts +162 -155
  175. package/dist/index.js +1822 -1703
  176. package/dist/index.js.map +1 -1
  177. package/dist/interaction.d.ts +33 -0
  178. package/dist/interaction.js +550 -0
  179. package/dist/interaction.js.map +1 -0
  180. package/dist/interactive-workbench-viewers-TOHBXJEE.js +15 -0
  181. package/dist/interactive-workbench-viewers-TOHBXJEE.js.map +1 -0
  182. package/dist/lib/host-platform.d.ts +5 -0
  183. package/dist/lib/relay-wire.d.ts +24 -1
  184. package/dist/lib/sandbox-liveness.d.ts +9 -0
  185. package/dist/lib/terminal-capability.d.ts +5 -0
  186. package/dist/lib/xterm-theme.d.ts +1 -1
  187. package/dist/machines.d.ts +30 -30
  188. package/dist/machines.js +2 -2
  189. package/dist/model-policy.d.ts +1 -1
  190. package/dist/model-policy.js +1 -1
  191. package/dist/provider.d.ts +6 -5
  192. package/dist/{queue-surface-implementation-U5JFG7HT.js → queue-surface-implementation-2KVJTYXH.js} +100 -48
  193. package/dist/queue-surface-implementation-2KVJTYXH.js.map +1 -0
  194. package/dist/realtime/dropdown-menu.d.ts +8 -8
  195. package/dist/realtime/realtime-control.d.ts +8 -8
  196. package/dist/realtime.d.ts +4 -4
  197. package/dist/realtime.js +38 -11
  198. package/dist/realtime.js.map +1 -1
  199. package/dist/session-context.d.ts +28 -2
  200. package/dist/session-ui.d.ts +14 -14
  201. package/dist/session-ui.js +5 -4
  202. package/dist/session.d.ts +28 -28
  203. package/dist/session.js +10 -10
  204. package/dist/timeline/activity-rail.d.ts +5 -3
  205. package/dist/timeline/disclosure-context.d.ts +1 -1
  206. package/dist/timeline/fleet-decision-projection.d.ts +1 -1
  207. package/dist/timeline/fleet-decision-row.d.ts +3 -3
  208. package/dist/timeline/index.d.ts +19 -19
  209. package/dist/timeline/parsers.d.ts +4 -1
  210. package/dist/timeline/projection.d.ts +3 -3
  211. package/dist/timeline/registry.d.ts +8 -2
  212. package/dist/timeline/screenshot-lightbox.d.ts +2 -2
  213. package/dist/timeline/shared.d.ts +21 -10
  214. package/dist/timeline/tool-diff.d.ts +2 -2
  215. package/dist/timeline/tool-renderers.d.ts +1 -1
  216. package/dist/timeline/turn-summary.d.ts +3 -3
  217. package/dist/timeline/types.d.ts +44 -3
  218. package/dist/timeline-annotation-selection-3L7LHGG2.js +187 -0
  219. package/dist/timeline-annotation-selection-3L7LHGG2.js.map +1 -0
  220. package/dist/timeline-annotations-dialog-U7EVLR75.js +196 -0
  221. package/dist/timeline-annotations-dialog-U7EVLR75.js.map +1 -0
  222. package/package.json +36 -7
  223. package/src/artifacts-document.ts +31 -0
  224. package/src/artifacts-presentation.ts +36 -0
  225. package/src/artifacts-spreadsheet.ts +21 -0
  226. package/src/artifacts.ts +89 -0
  227. package/src/client.ts +157 -1
  228. package/src/clipboard.ts +2 -0
  229. package/src/components/artifacts/artifact-surface.tsx +93 -0
  230. package/src/components/artifacts/document-editor.tsx +2255 -0
  231. package/src/components/artifacts/editable-artifact-ui.tsx +89 -0
  232. package/src/components/artifacts/editable-artifact-workbench.tsx +203 -0
  233. package/src/components/artifacts/editable-document.tsx +657 -0
  234. package/src/components/artifacts/editable-presentation.tsx +1020 -0
  235. package/src/components/artifacts/editable-spreadsheet.tsx +733 -0
  236. package/src/components/artifacts/index.ts +104 -0
  237. package/src/components/artifacts/presentation-editor.tsx +3148 -0
  238. package/src/components/artifacts/published-html-artifact-frame.tsx +38 -0
  239. package/src/components/artifacts/spreadsheet-canvas.ts +799 -0
  240. package/src/components/artifacts/spreadsheet-grid.tsx +2129 -0
  241. package/src/components/browser-input.ts +65 -0
  242. package/src/components/browser-viewer.tsx +2702 -0
  243. package/src/components/chat-composer.tsx +13 -0
  244. package/src/components/code-editor.tsx +89 -30
  245. package/src/components/composer-transcription-control.tsx +10 -6
  246. package/src/components/computer-viewer.tsx +1636 -0
  247. package/src/components/desktop-viewer.tsx +215 -74
  248. package/src/components/generated-video-player.tsx +89 -0
  249. package/src/components/interaction-intervention-banner.tsx +99 -0
  250. package/src/components/interactive-workbench-viewers.ts +2 -0
  251. package/src/components/machine-input-display.ts +3 -0
  252. package/src/components/machines/machine-detail.tsx +1 -1
  253. package/src/components/message-timeline.tsx +289 -32
  254. package/src/components/model-policy-picker.tsx +15 -0
  255. package/src/components/queue-surface-implementation.tsx +116 -60
  256. package/src/components/sandbox-files.tsx +2 -2
  257. package/src/components/sandbox-terminal.tsx +128 -46
  258. package/src/components/sandbox-workspace.tsx +256 -90
  259. package/src/components/session-chrome.tsx +53 -13
  260. package/src/components/timeline-annotation-selection.tsx +221 -0
  261. package/src/components/timeline-annotations-dialog.tsx +213 -0
  262. package/src/components/timeline-annotations.tsx +84 -0
  263. package/src/components/workbench-changes.tsx +188 -31
  264. package/src/components/workspace-dock.tsx +59 -5
  265. package/src/hooks/use-attached-browsers.ts +154 -0
  266. package/src/hooks/use-auth-runs.ts +278 -0
  267. package/src/hooks/use-browser-downloads.ts +218 -0
  268. package/src/hooks/use-browser-frame-stream.ts +425 -0
  269. package/src/hooks/use-browser-identities.ts +266 -0
  270. package/src/hooks/use-browser-session.ts +543 -0
  271. package/src/hooks/use-browser-sessions.ts +286 -0
  272. package/src/hooks/use-channels.ts +99 -0
  273. package/src/hooks/use-composer.ts +769 -24
  274. package/src/hooks/use-computer-frame-stream.ts +434 -0
  275. package/src/hooks/use-computer-session.ts +462 -0
  276. package/src/hooks/use-computer-sessions.ts +251 -0
  277. package/src/hooks/use-desktop-stream.ts +39 -7
  278. package/src/hooks/use-interaction-interventions.ts +242 -0
  279. package/src/hooks/use-interaction-invalidation.ts +66 -0
  280. package/src/hooks/use-machine-chip.ts +15 -3
  281. package/src/hooks/use-machines.ts +33 -3
  282. package/src/hooks/use-network-routes.ts +214 -0
  283. package/src/hooks/use-packs.ts +51 -0
  284. package/src/hooks/use-sandbox-files.ts +98 -55
  285. package/src/hooks/use-sandbox-git.ts +93 -38
  286. package/src/hooks/use-sandbox-terminal.ts +3 -2
  287. package/src/hooks/use-session-capabilities.ts +59 -46
  288. package/src/hooks/use-site-auth-connections.ts +226 -0
  289. package/src/hooks/use-supergrok-accounts.ts +81 -0
  290. package/src/hooks/use-terminal-stream.ts +359 -47
  291. package/src/hooks/use-video-artifact-playback.ts +28 -0
  292. package/src/hooks/use-workspace-edit.ts +2 -1
  293. package/src/index.ts +18 -0
  294. package/src/interaction.ts +101 -0
  295. package/src/lib/host-platform.ts +10 -0
  296. package/src/lib/relay-wire.ts +47 -4
  297. package/src/lib/sandbox-liveness.ts +11 -0
  298. package/src/lib/terminal-capability.ts +10 -0
  299. package/src/model-policy.ts +19 -4
  300. package/src/provider.tsx +133 -1
  301. package/src/realtime/realtime-control.tsx +34 -6
  302. package/src/session-context.ts +156 -1
  303. package/src/timeline/activity-rail.tsx +25 -3
  304. package/src/timeline/index.ts +3 -0
  305. package/src/timeline/parsers.ts +14 -1
  306. package/src/timeline/projection.ts +269 -14
  307. package/src/timeline/registry.ts +13 -1
  308. package/src/timeline/screenshot-lightbox.tsx +19 -9
  309. package/src/timeline/shared.tsx +56 -8
  310. package/src/timeline/tool-renderers.tsx +303 -50
  311. package/src/timeline/types.ts +57 -3
  312. package/styles/compiled.css +312 -21
  313. package/styles/index.css +15 -0
  314. package/styles/responsive.css +13 -1
  315. package/dist/chunk-23EJ676W.js.map +0 -1
  316. package/dist/chunk-EKZH6IDG.js.map +0 -1
  317. package/dist/chunk-FWXGSNXT.js.map +0 -1
  318. package/dist/chunk-LHLYWG5R.js.map +0 -1
  319. package/dist/chunk-O4VXOBGF.js.map +0 -1
  320. package/dist/chunk-OL6QVXGF.js.map +0 -1
  321. package/dist/chunk-WYA65Y3F.js.map +0 -1
  322. package/dist/chunk-XCNTXWBB.js.map +0 -1
  323. package/dist/fleet-decision-projection-SLNZMS42.js +0 -241
  324. package/dist/fleet-decision-projection-SLNZMS42.js.map +0 -1
  325. package/dist/queue-surface-implementation-U5JFG7HT.js.map +0 -1
@@ -0,0 +1,462 @@
1
+ import type {
2
+ ComputerAction,
3
+ ComputerActionReceipt,
4
+ ComputerClipboard,
5
+ ComputerFrame,
6
+ ComputerObservation,
7
+ ComputerSession,
8
+ ComputerTarget,
9
+ } from "@opengeni/sdk/interaction";
10
+ import { useCallback, useEffect, useRef, useState } from "react";
11
+ import {
12
+ type EmbeddedComputerInteractionClientOverride,
13
+ useEmbeddedComputerInteraction,
14
+ } from "../session-context";
15
+ import { usePageLiveActivity } from "./internal";
16
+
17
+ export type UseComputerSessionOptions = EmbeddedComputerInteractionClientOverride & {
18
+ computerSessionId: string | null;
19
+ enabled?: boolean | undefined;
20
+ pollIntervalMs?: number | undefined;
21
+ };
22
+
23
+ export type UseComputerSessionResult = {
24
+ session: ComputerSession | null;
25
+ targets: ComputerTarget[];
26
+ selectedTarget: ComputerTarget | null;
27
+ observation: ComputerObservation | null;
28
+ loading: boolean;
29
+ mutating: boolean;
30
+ error: Error | null;
31
+ refresh: () => Promise<void>;
32
+ readClipboard: () => Promise<ComputerClipboard>;
33
+ /** Changes only this viewer's target cursor; it never takes ownership or
34
+ * foregrounds an application. */
35
+ selectTarget: (targetId: string) => Promise<ComputerTarget>;
36
+ act: (action: ComputerAction, operationId?: string) => Promise<ComputerActionReceipt>;
37
+ /** Dispatch pointer input against the exact displayed frame. */
38
+ actFromFrame: (
39
+ action: Extract<ComputerAction, { type: "pointer" }>,
40
+ frame: ComputerFrame,
41
+ operationId?: string,
42
+ ) => Promise<ComputerActionReceipt>;
43
+ };
44
+
45
+ /** Selected ComputerSession state. Semantic and pixel input share the same
46
+ * generation-fenced controller operation stream used by agents. */
47
+ export function useComputerSession(options: UseComputerSessionOptions): UseComputerSessionResult {
48
+ const { client, workspaceId } = useEmbeddedComputerInteraction(options);
49
+ const computerSessionId = options.computerSessionId;
50
+ const enabled = (options.enabled ?? true) && computerSessionId !== null;
51
+ const pageLive = usePageLiveActivity();
52
+ const pollIntervalMs = Math.max(750, options.pollIntervalMs ?? 2_000);
53
+ const [state, setState] = useState<ComputerControlState>(() =>
54
+ emptyState(computerSessionId, enabled),
55
+ );
56
+ const visible =
57
+ state.computerSessionId === computerSessionId ? state : emptyState(computerSessionId, enabled);
58
+ const selectedTargetIdRef = useRef<string | null>(visible.selectedTargetId);
59
+ selectedTargetIdRef.current = visible.selectedTargetId;
60
+ const targetsRef = useRef<{
61
+ computerSessionId: string | null;
62
+ targets: ComputerTarget[];
63
+ }>({
64
+ computerSessionId,
65
+ targets: visible.targets,
66
+ });
67
+ const observationRef = useRef<{
68
+ computerSessionId: string | null;
69
+ observation: ComputerObservation | null;
70
+ }>({ computerSessionId, observation: visible.observation });
71
+ if (targetsRef.current.computerSessionId !== computerSessionId) {
72
+ targetsRef.current = { computerSessionId, targets: visible.targets };
73
+ observationRef.current = {
74
+ computerSessionId,
75
+ observation: visible.observation,
76
+ };
77
+ } else {
78
+ targetsRef.current.targets = visible.targets;
79
+ observationRef.current.observation = visible.observation;
80
+ }
81
+ const requestRef = useRef<{ id: number; controller: AbortController | null }>({
82
+ id: 0,
83
+ controller: null,
84
+ });
85
+ const mutationRef = useRef<{
86
+ computerSessionId: string | null;
87
+ count: number;
88
+ }>({
89
+ computerSessionId,
90
+ count: 0,
91
+ });
92
+ const mountedRef = useRef(true);
93
+
94
+ const invalidateRefresh = useCallback(() => {
95
+ const id = requestRef.current.id + 1;
96
+ requestRef.current.controller?.abort();
97
+ requestRef.current = { id, controller: null };
98
+ }, []);
99
+
100
+ const refresh = useCallback(async (): Promise<void> => {
101
+ if (!enabled || !computerSessionId) return;
102
+ const id = requestRef.current.id + 1;
103
+ requestRef.current.controller?.abort();
104
+ const controller = new AbortController();
105
+ requestRef.current = { id, controller };
106
+ try {
107
+ const [session, targetResponse] = await Promise.all([
108
+ client.getComputerSession(workspaceId, computerSessionId, {
109
+ signal: controller.signal,
110
+ }),
111
+ client.listComputerTargets(workspaceId, computerSessionId, {
112
+ signal: controller.signal,
113
+ }),
114
+ ]);
115
+ if (!mountedRef.current || requestRef.current.id !== id) return;
116
+ const targets = sortComputerTargets(targetResponse.targets);
117
+ const selected = chooseTarget(targets, selectedTargetIdRef.current, session.platform);
118
+ const observation = selected
119
+ ? await client.observeComputerTarget(workspaceId, computerSessionId, selected.id, {
120
+ signal: controller.signal,
121
+ })
122
+ : null;
123
+ if (!mountedRef.current || requestRef.current.id !== id) return;
124
+ selectedTargetIdRef.current = selected?.id ?? null;
125
+ targetsRef.current = { computerSessionId, targets };
126
+ observationRef.current = { computerSessionId, observation };
127
+ setState((current) =>
128
+ current.computerSessionId === computerSessionId
129
+ ? {
130
+ ...current,
131
+ session,
132
+ targets,
133
+ selectedTargetId: selected?.id ?? null,
134
+ observation,
135
+ loading: false,
136
+ error: null,
137
+ }
138
+ : current,
139
+ );
140
+ } catch (cause) {
141
+ if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id) return;
142
+ setState((current) =>
143
+ current.computerSessionId === computerSessionId
144
+ ? {
145
+ ...current,
146
+ loading: false,
147
+ error: cause instanceof Error ? cause : new Error(String(cause)),
148
+ }
149
+ : current,
150
+ );
151
+ } finally {
152
+ if (requestRef.current.id === id) requestRef.current = { id, controller: null };
153
+ }
154
+ }, [client, computerSessionId, enabled, workspaceId]);
155
+
156
+ useEffect(() => {
157
+ mountedRef.current = true;
158
+ if (!enabled) {
159
+ invalidateRefresh();
160
+ setState(emptyState(computerSessionId, false));
161
+ return;
162
+ }
163
+ setState((current) =>
164
+ current.computerSessionId === computerSessionId
165
+ ? { ...current, loading: true }
166
+ : emptyState(computerSessionId, true),
167
+ );
168
+ void refresh();
169
+ return () => {
170
+ mountedRef.current = false;
171
+ invalidateRefresh();
172
+ };
173
+ }, [computerSessionId, enabled, invalidateRefresh, refresh]);
174
+
175
+ useEffect(() => {
176
+ if (!enabled || !pageLive || visible.mutating) return;
177
+ const timer = setInterval(() => {
178
+ if (!requestRef.current.controller) void refresh();
179
+ }, pollIntervalMs);
180
+ return () => clearInterval(timer);
181
+ }, [enabled, pageLive, pollIntervalMs, refresh, visible.mutating]);
182
+
183
+ useEffect(() => {
184
+ if (!enabled || !computerSessionId || !pageLive) return;
185
+ let disposed = false;
186
+ const timer = setInterval(() => {
187
+ void client.heartbeatComputerSession(workspaceId, computerSessionId).catch(() => {
188
+ if (!disposed) void refresh();
189
+ });
190
+ }, 30_000);
191
+ return () => {
192
+ disposed = true;
193
+ clearInterval(timer);
194
+ };
195
+ }, [client, computerSessionId, enabled, pageLive, refresh, workspaceId]);
196
+
197
+ const runMutation = useCallback(
198
+ async <T>(scopeComputerSessionId: string, operation: () => Promise<T>): Promise<T> => {
199
+ invalidateRefresh();
200
+ if (mutationRef.current.computerSessionId !== scopeComputerSessionId) {
201
+ mutationRef.current = {
202
+ computerSessionId: scopeComputerSessionId,
203
+ count: 0,
204
+ };
205
+ }
206
+ mutationRef.current.count += 1;
207
+ setState((current) =>
208
+ current.computerSessionId === scopeComputerSessionId
209
+ ? { ...current, mutating: true, error: null }
210
+ : current,
211
+ );
212
+ try {
213
+ return await operation();
214
+ } catch (cause) {
215
+ const error = cause instanceof Error ? cause : new Error(String(cause));
216
+ setState((current) =>
217
+ current.computerSessionId === scopeComputerSessionId ? { ...current, error } : current,
218
+ );
219
+ throw error;
220
+ } finally {
221
+ if (mutationRef.current.computerSessionId === scopeComputerSessionId) {
222
+ mutationRef.current.count = Math.max(0, mutationRef.current.count - 1);
223
+ const mutating = mutationRef.current.count > 0;
224
+ setState((current) =>
225
+ current.computerSessionId === scopeComputerSessionId
226
+ ? { ...current, mutating }
227
+ : current,
228
+ );
229
+ }
230
+ }
231
+ },
232
+ [invalidateRefresh],
233
+ );
234
+
235
+ const selectTarget = useCallback(
236
+ async (targetId: string): Promise<ComputerTarget> => {
237
+ if (!computerSessionId) throw new Error("No ComputerSession is selected.");
238
+ const target = targetsRef.current.targets.find((candidate) => candidate.id === targetId);
239
+ if (!target) throw new Error("The selected computer target is no longer available.");
240
+ invalidateRefresh();
241
+ selectedTargetIdRef.current = target.id;
242
+ observationRef.current = { computerSessionId, observation: null };
243
+ setState((current) =>
244
+ current.computerSessionId === computerSessionId
245
+ ? {
246
+ ...current,
247
+ selectedTargetId: target.id,
248
+ observation: null,
249
+ loading: true,
250
+ error: null,
251
+ }
252
+ : current,
253
+ );
254
+ try {
255
+ const observation = await client.observeComputerTarget(
256
+ workspaceId,
257
+ computerSessionId,
258
+ target.id,
259
+ );
260
+ if (selectedTargetIdRef.current !== target.id) return target;
261
+ observationRef.current = { computerSessionId, observation };
262
+ setState((current) =>
263
+ current.computerSessionId === computerSessionId && current.selectedTargetId === target.id
264
+ ? { ...current, observation, loading: false, error: null }
265
+ : current,
266
+ );
267
+ return observation.target;
268
+ } catch (cause) {
269
+ const error = cause instanceof Error ? cause : new Error(String(cause));
270
+ setState((current) =>
271
+ current.computerSessionId === computerSessionId && current.selectedTargetId === target.id
272
+ ? { ...current, loading: false, error }
273
+ : current,
274
+ );
275
+ throw error;
276
+ }
277
+ },
278
+ [client, computerSessionId, invalidateRefresh, workspaceId],
279
+ );
280
+
281
+ const dispatchAction = useCallback(
282
+ async (
283
+ action: ComputerAction,
284
+ operationId: string,
285
+ frame: ComputerFrame | null,
286
+ ): Promise<ComputerActionReceipt> => {
287
+ if (!computerSessionId) throw new Error("No ComputerSession is selected.");
288
+ if (frame && frame.computerSessionId !== computerSessionId) {
289
+ throw new Error("The displayed computer frame belongs to another ComputerSession.");
290
+ }
291
+ const currentObservation =
292
+ observationRef.current.computerSessionId === computerSessionId
293
+ ? observationRef.current.observation
294
+ : null;
295
+ const focusTarget =
296
+ action.type === "focus"
297
+ ? (targetsRef.current.targets.find((candidate) => candidate.id === action.targetId) ??
298
+ null)
299
+ : null;
300
+ const frameTarget = frame
301
+ ? (targetsRef.current.targets.find((candidate) => candidate.id === frame.targetId) ??
302
+ (currentObservation?.target.id === frame.targetId ? currentObservation.target : null))
303
+ : null;
304
+ const target = frameTarget ?? focusTarget ?? currentObservation?.target ?? null;
305
+ if (!target) throw new Error("The computer target is not ready for input.");
306
+ if (frame && frame.targetId !== selectedTargetIdRef.current) {
307
+ throw new Error("The displayed computer frame is no longer selected.");
308
+ }
309
+ if (action.type === "pointer") {
310
+ const expectedFrameId = frame?.frameId ?? currentObservation?.frameId ?? null;
311
+ if (!expectedFrameId || action.frameId !== expectedFrameId) {
312
+ throw new Error("Pointer input must reference the exact displayed computer frame.");
313
+ }
314
+ }
315
+ if (action.type === "semantic" && !currentObservation) {
316
+ throw new Error("The computer accessibility tree is not ready for input.");
317
+ }
318
+
319
+ return await runMutation(computerSessionId, async () => {
320
+ const receipt = await client.actInComputer(workspaceId, computerSessionId, {
321
+ operationId,
322
+ targetId: target.id,
323
+ expectedTargetGeneration: frame?.targetGeneration ?? target.targetGeneration,
324
+ expectedObservationId:
325
+ action.type === "pointer" ? null : (currentObservation?.observationId ?? null),
326
+ expectedFrameId: action.type === "pointer" ? action.frameId : null,
327
+ action,
328
+ });
329
+ if (receipt.observation) {
330
+ const observation = receipt.observation;
331
+ observationRef.current = { computerSessionId, observation };
332
+ selectedTargetIdRef.current = observation.target.id;
333
+ setState((current) =>
334
+ current.computerSessionId === computerSessionId
335
+ ? {
336
+ ...current,
337
+ observation,
338
+ selectedTargetId: observation.target.id,
339
+ targets: replaceTarget(current.targets, observation.target),
340
+ }
341
+ : current,
342
+ );
343
+ } else {
344
+ void refresh();
345
+ }
346
+ return receipt;
347
+ });
348
+ },
349
+ [client, computerSessionId, refresh, runMutation, workspaceId],
350
+ );
351
+
352
+ const act = useCallback(
353
+ async (
354
+ action: ComputerAction,
355
+ operationId: string = crypto.randomUUID(),
356
+ ): Promise<ComputerActionReceipt> => await dispatchAction(action, operationId, null),
357
+ [dispatchAction],
358
+ );
359
+
360
+ const actFromFrame = useCallback(
361
+ async (
362
+ action: Extract<ComputerAction, { type: "pointer" }>,
363
+ frame: ComputerFrame,
364
+ operationId: string = crypto.randomUUID(),
365
+ ): Promise<ComputerActionReceipt> => await dispatchAction(action, operationId, frame),
366
+ [dispatchAction],
367
+ );
368
+
369
+ const readClipboard = useCallback(async (): Promise<ComputerClipboard> => {
370
+ if (!computerSessionId) throw new Error("No ComputerSession is selected.");
371
+ return await client.readComputerClipboard(workspaceId, computerSessionId);
372
+ }, [client, computerSessionId, workspaceId]);
373
+
374
+ return {
375
+ session: visible.session,
376
+ targets: visible.targets,
377
+ selectedTarget:
378
+ visible.targets.find((target) => target.id === visible.selectedTargetId) ?? null,
379
+ observation: visible.observation,
380
+ loading: visible.loading,
381
+ mutating: visible.mutating,
382
+ error: visible.error,
383
+ refresh,
384
+ readClipboard,
385
+ selectTarget,
386
+ act,
387
+ actFromFrame,
388
+ };
389
+ }
390
+
391
+ type ComputerControlState = {
392
+ computerSessionId: string | null;
393
+ session: ComputerSession | null;
394
+ targets: ComputerTarget[];
395
+ selectedTargetId: string | null;
396
+ observation: ComputerObservation | null;
397
+ loading: boolean;
398
+ mutating: boolean;
399
+ error: Error | null;
400
+ };
401
+
402
+ function emptyState(computerSessionId: string | null, loading: boolean): ComputerControlState {
403
+ return {
404
+ computerSessionId,
405
+ session: null,
406
+ targets: [],
407
+ selectedTargetId: null,
408
+ observation: null,
409
+ loading,
410
+ mutating: false,
411
+ error: null,
412
+ };
413
+ }
414
+
415
+ function chooseTarget(
416
+ targets: readonly ComputerTarget[],
417
+ preferredId: string | null,
418
+ platform: ComputerSession["platform"],
419
+ ): ComputerTarget | null {
420
+ const preferred = targets.find((target) => target.id === preferredId);
421
+ if (preferred) return preferred;
422
+ if (platform === "linux") {
423
+ return (
424
+ targets.find((target) => target.focused && target.kind === "screen") ??
425
+ targets.find((target) => target.kind === "screen") ??
426
+ targets.find((target) => target.focused && target.kind === "window") ??
427
+ targets.find((target) => target.kind === "window") ??
428
+ targets[0] ??
429
+ null
430
+ );
431
+ }
432
+ return (
433
+ targets.find((target) => target.focused && target.kind === "window") ??
434
+ targets.find((target) => target.kind === "window") ??
435
+ targets.find((target) => target.focused && target.kind === "app") ??
436
+ targets.find((target) => target.kind === "app") ??
437
+ targets.find((target) => target.kind === "screen") ??
438
+ targets[0] ??
439
+ null
440
+ );
441
+ }
442
+
443
+ function sortComputerTargets(targets: readonly ComputerTarget[]): ComputerTarget[] {
444
+ const rank = { window: 0, app: 1, screen: 2 } as const;
445
+ return [...targets].sort(
446
+ (left, right) =>
447
+ Number(right.focused) - Number(left.focused) ||
448
+ rank[left.kind] - rank[right.kind] ||
449
+ left.title.localeCompare(right.title) ||
450
+ left.id.localeCompare(right.id),
451
+ );
452
+ }
453
+
454
+ function replaceTarget(
455
+ targets: readonly ComputerTarget[],
456
+ target: ComputerTarget,
457
+ ): ComputerTarget[] {
458
+ return sortComputerTargets([
459
+ ...targets.filter((candidate) => candidate.id !== target.id),
460
+ target,
461
+ ]);
462
+ }
@@ -0,0 +1,251 @@
1
+ import type {
2
+ ComputerSession,
3
+ ComputerSessionMutationResponse,
4
+ CreateComputerSessionRequest,
5
+ } from "@opengeni/sdk/interaction";
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
7
+ import type { EmbeddedComputerInteractionClientLike } from "../client";
8
+ import {
9
+ type EmbeddedComputerInteractionClientOverride,
10
+ useEmbeddedComputerInteraction,
11
+ } from "../session-context";
12
+ import { useInteractionInvalidation } from "./use-interaction-invalidation";
13
+
14
+ export type UseComputerSessionsOptions = EmbeddedComputerInteractionClientOverride & {
15
+ /** Current agent/session relevance. Workspace peers remain in `sessions`. */
16
+ sessionId?: string | undefined;
17
+ enabled?: boolean | undefined;
18
+ /** Polling fallback used only while the workspace invalidation stream is unavailable. */
19
+ pollIntervalMs?: number | undefined;
20
+ };
21
+
22
+ export type UseComputerSessionsResult = {
23
+ revision: number;
24
+ sessions: ComputerSession[];
25
+ relevantSessions: ComputerSession[];
26
+ loading: boolean;
27
+ refreshing: boolean;
28
+ error: Error | null;
29
+ refresh: () => Promise<void>;
30
+ create: (
31
+ request: Omit<CreateComputerSessionRequest, "operationId"> & {
32
+ operationId?: string;
33
+ },
34
+ ) => Promise<ComputerSessionMutationResponse>;
35
+ end: (
36
+ computerSessionId: string,
37
+ operationId?: string,
38
+ ) => Promise<ComputerSessionMutationResponse>;
39
+ };
40
+
41
+ /** Workspace-wide ComputerSession registry. Associations rank relevance but
42
+ * never hide peer resources or create an ownership boundary. */
43
+ export function useComputerSessions(
44
+ options: UseComputerSessionsOptions = {},
45
+ ): UseComputerSessionsResult {
46
+ const {
47
+ client,
48
+ workspaceId,
49
+ registerSessionReconciler,
50
+ workspaceInteractionEvent,
51
+ workspaceInteractionConnectionState,
52
+ } = useEmbeddedComputerInteraction(options);
53
+ const enabled = options.enabled ?? true;
54
+ const [state, setState] = useState<ComputerRegistryState>(() => emptyState(workspaceId, enabled));
55
+ const requestRef = useRef<{ id: number; controller: AbortController | null }>({
56
+ id: 0,
57
+ controller: null,
58
+ });
59
+ const mountedRef = useRef(true);
60
+ const visible = state.workspaceId === workspaceId ? state : emptyState(workspaceId, enabled);
61
+
62
+ const cancelLoad = useCallback(() => {
63
+ const id = requestRef.current.id + 1;
64
+ requestRef.current.controller?.abort();
65
+ requestRef.current = { id, controller: null };
66
+ }, []);
67
+
68
+ const load = useCallback(
69
+ async (foreground: boolean): Promise<void> => {
70
+ if (!enabled) return;
71
+ const id = requestRef.current.id + 1;
72
+ requestRef.current.controller?.abort();
73
+ const controller = new AbortController();
74
+ requestRef.current = { id, controller };
75
+ setState((current) => ({
76
+ ...(current.workspaceId === workspaceId ? current : emptyState(workspaceId, true)),
77
+ loading: foreground,
78
+ refreshing: !foreground,
79
+ error: foreground || current.workspaceId !== workspaceId ? null : current.error,
80
+ }));
81
+ try {
82
+ const response = await client.listComputerSessions(workspaceId, {
83
+ signal: controller.signal,
84
+ });
85
+ if (!mountedRef.current || requestRef.current.id !== id) return;
86
+ setState({
87
+ workspaceId,
88
+ revision: response.revision,
89
+ sessions: sortComputerSessions(response.sessions),
90
+ loading: false,
91
+ refreshing: false,
92
+ error: null,
93
+ });
94
+ } catch (cause) {
95
+ if (controller.signal.aborted || !mountedRef.current || requestRef.current.id !== id)
96
+ return;
97
+ setState((current) => ({
98
+ ...(current.workspaceId === workspaceId ? current : emptyState(workspaceId, true)),
99
+ loading: false,
100
+ refreshing: false,
101
+ error: cause instanceof Error ? cause : new Error(String(cause)),
102
+ }));
103
+ } finally {
104
+ if (requestRef.current.id === id) requestRef.current = { id, controller: null };
105
+ }
106
+ },
107
+ [client, enabled, workspaceId],
108
+ );
109
+
110
+ const refresh = useCallback(async () => await load(false), [load]);
111
+
112
+ useEffect(() => {
113
+ mountedRef.current = true;
114
+ if (!enabled) {
115
+ cancelLoad();
116
+ setState(emptyState(workspaceId, false));
117
+ return;
118
+ }
119
+ void load(true);
120
+ return () => {
121
+ mountedRef.current = false;
122
+ cancelLoad();
123
+ };
124
+ }, [cancelLoad, enabled, load, workspaceId]);
125
+
126
+ useInteractionInvalidation({
127
+ workspaceId,
128
+ key: workspaceId,
129
+ enabled,
130
+ event: workspaceInteractionEvent,
131
+ connectionState: workspaceInteractionConnectionState,
132
+ knownRevision: visible.revision,
133
+ refresh,
134
+ fallbackPollIntervalMs: options.pollIntervalMs,
135
+ });
136
+
137
+ useEffect(() => {
138
+ if (!enabled || !options.sessionId) return;
139
+ return registerSessionReconciler(
140
+ options.sessionId,
141
+ `computer-sessions:${workspaceId}`,
142
+ refresh,
143
+ );
144
+ }, [enabled, options.sessionId, refresh, registerSessionReconciler, workspaceId]);
145
+
146
+ const create = useCallback(
147
+ async (
148
+ request: Omit<CreateComputerSessionRequest, "operationId"> & {
149
+ operationId?: string;
150
+ },
151
+ ): Promise<ComputerSessionMutationResponse> => {
152
+ const response = await client.createComputerSession(workspaceId, {
153
+ ...request,
154
+ operationId: request.operationId ?? crypto.randomUUID(),
155
+ });
156
+ setState((current) => mergeSession(current, workspaceId, response.session));
157
+ return response;
158
+ },
159
+ [client, workspaceId],
160
+ );
161
+
162
+ const end = useCallback(
163
+ async (
164
+ computerSessionId: string,
165
+ operationId: string = crypto.randomUUID(),
166
+ ): Promise<ComputerSessionMutationResponse> => {
167
+ const response = await client.endComputerSession(workspaceId, computerSessionId, {
168
+ operationId,
169
+ });
170
+ setState((current) => mergeSession(current, workspaceId, response.session));
171
+ return response;
172
+ },
173
+ [client, workspaceId],
174
+ );
175
+
176
+ const relevantSessions = useMemo(
177
+ () =>
178
+ options.sessionId
179
+ ? visible.sessions.filter((session) =>
180
+ session.associations.some((association) => association.sessionId === options.sessionId),
181
+ )
182
+ : [],
183
+ [options.sessionId, visible.sessions],
184
+ );
185
+
186
+ return {
187
+ revision: visible.revision,
188
+ sessions: visible.sessions,
189
+ relevantSessions,
190
+ loading: visible.loading,
191
+ refreshing: visible.refreshing,
192
+ error: visible.error,
193
+ refresh,
194
+ create,
195
+ end,
196
+ };
197
+ }
198
+
199
+ type ComputerRegistryState = {
200
+ workspaceId: string;
201
+ revision: number;
202
+ sessions: ComputerSession[];
203
+ loading: boolean;
204
+ refreshing: boolean;
205
+ error: Error | null;
206
+ };
207
+
208
+ function emptyState(workspaceId: string, loading: boolean): ComputerRegistryState {
209
+ return {
210
+ workspaceId,
211
+ revision: 0,
212
+ sessions: [],
213
+ loading,
214
+ refreshing: false,
215
+ error: null,
216
+ };
217
+ }
218
+
219
+ function sortComputerSessions(sessions: readonly ComputerSession[]): ComputerSession[] {
220
+ return [...sessions].sort((left, right) => {
221
+ const live = Number(isLiveComputer(right)) - Number(isLiveComputer(left));
222
+ return (
223
+ live ||
224
+ timestamp(right.lastUsedAt) - timestamp(left.lastUsedAt) ||
225
+ left.id.localeCompare(right.id)
226
+ );
227
+ });
228
+ }
229
+
230
+ function isLiveComputer(session: ComputerSession): boolean {
231
+ return !["ending", "ended", "failed", "lost"].includes(session.lifecycle);
232
+ }
233
+
234
+ function timestamp(value: string): number {
235
+ const parsed = Date.parse(value);
236
+ return Number.isFinite(parsed) ? parsed : 0;
237
+ }
238
+
239
+ function mergeSession(
240
+ current: ComputerRegistryState,
241
+ workspaceId: string,
242
+ session: ComputerSession,
243
+ ): ComputerRegistryState {
244
+ if (current.workspaceId !== workspaceId) return current;
245
+ const sessions = current.sessions.filter((candidate) => candidate.id !== session.id);
246
+ sessions.push(session);
247
+ return { ...current, sessions: sortComputerSessions(sessions), error: null };
248
+ }
249
+
250
+ /** Exported for narrow proxy implementations and tests. */
251
+ export type ComputerSessionsClient = EmbeddedComputerInteractionClientLike;