@nextclaw/service 0.1.14 → 0.1.16
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/dist/cli/commands/agent/agent-runtime.utils.d.ts +2 -1
- package/dist/cli/commands/agent/agent-runtime.utils.d.ts.map +1 -0
- package/dist/cli/commands/agent/agent-runtime.utils.js +3 -1
- package/dist/cli/commands/agent/agent-runtime.utils.js.map +1 -0
- package/dist/cli/commands/agent/cli-agent-runner.utils.d.ts +2 -1
- package/dist/cli/commands/agent/cli-agent-runner.utils.d.ts.map +1 -0
- package/dist/cli/commands/agent/cli-agent-runner.utils.js +3 -5
- package/dist/cli/commands/agent/cli-agent-runner.utils.js.map +1 -0
- package/dist/cli/commands/agent/services/agent-commands.service.d.ts +2 -1
- package/dist/cli/commands/agent/services/agent-commands.service.d.ts.map +1 -0
- package/dist/cli/commands/agent/services/agent-commands.service.js +2 -0
- package/dist/cli/commands/agent/services/agent-commands.service.js.map +1 -0
- package/dist/cli/commands/config/services/config-commands.service.d.ts +2 -1
- package/dist/cli/commands/config/services/config-commands.service.d.ts.map +1 -0
- package/dist/cli/commands/config/services/config-commands.service.js +2 -0
- package/dist/cli/commands/config/services/config-commands.service.js.map +1 -0
- package/dist/cli/commands/cron/services/cron-commands.service.d.ts +2 -1
- package/dist/cli/commands/cron/services/cron-commands.service.d.ts.map +1 -0
- package/dist/cli/commands/cron/services/cron-commands.service.js +2 -0
- package/dist/cli/commands/cron/services/cron-commands.service.js.map +1 -0
- package/dist/cli/commands/cron/services/cron-local.service.d.ts +2 -1
- package/dist/cli/commands/cron/services/cron-local.service.d.ts.map +1 -0
- package/dist/cli/commands/cron/services/cron-local.service.js +2 -0
- package/dist/cli/commands/cron/services/cron-local.service.js.map +1 -0
- package/dist/cli/commands/cron/utils/cron-job.utils.d.ts +2 -1
- package/dist/cli/commands/cron/utils/cron-job.utils.d.ts.map +1 -0
- package/dist/cli/commands/cron/utils/cron-job.utils.js +2 -0
- package/dist/cli/commands/cron/utils/cron-job.utils.js.map +1 -0
- package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.d.ts +4 -1
- package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.d.ts.map +1 -0
- package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.js +40 -14
- package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.js.map +1 -0
- package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.d.ts +2 -1
- package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.d.ts.map +1 -0
- package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.js +8 -0
- package/dist/cli/commands/diagnostics/utils/diagnostics-render.utils.js.map +1 -0
- package/dist/cli/commands/gateway/index.d.ts +2 -1
- package/dist/cli/commands/gateway/index.d.ts.map +1 -0
- package/dist/cli/commands/gateway/index.js +2 -0
- package/dist/cli/commands/gateway/index.js.map +1 -0
- package/dist/cli/commands/logs/index.d.ts +2 -1
- package/dist/cli/commands/logs/index.d.ts.map +1 -0
- package/dist/cli/commands/logs/index.js +2 -0
- package/dist/cli/commands/logs/index.js.map +1 -0
- package/dist/cli/commands/mcp/index.d.ts +2 -1
- package/dist/cli/commands/mcp/index.d.ts.map +1 -0
- package/dist/cli/commands/mcp/index.js +2 -0
- package/dist/cli/commands/mcp/index.js.map +1 -0
- package/dist/cli/commands/restart/index.d.ts +2 -1
- package/dist/cli/commands/restart/index.d.ts.map +1 -0
- package/dist/cli/commands/restart/index.js +2 -0
- package/dist/cli/commands/restart/index.js.map +1 -0
- package/dist/cli/commands/secrets/index.d.ts +2 -1
- package/dist/cli/commands/secrets/index.d.ts.map +1 -0
- package/dist/cli/commands/secrets/index.js +2 -0
- package/dist/cli/commands/secrets/index.js.map +1 -0
- package/dist/cli/commands/serve/index.d.ts +2 -1
- package/dist/cli/commands/serve/index.d.ts.map +1 -0
- package/dist/cli/commands/serve/index.js +2 -0
- package/dist/cli/commands/serve/index.js.map +1 -0
- package/dist/cli/commands/skills/index.d.ts +2 -1
- package/dist/cli/commands/skills/index.d.ts.map +1 -0
- package/dist/cli/commands/skills/index.js +2 -0
- package/dist/cli/commands/skills/index.js.map +1 -0
- package/dist/cli/commands/skills/marketplace-client.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace-client.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace-client.js +2 -0
- package/dist/cli/commands/skills/marketplace-client.js.map +1 -0
- package/dist/cli/commands/skills/marketplace-command-options.utils.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace-command-options.utils.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace-command-options.utils.js +2 -0
- package/dist/cli/commands/skills/marketplace-command-options.utils.js.map +1 -0
- package/dist/cli/commands/skills/marketplace-identity.utils.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace-identity.utils.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace-identity.utils.js +2 -0
- package/dist/cli/commands/skills/marketplace-identity.utils.js.map +1 -0
- package/dist/cli/commands/skills/marketplace-network-retry.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace-network-retry.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace-network-retry.js +2 -0
- package/dist/cli/commands/skills/marketplace-network-retry.js.map +1 -0
- package/dist/cli/commands/skills/marketplace.metadata.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace.metadata.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace.metadata.js +2 -0
- package/dist/cli/commands/skills/marketplace.metadata.js.map +1 -0
- package/dist/cli/commands/skills/marketplace.utils.d.ts +2 -1
- package/dist/cli/commands/skills/marketplace.utils.d.ts.map +1 -0
- package/dist/cli/commands/skills/marketplace.utils.js +2 -0
- package/dist/cli/commands/skills/marketplace.utils.js.map +1 -0
- package/dist/cli/commands/skills/skills-query.service.d.ts +2 -1
- package/dist/cli/commands/skills/skills-query.service.d.ts.map +1 -0
- package/dist/cli/commands/skills/skills-query.service.js +2 -0
- package/dist/cli/commands/skills/skills-query.service.js.map +1 -0
- package/dist/cli/commands/start/index.d.ts +2 -1
- package/dist/cli/commands/start/index.d.ts.map +1 -0
- package/dist/cli/commands/start/index.js +2 -0
- package/dist/cli/commands/start/index.js.map +1 -0
- package/dist/cli/commands/stop/index.d.ts +2 -1
- package/dist/cli/commands/stop/index.d.ts.map +1 -0
- package/dist/cli/commands/stop/index.js +2 -0
- package/dist/cli/commands/stop/index.js.map +1 -0
- package/dist/cli/commands/ui/index.d.ts +2 -1
- package/dist/cli/commands/ui/index.d.ts.map +1 -0
- package/dist/cli/commands/ui/index.js +2 -0
- package/dist/cli/commands/ui/index.js.map +1 -0
- package/dist/cli/commands/usage/services/llm-usage-command.service.d.ts +2 -1
- package/dist/cli/commands/usage/services/llm-usage-command.service.d.ts.map +1 -0
- package/dist/cli/commands/usage/services/llm-usage-command.service.js +2 -0
- package/dist/cli/commands/usage/services/llm-usage-command.service.js.map +1 -0
- package/dist/commands/channel/channel-config-view.d.ts +2 -1
- package/dist/commands/channel/channel-config-view.d.ts.map +1 -0
- package/dist/commands/channel/channel-config-view.js +2 -0
- package/dist/commands/channel/channel-config-view.js.map +1 -0
- package/dist/commands/channel/channel-list-view.service.d.ts +2 -1
- package/dist/commands/channel/channel-list-view.service.d.ts.map +1 -0
- package/dist/commands/channel/channel-list-view.service.js +2 -0
- package/dist/commands/channel/channel-list-view.service.js.map +1 -0
- package/dist/commands/channel/index.d.ts +2 -1
- package/dist/commands/channel/index.d.ts.map +1 -0
- package/dist/commands/channel/index.js +2 -0
- package/dist/commands/channel/index.js.map +1 -0
- package/dist/commands/platform-auth/services/account-status.service.d.ts +2 -1
- package/dist/commands/platform-auth/services/account-status.service.d.ts.map +1 -0
- package/dist/commands/platform-auth/services/account-status.service.js +2 -0
- package/dist/commands/platform-auth/services/account-status.service.js.map +1 -0
- package/dist/commands/platform-auth/services/platform-auth-commands.service.d.ts +2 -1
- package/dist/commands/platform-auth/services/platform-auth-commands.service.d.ts.map +1 -0
- package/dist/commands/platform-auth/services/platform-auth-commands.service.js +2 -0
- package/dist/commands/platform-auth/services/platform-auth-commands.service.js.map +1 -0
- package/dist/commands/platform-auth/utils/payload.utils.d.ts +2 -1
- package/dist/commands/platform-auth/utils/payload.utils.d.ts.map +1 -0
- package/dist/commands/platform-auth/utils/payload.utils.js +2 -0
- package/dist/commands/platform-auth/utils/payload.utils.js.map +1 -0
- package/dist/commands/plugin/index.d.ts +2 -1
- package/dist/commands/plugin/index.d.ts.map +1 -0
- package/dist/commands/plugin/index.js +2 -0
- package/dist/commands/plugin/index.js.map +1 -0
- package/dist/commands/plugin/plugin-command.utils.d.ts +2 -1
- package/dist/commands/plugin/plugin-command.utils.d.ts.map +1 -0
- package/dist/commands/plugin/plugin-command.utils.js +2 -0
- package/dist/commands/plugin/plugin-command.utils.js.map +1 -0
- package/dist/commands/plugin/plugin-mutation-actions.utils.d.ts +2 -1
- package/dist/commands/plugin/plugin-mutation-actions.utils.d.ts.map +1 -0
- package/dist/commands/plugin/plugin-mutation-actions.utils.js +2 -0
- package/dist/commands/plugin/plugin-mutation-actions.utils.js.map +1 -0
- package/dist/commands/remote/index.d.ts +2 -1
- package/dist/commands/remote/index.d.ts.map +1 -0
- package/dist/commands/remote/index.js +2 -0
- package/dist/commands/remote/index.js.map +1 -0
- package/dist/commands/remote/services/remote-access-host.service.d.ts +2 -1
- package/dist/commands/remote/services/remote-access-host.service.d.ts.map +1 -0
- package/dist/commands/remote/services/remote-access-host.service.js +2 -0
- package/dist/commands/remote/services/remote-access-host.service.js.map +1 -0
- package/dist/commands/remote/services/remote-service-control.service.d.ts +2 -1
- package/dist/commands/remote/services/remote-service-control.service.d.ts.map +1 -0
- package/dist/commands/remote/services/remote-service-control.service.js +134 -75
- package/dist/commands/remote/services/remote-service-control.service.js.map +1 -0
- package/dist/commands/remote/utils/platform-api-base.utils.d.ts +2 -1
- package/dist/commands/remote/utils/platform-api-base.utils.d.ts.map +1 -0
- package/dist/commands/remote/utils/platform-api-base.utils.js +2 -0
- package/dist/commands/remote/utils/platform-api-base.utils.js.map +1 -0
- package/dist/commands/remote/utils/remote-runtime-support.utils.d.ts +2 -1
- package/dist/commands/remote/utils/remote-runtime-support.utils.d.ts.map +1 -0
- package/dist/commands/remote/utils/remote-runtime-support.utils.js +2 -0
- package/dist/commands/remote/utils/remote-runtime-support.utils.js.map +1 -0
- package/dist/commands/service/index.d.ts +2 -1
- package/dist/commands/service/index.d.ts.map +1 -0
- package/dist/commands/service/index.js +2 -0
- package/dist/commands/service/index.js.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart-command.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/host-autostart-command.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart-command.service.js +2 -0
- package/dist/commands/service/services/autostart/host-autostart-command.service.js.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart-runtime.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/host-autostart-runtime.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart-runtime.service.js +2 -0
- package/dist/commands/service/services/autostart/host-autostart-runtime.service.js.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/host-autostart.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/host-autostart.service.js +2 -0
- package/dist/commands/service/services/autostart/host-autostart.service.js.map +1 -0
- package/dist/commands/service/services/autostart/linux-systemd-autostart.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/linux-systemd-autostart.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/linux-systemd-autostart.service.js +2 -0
- package/dist/commands/service/services/autostart/linux-systemd-autostart.service.js.map +1 -0
- package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.js +2 -0
- package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.js.map +1 -0
- package/dist/commands/service/services/autostart/windows-task-autostart.service.d.ts +2 -1
- package/dist/commands/service/services/autostart/windows-task-autostart.service.d.ts.map +1 -0
- package/dist/commands/service/services/autostart/windows-task-autostart.service.js +2 -0
- package/dist/commands/service/services/autostart/windows-task-autostart.service.js.map +1 -0
- package/dist/commands/service/types/autostart/host-autostart.types.d.ts +2 -1
- package/dist/commands/service/types/autostart/host-autostart.types.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-bundle-layout.store.d.ts +2 -1
- package/dist/launcher/npm-runtime-bundle-layout.store.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-bundle-layout.store.js +2 -0
- package/dist/launcher/npm-runtime-bundle-layout.store.js.map +1 -0
- package/dist/launcher/npm-runtime-bundle-manifest.service.d.ts +2 -1
- package/dist/launcher/npm-runtime-bundle-manifest.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-bundle-manifest.service.js +2 -0
- package/dist/launcher/npm-runtime-bundle-manifest.service.js.map +1 -0
- package/dist/launcher/npm-runtime-bundle.service.d.ts +2 -1
- package/dist/launcher/npm-runtime-bundle.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-bundle.service.js +2 -0
- package/dist/launcher/npm-runtime-bundle.service.js.map +1 -0
- package/dist/launcher/npm-runtime-bundle.types.d.ts +2 -1
- package/dist/launcher/npm-runtime-bundle.types.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-launcher.service.d.ts +2 -1
- package/dist/launcher/npm-runtime-launcher.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-launcher.service.js +2 -0
- package/dist/launcher/npm-runtime-launcher.service.js.map +1 -0
- package/dist/launcher/npm-runtime-update-command.service.d.ts +5 -1
- package/dist/launcher/npm-runtime-update-command.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-update-command.service.js +32 -0
- package/dist/launcher/npm-runtime-update-command.service.js.map +1 -0
- package/dist/launcher/npm-runtime-update-source.service.d.ts +2 -1
- package/dist/launcher/npm-runtime-update-source.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-update-source.service.js +2 -0
- package/dist/launcher/npm-runtime-update-source.service.js.map +1 -0
- package/dist/launcher/npm-runtime-update-state.store.d.ts +2 -1
- package/dist/launcher/npm-runtime-update-state.store.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-update-state.store.js +2 -0
- package/dist/launcher/npm-runtime-update-state.store.js.map +1 -0
- package/dist/launcher/npm-runtime-update.manager.d.ts +2 -1
- package/dist/launcher/npm-runtime-update.manager.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-update.manager.js +2 -0
- package/dist/launcher/npm-runtime-update.manager.js.map +1 -0
- package/dist/launcher/npm-runtime-update.service.d.ts +2 -1
- package/dist/launcher/npm-runtime-update.service.d.ts.map +1 -0
- package/dist/launcher/npm-runtime-update.service.js +2 -0
- package/dist/launcher/npm-runtime-update.service.js.map +1 -0
- package/dist/service-runtime.service.d.ts +2 -1
- package/dist/service-runtime.service.d.ts.map +1 -0
- package/dist/service-runtime.service.js +6 -1
- package/dist/service-runtime.service.js.map +1 -0
- package/dist/shared/controllers/gateway.controller.d.ts +2 -1
- package/dist/shared/controllers/gateway.controller.d.ts.map +1 -0
- package/dist/shared/controllers/gateway.controller.js +2 -0
- package/dist/shared/controllers/gateway.controller.js.map +1 -0
- package/dist/shared/services/gateway/gateway-restart-wake.service.d.ts +2 -1
- package/dist/shared/services/gateway/gateway-restart-wake.service.d.ts.map +1 -0
- package/dist/shared/services/gateway/gateway-restart-wake.service.js +2 -0
- package/dist/shared/services/gateway/gateway-restart-wake.service.js.map +1 -0
- package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts +2 -1
- package/dist/shared/services/gateway/managers/gateway-plugin.manager.d.ts.map +1 -0
- package/dist/shared/services/gateway/managers/gateway-plugin.manager.js +2 -0
- package/dist/shared/services/gateway/managers/gateway-plugin.manager.js.map +1 -0
- package/dist/shared/services/gateway/managers/gateway-remote.manager.d.ts +2 -1
- package/dist/shared/services/gateway/managers/gateway-remote.manager.d.ts.map +1 -0
- package/dist/shared/services/gateway/managers/gateway-remote.manager.js +2 -0
- package/dist/shared/services/gateway/managers/gateway-remote.manager.js.map +1 -0
- package/dist/shared/services/gateway/nextclaw-app.service.d.ts +2 -1
- package/dist/shared/services/gateway/nextclaw-app.service.d.ts.map +1 -0
- package/dist/shared/services/gateway/nextclaw-app.service.js +2 -0
- package/dist/shared/services/gateway/nextclaw-app.service.js.map +1 -0
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +2 -1
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts.map +1 -0
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +2 -0
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js.map +1 -0
- package/dist/shared/services/gateway/service-bootstrap-status.service.d.ts +2 -1
- package/dist/shared/services/gateway/service-bootstrap-status.service.d.ts.map +1 -0
- package/dist/shared/services/gateway/service-bootstrap-status.service.js +2 -0
- package/dist/shared/services/gateway/service-bootstrap-status.service.js.map +1 -0
- package/dist/shared/services/gateway/service-startup-support.service.d.ts +2 -1
- package/dist/shared/services/gateway/service-startup-support.service.d.ts.map +1 -0
- package/dist/shared/services/gateway/service-startup-support.service.js +2 -0
- package/dist/shared/services/gateway/service-startup-support.service.js.map +1 -0
- package/dist/shared/services/gateway/utils/cron-job-handler.utils.d.ts +2 -1
- package/dist/shared/services/gateway/utils/cron-job-handler.utils.d.ts.map +1 -0
- package/dist/shared/services/gateway/utils/cron-job-handler.utils.js +2 -0
- package/dist/shared/services/gateway/utils/cron-job-handler.utils.js.map +1 -0
- package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.d.ts +2 -1
- package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.d.ts.map +1 -0
- package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js +2 -0
- package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js.map +1 -0
- package/dist/shared/services/marketplace/service-marketplace-installer.service.d.ts +2 -1
- package/dist/shared/services/marketplace/service-marketplace-installer.service.d.ts.map +1 -0
- package/dist/shared/services/marketplace/service-marketplace-installer.service.js +2 -0
- package/dist/shared/services/marketplace/service-marketplace-installer.service.js.map +1 -0
- package/dist/shared/services/marketplace/service-mcp-marketplace-ops.d.ts +2 -1
- package/dist/shared/services/marketplace/service-mcp-marketplace-ops.d.ts.map +1 -0
- package/dist/shared/services/marketplace/service-mcp-marketplace-ops.js +2 -0
- package/dist/shared/services/marketplace/service-mcp-marketplace-ops.js.map +1 -0
- package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.d.ts +2 -1
- package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.d.ts.map +1 -0
- package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js +2 -0
- package/dist/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js.map +1 -0
- package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.d.ts +2 -1
- package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.d.ts.map +1 -0
- package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js +2 -1
- package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js.map +1 -0
- package/dist/shared/services/restart/restart-coordinator.service.d.ts +2 -1
- package/dist/shared/services/restart/restart-coordinator.service.d.ts.map +1 -0
- package/dist/shared/services/restart/restart-coordinator.service.js +2 -0
- package/dist/shared/services/restart/restart-coordinator.service.js.map +1 -0
- package/dist/shared/services/restart/restart-sentinel.service.d.ts +2 -1
- package/dist/shared/services/restart/restart-sentinel.service.d.ts.map +1 -0
- package/dist/shared/services/restart/restart-sentinel.service.js +2 -0
- package/dist/shared/services/restart/restart-sentinel.service.js.map +1 -0
- package/dist/shared/services/restart/runtime-restart-request.service.d.ts +2 -1
- package/dist/shared/services/restart/runtime-restart-request.service.d.ts.map +1 -0
- package/dist/shared/services/restart/runtime-restart-request.service.js +2 -0
- package/dist/shared/services/restart/runtime-restart-request.service.js.map +1 -0
- package/dist/shared/services/runtime/managed-service-supervisor.service.d.ts +85 -0
- package/dist/shared/services/runtime/managed-service-supervisor.service.d.ts.map +1 -0
- package/dist/shared/services/runtime/managed-service-supervisor.service.js +271 -0
- package/dist/shared/services/runtime/managed-service-supervisor.service.js.map +1 -0
- package/dist/shared/services/runtime/nextclaw-distribution.service.d.ts +2 -1
- package/dist/shared/services/runtime/nextclaw-distribution.service.d.ts.map +1 -0
- package/dist/shared/services/runtime/nextclaw-distribution.service.js +2 -0
- package/dist/shared/services/runtime/nextclaw-distribution.service.js.map +1 -0
- package/dist/shared/services/runtime/runtime-command.service.d.ts +3 -1
- package/dist/shared/services/runtime/runtime-command.service.d.ts.map +1 -0
- package/dist/shared/services/runtime/runtime-command.service.js +5 -0
- package/dist/shared/services/runtime/runtime-command.service.js.map +1 -0
- package/dist/shared/services/runtime/runtime-config-init.service.d.ts +2 -1
- package/dist/shared/services/runtime/runtime-config-init.service.d.ts.map +1 -0
- package/dist/shared/services/runtime/runtime-config-init.service.js +2 -0
- package/dist/shared/services/runtime/runtime-config-init.service.js.map +1 -0
- package/dist/shared/services/runtime/service-managed-startup.service.d.ts +4 -32
- package/dist/shared/services/runtime/service-managed-startup.service.d.ts.map +1 -0
- package/dist/shared/services/runtime/service-managed-startup.service.js +10 -92
- package/dist/shared/services/runtime/service-managed-startup.service.js.map +1 -0
- package/dist/shared/services/runtime/utils/managed-service-routing.utils.d.ts +2 -1
- package/dist/shared/services/runtime/utils/managed-service-routing.utils.d.ts.map +1 -0
- package/dist/shared/services/runtime/utils/managed-service-routing.utils.js +2 -0
- package/dist/shared/services/runtime/utils/managed-service-routing.utils.js.map +1 -0
- package/dist/shared/services/runtime/utils/service-remote-runtime.utils.d.ts +5 -2
- package/dist/shared/services/runtime/utils/service-remote-runtime.utils.d.ts.map +1 -0
- package/dist/shared/services/runtime/utils/service-remote-runtime.utils.js +23 -17
- package/dist/shared/services/runtime/utils/service-remote-runtime.utils.js.map +1 -0
- package/dist/shared/services/ui/companion-runtime.service.d.ts +2 -1
- package/dist/shared/services/ui/companion-runtime.service.d.ts.map +1 -0
- package/dist/shared/services/ui/companion-runtime.service.js +2 -0
- package/dist/shared/services/ui/companion-runtime.service.js.map +1 -0
- package/dist/shared/services/ui/local-ui-discovery.service.d.ts +2 -1
- package/dist/shared/services/ui/local-ui-discovery.service.d.ts.map +1 -0
- package/dist/shared/services/ui/local-ui-discovery.service.js +2 -0
- package/dist/shared/services/ui/local-ui-discovery.service.js.map +1 -0
- package/dist/shared/services/ui/npm-runtime-update-host.service.d.ts +2 -1
- package/dist/shared/services/ui/npm-runtime-update-host.service.d.ts.map +1 -0
- package/dist/shared/services/ui/npm-runtime-update-host.service.js +2 -0
- package/dist/shared/services/ui/npm-runtime-update-host.service.js.map +1 -0
- package/dist/shared/services/ui/runtime-control-host.service.d.ts +2 -1
- package/dist/shared/services/ui/runtime-control-host.service.d.ts.map +1 -0
- package/dist/shared/services/ui/runtime-control-host.service.js +2 -0
- package/dist/shared/services/ui/runtime-control-host.service.js.map +1 -0
- package/dist/shared/services/ui/service-remote-access.service.d.ts +2 -1
- package/dist/shared/services/ui/service-remote-access.service.d.ts.map +1 -0
- package/dist/shared/services/ui/service-remote-access.service.js +2 -0
- package/dist/shared/services/ui/service-remote-access.service.js.map +1 -0
- package/dist/shared/services/ui/ui-bridge-api.service.d.ts +2 -1
- package/dist/shared/services/ui/ui-bridge-api.service.d.ts.map +1 -0
- package/dist/shared/services/ui/ui-bridge-api.service.js +2 -0
- package/dist/shared/services/ui/ui-bridge-api.service.js.map +1 -0
- package/dist/shared/services/workspace/workspace-manager.service.d.ts +2 -1
- package/dist/shared/services/workspace/workspace-manager.service.d.ts.map +1 -0
- package/dist/shared/services/workspace/workspace-manager.service.js +2 -0
- package/dist/shared/services/workspace/workspace-manager.service.js.map +1 -0
- package/dist/shared/stores/companion-runtime.store.d.ts +2 -1
- package/dist/shared/stores/companion-runtime.store.d.ts.map +1 -0
- package/dist/shared/stores/companion-runtime.store.js +2 -0
- package/dist/shared/stores/companion-runtime.store.js.map +1 -0
- package/dist/shared/stores/local-ui-runtime.store.d.ts +2 -1
- package/dist/shared/stores/local-ui-runtime.store.d.ts.map +1 -0
- package/dist/shared/stores/local-ui-runtime.store.js +2 -0
- package/dist/shared/stores/local-ui-runtime.store.js.map +1 -0
- package/dist/shared/stores/managed-service-state.store.d.ts +19 -1
- package/dist/shared/stores/managed-service-state.store.d.ts.map +1 -0
- package/dist/shared/stores/managed-service-state.store.js +2 -0
- package/dist/shared/stores/managed-service-state.store.js.map +1 -0
- package/dist/shared/stores/pending-restart.store.d.ts +2 -1
- package/dist/shared/stores/pending-restart.store.d.ts.map +1 -0
- package/dist/shared/stores/pending-restart.store.js +2 -0
- package/dist/shared/stores/pending-restart.store.js.map +1 -0
- package/dist/shared/types/cli.types.d.ts +16 -1
- package/dist/shared/types/cli.types.d.ts.map +1 -0
- package/dist/shared/types/distribution.types.d.ts +2 -1
- package/dist/shared/types/distribution.types.d.ts.map +1 -0
- package/dist/shared/utils/cli.utils.d.ts +2 -1
- package/dist/shared/utils/cli.utils.d.ts.map +1 -0
- package/dist/shared/utils/cli.utils.js +2 -0
- package/dist/shared/utils/cli.utils.js.map +1 -0
- package/dist/shared/utils/config-path.d.ts +2 -1
- package/dist/shared/utils/config-path.d.ts.map +1 -0
- package/dist/shared/utils/config-path.js +2 -0
- package/dist/shared/utils/config-path.js.map +1 -0
- package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.d.ts +2 -1
- package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.d.ts.map +1 -0
- package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.js +2 -0
- package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.js.map +1 -0
- package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.d.ts +2 -1
- package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.d.ts.map +1 -0
- package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.js +2 -0
- package/dist/shared/utils/marketplace/service-marketplace-helpers.utils.js.map +1 -0
- package/dist/shared/utils/package/package-manifest.utils.d.ts +2 -1
- package/dist/shared/utils/package/package-manifest.utils.d.ts.map +1 -0
- package/dist/shared/utils/package/package-manifest.utils.js +2 -0
- package/dist/shared/utils/package/package-manifest.utils.js.map +1 -0
- package/dist/shared/utils/runtime-helpers.d.ts +2 -1
- package/dist/shared/utils/runtime-helpers.d.ts.map +1 -0
- package/dist/shared/utils/runtime-helpers.js +2 -0
- package/dist/shared/utils/runtime-helpers.js.map +1 -0
- package/dist/shared/utils/service-port-probe.utils.d.ts +2 -1
- package/dist/shared/utils/service-port-probe.utils.d.ts.map +1 -0
- package/dist/shared/utils/service-port-probe.utils.js +2 -0
- package/dist/shared/utils/service-port-probe.utils.js.map +1 -0
- package/dist/shared/utils/startup-trace.d.ts +2 -1
- package/dist/shared/utils/startup-trace.d.ts.map +1 -0
- package/dist/shared/utils/startup-trace.js +2 -0
- package/dist/shared/utils/startup-trace.js.map +1 -0
- package/dist/shared/utils/top-level-nextclaw-command-env.utils.d.ts +2 -1
- package/dist/shared/utils/top-level-nextclaw-command-env.utils.d.ts.map +1 -0
- package/dist/shared/utils/top-level-nextclaw-command-env.utils.js +2 -0
- package/dist/shared/utils/top-level-nextclaw-command-env.utils.js.map +1 -0
- package/package.json +20 -20
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { createTopLevelNextclawCommandEnv } from "../../utils/top-level-nextclaw-command-env.utils.js";
|
|
2
|
+
import { resolveCliSubcommandLaunch } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
|
|
3
|
+
import { isProcessRunning, resolveServiceLogPath } from "../../utils/cli.utils.js";
|
|
4
|
+
import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
|
|
5
|
+
import { writeInitialManagedServiceState, writeReadyManagedServiceState } from "./utils/service-remote-runtime.utils.js";
|
|
6
|
+
import * as NextclawCore from "@nextclaw/core";
|
|
7
|
+
import { FileLogSink } from "@nextclaw/core";
|
|
8
|
+
import { mkdirSync } from "node:fs";
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { dirname } from "node:path";
|
|
11
|
+
//#region src/shared/services/runtime/managed-service-supervisor.service.ts
|
|
12
|
+
const DEFAULT_HEARTBEAT_INTERVAL_MS = 2e3;
|
|
13
|
+
const DEFAULT_LEASE_TTL_MS = 1e4;
|
|
14
|
+
const SIGNAL_EXIT_CODES = {
|
|
15
|
+
SIGHUP: 129,
|
|
16
|
+
SIGINT: 130,
|
|
17
|
+
SIGTERM: 143
|
|
18
|
+
};
|
|
19
|
+
var ManagedServiceSupervisor = class {
|
|
20
|
+
stateStore;
|
|
21
|
+
now;
|
|
22
|
+
isProcessRunningFn;
|
|
23
|
+
heartbeatIntervalMs;
|
|
24
|
+
leaseTtlMs;
|
|
25
|
+
serviceStartupLogger = NextclawCore.getAppLogger("service.startup");
|
|
26
|
+
heartbeatTimer = null;
|
|
27
|
+
lifecycleTrackingInstalled = false;
|
|
28
|
+
pendingExit = null;
|
|
29
|
+
constructor(options = {}) {
|
|
30
|
+
this.stateStore = options.stateStore ?? managedServiceStateStore;
|
|
31
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
32
|
+
this.isProcessRunningFn = options.isProcessRunningFn ?? isProcessRunning;
|
|
33
|
+
this.heartbeatIntervalMs = options.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;
|
|
34
|
+
this.leaseTtlMs = options.leaseTtlMs ?? DEFAULT_LEASE_TTL_MS;
|
|
35
|
+
}
|
|
36
|
+
spawnManagedService = (params) => {
|
|
37
|
+
const { appName, apiUrl, appendStartupStage, config, healthUrl, printStartupFailureDiagnostics, resolveStartupTimeoutMs, startupTimeoutMs, uiConfig, uiUrl } = params;
|
|
38
|
+
const logPath = (params.resolveServiceLogPath ?? resolveServiceLogPath)();
|
|
39
|
+
new FileLogSink({ serviceLogPath: logPath }).ensureReady();
|
|
40
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
41
|
+
const readinessTimeoutMs = resolveStartupTimeoutMs(startupTimeoutMs);
|
|
42
|
+
const quickPhaseTimeoutMs = Math.min(8e3, readinessTimeoutMs);
|
|
43
|
+
const extendedPhaseTimeoutMs = Math.max(0, readinessTimeoutMs - quickPhaseTimeoutMs);
|
|
44
|
+
appendStartupStage(logPath, `start requested: ui=${uiConfig.host}:${uiConfig.port}, readinessTimeoutMs=${readinessTimeoutMs}`);
|
|
45
|
+
console.log(`Starting ${appName} background service (readiness timeout ${Math.ceil(readinessTimeoutMs / 1e3)}s)...`);
|
|
46
|
+
const cliLaunch = resolveCliSubcommandLaunch({
|
|
47
|
+
argvEntry: process.argv[1],
|
|
48
|
+
importMetaUrl: import.meta.url,
|
|
49
|
+
cliArgs: [
|
|
50
|
+
"serve",
|
|
51
|
+
"--ui-port",
|
|
52
|
+
String(uiConfig.port)
|
|
53
|
+
],
|
|
54
|
+
nodePath: process.execPath
|
|
55
|
+
});
|
|
56
|
+
const childArgs = [...process.execArgv, ...cliLaunch.args];
|
|
57
|
+
appendStartupStage(logPath, `spawning background process: ${cliLaunch.command} ${childArgs.join(" ")}`);
|
|
58
|
+
const child = spawn(cliLaunch.command, childArgs, {
|
|
59
|
+
env: createTopLevelNextclawCommandEnv(process.env),
|
|
60
|
+
stdio: "ignore",
|
|
61
|
+
detached: true,
|
|
62
|
+
windowsHide: true
|
|
63
|
+
});
|
|
64
|
+
appendStartupStage(logPath, `spawned background process pid=${child.pid ?? "unknown"}`);
|
|
65
|
+
if (!child.pid) {
|
|
66
|
+
appendStartupStage(logPath, "spawn failed: child pid missing");
|
|
67
|
+
console.error("Error: Failed to start background service.");
|
|
68
|
+
printStartupFailureDiagnostics({
|
|
69
|
+
uiUrl,
|
|
70
|
+
apiUrl,
|
|
71
|
+
healthUrl,
|
|
72
|
+
logPath,
|
|
73
|
+
lastProbeError: null
|
|
74
|
+
});
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const snapshot = {
|
|
78
|
+
pid: child.pid,
|
|
79
|
+
uiUrl,
|
|
80
|
+
apiUrl,
|
|
81
|
+
uiHost: uiConfig.host,
|
|
82
|
+
uiPort: uiConfig.port,
|
|
83
|
+
logPath
|
|
84
|
+
};
|
|
85
|
+
writeInitialManagedServiceState({
|
|
86
|
+
config,
|
|
87
|
+
lease: this.createLease(child.pid),
|
|
88
|
+
readinessTimeoutMs,
|
|
89
|
+
snapshot
|
|
90
|
+
});
|
|
91
|
+
this.serviceStartupLogger.info("runtime.process.started", {
|
|
92
|
+
runtimeKind: "managed-service",
|
|
93
|
+
childPid: child.pid,
|
|
94
|
+
uiUrl,
|
|
95
|
+
apiUrl,
|
|
96
|
+
uiHost: uiConfig.host,
|
|
97
|
+
uiPort: uiConfig.port,
|
|
98
|
+
entrypoint: `${cliLaunch.command} ${childArgs.join(" ")}`
|
|
99
|
+
});
|
|
100
|
+
this.serviceStartupLogger.info("service_state.written", {
|
|
101
|
+
runtimeKind: "managed-service",
|
|
102
|
+
childPid: child.pid,
|
|
103
|
+
statePath: this.stateStore.path,
|
|
104
|
+
uiUrl,
|
|
105
|
+
apiUrl
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
child,
|
|
109
|
+
logPath,
|
|
110
|
+
readinessTimeoutMs,
|
|
111
|
+
quickPhaseTimeoutMs,
|
|
112
|
+
extendedPhaseTimeoutMs,
|
|
113
|
+
snapshot
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
writeReadyState = (params) => {
|
|
117
|
+
return writeReadyManagedServiceState({
|
|
118
|
+
...params,
|
|
119
|
+
lease: this.createLease(params.snapshot.pid)
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
installCurrentProcessLifecycleTracking = () => {
|
|
123
|
+
if (this.lifecycleTrackingInstalled) return;
|
|
124
|
+
this.lifecycleTrackingInstalled = true;
|
|
125
|
+
this.startHeartbeatForCurrentProcess();
|
|
126
|
+
for (const signal of [
|
|
127
|
+
"SIGHUP",
|
|
128
|
+
"SIGINT",
|
|
129
|
+
"SIGTERM"
|
|
130
|
+
]) process.once(signal, () => {
|
|
131
|
+
this.pendingExit = {
|
|
132
|
+
pid: process.pid,
|
|
133
|
+
reason: "signal",
|
|
134
|
+
exitedAt: this.now().toISOString(),
|
|
135
|
+
code: SIGNAL_EXIT_CODES[signal],
|
|
136
|
+
signal
|
|
137
|
+
};
|
|
138
|
+
this.recordCurrentProcessExit(this.pendingExit);
|
|
139
|
+
this.stopHeartbeat();
|
|
140
|
+
process.exit(SIGNAL_EXIT_CODES[signal]);
|
|
141
|
+
});
|
|
142
|
+
process.once("uncaughtExceptionMonitor", (error) => {
|
|
143
|
+
this.pendingExit = {
|
|
144
|
+
pid: process.pid,
|
|
145
|
+
reason: "uncaughtException",
|
|
146
|
+
exitedAt: this.now().toISOString(),
|
|
147
|
+
message: error instanceof Error ? error.message : String(error)
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
process.once("exit", (code) => {
|
|
151
|
+
this.recordCurrentProcessExit({
|
|
152
|
+
...this.pendingExit ?? {
|
|
153
|
+
pid: process.pid,
|
|
154
|
+
reason: "exit",
|
|
155
|
+
exitedAt: this.now().toISOString()
|
|
156
|
+
},
|
|
157
|
+
code
|
|
158
|
+
});
|
|
159
|
+
this.stopHeartbeat();
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
startHeartbeatForCurrentProcess = (pid = process.pid) => {
|
|
163
|
+
if (this.heartbeatTimer) return;
|
|
164
|
+
if (!this.writeHeartbeat(pid)) return;
|
|
165
|
+
this.heartbeatTimer = setInterval(() => {
|
|
166
|
+
if (!this.writeHeartbeat(pid)) this.stopHeartbeat();
|
|
167
|
+
}, this.heartbeatIntervalMs);
|
|
168
|
+
this.heartbeatTimer.unref();
|
|
169
|
+
};
|
|
170
|
+
stopHeartbeatForCurrentProcess = () => {
|
|
171
|
+
this.stopHeartbeat();
|
|
172
|
+
};
|
|
173
|
+
resolveStateLiveness = (state) => {
|
|
174
|
+
if (!state) return {
|
|
175
|
+
processExists: false,
|
|
176
|
+
running: false,
|
|
177
|
+
staleState: false,
|
|
178
|
+
staleReason: null,
|
|
179
|
+
leaseExpired: false,
|
|
180
|
+
leaseMissing: false,
|
|
181
|
+
lastHeartbeatAt: null
|
|
182
|
+
};
|
|
183
|
+
const processExists = this.isProcessRunningFn(state.pid);
|
|
184
|
+
const leaseStatus = this.resolveLeaseStatus(state.lease);
|
|
185
|
+
if (!processExists) return {
|
|
186
|
+
processExists,
|
|
187
|
+
running: false,
|
|
188
|
+
staleState: true,
|
|
189
|
+
staleReason: "process-not-running",
|
|
190
|
+
leaseExpired: leaseStatus.expired,
|
|
191
|
+
leaseMissing: leaseStatus.missing,
|
|
192
|
+
lastHeartbeatAt: leaseStatus.heartbeatAt
|
|
193
|
+
};
|
|
194
|
+
if (leaseStatus.expired) return {
|
|
195
|
+
processExists,
|
|
196
|
+
running: false,
|
|
197
|
+
staleState: true,
|
|
198
|
+
staleReason: "lease-expired",
|
|
199
|
+
leaseExpired: true,
|
|
200
|
+
leaseMissing: false,
|
|
201
|
+
lastHeartbeatAt: leaseStatus.heartbeatAt
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
processExists,
|
|
205
|
+
running: true,
|
|
206
|
+
staleState: false,
|
|
207
|
+
staleReason: null,
|
|
208
|
+
leaseExpired: false,
|
|
209
|
+
leaseMissing: leaseStatus.missing,
|
|
210
|
+
lastHeartbeatAt: leaseStatus.heartbeatAt
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
writeHeartbeat = (pid) => {
|
|
214
|
+
let wrote = false;
|
|
215
|
+
this.stateStore.update((state) => {
|
|
216
|
+
if (state.pid !== pid) return state;
|
|
217
|
+
wrote = true;
|
|
218
|
+
const next = {
|
|
219
|
+
...state,
|
|
220
|
+
lease: {
|
|
221
|
+
...state.lease ?? this.createLease(pid),
|
|
222
|
+
ownerPid: pid,
|
|
223
|
+
heartbeatAt: this.now().toISOString(),
|
|
224
|
+
heartbeatIntervalMs: this.heartbeatIntervalMs,
|
|
225
|
+
ttlMs: this.leaseTtlMs
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
delete next.lastExit;
|
|
229
|
+
return next;
|
|
230
|
+
});
|
|
231
|
+
return wrote;
|
|
232
|
+
};
|
|
233
|
+
recordCurrentProcessExit = (exit) => {
|
|
234
|
+
this.stateStore.update((state) => {
|
|
235
|
+
if (state.pid !== exit.pid) return state;
|
|
236
|
+
return {
|
|
237
|
+
...state,
|
|
238
|
+
lastExit: exit
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
stopHeartbeat = () => {
|
|
243
|
+
if (!this.heartbeatTimer) return;
|
|
244
|
+
clearInterval(this.heartbeatTimer);
|
|
245
|
+
this.heartbeatTimer = null;
|
|
246
|
+
};
|
|
247
|
+
createLease = (ownerPid) => ({
|
|
248
|
+
ownerPid,
|
|
249
|
+
heartbeatAt: this.now().toISOString(),
|
|
250
|
+
heartbeatIntervalMs: this.heartbeatIntervalMs,
|
|
251
|
+
ttlMs: this.leaseTtlMs
|
|
252
|
+
});
|
|
253
|
+
resolveLeaseStatus = (lease) => {
|
|
254
|
+
if (!lease) return {
|
|
255
|
+
expired: false,
|
|
256
|
+
missing: true,
|
|
257
|
+
heartbeatAt: null
|
|
258
|
+
};
|
|
259
|
+
const heartbeatAtMs = Date.parse(lease.heartbeatAt);
|
|
260
|
+
const ttlMs = Number.isFinite(lease.ttlMs) ? lease.ttlMs : this.leaseTtlMs;
|
|
261
|
+
return {
|
|
262
|
+
expired: !Number.isFinite(heartbeatAtMs) || heartbeatAtMs + ttlMs < this.now().getTime(),
|
|
263
|
+
missing: false,
|
|
264
|
+
heartbeatAt: lease.heartbeatAt
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
//#endregion
|
|
269
|
+
export { ManagedServiceSupervisor };
|
|
270
|
+
|
|
271
|
+
//# sourceMappingURL=managed-service-supervisor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-service-supervisor.service.js","names":[],"sources":["../../../../src/shared/services/runtime/managed-service-supervisor.service.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { mkdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport * as NextclawCore from \"@nextclaw/core\";\nimport { FileLogSink } from \"@nextclaw/core\";\nimport {\n managedServiceStateStore,\n type ManagedServiceLastExit,\n type ManagedServiceLease,\n type ManagedServiceState,\n type ManagedServiceStateStore\n} from \"@nextclaw-service/shared/stores/managed-service-state.store.js\";\nimport { writeInitialManagedServiceState, writeReadyManagedServiceState } from \"@nextclaw-service/shared/services/runtime/utils/service-remote-runtime.utils.js\";\nimport type { ManagedServiceSnapshot } from \"@nextclaw-service/shared/services/runtime/utils/managed-service-routing.utils.js\";\nimport { resolveCliSubcommandLaunch } from \"@nextclaw-service/shared/utils/marketplace/cli-subcommand-launch.utils.js\";\nimport { createTopLevelNextclawCommandEnv } from \"@nextclaw-service/shared/utils/top-level-nextclaw-command-env.utils.js\";\nimport { isProcessRunning, resolveServiceLogPath } from \"@nextclaw-service/shared/utils/cli.utils.js\";\n\nconst DEFAULT_HEARTBEAT_INTERVAL_MS = 2_000;\nconst DEFAULT_LEASE_TTL_MS = 10_000;\nconst SIGNAL_EXIT_CODES: Record<string, number> = {\n SIGHUP: 129,\n SIGINT: 130,\n SIGTERM: 143\n};\n\ntype Config = NextclawCore.Config;\n\ntype ManagedServiceStartup = {\n child: ChildProcess;\n logPath: string;\n readinessTimeoutMs: number;\n quickPhaseTimeoutMs: number;\n extendedPhaseTimeoutMs: number;\n snapshot: ManagedServiceSnapshot;\n};\n\ntype ManagedServiceLiveness = {\n processExists: boolean;\n running: boolean;\n staleState: boolean;\n staleReason: \"process-not-running\" | \"lease-expired\" | null;\n leaseExpired: boolean;\n leaseMissing: boolean;\n lastHeartbeatAt: string | null;\n};\n\ntype ManagedServiceSupervisorOptions = {\n stateStore?: ManagedServiceStateStore;\n now?: () => Date;\n isProcessRunningFn?: (pid: number) => boolean;\n heartbeatIntervalMs?: number;\n leaseTtlMs?: number;\n};\n\nexport class ManagedServiceSupervisor {\n private readonly stateStore: ManagedServiceStateStore;\n private readonly now: () => Date;\n private readonly isProcessRunningFn: (pid: number) => boolean;\n private readonly heartbeatIntervalMs: number;\n private readonly leaseTtlMs: number;\n private readonly serviceStartupLogger = NextclawCore.getAppLogger(\"service.startup\");\n private heartbeatTimer: NodeJS.Timeout | null = null;\n private lifecycleTrackingInstalled = false;\n private pendingExit: ManagedServiceLastExit | null = null;\n\n constructor(options: ManagedServiceSupervisorOptions = {}) {\n this.stateStore = options.stateStore ?? managedServiceStateStore;\n this.now = options.now ?? (() => new Date());\n this.isProcessRunningFn = options.isProcessRunningFn ?? isProcessRunning;\n this.heartbeatIntervalMs = options.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_INTERVAL_MS;\n this.leaseTtlMs = options.leaseTtlMs ?? DEFAULT_LEASE_TTL_MS;\n }\n\n spawnManagedService = (params: {\n appName: string;\n config: Config;\n uiConfig: { host: string; port: number };\n uiUrl: string;\n apiUrl: string;\n healthUrl: string;\n startupTimeoutMs?: number;\n resolveStartupTimeoutMs: (overrideTimeoutMs: number | undefined) => number;\n appendStartupStage: (logPath: string, message: string) => void;\n printStartupFailureDiagnostics: (params: {\n uiUrl: string;\n apiUrl: string;\n healthUrl: string;\n logPath: string;\n lastProbeError: string | null;\n }) => void;\n resolveServiceLogPath?: () => string;\n }): ManagedServiceStartup | null => {\n const {\n appName,\n apiUrl,\n appendStartupStage,\n config,\n healthUrl,\n printStartupFailureDiagnostics,\n resolveStartupTimeoutMs,\n startupTimeoutMs,\n uiConfig,\n uiUrl\n } = params;\n const logPath = (params.resolveServiceLogPath ?? resolveServiceLogPath)();\n new FileLogSink({ serviceLogPath: logPath }).ensureReady();\n mkdirSync(dirname(logPath), { recursive: true });\n const readinessTimeoutMs = resolveStartupTimeoutMs(startupTimeoutMs);\n const quickPhaseTimeoutMs = Math.min(8000, readinessTimeoutMs);\n const extendedPhaseTimeoutMs = Math.max(0, readinessTimeoutMs - quickPhaseTimeoutMs);\n appendStartupStage(\n logPath,\n `start requested: ui=${uiConfig.host}:${uiConfig.port}, readinessTimeoutMs=${readinessTimeoutMs}`\n );\n console.log(`Starting ${appName} background service (readiness timeout ${Math.ceil(readinessTimeoutMs / 1000)}s)...`);\n\n const cliLaunch = resolveCliSubcommandLaunch({\n argvEntry: process.argv[1],\n importMetaUrl: import.meta.url,\n cliArgs: [\"serve\", \"--ui-port\", String(uiConfig.port)],\n nodePath: process.execPath\n });\n const childArgs = [...process.execArgv, ...cliLaunch.args];\n appendStartupStage(logPath, `spawning background process: ${cliLaunch.command} ${childArgs.join(\" \")}`);\n const child = spawn(cliLaunch.command, childArgs, {\n env: createTopLevelNextclawCommandEnv(process.env),\n stdio: \"ignore\",\n detached: true,\n windowsHide: true\n });\n appendStartupStage(logPath, `spawned background process pid=${child.pid ?? \"unknown\"}`);\n if (!child.pid) {\n appendStartupStage(logPath, \"spawn failed: child pid missing\");\n console.error(\"Error: Failed to start background service.\");\n printStartupFailureDiagnostics({\n uiUrl,\n apiUrl,\n healthUrl,\n logPath,\n lastProbeError: null\n });\n return null;\n }\n\n const snapshot: ManagedServiceSnapshot = {\n pid: child.pid,\n uiUrl,\n apiUrl,\n uiHost: uiConfig.host,\n uiPort: uiConfig.port,\n logPath\n };\n writeInitialManagedServiceState({\n config,\n lease: this.createLease(child.pid),\n readinessTimeoutMs,\n snapshot\n });\n this.serviceStartupLogger.info(\"runtime.process.started\", {\n runtimeKind: \"managed-service\",\n childPid: child.pid,\n uiUrl,\n apiUrl,\n uiHost: uiConfig.host,\n uiPort: uiConfig.port,\n entrypoint: `${cliLaunch.command} ${childArgs.join(\" \")}`\n });\n this.serviceStartupLogger.info(\"service_state.written\", {\n runtimeKind: \"managed-service\",\n childPid: child.pid,\n statePath: this.stateStore.path,\n uiUrl,\n apiUrl\n });\n return {\n child,\n logPath,\n readinessTimeoutMs,\n quickPhaseTimeoutMs,\n extendedPhaseTimeoutMs,\n snapshot\n };\n };\n\n writeReadyState = (params: {\n readinessTimeoutMs: number;\n readiness: { ready: boolean; lastProbeError: string | null };\n snapshot: ManagedServiceSnapshot;\n }): ManagedServiceState => {\n return writeReadyManagedServiceState({\n ...params,\n lease: this.createLease(params.snapshot.pid)\n });\n };\n\n installCurrentProcessLifecycleTracking = (): void => {\n if (this.lifecycleTrackingInstalled) {\n return;\n }\n this.lifecycleTrackingInstalled = true;\n this.startHeartbeatForCurrentProcess();\n\n for (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"] as const) {\n process.once(signal, () => {\n this.pendingExit = {\n pid: process.pid,\n reason: \"signal\",\n exitedAt: this.now().toISOString(),\n code: SIGNAL_EXIT_CODES[signal],\n signal\n };\n this.recordCurrentProcessExit(this.pendingExit);\n this.stopHeartbeat();\n process.exit(SIGNAL_EXIT_CODES[signal]);\n });\n }\n\n process.once(\"uncaughtExceptionMonitor\", (error) => {\n this.pendingExit = {\n pid: process.pid,\n reason: \"uncaughtException\",\n exitedAt: this.now().toISOString(),\n message: error instanceof Error ? error.message : String(error)\n };\n });\n\n process.once(\"exit\", (code) => {\n this.recordCurrentProcessExit({\n ...(this.pendingExit ?? {\n pid: process.pid,\n reason: \"exit\",\n exitedAt: this.now().toISOString()\n }),\n code\n });\n this.stopHeartbeat();\n });\n };\n\n startHeartbeatForCurrentProcess = (pid = process.pid): void => {\n if (this.heartbeatTimer) {\n return;\n }\n if (!this.writeHeartbeat(pid)) {\n return;\n }\n this.heartbeatTimer = setInterval(() => {\n if (!this.writeHeartbeat(pid)) {\n this.stopHeartbeat();\n }\n }, this.heartbeatIntervalMs);\n this.heartbeatTimer.unref();\n };\n\n stopHeartbeatForCurrentProcess = (): void => {\n this.stopHeartbeat();\n };\n\n resolveStateLiveness = (state: ManagedServiceState | null): ManagedServiceLiveness => {\n if (!state) {\n return {\n processExists: false,\n running: false,\n staleState: false,\n staleReason: null,\n leaseExpired: false,\n leaseMissing: false,\n lastHeartbeatAt: null\n };\n }\n\n const processExists = this.isProcessRunningFn(state.pid);\n const leaseStatus = this.resolveLeaseStatus(state.lease);\n if (!processExists) {\n return {\n processExists,\n running: false,\n staleState: true,\n staleReason: \"process-not-running\",\n leaseExpired: leaseStatus.expired,\n leaseMissing: leaseStatus.missing,\n lastHeartbeatAt: leaseStatus.heartbeatAt\n };\n }\n if (leaseStatus.expired) {\n return {\n processExists,\n running: false,\n staleState: true,\n staleReason: \"lease-expired\",\n leaseExpired: true,\n leaseMissing: false,\n lastHeartbeatAt: leaseStatus.heartbeatAt\n };\n }\n return {\n processExists,\n running: true,\n staleState: false,\n staleReason: null,\n leaseExpired: false,\n leaseMissing: leaseStatus.missing,\n lastHeartbeatAt: leaseStatus.heartbeatAt\n };\n };\n\n private writeHeartbeat = (pid: number): boolean => {\n let wrote = false;\n this.stateStore.update((state) => {\n if (state.pid !== pid) {\n return state;\n }\n wrote = true;\n const next: ManagedServiceState = {\n ...state,\n lease: {\n ...(state.lease ?? this.createLease(pid)),\n ownerPid: pid,\n heartbeatAt: this.now().toISOString(),\n heartbeatIntervalMs: this.heartbeatIntervalMs,\n ttlMs: this.leaseTtlMs\n }\n };\n delete next.lastExit;\n return next;\n });\n return wrote;\n };\n\n recordCurrentProcessExit = (exit: ManagedServiceLastExit): void => {\n this.stateStore.update((state) => {\n if (state.pid !== exit.pid) {\n return state;\n }\n return {\n ...state,\n lastExit: exit\n };\n });\n };\n\n private stopHeartbeat = (): void => {\n if (!this.heartbeatTimer) {\n return;\n }\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = null;\n };\n\n private readonly createLease = (ownerPid: number): ManagedServiceLease => ({\n ownerPid,\n heartbeatAt: this.now().toISOString(),\n heartbeatIntervalMs: this.heartbeatIntervalMs,\n ttlMs: this.leaseTtlMs\n });\n\n private resolveLeaseStatus = (lease: ManagedServiceLease | undefined): {\n expired: boolean;\n missing: boolean;\n heartbeatAt: string | null;\n } => {\n if (!lease) {\n return {\n expired: false,\n missing: true,\n heartbeatAt: null\n };\n }\n const heartbeatAtMs = Date.parse(lease.heartbeatAt);\n const ttlMs = Number.isFinite(lease.ttlMs) ? lease.ttlMs : this.leaseTtlMs;\n return {\n expired: !Number.isFinite(heartbeatAtMs) || heartbeatAtMs + ttlMs < this.now().getTime(),\n missing: false,\n heartbeatAt: lease.heartbeatAt\n };\n };\n}\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,gCAAgC;AACtC,MAAM,uBAAuB;AAC7B,MAAM,oBAA4C;CAChD,QAAQ;CACR,QAAQ;CACR,SAAS;CACV;AA+BD,IAAa,2BAAb,MAAsC;CACpC;CACA;CACA;CACA;CACA;CACA,uBAAwC,aAAa,aAAa,kBAAkB;CACpF,iBAAgD;CAChD,6BAAqC;CACrC,cAAqD;CAErD,YAAY,UAA2C,EAAE,EAAE;AACzD,OAAK,aAAa,QAAQ,cAAc;AACxC,OAAK,MAAM,QAAQ,8BAAc,IAAI,MAAM;AAC3C,OAAK,qBAAqB,QAAQ,sBAAsB;AACxD,OAAK,sBAAsB,QAAQ,uBAAuB;AAC1D,OAAK,aAAa,QAAQ,cAAc;;CAG1C,uBAAuB,WAkBa;EAClC,MAAM,EACJ,SACA,QACA,oBACA,QACA,WACA,gCACA,yBACA,kBACA,UACA,UACE;EACJ,MAAM,WAAW,OAAO,yBAAyB,wBAAwB;AACzE,MAAI,YAAY,EAAE,gBAAgB,SAAS,CAAC,CAAC,aAAa;AAC1D,YAAU,QAAQ,QAAQ,EAAE,EAAE,WAAW,MAAM,CAAC;EAChD,MAAM,qBAAqB,wBAAwB,iBAAiB;EACpE,MAAM,sBAAsB,KAAK,IAAI,KAAM,mBAAmB;EAC9D,MAAM,yBAAyB,KAAK,IAAI,GAAG,qBAAqB,oBAAoB;AACpF,qBACE,SACA,uBAAuB,SAAS,KAAK,GAAG,SAAS,KAAK,uBAAuB,qBAC9E;AAC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AK,MAAM,MAAM,YAAY;EACnD,MAAM,QAAQ,OAAO,SAAS,MAAM,MAAM,GAAG,MAAM,QAAQ,KAAK;AAChE,SAAO;GACL,SAAS,CAAC,OAAO,SAAS,cAAc,IAAI,gBAAgB,QAAQ,KAAK,KAAK,CAAC,SAAS;GACxF,SAAS;GACT,aAAa,MAAM;GACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-distribution.service.d.ts","names":[],"sources":["../../../../src/shared/services/runtime/nextclaw-distribution.service.ts"],"mappings":";;;cAEa,2BAAA;EAAA,eACI,mBAAA;EAAA,OAER,SAAA,CAAU,YAAA,EAAc,oBAAA;EAAA,OAIxB,GAAA,CAAA,GAAO,oBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-distribution.service.js","names":[],"sources":["../../../../src/shared/services/runtime/nextclaw-distribution.service.ts"],"sourcesContent":["import type { NextclawDistribution } from \"@nextclaw-service/shared/types/distribution.types.js\";\n\nexport class NextclawDistributionService {\n private static currentDistribution: NextclawDistribution | null = null;\n\n static configure(distribution: NextclawDistribution): void {\n NextclawDistributionService.currentDistribution = distribution;\n }\n\n static get(): NextclawDistribution {\n if (!NextclawDistributionService.currentDistribution) {\n throw new Error(\"NextClaw distribution is not configured.\");\n }\n return NextclawDistributionService.currentDistribution;\n }\n}\n"],"mappings":";AAEA,IAAa,8BAAb,MAAa,4BAA4B;CACvC,OAAe,sBAAmD;CAElE,OAAO,UAAU,cAA0C;AACzD,8BAA4B,sBAAsB;;CAGpD,OAAO,MAA4B;AACjC,MAAI,CAAC,4BAA4B,oBAC/B,OAAM,IAAI,MAAM,2CAA2C;AAE7D,SAAO,4BAA4B"}
|
|
@@ -11,6 +11,7 @@ declare class RuntimeCommandService {
|
|
|
11
11
|
private loggingInstalled;
|
|
12
12
|
private processExitLoggingInstalled;
|
|
13
13
|
private readonly runtimeLogger;
|
|
14
|
+
private readonly managedServiceSupervisor;
|
|
14
15
|
private readonly managedServiceCommandService;
|
|
15
16
|
constructor(deps: {
|
|
16
17
|
requestRestart: (params: RequestRestartParams) => Promise<void>;
|
|
@@ -37,4 +38,5 @@ declare class RuntimeCommandService {
|
|
|
37
38
|
private printServiceControlHints;
|
|
38
39
|
}
|
|
39
40
|
//#endregion
|
|
40
|
-
export { RuntimeCommandService, buildMarketplaceSkillInstallArgs, describeUnmanagedHealthyTargetMessage, pickUserFacingCommandSummary };
|
|
41
|
+
export { RuntimeCommandService, buildMarketplaceSkillInstallArgs, describeUnmanagedHealthyTargetMessage, pickUserFacingCommandSummary };
|
|
42
|
+
//# sourceMappingURL=runtime-command.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-command.service.d.ts","names":[],"sources":["../../../../src/shared/services/runtime/runtime-command.service.ts"],"mappings":";;;;;;;KAiBK,QAAA,GAAS,YAAA,CAAa,MAAA;AAAA,cAEd,qBAAA;EAAA,QAaS,IAAA;EAAA,QAZZ,gBAAA;EAAA,QACA,2BAAA;EAAA,iBACS,aAAA;EAAA,iBACA,wBAAA;EAAA,iBACA,4BAAA;cAQG,IAAA;IAClB,cAAA,GAAiB,MAAA,EAAQ,oBAAA,KAAyB,OAAA;IAClD,4BAAA,GAA+B,aAAA;EAAA;EAGjC,YAAA,GAAsB,OAAA;IAAW,WAAA,GAAc,OAAA,CAAQ,QAAA;IAAe,WAAA;EAAA,MAAqC,OAAA;EA0B3G,YAAA,GAAsB,OAAA,EAAS,mBAAA,KAAsB,OAAA;EAIrD,WAAA,QAAwB,OAAA;EAIxB,aAAA,GAAuB,OAAA;IACrB,WAAA,EAAa,OAAA,CAAQ,QAAA;IACrB,IAAA;EAAA,MACE,OAAA;EAAA,QAII,8BAAA;EAAA,QAUA,kBAAA;EAAA,QAIA,gBAAA;EAAA,QAWA,UAAA;EAAA,QA2CA,6BAAA;EAAA,QAWA,yBAAA;EAAA,QAcA,oBAAA;EAAA,QA6BA,iBAAA;EAAA,QAoBA,wBAAA;AAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveCliSubcommandEntry } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
|
|
2
2
|
import { isLoopbackHost, resolvePublicIp, resolveUiStaticDir } from "../../utils/cli.utils.js";
|
|
3
3
|
import { NextclawDistributionService } from "./nextclaw-distribution.service.js";
|
|
4
|
+
import { ManagedServiceSupervisor } from "./managed-service-supervisor.service.js";
|
|
4
5
|
import { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from "../../utils/service-port-probe.utils.js";
|
|
5
6
|
import { ManagedServiceCommandService } from "./service-managed-startup.service.js";
|
|
6
7
|
import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
|
|
@@ -14,6 +15,7 @@ var RuntimeCommandService = class {
|
|
|
14
15
|
loggingInstalled = false;
|
|
15
16
|
processExitLoggingInstalled = false;
|
|
16
17
|
runtimeLogger = NextclawCore.getAppLogger("service.runtime");
|
|
18
|
+
managedServiceSupervisor = new ManagedServiceSupervisor();
|
|
17
19
|
managedServiceCommandService = new ManagedServiceCommandService({
|
|
18
20
|
startGateway: async (options) => await this.startGateway(options),
|
|
19
21
|
printPublicUiUrls: async (host, port) => await this.printPublicUiUrls(host, port),
|
|
@@ -27,6 +29,7 @@ var RuntimeCommandService = class {
|
|
|
27
29
|
startGateway = async (options = {}) => {
|
|
28
30
|
this.ensureRuntimeLoggingInstalled();
|
|
29
31
|
this.installProcessExitLogging();
|
|
32
|
+
this.managedServiceSupervisor.installCurrentProcessLifecycleTracking();
|
|
30
33
|
this.runtimeLogger.info("runtime.process.started", {
|
|
31
34
|
runtimeKind: "serve-process",
|
|
32
35
|
pid: process.pid,
|
|
@@ -188,3 +191,5 @@ var RuntimeCommandService = class {
|
|
|
188
191
|
};
|
|
189
192
|
//#endregion
|
|
190
193
|
export { RuntimeCommandService, buildMarketplaceSkillInstallArgs, describeUnmanagedHealthyTargetMessage, pickUserFacingCommandSummary };
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=runtime-command.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-command.service.js","names":["getWorkspacePath","loadConfig"],"sources":["../../../../src/shared/services/runtime/runtime-command.service.ts"],"sourcesContent":["import * as NextclawCore from \"@nextclaw/core\";\nimport { spawn } from \"node:child_process\";\nimport { SkillManager } from \"@nextclaw/kernel\";\nimport type { RequestRestartParams } from \"@nextclaw-service/shared/types/cli.types.js\";\nimport { ManagedServiceCommandService, type StartServiceOptions } from \"@nextclaw-service/shared/services/runtime/service-managed-startup.service.js\";\nimport { ManagedServiceSupervisor } from \"@nextclaw-service/shared/services/runtime/managed-service-supervisor.service.js\";\nimport { NextclawGatewayRuntime } from \"@nextclaw-service/shared/services/gateway/nextclaw-gateway-runtime.service.js\";\nimport { NextclawDistributionService } from \"@nextclaw-service/shared/services/runtime/nextclaw-distribution.service.js\";\nimport { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from \"@nextclaw-service/shared/utils/service-port-probe.utils.js\";\nimport { resolveCliSubcommandEntry } from \"@nextclaw-service/shared/utils/marketplace/cli-subcommand-launch.utils.js\";\nimport { isLoopbackHost, resolvePublicIp, resolveUiStaticDir } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nexport { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from \"@nextclaw-service/shared/utils/marketplace/service-marketplace-helpers.utils.js\";\nexport { describeUnmanagedHealthyTargetMessage };\nconst {\n getWorkspacePath,\n loadConfig,\n} = NextclawCore;\ntype Config = NextclawCore.Config;\n\nexport class RuntimeCommandService {\n private loggingInstalled = false;\n private processExitLoggingInstalled = false;\n private readonly runtimeLogger = NextclawCore.getAppLogger(\"service.runtime\");\n private readonly managedServiceSupervisor = new ManagedServiceSupervisor();\n private readonly managedServiceCommandService = new ManagedServiceCommandService({\n startGateway: async (options) => await this.startGateway(options),\n printPublicUiUrls: async (host, port) => await this.printPublicUiUrls(host, port),\n printServiceControlHints: () => this.printServiceControlHints(),\n checkUiPortPreflight: async (params) => await this.checkUiPortPreflight(params),\n resolveUiStaticDir: () => resolveUiStaticDir(NextclawDistributionService.get().uiDistDir)\n });\n\n constructor(private deps: {\n requestRestart: (params: RequestRestartParams) => Promise<void>;\n initializeAgentHomeDirectory: (homeDirectory: string) => void;\n }) {}\n\n startGateway = async (options: { uiOverrides?: Partial<Config[\"ui\"]>; uiStaticDir?: string | null } = {}): Promise<void> => {\n this.ensureRuntimeLoggingInstalled();\n this.installProcessExitLogging();\n this.managedServiceSupervisor.installCurrentProcessLifecycleTracking();\n this.runtimeLogger.info(\"runtime.process.started\", {\n runtimeKind: \"serve-process\",\n pid: process.pid,\n source: \"RuntimeCommandService.startGateway\"\n });\n await new NextclawGatewayRuntime({\n requestRestart: this.deps.requestRestart,\n initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,\n startService: this.startService,\n stopService: this.stopService,\n runCliSubcommand: this.runCliSubcommand,\n installBuiltinMarketplaceSkill: this.installBuiltinMarketplaceSkill,\n }, {\n ...options\n }).start();\n this.runtimeLogger.info(\"runtime.process.ready\", {\n runtimeKind: \"serve-process\",\n pid: process.pid,\n source: \"RuntimeCommandService.startGateway\"\n });\n };\n\n startService = async (options: StartServiceOptions): Promise<void> => {\n await this.managedServiceCommandService.startService(options);\n };\n\n stopService = async (): Promise<void> => {\n await this.managedServiceCommandService.stopService();\n };\n\n runForeground = async (options: {\n uiOverrides: Partial<Config[\"ui\"]>;\n open: boolean;\n }): Promise<void> => {\n await this.managedServiceCommandService.runForeground(options);\n };\n\n private installBuiltinMarketplaceSkill = (slug: string, _force: boolean | undefined): { message: string; output?: string } | null => {\n const workspace = getWorkspacePath(loadConfig().agents.defaults.workspace);\n if (!new SkillManager({ workspace }).findBuiltinSkill(slug)) {\n return null;\n }\n return {\n message: `${slug} is already available (built-in)`\n };\n };\n\n private mergeCommandOutput = (stdout: string, stderr: string): string => {\n return `${stdout}\\n${stderr}`.trim();\n };\n\n private runCliSubcommand = (args: string[], timeoutMs = 180_000): Promise<string> => {\n const cliEntry = resolveCliSubcommandEntry({\n argvEntry: process.argv[1],\n importMetaUrl: import.meta.url\n });\n return this.runCommand(process.execPath, [...process.execArgv, cliEntry, ...args], {\n cwd: process.cwd(),\n timeoutMs\n }).then((result) => this.mergeCommandOutput(result.stdout, result.stderr));\n };\n\n private runCommand = (command: string, args: string[], options: { cwd?: string; timeoutMs?: number } = {}): Promise<{ stdout: string; stderr: string }> => {\n const timeoutMs = options.timeoutMs ?? 180_000;\n return new Promise((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n cwd: options.cwd ?? process.cwd(),\n env: process.env,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n windowsHide: true\n });\n\n let stdout = \"\";\n let stderr = \"\";\n child.stdout?.setEncoding(\"utf-8\");\n child.stderr?.setEncoding(\"utf-8\");\n child.stdout?.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr?.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n\n const timer = setTimeout(() => {\n child.kill(\"SIGTERM\");\n rejectPromise(new Error(`command timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n\n child.on(\"error\", (error) => {\n clearTimeout(timer);\n rejectPromise(new Error(`failed to start command: ${String(error)}`));\n });\n\n child.on(\"close\", (code) => {\n clearTimeout(timer);\n const output = this.mergeCommandOutput(stdout, stderr);\n if (code === 0) {\n resolvePromise({ stdout, stderr });\n return;\n }\n rejectPromise(new Error(output || `command failed with code ${code ?? 1}`));\n });\n });\n };\n\n private ensureRuntimeLoggingInstalled = (): void => {\n if (this.loggingInstalled) {\n return;\n }\n NextclawCore.configureAppLogging({\n installConsoleMirror: true,\n installProcessCrashMonitor: true\n });\n this.loggingInstalled = true;\n };\n\n private installProcessExitLogging = (): void => {\n if (this.processExitLoggingInstalled) {\n return;\n }\n this.processExitLoggingInstalled = true;\n process.once(\"exit\", (code) => {\n this.runtimeLogger.warn(\"runtime.process.exited\", {\n runtimeKind: \"serve-process\",\n pid: process.pid,\n code\n });\n });\n };\n\n private checkUiPortPreflight = async (params: {\n host: string;\n port: number;\n healthUrl: string;\n }): Promise<\n | { ok: true; reusedExistingHealthyTarget: boolean }\n | { ok: false; message: string }\n > => {\n const target = await inspectUiTarget(params);\n if (target.state === \"available\") {\n return { ok: true, reusedExistingHealthyTarget: false };\n }\n if (target.state === \"healthy-existing\") {\n return { ok: true, reusedExistingHealthyTarget: true };\n }\n\n const lines = [`Port probe: ${target.availabilityDetail}`];\n if (target.probeError) {\n lines.push(`Health probe: ${target.probeError}`);\n }\n lines.push(\"The port is occupied by a process that does not answer as a healthy NextClaw HTTP server.\");\n lines.push(`Fix: free port ${params.port} or start NextClaw with another port via --ui-port <port>.`);\n lines.push(`Inspect locally with: ss -ltnp | grep ${params.port} || lsof -iTCP:${params.port} -sTCP:LISTEN -n -P`);\n return {\n ok: false,\n message: lines.join(\"\\n\")\n };\n };\n\n private printPublicUiUrls = async (host: string, port: number): Promise<void> => {\n if (isLoopbackHost(host)) {\n console.log(\"Public URL: disabled (UI host is loopback). Current release expects public exposure; run nextclaw restart.\");\n return;\n }\n\n const publicIp = await resolvePublicIp();\n if (!publicIp) {\n console.log(\"Public URL: UI is exposed, but automatic public IP detection failed.\");\n return;\n }\n\n const publicBase = `http://${publicIp}:${port}`;\n console.log(`Public UI (if firewall/NAT allows): ${publicBase}`);\n console.log(`Public API (if firewall/NAT allows): ${publicBase}/api`);\n console.log(`Public deploy note: NextClaw serves plain HTTP on ${port}.`);\n console.log(`For https:// or standard 80/443 access, terminate TLS in Nginx/Caddy and proxy to http://127.0.0.1:${port}.`);\n console.log(`If a reverse proxy returns 502, verify its upstream is http://127.0.0.1:${port} (not https://, not a stale port, and not a stopped process).`);\n };\n\n private printServiceControlHints = (): void => {\n console.log(\"Service controls:\");\n console.log(\" - Check status: NextClaw status\");\n console.log(\" - If you need to stop the service, run: NextClaw stop\");\n console.log(\" - View log paths: NextClaw logs path\");\n console.log(\" - Tail recent logs: NextClaw logs tail\");\n console.log(\" - Check autostart: NextClaw service autostart status --user\");\n };\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,EACJ,kBAAA,oBACA,YAAA,iBACE;AAGJ,IAAa,wBAAb,MAAmC;CACjC,mBAA2B;CAC3B,8BAAsC;CACtC,gBAAiC,aAAa,aAAa,kBAAkB;CAC7E,2BAA4C,IAAI,0BAA0B;CAC1E,+BAAgD,IAAI,6BAA6B;EAC/E,cAAc,OAAO,YAAY,MAAM,KAAK,aAAa,QAAQ;EACjE,mBAAmB,OAAO,MAAM,SAAS,MAAM,KAAK,kBAAkB,MAAM,KAAK;EACjF,gCAAgC,KAAK,0BAA0B;EAC/D,sBAAsB,OAAO,WAAW,MAAM,KAAK,qBAAqB,OAAO;EAC/E,0BAA0B,mBAAmB,4BAA4B,KAAK,CAAC,UAAU;EAC1F,CAAC;CAEF,YAAY,MAGT;AAHiB,OAAA,OAAA;;CAKpB,eAAe,OAAO,UAAgF,EAAE,KAAoB;AAC1H,OAAK,+BAA+B;AACpC,OAAK,2BAA2B;AAChC,OAAK,yBAAyB,wCAAwC;AACtE,OAAK,cAAc,KAAK,2BAA2B;GACjD,aAAa;GACb,KAAK,QAAQ;GACb,QAAQ;GACT,CAAC;AACF,QAAM,IAAI,uBAAuB;GAC/B,gBAAgB,KAAK,KAAK;GAC1B,8BAA8B,KAAK,KAAK;GACxC,cAAc,KAAK;GACnB,aAAa,KAAK;GAClB,kBAAkB,KAAK;GACvB,gCAAgC,KAAK;GACtC,EAAE,EACD,GAAG,SACJ,CAAC,CAAC,OAAO;AACV,OAAK,cAAc,KAAK,yBAAyB;GAC/C,aAAa;GACb,KAAK,QAAQ;GACb,QAAQ;GACT,CAAC;;CAGJ,eAAe,OAAO,YAAgD;AACpE,QAAM,KAAK,6BAA6B,aAAa,QAAQ;;CAG/D,cAAc,YAA2B;AACvC,QAAM,KAAK,6BAA6B,aA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C;AAC/E,MAAI,eAAe,KAAK,EAAE;AACxB,WAAQ,IAAI,6GAA6G;AACzH;;EAGF,MAAM,WAAW,MAAM,iBAAiB;AACxC,MAAI,CAAC,UAAU;AACb,WAAQ,IAAI,uEAAuE;AACnF;;EAGF,MAAM,aAAa,UAAU,SAAS,GAAG;AACzC,UAAQ,IAAI,uCAAuC,aAAa;AAChE,UAAQ,IAAI,wCAAwC,WAAW,MAAM;AACrE,UAAQ,IAAI,qDAAqD,KAAK,GAAG;AACzE,UAAQ,IAAI,sGAAsG,KAAK,GAAG;AAC1H,UAAQ,IAAI,2EAA2E,KAAK,+DAA+D;;CAG7J,iCAA+C;AAC7C,UAAQ,IAAI,oBAAoB;AAChC,UAAQ,IAAI,oCAAoC;AAChD,UAAQ,IAAI,0DAA0D;AACtE,UAAQ,IAAI,yCAAyC;AACrD,UAAQ,IAAI,2CAA2C;AACvD,UAAQ,IAAI,gEAAgE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/shared/services/runtime/runtime-config-init.service.d.ts
|
|
2
2
|
declare function initializeConfigIfMissing(configPath?: string): boolean;
|
|
3
3
|
//#endregion
|
|
4
|
-
export { initializeConfigIfMissing };
|
|
4
|
+
export { initializeConfigIfMissing };
|
|
5
|
+
//# sourceMappingURL=runtime-config-init.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-config-init.service.d.ts","names":[],"sources":["../../../../src/shared/services/runtime/runtime-config-init.service.ts"],"mappings":";iBAGgB,yBAAA,CAA0B,UAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-config-init.service.js","names":[],"sources":["../../../../src/shared/services/runtime/runtime-config-init.service.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { getConfigPath, loadConfig } from \"@nextclaw/core\";\n\nexport function initializeConfigIfMissing(configPath = getConfigPath()): boolean {\n if (existsSync(configPath)) {\n return false;\n }\n loadConfig(configPath);\n return true;\n}\n"],"mappings":";;;AAGA,SAAgB,0BAA0B,aAAa,eAAe,EAAW;AAC/E,KAAI,WAAW,WAAW,CACxB,QAAO;AAET,YAAW,WAAW;AACtB,QAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate } from "./utils/managed-service-routing.utils.js";
|
|
2
2
|
import * as NextclawCore from "@nextclaw/core";
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
3
|
|
|
5
4
|
//#region src/shared/services/runtime/service-managed-startup.service.d.ts
|
|
6
5
|
type Config$1 = NextclawCore.Config;
|
|
@@ -9,35 +8,6 @@ type StartServiceOptions = {
|
|
|
9
8
|
open: boolean;
|
|
10
9
|
startupTimeoutMs?: number;
|
|
11
10
|
};
|
|
12
|
-
declare function spawnManagedService(params: {
|
|
13
|
-
appName: string;
|
|
14
|
-
config: NextclawCore.Config;
|
|
15
|
-
uiConfig: {
|
|
16
|
-
host: string;
|
|
17
|
-
port: number;
|
|
18
|
-
};
|
|
19
|
-
uiUrl: string;
|
|
20
|
-
apiUrl: string;
|
|
21
|
-
healthUrl: string;
|
|
22
|
-
startupTimeoutMs?: number;
|
|
23
|
-
resolveStartupTimeoutMs: (overrideTimeoutMs: number | undefined) => number;
|
|
24
|
-
appendStartupStage: (logPath: string, message: string) => void;
|
|
25
|
-
printStartupFailureDiagnostics: (params: {
|
|
26
|
-
uiUrl: string;
|
|
27
|
-
apiUrl: string;
|
|
28
|
-
healthUrl: string;
|
|
29
|
-
logPath: string;
|
|
30
|
-
lastProbeError: string | null;
|
|
31
|
-
}) => void;
|
|
32
|
-
resolveServiceLogPath: () => string;
|
|
33
|
-
}): {
|
|
34
|
-
child: ReturnType<typeof spawn>;
|
|
35
|
-
logPath: string;
|
|
36
|
-
readinessTimeoutMs: number;
|
|
37
|
-
quickPhaseTimeoutMs: number;
|
|
38
|
-
extendedPhaseTimeoutMs: number;
|
|
39
|
-
snapshot: ManagedServiceSnapshot;
|
|
40
|
-
} | null;
|
|
41
11
|
declare function waitForManagedServiceReadiness(params: {
|
|
42
12
|
appName: string;
|
|
43
13
|
childPid: number;
|
|
@@ -85,6 +55,7 @@ declare class ManagedServiceCommandService {
|
|
|
85
55
|
private readonly loggingRuntime;
|
|
86
56
|
private readonly serviceLogger;
|
|
87
57
|
private readonly startupLogger;
|
|
58
|
+
private readonly supervisor;
|
|
88
59
|
constructor(deps: {
|
|
89
60
|
startGateway: (options: {
|
|
90
61
|
uiOverrides: Partial<Config$1["ui"]>;
|
|
@@ -120,4 +91,5 @@ declare class ManagedServiceCommandService {
|
|
|
120
91
|
private printStartupFailureDiagnostics;
|
|
121
92
|
}
|
|
122
93
|
//#endregion
|
|
123
|
-
export { ManagedServiceCommandService, StartServiceOptions, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate,
|
|
94
|
+
export { ManagedServiceCommandService, StartServiceOptions, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate, waitForManagedServiceReadiness };
|
|
95
|
+
//# sourceMappingURL=service-managed-startup.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-managed-startup.service.d.ts","names":[],"sources":["../../../../src/shared/services/runtime/service-managed-startup.service.ts"],"mappings":";;;;KAqBK,QAAA,GAAS,YAAA,CAAa,MAAA;AAAA,KAEf,mBAAA;EACV,WAAA,EAAa,OAAA,CAAQ,QAAA;EACrB,IAAA;EACA,gBAAA;AAAA;AAAA,iBAKoB,8BAAA,CAA+B,MAAA;EACnD,OAAA;EACA,QAAA;EACA,SAAA;EACA,OAAA;EACA,kBAAA;EACA,mBAAA;EACA,sBAAA;EACA,kBAAA,GAAqB,OAAA,UAAiB,OAAA;EACtC,6BAAA,GAAgC,MAAA;IAC9B,GAAA;IACA,SAAA;IACA,SAAA;EAAA,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awCommandEnv } from "../../utils/top-level-nextclaw-command-env.utils.js";
|
|
2
|
-
import { resolveCliSubcommandLaunch } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
|
|
3
1
|
import { isProcessRunning, openBrowser, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, waitForExit } from "../../utils/cli.utils.js";
|
|
4
2
|
import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
|
|
5
3
|
import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
|
|
6
|
-
import {
|
|
4
|
+
import { ManagedServiceSupervisor } from "./managed-service-supervisor.service.js";
|
|
7
5
|
import { resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate } from "./utils/managed-service-routing.utils.js";
|
|
8
6
|
import { probeHealthEndpoint } from "../../utils/service-port-probe.utils.js";
|
|
9
7
|
import * as NextclawCore from "@nextclaw/core";
|
|
10
|
-
import { FileLogSink } from "@nextclaw/core";
|
|
11
|
-
import { mkdirSync } from "node:fs";
|
|
12
|
-
import { spawn } from "node:child_process";
|
|
13
|
-
import { dirname } from "node:path";
|
|
14
8
|
//#region src/shared/services/runtime/service-managed-startup.service.ts
|
|
15
9
|
const { APP_NAME: APP_NAME$1, loadConfig: loadConfig$1 } = NextclawCore;
|
|
16
|
-
const serviceStartupLogger = NextclawCore.getAppLogger("service.startup");
|
|
17
|
-
function spawnManagedService(params) {
|
|
18
|
-
const { appName, config, uiConfig, uiUrl, apiUrl, healthUrl, startupTimeoutMs, resolveStartupTimeoutMs, appendStartupStage, printStartupFailureDiagnostics, resolveServiceLogPath } = params;
|
|
19
|
-
const logPath = resolveServiceLogPath();
|
|
20
|
-
new FileLogSink({ serviceLogPath: logPath }).ensureReady();
|
|
21
|
-
mkdirSync(dirname(logPath), { recursive: true });
|
|
22
|
-
const readinessTimeoutMs = resolveStartupTimeoutMs(startupTimeoutMs);
|
|
23
|
-
const quickPhaseTimeoutMs = Math.min(8e3, readinessTimeoutMs);
|
|
24
|
-
const extendedPhaseTimeoutMs = Math.max(0, readinessTimeoutMs - quickPhaseTimeoutMs);
|
|
25
|
-
appendStartupStage(logPath, `start requested: ui=${uiConfig.host}:${uiConfig.port}, readinessTimeoutMs=${readinessTimeoutMs}`);
|
|
26
|
-
console.log(`Starting ${appName} background service (readiness timeout ${Math.ceil(readinessTimeoutMs / 1e3)}s)...`);
|
|
27
|
-
const cliLaunch = resolveCliSubcommandLaunch({
|
|
28
|
-
argvEntry: process.argv[1],
|
|
29
|
-
importMetaUrl: import.meta.url,
|
|
30
|
-
cliArgs: [
|
|
31
|
-
"serve",
|
|
32
|
-
"--ui-port",
|
|
33
|
-
String(uiConfig.port)
|
|
34
|
-
],
|
|
35
|
-
nodePath: process.execPath
|
|
36
|
-
});
|
|
37
|
-
const childArgs = [...process.execArgv, ...cliLaunch.args];
|
|
38
|
-
appendStartupStage(logPath, `spawning background process: ${cliLaunch.command} ${childArgs.join(" ")}`);
|
|
39
|
-
const child = spawn(cliLaunch.command, childArgs, {
|
|
40
|
-
env: createTopLevelNextclawCommandEnv(process.env),
|
|
41
|
-
stdio: "ignore",
|
|
42
|
-
detached: true,
|
|
43
|
-
windowsHide: true
|
|
44
|
-
});
|
|
45
|
-
appendStartupStage(logPath, `spawned background process pid=${child.pid ?? "unknown"}`);
|
|
46
|
-
if (!child.pid) {
|
|
47
|
-
appendStartupStage(logPath, "spawn failed: child pid missing");
|
|
48
|
-
console.error("Error: Failed to start background service.");
|
|
49
|
-
printStartupFailureDiagnostics({
|
|
50
|
-
uiUrl,
|
|
51
|
-
apiUrl,
|
|
52
|
-
healthUrl,
|
|
53
|
-
logPath,
|
|
54
|
-
lastProbeError: null
|
|
55
|
-
});
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const snapshot = {
|
|
59
|
-
pid: child.pid,
|
|
60
|
-
uiUrl,
|
|
61
|
-
apiUrl,
|
|
62
|
-
uiHost: uiConfig.host,
|
|
63
|
-
uiPort: uiConfig.port,
|
|
64
|
-
logPath
|
|
65
|
-
};
|
|
66
|
-
writeInitialManagedServiceState({
|
|
67
|
-
config,
|
|
68
|
-
readinessTimeoutMs,
|
|
69
|
-
snapshot
|
|
70
|
-
});
|
|
71
|
-
serviceStartupLogger.info("runtime.process.started", {
|
|
72
|
-
runtimeKind: "managed-service",
|
|
73
|
-
childPid: child.pid,
|
|
74
|
-
uiUrl,
|
|
75
|
-
apiUrl,
|
|
76
|
-
uiHost: uiConfig.host,
|
|
77
|
-
uiPort: uiConfig.port,
|
|
78
|
-
entrypoint: `${cliLaunch.command} ${childArgs.join(" ")}`
|
|
79
|
-
});
|
|
80
|
-
serviceStartupLogger.info("service_state.written", {
|
|
81
|
-
runtimeKind: "managed-service",
|
|
82
|
-
childPid: child.pid,
|
|
83
|
-
statePath: managedServiceStateStore.path,
|
|
84
|
-
uiUrl,
|
|
85
|
-
apiUrl
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
child,
|
|
89
|
-
logPath,
|
|
90
|
-
readinessTimeoutMs,
|
|
91
|
-
quickPhaseTimeoutMs,
|
|
92
|
-
extendedPhaseTimeoutMs,
|
|
93
|
-
snapshot
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
10
|
async function waitForManagedServiceReadiness(params) {
|
|
97
11
|
params.appendStartupStage(params.logPath, `health probe started: ${params.healthUrl} (phase=quick, timeoutMs=${params.quickPhaseTimeoutMs})`);
|
|
98
12
|
let readiness = await params.waitForBackgroundServiceReady({
|
|
@@ -128,6 +42,7 @@ var ManagedServiceCommandService = class {
|
|
|
128
42
|
loggingRuntime = NextclawCore.getLoggingRuntime();
|
|
129
43
|
serviceLogger = this.loggingRuntime.getLogger("service");
|
|
130
44
|
startupLogger = this.serviceLogger.child("startup");
|
|
45
|
+
supervisor = new ManagedServiceSupervisor();
|
|
131
46
|
constructor(deps) {
|
|
132
47
|
this.deps = deps;
|
|
133
48
|
}
|
|
@@ -149,7 +64,8 @@ var ManagedServiceCommandService = class {
|
|
|
149
64
|
const apiUrl = `${uiUrl}/api`;
|
|
150
65
|
const staticDir = this.deps.resolveUiStaticDir();
|
|
151
66
|
const existing = managedServiceStateStore.read();
|
|
152
|
-
|
|
67
|
+
const existingLiveness = this.supervisor.resolveStateLiveness(existing);
|
|
68
|
+
if (existing && existingLiveness.running) {
|
|
153
69
|
await this.handleExistingManagedService({
|
|
154
70
|
existing,
|
|
155
71
|
uiConfig,
|
|
@@ -157,7 +73,7 @@ var ManagedServiceCommandService = class {
|
|
|
157
73
|
});
|
|
158
74
|
return;
|
|
159
75
|
}
|
|
160
|
-
if (existing) managedServiceStateStore.clear();
|
|
76
|
+
if (existing && !existingLiveness.processExists) managedServiceStateStore.clear();
|
|
161
77
|
if (!staticDir) {
|
|
162
78
|
process.exitCode = 1, console.error(`Error: ${APP_NAME$1} UI frontend bundle not found. Reinstall or rebuild ${APP_NAME$1}. For dev-only overrides, set NEXTCLAW_UI_STATIC_DIR to a built frontend directory.`);
|
|
163
79
|
return;
|
|
@@ -282,7 +198,7 @@ var ManagedServiceCommandService = class {
|
|
|
282
198
|
};
|
|
283
199
|
startNewManagedServiceTarget = async (params) => {
|
|
284
200
|
const { apiUrl, config, healthUrl, startupTimeoutMs, uiConfig, uiUrl } = params;
|
|
285
|
-
const startup = spawnManagedService({
|
|
201
|
+
const startup = this.supervisor.spawnManagedService({
|
|
286
202
|
appName: APP_NAME$1,
|
|
287
203
|
config,
|
|
288
204
|
uiConfig,
|
|
@@ -336,7 +252,7 @@ var ManagedServiceCommandService = class {
|
|
|
336
252
|
}
|
|
337
253
|
startup.child.unref();
|
|
338
254
|
const readySnapshot = resolveManagedServiceReadySnapshot({ snapshot: startup.snapshot });
|
|
339
|
-
const state =
|
|
255
|
+
const state = this.supervisor.writeReadyState({
|
|
340
256
|
readinessTimeoutMs: startup.readinessTimeoutMs,
|
|
341
257
|
readiness,
|
|
342
258
|
snapshot: readySnapshot
|
|
@@ -420,4 +336,6 @@ var ManagedServiceCommandService = class {
|
|
|
420
336
|
};
|
|
421
337
|
};
|
|
422
338
|
//#endregion
|
|
423
|
-
export { ManagedServiceCommandService, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate,
|
|
339
|
+
export { ManagedServiceCommandService, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate, waitForManagedServiceReadiness };
|
|
340
|
+
|
|
341
|
+
//# sourceMappingURL=service-managed-startup.service.js.map
|