@myrialabs/clopen 0.2.16 → 0.2.17
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/.env.example +4 -4
- package/backend/utils/env.ts +5 -5
- package/bin/clopen.ts +21 -298
- package/dist/assets/addon-clipboard-wHJhZAA4.js +1 -0
- package/dist/assets/addon-fit-DX4qG4td.js +1 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js +2 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js +7 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js +1 -0
- package/dist/assets/index-C-eR9PGW.js +2 -0
- package/dist/assets/main-D1IISCsM.js +247 -0
- package/dist/assets/main-DzSwlujO.css +1 -0
- package/dist/assets/xterm-B-qIQCd3.js +16 -0
- package/{index.html → dist/index.html} +2 -1
- package/package.json +11 -2
- package/scripts/start.ts +3 -3
- package/shared/utils/logger.ts +1 -1
- package/.dockerignore +0 -5
- package/.github/workflows/ci.yml +0 -86
- package/CONTRIBUTING.md +0 -188
- package/bun.lock +0 -1127
- package/docker-compose.yml +0 -31
- package/frontend/App.svelte +0 -77
- package/frontend/app-environment.ts +0 -10
- package/frontend/app.css +0 -313
- package/frontend/components/auth/InvitePage.svelte +0 -215
- package/frontend/components/auth/LoginPage.svelte +0 -129
- package/frontend/components/auth/SetupPage.svelte +0 -1054
- package/frontend/components/chat/ChatInterface.svelte +0 -426
- package/frontend/components/chat/formatters/ErrorMessage.svelte +0 -57
- package/frontend/components/chat/formatters/MessageFormatter.svelte +0 -244
- package/frontend/components/chat/formatters/TextMessage.svelte +0 -383
- package/frontend/components/chat/formatters/Tools.svelte +0 -79
- package/frontend/components/chat/formatters/index.ts +0 -3
- package/frontend/components/chat/input/ChatInput.svelte +0 -492
- package/frontend/components/chat/input/components/ChatInputActions.svelte +0 -88
- package/frontend/components/chat/input/components/DragDropOverlay.svelte +0 -30
- package/frontend/components/chat/input/components/EditModeIndicator.svelte +0 -33
- package/frontend/components/chat/input/components/EngineModelPicker.svelte +0 -642
- package/frontend/components/chat/input/components/FileAttachmentPreview.svelte +0 -48
- package/frontend/components/chat/input/components/LoadingIndicator.svelte +0 -43
- package/frontend/components/chat/input/composables/use-animations.svelte.ts +0 -217
- package/frontend/components/chat/input/composables/use-chat-actions.svelte.ts +0 -152
- package/frontend/components/chat/input/composables/use-file-handling.svelte.ts +0 -216
- package/frontend/components/chat/input/composables/use-input-state.svelte.ts +0 -357
- package/frontend/components/chat/input/composables/use-textarea-resize.svelte.ts +0 -69
- package/frontend/components/chat/message/ChatMessage.svelte +0 -509
- package/frontend/components/chat/message/ChatMessages.svelte +0 -553
- package/frontend/components/chat/message/DateSeparator.svelte +0 -86
- package/frontend/components/chat/message/MessageBubble.svelte +0 -114
- package/frontend/components/chat/message/MessageHeader.svelte +0 -143
- package/frontend/components/chat/modal/DebugModal.svelte +0 -59
- package/frontend/components/chat/shared/index.ts +0 -2
- package/frontend/components/chat/shared/utils.ts +0 -116
- package/frontend/components/chat/tools/AgentTool.svelte +0 -96
- package/frontend/components/chat/tools/AskUserQuestionTool.svelte +0 -391
- package/frontend/components/chat/tools/BashOutputTool.svelte +0 -35
- package/frontend/components/chat/tools/BashTool.svelte +0 -51
- package/frontend/components/chat/tools/CustomMcpTool.svelte +0 -141
- package/frontend/components/chat/tools/EditTool.svelte +0 -48
- package/frontend/components/chat/tools/EnterPlanModeTool.svelte +0 -24
- package/frontend/components/chat/tools/ExitPlanModeTool.svelte +0 -29
- package/frontend/components/chat/tools/GlobTool.svelte +0 -51
- package/frontend/components/chat/tools/GrepTool.svelte +0 -90
- package/frontend/components/chat/tools/ListMcpResourcesTool.svelte +0 -31
- package/frontend/components/chat/tools/NotebookEditTool.svelte +0 -38
- package/frontend/components/chat/tools/ReadMcpResourceTool.svelte +0 -34
- package/frontend/components/chat/tools/ReadTool.svelte +0 -41
- package/frontend/components/chat/tools/SkillTool.svelte +0 -21
- package/frontend/components/chat/tools/TaskStopTool.svelte +0 -26
- package/frontend/components/chat/tools/TaskTool.svelte +0 -64
- package/frontend/components/chat/tools/TodoWriteTool.svelte +0 -75
- package/frontend/components/chat/tools/WebFetchTool.svelte +0 -35
- package/frontend/components/chat/tools/WebSearchTool.svelte +0 -84
- package/frontend/components/chat/tools/WriteTool.svelte +0 -33
- package/frontend/components/chat/tools/components/CodeBlock.svelte +0 -79
- package/frontend/components/chat/tools/components/DiffBlock.svelte +0 -408
- package/frontend/components/chat/tools/components/FileHeader.svelte +0 -59
- package/frontend/components/chat/tools/components/InfoLine.svelte +0 -19
- package/frontend/components/chat/tools/components/StatsBadges.svelte +0 -27
- package/frontend/components/chat/tools/components/TerminalCommand.svelte +0 -61
- package/frontend/components/chat/tools/components/index.ts +0 -7
- package/frontend/components/chat/tools/index.ts +0 -30
- package/frontend/components/chat/widgets/ContextIndicator.svelte +0 -186
- package/frontend/components/chat/widgets/FloatingTodoList.svelte +0 -367
- package/frontend/components/checkpoint/ConflictResolutionModal.svelte +0 -189
- package/frontend/components/checkpoint/TimelineModal.svelte +0 -447
- package/frontend/components/checkpoint/timeline/TimelineEdge.svelte +0 -26
- package/frontend/components/checkpoint/timeline/TimelineGraph.svelte +0 -87
- package/frontend/components/checkpoint/timeline/TimelineNode.svelte +0 -119
- package/frontend/components/checkpoint/timeline/TimelineVersionGroup.svelte +0 -59
- package/frontend/components/checkpoint/timeline/animation.ts +0 -168
- package/frontend/components/checkpoint/timeline/config.ts +0 -44
- package/frontend/components/checkpoint/timeline/graph-builder.ts +0 -304
- package/frontend/components/checkpoint/timeline/types.ts +0 -69
- package/frontend/components/checkpoint/timeline/utils.ts +0 -53
- package/frontend/components/common/display/AvatarBubble.svelte +0 -56
- package/frontend/components/common/display/Button.svelte +0 -71
- package/frontend/components/common/display/Card.svelte +0 -102
- package/frontend/components/common/display/Icon.svelte +0 -58
- package/frontend/components/common/display/PageTemplate.svelte +0 -76
- package/frontend/components/common/display/ProjectUserAvatars.svelte +0 -79
- package/frontend/components/common/display/ThemeToggle.svelte +0 -44
- package/frontend/components/common/editor/MonacoEditor.svelte +0 -583
- package/frontend/components/common/feedback/Alert.svelte +0 -139
- package/frontend/components/common/feedback/ConnectionBanner.svelte +0 -55
- package/frontend/components/common/feedback/LoadingScreen.svelte +0 -52
- package/frontend/components/common/feedback/LoadingSpinner.svelte +0 -48
- package/frontend/components/common/feedback/NotificationToast.svelte +0 -128
- package/frontend/components/common/feedback/RestartRequiredModal.svelte +0 -53
- package/frontend/components/common/feedback/UpdateBanner.svelte +0 -99
- package/frontend/components/common/form/Checkbox.svelte +0 -48
- package/frontend/components/common/form/FolderBrowser.svelte +0 -856
- package/frontend/components/common/form/Input.svelte +0 -72
- package/frontend/components/common/form/ModelSelector.svelte +0 -110
- package/frontend/components/common/form/Select.svelte +0 -98
- package/frontend/components/common/form/Textarea.svelte +0 -80
- package/frontend/components/common/lucide-icons.ts +0 -1642
- package/frontend/components/common/material-icons.ts +0 -1082
- package/frontend/components/common/media/MediaPreview.svelte +0 -187
- package/frontend/components/common/overlay/Dialog.svelte +0 -251
- package/frontend/components/common/overlay/Lightbox.svelte +0 -233
- package/frontend/components/common/overlay/Modal.svelte +0 -177
- package/frontend/components/common/overlay/ModalProvider.svelte +0 -28
- package/frontend/components/common/xterm/XTerm.svelte +0 -743
- package/frontend/components/common/xterm/index.ts +0 -16
- package/frontend/components/common/xterm/terminal-config.ts +0 -68
- package/frontend/components/common/xterm/types.ts +0 -32
- package/frontend/components/common/xterm/xterm-service.ts +0 -437
- package/frontend/components/files/FileNode.svelte +0 -327
- package/frontend/components/files/FileTree.svelte +0 -690
- package/frontend/components/files/FileViewer.svelte +0 -551
- package/frontend/components/files/SearchResults.svelte +0 -303
- package/frontend/components/git/BranchManager.svelte +0 -446
- package/frontend/components/git/ChangesSection.svelte +0 -196
- package/frontend/components/git/CommitForm.svelte +0 -128
- package/frontend/components/git/ConflictResolver.svelte +0 -158
- package/frontend/components/git/DiffViewer.svelte +0 -298
- package/frontend/components/git/FileChangeItem.svelte +0 -119
- package/frontend/components/git/GitButton.svelte +0 -33
- package/frontend/components/git/GitLog.svelte +0 -401
- package/frontend/components/git/GitModal.svelte +0 -80
- package/frontend/components/history/HistoryModal.svelte +0 -602
- package/frontend/components/history/HistoryView.svelte +0 -561
- package/frontend/components/index.ts +0 -34
- package/frontend/components/preview/browser/BrowserPreview.svelte +0 -558
- package/frontend/components/preview/browser/components/Canvas.svelte +0 -1523
- package/frontend/components/preview/browser/components/ConsolePanel.svelte +0 -757
- package/frontend/components/preview/browser/components/Container.svelte +0 -507
- package/frontend/components/preview/browser/components/ContextMenu.svelte +0 -236
- package/frontend/components/preview/browser/components/SelectDropdown.svelte +0 -224
- package/frontend/components/preview/browser/components/Toolbar.svelte +0 -358
- package/frontend/components/preview/browser/components/VirtualCursor.svelte +0 -36
- package/frontend/components/preview/browser/core/cleanup.svelte.ts +0 -155
- package/frontend/components/preview/browser/core/coordinator.svelte.ts +0 -885
- package/frontend/components/preview/browser/core/interactions.svelte.ts +0 -113
- package/frontend/components/preview/browser/core/mcp-handlers.svelte.ts +0 -331
- package/frontend/components/preview/browser/core/native-ui-handlers.svelte.ts +0 -391
- package/frontend/components/preview/browser/core/stream-handler.svelte.ts +0 -288
- package/frontend/components/preview/browser/core/tab-manager.svelte.ts +0 -210
- package/frontend/components/preview/browser/core/tab-operations.svelte.ts +0 -241
- package/frontend/components/preview/index.ts +0 -2
- package/frontend/components/settings/SettingsModal.svelte +0 -268
- package/frontend/components/settings/SettingsView.svelte +0 -54
- package/frontend/components/settings/account/AccountSettings.svelte +0 -5
- package/frontend/components/settings/admin/InviteManagement.svelte +0 -239
- package/frontend/components/settings/admin/UserManagement.svelte +0 -127
- package/frontend/components/settings/appearance/AppearanceSettings.svelte +0 -104
- package/frontend/components/settings/appearance/LayoutPresetSettings.svelte +0 -160
- package/frontend/components/settings/appearance/LayoutPreview.svelte +0 -76
- package/frontend/components/settings/engines/AIEnginesSettings.svelte +0 -917
- package/frontend/components/settings/general/AdvancedSettings.svelte +0 -193
- package/frontend/components/settings/general/AuthModeSettings.svelte +0 -229
- package/frontend/components/settings/general/DataManagementSettings.svelte +0 -89
- package/frontend/components/settings/general/GeneralSettings.svelte +0 -20
- package/frontend/components/settings/general/UpdateSettings.svelte +0 -130
- package/frontend/components/settings/git/GitSettings.svelte +0 -392
- package/frontend/components/settings/model/EngineModelPicker.svelte +0 -284
- package/frontend/components/settings/model/ModelSettings.svelte +0 -240
- package/frontend/components/settings/notifications/NotificationSettings.svelte +0 -205
- package/frontend/components/settings/security/SecuritySettings.svelte +0 -10
- package/frontend/components/settings/system/SystemSettings.svelte +0 -10
- package/frontend/components/settings/tunnel/TunnelSettings.svelte +0 -1060
- package/frontend/components/settings/user/UserSettings.svelte +0 -270
- package/frontend/components/terminal/Terminal.svelte +0 -338
- package/frontend/components/terminal/TerminalTabs.svelte +0 -88
- package/frontend/components/terminal/TerminalView.svelte +0 -55
- package/frontend/components/tunnel/TunnelActive.svelte +0 -218
- package/frontend/components/tunnel/TunnelButton.svelte +0 -60
- package/frontend/components/tunnel/TunnelInactive.svelte +0 -260
- package/frontend/components/tunnel/TunnelModal.svelte +0 -101
- package/frontend/components/tunnel/TunnelQRCode.svelte +0 -49
- package/frontend/components/workspace/DesktopNavigator.svelte +0 -445
- package/frontend/components/workspace/MobileNavigator.svelte +0 -427
- package/frontend/components/workspace/PanelContainer.svelte +0 -100
- package/frontend/components/workspace/PanelHeader.svelte +0 -664
- package/frontend/components/workspace/ViewMenu.svelte +0 -146
- package/frontend/components/workspace/WorkspaceLayout.svelte +0 -199
- package/frontend/components/workspace/layout/DesktopLayout.svelte +0 -15
- package/frontend/components/workspace/layout/MobileLayout.svelte +0 -17
- package/frontend/components/workspace/layout/split-pane/Container.svelte +0 -42
- package/frontend/components/workspace/layout/split-pane/Handle.svelte +0 -85
- package/frontend/components/workspace/layout/split-pane/Layout.svelte +0 -62
- package/frontend/components/workspace/panels/ChatPanel.svelte +0 -282
- package/frontend/components/workspace/panels/FilesPanel.svelte +0 -1376
- package/frontend/components/workspace/panels/GitPanel.svelte +0 -1601
- package/frontend/components/workspace/panels/PreviewPanel.svelte +0 -153
- package/frontend/components/workspace/panels/TerminalPanel.svelte +0 -73
- package/frontend/main.ts +0 -17
- package/frontend/services/chat/chat.service.ts +0 -975
- package/frontend/services/chat/index.ts +0 -7
- package/frontend/services/favicon.service.ts +0 -103
- package/frontend/services/notification/global-stream-monitor.ts +0 -120
- package/frontend/services/notification/index.ts +0 -8
- package/frontend/services/notification/push.service.ts +0 -144
- package/frontend/services/notification/sound.service.ts +0 -127
- package/frontend/services/preview/browser/browser-console.service.ts +0 -61
- package/frontend/services/preview/browser/browser-webcodecs.service.ts +0 -1643
- package/frontend/services/preview/browser/mcp-integration.svelte.ts +0 -67
- package/frontend/services/preview/index.ts +0 -23
- package/frontend/services/project/index.ts +0 -8
- package/frontend/services/project/status.service.ts +0 -170
- package/frontend/services/snapshot/snapshot.service.ts +0 -86
- package/frontend/services/terminal/background/index.ts +0 -130
- package/frontend/services/terminal/background/session-restore.ts +0 -274
- package/frontend/services/terminal/background/stream-manager.ts +0 -286
- package/frontend/services/terminal/index.ts +0 -14
- package/frontend/services/terminal/persistence.service.ts +0 -260
- package/frontend/services/terminal/project.service.ts +0 -1004
- package/frontend/services/terminal/session.service.ts +0 -364
- package/frontend/services/terminal/terminal.service.ts +0 -379
- package/frontend/stores/core/app.svelte.ts +0 -296
- package/frontend/stores/core/files.svelte.ts +0 -87
- package/frontend/stores/core/presence.svelte.ts +0 -128
- package/frontend/stores/core/projects.svelte.ts +0 -325
- package/frontend/stores/core/sessions.svelte.ts +0 -452
- package/frontend/stores/features/auth.svelte.ts +0 -336
- package/frontend/stores/features/claude-accounts.svelte.ts +0 -58
- package/frontend/stores/features/models.svelte.ts +0 -89
- package/frontend/stores/features/settings.svelte.ts +0 -151
- package/frontend/stores/features/terminal.svelte.ts +0 -747
- package/frontend/stores/features/tunnel-config.svelte.ts +0 -205
- package/frontend/stores/features/tunnel.svelte.ts +0 -277
- package/frontend/stores/features/user.svelte.ts +0 -54
- package/frontend/stores/ui/chat-input.svelte.ts +0 -57
- package/frontend/stores/ui/chat-model.svelte.ts +0 -61
- package/frontend/stores/ui/connection.svelte.ts +0 -40
- package/frontend/stores/ui/dialog.svelte.ts +0 -59
- package/frontend/stores/ui/edit-mode.svelte.ts +0 -214
- package/frontend/stores/ui/notification.svelte.ts +0 -169
- package/frontend/stores/ui/settings-modal.svelte.ts +0 -116
- package/frontend/stores/ui/theme.svelte.ts +0 -179
- package/frontend/stores/ui/todo-panel.svelte.ts +0 -39
- package/frontend/stores/ui/update.svelte.ts +0 -159
- package/frontend/stores/ui/workspace.svelte.ts +0 -798
- package/frontend/utils/chat/date-separator.ts +0 -39
- package/frontend/utils/chat/message-grouper.ts +0 -329
- package/frontend/utils/chat/message-processor.ts +0 -169
- package/frontend/utils/chat/tool-handler.ts +0 -287
- package/frontend/utils/chat/virtual-scroll.svelte.ts +0 -142
- package/frontend/utils/click-outside.ts +0 -20
- package/frontend/utils/context-manager.ts +0 -55
- package/frontend/utils/file-icon-mappings.ts +0 -769
- package/frontend/utils/file-type.ts +0 -68
- package/frontend/utils/folder-icon-mappings.ts +0 -1030
- package/frontend/utils/git-status.ts +0 -68
- package/frontend/utils/native-ui.ts +0 -73
- package/frontend/utils/platform.ts +0 -113
- package/frontend/utils/port-check.ts +0 -65
- package/frontend/utils/preview-constants.ts +0 -45
- package/frontend/utils/terminal-formatter.ts +0 -207
- package/frontend/utils/theme.ts +0 -6
- package/frontend/utils/tree-visualizer.ts +0 -320
- package/frontend/utils/ws.ts +0 -90
- package/scripts/dev.ts +0 -46
- package/scripts/generate-icons.ts +0 -87
- package/svelte.config.js +0 -20
- package/tsconfig.json +0 -41
- package/vite.config.ts +0 -51
- /package/{static → dist}/audio/notification.ogg +0 -0
- /package/{static → dist}/favicon.svg +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-italic-latin-ext.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-italic-latin.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-normal-latin-ext.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans/dm-sans-normal-latin.woff2 +0 -0
- /package/{static → dist}/fonts/dm-sans.css +0 -0
- /package/{static → dist}/manifest.json +0 -0
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { AskUserQuestionToolInput } from '$shared/types/messaging';
|
|
3
|
-
import Icon from '$frontend/components/common/display/Icon.svelte';
|
|
4
|
-
import ws from '$frontend/utils/ws';
|
|
5
|
-
import { currentSessionId } from '$frontend/stores/core/sessions.svelte';
|
|
6
|
-
import { appState, updateSessionProcessState } from '$frontend/stores/core/app.svelte';
|
|
7
|
-
import { debug } from '$shared/utils/logger';
|
|
8
|
-
|
|
9
|
-
const { toolInput }: { toolInput: AskUserQuestionToolInput } = $props();
|
|
10
|
-
|
|
11
|
-
// Parse answers from the SDK's $result.content string using known question texts as anchors.
|
|
12
|
-
// Format: User has answered your questions: "q1"="a1", "q2"="a2", ... . You can now continue...
|
|
13
|
-
// Regex-based parsing breaks when answers contain quotes or "=", so we use
|
|
14
|
-
// the known question texts to delimit each answer's boundaries.
|
|
15
|
-
function parseResultAnswers(content: string, questions: { question: string }[]): Record<string, string> {
|
|
16
|
-
const answers: Record<string, string> = {};
|
|
17
|
-
|
|
18
|
-
// Try JSON parse first (future SDK versions might use JSON)
|
|
19
|
-
try {
|
|
20
|
-
const json = JSON.parse(content);
|
|
21
|
-
if (json?.answers && typeof json.answers === 'object') return json.answers;
|
|
22
|
-
} catch {
|
|
23
|
-
// Not JSON — parse human-readable format
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < questions.length; i++) {
|
|
27
|
-
const q = questions[i].question;
|
|
28
|
-
const searchStr = `"${q}"="`;
|
|
29
|
-
const startIdx = content.indexOf(searchStr);
|
|
30
|
-
if (startIdx === -1) continue;
|
|
31
|
-
|
|
32
|
-
const answerStart = startIdx + searchStr.length;
|
|
33
|
-
|
|
34
|
-
// Find the end of this answer:
|
|
35
|
-
// If there's a next question, use its marker as delimiter.
|
|
36
|
-
// Otherwise, use the SDK's closing marker.
|
|
37
|
-
let answerEnd = -1;
|
|
38
|
-
|
|
39
|
-
if (i < questions.length - 1) {
|
|
40
|
-
const nextQ = questions[i + 1].question;
|
|
41
|
-
const nextMarker = `", "${nextQ}"="`;
|
|
42
|
-
answerEnd = content.indexOf(nextMarker, answerStart);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (answerEnd === -1) {
|
|
46
|
-
const endMarker = '". You can now continue';
|
|
47
|
-
answerEnd = content.indexOf(endMarker, answerStart);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
answers[q] = answerEnd !== -1
|
|
51
|
-
? content.slice(answerStart, answerEnd)
|
|
52
|
-
: content.slice(answerStart);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return answers;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Detect whether the tool has a $result (answered or errored)
|
|
59
|
-
const hasResult = $derived(!!toolInput.$result?.content);
|
|
60
|
-
|
|
61
|
-
// Parse per-question answers from the result content
|
|
62
|
-
let parsedAnswers = $derived.by(() => {
|
|
63
|
-
if (!toolInput.$result?.content) return {};
|
|
64
|
-
return parseResultAnswers(toolInput.$result.content, toolInput.input.questions);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Detect error: $result exists but no answers could be parsed (error message instead of answer format)
|
|
68
|
-
const isError = $derived(hasResult && Object.keys(parsedAnswers).length === 0);
|
|
69
|
-
|
|
70
|
-
// Successfully answered: has result and parsed answers exist
|
|
71
|
-
const isAnswered = $derived(hasResult && !isError);
|
|
72
|
-
|
|
73
|
-
// Selection state per question
|
|
74
|
-
let selections = $state<Record<number, Set<string>>>({});
|
|
75
|
-
// Custom text input per question (for "Other" option)
|
|
76
|
-
let customInputs = $state<Record<number, string>>({});
|
|
77
|
-
// Track whether "Other" is the active selection per question
|
|
78
|
-
let otherActive = $state<Record<number, boolean>>({});
|
|
79
|
-
let isSubmitting = $state(false);
|
|
80
|
-
let hasSubmitted = $state(false);
|
|
81
|
-
|
|
82
|
-
// Tool was interrupted — metadata set by chat service when stream ends (error/cancel/complete)
|
|
83
|
-
const isInterrupted = $derived(!!toolInput.metadata?.interrupted);
|
|
84
|
-
|
|
85
|
-
// Initialize selections
|
|
86
|
-
$effect(() => {
|
|
87
|
-
if (!toolInput.input.questions) return;
|
|
88
|
-
const initial: Record<number, Set<string>> = {};
|
|
89
|
-
const initialCustom: Record<number, string> = {};
|
|
90
|
-
const initialOther: Record<number, boolean> = {};
|
|
91
|
-
for (let i = 0; i < toolInput.input.questions.length; i++) {
|
|
92
|
-
initial[i] = new Set();
|
|
93
|
-
initialCustom[i] = '';
|
|
94
|
-
initialOther[i] = false;
|
|
95
|
-
}
|
|
96
|
-
selections = initial;
|
|
97
|
-
customInputs = initialCustom;
|
|
98
|
-
otherActive = initialOther;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Sound/push notifications for AskUserQuestion are handled globally by
|
|
102
|
-
// GlobalStreamMonitor (via chat:waiting-input event) — works cross-session,
|
|
103
|
-
// plays once per tool_use, and does not replay when returning to session.
|
|
104
|
-
|
|
105
|
-
function toggleSelection(questionIdx: number, label: string, isMultiSelect: boolean) {
|
|
106
|
-
const current = selections[questionIdx] || new Set();
|
|
107
|
-
if (isMultiSelect) {
|
|
108
|
-
if (current.has(label)) {
|
|
109
|
-
current.delete(label);
|
|
110
|
-
} else {
|
|
111
|
-
current.add(label);
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
current.clear();
|
|
115
|
-
current.add(label);
|
|
116
|
-
// Single-select: deselect Other when picking a regular option
|
|
117
|
-
otherActive[questionIdx] = false;
|
|
118
|
-
customInputs[questionIdx] = '';
|
|
119
|
-
}
|
|
120
|
-
selections[questionIdx] = new Set(current);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function toggleOther(questionIdx: number, isMultiSelect: boolean) {
|
|
124
|
-
if (isMultiSelect) {
|
|
125
|
-
otherActive[questionIdx] = !otherActive[questionIdx];
|
|
126
|
-
} else {
|
|
127
|
-
selections[questionIdx] = new Set();
|
|
128
|
-
otherActive[questionIdx] = true;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function isSelected(questionIdx: number, label: string): boolean {
|
|
133
|
-
return selections[questionIdx]?.has(label) ?? false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function submitAnswers() {
|
|
137
|
-
if (isSubmitting || hasSubmitted) return;
|
|
138
|
-
isSubmitting = true;
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
const answers: Record<string, string> = {};
|
|
142
|
-
const questions = toolInput.input.questions;
|
|
143
|
-
|
|
144
|
-
for (let i = 0; i < questions.length; i++) {
|
|
145
|
-
const q = questions[i];
|
|
146
|
-
const selected = selections[i] || new Set();
|
|
147
|
-
const customText = customInputs[i]?.trim();
|
|
148
|
-
const isOther = otherActive[i];
|
|
149
|
-
|
|
150
|
-
if (q.multiSelect) {
|
|
151
|
-
const parts: string[] = Array.from(selected);
|
|
152
|
-
if (isOther && customText) {
|
|
153
|
-
parts.push(customText);
|
|
154
|
-
}
|
|
155
|
-
answers[q.question] = parts.join(', ');
|
|
156
|
-
} else {
|
|
157
|
-
if (isOther && customText) {
|
|
158
|
-
answers[q.question] = customText;
|
|
159
|
-
} else if (selected.size > 0) {
|
|
160
|
-
answers[q.question] = Array.from(selected).join(', ');
|
|
161
|
-
} else {
|
|
162
|
-
answers[q.question] = '';
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
debug.log('chat', 'Submitting AskUserQuestion answers:', answers);
|
|
168
|
-
|
|
169
|
-
ws.emit('chat:ask-user-answer', {
|
|
170
|
-
chatSessionId: currentSessionId(),
|
|
171
|
-
toolUseId: toolInput.id,
|
|
172
|
-
answers
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Clear waiting input status — SDK will resume processing
|
|
176
|
-
const sessId = currentSessionId();
|
|
177
|
-
if (sessId) updateSessionProcessState(sessId, { isWaitingInput: false });
|
|
178
|
-
appState.isWaitingInput = false;
|
|
179
|
-
|
|
180
|
-
hasSubmitted = true;
|
|
181
|
-
} catch (error) {
|
|
182
|
-
debug.error('chat', 'Failed to submit answers:', error);
|
|
183
|
-
} finally {
|
|
184
|
-
isSubmitting = false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
</script>
|
|
188
|
-
|
|
189
|
-
{#if isError || isInterrupted}
|
|
190
|
-
<!-- Error/interrupted state — show questions as read-only with error indicator -->
|
|
191
|
-
<div class="space-y-3">
|
|
192
|
-
{#each toolInput.input.questions as question}
|
|
193
|
-
<div class="bg-white dark:bg-slate-800 rounded-lg border border-red-200/60 dark:border-red-800/40 p-4 space-y-2.5">
|
|
194
|
-
<div class="flex items-center gap-2">
|
|
195
|
-
<Icon name="lucide:circle-x" class="text-red-500 w-4 h-4 shrink-0" />
|
|
196
|
-
<span class="text-xs font-semibold px-2 py-0.5 rounded-full bg-slate-100 dark:bg-slate-700/50 text-slate-500 dark:text-slate-400">
|
|
197
|
-
{question.header}
|
|
198
|
-
</span>
|
|
199
|
-
</div>
|
|
200
|
-
<p class="text-sm text-slate-500 dark:text-slate-400">{question.question}</p>
|
|
201
|
-
</div>
|
|
202
|
-
{/each}
|
|
203
|
-
{#if isError && toolInput.$result?.content}
|
|
204
|
-
<p class="text-xs text-red-500 dark:text-red-400">{toolInput.$result.content}</p>
|
|
205
|
-
{:else}
|
|
206
|
-
<p class="text-xs text-red-500 dark:text-red-400">Session ended before question was answered</p>
|
|
207
|
-
{/if}
|
|
208
|
-
</div>
|
|
209
|
-
|
|
210
|
-
{:else if isAnswered}
|
|
211
|
-
<!-- Answered state — each question in its own card -->
|
|
212
|
-
<div class="space-y-3">
|
|
213
|
-
{#each toolInput.input.questions as question}
|
|
214
|
-
<div class="bg-white dark:bg-slate-800 rounded-lg border border-slate-200/60 dark:border-slate-700/60 p-4 space-y-2.5">
|
|
215
|
-
<div class="flex items-center gap-2">
|
|
216
|
-
<Icon name="lucide:circle-check" class="text-green-500 w-4 h-4 shrink-0" />
|
|
217
|
-
<span class="text-xs font-semibold px-2 py-0.5 rounded-full bg-blue-100 dark:bg-blue-800/50 text-blue-700 dark:text-blue-300">
|
|
218
|
-
{question.header}
|
|
219
|
-
</span>
|
|
220
|
-
</div>
|
|
221
|
-
<p class="text-sm font-medium text-slate-700 dark:text-slate-200">{question.question}</p>
|
|
222
|
-
<p class="text-sm text-green-700 dark:text-green-300 font-medium">
|
|
223
|
-
{parsedAnswers[question.question] || 'No answer'}
|
|
224
|
-
</p>
|
|
225
|
-
</div>
|
|
226
|
-
{/each}
|
|
227
|
-
</div>
|
|
228
|
-
|
|
229
|
-
{:else if hasSubmitted}
|
|
230
|
-
<!-- Submitted state — each question in its own card with local answer -->
|
|
231
|
-
<div class="space-y-3">
|
|
232
|
-
{#each toolInput.input.questions as question, idx}
|
|
233
|
-
{@const selected = selections[idx] || new Set()}
|
|
234
|
-
{@const customText = customInputs[idx]?.trim()}
|
|
235
|
-
{@const isOther = otherActive[idx]}
|
|
236
|
-
{@const localAnswer = question.multiSelect
|
|
237
|
-
? [...Array.from(selected), ...(isOther && customText ? [customText] : [])].join(', ')
|
|
238
|
-
: (isOther && customText ? customText : Array.from(selected).join(', '))
|
|
239
|
-
}
|
|
240
|
-
<div class="bg-white dark:bg-slate-800 rounded-lg border border-slate-200/60 dark:border-slate-700/60 p-4 space-y-2.5">
|
|
241
|
-
<div class="flex items-center gap-2">
|
|
242
|
-
<div class="w-4 h-4 border-2 border-blue-400 border-t-transparent rounded-full animate-spin shrink-0"></div>
|
|
243
|
-
<span class="text-xs font-semibold px-2 py-0.5 rounded-full bg-blue-100 dark:bg-blue-800/50 text-blue-700 dark:text-blue-300">
|
|
244
|
-
{question.header}
|
|
245
|
-
</span>
|
|
246
|
-
</div>
|
|
247
|
-
<p class="text-sm font-medium text-slate-700 dark:text-slate-200">{question.question}</p>
|
|
248
|
-
<p class="text-sm text-slate-500 dark:text-slate-400">
|
|
249
|
-
{localAnswer || 'No answer'}
|
|
250
|
-
</p>
|
|
251
|
-
</div>
|
|
252
|
-
{/each}
|
|
253
|
-
</div>
|
|
254
|
-
|
|
255
|
-
{:else}
|
|
256
|
-
<!-- Interactive form — each question in its own card -->
|
|
257
|
-
<div class="space-y-3">
|
|
258
|
-
{#each toolInput.input.questions as question, idx}
|
|
259
|
-
<div class="bg-white dark:bg-slate-800 rounded-lg border border-slate-200/60 dark:border-slate-700/60 p-4 space-y-3">
|
|
260
|
-
<!-- Question header badge -->
|
|
261
|
-
<div class="flex items-center gap-2">
|
|
262
|
-
<Icon name="lucide:message-circle-question-mark" class="text-blue-500 dark:text-blue-400 w-4 h-4 shrink-0" />
|
|
263
|
-
<span class="text-xs font-semibold px-2 py-0.5 rounded-full bg-blue-100 dark:bg-blue-800/50 text-blue-700 dark:text-blue-300">
|
|
264
|
-
{question.header}
|
|
265
|
-
</span>
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
<!-- Question text -->
|
|
269
|
-
<p class="text-sm font-medium text-slate-700 dark:text-slate-200">{question.question}</p>
|
|
270
|
-
|
|
271
|
-
<!-- Options -->
|
|
272
|
-
<div class="space-y-1.5">
|
|
273
|
-
{#each question.options as option}
|
|
274
|
-
<button
|
|
275
|
-
class="w-full text-left flex items-start gap-3 p-2.5 rounded-md border transition-colors
|
|
276
|
-
{isSelected(idx, option.label)
|
|
277
|
-
? 'border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-900/30'
|
|
278
|
-
: 'border-slate-200 dark:border-slate-700 hover:border-blue-300 dark:hover:border-blue-600 hover:bg-slate-50 dark:hover:bg-slate-700/50'
|
|
279
|
-
}"
|
|
280
|
-
onclick={() => toggleSelection(idx, option.label, question.multiSelect)}
|
|
281
|
-
>
|
|
282
|
-
<div class="mt-0.5 shrink-0">
|
|
283
|
-
{#if question.multiSelect}
|
|
284
|
-
<div class="w-4 h-4 rounded border-2 flex items-center justify-center transition-colors
|
|
285
|
-
{isSelected(idx, option.label)
|
|
286
|
-
? 'border-blue-500 bg-blue-500'
|
|
287
|
-
: 'border-slate-300 dark:border-slate-600'
|
|
288
|
-
}"
|
|
289
|
-
>
|
|
290
|
-
{#if isSelected(idx, option.label)}
|
|
291
|
-
<Icon name="lucide:check" class="text-white w-3 h-3" />
|
|
292
|
-
{/if}
|
|
293
|
-
</div>
|
|
294
|
-
{:else}
|
|
295
|
-
<div class="w-4 h-4 rounded-full border-2 flex items-center justify-center transition-colors
|
|
296
|
-
{isSelected(idx, option.label)
|
|
297
|
-
? 'border-blue-500'
|
|
298
|
-
: 'border-slate-300 dark:border-slate-600'
|
|
299
|
-
}"
|
|
300
|
-
>
|
|
301
|
-
{#if isSelected(idx, option.label)}
|
|
302
|
-
<div class="w-2 h-2 rounded-full bg-blue-500"></div>
|
|
303
|
-
{/if}
|
|
304
|
-
</div>
|
|
305
|
-
{/if}
|
|
306
|
-
</div>
|
|
307
|
-
<div class="min-w-0">
|
|
308
|
-
<span class="text-sm font-medium text-slate-800 dark:text-slate-200">{option.label}</span>
|
|
309
|
-
<span class="text-sm text-slate-500 dark:text-slate-400"> — {option.description}</span>
|
|
310
|
-
</div>
|
|
311
|
-
</button>
|
|
312
|
-
{/each}
|
|
313
|
-
|
|
314
|
-
<!-- "Other" custom input option -->
|
|
315
|
-
<div
|
|
316
|
-
class="flex items-start gap-3 p-2.5 rounded-md border transition-colors cursor-pointer
|
|
317
|
-
{otherActive[idx]
|
|
318
|
-
? 'border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-900/30'
|
|
319
|
-
: 'border-slate-200 dark:border-slate-700 hover:border-blue-300 dark:hover:border-blue-600 hover:bg-slate-50 dark:hover:bg-slate-700/50'
|
|
320
|
-
}"
|
|
321
|
-
onclick={() => toggleOther(idx, question.multiSelect)}
|
|
322
|
-
role="button"
|
|
323
|
-
tabindex="-1"
|
|
324
|
-
>
|
|
325
|
-
<div class="mt-0.5 shrink-0">
|
|
326
|
-
{#if question.multiSelect}
|
|
327
|
-
<div class="w-4 h-4 rounded border-2 flex items-center justify-center transition-colors
|
|
328
|
-
{otherActive[idx]
|
|
329
|
-
? 'border-blue-500 bg-blue-500'
|
|
330
|
-
: 'border-slate-300 dark:border-slate-600'
|
|
331
|
-
}"
|
|
332
|
-
>
|
|
333
|
-
{#if otherActive[idx]}
|
|
334
|
-
<Icon name="lucide:check" class="text-white w-3 h-3" />
|
|
335
|
-
{/if}
|
|
336
|
-
</div>
|
|
337
|
-
{:else}
|
|
338
|
-
<div class="w-4 h-4 rounded-full border-2 flex items-center justify-center transition-colors
|
|
339
|
-
{otherActive[idx]
|
|
340
|
-
? 'border-blue-500'
|
|
341
|
-
: 'border-slate-300 dark:border-slate-600'
|
|
342
|
-
}"
|
|
343
|
-
>
|
|
344
|
-
{#if otherActive[idx]}
|
|
345
|
-
<div class="w-2 h-2 rounded-full bg-blue-500"></div>
|
|
346
|
-
{/if}
|
|
347
|
-
</div>
|
|
348
|
-
{/if}
|
|
349
|
-
</div>
|
|
350
|
-
<div class="flex-1 min-w-0">
|
|
351
|
-
<input
|
|
352
|
-
type="text"
|
|
353
|
-
placeholder="Other (type your answer)..."
|
|
354
|
-
class="w-full text-sm bg-transparent border-none outline-none text-slate-700 dark:text-slate-200 placeholder-slate-400"
|
|
355
|
-
bind:value={customInputs[idx]}
|
|
356
|
-
onclick={(e) => e.stopPropagation()}
|
|
357
|
-
onfocus={() => {
|
|
358
|
-
if (!question.multiSelect) {
|
|
359
|
-
selections[idx] = new Set();
|
|
360
|
-
}
|
|
361
|
-
otherActive[idx] = true;
|
|
362
|
-
}}
|
|
363
|
-
/>
|
|
364
|
-
</div>
|
|
365
|
-
</div>
|
|
366
|
-
</div>
|
|
367
|
-
|
|
368
|
-
{#if question.multiSelect}
|
|
369
|
-
<p class="text-xs text-slate-400 dark:text-slate-500 italic">Multiple selections allowed</p>
|
|
370
|
-
{/if}
|
|
371
|
-
</div>
|
|
372
|
-
{/each}
|
|
373
|
-
|
|
374
|
-
<!-- Submit button -->
|
|
375
|
-
<div class="flex justify-end pt-1">
|
|
376
|
-
<button
|
|
377
|
-
class="px-4 py-1.5 text-sm font-medium rounded-md transition-colors
|
|
378
|
-
bg-blue-600 hover:bg-blue-700 text-white
|
|
379
|
-
disabled:opacity-50 disabled:cursor-not-allowed"
|
|
380
|
-
onclick={submitAnswers}
|
|
381
|
-
disabled={isSubmitting}
|
|
382
|
-
>
|
|
383
|
-
{#if isSubmitting}
|
|
384
|
-
Submitting...
|
|
385
|
-
{:else}
|
|
386
|
-
Submit Answer
|
|
387
|
-
{/if}
|
|
388
|
-
</button>
|
|
389
|
-
</div>
|
|
390
|
-
</div>
|
|
391
|
-
{/if}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { BashOutputToolInput } from '$shared/types/messaging';
|
|
3
|
-
import { InfoLine } from './components';
|
|
4
|
-
import TextMessage from '../formatters/TextMessage.svelte';
|
|
5
|
-
|
|
6
|
-
const { toolInput }: { toolInput: BashOutputToolInput } = $props();
|
|
7
|
-
|
|
8
|
-
const taskId = $derived(toolInput.input.task_id);
|
|
9
|
-
const block = $derived(toolInput.input.block);
|
|
10
|
-
const timeout = $derived(toolInput.input.timeout);
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<div class="bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
14
|
-
<!-- Command Info -->
|
|
15
|
-
<div class="flex gap-3">
|
|
16
|
-
<InfoLine icon="lucide:terminal" text="Reading output from task: {taskId}" />
|
|
17
|
-
{#if block}
|
|
18
|
-
<InfoLine icon="lucide:clock" text="Blocking: {block}" />
|
|
19
|
-
{/if}
|
|
20
|
-
{#if timeout}
|
|
21
|
-
<InfoLine icon="lucide:timer" text="Timeout: {timeout}ms" />
|
|
22
|
-
{/if}
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<!-- Tool Result -->
|
|
27
|
-
{#if toolInput.$result}
|
|
28
|
-
<div class="mt-4 bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
29
|
-
{#if typeof toolInput.$result.content === 'string'}
|
|
30
|
-
<TextMessage content={toolInput.$result.content} />
|
|
31
|
-
{:else}
|
|
32
|
-
<TextMessage content={JSON.stringify(toolInput.$result.content)} />
|
|
33
|
-
{/if}
|
|
34
|
-
</div>
|
|
35
|
-
{/if}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { BashToolInput } from '$shared/types/messaging';
|
|
3
|
-
import { TerminalCommand } from './components';
|
|
4
|
-
import CodeBlock from './components/CodeBlock.svelte';
|
|
5
|
-
|
|
6
|
-
/** Parsed background bash output (from XML-formatted BashOutput tool result) */
|
|
7
|
-
interface ParsedBashOutput {
|
|
8
|
-
status: 'running' | 'completed' | 'failed';
|
|
9
|
-
output: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { toolInput }: { toolInput: BashToolInput } = $props();
|
|
13
|
-
|
|
14
|
-
const command = $derived(toolInput.input.command || '');
|
|
15
|
-
const description = $derived(toolInput.input.description);
|
|
16
|
-
const timeout = $derived(toolInput.input.timeout);
|
|
17
|
-
const isBackground = $derived(toolInput.input.run_in_background);
|
|
18
|
-
|
|
19
|
-
function parseBashOutputToolOutput(content: string): ParsedBashOutput {
|
|
20
|
-
const statusMatch = content.match(/<status>(.*?)<\/status>/);
|
|
21
|
-
const stdoutMatch = content.match(/<stdout>(.*?)<\/stdout>/s);
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
status: statusMatch ? statusMatch[1] as ParsedBashOutput['status'] : 'completed',
|
|
25
|
-
output: stdoutMatch ? stdoutMatch[1].trim() : ""
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Parse the output content if it's from BashOutput format
|
|
30
|
-
const outputContent = $derived.by(() => {
|
|
31
|
-
if (!toolInput.$result?.content) return '';
|
|
32
|
-
|
|
33
|
-
// Check if this is a background command that has been merged with BashOutput
|
|
34
|
-
if (isBackground && toolInput.$result.content.includes('<status>')) {
|
|
35
|
-
const parsed = parseBashOutputToolOutput(toolInput.$result.content);
|
|
36
|
-
return parsed.output;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return toolInput.$result.content;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<TerminalCommand {command} {description} {timeout} />
|
|
45
|
-
|
|
46
|
-
<!-- Tool Result -->
|
|
47
|
-
{#if outputContent}
|
|
48
|
-
<div class="mt-4 bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
49
|
-
<CodeBlock code={outputContent} type="neutral" label="Output" />
|
|
50
|
-
</div>
|
|
51
|
-
{/if}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { FileHeader, CodeBlock } from './components';
|
|
3
|
-
import Icon from '$frontend/components/common/display/Icon.svelte';
|
|
4
|
-
import type { ToolInput } from '$shared/types/messaging';
|
|
5
|
-
|
|
6
|
-
const { toolInput }: { toolInput: ToolInput } = $props();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parse MCP tool name
|
|
10
|
-
* Format: mcp__server-name__tool-name
|
|
11
|
-
*/
|
|
12
|
-
interface ParsedToolName {
|
|
13
|
-
server: string;
|
|
14
|
-
tool: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function parseMcpToolName(fullName: string): ParsedToolName {
|
|
18
|
-
// Remove "mcp__" prefix
|
|
19
|
-
const withoutPrefix = fullName.replace('mcp__', '');
|
|
20
|
-
const parts = withoutPrefix.split('__');
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
server: parts[0] || 'unknown',
|
|
24
|
-
tool: parts[1] || 'unknown'
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const parsedToolName = $derived(parseMcpToolName(toolInput.name));
|
|
29
|
-
const server = $derived(parsedToolName.server);
|
|
30
|
-
const tool = $derived(parsedToolName.tool);
|
|
31
|
-
|
|
32
|
-
// Format server name for display (e.g., "weather-service" -> "Weather Service")
|
|
33
|
-
const serverDisplayName = $derived.by(() => {
|
|
34
|
-
return server
|
|
35
|
-
.split('-')
|
|
36
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
37
|
-
.join(' ');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Format tool name for display (e.g., "get_temperature" -> "Get Temperature")
|
|
41
|
-
const toolDisplayName = $derived.by(() => {
|
|
42
|
-
return tool
|
|
43
|
-
.split('_')
|
|
44
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
45
|
-
.join(' ');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Extract result content
|
|
49
|
-
const resultContent = $derived.by(() => {
|
|
50
|
-
if (!toolInput.$result?.content) return null;
|
|
51
|
-
|
|
52
|
-
const content = toolInput.$result.content;
|
|
53
|
-
|
|
54
|
-
// If content is already a string, return it
|
|
55
|
-
if (typeof content === 'string') {
|
|
56
|
-
return content;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// If content is an array (MCP format)
|
|
60
|
-
if (Array.isArray(content)) {
|
|
61
|
-
// Extract text from first text block
|
|
62
|
-
const textBlock = (content as any[]).find((block: any) => block.type === 'text');
|
|
63
|
-
if (textBlock && textBlock.text) {
|
|
64
|
-
return textBlock.text;
|
|
65
|
-
}
|
|
66
|
-
// Fallback: stringify the array
|
|
67
|
-
return JSON.stringify(content, null, 2);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// If content is an object, stringify it
|
|
71
|
-
if (typeof content === 'object' && content !== null) {
|
|
72
|
-
return JSON.stringify(content, null, 2);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Fallback: convert to string
|
|
76
|
-
return String(content);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Check if result is an error
|
|
80
|
-
const isError = $derived.by(() => {
|
|
81
|
-
if (!toolInput.$result?.content) return false;
|
|
82
|
-
|
|
83
|
-
const content = toolInput.$result.content;
|
|
84
|
-
|
|
85
|
-
// Check for error markers in string content
|
|
86
|
-
if (typeof content === 'string') {
|
|
87
|
-
return content.toLowerCase().includes('error:');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Check for error markers in array content (MCP format)
|
|
91
|
-
if (Array.isArray(content)) {
|
|
92
|
-
const textBlock = (content as any[]).find((block: any) => block.type === 'text');
|
|
93
|
-
if (textBlock && textBlock.text) {
|
|
94
|
-
return textBlock.text.toLowerCase().includes('error:');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Check for isError property in object content
|
|
99
|
-
if (typeof content === 'object' && content !== null) {
|
|
100
|
-
return (content as any).isError === true;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return false;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Format input for display
|
|
107
|
-
const formattedInput = $derived(JSON.stringify(toolInput.input, null, 2));
|
|
108
|
-
</script>
|
|
109
|
-
|
|
110
|
-
<div class="mb-2">
|
|
111
|
-
<h3 class="text-slate-900 dark:text-slate-100 flex items-center gap-x-3 gap-y-1 flex-wrap">
|
|
112
|
-
<div class="flex items-center gap-1.5">
|
|
113
|
-
<Icon name="lucide:tool-case" class="w-4 h-4" />
|
|
114
|
-
<span>{serverDisplayName}</span>
|
|
115
|
-
</div>
|
|
116
|
-
<div class="flex items-center gap-1.5">
|
|
117
|
-
<Icon name="lucide:hammer" class="w-4 h-4" />
|
|
118
|
-
<span>{toolDisplayName}</span>
|
|
119
|
-
</div>
|
|
120
|
-
</h3>
|
|
121
|
-
</div>
|
|
122
|
-
|
|
123
|
-
<!-- Tool Input -->
|
|
124
|
-
{#if toolInput.input && Object.keys(toolInput.input).length > 0}
|
|
125
|
-
<div class="bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
126
|
-
<CodeBlock code={formattedInput} type="neutral" label="Input" />
|
|
127
|
-
</div>
|
|
128
|
-
{/if}
|
|
129
|
-
|
|
130
|
-
<!-- Tool Result -->
|
|
131
|
-
{#if resultContent}
|
|
132
|
-
<div class="mt-4 bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
133
|
-
<CodeBlock code={resultContent} type="neutral" label={isError ? 'Error' : 'Result'} />
|
|
134
|
-
<!-- {@html resultContent.replace(/\n/g, '<br>')} -->
|
|
135
|
-
</div>
|
|
136
|
-
{:else if toolInput.$result}
|
|
137
|
-
<!-- Empty result -->
|
|
138
|
-
<div class="mt-4 bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
139
|
-
<p class="text-sm text-slate-500 dark:text-slate-400 italic">No result returned</p>
|
|
140
|
-
</div>
|
|
141
|
-
{/if}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { EditToolInput } from '$shared/types/messaging';
|
|
3
|
-
import { FileHeader, DiffBlock } from './components';
|
|
4
|
-
import Icon from '$frontend/components/common/display/Icon.svelte';
|
|
5
|
-
|
|
6
|
-
const { toolInput }: { toolInput: EditToolInput } = $props();
|
|
7
|
-
|
|
8
|
-
const filePath = $derived(toolInput.input.file_path || '');
|
|
9
|
-
const fileName = $derived(filePath.split(/[/\\]/).pop() || filePath || 'unknown');
|
|
10
|
-
const oldString = $derived(toolInput.input.old_string || '');
|
|
11
|
-
const newString = $derived(toolInput.input.new_string || '');
|
|
12
|
-
const replaceAll = $derived(toolInput.input.replace_all || false);
|
|
13
|
-
|
|
14
|
-
const badges = $derived(replaceAll ? [{ text: 'Replace All', color: 'bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300' }] : []);
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<FileHeader
|
|
18
|
-
{filePath}
|
|
19
|
-
{fileName}
|
|
20
|
-
iconColor="text-emerald-600 dark:text-emerald-400"
|
|
21
|
-
{badges}
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
<!-- Replace All Info -->
|
|
25
|
-
<!-- {#if replaceAll}
|
|
26
|
-
<div class="mt-3 flex items-start gap-2 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-md p-3">
|
|
27
|
-
<Icon name="lucide:info" class="w-4 h-4 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5" />
|
|
28
|
-
<p class="text-xs text-amber-700 dark:text-amber-300">
|
|
29
|
-
This edit will replace <strong>all occurrences</strong> of the old string in the file. The actual file changes may affect multiple lines beyond what is shown in the diff preview below.
|
|
30
|
-
</p>
|
|
31
|
-
</div>
|
|
32
|
-
{/if} -->
|
|
33
|
-
|
|
34
|
-
<!-- Code Changes -->
|
|
35
|
-
<div class="mt-4">
|
|
36
|
-
<DiffBlock {oldString} {newString} label="Edit" />
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<!-- Tool Result -->
|
|
40
|
-
<!-- {#if toolInput.$result?.content}
|
|
41
|
-
<div class="mt-4 bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
42
|
-
{#if typeof toolInput.$result.content === 'string'}
|
|
43
|
-
<TextMessage content={toolInput.$result.content} />
|
|
44
|
-
{:else}
|
|
45
|
-
<TextMessage content={JSON.stringify(toolInput.$result.content)} />
|
|
46
|
-
{/if}
|
|
47
|
-
</div>
|
|
48
|
-
{/if} -->
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { EnterPlanModeToolInput } from '$shared/types/messaging';
|
|
3
|
-
import { InfoLine } from './components';
|
|
4
|
-
import TextMessage from '../formatters/TextMessage.svelte';
|
|
5
|
-
|
|
6
|
-
const { toolInput }: { toolInput: EnterPlanModeToolInput } = $props();
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<div class="bg-white dark:bg-slate-800 rounded-md border border-slate-200/60 dark:border-slate-700/60 p-3">
|
|
10
|
-
<div class="flex gap-3">
|
|
11
|
-
<InfoLine icon="lucide:map" text="Entering plan mode" />
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<!-- Tool Result -->
|
|
16
|
-
{#if toolInput.$result}
|
|
17
|
-
<div class="mt-4">
|
|
18
|
-
{#if typeof toolInput.$result.content === 'string'}
|
|
19
|
-
<TextMessage content={toolInput.$result.content} />
|
|
20
|
-
{:else}
|
|
21
|
-
<TextMessage content={JSON.stringify(toolInput.$result.content)} />
|
|
22
|
-
{/if}
|
|
23
|
-
</div>
|
|
24
|
-
{/if}
|