@raindrop-ai/claude-code 0.0.17 → 0.0.19
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/.claude-plugin/plugin.json +1 -1
- package/dist/cli.js +407 -62
- package/dist/index.cjs +387 -44
- package/dist/index.d.cts +55 -9
- package/dist/index.d.ts +55 -9
- package/dist/index.js +387 -44
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,10 @@ type IdentifyInput = {
|
|
|
45
45
|
userId: string;
|
|
46
46
|
traits?: Record<string, unknown>;
|
|
47
47
|
};
|
|
48
|
+
type EventUsage = {
|
|
49
|
+
promptTokens?: number;
|
|
50
|
+
completionTokens?: number;
|
|
51
|
+
};
|
|
48
52
|
type Patch = {
|
|
49
53
|
eventName?: string;
|
|
50
54
|
userId?: string;
|
|
@@ -52,7 +56,10 @@ type Patch = {
|
|
|
52
56
|
input?: string;
|
|
53
57
|
output?: string;
|
|
54
58
|
model?: string;
|
|
59
|
+
usage?: EventUsage;
|
|
60
|
+
error?: unknown;
|
|
55
61
|
properties?: Record<string, unknown>;
|
|
62
|
+
featureFlags?: Record<string, string>;
|
|
56
63
|
attachments?: Attachment[];
|
|
57
64
|
isPending?: boolean;
|
|
58
65
|
timestamp?: string;
|
|
@@ -149,12 +156,7 @@ declare class EventShipper$1 {
|
|
|
149
156
|
*/
|
|
150
157
|
private requestOpts;
|
|
151
158
|
patch(eventId: string, patch: Patch): Promise<void>;
|
|
152
|
-
finish(eventId: string, patch:
|
|
153
|
-
output?: string;
|
|
154
|
-
model?: string;
|
|
155
|
-
properties?: Record<string, unknown>;
|
|
156
|
-
userId?: string;
|
|
157
|
-
}): Promise<void>;
|
|
159
|
+
finish(eventId: string, patch: Pick<Patch, "output" | "model" | "usage" | "error" | "properties" | "featureFlags" | "userId">): Promise<void>;
|
|
158
160
|
flush(): Promise<void>;
|
|
159
161
|
shutdown(): Promise<void>;
|
|
160
162
|
trackSignal(signal: SignalInput): Promise<void>;
|
|
@@ -327,6 +329,9 @@ declare class TraceShipper$1 {
|
|
|
327
329
|
spanIdB64: string;
|
|
328
330
|
};
|
|
329
331
|
eventId: string;
|
|
332
|
+
userId?: string;
|
|
333
|
+
convoId?: string;
|
|
334
|
+
eventName?: string;
|
|
330
335
|
operationId?: string;
|
|
331
336
|
attributes?: Array<OtlpKeyValue | undefined>;
|
|
332
337
|
startTimeUnixNano?: string;
|
|
@@ -345,6 +350,9 @@ declare class TraceShipper$1 {
|
|
|
345
350
|
spanIdB64: string;
|
|
346
351
|
};
|
|
347
352
|
eventId: string;
|
|
353
|
+
userId?: string;
|
|
354
|
+
convoId?: string;
|
|
355
|
+
eventName?: string;
|
|
348
356
|
startTimeUnixNano: string;
|
|
349
357
|
endTimeUnixNano: string;
|
|
350
358
|
attributes?: Array<OtlpKeyValue | undefined>;
|
|
@@ -357,6 +365,42 @@ declare class TraceShipper$1 {
|
|
|
357
365
|
shutdown(): Promise<void>;
|
|
358
366
|
}
|
|
359
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Run telemetry egress with OpenTelemetry tracing suppressed.
|
|
370
|
+
*
|
|
371
|
+
* Why this exists
|
|
372
|
+
* ---------------
|
|
373
|
+
* Raindrop integrations ship spans/events over HTTP with the global `fetch`
|
|
374
|
+
* (see {@link ../http.ts `postJson`}). When the host app also runs an OTel
|
|
375
|
+
* fetch/undici instrumentation — e.g. `@vercel/otel`'s `registerOTel`, which
|
|
376
|
+
* every Eve agent installs — that instrumentation wraps *our own* telemetry
|
|
377
|
+
* POSTs in a `fetch POST <endpoint>` span. Those spans are then handed to the
|
|
378
|
+
* very exporter that issued the request, so they get shipped right back to
|
|
379
|
+
* Raindrop and Workshop as standalone "runs" (and, because each export issues
|
|
380
|
+
* another fetch, they feed back on themselves). The result is a run list
|
|
381
|
+
* flooded with `fetch POST .../v1/traces`, `.../events/track_partial` and
|
|
382
|
+
* `.../live` entries that drown out the real agent turns — especially with
|
|
383
|
+
* sub-agents, where every sandbox runs its own instrumentation.
|
|
384
|
+
*
|
|
385
|
+
* The OTel-blessed fix is to mark the active context as "tracing suppressed"
|
|
386
|
+
* around the request; instrumentations check `isTracingSuppressed` and return
|
|
387
|
+
* a no-op span instead of recording one. We do this through a hook stashed on
|
|
388
|
+
* `globalThis` by the Node entrypoint ({@link ../index.node.ts}) so that:
|
|
389
|
+
* - `@opentelemetry/api` / `@opentelemetry/core` stay *optional* — core never
|
|
390
|
+
* hard-depends on them, and the hook is simply absent when they (and thus
|
|
391
|
+
* any instrumentation to suppress) are not installed; and
|
|
392
|
+
* - the browser bundle never pulls in `node:module`, mirroring how core
|
|
393
|
+
* injects `AsyncLocalStorage` via `RAINDROP_ASYNC_LOCAL_STORAGE`.
|
|
394
|
+
*
|
|
395
|
+
* When no hook is present the callback runs unchanged, so suppression is a
|
|
396
|
+
* best-effort no-op rather than a hard requirement.
|
|
397
|
+
*/
|
|
398
|
+
/** Hook signature: run `fn` with OTel tracing suppressed, returning its value. */
|
|
399
|
+
type SuppressTracingHook = <T>(fn: () => T) => T;
|
|
400
|
+
declare global {
|
|
401
|
+
var RAINDROP_SUPPRESS_TRACING: SuppressTracingHook | undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
360
404
|
type ParentSpanContext = {
|
|
361
405
|
traceIdB64: string;
|
|
362
406
|
spanIdB64: string;
|
|
@@ -489,7 +533,7 @@ declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, e
|
|
|
489
533
|
declare function extractAppendSystemPrompt(args: string[]): string | undefined;
|
|
490
534
|
|
|
491
535
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
492
|
-
declare const PACKAGE_VERSION
|
|
536
|
+
declare const PACKAGE_VERSION: string;
|
|
493
537
|
|
|
494
538
|
/** A tool call extracted from an assistant message content block. */
|
|
495
539
|
interface LLMToolCall {
|
|
@@ -583,9 +627,11 @@ interface LocalDebuggerResult {
|
|
|
583
627
|
declare function detectLocalDebugger(debug: boolean): Promise<LocalDebuggerResult>;
|
|
584
628
|
/**
|
|
585
629
|
* Mirror an event payload to the local debugger's track_partial endpoint.
|
|
586
|
-
*
|
|
630
|
+
* Must be awaited: Claude Code hooks call process.exit as soon as handleHook
|
|
631
|
+
* returns, so a fire-and-forget fetch is killed before it leaves the socket.
|
|
632
|
+
* Errors are swallowed — observability must never fail the hook.
|
|
587
633
|
*/
|
|
588
|
-
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): void
|
|
634
|
+
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): Promise<void>;
|
|
589
635
|
|
|
590
636
|
interface ResolvedSignal {
|
|
591
637
|
description: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,10 @@ type IdentifyInput = {
|
|
|
45
45
|
userId: string;
|
|
46
46
|
traits?: Record<string, unknown>;
|
|
47
47
|
};
|
|
48
|
+
type EventUsage = {
|
|
49
|
+
promptTokens?: number;
|
|
50
|
+
completionTokens?: number;
|
|
51
|
+
};
|
|
48
52
|
type Patch = {
|
|
49
53
|
eventName?: string;
|
|
50
54
|
userId?: string;
|
|
@@ -52,7 +56,10 @@ type Patch = {
|
|
|
52
56
|
input?: string;
|
|
53
57
|
output?: string;
|
|
54
58
|
model?: string;
|
|
59
|
+
usage?: EventUsage;
|
|
60
|
+
error?: unknown;
|
|
55
61
|
properties?: Record<string, unknown>;
|
|
62
|
+
featureFlags?: Record<string, string>;
|
|
56
63
|
attachments?: Attachment[];
|
|
57
64
|
isPending?: boolean;
|
|
58
65
|
timestamp?: string;
|
|
@@ -149,12 +156,7 @@ declare class EventShipper$1 {
|
|
|
149
156
|
*/
|
|
150
157
|
private requestOpts;
|
|
151
158
|
patch(eventId: string, patch: Patch): Promise<void>;
|
|
152
|
-
finish(eventId: string, patch:
|
|
153
|
-
output?: string;
|
|
154
|
-
model?: string;
|
|
155
|
-
properties?: Record<string, unknown>;
|
|
156
|
-
userId?: string;
|
|
157
|
-
}): Promise<void>;
|
|
159
|
+
finish(eventId: string, patch: Pick<Patch, "output" | "model" | "usage" | "error" | "properties" | "featureFlags" | "userId">): Promise<void>;
|
|
158
160
|
flush(): Promise<void>;
|
|
159
161
|
shutdown(): Promise<void>;
|
|
160
162
|
trackSignal(signal: SignalInput): Promise<void>;
|
|
@@ -327,6 +329,9 @@ declare class TraceShipper$1 {
|
|
|
327
329
|
spanIdB64: string;
|
|
328
330
|
};
|
|
329
331
|
eventId: string;
|
|
332
|
+
userId?: string;
|
|
333
|
+
convoId?: string;
|
|
334
|
+
eventName?: string;
|
|
330
335
|
operationId?: string;
|
|
331
336
|
attributes?: Array<OtlpKeyValue | undefined>;
|
|
332
337
|
startTimeUnixNano?: string;
|
|
@@ -345,6 +350,9 @@ declare class TraceShipper$1 {
|
|
|
345
350
|
spanIdB64: string;
|
|
346
351
|
};
|
|
347
352
|
eventId: string;
|
|
353
|
+
userId?: string;
|
|
354
|
+
convoId?: string;
|
|
355
|
+
eventName?: string;
|
|
348
356
|
startTimeUnixNano: string;
|
|
349
357
|
endTimeUnixNano: string;
|
|
350
358
|
attributes?: Array<OtlpKeyValue | undefined>;
|
|
@@ -357,6 +365,42 @@ declare class TraceShipper$1 {
|
|
|
357
365
|
shutdown(): Promise<void>;
|
|
358
366
|
}
|
|
359
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Run telemetry egress with OpenTelemetry tracing suppressed.
|
|
370
|
+
*
|
|
371
|
+
* Why this exists
|
|
372
|
+
* ---------------
|
|
373
|
+
* Raindrop integrations ship spans/events over HTTP with the global `fetch`
|
|
374
|
+
* (see {@link ../http.ts `postJson`}). When the host app also runs an OTel
|
|
375
|
+
* fetch/undici instrumentation — e.g. `@vercel/otel`'s `registerOTel`, which
|
|
376
|
+
* every Eve agent installs — that instrumentation wraps *our own* telemetry
|
|
377
|
+
* POSTs in a `fetch POST <endpoint>` span. Those spans are then handed to the
|
|
378
|
+
* very exporter that issued the request, so they get shipped right back to
|
|
379
|
+
* Raindrop and Workshop as standalone "runs" (and, because each export issues
|
|
380
|
+
* another fetch, they feed back on themselves). The result is a run list
|
|
381
|
+
* flooded with `fetch POST .../v1/traces`, `.../events/track_partial` and
|
|
382
|
+
* `.../live` entries that drown out the real agent turns — especially with
|
|
383
|
+
* sub-agents, where every sandbox runs its own instrumentation.
|
|
384
|
+
*
|
|
385
|
+
* The OTel-blessed fix is to mark the active context as "tracing suppressed"
|
|
386
|
+
* around the request; instrumentations check `isTracingSuppressed` and return
|
|
387
|
+
* a no-op span instead of recording one. We do this through a hook stashed on
|
|
388
|
+
* `globalThis` by the Node entrypoint ({@link ../index.node.ts}) so that:
|
|
389
|
+
* - `@opentelemetry/api` / `@opentelemetry/core` stay *optional* — core never
|
|
390
|
+
* hard-depends on them, and the hook is simply absent when they (and thus
|
|
391
|
+
* any instrumentation to suppress) are not installed; and
|
|
392
|
+
* - the browser bundle never pulls in `node:module`, mirroring how core
|
|
393
|
+
* injects `AsyncLocalStorage` via `RAINDROP_ASYNC_LOCAL_STORAGE`.
|
|
394
|
+
*
|
|
395
|
+
* When no hook is present the callback runs unchanged, so suppression is a
|
|
396
|
+
* best-effort no-op rather than a hard requirement.
|
|
397
|
+
*/
|
|
398
|
+
/** Hook signature: run `fn` with OTel tracing suppressed, returning its value. */
|
|
399
|
+
type SuppressTracingHook = <T>(fn: () => T) => T;
|
|
400
|
+
declare global {
|
|
401
|
+
var RAINDROP_SUPPRESS_TRACING: SuppressTracingHook | undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
360
404
|
type ParentSpanContext = {
|
|
361
405
|
traceIdB64: string;
|
|
362
406
|
spanIdB64: string;
|
|
@@ -489,7 +533,7 @@ declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, e
|
|
|
489
533
|
declare function extractAppendSystemPrompt(args: string[]): string | undefined;
|
|
490
534
|
|
|
491
535
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
492
|
-
declare const PACKAGE_VERSION
|
|
536
|
+
declare const PACKAGE_VERSION: string;
|
|
493
537
|
|
|
494
538
|
/** A tool call extracted from an assistant message content block. */
|
|
495
539
|
interface LLMToolCall {
|
|
@@ -583,9 +627,11 @@ interface LocalDebuggerResult {
|
|
|
583
627
|
declare function detectLocalDebugger(debug: boolean): Promise<LocalDebuggerResult>;
|
|
584
628
|
/**
|
|
585
629
|
* Mirror an event payload to the local debugger's track_partial endpoint.
|
|
586
|
-
*
|
|
630
|
+
* Must be awaited: Claude Code hooks call process.exit as soon as handleHook
|
|
631
|
+
* returns, so a fire-and-forget fetch is killed before it leaves the socket.
|
|
632
|
+
* Errors are swallowed — observability must never fail the hook.
|
|
587
633
|
*/
|
|
588
|
-
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): void
|
|
634
|
+
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): Promise<void>;
|
|
589
635
|
|
|
590
636
|
interface ResolvedSignal {
|
|
591
637
|
description: string;
|