@raindrop-ai/ai-sdk 0.0.33 → 0.0.34
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 -0
- package/dist/{chunk-FIX66Y7M.mjs → chunk-OLOFN54C.mjs} +440 -77
- package/dist/{index-Dcf4FPZL.d.mts → index-HYjRP6nV.d.mts} +112 -2
- package/dist/{index-Dcf4FPZL.d.ts → index-HYjRP6nV.d.ts} +112 -2
- package/dist/index.browser.d.mts +112 -2
- package/dist/index.browser.d.ts +112 -2
- package/dist/index.browser.js +443 -76
- package/dist/index.browser.mjs +440 -77
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.d.ts +1 -1
- package/dist/index.node.js +443 -76
- 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 +443 -76
- package/dist/index.workers.mjs +1 -1
- package/package.json +2 -2
package/dist/index.browser.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ type SpanIds = {
|
|
|
35
35
|
spanIdB64: string;
|
|
36
36
|
parentSpanIdB64?: string;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
38
|
type Attachment$1 = {
|
|
40
39
|
type: string;
|
|
41
40
|
role: string;
|
|
@@ -84,6 +83,14 @@ type EventShipperOptions = {
|
|
|
84
83
|
* Pass `null` to opt out of all mirroring (including auto-detect).
|
|
85
84
|
*/
|
|
86
85
|
localDebuggerUrl?: string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Per-field character cap applied to event input/output BEFORE buffering
|
|
88
|
+
* or serialization, so oversized payloads cost the cap — not the payload —
|
|
89
|
+
* on the calling code path. Truncated fields end with
|
|
90
|
+
* `...[truncated by raindrop]` and never exceed the cap, marker included.
|
|
91
|
+
* Defaults to 1,000,000 (matching the Python SDK).
|
|
92
|
+
*/
|
|
93
|
+
maxTextFieldChars?: number;
|
|
87
94
|
};
|
|
88
95
|
declare class EventShipper$1 {
|
|
89
96
|
private baseUrl;
|
|
@@ -99,11 +106,39 @@ declare class EventShipper$1 {
|
|
|
99
106
|
private sticky;
|
|
100
107
|
private timers;
|
|
101
108
|
private inFlight;
|
|
109
|
+
private maxTextFieldCharsOpt;
|
|
110
|
+
/**
|
|
111
|
+
* Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
|
|
112
|
+
* Checked before every POST issued during the final flush.
|
|
113
|
+
*/
|
|
114
|
+
private shutdownDeadlineAt;
|
|
115
|
+
/**
|
|
116
|
+
* Set once `shutdown()` begins and never cleared. Sends issued after the
|
|
117
|
+
* drain window (stragglers, or flush work the deadline abandoned
|
|
118
|
+
* mid-drain) run as a single short attempt instead of regaining the full
|
|
119
|
+
* retry schedule.
|
|
120
|
+
*/
|
|
121
|
+
private hasShutdown;
|
|
102
122
|
/** URL of the local debugger / Workshop daemon, when one is reachable. */
|
|
103
123
|
private localDebuggerUrl;
|
|
104
124
|
constructor(opts: EventShipperOptions);
|
|
105
125
|
isDebugEnabled(): boolean;
|
|
106
126
|
private authHeaders;
|
|
127
|
+
/**
|
|
128
|
+
* Build the retry/timeout options for one POST, honoring the shutdown
|
|
129
|
+
* deadline. Returns `null` when the shutdown drain window is exhausted —
|
|
130
|
+
* the caller must drop the payload (with a rate-limited warning) instead
|
|
131
|
+
* of issuing a request that could outlive process exit.
|
|
132
|
+
*
|
|
133
|
+
* Checked fresh on EVERY send, so a shutdown that begins while the flush
|
|
134
|
+
* path is mid-drain takes effect immediately: no further retries, and the
|
|
135
|
+
* per-attempt timeout is clamped to the remaining window. After
|
|
136
|
+
* `shutdown()` returns (deadline cleared, `hasShutdown` still set),
|
|
137
|
+
* sends — late callers, or flush work the deadline abandoned mid-drain —
|
|
138
|
+
* run as a single short attempt rather than regaining the full retry
|
|
139
|
+
* schedule.
|
|
140
|
+
*/
|
|
141
|
+
private requestOpts;
|
|
107
142
|
patch(eventId: string, patch: Patch): Promise<void>;
|
|
108
143
|
finish(eventId: string, patch: {
|
|
109
144
|
output?: string;
|
|
@@ -115,6 +150,7 @@ declare class EventShipper$1 {
|
|
|
115
150
|
shutdown(): Promise<void>;
|
|
116
151
|
trackSignal(signal: SignalInput): Promise<void>;
|
|
117
152
|
identify(users: IdentifyInput$1 | IdentifyInput$1[]): Promise<void>;
|
|
153
|
+
private warnShutdownDrop;
|
|
118
154
|
private flushOne;
|
|
119
155
|
}
|
|
120
156
|
|
|
@@ -252,6 +288,15 @@ type TraceShipperOptions = {
|
|
|
252
288
|
* still want some redaction in that case.
|
|
253
289
|
*/
|
|
254
290
|
disableDefaultRedaction?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Per-attribute character cap applied to every span attribute string value
|
|
293
|
+
* right before the span enters a ship path, so a multi-MB prompt/tool
|
|
294
|
+
* payload can never make the batch `JSON.stringify` (which runs on the
|
|
295
|
+
* event loop) cost seconds. Truncated values end with
|
|
296
|
+
* `...[truncated by raindrop]` and never exceed the cap, marker included.
|
|
297
|
+
* Defaults to 1,000,000 (matching the Python SDK).
|
|
298
|
+
*/
|
|
299
|
+
maxTextFieldChars?: number;
|
|
255
300
|
};
|
|
256
301
|
declare class TraceShipper$1 {
|
|
257
302
|
private baseUrl;
|
|
@@ -273,7 +318,32 @@ declare class TraceShipper$1 {
|
|
|
273
318
|
private localDebuggerUrl;
|
|
274
319
|
private transformSpanHook;
|
|
275
320
|
private disableDefaultRedaction;
|
|
321
|
+
private maxTextFieldCharsOpt;
|
|
322
|
+
/**
|
|
323
|
+
* Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
|
|
324
|
+
* Checked before every batch POST issued during the final flush.
|
|
325
|
+
*/
|
|
326
|
+
private shutdownDeadlineAt;
|
|
327
|
+
/**
|
|
328
|
+
* Set once `shutdown()` begins and never cleared. Sends issued after the
|
|
329
|
+
* drain window (stragglers, or flush work the deadline abandoned
|
|
330
|
+
* mid-drain) run as a single short attempt instead of regaining the full
|
|
331
|
+
* retry schedule.
|
|
332
|
+
*/
|
|
333
|
+
private hasShutdown;
|
|
276
334
|
constructor(opts: TraceShipperOptions);
|
|
335
|
+
/**
|
|
336
|
+
* Cap every string attribute value on the span. O(#attributes) length
|
|
337
|
+
* checks; only oversized values pay a slice. Runs AFTER the redaction
|
|
338
|
+
* pipeline so the default secret-scrub still sees parseable JSON in
|
|
339
|
+
* `ai.request.providerOptions` / `ai.response.providerMetadata` (capping
|
|
340
|
+
* first could cut a JSON blob mid-way, fail the parse, and ship secrets
|
|
341
|
+
* in the surviving prefix).
|
|
342
|
+
*
|
|
343
|
+
* A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored
|
|
344
|
+
* for span content, matching the Python SDK and the OTel SDK convention.
|
|
345
|
+
*/
|
|
346
|
+
private capSpanAttributes;
|
|
277
347
|
/**
|
|
278
348
|
* Apply the user `transformSpan` hook (if any) followed by the default
|
|
279
349
|
* redactor (unless disabled). Returns either the (possibly new) span to
|
|
@@ -323,6 +393,8 @@ declare class TraceShipper$1 {
|
|
|
323
393
|
}): void;
|
|
324
394
|
enqueue(span: OtlpSpan): void;
|
|
325
395
|
flush(): Promise<void>;
|
|
396
|
+
/** See EventShipper.requestOpts — same shutdown-budget semantics. */
|
|
397
|
+
private requestOpts;
|
|
326
398
|
shutdown(): Promise<void>;
|
|
327
399
|
}
|
|
328
400
|
|
|
@@ -519,6 +591,33 @@ type IdentifyInput = {
|
|
|
519
591
|
traits?: Record<string, unknown>;
|
|
520
592
|
};
|
|
521
593
|
|
|
594
|
+
declare const TRUNCATION_MARKER = "...[truncated by raindrop]";
|
|
595
|
+
declare const DEFAULT_MAX_TEXT_FIELD_CHARS = 1000000;
|
|
596
|
+
/**
|
|
597
|
+
* Cap a raw text field BEFORE it is buffered or attached to a span.
|
|
598
|
+
*
|
|
599
|
+
* The length check is O(1), so multi-MB strings cost nothing on the caller
|
|
600
|
+
* beyond the slice that keeps the first `limit` chars. Non-string values
|
|
601
|
+
* (including `undefined`) pass through untouched.
|
|
602
|
+
*/
|
|
603
|
+
declare function capText(value: string, limit?: number): string;
|
|
604
|
+
declare function capText(value: string | undefined, limit?: number): string | undefined;
|
|
605
|
+
/**
|
|
606
|
+
* JSON-serialize `value` with a hard output budget.
|
|
607
|
+
*
|
|
608
|
+
* Unlike serialize-then-truncate, the cost here is proportional to the
|
|
609
|
+
* limit, not the payload: the value is pruned by `boundedClone` first, so a
|
|
610
|
+
* multi-MB tool result can never burn seconds of CPU on the calling thread
|
|
611
|
+
* (which is typically the host app's event loop). Matching the previous
|
|
612
|
+
* `safeJson` semantics, returns `undefined` when the value cannot be
|
|
613
|
+
* serialized (e.g. BigInt leaves) — and, like any display truncation, a
|
|
614
|
+
* truncated result may not be valid JSON.
|
|
615
|
+
*
|
|
616
|
+
* Small payloads (within the budget) serialize exactly like
|
|
617
|
+
* `JSON.stringify`, except `Uint8Array` values become base64 strings.
|
|
618
|
+
*/
|
|
619
|
+
declare function boundedStringify(value: unknown, limit?: number): string | undefined;
|
|
620
|
+
|
|
522
621
|
type RaindropCallMetadata = {
|
|
523
622
|
userId?: string;
|
|
524
623
|
eventId?: string;
|
|
@@ -859,6 +958,17 @@ type RaindropAISDKOptions = {
|
|
|
859
958
|
partialFlushMs?: number;
|
|
860
959
|
debug?: boolean;
|
|
861
960
|
};
|
|
961
|
+
/**
|
|
962
|
+
* Per-field character cap applied to ai input/output text and serialized
|
|
963
|
+
* tool/LLM span payloads BEFORE (or during) serialization, so oversized
|
|
964
|
+
* payloads cost the cap — not the payload — on the calling thread.
|
|
965
|
+
* Truncated values end with `...[truncated by raindrop]` and never exceed
|
|
966
|
+
* the cap. A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is
|
|
967
|
+
* honored. Applies module-wide: the last `createRaindropAISDK` call that
|
|
968
|
+
* sets this option wins; omitting it leaves the current cap unchanged.
|
|
969
|
+
* Defaults to 1,000,000.
|
|
970
|
+
*/
|
|
971
|
+
maxTextFieldChars?: number;
|
|
862
972
|
};
|
|
863
973
|
type RaindropAISDKContext = {
|
|
864
974
|
userId?: string;
|
|
@@ -1186,4 +1296,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
|
|
|
1186
1296
|
*/
|
|
1187
1297
|
declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
|
|
1188
1298
|
|
|
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 };
|
|
1299
|
+
export { type AISDKChatRequestLike, type AISDKChatRequestMessageLike, type AISDKMessage, type AgentCallMetadata, type AgentWithMetadata, type Attachment, type BuildEventPatch, ContextManager, type ContextSpan, type CreateSpanArgs, DEFAULT_MAX_TEXT_FIELD_CHARS, DEFAULT_REDACT_ATTRIBUTE_KEYS, DEFAULT_SECRET_KEY_NAMES, type EndSpanArgs, type EventBuilder, type EventMetadataOptions, type IdentifyInput, type OtlpAnyValue, type OtlpSpan, type ParentToolContext, REDACTED_PLACEHOLDER, type RaindropAISDKClient, type RaindropAISDKContext, type RaindropAISDKOptions, type RaindropCallMetadata, RaindropTelemetryIntegration, type RaindropTelemetryIntegrationOptions, type RaindropTelemetryOptions, type SelfDiagnosticsOptions, type SelfDiagnosticsSignalDefinition, type SelfDiagnosticsSignalDefinitions, type SelfDiagnosticsTool, type SelfDiagnosticsToolInput, type SelfDiagnosticsToolOptions, type SelfDiagnosticsToolResult, type StartSpanArgs, TRUNCATION_MARKER, type TraceSpan, type TransformSpanHook, type WrapAISDKOptions, type WrappedAI, type WrappedAISDK, _resetParentToolContextStorage, _resetRaindropCallMetadataStorage, _resetWarnedMissingUserId, boundedStringify, capText, clearParentToolContext, createRaindropAISDK, currentSpan, defaultTransformSpan, enterParentToolContext, eventMetadata, eventMetadataFromChatRequest, getContextManager, getCurrentParentToolContext, getCurrentRaindropCallMetadata, raindrop, readRaindropCallMetadataFromArgs, redactJsonAttributeValue, redactSecretsInObject, runWithParentToolContext, runWithRaindropCallMetadata, withCurrent };
|