@raindrop-ai/claude-code 0.0.4 → 0.0.6
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 +20 -0
- package/dist/cli.js +713 -39
- package/dist/index.cjs +705 -26
- package/dist/index.d.cts +119 -2
- package/dist/index.d.ts +119 -2
- package/dist/index.js +690 -21
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -221,6 +221,15 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
221
221
|
enqueue(span: OtlpSpan): void;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
interface SelfDiagnosticsSignalDef {
|
|
225
|
+
description: string;
|
|
226
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
227
|
+
}
|
|
228
|
+
interface SelfDiagnosticsConfig {
|
|
229
|
+
signals?: Record<string, SelfDiagnosticsSignalDef>;
|
|
230
|
+
guidance?: string;
|
|
231
|
+
toolName?: string;
|
|
232
|
+
}
|
|
224
233
|
interface ConfigFile {
|
|
225
234
|
write_key?: string;
|
|
226
235
|
api_url?: string;
|
|
@@ -229,6 +238,7 @@ interface ConfigFile {
|
|
|
229
238
|
enabled?: boolean;
|
|
230
239
|
event_name?: string;
|
|
231
240
|
custom_properties?: Record<string, unknown>;
|
|
241
|
+
self_diagnostics?: SelfDiagnosticsConfig;
|
|
232
242
|
}
|
|
233
243
|
interface RaindropConfig {
|
|
234
244
|
writeKey: string;
|
|
@@ -238,6 +248,7 @@ interface RaindropConfig {
|
|
|
238
248
|
enabled: boolean;
|
|
239
249
|
eventName: string;
|
|
240
250
|
customProperties: Record<string, unknown>;
|
|
251
|
+
selfDiagnostics?: SelfDiagnosticsConfig;
|
|
241
252
|
}
|
|
242
253
|
/**
|
|
243
254
|
* Load config with precedence (low -> high):
|
|
@@ -275,6 +286,9 @@ interface HookPayload {
|
|
|
275
286
|
agent_transcript_path?: string;
|
|
276
287
|
trigger?: string;
|
|
277
288
|
compact_summary?: string;
|
|
289
|
+
file_path?: string;
|
|
290
|
+
memory_type?: string;
|
|
291
|
+
load_reason?: string;
|
|
278
292
|
}
|
|
279
293
|
interface MapperConfig {
|
|
280
294
|
userId: string;
|
|
@@ -283,9 +297,58 @@ interface MapperConfig {
|
|
|
283
297
|
customProperties: Record<string, unknown>;
|
|
284
298
|
}
|
|
285
299
|
declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, eventShipper: EventShipper, traceShipper: TraceShipper): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Parse command-line args for --append-system-prompt and
|
|
302
|
+
* --append-system-prompt-file flags. Handles both space-separated form
|
|
303
|
+
* (--flag value) and equals form (--flag=value). Supports both flags
|
|
304
|
+
* appearing together (they concatenate).
|
|
305
|
+
*
|
|
306
|
+
* Exported for testing.
|
|
307
|
+
*/
|
|
308
|
+
declare function extractAppendSystemPrompt(args: string[]): string | undefined;
|
|
286
309
|
|
|
287
310
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
288
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
311
|
+
declare const PACKAGE_VERSION = "0.0.6";
|
|
312
|
+
|
|
313
|
+
interface TranscriptSummary {
|
|
314
|
+
/** Aggregated token usage across all turns */
|
|
315
|
+
totalInputTokens: number;
|
|
316
|
+
totalOutputTokens: number;
|
|
317
|
+
totalCacheReadTokens: number;
|
|
318
|
+
totalCacheCreationTokens: number;
|
|
319
|
+
/** Token usage for the most recent turn only */
|
|
320
|
+
lastTurnInputTokens?: number;
|
|
321
|
+
lastTurnOutputTokens?: number;
|
|
322
|
+
lastTurnCacheReadTokens?: number;
|
|
323
|
+
/** Model used (from most recent assistant message) */
|
|
324
|
+
model?: string;
|
|
325
|
+
/** Service tier */
|
|
326
|
+
serviceTier?: string;
|
|
327
|
+
/** Number of API turns (assistant messages) */
|
|
328
|
+
turnCount: number;
|
|
329
|
+
/** Unique tool names used in the session */
|
|
330
|
+
toolsUsed: string[];
|
|
331
|
+
/** Stop reason from last assistant message */
|
|
332
|
+
stopReason?: string;
|
|
333
|
+
/** Total turn duration in ms (from system entries) */
|
|
334
|
+
totalDurationMs?: number;
|
|
335
|
+
/** Claude Code version */
|
|
336
|
+
codeVersion?: string;
|
|
337
|
+
/** Git branch */
|
|
338
|
+
gitBranch?: string;
|
|
339
|
+
/** Whether thinking/reasoning content was used */
|
|
340
|
+
hasThinking: boolean;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Parse a Claude Code transcript JSONL file and extract a summary.
|
|
344
|
+
* Returns undefined if the file doesn't exist or can't be parsed.
|
|
345
|
+
*/
|
|
346
|
+
declare function parseTranscript(transcriptPath: string): TranscriptSummary | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Convert a TranscriptSummary into a flat properties object
|
|
349
|
+
* suitable for merging into event properties.
|
|
350
|
+
*/
|
|
351
|
+
declare function transcriptToProperties(summary: TranscriptSummary): Record<string, unknown>;
|
|
289
352
|
|
|
290
353
|
interface LocalDebuggerResult {
|
|
291
354
|
/** The resolved base URL (e.g. "http://localhost:5899/v1/"), or null if not detected. */
|
|
@@ -308,4 +371,58 @@ declare function detectLocalDebugger(debug: boolean): Promise<LocalDebuggerResul
|
|
|
308
371
|
*/
|
|
309
372
|
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): void;
|
|
310
373
|
|
|
311
|
-
|
|
374
|
+
interface ResolvedSignal {
|
|
375
|
+
description: string;
|
|
376
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Normalize and validate user-provided signal definitions.
|
|
380
|
+
* Returns the default set if input is empty or all entries are invalid.
|
|
381
|
+
* Always appends `noteworthy` as the last category.
|
|
382
|
+
*/
|
|
383
|
+
declare function normalizeSignals(custom?: Record<string, SelfDiagnosticsSignalDef>): Record<string, ResolvedSignal>;
|
|
384
|
+
/**
|
|
385
|
+
* Resolve the full MCP tool configuration from optional user config.
|
|
386
|
+
*/
|
|
387
|
+
declare function resolveToolConfig(diagConfig?: SelfDiagnosticsConfig): {
|
|
388
|
+
signals: Record<string, ResolvedSignal>;
|
|
389
|
+
categoryKeys: string[];
|
|
390
|
+
toolName: string;
|
|
391
|
+
toolDescription: string;
|
|
392
|
+
};
|
|
393
|
+
/** Default category keys (before custom signal config is applied). */
|
|
394
|
+
declare const DEFAULT_CATEGORY_KEYS: string[];
|
|
395
|
+
/**
|
|
396
|
+
* Find the most recently modified event_* file in the state dir.
|
|
397
|
+
* Returns the eventId stored in that file, or undefined.
|
|
398
|
+
*/
|
|
399
|
+
declare function resolveCurrentEventId(): string | undefined;
|
|
400
|
+
declare function executeTool(args: Record<string, unknown>): Promise<{
|
|
401
|
+
content: Array<{
|
|
402
|
+
type: string;
|
|
403
|
+
text: string;
|
|
404
|
+
}>;
|
|
405
|
+
isError?: boolean;
|
|
406
|
+
}>;
|
|
407
|
+
declare const TOOL_SCHEMA: {
|
|
408
|
+
name: string;
|
|
409
|
+
description: string;
|
|
410
|
+
inputSchema: {
|
|
411
|
+
type: "object";
|
|
412
|
+
properties: {
|
|
413
|
+
category: {
|
|
414
|
+
type: "string";
|
|
415
|
+
enum: string[];
|
|
416
|
+
description: string;
|
|
417
|
+
};
|
|
418
|
+
detail: {
|
|
419
|
+
type: "string";
|
|
420
|
+
description: string;
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
required: string[];
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
declare function startMcpServer(): Promise<void>;
|
|
427
|
+
|
|
428
|
+
export { DEFAULT_CATEGORY_KEYS, EventShipper, type HookPayload, type LocalDebuggerResult, type MapperConfig, PACKAGE_NAME, PACKAGE_VERSION, type RaindropConfig, type SelfDiagnosticsConfig, type SelfDiagnosticsSignalDef, type SetupScope, TOOL_SCHEMA, TraceShipper, type TranscriptSummary, detectLocalDebugger, executeTool, extractAppendSystemPrompt, getConfigPath, loadConfig, mapHookToRaindrop, mirrorEventToLocalDebugger, normalizeSignals, parseTranscript, resolveCurrentEventId, resolveToolConfig, startMcpServer, transcriptToProperties, updateConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -221,6 +221,15 @@ declare class TraceShipper extends TraceShipper$1 {
|
|
|
221
221
|
enqueue(span: OtlpSpan): void;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
interface SelfDiagnosticsSignalDef {
|
|
225
|
+
description: string;
|
|
226
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
227
|
+
}
|
|
228
|
+
interface SelfDiagnosticsConfig {
|
|
229
|
+
signals?: Record<string, SelfDiagnosticsSignalDef>;
|
|
230
|
+
guidance?: string;
|
|
231
|
+
toolName?: string;
|
|
232
|
+
}
|
|
224
233
|
interface ConfigFile {
|
|
225
234
|
write_key?: string;
|
|
226
235
|
api_url?: string;
|
|
@@ -229,6 +238,7 @@ interface ConfigFile {
|
|
|
229
238
|
enabled?: boolean;
|
|
230
239
|
event_name?: string;
|
|
231
240
|
custom_properties?: Record<string, unknown>;
|
|
241
|
+
self_diagnostics?: SelfDiagnosticsConfig;
|
|
232
242
|
}
|
|
233
243
|
interface RaindropConfig {
|
|
234
244
|
writeKey: string;
|
|
@@ -238,6 +248,7 @@ interface RaindropConfig {
|
|
|
238
248
|
enabled: boolean;
|
|
239
249
|
eventName: string;
|
|
240
250
|
customProperties: Record<string, unknown>;
|
|
251
|
+
selfDiagnostics?: SelfDiagnosticsConfig;
|
|
241
252
|
}
|
|
242
253
|
/**
|
|
243
254
|
* Load config with precedence (low -> high):
|
|
@@ -275,6 +286,9 @@ interface HookPayload {
|
|
|
275
286
|
agent_transcript_path?: string;
|
|
276
287
|
trigger?: string;
|
|
277
288
|
compact_summary?: string;
|
|
289
|
+
file_path?: string;
|
|
290
|
+
memory_type?: string;
|
|
291
|
+
load_reason?: string;
|
|
278
292
|
}
|
|
279
293
|
interface MapperConfig {
|
|
280
294
|
userId: string;
|
|
@@ -283,9 +297,58 @@ interface MapperConfig {
|
|
|
283
297
|
customProperties: Record<string, unknown>;
|
|
284
298
|
}
|
|
285
299
|
declare function mapHookToRaindrop(payload: HookPayload, config: MapperConfig, eventShipper: EventShipper, traceShipper: TraceShipper): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Parse command-line args for --append-system-prompt and
|
|
302
|
+
* --append-system-prompt-file flags. Handles both space-separated form
|
|
303
|
+
* (--flag value) and equals form (--flag=value). Supports both flags
|
|
304
|
+
* appearing together (they concatenate).
|
|
305
|
+
*
|
|
306
|
+
* Exported for testing.
|
|
307
|
+
*/
|
|
308
|
+
declare function extractAppendSystemPrompt(args: string[]): string | undefined;
|
|
286
309
|
|
|
287
310
|
declare const PACKAGE_NAME = "@raindrop-ai/claude-code";
|
|
288
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
311
|
+
declare const PACKAGE_VERSION = "0.0.6";
|
|
312
|
+
|
|
313
|
+
interface TranscriptSummary {
|
|
314
|
+
/** Aggregated token usage across all turns */
|
|
315
|
+
totalInputTokens: number;
|
|
316
|
+
totalOutputTokens: number;
|
|
317
|
+
totalCacheReadTokens: number;
|
|
318
|
+
totalCacheCreationTokens: number;
|
|
319
|
+
/** Token usage for the most recent turn only */
|
|
320
|
+
lastTurnInputTokens?: number;
|
|
321
|
+
lastTurnOutputTokens?: number;
|
|
322
|
+
lastTurnCacheReadTokens?: number;
|
|
323
|
+
/** Model used (from most recent assistant message) */
|
|
324
|
+
model?: string;
|
|
325
|
+
/** Service tier */
|
|
326
|
+
serviceTier?: string;
|
|
327
|
+
/** Number of API turns (assistant messages) */
|
|
328
|
+
turnCount: number;
|
|
329
|
+
/** Unique tool names used in the session */
|
|
330
|
+
toolsUsed: string[];
|
|
331
|
+
/** Stop reason from last assistant message */
|
|
332
|
+
stopReason?: string;
|
|
333
|
+
/** Total turn duration in ms (from system entries) */
|
|
334
|
+
totalDurationMs?: number;
|
|
335
|
+
/** Claude Code version */
|
|
336
|
+
codeVersion?: string;
|
|
337
|
+
/** Git branch */
|
|
338
|
+
gitBranch?: string;
|
|
339
|
+
/** Whether thinking/reasoning content was used */
|
|
340
|
+
hasThinking: boolean;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Parse a Claude Code transcript JSONL file and extract a summary.
|
|
344
|
+
* Returns undefined if the file doesn't exist or can't be parsed.
|
|
345
|
+
*/
|
|
346
|
+
declare function parseTranscript(transcriptPath: string): TranscriptSummary | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* Convert a TranscriptSummary into a flat properties object
|
|
349
|
+
* suitable for merging into event properties.
|
|
350
|
+
*/
|
|
351
|
+
declare function transcriptToProperties(summary: TranscriptSummary): Record<string, unknown>;
|
|
289
352
|
|
|
290
353
|
interface LocalDebuggerResult {
|
|
291
354
|
/** The resolved base URL (e.g. "http://localhost:5899/v1/"), or null if not detected. */
|
|
@@ -308,4 +371,58 @@ declare function detectLocalDebugger(debug: boolean): Promise<LocalDebuggerResul
|
|
|
308
371
|
*/
|
|
309
372
|
declare function mirrorEventToLocalDebugger(baseUrl: string, payload: Record<string, unknown>, debug: boolean): void;
|
|
310
373
|
|
|
311
|
-
|
|
374
|
+
interface ResolvedSignal {
|
|
375
|
+
description: string;
|
|
376
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Normalize and validate user-provided signal definitions.
|
|
380
|
+
* Returns the default set if input is empty or all entries are invalid.
|
|
381
|
+
* Always appends `noteworthy` as the last category.
|
|
382
|
+
*/
|
|
383
|
+
declare function normalizeSignals(custom?: Record<string, SelfDiagnosticsSignalDef>): Record<string, ResolvedSignal>;
|
|
384
|
+
/**
|
|
385
|
+
* Resolve the full MCP tool configuration from optional user config.
|
|
386
|
+
*/
|
|
387
|
+
declare function resolveToolConfig(diagConfig?: SelfDiagnosticsConfig): {
|
|
388
|
+
signals: Record<string, ResolvedSignal>;
|
|
389
|
+
categoryKeys: string[];
|
|
390
|
+
toolName: string;
|
|
391
|
+
toolDescription: string;
|
|
392
|
+
};
|
|
393
|
+
/** Default category keys (before custom signal config is applied). */
|
|
394
|
+
declare const DEFAULT_CATEGORY_KEYS: string[];
|
|
395
|
+
/**
|
|
396
|
+
* Find the most recently modified event_* file in the state dir.
|
|
397
|
+
* Returns the eventId stored in that file, or undefined.
|
|
398
|
+
*/
|
|
399
|
+
declare function resolveCurrentEventId(): string | undefined;
|
|
400
|
+
declare function executeTool(args: Record<string, unknown>): Promise<{
|
|
401
|
+
content: Array<{
|
|
402
|
+
type: string;
|
|
403
|
+
text: string;
|
|
404
|
+
}>;
|
|
405
|
+
isError?: boolean;
|
|
406
|
+
}>;
|
|
407
|
+
declare const TOOL_SCHEMA: {
|
|
408
|
+
name: string;
|
|
409
|
+
description: string;
|
|
410
|
+
inputSchema: {
|
|
411
|
+
type: "object";
|
|
412
|
+
properties: {
|
|
413
|
+
category: {
|
|
414
|
+
type: "string";
|
|
415
|
+
enum: string[];
|
|
416
|
+
description: string;
|
|
417
|
+
};
|
|
418
|
+
detail: {
|
|
419
|
+
type: "string";
|
|
420
|
+
description: string;
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
required: string[];
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
declare function startMcpServer(): Promise<void>;
|
|
427
|
+
|
|
428
|
+
export { DEFAULT_CATEGORY_KEYS, EventShipper, type HookPayload, type LocalDebuggerResult, type MapperConfig, PACKAGE_NAME, PACKAGE_VERSION, type RaindropConfig, type SelfDiagnosticsConfig, type SelfDiagnosticsSignalDef, type SetupScope, TOOL_SCHEMA, TraceShipper, type TranscriptSummary, detectLocalDebugger, executeTool, extractAppendSystemPrompt, getConfigPath, loadConfig, mapHookToRaindrop, mirrorEventToLocalDebugger, normalizeSignals, parseTranscript, resolveCurrentEventId, resolveToolConfig, startMcpServer, transcriptToProperties, updateConfig };
|