ai-sdk-provider-claude-code 3.1.0 → 3.3.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.
package/README.md CHANGED
@@ -46,17 +46,13 @@ npm install ai-sdk-provider-claude-code@ai-sdk-v4 ai@^4.3.16
46
46
 
47
47
  ## Zod Compatibility
48
48
 
49
- This package is **fully compatible with both Zod 3 and Zod 4**.
49
+ **Starting from v3.2.0, this package requires Zod 4.**
50
50
 
51
51
  ```bash
52
- # With Zod 3
53
- npm install ai-sdk-provider-claude-code ai zod@^3.0.0
54
-
55
- # With Zod 4
56
52
  npm install ai-sdk-provider-claude-code ai zod@^4.0.0
57
53
  ```
58
54
 
59
- Both this package and the underlying `@anthropic-ai/claude-agent-sdk` declare support for both versions (`peerDependencies: "zod": "^3.24.1 || ^4.0.0"`).
55
+ > **Note:** Zod 3 support was dropped in v3.2.0 due to the underlying `@anthropic-ai/claude-agent-sdk@0.2.x` requiring Zod 4. If you need Zod 3 support, use `ai-sdk-provider-claude-code@3.1.x`.
60
56
 
61
57
  ## Installation
62
58
 
@@ -271,11 +267,31 @@ console.log(result.object); // Guaranteed to match schema
271
267
 
272
268
  ## Agent SDK Options (Advanced)
273
269
 
274
- This provider now exposes additional Agent SDK options directly (e.g. `betas`, `sandbox`,
275
- `plugins`, `resumeSessionAt`, `enableFileCheckpointing`, `maxBudgetUsd`, `tools`,
276
- `allowDangerouslySkipPermissions`).
270
+ This provider exposes Agent SDK options directly. Key options include:
271
+
272
+ | Option | Description |
273
+ | --------------------------------- | --------------------------------------------------------------------------------------------------------- |
274
+ | `betas` | Enable beta features (e.g., `['context-1m-2025-08-07']`) |
275
+ | `sandbox` | Configure sandbox behavior (`{ enabled: true }`) |
276
+ | `plugins` | Load custom plugins from local paths |
277
+ | `resumeSessionAt` | Resume session at a specific message UUID |
278
+ | `enableFileCheckpointing` | Enable file rewind support |
279
+ | `maxBudgetUsd` | Maximum budget in USD for the query |
280
+ | `tools` | Tool configuration (array of names or preset) |
281
+ | `allowDangerouslySkipPermissions` | Allow bypassing permissions |
282
+ | `persistSession` | When `false`, disables session persistence to disk (v3.2.0+) |
283
+ | `spawnClaudeCodeProcess` | Custom process spawner for VMs/containers (v3.2.0+) |
284
+ | `permissionMode` | Permission mode: `'default'`, `'acceptEdits'`, `'bypassPermissions'`, `'plan'`, `'delegate'`, `'dontAsk'` |
285
+
286
+ **Agent definitions** (`agents`) now support additional fields (v3.2.0+):
287
+
288
+ - `disallowedTools` - Tools to explicitly disallow for the agent
289
+ - `mcpServers` - MCP servers available to the agent
290
+ - `criticalSystemReminder_EXPERIMENTAL` - Experimental critical reminder
277
291
 
278
- For newer SDK options, use the `sdkOptions` escape hatch. It **overrides** explicit settings,
292
+ See [`ClaudeCodeSettings`](https://github.com/ben-vargas/ai-sdk-provider-claude-code/blob/main/src/types.ts) for the full list of supported options (e.g., `allowedTools`, `disallowedTools`, `hooks`, `canUseTool`, `env`, `settingSources`).
293
+
294
+ For options not explicitly exposed, use the `sdkOptions` escape hatch. It **overrides** explicit settings,
279
295
  but provider-managed fields are ignored (`model`, `abortController`, `prompt`, `outputFormat`).
280
296
  If you set `sdkOptions.resume`, it also drives the streaming prompt `session_id` so the SDK
281
297
  and prompt target the same session.
@@ -284,6 +300,7 @@ and prompt target the same session.
284
300
  const model = claudeCode('sonnet', {
285
301
  betas: ['context-1m-2025-08-07'],
286
302
  sandbox: { enabled: true },
303
+ persistSession: false, // Don't persist session to disk
287
304
  sdkOptions: {
288
305
  maxBudgetUsd: 1,
289
306
  resume: 'session-abc',
@@ -344,6 +361,31 @@ See [examples/skills-management.ts](examples/skills-management.ts) for more exam
344
361
  - For parity with other tool events, `tool-error` includes `providerExecuted: true` and `providerMetadata['claude-code']` (e.g., `rawError`). These fields are documented extensions; downstream consumers may safely ignore them if unused.
345
362
  - See Tool Streaming Support for full event list, ordering guarantees, and performance considerations.
346
363
 
364
+ ## Content Block Streaming
365
+
366
+ This provider handles Anthropic `content_block_*` stream events directly for more responsive UIs:
367
+
368
+ - **Tool input streaming** — `tool-input-delta` streams arguments incrementally; `tool-call` emits when the tool input block completes (before results), enabling “running” state in UIs.
369
+ - **Text streaming** — `text-start/delta/end` emitted from content blocks with proper lifecycle management.
370
+ - **Extended thinking** — `reasoning-start/delta/end` emitted from `thinking` content blocks (availability depends on model and request).
371
+
372
+ For subagent parent/child tracking, see **Subagent Hierarchy Tracking** in this README.
373
+
374
+ ## Subagent Hierarchy Tracking
375
+
376
+ When Claude Code spawns subagents via the `Task` tool, this provider exposes parent-child relationships through `providerMetadata`:
377
+
378
+ ```ts
379
+ // Available on tool-input-start, tool-call, tool-result, and tool-error events
380
+ providerMetadata['claude-code'].parentToolCallId: string | null;
381
+ ```
382
+
383
+ - Task tools: Always null (top-level)
384
+ - Child tools: Reference their parent Task's ID
385
+ - Parallel Tasks: Child returns null if parent is ambiguous
386
+
387
+ This enables UIs to build hierarchical views of nested agent execution.
388
+
347
389
  ## Contributing
348
390
 
349
391
  We welcome contributions, especially: