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