@ai-sdk/harness-claude-code 0.0.0 → 1.0.0-canary.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.
@@ -0,0 +1,376 @@
1
+ import * as zod from 'zod';
2
+ import { z } from 'zod';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
+ import * as _ai_sdk_harness from '@ai-sdk/harness';
5
+ import { HarnessV1, HarnessV1BuiltinTool } from '@ai-sdk/harness';
6
+
7
+ type ClaudeCodeAuthOptions = {
8
+ readonly anthropic?: {
9
+ readonly apiKey?: string;
10
+ readonly authToken?: string;
11
+ readonly baseUrl?: string;
12
+ };
13
+ readonly gateway?: {
14
+ readonly apiKey?: string;
15
+ readonly baseUrl?: string;
16
+ };
17
+ };
18
+
19
+ type ClaudeCodeHarnessSettings = {
20
+ readonly auth?: ClaudeCodeAuthOptions;
21
+ /**
22
+ * Anthropic model id the underlying `claude` CLI should use. Leaving this
23
+ * unset defers to the CLI's default.
24
+ */
25
+ readonly model?: string;
26
+ /**
27
+ * Hard cap on how many internal turns the CLI can take before yielding
28
+ * back to the caller. Unset means the CLI's default.
29
+ */
30
+ readonly maxTurns?: number;
31
+ /**
32
+ * Controls extended-thinking behavior. `'off'` disables thinking,
33
+ * `'on'` forces it on, `'adaptive'` lets the runtime decide.
34
+ */
35
+ readonly thinking?: 'off' | 'on' | 'adaptive';
36
+ /**
37
+ * Override the port the bridge binds inside the sandbox. By default the
38
+ * adapter uses the first port the sandbox declares via `sandbox.ports`.
39
+ * Only set this if the sandbox declares multiple ports and the first one
40
+ * is reserved for something else.
41
+ */
42
+ readonly port?: number;
43
+ /** Maximum milliseconds to wait for the bridge to advertise its port. Defaults to 120000. */
44
+ readonly startupTimeoutMs?: number;
45
+ };
46
+ declare const CLAUDE_CODE_BUILTIN_TOOLS: {
47
+ readonly read: HarnessV1BuiltinTool<{
48
+ file_path: string;
49
+ offset?: number | undefined;
50
+ limit?: number | undefined;
51
+ pages?: string | undefined;
52
+ }, unknown>;
53
+ readonly write: HarnessV1BuiltinTool<{
54
+ file_path: string;
55
+ content: string;
56
+ }, unknown>;
57
+ readonly edit: HarnessV1BuiltinTool<{
58
+ file_path: string;
59
+ old_string: string;
60
+ new_string: string;
61
+ replace_all?: boolean | undefined;
62
+ }, unknown>;
63
+ readonly bash: HarnessV1BuiltinTool<{
64
+ command: string;
65
+ description?: string | undefined;
66
+ timeout?: number | undefined;
67
+ run_in_background?: boolean | undefined;
68
+ dangerouslyDisableSandbox?: boolean | undefined;
69
+ }, unknown>;
70
+ readonly glob: HarnessV1BuiltinTool<{
71
+ pattern: string;
72
+ path?: string | undefined;
73
+ }, unknown>;
74
+ readonly grep: HarnessV1BuiltinTool<{
75
+ pattern: string;
76
+ glob?: string | undefined;
77
+ type?: string | undefined;
78
+ path?: string | undefined;
79
+ offset?: number | undefined;
80
+ output_mode?: "content" | "files_with_matches" | "count" | undefined;
81
+ '-B'?: number | undefined;
82
+ '-A'?: number | undefined;
83
+ '-C'?: number | undefined;
84
+ context?: number | undefined;
85
+ '-n'?: boolean | undefined;
86
+ '-i'?: boolean | undefined;
87
+ '-o'?: boolean | undefined;
88
+ head_limit?: number | undefined;
89
+ multiline?: boolean | undefined;
90
+ }, unknown>;
91
+ readonly webSearch: HarnessV1BuiltinTool<{
92
+ query: string;
93
+ allowed_domains?: string[] | undefined;
94
+ blocked_domains?: string[] | undefined;
95
+ }, unknown>;
96
+ readonly WebFetch: _ai_sdk_provider_utils.Tool<{
97
+ url: string;
98
+ prompt: string;
99
+ }, any, any>;
100
+ readonly NotebookEdit: _ai_sdk_provider_utils.Tool<{
101
+ notebook_path: string;
102
+ new_source: string;
103
+ cell_id?: string | undefined;
104
+ cell_type?: "code" | "markdown" | undefined;
105
+ edit_mode?: "replace" | "insert" | "delete" | undefined;
106
+ }, any, any>;
107
+ readonly TodoWrite: _ai_sdk_provider_utils.Tool<{
108
+ todos: {
109
+ status: "pending" | "in_progress" | "completed";
110
+ content: string;
111
+ activeForm: string;
112
+ }[];
113
+ }, any, any>;
114
+ readonly Agent: _ai_sdk_provider_utils.Tool<{
115
+ description: string;
116
+ prompt: string;
117
+ run_in_background?: boolean | undefined;
118
+ subagent_type?: string | undefined;
119
+ model?: "sonnet" | "opus" | "haiku" | undefined;
120
+ name?: string | undefined;
121
+ team_name?: string | undefined;
122
+ mode?: "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan" | undefined;
123
+ isolation?: "worktree" | undefined;
124
+ }, any, any>;
125
+ readonly TaskCreate: _ai_sdk_provider_utils.Tool<{
126
+ description: string;
127
+ subject: string;
128
+ metadata?: Record<string, unknown> | undefined;
129
+ activeForm?: string | undefined;
130
+ }, any, any>;
131
+ readonly TaskGet: _ai_sdk_provider_utils.Tool<{
132
+ taskId: string;
133
+ }, any, any>;
134
+ readonly TaskUpdate: _ai_sdk_provider_utils.Tool<{
135
+ taskId: string;
136
+ metadata?: Record<string, unknown> | undefined;
137
+ description?: string | undefined;
138
+ status?: "pending" | "in_progress" | "completed" | "deleted" | undefined;
139
+ activeForm?: string | undefined;
140
+ subject?: string | undefined;
141
+ addBlocks?: string[] | undefined;
142
+ addBlockedBy?: string[] | undefined;
143
+ owner?: string | undefined;
144
+ }, any, any>;
145
+ readonly TaskList: _ai_sdk_provider_utils.Tool<{}, any, any>;
146
+ readonly TaskStop: _ai_sdk_provider_utils.Tool<{
147
+ task_id?: string | undefined;
148
+ shell_id?: string | undefined;
149
+ }, any, any>;
150
+ readonly TaskOutput: _ai_sdk_provider_utils.Tool<{
151
+ timeout: number;
152
+ task_id: string;
153
+ block: boolean;
154
+ }, any, any>;
155
+ readonly ListMcpResources: _ai_sdk_provider_utils.Tool<{
156
+ server?: string | undefined;
157
+ }, any, any>;
158
+ readonly ReadMcpResource: _ai_sdk_provider_utils.Tool<{
159
+ server: string;
160
+ uri: string;
161
+ }, any, any>;
162
+ readonly ExitPlanMode: _ai_sdk_provider_utils.Tool<z.objectOutputType<{
163
+ allowedPrompts: z.ZodOptional<z.ZodArray<z.ZodObject<{
164
+ tool: z.ZodLiteral<"Bash">;
165
+ prompt: z.ZodString;
166
+ }, "strip", z.ZodTypeAny, {
167
+ prompt: string;
168
+ tool: "Bash";
169
+ }, {
170
+ prompt: string;
171
+ tool: "Bash";
172
+ }>, "many">>;
173
+ }, z.ZodTypeAny, "passthrough">, any, any>;
174
+ readonly EnterWorktree: _ai_sdk_provider_utils.Tool<{
175
+ path?: string | undefined;
176
+ name?: string | undefined;
177
+ }, any, any>;
178
+ readonly ExitWorktree: _ai_sdk_provider_utils.Tool<{
179
+ action: "keep" | "remove";
180
+ discard_changes?: boolean | undefined;
181
+ }, any, any>;
182
+ readonly AskUserQuestion: _ai_sdk_provider_utils.Tool<{
183
+ questions: {
184
+ options: {
185
+ description: string;
186
+ label: string;
187
+ preview?: string | undefined;
188
+ }[];
189
+ question: string;
190
+ header: string;
191
+ multiSelect: boolean;
192
+ }[];
193
+ metadata?: {
194
+ source?: string | undefined;
195
+ } | undefined;
196
+ answers?: Record<string, string> | undefined;
197
+ annotations?: Record<string, {
198
+ preview?: string | undefined;
199
+ notes?: string | undefined;
200
+ }> | undefined;
201
+ }, any, any>;
202
+ readonly Skill: _ai_sdk_provider_utils.Tool<{
203
+ skill: string;
204
+ args?: string | undefined;
205
+ }, any, any>;
206
+ };
207
+ declare function createClaudeCode(settings?: ClaudeCodeHarnessSettings): HarnessV1<typeof CLAUDE_CODE_BUILTIN_TOOLS>;
208
+
209
+ /**
210
+ * Default `claude-code` harness instance with no overrides — suitable for the
211
+ * common case where the underlying `claude` CLI's defaults are fine.
212
+ * Equivalent to `createClaudeCode()`.
213
+ */
214
+ declare const claudeCode: _ai_sdk_harness.HarnessV1<{
215
+ readonly read: _ai_sdk_harness.HarnessV1BuiltinTool<{
216
+ file_path: string;
217
+ offset?: number | undefined;
218
+ limit?: number | undefined;
219
+ pages?: string | undefined;
220
+ }, unknown>;
221
+ readonly write: _ai_sdk_harness.HarnessV1BuiltinTool<{
222
+ file_path: string;
223
+ content: string;
224
+ }, unknown>;
225
+ readonly edit: _ai_sdk_harness.HarnessV1BuiltinTool<{
226
+ file_path: string;
227
+ old_string: string;
228
+ new_string: string;
229
+ replace_all?: boolean | undefined;
230
+ }, unknown>;
231
+ readonly bash: _ai_sdk_harness.HarnessV1BuiltinTool<{
232
+ command: string;
233
+ description?: string | undefined;
234
+ timeout?: number | undefined;
235
+ run_in_background?: boolean | undefined;
236
+ dangerouslyDisableSandbox?: boolean | undefined;
237
+ }, unknown>;
238
+ readonly glob: _ai_sdk_harness.HarnessV1BuiltinTool<{
239
+ pattern: string;
240
+ path?: string | undefined;
241
+ }, unknown>;
242
+ readonly grep: _ai_sdk_harness.HarnessV1BuiltinTool<{
243
+ pattern: string;
244
+ glob?: string | undefined;
245
+ type?: string | undefined;
246
+ path?: string | undefined;
247
+ offset?: number | undefined;
248
+ output_mode?: "content" | "files_with_matches" | "count" | undefined;
249
+ '-B'?: number | undefined;
250
+ '-A'?: number | undefined;
251
+ '-C'?: number | undefined;
252
+ context?: number | undefined;
253
+ '-n'?: boolean | undefined;
254
+ '-i'?: boolean | undefined;
255
+ '-o'?: boolean | undefined;
256
+ head_limit?: number | undefined;
257
+ multiline?: boolean | undefined;
258
+ }, unknown>;
259
+ readonly webSearch: _ai_sdk_harness.HarnessV1BuiltinTool<{
260
+ query: string;
261
+ allowed_domains?: string[] | undefined;
262
+ blocked_domains?: string[] | undefined;
263
+ }, unknown>;
264
+ readonly WebFetch: _ai_sdk_provider_utils.Tool<{
265
+ url: string;
266
+ prompt: string;
267
+ }, any, any>;
268
+ readonly NotebookEdit: _ai_sdk_provider_utils.Tool<{
269
+ notebook_path: string;
270
+ new_source: string;
271
+ cell_id?: string | undefined;
272
+ cell_type?: "code" | "markdown" | undefined;
273
+ edit_mode?: "replace" | "insert" | "delete" | undefined;
274
+ }, any, any>;
275
+ readonly TodoWrite: _ai_sdk_provider_utils.Tool<{
276
+ todos: {
277
+ status: "pending" | "in_progress" | "completed";
278
+ content: string;
279
+ activeForm: string;
280
+ }[];
281
+ }, any, any>;
282
+ readonly Agent: _ai_sdk_provider_utils.Tool<{
283
+ description: string;
284
+ prompt: string;
285
+ run_in_background?: boolean | undefined;
286
+ subagent_type?: string | undefined;
287
+ model?: "sonnet" | "opus" | "haiku" | undefined;
288
+ name?: string | undefined;
289
+ team_name?: string | undefined;
290
+ mode?: "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan" | undefined;
291
+ isolation?: "worktree" | undefined;
292
+ }, any, any>;
293
+ readonly TaskCreate: _ai_sdk_provider_utils.Tool<{
294
+ description: string;
295
+ subject: string;
296
+ metadata?: Record<string, unknown> | undefined;
297
+ activeForm?: string | undefined;
298
+ }, any, any>;
299
+ readonly TaskGet: _ai_sdk_provider_utils.Tool<{
300
+ taskId: string;
301
+ }, any, any>;
302
+ readonly TaskUpdate: _ai_sdk_provider_utils.Tool<{
303
+ taskId: string;
304
+ metadata?: Record<string, unknown> | undefined;
305
+ description?: string | undefined;
306
+ status?: "pending" | "in_progress" | "completed" | "deleted" | undefined;
307
+ activeForm?: string | undefined;
308
+ subject?: string | undefined;
309
+ addBlocks?: string[] | undefined;
310
+ addBlockedBy?: string[] | undefined;
311
+ owner?: string | undefined;
312
+ }, any, any>;
313
+ readonly TaskList: _ai_sdk_provider_utils.Tool<{}, any, any>;
314
+ readonly TaskStop: _ai_sdk_provider_utils.Tool<{
315
+ task_id?: string | undefined;
316
+ shell_id?: string | undefined;
317
+ }, any, any>;
318
+ readonly TaskOutput: _ai_sdk_provider_utils.Tool<{
319
+ timeout: number;
320
+ task_id: string;
321
+ block: boolean;
322
+ }, any, any>;
323
+ readonly ListMcpResources: _ai_sdk_provider_utils.Tool<{
324
+ server?: string | undefined;
325
+ }, any, any>;
326
+ readonly ReadMcpResource: _ai_sdk_provider_utils.Tool<{
327
+ server: string;
328
+ uri: string;
329
+ }, any, any>;
330
+ readonly ExitPlanMode: _ai_sdk_provider_utils.Tool<zod.objectOutputType<{
331
+ allowedPrompts: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
332
+ tool: zod.ZodLiteral<"Bash">;
333
+ prompt: zod.ZodString;
334
+ }, "strip", zod.ZodTypeAny, {
335
+ prompt: string;
336
+ tool: "Bash";
337
+ }, {
338
+ prompt: string;
339
+ tool: "Bash";
340
+ }>, "many">>;
341
+ }, zod.ZodTypeAny, "passthrough">, any, any>;
342
+ readonly EnterWorktree: _ai_sdk_provider_utils.Tool<{
343
+ path?: string | undefined;
344
+ name?: string | undefined;
345
+ }, any, any>;
346
+ readonly ExitWorktree: _ai_sdk_provider_utils.Tool<{
347
+ action: "keep" | "remove";
348
+ discard_changes?: boolean | undefined;
349
+ }, any, any>;
350
+ readonly AskUserQuestion: _ai_sdk_provider_utils.Tool<{
351
+ questions: {
352
+ options: {
353
+ description: string;
354
+ label: string;
355
+ preview?: string | undefined;
356
+ }[];
357
+ question: string;
358
+ header: string;
359
+ multiSelect: boolean;
360
+ }[];
361
+ metadata?: {
362
+ source?: string | undefined;
363
+ } | undefined;
364
+ answers?: Record<string, string> | undefined;
365
+ annotations?: Record<string, {
366
+ preview?: string | undefined;
367
+ notes?: string | undefined;
368
+ }> | undefined;
369
+ }, any, any>;
370
+ readonly Skill: _ai_sdk_provider_utils.Tool<{
371
+ skill: string;
372
+ args?: string | undefined;
373
+ }, any, any>;
374
+ }>;
375
+
376
+ export { type ClaudeCodeAuthOptions, type ClaudeCodeHarnessSettings, claudeCode, createClaudeCode };