@raindrop-ai/ai-sdk 0.0.10 → 0.0.12

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.
@@ -84,7 +84,7 @@ async function postJson(url, body, headers, opts) {
84
84
  // package.json
85
85
  var package_default = {
86
86
  name: "@raindrop-ai/ai-sdk",
87
- version: "0.0.10"};
87
+ version: "0.0.12"};
88
88
 
89
89
  // src/internal/version.ts
90
90
  var libraryName = package_default.name;
@@ -397,6 +397,9 @@ function base64Encode(bytes) {
397
397
  }
398
398
 
399
399
  // src/internal/otlp.ts
400
+ var SpanStatusCode = {
401
+ ERROR: 2
402
+ };
400
403
  function createSpanIds(parent) {
401
404
  const traceId = parent ? parent.traceIdB64 : base64Encode(randomBytes(16));
402
405
  const spanId = base64Encode(randomBytes(8));
@@ -449,6 +452,7 @@ function buildOtlpSpan(args) {
449
452
  };
450
453
  if (args.ids.parentSpanIdB64) span.parentSpanId = args.ids.parentSpanIdB64;
451
454
  if (attrs.length) span.attributes = attrs;
455
+ if (args.status) span.status = args.status;
452
456
  return span;
453
457
  }
454
458
  function buildExportTraceServiceRequest(spans) {
@@ -509,12 +513,18 @@ var TraceShipper = class {
509
513
  if ((_a = extra == null ? void 0 : extra.attributes) == null ? void 0 : _a.length) {
510
514
  span.attributes.push(...extra.attributes);
511
515
  }
516
+ let status;
517
+ if ((extra == null ? void 0 : extra.error) !== void 0) {
518
+ const message = extra.error instanceof Error ? extra.error.message : String(extra.error);
519
+ status = { code: SpanStatusCode.ERROR, message };
520
+ }
512
521
  const otlp = buildOtlpSpan({
513
522
  ids: span.ids,
514
523
  name: span.name,
515
524
  startTimeUnixNano: span.startTimeUnixNano,
516
525
  endTimeUnixNano: span.endTimeUnixNano,
517
- attributes: span.attributes
526
+ attributes: span.attributes,
527
+ status
518
528
  });
519
529
  this.enqueue(otlp);
520
530
  }
@@ -1247,21 +1257,20 @@ function attrsFromGenAiRequest(options) {
1247
1257
  // src/internal/wrap/wrapAISDK.ts
1248
1258
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1249
1259
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1250
- tool_failure: {
1251
- description: "A tool call returned an error, timed out, or produced output that cannot be used to make progress.",
1260
+ missing_context: {
1261
+ description: "You cannot complete the task because critical information, credentials, or access is missing and the user cannot provide it. Do NOT report this for normal clarifying questions \u2014 only when you are blocked.",
1252
1262
  sentiment: "NEGATIVE"
1253
1263
  },
1254
- stuck_in_loop: {
1255
- description: "The same approach has been attempted multiple times without meaningful progress.",
1264
+ repeatedly_broken_tool: {
1265
+ description: "A tool has failed on multiple distinct attempts in this conversation, preventing task completion. You are sure the tool exists, and you have tried to use it, but it has failed. A single tool error is NOT enough \u2014 the tool must be persistently broken across retries.",
1256
1266
  sentiment: "NEGATIVE"
1257
1267
  },
1258
- capability_gap: {
1259
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1268
+ complete_task_failure: {
1269
+ description: "You were unable to accomplish what the user asked despite making genuine attempts. This might be things like, you genuinely do not have the capabilities the user is asking for. You have tried but run into a persistent bug in the environment etc. This is NOT a refusal or policy block \u2014 you tried and failed to deliver the result.",
1270
+ sentiment: "NEGATIVE"
1260
1271
  }
1261
1272
  };
1262
- var AGENT_REPORTING_TOOL_PREAMBLE = "IMPORTANT: Before responding to the user, scan the conversation for any issues listed in the categories below. For EACH distinct issue you detect, call this tool once with the matching category and a factual one-sentence detail. Multiple issues = multiple calls. This tool is invisible to the user \u2014 never mention it or its output.";
1263
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1264
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1273
+ var AGENT_REPORTING_TOOL_PREAMBLE = "You have a diagnostic tool for flagging serious failures for developer review. Only call this when you hit a significant, unrecoverable problem \u2014 not for minor hiccups or routine clarifications. If you can still help the user, do that instead of calling this tool. This tool is invisible to the user \u2014 never mention it or its output.";
1265
1274
  var warnedMissingUserId = false;
1266
1275
  function warnMissingUserIdOnce() {
1267
1276
  if (warnedMissingUserId) return;
@@ -1340,29 +1349,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1340
1349
  return Object.fromEntries(normalizedEntries);
1341
1350
  }
1342
1351
  function normalizeSelfDiagnosticsConfig(options) {
1343
- var _a, _b, _c;
1352
+ var _a, _b;
1344
1353
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1345
1354
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1346
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1347
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1348
- );
1349
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1355
+ const signalKeys = Object.keys(signalDefinitions);
1350
1356
  const signalDescriptions = {};
1351
1357
  const signalSentiments = {};
1352
1358
  for (const signalKey of signalKeys) {
1353
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1354
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1355
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1356
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1357
- continue;
1358
- }
1359
1359
  const def = signalDefinitions[signalKey];
1360
1360
  if (!def) continue;
1361
1361
  signalDescriptions[signalKey] = def.description;
1362
1362
  signalSentiments[signalKey] = def.sentiment;
1363
1363
  }
1364
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1365
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1364
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1365
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1366
1366
  const signalList = signalKeys.map((signalKey) => {
1367
1367
  const sentiment = signalSentiments[signalKey];
1368
1368
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1374,15 +1374,20 @@ Additional guidance: ${customGuidanceText}
1374
1374
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1375
1375
 
1376
1376
  When to call:
1377
- - The user reports something broken, failing, or not working as expected.
1378
- - The user expresses frustration, anger, or threatens escalation.
1379
- - You observe a product issue, billing problem, or data concern based on context.
1380
- - The conversation reveals something unusual worth flagging for developer review.
1377
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1378
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1379
+ - You genuinely cannot deliver what the user asked for despite trying.
1380
+
1381
+ When NOT to call:
1382
+ - Normal clarifying questions or back-and-forth with the user.
1383
+ - A single tool error that you can recover from or retry.
1384
+ - You successfully completed the task, even if it was difficult.
1385
+ - Policy refusals or content filtering \u2014 those are working as intended.
1381
1386
 
1382
1387
  Rules:
1383
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1384
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1385
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1388
+ 1. Pick the single best category.
1389
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1390
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1386
1391
  ${guidanceBlock}
1387
1392
  Categories:
1388
1393
  ${signalList}`;
@@ -1453,28 +1458,9 @@ function createSelfDiagnosticsTool(ctx) {
1453
1458
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1454
1459
  const signalDescription = config.signalDescriptions[category];
1455
1460
  const signalSentiment = config.signalSentiments[category];
1456
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1457
- void ctx.eventShipper.trackSignal({
1458
- eventId: ctx.eventId,
1459
- name: "agent:noteworthy",
1460
- type: "agent_internal",
1461
- properties: {
1462
- source: "agent_flag_event_tool",
1463
- reason: detail,
1464
- severity: "medium",
1465
- ai_sdk_version: ctx.aiSDKVersion
1466
- }
1467
- }).catch((err) => {
1468
- if (ctx.debug) {
1469
- const msg = err instanceof Error ? err.message : String(err);
1470
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1471
- }
1472
- });
1473
- return { acknowledged: true, category };
1474
- }
1475
1461
  void ctx.eventShipper.trackSignal({
1476
1462
  eventId: ctx.eventId,
1477
- name: `agent:${category}`,
1463
+ name: `self diagnostics - ${category}`,
1478
1464
  type: "agent",
1479
1465
  sentiment: signalSentiment,
1480
1466
  properties: {
@@ -1760,7 +1746,8 @@ function createFinalize(params) {
1760
1746
  attrInt("ai.usage.cachedInputTokens", usage == null ? void 0 : usage.cachedInputTokens),
1761
1747
  attrInt("ai.toolCall.count", setup.toolCalls.length),
1762
1748
  ...error ? [attrString("error.message", error instanceof Error ? error.message : String(error))] : []
1763
- ]
1749
+ ],
1750
+ error
1764
1751
  });
1765
1752
  }
1766
1753
  if (sendEvents) {
@@ -2116,7 +2103,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
2116
2103
  error instanceof Error ? error.message : String(error)
2117
2104
  )
2118
2105
  ] : []
2119
- ]
2106
+ ],
2107
+ error
2120
2108
  });
2121
2109
  }
2122
2110
  if (sendEvents) {
@@ -2309,7 +2297,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
2309
2297
  error instanceof Error ? error.message : String(error)
2310
2298
  )
2311
2299
  ] : []
2312
- ]
2300
+ ],
2301
+ error
2313
2302
  });
2314
2303
  }
2315
2304
  if (sendEvents) {
@@ -2442,7 +2431,8 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
2442
2431
  ctx.traceShipper.endSpan(span, {
2443
2432
  attributes: [
2444
2433
  attrString("error.message", error instanceof Error ? error.message : String(error))
2445
- ]
2434
+ ],
2435
+ error
2446
2436
  });
2447
2437
  } else {
2448
2438
  ctx.traceShipper.endSpan(span, {
@@ -2555,7 +2545,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2555
2545
  "error.message",
2556
2546
  error instanceof Error ? error.message : String(error)
2557
2547
  )
2558
- ]
2548
+ ],
2549
+ error
2559
2550
  });
2560
2551
  throw error;
2561
2552
  }
@@ -2589,7 +2580,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2589
2580
  "error.message",
2590
2581
  error instanceof Error ? error.message : String(error)
2591
2582
  )
2592
- ]
2583
+ ],
2584
+ error
2593
2585
  });
2594
2586
  throw error;
2595
2587
  }
@@ -2643,7 +2635,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2643
2635
  error instanceof Error ? error.message : String(error)
2644
2636
  )
2645
2637
  ] : []
2646
- ]
2638
+ ],
2639
+ error
2647
2640
  });
2648
2641
  };
2649
2642
  const wrappedStream = new RS({
package/dist/index.js CHANGED
@@ -86,7 +86,7 @@ async function postJson(url, body, headers, opts) {
86
86
  // package.json
87
87
  var package_default = {
88
88
  name: "@raindrop-ai/ai-sdk",
89
- version: "0.0.10"};
89
+ version: "0.0.12"};
90
90
 
91
91
  // src/internal/version.ts
92
92
  var libraryName = package_default.name;
@@ -399,6 +399,9 @@ function base64Encode(bytes) {
399
399
  }
400
400
 
401
401
  // src/internal/otlp.ts
402
+ var SpanStatusCode = {
403
+ ERROR: 2
404
+ };
402
405
  function createSpanIds(parent) {
403
406
  const traceId = parent ? parent.traceIdB64 : base64Encode(randomBytes(16));
404
407
  const spanId = base64Encode(randomBytes(8));
@@ -451,6 +454,7 @@ function buildOtlpSpan(args) {
451
454
  };
452
455
  if (args.ids.parentSpanIdB64) span.parentSpanId = args.ids.parentSpanIdB64;
453
456
  if (attrs.length) span.attributes = attrs;
457
+ if (args.status) span.status = args.status;
454
458
  return span;
455
459
  }
456
460
  function buildExportTraceServiceRequest(spans) {
@@ -511,12 +515,18 @@ var TraceShipper = class {
511
515
  if ((_a = extra == null ? void 0 : extra.attributes) == null ? void 0 : _a.length) {
512
516
  span.attributes.push(...extra.attributes);
513
517
  }
518
+ let status;
519
+ if ((extra == null ? void 0 : extra.error) !== void 0) {
520
+ const message = extra.error instanceof Error ? extra.error.message : String(extra.error);
521
+ status = { code: SpanStatusCode.ERROR, message };
522
+ }
514
523
  const otlp = buildOtlpSpan({
515
524
  ids: span.ids,
516
525
  name: span.name,
517
526
  startTimeUnixNano: span.startTimeUnixNano,
518
527
  endTimeUnixNano: span.endTimeUnixNano,
519
- attributes: span.attributes
528
+ attributes: span.attributes,
529
+ status
520
530
  });
521
531
  this.enqueue(otlp);
522
532
  }
@@ -1249,21 +1259,20 @@ function attrsFromGenAiRequest(options) {
1249
1259
  // src/internal/wrap/wrapAISDK.ts
1250
1260
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1251
1261
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1252
- tool_failure: {
1253
- description: "A tool call returned an error, timed out, or produced output that cannot be used to make progress.",
1262
+ missing_context: {
1263
+ description: "You cannot complete the task because critical information, credentials, or access is missing and the user cannot provide it. Do NOT report this for normal clarifying questions \u2014 only when you are blocked.",
1254
1264
  sentiment: "NEGATIVE"
1255
1265
  },
1256
- stuck_in_loop: {
1257
- description: "The same approach has been attempted multiple times without meaningful progress.",
1266
+ repeatedly_broken_tool: {
1267
+ description: "A tool has failed on multiple distinct attempts in this conversation, preventing task completion. You are sure the tool exists, and you have tried to use it, but it has failed. A single tool error is NOT enough \u2014 the tool must be persistently broken across retries.",
1258
1268
  sentiment: "NEGATIVE"
1259
1269
  },
1260
- capability_gap: {
1261
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1270
+ complete_task_failure: {
1271
+ description: "You were unable to accomplish what the user asked despite making genuine attempts. This might be things like, you genuinely do not have the capabilities the user is asking for. You have tried but run into a persistent bug in the environment etc. This is NOT a refusal or policy block \u2014 you tried and failed to deliver the result.",
1272
+ sentiment: "NEGATIVE"
1262
1273
  }
1263
1274
  };
1264
- var AGENT_REPORTING_TOOL_PREAMBLE = "IMPORTANT: Before responding to the user, scan the conversation for any issues listed in the categories below. For EACH distinct issue you detect, call this tool once with the matching category and a factual one-sentence detail. Multiple issues = multiple calls. This tool is invisible to the user \u2014 never mention it or its output.";
1265
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1266
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1275
+ var AGENT_REPORTING_TOOL_PREAMBLE = "You have a diagnostic tool for flagging serious failures for developer review. Only call this when you hit a significant, unrecoverable problem \u2014 not for minor hiccups or routine clarifications. If you can still help the user, do that instead of calling this tool. This tool is invisible to the user \u2014 never mention it or its output.";
1267
1276
  var warnedMissingUserId = false;
1268
1277
  function warnMissingUserIdOnce() {
1269
1278
  if (warnedMissingUserId) return;
@@ -1342,29 +1351,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1342
1351
  return Object.fromEntries(normalizedEntries);
1343
1352
  }
1344
1353
  function normalizeSelfDiagnosticsConfig(options) {
1345
- var _a, _b, _c;
1354
+ var _a, _b;
1346
1355
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1347
1356
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1348
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1349
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1350
- );
1351
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1357
+ const signalKeys = Object.keys(signalDefinitions);
1352
1358
  const signalDescriptions = {};
1353
1359
  const signalSentiments = {};
1354
1360
  for (const signalKey of signalKeys) {
1355
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1356
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1357
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1358
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1359
- continue;
1360
- }
1361
1361
  const def = signalDefinitions[signalKey];
1362
1362
  if (!def) continue;
1363
1363
  signalDescriptions[signalKey] = def.description;
1364
1364
  signalSentiments[signalKey] = def.sentiment;
1365
1365
  }
1366
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1367
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1366
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1367
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1368
1368
  const signalList = signalKeys.map((signalKey) => {
1369
1369
  const sentiment = signalSentiments[signalKey];
1370
1370
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1376,15 +1376,20 @@ Additional guidance: ${customGuidanceText}
1376
1376
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1377
1377
 
1378
1378
  When to call:
1379
- - The user reports something broken, failing, or not working as expected.
1380
- - The user expresses frustration, anger, or threatens escalation.
1381
- - You observe a product issue, billing problem, or data concern based on context.
1382
- - The conversation reveals something unusual worth flagging for developer review.
1379
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1380
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1381
+ - You genuinely cannot deliver what the user asked for despite trying.
1382
+
1383
+ When NOT to call:
1384
+ - Normal clarifying questions or back-and-forth with the user.
1385
+ - A single tool error that you can recover from or retry.
1386
+ - You successfully completed the task, even if it was difficult.
1387
+ - Policy refusals or content filtering \u2014 those are working as intended.
1383
1388
 
1384
1389
  Rules:
1385
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1386
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1387
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1390
+ 1. Pick the single best category.
1391
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1392
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1388
1393
  ${guidanceBlock}
1389
1394
  Categories:
1390
1395
  ${signalList}`;
@@ -1455,28 +1460,9 @@ function createSelfDiagnosticsTool(ctx) {
1455
1460
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1456
1461
  const signalDescription = config.signalDescriptions[category];
1457
1462
  const signalSentiment = config.signalSentiments[category];
1458
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1459
- void ctx.eventShipper.trackSignal({
1460
- eventId: ctx.eventId,
1461
- name: "agent:noteworthy",
1462
- type: "agent_internal",
1463
- properties: {
1464
- source: "agent_flag_event_tool",
1465
- reason: detail,
1466
- severity: "medium",
1467
- ai_sdk_version: ctx.aiSDKVersion
1468
- }
1469
- }).catch((err) => {
1470
- if (ctx.debug) {
1471
- const msg = err instanceof Error ? err.message : String(err);
1472
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1473
- }
1474
- });
1475
- return { acknowledged: true, category };
1476
- }
1477
1463
  void ctx.eventShipper.trackSignal({
1478
1464
  eventId: ctx.eventId,
1479
- name: `agent:${category}`,
1465
+ name: `self diagnostics - ${category}`,
1480
1466
  type: "agent",
1481
1467
  sentiment: signalSentiment,
1482
1468
  properties: {
@@ -1762,7 +1748,8 @@ function createFinalize(params) {
1762
1748
  attrInt("ai.usage.cachedInputTokens", usage == null ? void 0 : usage.cachedInputTokens),
1763
1749
  attrInt("ai.toolCall.count", setup.toolCalls.length),
1764
1750
  ...error ? [attrString("error.message", error instanceof Error ? error.message : String(error))] : []
1765
- ]
1751
+ ],
1752
+ error
1766
1753
  });
1767
1754
  }
1768
1755
  if (sendEvents) {
@@ -2118,7 +2105,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
2118
2105
  error instanceof Error ? error.message : String(error)
2119
2106
  )
2120
2107
  ] : []
2121
- ]
2108
+ ],
2109
+ error
2122
2110
  });
