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,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolRegistry = void 0;
|
|
4
|
+
const circuit_breaker_1 = require("./circuit-breaker");
|
|
5
|
+
/**
|
|
6
|
+
* Registry that manages tool definitions together with circuit breakers.
|
|
7
|
+
*
|
|
8
|
+
* Provides:
|
|
9
|
+
* - Tool registration and lookup
|
|
10
|
+
* - Safe execution with circuit breaker protection
|
|
11
|
+
* - Per-tool failure tracking with retry guidance
|
|
12
|
+
*/
|
|
13
|
+
class ToolRegistry {
|
|
14
|
+
tools = new Map();
|
|
15
|
+
breakers = new Map();
|
|
16
|
+
retryCount;
|
|
17
|
+
errorTracker;
|
|
18
|
+
/**
|
|
19
|
+
* @param retryCount Number of retries allowed after the first failure
|
|
20
|
+
* (default: 2 → 3 total attempts before circuit opens).
|
|
21
|
+
* @param errorTracker Optional ToolErrorTracker for recording failure chains.
|
|
22
|
+
*/
|
|
23
|
+
constructor(retryCount, errorTracker) {
|
|
24
|
+
this.retryCount = retryCount ?? 2;
|
|
25
|
+
this.errorTracker = errorTracker;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Register a tool. Creates a circuit breaker for it automatically.
|
|
29
|
+
*/
|
|
30
|
+
register(tool) {
|
|
31
|
+
if (this.tools.has(tool.name)) {
|
|
32
|
+
throw new Error(`Tool "${tool.name}" is already registered.`);
|
|
33
|
+
}
|
|
34
|
+
this.tools.set(tool.name, tool);
|
|
35
|
+
this.breakers.set(tool.name, new circuit_breaker_1.CircuitBreaker({
|
|
36
|
+
toolName: tool.name,
|
|
37
|
+
retryCount: this.retryCount,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Register multiple tools at once.
|
|
42
|
+
*/
|
|
43
|
+
registerMany(tools) {
|
|
44
|
+
for (const tool of tools) {
|
|
45
|
+
this.register(tool);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get a tool by name. Returns undefined if not found.
|
|
50
|
+
*/
|
|
51
|
+
getTool(name) {
|
|
52
|
+
return this.tools.get(name);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get all registered tools (for passing to the LLM).
|
|
56
|
+
*/
|
|
57
|
+
getTools() {
|
|
58
|
+
return Array.from(this.tools.values());
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Remove a tool and its circuit breaker.
|
|
62
|
+
*/
|
|
63
|
+
remove(name) {
|
|
64
|
+
this.breakers.delete(name);
|
|
65
|
+
return this.tools.delete(name);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if a tool is registered.
|
|
69
|
+
*/
|
|
70
|
+
has(name) {
|
|
71
|
+
return this.tools.has(name);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the number of registered tools.
|
|
75
|
+
*/
|
|
76
|
+
get count() {
|
|
77
|
+
return this.tools.size;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get all registered tool names.
|
|
81
|
+
*/
|
|
82
|
+
get toolNames() {
|
|
83
|
+
return Array.from(this.tools.keys());
|
|
84
|
+
}
|
|
85
|
+
// ─── Circuit Breaker ───────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* Execute a tool with circuit-breaker protection and retry guidance.
|
|
88
|
+
*
|
|
89
|
+
* - If the circuit is OPEN, returns an error message with a recommendation
|
|
90
|
+
* to try a different approach.
|
|
91
|
+
* - If execution fails and retries remain, returns a message telling the LLM
|
|
92
|
+
* to analyze the error and retry with corrected parameters.
|
|
93
|
+
* - If execution succeeds, records a success (resets failure count).
|
|
94
|
+
*
|
|
95
|
+
* @returns The tool's result string, or an error message with retry guidance.
|
|
96
|
+
*/
|
|
97
|
+
async execute(name, args) {
|
|
98
|
+
const tool = this.tools.get(name);
|
|
99
|
+
if (!tool) {
|
|
100
|
+
return (`Error: Unknown tool "${name}". Available tools: ${this.toolNames.join(", ")}. ` +
|
|
101
|
+
`Please check the tool name and try again.`);
|
|
102
|
+
}
|
|
103
|
+
const breaker = this.breakers.get(name);
|
|
104
|
+
// Circuit breaker check — circuit is OPEN
|
|
105
|
+
if (!breaker.isAvailable) {
|
|
106
|
+
const status = breaker.getStatus();
|
|
107
|
+
return (`Error: Tool "${name}" has been automatically disabled after ${status.failureCount} consecutive failures. ` +
|
|
108
|
+
`It cannot be used again in this session. ` +
|
|
109
|
+
`Please try a completely different approach that does not rely on this tool. ` +
|
|
110
|
+
`Available alternatives: ${this.toolNames.filter((n) => n !== name).join(", ") || "none — try a different method."}`);
|
|
111
|
+
}
|
|
112
|
+
// Execute with failure tracking and retry guidance
|
|
113
|
+
try {
|
|
114
|
+
const result = await tool.execute(args);
|
|
115
|
+
// Success after previous failures — record recovery + reset breaker
|
|
116
|
+
if (breaker.currentFailureCount > 0) {
|
|
117
|
+
// Record recovery in the error tracker
|
|
118
|
+
if (this.errorTracker) {
|
|
119
|
+
const activeTrace = this.errorTracker.getActiveTraceId(name);
|
|
120
|
+
if (activeTrace) {
|
|
121
|
+
this.errorTracker.recordRecovery(name, activeTrace, `Tool "${name}" executed successfully after ${breaker.currentFailureCount} failure(s).`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
breaker.recordSuccess();
|
|
125
|
+
return (`${result}\n\n` +
|
|
126
|
+
`[Tool "${name}" has recovered after previous failures. The failure counter has been reset.]`);
|
|
127
|
+
}
|
|
128
|
+
breaker.recordSuccess();
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
const rawMessage = err instanceof Error ? err.message : String(err);
|
|
133
|
+
const remaining = breaker.recordFailure();
|
|
134
|
+
// Record the failure in the error tracker
|
|
135
|
+
if (this.errorTracker) {
|
|
136
|
+
this.errorTracker.recordFailure(name, args, rawMessage, remaining);
|
|
137
|
+
}
|
|
138
|
+
// Circuit just opened — no retries left
|
|
139
|
+
if (!breaker.isAvailable) {
|
|
140
|
+
return (`Error executing tool "${name}": ${rawMessage}\n\n` +
|
|
141
|
+
`This was the final attempt. The tool "${name}" is now disabled after ${breaker.currentFailureCount} consecutive failures. ` +
|
|
142
|
+
`Please do NOT try to use "${name}" again. Instead, try a different approach or a different tool.`);
|
|
143
|
+
}
|
|
144
|
+
// Retries still available — guide the LLM to re-analyze
|
|
145
|
+
const attemptNum = breaker.currentFailureCount;
|
|
146
|
+
const totalAllowed = breaker.effectiveThreshold;
|
|
147
|
+
return (`Error executing tool "${name}": ${rawMessage}\n\n` +
|
|
148
|
+
`[Retry Guidance] This is attempt ${attemptNum} of ${totalAllowed}. ` +
|
|
149
|
+
`You have ${remaining} retry attempt${remaining > 1 ? "s" : ""} remaining.\n` +
|
|
150
|
+
`Please analyze the error above carefully, correct the parameters, and retry. ` +
|
|
151
|
+
`If you believe the issue is with the input, try a different approach or different arguments.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get the error tracker instance, if one is configured.
|
|
156
|
+
*/
|
|
157
|
+
getErrorTracker() {
|
|
158
|
+
return this.errorTracker;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the circuit breaker status for a tool.
|
|
162
|
+
*/
|
|
163
|
+
getBreakerStatus(name) {
|
|
164
|
+
return this.breakers.get(name)?.getStatus();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get status for all tools.
|
|
168
|
+
*/
|
|
169
|
+
getAllBreakerStatuses() {
|
|
170
|
+
return Array.from(this.breakers.values()).map((b) => b.getStatus());
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Manually reset the circuit breaker for a specific tool.
|
|
174
|
+
*/
|
|
175
|
+
resetBreaker(name) {
|
|
176
|
+
this.breakers.get(name)?.reset();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Reset all circuit breakers.
|
|
180
|
+
*/
|
|
181
|
+
resetAllBreakers() {
|
|
182
|
+
for (const breaker of this.breakers.values()) {
|
|
183
|
+
breaker.reset();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.ToolRegistry = ToolRegistry;
|
|
188
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":";;;AACA,uDAAmD;AAGnD;;;;;;;GAOG;AACH,MAAa,YAAY;IACf,KAAK,GAAsB,IAAI,GAAG,EAAE,CAAC;IACrC,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAC;IAClD,UAAU,CAAS;IACnB,YAAY,CAAoB;IAExC;;;;OAIG;IACH,YAAY,UAAmB,EAAE,YAA+B;QAC9D,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAU;QACjB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,0BAA0B,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI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OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,qBAAqB;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,IAAY;QACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;CACF;AAnND,oCAmNC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool that an agent can invoke.
|
|
3
|
+
*/
|
|
4
|
+
export interface Tool {
|
|
5
|
+
/** Unique name of the tool. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Description of what the tool does (used by the LLM to decide when to call it). */
|
|
8
|
+
description: string;
|
|
9
|
+
/** JSON Schema describing the tool's parameters. */
|
|
10
|
+
parameters: Record<string, unknown>;
|
|
11
|
+
/** Execute the tool with the given arguments and return a result string. */
|
|
12
|
+
execute(args: Record<string, unknown>): Promise<string>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Current state of a circuit breaker for a specific tool.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum BreakerState {
|
|
18
|
+
/** Normal operation — tool calls are allowed. */
|
|
19
|
+
CLOSED = "closed",
|
|
20
|
+
/** Failure threshold reached — tool calls are blocked. */
|
|
21
|
+
OPEN = "open"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Status snapshot of a circuit breaker.
|
|
25
|
+
*/
|
|
26
|
+
export interface BreakerStatus {
|
|
27
|
+
/** Tool name. */
|
|
28
|
+
toolName: string;
|
|
29
|
+
/** Current circuit breaker state. */
|
|
30
|
+
state: BreakerState;
|
|
31
|
+
/** Current consecutive failure count. */
|
|
32
|
+
failureCount: number;
|
|
33
|
+
/** Max failures before the breaker opens. */
|
|
34
|
+
failureThreshold: number;
|
|
35
|
+
/** Whether the tool is available for calling. */
|
|
36
|
+
available: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A single event within an error trace chain.
|
|
40
|
+
*/
|
|
41
|
+
export interface TraceEvent {
|
|
42
|
+
/** Event type. */
|
|
43
|
+
type: "failure" | "retry" | "recovery" | "circuit_open" | "analysis";
|
|
44
|
+
/** When the event occurred. */
|
|
45
|
+
timestamp: string;
|
|
46
|
+
/** The error message (for failure/retry events). */
|
|
47
|
+
error?: string;
|
|
48
|
+
/** The attempt number (1-based). */
|
|
49
|
+
attemptNumber?: number;
|
|
50
|
+
/** How many retries remain after this attempt. */
|
|
51
|
+
retriesRemaining?: number;
|
|
52
|
+
/** LLM's analysis of the error (captured from agent). */
|
|
53
|
+
analysis?: string;
|
|
54
|
+
/** Resolution description (for recovery events). */
|
|
55
|
+
resolution?: string;
|
|
56
|
+
/** Arguments used in this attempt (for comparison). */
|
|
57
|
+
arguments?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Full trace of a tool error chain — from first failure through retries
|
|
61
|
+
* to either resolution or circuit-open.
|
|
62
|
+
*/
|
|
63
|
+
export interface ToolErrorTrace {
|
|
64
|
+
/** Unique trace identifier. */
|
|
65
|
+
traceId: string;
|
|
66
|
+
/** Name of the tool that failed. */
|
|
67
|
+
toolName: string;
|
|
68
|
+
/** Session identifier (if available). */
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
/** When the trace was created (first failure). */
|
|
71
|
+
createdAt: string;
|
|
72
|
+
/** When the trace was last updated. */
|
|
73
|
+
updatedAt: string;
|
|
74
|
+
/** Whether the tool eventually recovered. */
|
|
75
|
+
resolved: boolean;
|
|
76
|
+
/** Original arguments that caused the first failure. */
|
|
77
|
+
originalArguments: Record<string, unknown>;
|
|
78
|
+
/** All events in this trace, in chronological order. */
|
|
79
|
+
events: TraceEvent[];
|
|
80
|
+
/** Eventual resolution description (if resolved). */
|
|
81
|
+
resolution?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Lightweight summary of a trace for listing/indexing.
|
|
85
|
+
*/
|
|
86
|
+
export interface ErrorTraceSummary {
|
|
87
|
+
traceId: string;
|
|
88
|
+
toolName: string;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
resolved: boolean;
|
|
91
|
+
errorCount: number;
|
|
92
|
+
firstError: string;
|
|
93
|
+
resolution?: string;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,4EAA4E;IAC5E,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,iDAAiD;IACjD,MAAM,WAAW;IACjB,0DAA0D;IAC1D,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,KAAK,EAAE,YAAY,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;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BreakerState = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Current state of a circuit breaker for a specific tool.
|
|
6
|
+
*/
|
|
7
|
+
var BreakerState;
|
|
8
|
+
(function (BreakerState) {
|
|
9
|
+
/** Normal operation — tool calls are allowed. */
|
|
10
|
+
BreakerState["CLOSED"] = "closed";
|
|
11
|
+
/** Failure threshold reached — tool calls are blocked. */
|
|
12
|
+
BreakerState["OPEN"] = "open";
|
|
13
|
+
})(BreakerState || (exports.BreakerState = BreakerState = {}));
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":";;;AAcA;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,iDAAiD;IACjD,iCAAiB,CAAA;IACjB,0DAA0D;IAC1D,6BAAa,CAAA;AACf,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token counting utility.
|
|
3
|
+
*
|
|
4
|
+
* Uses the `tiktoken` package for accurate tokenization when available.
|
|
5
|
+
* Falls back to a simple character-based heuristic (~4 chars/token) on failure.
|
|
6
|
+
*
|
|
7
|
+
* The tiktoken module is loaded lazily and cached after the first successful check.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Count tokens in a text string.
|
|
11
|
+
*
|
|
12
|
+
* Uses tiktoken (by model name) when available, falling back to
|
|
13
|
+
* a simple ~4 characters-per-token heuristic.
|
|
14
|
+
*
|
|
15
|
+
* @param text The text to count tokens in.
|
|
16
|
+
* @param model The OpenAI model name for accurate encoding (e.g. "gpt-4o", "gpt-4o-mini").
|
|
17
|
+
* Defaults to "gpt-4o". Only used when tiktoken is available.
|
|
18
|
+
*/
|
|
19
|
+
export declare function countTokens(text: string, model?: string): number;
|
|
20
|
+
/**
|
|
21
|
+
* Count tokens in an array of messages.
|
|
22
|
+
* For each message, adds a small overhead for the role metadata.
|
|
23
|
+
*
|
|
24
|
+
* @param messages Array of message-like objects.
|
|
25
|
+
* @param model Optional model name for accurate token counting.
|
|
26
|
+
*/
|
|
27
|
+
export declare function countMessageTokens(messages: {
|
|
28
|
+
role: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}[], model?: string): number;
|
|
31
|
+
//# sourceMappingURL=token-counter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../../src/utils/token-counter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoDH;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAchE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,EAC7C,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAUR"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Token counting utility.
|
|
4
|
+
*
|
|
5
|
+
* Uses the `tiktoken` package for accurate tokenization when available.
|
|
6
|
+
* Falls back to a simple character-based heuristic (~4 chars/token) on failure.
|
|
7
|
+
*
|
|
8
|
+
* The tiktoken module is loaded lazily and cached after the first successful check.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.countTokens = countTokens;
|
|
12
|
+
exports.countMessageTokens = countMessageTokens;
|
|
13
|
+
let _tiktoken = null;
|
|
14
|
+
let _tiktokenChecked = false;
|
|
15
|
+
/**
|
|
16
|
+
* Try to load the tiktoken module (once, cached).
|
|
17
|
+
*/
|
|
18
|
+
function getTiktokenModule() {
|
|
19
|
+
if (!_tiktokenChecked) {
|
|
20
|
+
_tiktokenChecked = true;
|
|
21
|
+
try {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
23
|
+
_tiktoken = require("tiktoken");
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// tiktoken not available — fallback will be used
|
|
27
|
+
_tiktoken = null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return _tiktoken;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Encode text via tiktoken and return the token count.
|
|
34
|
+
* Falls back to heuristic if anything goes wrong.
|
|
35
|
+
*/
|
|
36
|
+
function countWithTiktoken(text, model) {
|
|
37
|
+
const tk = getTiktokenModule();
|
|
38
|
+
if (!tk)
|
|
39
|
+
throw new Error("tiktoken not loaded");
|
|
40
|
+
let enc;
|
|
41
|
+
try {
|
|
42
|
+
// Try to get the encoding for the requested model
|
|
43
|
+
enc = tk.encoding_for_model(model ?? "gpt-4o");
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Unknown model — use o200k_base (covers GPT-4o, GPT-4o-mini)
|
|
47
|
+
// Fall back to cl100k_base for older models if o200k_base also fails
|
|
48
|
+
try {
|
|
49
|
+
enc = tk.get_encoding("o200k_base");
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
enc = tk.get_encoding("cl100k_base");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return enc.encode(text).length;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
// Free the encoder to avoid memory leaks (tiktoken is wasm-backed)
|
|
60
|
+
enc.free();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Count tokens in a text string.
|
|
65
|
+
*
|
|
66
|
+
* Uses tiktoken (by model name) when available, falling back to
|
|
67
|
+
* a simple ~4 characters-per-token heuristic.
|
|
68
|
+
*
|
|
69
|
+
* @param text The text to count tokens in.
|
|
70
|
+
* @param model The OpenAI model name for accurate encoding (e.g. "gpt-4o", "gpt-4o-mini").
|
|
71
|
+
* Defaults to "gpt-4o". Only used when tiktoken is available.
|
|
72
|
+
*/
|
|
73
|
+
function countTokens(text, model) {
|
|
74
|
+
if (!text)
|
|
75
|
+
return 0;
|
|
76
|
+
// Try tiktoken first
|
|
77
|
+
if (getTiktokenModule()) {
|
|
78
|
+
try {
|
|
79
|
+
return countWithTiktoken(text, model);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// tiktoken failed — fall through to heuristic
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Heuristic fallback: ~4 characters per token (standard English approximation)
|
|
86
|
+
return Math.ceil(text.length / 4);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Count tokens in an array of messages.
|
|
90
|
+
* For each message, adds a small overhead for the role metadata.
|
|
91
|
+
*
|
|
92
|
+
* @param messages Array of message-like objects.
|
|
93
|
+
* @param model Optional model name for accurate token counting.
|
|
94
|
+
*/
|
|
95
|
+
function countMessageTokens(messages, model) {
|
|
96
|
+
// Per-message format overhead (role tag, spacing, etc.)
|
|
97
|
+
const PER_MESSAGE_OVERHEAD = 3;
|
|
98
|
+
let total = 0;
|
|
99
|
+
for (const msg of messages) {
|
|
100
|
+
total += PER_MESSAGE_OVERHEAD;
|
|
101
|
+
total += countTokens(msg.content, model);
|
|
102
|
+
}
|
|
103
|
+
return total;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=token-counter.js.map
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G,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,KAAc;IACtD,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IAEpB,qBAAqB;IACrB,IAAI,iBAAiB,EAAE,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,OAAO,iBAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,QAA6C,EAC7C,KAAc;IAEd,wDAAwD;IACxD,MAAM,oBAAoB,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,KAAK,IAAI,oBAAoB,CAAC;QAC9B,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kagent-ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A TypeScript agent framework — ReAct / Plan-Solve agent loops, tool management with circuit breaker, session persistence and resume, file-based progressive skills, and user preference injection.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"build:watch": "tsc --watch",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"prepack": "npm run build",
|
|
16
|
+
"test": "echo \"No tests yet — see src/ for manual test patterns\""
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"agent",
|
|
20
|
+
"llm",
|
|
21
|
+
"react",
|
|
22
|
+
"plan-solve",
|
|
23
|
+
"ai",
|
|
24
|
+
"framework",
|
|
25
|
+
"typescript",
|
|
26
|
+
"openai",
|
|
27
|
+
"agents",
|
|
28
|
+
"tool-use"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"author": "kyk",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/kkhhhh-ll/kagent-ts"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/kkhhhh-ll/kagent-ts#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/kkhhhh-ll/kagent-ts/issues"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"openai": "^4.80.0"
|
|
48
|
+
},
|
|
49
|
+
"optionalDependencies": {
|
|
50
|
+
"tiktoken": "^1.0.22"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^22.0.0",
|
|
54
|
+
"typescript": "^5.7.0"
|
|
55
|
+
}
|
|
56
|
+
}
|