@animus-labs/cortex 0.2.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 +73 -0
- package/dist/budget-guard.d.ts +75 -0
- package/dist/budget-guard.d.ts.map +1 -0
- package/dist/budget-guard.js +142 -0
- package/dist/budget-guard.js.map +1 -0
- package/dist/compaction/compaction.d.ts +99 -0
- package/dist/compaction/compaction.d.ts.map +1 -0
- package/dist/compaction/compaction.js +302 -0
- package/dist/compaction/compaction.js.map +1 -0
- package/dist/compaction/failsafe.d.ts +57 -0
- package/dist/compaction/failsafe.d.ts.map +1 -0
- package/dist/compaction/failsafe.js +135 -0
- package/dist/compaction/failsafe.js.map +1 -0
- package/dist/compaction/index.d.ts +381 -0
- package/dist/compaction/index.d.ts.map +1 -0
- package/dist/compaction/index.js +979 -0
- package/dist/compaction/index.js.map +1 -0
- package/dist/compaction/microcompaction.d.ts +219 -0
- package/dist/compaction/microcompaction.d.ts.map +1 -0
- package/dist/compaction/microcompaction.js +536 -0
- package/dist/compaction/microcompaction.js.map +1 -0
- package/dist/compaction/observational/buffering.d.ts +225 -0
- package/dist/compaction/observational/buffering.d.ts.map +1 -0
- package/dist/compaction/observational/buffering.js +354 -0
- package/dist/compaction/observational/buffering.js.map +1 -0
- package/dist/compaction/observational/constants.d.ts +70 -0
- package/dist/compaction/observational/constants.d.ts.map +1 -0
- package/dist/compaction/observational/constants.js +507 -0
- package/dist/compaction/observational/constants.js.map +1 -0
- package/dist/compaction/observational/index.d.ts +219 -0
- package/dist/compaction/observational/index.d.ts.map +1 -0
- package/dist/compaction/observational/index.js +641 -0
- package/dist/compaction/observational/index.js.map +1 -0
- package/dist/compaction/observational/observer.d.ts +97 -0
- package/dist/compaction/observational/observer.d.ts.map +1 -0
- package/dist/compaction/observational/observer.js +424 -0
- package/dist/compaction/observational/observer.js.map +1 -0
- package/dist/compaction/observational/recall-tool.d.ts +27 -0
- package/dist/compaction/observational/recall-tool.d.ts.map +1 -0
- package/dist/compaction/observational/recall-tool.js +93 -0
- package/dist/compaction/observational/recall-tool.js.map +1 -0
- package/dist/compaction/observational/reflector.d.ts +94 -0
- package/dist/compaction/observational/reflector.d.ts.map +1 -0
- package/dist/compaction/observational/reflector.js +167 -0
- package/dist/compaction/observational/reflector.js.map +1 -0
- package/dist/compaction/observational/types.d.ts +271 -0
- package/dist/compaction/observational/types.d.ts.map +1 -0
- package/dist/compaction/observational/types.js +15 -0
- package/dist/compaction/observational/types.js.map +1 -0
- package/dist/context-manager.d.ts +134 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +170 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/cortex-agent.d.ts +1020 -0
- package/dist/cortex-agent.d.ts.map +1 -0
- package/dist/cortex-agent.js +3589 -0
- package/dist/cortex-agent.js.map +1 -0
- package/dist/error-classifier.d.ts +48 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +152 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/event-bridge.d.ts +166 -0
- package/dist/event-bridge.d.ts.map +1 -0
- package/dist/event-bridge.js +381 -0
- package/dist/event-bridge.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-client.d.ts +119 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +474 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/model-wrapper.d.ts +58 -0
- package/dist/model-wrapper.d.ts.map +1 -0
- package/dist/model-wrapper.js +86 -0
- package/dist/model-wrapper.js.map +1 -0
- package/dist/noop-logger.d.ts +4 -0
- package/dist/noop-logger.d.ts.map +1 -0
- package/dist/noop-logger.js +8 -0
- package/dist/noop-logger.js.map +1 -0
- package/dist/prompt-diagnostics.d.ts +47 -0
- package/dist/prompt-diagnostics.d.ts.map +1 -0
- package/dist/prompt-diagnostics.js +230 -0
- package/dist/prompt-diagnostics.js.map +1 -0
- package/dist/provider-manager.d.ts +224 -0
- package/dist/provider-manager.d.ts.map +1 -0
- package/dist/provider-manager.js +563 -0
- package/dist/provider-manager.js.map +1 -0
- package/dist/provider-registry.d.ts +115 -0
- package/dist/provider-registry.d.ts.map +1 -0
- package/dist/provider-registry.js +305 -0
- package/dist/provider-registry.js.map +1 -0
- package/dist/schema-converter.d.ts +20 -0
- package/dist/schema-converter.d.ts.map +1 -0
- package/dist/schema-converter.js +48 -0
- package/dist/schema-converter.js.map +1 -0
- package/dist/skill-preprocessor.d.ts +46 -0
- package/dist/skill-preprocessor.d.ts.map +1 -0
- package/dist/skill-preprocessor.js +237 -0
- package/dist/skill-preprocessor.js.map +1 -0
- package/dist/skill-registry.d.ts +107 -0
- package/dist/skill-registry.d.ts.map +1 -0
- package/dist/skill-registry.js +330 -0
- package/dist/skill-registry.js.map +1 -0
- package/dist/skill-tool.d.ts +54 -0
- package/dist/skill-tool.d.ts.map +1 -0
- package/dist/skill-tool.js +88 -0
- package/dist/skill-tool.js.map +1 -0
- package/dist/sub-agent-manager.d.ts +90 -0
- package/dist/sub-agent-manager.d.ts.map +1 -0
- package/dist/sub-agent-manager.js +192 -0
- package/dist/sub-agent-manager.js.map +1 -0
- package/dist/token-estimator.d.ts +23 -0
- package/dist/token-estimator.d.ts.map +1 -0
- package/dist/token-estimator.js +27 -0
- package/dist/token-estimator.js.map +1 -0
- package/dist/tool-contract.d.ts +68 -0
- package/dist/tool-contract.d.ts.map +1 -0
- package/dist/tool-contract.js +35 -0
- package/dist/tool-contract.js.map +1 -0
- package/dist/tool-result-persistence.d.ts +89 -0
- package/dist/tool-result-persistence.d.ts.map +1 -0
- package/dist/tool-result-persistence.js +152 -0
- package/dist/tool-result-persistence.js.map +1 -0
- package/dist/tools/bash/index.d.ts +71 -0
- package/dist/tools/bash/index.d.ts.map +1 -0
- package/dist/tools/bash/index.js +485 -0
- package/dist/tools/bash/index.js.map +1 -0
- package/dist/tools/bash/interactive.d.ts +47 -0
- package/dist/tools/bash/interactive.d.ts.map +1 -0
- package/dist/tools/bash/interactive.js +262 -0
- package/dist/tools/bash/interactive.js.map +1 -0
- package/dist/tools/bash/safety.d.ts +149 -0
- package/dist/tools/bash/safety.d.ts.map +1 -0
- package/dist/tools/bash/safety.js +1116 -0
- package/dist/tools/bash/safety.js.map +1 -0
- package/dist/tools/edit.d.ts +57 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +310 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +34 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +268 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +53 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +673 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/index.d.ts +62 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/read.d.ts +43 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +459 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/runtime.d.ts +62 -0
- package/dist/tools/runtime.d.ts.map +1 -0
- package/dist/tools/runtime.js +116 -0
- package/dist/tools/runtime.js.map +1 -0
- package/dist/tools/shared/cwd-tracker.d.ts +32 -0
- package/dist/tools/shared/cwd-tracker.d.ts.map +1 -0
- package/dist/tools/shared/cwd-tracker.js +44 -0
- package/dist/tools/shared/cwd-tracker.js.map +1 -0
- package/dist/tools/shared/edit-history.d.ts +55 -0
- package/dist/tools/shared/edit-history.d.ts.map +1 -0
- package/dist/tools/shared/edit-history.js +72 -0
- package/dist/tools/shared/edit-history.js.map +1 -0
- package/dist/tools/shared/edit-matcher.d.ts +83 -0
- package/dist/tools/shared/edit-matcher.d.ts.map +1 -0
- package/dist/tools/shared/edit-matcher.js +359 -0
- package/dist/tools/shared/edit-matcher.js.map +1 -0
- package/dist/tools/shared/file-mutation-lock.d.ts +22 -0
- package/dist/tools/shared/file-mutation-lock.d.ts.map +1 -0
- package/dist/tools/shared/file-mutation-lock.js +35 -0
- package/dist/tools/shared/file-mutation-lock.js.map +1 -0
- package/dist/tools/shared/gitignore.d.ts +17 -0
- package/dist/tools/shared/gitignore.d.ts.map +1 -0
- package/dist/tools/shared/gitignore.js +59 -0
- package/dist/tools/shared/gitignore.js.map +1 -0
- package/dist/tools/shared/pdf-extractor.d.ts +96 -0
- package/dist/tools/shared/pdf-extractor.d.ts.map +1 -0
- package/dist/tools/shared/pdf-extractor.js +196 -0
- package/dist/tools/shared/pdf-extractor.js.map +1 -0
- package/dist/tools/shared/read-registry.d.ts +66 -0
- package/dist/tools/shared/read-registry.d.ts.map +1 -0
- package/dist/tools/shared/read-registry.js +65 -0
- package/dist/tools/shared/read-registry.js.map +1 -0
- package/dist/tools/shared/safe-env.d.ts +18 -0
- package/dist/tools/shared/safe-env.d.ts.map +1 -0
- package/dist/tools/shared/safe-env.js +70 -0
- package/dist/tools/shared/safe-env.js.map +1 -0
- package/dist/tools/sub-agent.d.ts +91 -0
- package/dist/tools/sub-agent.d.ts.map +1 -0
- package/dist/tools/sub-agent.js +89 -0
- package/dist/tools/sub-agent.js.map +1 -0
- package/dist/tools/task-output.d.ts +38 -0
- package/dist/tools/task-output.d.ts.map +1 -0
- package/dist/tools/task-output.js +186 -0
- package/dist/tools/task-output.js.map +1 -0
- package/dist/tools/tool-search/index.d.ts +40 -0
- package/dist/tools/tool-search/index.d.ts.map +1 -0
- package/dist/tools/tool-search/index.js +110 -0
- package/dist/tools/tool-search/index.js.map +1 -0
- package/dist/tools/tool-search/registry.d.ts +82 -0
- package/dist/tools/tool-search/registry.d.ts.map +1 -0
- package/dist/tools/tool-search/registry.js +238 -0
- package/dist/tools/tool-search/registry.js.map +1 -0
- package/dist/tools/undo-edit.d.ts +51 -0
- package/dist/tools/undo-edit.d.ts.map +1 -0
- package/dist/tools/undo-edit.js +231 -0
- package/dist/tools/undo-edit.js.map +1 -0
- package/dist/tools/web-fetch/cache.d.ts +49 -0
- package/dist/tools/web-fetch/cache.d.ts.map +1 -0
- package/dist/tools/web-fetch/cache.js +89 -0
- package/dist/tools/web-fetch/cache.js.map +1 -0
- package/dist/tools/web-fetch/index.d.ts +53 -0
- package/dist/tools/web-fetch/index.d.ts.map +1 -0
- package/dist/tools/web-fetch/index.js +513 -0
- package/dist/tools/web-fetch/index.js.map +1 -0
- package/dist/tools/write.d.ts +59 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +316 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types.d.ts +881 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/working-tags.d.ts +44 -0
- package/dist/working-tags.d.ts.map +1 -0
- package/dist/working-tags.js +103 -0
- package/dist/working-tags.js.map +1 -0
- package/package.json +87 -0
- package/src/budget-guard.ts +170 -0
- package/src/compaction/compaction.ts +386 -0
- package/src/compaction/failsafe.ts +185 -0
- package/src/compaction/index.ts +1199 -0
- package/src/compaction/microcompaction.ts +709 -0
- package/src/compaction/observational/buffering.ts +430 -0
- package/src/compaction/observational/constants.ts +532 -0
- package/src/compaction/observational/index.ts +837 -0
- package/src/compaction/observational/observer.ts +510 -0
- package/src/compaction/observational/recall-tool.ts +130 -0
- package/src/compaction/observational/reflector.ts +221 -0
- package/src/compaction/observational/types.ts +343 -0
- package/src/context-manager.ts +237 -0
- package/src/cortex-agent.ts +4297 -0
- package/src/error-classifier.ts +199 -0
- package/src/event-bridge.ts +508 -0
- package/src/index.ts +292 -0
- package/src/mcp-client.ts +582 -0
- package/src/model-wrapper.ts +128 -0
- package/src/noop-logger.ts +9 -0
- package/src/prompt-diagnostics.ts +296 -0
- package/src/provider-manager.ts +823 -0
- package/src/provider-registry.ts +386 -0
- package/src/schema-converter.ts +51 -0
- package/src/skill-preprocessor.ts +314 -0
- package/src/skill-registry.ts +378 -0
- package/src/skill-tool.ts +130 -0
- package/src/sub-agent-manager.ts +236 -0
- package/src/token-estimator.ts +26 -0
- package/src/tool-contract.ts +113 -0
- package/src/tool-result-persistence.ts +197 -0
- package/src/tools/bash/index.ts +633 -0
- package/src/tools/bash/interactive.ts +302 -0
- package/src/tools/bash/safety.ts +1297 -0
- package/src/tools/edit.ts +422 -0
- package/src/tools/glob.ts +330 -0
- package/src/tools/grep.ts +819 -0
- package/src/tools/index.ts +110 -0
- package/src/tools/read.ts +580 -0
- package/src/tools/runtime.ts +173 -0
- package/src/tools/shared/cwd-tracker.ts +50 -0
- package/src/tools/shared/edit-history.ts +96 -0
- package/src/tools/shared/edit-matcher.ts +457 -0
- package/src/tools/shared/file-mutation-lock.ts +40 -0
- package/src/tools/shared/gitignore.ts +61 -0
- package/src/tools/shared/pdf-extractor.ts +290 -0
- package/src/tools/shared/read-registry.ts +93 -0
- package/src/tools/shared/safe-env.ts +82 -0
- package/src/tools/sub-agent.ts +171 -0
- package/src/tools/task-output.ts +236 -0
- package/src/tools/tool-search/index.ts +167 -0
- package/src/tools/tool-search/registry.ts +278 -0
- package/src/tools/undo-edit.ts +314 -0
- package/src/tools/web-fetch/cache.ts +112 -0
- package/src/tools/web-fetch/index.ts +604 -0
- package/src/tools/write.ts +385 -0
- package/src/types.ts +1057 -0
- package/src/working-tags.ts +118 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAA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A0D;IAC1D,UAAU,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACpC,mDAAmD;IACnD,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAG1C,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sDAAsD;IACtD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,yEAAyE;IACzE,iBAAiB,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC/D"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the @animus-labs/cortex package.
|
|
3
|
+
*
|
|
4
|
+
* These types define the public API surface for CortexAgent configuration,
|
|
5
|
+
* context management, error classification, working tags, budget guards,
|
|
6
|
+
* compaction, events, and model tiers.
|
|
7
|
+
*
|
|
8
|
+
* References:
|
|
9
|
+
* - cortex-architecture.md
|
|
10
|
+
* - context-manager.md
|
|
11
|
+
* - model-tiers.md
|
|
12
|
+
* - error-recovery.md
|
|
13
|
+
* - working-tags.md
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working tags parser.
|
|
3
|
+
*
|
|
4
|
+
* Separates agent text into user-facing and working (internal reasoning)
|
|
5
|
+
* content based on <working> XML tag delimiters.
|
|
6
|
+
*
|
|
7
|
+
* Parsing rules:
|
|
8
|
+
* - Tags are flat delimiters: <working> opens, </working> closes. No nesting.
|
|
9
|
+
* - Multiple <working> blocks are concatenated (newline-separated) in `working`.
|
|
10
|
+
* - Whitespace between closing </working> tag and subsequent text is normalized.
|
|
11
|
+
* - Unclosed <working> tag: all content after the opening tag is treated as working.
|
|
12
|
+
* - Simple regex, not a full XML parser.
|
|
13
|
+
*
|
|
14
|
+
* Reference: working-tags.md
|
|
15
|
+
*/
|
|
16
|
+
import type { AgentTextOutput } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Strip all <working> tag content from text, returning only user-facing content.
|
|
19
|
+
* Whitespace is normalized: consecutive whitespace collapsed, trimmed.
|
|
20
|
+
*
|
|
21
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
22
|
+
* @returns User-facing text with all working content removed
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripWorkingTags(text: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Extract content from inside <working> tags.
|
|
27
|
+
* Multiple blocks are concatenated with newline separators.
|
|
28
|
+
* Returns null if no working tags are found.
|
|
29
|
+
*
|
|
30
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
31
|
+
* @returns Concatenated working content, or null if none found
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractWorkingContent(text: string): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Parse text into structured AgentTextOutput with user-facing and working segments.
|
|
36
|
+
*
|
|
37
|
+
* This is the primary parsing function used by CortexAgent at turn completion.
|
|
38
|
+
* It combines stripWorkingTags and extractWorkingContent into a single result.
|
|
39
|
+
*
|
|
40
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
41
|
+
* @returns Structured output with userFacing, working, and raw properties
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseWorkingTags(text: string): AgentTextOutput;
|
|
44
|
+
//# sourceMappingURL=working-tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-tags.d.ts","sourceRoot":"","sources":["../src/working-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAiBlD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBrD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgCjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAM9D"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working tags parser.
|
|
3
|
+
*
|
|
4
|
+
* Separates agent text into user-facing and working (internal reasoning)
|
|
5
|
+
* content based on <working> XML tag delimiters.
|
|
6
|
+
*
|
|
7
|
+
* Parsing rules:
|
|
8
|
+
* - Tags are flat delimiters: <working> opens, </working> closes. No nesting.
|
|
9
|
+
* - Multiple <working> blocks are concatenated (newline-separated) in `working`.
|
|
10
|
+
* - Whitespace between closing </working> tag and subsequent text is normalized.
|
|
11
|
+
* - Unclosed <working> tag: all content after the opening tag is treated as working.
|
|
12
|
+
* - Simple regex, not a full XML parser.
|
|
13
|
+
*
|
|
14
|
+
* Reference: working-tags.md
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Regex pattern for matching working tag blocks.
|
|
18
|
+
*
|
|
19
|
+
* Matches <working>...</working> pairs (non-greedy) and captures the content.
|
|
20
|
+
* The `s` flag makes `.` match newlines so working content can span multiple lines.
|
|
21
|
+
* The `g` flag finds all blocks in the text.
|
|
22
|
+
*/
|
|
23
|
+
const WORKING_TAG_PATTERN = /<working>(.*?)<\/working>/gs;
|
|
24
|
+
/**
|
|
25
|
+
* Pattern for detecting an unclosed <working> tag at the end of the text.
|
|
26
|
+
* Captures everything after the last unclosed <working> tag.
|
|
27
|
+
*/
|
|
28
|
+
const UNCLOSED_TAG_PATTERN = /<working>([\s\S]*)$/;
|
|
29
|
+
/**
|
|
30
|
+
* Strip all <working> tag content from text, returning only user-facing content.
|
|
31
|
+
* Whitespace is normalized: consecutive whitespace collapsed, trimmed.
|
|
32
|
+
*
|
|
33
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
34
|
+
* @returns User-facing text with all working content removed
|
|
35
|
+
*/
|
|
36
|
+
export function stripWorkingTags(text) {
|
|
37
|
+
// Replace closed <working>...</working> blocks with a newline sentinel.
|
|
38
|
+
// This ensures a clean break between content that was separated by a working block.
|
|
39
|
+
// The sentinel is used instead of directly removing to enable whitespace normalization.
|
|
40
|
+
let result = text.replace(WORKING_TAG_PATTERN, '\n');
|
|
41
|
+
// Handle any unclosed <working> tag at the end
|
|
42
|
+
result = result.replace(UNCLOSED_TAG_PATTERN, '');
|
|
43
|
+
// Normalize whitespace:
|
|
44
|
+
// 1. Collapse spaces/tabs around newlines into just the newline
|
|
45
|
+
// 2. Collapse 3+ newlines to 2 (preserve paragraph breaks)
|
|
46
|
+
result = result
|
|
47
|
+
.replace(/[ \t]*\n[ \t]*/g, '\n') // normalize spaces around newlines
|
|
48
|
+
.replace(/\n{3,}/g, '\n\n') // collapse 3+ newlines to 2
|
|
49
|
+
.trim();
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extract content from inside <working> tags.
|
|
54
|
+
* Multiple blocks are concatenated with newline separators.
|
|
55
|
+
* Returns null if no working tags are found.
|
|
56
|
+
*
|
|
57
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
58
|
+
* @returns Concatenated working content, or null if none found
|
|
59
|
+
*/
|
|
60
|
+
export function extractWorkingContent(text) {
|
|
61
|
+
const blocks = [];
|
|
62
|
+
// Reset regex lastIndex since we reuse the global pattern
|
|
63
|
+
WORKING_TAG_PATTERN.lastIndex = 0;
|
|
64
|
+
let match;
|
|
65
|
+
while ((match = WORKING_TAG_PATTERN.exec(text)) !== null) {
|
|
66
|
+
const content = match[1];
|
|
67
|
+
if (content !== undefined && content.trim().length > 0) {
|
|
68
|
+
blocks.push(content.trim());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Check for unclosed tag
|
|
72
|
+
// We need to check if there's an unclosed <working> AFTER the last closed block
|
|
73
|
+
const lastClosingIndex = text.lastIndexOf('</working>');
|
|
74
|
+
const lastOpeningIndex = text.lastIndexOf('<working>');
|
|
75
|
+
if (lastOpeningIndex > lastClosingIndex) {
|
|
76
|
+
// There is an unclosed tag after all closed blocks
|
|
77
|
+
const unclosedContent = text.slice(lastOpeningIndex + '<working>'.length);
|
|
78
|
+
if (unclosedContent.trim().length > 0) {
|
|
79
|
+
blocks.push(unclosedContent.trim());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (blocks.length === 0) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return blocks.join('\n');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse text into structured AgentTextOutput with user-facing and working segments.
|
|
89
|
+
*
|
|
90
|
+
* This is the primary parsing function used by CortexAgent at turn completion.
|
|
91
|
+
* It combines stripWorkingTags and extractWorkingContent into a single result.
|
|
92
|
+
*
|
|
93
|
+
* @param text - Raw agent text potentially containing <working> tags
|
|
94
|
+
* @returns Structured output with userFacing, working, and raw properties
|
|
95
|
+
*/
|
|
96
|
+
export function parseWorkingTags(text) {
|
|
97
|
+
return {
|
|
98
|
+
userFacing: stripWorkingTags(text),
|
|
99
|
+
working: extractWorkingContent(text),
|
|
100
|
+
raw: text,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=working-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-tags.js","sourceRoot":"","sources":["../src/working-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAE1D;;;GAGG;A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CAAC;IAEvD,IAAI,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;QACxC,mDAAmD;QACnD,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC1E,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO;QACL,UAAU,EAAE,gBAAgB,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,qBAAqB,CAAC,IAAI,CAAC;QACpC,GAAG,EAAE,IAAI;KACV,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@animus-labs/cortex",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Production-grade agent framework with structured context management, compaction, tools, and MCP support",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Animus Labs",
|
|
7
|
+
"private": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Craigtut/cortex-mono.git",
|
|
11
|
+
"directory": "packages/cortex"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Craigtut/cortex-mono/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/Craigtut/cortex-mono/tree/main/packages/cortex",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"agent",
|
|
20
|
+
"llm",
|
|
21
|
+
"context-management",
|
|
22
|
+
"compaction",
|
|
23
|
+
"mcp",
|
|
24
|
+
"tools",
|
|
25
|
+
"anthropic",
|
|
26
|
+
"openai"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"source": "./src/index.ts",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc",
|
|
50
|
+
"dev": "tsc --watch",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"test": "vitest",
|
|
53
|
+
"test:run": "vitest run",
|
|
54
|
+
"test:coverage": "vitest run --coverage",
|
|
55
|
+
"test:eval": "vitest run --config vitest.config.eval.ts",
|
|
56
|
+
"prepack": "npm run build"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=24.0.0"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@earendil-works/pi-agent-core": "^0.74.0",
|
|
63
|
+
"@earendil-works/pi-ai": "^0.74.0",
|
|
64
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
65
|
+
"typebox": "^1.1.24",
|
|
66
|
+
"@vscode/ripgrep": "^1.17.1",
|
|
67
|
+
"turndown": "^7.2.0",
|
|
68
|
+
"unpdf": "^1.6.0",
|
|
69
|
+
"zod-to-json-schema": "^3.25.1"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"zod": "^4.0.0"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"zod": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/node": "^22.0.0",
|
|
81
|
+
"@types/turndown": "^5.0.5",
|
|
82
|
+
"pdf-lib": "^1.17.1",
|
|
83
|
+
"typescript": "^5.6.0",
|
|
84
|
+
"vitest": "^2.1.0",
|
|
85
|
+
"zod": "^4.0.0"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget guard: enforces turn count and cost limits during the agentic loop.
|
|
3
|
+
*
|
|
4
|
+
* Monitors turn_end events for turn counting and cost accumulation.
|
|
5
|
+
* On breach, calls the provided abort function to stop the loop.
|
|
6
|
+
* Defaults to Infinity for both limits (no enforcement unless configured).
|
|
7
|
+
*
|
|
8
|
+
* Counters reset on agent_start (beginning of each agentic loop).
|
|
9
|
+
*
|
|
10
|
+
* Reference: cortex-architecture.md (Budget Guards section)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { BudgetGuardConfig, CortexLogger } from './types.js';
|
|
14
|
+
import { NOOP_LOGGER } from './noop-logger.js';
|
|
15
|
+
import type { EventBridge } from './event-bridge.js';
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// BudgetGuard
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
export class BudgetGuard {
|
|
22
|
+
private readonly maxTurns: number;
|
|
23
|
+
private readonly maxCost: number;
|
|
24
|
+
private readonly abortFn: () => void;
|
|
25
|
+
private readonly logger: CortexLogger;
|
|
26
|
+
|
|
27
|
+
private turnCount = 0;
|
|
28
|
+
private totalCost = 0;
|
|
29
|
+
private breached = false;
|
|
30
|
+
|
|
31
|
+
private unsubscribers: Array<() => void> = [];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create a BudgetGuard.
|
|
35
|
+
*
|
|
36
|
+
* @param config - Budget limits (maxTurns, maxCost). Both default to Infinity.
|
|
37
|
+
* @param abortFn - Function to call when a limit is breached (typically agent.abort())
|
|
38
|
+
* @param logger - Optional logger for diagnostics (defaults to silent no-op)
|
|
39
|
+
*/
|
|
40
|
+
constructor(config: Partial<BudgetGuardConfig>, abortFn: () => void, logger?: CortexLogger) {
|
|
41
|
+
this.maxTurns = config.maxTurns ?? Infinity;
|
|
42
|
+
this.maxCost = config.maxCost ?? Infinity;
|
|
43
|
+
this.abortFn = abortFn;
|
|
44
|
+
this.logger = logger ?? NOOP_LOGGER;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Wire the guard to an event bridge.
|
|
49
|
+
* Subscribes to turn_end (for turn counting and cost) and loop_start (for reset).
|
|
50
|
+
*
|
|
51
|
+
* @param bridge - The EventBridge to subscribe to
|
|
52
|
+
*/
|
|
53
|
+
wire(bridge: EventBridge): void {
|
|
54
|
+
// Clean up any previous wiring
|
|
55
|
+
this.unwire();
|
|
56
|
+
|
|
57
|
+
// Reset counters on agent_start (beginning of a new agentic loop)
|
|
58
|
+
this.unsubscribers.push(
|
|
59
|
+
bridge.on('loop_start', () => {
|
|
60
|
+
this.reset();
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Track turns and cost on turn_end
|
|
65
|
+
this.unsubscribers.push(
|
|
66
|
+
bridge.on('turn_end', (event) => {
|
|
67
|
+
this.turnCount++;
|
|
68
|
+
|
|
69
|
+
// Read cost from typed usage (extracted by EventBridge)
|
|
70
|
+
const cost = event.usage?.cost?.total ?? 0;
|
|
71
|
+
if (cost > 0) {
|
|
72
|
+
this.totalCost += cost;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check limits
|
|
76
|
+
this.checkLimits();
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Disconnect from the event bridge.
|
|
83
|
+
*/
|
|
84
|
+
unwire(): void {
|
|
85
|
+
for (const unsub of this.unsubscribers) {
|
|
86
|
+
unsub();
|
|
87
|
+
}
|
|
88
|
+
this.unsubscribers = [];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get the current turn count.
|
|
93
|
+
*/
|
|
94
|
+
getTurnCount(): number {
|
|
95
|
+
return this.turnCount;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get the accumulated cost.
|
|
100
|
+
*/
|
|
101
|
+
getTotalCost(): number {
|
|
102
|
+
return this.totalCost;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the maximum turn limit.
|
|
107
|
+
*/
|
|
108
|
+
getMaxTurns(): number {
|
|
109
|
+
return this.maxTurns;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the maximum cost limit.
|
|
114
|
+
*/
|
|
115
|
+
getMaxCost(): number {
|
|
116
|
+
return this.maxCost;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether any limit has been breached.
|
|
121
|
+
*/
|
|
122
|
+
isBreached(): boolean {
|
|
123
|
+
return this.breached;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Reset counters. Called automatically on loop_start.
|
|
128
|
+
*/
|
|
129
|
+
reset(): void {
|
|
130
|
+
this.turnCount = 0;
|
|
131
|
+
this.totalCost = 0;
|
|
132
|
+
this.breached = false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Clean up all subscriptions.
|
|
137
|
+
*/
|
|
138
|
+
destroy(): void {
|
|
139
|
+
this.unwire();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Check if any limits have been exceeded and abort if so.
|
|
144
|
+
*/
|
|
145
|
+
private checkLimits(): void {
|
|
146
|
+
if (this.breached) {
|
|
147
|
+
return; // Already breached, don't abort multiple times
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (this.turnCount >= this.maxTurns) {
|
|
151
|
+
this.breached = true;
|
|
152
|
+
this.logger.warn('[BudgetGuard] turn limit breached', {
|
|
153
|
+
turnCount: this.turnCount,
|
|
154
|
+
maxTurns: this.maxTurns,
|
|
155
|
+
});
|
|
156
|
+
this.abortFn();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (this.totalCost >= this.maxCost) {
|
|
161
|
+
this.breached = true;
|
|
162
|
+
this.logger.warn('[BudgetGuard] cost limit breached', {
|
|
163
|
+
totalCost: this.totalCost,
|
|
164
|
+
maxCost: this.maxCost,
|
|
165
|
+
});
|
|
166
|
+
this.abortFn();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|