@raindrop-ai/wizard 0.0.9 → 0.0.11
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.
|
@@ -53,6 +53,7 @@ const { query, createSdkMcpServer, ReadTool, EditTool } = raindrop.wrap(
|
|
|
53
53
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
56
57
|
},
|
|
57
58
|
);
|
|
58
59
|
|
|
@@ -126,9 +127,85 @@ const wrapped = raindrop.wrap(claudeAgentSDK, {
|
|
|
126
127
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
127
128
|
},
|
|
128
129
|
},
|
|
130
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
129
131
|
});
|
|
130
132
|
```
|
|
131
133
|
|
|
134
|
+
### Self Diagnostics
|
|
135
|
+
|
|
136
|
+
Enabling `selfDiagnostics` injects a tool that allows the users' AI to report
|
|
137
|
+
issues it detects during execution (for example: tool failures, looping
|
|
138
|
+
behavior, or missing capabilities). The tool is delivered as an in-process MCP
|
|
139
|
+
server, so it works alongside any other MCP servers the user configures. The
|
|
140
|
+
tool name defaults to `__raindrop_report`, and can be overridden with
|
|
141
|
+
`selfDiagnostics.toolName`. The SDK automatically prompt-engineers the tool
|
|
142
|
+
description from the developer provided `signals` definitions;
|
|
143
|
+
`selfDiagnostics.guidance` is optional extra guidance.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import * as claudeAgentSDK from '@anthropic-ai/claude-agent-sdk';
|
|
147
|
+
import {
|
|
148
|
+
createRaindropClaudeAgentSDK,
|
|
149
|
+
eventMetadata,
|
|
150
|
+
} from '@raindrop-ai/claude-agent-sdk';
|
|
151
|
+
|
|
152
|
+
const raindrop = createRaindropClaudeAgentSDK({
|
|
153
|
+
writeKey: process.env.RAINDROP_WRITE_KEY!,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const wrapped = raindrop.wrap(claudeAgentSDK, {
|
|
157
|
+
context: {
|
|
158
|
+
properties: {
|
|
159
|
+
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
selfDiagnostics: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
// Optional: replace defaults with domain-specific categories
|
|
165
|
+
signals: {
|
|
166
|
+
missing_context: {
|
|
167
|
+
description:
|
|
168
|
+
'You cannot complete the task because critical information, credentials, or access is missing and the user cannot provide it. ' +
|
|
169
|
+
'Do NOT report this for normal clarifying questions — only when you are blocked.',
|
|
170
|
+
sentiment: 'NEGATIVE',
|
|
171
|
+
},
|
|
172
|
+
repeatedly_broken_tool: {
|
|
173
|
+
description:
|
|
174
|
+
'A tool has failed or not returned the expected response on multiple distinct attempts in this conversation, preventing task completion. ' +
|
|
175
|
+
'A single tool error is NOT enough — the tool must be persistently broken or aberrantly behaving across retries.',
|
|
176
|
+
sentiment: 'NEGATIVE',
|
|
177
|
+
},
|
|
178
|
+
complete_task_failure: {
|
|
179
|
+
description:
|
|
180
|
+
'You were unable to accomplish what the user asked despite making genuine attempts. ' +
|
|
181
|
+
'This is NOT a refusal or policy block — you tried and failed to deliver the result.',
|
|
182
|
+
sentiment: 'NEGATIVE',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
When invoked, the injected tool tracks a signal on the same `eventId`:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"event_id": "evt_...",
|
|
194
|
+
"signal_name": "agent:tool_failure",
|
|
195
|
+
"signal_type": "agent",
|
|
196
|
+
"properties": {
|
|
197
|
+
"source": "agent_reporting_tool",
|
|
198
|
+
"category": "tool_failure",
|
|
199
|
+
"signal_description": "A tool call returned an error, timed out, or produced unusable output.",
|
|
200
|
+
"detail": "The search API returned a 503 after two retries."
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The self-diagnostics tool is invisible: it is auto-approved in the PreToolUse
|
|
206
|
+
hook and its tool_use/tool_result blocks are stripped from the SDK stream, so
|
|
207
|
+
the user never sees it and doesn't need to handle it.
|
|
208
|
+
|
|
132
209
|
## Per-Query Context
|
|
133
210
|
|
|
134
211
|
Use `eventMetadata()` as the second argument when you want a query tracked.
|
|
@@ -143,6 +220,7 @@ const wrapped = raindrop.wrap(claudeAgentSDK, {
|
|
|
143
220
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
144
221
|
},
|
|
145
222
|
},
|
|
223
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
146
224
|
});
|
|
147
225
|
|
|
148
226
|
for await (const msg of wrapped.query(
|
|
@@ -201,6 +279,7 @@ const wrapped = raindrop.wrap(claudeAgentSDK, {
|
|
|
201
279
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
202
280
|
},
|
|
203
281
|
},
|
|
282
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
204
283
|
});
|
|
205
284
|
|
|
206
285
|
for await (const msg of wrapped.query(
|
|
@@ -257,6 +336,7 @@ const wrapped = raindrop.wrap(claudeAgentSDK, {
|
|
|
257
336
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
258
337
|
},
|
|
259
338
|
},
|
|
339
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
260
340
|
});
|
|
261
341
|
|
|
262
342
|
for await (const msg of wrapped.query(
|
|
@@ -310,6 +390,7 @@ export async function POST(request: Request) {
|
|
|
310
390
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
311
391
|
},
|
|
312
392
|
},
|
|
393
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
313
394
|
});
|
|
314
395
|
const messages = [];
|
|
315
396
|
for await (const msg of wrapped.query(
|
|
@@ -50,6 +50,7 @@ const { generateText, streamText } = raindrop.wrap(ai, {
|
|
|
50
50
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
// 3. Use the wrapped methods
|
|
@@ -156,6 +157,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
156
157
|
}, // Optional - custom metadata
|
|
157
158
|
attachments: [], // Optional - input/output attachments
|
|
158
159
|
},
|
|
160
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
159
161
|
|
|
160
162
|
autoAttachment: true, // Default: true. Set false to disable automatic parsing
|
|
161
163
|
|
|
@@ -199,6 +201,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
199
201
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
200
202
|
},
|
|
201
203
|
},
|
|
204
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
202
205
|
});
|
|
203
206
|
|
|
204
207
|
// Override defaults for this call
|
|
@@ -242,6 +245,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
242
245
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
243
246
|
},
|
|
244
247
|
},
|
|
248
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
245
249
|
});
|
|
246
250
|
|
|
247
251
|
await generateText({
|
|
@@ -299,6 +303,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
299
303
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
300
304
|
},
|
|
301
305
|
},
|
|
306
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
302
307
|
});
|
|
303
308
|
|
|
304
309
|
// Tool calls are traced with args and results
|
|
@@ -317,6 +322,56 @@ const result = await generateText({
|
|
|
317
322
|
});
|
|
318
323
|
```
|
|
319
324
|
|
|
325
|
+
### Self Diagnostics
|
|
326
|
+
|
|
327
|
+
Enabling `selfDiagnostics` injects a hidden tool that the user's AI can call
|
|
328
|
+
silently when it hits an unrecoverable problem. Signals appear in Raindrop's
|
|
329
|
+
Self Diagnostics section and feed into issue discovery.
|
|
330
|
+
|
|
331
|
+
The three default categories are `missing_context`, `repeatedly_broken_tool`,
|
|
332
|
+
and `complete_task_failure`. You can replace these with your own.
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
const { generateText } = raindrop.wrap(ai, {
|
|
336
|
+
// Optional: include your wizard session for correlation in Raindrop
|
|
337
|
+
context: {
|
|
338
|
+
properties: {
|
|
339
|
+
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
selfDiagnostics: {
|
|
343
|
+
enabled: true,
|
|
344
|
+
// Optional: replace defaults with domain-specific categories
|
|
345
|
+
signals: {
|
|
346
|
+
payment_failed: {
|
|
347
|
+
description: 'Payment processing failed after retries.',
|
|
348
|
+
sentiment: 'NEGATIVE',
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
// Optional: extra guidance for the model
|
|
352
|
+
guidance: "Only report when the user's transaction is actually blocked.",
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
You don't need to mention self diagnostics in your system prompt — the SDK
|
|
358
|
+
handles the tool description automatically.
|
|
359
|
+
|
|
360
|
+
When the agent calls the tool, a signal is tracked on the same `eventId`:
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"event_id": "evt_...",
|
|
365
|
+
"signal_name": "self diagnostics - missing_context",
|
|
366
|
+
"signal_type": "agent",
|
|
367
|
+
"properties": {
|
|
368
|
+
"source": "agent_reporting_tool",
|
|
369
|
+
"category": "missing_context",
|
|
370
|
+
"detail": "User asked to fix deployment but no access to logs or SSH credentials."
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
320
375
|
### Nested LLM Calls in Tools
|
|
321
376
|
|
|
322
377
|
If your tool makes additional LLM calls, wrap them too for full trace
|
|
@@ -336,6 +391,7 @@ const summarizeTool = tool({
|
|
|
336
391
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
337
392
|
},
|
|
338
393
|
},
|
|
394
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
339
395
|
send: { events: false, traces: true },
|
|
340
396
|
});
|
|
341
397
|
|
|
@@ -368,6 +424,7 @@ const { streamText } = raindrop.wrap(ai, {
|
|
|
368
424
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
369
425
|
},
|
|
370
426
|
},
|
|
427
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
371
428
|
});
|
|
372
429
|
|
|
373
430
|
const result = await streamText({
|
|
@@ -408,6 +465,7 @@ const { streamObject } = raindrop.wrap(ai, {
|
|
|
408
465
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
409
466
|
},
|
|
410
467
|
},
|
|
468
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
411
469
|
});
|
|
412
470
|
|
|
413
471
|
const result = await streamObject({
|
|
@@ -466,7 +524,9 @@ const raindrop = createRaindropAISDK({
|
|
|
466
524
|
writeKey: process.env.RAINDROP_WRITE_KEY!,
|
|
467
525
|
});
|
|
468
526
|
|
|
469
|
-
const wrapped = raindrop.wrap(ai
|
|
527
|
+
const wrapped = raindrop.wrap(ai, {
|
|
528
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
529
|
+
});
|
|
470
530
|
|
|
471
531
|
const weatherTool = ai.tool({
|
|
472
532
|
description: 'Get current weather',
|
|
@@ -476,7 +536,7 @@ const weatherTool = ai.tool({
|
|
|
476
536
|
},
|
|
477
537
|
});
|
|
478
538
|
|
|
479
|
-
const agent = new ToolLoopAgent({
|
|
539
|
+
const agent = new wrapped.ToolLoopAgent({
|
|
480
540
|
model: openai('gpt-4o'),
|
|
481
541
|
tools: { weather: weatherTool },
|
|
482
542
|
maxSteps: 5,
|
|
@@ -526,6 +586,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
526
586
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
527
587
|
},
|
|
528
588
|
},
|
|
589
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
529
590
|
});
|
|
530
591
|
|
|
531
592
|
const result = await generateText({
|
|
@@ -551,11 +612,13 @@ await raindrop.signals.track({
|
|
|
551
612
|
|
|
552
613
|
### Signal Types
|
|
553
614
|
|
|
554
|
-
| Type | Use Case
|
|
555
|
-
| ------------ |
|
|
556
|
-
| `"default"` | Generic signals (thumbs up/down)
|
|
557
|
-
| `"feedback"` | User comments about quality
|
|
558
|
-
| `"edit"` | User corrected the output
|
|
615
|
+
| Type | Use Case |
|
|
616
|
+
| ------------ | ---------------------------------------------- |
|
|
617
|
+
| `"default"` | Generic signals (thumbs up/down) |
|
|
618
|
+
| `"feedback"` | User comments about quality |
|
|
619
|
+
| `"edit"` | User corrected the output |
|
|
620
|
+
| `"standard"` | Programmatic/custom instrumentation |
|
|
621
|
+
| `"agent"` | Self diagnostics issues from `selfDiagnostics` |
|
|
559
622
|
|
|
560
623
|
```typescript
|
|
561
624
|
// Thumbs up
|
|
@@ -620,6 +683,7 @@ const { generateText } = raindrop.wrap(ai, {
|
|
|
620
683
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
621
684
|
},
|
|
622
685
|
},
|
|
686
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
623
687
|
buildEvent: (messages) => {
|
|
624
688
|
const userMessages = messages.filter((m) => m.role === 'user');
|
|
625
689
|
const assistantMessages = messages.filter((m) => m.role === 'assistant');
|
|
@@ -758,6 +822,7 @@ const { generateText: innerGenerate } = raindrop.wrap(ai, {
|
|
|
758
822
|
wizardSession: '__WIZARD_SESSION_UUID__', // REQUIRED
|
|
759
823
|
},
|
|
760
824
|
},
|
|
825
|
+
selfDiagnostics: { enabled: true }, // REQUIRED upgrade: unless the user explicitly requests they don't want this new feature
|
|
761
826
|
send: { events: false, traces: true },
|
|
762
827
|
});
|
|
763
828
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raindrop-ai/wizard",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://github.com/raindrop/wizard",
|
|
6
6
|
"repository": "https://github.com/raindrop/wizard",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@anthropic-ai/claude-agent-sdk": "0.2.50",
|
|
38
38
|
"@inkkit/ink-markdown": "^1.0.0",
|
|
39
|
-
"@raindrop-ai/claude-agent-sdk": "^0.0.
|
|
39
|
+
"@raindrop-ai/claude-agent-sdk": "^0.0.7",
|
|
40
40
|
"chalk": "^2.4.1",
|
|
41
41
|
"clipboardy": "^4.0.0",
|
|
42
42
|
"diff": "^8.0.3",
|