@raindrop-ai/ai-sdk 0.0.11 → 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.
- package/dist/{chunk-MUDB4FLO.mjs → chunk-TTHMNVY7.mjs} +26 -50
- package/dist/index.js +26 -50
- package/dist/index.mjs +1 -1
- package/dist/index.node.js +26 -50
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.js +26 -50
- package/dist/index.workers.mjs +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
87
|
+
version: "0.0.12"};
|
|
88
88
|
|
|
89
89
|
// src/internal/version.ts
|
|
90
90
|
var libraryName = package_default.name;
|
|
@@ -1257,21 +1257,20 @@ 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
|
-
|
|
1261
|
-
description: "
|
|
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
|
-
|
|
1265
|
-
description: "
|
|
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
|
-
|
|
1269
|
-
description: "
|
|
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"
|
|
1270
1271
|
}
|
|
1271
1272
|
};
|
|
1272
|
-
var AGENT_REPORTING_TOOL_PREAMBLE = "
|
|
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.";
|
|
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.";
|
|
1275
1274
|
var warnedMissingUserId = false;
|
|
1276
1275
|
function warnMissingUserIdOnce() {
|
|
1277
1276
|
if (warnedMissingUserId) return;
|
|
@@ -1350,29 +1349,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
|
|
|
1350
1349
|
return Object.fromEntries(normalizedEntries);
|
|
1351
1350
|
}
|
|
1352
1351
|
function normalizeSelfDiagnosticsConfig(options) {
|
|
1353
|
-
var _a, _b
|
|
1352
|
+
var _a, _b;
|
|
1354
1353
|
if (!(options == null ? void 0 : options.enabled)) return void 0;
|
|
1355
1354
|
const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
|
|
1356
|
-
const
|
|
1357
|
-
(signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
|
|
1358
|
-
);
|
|
1359
|
-
const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
|
|
1355
|
+
const signalKeys = Object.keys(signalDefinitions);
|
|
1360
1356
|
const signalDescriptions = {};
|
|
1361
1357
|
const signalSentiments = {};
|
|
1362
1358
|
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
1359
|
const def = signalDefinitions[signalKey];
|
|
1370
1360
|
if (!def) continue;
|
|
1371
1361
|
signalDescriptions[signalKey] = def.description;
|
|
1372
1362
|
signalSentiments[signalKey] = def.sentiment;
|
|
1373
1363
|
}
|
|
1374
|
-
const customGuidanceText = ((
|
|
1375
|
-
const toolName = ((
|
|
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;
|
|
1376
1366
|
const signalList = signalKeys.map((signalKey) => {
|
|
1377
1367
|
const sentiment = signalSentiments[signalKey];
|
|
1378
1368
|
const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
|
|
@@ -1384,15 +1374,20 @@ Additional guidance: ${customGuidanceText}
|
|
|
1384
1374
|
const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
|
|
1385
1375
|
|
|
1386
1376
|
When to call:
|
|
1387
|
-
-
|
|
1388
|
-
-
|
|
1389
|
-
- You
|
|
1390
|
-
|
|
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.
|
|
1391
1386
|
|
|
1392
1387
|
Rules:
|
|
1393
|
-
1.
|
|
1394
|
-
2.
|
|
1395
|
-
3.
|
|
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.
|
|
1396
1391
|
${guidanceBlock}
|
|
1397
1392
|
Categories:
|
|
1398
1393
|
${signalList}`;
|
|
@@ -1463,28 +1458,9 @@ function createSelfDiagnosticsTool(ctx) {
|
|
|
1463
1458
|
const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
|
|
1464
1459
|
const signalDescription = config.signalDescriptions[category];
|
|
1465
1460
|
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
1461
|
void ctx.eventShipper.trackSignal({
|
|
1486
1462
|
eventId: ctx.eventId,
|
|
1487
|
-
name: `
|
|
1463
|
+
name: `self diagnostics - ${category}`,
|
|
1488
1464
|
type: "agent",
|
|
1489
1465
|
sentiment: signalSentiment,
|
|
1490
1466
|
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.
|
|
89
|
+
version: "0.0.12"};
|
|
90
90
|
|
|
91
91
|
// src/internal/version.ts
|
|
92
92
|
var libraryName = package_default.name;
|
|
@@ -1259,21 +1259,20 @@ 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
|
-
|
|
1263
|
-
description: "
|
|
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
|
-
|
|
1267
|
-
description: "
|
|
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
|
-
|
|
1271
|
-
description: "
|
|
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"
|
|
1272
1273
|
}
|
|
1273
1274
|
};
|
|
1274
|
-
var AGENT_REPORTING_TOOL_PREAMBLE = "
|
|
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.";
|
|
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.";
|
|
1277
1276
|
var warnedMissingUserId = false;
|
|
1278
1277
|
function warnMissingUserIdOnce() {
|
|
1279
1278
|
if (warnedMissingUserId) return;
|
|
@@ -1352,29 +1351,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
|
|
|
1352
1351
|
return Object.fromEntries(normalizedEntries);
|
|
1353
1352
|
}
|
|
1354
1353
|
function normalizeSelfDiagnosticsConfig(options) {
|
|
1355
|
-
var _a, _b
|
|
1354
|
+
var _a, _b;
|
|
1356
1355
|
if (!(options == null ? void 0 : options.enabled)) return void 0;
|
|
1357
1356
|
const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
|
|
1358
|
-
const
|
|
1359
|
-
(signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
|
|
1360
|
-
);
|
|
1361
|
-
const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
|
|
1357
|
+
const signalKeys = Object.keys(signalDefinitions);
|
|
1362
1358
|
const signalDescriptions = {};
|
|
1363
1359
|
const signalSentiments = {};
|
|
1364
1360
|
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
1361
|
const def = signalDefinitions[signalKey];
|
|
1372
1362
|
if (!def) continue;
|
|
1373
1363
|
signalDescriptions[signalKey] = def.description;
|
|
1374
1364
|
signalSentiments[signalKey] = def.sentiment;
|
|
1375
1365
|
}
|
|
1376
|
-
const customGuidanceText = ((
|
|
1377
|
-
const toolName = ((
|
|
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;
|
|
1378
1368
|
const signalList = signalKeys.map((signalKey) => {
|
|
1379
1369
|
const sentiment = signalSentiments[signalKey];
|
|
1380
1370
|
const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
|
|
@@ -1386,15 +1376,20 @@ Additional guidance: ${customGuidanceText}
|
|
|
1386
1376
|
const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
|
|
1387
1377
|
|
|
1388
1378
|
When to call:
|
|
1389
|
-
-
|
|
1390
|
-
-
|
|
1391
|
-
- You
|
|
1392
|
-
|
|
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.
|
|
1393
1388
|
|
|
1394
1389
|
Rules:
|
|
1395
|
-
1.
|
|
1396
|
-
2.
|
|
1397
|
-
3.
|
|
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.
|
|
1398
1393
|
${guidanceBlock}
|
|
1399
1394
|
Categories:
|
|
1400
1395
|
${signalList}`;
|
|
@@ -1465,28 +1460,9 @@ function createSelfDiagnosticsTool(ctx) {
|
|
|
1465
1460
|
const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
|
|
1466
1461
|
const signalDescription = config.signalDescriptions[category];
|
|
1467
1462
|
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
1463
|
void ctx.eventShipper.trackSignal({
|
|
1488
1464
|
eventId: ctx.eventId,
|
|
1489
|
-
name: `
|
|
1465
|
+
name: `self diagnostics - ${category}`,
|
|
1490
1466
|
type: "agent",
|
|
1491
1467
|
sentiment: signalSentiment,
|
|
1492
1468
|
properties: {
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-
|
|
1
|
+
export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-TTHMNVY7.mjs';
|
package/dist/index.node.js
CHANGED
|
@@ -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.
|
|
93
|
+
version: "0.0.12"};
|
|
94
94
|
|
|
95
95
|
// src/internal/version.ts
|
|
96
96
|
var libraryName = package_default.name;
|
|
@@ -1263,21 +1263,20 @@ 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
|
-
|
|
1267
|
-
description: "
|
|
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
|
-
|
|
1271
|
-
description: "
|
|
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
|
-
|
|
1275
|
-
description: "
|
|
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"
|
|
1276
1277
|
}
|
|
1277
1278
|
};
|
|
1278
|
-
var AGENT_REPORTING_TOOL_PREAMBLE = "
|
|
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.";
|
|
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.";
|
|
1281
1280
|
var warnedMissingUserId = false;
|
|
1282
1281
|
function warnMissingUserIdOnce() {
|
|
1283
1282
|
if (warnedMissingUserId) return;
|
|
@@ -1356,29 +1355,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
|
|
|
1356
1355
|
return Object.fromEntries(normalizedEntries);
|
|
1357
1356
|
}
|
|
1358
1357
|
function normalizeSelfDiagnosticsConfig(options) {
|
|
1359
|
-
var _a, _b
|
|
1358
|
+
var _a, _b;
|
|
1360
1359
|
if (!(options == null ? void 0 : options.enabled)) return void 0;
|
|
1361
1360
|
const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
|
|
1362
|
-
const
|
|
1363
|
-
(signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
|
|
1364
|
-
);
|
|
1365
|
-
const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
|
|
1361
|
+
const signalKeys = Object.keys(signalDefinitions);
|
|
1366
1362
|
const signalDescriptions = {};
|
|
1367
1363
|
const signalSentiments = {};
|
|
1368
1364
|
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
1365
|
const def = signalDefinitions[signalKey];
|
|
1376
1366
|
if (!def) continue;
|
|
1377
1367
|
signalDescriptions[signalKey] = def.description;
|
|
1378
1368
|
signalSentiments[signalKey] = def.sentiment;
|
|
1379
1369
|
}
|
|
1380
|
-
const customGuidanceText = ((
|
|
1381
|
-
const toolName = ((
|
|
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;
|
|
1382
1372
|
const signalList = signalKeys.map((signalKey) => {
|
|
1383
1373
|
const sentiment = signalSentiments[signalKey];
|
|
1384
1374
|
const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
|
|
@@ -1390,15 +1380,20 @@ Additional guidance: ${customGuidanceText}
|
|
|
1390
1380
|
const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
|
|
1391
1381
|
|
|
1392
1382
|
When to call:
|
|
1393
|
-
-
|
|
1394
|
-
-
|
|
1395
|
-
- You
|
|
1396
|
-
|
|
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.
|
|
1397
1392
|
|
|
1398
1393
|
Rules:
|
|
1399
|
-
1.
|
|
1400
|
-
2.
|
|
1401
|
-
3.
|
|
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.
|
|
1402
1397
|
${guidanceBlock}
|
|
1403
1398
|
Categories:
|
|
1404
1399
|
${signalList}`;
|
|
@@ -1469,28 +1464,9 @@ function createSelfDiagnosticsTool(ctx) {
|
|
|
1469
1464
|
const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
|
|
1470
1465
|
const signalDescription = config.signalDescriptions[category];
|
|
1471
1466
|
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
1467
|
void ctx.eventShipper.trackSignal({
|
|
1492
1468
|
eventId: ctx.eventId,
|
|
1493
|
-
name: `
|
|
1469
|
+
name: `self diagnostics - ${category}`,
|
|
1494
1470
|
type: "agent",
|
|
1495
1471
|
sentiment: signalSentiment,
|
|
1496
1472
|
properties: {
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-
|
|
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;
|
package/dist/index.workers.js
CHANGED
|
@@ -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.
|
|
93
|
+
version: "0.0.12"};
|
|
94
94
|
|
|
95
95
|
// src/internal/version.ts
|
|
96
96
|
var libraryName = package_default.name;
|
|
@@ -1263,21 +1263,20 @@ 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
|
-
|
|
1267
|
-
description: "
|
|
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
|
-
|
|
1271
|
-
description: "
|
|
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
|
-
|
|
1275
|
-
description: "
|
|
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"
|
|
1276
1277
|
}
|
|
1277
1278
|
};
|
|
1278
|
-
var AGENT_REPORTING_TOOL_PREAMBLE = "
|
|
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.";
|
|
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.";
|
|
1281
1280
|
var warnedMissingUserId = false;
|
|
1282
1281
|
function warnMissingUserIdOnce() {
|
|
1283
1282
|
if (warnedMissingUserId) return;
|
|
@@ -1356,29 +1355,20 @@ function normalizeSelfDiagnosticsSignals(signals) {
|
|
|
1356
1355
|
return Object.fromEntries(normalizedEntries);
|
|
1357
1356
|
}
|
|
1358
1357
|
function normalizeSelfDiagnosticsConfig(options) {
|
|
1359
|
-
var _a, _b
|
|
1358
|
+
var _a, _b;
|
|
1360
1359
|
if (!(options == null ? void 0 : options.enabled)) return void 0;
|
|
1361
1360
|
const signalDefinitions = normalizeSelfDiagnosticsSignals(options.signals);
|
|
1362
|
-
const
|
|
1363
|
-
(signalKey) => signalKey !== AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY
|
|
1364
|
-
);
|
|
1365
|
-
const signalKeys = [...configuredSignalKeys, AGENT_REPORTING_NOTEWORTHY_SIGNAL_KEY];
|
|
1361
|
+
const signalKeys = Object.keys(signalDefinitions);
|
|
1366
1362
|
const signalDescriptions = {};
|
|
1367
1363
|
const signalSentiments = {};
|
|
1368
1364
|
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
1365
|
const def = signalDefinitions[signalKey];
|
|
1376
1366
|
if (!def) continue;
|
|
1377
1367
|
signalDescriptions[signalKey] = def.description;
|
|
1378
1368
|
signalSentiments[signalKey] = def.sentiment;
|
|
1379
1369
|
}
|
|
1380
|
-
const customGuidanceText = ((
|
|
1381
|
-
const toolName = ((
|
|
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;
|
|
1382
1372
|
const signalList = signalKeys.map((signalKey) => {
|
|
1383
1373
|
const sentiment = signalSentiments[signalKey];
|
|
1384
1374
|
const sentimentTag = sentiment ? ` [${sentiment.toLowerCase()}]` : "";
|
|
@@ -1390,15 +1380,20 @@ Additional guidance: ${customGuidanceText}
|
|
|
1390
1380
|
const toolDescription = `${AGENT_REPORTING_TOOL_PREAMBLE}
|
|
1391
1381
|
|
|
1392
1382
|
When to call:
|
|
1393
|
-
-
|
|
1394
|
-
-
|
|
1395
|
-
- You
|
|
1396
|
-
|
|
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.
|
|
1397
1392
|
|
|
1398
1393
|
Rules:
|
|
1399
|
-
1.
|
|
1400
|
-
2.
|
|
1401
|
-
3.
|
|
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.
|
|
1402
1397
|
${guidanceBlock}
|
|
1403
1398
|
Categories:
|
|
1404
1399
|
${signalList}`;
|
|
@@ -1469,28 +1464,9 @@ function createSelfDiagnosticsTool(ctx) {
|
|
|
1469
1464
|
const detail = typeof (input == null ? void 0 : input["detail"]) === "string" ? input["detail"].trim() : "";
|
|
1470
1465
|
const signalDescription = config.signalDescriptions[category];
|
|
1471
1466
|
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
1467
|
void ctx.eventShipper.trackSignal({
|
|
1492
1468
|
eventId: ctx.eventId,
|
|
1493
|
-
name: `
|
|
1469
|
+
name: `self diagnostics - ${category}`,
|
|
1494
1470
|
type: "agent",
|
|
1495
1471
|
sentiment: signalSentiment,
|
|
1496
1472
|
properties: {
|
package/dist/index.workers.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, getContextManager, withCurrent } from './chunk-
|
|
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