2123
2111
  }
2124
2112
  if (sendEvents) {
@@ -2311,7 +2299,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
2311
2299
  error instanceof Error ? error.message : String(error)
2312
2300
  )
2313
2301
  ] : []
2314
- ]
2302
+ ],
2303
+ error
2315
2304
  });
2316
2305
  }
2317
2306
  if (sendEvents) {
@@ -2444,7 +2433,8 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
2444
2433
  ctx.traceShipper.endSpan(span, {
2445
2434
  attributes: [
2446
2435
  attrString("error.message", error instanceof Error ? error.message : String(error))
2447
- ]
2436
+ ],
2437
+ error
2448
2438
  });
2449
2439
  } else {
2450
2440
  ctx.traceShipper.endSpan(span, {
@@ -2557,7 +2547,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2557
2547
  "error.message",
2558
2548
  error instanceof Error ? error.message : String(error)
2559
2549
  )
2560
- ]
2550
+ ],
2551
+ error
2561
2552
  });
2562
2553
  throw error;
2563
2554
  }
@@ -2591,7 +2582,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2591
2582
  "error.message",
2592
2583
  error instanceof Error ? error.message : String(error)
2593
2584
  )
2594
- ]
2585
+ ],
2586
+ error
2595
2587
  });
2596
2588
  throw error;
