@myrialabs/clopen 0.4.46 → 0.4.48
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/stream-manager.ts +62 -62
- 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.test.ts +170 -0
- package/backend/database/migrations/086_single_owner.ts +418 -0
- package/backend/database/migrations/index.ts +21 -0
- package/backend/database/queries/auth-queries.ts +7 -85
- 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 +13 -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/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/presets.ts +27 -2
- package/backend/engine/adapters/opencode/server.ts +6 -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/image-processing.ts +1 -1
- package/backend/files/os-clipboard.ts +2 -2
- 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/index.ts +21 -7
- 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 +361 -25
- 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/helpers.ts +0 -1
- package/backend/snapshot/restore.ts +252 -0
- package/backend/ssh/ptykit.ts +1 -2
- package/backend/terminal/ptykit.ts +5 -8
- package/backend/tunnel/public-origin.ts +31 -20
- package/backend/utils/user-helpers.ts +0 -55
- package/backend/utils/ws.ts +61 -154
- 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 +64 -47
- 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/opencode/providers.ts +2 -1
- 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 +15 -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/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 +29 -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 +27 -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 +34 -45
- 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 +7 -7
- 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/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 +10 -11
- package/dist/assets/{index-CwuKQelV.js → index-CONlwAXZ.js} +1 -1
- package/dist/assets/{index-BTcR1byF.js → index-DJzwt-hq.js} +1 -1
- package/dist/assets/main-BUiUL3eZ.css +1 -0
- package/dist/assets/main-nBOb9YOA.js +1240 -0
- package/dist/index.html +2 -2
- package/package.json +2 -1
- 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 +2 -4
- 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/home-project.ts +25 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/ws-server.ts +32 -7
- 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
|
@@ -7,7 +7,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
7
7
|
import { connectionManager } from '../../db-client/connection-manager';
|
|
8
8
|
import type { AlterOperation, IndexDefinition, TableDefinition } from '../../db-client/drivers/types';
|
|
9
9
|
import type { DbClientSchemaNodeType } from '$shared/types/db-client';
|
|
10
|
-
import {
|
|
10
|
+
import { requireDbClientConnection } from './access';
|
|
11
11
|
|
|
12
12
|
const columnDefinitionSchema = t.Object({
|
|
13
13
|
name: t.String({ minLength: 1 }),
|
|
@@ -45,8 +45,8 @@ export const structureHandler = createRouter()
|
|
|
45
45
|
name: t.String({ minLength: 1 })
|
|
46
46
|
}),
|
|
47
47
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
48
|
-
}, async ({ data
|
|
49
|
-
|
|
48
|
+
}, async ({ data }) => {
|
|
49
|
+
requireDbClientConnection(data.connectionId);
|
|
50
50
|
const adapter = await connectionManager.get(data.connectionId);
|
|
51
51
|
if (!adapter.createDatabase) throw new Error('Driver does not support database creation');
|
|
52
52
|
const ddl = await adapter.createDatabase(data.name);
|
|
@@ -59,8 +59,8 @@ export const structureHandler = createRouter()
|
|
|
59
59
|
name: t.String({ minLength: 1 })
|
|
60
60
|
}),
|
|
61
61
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
62
|
-
}, async ({ data
|
|
63
|
-
|
|
62
|
+
}, async ({ data }) => {
|
|
63
|
+
requireDbClientConnection(data.connectionId);
|
|
64
64
|
const adapter = await connectionManager.get(data.connectionId);
|
|
65
65
|
if (!adapter.dropDatabase) throw new Error('Driver does not support dropping databases');
|
|
66
66
|
const ddl = await adapter.dropDatabase(data.name);
|
|
@@ -74,8 +74,8 @@ export const structureHandler = createRouter()
|
|
|
74
74
|
newName: t.String({ minLength: 1 })
|
|
75
75
|
}),
|
|
76
76
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
77
|
-
}, async ({ data
|
|
78
|
-
|
|
77
|
+
}, async ({ data }) => {
|
|
78
|
+
requireDbClientConnection(data.connectionId);
|
|
79
79
|
const adapter = await connectionManager.get(data.connectionId);
|
|
80
80
|
if (!adapter.renameDatabase) throw new Error('Driver does not support renaming databases');
|
|
81
81
|
const ddl = await adapter.renameDatabase(data.name, data.newName);
|
|
@@ -89,8 +89,8 @@ export const structureHandler = createRouter()
|
|
|
89
89
|
schema: t.Optional(t.String())
|
|
90
90
|
}),
|
|
91
91
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
92
|
-
}, async ({ data
|
|
93
|
-
|
|
92
|
+
}, async ({ data }) => {
|
|
93
|
+
requireDbClientConnection(data.connectionId);
|
|
94
94
|
const adapter = await connectionManager.get(data.connectionId);
|
|
95
95
|
if (!adapter.resetDatabase) throw new Error('Driver does not support emptying databases');
|
|
96
96
|
const ddl = await adapter.resetDatabase({ database: data.database, schema: data.schema });
|
|
@@ -102,8 +102,8 @@ export const structureHandler = createRouter()
|
|
|
102
102
|
connectionId: t.String({ minLength: 1 })
|
|
103
103
|
}),
|
|
104
104
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
105
|
-
}, async ({ data
|
|
106
|
-
|
|
105
|
+
}, async ({ data }) => {
|
|
106
|
+
requireDbClientConnection(data.connectionId);
|
|
107
107
|
const adapter = await connectionManager.get(data.connectionId);
|
|
108
108
|
if (!adapter.flushDatabase) throw new Error('Driver does not support flushing the database');
|
|
109
109
|
const ddl = await adapter.flushDatabase();
|
|
@@ -118,8 +118,8 @@ export const structureHandler = createRouter()
|
|
|
118
118
|
definition: tableDefinitionSchema
|
|
119
119
|
}),
|
|
120
120
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
121
|
-
}, async ({ data
|
|
122
|
-
|
|
121
|
+
}, async ({ data }) => {
|
|
122
|
+
requireDbClientConnection(data.connectionId);
|
|
123
123
|
const adapter = await connectionManager.get(data.connectionId);
|
|
124
124
|
if (!adapter.createTable) throw new Error('Driver does not support createTable');
|
|
125
125
|
const ddl = await adapter.createTable(data.definition as TableDefinition, {
|
|
@@ -138,8 +138,8 @@ export const structureHandler = createRouter()
|
|
|
138
138
|
operations: t.Array(alterOpSchema)
|
|
139
139
|
}),
|
|
140
140
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
141
|
-
}, async ({ data
|
|
142
|
-
|
|
141
|
+
}, async ({ data }) => {
|
|
142
|
+
requireDbClientConnection(data.connectionId);
|
|
143
143
|
const adapter = await connectionManager.get(data.connectionId);
|
|
144
144
|
if (!adapter.alterTable) throw new Error('Driver does not support alterTable');
|
|
145
145
|
const ddl = await adapter.alterTable(data.name, data.operations as AlterOperation[], {
|
|
@@ -157,8 +157,8 @@ export const structureHandler = createRouter()
|
|
|
157
157
|
name: t.String({ minLength: 1 })
|
|
158
158
|
}),
|
|
159
159
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
160
|
-
}, async ({ data
|
|
161
|
-
|
|
160
|
+
}, async ({ data }) => {
|
|
161
|
+
requireDbClientConnection(data.connectionId);
|
|
162
162
|
const adapter = await connectionManager.get(data.connectionId);
|
|
163
163
|
if (!adapter.dropTable) throw new Error('Driver does not support dropTable');
|
|
164
164
|
const ddl = await adapter.dropTable(data.name, {
|
|
@@ -176,8 +176,8 @@ export const structureHandler = createRouter()
|
|
|
176
176
|
name: t.String({ minLength: 1 })
|
|
177
177
|
}),
|
|
178
178
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
179
|
-
}, async ({ data
|
|
180
|
-
|
|
179
|
+
}, async ({ data }) => {
|
|
180
|
+
requireDbClientConnection(data.connectionId);
|
|
181
181
|
const adapter = await connectionManager.get(data.connectionId);
|
|
182
182
|
if (!adapter.truncateTable) throw new Error('Driver does not support truncateTable');
|
|
183
183
|
const ddl = await adapter.truncateTable(data.name, {
|
|
@@ -195,8 +195,8 @@ export const structureHandler = createRouter()
|
|
|
195
195
|
name: t.String({ minLength: 1 })
|
|
196
196
|
}),
|
|
197
197
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
198
|
-
}, async ({ data
|
|
199
|
-
|
|
198
|
+
}, async ({ data }) => {
|
|
199
|
+
requireDbClientConnection(data.connectionId);
|
|
200
200
|
const adapter = await connectionManager.get(data.connectionId);
|
|
201
201
|
if (!adapter.resetTable) throw new Error('Driver does not support resetTable');
|
|
202
202
|
const ddl = await adapter.resetTable(data.name, {
|
|
@@ -216,8 +216,8 @@ export const structureHandler = createRouter()
|
|
|
216
216
|
withData: t.Optional(t.Boolean())
|
|
217
217
|
}),
|
|
218
218
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
219
|
-
}, async ({ data
|
|
220
|
-
|
|
219
|
+
}, async ({ data }) => {
|
|
220
|
+
requireDbClientConnection(data.connectionId);
|
|
221
221
|
const adapter = await connectionManager.get(data.connectionId);
|
|
222
222
|
if (!adapter.duplicateTable) throw new Error('Driver does not support duplicateTable');
|
|
223
223
|
const ddl = await adapter.duplicateTable(data.name, data.newName, {
|
|
@@ -237,8 +237,8 @@ export const structureHandler = createRouter()
|
|
|
237
237
|
type: t.Optional(t.String())
|
|
238
238
|
}),
|
|
239
239
|
response: t.Object({ ok: t.Boolean(), statement: t.String() })
|
|
240
|
-
}, async ({ data
|
|
241
|
-
|
|
240
|
+
}, async ({ data }) => {
|
|
241
|
+
requireDbClientConnection(data.connectionId);
|
|
242
242
|
const adapter = await connectionManager.get(data.connectionId);
|
|
243
243
|
if (!adapter.getCreateStatement) throw new Error('Driver does not support fetching the CREATE statement');
|
|
244
244
|
const statement = await adapter.getCreateStatement(
|
|
@@ -258,8 +258,8 @@ export const structureHandler = createRouter()
|
|
|
258
258
|
newName: t.String({ minLength: 1 })
|
|
259
259
|
}),
|
|
260
260
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
261
|
-
}, async ({ data
|
|
262
|
-
|
|
261
|
+
}, async ({ data }) => {
|
|
262
|
+
requireDbClientConnection(data.connectionId);
|
|
263
263
|
const adapter = await connectionManager.get(data.connectionId);
|
|
264
264
|
if (!adapter.renameTable) throw new Error('Driver does not support renameTable');
|
|
265
265
|
const ddl = await adapter.renameTable(data.name, data.newName, {
|
|
@@ -278,8 +278,8 @@ export const structureHandler = createRouter()
|
|
|
278
278
|
indexDef: indexDefinitionSchema
|
|
279
279
|
}),
|
|
280
280
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
281
|
-
}, async ({ data
|
|
282
|
-
|
|
281
|
+
}, async ({ data }) => {
|
|
282
|
+
requireDbClientConnection(data.connectionId);
|
|
283
283
|
const adapter = await connectionManager.get(data.connectionId);
|
|
284
284
|
if (!adapter.createIndex) throw new Error('Driver does not support createIndex');
|
|
285
285
|
const ddl = await adapter.createIndex(data.tableName, data.indexDef as IndexDefinition, {
|
|
@@ -298,8 +298,8 @@ export const structureHandler = createRouter()
|
|
|
298
298
|
indexName: t.String({ minLength: 1 })
|
|
299
299
|
}),
|
|
300
300
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
301
|
-
}, async ({ data
|
|
302
|
-
|
|
301
|
+
}, async ({ data }) => {
|
|
302
|
+
requireDbClientConnection(data.connectionId);
|
|
303
303
|
const adapter = await connectionManager.get(data.connectionId);
|
|
304
304
|
if (!adapter.dropIndex) throw new Error('Driver does not support dropIndex');
|
|
305
305
|
const ddl = await adapter.dropIndex(data.tableName, data.indexName, {
|
|
@@ -318,8 +318,8 @@ export const structureHandler = createRouter()
|
|
|
318
318
|
query: t.String({ minLength: 1 })
|
|
319
319
|
}),
|
|
320
320
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
321
|
-
}, async ({ data
|
|
322
|
-
|
|
321
|
+
}, async ({ data }) => {
|
|
322
|
+
requireDbClientConnection(data.connectionId);
|
|
323
323
|
const adapter = await connectionManager.get(data.connectionId);
|
|
324
324
|
if (!adapter.createView) throw new Error('Driver does not support createView');
|
|
325
325
|
const ddl = await adapter.createView(data.name, data.query, {
|
|
@@ -337,8 +337,8 @@ export const structureHandler = createRouter()
|
|
|
337
337
|
name: t.String({ minLength: 1 })
|
|
338
338
|
}),
|
|
339
339
|
response: t.Object({ ok: t.Boolean(), ddl: t.String() })
|
|
340
|
-
}, async ({ data
|
|
341
|
-
|
|
340
|
+
}, async ({ data }) => {
|
|
341
|
+
requireDbClientConnection(data.connectionId);
|
|
342
342
|
const adapter = await connectionManager.get(data.connectionId);
|
|
343
343
|
if (!adapter.dropView) throw new Error('Driver does not support dropView');
|
|
344
344
|
const ddl = await adapter.dropView(data.name, {
|
|
@@ -7,17 +7,14 @@
|
|
|
7
7
|
* speculatively when a connection is selected and "this is not Supabase" is an
|
|
8
8
|
* ordinary answer.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `resolveDbClientProject` for the routes that touch the working tree. Reads
|
|
13
|
-
* are open to whoever can use the connection; applying a migration and writing
|
|
14
|
-
* types are not, and say so.
|
|
10
|
+
* The connection must exist, and the routes that touch the working tree also
|
|
11
|
+
* resolve their project through `resolveDbClientProject`.
|
|
15
12
|
*/
|
|
16
13
|
|
|
17
14
|
import { t } from 'elysia';
|
|
18
15
|
import { createRouter } from '$shared/utils/ws-server';
|
|
19
16
|
import { resolveSupabaseScope, supabaseSurface, type SupabaseScope } from '../../db-client/integrations';
|
|
20
|
-
import {
|
|
17
|
+
import { requireDbClientConnection } from './access';
|
|
21
18
|
import { resolveDbClientProject } from './context';
|
|
22
19
|
import type { WSConnection } from '$shared/utils/ws-server';
|
|
23
20
|
import { debug } from '$shared/utils/logger';
|
|
@@ -27,7 +24,7 @@ async function scopeFor(
|
|
|
27
24
|
connectionId: string,
|
|
28
25
|
projectId?: string
|
|
29
26
|
): Promise<SupabaseScope | null> {
|
|
30
|
-
|
|
27
|
+
requireDbClientConnection(connectionId);
|
|
31
28
|
const project = resolveDbClientProject(conn, projectId);
|
|
32
29
|
return resolveSupabaseScope(connectionId, project?.root ?? null);
|
|
33
30
|
}
|
|
@@ -50,18 +47,6 @@ async function requireScope(
|
|
|
50
47
|
return scope;
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
/**
|
|
54
|
-
* Writes are admin-only.
|
|
55
|
-
*
|
|
56
|
-
* Applying a migration changes a schema everyone shares, and writing generated
|
|
57
|
-
* types writes a file into the repository. Both are outward-facing in the sense
|
|
58
|
-
* `Task 3` uses: the consequence outlives the request.
|
|
59
|
-
*/
|
|
60
|
-
function requireAdmin(conn: WSConnection, action: string): void {
|
|
61
|
-
const { isAdmin } = getDbClientPrincipal(conn);
|
|
62
|
-
if (!isAdmin) throw new Error(`Only an admin can ${action}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
50
|
const connectionTarget = {
|
|
66
51
|
connectionId: t.String({ minLength: 1 }),
|
|
67
52
|
projectId: t.Optional(t.String())
|
|
@@ -110,7 +95,6 @@ export const supabaseHandler = createRouter()
|
|
|
110
95
|
data: t.Object({ ...connectionTarget, version: t.String({ minLength: 1 }) }),
|
|
111
96
|
response: t.Object({ version: t.String(), durationMs: t.Number() })
|
|
112
97
|
}, async ({ data, conn }) => {
|
|
113
|
-
requireAdmin(conn, 'apply a migration');
|
|
114
98
|
const scope = await requireScope(conn, data.connectionId, data.projectId);
|
|
115
99
|
const result = await supabaseSurface.apply(scope, data.version);
|
|
116
100
|
debug.log('db-client', `Supabase migration ${result.version} applied to ${scope.context.ref}`);
|
|
@@ -182,7 +166,6 @@ export const supabaseHandler = createRouter()
|
|
|
182
166
|
}),
|
|
183
167
|
response: t.Object({ path: t.String(), bytes: t.Number() })
|
|
184
168
|
}, async ({ data, conn }) => {
|
|
185
|
-
requireAdmin(conn, 'write generated types into the project');
|
|
186
169
|
const scope = await requireScope(conn, data.connectionId, data.projectId);
|
|
187
170
|
return supabaseSurface.writeTypes(scope, data.path, data.contents);
|
|
188
171
|
});
|
|
@@ -32,7 +32,7 @@ export interface DeployProjectContext {
|
|
|
32
32
|
export function resolveDeployProject(conn: WSConnection, projectId?: string): DeployProjectContext {
|
|
33
33
|
const current = ws.getProjectId(conn);
|
|
34
34
|
const target = (projectId ?? '').trim() || current;
|
|
35
|
-
const project = requireProjectAccess(
|
|
35
|
+
const project = requireProjectAccess(target);
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
38
|
projectId: target,
|
|
@@ -9,11 +9,6 @@
|
|
|
9
9
|
* deployments:set-config per-binding behaviour (environment, auto-refresh)
|
|
10
10
|
* deployments:logs build logs as one budgeted bundle
|
|
11
11
|
*
|
|
12
|
-
* NOT admin-gated, unlike `integrations:*`. The distinction is what the route
|
|
13
|
-
* can reach: an integrations route changes a credential every project and every
|
|
14
|
-
* engine depends on, while these act inside one project the caller was already
|
|
15
|
-
* granted access to — the same reasoning that leaves `git:push` open.
|
|
16
|
-
*
|
|
17
12
|
* Every route takes an optional `projectId`, because this surface is global.
|
|
18
13
|
*/
|
|
19
14
|
|
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Engine
|
|
3
|
-
*
|
|
4
|
-
* Engine accounts (Claude, Codex, Copilot, Qwen, OpenCode) are global system
|
|
5
|
-
* credentials. Mutations are gated to admins at the router level via
|
|
6
|
-
* `ADMIN_ONLY_ROUTES`. This file covers the leftover concern: setup-flow
|
|
7
|
-
* PTY sessions belong to the admin who started them, so other admins cannot
|
|
8
|
-
* submit codes or cancel into someone else's flow.
|
|
2
|
+
* Engine setup-flow guard.
|
|
9
3
|
*
|
|
10
4
|
* Each engine keeps its own `Map<setupId, SetupProcess>` (Claude, Codex, …).
|
|
11
|
-
* The shape varies, but every entry tracks
|
|
12
|
-
*
|
|
5
|
+
* The shape varies, but every entry tracks a `disposed` flag, so the helper is
|
|
6
|
+
* typed against that minimal contract.
|
|
13
7
|
*/
|
|
14
8
|
|
|
15
|
-
import type { WSConnection } from '$shared/utils/ws-server';
|
|
16
|
-
import { ws } from '$backend/utils/ws';
|
|
17
|
-
|
|
18
9
|
export interface SetupProcessLike {
|
|
19
|
-
userId: string;
|
|
20
10
|
disposed: boolean;
|
|
21
11
|
}
|
|
22
12
|
|
|
23
13
|
/**
|
|
24
|
-
* Resolve a setup-flow session
|
|
25
|
-
*
|
|
26
|
-
* we don't leak existence of another admin's setup.
|
|
14
|
+
* Resolve a live setup-flow session. Throws the same error for "missing" and
|
|
15
|
+
* "expired", because the client handles both the same way: start again.
|
|
27
16
|
*/
|
|
28
|
-
export function
|
|
29
|
-
conn: WSConnection,
|
|
17
|
+
export function requireSetupSession<T extends SetupProcessLike>(
|
|
30
18
|
setupId: string,
|
|
31
19
|
setupProcesses: Map<string, T>
|
|
32
20
|
): T {
|
|
33
|
-
const userId = ws.getUserId(conn);
|
|
34
21
|
const entry = setupProcesses.get(setupId);
|
|
35
|
-
if (!entry || entry.disposed
|
|
22
|
+
if (!entry || entry.disposed) {
|
|
36
23
|
throw new Error('Setup session not found or expired');
|
|
37
24
|
}
|
|
38
25
|
return entry;
|
|
@@ -22,7 +22,7 @@ import { resetEnvironment, getClaudeUserConfigDir } from '../../../engine/adapte
|
|
|
22
22
|
import { resolveEngineCli } from '$backend/engine/engine-cli';
|
|
23
23
|
import { debug } from '$shared/utils/logger';
|
|
24
24
|
import { getCleanSpawnEnv } from '../../../utils/env';
|
|
25
|
-
import {
|
|
25
|
+
import { requireSetupSession } from '../access';
|
|
26
26
|
import { stripAnsi, extractHttpsUrl } from '../pty-output';
|
|
27
27
|
|
|
28
28
|
// ── Helpers ──
|
|
@@ -376,7 +376,7 @@ export const accountsHandler = createRouter()
|
|
|
376
376
|
const userId = ws.getUserId(conn);
|
|
377
377
|
let entry: SetupProcess;
|
|
378
378
|
try {
|
|
379
|
-
entry =
|
|
379
|
+
entry = requireSetupSession(data.setupId, setupProcesses);
|
|
380
380
|
} catch {
|
|
381
381
|
ws.emit.user(userId, 'engine:claude-account-setup-error', {
|
|
382
382
|
setupId: data.setupId,
|
|
@@ -408,9 +408,9 @@ export const accountsHandler = createRouter()
|
|
|
408
408
|
data: t.Object({
|
|
409
409
|
setupId: t.String()
|
|
410
410
|
})
|
|
411
|
-
}, async ({ data
|
|
411
|
+
}, async ({ data }) => {
|
|
412
412
|
try {
|
|
413
|
-
|
|
413
|
+
requireSetupSession(data.setupId, setupProcesses);
|
|
414
414
|
} catch {
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
writeClineAccountCredential,
|
|
32
32
|
type ClineCredential,
|
|
33
33
|
} from '../../../engine/adapters/cline/credential';
|
|
34
|
-
import {
|
|
34
|
+
import { requireSetupSession } from '../access';
|
|
35
35
|
import { debug } from '$shared/utils/logger';
|
|
36
36
|
import { hasLoopbackCallbackListener } from '$backend/utils/port-utils';
|
|
37
37
|
|
|
@@ -295,10 +295,10 @@ export const clineAccountsHandler = createRouter()
|
|
|
295
295
|
|
|
296
296
|
.on('engine:cline-account-login-submit', {
|
|
297
297
|
data: t.Object({ loginId: t.String(), value: t.String() })
|
|
298
|
-
}, async ({ data
|
|
298
|
+
}, async ({ data }) => {
|
|
299
299
|
let entry: ClineLoginSession;
|
|
300
300
|
try {
|
|
301
|
-
entry =
|
|
301
|
+
entry = requireSetupSession(data.loginId, loginSessions);
|
|
302
302
|
} catch {
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
@@ -309,9 +309,9 @@ export const clineAccountsHandler = createRouter()
|
|
|
309
309
|
|
|
310
310
|
.on('engine:cline-account-login-cancel', {
|
|
311
311
|
data: t.Object({ loginId: t.String() })
|
|
312
|
-
}, async ({ data
|
|
312
|
+
}, async ({ data }) => {
|
|
313
313
|
try {
|
|
314
|
-
|
|
314
|
+
requireSetupSession(data.loginId, loginSessions);
|
|
315
315
|
} catch {
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
import { resolveEngineCli } from '$backend/engine/engine-cli';
|
|
56
56
|
import { getCleanSpawnEnv } from '../../../utils/env';
|
|
57
57
|
import { debug } from '$shared/utils/logger';
|
|
58
|
-
import {
|
|
58
|
+
import { requireSetupSession } from '../access';
|
|
59
59
|
// Codex emits coloured output and cursor moves; we strip them before
|
|
60
60
|
// pattern-matching but stream the raw bytes (with ANSI) to the UI's xterm.js so
|
|
61
61
|
// the user sees the CLI exactly as it would render in a real terminal.
|
|
@@ -497,10 +497,10 @@ export const codexAccountsHandler = createRouter()
|
|
|
497
497
|
|
|
498
498
|
.on('engine:codex-account-setup-cancel', {
|
|
499
499
|
data: t.Object({ setupId: t.String() })
|
|
500
|
-
}, async ({ data
|
|
500
|
+
}, async ({ data }) => {
|
|
501
501
|
let entry: CodexLoginProcess;
|
|
502
502
|
try {
|
|
503
|
-
entry =
|
|
503
|
+
entry = requireSetupSession(data.setupId, setupProcesses);
|
|
504
504
|
} catch {
|
|
505
505
|
return;
|
|
506
506
|
}
|
|
@@ -10,6 +10,7 @@ import { engineQueries } from '../../../database/queries';
|
|
|
10
10
|
import {
|
|
11
11
|
fetchAndCacheModelsDevCatalog,
|
|
12
12
|
getCachedModelsDevCatalog,
|
|
13
|
+
withCuratedProviders,
|
|
13
14
|
} from '../../../engine/adapters/opencode/presets';
|
|
14
15
|
import { debug } from '$shared/utils/logger';
|
|
15
16
|
|
|
@@ -268,7 +269,7 @@ export const openCodeProviderHandler = createRouter()
|
|
|
268
269
|
return { catalog, cachedAt: new Date().toISOString() };
|
|
269
270
|
} catch (error) {
|
|
270
271
|
debug.error('engine', 'Failed to fetch models.dev catalog:', error);
|
|
271
|
-
return { catalog: [], cachedAt: null };
|
|
272
|
+
return { catalog: withCuratedProviders([]), cachedAt: null };
|
|
272
273
|
}
|
|
273
274
|
})
|
|
274
275
|
|
|
@@ -21,7 +21,7 @@ import { engineQueries } from '../../../database/queries';
|
|
|
21
21
|
import { disposeAllProjectEnginesByType } from '../../../engine';
|
|
22
22
|
import { createPiRuntime, getPiProviderFields } from '../../../engine/adapters/pi/presets';
|
|
23
23
|
import { DbCredentialStore, serializePiCredential, parsePiCredential, getPiProvider, getPiDeviceId, writePiAccountCredential } from '../../../engine/adapters/pi/credential';
|
|
24
|
-
import {
|
|
24
|
+
import { requireSetupSession } from '../access';
|
|
25
25
|
import { hasLoopbackCallbackListener } from '$backend/utils/port-utils';
|
|
26
26
|
import { debug } from '$shared/utils/logger';
|
|
27
27
|
|
|
@@ -320,10 +320,10 @@ export const piAccountsHandler = createRouter()
|
|
|
320
320
|
|
|
321
321
|
.on('engine:pi-account-login-submit', {
|
|
322
322
|
data: t.Object({ loginId: t.String(), value: t.String() })
|
|
323
|
-
}, async ({ data
|
|
323
|
+
}, async ({ data }) => {
|
|
324
324
|
let entry: PiLoginSession;
|
|
325
325
|
try {
|
|
326
|
-
entry =
|
|
326
|
+
entry = requireSetupSession(data.loginId, loginSessions);
|
|
327
327
|
} catch {
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
@@ -334,9 +334,9 @@ export const piAccountsHandler = createRouter()
|
|
|
334
334
|
|
|
335
335
|
.on('engine:pi-account-login-cancel', {
|
|
336
336
|
data: t.Object({ loginId: t.String() })
|
|
337
|
-
}, async ({ data
|
|
337
|
+
}, async ({ data }) => {
|
|
338
338
|
try {
|
|
339
|
-
|
|
339
|
+
requireSetupSession(data.loginId, loginSessions);
|
|
340
340
|
} catch {
|
|
341
341
|
return;
|
|
342
342
|
}
|
|
@@ -17,29 +17,16 @@
|
|
|
17
17
|
* native file-drop list on a menu click (no DataTransfer), hence this backend
|
|
18
18
|
* round-trip.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* directory), so both routes are admin-only.
|
|
25
|
-
*
|
|
26
|
-
* The read route answers a non-admin with an empty list rather than an error:
|
|
27
|
-
* the frontend polls it to decide whether to offer "Paste", and an empty list
|
|
28
|
-
* simply means "nothing pasteable from the OS" — no error toast on every
|
|
29
|
-
* context-menu open. The write route throws, because it is only ever reached
|
|
30
|
-
* from an explicit Copy/Cut the caller asked for.
|
|
31
|
-
*
|
|
32
|
-
* Published paths still go through the standard per-user file access guard on
|
|
33
|
-
* top of the admin check, so the guard stays correct if the policy is ever
|
|
34
|
-
* widened. The backend only *publishes references* — the file manager
|
|
35
|
-
* performs the actual copy, and sources are never moved or deleted by Clopen.
|
|
20
|
+
* Both routes act on the clipboard of the machine the server runs on — the
|
|
21
|
+
* owner's own. Published paths are canonicalised first. The backend only
|
|
22
|
+
* *publishes references* — the file manager performs the actual copy, and
|
|
23
|
+
* sources are never moved or deleted by Clopen.
|
|
36
24
|
*/
|
|
37
25
|
|
|
38
26
|
import { t } from 'elysia';
|
|
39
27
|
import { createRouter } from '$shared/utils/ws-server';
|
|
40
|
-
import { ws } from '$backend/utils/ws';
|
|
41
28
|
import { copyPathsToOsClipboard, readOsClipboardFilePaths } from '../../files/os-clipboard';
|
|
42
|
-
import {
|
|
29
|
+
import { resolveFilePath } from './path-access';
|
|
43
30
|
|
|
44
31
|
export const clipboardHandler = createRouter()
|
|
45
32
|
.http('files:copy-to-os-clipboard', {
|
|
@@ -52,13 +39,10 @@ export const clipboardHandler = createRouter()
|
|
|
52
39
|
/** The effect actually published — `copy` on macOS even for a CUT. */
|
|
53
40
|
effect: t.Union([t.Literal('copy'), t.Literal('move')])
|
|
54
41
|
})
|
|
55
|
-
}, async ({ data
|
|
56
|
-
if (ws.getRole(conn) !== 'admin') {
|
|
57
|
-
throw new Error('Access denied');
|
|
58
|
-
}
|
|
42
|
+
}, async ({ data }) => {
|
|
59
43
|
const resolved: string[] = [];
|
|
60
44
|
for (const p of data.paths) {
|
|
61
|
-
resolved.push(await
|
|
45
|
+
resolved.push(await resolveFilePath(p));
|
|
62
46
|
}
|
|
63
47
|
return await copyPathsToOsClipboard(resolved, data.effect ?? 'copy');
|
|
64
48
|
})
|
|
@@ -70,9 +54,6 @@ export const clipboardHandler = createRouter()
|
|
|
70
54
|
isDirectory: t.Boolean()
|
|
71
55
|
}))
|
|
72
56
|
})
|
|
73
|
-
}, async (
|
|
74
|
-
if (ws.getRole(conn) !== 'admin') {
|
|
75
|
-
return { items: [] };
|
|
76
|
-
}
|
|
57
|
+
}, async () => {
|
|
77
58
|
return { items: await readOsClipboardFilePaths() };
|
|
78
59
|
});
|
|
@@ -17,7 +17,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
17
17
|
import { debug } from '$shared/utils/logger';
|
|
18
18
|
import type { ImageEditRecipe } from '$shared/types/filesystem';
|
|
19
19
|
import { processImageEdit } from '../../files/image-processing';
|
|
20
|
-
import {
|
|
20
|
+
import { resolveFilePath } from './path-access';
|
|
21
21
|
|
|
22
22
|
const cropSchema = t.Object({
|
|
23
23
|
left: t.Number(),
|
|
@@ -93,8 +93,8 @@ export const imageEditHandler = createRouter()
|
|
|
93
93
|
width: t.Number(),
|
|
94
94
|
height: t.Number()
|
|
95
95
|
})
|
|
96
|
-
}, async ({ data
|
|
97
|
-
const sourcePath = await
|
|
96
|
+
}, async ({ data }) => {
|
|
97
|
+
const sourcePath = await resolveFilePath(data.sourcePath);
|
|
98
98
|
// Fast mode: lower encoder effort so the live estimate stays responsive
|
|
99
99
|
// on very large images / upscales. The real save uses full effort.
|
|
100
100
|
const result = await processImageEdit(sourcePath, data.recipe as ImageEditRecipe, true);
|
|
@@ -120,9 +120,9 @@ export const imageEditHandler = createRouter()
|
|
|
120
120
|
height: t.Number(),
|
|
121
121
|
modified: t.String()
|
|
122
122
|
})
|
|
123
|
-
}, async ({ data
|
|
124
|
-
const sourcePath = await
|
|
125
|
-
const targetPath = await
|
|
123
|
+
}, async ({ data }) => {
|
|
124
|
+
const sourcePath = await resolveFilePath(data.sourcePath);
|
|
125
|
+
const targetPath = await resolveFilePath(data.targetPath);
|
|
126
126
|
|
|
127
127
|
const targetStat = await fsStat(targetPath).catch(() => null);
|
|
128
128
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - read.ts: HTTP endpoints for reading (list-tree, browse, read-file, read-content)
|
|
8
8
|
* - write.ts: HTTP endpoints for writing (write, create, rename, duplicate, upload, delete)
|
|
9
9
|
* - reveal.ts: HTTP endpoint for revealing files in the OS file manager
|
|
10
|
-
* - clipboard.ts: HTTP endpoints for the native OS clipboard bridge
|
|
10
|
+
* - clipboard.ts: HTTP endpoints for the native OS clipboard bridge
|
|
11
11
|
* - search.ts: HTTP endpoints for searching (search-files, search-code)
|
|
12
12
|
* - watch.ts: Event handlers for real-time file watching
|
|
13
13
|
*/
|