@raindrop-ai/ai-sdk 0.0.11 → 0.0.13

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.11"};
87
+ version: "0.0.13"};
88
88
 
89
89
  // src/internal/version.ts
90
90
  var libraryName = package_default.name;
@@ -1257,21 +1257,24 @@ function attrsFromGenAiRequest(options) {
1257
1257
  // src/internal/wrap/wrapAISDK.ts
1258
1258
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1259
1259
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1260
- tool_failure: {
1261
- 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.",
1262
1262
  sentiment: "NEGATIVE"
1263
1263
  },
1264
- stuck_in_loop: {
1265
- 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.",
1266
1266
  sentiment: "NEGATIVE"
1267
1267
  },
1268
1268
  capability_gap: {
1269
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1269
+ description: "The task requires a tool, permission, or capability that you do not have. For example, the user asks you to perform an action but no suitable tool exists, or you lack the necessary access. Do NOT report this if you simply need more information from the user \u2014 only when the gap is in your own capabilities.",
1270
+ sentiment: "NEGATIVE"
1271
+ },
1272
+ complete_task_failure: {
1273
+ 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.",
1274
+ sentiment: "NEGATIVE"
1270
1275
  }
1271
1276
  };
1272
- 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.";
1273
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1274
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1277
+ 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.";
1275
1278
  var warnedMissingUserId = false;
1276
1279
  function warnMissingUserIdOnce() {
1277
1280
  if (warnedMissingUserId) return;
@@ -1350,29 +1353,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1350
1353
  return Object.fromEntries(normalizedEntries);
1351
1354
  }
1352
1355
  function normalizeSelfDiagnosticsConfig(options) {
1353
- var _a, _b, _c;
1356
+ var _a, _b;
1354
1357
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1355
1358
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1356
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1357
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1358
- );
1359
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1359
+ const signalKeys = Object.keys(signalDefinitions);
1360
1360
  const signalDescriptions = {};
1361
1361
  const signalSentiments = {};
1362
1362
  for (const signalKey of signalKeys) {
1363
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1364
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1365
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1366
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1367
- continue;
1368
- }
1369
1363
  const def = signalDefinitions[signalKey];
1370
1364
  if (!def) continue;
1371
1365
  signalDescriptions[signalKey] = def.description;
1372
1366
  signalSentiments[signalKey] = def.sentiment;
1373
1367
  }
