@raindrop-ai/ai-sdk 0.0.41 → 0.1.1

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,14 @@
1
1
  import { AsyncLocalStorage } from 'async_hooks';
2
2
 
3
- // ../core/dist/chunk-WKRW55KX.js
3
+ // ../core/dist/chunk-Y5LUB7OE.js
4
+ function normalizeFeatureFlags(input) {
5
+ if (Array.isArray(input)) {
6
+ return Object.fromEntries(input.map((name) => [name, "true"]));
7
+ }
8
+ return Object.fromEntries(
9
+ Object.entries(input).map(([k, v]) => [k, String(v)])
10
+ );
11
+ }
4
12
  function getCrypto() {
5
13
  const c = globalThis.crypto;
6
14
  return c;
@@ -435,13 +443,16 @@ function projectIdHeaders(projectId) {
435
443
  var SHUTDOWN_DEADLINE_MS = 1e4;
436
444
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
437
445
  function mergePatches(target, source) {
438
- var _a, _b, _c, _d;
446
+ var _a, _b, _c, _d, _e, _f;
439
447
  const out = { ...target, ...source };
440
448
  if (target.properties || source.properties) {
441
449
  out.properties = { ...(_a = target.properties) != null ? _a : {}, ...(_b = source.properties) != null ? _b : {} };
442
450
  }
451
+ if (target.featureFlags || source.featureFlags) {
452
+ out.featureFlags = { ...(_c = target.featureFlags) != null ? _c : {}, ...(_d = source.featureFlags) != null ? _d : {} };
453
+ }
443
454
  if (target.attachments || source.attachments) {
444
- out.attachments = [...(_c = target.attachments) != null ? _c : [], ...(_d = source.attachments) != null ? _d : []];
455
+ out.attachments = [...(_e = target.attachments) != null ? _e : [], ...(_f = source.attachments) != null ? _f : []];
445
456
  }
446
457
  return out;
447
458
  }
@@ -711,6 +722,7 @@ var EventShipper = class {
711
722
  ...wizardSession ? { "raindrop.wizardSession": wizardSession } : {},
712
723
  $context: this.context
713
724
  },
725
+ ...accumulated.featureFlags && Object.keys(accumulated.featureFlags).length > 0 ? { feature_flags: accumulated.featureFlags } : {},
714
726
  attachments: accumulated.attachments,
715
727
  is_pending: isPending
716
728
  };
@@ -2725,6 +2737,20 @@ var RaindropTelemetryIntegration = class {
2725
2737
  } else if (properties && typeof properties === "object") {
2726
2738
  result.properties = properties;
2727
2739
  }
2740
+ const featureFlags = metadata["raindrop.featureFlags"];
2741
+ if (typeof featureFlags === "string") {
2742
+ try {
2743
+ const parsed = JSON.parse(featureFlags);
2744
+ if (parsed && typeof parsed === "object") {
2745
+ result.featureFlags = normalizeFeatureFlags(parsed);
2746
+ }
2747
+ } catch (e) {
2748
+ }
2749
+ } else if (featureFlags && typeof featureFlags === "object") {
2750
+ result.featureFlags = normalizeFeatureFlags(
2751
+ featureFlags
2752
+ );
2753
+ }
2728
2754
  return result;
2729
2755
  }
2730
2756
  /**
@@ -2939,7 +2965,7 @@ var RaindropTelemetryIntegration = class {
2939
2965
  * same event ID into a separate canonical row.
2940
2966
  */
