@gugacoder/agentic-sdk 0.2.0

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.
Files changed (129) hide show
  1. package/dist/agent.d.ts +2 -0
  2. package/dist/agent.js +463 -0
  3. package/dist/context/compaction.d.ts +27 -0
  4. package/dist/context/compaction.js +219 -0
  5. package/dist/context/models.d.ts +6 -0
  6. package/dist/context/models.js +41 -0
  7. package/dist/context/tokenizer.d.ts +5 -0
  8. package/dist/context/tokenizer.js +11 -0
  9. package/dist/context/usage.d.ts +11 -0
  10. package/dist/context/usage.js +49 -0
  11. package/dist/display-schemas.d.ts +1865 -0
  12. package/dist/display-schemas.js +219 -0
  13. package/dist/index.d.ts +38 -0
  14. package/dist/index.js +28 -0
  15. package/dist/middleware/logging.d.ts +2 -0
  16. package/dist/middleware/logging.js +32 -0
  17. package/dist/prompts/assembly.d.ts +13 -0
  18. package/dist/prompts/assembly.js +229 -0
  19. package/dist/providers.d.ts +19 -0
  20. package/dist/providers.js +44 -0
  21. package/dist/proxy.d.ts +2 -0
  22. package/dist/proxy.js +103 -0
  23. package/dist/schemas.d.ts +228 -0
  24. package/dist/schemas.js +51 -0
  25. package/dist/session.d.ts +7 -0
  26. package/dist/session.js +102 -0
  27. package/dist/structured.d.ts +18 -0
  28. package/dist/structured.js +38 -0
  29. package/dist/tool-repair.d.ts +21 -0
  30. package/dist/tool-repair.js +72 -0
  31. package/dist/tools/api-spec.d.ts +4 -0
  32. package/dist/tools/api-spec.js +123 -0
  33. package/dist/tools/apply-patch.d.ts +484 -0
  34. package/dist/tools/apply-patch.js +157 -0
  35. package/dist/tools/ask-user.d.ts +14 -0
  36. package/dist/tools/ask-user.js +27 -0
  37. package/dist/tools/bash.d.ts +550 -0
  38. package/dist/tools/bash.js +43 -0
  39. package/dist/tools/batch.d.ts +13 -0
  40. package/dist/tools/batch.js +84 -0
  41. package/dist/tools/brave-search.d.ts +6 -0
  42. package/dist/tools/brave-search.js +19 -0
  43. package/dist/tools/code-search.d.ts +20 -0
  44. package/dist/tools/code-search.js +42 -0
  45. package/dist/tools/diagnostics.d.ts +4 -0
  46. package/dist/tools/diagnostics.js +69 -0
  47. package/dist/tools/display.d.ts +483 -0
  48. package/dist/tools/display.js +77 -0
  49. package/dist/tools/edit.d.ts +682 -0
  50. package/dist/tools/edit.js +47 -0
  51. package/dist/tools/glob.d.ts +4 -0
  52. package/dist/tools/glob.js +42 -0
  53. package/dist/tools/grep.d.ts +6 -0
  54. package/dist/tools/grep.js +69 -0
  55. package/dist/tools/http-request.d.ts +7 -0
  56. package/dist/tools/http-request.js +98 -0
  57. package/dist/tools/index.d.ts +1611 -0
  58. package/dist/tools/index.js +46 -0
  59. package/dist/tools/job-tools.d.ts +24 -0
  60. package/dist/tools/job-tools.js +67 -0
  61. package/dist/tools/list-dir.d.ts +5 -0
  62. package/dist/tools/list-dir.js +79 -0
  63. package/dist/tools/multi-edit.d.ts +814 -0
  64. package/dist/tools/multi-edit.js +57 -0
  65. package/dist/tools/read.d.ts +5 -0
  66. package/dist/tools/read.js +33 -0
  67. package/dist/tools/task.d.ts +21 -0
  68. package/dist/tools/task.js +51 -0
  69. package/dist/tools/todo.d.ts +14 -0
  70. package/dist/tools/todo.js +60 -0
  71. package/dist/tools/web-fetch.d.ts +4 -0
  72. package/dist/tools/web-fetch.js +126 -0
  73. package/dist/tools/web-search.d.ts +22 -0
  74. package/dist/tools/web-search.js +48 -0
  75. package/dist/tools/write.d.ts +550 -0
  76. package/dist/tools/write.js +30 -0
  77. package/dist/types.d.ts +201 -0
  78. package/dist/types.js +1 -0
  79. package/package.json +43 -0
  80. package/src/agent.ts +520 -0
  81. package/src/context/compaction.ts +265 -0
  82. package/src/context/models.ts +42 -0
  83. package/src/context/tokenizer.ts +12 -0
  84. package/src/context/usage.ts +65 -0
  85. package/src/display-schemas.ts +276 -0
  86. package/src/index.ts +43 -0
  87. package/src/middleware/logging.ts +37 -0
  88. package/src/prompts/assembly.ts +263 -0
  89. package/src/prompts/identity.md +10 -0
  90. package/src/prompts/patterns.md +7 -0
  91. package/src/prompts/safety.md +7 -0
  92. package/src/prompts/tool-guide.md +9 -0
  93. package/src/prompts/tools/bash.md +7 -0
  94. package/src/prompts/tools/edit.md +7 -0
  95. package/src/prompts/tools/glob.md +7 -0
  96. package/src/prompts/tools/grep.md +7 -0
  97. package/src/prompts/tools/read.md +7 -0
  98. package/src/prompts/tools/write.md +7 -0
  99. package/src/providers.ts +58 -0
  100. package/src/proxy.ts +101 -0
  101. package/src/schemas.ts +58 -0
  102. package/src/session.ts +110 -0
  103. package/src/structured.ts +65 -0
  104. package/src/tool-repair.ts +92 -0
  105. package/src/tools/api-spec.ts +158 -0
  106. package/src/tools/apply-patch.ts +188 -0
  107. package/src/tools/ask-user.ts +40 -0
  108. package/src/tools/bash.ts +51 -0
  109. package/src/tools/batch.ts +103 -0
  110. package/src/tools/brave-search.ts +24 -0
  111. package/src/tools/code-search.ts +69 -0
  112. package/src/tools/diagnostics.ts +93 -0
  113. package/src/tools/display.ts +105 -0
  114. package/src/tools/edit.ts +55 -0
  115. package/src/tools/glob.ts +46 -0
  116. package/src/tools/grep.ts +68 -0
  117. package/src/tools/http-request.ts +103 -0
  118. package/src/tools/index.ts +48 -0
  119. package/src/tools/job-tools.ts +84 -0
  120. package/src/tools/list-dir.ts +102 -0
  121. package/src/tools/multi-edit.ts +65 -0
  122. package/src/tools/read.ts +40 -0
  123. package/src/tools/task.ts +71 -0
  124. package/src/tools/todo.ts +82 -0
  125. package/src/tools/web-fetch.ts +155 -0
  126. package/src/tools/web-search.ts +75 -0
  127. package/src/tools/write.ts +34 -0
  128. package/src/types.ts +145 -0
  129. package/tsconfig.json +17 -0
