@belboy47/brc-agent 0.0.0-stage → 2.0.18
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 +30 -0
- package/LICENSE-desktop-commander +21 -0
- package/NOTICE +13 -0
- package/README.md +64 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +487 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.d.ts +31 -0
- package/dist/context.js +11 -0
- package/dist/context.js.map +1 -0
- package/dist/core/command-manager.d.ts +8 -0
- package/dist/core/command-manager.js +242 -0
- package/dist/core/command-manager.js.map +1 -0
- package/dist/core/config-field-definitions.d.ts +41 -0
- package/dist/core/config-field-definitions.js +38 -0
- package/dist/core/config-field-definitions.js.map +1 -0
- package/dist/core/config-manager.d.ts +102 -0
- package/dist/core/config-manager.js +451 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/config.js +20 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/custom-stdio.d.ts +9 -0
- package/dist/core/custom-stdio.js +2 -0
- package/dist/core/custom-stdio.js.map +1 -0
- package/dist/core/error-handlers.d.ts +7 -0
- package/dist/core/error-handlers.js +16 -0
- package/dist/core/error-handlers.js.map +1 -0
- package/dist/core/file-transfer.d.ts +16 -0
- package/dist/core/file-transfer.js +316 -0
- package/dist/core/file-transfer.js.map +1 -0
- package/dist/core/handlers/edit-search-handlers.d.ts +6 -0
- package/dist/core/handlers/edit-search-handlers.js +7 -0
- package/dist/core/handlers/edit-search-handlers.js.map +1 -0
- package/dist/core/handlers/filesystem-handlers.d.ts +38 -0
- package/dist/core/handlers/filesystem-handlers.js +535 -0
- package/dist/core/handlers/filesystem-handlers.js.map +1 -0
- package/dist/core/handlers/history-handlers.d.ts +12 -0
- package/dist/core/handlers/history-handlers.js +68 -0
- package/dist/core/handlers/history-handlers.js.map +1 -0
- package/dist/core/handlers/index.d.ts +7 -0
- package/dist/core/handlers/index.js +9 -0
- package/dist/core/handlers/index.js.map +1 -0
- package/dist/core/handlers/process-handlers.d.ts +9 -0
- package/dist/core/handlers/process-handlers.js +16 -0
- package/dist/core/handlers/process-handlers.js.map +1 -0
- package/dist/core/handlers/search-handlers.d.ts +17 -0
- package/dist/core/handlers/search-handlers.js +336 -0
- package/dist/core/handlers/search-handlers.js.map +1 -0
- package/dist/core/handlers/terminal-handlers.d.ts +21 -0
- package/dist/core/handlers/terminal-handlers.js +36 -0
- package/dist/core/handlers/terminal-handlers.js.map +1 -0
- package/dist/core/handlers/transfer-handlers.d.ts +4 -0
- package/dist/core/handlers/transfer-handlers.js +76 -0
- package/dist/core/handlers/transfer-handlers.js.map +1 -0
- package/dist/core/search-manager.d.ts +162 -0
- package/dist/core/search-manager.js +929 -0
- package/dist/core/search-manager.js.map +1 -0
- package/dist/core/terminal-manager.d.ts +126 -0
- package/dist/core/terminal-manager.js +671 -0
- package/dist/core/terminal-manager.js.map +1 -0
- package/dist/core/tool-definitions.d.ts +9 -0
- package/dist/core/tool-definitions.js +1020 -0
- package/dist/core/tool-definitions.js.map +1 -0
- package/dist/core/tools/config.d.ts +98 -0
- package/dist/core/tools/config.js +279 -0
- package/dist/core/tools/config.js.map +1 -0
- package/dist/core/tools/edit.d.ts +49 -0
- package/dist/core/tools/edit.js +540 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/feedback.d.ts +8 -0
- package/dist/core/tools/feedback.js +133 -0
- package/dist/core/tools/feedback.js.map +1 -0
- package/dist/core/tools/filesystem.d.ts +84 -0
- package/dist/core/tools/filesystem.js +991 -0
- package/dist/core/tools/filesystem.js.map +1 -0
- package/dist/core/tools/fuzzySearch.d.ts +14 -0
- package/dist/core/tools/fuzzySearch.js +141 -0
- package/dist/core/tools/fuzzySearch.js.map +1 -0
- package/dist/core/tools/fuzzySearchCore.d.ts +52 -0
- package/dist/core/tools/fuzzySearchCore.js +126 -0
- package/dist/core/tools/fuzzySearchCore.js.map +1 -0
- package/dist/core/tools/improved-process-tools.d.ts +24 -0
- package/dist/core/tools/improved-process-tools.js +645 -0
- package/dist/core/tools/improved-process-tools.js.map +1 -0
- package/dist/core/tools/mime-types.d.ts +3 -0
- package/dist/core/tools/mime-types.js +29 -0
- package/dist/core/tools/mime-types.js.map +1 -0
- package/dist/core/tools/pdf/extract-images.d.ts +34 -0
- package/dist/core/tools/pdf/extract-images.js +133 -0
- package/dist/core/tools/pdf/extract-images.js.map +1 -0
- package/dist/core/tools/pdf/index.d.ts +6 -0
- package/dist/core/tools/pdf/index.js +4 -0
- package/dist/core/tools/pdf/index.js.map +1 -0
- package/dist/core/tools/pdf/lib/pdf2md.d.ts +36 -0
- package/dist/core/tools/pdf/lib/pdf2md.js +77 -0
- package/dist/core/tools/pdf/lib/pdf2md.js.map +1 -0
- package/dist/core/tools/pdf/manipulations.d.ts +13 -0
- package/dist/core/tools/pdf/manipulations.js +100 -0
- package/dist/core/tools/pdf/manipulations.js.map +1 -0
- package/dist/core/tools/pdf/markdown.d.ts +26 -0
- package/dist/core/tools/pdf/markdown.js +276 -0
- package/dist/core/tools/pdf/markdown.js.map +1 -0
- package/dist/core/tools/pdf/utils.d.ts +12 -0
- package/dist/core/tools/pdf/utils.js +35 -0
- package/dist/core/tools/pdf/utils.js.map +1 -0
- package/dist/core/tools/process.d.ts +17 -0
- package/dist/core/tools/process.js +88 -0
- package/dist/core/tools/process.js.map +1 -0
- package/dist/core/tools/prompts.d.ts +28 -0
- package/dist/core/tools/prompts.js +260 -0
- package/dist/core/tools/prompts.js.map +1 -0
- package/dist/core/tools/schemas.d.ts +594 -0
- package/dist/core/tools/schemas.js +282 -0
- package/dist/core/tools/schemas.js.map +1 -0
- package/dist/core/tools/usage.d.ts +5 -0
- package/dist/core/tools/usage.js +25 -0
- package/dist/core/tools/usage.js.map +1 -0
- package/dist/core/types.d.ts +83 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/ui/file-preview/shared/preview-file-types.d.ts +5 -0
- package/dist/core/ui/file-preview/shared/preview-file-types.js +60 -0
- package/dist/core/ui/file-preview/shared/preview-file-types.js.map +1 -0
- package/dist/core/utils/ab-test.d.ts +12 -0
- package/dist/core/utils/ab-test.js +105 -0
- package/dist/core/utils/ab-test.js.map +1 -0
- package/dist/core/utils/capture.d.ts +12 -0
- package/dist/core/utils/capture.js +38 -0
- package/dist/core/utils/capture.js.map +1 -0
- package/dist/core/utils/dockerPrompt.d.ts +17 -0
- package/dist/core/utils/dockerPrompt.js +54 -0
- package/dist/core/utils/dockerPrompt.js.map +1 -0
- package/dist/core/utils/feature-flags.d.ts +59 -0
- package/dist/core/utils/feature-flags.js +218 -0
- package/dist/core/utils/feature-flags.js.map +1 -0
- package/dist/core/utils/files/base.d.ts +173 -0
- package/dist/core/utils/files/base.js +6 -0
- package/dist/core/utils/files/base.js.map +1 -0
- package/dist/core/utils/files/binary.d.ts +21 -0
- package/dist/core/utils/files/binary.js +66 -0
- package/dist/core/utils/files/binary.js.map +1 -0
- package/dist/core/utils/files/docx.d.ts +47 -0
- package/dist/core/utils/files/docx.js +678 -0
- package/dist/core/utils/files/docx.js.map +1 -0
- package/dist/core/utils/files/excel.d.ts +24 -0
- package/dist/core/utils/files/excel.js +438 -0
- package/dist/core/utils/files/excel.js.map +1 -0
- package/dist/core/utils/files/factory.d.ts +29 -0
- package/dist/core/utils/files/factory.js +103 -0
- package/dist/core/utils/files/factory.js.map +1 -0
- package/dist/core/utils/files/image.d.ts +21 -0
- package/dist/core/utils/files/image.js +79 -0
- package/dist/core/utils/files/image.js.map +1 -0
- package/dist/core/utils/files/index.d.ts +9 -0
- package/dist/core/utils/files/index.js +15 -0
- package/dist/core/utils/files/index.js.map +1 -0
- package/dist/core/utils/files/pdf.d.ts +32 -0
- package/dist/core/utils/files/pdf.js +141 -0
- package/dist/core/utils/files/pdf.js.map +1 -0
- package/dist/core/utils/files/text.d.ts +70 -0
- package/dist/core/utils/files/text.js +552 -0
- package/dist/core/utils/files/text.js.map +1 -0
- package/dist/core/utils/fuzzySearchLogger.d.ts +26 -0
- package/dist/core/utils/fuzzySearchLogger.js +9 -0
- package/dist/core/utils/fuzzySearchLogger.js.map +1 -0
- package/dist/core/utils/lineEndingHandler.d.ts +21 -0
- package/dist/core/utils/lineEndingHandler.js +78 -0
- package/dist/core/utils/lineEndingHandler.js.map +1 -0
- package/dist/core/utils/logger.d.ts +17 -0
- package/dist/core/utils/logger.js +5 -0
- package/dist/core/utils/logger.js.map +1 -0
- package/dist/core/utils/mcp-ui-ab-test.d.ts +13 -0
- package/dist/core/utils/mcp-ui-ab-test.js +63 -0
- package/dist/core/utils/mcp-ui-ab-test.js.map +1 -0
- package/dist/core/utils/open-browser.d.ts +9 -0
- package/dist/core/utils/open-browser.js +47 -0
- package/dist/core/utils/open-browser.js.map +1 -0
- package/dist/core/utils/process-detection.d.ts +23 -0
- package/dist/core/utils/process-detection.js +151 -0
- package/dist/core/utils/process-detection.js.map +1 -0
- package/dist/core/utils/ripgrep-resolver.d.ts +9 -0
- package/dist/core/utils/ripgrep-resolver.js +96 -0
- package/dist/core/utils/ripgrep-resolver.js.map +1 -0
- package/dist/core/utils/system-info.d.ts +72 -0
- package/dist/core/utils/system-info.js +723 -0
- package/dist/core/utils/system-info.js.map +1 -0
- package/dist/core/utils/toolHistory.d.ts +31 -0
- package/dist/core/utils/toolHistory.js +17 -0
- package/dist/core/utils/toolHistory.js.map +1 -0
- package/dist/core/utils/trackTools.d.ts +1 -0
- package/dist/core/utils/trackTools.js +3 -0
- package/dist/core/utils/trackTools.js.map +1 -0
- package/dist/core/utils/unsupportedParams.d.ts +24 -0
- package/dist/core/utils/unsupportedParams.js +67 -0
- package/dist/core/utils/unsupportedParams.js.map +1 -0
- package/dist/core/utils/usageTracker.d.ts +125 -0
- package/dist/core/utils/usageTracker.js +475 -0
- package/dist/core/utils/usageTracker.js.map +1 -0
- package/dist/core/utils/welcome-onboarding.d.ts +11 -0
- package/dist/core/utils/welcome-onboarding.js +100 -0
- package/dist/core/utils/welcome-onboarding.js.map +1 -0
- package/dist/core/utils/withTimeout.d.ts +28 -0
- package/dist/core/utils/withTimeout.js +86 -0
- package/dist/core/utils/withTimeout.js.map +1 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +2 -0
- package/dist/core/version.js.map +1 -0
- package/dist/dispatcher.d.ts +7 -0
- package/dist/dispatcher.js +179 -0
- package/dist/dispatcher.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/cli-commands.d.ts +5 -0
- package/dist/plugins/cli-commands.js +240 -0
- package/dist/plugins/cli-commands.js.map +1 -0
- package/dist/plugins/defaults.d.ts +62 -0
- package/dist/plugins/defaults.js +260 -0
- package/dist/plugins/defaults.js.map +1 -0
- package/dist/plugins/first-run.d.ts +16 -0
- package/dist/plugins/first-run.js +89 -0
- package/dist/plugins/first-run.js.map +1 -0
- package/dist/plugins/host.d.ts +20 -0
- package/dist/plugins/host.js +175 -0
- package/dist/plugins/host.js.map +1 -0
- package/dist/plugins/installer.d.ts +21 -0
- package/dist/plugins/installer.js +350 -0
- package/dist/plugins/installer.js.map +1 -0
- package/dist/plugins/locate.d.ts +15 -0
- package/dist/plugins/locate.js +99 -0
- package/dist/plugins/locate.js.map +1 -0
- package/dist/plugins/manager.d.ts +32 -0
- package/dist/plugins/manager.js +139 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/paths.d.ts +32 -0
- package/dist/plugins/paths.js +49 -0
- package/dist/plugins/paths.js.map +1 -0
- package/dist/plugins/python.d.ts +55 -0
- package/dist/plugins/python.js +234 -0
- package/dist/plugins/python.js.map +1 -0
- package/dist/plugins/store.d.ts +12 -0
- package/dist/plugins/store.js +76 -0
- package/dist/plugins/store.js.map +1 -0
- package/dist/plugins/types.d.ts +112 -0
- package/dist/plugins/types.js +9 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/util.d.ts +37 -0
- package/dist/plugins/util.js +283 -0
- package/dist/plugins/util.js.map +1 -0
- package/dist/runtime/activity.d.ts +49 -0
- package/dist/runtime/activity.js +158 -0
- package/dist/runtime/activity.js.map +1 -0
- package/dist/runtime/browser-workflow.d.ts +21 -0
- package/dist/runtime/browser-workflow.js +51 -0
- package/dist/runtime/browser-workflow.js.map +1 -0
- package/dist/runtime/code-graph.d.ts +156 -0
- package/dist/runtime/code-graph.js +330 -0
- package/dist/runtime/code-graph.js.map +1 -0
- package/dist/runtime/code-structure.d.ts +53 -0
- package/dist/runtime/code-structure.js +152 -0
- package/dist/runtime/code-structure.js.map +1 -0
- package/dist/runtime/coding-session.d.ts +97 -0
- package/dist/runtime/coding-session.js +142 -0
- package/dist/runtime/coding-session.js.map +1 -0
- package/dist/runtime/detach.d.ts +114 -0
- package/dist/runtime/detach.js +505 -0
- package/dist/runtime/detach.js.map +1 -0
- package/dist/runtime/docker-client.d.ts +47 -0
- package/dist/runtime/docker-client.js +40 -0
- package/dist/runtime/docker-client.js.map +1 -0
- package/dist/runtime/errors.d.ts +9 -0
- package/dist/runtime/errors.js +56 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/failure-log.d.ts +22 -0
- package/dist/runtime/failure-log.js +112 -0
- package/dist/runtime/failure-log.js.map +1 -0
- package/dist/runtime/fast-batch.d.ts +55 -0
- package/dist/runtime/fast-batch.js +104 -0
- package/dist/runtime/fast-batch.js.map +1 -0
- package/dist/runtime/file-safety.d.ts +7 -0
- package/dist/runtime/file-safety.js +134 -0
- package/dist/runtime/file-safety.js.map +1 -0
- package/dist/runtime/generic-code.d.ts +9 -0
- package/dist/runtime/generic-code.js +123 -0
- package/dist/runtime/generic-code.js.map +1 -0
- package/dist/runtime/graph-outline.d.ts +54 -0
- package/dist/runtime/graph-outline.js +118 -0
- package/dist/runtime/graph-outline.js.map +1 -0
- package/dist/runtime/harness.d.ts +61 -0
- package/dist/runtime/harness.js +102 -0
- package/dist/runtime/harness.js.map +1 -0
- package/dist/runtime/instruction-context.d.ts +23 -0
- package/dist/runtime/instruction-context.js +136 -0
- package/dist/runtime/instruction-context.js.map +1 -0
- package/dist/runtime/lab-mode.d.ts +32 -0
- package/dist/runtime/lab-mode.js +138 -0
- package/dist/runtime/lab-mode.js.map +1 -0
- package/dist/runtime/languages.d.ts +30 -0
- package/dist/runtime/languages.js +59 -0
- package/dist/runtime/languages.js.map +1 -0
- package/dist/runtime/nav-cache.d.ts +2 -0
- package/dist/runtime/nav-cache.js +12 -0
- package/dist/runtime/nav-cache.js.map +1 -0
- package/dist/runtime/operations.d.ts +40 -0
- package/dist/runtime/operations.js +86 -0
- package/dist/runtime/operations.js.map +1 -0
- package/dist/runtime/platform-capabilities.d.ts +20 -0
- package/dist/runtime/platform-capabilities.js +36 -0
- package/dist/runtime/platform-capabilities.js.map +1 -0
- package/dist/runtime/program-runner.d.ts +4 -0
- package/dist/runtime/program-runner.js +73 -0
- package/dist/runtime/program-runner.js.map +1 -0
- package/dist/runtime/project-context.d.ts +53 -0
- package/dist/runtime/project-context.js +90 -0
- package/dist/runtime/project-context.js.map +1 -0
- package/dist/runtime/project-files.d.ts +2 -0
- package/dist/runtime/project-files.js +3 -0
- package/dist/runtime/project-files.js.map +1 -0
- package/dist/runtime/project-index.d.ts +40 -0
- package/dist/runtime/project-index.js +158 -0
- package/dist/runtime/project-index.js.map +1 -0
- package/dist/runtime/resource-limits.d.ts +42 -0
- package/dist/runtime/resource-limits.js +50 -0
- package/dist/runtime/resource-limits.js.map +1 -0
- package/dist/runtime/scratch-budget.d.ts +11 -0
- package/dist/runtime/scratch-budget.js +107 -0
- package/dist/runtime/scratch-budget.js.map +1 -0
- package/dist/runtime/search-diagnostics.d.ts +3 -0
- package/dist/runtime/search-diagnostics.js +45 -0
- package/dist/runtime/search-diagnostics.js.map +1 -0
- package/dist/runtime/toolchains.d.ts +25 -0
- package/dist/runtime/toolchains.js +70 -0
- package/dist/runtime/toolchains.js.map +1 -0
- package/dist/runtime/worker-coordination.d.ts +314 -0
- package/dist/runtime/worker-coordination.js +564 -0
- package/dist/runtime/worker-coordination.js.map +1 -0
- package/dist/runtime/workspace.d.ts +151 -0
- package/dist/runtime/workspace.js +267 -0
- package/dist/runtime/workspace.js.map +1 -0
- package/dist/service.d.ts +3 -0
- package/dist/service.js +102 -0
- package/dist/service.js.map +1 -0
- package/dist/terminal-setup.d.ts +33 -0
- package/dist/terminal-setup.js +219 -0
- package/dist/terminal-setup.js.map +1 -0
- package/dist/terminal-shortcuts.d.ts +22 -0
- package/dist/terminal-shortcuts.js +145 -0
- package/dist/terminal-shortcuts.js.map +1 -0
- package/dist/terminal-ui.d.ts +20 -0
- package/dist/terminal-ui.js +53 -0
- package/dist/terminal-ui.js.map +1 -0
- package/dist/tools/ast-grep.d.ts +132 -0
- package/dist/tools/ast-grep.js +625 -0
- package/dist/tools/ast-grep.js.map +1 -0
- package/dist/tools/brc-tools.d.ts +112 -0
- package/dist/tools/brc-tools.js +599 -0
- package/dist/tools/brc-tools.js.map +1 -0
- package/dist/tools/check-tools.d.ts +4 -0
- package/dist/tools/check-tools.js +29 -0
- package/dist/tools/check-tools.js.map +1 -0
- package/dist/tools/coding-tools.d.ts +33 -0
- package/dist/tools/coding-tools.js +190 -0
- package/dist/tools/coding-tools.js.map +1 -0
- package/dist/tools/command-shell.d.ts +17 -0
- package/dist/tools/command-shell.js +84 -0
- package/dist/tools/command-shell.js.map +1 -0
- package/dist/tools/dev-extras.d.ts +42 -0
- package/dist/tools/dev-extras.js +135 -0
- package/dist/tools/dev-extras.js.map +1 -0
- package/dist/tools/edit-tools.d.ts +4 -0
- package/dist/tools/edit-tools.js +293 -0
- package/dist/tools/edit-tools.js.map +1 -0
- package/dist/tools/fast-exec.d.ts +11 -0
- package/dist/tools/fast-exec.js +202 -0
- package/dist/tools/fast-exec.js.map +1 -0
- package/dist/tools/image-tools.d.ts +37 -0
- package/dist/tools/image-tools.js +293 -0
- package/dist/tools/image-tools.js.map +1 -0
- package/dist/tools/jobs.d.ts +227 -0
- package/dist/tools/jobs.js +608 -0
- package/dist/tools/jobs.js.map +1 -0
- package/dist/tools/ops-tools.d.ts +8 -0
- package/dist/tools/ops-tools.js +58 -0
- package/dist/tools/ops-tools.js.map +1 -0
- package/dist/tools/plugin-tools.d.ts +38 -0
- package/dist/tools/plugin-tools.js +133 -0
- package/dist/tools/plugin-tools.js.map +1 -0
- package/dist/tools/rtk.d.ts +60 -0
- package/dist/tools/rtk.js +245 -0
- package/dist/tools/rtk.js.map +1 -0
- package/dist/tools/sandbox-tools.d.ts +41 -0
- package/dist/tools/sandbox-tools.js +146 -0
- package/dist/tools/sandbox-tools.js.map +1 -0
- package/dist/tools/worker-tools.d.ts +231 -0
- package/dist/tools/worker-tools.js +55 -0
- package/dist/tools/worker-tools.js.map +1 -0
- package/dist/tools/workspace-batch.d.ts +262 -0
- package/dist/tools/workspace-batch.js +188 -0
- package/dist/tools/workspace-batch.js.map +1 -0
- package/dist/transport/pairing.d.ts +22 -0
- package/dist/transport/pairing.js +154 -0
- package/dist/transport/pairing.js.map +1 -0
- package/dist/transport/plugin-admin.d.ts +33 -0
- package/dist/transport/plugin-admin.js +156 -0
- package/dist/transport/plugin-admin.js.map +1 -0
- package/dist/transport/relay-url.d.ts +3 -0
- package/dist/transport/relay-url.js +38 -0
- package/dist/transport/relay-url.js.map +1 -0
- package/dist/transport/result-budget.d.ts +11 -0
- package/dist/transport/result-budget.js +45 -0
- package/dist/transport/result-budget.js.map +1 -0
- package/dist/transport/ws-client.d.ts +64 -0
- package/dist/transport/ws-client.js +242 -0
- package/dist/transport/ws-client.js.map +1 -0
- package/package.json +89 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Better Remote Commander contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This project includes code derived from Desktop Commander MCP
|
|
26
|
+
(https://github.com/wonderwhy-er/DesktopCommanderMCP), used under the MIT License:
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2024-2025 Eduard Ruzga and Desktop Commander Contributors
|
|
29
|
+
|
|
30
|
+
The derived code lives in packages/agent/src/core/. See NOTICE for details.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Eduard Ruzga and Desktop Commander Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Better Remote Commander
|
|
2
|
+
=======================
|
|
3
|
+
|
|
4
|
+
Third-party code
|
|
5
|
+
----------------
|
|
6
|
+
packages/agent/src/core/ is derived from Desktop Commander MCP
|
|
7
|
+
https://github.com/wonderwhy-er/DesktopCommanderMCP (MIT)
|
|
8
|
+
Copyright (c) 2024-2025 Eduard Ruzga and Desktop Commander Contributors
|
|
9
|
+
Modifications: removed Supabase/stdio/remote-device transport and telemetry defaults,
|
|
10
|
+
added Better Remote Commander (BRC) context shim, own config directory (~/.brc), tool-definition extraction.
|
|
11
|
+
|
|
12
|
+
Everything else (relay, protocol, agent transport, pairing, dashboard,
|
|
13
|
+
Docker/CI) is original work of this project, MIT licensed.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@belboy47/brc-agent`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Device agent for **Better Remote Commander (BRC)** — an independently maintained remote-execution and infrastructure-management component for AI-assisted engineering, systems administration, and authorized network experimentation.
|
|
4
|
+
|
|
5
|
+
- **Repository**: [https://github.com/Belboy47/better-remote-commander](https://github.com/Belboy47/better-remote-commander)
|
|
6
|
+
- **Executables**: `brc-lab-agent` (primary) and `brc-agent` (alias)
|
|
7
|
+
- **Requirements**: Node.js `>=22.13` (Node.js 24 LTS recommended)
|
|
8
|
+
|
|
9
|
+
## Install & Update
|
|
10
|
+
|
|
11
|
+
Headless installation (skips Puppeteer browser downloads):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
PUPPETEER_SKIP_DOWNLOAD=true npm install -g @belboy47/brc-agent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Update to the latest regular release:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
PUPPETEER_SKIP_DOWNLOAD=true npm update -g @belboy47/brc-agent
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Usage
|
|
24
|
+
|
|
25
|
+
Standard foreground session:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
brc-lab-agent --relay https://relay.example.com --name server-01 --no-browser --no-plugins
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Linux laboratory networking session (requires `root` and interactive launch):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
sudo brc-lab-agent --relay https://relay.example.com --name lab-node-01 --lab-mode --no-browser --no-plugins
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Linux detached session (survives SSH disconnect without creating a boot service):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
brc-lab-agent --relay https://relay.example.com --name server-01 --detach --no-browser --no-plugins
|
|
41
|
+
brc-lab-agent --status
|
|
42
|
+
brc-lab-agent --logs --lines 100
|
|
43
|
+
brc-lab-agent --stop
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Key Options
|
|
47
|
+
|
|
48
|
+
| Option / Env | Purpose |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `--relay <url>` / `BRC_RELAY` | Relay base URL |
|
|
51
|
+
| `--name <name>` / `BRC_NAME` | Device name shown to connected clients (default: hostname) |
|
|
52
|
+
| `--allow-dir <path>` | Restrict file tools to directory (repeatable; persisted) |
|
|
53
|
+
| `--lab-mode` | Linux root session: temporary `/` scope + authorized firewall/networking commands |
|
|
54
|
+
| `--detach` | Linux: complete local authorization/pairing, then detach from SSH session |
|
|
55
|
+
| `--status` / `--stop` / `--logs [--lines N]` | Inspect, gracefully stop, or view redacted logs for a detached agent |
|
|
56
|
+
| `--no-browser` | Print pairing URL instead of opening a browser |
|
|
57
|
+
| `--no-plugins` / `BRC_PLUGINS=none` | Disable default plugin setup for this run |
|
|
58
|
+
| `--install-service` / `--uninstall-service` | Register/remove OS login service (standard mode) |
|
|
59
|
+
| `--logout` / `--forget-relay` | Remove saved relay URL and local pairing |
|
|
60
|
+
| `--debug` / `BRC_DEBUG=1` | Verbose diagnostic output |
|
|
61
|
+
| `BRC_HOME` | Agent state directory (default `~/.brc`) |
|
|
62
|
+
|
|
63
|
+
## Attribution & License
|
|
64
|
+
|
|
65
|
+
Independently maintained derivative of [shahidx0x/better-remote-commander](https://github.com/shahidx0x/better-remote-commander), preserving upstream MIT licensing and Desktop Commander MCP attribution. See `LICENSE`, `NOTICE`, and `LICENSE-desktop-commander`.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* BRC agent CLI.
|
|
4
|
+
* brc-agent --relay https://rdp.example.com [--name "My PC"] [--no-browser] [--debug]
|
|
5
|
+
* brc-agent interactive: first run asks for the relay URL; a saved connection auto-connects after 4 s (Enter = now, M = settings)
|
|
6
|
+
* brc-agent --setup open the connection settings menu
|
|
7
|
+
* brc-agent --forget-relay | --logout forget the saved relay URL and local pairing, then exit
|
|
8
|
+
* brc-agent --non-interactive never prompt or wait (used by the background service)
|
|
9
|
+
* brc-agent --compact | --verbose console style (default: compact on a terminal)
|
|
10
|
+
* brc-agent --relay <url> --token <t> --device-id <id> (dev: skip pairing, pre-issued token)
|
|
11
|
+
* brc-agent --install-service | --uninstall-service run as a background service (saved credentials)
|
|
12
|
+
* brc-agent --no-plugins run without plugin set-up (no default plugin installs this run)
|
|
13
|
+
* brc-agent --lab-mode foreground root Linux lab session (temporary filesystem scope; existing command policy remains)
|
|
14
|
+
*
|
|
15
|
+
* Plugins (each prints a result and exits):
|
|
16
|
+
* brc-agent --list-plugins
|
|
17
|
+
* brc-agent --add-plugin <id> re-add a default plugin (playwright, computer-use, ast-grep, rtk, serena, markitdown)
|
|
18
|
+
* brc-agent --add-plugin <id> --npm <pkg>@<ver> | --pypi <pkg>==<ver> | --command "<cmd> <args...>" | --url <https url>
|
|
19
|
+
* [--env KEY=VALUE ...] [--name "<display name>"]
|
|
20
|
+
* brc-agent --remove-plugin <id>
|
|
21
|
+
* brc-agent --enable-plugin <id> | --disable-plugin <id>
|
|
22
|
+
* brc-agent --update-plugins latest versions for the default plugins, then reinstall them
|
|
23
|
+
* Env: BRC_RELAY, BRC_NAME, BRC_TOKEN, BRC_DEVICE_ID, BRC_HOME, BRC_DEBUG, BRC_PLUGINS=none (same as --no-plugins)
|
|
24
|
+
*/
|
|
25
|
+
import os from 'node:os';
|
|
26
|
+
import { fileURLToPath } from 'node:url';
|
|
27
|
+
import { applyLegacyEnv } from 'brc-shared';
|
|
28
|
+
applyLegacyEnv();
|
|
29
|
+
import { WsClient } from './transport/ws-client.js';
|
|
30
|
+
import { pairDevice, loadCredentials, clearCredentials } from './transport/pairing.js';
|
|
31
|
+
import { callTool, listTools } from './dispatcher.js';
|
|
32
|
+
import { VERSION as CORE_VERSION } from './core/version.js';
|
|
33
|
+
import { setCurrentClient } from './context.js';
|
|
34
|
+
import { activity } from './runtime/activity.js';
|
|
35
|
+
import { listenForTerminalShortcuts } from './terminal-shortcuts.js';
|
|
36
|
+
import { createTerminalPrompts, resolveStartupConnection, shouldPromptForConnection } from './terminal-setup.js';
|
|
37
|
+
import { consoleBanner, controlHint, connectionPanel, recentActivity } from './terminal-ui.js';
|
|
38
|
+
import { DETACH_NONCE_ENV, DETACH_WORKER_FLAG, consumeDetachHandoff, getDetachedStatus, inspectDetachedInstance, launchDetachedAgent, readDetachedLogs, registerDetachedProcess, removeStateFileIfUnownedOrMatching, stopDetachedAgent, validateDetachLaunch, } from './runtime/detach.js';
|
|
39
|
+
const AGENT_VERSION = '2.0.18';
|
|
40
|
+
function arg(name, env, def) {
|
|
41
|
+
const i = process.argv.indexOf(`--${name}`);
|
|
42
|
+
if (i >= 0 && process.argv[i + 1] && !process.argv[i + 1].startsWith('--'))
|
|
43
|
+
return process.argv[i + 1];
|
|
44
|
+
return (env && process.env[env]) || def;
|
|
45
|
+
}
|
|
46
|
+
const flag = (name) => process.argv.includes(`--${name}`);
|
|
47
|
+
const debug = flag('debug') || process.env.BRC_DEBUG === '1';
|
|
48
|
+
if (debug)
|
|
49
|
+
process.env.BRC_DEBUG = '1';
|
|
50
|
+
if (flag('verbose') || debug)
|
|
51
|
+
activity.setConsoleMode('verbose');
|
|
52
|
+
else if (flag('compact'))
|
|
53
|
+
activity.setConsoleMode('compact');
|
|
54
|
+
const log = (level, msg) => activity.log(level, msg);
|
|
55
|
+
if (flag('help')) {
|
|
56
|
+
console.log([
|
|
57
|
+
'brc-lab-agent [options] (alias: brc-agent)',
|
|
58
|
+
'',
|
|
59
|
+
'Connection & enrollment:',
|
|
60
|
+
' (no options) interactive setup or auto-connect to saved relay after 4 s',
|
|
61
|
+
' --relay <base-url> relay base URL (e.g. https://relay.example.com)',
|
|
62
|
+
' --name <name> device name shown in connected clients (default: hostname)',
|
|
63
|
+
' --no-browser print pairing URL instead of opening a browser',
|
|
64
|
+
' --token <t> --device-id <id> skip pairing with a pre-issued token (requires --relay)',
|
|
65
|
+
' --setup open the connection settings menu',
|
|
66
|
+
' --forget-relay | --logout forget saved relay URL and local pairing, then exit',
|
|
67
|
+
' --non-interactive never prompt or wait; use saved credentials or --relay',
|
|
68
|
+
'',
|
|
69
|
+
'Permissions & laboratory mode:',
|
|
70
|
+
' --allow-dir <path> restrict file tools to a directory (repeatable; persisted)',
|
|
71
|
+
' --lab-mode Linux root lab session: temporary / scope + authorized',
|
|
72
|
+
' networking/firewall tools (iptables/ip6tables/nft/ufw/',
|
|
73
|
+
' firewall-cmd/ip/tc/wg/diagnostics); unrelated blocklist',
|
|
74
|
+
' protections remain active; never persisted to config.json',
|
|
75
|
+
'',
|
|
76
|
+
'Detached execution & lifecycle (Linux):',
|
|
77
|
+
' --detach complete local authorization/pairing, then detach so the',
|
|
78
|
+
' agent survives SSH disconnect (does not enable boot startup)',
|
|
79
|
+
' --status show status of the detached BRC agent instance',
|
|
80
|
+
' --stop gracefully stop the detached BRC agent instance',
|
|
81
|
+
' --logs [--lines <N>] show the last N lines (default 50) of detached agent logs',
|
|
82
|
+
'',
|
|
83
|
+
'Background service, plugins & diagnostics:',
|
|
84
|
+
' --install-service [--service-log] | --uninstall-service OS login service management',
|
|
85
|
+
' --no-plugins run without default plugin installs this session',
|
|
86
|
+
' --list-plugins | --add-plugin <id> | --remove-plugin <id> | --enable-plugin <id> | --disable-plugin <id> | --update-plugins',
|
|
87
|
+
' --compact | --verbose | --debug console verbosity',
|
|
88
|
+
'',
|
|
89
|
+
'Examples:',
|
|
90
|
+
' brc-lab-agent --relay https://relay.example.com --name server-01 --no-browser --no-plugins',
|
|
91
|
+
' sudo brc-lab-agent --relay https://relay.example.com --name lab-01 --lab-mode --detach --no-browser --no-plugins',
|
|
92
|
+
' brc-lab-agent --status',
|
|
93
|
+
' brc-lab-agent --logs --lines 100',
|
|
94
|
+
' brc-lab-agent --stop',
|
|
95
|
+
'',
|
|
96
|
+
'Limitations:',
|
|
97
|
+
' --detach is Linux-only and requires local interactive authorization before detaching.',
|
|
98
|
+
' --lab-mode requires Linux root and cannot be combined with --allow-dir or --install-service.',
|
|
99
|
+
'While running in a foreground terminal: M settings, S status, L recent activity, V compact/verbose, ? help, Ctrl+C stop.',
|
|
100
|
+
].join('\n'));
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
103
|
+
// Detached lifecycle management commands (read-only status/logs or graceful stop).
|
|
104
|
+
if (flag('status')) {
|
|
105
|
+
const res = getDetachedStatus();
|
|
106
|
+
console.log(res.message);
|
|
107
|
+
process.exit(res.running ? 0 : 1);
|
|
108
|
+
}
|
|
109
|
+
if (flag('stop')) {
|
|
110
|
+
const res = await stopDetachedAgent();
|
|
111
|
+
console.log(res.message);
|
|
112
|
+
process.exit(res.stopped || res.staleCleaned ? 0 : 0);
|
|
113
|
+
}
|
|
114
|
+
if (flag('logs')) {
|
|
115
|
+
const linesArg = arg('lines');
|
|
116
|
+
const logsIdx = process.argv.indexOf('--logs');
|
|
117
|
+
const positional = logsIdx >= 0 && process.argv[logsIdx + 1] && /^\d+$/.test(process.argv[logsIdx + 1]) ? process.argv[logsIdx + 1] : undefined;
|
|
118
|
+
const count = Number(linesArg ?? positional ?? 50);
|
|
119
|
+
const res = readDetachedLogs(Number.isFinite(count) ? count : 50);
|
|
120
|
+
console.log(res.text);
|
|
121
|
+
process.exit(res.exists ? 0 : 1);
|
|
122
|
+
}
|
|
123
|
+
const detachMode = flag('detach');
|
|
124
|
+
const detachedWorker = process.argv.includes(DETACH_WORKER_FLAG);
|
|
125
|
+
const labMode = flag('lab-mode');
|
|
126
|
+
if (detachMode) {
|
|
127
|
+
try {
|
|
128
|
+
validateDetachLaunch(process.argv.slice(2), process.platform);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
132
|
+
process.exit(2);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (detachedWorker) {
|
|
136
|
+
const nonce = process.env[DETACH_NONCE_ENV];
|
|
137
|
+
delete process.env[DETACH_NONCE_ENV];
|
|
138
|
+
try {
|
|
139
|
+
consumeDetachHandoff(labMode ? 'lab' : 'standard', nonce);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
143
|
+
process.exit(2);
|
|
144
|
+
}
|
|
145
|
+
// Ignore SIGHUP so SSH session disconnect does not terminate the detached worker.
|
|
146
|
+
process.on('SIGHUP', () => { });
|
|
147
|
+
}
|
|
148
|
+
if (labMode) {
|
|
149
|
+
const { validateLabLaunch } = await import('./runtime/lab-mode.js');
|
|
150
|
+
try {
|
|
151
|
+
validateLabLaunch(process.argv.slice(2), process.platform, process.getuid?.(), !!process.stdin.isTTY && !!process.stdout.isTTY, { detachedWorker });
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
155
|
+
process.exit(2);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (detachMode) {
|
|
159
|
+
const existing = inspectDetachedInstance(undefined, undefined, true);
|
|
160
|
+
if (existing.state === 'running') {
|
|
161
|
+
console.error(`A detached BRC agent is already running (PID ${existing.record.pid}, mode: ${existing.record.mode}, device: "${existing.record.name}").`);
|
|
162
|
+
console.error('Use `brc-lab-agent --status` to inspect or `brc-lab-agent --stop` before starting a new instance.');
|
|
163
|
+
process.exit(2);
|
|
164
|
+
}
|
|
165
|
+
if (existing.state === 'stale') {
|
|
166
|
+
console.log(`Cleared stale detached process record for PID ${existing.record.pid}.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (flag('logout') || flag('forget-relay')) {
|
|
170
|
+
try {
|
|
171
|
+
console.log(clearCredentials() ? 'Saved relay URL and local pairing forgotten. Projects and settings were not changed.' : 'No saved relay or pairing.');
|
|
172
|
+
console.log('This does not revoke the device on the old relay; remove it there separately.');
|
|
173
|
+
if (process.env.BRC_RELAY || process.env.BRC_TOKEN)
|
|
174
|
+
console.log('BRC_RELAY/BRC_TOKEN environment values are unchanged.');
|
|
175
|
+
process.exit(0);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
console.error('Could not forget the saved pairing. Check permissions on the agent state directory.');
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (process.argv.some((a) => /^--(list-plugins|add-plugin|remove-plugin|enable-plugin|disable-plugin|update-plugins)$/.test(a))) {
|
|
183
|
+
const { runPluginCommand } = await import('./plugins/cli-commands.js');
|
|
184
|
+
const code = await runPluginCommand(process.argv.slice(2), debug);
|
|
185
|
+
if (code !== null)
|
|
186
|
+
process.exit(code);
|
|
187
|
+
}
|
|
188
|
+
if (flag('install-service') || flag('uninstall-service')) {
|
|
189
|
+
const { installService, uninstallService } = await import('./service.js');
|
|
190
|
+
try {
|
|
191
|
+
if (flag('uninstall-service')) {
|
|
192
|
+
console.log(uninstallService());
|
|
193
|
+
process.exit(0);
|
|
194
|
+
}
|
|
195
|
+
if (!loadCredentials()) {
|
|
196
|
+
console.error('Pair first: run the agent once interactively (or with --relay <url>), then --install-service.');
|
|
197
|
+
process.exit(2);
|
|
198
|
+
}
|
|
199
|
+
// Service uses saved credentials; only pass through policy/debug flags.
|
|
200
|
+
const keep = new Set(['--debug', '--allow-dir', '--no-plugins']);
|
|
201
|
+
const passthrough = [];
|
|
202
|
+
const argv = process.argv.slice(2);
|
|
203
|
+
for (let i = 0; i < argv.length; i++) {
|
|
204
|
+
if (!keep.has(argv[i]))
|
|
205
|
+
continue;
|
|
206
|
+
passthrough.push(argv[i]);
|
|
207
|
+
if (argv[i] === '--allow-dir' && argv[i + 1])
|
|
208
|
+
passthrough.push(argv[++i]);
|
|
209
|
+
}
|
|
210
|
+
console.log(installService(passthrough, flag('service-log')));
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
console.error(`Service setup failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
process.exit(0);
|
|
217
|
+
}
|
|
218
|
+
// --allow-dir <path> (repeatable): restrict tools to these directories (agent-side policy, persisted in config)
|
|
219
|
+
const allowDirs = process.argv.flatMap((a, i, all) => (a === '--allow-dir' && all[i + 1] ? [all[i + 1]] : []));
|
|
220
|
+
if (labMode) {
|
|
221
|
+
const { configManager } = await import('./core/config-manager.js');
|
|
222
|
+
configManager.enableLabSession();
|
|
223
|
+
console.log('LAB MODE: temporary Linux / scope + authorized networking/firewall commands; unrelated blocklist rules and relay authentication remain active.');
|
|
224
|
+
}
|
|
225
|
+
else if (allowDirs.length) {
|
|
226
|
+
const { configManager } = await import('./core/config-manager.js');
|
|
227
|
+
await configManager.setValue('allowedDirectories', allowDirs);
|
|
228
|
+
console.log(`allowedDirectories set to: ${allowDirs.join(', ')}`);
|
|
229
|
+
}
|
|
230
|
+
const ambientEnv = (explicitFlag) => !(flag('auto-connect') && !flag('non-interactive') && !process.argv.includes(explicitFlag));
|
|
231
|
+
const connection = {
|
|
232
|
+
interactive: !!process.stdin.isTTY && !!process.stdout.isTTY,
|
|
233
|
+
setup: flag('setup'), autoConnect: flag('auto-connect'), nonInteractive: flag('non-interactive'),
|
|
234
|
+
// In the interactive --auto-connect flow the saved pairing is authoritative: a stale BRC_RELAY/BRC_TOKEN in the environment
|
|
235
|
+
// must not silently restore a server the user changed or forgot. Explicit --relay/--token/--device-id flags still win.
|
|
236
|
+
relay: arg('relay', ambientEnv('--relay') ? 'BRC_RELAY' : undefined), token: arg('token', ambientEnv('--token') ? 'BRC_TOKEN' : undefined), deviceId: arg('device-id', ambientEnv('--device-id') ? 'BRC_DEVICE_ID' : undefined),
|
|
237
|
+
name: arg('name', 'BRC_NAME', os.hostname()),
|
|
238
|
+
noBrowser: flag('no-browser'),
|
|
239
|
+
};
|
|
240
|
+
const startupAbort = new AbortController();
|
|
241
|
+
connection.signal = startupAbort.signal;
|
|
242
|
+
const stopStartup = () => startupAbort.abort(new DOMException('Startup cancelled.', 'AbortError'));
|
|
243
|
+
process.once('SIGINT', stopStartup);
|
|
244
|
+
process.once('SIGTERM', stopStartup);
|
|
245
|
+
let prompts;
|
|
246
|
+
let creds = null;
|
|
247
|
+
let startupExitCode = 0;
|
|
248
|
+
try {
|
|
249
|
+
await activity.start().catch(() => console.error('Could not remove an old diagnostic file; live logging remains enabled.'));
|
|
250
|
+
// readline is opened only when a menu is actually needed, so it never competes with shortcuts.
|
|
251
|
+
const getPrompts = () => (prompts ??= createTerminalPrompts(process.stdin, process.stdout, startupAbort.signal));
|
|
252
|
+
const lazyPrompts = shouldPromptForConnection(connection) ? {
|
|
253
|
+
ask: (message) => getPrompts().ask(message),
|
|
254
|
+
write: (message) => getPrompts().write(message),
|
|
255
|
+
get signal() { return prompts?.signal ?? startupAbort.signal; },
|
|
256
|
+
} : undefined;
|
|
257
|
+
creds = await resolveStartupConnection(connection, lazyPrompts);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (!startupAbort.signal.aborted && !prompts?.signal?.aborted) {
|
|
261
|
+
console.error(`Startup: ${error instanceof Error ? error.message : 'Connection setup failed.'}`);
|
|
262
|
+
startupExitCode = 2;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
prompts?.close();
|
|
267
|
+
process.removeListener('SIGINT', stopStartup);
|
|
268
|
+
process.removeListener('SIGTERM', stopStartup);
|
|
269
|
+
}
|
|
270
|
+
if (!creds) {
|
|
271
|
+
await activity.close();
|
|
272
|
+
process.exit(startupExitCode);
|
|
273
|
+
}
|
|
274
|
+
if (detachMode) {
|
|
275
|
+
const cliPath = fileURLToPath(new URL('./cli.js', import.meta.url));
|
|
276
|
+
const manualToken = creds.pairedAt === 'manual' ? creds.deviceToken : undefined;
|
|
277
|
+
const launched = await launchDetachedAgent({
|
|
278
|
+
cliPath,
|
|
279
|
+
originalArgv: process.argv.slice(2),
|
|
280
|
+
relayUrl: creds.relayUrl,
|
|
281
|
+
name: creds.name,
|
|
282
|
+
deviceId: creds.deviceId,
|
|
283
|
+
labMode,
|
|
284
|
+
manualToken,
|
|
285
|
+
});
|
|
286
|
+
await activity.close();
|
|
287
|
+
if (!launched.ok || !launched.record) {
|
|
288
|
+
console.error(`Failed to start detached agent: ${launched.error ?? 'Unknown error'}`);
|
|
289
|
+
if (launched.logTail) {
|
|
290
|
+
console.error('\nRecent log output:\n' + launched.logTail);
|
|
291
|
+
}
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
const r = launched.record;
|
|
295
|
+
console.log([
|
|
296
|
+
`Detached BRC agent started.`,
|
|
297
|
+
` PID: ${r.pid}`,
|
|
298
|
+
` Mode: ${r.mode === 'lab' ? 'LAB (temporary / scope + authorized networking)' : 'STANDARD'}`,
|
|
299
|
+
` Device: ${r.name} [${r.deviceId}]`,
|
|
300
|
+
` Relay: ${r.relayUrl}`,
|
|
301
|
+
` Log: ${r.logFile}`,
|
|
302
|
+
`Manage: brc-lab-agent --status | brc-lab-agent --logs | brc-lab-agent --stop`,
|
|
303
|
+
].join('\n'));
|
|
304
|
+
process.exit(0);
|
|
305
|
+
}
|
|
306
|
+
if (detachedWorker) {
|
|
307
|
+
registerDetachedProcess({
|
|
308
|
+
mode: labMode ? 'lab' : 'standard',
|
|
309
|
+
name: creds.name,
|
|
310
|
+
relayUrl: creds.relayUrl,
|
|
311
|
+
deviceId: creds.deviceId,
|
|
312
|
+
version: AGENT_VERSION,
|
|
313
|
+
cliPath: fileURLToPath(new URL('./cli.js', import.meta.url)),
|
|
314
|
+
argvSummary: process.argv.slice(2).filter((a) => a !== DETACH_WORKER_FLAG && a !== '--token'),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
const { registerInstaller } = await import('./plugins/installer.js');
|
|
318
|
+
registerInstaller();
|
|
319
|
+
const pluginsOff = flag('no-plugins') || (process.env.BRC_PLUGINS ?? '').toLowerCase() === 'none';
|
|
320
|
+
setCurrentClient({ name: 'brc-agent', version: AGENT_VERSION });
|
|
321
|
+
const tools = listTools();
|
|
322
|
+
const terminalInfo = { name: creds.name, relay: creds.relayUrl, deviceId: creds.deviceId, version: AGENT_VERSION, coreVersion: CORE_VERSION, tools: tools.length, mode: labMode ? 'lab' : 'standard' };
|
|
323
|
+
const visualConsole = !!process.stdout.isTTY && !connection.nonInteractive;
|
|
324
|
+
console.log(visualConsole ? consoleBanner(terminalInfo) : `brc-agent ${AGENT_VERSION} (core ${CORE_VERSION}) - ${tools.length} tools - "${creds.name}" [${creds.deviceId}] -> ${creds.relayUrl}`);
|
|
325
|
+
// Default plugins: set up in the background once the relay connection is up (or after 10 s
|
|
326
|
+
// without one), so plugin installs never delay connecting. Later starts only check files on disk.
|
|
327
|
+
let pluginSetupStarted = false;
|
|
328
|
+
const startPluginSetup = () => {
|
|
329
|
+
if (pluginSetupStarted || pluginsOff)
|
|
330
|
+
return;
|
|
331
|
+
pluginSetupStarted = true;
|
|
332
|
+
import('./plugins/first-run.js')
|
|
333
|
+
.then(({ ensureDefaultPlugins }) => ensureDefaultPlugins(log))
|
|
334
|
+
.then((r) => { if (r.queued.length)
|
|
335
|
+
void r.done.then(() => log('info', 'plugins: background set-up finished')); })
|
|
336
|
+
.catch((e) => log('warn', `plugin set-up failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
337
|
+
};
|
|
338
|
+
if (!pluginsOff)
|
|
339
|
+
setTimeout(startPluginSetup, 10_000).unref();
|
|
340
|
+
// Bounded, unref'd cache maintenance (RAM caches + owned scratch); stopped on shutdown.
|
|
341
|
+
void import('./runtime/resource-limits.js').then(({ startResourceMaintenance }) => startResourceMaintenance()).catch(() => { });
|
|
342
|
+
const runningAbort = new AbortController();
|
|
343
|
+
const foregroundControls = !connection.nonInteractive && (connection.interactive || !!connection.autoConnect);
|
|
344
|
+
const settingsHint = controlHint(!!process.stdin.isTTY);
|
|
345
|
+
let activeCredentials = creds;
|
|
346
|
+
let client;
|
|
347
|
+
let shortcuts;
|
|
348
|
+
let livePrompts;
|
|
349
|
+
let settingsOpen = false;
|
|
350
|
+
let shuttingDown = false;
|
|
351
|
+
function armShortcuts() {
|
|
352
|
+
shortcuts?.close();
|
|
353
|
+
shortcuts = undefined;
|
|
354
|
+
if (!foregroundControls || shuttingDown || settingsOpen || process.stdin.destroyed || process.stdin.readableEnded)
|
|
355
|
+
return;
|
|
356
|
+
shortcuts = listenForTerminalShortcuts(process.stdin, (choice) => {
|
|
357
|
+
if (choice === 'settings')
|
|
358
|
+
void openSettings();
|
|
359
|
+
else if (choice === 'status')
|
|
360
|
+
console.log(connectionPanel(client.status(), { ...terminalInfo, name: activeCredentials.name, relay: activeCredentials.relayUrl }));
|
|
361
|
+
else if (choice === 'activity')
|
|
362
|
+
console.log(recentActivity(activity.recent(), 10));
|
|
363
|
+
else if (choice === 'verbose') {
|
|
364
|
+
activity.setConsoleMode(activity.getConsoleMode() === 'compact' ? 'verbose' : 'compact');
|
|
365
|
+
console.log(' Console mode: ' + activity.getConsoleMode());
|
|
366
|
+
}
|
|
367
|
+
else if (choice === 'help')
|
|
368
|
+
console.log(settingsHint);
|
|
369
|
+
else if (choice === 'exit')
|
|
370
|
+
shutdown('Ctrl+C');
|
|
371
|
+
}, { signal: runningAbort.signal, liveCommands: true });
|
|
372
|
+
}
|
|
373
|
+
function start(c) {
|
|
374
|
+
activeCredentials = c;
|
|
375
|
+
const next = new WsClient({
|
|
376
|
+
relayUrl: c.relayUrl, token: c.deviceToken, deviceId: c.deviceId, name: c.name,
|
|
377
|
+
agentVersion: AGENT_VERSION, coreVersion: CORE_VERSION, tools, callTool, log,
|
|
378
|
+
onConnected: () => { if (!pluginSetupStarted)
|
|
379
|
+
setImmediate(startPluginSetup); },
|
|
380
|
+
onUnauthorized: async () => {
|
|
381
|
+
if (shuttingDown || client !== next)
|
|
382
|
+
return true;
|
|
383
|
+
if (c.pairedAt === 'manual')
|
|
384
|
+
return false;
|
|
385
|
+
log('warn', 'Relay rejected our device token; re-pairing');
|
|
386
|
+
// The old pairing is replaced only when the new one is approved (pairDevice saves it).
|
|
387
|
+
const fresh = await pairDevice({ relayUrl: c.relayUrl, name: c.name, deviceId: c.deviceId, openBrowser: !connection.noBrowser, log: (m) => console.log(m), signal: runningAbort.signal });
|
|
388
|
+
if (shuttingDown || client !== next)
|
|
389
|
+
return true;
|
|
390
|
+
next.stop();
|
|
391
|
+
start(fresh);
|
|
392
|
+
return true;
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
client = next;
|
|
396
|
+
client.start();
|
|
397
|
+
}
|
|
398
|
+
async function openSettings() {
|
|
399
|
+
if (settingsOpen || shuttingDown)
|
|
400
|
+
return;
|
|
401
|
+
if (!client.pauseForSettings()) {
|
|
402
|
+
log('info', 'Tools are still running. Press M again when idle; no work was interrupted.');
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const paused = client;
|
|
406
|
+
settingsOpen = true;
|
|
407
|
+
shortcuts?.close();
|
|
408
|
+
shortcuts = undefined;
|
|
409
|
+
const resumeLogs = activity.pauseConsole();
|
|
410
|
+
let forgotten = false;
|
|
411
|
+
try {
|
|
412
|
+
livePrompts = createTerminalPrompts(process.stdin, process.stdout, runningAbort.signal);
|
|
413
|
+
livePrompts.write('Connection settings: new tool calls are paused; the relay connection stays alive.');
|
|
414
|
+
const next = await resolveStartupConnection({ ...connection, setup: true, autoConnect: false, returnToAgent: true, relay: undefined, token: undefined, deviceId: undefined, signal: runningAbort.signal }, livePrompts, {
|
|
415
|
+
// Fall back to the live credentials only until the owner forgets them.
|
|
416
|
+
load: () => loadCredentials() ?? (forgotten ? null : activeCredentials),
|
|
417
|
+
clear: () => {
|
|
418
|
+
const removed = clearCredentials();
|
|
419
|
+
forgotten = true;
|
|
420
|
+
paused.stop(); // stop the old socket and its reconnect timer right away
|
|
421
|
+
livePrompts?.write('Old relay disconnected. Enter the new relay URL below.');
|
|
422
|
+
return removed;
|
|
423
|
+
},
|
|
424
|
+
pair: pairDevice,
|
|
425
|
+
});
|
|
426
|
+
if (shuttingDown)
|
|
427
|
+
return;
|
|
428
|
+
if (!next && forgotten) {
|
|
429
|
+
shutdown('Saved connection forgotten');
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (next && (forgotten || next.relayUrl !== activeCredentials.relayUrl || next.deviceId !== activeCredentials.deviceId || next.deviceToken !== activeCredentials.deviceToken)) {
|
|
433
|
+
paused.stop();
|
|
434
|
+
start(next);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
if (!shuttingDown)
|
|
439
|
+
console.error(`Settings: ${error instanceof Error ? error.message : 'Connection setup failed.'}`);
|
|
440
|
+
if (forgotten && !shuttingDown)
|
|
441
|
+
shutdown('Saved connection forgotten');
|
|
442
|
+
}
|
|
443
|
+
finally {
|
|
444
|
+
livePrompts?.close();
|
|
445
|
+
livePrompts = undefined;
|
|
446
|
+
paused.resumeAfterSettings();
|
|
447
|
+
settingsOpen = false;
|
|
448
|
+
resumeLogs();
|
|
449
|
+
if (!shuttingDown) {
|
|
450
|
+
console.log(`Back to live logs. ${settingsHint}`);
|
|
451
|
+
armShortcuts();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function shutdown(reason) {
|
|
456
|
+
if (shuttingDown)
|
|
457
|
+
return;
|
|
458
|
+
shuttingDown = true;
|
|
459
|
+
shortcuts?.close();
|
|
460
|
+
shortcuts = undefined;
|
|
461
|
+
console.log(`\n${reason}; stopping agent`);
|
|
462
|
+
runningAbort.abort();
|
|
463
|
+
livePrompts?.close();
|
|
464
|
+
client?.stop();
|
|
465
|
+
import('./runtime/resource-limits.js').then(({ stopResourceMaintenance }) => stopResourceMaintenance()).catch(() => { });
|
|
466
|
+
import('./runtime/worker-coordination.js').then(({ workerCoordinator }) => workerCoordinator.clear()).catch(() => { });
|
|
467
|
+
// Persist debounced background config writes (usage stats) and stop plugin processes, bounded wait.
|
|
468
|
+
const exit = () => {
|
|
469
|
+
if (detachedWorker)
|
|
470
|
+
removeStateFileIfUnownedOrMatching(undefined, process.pid);
|
|
471
|
+
process.exit(0);
|
|
472
|
+
};
|
|
473
|
+
const timer = setTimeout(exit, 2500);
|
|
474
|
+
Promise.allSettled([
|
|
475
|
+
import('./core/config-manager.js').then(({ configManager }) => configManager.flush()),
|
|
476
|
+
import('./plugins/host.js').then(({ stopAllPlugins }) => stopAllPlugins()),
|
|
477
|
+
activity.close(),
|
|
478
|
+
]).finally(() => { clearTimeout(timer); setTimeout(exit, 50); });
|
|
479
|
+
}
|
|
480
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
481
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
482
|
+
start(creds);
|
|
483
|
+
if (foregroundControls) {
|
|
484
|
+
console.log(settingsHint);
|
|
485
|
+
armShortcuts();
|
|
486
|
+
}
|
|
487
|
+
//# sourceMappingURL=cli.js.map
|