ai-pro-sdk 2.0.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.
@@ -0,0 +1,10 @@
1
+ # AI SDK v5 Documentation (Historical)
2
+
3
+ > **Historical:** These documents cover legacy provider versions 1.x–2.x (AI SDK v5). Much of the guidance still applies to 3.x, but new features are documented in the [main README](../../README.md).
4
+
5
+ - [GUIDE.md](GUIDE.md) - Usage guide
6
+ - [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Common issues and solutions
7
+ - [TOOL_STREAMING_SUPPORT.md](TOOL_STREAMING_SUPPORT.md) - Tool streaming event semantics
8
+ - [V5_BREAKING_CHANGES.md](V5_BREAKING_CHANGES.md) - v0.x to v1.x migration guide
9
+ - [V5_MIGRATION_PLAN.md](V5_MIGRATION_PLAN.md), [V5_MIGRATION_SUMMARY.md](V5_MIGRATION_SUMMARY.md), [V5_MIGRATION_TASKS.md](V5_MIGRATION_TASKS.md) - Internal v5 migration records
10
+ - [DEVELOPMENT-STATUS.md](DEVELOPMENT-STATUS.md) - Development status
@@ -0,0 +1,55 @@
1
+ # Tool Streaming Support (AI SDK v5)
2
+
3
+ ## Overview
4
+
5
+ Claude Code now emits full tool streaming events when used through the AI SDK v5 provider. This aligns the provider with the AI SDK's `LanguageModelV2StreamPart` contract, enabling downstream UIs to surface tool calls, inputs, and results in real time.
6
+
7
+ ## Requirements
8
+
9
+ - **Streaming input enabled**: set `streamingInput: 'always'` or rely on `'auto'` by supplying `canUseTool`.
10
+ - **Provider-executed tools**: Claude Code's built-in tools run inside the CLI; for every `tool-call` and `tool-result` event the provider sets `providerExecuted: true` so the AI SDK will not attempt to re-run the tool client-side.
11
+ - **Claude Code CLI**: authenticate with `claude login` and ensure the CLI is on your PATH before running streaming examples or tests. Allow the built-in tools explicitly (for example `allowedTools: ['Bash', 'Read']`) or set a permissive permission mode such as `bypassPermissions`.
12
+
13
+ ## Stream Parts Emitted
14
+
15
+ | Event | Description |
16
+ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | `tool-input-start` | Sent once per tool use with Claude's tool name and a stable ID. |
18
+ | `tool-input-delta` | JSON-serialized argument chunks. The provider emits deltas only for incremental prefix updates (new content appended to previous input). Non-prefix updates (corrections, replacements, or duplicate transmissions) do not emit `tool-input-delta`; the final complete input is always captured in the `tool-call` event. |
19
+ | `tool-input-end` | Marks completion of the request payload going to the tool. |
20
+ | `tool-call` | Includes `toolCallId`, `toolName`, serialized `input`, and `providerExecuted: true`. Raw, non-serialized input is preserved in `providerMetadata['claude-code'].rawInput`. |
21
+ | `tool-error` | Emitted when tool execution fails, includes `toolCallId`, `toolName`, error message, and is distinct from `tool-result` with `isError: true`. |
22
+ | `tool-result` | Streams the CLI output (JSON parsed when possible) with `toolName`, `toolCallId`, `isError`, `providerExecuted: true`, and the original output under `providerMetadata['claude-code'].rawResult`. |
23
+
24
+ Text streaming (`text-start`/`text-delta`/`text-end`), response metadata, and finish parts continue to behave as before.
25
+
26
+ ## Usage Example
27
+
28
+ Run the new example to observe the events:
29
+
30
+ ```bash
31
+ npm run build
32
+ npx tsx examples/tool-streaming.ts
33
+ ```
34
+
35
+ The script approves tools via `canUseTool` and logs each event in order, demonstrating directory listing and file-read operations executed by the CLI.
36
+
37
+ ## Testing & Validation
38
+
39
+ - Vitest suite includes coverage that asserts tool stream parts surface for provider-executed tools (`src/claude-code-language-model.test.ts`).
40
+ - Integration and example scripts rely on the compiled `dist` build; run `npm run build && npm run test` before publishing.
41
+ - If stream parts stop appearing, re-run with `DEBUG=1` or enable a custom logger (`settings.logger`) to capture warnings from the underlying SDK.
42
+
43
+ ## Known Limitations
44
+
45
+ - Claude Code does not emit incremental tool argument chunks today; the provider emits a single `tool-input-delta` payload per tool call unless the SDK starts sending partial updates.
46
+ - Delta skipping: If Claude sends non-prefix input updates (e.g., corrections or replacements rather than appends), the provider will skip delta emission and include the final input in the `tool-call` event only.
47
+ - Remote image URLs remain unsupported; convert images to base64 data URLs and set `streamingInput` accordingly.
48
+
49
+ ## Performance Considerations
50
+
51
+ - Delta calculation: Performed only for tool inputs ≤ 10KB and for prefix-only updates. Larger or non-prefix updates skip deltas and are captured in the final `tool-call` payload.
52
+ - Size limits: Tool inputs exceeding 1MB throw an error. Inputs above 100KB log a warning due to potential performance impact.
53
+ - Memory management: Tool state is retained until stream completion to avoid duplicate `tool-call` emissions when multiple result or error chunks arrive.
54
+
55
+ Note: This provider extends `tool-error` events to include `providerExecuted: true` and `providerMetadata['claude-code']` for parity with tool-call/result. Downstream consumers can safely ignore these fields if not used.
@@ -0,0 +1,381 @@
1
+ # Troubleshooting Guide (AI SDK v5)
2
+
3
+ This guide documents common issues and solutions for the Claude Code AI SDK Provider with v5.
4
+
5
+ ## Common Issues
6
+
7
+ ### 1. Authentication Errors
8
+
9
+ **Problem**: Getting authentication errors when trying to use the provider.
10
+
11
+ **Solution**:
12
+
13
+ ```bash
14
+ # Install Claude Code SDK globally
15
+ npm install -g @anthropic-ai/claude-code
16
+
17
+ # Authenticate with your Claude account
18
+ claude login
19
+ ```
20
+
21
+ **Verification**:
22
+
23
+ ```bash
24
+ # Check if authenticated
25
+ npx tsx ../examples/check-cli.ts
26
+ ```
27
+
28
+ ### 2. SDK Not Found
29
+
30
+ **Problem**: Error about `@anthropic-ai/claude-agent-sdk` module not found.
31
+
32
+ **Solution**: The SDK is a dependency of this provider and should be installed automatically. If not:
33
+
34
+ ```bash
35
+ npm install @anthropic-ai/claude-agent-sdk
36
+ ```
37
+
38
+ ### 3. v5 Message Format Errors
39
+
40
+ **Problem**: Error about invalid message content format.
41
+
42
+ **Solution**: In v5, user messages must have content as an array of parts:
43
+
44
+ ```typescript
45
+ // ❌ Wrong (v4 format)
46
+ { role: 'user', content: 'Hello' }
47
+
48
+ // ✅ Correct (v5 format)
49
+ { role: 'user', content: [{ type: 'text', text: 'Hello' }] }
50
+ ```
51
+
52
+ ### 4. Streaming API Changes
53
+
54
+ **Problem**: Streaming code from v4 doesn't work.
55
+
56
+ **Solution**: v5 uses a new streaming pattern with promises:
57
+
58
+ ```typescript
59
+ // ❌ Old v4 pattern
60
+ const { textStream } = await streamText({
61
+ model: claudeCode('sonnet'),
62
+ prompt: 'Hello',
63
+ });
64
+
65
+ // ✅ New v5 pattern
66
+ const result = streamText({
67
+ model: claudeCode('sonnet'),
68
+ prompt: 'Hello',
69
+ });
70
+
71
+ // Access parts as promises
72
+ const text = await result.text;
73
+ const usage = await result.usage;
74
+
75
+ // Or stream chunks
76
+ for await (const chunk of result.textStream) {
77
+ process.stdout.write(chunk);
78
+ }
79
+ ```
80
+
81
+ ### 5. Token Usage Property Names
82
+
83
+ **Problem**: Getting undefined for `promptTokens` or `completionTokens`.
84
+
85
+ **Solution**: Token properties have been renamed in v5:
86
+
87
+ ```typescript
88
+ // ❌ Old v4 names
89
+ console.log(usage.promptTokens);
90
+ console.log(usage.completionTokens);
91
+
92
+ // ✅ New v5 names
93
+ console.log(usage.inputTokens);
94
+ console.log(usage.outputTokens);
95
+ console.log(usage.totalTokens); // New in v5
96
+ ```
97
+
98
+ ### 6. Handling Long-Running Tasks
99
+
100
+ **Problem**: Complex queries with Claude Opus 4 may take longer due to extended thinking mode.
101
+
102
+ **Solution**: Use AbortSignal with custom timeouts:
103
+
104
+ ```typescript
105
+ import { generateText } from 'ai';
106
+ import { claudeCode } from 'ai-sdk-provider-claude-code';
107
+
108
+ // Create a custom timeout (5 minutes for complex tasks)
109
+ const controller = new AbortController();
110
+ const timeoutId = setTimeout(() => {
111
+ controller.abort(new Error('Request timeout'));
112
+ }, 300000);
113
+
114
+ try {
115
+ const result = await generateText({
116
+ model: claudeCode('opus'),
117
+ prompt: 'Complex reasoning task...',
118
+ abortSignal: controller.signal,
119
+ });
120
+ clearTimeout(timeoutId);
121
+ console.log(result.text);
122
+ } catch (error) {
123
+ if (error.name === 'AbortError') {
124
+ console.log('Request timed out');
125
+ }
126
+ }
127
+ ```
128
+
129
+ **Guidelines**:
130
+
131
+ - Simple queries: Default timeout is sufficient
132
+ - Complex reasoning: 5-10 minutes may be needed
133
+ - Very long tasks: Consider breaking into smaller chunks
134
+
135
+ ### 7. Object Generation Issues
136
+
137
+ **Problem**: Claude returns text instead of valid JSON when using `generateObject`.
138
+
139
+ **Solutions**:
140
+
141
+ 1. **Simplify your schema** - Start with fewer fields
142
+ 2. **Clear prompts** - Be explicit: "Generate a user profile with name and age"
143
+ 3. **Use descriptions** - Add `.describe()` to schema fields
144
+ 4. **Retry logic** - Implement retries for production:
145
+
146
+ ```typescript
147
+ async function generateWithRetry(schema, prompt, maxRetries = 3) {
148
+ for (let i = 0; i < maxRetries; i++) {
149
+ try {
150
+ return await generateObject({
151
+ model: claudeCode('sonnet'),
152
+ schema,
153
+ prompt,
154
+ });
155
+ } catch (error) {
156
+ if (i === maxRetries - 1) throw error;
157
+ await new Promise((r) => setTimeout(r, 1000 * Math.pow(2, i)));
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ ### 8. Session Management
164
+
165
+ **Problem**: Conversations don't maintain context.
166
+
167
+ **Solution**: Use message history with v5 format:
168
+
169
+ ```typescript
170
+ import { ModelMessage } from 'ai';
171
+
172
+ const messages: ModelMessage[] = [
173
+ { role: 'user', content: [{ type: 'text', text: 'My name is Alice' }] },
174
+ { role: 'assistant', content: [{ type: 'text', text: 'Nice to meet you, Alice!' }] },
175
+ { role: 'user', content: [{ type: 'text', text: 'What is my name?' }] },
176
+ ];
177
+
178
+ const result = await generateText({
179
+ model: claudeCode('sonnet'),
180
+ messages, // Pass full conversation history
181
+ });
182
+ ```
183
+
184
+ **Note**: While the provider returns session IDs in metadata, the recommended approach is to use message history for conversation continuity.
185
+
186
+ ### 9. Error Handling
187
+
188
+ **Problem**: Need to handle different types of errors appropriately.
189
+
190
+ **Solution**: Use the provider's error utilities:
191
+
192
+ ```typescript
193
+ import { isAuthenticationError, getErrorMetadata } from 'ai-sdk-provider-claude-code';
194
+
195
+ try {
196
+ const result = await generateText({
197
+ model: claudeCode('sonnet'),
198
+ prompt: 'Hello',
199
+ });
200
+ } catch (error) {
201
+ if (isAuthenticationError(error)) {
202
+ console.error('Please run: claude login');
203
+ } else if (error.name === 'AbortError') {
204
+ console.error('Request was cancelled or timed out');
205
+ } else {
206
+ // Get additional error details
207
+ const metadata = getErrorMetadata(error);
208
+ console.error('Error details:', metadata);
209
+ }
210
+ }
211
+ ```
212
+
213
+ ## v5-Specific Migration Issues
214
+
215
+ ### 1. Result Structure Changes
216
+
217
+ **Problem**: Code expecting v4 result structure fails.
218
+
219
+ **Solution**: Update to v5 result structure:
220
+
221
+ ```typescript
222
+ // ❌ v4 pattern
223
+ const { text, usage } = await generateText(...);
224
+
225
+ // ✅ v5 pattern
226
+ const result = await generateText(...);
227
+ console.log(result.text);
228
+ console.log(result.usage);
229
+ ```
230
+
231
+ ### 2. Stream Event Changes
232
+
233
+ **Problem**: Stream events have different names.
234
+
235
+ **Solution**: v5 includes a `stream-start` event:
236
+
237
+ ```typescript
238
+ const result = streamText({
239
+ model: claudeCode('sonnet'),
240
+ prompt: 'Hello',
241
+ });
242
+
243
+ // v5 stream includes: stream-start, text-delta, finish
244
+ for await (const chunk of result.fullStream) {
245
+ switch (chunk.type) {
246
+ case 'stream-start':
247
+ console.log('Stream started');
248
+ break;
249
+ case 'text-delta':
250
+ process.stdout.write(chunk.textDelta);
251
+ break;
252
+ case 'finish':
253
+ console.log('Stream finished');
254
+ break;
255
+ }
256
+ }
257
+ ```
258
+
259
+ ### 3. Unsupported Settings
260
+
261
+ **Problem**: Getting warnings about unsupported settings.
262
+
263
+ **Solution**: Some v4 settings are renamed or removed in v5:
264
+
265
+ ```typescript
266
+ // ❌ v4 setting names
267
+ {
268
+ maxTokens: 1000;
269
+ }
270
+
271
+ // ✅ v5 setting names
272
+ {
273
+ maxOutputTokens: 1000;
274
+ }
275
+
276
+ // Note: Many settings like temperature, topP, etc. are still not supported by Claude Code SDK
277
+ ```
278
+
279
+ ## Debugging Tips
280
+
281
+ ### 1. Verify Setup
282
+
283
+ ```bash
284
+ # Check Claude CLI version
285
+ claude --version
286
+
287
+ # Test authentication
288
+ npx tsx ../examples/check-cli.ts
289
+
290
+ # Run integration tests
291
+ npx tsx ../examples/integration-test.ts
292
+ ```
293
+
294
+ ### 2. Enable Debug Logging
295
+
296
+ ```typescript
297
+ // Log provider metadata to debug issues
298
+ const result = await generateText({
299
+ model: claudeCode('sonnet'),
300
+ prompt: 'Test',
301
+ });
302
+
303
+ console.log('Metadata:', result.providerMetadata);
304
+ // Shows: sessionId, costUsd, durationMs, rawUsage
305
+ ```
306
+
307
+ ### 3. Test Specific Features
308
+
309
+ ```bash
310
+ # Test streaming
311
+ npx tsx ../examples/streaming.ts
312
+
313
+ # Test object generation
314
+ npx tsx ../examples/generate-object-basic.ts
315
+
316
+ # Test conversations
317
+ npx tsx ../examples/conversation-history.ts
318
+
319
+ # Test long-running tasks
320
+ npx tsx ../examples/long-running-tasks.ts
321
+ ```
322
+
323
+ ## Platform-Specific Issues
324
+
325
+ ### Windows
326
+
327
+ - Ensure Claude CLI is in your PATH
328
+ - Use PowerShell or Command Prompt (not WSL) for installation
329
+
330
+ ### macOS
331
+
332
+ - May need to allow CLI in Security & Privacy settings
333
+ - Use Homebrew or direct npm installation
334
+
335
+ ### Linux
336
+
337
+ - Ensure Node.js ≥ 18 is installed
338
+ - May need to use `sudo` for global npm installs
339
+
340
+ ## Performance Tips
341
+
342
+ 1. **Model Selection**
343
+ - Use `haiku` for fastest, most cost-effective responses
344
+ - Use `sonnet` for balanced performance
345
+ - Use `opus` for complex reasoning tasks
346
+
347
+ 2. **Request Optimization**
348
+ - Keep prompts concise and clear
349
+ - Use streaming for better UX
350
+ - Implement proper error handling
351
+
352
+ 3. **Resource Management**
353
+ - The provider manages concurrent requests automatically
354
+ - Use AbortSignal for cancellable requests
355
+ - Clean up timeouts in finally blocks
356
+
357
+ ## Known Limitations
358
+
359
+ 1. **Image Support Requires Streaming Mode**: Image inputs are supported via streaming mode with base64/data URLs. See `examples/images.ts`. Remote HTTP(S) URLs are not supported.
360
+ 2. **No AI SDK Tool Calling**: The AI SDK's function calling interface isn't implemented, but Claude can use tools via MCP servers and built-in CLI tools
361
+ 3. **Object Generation**: Relies on prompt engineering rather than native JSON mode
362
+ 4. **Model Options**: Limited to 'opus', 'sonnet', and 'haiku' models
363
+
364
+ ## Getting Help
365
+
366
+ 1. **Check Examples**: Review the `../../examples` directory for working code
367
+ 2. **Integration Test**: Run `npx tsx ../../examples/integration-test.ts` to verify setup
368
+ 3. **GitHub Issues**: Report bugs at https://github.com/ben-vargas/ai-sdk-provider-claude-code/issues
369
+ 4. **Documentation**: See the README.md and GUIDE.md for detailed API documentation
370
+
371
+ ## Common Error Messages
372
+
373
+ | Error | Cause | Solution |
374
+ | ---------------------------------- | --------------------- | ---------------------------------------------- |
375
+ | "Claude Code executable not found" | CLI not installed | Run `npm install -g @anthropic-ai/claude-code` |
376
+ | "Authentication required" | Not logged in | Run `claude login` |
377
+ | "No object generated" | Invalid JSON response | Simplify schema, improve prompt |
378
+ | "Request timeout" | Task took too long | Increase timeout with AbortSignal |
379
+ | "Session not found" | Invalid session ID | Use message history instead |
380
+ | "Invalid message content" | v4 message format | Update to v5 array format |
381
+ | "promptTokens is undefined" | v4 property names | Use inputTokens/outputTokens |
@@ -0,0 +1,158 @@
1
+ # Breaking Changes: V4 to V5 Migration
2
+
3
+ This document outlines the breaking changes users will encounter when upgrading from v4 to v5 of the ai-sdk-provider-claude-code.
4
+
5
+ ⚠️ **IMPORTANT**: This is a complete breaking change. The v5 version of this provider ONLY works with AI SDK v5. You cannot use:
6
+
7
+ - v5 provider with AI SDK v4 ❌
8
+ - v4 provider with AI SDK v5 ❌
9
+
10
+ You must upgrade both together.
11
+
12
+ ## Installation
13
+
14
+ Update your dependencies to use the beta versions:
15
+
16
+ ```json
17
+ {
18
+ "dependencies": {
19
+ "ai": "beta",
20
+ "ai-sdk-provider-claude-code": "latest"
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## API Changes
26
+
27
+ ### 1. Token Usage Properties
28
+
29
+ The token usage properties have been renamed:
30
+
31
+ ```typescript
32
+ // V4
33
+ const { usage } = await generateText(...);
34
+ console.log(usage.promptTokens); // ❌ Old
35
+ console.log(usage.completionTokens); // ❌ Old
36
+
37
+ // V5
38
+ const { usage } = await generateText(...);
39
+ console.log(usage.inputTokens); // ✅ New
40
+ console.log(usage.outputTokens); // ✅ New
41
+ console.log(usage.totalTokens); // ✅ New
42
+ ```
43
+
44
+ ### 2. Streaming Response Pattern
45
+
46
+ The streamText function now returns a result object with promises:
47
+
48
+ ```typescript
49
+ // V4
50
+ const { text, usage } = await streamText({
51
+ model: claudeCode('opus'),
52
+ prompt: 'Hello',
53
+ });
54
+
55
+ // V5
56
+ const result = streamText({
57
+ model: claudeCode('opus'),
58
+ prompt: 'Hello',
59
+ });
60
+ const text = await result.text;
61
+ const usage = await result.usage;
62
+ ```
63
+
64
+ ### 3. Message Types
65
+
66
+ In v5, messages sent to the model should use `ModelMessage` type:
67
+
68
+ ```typescript
69
+ // V4
70
+ import type { Message } from 'ai';
71
+ const messages: Message[] = [];
72
+
73
+ // V5
74
+ import type { ModelMessage } from 'ai';
75
+ const messages: ModelMessage[] = [];
76
+ ```
77
+
78
+ **Note**: `UIMessage` is for UI state management, while `ModelMessage` is for sending to language models.
79
+
80
+ ### 4. Parameter Names
81
+
82
+ Some parameter names have changed:
83
+
84
+ ```typescript
85
+ // V4
86
+ generateText({
87
+ model: claudeCode('opus'),
88
+ prompt: 'Hello',
89
+ maxTokens: 100, // ❌ Old
90
+ });
91
+
92
+ // V5
93
+ generateText({
94
+ model: claudeCode('opus'),
95
+ prompt: 'Hello',
96
+ maxOutputTokens: 100, // ✅ New
97
+ });
98
+ ```
99
+
100
+ ### 5. Stream Events
101
+
102
+ V5 streams now emit additional events:
103
+
104
+ ```typescript
105
+ // V5 stream includes these events:
106
+ // - stream-start (with warnings)
107
+ // - response-metadata
108
+ // - text-delta (with 'delta' property, not 'textDelta')
109
+ // - finish
110
+ ```
111
+
112
+ ## Code Examples
113
+
114
+ ### Basic Text Generation
115
+
116
+ ```typescript
117
+ // V5 Pattern
118
+ import { streamText } from 'ai';
119
+ import { claudeCode } from 'ai-sdk-provider-claude-code';
120
+
121
+ const result = streamText({
122
+ model: claudeCode('opus'),
123
+ prompt: 'Write a haiku',
124
+ });
125
+
126
+ // Await the results
127
+ const text = await result.text;
128
+ const usage = await result.usage;
129
+ const metadata = await result.providerMetadata;
130
+ ```
131
+
132
+ ### Conversation with History
133
+
134
+ ```typescript
135
+ // V5 Pattern
136
+ import { streamText } from 'ai';
137
+ import { claudeCode } from 'ai-sdk-provider-claude-code';
138
+ import type { CoreMessage } from 'ai';
139
+
140
+ const messages: CoreMessage[] = [
141
+ { role: 'user', content: 'Hello!' },
142
+ { role: 'assistant', content: 'Hi there!' },
143
+ { role: 'user', content: 'How are you?' },
144
+ ];
145
+
146
+ const result = streamText({
147
+ model: claudeCode('opus'),
148
+ messages,
149
+ });
150
+
151
+ const response = await result.text;
152
+ ```
153
+
154
+ ## Notes
155
+
156
+ - All Claude Code SDK-specific limitations still apply (no temperature control, no output length limits, etc.)
157
+ - TypeScript users will get compile-time errors for most breaking changes
158
+ - This is a complete rewrite for v5 compatibility - no v4 compatibility is maintained
@@ -0,0 +1,22 @@
1
+ # V5-Beta Migration Plan
2
+
3
+ The goal of this migration is to update the `ai-sdk-provider-claude-code` to be compatible with the Vercel AI SDK v5-beta. This document outlines the plan that was followed to achieve this.
4
+
5
+ ## Key Areas of Change
6
+
7
+ The migration focused on the following key areas:
8
+
9
+ 1. **Dependency Upgrades:** The first step was to update all relevant `@ai-sdk` and `ai` packages to their `@beta` versions. This brought in the new `LanguageModelV2` architecture and other breaking changes.
10
+
11
+ 2. **`LanguageModelV2` Adoption:** The core of the migration was to rewrite the `ClaudeCodeLanguageModel` to conform to the new `LanguageModelV2` interface. This involved the following:
12
+ - Changing the `doStream` and `doGenerate` methods to handle the new `UIMessage` and `ModelMessage` formats.
13
+ - Adopting the "content-first" design, where all outputs are treated as ordered content parts.
14
+ - Ensuring type safety with the new `LanguageModelV2` types.
15
+
16
+ 3. **Message Overhaul:** The provider was updated to handle the new `UIMessage` and `ModelMessage` types. This meant that the `convertToClaudeCodeMessages` function was updated to accept `ModelMessage`s and convert them to the format that the Claude API expects.
17
+
18
+ 4. **Server-Sent Events (SSE):** The provider was updated to work with the new SSE-based streaming protocol. This required changes to how the streaming responses are handled and formatted.
19
+
20
+ 5. **Tool Handling:** The provider was updated to handle the new type-safe tool calls. This involved changes to how tools are defined and how tool calls are processed.
21
+
22
+ 6. **Examples and Tests:** All examples and tests were updated to use the new v5-beta APIs. This was a good way to validate the migration and ensure that everything was working as expected.