@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.
@@ -4,7 +4,7 @@ var async_hooks = require('async_hooks');
4
4
 
5
5
  // src/index.workers.ts
6
6
 
7
- // ../core/dist/chunk-Y5LUB7OE.js
7
+ // ../core/dist/chunk-QTUH3BHZ.js
8
8
  function normalizeFeatureFlags(input) {
9
9
  if (Array.isArray(input)) {
10
10
  return Object.fromEntries(input.map((name) => [name, "true"]));
@@ -447,19 +447,52 @@ function projectIdHeaders(projectId) {
447
447
  var SHUTDOWN_DEADLINE_MS = 1e4;
448
448
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
449
449
  function mergePatches(target, source) {
450
- var _a, _b, _c, _d, _e, _f;
450
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
451
451
  const out = { ...target, ...source };
452
452
  if (target.properties || source.properties) {
453
453
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
454
454
  }
455
+ if (target.usage || source.usage) {
456
+ out.usage = { ...(_c = target.usage) != null ? _c : {} };
457
+ if (((_d = source.usage) == null ? void 0 : _d.promptTokens) !== void 0) {
458
+ out.usage.promptTokens = source.usage.promptTokens;
459
+ }
460
+ if (((_e = source.usage) == null ? void 0 : _e.completionTokens) !== void 0) {
461
+ out.usage.completionTokens = source.usage.completionTokens;
462
+ }
463
+ }
464
+ if (source.error === void 0) {
465
+ out.error = target.error;
466
+ }
455
467
  if (target.featureFlags || source.featureFlags) {
456
- out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
468
+ out.featureFlags = { ...(_f = target.featureFlags) != null ? _f : {}, ...(_g = source.featureFlags) != null ? _g : {} };
457
469
  }
458
470
  if (target.attachments || source.attachments) {
459
- out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
471
+ out.attachments = [...(_h = target.attachments) != null ? _h : [], ...(_i = source.attachments) != null ? _i : []];
460
472
  }
461
473
  return out;
462
474
  }
475
+ function isErrorLike(value) {
476
+ return value !== null && typeof value === "object";
477
+ }
478
+ function eventTelemetryProperties(patch) {
479
+ var _a, _b;
480
+ const properties = {};
481
+ if (((_a = patch.usage) == null ? void 0 : _a.promptTokens) !== void 0 && Number.isFinite(patch.usage.promptTokens)) {
482
+ properties["ai.usage.prompt_tokens"] = patch.usage.promptTokens;
483
+ }
484
+ if (((_b = patch.usage) == null ? void 0 : _b.completionTokens) !== void 0 && Number.isFinite(patch.usage.completionTokens)) {
485
+ properties["ai.usage.completion_tokens"] = patch.usage.completionTokens;
486
+ }
487
+ if (patch.error !== void 0 && patch.error !== null) {
488
+ const constructorName = patch.error instanceof Error && patch.error.constructor !== Error ? patch.error.constructor.name : void 0;
489
+ 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";
490
+ const errorMessage = patch.error instanceof Error ? patch.error.message : isErrorLike(patch.error) && typeof patch.error.message === "string" ? patch.error.message : String(patch.error);
491
+ properties["error.type"] = errorType;
492
+ properties["error.message"] = errorMessage;
493
+ }
494
+ return properties;
495
+ }
463
496
  var EventShipper = class {
464
497
  constructor(opts) {
465
498
  this.buffers = /* @__PURE__ */ new Map();
@@ -708,6 +741,11 @@ var EventShipper = class {
708
741
  return;
709
742
  }
710
743
  const { wizardSession, ...restProperties } = (_e = accumulated.properties) != null ? _e : {};
744
+ let telemetryProperties = {};
745
+ try {
746
+ telemetryProperties = eventTelemetryProperties(accumulated);
747
+ } catch (e) {
748
+ }
711
749
  const convoId = (_f = accumulated.convoId) != null ? _f : sticky.convoId;
712
750
  const isPending = (_h = (_g = accumulated.isPending) != null ? _g : sticky.isPending) != null ? _h : true;
713
751
  const payload = {
@@ -717,12 +755,13 @@ var EventShipper = class {
717
755
  timestamp: (_i = accumulated.timestamp) != null ? _i : (/* @__PURE__ */ new Date()).toISOString(),
718
756
  ai_data: {
719
757
  input: accumulated.input,
720
- output: accumulated.output,
758
+ output: accumulated.error !== void 0 && accumulated.error !== null ? void 0 : accumulated.output,
721
759
  model: accumulated.model,
722
760
  convo_id: convoId
723
761
  },
724
762
  properties: {
725
763
  ...restProperties,
764
+ ...telemetryProperties,
726
765
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
727
766
  $context: this.context
728
767
  },
@@ -880,6 +919,13 @@ function redactJsonAttributeValue(key, value) {
880
919
  if (scrubbedJson === json) return void 0;
881
920
  return { stringValue: scrubbedJson };
882
921
  }
922
+ function identityAttrs(args) {
923
+ return [
924
+ attrString("ai.telemetry.metadata.raindrop.ai.userId", args.userId),
925
+ attrString("ai.telemetry.metadata.raindrop.convoId", args.convoId),
926
+ attrString("ai.telemetry.metadata.raindrop.eventName", args.eventName)
927
+ ];
928
+ }
883
929
  function applyOtelSpanAttributeLimit(limit) {
884
930
  var _a, _b;
885
931
  try {
@@ -1004,6 +1050,7 @@ var TraceShipper = class {
1004
1050
  const started = (_a = args.startTimeUnixNano) != null ? _a : nowUnixNanoString();
1005
1051
  const attrs = [
1006
1052
  attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId),
1053
+ ...identityAttrs(args),
1007
1054
  attrString("ai.operationId", args.operationId)
1008
1055
  ];
1009
1056
  if ((_b = args.attributes) == null ? void 0 : _b.length) attrs.push(...args.attributes);
@@ -1059,7 +1106,8 @@ var TraceShipper = class {
1059
1106
  var _a;
1060
1107
  const ids = createSpanIds(args.parent);
1061
1108
  const attrs = [
1062
- attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId)
1109
+ attrString("ai.telemetry.metadata.raindrop.eventId", args.eventId),
1110
+ ...identityAttrs(args)
1063
1111
  ];
1064
1112
  if ((_a = args.attributes) == null ? void 0 : _a.length) attrs.push(...args.attributes);
1065
1113
  const otlp = buildOtlpSpan({
@@ -1341,7 +1389,7 @@ installTracingSuppressionHook();
1341
1389
  // package.json
1342
1390
  var package_default = {
1343
1391
  name: "@raindrop-ai/ai-sdk",
1344
- version: "0.1.0"};
1392
+ version: "0.2.0"};
1345
1393
 
1346
1394
  // src/internal/version.ts
1347
1395
  var libraryName = package_default.name;
@@ -2276,7 +2324,7 @@ var RaindropTelemetryIntegration = class {
2276
2324
  };
2277
2325
  // ── onStart ─────────────────────────────────────────────────────────────
2278
2326
  this.onStart = (event) => {
2279
- var _a, _b, _c, _d, _e;
2327
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2280
2328
  if (event.isEnabled === false) return;
2281
2329
  const isEmbed = event.operationId === "ai.embed" || event.operationId === "ai.embedMany";
2282
2330
  const recordInputs = event.recordInputs !== false;
@@ -2286,15 +2334,20 @@ var RaindropTelemetryIntegration = class {
2286
2334
  const callContextMetadata = getCurrentRaindropCallMetadata();
2287
2335
  const metadata = eventMetadata2 != null ? eventMetadata2 : callContextMetadata == null ? void 0 : callContextMetadata.rawMetadata;
2288
2336
  const callMeta = this.extractRaindropMetadata(metadata);
2337
+ const identity = {
2338
+ userId: (_b = callMeta.userId) != null ? _b : (_a = this.defaultContext) == null ? void 0 : _a.userId,
2339
+ convoId: (_d = callMeta.convoId) != null ? _d : (_c = this.defaultContext) == null ? void 0 : _c.convoId,
2340
+ eventName: (_f = callMeta.eventName) != null ? _f : (_e = this.defaultContext) == null ? void 0 : _e.eventName
2341
+ };
2289
2342
  const inherited = getContextManager().getParentSpanIds();
2290
2343
  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;
2291
2344
  const explicitEventId = callMeta.eventId && !eventIdGenerated ? callMeta.eventId : void 0;
2292
- 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();
2345
+ 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();
2293
2346
  const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
2294
2347
  const { operationName, resourceName } = opName(event.operationId, functionId);
2295
2348
  const parentToolContext = !isEmbed && this.subagentWrapping ? getCurrentParentToolContext() : void 0;
2296
2349
  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;
2297
- const subagentName = (_e = parentToolContext == null ? void 0 : parentToolContext.toolName) != null ? _e : metadataSubagentName;
2350
+ const subagentName = (_k = parentToolContext == null ? void 0 : parentToolContext.toolName) != null ? _k : metadataSubagentName;
2298
2351
  let subagentToolCallSpan;
2299
2352
  let rootParentOverride;
2300
2353
  if (subagentName && this.sendTraces) {
@@ -2307,6 +2360,7 @@ var RaindropTelemetryIntegration = class {
2307
2360
  name: subagentName,
2308
2361
  parent: inheritedParent,
2309
2362
  eventId,
2363
+ ...identity,
2310
2364
  operationId: "ai.toolCall",
2311
2365
  attributes: [
2312
2366
  attrString("operation.name", "ai.toolCall"),
@@ -2323,6 +2377,7 @@ var RaindropTelemetryIntegration = class {
2323
2377
  name: "agent.subagent",
2324
2378
  parent: subagentParentRef,
2325
2379
  eventId,
2380
+ ...identity,
2326
2381
  operationId: "agent.subagent",
2327
2382
  attributes: [
2328
2383
  attrString("operation.name", "agent.subagent"),
@@ -2350,6 +2405,7 @@ var RaindropTelemetryIntegration = class {
2350
2405
  name: event.operationId,
2351
2406
  parent: rootParentOverride != null ? rootParentOverride : inheritedParent,
2352
2407
  eventId,
2408
+ ...identity,
2353
2409
  operationId: event.operationId,
2354
2410
  attributes: [
2355
2411
  attrString("operation.name", operationName),
@@ -2357,13 +2413,14 @@ var RaindropTelemetryIntegration = class {
2357
2413
  attrString("ai.telemetry.functionId", functionId),
2358
2414
  attrString("ai.model.provider", event.provider),
2359
2415
  attrString("ai.model.id", event.modelId),
2360
- // Filter out raindrop.eventId from metadata attrs since TraceShipper
2361
- // already sets it via the eventId arg. Without this, eventMetadata()'s
2362
- // auto-generated ID would duplicate and override the resolved one.
2416
+ // Filter out identity keys (eventId/userId/convoId/eventName) from
2417
+ // metadata attrs since TraceShipper already stamps them via dedicated
2418
+ // args. Without this, eventMetadata()'s auto-generated ID would
2419
+ // duplicate and override the resolved one.
2363
2420
  ...attrsFromTelemetryMetadata(
2364
2421
  metadata ? Object.fromEntries(
2365
2422
  Object.entries(metadata).filter(
2366
- ([k]) => k !== "raindrop.eventId" && k !== "raindrop.internal.eventIdGenerated"
2423
+ ([k]) => k !== "raindrop.eventId" && k !== "raindrop.internal.eventIdGenerated" && k !== "raindrop.userId" && k !== "raindrop.convoId" && k !== "raindrop.eventName"
2367
2424
  )
2368
2425
  ) : void 0
2369
2426
  ),
@@ -2375,6 +2432,7 @@ var RaindropTelemetryIntegration = class {
2375
2432
  this.callStates.set(event.callId, {
2376
2433
  operationId: event.operationId,
2377
2434
  eventId,
2435
+ identity,
2378
2436
  rootSpan,
2379
2437
  rootParent: rootSpan ? this.spanParentRef(rootSpan) : rootParentOverride != null ? rootParentOverride : inheritedParent,
2380
2438
  stepSpan: void 0,
@@ -2426,6 +2484,7 @@ var RaindropTelemetryIntegration = class {
2426
2484
  name: stepOperationId,
2427
2485
  parent: state.rootParent,
2428
2486
  eventId: state.eventId,
2487
+ ...state.identity,
2429
2488
  operationId: stepOperationId,
2430
2489
  attributes: [
2431
2490
  attrString("operation.name", operationName),
@@ -2559,6 +2618,7 @@ var RaindropTelemetryIntegration = class {
2559
2618
  name: event.operationId,
2560
2619
  parent: state.rootParent,
2561
2620
  eventId: state.eventId,
2621
+ ...state.identity,
2562
2622
  operationId: event.operationId,
2563
2623
  attributes: [
2564
2624
  attrString("operation.name", operationName),
@@ -2825,6 +2885,7 @@ var RaindropTelemetryIntegration = class {
2825
2885
  name: "ai.toolCall",
2826
2886
  parent: state.stepParent,
2827
2887
  eventId: state.eventId,
2888
+ ...state.identity,
2828
2889
  operationId: "ai.toolCall",
2829
2890
  attributes: [
2830
2891
  attrString("operation.name", operationName),
@@ -2902,6 +2963,7 @@ var RaindropTelemetryIntegration = class {
2902
2963
  name: "ai.toolCall",
2903
2964
  parent: state.stepParent,
2904
2965
  eventId: state.eventId,
2966
+ ...state.identity,
2905
2967
  operationId: "ai.toolCall",
2906
2968
  attributes: [
2907
2969
  attrString("operation.name", operationName),
@@ -3005,7 +3067,7 @@ var RaindropTelemetryIntegration = class {
3005
3067
  ...callMeta.properties
3006
3068
  };
3007
3069
  const featureFlags = {
3008
- ...(_g = this.defaultContext) == null ? void 0 : _g.featureFlags,
3070
+ ...((_g = this.defaultContext) == null ? void 0 : _g.featureFlags) ? normalizeFeatureFlags(this.defaultContext.featureFlags) : {},
3009
3071
  ...callMeta.featureFlags
3010
3072
  };
3011
3073
  const convoId = (_i = callMeta.convoId) != null ? _i : (_h = this.defaultContext) == null ? void 0 : _h.convoId;
@@ -3569,6 +3631,9 @@ function teeStreamObjectBaseStream(result) {
3569
3631
  } catch (e) {
3570
3632
  }
3571
3633
  }
3634
+ function identityFromContext(ctx) {
3635
+ return { userId: ctx.userId, convoId: ctx.convoId, eventName: ctx.eventName };
3636
+ }
3572
3637
  function setupOperation(params) {
3573
3638
  var _a, _b, _c;
3574
3639
  const {
@@ -3600,6 +3665,7 @@ function setupOperation(params) {
3600
3665
  name: outerOperationId,
3601
3666
  parent: inheritedParent,
3602
3667
  eventId,
3668
+ ...identityFromContext(mergedCtx),
3603
3669
  operationId: outerOperationId,
3604
3670
  attributes: [
3605
3671
  attrString("operation.name", operationName),
@@ -3608,9 +3674,6 @@ function setupOperation(params) {
3608
3674
  attrString("ai.model.provider", modelInfoFromArgs.provider),
3609
3675
  attrString("ai.model.id", modelInfoFromArgs.modelId),
3610
3676
  attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
3611
- attrString("ai.telemetry.metadata.raindrop.eventName", mergedCtx.eventName),
3612
- attrString("ai.telemetry.metadata.raindrop.ai.userId", mergedCtx.userId),
3613
- attrString("ai.telemetry.metadata.raindrop.convoId", mergedCtx.convoId),
3614
3677
  ...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
3615
3678
  ...attrsFromHeaders(isRecord(arg) ? arg["headers"] : void 0),
3616
3679
  ...attrsFromSettings(arg),
@@ -3700,6 +3763,7 @@ function createFinalize(params) {
3700
3763
  responseMessages,
3701
3764
  rootSpan: setup.rootSpan,
3702
3765
  eventId: setup.eventId,
3766
+ ...identityFromContext(setup.ctx),
3703
3767
  telemetry: setup.telemetry,
3704
3768
  toolCalls: setup.toolCalls,
3705
3769
  traceShipper,
@@ -3738,6 +3802,11 @@ function createFinalize(params) {
3738
3802
  input,
3739
3803
  output,
3740
3804
  model: finalModel,
3805
+ usage: {
3806
+ promptTokens: usage == null ? void 0 : usage.inputTokens,
3807
+ completionTokens: usage == null ? void 0 : usage.outputTokens
3808
+ },
3809
+ error,
3741
3810
  properties: patch.properties,
3742
3811
  featureFlags: patch.featureFlags,
3743
3812
  attachments: patch.attachments,
@@ -3772,6 +3841,7 @@ function startToolSpan(toolCall, rootSpan, ctx, startTimeUnixNano) {
3772
3841
  name: "ai.toolCall",
3773
3842
  parent: { traceIdB64: rootSpan.ids.traceIdB64, spanIdB64: rootSpan.ids.spanIdB64 },
3774
3843
  eventId: ctx.eventId,
3844
+ ...identityFromContext(ctx),
3775
3845
  operationId: "ai.toolCall",
3776
3846
  attributes: [
3777
3847
  attrString("operation.name", operationName),
@@ -3809,6 +3879,9 @@ function emitTranscriptToolCallSpans(params) {
3809
3879
  }
3810
3880
  const ctx = {
3811
3881
  eventId: params.eventId,
3882
+ userId: params.userId,
3883
+ convoId: params.convoId,
3884
+ eventName: params.eventName,
3812
3885
  telemetry: params.telemetry,
3813
3886
  traceShipper: params.traceShipper
3814
3887
  };
@@ -4188,6 +4261,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4188
4261
  name: outerOperationId,
4189
4262
  parent: inheritedParent,
4190
4263
  eventId,
4264
+ ...identityFromContext(ctx),
4191
4265
  operationId: outerOperationId,
4192
4266
  attributes: [
4193
4267
  attrString("operation.name", operationName),
@@ -4196,9 +4270,6 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4196
4270
  attrString("ai.model.provider", modelInfoFromArgs.provider),
4197
4271
  attrString("ai.model.id", modelInfoFromArgs.modelId),
4198
4272
  attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
4199
- attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
4200
- attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
4201
- attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
4202
4273
  ...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
4203
4274
  ...attrsFromHeaders(mergedArgs["headers"]),
4204
4275
  ...attrsFromSettings(mergedArgs),
@@ -4263,6 +4334,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4263
4334
  responseMessages,
4264
4335
  rootSpan,
4265
4336
  eventId,
4337
+ ...identityFromContext(ctx),
4266
4338
  telemetry,
4267
4339
  toolCalls,
4268
4340
  traceShipper: deps.traceShipper,
@@ -4315,6 +4387,11 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4315
4387
  input,
4316
4388
  output,
4317
4389
  model: finalModel,
4390
+ usage: {
4391
+ promptTokens: usage == null ? void 0 : usage.inputTokens,
4392
+ completionTokens: usage == null ? void 0 : usage.outputTokens
4393
+ },
4394
+ error,
4318
4395
  properties: patch.properties,
4319
4396
  featureFlags: patch.featureFlags,
4320
4397
  attachments: patch.attachments,
@@ -4398,6 +4475,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4398
4475
  name: outerOperationId,
4399
4476
  parent: inheritedParent,
4400
4477
  eventId,
4478
+ ...identityFromContext(ctx),
4401
4479
  operationId: outerOperationId,
4402
4480
  attributes: [
4403
4481
  attrString("operation.name", operationName),
@@ -4406,9 +4484,6 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4406
4484
  attrString("ai.model.provider", modelInfoFromArgs.provider),
4407
4485
  attrString("ai.model.id", modelInfoFromArgs.modelId),
4408
4486
  attrString("ai.telemetry.metadata.raindrop.eventId", eventId),
4409
- attrString("ai.telemetry.metadata.raindrop.eventName", ctx.eventName),
4410
- attrString("ai.telemetry.metadata.raindrop.ai.userId", ctx.userId),
4411
- attrString("ai.telemetry.metadata.raindrop.convoId", ctx.convoId),
4412
4487
  ...attrsFromTelemetryMetadata(telemetry == null ? void 0 : telemetry.metadata),
4413
4488
  ...attrsFromHeaders(mergedArgs["headers"]),
4414
4489
  ...attrsFromSettings(mergedArgs),
@@ -4473,6 +4548,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4473
4548
  responseMessages,
4474
4549
  rootSpan,
4475
4550
  eventId,
4551
+ ...identityFromContext(ctx),
4476
4552
  telemetry,
4477
4553
  toolCalls,
4478
4554
  traceShipper: deps.traceShipper,
@@ -4525,6 +4601,11 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4525
4601
  input,
4526
4602
  output,
4527
4603
  model: finalModel,
4604
+ usage: {
4605
+ promptTokens: usage == null ? void 0 : usage.inputTokens,
4606
+ completionTokens: usage == null ? void 0 : usage.outputTokens
4607
+ },
4608
+ error,
4528
4609
  properties: patch.properties,
4529
4610
  featureFlags: patch.featureFlags,
4530
4611
  attachments: patch.attachments,
@@ -4622,6 +4703,7 @@ function wrapToolExecute(name, tool, ctx, toolCalls) {
4622
4703
  name: "ai.toolCall",
4623
4704
  parent,
4624
4705
  eventId: ctx.eventId,
4706
+ ...identityFromContext(ctx.context),
4625
4707
  operationId: "ai.toolCall",
4626
4708
  attributes: [
4627
4709
  attrString("operation.name", operationName),
@@ -4982,6 +5064,7 @@ function startDoGenerateSpan(operationId, options, modelInfo, parent, ctx) {
4982
5064
  name: operationId,
4983
5065
  parent,
4984
5066
  eventId: ctx.eventId,
5067
+ ...identityFromContext(ctx.context),
4985
5068
  operationId,
4986
5069
  attributes: [
4987
5070
  attrString("operation.name", operationName),
@@ -5065,6 +5148,7 @@ function startDoStreamSpan(operationId, options, modelInfo, parent, ctx) {
5065
5148
  name: operationId,
5066
5149
  parent,
5067
5150
  eventId: ctx.eventId,
5151
+ ...identityFromContext(ctx.context),
5068
5152
  operationId,
5069
5153
  attributes: [
5070
5154
  attrString("operation.name", operationName),
@@ -5325,6 +5409,9 @@ function createRaindropAISDK(opts) {
5325
5409
  const internal = traceShipper.startSpan({
5326
5410
  name: args.name,
5327
5411
  eventId: args.eventId,
5412
+ userId: args.userId,
5413
+ convoId: args.convoId,
5414
+ eventName: args.eventName,
5328
5415
  parent,
5329
5416
  operationId: args.operationId,
5330
5417
  attributes: attrs
@@ -5359,6 +5446,9 @@ function createRaindropAISDK(opts) {
5359
5446
  const internal = traceShipper.startSpan({
5360
5447
  name: args.name,
5361
5448
  eventId: args.eventId,
5449
+ userId: args.userId,
5450
+ convoId: args.convoId,
5451
+ eventName: args.eventName,
5362
5452
  parent,
5363
5453
  operationId: args.operationId,
5364
5454
  attributes: startAttrs,
@@ -1,4 +1,4 @@
1
- export { DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent } from './chunk-ETGFVXYM.mjs';
1
+ export { DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent } from './chunk-RBVZVH46.mjs';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
4
  if (!globalThis.RAINDROP_ASYNC_LOCAL_STORAGE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raindrop-ai/ai-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Standalone Vercel AI SDK integration for Raindrop (events + OTLP/HTTP JSON traces, no OTEL runtime)",
5
5
  "main": "dist/index.node.js",
6
6
  "module": "dist/index.node.mjs",
@@ -37,7 +37,7 @@
37
37
  "tsup": "^8.4.0",
38
38
  "tsx": "^4.20.3",
39
39
  "typescript": "^5.3.3",
40
- "@raindrop-ai/core": "0.1.0"
40
+ "@raindrop-ai/core": "0.1.3"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "ai": ">=4 <8"