@raindrop-ai/ai-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ETGFVXYM.mjs → chunk-RBVZVH46.mjs} +114 -24
- package/dist/{index-CUR4qgwL.d.mts → index-BUWOlY-2.d.mts} +57 -8
- package/dist/{index-CUR4qgwL.d.ts → index-BUWOlY-2.d.ts} +57 -8
- package/dist/index.browser.d.mts +57 -8
- package/dist/index.browser.d.ts +57 -8
- package/dist/index.browser.js +114 -24
- package/dist/index.browser.mjs +114 -24
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +114 -24
- 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 +114 -24
- package/dist/index.workers.mjs +1 -1
- package/package.json +2 -2
package/dist/index.browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/chunk-
|
|
1
|
+
// ../core/dist/chunk-QTUH3BHZ.js
|
|
2
2
|
function normalizeFeatureFlags(input) {
|
|
3
3
|
if (Array.isArray(input)) {
|
|
4
4
|
return Object.fromEntries(input.map((name) => [name, "true"]));
|
|
@@ -441,19 +441,52 @@ function projectIdHeaders(projectId) {
|
|
|
441
441
|
var SHUTDOWN_DEADLINE_MS = 1e4;
|
|
442
442
|
var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
443
443
|
function mergePatches(target, source) {
|
|
444
|
-
var _a, _b, _c, _d, _e, _f;
|
|
444
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
445
445
|
const out = { ...target, ...source };
|
|
446
446
|
if (target.properties || source.properties) {
|
|
447
447
|
out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
|
|
448
448
|
}
|
|
449
|
+
if (target.usage || source.usage) {
|
|
450
|
+
out.usage = { ...(_c = target.usage) != null ? _c : {} };
|
|
451
|
+
if (((_d = source.usage) == null ? void 0 : _d.promptTokens) !== void 0) {
|
|
452
|
+
out.usage.promptTokens = source.usage.promptTokens;
|
|
453
|
+
}
|
|
454
|
+
if (((_e = source.usage) == null ? void 0 : _e.completionTokens) !== void 0) {
|
|
455
|
+
out.usage.completionTokens = source.usage.completionTokens;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (source.error === void 0) {
|
|
459
|
+
out.error = target.error;
|
|
460
|
+
}
|
|
449
461
|
if (target.featureFlags || source.featureFlags) {
|
|
450
|
-
out.featureFlags = { ...(
|
|
462
|
+
out.featureFlags = { ...(_f = target.featureFlags) != null ? _f : {}, ...(_g = source.featureFlags) != null ? _g : {} };
|
|
451
463
|
}
|
|
452
464
|
if (target.attachments || source.attachments) {
|
|
453
|
-
out.attachments = [...(
|
|
465
|
+
out.attachments = [...(_h = target.attachments) != null ? _h : [], ...(_i = source.attachments) != null ? _i : []];
|
|
454
466
|
}
|
|
455
467
|
return out;
|
|
456
468
|
}
|
|
469
|
+
function isErrorLike(value) {
|
|
470
|
+
return value !== null && typeof value === "object";
|
|
471
|
+
}
|
|
472
|
+
function eventTelemetryProperties(patch) {
|
|
473
|
+
var _a, _b;
|
|
474
|
+
const properties = {};
|
|
475
|
+
if (((_a = patch.usage) == null ? void 0 : _a.promptTokens) !== void 0 && Number.isFinite(patch.usage.promptTokens)) {
|
|
476
|
+
properties["ai.usage.prompt_tokens"] = patch.usage.promptTokens;
|
|
477
|
+
}
|
|
478
|
+
if (((_b = patch.usage) == null ? void 0 : _b.completionTokens) !== void 0 && Number.isFinite(patch.usage.completionTokens)) {
|
|
479
|
+
properties["ai.usage.completion_tokens"] = patch.usage.completionTokens;
|
|
480
|
+
}
|
|
481
|
+
if (patch.error !== void 0 && patch.error !== null) {
|
|
482
|
+
const constructorName = patch.error instanceof Error && patch.error.constructor !== Error ? patch.error.constructor.name : void 0;
|
|
483
|
+
const errorType = patch.error instanceof Error ? patch.error.name && patch.error.name !== "Error" ? patch.error.name : constructorName || patch.error.name || "Error" : isErrorLike(patch.error) && typeof patch.error.name === "string" && patch.error.name.length > 0 ? patch.error.name : "Error";
|
|
484
|
+
const errorMessage = patch.error instanceof Error ? patch.error.message : isErrorLike(patch.error) && typeof patch.error.message === "string" ? patch.error.message : String(patch.error);
|
|
485
|
+
properties["error.type"] = errorType;
|
|
486
|
+
properties["error.message"] = errorMessage;
|
|
487
|
+
}
|
|
488
|
+
return properties;
|
|
489
|
+
}
|
|
457
490
|
var EventShipper = class {
|
|
458
491
|
constructor(opts) {
|
|
459
492
|
this.buffers = /* @__PURE__ */ new Map();
|
|
@@ -702,6 +735,11 @@ var EventShipper = class {
|
|
|
702
735
|
return;
|
|
703
736
|
}
|
|
704
737
|
const { wizardSession, ...restProperties } = (_e = accumulated.properties) != null ? _e : {};
|
|
738
|
+
let telemetryProperties = {};
|
|
739
|
+
try {
|
|
740
|
+
telemetryProperties = eventTelemetryProperties(accumulated);
|
|
741
|
+
} catch (e) {
|
|
742
|
+
}
|
|
705
743
|
const convoId = (_f = accumulated.convoId) != null ? _f : sticky.convoId;
|
|
706
744
|
const isPending = (_h = (_g = accumulated.isPending) != null ? _g : sticky.isPending) != null ? _h : true;
|
|
707
745
|
const payload = {
|
|
@@ -711,12 +749,13 @@ var EventShipper = class {
|
|
|
711
749
|
timestamp: (_i = accumulated.timestamp) != null ? _i : (/* @__PURE__ */ new Date()).toISOString(),
|
|
712
750
|
ai_data: {
|
|
713
751
|
input: accumulated.input,
|
|
714
|
-
output: accumulated.output,
|
|
752
|
+
output: accumulated.error !== void 0 && accumulated.error !== null ? void 0 : accumulated.output,
|
|
715
753
|
model: accumulated.model,
|
|
716
754
|
convo_id: convoId
|
|
717
755
|
},
|
|
718
756
|
properties: {
|
|
719
757
|
...restProperties,
|
|
758
|
+
...telemetryProperties,
|
|
720
759
|
...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
|
|
721
760
|
$context: this.context
|
|
722
761
|
},
|
|
@@ -874,6 +913,13 @@ function redactJsonAttributeValue(key, value) {
|
|
|
874
913
|
if (scrubbedJson === json) return void 0;
|
|
875
914
|
return { stringValue: scrubbedJson };
|
|
876
915
|
}
|
|
916
|
+
function identityAttrs(args) {
|
|
917
|
+
return [
|
|
918
|
+
attrString("ai.telemetry.metadata.raindrop.ai.userId", args.userId),
|
|
919
|
+
attrString("ai.telemetry.metadata.raindrop.convoId", args.convoId),
|
|
920
|
+
attrString("ai.telemetry.metadata.raindrop.eventName", args.eventName)
|
|
921
|
+
];
|
|
922
|
+
}
|
|
877
923
|
function applyOtelSpanAttributeLimit(limit) {
|
|
878
924
|
var _a, _b;
|
|
879
925
|
try {
|
|
@@ -998,6 +1044,7 @@ var TraceShipper = class {
|
|
|
998
1044
|
const started = (_a = args.startTimeUnixNano) != null ? _a : nowUnixNanoString();
|
|
999
1045
|
const attrs = [
|
|
1000
1046
|
attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId),
|
|
1047
|
+
...identityAttrs(args),
|
|
1001
1048
|
attrString("ai.operationId", args.operationId)
|
|
1002
1049
|
];
|
|
1003
1050
|
if ((_b = args.attributes) == null ? void 0 : _b.length) attrs.push(...args.attributes);
|
|
@@ -1053,7 +1100,8 @@ var TraceShipper = class {
|
|
|
1053
1100
|
var _a;
|
|
1054
1101
|
const ids = createSpanIds(args.parent);
|
|
1055
1102
|
const attrs = [
|
|
1056
|
-
attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId)
|
|
1103
|
+
attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId),
|
|
1104
|
+
...identityAttrs(args)
|
|
1057
1105
|
];
|
|
1058
1106
|
if ((_a = args.attributes) == null ? void 0 : _a.length) attrs.push(...args.attributes);
|
|
1059
1107
|
const otlp = buildOtlpSpan({
|
|
@@ -1309,7 +1357,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
|
|
|
1309
1357
|
// package.json
|
|
1310
1358
|
var package_default = {
|
|
1311
1359
|
name: "@raindrop-ai/ai-sdk",
|
|
1312
|
-
version: "0.
|
|
1360
|
+
version: "0.2.0"};
|
|
1313
1361
|
|
|
1314
1362
|
// src/internal/version.ts
|
|
1315
1363
|
var libraryName = package_default.name;
|
|
@@ -2244,7 +2292,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2244
2292
|
};
|
|
2245
2293
|
// ── onStart ─────────────────────────────────────────────────────────────
|
|
2246
2294
|
this.onStart = (event) => {
|
|
2247
|
-
var _a, _b, _c, _d, _e;
|
|
2295
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2248
2296
|
if (event.isEnabled === false) return;
|
|
2249
2297
|
const isEmbed = event.operationId === "ai.embed" || event.operationId === "ai.embedMany";
|
|
2250
2298
|
const recordInputs = event.recordInputs !== false;
|
|
@@ -2254,15 +2302,20 @@ var RaindropTelemetryIntegration = class {
|
|
|
2254
2302
|
const callContextMetadata = getCurrentRaindropCallMetadata();
|
|
2255
2303
|
const metadata = eventMetadata2 != null ? eventMetadata2 : callContextMetadata == null ? void 0 : callContextMetadata.rawMetadata;
|
|
2256
2304
|
const callMeta = this.extractRaindropMetadata(metadata);
|
|
2305
|
+
const identity = {
|
|
2306
|
+
userId: (_b = callMeta.userId) != null ? _b : (_a = this.defaultContext) == null ? void 0 : _a.userId,
|
|
2307
|
+
convoId: (_d = callMeta.convoId) != null ? _d : (_c = this.defaultContext) == null ? void 0 : _c.convoId,
|
|
2308
|
+
eventName: (_f = callMeta.eventName) != null ? _f : (_e = this.defaultContext) == null ? void 0 : _e.eventName
|
|
2309
|
+
};
|
|
2257
2310
|
const inherited = getContextManager().getParentSpanIds();
|
|
2258
2311
|
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;
|
|
2259
2312
|
const explicitEventId = callMeta.eventId && !eventIdGenerated ? callMeta.eventId : void 0;
|
|
2260
|
-
const eventId = (
|
|
2313
|
+
const eventId = (_j = (_i = (_h = explicitEventId != null ? explicitEventId : (_g = this.defaultContext) == null ? void 0 : _g.eventId) != null ? _h : inherited == null ? void 0 : inherited.eventId) != null ? _i : callMeta.eventId) != null ? _j : randomUUID();
|
|
2261
2314
|
const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
|
|
2262
2315
|
const { operationName, resourceName } = opName(event.operationId, functionId);
|
|
2263
2316
|
const parentToolContext = !isEmbed && this.subagentWrapping ? getCurrentParentToolContext() : void 0;
|
|
2264
2317
|
const metadataSubagentName = !isEmbed && this.subagentWrapping && parentToolContext === void 0 ? typeof (metadata == null ? void 0 : metadata["eve.subagent.name"]) === "string" ? metadata["eve.subagent.name"] : typeof (metadata == null ? void 0 : metadata["ash.subagent.name"]) === "string" ? metadata["ash.subagent.name"] : void 0 : void 0;
|
|
2265
|
-
const subagentName = (
|
|
2318
|
+
const subagentName = (_k = parentToolContext == null ? void 0 : parentToolContext.toolName) != null ? _k : metadataSubagentName;
|
|
2266
2319
|
let subagentToolCallSpan;
|
|
2267
2320
|
let rootParentOverride;
|
|
2268
2321
|
if (subagentName && this.sendTraces) {
|
|
@@ -2275,6 +2328,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2275
2328
|
name: subagentName,
|
|
2276
2329
|
parent: inheritedParent,
|
|
2277
2330
|
eventId,
|
|
2331
|
+
...identity,
|
|
2278
2332
|
operationId: "ai.toolCall",
|
|
2279
2333
|
attributes: [
|
|
2280
2334
|
attrString("operation.name", "ai.toolCall"),
|
|
@@ -2291,6 +2345,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2291
2345
|
name: "agent.subagent",
|
|
2292
2346
|
parent: subagentParentRef,
|
|
2293
2347
|
eventId,
|
|
2348
|
+
...identity,
|
|
2294
2349
|
operationId: "agent.subagent",
|
|
2295
2350
|
attributes: [
|
|
2296
2351
|
attrString("operation.name", "agent.subagent"),
|
|
@@ -2318,6 +2373,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2318
2373
|
name: event.operationId,
|
|
2319
2374
|
parent: rootParentOverride != null ? rootParentOverride : inheritedParent,
|
|
2320
2375
|
eventId,
|
|
2376
|
+
...identity,
|
|
2321
2377
|
operationId: event.operationId,
|
|
2322
2378
|
attributes: [
|
|
2323
2379
|
attrString("operation.name", operationName),
|
|
@@ -2325,13 +2381,14 @@ var RaindropTelemetryIntegration = class {
|
|
|
2325
2381
|
attrString("ai.telemetry.functionId", functionId),
|
|
2326
2382
|
attrString("ai.model.provider", event.provider),
|
|
2327
2383
|
attrString("ai.model.id", event.modelId),
|
|
2328
|
-
// Filter out
|
|
2329
|
-
//
|
|
2330
|
-
// auto-generated ID would
|
|
2384
|
+
// Filter out identity keys (eventId/userId/convoId/eventName) from
|
|
2385
|
+
// metadata attrs since TraceShipper already stamps them via dedicated
|
|
2386
|
+
// args. Without this, eventMetadata()'s auto-generated ID would
|
|
2387
|
+
// duplicate and override the resolved one.
|
|
2331
2388
|
...attrsFromTelemetryMetadata(
|
|
2332
2389
|
metadata ? Object.fromEntries(
|
|
2333
2390
|
Object.entries(metadata).filter(
|
|
2334
|
-
([k]) => k !== "raindrop.eventId" && k !== "raindrop.internal.eventIdGenerated"
|
|
2391
|
+
([k]) => k !== "raindrop.eventId" && k !== "raindrop.internal.eventIdGenerated" && k !== "raindrop.userId" && k !== "raindrop.convoId" && k !== "raindrop.eventName"
|
|
2335
2392
|
)
|
|
2336
2393
|
) : void 0
|
|
2337
2394
|
),
|
|
@@ -2343,6 +2400,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2343
2400
|
this.callStates.set(event.callId, {
|
|
2344
2401
|
operationId: event.operationId,
|
|
2345
2402
|
eventId,
|
|
2403
|
+
identity,
|
|
2346
2404
|
rootSpan,
|
|
2347
2405
|
rootParent: rootSpan ? this.spanParentRef(rootSpan) : rootParentOverride != null ? rootParentOverride : inheritedParent,
|
|
2348
2406
|
stepSpan: void 0,
|
|
@@ -2394,6 +2452,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2394
2452
|
name: stepOperationId,
|
|
2395
2453
|
parent: state.rootParent,
|
|
2396
2454
|
eventId: state.eventId,
|
|
2455
|
+
...state.identity,
|
|
2397
2456
|
operationId: stepOperationId,
|
|
2398
2457
|
attributes: [
|
|
2399
2458
|
attrString("operation.name", operationName),
|
|
@@ -2527,6 +2586,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2527
2586
|
name: event.operationId,
|
|
2528
2587
|
parent: state.rootParent,
|
|
2529
2588
|
eventId: state.eventId,
|
|
2589
|
+
...state.identity,
|
|
2530
2590
|
operationId: event.operationId,
|
|
2531
2591
|
attributes: [
|
|
2532
2592
|
attrString("operation.name", operationName),
|
|
@@ -2793,6 +2853,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2793
2853
|
name: "ai.toolCall",
|
|
2794
2854
|
parent: state.stepParent,
|
|
2795
2855
|
eventId: state.eventId,
|
|
2856
|
+
...state.identity,
|
|
2796
2857
|
operationId: "ai.toolCall",
|
|
2797
2858
|
attributes: [
|
|
2798
2859
|
attrString("operation.name", operationName),
|
|
@@ -2870,6 +2931,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2870
2931
|
name: "ai.toolCall",
|
|
2871
2932
|
parent: state.stepParent,
|
|
2872
2933
|
eventId: state.eventId,
|
|
2934
|
+
...state.identity,
|
|
2873
2935
|
operationId: "ai.toolCall",
|
|
2874
2936
|
attributes: [
|
|
2875
2937
|
attrString("operation.name", operationName),
|
|
@@ -2973,7 +3035,7 @@ var RaindropTelemetryIntegration = class {
|
|
|
2973
3035
|
...callMeta.properties
|
|
2974
3036
|
};
|
|
2975
3037
|
const featureFlags = {
|
|
2976
|
-
...(_g = this.defaultContext) == null ? void 0 : _g.featureFlags,
|
|
3038
|
+
...((_g = this.defaultContext) == null ? void 0 : _g.featureFlags) ? normalizeFeatureFlags(this.defaultContext.featureFlags) : {},
|
|
2977
3039
|
...callMeta.featureFlags
|
|
2978
3040
|
};
|
|
2979
3041
|
const convoId = (_i = callMeta.convoId) != null ? _i : (_h = this.defaultContext) == null ? void 0 : _h.convoId;
|
|
@@ -3537,6 +3599,9 @@ function teeStreamObjectBaseStream(result) {
|
|
|
3537
3599
|
} catch (e) {
|
|
3538
3600
|
}
|
|
3539
3601
|
}
|
|
3602
|
+
function identityFromContext(ctx) {
|
|
3603
|
+
return { userId: ctx.userId, convoId: ctx.convoId, eventName: ctx.eventName };
|
|
3604
|
+
}
|
|
3540
3605
|
function setupOperation(params) {
|
|
3541
3606
|
var _a, _b, _c;
|
|
3542
3607
|
const {
|
|
@@ -3568,6 +3633,7 @@ function setupOperation(params) {
|
|
|
3568
3633
|
name: outerOperationId,
|
|
3569
3634
|
parent: inheritedParent,
|
|
3570
3635
|
eventId,
|
|
3636
|
+
...identityFromContext(mergedCtx),
|
|
3571
3637
|
operationId: outerOperationId,
|
|
3572
3638
|
attributes: [
|
|
3573
3639
|
attrString("operation.name", operationName),
|
|
@@ -3576,9 +3642,6 @@ function setupOperation(params) {
|
|
|
3576
3642
|
attrString("ai.model.provider", modelInfoFromArgs.provider),
|
|
3577
3643
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
3578
3644
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
3579
|
-
attrString("ai.telemetry.metadata.raindrop.eventName", mergedCtx.eventName),
|
|
3580
|
-
attrString("ai.telemetry.metadata.raindrop.ai.userId", mergedCtx.userId),
|
|
3581
|
-
attrString("ai.telemetry.metadata.raindrop.convoId", mergedCtx.convoId),
|
|
3582
3645
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
3583
3646
|
...attrsFromHeaders(isRecord(arg) ? arg["headers"] : void 0),
|
|
3584
3647
|
...attrsFromSettings(arg),
|
|
@@ -3668,6 +3731,7 @@ function createFinalize(params) {
|
|
|
3668
3731
|
responseMessages,
|
|
3669
3732
|
rootSpan: setup.rootSpan,
|
|
3670
3733
|
eventId: setup.eventId,
|
|
3734
|
+
...identityFromContext(setup.ctx),
|
|
3671
3735
|
telemetry: setup.telemetry,
|
|
3672
3736
|
toolCalls: setup.toolCalls,
|
|
3673
3737
|
traceShipper,
|
|
@@ -3706,6 +3770,11 @@ function createFinalize(params) {
|
|
|
3706
3770
|
input,
|
|
3707
3771
|
output,
|
|
3708
3772
|
model: finalModel,
|
|
3773
|
+
usage: {
|
|
3774
|
+
promptTokens: usage == null ? void 0 : usage.inputTokens,
|
|
3775
|
+
completionTokens: usage == null ? void 0 : usage.outputTokens
|
|
3776
|
+
},
|
|
3777
|
+
error,
|
|
3709
3778
|
properties: patch.properties,
|
|
3710
3779
|
featureFlags: patch.featureFlags,
|
|
3711
3780
|
attachments: patch.attachments,
|
|
@@ -3740,6 +3809,7 @@ function startToolSpan(toolCall, rootSpan, ctx, startTimeUnixNano) {
|
|
|
3740
3809
|
name: "ai.toolCall",
|
|
3741
3810
|
parent: { traceIdB64: rootSpan.ids.traceIdB64, spanIdB64: rootSpan.ids.spanIdB64 },
|
|
3742
3811
|
eventId: ctx.eventId,
|
|
3812
|
+
...identityFromContext(ctx),
|
|
3743
3813
|
operationId: "ai.toolCall",
|
|
3744
3814
|
attributes: [
|
|
3745
3815
|
attrString("operation.name", operationName),
|
|
@@ -3777,6 +3847,9 @@ function emitTranscriptToolCallSpans(params) {
|
|
|
3777
3847
|
}
|
|
3778
3848
|
const ctx = {
|
|
3779
3849
|
eventId: params.eventId,
|
|
3850
|
+
userId: params.userId,
|
|
3851
|
+
convoId: params.convoId,
|
|
3852
|
+
eventName: params.eventName,
|
|
3780
3853
|
telemetry: params.telemetry,
|
|
3781
3854
|
traceShipper: params.traceShipper
|
|
3782
3855
|
};
|
|
@@ -4156,6 +4229,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
4156
4229
|
name: outerOperationId,
|
|
4157
4230
|
parent: inheritedParent,
|
|
4158
4231
|
eventId,
|
|
4232
|
+
...identityFromContext(ctx),
|
|
4159
4233
|
operationId: outerOperationId,
|
|
4160
4234
|
attributes: [
|
|
4161
4235
|
attrString("operation.name", operationName),
|
|
@@ -4164,9 +4238,6 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
4164
4238
|
attrString("ai.model.provider", modelInfoFromArgs.provider),
|
|
4165
4239
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
4166
4240
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
4167
|
-
attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
|
|
4168
|
-
attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
|
|
4169
|
-
attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
|
|
4170
4241
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
4171
4242
|
...attrsFromHeaders(mergedArgs["headers"]),
|
|
4172
4243
|
...attrsFromSettings(mergedArgs),
|
|
@@ -4231,6 +4302,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
4231
4302
|
responseMessages,
|
|
4232
4303
|
rootSpan,
|
|
4233
4304
|
eventId,
|
|
4305
|
+
...identityFromContext(ctx),
|
|
4234
4306
|
telemetry,
|
|
4235
4307
|
toolCalls,
|
|
4236
4308
|
traceShipper: deps.traceShipper,
|
|
@@ -4283,6 +4355,11 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
|
|
|
4283
4355
|
input,
|
|
4284
4356
|
output,
|
|
4285
4357
|
model: finalModel,
|
|
4358
|
+
usage: {
|
|
4359
|
+
promptTokens: usage == null ? void 0 : usage.inputTokens,
|
|
4360
|
+
completionTokens: usage == null ? void 0 : usage.outputTokens
|
|
4361
|
+
},
|
|
4362
|
+
error,
|
|
4286
4363
|
properties: patch.properties,
|
|
4287
4364
|
featureFlags: patch.featureFlags,
|
|
4288
4365
|
attachments: patch.attachments,
|
|
@@ -4366,6 +4443,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
4366
4443
|
name: outerOperationId,
|
|
4367
4444
|
parent: inheritedParent,
|
|
4368
4445
|
eventId,
|
|
4446
|
+
...identityFromContext(ctx),
|
|
4369
4447
|
operationId: outerOperationId,
|
|
4370
4448
|
attributes: [
|
|
4371
4449
|
attrString("operation.name", operationName),
|
|
@@ -4374,9 +4452,6 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
4374
4452
|
attrString("ai.model.provider", modelInfoFromArgs.provider),
|
|
4375
4453
|
attrString("ai.model.id", modelInfoFromArgs.modelId),
|
|
4376
4454
|
attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
|
|
4377
|
-
attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
|
|
4378
|
-
attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
|
|
4379
|
-
attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
|
|
4380
4455
|
...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
|
|
4381
4456
|
...attrsFromHeaders(mergedArgs["headers"]),
|
|
4382
4457
|
...attrsFromSettings(mergedArgs),
|
|
@@ -4441,6 +4516,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
4441
4516
|
responseMessages,
|
|
4442
4517
|
rootSpan,
|
|
4443
4518
|
eventId,
|
|
4519
|
+
...identityFromContext(ctx),
|
|
4444
4520
|
telemetry,
|
|
4445
4521
|
toolCalls,
|
|
4446
4522
|
traceShipper: deps.traceShipper,
|
|
@@ -4493,6 +4569,11 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
|
|
|
4493
4569
|
input,
|
|
4494
4570
|
output,
|
|
4495
4571
|
model: finalModel,
|
|
4572
|
+
usage: {
|
|
4573
|
+
promptTokens: usage == null ? void 0 : usage.inputTokens,
|
|
4574
|
+
completionTokens: usage == null ? void 0 : usage.outputTokens
|
|
4575
|
+
},
|
|
4576
|
+
error,
|
|
4496
4577
|
properties: patch.properties,
|
|
4497
4578
|
featureFlags: patch.featureFlags,
|
|
4498
4579
|
attachments: patch.attachments,
|
|
@@ -4590,6 +4671,7 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
|
|
|
4590
4671
|
name: "ai.toolCall",
|
|
4591
4672
|
parent,
|
|
4592
4673
|
eventId: ctx.eventId,
|
|
4674
|
+
...identityFromContext(ctx.context),
|
|
4593
4675
|
operationId: "ai.toolCall",
|
|
4594
4676
|
attributes: [
|
|
4595
4677
|
attrString("operation.name", operationName),
|
|
@@ -4950,6 +5032,7 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
4950
5032
|
name: operationId,
|
|
4951
5033
|
parent,
|
|
4952
5034
|
eventId: ctx.eventId,
|
|
5035
|
+
...identityFromContext(ctx.context),
|
|
4953
5036
|
operationId,
|
|
4954
5037
|
attributes: [
|
|
4955
5038
|
attrString("operation.name", operationName),
|
|
@@ -5033,6 +5116,7 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
|
|
|
5033
5116
|
name: operationId,
|
|
5034
5117
|
parent,
|
|
5035
5118
|
eventId: ctx.eventId,
|
|
5119
|
+
...identityFromContext(ctx.context),
|
|
5036
5120
|
operationId,
|
|
5037
5121
|
attributes: [
|
|
5038
5122
|
attrString("operation.name", operationName),
|
|
@@ -5293,6 +5377,9 @@ function createRaindropAISDK(opts) {
|
|
|
5293
5377
|
const internal = traceShipper.startSpan({
|
|
5294
5378
|
name: args.name,
|
|
5295
5379
|
eventId: args.eventId,
|
|
5380
|
+
userId: args.userId,
|
|
5381
|
+
convoId: args.convoId,
|
|
5382
|
+
eventName: args.eventName,
|
|
5296
5383
|
parent,
|
|
5297
5384
|
operationId: args.operationId,
|
|
5298
5385
|
attributes: attrs
|
|
@@ -5327,6 +5414,9 @@ function createRaindropAISDK(opts) {
|
|
|
5327
5414
|
const internal = traceShipper.startSpan({
|
|
5328
5415
|
name: args.name,
|
|
5329
5416
|
eventId: args.eventId,
|
|
5417
|
+
userId: args.userId,
|
|
5418
|
+
convoId: args.convoId,
|
|
5419
|
+
eventName: args.eventName,
|
|
5330
5420
|
parent,
|
|
5331
5421
|
operationId: args.operationId,
|
|
5332
5422
|
attributes: startAttrs,
|
package/dist/index.node.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, D as DEFAULT_MAX_TEXT_FIELD_CHARS, h as DEFAULT_REDACT_ATTRIBUTE_KEYS, i as DEFAULT_SECRET_KEY_NAMES, E as EndSpanArgs, j as EventBuilder, k as EventMetadataOptions, F as FeatureFlagValue, l as FeatureFlags, I as IdentifyInput, O as OtlpAnyValue, m as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, n as RaindropAISDKClient, o as RaindropAISDKContext, p as RaindropAISDKOptions, q as RaindropCallMetadata, r as RaindropTelemetryIntegration, s as RaindropTelemetryIntegrationOptions, t as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, u as SelfDiagnosticsSignalDefinition, v as SelfDiagnosticsSignalDefinitions, w as SelfDiagnosticsTool, x as SelfDiagnosticsToolInput, y as SelfDiagnosticsToolOptions, z as SelfDiagnosticsToolResult, G as StartSpanArgs, T as TRUNCATION_MARKER, H as TraceSpan, J as TransformSpanHook, W as WrapAISDKOptions, K as WrappedAI, L as WrappedAISDK, _ as _resetParentToolContextStorage, M as _resetRaindropCallMetadataStorage, N as _resetWarnedMissingUserId, Q as boundedStringify, U as capText, V as clearParentToolContext, X as createRaindropAISDK, Y as currentSpan, Z as defaultTransformSpan, $ as enterParentToolContext, a0 as eventMetadata, a1 as eventMetadataFromChatRequest, a2 as getContextManager, a3 as getCurrentParentToolContext, a4 as getCurrentRaindropCallMetadata, a5 as normalizeFeatureFlags, a6 as raindrop, a7 as readRaindropCallMetadataFromArgs, a8 as redactJsonAttributeValue, a9 as redactSecretsInObject, aa as runWithParentToolContext, ab as runWithRaindropCallMetadata, ac as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, D as DEFAULT_MAX_TEXT_FIELD_CHARS, h as DEFAULT_REDACT_ATTRIBUTE_KEYS, i as DEFAULT_SECRET_KEY_NAMES, E as EndSpanArgs, j as EventBuilder, k as EventMetadataOptions, F as FeatureFlagValue, l as FeatureFlags, I as IdentifyInput, O as OtlpAnyValue, m as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, n as RaindropAISDKClient, o as RaindropAISDKContext, p as RaindropAISDKOptions, q as RaindropCallMetadata, r as RaindropTelemetryIntegration, s as RaindropTelemetryIntegrationOptions, t as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, u as SelfDiagnosticsSignalDefinition, v as SelfDiagnosticsSignalDefinitions, w as SelfDiagnosticsTool, x as SelfDiagnosticsToolInput, y as SelfDiagnosticsToolOptions, z as SelfDiagnosticsToolResult, G as StartSpanArgs, T as TRUNCATION_MARKER, H as TraceSpan, J as TransformSpanHook, W as WrapAISDKOptions, K as WrappedAI, L as WrappedAISDK, _ as _resetParentToolContextStorage, M as _resetRaindropCallMetadataStorage, N as _resetWarnedMissingUserId, Q as boundedStringify, U as capText, V as clearParentToolContext, X as createRaindropAISDK, Y as currentSpan, Z as defaultTransformSpan, $ as enterParentToolContext, a0 as eventMetadata, a1 as eventMetadataFromChatRequest, a2 as getContextManager, a3 as getCurrentParentToolContext, a4 as getCurrentRaindropCallMetadata, a5 as normalizeFeatureFlags, a6 as raindrop, a7 as readRaindropCallMetadataFromArgs, a8 as redactJsonAttributeValue, a9 as redactSecretsInObject, aa as runWithParentToolContext, ab as runWithRaindropCallMetadata, ac as withCurrent } from './index-BUWOlY-2.mjs';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
package/dist/index.node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, D as DEFAULT_MAX_TEXT_FIELD_CHARS, h as DEFAULT_REDACT_ATTRIBUTE_KEYS, i as DEFAULT_SECRET_KEY_NAMES, E as EndSpanArgs, j as EventBuilder, k as EventMetadataOptions, F as FeatureFlagValue, l as FeatureFlags, I as IdentifyInput, O as OtlpAnyValue, m as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, n as RaindropAISDKClient, o as RaindropAISDKContext, p as RaindropAISDKOptions, q as RaindropCallMetadata, r as RaindropTelemetryIntegration, s as RaindropTelemetryIntegrationOptions, t as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, u as SelfDiagnosticsSignalDefinition, v as SelfDiagnosticsSignalDefinitions, w as SelfDiagnosticsTool, x as SelfDiagnosticsToolInput, y as SelfDiagnosticsToolOptions, z as SelfDiagnosticsToolResult, G as StartSpanArgs, T as TRUNCATION_MARKER, H as TraceSpan, J as TransformSpanHook, W as WrapAISDKOptions, K as WrappedAI, L as WrappedAISDK, _ as _resetParentToolContextStorage, M as _resetRaindropCallMetadataStorage, N as _resetWarnedMissingUserId, Q as boundedStringify, U as capText, V as clearParentToolContext, X as createRaindropAISDK, Y as currentSpan, Z as defaultTransformSpan, $ as enterParentToolContext, a0 as eventMetadata, a1 as eventMetadataFromChatRequest, a2 as getContextManager, a3 as getCurrentParentToolContext, a4 as getCurrentRaindropCallMetadata, a5 as normalizeFeatureFlags, a6 as raindrop, a7 as readRaindropCallMetadataFromArgs, a8 as redactJsonAttributeValue, a9 as redactSecretsInObject, aa as runWithParentToolContext, ab as runWithRaindropCallMetadata, ac as withCurrent } from './index-
|
|
1
|
+
export { A as AISDKChatRequestLike, a as AISDKChatRequestMessageLike, b as AISDKMessage, c as AgentCallMetadata, d as AgentWithMetadata, e as Attachment, B as BuildEventPatch, C as ContextManager, f as ContextSpan, g as CreateSpanArgs, D as DEFAULT_MAX_TEXT_FIELD_CHARS, h as DEFAULT_REDACT_ATTRIBUTE_KEYS, i as DEFAULT_SECRET_KEY_NAMES, E as EndSpanArgs, j as EventBuilder, k as EventMetadataOptions, F as FeatureFlagValue, l as FeatureFlags, I as IdentifyInput, O as OtlpAnyValue, m as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, n as RaindropAISDKClient, o as RaindropAISDKContext, p as RaindropAISDKOptions, q as RaindropCallMetadata, r as RaindropTelemetryIntegration, s as RaindropTelemetryIntegrationOptions, t as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, u as SelfDiagnosticsSignalDefinition, v as SelfDiagnosticsSignalDefinitions, w as SelfDiagnosticsTool, x as SelfDiagnosticsToolInput, y as SelfDiagnosticsToolOptions, z as SelfDiagnosticsToolResult, G as StartSpanArgs, T as TRUNCATION_MARKER, H as TraceSpan, J as TransformSpanHook, W as WrapAISDKOptions, K as WrappedAI, L as WrappedAISDK, _ as _resetParentToolContextStorage, M as _resetRaindropCallMetadataStorage, N as _resetWarnedMissingUserId, Q as boundedStringify, U as capText, V as clearParentToolContext, X as createRaindropAISDK, Y as currentSpan, Z as defaultTransformSpan, $ as enterParentToolContext, a0 as eventMetadata, a1 as eventMetadataFromChatRequest, a2 as getContextManager, a3 as getCurrentParentToolContext, a4 as getCurrentRaindropCallMetadata, a5 as normalizeFeatureFlags, a6 as raindrop, a7 as readRaindropCallMetadataFromArgs, a8 as redactJsonAttributeValue, a9 as redactSecretsInObject, aa as runWithParentToolContext, ab as runWithRaindropCallMetadata, ac as withCurrent } from './index-BUWOlY-2.js';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|