@raindrop-ai/ai-sdk 0.0.31 → 0.0.33
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 +81 -3
- package/dist/{chunk-7VSCLQIX.mjs → chunk-FIX66Y7M.mjs} +382 -199
- package/dist/{index-IMe7ZUXV.d.mts → index-Dcf4FPZL.d.mts} +127 -3
- package/dist/{index-IMe7ZUXV.d.ts → index-Dcf4FPZL.d.ts} +127 -3
- package/dist/index.browser.d.mts +127 -3
- package/dist/index.browser.d.ts +127 -3
- package/dist/index.browser.js +395 -211
- package/dist/index.browser.mjs +395 -212
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +395 -211
- 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 +395 -211
- package/dist/index.workers.mjs +1 -1
- package/package.json +2 -2
package/dist/index.browser.d.ts
CHANGED
|
@@ -365,6 +365,29 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
type Listener<T> = (event: T) => PromiseLike<void> | void;
|
|
368
|
+
type ToolExecutionEndEvent = {
|
|
369
|
+
callId: string;
|
|
370
|
+
toolCall: {
|
|
371
|
+
toolCallId: string;
|
|
372
|
+
toolName: string;
|
|
373
|
+
};
|
|
374
|
+
toolOutput: {
|
|
375
|
+
type: "tool-result";
|
|
376
|
+
output: unknown;
|
|
377
|
+
} | {
|
|
378
|
+
type: "tool-error";
|
|
379
|
+
error: unknown;
|
|
380
|
+
};
|
|
381
|
+
} | {
|
|
382
|
+
callId: string;
|
|
383
|
+
toolCall: {
|
|
384
|
+
toolCallId: string;
|
|
385
|
+
toolName: string;
|
|
386
|
+
};
|
|
387
|
+
success: boolean;
|
|
388
|
+
output?: unknown;
|
|
389
|
+
error?: unknown;
|
|
390
|
+
};
|
|
368
391
|
interface TelemetryIntegration {
|
|
369
392
|
onStart?: Listener<any>;
|
|
370
393
|
onStepStart?: Listener<any>;
|
|
@@ -381,6 +404,7 @@ interface TelemetryIntegration {
|
|
|
381
404
|
onEmbedEnd?: Listener<any>;
|
|
382
405
|
onFinish?: Listener<any>;
|
|
383
406
|
onEnd?: Listener<any>;
|
|
407
|
+
onAbort?: Listener<any>;
|
|
384
408
|
onError?: Listener<any>;
|
|
385
409
|
executeTool?: <T>(params: {
|
|
386
410
|
callId: string;
|
|
@@ -441,6 +465,10 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
441
465
|
*/
|
|
442
466
|
private readonly priorParentContexts;
|
|
443
467
|
constructor(opts: RaindropTelemetryIntegrationOptions);
|
|
468
|
+
/** Flush any buffered events and trace spans to their destinations. */
|
|
469
|
+
flush: () => Promise<void>;
|
|
470
|
+
/** Flush and stop the background flush timers. */
|
|
471
|
+
shutdown: () => Promise<void>;
|
|
444
472
|
private getState;
|
|
445
473
|
private cleanup;
|
|
446
474
|
private spanParentRef;
|
|
@@ -456,12 +484,13 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
456
484
|
private toolExecutionStart;
|
|
457
485
|
private toolExecutionEnd;
|
|
458
486
|
onToolExecutionStart: (event: any) => void;
|
|
459
|
-
onToolExecutionEnd: (event:
|
|
487
|
+
onToolExecutionEnd: (event: ToolExecutionEndEvent) => void;
|
|
460
488
|
onToolCallStart: (event: any) => void;
|
|
461
|
-
onToolCallFinish: (event:
|
|
489
|
+
onToolCallFinish: (event: ToolExecutionEndEvent) => void;
|
|
462
490
|
onLanguageModelCallStart: (_event: any) => void;
|
|
463
491
|
onLanguageModelCallEnd: (_event: any) => void;
|
|
464
492
|
onChunk: (event: any) => void;
|
|
493
|
+
private emitProviderExecutedToolSpans;
|
|
465
494
|
onStepFinish: (event: any) => void;
|
|
466
495
|
onEmbedStart: (event: any) => void;
|
|
467
496
|
onEmbedFinish: (event: any) => void;
|
|
@@ -469,8 +498,15 @@ declare class RaindropTelemetryIntegration implements TelemetryIntegration {
|
|
|
469
498
|
onFinish: (event: any) => void;
|
|
470
499
|
onEnd: (event: any) => void;
|
|
471
500
|
private finishGenerate;
|
|
501
|
+
/**
|
|
502
|
+
* Patch the Raindrop event for a completed, aborted, or errored text
|
|
503
|
+
* generation so it leaves the `isPending` state. Shared by `onFinish`/`onEnd`,
|
|
504
|
+
* `onAbort`, and `onError`.
|
|
505
|
+
*/
|
|
506
|
+
private finalizeGenerateEvent;
|
|
472
507
|
private finishEmbed;
|
|
473
508
|
onError: (error: unknown) => void;
|
|
509
|
+
onAbort: (event: any) => void;
|
|
474
510
|
executeTool: <T>({ callId, toolCallId, execute, }: {
|
|
475
511
|
callId: string;
|
|
476
512
|
toolCallId: string;
|
|
@@ -893,6 +929,38 @@ type SelfDiagnosticsOptions = {
|
|
|
893
929
|
*/
|
|
894
930
|
toolName?: string;
|
|
895
931
|
};
|
|
932
|
+
type SelfDiagnosticsToolOptions = Omit<SelfDiagnosticsOptions, "enabled"> & {
|
|
933
|
+
/** Fixed Raindrop event ID to attach diagnostic signals to. */
|
|
934
|
+
eventId?: string;
|
|
935
|
+
/** Dynamic event ID resolver, useful when one tool instance serves many runs. */
|
|
936
|
+
getEventId?: () => string | undefined;
|
|
937
|
+
/** Behavior when no event ID can be resolved. Default: "warn" */
|
|
938
|
+
onMissingEventId?: "warn" | "ignore" | "throw";
|
|
939
|
+
};
|
|
940
|
+
type SelfDiagnosticsToolInput = {
|
|
941
|
+
category: string;
|
|
942
|
+
detail: string;
|
|
943
|
+
};
|
|
944
|
+
type SelfDiagnosticsToolResult = {
|
|
945
|
+
acknowledged: true;
|
|
946
|
+
category: string;
|
|
947
|
+
} | {
|
|
948
|
+
acknowledged: false;
|
|
949
|
+
category: string;
|
|
950
|
+
reason: "missing_event_id";
|
|
951
|
+
};
|
|
952
|
+
type SelfDiagnosticsTool = {
|
|
953
|
+
name: string;
|
|
954
|
+
description: string;
|
|
955
|
+
/**
|
|
956
|
+
* AI SDK v4 tool schema. This is the same cross-version schema object as
|
|
957
|
+
* `inputSchema`; both fields are exposed so the tool works on AI SDK v4-v7.
|
|
958
|
+
*/
|
|
959
|
+
parameters: any;
|
|
960
|
+
/** AI SDK v5+ tool schema. */
|
|
961
|
+
inputSchema: any;
|
|
962
|
+
execute(input: SelfDiagnosticsToolInput): Promise<SelfDiagnosticsToolResult>;
|
|
963
|
+
};
|
|
896
964
|
type WrapAISDKOptions = {
|
|
897
965
|
context: RaindropAISDKContext | ((info: {
|
|
898
966
|
operation: string;
|
|
@@ -977,6 +1045,14 @@ type EventPatch = {
|
|
|
977
1045
|
};
|
|
978
1046
|
type RaindropAISDKClient = {
|
|
979
1047
|
wrap<T extends object>(aiSDK: T, options?: WrapAISDKOptions): WrappedAISDK<T>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Create a standalone AI SDK self-diagnostics tool.
|
|
1050
|
+
*
|
|
1051
|
+
* The tool automatically uses the active Raindrop event while executing
|
|
1052
|
+
* under `createTelemetryIntegration()` with tracing enabled. Pass `eventId`
|
|
1053
|
+
* or `getEventId` when no active trace context is available.
|
|
1054
|
+
*/
|
|
1055
|
+
createSelfDiagnosticsTool(options?: SelfDiagnosticsToolOptions): SelfDiagnosticsTool;
|
|
980
1056
|
/**
|
|
981
1057
|
* Create a TelemetryIntegration instance for direct registration with AI SDK v7+.
|
|
982
1058
|
* Use with `registerTelemetryIntegration()` from the `ai` package.
|
|
@@ -1061,5 +1137,53 @@ type RaindropAISDKClient = {
|
|
|
1061
1137
|
shutdown(): Promise<void>;
|
|
1062
1138
|
};
|
|
1063
1139
|
declare function createRaindropAISDK(opts: RaindropAISDKOptions): RaindropAISDKClient;
|
|
1140
|
+
/**
|
|
1141
|
+
* Options for the {@link raindrop} telemetry-integration factory. A superset of
|
|
1142
|
+
* {@link RaindropAISDKOptions} plus the per-integration `context` defaults and
|
|
1143
|
+
* `subagentWrapping` toggle accepted by `createTelemetryIntegration()`.
|
|
1144
|
+
*/
|
|
1145
|
+
type RaindropTelemetryOptions = RaindropAISDKOptions & {
|
|
1146
|
+
/** Default Raindrop context (userId/eventName/convoId/properties) applied to every call. */
|
|
1147
|
+
context?: RaindropTelemetryIntegrationOptions["context"];
|
|
1148
|
+
/**
|
|
1149
|
+
* Wrap sub-agent generations (a `generateText`/`streamText` invoked from
|
|
1150
|
+
* inside a tool's `execute`) in a synthetic tool span so parent and child
|
|
1151
|
+
* spans nest correctly. Enabled by default.
|
|
1152
|
+
*/
|
|
1153
|
+
subagentWrapping?: boolean;
|
|
1154
|
+
};
|
|
1155
|
+
/**
|
|
1156
|
+
* One-line factory for the AI SDK v7 `registerTelemetry` DX.
|
|
1157
|
+
*
|
|
1158
|
+
* Returns a {@link RaindropTelemetryIntegration} wired to Raindrop's trace +
|
|
1159
|
+
* event shippers, ready to hand to the AI SDK's `registerTelemetry`. The
|
|
1160
|
+
* `writeKey` defaults to the `RAINDROP_WRITE_KEY` environment variable.
|
|
1161
|
+
*
|
|
1162
|
+
* @example
|
|
1163
|
+
* ```ts
|
|
1164
|
+
* import { generateText, registerTelemetry } from "ai";
|
|
1165
|
+
* import { OpenTelemetry } from "@ai-sdk/otel";
|
|
1166
|
+
* import { raindrop } from "@raindrop-ai/ai-sdk";
|
|
1167
|
+
*
|
|
1168
|
+
* registerTelemetry(new OpenTelemetry(), raindrop());
|
|
1169
|
+
*
|
|
1170
|
+
* await generateText({
|
|
1171
|
+
* model: anthropic("claude-sonnet-4-5"),
|
|
1172
|
+
* prompt: "what is the weather in Tokyo?",
|
|
1173
|
+
* telemetry: { functionId: "weather-agent" },
|
|
1174
|
+
* });
|
|
1175
|
+
* ```
|
|
1176
|
+
*
|
|
1177
|
+
* The returned integration also exposes `flush()` / `shutdown()` for
|
|
1178
|
+
* short-lived scripts that need to drain buffered telemetry before exiting:
|
|
1179
|
+
*
|
|
1180
|
+
* ```ts
|
|
1181
|
+
* const rd = raindrop();
|
|
1182
|
+
* registerTelemetry(rd);
|
|
1183
|
+
* // ...
|
|
1184
|
+
* await rd.flush();
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
|
|
1064
1188
|
|
|
1065
|
-
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, 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 SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type StartSpanArgs, type TraceSpan, type TransformSpanHook, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
|
|
1189
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, 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, type TraceSpan, type TransformSpanHook, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
|