@raindrop-ai/ai-sdk 0.0.24 → 0.0.26
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 +30 -4
- package/dist/{chunk-WHP2SVAR.mjs → chunk-76JSTQY3.mjs} +208 -91
- package/dist/{index-sxjvhkYW.d.mts → index-7aDHuHHR.d.mts} +70 -11
- package/dist/{index-sxjvhkYW.d.ts → index-7aDHuHHR.d.ts} +70 -11
- package/dist/index.browser.d.mts +70 -11
- package/dist/index.browser.d.ts +70 -11
- package/dist/index.browser.js +211 -90
- package/dist/index.browser.mjs +208 -91
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +211 -90
- 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 +211 -90
- package/dist/index.workers.mjs +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// ../core/dist/chunk-
|
|
3
|
+
// ../core/dist/chunk-Y7SM66SW.js
|
|
4
4
|
function getCrypto() {
|
|
5
5
|
const c = globalThis.crypto;
|
|
6
6
|
return c;
|
|
@@ -478,21 +478,6 @@ function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
|
478
478
|
function localDebuggerEnabled(baseUrl) {
|
|
479
479
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
480
480
|
}
|
|
481
|
-
function normalizeLocalDebuggerLiveEventType(type) {
|
|
482
|
-
switch (type) {
|
|
483
|
-
case "text-delta":
|
|
484
|
-
return "text_delta";
|
|
485
|
-
case "reasoning":
|
|
486
|
-
case "reasoning-delta":
|
|
487
|
-
return "reasoning_delta";
|
|
488
|
-
case "tool-call":
|
|
489
|
-
return "tool_start";
|
|
490
|
-
case "tool-result":
|
|
491
|
-
return "tool_result";
|
|
492
|
-
default:
|
|
493
|
-
return type;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
481
|
function mirrorTraceExportToLocalDebugger(body, options = {}) {
|
|
497
482
|
var _a;
|
|
498
483
|
const baseUrl = resolveLocalDebuggerBaseUrl(options.baseUrl);
|
|
@@ -512,7 +497,7 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
|
|
|
512
497
|
`${baseUrl}live`,
|
|
513
498
|
{
|
|
514
499
|
...event,
|
|
515
|
-
type:
|
|
500
|
+
type: event.type,
|
|
516
501
|
timestamp: (_a = event.timestamp) != null ? _a : Date.now()
|
|
517
502
|
},
|
|
518
503
|
{},
|
|
@@ -832,7 +817,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
|
|
|
832
817
|
// package.json
|
|
833
818
|
var package_default = {
|
|
834
819
|
name: "@raindrop-ai/ai-sdk",
|
|
835
|
-
version: "0.0.
|
|
820
|
+
version: "0.0.26"};
|
|
836
821
|
|
|
837
822
|
// src/internal/version.ts
|
|
838
823
|
var libraryName = package_default.name;
|
|
@@ -1472,6 +1457,77 @@ function attrsFromGenAiRequest(options) {
|
|
|
1472
1457
|
];
|
|
1473
1458
|
}
|
|
1474
1459
|
|
|
1460
|
+
// src/internal/call-metadata.ts
|
|
1461
|
+
var SyncFallbackStorage = class {
|
|
1462
|
+
constructor() {
|
|
1463
|
+
this._stack = [];
|
|
1464
|
+
}
|
|
1465
|
+
getStore() {
|
|
1466
|
+
return this._stack[this._stack.length - 1];
|
|
1467
|
+
}
|
|
1468
|
+
run(store, callback) {
|
|
1469
|
+
this._stack.push(store);
|
|
1470
|
+
try {
|
|
1471
|
+
return callback();
|
|
1472
|
+
} finally {
|
|
1473
|
+
this._stack.pop();
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
var _storage = null;
|
|
1478
|
+
function getStorage() {
|
|
1479
|
+
if (_storage) return _storage;
|
|
1480
|
+
const Ctor = globalThis.RAINDROP_ASYNC_LOCAL_STORAGE;
|
|
1481
|
+
_storage = Ctor ? new Ctor() : new SyncFallbackStorage();
|
|
1482
|
+
return _storage;
|
|
1483
|
+
}
|
|
1484
|
+
function _resetRaindropCallMetadataStorage() {
|
|
1485
|
+
_storage = null;
|
|
1486
|
+
}
|
|
1487
|
+
function getCurrentRaindropCallMetadata() {
|
|
1488
|
+
return getStorage().getStore();
|
|
1489
|
+
}
|
|
1490
|
+
function runWithRaindropCallMetadata(metadata, fn) {
|
|
1491
|
+
return getStorage().run(metadata, fn);
|
|
1492
|
+
}
|
|
1493
|
+
function readRaindropCallMetadataFromArgs(args) {
|
|
1494
|
+
var _a;
|
|
1495
|
+
if (args.length === 0) return void 0;
|
|
1496
|
+
const first = args[0];
|
|
1497
|
+
if (!isRecord(first)) return void 0;
|
|
1498
|
+
const topLevel = isRecord(first["metadata"]) ? first["metadata"] : void 0;
|
|
1499
|
+
const stable = isRecord(first["telemetry"]) ? first["telemetry"]["metadata"] : void 0;
|
|
1500
|
+
const stableMetadata = isRecord(stable) ? stable : void 0;
|
|
1501
|
+
const exp = extractExperimentalTelemetry(first);
|
|
1502
|
+
const expMetadata = (exp == null ? void 0 : exp.metadata) && typeof exp.metadata === "object" ? exp.metadata : void 0;
|
|
1503
|
+
const raw = (_a = topLevel != null ? topLevel : stableMetadata) != null ? _a : expMetadata;
|
|
1504
|
+
if (!raw) return void 0;
|
|
1505
|
+
const meta = { rawMetadata: raw };
|
|
1506
|
+
const userId = raw["raindrop.userId"];
|
|
1507
|
+
if (typeof userId === "string" && userId) meta.userId = userId;
|
|
1508
|
+
const eventId = raw["raindrop.eventId"];
|
|
1509
|
+
if (typeof eventId === "string" && eventId) meta.eventId = eventId;
|
|
1510
|
+
const eventIdGenerated = raw["raindrop.internal.eventIdGenerated"];
|
|
1511
|
+
if (eventIdGenerated === true || eventIdGenerated === "true" || eventIdGenerated === "1") {
|
|
1512
|
+
meta.eventIdGenerated = true;
|
|
1513
|
+
}
|
|
1514
|
+
const convoId = raw["raindrop.convoId"];
|
|
1515
|
+
if (typeof convoId === "string" && convoId) meta.convoId = convoId;
|
|
1516
|
+
const eventName = raw["raindrop.eventName"];
|
|
1517
|
+
if (typeof eventName === "string" && eventName) meta.eventName = eventName;
|
|
1518
|
+
const properties = raw["raindrop.properties"];
|
|
1519
|
+
if (typeof properties === "string") {
|
|
1520
|
+
try {
|
|
1521
|
+
const parsed = JSON.parse(properties);
|
|
1522
|
+
if (parsed && typeof parsed === "object") meta.properties = parsed;
|
|
1523
|
+
} catch (e) {
|
|
1524
|
+
}
|
|
1525
|
+
} else if (properties && typeof properties === "object") {
|
|
1526
|
+
meta.properties = properties;
|
|
1527
|
+
}
|
|
1528
|
+
return meta;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1475
1531
|
// src/internal/raindrop-telemetry-integration.ts
|
|
1476
1532
|
var RaindropTelemetryIntegration = class {
|
|
1477
1533
|
constructor(opts) {
|
|
@@ -1479,15 +1535,17 @@ var RaindropTelemetryIntegration = class {
|
|
|
1479
1535
|
// ── onStart ─────────────────────────────────────────────────────────────
|
|
1480
1536
|
this.onStart = (event) => {
|
|
1481
1537
|
var _a, _b, _c, _d;
|
|
1482
|
-
if (event.isEnabled
|
|
1538
|
+
if (event.isEnabled === false) return;
|
|
1483
1539
|
const isEmbed = event.operationId === "ai.embed" || event.operationId === "ai.embedMany";
|
|
1484
1540
|
const recordInputs = event.recordInputs !== false;
|
|
1485
1541
|
const recordOutputs = event.recordOutputs !== false;
|
|
1486
1542
|
const functionId = event.functionId;
|
|
1487
|
-
const
|
|
1543
|
+
const eventMetadata2 = event.metadata;
|
|
1544
|
+
const callContextMetadata = getCurrentRaindropCallMetadata();
|
|
1545
|
+
const metadata = eventMetadata2 != null ? eventMetadata2 : callContextMetadata == null ? void 0 : callContextMetadata.rawMetadata;
|
|
1488
1546
|
const callMeta = this.extractRaindropMetadata(metadata);
|
|
1489
1547
|
const inherited = getContextManager().getParentSpanIds();
|
|
1490
|
-
const eventIdGenerated = (metadata == null ? void 0 : metadata["raindrop.internal.eventIdGenerated"]) === "true" || (metadata == null ? void 0 : metadata["raindrop.internal.eventIdGenerated"]) === true;
|
|
1548
|
+
const eventIdGenerated = (metadata == null ? void 0 : metadata["raindrop.internal.eventIdGenerated"]) === "true" || (metadata == null ? void 0 : metadata["raindrop.internal.eventIdGenerated"]) === true || (callContextMetadata == null ? void 0 : callContextMetadata.eventIdGenerated) === true;
|
|
1491
1549
|
const explicitEventId = callMeta.eventId && !eventIdGenerated ? callMeta.eventId : void 0;
|
|
1492
1550
|
const eventId = (_d = (_c = (_b = explicitEventId != null ? explicitEventId : (_a = this.defaultContext) == null ? void 0 : _a.eventId) != null ? _b : inherited == null ? void 0 : inherited.eventId) != null ? _c : callMeta.eventId) != null ? _d : randomUUID();
|
|
1493
1551
|
const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
|
|
@@ -1613,48 +1671,25 @@ var RaindropTelemetryIntegration = class {
|
|
|
1613
1671
|
state.stepSpan = stepSpan;
|
|
1614
1672
|
state.stepParent = this.spanParentRef(stepSpan);
|
|
1615
1673
|
};
|
|
1616
|
-
|
|
1617
|
-
this.
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
attrString("resource.name", resourceName),
|
|
1634
|
-
attrString("ai.telemetry.functionId", state.functionId),
|
|
1635
|
-
attrString("ai.toolCall.name", toolCall.toolName),
|
|
1636
|
-
attrString("ai.toolCall.id", toolCall.toolCallId),
|
|
1637
|
-
...inputAttrs
|
|
1638
|
-
]
|
|
1639
|
-
});
|
|
1640
|
-
state.toolSpans.set(toolCall.toolCallId, toolSpan);
|
|
1641
|
-
this.emitLive(state, "tool_start", toolCall.toolName, { args: toolCall.input });
|
|
1674
|
+
this.onToolExecutionStart = (event) => this.toolExecutionStart(event);
|
|
1675
|
+
this.onToolExecutionEnd = (event) => this.toolExecutionEnd(event);
|
|
1676
|
+
// Older v7 betas (< beta.111) emit these names. Kept as thin aliases so
|
|
1677
|
+
// applications pinned to those betas continue to work.
|
|
1678
|
+
this.onToolCallStart = (event) => this.toolExecutionStart(event);
|
|
1679
|
+
this.onToolCallFinish = (event) => this.toolExecutionEnd(event);
|
|
1680
|
+
// ── language-model call (v7 beta.111+) ─────────────────────────────────
|
|
1681
|
+
//
|
|
1682
|
+
// `onLanguageModelCallStart` / `onLanguageModelCallEnd` are scoped to the
|
|
1683
|
+
// model invocation only and exclude later client-side tool execution.
|
|
1684
|
+
// Raindrop already spans at the operation + step level, so these are
|
|
1685
|
+
// intentional no-ops — declared so the dispatcher's `mergeCallbacks` sees
|
|
1686
|
+
// them and so we don't accidentally rely on them later.
|
|
1687
|
+
//
|
|
1688
|
+
// Defined as no-ops rather than omitted so adding logic here later is a
|
|
1689
|
+
// strictly additive change.
|
|
1690
|
+
this.onLanguageModelCallStart = (_event) => {
|
|
1642
1691
|
};
|
|
1643
|
-
|
|
1644
|
-
this.onToolCallFinish = (event) => {
|
|
1645
|
-
const state = this.getState(event.callId);
|
|
1646
|
-
if (!state) return;
|
|
1647
|
-
const toolSpan = state.toolSpans.get(event.toolCall.toolCallId);
|
|
1648
|
-
if (!toolSpan) return;
|
|
1649
|
-
state.toolCallCount += 1;
|
|
1650
|
-
if (event.success) {
|
|
1651
|
-
const outputAttrs = state.recordOutputs ? [attrString("ai.toolCall.result", safeJsonWithUint8(event.output))] : [];
|
|
1652
|
-
this.traceShipper.endSpan(toolSpan, { attributes: outputAttrs });
|
|
1653
|
-
} else {
|
|
1654
|
-
this.traceShipper.endSpan(toolSpan, { error: event.error });
|
|
1655
|
-
}
|
|
1656
|
-
this.emitLive(state, "tool_result", event.toolCall.toolName);
|
|
1657
|
-
state.toolSpans.delete(event.toolCall.toolCallId);
|
|
1692
|
+
this.onLanguageModelCallEnd = (_event) => {
|
|
1658
1693
|
};
|
|
1659
1694
|
// ── onChunk (streaming) ─────────────────────────────────────────────────
|
|
1660
1695
|
this.onChunk = (event) => {
|
|
@@ -1923,6 +1958,53 @@ var RaindropTelemetryIntegration = class {
|
|
|
1923
1958
|
}
|
|
1924
1959
|
return void 0;
|
|
1925
1960
|
}
|
|
1961
|
+
// ── tool execution start / end ──────────────────────────────────────────
|
|
1962
|
+
//
|
|
1963
|
+
// v7 < beta.111 dispatched `onToolCallStart` / `onToolCallFinish`.
|
|
1964
|
+
// v7 >= beta.111 renamed them to `onToolExecutionStart` / `onToolExecutionEnd`
|
|
1965
|
+
// (see https://github.com/vercel/ai/pull/14589). Event shape is identical.
|
|
1966
|
+
// Both names are exposed and forward to a single implementation.
|
|
1967
|
+
toolExecutionStart(event) {
|
|
1968
|
+
const state = this.getState(event.callId);
|
|
1969
|
+
if (!(state == null ? void 0 : state.stepParent)) return;
|
|
1970
|
+
const { toolCall } = event;
|
|
1971
|
+
const { operationName, resourceName } = opName(
|
|
1972
|
+
"ai.toolCall",
|
|
1973
|
+
state.functionId
|
|
1974
|
+
);
|
|
1975
|
+
const inputAttrs = state.recordInputs ? [attrString("ai.toolCall.args", safeJsonWithUint8(toolCall.input))] : [];
|
|
1976
|
+
const toolSpan = this.traceShipper.startSpan({
|
|
1977
|
+
name: "ai.toolCall",
|
|
1978
|
+
parent: state.stepParent,
|
|
1979
|
+
eventId: state.eventId,
|
|
1980
|
+
operationId: "ai.toolCall",
|
|
1981
|
+
attributes: [
|
|
1982
|
+
attrString("operation.name", operationName),
|
|
1983
|
+
attrString("resource.name", resourceName),
|
|
1984
|
+
attrString("ai.telemetry.functionId", state.functionId),
|
|
1985
|
+
attrString("ai.toolCall.name", toolCall.toolName),
|
|
1986
|
+
attrString("ai.toolCall.id", toolCall.toolCallId),
|
|
1987
|
+
...inputAttrs
|
|
1988
|
+
]
|
|
1989
|
+
});
|
|
1990
|
+
state.toolSpans.set(toolCall.toolCallId, toolSpan);
|
|
1991
|
+
this.emitLive(state, "tool_start", toolCall.toolName, { args: toolCall.input });
|
|
1992
|
+
}
|
|
1993
|
+
toolExecutionEnd(event) {
|
|
1994
|
+
const state = this.getState(event.callId);
|
|
1995
|
+
if (!state) return;
|
|
1996
|
+
const toolSpan = state.toolSpans.get(event.toolCall.toolCallId);
|
|
1997
|
+
if (!toolSpan) return;
|
|
1998
|
+
state.toolCallCount += 1;
|
|
1999
|
+
if (event.success) {
|
|
2000
|
+
const outputAttrs = state.recordOutputs ? [attrString("ai.toolCall.result", safeJsonWithUint8(event.output))] : [];
|
|
2001
|
+
this.traceShipper.endSpan(toolSpan, { attributes: outputAttrs });
|
|
2002
|
+
} else {
|
|
2003
|
+
this.traceShipper.endSpan(toolSpan, { error: event.error });
|
|
2004
|
+
}
|
|
2005
|
+
this.emitLive(state, "tool_result", event.toolCall.toolName);
|
|
2006
|
+
state.toolSpans.delete(event.toolCall.toolCallId);
|
|
2007
|
+
}
|
|
1926
2008
|
finishGenerate(event, state) {
|
|
1927
2009
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1928
2010
|
if (state.rootSpan) {
|
|
@@ -2250,7 +2332,16 @@ function detectAISDKVersion(aiSDK) {
|
|
|
2250
2332
|
return "4";
|
|
2251
2333
|
}
|
|
2252
2334
|
function hasStructuredTelemetryEvents(aiSDK) {
|
|
2253
|
-
|
|
2335
|
+
if (!isRecord(aiSDK)) return false;
|
|
2336
|
+
const hasRegister = isFunction(aiSDK["registerTelemetry"]) || isFunction(aiSDK["registerTelemetryIntegration"]);
|
|
2337
|
+
const hasV7Marker = isFunction(aiSDK["experimental_streamLanguageModelCall"]) || isFunction(aiSDK["experimental_streamModelCall"]);
|
|
2338
|
+
return hasRegister && hasV7Marker;
|
|
2339
|
+
}
|
|
2340
|
+
function resolveRegisterTelemetry(aiSDK) {
|
|
2341
|
+
var _a;
|
|
2342
|
+
if (!isRecord(aiSDK)) return void 0;
|
|
2343
|
+
const fn = (_a = aiSDK["registerTelemetry"]) != null ? _a : aiSDK["registerTelemetryIntegration"];
|
|
2344
|
+
return isFunction(fn) ? fn : void 0;
|
|
2254
2345
|
}
|
|
2255
2346
|
function asVercelSchema(jsonSchemaObj) {
|
|
2256
2347
|
const validatorSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.validator");
|
|
@@ -2528,7 +2619,7 @@ function setupOperation(params) {
|
|
|
2528
2619
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
2529
2620
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
2530
2621
|
attrString("ai.telemetry.metadata.raindrop.eventName", mergedCtx.eventName),
|
|
2531
|
-
attrString("ai.telemetry.metadata.raindrop.userId", mergedCtx.userId),
|
|
2622
|
+
attrString("ai.telemetry.metadata.raindrop.ai.userId", mergedCtx.userId),
|
|
2532
2623
|
attrString("ai.telemetry.metadata.raindrop.convoId", mergedCtx.convoId),
|
|
2533
2624
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
2534
2625
|
...attrsFromHeaders(isRecord(arg) ? arg["headers"] : void 0),
|
|
@@ -2891,31 +2982,44 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
2891
2982
|
properties: wrapTimeCtx.properties
|
|
2892
2983
|
}
|
|
2893
2984
|
});
|
|
2894
|
-
const registerFn = aiSDK
|
|
2895
|
-
if (
|
|
2985
|
+
const registerFn = resolveRegisterTelemetry(aiSDK);
|
|
2986
|
+
if (registerFn) {
|
|
2896
2987
|
registerFn(integration);
|
|
2897
2988
|
}
|
|
2898
2989
|
if (debug) {
|
|
2899
|
-
console.log(
|
|
2990
|
+
console.log(
|
|
2991
|
+
"[raindrop-ai/ai-sdk] nativeTelemetry: registered RaindropTelemetryIntegration (Proxy installed for per-call metadata propagation)"
|
|
2992
|
+
);
|
|
2900
2993
|
}
|
|
2901
2994
|
const selfDiagnostics2 = normalizeSelfDiagnosticsConfig(deps.options.selfDiagnostics);
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2995
|
+
const jsonSchemaFactory = selfDiagnostics2 ? resolveJsonSchemaFactory(aiSDK) : void 0;
|
|
2996
|
+
const metadataAwareOps = /* @__PURE__ */ new Set([
|
|
2997
|
+
"generateText",
|
|
2998
|
+
"streamText",
|
|
2999
|
+
"generateObject",
|
|
3000
|
+
"streamObject",
|
|
3001
|
+
"embed",
|
|
3002
|
+
"embedMany",
|
|
3003
|
+
"rerank"
|
|
3004
|
+
]);
|
|
3005
|
+
const selfDiagnosticsOps = /* @__PURE__ */ new Set(["generateText", "streamText"]);
|
|
3006
|
+
const proxyTarget2 = isModuleNamespace(aiSDK) ? Object.setPrototypeOf({}, aiSDK) : aiSDK;
|
|
3007
|
+
return new Proxy(proxyTarget2, {
|
|
3008
|
+
get(target, prop, receiver) {
|
|
3009
|
+
const original = Reflect.get(target, prop, receiver);
|
|
3010
|
+
if (typeof prop !== "string" || !metadataAwareOps.has(prop) || !isFunction(original)) {
|
|
3011
|
+
return original;
|
|
3012
|
+
}
|
|
3013
|
+
const propName = prop;
|
|
3014
|
+
return (...callArgs) => {
|
|
3015
|
+
var _a2, _b2, _c2;
|
|
3016
|
+
const arg = callArgs[0];
|
|
3017
|
+
const callMetadata = readRaindropCallMetadataFromArgs(callArgs);
|
|
3018
|
+
const callOriginal = () => original.call(aiSDK, ...callArgs);
|
|
3019
|
+
if (selfDiagnostics2 && selfDiagnosticsOps.has(propName) && isRecord(arg)) {
|
|
2916
3020
|
const telemetry = extractExperimentalTelemetry(arg);
|
|
2917
3021
|
const callMeta = (telemetry == null ? void 0 : telemetry.metadata) ? extractRaindropMetadata(telemetry.metadata) : {};
|
|
2918
|
-
const perCallEventIdExplicit = (_a2 =
|
|
3022
|
+
const perCallEventIdExplicit = (_b2 = (_a2 = callMetadata == null ? void 0 : callMetadata.eventId) != null ? _a2 : callMeta.eventId) != null ? _b2 : wrapTimeCtx.eventId;
|
|
2919
3023
|
const perCallEventId = perCallEventIdExplicit != null ? perCallEventIdExplicit : randomUUID();
|
|
2920
3024
|
const perCallEventIdGenerated = !perCallEventIdExplicit;
|
|
2921
3025
|
const perCallCtx = {
|
|
@@ -2952,12 +3056,25 @@ function wrapAISDK(aiSDK, deps) {
|
|
|
2952
3056
|
metadata: mergedMetadata
|
|
2953
3057
|
}
|
|
2954
3058
|
};
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
3059
|
+
const mergedAlsMetadata = {
|
|
3060
|
+
...callMetadata != null ? callMetadata : {},
|
|
3061
|
+
eventId: perCallEventId,
|
|
3062
|
+
eventIdGenerated: perCallEventIdGenerated || (callMetadata == null ? void 0 : callMetadata.eventIdGenerated),
|
|
3063
|
+
rawMetadata: {
|
|
3064
|
+
...(_c2 = callMetadata == null ? void 0 : callMetadata.rawMetadata) != null ? _c2 : {},
|
|
3065
|
+
"raindrop.eventId": perCallEventId,
|
|
3066
|
+
...perCallEventIdGenerated ? { "raindrop.internal.eventIdGenerated": "true" } : {}
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3069
|
+
return runWithRaindropCallMetadata(mergedAlsMetadata, callOriginal);
|
|
3070
|
+
}
|
|
3071
|
+
if (callMetadata) {
|
|
3072
|
+
return runWithRaindropCallMetadata(callMetadata, callOriginal);
|
|
3073
|
+
}
|
|
3074
|
+
return callOriginal();
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
});
|
|
2961
3078
|
}
|
|
2962
3079
|
const instrumentedOps = /* @__PURE__ */ new Set([
|
|
2963
3080
|
"generateText",
|
|
@@ -3093,7 +3210,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
3093
3210
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
3094
3211
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
3095
3212
|
attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
|
|
3096
|
-
attrString("ai.telemetry.metadata.raindrop.userId", ctx.userId),
|
|
3213
|
+
attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
|
|
3097
3214
|
attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
|
|
3098
3215
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
3099
3216
|
...attrsFromHeaders(mergedArgs["headers"]),
|
|
@@ -3301,7 +3418,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
3301
3418
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
3302
3419
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
3303
3420
|
attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
|
|
3304
|
-
attrString("ai.telemetry.metadata.raindrop.userId", ctx.userId),
|
|
3421
|
+
attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
|
|
3305
3422
|
attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
|
|
3306
3423
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
3307
3424
|
...attrsFromHeaders(mergedArgs["headers"]),
|
|
@@ -4244,10 +4361,14 @@ function createRaindropAISDK(opts) {
|
|
|
4244
4361
|
}
|
|
4245
4362
|
|
|
4246
4363
|
exports.RaindropTelemetryIntegration = RaindropTelemetryIntegration;
|
|
4364
|
+
exports._resetRaindropCallMetadataStorage = _resetRaindropCallMetadataStorage;
|
|
4247
4365
|
exports._resetWarnedMissingUserId = _resetWarnedMissingUserId;
|
|
4248
4366
|
exports.createRaindropAISDK = createRaindropAISDK;
|
|
4249
4367
|
exports.currentSpan = currentSpan;
|
|
4250
4368
|
exports.eventMetadata = eventMetadata;
|
|
4251
4369
|
exports.eventMetadataFromChatRequest = eventMetadataFromChatRequest;
|
|
4252
4370
|
exports.getContextManager = getContextManager;
|
|
4371
|
+
exports.getCurrentRaindropCallMetadata = getCurrentRaindropCallMetadata;
|
|
4372
|
+
exports.readRaindropCallMetadataFromArgs = readRaindropCallMetadataFromArgs;
|
|
4373
|
+
exports.runWithRaindropCallMetadata = runWithRaindropCallMetadata;
|
|
4253
4374
|
exports.withCurrent = withCurrent;
|