@ai-sdk/devtools 1.0.0-canary.27 → 1.0.0-canary.29
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 +40 -9
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/src/integration.ts +2 -2
package/README.md
CHANGED
|
@@ -14,20 +14,46 @@ pnpm add @ai-sdk/devtools
|
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
|
-
- AI SDK
|
|
17
|
+
- AI SDK v7 canary (`ai@canary`)
|
|
18
18
|
- Node.js compatible runtime
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
|
-
### 1.
|
|
22
|
+
### 1. Register the telemetry integration
|
|
23
|
+
|
|
24
|
+
Register `DevToolsTelemetry` globally so it captures all AI SDK calls:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { registerTelemetry } from 'ai';
|
|
28
|
+
import { DevToolsTelemetry } from '@ai-sdk/devtools';
|
|
29
|
+
|
|
30
|
+
registerTelemetry(DevToolsTelemetry());
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Telemetry is enabled automatically once an integration is registered:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { generateText } from 'ai';
|
|
37
|
+
|
|
38
|
+
const result = await generateText({
|
|
39
|
+
model: yourModel,
|
|
40
|
+
prompt: 'What cities are in the United States?',
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You can also pass the integration to individual calls instead of registering it
|
|
45
|
+
globally:
|
|
23
46
|
|
|
24
47
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
48
|
+
import { streamText } from 'ai';
|
|
49
|
+
import { DevToolsTelemetry } from '@ai-sdk/devtools';
|
|
27
50
|
|
|
28
|
-
const
|
|
29
|
-
middleware: devToolsMiddleware(),
|
|
51
|
+
const result = streamText({
|
|
30
52
|
model: yourModel,
|
|
53
|
+
prompt: 'Hello!',
|
|
54
|
+
telemetry: {
|
|
55
|
+
integrations: [DevToolsTelemetry()],
|
|
56
|
+
},
|
|
31
57
|
});
|
|
32
58
|
```
|
|
33
59
|
|
|
@@ -39,21 +65,26 @@ npx @ai-sdk/devtools
|
|
|
39
65
|
|
|
40
66
|
Open http://localhost:4983 to view your AI SDK interactions.
|
|
41
67
|
|
|
68
|
+
If you are using a monorepo, start DevTools from the same workspace where your
|
|
69
|
+
AI SDK code runs.
|
|
70
|
+
|
|
42
71
|
## How it works
|
|
43
72
|
|
|
44
|
-
The
|
|
73
|
+
The `DevToolsTelemetry` integration hooks into the AI SDK telemetry lifecycle to
|
|
74
|
+
capture `generateText`, `streamText`, `generateObject`, and `streamObject` calls.
|
|
75
|
+
It captures:
|
|
45
76
|
|
|
46
77
|
- Input parameters and prompts
|
|
47
78
|
- Output content and tool calls
|
|
48
79
|
- Token usage and timing
|
|
49
|
-
- Raw provider
|
|
80
|
+
- Raw provider data
|
|
50
81
|
|
|
51
82
|
Data is stored locally in a JSON file (`.devtools/generations.json`) and served through a web UI.
|
|
52
83
|
|
|
53
84
|
### Data flow
|
|
54
85
|
|
|
55
86
|
```
|
|
56
|
-
AI SDK call
|
|
87
|
+
AI SDK call -> DevToolsTelemetry -> JSON file -> Hono API -> React UI
|
|
57
88
|
```
|
|
58
89
|
|
|
59
90
|
### Key concepts
|
package/dist/index.js
CHANGED
|
@@ -567,7 +567,7 @@ function DevToolsTelemetry() {
|
|
|
567
567
|
provider_options: stepStartEvent.providerOptions ? JSON.stringify(stepStartEvent.providerOptions) : null
|
|
568
568
|
});
|
|
569
569
|
},
|
|
570
|
-
|
|
570
|
+
onStepEnd: async (event) => {
|
|
571
571
|
const stepResult = event;
|
|
572
572
|
const state = callStates.get(stepResult.callId);
|
|
573
573
|
if (!state) return;
|
|
@@ -596,7 +596,7 @@ function DevToolsTelemetry() {
|
|
|
596
596
|
});
|
|
597
597
|
state.stepStates.delete(stepResult.stepNumber);
|
|
598
598
|
},
|
|
599
|
-
|
|
599
|
+
onObjectStepEnd: async (event) => {
|
|
600
600
|
const stepResult = event;
|
|
601
601
|
const state = callStates.get(stepResult.callId);
|
|
602
602
|
if (!state) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/devtools",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vite": "^6.4.2",
|
|
57
57
|
"vitest": "^4.1.6",
|
|
58
58
|
"zod": "3.25.76",
|
|
59
|
-
"ai": "7.0.0-canary.
|
|
59
|
+
"ai": "7.0.0-canary.167"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public",
|
package/src/integration.ts
CHANGED
|
@@ -309,7 +309,7 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
309
309
|
});
|
|
310
310
|
},
|
|
311
311
|
|
|
312
|
-
|
|
312
|
+
onStepEnd: async event => {
|
|
313
313
|
const stepResult = event as GenerateTextStepEndEvent<ToolSet>;
|
|
314
314
|
|
|
315
315
|
const state = callStates.get(stepResult.callId);
|
|
@@ -350,7 +350,7 @@ export function DevToolsTelemetry(): Telemetry {
|
|
|
350
350
|
state.stepStates.delete(stepResult.stepNumber);
|
|
351
351
|
},
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
onObjectStepEnd: async event => {
|
|
354
354
|
const stepResult = event as GenerateObjectStepEndEvent;
|
|
355
355
|
|
|
356
356
|
const state = callStates.get(stepResult.callId);
|