@raindrop-ai/wizard 0.0.1 → 0.0.2
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/dist/src/docs/claude-agent-sdk.mdx +382 -0
- package/dist/src/docs/{typescript.md → typescript.mdx} +8 -4
- package/dist/src/docs/vercel-ai-sdk.mdx +769 -0
- package/dist/src/lib/agent-interface.d.ts +4 -3
- package/dist/src/lib/agent-interface.js +290 -197
- package/dist/src/lib/agent-interface.js.map +1 -1
- package/dist/src/lib/constants.d.ts +1 -0
- package/dist/src/lib/constants.js +1 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/handlers.d.ts +16 -8
- package/dist/src/lib/handlers.js +232 -118
- package/dist/src/lib/handlers.js.map +1 -1
- package/dist/src/lib/integration-testing.d.ts +5 -5
- package/dist/src/lib/integration-testing.js +28 -12
- package/dist/src/lib/integration-testing.js.map +1 -1
- package/dist/src/lib/mcp.d.ts +1 -1
- package/dist/src/lib/mcp.js +88 -49
- package/dist/src/lib/mcp.js.map +1 -1
- package/dist/src/lib/sdk-messages.d.ts +8 -1
- package/dist/src/lib/sdk-messages.js +83 -27
- package/dist/src/lib/sdk-messages.js.map +1 -1
- package/dist/src/lib/wizard.js +16 -20
- package/dist/src/lib/wizard.js.map +1 -1
- package/dist/src/ui/App.d.ts +5 -4
- package/dist/src/ui/App.js +12 -12
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/components/ClarifyingQuestionsPrompt.js +4 -2
- package/dist/src/ui/components/ClarifyingQuestionsPrompt.js.map +1 -1
- package/dist/src/ui/components/ContinuePrompt.d.ts +3 -2
- package/dist/src/ui/components/ContinuePrompt.js +4 -4
- package/dist/src/ui/components/ContinuePrompt.js.map +1 -1
- package/dist/src/ui/components/DiffDisplay.js +16 -6
- package/dist/src/ui/components/DiffDisplay.js.map +1 -1
- package/dist/src/ui/components/FeedbackSelectPrompt.js +6 -3
- package/dist/src/ui/components/FeedbackSelectPrompt.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +5 -3
- package/dist/src/ui/components/HistoryItemDisplay.js +10 -9
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/Logo.js +19 -34
- package/dist/src/ui/components/Logo.js.map +1 -1
- package/dist/src/ui/components/OrgInfoBox.d.ts +2 -1
- package/dist/src/ui/components/OrgInfoBox.js +2 -4
- package/dist/src/ui/components/OrgInfoBox.js.map +1 -1
- package/dist/src/ui/components/PersistentTextInput.js +13 -11
- package/dist/src/ui/components/PersistentTextInput.js.map +1 -1
- package/dist/src/ui/components/PromptContainer.js +4 -8
- package/dist/src/ui/components/PromptContainer.js.map +1 -1
- package/dist/src/ui/components/ToolApprovalPrompt.js +4 -4
- package/dist/src/ui/components/ToolApprovalPrompt.js.map +1 -1
- package/dist/src/ui/components/WriteKeyDisplay.d.ts +1 -1
- package/dist/src/ui/components/WriteKeyDisplay.js +1 -1
- package/dist/src/ui/components/WriteKeyDisplay.js.map +1 -1
- package/dist/src/ui/contexts/WizardContext.d.ts +13 -5
- package/dist/src/ui/contexts/WizardContext.js +60 -20
- package/dist/src/ui/contexts/WizardContext.js.map +1 -1
- package/dist/src/ui/render.js +49 -5
- package/dist/src/ui/render.js.map +1 -1
- package/dist/src/ui/types.d.ts +4 -2
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/utils/oauth.js +0 -4
- package/dist/src/utils/oauth.js.map +1 -1
- package/dist/src/utils/session.d.ts +1 -0
- package/dist/src/utils/session.js +40 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/ui.d.ts +7 -2
- package/dist/src/utils/ui.js +9 -2
- package/dist/src/utils/ui.js.map +1 -1
- package/package.json +2 -1
- package/dist/src/docs/vercel-ai-sdk.md +0 -304
- /package/dist/src/docs/{browser.md → browser.mdx} +0 -0
- /package/dist/src/docs/{python.md → python.mdx} +0 -0
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
## Vercel AI SDK Integration
|
|
2
|
-
|
|
3
|
-
Two-step setup:
|
|
4
|
-
|
|
5
|
-
1. Configure OpenTelemetry trace exporter (platform-specific)
|
|
6
|
-
2. Instrument AI SDK calls with Raindrop metadata
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Step 1: Configure OTEL Trace Exporter
|
|
11
|
-
|
|
12
|
-
> Choose the section matching the project setup:
|
|
13
|
-
>
|
|
14
|
-
> - **Next.js + Sentry** → [With Sentry (Next.js)](#with-sentry-nextjs)
|
|
15
|
-
> - **Next.js (no Sentry)** → [Next.js](#nextjs)
|
|
16
|
-
> - **Node.js** → [Node.js](#nodejs)
|
|
17
|
-
> - **Cloudflare Workers** → [Cloudflare Workers](#cloudflare-workers)
|
|
18
|
-
|
|
19
|
-
### With Sentry (Next.js)
|
|
20
|
-
|
|
21
|
-
If already using Sentry, add Raindrop's exporter to Sentry's OTEL config to
|
|
22
|
-
avoid duplicate registration issues.
|
|
23
|
-
|
|
24
|
-
**Install dependencies:**
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install @opentelemetry/exporter-trace-otlp-proto @opentelemetry/sdk-trace-base
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Configure:**
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
// sentry.server.config.ts
|
|
34
|
-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
35
|
-
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
36
|
-
import * as Sentry from '@sentry/nextjs';
|
|
37
|
-
|
|
38
|
-
Sentry.init({
|
|
39
|
-
dsn: process.env.SENTRY_DSN,
|
|
40
|
-
tracesSampleRate: 1,
|
|
41
|
-
openTelemetrySpanProcessors: [
|
|
42
|
-
new BatchSpanProcessor(
|
|
43
|
-
new OTLPTraceExporter({
|
|
44
|
-
url: 'https://api.raindrop.ai/v1/traces',
|
|
45
|
-
headers: {
|
|
46
|
-
Authorization: `Bearer ${process.env.RAINDROP_WRITE_KEY}`,
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
),
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Next.js
|
|
55
|
-
|
|
56
|
-
**Install dependencies:**
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
npm install raindrop-ai @opentelemetry/api @opentelemetry/sdk-trace-base @vercel/otel
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Configure:**
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
// instrumentation.ts
|
|
66
|
-
import { registerOTel, OTLPHttpProtoTraceExporter } from '@vercel/otel';
|
|
67
|
-
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
68
|
-
|
|
69
|
-
export function register() {
|
|
70
|
-
registerOTel({
|
|
71
|
-
serviceName: projectName, // Replace with your app/service name
|
|
72
|
-
spanProcessors: [
|
|
73
|
-
new BatchSpanProcessor(
|
|
74
|
-
new OTLPHttpProtoTraceExporter({
|
|
75
|
-
url: 'https://api.raindrop.ai/v1/traces',
|
|
76
|
-
headers: {
|
|
77
|
-
Authorization: `Bearer ${process.env.RAINDROP_WRITE_KEY}`,
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
),
|
|
81
|
-
],
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
> Error: "Cannot execute the operation on ended Span" → Use `runtime = 'nodejs'`
|
|
87
|
-
> instead of `'edge'`.
|
|
88
|
-
|
|
89
|
-
### Node.js
|
|
90
|
-
|
|
91
|
-
**Install dependencies:**
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
npm install raindrop-ai @opentelemetry/api @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-proto @opentelemetry/sdk-trace-node
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Configure:**
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
101
|
-
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';
|
|
102
|
-
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
103
|
-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
|
104
|
-
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
105
|
-
|
|
106
|
-
const sdk = new NodeSDK({
|
|
107
|
-
resource: resourceFromAttributes({
|
|
108
|
-
[ATTR_SERVICE_NAME]: projectName, // Replace with your app/service name
|
|
109
|
-
}),
|
|
110
|
-
spanProcessors: [
|
|
111
|
-
new BatchSpanProcessor(
|
|
112
|
-
new OTLPTraceExporter({
|
|
113
|
-
url: 'https://api.raindrop.ai/v1/traces',
|
|
114
|
-
headers: {
|
|
115
|
-
Authorization: `Bearer ${process.env.RAINDROP_WRITE_KEY}`,
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
),
|
|
119
|
-
],
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
sdk.start();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Cloudflare Workers
|
|
126
|
-
|
|
127
|
-
Cloudflare's native tracing does not support custom spans. Use
|
|
128
|
-
`@microlabs/otel-cf-workers`.
|
|
129
|
-
|
|
130
|
-
**Install dependencies:**
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
npm install raindrop-ai @opentelemetry/api @microlabs/otel-cf-workers
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Wrangler config:**
|
|
137
|
-
|
|
138
|
-
```toml
|
|
139
|
-
compatibility_flags = ["nodejs_compat"]
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**OTEL config:**
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
// src/otel.ts
|
|
146
|
-
import { instrument, type ResolveConfigFn } from '@microlabs/otel-cf-workers';
|
|
147
|
-
|
|
148
|
-
export interface Env {
|
|
149
|
-
RAINDROP_WRITE_KEY: string;
|
|
150
|
-
[key: string]: unknown;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const otelConfig: ResolveConfigFn<Env> = (env, _trigger) => ({
|
|
154
|
-
exporter: {
|
|
155
|
-
url: 'https://api.raindrop.ai/v1/traces',
|
|
156
|
-
headers: {
|
|
157
|
-
Authorization: `Bearer ${env.RAINDROP_WRITE_KEY}`,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
service: {
|
|
161
|
-
name: workerName, // Replace with your worker/service name
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
export { instrument };
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
**Instrument handler:**
|
|
169
|
-
|
|
170
|
-
```ts
|
|
171
|
-
// src/index.ts — adapt AI provider imports to your project
|
|
172
|
-
import { streamText } from 'ai';
|
|
173
|
-
import { createOpenAI } from '@ai-sdk/openai'; // Adapt to your AI provider (e.g. @ai-sdk/anthropic)
|
|
174
|
-
import raindrop from 'raindrop-ai/otel';
|
|
175
|
-
import { instrument, otelConfig, Env } from './otel';
|
|
176
|
-
|
|
177
|
-
const handler = {
|
|
178
|
-
async fetch(
|
|
179
|
-
request: Request,
|
|
180
|
-
env: Env,
|
|
181
|
-
ctx: ExecutionContext,
|
|
182
|
-
): Promise<Response> {
|
|
183
|
-
const openai = createOpenAI({ apiKey: env.OPENAI_API_KEY }); // Adapt to your AI provider
|
|
184
|
-
const { prompt } = await request.json();
|
|
185
|
-
|
|
186
|
-
const result = streamText({
|
|
187
|
-
model: model, // Your app's AI model instance (e.g. 'gpt-4o','claude-3-opus')
|
|
188
|
-
prompt,
|
|
189
|
-
experimental_telemetry: {
|
|
190
|
-
isEnabled: true,
|
|
191
|
-
functionId: 'chat',
|
|
192
|
-
metadata: {
|
|
193
|
-
...raindrop.metadata({ userId: userId }), // The authenticated user's ID from your app
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
ctx.waitUntil(result.text);
|
|
199
|
-
return result.toTextStreamResponse();
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export default instrument(handler, otelConfig);
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## Step 2: Instrumentation
|
|
209
|
-
|
|
210
|
-
### Requirements
|
|
211
|
-
|
|
212
|
-
1. Enable telemetry at **all** AI SDK call sites:
|
|
213
|
-
`experimental_telemetry: { isEnabled: true }`
|
|
214
|
-
2. Add Raindrop metadata at top-level call using `raindrop.metadata()`
|
|
215
|
-
|
|
216
|
-
### Usage
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
// Adapt imports to your project's AI provider (e.g. @ai-sdk/openai, @ai-sdk/anthropic, etc.)
|
|
220
|
-
import { generateText, tool } from 'ai';
|
|
221
|
-
import { z } from 'zod';
|
|
222
|
-
import raindrop from 'raindrop-ai/otel';
|
|
223
|
-
|
|
224
|
-
// Nested call - only needs isEnabled: true
|
|
225
|
-
const enhanceStory = tool({
|
|
226
|
-
description: 'Enhance story',
|
|
227
|
-
parameters: z.object({ story: z.string() }),
|
|
228
|
-
execute: async ({ story }) => {
|
|
229
|
-
const enhanced = await generateText({
|
|
230
|
-
model: model, // Your app's AI model instance (e.g. 'gpt-4o','claude-3-opus')
|
|
231
|
-
prompt: `Enhance: ${story}`,
|
|
232
|
-
experimental_telemetry: {
|
|
233
|
-
isEnabled: true, // Required at all call sites
|
|
234
|
-
functionId: 'enhance-story',
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
return { enhancedStory: enhanced.text };
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Top-level call - add raindrop.metadata()
|
|
242
|
-
const result = await generateText({
|
|
243
|
-
model: model, // Your app's AI model instance
|
|
244
|
-
prompt: userPrompt,
|
|
245
|
-
tools: { enhanceStory },
|
|
246
|
-
experimental_telemetry: {
|
|
247
|
-
isEnabled: true, // Required
|
|
248
|
-
functionId: 'generate-text',
|
|
249
|
-
metadata: {
|
|
250
|
-
...raindrop.metadata({
|
|
251
|
-
userId: userId, // Required — the authenticated user's ID from your app
|
|
252
|
-
eventName: eventName, // A descriptive name for this AI action (e.g. 'chat_message', 'code_generation')
|
|
253
|
-
convoId: conversationId, // Your app's conversation/thread ID (if applicable)
|
|
254
|
-
wizardSession: '__WIZARD_SESSION_UUID__', // Required
|
|
255
|
-
}),
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
### Key Points
|
|
262
|
-
|
|
263
|
-
- **All call sites** need `experimental_telemetry: { isEnabled: true }`
|
|
264
|
-
- **Top-level call** adds `raindrop.metadata()` to capture user/event info
|
|
265
|
-
- **Nested calls** only need `isEnabled: true`
|
|
266
|
-
|
|
267
|
-
## Troubleshooting
|
|
268
|
-
|
|
269
|
-
### Debug Logging
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
OTEL_LOG_LEVEL=debug npm run dev
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### Missing Traces
|
|
276
|
-
|
|
277
|
-
Ensure `experimental_telemetry: { isEnabled: true }` at **every** AI SDK call:
|
|
278
|
-
|
|
279
|
-
```typescript
|
|
280
|
-
// ❌ Not traced
|
|
281
|
-
const result = await generateText({ model: openai('gpt-4o'), prompt: 'Hello' });
|
|
282
|
-
|
|
283
|
-
// ✅ Traced
|
|
284
|
-
const result = await generateText({
|
|
285
|
-
model: openai('gpt-4o'),
|
|
286
|
-
prompt: 'Hello',
|
|
287
|
-
experimental_telemetry: { isEnabled: true },
|
|
288
|
-
});
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Cloudflare Workers: Incomplete Spans
|
|
292
|
-
|
|
293
|
-
Streaming responses need `waitUntil()` to prevent premature flush:
|
|
294
|
-
|
|
295
|
-
```typescript
|
|
296
|
-
// ❌ Incomplete spans (1ms duration)
|
|
297
|
-
const result = streamText({ ... });
|
|
298
|
-
return result.toTextStreamResponse();
|
|
299
|
-
|
|
300
|
-
// ✅ Complete spans
|
|
301
|
-
const result = streamText({ ... });
|
|
302
|
-
ctx.waitUntil(result.text); // Delays flush until stream completes
|
|
303
|
-
return result.toTextStreamResponse();
|
|
304
|
-
```
|
|
File without changes
|
|
File without changes
|