@@ -0,0 +1,550 @@
1
+ export declare function createBashTool(opts?: {
2
+ autoApprove?: boolean;
3
+ }): ({
4
+ description?: string;
5
+ title?: string;
6
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
7
+ inputSchema: import("ai").FlexibleSchema<{
8
+ command: string;
9
+ timeout?: number | undefined;
10
+ }>;
11
+ inputExamples?: {
12
+ input: NoInfer<{
13
+ command: string;
14
+ timeout?: number | undefined;
15
+ }>;
16
+ }[] | undefined;
17
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
18
+ command: string;
19
+ timeout?: number | undefined;
20
+ }> | undefined;
21
+ strict?: boolean;
22
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
23
+ onInputDelta?: (options: {
24
+ inputTextDelta: string;
25
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
26
+ onInputAvailable?: ((options: {
27
+ input: {
28
+ command: string;
29
+ timeout?: number | undefined;
30
+ };
31
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
32
+ } & {
33
+ outputSchema: import("ai").FlexibleSchema<string>;
34
+ execute?: never;
35
+ } & {
36
+ toModelOutput?: ((options: {
37
+ toolCallId: string;
38
+ input: {
39
+ command: string;
40
+ timeout?: number | undefined;
41
+ };
42
+ output: string;
43
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
44
+ } & {
45
+ type?: undefined | "function";
46
+ }) | ({
47
+ description?: string;
48
+ title?: string;
49
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
50
+ inputSchema: import("ai").FlexibleSchema<{
51
+ command: string;
52
+ timeout?: number | undefined;
53
+ }>;
54
+ inputExamples?: {
55
+ input: NoInfer<{
56
+ command: string;
57
+ timeout?: number | undefined;
58
+ }>;
59
+ }[] | undefined;
60
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
61
+ command: string;
62
+ timeout?: number | undefined;
63
+ }> | undefined;
64
+ strict?: boolean;
65
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
66
+ onInputDelta?: (options: {
67
+ inputTextDelta: string;
68
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
69
+ onInputAvailable?: ((options: {
70
+ input: {
71
+ command: string;
72
+ timeout?: number | undefined;
73
+ };
74
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
75
+ } & {
76
+ outputSchema: import("ai").FlexibleSchema<string>;
77
+ execute?: never;
78
+ } & {
79
+ toModelOutput?: ((options: {
80
+ toolCallId: string;
81
+ input: {
82
+ command: string;
83
+ timeout?: number | undefined;
84
+ };
85
+ output: string;
86
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
87
+ } & {
88
+ type: "dynamic";
89
+ }) | ({
90
+ description?: string;
91
+ title?: string;
92
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
93
+ inputSchema: import("ai").FlexibleSchema<{
94
+ command: string;
95
+ timeout?: number | undefined;
96
+ }>;
97
+ inputExamples?: {
98
+ input: NoInfer<{
99
+ command: string;
100
+ timeout?: number | undefined;
101
+ }>;
102
+ }[] | undefined;
103
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
104
+ command: string;
105
+ timeout?: number | undefined;
106
+ }> | undefined;
107
+ strict?: boolean;
108
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
109
+ onInputDelta?: (options: {
110
+ inputTextDelta: string;
111
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
112
+ onInputAvailable?: ((options: {
113
+ input: {
114
+ command: string;
115
+ timeout?: number | undefined;
116
+ };
117
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
118
+ } & {
119
+ outputSchema: import("ai").FlexibleSchema<string>;
120
+ execute?: never;
121
+ } & {
122
+ toModelOutput?: ((options: {
123
+ toolCallId: string;
124
+ input: {
125
+ command: string;
126
+ timeout?: number | undefined;
127
+ };
128
+ output: string;
129
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
130
+ } & {
131
+ type: "provider";
132
+ id: `${string}.${string}`;
133
+ args: Record<string, unknown>;
134
+ supportsDeferredResults?: boolean;
135
+ }) | ({
136
+ description?: string;
137
+ title?: string;
138
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
139
+ inputSchema: import("ai").FlexibleSchema<{
140
+ command: string;
141
+ timeout?: number | undefined;
142
+ }>;
143
+ inputExamples?: {
144
+ input: NoInfer<{
145
+ command: string;
146
+ timeout?: number | undefined;
147
+ }>;
148
+ }[] | undefined;
149
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
150
+ command: string;
151
+ timeout?: number | undefined;
152
+ }> | undefined;
153
+ strict?: boolean;
154
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
155
+ onInputDelta?: (options: {
156
+ inputTextDelta: string;
157
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
158
+ onInputAvailable?: ((options: {
159
+ input: {
160
+ command: string;
161
+ timeout?: number | undefined;
162
+ };
163
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
164
+ } & {
165
+ execute: import("ai").ToolExecuteFunction<{
166
+ command: string;
167
+ timeout?: number | undefined;
168
+ }, string>;
169
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
170
+ } & {
171
+ toModelOutput?: ((options: {
172
+ toolCallId: string;
173
+ input: {
174
+ command: string;
175
+ timeout?: number | undefined;
176
+ };
177
+ output: string;
178
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
179
+ } & {
180
+ type?: undefined | "function";
181
+ }) | ({
182
+ description?: string;
183
+ title?: string;
184
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
185
+ inputSchema: import("ai").FlexibleSchema<{
186
+ command: string;
187
+ timeout?: number | undefined;
188
+ }>;
189
+ inputExamples?: {
190
+ input: NoInfer<{
191
+ command: string;
192
+ timeout?: number | undefined;
193
+ }>;
194
+ }[] | undefined;
195
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
196
+ command: string;
197
+ timeout?: number | undefined;
198
+ }> | undefined;
199
+ strict?: boolean;
200
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
201
+ onInputDelta?: (options: {
202
+ inputTextDelta: string;
203
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
204
+ onInputAvailable?: ((options: {
205
+ input: {
206
+ command: string;
207
+ timeout?: number | undefined;
208
+ };
209
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
210
+ } & {
211
+ execute: import("ai").ToolExecuteFunction<{
212
+ command: string;
213
+ timeout?: number | undefined;
214
+ }, string>;
215
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
216
+ } & {
217
+ toModelOutput?: ((options: {
218
+ toolCallId: string;
219
+ input: {
220
+ command: string;
221
+ timeout?: number | undefined;
222
+ };
223
+ output: string;
224
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
225
+ } & {
226
+ type: "dynamic";
227
+ }) | ({
228
+ description?: string;
229
+ title?: string;
230
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
231
+ inputSchema: import("ai").FlexibleSchema<{
232
+ command: string;
233
+ timeout?: number | undefined;
234
+ }>;
235
+ inputExamples?: {
236
+ input: NoInfer<{
237
+ command: string;
238
+ timeout?: number | undefined;
239
+ }>;
240
+ }[] | undefined;
241
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
242
+ command: string;
243
+ timeout?: number | undefined;
244
+ }> | undefined;
245
+ strict?: boolean;
246
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
247
+ onInputDelta?: (options: {
248
+ inputTextDelta: string;
249
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
250
+ onInputAvailable?: ((options: {
251
+ input: {
252
+ command: string;
253
+ timeout?: number | undefined;
254
+ };
255
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
256
+ } & {
257
+ execute: import("ai").ToolExecuteFunction<{
258
+ command: string;
259
+ timeout?: number | undefined;
260
+ }, string>;
261
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
262
+ } & {
263
+ toModelOutput?: ((options: {
264
+ toolCallId: string;
265
+ input: {
266
+ command: string;
267
+ timeout?: number | undefined;
268
+ };
269
+ output: string;
270
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
271
+ } & {
272
+ type: "provider";
273
+ id: `${string}.${string}`;
274
+ args: Record<string, unknown>;
275
+ supportsDeferredResults?: boolean;
276
+ });
277
+ export declare const bashTool: ({
278
+ description?: string;
279
+ title?: string;
280
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
281
+ inputSchema: import("ai").FlexibleSchema<{
282
+ command: string;
283
+ timeout?: number | undefined;
284
+ }>;
285
+ inputExamples?: {
286
+ input: NoInfer<{
287
+ command: string;
288
+ timeout?: number | undefined;
289
+ }>;
290
+ }[] | undefined;
291
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
292
+ command: string;
293
+ timeout?: number | undefined;
294
+ }> | undefined;
295
+ strict?: boolean;
296
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
297
+ onInputDelta?: (options: {
298
+ inputTextDelta: string;
299
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
300
+ onInputAvailable?: ((options: {
301
+ input: {
302
+ command: string;
303
+ timeout?: number | undefined;
304
+ };
305
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
306
+ } & {
307
+ outputSchema: import("ai").FlexibleSchema<string>;
308
+ execute?: never;
309
+ } & {
310
+ toModelOutput?: ((options: {
311
+ toolCallId: string;
312
+ input: {
313
+ command: string;
314
+ timeout?: number | undefined;
315
+ };
316
+ output: string;
317
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
318
+ } & {
319
+ type?: undefined | "function";
320
+ }) | ({
321
+ description?: string;
322
+ title?: string;
323
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
324
+ inputSchema: import("ai").FlexibleSchema<{
325
+ command: string;
326
+ timeout?: number | undefined;
327
+ }>;
328
+ inputExamples?: {
329
+ input: NoInfer<{
330
+ command: string;
331
+ timeout?: number | undefined;
332
+ }>;
333
+ }[] | undefined;
334
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
335
+ command: string;
336
+ timeout?: number | undefined;
337
+ }> | undefined;
338
+ strict?: boolean;
339
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
340
+ onInputDelta?: (options: {
341
+ inputTextDelta: string;
342
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
343
+ onInputAvailable?: ((options: {
344
+ input: {
345
+ command: string;
346
+ timeout?: number | undefined;
347
+ };
348
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
349
+ } & {
350
+ outputSchema: import("ai").FlexibleSchema<string>;
351
+ execute?: never;
352
+ } & {
353
+ toModelOutput?: ((options: {
354
+ toolCallId: string;
355
+ input: {
356
+ command: string;
357
+ timeout?: number | undefined;
358
+ };
359
+ output: string;
360
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
361
+ } & {
362
+ type: "dynamic";
363
+ }) | ({
364
+ description?: string;
365
+ title?: string;
366
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
367
+ inputSchema: import("ai").FlexibleSchema<{
368
+ command: string;
369
+ timeout?: number | undefined;
370
+ }>;
371
+ inputExamples?: {
372
+ input: NoInfer<{
373
+ command: string;
374
+ timeout?: number | undefined;
375
+ }>;
376
+ }[] | undefined;
377
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
378
+ command: string;
379
+ timeout?: number | undefined;
380
+ }> | undefined;
381
+ strict?: boolean;
382
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
383
+ onInputDelta?: (options: {
384
+ inputTextDelta: string;
385
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
386
+ onInputAvailable?: ((options: {
387
+ input: {
388
+ command: string;
389
+ timeout?: number | undefined;
390
+ };
391
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
392
+ } & {
393
+ outputSchema: import("ai").FlexibleSchema<string>;
394
+ execute?: never;
395
+ } & {
396
+ toModelOutput?: ((options: {
397
+ toolCallId: string;
398
+ input: {
399
+ command: string;
400
+ timeout?: number | undefined;
401
+ };
402
+ output: string;
403
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
404
+ } & {
405
+ type: "provider";
406
+ id: `${string}.${string}`;
407
+ args: Record<string, unknown>;
408
+ supportsDeferredResults?: boolean;
409
+ }) | ({
410
+ description?: string;
411
+ title?: string;
412
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
413
+ inputSchema: import("ai").FlexibleSchema<{
414
+ command: string;
415
+ timeout?: number | undefined;
416
+ }>;
417
+ inputExamples?: {
418
+ input: NoInfer<{
419
+ command: string;
420
+ timeout?: number | undefined;
421
+ }>;
422
+ }[] | undefined;
423
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
424
+ command: string;
425
+ timeout?: number | undefined;
426
+ }> | undefined;
427
+ strict?: boolean;
428
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
429
+ onInputDelta?: (options: {
430
+ inputTextDelta: string;
431
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
432
+ onInputAvailable?: ((options: {
433
+ input: {
434
+ command: string;
435
+ timeout?: number | undefined;
436
+ };
437
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
438
+ } & {
439
+ execute: import("ai").ToolExecuteFunction<{
440
+ command: string;
441
+ timeout?: number | undefined;
442
+ }, string>;
443
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
444
+ } & {
445
+ toModelOutput?: ((options: {
446
+ toolCallId: string;
447
+ input: {
448
+ command: string;
449
+ timeout?: number | undefined;
450
+ };
451
+ output: string;
452
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
453
+ } & {
454
+ type?: undefined | "function";
455
+ }) | ({
456
+ description?: string;
457
+ title?: string;
458
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
459
+ inputSchema: import("ai").FlexibleSchema<{
460
+ command: string;
461
+ timeout?: number | undefined;
462
+ }>;
463
+ inputExamples?: {
464
+ input: NoInfer<{
465
+ command: string;
466
+ timeout?: number | undefined;
467
+ }>;
468
+ }[] | undefined;
469
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
470
+ command: string;
471
+ timeout?: number | undefined;
472
+ }> | undefined;
473
+ strict?: boolean;
474
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
475
+ onInputDelta?: (options: {
476
+ inputTextDelta: string;
477
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
478
+ onInputAvailable?: ((options: {
479
+ input: {
480
+ command: string;
481
+ timeout?: number | undefined;
482
+ };
483
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
484
+ } & {
485
+ execute: import("ai").ToolExecuteFunction<{
486
+ command: string;
487
+ timeout?: number | undefined;
488
+ }, string>;
489
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
490
+ } & {
491
+ toModelOutput?: ((options: {
492
+ toolCallId: string;
493
+ input: {
494
+ command: string;
495
+ timeout?: number | undefined;
496
+ };
497
+ output: string;
498
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
499
+ } & {
500
+ type: "dynamic";
501
+ }) | ({
502
+ description?: string;
503
+ title?: string;
504
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
505
+ inputSchema: import("ai").FlexibleSchema<{
506
+ command: string;
507
+ timeout?: number | undefined;
508
+ }>;
509
+ inputExamples?: {
510
+ input: NoInfer<{
511
+ command: string;
512
+ timeout?: number | undefined;
513
+ }>;
514
+ }[] | undefined;
515
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
516
+ command: string;
517
+ timeout?: number | undefined;
518
+ }> | undefined;
519
+ strict?: boolean;
520
+ onInputStart?: (options: import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
521
+ onInputDelta?: (options: {
522
+ inputTextDelta: string;
523
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>;
524
+ onInputAvailable?: ((options: {
525
+ input: {
526
+ command: string;
527
+ timeout?: number | undefined;
528
+ };
529
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
530
+ } & {
531
+ execute: import("ai").ToolExecuteFunction<{
532
+ command: string;
533
+ timeout?: number | undefined;
534
+ }, string>;
535
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
536
+ } & {
537
+ toModelOutput?: ((options: {
538
+ toolCallId: string;
539
+ input: {
540
+ command: string;
541
+ timeout?: number | undefined;
542
+ };
543
+ output: string;
544
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
545
+ } & {
546
+ type: "provider";
547
+ id: `${string}.${string}`;
548
+ args: Record<string, unknown>;
549
+ supportsDeferredResults?: boolean;
550
+ });
@@ -0,0 +1,43 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ import { exec } from "node:child_process";
4
+ const MAX_OUTPUT = 30_000;
5
+ const DEFAULT_TIMEOUT = 120_000;
6
+ export function createBashTool(opts) {
7
+ const baseTool = tool({
8
+ description: "Executes a bash command and returns stdout/stderr. Timeout defaults to 120s.",
9
+ inputSchema: z.object({
10
+ command: z.string().describe("The bash command to execute"),
11
+ timeout: z
12
+ .number()
13
+ .optional()
14
+ .describe("Timeout in milliseconds (max 600000)"),
15
+ }),
16
+ execute: async ({ command, timeout }) => {
17
+ const ms = Math.min(timeout ?? DEFAULT_TIMEOUT, 600_000);
18
+ return new Promise((resolve) => {
19
+ exec(command, { timeout: ms, maxBuffer: 10 * 1024 * 1024 }, (err, stdout, stderr) => {
20
+ let output = "";
21
+ if (stdout)
22
+ output += stdout;
23
+ if (stderr)
24
+ output += (output ? "\n" : "") + stderr;
25
+ if (err && !stdout && !stderr) {
26
+ output = `Error: ${err.message}`;
27
+ }
28
+ if (output.length > MAX_OUTPUT) {
29
+ output = output.slice(0, MAX_OUTPUT) + "\n...[truncated]";
30
+ }
31
+ resolve(output || "(no output)");
32
+ });
33
+ });
34
+ },
35
+ });
36
+ if (opts?.autoApprove === false) {
37
+ return Object.assign(baseTool, {
38
+ needsApproval: async () => true,
39
+ });
40
+ }
41
+ return baseTool;
42
+ }
43
+ export const bashTool = createBashTool();
@@ -0,0 +1,13 @@
1
+ import { type Tool } from "ai";
2
+ /**
3
+ * Factory that creates the Batch tool for parallel tool execution.
4
+ *
5
+ * Receives the resolved tool registry so it can look up tools by name.
6
+ * The Batch tool itself is excluded from the registry to prevent recursion.
7
+ */
8
+ export declare function createBatchTool(toolRegistry: Record<string, Tool>): Tool<{
9
+ tool_calls: {
10
+ tool: string;
11
+ parameters: Record<string, any>;
12
+ }[];
13
+ }, string>;
@@ -0,0 +1,84 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ const MAX_OUTPUT = 50_000;
4
+ /**
5
+ * Factory that creates the Batch tool for parallel tool execution.
6
+ *
7
+ * Receives the resolved tool registry so it can look up tools by name.
8
+ * The Batch tool itself is excluded from the registry to prevent recursion.
9
+ */
10
+ export function createBatchTool(toolRegistry) {
11
+ // Build the list of available tool names (excluding Batch itself)
12
+ const availableTools = Object.keys(toolRegistry).filter((name) => name !== "Batch");
13
+ return tool({
14
+ description: "Execute 2-10 tool calls simultaneously in parallel using Promise.allSettled(). " +
15
+ "Partial failures do not cancel other calls. " +
16
+ "Batch cannot call itself (no recursion). " +
17
+ `Available tools: ${availableTools.join(", ")}`,
18
+ inputSchema: z.object({
19
+ tool_calls: z
20
+ .array(z.object({
21
+ tool: z
22
+ .string()
23
+ .describe("Name of the tool to call (must be a registered tool)"),
24
+ parameters: z
25
+ .record(z.any())
26
+ .describe("Parameters to pass to the tool"),
27
+ }))
28
+ .min(2)
29
+ .max(10)
30
+ .describe("Array of tool calls to execute in parallel (2-10 items)"),
31
+ }),
32
+ execute: async ({ tool_calls }) => {
33
+ // Validate: no Batch inside Batch
34
+ const batchCalls = tool_calls.filter((tc) => tc.tool === "Batch");
35
+ if (batchCalls.length > 0) {
36
+ return "Error: Batch cannot call itself. Remove Batch from tool_calls.";
37
+ }
38
+ // Validate: all tools exist
39
+ const unknownTools = tool_calls.filter((tc) => !availableTools.includes(tc.tool));
40
+ if (unknownTools.length > 0) {
41
+ const names = unknownTools.map((tc) => tc.tool).join(", ");
42
+ return `Error: Unknown tool(s): ${names}. Available: ${availableTools.join(", ")}`;
43
+ }
44
+ // Execute all calls in parallel
45
+ const promises = tool_calls.map(async (tc, index) => {
46
+ const targetTool = toolRegistry[tc.tool];
47
+ if (!targetTool.execute) {
48
+ return { index, tool: tc.tool, result: `Error: Tool "${tc.tool}" has no execute function.` };
49
+ }
50
+ try {
51
+ const result = await targetTool.execute(tc.parameters, {
52
+ toolCallId: `batch-${index}-${tc.tool}`,
53
+ messages: [],
54
+ abortSignal: undefined,
55
+ });
56
+ return { index, tool: tc.tool, result: String(result) };
57
+ }
58
+ catch (err) {
59
+ return {
60
+ index,
61
+ tool: tc.tool,
62
+ result: `Error: ${err.message ?? String(err)}`,
63
+ };
64
+ }
65
+ });
66
+ const settled = await Promise.allSettled(promises);
67
+ const parts = [];
68
+ for (const outcome of settled) {
69
+ if (outcome.status === "fulfilled") {
70
+ const { index, tool: toolName, result } = outcome.value;
71
+ parts.push(`### [${index}] ${toolName}\n\n${result}`);
72
+ }
73
+ else {
74
+ parts.push(`### [?] Error\n\n${outcome.reason?.message ?? String(outcome.reason)}`);
75
+ }
76
+ }
77
+ let output = parts.join("\n\n---\n\n");
78
+ if (output.length > MAX_OUTPUT) {
79
+ output = output.slice(0, MAX_OUTPUT) + "\n...[truncated at 50KB]";
80
+ }
81
+ return output;
82
+ },
83
+ });
84
+ }
@@ -0,0 +1,6 @@
1
+ import type { WebSearchResult } from "./web-search.js";
2
+ /**
3
+ * Brave Web Search API client.
4
+ * Docs: https://api.search.brave.com/app#/documentation/web-search
5
+ */
6
+ export declare function braveSearch(query: string, numResults: number, apiKey: string): Promise<WebSearchResult[]>;