@raindrop-ai/claude-code 0.0.13 → 0.0.14

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/dist/index.d.cts CHANGED
@@ -35,7 +35,6 @@ type SpanIds = {
35
35
  spanIdB64: string;
36
36
  parentSpanIdB64?: string;
37
37
  };
38
-
39
38
  type Attachment = {
40
39
  type: string;
41
40
  role: string;
@@ -79,6 +78,19 @@ type EventShipperOptions = {
79
78
  libraryName?: string;
80
79
  libraryVersion?: string;
81
80
  defaultEventName?: string;
81
+ /**
82
+ * Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
83
+ * Pass `null` to opt out of all mirroring (including auto-detect).
84
+ */
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;
82
94
  };
83
95
  declare class EventShipper$1 {
84
96
  private baseUrl;
@@ -94,9 +106,39 @@ declare class EventShipper$1 {
94
106
  private sticky;
95
107
  private timers;
96
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;
122
+ /** URL of the local debugger / Workshop daemon, when one is reachable. */
123
+ private localDebuggerUrl;
97
124
  constructor(opts: EventShipperOptions);
98
125
  isDebugEnabled(): boolean;
99
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;
100
142
  patch(eventId: string, patch: Patch): Promise<void>;
101
143
  finish(eventId: string, patch: {
102
144
  output?: string;
@@ -108,8 +150,26 @@ declare class EventShipper$1 {
108
150
  shutdown(): Promise<void>;
109
151
  trackSignal(signal: SignalInput): Promise<void>;
110
152
  identify(users: IdentifyInput | IdentifyInput[]): Promise<void>;
153
+ private warnShutdownDrop;
111
154
  private flushOne;
112
155
  }
156
+ /**
157
+ * Hook fired per OTLP span right before the span is shipped (to the Raindrop
158
+ * API and to a local debugger). Lets callers inspect, rewrite, or drop the
159
+ * entire span — not just individual attributes — which is more flexible than
160
+ * an attribute-level hook (you can rename attributes, add new ones, drop the
161
+ * span outright, etc.).
162
+ *
163
+ * Return values:
164
+ * - `undefined` or the same span: ship the span unchanged.
165
+ * - a new `OtlpSpan`: ship the returned span in place of the original.
166
+ * - `null`: drop the span entirely from every ship path.
167
+ *
168
+ * The hook runs on the hot path — keep it synchronous and side-effect-free.
169
+ * If the hook throws, the span is dropped (fail-closed) so a buggy hook can
170
+ * never accidentally ship raw, un-redacted spans.
171
+ */
172
+ type TransformSpanHook = (span: OtlpSpan) => OtlpSpan | null | undefined;
113
173
 
114
174
  type InternalSpan = {
115
175
  ids: SpanIds;
@@ -130,6 +190,54 @@ type TraceShipperOptions = {
130
190
  sdkName?: string;
131
191
  serviceName?: string;
132
192
  serviceVersion?: string;
193
+ /**
194
+ * Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
195
+ * Pass `null` to opt out of all mirroring (including auto-detect).
196
+ */
197
+ localDebuggerUrl?: string | null;
198
+ /**
199
+ * Per-span hook that fires for every OTLP span right before the span is
200
+ * shipped (both to the Raindrop API and to a local debugger). Lets callers
201
+ * inspect, rewrite, or drop entire spans — rename attributes, add new ones,
202
+ * scrub additional secret-shaped values inside `ai.prompt.messages` /
203
+ * `ai.toolCall.args`, etc.
204
+ *
205
+ * Return values:
206
+ * - `undefined` or the same span reference: ship the span unchanged.
207
+ * - a new `OtlpSpan`: ship the returned span in place of the original.
208
+ * - `null`: drop the span entirely from every ship path.
209
+ *
210
+ * The hook runs BEFORE the default redactor (which is the always-on floor
211
+ * for documented BYOK secrets). The default redactor still runs on the
212
+ * post-transform span unless `disableDefaultRedaction` is set, so even if
213
+ * a custom transform overlooks a secret-shaped attribute, the floor catches
214
+ * it.
215
+ *
216
+ * The hook runs on the hot path — keep it synchronous and side-effect-free.
217
+ * If the hook itself throws, the span is dropped (fail-closed) so a buggy
218
+ * hook can never accidentally ship raw, un-redacted spans.
219
+ */
220
+ transformSpan?: TransformSpanHook;
221
+ /**
222
+ * Disable the built-in default span transformer (which scrubs documented
223
+ * secret-shaped properties — `apiKey`, `secretAccessKey`, `privateKey`,
224
+ * etc. — inside `ai.request.providerOptions` and
225
+ * `ai.response.providerMetadata`).
226
+ *
227
+ * Default: `false` (i.e. default redaction is on). Setting this to `true`
228
+ * disables the floor entirely; provide a custom `transformSpan` if you
229
+ * still want some redaction in that case.
230
+ */
231
+ disableDefaultRedaction?: boolean;
232
+ /**
233
+ * Per-attribute character cap applied to every span attribute string value
234
+ * right before the span enters a ship path, so a multi-MB prompt/tool
235
+ * payload can never make the batch `JSON.stringify` (which runs on the
236
+ * event loop) cost seconds. Truncated values end with
237
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
238
+ * Defaults to 1,000,000 (matching the Python SDK).
239
+ */
240
+ maxTextFieldChars?: number;
133
241
  };
134
242
  declare class TraceShipper$1 {
135
243
  private baseUrl;
@@ -147,9 +255,51 @@ declare class TraceShipper$1 {
147
255
  private queue;
148
256
  private timer;
149
257
  private inFlight;
150
- /** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
258
+ /** URL of the local debugger / Workshop daemon, when one is reachable. */
151
259
  private localDebuggerUrl;
260
+ private transformSpanHook;
261
+ private disableDefaultRedaction;
262
+ private maxTextFieldCharsOpt;
263
+ /**
264
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
265
+ * Checked before every batch POST issued during the final flush.
266
+ */
267
+ private shutdownDeadlineAt;
268
+ /**
269
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
270
+ * drain window (stragglers, or flush work the deadline abandoned
271
+ * mid-drain) run as a single short attempt instead of regaining the full
272
+ * retry schedule.
273
+ */
274
+ private hasShutdown;
152
275
  constructor(opts: TraceShipperOptions);
276
+ /**
277
+ * Cap every string attribute value on the span. O(#attributes) length
278
+ * checks; only oversized values pay a slice. Runs AFTER the redaction
279
+ * pipeline so the default secret-scrub still sees parseable JSON in
280
+ * `ai.request.providerOptions` / `ai.response.providerMetadata` (capping
281
+ * first could cut a JSON blob mid-way, fail the parse, and ship secrets
282
+ * in the surviving prefix).
283
+ *
284
+ * A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored
285
+ * for span content, matching the Python SDK and the OTel SDK convention.
286
+ */
287
+ private capSpanAttributes;
288
+ /**
289
+ * Apply the user `transformSpan` hook (if any) followed by the default
290
+ * redactor (unless disabled). Returns either the (possibly new) span to
291
+ * ship, or `null` to drop the span entirely.
292
+ *
293
+ * Ordering: user hook runs first so callers can rewrite the span freely
294
+ * (rename attrs, add new ones, scrub things the default doesn't know
295
+ * about). The default redactor then runs on whatever the user produced,
296
+ * acting as the always-on floor for documented BYOK secrets. If the user
297
+ * sets `disableDefaultRedaction: true`, the floor is skipped.
298
+ *
299
+ * Fail-closed: if the user hook throws, the span is dropped — a buggy
300
+ * hook can never accidentally ship raw, un-redacted spans.
301
+ */
302
+ private redactSpan;
153
303
  isDebugEnabled(): boolean;
154
304
  private authHeaders;
155
305
  startSpan(args: {
@@ -163,6 +313,7 @@ declare class TraceShipper$1 {
163
313
  attributes?: Array<OtlpKeyValue | undefined>;
164
314
  startTimeUnixNano?: string;
165
315
  }): InternalSpan;
316
+ private mirrorToLocalDebugger;
166
317
  endSpan(span: InternalSpan, extra?: {
167
318
  attributes?: InternalSpan["attributes"];
168
319
  error?: unknown;
@@ -183,6 +334,8 @@ declare class TraceShipper$1 {
183
334
  }): void;
184
335
  enqueue(span: OtlpSpan): void;
185
336
  flush(): Promise<void>;
337
+ /** See EventShipper.requestOpts — same shutdown-budget semantics. */
338
+ private requestOpts;
186
339
  shutdown(): Promise<void>;
187
340
  }
188
341
 
package/dist/index.d.ts CHANGED
@@ -35,7 +35,6 @@ type SpanIds = {
35
35
  spanIdB64: string;
36
36
  parentSpanIdB64?: string;
37
37
  };
38
-
39
38
  type Attachment = {
40
39
  type: string;
41
40
  role: string;
@@ -79,6 +78,19 @@ type EventShipperOptions = {
79
78
  libraryName?: string;
80
79
  libraryVersion?: string;
81
80
  defaultEventName?: string;
81
+ /**
82
+ * Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
83
+ * Pass `null` to opt out of all mirroring (including auto-detect).
84
+ */
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;
82
94
  };
83
95
  declare class EventShipper$1 {
84
96
  private baseUrl;
@@ -94,9 +106,39 @@ declare class EventShipper$1 {
94
106
  private sticky;
95
107
  private timers;
96
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;
122
+ /** URL of the local debugger / Workshop daemon, when one is reachable. */
123
+ private localDebuggerUrl;
97
124
  constructor(opts: EventShipperOptions);
98
125
  isDebugEnabled(): boolean;
99
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;
100
142
  patch(eventId: string, patch: Patch): Promise<void>;
101
143
  finish(eventId: string, patch: {
102
144
  output?: string;
@@ -108,8 +150,26 @@ declare class EventShipper$1 {
108
150
  shutdown(): Promise<void>;
109
151
  trackSignal(signal: SignalInput): Promise<void>;
110
152
  identify(users: IdentifyInput | IdentifyInput[]): Promise<void>;
153
+ private warnShutdownDrop;
111
154
  private flushOne;
112
155
  }
156
+ /**
157
+ * Hook fired per OTLP span right before the span is shipped (to the Raindrop
158
+ * API and to a local debugger). Lets callers inspect, rewrite, or drop the
159
+ * entire span — not just individual attributes — which is more flexible than
160
+ * an attribute-level hook (you can rename attributes, add new ones, drop the
161
+ * span outright, etc.).
162
+ *
163
+ * Return values:
164
+ * - `undefined` or the same span: ship the span unchanged.
165
+ * - a new `OtlpSpan`: ship the returned span in place of the original.
166
+ * - `null`: drop the span entirely from every ship path.
167
+ *
168
+ * The hook runs on the hot path — keep it synchronous and side-effect-free.
169
+ * If the hook throws, the span is dropped (fail-closed) so a buggy hook can
170
+ * never accidentally ship raw, un-redacted spans.
171
+ */
172
+ type TransformSpanHook = (span: OtlpSpan) => OtlpSpan | null | undefined;
113
173
 
114
174
  type InternalSpan = {
115
175
  ids: SpanIds;
@@ -130,6 +190,54 @@ type TraceShipperOptions = {
130
190
  sdkName?: string;
131
191
  serviceName?: string;
132
192
  serviceVersion?: string;
193
+ /**
194
+ * Explicit Workshop / local debugger URL. Wins over env vars + auto-detect.
195
+ * Pass `null` to opt out of all mirroring (including auto-detect).
196
+ */
197
+ localDebuggerUrl?: string | null;
198
+ /**
199
+ * Per-span hook that fires for every OTLP span right before the span is
200
+ * shipped (both to the Raindrop API and to a local debugger). Lets callers
201
+ * inspect, rewrite, or drop entire spans — rename attributes, add new ones,
202
+ * scrub additional secret-shaped values inside `ai.prompt.messages` /
203
+ * `ai.toolCall.args`, etc.
204
+ *
205
+ * Return values:
206
+ * - `undefined` or the same span reference: ship the span unchanged.
207
+ * - a new `OtlpSpan`: ship the returned span in place of the original.
208
+ * - `null`: drop the span entirely from every ship path.
209
+ *
210
+ * The hook runs BEFORE the default redactor (which is the always-on floor
211
+ * for documented BYOK secrets). The default redactor still runs on the
212
+ * post-transform span unless `disableDefaultRedaction` is set, so even if
213
+ * a custom transform overlooks a secret-shaped attribute, the floor catches
214
+ * it.
215
+ *
216
+ * The hook runs on the hot path — keep it synchronous and side-effect-free.
217
+ * If the hook itself throws, the span is dropped (fail-closed) so a buggy
218
+ * hook can never accidentally ship raw, un-redacted spans.
219
+ */
220
+ transformSpan?: TransformSpanHook;
221
+ /**
222
+ * Disable the built-in default span transformer (which scrubs documented
223
+ * secret-shaped properties — `apiKey`, `secretAccessKey`, `privateKey`,
224
+ * etc. — inside `ai.request.providerOptions` and
225
+ * `ai.response.providerMetadata`).
226
+ *
227
+ * Default: `false` (i.e. default redaction is on). Setting this to `true`
228
+ * disables the floor entirely; provide a custom `transformSpan` if you
229
+ * still want some redaction in that case.
230
+ */
231
+ disableDefaultRedaction?: boolean;
232
+ /**
233
+ * Per-attribute character cap applied to every span attribute string value
234
+ * right before the span enters a ship path, so a multi-MB prompt/tool
235
+ * payload can never make the batch `JSON.stringify` (which runs on the
236
+ * event loop) cost seconds. Truncated values end with
237
+ * `...[truncated by raindrop]` and never exceed the cap, marker included.
238
+ * Defaults to 1,000,000 (matching the Python SDK).
239
+ */
240
+ maxTextFieldChars?: number;
133
241
  };
134
242
  declare class TraceShipper$1 {
135
243
  private baseUrl;
@@ -147,9 +255,51 @@ declare class TraceShipper$1 {
147
255
  private queue;
148
256
  private timer;
149
257
  private inFlight;
150
- /** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
258
+ /** URL of the local debugger / Workshop daemon, when one is reachable. */
151
259
  private localDebuggerUrl;
260
+ private transformSpanHook;
261
+ private disableDefaultRedaction;
262
+ private maxTextFieldCharsOpt;
263
+ /**
264
+ * Epoch ms deadline while `shutdown()` is draining; undefined otherwise.
265
+ * Checked before every batch POST issued during the final flush.
266
+ */
267
+ private shutdownDeadlineAt;
268
+ /**
269
+ * Set once `shutdown()` begins and never cleared. Sends issued after the
270
+ * drain window (stragglers, or flush work the deadline abandoned
271
+ * mid-drain) run as a single short attempt instead of regaining the full
272
+ * retry schedule.
273
+ */
274
+ private hasShutdown;
152
275
  constructor(opts: TraceShipperOptions);
276
+ /**
277
+ * Cap every string attribute value on the span. O(#attributes) length
278
+ * checks; only oversized values pay a slice. Runs AFTER the redaction
279
+ * pipeline so the default secret-scrub still sees parseable JSON in
280
+ * `ai.request.providerOptions` / `ai.response.providerMetadata` (capping
281
+ * first could cut a JSON blob mid-way, fail the parse, and ship secrets
282
+ * in the surviving prefix).
283
+ *
284
+ * A stricter `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` env var is honored
285
+ * for span content, matching the Python SDK and the OTel SDK convention.
286
+ */
287
+ private capSpanAttributes;
288
+ /**
289
+ * Apply the user `transformSpan` hook (if any) followed by the default
290
+ * redactor (unless disabled). Returns either the (possibly new) span to
291
+ * ship, or `null` to drop the span entirely.
292
+ *
293
+ * Ordering: user hook runs first so callers can rewrite the span freely
294
+ * (rename attrs, add new ones, scrub things the default doesn't know
295
+ * about). The default redactor then runs on whatever the user produced,
296
+ * acting as the always-on floor for documented BYOK secrets. If the user
297
+ * sets `disableDefaultRedaction: true`, the floor is skipped.
298
+ *
299
+ * Fail-closed: if the user hook throws, the span is dropped — a buggy
300
+ * hook can never accidentally ship raw, un-redacted spans.
301
+ */
302
+ private redactSpan;
153
303
  isDebugEnabled(): boolean;
154
304
  private authHeaders;
155
305
  startSpan(args: {
@@ -163,6 +313,7 @@ declare class TraceShipper$1 {
163
313
  attributes?: Array<OtlpKeyValue | undefined>;
164
314
  startTimeUnixNano?: string;
165
315
  }): InternalSpan;
316
+ private mirrorToLocalDebugger;
166
317
  endSpan(span: InternalSpan, extra?: {
167
318
  attributes?: InternalSpan["attributes"];
168
319
  error?: unknown;
@@ -183,6 +334,8 @@ declare class TraceShipper$1 {
183
334
  }): void;
184
335
  enqueue(span: OtlpSpan): void;
185
336
  flush(): Promise<void>;
337
+ /** See EventShipper.requestOpts — same shutdown-budget semantics. */
338
+ private requestOpts;
186
339
  shutdown(): Promise<void>;
187
340
  }
188
341