ai-sdk-provider-claude-code 3.5.2 → 4.0.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 +223 -120
- package/dist/index.d.ts +236 -51
- package/dist/index.js +951 -223
- package/dist/index.js.map +1 -1
- package/docs/sessions.md +4 -4
- package/package.json +12 -14
- package/dist/index.cjs +0 -4025
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1329
package/docs/sessions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Session Management
|
|
2
2
|
|
|
3
|
-
Every `generateText`/`streamText` call through this provider runs as a Claude Code **session**. By default the CLI persists each session as a JSONL transcript under `~/.claude/projects/` (honoring `CLAUDE_CONFIG_DIR`), and the session ID is surfaced
|
|
3
|
+
Every `generateText`/`streamText` call through this provider runs as a Claude Code **session**. By default the CLI persists each session as a JSONL transcript under `~/.claude/projects/` (honoring `CLAUDE_CONFIG_DIR`), and the session ID is surfaced on AI SDK v7's final step: `result.finalStep.providerMetadata['claude-code'].sessionId` for `generateText`, or `(await stream.finalStep).providerMetadata['claude-code'].sessionId` for `streamText`. Use that ID to resume, fork, inspect, retitle, tag, or delete the session later.
|
|
4
4
|
|
|
5
5
|
This guide ties together the session-related **settings** (passed to `claudeCode(modelId, settings)`) and the session **helper functions** (re-exported from the Claude Agent SDK).
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ const result = await generateText({
|
|
|
29
29
|
prompt: 'Remember this code word: papaya. Reply with OK.',
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
const sessionId = result.providerMetadata?.['claude-code']?.sessionId as string;
|
|
32
|
+
const sessionId = result.finalStep.providerMetadata?.['claude-code']?.sessionId as string;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Resuming a session
|
|
@@ -50,7 +50,7 @@ const branched = await generateText({
|
|
|
50
50
|
prompt: 'Explore an alternative approach from here.',
|
|
51
51
|
});
|
|
52
52
|
// branched runs under a NEW session ID; the original transcript is untouched.
|
|
53
|
-
const forkId = branched.providerMetadata?.['claude-code']?.sessionId as string;
|
|
53
|
+
const forkId = branched.finalStep.providerMetadata?.['claude-code']?.sessionId as string;
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
## Session helper functions
|
|
@@ -91,7 +91,7 @@ await deleteSession(fork.sessionId);
|
|
|
91
91
|
|
|
92
92
|
### Two ways to fork
|
|
93
93
|
|
|
94
|
-
- **`forkSession` setting** (`{ resume, forkSession: true }`) — fork **and run a query** in one step; the new ID arrives in `providerMetadata
|
|
94
|
+
- **`forkSession` setting** (`{ resume, forkSession: true }`) — fork **and run a query** in one step; the new ID arrives in `finalStep.providerMetadata` (or `await stream.finalStep` for streaming).
|
|
95
95
|
- **`forkSession()` helper** — fork the stored transcript **without** running a query (and optionally slice it with `upToMessageId`); resume it later with the `resume` setting.
|
|
96
96
|
|
|
97
97
|
## Disk storage vs custom `SessionStore`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-provider-claude-code",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "AI SDK
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "AI SDK v7 provider for Claude via Claude Agent SDK (use Pro/Max subscription)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-sdk",
|
|
7
7
|
"claude-agent-sdk",
|
|
@@ -22,15 +22,13 @@
|
|
|
22
22
|
"author": "Ben Vargas",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"sideEffects": false,
|
|
25
|
-
"main": "./dist/index.
|
|
26
|
-
"module": "./dist/index.js",
|
|
25
|
+
"main": "./dist/index.js",
|
|
27
26
|
"types": "./dist/index.d.ts",
|
|
28
27
|
"exports": {
|
|
29
28
|
"./package.json": "./package.json",
|
|
30
29
|
".": {
|
|
31
30
|
"types": "./dist/index.d.ts",
|
|
32
|
-
"
|
|
33
|
-
"require": "./dist/index.cjs"
|
|
31
|
+
"default": "./dist/index.js"
|
|
34
32
|
}
|
|
35
33
|
},
|
|
36
34
|
"files": [
|
|
@@ -79,18 +77,18 @@
|
|
|
79
77
|
"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"
|
|
80
78
|
},
|
|
81
79
|
"dependencies": {
|
|
82
|
-
"@ai-sdk/provider": "^
|
|
83
|
-
"@ai-sdk/provider-utils": "^
|
|
84
|
-
"@anthropic-ai/claude-agent-sdk": "
|
|
80
|
+
"@ai-sdk/provider": "^4.0.2",
|
|
81
|
+
"@ai-sdk/provider-utils": "^5.0.5",
|
|
82
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.205"
|
|
85
83
|
},
|
|
86
84
|
"devDependencies": {
|
|
87
85
|
"@edge-runtime/vm": "5.0.0",
|
|
88
86
|
"@eslint/js": "9.28.0",
|
|
89
|
-
"@types/node": "^
|
|
87
|
+
"@types/node": "^22.10.0",
|
|
90
88
|
"@typescript-eslint/eslint-plugin": "8.34.0",
|
|
91
89
|
"@typescript-eslint/parser": "8.34.0",
|
|
92
90
|
"@vitest/coverage-v8": "^3.2.4",
|
|
93
|
-
"ai": "^
|
|
91
|
+
"ai": "^7.0.16",
|
|
94
92
|
"eslint": "9.28.0",
|
|
95
93
|
"globals": "16.2.0",
|
|
96
94
|
"prettier": "^3.6.2",
|
|
@@ -100,13 +98,13 @@
|
|
|
100
98
|
"zod": "^4.1.12"
|
|
101
99
|
},
|
|
102
100
|
"peerDependencies": {
|
|
103
|
-
"zod": "^4.
|
|
101
|
+
"zod": "^4.1.8"
|
|
104
102
|
},
|
|
105
103
|
"engines": {
|
|
106
|
-
"node": ">=
|
|
104
|
+
"node": ">=22"
|
|
107
105
|
},
|
|
108
106
|
"publishConfig": {
|
|
109
107
|
"access": "public",
|
|
110
|
-
"tag": "
|
|
108
|
+
"tag": "latest"
|
|
111
109
|
}
|
|
112
110
|
}
|