@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
package/backend/ws/ssh/sftp.ts
CHANGED
|
@@ -28,8 +28,8 @@ export const sshSftpHandler = createRouter()
|
|
|
28
28
|
.http('ssh:sftp-list', {
|
|
29
29
|
data: connectionAndPath,
|
|
30
30
|
response: t.Any()
|
|
31
|
-
}, async ({ data
|
|
32
|
-
const connection = requireSshConnection(
|
|
31
|
+
}, async ({ data }) => {
|
|
32
|
+
const connection = requireSshConnection(data.connectionId);
|
|
33
33
|
// An empty path means "wherever this connection starts": its configured
|
|
34
34
|
// initial path, else the account's home directory.
|
|
35
35
|
const path = data.path || connection.initialPath || '.';
|
|
@@ -39,16 +39,16 @@ export const sshSftpHandler = createRouter()
|
|
|
39
39
|
.http('ssh:sftp-stat', {
|
|
40
40
|
data: connectionAndPath,
|
|
41
41
|
response: t.Any()
|
|
42
|
-
}, async ({ data
|
|
43
|
-
requireSshConnection(
|
|
42
|
+
}, async ({ data }) => {
|
|
43
|
+
requireSshConnection(data.connectionId);
|
|
44
44
|
return sftpService.stat(data.connectionId, data.path);
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
.http('ssh:sftp-mkdir', {
|
|
48
48
|
data: connectionAndPath,
|
|
49
49
|
response: t.Object({ ok: t.Boolean() })
|
|
50
|
-
}, async ({ data
|
|
51
|
-
requireSshConnection(
|
|
50
|
+
}, async ({ data }) => {
|
|
51
|
+
requireSshConnection(data.connectionId);
|
|
52
52
|
await sftpService.makeDirectory(data.connectionId, data.path);
|
|
53
53
|
return { ok: true };
|
|
54
54
|
})
|
|
@@ -56,8 +56,8 @@ export const sshSftpHandler = createRouter()
|
|
|
56
56
|
.http('ssh:sftp-create-file', {
|
|
57
57
|
data: connectionAndPath,
|
|
58
58
|
response: t.Object({ ok: t.Boolean() })
|
|
59
|
-
}, async ({ data
|
|
60
|
-
requireSshConnection(
|
|
59
|
+
}, async ({ data }) => {
|
|
60
|
+
requireSshConnection(data.connectionId);
|
|
61
61
|
await sftpService.createFile(data.connectionId, data.path);
|
|
62
62
|
return { ok: true };
|
|
63
63
|
})
|
|
@@ -69,8 +69,8 @@ export const sshSftpHandler = createRouter()
|
|
|
69
69
|
toPath: t.String({ minLength: 1 })
|
|
70
70
|
}),
|
|
71
71
|
response: t.Object({ ok: t.Boolean() })
|
|
72
|
-
}, async ({ data
|
|
73
|
-
requireSshConnection(
|
|
72
|
+
}, async ({ data }) => {
|
|
73
|
+
requireSshConnection(data.connectionId);
|
|
74
74
|
await sftpService.rename(data.connectionId, data.fromPath, data.toPath);
|
|
75
75
|
return { ok: true };
|
|
76
76
|
})
|
|
@@ -82,8 +82,8 @@ export const sshSftpHandler = createRouter()
|
|
|
82
82
|
mode: t.Number({ minimum: 0, maximum: 0o7777 })
|
|
83
83
|
}),
|
|
84
84
|
response: t.Object({ ok: t.Boolean() })
|
|
85
|
-
}, async ({ data
|
|
86
|
-
requireSshConnection(
|
|
85
|
+
}, async ({ data }) => {
|
|
86
|
+
requireSshConnection(data.connectionId);
|
|
87
87
|
await sftpService.chmod(data.connectionId, data.path, data.mode);
|
|
88
88
|
return { ok: true };
|
|
89
89
|
})
|
|
@@ -95,8 +95,8 @@ export const sshSftpHandler = createRouter()
|
|
|
95
95
|
recursive: t.Optional(t.Boolean())
|
|
96
96
|
}),
|
|
97
97
|
response: t.Object({ ok: t.Boolean() })
|
|
98
|
-
}, async ({ data
|
|
99
|
-
requireSshConnection(
|
|
98
|
+
}, async ({ data }) => {
|
|
99
|
+
requireSshConnection(data.connectionId);
|
|
100
100
|
await sftpService.remove(data.connectionId, data.path, data.recursive === true);
|
|
101
101
|
return { ok: true };
|
|
102
102
|
})
|
|
@@ -107,8 +107,8 @@ export const sshSftpHandler = createRouter()
|
|
|
107
107
|
path: t.String({ minLength: 1 })
|
|
108
108
|
}),
|
|
109
109
|
response: t.Any()
|
|
110
|
-
}, async ({ data
|
|
111
|
-
requireSshConnection(
|
|
110
|
+
}, async ({ data }) => {
|
|
111
|
+
requireSshConnection(data.connectionId);
|
|
112
112
|
return sftpService.readText(data.connectionId, data.path);
|
|
113
113
|
})
|
|
114
114
|
|
|
@@ -119,8 +119,8 @@ export const sshSftpHandler = createRouter()
|
|
|
119
119
|
text: t.String()
|
|
120
120
|
}),
|
|
121
121
|
response: t.Object({ ok: t.Boolean() })
|
|
122
|
-
}, async ({ data
|
|
123
|
-
requireSshConnection(
|
|
122
|
+
}, async ({ data }) => {
|
|
123
|
+
requireSshConnection(data.connectionId);
|
|
124
124
|
await sftpService.writeText(data.connectionId, data.path, data.text);
|
|
125
125
|
return { ok: true };
|
|
126
126
|
})
|
|
@@ -132,8 +132,8 @@ export const sshSftpHandler = createRouter()
|
|
|
132
132
|
recursive: t.Optional(t.Boolean())
|
|
133
133
|
}),
|
|
134
134
|
response: t.Any()
|
|
135
|
-
}, async ({ data
|
|
136
|
-
requireSshConnection(
|
|
135
|
+
}, async ({ data }) => {
|
|
136
|
+
requireSshConnection(data.connectionId);
|
|
137
137
|
return sftpService.removeMany(data.connectionId, data.paths, data.recursive !== false);
|
|
138
138
|
})
|
|
139
139
|
|
|
@@ -145,8 +145,8 @@ export const sshSftpHandler = createRouter()
|
|
|
145
145
|
operation: t.Union([t.Literal('move'), t.Literal('copy')])
|
|
146
146
|
}),
|
|
147
147
|
response: t.Any()
|
|
148
|
-
}, async ({ data
|
|
149
|
-
requireSshConnection(
|
|
148
|
+
}, async ({ data }) => {
|
|
149
|
+
requireSshConnection(data.connectionId);
|
|
150
150
|
return sftpService.findConflicts(
|
|
151
151
|
data.connectionId,
|
|
152
152
|
data.paths,
|
|
@@ -163,8 +163,8 @@ export const sshSftpHandler = createRouter()
|
|
|
163
163
|
onConflict: t.Optional(conflictStrategy)
|
|
164
164
|
}),
|
|
165
165
|
response: t.Any()
|
|
166
|
-
}, async ({ data
|
|
167
|
-
requireSshConnection(
|
|
166
|
+
}, async ({ data }) => {
|
|
167
|
+
requireSshConnection(data.connectionId);
|
|
168
168
|
return sftpService.move(
|
|
169
169
|
data.connectionId,
|
|
170
170
|
data.paths,
|
|
@@ -181,8 +181,8 @@ export const sshSftpHandler = createRouter()
|
|
|
181
181
|
onConflict: t.Optional(conflictStrategy)
|
|
182
182
|
}),
|
|
183
183
|
response: t.Any()
|
|
184
|
-
}, async ({ data
|
|
185
|
-
requireSshConnection(
|
|
184
|
+
}, async ({ data }) => {
|
|
185
|
+
requireSshConnection(data.connectionId);
|
|
186
186
|
return sftpService.copy(
|
|
187
187
|
data.connectionId,
|
|
188
188
|
data.paths,
|
|
@@ -200,8 +200,8 @@ export const sshSftpHandler = createRouter()
|
|
|
200
200
|
onConflict: t.Optional(conflictStrategy)
|
|
201
201
|
}),
|
|
202
202
|
response: t.Any()
|
|
203
|
-
}, async ({ data
|
|
204
|
-
requireSshConnection(
|
|
203
|
+
}, async ({ data }) => {
|
|
204
|
+
requireSshConnection(data.connectionId);
|
|
205
205
|
return sftpService.compress(
|
|
206
206
|
data.connectionId,
|
|
207
207
|
data.paths,
|
|
@@ -218,8 +218,8 @@ export const sshSftpHandler = createRouter()
|
|
|
218
218
|
destinationDirectory: t.String({ minLength: 1 })
|
|
219
219
|
}),
|
|
220
220
|
response: t.Any()
|
|
221
|
-
}, async ({ data
|
|
222
|
-
requireSshConnection(
|
|
221
|
+
}, async ({ data }) => {
|
|
222
|
+
requireSshConnection(data.connectionId);
|
|
223
223
|
return sftpService.inspectArchive(
|
|
224
224
|
data.connectionId,
|
|
225
225
|
data.archivePath,
|
|
@@ -237,8 +237,8 @@ export const sshSftpHandler = createRouter()
|
|
|
237
237
|
onConflict: t.Optional(conflictStrategy)
|
|
238
238
|
}),
|
|
239
239
|
response: t.Any()
|
|
240
|
-
}, async ({ data
|
|
241
|
-
requireSshConnection(
|
|
240
|
+
}, async ({ data }) => {
|
|
241
|
+
requireSshConnection(data.connectionId);
|
|
242
242
|
return sftpService.extract(data.connectionId, data.archivePath, data.destinationDirectory, {
|
|
243
243
|
mode: data.mode ?? 'smart',
|
|
244
244
|
folderName: data.folderName,
|
|
@@ -249,8 +249,8 @@ export const sshSftpHandler = createRouter()
|
|
|
249
249
|
.http('ssh:sftp-disk-usage', {
|
|
250
250
|
data: connectionAndPath,
|
|
251
251
|
response: t.Any()
|
|
252
|
-
}, async ({ data
|
|
253
|
-
const connection = requireSshConnection(
|
|
252
|
+
}, async ({ data }) => {
|
|
253
|
+
const connection = requireSshConnection(data.connectionId);
|
|
254
254
|
// An empty path means "wherever this account lives". `.` resolves to the
|
|
255
255
|
// home directory in the exec session, which is what `df` needs and what the
|
|
256
256
|
// quota sources ignore — so the host overview can ask without knowing a path.
|
package/backend/ws/ssh/tunnel.ts
CHANGED
|
@@ -35,9 +35,8 @@ function getSshPtyConnection(conn: WSConnection): PtyKitConnection {
|
|
|
35
35
|
if (existing) return existing;
|
|
36
36
|
|
|
37
37
|
const userId = ws.getUserId(conn);
|
|
38
|
-
const isAdmin = ws.getRole(conn) === 'admin';
|
|
39
38
|
const ptyConn = sshPtyKitServer.createConnection({
|
|
40
|
-
data: { userId,
|
|
39
|
+
data: { userId, connId },
|
|
41
40
|
send: (frame) => {
|
|
42
41
|
ws.sendToConnectionId(connId, JSON.stringify({ action: 'ssh:pty-out', payload: frame }));
|
|
43
42
|
}
|
|
@@ -9,15 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
import { t } from 'elysia';
|
|
11
11
|
import { createRouter } from '$shared/utils/ws-server';
|
|
12
|
-
import { ws } from '$backend/utils/ws';
|
|
13
12
|
import { debug } from '$shared/utils/logger';
|
|
14
13
|
import {
|
|
15
14
|
startInstall,
|
|
16
15
|
cancelInstall,
|
|
16
|
+
getSession,
|
|
17
17
|
InstallAlreadyRunningError,
|
|
18
18
|
InstallNotAutoInstallableError
|
|
19
19
|
} from '$backend/engine/install-runner';
|
|
20
|
-
import { requireInstallSessionAccess } from './access';
|
|
21
20
|
|
|
22
21
|
const TOOL_UNION = t.Union([
|
|
23
22
|
t.Literal('git'),
|
|
@@ -49,13 +48,10 @@ export const stackInstallHandler = createRouter()
|
|
|
49
48
|
displayCommand: t.String(),
|
|
50
49
|
startedAt: t.Number()
|
|
51
50
|
})
|
|
52
|
-
}, async ({
|
|
53
|
-
|
|
54
|
-
if (!userId) throw new Error('Not authenticated');
|
|
55
|
-
|
|
56
|
-
debug.log('path', `install-start requested: tool=${data.tool} user=${userId}`);
|
|
51
|
+
}, async ({ data }) => {
|
|
52
|
+
debug.log('path', `install-start requested: tool=${data.tool}`);
|
|
57
53
|
try {
|
|
58
|
-
const session = await startInstall(data.tool
|
|
54
|
+
const session = await startInstall(data.tool);
|
|
59
55
|
return {
|
|
60
56
|
sessionId: session.id,
|
|
61
57
|
tool: data.tool,
|
|
@@ -76,10 +72,7 @@ export const stackInstallHandler = createRouter()
|
|
|
76
72
|
.http('stack:install-cancel', {
|
|
77
73
|
data: t.Object({ sessionId: t.String() }),
|
|
78
74
|
response: t.Object({ cancelled: t.Boolean() })
|
|
79
|
-
}, async ({ data
|
|
80
|
-
const userId = ws.getUserId(conn);
|
|
81
|
-
if (!userId) throw new Error('Not authenticated');
|
|
82
|
-
requireInstallSessionAccess(conn, data.sessionId);
|
|
75
|
+
}, async ({ data }) => {
|
|
83
76
|
const cancelled = cancelInstall(data.sessionId);
|
|
84
77
|
return { cancelled };
|
|
85
78
|
})
|
|
@@ -102,11 +95,8 @@ export const stackInstallHandler = createRouter()
|
|
|
102
95
|
})
|
|
103
96
|
])
|
|
104
97
|
})
|
|
105
|
-
}, async ({ data
|
|
106
|
-
|
|
107
|
-
if (!userId) throw new Error('Not authenticated');
|
|
108
|
-
const session = requireInstallSessionAccess(conn, data.sessionId);
|
|
109
|
-
return { session };
|
|
98
|
+
}, async ({ data }) => {
|
|
99
|
+
return { session: getSession(data.sessionId) };
|
|
110
100
|
})
|
|
111
101
|
|
|
112
102
|
// ═══ Server → client events ═══
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - subagents:list / get / create / update / parse-import / import / toggle / delete
|
|
5
5
|
* - subagents:detect — on-disk subagents (managed + adoptable) per engine
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Changes take effect on the next chat stream.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { t } from 'elysia';
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Inbound client frames arrive on `terminal:pty`; each Clopen connection gets one
|
|
6
6
|
* embedded `PtyKitConnection` whose `send` unicasts frames back on
|
|
7
|
-
* `terminal:pty-out` (RPC responses + reattach replay) while PtyKit
|
|
8
|
-
*
|
|
7
|
+
* `terminal:pty-out` (RPC responses + reattach replay) while PtyKit fans a
|
|
8
|
+
* session's output out to every connection attached to it. Identity (`userId`) is
|
|
9
9
|
* carried on the connection so `authorize` can enforce project access.
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* `share:ensure-origin` returns a public origin that Remote Access share links
|
|
5
5
|
* are built against, transparently starting a Cloudflare quick tunnel to
|
|
6
6
|
* Clopen's own port only when the app isn't already reachable on a real domain.
|
|
7
|
-
* Any authenticated user may call it (members add their own devices); invite
|
|
8
|
-
* creation stays admin-gated on its own route.
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
9
|
import { t } from 'elysia';
|
package/backend/ws/user/crud.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* User CRUD Operations
|
|
3
3
|
*
|
|
4
|
-
* HTTP endpoints for
|
|
5
|
-
* - Generate anonymous user
|
|
6
|
-
* - Update user name
|
|
4
|
+
* HTTP endpoints for the owner's saved UI state:
|
|
7
5
|
* - Restore user state (server-side state management)
|
|
8
6
|
* - Save user state
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
9
|
import { t } from 'elysia';
|
|
12
10
|
import { createRouter } from '$shared/utils/ws-server';
|
|
13
|
-
import { generateAnonymousUser, generateColorFromString, getInitials } from '../../utils/user-helpers';
|
|
14
|
-
import type { AnonymousUser } from '../../utils/user-helpers';
|
|
15
11
|
import { ws } from '$backend/utils/ws';
|
|
16
12
|
import { settingsQueries } from '$backend/database/queries';
|
|
17
13
|
import { debug } from '$shared/utils/logger';
|
|
@@ -48,60 +44,6 @@ function setUserState(userId: string, key: string, value: any): void {
|
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
export const crudHandler = createRouter()
|
|
51
|
-
// Generate anonymous user
|
|
52
|
-
.http('user:anonymous', {
|
|
53
|
-
data: t.Object({}),
|
|
54
|
-
response: t.Object({
|
|
55
|
-
id: t.String(),
|
|
56
|
-
name: t.String(),
|
|
57
|
-
color: t.String(),
|
|
58
|
-
avatar: t.String(),
|
|
59
|
-
createdAt: t.String()
|
|
60
|
-
})
|
|
61
|
-
}, async () => {
|
|
62
|
-
const newUser = generateAnonymousUser();
|
|
63
|
-
|
|
64
|
-
debug.log('user', '✅ Generated new anonymous user:', newUser.name);
|
|
65
|
-
|
|
66
|
-
return newUser;
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
// Update user name
|
|
70
|
-
.http('user:update', {
|
|
71
|
-
data: t.Object({
|
|
72
|
-
newName: t.String({ minLength: 1 })
|
|
73
|
-
}),
|
|
74
|
-
response: t.Object({
|
|
75
|
-
id: t.String(),
|
|
76
|
-
name: t.String(),
|
|
77
|
-
color: t.String(),
|
|
78
|
-
avatar: t.String(),
|
|
79
|
-
createdAt: t.String()
|
|
80
|
-
})
|
|
81
|
-
}, async ({ data, conn }) => {
|
|
82
|
-
const userId = ws.getUserId(conn);
|
|
83
|
-
const { newName } = data;
|
|
84
|
-
|
|
85
|
-
const trimmedName = newName.trim();
|
|
86
|
-
|
|
87
|
-
if (trimmedName.length === 0) {
|
|
88
|
-
throw new Error('Name cannot be empty');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Create updated user object
|
|
92
|
-
const updatedUser: AnonymousUser = {
|
|
93
|
-
id: userId,
|
|
94
|
-
name: trimmedName,
|
|
95
|
-
avatar: getInitials(trimmedName),
|
|
96
|
-
color: generateColorFromString(trimmedName),
|
|
97
|
-
createdAt: new Date().toISOString()
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
debug.log('user', '✅ Updated user name:', { userId, newName: trimmedName });
|
|
101
|
-
|
|
102
|
-
return updatedUser;
|
|
103
|
-
})
|
|
104
|
-
|
|
105
47
|
// Restore user state - returns all server-side user state at once
|
|
106
48
|
.http('user:restore-state', {
|
|
107
49
|
data: t.Object({}),
|
package/backend/ws/user/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Combines all user WebSocket handlers into a single router.
|
|
5
5
|
*
|
|
6
6
|
* Structure:
|
|
7
|
-
* - crud.ts: HTTP endpoints for
|
|
7
|
+
* - crud.ts: HTTP endpoints for the saved UI state (restore, save)
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { createRouter } from '$shared/utils/ws-server';
|
|
@@ -35,7 +35,7 @@ export interface IssueProjectContext {
|
|
|
35
35
|
export function resolveWorkProject(conn: WSConnection, projectId?: string): IssueProjectContext {
|
|
36
36
|
const current = ws.getProjectId(conn);
|
|
37
37
|
const target = (projectId ?? '').trim() || current;
|
|
38
|
-
const project = requireProjectAccess(
|
|
38
|
+
const project = requireProjectAccess(target);
|
|
39
39
|
|
|
40
40
|
if (target !== current) {
|
|
41
41
|
return { projectId: target, project, root: project.path, isCurrent: false };
|
package/backend/ws/work/crud.ts
CHANGED
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
* work:set-binding point a project at a different repository
|
|
16
16
|
* work:set-config per-binding behaviour (transitions, branch template)
|
|
17
17
|
*
|
|
18
|
-
* NOT admin-gated, unlike `integrations:*`. The distinction is what the route
|
|
19
|
-
* can reach: an integrations route changes a credential every project and every
|
|
20
|
-
* engine depends on, while these routes act inside one project the caller was
|
|
21
|
-
* already granted access to — the same reasoning that leaves `git:push` open.
|
|
22
|
-
*
|
|
23
18
|
* Every route takes an optional `projectId`, because this surface is global.
|
|
24
19
|
*/
|
|
25
20
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workspace State Handlers
|
|
3
3
|
*
|
|
4
|
-
* Persist per-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Persist per-project workspace state (dock layout/ratios/preset, git dock UI
|
|
5
|
+
* state, preview prefs, terminal active tab, and other dock view state). Single
|
|
6
|
+
* source of truth in DB so each project's workspace survives browser refresh
|
|
7
|
+
* and follows across devices.
|
|
8
8
|
*
|
|
9
9
|
* Mirrors the files:*-panel-state pattern.
|
|
10
10
|
*/
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
import { t } from 'elysia';
|
|
13
13
|
import { createRouter } from '$shared/utils/ws-server';
|
|
14
14
|
import { projectQueries } from '../../database/queries/project-queries';
|
|
15
|
-
import { ws as wsServer } from '../../utils/ws';
|
|
16
15
|
import { requireProjectAccess } from '../access';
|
|
17
16
|
|
|
18
17
|
export const workspaceStateHandler = createRouter()
|
|
@@ -23,10 +22,9 @@ export const workspaceStateHandler = createRouter()
|
|
|
23
22
|
response: t.Object({
|
|
24
23
|
state: t.Union([t.String(), t.Null()])
|
|
25
24
|
})
|
|
26
|
-
}, async ({ data
|
|
27
|
-
requireProjectAccess(
|
|
28
|
-
const
|
|
29
|
-
const state = projectQueries.getWorkspaceState(userId, data.projectId);
|
|
25
|
+
}, async ({ data }) => {
|
|
26
|
+
requireProjectAccess(data.projectId);
|
|
27
|
+
const state = projectQueries.getWorkspaceState(data.projectId);
|
|
30
28
|
return { state };
|
|
31
29
|
})
|
|
32
30
|
|
|
@@ -36,9 +34,8 @@ export const workspaceStateHandler = createRouter()
|
|
|
36
34
|
state: t.Union([t.String(), t.Null()])
|
|
37
35
|
}),
|
|
38
36
|
response: t.Object({ ok: t.Boolean() })
|
|
39
|
-
}, async ({ data
|
|
40
|
-
requireProjectAccess(
|
|
41
|
-
|
|
42
|
-
projectQueries.setWorkspaceState(userId, data.projectId, data.state);
|
|
37
|
+
}, async ({ data }) => {
|
|
38
|
+
requireProjectAccess(data.projectId);
|
|
39
|
+
projectQueries.setWorkspaceState(data.projectId, data.state);
|
|
43
40
|
return { ok: true };
|
|
44
41
|
});
|
|
@@ -12,18 +12,8 @@
|
|
|
12
12
|
* worktrees:branch-forget drop the row, leave the remote branch alone
|
|
13
13
|
* worktrees:branch-delete-remote destroy a branch the sweep found untracked
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* inside one project. The DESTROYING ones are additionally listed in
|
|
18
|
-
* `backend/auth/permissions.ts` as admin-only, the way `db-client:link` is:
|
|
19
|
-
* deleting one destroys a real database.
|
|
20
|
-
*
|
|
21
|
-
* Choosing a SOURCE is gated per source rather than per route, because the two
|
|
22
|
-
* kinds belong to different people. An integration account belongs to the
|
|
23
|
-
* install and spends its quota, so only an admin is shown one; a DB Client
|
|
24
|
-
* connection belongs to whoever saved it, and refusing a member their own would
|
|
25
|
-
* make the whole feature admin-only for no reason that survives being stated.
|
|
26
|
-
* `listBranchSources` decides, and `requireSource` enforces.
|
|
15
|
+
* Every route takes project access the way `worktrees:create` and `git:push`
|
|
16
|
+
* do — they act inside one project.
|
|
27
17
|
*/
|
|
28
18
|
|
|
29
19
|
import { t } from 'elysia';
|
|
@@ -33,30 +23,11 @@ import { worktreeBranching } from '../../worktrees';
|
|
|
33
23
|
import { ws } from '$backend/utils/ws';
|
|
34
24
|
import { requireCurrentProjectAccess } from '../access';
|
|
35
25
|
|
|
36
|
-
/**
|
|
37
|
-
* Who is asking.
|
|
38
|
-
*
|
|
39
|
-
* Passed into every source-facing call rather than checked here, because the
|
|
40
|
-
* rule is not "admin or not": an integration account belongs to the install and
|
|
41
|
-
* is admin-only, while a DB Client connection belongs to whoever saved it. One
|
|
42
|
-
* helper in the service answers both — see `requireSource`.
|
|
43
|
-
*/
|
|
44
|
-
function principalOf(conn: Parameters<typeof ws.getUserId>[0]) {
|
|
45
|
-
return { userId: ws.getUserId(conn), isAdmin: ws.getRole(conn) === 'admin' };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Tell everyone in the project that its branches or binding moved.
|
|
50
|
-
*
|
|
51
|
-
* The broadcast state is built for an ADMIN. Every recipient re-reads the
|
|
52
|
-
* source list through their own request anyway, and building one payload per
|
|
53
|
-
* viewer here would make an announcement O(viewers) round trips into the
|
|
54
|
-
* database for a list that is about to be refetched.
|
|
55
|
-
*/
|
|
26
|
+
/** Tell every device in the project that its branches or binding moved. */
|
|
56
27
|
async function announce(projectId: string): Promise<void> {
|
|
57
28
|
ws.emit.project(projectId, 'worktrees:branching-changed', {
|
|
58
29
|
projectId,
|
|
59
|
-
state: await worktreeBranching.state(projectId
|
|
30
|
+
state: await worktreeBranching.state(projectId)
|
|
60
31
|
});
|
|
61
32
|
}
|
|
62
33
|
|
|
@@ -67,7 +38,7 @@ export const worktreeBranchingHandler = createRouter()
|
|
|
67
38
|
}, async ({ conn }) => {
|
|
68
39
|
await initializeDatabase();
|
|
69
40
|
const { projectId } = requireCurrentProjectAccess(conn);
|
|
70
|
-
return worktreeBranching.state(projectId
|
|
41
|
+
return worktreeBranching.state(projectId);
|
|
71
42
|
})
|
|
72
43
|
|
|
73
44
|
/**
|
|
@@ -94,7 +65,7 @@ export const worktreeBranchingHandler = createRouter()
|
|
|
94
65
|
response: t.Array(t.Any())
|
|
95
66
|
}, async ({ data, conn }) => {
|
|
96
67
|
requireCurrentProjectAccess(conn);
|
|
97
|
-
return worktreeBranching.parents(data
|
|
68
|
+
return worktreeBranching.parents(data);
|
|
98
69
|
})
|
|
99
70
|
|
|
100
71
|
.http('worktrees:branching-save', {
|
|
@@ -118,7 +89,7 @@ export const worktreeBranchingHandler = createRouter()
|
|
|
118
89
|
await initializeDatabase();
|
|
119
90
|
const { projectId } = requireCurrentProjectAccess(conn);
|
|
120
91
|
|
|
121
|
-
const binding = worktreeBranching.saveBinding({ projectId, ...data }
|
|
92
|
+
const binding = worktreeBranching.saveBinding({ projectId, ...data });
|
|
122
93
|
await announce(projectId);
|
|
123
94
|
return binding;
|
|
124
95
|
})
|
|
@@ -181,8 +181,8 @@ export const worktreeCrudHandler = createRouter()
|
|
|
181
181
|
worktreeId: t.Union([t.String(), t.Null()])
|
|
182
182
|
}),
|
|
183
183
|
response: t.Object({ success: t.Boolean() })
|
|
184
|
-
}, async ({ data
|
|
185
|
-
const session = requireSessionAccess(
|
|
184
|
+
}, async ({ data }) => {
|
|
185
|
+
const session = requireSessionAccess(data.sessionId);
|
|
186
186
|
|
|
187
187
|
if (data.worktreeId !== null) {
|
|
188
188
|
const worktree = worktreeQueries.getById(data.worktreeId);
|