@sirenodeck/sirenodeck 0.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/bin/_wrapper-shared.js +42 -0
- package/bin/dev.js +95 -0
- package/bin/sirenodeck.js +42 -0
- package/config/default-config.yml +117 -0
- package/config/starter-config.yml +54 -0
- package/dist/main.mjs +64702 -0
- package/package.json +140 -0
- package/src/action/executor.ts +156 -0
- package/src/action/index.ts +7 -0
- package/src/addon/api-types.ts +15 -0
- package/src/addon/api.ts +461 -0
- package/src/addon/check-runner.ts +84 -0
- package/src/addon/index.ts +5 -0
- package/src/addon/loader.ts +441 -0
- package/src/addon/registry.ts +230 -0
- package/src/addon/spec.ts +69 -0
- package/src/api/addon.ts +33 -0
- package/src/api/asset-url.ts +24 -0
- package/src/api/index.ts +50 -0
- package/src/api/protocol-internal.ts +656 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/react/index.ts +11 -0
- package/src/api/react/registry.ts +91 -0
- package/src/api/react/use-addon-channel.ts +26 -0
- package/src/api/react/use-button-state.tsx +23 -0
- package/src/api/react/use-deck.ts +24 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/logo72x72.png +0 -0
- package/src/assets/logoFull.png +0 -0
- package/src/builtin-addons/brightness/README.md +51 -0
- package/src/builtin-addons/brightness/buttons/brightness/backend.ts +13 -0
- package/src/builtin-addons/brightness/buttons/brightness/config.ts +10 -0
- package/src/builtin-addons/brightness/buttons/brightness/frontend.tsx +50 -0
- package/src/builtin-addons/brightness/domain/macos.ts +46 -0
- package/src/builtin-addons/brightness/index.d.ts +5 -0
- package/src/builtin-addons/brightness/index.ts +20 -0
- package/src/builtin-addons/brightness/poller.ts +27 -0
- package/src/builtin-addons/brightness/providers/darwin.ts +107 -0
- package/src/builtin-addons/brightness/providers/index.ts +81 -0
- package/src/builtin-addons/brightness/providers/linux.ts +108 -0
- package/src/builtin-addons/brightness/providers/windows.ts +77 -0
- package/src/builtin-addons/brightness/sirenodeck.json +6 -0
- package/src/builtin-addons/coding-agents/assets/claude-code.svg +1 -0
- package/src/builtin-addons/coding-agents/assets/opencode-dark-square.svg +1 -0
- package/src/builtin-addons/coding-agents/buttons/agent/backend.ts +82 -0
- package/src/builtin-addons/coding-agents/buttons/agent/config.ts +13 -0
- package/src/builtin-addons/coding-agents/buttons/agent/frontend.tsx +130 -0
- package/src/builtin-addons/coding-agents/buttons/agent/pages.tsx +150 -0
- package/src/builtin-addons/coding-agents/buttons/summary/backend.ts +48 -0
- package/src/builtin-addons/coding-agents/buttons/summary/config.ts +11 -0
- package/src/builtin-addons/coding-agents/buttons/summary/frontend.tsx +254 -0
- package/src/builtin-addons/coding-agents/decks/agents.ts +69 -0
- package/src/builtin-addons/coding-agents/global/backend.ts +402 -0
- package/src/builtin-addons/coding-agents/global-entry.ts +7 -0
- package/src/builtin-addons/coding-agents/hook/script.ts +123 -0
- package/src/builtin-addons/coding-agents/index.ts +15 -0
- package/src/builtin-addons/coding-agents/manifest.ts +115 -0
- package/src/builtin-addons/coding-agents/providers/claude-code.ts +470 -0
- package/src/builtin-addons/coding-agents/providers/claude-instances.ts +184 -0
- package/src/builtin-addons/coding-agents/providers/opencode-instances.ts +108 -0
- package/src/builtin-addons/coding-agents/providers/opencode.ts +636 -0
- package/src/builtin-addons/coding-agents/providers/registry.ts +120 -0
- package/src/builtin-addons/coding-agents/providers/spawn.ts +112 -0
- package/src/builtin-addons/coding-agents/shared/claude-hook-events.ts +55 -0
- package/src/builtin-addons/coding-agents/shared/claude-status.ts +236 -0
- package/src/builtin-addons/coding-agents/shared/live-count.ts +39 -0
- package/src/builtin-addons/coding-agents/shared/notifier.ts +58 -0
- package/src/builtin-addons/coding-agents/shared/opencode-status.ts +82 -0
- package/src/builtin-addons/coding-agents/shared/snapshot.ts +66 -0
- package/src/builtin-addons/coding-agents/shared/state.ts +72 -0
- package/src/builtin-addons/coding-agents/sirenodeck.json +6 -0
- package/src/builtin-addons/coding-agents/types/types.ts +33 -0
- package/src/builtin-addons/core/README.md +89 -0
- package/src/builtin-addons/core/buttons/action/backend.ts +7 -0
- package/src/builtin-addons/core/buttons/action/config.ts +13 -0
- package/src/builtin-addons/core/buttons/action/frontend.tsx +16 -0
- package/src/builtin-addons/core/buttons/change-deck/backend.ts +18 -0
- package/src/builtin-addons/core/buttons/change-deck/config.ts +15 -0
- package/src/builtin-addons/core/buttons/change-deck/frontend.tsx +18 -0
- package/src/builtin-addons/core/buttons/media-sample/backend.ts +8 -0
- package/src/builtin-addons/core/buttons/media-sample/config.ts +7 -0
- package/src/builtin-addons/core/buttons/media-sample/frontend.tsx +2 -0
- package/src/builtin-addons/core/buttons/page-nav/backend.ts +28 -0
- package/src/builtin-addons/core/buttons/page-nav/config.ts +9 -0
- package/src/builtin-addons/core/buttons/page-nav/frontend.tsx +68 -0
- package/src/builtin-addons/core/buttons/toggle/backend.ts +119 -0
- package/src/builtin-addons/core/buttons/toggle/config.ts +57 -0
- package/src/builtin-addons/core/buttons/toggle/frontend.tsx +57 -0
- package/src/builtin-addons/core/buttons/toggle/global-service.ts +174 -0
- package/src/builtin-addons/core/index.ts +120 -0
- package/src/builtin-addons/core/sirenodeck.json +6 -0
- package/src/builtin-addons/date-time/README.md +73 -0
- package/src/builtin-addons/date-time/buttons/analog-clock/backend.ts +10 -0
- package/src/builtin-addons/date-time/buttons/analog-clock/config.ts +4 -0
- package/src/builtin-addons/date-time/buttons/analog-clock/frontend.tsx +88 -0
- package/src/builtin-addons/date-time/buttons/custom/backend.ts +10 -0
- package/src/builtin-addons/date-time/buttons/custom/config.ts +9 -0
- package/src/builtin-addons/date-time/buttons/custom/frontend.tsx +26 -0
- package/src/builtin-addons/date-time/buttons/date/backend.ts +10 -0
- package/src/builtin-addons/date-time/buttons/date/config.ts +10 -0
- package/src/builtin-addons/date-time/buttons/date/frontend.tsx +42 -0
- package/src/builtin-addons/date-time/buttons/time/backend.ts +10 -0
- package/src/builtin-addons/date-time/buttons/time/config.ts +9 -0
- package/src/builtin-addons/date-time/buttons/time/frontend.tsx +29 -0
- package/src/builtin-addons/date-time/index.d.ts +5 -0
- package/src/builtin-addons/date-time/index.ts +30 -0
- package/src/builtin-addons/date-time/poller.ts +11 -0
- package/src/builtin-addons/date-time/shared/format-date.ts +36 -0
- package/src/builtin-addons/date-time/shared/format.ts +105 -0
- package/src/builtin-addons/date-time/shared/use-now.ts +10 -0
- package/src/builtin-addons/date-time/sirenodeck.json +6 -0
- package/src/builtin-addons/emoji-selector/README.md +45 -0
- package/src/builtin-addons/emoji-selector/assets/launcher.svg +10 -0
- package/src/builtin-addons/emoji-selector/assets/smileys.svg +8 -0
- package/src/builtin-addons/emoji-selector/buttons/category/backend.ts +14 -0
- package/src/builtin-addons/emoji-selector/buttons/category/config.ts +8 -0
- package/src/builtin-addons/emoji-selector/buttons/category/frontend.tsx +19 -0
- package/src/builtin-addons/emoji-selector/buttons/emoji/backend.ts +7 -0
- package/src/builtin-addons/emoji-selector/buttons/emoji/config.ts +9 -0
- package/src/builtin-addons/emoji-selector/buttons/emoji/frontend.tsx +11 -0
- package/src/builtin-addons/emoji-selector/buttons/launcher/backend.ts +13 -0
- package/src/builtin-addons/emoji-selector/buttons/launcher/config.ts +6 -0
- package/src/builtin-addons/emoji-selector/buttons/launcher/frontend.tsx +31 -0
- package/src/builtin-addons/emoji-selector/data/categories.ts +1084 -0
- package/src/builtin-addons/emoji-selector/decks/index.ts +137 -0
- package/src/builtin-addons/emoji-selector/index.d.ts +5 -0
- package/src/builtin-addons/emoji-selector/index.ts +29 -0
- package/src/builtin-addons/emoji-selector/sirenodeck.json +6 -0
- package/src/builtin-addons/emoji-selector/support.ts +49 -0
- package/src/builtin-addons/index.ts +13 -0
- package/src/builtin-addons/internal-settings/README.md +26 -0
- package/src/builtin-addons/internal-settings/backend.ts +58 -0
- package/src/builtin-addons/internal-settings/buttons/app-info/backend.ts +7 -0
- package/src/builtin-addons/internal-settings/buttons/app-info/config.ts +13 -0
- package/src/builtin-addons/internal-settings/buttons/app-info/frontend.tsx +18 -0
- package/src/builtin-addons/internal-settings/buttons/brightness/common/frontend.tsx +50 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-down/backend.ts +16 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-down/config.ts +6 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-down/frontend.tsx +8 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-up/backend.ts +16 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-up/config.ts +6 -0
- package/src/builtin-addons/internal-settings/buttons/brightness-up/frontend.tsx +8 -0
- package/src/builtin-addons/internal-settings/decks/settings.ts +25 -0
- package/src/builtin-addons/internal-settings/index.d.ts +4 -0
- package/src/builtin-addons/internal-settings/index.ts +53 -0
- package/src/builtin-addons/internal-settings/logo72x72.png +0 -0
- package/src/builtin-addons/internal-settings/sirenodeck.json +6 -0
- package/src/builtin-addons/media/README.md +45 -0
- package/src/builtin-addons/media/backend.ts +143 -0
- package/src/builtin-addons/media/buttons/media-player/backend.ts +19 -0
- package/src/builtin-addons/media/buttons/media-player/components/MediaStatus.tsx +25 -0
- package/src/builtin-addons/media/buttons/media-player/components/MediaSurface.tsx +52 -0
- package/src/builtin-addons/media/buttons/media-player/components/ProgressBar.tsx +21 -0
- package/src/builtin-addons/media/buttons/media-player/components/status-meta.ts +36 -0
- package/src/builtin-addons/media/buttons/media-player/config.ts +4 -0
- package/src/builtin-addons/media/buttons/media-player/frontend.tsx +29 -0
- package/src/builtin-addons/media/buttons/volume/common/frontend.tsx +52 -0
- package/src/builtin-addons/media/buttons/volume/mute/backend.ts +13 -0
- package/src/builtin-addons/media/buttons/volume/mute/config.ts +4 -0
- package/src/builtin-addons/media/buttons/volume/mute/frontend.tsx +26 -0
- package/src/builtin-addons/media/buttons/volume/volume-down/backend.ts +14 -0
- package/src/builtin-addons/media/buttons/volume/volume-down/config.ts +6 -0
- package/src/builtin-addons/media/buttons/volume/volume-down/frontend.tsx +10 -0
- package/src/builtin-addons/media/buttons/volume/volume-up/backend.ts +14 -0
- package/src/builtin-addons/media/buttons/volume/volume-up/config.ts +6 -0
- package/src/builtin-addons/media/buttons/volume/volume-up/frontend.tsx +8 -0
- package/src/builtin-addons/media/checks.ts +104 -0
- package/src/builtin-addons/media/executor.ts +36 -0
- package/src/builtin-addons/media/index.d.ts +5 -0
- package/src/builtin-addons/media/index.ts +53 -0
- package/src/builtin-addons/media/progress.ts +16 -0
- package/src/builtin-addons/media/providers/darwin.ts +391 -0
- package/src/builtin-addons/media/providers/index.ts +27 -0
- package/src/builtin-addons/media/providers/linux.ts +196 -0
- package/src/builtin-addons/media/providers/types.ts +48 -0
- package/src/builtin-addons/media/providers/windows.ts +121 -0
- package/src/builtin-addons/media/sirenodeck.json +6 -0
- package/src/builtin-addons/media/state.ts +19 -0
- package/src/builtin-addons/register-builtins.ts +65 -0
- package/src/builtin-addons/session/README.md +14 -0
- package/src/builtin-addons/session/buttons/session-info/backend.ts +8 -0
- package/src/builtin-addons/session/buttons/session-info/config.ts +4 -0
- package/src/builtin-addons/session/buttons/session-info/frontend.tsx +2 -0
- package/src/builtin-addons/session/buttons/time/backend.ts +7 -0
- package/src/builtin-addons/session/buttons/time/config.ts +6 -0
- package/src/builtin-addons/session/buttons/time/frontend.tsx +2 -0
- package/src/builtin-addons/session/index.d.ts +5 -0
- package/src/builtin-addons/session/index.ts +18 -0
- package/src/builtin-addons/session/sirenodeck.json +6 -0
- package/src/builtin-addons/system-status/README.md +169 -0
- package/src/builtin-addons/system-status/buttons/_shared.ts +131 -0
- package/src/builtin-addons/system-status/buttons/system-status/frontend.tsx +224 -0
- package/src/builtin-addons/system-status/buttons/system-status/schemas.ts +67 -0
- package/src/builtin-addons/system-status/domain/catalog.ts +53 -0
- package/src/builtin-addons/system-status/domain/chart-sampler.ts +58 -0
- package/src/builtin-addons/system-status/domain/display-metrics.ts +128 -0
- package/src/builtin-addons/system-status/domain/index.ts +10 -0
- package/src/builtin-addons/system-status/domain/live-metrics.ts +1021 -0
- package/src/builtin-addons/system-status/domain/metric-ids.ts +0 -0
- package/src/builtin-addons/system-status/index.ts +16 -0
- package/src/builtin-addons/system-status/manifest.ts +105 -0
- package/src/builtin-addons/system-status/shared/metrics-catalog.ts +316 -0
- package/src/builtin-addons/system-status/sirenodeck.json +6 -0
- package/src/builtin-addons/test-buildin/decks/action-buttons-test.ts +56 -0
- package/src/builtin-addons/test-buildin/index.d.ts +5 -0
- package/src/builtin-addons/test-buildin/index.ts +16 -0
- package/src/builtin-addons/value-display/README.md +59 -0
- package/src/builtin-addons/value-display/backend.ts +86 -0
- package/src/builtin-addons/value-display/buttons/value-display/backend.ts +17 -0
- package/src/builtin-addons/value-display/buttons/value-display/config.ts +36 -0
- package/src/builtin-addons/value-display/buttons/value-display/frontend.tsx +54 -0
- package/src/builtin-addons/value-display/index.d.ts +5 -0
- package/src/builtin-addons/value-display/index.ts +23 -0
- package/src/builtin-addons/value-display/sirenodeck.json +6 -0
- package/src/builtin-addons/weather/README.md +46 -0
- package/src/builtin-addons/weather/backend.ts +121 -0
- package/src/builtin-addons/weather/buttons/weather/backend.ts +27 -0
- package/src/builtin-addons/weather/buttons/weather/config.ts +29 -0
- package/src/builtin-addons/weather/buttons/weather/frontend.tsx +63 -0
- package/src/builtin-addons/weather/buttons/weather/icons.tsx +88 -0
- package/src/builtin-addons/weather/buttons/weather/pages.tsx +109 -0
- package/src/builtin-addons/weather/domain/codes.ts +35 -0
- package/src/builtin-addons/weather/domain/fetch.ts +47 -0
- package/src/builtin-addons/weather/index.d.ts +5 -0
- package/src/builtin-addons/weather/index.ts +23 -0
- package/src/builtin-addons/weather/poller.ts +70 -0
- package/src/builtin-addons/weather/provider/city-key.ts +9 -0
- package/src/builtin-addons/weather/provider/codes.ts +35 -0
- package/src/builtin-addons/weather/provider/fetch.ts +97 -0
- package/src/builtin-addons/weather/provider/geocode.ts +67 -0
- package/src/builtin-addons/weather/provider/types.ts +42 -0
- package/src/builtin-addons/weather/sirenodeck.json +6 -0
- package/src/cli/coding-agents-onboarding.ts +434 -0
- package/src/cli/commands/addon-decks.ts +441 -0
- package/src/cli/commands/addon-registry.ts +639 -0
- package/src/cli/commands/emulator-mode.ts +289 -0
- package/src/cli/commands/install.ts +128 -0
- package/src/cli/commands/logs.ts +74 -0
- package/src/cli/commands/network-bind.ts +111 -0
- package/src/cli/commands/pipeline/helpers.ts +75 -0
- package/src/cli/commands/pipeline/preflight.ts +20 -0
- package/src/cli/commands/port-identity.ts +152 -0
- package/src/cli/commands/reload.ts +37 -0
- package/src/cli/commands/restart.ts +139 -0
- package/src/cli/commands/run.ts +2270 -0
- package/src/cli/commands/service/install.ts +121 -0
- package/src/cli/commands/service/render-template.ts +158 -0
- package/src/cli/commands/service-manager.ts +184 -0
- package/src/cli/commands/spawn-daemon.ts +251 -0
- package/src/cli/commands/start.ts +1061 -0
- package/src/cli/commands/status.ts +110 -0
- package/src/cli/commands/stop.ts +121 -0
- package/src/cli/commands/subprocess-supervisor.ts +203 -0
- package/src/cli/commands/system-requirements.ts +699 -0
- package/src/cli/cwd.ts +28 -0
- package/src/cli/first-run.ts +149 -0
- package/src/cli/http-server.ts +244 -0
- package/src/cli/index.ts +355 -0
- package/src/cli/install-root.ts +26 -0
- package/src/cli/main.ts +194 -0
- package/src/cli/package-manager.ts +175 -0
- package/src/cli/probe-deps.ts +45 -0
- package/src/cli/prompt.ts +22 -0
- package/src/cli/startup-display.ts +452 -0
- package/src/config/builtin-icons.ts +57 -0
- package/src/config/config-diff.ts +54 -0
- package/src/config/discovery.ts +64 -0
- package/src/config/icon-resolver.ts +90 -0
- package/src/config/include-resolver.ts +202 -0
- package/src/config/index.ts +9 -0
- package/src/config/loader.ts +187 -0
- package/src/config/mutation.ts +514 -0
- package/src/config/reference-expander.ts +84 -0
- package/src/config/schemas.ts +223 -0
- package/src/config/validation.ts +254 -0
- package/src/core/asset-id.ts +21 -0
- package/src/core/gesture-state.ts +344 -0
- package/src/core/icon-asset-registry.ts +127 -0
- package/src/core/icon-source.ts +86 -0
- package/src/core/index.ts +30 -0
- package/src/core/mime.ts +16 -0
- package/src/core/pagination.ts +90 -0
- package/src/core/pub-sub.ts +126 -0
- package/src/core/settings.ts +153 -0
- package/src/core/store.ts +88 -0
- package/src/core/watcher.ts +73 -0
- package/src/deck/addon-handler-bridge.ts +516 -0
- package/src/deck/deck-config.ts +271 -0
- package/src/deck/editor-surfaces.ts +87 -0
- package/src/deck/host-context.ts +18 -0
- package/src/deck/index.ts +102 -0
- package/src/deck/macro-parse.ts +182 -0
- package/src/deck/methods.ts +348 -0
- package/src/deck/paginate-deck.ts +98 -0
- package/src/deck/position-buttons.ts +57 -0
- package/src/deck/runtime/index.ts +5 -0
- package/src/deck/runtime/runtime.ts +1060 -0
- package/src/deck/runtime-subscriptions.ts +45 -0
- package/src/deck/system-back-injection.ts +62 -0
- package/src/deck/system-buttons/registry.tsx +97 -0
- package/src/deck/system-buttons/types.ts +14 -0
- package/src/device/black-frame.ts +73 -0
- package/src/device/index.ts +13 -0
- package/src/device/linux-udev.ts +36 -0
- package/src/device/models.ts +89 -0
- package/src/device/reconnecting.ts +193 -0
- package/src/device/registry.ts +38 -0
- package/src/device/stream-deck.ts +155 -0
- package/src/index.ts +74 -0
- package/src/outputClient/emulator.ts +357 -0
- package/src/outputClient/index.ts +26 -0
- package/src/outputClient/open-browser.ts +26 -0
- package/src/outputClient/real.ts +393 -0
- package/src/outputClient/types.ts +83 -0
- package/src/render/browser-renderer.ts +240 -0
- package/src/render/buffer-hash.ts +20 -0
- package/src/render/editor-handler.ts +197 -0
- package/src/render/emulator-server.ts +128 -0
- package/src/render/icon-source-resolver.ts +69 -0
- package/src/render/index.ts +16 -0
- package/src/render/protocol.ts +61 -0
- package/src/render/push-raw-image.ts +100 -0
- package/src/render/screenshot-cadence.ts +87 -0
- package/src/render/state-publisher.ts +110 -0
- package/src/render/vite-server.ts +138 -0
- package/src/render/ws-bridge.ts +315 -0
- package/src/system/device-selection.ts +80 -0
- package/src/system/glob-match.ts +74 -0
- package/src/system/providers/active-app/darwin.ts +117 -0
- package/src/system/providers/active-app/linux.ts +245 -0
- package/src/system/providers/active-app/wayland-gnome.ts +303 -0
- package/src/system/providers/active-app/windows.ts +94 -0
- package/src/system/providers/active-app.ts +97 -0
- package/src/system/providers/clipboard/darwin.ts +65 -0
- package/src/system/providers/clipboard/linux.ts +163 -0
- package/src/system/providers/clipboard/windows.ts +94 -0
- package/src/system/providers/clipboard.ts +84 -0
- package/src/system/providers/error.ts +16 -0
- package/src/system/providers/key-macro/darwin.ts +221 -0
- package/src/system/providers/key-macro/linux.ts +651 -0
- package/src/system/providers/key-macro/parser.ts +215 -0
- package/src/system/providers/key-macro/windows.ts +476 -0
- package/src/system/providers/key-macro.ts +79 -0
- package/src/system/providers/notification/darwin.ts +36 -0
- package/src/system/providers/notification/linux.ts +115 -0
- package/src/system/providers/notification/windows.ts +72 -0
- package/src/system/providers/notification.ts +75 -0
- package/src/system/providers/session/darwin.ts +82 -0
- package/src/system/providers/session/linux.ts +175 -0
- package/src/system/providers/session/windows.ts +73 -0
- package/src/system/providers/session.ts +89 -0
- package/src/system/providers/shared.ts +65 -0
- package/src/system/requirements.ts +235 -0
- package/src/system/setup-wizard/config-seed.ts +30 -0
- package/src/system/setup-wizard/format.ts +275 -0
- package/src/system/setup-wizard/index.ts +45 -0
- package/src/system/setup-wizard/open-settings.ts +26 -0
- package/src/system/setup-wizard/plan.ts +230 -0
- package/src/system/setup-wizard/probe-cache.ts +34 -0
- package/src/system/setup-wizard/probe.ts +486 -0
- package/src/system/setup-wizard/runtime-features.ts +85 -0
- package/src/system/setup-wizard/sudo.ts +178 -0
- package/src/system/setup-wizard/types.ts +133 -0
- package/src/system/virtual-stream-deck.ts +67 -0
- package/src/themes/css.ts +210 -0
- package/src/themes/default/assets/IBMPlexSans-Italic-VariableFont_wdth,wght.ttf +0 -0
- package/src/themes/default/assets/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Bold.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-BoldItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-ExtraLight.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-ExtraLightItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Italic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Light.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-LightItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Medium.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-MediumItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Regular.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-SemiBold.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-SemiBoldItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-Thin.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/IBMPlexMono-ThinItalic.ttf +0 -0
- package/src/themes/default/assets/IBM_Plex_Mono/OFL.txt +93 -0
- package/src/themes/default/assets/OFL.txt +93 -0
- package/src/themes/default/assets/README.txt +106 -0
- package/src/themes/default/assets/static/IBMPlexSans-Bold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-BoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-ExtraLight.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-ExtraLightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-Italic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-Light.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-LightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-Medium.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-MediumItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-Regular.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-SemiBold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-SemiBoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-Thin.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans-ThinItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Bold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-BoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-ExtraLight.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-ExtraLightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Italic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Light.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-LightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Medium.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-MediumItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Regular.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-SemiBold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-SemiBoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-Thin.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_Condensed-ThinItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Bold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-BoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-ExtraLight.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-ExtraLightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Italic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Light.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-LightItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Medium.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-MediumItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Regular.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-SemiBold.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-SemiBoldItalic.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-Thin.ttf +0 -0
- package/src/themes/default/assets/static/IBMPlexSans_SemiCondensed-ThinItalic.ttf +0 -0
- package/src/themes/default/components.css +81 -0
- package/src/themes/default/sirenodeck.json +170 -0
- package/src/themes/index.ts +14 -0
- package/src/themes/light/assets/IBMPlexSans-Italic-VariableFont_wdth,wght.ttf +0 -0
- package/src/themes/light/assets/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
- package/src/themes/light/assets/IBM_Plex_Mono/IBMPlexMono-Bold.ttf +0 -0
- package/src/themes/light/assets/IBM_Plex_Mono/IBMPlexMono-Medium.ttf +0 -0
- package/src/themes/light/assets/IBM_Plex_Mono/IBMPlexMono-Regular.ttf +0 -0
- package/src/themes/light/assets/IBM_Plex_Mono/OFL.txt +93 -0
- package/src/themes/light/assets/OFL.txt +93 -0
- package/src/themes/light/assets/README.txt +106 -0
- package/src/themes/light/assets/static/IBMPlexSans-Light.ttf +0 -0
- package/src/themes/light/assets/static/IBMPlexSans-LightItalic.ttf +0 -0
- package/src/themes/light/assets/static/IBMPlexSans-Thin.ttf +0 -0
- package/src/themes/light/components.css +70 -0
- package/src/themes/light/sirenodeck.json +170 -0
- package/src/themes/loader.ts +343 -0
- package/src/themes/manifest.ts +164 -0
- package/src/themes/use-resolved-theme.tsx +32 -0
- package/src/ui/ButtonFrame.tsx +230 -0
- package/src/ui/contexts/AssetCacheContext.tsx +43 -0
- package/src/ui/index.ts +20 -0
- package/src/ui/primitives/Chip.tsx +53 -0
- package/src/ui/primitives/Icon.tsx +209 -0
- package/src/ui/primitives/Label.tsx +82 -0
- package/src/ui/primitives/ProgressBar.tsx +38 -0
- package/src/ui/primitives/TapIndicator.tsx +67 -0
- package/src/ui/primitives/Text.tsx +810 -0
- package/src/ui/primitives/index.ts +6 -0
- package/src/ui/surfaces/BarsSurface.tsx +211 -0
- package/src/ui/surfaces/IconLabelProgressSurface.tsx +133 -0
- package/src/ui/surfaces/IconLabelSurface.tsx +59 -0
- package/src/ui/surfaces/LabelValueListSurface.tsx +202 -0
- package/src/ui/surfaces/PaginatedSurface.tsx +164 -0
- package/src/ui/surfaces/SplitActionSurface.tsx +98 -0
- package/src/ui/surfaces/TemporaryErrorSurface.tsx +68 -0
- package/src/ui/surfaces/ValueChart.tsx +218 -0
- package/src/ui/surfaces/index.ts +32 -0
- package/src/ui/surfaces/paginated-schema.ts +22 -0
- package/src/ui/theme-presentation-builder.ts +184 -0
- package/src/ui/theme-presentation.tsx +146 -0
- package/src/ui/utils/cn.ts +12 -0
- package/src/util/cache-paths.ts +38 -0
- package/src/util/config-diff.ts +16 -0
- package/src/util/daemon-control.ts +85 -0
- package/src/util/daemon.ts +575 -0
- package/src/util/device-config.ts +56 -0
- package/src/util/errors.ts +13 -0
- package/src/util/log-reader.ts +114 -0
- package/src/util/log-tail.ts +103 -0
- package/src/util/logger.ts +417 -0
- package/src/util/process-title.ts +79 -0
- package/src/util/single-instance.ts +202 -0
- package/src/version.ts +10 -0
- package/src/vite/index.ts +6 -0
- package/src/vite/virtual-modules.ts +631 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs"
|
|
2
|
+
import { execFileSync } from "node:child_process"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ponytail: every identity check in this module used to read /proc, which does
|
|
6
|
+
* not exist on macOS. The result was not a graceful degradation but a silent
|
|
7
|
+
* inversion: `readProcCmdline` returned null, so `isOurViteChild` was false for
|
|
8
|
+
* every process, `isOurDaemon` returned false before it even looked, and
|
|
9
|
+
* `isOrphan` bailed out as "can't tell". A Mac therefore reported the daemon's
|
|
10
|
+
* OWN vite as "a process that is NOT a sirenodeck child — leaving it alone",
|
|
11
|
+
* never reaped a stale daemon holding the WS port, and left the orphans that
|
|
12
|
+
* blocked the next start. `ps` answers the same questions everywhere POSIX
|
|
13
|
+
* does, so ask it when /proc is absent.
|
|
14
|
+
*/
|
|
15
|
+
const psField = (
|
|
16
|
+
pid: number,
|
|
17
|
+
field: "command" | "comm" | "ppid",
|
|
18
|
+
): string | null => {
|
|
19
|
+
try {
|
|
20
|
+
const out = execFileSync("ps", ["-p", String(pid), "-o", `${field}=`], {
|
|
21
|
+
encoding: "utf8",
|
|
22
|
+
timeout: 2_000,
|
|
23
|
+
maxBuffer: 1024 * 1024,
|
|
24
|
+
}).trim()
|
|
25
|
+
return out.length > 0 ? out : null
|
|
26
|
+
} catch {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const readProcCmdline = (pid: number): string | null => {
|
|
32
|
+
try {
|
|
33
|
+
const buf = readFileSync(`/proc/${String(pid)}/cmdline`, "utf8")
|
|
34
|
+
// cmdline is NUL-separated; replace with spaces for matching.
|
|
35
|
+
return buf.replace(/\u0000+/g, " ").trim()
|
|
36
|
+
} catch {
|
|
37
|
+
// No /proc (macOS, BSD): `ps -o command=` is the portable equivalent.
|
|
38
|
+
return psField(pid, "command")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const readProcComm = (pid: number): string | null => {
|
|
43
|
+
try {
|
|
44
|
+
// ponytail: /proc/<pid>/comm is NUL-terminated. `String.trim()` only
|
|
45
|
+
// strips whitespace (per ECMA-262), and U+0000 isn't classified as
|
|
46
|
+
// whitespace — so a raw `.trim()` leaves the NUL in place. Strip NULs
|
|
47
|
+
// explicitly so comm === "sirenodeck:dm" matches.
|
|
48
|
+
return readFileSync(`/proc/${String(pid)}/comm`, "utf8")
|
|
49
|
+
.replace(/\u0000+$/, "")
|
|
50
|
+
.trim()
|
|
51
|
+
} catch {
|
|
52
|
+
// macOS truncates `comm` to the executable name but reflects
|
|
53
|
+
// `process.title`, which is exactly the daemon marker we set.
|
|
54
|
+
return psField(pid, "comm")
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ponytail: identify a previous-session daemon by Linux process title. The
|
|
59
|
+
// daemon calls `setProcessTitle("sirenodeck:dm")` in main.ts:23, which sets
|
|
60
|
+
// `/proc/<pid>/comm`. Reading `comm` is cheaper than `cmdline` and works
|
|
61
|
+
// even when the original argv is replaced.
|
|
62
|
+
//
|
|
63
|
+
// Two checks — title match plus a cmdline fingerprint — so a non-daemon
|
|
64
|
+
// binary that happens to be named "sirenodeck:dm" by its supervisor still
|
|
65
|
+
// gets left alone. The cmdline fingerprint is intentionally loose (any
|
|
66
|
+
// "sireno[-_]?deck" segment) because the daemon's argv can move across
|
|
67
|
+
// versions, worktrees, and binaries (node, tsx, bin/sirenodeck.js).
|
|
68
|
+
export const isOurDaemon = (pid: number): boolean => {
|
|
69
|
+
const comm = readProcComm(pid)
|
|
70
|
+
if (comm === null) return false
|
|
71
|
+
// The daemon titles itself `sirenodeck:dm`; the foreground CLI that hosts an
|
|
72
|
+
// in-process daemon titles itself `sirenodeck:cli`. Both own the ports, so
|
|
73
|
+
// both must be recognisable — a Mac only ever sees the latter, which is why
|
|
74
|
+
// matching the daemon title alone left live daemons unrecognised there.
|
|
75
|
+
if (comm !== "sirenodeck:dm" && comm !== "sirenodeck:cli") return false
|
|
76
|
+
const cmdline = readProcCmdline(pid) ?? comm
|
|
77
|
+
return /sireno[-_]?deck/i.test(cmdline)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const readProcPpid = (pid: number): number | null => {
|
|
81
|
+
try {
|
|
82
|
+
const stat = readFileSync(`/proc/${String(pid)}/stat`, "utf8")
|
|
83
|
+
const closeParen = stat.lastIndexOf(")")
|
|
84
|
+
const tail = stat.slice(closeParen + 2)
|
|
85
|
+
const ppid = Number.parseInt(tail.split(" ")[1] ?? "", 10)
|
|
86
|
+
return Number.isFinite(ppid) && ppid > 0 ? ppid : null
|
|
87
|
+
} catch {
|
|
88
|
+
const raw = psField(pid, "ppid")
|
|
89
|
+
const ppid = raw === null ? Number.NaN : Number.parseInt(raw, 10)
|
|
90
|
+
return Number.isFinite(ppid) && ppid > 0 ? ppid : null
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ponytail: identity gate. Before sending SIGTERM to ANY process holding
|
|
95
|
+
// one of the daemon's ports, verify it's actually one of ours. Otherwise
|
|
96
|
+
// we could kill a Discord, a browser, an IDE, or a `vite dev` the user
|
|
97
|
+
// deliberately started for a different project. Two checks:
|
|
98
|
+
//
|
|
99
|
+
// 1. cmdline (`/proc/<pid>/cmdline`) must reference a sirenodeck vite
|
|
100
|
+
// config — the frontend (packages/cli/frontend/vite.config.ts) or the
|
|
101
|
+
// config UI (packages/cli/config-ui/vite.config.ts). The host string
|
|
102
|
+
// can be vendored, fork-installed, or extracted into a shared repo
|
|
103
|
+
// clone, so we match against the basename + the relative path
|
|
104
|
+
// tail; we also accept path segments that include the
|
|
105
|
+
// `/packages/cli/{frontend,emulator}/vite.config.ts` suffix under
|
|
106
|
+
// any of those roots.
|
|
107
|
+
//
|
|
108
|
+
// 2. parent process: cmdline alone is not enough — `pnpm dev` on any
|
|
109
|
+
// project that happens to share a vite config filename could match.
|
|
110
|
+
// Cross-check that the proc's ppid is either 1 (reparented to init
|
|
111
|
+
// because the daemon was killed) or — when the daemon pid file
|
|
112
|
+
// still has a value — ppid === that daemon pid. If the proc has a
|
|
113
|
+
// live, non-daemon parent, leave it alone.
|
|
114
|
+
//
|
|
115
|
+
// If either check fails, skip the pid with a debug log. The user gets a
|
|
116
|
+
// clear `port still in use` error from the new daemon's preflight and
|
|
117
|
+
// can decide what to do.
|
|
118
|
+
export const isOurViteChild = (pid: number): boolean => {
|
|
119
|
+
const cmdline = readProcCmdline(pid)
|
|
120
|
+
if (cmdline === null) return false
|
|
121
|
+
// Accept any path that ends with frontend/vite.config.ts or
|
|
122
|
+
// config-ui/vite.config.ts AND contains `vite` (the executable). The
|
|
123
|
+
// (?:^|\s) anchor catches the bin path's `/tsx/dist/cli.mjs` which
|
|
124
|
+
// may pass the config as a separate arg.
|
|
125
|
+
return /vite(?:[^\s]*)?\s+(?:[^\s]*\s+)?[^\s]*\/(frontend|emulator)\/vite\.config\.ts/.test(
|
|
126
|
+
cmdline,
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const cmdlineMentionsCliRoot = (cmdline: string): boolean => {
|
|
131
|
+
// Be a bit safer than just "vite.config.ts": the path must trace back
|
|
132
|
+
// to a sirenodeck checkout. We recognize the canonical
|
|
133
|
+
// /packages/cli/{frontend,emulator}/vite.config.ts layout.
|
|
134
|
+
return /\/packages\/cli\/(frontend|emulator)\/vite\.config\.ts\b/.test(
|
|
135
|
+
cmdline,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ponytail: orphan check is intentionally loose. On a Linux user session
|
|
140
|
+
// the orphans get reparented to systemd (NOT to init / ppid 1), so the
|
|
141
|
+
// old "ppid === 1" detection misses them. The cmdline check above is
|
|
142
|
+
// the load-bearing identity gate; this orphan check is a tie-breaker
|
|
143
|
+
// that only refuses to kill a proc whose parent is one of OUR running
|
|
144
|
+
// daemons — i.e. there's a live daemon tree and the proc is a healthy
|
|
145
|
+
// child of it. An orphan with ppid NOT in the live daemons list is
|
|
146
|
+
// classified as orphan and killed.
|
|
147
|
+
export const isOrphan = (pid: number, daemonPid: number | null): boolean => {
|
|
148
|
+
const ppid = readProcPpid(pid)
|
|
149
|
+
if (ppid === null) return false // can't tell — be safe
|
|
150
|
+
if (daemonPid !== null && ppid === daemonPid) return false // live child
|
|
151
|
+
return true // ppid is 1, systemd, kthread, or anything-but-our-daemon
|
|
152
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type pino from "pino"
|
|
2
|
+
|
|
3
|
+
import { readPid, isRunning, resolveDaemonPaths } from "@/util/daemon"
|
|
4
|
+
import { tailLogs } from "@/util/log-tail"
|
|
5
|
+
|
|
6
|
+
export interface ReloadOptions {
|
|
7
|
+
readonly logger: pino.Logger
|
|
8
|
+
readonly logs?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const reload = async (options: ReloadOptions): Promise<void> => {
|
|
12
|
+
const { logger } = options
|
|
13
|
+
const pid = readPid()
|
|
14
|
+
if (pid === null) {
|
|
15
|
+
logger.error("reload: no daemon running")
|
|
16
|
+
process.exitCode = 1
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
if (!isRunning(pid)) {
|
|
20
|
+
logger.error({ pid }, "reload: daemon not running")
|
|
21
|
+
process.exitCode = 1
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
process.kill(pid, "SIGUSR1")
|
|
26
|
+
logger.info({ pid }, "reload: sent SIGUSR1 to daemon")
|
|
27
|
+
} catch (err) {
|
|
28
|
+
logger.error({ err, pid }, "reload: failed to send signal")
|
|
29
|
+
process.exitCode = 1
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (options.logs === true && process.exitCode !== 1) {
|
|
34
|
+
const logPath = `${resolveDaemonPaths().runtimeDir}/service.log`
|
|
35
|
+
await tailLogs({ logPath, follow: true, lines: 50 })
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type pino from "pino"
|
|
2
|
+
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
isRunning,
|
|
7
|
+
readFlags,
|
|
8
|
+
readPid,
|
|
9
|
+
resolveDaemonPaths,
|
|
10
|
+
} from "@/util/daemon"
|
|
11
|
+
import {
|
|
12
|
+
readDaemonEventsFromSnapshot,
|
|
13
|
+
snapshotDaemonLog,
|
|
14
|
+
} from "@/util/log-reader"
|
|
15
|
+
|
|
16
|
+
import { ensureInstalled, invokeManager } from "./service-manager"
|
|
17
|
+
import start, { type StartOptions } from "./start"
|
|
18
|
+
import stop from "./stop"
|
|
19
|
+
import {
|
|
20
|
+
printDaemonEvents,
|
|
21
|
+
printRestartComplete,
|
|
22
|
+
printRestartFailed,
|
|
23
|
+
waitForFullStart,
|
|
24
|
+
waitForPortFree,
|
|
25
|
+
type StartOutcome,
|
|
26
|
+
} from "../startup-display"
|
|
27
|
+
|
|
28
|
+
export interface RestartOptions {
|
|
29
|
+
readonly logger: pino.Logger
|
|
30
|
+
readonly system?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ponytail: dev mode forks the daemon via spawnDetached from the wrapper,
|
|
34
|
+
// not via systemctl/launchctl. invokeManager in dev would shell out to
|
|
35
|
+
// the OS service manager and either fail or no-op against a daemon it
|
|
36
|
+
// never started. Read the cached flags.json (written by startInBackground)
|
|
37
|
+
// and run the in-process stop + start pair instead.
|
|
38
|
+
const flagsToStartOptions = (
|
|
39
|
+
flags: ReturnType<typeof readFlags>,
|
|
40
|
+
logger: pino.Logger,
|
|
41
|
+
): StartOptions | null => {
|
|
42
|
+
if (flags === null) return null
|
|
43
|
+
return {
|
|
44
|
+
logger,
|
|
45
|
+
emulator: flags.emulator,
|
|
46
|
+
...(flags.remote === true ? { remote: true } : {}),
|
|
47
|
+
...(flags.deviceModel !== undefined
|
|
48
|
+
? { deviceModel: flags.deviceModel }
|
|
49
|
+
: {}),
|
|
50
|
+
...(flags.port !== undefined ? { port: flags.port } : {}),
|
|
51
|
+
httpPort: flags.httpPort,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const logPathFor = (): string =>
|
|
56
|
+
join(resolveDaemonPaths().runtimeDir, "service.log")
|
|
57
|
+
|
|
58
|
+
export const restart = async (options: RestartOptions): Promise<void> => {
|
|
59
|
+
const { logger } = options
|
|
60
|
+
|
|
61
|
+
if (isDevInvocation()) {
|
|
62
|
+
const startOptions = flagsToStartOptions(readFlags(), logger)
|
|
63
|
+
if (startOptions === null) {
|
|
64
|
+
logger.warn(
|
|
65
|
+
"restart: no cached flags.json — pass them on the command line (e.g. `pnpm dev restart --emulator`)",
|
|
66
|
+
)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const snapshot = snapshotDaemonLog()
|
|
70
|
+
const logPath = logPathFor()
|
|
71
|
+
await stop({ logger })
|
|
72
|
+
await start(startOptions)
|
|
73
|
+
const outcome: StartOutcome = await waitForFullStart({
|
|
74
|
+
port: startOptions.port ?? 52937,
|
|
75
|
+
tcpTimeoutMs: 30_000,
|
|
76
|
+
runtimeTimeoutMs: 30_000,
|
|
77
|
+
logPath,
|
|
78
|
+
logSnapshot: snapshot,
|
|
79
|
+
})
|
|
80
|
+
printDaemonEvents(outcome.events)
|
|
81
|
+
if (outcome.runtimeReady && outcome.state !== null) {
|
|
82
|
+
printRestartComplete()
|
|
83
|
+
} else {
|
|
84
|
+
const message = outcome.tcpReady
|
|
85
|
+
? "daemon: TCP bound but runtime state did not appear in 5s"
|
|
86
|
+
: "daemon: port 52937 did not accept connections in 30s"
|
|
87
|
+
logger.warn(message)
|
|
88
|
+
process.exitCode = 1
|
|
89
|
+
printRestartFailed(message)
|
|
90
|
+
}
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await ensureInstalled({
|
|
95
|
+
logger,
|
|
96
|
+
...(options.system === true ? { system: true } : {}),
|
|
97
|
+
})
|
|
98
|
+
const snapshot = snapshotDaemonLog()
|
|
99
|
+
const logPath = logPathFor()
|
|
100
|
+
await invokeManager({ action: "restart", logger })
|
|
101
|
+
// ponytail: in production, systemctl restart doesn't return a pid,
|
|
102
|
+
// so we wait for the new daemon's WS port to accept connections,
|
|
103
|
+
// then poll the pid file for the new pid (written by the daemon's
|
|
104
|
+
// runInProcessSetup), then read its runtime state.
|
|
105
|
+
const port = 52937
|
|
106
|
+
await waitForPortFree(port, 3_000)
|
|
107
|
+
const pid = readPid()
|
|
108
|
+
if (pid === null || !isRunning(pid)) {
|
|
109
|
+
const message =
|
|
110
|
+
"daemon: systemctl restart succeeded but no daemon is running"
|
|
111
|
+
logger.warn(message)
|
|
112
|
+
process.exitCode = 1
|
|
113
|
+
printRestartFailed(message)
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
logger.info({ pid }, "restart: daemon restarted (waiting for readiness)")
|
|
117
|
+
const outcome = await waitForFullStart({
|
|
118
|
+
port,
|
|
119
|
+
tcpTimeoutMs: 30_000,
|
|
120
|
+
runtimeTimeoutMs: 30_000,
|
|
121
|
+
logPath,
|
|
122
|
+
logSnapshot: snapshot,
|
|
123
|
+
})
|
|
124
|
+
printDaemonEvents(outcome.events)
|
|
125
|
+
if (outcome.runtimeReady && outcome.state !== null) {
|
|
126
|
+
printRestartComplete()
|
|
127
|
+
} else {
|
|
128
|
+
const message = outcome.tcpReady
|
|
129
|
+
? "daemon: TCP bound but runtime state did not appear in 5s"
|
|
130
|
+
: "daemon: port 52937 did not accept connections in 30s"
|
|
131
|
+
logger.warn(message)
|
|
132
|
+
process.exitCode = 1
|
|
133
|
+
printRestartFailed(message)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const isDevInvocation = (): boolean => (process.argv[1] ?? "").endsWith(".ts")
|
|
138
|
+
|
|
139
|
+
export default restart
|