@raindrop-ai/ai-sdk 0.3.3 → 0.3.4
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/README.md +22 -0
- package/dist/{chunk-MCRACPKM.mjs → chunk-BS7SHOEE.mjs} +328 -145
- package/dist/{index-B_mpeckV.d.mts → index-DCYSGvxI.d.mts} +59 -1
- package/dist/{index-B_mpeckV.d.ts → index-DCYSGvxI.d.ts} +59 -1
- package/dist/index.browser.d.mts +59 -1
- package/dist/index.browser.d.ts +59 -1
- package/dist/index.browser.js +328 -144
- package/dist/index.browser.mjs +328 -145
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +328 -144
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.d.mts +1 -1
- package/dist/index.workers.d.ts +1 -1
- package/dist/index.workers.js +328 -144
- package/dist/index.workers.mjs +1 -1
- package/package.json +2 -2
|
@@ -64,7 +64,7 @@ function evalScopeAttributes() {
|
|
|
64
64
|
return { [EVAL_CORRELATION_ID_ATTRIBUTE]: scope.correlationId };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// ../core/dist/chunk-
|
|
67
|
+
// ../core/dist/chunk-I6TVJQEC.js
|
|
68
68
|
var STATE_KEY = /* @__PURE__ */ Symbol.for("raindrop.tracing.replayTraceRoutingState");
|
|
69
69
|
function state() {
|
|
70
70
|
const holder = globalThis;
|
|
@@ -2500,6 +2500,158 @@ var TraceShipper = class {
|
|
|
2500
2500
|
}
|
|
2501
2501
|
}
|
|
2502
2502
|
};
|
|
2503
|
+
var PROMPT_TOOLS_ATTRIBUTE = "ai.prompt.tools";
|
|
2504
|
+
function isRecord(value) {
|
|
2505
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2506
|
+
}
|
|
2507
|
+
var JSON_SCHEMA_KEYS = [
|
|
2508
|
+
"type",
|
|
2509
|
+
"properties",
|
|
2510
|
+
"$schema",
|
|
2511
|
+
"$ref",
|
|
2512
|
+
"anyOf",
|
|
2513
|
+
"oneOf",
|
|
2514
|
+
"allOf",
|
|
2515
|
+
"enum",
|
|
2516
|
+
"const",
|
|
2517
|
+
"items",
|
|
2518
|
+
"additionalProperties",
|
|
2519
|
+
"required"
|
|
2520
|
+
];
|
|
2521
|
+
function isJsonSchema(value) {
|
|
2522
|
+
if (!isRecord(value)) return false;
|
|
2523
|
+
if (typeof value["~standard"] === "object") return false;
|
|
2524
|
+
if (isRecord(value._def) || isRecord(value._zod)) return false;
|
|
2525
|
+
if (Object.keys(value).length === 0) return true;
|
|
2526
|
+
return JSON_SCHEMA_KEYS.some((key) => key in value);
|
|
2527
|
+
}
|
|
2528
|
+
function toJsonSchema(value, options) {
|
|
2529
|
+
if (value === void 0 || value === null) return void 0;
|
|
2530
|
+
if (isJsonSchema(value)) return value;
|
|
2531
|
+
if (isRecord(value) && isJsonSchema(value.jsonSchema)) return value.jsonSchema;
|
|
2532
|
+
if (isRecord(value) && isJsonSchema(value.json)) return value.json;
|
|
2533
|
+
if (options == null ? void 0 : options.schema) {
|
|
2534
|
+
try {
|
|
2535
|
+
return options.schema(value);
|
|
2536
|
+
} catch (e) {
|
|
2537
|
+
return void 0;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
return void 0;
|
|
2541
|
+
}
|
|
2542
|
+
function pickString(value) {
|
|
2543
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
2544
|
+
}
|
|
2545
|
+
function functionTool(name, description, schema, options) {
|
|
2546
|
+
const tool = { type: "function", name };
|
|
2547
|
+
const desc = pickString(description);
|
|
2548
|
+
if (desc !== void 0) tool.description = desc;
|
|
2549
|
+
const inputSchema = toJsonSchema(schema, options);
|
|
2550
|
+
if (inputSchema !== void 0) tool.inputSchema = inputSchema;
|
|
2551
|
+
return tool;
|
|
2552
|
+
}
|
|
2553
|
+
function normalizeToolDeclaration(tool, options, fallbackName) {
|
|
2554
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2555
|
+
if (!isRecord(tool)) return void 0;
|
|
2556
|
+
if (tool.type === "provider-defined" || tool.type === "provider") {
|
|
2557
|
+
const name2 = (_b = (_a = pickString(tool.name)) != null ? _a : pickString(tool.id)) != null ? _b : fallbackName;
|
|
2558
|
+
if (name2 === void 0) return void 0;
|
|
2559
|
+
const declaration = { type: "provider-defined", name: name2 };
|
|
2560
|
+
const id = pickString(tool.id);
|
|
2561
|
+
if (id !== void 0) declaration.id = id;
|
|
2562
|
+
if (isRecord(tool.args)) declaration.args = tool.args;
|
|
2563
|
+
return declaration;
|
|
2564
|
+
}
|
|
2565
|
+
if (isRecord(tool.toolSpec)) {
|
|
2566
|
+
const spec = tool.toolSpec;
|
|
2567
|
+
const name2 = (_c = pickString(spec.name)) != null ? _c : fallbackName;
|
|
2568
|
+
if (name2 === void 0) return void 0;
|
|
2569
|
+
return functionTool(name2, spec.description, spec.inputSchema, options);
|
|
2570
|
+
}
|
|
2571
|
+
if (isRecord(tool.function)) {
|
|
2572
|
+
const fn = tool.function;
|
|
2573
|
+
const name2 = (_d = pickString(fn.name)) != null ? _d : fallbackName;
|
|
2574
|
+
if (name2 === void 0) return void 0;
|
|
2575
|
+
return functionTool(name2, fn.description, (_e = fn.parameters) != null ? _e : fn.input_schema, options);
|
|
2576
|
+
}
|
|
2577
|
+
const name = (_g = (_f = pickString(tool.name)) != null ? _f : pickString(tool.id)) != null ? _g : fallbackName;
|
|
2578
|
+
if (name === void 0) return void 0;
|
|
2579
|
+
const type = pickString(tool.type);
|
|
2580
|
+
if (type !== void 0 && type !== "function" && type !== "dynamic" && type !== "custom") {
|
|
2581
|
+
if (!("input_schema" in tool) && !("inputSchema" in tool) && !("parameters" in tool)) {
|
|
2582
|
+
return { type: "provider-defined", id: type, name };
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
return functionTool(
|
|
2586
|
+
name,
|
|
2587
|
+
tool.description,
|
|
2588
|
+
(_j = (_i = (_h = tool.inputSchema) != null ? _h : tool.input_schema) != null ? _i : tool.parameters) != null ? _j : tool.schema,
|
|
2589
|
+
options
|
|
2590
|
+
);
|
|
2591
|
+
}
|
|
2592
|
+
var NOT_A_GEMINI_GROUP_KEYS = ["name", "id", "type", "function", "toolSpec", "cachePoint"];
|
|
2593
|
+
function isGeminiToolGroup(tool) {
|
|
2594
|
+
if (Array.isArray(tool.functionDeclarations)) return true;
|
|
2595
|
+
const keys = Object.keys(tool);
|
|
2596
|
+
if (keys.length === 0 || NOT_A_GEMINI_GROUP_KEYS.some((key) => key in tool)) return false;
|
|
2597
|
+
return keys.every((key) => isRecord(tool[key]));
|
|
2598
|
+
}
|
|
2599
|
+
function expandGeminiTool(tool, options) {
|
|
2600
|
+
const declarations = [];
|
|
2601
|
+
for (const [key, value] of Object.entries(tool)) {
|
|
2602
|
+
if (key === "functionDeclarations" && Array.isArray(value)) {
|
|
2603
|
+
for (const declaration of value) {
|
|
2604
|
+
const normalized = normalizeToolDeclaration(declaration, options);
|
|
2605
|
+
if (normalized) declarations.push(normalized);
|
|
2606
|
+
}
|
|
2607
|
+
} else if (isRecord(value)) {
|
|
2608
|
+
declarations.push({ type: "provider-defined", id: key, name: key, args: value });
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
return declarations;
|
|
2612
|
+
}
|
|
2613
|
+
function normalizeToolDeclarations(tools, options) {
|
|
2614
|
+
if (tools === void 0 || tools === null) return void 0;
|
|
2615
|
+
if (Array.isArray(tools)) {
|
|
2616
|
+
return tools.flatMap((tool) => {
|
|
2617
|
+
if (isRecord(tool) && isGeminiToolGroup(tool)) {
|
|
2618
|
+
return expandGeminiTool(tool, options);
|
|
2619
|
+
}
|
|
2620
|
+
const declaration = normalizeToolDeclaration(tool, options);
|
|
2621
|
+
return declaration ? [declaration] : [];
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
if (!isRecord(tools)) return void 0;
|
|
2625
|
+
return Object.entries(tools).flatMap(([key, tool]) => {
|
|
2626
|
+
const declaration = normalizeToolDeclaration(tool, options, key);
|
|
2627
|
+
return declaration ? [declaration] : [];
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
function resolvePromptTools(args) {
|
|
2631
|
+
var _a;
|
|
2632
|
+
if (args.override !== void 0) {
|
|
2633
|
+
return (_a = normalizeToolDeclarations(args.override, args.options)) != null ? _a : [];
|
|
2634
|
+
}
|
|
2635
|
+
return normalizeToolDeclarations(args.inferred, args.options);
|
|
2636
|
+
}
|
|
2637
|
+
function promptToolsAttribute(tools) {
|
|
2638
|
+
const values = promptToolsAttributeValue(tools);
|
|
2639
|
+
if (values === void 0) return void 0;
|
|
2640
|
+
return {
|
|
2641
|
+
key: PROMPT_TOOLS_ATTRIBUTE,
|
|
2642
|
+
value: { arrayValue: { values: values.map((stringValue) => ({ stringValue })) } }
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
function promptToolsAttributeValue(tools) {
|
|
2646
|
+
if (tools === void 0) return void 0;
|
|
2647
|
+
return tools.map((tool) => {
|
|
2648
|
+
try {
|
|
2649
|
+
return JSON.stringify(tool);
|
|
2650
|
+
} catch (e) {
|
|
2651
|
+
return JSON.stringify({ type: tool.type, name: tool.name });
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2503
2655
|
var resolveLocal = (sourceDirectory, detectBranch, completed) => {
|
|
2504
2656
|
const cwd = sourceDirectory ? resolve(sourceDirectory) : process.cwd();
|
|
2505
2657
|
let cancelled = false;
|
|
@@ -2798,7 +2950,7 @@ function boundedStringify(value, limit) {
|
|
|
2798
2950
|
}
|
|
2799
2951
|
|
|
2800
2952
|
// src/internal/wrap/helpers.ts
|
|
2801
|
-
function
|
|
2953
|
+
function isRecord2(value) {
|
|
2802
2954
|
return typeof value === "object" && value !== null;
|
|
2803
2955
|
}
|
|
2804
2956
|
function isFunction(value) {
|
|
@@ -2837,7 +2989,7 @@ function extractModelInfo(model) {
|
|
|
2837
2989
|
}
|
|
2838
2990
|
return { modelId: model };
|
|
2839
2991
|
}
|
|
2840
|
-
if (!
|
|
2992
|
+
if (!isRecord2(model)) return {};
|
|
2841
2993
|
const provider = typeof model["provider"] === "string" ? model["provider"] : void 0;
|
|
2842
2994
|
let modelIdRaw;
|
|
2843
2995
|
if (typeof model["modelId"] === "string") {
|
|
@@ -2858,13 +3010,13 @@ function extractModelInfo(model) {
|
|
|
2858
3010
|
return { provider, modelId: modelIdRaw };
|
|
2859
3011
|
}
|
|
2860
3012
|
function extractTextOutput(result) {
|
|
2861
|
-
if (!
|
|
3013
|
+
if (!isRecord2(result)) return void 0;
|
|
2862
3014
|
const text = result["text"];
|
|
2863
3015
|
return typeof text === "string" ? text : void 0;
|
|
2864
3016
|
}
|
|
2865
3017
|
function extractObjectOutput(result) {
|
|
2866
3018
|
var _a;
|
|
2867
|
-
if (!
|
|
3019
|
+
if (!isRecord2(result)) return void 0;
|
|
2868
3020
|
const obj = result["object"];
|
|
2869
3021
|
if (obj === void 0) return void 0;
|
|
2870
3022
|
return (_a = safeJson(obj)) != null ? _a : String(obj);
|
|
@@ -2872,24 +3024,24 @@ function extractObjectOutput(result) {
|
|
|
2872
3024
|
function isAgentClass(value) {
|
|
2873
3025
|
if (typeof value !== "function") return false;
|
|
2874
3026
|
const proto = value.prototype;
|
|
2875
|
-
if (!
|
|
3027
|
+
if (!isRecord2(proto)) return false;
|
|
2876
3028
|
return typeof proto["generate"] === "function" && typeof proto["stream"] === "function";
|
|
2877
3029
|
}
|
|
2878
3030
|
function extractModel(result) {
|
|
2879
|
-
if (!
|
|
3031
|
+
if (!isRecord2(result)) return void 0;
|
|
2880
3032
|
const model = result["model"];
|
|
2881
3033
|
if (typeof model === "string" && model.length) return model;
|
|
2882
3034
|
const response = result["response"];
|
|
2883
|
-
if (
|
|
3035
|
+
if (isRecord2(response)) {
|
|
2884
3036
|
const modelId = response["modelId"];
|
|
2885
3037
|
if (typeof modelId === "string" && modelId.length) return modelId;
|
|
2886
3038
|
}
|
|
2887
3039
|
return void 0;
|
|
2888
3040
|
}
|
|
2889
3041
|
function extractFinishReason(result) {
|
|
2890
|
-
if (!
|
|
3042
|
+
if (!isRecord2(result)) return void 0;
|
|
2891
3043
|
if (typeof result["finishReason"] === "string") return result["finishReason"];
|
|
2892
|
-
if (
|
|
3044
|
+
if (isRecord2(result["finishReason"]) && typeof result["finishReason"]["unified"] === "string") {
|
|
2893
3045
|
return result["finishReason"]["unified"];
|
|
2894
3046
|
}
|
|
2895
3047
|
return void 0;
|
|
@@ -2933,7 +3085,7 @@ function attachmentMediaType(part) {
|
|
|
2933
3085
|
if (typeof part["mediaType"] === "string") return part["mediaType"];
|
|
2934
3086
|
if (typeof part["mimeType"] === "string") return part["mimeType"];
|
|
2935
3087
|
const file = part["file"];
|
|
2936
|
-
if (
|
|
3088
|
+
if (isRecord2(file)) {
|
|
2937
3089
|
if (typeof file["mediaType"] === "string") return file["mediaType"];
|
|
2938
3090
|
if (typeof file["mimeType"] === "string") return file["mimeType"];
|
|
2939
3091
|
}
|
|
@@ -2943,7 +3095,7 @@ function attachmentName(part) {
|
|
|
2943
3095
|
if (typeof part["filename"] === "string") return part["filename"];
|
|
2944
3096
|
if (typeof part["name"] === "string") return part["name"];
|
|
2945
3097
|
const file = part["file"];
|
|
2946
|
-
if (
|
|
3098
|
+
if (isRecord2(file)) {
|
|
2947
3099
|
if (typeof file["filename"] === "string") return file["filename"];
|
|
2948
3100
|
if (typeof file["name"] === "string") return file["name"];
|
|
2949
3101
|
}
|
|
@@ -2952,7 +3104,7 @@ function attachmentName(part) {
|
|
|
2952
3104
|
function attachmentData(part) {
|
|
2953
3105
|
if ("data" in part) return part["data"];
|
|
2954
3106
|
const file = part["file"];
|
|
2955
|
-
if (
|
|
3107
|
+
if (isRecord2(file)) {
|
|
2956
3108
|
if ("file_data" in file) return file["file_data"];
|
|
2957
3109
|
if ("data" in file) return file["data"];
|
|
2958
3110
|
}
|
|
@@ -2970,7 +3122,7 @@ function contentPartToAttachment(part, role) {
|
|
|
2970
3122
|
}
|
|
2971
3123
|
if (partType === "image_url") {
|
|
2972
3124
|
const imageUrlPart = part["image_url"];
|
|
2973
|
-
const imageUrlValue =
|
|
3125
|
+
const imageUrlValue = isRecord2(imageUrlPart) ? imageUrlPart["url"] : imageUrlPart;
|
|
2974
3126
|
const value = asDataUrl(imageUrlValue, "image/png");
|
|
2975
3127
|
if (!value) return void 0;
|
|
2976
3128
|
return { type: "image", role, value };
|
|
@@ -2990,7 +3142,7 @@ function attachmentsFromContent(content, role) {
|
|
|
2990
3142
|
if (!Array.isArray(content)) return void 0;
|
|
2991
3143
|
const attachments = [];
|
|
2992
3144
|
for (const part of content) {
|
|
2993
|
-
if (!
|
|
3145
|
+
if (!isRecord2(part)) continue;
|
|
2994
3146
|
const attachment = contentPartToAttachment(part, role);
|
|
2995
3147
|
if (attachment) attachments.push(attachment);
|
|
2996
3148
|
}
|
|
@@ -3023,7 +3175,7 @@ async function outputAttachmentsFromFiles(files) {
|
|
|
3023
3175
|
if (!Array.isArray(resolvedFiles)) return void 0;
|
|
3024
3176
|
const attachments = [];
|
|
3025
3177
|
for (const file of resolvedFiles) {
|
|
3026
|
-
if (!
|
|
3178
|
+
if (!isRecord2(file)) continue;
|
|
3027
3179
|
const attachment = generatedFileToAttachment(file);
|
|
3028
3180
|
if (attachment) attachments.push(attachment);
|
|
3029
3181
|
}
|
|
@@ -3034,7 +3186,7 @@ function extractTextFromMessageContent(content) {
|
|
|
3034
3186
|
if (!Array.isArray(content)) return void 0;
|
|
3035
3187
|
let result = "";
|
|
3036
3188
|
for (const part of content) {
|
|
3037
|
-
if (!
|
|
3189
|
+
if (!isRecord2(part) || part["type"] !== "text" || typeof part["text"] !== "string") continue;
|
|
3038
3190
|
result += part["text"];
|
|
3039
3191
|
}
|
|
3040
3192
|
return result.length ? result : void 0;
|
|
@@ -3051,7 +3203,7 @@ function lastUserMessageFromArgs(args) {
|
|
|
3051
3203
|
if (!messages) return void 0;
|
|
3052
3204
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
3053
3205
|
const message = messages[i];
|
|
3054
|
-
if (
|
|
3206
|
+
if (isRecord2(message) && message["role"] === "user") {
|
|
3055
3207
|
return message;
|
|
3056
3208
|
}
|
|
3057
3209
|
}
|
|
@@ -3059,24 +3211,24 @@ function lastUserMessageFromArgs(args) {
|
|
|
3059
3211
|
}
|
|
3060
3212
|
function extractInputAttachmentsFromArgs(args) {
|
|
3061
3213
|
var _a;
|
|
3062
|
-
if (!
|
|
3214
|
+
if (!isRecord2(args)) return void 0;
|
|
3063
3215
|
return attachmentsFromContent((_a = lastUserMessageFromArgs(args)) == null ? void 0 : _a["content"], "input");
|
|
3064
3216
|
}
|
|
3065
3217
|
async function extractOutputAttachmentsFromResult(result) {
|
|
3066
|
-
if (!
|
|
3218
|
+
if (!isRecord2(result)) return void 0;
|
|
3067
3219
|
const fileAttachments = await outputAttachmentsFromFiles(result["files"]);
|
|
3068
3220
|
if (fileAttachments == null ? void 0 : fileAttachments.length) return fileAttachments;
|
|
3069
3221
|
const responseMessages = extractResponseMessages(result);
|
|
3070
3222
|
for (let i = responseMessages.length - 1; i >= 0; i--) {
|
|
3071
3223
|
const message = responseMessages[i];
|
|
3072
|
-
if (!
|
|
3224
|
+
if (!isRecord2(message) || message["role"] !== "assistant") continue;
|
|
3073
3225
|
return attachmentsFromContent(message["content"], "output");
|
|
3074
3226
|
}
|
|
3075
3227
|
return attachmentsFromContent(result["content"], "output");
|
|
3076
3228
|
}
|
|
3077
3229
|
function lastUserMessageTextFromArgs(args) {
|
|
3078
3230
|
var _a, _b;
|
|
3079
|
-
if (!
|
|
3231
|
+
if (!isRecord2(args)) return void 0;
|
|
3080
3232
|
const content = (_a = lastUserMessageFromArgs(args)) == null ? void 0 : _a["content"];
|
|
3081
3233
|
if (content === void 0) return void 0;
|
|
3082
3234
|
const text = extractTextFromMessageContent(content);
|
|
@@ -3085,13 +3237,13 @@ function lastUserMessageTextFromArgs(args) {
|
|
|
3085
3237
|
}
|
|
3086
3238
|
function extractInputFromArgs(args) {
|
|
3087
3239
|
var _a;
|
|
3088
|
-
if (!
|
|
3240
|
+
if (!isRecord2(args)) return void 0;
|
|
3089
3241
|
const prompt = args["prompt"];
|
|
3090
3242
|
if (typeof prompt === "string") return prompt;
|
|
3091
3243
|
const messages = messagesFromArgs(args);
|
|
3092
3244
|
if (Array.isArray(messages) && messages.length > 0) {
|
|
3093
3245
|
const last = messages[messages.length - 1];
|
|
3094
|
-
if (
|
|
3246
|
+
if (isRecord2(last)) {
|
|
3095
3247
|
const content = last["content"];
|
|
3096
3248
|
const text = extractTextFromMessageContent(content);
|
|
3097
3249
|
if (text !== void 0) return text;
|
|
@@ -3105,7 +3257,7 @@ function extractInputFromArgs(args) {
|
|
|
3105
3257
|
return safeJson(args);
|
|
3106
3258
|
}
|
|
3107
3259
|
function coerceMessagesFromArgs(args) {
|
|
3108
|
-
if (!
|
|
3260
|
+
if (!isRecord2(args)) return [];
|
|
3109
3261
|
const result = [];
|
|
3110
3262
|
if (typeof args["system"] === "string" && args["system"]) {
|
|
3111
3263
|
result.push({ role: "system", content: args["system"] });
|
|
@@ -3113,7 +3265,7 @@ function coerceMessagesFromArgs(args) {
|
|
|
3113
3265
|
const messages = messagesFromArgs(args);
|
|
3114
3266
|
if (Array.isArray(messages)) {
|
|
3115
3267
|
for (const message of messages) {
|
|
3116
|
-
if (
|
|
3268
|
+
if (isRecord2(message) && typeof message["role"] === "string") {
|
|
3117
3269
|
result.push(message);
|
|
3118
3270
|
}
|
|
3119
3271
|
}
|
|
@@ -3125,21 +3277,21 @@ function coerceMessagesFromArgs(args) {
|
|
|
3125
3277
|
return result;
|
|
3126
3278
|
}
|
|
3127
3279
|
function extractResponseMessages(result) {
|
|
3128
|
-
if (!
|
|
3280
|
+
if (!isRecord2(result)) return [];
|
|
3129
3281
|
const response = result["response"];
|
|
3130
|
-
if (
|
|
3282
|
+
if (isRecord2(response) && Array.isArray(response["messages"])) {
|
|
3131
3283
|
return response["messages"].filter(
|
|
3132
|
-
(message) =>
|
|
3284
|
+
(message) => isRecord2(message) && typeof message["role"] === "string" && "content" in message
|
|
3133
3285
|
).map((message) => message);
|
|
3134
3286
|
}
|
|
3135
3287
|
const steps = result["steps"];
|
|
3136
3288
|
if (Array.isArray(steps) && steps.length > 0) {
|
|
3137
3289
|
const lastStep = steps[steps.length - 1];
|
|
3138
|
-
if (
|
|
3290
|
+
if (isRecord2(lastStep) && isRecord2(lastStep["response"])) {
|
|
3139
3291
|
const responseMessages = lastStep["response"]["messages"];
|
|
3140
3292
|
if (Array.isArray(responseMessages)) {
|
|
3141
3293
|
return responseMessages.filter(
|
|
3142
|
-
(message) =>
|
|
3294
|
+
(message) => isRecord2(message) && typeof message["role"] === "string" && "content" in message
|
|
3143
3295
|
).map((message) => message);
|
|
3144
3296
|
}
|
|
3145
3297
|
}
|
|
@@ -3160,7 +3312,7 @@ function isTranscriptToolResultError(part, result) {
|
|
|
3160
3312
|
if (part["isError"] === true || part["type"] === "tool-error") {
|
|
3161
3313
|
return true;
|
|
3162
3314
|
}
|
|
3163
|
-
if (
|
|
3315
|
+
if (isRecord2(result) && typeof result["type"] === "string") {
|
|
3164
3316
|
return result["type"].startsWith("error") || result["type"] === "execution-denied";
|
|
3165
3317
|
}
|
|
3166
3318
|
return false;
|
|
@@ -3169,7 +3321,7 @@ function getTranscriptToolErrorMessage(result) {
|
|
|
3169
3321
|
if (typeof result === "string" && result.length > 0) {
|
|
3170
3322
|
return result;
|
|
3171
3323
|
}
|
|
3172
|
-
if (
|
|
3324
|
+
if (isRecord2(result)) {
|
|
3173
3325
|
if (typeof result["value"] === "string" && result["value"].length > 0) {
|
|
3174
3326
|
return result["value"];
|
|
3175
3327
|
}
|
|
@@ -3183,12 +3335,12 @@ function getTranscriptToolErrorMessage(result) {
|
|
|
3183
3335
|
return safeJsonWithUint8(result);
|
|
3184
3336
|
}
|
|
3185
3337
|
function getTranscriptMessageParts(message) {
|
|
3186
|
-
if (!
|
|
3338
|
+
if (!isRecord2(message)) return [];
|
|
3187
3339
|
const content = message["content"];
|
|
3188
3340
|
if (Array.isArray(content)) {
|
|
3189
|
-
return content.filter(
|
|
3341
|
+
return content.filter(isRecord2);
|
|
3190
3342
|
}
|
|
3191
|
-
return
|
|
3343
|
+
return isRecord2(content) ? [content] : [];
|
|
3192
3344
|
}
|
|
3193
3345
|
function getTranscriptToolCallInput(part) {
|
|
3194
3346
|
return "input" in part ? part["input"] : "args" in part ? part["args"] : void 0;
|
|
@@ -3289,7 +3441,7 @@ function extractTextFromLmContent(content) {
|
|
|
3289
3441
|
if (!Array.isArray(content)) return void 0;
|
|
3290
3442
|
let result = "";
|
|
3291
3443
|
for (const part of content) {
|
|
3292
|
-
if (
|
|
3444
|
+
if (isRecord2(part) && part["type"] === "text" && typeof part["text"] === "string") {
|
|
3293
3445
|
result += part["text"];
|
|
3294
3446
|
}
|
|
3295
3447
|
}
|
|
@@ -3299,7 +3451,7 @@ function extractToolCallsFromLmContent(content) {
|
|
|
3299
3451
|
if (!Array.isArray(content)) return void 0;
|
|
3300
3452
|
const calls = [];
|
|
3301
3453
|
for (const part of content) {
|
|
3302
|
-
if (!
|
|
3454
|
+
if (!isRecord2(part) || part["type"] !== "tool-call") continue;
|
|
3303
3455
|
const toolCallId = getTranscriptToolCallId(part);
|
|
3304
3456
|
const toolName = typeof part["toolName"] === "string" ? part["toolName"] : void 0;
|
|
3305
3457
|
if (toolCallId || toolName) {
|
|
@@ -3309,15 +3461,15 @@ function extractToolCallsFromLmContent(content) {
|
|
|
3309
3461
|
return calls.length ? calls : void 0;
|
|
3310
3462
|
}
|
|
3311
3463
|
function extractExperimentalTelemetry(args) {
|
|
3312
|
-
if (!
|
|
3464
|
+
if (!isRecord2(args)) return void 0;
|
|
3313
3465
|
const telemetryConfig = args["experimental_telemetry"];
|
|
3314
|
-
if (!
|
|
3466
|
+
if (!isRecord2(telemetryConfig)) return void 0;
|
|
3315
3467
|
return {
|
|
3316
3468
|
functionId: typeof telemetryConfig["functionId"] === "string" ? telemetryConfig["functionId"] : void 0,
|
|
3317
3469
|
isEnabled: typeof telemetryConfig["isEnabled"] === "boolean" ? telemetryConfig["isEnabled"] : void 0,
|
|
3318
3470
|
recordInputs: typeof telemetryConfig["recordInputs"] === "boolean" ? telemetryConfig["recordInputs"] : void 0,
|
|
3319
3471
|
recordOutputs: typeof telemetryConfig["recordOutputs"] === "boolean" ? telemetryConfig["recordOutputs"] : void 0,
|
|
3320
|
-
metadata:
|
|
3472
|
+
metadata: isRecord2(telemetryConfig["metadata"]) ? telemetryConfig["metadata"] : void 0
|
|
3321
3473
|
};
|
|
3322
3474
|
}
|
|
3323
3475
|
function opName(operationId, functionId) {
|
|
@@ -3345,7 +3497,7 @@ function attrsFromTelemetryMetadata(metadata) {
|
|
|
3345
3497
|
});
|
|
3346
3498
|
}
|
|
3347
3499
|
function attrsFromHeaders(headers) {
|
|
3348
|
-
if (!
|
|
3500
|
+
if (!isRecord2(headers)) return [];
|
|
3349
3501
|
return Object.entries(headers).filter(([, v]) => typeof v === "string").map(([k, v]) => attrString(`ai.request.headers.${k}`, v));
|
|
3350
3502
|
}
|
|
3351
3503
|
function attrsFromModelProvider(provider) {
|
|
@@ -3358,7 +3510,7 @@ function attrsFromModelProvider(provider) {
|
|
|
3358
3510
|
];
|
|
3359
3511
|
}
|
|
3360
3512
|
function attrsFromSettings(args) {
|
|
3361
|
-
if (!
|
|
3513
|
+
if (!isRecord2(args)) return [];
|
|
3362
3514
|
const result = [];
|
|
3363
3515
|
const settingKeys = [
|
|
3364
3516
|
"maxRetries",
|
|
@@ -3386,7 +3538,7 @@ function attrsFromSettings(args) {
|
|
|
3386
3538
|
return result;
|
|
3387
3539
|
}
|
|
3388
3540
|
function attrsFromGenAiRequest(options) {
|
|
3389
|
-
if (!
|
|
3541
|
+
if (!isRecord2(options)) return [];
|
|
3390
3542
|
return [
|
|
3391
3543
|
attrDouble(
|
|
3392
3544
|
"gen_ai.request.frequency_penalty",
|
|
@@ -3416,7 +3568,7 @@ function attrsFromGenAiRequest(options) {
|
|
|
3416
3568
|
];
|
|
3417
3569
|
}
|
|
3418
3570
|
function attrProviderOptions(options) {
|
|
3419
|
-
if (!
|
|
3571
|
+
if (!isRecord2(options) || !isRecord2(options["providerOptions"])) return void 0;
|
|
3420
3572
|
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
3421
3573
|
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
3422
3574
|
}
|
|
@@ -3458,10 +3610,10 @@ function readRaindropCallMetadataFromArgs(args) {
|
|
|
3458
3610
|
var _a;
|
|
3459
3611
|
if (args.length === 0) return void 0;
|
|
3460
3612
|
const first = args[0];
|
|
3461
|
-
if (!
|
|
3462
|
-
const topLevel =
|
|
3463
|
-
const stable =
|
|
3464
|
-
const stableMetadata =
|
|
3613
|
+
if (!isRecord2(first)) return void 0;
|
|
3614
|
+
const topLevel = isRecord2(first["metadata"]) ? first["metadata"] : void 0;
|
|
3615
|
+
const stable = isRecord2(first["telemetry"]) ? first["telemetry"]["metadata"] : void 0;
|
|
3616
|
+
const stableMetadata = isRecord2(stable) ? stable : void 0;
|
|
3465
3617
|
const exp = extractExperimentalTelemetry(first);
|
|
3466
3618
|
const expMetadata = (exp == null ? void 0 : exp.metadata) && typeof exp.metadata === "object" ? exp.metadata : void 0;
|
|
3467
3619
|
const raw = (_a = topLevel != null ? topLevel : stableMetadata) != null ? _a : expMetadata;
|
|
@@ -3901,38 +4053,38 @@ var CACHE_WRITE_METADATA_KEYS = [
|
|
|
3901
4053
|
["bedrock", "cacheWriteInputTokens"]
|
|
3902
4054
|
];
|
|
3903
4055
|
function cacheWriteTokensFromProviderMetadata(providerMetadata) {
|
|
3904
|
-
if (!
|
|
4056
|
+
if (!isRecord2(providerMetadata)) return void 0;
|
|
3905
4057
|
return firstTokenCount(
|
|
3906
4058
|
...CACHE_WRITE_METADATA_KEYS.flatMap(([namespace, key]) => {
|
|
3907
4059
|
const scope = providerMetadata[namespace];
|
|
3908
|
-
if (!
|
|
4060
|
+
if (!isRecord2(scope)) return [];
|
|
3909
4061
|
const usage = scope["usage"];
|
|
3910
|
-
return [scope[key],
|
|
4062
|
+
return [scope[key], isRecord2(usage) ? usage[key] : void 0];
|
|
3911
4063
|
})
|
|
3912
4064
|
);
|
|
3913
4065
|
}
|
|
3914
4066
|
function extractUsageMetricsFromUsage(usage, _provider, providerMetadata) {
|
|
3915
|
-
if (!
|
|
4067
|
+
if (!isRecord2(usage)) return {};
|
|
3916
4068
|
const inputTokenValue = usage["inputTokens"];
|
|
3917
4069
|
const outputTokenValue = usage["outputTokens"];
|
|
3918
4070
|
const inputTokenDetails = usage["inputTokenDetails"];
|
|
3919
4071
|
const outputTokenDetails = usage["outputTokenDetails"];
|
|
3920
|
-
const hasStructuredUsage =
|
|
4072
|
+
const hasStructuredUsage = isRecord2(inputTokenValue) || isRecord2(outputTokenValue) || isRecord2(inputTokenDetails) || isRecord2(outputTokenDetails);
|
|
3921
4073
|
const inputTokens = firstTokenCount(
|
|
3922
|
-
|
|
4074
|
+
isRecord2(inputTokenValue) ? inputTokenValue["total"] : void 0,
|
|
3923
4075
|
inputTokenValue,
|
|
3924
4076
|
usage["promptTokens"],
|
|
3925
4077
|
usage["prompt_tokens"]
|
|
3926
4078
|
);
|
|
3927
4079
|
const outputTokens = firstTokenCount(
|
|
3928
|
-
|
|
4080
|
+
isRecord2(outputTokenValue) ? outputTokenValue["total"] : void 0,
|
|
3929
4081
|
outputTokenValue,
|
|
3930
4082
|
usage["completionTokens"],
|
|
3931
4083
|
usage["completion_tokens"]
|
|
3932
4084
|
);
|
|
3933
4085
|
const reasoningTokens = firstTokenCount(
|
|
3934
|
-
|
|
3935
|
-
|
|
4086
|
+
isRecord2(outputTokenValue) ? outputTokenValue["reasoning"] : void 0,
|
|
4087
|
+
isRecord2(outputTokenDetails) ? outputTokenDetails["reasoningTokens"] : void 0,
|
|
3936
4088
|
usage["reasoningTokens"],
|
|
3937
4089
|
usage["completionReasoningTokens"],
|
|
3938
4090
|
usage["completion_reasoning_tokens"],
|
|
@@ -3941,27 +4093,27 @@ function extractUsageMetricsFromUsage(usage, _provider, providerMetadata) {
|
|
|
3941
4093
|
usage["thinking_tokens"]
|
|
3942
4094
|
);
|
|
3943
4095
|
const cacheReadInputTokens = firstTokenCount(
|
|
3944
|
-
|
|
3945
|
-
|
|
4096
|
+
isRecord2(inputTokenValue) ? inputTokenValue["cacheRead"] : void 0,
|
|
4097
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["cacheReadTokens"] : void 0,
|
|
3946
4098
|
usage["cachedInputTokens"],
|
|
3947
4099
|
usage["promptCachedTokens"],
|
|
3948
4100
|
usage["prompt_cached_tokens"]
|
|
3949
4101
|
);
|
|
3950
4102
|
const cacheWriteInputTokens = firstTokenCount(
|
|
3951
|
-
|
|
3952
|
-
|
|
4103
|
+
isRecord2(inputTokenValue) ? inputTokenValue["cacheWrite"] : void 0,
|
|
4104
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["cacheWriteTokens"] : void 0,
|
|
3953
4105
|
usage["cacheWriteInputTokens"],
|
|
3954
4106
|
usage["cacheCreationInputTokens"],
|
|
3955
4107
|
usage["cache_creation_input_tokens"],
|
|
3956
4108
|
cacheWriteTokensFromProviderMetadata(providerMetadata)
|
|
3957
4109
|
);
|
|
3958
4110
|
const nonCachedInputTokens = firstTokenCount(
|
|
3959
|
-
|
|
3960
|
-
|
|
4111
|
+
isRecord2(inputTokenValue) ? inputTokenValue["noCache"] : void 0,
|
|
4112
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["noCacheTokens"] : void 0
|
|
3961
4113
|
);
|
|
3962
4114
|
const nonReasoningOutputTokens = firstTokenCount(
|
|
3963
|
-
|
|
3964
|
-
|
|
4115
|
+
isRecord2(outputTokenValue) ? outputTokenValue["text"] : void 0,
|
|
4116
|
+
isRecord2(outputTokenDetails) ? outputTokenDetails["textTokens"] : void 0
|
|
3965
4117
|
);
|
|
3966
4118
|
const totalTokens = firstTokenCount(
|
|
3967
4119
|
usage["totalTokens"],
|
|
@@ -4187,17 +4339,10 @@ var RaindropTelemetryIntegration = class {
|
|
|
4187
4339
|
if (event.promptMessages) {
|
|
4188
4340
|
inputAttrs.push(attrString("ai.prompt.messages", safeJsonWithUint8(event.promptMessages)));
|
|
4189
4341
|
}
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
event.stepTools.map((t) => {
|
|
4195
|
-
var _a;
|
|
4196
|
-
return (_a = safeJsonWithUint8(t)) != null ? _a : "";
|
|
4197
|
-
})
|
|
4198
|
-
)
|
|
4199
|
-
);
|
|
4200
|
-
}
|
|
4342
|
+
const promptTools = promptToolsAttribute(
|
|
4343
|
+
resolvePromptTools({ override: this.promptTools, inferred: event.stepTools })
|
|
4344
|
+
);
|
|
4345
|
+
if (promptTools) inputAttrs.push(promptTools);
|
|
4201
4346
|
if (event.stepToolChoice != null) {
|
|
4202
4347
|
inputAttrs.push(
|
|
4203
4348
|
attrString("ai.prompt.toolChoice", safeJsonWithUint8(event.stepToolChoice))
|
|
@@ -4545,6 +4690,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
4545
4690
|
this.subagentWrapping = opts.subagentWrapping !== false;
|
|
4546
4691
|
this.debug = opts.debug === true;
|
|
4547
4692
|
this.defaultContext = opts.context;
|
|
4693
|
+
this.promptTools = opts.tools;
|
|
4548
4694
|
this.subagents = new SubagentApi({
|
|
4549
4695
|
traceShipper: this.traceShipper,
|
|
4550
4696
|
eventShipper: this.eventShipper,
|
|
@@ -5170,6 +5316,18 @@ function createStandaloneSelfDiagnosticsTool(args) {
|
|
|
5170
5316
|
}
|
|
5171
5317
|
|
|
5172
5318
|
// src/internal/wrap/wrapAISDK.ts
|
|
5319
|
+
function promptToolsOptionsFrom(aiSDK) {
|
|
5320
|
+
if (!isRecord2(aiSDK)) return void 0;
|
|
5321
|
+
const asSchema = aiSDK["asSchema"];
|
|
5322
|
+
if (!isFunction(asSchema)) return void 0;
|
|
5323
|
+
return {
|
|
5324
|
+
schema: (schema) => {
|
|
5325
|
+
const converted = asSchema(schema);
|
|
5326
|
+
const json = isRecord2(converted) ? converted["jsonSchema"] : void 0;
|
|
5327
|
+
return isRecord2(json) ? json : void 0;
|
|
5328
|
+
}
|
|
5329
|
+
};
|
|
5330
|
+
}
|
|
5173
5331
|
var pendingStoresByShipper = /* @__PURE__ */ new WeakMap();
|
|
5174
5332
|
var PendingToolSpanStore = class _PendingToolSpanStore {
|
|
5175
5333
|
constructor() {
|
|
@@ -5226,9 +5384,9 @@ function _resetWarnedMissingUserId() {
|
|
|
5226
5384
|
warnedMissingUserId = false;
|
|
5227
5385
|
}
|
|
5228
5386
|
function extractRaindropCallOptions(options) {
|
|
5229
|
-
if (!
|
|
5387
|
+
if (!isRecord2(options)) return {};
|
|
5230
5388
|
const em = options["metadata"];
|
|
5231
|
-
if (
|
|
5389
|
+
if (isRecord2(em)) return extractRaindropMetadata(em);
|
|
5232
5390
|
const telemetry = extractExperimentalTelemetry(options);
|
|
5233
5391
|
if (telemetry == null ? void 0 : telemetry.metadata) return extractRaindropMetadata(telemetry.metadata);
|
|
5234
5392
|
return {};
|
|
@@ -5290,20 +5448,20 @@ function mergeContexts(wrapTime, callTime) {
|
|
|
5290
5448
|
return result;
|
|
5291
5449
|
}
|
|
5292
5450
|
function detectAISDKVersion(aiSDK) {
|
|
5293
|
-
if (!
|
|
5451
|
+
if (!isRecord2(aiSDK)) return "unknown";
|
|
5294
5452
|
if (isFunction(aiSDK["jsonSchema"])) return "6";
|
|
5295
5453
|
if (isFunction(aiSDK["tool"])) return "5";
|
|
5296
5454
|
return "4";
|
|
5297
5455
|
}
|
|
5298
5456
|
function hasStructuredTelemetryEvents(aiSDK) {
|
|
5299
|
-
if (!
|
|
5457
|
+
if (!isRecord2(aiSDK)) return false;
|
|
5300
5458
|
const hasRegister = isFunction(aiSDK["registerTelemetry"]) || isFunction(aiSDK["registerTelemetryIntegration"]);
|
|
5301
5459
|
const hasV7Marker = isFunction(aiSDK["experimental_streamLanguageModelCall"]) || isFunction(aiSDK["experimental_streamModelCall"]);
|
|
5302
5460
|
return hasRegister && hasV7Marker;
|
|
5303
5461
|
}
|
|
5304
5462
|
function resolveRegisterTelemetry(aiSDK) {
|
|
5305
5463
|
var _a;
|
|
5306
|
-
if (!
|
|
5464
|
+
if (!isRecord2(aiSDK)) return void 0;
|
|
5307
5465
|
const fn = (_a = aiSDK["registerTelemetry"]) != null ? _a : aiSDK["registerTelemetryIntegration"];
|
|
5308
5466
|
return isFunction(fn) ? fn : void 0;
|
|
5309
5467
|
}
|
|
@@ -5334,18 +5492,18 @@ function isAsyncIterable(value) {
|
|
|
5334
5492
|
return value !== null && typeof value === "object" && Symbol.asyncIterator in value;
|
|
5335
5493
|
}
|
|
5336
5494
|
function resolveUsageRecord(result) {
|
|
5337
|
-
if (!
|
|
5495
|
+
if (!isRecord2(result)) return void 0;
|
|
5338
5496
|
let usage;
|
|
5339
5497
|
try {
|
|
5340
|
-
if (
|
|
5498
|
+
if (isRecord2(result["totalUsage"])) {
|
|
5341
5499
|
usage = result["totalUsage"];
|
|
5342
|
-
} else if (
|
|
5500
|
+
} else if (isRecord2(result["usage"])) {
|
|
5343
5501
|
usage = result["usage"];
|
|
5344
5502
|
}
|
|
5345
5503
|
} catch (e) {
|
|
5346
5504
|
return void 0;
|
|
5347
5505
|
}
|
|
5348
|
-
return
|
|
5506
|
+
return isRecord2(usage) ? usage : void 0;
|
|
5349
5507
|
}
|
|
5350
5508
|
function extractUsageMetrics(result) {
|
|
5351
5509
|
return extractUsageMetricsFromUsage(resolveUsageRecord(result));
|
|
@@ -5366,7 +5524,7 @@ function shouldKeepEventPending(params) {
|
|
|
5366
5524
|
}
|
|
5367
5525
|
function normalizePromptAttr(arg) {
|
|
5368
5526
|
var _a, _b;
|
|
5369
|
-
if (!
|
|
5527
|
+
if (!isRecord2(arg)) return arg;
|
|
5370
5528
|
const system = arg["system"];
|
|
5371
5529
|
const prompt = arg["prompt"];
|
|
5372
5530
|
const messages = arg["messages"];
|
|
@@ -5420,7 +5578,7 @@ async function runWithRootContextAsync(rootSpan, eventId, fn) {
|
|
|
5420
5578
|
);
|
|
5421
5579
|
}
|
|
5422
5580
|
function teeStreamObjectBaseStream(result) {
|
|
5423
|
-
if (!result || !
|
|
5581
|
+
if (!result || !isRecord2(result)) return;
|
|
5424
5582
|
const baseStream = result["baseStream"];
|
|
5425
5583
|
if (!(baseStream && typeof baseStream === "object" && "tee" in baseStream)) return;
|
|
5426
5584
|
try {
|
|
@@ -5461,7 +5619,7 @@ function setupOperation(params) {
|
|
|
5461
5619
|
const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
|
|
5462
5620
|
const outerOperationId = `ai.${operation}`;
|
|
5463
5621
|
const { operationName, resourceName } = opName(outerOperationId, telemetry == null ? void 0 : telemetry.functionId);
|
|
5464
|
-
const modelInfoFromArgs =
|
|
5622
|
+
const modelInfoFromArgs = isRecord2(arg) ? extractModelInfo(arg["model"]) : {};
|
|
5465
5623
|
const rootSpan = sendTraces ? traceShipper.startSpan({
|
|
5466
5624
|
name: outerOperationId,
|
|
5467
5625
|
parent: inheritedParent,
|
|
@@ -5476,7 +5634,7 @@ function setupOperation(params) {
|
|
|
5476
5634
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
5477
5635
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
5478
5636
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
5479
|
-
...attrsFromHeaders(
|
|
5637
|
+
...attrsFromHeaders(isRecord2(arg) ? arg["headers"] : void 0),
|
|
5480
5638
|
...attrsFromSettings(arg),
|
|
5481
5639
|
...(telemetry == null ? void 0 : telemetry.recordInputs) === false ? [] : [attrString("ai.prompt", safeJsonWithUint8(normalizePromptAttr(arg)))]
|
|
5482
5640
|
]
|
|
@@ -5493,7 +5651,9 @@ function setupOperation(params) {
|
|
|
5493
5651
|
traceShipper,
|
|
5494
5652
|
rootParentForChildren,
|
|
5495
5653
|
selfDiagnostics: operationSelfDiagnostics,
|
|
5496
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
5654
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
5655
|
+
promptTools: options.tools,
|
|
5656
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
5497
5657
|
};
|
|
5498
5658
|
const toolCalls = [];
|
|
5499
5659
|
const argsWithWrappedTools = wrapTools(arg, wrapCtx, toolCalls);
|
|
@@ -5566,8 +5726,8 @@ function createFinalize(params) {
|
|
|
5566
5726
|
endTimeUnixNano: spanEndTimeUnixNano,
|
|
5567
5727
|
keepEventPending
|
|
5568
5728
|
});
|
|
5569
|
-
const providerMetadata =
|
|
5570
|
-
const resultToolCalls =
|
|
5729
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
5730
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : setup.toolCalls.length ? safeJsonWithUint8(setup.toolCalls) : void 0;
|
|
5571
5731
|
traceShipper.endSpan(setup.rootSpan, {
|
|
5572
5732
|
attributes: [
|
|
5573
5733
|
...((_d = setup.telemetry) == null ? void 0 : _d.recordOutputs) === false ? [] : [
|
|
@@ -5839,6 +5999,7 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5839
5999
|
sendEvents: ((_b = deps.options.send) == null ? void 0 : _b.events) !== false,
|
|
5840
6000
|
debug,
|
|
5841
6001
|
settledEventIds: deps.settledEventIds,
|
|
6002
|
+
tools: deps.options.tools,
|
|
5842
6003
|
context: {
|
|
5843
6004
|
userId: wrapTimeCtx.userId,
|
|
5844
6005
|
eventId: wrapTimeCtx.eventId,
|
|
@@ -5881,7 +6042,7 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5881
6042
|
const arg = callArgs[0];
|
|
5882
6043
|
const callMetadata = readRaindropCallMetadataFromArgs(callArgs);
|
|
5883
6044
|
const callOriginal = () => original.call(aiSDK, ...callArgs);
|
|
5884
|
-
if (selfDiagnostics2 && selfDiagnosticsOps.has(propName) &&
|
|
6045
|
+
if (selfDiagnostics2 && selfDiagnosticsOps.has(propName) && isRecord2(arg)) {
|
|
5885
6046
|
const telemetry = extractExperimentalTelemetry(arg);
|
|
5886
6047
|
const callMeta = (telemetry == null ? void 0 : telemetry.metadata) ? extractRaindropMetadata(telemetry.metadata) : {};
|
|
5887
6048
|
const perCallEventIdExplicit = (_b2 = (_a2 = callMetadata == null ? void 0 : callMetadata.eventId) != null ? _a2 : callMeta.eventId) != null ? _b2 : wrapTimeCtx.eventId;
|
|
@@ -5893,16 +6054,18 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5893
6054
|
eventShipper: deps.eventShipper,
|
|
5894
6055
|
traceShipper: deps.traceShipper,
|
|
5895
6056
|
selfDiagnostics: selfDiagnostics2,
|
|
5896
|
-
aiSDKVersion: "7"
|
|
6057
|
+
aiSDKVersion: "7",
|
|
6058
|
+
promptTools: deps.options.tools,
|
|
6059
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
5897
6060
|
};
|
|
5898
|
-
const tools =
|
|
6061
|
+
const tools = isRecord2(arg["tools"]) ? { ...arg["tools"] } : {};
|
|
5899
6062
|
const toolName = selfDiagnostics2.toolName;
|
|
5900
6063
|
if (!(toolName in tools)) {
|
|
5901
6064
|
const reportTool = createSelfDiagnosticsTool(perCallCtx);
|
|
5902
6065
|
if (reportTool) tools[toolName] = reportTool;
|
|
5903
6066
|
}
|
|
5904
|
-
const existingTelemetry =
|
|
5905
|
-
const existingMetadata =
|
|
6067
|
+
const existingTelemetry = isRecord2(arg["experimental_telemetry"]) ? arg["experimental_telemetry"] : {};
|
|
6068
|
+
const existingMetadata = isRecord2(existingTelemetry["metadata"]) ? existingTelemetry["metadata"] : {};
|
|
5906
6069
|
const mergedMetadata = existingMetadata["raindrop.eventId"] ? existingMetadata : {
|
|
5907
6070
|
...existingMetadata,
|
|
5908
6071
|
"raindrop.eventId": perCallEventId,
|
|
@@ -6098,7 +6261,9 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
6098
6261
|
traceShipper: deps.traceShipper,
|
|
6099
6262
|
rootParentForChildren,
|
|
6100
6263
|
selfDiagnostics,
|
|
6101
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
6264
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
6265
|
+
promptTools: deps.options.tools,
|
|
6266
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
6102
6267
|
};
|
|
6103
6268
|
const toolCalls = [];
|
|
6104
6269
|
const mergedArgsWithWrappedTools = wrapTools(mergedArgs, wrapCtx, toolCalls);
|
|
@@ -6148,8 +6313,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
6148
6313
|
keepEventPending: false
|
|
6149
6314
|
});
|
|
6150
6315
|
const finishReason = extractFinishReason(result);
|
|
6151
|
-
const providerMetadata =
|
|
6152
|
-
const resultToolCalls =
|
|
6316
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6317
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : toolCalls.length ? safeJsonWithUint8(toolCalls) : void 0;
|
|
6153
6318
|
deps.traceShipper.endSpan(rootSpan, {
|
|
6154
6319
|
attributes: [
|
|
6155
6320
|
...(telemetry == null ? void 0 : telemetry.recordOutputs) === false ? [] : [
|
|
@@ -6318,7 +6483,9 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6318
6483
|
traceShipper: deps.traceShipper,
|
|
6319
6484
|
rootParentForChildren,
|
|
6320
6485
|
selfDiagnostics,
|
|
6321
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
6486
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
6487
|
+
promptTools: deps.options.tools,
|
|
6488
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
6322
6489
|
};
|
|
6323
6490
|
const toolCalls = [];
|
|
6324
6491
|
const mergedArgsWithWrappedTools = wrapTools(mergedArgs, wrapCtx, toolCalls);
|
|
@@ -6368,8 +6535,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6368
6535
|
keepEventPending: false
|
|
6369
6536
|
});
|
|
6370
6537
|
const finishReason = extractFinishReason(result);
|
|
6371
|
-
const providerMetadata =
|
|
6372
|
-
const resultToolCalls =
|
|
6538
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6539
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : toolCalls.length ? safeJsonWithUint8(toolCalls) : void 0;
|
|
6373
6540
|
deps.traceShipper.endSpan(rootSpan, {
|
|
6374
6541
|
attributes: [
|
|
6375
6542
|
...(telemetry == null ? void 0 : telemetry.recordOutputs) === false ? [] : [
|
|
@@ -6481,8 +6648,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6481
6648
|
};
|
|
6482
6649
|
}
|
|
6483
6650
|
function wrapTools(args, ctx, toolCalls) {
|
|
6484
|
-
if (!
|
|
6485
|
-
const tools =
|
|
6651
|
+
if (!isRecord2(args)) return args;
|
|
6652
|
+
const tools = isRecord2(args["tools"]) ? { ...args["tools"] } : {};
|
|
6486
6653
|
if (ctx.selfDiagnostics) {
|
|
6487
6654
|
const reportToolName = ctx.selfDiagnostics.toolName;
|
|
6488
6655
|
if (!(reportToolName in tools)) {
|
|
@@ -6505,7 +6672,7 @@ function wrapTools(args, ctx, toolCalls) {
|
|
|
6505
6672
|
}
|
|
6506
6673
|
function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
6507
6674
|
var _a;
|
|
6508
|
-
if (!
|
|
6675
|
+
if (!isRecord2(tool) || !isFunction(tool["execute"])) return tool;
|
|
6509
6676
|
const originalExecute = tool["execute"];
|
|
6510
6677
|
const { operationName, resourceName } = opName("ai.toolCall", (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6511
6678
|
const createToolSpan = (toolCallId, toolArgs, parent) => {
|
|
@@ -6566,7 +6733,7 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
|
6566
6733
|
const wrappedExecute = function(...execArgs) {
|
|
6567
6734
|
const toolArgs = execArgs[0];
|
|
6568
6735
|
const execOptions = execArgs.length > 1 ? execArgs[1] : void 0;
|
|
6569
|
-
const toolCallId =
|
|
6736
|
+
const toolCallId = isRecord2(execOptions) && typeof execOptions["toolCallId"] === "string" ? execOptions["toolCallId"] : randomUUID();
|
|
6570
6737
|
const result = originalExecute.apply(this, execArgs);
|
|
6571
6738
|
if (isAsyncIterable(result)) {
|
|
6572
6739
|
return (async function* () {
|
|
@@ -6641,20 +6808,20 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
|
6641
6808
|
return { ...tool, execute: wrappedExecute };
|
|
6642
6809
|
}
|
|
6643
6810
|
function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
6644
|
-
if (!
|
|
6811
|
+
if (!isRecord2(args) || !("model" in args)) return args;
|
|
6645
6812
|
let model = args["model"];
|
|
6646
6813
|
if (typeof model === "string") {
|
|
6647
6814
|
const maybeProvider = globalThis.AI_SDK_DEFAULT_PROVIDER;
|
|
6648
|
-
const gateway =
|
|
6815
|
+
const gateway = isRecord2(aiSDK) ? aiSDK["gateway"] : void 0;
|
|
6649
6816
|
const provider = maybeProvider != null ? maybeProvider : gateway;
|
|
6650
|
-
if (
|
|
6817
|
+
if (isRecord2(provider) && isFunction(provider["languageModel"])) {
|
|
6651
6818
|
try {
|
|
6652
6819
|
model = provider["languageModel"](model);
|
|
6653
6820
|
} catch (e) {
|
|
6654
6821
|
}
|
|
6655
6822
|
}
|
|
6656
6823
|
}
|
|
6657
|
-
if (!
|
|
6824
|
+
if (!isRecord2(model)) return args;
|
|
6658
6825
|
const modelInfo = extractModelInfo(model);
|
|
6659
6826
|
const doGenerateOpId = `${outerOperationId}.doGenerate`;
|
|
6660
6827
|
const doStreamOpId = `${outerOperationId}.doStream`;
|
|
@@ -6671,13 +6838,13 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6671
6838
|
try {
|
|
6672
6839
|
const result = await original.apply(target, callArgs);
|
|
6673
6840
|
if (span) endDoGenerateSpan(span, result, modelInfo, ctx);
|
|
6674
|
-
if (localDebuggerEnabled() && ctx.rootParentForChildren &&
|
|
6841
|
+
if (localDebuggerEnabled() && ctx.rootParentForChildren && isRecord2(result)) {
|
|
6675
6842
|
const traceId = ctx.rootParentForChildren.traceIdB64;
|
|
6676
6843
|
const liveMeta = getLocalDebuggerMetadata({ ...ctx.context, eventId: ctx.eventId });
|
|
6677
6844
|
const content = result["content"];
|
|
6678
6845
|
if (Array.isArray(content)) {
|
|
6679
6846
|
for (const part of content) {
|
|
6680
|
-
if (
|
|
6847
|
+
if (isRecord2(part)) {
|
|
6681
6848
|
if ((part["type"] === "reasoning" || part["type"] === "thinking") && typeof ((_a = part["text"]) != null ? _a : part["thinking"]) === "string") {
|
|
6682
6849
|
sendLocalDebuggerLiveEvent({
|
|
6683
6850
|
traceId,
|
|
@@ -6746,7 +6913,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6746
6913
|
});
|
|
6747
6914
|
throw error;
|
|
6748
6915
|
}
|
|
6749
|
-
const stream =
|
|
6916
|
+
const stream = isRecord2(result) ? result["stream"] : void 0;
|
|
6750
6917
|
const RS = globalThis.ReadableStream;
|
|
6751
6918
|
if (!RS || !(stream instanceof RS)) {
|
|
6752
6919
|
if (span) ctx.traceShipper.endSpan(span);
|
|
@@ -6819,7 +6986,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6819
6986
|
return;
|
|
6820
6987
|
}
|
|
6821
6988
|
if (firstChunkMs === void 0) firstChunkMs = Date.now();
|
|
6822
|
-
if (
|
|
6989
|
+
if (isRecord2(value)) {
|
|
6823
6990
|
const type = value["type"];
|
|
6824
6991
|
if (type === "text-delta") {
|
|
6825
6992
|
let textDelta;
|
|
@@ -6834,7 +7001,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6834
7001
|
}
|
|
6835
7002
|
if (type === "finish") finishReason = extractFinishReason(value);
|
|
6836
7003
|
if (type === "tool-call") toolCallsLocal.push(value);
|
|
6837
|
-
if ("response" in value &&
|
|
7004
|
+
if ("response" in value && isRecord2(value["response"])) {
|
|
6838
7005
|
const response = value["response"];
|
|
6839
7006
|
if (typeof response["id"] === "string") responseId = response["id"];
|
|
6840
7007
|
if (typeof response["modelId"] === "string")
|
|
@@ -6911,10 +7078,15 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6911
7078
|
function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
6912
7079
|
var _a, _b, _c;
|
|
6913
7080
|
const { operationName, resourceName } = opName(operationId, (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6914
|
-
const
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
7081
|
+
const promptTools = promptToolsAttribute(
|
|
7082
|
+
resolvePromptTools({
|
|
7083
|
+
override: ctx.promptTools,
|
|
7084
|
+
inferred: isRecord2(options) ? options["tools"] : void 0,
|
|
7085
|
+
options: ctx.promptToolsOptions
|
|
7086
|
+
})
|
|
7087
|
+
);
|
|
7088
|
+
const toolChoiceJson = isRecord2(options) ? safeJsonWithUint8(options["toolChoice"]) : void 0;
|
|
7089
|
+
const promptJson = isRecord2(options) ? safeJsonWithUint8(options["prompt"]) : safeJsonWithUint8(options);
|
|
6918
7090
|
return ctx.traceShipper.startSpan({
|
|
6919
7091
|
name: operationId,
|
|
6920
7092
|
parent,
|
|
@@ -6929,7 +7101,7 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
6929
7101
|
attrString("ai.model.id", modelInfo.modelId),
|
|
6930
7102
|
...((_c = ctx.telemetry) == null ? void 0 : _c.recordInputs) === false ? [] : [
|
|
6931
7103
|
attrString("ai.prompt.messages", promptJson),
|
|
6932
|
-
|
|
7104
|
+
promptTools,
|
|
6933
7105
|
attrString("ai.prompt.toolChoice", toolChoiceJson)
|
|
6934
7106
|
],
|
|
6935
7107
|
attrString(MODEL_USAGE_ATTRIBUTES.requestModel, modelInfo.modelId),
|
|
@@ -6941,26 +7113,26 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
6941
7113
|
function endDoGenerateSpan(span, result, modelInfo, ctx) {
|
|
6942
7114
|
var _a;
|
|
6943
7115
|
const finishReason = extractFinishReason(result);
|
|
6944
|
-
const content =
|
|
6945
|
-
const response =
|
|
6946
|
-
const usage =
|
|
6947
|
-
const providerMetadata =
|
|
7116
|
+
const content = isRecord2(result) ? result["content"] : void 0;
|
|
7117
|
+
const response = isRecord2(result) ? result["response"] : void 0;
|
|
7118
|
+
const usage = isRecord2(result) ? result["usage"] : void 0;
|
|
7119
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6948
7120
|
let responseId;
|
|
6949
|
-
if (
|
|
7121
|
+
if (isRecord2(response) && typeof response["id"] === "string") {
|
|
6950
7122
|
responseId = response["id"];
|
|
6951
7123
|
} else {
|
|
6952
7124
|
responseId = randomUUID();
|
|
6953
7125
|
}
|
|
6954
7126
|
let responseModelId;
|
|
6955
|
-
if (
|
|
7127
|
+
if (isRecord2(response) && typeof response["modelId"] === "string") {
|
|
6956
7128
|
responseModelId = response["modelId"];
|
|
6957
7129
|
} else {
|
|
6958
7130
|
responseModelId = modelInfo.modelId;
|
|
6959
7131
|
}
|
|
6960
7132
|
let responseTimestampIso;
|
|
6961
|
-
if (
|
|
7133
|
+
if (isRecord2(response) && response["timestamp"] instanceof Date) {
|
|
6962
7134
|
responseTimestampIso = response["timestamp"].toISOString();
|
|
6963
|
-
} else if (
|
|
7135
|
+
} else if (isRecord2(response) && typeof response["timestamp"] === "string") {
|
|
6964
7136
|
responseTimestampIso = response["timestamp"];
|
|
6965
7137
|
} else {
|
|
6966
7138
|
responseTimestampIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -6994,10 +7166,15 @@ function endDoGenerateSpan(span, result, modelInfo, ctx) {
|
|
|
6994
7166
|
function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
6995
7167
|
var _a, _b, _c;
|
|
6996
7168
|
const { operationName, resourceName } = opName(operationId, (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6997
|
-
const
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7169
|
+
const promptTools = promptToolsAttribute(
|
|
7170
|
+
resolvePromptTools({
|
|
7171
|
+
override: ctx.promptTools,
|
|
7172
|
+
inferred: isRecord2(options) ? options["tools"] : void 0,
|
|
7173
|
+
options: ctx.promptToolsOptions
|
|
7174
|
+
})
|
|
7175
|
+
);
|
|
7176
|
+
const toolChoiceJson = isRecord2(options) ? safeJsonWithUint8(options["toolChoice"]) : void 0;
|
|
7177
|
+
const promptJson = isRecord2(options) ? safeJsonWithUint8(options["prompt"]) : safeJsonWithUint8(options);
|
|
7001
7178
|
return ctx.traceShipper.startSpan({
|
|
7002
7179
|
name: operationId,
|
|
7003
7180
|
parent,
|
|
@@ -7012,7 +7189,7 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
7012
7189
|
attrString("ai.model.id", modelInfo.modelId),
|
|
7013
7190
|
...((_c = ctx.telemetry) == null ? void 0 : _c.recordInputs) === false ? [] : [
|
|
7014
7191
|
attrString("ai.prompt.messages", promptJson),
|
|
7015
|
-
|
|
7192
|
+
promptTools,
|
|
7016
7193
|
attrString("ai.prompt.toolChoice", toolChoiceJson)
|
|
7017
7194
|
],
|
|
7018
7195
|
attrString(MODEL_USAGE_ATTRIBUTES.requestModel, modelInfo.modelId),
|
|
@@ -7026,7 +7203,7 @@ function resolveContext(context, info) {
|
|
|
7026
7203
|
return typeof context === "function" ? context(info) : context;
|
|
7027
7204
|
}
|
|
7028
7205
|
function wrapOnFinish(args, onFinish) {
|
|
7029
|
-
if (!
|
|
7206
|
+
if (!isRecord2(args)) return args;
|
|
7030
7207
|
const existing = args["onFinish"];
|
|
7031
7208
|
if (existing === void 0) {
|
|
7032
7209
|
return { ...args, onFinish: async (result) => onFinish(result) };
|
|
@@ -7084,7 +7261,7 @@ function mergeAttachments(...groups) {
|
|
|
7084
7261
|
// package.json
|
|
7085
7262
|
var package_default = {
|
|
7086
7263
|
name: "@raindrop-ai/ai-sdk",
|
|
7087
|
-
version: "0.3.
|
|
7264
|
+
version: "0.3.4"};
|
|
7088
7265
|
|
|
7089
7266
|
// src/internal/version.ts
|
|
7090
7267
|
var libraryName = package_default.name;
|
|
@@ -7268,11 +7445,16 @@ function createRaindropAISDK(opts) {
|
|
|
7268
7445
|
];
|
|
7269
7446
|
let context;
|
|
7270
7447
|
let subagentWrapping;
|
|
7448
|
+
let tools;
|
|
7271
7449
|
if (contextOrOptions === void 0) ; else if ("context" in contextOrOptions) {
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7450
|
+
const shaped = contextOrOptions;
|
|
7451
|
+
context = shaped.context;
|
|
7452
|
+
subagentWrapping = shaped.subagentWrapping;
|
|
7453
|
+
tools = shaped.tools;
|
|
7454
|
+
} else if (("subagentWrapping" in contextOrOptions || "tools" in contextOrOptions) && !FLAT_CONTEXT_KEYS.some((k) => k in contextOrOptions)) {
|
|
7455
|
+
const shaped = contextOrOptions;
|
|
7456
|
+
subagentWrapping = shaped.subagentWrapping;
|
|
7457
|
+
tools = shaped.tools;
|
|
7276
7458
|
} else {
|
|
7277
7459
|
context = contextOrOptions;
|
|
7278
7460
|
}
|
|
@@ -7284,7 +7466,8 @@ function createRaindropAISDK(opts) {
|
|
|
7284
7466
|
subagentWrapping,
|
|
7285
7467
|
debug: envDebug,
|
|
7286
7468
|
settledEventIds,
|
|
7287
|
-
context
|
|
7469
|
+
context,
|
|
7470
|
+
tools
|
|
7288
7471
|
});
|
|
7289
7472
|
},
|
|
7290
7473
|
subagents: subagentApi,
|
|
@@ -7411,10 +7594,10 @@ function createRaindropAISDK(opts) {
|
|
|
7411
7594
|
}
|
|
7412
7595
|
function raindrop(options = {}) {
|
|
7413
7596
|
var _a;
|
|
7414
|
-
const { context, subagentWrapping, writeKey, ...rest } = options;
|
|
7597
|
+
const { context, subagentWrapping, tools, writeKey, ...rest } = options;
|
|
7415
7598
|
const resolvedWriteKey = writeKey != null ? writeKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.RAINDROP_WRITE_KEY : void 0;
|
|
7416
7599
|
const client = createRaindropAISDK({ ...rest, writeKey: resolvedWriteKey });
|
|
7417
|
-
return client.createTelemetryIntegration({ context, subagentWrapping });
|
|
7600
|
+
return client.createTelemetryIntegration({ context, subagentWrapping, tools });
|
|
7418
7601
|
}
|
|
7419
7602
|
|
|
7420
|
-
export { DEFAULT_MAX_TEXT_FIELD_CHARS2 as DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, DETACHED_MODE, HANDOFF_ATTRIBUTE_PREFIXES, HANDOFF_ATTRIBUTE_SUFFIXES, HANDOFF_TERMINAL_CANCELLED, HANDOFF_TERMINAL_PROPERTY_KEY, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, SUBAGENT_ABORTED_OUTPUT, SUBAGENT_AGENT_ROLE, SUBAGENT_CANCELLED_OUTPUT, TOOL_EVENTS_ALLOW, TRUNCATION_MARKER2 as TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText2 as capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, fromHeaders, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, resetUnresolvedCarrierWarning, runWithParentToolContext, runWithRaindropCallMetadata, toHeaders, toLangSmithHeaders, withCurrent };
|
|
7603
|
+
export { DEFAULT_MAX_TEXT_FIELD_CHARS2 as DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, DETACHED_MODE, HANDOFF_ATTRIBUTE_PREFIXES, HANDOFF_ATTRIBUTE_SUFFIXES, HANDOFF_TERMINAL_CANCELLED, HANDOFF_TERMINAL_PROPERTY_KEY, PROMPT_TOOLS_ATTRIBUTE, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, SUBAGENT_ABORTED_OUTPUT, SUBAGENT_AGENT_ROLE, SUBAGENT_CANCELLED_OUTPUT, TOOL_EVENTS_ALLOW, TRUNCATION_MARKER2 as TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText2 as capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, fromHeaders, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, resetUnresolvedCarrierWarning, runWithParentToolContext, runWithRaindropCallMetadata, toHeaders, toLangSmithHeaders, withCurrent };
|