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,897 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated This tool is DEPRECATED as of December 2024.
|
|
3
|
+
* Use WebTool (toolId: "web") instead for all browser automation tasks.
|
|
4
|
+
*
|
|
5
|
+
* WebTool provides:
|
|
6
|
+
* - All browser automation features (navigate, click, type, screenshot, etc.)
|
|
7
|
+
* - Built-in search engine support (Google, Bing, DuckDuckGo)
|
|
8
|
+
* - Tab management with agent isolation
|
|
9
|
+
* - AI-powered screenshot analysis
|
|
10
|
+
*
|
|
11
|
+
* This file is kept for backward compatibility but will be removed in a future version.
|
|
12
|
+
*
|
|
13
|
+
* Migration guide:
|
|
14
|
+
* - Replace toolId "browser" with "web"
|
|
15
|
+
* - Use operation: "interactive" with actions array
|
|
16
|
+
* - Wrap actions in open-tab for tab context
|
|
17
|
+
*
|
|
18
|
+
* Original BrowserTool - Handle browser automation and web interaction tasks
|
|
19
|
+
*
|
|
20
|
+
* Purpose:
|
|
21
|
+
* - Automate web browser interactions
|
|
22
|
+
* - Navigate websites and extract data
|
|
23
|
+
* - Fill forms and interact with web elements
|
|
24
|
+
* - Take screenshots and analyze web content
|
|
25
|
+
* - Handle authentication and sessions
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { BaseTool } from './baseTool.js';
|
|
29
|
+
import TagParser from '../utilities/tagParser.js';
|
|
30
|
+
import puppeteer from 'puppeteer';
|
|
31
|
+
import fs from 'fs/promises';
|
|
32
|
+
import path from 'path';
|
|
33
|
+
|
|
34
|
+
import {
|
|
35
|
+
TOOL_STATUS,
|
|
36
|
+
SYSTEM_DEFAULTS
|
|
37
|
+
} from '../utilities/constants.js';
|
|
38
|
+
import { getDefaultUserAgent } from '../utilities/platformUtils.js';
|
|
39
|
+
|
|
40
|
+
class BrowserTool extends BaseTool {
|
|
41
|
+
constructor(config = {}, logger = null) {
|
|
42
|
+
super(config, logger);
|
|
43
|
+
|
|
44
|
+
// Tool metadata
|
|
45
|
+
this.requiresProject = false;
|
|
46
|
+
this.isAsync = true; // Browser operations can be slow
|
|
47
|
+
this.timeout = config.timeout || 60000; // 1 minute default
|
|
48
|
+
this.maxConcurrentOperations = config.maxConcurrentOperations || 2;
|
|
49
|
+
|
|
50
|
+
// Browser configuration
|
|
51
|
+
this.browserConfig = {
|
|
52
|
+
headless: config.headless !== false, // Default to headless
|
|
53
|
+
viewport: config.viewport || { width: 1280, height: 720 },
|
|
54
|
+
userAgent: config.userAgent || getDefaultUserAgent(),
|
|
55
|
+
timeout: config.pageTimeout || 30000
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Active browser instances
|
|
59
|
+
this.browserInstances = new Map();
|
|
60
|
+
|
|
61
|
+
// Security settings
|
|
62
|
+
this.allowedDomains = config.allowedDomains || null; // null = all allowed
|
|
63
|
+
this.blockedDomains = config.blockedDomains || [];
|
|
64
|
+
this.maxScreenshotSize = config.maxScreenshotSize || 5 * 1024 * 1024; // 5MB
|
|
65
|
+
|
|
66
|
+
// Operation history
|
|
67
|
+
this.operationHistory = [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get tool description for LLM consumption
|
|
72
|
+
* @returns {string} Tool description
|
|
73
|
+
*/
|
|
74
|
+
getDescription() {
|
|
75
|
+
return `
|
|
76
|
+
Browser Tool: Automate web browser interactions, navigation, and data extraction.
|
|
77
|
+
|
|
78
|
+
USAGE:
|
|
79
|
+
\`\`\`json
|
|
80
|
+
{
|
|
81
|
+
"toolId": "browser",
|
|
82
|
+
"actions": [
|
|
83
|
+
{"type": "navigate", "url": "https://example.com"},
|
|
84
|
+
{"type": "wait", "waitTime": 2000},
|
|
85
|
+
{"type": "click", "selector": "button.submit"},
|
|
86
|
+
{"type": "screenshot", "outputPath": "screenshot.png"}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
SUPPORTED ACTIONS:
|
|
92
|
+
- navigate: Navigate to URL (url)
|
|
93
|
+
- click: Click element (selector)
|
|
94
|
+
- type: Type text (selector, text)
|
|
95
|
+
- wait: Wait for element/time (waitTime or waitSelector)
|
|
96
|
+
- screenshot: Take screenshot (outputPath, fullPage)
|
|
97
|
+
- extract: Extract data (selector, attribute)
|
|
98
|
+
- scroll: Scroll page (direction, pixels)
|
|
99
|
+
- close: Close browser
|
|
100
|
+
|
|
101
|
+
PARAMETERS:
|
|
102
|
+
- url: Target URL for navigation
|
|
103
|
+
- selector: CSS selector (e.g., "#id", ".class", "button[type='submit']")
|
|
104
|
+
- text: Text to type
|
|
105
|
+
- outputPath: Screenshot file path
|
|
106
|
+
- waitTime: Wait in milliseconds (100-30000)
|
|
107
|
+
- waitSelector: Element selector to wait for
|
|
108
|
+
- attribute: HTML attribute to extract (default: "text")
|
|
109
|
+
- direction: "up", "down", "left", "right"
|
|
110
|
+
- pixels: Scroll distance (default: 300)
|
|
111
|
+
- fullPage: Full page screenshot (true/false)
|
|
112
|
+
|
|
113
|
+
EXAMPLES:
|
|
114
|
+
|
|
115
|
+
Screenshot a page:
|
|
116
|
+
\`\`\`json
|
|
117
|
+
{
|
|
118
|
+
"toolId": "browser",
|
|
119
|
+
"actions": [
|
|
120
|
+
{"type": "navigate", "url": "https://github.com/trending"},
|
|
121
|
+
{"type": "wait", "waitTime": 2000},
|
|
122
|
+
{"type": "screenshot", "outputPath": "trending.png"},
|
|
123
|
+
{"type": "close"}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
Form automation:
|
|
129
|
+
\`\`\`json
|
|
130
|
+
{
|
|
131
|
+
"toolId": "browser",
|
|
132
|
+
"actions": [
|
|
133
|
+
{"type": "navigate", "url": "https://example.com/login"},
|
|
134
|
+
{"type": "wait", "waitSelector": "input#username"},
|
|
135
|
+
{"type": "type", "selector": "input#username", "text": "myuser"},
|
|
136
|
+
{"type": "type", "selector": "input#password", "text": "mypass"},
|
|
137
|
+
{"type": "click", "selector": "button[type='submit']"},
|
|
138
|
+
{"type": "close"}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
SECURITY:
|
|
144
|
+
- Restricted to allowed domains
|
|
145
|
+
- Screenshot size limits (max 5MB)
|
|
146
|
+
- Auto-cleanup after 10 minutes
|
|
147
|
+
|
|
148
|
+
VIEWPORT: ${this.browserConfig.viewport.width}x${this.browserConfig.viewport.height}
|
|
149
|
+
TIMEOUT: ${this.browserConfig.timeout}ms per operation
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Parse parameters from tool command content
|
|
155
|
+
* @param {string} content - Raw tool command content
|
|
156
|
+
* @returns {Object} Parsed parameters
|
|
157
|
+
*/
|
|
158
|
+
parseParameters(content) {
|
|
159
|
+
try {
|
|
160
|
+
// Try JSON first (for JSON in code blocks)
|
|
161
|
+
if (content.trim().startsWith('{')) {
|
|
162
|
+
const parsed = JSON.parse(content);
|
|
163
|
+
// Ensure actions is an array
|
|
164
|
+
if (!parsed.actions) {
|
|
165
|
+
parsed.actions = [];
|
|
166
|
+
}
|
|
167
|
+
if (!Array.isArray(parsed.actions)) {
|
|
168
|
+
parsed.actions = [parsed.actions];
|
|
169
|
+
}
|
|
170
|
+
return parsed;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const params = {};
|
|
174
|
+
const actions = [];
|
|
175
|
+
|
|
176
|
+
// Extract self-closing tags (e.g., <navigate url="..." />)
|
|
177
|
+
const selfClosingTags = [
|
|
178
|
+
'navigate', 'click', 'type', 'wait', 'screenshot',
|
|
179
|
+
'extract', 'scroll', 'close'
|
|
180
|
+
];
|
|
181
|
+
|
|
182
|
+
for (const tagName of selfClosingTags) {
|
|
183
|
+
// Extract self-closing tags using regex
|
|
184
|
+
const selfClosingPattern = new RegExp(
|
|
185
|
+
`<${tagName}\\s+([^>]*?)\\s*\\/?>`,
|
|
186
|
+
'gi'
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
let match;
|
|
190
|
+
while ((match = selfClosingPattern.exec(content)) !== null) {
|
|
191
|
+
const attributeString = match[1];
|
|
192
|
+
const attributes = this.parseAttributes(attributeString);
|
|
193
|
+
|
|
194
|
+
const action = {
|
|
195
|
+
type: tagName,
|
|
196
|
+
...attributes
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Normalize common attribute names (kebab-case to camelCase)
|
|
200
|
+
if (action['output-path']) {
|
|
201
|
+
action.outputPath = action['output-path'];
|
|
202
|
+
delete action['output-path'];
|
|
203
|
+
}
|
|
204
|
+
if (action['wait-time']) {
|
|
205
|
+
action.waitTime = parseInt(action['wait-time'], 10);
|
|
206
|
+
delete action['wait-time'];
|
|
207
|
+
}
|
|
208
|
+
if (action['wait-selector']) {
|
|
209
|
+
action.waitSelector = action['wait-selector'];
|
|
210
|
+
delete action['wait-selector'];
|
|
211
|
+
}
|
|
212
|
+
if (action['wait-type']) {
|
|
213
|
+
action.waitType = action['wait-type'];
|
|
214
|
+
delete action['wait-type'];
|
|
215
|
+
}
|
|
216
|
+
if (action['full-page']) {
|
|
217
|
+
action.fullPage = action['full-page'] === 'true';
|
|
218
|
+
delete action['full-page'];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
actions.push(action);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Ensure actions is always an array (even if empty)
|
|
226
|
+
params.actions = Array.isArray(actions) ? actions : [];
|
|
227
|
+
params.rawContent = content.trim();
|
|
228
|
+
|
|
229
|
+
return params;
|
|
230
|
+
|
|
231
|
+
} catch (error) {
|
|
232
|
+
// If JSON parsing fails, return a structure with empty actions
|
|
233
|
+
// This prevents "actions is not iterable" errors
|
|
234
|
+
this.logger?.error('Failed to parse browser parameters', { error: error.message });
|
|
235
|
+
return {
|
|
236
|
+
actions: [], // Always return an array
|
|
237
|
+
rawContent: content.trim(),
|
|
238
|
+
parseError: error.message
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Parse attributes from attribute string
|
|
245
|
+
* @param {string} attributeString - String containing attributes
|
|
246
|
+
* @returns {Object} Parsed attributes object
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
parseAttributes(attributeString) {
|
|
250
|
+
const attributes = {};
|
|
251
|
+
|
|
252
|
+
if (!attributeString) return attributes;
|
|
253
|
+
|
|
254
|
+
// Match attribute="value" or attribute='value'
|
|
255
|
+
const attrPattern = /([\w-]+)\s*=\s*["']([^"']*)["']/g;
|
|
256
|
+
let match;
|
|
257
|
+
|
|
258
|
+
while ((match = attrPattern.exec(attributeString)) !== null) {
|
|
259
|
+
const attrName = match[1];
|
|
260
|
+
const attrValue = match[2];
|
|
261
|
+
attributes[attrName] = attrValue;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return attributes;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Get required parameters
|
|
269
|
+
* @returns {Array<string>} Array of required parameter names
|
|
270
|
+
*/
|
|
271
|
+
getRequiredParameters() {
|
|
272
|
+
return ['actions'];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Custom parameter validation
|
|
277
|
+
* @param {Object} params - Parameters to validate
|
|
278
|
+
* @returns {Object} Validation result
|
|
279
|
+
*/
|
|
280
|
+
customValidateParameters(params) {
|
|
281
|
+
const errors = [];
|
|
282
|
+
|
|
283
|
+
if (!params.actions || !Array.isArray(params.actions) || params.actions.length === 0) {
|
|
284
|
+
errors.push('At least one action is required');
|
|
285
|
+
} else {
|
|
286
|
+
// Validate each action
|
|
287
|
+
for (const [index, action] of params.actions.entries()) {
|
|
288
|
+
if (!action.type) {
|
|
289
|
+
errors.push(`Action ${index + 1}: type is required`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
switch (action.type) {
|
|
294
|
+
case 'navigate':
|
|
295
|
+
if (!action.url) {
|
|
296
|
+
errors.push(`Action ${index + 1}: url is required for navigate`);
|
|
297
|
+
} else if (!this.isAllowedUrl(action.url)) {
|
|
298
|
+
errors.push(`Action ${index + 1}: URL not allowed: ${action.url}`);
|
|
299
|
+
}
|
|
300
|
+
break;
|
|
301
|
+
|
|
302
|
+
case 'click':
|
|
303
|
+
case 'extract':
|
|
304
|
+
if (!action.selector) {
|
|
305
|
+
errors.push(`Action ${index + 1}: selector is required for ${action.type}`);
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
|
|
309
|
+
case 'type':
|
|
310
|
+
if (!action.selector) {
|
|
311
|
+
errors.push(`Action ${index + 1}: selector is required for type`);
|
|
312
|
+
}
|
|
313
|
+
if (!action.text && action.text !== '') {
|
|
314
|
+
errors.push(`Action ${index + 1}: text is required for type`);
|
|
315
|
+
}
|
|
316
|
+
break;
|
|
317
|
+
|
|
318
|
+
case 'wait':
|
|
319
|
+
if (!action.waitTime && !action.waitSelector) {
|
|
320
|
+
errors.push(`Action ${index + 1}: either wait-time or wait-selector is required`);
|
|
321
|
+
}
|
|
322
|
+
if (action.waitTime && (action.waitTime < 100 || action.waitTime > 30000)) {
|
|
323
|
+
errors.push(`Action ${index + 1}: wait-time must be between 100 and 30000 milliseconds`);
|
|
324
|
+
}
|
|
325
|
+
break;
|
|
326
|
+
|
|
327
|
+
case 'screenshot':
|
|
328
|
+
if (!action.outputPath) {
|
|
329
|
+
errors.push(`Action ${index + 1}: output-path is required for screenshot`);
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
|
|
333
|
+
case 'scroll':
|
|
334
|
+
if (!action.direction) {
|
|
335
|
+
errors.push(`Action ${index + 1}: direction is required for scroll`);
|
|
336
|
+
} else if (!['up', 'down', 'left', 'right'].includes(action.direction)) {
|
|
337
|
+
errors.push(`Action ${index + 1}: invalid scroll direction: ${action.direction}`);
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
|
|
341
|
+
case 'close':
|
|
342
|
+
// No additional validation needed
|
|
343
|
+
break;
|
|
344
|
+
|
|
345
|
+
default:
|
|
346
|
+
errors.push(`Action ${index + 1}: unknown action type: ${action.type}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
valid: errors.length === 0,
|
|
353
|
+
errors
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Execute tool with parsed parameters
|
|
359
|
+
* @param {Object} params - Parsed parameters
|
|
360
|
+
* @param {Object} context - Execution context
|
|
361
|
+
* @returns {Promise<Object>} Execution result
|
|
362
|
+
*/
|
|
363
|
+
async execute(params, context) {
|
|
364
|
+
const { actions } = params;
|
|
365
|
+
const { agentId, projectDir } = context;
|
|
366
|
+
|
|
367
|
+
const browserKey = `${agentId}-${projectDir || 'default'}`;
|
|
368
|
+
const results = [];
|
|
369
|
+
|
|
370
|
+
for (const action of actions) {
|
|
371
|
+
try {
|
|
372
|
+
let result;
|
|
373
|
+
|
|
374
|
+
switch (action.type) {
|
|
375
|
+
case 'navigate':
|
|
376
|
+
result = await this.navigate(action.url, browserKey);
|
|
377
|
+
break;
|
|
378
|
+
|
|
379
|
+
case 'click':
|
|
380
|
+
result = await this.click(action.selector, browserKey);
|
|
381
|
+
break;
|
|
382
|
+
|
|
383
|
+
case 'type':
|
|
384
|
+
result = await this.type(action.selector, action.text, browserKey);
|
|
385
|
+
break;
|
|
386
|
+
|
|
387
|
+
case 'wait':
|
|
388
|
+
result = await this.wait(action, browserKey);
|
|
389
|
+
break;
|
|
390
|
+
|
|
391
|
+
case 'screenshot':
|
|
392
|
+
result = await this.screenshot(action.outputPath, projectDir, browserKey, action);
|
|
393
|
+
break;
|
|
394
|
+
|
|
395
|
+
case 'extract':
|
|
396
|
+
result = await this.extract(action.selector, action.attribute || 'text', browserKey);
|
|
397
|
+
break;
|
|
398
|
+
|
|
399
|
+
case 'scroll':
|
|
400
|
+
result = await this.scroll(action, browserKey);
|
|
401
|
+
break;
|
|
402
|
+
|
|
403
|
+
case 'close':
|
|
404
|
+
result = await this.closeBrowser(browserKey);
|
|
405
|
+
break;
|
|
406
|
+
|
|
407
|
+
default:
|
|
408
|
+
throw new Error(`Unknown action type: ${action.type}`);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
results.push(result);
|
|
412
|
+
this.addToHistory(action, result, agentId);
|
|
413
|
+
|
|
414
|
+
} catch (error) {
|
|
415
|
+
const errorResult = {
|
|
416
|
+
success: false,
|
|
417
|
+
action: action.type,
|
|
418
|
+
error: error.message,
|
|
419
|
+
selector: action.selector || action.url
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
results.push(errorResult);
|
|
423
|
+
this.addToHistory(action, errorResult, agentId);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
success: true,
|
|
429
|
+
actions: results,
|
|
430
|
+
executedActions: actions.length,
|
|
431
|
+
toolUsed: 'browser'
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Navigate to URL
|
|
437
|
+
* @private
|
|
438
|
+
*/
|
|
439
|
+
async navigate(url, browserKey) {
|
|
440
|
+
const browser = await this.getBrowser(browserKey);
|
|
441
|
+
const page = await this.getPage(browserKey);
|
|
442
|
+
|
|
443
|
+
const startTime = Date.now();
|
|
444
|
+
|
|
445
|
+
try {
|
|
446
|
+
await page.goto(url, {
|
|
447
|
+
waitUntil: 'networkidle0',
|
|
448
|
+
timeout: this.browserConfig.timeout
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
const title = await page.title();
|
|
452
|
+
const currentUrl = page.url();
|
|
453
|
+
|
|
454
|
+
return {
|
|
455
|
+
success: true,
|
|
456
|
+
action: 'navigate',
|
|
457
|
+
url: currentUrl,
|
|
458
|
+
originalUrl: url,
|
|
459
|
+
title,
|
|
460
|
+
loadTime: Date.now() - startTime,
|
|
461
|
+
message: `Navigated to ${url}`
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
} catch (error) {
|
|
465
|
+
throw new Error(`Navigation failed: ${error.message}`);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Click on element
|
|
471
|
+
* @private
|
|
472
|
+
*/
|
|
473
|
+
async click(selector, browserKey) {
|
|
474
|
+
const page = await this.getPage(browserKey);
|
|
475
|
+
|
|
476
|
+
try {
|
|
477
|
+
await page.waitForSelector(selector, { timeout: 5000 });
|
|
478
|
+
await page.click(selector);
|
|
479
|
+
|
|
480
|
+
return {
|
|
481
|
+
success: true,
|
|
482
|
+
action: 'click',
|
|
483
|
+
selector,
|
|
484
|
+
message: `Clicked on ${selector}`
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
} catch (error) {
|
|
488
|
+
throw new Error(`Click failed on ${selector}: ${error.message}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Type text into element
|
|
494
|
+
* @private
|
|
495
|
+
*/
|
|
496
|
+
async type(selector, text, browserKey) {
|
|
497
|
+
const page = await this.getPage(browserKey);
|
|
498
|
+
|
|
499
|
+
try {
|
|
500
|
+
await page.waitForSelector(selector, { timeout: 5000 });
|
|
501
|
+
await page.focus(selector);
|
|
502
|
+
await page.keyboard.selectAll();
|
|
503
|
+
await page.type(selector, text);
|
|
504
|
+
|
|
505
|
+
return {
|
|
506
|
+
success: true,
|
|
507
|
+
action: 'type',
|
|
508
|
+
selector,
|
|
509
|
+
text,
|
|
510
|
+
textLength: text.length,
|
|
511
|
+
message: `Typed ${text.length} characters into ${selector}`
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
} catch (error) {
|
|
515
|
+
throw new Error(`Type failed on ${selector}: ${error.message}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Wait for condition
|
|
521
|
+
* @private
|
|
522
|
+
*/
|
|
523
|
+
async wait(action, browserKey) {
|
|
524
|
+
const page = await this.getPage(browserKey);
|
|
525
|
+
|
|
526
|
+
try {
|
|
527
|
+
if (action.waitTime) {
|
|
528
|
+
// Use setTimeout wrapped in Promise (waitForTimeout was removed in Puppeteer v22+)
|
|
529
|
+
await new Promise(resolve => setTimeout(resolve, action.waitTime));
|
|
530
|
+
return {
|
|
531
|
+
success: true,
|
|
532
|
+
action: 'wait',
|
|
533
|
+
waitTime: action.waitTime,
|
|
534
|
+
message: `Waited ${action.waitTime}ms`
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (action.waitSelector) {
|
|
539
|
+
const waitType = action.waitType || 'visible';
|
|
540
|
+
const options = { timeout: 10000 };
|
|
541
|
+
|
|
542
|
+
if (waitType === 'hidden') {
|
|
543
|
+
await page.waitForSelector(action.waitSelector, { ...options, hidden: true });
|
|
544
|
+
} else {
|
|
545
|
+
await page.waitForSelector(action.waitSelector, options);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return {
|
|
549
|
+
success: true,
|
|
550
|
+
action: 'wait',
|
|
551
|
+
waitSelector: action.waitSelector,
|
|
552
|
+
waitType,
|
|
553
|
+
message: `Waited for ${action.waitSelector} to be ${waitType}`
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
} catch (error) {
|
|
558
|
+
throw new Error(`Wait failed: ${error.message}`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Take screenshot
|
|
564
|
+
* @private
|
|
565
|
+
*/
|
|
566
|
+
async screenshot(outputPath, projectDir, browserKey, options = {}) {
|
|
567
|
+
const page = await this.getPage(browserKey);
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
const fullPath = projectDir ? path.resolve(projectDir, outputPath) : path.resolve(outputPath);
|
|
571
|
+
|
|
572
|
+
// Ensure directory exists
|
|
573
|
+
const dir = path.dirname(fullPath);
|
|
574
|
+
await fs.mkdir(dir, { recursive: true });
|
|
575
|
+
|
|
576
|
+
const screenshotOptions = {
|
|
577
|
+
path: fullPath,
|
|
578
|
+
type: 'png'
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
if (options.fullPage) {
|
|
582
|
+
screenshotOptions.fullPage = true;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
await page.screenshot(screenshotOptions);
|
|
586
|
+
|
|
587
|
+
const stats = await fs.stat(fullPath);
|
|
588
|
+
|
|
589
|
+
if (stats.size > this.maxScreenshotSize) {
|
|
590
|
+
throw new Error(`Screenshot too large: ${stats.size} bytes (max ${this.maxScreenshotSize})`);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return {
|
|
594
|
+
success: true,
|
|
595
|
+
action: 'screenshot',
|
|
596
|
+
outputPath: path.relative(projectDir || process.cwd(), fullPath),
|
|
597
|
+
size: stats.size,
|
|
598
|
+
fullPage: !!options.fullPage,
|
|
599
|
+
message: `Screenshot saved: ${outputPath}`
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
} catch (error) {
|
|
603
|
+
throw new Error(`Screenshot failed: ${error.message}`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Extract data from elements
|
|
609
|
+
* @private
|
|
610
|
+
*/
|
|
611
|
+
async extract(selector, attribute, browserKey) {
|
|
612
|
+
const page = await this.getPage(browserKey);
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
await page.waitForSelector(selector, { timeout: 5000 });
|
|
616
|
+
|
|
617
|
+
let data;
|
|
618
|
+
if (attribute === 'text') {
|
|
619
|
+
data = await page.$eval(selector, el => el.textContent.trim());
|
|
620
|
+
} else {
|
|
621
|
+
data = await page.$eval(selector, (el, attr) => el.getAttribute(attr), attribute);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return {
|
|
625
|
+
success: true,
|
|
626
|
+
action: 'extract',
|
|
627
|
+
selector,
|
|
628
|
+
attribute,
|
|
629
|
+
data,
|
|
630
|
+
message: `Extracted ${attribute} from ${selector}`
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
} catch (error) {
|
|
634
|
+
throw new Error(`Extract failed on ${selector}: ${error.message}`);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Scroll page or element
|
|
640
|
+
* @private
|
|
641
|
+
*/
|
|
642
|
+
async scroll(action, browserKey) {
|
|
643
|
+
const page = await this.getPage(browserKey);
|
|
644
|
+
|
|
645
|
+
try {
|
|
646
|
+
const { direction, pixels = 300, selector } = action;
|
|
647
|
+
|
|
648
|
+
if (selector) {
|
|
649
|
+
// Scroll specific element
|
|
650
|
+
await page.evaluate((sel, dir, px) => {
|
|
651
|
+
const element = document.querySelector(sel);
|
|
652
|
+
if (element) {
|
|
653
|
+
if (dir === 'down') element.scrollTop += px;
|
|
654
|
+
else if (dir === 'up') element.scrollTop -= px;
|
|
655
|
+
else if (dir === 'right') element.scrollLeft += px;
|
|
656
|
+
else if (dir === 'left') element.scrollLeft -= px;
|
|
657
|
+
}
|
|
658
|
+
}, selector, direction, pixels);
|
|
659
|
+
} else {
|
|
660
|
+
// Scroll page
|
|
661
|
+
await page.evaluate((dir, px) => {
|
|
662
|
+
if (dir === 'down') window.scrollBy(0, px);
|
|
663
|
+
else if (dir === 'up') window.scrollBy(0, -px);
|
|
664
|
+
else if (dir === 'right') window.scrollBy(px, 0);
|
|
665
|
+
else if (dir === 'left') window.scrollBy(-px, 0);
|
|
666
|
+
}, direction, pixels);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return {
|
|
670
|
+
success: true,
|
|
671
|
+
action: 'scroll',
|
|
672
|
+
direction,
|
|
673
|
+
pixels,
|
|
674
|
+
selector: selector || 'page',
|
|
675
|
+
message: `Scrolled ${direction} by ${pixels}px`
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
} catch (error) {
|
|
679
|
+
throw new Error(`Scroll failed: ${error.message}`);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Get or create browser instance
|
|
685
|
+
* @private
|
|
686
|
+
*/
|
|
687
|
+
async getBrowser(browserKey) {
|
|
688
|
+
if (this.browserInstances.has(browserKey)) {
|
|
689
|
+
const instance = this.browserInstances.get(browserKey);
|
|
690
|
+
if (!instance.browser.isConnected()) {
|
|
691
|
+
this.browserInstances.delete(browserKey);
|
|
692
|
+
} else {
|
|
693
|
+
return instance.browser;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const browser = await puppeteer.launch({
|
|
698
|
+
headless: this.browserConfig.headless,
|
|
699
|
+
args: [
|
|
700
|
+
'--no-sandbox',
|
|
701
|
+
'--disable-setuid-sandbox',
|
|
702
|
+
'--disable-dev-shm-usage',
|
|
703
|
+
'--disable-gpu'
|
|
704
|
+
]
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
const page = await browser.newPage();
|
|
708
|
+
await page.setViewport(this.browserConfig.viewport);
|
|
709
|
+
await page.setUserAgent(this.browserConfig.userAgent);
|
|
710
|
+
|
|
711
|
+
this.browserInstances.set(browserKey, {
|
|
712
|
+
browser,
|
|
713
|
+
page,
|
|
714
|
+
created: Date.now()
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
// Auto-cleanup after 10 minutes of inactivity
|
|
718
|
+
setTimeout(() => {
|
|
719
|
+
this.cleanupBrowser(browserKey);
|
|
720
|
+
}, 10 * 60 * 1000);
|
|
721
|
+
|
|
722
|
+
return browser;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Get page instance
|
|
727
|
+
* @private
|
|
728
|
+
*/
|
|
729
|
+
async getPage(browserKey) {
|
|
730
|
+
await this.getBrowser(browserKey);
|
|
731
|
+
return this.browserInstances.get(browserKey).page;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Close browser instance
|
|
736
|
+
* @private
|
|
737
|
+
*/
|
|
738
|
+
async closeBrowser(browserKey) {
|
|
739
|
+
const instance = this.browserInstances.get(browserKey);
|
|
740
|
+
|
|
741
|
+
if (instance) {
|
|
742
|
+
try {
|
|
743
|
+
await instance.browser.close();
|
|
744
|
+
this.browserInstances.delete(browserKey);
|
|
745
|
+
|
|
746
|
+
return {
|
|
747
|
+
success: true,
|
|
748
|
+
action: 'close',
|
|
749
|
+
browserKey,
|
|
750
|
+
message: 'Browser instance closed'
|
|
751
|
+
};
|
|
752
|
+
} catch (error) {
|
|
753
|
+
throw new Error(`Failed to close browser: ${error.message}`);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return {
|
|
758
|
+
success: true,
|
|
759
|
+
action: 'close',
|
|
760
|
+
browserKey,
|
|
761
|
+
message: 'Browser instance not found (already closed)'
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Cleanup browser instance
|
|
767
|
+
* @private
|
|
768
|
+
*/
|
|
769
|
+
async cleanupBrowser(browserKey) {
|
|
770
|
+
const instance = this.browserInstances.get(browserKey);
|
|
771
|
+
|
|
772
|
+
if (instance) {
|
|
773
|
+
try {
|
|
774
|
+
await instance.browser.close();
|
|
775
|
+
} catch (error) {
|
|
776
|
+
// Ignore cleanup errors
|
|
777
|
+
} finally {
|
|
778
|
+
this.browserInstances.delete(browserKey);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Check if URL is allowed
|
|
785
|
+
* @private
|
|
786
|
+
*/
|
|
787
|
+
isAllowedUrl(url) {
|
|
788
|
+
try {
|
|
789
|
+
const urlObj = new URL(url);
|
|
790
|
+
const hostname = urlObj.hostname.toLowerCase();
|
|
791
|
+
|
|
792
|
+
// Check blocked domains
|
|
793
|
+
if (this.blockedDomains.some(blocked => hostname.includes(blocked.toLowerCase()))) {
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Check allowed domains if specified
|
|
798
|
+
if (this.allowedDomains && this.allowedDomains.length > 0) {
|
|
799
|
+
return this.allowedDomains.some(allowed => hostname.includes(allowed.toLowerCase()));
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return true;
|
|
803
|
+
} catch {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Add operation to history
|
|
810
|
+
* @private
|
|
811
|
+
*/
|
|
812
|
+
addToHistory(action, result, agentId) {
|
|
813
|
+
const historyEntry = {
|
|
814
|
+
timestamp: new Date().toISOString(),
|
|
815
|
+
agentId,
|
|
816
|
+
action: action.type,
|
|
817
|
+
selector: action.selector || action.url,
|
|
818
|
+
success: result.success,
|
|
819
|
+
loadTime: result.loadTime || 0
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
this.operationHistory.push(historyEntry);
|
|
823
|
+
|
|
824
|
+
// Keep only last 100 entries
|
|
825
|
+
if (this.operationHistory.length > 100) {
|
|
826
|
+
this.operationHistory = this.operationHistory.slice(-100);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Get supported actions for this tool
|
|
832
|
+
* @returns {Array<string>} Array of supported action names
|
|
833
|
+
*/
|
|
834
|
+
getSupportedActions() {
|
|
835
|
+
return ['navigate', 'click', 'type', 'wait', 'screenshot', 'extract', 'scroll', 'close'];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Get parameter schema for validation
|
|
840
|
+
* @returns {Object} Parameter schema
|
|
841
|
+
*/
|
|
842
|
+
getParameterSchema() {
|
|
843
|
+
return {
|
|
844
|
+
type: 'object',
|
|
845
|
+
properties: {
|
|
846
|
+
actions: {
|
|
847
|
+
type: 'array',
|
|
848
|
+
minItems: 1,
|
|
849
|
+
items: {
|
|
850
|
+
type: 'object',
|
|
851
|
+
properties: {
|
|
852
|
+
type: {
|
|
853
|
+
type: 'string',
|
|
854
|
+
enum: this.getSupportedActions()
|
|
855
|
+
},
|
|
856
|
+
url: { type: 'string' },
|
|
857
|
+
selector: { type: 'string' },
|
|
858
|
+
text: { type: 'string' },
|
|
859
|
+
outputPath: { type: 'string' },
|
|
860
|
+
waitTime: { type: 'integer' },
|
|
861
|
+
waitSelector: { type: 'string' },
|
|
862
|
+
attribute: { type: 'string' },
|
|
863
|
+
direction: { type: 'string' },
|
|
864
|
+
pixels: { type: 'integer' }
|
|
865
|
+
},
|
|
866
|
+
required: ['type']
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
required: ['actions']
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Resource cleanup
|
|
876
|
+
* @param {string} operationId - Operation identifier
|
|
877
|
+
*/
|
|
878
|
+
async cleanup(operationId) {
|
|
879
|
+
// Close all browser instances
|
|
880
|
+
for (const [browserKey] of this.browserInstances) {
|
|
881
|
+
await this.cleanupBrowser(browserKey);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Get operation history for debugging
|
|
887
|
+
* @returns {Array} Operation history
|
|
888
|
+
*/
|
|
889
|
+
getOperationHistory(agentId = null) {
|
|
890
|
+
if (agentId) {
|
|
891
|
+
return this.operationHistory.filter(entry => entry.agentId === agentId);
|
|
892
|
+
}
|
|
893
|
+
return [...this.operationHistory];
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
export default BrowserTool;
|