2941
2967
  finalizeGenerateEvent(state, output, model, keepPending = false) {
2942
- var _a, _b, _c, _d, _e, _f, _g, _h;
2968
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2943
2969
  const suppressSubagentEvent = state.subagentName !== void 0 && state.subagentToolCallSpan !== void 0;
2944
2970
  if (!this.sendEvents || suppressSubagentEvent) return;
2945
2971
  const callMeta = this.extractRaindropMetadata(state.metadata);
@@ -2952,7 +2978,11 @@ var RaindropTelemetryIntegration = class {
2952
2978
  ...(_f = this.defaultContext) == null ? void 0 : _f.properties,
2953
2979
  ...callMeta.properties
2954
2980
  };
2955
- const convoId = (_h = callMeta.convoId) != null ? _h : (_g = this.defaultContext) == null ? void 0 : _g.convoId;
2981
+ const featureFlags = {
2982
+ ...((_g = this.defaultContext) == null ? void 0 : _g.featureFlags) ? normalizeFeatureFlags(this.defaultContext.featureFlags) : {},
2983
+ ...callMeta.featureFlags
2984
+ };
2985
+ const convoId = (_i = callMeta.convoId) != null ? _i : (_h = this.defaultContext) == null ? void 0 : _h.convoId;
2956
2986
  void this.eventShipper.patch(state.eventId, {
2957
2987
  eventName,
2958
2988
  userId,
@@ -2961,6 +2991,7 @@ var RaindropTelemetryIntegration = class {
2961
2991
  output: cappedOutput,
2962
2992
  model,
2963
2993
  properties: Object.keys(properties).length > 0 ? properties : void 0,
2994
+ featureFlags: Object.keys(featureFlags).length > 0 ? featureFlags : void 0,
2964
2995
  isPending: keepPending
2965
2996
  }).catch((err) => {
2966
2997
  if (this.debug) {
@@ -3271,6 +3302,20 @@ function extractRaindropMetadata(metadata) {
3271
3302
  } else if (properties && typeof properties === "object") {
3272
3303
  result.properties = properties;
3273
3304
  }
3305
+ const featureFlags = metadata["raindrop.featureFlags"];
3306
+ if (typeof featureFlags === "string") {
3307
+ try {
3308
+ const parsed = JSON.parse(featureFlags);
3309
+ if (parsed && typeof parsed === "object") {
3310
+ result.featureFlags = normalizeFeatureFlags(parsed);
3311
+ }
3312
+ } catch (e) {
3313
+ }
3314
+ } else if (featureFlags && typeof featureFlags === "object") {
3315
+ result.featureFlags = normalizeFeatureFlags(
3316
+ featureFlags
3317
+ );
3318
+ }
3274
3319
  return result;
3275
3320
  }
3276
3321
  function mergeContexts(wrapTime, callTime) {
@@ -3285,6 +3330,10 @@ function mergeContexts(wrapTime, callTime) {
3285
3330
  ...callTime.properties
3286
3331
  };
3287
3332
  }
3333
+ if (callTime.featureFlags) {
3334
+ const wrapTimeFlags = wrapTime.featureFlags ? normalizeFeatureFlags(wrapTime.featureFlags) : {};
3335
+ result.featureFlags = { ...wrapTimeFlags, ...callTime.featureFlags };
3336
+ }
3288
3337
  return result;
3289
3338
  }
3290
3339
  function detectAISDKVersion(aiSDK) {
@@ -3597,6 +3646,7 @@ function createFinalize(params) {
3597
3646
  output: defaultOutput,
3598
3647
  model,
3599
3648
  properties: setup.ctx.properties,
3649
+ featureFlags: setup.ctx.featureFlags ? normalizeFeatureFlags(setup.ctx.featureFlags) : void 0,
3600
3650
  attachments: mergeAttachments(setup.ctx.attachments, inputAttachments, outputAttachments)
3601
3651
  };
3602
3652
  const built = await maybeBuildEvent(options.buildEvent, allMessages);
@@ -3650,6 +3700,7 @@ function createFinalize(params) {
3650
3700
  output,
3651
3701
  model: finalModel,
3652
3702
  properties: patch.properties,
3703
+ featureFlags: patch.featureFlags,
3653
3704
  attachments: patch.attachments,
3654
3705
  isPending: keepEventPending
3655
3706
  }).catch((err) => {
@@ -3881,7 +3932,8 @@ function wrapAISDK(aiSDK, deps) {
3881
3932
  eventId: wrapTimeCtx.eventId,
3882
3933
  eventName: wrapTimeCtx.eventName,
3883
3934
  convoId: wrapTimeCtx.convoId,
3884
- properties: wrapTimeCtx.properties
3935
+ properties: wrapTimeCtx.properties,
3936
+ featureFlags: wrapTimeCtx.featureFlags ? normalizeFeatureFlags(wrapTimeCtx.featureFlags) : void 0
3885
3937
  }
3886
3938
  });
3887
3939
  const registerFn = resolveRegisterTelemetry(aiSDK);
@@ -4157,6 +4209,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4157
4209
  output: outputText,
4158
4210
  model,
4159
4211
  properties: ctx.properties,
4212
+ featureFlags: ctx.featureFlags ? normalizeFeatureFlags(ctx.featureFlags) : void 0,
4160
4213
  attachments: mergeAttachments(ctx.attachments, inputAttachments, outputAttachments)
4161
4214
  };
4162
4215
  const built = await maybeBuildEvent(deps.options.buildEvent, allMessages);
@@ -4224,6 +4277,7 @@ function wrapAgentGenerate(generate, instance, agentSettings, className, aiSDK,
4224
4277
  output,
4225
4278
  model: finalModel,
4226
4279
  properties: patch.properties,
4280
+ featureFlags: patch.featureFlags,
4227
4281
  attachments: patch.attachments,
4228
4282
  isPending: false
4229
4283
  }).catch((err) => {
@@ -4365,6 +4419,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4365
4419
  output: outputText,
4366
4420
  model,
4367
4421
  properties: ctx.properties,
4422
+ featureFlags: ctx.featureFlags ? normalizeFeatureFlags(ctx.featureFlags) : void 0,
4368
4423
  attachments: mergeAttachments(ctx.attachments, inputAttachments, outputAttachments)
4369
4424
  };
4370
4425
  const built = await maybeBuildEvent(deps.options.buildEvent, allMessages);
@@ -4432,6 +4487,7 @@ function wrapAgentStream(stream, instance, agentSettings, className, aiSDK, deps
4432
4487
  output,
4433
4488
  model: finalModel,
4434
4489
  properties: patch.properties,
4490
+ featureFlags: patch.featureFlags,
4435
4491
  attachments: patch.attachments,
4436
4492
  isPending: false
4437
4493
  }).catch((err) => {
@@ -5029,7 +5085,7 @@ async function maybeBuildEvent(buildEvent, messages) {
5029
5085
  }
5030
5086
  }
5031
5087
  function mergeBuildEventPatch(defaults, override) {
5032
- var _a, _b, _c, _d, _e, _f, _g, _h;
5088
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5033
5089
  if (!override) return defaults;
5034
5090
  return {
5035
5091
  eventName: (_a = override.eventName) != null ? _a : defaults.eventName,
@@ -5037,7 +5093,8 @@ function mergeBuildEventPatch(defaults, override) {
5037
5093
  output: (_c = override.output) != null ? _c : defaults.output,
5038
5094
  model: (_d = override.model) != null ? _d : defaults.model,
5039
5095
  properties: override.properties !== void 0 ? { ...(_e = defaults.properties) != null ? _e : {}, ...(_f = override.properties) != null ? _f : {} } : defaults.properties,
5040
- attachments: override.attachments !== void 0 ? [...(_g = defaults.attachments) != null ? _g : [], ...(_h = override.attachments) != null ? _h : []] : defaults.attachments
5096
+ featureFlags: override.featureFlags !== void 0 ? { ...(_g = defaults.featureFlags) != null ? _g : {}, ...(_h = override.featureFlags) != null ? _h : {} } : defaults.featureFlags,
5097
+ attachments: override.attachments !== void 0 ? [...(_i = defaults.attachments) != null ? _i : [], ...(_j = override.attachments) != null ? _j : []] : defaults.attachments
5041
5098
  };
5042
5099
  }
5043
5100
  function mergeAttachments(...groups) {
@@ -5058,7 +5115,7 @@ function extractNestedTokens(usage, key) {
5058
5115
  // package.json
5059
5116
  var package_default = {
5060
5117
  name: "@raindrop-ai/ai-sdk",
5061
- version: "0.0.41"};
5118
+ version: "0.1.1"};
5062
5119
 
5063
5120
  // src/internal/version.ts
5064
5121
  var libraryName = package_default.name;
@@ -5103,6 +5160,8 @@ function eventMetadata(options) {
5103
5160
  if (options.convoId) result["raindrop.convoId"] = options.convoId;
5104
5161
  if (options.eventName) result["raindrop.eventName"] = options.eventName;
5105
5162
  if (options.properties) result["raindrop.properties"] = JSON.stringify(options.properties);
5163
+ if (options.featureFlags)
5164
+ result["raindrop.featureFlags"] = JSON.stringify(normalizeFeatureFlags(options.featureFlags));
5106
5165
  return result;
5107
5166
  }
5108
5167
  function deriveChatTurnMessageId(request) {
@@ -5207,7 +5266,8 @@ function createRaindropAISDK(opts) {
5207
5266
  "eventId",
5208
5267
  "eventName",
5209
5268
  "convoId",
5210
- "properties"
5269
+ "properties",
5270
+ "featureFlags"
5211
5271
  ];
5212
5272
  let context;
5213
5273
  let subagentWrapping;
@@ -5239,6 +5299,9 @@ function createRaindropAISDK(opts) {
5239
5299
  async setProperties(eventId, properties) {
5240
5300
  await eventShipper.patch(eventId, { properties });
5241
5301
  },
5302
+ async setFeatureFlags(eventId, featureFlags) {
5303
+ await eventShipper.patch(eventId, { featureFlags: normalizeFeatureFlags(featureFlags) });
5304
+ },
5242
5305
  async finish(eventId, patch) {
5243
5306
  await eventShipper.finish(eventId, patch);
5244
5307
  }
@@ -5339,4 +5402,4 @@ function raindrop(options = {}) {
5339
5402
  return client.createTelemetryIntegration({ context, subagentWrapping });
5340
5403
  }
5341
5404
 
5342
- export { DEFAULT_MAX_TEXT_FIELD_CHARS2 as DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, TRUNCATION_MARKER2 as TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText2 as capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
5405
+ export { DEFAULT_MAX_TEXT_FIELD_CHARS2 as DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, REDACTED_PLACEHOLDER, RaindropTelemetryIntegration, TRUNCATION_MARKER2 as TRUNCATION_MARKER, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText2 as capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
@@ -1,3 +1,14 @@
1
+ type FeatureFlagValue = string | number | boolean;
2
+ type FeatureFlags = string[] | Record<string, FeatureFlagValue>;
3
+ /**
4
+ * Normalizes feature flags from the two accepted input forms into a
5
+ * canonical `Record<string, string>` ready for the wire payload.
6
+ *
7
+ * - Array form: `["a", "b"]` → `{"a": "true", "b": "true"}`
8
+ * - Object form: `{ a: "v2", b: true, c: 3 }` → `{"a": "v2", "b": "true", "c": "3"}`
9
+ */
10
+ declare function normalizeFeatureFlags(input: FeatureFlags): Record<string, string>;
11
+
1
12
  type OtlpAnyValue = {
2
13
  stringValue?: string;
3
14
  intValue?: string;
@@ -53,6 +64,7 @@ type Patch = {
53
64
  output?: string;
54
65
  model?: string;
55
66
  properties?: Record<string, unknown>;
67
+ featureFlags?: Record<string, string>;
56
68
  attachments?: Attachment$1[];
57
69
  isPending?: boolean;
58
70
  timestamp?: string;
@@ -153,6 +165,7 @@ declare class EventShipper$1 {
153
165
  output?: string;
154
166
  model?: string;
155
167
  properties?: Record<string, unknown>;
168
+ featureFlags?: Record<string, string>;
156
169
  userId?: string;
157
170
  }): Promise<void>;
158
171
  flush(): Promise<void>;
@@ -490,6 +503,37 @@ declare class TraceShipper extends TraceShipper$1 {
490
503
  constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
491
504
  }
492
505
 
506
+ /**
507
+ * Raindrop telemetry integration for AI SDK v7+
508
+ *
509
+ * Implements the AI SDK's `Telemetry` interface (formerly `TelemetryIntegration`
510
+ * before v7 beta.111) to capture traces and events natively, replacing the
511
+ * Proxy-based wrapping used for v4-v6.
512
+ *
513
+ * Modeled after the upstream OpenTelemetry integration but uses Raindrop's
514
+ * TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
515
+ *
516
+ * Compatibility: this class targets the latest published v7 build but also
517
+ * exposes the older v7 callback names as aliases so it works on every v7
518
+ * beta/canary released to date:
519
+ * - `onToolCallStart`/`onToolCallFinish` (< beta.111) alongside
520
+ * `onToolExecutionStart`/`onToolExecutionEnd` (>= beta.111).
521
+ * - Current `onToolExecutionEnd` events use the `toolOutput` discriminated
522
+ * union; older builds used top-level `success`/`output`/`error` fields.
523
+ * - `onFinish`/`onEmbedFinish` (< canary.159) alongside `onEnd`/`onEmbedEnd`
524
+ * (>= canary.159, vercel/ai renamed the operation finalizers).
525
+ * - `onAbort` (added as a telemetry-integration callback on the v7 canary
526
+ * line, post-beta.116) finalizes open spans + the pending event when a
527
+ * `streamText` call is cancelled via its `AbortSignal`. Builds that don't
528
+ * dispatch it to integrations simply never call it, so it's a no-op there.
529
+ *
530
+ * Step-end note: we intentionally implement only `onStepFinish` (not the newer
531
+ * `onStepEnd`). The latest canary dispatcher fans every step-end event out to
532
+ * BOTH `onStepEnd` and the deprecated `onStepFinish` on each integration, so
533
+ * implementing both names would double-close the step span. `onStepFinish`
534
+ * alone is dispatched on every published v7 beta/canary to date.
535
+ */
536
+
493
537
  type Listener<T> = (event: T) => PromiseLike<void> | void;
494
538
  type ToolExecutionEndEvent = {
495
539
  callId: string;
@@ -563,6 +607,7 @@ type RaindropTelemetryIntegrationOptions = {
563
607
  eventName?: string;
564
608
  convoId?: string;
565
609
  properties?: Record<string, unknown>;
610
+ featureFlags?: FeatureFlags;
566
611
  };
567
612
  };
568
613
  declare class RaindropTelemetryIntegration implements TelemetryIntegration {
@@ -839,6 +884,8 @@ type EventMetadataOptions = {
839
884
  eventName?: string;
840
885
  /** Additional properties to merge with wrap-time properties */
841
886
  properties?: Record<string, unknown>;
887
+ /** Feature flags to attach to this event (merged with wrap-time flags; call-time wins) */
888
+ featureFlags?: FeatureFlags;
842
889
  };
843
890
  /**
844
891
  * Creates metadata for use with the AI SDK's `experimental_telemetry.metadata` option.
@@ -1042,6 +1089,7 @@ type RaindropAISDKContext = {
1042
1089
  eventName?: string;
1043
1090
  convoId?: string;
1044
1091
  properties?: Record<string, unknown>;
1092
+ featureFlags?: FeatureFlags;
1045
1093
  attachments?: Attachment[];
1046
1094
  };
1047
1095
 
@@ -1051,6 +1099,7 @@ type BuildEventPatch = {
1051
1099
  output?: string;
1052
1100
  model?: string;
1053
1101
  properties?: Record<string, unknown>;
1102
+ featureFlags?: Record<string, string>;
1054
1103
  attachments?: Attachment[];
1055
1104
  };
1056
1105
  /**
@@ -1215,6 +1264,7 @@ type EventPatch = {
1215
1264
  output?: string;
1216
1265
  model?: string;
1217
1266
  properties?: Record<string, unknown>;
1267
+ featureFlags?: Record<string, string>;
1218
1268
  attachments?: Attachment[];
1219
1269
  isPending?: boolean;
1220
1270
  timestamp?: string;
@@ -1247,10 +1297,12 @@ type RaindropAISDKClient = {
1247
1297
  patch(eventId: string, patch: EventPatch): Promise<void>;
1248
1298
  addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
1249
1299
  setProperties(eventId: string, properties: Record<string, unknown>): Promise<void>;
1300
+ setFeatureFlags(eventId: string, featureFlags: FeatureFlags): Promise<void>;
1250
1301
  finish(eventId: string, patch: {
1251
1302
  output?: string;
1252
1303
  model?: string;
1253
1304
  properties?: Record<string, unknown>;
1305
+ featureFlags?: Record<string, string>;
1254
1306
  }): Promise<void>;
1255
1307
  };
1256
1308
  /**
@@ -1361,4 +1413,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
1361
1413
  */
1362
1414
  declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
1363
1415
 
1364
- export { eventMetadataFromChatRequest as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type TraceSpan as F, type TransformSpanHook as G, type WrappedAI as H, type IdentifyInput as I, type WrappedAISDK as J, _resetRaindropCallMetadataStorage as K, _resetWarnedMissingUserId as L, boundedStringify as M, capText as N, type OtlpAnyValue as O, type ParentToolContext as P, clearParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, createRaindropAISDK as U, currentSpan as V, type WrapAISDKOptions as W, defaultTransformSpan as X, enterParentToolContext as Y, eventMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, getContextManager as a0, getCurrentParentToolContext as a1, getCurrentRaindropCallMetadata as a2, raindrop as a3, readRaindropCallMetadataFromArgs as a4, redactJsonAttributeValue as a5, redactSecretsInObject as a6, runWithParentToolContext as a7, runWithRaindropCallMetadata as a8, withCurrent as a9, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type OtlpSpan as l, type RaindropAISDKClient as m, type RaindropAISDKContext as n, type RaindropAISDKOptions as o, type RaindropCallMetadata as p, RaindropTelemetryIntegration as q, type RaindropTelemetryIntegrationOptions as r, type RaindropTelemetryOptions as s, type SelfDiagnosticsSignalDefinition as t, type SelfDiagnosticsSignalDefinitions as u, type SelfDiagnosticsTool as v, type SelfDiagnosticsToolInput as w, type SelfDiagnosticsToolOptions as x, type SelfDiagnosticsToolResult as y, type StartSpanArgs as z };
1416
+ export { enterParentToolContext as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type FeatureFlagValue as F, type StartSpanArgs as G, type TraceSpan as H, type IdentifyInput as I, type TransformSpanHook as J, type WrappedAI as K, type WrappedAISDK as L, _resetRaindropCallMetadataStorage as M, _resetWarnedMissingUserId as N, type OtlpAnyValue as O, type ParentToolContext as P, boundedStringify as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, capText as U, clearParentToolContext as V, type WrapAISDKOptions as W, createRaindropAISDK as X, currentSpan as Y, defaultTransformSpan as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, eventMetadata as a0, eventMetadataFromChatRequest as a1, getContextManager as a2, getCurrentParentToolContext as a3, getCurrentRaindropCallMetadata as a4, normalizeFeatureFlags as a5, raindrop as a6, readRaindropCallMetadataFromArgs as a7, redactJsonAttributeValue as a8, redactSecretsInObject as a9, runWithParentToolContext as aa, runWithRaindropCallMetadata as ab, withCurrent as ac, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type FeatureFlags as l, type OtlpSpan as m, type RaindropAISDKClient as n, type RaindropAISDKContext as o, type RaindropAISDKOptions as p, type RaindropCallMetadata as q, RaindropTelemetryIntegration as r, type RaindropTelemetryIntegrationOptions as s, type RaindropTelemetryOptions as t, type SelfDiagnosticsSignalDefinition as u, type SelfDiagnosticsSignalDefinitions as v, type SelfDiagnosticsTool as w, type SelfDiagnosticsToolInput as x, type SelfDiagnosticsToolOptions as y, type SelfDiagnosticsToolResult as z };
@@ -1,3 +1,14 @@
1
+ type FeatureFlagValue = string | number | boolean;
2
+ type FeatureFlags = string[] | Record<string, FeatureFlagValue>;
3
+ /**
4
+ * Normalizes feature flags from the two accepted input forms into a
5
+ * canonical `Record<string, string>` ready for the wire payload.
6
+ *
7
+ * - Array form: `["a", "b"]` → `{"a": "true", "b": "true"}`
8
+ * - Object form: `{ a: "v2", b: true, c: 3 }` → `{"a": "v2", "b": "true", "c": "3"}`
9
+ */
10
+ declare function normalizeFeatureFlags(input: FeatureFlags): Record<string, string>;
11
+
1
12
  type OtlpAnyValue = {
2
13
  stringValue?: string;
3
14
  intValue?: string;
@@ -53,6 +64,7 @@ type Patch = {
53
64
  output?: string;
54
65
  model?: string;
55
66
  properties?: Record<string, unknown>;
67
+ featureFlags?: Record<string, string>;
56
68
  attachments?: Attachment$1[];
57
69
  isPending?: boolean;
58
70
  timestamp?: string;
@@ -153,6 +165,7 @@ declare class EventShipper$1 {
153
165
  output?: string;
154
166
  model?: string;
155
167
  properties?: Record<string, unknown>;
168
+ featureFlags?: Record<string, string>;
156
169
  userId?: string;
157
170
  }): Promise<void>;
158
171
  flush(): Promise<void>;
@@ -490,6 +503,37 @@ declare class TraceShipper extends TraceShipper$1 {
490
503
  constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
491
504
  }
492
505
 
506
+ /**
507
+ * Raindrop telemetry integration for AI SDK v7+
508
+ *
509
+ * Implements the AI SDK's `Telemetry` interface (formerly `TelemetryIntegration`
510
+ * before v7 beta.111) to capture traces and events natively, replacing the
511
+ * Proxy-based wrapping used for v4-v6.
512
+ *
513
+ * Modeled after the upstream OpenTelemetry integration but uses Raindrop's
514
+ * TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
515
+ *
516
+ * Compatibility: this class targets the latest published v7 build but also
517
+ * exposes the older v7 callback names as aliases so it works on every v7
518
+ * beta/canary released to date:
519
+ * - `onToolCallStart`/`onToolCallFinish` (< beta.111) alongside
520
+ * `onToolExecutionStart`/`onToolExecutionEnd` (>= beta.111).
521
+ * - Current `onToolExecutionEnd` events use the `toolOutput` discriminated
522
+ * union; older builds used top-level `success`/`output`/`error` fields.
523
+ * - `onFinish`/`onEmbedFinish` (< canary.159) alongside `onEnd`/`onEmbedEnd`
524
+ * (>= canary.159, vercel/ai renamed the operation finalizers).
525
+ * - `onAbort` (added as a telemetry-integration callback on the v7 canary
526
+ * line, post-beta.116) finalizes open spans + the pending event when a
527
+ * `streamText` call is cancelled via its `AbortSignal`. Builds that don't
528
+ * dispatch it to integrations simply never call it, so it's a no-op there.
529
+ *
530
+ * Step-end note: we intentionally implement only `onStepFinish` (not the newer
531
+ * `onStepEnd`). The latest canary dispatcher fans every step-end event out to
532
+ * BOTH `onStepEnd` and the deprecated `onStepFinish` on each integration, so
533
+ * implementing both names would double-close the step span. `onStepFinish`
534
+ * alone is dispatched on every published v7 beta/canary to date.
535
+ */
536
+
493
537
  type Listener<T> = (event: T) => PromiseLike<void> | void;
494
538
  type ToolExecutionEndEvent = {
495
539
  callId: string;
@@ -563,6 +607,7 @@ type RaindropTelemetryIntegrationOptions = {
563
607
  eventName?: string;
564
608
  convoId?: string;
565
609
  properties?: Record<string, unknown>;
610
+ featureFlags?: FeatureFlags;
566
611
  };
567
612
  };
568
613
  declare class RaindropTelemetryIntegration implements TelemetryIntegration {
@@ -839,6 +884,8 @@ type EventMetadataOptions = {
839
884
  eventName?: string;
840
885
  /** Additional properties to merge with wrap-time properties */
841
886
  properties?: Record<string, unknown>;
887
+ /** Feature flags to attach to this event (merged with wrap-time flags; call-time wins) */
888
+ featureFlags?: FeatureFlags;
842
889
  };
843
890
  /**
844
891
  * Creates metadata for use with the AI SDK's `experimental_telemetry.metadata` option.
@@ -1042,6 +1089,7 @@ type RaindropAISDKContext = {
1042
1089
  eventName?: string;
1043
1090
  convoId?: string;
1044
1091
  properties?: Record<string, unknown>;
1092
+ featureFlags?: FeatureFlags;
1045
1093
  attachments?: Attachment[];
1046
1094
  };
1047
1095
 
@@ -1051,6 +1099,7 @@ type BuildEventPatch = {
1051
1099
  output?: string;
1052
1100
  model?: string;
1053
1101
  properties?: Record<string, unknown>;
1102
+ featureFlags?: Record<string, string>;
1054
1103
  attachments?: Attachment[];
1055
1104
  };
1056
1105
  /**
@@ -1215,6 +1264,7 @@ type EventPatch = {
1215
1264
  output?: string;
1216
1265
  model?: string;
1217
1266
  properties?: Record<string, unknown>;
1267
+ featureFlags?: Record<string, string>;
1218
1268
  attachments?: Attachment[];
1219
1269
  isPending?: boolean;
1220
1270
  timestamp?: string;
@@ -1247,10 +1297,12 @@ type RaindropAISDKClient = {
1247
1297
  patch(eventId: string, patch: EventPatch): Promise<void>;
1248
1298
  addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
1249
1299
  setProperties(eventId: string, properties: Record<string, unknown>): Promise<void>;
1300
+ setFeatureFlags(eventId: string, featureFlags: FeatureFlags): Promise<void>;
1250
1301
  finish(eventId: string, patch: {
1251
1302
  output?: string;
1252
1303
  model?: string;
1253
1304
  properties?: Record<string, unknown>;
1305
+ featureFlags?: Record<string, string>;
1254
1306
  }): Promise<void>;
1255
1307
  };
1256
1308
  /**
@@ -1361,4 +1413,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
1361
1413
  */
1362
1414
  declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
1363
1415
 
1364
- export { eventMetadataFromChatRequest as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type TraceSpan as F, type TransformSpanHook as G, type WrappedAI as H, type IdentifyInput as I, type WrappedAISDK as J, _resetRaindropCallMetadataStorage as K, _resetWarnedMissingUserId as L, boundedStringify as M, capText as N, type OtlpAnyValue as O, type ParentToolContext as P, clearParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, createRaindropAISDK as U, currentSpan as V, type WrapAISDKOptions as W, defaultTransformSpan as X, enterParentToolContext as Y, eventMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, getContextManager as a0, getCurrentParentToolContext as a1, getCurrentRaindropCallMetadata as a2, raindrop as a3, readRaindropCallMetadataFromArgs as a4, redactJsonAttributeValue as a5, redactSecretsInObject as a6, runWithParentToolContext as a7, runWithRaindropCallMetadata as a8, withCurrent as a9, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type OtlpSpan as l, type RaindropAISDKClient as m, type RaindropAISDKContext as n, type RaindropAISDKOptions as o, type RaindropCallMetadata as p, RaindropTelemetryIntegration as q, type RaindropTelemetryIntegrationOptions as r, type RaindropTelemetryOptions as s, type SelfDiagnosticsSignalDefinition as t, type SelfDiagnosticsSignalDefinitions as u, type SelfDiagnosticsTool as v, type SelfDiagnosticsToolInput as w, type SelfDiagnosticsToolOptions as x, type SelfDiagnosticsToolResult as y, type StartSpanArgs as z };
1416
+ export { enterParentToolContext as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type FeatureFlagValue as F, type StartSpanArgs as G, type TraceSpan as H, type IdentifyInput as I, type TransformSpanHook as J, type WrappedAI as K, type WrappedAISDK as L, _resetRaindropCallMetadataStorage as M, _resetWarnedMissingUserId as N, type OtlpAnyValue as O, type ParentToolContext as P, boundedStringify as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, capText as U, clearParentToolContext as V, type WrapAISDKOptions as W, createRaindropAISDK as X, currentSpan as Y, defaultTransformSpan as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, eventMetadata as a0, eventMetadataFromChatRequest as a1, getContextManager as a2, getCurrentParentToolContext as a3, getCurrentRaindropCallMetadata as a4, normalizeFeatureFlags as a5, raindrop as a6, readRaindropCallMetadataFromArgs as a7, redactJsonAttributeValue as a8, redactSecretsInObject as a9, runWithParentToolContext as aa, runWithRaindropCallMetadata as ab, withCurrent as ac, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type FeatureFlags as l, type OtlpSpan as m, type RaindropAISDKClient as n, type RaindropAISDKContext as o, type RaindropAISDKOptions as p, type RaindropCallMetadata as q, RaindropTelemetryIntegration as r, type RaindropTelemetryIntegrationOptions as s, type RaindropTelemetryOptions as t, type SelfDiagnosticsSignalDefinition as u, type SelfDiagnosticsSignalDefinitions as v, type SelfDiagnosticsTool as w, type SelfDiagnosticsToolInput as x, type SelfDiagnosticsToolOptions as y, type SelfDiagnosticsToolResult as z };
@@ -1,3 +1,14 @@
1
+ type FeatureFlagValue = string | number | boolean;
2
+ type FeatureFlags = string[] | Record<string, FeatureFlagValue>;
3
+ /**
4
+ * Normalizes feature flags from the two accepted input forms into a
5
+ * canonical `Record<string, string>` ready for the wire payload.
6
+ *
7
+ * - Array form: `["a", "b"]` → `{"a": "true", "b": "true"}`
8
+ * - Object form: `{ a: "v2", b: true, c: 3 }` → `{"a": "v2", "b": "true", "c": "3"}`
9
+ */
10
+ declare function normalizeFeatureFlags(input: FeatureFlags): Record<string, string>;
11
+
1
12
  type OtlpAnyValue = {
2
13
  stringValue?: string;
3
14
  intValue?: string;
@@ -53,6 +64,7 @@ type Patch = {
53
64
  output?: string;
54
65
  model?: string;
55
66
  properties?: Record<string, unknown>;
67
+ featureFlags?: Record<string, string>;
56
68
  attachments?: Attachment$1[];
57
69
  isPending?: boolean;
58
70
  timestamp?: string;
@@ -153,6 +165,7 @@ declare class EventShipper$1 {
153
165
  output?: string;
154
166
  model?: string;
155
167
  properties?: Record<string, unknown>;
168
+ featureFlags?: Record<string, string>;
156
169
  userId?: string;
157
170
  }): Promise<void>;
158
171
  flush(): Promise<void>;
@@ -490,6 +503,37 @@ declare class TraceShipper extends TraceShipper$1 {
490
503
  constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
491
504
  }
492
505
 
506
+ /**
507
+ * Raindrop telemetry integration for AI SDK v7+
508
+ *
509
+ * Implements the AI SDK's `Telemetry` interface (formerly `TelemetryIntegration`
510
+ * before v7 beta.111) to capture traces and events natively, replacing the
511
+ * Proxy-based wrapping used for v4-v6.
512
+ *
513
+ * Modeled after the upstream OpenTelemetry integration but uses Raindrop's
514
+ * TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
515
+ *
516
+ * Compatibility: this class targets the latest published v7 build but also
517
+ * exposes the older v7 callback names as aliases so it works on every v7
518
+ * beta/canary released to date:
519
+ * - `onToolCallStart`/`onToolCallFinish` (< beta.111) alongside
520
+ * `onToolExecutionStart`/`onToolExecutionEnd` (>= beta.111).
521
+ * - Current `onToolExecutionEnd` events use the `toolOutput` discriminated
522
+ * union; older builds used top-level `success`/`output`/`error` fields.
523
+ * - `onFinish`/`onEmbedFinish` (< canary.159) alongside `onEnd`/`onEmbedEnd`
524
+ * (>= canary.159, vercel/ai renamed the operation finalizers).
525
+ * - `onAbort` (added as a telemetry-integration callback on the v7 canary
526
+ * line, post-beta.116) finalizes open spans + the pending event when a
527
+ * `streamText` call is cancelled via its `AbortSignal`. Builds that don't
528
+ * dispatch it to integrations simply never call it, so it's a no-op there.
529
+ *
530
+ * Step-end note: we intentionally implement only `onStepFinish` (not the newer
531
+ * `onStepEnd`). The latest canary dispatcher fans every step-end event out to
532
+ * BOTH `onStepEnd` and the deprecated `onStepFinish` on each integration, so
533
+ * implementing both names would double-close the step span. `onStepFinish`
534
+ * alone is dispatched on every published v7 beta/canary to date.
535
+ */
536
+
493
537
  type Listener<T> = (event: T) => PromiseLike<void> | void;
494
538
  type ToolExecutionEndEvent = {
495
539
  callId: string;
@@ -563,6 +607,7 @@ type RaindropTelemetryIntegrationOptions = {
563
607
  eventName?: string;
564
608
  convoId?: string;
565
609
  properties?: Record<string, unknown>;
610
+ featureFlags?: FeatureFlags;
566
611
  };
567
612
  };
568
613
  declare class RaindropTelemetryIntegration implements TelemetryIntegration {
@@ -839,6 +884,8 @@ type EventMetadataOptions = {
839
884
  eventName?: string;
840
885
  /** Additional properties to merge with wrap-time properties */
841
886
  properties?: Record<string, unknown>;
887
+ /** Feature flags to attach to this event (merged with wrap-time flags; call-time wins) */
888
+ featureFlags?: FeatureFlags;
842
889
  };
843
890
  /**
844
891
  * Creates metadata for use with the AI SDK's `experimental_telemetry.metadata` option.
@@ -1042,6 +1089,7 @@ type RaindropAISDKContext = {
1042
1089
  eventName?: string;
1043
1090
  convoId?: string;
1044
1091
  properties?: Record<string, unknown>;
1092
+ featureFlags?: FeatureFlags;
1045
1093
  attachments?: Attachment[];
1046
1094
  };
1047
1095
 
@@ -1051,6 +1099,7 @@ type BuildEventPatch = {
1051
1099
  output?: string;
1052
1100
  model?: string;
1053
1101
  properties?: Record<string, unknown>;
1102
+ featureFlags?: Record<string, string>;
1054
1103
  attachments?: Attachment[];
1055
1104
  };
1056
1105
  /**
@@ -1215,6 +1264,7 @@ type EventPatch = {
1215
1264
  output?: string;
1216
1265
  model?: string;
1217
1266
  properties?: Record<string, unknown>;
1267
+ featureFlags?: Record<string, string>;
1218
1268
  attachments?: Attachment[];
1219
1269
  isPending?: boolean;
1220
1270
  timestamp?: string;
@@ -1247,10 +1297,12 @@ type RaindropAISDKClient = {
1247
1297
  patch(eventId: string, patch: EventPatch): Promise<void>;
1248
1298
  addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
1249
1299
  setProperties(eventId: string, properties: Record<string, unknown>): Promise<void>;
1300
+ setFeatureFlags(eventId: string, featureFlags: FeatureFlags): Promise<void>;
1250
1301
  finish(eventId: string, patch: {
1251
1302
  output?: string;
1252
1303
  model?: string;
1253
1304
  properties?: Record<string, unknown>;
1305
+ featureFlags?: Record<string, string>;
1254
1306
  }): Promise<void>;
1255
1307
  };
1256
1308
  /**
@@ -1361,4 +1413,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
1361
1413
  */
1362
1414
  declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
1363
1415
 
1364
- export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type OtlpAnyValue, type OtlpSpan, type ParentToolContext, REDACTED_PLACEHOLDER, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type RaindropCallMetadata, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type RaindropTelemetryOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type SelfDiagnosticsTool, type SelfDiagnosticsToolInput, type SelfDiagnosticsToolOptions, type SelfDiagnosticsToolResult, type StartSpanArgs, TRUNCATION_MARKER, type TraceSpan, type TransformSpanHook, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
1416
+ export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type FeatureFlagValue, type FeatureFlags, type IdentifyInput, type OtlpAnyValue, type OtlpSpan, type ParentToolContext, REDACTED_PLACEHOLDER, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type RaindropCallMetadata, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type RaindropTelemetryOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type SelfDiagnosticsTool, type SelfDiagnosticsToolInput, type SelfDiagnosticsToolOptions, type SelfDiagnosticsToolResult, type StartSpanArgs, TRUNCATION_MARKER, type TraceSpan, type TransformSpanHook, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, normalizeFeatureFlags, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };