@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
|
@@ -86,6 +86,11 @@ export const PROVIDER_ICONS: Record<string, ToolIcon> = {
|
|
|
86
86
|
// Neon ships one logomark in two greens — #37C38F for a light background,
|
|
87
87
|
// #34D59A for a dark one — which is the pair, not a tint we chose.
|
|
88
88
|
neon: { light: '<svg width="24" height="24" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M63 0.0177909V63.5526L38.4178 42.2501V63.5526H0V0L63 0.0177909ZM7.72251 55.8389H30.6953V25.3238L55.2779 47.0476V7.72922L7.72251 7.71559V55.8389Z" fill="#37C38F"/></svg>', dark: '<svg width="24" height="24" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M63 0.0177909V63.5526L38.4178 42.2501V63.5526H0V0L63 0.0177909ZM7.72251 55.8389H30.6953V25.3238L55.2779 47.0476V7.72922L7.72251 7.71559V55.8389Z" fill="#34D59A"/></svg>' },
|
|
89
|
+
// Telegram's own logo from telegram.org: the gradient roundel with the paper
|
|
90
|
+
// plane. It is drawn for any background, so both variants are the same
|
|
91
|
+
// artwork; the gradient ids are namespaced because every inline copy of
|
|
92
|
+
// this SVG shares the document's id space.
|
|
93
|
+
telegram: { light: '<svg width="24" height="24" viewBox="0 0 240 240" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="clopen-telegram-a" x1=".667" x2=".417" y1=".167" y2=".75"><stop offset="0" stop-color="#37aee2"/><stop offset="1" stop-color="#1e96c8"/></linearGradient><linearGradient id="clopen-telegram-b" x1=".66" x2=".851" y1=".437" y2=".802"><stop offset="0" stop-color="#eff7fc"/><stop offset="1" stop-color="#fff"/></linearGradient></defs><circle cx="120" cy="120" r="120" fill="url(#clopen-telegram-a)"/><path fill="#c8daea" d="M98 175c-3.888 0-3.227-1.468-4.568-5.17L82 132.207 170 80"/><path fill="#a9c9dd" d="M98 175c3 0 4.325-1.372 6-3l16-15.558-19.958-12.035"/><path fill="url(#clopen-telegram-b)" d="M100.04 144.41l48.36 35.729c5.519 3.045 9.501 1.468 10.876-5.123l19.685-92.763c2.015-8.08-3.08-11.746-8.36-9.349l-115.59 44.571c-7.89 3.165-7.843 7.567-1.438 9.528l29.663 9.259 68.673-43.325c3.242-1.966 6.218-.91 3.776 1.258"/></svg>', dark: '<svg width="24" height="24" viewBox="0 0 240 240" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="clopen-telegram-a" x1=".667" x2=".417" y1=".167" y2=".75"><stop offset="0" stop-color="#37aee2"/><stop offset="1" stop-color="#1e96c8"/></linearGradient><linearGradient id="clopen-telegram-b" x1=".66" x2=".851" y1=".437" y2=".802"><stop offset="0" stop-color="#eff7fc"/><stop offset="1" stop-color="#fff"/></linearGradient></defs><circle cx="120" cy="120" r="120" fill="url(#clopen-telegram-a)"/><path fill="#c8daea" d="M98 175c-3.888 0-3.227-1.468-4.568-5.17L82 132.207 170 80"/><path fill="#a9c9dd" d="M98 175c3 0 4.325-1.372 6-3l16-15.558-19.958-12.035"/><path fill="url(#clopen-telegram-b)" d="M100.04 144.41l48.36 35.729c5.519 3.045 9.501 1.468 10.876-5.123l19.685-92.763c2.015-8.08-3.08-11.746-8.36-9.349l-115.59 44.571c-7.89 3.165-7.843 7.567-1.438 9.528l29.663 9.259 68.673-43.325c3.242-1.966 6.218-.91 3.776 1.258"/></svg>' },
|
|
89
94
|
github: { light: '<svg width="24" height="24" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#24292f"/></svg>', dark: '<svg width="24" height="24" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#ffffff"/></svg>' }
|
|
90
95
|
};
|
|
91
96
|
|
|
@@ -12,8 +12,15 @@ export interface Project {
|
|
|
12
12
|
created_at: string;
|
|
13
13
|
last_opened_at: string;
|
|
14
14
|
default_profile_id?: number | null; // Shared per-project default Profile (null = none)
|
|
15
|
+
/**
|
|
16
|
+
* `home` is the workspace for chatting with no project selected — one per
|
|
17
|
+
* install, never deleted. Everything else is `project`.
|
|
18
|
+
*/
|
|
19
|
+
kind?: ProjectKind;
|
|
15
20
|
}
|
|
16
21
|
|
|
22
|
+
export type ProjectKind = 'project' | 'home';
|
|
23
|
+
|
|
17
24
|
/** Isolation status of a worktree copy. */
|
|
18
25
|
export type WorktreeStatus = 'active' | 'applied' | 'archived';
|
|
19
26
|
|
|
@@ -65,8 +72,6 @@ export interface ChatSession {
|
|
|
65
72
|
head_summary?: string; // Last assistant response text at HEAD (truncated)
|
|
66
73
|
|
|
67
74
|
// ── Activity tracking (updated on each message) ──
|
|
68
|
-
sender_id?: string; // Last active user
|
|
69
|
-
sender_name?: string;
|
|
70
75
|
message_count?: number; // Total messages (all types)
|
|
71
76
|
user_count?: number; // User messages only
|
|
72
77
|
last_message_at?: string; // Timestamp of the latest message
|
|
@@ -228,7 +233,6 @@ export interface DBDbClientConnectionRow {
|
|
|
228
233
|
ssh_passphrase: string | null;
|
|
229
234
|
options_json: string | null;
|
|
230
235
|
color: string | null;
|
|
231
|
-
owner_user_id: string | null;
|
|
232
236
|
/** When set, the SSH tunnel settings come from this saved SSH connection. */
|
|
233
237
|
ssh_connection_id: string | null;
|
|
234
238
|
created_at: string;
|
|
@@ -253,7 +257,6 @@ export interface DBSshConnectionRow {
|
|
|
253
257
|
keepalive_seconds: number;
|
|
254
258
|
strict_host_key: number;
|
|
255
259
|
color: string | null;
|
|
256
|
-
owner_user_id: string | null;
|
|
257
260
|
created_at: string;
|
|
258
261
|
updated_at: string;
|
|
259
262
|
last_used_at: string | null;
|
|
@@ -283,13 +286,13 @@ export interface DBSshPortForwardRow {
|
|
|
283
286
|
updated_at: string;
|
|
284
287
|
}
|
|
285
288
|
|
|
286
|
-
/**
|
|
289
|
+
/** Where a collection lives: inside one project, or across all of them. */
|
|
287
290
|
export type NoteScope = 'project' | 'global';
|
|
288
291
|
|
|
289
292
|
export interface NoteCollection {
|
|
290
293
|
id: string;
|
|
291
294
|
name: string;
|
|
292
|
-
/** `project` —
|
|
295
|
+
/** `project` — belongs to `project_id`. `global` — shown in every project. */
|
|
293
296
|
scope: NoteScope;
|
|
294
297
|
/** Set when `scope` is `project`, null when `scope` is `global`. */
|
|
295
298
|
project_id: string | null;
|
|
@@ -95,7 +95,7 @@ export interface GitIdentityInput {
|
|
|
95
95
|
*/
|
|
96
96
|
export interface ResolvedGitIdentity {
|
|
97
97
|
identity: GitIdentityDTO | null;
|
|
98
|
-
source: 'project' | '
|
|
98
|
+
source: 'project' | 'default' | 'none';
|
|
99
99
|
/**
|
|
100
100
|
* The identity supplying credentials for a given remote host, when the
|
|
101
101
|
* project's own identity does not claim that host. Null when the project
|
package/shared/types/git.ts
CHANGED
|
@@ -78,6 +78,10 @@ export interface GitBranchInfo {
|
|
|
78
78
|
operation?: GitOperation | null;
|
|
79
79
|
/** Nested git repos / submodules under this project */
|
|
80
80
|
nested?: GitNestedRepoInfo[];
|
|
81
|
+
/** The repo declares submodules (`.gitmodules` exists). */
|
|
82
|
+
hasSubmodules?: boolean;
|
|
83
|
+
/** The repo root has a `package.json`, so `npm version` can run. */
|
|
84
|
+
hasPackageJson?: boolean;
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
/**
|
|
@@ -352,3 +356,115 @@ export interface GeneratedCommitMessage {
|
|
|
352
356
|
export interface GeneratedBranchName {
|
|
353
357
|
description: string;
|
|
354
358
|
}
|
|
359
|
+
|
|
360
|
+
// ============================================
|
|
361
|
+
// Operation lock / sync types
|
|
362
|
+
// ============================================
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* What a running git operation is doing, in the terms the panel's buttons use.
|
|
366
|
+
* Each category drives one busy flag on the client, so a pull started anywhere
|
|
367
|
+
* — another tab, another device — spins every Pull button that can see it.
|
|
368
|
+
*/
|
|
369
|
+
export type GitOpCategory =
|
|
370
|
+
| 'commit'
|
|
371
|
+
| 'staging'
|
|
372
|
+
| 'push'
|
|
373
|
+
| 'pull'
|
|
374
|
+
| 'fetch'
|
|
375
|
+
| 'more'
|
|
376
|
+
| 'stash'
|
|
377
|
+
| 'tag'
|
|
378
|
+
| 'branch'
|
|
379
|
+
| 'resolve'
|
|
380
|
+
| 'configure';
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Which operations may overlap in one repository.
|
|
384
|
+
*
|
|
385
|
+
* - `exclusive` moves HEAD, the index or the working tree; it runs alone.
|
|
386
|
+
* - `network` talks to a remote and only writes remote-tracking refs, so the
|
|
387
|
+
* index stays free for staging while a long push or fetch runs.
|
|
388
|
+
* - `index` writes the index only (stage, unstage, discard).
|
|
389
|
+
*
|
|
390
|
+
* Two operations conflict when either is exclusive or both share a class.
|
|
391
|
+
*/
|
|
392
|
+
export type GitOpClass = 'exclusive' | 'network' | 'index';
|
|
393
|
+
|
|
394
|
+
export interface GitActiveOp {
|
|
395
|
+
id: string;
|
|
396
|
+
category: GitOpCategory;
|
|
397
|
+
cls: GitOpClass;
|
|
398
|
+
/** Human label, e.g. "Pull" or "Force push". */
|
|
399
|
+
label: string;
|
|
400
|
+
/** Branch, remote or tag the operation is aimed at, when it has one. */
|
|
401
|
+
target?: string;
|
|
402
|
+
startedAt: number;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Every operation running in one repository of one workspace. */
|
|
406
|
+
export interface GitRepoOpState {
|
|
407
|
+
/** Workspace scope key (project, or project + worktree). */
|
|
408
|
+
scope: string;
|
|
409
|
+
/** Absolute path of a nested repo; absent for the workspace's own repo. */
|
|
410
|
+
repoPath?: string;
|
|
411
|
+
ops: GitActiveOp[];
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** How a pull reconciles local and remote history. */
|
|
415
|
+
export type GitPullMode = 'default' | 'merge' | 'rebase' | 'ff-only';
|
|
416
|
+
|
|
417
|
+
export interface GitPullResult {
|
|
418
|
+
success: boolean;
|
|
419
|
+
message: string;
|
|
420
|
+
/**
|
|
421
|
+
* Why a pull did not complete, when git said something the panel can act on:
|
|
422
|
+
* `diverged` — both sides have commits and no reconcile strategy is set;
|
|
423
|
+
* `conflict` — the merge or rebase stopped on conflicts;
|
|
424
|
+
* `local-changes` — uncommitted work would be overwritten.
|
|
425
|
+
*/
|
|
426
|
+
reason?: 'diverged' | 'conflict' | 'local-changes';
|
|
427
|
+
/** Local commits the remote does not have (set with `diverged`). */
|
|
428
|
+
ahead?: number;
|
|
429
|
+
/** Remote commits the local branch does not have (set with `diverged`). */
|
|
430
|
+
behind?: number;
|
|
431
|
+
/** Commits HEAD actually moved forward by, measured before and after. */
|
|
432
|
+
pulledCount?: number;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface GitForcePullPreview {
|
|
436
|
+
/** `<remote>/<branch>` or the URL-tracked equivalent the reset will land on. */
|
|
437
|
+
target: string;
|
|
438
|
+
/** Local commits that will no longer be on the branch. */
|
|
439
|
+
localCommits: number;
|
|
440
|
+
/** Remote commits that will arrive. */
|
|
441
|
+
incomingCommits: number;
|
|
442
|
+
/** Tracked files with uncommitted changes (they will be stashed). */
|
|
443
|
+
changedFiles: number;
|
|
444
|
+
/** Untracked files the remote tree would overwrite (they will be stashed). */
|
|
445
|
+
collidingUntracked: string[];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface GitForcePullResult {
|
|
449
|
+
previousHead: string;
|
|
450
|
+
newHead: string;
|
|
451
|
+
discardedCommits: number;
|
|
452
|
+
/** Message of the safety stash, when one was created. */
|
|
453
|
+
stashMessage?: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export interface GitPruneCandidate {
|
|
457
|
+
name: string;
|
|
458
|
+
/** Whether the branch is fully merged into the default branch. */
|
|
459
|
+
merged: boolean;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface GitLockStatus {
|
|
463
|
+
exists: boolean;
|
|
464
|
+
/** Milliseconds since the lock file was last written. */
|
|
465
|
+
ageMs: number;
|
|
466
|
+
/** A git operation started by Clopen is still running in this project. */
|
|
467
|
+
clopenOpRunning: boolean;
|
|
468
|
+
/** Safe to offer removal: old enough and nothing of ours holds it. */
|
|
469
|
+
removable: boolean;
|
|
470
|
+
}
|
|
@@ -23,6 +23,13 @@ export const INTEGRATION_CAPABILITIES = [
|
|
|
23
23
|
'database',
|
|
24
24
|
'worktree-branching',
|
|
25
25
|
'notifications',
|
|
26
|
+
/**
|
|
27
|
+
* Control Clopen from a chat app — sessions, projects, models, engine
|
|
28
|
+
* accounts, MCP servers, skills and the rest of the control catalog
|
|
29
|
+
* (`backend/control/`), with questions and finished runs reported back to
|
|
30
|
+
* the chat. Distinct from `notifications`, which only sends.
|
|
31
|
+
*/
|
|
32
|
+
'control',
|
|
26
33
|
'inbound-events'
|
|
27
34
|
] as const;
|
|
28
35
|
|
|
@@ -101,7 +101,7 @@ export interface AppSettings {
|
|
|
101
101
|
/** Authentication mode */
|
|
102
102
|
export type AuthMode = 'none' | 'required';
|
|
103
103
|
|
|
104
|
-
/** System-wide settings
|
|
104
|
+
/** System-wide settings, shared by every device */
|
|
105
105
|
export interface SystemSettings {
|
|
106
106
|
/** Authentication mode: 'none' = single user no login, 'required' = multi-user with login. Default: 'required'. */
|
|
107
107
|
authMode: AuthMode;
|
|
@@ -100,6 +100,7 @@ export { toMcpServerStatus } from './stream';
|
|
|
100
100
|
export type {
|
|
101
101
|
SubAgentToolActivity,
|
|
102
102
|
SubAgentTextActivity,
|
|
103
|
+
SubAgentReasoningActivity,
|
|
103
104
|
SubAgentActivity,
|
|
104
105
|
ToolResult,
|
|
105
106
|
McpToolUseBlock,
|
|
@@ -113,7 +114,6 @@ export type {
|
|
|
113
114
|
MessageEngine,
|
|
114
115
|
MessageModel,
|
|
115
116
|
MessageParent,
|
|
116
|
-
MessageSender,
|
|
117
117
|
MessageAccount,
|
|
118
118
|
TextBlock,
|
|
119
119
|
ImageBlock,
|
|
@@ -12,12 +12,6 @@ import type { ToolUseBlock, ToolResult } from './tool';
|
|
|
12
12
|
// Message Base
|
|
13
13
|
// ============================================================
|
|
14
14
|
|
|
15
|
-
/** Sender identity attached to every message */
|
|
16
|
-
export interface MessageSender {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
15
|
/** Engine account identity attached to every message */
|
|
22
16
|
export interface MessageAccount {
|
|
23
17
|
id: number;
|
|
@@ -106,7 +100,6 @@ export type AssistantContentBlock =
|
|
|
106
100
|
*/
|
|
107
101
|
export interface UserMessage extends MessageBase {
|
|
108
102
|
type: 'user';
|
|
109
|
-
sender: MessageSender;
|
|
110
103
|
content: UserContentBlock[];
|
|
111
104
|
synthetic: boolean;
|
|
112
105
|
}
|
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
CompactBoundaryMessage,
|
|
17
17
|
UnifiedMessage,
|
|
18
18
|
MessageEngine,
|
|
19
|
-
MessageSender,
|
|
20
19
|
} from './message';
|
|
21
20
|
|
|
22
21
|
// ============================================================
|
|
@@ -218,11 +217,10 @@ export interface StreamRequest {
|
|
|
218
217
|
chatSessionId: string;
|
|
219
218
|
prompt: UserMessage;
|
|
220
219
|
engine: MessageEngine;
|
|
221
|
-
sender: MessageSender;
|
|
222
220
|
/**
|
|
223
221
|
* Server-trusted id of the user who started the stream (from the WS
|
|
224
|
-
* connection
|
|
225
|
-
*
|
|
222
|
+
* connection). Used to route Web Push notifications to their devices when
|
|
223
|
+
* Chrome is closed.
|
|
226
224
|
* Absent for streams started before this field existed.
|
|
227
225
|
*/
|
|
228
226
|
requestedByUserId?: string;
|
|
@@ -447,9 +447,16 @@ export interface SubAgentTextActivity {
|
|
|
447
447
|
text: string;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
+
/** The sub-agent's own thinking — rendered inside its parent tool, never at root. */
|
|
451
|
+
export interface SubAgentReasoningActivity {
|
|
452
|
+
type: 'reasoning';
|
|
453
|
+
text: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
450
456
|
export type SubAgentActivity =
|
|
451
457
|
| SubAgentToolActivity
|
|
452
|
-
| SubAgentTextActivity
|
|
458
|
+
| SubAgentTextActivity
|
|
459
|
+
| SubAgentReasoningActivity;
|
|
453
460
|
|
|
454
461
|
// ============================================================
|
|
455
462
|
// Tool Result
|
|
@@ -461,6 +468,13 @@ export interface ToolResult {
|
|
|
461
468
|
toolUseId: string;
|
|
462
469
|
content: string;
|
|
463
470
|
isError: boolean;
|
|
471
|
+
/**
|
|
472
|
+
* AskUserQuestion only: the answers the user submitted, keyed by question
|
|
473
|
+
* text, attached by the stream manager. `content` is the engine's prose for
|
|
474
|
+
* the model and is worded differently by every engine, so the UI reads this
|
|
475
|
+
* instead. Absent on results saved before it existed.
|
|
476
|
+
*/
|
|
477
|
+
answers?: Record<string, string>;
|
|
464
478
|
}
|
|
465
479
|
|
|
466
480
|
// ============================================================
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import type { ToolResult, UserMessage } from '$shared/types/unified';
|
|
3
|
+
import { attachSubmittedAnswers, parseAskUserQuestionAnswers, readAskUserQuestionAnswers } from './ask-user-question';
|
|
4
|
+
|
|
5
|
+
type Answers = Record<string, string>;
|
|
6
|
+
type Question = { question: string };
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Byte-for-byte replicas of what each engine sends back. Kept in sync with
|
|
10
|
+
* the engines' own templates so the parser is exercised on real output.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Claude Code: answered pairs only (empty answers are omitted), several closings.
|
|
14
|
+
const claude = {
|
|
15
|
+
answered: (qs: Question[], a: Answers) =>
|
|
16
|
+
`Your questions have been answered: ${claudePairs(qs, a)}. You can now continue with these answers in mind.`,
|
|
17
|
+
freeText: (qs: Question[], a: Answers) =>
|
|
18
|
+
`The user answered: ${claudePairs(qs, a)}. Read the answers carefully — they may request clarification, changes, or that you not proceed — and follow what they actually say.`,
|
|
19
|
+
followUp: (qs: Question[], a: Answers) =>
|
|
20
|
+
`The user wants to discuss this further before you proceed. So far they answered: ${claudePairs(qs, a)}. Call AskUserQuestion again with follow-up questions that build on these answers (do not repeat these); do not start the task yet.`,
|
|
21
|
+
followUpWithNote: (qs: Question[], a: Answers) =>
|
|
22
|
+
`The user wants to discuss this further before you proceed. So far they answered: ${claudePairs(qs, a)}. They also wrote: "Ask about "auth". Then billing.". Call AskUserQuestion again with follow-up questions that build on these answers (do not repeat these); do not start the task yet.`,
|
|
23
|
+
afk: (qs: Question[], a: Answers) =>
|
|
24
|
+
`The user did not respond within 5 minutes.\n\nBefore going idle the user had selected: ${claudePairs(qs, a)}.`
|
|
25
|
+
};
|
|
26
|
+
function claudePairs(qs: Question[], a: Answers): string {
|
|
27
|
+
return qs.filter(({ question }) => a[question]).map(({ question }) => `"${question}"="${a[question]}"`).join(', ');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// OpenCode: every question, unanswered ones as "Unanswered".
|
|
31
|
+
const opencode = (qs: Question[], a: Answers) =>
|
|
32
|
+
`User has answered your questions: ${qs.map(({ question }) => `"${question}"="${a[question] || 'Unanswered'}"`).join(', ')}. You can now continue with the user's answers in mind.`;
|
|
33
|
+
|
|
34
|
+
// Clopen's own adapters (Cline, Cursor, Pi, Qwen): every submitted answer.
|
|
35
|
+
const clopen = (qs: Question[], a: Answers) =>
|
|
36
|
+
`User has answered your questions: ${qs.map(({ question }) => `"${question}"="${a[question]}"`).join(', ')}. You can now continue with the user's answers in mind.`;
|
|
37
|
+
|
|
38
|
+
// An engine this parser has never heard of, with a quote-free closing.
|
|
39
|
+
const unknownEngine = (qs: Question[], a: Answers) =>
|
|
40
|
+
`Answers: ${claudePairs(qs, a)}. Proceed with care.`;
|
|
41
|
+
|
|
42
|
+
const FORMATTERS = {
|
|
43
|
+
'claude/answered': claude.answered,
|
|
44
|
+
'claude/free-text': claude.freeText,
|
|
45
|
+
'claude/follow-up': claude.followUp,
|
|
46
|
+
'claude/follow-up with note': claude.followUpWithNote,
|
|
47
|
+
'claude/afk': claude.afk,
|
|
48
|
+
opencode,
|
|
49
|
+
'clopen adapters': clopen,
|
|
50
|
+
'unknown engine': unknownEngine
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const WEIRD_ANSWERS: string[] = [
|
|
54
|
+
'Yes',
|
|
55
|
+
'Do everything at once',
|
|
56
|
+
'Option A, Option B',
|
|
57
|
+
'Say "hi"',
|
|
58
|
+
'"quoted from the start',
|
|
59
|
+
'ends with a quote"',
|
|
60
|
+
'"fully quoted"',
|
|
61
|
+
'Say "hi". Then stop',
|
|
62
|
+
'Ends with a sentence.',
|
|
63
|
+
'Ends with "x".',
|
|
64
|
+
'...',
|
|
65
|
+
'"."',
|
|
66
|
+
'". ',
|
|
67
|
+
'a"="b',
|
|
68
|
+
'"Which scope?"="Some"',
|
|
69
|
+
'=',
|
|
70
|
+
'"',
|
|
71
|
+
'""',
|
|
72
|
+
'x", y',
|
|
73
|
+
'. You can now continue with the user\'s answers in mind.',
|
|
74
|
+
'. Read the answers carefully — they may request clarification, changes, or that you not proceed — and follow what they actually say.',
|
|
75
|
+
'. Call AskUserQuestion again with follow-up questions that build on these answers (do not repeat these); do not start the task yet.',
|
|
76
|
+
'They also wrote: "x". Call me',
|
|
77
|
+
'Line one\nLine two\n\nLine four',
|
|
78
|
+
'Windows\r\nline',
|
|
79
|
+
'\ttabbed\t',
|
|
80
|
+
' padded ',
|
|
81
|
+
'kerjakan semuanya sekaligus tanpa stop',
|
|
82
|
+
'日本語の回答、そして中文',
|
|
83
|
+
'שלום עולם',
|
|
84
|
+
'emoji 🚀👍🏽 family 👨👩👧',
|
|
85
|
+
'zerowidth',
|
|
86
|
+
'back\\slash \\" escaped',
|
|
87
|
+
'$& $1 $$ replacement tokens',
|
|
88
|
+
'<script>alert(1)</script>',
|
|
89
|
+
'**markdown** `code` [link](http://x)',
|
|
90
|
+
'{"answers":{"Which scope?":"hijack"}}',
|
|
91
|
+
'null',
|
|
92
|
+
'Unanswered',
|
|
93
|
+
'x'.repeat(10_000)
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const QUESTION_SETS: Question[][] = [
|
|
97
|
+
[{ question: 'Which scope?' }],
|
|
98
|
+
[{ question: 'Which scope?' }, { question: 'Which approach?' }],
|
|
99
|
+
[{ question: 'Use "strict" mode?' }, { question: 'Name = value?' }, { question: 'Deploy 🚀?' }],
|
|
100
|
+
// One question text contained in another
|
|
101
|
+
[{ question: 'Name?' }, { question: 'Project Name?' }],
|
|
102
|
+
// Indonesian, as in the original report
|
|
103
|
+
[{ question: 'Bagaimana saya boleh melanjutkan?' }, { question: 'Sambil menunggu akun, bagian mana yang saya kerjakan dulu?' }]
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/** An answer containing `", "<a later question>"=` is the one shape engine output cannot disambiguate. */
|
|
107
|
+
function isInherentlyAmbiguous(qs: Question[], answers: Answers): boolean {
|
|
108
|
+
return qs.some(({ question }, i) => qs.slice(i + 1).some((later) => answers[question]?.includes(`", "${later.question}"=`)));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
describe('parseAskUserQuestionAnswers — every engine × weird answers', () => {
|
|
112
|
+
for (const [engine, format] of Object.entries(FORMATTERS)) {
|
|
113
|
+
test(engine, () => {
|
|
114
|
+
const failures: string[] = [];
|
|
115
|
+
for (const qs of QUESTION_SETS) {
|
|
116
|
+
for (let w = 0; w < WEIRD_ANSWERS.length; w++) {
|
|
117
|
+
// Rotate the weird answers across positions so each one is
|
|
118
|
+
// tested as the first, a middle and the last answer.
|
|
119
|
+
const answers: Answers = {};
|
|
120
|
+
qs.forEach(({ question }, i) => {
|
|
121
|
+
answers[question] = WEIRD_ANSWERS[(w + i) % WEIRD_ANSWERS.length];
|
|
122
|
+
});
|
|
123
|
+
if (isInherentlyAmbiguous(qs, answers)) continue;
|
|
124
|
+
|
|
125
|
+
const content = format(qs, answers);
|
|
126
|
+
const parsed = parseAskUserQuestionAnswers(content, qs);
|
|
127
|
+
for (const { question } of qs) {
|
|
128
|
+
const expected = answers[question];
|
|
129
|
+
if (parsed[question] !== expected) {
|
|
130
|
+
failures.push(`${JSON.stringify(question)}: expected ${JSON.stringify(expected).slice(0, 80)}, got ${JSON.stringify(parsed[question]).slice(0, 80)}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
expect(failures).toEqual([]);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('parseAskUserQuestionAnswers', () => {
|
|
141
|
+
const qs = [{ question: 'Which scope?' }, { question: 'Which approach?' }];
|
|
142
|
+
|
|
143
|
+
test('drops the Claude Code closing from the reported answer', () => {
|
|
144
|
+
const content = claude.freeText(qs, { 'Which scope?': 'Some', 'Which approach?': 'kerjakan semuanya sekaligus tanpa stop' });
|
|
145
|
+
expect(parseAskUserQuestionAnswers(content, qs)).toEqual({
|
|
146
|
+
'Which scope?': 'Some',
|
|
147
|
+
'Which approach?': 'kerjakan semuanya sekaligus tanpa stop'
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('skips a question Claude omitted because it was left empty', () => {
|
|
152
|
+
const three = [...qs, { question: 'Which name?' }];
|
|
153
|
+
const content = claude.answered(three, { 'Which scope?': 'Some', 'Which approach?': '', 'Which name?': 'Foo' });
|
|
154
|
+
expect(parseAskUserQuestionAnswers(content, three)).toEqual({ 'Which scope?': 'Some', 'Which name?': 'Foo' });
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('reports OpenCode\'s own placeholder for an unanswered question verbatim', () => {
|
|
158
|
+
const content = opencode(qs, { 'Which scope?': 'Some' });
|
|
159
|
+
expect(parseAskUserQuestionAnswers(content, qs)).toEqual({ 'Which scope?': 'Some', 'Which approach?': 'Unanswered' });
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('an unknown closing that itself quotes is indistinguishable from the answer', () => {
|
|
163
|
+
// Documents the limit of the fallback: without knowing the closing,
|
|
164
|
+
// `"Bold". Go, "now".` reads the same as an answer ending in `". Go, "now`.
|
|
165
|
+
const content = '"Which scope?"="Bold". Go, "now".';
|
|
166
|
+
expect(parseAskUserQuestionAnswers(content, qs)).toEqual({ 'Which scope?': 'Bold". Go, "now' });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('handles a result with no closing at all', () => {
|
|
170
|
+
expect(parseAskUserQuestionAnswers('"Which scope?"="Some"', qs)).toEqual({ 'Which scope?': 'Some' });
|
|
171
|
+
expect(parseAskUserQuestionAnswers('"Which scope?"="Some".', qs)).toEqual({ 'Which scope?': 'Some' });
|
|
172
|
+
expect(parseAskUserQuestionAnswers('"Which scope?"="Some" \n', qs)).toEqual({ 'Which scope?': 'Some' });
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('reads the JSON answers shape, coercing non-string values', () => {
|
|
176
|
+
expect(parseAskUserQuestionAnswers('{"answers":{"Which scope?":"Some"}}', qs)).toEqual({ 'Which scope?': 'Some' });
|
|
177
|
+
expect(parseAskUserQuestionAnswers('{"answers":{"Which scope?":["A","B"],"Which approach?":3}}', qs))
|
|
178
|
+
.toEqual({ 'Which scope?': 'A, B', 'Which approach?': '3' });
|
|
179
|
+
expect(parseAskUserQuestionAnswers('{"answers":{"Which scope?":null}}', qs)).toEqual({});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('ignores JSON that is not an answers object', () => {
|
|
183
|
+
expect(parseAskUserQuestionAnswers('{"answers":["Some"]}', qs)).toEqual({});
|
|
184
|
+
expect(parseAskUserQuestionAnswers('null', qs)).toEqual({});
|
|
185
|
+
expect(parseAskUserQuestionAnswers('"Which scope?"', qs)).toEqual({});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('returns nothing for results without answers', () => {
|
|
189
|
+
expect(parseAskUserQuestionAnswers('Error: questions is required', qs)).toEqual({});
|
|
190
|
+
expect(parseAskUserQuestionAnswers('The user did not answer the questions.', qs)).toEqual({});
|
|
191
|
+
expect(parseAskUserQuestionAnswers('The user responded: just do it', qs)).toEqual({});
|
|
192
|
+
expect(parseAskUserQuestionAnswers('', qs)).toEqual({});
|
|
193
|
+
expect(parseAskUserQuestionAnswers('"Which scope?"="Some"', [])).toEqual({});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('does not hang on very large results', () => {
|
|
197
|
+
const huge = 'a'.repeat(1_000_000);
|
|
198
|
+
const started = performance.now();
|
|
199
|
+
expect(parseAskUserQuestionAnswers(claude.freeText(qs, { 'Which scope?': huge }), qs)).toEqual({ 'Which scope?': huge });
|
|
200
|
+
expect(parseAskUserQuestionAnswers(`"Which scope?"="${huge}`, qs)).toEqual({ 'Which scope?': huge });
|
|
201
|
+
expect(performance.now() - started).toBeLessThan(1000);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
function toolResult(toolUseId: string, content: string, isError = false): ToolResult {
|
|
206
|
+
return { type: 'tool_result', toolUseId, content, isError };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function userMessage(...content: UserMessage['content']): UserMessage {
|
|
210
|
+
return { type: 'user', content, synthetic: false } as UserMessage;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
describe('attachSubmittedAnswers → readAskUserQuestionAnswers (every engine × weird answers)', () => {
|
|
214
|
+
for (const [engine, format] of Object.entries(FORMATTERS)) {
|
|
215
|
+
test(engine, () => {
|
|
216
|
+
const failures: string[] = [];
|
|
217
|
+
for (const qs of QUESTION_SETS) {
|
|
218
|
+
for (let w = 0; w < WEIRD_ANSWERS.length; w++) {
|
|
219
|
+
const answers: Answers = {};
|
|
220
|
+
qs.forEach(({ question }, i) => {
|
|
221
|
+
answers[question] = WEIRD_ANSWERS[(w + i) % WEIRD_ANSWERS.length];
|
|
222
|
+
});
|
|
223
|
+
// No ambiguity carve-out: the structured path never reads the prose.
|
|
224
|
+
const message = userMessage(toolResult('call-1', format(qs, answers)));
|
|
225
|
+
attachSubmittedAnswers(message, new Map([['call-1', { ...answers }]]));
|
|
226
|
+
|
|
227
|
+
// Round-trip as the DB and the WS do, then read as the UI does.
|
|
228
|
+
const stored = JSON.parse(JSON.stringify(message)) as UserMessage;
|
|
229
|
+
const block = stored.content[0] as ToolResult;
|
|
230
|
+
const read = readAskUserQuestionAnswers(block, qs);
|
|
231
|
+
if (JSON.stringify(read) !== JSON.stringify(answers)) {
|
|
232
|
+
failures.push(`${JSON.stringify(answers).slice(0, 120)} → ${JSON.stringify(read).slice(0, 120)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
expect(failures).toEqual([]);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('attachSubmittedAnswers', () => {
|
|
242
|
+
const answers = { 'Which scope?': 'Some' };
|
|
243
|
+
|
|
244
|
+
test('attaches only to the matching tool_result and consumes the entry', () => {
|
|
245
|
+
const submitted = new Map([['call-1', answers]]);
|
|
246
|
+
const other = toolResult('call-2', 'unrelated');
|
|
247
|
+
const match = toolResult('call-1', 'engine prose');
|
|
248
|
+
const message = userMessage({ type: 'text', text: 'hi' }, other, match);
|
|
249
|
+
|
|
250
|
+
attachSubmittedAnswers(message, submitted);
|
|
251
|
+
|
|
252
|
+
expect(match.answers).toEqual(answers);
|
|
253
|
+
expect(match.content).toBe('engine prose');
|
|
254
|
+
expect(other.answers).toBeUndefined();
|
|
255
|
+
expect(submitted.size).toBe(0);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('leaves an error result unanswered but still consumes the entry', () => {
|
|
259
|
+
const submitted = new Map([['call-1', answers]]);
|
|
260
|
+
const rejected = toolResult('call-1', 'Error: questions is required', true);
|
|
261
|
+
|
|
262
|
+
attachSubmittedAnswers(userMessage(rejected), submitted);
|
|
263
|
+
|
|
264
|
+
expect(rejected.answers).toBeUndefined();
|
|
265
|
+
expect(submitted.size).toBe(0);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('keeps answers for a question whose result has not arrived yet', () => {
|
|
269
|
+
const submitted = new Map([['call-1', answers], ['call-9', { 'Later?': 'Yes' }]]);
|
|
270
|
+
attachSubmittedAnswers(userMessage(toolResult('call-1', 'x')), submitted);
|
|
271
|
+
expect([...submitted.keys()]).toEqual(['call-9']);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test('attaches each of several questions answered in one message', () => {
|
|
275
|
+
const a = toolResult('call-1', 'x');
|
|
276
|
+
const b = toolResult('call-2', 'y');
|
|
277
|
+
attachSubmittedAnswers(userMessage(a, b), new Map([['call-1', { Q1: 'A' }], ['call-2', { Q2: 'B' }]]));
|
|
278
|
+
expect(a.answers).toEqual({ Q1: 'A' });
|
|
279
|
+
expect(b.answers).toEqual({ Q2: 'B' });
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('does nothing without submitted answers', () => {
|
|
283
|
+
const block = toolResult('call-1', 'x');
|
|
284
|
+
attachSubmittedAnswers(userMessage(block), new Map());
|
|
285
|
+
expect(block.answers).toBeUndefined();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test('treats tool_use ids as opaque strings', () => {
|
|
289
|
+
const ids = ['toolu_01AbC', 'call_9f8e', 'copilot-ask-user-6b1f', '', ' ', 'id with "quotes" and 🚀', '__proto__', 'constructor'];
|
|
290
|
+
for (const id of ids) {
|
|
291
|
+
const block = toolResult(id, 'x');
|
|
292
|
+
attachSubmittedAnswers(userMessage(block), new Map([[id, { Q: id }]]));
|
|
293
|
+
expect(block.answers).toEqual({ Q: id });
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('readAskUserQuestionAnswers', () => {
|
|
299
|
+
const qs = [{ question: 'Which scope?' }, { question: 'Which approach?' }];
|
|
300
|
+
|
|
301
|
+
test('prefers attached answers over anything the prose says', () => {
|
|
302
|
+
const content = claude.freeText(qs, { 'Which scope?': 'From prose' });
|
|
303
|
+
expect(readAskUserQuestionAnswers({ content, answers: { 'Which scope?': 'Submitted' } }, qs))
|
|
304
|
+
.toEqual({ 'Which scope?': 'Submitted' });
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('falls back to the prose for results saved before answers were attached', () => {
|
|
308
|
+
const content = claude.freeText(qs, { 'Which scope?': 'Some', 'Which approach?': 'kerjakan semuanya sekaligus tanpa stop' });
|
|
309
|
+
expect(readAskUserQuestionAnswers({ content }, qs)).toEqual({
|
|
310
|
+
'Which scope?': 'Some',
|
|
311
|
+
'Which approach?': 'kerjakan semuanya sekaligus tanpa stop'
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test('keeps attached answers verbatim, including empty and question-keyed oddities', () => {
|
|
316
|
+
const attached = { 'Which scope?': '', 'Which approach?': '", "Which scope?"="spoof', 'Not asked?': 'extra' };
|
|
317
|
+
expect(readAskUserQuestionAnswers({ content: '', answers: attached }, qs)).toEqual(attached);
|
|
318
|
+
});
|
|
319
|
+
});
|