bashkit 0.3.1 → 0.4.0

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.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Debug logging utilities for bashkit tools.
3
+ *
4
+ * Enable debug logging via environment variable:
5
+ * - BASHKIT_DEBUG=1 or BASHKIT_DEBUG=stderr - Human readable output to stderr
6
+ * - BASHKIT_DEBUG=json - JSON lines to stderr
7
+ * - BASHKIT_DEBUG=memory - In-memory array (retrieve via getDebugLogs())
8
+ * - BASHKIT_DEBUG=file:/path/to/trace.jsonl - Write to file
9
+ */
10
+ /** Debug event structure for tool execution tracing */
11
+ export interface DebugEvent {
12
+ /** Unique ID to correlate start/end events (e.g., "grep-1") */
13
+ id: string;
14
+ /** Timestamp in milliseconds */
15
+ ts: number;
16
+ /** Tool name */
17
+ tool: string;
18
+ /** Event type */
19
+ event: "start" | "end" | "error";
20
+ /** Input parameters (start events only, summarized) */
21
+ input?: unknown;
22
+ /** Output data (end events only, summarized) */
23
+ output?: unknown;
24
+ /** Key metrics like exitCode, matchCount, etc. */
25
+ summary?: Record<string, unknown>;
26
+ /** Duration in milliseconds (end events only) */
27
+ duration_ms?: number;
28
+ /** Parent event ID for nested tool calls (e.g., task → subagent tools) */
29
+ parent?: string;
30
+ /** Error message (error events only) */
31
+ error?: string;
32
+ }
33
+ /**
34
+ * Checks if debug mode is enabled (any mode except "off").
35
+ */
36
+ export declare function isDebugEnabled(): boolean;
37
+ /**
38
+ * Summarize data for debug output.
39
+ * - Truncates strings to 1000 chars
40
+ * - Limits arrays to 10 items
41
+ * - Recursively summarizes nested objects
42
+ */
43
+ export declare function summarize(data: unknown, depth?: number): unknown;
44
+ /**
45
+ * Record the start of a tool execution.
46
+ * @returns Event ID to correlate with debugEnd/debugError
47
+ */
48
+ export declare function debugStart(tool: string, input?: Record<string, unknown>): string;
49
+ /**
50
+ * Record the successful end of a tool execution.
51
+ */
52
+ export declare function debugEnd(id: string, tool: string, options: {
53
+ output?: unknown;
54
+ summary?: Record<string, unknown>;
55
+ duration_ms: number;
56
+ }): void;
57
+ /**
58
+ * Record an error during tool execution.
59
+ */
60
+ export declare function debugError(id: string, tool: string, error: string | Error): void;
61
+ /**
62
+ * Push a parent context for nested tool calls (e.g., when Task starts a subagent).
63
+ */
64
+ export declare function pushParent(id: string): void;
65
+ /**
66
+ * Pop the current parent context.
67
+ */
68
+ export declare function popParent(): void;
69
+ /**
70
+ * Get all debug logs (memory mode only).
71
+ * @returns Array of debug events, or empty array if not in memory mode
72
+ */
73
+ export declare function getDebugLogs(): DebugEvent[];
74
+ /**
75
+ * Clear all debug logs (memory mode).
76
+ * Call this between agent runs to reset the trace.
77
+ */
78
+ export declare function clearDebugLogs(): void;
79
+ /**
80
+ * Force re-initialization of debug mode from environment.
81
+ * Useful for testing or when environment changes.
82
+ */
83
+ export declare function reinitDebugMode(): void;
@@ -1,3 +1,4 @@
1
1
  export { type CompactConversationConfig, type CompactConversationResult, type CompactConversationState, compactConversation, createCompactConfig, MODEL_CONTEXT_LIMITS, type ModelContextLimit, } from "./compact-conversation";
2
2
  export { type ContextMetrics, type ContextStatus, type ContextStatusConfig, type ContextStatusLevel, contextNeedsAttention, contextNeedsCompaction, getContextStatus, } from "./context-status";
3
+ export { type DebugEvent, clearDebugLogs, getDebugLogs, isDebugEnabled, reinitDebugMode, } from "./debug";
3
4
  export { estimateMessagesTokens, estimateMessageTokens, estimateTokens, type PruneMessagesConfig, pruneMessagesByTokens, } from "./prune-messages";