@raindrop-ai/ai-sdk 0.0.33 → 0.0.35

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.
@@ -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,21 @@ type EventShipperOptions = {
84
83
  * Pass `null` to opt out of all mirroring (including auto-detect).
85
84
  */
86
85
  localDebuggerUrl?: string | null;
86
+ /**
87
+ * Optional project slug. When set, every outbound cloud request includes an
88
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
89
+ * values are ignored. Slug format is validated on construction but never
90
+ * throws — the backend returns 400 on invalid values.
91
+ */
92
+ projectId?: string;
93
+ /**
94
+ * Per-field character cap applied to event input/output BEFORE buffering
95
+ * or serialization, so oversized payloads cost the cap — not the payload —
96
+ * on the calling code path. Truncated fields end with
97
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
98
+ * Defaults to 1,000,000 (matching the Python SDK).
99
+ */
100
+ maxTextFieldChars?: number;
87
101
  };
88
102
  declare class EventShipper$1 {
89
103
  private baseUrl;
@@ -94,16 +108,46 @@ declare class EventShipper$1 {
94
108
  private sdkName;
95
109
  private prefix;
96
110
  private defaultEventName;
111
+ private projectId;
97
112
  private context;
98
113
  private buffers;
99
114
  private sticky;
100
115
  private timers;
101
116
  private inFlight;
117
+ private maxTextFieldCharsOpt;
118
+ /**
119
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
120
+ * Checked before every POST issued during the final flush.
121
+ */
122
+ private shutdownDeadlineAt;
123
+ /**
124
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
125
+ * drain window (stragglers, or flush work the deadline abandoned
126
+ * mid-drain) run as a single short attempt instead of regaining the full
127
+ * retry schedule.
128
+ */
129
+ private hasShutdown;
102
130
  /** URL of the local debugger / Workshop daemon, when one is reachable. */
103
131
  private localDebuggerUrl;
104
132
  constructor(opts: EventShipperOptions);
105
133
  isDebugEnabled(): boolean;
106
134
  private authHeaders;
135
+ private requestHeaders;
136
+ /**
137
+ * Build the retry/timeout options for one POST, honoring the shutdown
138
+ * deadline. Returns `null` when the shutdown drain window is exhausted —
139
+ * the caller must drop the payload (with a rate-limited warning) instead
140
+ * of issuing a request that could outlive process exit.
141
+ *
142
+ * Checked fresh on EVERY send, so a shutdown that begins while the flush
143
+ * path is mid-drain takes effect immediately: no further retries, and the
144
+ * per-attempt timeout is clamped to the remaining window. After
145
+ * `shutdown()` returns (deadline cleared, `hasShutdown` still set),
146
+ * sends — late callers, or flush work the deadline abandoned mid-drain —
147
+ * run as a single short attempt rather than regaining the full retry
148
+ * schedule.
149
+ */
150
+ private requestOpts;
107
151
  patch(eventId: string, patch: Patch): Promise<void>;
108
152
  finish(eventId: string, patch: {
109
153
  output?: string;
@@ -115,6 +159,7 @@ declare class EventShipper$1 {
115
159
  shutdown(): Promise<void>;
116
160
  trackSignal(signal: SignalInput): Promise<void>;
117
161
  identify(users: IdentifyInput$1 | IdentifyInput$1[]): Promise<void>;
162
+ private warnShutdownDrop;
118
163
  private flushOne;
119
164
  }
120
165
 
@@ -218,6 +263,13 @@ type TraceShipperOptions = {
218
263
  * Pass `null` to opt out of all mirroring (including auto-detect).
219
264
  */
220
265
  localDebuggerUrl?: string | null;
266
+ /**
267
+ * Optional project slug. When set, every OTLP trace export includes an
268
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
269
+ * values are ignored. Slug format is validated on construction but never
270
+ * throws — the backend returns 400 on invalid values.
271
+ */
272
+ projectId?: string;
221
273
  /**
222
274
  * Per-span hook that fires for every OTLP span right before the span is
223
275
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -252,6 +304,15 @@ type TraceShipperOptions = {
252
304
  * still want some redaction in that case.
253
305
  */
254
306
  disableDefaultRedaction?: boolean;
307
+ /**
308
+ * Per-attribute character cap applied to every span attribute string value
309
+ * right before the span enters a ship path, so a multi-MB prompt/tool
310
+ * payload can never make the batch `JSON.stringify` (which runs on the
311
+ * event loop) cost seconds. Truncated values end with
312
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
313
+ * Defaults to 1,000,000 (matching the Python SDK).
314
+ */
315
+ maxTextFieldChars?: number;
255
316
  };
256
317
  declare class TraceShipper$1 {
257
318
  private baseUrl;
@@ -266,6 +327,7 @@ declare class TraceShipper$1 {
266
327
  private flushIntervalMs;
267
328
  private maxBatchSize;
268
329
  private maxQueueSize;
330
+ private projectId;
269
331
  private queue;
270
332
  private timer;
271
333
  private inFlight;
@@ -273,7 +335,32 @@ declare class TraceShipper$1 {
273
335
  private localDebuggerUrl;
274
336
  private transformSpanHook;
275
337
  private disableDefaultRedaction;
338
+ private maxTextFieldCharsOpt;
339
+ /**
340
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
341
+ * Checked before every batch POST issued during the final flush.
342
+ */
343
+ private shutdownDeadlineAt;
344
+ /**
345
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
346
+ * drain window (stragglers, or flush work the deadline abandoned
347
+ * mid-drain) run as a single short attempt instead of regaining the full
348
+ * retry schedule.
349
+ */
350
+ private hasShutdown;
276
351
  constructor(opts: TraceShipperOptions);
352
+ /**
353
+ * Cap every string attribute value on the span. O(#attributes) length
354
+ * checks; only oversized values pay a slice. Runs AFTER the redaction
355
+ * pipeline so the default secret-scrub still sees parseable JSON in
356
+ * `ai.request.providerOptions` / `ai.response.providerMetadata` (capping
357
+ * first could cut a JSON blob mid-way, fail the parse, and ship secrets
358
+ * in the surviving prefix).
359
+ *
360
+ * A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored
361
+ * for span content, matching the Python SDK and the OTel SDK convention.
362
+ */
363
+ private capSpanAttributes;
277
364
  /**
278
365
  * Apply the user `transformSpan` hook (if any) followed by the default
279
366
  * redactor (unless disabled). Returns either the (possibly new) span to
@@ -291,6 +378,7 @@ declare class TraceShipper$1 {
291
378
  private redactSpan;
292
379
  isDebugEnabled(): boolean;
293
380
  private authHeaders;
381
+ private requestHeaders;
294
382
  startSpan(args: {
295
383
  name: string;
296
384
  parent?: {
@@ -323,6 +411,8 @@ declare class TraceShipper$1 {
323
411
  }): void;
324
412
  enqueue(span: OtlpSpan): void;
325
413
  flush(): Promise<void>;
414
+ /** See EventShipper.requestOpts — same shutdown-budget semantics. */
415
+ private requestOpts;
326
416
  shutdown(): Promise<void>;
327
417
  }
328
418
 
@@ -519,6 +609,33 @@ type IdentifyInput = {
519
609
  traits?: Record<string, unknown>;
520
610
  };
521
611
 
612
+ declare const TRUNCATION_MARKER = "...[truncated by raindrop]";
613
+ declare const DEFAULT_MAX_TEXT_FIELD_CHARS = 1000000;
614
+ /**
615
+ * Cap a raw text field BEFORE it is buffered or attached to a span.
616
+ *
617
+ * The length check is O(1), so multi-MB strings cost nothing on the caller
618
+ * beyond the slice that keeps the first `limit` chars. Non-string values
619
+ * (including `undefined`) pass through untouched.
620
+ */
621
+ declare function capText(value: string, limit?: number): string;
622
+ declare function capText(value: string | undefined, limit?: number): string | undefined;
623
+ /**
624
+ * JSON-serialize `value` with a hard output budget.
625
+ *
626
+ * Unlike serialize-then-truncate, the cost here is proportional to the
627
+ * limit, not the payload: the value is pruned by `boundedClone` first, so a
628
+ * multi-MB tool result can never burn seconds of CPU on the calling thread
629
+ * (which is typically the host app's event loop). Matching the previous
630
+ * `safeJson` semantics, returns `undefined` when the value cannot be
631
+ * serialized (e.g. BigInt leaves) — and, like any display truncation, a
632
+ * truncated result may not be valid JSON.
633
+ *
634
+ * Small payloads (within the budget) serialize exactly like
635
+ * `JSON.stringify`, except `Uint8Array` values become base64 strings.
636
+ */
637
+ declare function boundedStringify(value: unknown, limit?: number): string | undefined;
638
+
522
639
  type RaindropCallMetadata = {
523
640
  userId?: string;
524
641
  eventId?: string;
@@ -800,6 +917,12 @@ type RaindropAISDKOptions = {
800
917
  */
801
918
  writeKey?: string;
802
919
  endpoint?: string;
920
+ /**
921
+ * Optional Raindrop project slug. When set, every outbound cloud request
922
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
923
+ * resolves to `default` server-side; byte-identical to prior behavior).
924
+ */
925
+ projectId?: string;
803
926
  /**
804
927
  * Force-enable (or opt out of) Workshop / local-debugger mirroring.
805
928
  *
@@ -859,6 +982,17 @@ type RaindropAISDKOptions = {
859
982
  partialFlushMs?: number;
860
983
  debug?: boolean;
861
984
  };
985
+ /**
986
+ * Per-field character cap applied to ai input/output text and serialized
987
+ * tool/LLM span payloads BEFORE (or during) serialization, so oversized
988
+ * payloads cost the cap — not the payload — on the calling thread.
989
+ * Truncated values end with `...[truncated by raindrop]` and never exceed
990
+ * the cap. A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is
991
+ * honored. Applies module-wide: the last `createRaindropAISDK` call that
992
+ * sets this option wins; omitting it leaves the current cap unchanged.
993
+ * Defaults to 1,000,000.
994
+ */
995
+ maxTextFieldChars?: number;
862
996
  };
863
997
  type RaindropAISDKContext = {
864
998
  userId?: string;
@@ -1186,4 +1320,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
1186
1320
  */
1187
1321
  declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
1188
1322
 
1189
- export { raindrop as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_REDACT_ATTRIBUTE_KEYS as D, type EndSpanArgs as E, type WrappedAI as F, type WrappedAISDK as G, _resetRaindropCallMetadataStorage as H, type IdentifyInput as I, _resetWarnedMissingUserId as J, clearParentToolContext as K, createRaindropAISDK as L, currentSpan as M, defaultTransformSpan as N, type OtlpAnyValue as O, type ParentToolContext as P, enterParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, eventMetadata as U, eventMetadataFromChatRequest as V, type WrapAISDKOptions as W, getContextManager as X, getCurrentParentToolContext as Y, getCurrentRaindropCallMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, readRaindropCallMetadataFromArgs as a0, redactJsonAttributeValue as a1, redactSecretsInObject as a2, runWithParentToolContext as a3, runWithRaindropCallMetadata as a4, withCurrent as a5, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_SECRET_KEY_NAMES as h, type EventBuilder as i, type EventMetadataOptions as j, type OtlpSpan as k, type RaindropAISDKClient as l, type RaindropAISDKContext as m, type RaindropAISDKOptions as n, type RaindropCallMetadata as o, RaindropTelemetryIntegration as p, type RaindropTelemetryIntegrationOptions as q, type RaindropTelemetryOptions as r, type SelfDiagnosticsSignalDefinition as s, type SelfDiagnosticsSignalDefinitions as t, type SelfDiagnosticsTool as u, type SelfDiagnosticsToolInput as v, type SelfDiagnosticsToolOptions as w, type SelfDiagnosticsToolResult as x, type StartSpanArgs as y, type TransformSpanHook as z };
1323
+ export { eventMetadataFromChatRequest as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type TraceSpan as F, type TransformSpanHook as G, type WrappedAI as H, type IdentifyInput as I, type WrappedAISDK as J, _resetRaindropCallMetadataStorage as K, _resetWarnedMissingUserId as L, boundedStringify as M, capText as N, type OtlpAnyValue as O, type ParentToolContext as P, clearParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, createRaindropAISDK as U, currentSpan as V, type WrapAISDKOptions as W, defaultTransformSpan as X, enterParentToolContext as Y, eventMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, getContextManager as a0, getCurrentParentToolContext as a1, getCurrentRaindropCallMetadata as a2, raindrop as a3, readRaindropCallMetadataFromArgs as a4, redactJsonAttributeValue as a5, redactSecretsInObject as a6, runWithParentToolContext as a7, runWithRaindropCallMetadata as a8, withCurrent as a9, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type OtlpSpan as l, type RaindropAISDKClient as m, type RaindropAISDKContext as n, type RaindropAISDKOptions as o, type RaindropCallMetadata as p, RaindropTelemetryIntegration as q, type RaindropTelemetryIntegrationOptions as r, type RaindropTelemetryOptions as s, type SelfDiagnosticsSignalDefinition as t, type SelfDiagnosticsSignalDefinitions as u, type SelfDiagnosticsTool as v, type SelfDiagnosticsToolInput as w, type SelfDiagnosticsToolOptions as x, type SelfDiagnosticsToolResult as y, type StartSpanArgs as z };
@@ -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,21 @@ type EventShipperOptions = {
84
83
  * Pass `null` to opt out of all mirroring (including auto-detect).
85
84
  */
86
85
  localDebuggerUrl?: string | null;
86
+ /**
87
+ * Optional project slug. When set, every outbound cloud request includes an
88
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
89
+ * values are ignored. Slug format is validated on construction but never
90
+ * throws — the backend returns 400 on invalid values.
91
+ */
92
+ projectId?: string;
93
+ /**
94
+ * Per-field character cap applied to event input/output BEFORE buffering
95
+ * or serialization, so oversized payloads cost the cap — not the payload —
96
+ * on the calling code path. Truncated fields end with
97
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
98
+ * Defaults to 1,000,000 (matching the Python SDK).
99
+ */
100
+ maxTextFieldChars?: number;
87
101
  };
88
102
  declare class EventShipper$1 {
89
103
  private baseUrl;
@@ -94,16 +108,46 @@ declare class EventShipper$1 {
94
108
  private sdkName;
95
109
  private prefix;
96
110
  private defaultEventName;
111
+ private projectId;
97
112
  private context;
98
113
  private buffers;
99
114
  private sticky;
100
115
  private timers;
101
116
  private inFlight;
117
+ private maxTextFieldCharsOpt;
118
+ /**
119
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
120
+ * Checked before every POST issued during the final flush.
121
+ */
122
+ private shutdownDeadlineAt;
123
+ /**
124
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
125
+ * drain window (stragglers, or flush work the deadline abandoned
126
+ * mid-drain) run as a single short attempt instead of regaining the full
127
+ * retry schedule.
128
+ */
129
+ private hasShutdown;
102
130
  /** URL of the local debugger / Workshop daemon, when one is reachable. */
103
131
  private localDebuggerUrl;
104
132
  constructor(opts: EventShipperOptions);
105
133
  isDebugEnabled(): boolean;
106
134
  private authHeaders;
135
+ private requestHeaders;
136
+ /**
137
+ * Build the retry/timeout options for one POST, honoring the shutdown
138
+ * deadline. Returns `null` when the shutdown drain window is exhausted —
139
+ * the caller must drop the payload (with a rate-limited warning) instead
140
+ * of issuing a request that could outlive process exit.
141
+ *
142
+ * Checked fresh on EVERY send, so a shutdown that begins while the flush
143
+ * path is mid-drain takes effect immediately: no further retries, and the
144
+ * per-attempt timeout is clamped to the remaining window. After
145
+ * `shutdown()` returns (deadline cleared, `hasShutdown` still set),
146
+ * sends — late callers, or flush work the deadline abandoned mid-drain —
147
+ * run as a single short attempt rather than regaining the full retry
148
+ * schedule.
149
+ */
150
+ private requestOpts;
107
151
  patch(eventId: string, patch: Patch): Promise<void>;
108
152
  finish(eventId: string, patch: {
109
153
  output?: string;
@@ -115,6 +159,7 @@ declare class EventShipper$1 {
115
159
  shutdown(): Promise<void>;
116
160
  trackSignal(signal: SignalInput): Promise<void>;
117
161
  identify(users: IdentifyInput$1 | IdentifyInput$1[]): Promise<void>;
162
+ private warnShutdownDrop;
118
163
  private flushOne;
119
164
  }
120
165
 
@@ -218,6 +263,13 @@ type TraceShipperOptions = {
218
263
  * Pass `null` to opt out of all mirroring (including auto-detect).
219
264
  */
220
265
  localDebuggerUrl?: string | null;
266
+ /**
267
+ * Optional project slug. When set, every OTLP trace export includes an
268
+ * `X-Raindrop-Project-Id: <projectId>` header. Empty / whitespace-only
269
+ * values are ignored. Slug format is validated on construction but never
270
+ * throws — the backend returns 400 on invalid values.
271
+ */
272
+ projectId?: string;
221
273
  /**
222
274
  * Per-span hook that fires for every OTLP span right before the span is
223
275
  * shipped (both to the Raindrop API and to a local debugger). Lets callers
@@ -252,6 +304,15 @@ type TraceShipperOptions = {
252
304
  * still want some redaction in that case.
253
305
  */
254
306
  disableDefaultRedaction?: boolean;
307
+ /**
308
+ * Per-attribute character cap applied to every span attribute string value
309
+ * right before the span enters a ship path, so a multi-MB prompt/tool
310
+ * payload can never make the batch `JSON.stringify` (which runs on the
311
+ * event loop) cost seconds. Truncated values end with
312
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
313
+ * Defaults to 1,000,000 (matching the Python SDK).
314
+ */
315
+ maxTextFieldChars?: number;
255
316
  };
256
317
  declare class TraceShipper$1 {
257
318
  private baseUrl;
@@ -266,6 +327,7 @@ declare class TraceShipper$1 {
266
327
  private flushIntervalMs;
267
328
  private maxBatchSize;
268
329
  private maxQueueSize;
330
+ private projectId;
269
331
  private queue;
270
332
  private timer;
271
333
  private inFlight;
@@ -273,7 +335,32 @@ declare class TraceShipper$1 {
273
335
  private localDebuggerUrl;
274
336
  private transformSpanHook;
275
337
  private disableDefaultRedaction;
338
+ private maxTextFieldCharsOpt;
339
+ /**
340
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
341
+ * Checked before every batch POST issued during the final flush.
342
+ */
343
+ private shutdownDeadlineAt;
344
+ /**
345
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
346
+ * drain window (stragglers, or flush work the deadline abandoned
347
+ * mid-drain) run as a single short attempt instead of regaining the full
348
+ * retry schedule.
349
+ */
350
+ private hasShutdown;
276
351
  constructor(opts: TraceShipperOptions);
352
+ /**
353
+ * Cap every string attribute value on the span. O(#attributes) length
354
+ * checks; only oversized values pay a slice. Runs AFTER the redaction
355
+ * pipeline so the default secret-scrub still sees parseable JSON in
356
+ * `ai.request.providerOptions` / `ai.response.providerMetadata` (capping
357
+ * first could cut a JSON blob mid-way, fail the parse, and ship secrets
358
+ * in the surviving prefix).
359
+ *
360
+ * A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored
361
+ * for span content, matching the Python SDK and the OTel SDK convention.
362
+ */
363
+ private capSpanAttributes;
277
364
  /**
278
365
  * Apply the user `transformSpan` hook (if any) followed by the default
279
366
  * redactor (unless disabled). Returns either the (possibly new) span to
@@ -291,6 +378,7 @@ declare class TraceShipper$1 {
291
378
  private redactSpan;
292
379
  isDebugEnabled(): boolean;
293
380
  private authHeaders;
381
+ private requestHeaders;
294
382
  startSpan(args: {
295
383
  name: string;
296
384
  parent?: {
@@ -323,6 +411,8 @@ declare class TraceShipper$1 {
323
411
  }): void;
324
412
  enqueue(span: OtlpSpan): void;
325
413
  flush(): Promise<void>;
414
+ /** See EventShipper.requestOpts — same shutdown-budget semantics. */
415
+ private requestOpts;
326
416
  shutdown(): Promise<void>;
327
417
  }
328
418
 
@@ -519,6 +609,33 @@ type IdentifyInput = {
519
609
  traits?: Record<string, unknown>;
520
610
  };
521
611
 
612
+ declare const TRUNCATION_MARKER = "...[truncated by raindrop]";
613
+ declare const DEFAULT_MAX_TEXT_FIELD_CHARS = 1000000;
614
+ /**
615
+ * Cap a raw text field BEFORE it is buffered or attached to a span.
616
+ *
617
+ * The length check is O(1), so multi-MB strings cost nothing on the caller
618
+ * beyond the slice that keeps the first `limit` chars. Non-string values
619
+ * (including `undefined`) pass through untouched.
620
+ */
621
+ declare function capText(value: string, limit?: number): string;
622
+ declare function capText(value: string | undefined, limit?: number): string | undefined;
623
+ /**
624
+ * JSON-serialize `value` with a hard output budget.
625
+ *
626
+ * Unlike serialize-then-truncate, the cost here is proportional to the
627
+ * limit, not the payload: the value is pruned by `boundedClone` first, so a
628
+ * multi-MB tool result can never burn seconds of CPU on the calling thread
629
+ * (which is typically the host app's event loop). Matching the previous
630
+ * `safeJson` semantics, returns `undefined` when the value cannot be
631
+ * serialized (e.g. BigInt leaves) — and, like any display truncation, a
632
+ * truncated result may not be valid JSON.
633
+ *
634
+ * Small payloads (within the budget) serialize exactly like
635
+ * `JSON.stringify`, except `Uint8Array` values become base64 strings.
636
+ */
637
+ declare function boundedStringify(value: unknown, limit?: number): string | undefined;
638
+
522
639
  type RaindropCallMetadata = {
523
640
  userId?: string;
524
641
  eventId?: string;
@@ -800,6 +917,12 @@ type RaindropAISDKOptions = {
800
917
  */
801
918
  writeKey?: string;
802
919
  endpoint?: string;
920
+ /**
921
+ * Optional Raindrop project slug. When set, every outbound cloud request
922
+ * carries an `X-Raindrop-Project-Id` header. Unset → no header (the project
923
+ * resolves to `default` server-side; byte-identical to prior behavior).
924
+ */
925
+ projectId?: string;
803
926
  /**
804
927
  * Force-enable (or opt out of) Workshop / local-debugger mirroring.
805
928
  *
@@ -859,6 +982,17 @@ type RaindropAISDKOptions = {
859
982
  partialFlushMs?: number;
860
983
  debug?: boolean;
861
984
  };
985
+ /**
986
+ * Per-field character cap applied to ai input/output text and serialized
987
+ * tool/LLM span payloads BEFORE (or during) serialization, so oversized
988
+ * payloads cost the cap — not the payload — on the calling thread.
989
+ * Truncated values end with `...[truncated by raindrop]` and never exceed
990
+ * the cap. A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is
991
+ * honored. Applies module-wide: the last `createRaindropAISDK` call that
992
+ * sets this option wins; omitting it leaves the current cap unchanged.
993
+ * Defaults to 1,000,000.
994
+ */
995
+ maxTextFieldChars?: number;
862
996
  };
863
997
  type RaindropAISDKContext = {
864
998
  userId?: string;
@@ -1186,4 +1320,4 @@ type RaindropTelemetryOptions = RaindropAISDKOptions & {
1186
1320
  */
1187
1321
  declare function raindrop(options?: RaindropTelemetryOptions): RaindropTelemetryIntegration;
1188
1322
 
1189
- export { raindrop as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_REDACT_ATTRIBUTE_KEYS as D, type EndSpanArgs as E, type WrappedAI as F, type WrappedAISDK as G, _resetRaindropCallMetadataStorage as H, type IdentifyInput as I, _resetWarnedMissingUserId as J, clearParentToolContext as K, createRaindropAISDK as L, currentSpan as M, defaultTransformSpan as N, type OtlpAnyValue as O, type ParentToolContext as P, enterParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, type TraceSpan as T, eventMetadata as U, eventMetadataFromChatRequest as V, type WrapAISDKOptions as W, getContextManager as X, getCurrentParentToolContext as Y, getCurrentRaindropCallMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, readRaindropCallMetadataFromArgs as a0, redactJsonAttributeValue as a1, redactSecretsInObject as a2, runWithParentToolContext as a3, runWithRaindropCallMetadata as a4, withCurrent as a5, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_SECRET_KEY_NAMES as h, type EventBuilder as i, type EventMetadataOptions as j, type OtlpSpan as k, type RaindropAISDKClient as l, type RaindropAISDKContext as m, type RaindropAISDKOptions as n, type RaindropCallMetadata as o, RaindropTelemetryIntegration as p, type RaindropTelemetryIntegrationOptions as q, type RaindropTelemetryOptions as r, type SelfDiagnosticsSignalDefinition as s, type SelfDiagnosticsSignalDefinitions as t, type SelfDiagnosticsTool as u, type SelfDiagnosticsToolInput as v, type SelfDiagnosticsToolOptions as w, type SelfDiagnosticsToolResult as x, type StartSpanArgs as y, type TransformSpanHook as z };
1323
+ export { eventMetadataFromChatRequest as $, type AISDKChatRequestLike as A, type BuildEventPatch as B, ContextManager as C, DEFAULT_MAX_TEXT_FIELD_CHARS as D, type EndSpanArgs as E, type TraceSpan as F, type TransformSpanHook as G, type WrappedAI as H, type IdentifyInput as I, type WrappedAISDK as J, _resetRaindropCallMetadataStorage as K, _resetWarnedMissingUserId as L, boundedStringify as M, capText as N, type OtlpAnyValue as O, type ParentToolContext as P, clearParentToolContext as Q, REDACTED_PLACEHOLDER as R, type SelfDiagnosticsOptions as S, TRUNCATION_MARKER as T, createRaindropAISDK as U, currentSpan as V, type WrapAISDKOptions as W, defaultTransformSpan as X, enterParentToolContext as Y, eventMetadata as Z, _resetParentToolContextStorage as _, type AISDKChatRequestMessageLike as a, getContextManager as a0, getCurrentParentToolContext as a1, getCurrentRaindropCallMetadata as a2, raindrop as a3, readRaindropCallMetadataFromArgs as a4, redactJsonAttributeValue as a5, redactSecretsInObject as a6, runWithParentToolContext as a7, runWithRaindropCallMetadata as a8, withCurrent as a9, type AISDKMessage as b, type AgentCallMetadata as c, type AgentWithMetadata as d, type Attachment as e, type ContextSpan as f, type CreateSpanArgs as g, DEFAULT_REDACT_ATTRIBUTE_KEYS as h, DEFAULT_SECRET_KEY_NAMES as i, type EventBuilder as j, type EventMetadataOptions as k, type OtlpSpan as l, type RaindropAISDKClient as m, type RaindropAISDKContext as n, type RaindropAISDKOptions as o, type RaindropCallMetadata as p, RaindropTelemetryIntegration as q, type RaindropTelemetryIntegrationOptions as r, type RaindropTelemetryOptions as s, type SelfDiagnosticsSignalDefinition as t, type SelfDiagnosticsSignalDefinitions as u, type SelfDiagnosticsTool as v, type SelfDiagnosticsToolInput as w, type SelfDiagnosticsToolOptions as x, type SelfDiagnosticsToolResult as y, type StartSpanArgs as z };