kagent-ts 0.1.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.
- package/LICENSE +21 -0
- package/README.md +395 -0
- package/dist/compression/interface.d.ts +26 -0
- package/dist/compression/interface.d.ts.map +1 -0
- package/dist/compression/interface.js +3 -0
- package/dist/compression/interface.js.map +1 -0
- package/dist/compression/sliding-window.d.ts +21 -0
- package/dist/compression/sliding-window.d.ts.map +1 -0
- package/dist/compression/sliding-window.js +55 -0
- package/dist/compression/sliding-window.js.map +1 -0
- package/dist/compression/types.d.ts +12 -0
- package/dist/compression/types.d.ts.map +1 -0
- package/dist/compression/types.js +3 -0
- package/dist/compression/types.js.map +1 -0
- package/dist/context/context-manager.d.ts +76 -0
- package/dist/context/context-manager.d.ts.map +1 -0
- package/dist/context/context-manager.js +132 -0
- package/dist/context/context-manager.js.map +1 -0
- package/dist/context/types.d.ts +35 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/context/types.js +3 -0
- package/dist/context/types.js.map +1 -0
- package/dist/core/agent.d.ts +288 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +398 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/hooks.d.ts +34 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +3 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/plan-solve-agent.d.ts +114 -0
- package/dist/core/plan-solve-agent.d.ts.map +1 -0
- package/dist/core/plan-solve-agent.js +450 -0
- package/dist/core/plan-solve-agent.js.map +1 -0
- package/dist/core/react-agent.d.ts +52 -0
- package/dist/core/react-agent.d.ts.map +1 -0
- package/dist/core/react-agent.js +266 -0
- package/dist/core/react-agent.js.map +1 -0
- package/dist/core/response-schema.d.ts +91 -0
- package/dist/core/response-schema.d.ts.map +1 -0
- package/dist/core/response-schema.js +292 -0
- package/dist/core/response-schema.js.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/interface.d.ts +87 -0
- package/dist/llm/interface.d.ts.map +1 -0
- package/dist/llm/interface.js +3 -0
- package/dist/llm/interface.js.map +1 -0
- package/dist/llm/openai-provider.d.ts +92 -0
- package/dist/llm/openai-provider.d.ts.map +1 -0
- package/dist/llm/openai-provider.js +262 -0
- package/dist/llm/openai-provider.js.map +1 -0
- package/dist/messages/message.d.ts +50 -0
- package/dist/messages/message.d.ts.map +1 -0
- package/dist/messages/message.js +87 -0
- package/dist/messages/message.js.map +1 -0
- package/dist/messages/types.d.ts +31 -0
- package/dist/messages/types.d.ts.map +1 -0
- package/dist/messages/types.js +14 -0
- package/dist/messages/types.js.map +1 -0
- package/dist/preferences/preference-manager.d.ts +88 -0
- package/dist/preferences/preference-manager.d.ts.map +1 -0
- package/dist/preferences/preference-manager.js +196 -0
- package/dist/preferences/preference-manager.js.map +1 -0
- package/dist/preferences/types.d.ts +27 -0
- package/dist/preferences/types.d.ts.map +1 -0
- package/dist/preferences/types.js +3 -0
- package/dist/preferences/types.js.map +1 -0
- package/dist/session/session-manager.d.ts +56 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +156 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/session-types.d.ts +51 -0
- package/dist/session/session-types.d.ts.map +1 -0
- package/dist/session/session-types.js +3 -0
- package/dist/session/session-types.js.map +1 -0
- package/dist/skills/file-skill-loader.d.ts +88 -0
- package/dist/skills/file-skill-loader.d.ts.map +1 -0
- package/dist/skills/file-skill-loader.js +365 -0
- package/dist/skills/file-skill-loader.js.map +1 -0
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +10 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skill-manager.d.ts +133 -0
- package/dist/skills/skill-manager.d.ts.map +1 -0
- package/dist/skills/skill-manager.js +310 -0
- package/dist/skills/skill-manager.js.map +1 -0
- package/dist/skills/types.d.ts +42 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +3 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/builtin/edit-file.d.ts +12 -0
- package/dist/tools/builtin/edit-file.d.ts.map +1 -0
- package/dist/tools/builtin/edit-file.js +123 -0
- package/dist/tools/builtin/edit-file.js.map +1 -0
- package/dist/tools/builtin/glob-search.d.ts +11 -0
- package/dist/tools/builtin/glob-search.d.ts.map +1 -0
- package/dist/tools/builtin/glob-search.js +264 -0
- package/dist/tools/builtin/glob-search.js.map +1 -0
- package/dist/tools/builtin/grep-search.d.ts +14 -0
- package/dist/tools/builtin/grep-search.d.ts.map +1 -0
- package/dist/tools/builtin/grep-search.js +264 -0
- package/dist/tools/builtin/grep-search.js.map +1 -0
- package/dist/tools/builtin/index.d.ts +21 -0
- package/dist/tools/builtin/index.d.ts.map +1 -0
- package/dist/tools/builtin/index.js +53 -0
- package/dist/tools/builtin/index.js.map +1 -0
- package/dist/tools/builtin/read-file.d.ts +11 -0
- package/dist/tools/builtin/read-file.d.ts.map +1 -0
- package/dist/tools/builtin/read-file.js +122 -0
- package/dist/tools/builtin/read-file.js.map +1 -0
- package/dist/tools/builtin/write-file.d.ts +10 -0
- package/dist/tools/builtin/write-file.d.ts.map +1 -0
- package/dist/tools/builtin/write-file.js +89 -0
- package/dist/tools/builtin/write-file.js.map +1 -0
- package/dist/tools/circuit-breaker.d.ts +77 -0
- package/dist/tools/circuit-breaker.d.ts.map +1 -0
- package/dist/tools/circuit-breaker.js +102 -0
- package/dist/tools/circuit-breaker.js.map +1 -0
- package/dist/tools/error-tracker.d.ts +116 -0
- package/dist/tools/error-tracker.d.ts.map +1 -0
- package/dist/tools/error-tracker.js +484 -0
- package/dist/tools/error-tracker.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +87 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +188 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/tools/types.d.ts +95 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +14 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/utils/token-counter.d.ts +31 -0
- package/dist/utils/token-counter.d.ts.map +1 -0
- package/dist/utils/token-counter.js +105 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BreakerState, BreakerStatus } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for a circuit breaker instance.
|
|
4
|
+
*/
|
|
5
|
+
export interface CircuitBreakerConfig {
|
|
6
|
+
/** Tool name this breaker protects. */
|
|
7
|
+
toolName: string;
|
|
8
|
+
/**
|
|
9
|
+
* Number of retries allowed after the first failure.
|
|
10
|
+
* The effective maximum attempts = retryCount + 1.
|
|
11
|
+
* Default: 2 (3 total attempts before the circuit opens).
|
|
12
|
+
*/
|
|
13
|
+
retryCount?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Circuit breaker that tracks consecutive failures for a single tool.
|
|
17
|
+
*
|
|
18
|
+
* States:
|
|
19
|
+
* - CLOSED: Normal operation — executions are allowed.
|
|
20
|
+
* - OPEN: All retries exhausted — subsequent calls are blocked
|
|
21
|
+
* without attempting execution.
|
|
22
|
+
*
|
|
23
|
+
* Flow:
|
|
24
|
+
* 1st failure → 2 retries remaining → LLM should analyze the error and retry
|
|
25
|
+
* 2nd failure → 1 retry remaining
|
|
26
|
+
* 3rd failure → circuit OPENS → LLM must try a different approach
|
|
27
|
+
* Success → failure count resets to zero
|
|
28
|
+
*/
|
|
29
|
+
export declare class CircuitBreaker {
|
|
30
|
+
private toolName;
|
|
31
|
+
private retryCount;
|
|
32
|
+
private failureCount;
|
|
33
|
+
private _state;
|
|
34
|
+
constructor(config: CircuitBreakerConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Whether the circuit is closed and the tool can be called.
|
|
37
|
+
*/
|
|
38
|
+
get isAvailable(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Current breaker state.
|
|
41
|
+
*/
|
|
42
|
+
get state(): BreakerState;
|
|
43
|
+
/**
|
|
44
|
+
* Current consecutive failure count.
|
|
45
|
+
*/
|
|
46
|
+
get currentFailureCount(): number;
|
|
47
|
+
/**
|
|
48
|
+
* How many retries remain before the circuit opens.
|
|
49
|
+
* When this reaches 0 and another failure occurs, the circuit opens.
|
|
50
|
+
*/
|
|
51
|
+
get retriesRemaining(): number;
|
|
52
|
+
/**
|
|
53
|
+
* The total number of consecutive failures that would open the circuit.
|
|
54
|
+
*/
|
|
55
|
+
get effectiveThreshold(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Record a successful tool execution — resets failure count
|
|
58
|
+
* and closes the circuit if it was open.
|
|
59
|
+
*/
|
|
60
|
+
recordSuccess(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Record a failed tool execution.
|
|
63
|
+
* If all retries are exhausted, the circuit opens.
|
|
64
|
+
*
|
|
65
|
+
* @returns The updated number of retries remaining (0 means the circuit opened).
|
|
66
|
+
*/
|
|
67
|
+
recordFailure(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Manually reset the breaker back to CLOSED.
|
|
70
|
+
*/
|
|
71
|
+
reset(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Get a snapshot of the current breaker status.
|
|
74
|
+
*/
|
|
75
|
+
getStatus(): BreakerStatus;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=circuit-breaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../src/tools/circuit-breaker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,MAAM,CAAqC;gBAEvC,MAAM,EAAE,oBAAoB;IAKxC;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,YAAY,CAExB;IAED;;OAEG;IACH,IAAI,mBAAmB,IAAI,MAAM,CAEhC;IAED;;;OAGG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED;;;OAGG;IACH,aAAa,IAAI,IAAI;IAKrB;;;;;OAKG;IACH,aAAa,IAAI,MAAM;IASvB;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,SAAS,IAAI,aAAa;CAS3B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircuitBreaker = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Circuit breaker that tracks consecutive failures for a single tool.
|
|
7
|
+
*
|
|
8
|
+
* States:
|
|
9
|
+
* - CLOSED: Normal operation — executions are allowed.
|
|
10
|
+
* - OPEN: All retries exhausted — subsequent calls are blocked
|
|
11
|
+
* without attempting execution.
|
|
12
|
+
*
|
|
13
|
+
* Flow:
|
|
14
|
+
* 1st failure → 2 retries remaining → LLM should analyze the error and retry
|
|
15
|
+
* 2nd failure → 1 retry remaining
|
|
16
|
+
* 3rd failure → circuit OPENS → LLM must try a different approach
|
|
17
|
+
* Success → failure count resets to zero
|
|
18
|
+
*/
|
|
19
|
+
class CircuitBreaker {
|
|
20
|
+
toolName;
|
|
21
|
+
retryCount;
|
|
22
|
+
failureCount = 0;
|
|
23
|
+
_state = types_1.BreakerState.CLOSED;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.toolName = config.toolName;
|
|
26
|
+
this.retryCount = config.retryCount ?? 2;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether the circuit is closed and the tool can be called.
|
|
30
|
+
*/
|
|
31
|
+
get isAvailable() {
|
|
32
|
+
return this._state === types_1.BreakerState.CLOSED;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Current breaker state.
|
|
36
|
+
*/
|
|
37
|
+
get state() {
|
|
38
|
+
return this._state;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Current consecutive failure count.
|
|
42
|
+
*/
|
|
43
|
+
get currentFailureCount() {
|
|
44
|
+
return this.failureCount;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How many retries remain before the circuit opens.
|
|
48
|
+
* When this reaches 0 and another failure occurs, the circuit opens.
|
|
49
|
+
*/
|
|
50
|
+
get retriesRemaining() {
|
|
51
|
+
return Math.max(0, this.retryCount - this.failureCount);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The total number of consecutive failures that would open the circuit.
|
|
55
|
+
*/
|
|
56
|
+
get effectiveThreshold() {
|
|
57
|
+
return this.retryCount + 1;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Record a successful tool execution — resets failure count
|
|
61
|
+
* and closes the circuit if it was open.
|
|
62
|
+
*/
|
|
63
|
+
recordSuccess() {
|
|
64
|
+
this.failureCount = 0;
|
|
65
|
+
this._state = types_1.BreakerState.CLOSED;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Record a failed tool execution.
|
|
69
|
+
* If all retries are exhausted, the circuit opens.
|
|
70
|
+
*
|
|
71
|
+
* @returns The updated number of retries remaining (0 means the circuit opened).
|
|
72
|
+
*/
|
|
73
|
+
recordFailure() {
|
|
74
|
+
this.failureCount++;
|
|
75
|
+
if (this.failureCount > this.retryCount) {
|
|
76
|
+
this._state = types_1.BreakerState.OPEN;
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
return this.retriesRemaining;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Manually reset the breaker back to CLOSED.
|
|
83
|
+
*/
|
|
84
|
+
reset() {
|
|
85
|
+
this.failureCount = 0;
|
|
86
|
+
this._state = types_1.BreakerState.CLOSED;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get a snapshot of the current breaker status.
|
|
90
|
+
*/
|
|
91
|
+
getStatus() {
|
|
92
|
+
return {
|
|
93
|
+
toolName: this.toolName,
|
|
94
|
+
state: this._state,
|
|
95
|
+
failureCount: this.failureCount,
|
|
96
|
+
failureThreshold: this.effectiveThreshold,
|
|
97
|
+
available: this.isAvailable,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.CircuitBreaker = CircuitBreaker;
|
|
102
|
+
//# sourceMappingURL=circuit-breaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuit-breaker.js","sourceRoot":"","sources":["../../src/tools/circuit-breaker.ts"],"names":[],"mappings":";;;AAAA,mCAAsD;AAiBtD;;;;;;;;;;;;;GAaG;AACH,MAAa,cAAc;IACjB,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,YAAY,GAAG,CAAC,CAAC;IACjB,MAAM,GAAiB,oBAAY,CAAC,MAAM,CAAC;IAEnD,YAAY,MAA4B;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAA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SAC5B,CAAC;IACJ,CAAC;CACF;AA3FD,wCA2FC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ToolErrorTrace, ErrorTraceSummary } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the ToolErrorTracker.
|
|
4
|
+
*/
|
|
5
|
+
export interface ErrorTrackerConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Directory where trace files are stored.
|
|
8
|
+
* Defaults to `.error-traces` relative to the working directory.
|
|
9
|
+
*/
|
|
10
|
+
storageDir?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to persist traces to disk immediately.
|
|
13
|
+
* Defaults to true.
|
|
14
|
+
*/
|
|
15
|
+
persistImmediately?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Categorize a tool error based on its message content.
|
|
19
|
+
* Helps developers quickly identify common failure patterns.
|
|
20
|
+
*/
|
|
21
|
+
export declare function categorizeError(error: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* ToolErrorTracker records the complete lifecycle of tool failures.
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* ```ts
|
|
27
|
+
* const tracker = new ToolErrorTracker({ storageDir: ".error-traces" });
|
|
28
|
+
* const registry = new ToolRegistry({ errorTracker: tracker });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Lifecycle of a trace:
|
|
32
|
+
* 1. First failure → `recordFailure()` creates a new trace
|
|
33
|
+
* 2. LLM analysis → `recordAnalysis()` attaches the LLM's reasoning
|
|
34
|
+
* 3. Retry failure → `recordFailure()` appends to the existing trace
|
|
35
|
+
* 4. Recovery → `recordRecovery()` marks the trace as resolved
|
|
36
|
+
* 5. Circuit open → `recordFailure()` marks the trace as unresolved
|
|
37
|
+
*
|
|
38
|
+
* All traces are persisted as individual JSON files in the storage
|
|
39
|
+
* directory, plus an index file for quick browsing.
|
|
40
|
+
*/
|
|
41
|
+
export declare class ToolErrorTracker {
|
|
42
|
+
private traces;
|
|
43
|
+
private activeTraceByTool;
|
|
44
|
+
private storageDir;
|
|
45
|
+
private persistImmediately;
|
|
46
|
+
private sessionId?;
|
|
47
|
+
constructor(config?: ErrorTrackerConfig);
|
|
48
|
+
/**
|
|
49
|
+
* Set a session identifier that will be attached to all traces.
|
|
50
|
+
*/
|
|
51
|
+
setSessionId(id: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Record a tool execution failure.
|
|
54
|
+
*
|
|
55
|
+
* - If this is the first failure for the tool in the current chain,
|
|
56
|
+
* a new trace is created.
|
|
57
|
+
* - If a trace for this tool already exists and is still open,
|
|
58
|
+
* the failure is appended as a retry event.
|
|
59
|
+
*
|
|
60
|
+
* @returns The trace ID for the chain this failure belongs to.
|
|
61
|
+
*/
|
|
62
|
+
recordFailure(toolName: string, args: Record<string, unknown>, error: string, retriesRemaining: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* Record a tool recovery (successful execution after previous failures).
|
|
65
|
+
*
|
|
66
|
+
* @param toolName The tool that recovered.
|
|
67
|
+
* @param traceId The trace ID for this failure chain.
|
|
68
|
+
* @param resolution Optional description of how it was resolved.
|
|
69
|
+
*/
|
|
70
|
+
recordRecovery(toolName: string, traceId: string, resolution?: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Attach LLM analysis to the latest failure/retry event in a trace.
|
|
73
|
+
*
|
|
74
|
+
* Called by the agent after the LLM has reasoned about a tool error.
|
|
75
|
+
*/
|
|
76
|
+
recordAnalysis(traceId: string, analysis: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get a full trace by ID.
|
|
79
|
+
*/
|
|
80
|
+
getTrace(traceId: string): ToolErrorTrace | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Get all trace summaries — lightweight list for browsing.
|
|
83
|
+
*/
|
|
84
|
+
getAllSummaries(): ErrorTraceSummary[];
|
|
85
|
+
/**
|
|
86
|
+
* Get the active (open, unresolved) trace ID for a tool, if any.
|
|
87
|
+
*/
|
|
88
|
+
getActiveTraceId(toolName: string): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Get the total number of traces recorded.
|
|
91
|
+
*/
|
|
92
|
+
get traceCount(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Persist all traces to disk immediately.
|
|
95
|
+
*/
|
|
96
|
+
persistAll(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Load traces from disk (e.g., on startup to resume monitoring).
|
|
99
|
+
*/
|
|
100
|
+
loadFromDisk(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Generate a human-readable markdown report of all traces.
|
|
103
|
+
*/
|
|
104
|
+
generateMarkdownReport(): string;
|
|
105
|
+
/**
|
|
106
|
+
* Delete all stored traces.
|
|
107
|
+
*/
|
|
108
|
+
clearAll(): void;
|
|
109
|
+
private createTrace;
|
|
110
|
+
private persistTrace;
|
|
111
|
+
private ensureStorageDir;
|
|
112
|
+
private writeTraceFile;
|
|
113
|
+
private writeIndexFile;
|
|
114
|
+
private formatEventType;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=error-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-tracker.d.ts","sourceRoot":"","sources":["../../src/tools/error-tracker.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,cAAc,EAEd,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAoDD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6BrD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAA0C;IACxD,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,kB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