@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
package/dist/index.browser.mjs
CHANGED
|
@@ -60,7 +60,7 @@ function evalScopeAttributes() {
|
|
|
60
60
|
return { [EVAL_CORRELATION_ID_ATTRIBUTE]: scope.correlationId };
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// ../core/dist/chunk-
|
|
63
|
+
// ../core/dist/chunk-I6TVJQEC.js
|
|
64
64
|
var STATE_KEY = /* @__PURE__ */ Symbol.for("raindrop.tracing.replayTraceRoutingState");
|
|
65
65
|
function state() {
|
|
66
66
|
const holder = globalThis;
|
|
@@ -2496,11 +2496,163 @@ var TraceShipper = class {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
}
|
|
2498
2498
|
};
|
|
2499
|
+
var PROMPT_TOOLS_ATTRIBUTE = "ai.prompt.tools";
|
|
2500
|
+
function isRecord(value) {
|
|
2501
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2502
|
+
}
|
|
2503
|
+
var JSON_SCHEMA_KEYS = [
|
|
2504
|
+
"type",
|
|
2505
|
+
"properties",
|
|
2506
|
+
"$schema",
|
|
2507
|
+
"$ref",
|
|
2508
|
+
"anyOf",
|
|
2509
|
+
"oneOf",
|
|
2510
|
+
"allOf",
|
|
2511
|
+
"enum",
|
|
2512
|
+
"const",
|
|
2513
|
+
"items",
|
|
2514
|
+
"additionalProperties",
|
|
2515
|
+
"required"
|
|
2516
|
+
];
|
|
2517
|
+
function isJsonSchema(value) {
|
|
2518
|
+
if (!isRecord(value)) return false;
|
|
2519
|
+
if (typeof value["~standard"] === "object") return false;
|
|
2520
|
+
if (isRecord(value._def) || isRecord(value._zod)) return false;
|
|
2521
|
+
if (Object.keys(value).length === 0) return true;
|
|
2522
|
+
return JSON_SCHEMA_KEYS.some((key) => key in value);
|
|
2523
|
+
}
|
|
2524
|
+
function toJsonSchema(value, options) {
|
|
2525
|
+
if (value === void 0 || value === null) return void 0;
|
|
2526
|
+
if (isJsonSchema(value)) return value;
|
|
2527
|
+
if (isRecord(value) && isJsonSchema(value.jsonSchema)) return value.jsonSchema;
|
|
2528
|
+
if (isRecord(value) && isJsonSchema(value.json)) return value.json;
|
|
2529
|
+
if (options == null ? void 0 : options.schema) {
|
|
2530
|
+
try {
|
|
2531
|
+
return options.schema(value);
|
|
2532
|
+
} catch (e) {
|
|
2533
|
+
return void 0;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
return void 0;
|
|
2537
|
+
}
|
|
2538
|
+
function pickString(value) {
|
|
2539
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
2540
|
+
}
|
|
2541
|
+
function functionTool(name, description, schema, options) {
|
|
2542
|
+
const tool = { type: "function", name };
|
|
2543
|
+
const desc = pickString(description);
|
|
2544
|
+
if (desc !== void 0) tool.description = desc;
|
|
2545
|
+
const inputSchema = toJsonSchema(schema, options);
|
|
2546
|
+
if (inputSchema !== void 0) tool.inputSchema = inputSchema;
|
|
2547
|
+
return tool;
|
|
2548
|
+
}
|
|
2549
|
+
function normalizeToolDeclaration(tool, options, fallbackName) {
|
|
2550
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2551
|
+
if (!isRecord(tool)) return void 0;
|
|
2552
|
+
if (tool.type === "provider-defined" || tool.type === "provider") {
|
|
2553
|
+
const name2 = (_b = (_a = pickString(tool.name)) != null ? _a : pickString(tool.id)) != null ? _b : fallbackName;
|
|
2554
|
+
if (name2 === void 0) return void 0;
|
|
2555
|
+
const declaration = { type: "provider-defined", name: name2 };
|
|
2556
|
+
const id = pickString(tool.id);
|
|
2557
|
+
if (id !== void 0) declaration.id = id;
|
|
2558
|
+
if (isRecord(tool.args)) declaration.args = tool.args;
|
|
2559
|
+
return declaration;
|
|
2560
|
+
}
|
|
2561
|
+
if (isRecord(tool.toolSpec)) {
|
|
2562
|
+
const spec = tool.toolSpec;
|
|
2563
|
+
const name2 = (_c = pickString(spec.name)) != null ? _c : fallbackName;
|
|
2564
|
+
if (name2 === void 0) return void 0;
|
|
2565
|
+
return functionTool(name2, spec.description, spec.inputSchema, options);
|
|
2566
|
+
}
|
|
2567
|
+
if (isRecord(tool.function)) {
|
|
2568
|
+
const fn = tool.function;
|
|
2569
|
+
const name2 = (_d = pickString(fn.name)) != null ? _d : fallbackName;
|
|
2570
|
+
if (name2 === void 0) return void 0;
|
|
2571
|
+
return functionTool(name2, fn.description, (_e = fn.parameters) != null ? _e : fn.input_schema, options);
|
|
2572
|
+
}
|
|
2573
|
+
const name = (_g = (_f = pickString(tool.name)) != null ? _f : pickString(tool.id)) != null ? _g : fallbackName;
|
|
2574
|
+
if (name === void 0) return void 0;
|
|
2575
|
+
const type = pickString(tool.type);
|
|
2576
|
+
if (type !== void 0 && type !== "function" && type !== "dynamic" && type !== "custom") {
|
|
2577
|
+
if (!("input_schema" in tool) && !("inputSchema" in tool) && !("parameters" in tool)) {
|
|
2578
|
+
return { type: "provider-defined", id: type, name };
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
return functionTool(
|
|
2582
|
+
name,
|
|
2583
|
+
tool.description,
|
|
2584
|
+
(_j = (_i = (_h = tool.inputSchema) != null ? _h : tool.input_schema) != null ? _i : tool.parameters) != null ? _j : tool.schema,
|
|
2585
|
+
options
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
var NOT_A_GEMINI_GROUP_KEYS = ["name", "id", "type", "function", "toolSpec", "cachePoint"];
|
|
2589
|
+
function isGeminiToolGroup(tool) {
|
|
2590
|
+
if (Array.isArray(tool.functionDeclarations)) return true;
|
|
2591
|
+
const keys = Object.keys(tool);
|
|
2592
|
+
if (keys.length === 0 || NOT_A_GEMINI_GROUP_KEYS.some((key) => key in tool)) return false;
|
|
2593
|
+
return keys.every((key) => isRecord(tool[key]));
|
|
2594
|
+
}
|
|
2595
|
+
function expandGeminiTool(tool, options) {
|
|
2596
|
+
const declarations = [];
|
|
2597
|
+
for (const [key, value] of Object.entries(tool)) {
|
|
2598
|
+
if (key === "functionDeclarations" && Array.isArray(value)) {
|
|
2599
|
+
for (const declaration of value) {
|
|
2600
|
+
const normalized = normalizeToolDeclaration(declaration, options);
|
|
2601
|
+
if (normalized) declarations.push(normalized);
|
|
2602
|
+
}
|
|
2603
|
+
} else if (isRecord(value)) {
|
|
2604
|
+
declarations.push({ type: "provider-defined", id: key, name: key, args: value });
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
return declarations;
|
|
2608
|
+
}
|
|
2609
|
+
function normalizeToolDeclarations(tools, options) {
|
|
2610
|
+
if (tools === void 0 || tools === null) return void 0;
|
|
2611
|
+
if (Array.isArray(tools)) {
|
|
2612
|
+
return tools.flatMap((tool) => {
|
|
2613
|
+
if (isRecord(tool) && isGeminiToolGroup(tool)) {
|
|
2614
|
+
return expandGeminiTool(tool, options);
|
|
2615
|
+
}
|
|
2616
|
+
const declaration = normalizeToolDeclaration(tool, options);
|
|
2617
|
+
return declaration ? [declaration] : [];
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
if (!isRecord(tools)) return void 0;
|
|
2621
|
+
return Object.entries(tools).flatMap(([key, tool]) => {
|
|
2622
|
+
const declaration = normalizeToolDeclaration(tool, options, key);
|
|
2623
|
+
return declaration ? [declaration] : [];
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
function resolvePromptTools(args) {
|
|
2627
|
+
var _a;
|
|
2628
|
+
if (args.override !== void 0) {
|
|
2629
|
+
return (_a = normalizeToolDeclarations(args.override, args.options)) != null ? _a : [];
|
|
2630
|
+
}
|
|
2631
|
+
return normalizeToolDeclarations(args.inferred, args.options);
|
|
2632
|
+
}
|
|
2633
|
+
function promptToolsAttribute(tools) {
|
|
2634
|
+
const values = promptToolsAttributeValue(tools);
|
|
2635
|
+
if (values === void 0) return void 0;
|
|
2636
|
+
return {
|
|
2637
|
+
key: PROMPT_TOOLS_ATTRIBUTE,
|
|
2638
|
+
value: { arrayValue: { values: values.map((stringValue) => ({ stringValue })) } }
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
function promptToolsAttributeValue(tools) {
|
|
2642
|
+
if (tools === void 0) return void 0;
|
|
2643
|
+
return tools.map((tool) => {
|
|
2644
|
+
try {
|
|
2645
|
+
return JSON.stringify(tool);
|
|
2646
|
+
} catch (e) {
|
|
2647
|
+
return JSON.stringify({ type: tool.type, name: tool.name });
|
|
2648
|
+
}
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2499
2651
|
|
|
2500
2652
|
// package.json
|
|
2501
2653
|
var package_default = {
|
|
2502
2654
|
name: "@raindrop-ai/ai-sdk",
|
|
2503
|
-
version: "0.3.
|
|
2655
|
+
version: "0.3.4"};
|
|
2504
2656
|
|
|
2505
2657
|
// src/internal/version.ts
|
|
2506
2658
|
var libraryName = package_default.name;
|
|
@@ -2647,7 +2799,7 @@ function boundedStringify(value, limit) {
|
|
|
2647
2799
|
}
|
|
2648
2800
|
|
|
2649
2801
|
// src/internal/wrap/helpers.ts
|
|
2650
|
-
function
|
|
2802
|
+
function isRecord2(value) {
|
|
2651
2803
|
return typeof value === "object" && value !== null;
|
|
2652
2804
|
}
|
|
2653
2805
|
function isFunction(value) {
|
|
@@ -2686,7 +2838,7 @@ function extractModelInfo(model) {
|
|
|
2686
2838
|
}
|
|
2687
2839
|
return { modelId: model };
|
|
2688
2840
|
}
|
|
2689
|
-
if (!
|
|
2841
|
+
if (!isRecord2(model)) return {};
|
|
2690
2842
|
const provider = typeof model["provider"] === "string" ? model["provider"] : void 0;
|
|
2691
2843
|
let modelIdRaw;
|
|
2692
2844
|
if (typeof model["modelId"] === "string") {
|
|
@@ -2707,13 +2859,13 @@ function extractModelInfo(model) {
|
|
|
2707
2859
|
return { provider, modelId: modelIdRaw };
|
|
2708
2860
|
}
|
|
2709
2861
|
function extractTextOutput(result) {
|
|
2710
|
-
if (!
|
|
2862
|
+
if (!isRecord2(result)) return void 0;
|
|
2711
2863
|
const text = result["text"];
|
|
2712
2864
|
return typeof text === "string" ? text : void 0;
|
|
2713
2865
|
}
|
|
2714
2866
|
function extractObjectOutput(result) {
|
|
2715
2867
|
var _a;
|
|
2716
|
-
if (!
|
|
2868
|
+
if (!isRecord2(result)) return void 0;
|
|
2717
2869
|
const obj = result["object"];
|
|
2718
2870
|
if (obj === void 0) return void 0;
|
|
2719
2871
|
return (_a = safeJson(obj)) != null ? _a : String(obj);
|
|
@@ -2721,24 +2873,24 @@ function extractObjectOutput(result) {
|
|
|
2721
2873
|
function isAgentClass(value) {
|
|
2722
2874
|
if (typeof value !== "function") return false;
|
|
2723
2875
|
const proto = value.prototype;
|
|
2724
|
-
if (!
|
|
2876
|
+
if (!isRecord2(proto)) return false;
|
|
2725
2877
|
return typeof proto["generate"] === "function" && typeof proto["stream"] === "function";
|
|
2726
2878
|
}
|
|
2727
2879
|
function extractModel(result) {
|
|
2728
|
-
if (!
|
|
2880
|
+
if (!isRecord2(result)) return void 0;
|
|
2729
2881
|
const model = result["model"];
|
|
2730
2882
|
if (typeof model === "string" && model.length) return model;
|
|
2731
2883
|
const response = result["response"];
|
|
2732
|
-
if (
|
|
2884
|
+
if (isRecord2(response)) {
|
|
2733
2885
|
const modelId = response["modelId"];
|
|
2734
2886
|
if (typeof modelId === "string" && modelId.length) return modelId;
|
|
2735
2887
|
}
|
|
2736
2888
|
return void 0;
|
|
2737
2889
|
}
|
|
2738
2890
|
function extractFinishReason(result) {
|
|
2739
|
-
if (!
|
|
2891
|
+
if (!isRecord2(result)) return void 0;
|
|
2740
2892
|
if (typeof result["finishReason"] === "string") return result["finishReason"];
|
|
2741
|
-
if (
|
|
2893
|
+
if (isRecord2(result["finishReason"]) && typeof result["finishReason"]["unified"] === "string") {
|
|
2742
2894
|
return result["finishReason"]["unified"];
|
|
2743
2895
|
}
|
|
2744
2896
|
return void 0;
|
|
@@ -2782,7 +2934,7 @@ function attachmentMediaType(part) {
|
|
|
2782
2934
|
if (typeof part["mediaType"] === "string") return part["mediaType"];
|
|
2783
2935
|
if (typeof part["mimeType"] === "string") return part["mimeType"];
|
|
2784
2936
|
const file = part["file"];
|
|
2785
|
-
if (
|
|
2937
|
+
if (isRecord2(file)) {
|
|
2786
2938
|
if (typeof file["mediaType"] === "string") return file["mediaType"];
|
|
2787
2939
|
if (typeof file["mimeType"] === "string") return file["mimeType"];
|
|
2788
2940
|
}
|
|
@@ -2792,7 +2944,7 @@ function attachmentName(part) {
|
|
|
2792
2944
|
if (typeof part["filename"] === "string") return part["filename"];
|
|
2793
2945
|
if (typeof part["name"] === "string") return part["name"];
|
|
2794
2946
|
const file = part["file"];
|
|
2795
|
-
if (
|
|
2947
|
+
if (isRecord2(file)) {
|
|
2796
2948
|
if (typeof file["filename"] === "string") return file["filename"];
|
|
2797
2949
|
if (typeof file["name"] === "string") return file["name"];
|
|
2798
2950
|
}
|
|
@@ -2801,7 +2953,7 @@ function attachmentName(part) {
|
|
|
2801
2953
|
function attachmentData(part) {
|
|
2802
2954
|
if ("data" in part) return part["data"];
|
|
2803
2955
|
const file = part["file"];
|
|
2804
|
-
if (
|
|
2956
|
+
if (isRecord2(file)) {
|
|
2805
2957
|
if ("file_data" in file) return file["file_data"];
|
|
2806
2958
|
if ("data" in file) return file["data"];
|
|
2807
2959
|
}
|
|
@@ -2819,7 +2971,7 @@ function contentPartToAttachment(part, role) {
|
|
|
2819
2971
|
}
|
|
2820
2972
|
if (partType === "image_url") {
|
|
2821
2973
|
const imageUrlPart = part["image_url"];
|
|
2822
|
-
const imageUrlValue =
|
|
2974
|
+
const imageUrlValue = isRecord2(imageUrlPart) ? imageUrlPart["url"] : imageUrlPart;
|
|
2823
2975
|
const value = asDataUrl(imageUrlValue, "image/png");
|
|
2824
2976
|
if (!value) return void 0;
|
|
2825
2977
|
return { type: "image", role, value };
|
|
@@ -2839,7 +2991,7 @@ function attachmentsFromContent(content, role) {
|
|
|
2839
2991
|
if (!Array.isArray(content)) return void 0;
|
|
2840
2992
|
const attachments = [];
|
|
2841
2993
|
for (const part of content) {
|
|
2842
|
-
if (!
|
|
2994
|
+
if (!isRecord2(part)) continue;
|
|
2843
2995
|
const attachment = contentPartToAttachment(part, role);
|
|
2844
2996
|
if (attachment) attachments.push(attachment);
|
|
2845
2997
|
}
|
|
@@ -2872,7 +3024,7 @@ async function outputAttachmentsFromFiles(files) {
|
|
|
2872
3024
|
if (!Array.isArray(resolvedFiles)) return void 0;
|
|
2873
3025
|
const attachments = [];
|
|
2874
3026
|
for (const file of resolvedFiles) {
|
|
2875
|
-
if (!
|
|
3027
|
+
if (!isRecord2(file)) continue;
|
|
2876
3028
|
const attachment = generatedFileToAttachment(file);
|
|
2877
3029
|
if (attachment) attachments.push(attachment);
|
|
2878
3030
|
}
|
|
@@ -2883,7 +3035,7 @@ function extractTextFromMessageContent(content) {
|
|
|
2883
3035
|
if (!Array.isArray(content)) return void 0;
|
|
2884
3036
|
let result = "";
|
|
2885
3037
|
for (const part of content) {
|
|
2886
|
-
if (!
|
|
3038
|
+
if (!isRecord2(part) || part["type"] !== "text" || typeof part["text"] !== "string") continue;
|
|
2887
3039
|
result += part["text"];
|
|
2888
3040
|
}
|
|
2889
3041
|
return result.length ? result : void 0;
|
|
@@ -2900,7 +3052,7 @@ function lastUserMessageFromArgs(args) {
|
|
|
2900
3052
|
if (!messages) return void 0;
|
|
2901
3053
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2902
3054
|
const message = messages[i];
|
|
2903
|
-
if (
|
|
3055
|
+
if (isRecord2(message) && message["role"] === "user") {
|
|
2904
3056
|
return message;
|
|
2905
3057
|
}
|
|
2906
3058
|
}
|
|
@@ -2908,24 +3060,24 @@ function lastUserMessageFromArgs(args) {
|
|
|
2908
3060
|
}
|
|
2909
3061
|
function extractInputAttachmentsFromArgs(args) {
|
|
2910
3062
|
var _a;
|
|
2911
|
-
if (!
|
|
3063
|
+
if (!isRecord2(args)) return void 0;
|
|
2912
3064
|
return attachmentsFromContent((_a = lastUserMessageFromArgs(args)) == null ? void 0 : _a["content"], "input");
|
|
2913
3065
|
}
|
|
2914
3066
|
async function extractOutputAttachmentsFromResult(result) {
|
|
2915
|
-
if (!
|
|
3067
|
+
if (!isRecord2(result)) return void 0;
|
|
2916
3068
|
const fileAttachments = await outputAttachmentsFromFiles(result["files"]);
|
|
2917
3069
|
if (fileAttachments == null ? void 0 : fileAttachments.length) return fileAttachments;
|
|
2918
3070
|
const responseMessages = extractResponseMessages(result);
|
|
2919
3071
|
for (let i = responseMessages.length - 1; i >= 0; i--) {
|
|
2920
3072
|
const message = responseMessages[i];
|
|
2921
|
-
if (!
|
|
3073
|
+
if (!isRecord2(message) || message["role"] !== "assistant") continue;
|
|
2922
3074
|
return attachmentsFromContent(message["content"], "output");
|
|
2923
3075
|
}
|
|
2924
3076
|
return attachmentsFromContent(result["content"], "output");
|
|
2925
3077
|
}
|
|
2926
3078
|
function lastUserMessageTextFromArgs(args) {
|
|
2927
3079
|
var _a, _b;
|
|
2928
|
-
if (!
|
|
3080
|
+
if (!isRecord2(args)) return void 0;
|
|
2929
3081
|
const content = (_a = lastUserMessageFromArgs(args)) == null ? void 0 : _a["content"];
|
|
2930
3082
|
if (content === void 0) return void 0;
|
|
2931
3083
|
const text = extractTextFromMessageContent(content);
|
|
@@ -2934,13 +3086,13 @@ function lastUserMessageTextFromArgs(args) {
|
|
|
2934
3086
|
}
|
|
2935
3087
|
function extractInputFromArgs(args) {
|
|
2936
3088
|
var _a;
|
|
2937
|
-
if (!
|
|
3089
|
+
if (!isRecord2(args)) return void 0;
|
|
2938
3090
|
const prompt = args["prompt"];
|
|
2939
3091
|
if (typeof prompt === "string") return prompt;
|
|
2940
3092
|
const messages = messagesFromArgs(args);
|
|
2941
3093
|
if (Array.isArray(messages) && messages.length > 0) {
|
|
2942
3094
|
const last = messages[messages.length - 1];
|
|
2943
|
-
if (
|
|
3095
|
+
if (isRecord2(last)) {
|
|
2944
3096
|
const content = last["content"];
|
|
2945
3097
|
const text = extractTextFromMessageContent(content);
|
|
2946
3098
|
if (text !== void 0) return text;
|
|
@@ -2954,7 +3106,7 @@ function extractInputFromArgs(args) {
|
|
|
2954
3106
|
return safeJson(args);
|
|
2955
3107
|
}
|
|
2956
3108
|
function coerceMessagesFromArgs(args) {
|
|
2957
|
-
if (!
|
|
3109
|
+
if (!isRecord2(args)) return [];
|
|
2958
3110
|
const result = [];
|
|
2959
3111
|
if (typeof args["system"] === "string" && args["system"]) {
|
|
2960
3112
|
result.push({ role: "system", content: args["system"] });
|
|
@@ -2962,7 +3114,7 @@ function coerceMessagesFromArgs(args) {
|
|
|
2962
3114
|
const messages = messagesFromArgs(args);
|
|
2963
3115
|
if (Array.isArray(messages)) {
|
|
2964
3116
|
for (const message of messages) {
|
|
2965
|
-
if (
|
|
3117
|
+
if (isRecord2(message) && typeof message["role"] === "string") {
|
|
2966
3118
|
result.push(message);
|
|
2967
3119
|
}
|
|
2968
3120
|
}
|
|
@@ -2974,21 +3126,21 @@ function coerceMessagesFromArgs(args) {
|
|
|
2974
3126
|
return result;
|
|
2975
3127
|
}
|
|
2976
3128
|
function extractResponseMessages(result) {
|
|
2977
|
-
if (!
|
|
3129
|
+
if (!isRecord2(result)) return [];
|
|
2978
3130
|
const response = result["response"];
|
|
2979
|
-
if (
|
|
3131
|
+
if (isRecord2(response) && Array.isArray(response["messages"])) {
|
|
2980
3132
|
return response["messages"].filter(
|
|
2981
|
-
(message) =>
|
|
3133
|
+
(message) => isRecord2(message) && typeof message["role"] === "string" && "content" in message
|
|
2982
3134
|
).map((message) => message);
|
|
2983
3135
|
}
|
|
2984
3136
|
const steps = result["steps"];
|
|
2985
3137
|
if (Array.isArray(steps) && steps.length > 0) {
|
|
2986
3138
|
const lastStep = steps[steps.length - 1];
|
|
2987
|
-
if (
|
|
3139
|
+
if (isRecord2(lastStep) && isRecord2(lastStep["response"])) {
|
|
2988
3140
|
const responseMessages = lastStep["response"]["messages"];
|
|
2989
3141
|
if (Array.isArray(responseMessages)) {
|
|
2990
3142
|
return responseMessages.filter(
|
|
2991
|
-
(message) =>
|
|
3143
|
+
(message) => isRecord2(message) && typeof message["role"] === "string" && "content" in message
|
|
2992
3144
|
).map((message) => message);
|
|
2993
3145
|
}
|
|
2994
3146
|
}
|
|
@@ -3009,7 +3161,7 @@ function isTranscriptToolResultError(part, result) {
|
|
|
3009
3161
|
if (part["isError"] === true || part["type"] === "tool-error") {
|
|
3010
3162
|
return true;
|
|
3011
3163
|
}
|
|
3012
|
-
if (
|
|
3164
|
+
if (isRecord2(result) && typeof result["type"] === "string") {
|
|
3013
3165
|
return result["type"].startsWith("error") || result["type"] === "execution-denied";
|
|
3014
3166
|
}
|
|
3015
3167
|
return false;
|
|
@@ -3018,7 +3170,7 @@ function getTranscriptToolErrorMessage(result) {
|
|
|
3018
3170
|
if (typeof result === "string" && result.length > 0) {
|
|
3019
3171
|
return result;
|
|
3020
3172
|
}
|
|
3021
|
-
if (
|
|
3173
|
+
if (isRecord2(result)) {
|
|
3022
3174
|
if (typeof result["value"] === "string" && result["value"].length > 0) {
|
|
3023
3175
|
return result["value"];
|
|
3024
3176
|
}
|
|
@@ -3032,12 +3184,12 @@ function getTranscriptToolErrorMessage(result) {
|
|
|
3032
3184
|
return safeJsonWithUint8(result);
|
|
3033
3185
|
}
|
|
3034
3186
|
function getTranscriptMessageParts(message) {
|
|
3035
|
-
if (!
|
|
3187
|
+
if (!isRecord2(message)) return [];
|
|
3036
3188
|
const content = message["content"];
|
|
3037
3189
|
if (Array.isArray(content)) {
|
|
3038
|
-
return content.filter(
|
|
3190
|
+
return content.filter(isRecord2);
|
|
3039
3191
|
}
|
|
3040
|
-
return
|
|
3192
|
+
return isRecord2(content) ? [content] : [];
|
|
3041
3193
|
}
|
|
3042
3194
|
function getTranscriptToolCallInput(part) {
|
|
3043
3195
|
return "input" in part ? part["input"] : "args" in part ? part["args"] : void 0;
|
|
@@ -3138,7 +3290,7 @@ function extractTextFromLmContent(content) {
|
|
|
3138
3290
|
if (!Array.isArray(content)) return void 0;
|
|
3139
3291
|
let result = "";
|
|
3140
3292
|
for (const part of content) {
|
|
3141
|
-
if (
|
|
3293
|
+
if (isRecord2(part) && part["type"] === "text" && typeof part["text"] === "string") {
|
|
3142
3294
|
result += part["text"];
|
|
3143
3295
|
}
|
|
3144
3296
|
}
|
|
@@ -3148,7 +3300,7 @@ function extractToolCallsFromLmContent(content) {
|
|
|
3148
3300
|
if (!Array.isArray(content)) return void 0;
|
|
3149
3301
|
const calls = [];
|
|
3150
3302
|
for (const part of content) {
|
|
3151
|
-
if (!
|
|
3303
|
+
if (!isRecord2(part) || part["type"] !== "tool-call") continue;
|
|
3152
3304
|
const toolCallId = getTranscriptToolCallId(part);
|
|
3153
3305
|
const toolName = typeof part["toolName"] === "string" ? part["toolName"] : void 0;
|
|
3154
3306
|
if (toolCallId || toolName) {
|
|
@@ -3158,15 +3310,15 @@ function extractToolCallsFromLmContent(content) {
|
|
|
3158
3310
|
return calls.length ? calls : void 0;
|
|
3159
3311
|
}
|
|
3160
3312
|
function extractExperimentalTelemetry(args) {
|
|
3161
|
-
if (!
|
|
3313
|
+
if (!isRecord2(args)) return void 0;
|
|
3162
3314
|
const telemetryConfig = args["experimental_telemetry"];
|
|
3163
|
-
if (!
|
|
3315
|
+
if (!isRecord2(telemetryConfig)) return void 0;
|
|
3164
3316
|
return {
|
|
3165
3317
|
functionId: typeof telemetryConfig["functionId"] === "string" ? telemetryConfig["functionId"] : void 0,
|
|
3166
3318
|
isEnabled: typeof telemetryConfig["isEnabled"] === "boolean" ? telemetryConfig["isEnabled"] : void 0,
|
|
3167
3319
|
recordInputs: typeof telemetryConfig["recordInputs"] === "boolean" ? telemetryConfig["recordInputs"] : void 0,
|
|
3168
3320
|
recordOutputs: typeof telemetryConfig["recordOutputs"] === "boolean" ? telemetryConfig["recordOutputs"] : void 0,
|
|
3169
|
-
metadata:
|
|
3321
|
+
metadata: isRecord2(telemetryConfig["metadata"]) ? telemetryConfig["metadata"] : void 0
|
|
3170
3322
|
};
|
|
3171
3323
|
}
|
|
3172
3324
|
function opName(operationId, functionId) {
|
|
@@ -3194,7 +3346,7 @@ function attrsFromTelemetryMetadata(metadata) {
|
|
|
3194
3346
|
});
|
|
3195
3347
|
}
|
|
3196
3348
|
function attrsFromHeaders(headers) {
|
|
3197
|
-
if (!
|
|
3349
|
+
if (!isRecord2(headers)) return [];
|
|
3198
3350
|
return Object.entries(headers).filter(([, v]) => typeof v === "string").map(([k, v]) => attrString(`ai.request.headers.${k}`, v));
|
|
3199
3351
|
}
|
|
3200
3352
|
function attrsFromModelProvider(provider) {
|
|
@@ -3207,7 +3359,7 @@ function attrsFromModelProvider(provider) {
|
|
|
3207
3359
|
];
|
|
3208
3360
|
}
|
|
3209
3361
|
function attrsFromSettings(args) {
|
|
3210
|
-
if (!
|
|
3362
|
+
if (!isRecord2(args)) return [];
|
|
3211
3363
|
const result = [];
|
|
3212
3364
|
const settingKeys = [
|
|
3213
3365
|
"maxRetries",
|
|
@@ -3235,7 +3387,7 @@ function attrsFromSettings(args) {
|
|
|
3235
3387
|
return result;
|
|
3236
3388
|
}
|
|
3237
3389
|
function attrsFromGenAiRequest(options) {
|
|
3238
|
-
if (!
|
|
3390
|
+
if (!isRecord2(options)) return [];
|
|
3239
3391
|
return [
|
|
3240
3392
|
attrDouble(
|
|
3241
3393
|
"gen_ai.request.frequency_penalty",
|
|
@@ -3265,7 +3417,7 @@ function attrsFromGenAiRequest(options) {
|
|
|
3265
3417
|
];
|
|
3266
3418
|
}
|
|
3267
3419
|
function attrProviderOptions(options) {
|
|
3268
|
-
if (!
|
|
3420
|
+
if (!isRecord2(options) || !isRecord2(options["providerOptions"])) return void 0;
|
|
3269
3421
|
const json = safeJsonWithUint8(options["providerOptions"]);
|
|
3270
3422
|
return json ? attrString("ai.request.providerOptions", json) : void 0;
|
|
3271
3423
|
}
|
|
@@ -3307,10 +3459,10 @@ function readRaindropCallMetadataFromArgs(args) {
|
|
|
3307
3459
|
var _a;
|
|
3308
3460
|
if (args.length === 0) return void 0;
|
|
3309
3461
|
const first = args[0];
|
|
3310
|
-
if (!
|
|
3311
|
-
const topLevel =
|
|
3312
|
-
const stable =
|
|
3313
|
-
const stableMetadata =
|
|
3462
|
+
if (!isRecord2(first)) return void 0;
|
|
3463
|
+
const topLevel = isRecord2(first["metadata"]) ? first["metadata"] : void 0;
|
|
3464
|
+
const stable = isRecord2(first["telemetry"]) ? first["telemetry"]["metadata"] : void 0;
|
|
3465
|
+
const stableMetadata = isRecord2(stable) ? stable : void 0;
|
|
3314
3466
|
const exp = extractExperimentalTelemetry(first);
|
|
3315
3467
|
const expMetadata = (exp == null ? void 0 : exp.metadata) && typeof exp.metadata === "object" ? exp.metadata : void 0;
|
|
3316
3468
|
const raw = (_a = topLevel != null ? topLevel : stableMetadata) != null ? _a : expMetadata;
|
|
@@ -3750,38 +3902,38 @@ var CACHE_WRITE_METADATA_KEYS = [
|
|
|
3750
3902
|
["bedrock", "cacheWriteInputTokens"]
|
|
3751
3903
|
];
|
|
3752
3904
|
function cacheWriteTokensFromProviderMetadata(providerMetadata) {
|
|
3753
|
-
if (!
|
|
3905
|
+
if (!isRecord2(providerMetadata)) return void 0;
|
|
3754
3906
|
return firstTokenCount(
|
|
3755
3907
|
...CACHE_WRITE_METADATA_KEYS.flatMap(([namespace, key]) => {
|
|
3756
3908
|
const scope = providerMetadata[namespace];
|
|
3757
|
-
if (!
|
|
3909
|
+
if (!isRecord2(scope)) return [];
|
|
3758
3910
|
const usage = scope["usage"];
|
|
3759
|
-
return [scope[key],
|
|
3911
|
+
return [scope[key], isRecord2(usage) ? usage[key] : void 0];
|
|
3760
3912
|
})
|
|
3761
3913
|
);
|
|
3762
3914
|
}
|
|
3763
3915
|
function extractUsageMetricsFromUsage(usage, _provider, providerMetadata) {
|
|
3764
|
-
if (!
|
|
3916
|
+
if (!isRecord2(usage)) return {};
|
|
3765
3917
|
const inputTokenValue = usage["inputTokens"];
|
|
3766
3918
|
const outputTokenValue = usage["outputTokens"];
|
|
3767
3919
|
const inputTokenDetails = usage["inputTokenDetails"];
|
|
3768
3920
|
const outputTokenDetails = usage["outputTokenDetails"];
|
|
3769
|
-
const hasStructuredUsage =
|
|
3921
|
+
const hasStructuredUsage = isRecord2(inputTokenValue) || isRecord2(outputTokenValue) || isRecord2(inputTokenDetails) || isRecord2(outputTokenDetails);
|
|
3770
3922
|
const inputTokens = firstTokenCount(
|
|
3771
|
-
|
|
3923
|
+
isRecord2(inputTokenValue) ? inputTokenValue["total"] : void 0,
|
|
3772
3924
|
inputTokenValue,
|
|
3773
3925
|
usage["promptTokens"],
|
|
3774
3926
|
usage["prompt_tokens"]
|
|
3775
3927
|
);
|
|
3776
3928
|
const outputTokens = firstTokenCount(
|
|
3777
|
-
|
|
3929
|
+
isRecord2(outputTokenValue) ? outputTokenValue["total"] : void 0,
|
|
3778
3930
|
outputTokenValue,
|
|
3779
3931
|
usage["completionTokens"],
|
|
3780
3932
|
usage["completion_tokens"]
|
|
3781
3933
|
);
|
|
3782
3934
|
const reasoningTokens = firstTokenCount(
|
|
3783
|
-
|
|
3784
|
-
|
|
3935
|
+
isRecord2(outputTokenValue) ? outputTokenValue["reasoning"] : void 0,
|
|
3936
|
+
isRecord2(outputTokenDetails) ? outputTokenDetails["reasoningTokens"] : void 0,
|
|
3785
3937
|
usage["reasoningTokens"],
|
|
3786
3938
|
usage["completionReasoningTokens"],
|
|
3787
3939
|
usage["completion_reasoning_tokens"],
|
|
@@ -3790,27 +3942,27 @@ function extractUsageMetricsFromUsage(usage, _provider, providerMetadata) {
|
|
|
3790
3942
|
usage["thinking_tokens"]
|
|
3791
3943
|
);
|
|
3792
3944
|
const cacheReadInputTokens = firstTokenCount(
|
|
3793
|
-
|
|
3794
|
-
|
|
3945
|
+
isRecord2(inputTokenValue) ? inputTokenValue["cacheRead"] : void 0,
|
|
3946
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["cacheReadTokens"] : void 0,
|
|
3795
3947
|
usage["cachedInputTokens"],
|
|
3796
3948
|
usage["promptCachedTokens"],
|
|
3797
3949
|
usage["prompt_cached_tokens"]
|
|
3798
3950
|
);
|
|
3799
3951
|
const cacheWriteInputTokens = firstTokenCount(
|
|
3800
|
-
|
|
3801
|
-
|
|
3952
|
+
isRecord2(inputTokenValue) ? inputTokenValue["cacheWrite"] : void 0,
|
|
3953
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["cacheWriteTokens"] : void 0,
|
|
3802
3954
|
usage["cacheWriteInputTokens"],
|
|
3803
3955
|
usage["cacheCreationInputTokens"],
|
|
3804
3956
|
usage["cache_creation_input_tokens"],
|
|
3805
3957
|
cacheWriteTokensFromProviderMetadata(providerMetadata)
|
|
3806
3958
|
);
|
|
3807
3959
|
const nonCachedInputTokens = firstTokenCount(
|
|
3808
|
-
|
|
3809
|
-
|
|
3960
|
+
isRecord2(inputTokenValue) ? inputTokenValue["noCache"] : void 0,
|
|
3961
|
+
isRecord2(inputTokenDetails) ? inputTokenDetails["noCacheTokens"] : void 0
|
|
3810
3962
|
);
|
|
3811
3963
|
const nonReasoningOutputTokens = firstTokenCount(
|
|
3812
|
-
|
|
3813
|
-
|
|
3964
|
+
isRecord2(outputTokenValue) ? outputTokenValue["text"] : void 0,
|
|
3965
|
+
isRecord2(outputTokenDetails) ? outputTokenDetails["textTokens"] : void 0
|
|
3814
3966
|
);
|
|
3815
3967
|
const totalTokens = firstTokenCount(
|
|
3816
3968
|
usage["totalTokens"],
|
|
@@ -4036,17 +4188,10 @@ var RaindropTelemetryIntegration = class {
|
|
|
4036
4188
|
if (event.promptMessages) {
|
|
4037
4189
|
inputAttrs.push(attrString("ai.prompt.messages", safeJsonWithUint8(event.promptMessages)));
|
|
4038
4190
|
}
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
event.stepTools.map((t) => {
|
|
4044
|
-
var _a;
|
|
4045
|
-
return (_a = safeJsonWithUint8(t)) != null ? _a : "";
|
|
4046
|
-
})
|
|
4047
|
-
)
|
|
4048
|
-
);
|
|
4049
|
-
}
|
|
4191
|
+
const promptTools = promptToolsAttribute(
|
|
4192
|
+
resolvePromptTools({ override: this.promptTools, inferred: event.stepTools })
|
|
4193
|
+
);
|
|
4194
|
+
if (promptTools) inputAttrs.push(promptTools);
|
|
4050
4195
|
if (event.stepToolChoice != null) {
|
|
4051
4196
|
inputAttrs.push(
|
|
4052
4197
|
attrString("ai.prompt.toolChoice", safeJsonWithUint8(event.stepToolChoice))
|
|
@@ -4394,6 +4539,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
4394
4539
|
this.subagentWrapping = opts.subagentWrapping !== false;
|
|
4395
4540
|
this.debug = opts.debug === true;
|
|
4396
4541
|
this.defaultContext = opts.context;
|
|
4542
|
+
this.promptTools = opts.tools;
|
|
4397
4543
|
this.subagents = new SubagentApi({
|
|
4398
4544
|
traceShipper: this.traceShipper,
|
|
4399
4545
|
eventShipper: this.eventShipper,
|
|
@@ -5032,6 +5178,18 @@ var TraceShipper2 = class extends TraceShipper {
|
|
|
5032
5178
|
};
|
|
5033
5179
|
|
|
5034
5180
|
// src/internal/wrap/wrapAISDK.ts
|
|
5181
|
+
function promptToolsOptionsFrom(aiSDK) {
|
|
5182
|
+
if (!isRecord2(aiSDK)) return void 0;
|
|
5183
|
+
const asSchema = aiSDK["asSchema"];
|
|
5184
|
+
if (!isFunction(asSchema)) return void 0;
|
|
5185
|
+
return {
|
|
5186
|
+
schema: (schema) => {
|
|
5187
|
+
const converted = asSchema(schema);
|
|
5188
|
+
const json = isRecord2(converted) ? converted["jsonSchema"] : void 0;
|
|
5189
|
+
return isRecord2(json) ? json : void 0;
|
|
5190
|
+
}
|
|
5191
|
+
};
|
|
5192
|
+
}
|
|
5035
5193
|
var pendingStoresByShipper = /* @__PURE__ */ new WeakMap();
|
|
5036
5194
|
var PendingToolSpanStore = class _PendingToolSpanStore {
|
|
5037
5195
|
constructor() {
|
|
@@ -5088,9 +5246,9 @@ function _resetWarnedMissingUserId() {
|
|
|
5088
5246
|
warnedMissingUserId = false;
|
|
5089
5247
|
}
|
|
5090
5248
|
function extractRaindropCallOptions(options) {
|
|
5091
|
-
if (!
|
|
5249
|
+
if (!isRecord2(options)) return {};
|
|
5092
5250
|
const em = options["metadata"];
|
|
5093
|
-
if (
|
|
5251
|
+
if (isRecord2(em)) return extractRaindropMetadata(em);
|
|
5094
5252
|
const telemetry = extractExperimentalTelemetry(options);
|
|
5095
5253
|
if (telemetry == null ? void 0 : telemetry.metadata) return extractRaindropMetadata(telemetry.metadata);
|
|
5096
5254
|
return {};
|
|
@@ -5152,20 +5310,20 @@ function mergeContexts(wrapTime, callTime) {
|
|
|
5152
5310
|
return result;
|
|
5153
5311
|
}
|
|
5154
5312
|
function detectAISDKVersion(aiSDK) {
|
|
5155
|
-
if (!
|
|
5313
|
+
if (!isRecord2(aiSDK)) return "unknown";
|
|
5156
5314
|
if (isFunction(aiSDK["jsonSchema"])) return "6";
|
|
5157
5315
|
if (isFunction(aiSDK["tool"])) return "5";
|
|
5158
5316
|
return "4";
|
|
5159
5317
|
}
|
|
5160
5318
|
function hasStructuredTelemetryEvents(aiSDK) {
|
|
5161
|
-
if (!
|
|
5319
|
+
if (!isRecord2(aiSDK)) return false;
|
|
5162
5320
|
const hasRegister = isFunction(aiSDK["registerTelemetry"]) || isFunction(aiSDK["registerTelemetryIntegration"]);
|
|
5163
5321
|
const hasV7Marker = isFunction(aiSDK["experimental_streamLanguageModelCall"]) || isFunction(aiSDK["experimental_streamModelCall"]);
|
|
5164
5322
|
return hasRegister && hasV7Marker;
|
|
5165
5323
|
}
|
|
5166
5324
|
function resolveRegisterTelemetry(aiSDK) {
|
|
5167
5325
|
var _a;
|
|
5168
|
-
if (!
|
|
5326
|
+
if (!isRecord2(aiSDK)) return void 0;
|
|
5169
5327
|
const fn = (_a = aiSDK["registerTelemetry"]) != null ? _a : aiSDK["registerTelemetryIntegration"];
|
|
5170
5328
|
return isFunction(fn) ? fn : void 0;
|
|
5171
5329
|
}
|
|
@@ -5196,18 +5354,18 @@ function isAsyncIterable(value) {
|
|
|
5196
5354
|
return value !== null && typeof value === "object" && Symbol.asyncIterator in value;
|
|
5197
5355
|
}
|
|
5198
5356
|
function resolveUsageRecord(result) {
|
|
5199
|
-
if (!
|
|
5357
|
+
if (!isRecord2(result)) return void 0;
|
|
5200
5358
|
let usage;
|
|
5201
5359
|
try {
|
|
5202
|
-
if (
|
|
5360
|
+
if (isRecord2(result["totalUsage"])) {
|
|
5203
5361
|
usage = result["totalUsage"];
|
|
5204
|
-
} else if (
|
|
5362
|
+
} else if (isRecord2(result["usage"])) {
|
|
5205
5363
|
usage = result["usage"];
|
|
5206
5364
|
}
|
|
5207
5365
|
} catch (e) {
|
|
5208
5366
|
return void 0;
|
|
5209
5367
|
}
|
|
5210
|
-
return
|
|
5368
|
+
return isRecord2(usage) ? usage : void 0;
|
|
5211
5369
|
}
|
|
5212
5370
|
function extractUsageMetrics(result) {
|
|
5213
5371
|
return extractUsageMetricsFromUsage(resolveUsageRecord(result));
|
|
@@ -5228,7 +5386,7 @@ function shouldKeepEventPending(params) {
|
|
|
5228
5386
|
}
|
|
5229
5387
|
function normalizePromptAttr(arg) {
|
|
5230
5388
|
var _a, _b;
|
|
5231
|
-
if (!
|
|
5389
|
+
if (!isRecord2(arg)) return arg;
|
|
5232
5390
|
const system = arg["system"];
|
|
5233
5391
|
const prompt = arg["prompt"];
|
|
5234
5392
|
const messages = arg["messages"];
|
|
@@ -5282,7 +5440,7 @@ async function runWithRootContextAsync(rootSpan, eventId, fn) {
|
|
|
5282
5440
|
);
|
|
5283
5441
|
}
|
|
5284
5442
|
function teeStreamObjectBaseStream(result) {
|
|
5285
|
-
if (!result || !
|
|
5443
|
+
if (!result || !isRecord2(result)) return;
|
|
5286
5444
|
const baseStream = result["baseStream"];
|
|
5287
5445
|
if (!(baseStream && typeof baseStream === "object" && "tee" in baseStream)) return;
|
|
5288
5446
|
try {
|
|
@@ -5323,7 +5481,7 @@ function setupOperation(params) {
|
|
|
5323
5481
|
const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
|
|
5324
5482
|
const outerOperationId = `ai.${operation}`;
|
|
5325
5483
|
const { operationName, resourceName } = opName(outerOperationId, telemetry == null ? void 0 : telemetry.functionId);
|
|
5326
|
-
const modelInfoFromArgs =
|
|
5484
|
+
const modelInfoFromArgs = isRecord2(arg) ? extractModelInfo(arg["model"]) : {};
|
|
5327
5485
|
const rootSpan = sendTraces ? traceShipper.startSpan({
|
|
5328
5486
|
name: outerOperationId,
|
|
5329
5487
|
parent: inheritedParent,
|
|
@@ -5338,7 +5496,7 @@ function setupOperation(params) {
|
|
|
5338
5496
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
5339
5497
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
5340
5498
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
5341
|
-
...attrsFromHeaders(
|
|
5499
|
+
...attrsFromHeaders(isRecord2(arg) ? arg["headers"] : void 0),
|
|
5342
5500
|
...attrsFromSettings(arg),
|
|
5343
5501
|
...(telemetry == null ? void 0 : telemetry.recordInputs) === false ? [] : [attrString("ai.prompt", safeJsonWithUint8(normalizePromptAttr(arg)))]
|
|
5344
5502
|
]
|
|
@@ -5355,7 +5513,9 @@ function setupOperation(params) {
|
|
|
5355
5513
|
traceShipper,
|
|
5356
5514
|
rootParentForChildren,
|
|
5357
5515
|
selfDiagnostics: operationSelfDiagnostics,
|
|
5358
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
5516
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
5517
|
+
promptTools: options.tools,
|
|
5518
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
5359
5519
|
};
|
|
5360
5520
|
const toolCalls = [];
|
|
5361
5521
|
const argsWithWrappedTools = wrapTools(arg, wrapCtx, toolCalls);
|
|
@@ -5428,8 +5588,8 @@ function createFinalize(params) {
|
|
|
5428
5588
|
endTimeUnixNano: spanEndTimeUnixNano,
|
|
5429
5589
|
keepEventPending
|
|
5430
5590
|
});
|
|
5431
|
-
const providerMetadata =
|
|
5432
|
-
const resultToolCalls =
|
|
5591
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
5592
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : setup.toolCalls.length ? safeJsonWithUint8(setup.toolCalls) : void 0;
|
|
5433
5593
|
traceShipper.endSpan(setup.rootSpan, {
|
|
5434
5594
|
attributes: [
|
|
5435
5595
|
...((_d = setup.telemetry) == null ? void 0 : _d.recordOutputs) === false ? [] : [
|
|
@@ -5701,6 +5861,7 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5701
5861
|
sendEvents: ((_b = deps.options.send) == null ? void 0 : _b.events) !== false,
|
|
5702
5862
|
debug,
|
|
5703
5863
|
settledEventIds: deps.settledEventIds,
|
|
5864
|
+
tools: deps.options.tools,
|
|
5704
5865
|
context: {
|
|
5705
5866
|
userId: wrapTimeCtx.userId,
|
|
5706
5867
|
eventId: wrapTimeCtx.eventId,
|
|
@@ -5743,7 +5904,7 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5743
5904
|
const arg = callArgs[0];
|
|
5744
5905
|
const callMetadata = readRaindropCallMetadataFromArgs(callArgs);
|
|
5745
5906
|
const callOriginal = () => original.call(aiSDK, ...callArgs);
|
|
5746
|
-
if (selfDiagnostics2 && selfDiagnosticsOps.has(propName) &&
|
|
5907
|
+
if (selfDiagnostics2 && selfDiagnosticsOps.has(propName) && isRecord2(arg)) {
|
|
5747
5908
|
const telemetry = extractExperimentalTelemetry(arg);
|
|
5748
5909
|
const callMeta = (telemetry == null ? void 0 : telemetry.metadata) ? extractRaindropMetadata(telemetry.metadata) : {};
|
|
5749
5910
|
const perCallEventIdExplicit = (_b2 = (_a2 = callMetadata == null ? void 0 : callMetadata.eventId) != null ? _a2 : callMeta.eventId) != null ? _b2 : wrapTimeCtx.eventId;
|
|
@@ -5755,16 +5916,18 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
5755
5916
|
eventShipper: deps.eventShipper,
|
|
5756
5917
|
traceShipper: deps.traceShipper,
|
|
5757
5918
|
selfDiagnostics: selfDiagnostics2,
|
|
5758
|
-
aiSDKVersion: "7"
|
|
5919
|
+
aiSDKVersion: "7",
|
|
5920
|
+
promptTools: deps.options.tools,
|
|
5921
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
5759
5922
|
};
|
|
5760
|
-
const tools =
|
|
5923
|
+
const tools = isRecord2(arg["tools"]) ? { ...arg["tools"] } : {};
|
|
5761
5924
|
const toolName = selfDiagnostics2.toolName;
|
|
5762
5925
|
if (!(toolName in tools)) {
|
|
5763
5926
|
const reportTool = createSelfDiagnosticsTool(perCallCtx);
|
|
5764
5927
|
if (reportTool) tools[toolName] = reportTool;
|
|
5765
5928
|
}
|
|
5766
|
-
const existingTelemetry =
|
|
5767
|
-
const existingMetadata =
|
|
5929
|
+
const existingTelemetry = isRecord2(arg["experimental_telemetry"]) ? arg["experimental_telemetry"] : {};
|
|
5930
|
+
const existingMetadata = isRecord2(existingTelemetry["metadata"]) ? existingTelemetry["metadata"] : {};
|
|
5768
5931
|
const mergedMetadata = existingMetadata["raindrop.eventId"] ? existingMetadata : {
|
|
5769
5932
|
...existingMetadata,
|
|
5770
5933
|
"raindrop.eventId": perCallEventId,
|
|
@@ -5960,7 +6123,9 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
5960
6123
|
traceShipper: deps.traceShipper,
|
|
5961
6124
|
rootParentForChildren,
|
|
5962
6125
|
selfDiagnostics,
|
|
5963
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
6126
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
6127
|
+
promptTools: deps.options.tools,
|
|
6128
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
5964
6129
|
};
|
|
5965
6130
|
const toolCalls = [];
|
|
5966
6131
|
const mergedArgsWithWrappedTools = wrapTools(mergedArgs, wrapCtx, toolCalls);
|
|
@@ -6010,8 +6175,8 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
6010
6175
|
keepEventPending: false
|
|
6011
6176
|
});
|
|
6012
6177
|
const finishReason = extractFinishReason(result);
|
|
6013
|
-
const providerMetadata =
|
|
6014
|
-
const resultToolCalls =
|
|
6178
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6179
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : toolCalls.length ? safeJsonWithUint8(toolCalls) : void 0;
|
|
6015
6180
|
deps.traceShipper.endSpan(rootSpan, {
|
|
6016
6181
|
attributes: [
|
|
6017
6182
|
...(telemetry == null ? void 0 : telemetry.recordOutputs) === false ? [] : [
|
|
@@ -6180,7 +6345,9 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6180
6345
|
traceShipper: deps.traceShipper,
|
|
6181
6346
|
rootParentForChildren,
|
|
6182
6347
|
selfDiagnostics,
|
|
6183
|
-
aiSDKVersion: detectAISDKVersion(aiSDK)
|
|
6348
|
+
aiSDKVersion: detectAISDKVersion(aiSDK),
|
|
6349
|
+
promptTools: deps.options.tools,
|
|
6350
|
+
promptToolsOptions: promptToolsOptionsFrom(aiSDK)
|
|
6184
6351
|
};
|
|
6185
6352
|
const toolCalls = [];
|
|
6186
6353
|
const mergedArgsWithWrappedTools = wrapTools(mergedArgs, wrapCtx, toolCalls);
|
|
@@ -6230,8 +6397,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6230
6397
|
keepEventPending: false
|
|
6231
6398
|
});
|
|
6232
6399
|
const finishReason = extractFinishReason(result);
|
|
6233
|
-
const providerMetadata =
|
|
6234
|
-
const resultToolCalls =
|
|
6400
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6401
|
+
const resultToolCalls = isRecord2(result) && Array.isArray(result["toolCalls"]) ? safeJsonWithUint8(result["toolCalls"]) : toolCalls.length ? safeJsonWithUint8(toolCalls) : void 0;
|
|
6235
6402
|
deps.traceShipper.endSpan(rootSpan, {
|
|
6236
6403
|
attributes: [
|
|
6237
6404
|
...(telemetry == null ? void 0 : telemetry.recordOutputs) === false ? [] : [
|
|
@@ -6343,8 +6510,8 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
6343
6510
|
};
|
|
6344
6511
|
}
|
|
6345
6512
|
function wrapTools(args, ctx, toolCalls) {
|
|
6346
|
-
if (!
|
|
6347
|
-
const tools =
|
|
6513
|
+
if (!isRecord2(args)) return args;
|
|
6514
|
+
const tools = isRecord2(args["tools"]) ? { ...args["tools"] } : {};
|
|
6348
6515
|
if (ctx.selfDiagnostics) {
|
|
6349
6516
|
const reportToolName = ctx.selfDiagnostics.toolName;
|
|
6350
6517
|
if (!(reportToolName in tools)) {
|
|
@@ -6367,7 +6534,7 @@ function wrapTools(args, ctx, toolCalls) {
|
|
|
6367
6534
|
}
|
|
6368
6535
|
function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
6369
6536
|
var _a;
|
|
6370
|
-
if (!
|
|
6537
|
+
if (!isRecord2(tool) || !isFunction(tool["execute"])) return tool;
|
|
6371
6538
|
const originalExecute = tool["execute"];
|
|
6372
6539
|
const { operationName, resourceName } = opName("ai.toolCall", (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6373
6540
|
const createToolSpan = (toolCallId, toolArgs, parent) => {
|
|
@@ -6428,7 +6595,7 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
|
6428
6595
|
const wrappedExecute = function(...execArgs) {
|
|
6429
6596
|
const toolArgs = execArgs[0];
|
|
6430
6597
|
const execOptions = execArgs.length > 1 ? execArgs[1] : void 0;
|
|
6431
|
-
const toolCallId =
|
|
6598
|
+
const toolCallId = isRecord2(execOptions) && typeof execOptions["toolCallId"] === "string" ? execOptions["toolCallId"] : randomUUID();
|
|
6432
6599
|
const result = originalExecute.apply(this, execArgs);
|
|
6433
6600
|
if (isAsyncIterable(result)) {
|
|
6434
6601
|
return (async function* () {
|
|
@@ -6503,20 +6670,20 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
|
6503
6670
|
return { ...tool, execute: wrappedExecute };
|
|
6504
6671
|
}
|
|
6505
6672
|
function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
6506
|
-
if (!
|
|
6673
|
+
if (!isRecord2(args) || !("model" in args)) return args;
|
|
6507
6674
|
let model = args["model"];
|
|
6508
6675
|
if (typeof model === "string") {
|
|
6509
6676
|
const maybeProvider = globalThis.AI_SDK_DEFAULT_PROVIDER;
|
|
6510
|
-
const gateway =
|
|
6677
|
+
const gateway = isRecord2(aiSDK) ? aiSDK["gateway"] : void 0;
|
|
6511
6678
|
const provider = maybeProvider != null ? maybeProvider : gateway;
|
|
6512
|
-
if (
|
|
6679
|
+
if (isRecord2(provider) && isFunction(provider["languageModel"])) {
|
|
6513
6680
|
try {
|
|
6514
6681
|
model = provider["languageModel"](model);
|
|
6515
6682
|
} catch (e) {
|
|
6516
6683
|
}
|
|
6517
6684
|
}
|
|
6518
6685
|
}
|
|
6519
|
-
if (!
|
|
6686
|
+
if (!isRecord2(model)) return args;
|
|
6520
6687
|
const modelInfo = extractModelInfo(model);
|
|
6521
6688
|
const doGenerateOpId = `${outerOperationId}.doGenerate`;
|
|
6522
6689
|
const doStreamOpId = `${outerOperationId}.doStream`;
|
|
@@ -6533,13 +6700,13 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6533
6700
|
try {
|
|
6534
6701
|
const result = await original.apply(target, callArgs);
|
|
6535
6702
|
if (span) endDoGenerateSpan(span, result, modelInfo, ctx);
|
|
6536
|
-
if (localDebuggerEnabled() && ctx.rootParentForChildren &&
|
|
6703
|
+
if (localDebuggerEnabled() && ctx.rootParentForChildren && isRecord2(result)) {
|
|
6537
6704
|
const traceId = ctx.rootParentForChildren.traceIdB64;
|
|
6538
6705
|
const liveMeta = getLocalDebuggerMetadata({ ...ctx.context, eventId: ctx.eventId });
|
|
6539
6706
|
const content = result["content"];
|
|
6540
6707
|
if (Array.isArray(content)) {
|
|
6541
6708
|
for (const part of content) {
|
|
6542
|
-
if (
|
|
6709
|
+
if (isRecord2(part)) {
|
|
6543
6710
|
if ((part["type"] === "reasoning" || part["type"] === "thinking") && typeof ((_a = part["text"]) != null ? _a : part["thinking"]) === "string") {
|
|
6544
6711
|
sendLocalDebuggerLiveEvent({
|
|
6545
6712
|
traceId,
|
|
@@ -6608,7 +6775,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6608
6775
|
});
|
|
6609
6776
|
throw error;
|
|
6610
6777
|
}
|
|
6611
|
-
const stream =
|
|
6778
|
+
const stream = isRecord2(result) ? result["stream"] : void 0;
|
|
6612
6779
|
const RS = globalThis.ReadableStream;
|
|
6613
6780
|
if (!RS || !(stream instanceof RS)) {
|
|
6614
6781
|
if (span) ctx.traceShipper.endSpan(span);
|
|
@@ -6681,7 +6848,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6681
6848
|
return;
|
|
6682
6849
|
}
|
|
6683
6850
|
if (firstChunkMs === void 0) firstChunkMs = Date.now();
|
|
6684
|
-
if (
|
|
6851
|
+
if (isRecord2(value)) {
|
|
6685
6852
|
const type = value["type"];
|
|
6686
6853
|
if (type === "text-delta") {
|
|
6687
6854
|
let textDelta;
|
|
@@ -6696,7 +6863,7 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6696
6863
|
}
|
|
6697
6864
|
if (type === "finish") finishReason = extractFinishReason(value);
|
|
6698
6865
|
if (type === "tool-call") toolCallsLocal.push(value);
|
|
6699
|
-
if ("response" in value &&
|
|
6866
|
+
if ("response" in value && isRecord2(value["response"])) {
|
|
6700
6867
|
const response = value["response"];
|
|
6701
6868
|
if (typeof response["id"] === "string") responseId = response["id"];
|
|
6702
6869
|
if (typeof response["modelId"] === "string")
|
|
@@ -6773,10 +6940,15 @@ function wrapModel(args, aiSDK, outerOperationId, ctx) {
|
|
|
6773
6940
|
function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
6774
6941
|
var _a, _b, _c;
|
|
6775
6942
|
const { operationName, resourceName } = opName(operationId, (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6776
|
-
const
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6943
|
+
const promptTools = promptToolsAttribute(
|
|
6944
|
+
resolvePromptTools({
|
|
6945
|
+
override: ctx.promptTools,
|
|
6946
|
+
inferred: isRecord2(options) ? options["tools"] : void 0,
|
|
6947
|
+
options: ctx.promptToolsOptions
|
|
6948
|
+
})
|
|
6949
|
+
);
|
|
6950
|
+
const toolChoiceJson = isRecord2(options) ? safeJsonWithUint8(options["toolChoice"]) : void 0;
|
|
6951
|
+
const promptJson = isRecord2(options) ? safeJsonWithUint8(options["prompt"]) : safeJsonWithUint8(options);
|
|
6780
6952
|
return ctx.traceShipper.startSpan({
|
|
6781
6953
|
name: operationId,
|
|
6782
6954
|
parent,
|
|
@@ -6791,7 +6963,7 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
6791
6963
|
attrString("ai.model.id", modelInfo.modelId),
|
|
6792
6964
|
...((_c = ctx.telemetry) == null ? void 0 : _c.recordInputs) === false ? [] : [
|
|
6793
6965
|
attrString("ai.prompt.messages", promptJson),
|
|
6794
|
-
|
|
6966
|
+
promptTools,
|
|
6795
6967
|
attrString("ai.prompt.toolChoice", toolChoiceJson)
|
|
6796
6968
|
],
|
|
6797
6969
|
attrString(MODEL_USAGE_ATTRIBUTES.requestModel, modelInfo.modelId),
|
|
@@ -6803,26 +6975,26 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
6803
6975
|
function endDoGenerateSpan(span, result, modelInfo, ctx) {
|
|
6804
6976
|
var _a;
|
|
6805
6977
|
const finishReason = extractFinishReason(result);
|
|
6806
|
-
const content =
|
|
6807
|
-
const response =
|
|
6808
|
-
const usage =
|
|
6809
|
-
const providerMetadata =
|
|
6978
|
+
const content = isRecord2(result) ? result["content"] : void 0;
|
|
6979
|
+
const response = isRecord2(result) ? result["response"] : void 0;
|
|
6980
|
+
const usage = isRecord2(result) ? result["usage"] : void 0;
|
|
6981
|
+
const providerMetadata = isRecord2(result) ? result["providerMetadata"] : void 0;
|
|
6810
6982
|
let responseId;
|
|
6811
|
-
if (
|
|
6983
|
+
if (isRecord2(response) && typeof response["id"] === "string") {
|
|
6812
6984
|
responseId = response["id"];
|
|
6813
6985
|
} else {
|
|
6814
6986
|
responseId = randomUUID();
|
|
6815
6987
|
}
|
|
6816
6988
|
let responseModelId;
|
|
6817
|
-
if (
|
|
6989
|
+
if (isRecord2(response) && typeof response["modelId"] === "string") {
|
|
6818
6990
|
responseModelId = response["modelId"];
|
|
6819
6991
|
} else {
|
|
6820
6992
|
responseModelId = modelInfo.modelId;
|
|
6821
6993
|
}
|
|
6822
6994
|
let responseTimestampIso;
|
|
6823
|
-
if (
|
|
6995
|
+
if (isRecord2(response) && response["timestamp"] instanceof Date) {
|
|
6824
6996
|
responseTimestampIso = response["timestamp"].toISOString();
|
|
6825
|
-
} else if (
|
|
6997
|
+
} else if (isRecord2(response) && typeof response["timestamp"] === "string") {
|
|
6826
6998
|
responseTimestampIso = response["timestamp"];
|
|
6827
6999
|
} else {
|
|
6828
7000
|
responseTimestampIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -6856,10 +7028,15 @@ function endDoGenerateSpan(span, result, modelInfo, ctx) {
|
|
|
6856
7028
|
function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
6857
7029
|
var _a, _b, _c;
|
|
6858
7030
|
const { operationName, resourceName } = opName(operationId, (_a = ctx.telemetry) == null ? void 0 : _a.functionId);
|
|
6859
|
-
const
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
7031
|
+
const promptTools = promptToolsAttribute(
|
|
7032
|
+
resolvePromptTools({
|
|
7033
|
+
override: ctx.promptTools,
|
|
7034
|
+
inferred: isRecord2(options) ? options["tools"] : void 0,
|
|
7035
|
+
options: ctx.promptToolsOptions
|
|
7036
|
+
})
|
|
7037
|
+
);
|
|
7038
|
+
const toolChoiceJson = isRecord2(options) ? safeJsonWithUint8(options["toolChoice"]) : void 0;
|
|
7039
|
+
const promptJson = isRecord2(options) ? safeJsonWithUint8(options["prompt"]) : safeJsonWithUint8(options);
|
|
6863
7040
|
return ctx.traceShipper.startSpan({
|
|
6864
7041
|
name: operationId,
|
|
6865
7042
|
parent,
|
|
@@ -6874,7 +7051,7 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
6874
7051
|
attrString("ai.model.id", modelInfo.modelId),
|
|
6875
7052
|
...((_c = ctx.telemetry) == null ? void 0 : _c.recordInputs) === false ? [] : [
|
|
6876
7053
|
attrString("ai.prompt.messages", promptJson),
|
|
6877
|
-
|
|
7054
|
+
promptTools,
|
|
6878
7055
|
attrString("ai.prompt.toolChoice", toolChoiceJson)
|
|
6879
7056
|
],
|
|
6880
7057
|
attrString(MODEL_USAGE_ATTRIBUTES.requestModel, modelInfo.modelId),
|
|
@@ -6888,7 +7065,7 @@ function resolveContext(context, info) {
|
|
|
6888
7065
|
return typeof context === "function" ? context(info) : context;
|
|
6889
7066
|
}
|
|
6890
7067
|
function wrapOnFinish(args, onFinish) {
|
|
6891
|
-
if (!
|
|
7068
|
+
if (!isRecord2(args)) return args;
|
|
6892
7069
|
const existing = args["onFinish"];
|
|
6893
7070
|
if (existing === void 0) {
|
|
6894
7071
|
return { ...args, onFinish: async (result) => onFinish(result) };
|
|
@@ -7095,11 +7272,16 @@ function createRaindropAISDK(opts) {
|
|
|
7095
7272
|
];
|
|
7096
7273
|
let context;
|
|
7097
7274
|
let subagentWrapping;
|
|
7275
|
+
let tools;
|
|
7098
7276
|
if (contextOrOptions === void 0) ; else if ("context" in contextOrOptions) {
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7277
|
+
const shaped = contextOrOptions;
|
|
7278
|
+
context = shaped.context;
|
|
7279
|
+
subagentWrapping = shaped.subagentWrapping;
|
|
7280
|
+
tools = shaped.tools;
|
|
7281
|
+
} else if (("subagentWrapping" in contextOrOptions || "tools" in contextOrOptions) && !FLAT_CONTEXT_KEYS.some((k) => k in contextOrOptions)) {
|
|
7282
|
+
const shaped = contextOrOptions;
|
|
7283
|
+
subagentWrapping = shaped.subagentWrapping;
|
|
7284
|
+
tools = shaped.tools;
|
|
7103
7285
|
} else {
|
|
7104
7286
|
context = contextOrOptions;
|
|
7105
7287
|
}
|
|
@@ -7111,7 +7293,8 @@ function createRaindropAISDK(opts) {
|
|
|
7111
7293
|
subagentWrapping,
|
|
7112
7294
|
debug: envDebug,
|
|
7113
7295
|
settledEventIds,
|
|
7114
|
-
context
|
|
7296
|
+
context,
|
|
7297
|
+
tools
|
|
7115
7298
|
});
|
|
7116
7299
|
},
|
|
7117
7300
|
subagents: subagentApi,
|
|
@@ -7238,10 +7421,10 @@ function createRaindropAISDK(opts) {
|
|
|
7238
7421
|
}
|
|
7239
7422
|
function raindrop(options = {}) {
|
|
7240
7423
|
var _a;
|
|
7241
|
-
const { context, subagentWrapping, writeKey, ...rest } = options;
|
|
7424
|
+
const { context, subagentWrapping, tools, writeKey, ...rest } = options;
|
|
7242
7425
|
const resolvedWriteKey = writeKey != null ? writeKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.RAINDROP_WRITE_KEY : void 0;
|
|
7243
7426
|
const client = createRaindropAISDK({ ...rest, writeKey: resolvedWriteKey });
|
|
7244
|
-
return client.createTelemetryIntegration({ context, subagentWrapping });
|
|
7427
|
+
return client.createTelemetryIntegration({ context, subagentWrapping, tools });
|
|
7245
7428
|
}
|
|
7246
7429
|
|
|
7247
|
-
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 };
|
|
7430
|
+
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 };
|