onbuzz 3.3.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 +267 -0
- package/README.md +425 -0
- package/bin/cli.js +556 -0
- package/bin/loxia-terminal-v2.js +162 -0
- package/bin/loxia-terminal.js +90 -0
- package/bin/start-with-terminal.js +200 -0
- package/node_modules/@isaacs/balanced-match/LICENSE.md +23 -0
- package/node_modules/@isaacs/balanced-match/README.md +60 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts +9 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js +59 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts +9 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.js +54 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/balanced-match/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/balanced-match/package.json +79 -0
- package/node_modules/@isaacs/brace-expansion/LICENSE +23 -0
- package/node_modules/@isaacs/brace-expansion/README.md +97 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts +6 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js +199 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/package.json +3 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts +6 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.js +195 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.js.map +1 -0
- package/node_modules/@isaacs/brace-expansion/dist/esm/package.json +3 -0
- package/node_modules/@isaacs/brace-expansion/package.json +60 -0
- package/node_modules/glob/LICENSE.md +63 -0
- package/node_modules/glob/README.md +1177 -0
- package/node_modules/glob/dist/commonjs/glob.d.ts +388 -0
- package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/glob.js +247 -0
- package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
- package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
- package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
- package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
- package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
- package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/ignore.js +119 -0
- package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
- package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
- package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/index.js +68 -0
- package/node_modules/glob/dist/commonjs/index.js.map +1 -0
- package/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/glob/dist/commonjs/package.json +3 -0
- package/node_modules/glob/dist/commonjs/pattern.d.ts +76 -0
- package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/pattern.js +219 -0
- package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
- package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
- package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/processor.js +301 -0
- package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
- package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
- package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
- package/node_modules/glob/dist/commonjs/walker.js +387 -0
- package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
- package/node_modules/glob/dist/esm/glob.d.ts +388 -0
- package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/glob.js +243 -0
- package/node_modules/glob/dist/esm/glob.js.map +1 -0
- package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
- package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/has-magic.js +23 -0
- package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
- package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
- package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/ignore.js +115 -0
- package/node_modules/glob/dist/esm/ignore.js.map +1 -0
- package/node_modules/glob/dist/esm/index.d.ts +97 -0
- package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/index.js +55 -0
- package/node_modules/glob/dist/esm/index.js.map +1 -0
- package/node_modules/glob/dist/esm/index.min.js +4 -0
- package/node_modules/glob/dist/esm/index.min.js.map +7 -0
- package/node_modules/glob/dist/esm/package.json +3 -0
- package/node_modules/glob/dist/esm/pattern.d.ts +76 -0
- package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/pattern.js +215 -0
- package/node_modules/glob/dist/esm/pattern.js.map +1 -0
- package/node_modules/glob/dist/esm/processor.d.ts +59 -0
- package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/processor.js +294 -0
- package/node_modules/glob/dist/esm/processor.js.map +1 -0
- package/node_modules/glob/dist/esm/walker.d.ts +97 -0
- package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
- package/node_modules/glob/dist/esm/walker.js +381 -0
- package/node_modules/glob/dist/esm/walker.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/LICENSE.md +55 -0
- package/node_modules/glob/node_modules/minimatch/README.md +453 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js +591 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js +152 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts +94 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +1029 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js +587 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js +148 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts +94 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js +1016 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/package.json +3 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
- package/node_modules/glob/node_modules/minimatch/package.json +67 -0
- package/node_modules/glob/package.json +101 -0
- package/node_modules/minipass/LICENSE +15 -0
- package/node_modules/minipass/README.md +825 -0
- package/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
- package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/minipass/dist/commonjs/index.js +1028 -0
- package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
- package/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/node_modules/minipass/dist/esm/index.d.ts +549 -0
- package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
- package/node_modules/minipass/dist/esm/index.js +1018 -0
- package/node_modules/minipass/dist/esm/index.js.map +1 -0
- package/node_modules/minipass/dist/esm/package.json +3 -0
- package/node_modules/minipass/package.json +82 -0
- package/node_modules/package-json-from-dist/LICENSE.md +63 -0
- package/node_modules/package-json-from-dist/README.md +110 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts +89 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.js +134 -0
- package/node_modules/package-json-from-dist/dist/commonjs/index.js.map +1 -0
- package/node_modules/package-json-from-dist/dist/commonjs/package.json +3 -0
- package/node_modules/package-json-from-dist/dist/esm/index.d.ts +89 -0
- package/node_modules/package-json-from-dist/dist/esm/index.d.ts.map +1 -0
- package/node_modules/package-json-from-dist/dist/esm/index.js +129 -0
- package/node_modules/package-json-from-dist/dist/esm/index.js.map +1 -0
- package/node_modules/package-json-from-dist/dist/esm/package.json +3 -0
- package/node_modules/package-json-from-dist/package.json +68 -0
- package/node_modules/path-scurry/LICENSE.md +55 -0
- package/node_modules/path-scurry/README.md +636 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
- package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
- package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
- package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
- package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
- package/node_modules/path-scurry/dist/esm/index.js +1983 -0
- package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
- package/node_modules/path-scurry/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
- package/node_modules/path-scurry/node_modules/lru-cache/README.md +383 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts +1323 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1589 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts +1323 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1585 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/node_modules/path-scurry/node_modules/lru-cache/package.json +101 -0
- package/node_modules/path-scurry/package.json +88 -0
- package/node_modules/rimraf/LICENSE.md +55 -0
- package/node_modules/rimraf/README.md +226 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.js +58 -0
- package/node_modules/rimraf/dist/commonjs/default-tmp.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/error.d.ts +6 -0
- package/node_modules/rimraf/dist/commonjs/error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/error.js +10 -0
- package/node_modules/rimraf/dist/commonjs/error.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.js +38 -0
- package/node_modules/rimraf/dist/commonjs/fix-eperm.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fs.d.ts +15 -0
- package/node_modules/rimraf/dist/commonjs/fs.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/fs.js +33 -0
- package/node_modules/rimraf/dist/commonjs/fs.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.js +24 -0
- package/node_modules/rimraf/dist/commonjs/ignore-enoent.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/index.d.ts +50 -0
- package/node_modules/rimraf/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/index.js +78 -0
- package/node_modules/rimraf/dist/commonjs/index.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts +34 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.js +53 -0
- package/node_modules/rimraf/dist/commonjs/opt-arg.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/package.json +3 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.js +48 -0
- package/node_modules/rimraf/dist/commonjs/path-arg.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.js +19 -0
- package/node_modules/rimraf/dist/commonjs/readdir-or-error.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts +8 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.js +65 -0
- package/node_modules/rimraf/dist/commonjs/retry-busy.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts +3 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.js +8 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-manual.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js +138 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.js +24 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-native.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.js +103 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-posix.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.js +159 -0
- package/node_modules/rimraf/dist/commonjs/rimraf-windows.js.map +1 -0
- package/node_modules/rimraf/dist/commonjs/use-native.d.ts +4 -0
- package/node_modules/rimraf/dist/commonjs/use-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/commonjs/use-native.js +18 -0
- package/node_modules/rimraf/dist/commonjs/use-native.js.map +1 -0
- package/node_modules/rimraf/dist/esm/bin.d.mts +3 -0
- package/node_modules/rimraf/dist/esm/bin.d.mts.map +1 -0
- package/node_modules/rimraf/dist/esm/bin.mjs +250 -0
- package/node_modules/rimraf/dist/esm/bin.mjs.map +1 -0
- package/node_modules/rimraf/dist/esm/default-tmp.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/default-tmp.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/default-tmp.js +55 -0
- package/node_modules/rimraf/dist/esm/default-tmp.js.map +1 -0
- package/node_modules/rimraf/dist/esm/error.d.ts +6 -0
- package/node_modules/rimraf/dist/esm/error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/error.js +5 -0
- package/node_modules/rimraf/dist/esm/error.js.map +1 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.js +33 -0
- package/node_modules/rimraf/dist/esm/fix-eperm.js.map +1 -0
- package/node_modules/rimraf/dist/esm/fs.d.ts +15 -0
- package/node_modules/rimraf/dist/esm/fs.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/fs.js +18 -0
- package/node_modules/rimraf/dist/esm/fs.js.map +1 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.js +19 -0
- package/node_modules/rimraf/dist/esm/ignore-enoent.js.map +1 -0
- package/node_modules/rimraf/dist/esm/index.d.ts +50 -0
- package/node_modules/rimraf/dist/esm/index.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/index.js +70 -0
- package/node_modules/rimraf/dist/esm/index.js.map +1 -0
- package/node_modules/rimraf/dist/esm/opt-arg.d.ts +34 -0
- package/node_modules/rimraf/dist/esm/opt-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/opt-arg.js +46 -0
- package/node_modules/rimraf/dist/esm/opt-arg.js.map +1 -0
- package/node_modules/rimraf/dist/esm/package.json +3 -0
- package/node_modules/rimraf/dist/esm/path-arg.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/path-arg.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/path-arg.js +46 -0
- package/node_modules/rimraf/dist/esm/path-arg.js.map +1 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.js +14 -0
- package/node_modules/rimraf/dist/esm/readdir-or-error.js.map +1 -0
- package/node_modules/rimraf/dist/esm/retry-busy.d.ts +8 -0
- package/node_modules/rimraf/dist/esm/retry-busy.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/retry-busy.js +60 -0
- package/node_modules/rimraf/dist/esm/retry-busy.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts +3 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.js +5 -0
- package/node_modules/rimraf/dist/esm/rimraf-manual.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.js +133 -0
- package/node_modules/rimraf/dist/esm/rimraf-move-remove.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.js +19 -0
- package/node_modules/rimraf/dist/esm/rimraf-native.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.js +98 -0
- package/node_modules/rimraf/dist/esm/rimraf-posix.js.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.js +154 -0
- package/node_modules/rimraf/dist/esm/rimraf-windows.js.map +1 -0
- package/node_modules/rimraf/dist/esm/use-native.d.ts +4 -0
- package/node_modules/rimraf/dist/esm/use-native.d.ts.map +1 -0
- package/node_modules/rimraf/dist/esm/use-native.js +15 -0
- package/node_modules/rimraf/dist/esm/use-native.js.map +1 -0
- package/node_modules/rimraf/package.json +92 -0
- package/package.json +152 -0
- package/scripts/install-scanners.js +258 -0
- package/scripts/watchdog.js +147 -0
- package/src/analyzers/CSSAnalyzer.js +297 -0
- package/src/analyzers/ConfigValidator.js +690 -0
- package/src/analyzers/ESLintAnalyzer.js +320 -0
- package/src/analyzers/JavaScriptAnalyzer.js +261 -0
- package/src/analyzers/PrettierFormatter.js +247 -0
- package/src/analyzers/PythonAnalyzer.js +283 -0
- package/src/analyzers/SecurityAnalyzer.js +729 -0
- package/src/analyzers/SparrowAnalyzer.js +341 -0
- package/src/analyzers/TypeScriptAnalyzer.js +247 -0
- package/src/analyzers/codeCloneDetector/analyzer.js +344 -0
- package/src/analyzers/codeCloneDetector/detector.js +250 -0
- package/src/analyzers/codeCloneDetector/index.js +192 -0
- package/src/analyzers/codeCloneDetector/parser.js +199 -0
- package/src/analyzers/codeCloneDetector/reporter.js +148 -0
- package/src/analyzers/codeCloneDetector/scanner.js +88 -0
- package/src/core/agentPool.js +1957 -0
- package/src/core/agentScheduler.js +3212 -0
- package/src/core/contextManager.js +709 -0
- package/src/core/flowExecutor.js +928 -0
- package/src/core/messageProcessor.js +808 -0
- package/src/core/orchestrator.js +584 -0
- package/src/core/stateManager.js +1500 -0
- package/src/index.js +972 -0
- package/src/interfaces/cli.js +553 -0
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +208 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +236 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +138 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +137 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +350 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +156 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +332 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +256 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +388 -0
- package/src/interfaces/terminal/api/apiClient.js +299 -0
- package/src/interfaces/terminal/api/messageRouter.js +262 -0
- package/src/interfaces/terminal/api/session.js +266 -0
- package/src/interfaces/terminal/api/websocket.js +497 -0
- package/src/interfaces/terminal/components/AgentCreator.js +705 -0
- package/src/interfaces/terminal/components/AgentEditor.js +678 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +330 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +92 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +264 -0
- package/src/interfaces/terminal/components/Header.js +28 -0
- package/src/interfaces/terminal/components/HelpPanel.js +231 -0
- package/src/interfaces/terminal/components/InputBox.js +118 -0
- package/src/interfaces/terminal/components/Layout.js +603 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +71 -0
- package/src/interfaces/terminal/components/MessageList.js +281 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +251 -0
- package/src/interfaces/terminal/components/SearchPanel.js +265 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +415 -0
- package/src/interfaces/terminal/components/StatusBar.js +65 -0
- package/src/interfaces/terminal/components/TextInput.js +127 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +227 -0
- package/src/interfaces/terminal/config/constants.js +393 -0
- package/src/interfaces/terminal/index.js +168 -0
- package/src/interfaces/terminal/state/useAgentControl.js +496 -0
- package/src/interfaces/terminal/state/useAgents.js +537 -0
- package/src/interfaces/terminal/state/useConnection.js +444 -0
- package/src/interfaces/terminal/state/useMessages.js +630 -0
- package/src/interfaces/terminal/state/useTools.js +554 -0
- package/src/interfaces/terminal/utils/debugLogger.js +44 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +232 -0
- package/src/interfaces/terminal/utils/theme.js +85 -0
- package/src/interfaces/webServer.js +5457 -0
- package/src/modules/fileExplorer/controller.js +413 -0
- package/src/modules/fileExplorer/index.js +37 -0
- package/src/modules/fileExplorer/middleware.js +92 -0
- package/src/modules/fileExplorer/routes.js +158 -0
- package/src/modules/fileExplorer/types.js +44 -0
- package/src/services/agentActivityService.js +399 -0
- package/src/services/aiService.js +2618 -0
- package/src/services/apiKeyManager.js +334 -0
- package/src/services/benchmarkService.js +196 -0
- package/src/services/budgetService.js +565 -0
- package/src/services/contextInjectionService.js +268 -0
- package/src/services/conversationCompactionService.js +1103 -0
- package/src/services/credentialVault.js +685 -0
- package/src/services/errorHandler.js +810 -0
- package/src/services/fileAttachmentService.js +547 -0
- package/src/services/flowContextService.js +189 -0
- package/src/services/memoryService.js +521 -0
- package/src/services/modelRouterService.js +365 -0
- package/src/services/modelsService.js +323 -0
- package/src/services/ollamaService.js +452 -0
- package/src/services/portRegistry.js +336 -0
- package/src/services/portTracker.js +223 -0
- package/src/services/projectDetector.js +404 -0
- package/src/services/promptService.js +372 -0
- package/src/services/qualityInspector.js +796 -0
- package/src/services/scheduleService.js +725 -0
- package/src/services/serviceRegistry.js +386 -0
- package/src/services/skillsService.js +486 -0
- package/src/services/telegramService.js +920 -0
- package/src/services/tokenCountingService.js +316 -0
- package/src/services/visualEditorBridge.js +1033 -0
- package/src/services/visualEditorServer.js +1727 -0
- package/src/services/whatsappService.js +663 -0
- package/src/tools/__tests__/webTool.e2e.test.js +569 -0
- package/src/tools/__tests__/webTool.unit.test.js +195 -0
- package/src/tools/agentCommunicationTool.js +1343 -0
- package/src/tools/agentDelayTool.js +498 -0
- package/src/tools/asyncToolManager.js +604 -0
- package/src/tools/baseTool.js +887 -0
- package/src/tools/browserTool.js +897 -0
- package/src/tools/cloneDetectionTool.js +581 -0
- package/src/tools/codeMapTool.js +857 -0
- package/src/tools/dependencyResolverTool.js +1212 -0
- package/src/tools/docxTool.js +623 -0
- package/src/tools/excelTool.js +636 -0
- package/src/tools/fileContentReplaceTool.js +840 -0
- package/src/tools/fileTreeTool.js +833 -0
- package/src/tools/filesystemTool.js +1217 -0
- package/src/tools/helpTool.js +198 -0
- package/src/tools/imageTool.js +1034 -0
- package/src/tools/importAnalyzerTool.js +1056 -0
- package/src/tools/jobDoneTool.js +388 -0
- package/src/tools/memoryTool.js +554 -0
- package/src/tools/pdfTool.js +627 -0
- package/src/tools/seekTool.js +883 -0
- package/src/tools/skillsTool.js +276 -0
- package/src/tools/staticAnalysisTool.js +2146 -0
- package/src/tools/taskManagerTool.js +2836 -0
- package/src/tools/terminalTool.js +2486 -0
- package/src/tools/userPromptTool.js +474 -0
- package/src/tools/videoTool.js +1139 -0
- package/src/tools/visionTool.js +507 -0
- package/src/tools/visualEditorTool.js +1175 -0
- package/src/tools/webTool.js +3114 -0
- package/src/tools/whatsappTool.js +457 -0
- package/src/types/agent.js +519 -0
- package/src/types/contextReference.js +972 -0
- package/src/types/conversation.js +730 -0
- package/src/types/toolCommand.js +747 -0
- package/src/utilities/attachmentValidator.js +288 -0
- package/src/utilities/browserStealth.js +630 -0
- package/src/utilities/configManager.js +618 -0
- package/src/utilities/constants.js +870 -0
- package/src/utilities/directoryAccessManager.js +566 -0
- package/src/utilities/fileProcessor.js +307 -0
- package/src/utilities/humanBehavior.js +453 -0
- package/src/utilities/jsonRepair.js +242 -0
- package/src/utilities/logger.js +436 -0
- package/src/utilities/platformUtils.js +255 -0
- package/src/utilities/platformUtils.test.js +98 -0
- package/src/utilities/stealthConstants.js +377 -0
- package/src/utilities/structuredFileValidator.js +699 -0
- package/src/utilities/tagParser.js +878 -0
- package/src/utilities/toolConstants.js +415 -0
- package/src/utilities/userDataDir.js +300 -0
- package/web-ui/build/brands/autopilot/favicon.svg +1 -0
- package/web-ui/build/brands/autopilot/logo.webp +0 -0
- package/web-ui/build/brands/onbuzz/favicon.svg +1 -0
- package/web-ui/build/brands/onbuzz/logo-text.webp +0 -0
- package/web-ui/build/brands/onbuzz/logo.webp +0 -0
- package/web-ui/build/index.html +15 -0
- package/web-ui/build/logo.png +0 -0
- package/web-ui/build/logo2.png +0 -0
- package/web-ui/build/static/index-SmQFfvBs.js +746 -0
- package/web-ui/build/static/index-V2ySwjHp.css +1 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TagParser - Utility for parsing JSON tool commands
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* - Parse JSON tool commands from agent messages (LLM industry standard)
|
|
6
|
+
* - Extract parameters from JSON format
|
|
7
|
+
* - Agent redirect parsing
|
|
8
|
+
*
|
|
9
|
+
* Supported format:
|
|
10
|
+
* - JSON code blocks: ```json {"toolId": "...", "parameters": {...}} ```
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
AGENT_REDIRECT_ATTRIBUTES
|
|
15
|
+
} from './constants.js';
|
|
16
|
+
import {
|
|
17
|
+
TOOL_IDS,
|
|
18
|
+
COMMAND_FORMATS,
|
|
19
|
+
JSON_STRUCTURES,
|
|
20
|
+
identifyJsonStructure,
|
|
21
|
+
getToolIdFromAction,
|
|
22
|
+
isValidToolId
|
|
23
|
+
} from './toolConstants.js';
|
|
24
|
+
import { parseJSONWithRepair, looksLikeTruncatedJSON } from './jsonRepair.js';
|
|
25
|
+
|
|
26
|
+
class TagParser {
|
|
27
|
+
constructor() {
|
|
28
|
+
// Tag parsing patterns - JSON only (industry standard)
|
|
29
|
+
this.patterns = {
|
|
30
|
+
attribute: /([\w-]+)=["']([^"']*)["']/g,
|
|
31
|
+
agentRedirect: /\[agent-redirect\s+([^\]]*)\](.*?)\[\/agent-redirect\]/gs,
|
|
32
|
+
jsonBlock: /```json\s*(\{[\s\S]*?\})\s*```/g,
|
|
33
|
+
// Also match plain JSON objects on their own line(s) as fallback
|
|
34
|
+
plainJson: /^(\{(?:[^{}]|(?:\{[^{}]*\}))*\})$/gm
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Decode HTML entities that might be present in tool content
|
|
40
|
+
* @param {string} text - Text that might contain HTML entities
|
|
41
|
+
* @returns {string} Decoded text
|
|
42
|
+
*/
|
|
43
|
+
decodeHtmlEntities(text) {
|
|
44
|
+
const entityMap = {
|
|
45
|
+
'<': '<',
|
|
46
|
+
'>': '>',
|
|
47
|
+
'&': '&',
|
|
48
|
+
'"': '"',
|
|
49
|
+
''': "'",
|
|
50
|
+
'/': '/',
|
|
51
|
+
''': "'",
|
|
52
|
+
'/': '/'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return text.replace(/&(?:lt|gt|amp|quot|#x27|#x2F|#39|#47);/g, match => entityMap[match] || match);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Extract tool commands from message content (JSON format only)
|
|
60
|
+
* @param {string} content - Message content to parse
|
|
61
|
+
* @returns {Array} Array of parsed tool commands
|
|
62
|
+
*/
|
|
63
|
+
extractToolCommands(content) {
|
|
64
|
+
const commands = [];
|
|
65
|
+
|
|
66
|
+
// Decode HTML entities that might be present in the content
|
|
67
|
+
const decodedContent = this.decodeHtmlEntities(content);
|
|
68
|
+
|
|
69
|
+
// PHASE 1: Extract JSON code blocks (LLM industry standard format)
|
|
70
|
+
// Format: ```json {"toolId": "...", "parameters": {...}} ```
|
|
71
|
+
const jsonCodeBlockCommands = this.extractJSONCodeBlocks(decodedContent);
|
|
72
|
+
commands.push(...jsonCodeBlockCommands);
|
|
73
|
+
|
|
74
|
+
// PHASE 2: Sanitize content by removing already-extracted JSON blocks
|
|
75
|
+
// This prevents duplicate extraction
|
|
76
|
+
const sanitizedContent = this.removeJsonBlocks(decodedContent);
|
|
77
|
+
|
|
78
|
+
// PHASE 3: Extract plain JSON (fallback for agents that don't use code blocks)
|
|
79
|
+
// This should rarely find anything if agents follow the ```json block convention
|
|
80
|
+
const plainJsonCommands = this.extractPlainJSON(sanitizedContent);
|
|
81
|
+
commands.push(...plainJsonCommands);
|
|
82
|
+
|
|
83
|
+
return commands;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Extract top-level parameters from JSON data (excluding toolId)
|
|
88
|
+
* Used as fallback when JSON doesn't use standard parameters/actions/files wrappers
|
|
89
|
+
* @param {Object} jsonData - JSON data to extract from
|
|
90
|
+
* @returns {Object} Extracted parameters
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
_extractTopLevelParams(jsonData) {
|
|
94
|
+
const params = {};
|
|
95
|
+
for (const [key, value] of Object.entries(jsonData)) {
|
|
96
|
+
// Skip the tool identifier keys
|
|
97
|
+
if (key !== 'toolId' && key !== 'tool') {
|
|
98
|
+
params[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return params;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Remove JSON code blocks from content to prevent duplicate extraction
|
|
106
|
+
* @param {string} content - Content to sanitize
|
|
107
|
+
* @returns {string} Content with JSON code blocks removed
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
removeJsonBlocks(content) {
|
|
111
|
+
let sanitized = content;
|
|
112
|
+
let position = 0;
|
|
113
|
+
|
|
114
|
+
while (position < sanitized.length) {
|
|
115
|
+
const startMarker = '```json';
|
|
116
|
+
const endMarker = '```';
|
|
117
|
+
|
|
118
|
+
const startIndex = sanitized.indexOf(startMarker, position);
|
|
119
|
+
if (startIndex === -1) break;
|
|
120
|
+
|
|
121
|
+
const contentStart = startIndex + startMarker.length;
|
|
122
|
+
const endIndex = sanitized.indexOf(endMarker, contentStart);
|
|
123
|
+
if (endIndex === -1) break;
|
|
124
|
+
|
|
125
|
+
// Replace JSON code block with placeholder
|
|
126
|
+
const before = sanitized.substring(0, startIndex);
|
|
127
|
+
const after = sanitized.substring(endIndex + endMarker.length);
|
|
128
|
+
sanitized = before + '[JSON_BLOCK_REMOVED]' + after;
|
|
129
|
+
|
|
130
|
+
position = startIndex + '[JSON_BLOCK_REMOVED]'.length;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return sanitized;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Extract JSON from markdown code blocks using string functions
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
extractJSONCodeBlocks(content) {
|
|
141
|
+
const commands = [];
|
|
142
|
+
let searchIndex = 0;
|
|
143
|
+
|
|
144
|
+
while (true) {
|
|
145
|
+
// Find opening marker
|
|
146
|
+
const startMarker = '```json';
|
|
147
|
+
const endMarker = '```';
|
|
148
|
+
|
|
149
|
+
const startIndex = content.indexOf(startMarker, searchIndex);
|
|
150
|
+
if (startIndex === -1) break;
|
|
151
|
+
|
|
152
|
+
// Find closing marker - MUST find the MATCHING one, not nested ones
|
|
153
|
+
const contentStart = startIndex + startMarker.length;
|
|
154
|
+
const endIndex = this._findMatchingCodeBlockEnd(content, contentStart);
|
|
155
|
+
if (endIndex === -1) break;
|
|
156
|
+
|
|
157
|
+
// Extract JSON content
|
|
158
|
+
const jsonString = content.substring(contentStart, endIndex).trim();
|
|
159
|
+
|
|
160
|
+
// Use repair-capable JSON parser to handle truncated responses
|
|
161
|
+
const parseResult = parseJSONWithRepair(jsonString, { silent: false });
|
|
162
|
+
|
|
163
|
+
if (parseResult.error) {
|
|
164
|
+
// Even repair failed - skip this block
|
|
165
|
+
console.log('TagParser DEBUG: JSON parse failed even with repair:', parseResult.error);
|
|
166
|
+
searchIndex = endIndex + endMarker.length;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const jsonData = parseResult.data;
|
|
171
|
+
const wasRepaired = parseResult.wasRepaired;
|
|
172
|
+
const wasTruncated = parseResult.wasTruncated;
|
|
173
|
+
|
|
174
|
+
if (wasRepaired) {
|
|
175
|
+
console.log('TagParser DEBUG: JSON was repaired', {
|
|
176
|
+
wasTruncated,
|
|
177
|
+
originalLength: jsonString.length,
|
|
178
|
+
repairedLength: parseResult.repaired?.length
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (this.isToolCommandJSON(jsonData)) {
|
|
183
|
+
// ARCHITECTURAL PRINCIPLE: Use OUTER layer (toolId) for tool identification
|
|
184
|
+
const toolId = jsonData.toolId || jsonData.tool;
|
|
185
|
+
|
|
186
|
+
// Skip if no explicit outer tool identifier
|
|
187
|
+
if (!toolId || toolId === 'unknown') {
|
|
188
|
+
console.log('TagParser DEBUG: Skipping JSON block - missing explicit toolId');
|
|
189
|
+
searchIndex = endIndex + endMarker.length;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Extract parameters from JSON:
|
|
194
|
+
// - If 'parameters' wrapper exists, use it (standard format)
|
|
195
|
+
// - Otherwise, extract ALL top-level properties (operation, headless, actions, files, etc.)
|
|
196
|
+
// This ensures tools like 'web' receive operation alongside actions
|
|
197
|
+
let extractedParams;
|
|
198
|
+
if (jsonData.parameters) {
|
|
199
|
+
extractedParams = jsonData.parameters;
|
|
200
|
+
} else {
|
|
201
|
+
// Extract all top-level params (excluding toolId) - includes operation, headless, actions, files, etc.
|
|
202
|
+
extractedParams = this._extractTopLevelParams(jsonData);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const command = {
|
|
206
|
+
type: COMMAND_FORMATS.JSON,
|
|
207
|
+
toolId: toolId,
|
|
208
|
+
parameters: extractedParams,
|
|
209
|
+
actions: jsonData.actions,
|
|
210
|
+
rawContent: content.substring(startIndex, endIndex + endMarker.length),
|
|
211
|
+
jsonData,
|
|
212
|
+
// Mark if this was repaired/truncated for tool to handle appropriately
|
|
213
|
+
wasRepaired,
|
|
214
|
+
wasTruncated
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
commands.push(command);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Handle toolCommands array format
|
|
221
|
+
if (jsonData.toolCommands && Array.isArray(jsonData.toolCommands)) {
|
|
222
|
+
for (const toolCommand of jsonData.toolCommands) {
|
|
223
|
+
if (this.isToolCommandJSON(toolCommand)) {
|
|
224
|
+
// ARCHITECTURAL PRINCIPLE: Use OUTER layer (toolId) for tool identification
|
|
225
|
+
const toolId = toolCommand.toolId || toolCommand.tool;
|
|
226
|
+
|
|
227
|
+
// Skip if no explicit outer tool identifier
|
|
228
|
+
if (!toolId || toolId === 'unknown') {
|
|
229
|
+
console.log('TagParser DEBUG: Skipping toolCommand - missing explicit toolId');
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Extract parameters using same logic as single commands
|
|
234
|
+
let cmdParams;
|
|
235
|
+
if (toolCommand.parameters) {
|
|
236
|
+
cmdParams = toolCommand.parameters;
|
|
237
|
+
} else {
|
|
238
|
+
// Extract all top-level params (operation, headless, actions, files, etc.)
|
|
239
|
+
cmdParams = this._extractTopLevelParams(toolCommand);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const command = {
|
|
243
|
+
type: COMMAND_FORMATS.JSON,
|
|
244
|
+
toolId: toolId,
|
|
245
|
+
parameters: cmdParams,
|
|
246
|
+
actions: toolCommand.actions,
|
|
247
|
+
rawContent: JSON.stringify(toolCommand, null, 2),
|
|
248
|
+
jsonData: toolCommand,
|
|
249
|
+
wasRepaired,
|
|
250
|
+
wasTruncated
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
commands.push(command);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
searchIndex = endIndex + endMarker.length;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return commands;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Extract plain JSON objects using string functions
|
|
266
|
+
* @private
|
|
267
|
+
*/
|
|
268
|
+
extractPlainJSON(content) {
|
|
269
|
+
const commands = [];
|
|
270
|
+
const lines = content.split('\n');
|
|
271
|
+
|
|
272
|
+
for (let i = 0; i < lines.length; i++) {
|
|
273
|
+
const line = lines[i].trim();
|
|
274
|
+
|
|
275
|
+
// Skip if line doesn't start with {
|
|
276
|
+
if (!line.startsWith('{')) continue;
|
|
277
|
+
|
|
278
|
+
// Try to find complete JSON object
|
|
279
|
+
let jsonString = '';
|
|
280
|
+
let braceCount = 0;
|
|
281
|
+
let foundComplete = false;
|
|
282
|
+
|
|
283
|
+
// Start from current line and look for complete JSON
|
|
284
|
+
for (let j = i; j < lines.length; j++) {
|
|
285
|
+
const currentLine = lines[j].trim();
|
|
286
|
+
jsonString += (j > i ? '\n' : '') + currentLine;
|
|
287
|
+
|
|
288
|
+
// Count braces to find complete object
|
|
289
|
+
for (const char of currentLine) {
|
|
290
|
+
if (char === '{') braceCount++;
|
|
291
|
+
if (char === '}') braceCount--;
|
|
292
|
+
if (braceCount === 0 && char === '}') {
|
|
293
|
+
foundComplete = true;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (foundComplete) break;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (!foundComplete) continue;
|
|
302
|
+
|
|
303
|
+
// Use repair-capable JSON parser
|
|
304
|
+
const parseResult = parseJSONWithRepair(jsonString, { silent: true });
|
|
305
|
+
|
|
306
|
+
if (parseResult.error) {
|
|
307
|
+
// Even repair failed - skip
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const jsonData = parseResult.data;
|
|
312
|
+
const wasRepaired = parseResult.wasRepaired;
|
|
313
|
+
const wasTruncated = parseResult.wasTruncated;
|
|
314
|
+
|
|
315
|
+
// ARCHITECTURAL PRINCIPLE: Use OUTER layer for tool identification
|
|
316
|
+
// Only parse INNER content (actions, type) if OUTER identifier missing
|
|
317
|
+
// This follows the layered invocation hierarchy:
|
|
318
|
+
// OUTER (message level): Tool identification via "toolId"
|
|
319
|
+
// INNER (payload level): Action specification via "type"
|
|
320
|
+
|
|
321
|
+
// Check if this JSON looks like a tool command
|
|
322
|
+
if (this.isToolCommandJSON(jsonData) ||
|
|
323
|
+
(jsonData.actions && Array.isArray(jsonData.actions)) ||
|
|
324
|
+
(jsonData.type && typeof jsonData.type === 'string')) {
|
|
325
|
+
|
|
326
|
+
// CRITICAL: Use OUTER identifier first, only infer from INNER as fallback
|
|
327
|
+
const toolId = jsonData.toolId || jsonData.tool || this.inferToolFromActions(jsonData);
|
|
328
|
+
|
|
329
|
+
// Skip if we couldn't determine a valid tool
|
|
330
|
+
if (!toolId || toolId === 'unknown') {
|
|
331
|
+
console.log('TagParser DEBUG: Skipping plain JSON - could not determine valid toolId');
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const command = {
|
|
336
|
+
type: COMMAND_FORMATS.JSON_PLAIN,
|
|
337
|
+
toolId: toolId,
|
|
338
|
+
// Use parameters if wrapped, otherwise extract all top-level params (excluding toolId)
|
|
339
|
+
parameters: jsonData.parameters || this._extractTopLevelParams(jsonData),
|
|
340
|
+
actions: jsonData.actions,
|
|
341
|
+
rawContent: jsonString,
|
|
342
|
+
jsonData,
|
|
343
|
+
warning: 'Plain JSON detected - should use ```json blocks',
|
|
344
|
+
wasRepaired,
|
|
345
|
+
wasTruncated
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
commands.push(command);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return commands;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Infer tool ID from JSON structure
|
|
357
|
+
* Uses the constants-based approach for deterministic tool identification
|
|
358
|
+
* @private
|
|
359
|
+
*/
|
|
360
|
+
inferToolFromActions(jsonData) {
|
|
361
|
+
const structure = identifyJsonStructure(jsonData);
|
|
362
|
+
|
|
363
|
+
switch (structure) {
|
|
364
|
+
case JSON_STRUCTURES.STANDARD:
|
|
365
|
+
// Already has toolId
|
|
366
|
+
return jsonData.toolId || 'unknown';
|
|
367
|
+
|
|
368
|
+
case JSON_STRUCTURES.ACTIONS_ARRAY:
|
|
369
|
+
// Get tool from first action type
|
|
370
|
+
if (jsonData.actions && jsonData.actions.length > 0) {
|
|
371
|
+
const firstAction = jsonData.actions[0];
|
|
372
|
+
const toolId = getToolIdFromAction(firstAction.type);
|
|
373
|
+
return toolId || 'unknown';
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
|
|
377
|
+
case JSON_STRUCTURES.DIRECT_ACTION:
|
|
378
|
+
// Get tool from type field
|
|
379
|
+
const toolId = getToolIdFromAction(jsonData.type);
|
|
380
|
+
return toolId || 'unknown';
|
|
381
|
+
|
|
382
|
+
case JSON_STRUCTURES.TOOL_COMMANDS:
|
|
383
|
+
// Get from first command
|
|
384
|
+
if (jsonData.toolCommands && jsonData.toolCommands.length > 0) {
|
|
385
|
+
return this.inferToolFromActions(jsonData.toolCommands[0]);
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return 'unknown';
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Extract agent redirects from content
|
|
395
|
+
* @param {string} content - Content to parse
|
|
396
|
+
* @returns {Array} Array of parsed agent redirects
|
|
397
|
+
*/
|
|
398
|
+
extractAgentRedirects(content) {
|
|
399
|
+
const redirects = [];
|
|
400
|
+
|
|
401
|
+
const matches = this.matchAll(content, this.patterns.agentRedirect);
|
|
402
|
+
|
|
403
|
+
for (const match of matches) {
|
|
404
|
+
const attributeString = match.groups[1];
|
|
405
|
+
const messageContent = match.groups[2].trim();
|
|
406
|
+
|
|
407
|
+
const attributes = this.parseAttributes(attributeString);
|
|
408
|
+
|
|
409
|
+
const redirect = {
|
|
410
|
+
to: attributes.to,
|
|
411
|
+
content: messageContent,
|
|
412
|
+
urgent: attributes[AGENT_REDIRECT_ATTRIBUTES.URGENT] === 'true',
|
|
413
|
+
requiresResponse: attributes[AGENT_REDIRECT_ATTRIBUTES.REQUIRES_RESPONSE] === 'true',
|
|
414
|
+
context: attributes[AGENT_REDIRECT_ATTRIBUTES.CONTEXT],
|
|
415
|
+
rawMatch: match.match
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// Add any additional attributes
|
|
419
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
420
|
+
if (!['to', AGENT_REDIRECT_ATTRIBUTES.URGENT, AGENT_REDIRECT_ATTRIBUTES.REQUIRES_RESPONSE, AGENT_REDIRECT_ATTRIBUTES.CONTEXT].includes(key)) {
|
|
421
|
+
redirect[key] = value;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
redirects.push(redirect);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return redirects;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Parse XML parameters from tool content
|
|
433
|
+
* @param {string} content - Tool content to parse
|
|
434
|
+
* @returns {Object} Parsed parameters
|
|
435
|
+
*/
|
|
436
|
+
parseXMLParameters(content) {
|
|
437
|
+
const parameters = {};
|
|
438
|
+
|
|
439
|
+
console.log('TagParser DEBUG: parseXMLParameters - content length:', content.length);
|
|
440
|
+
|
|
441
|
+
let position = 0;
|
|
442
|
+
let foundCount = 0;
|
|
443
|
+
|
|
444
|
+
// Look for opening tags like <write>, <read>, etc.
|
|
445
|
+
while (position < content.length) {
|
|
446
|
+
const openTagStart = content.indexOf('<', position);
|
|
447
|
+
if (openTagStart === -1) break;
|
|
448
|
+
|
|
449
|
+
const openTagEnd = content.indexOf('>', openTagStart);
|
|
450
|
+
if (openTagEnd === -1) break;
|
|
451
|
+
|
|
452
|
+
// Extract the full opening tag
|
|
453
|
+
const openTag = content.substring(openTagStart, openTagEnd + 1);
|
|
454
|
+
|
|
455
|
+
// Parse tag name and attributes from the opening tag
|
|
456
|
+
const spaceIndex = openTag.indexOf(' ');
|
|
457
|
+
const tagName = spaceIndex > 0
|
|
458
|
+
? openTag.substring(1, spaceIndex)
|
|
459
|
+
: openTag.substring(1, openTag.length - 1);
|
|
460
|
+
|
|
461
|
+
const isValid = this.isValidXmlTagName(tagName);
|
|
462
|
+
|
|
463
|
+
// Skip malformed tags or content that looks like code
|
|
464
|
+
if (tagName.includes('/') || !tagName || !this.isValidXmlTagName(tagName)) {
|
|
465
|
+
position = openTagEnd + 1;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Check if this is a self-closing tag (ends with />)
|
|
470
|
+
const isSelfClosing = openTag.endsWith('/>');
|
|
471
|
+
|
|
472
|
+
let tagContent = '';
|
|
473
|
+
let closingTagStart = openTagEnd;
|
|
474
|
+
|
|
475
|
+
if (isSelfClosing) {
|
|
476
|
+
// Self-closing tag has no content
|
|
477
|
+
tagContent = '';
|
|
478
|
+
closingTagStart = openTagEnd; // Position right after the self-closing tag
|
|
479
|
+
} else {
|
|
480
|
+
// Look for the closing tag
|
|
481
|
+
const closingTag = `</${tagName}>`;
|
|
482
|
+
closingTagStart = content.indexOf(closingTag, openTagEnd + 1);
|
|
483
|
+
|
|
484
|
+
if (closingTagStart === -1) {
|
|
485
|
+
position = openTagEnd + 1;
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Extract the content between tags
|
|
490
|
+
tagContent = content.substring(openTagEnd + 1, closingTagStart);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Extract attributes from the opening tag
|
|
494
|
+
let attributeString = spaceIndex > 0
|
|
495
|
+
? openTag.substring(spaceIndex + 1, openTag.length - 1).trim()
|
|
496
|
+
: '';
|
|
497
|
+
|
|
498
|
+
// For self-closing tags, remove the trailing '/' from attributes
|
|
499
|
+
if (isSelfClosing && attributeString.endsWith('/')) {
|
|
500
|
+
attributeString = attributeString.substring(0, attributeString.length - 1).trim();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const attributes = this.parseAttributes(attributeString);
|
|
504
|
+
|
|
505
|
+
console.log('TagParser DEBUG: parseXMLParameters - found match:', {
|
|
506
|
+
paramName: tagName,
|
|
507
|
+
attributeString,
|
|
508
|
+
valueLength: tagContent.length,
|
|
509
|
+
valuePreview: tagContent.substring(0, 50) + (tagContent.length > 50 ? '...' : '')
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// CRITICAL FIX: Handle multiple tags with same name (e.g., multiple <write> tags)
|
|
513
|
+
// Convert to array if duplicate detected
|
|
514
|
+
const paramValue = {
|
|
515
|
+
value: tagContent.trim(),
|
|
516
|
+
attributes
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
if (parameters[tagName]) {
|
|
520
|
+
// Tag already exists - convert to array or append to existing array
|
|
521
|
+
if (Array.isArray(parameters[tagName])) {
|
|
522
|
+
// Already an array, append
|
|
523
|
+
parameters[tagName].push(paramValue);
|
|
524
|
+
console.log('TagParser DEBUG: appended to existing array for tag:', tagName, 'count:', parameters[tagName].length);
|
|
525
|
+
} else {
|
|
526
|
+
// First duplicate - convert to array
|
|
527
|
+
const existingValue = parameters[tagName];
|
|
528
|
+
parameters[tagName] = [existingValue, paramValue];
|
|
529
|
+
console.log('TagParser DEBUG: converted to array for duplicate tag:', tagName);
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
// First occurrence - store as single object
|
|
533
|
+
parameters[tagName] = paramValue;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// For convenience, also store direct access to value (deprecated, kept for backward compatibility)
|
|
537
|
+
// Only define if it doesn't exist (handles multiple tags with same name)
|
|
538
|
+
const valuePropertyName = tagName + '_value';
|
|
539
|
+
if (!Object.prototype.hasOwnProperty.call(parameters, valuePropertyName)) {
|
|
540
|
+
Object.defineProperty(parameters, valuePropertyName, {
|
|
541
|
+
value: tagContent.trim(),
|
|
542
|
+
enumerable: false
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
foundCount++;
|
|
547
|
+
|
|
548
|
+
// Update position based on whether it's self-closing or paired tags
|
|
549
|
+
if (isSelfClosing) {
|
|
550
|
+
position = openTagEnd + 1;
|
|
551
|
+
} else {
|
|
552
|
+
const closingTag = `</${tagName}>`;
|
|
553
|
+
position = closingTagStart + closingTag.length;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
console.log('TagParser DEBUG: parseXMLParameters - matches found:', foundCount);
|
|
558
|
+
console.log('TagParser DEBUG: parseXMLParameters - final parameters:', Object.keys(parameters));
|
|
559
|
+
return parameters;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Parse attributes from attribute string
|
|
564
|
+
* @param {string} attributeString - Attribute string to parse
|
|
565
|
+
* @returns {Object} Parsed attributes
|
|
566
|
+
*/
|
|
567
|
+
parseAttributes(attributeString) {
|
|
568
|
+
const attributes = {};
|
|
569
|
+
|
|
570
|
+
if (!attributeString) return attributes;
|
|
571
|
+
|
|
572
|
+
const attrMatches = this.matchAll(attributeString, this.patterns.attribute);
|
|
573
|
+
|
|
574
|
+
for (const match of attrMatches) {
|
|
575
|
+
const attrName = match.groups[0];
|
|
576
|
+
const attrValue = match.groups[1];
|
|
577
|
+
|
|
578
|
+
attributes[attrName] = attrValue;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return attributes;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Extract content from tags
|
|
586
|
+
* @param {string} content - Content to search
|
|
587
|
+
* @param {string} tagName - Tag name to extract
|
|
588
|
+
* @returns {Array} Array of extracted content strings
|
|
589
|
+
*/
|
|
590
|
+
static extractContent(content, tagName) {
|
|
591
|
+
const pattern = new RegExp(`<${tagName}[^>]*>([^<]*)<\\/${tagName}>`, 'g');
|
|
592
|
+
const matches = [];
|
|
593
|
+
let match;
|
|
594
|
+
|
|
595
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
596
|
+
matches.push(match[1].trim());
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return matches;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Extract tag with attributes
|
|
604
|
+
* @param {string} content - Content to search
|
|
605
|
+
* @param {string} tagName - Tag name to extract
|
|
606
|
+
* @returns {Array} Array of extracted tag objects with content and attributes
|
|
607
|
+
*/
|
|
608
|
+
static extractTagsWithAttributes(content, tagName) {
|
|
609
|
+
const pattern = new RegExp(`<${tagName}\\s*([^>]*)>([^<]*)<\\/${tagName}>`, 'g');
|
|
610
|
+
const tags = [];
|
|
611
|
+
let match;
|
|
612
|
+
|
|
613
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
614
|
+
const attributeString = match[1];
|
|
615
|
+
const tagContent = match[2].trim();
|
|
616
|
+
|
|
617
|
+
const parser = new TagParser();
|
|
618
|
+
const attributes = parser.parseAttributes(attributeString);
|
|
619
|
+
|
|
620
|
+
tags.push({
|
|
621
|
+
content: tagContent,
|
|
622
|
+
attributes,
|
|
623
|
+
rawMatch: match[0]
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return tags;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Check if JSON object represents a tool command
|
|
632
|
+
* @private
|
|
633
|
+
*/
|
|
634
|
+
isToolCommandJSON(obj) {
|
|
635
|
+
return obj &&
|
|
636
|
+
typeof obj === 'object' &&
|
|
637
|
+
(obj.toolId || obj.tool) &&
|
|
638
|
+
(obj.parameters || obj.actions || obj.files || this._hasToolParams(obj));
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Check if object has any tool-related parameters (excluding toolId/tool)
|
|
643
|
+
* @private
|
|
644
|
+
*/
|
|
645
|
+
_hasToolParams(obj) {
|
|
646
|
+
if (!obj || typeof obj !== 'object') return false;
|
|
647
|
+
const keys = Object.keys(obj);
|
|
648
|
+
// Has more than just toolId/tool
|
|
649
|
+
return keys.some(k => k !== 'toolId' && k !== 'tool');
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Match all occurrences of a pattern
|
|
654
|
+
* @private
|
|
655
|
+
*/
|
|
656
|
+
matchAll(content, pattern) {
|
|
657
|
+
const matches = [];
|
|
658
|
+
let match;
|
|
659
|
+
|
|
660
|
+
// Reset pattern lastIndex to ensure clean matching
|
|
661
|
+
pattern.lastIndex = 0;
|
|
662
|
+
|
|
663
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
664
|
+
matches.push({
|
|
665
|
+
match: match[0],
|
|
666
|
+
groups: match.slice(1),
|
|
667
|
+
index: match.index
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return matches;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Validate tool command structure (JSON format)
|
|
676
|
+
* @param {Object} command - Tool command to validate
|
|
677
|
+
* @returns {Object} Validation result
|
|
678
|
+
*/
|
|
679
|
+
validateToolCommand(command) {
|
|
680
|
+
const errors = [];
|
|
681
|
+
|
|
682
|
+
if (!command.toolId) {
|
|
683
|
+
errors.push('Missing toolId');
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (!command.parameters && !command.actions) {
|
|
687
|
+
errors.push('Missing parameters or actions');
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (command.type === COMMAND_FORMATS.JSON || command.type === COMMAND_FORMATS.JSON_PLAIN) {
|
|
691
|
+
if (!command.jsonData) {
|
|
692
|
+
errors.push('Missing jsonData for JSON command');
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return {
|
|
697
|
+
valid: errors.length === 0,
|
|
698
|
+
errors
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Normalize tool command to consistent format (JSON only)
|
|
704
|
+
* @param {Object} command - Tool command to normalize
|
|
705
|
+
* @returns {Object} Normalized command
|
|
706
|
+
*/
|
|
707
|
+
normalizeToolCommand(command) {
|
|
708
|
+
const normalized = {
|
|
709
|
+
toolId: command.toolId,
|
|
710
|
+
type: command.type,
|
|
711
|
+
parameters: {},
|
|
712
|
+
rawContent: command.rawContent
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// JSON parameters are already in simple format
|
|
716
|
+
normalized.parameters = { ...command.parameters };
|
|
717
|
+
|
|
718
|
+
// Handle actions array format (common in agentcommunication tool)
|
|
719
|
+
if (command.actions && Array.isArray(command.actions)) {
|
|
720
|
+
normalized.parameters.actions = command.actions;
|
|
721
|
+
|
|
722
|
+
// For agentcommunication tool, extract the action from the first item
|
|
723
|
+
if (command.toolId === TOOL_IDS.AGENT_COMMUNICATION && command.actions.length > 0) {
|
|
724
|
+
const firstAction = command.actions[0];
|
|
725
|
+
normalized.parameters.action = firstAction.type || firstAction.action;
|
|
726
|
+
// Spread the rest of the action properties
|
|
727
|
+
Object.assign(normalized.parameters, firstAction);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
return normalized;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Find the matching closing ``` for a code block, handling nested code blocks
|
|
736
|
+
*
|
|
737
|
+
* The challenge: JSON content may contain embedded ``` markers (e.g., README with bash examples)
|
|
738
|
+
* We need to find the ``` that closes our JSON block, not a nested one inside the content.
|
|
739
|
+
*
|
|
740
|
+
* Strategy: Parse character by character, tracking if we're inside a JSON string.
|
|
741
|
+
* When inside a string, ``` is just content. When outside strings, ``` closes the block.
|
|
742
|
+
*
|
|
743
|
+
* @param {string} content - Full content to search
|
|
744
|
+
* @param {number} startPos - Position after the opening ```json marker
|
|
745
|
+
* @returns {number} Position of the closing ```, or -1 if not found
|
|
746
|
+
* @private
|
|
747
|
+
*/
|
|
748
|
+
_findMatchingCodeBlockEnd(content, startPos) {
|
|
749
|
+
let pos = startPos;
|
|
750
|
+
let inString = false;
|
|
751
|
+
let escaped = false;
|
|
752
|
+
|
|
753
|
+
while (pos < content.length) {
|
|
754
|
+
const char = content[pos];
|
|
755
|
+
|
|
756
|
+
// Handle escape sequences inside strings
|
|
757
|
+
if (escaped) {
|
|
758
|
+
escaped = false;
|
|
759
|
+
pos++;
|
|
760
|
+
continue;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
if (char === '\\' && inString) {
|
|
764
|
+
escaped = true;
|
|
765
|
+
pos++;
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Track string boundaries
|
|
770
|
+
if (char === '"') {
|
|
771
|
+
inString = !inString;
|
|
772
|
+
pos++;
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// Only look for ``` when we're outside of JSON strings
|
|
777
|
+
if (!inString && content.substring(pos, pos + 3) === '```') {
|
|
778
|
+
// Check this is the end marker (not another opening like ```bash)
|
|
779
|
+
// The closing ``` should be followed by newline, EOF, or just whitespace
|
|
780
|
+
const afterMarker = content.substring(pos + 3, pos + 20);
|
|
781
|
+
const isClosingMarker = !afterMarker.match(/^[a-zA-Z]/); // Not followed by language name
|
|
782
|
+
|
|
783
|
+
if (isClosingMarker) {
|
|
784
|
+
return pos;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
pos++;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// Fallback: if we couldn't find it with state tracking,
|
|
792
|
+
// try to find the last ``` in the content (less accurate but better than nothing)
|
|
793
|
+
const lastBackticks = content.lastIndexOf('```', content.length);
|
|
794
|
+
if (lastBackticks > startPos) {
|
|
795
|
+
console.warn('[TagParser] Used fallback method to find closing code block');
|
|
796
|
+
return lastBackticks;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
return -1;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Convert kebab-case or snake_case to camelCase
|
|
804
|
+
* @private
|
|
805
|
+
*/
|
|
806
|
+
_toCamelCase(str) {
|
|
807
|
+
return str.replace(/[-_](.)/g, (_, char) => char.toUpperCase());
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Extract all content between tags, including nested tags
|
|
812
|
+
* @param {string} content - Content to search
|
|
813
|
+
* @param {string} startTag - Opening tag
|
|
814
|
+
* @param {string} endTag - Closing tag
|
|
815
|
+
* @returns {Array} Array of extracted content blocks
|
|
816
|
+
*/
|
|
817
|
+
static extractBetweenTags(content, startTag, endTag) {
|
|
818
|
+
const blocks = [];
|
|
819
|
+
let startIndex = 0;
|
|
820
|
+
|
|
821
|
+
while (true) {
|
|
822
|
+
const start = content.indexOf(startTag, startIndex);
|
|
823
|
+
if (start === -1) break;
|
|
824
|
+
|
|
825
|
+
const end = content.indexOf(endTag, start + startTag.length);
|
|
826
|
+
if (end === -1) break;
|
|
827
|
+
|
|
828
|
+
const blockContent = content.substring(start + startTag.length, end);
|
|
829
|
+
blocks.push({
|
|
830
|
+
content: blockContent,
|
|
831
|
+
fullMatch: content.substring(start, end + endTag.length),
|
|
832
|
+
startIndex: start,
|
|
833
|
+
endIndex: end + endTag.length
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
startIndex = end + endTag.length;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
return blocks;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Clean content by removing all tool commands and agent redirects
|
|
844
|
+
* @param {string} content - Content to clean
|
|
845
|
+
* @returns {string} Cleaned content
|
|
846
|
+
*/
|
|
847
|
+
cleanContent(content) {
|
|
848
|
+
let cleaned = content;
|
|
849
|
+
|
|
850
|
+
// Remove tool command blocks
|
|
851
|
+
cleaned = cleaned.replace(this.patterns.toolCommand, '');
|
|
852
|
+
|
|
853
|
+
// Remove agent redirects
|
|
854
|
+
cleaned = cleaned.replace(this.patterns.agentRedirect, '');
|
|
855
|
+
|
|
856
|
+
// Remove JSON tool command blocks
|
|
857
|
+
cleaned = cleaned.replace(this.patterns.jsonBlock, (match, jsonContent) => {
|
|
858
|
+
try {
|
|
859
|
+
const jsonData = JSON.parse(jsonContent);
|
|
860
|
+
if (this.isToolCommandJSON(jsonData) ||
|
|
861
|
+
(jsonData.toolCommands && Array.isArray(jsonData.toolCommands))) {
|
|
862
|
+
return '';
|
|
863
|
+
}
|
|
864
|
+
} catch {
|
|
865
|
+
// Not a tool command JSON block, keep it
|
|
866
|
+
}
|
|
867
|
+
return match;
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// Clean up excessive whitespace
|
|
871
|
+
cleaned = cleaned.replace(/\n\s*\n\s*\n/g, '\n\n');
|
|
872
|
+
cleaned = cleaned.trim();
|
|
873
|
+
|
|
874
|
+
return cleaned;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
export default TagParser;
|