@ai-sdk/devtools 0.0.1-beta.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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # AI SDK DevTools
2
+
3
+ A local development tool for debugging and inspecting AI SDK applications. View LLM requests, responses, tool calls, and multi-step interactions in a web-based UI.
4
+
5
+ > **Note**: This package is experimental and intended for local development only. Do not use in production environments.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ai-sdk/devtools
11
+ # or
12
+ pnpm add @ai-sdk/devtools
13
+ ```
14
+
15
+ ## Requirements
16
+
17
+ - AI SDK v6 beta (`ai@^6.0.0-beta.0`)
18
+ - Node.js compatible runtime
19
+
20
+ ## Usage
21
+
22
+ ### 1. Add the middleware to your model
23
+
24
+ ```typescript
25
+ import { wrapLanguageModel } from 'ai';
26
+ import { devToolsMiddleware } from '@ai-sdk/devtools';
27
+
28
+ const model = wrapLanguageModel({
29
+ middleware: devToolsMiddleware,
30
+ model: yourModel,
31
+ });
32
+ ```
33
+
34
+ ### 2. Run the viewer
35
+
36
+ ```bash
37
+ npx @ai-sdk/devtools
38
+ ```
39
+
40
+ Open http://localhost:4983 to view your AI SDK interactions.
41
+
42
+ ## How it works
43
+
44
+ The middleware intercepts all `generateText` and `streamText` calls, capturing:
45
+
46
+ - Input parameters and prompts
47
+ - Output content and tool calls
48
+ - Token usage and timing
49
+ - Raw provider request/response data
50
+
51
+ Data is stored locally in a JSON file (`.devtools/generations.json`) and served through a web UI.
52
+
53
+ ### Data flow
54
+
55
+ ```
56
+ AI SDK call → devToolsMiddleware → JSON file → Hono API → React UI
57
+ ```
58
+
59
+ ### Key concepts
60
+
61
+ - **Run**: A complete multi-step AI interaction, grouped by initial prompt
62
+ - **Step**: A single LLM call within a run
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ pnpm install
68
+ pnpm dev # Start dev server at http://localhost:5173
69
+ ```
70
+
71
+ ## License
72
+
73
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { startViewer } from '../dist/viewer/server.js';
4
+
5
+ const port = process.env.AI_SDK_DEVTOOLS_PORT
6
+ ? parseInt(process.env.AI_SDK_DEVTOOLS_PORT)
7
+ : 4983;
8
+
9
+ startViewer(port);