@raindrop-ai/ai-sdk 0.0.25 → 0.0.27
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 +30 -4
- package/dist/{chunk-AUFHKHNR.mjs → chunk-YP2VKVP7.mjs} +270 -98
- package/dist/{index-sxjvhkYW.d.mts → index-TERu6zvv.d.mts} +88 -12
- package/dist/{index-sxjvhkYW.d.ts → index-TERu6zvv.d.ts} +88 -12
- package/dist/index.browser.d.mts +88 -12
- package/dist/index.browser.d.ts +88 -12
- package/dist/index.browser.js +273 -97
- package/dist/index.browser.mjs +270 -98
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +273 -97
- 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 +273 -97
- package/dist/index.workers.mjs +1 -1
- package/package.json +1 -1
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -224,22 +229,16 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
224
229
|
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
225
230
|
}
|
|
226
231
|
|
|
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
232
|
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
238
233
|
interface TelemetryIntegration {
|
|
239
234
|
onStart?: Listener<any>;
|
|
240
235
|
onStepStart?: Listener<any>;
|
|
236
|
+
onToolExecutionStart?: Listener<any>;
|
|
237
|
+
onToolExecutionEnd?: Listener<any>;
|
|
241
238
|
onToolCallStart?: Listener<any>;
|
|
242
239
|
onToolCallFinish?: Listener<any>;
|
|
240
|
+
onLanguageModelCallStart?: Listener<any>;
|
|
241
|
+
onLanguageModelCallEnd?: Listener<any>;
|
|
243
242
|
onChunk?: Listener<any>;
|
|
244
243
|
onStepFinish?: Listener<any>;
|
|
245
244
|
onEmbedStart?: Listener<any>;
|
|
@@ -287,8 +286,14 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
287
286
|
private extractInputText;
|
|
288
287
|
onStart: (event: any) => void;
|
|
289
288
|
onStepStart: (event: any) => void;
|
|
289
|
+
private toolExecutionStart;
|
|
290
|
+
private toolExecutionEnd;
|
|
291
|
+
onToolExecutionStart: (event: any) => void;
|
|
292
|
+
onToolExecutionEnd: (event: any) => void;
|
|
290
293
|
onToolCallStart: (event: any) => void;
|
|
291
294
|
onToolCallFinish: (event: any) => void;
|
|
295
|
+
onLanguageModelCallStart: (_event: any) => void;
|
|
296
|
+
onLanguageModelCallEnd: (_event: any) => void;
|
|
292
297
|
onChunk: (event: any) => void;
|
|
293
298
|
onStepFinish: (event: any) => void;
|
|
294
299
|
onEmbedStart: (event: any) => void;
|
|
@@ -309,6 +314,65 @@ type IdentifyInput = {
|
|
|
309
314
|
traits?: Record<string, unknown>;
|
|
310
315
|
};
|
|
311
316
|
|
|
317
|
+
type RaindropCallMetadata = {
|
|
318
|
+
userId?: string;
|
|
319
|
+
eventId?: string;
|
|
320
|
+
/** True when the eventId was auto-generated by `eventMetadata()` rather than user-provided. */
|
|
321
|
+
eventIdGenerated?: boolean;
|
|
322
|
+
convoId?: string;
|
|
323
|
+
eventName?: string;
|
|
324
|
+
properties?: Record<string, unknown>;
|
|
325
|
+
/**
|
|
326
|
+
* Raw `metadata` record, preserved so the integration can write the
|
|
327
|
+
* full set of `raindrop.*` keys onto root spans (the trace shipper
|
|
328
|
+
* relies on this to surface metadata in the dashboard span attributes).
|
|
329
|
+
*/
|
|
330
|
+
rawMetadata?: Record<string, unknown>;
|
|
331
|
+
};
|
|
332
|
+
declare global {
|
|
333
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
|
334
|
+
getStore(): T | undefined;
|
|
335
|
+
run<R>(store: T, callback: () => R): R;
|
|
336
|
+
enterWith?(store: T): void;
|
|
337
|
+
}) | undefined;
|
|
338
|
+
}
|
|
339
|
+
/** Test helper — allow tests to drop a stale fallback storage between runs. */
|
|
340
|
+
declare function _resetRaindropCallMetadataStorage(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Returns the active per-call Raindrop metadata, or `undefined` if no
|
|
343
|
+
* call is currently in scope. Safe to call from any telemetry callback.
|
|
344
|
+
*/
|
|
345
|
+
declare function getCurrentRaindropCallMetadata(): RaindropCallMetadata | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Runs `fn` with `metadata` bound as the active per-call Raindrop metadata.
|
|
348
|
+
* Visible to nested async work via `AsyncLocalStorage` when available.
|
|
349
|
+
*/
|
|
350
|
+
declare function runWithRaindropCallMetadata<R>(metadata: RaindropCallMetadata, fn: () => R): R;
|
|
351
|
+
/**
|
|
352
|
+
* Inspect the first argument to an AI SDK function call (the call
|
|
353
|
+
* options object) and pull out any Raindrop metadata routed via one of:
|
|
354
|
+
*
|
|
355
|
+
* 1. top-level `metadata` — convention inherited from the v4-v6 Proxy
|
|
356
|
+
* path (`extractRaindropCallOptions` in `wrap/wrapAISDK.ts`). Some
|
|
357
|
+
* callers route `eventMetadata()` here to bypass framework-specific
|
|
358
|
+
* `experimental_telemetry` typings;
|
|
359
|
+
* 2. `telemetry.metadata` — the v7 beta.111+ stable name (anticipated;
|
|
360
|
+
* the v7 dispatcher does not currently forward `metadata`, but the
|
|
361
|
+
* shape is what users will pass once it lands);
|
|
362
|
+
* 3. `experimental_telemetry.metadata` — the documented and currently
|
|
363
|
+
* working channel for v6 + every published v7 beta.
|
|
364
|
+
*
|
|
365
|
+
* Priority is `(1) > (2) > (3)` to stay consistent with the v4-v6 path's
|
|
366
|
+
* `extractRaindropCallOptions`. If you ever change this order, the
|
|
367
|
+
* self-diagnostics injection in `wrapAISDK.ts` (which mutates the v3
|
|
368
|
+
* source only) becomes a re-read hazard — see the comment by
|
|
369
|
+
* `mergedAlsMetadata` in that file.
|
|
370
|
+
*
|
|
371
|
+
* Returns `undefined` when there is no Raindrop metadata to propagate,
|
|
372
|
+
* so callers can skip the ALS push entirely.
|
|
373
|
+
*/
|
|
374
|
+
declare function readRaindropCallMetadataFromArgs(args: readonly unknown[]): RaindropCallMetadata | undefined;
|
|
375
|
+
|
|
312
376
|
declare function _resetWarnedMissingUserId(): void;
|
|
313
377
|
|
|
314
378
|
/**
|
|
@@ -445,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
445
509
|
*/
|
|
446
510
|
writeKey?: string;
|
|
447
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
448
524
|
traces?: {
|
|
449
525
|
enabled?: boolean;
|
|
450
526
|
flushIntervalMs?: number;
|
|
@@ -688,4 +764,4 @@ type RaindropAISDKClient = {
|
|
|
688
764
|
};
|
|
689
765
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
690
766
|
|
|
691
|
-
export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EndSpanArgs as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, type WrapAISDKOptions as W,
|
|
767
|
+
export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, readRaindropCallMetadataFromArgs as D, type EndSpanArgs as E, runWithRaindropCallMetadata as F, withCurrent as G, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, type WrapAISDKOptions as W, _resetRaindropCallMetadataStorage 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 CreateSpanArgs as g, type EventBuilder as h, type EventMetadataOptions as i, type RaindropAISDKContext as j, type RaindropAISDKOptions as k, type RaindropCallMetadata as l, RaindropTelemetryIntegration as m, type RaindropTelemetryIntegrationOptions as n, type SelfDiagnosticsSignalDefinition as o, type SelfDiagnosticsSignalDefinitions as p, type StartSpanArgs as q, type WrappedAI as r, type WrappedAISDK as s, _resetWarnedMissingUserId as t, createRaindropAISDK as u, currentSpan as v, eventMetadata as w, eventMetadataFromChatRequest as x, getContextManager as y, getCurrentRaindropCallMetadata as z };
|
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -224,22 +229,16 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
224
229
|
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
225
230
|
}
|
|
226
231
|
|
|
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
232
|
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
238
233
|
interface TelemetryIntegration {
|
|
239
234
|
onStart?: Listener<any>;
|
|
240
235
|
onStepStart?: Listener<any>;
|
|
236
|
+
onToolExecutionStart?: Listener<any>;
|
|
237
|
+
onToolExecutionEnd?: Listener<any>;
|
|
241
238
|
onToolCallStart?: Listener<any>;
|
|
242
239
|
onToolCallFinish?: Listener<any>;
|
|
240
|
+
onLanguageModelCallStart?: Listener<any>;
|
|
241
|
+
onLanguageModelCallEnd?: Listener<any>;
|
|
243
242
|
onChunk?: Listener<any>;
|
|
244
243
|
onStepFinish?: Listener<any>;
|
|
245
244
|
onEmbedStart?: Listener<any>;
|
|
@@ -287,8 +286,14 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
287
286
|
private extractInputText;
|
|
288
287
|
onStart: (event: any) => void;
|
|
289
288
|
onStepStart: (event: any) => void;
|
|
289
|
+
private toolExecutionStart;
|
|
290
|
+
private toolExecutionEnd;
|
|
291
|
+
onToolExecutionStart: (event: any) => void;
|
|
292
|
+
onToolExecutionEnd: (event: any) => void;
|
|
290
293
|
onToolCallStart: (event: any) => void;
|
|
291
294
|
onToolCallFinish: (event: any) => void;
|
|
295
|
+
onLanguageModelCallStart: (_event: any) => void;
|
|
296
|
+
onLanguageModelCallEnd: (_event: any) => void;
|
|
292
297
|
onChunk: (event: any) => void;
|
|
293
298
|
onStepFinish: (event: any) => void;
|
|
294
299
|
onEmbedStart: (event: any) => void;
|
|
@@ -309,6 +314,65 @@ type IdentifyInput = {
|
|
|
309
314
|
traits?: Record<string, unknown>;
|
|
310
315
|
};
|
|
311
316
|
|
|
317
|
+
type RaindropCallMetadata = {
|
|
318
|
+
userId?: string;
|
|
319
|
+
eventId?: string;
|
|
320
|
+
/** True when the eventId was auto-generated by `eventMetadata()` rather than user-provided. */
|
|
321
|
+
eventIdGenerated?: boolean;
|
|
322
|
+
convoId?: string;
|
|
323
|
+
eventName?: string;
|
|
324
|
+
properties?: Record<string, unknown>;
|
|
325
|
+
/**
|
|
326
|
+
* Raw `metadata` record, preserved so the integration can write the
|
|
327
|
+
* full set of `raindrop.*` keys onto root spans (the trace shipper
|
|
328
|
+
* relies on this to surface metadata in the dashboard span attributes).
|
|
329
|
+
*/
|
|
330
|
+
rawMetadata?: Record<string, unknown>;
|
|
331
|
+
};
|
|
332
|
+
declare global {
|
|
333
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
|
334
|
+
getStore(): T | undefined;
|
|
335
|
+
run<R>(store: T, callback: () => R): R;
|
|
336
|
+
enterWith?(store: T): void;
|
|
337
|
+
}) | undefined;
|
|
338
|
+
}
|
|
339
|
+
/** Test helper — allow tests to drop a stale fallback storage between runs. */
|
|
340
|
+
declare function _resetRaindropCallMetadataStorage(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Returns the active per-call Raindrop metadata, or `undefined` if no
|
|
343
|
+
* call is currently in scope. Safe to call from any telemetry callback.
|
|
344
|
+
*/
|
|
345
|
+
declare function getCurrentRaindropCallMetadata(): RaindropCallMetadata | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Runs `fn` with `metadata` bound as the active per-call Raindrop metadata.
|
|
348
|
+
* Visible to nested async work via `AsyncLocalStorage` when available.
|
|
349
|
+
*/
|
|
350
|
+
declare function runWithRaindropCallMetadata<R>(metadata: RaindropCallMetadata, fn: () => R): R;
|
|
351
|
+
/**
|
|
352
|
+
* Inspect the first argument to an AI SDK function call (the call
|
|
353
|
+
* options object) and pull out any Raindrop metadata routed via one of:
|
|
354
|
+
*
|
|
355
|
+
* 1. top-level `metadata` — convention inherited from the v4-v6 Proxy
|
|
356
|
+
* path (`extractRaindropCallOptions` in `wrap/wrapAISDK.ts`). Some
|
|
357
|
+
* callers route `eventMetadata()` here to bypass framework-specific
|
|
358
|
+
* `experimental_telemetry` typings;
|
|
359
|
+
* 2. `telemetry.metadata` — the v7 beta.111+ stable name (anticipated;
|
|
360
|
+
* the v7 dispatcher does not currently forward `metadata`, but the
|
|
361
|
+
* shape is what users will pass once it lands);
|
|
362
|
+
* 3. `experimental_telemetry.metadata` — the documented and currently
|
|
363
|
+
* working channel for v6 + every published v7 beta.
|
|
364
|
+
*
|
|
365
|
+
* Priority is `(1) > (2) > (3)` to stay consistent with the v4-v6 path's
|
|
366
|
+
* `extractRaindropCallOptions`. If you ever change this order, the
|
|
367
|
+
* self-diagnostics injection in `wrapAISDK.ts` (which mutates the v3
|
|
368
|
+
* source only) becomes a re-read hazard — see the comment by
|
|
369
|
+
* `mergedAlsMetadata` in that file.
|
|
370
|
+
*
|
|
371
|
+
* Returns `undefined` when there is no Raindrop metadata to propagate,
|
|
372
|
+
* so callers can skip the ALS push entirely.
|
|
373
|
+
*/
|
|
374
|
+
declare function readRaindropCallMetadataFromArgs(args: readonly unknown[]): RaindropCallMetadata | undefined;
|
|
375
|
+
|
|
312
376
|
declare function _resetWarnedMissingUserId(): void;
|
|
313
377
|
|
|
314
378
|
/**
|
|
@@ -445,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
445
509
|
*/
|
|
446
510
|
writeKey?: string;
|
|
447
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
448
524
|
traces?: {
|
|
449
525
|
enabled?: boolean;
|
|
450
526
|
flushIntervalMs?: number;
|
|
@@ -688,4 +764,4 @@ type RaindropAISDKClient = {
|
|
|
688
764
|
};
|
|
689
765
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
690
766
|
|
|
691
|
-
export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, type EndSpanArgs as E, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, type WrapAISDKOptions as W,
|
|
767
|
+
export { type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, readRaindropCallMetadataFromArgs as D, type EndSpanArgs as E, runWithRaindropCallMetadata as F, withCurrent as G, type IdentifyInput as I, type RaindropAISDKClient as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, type WrapAISDKOptions as W, _resetRaindropCallMetadataStorage 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 CreateSpanArgs as g, type EventBuilder as h, type EventMetadataOptions as i, type RaindropAISDKContext as j, type RaindropAISDKOptions as k, type RaindropCallMetadata as l, RaindropTelemetryIntegration as m, type RaindropTelemetryIntegrationOptions as n, type SelfDiagnosticsSignalDefinition as o, type SelfDiagnosticsSignalDefinitions as p, type StartSpanArgs as q, type WrappedAI as r, type WrappedAISDK as s, _resetWarnedMissingUserId as t, createRaindropAISDK as u, currentSpan as v, eventMetadata as w, eventMetadataFromChatRequest as x, getContextManager as y, getCurrentRaindropCallMetadata as z };
|
package/dist/index.browser.d.mts
CHANGED
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -224,22 +229,16 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
224
229
|
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
225
230
|
}
|
|
226
231
|
|
|
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
232
|
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
238
233
|
interface TelemetryIntegration {
|
|
239
234
|
onStart?: Listener<any>;
|
|
240
235
|
onStepStart?: Listener<any>;
|
|
236
|
+
onToolExecutionStart?: Listener<any>;
|
|
237
|
+
onToolExecutionEnd?: Listener<any>;
|
|
241
238
|
onToolCallStart?: Listener<any>;
|
|
242
239
|
onToolCallFinish?: Listener<any>;
|
|
240
|
+
onLanguageModelCallStart?: Listener<any>;
|
|
241
|
+
onLanguageModelCallEnd?: Listener<any>;
|
|
243
242
|
onChunk?: Listener<any>;
|
|
244
243
|
onStepFinish?: Listener<any>;
|
|
245
244
|
onEmbedStart?: Listener<any>;
|
|
@@ -287,8 +286,14 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
287
286
|
private extractInputText;
|
|
288
287
|
onStart: (event: any) => void;
|
|
289
288
|
onStepStart: (event: any) => void;
|
|
289
|
+
private toolExecutionStart;
|
|
290
|
+
private toolExecutionEnd;
|
|
291
|
+
onToolExecutionStart: (event: any) => void;
|
|
292
|
+
onToolExecutionEnd: (event: any) => void;
|
|
290
293
|
onToolCallStart: (event: any) => void;
|
|
291
294
|
onToolCallFinish: (event: any) => void;
|
|
295
|
+
onLanguageModelCallStart: (_event: any) => void;
|
|
296
|
+
onLanguageModelCallEnd: (_event: any) => void;
|
|
292
297
|
onChunk: (event: any) => void;
|
|
293
298
|
onStepFinish: (event: any) => void;
|
|
294
299
|
onEmbedStart: (event: any) => void;
|
|
@@ -309,6 +314,65 @@ type IdentifyInput = {
|
|
|
309
314
|
traits?: Record<string, unknown>;
|
|
310
315
|
};
|
|
311
316
|
|
|
317
|
+
type RaindropCallMetadata = {
|
|
318
|
+
userId?: string;
|
|
319
|
+
eventId?: string;
|
|
320
|
+
/** True when the eventId was auto-generated by `eventMetadata()` rather than user-provided. */
|
|
321
|
+
eventIdGenerated?: boolean;
|
|
322
|
+
convoId?: string;
|
|
323
|
+
eventName?: string;
|
|
324
|
+
properties?: Record<string, unknown>;
|
|
325
|
+
/**
|
|
326
|
+
* Raw `metadata` record, preserved so the integration can write the
|
|
327
|
+
* full set of `raindrop.*` keys onto root spans (the trace shipper
|
|
328
|
+
* relies on this to surface metadata in the dashboard span attributes).
|
|
329
|
+
*/
|
|
330
|
+
rawMetadata?: Record<string, unknown>;
|
|
331
|
+
};
|
|
332
|
+
declare global {
|
|
333
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
|
334
|
+
getStore(): T | undefined;
|
|
335
|
+
run<R>(store: T, callback: () => R): R;
|
|
336
|
+
enterWith?(store: T): void;
|
|
337
|
+
}) | undefined;
|
|
338
|
+
}
|
|
339
|
+
/** Test helper — allow tests to drop a stale fallback storage between runs. */
|
|
340
|
+
declare function _resetRaindropCallMetadataStorage(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Returns the active per-call Raindrop metadata, or `undefined` if no
|
|
343
|
+
* call is currently in scope. Safe to call from any telemetry callback.
|
|
344
|
+
*/
|
|
345
|
+
declare function getCurrentRaindropCallMetadata(): RaindropCallMetadata | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Runs `fn` with `metadata` bound as the active per-call Raindrop metadata.
|
|
348
|
+
* Visible to nested async work via `AsyncLocalStorage` when available.
|
|
349
|
+
*/
|
|
350
|
+
declare function runWithRaindropCallMetadata<R>(metadata: RaindropCallMetadata, fn: () => R): R;
|
|
351
|
+
/**
|
|
352
|
+
* Inspect the first argument to an AI SDK function call (the call
|
|
353
|
+
* options object) and pull out any Raindrop metadata routed via one of:
|
|
354
|
+
*
|
|
355
|
+
* 1. top-level `metadata` — convention inherited from the v4-v6 Proxy
|
|
356
|
+
* path (`extractRaindropCallOptions` in `wrap/wrapAISDK.ts`). Some
|
|
357
|
+
* callers route `eventMetadata()` here to bypass framework-specific
|
|
358
|
+
* `experimental_telemetry` typings;
|
|
359
|
+
* 2. `telemetry.metadata` — the v7 beta.111+ stable name (anticipated;
|
|
360
|
+
* the v7 dispatcher does not currently forward `metadata`, but the
|
|
361
|
+
* shape is what users will pass once it lands);
|
|
362
|
+
* 3. `experimental_telemetry.metadata` — the documented and currently
|
|
363
|
+
* working channel for v6 + every published v7 beta.
|
|
364
|
+
*
|
|
365
|
+
* Priority is `(1) > (2) > (3)` to stay consistent with the v4-v6 path's
|
|
366
|
+
* `extractRaindropCallOptions`. If you ever change this order, the
|
|
367
|
+
* self-diagnostics injection in `wrapAISDK.ts` (which mutates the v3
|
|
368
|
+
* source only) becomes a re-read hazard — see the comment by
|
|
369
|
+
* `mergedAlsMetadata` in that file.
|
|
370
|
+
*
|
|
371
|
+
* Returns `undefined` when there is no Raindrop metadata to propagate,
|
|
372
|
+
* so callers can skip the ALS push entirely.
|
|
373
|
+
*/
|
|
374
|
+
declare function readRaindropCallMetadataFromArgs(args: readonly unknown[]): RaindropCallMetadata | undefined;
|
|
375
|
+
|
|
312
376
|
declare function _resetWarnedMissingUserId(): void;
|
|
313
377
|
|
|
314
378
|
/**
|
|
@@ -445,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
445
509
|
*/
|
|
446
510
|
writeKey?: string;
|
|
447
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
448
524
|
traces?: {
|
|
449
525
|
enabled?: boolean;
|
|
450
526
|
flushIntervalMs?: number;
|
|
@@ -688,4 +764,4 @@ type RaindropAISDKClient = {
|
|
|
688
764
|
};
|
|
689
765
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
690
766
|
|
|
691
|
-
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type StartSpanArgs, type TraceSpan, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };
|
|
767
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type RaindropCallMetadata, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type StartSpanArgs, type TraceSpan, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent };
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -130,6 +130,11 @@ type TraceShipperOptions = {
|
|
|
130
130
|
sdkName?: string;
|
|
131
131
|
serviceName?: string;
|
|
132
132
|
serviceVersion?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
|
|
135
|
+
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
136
|
+
*/
|
|
137
|
+
localDebuggerUrl?: string | null;
|
|
133
138
|
};
|
|
134
139
|
declare class TraceShipper$1 {
|
|
135
140
|
private baseUrl;
|
|
@@ -147,7 +152,7 @@ declare class TraceShipper$1 {
|
|
|
147
152
|
private queue;
|
|
148
153
|
private timer;
|
|
149
154
|
private inFlight;
|
|
150
|
-
/** URL of the local debugger
|
|
155
|
+
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
151
156
|
private localDebuggerUrl;
|
|
152
157
|
constructor(opts: TraceShipperOptions);
|
|
153
158
|
isDebugEnabled(): boolean;
|
|
@@ -224,22 +229,16 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
224
229
|
constructor(opts: ConstructorParameters<typeof TraceShipper$1>[0]);
|
|
225
230
|
}
|
|
226
231
|
|
|
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
232
|
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
238
233
|
interface TelemetryIntegration {
|
|
239
234
|
onStart?: Listener<any>;
|
|
240
235
|
onStepStart?: Listener<any>;
|
|
236
|
+
onToolExecutionStart?: Listener<any>;
|
|
237
|
+
onToolExecutionEnd?: Listener<any>;
|
|
241
238
|
onToolCallStart?: Listener<any>;
|
|
242
239
|
onToolCallFinish?: Listener<any>;
|
|
240
|
+
onLanguageModelCallStart?: Listener<any>;
|
|
241
|
+
onLanguageModelCallEnd?: Listener<any>;
|
|
243
242
|
onChunk?: Listener<any>;
|
|
244
243
|
onStepFinish?: Listener<any>;
|
|
245
244
|
onEmbedStart?: Listener<any>;
|
|
@@ -287,8 +286,14 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
287
286
|
private extractInputText;
|
|
288
287
|
onStart: (event: any) => void;
|
|
289
288
|
onStepStart: (event: any) => void;
|
|
289
|
+
private toolExecutionStart;
|
|
290
|
+
private toolExecutionEnd;
|
|
291
|
+
onToolExecutionStart: (event: any) => void;
|
|
292
|
+
onToolExecutionEnd: (event: any) => void;
|
|
290
293
|
onToolCallStart: (event: any) => void;
|
|
291
294
|
onToolCallFinish: (event: any) => void;
|
|
295
|
+
onLanguageModelCallStart: (_event: any) => void;
|
|
296
|
+
onLanguageModelCallEnd: (_event: any) => void;
|
|
292
297
|
onChunk: (event: any) => void;
|
|
293
298
|
onStepFinish: (event: any) => void;
|
|
294
299
|
onEmbedStart: (event: any) => void;
|
|
@@ -309,6 +314,65 @@ type IdentifyInput = {
|
|
|
309
314
|
traits?: Record<string, unknown>;
|
|
310
315
|
};
|
|
311
316
|
|
|
317
|
+
type RaindropCallMetadata = {
|
|
318
|
+
userId?: string;
|
|
319
|
+
eventId?: string;
|
|
320
|
+
/** True when the eventId was auto-generated by `eventMetadata()` rather than user-provided. */
|
|
321
|
+
eventIdGenerated?: boolean;
|
|
322
|
+
convoId?: string;
|
|
323
|
+
eventName?: string;
|
|
324
|
+
properties?: Record<string, unknown>;
|
|
325
|
+
/**
|
|
326
|
+
* Raw `metadata` record, preserved so the integration can write the
|
|
327
|
+
* full set of `raindrop.*` keys onto root spans (the trace shipper
|
|
328
|
+
* relies on this to surface metadata in the dashboard span attributes).
|
|
329
|
+
*/
|
|
330
|
+
rawMetadata?: Record<string, unknown>;
|
|
331
|
+
};
|
|
332
|
+
declare global {
|
|
333
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => {
|
|
334
|
+
getStore(): T | undefined;
|
|
335
|
+
run<R>(store: T, callback: () => R): R;
|
|
336
|
+
enterWith?(store: T): void;
|
|
337
|
+
}) | undefined;
|
|
338
|
+
}
|
|
339
|
+
/** Test helper — allow tests to drop a stale fallback storage between runs. */
|
|
340
|
+
declare function _resetRaindropCallMetadataStorage(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Returns the active per-call Raindrop metadata, or `undefined` if no
|
|
343
|
+
* call is currently in scope. Safe to call from any telemetry callback.
|
|
344
|
+
*/
|
|
345
|
+
declare function getCurrentRaindropCallMetadata(): RaindropCallMetadata | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Runs `fn` with `metadata` bound as the active per-call Raindrop metadata.
|
|
348
|
+
* Visible to nested async work via `AsyncLocalStorage` when available.
|
|
349
|
+
*/
|
|
350
|
+
declare function runWithRaindropCallMetadata<R>(metadata: RaindropCallMetadata, fn: () => R): R;
|
|
351
|
+
/**
|
|
352
|
+
* Inspect the first argument to an AI SDK function call (the call
|
|
353
|
+
* options object) and pull out any Raindrop metadata routed via one of:
|
|
354
|
+
*
|
|
355
|
+
* 1. top-level `metadata` — convention inherited from the v4-v6 Proxy
|
|
356
|
+
* path (`extractRaindropCallOptions` in `wrap/wrapAISDK.ts`). Some
|
|
357
|
+
* callers route `eventMetadata()` here to bypass framework-specific
|
|
358
|
+
* `experimental_telemetry` typings;
|
|
359
|
+
* 2. `telemetry.metadata` — the v7 beta.111+ stable name (anticipated;
|
|
360
|
+
* the v7 dispatcher does not currently forward `metadata`, but the
|
|
361
|
+
* shape is what users will pass once it lands);
|
|
362
|
+
* 3. `experimental_telemetry.metadata` — the documented and currently
|
|
363
|
+
* working channel for v6 + every published v7 beta.
|
|
364
|
+
*
|
|
365
|
+
* Priority is `(1) > (2) > (3)` to stay consistent with the v4-v6 path's
|
|
366
|
+
* `extractRaindropCallOptions`. If you ever change this order, the
|
|
367
|
+
* self-diagnostics injection in `wrapAISDK.ts` (which mutates the v3
|
|
368
|
+
* source only) becomes a re-read hazard — see the comment by
|
|
369
|
+
* `mergedAlsMetadata` in that file.
|
|
370
|
+
*
|
|
371
|
+
* Returns `undefined` when there is no Raindrop metadata to propagate,
|
|
372
|
+
* so callers can skip the ALS push entirely.
|
|
373
|
+
*/
|
|
374
|
+
declare function readRaindropCallMetadataFromArgs(args: readonly unknown[]): RaindropCallMetadata | undefined;
|
|
375
|
+
|
|
312
376
|
declare function _resetWarnedMissingUserId(): void;
|
|
313
377
|
|
|
314
378
|
/**
|
|
@@ -445,6 +509,18 @@ type RaindropAISDKOptions = {
|
|
|
445
509
|
*/
|
|
446
510
|
writeKey?: string;
|
|
447
511
|
endpoint?: string;
|
|
512
|
+
/**
|
|
513
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
514
|
+
*
|
|
515
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
516
|
+
* wins over env vars and runtime auto-detect.
|
|
517
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
518
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
519
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
520
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
521
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
522
|
+
*/
|
|
523
|
+
localWorkshopUrl?: string | false | null;
|
|
448
524
|
traces?: {
|
|
449
525
|
enabled?: boolean;
|
|
450
526
|
flushIntervalMs?: number;
|
|
@@ -688,4 +764,4 @@ type RaindropAISDKClient = {
|
|
|
688
764
|
};
|
|
689
765
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
690
766
|
|
|
691
|
-
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type StartSpanArgs, type TraceSpan, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, withCurrent };
|
|
767
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type RaindropCallMetadata, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type StartSpanArgs, type TraceSpan, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, createRaindropAISDK, currentSpan, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, runWithRaindropCallMetadata, withCurrent };
|