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,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhatsApp Service - Manages WhatsApp Web connection via whatsapp-web.js
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* - Handle WhatsApp pairing/linking via QR code
|
|
6
|
+
* - Maintain persistent session state
|
|
7
|
+
* - Provide data access APIs for the WhatsApp tool
|
|
8
|
+
* - Manage allowed chats/groups access control
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
|
|
14
|
+
// Lazy-load whatsapp-web.js — throws at connect() time if missing
|
|
15
|
+
let Client, LocalAuth, MessageMedia;
|
|
16
|
+
try {
|
|
17
|
+
const pkg = await import('whatsapp-web.js');
|
|
18
|
+
const mod = pkg.default || pkg;
|
|
19
|
+
Client = mod.Client;
|
|
20
|
+
LocalAuth = mod.LocalAuth;
|
|
21
|
+
MessageMedia = mod.MessageMedia;
|
|
22
|
+
} catch {
|
|
23
|
+
// Will be checked at connect() time
|
|
24
|
+
}
|
|
25
|
+
import { getUserDataDir } from '../utilities/userDataDir.js';
|
|
26
|
+
|
|
27
|
+
// Connection states
|
|
28
|
+
const WA_STATUS = {
|
|
29
|
+
DISCONNECTED: 'disconnected',
|
|
30
|
+
CONNECTING: 'connecting',
|
|
31
|
+
QR_READY: 'qr_ready',
|
|
32
|
+
AUTHENTICATING: 'authenticating',
|
|
33
|
+
CONNECTED: 'connected',
|
|
34
|
+
FAILED: 'failed'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
class WhatsAppService {
|
|
38
|
+
constructor(logger = null) {
|
|
39
|
+
this.logger = logger;
|
|
40
|
+
this.client = null;
|
|
41
|
+
this.status = WA_STATUS.DISCONNECTED;
|
|
42
|
+
this.qrCode = null;
|
|
43
|
+
this.currentUser = null;
|
|
44
|
+
this.webSocketManager = null;
|
|
45
|
+
|
|
46
|
+
// Allowed chats/groups (empty = all allowed)
|
|
47
|
+
this.allowedChats = [];
|
|
48
|
+
|
|
49
|
+
// Persisted config path
|
|
50
|
+
this.dataDir = path.join(getUserDataDir(), 'whatsapp');
|
|
51
|
+
this.configPath = path.join(this.dataDir, 'whatsapp-config.json');
|
|
52
|
+
this.sessionDir = path.join(this.dataDir, 'session');
|
|
53
|
+
|
|
54
|
+
// Ensure directories exist
|
|
55
|
+
this._ensureDirs();
|
|
56
|
+
|
|
57
|
+
// Load saved config
|
|
58
|
+
this._loadConfig();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ========================
|
|
62
|
+
// Lifecycle
|
|
63
|
+
// ========================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Check if a previous session exists and auto-reconnect if so.
|
|
67
|
+
* Called once after the WebSocket manager is wired up.
|
|
68
|
+
*/
|
|
69
|
+
async autoReconnect() {
|
|
70
|
+
if (this._hasExistingSession()) {
|
|
71
|
+
this.logger?.info('WhatsApp: Found existing session, auto-reconnecting...');
|
|
72
|
+
try {
|
|
73
|
+
await this.connect();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
this.logger?.warn('WhatsApp auto-reconnect failed', { error: e.message });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check if a saved session directory exists (non-empty)
|
|
82
|
+
*/
|
|
83
|
+
_hasExistingSession() {
|
|
84
|
+
try {
|
|
85
|
+
if (!fs.existsSync(this.sessionDir)) return false;
|
|
86
|
+
const entries = fs.readdirSync(this.sessionDir);
|
|
87
|
+
return entries.length > 0;
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Initialize and connect the WhatsApp client
|
|
95
|
+
*/
|
|
96
|
+
async connect() {
|
|
97
|
+
if (!Client) {
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
error: 'whatsapp-web.js is not installed. Run: npm install whatsapp-web.js',
|
|
101
|
+
status: WA_STATUS.FAILED
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.status === WA_STATUS.CONNECTED) {
|
|
106
|
+
return { success: true, status: this.status, user: this.currentUser };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (this.status === WA_STATUS.CONNECTING || this.status === WA_STATUS.QR_READY) {
|
|
110
|
+
return { success: true, status: this.status, qrCode: this.qrCode };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.status = WA_STATUS.CONNECTING;
|
|
114
|
+
this._broadcast('whatsapp_status', { status: this.status });
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
this.client = new Client({
|
|
118
|
+
authStrategy: new LocalAuth({ dataPath: this.sessionDir }),
|
|
119
|
+
puppeteer: {
|
|
120
|
+
headless: true,
|
|
121
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this._attachClientEvents();
|
|
126
|
+
await this.client.initialize();
|
|
127
|
+
|
|
128
|
+
return { success: true, status: this.status, qrCode: this.qrCode };
|
|
129
|
+
} catch (error) {
|
|
130
|
+
this.status = WA_STATUS.FAILED;
|
|
131
|
+
this.logger?.error('WhatsApp connection failed', { error: error.message });
|
|
132
|
+
this._broadcast('whatsapp_status', { status: this.status, error: error.message });
|
|
133
|
+
return { success: false, error: error.message, status: this.status };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Disconnect the WhatsApp client
|
|
139
|
+
*/
|
|
140
|
+
async disconnect() {
|
|
141
|
+
if (!this.client) {
|
|
142
|
+
this.status = WA_STATUS.DISCONNECTED;
|
|
143
|
+
return { success: true };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await this.client.destroy();
|
|
148
|
+
} catch (e) {
|
|
149
|
+
this.logger?.warn('WhatsApp disconnect error', { error: e.message });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.client = null;
|
|
153
|
+
this.status = WA_STATUS.DISCONNECTED;
|
|
154
|
+
this.qrCode = null;
|
|
155
|
+
this.currentUser = null;
|
|
156
|
+
this._broadcast('whatsapp_status', { status: this.status });
|
|
157
|
+
return { success: true };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Logout — clears session so re-pairing is required
|
|
162
|
+
*/
|
|
163
|
+
async logout() {
|
|
164
|
+
if (this.client) {
|
|
165
|
+
try {
|
|
166
|
+
await this.client.logout();
|
|
167
|
+
} catch (e) {
|
|
168
|
+
this.logger?.warn('WhatsApp logout error', { error: e.message });
|
|
169
|
+
}
|
|
170
|
+
await this.disconnect();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Remove session files
|
|
174
|
+
try {
|
|
175
|
+
if (fs.existsSync(this.sessionDir)) {
|
|
176
|
+
fs.rmSync(this.sessionDir, { recursive: true, force: true });
|
|
177
|
+
}
|
|
178
|
+
} catch (e) {
|
|
179
|
+
this.logger?.warn('Failed to remove session dir', { error: e.message });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { success: true };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Get current connection status
|
|
187
|
+
*/
|
|
188
|
+
getStatus() {
|
|
189
|
+
return {
|
|
190
|
+
status: this.status,
|
|
191
|
+
connected: this.status === WA_STATUS.CONNECTED,
|
|
192
|
+
qrCode: this.qrCode,
|
|
193
|
+
user: this.currentUser,
|
|
194
|
+
allowedChats: this.allowedChats
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ========================
|
|
199
|
+
// Access Control
|
|
200
|
+
// ========================
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Update allowed chats list
|
|
204
|
+
* @param {Array<{id: string, name: string}>} chats
|
|
205
|
+
*/
|
|
206
|
+
setAllowedChats(chats) {
|
|
207
|
+
this.allowedChats = chats || [];
|
|
208
|
+
this._saveConfig();
|
|
209
|
+
return { success: true, allowedChats: this.allowedChats };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Check if a chat is allowed
|
|
214
|
+
*/
|
|
215
|
+
isChatAllowed(chatId) {
|
|
216
|
+
if (this.allowedChats.length === 0) return true; // empty = all allowed
|
|
217
|
+
return this.allowedChats.some(c => c.id === chatId);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ========================
|
|
221
|
+
// Data Access (used by WhatsAppTool)
|
|
222
|
+
// ========================
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Resolve a chat identifier — accepts either a WhatsApp ID (e.g. "1234@g.us")
|
|
226
|
+
* or a human-readable name (e.g. "Work Group"). Returns the serialized chat ID.
|
|
227
|
+
* Throws if no match or multiple ambiguous matches are found.
|
|
228
|
+
* @param {string} chatIdOrName
|
|
229
|
+
* @returns {Promise<string>} Resolved serialized chat ID
|
|
230
|
+
*/
|
|
231
|
+
async resolveChatId(chatIdOrName) {
|
|
232
|
+
if (!chatIdOrName) throw new Error('chatId or chat name is required');
|
|
233
|
+
|
|
234
|
+
// If it looks like a WhatsApp ID already, return as-is
|
|
235
|
+
if (chatIdOrName.includes('@')) {
|
|
236
|
+
return chatIdOrName;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Otherwise search by name (case-insensitive)
|
|
240
|
+
this._ensureConnected();
|
|
241
|
+
const allChats = await this.client.getChats();
|
|
242
|
+
const needle = chatIdOrName.toLowerCase().trim();
|
|
243
|
+
|
|
244
|
+
// Exact match first
|
|
245
|
+
const exact = allChats.find(c =>
|
|
246
|
+
(c.name || c.id.user || '').toLowerCase() === needle
|
|
247
|
+
);
|
|
248
|
+
if (exact) return exact.id._serialized;
|
|
249
|
+
|
|
250
|
+
// Partial/substring match
|
|
251
|
+
const partial = allChats.filter(c =>
|
|
252
|
+
(c.name || c.id.user || '').toLowerCase().includes(needle)
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
if (partial.length === 0) {
|
|
256
|
+
throw new Error(`No chat found matching "${chatIdOrName}". Use list-chats to see available chats.`);
|
|
257
|
+
}
|
|
258
|
+
if (partial.length === 1) {
|
|
259
|
+
return partial[0].id._serialized;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Multiple matches — return a helpful error
|
|
263
|
+
const matches = partial.slice(0, 5).map(c => `"${c.name || c.id.user}" (${c.id._serialized})`).join(', ');
|
|
264
|
+
throw new Error(
|
|
265
|
+
`Multiple chats match "${chatIdOrName}": ${matches}. ` +
|
|
266
|
+
`Please use a more specific name or the exact chat ID.`
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* List chats with optional filtering and pagination
|
|
272
|
+
* @param {Object} options
|
|
273
|
+
* @param {string} options.filter - Filter by name (substring, case-insensitive)
|
|
274
|
+
* @param {string} options.type - Filter by type: "group", "individual", or "all" (default)
|
|
275
|
+
* @param {number} options.page - Page number, 1-based (default: 1)
|
|
276
|
+
* @param {number} options.pageSize - Items per page (default: 20)
|
|
277
|
+
* @param {boolean} options.unreadOnly - Only show chats with unread messages
|
|
278
|
+
*/
|
|
279
|
+
async listChats(options = {}) {
|
|
280
|
+
this._ensureConnected();
|
|
281
|
+
const { filter, type = 'all', page = 1, pageSize = 20, unreadOnly = false } = options;
|
|
282
|
+
|
|
283
|
+
const rawChats = await this.client.getChats();
|
|
284
|
+
|
|
285
|
+
let chats = rawChats.map(chat => ({
|
|
286
|
+
id: chat.id._serialized,
|
|
287
|
+
name: chat.name || chat.id.user,
|
|
288
|
+
isGroup: chat.isGroup,
|
|
289
|
+
unreadCount: chat.unreadCount,
|
|
290
|
+
lastMessage: chat.lastMessage ? {
|
|
291
|
+
body: chat.lastMessage.body?.substring(0, 200),
|
|
292
|
+
timestamp: chat.lastMessage.timestamp,
|
|
293
|
+
fromMe: chat.lastMessage.fromMe
|
|
294
|
+
} : null,
|
|
295
|
+
allowed: this.isChatAllowed(chat.id._serialized)
|
|
296
|
+
}));
|
|
297
|
+
|
|
298
|
+
// Apply filters
|
|
299
|
+
if (type === 'group') {
|
|
300
|
+
chats = chats.filter(c => c.isGroup);
|
|
301
|
+
} else if (type === 'individual') {
|
|
302
|
+
chats = chats.filter(c => !c.isGroup);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (filter) {
|
|
306
|
+
const needle = filter.toLowerCase();
|
|
307
|
+
chats = chats.filter(c => c.name.toLowerCase().includes(needle));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (unreadOnly) {
|
|
311
|
+
chats = chats.filter(c => c.unreadCount > 0);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Pagination
|
|
315
|
+
const totalChats = chats.length;
|
|
316
|
+
const totalPages = Math.ceil(totalChats / pageSize) || 1;
|
|
317
|
+
const safePage = Math.max(1, Math.min(page, totalPages));
|
|
318
|
+
const startIdx = (safePage - 1) * pageSize;
|
|
319
|
+
const pageChats = chats.slice(startIdx, startIdx + pageSize);
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
chats: pageChats,
|
|
323
|
+
pagination: {
|
|
324
|
+
page: safePage,
|
|
325
|
+
pageSize,
|
|
326
|
+
totalChats,
|
|
327
|
+
totalPages,
|
|
328
|
+
hasMore: safePage < totalPages
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get messages from a specific chat
|
|
335
|
+
* @param {string} chatId
|
|
336
|
+
* @param {Object} options - { limit, before, after, searchTerm }
|
|
337
|
+
*/
|
|
338
|
+
async getMessages(chatId, options = {}) {
|
|
339
|
+
this._ensureConnected();
|
|
340
|
+
chatId = await this.resolveChatId(chatId);
|
|
341
|
+
this._ensureChatAllowed(chatId);
|
|
342
|
+
|
|
343
|
+
const { limit = 50, before, after, searchTerm } = options;
|
|
344
|
+
|
|
345
|
+
const chat = await this.client.getChatById(chatId);
|
|
346
|
+
if (!chat) throw new Error(`Chat not found: ${chatId}`);
|
|
347
|
+
|
|
348
|
+
// Fetch messages — whatsapp-web.js uses fetchMessages with limit
|
|
349
|
+
const fetchLimit = searchTerm ? Math.max(limit * 5, 200) : limit;
|
|
350
|
+
const messages = await chat.fetchMessages({ limit: fetchLimit });
|
|
351
|
+
|
|
352
|
+
let filtered = messages;
|
|
353
|
+
|
|
354
|
+
// Date filtering
|
|
355
|
+
if (before) {
|
|
356
|
+
const beforeTs = new Date(before).getTime() / 1000;
|
|
357
|
+
filtered = filtered.filter(m => m.timestamp <= beforeTs);
|
|
358
|
+
}
|
|
359
|
+
if (after) {
|
|
360
|
+
const afterTs = new Date(after).getTime() / 1000;
|
|
361
|
+
filtered = filtered.filter(m => m.timestamp >= afterTs);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Text search
|
|
365
|
+
if (searchTerm) {
|
|
366
|
+
const term = searchTerm.toLowerCase();
|
|
367
|
+
filtered = filtered.filter(m =>
|
|
368
|
+
m.body?.toLowerCase().includes(term)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Apply final limit
|
|
373
|
+
filtered = filtered.slice(-limit);
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
chatId,
|
|
377
|
+
chatName: chat.name || chat.id.user,
|
|
378
|
+
messageCount: filtered.length,
|
|
379
|
+
messages: await Promise.all(filtered.map(m => this._formatMessage(m)))
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Search across multiple chats
|
|
385
|
+
* @param {string} searchTerm
|
|
386
|
+
* @param {Object} options - { chatIds, limit, before, after }
|
|
387
|
+
*/
|
|
388
|
+
async searchMessages(searchTerm, options = {}) {
|
|
389
|
+
this._ensureConnected();
|
|
390
|
+
if (!searchTerm) throw new Error('searchTerm is required');
|
|
391
|
+
|
|
392
|
+
const { chatIds, limit = 30, before, after } = options;
|
|
393
|
+
|
|
394
|
+
// Determine which chats to search (resolve names to IDs)
|
|
395
|
+
let chatsToSearch;
|
|
396
|
+
if (chatIds && chatIds.length > 0) {
|
|
397
|
+
chatsToSearch = await Promise.all(chatIds.map(id => this.resolveChatId(id)));
|
|
398
|
+
} else if (this.allowedChats.length > 0) {
|
|
399
|
+
chatsToSearch = this.allowedChats.map(c => c.id);
|
|
400
|
+
} else {
|
|
401
|
+
// Search all chats — get up to 20 most recent
|
|
402
|
+
const allChats = await this.client.getChats();
|
|
403
|
+
chatsToSearch = allChats.slice(0, 20).map(c => c.id._serialized);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const results = [];
|
|
407
|
+
for (const chatId of chatsToSearch) {
|
|
408
|
+
try {
|
|
409
|
+
const chatResults = await this.getMessages(chatId, {
|
|
410
|
+
limit: Math.ceil(limit / chatsToSearch.length) || 10,
|
|
411
|
+
before,
|
|
412
|
+
after,
|
|
413
|
+
searchTerm
|
|
414
|
+
});
|
|
415
|
+
if (chatResults.messages.length > 0) {
|
|
416
|
+
results.push(chatResults);
|
|
417
|
+
}
|
|
418
|
+
} catch (e) {
|
|
419
|
+
this.logger?.debug('Search skip chat', { chatId, error: e.message });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return {
|
|
424
|
+
searchTerm,
|
|
425
|
+
totalMatches: results.reduce((s, r) => s + r.messageCount, 0),
|
|
426
|
+
chatsSearched: chatsToSearch.length,
|
|
427
|
+
results
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Get media/file from a message
|
|
433
|
+
* @param {string} chatId
|
|
434
|
+
* @param {string} messageId - serialized message ID
|
|
435
|
+
*/
|
|
436
|
+
async getMedia(chatId, messageId) {
|
|
437
|
+
this._ensureConnected();
|
|
438
|
+
chatId = await this.resolveChatId(chatId);
|
|
439
|
+
this._ensureChatAllowed(chatId);
|
|
440
|
+
|
|
441
|
+
const chat = await this.client.getChatById(chatId);
|
|
442
|
+
if (!chat) throw new Error(`Chat not found: ${chatId}`);
|
|
443
|
+
|
|
444
|
+
// Fetch a batch of messages to find the target one
|
|
445
|
+
const messages = await chat.fetchMessages({ limit: 100 });
|
|
446
|
+
const message = messages.find(m => m.id._serialized === messageId);
|
|
447
|
+
|
|
448
|
+
if (!message) throw new Error(`Message not found: ${messageId}`);
|
|
449
|
+
if (!message.hasMedia) throw new Error('Message has no media');
|
|
450
|
+
|
|
451
|
+
const media = await message.downloadMedia();
|
|
452
|
+
if (!media) throw new Error('Failed to download media');
|
|
453
|
+
|
|
454
|
+
// Save to temp dir
|
|
455
|
+
const ext = this._mimeToExt(media.mimetype);
|
|
456
|
+
const filename = `wa-media-${Date.now()}${ext}`;
|
|
457
|
+
const outputDir = path.join(this.dataDir, 'media');
|
|
458
|
+
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
|
|
459
|
+
|
|
460
|
+
const filePath = path.join(outputDir, filename);
|
|
461
|
+
fs.writeFileSync(filePath, media.data, 'base64');
|
|
462
|
+
|
|
463
|
+
return {
|
|
464
|
+
filename,
|
|
465
|
+
mimetype: media.mimetype,
|
|
466
|
+
filePath,
|
|
467
|
+
size: Buffer.from(media.data, 'base64').length
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Get chat info (participants, description, etc.)
|
|
473
|
+
*/
|
|
474
|
+
async getChatInfo(chatId) {
|
|
475
|
+
this._ensureConnected();
|
|
476
|
+
chatId = await this.resolveChatId(chatId);
|
|
477
|
+
this._ensureChatAllowed(chatId);
|
|
478
|
+
|
|
479
|
+
const chat = await this.client.getChatById(chatId);
|
|
480
|
+
if (!chat) throw new Error(`Chat not found: ${chatId}`);
|
|
481
|
+
|
|
482
|
+
const info = {
|
|
483
|
+
id: chat.id._serialized,
|
|
484
|
+
name: chat.name || chat.id.user,
|
|
485
|
+
isGroup: chat.isGroup,
|
|
486
|
+
unreadCount: chat.unreadCount,
|
|
487
|
+
timestamp: chat.timestamp,
|
|
488
|
+
muteExpiration: chat.muteExpiration
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
if (chat.isGroup) {
|
|
492
|
+
info.description = chat.groupMetadata?.desc || '';
|
|
493
|
+
info.participants = (chat.groupMetadata?.participants || []).map(p => ({
|
|
494
|
+
id: p.id._serialized,
|
|
495
|
+
isAdmin: p.isAdmin || false,
|
|
496
|
+
isSuperAdmin: p.isSuperAdmin || false
|
|
497
|
+
}));
|
|
498
|
+
info.participantCount = info.participants.length;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return info;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// ========================
|
|
505
|
+
// Internal helpers
|
|
506
|
+
// ========================
|
|
507
|
+
|
|
508
|
+
setWebSocketManager(wsManager) {
|
|
509
|
+
this.webSocketManager = wsManager;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
_attachClientEvents() {
|
|
513
|
+
this.client.on('qr', (qr) => {
|
|
514
|
+
this.qrCode = qr;
|
|
515
|
+
this.status = WA_STATUS.QR_READY;
|
|
516
|
+
this.logger?.info('WhatsApp QR code generated');
|
|
517
|
+
this._broadcast('whatsapp_qr', { qrCode: qr });
|
|
518
|
+
this._broadcast('whatsapp_status', { status: this.status });
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
this.client.on('authenticated', () => {
|
|
522
|
+
this.status = WA_STATUS.AUTHENTICATING;
|
|
523
|
+
this.qrCode = null;
|
|
524
|
+
this.logger?.info('WhatsApp authenticated');
|
|
525
|
+
this._broadcast('whatsapp_status', { status: this.status });
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
this.client.on('ready', async () => {
|
|
529
|
+
this.status = WA_STATUS.CONNECTED;
|
|
530
|
+
this.qrCode = null;
|
|
531
|
+
|
|
532
|
+
try {
|
|
533
|
+
const info = this.client.info;
|
|
534
|
+
this.currentUser = {
|
|
535
|
+
id: info.wid._serialized,
|
|
536
|
+
name: info.pushname,
|
|
537
|
+
phone: info.wid.user
|
|
538
|
+
};
|
|
539
|
+
} catch (e) {
|
|
540
|
+
this.currentUser = { name: 'Connected' };
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
this.logger?.info('WhatsApp ready', { user: this.currentUser });
|
|
544
|
+
this._broadcast('whatsapp_status', { status: this.status, user: this.currentUser });
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
this.client.on('disconnected', (reason) => {
|
|
548
|
+
this.status = WA_STATUS.DISCONNECTED;
|
|
549
|
+
this.qrCode = null;
|
|
550
|
+
this.currentUser = null;
|
|
551
|
+
this.logger?.warn('WhatsApp disconnected', { reason });
|
|
552
|
+
this._broadcast('whatsapp_status', { status: this.status, reason });
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
this.client.on('auth_failure', (msg) => {
|
|
556
|
+
this.status = WA_STATUS.FAILED;
|
|
557
|
+
this.logger?.error('WhatsApp auth failure', { message: msg });
|
|
558
|
+
this._broadcast('whatsapp_status', { status: this.status, error: msg });
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async _formatMessage(msg) {
|
|
563
|
+
const formatted = {
|
|
564
|
+
id: msg.id._serialized,
|
|
565
|
+
body: msg.body,
|
|
566
|
+
timestamp: msg.timestamp,
|
|
567
|
+
date: new Date(msg.timestamp * 1000).toISOString(),
|
|
568
|
+
fromMe: msg.fromMe,
|
|
569
|
+
author: msg.author || msg.from,
|
|
570
|
+
type: msg.type, // chat, image, video, audio, document, sticker, etc.
|
|
571
|
+
hasMedia: msg.hasMedia,
|
|
572
|
+
isForwarded: msg.isForwarded || false
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// Include contact name if available
|
|
576
|
+
try {
|
|
577
|
+
const contact = await msg.getContact();
|
|
578
|
+
formatted.authorName = contact.pushname || contact.name || contact.number;
|
|
579
|
+
} catch {
|
|
580
|
+
formatted.authorName = formatted.author;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// Media metadata (without downloading)
|
|
584
|
+
if (msg.hasMedia) {
|
|
585
|
+
formatted.mediaType = msg.type;
|
|
586
|
+
if (msg._data?.mimetype) formatted.mimetype = msg._data.mimetype;
|
|
587
|
+
if (msg._data?.filename) formatted.fileName = msg._data.filename;
|
|
588
|
+
if (msg._data?.size) formatted.fileSize = msg._data.size;
|
|
589
|
+
formatted.caption = msg._data?.caption || null;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return formatted;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
_ensureConnected() {
|
|
596
|
+
if (this.status !== WA_STATUS.CONNECTED || !this.client) {
|
|
597
|
+
throw new Error('WhatsApp is not connected. Please link your account first in Settings.');
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
_ensureChatAllowed(chatId) {
|
|
602
|
+
if (!this.isChatAllowed(chatId)) {
|
|
603
|
+
throw new Error(`Access denied: Chat ${chatId} is not in the allowed list. Update allowed chats in Settings.`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
_broadcast(type, data) {
|
|
608
|
+
if (this.webSocketManager) {
|
|
609
|
+
// Broadcast to all sessions
|
|
610
|
+
this.webSocketManager.broadcastToSession(null, {
|
|
611
|
+
type,
|
|
612
|
+
data,
|
|
613
|
+
timestamp: new Date().toISOString()
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
_ensureDirs() {
|
|
619
|
+
for (const dir of [this.dataDir, this.sessionDir]) {
|
|
620
|
+
if (!fs.existsSync(dir)) {
|
|
621
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
_loadConfig() {
|
|
627
|
+
try {
|
|
628
|
+
if (fs.existsSync(this.configPath)) {
|
|
629
|
+
const raw = fs.readFileSync(this.configPath, 'utf-8');
|
|
630
|
+
const config = JSON.parse(raw);
|
|
631
|
+
this.allowedChats = config.allowedChats || [];
|
|
632
|
+
}
|
|
633
|
+
} catch (e) {
|
|
634
|
+
this.logger?.warn('Failed to load WhatsApp config', { error: e.message });
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
_saveConfig() {
|
|
639
|
+
try {
|
|
640
|
+
fs.writeFileSync(this.configPath, JSON.stringify({
|
|
641
|
+
allowedChats: this.allowedChats,
|
|
642
|
+
updatedAt: new Date().toISOString()
|
|
643
|
+
}, null, 2));
|
|
644
|
+
} catch (e) {
|
|
645
|
+
this.logger?.warn('Failed to save WhatsApp config', { error: e.message });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
_mimeToExt(mime) {
|
|
650
|
+
const map = {
|
|
651
|
+
'image/jpeg': '.jpg', 'image/png': '.png', 'image/gif': '.gif', 'image/webp': '.webp',
|
|
652
|
+
'video/mp4': '.mp4', 'audio/ogg': '.ogg', 'audio/mpeg': '.mp3',
|
|
653
|
+
'application/pdf': '.pdf', 'application/msword': '.doc',
|
|
654
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx',
|
|
655
|
+
'application/vnd.ms-excel': '.xls',
|
|
656
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': '.xlsx'
|
|
657
|
+
};
|
|
658
|
+
return map[mime] || '.bin';
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export default WhatsAppService;
|
|
663
|
+
export { WA_STATUS };
|