kagent-ts 0.1.4 → 0.1.5
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 +68 -21
- package/README.md +27 -371
- package/dist/compression/progressive-compressor.d.ts +66 -0
- package/dist/compression/progressive-compressor.d.ts.map +1 -0
- package/dist/compression/progressive-compressor.js +367 -0
- package/dist/compression/progressive-compressor.js.map +1 -0
- package/dist/compression/types.d.ts +1 -5
- package/dist/compression/types.d.ts.map +1 -1
- package/dist/context/context-manager.d.ts +34 -15
- package/dist/context/context-manager.d.ts.map +1 -1
- package/dist/context/context-manager.js +78 -28
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/types.d.ts +20 -4
- package/dist/context/types.d.ts.map +1 -1
- package/dist/core/agent.d.ts +354 -25
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +646 -64
- package/dist/core/agent.js.map +1 -1
- package/dist/core/fusion-agent.d.ts +207 -0
- package/dist/core/fusion-agent.d.ts.map +1 -0
- package/dist/core/fusion-agent.js +769 -0
- package/dist/core/fusion-agent.js.map +1 -0
- package/dist/core/hooks.d.ts +19 -7
- package/dist/core/hooks.d.ts.map +1 -1
- package/dist/core/plan-solve-agent.d.ts +1 -15
- package/dist/core/plan-solve-agent.d.ts.map +1 -1
- package/dist/core/plan-solve-agent.js +142 -117
- package/dist/core/plan-solve-agent.js.map +1 -1
- package/dist/core/react-agent.d.ts +0 -13
- package/dist/core/react-agent.d.ts.map +1 -1
- package/dist/core/react-agent.js +127 -102
- package/dist/core/react-agent.js.map +1 -1
- package/dist/core/response-schema.d.ts +65 -0
- package/dist/core/response-schema.d.ts.map +1 -1
- package/dist/core/response-schema.js +174 -1
- package/dist/core/response-schema.js.map +1 -1
- package/dist/core/system-prompts.d.ts +27 -0
- package/dist/core/system-prompts.d.ts.map +1 -0
- package/dist/core/system-prompts.js +112 -0
- package/dist/core/system-prompts.js.map +1 -0
- package/dist/eval/benchmark.d.ts +81 -0
- package/dist/eval/benchmark.d.ts.map +1 -0
- package/dist/eval/benchmark.js +292 -0
- package/dist/eval/benchmark.js.map +1 -0
- package/dist/eval/eval-runner.d.ts +79 -0
- package/dist/eval/eval-runner.d.ts.map +1 -0
- package/dist/eval/eval-runner.js +252 -0
- package/dist/eval/eval-runner.js.map +1 -0
- package/dist/eval/index.d.ts +7 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +13 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/tool-call-evaluator.d.ts +72 -0
- package/dist/eval/tool-call-evaluator.d.ts.map +1 -0
- package/dist/eval/tool-call-evaluator.js +265 -0
- package/dist/eval/tool-call-evaluator.js.map +1 -0
- package/dist/eval/types.d.ts +219 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +3 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/index.d.ts +58 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -8
- package/dist/index.js.map +1 -1
- package/dist/llm/anthropic-provider.d.ts +141 -0
- package/dist/llm/anthropic-provider.d.ts.map +1 -0
- package/dist/llm/anthropic-provider.js +486 -0
- package/dist/llm/anthropic-provider.js.map +1 -0
- package/dist/llm/errors.d.ts +26 -0
- package/dist/llm/errors.d.ts.map +1 -0
- package/dist/llm/errors.js +19 -0
- package/dist/llm/errors.js.map +1 -0
- package/dist/llm/factory.d.ts +73 -0
- package/dist/llm/factory.d.ts.map +1 -0
- package/dist/llm/factory.js +77 -0
- package/dist/llm/factory.js.map +1 -0
- package/dist/llm/fallback-provider.d.ts +47 -0
- package/dist/llm/fallback-provider.d.ts.map +1 -0
- package/dist/llm/fallback-provider.js +91 -0
- package/dist/llm/fallback-provider.js.map +1 -0
- package/dist/llm/interface.d.ts +54 -11
- package/dist/llm/interface.d.ts.map +1 -1
- package/dist/llm/interface.js +34 -0
- package/dist/llm/interface.js.map +1 -1
- package/dist/llm/model-router.d.ts +126 -0
- package/dist/llm/model-router.d.ts.map +1 -0
- package/dist/llm/model-router.js +178 -0
- package/dist/llm/model-router.js.map +1 -0
- package/dist/llm/openai-provider.d.ts +8 -32
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +27 -60
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/rate-limiter.d.ts +41 -0
- package/dist/llm/rate-limiter.d.ts.map +1 -0
- package/dist/llm/rate-limiter.js +93 -0
- package/dist/llm/rate-limiter.js.map +1 -0
- package/dist/llm/retry.d.ts +26 -0
- package/dist/llm/retry.d.ts.map +1 -0
- package/dist/llm/retry.js +44 -0
- package/dist/llm/retry.js.map +1 -0
- package/dist/llm/token-budget.d.ts +97 -0
- package/dist/llm/token-budget.d.ts.map +1 -0
- package/dist/llm/token-budget.js +115 -0
- package/dist/llm/token-budget.js.map +1 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +7 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +38 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +34 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/mcp/mcp-client-manager.d.ts +10 -2
- package/dist/mcp/mcp-client-manager.d.ts.map +1 -1
- package/dist/mcp/mcp-client-manager.js +20 -9
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/memory/index.d.ts +3 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +6 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory-manager.d.ts +119 -0
- package/dist/memory/memory-manager.d.ts.map +1 -0
- package/dist/memory/memory-manager.js +334 -0
- package/dist/memory/memory-manager.js.map +1 -0
- package/dist/messages/types.d.ts +2 -0
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/orchestrator/index.d.ts +5 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +13 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/json-extractor.d.ts +18 -0
- package/dist/orchestrator/json-extractor.d.ts.map +1 -0
- package/dist/orchestrator/json-extractor.js +111 -0
- package/dist/orchestrator/json-extractor.js.map +1 -0
- package/dist/orchestrator/orchestrator-agent.d.ts +152 -0
- package/dist/orchestrator/orchestrator-agent.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator-agent.js +675 -0
- package/dist/orchestrator/orchestrator-agent.js.map +1 -0
- package/dist/orchestrator/orchestrator-response.d.ts +40 -0
- package/dist/orchestrator/orchestrator-response.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator-response.js +275 -0
- package/dist/orchestrator/orchestrator-response.js.map +1 -0
- package/dist/orchestrator/orchestrator-types.d.ts +116 -0
- package/dist/orchestrator/orchestrator-types.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator-types.js +3 -0
- package/dist/orchestrator/orchestrator-types.js.map +1 -0
- package/dist/preferences/preference-manager.d.ts +8 -3
- package/dist/preferences/preference-manager.d.ts.map +1 -1
- package/dist/preferences/preference-manager.js +17 -4
- package/dist/preferences/preference-manager.js.map +1 -1
- package/dist/rag/chroma-store.d.ts +52 -0
- package/dist/rag/chroma-store.d.ts.map +1 -0
- package/dist/rag/chroma-store.js +110 -0
- package/dist/rag/chroma-store.js.map +1 -0
- package/dist/rag/document-loader.d.ts +21 -0
- package/dist/rag/document-loader.d.ts.map +1 -0
- package/dist/rag/document-loader.js +129 -0
- package/dist/rag/document-loader.js.map +1 -0
- package/dist/rag/embedding-provider.d.ts +36 -0
- package/dist/rag/embedding-provider.d.ts.map +1 -0
- package/dist/rag/embedding-provider.js +74 -0
- package/dist/rag/embedding-provider.js.map +1 -0
- package/dist/rag/index.d.ts +17 -0
- package/dist/rag/index.d.ts.map +1 -0
- package/dist/rag/index.js +27 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/rag/keyword-index.d.ts +53 -0
- package/dist/rag/keyword-index.d.ts.map +1 -0
- package/dist/rag/keyword-index.js +161 -0
- package/dist/rag/keyword-index.js.map +1 -0
- package/dist/rag/llm-reranker.d.ts +36 -0
- package/dist/rag/llm-reranker.d.ts.map +1 -0
- package/dist/rag/llm-reranker.js +95 -0
- package/dist/rag/llm-reranker.js.map +1 -0
- package/dist/rag/rag-manager.d.ts +54 -0
- package/dist/rag/rag-manager.d.ts.map +1 -0
- package/dist/rag/rag-manager.js +179 -0
- package/dist/rag/rag-manager.js.map +1 -0
- package/dist/rag/rag-types.d.ts +143 -0
- package/dist/rag/rag-types.d.ts.map +1 -0
- package/dist/rag/rag-types.js +9 -0
- package/dist/rag/rag-types.js.map +1 -0
- package/dist/rag/rrf.d.ts +47 -0
- package/dist/rag/rrf.d.ts.map +1 -0
- package/dist/rag/rrf.js +70 -0
- package/dist/rag/rrf.js.map +1 -0
- package/dist/rag/search-knowledge.d.ts +24 -0
- package/dist/rag/search-knowledge.d.ts.map +1 -0
- package/dist/rag/search-knowledge.js +86 -0
- package/dist/rag/search-knowledge.js.map +1 -0
- package/dist/rag/text-splitter.d.ts +25 -0
- package/dist/rag/text-splitter.d.ts.map +1 -0
- package/dist/rag/text-splitter.js +136 -0
- package/dist/rag/text-splitter.js.map +1 -0
- package/dist/rag/vector-store.d.ts +34 -0
- package/dist/rag/vector-store.d.ts.map +1 -0
- package/dist/rag/vector-store.js +73 -0
- package/dist/rag/vector-store.js.map +1 -0
- package/dist/reflection/error-notebook.d.ts +125 -0
- package/dist/reflection/error-notebook.d.ts.map +1 -0
- package/dist/reflection/error-notebook.js +368 -0
- package/dist/reflection/error-notebook.js.map +1 -0
- package/dist/reflection/index.d.ts +8 -0
- package/dist/reflection/index.d.ts.map +1 -0
- package/dist/reflection/index.js +12 -0
- package/dist/reflection/index.js.map +1 -0
- package/dist/reflection/memory-reflector.d.ts +97 -0
- package/dist/reflection/memory-reflector.d.ts.map +1 -0
- package/dist/reflection/memory-reflector.js +215 -0
- package/dist/reflection/memory-reflector.js.map +1 -0
- package/dist/reflection/reflection-agent.d.ts +105 -0
- package/dist/reflection/reflection-agent.d.ts.map +1 -0
- package/dist/reflection/reflection-agent.js +234 -0
- package/dist/reflection/reflection-agent.js.map +1 -0
- package/dist/reflection/reflection-hook.d.ts +50 -0
- package/dist/reflection/reflection-hook.d.ts.map +1 -0
- package/dist/reflection/reflection-hook.js +108 -0
- package/dist/reflection/reflection-hook.js.map +1 -0
- package/dist/rules/project-rules.d.ts +47 -0
- package/dist/rules/project-rules.d.ts.map +1 -0
- package/dist/rules/project-rules.js +166 -0
- package/dist/rules/project-rules.js.map +1 -0
- package/dist/security/boundaries.d.ts +81 -0
- package/dist/security/boundaries.d.ts.map +1 -0
- package/dist/security/boundaries.js +158 -0
- package/dist/security/boundaries.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +11 -0
- package/dist/security/index.js.map +1 -0
- package/dist/session/session-types.d.ts +25 -4
- package/dist/session/session-types.d.ts.map +1 -1
- package/dist/skills/file-skill-loader.d.ts +4 -6
- package/dist/skills/file-skill-loader.d.ts.map +1 -1
- package/dist/skills/file-skill-loader.js +8 -19
- package/dist/skills/file-skill-loader.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -2
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/skill-manager.d.ts +18 -8
- package/dist/skills/skill-manager.d.ts.map +1 -1
- package/dist/skills/skill-manager.js +58 -36
- package/dist/skills/skill-manager.js.map +1 -1
- package/dist/skills/types.d.ts +3 -8
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/subagent/index.d.ts +4 -0
- package/dist/subagent/index.d.ts.map +1 -0
- package/dist/subagent/index.js +8 -0
- package/dist/subagent/index.js.map +1 -0
- package/dist/subagent/subagent-loader.d.ts +53 -0
- package/dist/subagent/subagent-loader.d.ts.map +1 -0
- package/dist/subagent/subagent-loader.js +155 -0
- package/dist/subagent/subagent-loader.js.map +1 -0
- package/dist/subagent/subagent-manager.d.ts +161 -0
- package/dist/subagent/subagent-manager.d.ts.map +1 -0
- package/dist/subagent/subagent-manager.js +468 -0
- package/dist/subagent/subagent-manager.js.map +1 -0
- package/dist/subagent/subagent-types.d.ts +77 -0
- package/dist/subagent/subagent-types.d.ts.map +1 -0
- package/dist/subagent/subagent-types.js +3 -0
- package/dist/subagent/subagent-types.js.map +1 -0
- package/dist/tools/builtin/bash.d.ts +3 -0
- package/dist/tools/builtin/bash.d.ts.map +1 -0
- package/dist/tools/builtin/bash.js +87 -0
- package/dist/tools/builtin/bash.js.map +1 -0
- package/dist/tools/builtin/edit-file.d.ts.map +1 -1
- package/dist/tools/builtin/edit-file.js +1 -0
- package/dist/tools/builtin/edit-file.js.map +1 -1
- package/dist/tools/builtin/index.d.ts +14 -0
- package/dist/tools/builtin/index.d.ts.map +1 -1
- package/dist/tools/builtin/index.js +45 -1
- package/dist/tools/builtin/index.js.map +1 -1
- package/dist/tools/builtin/list-errors.d.ts +7 -0
- package/dist/tools/builtin/list-errors.d.ts.map +1 -0
- package/dist/tools/builtin/list-errors.js +64 -0
- package/dist/tools/builtin/list-errors.js.map +1 -0
- package/dist/tools/builtin/list-subagents.d.ts +7 -0
- package/dist/tools/builtin/list-subagents.d.ts.map +1 -0
- package/dist/tools/builtin/list-subagents.js +21 -0
- package/dist/tools/builtin/list-subagents.js.map +1 -0
- package/dist/tools/builtin/recall.d.ts +11 -0
- package/dist/tools/builtin/recall.d.ts.map +1 -0
- package/dist/tools/builtin/recall.js +60 -0
- package/dist/tools/builtin/recall.js.map +1 -0
- package/dist/tools/builtin/remember.d.ts +12 -0
- package/dist/tools/builtin/remember.d.ts.map +1 -0
- package/dist/tools/builtin/remember.js +72 -0
- package/dist/tools/builtin/remember.js.map +1 -0
- package/dist/tools/builtin/skill.d.ts +14 -0
- package/dist/tools/builtin/skill.d.ts.map +1 -0
- package/dist/tools/builtin/skill.js +71 -0
- package/dist/tools/builtin/skill.js.map +1 -0
- package/dist/tools/builtin/spawn-subagent.d.ts +7 -0
- package/dist/tools/builtin/spawn-subagent.d.ts.map +1 -0
- package/dist/tools/builtin/spawn-subagent.js +43 -0
- package/dist/tools/builtin/spawn-subagent.js.map +1 -0
- package/dist/tools/builtin/web-fetch.d.ts +3 -0
- package/dist/tools/builtin/web-fetch.d.ts.map +1 -0
- package/dist/tools/builtin/web-fetch.js +101 -0
- package/dist/tools/builtin/web-fetch.js.map +1 -0
- package/dist/tools/builtin/write-file.d.ts.map +1 -1
- package/dist/tools/builtin/write-file.js +1 -0
- package/dist/tools/builtin/write-file.js.map +1 -1
- package/dist/tools/circuit-breaker.d.ts +19 -10
- package/dist/tools/circuit-breaker.d.ts.map +1 -1
- package/dist/tools/circuit-breaker.js +22 -11
- package/dist/tools/circuit-breaker.js.map +1 -1
- package/dist/tools/error-tracker.d.ts +28 -44
- package/dist/tools/error-tracker.d.ts.map +1 -1
- package/dist/tools/error-tracker.js +39 -156
- package/dist/tools/error-tracker.js.map +1 -1
- package/dist/tools/tool-filter.d.ts +70 -0
- package/dist/tools/tool-filter.d.ts.map +1 -0
- package/dist/tools/tool-filter.js +92 -0
- package/dist/tools/tool-filter.js.map +1 -0
- package/dist/tools/tool-output-truncator.d.ts +36 -0
- package/dist/tools/tool-output-truncator.d.ts.map +1 -0
- package/dist/tools/tool-output-truncator.js +117 -0
- package/dist/tools/tool-output-truncator.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +25 -9
- package/dist/tools/tool-registry.d.ts.map +1 -1
- package/dist/tools/tool-registry.js +77 -28
- package/dist/tools/tool-registry.js.map +1 -1
- package/dist/tools/tool-validator.d.ts +13 -0
- package/dist/tools/tool-validator.d.ts.map +1 -0
- package/dist/tools/tool-validator.js +116 -0
- package/dist/tools/tool-validator.js.map +1 -0
- package/dist/tools/types.d.ts +86 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +51 -2
- package/dist/tools/types.js.map +1 -1
- package/dist/trace/trace-logger.d.ts +30 -4
- package/dist/trace/trace-logger.d.ts.map +1 -1
- package/dist/trace/trace-logger.js +82 -6
- package/dist/trace/trace-logger.js.map +1 -1
- package/package.json +13 -4
- package/dist/compression/sliding-window.d.ts +0 -21
- package/dist/compression/sliding-window.d.ts.map +0 -1
- package/dist/compression/sliding-window.js +0 -44
- package/dist/compression/sliding-window.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
Parameters
|
|
7
|
+
|
|
8
|
+
Licensor: kagent-ts
|
|
9
|
+
|
|
10
|
+
Licensed Work: kagent-ts — A TypeScript agent framework.
|
|
11
|
+
The Licensed Work is (c) 2026 kagent-ts.
|
|
12
|
+
|
|
13
|
+
Change Date: 2030-06-26
|
|
14
|
+
|
|
15
|
+
Change License: MIT License
|
|
16
|
+
|
|
17
|
+
For information about the Change License and the Change Date, see the FAQ
|
|
18
|
+
below: https://mariadb.com/bsl11/faq/
|
|
19
|
+
|
|
20
|
+
-----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
Terms
|
|
23
|
+
|
|
24
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
25
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
26
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
27
|
+
production use.
|
|
28
|
+
|
|
29
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
30
|
+
available distribution of a specific version of the Licensed Work under this
|
|
31
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
32
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
33
|
+
above terminate.
|
|
34
|
+
|
|
35
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
36
|
+
currently in effect as described in this License, you must purchase a
|
|
37
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
38
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
39
|
+
|
|
40
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
41
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
42
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
43
|
+
for each version of the Licensed Work released by Licensor.
|
|
44
|
+
|
|
45
|
+
You must conspicuously display this License on each original or modified copy
|
|
46
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
47
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
48
|
+
License apply to your use of that work.
|
|
49
|
+
|
|
50
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
51
|
+
terminate your rights under this License for the current and all other
|
|
52
|
+
versions of the Licensed Work.
|
|
53
|
+
|
|
54
|
+
This License does not grant you any right in any trademark or logo of
|
|
55
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
56
|
+
Licensor as expressly required by this License).
|
|
57
|
+
|
|
58
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
59
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
60
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
61
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
62
|
+
TITLE.
|
|
63
|
+
|
|
64
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
65
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
66
|
+
as long as you comply with the Covenants of Licensor linked below.
|
|
67
|
+
|
|
68
|
+
Covenants of Licensor: https://mariadb.com/bsl11/covenants/
|
package/README.md
CHANGED
|
@@ -1,395 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# kagent-ts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
一个 TypeScript AI Agent 框架,提供 ReAct / Plan-Solve / Fusion / Orchestrator 多种 Agent 循环范式,内置工具管理(Circuit Breaker)、会话持久化、渐进式 Skill 系统、MCP 协议支持、RAG 知识检索(混合检索 + Re-rank)、Reflection 反思与 Eval 评估。
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- **Agent Loop Paradigms** — Base `Agent` + `ReActAgent` (Thought → Action → Observation → Final) + `PlanSolveAgent` (Plan → Resolve → Revise → Final)
|
|
8
|
-
- **LLM Integration** — OpenAI provider with automatic retry (exponential backoff + jitter) and network error classification
|
|
9
|
-
- **Tool System** — `ToolRegistry` with circuit breaker (automatic disable after threshold) and structured error tracking
|
|
10
|
-
- **Context Management** — Automatic token tracking, threshold-based compression with sliding window
|
|
11
|
-
- **Session Persistence** — Checkpoint-and-resume: auto-save on network error, graceful discard on abort (SIGINT)
|
|
12
|
-
- **User Preferences** — Plain-text Markdown file (`key: value`), injected into system prompt, auto-reloaded on file change
|
|
13
|
-
- **Skills** — Progressive disclosure: skills auto-detect from user input and load on demand
|
|
14
|
-
- **Built-in Tools** — Read file, write file, edit file, grep search, glob search
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
5
|
+
## 安装
|
|
17
6
|
|
|
18
7
|
```bash
|
|
19
8
|
npm install kagent-ts
|
|
20
9
|
```
|
|
21
10
|
|
|
22
|
-
##
|
|
11
|
+
## 快速开始
|
|
23
12
|
|
|
24
|
-
```
|
|
25
|
-
import { ReActAgent,
|
|
13
|
+
```ts
|
|
14
|
+
import { ReActAgent, createLLMProvider } from "kagent-ts"
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
const llm = new OpenAIProvider({
|
|
16
|
+
const llm = createLLMProvider({
|
|
29
17
|
apiKey: process.env.OPENAI_API_KEY!,
|
|
30
18
|
model: "gpt-4o",
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// 2. Define a tool
|
|
34
|
-
const calculator: Tool = {
|
|
35
|
-
name: "calculator",
|
|
36
|
-
description: "Perform a mathematical calculation",
|
|
37
|
-
parameters: {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {
|
|
40
|
-
expression: {
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "The mathematical expression to evaluate",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
required: ["expression"],
|
|
46
|
-
},
|
|
47
|
-
async execute(args) {
|
|
48
|
-
const { expression } = args as { expression: string };
|
|
49
|
-
return String(eval(expression));
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// 3. Create the agent
|
|
54
|
-
const agent = new ReActAgent({ llm, tools: [calculator] });
|
|
55
|
-
|
|
56
|
-
// 4. Run
|
|
57
|
-
const response = await agent.run("What is 25 * 4 + 10?");
|
|
58
|
-
console.log(response);
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Architecture
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
src/
|
|
65
|
-
├── core/ # Agent classes: Agent, ReActAgent, PlanSolveAgent
|
|
66
|
-
├── llm/ # LLM provider interface + OpenAI implementation
|
|
67
|
-
├── messages/ # Message types and builder class
|
|
68
|
-
├── context/ # Context window management (token tracking)
|
|
69
|
-
├── compression/ # Compression strategies (sliding window)
|
|
70
|
-
├── session/ # Session checkpoint persistence & resume
|
|
71
|
-
├── preferences/ # User preferences (Markdown file, auto-reload)
|
|
72
|
-
├── skills/ # Progressive disclosure skill system
|
|
73
|
-
├── tools/ # Tool registry, circuit breaker, error tracker
|
|
74
|
-
│ └── builtin/ # Built-in file tools (read, write, edit, grep, glob)
|
|
75
|
-
├── utils/ # Token counting utilities
|
|
76
|
-
└── index.ts # Public API exports
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Agent Paradigms
|
|
80
|
-
|
|
81
|
-
### ReActAgent
|
|
82
|
-
|
|
83
|
-
The classic Thought → Action → Observation loop with tool-call support:
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import { ReActAgent } from "kagent-ts";
|
|
19
|
+
})
|
|
87
20
|
|
|
88
21
|
const agent = new ReActAgent({
|
|
89
22
|
llm,
|
|
90
|
-
tools: [
|
|
91
|
-
systemPrompt: "You are a helpful assistant.",
|
|
23
|
+
tools: [],
|
|
92
24
|
maxIterations: 10,
|
|
93
|
-
})
|
|
94
|
-
const response = await agent.run("Search for the latest news.");
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### PlanSolveAgent
|
|
98
|
-
|
|
99
|
-
Plan → Resolve → Revise loop for complex multi-step tasks:
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
import { PlanSolveAgent } from "kagent-ts";
|
|
103
|
-
|
|
104
|
-
const agent = new PlanSolveAgent({
|
|
105
|
-
llm,
|
|
106
|
-
tools: [searchTool, calculatorTool],
|
|
107
|
-
maxIterations: 15,
|
|
108
|
-
maxPlanSteps: 12,
|
|
109
|
-
replanThreshold: 2, // auto-suggest replan after 2 consecutive failures
|
|
110
|
-
});
|
|
111
|
-
const response = await agent.run("Analyze Q3 financial data and generate a report.");
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
The agent will:
|
|
115
|
-
1. Create a detailed plan
|
|
116
|
-
2. Execute each step with tools
|
|
117
|
-
3. Revise the plan mid-execution if obstacles occur
|
|
118
|
-
4. Deliver the final answer
|
|
119
|
-
|
|
120
|
-
## LLM & Network Resilience
|
|
121
|
-
|
|
122
|
-
The OpenAI provider includes built-in retry logic:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
const llm = new OpenAIProvider({
|
|
126
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
127
|
-
model: "gpt-4o",
|
|
128
|
-
retry: {
|
|
129
|
-
maxRetries: 3,
|
|
130
|
-
baseDelayMs: 1000,
|
|
131
|
-
maxDelayMs: 30000,
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
- **Retryable errors**: timeout, connection refused/reset, DNS failure, HTTP 429 (rate limit), HTTP 5xx (server error)
|
|
137
|
-
- **Permanent errors**: HTTP 401 (auth), HTTP 400 (bad request), abort signal — propagate immediately
|
|
138
|
-
- On retry exhaustion → throws `LLMNetworkError` with `cause` field for agent-level handling
|
|
139
|
-
|
|
140
|
-
## Tool System
|
|
141
|
-
|
|
142
|
-
### ToolRegistry + Circuit Breaker
|
|
143
|
-
|
|
144
|
-
Tools can be registered with automatic failure detection and circuit breaking:
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
import { ToolRegistry } from "kagent-ts";
|
|
148
|
-
|
|
149
|
-
const registry = new ToolRegistry({
|
|
150
|
-
breakerConfig: {
|
|
151
|
-
failureThreshold: 5, // disable after 5 consecutive failures
|
|
152
|
-
cooldownMs: 60000, // re-enable after 60s
|
|
153
|
-
halfOpenMaxRetries: 2,
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
registry.register(calculatorTool);
|
|
158
|
-
const result = await registry.execute("calculator", { expression: "2+2" });
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
States: `CLOSED` (normal) → `OPEN` (disabled) → `HALF_OPEN` (probing) → `CLOSED` (recovered).
|
|
162
|
-
|
|
163
|
-
### Error Tracking
|
|
164
|
-
|
|
165
|
-
Track full tool failure chains with LLM analysis:
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
const report = agent.generateErrorReport();
|
|
169
|
-
// Generates a structured markdown report of all tool failures,
|
|
170
|
-
// including LLM analysis of root cause and recovery steps.
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Built-in Tools
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
import { registerAllBuiltinTools, ReadFileTool, WriteFileTool } from "kagent-ts";
|
|
177
|
-
|
|
178
|
-
// Register individually
|
|
179
|
-
const agent = new ReActAgent({
|
|
180
|
-
llm,
|
|
181
|
-
tools: [...registerAllBuiltinTools()],
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// Or add at runtime
|
|
185
|
-
agent.addTool(new ReadFileTool());
|
|
186
|
-
agent.addTool(new WriteFileTool());
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Available: `ReadFileTool`, `WriteFileTool`, `EditFileTool`, `GrepSearchTool`, `GlobSearchTool`.
|
|
190
|
-
|
|
191
|
-
## Session Persistence & Network Recovery
|
|
192
|
-
|
|
193
|
-
The agent can checkpoint its state mid-run and resume after disconnection:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
const agent = new ReActAgent({
|
|
197
|
-
llm,
|
|
198
|
-
tools: [myTool],
|
|
199
|
-
sessionId: "my-session",
|
|
200
|
-
enableCheckpointing: true,
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Normal execution — auto-saves after each LLM+tools cycle.
|
|
204
|
-
// On network error: saves "interrupted" checkpoint, returns resume instructions.
|
|
205
|
-
const result = await agent.run("Do something...");
|
|
206
|
-
|
|
207
|
-
// After network is restored:
|
|
208
|
-
const resumed = await agent.resume("my-session", "continue");
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
When the user aborts (SIGINT / `agent.cancel()`), the checkpoint is discarded — no stale state persists.
|
|
212
|
-
|
|
213
|
-
## User Preferences
|
|
214
|
-
|
|
215
|
-
Preferences are stored as a Markdown file (`.kagent/preferences.md` by default) and injected into the system prompt as a `=== User Preferences ===` section. File changes are auto-detected each loop iteration.
|
|
216
|
-
|
|
217
|
-
```markdown
|
|
218
|
-
# User Preferences
|
|
219
|
-
|
|
220
|
-
codeStyle: Use TypeScript with functional style. Prefer interfaces.
|
|
221
|
-
language: Always respond in Chinese.
|
|
222
|
-
forbidden: Never use `any` type. Avoid mutating function parameters.
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
// Via constructor
|
|
227
|
-
const agent = new ReActAgent({
|
|
228
|
-
llm,
|
|
229
|
-
tools: [myTool],
|
|
230
|
-
preferences: {
|
|
231
|
-
codeStyle: "Use TypeScript with functional style.",
|
|
232
|
-
language: "Always respond in Chinese.",
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// With file persistence
|
|
237
|
-
import { PreferenceManager } from "kagent-ts";
|
|
238
|
-
|
|
239
|
-
const agent = new ReActAgent({
|
|
240
|
-
llm,
|
|
241
|
-
tools: [myTool],
|
|
242
|
-
preferenceManager: new PreferenceManager(),
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// Runtime CRUD (auto-persists if PreferenceManager configured)
|
|
246
|
-
agent.setPreference("codeStyle", "Use TypeScript with functional style.");
|
|
247
|
-
agent.getPreference("language"); // "Always respond in Chinese."
|
|
248
|
-
agent.removePreference("forbidden");
|
|
249
|
-
agent.clearPreferences();
|
|
250
|
-
|
|
251
|
-
// The LLM sees this in every system prompt:
|
|
252
|
-
// === User Preferences ===
|
|
253
|
-
// - codeStyle: Use TypeScript with functional style.
|
|
254
|
-
// - language: Always respond in Chinese.
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### File Format
|
|
258
|
-
|
|
259
|
-
`preferences.md` uses simple `key: value` lines. Lines starting with `#` are comments:
|
|
260
|
-
|
|
261
|
-
```markdown
|
|
262
|
-
# User Preferences
|
|
263
|
-
|
|
264
|
-
codeStyle: Use TypeScript with functional style.
|
|
265
|
-
replyLanguage: Always respond in Chinese.
|
|
266
|
-
# This is a comment — ignored when loaded.
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
Manually edit the file while the agent is running — changes are auto-detected before the next LLM call.
|
|
270
|
-
|
|
271
|
-
## Skills (Progressive Disclosure)
|
|
272
|
-
|
|
273
|
-
Skills provide domain-specific knowledge and tools that load on demand. Skills are defined as file-based directories, making them easy to author and share.
|
|
274
|
-
|
|
275
|
-
### Directory Structure
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
skills/
|
|
279
|
-
├── sql/
|
|
280
|
-
│ ├── SKILL.md # Frontmatter (metadata) + system prompt body
|
|
281
|
-
│ ├── reference/ # Reference docs loaded on activation
|
|
282
|
-
│ │ └── cheatsheet.md
|
|
283
|
-
│ └── scripts/ # Executable scripts registered as tools
|
|
284
|
-
│ └── format_sql.sh
|
|
285
|
-
├── git/
|
|
286
|
-
│ ├── SKILL.md
|
|
287
|
-
│ └── scripts/
|
|
288
|
-
│ └── list_branches.sh
|
|
289
|
-
└── ...
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### SKILL.md Format
|
|
293
|
-
|
|
294
|
-
```markdown
|
|
295
|
-
---
|
|
296
|
-
name: sql
|
|
297
|
-
description: SQL query writing and optimization
|
|
298
|
-
keywords: sql, query, database, select, join
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
You are an expert in SQL. Write efficient queries, use appropriate indexes, and consider EXPLAIN plans.
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Usage
|
|
305
|
-
|
|
306
|
-
Point the agent to your `skills/` directory — skills are auto-discovered and lazily loaded:
|
|
307
|
-
|
|
308
|
-
```typescript
|
|
309
|
-
import { ReActAgent, OpenAIProvider } from "kagent-ts";
|
|
310
|
-
|
|
311
|
-
const agent = new ReActAgent({
|
|
312
|
-
llm: provider,
|
|
313
|
-
tools: myTools,
|
|
314
|
-
skillsDir: "./skills", // Auto-discover file-based skills
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
// Manual activation
|
|
318
|
-
agent.activateSkill("sql");
|
|
319
|
-
|
|
320
|
-
// Or rely on auto-detection: when user input contains matching
|
|
321
|
-
// keywords (e.g., "write a SQL query"), the skill activates automatically.
|
|
322
|
-
const response = await agent.run("Write a query to find top 10 customers by revenue.");
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### Skill Components
|
|
25
|
+
})
|
|
326
26
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
| **Metadata** | SKILL.md frontmatter (`---`) | Registered on scan — name, description, keywords |
|
|
330
|
-
| **System Prompt** | SKILL.md body | Loaded on activation — injected into the agent's system prompt |
|
|
331
|
-
| **Reference Docs** | `reference/*.md`, `*.txt` | Appended to system prompt on activation, with `[Reference: filename]` headers |
|
|
332
|
-
| **Scripts** | `scripts/*.sh`, `.py`, `.js`, `.bat` | Registered as executable `Tool` objects on activation, named `{skillName}_{scriptName}` |
|
|
333
|
-
|
|
334
|
-
### Supported Script Types
|
|
335
|
-
|
|
336
|
-
| Extension | Interpreter | Platform |
|
|
337
|
-
|-----------|-------------|----------|
|
|
338
|
-
| `.sh` | `bash` | Linux/macOS/WSL |
|
|
339
|
-
| `.bat` / `.cmd` | `cmd.exe /c` | Windows |
|
|
340
|
-
| `.ps1` | `powershell.exe -File` | Windows |
|
|
341
|
-
| `.js` | `node` | Cross-platform |
|
|
342
|
-
| `.py` | `python3` / `python` | Cross-platform |
|
|
343
|
-
|
|
344
|
-
Each script becomes a Tool that accepts a single `args: string` parameter, passed as CLI arguments to the script.
|
|
345
|
-
|
|
346
|
-
## Context Management
|
|
347
|
-
|
|
348
|
-
Automatic token tracking with configurable thresholds:
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
|
-
import { ContextManager } from "kagent-ts";
|
|
352
|
-
|
|
353
|
-
const ctx = new ContextManager({
|
|
354
|
-
maxTokens: 128000,
|
|
355
|
-
compressionThresholdRatio: 0.75, // compress at 75% capacity
|
|
356
|
-
compressionRatio: 0.5, // remove 50% of messages on compress
|
|
357
|
-
});
|
|
27
|
+
const answer = await agent.run("请介绍一下 TypeScript 的特点。")
|
|
28
|
+
console.log(answer)
|
|
358
29
|
```
|
|
359
30
|
|
|
360
|
-
##
|
|
31
|
+
## 核心特性
|
|
361
32
|
|
|
362
|
-
|
|
33
|
+
- 🧠 **4 种 Agent 范式** — ReAct → Plan-Solve → Fusion → Orchestrator,从简单问答到大规模多代理编排
|
|
34
|
+
- 🔧 **工具系统** — Circuit Breaker 熔断、JSON Schema 参数校验、HITL 审批、错误追踪链
|
|
35
|
+
- 🔌 **多 LLM 后端** — OpenAI / Anthropic,Fallback 降级、Rate Limiter 限流、Model Router 路由
|
|
36
|
+
- 💾 **会话持久化** — 自动 Checkpoint,支持网络中断恢复和取消续跑
|
|
37
|
+
- 📦 **渐进式 Skill** — 基于 SKILL.md 文件,按需激活,Token 友好
|
|
38
|
+
- 🌐 **MCP 协议** — 动态发现外部工具,支持 stdio / SSE 传输
|
|
39
|
+
- 📚 **RAG 知识库** — 混合检索(BM25 + 向量 + RRF 融合)、Chroma/Milvus 等向量数据库、Re-rank 精排
|
|
40
|
+
- 🔍 **反思与评估** — Reflection + ErrorNotebook + EvalRunner + Benchmark
|
|
41
|
+
- 🛡️ **安全防护** — 多层 Prompt Injection 防御
|
|
363
42
|
|
|
364
|
-
|
|
365
|
-
import { SlidingWindowCompression } from "kagent-ts";
|
|
43
|
+
## 文档
|
|
366
44
|
|
|
367
|
-
|
|
368
|
-
keepLastN: 20,
|
|
369
|
-
keepSystemMessages: true,
|
|
370
|
-
});
|
|
45
|
+
完整文档请访问:**[https://kkhhhh-ll.github.io/kagent-ts](https://kkhhhh-ll.github.io/kagent-ts)**
|
|
371
46
|
|
|
372
|
-
|
|
373
|
-
// result.messages — compressed list
|
|
374
|
-
// result.removedCount — how many were removed
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## Message API
|
|
378
|
-
|
|
379
|
-
```typescript
|
|
380
|
-
import { Message } from "kagent-ts";
|
|
381
|
-
|
|
382
|
-
Message.user("Hello");
|
|
383
|
-
Message.system("You are a helpful assistant.");
|
|
384
|
-
Message.assistant("Hi there!");
|
|
385
|
-
Message.tool("Result", "call_123", "calculator");
|
|
47
|
+
本地运行文档:
|
|
386
48
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
Message.fromJSON(json); // Deserialize
|
|
390
|
-
Message.fromJSONBulk(array); // Deserialize array
|
|
49
|
+
```bash
|
|
50
|
+
npm run docs:dev
|
|
391
51
|
```
|
|
392
|
-
|
|
393
|
-
## License
|
|
394
|
-
|
|
395
|
-
MIT
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MessageData } from "../messages/types";
|
|
2
|
+
import { LLMProvider } from "../llm/interface";
|
|
3
|
+
import { Logger } from "../logging/logger";
|
|
4
|
+
interface CompressionConfig {
|
|
5
|
+
maxTokens: number;
|
|
6
|
+
compressionThreshold: number;
|
|
7
|
+
keepTurns: number;
|
|
8
|
+
toolResultMaxAgeMs: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Progressive 4-step compression.
|
|
12
|
+
*
|
|
13
|
+
* Each step is applied in order. After each step the token count is
|
|
14
|
+
* re-checked; if the context now fits comfortably, later steps are skipped.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ProgressiveCompressor {
|
|
17
|
+
private config;
|
|
18
|
+
private logger;
|
|
19
|
+
constructor(config: CompressionConfig, logger?: Logger);
|
|
20
|
+
/**
|
|
21
|
+
* Run progressive compression.
|
|
22
|
+
*
|
|
23
|
+
* @param messages The full message list (without system message).
|
|
24
|
+
* @param systemMessage The system message (preserved).
|
|
25
|
+
* @param llm Optional LLM provider for Step 4 summarization.
|
|
26
|
+
* If omitted, Step 4 is skipped.
|
|
27
|
+
* @returns Compressed message list + removal count.
|
|
28
|
+
*/
|
|
29
|
+
compress(messages: MessageData[], systemMessage: MessageData | null, llm?: LLMProvider, model?: string): Promise<{
|
|
30
|
+
messages: MessageData[];
|
|
31
|
+
removedCount: number;
|
|
32
|
+
applied: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
private finalize;
|
|
35
|
+
private tokenCount;
|
|
36
|
+
/**
|
|
37
|
+
* If total tool-result bytes exceed 200 KB, truncate the largest
|
|
38
|
+
* results (keep 2 KB + save to disk). Returns a new array if modified.
|
|
39
|
+
*/
|
|
40
|
+
private step1TruncateToolResults;
|
|
41
|
+
/**
|
|
42
|
+
* Remove messages older than `keepTurns` conversation turns.
|
|
43
|
+
* A "turn" is a user message + all subsequent assistant/tool messages
|
|
44
|
+
* until the next user message.
|
|
45
|
+
*/
|
|
46
|
+
private step2DropOldTurns;
|
|
47
|
+
/**
|
|
48
|
+
* Remove tool results older than `toolResultMaxAgeMs` for read-type
|
|
49
|
+
* tools (results that can be reproduced by re-running the tool).
|
|
50
|
+
* Sub-agent results (`<subagent-result>`) are preserved.
|
|
51
|
+
*/
|
|
52
|
+
private step3DropStaleToolResults;
|
|
53
|
+
/**
|
|
54
|
+
* Generate a structured summary of ALL messages via the LLM.
|
|
55
|
+
*
|
|
56
|
+
* The entire conversation (from the first user message onward) is
|
|
57
|
+
* compressed into a single summary. No recent turns are kept verbatim —
|
|
58
|
+
* the summary is the sole source of history after compression.
|
|
59
|
+
*
|
|
60
|
+
* A continuity hint is appended so the LLM knows it is resuming, not
|
|
61
|
+
* starting from scratch.
|
|
62
|
+
*/
|
|
63
|
+
private step4LlmSummarize;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=progressive-compressor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressive-compressor.d.ts","sourceRoot":"","sources":["../../src/compression/progressive-compressor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAQ,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAiB,MAAM,mBAAmB,CAAC;AAe1D,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAID;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,MAAM;IAKtD;;;;;;;;OAQG;IACG,QAAQ,CACZ,QAAQ,EAAE,WAAW,EAAE,EACvB,aAAa,EAAE,WAAW,GAAG,IAAI,EACjC,GAAG,CAAC,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAkD/E,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,UAAU;IAWlB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAsDhC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IA8BjC;;;;;;;;;OASG;YACW,iBAAiB;CA6ChC"}
|