@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":"edit-matcher.js","sourceRoot":"","sources":["../../../src/tools/shared/edit-matcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA4CH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,MAAc;IACxD,yEAAyE;IACzE,2EAA2E;IAC3E,iEAAiE;IACjE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAA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E,CAAC;QAC5B,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAChB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,EAChB,IAAI,CAAC,CAAC,CAAE,GAAG,CAAC,EACZ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,IAAI,CACpB,CAAC;QACJ,CAAC;QACD,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-file async mutation lock.
|
|
3
|
+
*
|
|
4
|
+
* Serializes concurrent mutations (Edit, Write) that target the same file
|
|
5
|
+
* while allowing mutations on different files to proceed in parallel.
|
|
6
|
+
*
|
|
7
|
+
* Uses promise chaining rather than OS mutexes: each `acquire()` appends
|
|
8
|
+
* a new link to the per-path chain. The caller awaits the previous link
|
|
9
|
+
* (serialization) and receives a `release` callback that resolves the
|
|
10
|
+
* current link so the next waiter can proceed.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FileMutationLock {
|
|
13
|
+
private chains;
|
|
14
|
+
/**
|
|
15
|
+
* Acquire exclusive mutation access for a file path.
|
|
16
|
+
* Returns a release function that MUST be called when done (use try/finally).
|
|
17
|
+
*/
|
|
18
|
+
acquire(filePath: string): Promise<() => void>;
|
|
19
|
+
/** Clear all chains. Safe to call between agentic loops. */
|
|
20
|
+
clear(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=file-mutation-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-mutation-lock.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/file-mutation-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAoC;IAElD;;;OAGG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAcpD,4DAA4D;IAC5D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-file async mutation lock.
|
|
3
|
+
*
|
|
4
|
+
* Serializes concurrent mutations (Edit, Write) that target the same file
|
|
5
|
+
* while allowing mutations on different files to proceed in parallel.
|
|
6
|
+
*
|
|
7
|
+
* Uses promise chaining rather than OS mutexes: each `acquire()` appends
|
|
8
|
+
* a new link to the per-path chain. The caller awaits the previous link
|
|
9
|
+
* (serialization) and receives a `release` callback that resolves the
|
|
10
|
+
* current link so the next waiter can proceed.
|
|
11
|
+
*/
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
export class FileMutationLock {
|
|
14
|
+
chains = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* Acquire exclusive mutation access for a file path.
|
|
17
|
+
* Returns a release function that MUST be called when done (use try/finally).
|
|
18
|
+
*/
|
|
19
|
+
async acquire(filePath) {
|
|
20
|
+
const key = path.resolve(filePath);
|
|
21
|
+
const previous = this.chains.get(key) ?? Promise.resolve();
|
|
22
|
+
let release;
|
|
23
|
+
const current = new Promise(resolve => {
|
|
24
|
+
release = resolve;
|
|
25
|
+
});
|
|
26
|
+
this.chains.set(key, current);
|
|
27
|
+
await previous;
|
|
28
|
+
return release;
|
|
29
|
+
}
|
|
30
|
+
/** Clear all chains. Safe to call between agentic loops. */
|
|
31
|
+
clear() {
|
|
32
|
+
this.chains.clear();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=file-mutation-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-mutation-lock.js","sourceRoot":"","sources":["../../../src/tools/shared/file-mutation-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,OAAO,gBAAgB;IACnB,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAElD;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAE3D,IAAI,OAAoB,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;YAC1C,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAE9B,MAAM,QAAQ,CAAC;QACf,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,4DAA4D;IAC5D,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared .gitignore reading utility.
|
|
3
|
+
*
|
|
4
|
+
* Walks up the directory tree collecting .gitignore patterns.
|
|
5
|
+
* Used by both Glob and Grep tools to respect .gitignore rules.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default ignore patterns used when no .gitignore is present,
|
|
9
|
+
* or merged with .gitignore patterns.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_IGNORE_PATTERNS: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Read and parse .gitignore files by walking up from `dir` to the filesystem root.
|
|
14
|
+
* Returns an array of gitignore patterns (comments and empty lines stripped).
|
|
15
|
+
*/
|
|
16
|
+
export declare function readGitignorePatterns(dir: string): Promise<string[]>;
|
|
17
|
+
//# sourceMappingURL=gitignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/gitignore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;GAGG;AACH,eAAO,MAAM,uBAAuB,UAanC,CAAC;AAEF;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B1E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared .gitignore reading utility.
|
|
3
|
+
*
|
|
4
|
+
* Walks up the directory tree collecting .gitignore patterns.
|
|
5
|
+
* Used by both Glob and Grep tools to respect .gitignore rules.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
/**
|
|
10
|
+
* Default ignore patterns used when no .gitignore is present,
|
|
11
|
+
* or merged with .gitignore patterns.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_IGNORE_PATTERNS = [
|
|
14
|
+
'node_modules',
|
|
15
|
+
'.git',
|
|
16
|
+
'dist',
|
|
17
|
+
'build',
|
|
18
|
+
'__pycache__',
|
|
19
|
+
'.DS_Store',
|
|
20
|
+
'.next',
|
|
21
|
+
'.nuxt',
|
|
22
|
+
'coverage',
|
|
23
|
+
'.cache',
|
|
24
|
+
'.parcel-cache',
|
|
25
|
+
'.vite',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Read and parse .gitignore files by walking up from `dir` to the filesystem root.
|
|
29
|
+
* Returns an array of gitignore patterns (comments and empty lines stripped).
|
|
30
|
+
*/
|
|
31
|
+
export async function readGitignorePatterns(dir) {
|
|
32
|
+
const patterns = [];
|
|
33
|
+
let current = dir;
|
|
34
|
+
const visited = new Set();
|
|
35
|
+
while (!visited.has(current)) {
|
|
36
|
+
visited.add(current);
|
|
37
|
+
const gitignorePath = path.join(current, '.gitignore');
|
|
38
|
+
try {
|
|
39
|
+
const content = await fs.promises.readFile(gitignorePath, 'utf8');
|
|
40
|
+
const lines = content.split('\n');
|
|
41
|
+
for (const line of lines) {
|
|
42
|
+
const trimmed = line.trim();
|
|
43
|
+
// Skip comments and empty lines
|
|
44
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
45
|
+
patterns.push(trimmed);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// No .gitignore at this level, continue
|
|
51
|
+
}
|
|
52
|
+
const parent = path.dirname(current);
|
|
53
|
+
if (parent === current)
|
|
54
|
+
break;
|
|
55
|
+
current = parent;
|
|
56
|
+
}
|
|
57
|
+
return patterns;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=gitignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../../../src/tools/shared/gitignore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,aAAa;IACb,WAAW;IACX,OAAO;IACP,OAAO;IACP,UAAU;IACV,QAAQ;IACR,eAAe;IACf,OAAO;CACR,CAAC;A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ary so the Read tool never touches pdfjs directly. Swapping the
|
|
6
|
+
* backend later is a one-file change.
|
|
7
|
+
*
|
|
8
|
+
* Responsibilities:
|
|
9
|
+
* - Parse the caller's `pages` spec and clamp it to the document and
|
|
10
|
+
* the per-call page cap.
|
|
11
|
+
* - Extract per-page text.
|
|
12
|
+
* - Detect "no extractable text" (scanned / image-only PDFs) and
|
|
13
|
+
* return a structured signal rather than silently-empty output.
|
|
14
|
+
* - Render the extracted text with `[Page N]` markers so the caller
|
|
15
|
+
* can line-number it exactly like any other file content.
|
|
16
|
+
*
|
|
17
|
+
* Pure-ish: does no filesystem I/O. Callers are expected to have
|
|
18
|
+
* already loaded the PDF bytes.
|
|
19
|
+
*/
|
|
20
|
+
export interface PdfExtractionRequest {
|
|
21
|
+
/** PDF bytes. Accepts a Node Buffer or any Uint8Array. */
|
|
22
|
+
data: Buffer | Uint8Array;
|
|
23
|
+
/**
|
|
24
|
+
* Page spec: `"N"`, `"N-M"`, or undefined. When undefined, extracts
|
|
25
|
+
* the first `maxPages` pages starting at page 1.
|
|
26
|
+
*/
|
|
27
|
+
pagesSpec?: string | undefined;
|
|
28
|
+
/** Upper bound on how many pages may be extracted in one call. */
|
|
29
|
+
maxPages?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface PdfExtractionOk {
|
|
32
|
+
kind: 'ok';
|
|
33
|
+
totalPages: number;
|
|
34
|
+
/** First page extracted (1-based, inclusive). */
|
|
35
|
+
firstPage: number;
|
|
36
|
+
/** Last page extracted (1-based, inclusive). */
|
|
37
|
+
lastPage: number;
|
|
38
|
+
/** Per-page text. `pages[i].pageNumber` is 1-based. */
|
|
39
|
+
pages: Array<{
|
|
40
|
+
pageNumber: number;
|
|
41
|
+
text: string;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Full rendered text with `[Page N]` markers separating pages, ready
|
|
45
|
+
* to be handed to the same line-numbering pipeline Read uses for
|
|
46
|
+
* plain text files.
|
|
47
|
+
*/
|
|
48
|
+
rendered: string;
|
|
49
|
+
}
|
|
50
|
+
export interface PdfExtractionEmpty {
|
|
51
|
+
kind: 'empty';
|
|
52
|
+
totalPages: number;
|
|
53
|
+
firstPage: number;
|
|
54
|
+
lastPage: number;
|
|
55
|
+
message: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PdfExtractionInvalidRange {
|
|
58
|
+
kind: 'invalid-range';
|
|
59
|
+
totalPages: number;
|
|
60
|
+
message: string;
|
|
61
|
+
}
|
|
62
|
+
export interface PdfExtractionError {
|
|
63
|
+
kind: 'error';
|
|
64
|
+
message: string;
|
|
65
|
+
}
|
|
66
|
+
export type PdfExtractionResult = PdfExtractionOk | PdfExtractionEmpty | PdfExtractionInvalidRange | PdfExtractionError;
|
|
67
|
+
/**
|
|
68
|
+
* Default cap on pages extracted per call. Matches the advertised
|
|
69
|
+
* schema default for Read's `pages` param ("max 20 pages per request").
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_MAX_PAGES = 20;
|
|
72
|
+
export type PagesSpecResult = {
|
|
73
|
+
ok: true;
|
|
74
|
+
first: number;
|
|
75
|
+
last: number;
|
|
76
|
+
} | {
|
|
77
|
+
ok: false;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Parse a pages-spec string against a document's page count and the
|
|
82
|
+
* per-call cap. Enforces:
|
|
83
|
+
* - Format: `"N"` or `"N-M"` (base 10, whitespace tolerant)
|
|
84
|
+
* - 1 <= first <= last <= totalPages
|
|
85
|
+
* - (last - first + 1) <= maxPages
|
|
86
|
+
*
|
|
87
|
+
* Returns `{ ok: false }` with an actionable message on any failure.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parsePagesSpec(spec: string, totalPages: number, maxPages: number): PagesSpecResult;
|
|
90
|
+
/**
|
|
91
|
+
* Extract text from a PDF buffer. Never throws — all failure modes are
|
|
92
|
+
* returned as structured results so the caller can render them as
|
|
93
|
+
* tool-content messages.
|
|
94
|
+
*/
|
|
95
|
+
export declare function extractPdfText(req: PdfExtractionRequest): Promise<PdfExtractionResult>;
|
|
96
|
+
//# sourceMappingURL=pdf-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-extractor.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/pdf-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,KAAK,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,eAAe,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,kBAAkB,GAClB,yBAAyB,GACzB,kBAAkB,CAAC;AAMvB;;;GAGG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAapC,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,eAAe,CA4CjB;AAwBD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA6E9B"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF text extraction.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `unpdf` (pure-ESM, zero native deps) behind a narrow, well-typed
|
|
5
|
+
* boundary so the Read tool never touches pdfjs directly. Swapping the
|
|
6
|
+
* backend later is a one-file change.
|
|
7
|
+
*
|
|
8
|
+
* Responsibilities:
|
|
9
|
+
* - Parse the caller's `pages` spec and clamp it to the document and
|
|
10
|
+
* the per-call page cap.
|
|
11
|
+
* - Extract per-page text.
|
|
12
|
+
* - Detect "no extractable text" (scanned / image-only PDFs) and
|
|
13
|
+
* return a structured signal rather than silently-empty output.
|
|
14
|
+
* - Render the extracted text with `[Page N]` markers so the caller
|
|
15
|
+
* can line-number it exactly like any other file content.
|
|
16
|
+
*
|
|
17
|
+
* Pure-ish: does no filesystem I/O. Callers are expected to have
|
|
18
|
+
* already loaded the PDF bytes.
|
|
19
|
+
*/
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Constants
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Default cap on pages extracted per call. Matches the advertised
|
|
25
|
+
* schema default for Read's `pages` param ("max 20 pages per request").
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_MAX_PAGES = 20;
|
|
28
|
+
/**
|
|
29
|
+
* Total-text length below which we treat the document as image-based.
|
|
30
|
+
* 20 characters allows for a stray page number or watermark without
|
|
31
|
+
* pretending we extracted meaningful content.
|
|
32
|
+
*/
|
|
33
|
+
const EMPTY_TEXT_THRESHOLD = 20;
|
|
34
|
+
/**
|
|
35
|
+
* Parse a pages-spec string against a document's page count and the
|
|
36
|
+
* per-call cap. Enforces:
|
|
37
|
+
* - Format: `"N"` or `"N-M"` (base 10, whitespace tolerant)
|
|
38
|
+
* - 1 <= first <= last <= totalPages
|
|
39
|
+
* - (last - first + 1) <= maxPages
|
|
40
|
+
*
|
|
41
|
+
* Returns `{ ok: false }` with an actionable message on any failure.
|
|
42
|
+
*/
|
|
43
|
+
export function parsePagesSpec(spec, totalPages, maxPages) {
|
|
44
|
+
const trimmed = spec.trim();
|
|
45
|
+
const rangeMatch = /^(\d+)-(\d+)$/u.exec(trimmed);
|
|
46
|
+
const singleMatch = /^(\d+)$/u.exec(trimmed);
|
|
47
|
+
let first;
|
|
48
|
+
let last;
|
|
49
|
+
if (rangeMatch) {
|
|
50
|
+
first = Number.parseInt(rangeMatch[1], 10);
|
|
51
|
+
last = Number.parseInt(rangeMatch[2], 10);
|
|
52
|
+
}
|
|
53
|
+
else if (singleMatch) {
|
|
54
|
+
first = Number.parseInt(singleMatch[1], 10);
|
|
55
|
+
last = first;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
message: `Invalid pages spec "${spec}". Use "N" or "N-M" (e.g. "1-5", "3").`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (first < 1) {
|
|
64
|
+
return { ok: false, message: `Page numbers are 1-based; got first page ${first}.` };
|
|
65
|
+
}
|
|
66
|
+
if (last < first) {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
message: `Invalid pages spec "${spec}": last page (${last}) is before first page (${first}).`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (last > totalPages) {
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
message: `Pages spec "${spec}" exceeds document (has ${totalPages} page${totalPages === 1 ? '' : 's'}).`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const count = last - first + 1;
|
|
79
|
+
if (count > maxPages) {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
message: `Pages spec "${spec}" requests ${count} pages; the per-call limit is ${maxPages}. Narrow the range.`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return { ok: true, first, last };
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Buffer normalization
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* Convert input bytes to a fresh, owned `Uint8Array`.
|
|
92
|
+
*
|
|
93
|
+
* `unpdf` rejects `Buffer` inputs outright ("Please provide binary data
|
|
94
|
+
* as `Uint8Array`, rather than `Buffer`"), and its PDF.js worker path
|
|
95
|
+
* may transfer the backing buffer during postMessage — leaving a shared
|
|
96
|
+
* view detached for subsequent calls. Making a full copy here keeps
|
|
97
|
+
* the caller's buffer usable and makes repeat extractions on the same
|
|
98
|
+
* bytes safe across tests and sessions.
|
|
99
|
+
*/
|
|
100
|
+
function toUint8Array(data) {
|
|
101
|
+
return new Uint8Array(data);
|
|
102
|
+
}
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Extraction
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Extract text from a PDF buffer. Never throws — all failure modes are
|
|
108
|
+
* returned as structured results so the caller can render them as
|
|
109
|
+
* tool-content messages.
|
|
110
|
+
*/
|
|
111
|
+
export async function extractPdfText(req) {
|
|
112
|
+
const maxPages = req.maxPages ?? DEFAULT_MAX_PAGES;
|
|
113
|
+
const bytes = toUint8Array(req.data);
|
|
114
|
+
let extractResult;
|
|
115
|
+
try {
|
|
116
|
+
const { extractText } = await import('unpdf');
|
|
117
|
+
const raw = await extractText(bytes, { mergePages: false });
|
|
118
|
+
extractResult = {
|
|
119
|
+
totalPages: raw.totalPages,
|
|
120
|
+
text: Array.isArray(raw.text) ? raw.text : [raw.text],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
125
|
+
return {
|
|
126
|
+
kind: 'error',
|
|
127
|
+
message: `Failed to parse PDF: ${msg}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const { totalPages, text: allPages } = extractResult;
|
|
131
|
+
if (totalPages === 0) {
|
|
132
|
+
return {
|
|
133
|
+
kind: 'empty',
|
|
134
|
+
totalPages: 0,
|
|
135
|
+
firstPage: 0,
|
|
136
|
+
lastPage: 0,
|
|
137
|
+
message: 'PDF contains no pages.',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
// Resolve the page range.
|
|
141
|
+
let first;
|
|
142
|
+
let last;
|
|
143
|
+
if (req.pagesSpec !== undefined) {
|
|
144
|
+
const parsed = parsePagesSpec(req.pagesSpec, totalPages, maxPages);
|
|
145
|
+
if (!parsed.ok) {
|
|
146
|
+
return { kind: 'invalid-range', totalPages, message: parsed.message };
|
|
147
|
+
}
|
|
148
|
+
first = parsed.first;
|
|
149
|
+
last = parsed.last;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
first = 1;
|
|
153
|
+
last = Math.min(maxPages, totalPages);
|
|
154
|
+
}
|
|
155
|
+
const pages = [];
|
|
156
|
+
for (let pageNumber = first; pageNumber <= last; pageNumber++) {
|
|
157
|
+
const raw = allPages[pageNumber - 1] ?? '';
|
|
158
|
+
pages.push({ pageNumber, text: raw });
|
|
159
|
+
}
|
|
160
|
+
const totalLen = pages.reduce((n, p) => n + p.text.trim().length, 0);
|
|
161
|
+
if (totalLen < EMPTY_TEXT_THRESHOLD) {
|
|
162
|
+
return {
|
|
163
|
+
kind: 'empty',
|
|
164
|
+
totalPages,
|
|
165
|
+
firstPage: first,
|
|
166
|
+
lastPage: last,
|
|
167
|
+
message: totalPages > 0 && totalLen === 0
|
|
168
|
+
? 'PDF has no extractable text (likely scanned or image-only). Use an OCR tool to process it.'
|
|
169
|
+
: 'PDF yielded almost no extractable text (likely scanned or image-heavy). Use an OCR tool for full content.',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const rendered = renderPages(pages, first, last, totalPages);
|
|
173
|
+
return {
|
|
174
|
+
kind: 'ok',
|
|
175
|
+
totalPages,
|
|
176
|
+
firstPage: first,
|
|
177
|
+
lastPage: last,
|
|
178
|
+
pages,
|
|
179
|
+
rendered,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Render the per-page text into a single string with `[Page N]`
|
|
184
|
+
* markers. A leading summary line is included so the model knows how
|
|
185
|
+
* many pages the document has and which subset it's seeing.
|
|
186
|
+
*/
|
|
187
|
+
function renderPages(pages, firstPage, lastPage, totalPages) {
|
|
188
|
+
const header = firstPage === 1 && lastPage === totalPages
|
|
189
|
+
? `[PDF: ${totalPages} page${totalPages === 1 ? '' : 's'}]`
|
|
190
|
+
: `[PDF: showing pages ${firstPage}-${lastPage} of ${totalPages}]`;
|
|
191
|
+
const body = pages
|
|
192
|
+
.map((p) => `[Page ${p.pageNumber}]\n${p.text.trim()}`)
|
|
193
|
+
.join('\n\n');
|
|
194
|
+
return `${header}\n\n${body}\n`;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=pdf-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-extractor.js","sourceRoot":"","sources":["../../../src/tools/shared/pdf-extractor.ts"],"names":[],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,IAAI,QAAQ,KAAK,UAAU;QACxC,CAAC,CAAC,SAAS,UAAU,QAAQ,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;QAC3D,CAAC,CAAC,uBAAuB,SAAS,IAAI,QAAQ,OAAO,UAAU,GAAG,CAAC;IACvE,MAAM,IAAI,GAAG,KAAK;SACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,UAAU,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;SACtD,IAAI,CAAC,MAAM,CAAC,CAAC;IAChB,OAAO,GAAG,MAAM,OAAO,IAAI,IAAI,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop-scoped file read tracking.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the Read, Write, and Edit tools to enforce
|
|
5
|
+
* the read-before-write/edit contract. Tracks which files
|
|
6
|
+
* have been read during the current agentic loop, along with
|
|
7
|
+
* metadata (mtime, offset, limit) for file-unchanged dedup.
|
|
8
|
+
*
|
|
9
|
+
* Created once per CortexAgent and cleared at the start
|
|
10
|
+
* of each agentic loop via clear().
|
|
11
|
+
*/
|
|
12
|
+
export interface ReadState {
|
|
13
|
+
/** File mtime at time of read (ms since epoch). */
|
|
14
|
+
timestamp: number;
|
|
15
|
+
/** 1-based offset used for the read (undefined = full read). */
|
|
16
|
+
offset?: number;
|
|
17
|
+
/** Line limit used for the read (undefined = default/full). */
|
|
18
|
+
limit?: number;
|
|
19
|
+
/**
|
|
20
|
+
* SHA-256 hex digest of the raw file bytes at the time of read.
|
|
21
|
+
* Populated only for non-truncated, full reads; used as a fallback
|
|
22
|
+
* on mtime mismatch to allow writes when the on-disk bytes are
|
|
23
|
+
* actually unchanged (e.g. a formatter or cloud-sync tool touched
|
|
24
|
+
* the mtime without modifying content).
|
|
25
|
+
*/
|
|
26
|
+
contentHash?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class ReadRegistry {
|
|
29
|
+
private readonly entries;
|
|
30
|
+
/**
|
|
31
|
+
* Mark a file as read with metadata for dedup.
|
|
32
|
+
* The path is normalized to an absolute, platform-canonical form.
|
|
33
|
+
*/
|
|
34
|
+
markRead(filePath: string, state?: ReadState): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check whether a file has been read in the current agentic loop.
|
|
37
|
+
*/
|
|
38
|
+
hasBeenRead(filePath: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get the read state for a file, or undefined if not read.
|
|
41
|
+
*/
|
|
42
|
+
getState(filePath: string): ReadState | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Invalidate a single file's read state.
|
|
45
|
+
* Called when the on-disk mtime diverges from the recorded read
|
|
46
|
+
* state (external modification), forcing a fresh Read before
|
|
47
|
+
* the next mutation. Successful Edit/Write calls instead call
|
|
48
|
+
* markRead() with the new mtime, since the agent's own mutation
|
|
49
|
+
* is authoritative knowledge of current file contents.
|
|
50
|
+
*/
|
|
51
|
+
invalidate(filePath: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Clear all read tracking. Called at the start of each agentic loop.
|
|
54
|
+
*/
|
|
55
|
+
clear(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of tracked files (for diagnostics).
|
|
58
|
+
*/
|
|
59
|
+
get size(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize a file path for consistent comparison.
|
|
62
|
+
* Resolves to absolute and normalizes separators.
|
|
63
|
+
*/
|
|
64
|
+
private normalize;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=read-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-registry.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/read-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI;IAOnD;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAItC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIjD;;;;;;;OAOG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,OAAO,CAAC,SAAS;CAGlB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loop-scoped file read tracking.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the Read, Write, and Edit tools to enforce
|
|
5
|
+
* the read-before-write/edit contract. Tracks which files
|
|
6
|
+
* have been read during the current agentic loop, along with
|
|
7
|
+
* metadata (mtime, offset, limit) for file-unchanged dedup.
|
|
8
|
+
*
|
|
9
|
+
* Created once per CortexAgent and cleared at the start
|
|
10
|
+
* of each agentic loop via clear().
|
|
11
|
+
*/
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
export class ReadRegistry {
|
|
14
|
+
entries = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* Mark a file as read with metadata for dedup.
|
|
17
|
+
* The path is normalized to an absolute, platform-canonical form.
|
|
18
|
+
*/
|
|
19
|
+
markRead(filePath, state) {
|
|
20
|
+
this.entries.set(this.normalize(filePath), state ?? { timestamp: Date.now() });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check whether a file has been read in the current agentic loop.
|
|
24
|
+
*/
|
|
25
|
+
hasBeenRead(filePath) {
|
|
26
|
+
return this.entries.has(this.normalize(filePath));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the read state for a file, or undefined if not read.
|
|
30
|
+
*/
|
|
31
|
+
getState(filePath) {
|
|
32
|
+
return this.entries.get(this.normalize(filePath));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Invalidate a single file's read state.
|
|
36
|
+
* Called when the on-disk mtime diverges from the recorded read
|
|
37
|
+
* state (external modification), forcing a fresh Read before
|
|
38
|
+
* the next mutation. Successful Edit/Write calls instead call
|
|
39
|
+
* markRead() with the new mtime, since the agent's own mutation
|
|
40
|
+
* is authoritative knowledge of current file contents.
|
|
41
|
+
*/
|
|
42
|
+
invalidate(filePath) {
|
|
43
|
+
this.entries.delete(this.normalize(filePath));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Clear all read tracking. Called at the start of each agentic loop.
|
|
47
|
+
*/
|
|
48
|
+
clear() {
|
|
49
|
+
this.entries.clear();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the number of tracked files (for diagnostics).
|
|
53
|
+
*/
|
|
54
|
+
get size() {
|
|
55
|
+
return this.entries.size;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Normalize a file path for consistent comparison.
|
|
59
|
+
* Resolves to absolute and normalizes separators.
|
|
60
|
+
*/
|
|
61
|
+
normalize(filePath) {
|
|
62
|
+
return path.resolve(filePath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=read-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-registry.js","sourceRoot":"","sources":["../../../src/tools/shared/read-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAmBlC,MAAM,OAAO,YAAY;IACN,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAExD;;;OAGG;IACH,QAAQ,CAAC,QAAgB,EAAE,KAAiB;QAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,CACd,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EACxB,KAAK,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CACnC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAAgB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,QAAgB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,QAAgB;QACzB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACK,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared environment sanitization for child processes.
|
|
3
|
+
*
|
|
4
|
+
* Used by both the Bash tool (safety.ts) and MCP client (mcp-client.ts)
|
|
5
|
+
* to strip dangerous environment variables before spawning subprocesses.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Build a safe environment for child processes by stripping dangerous variables.
|
|
9
|
+
*
|
|
10
|
+
* @param parentEnv - The source environment (typically process.env or a consumer-supplied map)
|
|
11
|
+
* @param marker - Optional context marker added as CORTEX_SHELL. Pass undefined to skip.
|
|
12
|
+
* @param overrides - Optional key-value pairs merged ON TOP of the sanitized env, bypassing
|
|
13
|
+
* the blocklist. Used for consumer-set variables that must propagate (e.g., macOS dock
|
|
14
|
+
* icon suppression vars like DYLD_INSERT_LIBRARIES).
|
|
15
|
+
* @returns A new object with dangerous variables removed and overrides applied
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSafeEnv(parentEnv: NodeJS.ProcessEnv | Record<string, string>, marker?: string | undefined, overrides?: Record<string, string> | undefined): Record<string, string>;
|
|
18
|
+
//# sourceMappingURL=safe-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-env.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/safe-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoCxB"}
|