2597
2589
  }
@@ -2645,7 +2637,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2645
2637
  error instanceof Error ? error.message : String(error)
2646
2638
  )
2647
2639
  ] : []
2648
- ]
2640
+ ],
2641
+ error
2649
2642
  });
2650
2643
  };
2651
2644
  const wrappedStream = new RS({
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-ZVQRZCBO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-TTHMNVY7.mjs';
@@ -90,7 +90,7 @@ async function postJson(url, body, headers, opts) {
90
90
  // package.json
91
91
  var package_default = {
92
92
  name: "@raindrop-ai/ai-sdk",
93
- version: "0.0.10"};
93
+ version: "0.0.12"};
94
94
 
95
95
  // src/internal/version.ts
96
96
  var libraryName = package_default.name;
@@ -403,6 +403,9 @@ function base64Encode(bytes) {
403
403
  }
404
404
 
405
405
  // src/internal/otlp.ts
406
+ var SpanStatusCode = {
407
+ ERROR: 2
408
+ };
406
409
  function createSpanIds(parent) {
407
410
  const traceId = parent ? parent.traceIdB64 : base64Encode(randomBytes(16));
408
411
  const spanId = base64Encode(randomBytes(8));
@@ -455,6 +458,7 @@ function buildOtlpSpan(args) {
455
458
  };
456
459
  if (args.ids.parentSpanIdB64) span.parentSpanId = args.ids.parentSpanIdB64;
457
460
  if (attrs.length) span.attributes = attrs;
461
+ if (args.status) span.status = args.status;
458
462
  return span;
459
463
  }
460
464
  function buildExportTraceServiceRequest(spans) {
@@ -515,12 +519,18 @@ var TraceShipper = class {
515
519
  if ((_a = extra == null ? void 0 : extra.attributes) == null ? void 0 : _a.length) {
516
520
  span.attributes.push(...extra.attributes);
517
521
  }
522
+ let status;
523
+ if ((extra == null ? void 0 : extra.error) !== void 0) {
524
+ const message = extra.error instanceof Error ? extra.error.message : String(extra.error);
525
+ status = { code: SpanStatusCode.ERROR, message };
526
+ }
518
527
  const otlp = buildOtlpSpan({
519
528
  ids: span.ids,
520
529
  name: span.name,
521
530
  startTimeUnixNano: span.startTimeUnixNano,
522
531
  endTimeUnixNano: span.endTimeUnixNano,
523
- attributes: span.attributes
532
+ attributes: span.attributes,
533
+ status
524
534
  });
525
535
  this.enqueue(otlp);
526
536
  }
@@ -1253,21 +1263,20 @@ function attrsFromGenAiRequest(options) {
1253
1263
  // src/internal/wrap/wrapAISDK.ts
1254
1264
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1255
1265
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1256
- tool_failure: {
1257
- description: "A tool call returned an error, timed out, or produced output that cannot be used to make progress.",
1266
+ missing_context: {
1267
+ description: "You cannot complete the task because critical information, credentials, or access is missing and the user cannot provide it. Do NOT report this for normal clarifying questions \u2014 only when you are blocked.",
1258
1268
  sentiment: "NEGATIVE"
1259
1269
  },
1260
- stuck_in_loop: {
1261
- description: "The same approach has been attempted multiple times without meaningful progress.",
1270
+ repeatedly_broken_tool: {
1271
+ description: "A tool has failed on multiple distinct attempts in this conversation, preventing task completion. You are sure the tool exists, and you have tried to use it, but it has failed. A single tool error is NOT enough \u2014 the tool must be persistently broken across retries.",
1262
1272
  sentiment: "NEGATIVE"
1263
1273
  },
1264
- capability_gap: {
1265
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1274
+ complete_task_failure: {
1275
+ description: "You were unable to accomplish what the user asked despite making genuine attempts. This might be things like, you genuinely do not have the capabilities the user is asking for. You have tried but run into a persistent bug in the environment etc. This is NOT a refusal or policy block \u2014 you tried and failed to deliver the result.",
1276
+ sentiment: "NEGATIVE"
1266
1277
  }
1267
1278
  };
1268
- var AGENT_REPORTING_TOOL_PREAMBLE = "IMPORTANT: Before responding to the user, scan the conversation for any issues listed in the categories below. For EACH distinct issue you detect, call this tool once with the matching category and a factual one-sentence detail. Multiple issues = multiple calls. This tool is invisible to the user \u2014 never mention it or its output.";
1269
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1270
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1279
+ var AGENT_REPORTING_TOOL_PREAMBLE = "You have a diagnostic tool for flagging serious failures for developer review. Only call this when you hit a significant, unrecoverable problem \u2014 not for minor hiccups or routine clarifications. If you can still help the user, do that instead of calling this tool. This tool is invisible to the user \u2014 never mention it or its output.";
1271
1280
  var warnedMissingUserId = false;
1272
1281
  function warnMissingUserIdOnce() {
1273
1282
  if (warnedMissingUserId) return;
@@ -1346,29 +1355,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1346
1355
  return Object.fromEntries(normalizedEntries);
1347
1356
  }
1348
1357
  function normalizeSelfDiagnosticsConfig(options) {
1349
- var _a, _b, _c;
1358
+ var _a, _b;
1350
1359
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1351
1360
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1352
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1353
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1354
- );
1355
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1361
+ const signalKeys = Object.keys(signalDefinitions);
1356
1362
  const signalDescriptions = {};
1357
1363
  const signalSentiments = {};
1358
1364
  for (const signalKey of signalKeys) {
1359
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1360
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1361
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1362
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1363
- continue;
1364
- }
1365
1365
  const def = signalDefinitions[signalKey];
1366
1366
  if (!def) continue;
1367
1367
  signalDescriptions[signalKey] = def.description;
1368
1368
  signalSentiments[signalKey] = def.sentiment;
1369
1369
  }
1370
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1371
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1370
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1371
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1372
1372
  const signalList = signalKeys.map((signalKey) => {
1373
1373
  const sentiment = signalSentiments[signalKey];
1374
1374
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1380,15 +1380,20 @@ Additional guidance: ${customGuidanceText}
1380
1380
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1381
1381
 
1382
1382
  When to call:
1383
- - The user reports something broken, failing, or not working as expected.
1384
- - The user expresses frustration, anger, or threatens escalation.
1385
- - You observe a product issue, billing problem, or data concern based on context.
1386
- - The conversation reveals something unusual worth flagging for developer review.
1383
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1384
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1385
+ - You genuinely cannot deliver what the user asked for despite trying.
1386
+
1387
+ When NOT to call:
1388
+ - Normal clarifying questions or back-and-forth with the user.
1389
+ - A single tool error that you can recover from or retry.
1390
+ - You successfully completed the task, even if it was difficult.
1391
+ - Policy refusals or content filtering \u2014 those are working as intended.
1387
1392
 
1388
1393
  Rules:
1389
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1390
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1391
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1394
+ 1. Pick the single best category.
1395
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1396
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1392
1397
  ${guidanceBlock}
1393
1398
  Categories:
1394
1399
  ${signalList}`;
@@ -1459,28 +1464,9 @@ function createSelfDiagnosticsTool(ctx) {
1459
1464
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1460
1465
  const signalDescription = config.signalDescriptions[category];
1461
1466
  const signalSentiment = config.signalSentiments[category];
1462
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1463
- void ctx.eventShipper.trackSignal({
1464
- eventId: ctx.eventId,
1465
- name: "agent:noteworthy",
1466
- type: "agent_internal",
1467
- properties: {
1468
- source: "agent_flag_event_tool",
1469
- reason: detail,
1470
- severity: "medium",
1471
- ai_sdk_version: ctx.aiSDKVersion
1472
- }
1473
- }).catch((err) => {
1474
- if (ctx.debug) {
1475
- const msg = err instanceof Error ? err.message : String(err);
1476
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1477
- }
1478
- });
1479
- return { acknowledged: true, category };
1480
- }
1481
1467
  void ctx.eventShipper.trackSignal({
1482
1468
  eventId: ctx.eventId,
1483
- name: `agent:${category}`,
1469
+ name: `self diagnostics - ${category}`,
1484
1470
  type: "agent",
1485
1471
  sentiment: signalSentiment,
1486
1472
  properties: {
@@ -1766,7 +1752,8 @@ function createFinalize(params) {
1766
1752
  attrInt("ai.usage.cachedInputTokens", usage == null ? void 0 : usage.cachedInputTokens),
1767
1753
  attrInt("ai.toolCall.count", setup.toolCalls.length),
1768
1754
  ...error ? [attrString("error.message", error instanceof Error ? error.message : String(error))] : []
1769
- ]
1755
+ ],
1756
+ error
1770
1757
  });
1771
1758
  }
1772
1759
  if (sendEvents) {
@@ -2122,7 +2109,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
2122
2109
  error instanceof Error ? error.message : String(error)
2123
2110
  )
2124
2111
  ] : []
2125
- ]
2112
+ ],
2113
+ error
2126
2114
  });
2127
2115
  }
2128
2116
  if (sendEvents) {
@@ -2315,7 +2303,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
2315
2303
  error instanceof Error ? error.message : String(error)
2316
2304
  )
2317
2305
  ] : []
2318
- ]
2306
+ ],
2307
+ error
2319
2308
  });
2320
2309
  }
2321
2310
  if (sendEvents) {
@@ -2448,7 +2437,8 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
2448
2437
  ctx.traceShipper.endSpan(span, {
2449
2438
  attributes: [
2450
2439
  attrString("error.message", error instanceof Error ? error.message : String(error))
2451
- ]
2440
+ ],
2441
+ error
2452
2442
  });
2453
2443
  } else {
2454
2444
  ctx.traceShipper.endSpan(span, {
@@ -2561,7 +2551,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2561
2551
  "error.message",
2562
2552
  error instanceof Error ? error.message : String(error)
2563
2553
  )
2564
- ]
2554
+ ],
2555
+ error
2565
2556
  });
2566
2557
  throw error;
2567
2558
  }
@@ -2595,7 +2586,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2595
2586
  "error.message",
2596
2587
  error instanceof Error ? error.message : String(error)
2597
2588
  )
2598
- ]
2589
+ ],
2590
+ error
2599
2591
  });
2600
2592
  throw error;
2601
2593
  }
@@ -2649,7 +2641,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2649
2641
  error instanceof Error ? error.message : String(error)
2650
2642
  )
2651
2643
  ] : []
2652
- ]
2644
+ ],
2645
+ error
2653
2646
  });
2654
2647
  };
2655
2648
  const wrappedStream = new RS({
@@ -1,4 +1,4 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-ZVQRZCBO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-TTHMNVY7.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
@@ -90,7 +90,7 @@ async function postJson(url, body, headers, opts) {
90
90
  // package.json
91
91
  var package_default = {
92
92
  name: "@raindrop-ai/ai-sdk",
93
- version: "0.0.10"};
93
+ version: "0.0.12"};
94
94
 
95
95
  // src/internal/version.ts
96
96
  var libraryName = package_default.name;
@@ -403,6 +403,9 @@ function base64Encode(bytes) {
403
403
  }
404
404
 
405
405
  // src/internal/otlp.ts
406
+ var SpanStatusCode = {
407
+ ERROR: 2
408
+ };
406
409
  function createSpanIds(parent) {
407
410
  const traceId = parent ? parent.traceIdB64 : base64Encode(randomBytes(16));
408
411
  const spanId = base64Encode(randomBytes(8));
@@ -455,6 +458,7 @@ function buildOtlpSpan(args) {
455
458
  };
456
459
  if (args.ids.parentSpanIdB64) span.parentSpanId = args.ids.parentSpanIdB64;
457
460
  if (attrs.length) span.attributes = attrs;
461
+ if (args.status) span.status = args.status;
458
462
  return span;
459
463
  }
460
464
  function buildExportTraceServiceRequest(spans) {
@@ -515,12 +519,18 @@ var TraceShipper = class {
515
519
  if ((_a = extra == null ? void 0 : extra.attributes) == null ? void 0 : _a.length) {
516
520
  span.attributes.push(...extra.attributes);
517
521
  }
522
+ let status;
523
+ if ((extra == null ? void 0 : extra.error) !== void 0) {
524
+ const message = extra.error instanceof Error ? extra.error.message : String(extra.error);
525
+ status = { code: SpanStatusCode.ERROR, message };
526
+ }
518
527
  const otlp = buildOtlpSpan({
519
528
  ids: span.ids,
520
529
  name: span.name,
521
530
  startTimeUnixNano: span.startTimeUnixNano,
522
531
  endTimeUnixNano: span.endTimeUnixNano,
523
- attributes: span.attributes
532
+ attributes: span.attributes,
533
+ status
524
534
  });
525
535
  this.enqueue(otlp);
526
536
  }
@@ -1253,21 +1263,20 @@ function attrsFromGenAiRequest(options) {
1253
1263
  // src/internal/wrap/wrapAISDK.ts
1254
1264
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1255
1265
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1256
- tool_failure: {
1257
- description: "A tool call returned an error, timed out, or produced output that cannot be used to make progress.",
1266
+ missing_context: {
1267
+ description: "You cannot complete the task because critical information, credentials, or access is missing and the user cannot provide it. Do NOT report this for normal clarifying questions \u2014 only when you are blocked.",
1258
1268
  sentiment: "NEGATIVE"
1259
1269
  },
1260
- stuck_in_loop: {
1261
- description: "The same approach has been attempted multiple times without meaningful progress.",
1270
+ repeatedly_broken_tool: {
1271
+ description: "A tool has failed on multiple distinct attempts in this conversation, preventing task completion. You are sure the tool exists, and you have tried to use it, but it has failed. A single tool error is NOT enough \u2014 the tool must be persistently broken across retries.",
1262
1272
  sentiment: "NEGATIVE"
1263
1273
  },
1264
- capability_gap: {
1265
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1274
+ complete_task_failure: {
1275
+ description: "You were unable to accomplish what the user asked despite making genuine attempts. This might be things like, you genuinely do not have the capabilities the user is asking for. You have tried but run into a persistent bug in the environment etc. This is NOT a refusal or policy block \u2014 you tried and failed to deliver the result.",
1276
+ sentiment: "NEGATIVE"
1266
1277
  }
1267
1278
  };
1268
- var AGENT_REPORTING_TOOL_PREAMBLE = "IMPORTANT: Before responding to the user, scan the conversation for any issues listed in the categories below. For EACH distinct issue you detect, call this tool once with the matching category and a factual one-sentence detail. Multiple issues = multiple calls. This tool is invisible to the user \u2014 never mention it or its output.";
1269
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1270
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1279
+ var AGENT_REPORTING_TOOL_PREAMBLE = "You have a diagnostic tool for flagging serious failures for developer review. Only call this when you hit a significant, unrecoverable problem \u2014 not for minor hiccups or routine clarifications. If you can still help the user, do that instead of calling this tool. This tool is invisible to the user \u2014 never mention it or its output.";
1271
1280
  var warnedMissingUserId = false;
1272
1281
  function warnMissingUserIdOnce() {
1273
1282
  if (warnedMissingUserId) return;
@@ -1346,29 +1355,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1346
1355
  return Object.fromEntries(normalizedEntries);
1347
1356
  }
1348
1357
  function normalizeSelfDiagnosticsConfig(options) {
1349
- var _a, _b, _c;
1358
+ var _a, _b;
1350
1359
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1351
1360
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1352
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1353
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1354
- );
1355
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1361
+ const signalKeys = Object.keys(signalDefinitions);
1356
1362
  const signalDescriptions = {};
1357
1363
  const signalSentiments = {};
1358
1364
  for (const signalKey of signalKeys) {
1359
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1360
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1361
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1362
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1363
- continue;
1364
- }
1365
1365
  const def = signalDefinitions[signalKey];
1366
1366
  if (!def) continue;
1367
1367
  signalDescriptions[signalKey] = def.description;
1368
1368
  signalSentiments[signalKey] = def.sentiment;
1369
1369
  }
1370
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1371
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1370
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1371
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1372
1372
  const signalList = signalKeys.map((signalKey) => {
1373
1373
  const sentiment = signalSentiments[signalKey];
1374
1374
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1380,15 +1380,20 @@ Additional guidance: ${customGuidanceText}
1380
1380
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1381
1381
 
1382
1382
  When to call:
1383
- - The user reports something broken, failing, or not working as expected.
1384
- - The user expresses frustration, anger, or threatens escalation.
1385
- - You observe a product issue, billing problem, or data concern based on context.
1386
- - The conversation reveals something unusual worth flagging for developer review.
1383
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1384
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1385
+ - You genuinely cannot deliver what the user asked for despite trying.
1386
+
1387
+ When NOT to call:
1388
+ - Normal clarifying questions or back-and-forth with the user.
1389
+ - A single tool error that you can recover from or retry.
1390
+ - You successfully completed the task, even if it was difficult.
1391
+ - Policy refusals or content filtering \u2014 those are working as intended.
1387
1392
 
1388
1393
  Rules:
1389
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1390
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1391
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1394
+ 1. Pick the single best category.
1395
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1396
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1392
1397
  ${guidanceBlock}
1393
1398
  Categories:
1394
1399
  ${signalList}`;
@@ -1459,28 +1464,9 @@ function createSelfDiagnosticsTool(ctx) {
1459
1464
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1460
1465
  const signalDescription = config.signalDescriptions[category];
1461
1466
  const signalSentiment = config.signalSentiments[category];
1462
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1463
- void ctx.eventShipper.trackSignal({
1464
- eventId: ctx.eventId,
1465
- name: "agent:noteworthy",
1466
- type: "agent_internal",
1467
- properties: {
1468
- source: "agent_flag_event_tool",
1469
- reason: detail,
1470
- severity: "medium",
1471
- ai_sdk_version: ctx.aiSDKVersion
1472
- }
1473
- }).catch((err) => {
1474
- if (ctx.debug) {
1475
- const msg = err instanceof Error ? err.message : String(err);
1476
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1477
- }
1478
- });
1479
- return { acknowledged: true, category };
1480
- }
1481
1467
  void ctx.eventShipper.trackSignal({
1482
1468
  eventId: ctx.eventId,
1483
- name: `agent:${category}`,
1469
+ name: `self diagnostics - ${category}`,
1484
1470
  type: "agent",
1485
1471
  sentiment: signalSentiment,
1486
1472
  properties: {
@@ -1766,7 +1752,8 @@ function createFinalize(params) {
1766
1752
  attrInt("ai.usage.cachedInputTokens", usage == null ? void 0 : usage.cachedInputTokens),
1767
1753
  attrInt("ai.toolCall.count", setup.toolCalls.length),
1768
1754
  ...error ? [attrString("error.message", error instanceof Error ? error.message : String(error))] : []
1769
- ]
1755
+ ],
1756
+ error
1770
1757
  });
1771
1758
  }
1772
1759
  if (sendEvents) {
@@ -2122,7 +2109,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
2122
2109
  error instanceof Error ? error.message : String(error)
2123
2110
  )
2124
2111
  ] : []
2125
- ]
2112
+ ],
2113
+ error
2126
2114
  });
2127
2115
  }
