ai-sdk-provider-claude-code 3.3.6 → 3.4.1
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 +3 -0
- package/dist/index.cjs +40 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/docs/ai-sdk-v4/GUIDE.md +1 -1
- package/docs/ai-sdk-v5/GUIDE.md +56 -1
- package/package.json +6 -5
package/docs/ai-sdk-v4/GUIDE.md
CHANGED
|
@@ -252,7 +252,7 @@ const gitOnlyClaude = createClaudeCode({
|
|
|
252
252
|
|
|
253
253
|
// Mix built-in and MCP tools
|
|
254
254
|
const mixedClaude = createClaudeCode({
|
|
255
|
-
allowedTools: ['Read', 'Bash(npm test:*)', '
|
|
255
|
+
allowedTools: ['Read', 'Bash(npm test:*)', 'mcp__filesystem__read_text_file', 'mcp__git__status'],
|
|
256
256
|
});
|
|
257
257
|
```
|
|
258
258
|
|
package/docs/ai-sdk-v5/GUIDE.md
CHANGED
|
@@ -148,6 +148,15 @@ const response = await generateText({
|
|
|
148
148
|
|
|
149
149
|
`resume` continues a previous CLI session instead of starting a new one.
|
|
150
150
|
|
|
151
|
+
You can also pass a deterministic `sessionId` for correlation and tracking:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const result = await generateText({
|
|
155
|
+
model: claudeCode('sonnet', { sessionId: 'my-custom-session-id' }),
|
|
156
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: 'Hello' }] }],
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
151
160
|
---
|
|
152
161
|
|
|
153
162
|
## Key Changes in v5
|
|
@@ -247,8 +256,11 @@ const result = await generateText({
|
|
|
247
256
|
| `mcpServers` | `object` | `undefined` | MCP server configuration |
|
|
248
257
|
| `env` | `Record<string, string>` | `undefined` | Environment variables passed to CLI |
|
|
249
258
|
| `resume` | `string` | `undefined` | Resume an existing session |
|
|
259
|
+
| `sessionId` | `string` | `undefined` | Use a specific session ID for tracking and correlation |
|
|
250
260
|
| `hooks` | `object` | `undefined` | Lifecycle hooks (e.g., PreToolUse, PostToolUse) |
|
|
251
261
|
| `canUseTool` | `(name, input, opts) => Promise` | `undefined` | Runtime permission callback. Requires streaming input at SDK level |
|
|
262
|
+
| `debug` | `boolean` | `undefined` | Enable SDK-level debug logging |
|
|
263
|
+
| `debugFile` | `string` | `undefined` | Path to a file for SDK debug log output |
|
|
252
264
|
|
|
253
265
|
### Custom Configuration
|
|
254
266
|
|
|
@@ -424,6 +436,17 @@ try {
|
|
|
424
436
|
}
|
|
425
437
|
```
|
|
426
438
|
|
|
439
|
+
#### SDK Debug Logging
|
|
440
|
+
|
|
441
|
+
Separate from the provider-level verbose/logger system, you can enable the underlying Agent SDK's own debug logging. This captures lower-level SDK internals and can be written to a file:
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
const model = claudeCode('sonnet', {
|
|
445
|
+
debug: true, // Enable SDK debug output
|
|
446
|
+
debugFile: '/tmp/sdk.log', // Write SDK debug logs to file
|
|
447
|
+
});
|
|
448
|
+
```
|
|
449
|
+
|
|
427
450
|
### Tool Management
|
|
428
451
|
|
|
429
452
|
Control which tools Claude Code can use with either `allowedTools` (allowlist) or `disallowedTools` (denylist). These flags work for **both built-in Claude tools and MCP tools**, providing session-only permission overrides.
|
|
@@ -450,7 +473,7 @@ const gitOnlyClaude = createClaudeCode({
|
|
|
450
473
|
|
|
451
474
|
// Mix built-in and MCP tools
|
|
452
475
|
const mixedClaude = createClaudeCode({
|
|
453
|
-
allowedTools: ['Read', 'Bash(npm test:*)', '
|
|
476
|
+
allowedTools: ['Read', 'Bash(npm test:*)', 'mcp__filesystem__read_text_file', 'mcp__git__status'],
|
|
454
477
|
});
|
|
455
478
|
```
|
|
456
479
|
|
|
@@ -579,6 +602,38 @@ Notes:
|
|
|
579
602
|
- Tool naming for allow/deny: `mcp__<serverName>__<toolName>`; to allow an entire server: `mcp__<serverName>`.
|
|
580
603
|
- Security: only allow the tools you intend; prefer allowlists in sensitive environments.
|
|
581
604
|
|
|
605
|
+
#### Tool Annotations
|
|
606
|
+
|
|
607
|
+
You can add MCP tool annotations to hint tool behavior. The `createCustomMcpServer` convenience helper accepts an optional `annotations` field per tool:
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
import { z } from 'zod';
|
|
611
|
+
import { createClaudeCode, createCustomMcpServer } from 'ai-sdk-provider-claude-code';
|
|
612
|
+
|
|
613
|
+
const server = createCustomMcpServer({
|
|
614
|
+
name: 'my-tools',
|
|
615
|
+
tools: {
|
|
616
|
+
lookup: {
|
|
617
|
+
description: 'Look up a value by key',
|
|
618
|
+
inputSchema: z.object({ key: z.string() }),
|
|
619
|
+
handler: async ({ key }) => ({
|
|
620
|
+
content: [{ type: 'text', text: `value for ${key}` }],
|
|
621
|
+
}),
|
|
622
|
+
annotations: {
|
|
623
|
+
readOnlyHint: true,
|
|
624
|
+
idempotentHint: true,
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
const claude = createClaudeCode({
|
|
631
|
+
defaultSettings: { mcpServers: { 'my-tools': server } },
|
|
632
|
+
});
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Supported annotation hints: `readOnlyHint`, `destructiveHint`, `openWorldHint`, `idempotentHint`.
|
|
636
|
+
|
|
582
637
|
### Hooks and Runtime Permissions
|
|
583
638
|
|
|
584
639
|
You can intercept lifecycle events and apply custom runtime permissions:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-provider-claude-code",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "AI SDK v6 provider for Claude via Claude Agent SDK (use Pro/Max subscription)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-sdk",
|
|
@@ -61,19 +61,20 @@
|
|
|
61
61
|
"example:streaming": "npm run build && npx tsx examples/streaming.ts",
|
|
62
62
|
"example:conversation": "npm run build && npx tsx examples/conversation-history.ts",
|
|
63
63
|
"example:config": "npm run build && npx tsx examples/custom-config.ts",
|
|
64
|
-
"example:object
|
|
65
|
-
"example:object:nested": "npm run build && npx tsx examples/generate-object-nested.ts",
|
|
64
|
+
"example:object": "npm run build && npx tsx examples/generate-object.ts",
|
|
66
65
|
"example:object:constraints": "npm run build && npx tsx examples/generate-object-constraints.ts",
|
|
67
66
|
"example:tools": "npm run build && npx tsx examples/tool-management.ts",
|
|
67
|
+
"example:mcp:filesystem": "npm run build && npx tsx examples/mcp-filesystem.ts",
|
|
68
|
+
"example:mcp:exa": "npm run build && npx tsx examples/mcp-exa.ts",
|
|
68
69
|
"example:timeout": "npm run build && npx tsx examples/long-running-tasks.ts",
|
|
69
70
|
"example:zod4": "npm run build && npx tsx examples/zod4-compatibility-test.ts",
|
|
70
71
|
"example:structured-repro": "npx tsx examples/structured-output-repro.ts",
|
|
71
|
-
"example:all": "npm run build && npm run example:basic && npm run example:streaming && npm run example:conversation && npm run example:config && npm run example:object
|
|
72
|
+
"example:all": "npm run build && npm run example:basic && npm run example:streaming && npm run example:conversation && npm run example:config && npm run example:object && npm run example:object:constraints && npm run example:tools && npm run example:timeout"
|
|
72
73
|
},
|
|
73
74
|
"dependencies": {
|
|
74
75
|
"@ai-sdk/provider": "^3.0.0",
|
|
75
76
|
"@ai-sdk/provider-utils": "^4.0.1",
|
|
76
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
77
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.33"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
80
|
"@edge-runtime/vm": "5.0.0",
|