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,565 @@
|
|
|
1
|
+
import { BUDGET_LIMITS, USAGE_ALERTS } from '../utilities/constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Budget and usage tracking service for monitoring AI model costs and token usage
|
|
5
|
+
*/
|
|
6
|
+
export class BudgetService {
|
|
7
|
+
constructor(config, logger, modelsService = null) {
|
|
8
|
+
this.config = config || {};
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.modelsService = modelsService;
|
|
11
|
+
this.usage = {
|
|
12
|
+
daily: new Map(),
|
|
13
|
+
weekly: new Map(),
|
|
14
|
+
monthly: new Map(),
|
|
15
|
+
total: {
|
|
16
|
+
tokens: 0,
|
|
17
|
+
cost: 0,
|
|
18
|
+
requests: 0
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
this.budgets = {
|
|
23
|
+
daily: BUDGET_LIMITS.DAILY,
|
|
24
|
+
weekly: BUDGET_LIMITS.WEEKLY,
|
|
25
|
+
monthly: BUDGET_LIMITS.MONTHLY
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
this.alerts = {
|
|
29
|
+
enabled: true,
|
|
30
|
+
thresholds: USAGE_ALERTS.THRESHOLDS,
|
|
31
|
+
lastAlertTimes: new Map()
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.loadUsageData();
|
|
35
|
+
this.setupPeriodicSave();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set models service reference (for dynamic pricing lookup)
|
|
40
|
+
* @param {ModelsService} modelsService
|
|
41
|
+
*/
|
|
42
|
+
setModelsService(modelsService) {
|
|
43
|
+
this.modelsService = modelsService;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Track token usage for a specific model and agent
|
|
48
|
+
* @param {string} agentId - Agent identifier
|
|
49
|
+
* @param {string} modelId - Model identifier
|
|
50
|
+
* @param {Object} tokenUsage - Token usage data
|
|
51
|
+
* @param {number} tokenUsage.prompt_tokens - Input tokens used
|
|
52
|
+
* @param {number} tokenUsage.completion_tokens - Output tokens used
|
|
53
|
+
* @param {number} tokenUsage.total_tokens - Total tokens used
|
|
54
|
+
* @returns {Object} Updated usage statistics and cost
|
|
55
|
+
*/
|
|
56
|
+
trackUsage(agentId, modelId, tokenUsage) {
|
|
57
|
+
try {
|
|
58
|
+
const cost = this.calculateCost(modelId, tokenUsage);
|
|
59
|
+
const now = new Date();
|
|
60
|
+
const dayKey = this.getDayKey(now);
|
|
61
|
+
const weekKey = this.getWeekKey(now);
|
|
62
|
+
const monthKey = this.getMonthKey(now);
|
|
63
|
+
|
|
64
|
+
// Initialize usage entries if they don't exist
|
|
65
|
+
this.initializeUsageEntry(this.usage.daily, dayKey);
|
|
66
|
+
this.initializeUsageEntry(this.usage.weekly, weekKey);
|
|
67
|
+
this.initializeUsageEntry(this.usage.monthly, monthKey);
|
|
68
|
+
|
|
69
|
+
// Update usage statistics
|
|
70
|
+
const usageData = {
|
|
71
|
+
agentId,
|
|
72
|
+
modelId,
|
|
73
|
+
tokens: tokenUsage.total_tokens,
|
|
74
|
+
cost,
|
|
75
|
+
timestamp: now.toISOString()
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
this.updateUsageEntry(this.usage.daily.get(dayKey), usageData);
|
|
79
|
+
this.updateUsageEntry(this.usage.weekly.get(weekKey), usageData);
|
|
80
|
+
this.updateUsageEntry(this.usage.monthly.get(monthKey), usageData);
|
|
81
|
+
|
|
82
|
+
// Update total usage
|
|
83
|
+
this.usage.total.tokens += tokenUsage.total_tokens;
|
|
84
|
+
this.usage.total.cost += cost;
|
|
85
|
+
this.usage.total.requests += 1;
|
|
86
|
+
|
|
87
|
+
// Check budget limits and send alerts if necessary
|
|
88
|
+
this.checkBudgetLimits(dayKey, weekKey, monthKey);
|
|
89
|
+
|
|
90
|
+
this.logger.info('Usage tracked', {
|
|
91
|
+
agentId,
|
|
92
|
+
modelId,
|
|
93
|
+
tokens: tokenUsage.total_tokens,
|
|
94
|
+
cost,
|
|
95
|
+
totalCost: this.usage.total.cost
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
cost,
|
|
100
|
+
totalCost: this.usage.total.cost,
|
|
101
|
+
totalTokens: this.usage.total.tokens,
|
|
102
|
+
dailyUsage: this.usage.daily.get(dayKey),
|
|
103
|
+
budgetRemaining: this.getRemainingBudget()
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
} catch (error) {
|
|
107
|
+
this.logger.error('Failed to track usage', { error: error.message, agentId, modelId });
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Calculate cost based on model and token usage
|
|
114
|
+
* @param {string} modelId - Model identifier
|
|
115
|
+
* @param {Object} tokenUsage - Token usage data
|
|
116
|
+
* @returns {number} Cost in USD
|
|
117
|
+
*/
|
|
118
|
+
calculateCost(modelId, tokenUsage) {
|
|
119
|
+
// Look up pricing from modelsService (single source of truth from /models API)
|
|
120
|
+
const pricing = this._getModelPricing(modelId);
|
|
121
|
+
|
|
122
|
+
if (!pricing) {
|
|
123
|
+
this.logger.debug('No pricing available for model', { modelId });
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// pricing.input and pricing.output are per-1K-token rates from the API
|
|
128
|
+
const inputCost = (tokenUsage.prompt_tokens || 0) * (pricing.input / 1000);
|
|
129
|
+
const outputCost = (tokenUsage.completion_tokens || 0) * (pricing.output / 1000);
|
|
130
|
+
|
|
131
|
+
return inputCost + outputCost;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get pricing for a model from modelsService.
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
_getModelPricing(modelId) {
|
|
139
|
+
if (!this.modelsService) return null;
|
|
140
|
+
try {
|
|
141
|
+
const models = this.modelsService.getModels();
|
|
142
|
+
const modelInfo = models.find(m => m.name === modelId);
|
|
143
|
+
return modelInfo?.pricing || null;
|
|
144
|
+
} catch {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get current usage statistics
|
|
151
|
+
* @param {string} period - 'daily', 'weekly', 'monthly', or 'total'
|
|
152
|
+
* @param {Date} date - Date for the period (optional, defaults to now)
|
|
153
|
+
* @returns {Object} Usage statistics
|
|
154
|
+
*/
|
|
155
|
+
getUsage(period = 'daily', date = new Date()) {
|
|
156
|
+
switch (period) {
|
|
157
|
+
case 'daily':
|
|
158
|
+
return this.usage.daily.get(this.getDayKey(date)) || this.createEmptyUsage();
|
|
159
|
+
case 'weekly':
|
|
160
|
+
return this.usage.weekly.get(this.getWeekKey(date)) || this.createEmptyUsage();
|
|
161
|
+
case 'monthly':
|
|
162
|
+
return this.usage.monthly.get(this.getMonthKey(date)) || this.createEmptyUsage();
|
|
163
|
+
case 'total':
|
|
164
|
+
return { ...this.usage.total };
|
|
165
|
+
default:
|
|
166
|
+
throw new Error(`Invalid period: ${period}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Get usage by agent
|
|
172
|
+
* @param {string} agentId - Agent identifier
|
|
173
|
+
* @param {string} period - 'daily', 'weekly', 'monthly', or 'total'
|
|
174
|
+
* @returns {Object} Agent-specific usage statistics
|
|
175
|
+
*/
|
|
176
|
+
getAgentUsage(agentId, period = 'daily') {
|
|
177
|
+
const usage = this.getUsage(period);
|
|
178
|
+
return usage.byAgent?.[agentId] || this.createEmptyUsage();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get usage by model
|
|
183
|
+
* @param {string} modelId - Model identifier
|
|
184
|
+
* @param {string} period - 'daily', 'weekly', 'monthly', or 'total'
|
|
185
|
+
* @returns {Object} Model-specific usage statistics
|
|
186
|
+
*/
|
|
187
|
+
getModelUsage(modelId, period = 'daily') {
|
|
188
|
+
const usage = this.getUsage(period);
|
|
189
|
+
return usage.byModel?.[modelId] || this.createEmptyUsage();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Set budget limits
|
|
194
|
+
* @param {Object} budgets - Budget configuration
|
|
195
|
+
* @param {number} budgets.daily - Daily budget limit in USD
|
|
196
|
+
* @param {number} budgets.weekly - Weekly budget limit in USD
|
|
197
|
+
* @param {number} budgets.monthly - Monthly budget limit in USD
|
|
198
|
+
*/
|
|
199
|
+
setBudgets(budgets) {
|
|
200
|
+
if (budgets.daily !== undefined) this.budgets.daily = budgets.daily;
|
|
201
|
+
if (budgets.weekly !== undefined) this.budgets.weekly = budgets.weekly;
|
|
202
|
+
if (budgets.monthly !== undefined) this.budgets.monthly = budgets.monthly;
|
|
203
|
+
|
|
204
|
+
this.logger.info('Budget limits updated', this.budgets);
|
|
205
|
+
this.saveUsageData();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get remaining budget for each period
|
|
210
|
+
* @returns {Object} Remaining budget amounts
|
|
211
|
+
*/
|
|
212
|
+
getRemainingBudget() {
|
|
213
|
+
const now = new Date();
|
|
214
|
+
const dailyUsage = this.getUsage('daily', now);
|
|
215
|
+
const weeklyUsage = this.getUsage('weekly', now);
|
|
216
|
+
const monthlyUsage = this.getUsage('monthly', now);
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
daily: Math.max(0, this.budgets.daily - dailyUsage.cost),
|
|
220
|
+
weekly: Math.max(0, this.budgets.weekly - weeklyUsage.cost),
|
|
221
|
+
monthly: Math.max(0, this.budgets.monthly - monthlyUsage.cost)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Check if usage is within budget limits
|
|
227
|
+
* @param {string} period - 'daily', 'weekly', or 'monthly'
|
|
228
|
+
* @returns {boolean} True if within budget
|
|
229
|
+
*/
|
|
230
|
+
isWithinBudget(period = 'daily') {
|
|
231
|
+
const usage = this.getUsage(period);
|
|
232
|
+
const budget = this.budgets[period];
|
|
233
|
+
return usage.cost <= budget;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Get usage trends and analytics
|
|
238
|
+
* @param {number} days - Number of days to analyze
|
|
239
|
+
* @returns {Object} Usage trends and analytics
|
|
240
|
+
*/
|
|
241
|
+
getUsageTrends(days = 30) {
|
|
242
|
+
const trends = {
|
|
243
|
+
dailyAverages: {
|
|
244
|
+
cost: 0,
|
|
245
|
+
tokens: 0,
|
|
246
|
+
requests: 0
|
|
247
|
+
},
|
|
248
|
+
topAgents: [],
|
|
249
|
+
topModels: [],
|
|
250
|
+
costByDay: [],
|
|
251
|
+
tokensByDay: []
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const now = new Date();
|
|
255
|
+
let totalCost = 0;
|
|
256
|
+
let totalTokens = 0;
|
|
257
|
+
let totalRequests = 0;
|
|
258
|
+
const agentUsage = new Map();
|
|
259
|
+
const modelUsage = new Map();
|
|
260
|
+
|
|
261
|
+
// Analyze daily usage for the specified period
|
|
262
|
+
for (let i = 0; i < days; i++) {
|
|
263
|
+
const date = new Date(now);
|
|
264
|
+
date.setDate(date.getDate() - i);
|
|
265
|
+
const dayKey = this.getDayKey(date);
|
|
266
|
+
const dayUsage = this.usage.daily.get(dayKey);
|
|
267
|
+
|
|
268
|
+
if (dayUsage) {
|
|
269
|
+
totalCost += dayUsage.cost;
|
|
270
|
+
totalTokens += dayUsage.tokens;
|
|
271
|
+
totalRequests += dayUsage.requests;
|
|
272
|
+
|
|
273
|
+
trends.costByDay.unshift({ date: dayKey, cost: dayUsage.cost });
|
|
274
|
+
trends.tokensByDay.unshift({ date: dayKey, tokens: dayUsage.tokens });
|
|
275
|
+
|
|
276
|
+
// Aggregate agent usage
|
|
277
|
+
Object.entries(dayUsage.byAgent || {}).forEach(([agentId, usage]) => {
|
|
278
|
+
if (!agentUsage.has(agentId)) {
|
|
279
|
+
agentUsage.set(agentId, { cost: 0, tokens: 0, requests: 0 });
|
|
280
|
+
}
|
|
281
|
+
const current = agentUsage.get(agentId);
|
|
282
|
+
current.cost += usage.cost;
|
|
283
|
+
current.tokens += usage.tokens;
|
|
284
|
+
current.requests += usage.requests;
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Aggregate model usage
|
|
288
|
+
Object.entries(dayUsage.byModel || {}).forEach(([modelId, usage]) => {
|
|
289
|
+
if (!modelUsage.has(modelId)) {
|
|
290
|
+
modelUsage.set(modelId, { cost: 0, tokens: 0, requests: 0 });
|
|
291
|
+
}
|
|
292
|
+
const current = modelUsage.get(modelId);
|
|
293
|
+
current.cost += usage.cost;
|
|
294
|
+
current.tokens += usage.tokens;
|
|
295
|
+
current.requests += usage.requests;
|
|
296
|
+
});
|
|
297
|
+
} else {
|
|
298
|
+
trends.costByDay.unshift({ date: dayKey, cost: 0 });
|
|
299
|
+
trends.tokensByDay.unshift({ date: dayKey, tokens: 0 });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Calculate averages
|
|
304
|
+
trends.dailyAverages.cost = totalCost / days;
|
|
305
|
+
trends.dailyAverages.tokens = totalTokens / days;
|
|
306
|
+
trends.dailyAverages.requests = totalRequests / days;
|
|
307
|
+
|
|
308
|
+
// Sort and get top agents and models
|
|
309
|
+
trends.topAgents = Array.from(agentUsage.entries())
|
|
310
|
+
.map(([id, usage]) => ({ id, ...usage }))
|
|
311
|
+
.sort((a, b) => b.cost - a.cost)
|
|
312
|
+
.slice(0, 10);
|
|
313
|
+
|
|
314
|
+
trends.topModels = Array.from(modelUsage.entries())
|
|
315
|
+
.map(([id, usage]) => ({ id, ...usage }))
|
|
316
|
+
.sort((a, b) => b.cost - a.cost)
|
|
317
|
+
.slice(0, 10);
|
|
318
|
+
|
|
319
|
+
return trends;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Export usage data for reporting
|
|
324
|
+
* @param {string} format - 'json' or 'csv'
|
|
325
|
+
* @param {Date} startDate - Start date for export
|
|
326
|
+
* @param {Date} endDate - End date for export
|
|
327
|
+
* @returns {string} Exported data
|
|
328
|
+
*/
|
|
329
|
+
exportUsageData(format = 'json', startDate = null, endDate = null) {
|
|
330
|
+
const data = {
|
|
331
|
+
budgets: this.budgets,
|
|
332
|
+
total: this.usage.total,
|
|
333
|
+
daily: {},
|
|
334
|
+
weekly: {},
|
|
335
|
+
monthly: {}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// Filter data by date range if specified
|
|
339
|
+
const filterByDateRange = (entries, keyFormatter) => {
|
|
340
|
+
const filtered = {};
|
|
341
|
+
entries.forEach((usage, key) => {
|
|
342
|
+
const date = keyFormatter(key);
|
|
343
|
+
if ((!startDate || date >= startDate) && (!endDate || date <= endDate)) {
|
|
344
|
+
filtered[key] = usage;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
return filtered;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
if (startDate || endDate) {
|
|
351
|
+
data.daily = filterByDateRange(this.usage.daily, key => new Date(key));
|
|
352
|
+
data.weekly = filterByDateRange(this.usage.weekly, key => new Date(key));
|
|
353
|
+
data.monthly = filterByDateRange(this.usage.monthly, key => new Date(key + '-01'));
|
|
354
|
+
} else {
|
|
355
|
+
this.usage.daily.forEach((usage, key) => data.daily[key] = usage);
|
|
356
|
+
this.usage.weekly.forEach((usage, key) => data.weekly[key] = usage);
|
|
357
|
+
this.usage.monthly.forEach((usage, key) => data.monthly[key] = usage);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (format === 'csv') {
|
|
361
|
+
return this.convertToCSV(data);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return JSON.stringify(data, null, 2);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Private helper methods
|
|
368
|
+
|
|
369
|
+
initializeUsageEntry(usageMap, key) {
|
|
370
|
+
if (!usageMap.has(key)) {
|
|
371
|
+
usageMap.set(key, this.createEmptyUsage());
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
createEmptyUsage() {
|
|
376
|
+
return {
|
|
377
|
+
cost: 0,
|
|
378
|
+
tokens: 0,
|
|
379
|
+
requests: 0,
|
|
380
|
+
byAgent: {},
|
|
381
|
+
byModel: {}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
updateUsageEntry(entry, usageData) {
|
|
386
|
+
entry.cost += usageData.cost;
|
|
387
|
+
entry.tokens += usageData.tokens;
|
|
388
|
+
entry.requests += 1;
|
|
389
|
+
|
|
390
|
+
// Update by agent
|
|
391
|
+
if (!entry.byAgent[usageData.agentId]) {
|
|
392
|
+
entry.byAgent[usageData.agentId] = this.createEmptyUsage();
|
|
393
|
+
}
|
|
394
|
+
entry.byAgent[usageData.agentId].cost += usageData.cost;
|
|
395
|
+
entry.byAgent[usageData.agentId].tokens += usageData.tokens;
|
|
396
|
+
entry.byAgent[usageData.agentId].requests += 1;
|
|
397
|
+
|
|
398
|
+
// Update by model
|
|
399
|
+
if (!entry.byModel[usageData.modelId]) {
|
|
400
|
+
entry.byModel[usageData.modelId] = this.createEmptyUsage();
|
|
401
|
+
}
|
|
402
|
+
entry.byModel[usageData.modelId].cost += usageData.cost;
|
|
403
|
+
entry.byModel[usageData.modelId].tokens += usageData.tokens;
|
|
404
|
+
entry.byModel[usageData.modelId].requests += 1;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
checkBudgetLimits(dayKey, weekKey, monthKey) {
|
|
408
|
+
const dailyUsage = this.usage.daily.get(dayKey);
|
|
409
|
+
const weeklyUsage = this.usage.weekly.get(weekKey);
|
|
410
|
+
const monthlyUsage = this.usage.monthly.get(monthKey);
|
|
411
|
+
|
|
412
|
+
// Check daily budget
|
|
413
|
+
if (dailyUsage.cost > this.budgets.daily) {
|
|
414
|
+
this.sendBudgetAlert('daily', dailyUsage.cost, this.budgets.daily);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Check weekly budget
|
|
418
|
+
if (weeklyUsage.cost > this.budgets.weekly) {
|
|
419
|
+
this.sendBudgetAlert('weekly', weeklyUsage.cost, this.budgets.weekly);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Check monthly budget
|
|
423
|
+
if (monthlyUsage.cost > this.budgets.monthly) {
|
|
424
|
+
this.sendBudgetAlert('monthly', monthlyUsage.cost, this.budgets.monthly);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Check threshold alerts
|
|
428
|
+
this.checkThresholdAlerts(dailyUsage, weeklyUsage, monthlyUsage);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
checkThresholdAlerts(dailyUsage, weeklyUsage, monthlyUsage) {
|
|
432
|
+
const thresholds = this.alerts.thresholds;
|
|
433
|
+
|
|
434
|
+
this.checkThreshold('daily', dailyUsage.cost, this.budgets.daily, thresholds);
|
|
435
|
+
this.checkThreshold('weekly', weeklyUsage.cost, this.budgets.weekly, thresholds);
|
|
436
|
+
this.checkThreshold('monthly', monthlyUsage.cost, this.budgets.monthly, thresholds);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
checkThreshold(period, usage, budget, thresholds) {
|
|
440
|
+
const percentage = (usage / budget) * 100;
|
|
441
|
+
|
|
442
|
+
for (const threshold of thresholds) {
|
|
443
|
+
if (percentage >= threshold) {
|
|
444
|
+
const alertKey = `${period}_${threshold}`;
|
|
445
|
+
const lastAlert = this.alerts.lastAlertTimes.get(alertKey);
|
|
446
|
+
const now = Date.now();
|
|
447
|
+
|
|
448
|
+
// Only send alert if we haven't sent one in the last hour
|
|
449
|
+
if (!lastAlert || (now - lastAlert) > 3600000) {
|
|
450
|
+
this.sendThresholdAlert(period, percentage, threshold, usage, budget);
|
|
451
|
+
this.alerts.lastAlertTimes.set(alertKey, now);
|
|
452
|
+
}
|
|
453
|
+
break; // Only send the highest threshold alert
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
sendBudgetAlert(period, currentUsage, budgetLimit) {
|
|
459
|
+
this.logger.warn('Budget limit exceeded', {
|
|
460
|
+
period,
|
|
461
|
+
currentUsage,
|
|
462
|
+
budgetLimit,
|
|
463
|
+
excess: currentUsage - budgetLimit
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Emit event for external handling
|
|
467
|
+
if (typeof process !== 'undefined' && process.emit) {
|
|
468
|
+
process.emit('budgetAlert', {
|
|
469
|
+
type: 'budget_exceeded',
|
|
470
|
+
period,
|
|
471
|
+
currentUsage,
|
|
472
|
+
budgetLimit,
|
|
473
|
+
excess: currentUsage - budgetLimit
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
sendThresholdAlert(period, percentage, threshold, usage, budget) {
|
|
479
|
+
this.logger.warn('Budget threshold reached', {
|
|
480
|
+
period,
|
|
481
|
+
percentage: Math.round(percentage),
|
|
482
|
+
threshold,
|
|
483
|
+
usage,
|
|
484
|
+
budget
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// Emit event for external handling
|
|
488
|
+
if (typeof process !== 'undefined' && process.emit) {
|
|
489
|
+
process.emit('budgetAlert', {
|
|
490
|
+
type: 'threshold_reached',
|
|
491
|
+
period,
|
|
492
|
+
percentage: Math.round(percentage),
|
|
493
|
+
threshold,
|
|
494
|
+
usage,
|
|
495
|
+
budget
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
getDayKey(date) {
|
|
501
|
+
return date.toISOString().split('T')[0];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
getWeekKey(date) {
|
|
505
|
+
const year = date.getFullYear();
|
|
506
|
+
const weekNum = this.getWeekNumber(date);
|
|
507
|
+
return `${year}-W${weekNum.toString().padStart(2, '0')}`;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
getMonthKey(date) {
|
|
511
|
+
const year = date.getFullYear();
|
|
512
|
+
const month = date.getMonth() + 1;
|
|
513
|
+
return `${year}-${month.toString().padStart(2, '0')}`;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
getWeekNumber(date) {
|
|
517
|
+
const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
|
|
518
|
+
const pastDaysOfYear = (date - firstDayOfYear) / 86400000;
|
|
519
|
+
return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
convertToCSV(data) {
|
|
523
|
+
const rows = [];
|
|
524
|
+
rows.push(['Period', 'Date', 'Cost', 'Tokens', 'Requests', 'Agent', 'Model']);
|
|
525
|
+
|
|
526
|
+
// Convert daily data
|
|
527
|
+
Object.entries(data.daily).forEach(([date, usage]) => {
|
|
528
|
+
rows.push(['Daily', date, usage.cost, usage.tokens, usage.requests, '', '']);
|
|
529
|
+
|
|
530
|
+
Object.entries(usage.byAgent || {}).forEach(([agentId, agentUsage]) => {
|
|
531
|
+
rows.push(['Daily', date, agentUsage.cost, agentUsage.tokens, agentUsage.requests, agentId, '']);
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
return rows.map(row => row.join(',')).join('\n');
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
loadUsageData() {
|
|
539
|
+
try {
|
|
540
|
+
// In a real implementation, this would load from persistent storage
|
|
541
|
+
// For now, we'll just initialize with empty data
|
|
542
|
+
this.logger.info('Budget service initialized');
|
|
543
|
+
} catch (error) {
|
|
544
|
+
this.logger.error('Failed to load usage data', { error: error.message });
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
saveUsageData() {
|
|
549
|
+
try {
|
|
550
|
+
// In a real implementation, this would save to persistent storage
|
|
551
|
+
this.logger.debug('Usage data saved');
|
|
552
|
+
} catch (error) {
|
|
553
|
+
this.logger.error('Failed to save usage data', { error: error.message });
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
setupPeriodicSave() {
|
|
558
|
+
// Save usage data every 5 minutes
|
|
559
|
+
setInterval(() => {
|
|
560
|
+
this.saveUsageData();
|
|
561
|
+
}, 300000);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export default BudgetService;
|