ai 6.0.89 → 6.0.91
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/CHANGELOG.md +13 -0
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-getting-started/09-coding-agents.mdx +179 -0
- package/package.json +2 -2
- package/src/ui/chat.ts +28 -13
package/dist/internal/index.js
CHANGED
|
@@ -153,7 +153,7 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
|
153
153
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
154
154
|
|
|
155
155
|
// src/version.ts
|
|
156
|
-
var VERSION = true ? "6.0.
|
|
156
|
+
var VERSION = true ? "6.0.91" : "0.0.0-test";
|
|
157
157
|
|
|
158
158
|
// src/util/download/download.ts
|
|
159
159
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Coding Agents
|
|
3
|
+
description: Learn how to set up the AI SDK for use with coding agents, including installing skills, accessing bundled docs, and using DevTools.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Getting Started with Coding Agents
|
|
7
|
+
|
|
8
|
+
This page explains how to get the most out of the AI SDK when working inside a coding agent (such as Claude Code, Codex, OpenCode, Cursor, or any other AI-assisted development environment).
|
|
9
|
+
|
|
10
|
+
## Install the AI SDK Skill
|
|
11
|
+
|
|
12
|
+
The fastest way to give your coding agent deep knowledge of the AI SDK is to install the official AI SDK skill. Skills are lightweight markdown files that load specialized instructions into your agent's context on demand — so your agent knows exactly how to use the SDK without you needing to explain it.
|
|
13
|
+
|
|
14
|
+
Install the AI SDK skill using `npx skills add`:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx skills add vercel/ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This installs the skill into your agent's specific skills directory (e.g., `.claude/skills`, `.codex/skills`). If you select more than one agent, the CLI creates symlinks so each agent can discover the skill. Use `-a` to specify agents directly — for example, `-a amp` installs into the universal `.agents/skills` directory. Use `-y` for non-interactive installation.
|
|
21
|
+
|
|
22
|
+
Once installed, any agent that supports the [Agent Skills](https://agentskills.io) format will automatically discover and load the skill when working on AI SDK tasks.
|
|
23
|
+
|
|
24
|
+
<Note>
|
|
25
|
+
Agent Skills use **progressive disclosure**: your agent loads only the skill's
|
|
26
|
+
name and description at startup. The full instructions are only pulled into
|
|
27
|
+
context when the task calls for it, keeping your agent fast and focused.
|
|
28
|
+
</Note>
|
|
29
|
+
|
|
30
|
+
## Docs and Source Code in `node_modules`
|
|
31
|
+
|
|
32
|
+
Once you've installed the `ai` package, you already have the full AI SDK documentation and source code available locally inside `node_modules`. Your coding agent can read these directly — no internet access required.
|
|
33
|
+
|
|
34
|
+
Install the `ai` package if you haven't already:
|
|
35
|
+
|
|
36
|
+
<div className="my-4">
|
|
37
|
+
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
|
|
38
|
+
<Tab>
|
|
39
|
+
<Snippet text="pnpm add ai" dark />
|
|
40
|
+
</Tab>
|
|
41
|
+
<Tab>
|
|
42
|
+
<Snippet text="npm install ai" dark />
|
|
43
|
+
</Tab>
|
|
44
|
+
<Tab>
|
|
45
|
+
<Snippet text="yarn add ai" dark />
|
|
46
|
+
</Tab>
|
|
47
|
+
<Tab>
|
|
48
|
+
<Snippet text="bun add ai" dark />
|
|
49
|
+
</Tab>
|
|
50
|
+
</Tabs>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
After installation, your agent can reference the bundled source code and documentation at paths like:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
node_modules/ai/src/ # Full source code organized by module
|
|
57
|
+
node_modules/ai/docs/ # Official documentation with examples
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This means your agent can look up accurate API signatures, implementations, and usage examples directly from the installed package — ensuring it always uses the version of the SDK that's actually installed in your project.
|
|
61
|
+
|
|
62
|
+
## Install DevTools
|
|
63
|
+
|
|
64
|
+
AI SDK DevTools gives you full visibility into your AI SDK calls during development. It captures LLM requests, responses, tool calls, token usage, and multi-step interactions, and displays them in a local web UI.
|
|
65
|
+
|
|
66
|
+
<Note type="warning">
|
|
67
|
+
AI SDK DevTools is experimental and intended for local development only. Do
|
|
68
|
+
not use in production environments.
|
|
69
|
+
</Note>
|
|
70
|
+
|
|
71
|
+
Install the DevTools package:
|
|
72
|
+
|
|
73
|
+
<div className="my-4">
|
|
74
|
+
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
|
|
75
|
+
<Tab>
|
|
76
|
+
<Snippet text="pnpm add @ai-sdk/devtools" dark />
|
|
77
|
+
</Tab>
|
|
78
|
+
<Tab>
|
|
79
|
+
<Snippet text="npm install @ai-sdk/devtools" dark />
|
|
80
|
+
</Tab>
|
|
81
|
+
<Tab>
|
|
82
|
+
<Snippet text="yarn add @ai-sdk/devtools" dark />
|
|
83
|
+
</Tab>
|
|
84
|
+
<Tab>
|
|
85
|
+
<Snippet text="bun add @ai-sdk/devtools" dark />
|
|
86
|
+
</Tab>
|
|
87
|
+
</Tabs>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
### Add the middleware
|
|
91
|
+
|
|
92
|
+
Wrap your language model with the DevTools middleware using [`wrapLanguageModel`](/docs/ai-sdk-core/middleware):
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { wrapLanguageModel, gateway } from 'ai';
|
|
96
|
+
import { devToolsMiddleware } from '@ai-sdk/devtools';
|
|
97
|
+
|
|
98
|
+
const model = wrapLanguageModel({
|
|
99
|
+
model: gateway('anthropic/claude-sonnet-4.5'),
|
|
100
|
+
middleware: devToolsMiddleware(),
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Use the wrapped model with any AI SDK Core function:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { generateText } from 'ai';
|
|
108
|
+
|
|
109
|
+
const result = await generateText({
|
|
110
|
+
model, // wrapped model with DevTools middleware
|
|
111
|
+
prompt: 'What cities are in the United States?',
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Launch the viewer
|
|
116
|
+
|
|
117
|
+
Start the DevTools viewer in a separate terminal:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx @ai-sdk/devtools
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Open [http://localhost:4983](http://localhost:4983) to inspect your AI SDK interactions in real time.
|
|
124
|
+
|
|
125
|
+
## Inspecting Tool Calls and Outputs
|
|
126
|
+
|
|
127
|
+
DevTools captures and displays the following for every call:
|
|
128
|
+
|
|
129
|
+
- **Input parameters and prompts** — the complete input sent to your LLM
|
|
130
|
+
- **Output content and tool calls** — generated text and tool invocations
|
|
131
|
+
- **Token usage and timing** — resource consumption and latency per step
|
|
132
|
+
- **Raw provider data** — complete request and response payloads
|
|
133
|
+
|
|
134
|
+
For multi-step agent interactions, DevTools groups everything into **runs** (a complete interaction) and **steps** (each individual LLM call within it), making it easy to trace exactly what your agent did and why.
|
|
135
|
+
|
|
136
|
+
You can also log tool results directly in code during development:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { streamText, tool, stepCountIs } from 'ai';
|
|
140
|
+
import { z } from 'zod';
|
|
141
|
+
|
|
142
|
+
const result = streamText({
|
|
143
|
+
model,
|
|
144
|
+
prompt: "What's the weather in New York in celsius?",
|
|
145
|
+
tools: {
|
|
146
|
+
weather: tool({
|
|
147
|
+
description: 'Get the weather in a location (fahrenheit)',
|
|
148
|
+
inputSchema: z.object({
|
|
149
|
+
location: z.string().describe('The location to get the weather for'),
|
|
150
|
+
}),
|
|
151
|
+
execute: async ({ location }) => ({
|
|
152
|
+
location,
|
|
153
|
+
temperature: Math.round(Math.random() * (90 - 32) + 32),
|
|
154
|
+
}),
|
|
155
|
+
}),
|
|
156
|
+
},
|
|
157
|
+
stopWhen: stepCountIs(5),
|
|
158
|
+
onStepFinish: async ({ toolResults }) => {
|
|
159
|
+
if (toolResults.length) {
|
|
160
|
+
console.log(JSON.stringify(toolResults, null, 2));
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The `onStepFinish` callback fires after each LLM step and prints any tool results to your terminal — useful for quick debugging without opening the DevTools UI.
|
|
167
|
+
|
|
168
|
+
<Note>
|
|
169
|
+
DevTools stores all AI interactions in a local `.devtools/generations.json`
|
|
170
|
+
file. It automatically adds `.devtools` to your `.gitignore` to prevent
|
|
171
|
+
committing sensitive interaction data.
|
|
172
|
+
</Note>
|
|
173
|
+
|
|
174
|
+
## Where to Next?
|
|
175
|
+
|
|
176
|
+
- Learn about [Agent Skills](https://agentskills.io/specification) to understand the full skill format.
|
|
177
|
+
- Read the [DevTools reference](/docs/ai-sdk-core/devtools) for a complete list of captured data and configuration options.
|
|
178
|
+
- Explore [Tools and Tool Calling](/docs/ai-sdk-core/tools-and-tool-calling) to build agents that can take real-world actions.
|
|
179
|
+
- Check out the [Add Skills to Your Agent](/docs/guides/agent-skills) cookbook guide for a step-by-step integration walkthrough.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.91",
|
|
4
4
|
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentelemetry/api": "1.9.0",
|
|
48
|
-
"@ai-sdk/gateway": "3.0.
|
|
48
|
+
"@ai-sdk/gateway": "3.0.50",
|
|
49
49
|
"@ai-sdk/provider": "3.0.8",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.15"
|
|
51
51
|
},
|
package/src/ui/chat.ts
CHANGED
|
@@ -582,6 +582,33 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
582
582
|
trigger: 'submit-message' | 'resume-stream' | 'regenerate-message';
|
|
583
583
|
messageId?: string;
|
|
584
584
|
} & ChatRequestOptions) {
|
|
585
|
+
// For resume-stream, check if there's an active stream before
|
|
586
|
+
// changing status. This avoids a brief flash of 'submitted' status
|
|
587
|
+
// when there is no stream to resume (e.g. on page load).
|
|
588
|
+
let resumeStream: ReadableStream<UIMessageChunk> | undefined;
|
|
589
|
+
if (trigger === 'resume-stream') {
|
|
590
|
+
try {
|
|
591
|
+
const reconnect = await this.transport.reconnectToStream({
|
|
592
|
+
chatId: this.id,
|
|
593
|
+
metadata,
|
|
594
|
+
headers,
|
|
595
|
+
body,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
if (reconnect == null) {
|
|
599
|
+
return; // no active stream found, so we do not resume
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
resumeStream = reconnect;
|
|
603
|
+
} catch (err) {
|
|
604
|
+
if (this.onError && err instanceof Error) {
|
|
605
|
+
this.onError(err);
|
|
606
|
+
}
|
|
607
|
+
this.setStatus({ status: 'error', error: err as Error });
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
585
612
|
this.setStatus({ status: 'submitted', error: undefined });
|
|
586
613
|
|
|
587
614
|
const lastMessage = this.lastMessage;
|
|
@@ -608,19 +635,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
608
635
|
let stream: ReadableStream<UIMessageChunk>;
|
|
609
636
|
|
|
610
637
|
if (trigger === 'resume-stream') {
|
|
611
|
-
|
|
612
|
-
chatId: this.id,
|
|
613
|
-
metadata,
|
|
614
|
-
headers,
|
|
615
|
-
body,
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
if (reconnect == null) {
|
|
619
|
-
this.setStatus({ status: 'ready' });
|
|
620
|
-
return; // no active stream found, so we do not resume
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
stream = reconnect;
|
|
638
|
+
stream = resumeStream!;
|
|
624
639
|
} else {
|
|
625
640
|
stream = await this.transport.sendMessages({
|
|
626
641
|
chatId: this.id,
|