@raindrop-ai/ai-sdk 0.0.19 → 0.0.21

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,7 +1,190 @@
1
- type IdentifyInput = {
1
+ type OtlpAnyValue = {
2
+ stringValue?: string;
3
+ intValue?: string;
4
+ doubleValue?: number;
5
+ boolValue?: boolean;
6
+ arrayValue?: {
7
+ values: OtlpAnyValue[];
8
+ };
9
+ };
10
+ type OtlpKeyValue = {
11
+ key: string;
12
+ value: OtlpAnyValue;
13
+ };
14
+ declare const SpanStatusCode: {
15
+ readonly UNSET: 0;
16
+ readonly OK: 1;
17
+ readonly ERROR: 2;
18
+ };
19
+ type OtlpSpanStatus = {
20
+ code: (typeof SpanStatusCode)[keyof typeof SpanStatusCode] | number;
21
+ message?: string;
22
+ };
23
+ type OtlpSpan = {
24
+ traceId: string;
25
+ spanId: string;
26
+ parentSpanId?: string;
27
+ name: string;
28
+ startTimeUnixNano: string;
29
+ endTimeUnixNano: string;
30
+ attributes?: OtlpKeyValue[];
31
+ status?: OtlpSpanStatus;
32
+ };
33
+ type SpanIds = {
34
+ traceIdB64: string;
35
+ spanIdB64: string;
36
+ parentSpanIdB64?: string;
37
+ };
38
+
39
+ type Attachment$1 = {
40
+ type: string;
41
+ role: string;
42
+ name?: string;
43
+ value: string;
44
+ };
45
+ type IdentifyInput$1 = {
2
46
  userId: string;
3
47
  traits?: Record<string, unknown>;
4
48
  };
49
+ type Patch = {
50
+ eventName?: string;
51
+ userId?: string;
52
+ convoId?: string;
53
+ input?: string;
54
+ output?: string;
55
+ model?: string;
56
+ properties?: Record<string, unknown>;
57
+ attachments?: Attachment$1[];
58
+ isPending?: boolean;
59
+ timestamp?: string;
60
+ };
61
+ type SignalInput = {
62
+ eventId: string;
63
+ name: string;
64
+ type?: "default" | "feedback" | "edit" | "standard" | "agent" | "agent_internal";
65
+ sentiment?: "POSITIVE" | "NEGATIVE";
66
+ timestamp?: string;
67
+ properties?: Record<string, unknown>;
68
+ attachmentId?: string;
69
+ comment?: string;
70
+ after?: string;
71
+ };
72
+ type EventShipperOptions = {
73
+ writeKey?: string;
74
+ endpoint?: string;
75
+ enabled?: boolean;
76
+ debug: boolean;
77
+ partialFlushMs?: number;
78
+ sdkName?: string;
79
+ libraryName?: string;
80
+ libraryVersion?: string;
81
+ defaultEventName?: string;
82
+ };
83
+ declare class EventShipper$1 {
84
+ private baseUrl;
85
+ private writeKey?;
86
+ private enabled;
87
+ private debug;
88
+ private partialFlushMs;
89
+ private sdkName;
90
+ private prefix;
91
+ private defaultEventName;
92
+ private context;
93
+ private buffers;
94
+ private sticky;
95
+ private timers;
96
+ private inFlight;
97
+ constructor(opts: EventShipperOptions);
98
+ isDebugEnabled(): boolean;
99
+ private authHeaders;
100
+ patch(eventId: string, patch: Patch): Promise<void>;
101
+ finish(eventId: string, patch: {
102
+ output?: string;
103
+ model?: string;
104
+ properties?: Record<string, unknown>;
105
+ userId?: string;
106
+ }): Promise<void>;
107
+ flush(): Promise<void>;
108
+ shutdown(): Promise<void>;
109
+ trackSignal(signal: SignalInput): Promise<void>;
110
+ identify(users: IdentifyInput$1 | IdentifyInput$1[]): Promise<void>;
111
+ private flushOne;
112
+ }
113
+
114
+ type InternalSpan = {
115
+ ids: SpanIds;
116
+ name: string;
117
+ startTimeUnixNano: string;
118
+ endTimeUnixNano?: string;
119
+ attributes: Array<OtlpKeyValue | undefined>;
120
+ };
121
+ type TraceShipperOptions = {
122
+ writeKey?: string;
123
+ endpoint?: string;
124
+ enabled?: boolean;
125
+ debug: boolean;
126
+ debugSpans?: boolean;
127
+ flushIntervalMs?: number;
128
+ maxBatchSize?: number;
129
+ maxQueueSize?: number;
130
+ sdkName?: string;
131
+ serviceName?: string;
132
+ serviceVersion?: string;
133
+ };
134
+ declare class TraceShipper$1 {
135
+ private baseUrl;
136
+ private writeKey?;
137
+ private enabled;
138
+ private debug;
139
+ private debugSpans;
140
+ private sdkName;
141
+ private prefix;
142
+ private serviceName;
143
+ private serviceVersion;
144
+ private flushIntervalMs;
145
+ private maxBatchSize;
146
+ private maxQueueSize;
147
+ private queue;
148
+ private timer;
149
+ private inFlight;
150
+ /** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
151
+ private localDebuggerUrl;
152
+ constructor(opts: TraceShipperOptions);
153
+ isDebugEnabled(): boolean;
154
+ private authHeaders;
155
+ startSpan(args: {
156
+ name: string;
157
+ parent?: {
158
+ traceIdB64: string;
159
+ spanIdB64: string;
160
+ };
161
+ eventId: string;
162
+ operationId?: string;
163
+ attributes?: Array<OtlpKeyValue | undefined>;
164
+ startTimeUnixNano?: string;
165
+ }): InternalSpan;
166
+ endSpan(span: InternalSpan, extra?: {
167
+ attributes?: InternalSpan["attributes"];
168
+ error?: unknown;
169
+ status?: OtlpSpanStatus;
170
+ endTimeUnixNano?: string;
171
+ }): void;
172
+ createSpan(args: {
173
+ name: string;
174
+ parent?: {
175
+ traceIdB64: string;
176
+ spanIdB64: string;
177
+ };
178
+ eventId: string;
179
+ startTimeUnixNano: string;
180
+ endTimeUnixNano: string;
181
+ attributes?: Array<OtlpKeyValue | undefined>;
182
+ status?: OtlpSpanStatus;
183
+ }): void;
184
+ enqueue(span: OtlpSpan): void;
185
+ flush(): Promise<void>;
186
+ shutdown(): Promise<void>;
187
+ }
5
188
 
6
189
  type ParentSpanContext = {
7
190
  traceIdB64: string;
@@ -33,6 +216,99 @@ declare function getContextManager(): ContextManager;
33
216
  declare function currentSpan(): ContextSpan;
34
217
  declare function withCurrent<R>(span: ContextSpan, callback: () => R): R;
35
218
 
219
+ declare class EventShipper extends EventShipper$1 {
220
+ constructor(opts: ConstructorParameters<typeof EventShipper$1>[0]);
221
+ }
222
+
223
+ declare class TraceShipper extends TraceShipper$1 {
224
+ constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
225
+ }
226
+
227
+ /**
228
+ * Raindrop TelemetryIntegration for AI SDK v7+
229
+ *
230
+ * Implements the AI SDK's TelemetryIntegration interface to capture traces and
231
+ * events natively, replacing the Proxy-based wrapping used for v4-v6.
232
+ *
233
+ * Modeled after the upstream OpenTelemetryIntegration but uses Raindrop's
234
+ * TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
235
+ */
236
+
237
+ type Listener<T> = (event: T) => PromiseLike<void> | void;
238
+ interface TelemetryIntegration {
239
+ onStart?: Listener<any>;
240
+ onStepStart?: Listener<any>;
241
+ onToolCallStart?: Listener<any>;
242
+ onToolCallFinish?: Listener<any>;
243
+ onChunk?: Listener<any>;
244
+ onStepFinish?: Listener<any>;
245
+ onEmbedStart?: Listener<any>;
246
+ onEmbedFinish?: Listener<any>;
247
+ onFinish?: Listener<any>;
248
+ onError?: Listener<any>;
249
+ executeTool?: <T>(params: {
250
+ callId: string;
251
+ toolCallId: string;
252
+ execute: () => PromiseLike<T>;
253
+ }) => PromiseLike<T>;
254
+ }
255
+ type RaindropTelemetryIntegrationOptions = {
256
+ traceShipper: TraceShipper;
257
+ eventShipper: EventShipper;
258
+ sendTraces?: boolean;
259
+ sendEvents?: boolean;
260
+ debug?: boolean;
261
+ context?: {
262
+ userId?: string;
263
+ eventId?: string;
264
+ eventName?: string;
265
+ convoId?: string;
266
+ properties?: Record<string, unknown>;
267
+ };
268
+ };
269
+ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
270
+ private readonly traceShipper;
271
+ private readonly eventShipper;
272
+ private readonly sendTraces;
273
+ private readonly sendEvents;
274
+ private readonly debug;
275
+ private readonly defaultContext;
276
+ private readonly callStates;
277
+ constructor(opts: RaindropTelemetryIntegrationOptions);
278
+ private getState;
279
+ private cleanup;
280
+ private spanParentRef;
281
+ private emitLive;
282
+ private extractRaindropMetadata;
283
+ /**
284
+ * Extract the user-facing input text from an onStart event.
285
+ * Mirrors the logic in the v4-v6 Proxy path (lastUserMessageTextFromArgs / extractInputFromArgs).
286
+ */
287
+ private extractInputText;
288
+ onStart: (event: any) => void;
289
+ onStepStart: (event: any) => void;
290
+ onToolCallStart: (event: any) => void;
291
+ onToolCallFinish: (event: any) => void;
292
+ onChunk: (event: any) => void;
293
+ onStepFinish: (event: any) => void;
294
+ onEmbedStart: (event: any) => void;
295
+ onEmbedFinish: (event: any) => void;
296
+ onFinish: (event: any) => void;
297
+ private finishGenerate;
298
+ private finishEmbed;
299
+ onError: (error: unknown) => void;
300
+ executeTool: <T>({ callId, toolCallId, execute, }: {
301
+ callId: string;
302
+ toolCallId: string;
303
+ execute: () => PromiseLike<T>;
304
+ }) => Promise<T>;
305
+ }
306
+
307
+ type IdentifyInput = {
308
+ userId: string;
309
+ traits?: Record<string, unknown>;
310
+ };
311
+
36
312
  declare function _resetWarnedMissingUserId(): void;
37
313
 
38
314
  /**
@@ -264,6 +540,16 @@ type WrapAISDKOptions = {
264
540
  events?: boolean;
265
541
  traces?: boolean;
266
542
  };
543
+ /**
544
+ * Use the AI SDK's native TelemetryIntegration instead of Proxy-based wrapping.
545
+ * Requires AI SDK v7+. Throws on older versions.
546
+ *
547
+ * When enabled, `wrap()` registers a `RaindropTelemetryIntegration` globally
548
+ * and returns the original module instead of a Proxy.
549
+ *
550
+ * Default: false (uses Proxy wrapping for backward compatibility).
551
+ */
552
+ nativeTelemetry?: boolean;
267
553
  };
