@raindrop-ai/ai-sdk 0.0.32 → 0.0.34

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 CHANGED
@@ -55,6 +55,28 @@ await raindrop.users.identify({
55
55
  await raindrop.flush();
56
56
  ```
57
57
 
58
+ ## Payload size limits
59
+
60
+ Text fields (event input/output, tool/LLM span payloads such as `ai.prompt`,
61
+ `ai.toolCall.args`, `ai.toolCall.result`) are capped at **1,000,000 characters
62
+ per field by default** and truncated with a `...[truncated by raindrop]`
63
+ marker. The cap is enforced before (or during) serialization, so a multi-MB
64
+ tool result costs the cap — not the payload — on your event loop, and
65
+ oversized events land truncated instead of being dropped at the ingest size
66
+ limit. Tune it via:
67
+
68
+ ```ts
69
+ const raindrop = createRaindropAISDK({
70
+ writeKey: "...",
71
+ maxTextFieldChars: 250_000,
72
+ });
73
+ ```
74
+
75
+ A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored. The
76
+ bounded helpers are exported (`capText`, `boundedStringify`,
77
+ `TRUNCATION_MARKER`, `DEFAULT_MAX_TEXT_FIELD_CHARS`) for use in custom
78
+ `transformSpan` hooks and `buildEvent` builders.
79
+
58
80
  ## Manual Traces
59
81
 
60
82
  Create trace spans manually alongside, or instead of, auto-instrumented ones.
@@ -115,9 +137,50 @@ raindrop.traces.endSpan(agentTurn);
115
137
  await raindrop.flush();
116
138
  ```
117
139
 
118
- ### AI SDK v7+ native telemetry (opt-in)
140
+ ### AI SDK v7 quick start: `registerTelemetry(raindrop())`
141
+
142
+ On AI SDK v7, the simplest setup is the `raindrop()` factory, which returns a
143
+ ready-to-register telemetry integration. The `writeKey` defaults to the
144
+ `RAINDROP_WRITE_KEY` environment variable.
145
+
146
+ ```ts
147
+ import { generateText, registerTelemetry } from "ai";
148
+ import { OpenTelemetry } from "@ai-sdk/otel";
149
+ import { raindrop } from "@raindrop-ai/ai-sdk";
150
+
151
+ registerTelemetry(new OpenTelemetry(), raindrop());
152
+
153
+ const result = await generateText({
154
+ model: anthropic("claude-sonnet-4-5"),
155
+ prompt: "what is the weather in Tokyo?",
156
+ telemetry: { functionId: "weather-agent" }, // no `isEnabled` needed in v7
157
+ });
158
+ ```
159
+
160
+ `raindrop()` is self-contained — `@ai-sdk/otel` is optional; you can register
161
+ Raindrop on its own with `registerTelemetry(raindrop())`. Pass `context` and
162
+ `subagentWrapping` to customise behaviour, e.g. `raindrop({ context: { userId: "user_123" } })`.
163
+
164
+ For short-lived scripts that exit before the background flush timer fires, keep
165
+ the reference and drain it before exiting:
166
+
167
+ ```ts
168
+ const rd = raindrop();
169
+ registerTelemetry(rd);
170
+ // ... run your generations ...
171
+ await rd.flush(); // or rd.shutdown()
172
+ ```
173
+
174
+ Sub-agents (a `generateText`/`streamText` invoked from inside a tool's
175
+ `execute`) nest automatically: the inner generation's spans are parented under
176
+ the tool span so parent and child spans stay correctly nested.
177
+
178
+ ### AI SDK v7+ native telemetry (advanced)
119
179
 
120
- On AI SDK v7+, you can use the native `Telemetry` callback interface (formerly `TelemetryIntegration` before beta.111) instead of Proxy wrapping. This avoids Proxy overhead and works with all AI SDK entry points (including `ToolLoopAgent`).
180
+ For finer control you can build the integration from a `createRaindropAISDK`
181
+ client instead. The native `Telemetry` callback interface (formerly
182
+ `TelemetryIntegration` before beta.111) avoids Proxy overhead and works with all
183
+ AI SDK entry points (including `ToolLoopAgent`).
121
184
 
122
185
  ```ts
123
186
  // Option A: wrap() with nativeTelemetry flag
@@ -251,7 +314,7 @@ This package is tested against multiple Vercel AI SDK versions:
251
314
  | v4.x | ✅ Supported | Proxy |
252
315
  | v5.x | ✅ Supported | Proxy |
253
316
  | v6.x | ✅ Supported | Proxy |
254
- | v7.x (beta) | ✅ Supported | Proxy (default) or native `Telemetry` (opt-in, formerly `TelemetryIntegration` pre-beta.111). Verified against beta.116. |
317
+ | v7.x (beta/canary) | ✅ Supported | Proxy (default) or native `Telemetry` (opt-in, formerly `TelemetryIntegration` pre-beta.111). Verified against beta.116 and canary.171. |
255
318
 
256
319
  ### Version Differences Handled
257
320