1374
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1375
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1368
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1369
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1376
1370
  const signalList = signalKeys.map((signalKey) => {
1377
1371
  const sentiment = signalSentiments[signalKey];
1378
1372
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1384,15 +1378,21 @@ Additional guidance: ${customGuidanceText}
1384
1378
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1385
1379
 
1386
1380
  When to call:
1387
- - The user reports something broken, failing, or not working as expected.
1388
- - The user expresses frustration, anger, or threatens escalation.
1389
- - You observe a product issue, billing problem, or data concern based on context.
1390
- - The conversation reveals something unusual worth flagging for developer review.
1381
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1382
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1383
+ - The task requires a tool, permission, or capability you do not have.
1384
+ - You genuinely cannot deliver what the user asked for despite trying.
1385
+
1386
+ When NOT to call:
1387
+ - Normal clarifying questions or back-and-forth with the user.
1388
+ - A single tool error that you can recover from or retry.
1389
+ - You successfully completed the task, even if it was difficult.
1390
+ - Policy refusals or content filtering \u2014 those are working as intended.
1391
1391
 
1392
1392
  Rules:
1393
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1394
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1395
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1393
+ 1. Pick the single best category.
1394
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1395
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1396
1396
  ${guidanceBlock}
1397
1397
  Categories:
1398
1398
  ${signalList}`;
@@ -1463,28 +1463,9 @@ function createSelfDiagnosticsTool(ctx) {
1463
1463
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1464
1464
  const signalDescription = config.signalDescriptions[category];
1465
1465
  const signalSentiment = config.signalSentiments[category];
1466
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1467
- void ctx.eventShipper.trackSignal({
1468
- eventId: ctx.eventId,
1469
- name: "agent:noteworthy",
1470
- type: "agent_internal",
1471
- properties: {
1472
- source: "agent_flag_event_tool",
1473
- reason: detail,
1474
- severity: "medium",
1475
- ai_sdk_version: ctx.aiSDKVersion
1476
- }
1477
- }).catch((err) => {
1478
- if (ctx.debug) {
1479
- const msg = err instanceof Error ? err.message : String(err);
1480
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1481
- }
1482
- });
1483
- return { acknowledged: true, category };
1484
- }
1485
1466
  void ctx.eventShipper.trackSignal({
1486
1467
  eventId: ctx.eventId,
1487
- name: `agent:${category}`,
1468
+ name: `self diagnostics - ${category}`,
1488
1469
  type: "agent",
1489
1470
  sentiment: signalSentiment,
1490
1471
  properties: {
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.11"};
89
+ version: "0.0.13"};
90
90
 
91
91
  // src/internal/version.ts
92
92
  var libraryName = package_default.name;
@@ -1259,21 +1259,24 @@ function attrsFromGenAiRequest(options) {
1259
1259
  // src/internal/wrap/wrapAISDK.ts
1260
1260
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1261
1261
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1262
- tool_failure: {
1263
- 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.",
1264
1264
  sentiment: "NEGATIVE"
1265
1265
  },
1266
- stuck_in_loop: {
1267
- 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.",
1268
1268
  sentiment: "NEGATIVE"
1269
1269
  },
1270
1270
  capability_gap: {
1271
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1271
+ description: "The task requires a tool, permission, or capability that you do not have. For example, the user asks you to perform an action but no suitable tool exists, or you lack the necessary access. Do NOT report this if you simply need more information from the user \u2014 only when the gap is in your own capabilities.",
1272
+ sentiment: "NEGATIVE"
1273
+ },
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"
1272
1277
  }
1273
1278
  };
1274
- 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.";
1275
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1276
- 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.";
1277
1280
  var warnedMissingUserId = false;
1278
1281
  function warnMissingUserIdOnce() {
1279
1282
  if (warnedMissingUserId) return;
@@ -1352,29 +1355,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1352
1355
  return Object.fromEntries(normalizedEntries);
1353
1356
  }
1354
1357
  function normalizeSelfDiagnosticsConfig(options) {
1355
- var _a, _b, _c;
1358
+ var _a, _b;
1356
1359
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1357
1360
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1358
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1359
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1360
- );
1361
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1361
+ const signalKeys = Object.keys(signalDefinitions);
1362
1362
  const signalDescriptions = {};
1363
1363
  const signalSentiments = {};
1364
1364
  for (const signalKey of signalKeys) {
1365
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1366
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1367
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1368
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1369
- continue;
1370
- }
1371
1365
  const def = signalDefinitions[signalKey];
1372
1366
  if (!def) continue;
1373
1367
  signalDescriptions[signalKey] = def.description;
1374
1368
  signalSentiments[signalKey] = def.sentiment;
1375
1369
  }
1376
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1377
- 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;
1378
1372
  const signalList = signalKeys.map((signalKey) => {
1379
1373
  const sentiment = signalSentiments[signalKey];
1380
1374
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1386,15 +1380,21 @@ Additional guidance: ${customGuidanceText}
1386
1380
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1387
1381
 
1388
1382
  When to call:
1389
- - The user reports something broken, failing, or not working as expected.
1390
- - The user expresses frustration, anger, or threatens escalation.
1391
- - You observe a product issue, billing problem, or data concern based on context.
1392
- - 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
+ - The task requires a tool, permission, or capability you do not have.
1386
+ - You genuinely cannot deliver what the user asked for despite trying.
1387
+
1388
+ When NOT to call:
1389
+ - Normal clarifying questions or back-and-forth with the user.
1390
+ - A single tool error that you can recover from or retry.
1391
+ - You successfully completed the task, even if it was difficult.
1392
+ - Policy refusals or content filtering \u2014 those are working as intended.
1393
1393
 
1394
1394
  Rules:
1395
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1396
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1397
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1395
+ 1. Pick the single best category.
1396
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1397
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1398
1398
  ${guidanceBlock}
1399
1399
  Categories:
1400
1400
  ${signalList}`;
@@ -1465,28 +1465,9 @@ function createSelfDiagnosticsTool(ctx) {
1465
1465
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1466
1466
  const signalDescription = config.signalDescriptions[category];
1467
1467
  const signalSentiment = config.signalSentiments[category];
1468
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1469
- void ctx.eventShipper.trackSignal({
1470
- eventId: ctx.eventId,
1471
- name: "agent:noteworthy",
1472
- type: "agent_internal",
1473
- properties: {
1474
- source: "agent_flag_event_tool",
1475
- reason: detail,
1476
- severity: "medium",
1477
- ai_sdk_version: ctx.aiSDKVersion
1478
- }
1479
- }).catch((err) => {
1480
- if (ctx.debug) {
1481
- const msg = err instanceof Error ? err.message : String(err);
1482
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1483
- }
1484
- });
1485
- return { acknowledged: true, category };
1486
- }
1487
1468
  void ctx.eventShipper.trackSignal({
1488
1469
  eventId: ctx.eventId,
1489
- name: `agent:${category}`,
1470
+ name: `self diagnostics - ${category}`,
1490
1471
  type: "agent",
1491
1472
  sentiment: signalSentiment,
1492
1473
  properties: {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-MUDB4FLO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-BQPXVMAV.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.11"};
93
+ version: "0.0.13"};
94
94
 
95
95
  // src/internal/version.ts
96
96
  var libraryName = package_default.name;
@@ -1263,21 +1263,24 @@ function attrsFromGenAiRequest(options) {
1263
1263
  // src/internal/wrap/wrapAISDK.ts
1264
1264
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1265
1265
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1266
- tool_failure: {
1267
- 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.",
1268
1268
  sentiment: "NEGATIVE"
1269
1269
  },
1270
- stuck_in_loop: {
1271
- 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.",
1272
1272
  sentiment: "NEGATIVE"
1273
1273
  },
1274
1274
  capability_gap: {
1275
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1275
+ description: "The task requires a tool, permission, or capability that you do not have. For example, the user asks you to perform an action but no suitable tool exists, or you lack the necessary access. Do NOT report this if you simply need more information from the user \u2014 only when the gap is in your own capabilities.",
1276
+ sentiment: "NEGATIVE"
1277
+ },
1278
+ complete_task_failure: {
1279
+ 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.",
1280
+ sentiment: "NEGATIVE"
1276
1281
  }
1277
1282
  };
1278
- 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.";
1279
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1280
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1283
+ 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.";
1281
1284
  var warnedMissingUserId = false;
1282
1285
  function warnMissingUserIdOnce() {
1283
1286
  if (warnedMissingUserId) return;
@@ -1356,29 +1359,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1356
1359
  return Object.fromEntries(normalizedEntries);
1357
1360
  }
1358
1361
  function normalizeSelfDiagnosticsConfig(options) {
1359
- var _a, _b, _c;
1362
+ var _a, _b;
1360
1363
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1361
1364
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1362
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1363
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1364
- );
1365
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1365
+ const signalKeys = Object.keys(signalDefinitions);
1366
1366
  const signalDescriptions = {};
1367
1367
  const signalSentiments = {};
1368
1368
  for (const signalKey of signalKeys) {
1369
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1370
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1371
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1372
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1373
- continue;
1374
- }
1375
1369
  const def = signalDefinitions[signalKey];
1376
1370
  if (!def) continue;
1377
1371
  signalDescriptions[signalKey] = def.description;
1378
1372
  signalSentiments[signalKey] = def.sentiment;
1379
1373
  }
1380
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1381
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1374
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1375
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1382
1376
  const signalList = signalKeys.map((signalKey) => {
1383
1377
  const sentiment = signalSentiments[signalKey];
1384
1378
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1390,15 +1384,21 @@ Additional guidance: ${customGuidanceText}
1390
1384
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1391
1385
 
1392
1386
  When to call:
1393
- - The user reports something broken, failing, or not working as expected.
1394
- - The user expresses frustration, anger, or threatens escalation.
1395
- - You observe a product issue, billing problem, or data concern based on context.
1396
- - The conversation reveals something unusual worth flagging for developer review.
1387
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1388
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1389
+ - The task requires a tool, permission, or capability you do not have.
1390
+ - You genuinely cannot deliver what the user asked for despite trying.
1391
+
1392
+ When NOT to call:
1393
+ - Normal clarifying questions or back-and-forth with the user.
1394
+ - A single tool error that you can recover from or retry.
1395
+ - You successfully completed the task, even if it was difficult.
1396
+ - Policy refusals or content filtering \u2014 those are working as intended.
1397
1397
 
1398
1398
  Rules:
1399
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1400
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1401
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1399
+ 1. Pick the single best category.
1400
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1401
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1402
1402
  ${guidanceBlock}
1403
1403
  Categories:
1404
1404
  ${signalList}`;
@@ -1469,28 +1469,9 @@ function createSelfDiagnosticsTool(ctx) {
1469
1469
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1470
1470
  const signalDescription = config.signalDescriptions[category];
1471
1471
  const signalSentiment = config.signalSentiments[category];
1472
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1473
- void ctx.eventShipper.trackSignal({
1474
- eventId: ctx.eventId,
1475
- name: "agent:noteworthy",
1476
- type: "agent_internal",
1477
- properties: {
1478
- source: "agent_flag_event_tool",
1479
- reason: detail,
1480
- severity: "medium",
1481
- ai_sdk_version: ctx.aiSDKVersion
1482
- }
1483
- }).catch((err) => {
1484
- if (ctx.debug) {
1485
- const msg = err instanceof Error ? err.message : String(err);
1486
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1487
- }
1488
- });
1489
- return { acknowledged: true, category };
1490
- }
1491
1472
  void ctx.eventShipper.trackSignal({
1492
1473
  eventId: ctx.eventId,
1493
- name: `agent:${category}`,
1474
+ name: `self diagnostics - ${category}`,
1494
1475
  type: "agent",
1495
1476
  sentiment: signalSentiment,
1496
1477
  properties: {
@@ -1,4 +1,4 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-MUDB4FLO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-BQPXVMAV.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.11"};
93
+ version: "0.0.13"};
94
94
 
95
95
  // src/internal/version.ts
96
96
  var libraryName = package_default.name;
@@ -1263,21 +1263,24 @@ function attrsFromGenAiRequest(options) {
1263
1263
  // src/internal/wrap/wrapAISDK.ts
1264
1264
  var AGENT_REPORTING_TOOL_NAME_DEFAULT = "__raindrop_report";
1265
1265
  var AGENT_REPORTING_SIGNALS_DEFAULT = {
1266
- tool_failure: {
1267
- 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.",
1268
1268
  sentiment: "NEGATIVE"
1269
1269
  },
1270
- stuck_in_loop: {
1271
- 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.",
1272
1272
  sentiment: "NEGATIVE"
1273
1273
  },
1274
1274
  capability_gap: {
1275
- description: "The task requires a tool, permission, or capability that is not available to the agent."
1275
+ description: "The task requires a tool, permission, or capability that you do not have. For example, the user asks you to perform an action but no suitable tool exists, or you lack the necessary access. Do NOT report this if you simply need more information from the user \u2014 only when the gap is in your own capabilities.",
1276
+ sentiment: "NEGATIVE"
1277
+ },
1278
+ complete_task_failure: {
1279
+ 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.",
1280
+ sentiment: "NEGATIVE"
1276
1281
  }
1277
1282
  };
1278
- 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.";
1279
- var AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY = "noteworthy";
1280
- var AGENT_REPORTING_NOTEWORTHY_DESCRIPTION = "Only when no specific category applies: flag that this turn is noteworthy for developer review.";
1283
+ 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.";
1281
1284
  var warnedMissingUserId = false;
1282
1285
  function warnMissingUserIdOnce() {
1283
1286
  if (warnedMissingUserId) return;
@@ -1356,29 +1359,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
1356
1359
  return Object.fromEntries(normalizedEntries);
1357
1360
  }
1358
1361
  function normalizeSelfDiagnosticsConfig(options) {
1359
- var _a, _b, _c;
1362
+ var _a, _b;
1360
1363
  if (!(options == null ? void 0 : options.enabled)) return void 0;
1361
1364
  const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
1362
- const configuredSignalKeys = Object.keys(signalDefinitions).filter(
1363
- (signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
1364
- );
1365
- const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1365
+ const signalKeys = Object.keys(signalDefinitions);
1366
1366
  const signalDescriptions = {};
1367
1367
  const signalSentiments = {};
1368
1368
  for (const signalKey of signalKeys) {
1369
- if (signalKey === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1370
- const noteworthyDefinition = signalDefinitions[AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
1371
- signalDescriptions[signalKey] = ((_a = noteworthyDefinition == null ? void 0 : noteworthyDefinition.description) == null ? void 0 : _a.trim()) || AGENT_REPORTING_NOTEWORTHY_DESCRIPTION;
1372
- signalSentiments[signalKey] = noteworthyDefinition == null ? void 0 : noteworthyDefinition.sentiment;
1373
- continue;
1374
- }
1375
1369
  const def = signalDefinitions[signalKey];
1376
1370
  if (!def) continue;
1377
1371
  signalDescriptions[signalKey] = def.description;
1378
1372
  signalSentiments[signalKey] = def.sentiment;
1379
1373
  }
1380
- const customGuidanceText = ((_b = options.guidance) == null ? void 0 : _b.trim()) || "";
1381
- const toolName = ((_c = options.toolName) == null ? void 0 : _c.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1374
+ const customGuidanceText = ((_a = options.guidance) == null ? void 0 : _a.trim()) || "";
1375
+ const toolName = ((_b = options.toolName) == null ? void 0 : _b.trim()) || AGENT_REPORTING_TOOL_NAME_DEFAULT;
1382
1376
  const signalList = signalKeys.map((signalKey) => {
1383
1377
  const sentiment = signalSentiments[signalKey];
1384
1378
  const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
@@ -1390,15 +1384,21 @@ Additional guidance: ${customGuidanceText}
1390
1384
  const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
1391
1385
 
1392
1386
  When to call:
1393
- - The user reports something broken, failing, or not working as expected.
1394
- - The user expresses frustration, anger, or threatens escalation.
1395
- - You observe a product issue, billing problem, or data concern based on context.
1396
- - The conversation reveals something unusual worth flagging for developer review.
1387
+ - You are blocked from completing the task due to missing information or access that the user cannot provide.
1388
+ - A tool is persistently failing across multiple attempts, not just a single transient error.
1389
+ - The task requires a tool, permission, or capability you do not have.
1390
+ - You genuinely cannot deliver what the user asked for despite trying.
1391
+
1392
+ When NOT to call:
1393
+ - Normal clarifying questions or back-and-forth with the user.
1394
+ - A single tool error that you can recover from or retry.
1395
+ - You successfully completed the task, even if it was difficult.
1396
+ - Policy refusals or content filtering \u2014 those are working as intended.
1397
1397
 
1398
1398
  Rules:
1399
- 1. Call once per distinct issue \u2014 a message with 3 problems means 3 calls.
1400
- 2. Pick the single best category per issue. Use noteworthy only when no specific category fits.
1401
- 3. Do not fabricate issues. Only report what is evident from the conversation.
1399
+ 1. Pick the single best category.
1400
+ 2. Do not fabricate issues. Only report what is evident from the conversation.
1401
+ 3. Err on the side of NOT calling this tool. When in doubt, help the user instead.
1402
1402
  ${guidanceBlock}
1403
1403
  Categories:
1404
1404
  ${signalList}`;
@@ -1469,28 +1469,9 @@ function createSelfDiagnosticsTool(ctx) {
1469
1469
  const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
1470
1470
  const signalDescription = config.signalDescriptions[category];
1471
1471
  const signalSentiment = config.signalSentiments[category];
1472
- if (category === AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY) {
1473
- void ctx.eventShipper.trackSignal({
1474
- eventId: ctx.eventId,
1475
- name: "agent:noteworthy",
1476
- type: "agent_internal",
1477
- properties: {
1478
- source: "agent_flag_event_tool",
1479
- reason: detail,
1480
- severity: "medium",
1481
- ai_sdk_version: ctx.aiSDKVersion
1482
- }
1483
- }).catch((err) => {
1484
- if (ctx.debug) {
1485
- const msg = err instanceof Error ? err.message : String(err);
1486
- console.warn(`[raindrop-ai/ai-sdk] agentFlagEvent signal dispatch failed: ${msg}`);
1487
- }
1488
- });
1489
- return { acknowledged: true, category };
1490
- }
1491
1472
  void ctx.eventShipper.trackSignal({
1492
1473
  eventId: ctx.eventId,
1493
- name: `agent:${category}`,
1474
+ name: `self diagnostics - ${category}`,
1494
1475
  type: "agent",
1495
1476
  sentiment: signalSentiment,
1496
1477
  properties: {
@@ -1,4 +1,4 @@
1
- export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-MUDB4FLO.mjs';
1
+ export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-BQPXVMAV.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.11",
3
+ "version": "0.0.13",
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",