268
554
  type EventPatch = {
269
555
  eventName?: string;
@@ -279,6 +565,11 @@ type EventPatch = {
279
565
  };
280
566
  type RaindropAISDKClient = {
281
567
  wrap<T extends object>(aiSDK: T, options?: WrapAISDKOptions): WrappedAISDK<T>;
568
+ /**
569
+ * Create a TelemetryIntegration instance for direct registration with AI SDK v7+.
570
+ * Use with `registerTelemetryIntegration()` from the `ai` package.
571
+ */
572
+ createTelemetryIntegration(context?: RaindropTelemetryIntegrationOptions["context"]): RaindropTelemetryIntegration;
282
573
  events: {
283
574
  patch(eventId: string, patch: EventPatch): Promise<void>;
284
575
  addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
@@ -310,4 +601,4 @@ type RaindropAISDKClient = {
310
601
  };
311
602
  declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
312
603
 
313
- export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EventBuilder as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type WrapAISDKOptions as W, _resetWarnedMissingUserId as _, type AISDKChatRequestMessageLike as a, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type EventMetadataOptions as g, type RaindropAISDKContext as h, type RaindropAISDKOptions as i, type SelfDiagnosticsSignalDefinition as j, type SelfDiagnosticsSignalDefinitions as k, type WrappedAI as l, type WrappedAISDK as m, createRaindropAISDK as n, currentSpan as o, eventMetadata as p, eventMetadataFromChatRequest as q, getContextManager as r, withCurrent as w };
604
+ export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EventBuilder as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type WrapAISDKOptions as W, _resetWarnedMissingUserId as _, type AISDKChatRequestMessageLike as a, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type EventMetadataOptions as g, type RaindropAISDKContext as h, type RaindropAISDKOptions as i, RaindropTelemetryIntegration as j, type RaindropTelemetryIntegrationOptions as k, type SelfDiagnosticsSignalDefinition as l, type SelfDiagnosticsSignalDefinitions as m, type WrappedAI as n, type WrappedAISDK as o, createRaindropAISDK as p, currentSpan as q, eventMetadata as r, eventMetadataFromChatRequest as s, getContextManager as t, withCurrent as w };
@@ -1,7 +1,190 @@
1
- type IdentifyInput = {
1
+ type OtlpAnyValue = {
2
+ stringValue?: string;
3
+ intValue?: string;
4
+ doubleValue?: number;
5
+ boolValue?: boolean;
6
+ arrayValue?: {
7
+ values: OtlpAnyValue[];
8
+ };
9
+ };
10
+ type OtlpKeyValue = {
11
+ key: string;
12
+ value: OtlpAnyValue;
13
+ };
14
+ declare const SpanStatusCode: {
15
+ readonly UNSET: 0;
16
+ readonly OK: 1;
17
+ readonly ERROR: 2;
18
+ };
19
+ type OtlpSpanStatus = {
20
+ code: (typeof SpanStatusCode)[keyof typeof SpanStatusCode] | number;
21
+ message?: string;
22
+ };
23
+ type OtlpSpan = {
24
+ traceId: string;
25
+ spanId: string;
26
+ parentSpanId?: string;
27
+ name: string;
28
+ startTimeUnixNano: string;
29
+ endTimeUnixNano: string;
30
+ attributes?: OtlpKeyValue[];
31
+ status?: OtlpSpanStatus;
32
+ };
33
+ type SpanIds = {
34
+ traceIdB64: string;
35
+ spanIdB64: string;
36
+ parentSpanIdB64?: string;
37
+ };
38
+
39
+ type Attachment$1 = {
40
+ type: string;
41
+ role: string;
42
+ name?: string;
43
+ value: string;
44
+ };
45
+ type IdentifyInput$1 = {
2
46
  userId: string;
3
47
  traits?: Record<string, unknown>;
4
48
  };
49
+ type Patch = {
50
+ eventName?: string;
51
+ userId?: string;
52
+ convoId?: string;
53
+ input?: string;
54
+ output?: string;
55
+ model?: string;
56
+ properties?: Record<string, unknown>;
57
+ attachments?: Attachment$1[];
58
+ isPending?: boolean;
59
+ timestamp?: string;
60
+ };
61
+ type SignalInput = {
62
+ eventId: string;
63
+ name: string;
64
+ type?: "default" | "feedback" | "edit" | "standard" | "agent" | "agent_internal";
65
+ sentiment?: "POSITIVE" | "NEGATIVE";
66
+ timestamp?: string;
67
+ properties?: Record<string, unknown>;
68
+ attachmentId?: string;
69
+ comment?: string;
70
+ after?: string;
71
+ };
72
+ type EventShipperOptions = {
73
+ writeKey?: string;
74
+ endpoint?: string;
75
+ enabled?: boolean;
76
+ debug: boolean;
77
+ partialFlushMs?: number;
78
+ sdkName?: string;
79
+ libraryName?: string;
80
+ libraryVersion?: string;
81
+ defaultEventName?: string;
82
+ };
83
+ declare class EventShipper$1 {
84
+ private baseUrl;
85
+ private writeKey?;
86
+ private enabled;
87
+ private debug;
88
+ private partialFlushMs;
89
+ private sdkName;
90
+ private prefix;
91
+ private defaultEventName;
92
+ private context;
93
+ private buffers;
94
+ private sticky;
95
+ private timers;
96
+ private inFlight;
97
+ constructor(opts: EventShipperOptions);
98
+ isDebugEnabled(): boolean;
99
+ private authHeaders;
100
+ patch(eventId: string, patch: Patch): Promise<void>;
101
+ finish(eventId: string, patch: {
102
+ output?: string;
103
+ model?: string;
104
+ properties?: Record<string, unknown>;
105
+ userId?: string;
106
+ }): Promise<void>;
107
+ flush(): Promise<void>;
108
+ shutdown(): Promise<void>;
109
+ trackSignal(signal: SignalInput): Promise<void>;
110
+ identify(users: IdentifyInput$1 | IdentifyInput$1[]): Promise<void>;
111
+ private flushOne;
112
+ }
113
+
114
+ type InternalSpan = {
115
+ ids: SpanIds;
116
+ name: string;
117
+ startTimeUnixNano: string;
118
+ endTimeUnixNano?: string;
119
+ attributes: Array<OtlpKeyValue | undefined>;
120
+ };
121
+ type TraceShipperOptions = {
122
+ writeKey?: string;
123
+ endpoint?: string;
124
+ enabled?: boolean;
125
+ debug: boolean;
126
+ debugSpans?: boolean;
127
+ flushIntervalMs?: number;
128
+ maxBatchSize?: number;
129
+ maxQueueSize?: number;
130
+ sdkName?: string;
131
+ serviceName?: string;
132
+ serviceVersion?: string;
133
+ };
134
+ declare class TraceShipper$1 {
135
+ private baseUrl;
136
+ private writeKey?;
137
+ private enabled;
138
+ private debug;
139
+ private debugSpans;
140
+ private sdkName;
141
+ private prefix;
142
+ private serviceName;
143
+ private serviceVersion;
144
+ private flushIntervalMs;
145
+ private maxBatchSize;
146
+ private maxQueueSize;
147
+ private queue;
148
+ private timer;
149
+ private inFlight;
150
+ /** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
151
+ private localDebuggerUrl;
152
+ constructor(opts: TraceShipperOptions);
153
+ isDebugEnabled(): boolean;
154
+ private authHeaders;
155
+ startSpan(args: {
156
+ name: string;
157
+ parent?: {
158
+ traceIdB64: string;
159
+ spanIdB64: string;
160
+ };
161
+ eventId: string;
162
+ operationId?: string;
163
+ attributes?: Array<OtlpKeyValue | undefined>;
164
+ startTimeUnixNano?: string;
165
+ }): InternalSpan;
166
+ endSpan(span: InternalSpan, extra?: {
167
+ attributes?: InternalSpan["attributes"];
168
+ error?: unknown;
169
+ status?: OtlpSpanStatus;
170
+ endTimeUnixNano?: string;
171
+ }): void;
172
+ createSpan(args: {
173
+ name: string;
174
+ parent?: {
175
+ traceIdB64: string;
176
+ spanIdB64: string;
177
+ };
178
+ eventId: string;
179
+ startTimeUnixNano: string;
180
+ endTimeUnixNano: string;
181
+ attributes?: Array<OtlpKeyValue | undefined>;
182
+ status?: OtlpSpanStatus;
183
+ }): void;
184
+ enqueue(span: OtlpSpan): void;
185
+ flush(): Promise<void>;
186
+ shutdown(): Promise<void>;
187
+ }
5
188
 
6
189
  type ParentSpanContext = {
7
190
  traceIdB64: string;
@@ -33,6 +216,99 @@ declare function getContextManager(): ContextManager;
33
216
  declare function currentSpan(): ContextSpan;
34
217
  declare function withCurrent<R>(span: ContextSpan, callback: () => R): R;
35
218
 
219
+ declare class EventShipper extends EventShipper$1 {
220
+ constructor(opts: ConstructorParameters<typeof EventShipper$1>[0]);
221
+ }
222
+
223
+ declare class TraceShipper extends TraceShipper$1 {
224
+ constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
225
+ }
226
+
227
+ /**
228
+ * Raindrop TelemetryIntegration for AI SDK v7+
229
+ *
230
+ * Implements the AI SDK's TelemetryIntegration interface to capture traces and
231
+ * events natively, replacing the Proxy-based wrapping used for v4-v6.
232
+ *
233
+ * Modeled after the upstream OpenTelemetryIntegration but uses Raindrop's
234
+ * TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
235
+ */
236
+
237
+ type Listener<T> = (event: T) => PromiseLike<void> | void;
238
+ interface TelemetryIntegration {
239
+ onStart?: Listener<any>;
240
+ onStepStart?: Listener<any>;
241
+ onToolCallStart?: Listener<any>;
242
+ onToolCallFinish?: Listener<any>;
243
+ onChunk?: Listener<any>;
244
+ onStepFinish?: Listener<any>;
245
+ onEmbedStart?: Listener<any>;
246
+ onEmbedFinish?: Listener<any>;
247
+ onFinish?: Listener<any>;
248
+ onError?: Listener<any>;
249
+ executeTool?: <T>(params: {
250
+ callId: string;
251
+ toolCallId: string;
252
+ execute: () => PromiseLike<T>;
253
+ }) => PromiseLike<T>;
254
+ }
255
+ type RaindropTelemetryIntegrationOptions = {
256
+ traceShipper: TraceShipper;
257
+ eventShipper: EventShipper;
258
+ sendTraces?: boolean;
259
+ sendEvents?: boolean;
260
+ debug?: boolean;
261
+ context?: {
262
+ userId?: string;
263
+ eventId?: string;
264
+ eventName?: string;
265
+ convoId?: string;
266
+ properties?: Record<string, unknown>;
267
+ };
268
+ };
269
+ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
270
+ private readonly traceShipper;
271
+ private readonly eventShipper;
272
+ private readonly sendTraces;
273
+ private readonly sendEvents;
274
+ private readonly debug;
275
+ private readonly defaultContext;
276
+ private readonly callStates;
277
+ constructor(opts: RaindropTelemetryIntegrationOptions);
278
+ private getState;
279
+ private cleanup;
280
+ private spanParentRef;
281
+ private emitLive;
282
+ private extractRaindropMetadata;
283
+ /**
284
+ * Extract the user-facing input text from an onStart event.
285
+ * Mirrors the logic in the v4-v6 Proxy path (lastUserMessageTextFromArgs / extractInputFromArgs).
286
+ */
287
+ private extractInputText;
288
+ onStart: (event: any) => void;
289
+ onStepStart: (event: any) => void;
290
+ onToolCallStart: (event: any) => void;
291
+ onToolCallFinish: (event: any) => void;
292
+ onChunk: (event: any) => void;
293
+ onStepFinish: (event: any) => void;
294
+ onEmbedStart: (event: any) => void;
295
+ onEmbedFinish: (event: any) => void;
296
+ onFinish: (event: any) => void;
297
+ private finishGenerate;
298
+ private finishEmbed;
299
+ onError: (error: unknown) => void;
300
+ executeTool: <T>({ callId, toolCallId, execute, }: {
301
+ callId: string;
302
+ toolCallId: string;
303
+ execute: () => PromiseLike<T>;
304
+ }) => Promise<T>;
305
+ }
306
+
307
+ type IdentifyInput = {
308
+ userId: string;
309
+ traits?: Record<string, unknown>;
310
+ };
311
+
36
312
  declare function _resetWarnedMissingUserId(): void;
37
313
 
38
314
  /**
@@ -264,6 +540,16 @@ type WrapAISDKOptions = {
264
540
  events?: boolean;
265
541
  traces?: boolean;
266
542
  };
543
+ /**
544
+ * Use the AI SDK's native TelemetryIntegration instead of Proxy-based wrapping.
545
+ * Requires AI SDK v7+. Throws on older versions.
546
+ *
547
+ * When enabled, `wrap()` registers a `RaindropTelemetryIntegration` globally
548
+ * and returns the original module instead of a Proxy.
549
+ *
550
+ * Default: false (uses Proxy wrapping for backward compatibility).
551
+ */
552
+ nativeTelemetry?: boolean;
267
553
  };
268
554
  type EventPatch = {
269
555
  eventName?: string;
@@ -279,6 +565,11 @@ type EventPatch = {
279
565
  };
280
566
  type RaindropAISDKClient = {
281
567
  wrap<T extends object>(aiSDK: T, options?: WrapAISDKOptions): WrappedAISDK<T>;
568
+ /**
569
+ * Create a TelemetryIntegration instance for direct registration with AI SDK v7+.
570
+ * Use with `registerTelemetryIntegration()` from the `ai` package.
571
+ */
572
+ createTelemetryIntegration(context?: RaindropTelemetryIntegrationOptions["context"]): RaindropTelemetryIntegration;
282
573
  events: {
283
574
  patch(eventId: string, patch: EventPatch): Promise<void>;
284
575
  addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
@@ -310,4 +601,4 @@ type RaindropAISDKClient = {
310
601
  };
311
602
  declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
312
603
 
313
- export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EventBuilder as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type WrapAISDKOptions as W, _resetWarnedMissingUserId as _, type AISDKChatRequestMessageLike as a, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type EventMetadataOptions as g, type RaindropAISDKContext as h, type RaindropAISDKOptions as i, type SelfDiagnosticsSignalDefinition as j, type SelfDiagnosticsSignalDefinitions as k, type WrappedAI as l, type WrappedAISDK as m, createRaindropAISDK as n, currentSpan as o, eventMetadata as p, eventMetadataFromChatRequest as q, getContextManager as r, withCurrent as w };
604
+ export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EventBuilder as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type WrapAISDKOptions as W, _resetWarnedMissingUserId as _, type AISDKChatRequestMessageLike as a, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type EventMetadataOptions as g, type RaindropAISDKContext as h, type RaindropAISDKOptions as i, RaindropTelemetryIntegration as j, type RaindropTelemetryIntegrationOptions as k, type SelfDiagnosticsSignalDefinition as l, type SelfDiagnosticsSignalDefinitions as m, type WrappedAI as n, type WrappedAISDK as o, createRaindropAISDK as p, currentSpan as q, eventMetadata as r, eventMetadataFromChatRequest as s, getContextManager as t, withCurrent as w };