@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 createWriteTool(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
+ file_path: string;
9
+ content: string;
10
+ }>;
11
+ inputExamples?: {
12
+ input: NoInfer<{
13
+ file_path: string;
14
+ content: string;
15
+ }>;
16
+ }[] | undefined;
17
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
18
+ file_path: string;
19
+ content: string;
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
+ file_path: string;
29
+ content: string;
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
+ file_path: string;
40
+ content: string;
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
+ file_path: string;
52
+ content: string;
53
+ }>;
54
+ inputExamples?: {
55
+ input: NoInfer<{
56
+ file_path: string;
57
+ content: string;
58
+ }>;
59
+ }[] | undefined;
60
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
61
+ file_path: string;
62
+ content: string;
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
+ file_path: string;
72
+ content: string;
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
+ file_path: string;
83
+ content: string;
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
+ file_path: string;
95
+ content: string;
96
+ }>;
97
+ inputExamples?: {
98
+ input: NoInfer<{
99
+ file_path: string;
100
+ content: string;
101
+ }>;
102
+ }[] | undefined;
103
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
104
+ file_path: string;
105
+ content: string;
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
+ file_path: string;
115
+ content: string;
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
+ file_path: string;
126
+ content: string;
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
+ file_path: string;
141
+ content: string;
142
+ }>;
143
+ inputExamples?: {
144
+ input: NoInfer<{
145
+ file_path: string;
146
+ content: string;
147
+ }>;
148
+ }[] | undefined;
149
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
150
+ file_path: string;
151
+ content: string;
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
+ file_path: string;
161
+ content: string;
162
+ };
163
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
164
+ } & {
165
+ execute: import("ai").ToolExecuteFunction<{
166
+ file_path: string;
167
+ content: string;
168
+ }, string>;
169
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
170
+ } & {
171
+ toModelOutput?: ((options: {
172
+ toolCallId: string;
173
+ input: {
174
+ file_path: string;
175
+ content: string;
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
+ file_path: string;
187
+ content: string;
188
+ }>;
189
+ inputExamples?: {
190
+ input: NoInfer<{
191
+ file_path: string;
192
+ content: string;
193
+ }>;
194
+ }[] | undefined;
195
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
196
+ file_path: string;
197
+ content: string;
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
+ file_path: string;
207
+ content: string;
208
+ };
209
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
210
+ } & {
211
+ execute: import("ai").ToolExecuteFunction<{
212
+ file_path: string;
213
+ content: string;
214
+ }, string>;
215
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
216
+ } & {
217
+ toModelOutput?: ((options: {
218
+ toolCallId: string;
219
+ input: {
220
+ file_path: string;
221
+ content: string;
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
+ file_path: string;
233
+ content: string;
234
+ }>;
235
+ inputExamples?: {
236
+ input: NoInfer<{
237
+ file_path: string;
238
+ content: string;
239
+ }>;
240
+ }[] | undefined;
241
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
242
+ file_path: string;
243
+ content: string;
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
+ file_path: string;
253
+ content: string;
254
+ };
255
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
256
+ } & {
257
+ execute: import("ai").ToolExecuteFunction<{
258
+ file_path: string;
259
+ content: string;
260
+ }, string>;
261
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
262
+ } & {
263
+ toModelOutput?: ((options: {
264
+ toolCallId: string;
265
+ input: {
266
+ file_path: string;
267
+ content: string;
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 writeTool: ({
278
+ description?: string;
279
+ title?: string;
280
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
281
+ inputSchema: import("ai").FlexibleSchema<{
282
+ file_path: string;
283
+ content: string;
284
+ }>;
285
+ inputExamples?: {
286
+ input: NoInfer<{
287
+ file_path: string;
288
+ content: string;
289
+ }>;
290
+ }[] | undefined;
291
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
292
+ file_path: string;
293
+ content: string;
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
+ file_path: string;
303
+ content: string;
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
+ file_path: string;
314
+ content: string;
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
+ file_path: string;
326
+ content: string;
327
+ }>;
328
+ inputExamples?: {
329
+ input: NoInfer<{
330
+ file_path: string;
331
+ content: string;
332
+ }>;
333
+ }[] | undefined;
334
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
335
+ file_path: string;
336
+ content: string;
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
+ file_path: string;
346
+ content: string;
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
+ file_path: string;
357
+ content: string;
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
+ file_path: string;
369
+ content: string;
370
+ }>;
371
+ inputExamples?: {
372
+ input: NoInfer<{
373
+ file_path: string;
374
+ content: string;
375
+ }>;
376
+ }[] | undefined;
377
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
378
+ file_path: string;
379
+ content: string;
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
+ file_path: string;
389
+ content: string;
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
+ file_path: string;
400
+ content: string;
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
+ file_path: string;
415
+ content: string;
416
+ }>;
417
+ inputExamples?: {
418
+ input: NoInfer<{
419
+ file_path: string;
420
+ content: string;
421
+ }>;
422
+ }[] | undefined;
423
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
424
+ file_path: string;
425
+ content: string;
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
+ file_path: string;
435
+ content: string;
436
+ };
437
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
438
+ } & {
439
+ execute: import("ai").ToolExecuteFunction<{
440
+ file_path: string;
441
+ content: string;
442
+ }, string>;
443
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
444
+ } & {
445
+ toModelOutput?: ((options: {
446
+ toolCallId: string;
447
+ input: {
448
+ file_path: string;
449
+ content: string;
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
+ file_path: string;
461
+ content: string;
462
+ }>;
463
+ inputExamples?: {
464
+ input: NoInfer<{
465
+ file_path: string;
466
+ content: string;
467
+ }>;
468
+ }[] | undefined;
469
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
470
+ file_path: string;
471
+ content: string;
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
+ file_path: string;
481
+ content: string;
482
+ };
483
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
484
+ } & {
485
+ execute: import("ai").ToolExecuteFunction<{
486
+ file_path: string;
487
+ content: string;
488
+ }, string>;
489
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
490
+ } & {
491
+ toModelOutput?: ((options: {
492
+ toolCallId: string;
493
+ input: {
494
+ file_path: string;
495
+ content: string;
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
+ file_path: string;
507
+ content: string;
508
+ }>;
509
+ inputExamples?: {
510
+ input: NoInfer<{
511
+ file_path: string;
512
+ content: string;
513
+ }>;
514
+ }[] | undefined;
515
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
516
+ file_path: string;
517
+ content: string;
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
+ file_path: string;
527
+ content: string;
528
+ };
529
+ } & import("ai").ToolExecutionOptions) => void | PromiseLike<void>) | undefined;
530
+ } & {
531
+ execute: import("ai").ToolExecuteFunction<{
532
+ file_path: string;
533
+ content: string;
534
+ }, string>;
535
+ outputSchema?: import("ai").FlexibleSchema<string> | undefined;
536
+ } & {
537
+ toModelOutput?: ((options: {
538
+ toolCallId: string;
539
+ input: {
540
+ file_path: string;
541
+ content: string;
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,30 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ import { writeFile, mkdir } from "node:fs/promises";
4
+ import { dirname } from "node:path";
5
+ export function createWriteTool(opts) {
6
+ const baseTool = tool({
7
+ description: "Writes content to a file. Creates parent directories if needed. Overwrites existing files.",
8
+ inputSchema: z.object({
9
+ file_path: z.string().describe("Absolute path to the file to write"),
10
+ content: z.string().describe("The content to write to the file"),
11
+ }),
12
+ execute: async ({ file_path, content }) => {
13
+ try {
14
+ await mkdir(dirname(file_path), { recursive: true });
15
+ await writeFile(file_path, content, "utf-8");
16
+ return `File written successfully: ${file_path}`;
17
+ }
18
+ catch (err) {
19
+ return `Error writing file: ${err.message}`;
20
+ }
21
+ },
22
+ });
23
+ if (opts?.autoApprove === false) {
24
+ return Object.assign(baseTool, {
25
+ needsApproval: async () => true,
26
+ });
27
+ }
28
+ return baseTool;
29
+ }
30
+ export const writeTool = createWriteTool();