@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
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Projects Status
|
|
2
|
+
* Projects Status
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - projects:
|
|
7
|
-
* - projects:
|
|
8
|
-
* - projects:presence-updated (Broadcast) - Full
|
|
9
|
-
*
|
|
10
|
-
* Single broadcast event: `projects:presence-updated` contains full state.
|
|
4
|
+
* Live chat-stream status of every project, mirrored on every device so busy
|
|
5
|
+
* and waiting-for-input indicators stay in sync:
|
|
6
|
+
* - projects:get-status (HTTP) - Status of the current project
|
|
7
|
+
* - projects:join (Event) - A device opened a project; replies with every project's status
|
|
8
|
+
* - projects:presence-updated (Broadcast) - Full status of all projects
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
import { t } from 'elysia';
|
|
14
12
|
import { createRouter } from '$shared/utils/ws-server';
|
|
15
|
-
import { getProjectStatusData
|
|
13
|
+
import { getProjectStatusData } from '../../project/status-manager';
|
|
16
14
|
import { streamManager } from '../../chat/stream-manager';
|
|
17
15
|
import { ws } from '$backend/utils/ws';
|
|
18
16
|
import { debug } from '$shared/utils/logger';
|
|
19
|
-
import { requireProjectAccess } from '../access';
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
|
-
* Broadcast full
|
|
19
|
+
* Broadcast the full status of all projects to all connected clients
|
|
23
20
|
*/
|
|
24
21
|
export async function broadcastPresence() {
|
|
25
22
|
const statuses = await getProjectStatusData();
|
|
@@ -40,17 +37,15 @@ export const statusHandler = createRouter()
|
|
|
40
37
|
return await getProjectStatusData(projectId);
|
|
41
38
|
})
|
|
42
39
|
|
|
43
|
-
//
|
|
40
|
+
// A device opened a project
|
|
44
41
|
.on('projects:join', {
|
|
45
|
-
data: t.Object({
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
}, async ({ data, conn }) => {
|
|
42
|
+
data: t.Object({})
|
|
43
|
+
}, async ({ conn }) => {
|
|
49
44
|
const projectId = ws.getProjectId(conn);
|
|
50
45
|
const userId = ws.getUserId(conn);
|
|
51
46
|
|
|
52
47
|
try {
|
|
53
|
-
// Send initial
|
|
48
|
+
// Send initial status for ALL projects
|
|
54
49
|
const allStatuses = await getProjectStatusData();
|
|
55
50
|
ws.emit.user(userId, 'projects:presence-updated', {
|
|
56
51
|
type: 'presence-updated',
|
|
@@ -58,28 +53,13 @@ export const statusHandler = createRouter()
|
|
|
58
53
|
data: allStatuses
|
|
59
54
|
});
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
streamManager.cleanupProjectStreams(projectId);
|
|
66
|
-
} catch (cleanupError) {
|
|
67
|
-
debug.error('project', 'Error cleaning up project streams:', cleanupError);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Auto-cleanup on connection close (tab close, network drop)
|
|
71
|
-
ws.addCleanup(conn, () => {
|
|
72
|
-
updateUserPresence(projectId, userId, '', 'leave');
|
|
73
|
-
debug.log('project', `Auto-cleaned presence for ${userId} from project ${projectId}`);
|
|
74
|
-
broadcastPresence().catch((err) => {
|
|
75
|
-
debug.warn('project', `Presence broadcast error after auto-cleanup for ${userId}:`, err);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
await broadcastPresence();
|
|
56
|
+
try {
|
|
57
|
+
streamManager.cleanupProjectStreams(projectId);
|
|
58
|
+
} catch (cleanupError) {
|
|
59
|
+
debug.error('project', 'Error cleaning up project streams:', cleanupError);
|
|
80
60
|
}
|
|
81
61
|
|
|
82
|
-
debug.log('project', `
|
|
62
|
+
debug.log('project', `Device joined project ${projectId}`);
|
|
83
63
|
} catch (error) {
|
|
84
64
|
debug.error('project', 'Error joining project:', error);
|
|
85
65
|
ws.emit.user(userId, 'projects:error', {
|
|
@@ -88,26 +68,6 @@ export const statusHandler = createRouter()
|
|
|
88
68
|
}
|
|
89
69
|
})
|
|
90
70
|
|
|
91
|
-
// User leaves a project
|
|
92
|
-
.on('projects:leave', {
|
|
93
|
-
data: t.Object({
|
|
94
|
-
projectId: t.Optional(t.String())
|
|
95
|
-
})
|
|
96
|
-
}, async ({ data, conn }) => {
|
|
97
|
-
// Use explicit projectId from client (avoids race condition when switching projects)
|
|
98
|
-
const projectId = data.projectId || ws.getProjectId(conn);
|
|
99
|
-
const userId = ws.getUserId(conn);
|
|
100
|
-
requireProjectAccess(conn, projectId);
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
updateUserPresence(projectId, userId, '', 'leave');
|
|
104
|
-
await broadcastPresence();
|
|
105
|
-
debug.log('project', `User ${userId} left project ${projectId}`);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
debug.error('project', 'Error leaving project:', error);
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
|
|
111
71
|
// Event declarations
|
|
112
72
|
.emit('projects:presence-updated', t.Object({
|
|
113
73
|
type: t.Literal('presence-updated'),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* HTTP endpoints for session management:
|
|
5
5
|
* - List sessions (all or by project)
|
|
6
6
|
* - Create new session
|
|
7
|
-
* - Get session by ID
|
|
7
|
+
* - Get session by ID
|
|
8
8
|
* - Get or create shared session
|
|
9
9
|
* - Update session (title, reactivate, end)
|
|
10
10
|
* - Delete session
|
|
@@ -47,8 +47,6 @@ const sessionSchema = t.Object({
|
|
|
47
47
|
// Isolation
|
|
48
48
|
worktree_id: t.Optional(t.Union([t.String(), t.Null()])),
|
|
49
49
|
// Activity tracking
|
|
50
|
-
sender_id: t.Optional(t.String()),
|
|
51
|
-
sender_name: t.Optional(t.String()),
|
|
52
50
|
message_count: t.Optional(t.Number()),
|
|
53
51
|
user_count: t.Optional(t.Number()),
|
|
54
52
|
last_message_at: t.Optional(t.String()),
|
|
@@ -73,8 +71,6 @@ function serializeSession(session: ChatSession) {
|
|
|
73
71
|
head_message_id: session.head_message_id ?? undefined,
|
|
74
72
|
head_session_id: session.head_session_id ?? undefined,
|
|
75
73
|
ended_at: session.ended_at ?? undefined,
|
|
76
|
-
sender_id: session.sender_id ?? undefined,
|
|
77
|
-
sender_name: session.sender_name ?? undefined,
|
|
78
74
|
head_title: session.head_title ?? undefined,
|
|
79
75
|
head_summary: session.head_summary ?? undefined,
|
|
80
76
|
message_count: session.message_count ?? undefined,
|
|
@@ -104,15 +100,14 @@ export const crudHandler = createRouter()
|
|
|
104
100
|
}))
|
|
105
101
|
})
|
|
106
102
|
}, async ({ conn }) => {
|
|
107
|
-
const { projectId
|
|
103
|
+
const { projectId } = requireCurrentProjectAccess(conn);
|
|
108
104
|
const sessions = sessionQueries.getByProjectId(projectId);
|
|
109
105
|
|
|
110
|
-
//
|
|
111
|
-
const currentSessionId = projectQueries.getCurrentSessionId(
|
|
106
|
+
// The saved current session for this project
|
|
107
|
+
const currentSessionId = projectQueries.getCurrentSessionId(projectId);
|
|
112
108
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
debug.log('session', `[unread] sessions:list — user=${userId}, project=${projectId}, unreadCount=${unreadRows.length}`, unreadRows);
|
|
109
|
+
const unreadRows = sessionQueries.getUnreadSessions(projectId);
|
|
110
|
+
debug.log('session', `[unread] sessions:list — project=${projectId}, unreadCount=${unreadRows.length}`, unreadRows);
|
|
116
111
|
|
|
117
112
|
return {
|
|
118
113
|
sessions: sessions.map(serializeSession),
|
|
@@ -154,25 +149,21 @@ export const crudHandler = createRouter()
|
|
|
154
149
|
return serializeSession(session);
|
|
155
150
|
})
|
|
156
151
|
|
|
157
|
-
// Get session by ID
|
|
152
|
+
// Get session by ID.
|
|
153
|
+
//
|
|
154
|
+
// The session only. It used to carry the whole message chain as well, which
|
|
155
|
+
// no caller read — opening a chat loads its messages through `messages:list`
|
|
156
|
+
// right after — so every chat open downloaded its entire history twice.
|
|
158
157
|
.http('sessions:get', {
|
|
159
158
|
data: t.Object({
|
|
160
159
|
id: t.String({ minLength: 1 })
|
|
161
160
|
}),
|
|
162
161
|
response: t.Object({
|
|
163
|
-
session: sessionSchema
|
|
164
|
-
messages: t.Array(t.Any())
|
|
162
|
+
session: sessionSchema
|
|
165
163
|
})
|
|
166
|
-
}, async ({ data
|
|
167
|
-
const session = requireSessionAccess(
|
|
168
|
-
|
|
169
|
-
// Also get messages for this session
|
|
170
|
-
const messages = messageQueries.getBySessionId(data.id);
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
session: serializeSession(session),
|
|
174
|
-
messages
|
|
175
|
-
};
|
|
164
|
+
}, async ({ data }) => {
|
|
165
|
+
const session = requireSessionAccess(data.id);
|
|
166
|
+
return { session: serializeSession(session) };
|
|
176
167
|
})
|
|
177
168
|
|
|
178
169
|
// Get or create shared session
|
|
@@ -222,8 +213,8 @@ export const crudHandler = createRouter()
|
|
|
222
213
|
end_session: t.Optional(t.Boolean())
|
|
223
214
|
}),
|
|
224
215
|
response: sessionSchema
|
|
225
|
-
}, async ({ data
|
|
226
|
-
requireSessionAccess(
|
|
216
|
+
}, async ({ data }) => {
|
|
217
|
+
requireSessionAccess(data.id);
|
|
227
218
|
|
|
228
219
|
if (data.title) {
|
|
229
220
|
sessionQueries.updateTitle(data.id, data.title);
|
|
@@ -249,8 +240,8 @@ export const crudHandler = createRouter()
|
|
|
249
240
|
response: t.Object({
|
|
250
241
|
message: t.String()
|
|
251
242
|
})
|
|
252
|
-
}, async ({ data
|
|
253
|
-
const session = requireSessionAccess(
|
|
243
|
+
}, async ({ data }) => {
|
|
244
|
+
const session = requireSessionAccess(data.id);
|
|
254
245
|
|
|
255
246
|
const projectId = session.project_id;
|
|
256
247
|
|
|
@@ -293,7 +284,7 @@ export const crudHandler = createRouter()
|
|
|
293
284
|
}
|
|
294
285
|
}
|
|
295
286
|
|
|
296
|
-
// Broadcast to
|
|
287
|
+
// Broadcast to the project so other devices see the deletion
|
|
297
288
|
debug.log('session', `Broadcasting session deleted: ${data.id} in project: ${projectId}`);
|
|
298
289
|
ws.emit.project(projectId, 'sessions:session-deleted', {
|
|
299
290
|
sessionId: data.id,
|
|
@@ -394,57 +385,52 @@ export const crudHandler = createRouter()
|
|
|
394
385
|
};
|
|
395
386
|
})
|
|
396
387
|
|
|
397
|
-
// Persist
|
|
388
|
+
// Persist the current session choice (for refresh restore)
|
|
398
389
|
.on('sessions:set-current', {
|
|
399
390
|
data: t.Object({
|
|
400
391
|
sessionId: t.String()
|
|
401
392
|
})
|
|
402
393
|
}, async ({ data, conn }) => {
|
|
403
|
-
const { projectId
|
|
404
|
-
requireSessionAccess(
|
|
405
|
-
projectQueries.setCurrentSessionId(
|
|
406
|
-
debug.log('session', `
|
|
394
|
+
const { projectId } = requireCurrentProjectAccess(conn);
|
|
395
|
+
requireSessionAccess(data.sessionId);
|
|
396
|
+
projectQueries.setCurrentSessionId(projectId, data.sessionId);
|
|
397
|
+
debug.log('session', `Current session set to ${data.sessionId} in project ${projectId}`);
|
|
407
398
|
})
|
|
408
399
|
|
|
409
|
-
// Mark a session as read for the current user
|
|
410
400
|
.on('sessions:mark-read', {
|
|
411
401
|
data: t.Object({
|
|
412
402
|
sessionId: t.String()
|
|
413
403
|
})
|
|
414
|
-
}, async ({ data
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
debug.log('session', `[unread] Marked session ${data.sessionId} as READ for user ${userId}`);
|
|
404
|
+
}, async ({ data }) => {
|
|
405
|
+
requireSessionAccess(data.sessionId);
|
|
406
|
+
sessionQueries.markRead(data.sessionId);
|
|
407
|
+
debug.log('session', `[unread] Marked session ${data.sessionId} as READ`);
|
|
419
408
|
})
|
|
420
409
|
|
|
421
|
-
// Mark a session as unread for the current user
|
|
422
410
|
.on('sessions:mark-unread', {
|
|
423
411
|
data: t.Object({
|
|
424
412
|
sessionId: t.String(),
|
|
425
413
|
projectId: t.String()
|
|
426
414
|
})
|
|
427
|
-
}, async ({ data
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
requireProjectAccess(conn, data.projectId);
|
|
415
|
+
}, async ({ data }) => {
|
|
416
|
+
const session = requireSessionAccess(data.sessionId);
|
|
417
|
+
requireProjectAccess(data.projectId);
|
|
431
418
|
if (session.project_id !== data.projectId) {
|
|
432
419
|
throw new Error('Access denied');
|
|
433
420
|
}
|
|
434
|
-
sessionQueries.markUnread(
|
|
435
|
-
debug.log('session', `[unread] Marked session ${data.sessionId} as UNREAD
|
|
421
|
+
sessionQueries.markUnread(data.sessionId, data.projectId);
|
|
422
|
+
debug.log('session', `[unread] Marked session ${data.sessionId} as UNREAD in project ${data.projectId}`);
|
|
436
423
|
})
|
|
437
424
|
|
|
438
|
-
// Mark every session in a project as read
|
|
425
|
+
// Mark every session in a project as read
|
|
439
426
|
.on('sessions:mark-all-read', {
|
|
440
427
|
data: t.Object({
|
|
441
428
|
projectId: t.String()
|
|
442
429
|
})
|
|
443
|
-
}, async ({ data
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
debug.log('session', `[unread] Marked ALL sessions as READ for user ${userId} in project ${data.projectId}`);
|
|
430
|
+
}, async ({ data }) => {
|
|
431
|
+
requireProjectAccess(data.projectId);
|
|
432
|
+
sessionQueries.markAllRead(data.projectId);
|
|
433
|
+
debug.log('session', `[unread] Marked ALL sessions as READ in project ${data.projectId}`);
|
|
448
434
|
})
|
|
449
435
|
|
|
450
436
|
// Search sessions by message content within the current project (deep search)
|
|
@@ -464,7 +450,7 @@ export const crudHandler = createRouter()
|
|
|
464
450
|
return { results };
|
|
465
451
|
})
|
|
466
452
|
|
|
467
|
-
// Search sessions across every project the
|
|
453
|
+
// Search sessions across every project in the workspace list (Command Palette)
|
|
468
454
|
.http('sessions:search-global', {
|
|
469
455
|
data: t.Object({
|
|
470
456
|
query: t.String({ minLength: 1 })
|
|
@@ -472,9 +458,8 @@ export const crudHandler = createRouter()
|
|
|
472
458
|
response: t.Object({
|
|
473
459
|
sessions: t.Array(sessionSearchResultSchema)
|
|
474
460
|
})
|
|
475
|
-
}, async ({ data
|
|
476
|
-
const
|
|
477
|
-
const results = sessionQueries.searchGlobal(userId, data.query);
|
|
461
|
+
}, async ({ data }) => {
|
|
462
|
+
const results = sessionQueries.searchGlobal(data.query);
|
|
478
463
|
return {
|
|
479
464
|
sessions: results.map(r => ({ ...serializeSession(r), matchSnippet: r.matchSnippet }))
|
|
480
465
|
};
|
|
@@ -18,7 +18,7 @@ export const sessionsRouter = createRouter()
|
|
|
18
18
|
.emit('sessions:session-available', t.Object({
|
|
19
19
|
session: t.Any()
|
|
20
20
|
}))
|
|
21
|
-
// Notification: a session was deleted
|
|
21
|
+
// Notification: a session was deleted on another device
|
|
22
22
|
.emit('sessions:session-deleted', t.Object({
|
|
23
23
|
sessionId: t.String(),
|
|
24
24
|
projectId: t.String()
|
|
@@ -63,7 +63,7 @@ export const crudHandler = createRouter()
|
|
|
63
63
|
return setting;
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
// Merge-update system settings
|
|
66
|
+
// Merge-update system settings.
|
|
67
67
|
// Sending only the changed keys prevents a partial update from clobbering
|
|
68
68
|
// sibling fields (e.g. the onboarding marker) when a client's in-memory copy
|
|
69
69
|
// of the settings is stale. The merge itself lives in the system-settings
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
* - skills:adopt — link an adoptable on-disk skill into Clopen's engine dir
|
|
16
16
|
* - skills:available — slash-invocable skills for the chat "/" picker
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* take effect on the next chat stream, when each engine re-syncs its skills.
|
|
18
|
+
* Changes take effect on the next chat stream, when each engine re-syncs its
|
|
19
|
+
* skills.
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
import { t } from 'elysia';
|
|
@@ -207,7 +206,7 @@ export const skillCrudHandler = createRouter()
|
|
|
207
206
|
return { linkedTo };
|
|
208
207
|
})
|
|
209
208
|
.http('skills:available', {
|
|
210
|
-
//
|
|
209
|
+
// Slash-invocable skills for the chat "/" picker (display fields
|
|
211
210
|
// only), narrowed by the session's active profile same as stream sync.
|
|
212
211
|
data: t.Object({
|
|
213
212
|
profileId: t.Optional(t.Union([t.Number(), t.Null()])),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* covering model-invoked skills and user-invoked `/slash` prompts:
|
|
6
6
|
* - skills:list / get / create / update / import / toggle / delete — CRUD
|
|
7
7
|
* - skills:detect / adopt — on-disk skills, and linking one Clopen doesn't own
|
|
8
|
-
* - skills:available — the chat "/" picker
|
|
8
|
+
* - skills:available — the chat "/" picker
|
|
9
9
|
* - skills:catalog / install — browse + install from a marketplace provider
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
} from '../../database/queries';
|
|
30
30
|
import { loadMessage } from '$shared/utils/message-formatter';
|
|
31
31
|
import { blobStore } from '../../snapshot/blob-store';
|
|
32
|
+
import { blobLineStats } from '../../snapshot/line-stats';
|
|
32
33
|
import { snapshotService } from '../../snapshot/snapshot-service';
|
|
33
34
|
import { resolveSessionRoot } from '../../worktrees';
|
|
34
35
|
import { makeScopeKey } from '$shared/utils/workspace-scope';
|
|
@@ -139,11 +140,10 @@ export const changesHandler = createRouter()
|
|
|
139
140
|
/** Net over the whole active path — what the chat changed, not the sum of its turns. */
|
|
140
141
|
net: NET_SCHEMA
|
|
141
142
|
})
|
|
142
|
-
}, async ({ data
|
|
143
|
-
requireSessionAccess(
|
|
143
|
+
}, async ({ data }) => {
|
|
144
|
+
requireSessionAccess(data.sessionId);
|
|
144
145
|
|
|
145
146
|
const activePath = activeCheckpoints(data.sessionId);
|
|
146
|
-
const readBlob = (hash: string) => blobStore.readBlob(hash);
|
|
147
147
|
|
|
148
148
|
const turns = [];
|
|
149
149
|
const settled: SessionScopedChanges[] = [];
|
|
@@ -152,7 +152,7 @@ export const changesHandler = createRouter()
|
|
|
152
152
|
const snapshot = snapshotQueries.getByMessageId(checkpoint.id);
|
|
153
153
|
const changes = parseSessionChanges(snapshot?.session_changes);
|
|
154
154
|
settled.push(changes);
|
|
155
|
-
const files = await buildTurnFiles(changes,
|
|
155
|
+
const files = await buildTurnFiles(changes, blobLineStats);
|
|
156
156
|
|
|
157
157
|
turns.push({
|
|
158
158
|
checkpointMessageId: checkpoint.id,
|
|
@@ -166,7 +166,7 @@ export const changesHandler = createRouter()
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
const net = await summariseNetChanges(settled,
|
|
169
|
+
const net = await summariseNetChanges(settled, blobLineStats);
|
|
170
170
|
|
|
171
171
|
// Newest first: the turn a user wants to review is almost always the last
|
|
172
172
|
// one, and scrolling to reach it is a tax on the common case.
|
|
@@ -206,14 +206,14 @@ export const changesHandler = createRouter()
|
|
|
206
206
|
]),
|
|
207
207
|
isBinary: t.Boolean()
|
|
208
208
|
})
|
|
209
|
-
}, async ({ data
|
|
209
|
+
}, async ({ data }) => {
|
|
210
210
|
const unchanged = { before: null, after: null, status: 'unchanged' as const, isBinary: false };
|
|
211
211
|
|
|
212
212
|
const sessionId = data.messageId
|
|
213
|
-
? requireMessageAccess(
|
|
213
|
+
? requireMessageAccess(data.messageId).session_id
|
|
214
214
|
: data.sessionId;
|
|
215
215
|
if (!sessionId) return unchanged;
|
|
216
|
-
if (!data.messageId) requireSessionAccess(
|
|
216
|
+
if (!data.messageId) requireSessionAccess(sessionId);
|
|
217
217
|
|
|
218
218
|
const session = sessionQueries.getById(sessionId);
|
|
219
219
|
const root = resolveSessionRoot(sessionId)?.path
|
|
@@ -282,8 +282,8 @@ export const changesHandler = createRouter()
|
|
|
282
282
|
/** Net over the active path including the running turn; null when it adds nothing. */
|
|
283
283
|
net: t.Union([NET_SCHEMA, t.Null()])
|
|
284
284
|
})
|
|
285
|
-
}, async ({ data
|
|
286
|
-
requireSessionAccess(
|
|
285
|
+
}, async ({ data }) => {
|
|
286
|
+
requireSessionAccess(data.sessionId);
|
|
287
287
|
|
|
288
288
|
const session = sessionQueries.getById(data.sessionId);
|
|
289
289
|
if (!session) return { files: [], net: null };
|
|
@@ -300,12 +300,11 @@ export const changesHandler = createRouter()
|
|
|
300
300
|
);
|
|
301
301
|
if (Object.keys(changes).length === 0) return { files: [], net: null };
|
|
302
302
|
|
|
303
|
-
const
|
|
304
|
-
const files = await buildTurnFiles(changes, readBlob);
|
|
303
|
+
const files = await buildTurnFiles(changes, blobLineStats);
|
|
305
304
|
const settled = activeCheckpoints(data.sessionId).map((checkpoint) =>
|
|
306
305
|
parseSessionChanges(snapshotQueries.getByMessageId(checkpoint.id)?.session_changes)
|
|
307
306
|
);
|
|
308
|
-
const net = await summariseNetChanges([...settled, changes],
|
|
307
|
+
const net = await summariseNetChanges([...settled, changes], blobLineStats);
|
|
309
308
|
return { files, net };
|
|
310
309
|
} catch (error) {
|
|
311
310
|
debug.warn('snapshot', 'Failed to read pending changes:', error);
|