@raindrop-ai/ai-sdk 0.0.19-beta.3 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/dist/{chunk-TVOZIVJA.mjs → chunk-CNLUX2MV.mjs} +93 -767
- package/dist/index-C9H6HnZm.d.mts +313 -0
- package/dist/index-C9H6HnZm.d.ts +313 -0
- package/dist/{index.d.mts → index.browser.d.mts} +2 -290
- package/dist/{index.d.ts → index.browser.d.ts} +2 -290
- package/dist/{index.js → index.browser.js} +68 -746
- package/dist/index.browser.mjs +3314 -0
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +69 -746
- package/dist/index.node.mjs +1 -1
- package/dist/index.workers.d.mts +1 -1
- package/dist/index.workers.d.ts +1 -1
- package/dist/index.workers.js +69 -746
- package/dist/index.workers.mjs +1 -1
- package/package.json +15 -29
- package/dist/index.mjs +0 -1
|
@@ -1,188 +1,7 @@
|
|
|
1
|
-
type
|
|
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 = {
|
|
1
|
+
type IdentifyInput = {
|
|
46
2
|
userId: string;
|
|
47
3
|
traits?: Record<string, unknown>;
|
|
48
4
|
};
|
|
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
|
-
constructor(opts: TraceShipperOptions);
|
|
151
|
-
isDebugEnabled(): boolean;
|
|
152
|
-
private authHeaders;
|
|
153
|
-
startSpan(args: {
|
|
154
|
-
name: string;
|
|
155
|
-
parent?: {
|
|
156
|
-
traceIdB64: string;
|
|
157
|
-
spanIdB64: string;
|
|
158
|
-
};
|
|
159
|
-
eventId: string;
|
|
160
|
-
operationId?: string;
|
|
161
|
-
attributes?: Array<OtlpKeyValue | undefined>;
|
|
162
|
-
startTimeUnixNano?: string;
|
|
163
|
-
}): InternalSpan;
|
|
164
|
-
endSpan(span: InternalSpan, extra?: {
|
|
165
|
-
attributes?: InternalSpan["attributes"];
|
|
166
|
-
error?: unknown;
|
|
167
|
-
status?: OtlpSpanStatus;
|
|
168
|
-
endTimeUnixNano?: string;
|
|
169
|
-
}): void;
|
|
170
|
-
createSpan(args: {
|
|
171
|
-
name: string;
|
|
172
|
-
parent?: {
|
|
173
|
-
traceIdB64: string;
|
|
174
|
-
spanIdB64: string;
|
|
175
|
-
};
|
|
176
|
-
eventId: string;
|
|
177
|
-
startTimeUnixNano: string;
|
|
178
|
-
endTimeUnixNano: string;
|
|
179
|
-
attributes?: Array<OtlpKeyValue | undefined>;
|
|
180
|
-
status?: OtlpSpanStatus;
|
|
181
|
-
}): void;
|
|
182
|
-
enqueue(span: OtlpSpan): void;
|
|
183
|
-
flush(): Promise<void>;
|
|
184
|
-
shutdown(): Promise<void>;
|
|
185
|
-
}
|
|
186
5
|
|
|
187
6
|
type ParentSpanContext = {
|
|
188
7
|
traceIdB64: string;
|
|
@@ -214,98 +33,6 @@ declare function getContextManager(): ContextManager;
|
|
|
214
33
|
declare function currentSpan(): ContextSpan;
|
|
215
34
|
declare function withCurrent<R>(span: ContextSpan, callback: () => R): R;
|
|
216
35
|
|
|
217
|
-
declare class EventShipper extends EventShipper$1 {
|
|
218
|
-
constructor(opts: ConstructorParameters<typeof EventShipper$1>[0]);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
declare class TraceShipper extends TraceShipper$1 {
|
|
222
|
-
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Raindrop TelemetryIntegration for AI SDK v7+
|
|
227
|
-
*
|
|
228
|
-
* Implements the AI SDK's TelemetryIntegration interface to capture traces and
|
|
229
|
-
* events natively, replacing the Proxy-based wrapping used for v4-v6.
|
|
230
|
-
*
|
|
231
|
-
* Modeled after the upstream OpenTelemetryIntegration but uses Raindrop's
|
|
232
|
-
* TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
236
|
-
interface TelemetryIntegration {
|
|
237
|
-
onStart?: Listener<any>;
|
|
238
|
-
onStepStart?: Listener<any>;
|
|
239
|
-
onToolCallStart?: Listener<any>;
|
|
240
|
-
onToolCallFinish?: Listener<any>;
|
|
241
|
-
onChunk?: Listener<any>;
|
|
242
|
-
onStepFinish?: Listener<any>;
|
|
243
|
-
onEmbedStart?: Listener<any>;
|
|
244
|
-
onEmbedFinish?: Listener<any>;
|
|
245
|
-
onFinish?: Listener<any>;
|
|
246
|
-
onError?: Listener<any>;
|
|
247
|
-
executeTool?: <T>(params: {
|
|
248
|
-
callId: string;
|
|
249
|
-
toolCallId: string;
|
|
250
|
-
execute: () => PromiseLike<T>;
|
|
251
|
-
}) => PromiseLike<T>;
|
|
252
|
-
}
|
|
253
|
-
type RaindropTelemetryIntegrationOptions = {
|
|
254
|
-
traceShipper: TraceShipper;
|
|
255
|
-
eventShipper: EventShipper;
|
|
256
|
-
sendTraces?: boolean;
|
|
257
|
-
sendEvents?: boolean;
|
|
258
|
-
debug?: boolean;
|
|
259
|
-
context?: {
|
|
260
|
-
userId?: string;
|
|
261
|
-
eventId?: string;
|
|
262
|
-
eventName?: string;
|
|
263
|
-
convoId?: string;
|
|
264
|
-
properties?: Record<string, unknown>;
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
268
|
-
private readonly traceShipper;
|
|
269
|
-
private readonly eventShipper;
|
|
270
|
-
private readonly sendTraces;
|
|
271
|
-
private readonly sendEvents;
|
|
272
|
-
private readonly debug;
|
|
273
|
-
private readonly defaultContext;
|
|
274
|
-
private readonly callStates;
|
|
275
|
-
constructor(opts: RaindropTelemetryIntegrationOptions);
|
|
276
|
-
private getState;
|
|
277
|
-
private cleanup;
|
|
278
|
-
private spanParentRef;
|
|
279
|
-
private extractRaindropMetadata;
|
|
280
|
-
/**
|
|
281
|
-
* Extract the user-facing input text from an onStart event.
|
|
282
|
-
* Mirrors the logic in the v4-v6 Proxy path (lastUserMessageTextFromArgs / extractInputFromArgs).
|
|
283
|
-
*/
|
|
284
|
-
private extractInputText;
|
|
285
|
-
onStart: (event: any) => void;
|
|
286
|
-
onStepStart: (event: any) => void;
|
|
287
|
-
onToolCallStart: (event: any) => void;
|
|
288
|
-
onToolCallFinish: (event: any) => void;
|
|
289
|
-
onChunk: (event: any) => void;
|
|
290
|
-
onStepFinish: (event: any) => void;
|
|
291
|
-
onEmbedStart: (event: any) => void;
|
|
292
|
-
onEmbedFinish: (event: any) => void;
|
|
293
|
-
onFinish: (event: any) => void;
|
|
294
|
-
private finishGenerate;
|
|
295
|
-
private finishEmbed;
|
|
296
|
-
onError: (error: unknown) => void;
|
|
297
|
-
executeTool: <T>({ callId, toolCallId, execute, }: {
|
|
298
|
-
callId: string;
|
|
299
|
-
toolCallId: string;
|
|
300
|
-
execute: () => PromiseLike<T>;
|
|
301
|
-
}) => Promise<T>;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
type IdentifyInput = {
|
|
305
|
-
userId: string;
|
|
306
|
-
traits?: Record<string, unknown>;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
36
|
declare function _resetWarnedMissingUserId(): void;
|
|
310
37
|
|
|
311
38
|
/**
|
|
@@ -537,16 +264,6 @@ type WrapAISDKOptions = {
|
|
|
537
264
|
events?: boolean;
|
|
538
265
|
traces?: boolean;
|
|
539
266
|
};
|
|
540
|
-
/**
|
|
541
|
-
* Use the AI SDK's native TelemetryIntegration instead of Proxy-based wrapping.
|
|
542
|
-
* Requires AI SDK v7+. Throws on older versions.
|
|
543
|
-
*
|
|
544
|
-
* When enabled, `wrap()` registers a `RaindropTelemetryIntegration` globally
|
|
545
|
-
* and returns the original module instead of a Proxy.
|
|
546
|
-
*
|
|
547
|
-
* Default: false (uses Proxy wrapping for backward compatibility).
|
|
548
|
-
*/
|
|
549
|
-
nativeTelemetry?: boolean;
|
|
550
267
|
};
|
|
551
268
|
type EventPatch = {
|
|
552
269
|
eventName?: string;
|
|
@@ -562,11 +279,6 @@ type EventPatch = {
|
|
|
562
279
|
};
|
|
563
280
|
type RaindropAISDKClient = {
|
|
564
281
|
wrap<T extends object>(aiSDK: T, options?: WrapAISDKOptions): WrappedAISDK<T>;
|
|
565
|
-
/**
|
|
566
|
-
* Create a TelemetryIntegration instance for direct registration with AI SDK v7+.
|
|
567
|
-
* Use with `registerTelemetryIntegration()` from the `ai` package.
|
|
568
|
-
*/
|
|
569
|
-
createTelemetryIntegration(context?: RaindropTelemetryIntegrationOptions["context"]): RaindropTelemetryIntegration;
|
|
570
282
|
events: {
|
|
571
283
|
patch(eventId: string, patch: EventPatch): Promise<void>;
|
|
572
284
|
addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
|
|
@@ -598,4 +310,4 @@ type RaindropAISDKClient = {
|
|
|
598
310
|
};
|
|
599
311
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
600
312
|
|
|
601
|
-
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions,
|
|
313
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };
|
|
@@ -1,188 +1,7 @@
|
|
|
1
|
-
type
|
|
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 = {
|
|
1
|
+
type IdentifyInput = {
|
|
46
2
|
userId: string;
|
|
47
3
|
traits?: Record<string, unknown>;
|
|
48
4
|
};
|
|
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
|
-
constructor(opts: TraceShipperOptions);
|
|
151
|
-
isDebugEnabled(): boolean;
|
|
152
|
-
private authHeaders;
|
|
153
|
-
startSpan(args: {
|
|
154
|
-
name: string;
|
|
155
|
-
parent?: {
|
|
156
|
-
traceIdB64: string;
|
|
157
|
-
spanIdB64: string;
|
|
158
|
-
};
|
|
159
|
-
eventId: string;
|
|
160
|
-
operationId?: string;
|
|
161
|
-
attributes?: Array<OtlpKeyValue | undefined>;
|
|
162
|
-
startTimeUnixNano?: string;
|
|
163
|
-
}): InternalSpan;
|
|
164
|
-
endSpan(span: InternalSpan, extra?: {
|
|
165
|
-
attributes?: InternalSpan["attributes"];
|
|
166
|
-
error?: unknown;
|
|
167
|
-
status?: OtlpSpanStatus;
|
|
168
|
-
endTimeUnixNano?: string;
|
|
169
|
-
}): void;
|
|
170
|
-
createSpan(args: {
|
|
171
|
-
name: string;
|
|
172
|
-
parent?: {
|
|
173
|
-
traceIdB64: string;
|
|
174
|
-
spanIdB64: string;
|
|
175
|
-
};
|
|
176
|
-
eventId: string;
|
|
177
|
-
startTimeUnixNano: string;
|
|
178
|
-
endTimeUnixNano: string;
|
|
179
|
-
attributes?: Array<OtlpKeyValue | undefined>;
|
|
180
|
-
status?: OtlpSpanStatus;
|
|
181
|
-
}): void;
|
|
182
|
-
enqueue(span: OtlpSpan): void;
|
|
183
|
-
flush(): Promise<void>;
|
|
184
|
-
shutdown(): Promise<void>;
|
|
185
|
-
}
|
|
186
5
|
|
|
187
6
|
type ParentSpanContext = {
|
|
188
7
|
traceIdB64: string;
|
|
@@ -214,98 +33,6 @@ declare function getContextManager(): ContextManager;
|
|
|
214
33
|
declare function currentSpan(): ContextSpan;
|
|
215
34
|
declare function withCurrent<R>(span: ContextSpan, callback: () => R): R;
|
|
216
35
|
|
|
217
|
-
declare class EventShipper extends EventShipper$1 {
|
|
218
|
-
constructor(opts: ConstructorParameters<typeof EventShipper$1>[0]);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
declare class TraceShipper extends TraceShipper$1 {
|
|
222
|
-
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Raindrop TelemetryIntegration for AI SDK v7+
|
|
227
|
-
*
|
|
228
|
-
* Implements the AI SDK's TelemetryIntegration interface to capture traces and
|
|
229
|
-
* events natively, replacing the Proxy-based wrapping used for v4-v6.
|
|
230
|
-
*
|
|
231
|
-
* Modeled after the upstream OpenTelemetryIntegration but uses Raindrop's
|
|
232
|
-
* TraceShipper (OTLP/HTTP) + EventShipper instead of the OTel Tracer API.
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
236
|
-
interface TelemetryIntegration {
|
|
237
|
-
onStart?: Listener<any>;
|
|
238
|
-
onStepStart?: Listener<any>;
|
|
239
|
-
onToolCallStart?: Listener<any>;
|
|
240
|
-
onToolCallFinish?: Listener<any>;
|
|
241
|
-
onChunk?: Listener<any>;
|
|
242
|
-
onStepFinish?: Listener<any>;
|
|
243
|
-
onEmbedStart?: Listener<any>;
|
|
244
|
-
onEmbedFinish?: Listener<any>;
|
|
245
|
-
onFinish?: Listener<any>;
|
|
246
|
-
onError?: Listener<any>;
|
|
247
|
-
executeTool?: <T>(params: {
|
|
248
|
-
callId: string;
|
|
249
|
-
toolCallId: string;
|
|
250
|
-
execute: () => PromiseLike<T>;
|
|
251
|
-
}) => PromiseLike<T>;
|
|
252
|
-
}
|
|
253
|
-
type RaindropTelemetryIntegrationOptions = {
|
|
254
|
-
traceShipper: TraceShipper;
|
|
255
|
-
eventShipper: EventShipper;
|
|
256
|
-
sendTraces?: boolean;
|
|
257
|
-
sendEvents?: boolean;
|
|
258
|
-
debug?: boolean;
|
|
259
|
-
context?: {
|
|
260
|
-
userId?: string;
|
|
261
|
-
eventId?: string;
|
|
262
|
-
eventName?: string;
|
|
263
|
-
convoId?: string;
|
|
264
|
-
properties?: Record<string, unknown>;
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
268
|
-
private readonly traceShipper;
|
|
269
|
-
private readonly eventShipper;
|
|
270
|
-
private readonly sendTraces;
|
|
271
|
-
private readonly sendEvents;
|
|
272
|
-
private readonly debug;
|
|
273
|
-
private readonly defaultContext;
|
|
274
|
-
private readonly callStates;
|
|
275
|
-
constructor(opts: RaindropTelemetryIntegrationOptions);
|
|
276
|
-
private getState;
|
|
277
|
-
private cleanup;
|
|
278
|
-
private spanParentRef;
|
|
279
|
-
private extractRaindropMetadata;
|
|
280
|
-
/**
|
|
281
|
-
* Extract the user-facing input text from an onStart event.
|
|
282
|
-
* Mirrors the logic in the v4-v6 Proxy path (lastUserMessageTextFromArgs / extractInputFromArgs).
|
|
283
|
-
*/
|
|
284
|
-
private extractInputText;
|
|
285
|
-
onStart: (event: any) => void;
|
|
286
|
-
onStepStart: (event: any) => void;
|
|
287
|
-
onToolCallStart: (event: any) => void;
|
|
288
|
-
onToolCallFinish: (event: any) => void;
|
|
289
|
-
onChunk: (event: any) => void;
|
|
290
|
-
onStepFinish: (event: any) => void;
|
|
291
|
-
onEmbedStart: (event: any) => void;
|
|
292
|
-
onEmbedFinish: (event: any) => void;
|
|
293
|
-
onFinish: (event: any) => void;
|
|
294
|
-
private finishGenerate;
|
|
295
|
-
private finishEmbed;
|
|
296
|
-
onError: (error: unknown) => void;
|
|
297
|
-
executeTool: <T>({ callId, toolCallId, execute, }: {
|
|
298
|
-
callId: string;
|
|
299
|
-
toolCallId: string;
|
|
300
|
-
execute: () => PromiseLike<T>;
|
|
301
|
-
}) => Promise<T>;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
type IdentifyInput = {
|
|
305
|
-
userId: string;
|
|
306
|
-
traits?: Record<string, unknown>;
|
|
307
|
-
};
|
|
308
|
-
|
|
309
36
|
declare function _resetWarnedMissingUserId(): void;
|
|
310
37
|
|
|
311
38
|
/**
|
|
@@ -537,16 +264,6 @@ type WrapAISDKOptions = {
|
|
|
537
264
|
events?: boolean;
|
|
538
265
|
traces?: boolean;
|
|
539
266
|
};
|
|
540
|
-
/**
|
|
541
|
-
* Use the AI SDK's native TelemetryIntegration instead of Proxy-based wrapping.
|
|
542
|
-
* Requires AI SDK v7+. Throws on older versions.
|
|
543
|
-
*
|
|
544
|
-
* When enabled, `wrap()` registers a `RaindropTelemetryIntegration` globally
|
|
545
|
-
* and returns the original module instead of a Proxy.
|
|
546
|
-
*
|
|
547
|
-
* Default: false (uses Proxy wrapping for backward compatibility).
|
|
548
|
-
*/
|
|
549
|
-
nativeTelemetry?: boolean;
|
|
550
267
|
};
|
|
551
268
|
type EventPatch = {
|
|
552
269
|
eventName?: string;
|
|
@@ -562,11 +279,6 @@ type EventPatch = {
|
|
|
562
279
|
};
|
|
563
280
|
type RaindropAISDKClient = {
|
|
564
281
|
wrap<T extends object>(aiSDK: T, options?: WrapAISDKOptions): WrappedAISDK<T>;
|
|
565
|
-
/**
|
|
566
|
-
* Create a TelemetryIntegration instance for direct registration with AI SDK v7+.
|
|
567
|
-
* Use with `registerTelemetryIntegration()` from the `ai` package.
|
|
568
|
-
*/
|
|
569
|
-
createTelemetryIntegration(context?: RaindropTelemetryIntegrationOptions["context"]): RaindropTelemetryIntegration;
|
|
570
282
|
events: {
|
|
571
283
|
patch(eventId: string, patch: EventPatch): Promise<void>;
|
|
572
284
|
addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
|
|
@@ -598,4 +310,4 @@ type RaindropAISDKClient = {
|
|
|
598
310
|
};
|
|
599
311
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
600
312
|
|
|
601
|
-
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions,
|
|
313
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };
|