@myrialabs/clopen 0.0.7 → 0.1.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/backend/index.ts +28 -10
- package/backend/lib/chat/stream-manager.ts +130 -10
- package/backend/lib/database/queries/message-queries.ts +47 -0
- package/backend/lib/engine/adapters/claude/stream.ts +65 -1
- package/backend/lib/engine/adapters/opencode/message-converter.ts +35 -77
- package/backend/lib/engine/types.ts +6 -0
- package/backend/lib/files/file-operations.ts +2 -2
- package/backend/lib/files/file-reading.ts +2 -2
- package/backend/lib/files/path-browsing.ts +2 -2
- package/backend/lib/terminal/pty-session-manager.ts +1 -1
- package/backend/lib/terminal/shell-utils.ts +4 -4
- package/backend/lib/terminal/stream-manager.ts +6 -3
- package/backend/ws/chat/background.ts +3 -0
- package/backend/ws/chat/stream.ts +43 -1
- package/backend/ws/terminal/session.ts +48 -0
- package/bin/clopen.ts +10 -0
- package/bun.lock +258 -383
- package/frontend/lib/components/chat/ChatInterface.svelte +8 -1
- package/frontend/lib/components/chat/formatters/MessageFormatter.svelte +20 -0
- package/frontend/lib/components/chat/formatters/TextMessage.svelte +3 -15
- package/frontend/lib/components/chat/formatters/Tools.svelte +15 -8
- package/frontend/lib/components/chat/input/ChatInput.svelte +70 -21
- package/frontend/lib/components/chat/input/components/LoadingIndicator.svelte +23 -11
- package/frontend/lib/components/chat/input/composables/use-chat-actions.svelte.ts +1 -1
- package/frontend/lib/components/chat/message/ChatMessage.svelte +13 -1
- package/frontend/lib/components/chat/message/ChatMessages.svelte +2 -2
- package/frontend/lib/components/chat/message/DateSeparator.svelte +1 -1
- package/frontend/lib/components/chat/message/MessageBubble.svelte +2 -2
- package/frontend/lib/components/chat/message/MessageHeader.svelte +14 -12
- package/frontend/lib/components/chat/tools/AgentTool.svelte +95 -0
- package/frontend/lib/components/chat/tools/AskUserQuestionTool.svelte +396 -0
- package/frontend/lib/components/chat/tools/BashTool.svelte +9 -4
- package/frontend/lib/components/chat/tools/EnterPlanModeTool.svelte +24 -0
- package/frontend/lib/components/chat/tools/ExitPlanModeTool.svelte +4 -7
- package/frontend/lib/components/chat/tools/{KillShellTool.svelte → TaskStopTool.svelte} +6 -6
- package/frontend/lib/components/chat/tools/index.ts +5 -2
- package/frontend/lib/components/checkpoint/TimelineModal.svelte +7 -2
- package/frontend/lib/components/history/HistoryModal.svelte +13 -5
- package/frontend/lib/components/workspace/DesktopNavigator.svelte +2 -1
- package/frontend/lib/components/workspace/MobileNavigator.svelte +2 -1
- package/frontend/lib/services/chat/chat.service.ts +146 -12
- package/frontend/lib/services/terminal/project.service.ts +65 -10
- package/frontend/lib/services/terminal/terminal.service.ts +19 -0
- package/frontend/lib/stores/core/app.svelte.ts +77 -0
- package/frontend/lib/stores/features/terminal.svelte.ts +10 -0
- package/frontend/lib/utils/chat/message-grouper.ts +94 -12
- package/frontend/lib/utils/chat/message-processor.ts +37 -4
- package/frontend/lib/utils/chat/tool-handler.ts +96 -5
- package/package.json +4 -5
- package/shared/constants/engines.ts +1 -1
- package/shared/types/database/schema.ts +1 -0
- package/shared/types/messaging/index.ts +15 -13
- package/shared/types/messaging/tool.ts +185 -361
- package/shared/utils/message-formatter.ts +1 -0
|
@@ -1,401 +1,135 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool
|
|
2
|
+
* Tool Types
|
|
3
3
|
*
|
|
4
|
-
* Defines all tool input interfaces for UI components
|
|
4
|
+
* Defines all tool input/output interfaces for UI components.
|
|
5
|
+
* Input types AND output types are imported from the official SDK.
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
|
-
//
|
|
8
|
+
// ============================================================
|
|
9
|
+
// SDK Tool Input Types
|
|
10
|
+
// ============================================================
|
|
11
|
+
|
|
8
12
|
import type {
|
|
13
|
+
AgentInput,
|
|
14
|
+
AskUserQuestionInput,
|
|
9
15
|
BashInput,
|
|
10
16
|
TaskOutputInput,
|
|
11
|
-
|
|
17
|
+
ConfigInput,
|
|
18
|
+
EnterWorktreeInput,
|
|
12
19
|
ExitPlanModeInput,
|
|
20
|
+
FileEditInput,
|
|
21
|
+
FileReadInput,
|
|
22
|
+
FileWriteInput,
|
|
13
23
|
GlobInput,
|
|
14
24
|
GrepInput,
|
|
15
|
-
KillShellInput,
|
|
16
25
|
ListMcpResourcesInput,
|
|
26
|
+
McpInput,
|
|
17
27
|
NotebookEditInput,
|
|
18
28
|
ReadMcpResourceInput,
|
|
19
|
-
|
|
20
|
-
AgentInput,
|
|
29
|
+
TaskStopInput,
|
|
21
30
|
TodoWriteInput,
|
|
22
31
|
WebFetchInput,
|
|
23
|
-
WebSearchInput
|
|
24
|
-
FileWriteInput
|
|
32
|
+
WebSearchInput
|
|
25
33
|
} from '@anthropic-ai/claude-agent-sdk/sdk-tools';
|
|
26
34
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* Output from Task tool execution
|
|
31
|
-
*/
|
|
32
|
-
export interface TaskOutput {
|
|
33
|
-
/** Final result message from the subagent */
|
|
34
|
-
result: string;
|
|
35
|
-
/** Token usage statistics */
|
|
36
|
-
usage?: {
|
|
37
|
-
/** Number of input tokens consumed */
|
|
38
|
-
input_tokens: number;
|
|
39
|
-
/** Number of output tokens generated */
|
|
40
|
-
output_tokens: number;
|
|
41
|
-
/** Number of cache creation input tokens */
|
|
42
|
-
cache_creation_input_tokens?: number;
|
|
43
|
-
/** Number of cache read input tokens */
|
|
44
|
-
cache_read_input_tokens?: number;
|
|
45
|
-
};
|
|
46
|
-
/** Total cost in USD for this task execution */
|
|
47
|
-
total_cost_usd?: number;
|
|
48
|
-
/** Execution duration in milliseconds */
|
|
49
|
-
duration_ms?: number;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Output from Bash tool execution
|
|
54
|
-
*/
|
|
55
|
-
export interface BashOutput {
|
|
56
|
-
/** Combined stdout and stderr output */
|
|
57
|
-
output: string;
|
|
58
|
-
/** Exit code of the command */
|
|
59
|
-
exitCode: number;
|
|
60
|
-
/** Whether the command was killed due to timeout */
|
|
61
|
-
killed?: boolean;
|
|
62
|
-
/** Shell ID for background processes */
|
|
63
|
-
shellId?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Output from BashOutput tool for monitoring background processes
|
|
68
|
-
*/
|
|
69
|
-
export interface BashOutputToolOutput {
|
|
70
|
-
/** Output from the background process */
|
|
71
|
-
output: string;
|
|
72
|
-
/** Current status of the background process */
|
|
73
|
-
status: 'running' | 'completed' | 'failed';
|
|
74
|
-
/** Exit code if the process has completed */
|
|
75
|
-
exitCode?: number;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Output from Edit tool for file modifications
|
|
80
|
-
*/
|
|
81
|
-
export interface EditOutput {
|
|
82
|
-
/** Confirmation message about the edit operation */
|
|
83
|
-
message: string;
|
|
84
|
-
/** Number of replacements made */
|
|
85
|
-
replacements: number;
|
|
86
|
-
/** Path to the edited file */
|
|
87
|
-
file_path: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Output when reading a text file
|
|
92
|
-
*/
|
|
93
|
-
export interface TextFileOutput {
|
|
94
|
-
/** Text content of the file */
|
|
95
|
-
content: string;
|
|
96
|
-
/** Total number of lines in the file */
|
|
97
|
-
total_lines: number;
|
|
98
|
-
/** Number of lines returned (may be limited by offset/limit) */
|
|
99
|
-
lines_returned: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Output when reading an image file
|
|
104
|
-
*/
|
|
105
|
-
export interface ImageFileOutput {
|
|
106
|
-
/** Base64-encoded image data */
|
|
107
|
-
image: string;
|
|
108
|
-
/** MIME type of the image */
|
|
109
|
-
mime_type: string;
|
|
110
|
-
/** File size in bytes */
|
|
111
|
-
file_size: number;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Output when reading a PDF file
|
|
116
|
-
*/
|
|
117
|
-
export interface PDFFileOutput {
|
|
118
|
-
/** Array of pages with text and images */
|
|
119
|
-
pages: Array<{
|
|
120
|
-
/** Page number (1-indexed) */
|
|
121
|
-
page_number: number;
|
|
122
|
-
/** Extracted text from the page */
|
|
123
|
-
text?: string;
|
|
124
|
-
/** Images found on the page */
|
|
125
|
-
images?: Array<{
|
|
126
|
-
/** Base64-encoded image data */
|
|
127
|
-
image: string;
|
|
128
|
-
/** MIME type of the image */
|
|
129
|
-
mime_type: string;
|
|
130
|
-
}>;
|
|
131
|
-
}>;
|
|
132
|
-
/** Total number of pages in the PDF */
|
|
133
|
-
total_pages: number;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Output when reading a Jupyter notebook file
|
|
138
|
-
*/
|
|
139
|
-
export interface NotebookFileOutput {
|
|
140
|
-
/** Array of notebook cells */
|
|
141
|
-
cells: Array<{
|
|
142
|
-
/** Type of the cell */
|
|
143
|
-
cell_type: 'code' | 'markdown';
|
|
144
|
-
/** Source code or markdown content */
|
|
145
|
-
source: string;
|
|
146
|
-
/** Cell outputs (for code cells) */
|
|
147
|
-
outputs?: any[];
|
|
148
|
-
/** Execution count (for code cells) */
|
|
149
|
-
execution_count?: number;
|
|
150
|
-
}>;
|
|
151
|
-
/** Notebook metadata */
|
|
152
|
-
metadata?: Record<string, any>;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Union type for all possible Read tool outputs
|
|
157
|
-
*/
|
|
158
|
-
export type ReadOutput =
|
|
159
|
-
| TextFileOutput
|
|
160
|
-
| ImageFileOutput
|
|
161
|
-
| PDFFileOutput
|
|
162
|
-
| NotebookFileOutput;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Output from Glob tool for file pattern matching
|
|
166
|
-
*/
|
|
167
|
-
export interface GlobOutput {
|
|
168
|
-
/** Array of file paths matching the pattern */
|
|
169
|
-
matches: string[];
|
|
170
|
-
/** Number of matches found */
|
|
171
|
-
count: number;
|
|
172
|
-
/** Search directory used */
|
|
173
|
-
search_path: string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Output from Grep tool for content searching (content mode)
|
|
178
|
-
*/
|
|
179
|
-
export interface GrepContentOutput {
|
|
180
|
-
/** Matching lines with context */
|
|
181
|
-
matches: Array<{
|
|
182
|
-
/** File path where the match was found */
|
|
183
|
-
file: string;
|
|
184
|
-
/** Line number of the match (if available) */
|
|
185
|
-
line_number?: number;
|
|
186
|
-
/** Content of the matching line */
|
|
187
|
-
line: string;
|
|
188
|
-
/** Lines before the match (if -B or -C was used) */
|
|
189
|
-
before_context?: string[];
|
|
190
|
-
/** Lines after the match (if -A or -C was used) */
|
|
191
|
-
after_context?: string[];
|
|
192
|
-
}>;
|
|
193
|
-
/** Total number of matches found */
|
|
194
|
-
total_matches: number;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Output from Grep tool for files mode
|
|
199
|
-
*/
|
|
200
|
-
export interface GrepFilesOutput {
|
|
201
|
-
/** Files containing matches */
|
|
202
|
-
files: string[];
|
|
203
|
-
/** Number of files with matches */
|
|
204
|
-
count: number;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Output from Grep tool for count mode
|
|
209
|
-
*/
|
|
210
|
-
export interface GrepCountOutput {
|
|
211
|
-
/** Match counts per file */
|
|
212
|
-
counts: Array<{
|
|
213
|
-
/** File path */
|
|
214
|
-
file: string;
|
|
215
|
-
/** Number of matches in this file */
|
|
216
|
-
count: number;
|
|
217
|
-
}>;
|
|
218
|
-
/** Total matches across all files */
|
|
219
|
-
total: number;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Union type for all possible Grep outputs based on output_mode
|
|
224
|
-
*/
|
|
225
|
-
export type GrepOutput =
|
|
226
|
-
| GrepContentOutput
|
|
227
|
-
| GrepFilesOutput
|
|
228
|
-
| GrepCountOutput;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Output from WebFetch tool for web content retrieval
|
|
232
|
-
*/
|
|
233
|
-
export interface WebFetchOutput {
|
|
234
|
-
/** AI model's response to the prompt */
|
|
235
|
-
response: string;
|
|
236
|
-
/** URL that was fetched */
|
|
237
|
-
url: string;
|
|
238
|
-
/** Final URL after redirects */
|
|
239
|
-
final_url?: string;
|
|
240
|
-
/** HTTP status code */
|
|
241
|
-
status_code?: number;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Output from WebSearch tool for web searching
|
|
246
|
-
*/
|
|
247
|
-
export interface WebSearchOutput {
|
|
248
|
-
/** Array of search results */
|
|
249
|
-
results: Array<{
|
|
250
|
-
/** Title of the search result */
|
|
251
|
-
title: string;
|
|
252
|
-
/** URL of the search result */
|
|
253
|
-
url: string;
|
|
254
|
-
/** Snippet/description of the search result */
|
|
255
|
-
snippet: string;
|
|
256
|
-
}>;
|
|
257
|
-
/** Total number of results found */
|
|
258
|
-
total_results: number;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Output from Write tool for file creation
|
|
263
|
-
*/
|
|
264
|
-
export interface WriteOutput {
|
|
265
|
-
/** Confirmation message about the write operation */
|
|
266
|
-
message: string;
|
|
267
|
-
/** Path to the written file */
|
|
268
|
-
file_path: string;
|
|
269
|
-
/** Number of bytes written */
|
|
270
|
-
bytes_written: number;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Output from NotebookEdit tool for Jupyter notebook modifications
|
|
275
|
-
*/
|
|
276
|
-
export interface NotebookEditOutput {
|
|
277
|
-
/** Confirmation message about the notebook edit */
|
|
278
|
-
message: string;
|
|
279
|
-
/** Type of edit performed */
|
|
280
|
-
edit_type: 'replaced' | 'inserted' | 'deleted';
|
|
281
|
-
/** ID of the edited cell (if applicable) */
|
|
282
|
-
cell_id?: string;
|
|
283
|
-
/** Total cells in notebook after edit */
|
|
284
|
-
total_cells: number;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Output from TodoWrite tool for task management
|
|
289
|
-
*/
|
|
290
|
-
export interface TodoWriteOutput {
|
|
291
|
-
/** Confirmation message about the todo operation */
|
|
292
|
-
message: string;
|
|
293
|
-
/** Current todo statistics */
|
|
294
|
-
stats: {
|
|
295
|
-
/** Total number of todos */
|
|
296
|
-
total: number;
|
|
297
|
-
/** Number of pending todos */
|
|
298
|
-
pending: number;
|
|
299
|
-
/** Number of in-progress todos */
|
|
300
|
-
in_progress: number;
|
|
301
|
-
/** Number of completed todos */
|
|
302
|
-
completed: number;
|
|
303
|
-
};
|
|
304
|
-
}
|
|
35
|
+
// ============================================================
|
|
36
|
+
// SDK Tool Output Types
|
|
37
|
+
// ============================================================
|
|
305
38
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
39
|
+
import type {
|
|
40
|
+
AgentOutput as SDKAgentOutput,
|
|
41
|
+
AskUserQuestionOutput as SDKAskUserQuestionOutput,
|
|
42
|
+
BashOutput as SDKBashOutput,
|
|
43
|
+
ConfigOutput as SDKConfigOutput,
|
|
44
|
+
EnterWorktreeOutput as SDKEnterWorktreeOutput,
|
|
45
|
+
ExitPlanModeOutput as SDKExitPlanModeOutput,
|
|
46
|
+
FileEditOutput as SDKFileEditOutput,
|
|
47
|
+
FileReadOutput as SDKFileReadOutput,
|
|
48
|
+
FileWriteOutput as SDKFileWriteOutput,
|
|
49
|
+
GlobOutput as SDKGlobOutput,
|
|
50
|
+
GrepOutput as SDKGrepOutput,
|
|
51
|
+
ListMcpResourcesOutput as SDKListMcpResourcesOutput,
|
|
52
|
+
NotebookEditOutput as SDKNotebookEditOutput,
|
|
53
|
+
ReadMcpResourceOutput as SDKReadMcpResourceOutput,
|
|
54
|
+
TaskStopOutput as SDKTaskStopOutput,
|
|
55
|
+
TodoWriteOutput as SDKTodoWriteOutput,
|
|
56
|
+
WebFetchOutput as SDKWebFetchOutput,
|
|
57
|
+
WebSearchOutput as SDKWebSearchOutput
|
|
58
|
+
} from '@anthropic-ai/claude-agent-sdk/sdk-tools';
|
|
323
59
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
export
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
60
|
+
// Re-export SDK output types with consistent names
|
|
61
|
+
export type TaskOutput = SDKAgentOutput;
|
|
62
|
+
export type AskUserQuestionOutput = SDKAskUserQuestionOutput;
|
|
63
|
+
export type BashOutput = SDKBashOutput;
|
|
64
|
+
export type ConfigOutput = SDKConfigOutput;
|
|
65
|
+
export type EnterWorktreeOutput = SDKEnterWorktreeOutput;
|
|
66
|
+
export type ExitPlanModeOutput = SDKExitPlanModeOutput;
|
|
67
|
+
export type EditOutput = SDKFileEditOutput;
|
|
68
|
+
export type ReadOutput = SDKFileReadOutput;
|
|
69
|
+
export type WriteOutput = SDKFileWriteOutput;
|
|
70
|
+
export type GlobOutput = SDKGlobOutput;
|
|
71
|
+
export type GrepOutput = SDKGrepOutput;
|
|
72
|
+
export type ListMcpResourcesOutput = SDKListMcpResourcesOutput;
|
|
73
|
+
export type NotebookEditOutput = SDKNotebookEditOutput;
|
|
74
|
+
export type ReadMcpResourceOutput = SDKReadMcpResourceOutput;
|
|
75
|
+
export type TaskStopOutput = SDKTaskStopOutput;
|
|
76
|
+
export type TodoWriteOutput = SDKTodoWriteOutput;
|
|
77
|
+
export type WebFetchOutput = SDKWebFetchOutput;
|
|
78
|
+
export type WebSearchOutput = SDKWebSearchOutput;
|
|
344
79
|
|
|
345
80
|
/**
|
|
346
|
-
*
|
|
347
|
-
*/
|
|
348
|
-
export interface ReadMcpResourceOutput {
|
|
349
|
-
/** Resource contents (can be multiple if resource has multiple parts) */
|
|
350
|
-
contents: Array<{
|
|
351
|
-
/** URI of the resource */
|
|
352
|
-
uri: string;
|
|
353
|
-
/** MIME type of the resource */
|
|
354
|
-
mimeType?: string;
|
|
355
|
-
/** Text content (for text resources) */
|
|
356
|
-
text?: string;
|
|
357
|
-
/** Base64-encoded blob (for binary resources) */
|
|
358
|
-
blob?: string;
|
|
359
|
-
}>;
|
|
360
|
-
/** Server that provided the resource */
|
|
361
|
-
server: string;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Union type for all possible tool outputs
|
|
81
|
+
* Union type for all possible tool outputs (SDK types)
|
|
366
82
|
*/
|
|
367
83
|
export type ToolOutput =
|
|
368
84
|
| TaskOutput
|
|
85
|
+
| AskUserQuestionOutput
|
|
369
86
|
| BashOutput
|
|
370
|
-
|
|
|
87
|
+
| ConfigOutput
|
|
88
|
+
| EnterWorktreeOutput
|
|
89
|
+
| ExitPlanModeOutput
|
|
371
90
|
| EditOutput
|
|
372
91
|
| ReadOutput
|
|
92
|
+
| WriteOutput
|
|
373
93
|
| GlobOutput
|
|
374
94
|
| GrepOutput
|
|
375
|
-
|
|
|
376
|
-
| WebSearchOutput
|
|
377
|
-
| WriteOutput
|
|
95
|
+
| ListMcpResourcesOutput
|
|
378
96
|
| NotebookEditOutput
|
|
97
|
+
| ReadMcpResourceOutput
|
|
98
|
+
| TaskStopOutput
|
|
379
99
|
| TodoWriteOutput
|
|
380
|
-
|
|
|
381
|
-
|
|
|
382
|
-
|
|
383
|
-
|
|
100
|
+
| WebFetchOutput
|
|
101
|
+
| WebSearchOutput;
|
|
102
|
+
|
|
103
|
+
// ============================================================
|
|
104
|
+
// Tool Result Type (for embedding in tool_use)
|
|
105
|
+
// ============================================================
|
|
384
106
|
|
|
385
|
-
// Tool result type for embedding in tool_use
|
|
386
107
|
export interface ToolResult {
|
|
387
108
|
type: 'tool_result';
|
|
388
109
|
tool_use_id: string;
|
|
389
110
|
content: string;
|
|
390
111
|
}
|
|
391
112
|
|
|
392
|
-
//
|
|
113
|
+
// ============================================================
|
|
114
|
+
// Tool Metadata (set by chat service on stream end)
|
|
115
|
+
// ============================================================
|
|
116
|
+
|
|
117
|
+
export interface ToolMetadata {
|
|
118
|
+
/** Tool was interrupted — stream ended (error/cancel/complete) before tool got its result */
|
|
119
|
+
interrupted?: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ============================================================
|
|
123
|
+
// Tool Input Types for UI Components
|
|
124
|
+
// ============================================================
|
|
125
|
+
|
|
393
126
|
export interface BashToolInput {
|
|
394
127
|
type: 'tool_use';
|
|
395
128
|
id: string;
|
|
396
129
|
name: 'Bash';
|
|
397
130
|
input: BashInput;
|
|
398
131
|
$result?: ToolResult;
|
|
132
|
+
metadata?: ToolMetadata;
|
|
399
133
|
}
|
|
400
134
|
|
|
401
135
|
export interface BashOutputToolInput {
|
|
@@ -404,6 +138,7 @@ export interface BashOutputToolInput {
|
|
|
404
138
|
name: 'TaskOutput';
|
|
405
139
|
input: TaskOutputInput;
|
|
406
140
|
$result?: ToolResult;
|
|
141
|
+
metadata?: ToolMetadata;
|
|
407
142
|
}
|
|
408
143
|
|
|
409
144
|
export interface EditToolInput {
|
|
@@ -412,6 +147,7 @@ export interface EditToolInput {
|
|
|
412
147
|
name: 'Edit';
|
|
413
148
|
input: FileEditInput;
|
|
414
149
|
$result?: ToolResult;
|
|
150
|
+
metadata?: ToolMetadata;
|
|
415
151
|
}
|
|
416
152
|
|
|
417
153
|
export interface ExitPlanModeToolInput {
|
|
@@ -420,6 +156,7 @@ export interface ExitPlanModeToolInput {
|
|
|
420
156
|
name: 'ExitPlanMode';
|
|
421
157
|
input: ExitPlanModeInput;
|
|
422
158
|
$result?: ToolResult;
|
|
159
|
+
metadata?: ToolMetadata;
|
|
423
160
|
}
|
|
424
161
|
|
|
425
162
|
export interface GlobToolInput {
|
|
@@ -428,6 +165,7 @@ export interface GlobToolInput {
|
|
|
428
165
|
name: 'Glob';
|
|
429
166
|
input: GlobInput;
|
|
430
167
|
$result?: ToolResult;
|
|
168
|
+
metadata?: ToolMetadata;
|
|
431
169
|
}
|
|
432
170
|
|
|
433
171
|
export interface GrepToolInput {
|
|
@@ -436,14 +174,16 @@ export interface GrepToolInput {
|
|
|
436
174
|
name: 'Grep';
|
|
437
175
|
input: GrepInput;
|
|
438
176
|
$result?: ToolResult;
|
|
177
|
+
metadata?: ToolMetadata;
|
|
439
178
|
}
|
|
440
179
|
|
|
441
|
-
export interface
|
|
180
|
+
export interface TaskStopToolInput {
|
|
442
181
|
type: 'tool_use';
|
|
443
182
|
id: string;
|
|
444
|
-
name: '
|
|
445
|
-
input:
|
|
183
|
+
name: 'TaskStop';
|
|
184
|
+
input: TaskStopInput;
|
|
446
185
|
$result?: ToolResult;
|
|
186
|
+
metadata?: ToolMetadata;
|
|
447
187
|
}
|
|
448
188
|
|
|
449
189
|
export interface ListMcpResourcesToolInput {
|
|
@@ -452,6 +192,7 @@ export interface ListMcpResourcesToolInput {
|
|
|
452
192
|
name: 'ListMcpResources';
|
|
453
193
|
input: ListMcpResourcesInput;
|
|
454
194
|
$result?: ToolResult;
|
|
195
|
+
metadata?: ToolMetadata;
|
|
455
196
|
}
|
|
456
197
|
|
|
457
198
|
export interface NotebookEditToolInput {
|
|
@@ -460,6 +201,7 @@ export interface NotebookEditToolInput {
|
|
|
460
201
|
name: 'NotebookEdit';
|
|
461
202
|
input: NotebookEditInput;
|
|
462
203
|
$result?: ToolResult;
|
|
204
|
+
metadata?: ToolMetadata;
|
|
463
205
|
}
|
|
464
206
|
|
|
465
207
|
export interface ReadMcpResourceToolInput {
|
|
@@ -468,6 +210,7 @@ export interface ReadMcpResourceToolInput {
|
|
|
468
210
|
name: 'ReadMcpResource';
|
|
469
211
|
input: ReadMcpResourceInput;
|
|
470
212
|
$result?: ToolResult;
|
|
213
|
+
metadata?: ToolMetadata;
|
|
471
214
|
}
|
|
472
215
|
|
|
473
216
|
export interface ReadToolInput {
|
|
@@ -476,6 +219,7 @@ export interface ReadToolInput {
|
|
|
476
219
|
name: 'Read';
|
|
477
220
|
input: FileReadInput;
|
|
478
221
|
$result?: ToolResult;
|
|
222
|
+
metadata?: ToolMetadata;
|
|
479
223
|
}
|
|
480
224
|
|
|
481
225
|
export interface TaskToolInput {
|
|
@@ -484,6 +228,7 @@ export interface TaskToolInput {
|
|
|
484
228
|
name: 'Task';
|
|
485
229
|
input: AgentInput;
|
|
486
230
|
$result?: ToolResult;
|
|
231
|
+
metadata?: ToolMetadata;
|
|
487
232
|
}
|
|
488
233
|
|
|
489
234
|
export interface TodoWriteToolInput {
|
|
@@ -492,6 +237,7 @@ export interface TodoWriteToolInput {
|
|
|
492
237
|
name: 'TodoWrite';
|
|
493
238
|
input: TodoWriteInput;
|
|
494
239
|
$result?: ToolResult;
|
|
240
|
+
metadata?: ToolMetadata;
|
|
495
241
|
}
|
|
496
242
|
|
|
497
243
|
export interface WebFetchToolInput {
|
|
@@ -500,6 +246,7 @@ export interface WebFetchToolInput {
|
|
|
500
246
|
name: 'WebFetch';
|
|
501
247
|
input: WebFetchInput;
|
|
502
248
|
$result?: ToolResult;
|
|
249
|
+
metadata?: ToolMetadata;
|
|
503
250
|
}
|
|
504
251
|
|
|
505
252
|
export interface WebSearchToolInput {
|
|
@@ -508,6 +255,7 @@ export interface WebSearchToolInput {
|
|
|
508
255
|
name: 'WebSearch';
|
|
509
256
|
input: WebSearchInput;
|
|
510
257
|
$result?: ToolResult;
|
|
258
|
+
metadata?: ToolMetadata;
|
|
511
259
|
}
|
|
512
260
|
|
|
513
261
|
export interface WriteToolInput {
|
|
@@ -516,11 +264,87 @@ export interface WriteToolInput {
|
|
|
516
264
|
name: 'Write';
|
|
517
265
|
input: FileWriteInput;
|
|
518
266
|
$result?: ToolResult;
|
|
267
|
+
metadata?: ToolMetadata;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface AskUserQuestionToolInput {
|
|
271
|
+
type: 'tool_use';
|
|
272
|
+
id: string;
|
|
273
|
+
name: 'AskUserQuestion';
|
|
274
|
+
input: AskUserQuestionInput;
|
|
275
|
+
$result?: ToolResult;
|
|
276
|
+
metadata?: ToolMetadata;
|
|
519
277
|
}
|
|
520
278
|
|
|
279
|
+
export interface ConfigToolInput {
|
|
280
|
+
type: 'tool_use';
|
|
281
|
+
id: string;
|
|
282
|
+
name: 'Config';
|
|
283
|
+
input: ConfigInput;
|
|
284
|
+
$result?: ToolResult;
|
|
285
|
+
metadata?: ToolMetadata;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface EnterWorktreeToolInput {
|
|
289
|
+
type: 'tool_use';
|
|
290
|
+
id: string;
|
|
291
|
+
name: 'EnterWorktree';
|
|
292
|
+
input: EnterWorktreeInput;
|
|
293
|
+
$result?: ToolResult;
|
|
294
|
+
metadata?: ToolMetadata;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Sub-agent activity item for Agent tool display
|
|
298
|
+
export interface SubAgentActivity {
|
|
299
|
+
type: 'tool_use' | 'text';
|
|
300
|
+
toolName?: string;
|
|
301
|
+
toolInput?: any;
|
|
302
|
+
toolResult?: any;
|
|
303
|
+
text?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface AgentToolInput {
|
|
307
|
+
type: 'tool_use';
|
|
308
|
+
id: string;
|
|
309
|
+
name: 'Agent';
|
|
310
|
+
input: AgentInput;
|
|
311
|
+
$result?: ToolResult;
|
|
312
|
+
$subMessages?: SubAgentActivity[];
|
|
313
|
+
metadata?: ToolMetadata;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface EnterPlanModeToolInput {
|
|
317
|
+
type: 'tool_use';
|
|
318
|
+
id: string;
|
|
319
|
+
name: 'EnterPlanMode';
|
|
320
|
+
input: Record<string, unknown>;
|
|
321
|
+
$result?: ToolResult;
|
|
322
|
+
metadata?: ToolMetadata;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ============================================================
|
|
326
|
+
// Union of All Tool Input Types
|
|
327
|
+
// ============================================================
|
|
328
|
+
|
|
521
329
|
export type ToolInput =
|
|
522
|
-
| BashToolInput
|
|
523
|
-
|
|
|
330
|
+
| BashToolInput
|
|
331
|
+
| BashOutputToolInput
|
|
332
|
+
| EditToolInput
|
|
333
|
+
| ExitPlanModeToolInput
|
|
334
|
+
| GlobToolInput
|
|
335
|
+
| GrepToolInput
|
|
336
|
+
| TaskStopToolInput
|
|
337
|
+
| ListMcpResourcesToolInput
|
|
524
338
|
| NotebookEditToolInput
|
|
525
|
-
| ReadMcpResourceToolInput
|
|
526
|
-
|
|
|
339
|
+
| ReadMcpResourceToolInput
|
|
340
|
+
| ReadToolInput
|
|
341
|
+
| TaskToolInput
|
|
342
|
+
| TodoWriteToolInput
|
|
343
|
+
| WebFetchToolInput
|
|
344
|
+
| WebSearchToolInput
|
|
345
|
+
| WriteToolInput
|
|
346
|
+
| AskUserQuestionToolInput
|
|
347
|
+
| ConfigToolInput
|
|
348
|
+
| EnterWorktreeToolInput
|
|
349
|
+
| AgentToolInput
|
|
350
|
+
| EnterPlanModeToolInput;
|