cyrus-gemini-runner 0.2.4
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/LICENSE +674 -0
- package/README.md +411 -0
- package/dist/GeminiRunner.d.ts +136 -0
- package/dist/GeminiRunner.d.ts.map +1 -0
- package/dist/GeminiRunner.js +683 -0
- package/dist/GeminiRunner.js.map +1 -0
- package/dist/SimpleGeminiRunner.d.ts +27 -0
- package/dist/SimpleGeminiRunner.d.ts.map +1 -0
- package/dist/SimpleGeminiRunner.js +149 -0
- package/dist/SimpleGeminiRunner.js.map +1 -0
- package/dist/adapters.d.ts +37 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +317 -0
- package/dist/adapters.js.map +1 -0
- package/dist/formatter.d.ts +40 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +363 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/system.md +108 -0
- package/dist/schemas.d.ts +1472 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +678 -0
- package/dist/schemas.js.map +1 -0
- package/dist/settingsGenerator.d.ts +72 -0
- package/dist/settingsGenerator.d.ts.map +1 -0
- package/dist/settingsGenerator.js +255 -0
- package/dist/settingsGenerator.js.map +1 -0
- package/dist/systemPromptManager.d.ts +27 -0
- package/dist/systemPromptManager.d.ts.map +1 -0
- package/dist/systemPromptManager.js +65 -0
- package/dist/systemPromptManager.js.map +1 -0
- package/dist/types.d.ts +113 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,1472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schemas for Gemini CLI Stream Events
|
|
3
|
+
*
|
|
4
|
+
* These schemas provide runtime validation for Gemini CLI's stream-json output format.
|
|
5
|
+
* TypeScript types are derived from these schemas using z.infer<> for type safety.
|
|
6
|
+
*
|
|
7
|
+
* Note: The official `@google/gemini-cli-core` package (v0.17.1) exports TypeScript
|
|
8
|
+
* interfaces for these event types. However, we use custom Zod schemas because:
|
|
9
|
+
* 1. Runtime validation - official types are TypeScript-only, no runtime checks
|
|
10
|
+
* 2. Detailed tool typing - official uses `Record<string, unknown>` for tool params
|
|
11
|
+
* 3. Type guards and parsers - utility functions for narrowing event/tool types
|
|
12
|
+
* 4. Tool result typing - result schemas typed by tool_id prefix
|
|
13
|
+
*
|
|
14
|
+
* Our schemas are structurally compatible with the official types.
|
|
15
|
+
*
|
|
16
|
+
* Official type definitions (pinned to v0.17.0):
|
|
17
|
+
* @see https://github.com/google-gemini/gemini-cli/blob/v0.17.0/packages/core/src/output/types.ts
|
|
18
|
+
* @see https://www.npmjs.com/package/@google/gemini-cli-core/v/0.17.0
|
|
19
|
+
*
|
|
20
|
+
* Documentation:
|
|
21
|
+
* @see https://github.com/google-gemini/gemini-cli/blob/v0.17.0/docs/cli/headless.md
|
|
22
|
+
*/
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
/**
|
|
25
|
+
* Session initialization event
|
|
26
|
+
*
|
|
27
|
+
* Example:
|
|
28
|
+
* ```json
|
|
29
|
+
* {"type":"init","timestamp":"2025-11-25T03:27:51.000Z","session_id":"c25acda3-b51f-41f9-9bc5-954c70c17bf4","model":"auto"}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const GeminiInitEventSchema: z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"init">;
|
|
34
|
+
timestamp: z.ZodString;
|
|
35
|
+
session_id: z.ZodString;
|
|
36
|
+
model: z.ZodString;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
type: "init";
|
|
39
|
+
timestamp: string;
|
|
40
|
+
session_id: string;
|
|
41
|
+
model: string;
|
|
42
|
+
}, {
|
|
43
|
+
type: "init";
|
|
44
|
+
timestamp: string;
|
|
45
|
+
session_id: string;
|
|
46
|
+
model: string;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* User or assistant message event
|
|
50
|
+
*
|
|
51
|
+
* When delta is true, this message should be accumulated with previous delta messages
|
|
52
|
+
* of the same role. The caller (GeminiRunner) is responsible for accumulating delta messages.
|
|
53
|
+
*
|
|
54
|
+
* Examples:
|
|
55
|
+
* ```json
|
|
56
|
+
* {"type":"message","timestamp":"2025-11-25T03:27:51.001Z","role":"user","content":"What is 2 + 2?"}
|
|
57
|
+
* {"type":"message","timestamp":"2025-11-25T03:28:05.256Z","role":"assistant","content":"2 + 2 = 4.","delta":true}
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const GeminiMessageEventSchema: z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"message">;
|
|
62
|
+
timestamp: z.ZodString;
|
|
63
|
+
role: z.ZodEnum<["user", "assistant"]>;
|
|
64
|
+
content: z.ZodString;
|
|
65
|
+
delta: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
type: "message";
|
|
68
|
+
timestamp: string;
|
|
69
|
+
role: "user" | "assistant";
|
|
70
|
+
content: string;
|
|
71
|
+
delta?: boolean | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
type: "message";
|
|
74
|
+
timestamp: string;
|
|
75
|
+
role: "user" | "assistant";
|
|
76
|
+
content: string;
|
|
77
|
+
delta?: boolean | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Parameters for the read_file tool
|
|
81
|
+
*
|
|
82
|
+
* Example:
|
|
83
|
+
* ```json
|
|
84
|
+
* {"file_path":"package.json"}
|
|
85
|
+
* {"file_path":"app/mcts.py"}
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare const ReadFileParametersSchema: z.ZodObject<{
|
|
89
|
+
file_path: z.ZodString;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
file_path: string;
|
|
92
|
+
}, {
|
|
93
|
+
file_path: string;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Parameters for the write_file tool
|
|
97
|
+
*
|
|
98
|
+
* Example:
|
|
99
|
+
* ```json
|
|
100
|
+
* {"file_path":"tests/test_snake.py","content":"import unittest\n..."}
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const WriteFileParametersSchema: z.ZodObject<{
|
|
104
|
+
file_path: z.ZodString;
|
|
105
|
+
content: z.ZodString;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
content: string;
|
|
108
|
+
file_path: string;
|
|
109
|
+
}, {
|
|
110
|
+
content: string;
|
|
111
|
+
file_path: string;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Parameters for the list_directory tool
|
|
115
|
+
*
|
|
116
|
+
* Example:
|
|
117
|
+
* ```json
|
|
118
|
+
* {"dir_path":"."}
|
|
119
|
+
* {"dir_path":"./src"}
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare const ListDirectoryParametersSchema: z.ZodObject<{
|
|
123
|
+
dir_path: z.ZodString;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
dir_path: string;
|
|
126
|
+
}, {
|
|
127
|
+
dir_path: string;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Parameters for the search_file_content tool
|
|
131
|
+
*
|
|
132
|
+
* Example:
|
|
133
|
+
* ```json
|
|
134
|
+
* {"pattern":"(TODO|FIXME)"}
|
|
135
|
+
* {"pattern":"function.*export"}
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const SearchFileContentParametersSchema: z.ZodObject<{
|
|
139
|
+
pattern: z.ZodString;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
pattern: string;
|
|
142
|
+
}, {
|
|
143
|
+
pattern: string;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Parameters for the run_shell_command tool
|
|
147
|
+
*
|
|
148
|
+
* Example:
|
|
149
|
+
* ```json
|
|
150
|
+
* {"command":"/usr/bin/python3 -m pytest tests/"}
|
|
151
|
+
* {"command":"git status"}
|
|
152
|
+
* {"command":"flake8 --version"}
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare const RunShellCommandParametersSchema: z.ZodObject<{
|
|
156
|
+
command: z.ZodString;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
command: string;
|
|
159
|
+
}, {
|
|
160
|
+
command: string;
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* Todo item for the write_todos tool
|
|
164
|
+
*/
|
|
165
|
+
export declare const TodoItemSchema: z.ZodObject<{
|
|
166
|
+
description: z.ZodString;
|
|
167
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "in_progress", "completed"]>>;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
description: string;
|
|
170
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
171
|
+
}, {
|
|
172
|
+
description: string;
|
|
173
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Parameters for the write_todos tool
|
|
177
|
+
*
|
|
178
|
+
* Example:
|
|
179
|
+
* ```json
|
|
180
|
+
* {"todos":[{"description":"Explore codebase to identify bugs","status":"in_progress"},{"description":"Fix coordinate system","status":"pending"}]}
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare const WriteTodosParametersSchema: z.ZodObject<{
|
|
184
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
185
|
+
description: z.ZodString;
|
|
186
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "in_progress", "completed"]>>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
description: string;
|
|
189
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
190
|
+
}, {
|
|
191
|
+
description: string;
|
|
192
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
193
|
+
}>, "many">;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
todos: {
|
|
196
|
+
description: string;
|
|
197
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
198
|
+
}[];
|
|
199
|
+
}, {
|
|
200
|
+
todos: {
|
|
201
|
+
description: string;
|
|
202
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
203
|
+
}[];
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Parameters for the replace tool (AI-powered code editing)
|
|
207
|
+
*
|
|
208
|
+
* Can use either instruction-based or literal string replacement:
|
|
209
|
+
* - instruction: Natural language description of the change
|
|
210
|
+
* - old_string/new_string: Literal string replacement
|
|
211
|
+
*
|
|
212
|
+
* Examples:
|
|
213
|
+
* Instruction-based:
|
|
214
|
+
* ```json
|
|
215
|
+
* {"instruction":"Modify get_other_snake_heads to return a list instead of dict","file_path":"app/mcts.py"}
|
|
216
|
+
* {"instruction":"Clean up comments in is_terminal.","file_path":"app/mcts.py"}
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* Literal replacement:
|
|
220
|
+
* ```json
|
|
221
|
+
* {"file_path":"app/mcts.py","old_string":" # Simulate other snakes' moves\\n othe","new_string":" # Track enemy positions\\n enemy"}
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare const ReplaceParametersSchema: z.ZodObject<{
|
|
225
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
226
|
+
file_path: z.ZodOptional<z.ZodString>;
|
|
227
|
+
old_string: z.ZodOptional<z.ZodString>;
|
|
228
|
+
new_string: z.ZodOptional<z.ZodString>;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
file_path?: string | undefined;
|
|
231
|
+
instruction?: string | undefined;
|
|
232
|
+
old_string?: string | undefined;
|
|
233
|
+
new_string?: string | undefined;
|
|
234
|
+
}, {
|
|
235
|
+
file_path?: string | undefined;
|
|
236
|
+
instruction?: string | undefined;
|
|
237
|
+
old_string?: string | undefined;
|
|
238
|
+
new_string?: string | undefined;
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Union of all known tool parameter schemas
|
|
242
|
+
*/
|
|
243
|
+
export declare const GeminiToolParametersSchema: z.ZodUnion<[z.ZodObject<{
|
|
244
|
+
file_path: z.ZodString;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
file_path: string;
|
|
247
|
+
}, {
|
|
248
|
+
file_path: string;
|
|
249
|
+
}>, z.ZodObject<{
|
|
250
|
+
file_path: z.ZodString;
|
|
251
|
+
content: z.ZodString;
|
|
252
|
+
}, "strip", z.ZodTypeAny, {
|
|
253
|
+
content: string;
|
|
254
|
+
file_path: string;
|
|
255
|
+
}, {
|
|
256
|
+
content: string;
|
|
257
|
+
file_path: string;
|
|
258
|
+
}>, z.ZodObject<{
|
|
259
|
+
dir_path: z.ZodString;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
dir_path: string;
|
|
262
|
+
}, {
|
|
263
|
+
dir_path: string;
|
|
264
|
+
}>, z.ZodObject<{
|
|
265
|
+
pattern: z.ZodString;
|
|
266
|
+
}, "strip", z.ZodTypeAny, {
|
|
267
|
+
pattern: string;
|
|
268
|
+
}, {
|
|
269
|
+
pattern: string;
|
|
270
|
+
}>, z.ZodObject<{
|
|
271
|
+
command: z.ZodString;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
command: string;
|
|
274
|
+
}, {
|
|
275
|
+
command: string;
|
|
276
|
+
}>, z.ZodObject<{
|
|
277
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
278
|
+
description: z.ZodString;
|
|
279
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "in_progress", "completed"]>>;
|
|
280
|
+
}, "strip", z.ZodTypeAny, {
|
|
281
|
+
description: string;
|
|
282
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
283
|
+
}, {
|
|
284
|
+
description: string;
|
|
285
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
286
|
+
}>, "many">;
|
|
287
|
+
}, "strip", z.ZodTypeAny, {
|
|
288
|
+
todos: {
|
|
289
|
+
description: string;
|
|
290
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
291
|
+
}[];
|
|
292
|
+
}, {
|
|
293
|
+
todos: {
|
|
294
|
+
description: string;
|
|
295
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
296
|
+
}[];
|
|
297
|
+
}>, z.ZodObject<{
|
|
298
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
299
|
+
file_path: z.ZodOptional<z.ZodString>;
|
|
300
|
+
old_string: z.ZodOptional<z.ZodString>;
|
|
301
|
+
new_string: z.ZodOptional<z.ZodString>;
|
|
302
|
+
}, "strip", z.ZodTypeAny, {
|
|
303
|
+
file_path?: string | undefined;
|
|
304
|
+
instruction?: string | undefined;
|
|
305
|
+
old_string?: string | undefined;
|
|
306
|
+
new_string?: string | undefined;
|
|
307
|
+
}, {
|
|
308
|
+
file_path?: string | undefined;
|
|
309
|
+
instruction?: string | undefined;
|
|
310
|
+
old_string?: string | undefined;
|
|
311
|
+
new_string?: string | undefined;
|
|
312
|
+
}>]>;
|
|
313
|
+
export type ReadFileParameters = z.infer<typeof ReadFileParametersSchema>;
|
|
314
|
+
export type WriteFileParameters = z.infer<typeof WriteFileParametersSchema>;
|
|
315
|
+
export type ListDirectoryParameters = z.infer<typeof ListDirectoryParametersSchema>;
|
|
316
|
+
export type SearchFileContentParameters = z.infer<typeof SearchFileContentParametersSchema>;
|
|
317
|
+
export type RunShellCommandParameters = z.infer<typeof RunShellCommandParametersSchema>;
|
|
318
|
+
export type TodoItem = z.infer<typeof TodoItemSchema>;
|
|
319
|
+
export type WriteTodosParameters = z.infer<typeof WriteTodosParametersSchema>;
|
|
320
|
+
export type ReplaceParameters = z.infer<typeof ReplaceParametersSchema>;
|
|
321
|
+
export type GeminiToolParameters = z.infer<typeof GeminiToolParametersSchema>;
|
|
322
|
+
/**
|
|
323
|
+
* Type for tool input parameters used by GeminiMessageFormatter
|
|
324
|
+
*
|
|
325
|
+
* This is a permissive type that allows accessing any property while still
|
|
326
|
+
* being more explicit than `any`. It represents the union of:
|
|
327
|
+
* - Known Gemini CLI tool parameters (read_file, write_file, etc.)
|
|
328
|
+
* - Unknown tool parameters from MCP or future tools
|
|
329
|
+
*
|
|
330
|
+
* We use Record<string, unknown> instead of a discriminated union because:
|
|
331
|
+
* 1. The formatter uses switch on toolName (string), not on input structure
|
|
332
|
+
* 2. Properties are accessed dynamically based on the tool type
|
|
333
|
+
* 3. TypeScript can't narrow Record types based on external string values
|
|
334
|
+
*
|
|
335
|
+
* Known properties that may exist (based on Gemini tools):
|
|
336
|
+
* - file_path: string (read_file, write_file, replace)
|
|
337
|
+
* - content: string (write_file)
|
|
338
|
+
* - dir_path: string (list_directory)
|
|
339
|
+
* - pattern: string (search_file_content)
|
|
340
|
+
* - command: string (run_shell_command)
|
|
341
|
+
* - description: string (run_shell_command, todos)
|
|
342
|
+
* - todos: Array<{description, status}> (write_todos)
|
|
343
|
+
* - instruction: string (replace)
|
|
344
|
+
* - old_string: string (replace)
|
|
345
|
+
* - new_string: string (replace)
|
|
346
|
+
*/
|
|
347
|
+
export type FormatterToolInput = Record<string, unknown>;
|
|
348
|
+
/**
|
|
349
|
+
* Typed read_file tool use event
|
|
350
|
+
*/
|
|
351
|
+
export declare const ReadFileToolUseEventSchema: z.ZodObject<{
|
|
352
|
+
type: z.ZodLiteral<"tool_use">;
|
|
353
|
+
timestamp: z.ZodString;
|
|
354
|
+
tool_id: z.ZodString;
|
|
355
|
+
} & {
|
|
356
|
+
tool_name: z.ZodLiteral<"read_file">;
|
|
357
|
+
parameters: z.ZodObject<{
|
|
358
|
+
file_path: z.ZodString;
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
file_path: string;
|
|
361
|
+
}, {
|
|
362
|
+
file_path: string;
|
|
363
|
+
}>;
|
|
364
|
+
}, "strip", z.ZodTypeAny, {
|
|
365
|
+
type: "tool_use";
|
|
366
|
+
timestamp: string;
|
|
367
|
+
tool_id: string;
|
|
368
|
+
tool_name: "read_file";
|
|
369
|
+
parameters: {
|
|
370
|
+
file_path: string;
|
|
371
|
+
};
|
|
372
|
+
}, {
|
|
373
|
+
type: "tool_use";
|
|
374
|
+
timestamp: string;
|
|
375
|
+
tool_id: string;
|
|
376
|
+
tool_name: "read_file";
|
|
377
|
+
parameters: {
|
|
378
|
+
file_path: string;
|
|
379
|
+
};
|
|
380
|
+
}>;
|
|
381
|
+
/**
|
|
382
|
+
* Typed write_file tool use event
|
|
383
|
+
*/
|
|
384
|
+
export declare const WriteFileToolUseEventSchema: z.ZodObject<{
|
|
385
|
+
type: z.ZodLiteral<"tool_use">;
|
|
386
|
+
timestamp: z.ZodString;
|
|
387
|
+
tool_id: z.ZodString;
|
|
388
|
+
} & {
|
|
389
|
+
tool_name: z.ZodLiteral<"write_file">;
|
|
390
|
+
parameters: z.ZodObject<{
|
|
391
|
+
file_path: z.ZodString;
|
|
392
|
+
content: z.ZodString;
|
|
393
|
+
}, "strip", z.ZodTypeAny, {
|
|
394
|
+
content: string;
|
|
395
|
+
file_path: string;
|
|
396
|
+
}, {
|
|
397
|
+
content: string;
|
|
398
|
+
file_path: string;
|
|
399
|
+
}>;
|
|
400
|
+
}, "strip", z.ZodTypeAny, {
|
|
401
|
+
type: "tool_use";
|
|
402
|
+
timestamp: string;
|
|
403
|
+
tool_id: string;
|
|
404
|
+
tool_name: "write_file";
|
|
405
|
+
parameters: {
|
|
406
|
+
content: string;
|
|
407
|
+
file_path: string;
|
|
408
|
+
};
|
|
409
|
+
}, {
|
|
410
|
+
type: "tool_use";
|
|
411
|
+
timestamp: string;
|
|
412
|
+
tool_id: string;
|
|
413
|
+
tool_name: "write_file";
|
|
414
|
+
parameters: {
|
|
415
|
+
content: string;
|
|
416
|
+
file_path: string;
|
|
417
|
+
};
|
|
418
|
+
}>;
|
|
419
|
+
/**
|
|
420
|
+
* Typed list_directory tool use event
|
|
421
|
+
*/
|
|
422
|
+
export declare const ListDirectoryToolUseEventSchema: z.ZodObject<{
|
|
423
|
+
type: z.ZodLiteral<"tool_use">;
|
|
424
|
+
timestamp: z.ZodString;
|
|
425
|
+
tool_id: z.ZodString;
|
|
426
|
+
} & {
|
|
427
|
+
tool_name: z.ZodLiteral<"list_directory">;
|
|
428
|
+
parameters: z.ZodObject<{
|
|
429
|
+
dir_path: z.ZodString;
|
|
430
|
+
}, "strip", z.ZodTypeAny, {
|
|
431
|
+
dir_path: string;
|
|
432
|
+
}, {
|
|
433
|
+
dir_path: string;
|
|
434
|
+
}>;
|
|
435
|
+
}, "strip", z.ZodTypeAny, {
|
|
436
|
+
type: "tool_use";
|
|
437
|
+
timestamp: string;
|
|
438
|
+
tool_id: string;
|
|
439
|
+
tool_name: "list_directory";
|
|
440
|
+
parameters: {
|
|
441
|
+
dir_path: string;
|
|
442
|
+
};
|
|
443
|
+
}, {
|
|
444
|
+
type: "tool_use";
|
|
445
|
+
timestamp: string;
|
|
446
|
+
tool_id: string;
|
|
447
|
+
tool_name: "list_directory";
|
|
448
|
+
parameters: {
|
|
449
|
+
dir_path: string;
|
|
450
|
+
};
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Typed search_file_content tool use event
|
|
454
|
+
*/
|
|
455
|
+
export declare const SearchFileContentToolUseEventSchema: z.ZodObject<{
|
|
456
|
+
type: z.ZodLiteral<"tool_use">;
|
|
457
|
+
timestamp: z.ZodString;
|
|
458
|
+
tool_id: z.ZodString;
|
|
459
|
+
} & {
|
|
460
|
+
tool_name: z.ZodLiteral<"search_file_content">;
|
|
461
|
+
parameters: z.ZodObject<{
|
|
462
|
+
pattern: z.ZodString;
|
|
463
|
+
}, "strip", z.ZodTypeAny, {
|
|
464
|
+
pattern: string;
|
|
465
|
+
}, {
|
|
466
|
+
pattern: string;
|
|
467
|
+
}>;
|
|
468
|
+
}, "strip", z.ZodTypeAny, {
|
|
469
|
+
type: "tool_use";
|
|
470
|
+
timestamp: string;
|
|
471
|
+
tool_id: string;
|
|
472
|
+
tool_name: "search_file_content";
|
|
473
|
+
parameters: {
|
|
474
|
+
pattern: string;
|
|
475
|
+
};
|
|
476
|
+
}, {
|
|
477
|
+
type: "tool_use";
|
|
478
|
+
timestamp: string;
|
|
479
|
+
tool_id: string;
|
|
480
|
+
tool_name: "search_file_content";
|
|
481
|
+
parameters: {
|
|
482
|
+
pattern: string;
|
|
483
|
+
};
|
|
484
|
+
}>;
|
|
485
|
+
/**
|
|
486
|
+
* Typed run_shell_command tool use event
|
|
487
|
+
*/
|
|
488
|
+
export declare const RunShellCommandToolUseEventSchema: z.ZodObject<{
|
|
489
|
+
type: z.ZodLiteral<"tool_use">;
|
|
490
|
+
timestamp: z.ZodString;
|
|
491
|
+
tool_id: z.ZodString;
|
|
492
|
+
} & {
|
|
493
|
+
tool_name: z.ZodLiteral<"run_shell_command">;
|
|
494
|
+
parameters: z.ZodObject<{
|
|
495
|
+
command: z.ZodString;
|
|
496
|
+
}, "strip", z.ZodTypeAny, {
|
|
497
|
+
command: string;
|
|
498
|
+
}, {
|
|
499
|
+
command: string;
|
|
500
|
+
}>;
|
|
501
|
+
}, "strip", z.ZodTypeAny, {
|
|
502
|
+
type: "tool_use";
|
|
503
|
+
timestamp: string;
|
|
504
|
+
tool_id: string;
|
|
505
|
+
tool_name: "run_shell_command";
|
|
506
|
+
parameters: {
|
|
507
|
+
command: string;
|
|
508
|
+
};
|
|
509
|
+
}, {
|
|
510
|
+
type: "tool_use";
|
|
511
|
+
timestamp: string;
|
|
512
|
+
tool_id: string;
|
|
513
|
+
tool_name: "run_shell_command";
|
|
514
|
+
parameters: {
|
|
515
|
+
command: string;
|
|
516
|
+
};
|
|
517
|
+
}>;
|
|
518
|
+
/**
|
|
519
|
+
* Typed write_todos tool use event
|
|
520
|
+
*/
|
|
521
|
+
export declare const WriteTodosToolUseEventSchema: z.ZodObject<{
|
|
522
|
+
type: z.ZodLiteral<"tool_use">;
|
|
523
|
+
timestamp: z.ZodString;
|
|
524
|
+
tool_id: z.ZodString;
|
|
525
|
+
} & {
|
|
526
|
+
tool_name: z.ZodLiteral<"write_todos">;
|
|
527
|
+
parameters: z.ZodObject<{
|
|
528
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
529
|
+
description: z.ZodString;
|
|
530
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "in_progress", "completed"]>>;
|
|
531
|
+
}, "strip", z.ZodTypeAny, {
|
|
532
|
+
description: string;
|
|
533
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
534
|
+
}, {
|
|
535
|
+
description: string;
|
|
536
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
537
|
+
}>, "many">;
|
|
538
|
+
}, "strip", z.ZodTypeAny, {
|
|
539
|
+
todos: {
|
|
540
|
+
description: string;
|
|
541
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
542
|
+
}[];
|
|
543
|
+
}, {
|
|
544
|
+
todos: {
|
|
545
|
+
description: string;
|
|
546
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
547
|
+
}[];
|
|
548
|
+
}>;
|
|
549
|
+
}, "strip", z.ZodTypeAny, {
|
|
550
|
+
type: "tool_use";
|
|
551
|
+
timestamp: string;
|
|
552
|
+
tool_id: string;
|
|
553
|
+
tool_name: "write_todos";
|
|
554
|
+
parameters: {
|
|
555
|
+
todos: {
|
|
556
|
+
description: string;
|
|
557
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
558
|
+
}[];
|
|
559
|
+
};
|
|
560
|
+
}, {
|
|
561
|
+
type: "tool_use";
|
|
562
|
+
timestamp: string;
|
|
563
|
+
tool_id: string;
|
|
564
|
+
tool_name: "write_todos";
|
|
565
|
+
parameters: {
|
|
566
|
+
todos: {
|
|
567
|
+
description: string;
|
|
568
|
+
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
569
|
+
}[];
|
|
570
|
+
};
|
|
571
|
+
}>;
|
|
572
|
+
/**
|
|
573
|
+
* Typed replace tool use event
|
|
574
|
+
*/
|
|
575
|
+
export declare const ReplaceToolUseEventSchema: z.ZodObject<{
|
|
576
|
+
type: z.ZodLiteral<"tool_use">;
|
|
577
|
+
timestamp: z.ZodString;
|
|
578
|
+
tool_id: z.ZodString;
|
|
579
|
+
} & {
|
|
580
|
+
tool_name: z.ZodLiteral<"replace">;
|
|
581
|
+
parameters: z.ZodObject<{
|
|
582
|
+
instruction: z.ZodOptional<z.ZodString>;
|
|
583
|
+
file_path: z.ZodOptional<z.ZodString>;
|
|
584
|
+
old_string: z.ZodOptional<z.ZodString>;
|
|
585
|
+
new_string: z.ZodOptional<z.ZodString>;
|
|
586
|
+
}, "strip", z.ZodTypeAny, {
|
|
587
|
+
file_path?: string | undefined;
|
|
588
|
+
instruction?: string | undefined;
|
|
589
|
+
old_string?: string | undefined;
|
|
590
|
+
new_string?: string | undefined;
|
|
591
|
+
}, {
|
|
592
|
+
file_path?: string | undefined;
|
|
593
|
+
instruction?: string | undefined;
|
|
594
|
+
old_string?: string | undefined;
|
|
595
|
+
new_string?: string | undefined;
|
|
596
|
+
}>;
|
|
597
|
+
}, "strip", z.ZodTypeAny, {
|
|
598
|
+
type: "tool_use";
|
|
599
|
+
timestamp: string;
|
|
600
|
+
tool_id: string;
|
|
601
|
+
tool_name: "replace";
|
|
602
|
+
parameters: {
|
|
603
|
+
file_path?: string | undefined;
|
|
604
|
+
instruction?: string | undefined;
|
|
605
|
+
old_string?: string | undefined;
|
|
606
|
+
new_string?: string | undefined;
|
|
607
|
+
};
|
|
608
|
+
}, {
|
|
609
|
+
type: "tool_use";
|
|
610
|
+
timestamp: string;
|
|
611
|
+
tool_id: string;
|
|
612
|
+
tool_name: "replace";
|
|
613
|
+
parameters: {
|
|
614
|
+
file_path?: string | undefined;
|
|
615
|
+
instruction?: string | undefined;
|
|
616
|
+
old_string?: string | undefined;
|
|
617
|
+
new_string?: string | undefined;
|
|
618
|
+
};
|
|
619
|
+
}>;
|
|
620
|
+
/**
|
|
621
|
+
* Unknown tool use event (for tools not explicitly typed)
|
|
622
|
+
*/
|
|
623
|
+
export declare const UnknownToolUseEventSchema: z.ZodObject<{
|
|
624
|
+
type: z.ZodLiteral<"tool_use">;
|
|
625
|
+
timestamp: z.ZodString;
|
|
626
|
+
tool_id: z.ZodString;
|
|
627
|
+
} & {
|
|
628
|
+
tool_name: z.ZodString;
|
|
629
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
630
|
+
}, "strip", z.ZodTypeAny, {
|
|
631
|
+
type: "tool_use";
|
|
632
|
+
timestamp: string;
|
|
633
|
+
tool_id: string;
|
|
634
|
+
tool_name: string;
|
|
635
|
+
parameters: Record<string, unknown>;
|
|
636
|
+
}, {
|
|
637
|
+
type: "tool_use";
|
|
638
|
+
timestamp: string;
|
|
639
|
+
tool_id: string;
|
|
640
|
+
tool_name: string;
|
|
641
|
+
parameters: Record<string, unknown>;
|
|
642
|
+
}>;
|
|
643
|
+
export type ReadFileToolUseEvent = z.infer<typeof ReadFileToolUseEventSchema>;
|
|
644
|
+
export type WriteFileToolUseEvent = z.infer<typeof WriteFileToolUseEventSchema>;
|
|
645
|
+
export type ListDirectoryToolUseEvent = z.infer<typeof ListDirectoryToolUseEventSchema>;
|
|
646
|
+
export type SearchFileContentToolUseEvent = z.infer<typeof SearchFileContentToolUseEventSchema>;
|
|
647
|
+
export type RunShellCommandToolUseEvent = z.infer<typeof RunShellCommandToolUseEventSchema>;
|
|
648
|
+
export type WriteTodosToolUseEvent = z.infer<typeof WriteTodosToolUseEventSchema>;
|
|
649
|
+
export type ReplaceToolUseEvent = z.infer<typeof ReplaceToolUseEventSchema>;
|
|
650
|
+
export type UnknownToolUseEvent = z.infer<typeof UnknownToolUseEventSchema>;
|
|
651
|
+
/**
|
|
652
|
+
* Tool use event - represents a tool invocation by the model
|
|
653
|
+
*
|
|
654
|
+
* The tool_id is assigned by Gemini CLI and follows the format:
|
|
655
|
+
* `{tool_name}-{timestamp_ms}-{random_hex}`
|
|
656
|
+
*
|
|
657
|
+
* Example:
|
|
658
|
+
* ```json
|
|
659
|
+
* {"type":"tool_use","timestamp":"2025-11-25T03:27:54.691Z","tool_name":"list_directory","tool_id":"list_directory-1764041274691-eabd3cbcdee66","parameters":{"dir_path":"."}}
|
|
660
|
+
* {"type":"tool_use","timestamp":"2025-11-25T03:27:54.691Z","tool_name":"read_file","tool_id":"read_file-1764041274691-e1084c2fd73dc","parameters":{"file_path":"test.ts"}}
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
export declare const GeminiToolUseEventSchema: z.ZodObject<{
|
|
664
|
+
type: z.ZodLiteral<"tool_use">;
|
|
665
|
+
timestamp: z.ZodString;
|
|
666
|
+
tool_name: z.ZodString;
|
|
667
|
+
tool_id: z.ZodString;
|
|
668
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
669
|
+
}, "strip", z.ZodTypeAny, {
|
|
670
|
+
type: "tool_use";
|
|
671
|
+
timestamp: string;
|
|
672
|
+
tool_id: string;
|
|
673
|
+
tool_name: string;
|
|
674
|
+
parameters: Record<string, unknown>;
|
|
675
|
+
}, {
|
|
676
|
+
type: "tool_use";
|
|
677
|
+
timestamp: string;
|
|
678
|
+
tool_id: string;
|
|
679
|
+
tool_name: string;
|
|
680
|
+
parameters: Record<string, unknown>;
|
|
681
|
+
}>;
|
|
682
|
+
/**
|
|
683
|
+
* Tool result event - the result of a tool execution
|
|
684
|
+
*
|
|
685
|
+
* Uses tool_id (not tool_name) to match the corresponding tool_use event.
|
|
686
|
+
* Contains either output (success) or error (failure).
|
|
687
|
+
*
|
|
688
|
+
* Examples:
|
|
689
|
+
* Success:
|
|
690
|
+
* ```json
|
|
691
|
+
* {"type":"tool_result","timestamp":"2025-11-25T03:27:54.724Z","tool_id":"list_directory-1764041274691-eabd3cbcdee66","status":"success","output":"Listed 2 item(s)."}
|
|
692
|
+
* ```
|
|
693
|
+
*
|
|
694
|
+
* Error:
|
|
695
|
+
* ```json
|
|
696
|
+
* {"type":"tool_result","timestamp":"2025-11-25T03:28:13.200Z","tool_id":"read_file-1764041293170-fd5f6da4bd4a1","status":"error","output":"File path must be within...","error":{"type":"invalid_tool_params","message":"File path must be within..."}}
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
export declare const GeminiToolResultEventSchema: z.ZodObject<{
|
|
700
|
+
type: z.ZodLiteral<"tool_result">;
|
|
701
|
+
timestamp: z.ZodString;
|
|
702
|
+
tool_id: z.ZodString;
|
|
703
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
704
|
+
output: z.ZodOptional<z.ZodString>;
|
|
705
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
706
|
+
type: z.ZodOptional<z.ZodString>;
|
|
707
|
+
message: z.ZodString;
|
|
708
|
+
code: z.ZodOptional<z.ZodString>;
|
|
709
|
+
}, "strip", z.ZodTypeAny, {
|
|
710
|
+
message: string;
|
|
711
|
+
type?: string | undefined;
|
|
712
|
+
code?: string | undefined;
|
|
713
|
+
}, {
|
|
714
|
+
message: string;
|
|
715
|
+
type?: string | undefined;
|
|
716
|
+
code?: string | undefined;
|
|
717
|
+
}>>;
|
|
718
|
+
}, "strip", z.ZodTypeAny, {
|
|
719
|
+
type: "tool_result";
|
|
720
|
+
status: "success" | "error";
|
|
721
|
+
timestamp: string;
|
|
722
|
+
tool_id: string;
|
|
723
|
+
error?: {
|
|
724
|
+
message: string;
|
|
725
|
+
type?: string | undefined;
|
|
726
|
+
code?: string | undefined;
|
|
727
|
+
} | undefined;
|
|
728
|
+
output?: string | undefined;
|
|
729
|
+
}, {
|
|
730
|
+
type: "tool_result";
|
|
731
|
+
status: "success" | "error";
|
|
732
|
+
timestamp: string;
|
|
733
|
+
tool_id: string;
|
|
734
|
+
error?: {
|
|
735
|
+
message: string;
|
|
736
|
+
type?: string | undefined;
|
|
737
|
+
code?: string | undefined;
|
|
738
|
+
} | undefined;
|
|
739
|
+
output?: string | undefined;
|
|
740
|
+
}>;
|
|
741
|
+
/**
|
|
742
|
+
* Tool result output types based on the originating tool
|
|
743
|
+
*
|
|
744
|
+
* These describe the expected output format for each tool type.
|
|
745
|
+
* The tool_id prefix indicates which tool generated the result.
|
|
746
|
+
*/
|
|
747
|
+
/**
|
|
748
|
+
* read_file tool result - returns empty string on success (file content is in context)
|
|
749
|
+
*
|
|
750
|
+
* Example:
|
|
751
|
+
* ```json
|
|
752
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:12:40.148Z","tool_id":"read_file-1764015160012-767cb93e436f3","status":"success","output":""}
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
export declare const ReadFileToolResultSchema: z.ZodObject<{
|
|
756
|
+
type: z.ZodLiteral<"tool_result">;
|
|
757
|
+
timestamp: z.ZodString;
|
|
758
|
+
tool_id: z.ZodString;
|
|
759
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
760
|
+
output: z.ZodOptional<z.ZodString>;
|
|
761
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
762
|
+
type: z.ZodOptional<z.ZodString>;
|
|
763
|
+
message: z.ZodString;
|
|
764
|
+
code: z.ZodOptional<z.ZodString>;
|
|
765
|
+
}, "strip", z.ZodTypeAny, {
|
|
766
|
+
message: string;
|
|
767
|
+
type?: string | undefined;
|
|
768
|
+
code?: string | undefined;
|
|
769
|
+
}, {
|
|
770
|
+
message: string;
|
|
771
|
+
type?: string | undefined;
|
|
772
|
+
code?: string | undefined;
|
|
773
|
+
}>>;
|
|
774
|
+
}, "strip", z.ZodTypeAny, {
|
|
775
|
+
type: "tool_result";
|
|
776
|
+
status: "success" | "error";
|
|
777
|
+
timestamp: string;
|
|
778
|
+
tool_id: string;
|
|
779
|
+
error?: {
|
|
780
|
+
message: string;
|
|
781
|
+
type?: string | undefined;
|
|
782
|
+
code?: string | undefined;
|
|
783
|
+
} | undefined;
|
|
784
|
+
output?: string | undefined;
|
|
785
|
+
}, {
|
|
786
|
+
type: "tool_result";
|
|
787
|
+
status: "success" | "error";
|
|
788
|
+
timestamp: string;
|
|
789
|
+
tool_id: string;
|
|
790
|
+
error?: {
|
|
791
|
+
message: string;
|
|
792
|
+
type?: string | undefined;
|
|
793
|
+
code?: string | undefined;
|
|
794
|
+
} | undefined;
|
|
795
|
+
output?: string | undefined;
|
|
796
|
+
}>;
|
|
797
|
+
/**
|
|
798
|
+
* write_file tool result - returns empty output on success
|
|
799
|
+
*
|
|
800
|
+
* Example:
|
|
801
|
+
* ```json
|
|
802
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:13:55.193Z","tool_id":"write_file-1764015234674-0581b9629931a","status":"success"}
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
export declare const WriteFileToolResultSchema: z.ZodObject<{
|
|
806
|
+
type: z.ZodLiteral<"tool_result">;
|
|
807
|
+
timestamp: z.ZodString;
|
|
808
|
+
tool_id: z.ZodString;
|
|
809
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
810
|
+
output: z.ZodOptional<z.ZodString>;
|
|
811
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
812
|
+
type: z.ZodOptional<z.ZodString>;
|
|
813
|
+
message: z.ZodString;
|
|
814
|
+
code: z.ZodOptional<z.ZodString>;
|
|
815
|
+
}, "strip", z.ZodTypeAny, {
|
|
816
|
+
message: string;
|
|
817
|
+
type?: string | undefined;
|
|
818
|
+
code?: string | undefined;
|
|
819
|
+
}, {
|
|
820
|
+
message: string;
|
|
821
|
+
type?: string | undefined;
|
|
822
|
+
code?: string | undefined;
|
|
823
|
+
}>>;
|
|
824
|
+
}, "strip", z.ZodTypeAny, {
|
|
825
|
+
type: "tool_result";
|
|
826
|
+
status: "success" | "error";
|
|
827
|
+
timestamp: string;
|
|
828
|
+
tool_id: string;
|
|
829
|
+
error?: {
|
|
830
|
+
message: string;
|
|
831
|
+
type?: string | undefined;
|
|
832
|
+
code?: string | undefined;
|
|
833
|
+
} | undefined;
|
|
834
|
+
output?: string | undefined;
|
|
835
|
+
}, {
|
|
836
|
+
type: "tool_result";
|
|
837
|
+
status: "success" | "error";
|
|
838
|
+
timestamp: string;
|
|
839
|
+
tool_id: string;
|
|
840
|
+
error?: {
|
|
841
|
+
message: string;
|
|
842
|
+
type?: string | undefined;
|
|
843
|
+
code?: string | undefined;
|
|
844
|
+
} | undefined;
|
|
845
|
+
output?: string | undefined;
|
|
846
|
+
}>;
|
|
847
|
+
/**
|
|
848
|
+
* list_directory tool result - returns summary of items found
|
|
849
|
+
*
|
|
850
|
+
* Example:
|
|
851
|
+
* ```json
|
|
852
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:12:53.273Z","tool_id":"list_directory-1764015173255-396a90dd79fa6","status":"success","output":"Listed 4 item(s). (1 ignored)"}
|
|
853
|
+
* ```
|
|
854
|
+
*/
|
|
855
|
+
export declare const ListDirectoryToolResultSchema: z.ZodObject<{
|
|
856
|
+
type: z.ZodLiteral<"tool_result">;
|
|
857
|
+
timestamp: z.ZodString;
|
|
858
|
+
tool_id: z.ZodString;
|
|
859
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
860
|
+
output: z.ZodOptional<z.ZodString>;
|
|
861
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
862
|
+
type: z.ZodOptional<z.ZodString>;
|
|
863
|
+
message: z.ZodString;
|
|
864
|
+
code: z.ZodOptional<z.ZodString>;
|
|
865
|
+
}, "strip", z.ZodTypeAny, {
|
|
866
|
+
message: string;
|
|
867
|
+
type?: string | undefined;
|
|
868
|
+
code?: string | undefined;
|
|
869
|
+
}, {
|
|
870
|
+
message: string;
|
|
871
|
+
type?: string | undefined;
|
|
872
|
+
code?: string | undefined;
|
|
873
|
+
}>>;
|
|
874
|
+
}, "strip", z.ZodTypeAny, {
|
|
875
|
+
type: "tool_result";
|
|
876
|
+
status: "success" | "error";
|
|
877
|
+
timestamp: string;
|
|
878
|
+
tool_id: string;
|
|
879
|
+
error?: {
|
|
880
|
+
message: string;
|
|
881
|
+
type?: string | undefined;
|
|
882
|
+
code?: string | undefined;
|
|
883
|
+
} | undefined;
|
|
884
|
+
output?: string | undefined;
|
|
885
|
+
}, {
|
|
886
|
+
type: "tool_result";
|
|
887
|
+
status: "success" | "error";
|
|
888
|
+
timestamp: string;
|
|
889
|
+
tool_id: string;
|
|
890
|
+
error?: {
|
|
891
|
+
message: string;
|
|
892
|
+
type?: string | undefined;
|
|
893
|
+
code?: string | undefined;
|
|
894
|
+
} | undefined;
|
|
895
|
+
output?: string | undefined;
|
|
896
|
+
}>;
|
|
897
|
+
/**
|
|
898
|
+
* search_file_content tool result - returns match info or "No matches found"
|
|
899
|
+
*
|
|
900
|
+
* Example:
|
|
901
|
+
* ```json
|
|
902
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:12:40.196Z","tool_id":"search_file_content-1764015160072-c1e0f530591f6","status":"success","output":"No matches found"}
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
export declare const SearchFileContentToolResultSchema: z.ZodObject<{
|
|
906
|
+
type: z.ZodLiteral<"tool_result">;
|
|
907
|
+
timestamp: z.ZodString;
|
|
908
|
+
tool_id: z.ZodString;
|
|
909
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
910
|
+
output: z.ZodOptional<z.ZodString>;
|
|
911
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
912
|
+
type: z.ZodOptional<z.ZodString>;
|
|
913
|
+
message: z.ZodString;
|
|
914
|
+
code: z.ZodOptional<z.ZodString>;
|
|
915
|
+
}, "strip", z.ZodTypeAny, {
|
|
916
|
+
message: string;
|
|
917
|
+
type?: string | undefined;
|
|
918
|
+
code?: string | undefined;
|
|
919
|
+
}, {
|
|
920
|
+
message: string;
|
|
921
|
+
type?: string | undefined;
|
|
922
|
+
code?: string | undefined;
|
|
923
|
+
}>>;
|
|
924
|
+
}, "strip", z.ZodTypeAny, {
|
|
925
|
+
type: "tool_result";
|
|
926
|
+
status: "success" | "error";
|
|
927
|
+
timestamp: string;
|
|
928
|
+
tool_id: string;
|
|
929
|
+
error?: {
|
|
930
|
+
message: string;
|
|
931
|
+
type?: string | undefined;
|
|
932
|
+
code?: string | undefined;
|
|
933
|
+
} | undefined;
|
|
934
|
+
output?: string | undefined;
|
|
935
|
+
}, {
|
|
936
|
+
type: "tool_result";
|
|
937
|
+
status: "success" | "error";
|
|
938
|
+
timestamp: string;
|
|
939
|
+
tool_id: string;
|
|
940
|
+
error?: {
|
|
941
|
+
message: string;
|
|
942
|
+
type?: string | undefined;
|
|
943
|
+
code?: string | undefined;
|
|
944
|
+
} | undefined;
|
|
945
|
+
output?: string | undefined;
|
|
946
|
+
}>;
|
|
947
|
+
/**
|
|
948
|
+
* run_shell_command tool result - returns command output
|
|
949
|
+
*
|
|
950
|
+
* Examples:
|
|
951
|
+
* ```json
|
|
952
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:13:15.060Z","tool_id":"run_shell_command-1764015194969-e79bcda1d6e9","status":"success","output":"/usr/bin/python3: No module named pytest"}
|
|
953
|
+
* {"type":"tool_result","timestamp":"2025-11-24T20:19:49.805Z","tool_id":"run_shell_command-1764015589776-b029531d6e71e","status":"success","output":"node"}
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
export declare const RunShellCommandToolResultSchema: z.ZodObject<{
|
|
957
|
+
type: z.ZodLiteral<"tool_result">;
|
|
958
|
+
timestamp: z.ZodString;
|
|
959
|
+
tool_id: z.ZodString;
|
|
960
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
961
|
+
output: z.ZodOptional<z.ZodString>;
|
|
962
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
963
|
+
type: z.ZodOptional<z.ZodString>;
|
|
964
|
+
message: z.ZodString;
|
|
965
|
+
code: z.ZodOptional<z.ZodString>;
|
|
966
|
+
}, "strip", z.ZodTypeAny, {
|
|
967
|
+
message: string;
|
|
968
|
+
type?: string | undefined;
|
|
969
|
+
code?: string | undefined;
|
|
970
|
+
}, {
|
|
971
|
+
message: string;
|
|
972
|
+
type?: string | undefined;
|
|
973
|
+
code?: string | undefined;
|
|
974
|
+
}>>;
|
|
975
|
+
}, "strip", z.ZodTypeAny, {
|
|
976
|
+
type: "tool_result";
|
|
977
|
+
status: "success" | "error";
|
|
978
|
+
timestamp: string;
|
|
979
|
+
tool_id: string;
|
|
980
|
+
error?: {
|
|
981
|
+
message: string;
|
|
982
|
+
type?: string | undefined;
|
|
983
|
+
code?: string | undefined;
|
|
984
|
+
} | undefined;
|
|
985
|
+
output?: string | undefined;
|
|
986
|
+
}, {
|
|
987
|
+
type: "tool_result";
|
|
988
|
+
status: "success" | "error";
|
|
989
|
+
timestamp: string;
|
|
990
|
+
tool_id: string;
|
|
991
|
+
error?: {
|
|
992
|
+
message: string;
|
|
993
|
+
type?: string | undefined;
|
|
994
|
+
code?: string | undefined;
|
|
995
|
+
} | undefined;
|
|
996
|
+
output?: string | undefined;
|
|
997
|
+
}>;
|
|
998
|
+
/**
|
|
999
|
+
* write_todos tool result - returns empty output on success, or error if invalid
|
|
1000
|
+
*
|
|
1001
|
+
* Examples:
|
|
1002
|
+
* Success:
|
|
1003
|
+
* ```json
|
|
1004
|
+
* {"type":"tool_result","timestamp":"2025-11-24T19:29:56.539Z","tool_id":"write_todos-1764012596037-37082c9903ce7","status":"success"}
|
|
1005
|
+
* ```
|
|
1006
|
+
*
|
|
1007
|
+
* Error (multiple in_progress):
|
|
1008
|
+
* ```json
|
|
1009
|
+
* {"type":"tool_result","timestamp":"2025-11-24T19:37:13.465Z","tool_id":"write_todos-1764013031965-70bbdf7c35856","status":"error","output":"Invalid parameters: Only one task can be \"in_progress\" at a time."}
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
export declare const WriteTodosToolResultSchema: z.ZodObject<{
|
|
1013
|
+
type: z.ZodLiteral<"tool_result">;
|
|
1014
|
+
timestamp: z.ZodString;
|
|
1015
|
+
tool_id: z.ZodString;
|
|
1016
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
1017
|
+
output: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1019
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1020
|
+
message: z.ZodString;
|
|
1021
|
+
code: z.ZodOptional<z.ZodString>;
|
|
1022
|
+
}, "strip", z.ZodTypeAny, {
|
|
1023
|
+
message: string;
|
|
1024
|
+
type?: string | undefined;
|
|
1025
|
+
code?: string | undefined;
|
|
1026
|
+
}, {
|
|
1027
|
+
message: string;
|
|
1028
|
+
type?: string | undefined;
|
|
1029
|
+
code?: string | undefined;
|
|
1030
|
+
}>>;
|
|
1031
|
+
}, "strip", z.ZodTypeAny, {
|
|
1032
|
+
type: "tool_result";
|
|
1033
|
+
status: "success" | "error";
|
|
1034
|
+
timestamp: string;
|
|
1035
|
+
tool_id: string;
|
|
1036
|
+
error?: {
|
|
1037
|
+
message: string;
|
|
1038
|
+
type?: string | undefined;
|
|
1039
|
+
code?: string | undefined;
|
|
1040
|
+
} | undefined;
|
|
1041
|
+
output?: string | undefined;
|
|
1042
|
+
}, {
|
|
1043
|
+
type: "tool_result";
|
|
1044
|
+
status: "success" | "error";
|
|
1045
|
+
timestamp: string;
|
|
1046
|
+
tool_id: string;
|
|
1047
|
+
error?: {
|
|
1048
|
+
message: string;
|
|
1049
|
+
type?: string | undefined;
|
|
1050
|
+
code?: string | undefined;
|
|
1051
|
+
} | undefined;
|
|
1052
|
+
output?: string | undefined;
|
|
1053
|
+
}>;
|
|
1054
|
+
/**
|
|
1055
|
+
* replace tool result - returns empty output on success
|
|
1056
|
+
*
|
|
1057
|
+
* Example:
|
|
1058
|
+
* ```json
|
|
1059
|
+
* {"type":"tool_result","timestamp":"2025-11-24T19:31:12.165Z","tool_id":"replace-1764012672140-c56f46960e14a","status":"success"}
|
|
1060
|
+
* ```
|
|
1061
|
+
*/
|
|
1062
|
+
export declare const ReplaceToolResultSchema: z.ZodObject<{
|
|
1063
|
+
type: z.ZodLiteral<"tool_result">;
|
|
1064
|
+
timestamp: z.ZodString;
|
|
1065
|
+
tool_id: z.ZodString;
|
|
1066
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
1067
|
+
output: z.ZodOptional<z.ZodString>;
|
|
1068
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1069
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1070
|
+
message: z.ZodString;
|
|
1071
|
+
code: z.ZodOptional<z.ZodString>;
|
|
1072
|
+
}, "strip", z.ZodTypeAny, {
|
|
1073
|
+
message: string;
|
|
1074
|
+
type?: string | undefined;
|
|
1075
|
+
code?: string | undefined;
|
|
1076
|
+
}, {
|
|
1077
|
+
message: string;
|
|
1078
|
+
type?: string | undefined;
|
|
1079
|
+
code?: string | undefined;
|
|
1080
|
+
}>>;
|
|
1081
|
+
}, "strip", z.ZodTypeAny, {
|
|
1082
|
+
type: "tool_result";
|
|
1083
|
+
status: "success" | "error";
|
|
1084
|
+
timestamp: string;
|
|
1085
|
+
tool_id: string;
|
|
1086
|
+
error?: {
|
|
1087
|
+
message: string;
|
|
1088
|
+
type?: string | undefined;
|
|
1089
|
+
code?: string | undefined;
|
|
1090
|
+
} | undefined;
|
|
1091
|
+
output?: string | undefined;
|
|
1092
|
+
}, {
|
|
1093
|
+
type: "tool_result";
|
|
1094
|
+
status: "success" | "error";
|
|
1095
|
+
timestamp: string;
|
|
1096
|
+
tool_id: string;
|
|
1097
|
+
error?: {
|
|
1098
|
+
message: string;
|
|
1099
|
+
type?: string | undefined;
|
|
1100
|
+
code?: string | undefined;
|
|
1101
|
+
} | undefined;
|
|
1102
|
+
output?: string | undefined;
|
|
1103
|
+
}>;
|
|
1104
|
+
export type ReadFileToolResult = z.infer<typeof ReadFileToolResultSchema>;
|
|
1105
|
+
export type WriteFileToolResult = z.infer<typeof WriteFileToolResultSchema>;
|
|
1106
|
+
export type ListDirectoryToolResult = z.infer<typeof ListDirectoryToolResultSchema>;
|
|
1107
|
+
export type SearchFileContentToolResult = z.infer<typeof SearchFileContentToolResultSchema>;
|
|
1108
|
+
export type RunShellCommandToolResult = z.infer<typeof RunShellCommandToolResultSchema>;
|
|
1109
|
+
export type WriteTodosToolResult = z.infer<typeof WriteTodosToolResultSchema>;
|
|
1110
|
+
export type ReplaceToolResult = z.infer<typeof ReplaceToolResultSchema>;
|
|
1111
|
+
/**
|
|
1112
|
+
* Type guards for tool results based on tool_id prefix
|
|
1113
|
+
*/
|
|
1114
|
+
export declare function isReadFileToolResult(event: GeminiToolResultEvent): event is ReadFileToolResult;
|
|
1115
|
+
export declare function isWriteFileToolResult(event: GeminiToolResultEvent): event is WriteFileToolResult;
|
|
1116
|
+
export declare function isListDirectoryToolResult(event: GeminiToolResultEvent): event is ListDirectoryToolResult;
|
|
1117
|
+
export declare function isSearchFileContentToolResult(event: GeminiToolResultEvent): event is SearchFileContentToolResult;
|
|
1118
|
+
export declare function isRunShellCommandToolResult(event: GeminiToolResultEvent): event is RunShellCommandToolResult;
|
|
1119
|
+
export declare function isWriteTodosToolResult(event: GeminiToolResultEvent): event is WriteTodosToolResult;
|
|
1120
|
+
export declare function isReplaceToolResult(event: GeminiToolResultEvent): event is ReplaceToolResult;
|
|
1121
|
+
/**
|
|
1122
|
+
* Extract tool name from tool_id
|
|
1123
|
+
*
|
|
1124
|
+
* Tool IDs follow the format: `{tool_name}-{timestamp_ms}-{random_hex}`
|
|
1125
|
+
*
|
|
1126
|
+
* @param toolId - The tool_id from a tool_use or tool_result event
|
|
1127
|
+
* @returns The tool name, or null if format is invalid
|
|
1128
|
+
*/
|
|
1129
|
+
export declare function extractToolNameFromId(toolId: string): string | null;
|
|
1130
|
+
/**
|
|
1131
|
+
* Non-fatal error event
|
|
1132
|
+
*
|
|
1133
|
+
* Example:
|
|
1134
|
+
* ```json
|
|
1135
|
+
* {"type":"error","timestamp":"2025-11-25T03:28:00.000Z","message":"Rate limit exceeded","code":429}
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
export declare const GeminiErrorEventSchema: z.ZodObject<{
|
|
1139
|
+
type: z.ZodLiteral<"error">;
|
|
1140
|
+
timestamp: z.ZodString;
|
|
1141
|
+
message: z.ZodString;
|
|
1142
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
1143
|
+
}, "strip", z.ZodTypeAny, {
|
|
1144
|
+
type: "error";
|
|
1145
|
+
message: string;
|
|
1146
|
+
timestamp: string;
|
|
1147
|
+
code?: number | undefined;
|
|
1148
|
+
}, {
|
|
1149
|
+
type: "error";
|
|
1150
|
+
message: string;
|
|
1151
|
+
timestamp: string;
|
|
1152
|
+
code?: number | undefined;
|
|
1153
|
+
}>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Final result event with session statistics
|
|
1156
|
+
*
|
|
1157
|
+
* Examples:
|
|
1158
|
+
* Success:
|
|
1159
|
+
* ```json
|
|
1160
|
+
* {"type":"result","timestamp":"2025-11-25T03:28:05.262Z","status":"success","stats":{"total_tokens":8064,"input_tokens":7854,"output_tokens":58,"duration_ms":2534,"tool_calls":0}}
|
|
1161
|
+
* ```
|
|
1162
|
+
*
|
|
1163
|
+
* Error:
|
|
1164
|
+
* ```json
|
|
1165
|
+
* {"type":"result","timestamp":"2025-11-25T03:27:54.727Z","status":"error","error":{"type":"FatalTurnLimitedError","message":"Reached max session turns..."},"stats":{"total_tokens":8255,"input_tokens":7862,"output_tokens":90,"duration_ms":0,"tool_calls":2}}
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
export declare const GeminiResultEventSchema: z.ZodObject<{
|
|
1169
|
+
type: z.ZodLiteral<"result">;
|
|
1170
|
+
timestamp: z.ZodString;
|
|
1171
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
1172
|
+
stats: z.ZodOptional<z.ZodObject<{
|
|
1173
|
+
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1174
|
+
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1175
|
+
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1176
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
1177
|
+
tool_calls: z.ZodOptional<z.ZodNumber>;
|
|
1178
|
+
}, "strip", z.ZodTypeAny, {
|
|
1179
|
+
total_tokens?: number | undefined;
|
|
1180
|
+
input_tokens?: number | undefined;
|
|
1181
|
+
output_tokens?: number | undefined;
|
|
1182
|
+
duration_ms?: number | undefined;
|
|
1183
|
+
tool_calls?: number | undefined;
|
|
1184
|
+
}, {
|
|
1185
|
+
total_tokens?: number | undefined;
|
|
1186
|
+
input_tokens?: number | undefined;
|
|
1187
|
+
output_tokens?: number | undefined;
|
|
1188
|
+
duration_ms?: number | undefined;
|
|
1189
|
+
tool_calls?: number | undefined;
|
|
1190
|
+
}>>;
|
|
1191
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1192
|
+
type: z.ZodString;
|
|
1193
|
+
message: z.ZodString;
|
|
1194
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
1195
|
+
}, "strip", z.ZodTypeAny, {
|
|
1196
|
+
type: string;
|
|
1197
|
+
message: string;
|
|
1198
|
+
code?: number | undefined;
|
|
1199
|
+
}, {
|
|
1200
|
+
type: string;
|
|
1201
|
+
message: string;
|
|
1202
|
+
code?: number | undefined;
|
|
1203
|
+
}>>;
|
|
1204
|
+
}, "strip", z.ZodTypeAny, {
|
|
1205
|
+
type: "result";
|
|
1206
|
+
status: "success" | "error";
|
|
1207
|
+
timestamp: string;
|
|
1208
|
+
error?: {
|
|
1209
|
+
type: string;
|
|
1210
|
+
message: string;
|
|
1211
|
+
code?: number | undefined;
|
|
1212
|
+
} | undefined;
|
|
1213
|
+
stats?: {
|
|
1214
|
+
total_tokens?: number | undefined;
|
|
1215
|
+
input_tokens?: number | undefined;
|
|
1216
|
+
output_tokens?: number | undefined;
|
|
1217
|
+
duration_ms?: number | undefined;
|
|
1218
|
+
tool_calls?: number | undefined;
|
|
1219
|
+
} | undefined;
|
|
1220
|
+
}, {
|
|
1221
|
+
type: "result";
|
|
1222
|
+
status: "success" | "error";
|
|
1223
|
+
timestamp: string;
|
|
1224
|
+
error?: {
|
|
1225
|
+
type: string;
|
|
1226
|
+
message: string;
|
|
1227
|
+
code?: number | undefined;
|
|
1228
|
+
} | undefined;
|
|
1229
|
+
stats?: {
|
|
1230
|
+
total_tokens?: number | undefined;
|
|
1231
|
+
input_tokens?: number | undefined;
|
|
1232
|
+
output_tokens?: number | undefined;
|
|
1233
|
+
duration_ms?: number | undefined;
|
|
1234
|
+
tool_calls?: number | undefined;
|
|
1235
|
+
} | undefined;
|
|
1236
|
+
}>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Discriminated union of all Gemini stream events
|
|
1239
|
+
*
|
|
1240
|
+
* Uses the 'type' field as the discriminator for type narrowing.
|
|
1241
|
+
*/
|
|
1242
|
+
export declare const GeminiStreamEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
1243
|
+
type: z.ZodLiteral<"init">;
|
|
1244
|
+
timestamp: z.ZodString;
|
|
1245
|
+
session_id: z.ZodString;
|
|
1246
|
+
model: z.ZodString;
|
|
1247
|
+
}, "strip", z.ZodTypeAny, {
|
|
1248
|
+
type: "init";
|
|
1249
|
+
timestamp: string;
|
|
1250
|
+
session_id: string;
|
|
1251
|
+
model: string;
|
|
1252
|
+
}, {
|
|
1253
|
+
type: "init";
|
|
1254
|
+
timestamp: string;
|
|
1255
|
+
session_id: string;
|
|
1256
|
+
model: string;
|
|
1257
|
+
}>, z.ZodObject<{
|
|
1258
|
+
type: z.ZodLiteral<"message">;
|
|
1259
|
+
timestamp: z.ZodString;
|
|
1260
|
+
role: z.ZodEnum<["user", "assistant"]>;
|
|
1261
|
+
content: z.ZodString;
|
|
1262
|
+
delta: z.ZodOptional<z.ZodBoolean>;
|
|
1263
|
+
}, "strip", z.ZodTypeAny, {
|
|
1264
|
+
type: "message";
|
|
1265
|
+
timestamp: string;
|
|
1266
|
+
role: "user" | "assistant";
|
|
1267
|
+
content: string;
|
|
1268
|
+
delta?: boolean | undefined;
|
|
1269
|
+
}, {
|
|
1270
|
+
type: "message";
|
|
1271
|
+
timestamp: string;
|
|
1272
|
+
role: "user" | "assistant";
|
|
1273
|
+
content: string;
|
|
1274
|
+
delta?: boolean | undefined;
|
|
1275
|
+
}>, z.ZodObject<{
|
|
1276
|
+
type: z.ZodLiteral<"tool_use">;
|
|
1277
|
+
timestamp: z.ZodString;
|
|
1278
|
+
tool_name: z.ZodString;
|
|
1279
|
+
tool_id: z.ZodString;
|
|
1280
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1281
|
+
}, "strip", z.ZodTypeAny, {
|
|
1282
|
+
type: "tool_use";
|
|
1283
|
+
timestamp: string;
|
|
1284
|
+
tool_id: string;
|
|
1285
|
+
tool_name: string;
|
|
1286
|
+
parameters: Record<string, unknown>;
|
|
1287
|
+
}, {
|
|
1288
|
+
type: "tool_use";
|
|
1289
|
+
timestamp: string;
|
|
1290
|
+
tool_id: string;
|
|
1291
|
+
tool_name: string;
|
|
1292
|
+
parameters: Record<string, unknown>;
|
|
1293
|
+
}>, z.ZodObject<{
|
|
1294
|
+
type: z.ZodLiteral<"tool_result">;
|
|
1295
|
+
timestamp: z.ZodString;
|
|
1296
|
+
tool_id: z.ZodString;
|
|
1297
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
1298
|
+
output: z.ZodOptional<z.ZodString>;
|
|
1299
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1300
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1301
|
+
message: z.ZodString;
|
|
1302
|
+
code: z.ZodOptional<z.ZodString>;
|
|
1303
|
+
}, "strip", z.ZodTypeAny, {
|
|
1304
|
+
message: string;
|
|
1305
|
+
type?: string | undefined;
|
|
1306
|
+
code?: string | undefined;
|
|
1307
|
+
}, {
|
|
1308
|
+
message: string;
|
|
1309
|
+
type?: string | undefined;
|
|
1310
|
+
code?: string | undefined;
|
|
1311
|
+
}>>;
|
|
1312
|
+
}, "strip", z.ZodTypeAny, {
|
|
1313
|
+
type: "tool_result";
|
|
1314
|
+
status: "success" | "error";
|
|
1315
|
+
timestamp: string;
|
|
1316
|
+
tool_id: string;
|
|
1317
|
+
error?: {
|
|
1318
|
+
message: string;
|
|
1319
|
+
type?: string | undefined;
|
|
1320
|
+
code?: string | undefined;
|
|
1321
|
+
} | undefined;
|
|
1322
|
+
output?: string | undefined;
|
|
1323
|
+
}, {
|
|
1324
|
+
type: "tool_result";
|
|
1325
|
+
status: "success" | "error";
|
|
1326
|
+
timestamp: string;
|
|
1327
|
+
tool_id: string;
|
|
1328
|
+
error?: {
|
|
1329
|
+
message: string;
|
|
1330
|
+
type?: string | undefined;
|
|
1331
|
+
code?: string | undefined;
|
|
1332
|
+
} | undefined;
|
|
1333
|
+
output?: string | undefined;
|
|
1334
|
+
}>, z.ZodObject<{
|
|
1335
|
+
type: z.ZodLiteral<"error">;
|
|
1336
|
+
timestamp: z.ZodString;
|
|
1337
|
+
message: z.ZodString;
|
|
1338
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
1339
|
+
}, "strip", z.ZodTypeAny, {
|
|
1340
|
+
type: "error";
|
|
1341
|
+
message: string;
|
|
1342
|
+
timestamp: string;
|
|
1343
|
+
code?: number | undefined;
|
|
1344
|
+
}, {
|
|
1345
|
+
type: "error";
|
|
1346
|
+
message: string;
|
|
1347
|
+
timestamp: string;
|
|
1348
|
+
code?: number | undefined;
|
|
1349
|
+
}>, z.ZodObject<{
|
|
1350
|
+
type: z.ZodLiteral<"result">;
|
|
1351
|
+
timestamp: z.ZodString;
|
|
1352
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
1353
|
+
stats: z.ZodOptional<z.ZodObject<{
|
|
1354
|
+
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1355
|
+
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1356
|
+
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1357
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
1358
|
+
tool_calls: z.ZodOptional<z.ZodNumber>;
|
|
1359
|
+
}, "strip", z.ZodTypeAny, {
|
|
1360
|
+
total_tokens?: number | undefined;
|
|
1361
|
+
input_tokens?: number | undefined;
|
|
1362
|
+
output_tokens?: number | undefined;
|
|
1363
|
+
duration_ms?: number | undefined;
|
|
1364
|
+
tool_calls?: number | undefined;
|
|
1365
|
+
}, {
|
|
1366
|
+
total_tokens?: number | undefined;
|
|
1367
|
+
input_tokens?: number | undefined;
|
|
1368
|
+
output_tokens?: number | undefined;
|
|
1369
|
+
duration_ms?: number | undefined;
|
|
1370
|
+
tool_calls?: number | undefined;
|
|
1371
|
+
}>>;
|
|
1372
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
1373
|
+
type: z.ZodString;
|
|
1374
|
+
message: z.ZodString;
|
|
1375
|
+
code: z.ZodOptional<z.ZodNumber>;
|
|
1376
|
+
}, "strip", z.ZodTypeAny, {
|
|
1377
|
+
type: string;
|
|
1378
|
+
message: string;
|
|
1379
|
+
code?: number | undefined;
|
|
1380
|
+
}, {
|
|
1381
|
+
type: string;
|
|
1382
|
+
message: string;
|
|
1383
|
+
code?: number | undefined;
|
|
1384
|
+
}>>;
|
|
1385
|
+
}, "strip", z.ZodTypeAny, {
|
|
1386
|
+
type: "result";
|
|
1387
|
+
status: "success" | "error";
|
|
1388
|
+
timestamp: string;
|
|
1389
|
+
error?: {
|
|
1390
|
+
type: string;
|
|
1391
|
+
message: string;
|
|
1392
|
+
code?: number | undefined;
|
|
1393
|
+
} | undefined;
|
|
1394
|
+
stats?: {
|
|
1395
|
+
total_tokens?: number | undefined;
|
|
1396
|
+
input_tokens?: number | undefined;
|
|
1397
|
+
output_tokens?: number | undefined;
|
|
1398
|
+
duration_ms?: number | undefined;
|
|
1399
|
+
tool_calls?: number | undefined;
|
|
1400
|
+
} | undefined;
|
|
1401
|
+
}, {
|
|
1402
|
+
type: "result";
|
|
1403
|
+
status: "success" | "error";
|
|
1404
|
+
timestamp: string;
|
|
1405
|
+
error?: {
|
|
1406
|
+
type: string;
|
|
1407
|
+
message: string;
|
|
1408
|
+
code?: number | undefined;
|
|
1409
|
+
} | undefined;
|
|
1410
|
+
stats?: {
|
|
1411
|
+
total_tokens?: number | undefined;
|
|
1412
|
+
input_tokens?: number | undefined;
|
|
1413
|
+
output_tokens?: number | undefined;
|
|
1414
|
+
duration_ms?: number | undefined;
|
|
1415
|
+
tool_calls?: number | undefined;
|
|
1416
|
+
} | undefined;
|
|
1417
|
+
}>]>;
|
|
1418
|
+
export type GeminiInitEvent = z.infer<typeof GeminiInitEventSchema>;
|
|
1419
|
+
export type GeminiMessageEvent = z.infer<typeof GeminiMessageEventSchema>;
|
|
1420
|
+
export type GeminiToolUseEvent = z.infer<typeof GeminiToolUseEventSchema>;
|
|
1421
|
+
export type GeminiToolResultEvent = z.infer<typeof GeminiToolResultEventSchema>;
|
|
1422
|
+
export type GeminiErrorEvent = z.infer<typeof GeminiErrorEventSchema>;
|
|
1423
|
+
export type GeminiResultEvent = z.infer<typeof GeminiResultEventSchema>;
|
|
1424
|
+
export type GeminiStreamEvent = z.infer<typeof GeminiStreamEventSchema>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Parse and validate a Gemini stream event from a JSON string
|
|
1427
|
+
*
|
|
1428
|
+
* @param jsonString - Raw JSON string from Gemini CLI stdout
|
|
1429
|
+
* @returns Validated and typed GeminiStreamEvent
|
|
1430
|
+
* @throws ZodError if validation fails
|
|
1431
|
+
*/
|
|
1432
|
+
export declare function parseGeminiStreamEvent(jsonString: string): GeminiStreamEvent;
|
|
1433
|
+
/**
|
|
1434
|
+
* Safely parse a Gemini stream event, returning null on failure
|
|
1435
|
+
*
|
|
1436
|
+
* @param jsonString - Raw JSON string from Gemini CLI stdout
|
|
1437
|
+
* @returns Validated GeminiStreamEvent or null if parsing/validation fails
|
|
1438
|
+
*/
|
|
1439
|
+
export declare function safeParseGeminiStreamEvent(jsonString: string): GeminiStreamEvent | null;
|
|
1440
|
+
/**
|
|
1441
|
+
* Type guard for checking if an event is a specific type
|
|
1442
|
+
*/
|
|
1443
|
+
export declare function isGeminiInitEvent(event: GeminiStreamEvent): event is GeminiInitEvent;
|
|
1444
|
+
export declare function isGeminiMessageEvent(event: GeminiStreamEvent): event is GeminiMessageEvent;
|
|
1445
|
+
export declare function isGeminiToolUseEvent(event: GeminiStreamEvent): event is GeminiToolUseEvent;
|
|
1446
|
+
export declare function isGeminiToolResultEvent(event: GeminiStreamEvent): event is GeminiToolResultEvent;
|
|
1447
|
+
export declare function isGeminiErrorEvent(event: GeminiStreamEvent): event is GeminiErrorEvent;
|
|
1448
|
+
export declare function isGeminiResultEvent(event: GeminiStreamEvent): event is GeminiResultEvent;
|
|
1449
|
+
/**
|
|
1450
|
+
* Parse a tool use event as a specific typed tool
|
|
1451
|
+
*
|
|
1452
|
+
* @param event - A GeminiToolUseEvent to parse
|
|
1453
|
+
* @returns The typed tool use event, or null if the tool name doesn't match or validation fails
|
|
1454
|
+
*/
|
|
1455
|
+
export declare function parseAsReadFileTool(event: GeminiToolUseEvent): ReadFileToolUseEvent | null;
|
|
1456
|
+
export declare function parseAsWriteFileTool(event: GeminiToolUseEvent): WriteFileToolUseEvent | null;
|
|
1457
|
+
export declare function parseAsListDirectoryTool(event: GeminiToolUseEvent): ListDirectoryToolUseEvent | null;
|
|
1458
|
+
export declare function parseAsSearchFileContentTool(event: GeminiToolUseEvent): SearchFileContentToolUseEvent | null;
|
|
1459
|
+
export declare function parseAsRunShellCommandTool(event: GeminiToolUseEvent): RunShellCommandToolUseEvent | null;
|
|
1460
|
+
export declare function parseAsWriteTodosTool(event: GeminiToolUseEvent): WriteTodosToolUseEvent | null;
|
|
1461
|
+
export declare function parseAsReplaceTool(event: GeminiToolUseEvent): ReplaceToolUseEvent | null;
|
|
1462
|
+
/**
|
|
1463
|
+
* Type guard for specific tool types based on tool_name
|
|
1464
|
+
*/
|
|
1465
|
+
export declare function isReadFileTool(event: GeminiToolUseEvent): event is ReadFileToolUseEvent;
|
|
1466
|
+
export declare function isWriteFileTool(event: GeminiToolUseEvent): event is WriteFileToolUseEvent;
|
|
1467
|
+
export declare function isListDirectoryTool(event: GeminiToolUseEvent): event is ListDirectoryToolUseEvent;
|
|
1468
|
+
export declare function isSearchFileContentTool(event: GeminiToolUseEvent): event is SearchFileContentToolUseEvent;
|
|
1469
|
+
export declare function isRunShellCommandTool(event: GeminiToolUseEvent): event is RunShellCommandToolUseEvent;
|
|
1470
|
+
export declare function isWriteTodosTool(event: GeminiToolUseEvent): event is WriteTodosToolUseEvent;
|
|
1471
|
+
export declare function isReplaceTool(event: GeminiToolUseEvent): event is ReplaceToolUseEvent;
|
|
1472
|
+
//# sourceMappingURL=schemas.d.ts.map
|