@opengeni/react 0.46.1 → 0.52.1
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.
- package/README.md +158 -14
- package/dist/artifacts-document.d.ts +3 -0
- package/dist/artifacts-document.js +17 -0
- package/dist/artifacts-document.js.map +1 -0
- package/dist/artifacts-presentation.d.ts +3 -0
- package/dist/artifacts-presentation.js +17 -0
- package/dist/artifacts-presentation.js.map +1 -0
- package/dist/artifacts-spreadsheet.d.ts +3 -0
- package/dist/artifacts-spreadsheet.js +17 -0
- package/dist/artifacts-spreadsheet.js.map +1 -0
- package/dist/artifacts.d.ts +2 -0
- package/dist/artifacts.js +170 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/chunk-6BBWWOOU.js +82 -0
- package/dist/chunk-6BBWWOOU.js.map +1 -0
- package/dist/{chunk-HFO4ERGQ.js → chunk-724BW4TW.js} +586 -35
- package/dist/chunk-724BW4TW.js.map +1 -0
- package/dist/chunk-7I2KB3OK.js +3895 -0
- package/dist/chunk-7I2KB3OK.js.map +1 -0
- package/dist/chunk-7WCLAEFV.js +2828 -0
- package/dist/chunk-7WCLAEFV.js.map +1 -0
- package/dist/{chunk-U3CSCMWA.js → chunk-FK6VG4LL.js} +9 -13
- package/dist/chunk-FK6VG4LL.js.map +1 -0
- package/dist/{chunk-SRFUT2ZU.js → chunk-FWS3KC3Z.js} +120 -64
- package/dist/chunk-FWS3KC3Z.js.map +1 -0
- package/dist/{chunk-EKZH6IDG.js → chunk-HDBG7XGO.js} +62 -1
- package/dist/chunk-HDBG7XGO.js.map +1 -0
- package/dist/chunk-HUIKIDM5.js +2148 -0
- package/dist/chunk-HUIKIDM5.js.map +1 -0
- package/dist/{chunk-LGVMUIRV.js → chunk-JAGDUCZQ.js} +1053 -390
- package/dist/chunk-JAGDUCZQ.js.map +1 -0
- package/dist/{chunk-LWR4MXSS.js → chunk-JR3QFY6B.js} +420 -35
- package/dist/chunk-JR3QFY6B.js.map +1 -0
- package/dist/chunk-JVYQRRC4.js +53 -0
- package/dist/chunk-JVYQRRC4.js.map +1 -0
- package/dist/chunk-KCGXPP5V.js +157 -0
- package/dist/chunk-KCGXPP5V.js.map +1 -0
- package/dist/{chunk-EB67J347.js → chunk-KZ73RL76.js} +111 -31
- package/dist/chunk-KZ73RL76.js.map +1 -0
- package/dist/chunk-PEI6RANI.js +3234 -0
- package/dist/chunk-PEI6RANI.js.map +1 -0
- package/dist/{chunk-3PB7MIT6.js → chunk-ROIRTM37.js} +220 -72
- package/dist/chunk-ROIRTM37.js.map +1 -0
- package/dist/chunk-VZTQ73XT.js +86 -0
- package/dist/chunk-VZTQ73XT.js.map +1 -0
- package/dist/{chunk-VCBFUSUZ.js → chunk-WSK7G5LE.js} +72 -4
- package/dist/chunk-WSK7G5LE.js.map +1 -0
- package/dist/{chunk-FGZUCXZF.js → chunk-WYA65Y3F.js} +16 -16
- package/dist/chunk-WYA65Y3F.js.map +1 -0
- package/dist/{chunk-6EDV6YFE.js → chunk-X4S56Y2H.js} +147 -35
- package/dist/chunk-X4S56Y2H.js.map +1 -0
- package/dist/client.d.ts +7 -1
- package/dist/clipboard.d.ts +1 -0
- package/dist/clipboard.js +7 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/types.d.ts +1 -1
- package/dist/components/approval-surface.d.ts +2 -2
- package/dist/components/artifacts/artifact-surface.d.ts +18 -0
- package/dist/components/artifacts/document-editor.d.ts +172 -0
- package/dist/components/artifacts/editable-artifact-ui.d.ts +13 -0
- package/dist/components/artifacts/editable-artifact-workbench.d.ts +49 -0
- package/dist/components/artifacts/editable-document.d.ts +24 -0
- package/dist/components/artifacts/editable-presentation.d.ts +24 -0
- package/dist/components/artifacts/editable-spreadsheet.d.ts +32 -0
- package/dist/components/artifacts/index.d.ts +8 -0
- package/dist/components/artifacts/presentation-editor.d.ts +297 -0
- package/dist/components/artifacts/spreadsheet-canvas.d.ts +120 -0
- package/dist/components/artifacts/spreadsheet-grid.d.ts +113 -0
- package/dist/components/browser-viewer.d.ts +29 -0
- package/dist/components/chat-composer.d.ts +13 -8
- package/dist/components/code-editor.d.ts +25 -3
- package/dist/components/command-palette.d.ts +2 -2
- package/dist/components/composer-transcription-control.d.ts +4 -2
- package/dist/components/composer.d.ts +29 -15
- package/dist/components/computer-viewer.d.ts +23 -0
- package/dist/components/copy-button.d.ts +2 -2
- package/dist/components/desktop-viewer.d.ts +25 -21
- package/dist/components/diff-view.d.ts +1 -1
- package/dist/components/enrollment-consent.d.ts +1 -1
- package/dist/components/enrollment-device-flow.d.ts +1 -1
- package/dist/components/file-browser.d.ts +2 -2
- package/dist/components/fleet-tile.d.ts +1 -1
- package/dist/components/generated-video-player.d.ts +10 -0
- package/dist/components/human-input-form.d.ts +1 -1
- package/dist/components/human-input-surface.d.ts +2 -2
- package/dist/components/interactive-workbench-viewers.d.ts +2 -0
- package/dist/components/machine-card.d.ts +2 -2
- package/dist/components/machine-dock-bar.d.ts +3 -3
- package/dist/components/machine-health-pill.d.ts +2 -2
- package/dist/components/machine-input-display.d.ts +1 -1
- package/dist/components/machine-metrics.d.ts +2 -2
- package/dist/components/machine-status-pill.d.ts +4 -4
- package/dist/components/machines/health.d.ts +1 -1
- package/dist/components/machines/machine-detail.d.ts +5 -3
- package/dist/components/machines/metric-history-chart.d.ts +1 -1
- package/dist/components/machines/metric-sparkline.d.ts +2 -2
- package/dist/components/machines/series.d.ts +2 -2
- package/dist/components/machines-dashboard.d.ts +5 -5
- package/dist/components/markdown.d.ts +1 -1
- package/dist/components/message-timeline.d.ts +22 -5
- package/dist/components/model-picker.d.ts +2 -2
- package/dist/components/model-policy-picker.d.ts +7 -7
- package/dist/components/pierre-diff.d.ts +1 -1
- package/dist/components/pierre-file.d.ts +1 -1
- package/dist/components/queue-draft-policy.d.ts +1 -1
- package/dist/components/queue-surface-implementation.d.ts +3 -3
- package/dist/components/queue-surface-state.d.ts +4 -4
- package/dist/components/queue-surface.d.ts +5 -5
- package/dist/components/sandbox-files.d.ts +5 -5
- package/dist/components/sandbox-terminal.d.ts +50 -4
- package/dist/components/sandbox-workspace.d.ts +30 -10
- package/dist/components/session-chrome.d.ts +4 -4
- package/dist/components/session-status.d.ts +2 -2
- package/dist/components/timeline-annotation-selection.d.ts +9 -0
- package/dist/components/timeline-annotations-dialog.d.ts +16 -0
- package/dist/components/timeline-annotations.d.ts +13 -0
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/user-message-body.d.ts +2 -2
- package/dist/components/workbench-changes.d.ts +2 -2
- package/dist/components/workspace-dock.d.ts +3 -1
- package/dist/composer.d.ts +11 -11
- package/dist/composer.js +7 -7
- package/dist/hooks/internal.d.ts +7 -1
- package/dist/hooks/use-attached-browsers.d.ts +21 -0
- package/dist/hooks/use-available-models.d.ts +2 -2
- package/dist/hooks/use-billing-usage.d.ts +1 -1
- package/dist/hooks/use-browser-frame-stream.d.ts +28 -0
- package/dist/hooks/use-browser-identities.d.ts +26 -0
- package/dist/hooks/use-browser-session.d.ts +28 -0
- package/dist/hooks/use-browser-sessions.d.ts +32 -0
- package/dist/hooks/use-codex-accounts.d.ts +3 -3
- package/dist/hooks/use-composer.d.ts +36 -9
- package/dist/hooks/use-computer-frame-stream.d.ts +24 -0
- package/dist/hooks/use-computer-session.d.ts +28 -0
- package/dist/hooks/use-computer-sessions.d.ts +28 -0
- package/dist/hooks/use-desktop-stream.d.ts +1 -1
- package/dist/hooks/use-environments.d.ts +11 -5
- package/dist/hooks/use-file-attachments.d.ts +1 -1
- package/dist/hooks/use-goal.d.ts +2 -2
- package/dist/hooks/use-human-input.d.ts +2 -2
- package/dist/hooks/use-last-started-turn-policy.d.ts +2 -2
- package/dist/hooks/use-machine-chip.d.ts +2 -2
- package/dist/hooks/use-machines.d.ts +10 -3
- package/dist/hooks/use-packs.d.ts +7 -2
- package/dist/hooks/use-rigs.d.ts +1 -1
- package/dist/hooks/use-sandbox-files.d.ts +25 -4
- package/dist/hooks/use-sandbox-git.d.ts +13 -5
- package/dist/hooks/use-sandbox-terminal.d.ts +1 -1
- package/dist/hooks/use-scheduled-tasks.d.ts +1 -1
- package/dist/hooks/use-session-capabilities.d.ts +5 -4
- package/dist/hooks/use-session-control.d.ts +1 -1
- package/dist/hooks/use-session-events.d.ts +2 -2
- package/dist/hooks/use-session-lineage.d.ts +1 -1
- package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
- package/dist/hooks/use-session.d.ts +2 -2
- package/dist/hooks/use-slash-commands.d.ts +1 -1
- package/dist/hooks/use-terminal-stream.d.ts +8 -2
- package/dist/hooks/use-transcription.d.ts +2 -2
- package/dist/hooks/use-turn-queue.d.ts +2 -2
- package/dist/hooks/use-video-artifact-playback.d.ts +9 -0
- package/dist/hooks/use-voice-input.d.ts +6 -4
- package/dist/hooks/use-workspace-capture.d.ts +1 -1
- package/dist/hooks/use-workspace-edit.d.ts +1 -1
- package/dist/hooks/use-workspace-sessions.d.ts +1 -1
- package/dist/hooks/use-workspaces.d.ts +1 -1
- package/dist/index.d.ts +158 -154
- package/dist/index.js +1718 -908
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +23 -0
- package/dist/interaction.js +36 -0
- package/dist/interaction.js.map +1 -0
- package/dist/interactive-workbench-viewers-KHNOHWQE.js +13 -0
- package/dist/interactive-workbench-viewers-KHNOHWQE.js.map +1 -0
- package/dist/lib/composer-responsive-context.d.ts +9 -0
- package/dist/lib/relay-wire.d.ts +4 -0
- package/dist/lib/sandbox-liveness.d.ts +9 -0
- package/dist/lib/terminal-capability.d.ts +5 -0
- package/dist/lib/use-portal-token-style.d.ts +14 -3
- package/dist/lib/xterm-theme.d.ts +1 -1
- package/dist/machines.d.ts +30 -30
- package/dist/machines.js +3 -3
- package/dist/provider.d.ts +4 -4
- package/dist/{queue-surface-implementation-J4XJFKRW.js → queue-surface-implementation-2KVJTYXH.js} +117 -64
- package/dist/queue-surface-implementation-2KVJTYXH.js.map +1 -0
- package/dist/realtime/dropdown-menu.d.ts +8 -8
- package/dist/realtime/realtime-control.d.ts +15 -6
- package/dist/realtime.d.ts +4 -4
- package/dist/realtime.js +30 -33
- package/dist/realtime.js.map +1 -1
- package/dist/session-context.d.ts +19 -1
- package/dist/session-ui.d.ts +14 -14
- package/dist/session-ui.js +6 -5
- package/dist/session.d.ts +28 -28
- package/dist/session.js +5 -5
- package/dist/timeline/activity-rail.d.ts +6 -3
- package/dist/timeline/disclosure-context.d.ts +1 -1
- package/dist/timeline/fleet-decision-projection.d.ts +1 -1
- package/dist/timeline/fleet-decision-row.d.ts +3 -3
- package/dist/timeline/index.d.ts +19 -19
- package/dist/timeline/parsers.d.ts +6 -3
- package/dist/timeline/projection.d.ts +3 -3
- package/dist/timeline/registry.d.ts +10 -1
- package/dist/timeline/screenshot-lightbox.d.ts +2 -2
- package/dist/timeline/shared.d.ts +21 -10
- package/dist/timeline/tool-diff.d.ts +2 -2
- package/dist/timeline/tool-renderers.d.ts +1 -1
- package/dist/timeline/turn-summary.d.ts +3 -3
- package/dist/timeline/types.d.ts +42 -2
- package/dist/timeline-annotation-selection-3L7LHGG2.js +187 -0
- package/dist/timeline-annotation-selection-3L7LHGG2.js.map +1 -0
- package/dist/timeline-annotations-dialog-U7EVLR75.js +196 -0
- package/dist/timeline-annotations-dialog-U7EVLR75.js.map +1 -0
- package/dist/voice-recording-store.d.ts +8 -2
- package/package.json +52 -7
- package/src/artifacts-document.ts +31 -0
- package/src/artifacts-presentation.ts +36 -0
- package/src/artifacts-spreadsheet.ts +21 -0
- package/src/artifacts.ts +86 -0
- package/src/client.ts +90 -1
- package/src/clipboard.ts +2 -0
- package/src/components/artifacts/artifact-surface.tsx +93 -0
- package/src/components/artifacts/document-editor.tsx +2255 -0
- package/src/components/artifacts/editable-artifact-ui.tsx +89 -0
- package/src/components/artifacts/editable-artifact-workbench.tsx +203 -0
- package/src/components/artifacts/editable-document.tsx +657 -0
- package/src/components/artifacts/editable-presentation.tsx +1020 -0
- package/src/components/artifacts/editable-spreadsheet.tsx +733 -0
- package/src/components/artifacts/index.ts +99 -0
- package/src/components/artifacts/presentation-editor.tsx +3148 -0
- package/src/components/artifacts/spreadsheet-canvas.ts +799 -0
- package/src/components/artifacts/spreadsheet-grid.tsx +2129 -0
- package/src/components/browser-viewer.tsx +1592 -0
- package/src/components/chat-composer.tsx +25 -2
- package/src/components/code-editor.tsx +90 -31
- package/src/components/command-palette.tsx +1 -1
- package/src/components/composer-transcription-control.tsx +51 -22
- package/src/components/composer.tsx +49 -23
- package/src/components/computer-viewer.tsx +1139 -0
- package/src/components/copy-button.tsx +1 -1
- package/src/components/desktop-viewer.tsx +103 -75
- package/src/components/file-browser.tsx +39 -17
- package/src/components/generated-video-player.tsx +89 -0
- package/src/components/human-input-form.tsx +2 -2
- package/src/components/interactive-workbench-viewers.ts +2 -0
- package/src/components/machine-card.tsx +1 -1
- package/src/components/machine-input-display.ts +3 -0
- package/src/components/machines/machine-detail.tsx +39 -15
- package/src/components/machines-dashboard.tsx +7 -6
- package/src/components/message-timeline.tsx +327 -37
- package/src/components/model-picker.tsx +2 -2
- package/src/components/model-policy-picker.tsx +16 -15
- package/src/components/queue-surface-implementation.tsx +135 -75
- package/src/components/queue-surface-state.tsx +2 -2
- package/src/components/sandbox-files.tsx +142 -62
- package/src/components/sandbox-terminal.tsx +119 -35
- package/src/components/sandbox-workspace.tsx +394 -228
- package/src/components/session-chrome.tsx +67 -27
- package/src/components/timeline-annotation-selection.tsx +221 -0
- package/src/components/timeline-annotations-dialog.tsx +213 -0
- package/src/components/timeline-annotations.tsx +84 -0
- package/src/components/tooltip.tsx +13 -16
- package/src/components/user-message-body.tsx +1 -1
- package/src/components/workbench-changes.tsx +192 -35
- package/src/components/workspace-dock.tsx +13 -5
- package/src/composer.ts +3 -0
- package/src/hooks/internal.ts +132 -38
- package/src/hooks/use-attached-browsers.ts +152 -0
- package/src/hooks/use-browser-frame-stream.ts +316 -0
- package/src/hooks/use-browser-identities.ts +225 -0
- package/src/hooks/use-browser-session.ts +476 -0
- package/src/hooks/use-browser-sessions.ts +281 -0
- package/src/hooks/use-codex-accounts.ts +4 -4
- package/src/hooks/use-composer.ts +769 -24
- package/src/hooks/use-computer-frame-stream.ts +311 -0
- package/src/hooks/use-computer-session.ts +442 -0
- package/src/hooks/use-computer-sessions.ts +245 -0
- package/src/hooks/use-environments.ts +24 -5
- package/src/hooks/use-file-attachments.ts +70 -32
- package/src/hooks/use-goal.ts +17 -5
- package/src/hooks/use-machine-chip.ts +5 -3
- package/src/hooks/use-machines.ts +79 -3
- package/src/hooks/use-packs.ts +51 -0
- package/src/hooks/use-sandbox-files.ts +382 -88
- package/src/hooks/use-sandbox-git.ts +208 -46
- package/src/hooks/use-sandbox-terminal.ts +3 -2
- package/src/hooks/use-session-capabilities.ts +94 -70
- package/src/hooks/use-session-events.ts +18 -4
- package/src/hooks/use-terminal-stream.ts +102 -23
- package/src/hooks/use-transcription.ts +4 -14
- package/src/hooks/use-turn-queue.ts +17 -5
- package/src/hooks/use-video-artifact-playback.ts +28 -0
- package/src/hooks/use-voice-input.ts +163 -19
- package/src/hooks/use-windowed-sections.ts +9 -7
- package/src/hooks/use-workspace-edit.ts +2 -1
- package/src/index.ts +21 -6
- package/src/interaction.ts +71 -0
- package/src/lib/composer-responsive-context.ts +15 -0
- package/src/lib/relay-wire.ts +4 -0
- package/src/lib/sandbox-liveness.ts +11 -0
- package/src/lib/terminal-capability.ts +10 -0
- package/src/lib/use-portal-token-style.ts +60 -15
- package/src/provider.tsx +52 -7
- package/src/realtime/dropdown-menu.tsx +15 -19
- package/src/realtime/realtime-control.tsx +16 -5
- package/src/session-context.ts +90 -0
- package/src/timeline/activity-rail.tsx +31 -6
- package/src/timeline/index.ts +4 -1
- package/src/timeline/parsers.ts +46 -20
- package/src/timeline/projection.ts +233 -13
- package/src/timeline/registry.ts +19 -0
- package/src/timeline/screenshot-lightbox.tsx +30 -9
- package/src/timeline/shared.tsx +59 -11
- package/src/timeline/tool-renderers.tsx +421 -24
- package/src/timeline/turn-summary.tsx +2 -2
- package/src/timeline/types.ts +58 -2
- package/src/voice-recording-store.ts +15 -0
- package/styles/compiled.css +5298 -0
- package/styles/compiled.d.ts +2 -0
- package/styles/effective-tokens.css +27 -0
- package/styles/index.css +18 -0
- package/styles/responsive.css +208 -0
- package/styles/responsive.d.ts +2 -0
- package/styles/tokens.css +50 -17
- package/dist/chunk-3PB7MIT6.js.map +0 -1
- package/dist/chunk-6EDV6YFE.js.map +0 -1
- package/dist/chunk-EB67J347.js.map +0 -1
- package/dist/chunk-EKZH6IDG.js.map +0 -1
- package/dist/chunk-FGZUCXZF.js.map +0 -1
- package/dist/chunk-HFO4ERGQ.js.map +0 -1
- package/dist/chunk-JB5725BI.js +0 -48
- package/dist/chunk-JB5725BI.js.map +0 -1
- package/dist/chunk-LGVMUIRV.js.map +0 -1
- package/dist/chunk-LWR4MXSS.js.map +0 -1
- package/dist/chunk-SRFUT2ZU.js.map +0 -1
- package/dist/chunk-U3CSCMWA.js.map +0 -1
- package/dist/chunk-VCBFUSUZ.js.map +0 -1
- package/dist/fleet-decision-projection-SLNZMS42.js +0 -241
- package/dist/fleet-decision-projection-SLNZMS42.js.map +0 -1
- package/dist/queue-surface-implementation-J4XJFKRW.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,90 @@ ancestor. Components are styled with Tailwind v4 utilities mapped onto the
|
|
|
24
24
|
tokens, Radix primitives for behavior, and Motion for state-communicating
|
|
25
25
|
animation. Override the tokens to rebrand everything.
|
|
26
26
|
|
|
27
|
+
## Editable Office artifacts
|
|
28
|
+
|
|
29
|
+
The optional artifact workbench is isolated from the ordinary session and
|
|
30
|
+
realtime entries. The default browser composition owns one verified WASM
|
|
31
|
+
Worker, durable IndexedDB state, authenticated live sync, teardown, and the
|
|
32
|
+
matching editor for the artifact modality:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import workerUrl from "@opengeni/sdk/editable-artifacts/worker?worker&url";
|
|
36
|
+
import { BrowserEditableArtifactWorkbench } from "@opengeni/react/artifacts";
|
|
37
|
+
import { editableArtifactKernelRuntime } from "@opengeni/artifact-kernel-wasm-spreadsheet";
|
|
38
|
+
|
|
39
|
+
<BrowserEditableArtifactWorkbench
|
|
40
|
+
options={{
|
|
41
|
+
baseUrl: "https://api.example.com",
|
|
42
|
+
workspaceId,
|
|
43
|
+
artifact,
|
|
44
|
+
replicaId,
|
|
45
|
+
storageAuthority,
|
|
46
|
+
runtime: {
|
|
47
|
+
workerUrl,
|
|
48
|
+
...editableArtifactKernelRuntime,
|
|
49
|
+
applicationOrigin: window.location.origin,
|
|
50
|
+
},
|
|
51
|
+
transport: { credentials: "include" },
|
|
52
|
+
}}
|
|
53
|
+
spreadsheet={{ title: artifact.title }}
|
|
54
|
+
/>;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`storageAuthority` is the host's authenticated deployment/account/workspace/
|
|
58
|
+
principal partition and authorization epoch; it must rotate when that authority
|
|
59
|
+
or any static transport credential changes. `replicaId` is a persisted random
|
|
60
|
+
64-bit writer id. Cookie auth works through `credentials`; self-hosted browser
|
|
61
|
+
consoles may pass static deployment-bound `transport.headers`. Browser API keys
|
|
62
|
+
and custom fetch/WebSocket functions stay on the lower-level
|
|
63
|
+
`EditableArtifactWorkbenchHost`, whose host supplies its own SDK session factory
|
|
64
|
+
and complete `sessionKey`.
|
|
65
|
+
|
|
66
|
+
Hosts that already own an `EditableArtifactSession` can render one modality
|
|
67
|
+
directly. No snapshot or artifact-tool model crosses onto the React thread:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { EditableSpreadsheetArtifactSurface } from "@opengeni/react/artifacts/spreadsheet";
|
|
71
|
+
import { EditableDocumentArtifactSurface } from "@opengeni/react/artifacts/document";
|
|
72
|
+
import { EditablePresentationArtifactSurface } from "@opengeni/react/artifacts/presentation";
|
|
73
|
+
|
|
74
|
+
<EditableSpreadsheetArtifactSurface session={spreadsheetSession} title="Report" />;
|
|
75
|
+
<EditableDocumentArtifactSurface session={documentSession} title="Brief" />;
|
|
76
|
+
<EditablePresentationArtifactSurface session={presentationSession} title="Launch deck" />;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The durable document surface composes bounded summary, body, section, and
|
|
80
|
+
review queries at one native revision. Text edits become UTF-16-correct minimal
|
|
81
|
+
`paragraph.edit` commands; formatting becomes `paragraph.format`. Empty
|
|
82
|
+
documents use the SDK's native-namespace structural allocator to create their
|
|
83
|
+
first durable paragraph without inventing React-side identity rules.
|
|
84
|
+
|
|
85
|
+
The durable presentation surface composes the bounded slide catalog and
|
|
86
|
+
per-slide editor ABI. It keeps master/layout inheritance and node hierarchy in
|
|
87
|
+
the projection, renders inherited nodes read-only in slide mode, and maps
|
|
88
|
+
movement, resizing, and rich-text changes to canonical node commands. Geometry
|
|
89
|
+
uses the Office EMU-to-CSS-pixel scale; unchanged command fields retain their
|
|
90
|
+
exact canonical values. Slide and text-box insertion/deletion likewise use
|
|
91
|
+
canonical SDK/session commands; optimistic UI never mutates a shadow deck.
|
|
92
|
+
|
|
93
|
+
Run `OPENGENI_REACT_DEMO_API_TARGET=http://127.0.0.1:8000 bun run demo`, then
|
|
94
|
+
open `http://localhost:3100/editable-artifacts.html?workspaceId=<id>`. This is a
|
|
95
|
+
live public-SDK reference consumer for all three modalities; it has no in-memory
|
|
96
|
+
or permissive fallback.
|
|
97
|
+
|
|
98
|
+
`DocumentProjectionEditor`, `PresentationProjectionEditor`, and
|
|
99
|
+
`SpreadsheetProjectionGrid` expose the same host-owned projection/async-command
|
|
100
|
+
boundary without requiring the OpenGeni sync session. Pending, failure, retry,
|
|
101
|
+
read-only, focus, and reconciliation behavior stays inside the components.
|
|
102
|
+
|
|
103
|
+
Projection editors use browser-safe structural views and do not load
|
|
104
|
+
`@opengeni/artifact-tool`, its codecs, or native bindings. Local authoring tools
|
|
105
|
+
can optionally supply the reference models from `@opengeni/artifact-tool/reference`
|
|
106
|
+
to the compatible `DocumentEditor`,
|
|
107
|
+
`PresentationEditor`, or `SpreadsheetGrid` adapters. Those convenience adapters
|
|
108
|
+
deliberately mutate the supplied public authoring model.
|
|
109
|
+
`@opengeni/react/artifacts` remains the all-modality barrel.
|
|
110
|
+
|
|
27
111
|
## Install & styles
|
|
28
112
|
|
|
29
113
|
Hosts that render their own UI should import the session-only surface:
|
|
@@ -51,20 +135,40 @@ can therefore implement only the methods used by each hook. A shared event feed
|
|
|
51
135
|
also avoids requiring a client-owned event stream at runtime. Workspace-level
|
|
52
136
|
Resume is an optional authority.
|
|
53
137
|
|
|
54
|
-
The styled root surface
|
|
138
|
+
The styled root surface ships with ready-to-use CSS. Import it once; the host
|
|
139
|
+
does not need Tailwind:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import "@opengeni/react/compiled.css";
|
|
143
|
+
```
|
|
55
144
|
|
|
56
|
-
The
|
|
57
|
-
|
|
145
|
+
The compiled entry contains the package's Tailwind v4 utilities and tokens,
|
|
146
|
+
omits global Preflight, and scopes every style rule to `.og-root`. Components
|
|
147
|
+
put that class on their standalone roots, including portalled menus, dialogs,
|
|
148
|
+
tooltips, and lightboxes. The low-specificity scope covers both the root element
|
|
149
|
+
itself and its descendants, so utilities work in either shape without resetting
|
|
150
|
+
the host document or globally registering Tailwind's `--tw-*` custom properties.
|
|
151
|
+
Tailwind runtime variables are initialized per element only inside those roots.
|
|
152
|
+
Independent package defaults inherit without replacing host `--og-*` values;
|
|
153
|
+
derived defaults use scoped effective values so changing a base accent, radius,
|
|
154
|
+
motion, or surface token updates its dependents at runtime.
|
|
155
|
+
|
|
156
|
+
The original Tailwind v4 bridge remains available for hosts that intentionally
|
|
157
|
+
want OpenGeni utilities compiled into their own Tailwind entry:
|
|
58
158
|
|
|
59
159
|
```css
|
|
60
160
|
@import "tailwindcss";
|
|
61
161
|
@import "@opengeni/react/styles.css";
|
|
162
|
+
@import "@opengeni/react/responsive.css";
|
|
62
163
|
@source "../node_modules/@opengeni/react/src";
|
|
63
164
|
```
|
|
64
165
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
166
|
+
`@source` lets the host compiler discover utilities used inside the components.
|
|
167
|
+
`responsive.css` is the small opt-in layout layer for
|
|
168
|
+
`responsiveBasis="container"`; omit it when every composer keeps the historical
|
|
169
|
+
viewport basis. `compiled.css` already contains that layer. Do not import both
|
|
170
|
+
`compiled.css` and `styles.css`. Consuming only the tokens?
|
|
171
|
+
Import `@opengeni/react/tokens.css` and use the `--og-*` variables directly.
|
|
68
172
|
|
|
69
173
|
### Product-compatible theming and density
|
|
70
174
|
|
|
@@ -76,6 +180,12 @@ SDK type utilities are also scoped against ordinary host resets such as
|
|
|
76
180
|
`.app button { font: inherit }`; customize their public tokens instead of
|
|
77
181
|
adding selector-specific overrides.
|
|
78
182
|
|
|
183
|
+
Every portalled surface is an independent `.og-root`. Token-themed portal
|
|
184
|
+
content copies the effective `--og-*` values from its trigger, preserving an
|
|
185
|
+
enclosing light, compact, or rebranded theme even though it mounts under
|
|
186
|
+
`<body>`; a standalone root with `data-og-theme` or `data-og-density` works
|
|
187
|
+
directly as well.
|
|
188
|
+
|
|
79
189
|
For a narrow product sidebar, opt into the supported compact preset:
|
|
80
190
|
|
|
81
191
|
```tsx
|
|
@@ -85,6 +195,27 @@ For a narrow product sidebar, opt into the supported compact preset:
|
|
|
85
195
|
</aside>
|
|
86
196
|
```
|
|
87
197
|
|
|
198
|
+
Density and responsive measurement are separate opt-ins. By default,
|
|
199
|
+
`ChatComposer` keeps its existing viewport breakpoints. An embed whose composer
|
|
200
|
+
can be narrow inside a wide page should measure the composer instead:
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
<aside data-og-theme="light" data-og-density="compact">
|
|
204
|
+
<ChatComposer {...composerProps} responsiveBasis="container" />
|
|
205
|
+
</aside>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`responsiveBasis="container"` makes the composer root an inline-size query
|
|
209
|
+
container. Input density, footer wrapping, command descriptions, paused labels,
|
|
210
|
+
model controls, transcription status, and nested realtime controls then follow
|
|
211
|
+
that root's actual width. Coarse-pointer target sizing remains a separate media
|
|
212
|
+
feature, so a narrow mouse-driven panel stays compact while touch targets remain
|
|
213
|
+
at least 44px. Composer-owned model and realtime menus keep their portal
|
|
214
|
+
placement but copy the live root width with the existing theme tokens and never
|
|
215
|
+
grow wider than that source container. Compound layouts can pass the same prop
|
|
216
|
+
to `Composer.Root`. Hosts using the Tailwind source bridge import
|
|
217
|
+
`@opengeni/react/responsive.css`; the ready-to-use `compiled.css` includes it.
|
|
218
|
+
|
|
88
219
|
The preset is only a starting point. Override individual runtime tokens on the
|
|
89
220
|
same ancestor without rebuilding Tailwind:
|
|
90
221
|
|
|
@@ -104,7 +235,8 @@ The type ramp is `--og-font-size-{xs,sm,base,md}` with matching
|
|
|
104
235
|
`--og-line-height-*` tokens. Interactive chrome uses the semantic `control`,
|
|
105
236
|
`menu`, `composer`, and `composer-wide` pairs. Model picker height, width,
|
|
106
237
|
padding, and row-density tokens are grouped under `--og-model-picker-*` in
|
|
107
|
-
`styles/tokens.css
|
|
238
|
+
`styles/tokens.css`; realtime menu width uses `--og-realtime-menu-width`.
|
|
239
|
+
`ModelPolicyPicker` also exposes `contentClassName` and
|
|
108
240
|
`contentStyle` for exceptional surface-level customization; tokens are the
|
|
109
241
|
recommended path.
|
|
110
242
|
|
|
@@ -238,6 +370,11 @@ containing only `api-key` and/or `access-key` with
|
|
|
238
370
|
exposed as container environment variables. Local non-Kubernetes servers may
|
|
239
371
|
instead use `OPENGENI_DEMO_API_KEY` and/or `OPENGENI_DEMO_ACCESS_KEY`.
|
|
240
372
|
|
|
373
|
+
The container-responsive reference is `demo/composer-responsive.html`. It keeps
|
|
374
|
+
the browser viewport wide while resizing one child composer through 280, 320,
|
|
375
|
+
360, 420, 640, and 768px, with theme, density, paused, voice, model-menu, and
|
|
376
|
+
slash-command states available from the harness controls.
|
|
377
|
+
|
|
241
378
|
Microphone capture works on `localhost` or a secure HTTPS origin. A remote HTTP
|
|
242
379
|
deployment cannot request microphone access. The live page exercises catalog
|
|
243
380
|
loading, realtime-first creation, Codex Live, Gateway models, mute, recovery,
|
|
@@ -281,7 +418,7 @@ function CustomComposer({ sessionComposer, attachments, effectiveControl }) {
|
|
|
281
418
|
});
|
|
282
419
|
|
|
283
420
|
return (
|
|
284
|
-
<Composer.Root controller={controller}>
|
|
421
|
+
<Composer.Root controller={controller} responsiveBasis="container">
|
|
285
422
|
<Composer.Frame>
|
|
286
423
|
<Composer.CommandPalette />
|
|
287
424
|
<Composer.Surface>
|
|
@@ -366,8 +503,10 @@ state remains application-owned; durable draft and session state remain in
|
|
|
366
503
|
handlers) behind `CommandPalette`.
|
|
367
504
|
- `useWorkspaceSessions()` / `useScheduledTasks()` — workspace lists for
|
|
368
505
|
fleet/manager views (optional polling).
|
|
369
|
-
- `
|
|
370
|
-
|
|
506
|
+
- `useVariableSets()` — workspace variable sets with metadata-only generic
|
|
507
|
+
reads and create/update/remove/set/delete operations. Dedicated permissioned
|
|
508
|
+
exact-value reveal is part of the held React/UI train rather than an
|
|
509
|
+
implicit field on ordinary reads.
|
|
371
510
|
- `usePacks()` — capability packs + installations with
|
|
372
511
|
register/enable/remove and `installationFor(packId)`.
|
|
373
512
|
- `useWorkspaces()` — the caller's workspaces with create/update (client-only;
|
|
@@ -411,7 +550,10 @@ intentional changes should regenerate those snapshots and review the diff.
|
|
|
411
550
|
- `MessageTimeline` — the session timeline with stick-to-bottom scrolling, a
|
|
412
551
|
"jump to latest" affordance, streaming caret, collapsible activity clusters,
|
|
413
552
|
and worker cards (wire `onOpenSession` to drill into a worker). Pass
|
|
414
|
-
`renderMessageText` to plug a markdown renderer.
|
|
553
|
+
`renderMessageText` to plug a markdown renderer. Pass
|
|
554
|
+
`loadRetainedArtifact` to render permanent generated-image receipts; a loader
|
|
555
|
+
may return verified bytes or a short-lived signed URL. The stock web app uses
|
|
556
|
+
the URL path to avoid copying multi-megabyte images into JavaScript memory.
|
|
415
557
|
- `UserMessageBody` — the shared lossless rendered-height disclosure for
|
|
416
558
|
already-sent user text. Use it inside a custom `renderMessageText` user branch
|
|
417
559
|
so attachments and voice identity remain outside the clipped Markdown region.
|
|
@@ -472,10 +614,12 @@ capability document so every surface degrades to a reason instead of crashing.
|
|
|
472
614
|
- `useSessionCapabilities(sessionId, { attachDesktop?, attachTerminal?, attachFiles? })`
|
|
473
615
|
— negotiates the per-session capability doc, tracks lease liveness
|
|
474
616
|
(`cold`/`warming`/`warm`), and acquires the viewer holder(s) that keep the box
|
|
475
|
-
warm.
|
|
617
|
+
warm. Opening `DesktopViewer` engages the desktop immediately and records any
|
|
618
|
+
required un-redacted/shared acknowledgment automatically before attaching.
|
|
476
619
|
- `useSandboxFiles` / `useSandboxGit` — the Pierre file tree + git status/diff
|
|
477
|
-
feeds
|
|
478
|
-
`
|
|
620
|
+
feeds. Initial and refresh reads use the SDK's batched file-frontier and
|
|
621
|
+
multi-repository Git queries behind one sandbox lease; `fs.changed` /
|
|
622
|
+
`git.changed` notifications keep the result live.
|
|
479
623
|
- `useSandboxTerminal` / `useTerminalStream` — the read-only command-output
|
|
480
624
|
firehose and the real interactive PTY over the minted `pty-ws` cell.
|
|
481
625
|
- `useDesktopStream` — the noVNC socket, hot-swapped on box rollover via
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Document-only artifact surface. Import from `@opengeni/react/artifacts/document`. */
|
|
2
|
+
export { EditableDocumentArtifactSurface, type EditableDocumentArtifactSurfaceProps, } from "./components/artifacts/editable-document.js";
|
|
3
|
+
export { DocumentArtifactSurface, DocumentEditor, DocumentProjectionArtifactSurface, DocumentProjectionEditor, type DocumentArtifactSurfaceProps, type DocumentCommit, type DocumentCommitHandler, type DocumentEditorProps, type DocumentEditorProjection, type DocumentLayoutMode, type DocumentProjectionArtifactSurfaceProps, type DocumentProjectionBlock, type DocumentProjectionChange, type DocumentProjectionComment, type DocumentProjectionEditorProps, type DocumentProjectionPageBreak, type DocumentProjectionPageGeometry, type DocumentProjectionParagraph, type DocumentProjectionParagraphStyle, type DocumentProjectionSection, type DocumentProjectionTable, type DocumentProjectionTextRun, type DocumentProjectionTextStyle, type DocumentSelection, } from "./components/artifacts/document-editor.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DocumentArtifactSurface,
|
|
3
|
+
DocumentEditor,
|
|
4
|
+
DocumentProjectionArtifactSurface,
|
|
5
|
+
DocumentProjectionEditor,
|
|
6
|
+
EditableDocumentArtifactSurface
|
|
7
|
+
} from "./chunk-HUIKIDM5.js";
|
|
8
|
+
import "./chunk-KCGXPP5V.js";
|
|
9
|
+
import "./chunk-22KP6LR5.js";
|
|
10
|
+
export {
|
|
11
|
+
DocumentArtifactSurface,
|
|
12
|
+
DocumentEditor,
|
|
13
|
+
DocumentProjectionArtifactSurface,
|
|
14
|
+
DocumentProjectionEditor,
|
|
15
|
+
EditableDocumentArtifactSurface
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=artifacts-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Presentation-only artifact surface. Import from `@opengeni/react/artifacts/presentation`. */
|
|
2
|
+
export { EditablePresentationArtifactSurface, type EditablePresentationArtifactSurfaceProps, } from "./components/artifacts/editable-presentation.js";
|
|
3
|
+
export { PresentationArtifactSurface, PresentationEditor, PresentationProjectionArtifactSurface, PresentationProjectionEditor, type PresentationArtifactSurfaceProps, type PresentationCommit, type PresentationCommitHandler, type PresentationEditorProps, type PresentationEditorProjection, type PresentationProjectionArtifactSurfaceProps, type PresentationProjectionChart, type PresentationProjectionChartSeries, type PresentationProjectionConnector, type PresentationProjectionEditorProps, type PresentationProjectionElementMetadata, type PresentationProjectionElement, type PresentationProjectionFill, type PresentationProjectionGroup, type PresentationProjectionImage, type PresentationProjectionLine, type PresentationProjectionPosition, type PresentationProjectionRichText, type PresentationProjectionShape, type PresentationProjectionTable, type PresentationProjectionTableCell, type PresentationProjectionTextParagraph, type PresentationProjectionTextRun, type PresentationProjectionTextStyle, type PresentationSlideProjection, } from "./components/artifacts/presentation-editor.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditablePresentationArtifactSurface,
|
|
3
|
+
PresentationArtifactSurface,
|
|
4
|
+
PresentationEditor,
|
|
5
|
+
PresentationProjectionArtifactSurface,
|
|
6
|
+
PresentationProjectionEditor
|
|
7
|
+
} from "./chunk-PEI6RANI.js";
|
|
8
|
+
import "./chunk-KCGXPP5V.js";
|
|
9
|
+
import "./chunk-22KP6LR5.js";
|
|
10
|
+
export {
|
|
11
|
+
EditablePresentationArtifactSurface,
|
|
12
|
+
PresentationArtifactSurface,
|
|
13
|
+
PresentationEditor,
|
|
14
|
+
PresentationProjectionArtifactSurface,
|
|
15
|
+
PresentationProjectionEditor
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=artifacts-presentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Spreadsheet-only artifact surface. Import from `@opengeni/react/artifacts/spreadsheet`. */
|
|
2
|
+
export { SpreadsheetArtifactSurface, SpreadsheetGrid, SpreadsheetProjectionGrid, type SpreadsheetArtifactSurfaceProps, type SpreadsheetCommit, type SpreadsheetRangeCommit, type SpreadsheetGridProps, type SpreadsheetGridProjection, type SpreadsheetProjectionCell, type SpreadsheetProjectionGridProps, type SpreadsheetSelection, type SpreadsheetViewport, } from "./components/artifacts/spreadsheet-grid.js";
|
|
3
|
+
export { EditableSpreadsheetArtifactSurface, EditableSpreadsheetGrid, type EditableSpreadsheetArtifactSurfaceProps, type EditableSpreadsheetGridProps, } from "./components/artifacts/editable-spreadsheet.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditableSpreadsheetArtifactSurface,
|
|
3
|
+
EditableSpreadsheetGrid,
|
|
4
|
+
SpreadsheetArtifactSurface,
|
|
5
|
+
SpreadsheetGrid,
|
|
6
|
+
SpreadsheetProjectionGrid
|
|
7
|
+
} from "./chunk-7WCLAEFV.js";
|
|
8
|
+
import "./chunk-KCGXPP5V.js";
|
|
9
|
+
import "./chunk-22KP6LR5.js";
|
|
10
|
+
export {
|
|
11
|
+
EditableSpreadsheetArtifactSurface,
|
|
12
|
+
EditableSpreadsheetGrid,
|
|
13
|
+
SpreadsheetArtifactSurface,
|
|
14
|
+
SpreadsheetGrid,
|
|
15
|
+
SpreadsheetProjectionGrid
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=artifacts-spreadsheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Public artifact surfaces. Import from `@opengeni/react/artifacts`. */
|
|
2
|
+
export { ArtifactSurface, DocumentArtifactSurface, DocumentEditor, DocumentProjectionArtifactSurface, DocumentProjectionEditor, BrowserEditableArtifactWorkbench, EditableDocumentArtifactSurface, EditableArtifactWorkbench, EditableArtifactWorkbenchHost, EditablePresentationArtifactSurface, EditableSpreadsheetArtifactSurface, EditableSpreadsheetGrid, PresentationArtifactSurface, PresentationEditor, PresentationProjectionArtifactSurface, PresentationProjectionEditor, SpreadsheetArtifactSurface, SpreadsheetGrid, SpreadsheetProjectionGrid, type ArtifactModality, type ArtifactSurfaceProps, type DocumentArtifactSurfaceProps, type DocumentCommit, type DocumentCommitHandler, type DocumentEditorProps, type DocumentEditorProjection, type DocumentLayoutMode, type DocumentProjectionArtifactSurfaceProps, type DocumentProjectionBlock, type DocumentProjectionChange, type DocumentProjectionComment, type DocumentProjectionEditorProps, type DocumentProjectionPageBreak, type DocumentProjectionPageGeometry, type DocumentProjectionParagraph, type DocumentProjectionParagraphStyle, type DocumentProjectionSection, type DocumentProjectionTable, type DocumentProjectionTextRun, type DocumentProjectionTextStyle, type DocumentSelection, type BrowserEditableArtifactWorkbenchOptions, type BrowserEditableArtifactWorkbenchProps, type EditableDocumentArtifactSurfaceProps, type EditableArtifactWorkbenchHostProps, type EditableArtifactWorkbenchProps, type EditablePresentationArtifactSurfaceProps, type EditableSpreadsheetArtifactSurfaceProps, type EditableSpreadsheetGridProps, type PresentationArtifactSurfaceProps, type PresentationCommit, type PresentationCommitHandler, type PresentationEditorProps, type PresentationEditorProjection, type PresentationProjectionArtifactSurfaceProps, type PresentationProjectionChart, type PresentationProjectionChartSeries, type PresentationProjectionConnector, type PresentationProjectionEditorProps, type PresentationProjectionElementMetadata, type PresentationProjectionElement, type PresentationProjectionFill, type PresentationProjectionGroup, type PresentationProjectionImage, type PresentationProjectionLine, type PresentationProjectionPosition, type PresentationProjectionRichText, type PresentationProjectionShape, type PresentationProjectionTable, type PresentationProjectionTableCell, type PresentationProjectionTextParagraph, type PresentationProjectionTextRun, type PresentationProjectionTextStyle, type PresentationSlideProjection, type SpreadsheetArtifactSurfaceProps, type SpreadsheetCommit, type SpreadsheetRangeCommit, type SpreadsheetGridProps, type SpreadsheetGridProjection, type SpreadsheetProjectionCell, type SpreadsheetProjectionGridProps, type SpreadsheetSelection, type SpreadsheetViewport, } from "./components/artifacts/index.js";
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DocumentArtifactSurface,
|
|
3
|
+
DocumentEditor,
|
|
4
|
+
DocumentProjectionArtifactSurface,
|
|
5
|
+
DocumentProjectionEditor,
|
|
6
|
+
EditableDocumentArtifactSurface
|
|
7
|
+
} from "./chunk-HUIKIDM5.js";
|
|
8
|
+
import {
|
|
9
|
+
EditablePresentationArtifactSurface,
|
|
10
|
+
PresentationArtifactSurface,
|
|
11
|
+
PresentationEditor,
|
|
12
|
+
PresentationProjectionArtifactSurface,
|
|
13
|
+
PresentationProjectionEditor
|
|
14
|
+
} from "./chunk-PEI6RANI.js";
|
|
15
|
+
import {
|
|
16
|
+
EditableSpreadsheetArtifactSurface,
|
|
17
|
+
EditableSpreadsheetGrid,
|
|
18
|
+
SpreadsheetArtifactSurface,
|
|
19
|
+
SpreadsheetGrid,
|
|
20
|
+
SpreadsheetProjectionGrid
|
|
21
|
+
} from "./chunk-7WCLAEFV.js";
|
|
22
|
+
import {
|
|
23
|
+
ArtifactSurface,
|
|
24
|
+
EditableArtifactMessage
|
|
25
|
+
} from "./chunk-KCGXPP5V.js";
|
|
26
|
+
import "./chunk-22KP6LR5.js";
|
|
27
|
+
|
|
28
|
+
// src/components/artifacts/editable-artifact-workbench.tsx
|
|
29
|
+
import {
|
|
30
|
+
createBrowserEditableArtifactSession
|
|
31
|
+
} from "@opengeni/sdk/editable-artifacts";
|
|
32
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
33
|
+
import { jsx } from "react/jsx-runtime";
|
|
34
|
+
function EditableArtifactWorkbench({
|
|
35
|
+
session,
|
|
36
|
+
document,
|
|
37
|
+
spreadsheet,
|
|
38
|
+
presentation
|
|
39
|
+
}) {
|
|
40
|
+
switch (session.modality) {
|
|
41
|
+
case "document":
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
EditableDocumentArtifactSurface,
|
|
44
|
+
{
|
|
45
|
+
...document,
|
|
46
|
+
session,
|
|
47
|
+
title: document?.title ?? "Document"
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
case "spreadsheet":
|
|
51
|
+
return /* @__PURE__ */ jsx(EditableSpreadsheetArtifactSurface, { ...spreadsheet, session });
|
|
52
|
+
case "presentation":
|
|
53
|
+
return /* @__PURE__ */ jsx(EditablePresentationArtifactSurface, { ...presentation, session });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function EditableArtifactWorkbenchHost({
|
|
57
|
+
sessionKey,
|
|
58
|
+
createSession,
|
|
59
|
+
document,
|
|
60
|
+
spreadsheet,
|
|
61
|
+
presentation
|
|
62
|
+
}) {
|
|
63
|
+
const createSessionRef = useRef(createSession);
|
|
64
|
+
const [retryEpoch, setRetryEpoch] = useState(0);
|
|
65
|
+
const [state, setState] = useState({ key: null, session: null, error: null });
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
createSessionRef.current = createSession;
|
|
68
|
+
}, [createSession]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
let owned = null;
|
|
71
|
+
setState({ key: sessionKey, session: null, error: null });
|
|
72
|
+
try {
|
|
73
|
+
owned = createSessionRef.current();
|
|
74
|
+
setState({ key: sessionKey, session: owned, error: null });
|
|
75
|
+
} catch (cause) {
|
|
76
|
+
setState({
|
|
77
|
+
key: sessionKey,
|
|
78
|
+
session: null,
|
|
79
|
+
error: cause instanceof Error ? cause : new Error("Could not create artifact session")
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
const closing = owned;
|
|
84
|
+
owned = null;
|
|
85
|
+
if (closing) void closing.close().catch(() => void 0);
|
|
86
|
+
};
|
|
87
|
+
}, [retryEpoch, sessionKey]);
|
|
88
|
+
const retry = useCallback(() => setRetryEpoch((value) => value + 1), []);
|
|
89
|
+
const currentError = state.key === sessionKey ? state.error : null;
|
|
90
|
+
if (state.key === sessionKey && state.session) {
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
EditableArtifactWorkbench,
|
|
93
|
+
{
|
|
94
|
+
session: state.session,
|
|
95
|
+
...document ? { document } : {},
|
|
96
|
+
...spreadsheet ? { spreadsheet } : {},
|
|
97
|
+
...presentation ? { presentation } : {}
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
EditableArtifactMessage,
|
|
103
|
+
{
|
|
104
|
+
title: currentError ? "Could not open this artifact" : "Opening artifact",
|
|
105
|
+
detail: currentError?.message ?? "Starting the secure editing session\u2026",
|
|
106
|
+
retry: currentError ? retry : void 0
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function BrowserEditableArtifactWorkbench({
|
|
111
|
+
options,
|
|
112
|
+
document,
|
|
113
|
+
spreadsheet,
|
|
114
|
+
presentation
|
|
115
|
+
}) {
|
|
116
|
+
const sessionKey = browserSessionKey(options);
|
|
117
|
+
const createSession = useCallback(() => createBrowserEditableArtifactSession(options), [options]);
|
|
118
|
+
return /* @__PURE__ */ jsx(
|
|
119
|
+
EditableArtifactWorkbenchHost,
|
|
120
|
+
{
|
|
121
|
+
sessionKey,
|
|
122
|
+
createSession,
|
|
123
|
+
...document ? { document } : {},
|
|
124
|
+
...spreadsheet ? { spreadsheet } : {},
|
|
125
|
+
...presentation ? { presentation } : {}
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function browserSessionKey(options) {
|
|
130
|
+
const transport = options.transport ? {
|
|
131
|
+
...options.transport,
|
|
132
|
+
// Credentials must not be copied into React lifecycle keys. The
|
|
133
|
+
// authorization epoch is the explicit credential/grant rotation fence.
|
|
134
|
+
headers: options.transport.headers ? Object.keys(options.transport.headers).sort() : void 0
|
|
135
|
+
} : null;
|
|
136
|
+
return JSON.stringify(
|
|
137
|
+
{
|
|
138
|
+
baseUrl: options.baseUrl,
|
|
139
|
+
workspaceId: options.workspaceId,
|
|
140
|
+
artifact: { id: options.artifact.id, modality: options.artifact.modality },
|
|
141
|
+
storageAuthority: options.storageAuthority,
|
|
142
|
+
runtime: options.runtime,
|
|
143
|
+
replicaId: options.replicaId ?? null,
|
|
144
|
+
transport
|
|
145
|
+
},
|
|
146
|
+
(_key, value) => value instanceof URL ? value.href : value
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
ArtifactSurface,
|
|
151
|
+
BrowserEditableArtifactWorkbench,
|
|
152
|
+
DocumentArtifactSurface,
|
|
153
|
+
DocumentEditor,
|
|
154
|
+
DocumentProjectionArtifactSurface,
|
|
155
|
+
DocumentProjectionEditor,
|
|
156
|
+
EditableArtifactWorkbench,
|
|
157
|
+
EditableArtifactWorkbenchHost,
|
|
158
|
+
EditableDocumentArtifactSurface,
|
|
159
|
+
EditablePresentationArtifactSurface,
|
|
160
|
+
EditableSpreadsheetArtifactSurface,
|
|
161
|
+
EditableSpreadsheetGrid,
|
|
162
|
+
PresentationArtifactSurface,
|
|
163
|
+
PresentationEditor,
|
|
164
|
+
PresentationProjectionArtifactSurface,
|
|
165
|
+
PresentationProjectionEditor,
|
|
166
|
+
SpreadsheetArtifactSurface,
|
|
167
|
+
SpreadsheetGrid,
|
|
168
|
+
SpreadsheetProjectionGrid
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/artifacts/editable-artifact-workbench.tsx"],"sourcesContent":["import {\n createBrowserEditableArtifactSession,\n type CreateBrowserEditableArtifactSessionOptions,\n type EditableArtifactBrowserRuntime,\n type EditableArtifactSession,\n} from \"@opengeni/sdk/editable-artifacts\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { EditableArtifactMessage } from \"./editable-artifact-ui\";\nimport {\n EditableDocumentArtifactSurface,\n type EditableDocumentArtifactSurfaceProps,\n} from \"./editable-document\";\nimport {\n EditablePresentationArtifactSurface,\n type EditablePresentationArtifactSurfaceProps,\n} from \"./editable-presentation\";\nimport {\n EditableSpreadsheetArtifactSurface,\n type EditableSpreadsheetArtifactSurfaceProps,\n} from \"./editable-spreadsheet\";\n\nexport type EditableArtifactWorkbenchProps = Readonly<{\n session: EditableArtifactSession;\n document?: Omit<EditableDocumentArtifactSurfaceProps, \"session\">;\n spreadsheet?: Omit<EditableSpreadsheetArtifactSurfaceProps, \"session\">;\n presentation?: Omit<EditablePresentationArtifactSurfaceProps, \"session\">;\n}>;\n\nexport type EditableArtifactWorkbenchHostProps = Omit<EditableArtifactWorkbenchProps, \"session\"> &\n Readonly<{\n /**\n * Complete identity of the browser session authority. Change this when the\n * artifact, deployment, principal, or authorization epoch changes.\n */\n sessionKey: string;\n /** Called for the active keyed lifecycle and again only after replacement or retry. */\n createSession: () => EditableArtifactSession;\n }>;\n\ntype DefaultBrowserArtifactTransport = Omit<\n NonNullable<CreateBrowserEditableArtifactSessionOptions[\"transport\"]>,\n \"apiKey\" | \"fetch\" | \"headers\" | \"webSocketFactory\"\n> &\n Readonly<{\n /** Static deployment auth headers; rotate authorizationEpoch when they change. */\n headers?: Readonly<Record<string, string>>;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchOptions = Omit<\n CreateBrowserEditableArtifactSessionOptions,\n \"runtime\" | \"storage\" | \"transport\"\n> &\n Readonly<{\n /** Default module Worker only; custom Worker hosts use EditableArtifactWorkbenchHost. */\n runtime: Omit<EditableArtifactBrowserRuntime, \"workerFactory\">;\n /** Default fetch/WebSocket only; static deployment auth headers are supported. */\n transport?: DefaultBrowserArtifactTransport;\n }>;\n\nexport type BrowserEditableArtifactWorkbenchProps = Omit<\n EditableArtifactWorkbenchProps,\n \"session\"\n> &\n Readonly<{ options: BrowserEditableArtifactWorkbenchOptions }>;\n\n/**\n * One modality-neutral SDK workbench. Embedding hosts keep one route/component;\n * each artifact still renders through its complete first-party editor surface.\n */\nexport function EditableArtifactWorkbench({\n session,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchProps) {\n switch (session.modality) {\n case \"document\":\n return (\n <EditableDocumentArtifactSurface\n {...document}\n session={session}\n title={document?.title ?? \"Document\"}\n />\n );\n case \"spreadsheet\":\n return <EditableSpreadsheetArtifactSurface {...spreadsheet} session={session} />;\n case \"presentation\":\n return <EditablePresentationArtifactSurface {...presentation} session={session} />;\n }\n}\n\n/**\n * Route/embed composition that owns exactly one SDK session. The host supplies\n * the authenticated SDK factory; React guarantees replacement and teardown.\n */\nexport function EditableArtifactWorkbenchHost({\n sessionKey,\n createSession,\n document,\n spreadsheet,\n presentation,\n}: EditableArtifactWorkbenchHostProps) {\n const createSessionRef = useRef(createSession);\n const [retryEpoch, setRetryEpoch] = useState(0);\n const [state, setState] = useState<\n | Readonly<{ key: string; session: EditableArtifactSession; error: null }>\n | Readonly<{ key: string | null; session: null; error: Error | null }>\n >({ key: null, session: null, error: null });\n\n useEffect(() => {\n createSessionRef.current = createSession;\n }, [createSession]);\n\n useEffect(() => {\n let owned: EditableArtifactSession | null = null;\n setState({ key: sessionKey, session: null, error: null });\n try {\n owned = createSessionRef.current();\n setState({ key: sessionKey, session: owned, error: null });\n } catch (cause) {\n setState({\n key: sessionKey,\n session: null,\n error: cause instanceof Error ? cause : new Error(\"Could not create artifact session\"),\n });\n }\n return () => {\n const closing = owned;\n owned = null;\n if (closing) void closing.close().catch(() => undefined);\n };\n }, [retryEpoch, sessionKey]);\n\n const retry = useCallback(() => setRetryEpoch((value) => value + 1), []);\n const currentError = state.key === sessionKey ? state.error : null;\n if (state.key === sessionKey && state.session) {\n return (\n <EditableArtifactWorkbench\n session={state.session}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n }\n return (\n <EditableArtifactMessage\n title={currentError ? \"Could not open this artifact\" : \"Opening artifact\"}\n detail={currentError?.message ?? \"Starting the secure editing session…\"}\n retry={currentError ? retry : undefined}\n />\n );\n}\n\n/**\n * Complete default-browser composition for embedders: verified WASM Worker,\n * durable IndexedDB state, authenticated live sync, teardown, and the matching\n * first-party editor. Advanced/custom transports compose the lower-level host.\n */\nexport function BrowserEditableArtifactWorkbench({\n options,\n document,\n spreadsheet,\n presentation,\n}: BrowserEditableArtifactWorkbenchProps) {\n const sessionKey = browserSessionKey(options);\n const createSession = useCallback(() => createBrowserEditableArtifactSession(options), [options]);\n return (\n <EditableArtifactWorkbenchHost\n sessionKey={sessionKey}\n createSession={createSession}\n {...(document ? { document } : {})}\n {...(spreadsheet ? { spreadsheet } : {})}\n {...(presentation ? { presentation } : {})}\n />\n );\n}\n\nfunction browserSessionKey(options: BrowserEditableArtifactWorkbenchOptions): string {\n const transport = options.transport\n ? {\n ...options.transport,\n // Credentials must not be copied into React lifecycle keys. The\n // authorization epoch is the explicit credential/grant rotation fence.\n headers: options.transport.headers\n ? Object.keys(options.transport.headers).sort()\n : undefined,\n }\n : null;\n return JSON.stringify(\n {\n baseUrl: options.baseUrl,\n workspaceId: options.workspaceId,\n artifact: { id: options.artifact.id, modality: options.artifact.modality },\n storageAuthority: options.storageAuthority,\n runtime: options.runtime,\n replicaId: options.replicaId ?? null,\n transport,\n },\n (_key, value: unknown) => (value instanceof URL ? value.href : value),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAyEjD;AATD,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aACE;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,UACA,OAAO,UAAU,SAAS;AAAA;AAAA,MAC5B;AAAA,IAEJ,KAAK;AACH,aAAO,oBAAC,sCAAoC,GAAG,aAAa,SAAkB;AAAA,IAChF,KAAK;AACH,aAAO,oBAAC,uCAAqC,GAAG,cAAc,SAAkB;AAAA,EACpF;AACF;AAMO,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,mBAAmB,OAAO,aAAa;AAC7C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,CAAC;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAGxB,EAAE,KAAK,MAAM,SAAS,MAAM,OAAO,KAAK,CAAC;AAE3C,YAAU,MAAM;AACd,qBAAiB,UAAU;AAAA,EAC7B,GAAG,CAAC,aAAa,CAAC;AAElB,YAAU,MAAM;AACd,QAAI,QAAwC;AAC5C,aAAS,EAAE,KAAK,YAAY,SAAS,MAAM,OAAO,KAAK,CAAC;AACxD,QAAI;AACF,cAAQ,iBAAiB,QAAQ;AACjC,eAAS,EAAE,KAAK,YAAY,SAAS,OAAO,OAAO,KAAK,CAAC;AAAA,IAC3D,SAAS,OAAO;AACd,eAAS;AAAA,QACP,KAAK;AAAA,QACL,SAAS;AAAA,QACT,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,mCAAmC;AAAA,MACvF,CAAC;AAAA,IACH;AACA,WAAO,MAAM;AACX,YAAM,UAAU;AAChB,cAAQ;AACR,UAAI,QAAS,MAAK,QAAQ,MAAM,EAAE,MAAM,MAAM,MAAS;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,YAAY,UAAU,CAAC;AAE3B,QAAM,QAAQ,YAAY,MAAM,cAAc,CAAC,UAAU,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvE,QAAM,eAAe,MAAM,QAAQ,aAAa,MAAM,QAAQ;AAC9D,MAAI,MAAM,QAAQ,cAAc,MAAM,SAAS;AAC7C,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,MAAM;AAAA,QACd,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,QAC/B,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;AAAA,QACrC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA;AAAA,IAC1C;AAAA,EAEJ;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,eAAe,iCAAiC;AAAA,MACvD,QAAQ,cAAc,WAAW;AAAA,MACjC,OAAO,eAAe,QAAQ;AAAA;AAAA,EAChC;AAEJ;AAOO,SAAS,iCAAiC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0C;AACxC,QAAM,aAAa,kBAAkB,OAAO;AAC5C,QAAM,gBAAgB,YAAY,MAAM,qCAAqC,OAAO,GAAG,CAAC,OAAO,CAAC;AAChG,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACC,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,MAC/B,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;AAAA,MACrC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA;AAAA,EAC1C;AAEJ;AAEA,SAAS,kBAAkB,SAA0D;AACnF,QAAM,YAAY,QAAQ,YACtB;AAAA,IACE,GAAG,QAAQ;AAAA;AAAA;AAAA,IAGX,SAAS,QAAQ,UAAU,UACvB,OAAO,KAAK,QAAQ,UAAU,OAAO,EAAE,KAAK,IAC5C;AAAA,EACN,IACA;AACJ,SAAO,KAAK;AAAA,IACV;AAAA,MACE,SAAS,QAAQ;AAAA,MACjB,aAAa,QAAQ;AAAA,MACrB,UAAU,EAAE,IAAI,QAAQ,SAAS,IAAI,UAAU,QAAQ,SAAS,SAAS;AAAA,MACzE,kBAAkB,QAAQ;AAAA,MAC1B,SAAS,QAAQ;AAAA,MACjB,WAAW,QAAQ,aAAa;AAAA,MAChC;AAAA,IACF;AAAA,IACA,CAAC,MAAM,UAAoB,iBAAiB,MAAM,MAAM,OAAO;AAAA,EACjE;AACF;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/lib/relay-wire.ts
|
|
2
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
|
+
var STREAM_KIND_DESKTOP = 2;
|
|
4
|
+
var STREAM_KIND_BROWSER = 3;
|
|
5
|
+
var STREAM_KIND_COMPUTER = 4;
|
|
6
|
+
var STREAM_ROLE_CLIENT = 2;
|
|
7
|
+
function encodeChannel(message, writer) {
|
|
8
|
+
if (message.channelId !== "") writer.uint32(10).string(message.channelId);
|
|
9
|
+
if (message.workspaceId !== "") writer.uint32(18).string(message.workspaceId);
|
|
10
|
+
if (message.agentId !== "") writer.uint32(26).string(message.agentId);
|
|
11
|
+
if (message.kind !== 0) writer.uint32(32).int32(message.kind);
|
|
12
|
+
if (message.port !== 0) writer.uint32(40).uint32(message.port);
|
|
13
|
+
return writer;
|
|
14
|
+
}
|
|
15
|
+
function encodeStreamOpen(message) {
|
|
16
|
+
const writer = new BinaryWriter();
|
|
17
|
+
encodeChannel(message.channel, writer.uint32(10).fork()).join();
|
|
18
|
+
if (message.token !== "") writer.uint32(18).string(message.token);
|
|
19
|
+
if (message.role !== 0) writer.uint32(24).int32(message.role);
|
|
20
|
+
if (message.resumeFromSeq !== "0") writer.uint32(32).uint64(message.resumeFromSeq);
|
|
21
|
+
return writer.finish();
|
|
22
|
+
}
|
|
23
|
+
function decodeAgentErrorMessage(reader, length) {
|
|
24
|
+
const end = reader.pos + length;
|
|
25
|
+
let message;
|
|
26
|
+
while (reader.pos < end) {
|
|
27
|
+
const tag = reader.uint32();
|
|
28
|
+
if (tag >>> 3 === 2 && tag === 18) {
|
|
29
|
+
message = reader.string();
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
33
|
+
reader.skip(tag & 7);
|
|
34
|
+
}
|
|
35
|
+
return message !== void 0 ? { message } : {};
|
|
36
|
+
}
|
|
37
|
+
function decodeStreamOpenAck(bytes) {
|
|
38
|
+
const reader = new BinaryReader(bytes);
|
|
39
|
+
const end = reader.len;
|
|
40
|
+
let accepted = false;
|
|
41
|
+
let error;
|
|
42
|
+
while (reader.pos < end) {
|
|
43
|
+
const tag = reader.uint32();
|
|
44
|
+
if (tag >>> 3 === 1 && tag === 8) {
|
|
45
|
+
accepted = reader.bool();
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (tag >>> 3 === 2 && tag === 18) {
|
|
49
|
+
error = decodeAgentErrorMessage(reader, reader.uint32());
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
53
|
+
reader.skip(tag & 7);
|
|
54
|
+
}
|
|
55
|
+
return error !== void 0 ? { accepted, error } : { accepted };
|
|
56
|
+
}
|
|
57
|
+
function decodeStreamFrame(bytes) {
|
|
58
|
+
const reader = new BinaryReader(bytes);
|
|
59
|
+
const end = reader.len;
|
|
60
|
+
let data = new Uint8Array(0);
|
|
61
|
+
while (reader.pos < end) {
|
|
62
|
+
const tag = reader.uint32();
|
|
63
|
+
if (tag >>> 3 === 3 && tag === 26) {
|
|
64
|
+
data = new Uint8Array(reader.bytes());
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
68
|
+
reader.skip(tag & 7);
|
|
69
|
+
}
|
|
70
|
+
return { data };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
STREAM_KIND_DESKTOP,
|
|
75
|
+
STREAM_KIND_BROWSER,
|
|
76
|
+
STREAM_KIND_COMPUTER,
|
|
77
|
+
STREAM_ROLE_CLIENT,
|
|
78
|
+
encodeStreamOpen,
|
|
79
|
+
decodeStreamOpenAck,
|
|
80
|
+
decodeStreamFrame
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=chunk-6BBWWOOU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/relay-wire.ts"],"sourcesContent":["// Minimal HAND-MIRROR of the relay stream wire messages the desktop frame client\n// needs (`StreamOpen` encode; `StreamOpenAck` + `StreamFrame` decode). It exists\n// because the publish-closure guard (scripts/publish-closure-guard.ts) forbids\n// `@opengeni/react` from depending on `@opengeni/agent-proto` — the published SDK\n// closure may only reach `@opengeni/sdk` among `@opengeni/*` packages. So, exactly\n// as the guard prescribes (\"hand-mirror it\"), we re-encode just these three\n// messages against the third-party `@bufbuild/protobuf/wire` runtime (the same\n// runtime `@opengeni/agent-proto` generates against), byte-compatible with the\n// generated code. Field numbers copied verbatim from\n// `packages/agent-proto/src/gen/opengeni_agent.ts`:\n// StreamChannel: channelId=1, workspaceId=2, agentId=3, kind=4(int32), port=5(uint32)\n// StreamOpen: channel=1(msg), token=2, role=3(int32), resumeFromSeq=4(uint64, omitted when \"0\")\n// StreamOpenAck: accepted=1(bool), error=2(AgentError msg), resumeFromSeq=3\n// AgentError: code=1, message=2, retryable=3, detail=4 (we read only message)\n// StreamFrame: channelId=1, seq=2, data=3(bytes), producedAtMs=4 (we read only data)\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\n\n/** `StreamKind.STREAM_KIND_DESKTOP` (agent-proto enum value). */\nexport const STREAM_KIND_DESKTOP = 2;\n/** `StreamKind.STREAM_KIND_BROWSER` (agent-proto enum value). */\nexport const STREAM_KIND_BROWSER = 3;\n/** `StreamKind.STREAM_KIND_COMPUTER` (agent-proto enum value). */\nexport const STREAM_KIND_COMPUTER = 4;\n/** `StreamRole.STREAM_ROLE_CLIENT` (agent-proto enum value). */\nexport const STREAM_ROLE_CLIENT = 2;\n\nexport interface RelayChannel {\n channelId: string;\n workspaceId: string;\n agentId: string;\n kind: number;\n port: number;\n}\n\nexport interface RelayStreamOpen {\n channel: RelayChannel;\n token: string;\n role: number;\n resumeFromSeq: string;\n}\n\nfunction encodeChannel(message: RelayChannel, writer: BinaryWriter): BinaryWriter {\n if (message.channelId !== \"\") writer.uint32(10).string(message.channelId);\n if (message.workspaceId !== \"\") writer.uint32(18).string(message.workspaceId);\n if (message.agentId !== \"\") writer.uint32(26).string(message.agentId);\n if (message.kind !== 0) writer.uint32(32).int32(message.kind);\n if (message.port !== 0) writer.uint32(40).uint32(message.port);\n return writer;\n}\n\n/** Encode a `StreamOpen`, byte-compatible with `StreamOpen.encode(...).finish()`. */\nexport function encodeStreamOpen(message: RelayStreamOpen): Uint8Array {\n const writer = new BinaryWriter();\n encodeChannel(message.channel, writer.uint32(10).fork()).join();\n if (message.token !== \"\") writer.uint32(18).string(message.token);\n if (message.role !== 0) writer.uint32(24).int32(message.role);\n if (message.resumeFromSeq !== \"0\") writer.uint32(32).uint64(message.resumeFromSeq);\n return writer.finish();\n}\n\n/** The only `AgentError` field we surface from a rejected ack. */\nfunction decodeAgentErrorMessage(reader: BinaryReader, length: number): { message?: string } {\n const end = reader.pos + length;\n let message: string | undefined;\n while (reader.pos < end) {\n const tag = reader.uint32();\n if (tag >>> 3 === 2 && tag === 18) {\n message = reader.string();\n continue;\n }\n if ((tag & 7) === 4 || tag === 0) break;\n reader.skip(tag & 7);\n }\n return message !== undefined ? { message } : {};\n}\n\n/** Decode a `StreamOpenAck` (we need `accepted` + the error message). */\nexport function decodeStreamOpenAck(bytes: Uint8Array): {\n accepted: boolean;\n error?: { message?: string };\n} {\n const reader = new BinaryReader(bytes);\n const end = reader.len;\n let accepted = false;\n let error: { message?: string } | undefined;\n while (reader.pos < end) {\n const tag = reader.uint32();\n if (tag >>> 3 === 1 && tag === 8) {\n accepted = reader.bool();\n continue;\n }\n if (tag >>> 3 === 2 && tag === 18) {\n error = decodeAgentErrorMessage(reader, reader.uint32());\n continue;\n }\n if ((tag & 7) === 4 || tag === 0) break;\n reader.skip(tag & 7);\n }\n return error !== undefined ? { accepted, error } : { accepted };\n}\n\n/** Decode a `StreamFrame`, extracting only the `data` (framebuffer PNG) bytes. */\nexport function decodeStreamFrame(bytes: Uint8Array): { data: Uint8Array } {\n const reader = new BinaryReader(bytes);\n const end = reader.len;\n let data = new Uint8Array(0);\n while (reader.pos < end) {\n const tag = reader.uint32();\n if (tag >>> 3 === 3 && tag === 26) {\n // Copy into a fresh ArrayBuffer-backed view: BinaryReader.bytes() returns\n // `Uint8Array<ArrayBufferLike>` (a view into the message buffer), which both\n // narrows the type to `Uint8Array<ArrayBuffer>` and isolates just this frame.\n data = new Uint8Array(reader.bytes());\n continue;\n }\n if ((tag & 7) === 4 || tag === 0) break;\n reader.skip(tag & 7);\n }\n return { data };\n}\n"],"mappings":";AAeA,SAAS,cAAc,oBAAoB;AAGpC,IAAM,sBAAsB;AAE5B,IAAM,sBAAsB;AAE5B,IAAM,uBAAuB;AAE7B,IAAM,qBAAqB;AAiBlC,SAAS,cAAc,SAAuB,QAAoC;AAChF,MAAI,QAAQ,cAAc,GAAI,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,SAAS;AACxE,MAAI,QAAQ,gBAAgB,GAAI,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,WAAW;AAC5E,MAAI,QAAQ,YAAY,GAAI,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,OAAO;AACpE,MAAI,QAAQ,SAAS,EAAG,QAAO,OAAO,EAAE,EAAE,MAAM,QAAQ,IAAI;AAC5D,MAAI,QAAQ,SAAS,EAAG,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,IAAI;AAC7D,SAAO;AACT;AAGO,SAAS,iBAAiB,SAAsC;AACrE,QAAM,SAAS,IAAI,aAAa;AAChC,gBAAc,QAAQ,SAAS,OAAO,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK;AAC9D,MAAI,QAAQ,UAAU,GAAI,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,KAAK;AAChE,MAAI,QAAQ,SAAS,EAAG,QAAO,OAAO,EAAE,EAAE,MAAM,QAAQ,IAAI;AAC5D,MAAI,QAAQ,kBAAkB,IAAK,QAAO,OAAO,EAAE,EAAE,OAAO,QAAQ,aAAa;AACjF,SAAO,OAAO,OAAO;AACvB;AAGA,SAAS,wBAAwB,QAAsB,QAAsC;AAC3F,QAAM,MAAM,OAAO,MAAM;AACzB,MAAI;AACJ,SAAO,OAAO,MAAM,KAAK;AACvB,UAAM,MAAM,OAAO,OAAO;AAC1B,QAAI,QAAQ,MAAM,KAAK,QAAQ,IAAI;AACjC,gBAAU,OAAO,OAAO;AACxB;AAAA,IACF;AACA,SAAK,MAAM,OAAO,KAAK,QAAQ,EAAG;AAClC,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AACA,SAAO,YAAY,SAAY,EAAE,QAAQ,IAAI,CAAC;AAChD;AAGO,SAAS,oBAAoB,OAGlC;AACA,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,MAAM,OAAO;AACnB,MAAI,WAAW;AACf,MAAI;AACJ,SAAO,OAAO,MAAM,KAAK;AACvB,UAAM,MAAM,OAAO,OAAO;AAC1B,QAAI,QAAQ,MAAM,KAAK,QAAQ,GAAG;AAChC,iBAAW,OAAO,KAAK;AACvB;AAAA,IACF;AACA,QAAI,QAAQ,MAAM,KAAK,QAAQ,IAAI;AACjC,cAAQ,wBAAwB,QAAQ,OAAO,OAAO,CAAC;AACvD;AAAA,IACF;AACA,SAAK,MAAM,OAAO,KAAK,QAAQ,EAAG;AAClC,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AACA,SAAO,UAAU,SAAY,EAAE,UAAU,MAAM,IAAI,EAAE,SAAS;AAChE;AAGO,SAAS,kBAAkB,OAAyC;AACzE,QAAM,SAAS,IAAI,aAAa,KAAK;AACrC,QAAM,MAAM,OAAO;AACnB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,SAAO,OAAO,MAAM,KAAK;AACvB,UAAM,MAAM,OAAO,OAAO;AAC1B,QAAI,QAAQ,MAAM,KAAK,QAAQ,IAAI;AAIjC,aAAO,IAAI,WAAW,OAAO,MAAM,CAAC;AACpC;AAAA,IACF;AACA,SAAK,MAAM,OAAO,KAAK,QAAQ,EAAG;AAClC,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AACA,SAAO,EAAE,KAAK;AAChB;","names":[]}
|