bloby-bot 0.17.2
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/README.md +593 -0
- package/bin/cli.js +1788 -0
- package/cli/commands/daemon.ts +31 -0
- package/cli/commands/init.ts +40 -0
- package/cli/commands/start.ts +91 -0
- package/cli/commands/tunnel.ts +175 -0
- package/cli/commands/update.ts +170 -0
- package/cli/core/base-adapter.ts +99 -0
- package/cli/core/cloudflared.ts +71 -0
- package/cli/core/config.ts +58 -0
- package/cli/core/os-detector.ts +31 -0
- package/cli/core/server.ts +87 -0
- package/cli/core/types.ts +15 -0
- package/cli/index.ts +72 -0
- package/cli/platforms/darwin.ts +110 -0
- package/cli/platforms/index.ts +20 -0
- package/cli/platforms/linux.ts +116 -0
- package/cli/platforms/win32.ts +20 -0
- package/cli/utils/ui.ts +24 -0
- package/components.json +20 -0
- package/dist-bloby/assets/bloby-CMybOOCK.js +37 -0
- package/dist-bloby/assets/globals-CCAaaNDA.css +2 -0
- package/dist-bloby/assets/globals-Eq8C57hc.js +18 -0
- package/dist-bloby/assets/onboard-J0aqq4XH.js +1 -0
- package/dist-bloby/bloby.html +28 -0
- package/dist-bloby/onboard.html +14 -0
- package/package.json +103 -0
- package/postcss.config.js +5 -0
- package/scripts/install +316 -0
- package/scripts/install.ps1 +351 -0
- package/scripts/install.sh +322 -0
- package/scripts/postinstall.js +137 -0
- package/shared/ai.ts +141 -0
- package/shared/config.ts +68 -0
- package/shared/logger.ts +13 -0
- package/shared/paths.ts +20 -0
- package/shared/relay.ts +148 -0
- package/supervisor/app-ws.js +200 -0
- package/supervisor/backend.ts +143 -0
- package/supervisor/bloby-agent.ts +299 -0
- package/supervisor/channels/manager.ts +618 -0
- package/supervisor/channels/types.ts +59 -0
- package/supervisor/channels/whatsapp.ts +436 -0
- package/supervisor/chat/ARCHITECTURE.md +89 -0
- package/supervisor/chat/OnboardWizard.tsx +2353 -0
- package/supervisor/chat/bloby-main.tsx +567 -0
- package/supervisor/chat/bloby.html +26 -0
- package/supervisor/chat/onboard-main.tsx +19 -0
- package/supervisor/chat/onboard.html +12 -0
- package/supervisor/chat/src/components/Chat/AudioBubble.tsx +117 -0
- package/supervisor/chat/src/components/Chat/ChatView.tsx +25 -0
- package/supervisor/chat/src/components/Chat/ImageLightbox.tsx +86 -0
- package/supervisor/chat/src/components/Chat/InputBar.tsx +508 -0
- package/supervisor/chat/src/components/Chat/MessageBubble.tsx +226 -0
- package/supervisor/chat/src/components/Chat/MessageList.tsx +126 -0
- package/supervisor/chat/src/components/Chat/TypingIndicator.tsx +47 -0
- package/supervisor/chat/src/components/LoginScreen.tsx +280 -0
- package/supervisor/chat/src/hooks/useBlobyChat.ts +266 -0
- package/supervisor/chat/src/hooks/useChat.ts +237 -0
- package/supervisor/chat/src/hooks/useSpeechRecognition.ts +137 -0
- package/supervisor/chat/src/lib/auth.ts +38 -0
- package/supervisor/chat/src/lib/ws-client.ts +126 -0
- package/supervisor/chat/src/styles/globals.css +116 -0
- package/supervisor/file-saver.ts +50 -0
- package/supervisor/index.ts +1537 -0
- package/supervisor/scheduler.ts +309 -0
- package/supervisor/tunnel.ts +156 -0
- package/supervisor/vite-dev.ts +72 -0
- package/supervisor/widget.js +441 -0
- package/tsconfig.json +20 -0
- package/vite.bloby.config.ts +43 -0
- package/vite.config.ts +68 -0
- package/worker/claude-auth.ts +282 -0
- package/worker/codex-auth.ts +199 -0
- package/worker/db.ts +198 -0
- package/worker/index.ts +886 -0
- package/worker/prompts/bloby-system-prompt.txt +739 -0
- package/workspace/.backend.log +1 -0
- package/workspace/.env +3 -0
- package/workspace/CRONS.json +1 -0
- package/workspace/MEMORY.md +0 -0
- package/workspace/MYHUMAN.md +0 -0
- package/workspace/MYSELF.md +20 -0
- package/workspace/PULSE.json +8 -0
- package/workspace/app.db +0 -0
- package/workspace/backend/index.ts +52 -0
- package/workspace/client/index.html +75 -0
- package/workspace/client/public/.gitkeep +0 -0
- package/workspace/client/public/arrow.png +0 -0
- package/workspace/client/public/bloby-badge.png +0 -0
- package/workspace/client/public/bloby-icon-192.png +0 -0
- package/workspace/client/public/bloby-icon-512.png +0 -0
- package/workspace/client/public/bloby.png +0 -0
- package/workspace/client/public/bloby_frame1.png +0 -0
- package/workspace/client/public/bloby_happy.mov +0 -0
- package/workspace/client/public/bloby_happy.webm +0 -0
- package/workspace/client/public/bloby_happy_reappearing.mov +0 -0
- package/workspace/client/public/bloby_happy_reappearing.webm +0 -0
- package/workspace/client/public/bloby_say_hi.mov +0 -0
- package/workspace/client/public/bloby_say_hi.webm +0 -0
- package/workspace/client/public/bloby_tilts.webm +0 -0
- package/workspace/client/public/icons/claude.png +0 -0
- package/workspace/client/public/icons/codex.png +0 -0
- package/workspace/client/public/icons/openai.svg +15 -0
- package/workspace/client/public/manifest.json +23 -0
- package/workspace/client/public/spritesheet.webp +0 -0
- package/workspace/client/public/sw.js +136 -0
- package/workspace/client/src/App.tsx +191 -0
- package/workspace/client/src/components/Dashboard/DashboardPage.tsx +134 -0
- package/workspace/client/src/components/ErrorBoundary.tsx +23 -0
- package/workspace/client/src/components/Layout/DashboardLayout.tsx +56 -0
- package/workspace/client/src/components/Layout/Footer.tsx +14 -0
- package/workspace/client/src/components/Layout/MobileNav.tsx +30 -0
- package/workspace/client/src/components/Layout/Sidebar.tsx +110 -0
- package/workspace/client/src/components/deleteme_onboarding/WorkspaceTour.tsx +104 -0
- package/workspace/client/src/components/deleteme_onboarding/tour-theme.css +75 -0
- package/workspace/client/src/components/ui/avatar.tsx +109 -0
- package/workspace/client/src/components/ui/badge.tsx +48 -0
- package/workspace/client/src/components/ui/button.tsx +64 -0
- package/workspace/client/src/components/ui/card.tsx +92 -0
- package/workspace/client/src/components/ui/dialog.tsx +156 -0
- package/workspace/client/src/components/ui/dropdown-menu.tsx +257 -0
- package/workspace/client/src/components/ui/input.tsx +21 -0
- package/workspace/client/src/components/ui/scroll-area.tsx +58 -0
- package/workspace/client/src/components/ui/select.tsx +190 -0
- package/workspace/client/src/components/ui/separator.tsx +28 -0
- package/workspace/client/src/components/ui/sheet.tsx +142 -0
- package/workspace/client/src/components/ui/skeleton.tsx +13 -0
- package/workspace/client/src/components/ui/switch.tsx +33 -0
- package/workspace/client/src/components/ui/tabs.tsx +89 -0
- package/workspace/client/src/components/ui/textarea.tsx +18 -0
- package/workspace/client/src/components/ui/tooltip.tsx +55 -0
- package/workspace/client/src/lib/utils.ts +6 -0
- package/workspace/client/src/main.tsx +20 -0
- package/workspace/client/src/styles/globals.css +119 -0
- package/workspace/node_modules/.package-lock.json +1248 -0
- package/workspace/node_modules/.vite/deps/_metadata.json +116 -0
- package/workspace/node_modules/.vite/deps/clsx.js +18 -0
- package/workspace/node_modules/.vite/deps/clsx.js.map +1 -0
- package/workspace/node_modules/.vite/deps/driver__js.js +581 -0
- package/workspace/node_modules/.vite/deps/driver__js.js.map +1 -0
- package/workspace/node_modules/.vite/deps/framer-motion.js +13761 -0
- package/workspace/node_modules/.vite/deps/framer-motion.js.map +1 -0
- package/workspace/node_modules/.vite/deps/lucide-react.js +34357 -0
- package/workspace/node_modules/.vite/deps/lucide-react.js.map +1 -0
- package/workspace/node_modules/.vite/deps/package.json +3 -0
- package/workspace/node_modules/.vite/deps/radix-ui.js +13835 -0
- package/workspace/node_modules/.vite/deps/radix-ui.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react-3_O8oni9.js +799 -0
- package/workspace/node_modules/.vite/deps/react-3_O8oni9.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react-dom.js +185 -0
- package/workspace/node_modules/.vite/deps/react-dom.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react-dom_client.js +14384 -0
- package/workspace/node_modules/.vite/deps/react-dom_client.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react-router.js +9785 -0
- package/workspace/node_modules/.vite/deps/react-router.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react.js +2 -0
- package/workspace/node_modules/.vite/deps/react_jsx-dev-runtime.js +204 -0
- package/workspace/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +1 -0
- package/workspace/node_modules/.vite/deps/react_jsx-runtime.js +209 -0
- package/workspace/node_modules/.vite/deps/react_jsx-runtime.js.map +1 -0
- package/workspace/node_modules/.vite/deps/recharts.js +34142 -0
- package/workspace/node_modules/.vite/deps/recharts.js.map +1 -0
- package/workspace/node_modules/.vite/deps/sonner.js +943 -0
- package/workspace/node_modules/.vite/deps/sonner.js.map +1 -0
- package/workspace/node_modules/.vite/deps/tailwind-merge.js +2025 -0
- package/workspace/node_modules/.vite/deps/tailwind-merge.js.map +1 -0
- package/workspace/node_modules/.vite/deps/use-sync-external-store.js +27 -0
- package/workspace/node_modules/.vite/deps/use-sync-external-store.js.map +1 -0
- package/workspace/node_modules/.vite/deps/use-sync-external-store_shim.js +75 -0
- package/workspace/node_modules/.vite/deps/use-sync-external-store_shim.js.map +1 -0
- package/workspace/node_modules/.vite/deps/zustand.js +49 -0
- package/workspace/node_modules/.vite/deps/zustand.js.map +1 -0
- package/workspace/node_modules/accepts/HISTORY.md +250 -0
- package/workspace/node_modules/accepts/LICENSE +23 -0
- package/workspace/node_modules/accepts/README.md +140 -0
- package/workspace/node_modules/accepts/index.js +238 -0
- package/workspace/node_modules/accepts/package.json +47 -0
- package/workspace/node_modules/base64-js/LICENSE +21 -0
- package/workspace/node_modules/base64-js/README.md +34 -0
- package/workspace/node_modules/base64-js/base64js.min.js +1 -0
- package/workspace/node_modules/base64-js/index.d.ts +3 -0
- package/workspace/node_modules/base64-js/index.js +150 -0
- package/workspace/node_modules/base64-js/package.json +47 -0
- package/workspace/node_modules/better-sqlite3/LICENSE +21 -0
- package/workspace/node_modules/better-sqlite3/README.md +99 -0
- package/workspace/node_modules/better-sqlite3/binding.gyp +38 -0
- package/workspace/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- package/workspace/node_modules/better-sqlite3/deps/common.gypi +68 -0
- package/workspace/node_modules/better-sqlite3/deps/copy.js +31 -0
- package/workspace/node_modules/better-sqlite3/deps/defines.gypi +41 -0
- package/workspace/node_modules/better-sqlite3/deps/download.sh +122 -0
- package/workspace/node_modules/better-sqlite3/deps/patches/1208.patch +15 -0
- package/workspace/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c +265994 -0
- package/workspace/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h +13968 -0
- package/workspace/node_modules/better-sqlite3/deps/sqlite3/sqlite3ext.h +730 -0
- package/workspace/node_modules/better-sqlite3/deps/sqlite3.gyp +80 -0
- package/workspace/node_modules/better-sqlite3/deps/test_extension.c +21 -0
- package/workspace/node_modules/better-sqlite3/lib/database.js +90 -0
- package/workspace/node_modules/better-sqlite3/lib/index.js +3 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/workspace/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/workspace/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/workspace/node_modules/better-sqlite3/lib/util.js +12 -0
- package/workspace/node_modules/better-sqlite3/package.json +59 -0
- package/workspace/node_modules/better-sqlite3/src/addon.cpp +47 -0
- package/workspace/node_modules/better-sqlite3/src/better_sqlite3.cpp +74 -0
- package/workspace/node_modules/better-sqlite3/src/objects/backup.cpp +120 -0
- package/workspace/node_modules/better-sqlite3/src/objects/backup.hpp +36 -0
- package/workspace/node_modules/better-sqlite3/src/objects/database.cpp +417 -0
- package/workspace/node_modules/better-sqlite3/src/objects/database.hpp +103 -0
- package/workspace/node_modules/better-sqlite3/src/objects/statement-iterator.cpp +113 -0
- package/workspace/node_modules/better-sqlite3/src/objects/statement-iterator.hpp +50 -0
- package/workspace/node_modules/better-sqlite3/src/objects/statement.cpp +383 -0
- package/workspace/node_modules/better-sqlite3/src/objects/statement.hpp +58 -0
- package/workspace/node_modules/better-sqlite3/src/util/bind-map.cpp +73 -0
- package/workspace/node_modules/better-sqlite3/src/util/binder.cpp +193 -0
- package/workspace/node_modules/better-sqlite3/src/util/constants.cpp +172 -0
- package/workspace/node_modules/better-sqlite3/src/util/custom-aggregate.cpp +121 -0
- package/workspace/node_modules/better-sqlite3/src/util/custom-function.cpp +59 -0
- package/workspace/node_modules/better-sqlite3/src/util/custom-table.cpp +409 -0
- package/workspace/node_modules/better-sqlite3/src/util/data-converter.cpp +17 -0
- package/workspace/node_modules/better-sqlite3/src/util/data.cpp +194 -0
- package/workspace/node_modules/better-sqlite3/src/util/helpers.cpp +109 -0
- package/workspace/node_modules/better-sqlite3/src/util/macros.cpp +83 -0
- package/workspace/node_modules/better-sqlite3/src/util/query-macros.cpp +71 -0
- package/workspace/node_modules/better-sqlite3/src/util/row-builder.cpp +49 -0
- package/workspace/node_modules/bindings/LICENSE.md +22 -0
- package/workspace/node_modules/bindings/README.md +98 -0
- package/workspace/node_modules/bindings/bindings.js +221 -0
- package/workspace/node_modules/bindings/package.json +28 -0
- package/workspace/node_modules/bl/.travis.yml +17 -0
- package/workspace/node_modules/bl/BufferList.js +396 -0
- package/workspace/node_modules/bl/LICENSE.md +13 -0
- package/workspace/node_modules/bl/README.md +247 -0
- package/workspace/node_modules/bl/bl.js +84 -0
- package/workspace/node_modules/bl/package.json +37 -0
- package/workspace/node_modules/bl/test/convert.js +21 -0
- package/workspace/node_modules/bl/test/indexOf.js +492 -0
- package/workspace/node_modules/bl/test/isBufferList.js +32 -0
- package/workspace/node_modules/bl/test/test.js +869 -0
- package/workspace/node_modules/body-parser/LICENSE +23 -0
- package/workspace/node_modules/body-parser/README.md +494 -0
- package/workspace/node_modules/body-parser/index.js +71 -0
- package/workspace/node_modules/body-parser/lib/read.js +247 -0
- package/workspace/node_modules/body-parser/lib/types/json.js +158 -0
- package/workspace/node_modules/body-parser/lib/types/raw.js +42 -0
- package/workspace/node_modules/body-parser/lib/types/text.js +36 -0
- package/workspace/node_modules/body-parser/lib/types/urlencoded.js +142 -0
- package/workspace/node_modules/body-parser/lib/utils.js +98 -0
- package/workspace/node_modules/body-parser/package.json +52 -0
- package/workspace/node_modules/buffer/AUTHORS.md +70 -0
- package/workspace/node_modules/buffer/LICENSE +21 -0
- package/workspace/node_modules/buffer/README.md +410 -0
- package/workspace/node_modules/buffer/index.d.ts +186 -0
- package/workspace/node_modules/buffer/index.js +1817 -0
- package/workspace/node_modules/buffer/package.json +96 -0
- package/workspace/node_modules/bytes/History.md +97 -0
- package/workspace/node_modules/bytes/LICENSE +23 -0
- package/workspace/node_modules/bytes/Readme.md +152 -0
- package/workspace/node_modules/bytes/index.js +170 -0
- package/workspace/node_modules/bytes/package.json +42 -0
- package/workspace/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/workspace/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/workspace/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/workspace/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/workspace/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/workspace/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/workspace/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/workspace/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/workspace/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/workspace/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/workspace/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/workspace/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/workspace/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/workspace/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/workspace/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/workspace/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/workspace/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/workspace/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/workspace/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/workspace/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/workspace/node_modules/call-bound/.eslintrc +13 -0
- package/workspace/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/call-bound/.nycrc +9 -0
- package/workspace/node_modules/call-bound/CHANGELOG.md +42 -0
- package/workspace/node_modules/call-bound/LICENSE +21 -0
- package/workspace/node_modules/call-bound/README.md +53 -0
- package/workspace/node_modules/call-bound/index.d.ts +94 -0
- package/workspace/node_modules/call-bound/index.js +19 -0
- package/workspace/node_modules/call-bound/package.json +99 -0
- package/workspace/node_modules/call-bound/test/index.js +61 -0
- package/workspace/node_modules/call-bound/tsconfig.json +10 -0
- package/workspace/node_modules/chownr/LICENSE +15 -0
- package/workspace/node_modules/chownr/README.md +3 -0
- package/workspace/node_modules/chownr/chownr.js +167 -0
- package/workspace/node_modules/chownr/package.json +29 -0
- package/workspace/node_modules/content-disposition/HISTORY.md +72 -0
- package/workspace/node_modules/content-disposition/LICENSE +22 -0
- package/workspace/node_modules/content-disposition/README.md +142 -0
- package/workspace/node_modules/content-disposition/index.js +458 -0
- package/workspace/node_modules/content-disposition/package.json +43 -0
- package/workspace/node_modules/content-type/HISTORY.md +29 -0
- package/workspace/node_modules/content-type/LICENSE +22 -0
- package/workspace/node_modules/content-type/README.md +94 -0
- package/workspace/node_modules/content-type/index.js +225 -0
- package/workspace/node_modules/content-type/package.json +42 -0
- package/workspace/node_modules/cookie/LICENSE +24 -0
- package/workspace/node_modules/cookie/README.md +317 -0
- package/workspace/node_modules/cookie/SECURITY.md +25 -0
- package/workspace/node_modules/cookie/index.js +335 -0
- package/workspace/node_modules/cookie/package.json +44 -0
- package/workspace/node_modules/cookie-signature/History.md +70 -0
- package/workspace/node_modules/cookie-signature/LICENSE +22 -0
- package/workspace/node_modules/cookie-signature/Readme.md +23 -0
- package/workspace/node_modules/cookie-signature/index.js +47 -0
- package/workspace/node_modules/cookie-signature/package.json +24 -0
- package/workspace/node_modules/debug/LICENSE +20 -0
- package/workspace/node_modules/debug/README.md +481 -0
- package/workspace/node_modules/debug/package.json +64 -0
- package/workspace/node_modules/debug/src/browser.js +272 -0
- package/workspace/node_modules/debug/src/common.js +292 -0
- package/workspace/node_modules/debug/src/index.js +10 -0
- package/workspace/node_modules/debug/src/node.js +263 -0
- package/workspace/node_modules/decompress-response/index.d.ts +22 -0
- package/workspace/node_modules/decompress-response/index.js +58 -0
- package/workspace/node_modules/decompress-response/license +9 -0
- package/workspace/node_modules/decompress-response/package.json +56 -0
- package/workspace/node_modules/decompress-response/readme.md +48 -0
- package/workspace/node_modules/deep-extend/CHANGELOG.md +46 -0
- package/workspace/node_modules/deep-extend/LICENSE +20 -0
- package/workspace/node_modules/deep-extend/README.md +91 -0
- package/workspace/node_modules/deep-extend/index.js +1 -0
- package/workspace/node_modules/deep-extend/lib/deep-extend.js +150 -0
- package/workspace/node_modules/deep-extend/package.json +62 -0
- package/workspace/node_modules/depd/History.md +103 -0
- package/workspace/node_modules/depd/LICENSE +22 -0
- package/workspace/node_modules/depd/Readme.md +280 -0
- package/workspace/node_modules/depd/index.js +538 -0
- package/workspace/node_modules/depd/lib/browser/index.js +77 -0
- package/workspace/node_modules/depd/package.json +45 -0
- package/workspace/node_modules/detect-libc/LICENSE +201 -0
- package/workspace/node_modules/detect-libc/README.md +163 -0
- package/workspace/node_modules/detect-libc/index.d.ts +14 -0
- package/workspace/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/workspace/node_modules/detect-libc/lib/elf.js +39 -0
- package/workspace/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/workspace/node_modules/detect-libc/lib/process.js +24 -0
- package/workspace/node_modules/detect-libc/package.json +44 -0
- package/workspace/node_modules/dunder-proto/.eslintrc +5 -0
- package/workspace/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/dunder-proto/.nycrc +13 -0
- package/workspace/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/workspace/node_modules/dunder-proto/LICENSE +21 -0
- package/workspace/node_modules/dunder-proto/README.md +54 -0
- package/workspace/node_modules/dunder-proto/get.d.ts +5 -0
- package/workspace/node_modules/dunder-proto/get.js +30 -0
- package/workspace/node_modules/dunder-proto/package.json +76 -0
- package/workspace/node_modules/dunder-proto/set.d.ts +5 -0
- package/workspace/node_modules/dunder-proto/set.js +35 -0
- package/workspace/node_modules/dunder-proto/test/get.js +34 -0
- package/workspace/node_modules/dunder-proto/test/index.js +4 -0
- package/workspace/node_modules/dunder-proto/test/set.js +50 -0
- package/workspace/node_modules/dunder-proto/tsconfig.json +9 -0
- package/workspace/node_modules/ee-first/LICENSE +22 -0
- package/workspace/node_modules/ee-first/README.md +80 -0
- package/workspace/node_modules/ee-first/index.js +95 -0
- package/workspace/node_modules/ee-first/package.json +29 -0
- package/workspace/node_modules/encodeurl/LICENSE +22 -0
- package/workspace/node_modules/encodeurl/README.md +109 -0
- package/workspace/node_modules/encodeurl/index.js +60 -0
- package/workspace/node_modules/encodeurl/package.json +40 -0
- package/workspace/node_modules/end-of-stream/LICENSE +21 -0
- package/workspace/node_modules/end-of-stream/README.md +54 -0
- package/workspace/node_modules/end-of-stream/index.js +96 -0
- package/workspace/node_modules/end-of-stream/package.json +37 -0
- package/workspace/node_modules/es-define-property/.eslintrc +13 -0
- package/workspace/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/es-define-property/.nycrc +9 -0
- package/workspace/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/workspace/node_modules/es-define-property/LICENSE +21 -0
- package/workspace/node_modules/es-define-property/README.md +49 -0
- package/workspace/node_modules/es-define-property/index.d.ts +3 -0
- package/workspace/node_modules/es-define-property/index.js +14 -0
- package/workspace/node_modules/es-define-property/package.json +81 -0
- package/workspace/node_modules/es-define-property/test/index.js +56 -0
- package/workspace/node_modules/es-define-property/tsconfig.json +10 -0
- package/workspace/node_modules/es-errors/.eslintrc +5 -0
- package/workspace/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/es-errors/CHANGELOG.md +40 -0
- package/workspace/node_modules/es-errors/LICENSE +21 -0
- package/workspace/node_modules/es-errors/README.md +55 -0
- package/workspace/node_modules/es-errors/eval.d.ts +3 -0
- package/workspace/node_modules/es-errors/eval.js +4 -0
- package/workspace/node_modules/es-errors/index.d.ts +3 -0
- package/workspace/node_modules/es-errors/index.js +4 -0
- package/workspace/node_modules/es-errors/package.json +80 -0
- package/workspace/node_modules/es-errors/range.d.ts +3 -0
- package/workspace/node_modules/es-errors/range.js +4 -0
- package/workspace/node_modules/es-errors/ref.d.ts +3 -0
- package/workspace/node_modules/es-errors/ref.js +4 -0
- package/workspace/node_modules/es-errors/syntax.d.ts +3 -0
- package/workspace/node_modules/es-errors/syntax.js +4 -0
- package/workspace/node_modules/es-errors/test/index.js +19 -0
- package/workspace/node_modules/es-errors/tsconfig.json +49 -0
- package/workspace/node_modules/es-errors/type.d.ts +3 -0
- package/workspace/node_modules/es-errors/type.js +4 -0
- package/workspace/node_modules/es-errors/uri.d.ts +3 -0
- package/workspace/node_modules/es-errors/uri.js +4 -0
- package/workspace/node_modules/es-object-atoms/.eslintrc +16 -0
- package/workspace/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/es-object-atoms/CHANGELOG.md +37 -0
- package/workspace/node_modules/es-object-atoms/LICENSE +21 -0
- package/workspace/node_modules/es-object-atoms/README.md +63 -0
- package/workspace/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/workspace/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/workspace/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/workspace/node_modules/es-object-atoms/ToObject.js +10 -0
- package/workspace/node_modules/es-object-atoms/index.d.ts +3 -0
- package/workspace/node_modules/es-object-atoms/index.js +4 -0
- package/workspace/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/workspace/node_modules/es-object-atoms/isObject.js +6 -0
- package/workspace/node_modules/es-object-atoms/package.json +80 -0
- package/workspace/node_modules/es-object-atoms/test/index.js +38 -0
- package/workspace/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/workspace/node_modules/escape-html/LICENSE +24 -0
- package/workspace/node_modules/escape-html/Readme.md +43 -0
- package/workspace/node_modules/escape-html/index.js +78 -0
- package/workspace/node_modules/escape-html/package.json +24 -0
- package/workspace/node_modules/etag/HISTORY.md +83 -0
- package/workspace/node_modules/etag/LICENSE +22 -0
- package/workspace/node_modules/etag/README.md +159 -0
- package/workspace/node_modules/etag/index.js +131 -0
- package/workspace/node_modules/etag/package.json +47 -0
- package/workspace/node_modules/expand-template/.travis.yml +6 -0
- package/workspace/node_modules/expand-template/LICENSE +21 -0
- package/workspace/node_modules/expand-template/README.md +43 -0
- package/workspace/node_modules/expand-template/index.js +26 -0
- package/workspace/node_modules/expand-template/package.json +29 -0
- package/workspace/node_modules/expand-template/test.js +67 -0
- package/workspace/node_modules/express/LICENSE +24 -0
- package/workspace/node_modules/express/Readme.md +276 -0
- package/workspace/node_modules/express/index.js +11 -0
- package/workspace/node_modules/express/lib/application.js +631 -0
- package/workspace/node_modules/express/lib/express.js +81 -0
- package/workspace/node_modules/express/lib/request.js +514 -0
- package/workspace/node_modules/express/lib/response.js +1053 -0
- package/workspace/node_modules/express/lib/utils.js +271 -0
- package/workspace/node_modules/express/lib/view.js +205 -0
- package/workspace/node_modules/express/package.json +99 -0
- package/workspace/node_modules/file-uri-to-path/.travis.yml +30 -0
- package/workspace/node_modules/file-uri-to-path/History.md +21 -0
- package/workspace/node_modules/file-uri-to-path/LICENSE +20 -0
- package/workspace/node_modules/file-uri-to-path/README.md +74 -0
- package/workspace/node_modules/file-uri-to-path/index.d.ts +2 -0
- package/workspace/node_modules/file-uri-to-path/index.js +66 -0
- package/workspace/node_modules/file-uri-to-path/package.json +32 -0
- package/workspace/node_modules/file-uri-to-path/test/test.js +24 -0
- package/workspace/node_modules/file-uri-to-path/test/tests.json +13 -0
- package/workspace/node_modules/finalhandler/HISTORY.md +239 -0
- package/workspace/node_modules/finalhandler/LICENSE +22 -0
- package/workspace/node_modules/finalhandler/README.md +150 -0
- package/workspace/node_modules/finalhandler/index.js +293 -0
- package/workspace/node_modules/finalhandler/package.json +47 -0
- package/workspace/node_modules/forwarded/HISTORY.md +21 -0
- package/workspace/node_modules/forwarded/LICENSE +22 -0
- package/workspace/node_modules/forwarded/README.md +57 -0
- package/workspace/node_modules/forwarded/index.js +90 -0
- package/workspace/node_modules/forwarded/package.json +45 -0
- package/workspace/node_modules/fresh/HISTORY.md +80 -0
- package/workspace/node_modules/fresh/LICENSE +23 -0
- package/workspace/node_modules/fresh/README.md +117 -0
- package/workspace/node_modules/fresh/index.js +136 -0
- package/workspace/node_modules/fresh/package.json +46 -0
- package/workspace/node_modules/fs-constants/LICENSE +21 -0
- package/workspace/node_modules/fs-constants/README.md +26 -0
- package/workspace/node_modules/fs-constants/browser.js +1 -0
- package/workspace/node_modules/fs-constants/index.js +1 -0
- package/workspace/node_modules/fs-constants/package.json +19 -0
- package/workspace/node_modules/function-bind/.eslintrc +21 -0
- package/workspace/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/workspace/node_modules/function-bind/.nycrc +13 -0
- package/workspace/node_modules/function-bind/CHANGELOG.md +136 -0
- package/workspace/node_modules/function-bind/LICENSE +20 -0
- package/workspace/node_modules/function-bind/README.md +46 -0
- package/workspace/node_modules/function-bind/implementation.js +84 -0
- package/workspace/node_modules/function-bind/index.js +5 -0
- package/workspace/node_modules/function-bind/package.json +87 -0
- package/workspace/node_modules/function-bind/test/.eslintrc +9 -0
- package/workspace/node_modules/function-bind/test/index.js +252 -0
- package/workspace/node_modules/get-intrinsic/.eslintrc +42 -0
- package/workspace/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/get-intrinsic/.nycrc +9 -0
- package/workspace/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/workspace/node_modules/get-intrinsic/LICENSE +21 -0
- package/workspace/node_modules/get-intrinsic/README.md +71 -0
- package/workspace/node_modules/get-intrinsic/index.js +378 -0
- package/workspace/node_modules/get-intrinsic/package.json +97 -0
- package/workspace/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/workspace/node_modules/get-proto/.eslintrc +10 -0
- package/workspace/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/get-proto/.nycrc +9 -0
- package/workspace/node_modules/get-proto/CHANGELOG.md +21 -0
- package/workspace/node_modules/get-proto/LICENSE +21 -0
- package/workspace/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/workspace/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/workspace/node_modules/get-proto/README.md +50 -0
- package/workspace/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/workspace/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/workspace/node_modules/get-proto/index.d.ts +5 -0
- package/workspace/node_modules/get-proto/index.js +27 -0
- package/workspace/node_modules/get-proto/package.json +81 -0
- package/workspace/node_modules/get-proto/test/index.js +68 -0
- package/workspace/node_modules/get-proto/tsconfig.json +9 -0
- package/workspace/node_modules/github-from-package/.travis.yml +4 -0
- package/workspace/node_modules/github-from-package/LICENSE +18 -0
- package/workspace/node_modules/github-from-package/example/package.json +8 -0
- package/workspace/node_modules/github-from-package/example/url.js +3 -0
- package/workspace/node_modules/github-from-package/index.js +17 -0
- package/workspace/node_modules/github-from-package/package.json +30 -0
- package/workspace/node_modules/github-from-package/readme.markdown +53 -0
- package/workspace/node_modules/github-from-package/test/a.json +8 -0
- package/workspace/node_modules/github-from-package/test/b.json +5 -0
- package/workspace/node_modules/github-from-package/test/c.json +5 -0
- package/workspace/node_modules/github-from-package/test/d.json +7 -0
- package/workspace/node_modules/github-from-package/test/e.json +5 -0
- package/workspace/node_modules/github-from-package/test/url.js +19 -0
- package/workspace/node_modules/gopd/.eslintrc +16 -0
- package/workspace/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/gopd/CHANGELOG.md +45 -0
- package/workspace/node_modules/gopd/LICENSE +21 -0
- package/workspace/node_modules/gopd/README.md +40 -0
- package/workspace/node_modules/gopd/gOPD.d.ts +1 -0
- package/workspace/node_modules/gopd/gOPD.js +4 -0
- package/workspace/node_modules/gopd/index.d.ts +5 -0
- package/workspace/node_modules/gopd/index.js +15 -0
- package/workspace/node_modules/gopd/package.json +77 -0
- package/workspace/node_modules/gopd/test/index.js +36 -0
- package/workspace/node_modules/gopd/tsconfig.json +9 -0
- package/workspace/node_modules/has-symbols/.eslintrc +11 -0
- package/workspace/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/has-symbols/.nycrc +9 -0
- package/workspace/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/workspace/node_modules/has-symbols/LICENSE +21 -0
- package/workspace/node_modules/has-symbols/README.md +46 -0
- package/workspace/node_modules/has-symbols/index.d.ts +3 -0
- package/workspace/node_modules/has-symbols/index.js +14 -0
- package/workspace/node_modules/has-symbols/package.json +111 -0
- package/workspace/node_modules/has-symbols/shams.d.ts +3 -0
- package/workspace/node_modules/has-symbols/shams.js +45 -0
- package/workspace/node_modules/has-symbols/test/index.js +22 -0
- package/workspace/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/workspace/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/workspace/node_modules/has-symbols/test/tests.js +58 -0
- package/workspace/node_modules/has-symbols/tsconfig.json +10 -0
- package/workspace/node_modules/hasown/.eslintrc +5 -0
- package/workspace/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/hasown/.nycrc +13 -0
- package/workspace/node_modules/hasown/CHANGELOG.md +40 -0
- package/workspace/node_modules/hasown/LICENSE +21 -0
- package/workspace/node_modules/hasown/README.md +40 -0
- package/workspace/node_modules/hasown/index.d.ts +3 -0
- package/workspace/node_modules/hasown/index.js +8 -0
- package/workspace/node_modules/hasown/package.json +92 -0
- package/workspace/node_modules/hasown/tsconfig.json +6 -0
- package/workspace/node_modules/http-errors/HISTORY.md +186 -0
- package/workspace/node_modules/http-errors/LICENSE +23 -0
- package/workspace/node_modules/http-errors/README.md +169 -0
- package/workspace/node_modules/http-errors/index.js +290 -0
- package/workspace/node_modules/http-errors/package.json +54 -0
- package/workspace/node_modules/iconv-lite/LICENSE +21 -0
- package/workspace/node_modules/iconv-lite/README.md +138 -0
- package/workspace/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/workspace/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/workspace/node_modules/iconv-lite/encodings/index.js +23 -0
- package/workspace/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/workspace/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/workspace/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/workspace/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/workspace/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/workspace/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/workspace/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/workspace/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/workspace/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/workspace/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/workspace/node_modules/iconv-lite/lib/index.d.ts +129 -0
- package/workspace/node_modules/iconv-lite/lib/index.js +182 -0
- package/workspace/node_modules/iconv-lite/lib/streams.js +105 -0
- package/workspace/node_modules/iconv-lite/package.json +70 -0
- package/workspace/node_modules/iconv-lite/types/encodings.d.ts +423 -0
- package/workspace/node_modules/ieee754/LICENSE +11 -0
- package/workspace/node_modules/ieee754/README.md +51 -0
- package/workspace/node_modules/ieee754/index.d.ts +10 -0
- package/workspace/node_modules/ieee754/index.js +85 -0
- package/workspace/node_modules/ieee754/package.json +52 -0
- package/workspace/node_modules/inherits/LICENSE +16 -0
- package/workspace/node_modules/inherits/README.md +42 -0
- package/workspace/node_modules/inherits/inherits.js +9 -0
- package/workspace/node_modules/inherits/inherits_browser.js +27 -0
- package/workspace/node_modules/inherits/package.json +29 -0
- package/workspace/node_modules/ini/LICENSE +15 -0
- package/workspace/node_modules/ini/README.md +102 -0
- package/workspace/node_modules/ini/ini.js +206 -0
- package/workspace/node_modules/ini/package.json +33 -0
- package/workspace/node_modules/ipaddr.js/LICENSE +19 -0
- package/workspace/node_modules/ipaddr.js/README.md +233 -0
- package/workspace/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- package/workspace/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
- package/workspace/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
- package/workspace/node_modules/ipaddr.js/package.json +35 -0
- package/workspace/node_modules/is-promise/LICENSE +19 -0
- package/workspace/node_modules/is-promise/index.d.ts +2 -0
- package/workspace/node_modules/is-promise/index.js +6 -0
- package/workspace/node_modules/is-promise/index.mjs +3 -0
- package/workspace/node_modules/is-promise/package.json +30 -0
- package/workspace/node_modules/is-promise/readme.md +33 -0
- package/workspace/node_modules/math-intrinsics/.eslintrc +16 -0
- package/workspace/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/workspace/node_modules/math-intrinsics/LICENSE +21 -0
- package/workspace/node_modules/math-intrinsics/README.md +50 -0
- package/workspace/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/abs.js +4 -0
- package/workspace/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/workspace/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/workspace/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/workspace/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/floor.js +4 -0
- package/workspace/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/isFinite.js +12 -0
- package/workspace/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/isInteger.js +16 -0
- package/workspace/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/isNaN.js +6 -0
- package/workspace/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/workspace/node_modules/math-intrinsics/max.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/max.js +4 -0
- package/workspace/node_modules/math-intrinsics/min.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/min.js +4 -0
- package/workspace/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/mod.js +9 -0
- package/workspace/node_modules/math-intrinsics/package.json +86 -0
- package/workspace/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/pow.js +4 -0
- package/workspace/node_modules/math-intrinsics/round.d.ts +1 -0
- package/workspace/node_modules/math-intrinsics/round.js +4 -0
- package/workspace/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/workspace/node_modules/math-intrinsics/sign.js +11 -0
- package/workspace/node_modules/math-intrinsics/test/index.js +192 -0
- package/workspace/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/workspace/node_modules/media-typer/HISTORY.md +50 -0
- package/workspace/node_modules/media-typer/LICENSE +22 -0
- package/workspace/node_modules/media-typer/README.md +93 -0
- package/workspace/node_modules/media-typer/index.js +143 -0
- package/workspace/node_modules/media-typer/package.json +33 -0
- package/workspace/node_modules/merge-descriptors/index.d.ts +11 -0
- package/workspace/node_modules/merge-descriptors/index.js +26 -0
- package/workspace/node_modules/merge-descriptors/license +11 -0
- package/workspace/node_modules/merge-descriptors/package.json +50 -0
- package/workspace/node_modules/merge-descriptors/readme.md +55 -0
- package/workspace/node_modules/mime-db/HISTORY.md +541 -0
- package/workspace/node_modules/mime-db/LICENSE +23 -0
- package/workspace/node_modules/mime-db/README.md +109 -0
- package/workspace/node_modules/mime-db/db.json +9342 -0
- package/workspace/node_modules/mime-db/index.js +12 -0
- package/workspace/node_modules/mime-db/package.json +56 -0
- package/workspace/node_modules/mime-types/HISTORY.md +428 -0
- package/workspace/node_modules/mime-types/LICENSE +23 -0
- package/workspace/node_modules/mime-types/README.md +126 -0
- package/workspace/node_modules/mime-types/index.js +211 -0
- package/workspace/node_modules/mime-types/mimeScore.js +57 -0
- package/workspace/node_modules/mime-types/package.json +49 -0
- package/workspace/node_modules/mimic-response/index.d.ts +17 -0
- package/workspace/node_modules/mimic-response/index.js +77 -0
- package/workspace/node_modules/mimic-response/license +9 -0
- package/workspace/node_modules/mimic-response/package.json +42 -0
- package/workspace/node_modules/mimic-response/readme.md +78 -0
- package/workspace/node_modules/minimist/.eslintrc +29 -0
- package/workspace/node_modules/minimist/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/minimist/.nycrc +14 -0
- package/workspace/node_modules/minimist/CHANGELOG.md +298 -0
- package/workspace/node_modules/minimist/LICENSE +18 -0
- package/workspace/node_modules/minimist/README.md +121 -0
- package/workspace/node_modules/minimist/example/parse.js +4 -0
- package/workspace/node_modules/minimist/index.js +263 -0
- package/workspace/node_modules/minimist/package.json +75 -0
- package/workspace/node_modules/minimist/test/all_bool.js +34 -0
- package/workspace/node_modules/minimist/test/bool.js +177 -0
- package/workspace/node_modules/minimist/test/dash.js +43 -0
- package/workspace/node_modules/minimist/test/default_bool.js +37 -0
- package/workspace/node_modules/minimist/test/dotted.js +24 -0
- package/workspace/node_modules/minimist/test/kv_short.js +32 -0
- package/workspace/node_modules/minimist/test/long.js +33 -0
- package/workspace/node_modules/minimist/test/num.js +38 -0
- package/workspace/node_modules/minimist/test/parse.js +209 -0
- package/workspace/node_modules/minimist/test/parse_modified.js +11 -0
- package/workspace/node_modules/minimist/test/proto.js +64 -0
- package/workspace/node_modules/minimist/test/short.js +69 -0
- package/workspace/node_modules/minimist/test/stop_early.js +17 -0
- package/workspace/node_modules/minimist/test/unknown.js +104 -0
- package/workspace/node_modules/minimist/test/whitespace.js +10 -0
- package/workspace/node_modules/mkdirp-classic/LICENSE +21 -0
- package/workspace/node_modules/mkdirp-classic/README.md +18 -0
- package/workspace/node_modules/mkdirp-classic/index.js +98 -0
- package/workspace/node_modules/mkdirp-classic/package.json +18 -0
- package/workspace/node_modules/ms/index.js +162 -0
- package/workspace/node_modules/ms/license.md +21 -0
- package/workspace/node_modules/ms/package.json +38 -0
- package/workspace/node_modules/ms/readme.md +59 -0
- package/workspace/node_modules/napi-build-utils/.github/workflows/run-npm-tests.yml +31 -0
- package/workspace/node_modules/napi-build-utils/LICENSE +21 -0
- package/workspace/node_modules/napi-build-utils/README.md +52 -0
- package/workspace/node_modules/napi-build-utils/index.js +214 -0
- package/workspace/node_modules/napi-build-utils/index.md +0 -0
- package/workspace/node_modules/napi-build-utils/package.json +42 -0
- package/workspace/node_modules/negotiator/HISTORY.md +114 -0
- package/workspace/node_modules/negotiator/LICENSE +24 -0
- package/workspace/node_modules/negotiator/README.md +212 -0
- package/workspace/node_modules/negotiator/index.js +83 -0
- package/workspace/node_modules/negotiator/lib/charset.js +169 -0
- package/workspace/node_modules/negotiator/lib/encoding.js +205 -0
- package/workspace/node_modules/negotiator/lib/language.js +179 -0
- package/workspace/node_modules/negotiator/lib/mediaType.js +294 -0
- package/workspace/node_modules/negotiator/package.json +43 -0
- package/workspace/node_modules/node-abi/LICENSE +21 -0
- package/workspace/node_modules/node-abi/README.md +54 -0
- package/workspace/node_modules/node-abi/abi_registry.json +439 -0
- package/workspace/node_modules/node-abi/index.js +179 -0
- package/workspace/node_modules/node-abi/package.json +45 -0
- package/workspace/node_modules/object-inspect/.eslintrc +53 -0
- package/workspace/node_modules/object-inspect/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/object-inspect/.nycrc +13 -0
- package/workspace/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/workspace/node_modules/object-inspect/LICENSE +21 -0
- package/workspace/node_modules/object-inspect/example/all.js +23 -0
- package/workspace/node_modules/object-inspect/example/circular.js +6 -0
- package/workspace/node_modules/object-inspect/example/fn.js +5 -0
- package/workspace/node_modules/object-inspect/example/inspect.js +10 -0
- package/workspace/node_modules/object-inspect/index.js +544 -0
- package/workspace/node_modules/object-inspect/package-support.json +20 -0
- package/workspace/node_modules/object-inspect/package.json +105 -0
- package/workspace/node_modules/object-inspect/readme.markdown +84 -0
- package/workspace/node_modules/object-inspect/test/bigint.js +58 -0
- package/workspace/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/workspace/node_modules/object-inspect/test/circular.js +16 -0
- package/workspace/node_modules/object-inspect/test/deep.js +12 -0
- package/workspace/node_modules/object-inspect/test/element.js +53 -0
- package/workspace/node_modules/object-inspect/test/err.js +48 -0
- package/workspace/node_modules/object-inspect/test/fakes.js +29 -0
- package/workspace/node_modules/object-inspect/test/fn.js +76 -0
- package/workspace/node_modules/object-inspect/test/global.js +17 -0
- package/workspace/node_modules/object-inspect/test/has.js +15 -0
- package/workspace/node_modules/object-inspect/test/holes.js +15 -0
- package/workspace/node_modules/object-inspect/test/indent-option.js +271 -0
- package/workspace/node_modules/object-inspect/test/inspect.js +139 -0
- package/workspace/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/workspace/node_modules/object-inspect/test/number.js +58 -0
- package/workspace/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/workspace/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/workspace/node_modules/object-inspect/test/undef.js +12 -0
- package/workspace/node_modules/object-inspect/test/values.js +261 -0
- package/workspace/node_modules/object-inspect/test-core-js.js +26 -0
- package/workspace/node_modules/object-inspect/util.inspect.js +1 -0
- package/workspace/node_modules/on-finished/HISTORY.md +98 -0
- package/workspace/node_modules/on-finished/LICENSE +23 -0
- package/workspace/node_modules/on-finished/README.md +162 -0
- package/workspace/node_modules/on-finished/index.js +234 -0
- package/workspace/node_modules/on-finished/package.json +39 -0
- package/workspace/node_modules/once/LICENSE +15 -0
- package/workspace/node_modules/once/README.md +79 -0
- package/workspace/node_modules/once/once.js +42 -0
- package/workspace/node_modules/once/package.json +33 -0
- package/workspace/node_modules/parseurl/HISTORY.md +58 -0
- package/workspace/node_modules/parseurl/LICENSE +24 -0
- package/workspace/node_modules/parseurl/README.md +133 -0
- package/workspace/node_modules/parseurl/index.js +158 -0
- package/workspace/node_modules/parseurl/package.json +40 -0
- package/workspace/node_modules/path-to-regexp/LICENSE +21 -0
- package/workspace/node_modules/path-to-regexp/Readme.md +224 -0
- package/workspace/node_modules/path-to-regexp/dist/index.d.ts +147 -0
- package/workspace/node_modules/path-to-regexp/dist/index.js +426 -0
- package/workspace/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/workspace/node_modules/path-to-regexp/package.json +64 -0
- package/workspace/node_modules/prebuild-install/CHANGELOG.md +131 -0
- package/workspace/node_modules/prebuild-install/CONTRIBUTING.md +6 -0
- package/workspace/node_modules/prebuild-install/LICENSE +21 -0
- package/workspace/node_modules/prebuild-install/README.md +163 -0
- package/workspace/node_modules/prebuild-install/asset.js +44 -0
- package/workspace/node_modules/prebuild-install/bin.js +78 -0
- package/workspace/node_modules/prebuild-install/download.js +142 -0
- package/workspace/node_modules/prebuild-install/error.js +14 -0
- package/workspace/node_modules/prebuild-install/help.txt +16 -0
- package/workspace/node_modules/prebuild-install/index.js +1 -0
- package/workspace/node_modules/prebuild-install/log.js +33 -0
- package/workspace/node_modules/prebuild-install/package.json +67 -0
- package/workspace/node_modules/prebuild-install/proxy.js +35 -0
- package/workspace/node_modules/prebuild-install/rc.js +64 -0
- package/workspace/node_modules/prebuild-install/util.js +143 -0
- package/workspace/node_modules/proxy-addr/HISTORY.md +161 -0
- package/workspace/node_modules/proxy-addr/LICENSE +22 -0
- package/workspace/node_modules/proxy-addr/README.md +139 -0
- package/workspace/node_modules/proxy-addr/index.js +327 -0
- package/workspace/node_modules/proxy-addr/package.json +47 -0
- package/workspace/node_modules/pump/.github/FUNDING.yml +2 -0
- package/workspace/node_modules/pump/.travis.yml +5 -0
- package/workspace/node_modules/pump/LICENSE +21 -0
- package/workspace/node_modules/pump/README.md +74 -0
- package/workspace/node_modules/pump/SECURITY.md +5 -0
- package/workspace/node_modules/pump/empty.js +1 -0
- package/workspace/node_modules/pump/index.js +86 -0
- package/workspace/node_modules/pump/package.json +30 -0
- package/workspace/node_modules/pump/test-browser.js +66 -0
- package/workspace/node_modules/pump/test-node.js +53 -0
- package/workspace/node_modules/qs/.editorconfig +46 -0
- package/workspace/node_modules/qs/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/qs/.github/SECURITY.md +11 -0
- package/workspace/node_modules/qs/.github/THREAT_MODEL.md +78 -0
- package/workspace/node_modules/qs/.nycrc +13 -0
- package/workspace/node_modules/qs/CHANGELOG.md +806 -0
- package/workspace/node_modules/qs/LICENSE.md +29 -0
- package/workspace/node_modules/qs/README.md +758 -0
- package/workspace/node_modules/qs/dist/qs.js +141 -0
- package/workspace/node_modules/qs/eslint.config.mjs +56 -0
- package/workspace/node_modules/qs/lib/formats.js +23 -0
- package/workspace/node_modules/qs/lib/index.js +11 -0
- package/workspace/node_modules/qs/lib/parse.js +373 -0
- package/workspace/node_modules/qs/lib/stringify.js +356 -0
- package/workspace/node_modules/qs/lib/utils.js +342 -0
- package/workspace/node_modules/qs/package.json +94 -0
- package/workspace/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/workspace/node_modules/qs/test/parse.js +1568 -0
- package/workspace/node_modules/qs/test/stringify.js +1310 -0
- package/workspace/node_modules/qs/test/utils.js +404 -0
- package/workspace/node_modules/range-parser/HISTORY.md +56 -0
- package/workspace/node_modules/range-parser/LICENSE +23 -0
- package/workspace/node_modules/range-parser/README.md +84 -0
- package/workspace/node_modules/range-parser/index.js +162 -0
- package/workspace/node_modules/range-parser/package.json +44 -0
- package/workspace/node_modules/raw-body/LICENSE +22 -0
- package/workspace/node_modules/raw-body/README.md +223 -0
- package/workspace/node_modules/raw-body/index.d.ts +85 -0
- package/workspace/node_modules/raw-body/index.js +336 -0
- package/workspace/node_modules/raw-body/package.json +46 -0
- package/workspace/node_modules/rc/LICENSE.APACHE2 +15 -0
- package/workspace/node_modules/rc/LICENSE.BSD +26 -0
- package/workspace/node_modules/rc/LICENSE.MIT +24 -0
- package/workspace/node_modules/rc/README.md +227 -0
- package/workspace/node_modules/rc/browser.js +7 -0
- package/workspace/node_modules/rc/cli.js +4 -0
- package/workspace/node_modules/rc/index.js +53 -0
- package/workspace/node_modules/rc/lib/utils.js +104 -0
- package/workspace/node_modules/rc/package.json +29 -0
- package/workspace/node_modules/rc/test/ini.js +16 -0
- package/workspace/node_modules/rc/test/nested-env-vars.js +50 -0
- package/workspace/node_modules/rc/test/test.js +59 -0
- package/workspace/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/workspace/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/workspace/node_modules/readable-stream/LICENSE +47 -0
- package/workspace/node_modules/readable-stream/README.md +106 -0
- package/workspace/node_modules/readable-stream/errors-browser.js +127 -0
- package/workspace/node_modules/readable-stream/errors.js +116 -0
- package/workspace/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/workspace/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/workspace/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/workspace/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/workspace/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/workspace/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/workspace/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/workspace/node_modules/readable-stream/package.json +68 -0
- package/workspace/node_modules/readable-stream/readable-browser.js +9 -0
- package/workspace/node_modules/readable-stream/readable.js +16 -0
- package/workspace/node_modules/router/HISTORY.md +228 -0
- package/workspace/node_modules/router/LICENSE +23 -0
- package/workspace/node_modules/router/README.md +416 -0
- package/workspace/node_modules/router/index.js +748 -0
- package/workspace/node_modules/router/lib/layer.js +247 -0
- package/workspace/node_modules/router/lib/route.js +242 -0
- package/workspace/node_modules/router/package.json +44 -0
- package/workspace/node_modules/safe-buffer/LICENSE +21 -0
- package/workspace/node_modules/safe-buffer/README.md +584 -0
- package/workspace/node_modules/safe-buffer/index.d.ts +187 -0
- package/workspace/node_modules/safe-buffer/index.js +65 -0
- package/workspace/node_modules/safe-buffer/package.json +51 -0
- package/workspace/node_modules/safer-buffer/LICENSE +21 -0
- package/workspace/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/workspace/node_modules/safer-buffer/Readme.md +156 -0
- package/workspace/node_modules/safer-buffer/dangerous.js +58 -0
- package/workspace/node_modules/safer-buffer/package.json +34 -0
- package/workspace/node_modules/safer-buffer/safer.js +77 -0
- package/workspace/node_modules/safer-buffer/tests.js +406 -0
- package/workspace/node_modules/semver/LICENSE +15 -0
- package/workspace/node_modules/semver/README.md +665 -0
- package/workspace/node_modules/semver/bin/semver.js +191 -0
- package/workspace/node_modules/semver/classes/comparator.js +143 -0
- package/workspace/node_modules/semver/classes/index.js +7 -0
- package/workspace/node_modules/semver/classes/range.js +557 -0
- package/workspace/node_modules/semver/classes/semver.js +333 -0
- package/workspace/node_modules/semver/functions/clean.js +8 -0
- package/workspace/node_modules/semver/functions/cmp.js +54 -0
- package/workspace/node_modules/semver/functions/coerce.js +62 -0
- package/workspace/node_modules/semver/functions/compare-build.js +9 -0
- package/workspace/node_modules/semver/functions/compare-loose.js +5 -0
- package/workspace/node_modules/semver/functions/compare.js +7 -0
- package/workspace/node_modules/semver/functions/diff.js +60 -0
- package/workspace/node_modules/semver/functions/eq.js +5 -0
- package/workspace/node_modules/semver/functions/gt.js +5 -0
- package/workspace/node_modules/semver/functions/gte.js +5 -0
- package/workspace/node_modules/semver/functions/inc.js +21 -0
- package/workspace/node_modules/semver/functions/lt.js +5 -0
- package/workspace/node_modules/semver/functions/lte.js +5 -0
- package/workspace/node_modules/semver/functions/major.js +5 -0
- package/workspace/node_modules/semver/functions/minor.js +5 -0
- package/workspace/node_modules/semver/functions/neq.js +5 -0
- package/workspace/node_modules/semver/functions/parse.js +18 -0
- package/workspace/node_modules/semver/functions/patch.js +5 -0
- package/workspace/node_modules/semver/functions/prerelease.js +8 -0
- package/workspace/node_modules/semver/functions/rcompare.js +5 -0
- package/workspace/node_modules/semver/functions/rsort.js +5 -0
- package/workspace/node_modules/semver/functions/satisfies.js +12 -0
- package/workspace/node_modules/semver/functions/sort.js +5 -0
- package/workspace/node_modules/semver/functions/valid.js +8 -0
- package/workspace/node_modules/semver/index.js +91 -0
- package/workspace/node_modules/semver/internal/constants.js +37 -0
- package/workspace/node_modules/semver/internal/debug.js +11 -0
- package/workspace/node_modules/semver/internal/identifiers.js +29 -0
- package/workspace/node_modules/semver/internal/lrucache.js +42 -0
- package/workspace/node_modules/semver/internal/parse-options.js +17 -0
- package/workspace/node_modules/semver/internal/re.js +223 -0
- package/workspace/node_modules/semver/package.json +78 -0
- package/workspace/node_modules/semver/preload.js +4 -0
- package/workspace/node_modules/semver/range.bnf +16 -0
- package/workspace/node_modules/semver/ranges/gtr.js +6 -0
- package/workspace/node_modules/semver/ranges/intersects.js +9 -0
- package/workspace/node_modules/semver/ranges/ltr.js +6 -0
- package/workspace/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/workspace/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/workspace/node_modules/semver/ranges/min-version.js +63 -0
- package/workspace/node_modules/semver/ranges/outside.js +82 -0
- package/workspace/node_modules/semver/ranges/simplify.js +49 -0
- package/workspace/node_modules/semver/ranges/subset.js +249 -0
- package/workspace/node_modules/semver/ranges/to-comparators.js +10 -0
- package/workspace/node_modules/semver/ranges/valid.js +13 -0
- package/workspace/node_modules/send/LICENSE +23 -0
- package/workspace/node_modules/send/README.md +317 -0
- package/workspace/node_modules/send/index.js +997 -0
- package/workspace/node_modules/send/package.json +63 -0
- package/workspace/node_modules/serve-static/LICENSE +25 -0
- package/workspace/node_modules/serve-static/README.md +253 -0
- package/workspace/node_modules/serve-static/index.js +208 -0
- package/workspace/node_modules/serve-static/package.json +44 -0
- package/workspace/node_modules/setprototypeof/LICENSE +13 -0
- package/workspace/node_modules/setprototypeof/README.md +31 -0
- package/workspace/node_modules/setprototypeof/index.d.ts +2 -0
- package/workspace/node_modules/setprototypeof/index.js +17 -0
- package/workspace/node_modules/setprototypeof/package.json +38 -0
- package/workspace/node_modules/setprototypeof/test/index.js +24 -0
- package/workspace/node_modules/side-channel/.editorconfig +9 -0
- package/workspace/node_modules/side-channel/.eslintrc +12 -0
- package/workspace/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/side-channel/.nycrc +13 -0
- package/workspace/node_modules/side-channel/CHANGELOG.md +110 -0
- package/workspace/node_modules/side-channel/LICENSE +21 -0
- package/workspace/node_modules/side-channel/README.md +61 -0
- package/workspace/node_modules/side-channel/index.d.ts +14 -0
- package/workspace/node_modules/side-channel/index.js +43 -0
- package/workspace/node_modules/side-channel/package.json +85 -0
- package/workspace/node_modules/side-channel/test/index.js +104 -0
- package/workspace/node_modules/side-channel/tsconfig.json +9 -0
- package/workspace/node_modules/side-channel-list/.editorconfig +9 -0
- package/workspace/node_modules/side-channel-list/.eslintrc +11 -0
- package/workspace/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/side-channel-list/.nycrc +13 -0
- package/workspace/node_modules/side-channel-list/CHANGELOG.md +15 -0
- package/workspace/node_modules/side-channel-list/LICENSE +21 -0
- package/workspace/node_modules/side-channel-list/README.md +62 -0
- package/workspace/node_modules/side-channel-list/index.d.ts +13 -0
- package/workspace/node_modules/side-channel-list/index.js +113 -0
- package/workspace/node_modules/side-channel-list/list.d.ts +14 -0
- package/workspace/node_modules/side-channel-list/package.json +77 -0
- package/workspace/node_modules/side-channel-list/test/index.js +104 -0
- package/workspace/node_modules/side-channel-list/tsconfig.json +9 -0
- package/workspace/node_modules/side-channel-map/.editorconfig +9 -0
- package/workspace/node_modules/side-channel-map/.eslintrc +11 -0
- package/workspace/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/side-channel-map/.nycrc +13 -0
- package/workspace/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/workspace/node_modules/side-channel-map/LICENSE +21 -0
- package/workspace/node_modules/side-channel-map/README.md +62 -0
- package/workspace/node_modules/side-channel-map/index.d.ts +15 -0
- package/workspace/node_modules/side-channel-map/index.js +68 -0
- package/workspace/node_modules/side-channel-map/package.json +80 -0
- package/workspace/node_modules/side-channel-map/test/index.js +114 -0
- package/workspace/node_modules/side-channel-map/tsconfig.json +9 -0
- package/workspace/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/workspace/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/workspace/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/workspace/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/workspace/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/workspace/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/workspace/node_modules/side-channel-weakmap/README.md +62 -0
- package/workspace/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/workspace/node_modules/side-channel-weakmap/index.js +84 -0
- package/workspace/node_modules/side-channel-weakmap/package.json +87 -0
- package/workspace/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/workspace/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/workspace/node_modules/simple-concat/.travis.yml +3 -0
- package/workspace/node_modules/simple-concat/LICENSE +20 -0
- package/workspace/node_modules/simple-concat/README.md +44 -0
- package/workspace/node_modules/simple-concat/index.js +15 -0
- package/workspace/node_modules/simple-concat/package.json +47 -0
- package/workspace/node_modules/simple-concat/test/basic.js +41 -0
- package/workspace/node_modules/simple-get/.github/dependabot.yml +15 -0
- package/workspace/node_modules/simple-get/.github/workflows/ci.yml +23 -0
- package/workspace/node_modules/simple-get/LICENSE +20 -0
- package/workspace/node_modules/simple-get/README.md +333 -0
- package/workspace/node_modules/simple-get/index.js +108 -0
- package/workspace/node_modules/simple-get/package.json +67 -0
- package/workspace/node_modules/statuses/HISTORY.md +87 -0
- package/workspace/node_modules/statuses/LICENSE +23 -0
- package/workspace/node_modules/statuses/README.md +139 -0
- package/workspace/node_modules/statuses/codes.json +65 -0
- package/workspace/node_modules/statuses/index.js +146 -0
- package/workspace/node_modules/statuses/package.json +49 -0
- package/workspace/node_modules/string_decoder/LICENSE +48 -0
- package/workspace/node_modules/string_decoder/README.md +47 -0
- package/workspace/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/workspace/node_modules/string_decoder/package.json +34 -0
- package/workspace/node_modules/strip-json-comments/index.js +70 -0
- package/workspace/node_modules/strip-json-comments/license +21 -0
- package/workspace/node_modules/strip-json-comments/package.json +42 -0
- package/workspace/node_modules/strip-json-comments/readme.md +64 -0
- package/workspace/node_modules/tar-fs/.travis.yml +6 -0
- package/workspace/node_modules/tar-fs/LICENSE +21 -0
- package/workspace/node_modules/tar-fs/README.md +165 -0
- package/workspace/node_modules/tar-fs/index.js +363 -0
- package/workspace/node_modules/tar-fs/package.json +41 -0
- package/workspace/node_modules/tar-fs/test/fixtures/a/hello.txt +1 -0
- package/workspace/node_modules/tar-fs/test/fixtures/b/a/test.txt +1 -0
- package/workspace/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/e/file +0 -0
- package/workspace/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
- package/workspace/node_modules/tar-fs/test/index.js +346 -0
- package/workspace/node_modules/tar-stream/LICENSE +21 -0
- package/workspace/node_modules/tar-stream/README.md +168 -0
- package/workspace/node_modules/tar-stream/extract.js +257 -0
- package/workspace/node_modules/tar-stream/headers.js +295 -0
- package/workspace/node_modules/tar-stream/index.js +2 -0
- package/workspace/node_modules/tar-stream/pack.js +255 -0
- package/workspace/node_modules/tar-stream/package.json +58 -0
- package/workspace/node_modules/tar-stream/sandbox.js +11 -0
- package/workspace/node_modules/toidentifier/HISTORY.md +9 -0
- package/workspace/node_modules/toidentifier/LICENSE +21 -0
- package/workspace/node_modules/toidentifier/README.md +61 -0
- package/workspace/node_modules/toidentifier/index.js +32 -0
- package/workspace/node_modules/toidentifier/package.json +38 -0
- package/workspace/node_modules/tunnel-agent/LICENSE +55 -0
- package/workspace/node_modules/tunnel-agent/README.md +4 -0
- package/workspace/node_modules/tunnel-agent/index.js +244 -0
- package/workspace/node_modules/tunnel-agent/package.json +22 -0
- package/workspace/node_modules/type-is/HISTORY.md +292 -0
- package/workspace/node_modules/type-is/LICENSE +23 -0
- package/workspace/node_modules/type-is/README.md +198 -0
- package/workspace/node_modules/type-is/index.js +250 -0
- package/workspace/node_modules/type-is/package.json +47 -0
- package/workspace/node_modules/unpipe/HISTORY.md +4 -0
- package/workspace/node_modules/unpipe/LICENSE +22 -0
- package/workspace/node_modules/unpipe/README.md +43 -0
- package/workspace/node_modules/unpipe/index.js +69 -0
- package/workspace/node_modules/unpipe/package.json +27 -0
- package/workspace/node_modules/util-deprecate/History.md +16 -0
- package/workspace/node_modules/util-deprecate/LICENSE +24 -0
- package/workspace/node_modules/util-deprecate/README.md +53 -0
- package/workspace/node_modules/util-deprecate/browser.js +67 -0
- package/workspace/node_modules/util-deprecate/node.js +6 -0
- package/workspace/node_modules/util-deprecate/package.json +27 -0
- package/workspace/node_modules/vary/HISTORY.md +39 -0
- package/workspace/node_modules/vary/LICENSE +22 -0
- package/workspace/node_modules/vary/README.md +101 -0
- package/workspace/node_modules/vary/index.js +149 -0
- package/workspace/node_modules/vary/package.json +43 -0
- package/workspace/node_modules/wrappy/LICENSE +15 -0
- package/workspace/node_modules/wrappy/README.md +36 -0
- package/workspace/node_modules/wrappy/package.json +29 -0
- package/workspace/node_modules/wrappy/wrappy.js +33 -0
- package/workspace/package.json +9 -0
- package/workspace/skills/backup skills/whatsapp/.claude-plugin/plugin.json +6 -0
- package/workspace/skills/backup skills/whatsapp/SKILL.md +119 -0
- package/workspace/skills/backup skills/whatsapp/skill.json +11 -0
- package/workspace/skills/backup skills/whatsapp-clinic-secretary/.claude-plugin/plugin.json +6 -0
- package/workspace/skills/backup skills/whatsapp-clinic-secretary/SCRIPT.md +154 -0
- package/workspace/skills/backup skills/whatsapp-clinic-secretary/SKILL.md +132 -0
- package/workspace/skills/backup skills/whatsapp-clinic-secretary/skill.json +12 -0
- package/workspace/skills/backup skills/whatsapp-support/SCRIPT.md +172 -0
- package/workspace/skills/backup skills/whatsapp-support/SKILL.md +21 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,1788 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn, execSync, spawnSync } from 'child_process';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import readline from 'readline';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
|
|
12
|
+
const REPO_ROOT = path.resolve(__dirname, '..');
|
|
13
|
+
const DATA_DIR = path.join(process.env.BLOBY_REAL_HOME || os.homedir(), '.bloby');
|
|
14
|
+
const IS_DEV = fs.existsSync(path.join(REPO_ROOT, '.git'));
|
|
15
|
+
const ROOT = IS_DEV ? REPO_ROOT : DATA_DIR;
|
|
16
|
+
const CONFIG_PATH = path.join(DATA_DIR, 'config.json');
|
|
17
|
+
const BIN_DIR = path.join(DATA_DIR, 'bin');
|
|
18
|
+
const CF_PATH = path.join(BIN_DIR, 'cloudflared');
|
|
19
|
+
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf-8'));
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const command = args[0];
|
|
23
|
+
const subcommand = args[1];
|
|
24
|
+
const flags = new Set(args.filter(a => a.startsWith('--')));
|
|
25
|
+
const HOSTED = flags.has('--hosted');
|
|
26
|
+
|
|
27
|
+
// ── Daemon constants & helpers ──
|
|
28
|
+
|
|
29
|
+
const PLATFORM = os.platform();
|
|
30
|
+
|
|
31
|
+
// --- systemd (Linux) ---
|
|
32
|
+
const SERVICE_NAME = 'bloby';
|
|
33
|
+
const SERVICE_PATH = `/etc/systemd/system/${SERVICE_NAME}.service`;
|
|
34
|
+
|
|
35
|
+
function needsSudo() {
|
|
36
|
+
return process.getuid() !== 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function sudoReExec() {
|
|
40
|
+
const nodePath = process.env.BLOBY_NODE_PATH || process.execPath;
|
|
41
|
+
const realHome = getRealHome();
|
|
42
|
+
const args = process.argv.slice(1);
|
|
43
|
+
const result = spawnSync('sudo', [
|
|
44
|
+
`BLOBY_NODE_PATH=${nodePath}`,
|
|
45
|
+
`BLOBY_REAL_HOME=${realHome}`,
|
|
46
|
+
nodePath, ...args,
|
|
47
|
+
], { stdio: 'inherit' });
|
|
48
|
+
process.exit(result.status ?? 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getRealUser() {
|
|
52
|
+
return process.env.SUDO_USER || os.userInfo().username;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getRealHome() {
|
|
56
|
+
if (process.env.BLOBY_REAL_HOME) return process.env.BLOBY_REAL_HOME;
|
|
57
|
+
try {
|
|
58
|
+
return execSync(`getent passwd ${getRealUser()}`, { encoding: 'utf-8' }).split(':')[5];
|
|
59
|
+
} catch {
|
|
60
|
+
return os.homedir();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isServiceInstalled() {
|
|
65
|
+
return fs.existsSync(SERVICE_PATH);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function isServiceActive() {
|
|
69
|
+
try {
|
|
70
|
+
execSync(`systemctl is-active ${SERVICE_NAME}`, { stdio: 'ignore' });
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function generateUnitFile({ user, home, nodePath, dataDir }) {
|
|
78
|
+
const nodeBinDir = path.dirname(nodePath);
|
|
79
|
+
return `[Unit]
|
|
80
|
+
Description=Bloby Bot
|
|
81
|
+
After=network-online.target
|
|
82
|
+
Wants=network-online.target
|
|
83
|
+
|
|
84
|
+
[Service]
|
|
85
|
+
Type=simple
|
|
86
|
+
User=${user}
|
|
87
|
+
WorkingDirectory=${dataDir}
|
|
88
|
+
ExecStart=${nodePath} --import tsx/esm ${dataDir}/supervisor/index.ts
|
|
89
|
+
Restart=on-failure
|
|
90
|
+
RestartSec=5
|
|
91
|
+
Environment=HOME=${home}
|
|
92
|
+
Environment=NODE_ENV=development
|
|
93
|
+
Environment=NODE_PATH=${dataDir}/node_modules
|
|
94
|
+
Environment=PATH=${nodeBinDir}:${dataDir}/node_modules/.bin:/usr/local/bin:/usr/bin:/bin
|
|
95
|
+
StandardOutput=journal
|
|
96
|
+
StandardError=journal
|
|
97
|
+
SyslogIdentifier=bloby
|
|
98
|
+
|
|
99
|
+
[Install]
|
|
100
|
+
WantedBy=multi-user.target
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// --- launchd (macOS) ---
|
|
105
|
+
const LAUNCHD_LABEL = 'com.bloby.bot';
|
|
106
|
+
const LAUNCHD_PLIST_PATH = path.join(os.homedir(), 'Library', 'LaunchAgents', `${LAUNCHD_LABEL}.plist`);
|
|
107
|
+
const LAUNCHD_LOG_DIR = path.join(os.homedir(), 'Library', 'Logs', 'bloby');
|
|
108
|
+
|
|
109
|
+
function isLaunchdInstalled() {
|
|
110
|
+
return fs.existsSync(LAUNCHD_PLIST_PATH);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isLaunchdActive() {
|
|
114
|
+
try {
|
|
115
|
+
const out = execSync(`launchctl list ${LAUNCHD_LABEL} 2>/dev/null`, { encoding: 'utf-8' });
|
|
116
|
+
// launchctl list <label> succeeds if the job is loaded; check PID field
|
|
117
|
+
const pidLine = out.split('\n').find(l => l.includes('PID'));
|
|
118
|
+
if (pidLine) {
|
|
119
|
+
const pid = pidLine.split('=')[1]?.trim();
|
|
120
|
+
return pid && pid !== '0' && pid !== '-';
|
|
121
|
+
}
|
|
122
|
+
// Fallback: if the command succeeded, it's loaded. Check if the process is running.
|
|
123
|
+
const lines = out.trim().split('\n');
|
|
124
|
+
// First line of `launchctl list <label>` output: "PID\tStatus\tLabel" header or direct values
|
|
125
|
+
// The format is: { "PID" = <pid>; "Status" = <code>; ... }
|
|
126
|
+
return !out.includes('"PID" = 0;');
|
|
127
|
+
} catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function generateLaunchdPlist({ nodePath, dataDir }) {
|
|
133
|
+
const nodeBinDir = path.dirname(nodePath);
|
|
134
|
+
fs.mkdirSync(LAUNCHD_LOG_DIR, { recursive: true });
|
|
135
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
136
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
137
|
+
<plist version="1.0">
|
|
138
|
+
<dict>
|
|
139
|
+
<key>Label</key>
|
|
140
|
+
<string>${LAUNCHD_LABEL}</string>
|
|
141
|
+
<key>ProgramArguments</key>
|
|
142
|
+
<array>
|
|
143
|
+
<string>${nodePath}</string>
|
|
144
|
+
<string>--import</string>
|
|
145
|
+
<string>tsx/esm</string>
|
|
146
|
+
<string>${dataDir}/supervisor/index.ts</string>
|
|
147
|
+
</array>
|
|
148
|
+
<key>WorkingDirectory</key>
|
|
149
|
+
<string>${dataDir}</string>
|
|
150
|
+
<key>EnvironmentVariables</key>
|
|
151
|
+
<dict>
|
|
152
|
+
<key>HOME</key>
|
|
153
|
+
<string>${os.homedir()}</string>
|
|
154
|
+
<key>NODE_ENV</key>
|
|
155
|
+
<string>development</string>
|
|
156
|
+
<key>NODE_PATH</key>
|
|
157
|
+
<string>${dataDir}/node_modules</string>
|
|
158
|
+
<key>PATH</key>
|
|
159
|
+
<string>${nodeBinDir}:${dataDir}/node_modules/.bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
|
|
160
|
+
</dict>
|
|
161
|
+
<key>RunAtLoad</key>
|
|
162
|
+
<true/>
|
|
163
|
+
<key>KeepAlive</key>
|
|
164
|
+
<dict>
|
|
165
|
+
<key>SuccessfulExit</key>
|
|
166
|
+
<false/>
|
|
167
|
+
</dict>
|
|
168
|
+
<key>ThrottleInterval</key>
|
|
169
|
+
<integer>5</integer>
|
|
170
|
+
<key>StandardOutPath</key>
|
|
171
|
+
<string>${LAUNCHD_LOG_DIR}/bloby.log</string>
|
|
172
|
+
<key>StandardErrorPath</key>
|
|
173
|
+
<string>${LAUNCHD_LOG_DIR}/bloby.log</string>
|
|
174
|
+
<key>ProcessType</key>
|
|
175
|
+
<string>Standard</string>
|
|
176
|
+
</dict>
|
|
177
|
+
</plist>
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// --- Platform-agnostic daemon helpers ---
|
|
182
|
+
|
|
183
|
+
function hasDaemonSupport() {
|
|
184
|
+
if (PLATFORM === 'darwin') return true; // launchd is always available on macOS
|
|
185
|
+
if (PLATFORM === 'linux') {
|
|
186
|
+
try { execSync('systemctl --version', { stdio: 'ignore' }); return true; } catch { return false; }
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function isDaemonInstalled() {
|
|
192
|
+
if (PLATFORM === 'darwin') return isLaunchdInstalled();
|
|
193
|
+
if (PLATFORM === 'linux') return isServiceInstalled();
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function isDaemonActive() {
|
|
198
|
+
if (PLATFORM === 'darwin') return isLaunchdActive();
|
|
199
|
+
if (PLATFORM === 'linux') return isServiceActive();
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function killAndWait(child, timeout = 10_000) {
|
|
204
|
+
return new Promise((resolve) => {
|
|
205
|
+
child.removeAllListeners('exit');
|
|
206
|
+
child.on('exit', () => resolve());
|
|
207
|
+
child.kill('SIGTERM');
|
|
208
|
+
// Force kill after timeout if SIGTERM doesn't work
|
|
209
|
+
setTimeout(() => {
|
|
210
|
+
try { child.kill('SIGKILL'); } catch {}
|
|
211
|
+
setTimeout(resolve, 500);
|
|
212
|
+
}, timeout);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ── UI helpers ──
|
|
217
|
+
|
|
218
|
+
const c = {
|
|
219
|
+
reset: '\x1b[0m',
|
|
220
|
+
dim: '\x1b[2m',
|
|
221
|
+
bold: '\x1b[1m',
|
|
222
|
+
green: '\x1b[32m',
|
|
223
|
+
cyan: '\x1b[36m',
|
|
224
|
+
yellow: '\x1b[33m',
|
|
225
|
+
red: '\x1b[31m',
|
|
226
|
+
white: '\x1b[97m',
|
|
227
|
+
blue: '\x1b[38;2;50;165;247m',
|
|
228
|
+
pink: '\x1b[38;2;219;54;163m',
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
232
|
+
const BAR_WIDTH = 30;
|
|
233
|
+
|
|
234
|
+
function gradientChar(i, total) {
|
|
235
|
+
const t = total > 1 ? i / (total - 1) : 0;
|
|
236
|
+
const r = Math.round(50 + t * (219 - 50));
|
|
237
|
+
const g = Math.round(165 + t * (54 - 165));
|
|
238
|
+
const b = Math.round(247 + t * (163 - 247));
|
|
239
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function progressBar(ratio, width = BAR_WIDTH) {
|
|
243
|
+
const filled = Math.round(ratio * width);
|
|
244
|
+
const empty = width - filled;
|
|
245
|
+
let bar = '';
|
|
246
|
+
for (let i = 0; i < filled; i++) bar += `${gradientChar(i, width)}█`;
|
|
247
|
+
bar += `${c.dim}${'░'.repeat(empty)}${c.reset}`;
|
|
248
|
+
return bar;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function link(url) {
|
|
252
|
+
return `\x1b]8;;${url}\x07${url}\x1b]8;;\x07`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function chooseTunnelMode() {
|
|
256
|
+
return new Promise((resolve) => {
|
|
257
|
+
const options = [
|
|
258
|
+
{
|
|
259
|
+
label: 'Quick Tunnel',
|
|
260
|
+
mode: 'quick',
|
|
261
|
+
tag: 'Easy and Fast',
|
|
262
|
+
tagColor: c.green,
|
|
263
|
+
desc: [
|
|
264
|
+
'Random CloudFlare tunnel URL on every start/update',
|
|
265
|
+
`Optional: Use Bloby Relay Server and access your bot at ${c.reset}${c.pink}my.bloby.bot/YOURBOT${c.reset}${c.dim} (Free)`,
|
|
266
|
+
`Or use a premium handle like ${c.reset}${c.pink}bloby.bot/YOURBOT${c.reset}${c.dim} ($5 one-time fee)`,
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
label: 'Named Tunnel',
|
|
271
|
+
mode: 'named',
|
|
272
|
+
tag: 'Advanced',
|
|
273
|
+
tagColor: c.yellow,
|
|
274
|
+
desc: [
|
|
275
|
+
'Persistent URL with your own domain',
|
|
276
|
+
'Requires a CloudFlare account + domain',
|
|
277
|
+
`Use a subdomain like ${c.reset}${c.white}bot.YOURDOMAIN.COM${c.reset}${c.dim} or the root domain`,
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
label: 'Private Network',
|
|
282
|
+
mode: 'off',
|
|
283
|
+
tag: 'Secure',
|
|
284
|
+
tagColor: c.cyan,
|
|
285
|
+
desc: [
|
|
286
|
+
'No public URL — access via local network or VPN only',
|
|
287
|
+
`Use with ${c.reset}${c.white}Tailscale${c.reset}${c.dim}, WireGuard, or any private network`,
|
|
288
|
+
`Your bot stays invisible to the internet`,
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
let selected = 0;
|
|
294
|
+
let lineCount = 0;
|
|
295
|
+
|
|
296
|
+
function writeLine(text = '') {
|
|
297
|
+
process.stdout.write(`\x1b[2K${text}\n`);
|
|
298
|
+
lineCount++;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function render() {
|
|
302
|
+
// Move cursor up to overwrite previous render
|
|
303
|
+
if (lineCount > 0) {
|
|
304
|
+
process.stdout.write(`\x1b[${lineCount}A`);
|
|
305
|
+
}
|
|
306
|
+
lineCount = 0;
|
|
307
|
+
|
|
308
|
+
writeLine(` ${c.bold}${c.white}How do you want to connect your bot?${c.reset}`);
|
|
309
|
+
writeLine();
|
|
310
|
+
|
|
311
|
+
for (let i = 0; i < options.length; i++) {
|
|
312
|
+
const opt = options[i];
|
|
313
|
+
const isSelected = i === selected;
|
|
314
|
+
const bullet = isSelected ? `${c.pink}❯` : `${c.dim} `;
|
|
315
|
+
const label = isSelected ? `${c.bold}${c.white}${opt.label}` : `${c.dim}${opt.label}`;
|
|
316
|
+
const tag = `${opt.tagColor}[${opt.tag}]${c.reset}`;
|
|
317
|
+
|
|
318
|
+
writeLine(` ${bullet} ${label}${c.reset} ${tag}`);
|
|
319
|
+
for (const line of opt.desc) {
|
|
320
|
+
writeLine(` ${c.dim}${line}${c.reset}`);
|
|
321
|
+
}
|
|
322
|
+
if (i < options.length - 1) writeLine();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
render();
|
|
327
|
+
|
|
328
|
+
// Enable raw mode for arrow key input
|
|
329
|
+
process.stdin.setRawMode(true);
|
|
330
|
+
process.stdin.resume();
|
|
331
|
+
process.stdin.setEncoding('utf-8');
|
|
332
|
+
|
|
333
|
+
const onKey = (key) => {
|
|
334
|
+
if (key === '\x1b[A' || key === 'k') { // Up
|
|
335
|
+
selected = (selected - 1 + options.length) % options.length;
|
|
336
|
+
render();
|
|
337
|
+
} else if (key === '\x1b[B' || key === 'j') { // Down
|
|
338
|
+
selected = (selected + 1) % options.length;
|
|
339
|
+
render();
|
|
340
|
+
} else if (key === '\r' || key === '\n') { // Enter
|
|
341
|
+
process.stdin.setRawMode(false);
|
|
342
|
+
process.stdin.pause();
|
|
343
|
+
process.stdin.removeListener('data', onKey);
|
|
344
|
+
resolve(options[selected].mode);
|
|
345
|
+
} else if (key === '\x03') { // Ctrl+C
|
|
346
|
+
process.stdout.write('\n');
|
|
347
|
+
process.exit(0);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
process.stdin.on('data', onKey);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async function runNamedTunnelSetup() {
|
|
356
|
+
// Ensure cloudflared is installed
|
|
357
|
+
console.log(`\n ${c.blue}⠋${c.reset} Checking cloudflared...`);
|
|
358
|
+
await installCloudflared();
|
|
359
|
+
console.log(` ${c.blue}✔${c.reset} cloudflared ready\n`);
|
|
360
|
+
|
|
361
|
+
// Login to Cloudflare
|
|
362
|
+
console.log(` ${c.bold}${c.white}Step 1:${c.reset} Log in to Cloudflare\n`);
|
|
363
|
+
console.log(` ${c.dim}This will open a browser window. Authorize the domain you want to use.${c.reset}\n`);
|
|
364
|
+
try {
|
|
365
|
+
spawnSync('cloudflared', ['tunnel', 'login'], { stdio: 'inherit' });
|
|
366
|
+
} catch {
|
|
367
|
+
if (fs.existsSync(CF_PATH)) {
|
|
368
|
+
spawnSync(CF_PATH, ['tunnel', 'login'], { stdio: 'inherit' });
|
|
369
|
+
} else {
|
|
370
|
+
console.log(`\n ${c.red}✗${c.reset} cloudflared login failed.\n`);
|
|
371
|
+
process.exit(1);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
console.log('');
|
|
375
|
+
|
|
376
|
+
// Ask for tunnel name
|
|
377
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
378
|
+
const askQ = (q) => new Promise((r) => rl.question(q, (a) => r(a.trim())));
|
|
379
|
+
|
|
380
|
+
const tunnelName = (await askQ(` ${c.bold}Tunnel name${c.reset} ${c.dim}(default: bloby)${c.reset}: `)) || 'bloby';
|
|
381
|
+
|
|
382
|
+
// Create tunnel
|
|
383
|
+
console.log(`\n ${c.blue}⠋${c.reset} Creating tunnel "${tunnelName}"...`);
|
|
384
|
+
let createOutput;
|
|
385
|
+
try {
|
|
386
|
+
createOutput = execSync(`cloudflared tunnel create ${tunnelName}`, { encoding: 'utf-8' });
|
|
387
|
+
} catch {
|
|
388
|
+
try {
|
|
389
|
+
createOutput = execSync(`${CF_PATH} tunnel create ${tunnelName}`, { encoding: 'utf-8' });
|
|
390
|
+
} catch {
|
|
391
|
+
console.log(`\n ${c.red}✗${c.reset} Failed to create tunnel. It may already exist.`);
|
|
392
|
+
console.log(` ${c.dim}Try: cloudflared tunnel list${c.reset}\n`);
|
|
393
|
+
process.exit(1);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const uuidMatch = createOutput.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
398
|
+
if (!uuidMatch) {
|
|
399
|
+
console.log(`\n ${c.red}✗${c.reset} Could not parse tunnel UUID from output.`);
|
|
400
|
+
console.log(` ${c.dim}${createOutput}${c.reset}\n`);
|
|
401
|
+
process.exit(1);
|
|
402
|
+
}
|
|
403
|
+
const tunnelUuid = uuidMatch[1];
|
|
404
|
+
console.log(` ${c.blue}✔${c.reset} Tunnel created: ${c.dim}${tunnelUuid}${c.reset}\n`);
|
|
405
|
+
|
|
406
|
+
// Ask for domain
|
|
407
|
+
const domain = await askQ(` ${c.bold}Your domain${c.reset} ${c.dim}(e.g. bot.mydomain.com)${c.reset}: `);
|
|
408
|
+
rl.close();
|
|
409
|
+
|
|
410
|
+
if (!domain) {
|
|
411
|
+
console.log(`\n ${c.red}✗${c.reset} Domain is required for named tunnels.\n`);
|
|
412
|
+
process.exit(1);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Generate cloudflared config
|
|
416
|
+
const config = fs.existsSync(CONFIG_PATH) ? JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')) : {};
|
|
417
|
+
const port = config.port || 3000;
|
|
418
|
+
const cfHome = path.join(os.homedir(), '.cloudflared');
|
|
419
|
+
const cfConfigPath = path.join(DATA_DIR, 'cloudflared-config.yml');
|
|
420
|
+
|
|
421
|
+
const yamlContent = `tunnel: ${tunnelUuid}
|
|
422
|
+
credentials-file: ${path.join(cfHome, `${tunnelUuid}.json`)}
|
|
423
|
+
ingress:
|
|
424
|
+
- service: http://localhost:${port}
|
|
425
|
+
`;
|
|
426
|
+
fs.mkdirSync(DATA_DIR, { recursive: true });
|
|
427
|
+
fs.writeFileSync(cfConfigPath, yamlContent);
|
|
428
|
+
console.log(`\n ${c.blue}✔${c.reset} Config written to ${c.dim}${cfConfigPath}${c.reset}`);
|
|
429
|
+
|
|
430
|
+
// Print DNS instructions
|
|
431
|
+
console.log(`\n ${c.dim}─────────────────────────────────${c.reset}\n`);
|
|
432
|
+
console.log(` ${c.bold}${c.white}Tunnel created!${c.reset}`);
|
|
433
|
+
console.log(` ${c.white}Add a CNAME record pointing to:${c.reset}\n`);
|
|
434
|
+
console.log(` ${c.pink}${c.bold}${tunnelUuid}.cfargotunnel.com${c.reset}\n`);
|
|
435
|
+
console.log(` ${c.dim}Or run: cloudflared tunnel route dns ${tunnelName} ${domain}${c.reset}\n`);
|
|
436
|
+
|
|
437
|
+
return { tunnelName, domain, cfConfigPath };
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
class Stepper {
|
|
441
|
+
constructor(steps) {
|
|
442
|
+
this.steps = steps;
|
|
443
|
+
this.current = 0;
|
|
444
|
+
this.frame = 0;
|
|
445
|
+
this.interval = null;
|
|
446
|
+
this.done = false;
|
|
447
|
+
this.infoLines = []; // extra lines shown below the progress bar
|
|
448
|
+
this._totalLines = 0; // total lines rendered last frame (for cursor rewind)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
start() {
|
|
452
|
+
console.log('');
|
|
453
|
+
this.interval = setInterval(() => {
|
|
454
|
+
this.frame = (this.frame + 1) % SPINNER.length;
|
|
455
|
+
this.render();
|
|
456
|
+
}, 80);
|
|
457
|
+
this.render();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
setInfo(lines) {
|
|
461
|
+
this.infoLines = lines || [];
|
|
462
|
+
this.render();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
render() {
|
|
466
|
+
if (this.done) return;
|
|
467
|
+
|
|
468
|
+
if (this._totalLines > 0) {
|
|
469
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const ratio = this.current / this.steps.length;
|
|
473
|
+
|
|
474
|
+
for (let i = 0; i < this.steps.length; i++) {
|
|
475
|
+
if (i < this.current) {
|
|
476
|
+
console.log(` ${c.blue}✔${c.reset} ${this.steps[i]}`);
|
|
477
|
+
} else if (i === this.current) {
|
|
478
|
+
console.log(` ${c.pink}${SPINNER[this.frame]}${c.reset} ${this.steps[i]}${c.dim}...${c.reset}`);
|
|
479
|
+
} else {
|
|
480
|
+
console.log(` ${c.dim}○ ${this.steps[i]}${c.reset}`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
console.log(`\n ${progressBar(ratio)} ${c.dim}${Math.round(ratio * 100)}%${c.reset}`);
|
|
485
|
+
|
|
486
|
+
// steps + blank + progress = steps.length + 2, plus info lines
|
|
487
|
+
let lineCount = this.steps.length + 2;
|
|
488
|
+
|
|
489
|
+
if (this.infoLines.length) {
|
|
490
|
+
console.log('');
|
|
491
|
+
for (const line of this.infoLines) {
|
|
492
|
+
console.log(line);
|
|
493
|
+
}
|
|
494
|
+
lineCount += 1 + this.infoLines.length;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
this._totalLines = lineCount;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
advance() {
|
|
501
|
+
this.current++;
|
|
502
|
+
this.render();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
finish() {
|
|
506
|
+
this.done = true;
|
|
507
|
+
if (this.interval) clearInterval(this.interval);
|
|
508
|
+
|
|
509
|
+
if (this._totalLines > 0) {
|
|
510
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
511
|
+
}
|
|
512
|
+
// Clear all previously rendered lines
|
|
513
|
+
for (let i = 0; i < this._totalLines; i++) {
|
|
514
|
+
process.stdout.write('\x1b[2K\n');
|
|
515
|
+
}
|
|
516
|
+
process.stdout.write(`\x1b[${this._totalLines}A`);
|
|
517
|
+
|
|
518
|
+
for (const step of this.steps) {
|
|
519
|
+
console.log(` ${c.blue}✔${c.reset} ${step}`);
|
|
520
|
+
}
|
|
521
|
+
console.log(`\n ${progressBar(1)} ${c.pink}Done${c.reset}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function banner() {
|
|
526
|
+
console.log(`
|
|
527
|
+
${c.blue}${c.bold} _______ _ ${c.reset}
|
|
528
|
+
${c.blue}${c.bold} (_______) | ${c.reset}
|
|
529
|
+
${c.blue}${c.bold} _____ | |_ _ _ _ _ _ ${c.reset}
|
|
530
|
+
${c.blue}${c.bold} | ___) | | | | ( \\ / ) | | | ${c.reset}
|
|
531
|
+
${c.pink}${c.bold} | | | | |_| |) X (| |_| | ${c.reset}
|
|
532
|
+
${c.pink}${c.bold} |_| |_|\\____(_/ \\_)\\__ | ${c.reset}
|
|
533
|
+
${c.pink}${c.bold} (____/ ${c.reset}
|
|
534
|
+
${c.dim}v${pkg.version} · Self-hosted AI agent${c.reset}`);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function getNetworkUrls(port) {
|
|
538
|
+
const urls = [];
|
|
539
|
+
const nets = os.networkInterfaces();
|
|
540
|
+
for (const [name, addrs] of Object.entries(nets)) {
|
|
541
|
+
for (const addr of addrs) {
|
|
542
|
+
if (addr.family !== 'IPv4' || addr.internal) continue;
|
|
543
|
+
const ip = addr.address;
|
|
544
|
+
// Tailscale uses 100.64.0.0/10 (CGNAT range)
|
|
545
|
+
if (ip.startsWith('100.')) {
|
|
546
|
+
urls.push({ type: 'tailscale', url: `http://${ip}:${port}`, ip });
|
|
547
|
+
} else if (ip.startsWith('192.168.') || ip.startsWith('10.') || ip.match(/^172\.(1[6-9]|2\d|3[01])\./)) {
|
|
548
|
+
urls.push({ type: 'lan', url: `http://${ip}:${port}`, ip });
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return urls;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function privateNetworkMessage(port) {
|
|
556
|
+
const urls = getNetworkUrls(port);
|
|
557
|
+
const tailscale = urls.find(u => u.type === 'tailscale');
|
|
558
|
+
const lan = urls.find(u => u.type === 'lan');
|
|
559
|
+
|
|
560
|
+
console.log(`
|
|
561
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
562
|
+
|
|
563
|
+
${c.bold}${c.white}Open your dashboard to finish setup:${c.reset}
|
|
564
|
+
`);
|
|
565
|
+
|
|
566
|
+
if (tailscale) {
|
|
567
|
+
console.log(` ${c.cyan}${c.bold}${link(tailscale.url)}${c.reset} ${c.dim}(Tailscale)${c.reset}`);
|
|
568
|
+
}
|
|
569
|
+
if (lan) {
|
|
570
|
+
console.log(` ${c.blue}${c.bold}${link(lan.url)}${c.reset} ${c.dim}(Local network)${c.reset}`);
|
|
571
|
+
}
|
|
572
|
+
console.log(` ${c.dim}${link(`http://localhost:${port}`)}${c.reset} ${c.dim}(This machine)${c.reset}`);
|
|
573
|
+
|
|
574
|
+
if (!tailscale && !lan) {
|
|
575
|
+
console.log(`
|
|
576
|
+
${c.dim}Tip: Install Tailscale to access from other devices:${c.reset}
|
|
577
|
+
${c.dim}https://tailscale.com/download${c.reset}`);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (hasDaemonSupport()) {
|
|
581
|
+
console.log(`
|
|
582
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
583
|
+
|
|
584
|
+
${c.bold}${c.white}Commands:${c.reset}
|
|
585
|
+
${c.dim}Status${c.reset} ${c.pink}bloby status${c.reset}
|
|
586
|
+
${c.dim}Logs${c.reset} ${c.pink}bloby logs${c.reset}
|
|
587
|
+
${c.dim}Stop${c.reset} ${c.pink}bloby stop${c.reset}
|
|
588
|
+
${c.dim}Restart${c.reset} ${c.pink}bloby daemon restart${c.reset}
|
|
589
|
+
${c.dim}Update${c.reset} ${c.pink}bloby update${c.reset}
|
|
590
|
+
`);
|
|
591
|
+
} else {
|
|
592
|
+
console.log(`
|
|
593
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
594
|
+
|
|
595
|
+
${c.bold}${c.white}Commands:${c.reset}
|
|
596
|
+
${c.dim}Status${c.reset} ${c.pink}bloby status${c.reset}
|
|
597
|
+
${c.dim}Update${c.reset} ${c.pink}bloby update${c.reset}
|
|
598
|
+
|
|
599
|
+
${c.dim}Press Ctrl+C to stop${c.reset}
|
|
600
|
+
`);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function tunnelFailedMessage(localUrl) {
|
|
605
|
+
console.log(`
|
|
606
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
607
|
+
|
|
608
|
+
${c.yellow}⚠${c.reset} ${c.bold}${c.white}Tunnel failed to connect${c.reset}
|
|
609
|
+
|
|
610
|
+
${c.dim}CloudFlare quick tunnels are rate-limited.${c.reset}
|
|
611
|
+
${c.dim}This usually resolves itself after a few minutes.${c.reset}
|
|
612
|
+
|
|
613
|
+
${c.bold}${c.white}Your dashboard is available locally:${c.reset}
|
|
614
|
+
|
|
615
|
+
${c.blue}${c.bold}${link(localUrl)}${c.reset}
|
|
616
|
+
${c.dim}(cmd+click or ctrl+click to open)${c.reset}
|
|
617
|
+
|
|
618
|
+
${c.bold}${c.white}To retry the tunnel:${c.reset}
|
|
619
|
+
${c.pink}bloby start${c.reset}
|
|
620
|
+
|
|
621
|
+
${c.bold}${c.white}For a persistent tunnel, use a named tunnel:${c.reset}
|
|
622
|
+
${c.pink}bloby tunnel setup${c.reset}
|
|
623
|
+
`);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function finalMessage(tunnelUrl, relayUrl) {
|
|
627
|
+
console.log(`
|
|
628
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
629
|
+
|
|
630
|
+
${c.bold}${c.white}Open your dashboard to finish setup:${c.reset}
|
|
631
|
+
|
|
632
|
+
${c.blue}${c.bold}${link(tunnelUrl)}${c.reset}
|
|
633
|
+
${c.dim}(cmd+click or ctrl+click to open)${c.reset}`);
|
|
634
|
+
|
|
635
|
+
if (relayUrl && relayUrl !== tunnelUrl) {
|
|
636
|
+
console.log(`
|
|
637
|
+
${c.bold}${c.white}Your permanent URL:${c.reset}
|
|
638
|
+
|
|
639
|
+
${c.pink}${c.bold}${link(relayUrl)}${c.reset}`);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (hasDaemonSupport()) {
|
|
643
|
+
console.log(`
|
|
644
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
645
|
+
|
|
646
|
+
${c.bold}${c.white}Commands:${c.reset}
|
|
647
|
+
${c.dim}Status${c.reset} ${c.pink}bloby status${c.reset}
|
|
648
|
+
${c.dim}Logs${c.reset} ${c.pink}bloby logs${c.reset}
|
|
649
|
+
${c.dim}Stop${c.reset} ${c.pink}bloby stop${c.reset}
|
|
650
|
+
${c.dim}Restart${c.reset} ${c.pink}bloby daemon restart${c.reset}
|
|
651
|
+
${c.dim}Update${c.reset} ${c.pink}bloby update${c.reset}
|
|
652
|
+
`);
|
|
653
|
+
} else {
|
|
654
|
+
console.log(`
|
|
655
|
+
${c.dim}─────────────────────────────────${c.reset}
|
|
656
|
+
|
|
657
|
+
${c.bold}${c.white}Commands:${c.reset}
|
|
658
|
+
${c.dim}Status${c.reset} ${c.pink}bloby status${c.reset}
|
|
659
|
+
${c.dim}Update${c.reset} ${c.pink}bloby update${c.reset}
|
|
660
|
+
|
|
661
|
+
${c.dim}Press Ctrl+C to stop${c.reset}
|
|
662
|
+
`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function writeVersionFile(version) {
|
|
667
|
+
try { fs.writeFileSync(path.join(DATA_DIR, 'VERSION'), version); } catch {}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ── Steps ──
|
|
671
|
+
|
|
672
|
+
function createConfig() {
|
|
673
|
+
fs.mkdirSync(DATA_DIR, { recursive: true });
|
|
674
|
+
if (!fs.existsSync(CONFIG_PATH)) {
|
|
675
|
+
const config = {
|
|
676
|
+
port: 3000,
|
|
677
|
+
username: '',
|
|
678
|
+
ai: { provider: '', model: '', apiKey: '' },
|
|
679
|
+
tunnel: { mode: 'quick' },
|
|
680
|
+
relay: { token: '', tier: '', url: '' },
|
|
681
|
+
};
|
|
682
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const MIN_CF_SIZE = 10 * 1024 * 1024; // 10 MB — valid cloudflared is ~30-50 MB
|
|
687
|
+
|
|
688
|
+
function hasCloudflared() {
|
|
689
|
+
// Check system-wide install
|
|
690
|
+
const which = process.platform === 'win32' ? 'where cloudflared' : 'which cloudflared';
|
|
691
|
+
try { execSync(which, { stdio: 'ignore' }); return true; } catch {}
|
|
692
|
+
|
|
693
|
+
// Check local install (validate by file size, never execute — avoids Windows popup)
|
|
694
|
+
const cfExe = process.platform === 'win32' ? CF_PATH + '.exe' : CF_PATH;
|
|
695
|
+
if (!fs.existsSync(cfExe)) return false;
|
|
696
|
+
const size = fs.statSync(cfExe).size;
|
|
697
|
+
if (size < MIN_CF_SIZE) {
|
|
698
|
+
fs.unlinkSync(cfExe);
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
async function installCloudflared() {
|
|
705
|
+
if (hasCloudflared()) return;
|
|
706
|
+
|
|
707
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
708
|
+
|
|
709
|
+
const platform = os.platform();
|
|
710
|
+
// os.arch() returns Node's arch, not the OS. Use PROCESSOR_ARCHITECTURE on Windows for real OS arch.
|
|
711
|
+
const arch = platform === 'win32'
|
|
712
|
+
? (process.env.PROCESSOR_ARCHITECTURE || os.arch()).toLowerCase()
|
|
713
|
+
: os.arch();
|
|
714
|
+
let url;
|
|
715
|
+
|
|
716
|
+
if (platform === 'win32') {
|
|
717
|
+
url = arch.includes('arm')
|
|
718
|
+
? 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-arm64.exe'
|
|
719
|
+
: 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe';
|
|
720
|
+
} else if (platform === 'darwin') {
|
|
721
|
+
url = arch === 'arm64'
|
|
722
|
+
? 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-arm64.tgz'
|
|
723
|
+
: 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-amd64.tgz';
|
|
724
|
+
} else if (platform === 'linux') {
|
|
725
|
+
if (arch === 'arm64' || arch === 'aarch64') {
|
|
726
|
+
url = 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64';
|
|
727
|
+
} else if (arch === 'arm' || arch === 'armv7l') {
|
|
728
|
+
url = 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm';
|
|
729
|
+
} else {
|
|
730
|
+
url = 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64';
|
|
731
|
+
}
|
|
732
|
+
} else {
|
|
733
|
+
throw new Error(`Unsupported platform: ${platform}/${arch}`);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
if (platform === 'win32') {
|
|
737
|
+
const dest = CF_PATH + '.exe';
|
|
738
|
+
execSync(`curl.exe -fsSL -o "${dest}" "${url}"`, { stdio: 'ignore' });
|
|
739
|
+
} else if (url.endsWith('.tgz')) {
|
|
740
|
+
execSync(`curl -fsSL "${url}" | tar xz -C "${BIN_DIR}"`, { stdio: 'ignore' });
|
|
741
|
+
} else {
|
|
742
|
+
execSync(`curl -fsSL -o "${CF_PATH}" "${url}"`, { stdio: 'ignore' });
|
|
743
|
+
fs.chmodSync(CF_PATH, 0o755);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// ── Boot server ──
|
|
748
|
+
|
|
749
|
+
function bootServer({ onTunnelUp, onReady } = {}) {
|
|
750
|
+
return new Promise((resolve, reject) => {
|
|
751
|
+
const child = spawn(
|
|
752
|
+
process.execPath,
|
|
753
|
+
['--import', 'tsx/esm', path.join(ROOT, 'supervisor/index.ts')],
|
|
754
|
+
{ cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env } },
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
let tunnelUrl = null;
|
|
758
|
+
let relayUrl = null;
|
|
759
|
+
let resolved = false;
|
|
760
|
+
let stderrBuf = '';
|
|
761
|
+
let tunnelFired = false;
|
|
762
|
+
let tunnelFailed = false;
|
|
763
|
+
|
|
764
|
+
// Vite warmup tracking
|
|
765
|
+
let viteWarmResolve;
|
|
766
|
+
const viteWarm = new Promise((r) => { viteWarmResolve = r; });
|
|
767
|
+
|
|
768
|
+
const doResolve = () => {
|
|
769
|
+
if (resolved) return;
|
|
770
|
+
resolved = true;
|
|
771
|
+
if (!tunnelFired && onTunnelUp) onTunnelUp();
|
|
772
|
+
if (onReady) onReady();
|
|
773
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
774
|
+
resolve({
|
|
775
|
+
child,
|
|
776
|
+
tunnelUrl: tunnelUrl || `http://localhost:${config.port}`,
|
|
777
|
+
relayUrl: relayUrl || config.relay?.url || null,
|
|
778
|
+
tunnelFailed,
|
|
779
|
+
viteWarm,
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
const handleData = (data) => {
|
|
784
|
+
const text = data.toString();
|
|
785
|
+
|
|
786
|
+
const tunnelMatch = text.match(/__TUNNEL_URL__=(\S+)/);
|
|
787
|
+
if (tunnelMatch) {
|
|
788
|
+
tunnelUrl = tunnelMatch[1];
|
|
789
|
+
if (!tunnelFired && onTunnelUp) { tunnelFired = true; onTunnelUp(tunnelUrl); }
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
const relayMatch = text.match(/__RELAY_URL__=(\S+)/);
|
|
793
|
+
if (relayMatch) relayUrl = relayMatch[1];
|
|
794
|
+
|
|
795
|
+
if (text.includes('__VITE_WARM__')) {
|
|
796
|
+
viteWarmResolve();
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (text.includes('__READY__')) {
|
|
800
|
+
doResolve();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (text.includes('__TUNNEL_FAILED__')) {
|
|
805
|
+
tunnelFailed = true;
|
|
806
|
+
doResolve();
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// Safety-net timeout: resolve after 45s even if __READY__ never arrives
|
|
811
|
+
setTimeout(doResolve, 45_000);
|
|
812
|
+
|
|
813
|
+
child.stdout.on('data', handleData);
|
|
814
|
+
child.stderr.on('data', (data) => {
|
|
815
|
+
stderrBuf += data.toString();
|
|
816
|
+
handleData(data);
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
process.on('SIGINT', () => child.kill('SIGINT'));
|
|
820
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
821
|
+
|
|
822
|
+
child.on('exit', (code) => {
|
|
823
|
+
if (!resolved) {
|
|
824
|
+
reject(new Error(stderrBuf.trim() || `Server exited with code ${code}`));
|
|
825
|
+
} else {
|
|
826
|
+
process.exit(code ?? 1);
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// ── Main flows ──
|
|
833
|
+
|
|
834
|
+
async function init() {
|
|
835
|
+
if (!HOSTED) banner();
|
|
836
|
+
|
|
837
|
+
createConfig();
|
|
838
|
+
writeVersionFile(pkg.version);
|
|
839
|
+
|
|
840
|
+
// --hosted: non-interactive, quick tunnel, no prompts
|
|
841
|
+
const tunnelMode = HOSTED ? 'quick' : await (async () => {
|
|
842
|
+
console.log('');
|
|
843
|
+
const mode = await chooseTunnelMode();
|
|
844
|
+
console.log('');
|
|
845
|
+
return mode;
|
|
846
|
+
})();
|
|
847
|
+
|
|
848
|
+
// Update config with chosen mode + generate wallet if needed
|
|
849
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
850
|
+
|
|
851
|
+
// Generate USDC wallet (skip if one already exists)
|
|
852
|
+
if (!config.wallet?.privateKey) {
|
|
853
|
+
const { generatePrivateKey, privateKeyToAccount } = await import('viem/accounts');
|
|
854
|
+
const privateKey = generatePrivateKey();
|
|
855
|
+
const account = privateKeyToAccount(privateKey);
|
|
856
|
+
config.wallet = { privateKey, address: account.address };
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// Handle named tunnel setup before starting
|
|
860
|
+
if (tunnelMode === 'named') {
|
|
861
|
+
const setup = await runNamedTunnelSetup();
|
|
862
|
+
config.tunnel = {
|
|
863
|
+
mode: 'named',
|
|
864
|
+
name: setup.tunnelName,
|
|
865
|
+
domain: setup.domain,
|
|
866
|
+
configPath: setup.cfConfigPath,
|
|
867
|
+
};
|
|
868
|
+
} else {
|
|
869
|
+
config.tunnel = { mode: tunnelMode };
|
|
870
|
+
}
|
|
871
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
872
|
+
|
|
873
|
+
const canDaemon = hasDaemonSupport();
|
|
874
|
+
const hasTunnelInit = tunnelMode !== 'off';
|
|
875
|
+
|
|
876
|
+
// Hosted mode: simple log lines instead of animated stepper
|
|
877
|
+
const log = HOSTED
|
|
878
|
+
? (msg) => console.log(`[bloby] ${msg}`)
|
|
879
|
+
: null;
|
|
880
|
+
|
|
881
|
+
const steps = [
|
|
882
|
+
'Creating config',
|
|
883
|
+
...(hasTunnelInit ? ['Installing cloudflared'] : []),
|
|
884
|
+
'Starting server',
|
|
885
|
+
...(hasTunnelInit ? ['Connecting tunnel', 'Verifying connection'] : []),
|
|
886
|
+
'Preparing dashboard',
|
|
887
|
+
...(canDaemon ? ['Setting up auto-start daemon'] : []),
|
|
888
|
+
];
|
|
889
|
+
|
|
890
|
+
const stepper = HOSTED ? null : new Stepper(steps);
|
|
891
|
+
if (stepper) stepper.start();
|
|
892
|
+
|
|
893
|
+
// Config already created
|
|
894
|
+
if (log) log('Config created');
|
|
895
|
+
if (stepper) stepper.advance();
|
|
896
|
+
|
|
897
|
+
// Cloudflared (skip for named — already installed during setup, skip for off — no tunnel)
|
|
898
|
+
if (hasTunnelInit && tunnelMode !== 'named') {
|
|
899
|
+
if (log) log('Installing cloudflared...');
|
|
900
|
+
await installCloudflared();
|
|
901
|
+
if (log) log('Cloudflared ready');
|
|
902
|
+
}
|
|
903
|
+
if (hasTunnelInit && stepper) stepper.advance();
|
|
904
|
+
|
|
905
|
+
// Server + Tunnel
|
|
906
|
+
if (log) log('Starting server...');
|
|
907
|
+
if (stepper) stepper.advance();
|
|
908
|
+
let result;
|
|
909
|
+
try {
|
|
910
|
+
result = await bootServer({
|
|
911
|
+
onTunnelUp: hasTunnelInit ? (url) => {
|
|
912
|
+
if (log) log(`Tunnel up: ${url}`);
|
|
913
|
+
if (stepper) {
|
|
914
|
+
stepper.advance(); // Connecting tunnel done
|
|
915
|
+
if (config.relay?.url) {
|
|
916
|
+
stepper.setInfo([
|
|
917
|
+
` ${c.dim}Waiting for ${c.reset}${c.white}${config.relay.url.replace('https://', '')}${c.reset}${c.dim} to become reachable (can take up to 2 min)${c.reset}`,
|
|
918
|
+
` ${c.dim}In the meanwhile you can access:${c.reset} ${c.blue}${link(url)}${c.reset}`,
|
|
919
|
+
]);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
} : undefined,
|
|
923
|
+
onReady: hasTunnelInit ? () => {
|
|
924
|
+
if (log) log('Connection verified');
|
|
925
|
+
if (stepper) {
|
|
926
|
+
stepper.setInfo([]);
|
|
927
|
+
stepper.advance(); // Verifying connection done
|
|
928
|
+
}
|
|
929
|
+
} : undefined,
|
|
930
|
+
});
|
|
931
|
+
} catch (err) {
|
|
932
|
+
if (stepper) stepper.finish();
|
|
933
|
+
if (HOSTED) {
|
|
934
|
+
console.error(JSON.stringify({ error: err.message }));
|
|
935
|
+
process.exit(1);
|
|
936
|
+
}
|
|
937
|
+
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
938
|
+
console.error(` ${c.dim}${err.message}${c.reset}\n`);
|
|
939
|
+
process.exit(1);
|
|
940
|
+
}
|
|
941
|
+
let { child, tunnelUrl, relayUrl, tunnelFailed, viteWarm } = result;
|
|
942
|
+
|
|
943
|
+
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
944
|
+
if (log) log('Preparing dashboard...');
|
|
945
|
+
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
946
|
+
if (stepper) stepper.advance();
|
|
947
|
+
|
|
948
|
+
// Install daemon (systemd on Linux, launchd on macOS)
|
|
949
|
+
if (canDaemon) {
|
|
950
|
+
if (log) log('Installing daemon...');
|
|
951
|
+
await killAndWait(child);
|
|
952
|
+
const nodePath = process.execPath;
|
|
953
|
+
const realHome = os.homedir();
|
|
954
|
+
const res = spawnSync(process.execPath, [process.argv[1], 'daemon', 'install'], {
|
|
955
|
+
stdio: 'pipe', // Suppress subprocess output — stepper handles UI
|
|
956
|
+
env: { ...process.env, BLOBY_NODE_PATH: nodePath, BLOBY_REAL_HOME: realHome },
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
// Wait for the daemon's supervisor to get a new tunnel URL
|
|
960
|
+
// (the old one died with the temp server we just killed)
|
|
961
|
+
if (res.status === 0 && hasTunnelInit) {
|
|
962
|
+
if (log) log('Waiting for daemon tunnel URL...');
|
|
963
|
+
let daemonTunnelUrl = null;
|
|
964
|
+
for (let i = 0; i < 30; i++) {
|
|
965
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
966
|
+
try {
|
|
967
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
968
|
+
if (cfg.tunnelUrl && cfg.tunnelUrl !== tunnelUrl) {
|
|
969
|
+
daemonTunnelUrl = cfg.tunnelUrl;
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
} catch {}
|
|
973
|
+
}
|
|
974
|
+
if (daemonTunnelUrl) tunnelUrl = daemonTunnelUrl;
|
|
975
|
+
// Also pick up relay URL that may have been saved earlier
|
|
976
|
+
try {
|
|
977
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
978
|
+
if (cfg.relay?.url) relayUrl = cfg.relay.url;
|
|
979
|
+
} catch {}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (stepper) {
|
|
983
|
+
stepper.advance();
|
|
984
|
+
stepper.finish();
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
if (HOSTED) {
|
|
988
|
+
// Machine-readable output for the provisioning script
|
|
989
|
+
const result = { tunnelUrl, status: tunnelFailed ? 'tunnel_failed' : 'ok' };
|
|
990
|
+
if (res.status === 0) result.daemon = true;
|
|
991
|
+
console.log(`__HOSTED_READY__=${JSON.stringify(result)}`);
|
|
992
|
+
process.exit(res.status ?? 0);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
if (!hasTunnelInit) {
|
|
996
|
+
privateNetworkMessage(config.port);
|
|
997
|
+
} else if (tunnelFailed) {
|
|
998
|
+
tunnelFailedMessage(tunnelUrl);
|
|
999
|
+
} else {
|
|
1000
|
+
finalMessage(tunnelUrl, relayUrl);
|
|
1001
|
+
}
|
|
1002
|
+
if (res.status === 0) {
|
|
1003
|
+
console.log(` ${c.blue}✔${c.reset} Daemon installed — Bloby will auto-start on ${PLATFORM === 'darwin' ? 'login' : 'boot'}.`);
|
|
1004
|
+
} else {
|
|
1005
|
+
console.log(` ${c.yellow}⚠${c.reset} Daemon install failed. Run ${c.pink}bloby daemon install${c.reset} manually.`);
|
|
1006
|
+
}
|
|
1007
|
+
console.log('');
|
|
1008
|
+
process.exit(res.status ?? 0);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
if (stepper) stepper.finish();
|
|
1012
|
+
if (HOSTED) {
|
|
1013
|
+
const result = { tunnelUrl, status: tunnelFailed ? 'tunnel_failed' : 'ok' };
|
|
1014
|
+
console.log(`__HOSTED_READY__=${JSON.stringify(result)}`);
|
|
1015
|
+
} else if (!hasTunnelInit) {
|
|
1016
|
+
privateNetworkMessage(config.port);
|
|
1017
|
+
} else if (tunnelFailed) {
|
|
1018
|
+
tunnelFailedMessage(tunnelUrl);
|
|
1019
|
+
} else {
|
|
1020
|
+
finalMessage(tunnelUrl, relayUrl);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
child.stdout.on('data', (d) => {
|
|
1024
|
+
process.stdout.write(` ${c.dim}${d.toString().trim()}${c.reset}\n`);
|
|
1025
|
+
});
|
|
1026
|
+
child.stderr.on('data', (d) => {
|
|
1027
|
+
const line = d.toString().trim();
|
|
1028
|
+
if (!line || line.includes('AssignProcessToJobObject')) return;
|
|
1029
|
+
process.stderr.write(` ${c.dim}${line}${c.reset}\n`);
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
async function start() {
|
|
1034
|
+
if (!fs.existsSync(CONFIG_PATH)) {
|
|
1035
|
+
return init();
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// If daemon is already running, don't start a second instance
|
|
1039
|
+
if (isDaemonInstalled() && isDaemonActive()) {
|
|
1040
|
+
banner();
|
|
1041
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1042
|
+
console.log(`\n ${c.blue}●${c.reset} Bloby is already running as a daemon.\n`);
|
|
1043
|
+
if (config.relay?.url) {
|
|
1044
|
+
console.log(` ${c.dim}URL:${c.reset} ${c.pink}${link(config.relay.url)}${c.reset}`);
|
|
1045
|
+
}
|
|
1046
|
+
console.log(` ${c.dim}Status:${c.reset} ${c.pink}bloby daemon status${c.reset}`);
|
|
1047
|
+
console.log(` ${c.dim}Logs:${c.reset} ${c.pink}bloby daemon logs${c.reset}`);
|
|
1048
|
+
console.log(` ${c.dim}Restart:${c.reset} ${c.pink}bloby daemon restart${c.reset}`);
|
|
1049
|
+
console.log(` ${c.dim}Stop:${c.reset} ${c.pink}bloby daemon stop${c.reset}\n`);
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
const canDaemon = hasDaemonSupport();
|
|
1054
|
+
const needsDaemon = canDaemon && !isDaemonInstalled();
|
|
1055
|
+
|
|
1056
|
+
banner();
|
|
1057
|
+
|
|
1058
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1059
|
+
const tunnelMode = config.tunnel?.mode ?? (config.tunnel?.enabled === false ? 'off' : 'quick');
|
|
1060
|
+
const hasTunnel = tunnelMode !== 'off';
|
|
1061
|
+
|
|
1062
|
+
const steps = [
|
|
1063
|
+
'Loading config',
|
|
1064
|
+
'Starting server',
|
|
1065
|
+
...(hasTunnel ? ['Connecting tunnel', 'Verifying connection'] : []),
|
|
1066
|
+
'Preparing dashboard',
|
|
1067
|
+
...(needsDaemon ? ['Setting up auto-start daemon'] : []),
|
|
1068
|
+
];
|
|
1069
|
+
const stepper = new Stepper(steps);
|
|
1070
|
+
stepper.start();
|
|
1071
|
+
|
|
1072
|
+
stepper.advance(); // config exists
|
|
1073
|
+
stepper.advance(); // starting
|
|
1074
|
+
|
|
1075
|
+
let result;
|
|
1076
|
+
try {
|
|
1077
|
+
result = await bootServer({
|
|
1078
|
+
onTunnelUp: (url) => {
|
|
1079
|
+
if (!hasTunnel) return;
|
|
1080
|
+
stepper.advance(); // Connecting tunnel done
|
|
1081
|
+
if (config.relay?.url) {
|
|
1082
|
+
stepper.setInfo([
|
|
1083
|
+
` ${c.dim}Waiting for ${c.reset}${c.white}${config.relay.url.replace('https://', '')}${c.reset}${c.dim} to become reachable (can take up to 2 min)${c.reset}`,
|
|
1084
|
+
` ${c.dim}In the meanwhile you can access:${c.reset} ${c.blue}${link(url)}${c.reset}`,
|
|
1085
|
+
]);
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
onReady: () => {
|
|
1089
|
+
if (!hasTunnel) return;
|
|
1090
|
+
stepper.setInfo([]);
|
|
1091
|
+
stepper.advance(); // Verifying connection done
|
|
1092
|
+
},
|
|
1093
|
+
});
|
|
1094
|
+
} catch (err) {
|
|
1095
|
+
stepper.finish();
|
|
1096
|
+
console.error(`\n ${c.red}Server failed to start:${c.reset}`);
|
|
1097
|
+
console.error(` ${c.dim}${err.message}${c.reset}\n`);
|
|
1098
|
+
process.exit(1);
|
|
1099
|
+
}
|
|
1100
|
+
let { child, tunnelUrl, relayUrl, tunnelFailed, viteWarm } = result;
|
|
1101
|
+
|
|
1102
|
+
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
1103
|
+
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
1104
|
+
stepper.advance();
|
|
1105
|
+
|
|
1106
|
+
// Install daemon (systemd on Linux, launchd on macOS) if not already installed
|
|
1107
|
+
if (needsDaemon) {
|
|
1108
|
+
await killAndWait(child);
|
|
1109
|
+
const nodePath = process.execPath;
|
|
1110
|
+
const realHome = os.homedir();
|
|
1111
|
+
const res = spawnSync(process.execPath, [process.argv[1], 'daemon', 'install'], {
|
|
1112
|
+
stdio: 'pipe', // Suppress subprocess output — stepper handles UI
|
|
1113
|
+
env: { ...process.env, BLOBY_NODE_PATH: nodePath, BLOBY_REAL_HOME: realHome },
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
// Wait for the daemon's supervisor to get a new tunnel URL
|
|
1117
|
+
if (res.status === 0 && hasTunnel) {
|
|
1118
|
+
let daemonTunnelUrl = null;
|
|
1119
|
+
for (let i = 0; i < 30; i++) {
|
|
1120
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
1121
|
+
try {
|
|
1122
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1123
|
+
if (cfg.tunnelUrl && cfg.tunnelUrl !== tunnelUrl) {
|
|
1124
|
+
daemonTunnelUrl = cfg.tunnelUrl;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
} catch {}
|
|
1128
|
+
}
|
|
1129
|
+
if (daemonTunnelUrl) tunnelUrl = daemonTunnelUrl;
|
|
1130
|
+
try {
|
|
1131
|
+
const cfg = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1132
|
+
if (cfg.relay?.url) relayUrl = cfg.relay.url;
|
|
1133
|
+
} catch {}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
stepper.advance();
|
|
1137
|
+
stepper.finish();
|
|
1138
|
+
if (!hasTunnel) {
|
|
1139
|
+
privateNetworkMessage(config.port);
|
|
1140
|
+
} else if (tunnelFailed) {
|
|
1141
|
+
tunnelFailedMessage(tunnelUrl);
|
|
1142
|
+
} else {
|
|
1143
|
+
finalMessage(tunnelUrl, relayUrl);
|
|
1144
|
+
}
|
|
1145
|
+
if (res.status === 0) {
|
|
1146
|
+
console.log(` ${c.blue}✔${c.reset} Daemon installed — Bloby will auto-start on ${PLATFORM === 'darwin' ? 'login' : 'boot'}.`);
|
|
1147
|
+
} else {
|
|
1148
|
+
console.log(` ${c.yellow}⚠${c.reset} Daemon install failed. Run ${c.pink}bloby daemon install${c.reset} manually.`);
|
|
1149
|
+
}
|
|
1150
|
+
console.log('');
|
|
1151
|
+
process.exit(res.status ?? 0);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
stepper.finish();
|
|
1155
|
+
if (!hasTunnel) {
|
|
1156
|
+
privateNetworkMessage(config.port);
|
|
1157
|
+
} else if (tunnelFailed) {
|
|
1158
|
+
tunnelFailedMessage(tunnelUrl);
|
|
1159
|
+
} else {
|
|
1160
|
+
finalMessage(tunnelUrl, relayUrl);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
child.stdout.on('data', (d) => {
|
|
1164
|
+
process.stdout.write(` ${c.dim}${d.toString().trim()}${c.reset}\n`);
|
|
1165
|
+
});
|
|
1166
|
+
child.stderr.on('data', (d) => {
|
|
1167
|
+
const line = d.toString().trim();
|
|
1168
|
+
if (!line || line.includes('AssignProcessToJobObject')) return;
|
|
1169
|
+
process.stderr.write(` ${c.dim}${line}${c.reset}\n`);
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
async function status() {
|
|
1174
|
+
const config = fs.existsSync(CONFIG_PATH) ? JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')) : null;
|
|
1175
|
+
const daemonRunning = isDaemonInstalled() && isDaemonActive();
|
|
1176
|
+
|
|
1177
|
+
// Try health endpoint
|
|
1178
|
+
let healthOk = false;
|
|
1179
|
+
let uptime = null;
|
|
1180
|
+
if (config) {
|
|
1181
|
+
try {
|
|
1182
|
+
const res = await fetch(`http://localhost:${config.port}/api/health`);
|
|
1183
|
+
const data = await res.json();
|
|
1184
|
+
healthOk = true;
|
|
1185
|
+
uptime = data.uptime;
|
|
1186
|
+
} catch {}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
if (healthOk) {
|
|
1190
|
+
console.log(`\n ${c.blue}●${c.reset} Bloby is running${daemonRunning ? ` ${c.dim}(daemon)${c.reset}` : ''}`);
|
|
1191
|
+
if (uptime != null) console.log(` ${c.dim}Uptime: ${uptime}s${c.reset}`);
|
|
1192
|
+
if (config?.tunnelUrl) {
|
|
1193
|
+
console.log(` ${c.dim}Tunnel: ${c.reset}${c.blue}${link(config.tunnelUrl)}${c.reset}`);
|
|
1194
|
+
}
|
|
1195
|
+
if (config?.relay?.url) {
|
|
1196
|
+
console.log(` ${c.dim}Relay: ${c.reset}${c.pink}${link(config.relay.url)}${c.reset}`);
|
|
1197
|
+
}
|
|
1198
|
+
console.log(` ${c.dim}Config: ${CONFIG_PATH}${c.reset}\n`);
|
|
1199
|
+
} else if (daemonRunning) {
|
|
1200
|
+
console.log(`\n ${c.yellow}●${c.reset} Bloby daemon is running but not responding yet.`);
|
|
1201
|
+
console.log(` ${c.dim}It may still be starting up. Check logs:${c.reset}`);
|
|
1202
|
+
console.log(` ${c.pink}bloby daemon logs${c.reset}\n`);
|
|
1203
|
+
} else {
|
|
1204
|
+
console.log(`\n ${c.dim}●${c.reset} Bloby is not running.\n`);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
async function update() {
|
|
1209
|
+
banner();
|
|
1210
|
+
|
|
1211
|
+
// Refuse to run the update as root — file ownership would get poisoned
|
|
1212
|
+
if (os.platform() !== 'win32' && process.getuid?.() === 0) {
|
|
1213
|
+
console.log(`\n ${c.red}✗${c.reset} Do not run ${c.bold}bloby update${c.reset} with sudo.`);
|
|
1214
|
+
console.log(` The update manages sudo internally for daemon commands.\n`);
|
|
1215
|
+
process.exit(1);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
const currentVersion = pkg.version;
|
|
1219
|
+
console.log(`\n ${c.dim}Current version: v${currentVersion}${c.reset}`);
|
|
1220
|
+
console.log(` ${c.blue}⠋${c.reset} Checking for updates...\n`);
|
|
1221
|
+
|
|
1222
|
+
// Fetch latest package info from npm registry
|
|
1223
|
+
let latest;
|
|
1224
|
+
try {
|
|
1225
|
+
const res = await fetch('https://registry.npmjs.org/bloby/latest');
|
|
1226
|
+
if (!res.ok) throw new Error();
|
|
1227
|
+
latest = await res.json();
|
|
1228
|
+
} catch {
|
|
1229
|
+
console.log(` ${c.red}✗${c.reset} Failed to check for updates\n`);
|
|
1230
|
+
process.exit(1);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
if (currentVersion === latest.version) {
|
|
1234
|
+
console.log(` ${c.blue}✔${c.reset} Already up to date (v${currentVersion})\n`);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
console.log(` ${c.dim}v${currentVersion} → v${latest.version}${c.reset}\n`);
|
|
1239
|
+
|
|
1240
|
+
// When triggered by the supervisor (BLOBY_SELF_UPDATE=1), skip daemon stop/restart —
|
|
1241
|
+
// the supervisor will exit after we finish, and the daemon manager restarts it.
|
|
1242
|
+
const selfUpdate = !!process.env.BLOBY_SELF_UPDATE;
|
|
1243
|
+
const daemonWasRunning = !selfUpdate && isDaemonInstalled() && isDaemonActive();
|
|
1244
|
+
|
|
1245
|
+
const steps = [
|
|
1246
|
+
'Downloading update',
|
|
1247
|
+
...(daemonWasRunning ? ['Stopping daemon'] : []),
|
|
1248
|
+
'Updating files',
|
|
1249
|
+
'Installing dependencies',
|
|
1250
|
+
'Building interface',
|
|
1251
|
+
...(daemonWasRunning ? ['Restarting daemon'] : []),
|
|
1252
|
+
];
|
|
1253
|
+
|
|
1254
|
+
const stepper = new Stepper(steps);
|
|
1255
|
+
stepper.start();
|
|
1256
|
+
|
|
1257
|
+
// Download tarball FIRST — before stopping daemon, so failure doesn't leave bot offline
|
|
1258
|
+
const tarballUrl = latest.dist.tarball;
|
|
1259
|
+
const tmpDir = path.join(os.tmpdir(), `bloby-update-${Date.now()}`);
|
|
1260
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
1261
|
+
const tarball = path.join(tmpDir, 'bloby.tgz');
|
|
1262
|
+
|
|
1263
|
+
try {
|
|
1264
|
+
const res = await fetch(tarballUrl);
|
|
1265
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
1266
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
1267
|
+
fs.writeFileSync(tarball, buf);
|
|
1268
|
+
execSync(`tar xzf "${tarball}" -C "${tmpDir}"`, { stdio: 'ignore' });
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
stepper.finish();
|
|
1271
|
+
console.log(`\n ${c.red}✗${c.reset} Download failed: ${e.message}\n`);
|
|
1272
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
1273
|
+
process.exit(1);
|
|
1274
|
+
}
|
|
1275
|
+
stepper.advance();
|
|
1276
|
+
|
|
1277
|
+
// Stop daemon AFTER download succeeds — minimizes downtime
|
|
1278
|
+
// Skipped during self-update (supervisor handles restart via process exit)
|
|
1279
|
+
if (daemonWasRunning) {
|
|
1280
|
+
try {
|
|
1281
|
+
if (PLATFORM === 'darwin') {
|
|
1282
|
+
execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1283
|
+
} else {
|
|
1284
|
+
const cmd = needsSudo() ? `sudo systemctl stop ${SERVICE_NAME}` : `systemctl stop ${SERVICE_NAME}`;
|
|
1285
|
+
execSync(cmd, { stdio: 'ignore' });
|
|
1286
|
+
}
|
|
1287
|
+
} catch (e) {
|
|
1288
|
+
console.log(` ${c.yellow}⚠${c.reset} Could not stop daemon: ${e.message}`);
|
|
1289
|
+
}
|
|
1290
|
+
stepper.advance();
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
const extracted = path.join(tmpDir, 'package');
|
|
1294
|
+
|
|
1295
|
+
// Update code directories (preserve workspace/ user data)
|
|
1296
|
+
try {
|
|
1297
|
+
for (const dir of ['bin', 'supervisor', 'worker', 'shared', 'scripts']) {
|
|
1298
|
+
const src = path.join(extracted, dir);
|
|
1299
|
+
if (fs.existsSync(src)) {
|
|
1300
|
+
fs.cpSync(src, path.join(DATA_DIR, dir), { recursive: true, force: true });
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// Copy workspace template only if it doesn't exist yet
|
|
1305
|
+
if (!fs.existsSync(path.join(DATA_DIR, 'workspace'))) {
|
|
1306
|
+
const wsSrc = path.join(extracted, 'workspace');
|
|
1307
|
+
if (fs.existsSync(wsSrc)) {
|
|
1308
|
+
fs.cpSync(wsSrc, path.join(DATA_DIR, 'workspace'), { recursive: true });
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// Update code files (never touches config.json, memory.db, etc.)
|
|
1313
|
+
for (const file of ['package.json', 'vite.config.ts', 'vite.bloby.config.ts', 'tsconfig.json', 'postcss.config.js', 'components.json']) {
|
|
1314
|
+
const src = path.join(extracted, file);
|
|
1315
|
+
if (fs.existsSync(src)) {
|
|
1316
|
+
fs.copyFileSync(src, path.join(DATA_DIR, file));
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// Update pre-built UI from tarball
|
|
1321
|
+
const distSrc = path.join(extracted, 'dist-bloby');
|
|
1322
|
+
if (fs.existsSync(distSrc)) {
|
|
1323
|
+
const dst = path.join(DATA_DIR, 'dist-bloby');
|
|
1324
|
+
if (fs.existsSync(dst)) fs.rmSync(dst, { recursive: true });
|
|
1325
|
+
fs.cpSync(distSrc, dst, { recursive: true });
|
|
1326
|
+
}
|
|
1327
|
+
} catch (e) {
|
|
1328
|
+
console.log(` ${c.red}✗${c.reset} File copy failed: ${e.message}`);
|
|
1329
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
1330
|
+
process.exit(1);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
stepper.advance();
|
|
1334
|
+
|
|
1335
|
+
const distDst = path.join(DATA_DIR, 'dist-bloby');
|
|
1336
|
+
|
|
1337
|
+
// Install dependencies (5 min timeout to prevent hanging forever)
|
|
1338
|
+
try {
|
|
1339
|
+
execSync('npm install --omit=dev', { cwd: DATA_DIR, stdio: 'ignore', timeout: 300_000 });
|
|
1340
|
+
} catch (e) {
|
|
1341
|
+
console.log(` ${c.yellow}⚠${c.reset} npm install issue: ${e.message}`);
|
|
1342
|
+
}
|
|
1343
|
+
stepper.advance();
|
|
1344
|
+
|
|
1345
|
+
// Rebuild UI if not in tarball
|
|
1346
|
+
if (!fs.existsSync(path.join(distDst, 'onboard.html'))) {
|
|
1347
|
+
try {
|
|
1348
|
+
if (fs.existsSync(distDst)) fs.rmSync(distDst, { recursive: true });
|
|
1349
|
+
execSync('npm run build:bloby', { cwd: DATA_DIR, stdio: 'ignore', timeout: 300_000 });
|
|
1350
|
+
} catch {}
|
|
1351
|
+
}
|
|
1352
|
+
stepper.advance();
|
|
1353
|
+
|
|
1354
|
+
// Read release notes and write version before cleanup
|
|
1355
|
+
let releaseNotes = '';
|
|
1356
|
+
try {
|
|
1357
|
+
const newPkg = JSON.parse(fs.readFileSync(path.join(extracted, 'package.json'), 'utf-8'));
|
|
1358
|
+
releaseNotes = newPkg.releaseNotes || '';
|
|
1359
|
+
} catch {}
|
|
1360
|
+
writeVersionFile(latest.version);
|
|
1361
|
+
|
|
1362
|
+
// Clean up
|
|
1363
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
1364
|
+
|
|
1365
|
+
// Restart daemon if it was running (skipped during self-update)
|
|
1366
|
+
if (daemonWasRunning) {
|
|
1367
|
+
try {
|
|
1368
|
+
if (PLATFORM === 'darwin') {
|
|
1369
|
+
execSync(`launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1370
|
+
} else {
|
|
1371
|
+
const cmd = needsSudo() ? `sudo systemctl start ${SERVICE_NAME}` : `systemctl start ${SERVICE_NAME}`;
|
|
1372
|
+
execSync(cmd, { stdio: 'ignore' });
|
|
1373
|
+
}
|
|
1374
|
+
} catch {}
|
|
1375
|
+
stepper.advance();
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
stepper.finish();
|
|
1379
|
+
|
|
1380
|
+
console.log(`\n ${c.blue}${c.bold}✔ Updated to v${latest.version}${c.reset}\n`);
|
|
1381
|
+
|
|
1382
|
+
if (releaseNotes) {
|
|
1383
|
+
console.log(` ${c.bold}${c.white}What's new:${c.reset}`);
|
|
1384
|
+
const notes = Array.isArray(releaseNotes) ? releaseNotes : [releaseNotes];
|
|
1385
|
+
notes.forEach((note, i) => {
|
|
1386
|
+
console.log(` ${c.dim}${i + 1}.${c.reset} ${note}`);
|
|
1387
|
+
});
|
|
1388
|
+
console.log('');
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// During self-update, supervisor handles restart — just exit cleanly
|
|
1392
|
+
if (selfUpdate) {
|
|
1393
|
+
console.log(` Files updated — supervisor will restart with new version.\n`);
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
if (daemonWasRunning) {
|
|
1398
|
+
if (isDaemonActive()) {
|
|
1399
|
+
console.log(` ${c.blue}✔${c.reset} Daemon restarted with new version.\n`);
|
|
1400
|
+
} else {
|
|
1401
|
+
console.log(` ${c.yellow}⚠${c.reset} Daemon may still be starting. Check ${c.pink}bloby daemon status${c.reset}\n`);
|
|
1402
|
+
}
|
|
1403
|
+
} else if (isDaemonInstalled()) {
|
|
1404
|
+
try {
|
|
1405
|
+
if (PLATFORM === 'darwin') {
|
|
1406
|
+
execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null; launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1407
|
+
} else {
|
|
1408
|
+
const cmd = needsSudo() ? `sudo systemctl start ${SERVICE_NAME}` : `systemctl start ${SERVICE_NAME}`;
|
|
1409
|
+
execSync(cmd, { stdio: 'ignore' });
|
|
1410
|
+
}
|
|
1411
|
+
console.log(` ${c.blue}✔${c.reset} Daemon started with new version.\n`);
|
|
1412
|
+
} catch {
|
|
1413
|
+
console.log(` ${c.dim}Run ${c.reset}${c.pink}bloby daemon start${c.reset}${c.dim} to launch.${c.reset}\n`);
|
|
1414
|
+
}
|
|
1415
|
+
} else {
|
|
1416
|
+
console.log(` ${c.dim}Run ${c.reset}${c.pink}bloby start${c.reset}${c.dim} to launch.${c.reset}\n`);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// ── Daemon ──
|
|
1421
|
+
|
|
1422
|
+
async function daemon(sub) {
|
|
1423
|
+
// Platform guard
|
|
1424
|
+
if (!hasDaemonSupport()) {
|
|
1425
|
+
const hint = PLATFORM === 'win32'
|
|
1426
|
+
? 'Use Task Scheduler to keep Bloby running in the background.'
|
|
1427
|
+
: 'No supported daemon system found.';
|
|
1428
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Daemon mode is not supported on this platform.`);
|
|
1429
|
+
console.log(` ${c.dim}${hint}${c.reset}\n`);
|
|
1430
|
+
process.exit(1);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
const action = sub || 'install';
|
|
1434
|
+
|
|
1435
|
+
// ── macOS (launchd) ──
|
|
1436
|
+
if (PLATFORM === 'darwin') {
|
|
1437
|
+
switch (action) {
|
|
1438
|
+
case 'install': {
|
|
1439
|
+
const dataDir = ROOT; // Uses REPO_ROOT in dev, DATA_DIR (~/.bloby) in production
|
|
1440
|
+
if (!fs.existsSync(path.join(dataDir, 'supervisor', 'index.ts'))) {
|
|
1441
|
+
console.log(`\n ${c.red}✗${c.reset} Run ${c.pink}bloby init${c.reset} first.\n`);
|
|
1442
|
+
process.exit(1);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// Unload existing plist if loaded
|
|
1446
|
+
if (isLaunchdInstalled()) {
|
|
1447
|
+
try { execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null`, { stdio: 'ignore' }); } catch {}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
const nodePath = process.env.BLOBY_NODE_PATH || process.execPath;
|
|
1451
|
+
const plist = generateLaunchdPlist({ nodePath, dataDir });
|
|
1452
|
+
|
|
1453
|
+
// Ensure LaunchAgents directory exists
|
|
1454
|
+
fs.mkdirSync(path.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
|
|
1455
|
+
fs.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
1456
|
+
execSync(`launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1457
|
+
|
|
1458
|
+
// Verify it started
|
|
1459
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
1460
|
+
if (isLaunchdActive()) {
|
|
1461
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon installed and running.`);
|
|
1462
|
+
console.log(` ${c.dim}It will auto-start on login.${c.reset}`);
|
|
1463
|
+
console.log(`\n ${c.dim}View logs:${c.reset} ${c.pink}bloby daemon logs${c.reset}`);
|
|
1464
|
+
console.log(` ${c.dim}Stop:${c.reset} ${c.pink}bloby daemon stop${c.reset}`);
|
|
1465
|
+
console.log(` ${c.dim}Uninstall:${c.reset} ${c.pink}bloby daemon uninstall${c.reset}\n`);
|
|
1466
|
+
} else {
|
|
1467
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Plist installed but process may not be running.`);
|
|
1468
|
+
console.log(` ${c.dim}Check with: ${c.reset}${c.pink}bloby daemon status${c.reset}\n`);
|
|
1469
|
+
}
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
case 'stop': {
|
|
1474
|
+
if (!isLaunchdInstalled()) {
|
|
1475
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Daemon not installed. Run ${c.pink}bloby daemon install${c.reset} first.\n`);
|
|
1476
|
+
process.exit(1);
|
|
1477
|
+
}
|
|
1478
|
+
execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1479
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon stopped.\n`);
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
case 'start': {
|
|
1484
|
+
if (!isLaunchdInstalled()) {
|
|
1485
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Daemon not installed. Run ${c.pink}bloby daemon install${c.reset} first.\n`);
|
|
1486
|
+
process.exit(1);
|
|
1487
|
+
}
|
|
1488
|
+
// Reload: unload first in case it's already loaded, then load
|
|
1489
|
+
try { execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null`, { stdio: 'ignore' }); } catch {}
|
|
1490
|
+
execSync(`launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1491
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon started.\n`);
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
case 'restart': {
|
|
1496
|
+
if (!isLaunchdInstalled()) {
|
|
1497
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Daemon not installed. Run ${c.pink}bloby daemon install${c.reset} first.\n`);
|
|
1498
|
+
process.exit(1);
|
|
1499
|
+
}
|
|
1500
|
+
try { execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null`, { stdio: 'ignore' }); } catch {}
|
|
1501
|
+
execSync(`launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1502
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon restarted.\n`);
|
|
1503
|
+
break;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
case 'status': {
|
|
1507
|
+
if (!isLaunchdInstalled()) {
|
|
1508
|
+
console.log(`\n ${c.dim}●${c.reset} Daemon not installed.\n`);
|
|
1509
|
+
break;
|
|
1510
|
+
}
|
|
1511
|
+
const active = isLaunchdActive();
|
|
1512
|
+
if (active) {
|
|
1513
|
+
console.log(`\n ${c.blue}●${c.reset} Bloby daemon is running.`);
|
|
1514
|
+
} else {
|
|
1515
|
+
console.log(`\n ${c.dim}●${c.reset} Bloby daemon is stopped.`);
|
|
1516
|
+
}
|
|
1517
|
+
console.log(` ${c.dim}Plist:${c.reset} ${LAUNCHD_PLIST_PATH}`);
|
|
1518
|
+
console.log(` ${c.dim}Logs:${c.reset} ${LAUNCHD_LOG_DIR}/bloby.log\n`);
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
case 'logs': {
|
|
1523
|
+
const logFile = path.join(LAUNCHD_LOG_DIR, 'bloby.log');
|
|
1524
|
+
if (!fs.existsSync(logFile)) {
|
|
1525
|
+
console.log(`\n ${c.dim}No logs found at ${logFile}${c.reset}\n`);
|
|
1526
|
+
break;
|
|
1527
|
+
}
|
|
1528
|
+
spawnSync('tail', ['-f', '-n', '50', logFile], { stdio: 'inherit' });
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
case 'uninstall': {
|
|
1533
|
+
try { execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null`, { stdio: 'ignore' }); } catch {}
|
|
1534
|
+
if (fs.existsSync(LAUNCHD_PLIST_PATH)) fs.unlinkSync(LAUNCHD_PLIST_PATH);
|
|
1535
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon uninstalled.\n`);
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
default:
|
|
1540
|
+
console.log(`\n ${c.red}✗${c.reset} Unknown daemon command: ${action}`);
|
|
1541
|
+
console.log(` ${c.dim}Available: install, start, stop, restart, status, logs, uninstall${c.reset}\n`);
|
|
1542
|
+
process.exit(1);
|
|
1543
|
+
}
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
// ── Linux (systemd) ──
|
|
1548
|
+
|
|
1549
|
+
// Check systemd is available
|
|
1550
|
+
try {
|
|
1551
|
+
execSync('systemctl --version', { stdio: 'ignore' });
|
|
1552
|
+
} catch {
|
|
1553
|
+
console.log(`\n ${c.red}✗${c.reset} systemd not found. Daemon mode requires systemd.\n`);
|
|
1554
|
+
process.exit(1);
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
switch (action) {
|
|
1558
|
+
case 'install': {
|
|
1559
|
+
if (!fs.existsSync(path.join(getRealHome(), '.bloby', 'supervisor', 'index.ts'))) {
|
|
1560
|
+
console.log(`\n ${c.red}✗${c.reset} Run ${c.pink}bloby init${c.reset} first.\n`);
|
|
1561
|
+
process.exit(1);
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// Re-exec with sudo if needed
|
|
1565
|
+
if (needsSudo()) sudoReExec();
|
|
1566
|
+
|
|
1567
|
+
const user = getRealUser();
|
|
1568
|
+
const home = getRealHome();
|
|
1569
|
+
const nodePath = process.env.BLOBY_NODE_PATH || process.execPath;
|
|
1570
|
+
const dataDir = path.join(home, '.bloby');
|
|
1571
|
+
|
|
1572
|
+
const unit = generateUnitFile({ user, home, nodePath, dataDir });
|
|
1573
|
+
fs.writeFileSync(SERVICE_PATH, unit);
|
|
1574
|
+
|
|
1575
|
+
execSync('systemctl daemon-reload', { stdio: 'ignore' });
|
|
1576
|
+
execSync(`systemctl enable ${SERVICE_NAME}`, { stdio: 'ignore' });
|
|
1577
|
+
execSync(`systemctl start ${SERVICE_NAME}`, { stdio: 'ignore' });
|
|
1578
|
+
|
|
1579
|
+
// Verify it started
|
|
1580
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
1581
|
+
if (isServiceActive()) {
|
|
1582
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon installed and running.`);
|
|
1583
|
+
console.log(` ${c.dim}It will auto-start on boot.${c.reset}`);
|
|
1584
|
+
console.log(`\n ${c.dim}View logs:${c.reset} ${c.pink}bloby daemon logs${c.reset}`);
|
|
1585
|
+
console.log(` ${c.dim}Stop:${c.reset} ${c.pink}bloby daemon stop${c.reset}`);
|
|
1586
|
+
console.log(` ${c.dim}Uninstall:${c.reset} ${c.pink}bloby daemon uninstall${c.reset}\n`);
|
|
1587
|
+
} else {
|
|
1588
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Service installed but may not be running.`);
|
|
1589
|
+
console.log(` ${c.dim}Check with: ${c.reset}${c.pink}bloby daemon status${c.reset}\n`);
|
|
1590
|
+
}
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
case 'stop': {
|
|
1595
|
+
if (needsSudo()) sudoReExec();
|
|
1596
|
+
execSync(`systemctl stop ${SERVICE_NAME}`, { stdio: 'inherit' });
|
|
1597
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon stopped.\n`);
|
|
1598
|
+
break;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
case 'start': {
|
|
1602
|
+
if (needsSudo()) sudoReExec();
|
|
1603
|
+
execSync(`systemctl start ${SERVICE_NAME}`, { stdio: 'inherit' });
|
|
1604
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon started.\n`);
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
case 'restart': {
|
|
1609
|
+
if (needsSudo()) sudoReExec();
|
|
1610
|
+
execSync(`systemctl restart ${SERVICE_NAME}`, { stdio: 'inherit' });
|
|
1611
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon restarted.\n`);
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
case 'status': {
|
|
1616
|
+
spawnSync('systemctl', ['status', SERVICE_NAME], { stdio: 'inherit' });
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
case 'logs': {
|
|
1621
|
+
spawnSync('journalctl', ['-u', SERVICE_NAME, '-f', '-n', '50'], { stdio: 'inherit' });
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
case 'uninstall': {
|
|
1626
|
+
if (needsSudo()) sudoReExec();
|
|
1627
|
+
try { execSync(`systemctl stop ${SERVICE_NAME}`, { stdio: 'ignore' }); } catch {}
|
|
1628
|
+
try { execSync(`systemctl disable ${SERVICE_NAME}`, { stdio: 'ignore' }); } catch {}
|
|
1629
|
+
if (fs.existsSync(SERVICE_PATH)) fs.unlinkSync(SERVICE_PATH);
|
|
1630
|
+
execSync('systemctl daemon-reload', { stdio: 'ignore' });
|
|
1631
|
+
console.log(`\n ${c.blue}✔${c.reset} Bloby daemon uninstalled.\n`);
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
default:
|
|
1636
|
+
console.log(`\n ${c.red}✗${c.reset} Unknown daemon command: ${action}`);
|
|
1637
|
+
console.log(` ${c.dim}Available: install, start, stop, restart, status, logs, uninstall${c.reset}\n`);
|
|
1638
|
+
process.exit(1);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
// ── Tunnel management ──
|
|
1643
|
+
|
|
1644
|
+
function ask(question) {
|
|
1645
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1646
|
+
return new Promise((resolve) => rl.question(question, (answer) => { rl.close(); resolve(answer.trim()); }));
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
async function tunnel(sub) {
|
|
1650
|
+
const action = sub || 'status';
|
|
1651
|
+
|
|
1652
|
+
switch (action) {
|
|
1653
|
+
case 'setup': {
|
|
1654
|
+
banner();
|
|
1655
|
+
console.log(`\n ${c.bold}${c.white}Named Tunnel Setup${c.reset}`);
|
|
1656
|
+
|
|
1657
|
+
const setup = await runNamedTunnelSetup();
|
|
1658
|
+
|
|
1659
|
+
// Update bloby config
|
|
1660
|
+
const config = fs.existsSync(CONFIG_PATH) ? JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')) : {};
|
|
1661
|
+
config.tunnel = {
|
|
1662
|
+
mode: 'named',
|
|
1663
|
+
name: setup.tunnelName,
|
|
1664
|
+
domain: setup.domain,
|
|
1665
|
+
configPath: setup.cfConfigPath,
|
|
1666
|
+
};
|
|
1667
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
1668
|
+
console.log(` ${c.blue}✔${c.reset} Bloby config updated\n`);
|
|
1669
|
+
|
|
1670
|
+
// Offer restart if daemon is running
|
|
1671
|
+
if (isDaemonInstalled() && isDaemonActive()) {
|
|
1672
|
+
const restart = await ask(` ${c.bold}Restart daemon now?${c.reset} ${c.dim}(Y/n)${c.reset}: `);
|
|
1673
|
+
if (!restart || restart.toLowerCase() === 'y') {
|
|
1674
|
+
try {
|
|
1675
|
+
if (PLATFORM === 'darwin') {
|
|
1676
|
+
execSync(`launchctl unload "${LAUNCHD_PLIST_PATH}" 2>/dev/null; launchctl load "${LAUNCHD_PLIST_PATH}"`, { stdio: 'ignore' });
|
|
1677
|
+
} else {
|
|
1678
|
+
const cmd = needsSudo() ? `sudo systemctl restart ${SERVICE_NAME}` : `systemctl restart ${SERVICE_NAME}`;
|
|
1679
|
+
execSync(cmd, { stdio: 'ignore' });
|
|
1680
|
+
}
|
|
1681
|
+
console.log(`\n ${c.blue}✔${c.reset} Daemon restarted.\n`);
|
|
1682
|
+
} catch {
|
|
1683
|
+
console.log(`\n ${c.yellow}⚠${c.reset} Restart failed. Try ${c.pink}bloby daemon restart${c.reset}\n`);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
} else {
|
|
1687
|
+
console.log(` ${c.dim}Run ${c.reset}${c.pink}bloby start${c.reset}${c.dim} to launch with the named tunnel.${c.reset}\n`);
|
|
1688
|
+
}
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
case 'status': {
|
|
1693
|
+
if (!fs.existsSync(CONFIG_PATH)) {
|
|
1694
|
+
console.log(`\n ${c.dim}No config found. Run ${c.reset}${c.pink}bloby init${c.reset}${c.dim} first.${c.reset}\n`);
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1698
|
+
const mode = config.tunnel?.mode ?? (config.tunnel?.enabled === false ? 'off' : 'quick');
|
|
1699
|
+
|
|
1700
|
+
console.log(`\n ${c.bold}${c.white}Tunnel Configuration${c.reset}\n`);
|
|
1701
|
+
console.log(` ${c.dim}Mode:${c.reset} ${c.bold}${mode}${c.reset}`);
|
|
1702
|
+
if (mode === 'named') {
|
|
1703
|
+
if (config.tunnel?.name) console.log(` ${c.dim}Name:${c.reset} ${config.tunnel.name}`);
|
|
1704
|
+
if (config.tunnel?.domain) console.log(` ${c.dim}Domain:${c.reset} ${c.pink}${config.tunnel.domain}${c.reset}`);
|
|
1705
|
+
if (config.tunnel?.configPath) console.log(` ${c.dim}Config:${c.reset} ${config.tunnel.configPath}`);
|
|
1706
|
+
}
|
|
1707
|
+
if (config.tunnelUrl) {
|
|
1708
|
+
console.log(` ${c.dim}URL:${c.reset} ${c.blue}${link(config.tunnelUrl)}${c.reset}`);
|
|
1709
|
+
}
|
|
1710
|
+
console.log('');
|
|
1711
|
+
break;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
case 'reset': {
|
|
1715
|
+
if (!fs.existsSync(CONFIG_PATH)) {
|
|
1716
|
+
console.log(`\n ${c.dim}No config found. Run ${c.reset}${c.pink}bloby init${c.reset}${c.dim} first.${c.reset}\n`);
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
1720
|
+
config.tunnel = { mode: 'quick' };
|
|
1721
|
+
delete config.tunnelUrl;
|
|
1722
|
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
1723
|
+
console.log(`\n ${c.blue}✔${c.reset} Tunnel mode reset to ${c.bold}quick${c.reset} (random trycloudflare.com URL).\n`);
|
|
1724
|
+
|
|
1725
|
+
if (isDaemonInstalled() && isDaemonActive()) {
|
|
1726
|
+
console.log(` ${c.dim}Restart the daemon to apply: ${c.reset}${c.pink}bloby daemon restart${c.reset}\n`);
|
|
1727
|
+
}
|
|
1728
|
+
break;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
default:
|
|
1732
|
+
console.log(`\n ${c.red}✗${c.reset} Unknown tunnel command: ${action}`);
|
|
1733
|
+
console.log(` ${c.dim}Available: setup, status, reset${c.reset}\n`);
|
|
1734
|
+
process.exit(1);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// ── Password Reset ──
|
|
1739
|
+
|
|
1740
|
+
async function passwordReset() {
|
|
1741
|
+
const DB_PATH = path.join(DATA_DIR, 'memory.db');
|
|
1742
|
+
|
|
1743
|
+
if (!fs.existsSync(DB_PATH)) {
|
|
1744
|
+
console.log(`\n ${c.red}✗${c.reset} No database found. Run ${c.pink}bloby init${c.reset} and complete setup first.\n`);
|
|
1745
|
+
process.exit(1);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
const Database = (await import('better-sqlite3')).default;
|
|
1749
|
+
const db = new Database(DB_PATH);
|
|
1750
|
+
|
|
1751
|
+
// Clear password and TOTP credentials
|
|
1752
|
+
db.prepare("DELETE FROM settings WHERE key IN ('portal_pass', 'totp_enabled', 'totp_secret', 'totp_recovery_codes')").run();
|
|
1753
|
+
|
|
1754
|
+
// Reset onboard flag so the wizard appears on next visit
|
|
1755
|
+
db.prepare("INSERT INTO settings (key, value) VALUES ('onboard_complete', 'false') ON CONFLICT(key) DO UPDATE SET value = 'false', updated_at = CURRENT_TIMESTAMP").run();
|
|
1756
|
+
|
|
1757
|
+
// Invalidate all active sessions and trusted devices
|
|
1758
|
+
db.prepare('DELETE FROM sessions').run();
|
|
1759
|
+
db.prepare('DELETE FROM trusted_devices').run();
|
|
1760
|
+
|
|
1761
|
+
db.close();
|
|
1762
|
+
|
|
1763
|
+
console.log(`\n ${c.blue}✔${c.reset} Password reset successful.\n`);
|
|
1764
|
+
console.log(` ${c.dim}The onboard wizard will appear on your next visit`);
|
|
1765
|
+
console.log(` so you can create a new password.${c.reset}\n`);
|
|
1766
|
+
|
|
1767
|
+
// Auto-restart daemon if it's running
|
|
1768
|
+
if (isDaemonInstalled() && isDaemonActive()) {
|
|
1769
|
+
console.log(` ${c.dim}Restarting Bloby daemon...${c.reset}`);
|
|
1770
|
+
daemon('restart');
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// ── Route ──
|
|
1775
|
+
|
|
1776
|
+
switch (command) {
|
|
1777
|
+
case 'init': init(); break;
|
|
1778
|
+
case 'start': start(); break;
|
|
1779
|
+
case 'stop': daemon('stop'); break;
|
|
1780
|
+
case 'logs': daemon('logs'); break;
|
|
1781
|
+
case 'status': status(); break;
|
|
1782
|
+
case 'update': update(); break;
|
|
1783
|
+
case 'daemon': daemon(subcommand); break;
|
|
1784
|
+
case 'tunnel': tunnel(subcommand); break;
|
|
1785
|
+
case 'password-reset': passwordReset(); break;
|
|
1786
|
+
default:
|
|
1787
|
+
fs.existsSync(CONFIG_PATH) ? start() : init();
|
|
1788
|
+
}
|