2128
2116
  if (sendEvents) {
@@ -2315,7 +2303,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
2315
2303
  error instanceof Error ? error.message : String(error)
2316
2304
  )
2317
2305
  ] : []
2318
- ]
2306
+ ],
2307
+ error
2319
2308
  });
2320
2309
  }
2321
2310
  if (sendEvents) {
@@ -2448,7 +2437,8 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
2448
2437
  ctx.traceShipper.endSpan(span, {
2449
2438
  attributes: [
2450
2439
  attrString("error.message", error instanceof Error ? error.message : String(error))
2451
- ]
2440
+ ],
2441
+ error
2452
2442
  });
2453
2443
  } else {
2454
2444
  ctx.traceShipper.endSpan(span, {
@@ -2561,7 +2551,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2561
2551
  "error.message",
2562
2552
  error instanceof Error ? error.message : String(error)
2563
2553
  )
2564
- ]
2554
+ ],
2555
+ error
2565
2556
  });
2566
2557
  throw error;
2567
2558
  }
@@ -2595,7 +2586,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2595
2586
  "error.message",
2596
2587
  error instanceof Error ? error.message : String(error)
2597
2588
  )
2598
- ]
2589
+ ],
2590
+ error
2599
2591
  });
2600
2592
  throw error;
2601
2593
  }
@@ -2649,7 +2641,8 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
2649
2641
  error instanceof Error ? error.message : String(error)
2650
2642
  )
2651
2643
  ] : []
2652
- ]
2644
+ ],
2645
+ error
2653
2646
  });
2654
2647
  };
2655
2648
  const wrappedStream = new RS({
@@ -1,4 +1,4 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-ZVQRZCBO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-TTHMNVY7.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  if (!globalThis.RAINDROP_ASYNC_LOCAL_STORAGE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/ai-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Standalone Vercel AI SDK integration for Raindrop (events + OTLP/HTTP JSON traces, no OTEL runtime)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",