@lov3kaizen/agentsea-debugger 0.5.1
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/LICENSE +21 -0
- package/README.md +364 -0
- package/dist/Recorder-Dc9qR2V2.d.ts +138 -0
- package/dist/ReplayEngine-Dyyqy5bw.d.ts +54 -0
- package/dist/analysis/index.d.ts +4 -0
- package/dist/analysis/index.js +1840 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/diff-CLShBdWe.d.ts +24 -0
- package/dist/index-1W27DYJt.d.ts +366 -0
- package/dist/index-DRrKPSo9.d.ts +233 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +6232 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/agentsea/index.d.ts +8 -0
- package/dist/integrations/agentsea/index.js +5826 -0
- package/dist/integrations/agentsea/index.js.map +1 -0
- package/dist/recording/index.d.ts +91 -0
- package/dist/recording/index.js +1207 -0
- package/dist/recording/index.js.map +1 -0
- package/dist/recording.types-Ck7pbikw.d.ts +281 -0
- package/dist/replay/index.d.ts +80 -0
- package/dist/replay/index.js +1112 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/replay.types-C9hJizI-.d.ts +76 -0
- package/dist/storage/index.d.ts +135 -0
- package/dist/storage/index.js +588 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/visualization/index.d.ts +123 -0
- package/dist/visualization/index.js +789 -0
- package/dist/visualization/index.js.map +1 -0
- package/dist/visualization.types-dWjGE037.d.ts +98 -0
- package/package.json +99 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { B as BreakpointType, c as BreakpointCondition, b as Breakpoint, d as BreakpointContext, E as ExecutionStep, A as AgentState, I as InspectorResult, T as ToolCall, e as Decision, M as MemorySnapshot, D as DebugSessionState, C as Checkpoint, k as StepAction, j as DebugSession, m as Recording, a as DebuggerConfig, h as TokenUsage, S as StepType, t as RecordingStorageAdapter } from './recording.types-Ck7pbikw.js';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { R as Recorder } from './Recorder-Dc9qR2V2.js';
|
|
4
|
+
import { b as ReplaySession } from './replay.types-C9hJizI-.js';
|
|
5
|
+
import { a as DecisionTree, f as FlowGraph } from './visualization.types-dWjGE037.js';
|
|
6
|
+
import { f as FailureAnalysis, F as FailureAnalyzer, i as WhatIfScenario, k as ScenarioResult, W as WhatIfEngine } from './index-DRrKPSo9.js';
|
|
7
|
+
import { R as ReplayEngine } from './ReplayEngine-Dyyqy5bw.js';
|
|
8
|
+
|
|
9
|
+
interface BreakpointManagerEvents {
|
|
10
|
+
'breakpoint:added': (breakpoint: Breakpoint) => void;
|
|
11
|
+
'breakpoint:removed': (breakpointId: string) => void;
|
|
12
|
+
'breakpoint:hit': (breakpoint: Breakpoint, context: BreakpointContext) => void;
|
|
13
|
+
'breakpoint:toggled': (breakpoint: Breakpoint) => void;
|
|
14
|
+
}
|
|
15
|
+
interface BreakpointOptions {
|
|
16
|
+
type: BreakpointType;
|
|
17
|
+
condition?: BreakpointCondition;
|
|
18
|
+
step?: number;
|
|
19
|
+
toolName?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare class BreakpointManager extends EventEmitter<BreakpointManagerEvents> {
|
|
24
|
+
private breakpoints;
|
|
25
|
+
add(options: BreakpointOptions): Breakpoint;
|
|
26
|
+
remove(id: string): boolean;
|
|
27
|
+
get(id: string): Breakpoint | undefined;
|
|
28
|
+
getAll(): Breakpoint[];
|
|
29
|
+
getEnabled(): Breakpoint[];
|
|
30
|
+
toggle(id: string): boolean;
|
|
31
|
+
enable(id: string): boolean;
|
|
32
|
+
disable(id: string): boolean;
|
|
33
|
+
clear(): void;
|
|
34
|
+
check(step: ExecutionStep, state: AgentState): Breakpoint | null;
|
|
35
|
+
private shouldTrigger;
|
|
36
|
+
private buildContext;
|
|
37
|
+
get count(): number;
|
|
38
|
+
get enabledCount(): number;
|
|
39
|
+
}
|
|
40
|
+
declare function createBreakpointManager(): BreakpointManager;
|
|
41
|
+
declare const BreakpointHelpers: {
|
|
42
|
+
atStep(step: number, description?: string): BreakpointOptions;
|
|
43
|
+
onToolCall(description?: string): BreakpointOptions;
|
|
44
|
+
onTool(toolName: string, description?: string): BreakpointOptions;
|
|
45
|
+
onError(description?: string): BreakpointOptions;
|
|
46
|
+
onDecision(condition?: BreakpointCondition): BreakpointOptions;
|
|
47
|
+
onLowConfidence(threshold?: number): BreakpointOptions;
|
|
48
|
+
onMemoryChange(description?: string): BreakpointOptions;
|
|
49
|
+
custom(condition: BreakpointCondition, description?: string): BreakpointOptions;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
interface InspectorConfig {
|
|
53
|
+
maxDepth?: number;
|
|
54
|
+
maxStringLength?: number;
|
|
55
|
+
includeFullMemory?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface VariableWatch {
|
|
58
|
+
id: string;
|
|
59
|
+
path: string;
|
|
60
|
+
value: unknown;
|
|
61
|
+
previousValue?: unknown;
|
|
62
|
+
changed: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare class Inspector {
|
|
65
|
+
private steps;
|
|
66
|
+
private currentStepIndex;
|
|
67
|
+
private state;
|
|
68
|
+
private watches;
|
|
69
|
+
private config;
|
|
70
|
+
constructor(steps: ExecutionStep[], state: AgentState, config?: InspectorConfig);
|
|
71
|
+
update(steps: ExecutionStep[], state: AgentState, stepIndex?: number): void;
|
|
72
|
+
getCurrentStepIndex(): number;
|
|
73
|
+
setCurrentStepIndex(index: number): void;
|
|
74
|
+
inspect(): InspectorResult;
|
|
75
|
+
getCurrentStep(): ExecutionStep | null;
|
|
76
|
+
getStep(index: number): ExecutionStep | undefined;
|
|
77
|
+
getSteps(): ExecutionStep[];
|
|
78
|
+
getStepsUpToCurrent(): ExecutionStep[];
|
|
79
|
+
getToolCalls(): ToolCall[];
|
|
80
|
+
getToolCallsByName(name: string): ToolCall[];
|
|
81
|
+
getDecisions(): Decision[];
|
|
82
|
+
getMemorySnapshot(): MemorySnapshot;
|
|
83
|
+
getVariables(): Record<string, unknown>;
|
|
84
|
+
getVariable(path: string): unknown;
|
|
85
|
+
getCallStack(): string[];
|
|
86
|
+
watch(path: string): VariableWatch;
|
|
87
|
+
unwatch(path: string): boolean;
|
|
88
|
+
getWatches(): VariableWatch[];
|
|
89
|
+
private updateWatches;
|
|
90
|
+
getChangedWatches(): VariableWatch[];
|
|
91
|
+
searchSteps(query: string, options?: {
|
|
92
|
+
caseSensitive?: boolean;
|
|
93
|
+
types?: string[];
|
|
94
|
+
}): ExecutionStep[];
|
|
95
|
+
getStepSummary(step: ExecutionStep): string;
|
|
96
|
+
private summarizeObject;
|
|
97
|
+
export(): Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
declare function createInspector(steps: ExecutionStep[], state: AgentState, config?: InspectorConfig): Inspector;
|
|
100
|
+
|
|
101
|
+
interface SessionEvents {
|
|
102
|
+
'state:changed': (state: DebugSessionState) => void;
|
|
103
|
+
'step:executed': (step: ExecutionStep) => void;
|
|
104
|
+
'step:paused': (step: ExecutionStep, breakpoint?: Breakpoint) => void;
|
|
105
|
+
'breakpoint:hit': (breakpoint: Breakpoint, step: ExecutionStep) => void;
|
|
106
|
+
'checkpoint:created': (checkpoint: Checkpoint) => void;
|
|
107
|
+
error: (error: Error) => void;
|
|
108
|
+
}
|
|
109
|
+
interface SessionConfig {
|
|
110
|
+
agentId: string;
|
|
111
|
+
checkpointInterval?: number;
|
|
112
|
+
maxSteps?: number;
|
|
113
|
+
}
|
|
114
|
+
declare class DebugSessionManager extends EventEmitter<SessionEvents> {
|
|
115
|
+
private session;
|
|
116
|
+
private steps;
|
|
117
|
+
private state;
|
|
118
|
+
private breakpoints;
|
|
119
|
+
private checkpoints;
|
|
120
|
+
private config;
|
|
121
|
+
private pauseResolver?;
|
|
122
|
+
private stepAction;
|
|
123
|
+
constructor(config: SessionConfig);
|
|
124
|
+
get id(): string;
|
|
125
|
+
get sessionState(): DebugSessionState;
|
|
126
|
+
start(): void;
|
|
127
|
+
stop(): void;
|
|
128
|
+
pause(): void;
|
|
129
|
+
continue(): void;
|
|
130
|
+
stepOver(): void;
|
|
131
|
+
stepInto(): void;
|
|
132
|
+
stepOut(): void;
|
|
133
|
+
addStep(step: ExecutionStep, agentState: AgentState): boolean;
|
|
134
|
+
waitForContinue(): Promise<StepAction>;
|
|
135
|
+
setBreakpoint(options: BreakpointOptions): Breakpoint;
|
|
136
|
+
removeBreakpoint(id: string): boolean;
|
|
137
|
+
getBreakpoints(): Breakpoint[];
|
|
138
|
+
createCheckpoint(options: {
|
|
139
|
+
name: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
automatic?: boolean;
|
|
142
|
+
}): Checkpoint;
|
|
143
|
+
getCheckpoint(id: string): Checkpoint | undefined;
|
|
144
|
+
getCheckpoints(): Checkpoint[];
|
|
145
|
+
restoreCheckpoint(id: string): boolean;
|
|
146
|
+
inspect(): Inspector;
|
|
147
|
+
getState(): AgentState;
|
|
148
|
+
getSteps(): ExecutionStep[];
|
|
149
|
+
getSession(): DebugSession;
|
|
150
|
+
complete(): void;
|
|
151
|
+
error(err: Error): void;
|
|
152
|
+
toRecording(): Recording;
|
|
153
|
+
private createInitialState;
|
|
154
|
+
}
|
|
155
|
+
declare function createDebugSession(config: SessionConfig): DebugSessionManager;
|
|
156
|
+
|
|
157
|
+
interface DebuggerEvents {
|
|
158
|
+
'session:started': (sessionId: string) => void;
|
|
159
|
+
'session:ended': (sessionId: string, recording: Recording) => void;
|
|
160
|
+
step: (step: ExecutionStep) => void;
|
|
161
|
+
'breakpoint:hit': (breakpoint: Breakpoint, step: ExecutionStep) => void;
|
|
162
|
+
paused: (reason: string) => void;
|
|
163
|
+
resumed: () => void;
|
|
164
|
+
error: (error: Error) => void;
|
|
165
|
+
}
|
|
166
|
+
interface DebuggableAgent {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
model: string;
|
|
170
|
+
getState?: () => AgentState;
|
|
171
|
+
onStep?: (callback: (step: ExecutionStep) => void) => void;
|
|
172
|
+
}
|
|
173
|
+
interface StepBuilder {
|
|
174
|
+
input(data: unknown): ExecutionStep;
|
|
175
|
+
prompt(content: string): ExecutionStep;
|
|
176
|
+
response(content: string, usage?: TokenUsage): ExecutionStep;
|
|
177
|
+
toolCall(tool: ToolCall): ExecutionStep;
|
|
178
|
+
toolResult(tool: ToolCall, success: boolean): ExecutionStep;
|
|
179
|
+
decision(decision: Decision): ExecutionStep;
|
|
180
|
+
error(error: Error): ExecutionStep;
|
|
181
|
+
custom(type: StepType, data: unknown): ExecutionStep;
|
|
182
|
+
}
|
|
183
|
+
declare class Debugger extends EventEmitter<DebuggerEvents> {
|
|
184
|
+
private config;
|
|
185
|
+
private sessions;
|
|
186
|
+
private currentSession?;
|
|
187
|
+
private attachedAgent?;
|
|
188
|
+
private stepIndex;
|
|
189
|
+
private globalBreakpoints;
|
|
190
|
+
constructor(config?: Partial<DebuggerConfig>);
|
|
191
|
+
attach(agent: DebuggableAgent): void;
|
|
192
|
+
detach(): void;
|
|
193
|
+
startSession(options?: Partial<SessionConfig>): DebugSessionManager;
|
|
194
|
+
endSession(): Recording | undefined;
|
|
195
|
+
getSession(): DebugSessionManager | undefined;
|
|
196
|
+
getSessionById(id: string): DebugSessionManager | undefined;
|
|
197
|
+
setBreakpoint(options: BreakpointOptions): Breakpoint | undefined;
|
|
198
|
+
clearBreakpoints(): void;
|
|
199
|
+
continue(): void;
|
|
200
|
+
stepOver(): void;
|
|
201
|
+
stepInto(): void;
|
|
202
|
+
stepOut(): void;
|
|
203
|
+
pause(): void;
|
|
204
|
+
stop(): void;
|
|
205
|
+
createCheckpoint(options: {
|
|
206
|
+
name: string;
|
|
207
|
+
description?: string;
|
|
208
|
+
}): Checkpoint | undefined;
|
|
209
|
+
listCheckpoints(): Checkpoint[];
|
|
210
|
+
restoreCheckpoint(id: string): boolean;
|
|
211
|
+
inspect(): Inspector | undefined;
|
|
212
|
+
recordStep(step: Partial<ExecutionStep>, state?: AgentState): boolean;
|
|
213
|
+
steps(): StepBuilder;
|
|
214
|
+
private createStep;
|
|
215
|
+
private createDefaultState;
|
|
216
|
+
getConfig(): Readonly<DebuggerConfig>;
|
|
217
|
+
static get Breakpoints(): typeof BreakpointHelpers;
|
|
218
|
+
}
|
|
219
|
+
declare function createDebugger(config?: Partial<DebuggerConfig>): Debugger;
|
|
220
|
+
|
|
221
|
+
interface DebugMiddlewareOptions {
|
|
222
|
+
enabled?: boolean;
|
|
223
|
+
recordEnabled?: boolean;
|
|
224
|
+
debugger?: Debugger;
|
|
225
|
+
recorder?: Recorder;
|
|
226
|
+
autoStart?: boolean;
|
|
227
|
+
includePrompts?: boolean;
|
|
228
|
+
includeResponses?: boolean;
|
|
229
|
+
}
|
|
230
|
+
interface AgentMessage {
|
|
231
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
232
|
+
content: string;
|
|
233
|
+
toolCalls?: Array<{
|
|
234
|
+
id: string;
|
|
235
|
+
name: string;
|
|
236
|
+
arguments: Record<string, unknown>;
|
|
237
|
+
}>;
|
|
238
|
+
toolCallId?: string;
|
|
239
|
+
}
|
|
240
|
+
interface ExecutionContext {
|
|
241
|
+
agentId: string;
|
|
242
|
+
agentName: string;
|
|
243
|
+
model: string;
|
|
244
|
+
messages: AgentMessage[];
|
|
245
|
+
tools: string[];
|
|
246
|
+
memory?: Record<string, unknown>;
|
|
247
|
+
context?: Record<string, unknown>;
|
|
248
|
+
}
|
|
249
|
+
declare class DebugMiddleware {
|
|
250
|
+
private options;
|
|
251
|
+
private debugger;
|
|
252
|
+
private recorder;
|
|
253
|
+
private stepIndex;
|
|
254
|
+
private currentTiming?;
|
|
255
|
+
private isSessionActive;
|
|
256
|
+
constructor(options?: DebugMiddlewareOptions);
|
|
257
|
+
startSession(context: ExecutionContext): void;
|
|
258
|
+
endSession(): void;
|
|
259
|
+
onInput(input: unknown, context?: ExecutionContext): void;
|
|
260
|
+
onPrompt(prompt: string | AgentMessage[], context?: ExecutionContext): void;
|
|
261
|
+
onResponse(response: string, usage?: TokenUsage, context?: ExecutionContext): void;
|
|
262
|
+
onToolCall(tool: {
|
|
263
|
+
id?: string;
|
|
264
|
+
name: string;
|
|
265
|
+
arguments: Record<string, unknown>;
|
|
266
|
+
}, context?: ExecutionContext): void;
|
|
267
|
+
onToolResult(tool: {
|
|
268
|
+
id: string;
|
|
269
|
+
name: string;
|
|
270
|
+
result: unknown;
|
|
271
|
+
success: boolean;
|
|
272
|
+
}, context?: ExecutionContext): void;
|
|
273
|
+
onDecision(decision: Decision, context?: ExecutionContext): void;
|
|
274
|
+
onError(error: Error, context?: ExecutionContext): void;
|
|
275
|
+
onMemoryWrite(data: Record<string, unknown>, context?: ExecutionContext): void;
|
|
276
|
+
onMemoryRead(query: string | Record<string, unknown>, result: unknown, context?: ExecutionContext): void;
|
|
277
|
+
createCheckpoint(name: string, description?: string): void;
|
|
278
|
+
getDebugger(): Debugger;
|
|
279
|
+
getRecorder(): Recorder;
|
|
280
|
+
isActive(): boolean;
|
|
281
|
+
createHandler(): {
|
|
282
|
+
beforeExecute: (context: ExecutionContext) => Promise<void>;
|
|
283
|
+
afterExecute: (context: ExecutionContext) => Promise<void>;
|
|
284
|
+
onStep: (type: StepType, data: Record<string, unknown>, context: ExecutionContext) => void;
|
|
285
|
+
onError: (error: Error, context: ExecutionContext) => void;
|
|
286
|
+
};
|
|
287
|
+
private createStep;
|
|
288
|
+
private recordStep;
|
|
289
|
+
private startTiming;
|
|
290
|
+
private finishCurrentStep;
|
|
291
|
+
private contextToState;
|
|
292
|
+
private createDefaultState;
|
|
293
|
+
}
|
|
294
|
+
declare function createDebugMiddleware(options?: DebugMiddlewareOptions): DebugMiddleware;
|
|
295
|
+
|
|
296
|
+
interface AgentDebuggerEvents extends DebuggerEvents {
|
|
297
|
+
'recording:saved': (recording: Recording) => void;
|
|
298
|
+
'replay:started': (session: ReplaySession) => void;
|
|
299
|
+
'replay:completed': (session: ReplaySession) => void;
|
|
300
|
+
'analysis:completed': (analysis: FailureAnalysis) => void;
|
|
301
|
+
}
|
|
302
|
+
interface AgentDebuggerOptions {
|
|
303
|
+
storage?: RecordingStorageAdapter;
|
|
304
|
+
autoSave?: boolean;
|
|
305
|
+
recordingEnabled?: boolean;
|
|
306
|
+
breakpointsEnabled?: boolean;
|
|
307
|
+
}
|
|
308
|
+
declare class AgentDebugger extends EventEmitter<AgentDebuggerEvents> {
|
|
309
|
+
private debugger;
|
|
310
|
+
private recorder;
|
|
311
|
+
private replayEngine;
|
|
312
|
+
private failureAnalyzer;
|
|
313
|
+
private whatIfEngine;
|
|
314
|
+
private middleware;
|
|
315
|
+
private storage;
|
|
316
|
+
private options;
|
|
317
|
+
private recordings;
|
|
318
|
+
private currentRecording?;
|
|
319
|
+
constructor(options?: AgentDebuggerOptions);
|
|
320
|
+
private setupEventForwarding;
|
|
321
|
+
private handleRecordingComplete;
|
|
322
|
+
attach(agent: DebuggableAgent): void;
|
|
323
|
+
detach(): void;
|
|
324
|
+
getMiddleware(): DebugMiddleware;
|
|
325
|
+
startSession(context: ExecutionContext): void;
|
|
326
|
+
endSession(): Recording | undefined;
|
|
327
|
+
breakOnTool(toolName?: string): Breakpoint | undefined;
|
|
328
|
+
breakOnError(): Breakpoint | undefined;
|
|
329
|
+
breakOnDecision(): Breakpoint | undefined;
|
|
330
|
+
breakAtStep(step: number): Breakpoint | undefined;
|
|
331
|
+
setBreakpoint(options: Parameters<Debugger['setBreakpoint']>[0]): Breakpoint | undefined;
|
|
332
|
+
clearBreakpoints(): void;
|
|
333
|
+
continue(): void;
|
|
334
|
+
stepOver(): void;
|
|
335
|
+
stepInto(): void;
|
|
336
|
+
stepOut(): void;
|
|
337
|
+
pause(): void;
|
|
338
|
+
stop(): void;
|
|
339
|
+
createCheckpoint(name: string, description?: string): Checkpoint | undefined;
|
|
340
|
+
listCheckpoints(): Checkpoint[];
|
|
341
|
+
restoreCheckpoint(id: string): boolean;
|
|
342
|
+
getRecording(): Recording | undefined;
|
|
343
|
+
loadRecording(id: string): Promise<Recording | undefined>;
|
|
344
|
+
listRecordings(): Promise<Array<{
|
|
345
|
+
id: string;
|
|
346
|
+
agentId: string;
|
|
347
|
+
agentName: string;
|
|
348
|
+
status: string;
|
|
349
|
+
startedAt: number;
|
|
350
|
+
}>>;
|
|
351
|
+
replay(recording: Recording, options?: Parameters<ReplayEngine['start']>[1]): ReplaySession;
|
|
352
|
+
getReplayEngine(): ReplayEngine;
|
|
353
|
+
analyzeFailure(recording: Recording): FailureAnalysis;
|
|
354
|
+
getFailureAnalyzer(): FailureAnalyzer;
|
|
355
|
+
createWhatIfScenario(recording: Recording, modifications: WhatIfScenario['modifications'], name?: string): WhatIfScenario;
|
|
356
|
+
runWhatIfScenario(scenarioId: string, recording: Recording): Promise<ScenarioResult>;
|
|
357
|
+
getWhatIfEngine(): WhatIfEngine;
|
|
358
|
+
buildDecisionTree(recording: Recording): DecisionTree;
|
|
359
|
+
buildFlowGraph(recording: Recording): FlowGraph;
|
|
360
|
+
inspect(): Inspector | undefined;
|
|
361
|
+
getDebugger(): Debugger;
|
|
362
|
+
getStorage(): RecordingStorageAdapter;
|
|
363
|
+
}
|
|
364
|
+
declare function createAgentDebugger(options?: AgentDebuggerOptions): AgentDebugger;
|
|
365
|
+
|
|
366
|
+
export { type AgentMessage as A, BreakpointManager as B, Debugger as D, type ExecutionContext as E, Inspector as I, type StepBuilder as S, type VariableWatch as V, type DebuggerEvents as a, type DebuggableAgent as b, createDebugger as c, DebugSessionManager as d, createDebugSession as e, type SessionEvents as f, type SessionConfig as g, createBreakpointManager as h, BreakpointHelpers as i, type BreakpointManagerEvents as j, type BreakpointOptions as k, createInspector as l, type InspectorConfig as m, DebugMiddleware as n, createDebugMiddleware as o, type DebugMiddlewareOptions as p, AgentDebugger as q, createAgentDebugger as r, type AgentDebuggerEvents as s, type AgentDebuggerOptions as t };
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { A as AgentState, E as ExecutionStep, m as Recording, S as StepType } from './recording.types-Ck7pbikw.js';
|
|
3
|
+
import { d as ReplayModification, g as ReplayDifference } from './replay.types-C9hJizI-.js';
|
|
4
|
+
|
|
5
|
+
interface FailureAnalysis {
|
|
6
|
+
id: string;
|
|
7
|
+
recordingId: string;
|
|
8
|
+
analyzedAt: number;
|
|
9
|
+
rootCause: string;
|
|
10
|
+
contributingFactors: ContributingFactor[];
|
|
11
|
+
recommendations: Recommendation[];
|
|
12
|
+
errorStepIndex?: number;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
stackTrace?: string;
|
|
15
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
16
|
+
confidence: number;
|
|
17
|
+
}
|
|
18
|
+
interface ContributingFactor {
|
|
19
|
+
id: string;
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
23
|
+
stepIndices: number[];
|
|
24
|
+
evidence?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
interface Recommendation {
|
|
27
|
+
id: string;
|
|
28
|
+
priority: number;
|
|
29
|
+
title: string;
|
|
30
|
+
description: string;
|
|
31
|
+
relatedFactors: string[];
|
|
32
|
+
}
|
|
33
|
+
interface WhatIfScenario {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
baseRecordingId: string;
|
|
38
|
+
modifications: ReplayModification[];
|
|
39
|
+
status: ScenarioStatus;
|
|
40
|
+
createdAt: number;
|
|
41
|
+
}
|
|
42
|
+
type ScenarioStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
43
|
+
interface ScenarioResult {
|
|
44
|
+
scenarioId: string;
|
|
45
|
+
success: boolean;
|
|
46
|
+
originalRecordingId: string;
|
|
47
|
+
modifiedSteps: number;
|
|
48
|
+
differences: ReplayDifference[];
|
|
49
|
+
divergencePoint?: number;
|
|
50
|
+
finalState: AgentState;
|
|
51
|
+
executedAt: number;
|
|
52
|
+
durationMs: number;
|
|
53
|
+
}
|
|
54
|
+
interface ScenarioComparison {
|
|
55
|
+
scenarioId: string;
|
|
56
|
+
scenarioName: string;
|
|
57
|
+
originalRecordingId: string;
|
|
58
|
+
outcomeChanged: boolean;
|
|
59
|
+
divergencePoint?: number;
|
|
60
|
+
divergencePercentage: number;
|
|
61
|
+
differences: ReplayDifference[];
|
|
62
|
+
summary: string;
|
|
63
|
+
}
|
|
64
|
+
interface PerformanceProfile {
|
|
65
|
+
recordingId: string;
|
|
66
|
+
totalDurationMs: number;
|
|
67
|
+
llmTimeMs: number;
|
|
68
|
+
toolTimeMs: number;
|
|
69
|
+
overheadMs: number;
|
|
70
|
+
tokens: {
|
|
71
|
+
total: number;
|
|
72
|
+
perSecond: number;
|
|
73
|
+
costUSD: number;
|
|
74
|
+
};
|
|
75
|
+
bottlenecks: Bottleneck[];
|
|
76
|
+
stepPerformance: StepPerformance[];
|
|
77
|
+
}
|
|
78
|
+
interface Bottleneck {
|
|
79
|
+
stepIndex: number;
|
|
80
|
+
type: 'slow-tool' | 'slow-llm' | 'large-context' | 'retry';
|
|
81
|
+
description: string;
|
|
82
|
+
durationMs: number;
|
|
83
|
+
percentage: number;
|
|
84
|
+
suggestion?: string;
|
|
85
|
+
}
|
|
86
|
+
interface StepPerformance {
|
|
87
|
+
stepIndex: number;
|
|
88
|
+
type: string;
|
|
89
|
+
durationMs: number;
|
|
90
|
+
tokensUsed: number;
|
|
91
|
+
isBottleneck: boolean;
|
|
92
|
+
}
|
|
93
|
+
type FactorCategory = 'tool-failure' | 'context-issue' | 'decision-error' | 'resource-limit' | 'external-dependency' | 'configuration' | 'unknown';
|
|
94
|
+
interface SimilarFailure {
|
|
95
|
+
recordingId: string;
|
|
96
|
+
similarity: number;
|
|
97
|
+
matchingFactors: string[];
|
|
98
|
+
timestamp: number;
|
|
99
|
+
}
|
|
100
|
+
interface ComparisonMetric {
|
|
101
|
+
name: string;
|
|
102
|
+
original: number;
|
|
103
|
+
modified: number;
|
|
104
|
+
delta: number;
|
|
105
|
+
deltaPercent: number;
|
|
106
|
+
improved: boolean;
|
|
107
|
+
}
|
|
108
|
+
type InputVariationType = 'text-change' | 'context-addition' | 'context-removal' | 'tool-result-change' | 'state-modification';
|
|
109
|
+
interface InputVariation {
|
|
110
|
+
id: string;
|
|
111
|
+
type: InputVariationType;
|
|
112
|
+
stepIndex: number;
|
|
113
|
+
original: unknown;
|
|
114
|
+
modified: unknown;
|
|
115
|
+
description?: string;
|
|
116
|
+
}
|
|
117
|
+
interface PathAnalysis {
|
|
118
|
+
recordingId: string;
|
|
119
|
+
totalPaths: number;
|
|
120
|
+
criticalPoints: number[];
|
|
121
|
+
alternatives: AlternativePathAnalysis[];
|
|
122
|
+
optimalPath?: string;
|
|
123
|
+
}
|
|
124
|
+
interface AlternativePathAnalysis {
|
|
125
|
+
id: string;
|
|
126
|
+
decisionPoint: number;
|
|
127
|
+
alternativeOption: string;
|
|
128
|
+
predictedOutcome: string;
|
|
129
|
+
confidence: number;
|
|
130
|
+
costDelta?: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface WhatIfEngineEvents {
|
|
134
|
+
'scenario:created': (scenario: WhatIfScenario) => void;
|
|
135
|
+
'scenario:started': (scenarioId: string) => void;
|
|
136
|
+
'scenario:completed': (result: ScenarioResult) => void;
|
|
137
|
+
'scenario:failed': (scenarioId: string, error: Error) => void;
|
|
138
|
+
'comparison:completed': (comparison: ScenarioComparison) => void;
|
|
139
|
+
error: (error: Error) => void;
|
|
140
|
+
}
|
|
141
|
+
interface ScenarioOptions {
|
|
142
|
+
name: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
recordingId: string;
|
|
145
|
+
modifications: ReplayModification[];
|
|
146
|
+
executeTools?: boolean;
|
|
147
|
+
executeLLM?: boolean;
|
|
148
|
+
onToolCall?: (step: ExecutionStep) => Promise<unknown>;
|
|
149
|
+
onLLMCall?: (step: ExecutionStep) => Promise<string>;
|
|
150
|
+
}
|
|
151
|
+
interface BatchScenarioOptions {
|
|
152
|
+
recordingId: string;
|
|
153
|
+
variations: Array<{
|
|
154
|
+
name: string;
|
|
155
|
+
modifications: ReplayModification[];
|
|
156
|
+
}>;
|
|
157
|
+
parallel?: boolean;
|
|
158
|
+
}
|
|
159
|
+
declare class WhatIfEngine extends EventEmitter<WhatIfEngineEvents> {
|
|
160
|
+
private scenarios;
|
|
161
|
+
private results;
|
|
162
|
+
private replayEngine;
|
|
163
|
+
private stateRestorer;
|
|
164
|
+
constructor();
|
|
165
|
+
createScenario(options: ScenarioOptions): WhatIfScenario;
|
|
166
|
+
runScenario(scenarioId: string, recording: Recording, options?: {
|
|
167
|
+
executeTools?: boolean;
|
|
168
|
+
executeLLM?: boolean;
|
|
169
|
+
onToolCall?: (step: ExecutionStep) => Promise<unknown>;
|
|
170
|
+
onLLMCall?: (step: ExecutionStep) => Promise<string>;
|
|
171
|
+
}): Promise<ScenarioResult>;
|
|
172
|
+
private waitForReplayCompletion;
|
|
173
|
+
runBatch(options: BatchScenarioOptions, recording: Recording): Promise<ScenarioResult[]>;
|
|
174
|
+
compare(original: Recording, result: ScenarioResult): ScenarioComparison;
|
|
175
|
+
private generateComparisonSummary;
|
|
176
|
+
createFromDecision(recording: Recording, stepIndex: number, alternativeChoice: string): WhatIfScenario;
|
|
177
|
+
createFromToolResult(recording: Recording, stepIndex: number, alternativeResult: unknown): WhatIfScenario;
|
|
178
|
+
createFromSkip(recording: Recording, stepIndices: number[], name?: string): WhatIfScenario;
|
|
179
|
+
getScenario(id: string): WhatIfScenario | undefined;
|
|
180
|
+
getScenarios(): WhatIfScenario[];
|
|
181
|
+
getScenariosForRecording(recordingId: string): WhatIfScenario[];
|
|
182
|
+
getResult(scenarioId: string): ScenarioResult | undefined;
|
|
183
|
+
getResults(): ScenarioResult[];
|
|
184
|
+
deleteScenario(id: string): boolean;
|
|
185
|
+
clear(): void;
|
|
186
|
+
}
|
|
187
|
+
declare function createWhatIfEngine(): WhatIfEngine;
|
|
188
|
+
|
|
189
|
+
interface AnalysisOptions {
|
|
190
|
+
includeDetailedSteps?: boolean;
|
|
191
|
+
includeMemoryAnalysis?: boolean;
|
|
192
|
+
includeTimingAnalysis?: boolean;
|
|
193
|
+
customPatterns?: FailurePattern[];
|
|
194
|
+
}
|
|
195
|
+
interface FailurePattern {
|
|
196
|
+
id: string;
|
|
197
|
+
name: string;
|
|
198
|
+
description: string;
|
|
199
|
+
matcher: (recording: Recording, steps: ExecutionStep[]) => boolean;
|
|
200
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
201
|
+
recommendations: string[];
|
|
202
|
+
}
|
|
203
|
+
interface StepAnalysis {
|
|
204
|
+
stepIndex: number;
|
|
205
|
+
type: StepType;
|
|
206
|
+
suspicious: boolean;
|
|
207
|
+
reasons: string[];
|
|
208
|
+
relatedSteps: number[];
|
|
209
|
+
}
|
|
210
|
+
declare class FailureAnalyzer {
|
|
211
|
+
private patterns;
|
|
212
|
+
private options;
|
|
213
|
+
constructor(options?: AnalysisOptions);
|
|
214
|
+
analyze(recording: Recording): FailureAnalysis;
|
|
215
|
+
private findContributingFactors;
|
|
216
|
+
private findPatternSteps;
|
|
217
|
+
private gatherEvidence;
|
|
218
|
+
private determineRootCause;
|
|
219
|
+
private generateRecommendations;
|
|
220
|
+
private getPriorityFromSeverity;
|
|
221
|
+
private findErrorStep;
|
|
222
|
+
private getErrorMessage;
|
|
223
|
+
private getStackTrace;
|
|
224
|
+
private calculateOverallSeverity;
|
|
225
|
+
private calculateConfidence;
|
|
226
|
+
analyzeSteps(steps: ExecutionStep[]): StepAnalysis[];
|
|
227
|
+
addPattern(pattern: FailurePattern): void;
|
|
228
|
+
removePattern(patternId: string): boolean;
|
|
229
|
+
getPatterns(): FailurePattern[];
|
|
230
|
+
}
|
|
231
|
+
declare function createFailureAnalyzer(options?: AnalysisOptions): FailureAnalyzer;
|
|
232
|
+
|
|
233
|
+
export { type AnalysisOptions as A, type BatchScenarioOptions as B, type ContributingFactor as C, FailureAnalyzer as F, type InputVariation as I, type PerformanceProfile as P, type Recommendation as R, type ScenarioOptions as S, WhatIfEngine as W, type WhatIfEngineEvents as a, createFailureAnalyzer as b, createWhatIfEngine as c, type FailurePattern as d, type StepAnalysis as e, type FailureAnalysis as f, type FactorCategory as g, type SimilarFailure as h, type WhatIfScenario as i, type ScenarioStatus as j, type ScenarioResult as k, type ScenarioComparison as l, type ComparisonMetric as m, type InputVariationType as n, type Bottleneck as o, type StepPerformance as p, type PathAnalysis as q, type AlternativePathAnalysis as r };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { A as AgentState, b as Breakpoint, c as BreakpointCondition, d as BreakpointContext, B as BreakpointType, C as Checkpoint, j as DebugSession, D as DebugSessionState, a as DebuggerConfig, e as Decision, f as DecisionOption, i as ErrorInfo, E as ExecutionStep, I as InspectorResult, M as MemorySnapshot, g as Message, s as RecorderConfig, m as Recording, R as RecordingConfig, u as RecordingListOptions, v as RecordingListResult, o as RecordingMetadata, n as RecordingOutcome, l as RecordingStatus, t as RecordingStorageAdapter, w as RecordingSummary, p as Snapshot, k as StepAction, S as StepType, x as StorageStats, q as TimelineEvent, r as TimelineEventType, h as TokenUsage, T as ToolCall } from './recording.types-Ck7pbikw.js';
|
|
2
|
+
export { h as ReplayComparison, c as ReplayConfig, g as ReplayDifference, d as ReplayModification, e as ReplayModificationType, f as ReplayResult, b as ReplaySession, a as ReplaySpeed, R as ReplayState, S as StateRestoreOptions, i as StateRestoreResult } from './replay.types-C9hJizI-.js';
|
|
3
|
+
export { A as AlternativePath, a as DecisionTree, D as DecisionTreeNode, E as ExportFormat, e as FlowEdgeStyle, f as FlowGraph, d as FlowGraphEdge, F as FlowGraphNode, c as FlowNodeStyle, b as FlowNodeType, M as MermaidOptions, g as StateTimeline, S as StateTimelineEntry, h as ToolCallTree, T as ToolCallTreeNode } from './visualization.types-dWjGE037.js';
|
|
4
|
+
export { r as AlternativePathAnalysis, A as AnalysisOptions, B as BatchScenarioOptions, o as Bottleneck, m as ComparisonMetric, C as ContributingFactor, g as FactorCategory, f as FailureAnalysis, F as FailureAnalyzer, d as FailurePattern, I as InputVariation, n as InputVariationType, q as PathAnalysis, P as PerformanceProfile, R as Recommendation, l as ScenarioComparison, S as ScenarioOptions, k as ScenarioResult, j as ScenarioStatus, h as SimilarFailure, e as StepAnalysis, p as StepPerformance, W as WhatIfEngine, a as WhatIfEngineEvents, i as WhatIfScenario, b as createFailureAnalyzer, c as createWhatIfEngine } from './index-DRrKPSo9.js';
|
|
5
|
+
export { q as AgentDebugger, s as AgentDebuggerEvents, t as AgentDebuggerOptions, A as AgentMessage, i as BreakpointHelpers, B as BreakpointManager, j as BreakpointManagerEvents, k as BreakpointOptions, n as DebugMiddleware, p as DebugMiddlewareOptions, d as DebugSessionManager, b as DebuggableAgent, D as Debugger, a as DebuggerEvents, E as ExecutionContext, I as Inspector, m as InspectorConfig, g as SessionConfig, f as SessionEvents, S as StepBuilder, V as VariableWatch, r as createAgentDebugger, h as createBreakpointManager, o as createDebugMiddleware, e as createDebugSession, c as createDebugger, l as createInspector } from './index-1W27DYJt.js';
|
|
6
|
+
export { R as Recorder, a as RecorderEvents, T as Timeline, d as TimelineEventOptions, g as TimelineFilterOptions, e as TimelineMarker, f as TimelineSegment, h as TimelineStats, c as createRecorder, b as createTimeline } from './Recorder-Dc9qR2V2.js';
|
|
7
|
+
export { CheckpointCreateOptions, CheckpointFilterOptions, CheckpointManager, IncrementalSnapshot, SnapshotManager, SnapshotOptions, createCheckpointManager, createSnapshotManager } from './recording/index.js';
|
|
8
|
+
export { R as ReplayEngine, a as ReplayEngineEvents, b as ReplayOptions, c as createReplayEngine } from './ReplayEngine-Dyyqy5bw.js';
|
|
9
|
+
export { PlaybackState, ReplayController, ReplayControllerEvents, RestoreOptions, StateRestorer, StateValidation, createReplayController, createStateRestorer } from './replay/index.js';
|
|
10
|
+
export { DecisionTreeBuilder, EdgeStyle, FlowGraphBuilder, GraphBuildOptions, LayoutOptions, NodeOptions, NodeStyle, TreeBuildOptions, createDecisionTreeBuilder, createFlowGraphBuilder } from './visualization/index.js';
|
|
11
|
+
export { FileStorage, FileStorageOptions, FileSystem, MemoryStorage, MemoryStorageOptions, RecordingMeta, createFileStorage, createMemoryStorage } from './storage/index.js';
|
|
12
|
+
export { D as Difference, a as applyPatch, d as diff, g as getAtPath, i as isEqual, b as setAtPath, s as summarizeDiff, t as toReplayDifferences } from './diff-CLShBdWe.js';
|
|
13
|
+
import 'eventemitter3';
|
|
14
|
+
|
|
15
|
+
declare function generateId(prefix?: string): string;
|
|
16
|
+
declare function now(): number;
|
|
17
|
+
declare function duration(start: number, end?: number): number;
|
|
18
|
+
declare function deepClone<T>(obj: T): T;
|
|
19
|
+
declare function safeStringify(obj: unknown, indent?: number): string;
|
|
20
|
+
declare function safeParse<T>(json: string, defaultValue?: T): T | undefined;
|
|
21
|
+
declare function formatDuration(ms: number): string;
|
|
22
|
+
declare function formatBytes(bytes: number): string;
|
|
23
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
24
|
+
declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
25
|
+
declare function sleep(ms: number): Promise<void>;
|
|
26
|
+
declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, baseDelayMs?: number): Promise<T>;
|
|
27
|
+
declare function estimateSize(obj: unknown): number;
|
|
28
|
+
|
|
29
|
+
export { debounce, deepClone, duration, estimateSize, formatBytes, formatDuration, generateId, now, retry, safeParse, safeStringify, sleep, truncate };
|