@raindrop-ai/ai-sdk 0.0.34 → 0.0.36

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- // ../core/dist/chunk-U5HUTMR5.js
3
+ // ../core/dist/chunk-SK6EJEO7.js
4
4
  function getCrypto() {
5
5
  const c = globalThis.crypto;
6
6
  return c;
@@ -397,6 +397,25 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
397
397
  ).catch(() => {
398
398
  });
399
399
  }
400
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
401
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
402
+ function isValidProjectIdSlug(value) {
403
+ return PROJECT_ID_SLUG_PATTERN.test(value);
404
+ }
405
+ function normalizeProjectId(raw, opts) {
406
+ if (typeof raw !== "string") return void 0;
407
+ const trimmed = raw.trim();
408
+ if (!trimmed) return void 0;
409
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
410
+ console.warn(
411
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
412
+ );
413
+ }
414
+ return trimmed;
415
+ }
416
+ function projectIdHeaders(projectId) {
417
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
418
+ }
400
419
  var SHUTDOWN_DEADLINE_MS = 1e4;
401
420
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
402
421
  function mergePatches(target, source) {
@@ -431,6 +450,10 @@ var EventShipper = class {
431
450
  if (this.debug && this.localDebuggerUrl) {
432
451
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
433
452
  }
453
+ this.projectId = normalizeProjectId(opts.projectId, {
454
+ debug: this.debug,
455
+ prefix: this.prefix
456
+ });
434
457
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
435
458
  this.context = {
436
459
  library: {
@@ -449,6 +472,9 @@ var EventShipper = class {
449
472
  authHeaders() {
450
473
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
451
474
  }
475
+ requestHeaders() {
476
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
477
+ }
452
478
  /**
453
479
  * Build the retry/timeout options for one POST, honoring the shutdown
454
480
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -578,7 +604,7 @@ var EventShipper = class {
578
604
  return;
579
605
  }
580
606
  try {
581
- await postJson(url, body, this.authHeaders(), opts);
607
+ await postJson(url, body, this.requestHeaders(), opts);
582
608
  } catch (err) {
583
609
  const msg = err instanceof Error ? err.message : String(err);
584
610
  rateLimitedLog(
@@ -614,7 +640,7 @@ var EventShipper = class {
614
640
  return;
615
641
  }
616
642
  try {
617
- await postJson(url, body, this.authHeaders(), opts);
643
+ await postJson(url, body, this.requestHeaders(), opts);
618
644
  } catch (err) {
619
645
  const msg = err instanceof Error ? err.message : String(err);
620
646
  rateLimitedLog(
@@ -710,7 +736,7 @@ var EventShipper = class {
710
736
  if (!isPending) this.sticky.delete(eventId);
711
737
  return;
712
738
  }
713
- const p = postJson(url, payload, this.authHeaders(), opts);
739
+ const p = postJson(url, payload, this.requestHeaders(), opts);
714
740
  this.inFlight.add(p);
715
741
  try {
716
742
  try {
@@ -857,6 +883,10 @@ var TraceShipper = class {
857
883
  if (this.debug && this.localDebuggerUrl) {
858
884
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
859
885
  }
886
+ this.projectId = normalizeProjectId(opts.projectId, {
887
+ debug: this.debug,
888
+ prefix: this.prefix
889
+ });
860
890
  this.transformSpanHook = opts.transformSpan;
861
891
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
862
892
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -933,6 +963,9 @@ var TraceShipper = class {
933
963
  authHeaders() {
934
964
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
935
965
  }
966
+ requestHeaders() {
967
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
968
+ }
936
969
  startSpan(args) {
937
970
  var _a, _b;
938
971
  const ids = createSpanIds(args.parent);
@@ -1064,7 +1097,7 @@ var TraceShipper = class {
1064
1097
  endpoint: url
1065
1098
  });
1066
1099
  }
1067
- const p = postJson(url, body, this.authHeaders(), opts);
1100
+ const p = postJson(url, body, this.requestHeaders(), opts);
1068
1101
  this.inFlight.add(p);
1069
1102
  try {
1070
1103
  try {
@@ -1250,7 +1283,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
1250
1283
  // package.json
1251
1284
  var package_default = {
1252
1285
  name: "@raindrop-ai/ai-sdk",
1253
- version: "0.0.34"};
1286
+ version: "0.0.36"};
1254
1287
 
1255
1288
  // src/internal/version.ts
1256
1289
  var libraryName = package_default.name;
@@ -2163,10 +2196,7 @@ var RaindropTelemetryIntegration = class {
2163
2196
  };
2164
2197
  /** Flush and stop the background flush timers. */
2165
2198
  this.shutdown = async () => {
2166
- await Promise.all([
2167
- this.eventShipper.shutdown(),
2168
- this.traceShipper.shutdown()
2169
- ]);
2199
+ await Promise.all([this.eventShipper.shutdown(), this.traceShipper.shutdown()]);
2170
2200
  };
2171
2201
  // ── onStart ─────────────────────────────────────────────────────────────
2172
2202
  this.onStart = (event) => {
@@ -2185,12 +2215,9 @@ var RaindropTelemetryIntegration = class {
2185
2215
  const explicitEventId = callMeta.eventId && !eventIdGenerated ? callMeta.eventId : void 0;
2186
2216
  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();
2187
2217
  const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
2188
- const { operationName, resourceName } = opName(
2189
- event.operationId,
2190
- functionId
2191
- );
2218
+ const { operationName, resourceName } = opName(event.operationId, functionId);
2192
2219
  const parentToolContext = !isEmbed && this.subagentWrapping ? getCurrentParentToolContext() : void 0;
2193
- const metadataSubagentName = !isEmbed && this.subagentWrapping && parentToolContext === void 0 ? typeof (metadata == null ? void 0 : metadata["ash.subagent.name"]) === "string" ? metadata["ash.subagent.name"] : void 0 : void 0;
2220
+ 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;
2194
2221
  const subagentName = (_e = parentToolContext == null ? void 0 : parentToolContext.toolName) != null ? _e : metadataSubagentName;
2195
2222
  let subagentToolCallSpan;
2196
2223
  let rootParentOverride;
@@ -2242,12 +2269,7 @@ var RaindropTelemetryIntegration = class {
2242
2269
  })
2243
2270
  )
2244
2271
  ] : [];
2245
- const embedAttrs = isEmbed && recordInputs ? event.operationId === "ai.embedMany" ? [
2246
- attrString(
2247
- "ai.values",
2248
- safeJsonWithUint8(event.value)
2249
- )
2250
- ] : [attrString("ai.value", safeJsonWithUint8(event.value))] : [];
2272
+ const embedAttrs = isEmbed && recordInputs ? event.operationId === "ai.embedMany" ? [attrString("ai.values", safeJsonWithUint8(event.value))] : [attrString("ai.value", safeJsonWithUint8(event.value))] : [];
2251
2273
  rootSpan = this.traceShipper.startSpan({
2252
2274
  name: event.operationId,
2253
2275
  parent: rootParentOverride != null ? rootParentOverride : inheritedParent,
@@ -2301,19 +2323,11 @@ var RaindropTelemetryIntegration = class {
2301
2323
  if (!(state == null ? void 0 : state.rootSpan) || !state.rootParent) return;
2302
2324
  const isStream = state.operationId === "ai.streamText" || state.operationId === "ai.streamObject";
2303
2325
  const stepOperationId = isStream ? `${state.operationId}.doStream` : `${state.operationId}.doGenerate`;
2304
- const { operationName, resourceName } = opName(
2305
- stepOperationId,
2306
- state.functionId
2307
- );
2326
+ const { operationName, resourceName } = opName(stepOperationId, state.functionId);
2308
2327
  const inputAttrs = [];
2309
2328
  if (state.recordInputs) {
2310
2329
  if (event.promptMessages) {
2311
- inputAttrs.push(
2312
- attrString(
2313
- "ai.prompt.messages",
2314
- safeJsonWithUint8(event.promptMessages)
2315
- )
2316
- );
2330
+ inputAttrs.push(attrString("ai.prompt.messages", safeJsonWithUint8(event.promptMessages)));
2317
2331
  }
2318
2332
  if (event.stepTools) {
2319
2333
  inputAttrs.push(
@@ -2328,10 +2342,7 @@ var RaindropTelemetryIntegration = class {
2328
2342
  }
2329
2343
  if (event.stepToolChoice != null) {
2330
2344
  inputAttrs.push(
2331
- attrString(
2332
- "ai.prompt.toolChoice",
2333
- safeJsonWithUint8(event.stepToolChoice)
2334
- )
2345
+ attrString("ai.prompt.toolChoice", safeJsonWithUint8(event.stepToolChoice))
2335
2346
  );
2336
2347
  }
2337
2348
  }
@@ -2466,16 +2477,8 @@ var RaindropTelemetryIntegration = class {
2466
2477
  this.onEmbedStart = (event) => {
2467
2478
  const state = this.getState(event.callId);
2468
2479
  if (!(state == null ? void 0 : state.rootSpan) || !state.rootParent) return;
2469
- const { operationName, resourceName } = opName(
2470
- event.operationId,
2471
- state.functionId
2472
- );
2473
- const inputAttrs = state.recordInputs ? [
2474
- attrString(
2475
- "ai.values",
2476
- safeJsonWithUint8(event.values)
2477
- )
2478
- ] : [];
2480
+ const { operationName, resourceName } = opName(event.operationId, state.functionId);
2481
+ const inputAttrs = state.recordInputs ? [attrString("ai.values", safeJsonWithUint8(event.values))] : [];
2479
2482
  const embedSpan = this.traceShipper.startSpan({
2480
2483
  name: event.operationId,
2481
2484
  parent: state.rootParent,
@@ -2499,12 +2502,7 @@ var RaindropTelemetryIntegration = class {
2499
2502
  if (!embedSpan) return;
2500
2503
  const outputAttrs = [];
2501
2504
  if (state.recordOutputs) {
2502
- outputAttrs.push(
2503
- attrString(
2504
- "ai.embeddings",
2505
- safeJsonWithUint8(event.embeddings)
2506
- )
2507
- );
2505
+ outputAttrs.push(attrString("ai.embeddings", safeJsonWithUint8(event.embeddings)));
2508
2506
  }
2509
2507
  if (((_a = event.usage) == null ? void 0 : _a.tokens) != null) {
2510
2508
  outputAttrs.push(attrInt("ai.usage.tokens", event.usage.tokens));
@@ -2722,10 +2720,7 @@ var RaindropTelemetryIntegration = class {
2722
2720
  toolExecutionStart(event) {
2723
2721
  const { toolCall } = event;
2724
2722
  const priorParent = getCurrentParentToolContext();
2725
- this.priorParentContexts.set(
2726
- toolCall.toolCallId,
2727
- priorParent != null ? priorParent : null
2728
- );
2723
+ this.priorParentContexts.set(toolCall.toolCallId, priorParent != null ? priorParent : null);
2729
2724
  enterParentToolContext({
2730
2725
  parentCallId: event.callId,
2731
2726
  toolCallId: toolCall.toolCallId,
@@ -2734,10 +2729,7 @@ var RaindropTelemetryIntegration = class {
2734
2729
  const state = this.getState(event.callId);
2735
2730
  state == null ? void 0 : state.parentContextToolCallIds.add(toolCall.toolCallId);
2736
2731
  if (!(state == null ? void 0 : state.stepParent)) return;
2737
- const { operationName, resourceName } = opName(
2738
- "ai.toolCall",
2739
- state.functionId
2740
- );
2732
+ const { operationName, resourceName } = opName("ai.toolCall", state.functionId);
2741
2733
  const inputAttrs = state.recordInputs ? [attrString("ai.toolCall.args", safeJsonWithUint8(toolCall.input))] : [];
2742
2734
  const toolSpan = this.traceShipper.startSpan({
2743
2735
  name: "ai.toolCall",
@@ -2814,10 +2806,7 @@ var RaindropTelemetryIntegration = class {
2814
2806
  }
2815
2807
  }
2816
2808
  for (const call of providerToolCalls) {
2817
- const { operationName, resourceName } = opName(
2818
- "ai.toolCall",
2819
- state.functionId
2820
- );
2809
+ const { operationName, resourceName } = opName("ai.toolCall", state.functionId);
2821
2810
  const inputAttrs = state.recordInputs ? [attrString("ai.toolCall.args", safeJsonWithUint8(call.input))] : [];
2822
2811
  const toolSpan = this.traceShipper.startSpan({
2823
2812
  name: "ai.toolCall",
@@ -2840,12 +2829,7 @@ var RaindropTelemetryIntegration = class {
2840
2829
  if ((resultPart == null ? void 0 : resultPart.type) === "tool-error") {
2841
2830
  this.traceShipper.endSpan(toolSpan, { error: resultPart.error });
2842
2831
  } else {
2843
- const outputAttrs = state.recordOutputs && resultPart && "output" in resultPart ? [
2844
- attrString(
2845
- "ai.toolCall.result",
2846
- safeJsonWithUint8(resultPart.output)
2847
- )
2848
- ] : [];
2832
+ const outputAttrs = state.recordOutputs && resultPart && "output" in resultPart ? [attrString("ai.toolCall.result", safeJsonWithUint8(resultPart.output))] : [];
2849
2833
  this.traceShipper.endSpan(toolSpan, { attributes: outputAttrs });
2850
2834
  }
2851
2835
  this.emitLive(state, "tool_result", call.toolName);
@@ -2895,9 +2879,7 @@ var RaindropTelemetryIntegration = class {
2895
2879
  attrInt("ai.usage.cachedInputTokens", usage.cachedInputTokens)
2896
2880
  );
2897
2881
  }
2898
- outputAttrs.push(
2899
- attrInt("ai.toolCall.count", state.toolCallCount)
2900
- );
2882
+ outputAttrs.push(attrInt("ai.toolCall.count", state.toolCallCount));
2901
2883
  this.traceShipper.endSpan(state.rootSpan, { attributes: outputAttrs });
2902
2884
  }
2903
2885
  this.finalizeGenerateEvent(
@@ -2950,13 +2932,9 @@ var RaindropTelemetryIntegration = class {
2950
2932
  const isMany = state.operationId === "ai.embedMany";
2951
2933
  if (state.recordOutputs) {
2952
2934
  if (isMany) {
2953
- outputAttrs.push(
2954
- attrString("ai.embeddings", safeJsonWithUint8(event.embedding))
2955
- );
2935
+ outputAttrs.push(attrString("ai.embeddings", safeJsonWithUint8(event.embedding)));
2956
2936
  } else {
2957
- outputAttrs.push(
2958
- attrString("ai.embedding", safeJsonWithUint8(event.embedding))
2959
- );
2937
+ outputAttrs.push(attrString("ai.embedding", safeJsonWithUint8(event.embedding)));
2960
2938
  }
2961
2939
  }
2962
2940
  if (((_a = event.usage) == null ? void 0 : _a.tokens) != null) {
@@ -5123,6 +5101,7 @@ function createRaindropAISDK(opts) {
5123
5101
  enabled: eventsEnabled,
5124
5102
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
5125
5103
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs,
5104
+ projectId: opts.projectId,
5126
5105
  localDebuggerUrl
5127
5106
  });
5128
5107
  const traceShipper = new TraceShipper2({
@@ -5134,6 +5113,7 @@ function createRaindropAISDK(opts) {
5134
5113
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
5135
5114
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
5136
5115
  maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
5116
+ projectId: opts.projectId,
5137
5117
  localDebuggerUrl,
5138
5118
  transformSpan: (_j = opts.traces) == null ? void 0 : _j.transformSpan,
5139
5119
  disableDefaultRedaction: (_k = opts.traces) == null ? void 0 : _k.disableDefaultRedaction
@@ -1,4 +1,4 @@
1
- // ../core/dist/chunk-U5HUTMR5.js
1
+ // ../core/dist/chunk-SK6EJEO7.js
2
2
  function getCrypto() {
3
3
  const c = globalThis.crypto;
4
4
  return c;
@@ -395,6 +395,25 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
395
395
  ).catch(() => {
396
396
  });
397
397
  }
398
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
399
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
400
+ function isValidProjectIdSlug(value) {
401
+ return PROJECT_ID_SLUG_PATTERN.test(value);
402
+ }
403
+ function normalizeProjectId(raw, opts) {
404
+ if (typeof raw !== "string") return void 0;
405
+ const trimmed = raw.trim();
406
+ if (!trimmed) return void 0;
407
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
408
+ console.warn(
409
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
410
+ );
411
+ }
412
+ return trimmed;
413
+ }
414
+ function projectIdHeaders(projectId) {
415
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
416
+ }
398
417
  var SHUTDOWN_DEADLINE_MS = 1e4;
399
418
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
400
419
  function mergePatches(target, source) {
@@ -429,6 +448,10 @@ var EventShipper = class {
429
448
  if (this.debug && this.localDebuggerUrl) {
430
449
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
431
450
  }
451
+ this.projectId = normalizeProjectId(opts.projectId, {
452
+ debug: this.debug,
453
+ prefix: this.prefix
454
+ });
432
455
  const isNode = typeof process !== "undefined" && typeof process.version === "string";
433
456
  this.context = {
434
457
  library: {
@@ -447,6 +470,9 @@ var EventShipper = class {
447
470
  authHeaders() {
448
471
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
449
472
  }
473
+ requestHeaders() {
474
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
475
+ }
450
476
  /**
451
477
  * Build the retry/timeout options for one POST, honoring the shutdown
452
478
  * deadline. Returns `null` when the shutdown drain window is exhausted —
@@ -576,7 +602,7 @@ var EventShipper = class {
576
602
  return;
577
603
  }
578
604
  try {
579
- await postJson(url, body, this.authHeaders(), opts);
605
+ await postJson(url, body, this.requestHeaders(), opts);
580
606
  } catch (err) {
581
607
  const msg = err instanceof Error ? err.message : String(err);
582
608
  rateLimitedLog(
@@ -612,7 +638,7 @@ var EventShipper = class {
612
638
  return;
613
639
  }
614
640
  try {
615
- await postJson(url, body, this.authHeaders(), opts);
641
+ await postJson(url, body, this.requestHeaders(), opts);
616
642
  } catch (err) {
617
643
  const msg = err instanceof Error ? err.message : String(err);
618
644
  rateLimitedLog(
@@ -708,7 +734,7 @@ var EventShipper = class {
708
734
  if (!isPending) this.sticky.delete(eventId);
709
735
  return;
710
736
  }
711
- const p = postJson(url, payload, this.authHeaders(), opts);
737
+ const p = postJson(url, payload, this.requestHeaders(), opts);
712
738
  this.inFlight.add(p);
713
739
  try {
714
740
  try {
@@ -855,6 +881,10 @@ var TraceShipper = class {
855
881
  if (this.debug && this.localDebuggerUrl) {
856
882
  console.log(`${this.prefix} Local debugger mirroring: ${this.localDebuggerUrl}`);
857
883
  }
884
+ this.projectId = normalizeProjectId(opts.projectId, {
885
+ debug: this.debug,
886
+ prefix: this.prefix
887
+ });
858
888
  this.transformSpanHook = opts.transformSpan;
859
889
  this.disableDefaultRedaction = opts.disableDefaultRedaction === true;
860
890
  this.maxTextFieldCharsOpt = opts.maxTextFieldChars;
@@ -931,6 +961,9 @@ var TraceShipper = class {
931
961
  authHeaders() {
932
962
  return this.writeKey ? { Authorization: `Bearer ${this.writeKey}` } : {};
933
963
  }
964
+ requestHeaders() {
965
+ return { ...this.authHeaders(), ...projectIdHeaders(this.projectId) };
966
+ }
934
967
  startSpan(args) {
935
968
  var _a, _b;
936
969
  const ids = createSpanIds(args.parent);
@@ -1062,7 +1095,7 @@ var TraceShipper = class {
1062
1095
  endpoint: url
1063
1096
  });
1064
1097
  }
1065
- const p = postJson(url, body, this.authHeaders(), opts);
1098
+ const p = postJson(url, body, this.requestHeaders(), opts);
1066
1099
  this.inFlight.add(p);
1067
1100
  try {
1068
1101
  try {
@@ -1248,7 +1281,7 @@ async function* asyncGeneratorWithCurrent(span, gen) {
1248
1281
  // package.json
1249
1282
  var package_default = {
1250
1283
  name: "@raindrop-ai/ai-sdk",
1251
- version: "0.0.34"};
1284
+ version: "0.0.36"};
1252
1285
 
1253
1286
  // src/internal/version.ts
1254
1287
  var libraryName = package_default.name;
@@ -2161,10 +2194,7 @@ var RaindropTelemetryIntegration = class {
2161
2194
  };
2162
2195
  /** Flush and stop the background flush timers. */
2163
2196
  this.shutdown = async () => {
2164
- await Promise.all([
2165
- this.eventShipper.shutdown(),
2166
- this.traceShipper.shutdown()
2167
- ]);
2197
+ await Promise.all([this.eventShipper.shutdown(), this.traceShipper.shutdown()]);
2168
2198
  };
2169
2199
  // ── onStart ─────────────────────────────────────────────────────────────
2170
2200
  this.onStart = (event) => {
@@ -2183,12 +2213,9 @@ var RaindropTelemetryIntegration = class {
2183
2213
  const explicitEventId = callMeta.eventId && !eventIdGenerated ? callMeta.eventId : void 0;
2184
2214
  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();
2185
2215
  const inheritedParent = inherited && inherited.eventId === eventId ? { traceIdB64: inherited.traceIdB64, spanIdB64: inherited.spanIdB64 } : void 0;
2186
- const { operationName, resourceName } = opName(
2187
- event.operationId,
2188
- functionId
2189
- );
2216
+ const { operationName, resourceName } = opName(event.operationId, functionId);
2190
2217
  const parentToolContext = !isEmbed && this.subagentWrapping ? getCurrentParentToolContext() : void 0;
2191
- const metadataSubagentName = !isEmbed && this.subagentWrapping && parentToolContext === void 0 ? typeof (metadata == null ? void 0 : metadata["ash.subagent.name"]) === "string" ? metadata["ash.subagent.name"] : void 0 : void 0;
2218
+ 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;
2192
2219
  const subagentName = (_e = parentToolContext == null ? void 0 : parentToolContext.toolName) != null ? _e : metadataSubagentName;
2193
2220
  let subagentToolCallSpan;
2194
2221
  let rootParentOverride;
@@ -2240,12 +2267,7 @@ var RaindropTelemetryIntegration = class {
2240
2267
  })
2241
2268
  )
2242
2269
  ] : [];
2243
- const embedAttrs = isEmbed && recordInputs ? event.operationId === "ai.embedMany" ? [
2244
- attrString(
2245
- "ai.values",
2246
- safeJsonWithUint8(event.value)
2247
- )
2248
- ] : [attrString("ai.value", safeJsonWithUint8(event.value))] : [];
2270
+ const embedAttrs = isEmbed && recordInputs ? event.operationId === "ai.embedMany" ? [attrString("ai.values", safeJsonWithUint8(event.value))] : [attrString("ai.value", safeJsonWithUint8(event.value))] : [];
2249
2271
  rootSpan = this.traceShipper.startSpan({
2250
2272
  name: event.operationId,
2251
2273
  parent: rootParentOverride != null ? rootParentOverride : inheritedParent,
@@ -2299,19 +2321,11 @@ var RaindropTelemetryIntegration = class {
2299
2321
  if (!(state == null ? void 0 : state.rootSpan) || !state.rootParent) return;
2300
2322
  const isStream = state.operationId === "ai.streamText" || state.operationId === "ai.streamObject";
2301
2323
  const stepOperationId = isStream ? `${state.operationId}.doStream` : `${state.operationId}.doGenerate`;
2302
- const { operationName, resourceName } = opName(
2303
- stepOperationId,
2304
- state.functionId
2305
- );
2324
+ const { operationName, resourceName } = opName(stepOperationId, state.functionId);
2306
2325
  const inputAttrs = [];
2307
2326
  if (state.recordInputs) {
2308
2327
  if (event.promptMessages) {
2309
- inputAttrs.push(
2310
- attrString(
2311
- "ai.prompt.messages",
2312
- safeJsonWithUint8(event.promptMessages)
2313
- )
2314
- );
2328
+ inputAttrs.push(attrString("ai.prompt.messages", safeJsonWithUint8(event.promptMessages)));
2315
2329
  }
2316
2330
  if (event.stepTools) {
2317
2331
  inputAttrs.push(
@@ -2326,10 +2340,7 @@ var RaindropTelemetryIntegration = class {
2326
2340
  }
2327
2341
  if (event.stepToolChoice != null) {
2328
2342
  inputAttrs.push(
2329
- attrString(
2330
- "ai.prompt.toolChoice",
2331
- safeJsonWithUint8(event.stepToolChoice)
2332
- )
2343
+ attrString("ai.prompt.toolChoice", safeJsonWithUint8(event.stepToolChoice))
2333
2344
  );
2334
2345
  }
2335
2346
  }
@@ -2464,16 +2475,8 @@ var RaindropTelemetryIntegration = class {
2464
2475
  this.onEmbedStart = (event) => {
2465
2476
  const state = this.getState(event.callId);
2466
2477
  if (!(state == null ? void 0 : state.rootSpan) || !state.rootParent) return;
2467
- const { operationName, resourceName } = opName(
2468
- event.operationId,
2469
- state.functionId
2470
- );
2471
- const inputAttrs = state.recordInputs ? [
2472
- attrString(
2473
- "ai.values",
2474
- safeJsonWithUint8(event.values)
2475
- )
2476
- ] : [];
2478
+ const { operationName, resourceName } = opName(event.operationId, state.functionId);
2479
+ const inputAttrs = state.recordInputs ? [attrString("ai.values", safeJsonWithUint8(event.values))] : [];
2477
2480
  const embedSpan = this.traceShipper.startSpan({
2478
2481
  name: event.operationId,
2479
2482
  parent: state.rootParent,
@@ -2497,12 +2500,7 @@ var RaindropTelemetryIntegration = class {
2497
2500
  if (!embedSpan) return;
2498
2501
  const outputAttrs = [];
2499
2502
  if (state.recordOutputs) {
2500
- outputAttrs.push(
2501
- attrString(
2502
- "ai.embeddings",
2503
- safeJsonWithUint8(event.embeddings)
2504
- )
2505
- );
2503
+ outputAttrs.push(attrString("ai.embeddings", safeJsonWithUint8(event.embeddings)));
2506
2504
  }
2507
2505
  if (((_a = event.usage) == null ? void 0 : _a.tokens) != null) {
2508
2506
  outputAttrs.push(attrInt("ai.usage.tokens", event.usage.tokens));
@@ -2720,10 +2718,7 @@ var RaindropTelemetryIntegration = class {
2720
2718
  toolExecutionStart(event) {
2721
2719
  const { toolCall } = event;
2722
2720
  const priorParent = getCurrentParentToolContext();
2723
- this.priorParentContexts.set(
2724
- toolCall.toolCallId,
2725
- priorParent != null ? priorParent : null
2726
- );
2721
+ this.priorParentContexts.set(toolCall.toolCallId, priorParent != null ? priorParent : null);
2727
2722
  enterParentToolContext({
2728
2723
  parentCallId: event.callId,
2729
2724
  toolCallId: toolCall.toolCallId,
@@ -2732,10 +2727,7 @@ var RaindropTelemetryIntegration = class {
2732
2727
  const state = this.getState(event.callId);
2733
2728
  state == null ? void 0 : state.parentContextToolCallIds.add(toolCall.toolCallId);
2734
2729
  if (!(state == null ? void 0 : state.stepParent)) return;
2735
- const { operationName, resourceName } = opName(
2736
- "ai.toolCall",
2737
- state.functionId
2738
- );
2730
+ const { operationName, resourceName } = opName("ai.toolCall", state.functionId);
2739
2731
  const inputAttrs = state.recordInputs ? [attrString("ai.toolCall.args", safeJsonWithUint8(toolCall.input))] : [];
2740
2732
  const toolSpan = this.traceShipper.startSpan({
2741
2733
  name: "ai.toolCall",
@@ -2812,10 +2804,7 @@ var RaindropTelemetryIntegration = class {
2812
2804
  }
2813
2805
  }
2814
2806
  for (const call of providerToolCalls) {
2815
- const { operationName, resourceName } = opName(
2816
- "ai.toolCall",
2817
- state.functionId
2818
- );
2807
+ const { operationName, resourceName } = opName("ai.toolCall", state.functionId);
2819
2808
  const inputAttrs = state.recordInputs ? [attrString("ai.toolCall.args", safeJsonWithUint8(call.input))] : [];
2820
2809
  const toolSpan = this.traceShipper.startSpan({
2821
2810
  name: "ai.toolCall",
@@ -2838,12 +2827,7 @@ var RaindropTelemetryIntegration = class {
2838
2827
  if ((resultPart == null ? void 0 : resultPart.type) === "tool-error") {
2839
2828
  this.traceShipper.endSpan(toolSpan, { error: resultPart.error });
2840
2829
  } else {
2841
- const outputAttrs = state.recordOutputs && resultPart && "output" in resultPart ? [
2842
- attrString(
2843
- "ai.toolCall.result",
2844
- safeJsonWithUint8(resultPart.output)
2845
- )
2846
- ] : [];
2830
+ const outputAttrs = state.recordOutputs && resultPart && "output" in resultPart ? [attrString("ai.toolCall.result", safeJsonWithUint8(resultPart.output))] : [];
2847
2831
  this.traceShipper.endSpan(toolSpan, { attributes: outputAttrs });
2848
2832
  }
2849
2833
  this.emitLive(state, "tool_result", call.toolName);
@@ -2893,9 +2877,7 @@ var RaindropTelemetryIntegration = class {
2893
2877
  attrInt("ai.usage.cachedInputTokens", usage.cachedInputTokens)
2894
2878
  );
2895
2879
  }
2896
- outputAttrs.push(
2897
- attrInt("ai.toolCall.count", state.toolCallCount)
2898
- );
2880
+ outputAttrs.push(attrInt("ai.toolCall.count", state.toolCallCount));
2899
2881
  this.traceShipper.endSpan(state.rootSpan, { attributes: outputAttrs });
2900
2882
  }
2901
2883
  this.finalizeGenerateEvent(
@@ -2948,13 +2930,9 @@ var RaindropTelemetryIntegration = class {
2948
2930
  const isMany = state.operationId === "ai.embedMany";
2949
2931
  if (state.recordOutputs) {
2950
2932
  if (isMany) {
2951
- outputAttrs.push(
2952
- attrString("ai.embeddings", safeJsonWithUint8(event.embedding))
2953
- );
2933
+ outputAttrs.push(attrString("ai.embeddings", safeJsonWithUint8(event.embedding)));
2954
2934
  } else {
2955
- outputAttrs.push(
2956
- attrString("ai.embedding", safeJsonWithUint8(event.embedding))
2957
- );
2935
+ outputAttrs.push(attrString("ai.embedding", safeJsonWithUint8(event.embedding)));
2958
2936
  }
2959
2937
  }
2960
2938
  if (((_a = event.usage) == null ? void 0 : _a.tokens) != null) {
@@ -5121,6 +5099,7 @@ function createRaindropAISDK(opts) {
5121
5099
  enabled: eventsEnabled,
5122
5100
  debug: ((_c = opts.events) == null ? void 0 : _c.debug) === true || envDebug,
5123
5101
  partialFlushMs: (_d = opts.events) == null ? void 0 : _d.partialFlushMs,
5102
+ projectId: opts.projectId,
5124
5103
  localDebuggerUrl
5125
5104
  });
5126
5105
  const traceShipper = new TraceShipper2({
@@ -5132,6 +5111,7 @@ function createRaindropAISDK(opts) {
5132
5111
  flushIntervalMs: (_g = opts.traces) == null ? void 0 : _g.flushIntervalMs,
5133
5112
  maxBatchSize: (_h = opts.traces) == null ? void 0 : _h.maxBatchSize,
5134
5113
  maxQueueSize: (_i = opts.traces) == null ? void 0 : _i.maxQueueSize,
5114
+ projectId: opts.projectId,
5135
5115
  localDebuggerUrl,
5136
5116
  transformSpan: (_j = opts.traces) == null ? void 0 : _j.transformSpan,
5137
5117
  disableDefaultRedaction: (_k = opts.traces) == null ? void 0 : _k.disableDefaultRedaction
@@ -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, I as IdentifyInput, O as OtlpAnyValue, l as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, m as RaindropAISDKClient, n as RaindropAISDKContext, o as RaindropAISDKOptions, p as RaindropCallMetadata, q as RaindropTelemetryIntegration, r as RaindropTelemetryIntegrationOptions, s as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, t as SelfDiagnosticsSignalDefinition, u as SelfDiagnosticsSignalDefinitions, v as SelfDiagnosticsTool, w as SelfDiagnosticsToolInput, x as SelfDiagnosticsToolOptions, y as SelfDiagnosticsToolResult, z as StartSpanArgs, T as TRUNCATION_MARKER, F as TraceSpan, G as TransformSpanHook, W as WrapAISDKOptions, H as WrappedAI, J as WrappedAISDK, _ as _resetParentToolContextStorage, K as _resetRaindropCallMetadataStorage, L as _resetWarnedMissingUserId, M as boundedStringify, N as capText, Q as clearParentToolContext, U as createRaindropAISDK, V as currentSpan, X as defaultTransformSpan, Y as enterParentToolContext, Z as eventMetadata, $ as eventMetadataFromChatRequest, a0 as getContextManager, a1 as getCurrentParentToolContext, a2 as getCurrentRaindropCallMetadata, a3 as raindrop, a4 as readRaindropCallMetadataFromArgs, a5 as redactJsonAttributeValue, a6 as redactSecretsInObject, a7 as runWithParentToolContext, a8 as runWithRaindropCallMetadata, a9 as withCurrent } from './index-HYjRP6nV.mjs';
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, I as IdentifyInput, O as OtlpAnyValue, l as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, m as RaindropAISDKClient, n as RaindropAISDKContext, o as RaindropAISDKOptions, p as RaindropCallMetadata, q as RaindropTelemetryIntegration, r as RaindropTelemetryIntegrationOptions, s as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, t as SelfDiagnosticsSignalDefinition, u as SelfDiagnosticsSignalDefinitions, v as SelfDiagnosticsTool, w as SelfDiagnosticsToolInput, x as SelfDiagnosticsToolOptions, y as SelfDiagnosticsToolResult, z as StartSpanArgs, T as TRUNCATION_MARKER, F as TraceSpan, G as TransformSpanHook, W as WrapAISDKOptions, H as WrappedAI, J as WrappedAISDK, _ as _resetParentToolContextStorage, K as _resetRaindropCallMetadataStorage, L as _resetWarnedMissingUserId, M as boundedStringify, N as capText, Q as clearParentToolContext, U as createRaindropAISDK, V as currentSpan, X as defaultTransformSpan, Y as enterParentToolContext, Z as eventMetadata, $ as eventMetadataFromChatRequest, a0 as getContextManager, a1 as getCurrentParentToolContext, a2 as getCurrentRaindropCallMetadata, a3 as raindrop, a4 as readRaindropCallMetadataFromArgs, a5 as redactJsonAttributeValue, a6 as redactSecretsInObject, a7 as runWithParentToolContext, a8 as runWithRaindropCallMetadata, a9 as withCurrent } from './index-Crm3oDAG.mjs';
2
2
 
3
3
  declare global {
4
4
  var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
@@ -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, I as IdentifyInput, O as OtlpAnyValue, l as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, m as RaindropAISDKClient, n as RaindropAISDKContext, o as RaindropAISDKOptions, p as RaindropCallMetadata, q as RaindropTelemetryIntegration, r as RaindropTelemetryIntegrationOptions, s as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, t as SelfDiagnosticsSignalDefinition, u as SelfDiagnosticsSignalDefinitions, v as SelfDiagnosticsTool, w as SelfDiagnosticsToolInput, x as SelfDiagnosticsToolOptions, y as SelfDiagnosticsToolResult, z as StartSpanArgs, T as TRUNCATION_MARKER, F as TraceSpan, G as TransformSpanHook, W as WrapAISDKOptions, H as WrappedAI, J as WrappedAISDK, _ as _resetParentToolContextStorage, K as _resetRaindropCallMetadataStorage, L as _resetWarnedMissingUserId, M as boundedStringify, N as capText, Q as clearParentToolContext, U as createRaindropAISDK, V as currentSpan, X as defaultTransformSpan, Y as enterParentToolContext, Z as eventMetadata, $ as eventMetadataFromChatRequest, a0 as getContextManager, a1 as getCurrentParentToolContext, a2 as getCurrentRaindropCallMetadata, a3 as raindrop, a4 as readRaindropCallMetadataFromArgs, a5 as redactJsonAttributeValue, a6 as redactSecretsInObject, a7 as runWithParentToolContext, a8 as runWithRaindropCallMetadata, a9 as withCurrent } from './index-HYjRP6nV.js';
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, I as IdentifyInput, O as OtlpAnyValue, l as OtlpSpan, P as ParentToolContext, R as REDACTED_PLACEHOLDER, m as RaindropAISDKClient, n as RaindropAISDKContext, o as RaindropAISDKOptions, p as RaindropCallMetadata, q as RaindropTelemetryIntegration, r as RaindropTelemetryIntegrationOptions, s as RaindropTelemetryOptions, S as SelfDiagnosticsOptions, t as SelfDiagnosticsSignalDefinition, u as SelfDiagnosticsSignalDefinitions, v as SelfDiagnosticsTool, w as SelfDiagnosticsToolInput, x as SelfDiagnosticsToolOptions, y as SelfDiagnosticsToolResult, z as StartSpanArgs, T as TRUNCATION_MARKER, F as TraceSpan, G as TransformSpanHook, W as WrapAISDKOptions, H as WrappedAI, J as WrappedAISDK, _ as _resetParentToolContextStorage, K as _resetRaindropCallMetadataStorage, L as _resetWarnedMissingUserId, M as boundedStringify, N as capText, Q as clearParentToolContext, U as createRaindropAISDK, V as currentSpan, X as defaultTransformSpan, Y as enterParentToolContext, Z as eventMetadata, $ as eventMetadataFromChatRequest, a0 as getContextManager, a1 as getCurrentParentToolContext, a2 as getCurrentRaindropCallMetadata, a3 as raindrop, a4 as readRaindropCallMetadataFromArgs, a5 as redactJsonAttributeValue, a6 as redactSecretsInObject, a7 as runWithParentToolContext, a8 as runWithRaindropCallMetadata, a9 as withCurrent } from './index-Crm3oDAG.js';
2
2
 
3
3
  declare global {
4
4
  var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {