@myrialabs/clopen 0.4.47 → 0.4.49
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 +11 -11
- package/backend/artifacts/project/sources.ts +1 -1
- package/backend/auth/auth-service.ts +52 -358
- package/backend/auth/onboarding.test.ts +2 -3
- package/backend/auth/permissions.test.ts +10 -20
- package/backend/auth/permissions.ts +4 -290
- package/backend/auth/rate-limiter.test.ts +8 -9
- package/backend/auth/rate-limiter.ts +0 -2
- package/backend/auth/tokens.ts +1 -8
- package/backend/bootstrap.ts +7 -0
- package/backend/chat/attachments.test.ts +88 -0
- package/backend/chat/attachments.ts +159 -0
- package/backend/chat/engine-handoff.test.ts +0 -2
- package/backend/chat/message-pages.test.ts +163 -0
- package/backend/chat/message-pages.ts +233 -0
- package/backend/chat/stream-manager.ts +91 -67
- package/backend/chat/turn-answer.test.ts +64 -0
- package/backend/chat/turn-answer.ts +125 -0
- package/backend/chat-apps/awaiting.test.ts +39 -0
- package/backend/chat-apps/awaiting.ts +49 -0
- package/backend/chat-apps/conversation.ts +746 -0
- package/backend/chat-apps/inbound.ts +324 -0
- package/backend/chat-apps/index.ts +309 -0
- package/backend/chat-apps/link-events.ts +20 -0
- package/backend/chat-apps/media.test.ts +62 -0
- package/backend/chat-apps/media.ts +208 -0
- package/backend/chat-apps/messages.test.ts +229 -0
- package/backend/chat-apps/messages.ts +365 -0
- package/backend/chat-apps/outbound.ts +243 -0
- package/backend/chat-apps/pairing.test.ts +45 -0
- package/backend/chat-apps/pairing.ts +74 -0
- package/backend/chat-apps/platforms/index.ts +20 -0
- package/backend/chat-apps/platforms/telegram.test.ts +35 -0
- package/backend/chat-apps/platforms/telegram.ts +191 -0
- package/backend/chat-apps/platforms/types.ts +114 -0
- package/backend/chat-apps/questions.ts +133 -0
- package/backend/chat-apps/runtime.ts +572 -0
- package/backend/chat-apps/storage.test.ts +201 -0
- package/backend/chat-apps/turns.test.ts +45 -0
- package/backend/chat-apps/turns.ts +208 -0
- package/backend/containers/pty.ts +3 -11
- package/backend/control/actions/accounts.ts +89 -0
- package/backend/control/actions/files.ts +116 -0
- package/backend/control/actions/models.ts +188 -0
- package/backend/control/actions/projects.ts +272 -0
- package/backend/control/actions/sessions.ts +280 -0
- package/backend/control/actions/skills.ts +111 -0
- package/backend/control/control.test.ts +169 -0
- package/backend/control/define.ts +20 -0
- package/backend/control/folders.test.ts +67 -0
- package/backend/control/index.ts +213 -0
- package/backend/control/invoke.ts +44 -0
- package/backend/control/links.ts +35 -0
- package/backend/control/paging.ts +26 -0
- package/backend/control/types.ts +117 -0
- package/backend/control/workspace.ts +127 -0
- package/backend/database/migrations/084_create_channel_links.ts +71 -0
- package/backend/database/migrations/085_add_home_projects.ts +36 -0
- package/backend/database/migrations/086_single_owner.ts +418 -0
- package/backend/database/migrations/087_create_blob_line_stats.ts +37 -0
- package/backend/database/migrations/index.ts +28 -0
- package/backend/database/queries/auth-queries.ts +7 -85
- package/backend/database/queries/blob-line-stats-queries.ts +48 -0
- package/backend/database/queries/channel-queries.ts +270 -0
- package/backend/database/queries/db-client-connection-queries.ts +18 -56
- package/backend/database/queries/file-share-queries.ts +5 -23
- package/backend/database/queries/git-identity-queries.ts +31 -42
- package/backend/database/queries/graph-queries.ts +1 -1
- package/backend/database/queries/index.ts +15 -1
- package/backend/database/queries/message-queries.test.ts +146 -0
- package/backend/database/queries/message-queries.ts +42 -1
- package/backend/database/queries/permission-set-queries.ts +1 -1
- package/backend/database/queries/profile-queries.ts +1 -1
- package/backend/database/queries/project-mcp-trust-queries.ts +1 -1
- package/backend/database/queries/project-queries.ts +50 -63
- package/backend/database/queries/session-queries.ts +28 -56
- package/backend/database/queries/ssh-connection-queries.ts +18 -41
- package/backend/db-client/env/diff.ts +9 -33
- package/backend/db-client/env/env.test.ts +8 -8
- package/backend/db-client/env/service.ts +1 -1
- package/backend/db-client/integrations/projector.ts +0 -5
- package/backend/engine/adapters/claude/message-converter.test.ts +47 -0
- package/backend/engine/adapters/claude/message-converter.ts +25 -2
- package/backend/engine/adapters/cline/message-converter.ts +0 -1
- package/backend/engine/adapters/cline/stream.ts +11 -15
- package/backend/engine/adapters/codex/message-converter.ts +0 -2
- package/backend/engine/adapters/copilot/message-converter.ts +1 -2
- package/backend/engine/adapters/cursor/message-converter.ts +0 -1
- package/backend/engine/adapters/opencode/message-converter.ts +2 -4
- package/backend/engine/adapters/opencode/stream.ts +11 -0
- package/backend/engine/adapters/parent-scope.test.ts +38 -0
- package/backend/engine/adapters/parent-scope.ts +44 -0
- package/backend/engine/adapters/pi/message-converter.ts +0 -1
- package/backend/engine/adapters/pi/stream.ts +4 -5
- package/backend/engine/adapters/qwen/message-converter.ts +0 -2
- package/backend/engine/bootstrap-default-engine.ts +2 -2
- package/backend/engine/docs/adapter-contract.md +8 -1
- package/backend/engine/install-runner.ts +8 -17
- package/backend/files/file-shares.ts +20 -44
- package/backend/files/file-size-limit.ts +3 -3
- package/backend/files/file-watcher.ts +19 -0
- package/backend/files/image-processing.ts +1 -1
- package/backend/files/os-clipboard.ts +2 -2
- package/backend/git/contributors.test.ts +35 -0
- package/backend/git/contributors.ts +46 -0
- package/backend/git/git-executor.ts +25 -5
- package/backend/git/git-service.ts +420 -19
- package/backend/git/identity/credential-helper.test.ts +2 -7
- package/backend/git/identity/import-local.test.ts +11 -16
- package/backend/git/identity/import-local.ts +12 -12
- package/backend/git/identity/index.ts +10 -24
- package/backend/git/identity/resolve.ts +13 -14
- package/backend/git/identity/scope-config.ts +33 -28
- package/backend/git/identity/service.ts +44 -47
- package/backend/git/op-lock.test.ts +111 -0
- package/backend/git/op-lock.ts +180 -0
- package/backend/git/remote-sync.test.ts +249 -0
- package/backend/host/metrics.ts +1 -1
- package/backend/http/bearer-auth.ts +1 -2
- package/backend/http/files-download.test.ts +8 -9
- package/backend/http/files-download.ts +2 -2
- package/backend/http/files-shared.test.ts +62 -89
- package/backend/http/files-shared.ts +2 -2
- package/backend/http/files-upload.test.ts +3 -7
- package/backend/http/files-upload.ts +3 -3
- package/backend/http/notes-images.test.ts +15 -38
- package/backend/http/notes-images.ts +6 -8
- package/backend/http/ssh-sftp.ts +5 -10
- package/backend/http/static-assets.test.ts +78 -0
- package/backend/http/static-assets.ts +104 -0
- package/backend/index.ts +32 -16
- package/backend/integrations/accounts.ts +61 -3
- package/backend/integrations/index.ts +2 -2
- package/backend/integrations/registry/define.ts +15 -0
- package/backend/integrations/registry/index.ts +2 -0
- package/backend/integrations/registry/providers/telegram.ts +54 -0
- package/backend/integrations/registry/types.ts +21 -1
- package/backend/integrations/webhooks/gateway.ts +7 -6
- package/backend/integrations/webhooks/verify.test.ts +30 -0
- package/backend/integrations/webhooks/verify.ts +4 -0
- package/backend/mcp/external/project.ts +1 -1
- package/backend/mcp/internal/remote-server.test.ts +1 -3
- package/backend/mcp/internal/remote-server.ts +4 -4
- package/backend/mcp/internal/servers/browser-automation/actions/dialogs.ts +67 -0
- package/backend/mcp/internal/servers/browser-automation/actions/index.ts +3 -1
- package/backend/mcp/internal/servers/browser-automation/actions/input.ts +5 -5
- package/backend/mcp/internal/servers/browser-automation/actions/tabs.ts +157 -28
- package/backend/mcp/internal/servers/browser-automation/context.ts +1 -0
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -2
- package/backend/mcp/internal/servers/browser-automation/format.ts +24 -1
- package/backend/mcp/internal/servers/browser-automation/runner.ts +68 -3
- package/backend/memory/redact.ts +1 -1
- package/backend/notes/access.test.ts +28 -29
- package/backend/notes/access.ts +6 -11
- package/backend/permissions/service.ts +1 -1
- package/backend/preview/browser/browser-clipboard.test.ts +46 -0
- package/backend/preview/browser/browser-clipboard.ts +67 -0
- package/backend/preview/browser/browser-dialog-handler.ts +95 -6
- package/backend/preview/browser/browser-host-bridge.ts +9 -0
- package/backend/preview/browser/browser-interaction-handler.ts +316 -86
- package/backend/preview/browser/browser-mcp-control.ts +34 -0
- package/backend/preview/browser/browser-pool.ts +67 -6
- package/backend/preview/browser/browser-preview-service.ts +383 -29
- package/backend/preview/browser/browser-tab-manager.ts +66 -23
- package/backend/preview/browser/browser-video-capture.ts +92 -5
- package/backend/preview/browser/element-locator.ts +190 -17
- package/backend/preview/browser/keyboard-chords.test.ts +68 -0
- package/backend/preview/browser/keyboard-chords.ts +132 -0
- package/backend/preview/browser/paste.ts +81 -0
- package/backend/preview/browser/process-usage.ts +142 -0
- package/backend/preview/browser/profile-lock.ts +209 -0
- package/backend/preview/browser/scripts/host-bridge.ts +59 -0
- package/backend/preview/browser/scripts/video-stream.ts +58 -0
- package/backend/preview/browser/types.ts +40 -2
- package/backend/preview/browser/viewport.test.ts +45 -0
- package/backend/preview/browser/viewport.ts +96 -0
- package/backend/profiles/service.ts +2 -2
- package/backend/project/status-manager.ts +43 -172
- package/backend/projects/home.ts +61 -0
- package/backend/projects/project-cleanup.integration.test.ts +2 -2
- package/backend/projects/project-cleanup.ts +0 -8
- package/backend/skills/service.ts +2 -3
- package/backend/snapshot/blob-store.ts +9 -1
- package/backend/snapshot/helpers.ts +3 -11
- package/backend/snapshot/line-stats.test.ts +80 -0
- package/backend/snapshot/line-stats.ts +64 -0
- package/backend/snapshot/restore.ts +252 -0
- package/backend/snapshot/snapshot-service.ts +14 -27
- package/backend/snapshot/turn-changes.test.ts +10 -5
- package/backend/snapshot/turn-changes.ts +78 -40
- package/backend/ssh/ptykit.ts +1 -2
- package/backend/terminal/ptykit.ts +10 -8
- package/backend/tunnel/public-origin.ts +31 -20
- package/backend/utils/user-helpers.ts +0 -55
- package/backend/utils/ws-wire.test.ts +87 -0
- package/backend/utils/ws-wire.ts +189 -0
- package/backend/utils/ws.ts +101 -192
- package/backend/worktrees/branching/engine.ts +3 -16
- package/backend/worktrees/branching/index.ts +1 -1
- package/backend/worktrees/branching/projector.ts +1 -1
- package/backend/worktrees/branching/service.ts +13 -25
- package/backend/ws/access.ts +12 -21
- package/backend/ws/artifacts/generate.ts +2 -2
- package/backend/ws/auth/device.ts +16 -71
- package/backend/ws/auth/index.ts +4 -22
- package/backend/ws/auth/login.test.ts +14 -60
- package/backend/ws/auth/login.ts +24 -124
- package/backend/ws/auth/status.ts +0 -1
- package/backend/ws/chat/composer.ts +118 -118
- package/backend/ws/chat/stream.ts +105 -57
- package/backend/ws/chat-apps/index.ts +117 -0
- package/backend/ws/containers/actions.ts +11 -25
- package/backend/ws/containers/index.ts +3 -4
- package/backend/ws/containers/list.ts +10 -36
- package/backend/ws/containers/logs.ts +2 -2
- package/backend/ws/containers/tunnel.ts +1 -2
- package/backend/ws/db-client/access.ts +2 -16
- package/backend/ws/db-client/accounts.ts +5 -15
- package/backend/ws/db-client/connections.ts +17 -25
- package/backend/ws/db-client/context.ts +1 -1
- package/backend/ws/db-client/env.ts +7 -10
- package/backend/ws/db-client/index.ts +2 -2
- package/backend/ws/db-client/io.ts +5 -5
- package/backend/ws/db-client/query-history-retention.test.ts +8 -8
- package/backend/ws/db-client/query.ts +18 -17
- package/backend/ws/db-client/schema.ts +13 -13
- package/backend/ws/db-client/structure.ts +35 -35
- package/backend/ws/db-client/supabase.ts +4 -21
- package/backend/ws/deployments/context.ts +1 -1
- package/backend/ws/deployments/crud.ts +0 -5
- package/backend/ws/engine/access.ts +7 -20
- package/backend/ws/engine/claude/accounts.ts +4 -4
- package/backend/ws/engine/cline/accounts.ts +5 -5
- package/backend/ws/engine/codex/accounts.ts +3 -3
- package/backend/ws/engine/pi/accounts.ts +5 -5
- package/backend/ws/files/clipboard.ts +8 -27
- package/backend/ws/files/image-edit.ts +6 -6
- package/backend/ws/files/index.ts +1 -1
- package/backend/ws/files/path-access.test.ts +32 -131
- package/backend/ws/files/path-access.ts +8 -87
- package/backend/ws/files/read.ts +45 -19
- package/backend/ws/files/reveal.ts +3 -3
- package/backend/ws/files/search.ts +7 -7
- package/backend/ws/files/share.ts +9 -13
- package/backend/ws/files/state.ts +9 -12
- package/backend/ws/files/watch.ts +3 -3
- package/backend/ws/files/write.ts +30 -31
- package/backend/ws/git/branch.ts +80 -59
- package/backend/ws/git/commit.ts +63 -44
- package/backend/ws/git/conflict.ts +16 -18
- package/backend/ws/git/identity-context.ts +8 -17
- package/backend/ws/git/identity.ts +17 -27
- package/backend/ws/git/index.ts +3 -1
- package/backend/ws/git/log.ts +52 -0
- package/backend/ws/git/op-state.ts +139 -0
- package/backend/ws/git/remote.ts +241 -141
- package/backend/ws/git/repo-context.ts +67 -0
- package/backend/ws/git/staging.ts +18 -28
- package/backend/ws/git/status.ts +5 -2
- package/backend/ws/index.ts +5 -1
- package/backend/ws/instructions/crud.ts +1 -1
- package/backend/ws/integrations/crud.ts +1 -3
- package/backend/ws/mcp/crud.ts +3 -5
- package/backend/ws/mcp/tools.ts +1 -1
- package/backend/ws/memory/crud.ts +14 -46
- package/backend/ws/memory/index.ts +2 -2
- package/backend/ws/messages/crud.ts +78 -8
- package/backend/ws/notes/index.ts +33 -39
- package/backend/ws/permissions/crud.ts +3 -4
- package/backend/ws/ports/index.ts +1 -2
- package/backend/ws/ports/kill.ts +5 -10
- package/backend/ws/ports/list.ts +4 -10
- package/backend/ws/preview/access.ts +1 -1
- package/backend/ws/preview/browser/interact.ts +52 -79
- package/backend/ws/preview/browser/native-ui.ts +24 -0
- package/backend/ws/preview/browser/stats.ts +98 -1
- package/backend/ws/preview/browser/tab-info.ts +15 -0
- package/backend/ws/preview/browser/tab.ts +19 -4
- package/backend/ws/preview/index.ts +29 -0
- package/backend/ws/preview/watchers.ts +84 -0
- package/backend/ws/profiles/crud.ts +6 -8
- package/backend/ws/project-artifacts/index.ts +30 -31
- package/backend/ws/projects/crud.ts +33 -35
- package/backend/ws/projects/index.ts +3 -8
- package/backend/ws/projects/info.ts +3 -3
- package/backend/ws/projects/overview.ts +19 -30
- package/backend/ws/projects/status.ts +17 -57
- package/backend/ws/sessions/crud.ts +42 -57
- package/backend/ws/sessions/index.ts +1 -1
- package/backend/ws/settings/crud.ts +1 -1
- package/backend/ws/skills/crud.ts +3 -4
- package/backend/ws/skills/index.ts +1 -1
- package/backend/ws/snapshot/changes.ts +12 -13
- package/backend/ws/snapshot/restore.ts +11 -295
- package/backend/ws/snapshot/timeline.ts +2 -4
- package/backend/ws/ssh/access.ts +6 -21
- package/backend/ws/ssh/connections.ts +21 -31
- package/backend/ws/ssh/forwards.ts +12 -12
- package/backend/ws/ssh/sftp.ts +34 -34
- package/backend/ws/ssh/tunnel.ts +1 -2
- package/backend/ws/stack/install.ts +7 -17
- package/backend/ws/subagents/crud.ts +1 -1
- package/backend/ws/terminal/tunnel.ts +2 -2
- package/backend/ws/tunnel/share.ts +0 -2
- package/backend/ws/user/crud.ts +1 -59
- package/backend/ws/user/index.ts +1 -1
- package/backend/ws/work/context.ts +1 -1
- package/backend/ws/work/crud.ts +0 -5
- package/backend/ws/workspace/state.ts +10 -13
- package/backend/ws/worktrees/branching.ts +7 -36
- package/backend/ws/worktrees/crud.ts +2 -2
- package/bin/clopen.ts +46 -41
- package/dist/assets/addon-clipboard-wHJhZAA4.js.br +0 -0
- package/dist/assets/addon-clipboard-wHJhZAA4.js.gz +0 -0
- package/dist/assets/addon-fit-DX4qG4td.js.br +1 -0
- package/dist/assets/addon-fit-DX4qG4td.js.gz +0 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js.br +0 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js.gz +0 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js.br +0 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js.gz +0 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js.br +0 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js.gz +0 -0
- package/dist/assets/diff.worker-BoHLxmr2.js +7 -0
- package/dist/assets/diff.worker-BoHLxmr2.js.br +0 -0
- package/dist/assets/diff.worker-BoHLxmr2.js.gz +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/{index-CwuKQelV.js → index-CrVWZH_D.js} +1 -1
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/{index-BTcR1byF.js → index-DD0-3EWg.js} +1 -1
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/main-D2_TmcwQ.js +1240 -0
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +1 -0
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
- package/dist/assets/preview-video.worker-DcpDhCWL.js.br +0 -0
- package/dist/assets/preview-video.worker-DcpDhCWL.js.gz +0 -0
- package/dist/assets/xterm-B-qIQCd3.js.br +0 -0
- package/dist/assets/xterm-B-qIQCd3.js.gz +0 -0
- package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.br +0 -0
- package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.gz +0 -0
- package/dist/fonts/dm-sans.css.br +0 -0
- package/dist/fonts/dm-sans.css.gz +0 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/sw.js.br +0 -0
- package/dist/sw.js.gz +0 -0
- package/package.json +3 -3
- package/shared/constants/attachments.ts +14 -0
- package/shared/constants/engine-tools.ts +1 -1
- package/shared/constants/preview.test.ts +259 -0
- package/shared/constants/preview.ts +1018 -57
- package/shared/constants/tool-icons.ts +5 -0
- package/shared/types/containers/container.ts +1 -1
- package/shared/types/database/schema.ts +9 -6
- package/shared/types/git-identity.ts +1 -1
- package/shared/types/git.ts +116 -0
- package/shared/types/integrations.ts +7 -0
- package/shared/types/stores/settings.ts +1 -1
- package/shared/types/unified/index.ts +1 -1
- package/shared/types/unified/message.ts +0 -7
- package/shared/types/unified/stream.ts +13 -5
- package/shared/types/unified/tool.ts +15 -1
- package/shared/utils/ask-user-question.test.ts +319 -0
- package/shared/utils/ask-user-question.ts +154 -0
- package/shared/utils/diff-calculator.test.ts +178 -41
- package/shared/utils/diff-calculator.ts +383 -100
- package/shared/utils/home-project.ts +25 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/process-supervisor.test.ts +172 -0
- package/shared/utils/process-supervisor.ts +251 -0
- package/shared/utils/ws-chunk.test.ts +33 -0
- package/shared/utils/ws-chunk.ts +73 -0
- package/shared/utils/ws-client-chunks.test.ts +45 -0
- package/shared/utils/ws-client.ts +43 -0
- package/shared/utils/ws-server.ts +49 -21
- package/backend/auth/session-invalidation.test.ts +0 -112
- package/backend/auth/session-invalidation.ts +0 -77
- package/backend/project/status-manager.test.ts +0 -32
- package/backend/ws/auth/invites.ts +0 -94
- package/backend/ws/auth/users.ts +0 -112
- package/backend/ws/projects/presence.ts +0 -46
- package/backend/ws/stack/access.ts +0 -31
- package/dist/assets/main-BiDNMWb3.css +0 -1
- package/dist/assets/main-BlhKWz2B.js +0 -1241
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* - permissions:save — upsert one (scope, project, engine) rule set
|
|
7
7
|
*
|
|
8
8
|
* Rules are enforced at each engine's runtime auto-approve hook (real on
|
|
9
|
-
* Claude/Qwen/Copilot; best-effort/unverified on OpenCode/Codex).
|
|
10
|
-
*
|
|
11
|
-
* chat stream.
|
|
9
|
+
* Claude/Qwen/Copilot; best-effort/unverified on OpenCode/Codex). Changes take
|
|
10
|
+
* effect on the next chat stream.
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
import { t } from 'elysia';
|
|
@@ -65,7 +64,7 @@ export const permissionsCrudHandler = createRouter()
|
|
|
65
64
|
debug.log('path', `permissions:save ${data.engine}/${data.scope}`);
|
|
66
65
|
const projectId = data.scope === 'project' ? (data.projectId ?? null) : null;
|
|
67
66
|
if (data.scope === 'project' && !projectId) throw new Error('A project is required for project-scoped permissions');
|
|
68
|
-
// This
|
|
67
|
+
// This endpoint only manages global/project scope. Profile-scoped
|
|
69
68
|
// permission overlays are edited through the profiles editor (profiles:save-permissions).
|
|
70
69
|
permissionService.save(data.scope as PermissionScope, projectId, null, data.engine as EngineType, data.allow, data.deny);
|
|
71
70
|
return { success: true };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Port manager WebSocket router.
|
|
3
3
|
*
|
|
4
|
-
* Reading the table
|
|
5
|
-
* in ADMIN_ONLY_ROUTES and gated there.
|
|
4
|
+
* Reading the table, and stopping a process with `ports:kill`.
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
import { t } from 'elysia';
|
package/backend/ws/ports/kill.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Port manager — stopping a process
|
|
2
|
+
* Port manager — stopping a process.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This handler re-scans before acting rather than trusting the pid the client
|
|
5
|
+
* sent. A table is up to a
|
|
6
6
|
* second old, and a second is long enough for a pid to be recycled onto an
|
|
7
7
|
* unrelated process — signalling that would be indefensible.
|
|
8
8
|
*/
|
|
@@ -13,7 +13,6 @@ import { LOCAL_PORT_HOST } from '$shared/types/ports';
|
|
|
13
13
|
import { portMonitor } from '../../ports/monitor';
|
|
14
14
|
import { stopPortHolder } from '../../ports/kill';
|
|
15
15
|
import { sshConnectionQueries } from '../../database/queries';
|
|
16
|
-
import { ws } from '../../utils/ws';
|
|
17
16
|
import { debug } from '$shared/utils/logger';
|
|
18
17
|
|
|
19
18
|
export const portsKillHandler = createRouter().http(
|
|
@@ -26,13 +25,9 @@ export const portsKillHandler = createRouter().http(
|
|
|
26
25
|
}),
|
|
27
26
|
response: t.Any()
|
|
28
27
|
},
|
|
29
|
-
async ({ data
|
|
30
|
-
const userId = ws.getUserId(conn);
|
|
28
|
+
async ({ data }) => {
|
|
31
29
|
if (data.hostId !== LOCAL_PORT_HOST) {
|
|
32
|
-
|
|
33
|
-
// role rather than a hardcoded one — a gate that trusts its caller is
|
|
34
|
-
// no gate at all.
|
|
35
|
-
sshConnectionQueries.ensureAccess(data.hostId, userId, ws.getRole(conn) === 'admin');
|
|
30
|
+
sshConnectionQueries.require(data.hostId);
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
const fresh = await portMonitor.scanOnce(data.hostId);
|
package/backend/ws/ports/list.ts
CHANGED
|
@@ -17,23 +17,17 @@ import { portMonitor } from '../../ports/monitor';
|
|
|
17
17
|
import { sshConnectionQueries } from '../../database/queries';
|
|
18
18
|
import { ws } from '../../utils/ws';
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
* machine is watchable by anyone signed in — it is the machine they are
|
|
23
|
-
* already using Clopen on.
|
|
24
|
-
*/
|
|
25
|
-
function requireHostAccess(conn: Parameters<typeof ws.getUserId>[0], hostId: string): void {
|
|
20
|
+
/** The local machine, or a saved SSH host that still exists. */
|
|
21
|
+
function requireHost(hostId: string): void {
|
|
26
22
|
if (hostId === LOCAL_PORT_HOST) return;
|
|
27
|
-
|
|
28
|
-
const isAdmin = ws.getRole(conn) === 'admin';
|
|
29
|
-
sshConnectionQueries.ensureAccess(hostId, userId, isAdmin);
|
|
23
|
+
sshConnectionQueries.require(hostId);
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
const hostSchema = t.Object({ hostId: t.String({ minLength: 1 }) });
|
|
33
27
|
|
|
34
28
|
export const portsListHandler = createRouter()
|
|
35
29
|
.http('ports:watch', { data: hostSchema, response: t.Any() }, async ({ data, conn }) => {
|
|
36
|
-
|
|
30
|
+
requireHost(data.hostId);
|
|
37
31
|
const userId = ws.getUserId(conn);
|
|
38
32
|
|
|
39
33
|
const result = await portMonitor.watch(data.hostId, userId);
|
|
@@ -48,7 +48,7 @@ export function requireBrowserPreviewAccessFor(
|
|
|
48
48
|
// The caller passes a workspace scope key; membership is always decided on
|
|
49
49
|
// the project it belongs to.
|
|
50
50
|
const projectId = scopeProjectId(scopeKey);
|
|
51
|
-
requireProjectAccess(
|
|
51
|
+
requireProjectAccess(projectId); // throws if the caller isn't a member
|
|
52
52
|
const userId = ws.getUserId(conn);
|
|
53
53
|
const previewService = browserPreviewServiceManager.getService(scopeKey);
|
|
54
54
|
return { userId, projectId, previewService };
|
|
@@ -12,6 +12,9 @@ import { debug } from '$shared/utils/logger';
|
|
|
12
12
|
import { sleep } from '$shared/utils/async';
|
|
13
13
|
import { requireBrowserPreviewAccess, requireBrowserTabAccess } from '../access';
|
|
14
14
|
import { resolveFrameTarget } from '$backend/preview/browser/frame-targeting';
|
|
15
|
+
import { isPasteChord, pressChord, selectAll, type Modifier } from '$backend/preview/browser/keyboard-chords';
|
|
16
|
+
import { pasteText } from '$backend/preview/browser/paste';
|
|
17
|
+
import { isDeviceSize } from '$shared/constants/preview';
|
|
15
18
|
|
|
16
19
|
// Throttle cursor detection evaluate calls per session (100ms = ~10/sec is plenty)
|
|
17
20
|
const lastCursorEvalTime = new Map<string, number>();
|
|
@@ -27,6 +30,16 @@ function isNavigationError(error: Error): boolean {
|
|
|
27
30
|
msg.includes('cannot find context');
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/** The held modifiers of a forwarded key event, in press order. */
|
|
34
|
+
function modifiersOf(action: { ctrlKey?: boolean; metaKey?: boolean; altKey?: boolean; shiftKey?: boolean }): Modifier[] {
|
|
35
|
+
const modifiers: Modifier[] = [];
|
|
36
|
+
if (action.ctrlKey) modifiers.push('Control');
|
|
37
|
+
if (action.metaKey) modifiers.push('Meta');
|
|
38
|
+
if (action.altKey) modifiers.push('Alt');
|
|
39
|
+
if (action.shiftKey) modifiers.push('Shift');
|
|
40
|
+
return modifiers;
|
|
41
|
+
}
|
|
42
|
+
|
|
30
43
|
export const interactPreviewHandler = createRouter()
|
|
31
44
|
// Action: Client requests browser interaction
|
|
32
45
|
.on('preview:browser-interact', {
|
|
@@ -61,7 +74,8 @@ export const interactPreviewHandler = createRouter()
|
|
|
61
74
|
width: t.Optional(t.Number()),
|
|
62
75
|
height: t.Optional(t.Number()),
|
|
63
76
|
deviceSize: t.Optional(t.String()),
|
|
64
|
-
rotation: t.Optional(t.String())
|
|
77
|
+
rotation: t.Optional(t.String()),
|
|
78
|
+
deviceModel: t.Optional(t.String())
|
|
65
79
|
}),
|
|
66
80
|
/**
|
|
67
81
|
* The tab the viewer is looking at.
|
|
@@ -207,10 +221,9 @@ export const interactPreviewHandler = createRouter()
|
|
|
207
221
|
const shouldClear = action.clearFirst === true; // default false for user
|
|
208
222
|
|
|
209
223
|
if (shouldClear) {
|
|
210
|
-
// Select all
|
|
211
|
-
|
|
212
|
-
await session.page
|
|
213
|
-
await session.page.keyboard.up('Control');
|
|
224
|
+
// Select all, then typing overwrites it. Platform-aware: a
|
|
225
|
+
// bare Ctrl+A selects nothing on a macOS host.
|
|
226
|
+
await selectAll(session.page);
|
|
214
227
|
await sleep(50); // Small delay for selection
|
|
215
228
|
}
|
|
216
229
|
|
|
@@ -230,23 +243,16 @@ export const interactPreviewHandler = createRouter()
|
|
|
230
243
|
case 'key':
|
|
231
244
|
if (action.key) {
|
|
232
245
|
try {
|
|
233
|
-
|
|
234
|
-
const modifiers: string[] = [];
|
|
235
|
-
if (action.ctrlKey) modifiers.push('Control');
|
|
236
|
-
if (action.metaKey) modifiers.push('Meta');
|
|
237
|
-
if (action.altKey) modifiers.push('Alt');
|
|
238
|
-
if (action.shiftKey) modifiers.push('Shift');
|
|
246
|
+
const modifiers = modifiersOf(action);
|
|
239
247
|
|
|
240
248
|
if (modifiers.length > 0) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
await session.page.
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
for (const mod of modifiers.reverse()) {
|
|
249
|
-
await session.page.keyboard.up(mod as KeyInput);
|
|
249
|
+
if (isPasteChord(modifiers, action.key)) {
|
|
250
|
+
// Never the headless clipboard: paste what the workspace holds.
|
|
251
|
+
await pasteText(session.page, previewService.getClipboardText());
|
|
252
|
+
} else {
|
|
253
|
+
// Editing shortcuts carry their command where the host
|
|
254
|
+
// would otherwise ignore them (⌘A on macOS).
|
|
255
|
+
await pressChord(session.page, modifiers, action.key);
|
|
250
256
|
}
|
|
251
257
|
} else {
|
|
252
258
|
// No modifiers, just press the key
|
|
@@ -312,39 +318,13 @@ export const interactPreviewHandler = createRouter()
|
|
|
312
318
|
break;
|
|
313
319
|
|
|
314
320
|
case 'paste':
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
//
|
|
321
|
+
// What the user pasted is what their device's clipboard holds,
|
|
322
|
+
// so the workspace clipboard learns it too. The paste itself
|
|
323
|
+
// raises a real `paste` event first — spreadsheets and rich
|
|
324
|
+
// editors only listen for that.
|
|
318
325
|
if (typeof action.text === 'string') {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const inserted = await frame.evaluate((text: string) => {
|
|
322
|
-
const active = document.activeElement as HTMLElement | null;
|
|
323
|
-
if (!active) return false;
|
|
324
|
-
|
|
325
|
-
const isField = active.tagName === 'INPUT' || active.tagName === 'TEXTAREA';
|
|
326
|
-
if (!isField && !active.isContentEditable) return false;
|
|
327
|
-
|
|
328
|
-
if (isField) {
|
|
329
|
-
const field = active as HTMLInputElement | HTMLTextAreaElement;
|
|
330
|
-
const start = field.selectionStart ?? field.value.length;
|
|
331
|
-
const end = field.selectionEnd ?? field.value.length;
|
|
332
|
-
field.value = field.value.slice(0, start) + text + field.value.slice(end);
|
|
333
|
-
const caret = start + text.length;
|
|
334
|
-
field.setSelectionRange(caret, caret);
|
|
335
|
-
} else {
|
|
336
|
-
document.execCommand('insertText', false, text);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
active.dispatchEvent(new Event('input', { bubbles: true }));
|
|
340
|
-
active.dispatchEvent(new Event('change', { bubbles: true }));
|
|
341
|
-
return true;
|
|
342
|
-
}, action.text);
|
|
343
|
-
if (inserted) break;
|
|
344
|
-
} catch {
|
|
345
|
-
// Frame detached mid-paste; try the next one.
|
|
346
|
-
}
|
|
347
|
-
}
|
|
326
|
+
previewService.setClipboardText(action.text, 'device');
|
|
327
|
+
await pasteText(session.page, action.text);
|
|
348
328
|
}
|
|
349
329
|
break;
|
|
350
330
|
|
|
@@ -450,20 +430,10 @@ export const interactPreviewHandler = createRouter()
|
|
|
450
430
|
|
|
451
431
|
case 'keynav':
|
|
452
432
|
if (action.key) {
|
|
453
|
-
const modifiers
|
|
454
|
-
if (action.ctrlKey) modifiers.push('Control');
|
|
455
|
-
if (action.metaKey) modifiers.push('Meta');
|
|
456
|
-
if (action.altKey) modifiers.push('Alt');
|
|
457
|
-
if (action.shiftKey) modifiers.push('Shift');
|
|
433
|
+
const modifiers = modifiersOf(action);
|
|
458
434
|
|
|
459
435
|
if (modifiers.length > 0) {
|
|
460
|
-
|
|
461
|
-
await session.page.keyboard.down(mod as KeyInput);
|
|
462
|
-
}
|
|
463
|
-
await session.page.keyboard.press(action.key as KeyInput);
|
|
464
|
-
for (const mod of modifiers.reverse()) {
|
|
465
|
-
await session.page.keyboard.up(mod as KeyInput);
|
|
466
|
-
}
|
|
436
|
+
await pressChord(session.page, modifiers, action.key);
|
|
467
437
|
} else {
|
|
468
438
|
await session.page.keyboard.press(action.key as KeyInput);
|
|
469
439
|
}
|
|
@@ -555,7 +525,7 @@ export const interactPreviewHandler = createRouter()
|
|
|
555
525
|
break;
|
|
556
526
|
|
|
557
527
|
case 'viewport-update':
|
|
558
|
-
// Handle viewport change (device/rotation) without reconnection
|
|
528
|
+
// Handle viewport change (device/rotation/exact size) without reconnection
|
|
559
529
|
if (action.width && action.height && action.scale && action.scale > 0 && action.scale <= 1) {
|
|
560
530
|
session.scale = action.scale;
|
|
561
531
|
|
|
@@ -567,22 +537,25 @@ export const interactPreviewHandler = createRouter()
|
|
|
567
537
|
// the tab's metadata — which nothing told them had changed.
|
|
568
538
|
// So a phone switched to Tablet from a laptop went on
|
|
569
539
|
// drawing a laptop frame around a tablet-shaped picture.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
540
|
+
//
|
|
541
|
+
// The width and height are the tab's exact size now, not a
|
|
542
|
+
// restatement of the device class — a preset or a drag can
|
|
543
|
+
// put any size on any class. The service also rebuilds the
|
|
544
|
+
// capture around it.
|
|
545
|
+
const deviceSize = isDeviceSize(action.deviceSize) ? action.deviceSize : session.deviceSize;
|
|
546
|
+
const rotation =
|
|
547
|
+
action.rotation === 'portrait' || action.rotation === 'landscape'
|
|
548
|
+
? action.rotation
|
|
549
|
+
: session.rotation;
|
|
550
|
+
|
|
551
|
+
const updated = await previewService.setViewport(session.id, {
|
|
552
|
+
deviceSize,
|
|
553
|
+
rotation,
|
|
554
|
+
size: { width: action.width, height: action.height },
|
|
555
|
+
deviceModel: action.deviceModel
|
|
556
|
+
});
|
|
577
557
|
|
|
578
558
|
debug.log('preview', `📱 Viewport updated for tab ${tabId}: ${action.width}x${action.height}`);
|
|
579
|
-
|
|
580
|
-
// The hot-swap recomputes capture geometry from the new
|
|
581
|
-
// viewport and the viewers' own display metrics, which
|
|
582
|
-
// each of them reports separately.
|
|
583
|
-
|
|
584
|
-
// Hot-swap viewport without reconnection
|
|
585
|
-
const updated = await previewService.updateWebCodecsViewport(session.id, action.width, action.height);
|
|
586
559
|
if (!updated) {
|
|
587
560
|
debug.warn('preview', `⚠️ Viewport hot-swap failed`);
|
|
588
561
|
}
|
|
@@ -37,6 +37,22 @@ export const nativeUIPreviewHandler = createRouter()
|
|
|
37
37
|
return { success };
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The device's clipboard, as the viewer just read it.
|
|
42
|
+
*
|
|
43
|
+
* Sent on focus and on every copy or paste the user makes, so a paste in
|
|
44
|
+
* the preview — by the user or by an agent — pastes what the user last
|
|
45
|
+
* copied anywhere, not what the headless browser happens to hold.
|
|
46
|
+
*/
|
|
47
|
+
.on('preview:browser-clipboard-set', {
|
|
48
|
+
data: t.Object({
|
|
49
|
+
text: t.String()
|
|
50
|
+
})
|
|
51
|
+
}, async ({ data, conn }) => {
|
|
52
|
+
const { previewService } = requireBrowserPreviewAccess(conn);
|
|
53
|
+
previewService.setClipboardText(data.text, 'device');
|
|
54
|
+
})
|
|
55
|
+
|
|
40
56
|
// Action: Client responds to a dialog (alert, confirm, prompt)
|
|
41
57
|
.on('preview:browser-dialog-input', {
|
|
42
58
|
data: t.Object({
|
|
@@ -250,6 +266,14 @@ export const nativeUIPreviewHandler = createRouter()
|
|
|
250
266
|
text: t.String()
|
|
251
267
|
}))
|
|
252
268
|
|
|
269
|
+
// The workspace clipboard changed somewhere other than this device.
|
|
270
|
+
.emit('preview:browser-clipboard-sync', t.Object({
|
|
271
|
+
text: t.String(),
|
|
272
|
+
source: t.String(),
|
|
273
|
+
timestamp: t.Number(),
|
|
274
|
+
projectId: t.String()
|
|
275
|
+
}))
|
|
276
|
+
|
|
253
277
|
.emit('preview:browser-open-url-new-tab', t.Object({
|
|
254
278
|
url: t.String()
|
|
255
279
|
}))
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { t } from 'elysia';
|
|
8
|
+
import { cpus, freemem, loadavg, totalmem } from 'os';
|
|
8
9
|
import { createRouter } from '$shared/utils/ws-server';
|
|
9
|
-
import { requireBrowserTabAccess } from '../access';
|
|
10
|
+
import { requireBrowserPreviewAccess, requireBrowserTabAccess } from '../access';
|
|
11
|
+
import { browserPool } from '$backend/preview/browser/browser-pool';
|
|
12
|
+
import { availableMemoryBytes, measureProcessTrees } from '$backend/preview/browser/process-usage';
|
|
10
13
|
|
|
11
14
|
export const statsPreviewHandler = createRouter()
|
|
12
15
|
.http('preview:browser-tab-stats', {
|
|
@@ -42,4 +45,98 @@ export const statsPreviewHandler = createRouter()
|
|
|
42
45
|
stats: stats ?? null,
|
|
43
46
|
timestamp: new Date().toISOString()
|
|
44
47
|
};
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Everything the diagnostics panel shows: what the host has left, what
|
|
52
|
+
* every preview Chrome costs, and what each of this workspace's tabs is
|
|
53
|
+
* doing. Polled only while the panel is open.
|
|
54
|
+
*/
|
|
55
|
+
.http('preview:browser-diagnostics', {
|
|
56
|
+
data: t.Object({}),
|
|
57
|
+
response: t.Object({
|
|
58
|
+
host: t.Object({
|
|
59
|
+
platform: t.String(),
|
|
60
|
+
cpuCount: t.Number(),
|
|
61
|
+
loadAverage: t.Array(t.Number()),
|
|
62
|
+
totalMemBytes: t.Number(),
|
|
63
|
+
availableMemBytes: t.Number()
|
|
64
|
+
}),
|
|
65
|
+
browsers: t.Array(t.Object({
|
|
66
|
+
current: t.Boolean(),
|
|
67
|
+
tabs: t.Number(),
|
|
68
|
+
pid: t.Union([t.Number(), t.Null()]),
|
|
69
|
+
processes: t.Number(),
|
|
70
|
+
rssBytes: t.Number(),
|
|
71
|
+
cpuPercent: t.Union([t.Number(), t.Null()])
|
|
72
|
+
})),
|
|
73
|
+
tabs: t.Array(t.Object({
|
|
74
|
+
id: t.String(),
|
|
75
|
+
title: t.String(),
|
|
76
|
+
url: t.String(),
|
|
77
|
+
state: t.Union([t.Literal('active'), t.Literal('frozen')]),
|
|
78
|
+
watched: t.Boolean(),
|
|
79
|
+
isLoading: t.Boolean(),
|
|
80
|
+
openedBy: t.Union([t.Literal('agent'), t.Literal('user')]),
|
|
81
|
+
agentHeld: t.Boolean(),
|
|
82
|
+
dialog: t.Union([t.Object({ type: t.String(), message: t.String() }), t.Null()]),
|
|
83
|
+
createdAt: t.Number(),
|
|
84
|
+
lastAccessedAt: t.Number(),
|
|
85
|
+
jsHeapUsedBytes: t.Union([t.Number(), t.Null()]),
|
|
86
|
+
domNodes: t.Union([t.Number(), t.Null()]),
|
|
87
|
+
stream: t.Union([
|
|
88
|
+
t.Object({
|
|
89
|
+
videoBytesSent: t.Number(),
|
|
90
|
+
videoFramesEncoded: t.Number(),
|
|
91
|
+
connectionState: t.String()
|
|
92
|
+
}),
|
|
93
|
+
t.Null()
|
|
94
|
+
])
|
|
95
|
+
})),
|
|
96
|
+
clipboard: t.Object({
|
|
97
|
+
length: t.Number(),
|
|
98
|
+
source: t.Union([t.String(), t.Null()]),
|
|
99
|
+
updatedAt: t.Number()
|
|
100
|
+
}),
|
|
101
|
+
timestamp: t.Number()
|
|
102
|
+
})
|
|
103
|
+
}, async ({ conn }) => {
|
|
104
|
+
const { previewService } = requireBrowserPreviewAccess(conn);
|
|
105
|
+
const scope = previewService.getProjectId();
|
|
106
|
+
|
|
107
|
+
const running = browserPool.getRunningBrowsers();
|
|
108
|
+
const usage = measureProcessTrees(running.map((entry) => entry.pid).filter((pid): pid is number => pid !== null));
|
|
109
|
+
|
|
110
|
+
// Other workspaces' Chromes are reported without naming them: the cost is
|
|
111
|
+
// shared by the machine, but which projects they belong to is not this
|
|
112
|
+
// viewer's business.
|
|
113
|
+
const browsers = running
|
|
114
|
+
.map((entry) => {
|
|
115
|
+
const tree = entry.pid !== null ? usage.get(entry.pid) : undefined;
|
|
116
|
+
return {
|
|
117
|
+
current: entry.profileKey === scope,
|
|
118
|
+
tabs: entry.sessions,
|
|
119
|
+
pid: entry.pid,
|
|
120
|
+
processes: tree?.processes ?? 0,
|
|
121
|
+
rssBytes: tree?.rssBytes ?? 0,
|
|
122
|
+
cpuPercent: tree?.cpuPercent ?? null
|
|
123
|
+
};
|
|
124
|
+
})
|
|
125
|
+
.sort((a, b) => Number(b.current) - Number(a.current) || b.rssBytes - a.rssBytes);
|
|
126
|
+
|
|
127
|
+
const { tabs, clipboard } = await previewService.getDiagnostics();
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
host: {
|
|
131
|
+
platform: process.platform,
|
|
132
|
+
cpuCount: cpus().length,
|
|
133
|
+
loadAverage: loadavg(),
|
|
134
|
+
totalMemBytes: totalmem(),
|
|
135
|
+
availableMemBytes: availableMemoryBytes(freemem())
|
|
136
|
+
},
|
|
137
|
+
browsers,
|
|
138
|
+
tabs,
|
|
139
|
+
clipboard,
|
|
140
|
+
timestamp: Date.now()
|
|
141
|
+
};
|
|
45
142
|
});
|
|
@@ -25,6 +25,15 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
25
25
|
isStreaming: t.Boolean(),
|
|
26
26
|
deviceSize: t.String(),
|
|
27
27
|
rotation: t.String(),
|
|
28
|
+
width: t.Number(),
|
|
29
|
+
height: t.Number(),
|
|
30
|
+
deviceModel: t.Union([t.String(), t.Null()]),
|
|
31
|
+
emulation: t.Object({
|
|
32
|
+
touch: t.Optional(t.Boolean()),
|
|
33
|
+
mobile: t.Optional(t.Boolean()),
|
|
34
|
+
colorScheme: t.Optional(t.String()),
|
|
35
|
+
reducedMotion: t.Optional(t.String())
|
|
36
|
+
}),
|
|
28
37
|
isActive: t.Boolean(),
|
|
29
38
|
canGoBack: t.Boolean(),
|
|
30
39
|
canGoForward: t.Boolean(),
|
|
@@ -61,6 +70,9 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
61
70
|
isStreaming: t.Boolean(),
|
|
62
71
|
deviceSize: t.String(),
|
|
63
72
|
rotation: t.String(),
|
|
73
|
+
width: t.Number(),
|
|
74
|
+
height: t.Number(),
|
|
75
|
+
deviceModel: t.Union([t.String(), t.Null()]),
|
|
64
76
|
isActive: t.Boolean(),
|
|
65
77
|
canGoBack: t.Boolean(),
|
|
66
78
|
canGoForward: t.Boolean(),
|
|
@@ -123,6 +135,9 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
123
135
|
isStreaming: tab.isStreaming,
|
|
124
136
|
deviceSize: tab.deviceSize,
|
|
125
137
|
rotation: tab.rotation,
|
|
138
|
+
width: tab.width,
|
|
139
|
+
height: tab.height,
|
|
140
|
+
deviceModel: tab.deviceModel,
|
|
126
141
|
isActive: tab.isActive,
|
|
127
142
|
canGoBack: tab.canGoBack,
|
|
128
143
|
canGoForward: tab.canGoForward,
|
|
@@ -22,12 +22,22 @@ export const tabPreviewHandler = createRouter()
|
|
|
22
22
|
t.Literal('desktop'),
|
|
23
23
|
t.Literal('laptop'),
|
|
24
24
|
t.Literal('tablet'),
|
|
25
|
-
t.Literal('mobile')
|
|
25
|
+
t.Literal('mobile'),
|
|
26
|
+
t.Literal('responsive')
|
|
26
27
|
])),
|
|
27
28
|
rotation: t.Optional(t.Union([
|
|
28
29
|
t.Literal('portrait'),
|
|
29
30
|
t.Literal('landscape')
|
|
30
31
|
])),
|
|
32
|
+
/**
|
|
33
|
+
* Exact viewport size, when the tab was given one (a preset that is
|
|
34
|
+
* not its class's default, or a responsive size). The class default
|
|
35
|
+
* when omitted.
|
|
36
|
+
*/
|
|
37
|
+
width: t.Optional(t.Number()),
|
|
38
|
+
height: t.Optional(t.Number()),
|
|
39
|
+
/** The device model; the class default when omitted. */
|
|
40
|
+
deviceModel: t.Optional(t.String()),
|
|
31
41
|
/**
|
|
32
42
|
* Client-minted name for this launch.
|
|
33
43
|
*
|
|
@@ -60,6 +70,9 @@ export const tabPreviewHandler = createRouter()
|
|
|
60
70
|
url,
|
|
61
71
|
deviceSize = 'laptop',
|
|
62
72
|
rotation = 'portrait',
|
|
73
|
+
width,
|
|
74
|
+
height,
|
|
75
|
+
deviceModel,
|
|
63
76
|
launchId
|
|
64
77
|
} = data;
|
|
65
78
|
|
|
@@ -68,9 +81,11 @@ export const tabPreviewHandler = createRouter()
|
|
|
68
81
|
// Create browser tab
|
|
69
82
|
const tabPromise = previewService.createTab(
|
|
70
83
|
url, // Can be undefined for blank tab
|
|
71
|
-
deviceSize
|
|
72
|
-
rotation
|
|
73
|
-
launchId
|
|
84
|
+
deviceSize,
|
|
85
|
+
rotation,
|
|
86
|
+
launchId,
|
|
87
|
+
width && height ? { width, height } : null,
|
|
88
|
+
{ deviceModel }
|
|
74
89
|
);
|
|
75
90
|
const timeoutPromise = new Promise((_, reject) => {
|
|
76
91
|
setTimeout(() => reject(new Error('Browser tab open timeout - took longer than 60 seconds')), OPEN_TIMEOUT);
|
|
@@ -57,6 +57,7 @@ import { streamPreviewHandler } from './browser/webcodecs';
|
|
|
57
57
|
import { nativeUIPreviewHandler } from './browser/native-ui';
|
|
58
58
|
import { mcpPreviewHandler } from './browser/mcp';
|
|
59
59
|
import { hostPreviewHandler } from './browser/host';
|
|
60
|
+
import { previewWatchHandler } from './watchers';
|
|
60
61
|
|
|
61
62
|
export const previewRouter = createRouter()
|
|
62
63
|
.merge(tabPreviewHandler)
|
|
@@ -70,6 +71,7 @@ export const previewRouter = createRouter()
|
|
|
70
71
|
.merge(nativeUIPreviewHandler)
|
|
71
72
|
.merge(mcpPreviewHandler)
|
|
72
73
|
.merge(hostPreviewHandler)
|
|
74
|
+
.merge(previewWatchHandler)
|
|
73
75
|
// Server-emitted events (for type safety)
|
|
74
76
|
.emit('preview:browser-tab-opened', t.Object({
|
|
75
77
|
// projectId lets the frontend reject events that belong to a project it has
|
|
@@ -79,6 +81,11 @@ export const previewRouter = createRouter()
|
|
|
79
81
|
url: t.String(),
|
|
80
82
|
title: t.String(),
|
|
81
83
|
isActive: t.Boolean(),
|
|
84
|
+
deviceSize: t.Optional(t.String()),
|
|
85
|
+
rotation: t.Optional(t.String()),
|
|
86
|
+
width: t.Optional(t.Number()),
|
|
87
|
+
height: t.Optional(t.Number()),
|
|
88
|
+
deviceModel: t.Optional(t.Union([t.String(), t.Null()])),
|
|
82
89
|
/**
|
|
83
90
|
* The launch this tab came from, when a client started it. Absent for
|
|
84
91
|
* tabs the backend opened on its own (an agent, a popup).
|
|
@@ -188,6 +195,18 @@ export const previewRouter = createRouter()
|
|
|
188
195
|
timestamp: t.Number(),
|
|
189
196
|
source: t.Literal('mcp')
|
|
190
197
|
}))
|
|
198
|
+
// A whole pointer movement, animated by the viewer — see publishGlide.
|
|
199
|
+
.emit('preview:browser-mcp-cursor-glide', t.Object({
|
|
200
|
+
sessionId: t.String(),
|
|
201
|
+
from: t.Object({ x: t.Number(), y: t.Number() }),
|
|
202
|
+
control: t.Object({ x: t.Number(), y: t.Number() }),
|
|
203
|
+
to: t.Object({ x: t.Number(), y: t.Number() }),
|
|
204
|
+
durationMs: t.Number(),
|
|
205
|
+
pressed: t.Boolean(),
|
|
206
|
+
easing: t.Union([t.Literal('out'), t.Literal('linear')]),
|
|
207
|
+
timestamp: t.Number(),
|
|
208
|
+
source: t.Literal('mcp')
|
|
209
|
+
}))
|
|
191
210
|
.emit('preview:browser-mcp-cursor-click', t.Object({
|
|
192
211
|
sessionId: t.String(),
|
|
193
212
|
x: t.Number(),
|
|
@@ -217,6 +236,16 @@ export const previewRouter = createRouter()
|
|
|
217
236
|
rotation: t.String(),
|
|
218
237
|
width: t.Number(),
|
|
219
238
|
height: t.Number(),
|
|
239
|
+
deviceModel: t.Optional(t.Union([t.String(), t.Null()])),
|
|
240
|
+
timestamp: t.Number()
|
|
241
|
+
}))
|
|
242
|
+
// The colours a phone or tablet page asks to be framed in — its
|
|
243
|
+
// theme-color and background — for the system bands drawn around it.
|
|
244
|
+
.emit('preview:browser-page-colors', t.Object({
|
|
245
|
+
projectId: t.String(),
|
|
246
|
+
tabId: t.String(),
|
|
247
|
+
statusBar: t.String(),
|
|
248
|
+
background: t.String(),
|
|
220
249
|
timestamp: t.Number()
|
|
221
250
|
}))
|
|
222
251
|
// Live tab metadata: the page's own title and favicon plus whether
|