bingocode 1.0.3 → 1.0.5
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/package.json +3 -7
- package/desktop/README.md +0 -30
- package/desktop/bunfig.toml +0 -1
- package/desktop/index.html +0 -17
- package/desktop/package.json +0 -55
- package/desktop/pnpm-lock.yaml +0 -3832
- package/desktop/public/app-icon.jpg +0 -0
- package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/inter-latin.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin.woff2 +0 -0
- package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
- package/desktop/public/icons/bilibili.svg +0 -1
- package/desktop/public/icons/douyin.svg +0 -1
- package/desktop/public/icons/github.svg +0 -3
- package/desktop/public/icons/xiaohongshu.svg +0 -1
- package/desktop/scripts/build-macos-arm64.sh +0 -270
- package/desktop/scripts/build-sidecars.ts +0 -183
- package/desktop/scripts/build-windows-x64.ps1 +0 -295
- package/desktop/scripts/scan-missing-imports.ts +0 -235
- package/desktop/sidecars/claude-sidecar.ts +0 -156
- package/desktop/src/App.tsx +0 -5
- package/desktop/src/__tests__/agentsSettings.test.tsx +0 -349
- package/desktop/src/__tests__/pages.test.tsx +0 -290
- package/desktop/src/__tests__/skillsSettings.test.tsx +0 -205
- package/desktop/src/api/adapters.ts +0 -12
- package/desktop/src/api/agents.ts +0 -36
- package/desktop/src/api/cliTasks.ts +0 -28
- package/desktop/src/api/client.ts +0 -63
- package/desktop/src/api/computerUse.ts +0 -76
- package/desktop/src/api/filesystem.ts +0 -30
- package/desktop/src/api/hahaOAuth.ts +0 -38
- package/desktop/src/api/models.ts +0 -28
- package/desktop/src/api/providers.ts +0 -63
- package/desktop/src/api/search.ts +0 -29
- package/desktop/src/api/sessions.ts +0 -56
- package/desktop/src/api/settings.ts +0 -20
- package/desktop/src/api/skills.ts +0 -19
- package/desktop/src/api/tasks.ts +0 -36
- package/desktop/src/api/teams.ts +0 -44
- package/desktop/src/api/websocket.ts +0 -164
- package/desktop/src/components/chat/AskUserQuestion.tsx +0 -268
- package/desktop/src/components/chat/AssistantMessage.tsx +0 -29
- package/desktop/src/components/chat/AttachmentGallery.tsx +0 -113
- package/desktop/src/components/chat/ChatInput.tsx +0 -622
- package/desktop/src/components/chat/CodeViewer.tsx +0 -161
- package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +0 -174
- package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +0 -311
- package/desktop/src/components/chat/DiffViewer.tsx +0 -157
- package/desktop/src/components/chat/FileSearchMenu.tsx +0 -198
- package/desktop/src/components/chat/ImageGalleryModal.tsx +0 -91
- package/desktop/src/components/chat/InlineImageGallery.tsx +0 -106
- package/desktop/src/components/chat/InlineTaskSummary.tsx +0 -60
- package/desktop/src/components/chat/MermaidRenderer.test.tsx +0 -98
- package/desktop/src/components/chat/MermaidRenderer.tsx +0 -361
- package/desktop/src/components/chat/MessageActionBar.tsx +0 -27
- package/desktop/src/components/chat/MessageList.test.tsx +0 -313
- package/desktop/src/components/chat/MessageList.tsx +0 -249
- package/desktop/src/components/chat/PermissionDialog.tsx +0 -262
- package/desktop/src/components/chat/SessionTaskBar.test.tsx +0 -99
- package/desktop/src/components/chat/SessionTaskBar.tsx +0 -159
- package/desktop/src/components/chat/StreamingIndicator.tsx +0 -41
- package/desktop/src/components/chat/TerminalChrome.tsx +0 -35
- package/desktop/src/components/chat/ThinkingBlock.tsx +0 -87
- package/desktop/src/components/chat/ToolCallBlock.tsx +0 -247
- package/desktop/src/components/chat/ToolCallGroup.tsx +0 -617
- package/desktop/src/components/chat/ToolResultBlock.tsx +0 -107
- package/desktop/src/components/chat/UserMessage.tsx +0 -38
- package/desktop/src/components/chat/chatBlocks.test.tsx +0 -136
- package/desktop/src/components/chat/clipboard.ts +0 -25
- package/desktop/src/components/chat/composerUtils.test.ts +0 -55
- package/desktop/src/components/chat/composerUtils.ts +0 -149
- package/desktop/src/components/controls/ModelSelector.tsx +0 -156
- package/desktop/src/components/controls/PermissionModeSelector.tsx +0 -229
- package/desktop/src/components/layout/AppShell.tsx +0 -107
- package/desktop/src/components/layout/ContentRouter.tsx +0 -27
- package/desktop/src/components/layout/ProjectFilter.tsx +0 -126
- package/desktop/src/components/layout/Sidebar.test.tsx +0 -158
- package/desktop/src/components/layout/Sidebar.tsx +0 -384
- package/desktop/src/components/layout/StatusBar.tsx +0 -31
- package/desktop/src/components/layout/TabBar.test.tsx +0 -136
- package/desktop/src/components/layout/TabBar.tsx +0 -318
- package/desktop/src/components/layout/TitleBar.tsx +0 -96
- package/desktop/src/components/layout/WindowControls.test.tsx +0 -69
- package/desktop/src/components/layout/WindowControls.tsx +0 -89
- package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +0 -100
- package/desktop/src/components/markdown/MarkdownRenderer.tsx +0 -229
- package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +0 -107
- package/desktop/src/components/shared/Button.tsx +0 -63
- package/desktop/src/components/shared/CopyButton.tsx +0 -58
- package/desktop/src/components/shared/DirectoryPicker.tsx +0 -316
- package/desktop/src/components/shared/Dropdown.tsx +0 -91
- package/desktop/src/components/shared/Input.tsx +0 -38
- package/desktop/src/components/shared/Modal.tsx +0 -65
- package/desktop/src/components/shared/ProjectContextChip.tsx +0 -30
- package/desktop/src/components/shared/Spinner.tsx +0 -30
- package/desktop/src/components/shared/Textarea.tsx +0 -38
- package/desktop/src/components/shared/Toast.tsx +0 -47
- package/desktop/src/components/shared/UpdateChecker.tsx +0 -90
- package/desktop/src/components/skills/SkillDetail.test.tsx +0 -89
- package/desktop/src/components/skills/SkillDetail.tsx +0 -403
- package/desktop/src/components/skills/SkillList.tsx +0 -254
- package/desktop/src/components/tasks/DayOfWeekPicker.tsx +0 -57
- package/desktop/src/components/tasks/NewTaskModal.tsx +0 -407
- package/desktop/src/components/tasks/PromptEditor.tsx +0 -74
- package/desktop/src/components/tasks/TaskEmptyState.tsx +0 -30
- package/desktop/src/components/tasks/TaskList.tsx +0 -46
- package/desktop/src/components/tasks/TaskRow.tsx +0 -253
- package/desktop/src/components/tasks/TaskRunsPanel.tsx +0 -195
- package/desktop/src/components/teams/TeamStatusBar.tsx +0 -147
- package/desktop/src/config/providerPresets.ts +0 -78
- package/desktop/src/config/spinnerVerbs.ts +0 -193
- package/desktop/src/hooks/useKeyboardShortcuts.ts +0 -60
- package/desktop/src/i18n/index.ts +0 -54
- package/desktop/src/i18n/locales/en.ts +0 -670
- package/desktop/src/i18n/locales/zh.ts +0 -670
- package/desktop/src/lib/__tests__/cronDescribe.test.ts +0 -93
- package/desktop/src/lib/cronDescribe.ts +0 -188
- package/desktop/src/lib/desktopRuntime.ts +0 -54
- package/desktop/src/lib/parseRunOutput.ts +0 -79
- package/desktop/src/main.tsx +0 -13
- package/desktop/src/mocks/data.ts +0 -202
- package/desktop/src/pages/ActiveSession.test.tsx +0 -181
- package/desktop/src/pages/ActiveSession.tsx +0 -219
- package/desktop/src/pages/AdapterSettings.tsx +0 -375
- package/desktop/src/pages/AgentTeams.tsx +0 -200
- package/desktop/src/pages/ComputerUseSettings.tsx +0 -420
- package/desktop/src/pages/EmptySession.tsx +0 -518
- package/desktop/src/pages/NewTaskModal.tsx +0 -346
- package/desktop/src/pages/ScheduledTasks.tsx +0 -66
- package/desktop/src/pages/ScheduledTasksEmpty.tsx +0 -152
- package/desktop/src/pages/ScheduledTasksList.tsx +0 -416
- package/desktop/src/pages/SessionControls.tsx +0 -460
- package/desktop/src/pages/Settings.tsx +0 -1448
- package/desktop/src/pages/ToolInspection.tsx +0 -235
- package/desktop/src/stores/adapterStore.ts +0 -106
- package/desktop/src/stores/agentStore.ts +0 -34
- package/desktop/src/stores/chatStore.test.ts +0 -505
- package/desktop/src/stores/chatStore.ts +0 -850
- package/desktop/src/stores/cliTaskStore.ts +0 -152
- package/desktop/src/stores/hahaOAuthStore.test.ts +0 -77
- package/desktop/src/stores/hahaOAuthStore.ts +0 -97
- package/desktop/src/stores/providerStore.ts +0 -101
- package/desktop/src/stores/sessionStore.test.ts +0 -63
- package/desktop/src/stores/sessionStore.ts +0 -102
- package/desktop/src/stores/settingsStore.ts +0 -120
- package/desktop/src/stores/skillStore.ts +0 -51
- package/desktop/src/stores/tabStore.ts +0 -169
- package/desktop/src/stores/taskStore.ts +0 -68
- package/desktop/src/stores/teamStore.ts +0 -344
- package/desktop/src/stores/uiStore.ts +0 -100
- package/desktop/src/stores/updateStore.test.ts +0 -71
- package/desktop/src/stores/updateStore.ts +0 -221
- package/desktop/src/theme/globals.css +0 -465
- package/desktop/src/types/adapter.ts +0 -33
- package/desktop/src/types/chat.ts +0 -152
- package/desktop/src/types/cliTask.ts +0 -24
- package/desktop/src/types/provider.ts +0 -62
- package/desktop/src/types/session.ts +0 -27
- package/desktop/src/types/settings.ts +0 -22
- package/desktop/src/types/skill.ts +0 -38
- package/desktop/src/types/task.ts +0 -56
- package/desktop/src/types/team.ts +0 -38
- package/desktop/src-tauri/Cargo.lock +0 -5549
- package/desktop/src-tauri/Cargo.toml +0 -20
- package/desktop/src-tauri/app-icon.svg +0 -13
- package/desktop/src-tauri/build.rs +0 -3
- package/desktop/src-tauri/capabilities/default.json +0 -106
- package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +0 -4
- package/desktop/src-tauri/icons/icon.icns +0 -0
- package/desktop/src-tauri/icons/icon.ico +0 -0
- package/desktop/src-tauri/src/lib.rs +0 -408
- package/desktop/src-tauri/src/main.rs +0 -6
- package/desktop/src-tauri/tauri.conf.json +0 -78
- package/desktop/src-tauri/tauri.macos.conf.json +0 -18
- package/desktop/src-tauri/tauri.release-ci.json +0 -5
- package/desktop/src-tauri/tauri.windows.conf.json +0 -16
- package/desktop/src-tauri/windows-installer-hooks.nsh +0 -17
- package/desktop/tsconfig.json +0 -25
- package/desktop/vite.config.ts +0 -26
- package/desktop/vitest.config.ts +0 -18
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from 'react'
|
|
2
|
-
import { CodeViewer } from './CodeViewer'
|
|
3
|
-
import { DiffViewer } from './DiffViewer'
|
|
4
|
-
import { TerminalChrome } from './TerminalChrome'
|
|
5
|
-
import { CopyButton } from '../shared/CopyButton'
|
|
6
|
-
import { useTranslation } from '../../i18n'
|
|
7
|
-
import type { TranslationKey } from '../../i18n'
|
|
8
|
-
import { InlineImageGallery } from './InlineImageGallery'
|
|
9
|
-
import type { AgentTaskNotification } from '../../types/chat'
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
toolName: string
|
|
13
|
-
input: unknown
|
|
14
|
-
result?: { content: unknown; isError: boolean } | null
|
|
15
|
-
agentTaskNotification?: AgentTaskNotification
|
|
16
|
-
compact?: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const TOOL_ICONS: Record<string, string> = {
|
|
20
|
-
Bash: 'terminal',
|
|
21
|
-
Read: 'description',
|
|
22
|
-
Write: 'edit_document',
|
|
23
|
-
Edit: 'edit_note',
|
|
24
|
-
Glob: 'search',
|
|
25
|
-
Grep: 'find_in_page',
|
|
26
|
-
Agent: 'smart_toy',
|
|
27
|
-
WebSearch: 'travel_explore',
|
|
28
|
-
WebFetch: 'cloud_download',
|
|
29
|
-
NotebookEdit: 'note',
|
|
30
|
-
Skill: 'auto_awesome',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function ToolCallBlock({ toolName, input, result, compact = false }: Props) {
|
|
34
|
-
const [expanded, setExpanded] = useState(false)
|
|
35
|
-
const t = useTranslation()
|
|
36
|
-
const obj = input && typeof input === 'object' ? (input as Record<string, unknown>) : {}
|
|
37
|
-
const icon = TOOL_ICONS[toolName] || 'build'
|
|
38
|
-
const filePath = typeof obj.file_path === 'string' ? obj.file_path : ''
|
|
39
|
-
const summary = getToolSummary(toolName, obj, t)
|
|
40
|
-
const outputSummary = getToolResultSummary(toolName, result?.content, t)
|
|
41
|
-
|
|
42
|
-
const preview = useMemo(() => renderPreview(toolName, obj, result, t), [obj, result, toolName, t])
|
|
43
|
-
const details = useMemo(() => renderDetails(toolName, obj, t), [obj, toolName, t])
|
|
44
|
-
const hasResultDetails = Boolean(result && extractTextContent(result.content))
|
|
45
|
-
const expandable = toolName === 'Edit' || toolName === 'Write' || hasResultDetails
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div className={`overflow-hidden rounded-lg border border-[var(--color-border)]/50 bg-[var(--color-surface-container-lowest)] ${
|
|
49
|
-
compact ? 'mb-0' : 'mb-2 ml-10'
|
|
50
|
-
}`}>
|
|
51
|
-
<button
|
|
52
|
-
type="button"
|
|
53
|
-
onClick={() => {
|
|
54
|
-
if (expandable) {
|
|
55
|
-
setExpanded((value) => !value)
|
|
56
|
-
}
|
|
57
|
-
}}
|
|
58
|
-
className="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-[var(--color-surface-hover)]/50"
|
|
59
|
-
>
|
|
60
|
-
<span className="material-symbols-outlined text-[14px] text-[var(--color-outline)]">{icon}</span>
|
|
61
|
-
<span className="text-[11px] font-semibold text-[var(--color-text-secondary)]">
|
|
62
|
-
{toolName}
|
|
63
|
-
</span>
|
|
64
|
-
{filePath ? (
|
|
65
|
-
<span className="min-w-0 flex-1 truncate font-[var(--font-mono)] text-[11px] text-[var(--color-text-tertiary)]">
|
|
66
|
-
{filePath.split('/').pop()}
|
|
67
|
-
</span>
|
|
68
|
-
) : summary ? (
|
|
69
|
-
<span className="min-w-0 flex-1 truncate font-[var(--font-mono)] text-[11px] text-[var(--color-text-tertiary)]">
|
|
70
|
-
{summary}
|
|
71
|
-
</span>
|
|
72
|
-
) : (
|
|
73
|
-
<span className="flex-1" />
|
|
74
|
-
)}
|
|
75
|
-
{result && outputSummary && (
|
|
76
|
-
<span className="shrink-0 text-[10px] text-[var(--color-outline)]">
|
|
77
|
-
{outputSummary}
|
|
78
|
-
</span>
|
|
79
|
-
)}
|
|
80
|
-
{result?.isError && (
|
|
81
|
-
<span className="material-symbols-outlined shrink-0 text-[14px] text-[var(--color-error)]">error</span>
|
|
82
|
-
)}
|
|
83
|
-
{expandable && (
|
|
84
|
-
<span className="material-symbols-outlined text-[14px] text-[var(--color-outline)]">
|
|
85
|
-
{expanded ? 'expand_less' : 'expand_more'}
|
|
86
|
-
</span>
|
|
87
|
-
)}
|
|
88
|
-
</button>
|
|
89
|
-
|
|
90
|
-
{expandable && expanded && (
|
|
91
|
-
<div className="space-y-2.5 border-t border-[var(--color-border)]/60 px-3 py-3">
|
|
92
|
-
{preview}
|
|
93
|
-
{details}
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
|
-
</div>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function renderPreview(
|
|
101
|
-
toolName: string,
|
|
102
|
-
obj: Record<string, unknown>,
|
|
103
|
-
result?: { content: unknown; isError: boolean } | null,
|
|
104
|
-
t?: (key: TranslationKey, params?: Record<string, string | number>) => string,
|
|
105
|
-
) {
|
|
106
|
-
const filePath = typeof obj.file_path === 'string' ? obj.file_path : 'file'
|
|
107
|
-
|
|
108
|
-
if (toolName === 'Edit' && typeof obj.old_string === 'string' && typeof obj.new_string === 'string') {
|
|
109
|
-
return <DiffViewer filePath={filePath} oldString={obj.old_string} newString={obj.new_string} />
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (toolName === 'Write' && typeof obj.content === 'string') {
|
|
113
|
-
return <DiffViewer filePath={filePath} oldString="" newString={obj.content} />
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (toolName === 'Bash' && typeof obj.command === 'string') {
|
|
117
|
-
return (
|
|
118
|
-
<TerminalChrome title={typeof obj.description === 'string' ? obj.description : filePath}>
|
|
119
|
-
<div className="px-3 py-2.5 font-[var(--font-mono)] text-[11px] leading-[1.3] text-[var(--color-terminal-fg)]">
|
|
120
|
-
<span className="text-[var(--color-terminal-accent)]">$</span> {obj.command}
|
|
121
|
-
</div>
|
|
122
|
-
</TerminalChrome>
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (toolName === 'Read') {
|
|
127
|
-
return null
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (result) {
|
|
131
|
-
const text = extractTextContent(result.content)
|
|
132
|
-
if (text) {
|
|
133
|
-
return (
|
|
134
|
-
<>
|
|
135
|
-
<InlineImageGallery text={text} />
|
|
136
|
-
<div className={`overflow-hidden rounded-lg border ${
|
|
137
|
-
result.isError
|
|
138
|
-
? 'border-[var(--color-error)]/20 bg-[var(--color-error-container)]/60'
|
|
139
|
-
: 'border-[var(--color-border)] bg-[var(--color-surface)]'
|
|
140
|
-
}`}>
|
|
141
|
-
<div className="flex items-center justify-between border-b border-[var(--color-border)]/60 px-3 py-2 text-[10px] uppercase tracking-[0.18em] text-[var(--color-outline)]">
|
|
142
|
-
<span>{result.isError ? t?.('tool.errorOutput') ?? 'Error Output' : t?.('tool.toolOutput') ?? 'Tool Output'}</span>
|
|
143
|
-
<CopyButton
|
|
144
|
-
text={text}
|
|
145
|
-
className="rounded-md border border-[var(--color-border)] px-2 py-1 text-[10px] normal-case tracking-normal text-[var(--color-text-tertiary)] transition-colors hover:text-[var(--color-text-primary)]"
|
|
146
|
-
/>
|
|
147
|
-
</div>
|
|
148
|
-
<CodeViewer code={text} language="plaintext" maxLines={18} />
|
|
149
|
-
</div>
|
|
150
|
-
</>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return null
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function renderDetails(toolName: string, obj: Record<string, unknown>, t?: (key: TranslationKey, params?: Record<string, string | number>) => string) {
|
|
159
|
-
if (toolName === 'Edit' || toolName === 'Write') {
|
|
160
|
-
return null
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const text = JSON.stringify(obj, null, 2)
|
|
164
|
-
return (
|
|
165
|
-
<div className="overflow-hidden rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)]">
|
|
166
|
-
<div className="flex items-center justify-between border-b border-[var(--color-border)] px-3 py-2 text-[10px] uppercase tracking-[0.18em] text-[var(--color-outline)]">
|
|
167
|
-
<span>{t?.('tool.toolInput') ?? 'Tool Input'}</span>
|
|
168
|
-
<CopyButton
|
|
169
|
-
text={text}
|
|
170
|
-
className="rounded-md border border-[var(--color-border)] px-2 py-1 text-[10px] normal-case tracking-normal text-[var(--color-text-tertiary)] transition-colors hover:text-[var(--color-text-primary)]"
|
|
171
|
-
/>
|
|
172
|
-
</div>
|
|
173
|
-
<CodeViewer code={text} language="json" maxLines={18} />
|
|
174
|
-
</div>
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function getToolResultSummary(toolName: string, content: unknown, t?: (key: TranslationKey, params?: Record<string, string | number>) => string): string {
|
|
179
|
-
if (toolName === 'Bash') return ''
|
|
180
|
-
|
|
181
|
-
const text = extractTextContent(content)
|
|
182
|
-
if (!text) return ''
|
|
183
|
-
|
|
184
|
-
const lineCount = text.split('\n').length
|
|
185
|
-
if (lineCount > 1) {
|
|
186
|
-
return t?.('tool.linesOutput', { count: lineCount }) ?? `${lineCount} lines output`
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const compact = text.replace(/\s+/g, ' ').trim()
|
|
190
|
-
if (!compact) return ''
|
|
191
|
-
if (compact.length <= 36) return compact
|
|
192
|
-
return `${compact.slice(0, 36)}…`
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function getToolSummary(toolName: string, obj: Record<string, unknown>, t?: (key: TranslationKey, params?: Record<string, string | number>) => string): string {
|
|
196
|
-
switch (toolName) {
|
|
197
|
-
case 'Bash':
|
|
198
|
-
return typeof obj.command === 'string' ? obj.command : ''
|
|
199
|
-
case 'Read':
|
|
200
|
-
return t?.('tool.readFileContents') ?? 'Read file contents'
|
|
201
|
-
case 'Write':
|
|
202
|
-
return typeof obj.content === 'string'
|
|
203
|
-
? (t?.('tool.linesCreated', { count: obj.content.split('\n').length }) ?? `${obj.content.split('\n').length} lines created`)
|
|
204
|
-
: (t?.('tool.createFile') ?? 'Create file')
|
|
205
|
-
case 'Edit':
|
|
206
|
-
return typeof obj.old_string === 'string' && typeof obj.new_string === 'string'
|
|
207
|
-
? changedLineSummary(obj.old_string, obj.new_string, t)
|
|
208
|
-
: (t?.('tool.updateFileContents') ?? 'Update file contents')
|
|
209
|
-
case 'Glob':
|
|
210
|
-
return typeof obj.pattern === 'string' ? obj.pattern : ''
|
|
211
|
-
case 'Grep':
|
|
212
|
-
return typeof obj.pattern === 'string' ? obj.pattern : ''
|
|
213
|
-
case 'Agent':
|
|
214
|
-
return typeof obj.description === 'string' ? obj.description : ''
|
|
215
|
-
default:
|
|
216
|
-
return ''
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function extractTextContent(content: unknown): string | null {
|
|
221
|
-
if (typeof content === 'string') return content
|
|
222
|
-
if (Array.isArray(content)) {
|
|
223
|
-
return content
|
|
224
|
-
.map((chunk: any) => (typeof chunk === 'string' ? chunk : chunk?.text || ''))
|
|
225
|
-
.filter(Boolean)
|
|
226
|
-
.join('\n')
|
|
227
|
-
}
|
|
228
|
-
if (content && typeof content === 'object') {
|
|
229
|
-
return JSON.stringify(content, null, 2)
|
|
230
|
-
}
|
|
231
|
-
return null
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function changedLineSummary(oldString: string, newString: string, t?: (key: TranslationKey, params?: Record<string, string | number>) => string): string {
|
|
235
|
-
const oldLines = oldString.split('\n')
|
|
236
|
-
const newLines = newString.split('\n')
|
|
237
|
-
let changed = 0
|
|
238
|
-
const max = Math.max(oldLines.length, newLines.length)
|
|
239
|
-
|
|
240
|
-
for (let index = 0; index < max; index += 1) {
|
|
241
|
-
if ((oldLines[index] ?? '') !== (newLines[index] ?? '')) {
|
|
242
|
-
changed += 1
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return t?.('tool.linesChanged', { count: changed }) ?? `${changed} lines changed`
|
|
247
|
-
}
|