@raindrop-ai/ai-sdk 0.0.31 → 0.0.33
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 +81 -3
- package/dist/{chunk-7VSCLQIX.mjs → chunk-FIX66Y7M.mjs} +382 -199
- package/dist/{index-IMe7ZUXV.d.mts → index-Dcf4FPZL.d.mts} +127 -3
- package/dist/{index-IMe7ZUXV.d.ts → index-Dcf4FPZL.d.ts} +127 -3
- package/dist/index.browser.d.mts +127 -3
- package/dist/index.browser.d.ts +127 -3
- package/dist/index.browser.js +395 -211
- package/dist/index.browser.mjs +395 -212
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +395 -211
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.d.mts +1 -1
- package/dist/index.workers.d.ts +1 -1
- package/dist/index.workers.js +395 -211
- package/dist/index.workers.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -115,9 +115,50 @@ raindrop.traces.endSpan(agentTurn);
|
|
|
115
115
|
await raindrop.flush();
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
### AI SDK v7
|
|
118
|
+
### AI SDK v7 quick start: `registerTelemetry(raindrop())`
|
|
119
119
|
|
|
120
|
-
On AI SDK v7
|
|
120
|
+
On AI SDK v7, the simplest setup is the `raindrop()` factory, which returns a
|
|
121
|
+
ready-to-register telemetry integration. The `writeKey` defaults to the
|
|
122
|
+
`RAINDROP_WRITE_KEY` environment variable.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { generateText, registerTelemetry } from "ai";
|
|
126
|
+
import { OpenTelemetry } from "@ai-sdk/otel";
|
|
127
|
+
import { raindrop } from "@raindrop-ai/ai-sdk";
|
|
128
|
+
|
|
129
|
+
registerTelemetry(new OpenTelemetry(), raindrop());
|
|
130
|
+
|
|
131
|
+
const result = await generateText({
|
|
132
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
133
|
+
prompt: "what is the weather in Tokyo?",
|
|
134
|
+
telemetry: { functionId: "weather-agent" }, // no `isEnabled` needed in v7
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`raindrop()` is self-contained — `@ai-sdk/otel` is optional; you can register
|
|
139
|
+
Raindrop on its own with `registerTelemetry(raindrop())`. Pass `context` and
|
|
140
|
+
`subagentWrapping` to customise behaviour, e.g. `raindrop({ context: { userId: "user_123" } })`.
|
|
141
|
+
|
|
142
|
+
For short-lived scripts that exit before the background flush timer fires, keep
|
|
143
|
+
the reference and drain it before exiting:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const rd = raindrop();
|
|
147
|
+
registerTelemetry(rd);
|
|
148
|
+
// ... run your generations ...
|
|
149
|
+
await rd.flush(); // or rd.shutdown()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Sub-agents (a `generateText`/`streamText` invoked from inside a tool's
|
|
153
|
+
`execute`) nest automatically: the inner generation's spans are parented under
|
|
154
|
+
the tool span so parent and child spans stay correctly nested.
|
|
155
|
+
|
|
156
|
+
### AI SDK v7+ native telemetry (advanced)
|
|
157
|
+
|
|
158
|
+
For finer control you can build the integration from a `createRaindropAISDK`
|
|
159
|
+
client instead. The native `Telemetry` callback interface (formerly
|
|
160
|
+
`TelemetryIntegration` before beta.111) avoids Proxy overhead and works with all
|
|
161
|
+
AI SDK entry points (including `ToolLoopAgent`).
|
|
121
162
|
|
|
122
163
|
```ts
|
|
123
164
|
// Option A: wrap() with nativeTelemetry flag
|
|
@@ -136,6 +177,43 @@ registerTelemetry(
|
|
|
136
177
|
);
|
|
137
178
|
```
|
|
138
179
|
|
|
180
|
+
### Standalone self-diagnostics tool
|
|
181
|
+
|
|
182
|
+
When registering the native telemetry integration directly, create the
|
|
183
|
+
self-diagnostics tool from the same Raindrop client:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { createRaindropAISDK } from "@raindrop-ai/ai-sdk";
|
|
187
|
+
import { generateText, registerTelemetry } from "ai";
|
|
188
|
+
|
|
189
|
+
const raindrop = createRaindropAISDK({
|
|
190
|
+
writeKey: process.env.RAINDROP_WRITE_KEY!,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
registerTelemetry(raindrop.createTelemetryIntegration({ userId: "user_123" }));
|
|
194
|
+
|
|
195
|
+
const diagnostics = raindrop.createSelfDiagnosticsTool();
|
|
196
|
+
|
|
197
|
+
await generateText({
|
|
198
|
+
model,
|
|
199
|
+
prompt,
|
|
200
|
+
tools: {
|
|
201
|
+
[diagnostics.name]: diagnostics,
|
|
202
|
+
},
|
|
203
|
+
experimental_telemetry: { isEnabled: true },
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
With native telemetry and tracing enabled, the tool automatically attaches its
|
|
208
|
+
signal to the active Raindrop event. When there is no active trace context,
|
|
209
|
+
provide `eventId` or `getEventId`:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
const diagnostics = raindrop.createSelfDiagnosticsTool({
|
|
213
|
+
getEventId: () => currentEventId,
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
139
217
|
Setting `nativeTelemetry: true` on pre-v7 throws a clear error. The Proxy path remains the default and supports features not yet available on the native path (`buildEvent`, output attachment extraction).
|
|
140
218
|
|
|
141
219
|
#### Per-call routing on AI SDK v7 beta.94+
|
|
@@ -214,7 +292,7 @@ This package is tested against multiple Vercel AI SDK versions:
|
|
|
214
292
|
| v4.x | ✅ Supported | Proxy |
|
|
215
293
|
| v5.x | ✅ Supported | Proxy |
|
|
216
294
|
| v6.x | ✅ Supported | Proxy |
|
|
217
|
-
| v7.x (beta) | ✅ Supported | Proxy (default) or native `Telemetry` (opt-in, formerly `TelemetryIntegration` pre-beta.111). Verified against beta.116. |
|
|
295
|
+
| v7.x (beta/canary) | ✅ Supported | Proxy (default) or native `Telemetry` (opt-in, formerly `TelemetryIntegration` pre-beta.111). Verified against beta.116 and canary.171. |
|
|
218
296
|
|
|
219
297
|
### Version Differences Handled
|
|
220
298
|
|