@vibe-forge/client 0.11.0 → 0.11.1
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/dist/assets/{arc-M4HYfcHs.js → arc-CSepokz3.js} +1 -1
- package/dist/assets/{blockDiagram-c4efeb88-CUrDjrxj.js → blockDiagram-c4efeb88-D0ARcoNf.js} +1 -1
- package/dist/assets/{c4Diagram-c83219d4-BMEtqlFp.js → c4Diagram-c83219d4-BysYF9kP.js} +1 -1
- package/dist/assets/channel-CeKPk6Nd.js +1 -0
- package/dist/assets/{classDiagram-beda092f-BOmDJ0Ml.js → classDiagram-beda092f-BG1GhIOL.js} +1 -1
- package/dist/assets/{classDiagram-v2-2358418a-BODzX2MB.js → classDiagram-v2-2358418a-Dd08uGSH.js} +1 -1
- package/dist/assets/clone-CrkD2PuD.js +1 -0
- package/dist/assets/{createText-1719965b-B9Dd8zcR.js → createText-1719965b-CigPEIEn.js} +1 -1
- package/dist/assets/{cssMode-DLxG92Ot.js → cssMode-MjflyEfm.js} +1 -1
- package/dist/assets/{edges-96097737-CuZFd43m.js → edges-96097737-DuTBJJRv.js} +1 -1
- package/dist/assets/{erDiagram-0228fc6a-8g9lu2-Z.js → erDiagram-0228fc6a-Cp1bL7Y7.js} +1 -1
- package/dist/assets/{flowDb-c6c81e3f-BlBS1tdN.js → flowDb-c6c81e3f-BfKbhiq5.js} +1 -1
- package/dist/assets/{flowDiagram-50d868cf-u6mWflpF.js → flowDiagram-50d868cf-m7gGc3PK.js} +1 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-4ZU4bdp1.js +1 -0
- package/dist/assets/{flowchart-elk-definition-6af322e1-BDqI2NFr.js → flowchart-elk-definition-6af322e1-EVeTDRRK.js} +1 -1
- package/dist/assets/{freemarker2-tVtpTMPu.js → freemarker2-Bb3-QAIN.js} +1 -1
- package/dist/assets/{ganttDiagram-a2739b55-CDQjx9Wu.js → ganttDiagram-a2739b55-DslB2U0R.js} +1 -1
- package/dist/assets/{gitGraphDiagram-82fe8481-DUHFKRVA.js → gitGraphDiagram-82fe8481-C-KFWMXL.js} +1 -1
- package/dist/assets/{graph-2HKPi5B_.js → graph-CukaUc0o.js} +1 -1
- package/dist/assets/{handlebars-D00tgNd8.js → handlebars-C4le-2Y6.js} +1 -1
- package/dist/assets/{html-B-TDzBiR.js → html-CjNiRs5S.js} +1 -1
- package/dist/assets/{htmlMode-ClycqSTM.js → htmlMode-B73_3-We.js} +1 -1
- package/dist/assets/{index-5325376f-DPrJpRQ-.js → index-5325376f-CVISZFPw.js} +1 -1
- package/dist/assets/{index-CAHZZEoo.js → index-BZosmb5_.js} +330 -326
- package/dist/assets/index-C1oh0w9H.css +32 -0
- package/dist/assets/{infoDiagram-8eee0895-Co5tS1I5.js → infoDiagram-8eee0895-DoirLE1K.js} +1 -1
- package/dist/assets/{javascript-zbkwarmb.js → javascript-BDjnqJFP.js} +1 -1
- package/dist/assets/{journeyDiagram-c64418c1-k_qioHgy.js → journeyDiagram-c64418c1-Ckn-p2CM.js} +1 -1
- package/dist/assets/{jsonMode-C3CSpzBF.js → jsonMode-C-ftOc5j.js} +1 -1
- package/dist/assets/{layout-CjOXKxvs.js → layout-Z7yUG7hB.js} +1 -1
- package/dist/assets/{line-C-XnQrKR.js → line-DPG_cfAy.js} +1 -1
- package/dist/assets/{linear-C7MMERzS.js → linear--GSeVfMi.js} +1 -1
- package/dist/assets/{liquid-5G37EU6K.js → liquid-COiLZ9py.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-zaDMuhCE.js → lspLanguageFeatures-DGmhryFq.js} +1 -1
- package/dist/assets/{mdx-Bc-LY0gi.js → mdx-BpL87Gej.js} +1 -1
- package/dist/assets/{mermaid.core-CechbHof.js → mermaid.core-Cg1CCDo6.js} +4 -4
- package/dist/assets/{mindmap-definition-8da855dc-ejftCDGb.js → mindmap-definition-8da855dc-CKDof1lD.js} +1 -1
- package/dist/assets/{pieDiagram-a8764435-DY__X3Qj.js → pieDiagram-a8764435-DwvCaZVE.js} +1 -1
- package/dist/assets/{python-vK2Ff2J5.js → python-63dBmWV_.js} +1 -1
- package/dist/assets/{quadrantDiagram-1e28029f-azIZCv_2.js → quadrantDiagram-1e28029f-CkzYBQpy.js} +1 -1
- package/dist/assets/{razor-BipjBJKu.js → razor-C50tBqEZ.js} +1 -1
- package/dist/assets/{requirementDiagram-08caed73-C4EB0Xs2.js → requirementDiagram-08caed73-Brgdjqf4.js} +1 -1
- package/dist/assets/{sankeyDiagram-a04cb91d-PNhR6YWu.js → sankeyDiagram-a04cb91d-CGkYexrs.js} +1 -1
- package/dist/assets/{sequenceDiagram-c5b8d532-4c-qV-Ri.js → sequenceDiagram-c5b8d532-D0wE-_J8.js} +1 -1
- package/dist/assets/{stateDiagram-1ecb1508-CnURumPE.js → stateDiagram-1ecb1508-BYb3NCXZ.js} +1 -1
- package/dist/assets/{stateDiagram-v2-c2b004d7-DR2qHTPg.js → stateDiagram-v2-c2b004d7-DrPqi4Pt.js} +1 -1
- package/dist/assets/{styles-b4e223ce-B2PWXT_i.js → styles-b4e223ce-DD66TIO4.js} +1 -1
- package/dist/assets/{styles-ca3715f6-DEhgVF5H.js → styles-ca3715f6-iy02LHIV.js} +1 -1
- package/dist/assets/{styles-d45a18b0-DyzccA5F.js → styles-d45a18b0-BgqAgJyW.js} +1 -1
- package/dist/assets/{svgDrawCommon-b86b1483-C_1tMhxp.js → svgDrawCommon-b86b1483-CDq7ugnw.js} +1 -1
- package/dist/assets/{timeline-definition-faaaa080-FdaC0dQH.js → timeline-definition-faaaa080-DzcLLjK0.js} +1 -1
- package/dist/assets/{tsMode-CrMC5T3_.js → tsMode-BFRFI4ct.js} +1 -1
- package/dist/assets/{typescript-CRfPu8v7.js → typescript-CBZQRAPv.js} +1 -1
- package/dist/assets/{xml-jlRvQfFI.js → xml-BpWm6upt.js} +1 -1
- package/dist/assets/{xychartDiagram-f5964ef8-sxjv75h9.js → xychartDiagram-f5964ef8-zBN8FmLQ.js} +1 -1
- package/dist/assets/{yaml-B47_IHOH.js → yaml-CqbJPiIP.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +6 -6
- package/src/api/git.ts +78 -0
- package/src/api.ts +24 -0
- package/src/components/chat/ChatHeader.tsx +4 -0
- package/src/components/chat/git-controls/BranchSwitcherDropdown.tsx +157 -0
- package/src/components/chat/git-controls/ChatGitControls.scss +616 -0
- package/src/components/chat/git-controls/ChatGitControls.tsx +151 -0
- package/src/components/chat/git-controls/GitCommitModal.tsx +199 -0
- package/src/components/chat/git-controls/GitCommitModalParts.tsx +151 -0
- package/src/components/chat/git-controls/GitOperationsDropdown.tsx +123 -0
- package/src/components/chat/git-controls/GitPushModal.tsx +106 -0
- package/src/components/chat/git-controls/GitWorktreeDropdown.tsx +68 -0
- package/src/components/chat/git-controls/git-branch-utils.ts +88 -0
- package/src/components/chat/git-controls/git-commit-utils.ts +79 -0
- package/src/components/chat/git-controls/git-mutation-utils.ts +69 -0
- package/src/components/chat/git-controls/git-operation-utils.ts +98 -0
- package/src/components/chat/git-controls/git-worktree-utils.ts +49 -0
- package/src/components/chat/git-controls/use-chat-git-commit.ts +185 -0
- package/src/components/chat/git-controls/use-chat-git-controls.ts +200 -0
- package/src/components/chat/git-controls/use-chat-git-push-state.ts +19 -0
- package/src/components/chat/git-controls/use-chat-git-worktrees.ts +39 -0
- package/src/components/chat/tools/DefaultTool.tsx +40 -31
- package/src/components/chat/tools/adapter-claude/GenericClaudeTool.tsx +1 -15
- package/src/components/chat/tools/adapter-claude/claude-tool-edit-builders.ts +8 -1
- package/src/components/chat/tools/adapter-claude/claude-tool-field-sections.tsx +10 -95
- package/src/components/chat/tools/core/ToolCallBox.scss +18 -0
- package/src/components/chat/tools/core/generic-tool-presentation.ts +661 -0
- package/src/components/chat/tools/core/tool-display.ts +12 -1
- package/src/components/chat/tools/core/tool-field-sections.tsx +132 -0
- package/src/components/chat/tools/core/tool-summary.ts +18 -6
- package/src/components/chat/tools/plugin-chrome-devtools/ChromeDevtoolsTool.tsx +0 -7
- package/src/hooks/chat/session-view-cache.ts +80 -0
- package/src/hooks/chat/use-chat-session-messages.ts +124 -30
- package/src/resources/locales/en.json +68 -0
- package/src/resources/locales/zh.json +68 -0
- package/dist/assets/channel-Cj3Cp2OJ.js +0 -1
- package/dist/assets/clone-B7Q9B1dS.js +0 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-G3v545eF.js +0 -1
- package/dist/assets/index-Di7lePfb.css +0 -32
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
|
|
3
|
+
import type { ToolDiffMetaItem } from './ToolDiffViewer'
|
|
4
|
+
import type { ToolFieldView } from './tool-field-sections'
|
|
5
|
+
|
|
6
|
+
const WINDOWS_PATH_RE = /^[a-z]:[\\/]+/i
|
|
7
|
+
const PATH_KEY_SET = new Set(['cwd', 'dir', 'directory', 'filePath', 'file_path', 'path', 'workdir'])
|
|
8
|
+
const MULTILINE_CODE_KEY_SET = new Set([
|
|
9
|
+
'command',
|
|
10
|
+
'content',
|
|
11
|
+
'input',
|
|
12
|
+
'newString',
|
|
13
|
+
'new_string',
|
|
14
|
+
'oldString',
|
|
15
|
+
'old_string',
|
|
16
|
+
'output',
|
|
17
|
+
'patch',
|
|
18
|
+
'stderr',
|
|
19
|
+
'stdout'
|
|
20
|
+
])
|
|
21
|
+
const LIST_KEY_SET = new Set(['changes', 'entries', 'files', 'matches', 'results', 'todos'])
|
|
22
|
+
|
|
23
|
+
interface ToolMeta {
|
|
24
|
+
titleKey?: string
|
|
25
|
+
fallbackTitle: string
|
|
26
|
+
icon: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface GenericToolDiffView {
|
|
30
|
+
original: string
|
|
31
|
+
modified: string
|
|
32
|
+
language?: string
|
|
33
|
+
metaItems?: Array<{
|
|
34
|
+
labelKey: string
|
|
35
|
+
fallbackLabel: string
|
|
36
|
+
value?: string
|
|
37
|
+
tone?: ToolDiffMetaItem['tone']
|
|
38
|
+
icon?: string
|
|
39
|
+
}>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface GenericToolPresentation {
|
|
43
|
+
titleKey?: string
|
|
44
|
+
fallbackTitle: string
|
|
45
|
+
icon: string
|
|
46
|
+
primary?: string
|
|
47
|
+
inlineFields: ToolFieldView[]
|
|
48
|
+
blockFields: ToolFieldView[]
|
|
49
|
+
diff?: GenericToolDiffView
|
|
50
|
+
suppressSuccessResult?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => (
|
|
54
|
+
value != null && typeof value === 'object' && !Array.isArray(value)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const asString = (value: unknown) => (
|
|
58
|
+
typeof value === 'string' && value.trim() !== '' ? value : undefined
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const asNumber = (value: unknown) => (
|
|
62
|
+
typeof value === 'number' && Number.isFinite(value) ? value : undefined
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const asBoolean = (value: unknown) => (
|
|
66
|
+
typeof value === 'boolean' ? value : undefined
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const normalizeToolPath = (value: string) => value.replace(/\\/g, '/')
|
|
70
|
+
|
|
71
|
+
const getFileInfo = (filePath?: string) => {
|
|
72
|
+
const resolvedPath = (filePath != null && filePath !== '') ? filePath : 'unknown file'
|
|
73
|
+
const normalizedPath = normalizeToolPath(resolvedPath)
|
|
74
|
+
const lastSlashIndex = normalizedPath.lastIndexOf('/')
|
|
75
|
+
const fileName = lastSlashIndex >= 0 ? normalizedPath.slice(lastSlashIndex + 1) : normalizedPath
|
|
76
|
+
const dirPath = lastSlashIndex >= 0 ? normalizedPath.slice(0, lastSlashIndex) : ''
|
|
77
|
+
|
|
78
|
+
return { filePath: normalizedPath, fileName, dirPath }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const getLanguageFromPath = (path: string) => {
|
|
82
|
+
const extPart = path.split('.').pop()
|
|
83
|
+
const ext = (extPart != null && extPart !== '') ? extPart.toLowerCase() : ''
|
|
84
|
+
const langMap: Record<string, string> = {
|
|
85
|
+
'css': 'css',
|
|
86
|
+
'diff': 'diff',
|
|
87
|
+
'html': 'html',
|
|
88
|
+
'js': 'javascript',
|
|
89
|
+
'json': 'json',
|
|
90
|
+
'jsx': 'jsx',
|
|
91
|
+
'md': 'markdown',
|
|
92
|
+
'py': 'python',
|
|
93
|
+
'scss': 'scss',
|
|
94
|
+
'sh': 'bash',
|
|
95
|
+
'sql': 'sql',
|
|
96
|
+
'ts': 'typescript',
|
|
97
|
+
'tsx': 'tsx',
|
|
98
|
+
'yaml': 'yaml',
|
|
99
|
+
'yml': 'yaml'
|
|
100
|
+
}
|
|
101
|
+
return langMap[ext] ?? 'text'
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const humanizeToolSegment = (value: string) => (
|
|
105
|
+
value
|
|
106
|
+
.replace(/[_:-]+/g, ' ')
|
|
107
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
108
|
+
.trim()
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
const formatToolName = (name: string) => {
|
|
112
|
+
if (name.startsWith('mcp__ChromeDevtools__')) {
|
|
113
|
+
return name.replace('mcp__ChromeDevtools__', '')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const namespaceSegments = name.includes('__') ? name.split('__').filter(Boolean) : []
|
|
117
|
+
const lastSegment = namespaceSegments.length > 0
|
|
118
|
+
? namespaceSegments[namespaceSegments.length - 1]
|
|
119
|
+
: name.split(':').pop() ?? name
|
|
120
|
+
return humanizeToolSegment(lastSegment)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const normalizeToolKey = (name: string) => (
|
|
124
|
+
formatToolName(name).replace(/[^a-z0-9]+/gi, '').toLowerCase()
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
const toFieldKey = (value: string) => (
|
|
128
|
+
value
|
|
129
|
+
.replace(/^[^a-z0-9]+/i, '')
|
|
130
|
+
.replace(/[_-]+([a-z0-9])/gi, (_, char: string) => char.toUpperCase())
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
const toFallbackLabel = (value: string) => {
|
|
134
|
+
const humanized = humanizeToolSegment(value)
|
|
135
|
+
if (humanized === '') return value
|
|
136
|
+
return humanized.charAt(0).toUpperCase() + humanized.slice(1)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const getFieldDescriptor = (key: string, fallbackLabel?: string) => {
|
|
140
|
+
const normalizedKey = toFieldKey(key)
|
|
141
|
+
return {
|
|
142
|
+
labelKey: `chat.tools.fields.${normalizedKey}`,
|
|
143
|
+
fallbackLabel: fallbackLabel ?? toFallbackLabel(key)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const pushField = (
|
|
148
|
+
fields: ToolFieldView[],
|
|
149
|
+
usedKeys: Set<string>,
|
|
150
|
+
key: string,
|
|
151
|
+
field: ToolFieldView
|
|
152
|
+
) => {
|
|
153
|
+
const { value } = field
|
|
154
|
+
if (value == null || value === '') {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
if (isRecord(value) && Object.keys(value).length === 0) {
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
usedKeys.add(key)
|
|
165
|
+
fields.push(field)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const isPathLikeValue = (value: string) => (
|
|
169
|
+
value.startsWith('/') ||
|
|
170
|
+
value.startsWith('./') ||
|
|
171
|
+
value.startsWith('../') ||
|
|
172
|
+
WINDOWS_PATH_RE.test(value) ||
|
|
173
|
+
(value.includes('/') && !value.includes(' '))
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const getFirstLine = (value: string | undefined) => value?.split('\n')[0]?.trim()
|
|
177
|
+
|
|
178
|
+
const looksLikeCode = (key: string, value: string) => {
|
|
179
|
+
if (MULTILINE_CODE_KEY_SET.has(key)) return true
|
|
180
|
+
if (value.includes('*** Begin Patch')) return true
|
|
181
|
+
return /[{}();=<>]|^diff --git/m.test(value)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const isPrimitiveList = (value: unknown[]) =>
|
|
185
|
+
value.every(item => (
|
|
186
|
+
typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean'
|
|
187
|
+
))
|
|
188
|
+
|
|
189
|
+
const getChangeLines = (value: unknown) => {
|
|
190
|
+
if (!Array.isArray(value)) return undefined
|
|
191
|
+
const lines = value.flatMap((change) => {
|
|
192
|
+
if (!isRecord(change)) return []
|
|
193
|
+
const kind = asString(change.kind) ?? 'change'
|
|
194
|
+
const path = asString(change.path) ?? asString(change.file_path) ?? asString(change.filePath)
|
|
195
|
+
if (path == null) return []
|
|
196
|
+
return [`${kind} ${path}`]
|
|
197
|
+
})
|
|
198
|
+
return lines.length > 0 ? lines : undefined
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const getPatchTargets = (patch: string) => {
|
|
202
|
+
const matches = Array.from(
|
|
203
|
+
patch.matchAll(/^\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm),
|
|
204
|
+
match => match[1]?.trim()
|
|
205
|
+
).filter((value): value is string => typeof value === 'string' && value !== '')
|
|
206
|
+
|
|
207
|
+
if (matches.length > 0) {
|
|
208
|
+
return matches
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return Array.from(
|
|
212
|
+
patch.matchAll(/^\+\+\+ b\/(.+)$/gm),
|
|
213
|
+
match => match[1]?.trim()
|
|
214
|
+
).filter((value): value is string => typeof value === 'string' && value !== '')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const getGenericToolMeta = (name: string): ToolMeta => {
|
|
218
|
+
const normalizedKey = normalizeToolKey(name)
|
|
219
|
+
|
|
220
|
+
if (normalizedKey === 'applypatch') {
|
|
221
|
+
return { fallbackTitle: 'Apply Patch', icon: 'difference' }
|
|
222
|
+
}
|
|
223
|
+
if (normalizedKey === 'bash' || normalizedKey === 'execcommand') {
|
|
224
|
+
return { titleKey: 'chat.tools.bash', fallbackTitle: 'Bash', icon: 'terminal' }
|
|
225
|
+
}
|
|
226
|
+
if (normalizedKey === 'edit' || normalizedKey === 'editfile') {
|
|
227
|
+
return { titleKey: 'chat.tools.editTool', fallbackTitle: 'Edit File', icon: 'edit' }
|
|
228
|
+
}
|
|
229
|
+
if (normalizedKey === 'filechange') {
|
|
230
|
+
return { fallbackTitle: 'File Change', icon: 'difference' }
|
|
231
|
+
}
|
|
232
|
+
if (normalizedKey === 'glob') {
|
|
233
|
+
return { titleKey: 'chat.tools.globTool', fallbackTitle: 'Glob', icon: 'search' }
|
|
234
|
+
}
|
|
235
|
+
if (normalizedKey === 'grep') {
|
|
236
|
+
return { titleKey: 'chat.tools.grepTool', fallbackTitle: 'Grep', icon: 'find_in_page' }
|
|
237
|
+
}
|
|
238
|
+
if (normalizedKey === 'listdir' || normalizedKey === 'ls') {
|
|
239
|
+
return { titleKey: 'chat.tools.lsTool', fallbackTitle: 'List Directory', icon: 'folder_open' }
|
|
240
|
+
}
|
|
241
|
+
if (normalizedKey === 'read' || normalizedKey === 'readfile') {
|
|
242
|
+
return { titleKey: 'chat.tools.read', fallbackTitle: 'Read File', icon: 'visibility' }
|
|
243
|
+
}
|
|
244
|
+
if (normalizedKey === 'viewimage') {
|
|
245
|
+
return { fallbackTitle: 'View Image', icon: 'image' }
|
|
246
|
+
}
|
|
247
|
+
if (normalizedKey === 'webfetch') {
|
|
248
|
+
return { titleKey: 'chat.tools.webFetch', fallbackTitle: 'Web Fetch', icon: 'language' }
|
|
249
|
+
}
|
|
250
|
+
if (normalizedKey === 'websearch') {
|
|
251
|
+
return { titleKey: 'chat.tools.webSearch', fallbackTitle: 'Web Search', icon: 'travel_explore' }
|
|
252
|
+
}
|
|
253
|
+
if (normalizedKey === 'write' || normalizedKey === 'writefile') {
|
|
254
|
+
return { titleKey: 'chat.tools.write', fallbackTitle: 'Write File', icon: 'edit_note' }
|
|
255
|
+
}
|
|
256
|
+
if (name.startsWith('mcp__') || name.includes(':mcp:')) {
|
|
257
|
+
return { fallbackTitle: formatToolName(name), icon: 'extension' }
|
|
258
|
+
}
|
|
259
|
+
if (name.startsWith('plugin__')) {
|
|
260
|
+
return { fallbackTitle: formatToolName(name), icon: 'extension' }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return { fallbackTitle: formatToolName(name), icon: 'build' }
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const getPrimaryFromRecord = (record: Record<string, unknown>) => {
|
|
267
|
+
const preferredKeys = [
|
|
268
|
+
'file_path',
|
|
269
|
+
'filePath',
|
|
270
|
+
'path',
|
|
271
|
+
'url',
|
|
272
|
+
'query',
|
|
273
|
+
'pattern',
|
|
274
|
+
'command',
|
|
275
|
+
'selector',
|
|
276
|
+
'taskId',
|
|
277
|
+
'subject',
|
|
278
|
+
'title'
|
|
279
|
+
]
|
|
280
|
+
|
|
281
|
+
for (const key of preferredKeys) {
|
|
282
|
+
const value = asString(record[key])
|
|
283
|
+
if (value != null) {
|
|
284
|
+
return getFirstLine(value)
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
for (const value of Object.values(record)) {
|
|
289
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
290
|
+
const firstLine = getFirstLine(value)
|
|
291
|
+
if (firstLine != null && firstLine !== '' && !firstLine.startsWith('*** Begin Patch')) {
|
|
292
|
+
return firstLine
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return undefined
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const addRemainingRecordFields = (
|
|
301
|
+
blockFields: ToolFieldView[],
|
|
302
|
+
inlineFields: ToolFieldView[],
|
|
303
|
+
record: Record<string, unknown>,
|
|
304
|
+
usedKeys: Set<string>
|
|
305
|
+
) => {
|
|
306
|
+
for (const [key, value] of Object.entries(record)) {
|
|
307
|
+
if (usedKeys.has(key) || value == null) {
|
|
308
|
+
continue
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const descriptor = getFieldDescriptor(key)
|
|
312
|
+
if (typeof value === 'string') {
|
|
313
|
+
const trimmed = value.trim()
|
|
314
|
+
if (trimmed === '') {
|
|
315
|
+
continue
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (!trimmed.includes('\n') && trimmed.length <= 80) {
|
|
319
|
+
pushField(inlineFields, usedKeys, key, {
|
|
320
|
+
...descriptor,
|
|
321
|
+
format: 'inline',
|
|
322
|
+
value: trimmed
|
|
323
|
+
})
|
|
324
|
+
continue
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
pushField(blockFields, usedKeys, key, {
|
|
328
|
+
...descriptor,
|
|
329
|
+
format: looksLikeCode(key, trimmed) ? 'code' : 'text',
|
|
330
|
+
value: trimmed,
|
|
331
|
+
lang: key === 'patch' ? 'diff' : undefined
|
|
332
|
+
})
|
|
333
|
+
continue
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
337
|
+
pushField(inlineFields, usedKeys, key, {
|
|
338
|
+
...descriptor,
|
|
339
|
+
format: 'inline',
|
|
340
|
+
value
|
|
341
|
+
})
|
|
342
|
+
continue
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (Array.isArray(value)) {
|
|
346
|
+
if (value.length === 0) {
|
|
347
|
+
continue
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const changeLines = key === 'changes' ? getChangeLines(value) : undefined
|
|
351
|
+
if (changeLines != null) {
|
|
352
|
+
pushField(blockFields, usedKeys, key, {
|
|
353
|
+
...descriptor,
|
|
354
|
+
format: 'list',
|
|
355
|
+
value: changeLines
|
|
356
|
+
})
|
|
357
|
+
continue
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (LIST_KEY_SET.has(key) && isPrimitiveList(value)) {
|
|
361
|
+
pushField(blockFields, usedKeys, key, {
|
|
362
|
+
...descriptor,
|
|
363
|
+
format: 'list',
|
|
364
|
+
value: value.map(item => String(item))
|
|
365
|
+
})
|
|
366
|
+
continue
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
pushField(blockFields, usedKeys, key, {
|
|
370
|
+
...descriptor,
|
|
371
|
+
format: 'json',
|
|
372
|
+
value
|
|
373
|
+
})
|
|
374
|
+
continue
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (isRecord(value)) {
|
|
378
|
+
pushField(blockFields, usedKeys, key, {
|
|
379
|
+
...descriptor,
|
|
380
|
+
format: 'json',
|
|
381
|
+
value
|
|
382
|
+
})
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const buildPrimitiveInputPresentation = (
|
|
388
|
+
input: unknown,
|
|
389
|
+
meta: ToolMeta
|
|
390
|
+
): GenericToolPresentation => {
|
|
391
|
+
const blockFields: ToolFieldView[] = []
|
|
392
|
+
|
|
393
|
+
if (typeof input === 'string' && input.trim() !== '') {
|
|
394
|
+
const trimmed = input.trim()
|
|
395
|
+
pushField(blockFields, new Set<string>(), 'input', {
|
|
396
|
+
...getFieldDescriptor('input', 'Input'),
|
|
397
|
+
format: trimmed.includes('\n') || looksLikeCode('input', trimmed) ? 'code' : 'text',
|
|
398
|
+
value: trimmed
|
|
399
|
+
})
|
|
400
|
+
} else if (Array.isArray(input) && input.length > 0) {
|
|
401
|
+
pushField(blockFields, new Set<string>(), 'input', {
|
|
402
|
+
...getFieldDescriptor('input', 'Input'),
|
|
403
|
+
format: isPrimitiveList(input) ? 'list' : 'json',
|
|
404
|
+
value: isPrimitiveList(input) ? input.map(item => String(item)) : input
|
|
405
|
+
})
|
|
406
|
+
} else if (input != null) {
|
|
407
|
+
pushField(blockFields, new Set<string>(), 'input', {
|
|
408
|
+
...getFieldDescriptor('input', 'Input'),
|
|
409
|
+
format: 'json',
|
|
410
|
+
value: input
|
|
411
|
+
})
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
...meta,
|
|
416
|
+
primary: typeof input === 'string' && input.trim() !== '' ? getFirstLine(input.trim()) : undefined,
|
|
417
|
+
inlineFields: [],
|
|
418
|
+
blockFields
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function buildGenericToolPresentation(name: string, input: unknown): GenericToolPresentation {
|
|
423
|
+
const meta = getGenericToolMeta(name)
|
|
424
|
+
if (!isRecord(input)) {
|
|
425
|
+
return buildPrimitiveInputPresentation(input, meta)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const record = input
|
|
429
|
+
const inlineFields: ToolFieldView[] = []
|
|
430
|
+
const blockFields: ToolFieldView[] = []
|
|
431
|
+
const usedKeys = new Set<string>()
|
|
432
|
+
const normalizedKey = normalizeToolKey(name)
|
|
433
|
+
let primary: string | undefined
|
|
434
|
+
let diff: GenericToolDiffView | undefined
|
|
435
|
+
let suppressSuccessResult = false
|
|
436
|
+
|
|
437
|
+
if (normalizedKey === 'bash' || normalizedKey === 'execcommand') {
|
|
438
|
+
const command = asString(record.command)
|
|
439
|
+
primary = getFirstLine(command)
|
|
440
|
+
pushField(inlineFields, usedKeys, 'cwd', {
|
|
441
|
+
...getFieldDescriptor('cwd', 'Cwd'),
|
|
442
|
+
format: 'inline',
|
|
443
|
+
value: asString(record.cwd)
|
|
444
|
+
})
|
|
445
|
+
pushField(inlineFields, usedKeys, 'workdir', {
|
|
446
|
+
...getFieldDescriptor('workdir', 'Workdir'),
|
|
447
|
+
format: 'inline',
|
|
448
|
+
value: asString(record.workdir)
|
|
449
|
+
})
|
|
450
|
+
pushField(inlineFields, usedKeys, 'timeoutMs', {
|
|
451
|
+
...getFieldDescriptor('timeoutMs', 'Timeout'),
|
|
452
|
+
format: 'inline',
|
|
453
|
+
value: asNumber(record.timeoutMs)
|
|
454
|
+
})
|
|
455
|
+
pushField(inlineFields, usedKeys, 'yield_time_ms', {
|
|
456
|
+
...getFieldDescriptor('yieldTimeMs', 'Yield Time'),
|
|
457
|
+
format: 'inline',
|
|
458
|
+
value: asNumber(record.yield_time_ms)
|
|
459
|
+
})
|
|
460
|
+
pushField(inlineFields, usedKeys, 'max_output_tokens', {
|
|
461
|
+
...getFieldDescriptor('maxOutputTokens', 'Max Output Tokens'),
|
|
462
|
+
format: 'inline',
|
|
463
|
+
value: asNumber(record.max_output_tokens)
|
|
464
|
+
})
|
|
465
|
+
if (command != null && command.includes('\n')) {
|
|
466
|
+
pushField(blockFields, usedKeys, 'command', {
|
|
467
|
+
...getFieldDescriptor('command'),
|
|
468
|
+
format: 'code',
|
|
469
|
+
value: command,
|
|
470
|
+
lang: 'bash'
|
|
471
|
+
})
|
|
472
|
+
} else {
|
|
473
|
+
usedKeys.add('command')
|
|
474
|
+
}
|
|
475
|
+
} else if (normalizedKey === 'read' || normalizedKey === 'readfile' || normalizedKey === 'viewimage') {
|
|
476
|
+
const pathValue = asString(record.path) ?? asString(record.file_path)
|
|
477
|
+
primary = pathValue != null ? getFileInfo(pathValue).filePath : undefined
|
|
478
|
+
pushField(inlineFields, usedKeys, 'startLine', {
|
|
479
|
+
...getFieldDescriptor('startLine', 'Start Line'),
|
|
480
|
+
format: 'inline',
|
|
481
|
+
value: asNumber(record.startLine)
|
|
482
|
+
})
|
|
483
|
+
pushField(inlineFields, usedKeys, 'endLine', {
|
|
484
|
+
...getFieldDescriptor('endLine', 'End Line'),
|
|
485
|
+
format: 'inline',
|
|
486
|
+
value: asNumber(record.endLine)
|
|
487
|
+
})
|
|
488
|
+
pushField(inlineFields, usedKeys, 'offset', {
|
|
489
|
+
...getFieldDescriptor('offset'),
|
|
490
|
+
format: 'inline',
|
|
491
|
+
value: asNumber(record.offset)
|
|
492
|
+
})
|
|
493
|
+
pushField(inlineFields, usedKeys, 'limit', {
|
|
494
|
+
...getFieldDescriptor('limit'),
|
|
495
|
+
format: 'inline',
|
|
496
|
+
value: asNumber(record.limit)
|
|
497
|
+
})
|
|
498
|
+
usedKeys.add('path')
|
|
499
|
+
usedKeys.add('file_path')
|
|
500
|
+
} else if (normalizedKey === 'write' || normalizedKey === 'writefile') {
|
|
501
|
+
const pathValue = asString(record.path) ?? asString(record.file_path)
|
|
502
|
+
primary = pathValue != null ? getFileInfo(pathValue).filePath : undefined
|
|
503
|
+
const content = asString(record.content)
|
|
504
|
+
if (content != null) {
|
|
505
|
+
pushField(blockFields, usedKeys, 'content', {
|
|
506
|
+
...getFieldDescriptor('content'),
|
|
507
|
+
format: 'code',
|
|
508
|
+
value: content,
|
|
509
|
+
lang: getLanguageFromPath(primary ?? '')
|
|
510
|
+
})
|
|
511
|
+
}
|
|
512
|
+
usedKeys.add('path')
|
|
513
|
+
usedKeys.add('file_path')
|
|
514
|
+
suppressSuccessResult = true
|
|
515
|
+
} else if (normalizedKey === 'edit' || normalizedKey === 'editfile') {
|
|
516
|
+
const pathValue = asString(record.path) ?? asString(record.file_path)
|
|
517
|
+
primary = pathValue != null ? getFileInfo(pathValue).filePath : undefined
|
|
518
|
+
const original = asString(record.oldString) ?? asString(record.old_string) ?? ''
|
|
519
|
+
const modified = asString(record.newString) ?? asString(record.new_string) ?? ''
|
|
520
|
+
const replaceAll = asBoolean(record.replaceAll) ?? asBoolean(record.replace_all)
|
|
521
|
+
if (original !== '' || modified !== '') {
|
|
522
|
+
diff = {
|
|
523
|
+
original,
|
|
524
|
+
modified,
|
|
525
|
+
language: getLanguageFromPath(primary ?? ''),
|
|
526
|
+
metaItems: replaceAll == null
|
|
527
|
+
? []
|
|
528
|
+
: [{
|
|
529
|
+
...getFieldDescriptor('replaceAll'),
|
|
530
|
+
icon: 'select_all',
|
|
531
|
+
value: replaceAll ? 'true' : 'false',
|
|
532
|
+
tone: replaceAll ? 'success' : 'muted'
|
|
533
|
+
}]
|
|
534
|
+
}
|
|
535
|
+
usedKeys.add('oldString')
|
|
536
|
+
usedKeys.add('old_string')
|
|
537
|
+
usedKeys.add('newString')
|
|
538
|
+
usedKeys.add('new_string')
|
|
539
|
+
}
|
|
540
|
+
pushField(inlineFields, usedKeys, 'replaceAll', {
|
|
541
|
+
...getFieldDescriptor('replaceAll'),
|
|
542
|
+
format: 'inline',
|
|
543
|
+
value: replaceAll != null ? String(replaceAll) : undefined
|
|
544
|
+
})
|
|
545
|
+
usedKeys.add('path')
|
|
546
|
+
usedKeys.add('file_path')
|
|
547
|
+
suppressSuccessResult = true
|
|
548
|
+
} else if (normalizedKey === 'applypatch') {
|
|
549
|
+
const patch = asString(record.patch)
|
|
550
|
+
const targets = patch != null ? getPatchTargets(patch) : []
|
|
551
|
+
primary = targets.length === 1
|
|
552
|
+
? getFileInfo(targets[0]).filePath
|
|
553
|
+
: targets.length > 1
|
|
554
|
+
? `${targets.length} files`
|
|
555
|
+
: undefined
|
|
556
|
+
if (patch != null) {
|
|
557
|
+
pushField(blockFields, usedKeys, 'patch', {
|
|
558
|
+
...getFieldDescriptor('patch', 'Patch'),
|
|
559
|
+
format: 'code',
|
|
560
|
+
value: patch,
|
|
561
|
+
lang: 'diff'
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
pushField(inlineFields, usedKeys, 'cwd', {
|
|
565
|
+
...getFieldDescriptor('cwd', 'Cwd'),
|
|
566
|
+
format: 'inline',
|
|
567
|
+
value: asString(record.cwd)
|
|
568
|
+
})
|
|
569
|
+
suppressSuccessResult = true
|
|
570
|
+
} else if (normalizedKey === 'glob') {
|
|
571
|
+
primary = asString(record.pattern)
|
|
572
|
+
pushField(inlineFields, usedKeys, 'cwd', {
|
|
573
|
+
...getFieldDescriptor('cwd', 'Cwd'),
|
|
574
|
+
format: 'inline',
|
|
575
|
+
value: asString(record.cwd)
|
|
576
|
+
})
|
|
577
|
+
usedKeys.add('pattern')
|
|
578
|
+
} else if (normalizedKey === 'grep') {
|
|
579
|
+
primary = asString(record.pattern)
|
|
580
|
+
pushField(inlineFields, usedKeys, 'path', {
|
|
581
|
+
...getFieldDescriptor('path'),
|
|
582
|
+
format: 'inline',
|
|
583
|
+
value: asString(record.path)
|
|
584
|
+
})
|
|
585
|
+
pushField(inlineFields, usedKeys, 'glob', {
|
|
586
|
+
...getFieldDescriptor('glob'),
|
|
587
|
+
format: 'inline',
|
|
588
|
+
value: asString(record.glob)
|
|
589
|
+
})
|
|
590
|
+
pushField(inlineFields, usedKeys, 'ignoreCase', {
|
|
591
|
+
...getFieldDescriptor('ignoreCase', 'Ignore Case'),
|
|
592
|
+
format: 'inline',
|
|
593
|
+
value: asBoolean(record.ignoreCase) != null ? String(record.ignoreCase) : undefined
|
|
594
|
+
})
|
|
595
|
+
pushField(inlineFields, usedKeys, 'contextLines', {
|
|
596
|
+
...getFieldDescriptor('contextLines', 'Context Lines'),
|
|
597
|
+
format: 'inline',
|
|
598
|
+
value: asNumber(record.contextLines)
|
|
599
|
+
})
|
|
600
|
+
usedKeys.add('pattern')
|
|
601
|
+
} else if (normalizedKey === 'ls' || normalizedKey === 'listdir') {
|
|
602
|
+
const pathValue = asString(record.path)
|
|
603
|
+
primary = pathValue != null ? getFileInfo(pathValue).filePath : undefined
|
|
604
|
+
usedKeys.add('path')
|
|
605
|
+
} else if (normalizedKey === 'websearch') {
|
|
606
|
+
primary = asString(record.query)
|
|
607
|
+
usedKeys.add('query')
|
|
608
|
+
} else if (normalizedKey === 'webfetch') {
|
|
609
|
+
primary = asString(record.url)
|
|
610
|
+
usedKeys.add('url')
|
|
611
|
+
} else if (normalizedKey === 'filechange') {
|
|
612
|
+
const changeLines = getChangeLines(record.changes)
|
|
613
|
+
primary = changeLines?.length === 1
|
|
614
|
+
? getFileInfo(changeLines[0].split(' ').slice(1).join(' ')).filePath
|
|
615
|
+
: changeLines != null && changeLines.length > 1
|
|
616
|
+
? `${changeLines.length} files`
|
|
617
|
+
: undefined
|
|
618
|
+
pushField(inlineFields, usedKeys, 'status', {
|
|
619
|
+
...getFieldDescriptor('status'),
|
|
620
|
+
format: 'inline',
|
|
621
|
+
value: asString(record.status)
|
|
622
|
+
})
|
|
623
|
+
pushField(blockFields, usedKeys, 'changes', {
|
|
624
|
+
...getFieldDescriptor('changes', 'Changes'),
|
|
625
|
+
format: 'list',
|
|
626
|
+
value: changeLines
|
|
627
|
+
})
|
|
628
|
+
suppressSuccessResult = true
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (primary == null) {
|
|
632
|
+
const genericPrimary = getPrimaryFromRecord(record)
|
|
633
|
+
primary = genericPrimary
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
for (const key of ['path', 'file_path', 'url', 'query', 'pattern', 'command']) {
|
|
637
|
+
if (key in record && usedKeys.has(key)) {
|
|
638
|
+
continue
|
|
639
|
+
}
|
|
640
|
+
const value = asString(record[key])
|
|
641
|
+
if (value == null) continue
|
|
642
|
+
if (PATH_KEY_SET.has(key) || isPathLikeValue(value)) {
|
|
643
|
+
primary = primary ?? (PATH_KEY_SET.has(key) ? getFileInfo(value).filePath : value)
|
|
644
|
+
} else if (key === 'command') {
|
|
645
|
+
primary = primary ?? getFirstLine(value)
|
|
646
|
+
} else {
|
|
647
|
+
primary = primary ?? value
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
addRemainingRecordFields(blockFields, inlineFields, record, usedKeys)
|
|
652
|
+
|
|
653
|
+
return {
|
|
654
|
+
...meta,
|
|
655
|
+
primary,
|
|
656
|
+
inlineFields,
|
|
657
|
+
blockFields,
|
|
658
|
+
diff,
|
|
659
|
+
suppressSuccessResult
|
|
660
|
+
}
|
|
661
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
|
|
1
3
|
import { safeJsonStringify } from '#~/utils/safe-serialize'
|
|
2
4
|
|
|
3
5
|
export const TOOL_TOOLTIP_PROPS = {
|
|
@@ -23,14 +25,20 @@ const TOOL_FIELD_ICON_MAP: Record<string, string> = {
|
|
|
23
25
|
cellType: 'grid_view',
|
|
24
26
|
command: 'terminal',
|
|
25
27
|
content: 'notes',
|
|
28
|
+
contextLines: 'format_line_spacing',
|
|
29
|
+
cwd: 'folder_open',
|
|
30
|
+
changes: 'difference',
|
|
26
31
|
description: 'subject',
|
|
27
32
|
disableSandbox: 'shield',
|
|
28
33
|
details: 'info',
|
|
34
|
+
endLine: 'keyboard_double_arrow_down',
|
|
29
35
|
editMode: 'edit',
|
|
30
36
|
glob: 'data_object',
|
|
31
37
|
ignore: 'visibility_off',
|
|
38
|
+
ignoreCase: 'text_fields',
|
|
32
39
|
limit: 'filter_alt',
|
|
33
40
|
maxTurns: 'repeat',
|
|
41
|
+
maxOutputTokens: 'expand_content',
|
|
34
42
|
metadata: 'badge',
|
|
35
43
|
model: 'neurology',
|
|
36
44
|
mode: 'tune',
|
|
@@ -48,11 +56,14 @@ const TOOL_FIELD_ICON_MAP: Record<string, string> = {
|
|
|
48
56
|
replaceAll: 'select_all',
|
|
49
57
|
resume: 'play_circle',
|
|
50
58
|
runInBackground: 'background_dot_large',
|
|
59
|
+
startLine: 'keyboard_double_arrow_up',
|
|
51
60
|
status: 'flag',
|
|
52
61
|
subagentType: 'hub',
|
|
53
62
|
subject: 'title',
|
|
54
63
|
timeout: 'timer',
|
|
55
|
-
todos: 'checklist'
|
|
64
|
+
todos: 'checklist',
|
|
65
|
+
workdir: 'folder_code',
|
|
66
|
+
yieldTimeMs: 'schedule'
|
|
56
67
|
}
|
|
57
68
|
|
|
58
69
|
const TOOL_FORMAT_ICON_MAP: Record<string, string> = {
|