@raindrop-ai/ai-sdk 0.0.23 → 0.0.24

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raindrop AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -55,6 +55,66 @@ await raindrop.users.identify({
55
55
  await raindrop.flush();
56
56
  ```
57
57
 
58
+ ## Manual Traces
59
+
60
+ Create trace spans manually alongside, or instead of, auto-instrumented ones.
61
+
62
+ Use `createSpan` when the timing is already known:
63
+
64
+ ```ts
65
+ const eventId = "evt_123";
66
+
67
+ raindrop.traces.createSpan({
68
+ name: "SET theme=dark",
69
+ eventId,
70
+ operationId: "ai.toolCall",
71
+ input: "SET theme=dark",
72
+ output: "OK",
73
+ durationMs: 12,
74
+ });
75
+ ```
76
+
77
+ Use `startSpan` / `endSpan` when you want to time an operation in real time:
78
+
79
+ ```ts
80
+ const span = raindrop.traces.startSpan({
81
+ name: "database_query",
82
+ eventId: "evt_123",
83
+ operationId: "ai.toolCall",
84
+ });
85
+
86
+ try {
87
+ await db.query("SELECT ...");
88
+ raindrop.traces.endSpan(span);
89
+ } catch (err) {
90
+ raindrop.traces.endSpan(span, { error: err instanceof Error ? err : String(err) });
91
+ }
92
+ ```
93
+
94
+ Pass a span as `parent` to build nested trace trees:
95
+
96
+ ```ts
97
+ const eventId = "evt_456";
98
+
99
+ const agentTurn = raindrop.traces.startSpan({
100
+ name: "agent_turn",
101
+ eventId,
102
+ });
103
+
104
+ raindrop.traces.createSpan({
105
+ name: "grep_search",
106
+ eventId,
107
+ parent: agentTurn,
108
+ operationId: "ai.toolCall",
109
+ input: { pattern: "execute" },
110
+ output: { matches: 12 },
111
+ durationMs: 120,
112
+ });
113
+
114
+ raindrop.traces.endSpan(agentTurn);
115
+ await raindrop.flush();
116
+ ```
117
+
58
118
  ### AI SDK v7+ native telemetry (opt-in)
59
119
 
60
120
  On AI SDK v7+, you can use the native `TelemetryIntegration` callback interface instead of Proxy wrapping. This avoids Proxy overhead and works with all AI SDK entry points (including `ToolLoopAgent`).
@@ -192,135 +252,6 @@ v7 additionally runs:
192
252
  - **E2E native telemetry** - Real AI SDK v7 with MSW-intercepted payloads
193
253
  - **Subagent nesting** - Span hierarchy for nested generateText inside tool execution
194
254
 
195
- ## Manual Traces
196
-
197
- Create trace spans manually alongside (or instead of) auto-instrumented ones. Useful for custom operations, DSL command extraction, or building trace trees for custom agent loops.
198
-
199
- Spans share the same trace tree as auto-instrumented spans when you pass matching `eventId` values.
200
-
201
- All three methods are available on every entrypoint (`.`, `./workers`, `./browser`).
202
-
203
- ### One-shot spans
204
-
205
- Use `createSpan` when the operation is already complete and you know the duration:
206
-
207
- ```ts
208
- raindrop.traces.createSpan({
209
- name: "SET theme=dark",
210
- eventId: "evt_123",
211
- operationId: "ai.toolCall", // appears as a tool call in the dashboard
212
- input: "SET theme=dark",
213
- output: "OK",
214
- durationMs: 12,
215
- });
216
-
217
- // Failed span
218
- raindrop.traces.createSpan({
219
- name: "SET layout=invalid",
220
- eventId: "evt_123",
221
- operationId: "ai.toolCall",
222
- input: "SET layout=invalid",
223
- error: "Invalid layout value",
224
- durationMs: 8,
225
- });
226
- ```
227
-
228
- ### Lifecycle spans
229
-
230
- Use `startSpan` / `endSpan` to time an operation in real time:
231
-
232
- ```ts
233
- const span = raindrop.traces.startSpan({
234
- name: "database_query",
235
- eventId: "evt_123",
236
- operationId: "ai.toolCall",
237
- });
238
-
239
- try {
240
- const result = await db.query("SELECT ...");
241
- raindrop.traces.endSpan(span);
242
- } catch (err) {
243
- raindrop.traces.endSpan(span, { error: err });
244
- }
245
- ```
246
-
247
- ### Nested spans
248
-
249
- Pass a span as `parent` to build a trace tree:
250
-
251
- ```ts
252
- const eventId = "evt_456";
253
-
254
- const agentTurn = raindrop.traces.startSpan({ name: "agent_turn", eventId });
255
-
256
- const subagent = raindrop.traces.startSpan({
257
- name: "search_subagent",
258
- eventId,
259
- parent: agentTurn,
260
- });
261
-
262
- raindrop.traces.createSpan({
263
- name: "grep_search",
264
- eventId,
265
- parent: subagent,
266
- operationId: "ai.toolCall",
267
- input: { pattern: "execute" },
268
- output: { matches: 12 },
269
- durationMs: 120,
270
- });
271
-
272
- raindrop.traces.endSpan(subagent);
273
- raindrop.traces.endSpan(agentTurn);
274
-
275
- await raindrop.flush();
276
- ```
277
-
278
- ### Mixing with auto-instrumented spans
279
-
280
- Use the same `eventId` for both `wrap()` calls and manual spans — they appear in the same trace tree:
281
-
282
- ```ts
283
- const eventId = crypto.randomUUID();
284
- const { generateText } = raindrop.wrap(ai, {
285
- context: { userId: "user_123" },
286
- });
287
-
288
- await generateText({
289
- model: openai("gpt-4o"),
290
- prompt: "Analyze this data",
291
- experimental_telemetry: {
292
- isEnabled: true,
293
- metadata: eventMetadata({ eventId }),
294
- },
295
- });
296
-
297
- raindrop.traces.createSpan({
298
- name: "post_processing",
299
- eventId,
300
- input: "raw",
301
- output: "processed",
302
- durationMs: 50,
303
- });
304
-
305
- await raindrop.flush();
306
- ```
307
-
308
- ### API reference
309
-
310
- | Method | Description |
311
- |--------|-------------|
312
- | `raindrop.traces.createSpan(args)` | One-shot span with known duration |
313
- | `raindrop.traces.startSpan(args)` | Start a span, returns a `TraceSpan` handle |
314
- | `raindrop.traces.endSpan(span, extra?)` | Close a span opened with `startSpan` |
315
-
316
- **`createSpan` args:** `name`, `eventId`, `operationId?`, `parent?`, `input?`, `output?`, `durationMs`, `error?`
317
-
318
- **`startSpan` args:** `name`, `eventId`, `operationId?`, `parent?`
319
-
320
- **`endSpan` extra:** `error?` (`Error | string`)
321
-
322
- Set `operationId: "ai.toolCall"` to make spans appear as tool calls in the Raindrop dashboard.
323
-
324
255
  ## Notes
325
256
 
326
257
  - Spans include `ai.telemetry.metadata.raindrop.eventId` for correlation, and **omit** `ai.telemetry.metadata.raindrop.userId` to prevent duplicate span→event creation server-side.
@@ -4007,7 +4007,7 @@ function extractNestedTokens(usage, key) {
4007
4007
  // package.json
4008
4008
  var package_default = {
4009
4009
  name: "@raindrop-ai/ai-sdk",
4010
- version: "0.0.23"};
4010
+ version: "0.0.24"};
4011
4011
 
4012
4012
  // src/internal/version.ts
4013
4013
  var libraryName = package_default.name;
@@ -832,7 +832,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
832
832
  // package.json
833
833
  var package_default = {
834
834
  name: "@raindrop-ai/ai-sdk",
835
- version: "0.0.23"};
835
+ version: "0.0.24"};
836
836
 
837
837
  // src/internal/version.ts
838
838
  var libraryName = package_default.name;
@@ -830,7 +830,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
830
830
  // package.json
831
831
  var package_default = {
832
832
  name: "@raindrop-ai/ai-sdk",
833
- version: "0.0.23"};
833
+ version: "0.0.24"};
834
834
 
835
835
  // src/internal/version.ts
836
836
  var libraryName = package_default.name;
@@ -837,7 +837,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = async_hooks.AsyncLocalStorage;
837
837
  // package.json
838
838
  var package_default = {
839
839
  name: "@raindrop-ai/ai-sdk",
840
- version: "0.0.23"};
840
+ version: "0.0.24"};
841
841
 
842
842
  // src/internal/version.ts
843
843
  var libraryName = package_default.name;
@@ -1,4 +1,4 @@
1
- export { RaindropTelemetryIntegration, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent } from './chunk-VQZMQSBQ.mjs';
1
+ export { RaindropTelemetryIntegration, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent } from './chunk-WHP2SVAR.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
@@ -837,7 +837,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = async_hooks.AsyncLocalStorage;
837
837
  // package.json
838
838
  var package_default = {
839
839
  name: "@raindrop-ai/ai-sdk",
840
- version: "0.0.23"};
840
+ version: "0.0.24"};
841
841
 
842
842
  // src/internal/version.ts
843
843
  var libraryName = package_default.name;
@@ -1,4 +1,4 @@
1
- export { RaindropTelemetryIntegration, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent } from './chunk-VQZMQSBQ.mjs';
1
+ export { RaindropTelemetryIntegration, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent } from './chunk-WHP2SVAR.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  if (!globalThis.RAINDROP_ASYNC_LOCAL_STORAGE) {
package/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "@raindrop-ai/ai-sdk",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Standalone Vercel AI SDK integration for Raindrop (events + OTLP/HTTP JSON traces, no OTEL runtime)",
5
5
  "main": "dist/index.node.js",
6
6
  "module": "dist/index.node.mjs",
7
7
  "types": "dist/index.node.d.ts",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/raindrop-ai/raindrop-js.git",
12
+ "directory": "packages/ai-sdk"
13
+ },
14
+ "homepage": "https://github.com/raindrop-ai/raindrop-js/tree/main/packages/ai-sdk#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/raindrop-ai/raindrop-js/issues"
17
+ },
8
18
  "exports": {
9
19
  ".": {
10
20
  "types": "./dist/index.node.d.ts",
@@ -26,6 +36,20 @@
26
36
  "files": [
27
37
  "dist/**"
28
38
  ],
39
+ "devDependencies": {
40
+ "@types/node": "^20.11.17",
41
+ "msw": "^2.12.7",
42
+ "tsup": "^8.4.0",
43
+ "tsx": "^4.20.3",
44
+ "typescript": "^5.3.3",
45
+ "@raindrop-ai/core": "0.0.1"
46
+ },
47
+ "peerDependencies": {
48
+ "ai": ">=4 <8"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
29
53
  "scripts": {
30
54
  "build": "tsup",
31
55
  "dev": "tsup --watch",
@@ -40,19 +64,5 @@
40
64
  "test:v6": "pnpm build && cd tests/v6 && pnpm install --ignore-workspace --lockfile=false && pnpm test",
41
65
  "test:v7": "pnpm build && cd tests/v7 && pnpm install --ignore-workspace --lockfile=false && pnpm test",
42
66
  "test:install": "cd tests/v4 && pnpm install --ignore-workspace --lockfile=false && cd ../v5 && pnpm install --ignore-workspace --lockfile=false && cd ../v6 && pnpm install --ignore-workspace --lockfile=false && cd ../v7 && pnpm install --ignore-workspace --lockfile=false"
43
- },
44
- "devDependencies": {
45
- "@raindrop-ai/core": "workspace:*",
46
- "@types/node": "^20.11.17",
47
- "msw": "^2.12.7",
48
- "tsup": "^8.4.0",
49
- "tsx": "^4.20.3",
50
- "typescript": "^5.3.3"
51
- },
52
- "peerDependencies": {
53
- "ai": ">=4 <8"
54
- },
55
- "publishConfig": {
56
- "access": "public"
57
67
  }
58
- }
68
+ }