@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 @@
|
|
|
1
|
+
{"version":3,"file":"npm-runtime-update.manager.js","names":[],"sources":["../../src/launcher/npm-runtime-update.manager.ts"],"sourcesContent":["import type { UpdateManifest, UpdateProgress, UpdateSnapshot } from \"@nextclaw/kernel\";\nimport { getPackageVersion } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nimport { resolveEffectiveNpmRuntimeVersion } from \"./npm-runtime-bundle.service.js\";\nimport type { NpmRuntimeBundleService } from \"./npm-runtime-bundle.service.js\";\nimport type { NpmRuntimeBundleLayoutStore } from \"./npm-runtime-bundle-layout.store.js\";\nimport type { NpmRuntimeUpdateService, NpmRuntimeAvailableUpdate } from \"./npm-runtime-update.service.js\";\nimport type { NpmRuntimeUpdateStateStore } from \"./npm-runtime-update-state.store.js\";\nimport type { NpmRuntimeReleaseChannel } from \"./npm-runtime-update-source.service.js\";\nimport type { NpmRuntimeUpdateState } from \"./npm-runtime-bundle.types.js\";\n\ntype NpmRuntimeUpdateManagerOptions = {\n layout: NpmRuntimeBundleLayoutStore;\n stateStore: NpmRuntimeUpdateStateStore;\n bundleService: NpmRuntimeBundleService;\n updateService: NpmRuntimeUpdateService;\n resolveManifestUrl: (channel: NpmRuntimeReleaseChannel) => string | null;\n launcherVersion?: string;\n channel: NpmRuntimeReleaseChannel;\n now?: () => Date;\n};\n\ntype NpmRuntimeUpdateActionOptions = {\n apply?: boolean;\n applyAfterDownload?: boolean;\n checkOnly?: boolean;\n onProgress?: (progress: UpdateProgress) => void;\n};\n\nexport class NpmRuntimeUpdateManager {\n private readonly launcherVersion: string;\n private readonly now: () => Date;\n private availableManifest: UpdateManifest | null = null;\n\n constructor(private readonly options: NpmRuntimeUpdateManagerOptions) {\n this.launcherVersion = options.launcherVersion ?? getPackageVersion();\n this.now = options.now ?? (() => new Date());\n this.options.layout.ensureLauncherDirs();\n this.syncStateFromCurrentPointer();\n }\n\n getSnapshot = (): UpdateSnapshot => this.toSnapshotFromState(this.options.stateStore.read(), {\n status: this.options.stateStore.read().downloadedVersion ? \"downloaded\" : \"idle\"\n });\n\n run = async (options: NpmRuntimeUpdateActionOptions = {}): Promise<UpdateSnapshot> => {\n if (options.apply) {\n return this.applyDownloadedUpdate();\n }\n\n const applyAfterDownload = options.applyAfterDownload ?? true;\n const checkedSnapshot = await this.checkForUpdate();\n if (options.checkOnly) {\n return checkedSnapshot;\n }\n if (applyAfterDownload && checkedSnapshot.status === \"downloaded\") {\n return this.applyDownloadedUpdate();\n }\n if (checkedSnapshot.status !== \"update-available\") {\n return checkedSnapshot;\n }\n const downloadedSnapshot = await this.downloadUpdate(options.onProgress);\n if (!applyAfterDownload || downloadedSnapshot.status !== \"downloaded\") {\n return downloadedSnapshot;\n }\n return this.applyDownloadedUpdate();\n };\n\n checkForUpdate = async (): Promise<UpdateSnapshot> => {\n const manifestUrl = this.options.resolveManifestUrl(this.options.channel);\n if (!this.options.updateService.hasSignatureVerifier()) {\n return this.toSnapshotFromState(this.options.stateStore.read(), {\n status: \"blocked\",\n installationKind: \"npm-runtime-bundle\",\n blockReason: \"signature-verification-unavailable\",\n recoveryCommand: \"Set NEXTCLAW_UPDATE_BUNDLE_PUBLIC_KEY or NEXTCLAW_UPDATE_BUNDLE_PUBLIC_KEY_PATH\",\n errorMessage: \"Runtime bundle updates require a configured update public key.\"\n });\n }\n if (!manifestUrl) {\n return this.toSnapshotFromState(this.options.stateStore.read(), {\n status: \"blocked\",\n installationKind: \"npm-runtime-bundle\",\n blockReason: \"unsupported-installation\",\n recoveryCommand: \"Set NEXTCLAW_UPDATE_MANIFEST_URL or NEXTCLAW_UPDATE_MANIFEST_BASE_URL\",\n errorMessage: \"Runtime bundle update manifest URL is not configured.\"\n });\n }\n\n const checkedAt = this.now().toISOString();\n const state = this.options.stateStore.update((current) => ({\n ...current,\n channel: this.options.channel,\n lastUpdateCheckAt: checkedAt\n }));\n const availableUpdate = await this.options.updateService.checkForUpdate(manifestUrl, state.currentVersion, state.badVersions);\n return this.toSnapshotAfterCheck(availableUpdate, this.options.stateStore.read());\n };\n\n downloadUpdate = async (onProgress?: (progress: UpdateProgress) => void): Promise<UpdateSnapshot> => {\n const manifest = this.availableManifest ?? await this.ensureAvailableManifest();\n const downloaded = await this.options.updateService.downloadAndInstallUpdate(manifest, onProgress);\n const state = this.options.stateStore.update((current) => ({\n ...current,\n downloadedVersion: downloaded.downloadedVersion,\n downloadedReleaseNotesUrl: downloaded.manifest.releaseNotesUrl\n }));\n await this.options.bundleService.pruneRetainedArtifacts();\n return this.toSnapshotFromState(state, {\n status: \"downloaded\",\n availableVersion: downloaded.downloadedVersion,\n downloadedVersion: downloaded.downloadedVersion,\n minimumHostVersion: downloaded.manifest.minimumLauncherVersion,\n releaseNotesUrl: downloaded.manifest.releaseNotesUrl,\n canApplyInApp: true,\n requiresRestart: false\n });\n };\n\n applyDownloadedUpdate = (): UpdateSnapshot => {\n const downloadedVersion = this.options.stateStore.read().downloadedVersion?.trim();\n if (!downloadedVersion) {\n throw new Error(\"No downloaded npm runtime update is ready to apply.\");\n }\n this.options.bundleService.activateVersion(downloadedVersion);\n this.availableManifest = null;\n return this.toSnapshotFromState(this.options.stateStore.read(), {\n status: \"restart-required\",\n availableVersion: null,\n downloadedVersion: null,\n releaseNotesUrl: null,\n canApplyInApp: false,\n requiresRestart: true\n });\n };\n\n private ensureAvailableManifest = async (): Promise<UpdateManifest> => {\n const snapshot = await this.checkForUpdate();\n if (!this.availableManifest) {\n if (snapshot.downloadedVersion) {\n throw new Error(`Version ${snapshot.downloadedVersion} has already been downloaded and is ready to apply.`);\n }\n throw new Error(\"No npm runtime update is currently available.\");\n }\n return this.availableManifest;\n };\n\n private toSnapshotAfterCheck = (\n availableUpdate: NpmRuntimeAvailableUpdate | null,\n state: NpmRuntimeUpdateState\n ): UpdateSnapshot => {\n if (state.downloadedVersion) {\n this.availableManifest = availableUpdate?.kind === \"runtime-bundle-update\" ? availableUpdate.manifest : this.availableManifest;\n return this.toSnapshotFromState(state, {\n status: \"downloaded\",\n availableVersion: availableUpdate?.kind === \"runtime-bundle-update\" ? availableUpdate.manifest.latestVersion : state.downloadedVersion,\n minimumHostVersion: availableUpdate?.kind === \"runtime-bundle-update\" ? availableUpdate.manifest.minimumLauncherVersion : null,\n canApplyInApp: true,\n requiresRestart: false\n });\n }\n if (!availableUpdate) {\n this.availableManifest = null;\n return this.toSnapshotFromState(state, {\n status: \"up-to-date\",\n availableVersion: null,\n downloadedVersion: null,\n releaseNotesUrl: null\n });\n }\n if (availableUpdate.kind === \"host-update-required\") {\n this.availableManifest = null;\n return this.toSnapshotFromState(state, {\n status: \"blocked\",\n availableVersion: availableUpdate.manifest.latestVersion,\n minimumHostVersion: availableUpdate.manifest.minimumLauncherVersion,\n releaseNotesUrl: availableUpdate.manifest.releaseNotesUrl,\n blockReason: \"host-too-old\",\n recoveryCommand: \"npm install -g nextclaw@latest\",\n errorMessage: `NextClaw npm launcher ${this.launcherVersion} is too old for runtime bundle ${availableUpdate.manifest.latestVersion}.`\n });\n }\n if (availableUpdate.kind === \"quarantined-bad-version\") {\n this.availableManifest = null;\n return this.toSnapshotFromState(state, {\n status: \"failed\",\n availableVersion: availableUpdate.manifest.latestVersion,\n minimumHostVersion: availableUpdate.manifest.minimumLauncherVersion,\n releaseNotesUrl: availableUpdate.manifest.releaseNotesUrl,\n errorMessage: `Version ${availableUpdate.manifest.latestVersion} was quarantined after a failed launch.`\n });\n }\n this.availableManifest = availableUpdate.manifest;\n return this.toSnapshotFromState(state, {\n status: \"update-available\",\n availableVersion: availableUpdate.manifest.latestVersion,\n minimumHostVersion: availableUpdate.manifest.minimumLauncherVersion,\n releaseNotesUrl: availableUpdate.manifest.releaseNotesUrl\n });\n };\n\n private syncStateFromCurrentPointer = (): void => {\n const currentPointer = this.options.layout.readCurrentPointer();\n const effectiveCurrentVersion = resolveEffectiveNpmRuntimeVersion({\n launcherVersion: this.launcherVersion,\n currentBundleVersion: currentPointer?.version ?? null\n });\n if (!effectiveCurrentVersion) {\n return;\n }\n this.options.stateStore.update((state) => ({\n ...state,\n currentVersion: effectiveCurrentVersion\n }));\n };\n\n private toSnapshotFromState = (\n state: NpmRuntimeUpdateState,\n patch: Partial<UpdateSnapshot> & Pick<UpdateSnapshot, \"status\">\n ): UpdateSnapshot => {\n const hasDownloadedVersion = Boolean(state.downloadedVersion);\n const { status } = patch;\n return {\n installationKind: \"npm-runtime-bundle\",\n channel: state.channel,\n hostVersion: this.launcherVersion,\n currentVersion: state.currentVersion,\n availableVersion: null,\n downloadedVersion: state.downloadedVersion,\n minimumHostVersion: null,\n releaseNotesUrl: state.downloadedReleaseNotesUrl,\n lastCheckedAt: state.lastUpdateCheckAt,\n progress: null,\n canAutoDownload: state.updatePreferences.autoDownload,\n canApplyInApp: hasDownloadedVersion,\n requiresRestart: false,\n blockReason: null,\n recoveryCommand: null,\n errorMessage: null,\n preferences: { ...state.updatePreferences },\n ...patch,\n status\n };\n };\n}\n"],"mappings":";;;;AA4BA,IAAa,0BAAb,MAAqC;CACnC;CACA;CACA,oBAAmD;CAEnD,YAAY,SAA0D;AAAzC,OAAA,UAAA;AAC3B,OAAK,kBAAkB,QAAQ,mBAAmB,mBAAmB;AACrE,OAAK,MAAM,QAAQ,8BAAc,IAAI,MAAM;AAC3C,OAAK,QAAQ,OAAO,oBAAoB;AACxC,OAAK,6BAA6B;;CAGpC,oBAAoC,KAAK,oBAAoB,KAAK,QAAQ,WAAW,MAAM,EAAE,EAC3F,QAAQ,KAAK,QAAQ,WAAW,MAAM,CAAC,oBAAoB,eAAe,QAC3E,CAAC;CAEF,MAAM,OAAO,UAAyC,EAAE,KAA8B;AACpF,MAAI,QAAQ,MACV,QAAO,KAAK,uBAAuB;EAGrC,MAAM,qBAAqB,QAAQ,sBAAsB;EACzD,MAAM,kBAAkB,MAAM,KAAK,gBAAgB;AACnD,MAAI,QAAQ,UACV,QAAO;AAET,MAAI,sBAAsB,gBAAgB,WAAW,aACnD,QAAO,KAAK,uBAAuB;AAErC,MAAI,gBAAgB,WAAW,mBAC7B,QAAO;EAET,MAAM,qBAAqB,MAAM,KAAK,eAAe,QAAQ,WAAW;AACxE,MAAI,CAAC,sBAAsB,mBAAmB,WAAW,aACvD,QAAO;AAET,SAAO,KAAK,uBAAuB;;CAGrC,iBAAiB,YAAqC;EACpD,MAAM,cAAc,KAAK,QAAQ,mBAAmB,KAAK,QAAQ,QAAQ;AACzE,MAAI,CAAC,KAAK,QAAQ,cAAc,sBAAsB,CACpD,QAAO,KAAK,oBAAoB,KAAK,QAAQ,WAAW,MAAM,EAAE;GAC9D,QAAQ;GACR,kBAAkB;GAClB,aAAa;GACb,iBAAiB;GACjB,cAAc;GACf,CAAC;A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,gBAAgB,SAAS;IAC1C,cAAc,WAAW,gBAAgB,SAAS,cAAc;IACjE,CAAC;;AAEJ,OAAK,oBAAoB,gBAAgB;AACzC,SAAO,KAAK,oBAAoB,OAAO;GACrC,QAAQ;GACR,kBAAkB,gBAAgB,SAAS;GAC3C,oBAAoB,gBAAgB,SAAS;GAC7C,iBAAiB,gBAAgB,SAAS;GAC3C,CAAC;;CAGJ,oCAAkD;EAChD,MAAM,iBAAiB,KAAK,QAAQ,OAAO,oBAAoB;EAC/D,MAAM,0BAA0B,kCAAkC;GAChE,iBAAiB,KAAK;GACtB,sBAAsB,gBAAgB,WAAW;GAClD,CAAC;AACF,MAAI,CAAC,wBACH;AAEF,OAAK,QAAQ,WAAW,QAAQ,WAAW;GACzC,GAAG;GACH,gBAAgB;GACjB,EAAE;;CAGL,uBACE,OACA,UACmB;EACnB,MAAM,uBAAuB,QAAQ,MAAM,kBAAkB;EAC7D,MAAM,EAAE,WAAW;AACnB,SAAO;GACL,kBAAkB;GAClB,SAAS,MAAM;GACf,aAAa,KAAK;GAClB,gBAAgB,MAAM;GACtB,kBAAkB;GAClB,mBAAmB,MAAM;GACzB,oBAAoB;GACpB,iBAAiB,MAAM;GACvB,eAAe,MAAM;GACrB,UAAU;GACV,iBAAiB,MAAM,kBAAkB;GACzC,eAAe;GACf,iBAAiB;GACjB,aAAa;GACb,iBAAiB;GACjB,cAAc;GACd,aAAa,EAAE,GAAG,MAAM,mBAAmB;GAC3C,GAAG;GACH;GACD"}
|
|
@@ -51,4 +51,5 @@ declare class NpmRuntimeUpdateService {
|
|
|
51
51
|
private assertBundleSignature;
|
|
52
52
|
}
|
|
53
53
|
//#endregion
|
|
54
|
-
export { NpmRuntimeAvailableUpdate, NpmRuntimeUpdateService };
|
|
54
|
+
export { NpmRuntimeAvailableUpdate, NpmRuntimeUpdateService };
|
|
55
|
+
//# sourceMappingURL=npm-runtime-update.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-runtime-update.service.d.ts","names":[],"sources":["../../src/launcher/npm-runtime-update.service.ts"],"mappings":";;;;;;KAkBK,SAAA,UAAmB,KAAA;AAAA,KAEnB,8BAAA;EACH,MAAA,EAAQ,2BAAA;EACR,aAAA,EAAe,uBAAA;EACf,eAAA;EACA,eAAA;EACA,SAAA,GAAY,SAAA;EACZ,QAAA,GAAW,MAAA,CAAO,QAAA;EAClB,IAAA;EACA,cAAA,GAAiB,oBAAA;EACjB,GAAA;AAAA;AAAA,KAGU,yBAAA;EACN,IAAA;EAA+B,QAAA,EAAU,cAAA;AAAA;EACzC,IAAA;EAA8B,QAAA,EAAU,cAAA;AAAA;EACxC,IAAA;EAAiC,QAAA,EAAU,cAAA;AAAA;AAAA,cAEpC,uBAAA;EAAA,iBAQkB,OAAA;EAAA,iBAPZ,QAAA;EAAA,iBACA,IAAA;EAAA,iBACA,SAAA;EAAA,iBACA,cAAA;EAAA,iBACA,eAAA;EAAA,iBACA,GAAA;cAEY,OAAA,EAAS,8BAAA;EAStC,oBAAA;EAEA,cAAA,GAAwB,WAAA,UAAqB,cAAA,iBAA+B,WAAA,gBAA6B,OAAA,CAAQ,yBAAA;EAcjH,wBAAA,GACE,QAAA,EAAU,cAAA,EACV,cAAA,GAAiB,gCAAA,KAChB,OAAA,CAAQ,0BAAA;EAAA,QAmCH,mBAAA;EAAA,QAcA,aAAA;EAAA,QAaA,cAAA;EAAA,QAiBA,WAAA;EAAA,QAiBA,iBAAA;EAAA,QA0BA,iBAAA;EAAA,QASA,sBAAA;EAAA,QAYA,cAAA;EAAA,QAYA,oBAAA;EAAA,QAgBA,uBAAA;EAAA,QAWA,qBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-runtime-update.service.js","names":[],"sources":["../../src/launcher/npm-runtime-update.service.ts"],"sourcesContent":["import { createHash, createPublicKey, verify, type KeyObject } from \"node:crypto\";\nimport { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\nimport { dirname, join, resolve, sep } from \"node:path\";\nimport JSZip from \"jszip\";\nimport {\n serializeUnsignedUpdateManifest,\n UpdateManifestReader,\n type UpdateManifest\n} from \"@nextclaw/kernel\";\nimport type { NpmRuntimeBundleLayoutStore } from \"./npm-runtime-bundle-layout.store.js\";\nimport { compareNpmRuntimeVersions, type NpmRuntimeBundleService } from \"./npm-runtime-bundle.service.js\";\nimport type {\n NpmRuntimeDownloadedUpdate,\n NpmRuntimeUpdateProgressReporter\n} from \"./npm-runtime-bundle.types.js\";\n\ntype FetchLike = typeof fetch;\n\ntype NpmRuntimeUpdateServiceOptions = {\n layout: NpmRuntimeBundleLayoutStore;\n bundleService: NpmRuntimeBundleService;\n launcherVersion: string;\n bundlePublicKey?: string;\n fetchImpl?: FetchLike;\n platform?: NodeJS.Platform;\n arch?: string;\n manifestReader?: UpdateManifestReader;\n now?: () => number;\n};\n\nexport type NpmRuntimeAvailableUpdate =\n | { kind: \"runtime-bundle-update\"; manifest: UpdateManifest }\n | { kind: \"host-update-required\"; manifest: UpdateManifest }\n | { kind: \"quarantined-bad-version\"; manifest: UpdateManifest };\n\nexport class NpmRuntimeUpdateService {\n private readonly platform: NodeJS.Platform;\n private readonly arch: string;\n private readonly fetchImpl: FetchLike;\n private readonly manifestReader: UpdateManifestReader;\n private readonly bundlePublicKey: KeyObject | null;\n private readonly now: () => number;\n\n constructor(private readonly options: NpmRuntimeUpdateServiceOptions) {\n this.platform = options.platform ?? process.platform;\n this.arch = options.arch ?? process.arch;\n this.fetchImpl = options.fetchImpl ?? fetch;\n this.manifestReader = options.manifestReader ?? new UpdateManifestReader();\n this.bundlePublicKey = this.parseBundlePublicKey(options.bundlePublicKey);\n this.now = options.now ?? Date.now;\n }\n\n hasSignatureVerifier = (): boolean => Boolean(this.bundlePublicKey);\n\n checkForUpdate = async (manifestUrl: string, currentVersion: string | null, badVersions: string[] = []): Promise<NpmRuntimeAvailableUpdate | null> => {\n const manifest = await this.fetchManifest(manifestUrl);\n if (currentVersion && compareNpmRuntimeVersions(manifest.latestVersion, currentVersion) <= 0) {\n return null;\n }\n if (compareNpmRuntimeVersions(this.options.launcherVersion, manifest.minimumLauncherVersion) < 0) {\n return { kind: \"host-update-required\", manifest };\n }\n if (badVersions.includes(manifest.latestVersion)) {\n return { kind: \"quarantined-bad-version\", manifest };\n }\n return { kind: \"runtime-bundle-update\", manifest };\n };\n\n downloadAndInstallUpdate = async (\n manifest: UpdateManifest,\n reportProgress?: NpmRuntimeUpdateProgressReporter\n ): Promise<NpmRuntimeDownloadedUpdate> => {\n const bytes = await this.downloadBundleBytes(manifest, reportProgress);\n const stagingRoot = join(this.options.layout.getStagingDir(), `download-${manifest.latestVersion}-${this.now()}`);\n await rm(stagingRoot, { recursive: true, force: true });\n mkdirSync(stagingRoot, { recursive: true });\n\n try {\n const zip = await JSZip.loadAsync(bytes);\n const entries = Object.values(zip.files) as JSZip.JSZipObject[];\n await Promise.all(entries.map(async (entry) => {\n const targetPath = resolve(stagingRoot, entry.name);\n const resolvedStagingRoot = resolve(stagingRoot);\n if (targetPath !== resolvedStagingRoot && !targetPath.startsWith(`${resolvedStagingRoot}${sep}`)) {\n throw new Error(`runtime bundle archive contains invalid path: ${entry.name}`);\n }\n if (entry.dir) {\n mkdirSync(targetPath, { recursive: true });\n return;\n }\n mkdirSync(dirname(targetPath), { recursive: true });\n writeFileSync(targetPath, Buffer.from(await entry.async(\"uint8array\")));\n }));\n const bundleRoot = this.findBundleRoot(stagingRoot);\n const installedBundle = await this.options.bundleService.installFromDirectory(bundleRoot);\n return {\n manifest,\n downloadedVersion: installedBundle.manifest.bundleVersion,\n bundleDirectory: installedBundle.bundleDirectory\n };\n } catch (error) {\n await rm(stagingRoot, { recursive: true, force: true });\n throw error;\n }\n };\n\n private downloadBundleBytes = async (\n manifest: UpdateManifest,\n reportProgress?: NpmRuntimeUpdateProgressReporter\n ): Promise<Buffer> => {\n const response = await this.fetchBundle(manifest.bundleUrl);\n const bytes = await this.readResponseBytes(response, reportProgress);\n const sha256 = createHash(\"sha256\").update(bytes).digest(\"hex\");\n if (sha256 !== manifest.bundleSha256) {\n throw new Error(`runtime bundle sha256 mismatch: expected ${manifest.bundleSha256} but got ${sha256}`);\n }\n this.assertBundleSignature(manifest, bytes);\n return bytes;\n };\n\n private fetchManifest = async (manifestUrl: string): Promise<UpdateManifest> => {\n if (manifestUrl.startsWith(\"file://\")) {\n const manifest = this.manifestReader.parse(JSON.parse(readFileSync(fileURLToPath(manifestUrl), \"utf8\")), manifestUrl);\n return this.verifyManifest(manifest, manifestUrl);\n }\n const response = await this.fetchImpl(manifestUrl);\n if (!response.ok) {\n throw new Error(`runtime update manifest request failed with status ${response.status}`);\n }\n const manifest = this.manifestReader.parse(await response.json(), manifestUrl);\n return this.verifyManifest(manifest, manifestUrl);\n };\n\n private verifyManifest = (manifest: UpdateManifest, _manifestUrl: string): UpdateManifest => {\n if (manifest.hostKind && manifest.hostKind !== \"npm-runtime-bundle\") {\n throw new Error(`runtime update manifest hostKind mismatch: expected npm-runtime-bundle but got ${manifest.hostKind}`);\n }\n if (manifest.channel !== \"stable\" && manifest.channel !== \"beta\") {\n throw new Error(`runtime update manifest channel is unsupported: ${manifest.channel}`);\n }\n if (manifest.platform !== this.platform) {\n throw new Error(`runtime update manifest platform mismatch: expected ${this.platform} but got ${manifest.platform}`);\n }\n if (manifest.arch !== this.arch) {\n throw new Error(`runtime update manifest arch mismatch: expected ${this.arch} but got ${manifest.arch}`);\n }\n this.assertManifestSignature(manifest);\n return manifest;\n };\n\n private fetchBundle = async (bundleUrl: string): Promise<Response> => {\n if (bundleUrl.startsWith(\"file://\")) {\n const bytes = readFileSync(fileURLToPath(bundleUrl));\n return new Response(bytes, {\n status: 200,\n headers: {\n \"content-length\": String(bytes.byteLength)\n }\n });\n }\n const response = await this.fetchImpl(bundleUrl);\n if (!response.ok) {\n throw new Error(`runtime bundle download failed with status ${response.status}`);\n }\n return response;\n };\n\n private readResponseBytes = async (\n response: Response,\n reportProgress?: NpmRuntimeUpdateProgressReporter\n ): Promise<Buffer> => {\n const totalBytes = this.readContentLength(response);\n if (!response.body) {\n const bytes = Buffer.from(await response.arrayBuffer());\n this.reportDownloadProgress(reportProgress, bytes.byteLength, totalBytes ?? bytes.byteLength);\n return bytes;\n }\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let downloadedBytes = 0;\n this.reportDownloadProgress(reportProgress, downloadedBytes, totalBytes);\n while (true) {\n const next = await reader.read();\n if (next.done) {\n break;\n }\n chunks.push(next.value);\n downloadedBytes += next.value.byteLength;\n this.reportDownloadProgress(reportProgress, downloadedBytes, totalBytes);\n }\n return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));\n };\n\n private readContentLength = (response: Response): number | null => {\n const raw = response.headers.get(\"content-length\");\n if (!raw) {\n return null;\n }\n const parsed = Number(raw);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;\n };\n\n private reportDownloadProgress = (\n reportProgress: NpmRuntimeUpdateProgressReporter | undefined,\n downloadedBytes: number,\n totalBytes: number | null\n ): void => {\n reportProgress?.({\n downloadedBytes,\n totalBytes,\n percent: totalBytes && totalBytes > 0 ? Math.min(100, Math.round((downloadedBytes / totalBytes) * 100)) : null\n });\n };\n\n private findBundleRoot = (stagingRoot: string): string => {\n const directManifestPath = join(stagingRoot, \"manifest.json\");\n if (existsSync(directManifestPath)) {\n return stagingRoot;\n }\n const entries = readDirectoryNames(stagingRoot).filter((entry) => existsSync(join(stagingRoot, entry, \"manifest.json\")));\n if (entries.length === 1) {\n return join(stagingRoot, entries[0]);\n }\n throw new Error(`runtime bundle archive does not contain exactly one manifest root under ${stagingRoot}`);\n };\n\n private parseBundlePublicKey = (publicKey: string | undefined): KeyObject | null => {\n const normalizedKey = publicKey?.trim();\n if (!normalizedKey) {\n return null;\n }\n const pemOrEscapedPem = normalizedKey.replaceAll(\"\\\\n\", \"\\n\");\n if (pemOrEscapedPem.includes(\"BEGIN PUBLIC KEY\")) {\n return createPublicKey(pemOrEscapedPem);\n }\n return createPublicKey({\n key: Buffer.from(normalizedKey, \"base64\"),\n format: \"der\",\n type: \"spki\"\n });\n };\n\n private assertManifestSignature = (manifest: UpdateManifest): void => {\n if (!this.bundlePublicKey) {\n throw new Error(\"runtime update manifest signature verification requires bundlePublicKey\");\n }\n const signature = Buffer.from(manifest.manifestSignature, \"base64\");\n const valid = verify(null, Buffer.from(serializeUnsignedUpdateManifest(manifest)), this.bundlePublicKey, signature);\n if (!valid) {\n throw new Error(`runtime update manifest signature verification failed for ${manifest.latestVersion}`);\n }\n };\n\n private assertBundleSignature = (manifest: UpdateManifest, bytes: Buffer): void => {\n if (!this.bundlePublicKey) {\n throw new Error(\"runtime bundle signature verification requires bundlePublicKey\");\n }\n const signature = Buffer.from(manifest.bundleSignature, \"base64\");\n const valid = verify(null, bytes, this.bundlePublicKey, signature);\n if (!valid) {\n throw new Error(`runtime bundle signature verification failed for ${manifest.latestVersion}`);\n }\n };\n}\n\nfunction readDirectoryNames(directory: string): string[] {\n return readdirSync(directory, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAa,0BAAb,MAAqC;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0D;AAAzC,OAAA,UAAA;AAC3B,OAAK,WAAW,QAAQ,YAAY,QAAQ;AAC5C,OAAK,OAAO,QAAQ,QAAQ,QAAQ;AACpC,OAAK,YAAY,QAAQ,aAAa;AACtC,OAAK,iBAAiB,QAAQ,kBAAkB,IAAI,sBAAsB;AAC1E,OAAK,kBAAkB,KAAK,qBAAqB,QAAQ,gBAAgB;AACzE,OAAK,MAAM,QAAQ,OAAO,KAAK;;CAGjC,6BAAsC,QAAQ,KAAK,gBAAgB;CAEnE,iBAAiB,OAAO,aAAqB,gBAA+B,cAAwB,EAAE,KAAgD;EACpJ,MAAM,W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,gBAAgB;;;AAKnG,SAAS,mBAAmB,WAA6B;AACvD,QAAO,YAAY,WAAW,EAAE,eAAe,MAAM,CAAC,CACnD,QAAQ,UAAU,MAAM,aAAa,CAAC,CACtC,KAAK,UAAU,MAAM,KAAK"}
|
|
@@ -86,4 +86,5 @@ declare class NextclawServiceRuntime {
|
|
|
86
86
|
}
|
|
87
87
|
declare const runNextclawNpmRuntimeLauncher: (argv?: string[]) => void;
|
|
88
88
|
//#endregion
|
|
89
|
-
export { NextclawServiceCommands, NextclawServiceRuntime, NextclawServiceRuntimeAccount, NextclawServiceRuntimeOptions, runNextclawNpmRuntimeLauncher };
|
|
89
|
+
export { NextclawServiceCommands, NextclawServiceRuntime, NextclawServiceRuntimeAccount, NextclawServiceRuntimeOptions, runNextclawNpmRuntimeLauncher };
|
|
90
|
+
//# sourceMappingURL=service-runtime.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-runtime.service.d.ts","names":[],"sources":["../src/service-runtime.service.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KA8CY,6BAAA;EACV,IAAA;AAAA;AAAA,KAGU,6BAAA;EACV,MAAA,GAAS,IAAA;IAAS,OAAA;IAAkB,IAAA;EAAA,MAAqB,OAAA;EACzD,WAAA,GACE,QAAA,UACA,IAAA;IAAS,OAAA;IAAkB,IAAA;EAAA,MACxB,OAAA;AAAA;AAAA,KAGK,uBAAA;EACV,MAAA,EAAQ,oBAAA;EACR,MAAA,EAAQ,cAAA;EACR,OAAA,EAAS,eAAA;EACT,MAAA,EAAQ,cAAA;EACR,GAAA,EAAK,WAAA;EACL,OAAA,EAAS,eAAA;EACT,OAAA,EAAS,cAAA;EACT,MAAA,EAAQ,aAAA;EACR,QAAA,EAAU,eAAA;EACV,IAAA,EAAM,YAAA;EACN,WAAA,EAAa,mBAAA;EACb,IAAA,EAAM,YAAA;EACN,OAAA,EAAS,eAAA;EACT,EAAA,EAAI,UAAA;EACJ,KAAA,EAAO,aAAA;EACP,OAAA,EAAS,eAAA;EACT,KAAA,EAAO,aAAA;EACP,IAAA,EAAM,YAAA;EACN,KAAA,EAAO,sBAAA;AAAA;AAAA,cAGI,sBAAA;EAAA,QACH,IAAA;EAAA,QACA,kBAAA;EAAA,QACA,kBAAA;EAAA,QACA,iBAAA;EAAA,QACA,qBAAA;EAAA,QACA,gBAAA;EAAA,QACA,qBAAA;EAAA,QACA,oBAAA;EAAA,QACA,cAAA;EACR,OAAA,EAAS,6BAAA;EACT,QAAA,EAAU,uBAAA;cACE,OAAA,EAAS,6BAAA;EAAA,QAyCb,cAAA;EAAA,IA+DJ,OAAA,CAAA;EAAA,QAII,mBAAA;EAAA,QAOA,wBAAA;EAAA,QAuCA,yBAAA;EAAA,QA0GA,cAAA;EAAA,QAIA,mCAAA;EA0BR,OAAA,QAAoB,OAAA;EAOpB,IAAA,GAAc,OAAA;IAAW,MAAA;IAAiB,IAAA;IAAgB,KAAA;EAAA,MAAyB,OAAA;EA8CnF,KAAA,GAAe,IAAA,GAAM,mBAAA,KAA2B,OAAA;EAKhD,KAAA,GAAe,IAAA,EAAM,mBAAA,KAAsB,OAAA;EAoD3C,MAAA,GAAgB,IAAA,EAAM,oBAAA,KAAuB,OAAA;AAAA;AAAA,cAkBlC,6BAAA,GACX,IAAA"}
|
|
@@ -362,7 +362,10 @@ var NextclawServiceRuntime = class {
|
|
|
362
362
|
};
|
|
363
363
|
update = async (opts) => {
|
|
364
364
|
const versionBefore = this.version;
|
|
365
|
-
if (!opts.json)
|
|
365
|
+
if (!opts.json) {
|
|
366
|
+
const installationLabel = process.env.NEXTCLAW_DESKTOP_COMMAND_SURFACE === "1" ? "desktop runtime" : "npm launcher";
|
|
367
|
+
console.log(`Current ${installationLabel} version: ${versionBefore}`);
|
|
368
|
+
}
|
|
366
369
|
const snapshot = await new NpmRuntimeUpdateCommandService().run(opts);
|
|
367
370
|
if (snapshot.status === "blocked" || snapshot.status === "failed") process.exit(1);
|
|
368
371
|
const state = managedServiceStateStore.read();
|
|
@@ -379,3 +382,5 @@ const runNextclawNpmRuntimeLauncher = (argv = process.argv) => {
|
|
|
379
382
|
};
|
|
380
383
|
//#endregion
|
|
381
384
|
export { NextclawServiceRuntime, runNextclawNpmRuntimeLauncher };
|
|
385
|
+
|
|
386
|
+
//# sourceMappingURL=service-runtime.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-runtime.service.js","names":["toPluginConfigView"],"sources":["../src/service-runtime.service.ts"],"sourcesContent":["import { loadConfig, saveConfig, getConfigPath, getDataDir, resolveWorkspacePath, resolveConfigSecrets, APP_NAME } from \"@nextclaw/core\";\nimport { NextclawKernel } from \"@nextclaw/kernel\";\nimport { RemoteRuntimeActions } from \"@nextclaw/remote\";\nimport {\n setPluginRuntimeBridge,\n} from \"@nextclaw/openclaw-compat\";\nimport { existsSync, mkdirSync } from \"node:fs\";\nimport { spawn } from \"node:child_process\";\nimport { RestartCoordinator } from \"@nextclaw-service/shared/services/restart/restart-coordinator.service.js\";\nimport type { RestartStrategy } from \"@nextclaw-service/shared/services/restart/restart-coordinator.service.js\";\nimport { initializeConfigIfMissing } from \"@nextclaw-service/shared/services/runtime/runtime-config-init.service.js\";\nimport { writeRestartSentinel } from \"@nextclaw-service/shared/services/restart/restart-sentinel.service.js\";\nimport { createTopLevelNextclawCommandEnv } from \"@nextclaw-service/shared/utils/top-level-nextclaw-command-env.utils.js\";\nimport { resolveCliSubcommandLaunch } from \"@nextclaw-service/shared/utils/marketplace/cli-subcommand-launch.utils.js\";\nimport { logStartupTrace, measureStartupSync } from \"@nextclaw-service/shared/utils/startup-trace.js\";\nimport { isProcessRunning } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nimport { NpmRuntimeUpdateCommandService } from \"@nextclaw-service/launcher/npm-runtime-update-command.service.js\";\nimport { NpmRuntimeLauncher } from \"@nextclaw-service/launcher/npm-runtime-launcher.service.js\";\nimport { managedServiceStateStore } from \"@nextclaw-service/shared/stores/managed-service-state.store.js\";\nimport { mergePluginConfigView, toPluginConfigView, PluginCommands } from \"@nextclaw-service/commands/plugin/index.js\";\nimport { ConfigCommands } from \"@nextclaw-service/cli/commands/config/index.js\";\nimport { McpCommands } from \"@nextclaw-service/cli/commands/mcp/index.js\";\nimport { SecretsCommands } from \"@nextclaw-service/cli/commands/secrets/index.js\";\nimport { ChannelCommands } from \"@nextclaw-service/commands/channel/index.js\";\nimport { CronCommands } from \"@nextclaw-service/cli/commands/cron/index.js\";\nimport { AgentCommands, runCliAgentCommand } from \"@nextclaw-service/cli/commands/agent/index.js\";\nimport { PlatformAuthCommands } from \"@nextclaw-service/commands/platform-auth/index.js\";\nimport { RemoteCommands, hasRunningNextclawManagedService } from \"@nextclaw-service/commands/remote/index.js\";\nimport { DiagnosticsCommands } from \"@nextclaw-service/cli/commands/diagnostics/index.js\";\nimport { LogsCommands } from \"@nextclaw-service/cli/commands/logs/index.js\";\nimport { RuntimeCommandService } from \"@nextclaw-service/shared/services/runtime/runtime-command.service.js\";\nimport { NextclawDistributionService } from \"@nextclaw-service/shared/services/runtime/nextclaw-distribution.service.js\";\nimport { ServiceCommands } from \"@nextclaw-service/commands/service/index.js\";\nimport { WorkspaceManager } from \"@nextclaw-service/shared/services/workspace/workspace-manager.service.js\";\nimport { RuntimeRestartRequestService } from \"@nextclaw-service/shared/services/restart/runtime-restart-request.service.js\";\nimport { SkillsCommands } from \"@nextclaw-service/cli/commands/skills/index.js\";\nimport { GatewayCommands } from \"@nextclaw-service/cli/commands/gateway/index.js\";\nimport { UiCommands } from \"@nextclaw-service/cli/commands/ui/index.js\";\nimport { StartCommands } from \"@nextclaw-service/cli/commands/start/index.js\";\nimport { RestartCommands } from \"@nextclaw-service/cli/commands/restart/index.js\";\nimport { ServeCommands } from \"@nextclaw-service/cli/commands/serve/index.js\";\nimport { StopCommands } from \"@nextclaw-service/cli/commands/stop/index.js\";\nimport { LlmUsageCommandService } from \"@nextclaw-service/cli/commands/usage/index.js\";\nimport type { AgentCommandOptions, LoginCommandOptions, RequestRestartParams, UpdateCommandOptions } from \"@nextclaw-service/shared/types/cli.types.js\";\nconst FORCED_PUBLIC_UI_HOST = \"0.0.0.0\";\n\nexport type NextclawServiceRuntimeOptions = {\n logo?: string;\n};\n\nexport type NextclawServiceRuntimeAccount = {\n status: (opts?: { apiBase?: string; json?: boolean }) => Promise<void>;\n setUsername: (\n username: string,\n opts?: { apiBase?: string; json?: boolean },\n ) => Promise<void>;\n};\n\nexport type NextclawServiceCommands = {\n remote: RemoteRuntimeActions;\n skills: SkillsCommands;\n service: ServiceCommands;\n config: ConfigCommands;\n mcp: McpCommands;\n secrets: SecretsCommands;\n plugins: PluginCommands;\n agents: AgentCommands;\n channels: ChannelCommands;\n cron: CronCommands;\n diagnostics: DiagnosticsCommands;\n logs: LogsCommands;\n gateway: GatewayCommands;\n ui: UiCommands;\n start: StartCommands;\n restart: RestartCommands;\n serve: ServeCommands;\n stop: StopCommands;\n usage: LlmUsageCommandService;\n};\n\nexport class NextclawServiceRuntime {\n private logo: string;\n private restartCoordinator: RestartCoordinator;\n private serviceRestartTask: Promise<boolean> | null = null;\n private selfRelaunchArmed = false;\n private restartRequestService: RuntimeRestartRequestService;\n private workspaceManager: WorkspaceManager;\n private runtimeCommandService: RuntimeCommandService;\n private platformAuthCommands!: PlatformAuthCommands;\n private remoteCommands!: RemoteCommands;\n account: NextclawServiceRuntimeAccount;\n commands: NextclawServiceCommands;\n constructor(options: NextclawServiceRuntimeOptions) {\n logStartupTrace(\"cli.runtime.constructor.begin\");\n this.logo = options.logo ?? \"🤖\";\n this.workspaceManager = measureStartupSync(\"cli.runtime.workspace_manager\", () => new WorkspaceManager(this.logo));\n this.runtimeCommandService = measureStartupSync(\"cli.runtime.runtime_command_service\", () => new RuntimeCommandService({\n requestRestart: (params) => this.requestRestart(params),\n initializeAgentHomeDirectory: (homeDirectory) => this.workspaceManager.createWorkspaceTemplates(homeDirectory)\n }));\n this.commands = this.createCommands();\n\n this.restartCoordinator = measureStartupSync(\"cli.runtime.restart_coordinator\", () => new RestartCoordinator({\n readServiceState: managedServiceStateStore.read,\n isProcessRunning,\n currentPid: () => process.pid,\n restartBackgroundService: async (reason) =>\n this.restartBackgroundService(reason),\n scheduleProcessExit: (delayMs, reason) =>\n this.scheduleProcessExit(delayMs, reason),\n }));\n this.restartRequestService = new RuntimeRestartRequestService({\n armManagedServiceRelaunch: (params) => this.armManagedServiceRelaunch(params),\n requestRestartFromCoordinator: async (params) =>\n await this.restartCoordinator.requestRestart(params)\n });\n this.account = {\n status: async (opts = {}) => {\n await this.init({ source: \"account status\", auto: true });\n await this.platformAuthCommands.accountStatus(opts);\n },\n setUsername: async (username, opts = {}) => {\n await this.init({ source: \"account set-username\", auto: true });\n await this.platformAuthCommands.accountSetUsername({\n apiBase: opts.apiBase,\n json: opts.json,\n username\n });\n },\n };\n logStartupTrace(\"cli.runtime.constructor.end\");\n }\n\n private createCommands = (): NextclawServiceCommands => {\n const start = measureStartupSync(\"cli.runtime.start_commands\", () => new StartCommands({\n runtimeCommandService: this.runtimeCommandService,\n forcedPublicHost: FORCED_PUBLIC_UI_HOST,\n init: (params) => this.init(params)\n }));\n this.platformAuthCommands = measureStartupSync(\"cli.runtime.platform_auth_commands\", () => new PlatformAuthCommands());\n this.remoteCommands = measureStartupSync(\"cli.runtime.remote_commands\", () => new RemoteCommands());\n return {\n remote: measureStartupSync(\"cli.runtime.remote_runtime_actions\", () => new RemoteRuntimeActions({\n appName: APP_NAME,\n initAuto: (source) => this.init({ source, auto: true }),\n remoteCommands: this.remoteCommands,\n restartBackgroundService: (reason) => this.restartBackgroundService(reason),\n hasRunningManagedService: hasRunningNextclawManagedService\n })),\n skills: measureStartupSync(\"cli.runtime.skills_commands\", () => new SkillsCommands()),\n service: measureStartupSync(\"cli.runtime.service_commands\", () => new ServiceCommands()),\n config: measureStartupSync(\"cli.runtime.config_commands\", () => new ConfigCommands({\n requestRestart: (params) => this.requestRestart(params),\n })),\n mcp: measureStartupSync(\"cli.runtime.mcp_commands\", () => new McpCommands()),\n secrets: measureStartupSync(\"cli.runtime.secrets_commands\", () => new SecretsCommands({\n requestRestart: (params) => this.requestRestart(params),\n })),\n plugins: measureStartupSync(\"cli.runtime.plugin_commands\", () => new PluginCommands()),\n agents: measureStartupSync(\"cli.runtime.agent_commands\", () => new AgentCommands({\n initializeAgentHomeDirectory: (homeDirectory) => this.workspaceManager.createWorkspaceTemplates(homeDirectory)\n })),\n channels: measureStartupSync(\"cli.runtime.channel_commands\", () => new ChannelCommands({\n logo: this.logo,\n getBridgeDir: () => this.workspaceManager.getBridgeDir(),\n requestRestart: (params) => this.requestRestart(params),\n })),\n cron: measureStartupSync(\"cli.runtime.cron_commands\", () => new CronCommands()),\n diagnostics: measureStartupSync(\"cli.runtime.diagnostics_commands\", () => new DiagnosticsCommands({ logo: this.logo })),\n logs: measureStartupSync(\"cli.runtime.logs_commands\", () => new LogsCommands()),\n gateway: measureStartupSync(\"cli.runtime.gateway_commands\", () => new GatewayCommands({\n runtimeCommandService: this.runtimeCommandService,\n forcedPublicHost: FORCED_PUBLIC_UI_HOST\n })),\n ui: measureStartupSync(\"cli.runtime.ui_commands\", () => new UiCommands({\n runtimeCommandService: this.runtimeCommandService,\n forcedPublicHost: FORCED_PUBLIC_UI_HOST\n })),\n start,\n restart: measureStartupSync(\"cli.runtime.restart_commands\", () => new RestartCommands({\n runtimeCommandService: this.runtimeCommandService,\n startCommands: start,\n forcedPublicHost: FORCED_PUBLIC_UI_HOST,\n writeRestartSentinelFromExecContext: (reason) => this.writeRestartSentinelFromExecContext(reason)\n })),\n serve: measureStartupSync(\"cli.runtime.serve_commands\", () => new ServeCommands({\n runtimeCommandService: this.runtimeCommandService,\n forcedPublicHost: FORCED_PUBLIC_UI_HOST\n })),\n stop: measureStartupSync(\"cli.runtime.stop_commands\", () => new StopCommands({\n runtimeCommandService: this.runtimeCommandService\n })),\n usage: measureStartupSync(\"cli.runtime.usage_commands\", () => new LlmUsageCommandService()),\n };\n };\n\n get version(): string {\n return NextclawDistributionService.get().version;\n }\n\n private scheduleProcessExit = (delayMs: number, reason: string): void => {\n console.warn(`Gateway restart requested (${reason}).`);\n setTimeout(() => {\n process.exit(0);\n }, delayMs);\n };\n\n private restartBackgroundService = async (reason: string): Promise<boolean> => {\n if (this.serviceRestartTask) {\n return this.serviceRestartTask;\n }\n\n this.serviceRestartTask = (async () => {\n const state = managedServiceStateStore.read();\n if (!state || !isProcessRunning(state.pid) || state.pid === process.pid) {\n return false;\n }\n\n const uiHost = FORCED_PUBLIC_UI_HOST;\n const uiPort =\n typeof state.uiPort === \"number\" && Number.isFinite(state.uiPort)\n ? state.uiPort\n : 55667;\n\n console.log(\n `Applying changes (${reason}): restarting ${APP_NAME} background service...`,\n );\n await this.runtimeCommandService.stopService();\n await this.runtimeCommandService.startService({\n uiOverrides: {\n enabled: true,\n host: uiHost,\n port: uiPort,\n },\n open: false,\n });\n return true;\n })();\n\n try {\n return await this.serviceRestartTask;\n } finally {\n this.serviceRestartTask = null;\n }\n };\n\n private armManagedServiceRelaunch = (params: {\n reason: string;\n strategy?: RestartStrategy;\n delayMs?: number;\n }): void => {\n const { delayMs: requestedDelayMs, reason, strategy: requestedStrategy } = params;\n const strategy = requestedStrategy ?? \"background-service-or-manual\";\n if (\n strategy !== \"background-service-or-exit\" &&\n strategy !== \"exit-process\"\n ) {\n return;\n }\n if (this.selfRelaunchArmed) {\n return;\n }\n\n const state = managedServiceStateStore.read();\n if (!state || state.pid !== process.pid) {\n return;\n }\n\n const uiPort =\n typeof state.uiPort === \"number\" && Number.isFinite(state.uiPort)\n ? state.uiPort\n : 55667;\n const delayMs =\n typeof requestedDelayMs === \"number\" && Number.isFinite(requestedDelayMs)\n ? Math.max(0, Math.floor(requestedDelayMs))\n : 100;\n const launch = resolveCliSubcommandLaunch({\n argvEntry: process.argv[1],\n importMetaUrl: import.meta.url,\n cliArgs: [\"start\", \"--ui-port\", String(uiPort)],\n nodePath: process.execPath\n });\n const serviceStatePath = managedServiceStateStore.path;\n const helperScript = [\n 'const { spawnSync } = require(\"node:child_process\");',\n 'const { readFileSync } = require(\"node:fs\");',\n `const parentPid = ${process.pid};`,\n `const delayMs = ${delayMs};`,\n \"const maxWaitMs = 120000;\",\n \"const retryIntervalMs = 1000;\",\n `const command = ${JSON.stringify(launch.command)};`,\n `const args = ${JSON.stringify(launch.args)};`,\n `const serviceStatePath = ${JSON.stringify(serviceStatePath)};`,\n \"function isRunning(pid) {\",\n \" try {\",\n \" process.kill(pid, 0);\",\n \" return true;\",\n \" } catch {\",\n \" return false;\",\n \" }\",\n \"}\",\n \"function hasReplacementService() {\",\n \" try {\",\n ' const raw = readFileSync(serviceStatePath, \"utf-8\");',\n \" const state = JSON.parse(raw);\",\n \" const pid = Number(state?.pid);\",\n \" return Number.isFinite(pid) && pid > 0 && pid !== parentPid && isRunning(pid);\",\n \" } catch {\",\n \" return false;\",\n \" }\",\n \"}\",\n \"function tryStart() {\",\n \" spawnSync(command, args, {\",\n ' stdio: \"ignore\",',\n \" env: process.env,\",\n \" timeout: 60000,\",\n \" windowsHide: true\",\n \" });\",\n \"}\",\n \"setTimeout(() => {\",\n \" const startedAt = Date.now();\",\n \" const tick = () => {\",\n \" if (hasReplacementService() || Date.now() - startedAt >= maxWaitMs) {\",\n \" process.exit(0);\",\n \" return;\",\n \" }\",\n \" tryStart();\",\n \" if (hasReplacementService()) {\",\n \" process.exit(0);\",\n \" return;\",\n \" }\",\n \" setTimeout(tick, retryIntervalMs);\",\n \" };\",\n \" tick();\",\n \"}, delayMs);\",\n ].join(\"\\n\");\n\n try {\n const helper = spawn(process.execPath, [\"-e\", helperScript], {\n detached: true,\n stdio: \"ignore\",\n env: createTopLevelNextclawCommandEnv(process.env),\n windowsHide: true\n });\n helper.unref();\n this.selfRelaunchArmed = true;\n console.warn(`Gateway self-restart armed (${reason}).`);\n } catch (error) {\n console.error(`Failed to arm gateway self-restart: ${String(error)}`);\n }\n };\n\n private requestRestart = async (params: RequestRestartParams): Promise<void> => {\n await this.restartRequestService.run(params);\n };\n\n private writeRestartSentinelFromExecContext = async (reason: string): Promise<void> => {\n const sessionKeyRaw = process.env.NEXTCLAW_RUNTIME_SESSION_KEY;\n const sessionKey =\n typeof sessionKeyRaw === \"string\" ? sessionKeyRaw.trim() : \"\";\n if (!sessionKey) {\n return;\n }\n\n try {\n await writeRestartSentinel({\n kind: \"restart\",\n status: \"ok\",\n ts: Date.now(),\n sessionKey,\n stats: {\n reason: reason || \"cli.restart\",\n strategy: \"exec-tool\",\n },\n });\n } catch (error) {\n console.warn(\n `Warning: failed to write restart sentinel from exec context: ${String(error)}`,\n );\n }\n };\n\n onboard = async (): Promise<void> => {\n console.warn(\n `Warning: ${APP_NAME} onboard is deprecated. Use \"${APP_NAME} init\" instead.`,\n );\n await this.init({ source: \"onboard\" });\n };\n\n init = async (options: { source?: string; auto?: boolean; force?: boolean } = {}): Promise<void> => {\n const source = options.source ?? \"init\";\n const prefix = options.auto ? \"Auto init\" : \"Init\";\n const force = Boolean(options.force);\n\n const configPath = getConfigPath();\n const createdConfig = initializeConfigIfMissing(configPath);\n\n const config = loadConfig();\n const workspacePath = resolveWorkspacePath(config.agents.defaults.workspace);\n const workspaceExisted = existsSync(workspacePath);\n mkdirSync(workspacePath, { recursive: true });\n const templateResult = this.workspaceManager.createWorkspaceTemplates(\n workspacePath,\n { force },\n );\n\n if (createdConfig) {\n console.log(`✓ ${prefix}: created config at ${configPath}`);\n }\n if (!workspaceExisted) {\n console.log(`✓ ${prefix}: created workspace at ${workspacePath}`);\n }\n for (const file of templateResult.created) {\n console.log(`✓ ${prefix}: created ${file}`);\n }\n if (\n !createdConfig &&\n workspaceExisted &&\n templateResult.created.length === 0\n ) {\n console.log(`${prefix}: already initialized.`);\n }\n\n if (!options.auto) {\n console.log(`\\n${this.logo} ${APP_NAME} is ready! (${source})`);\n console.log(\"\\nNext steps:\");\n console.log(` 1. Add your API key to ${configPath}`);\n console.log(` 2. Chat: ${APP_NAME} agent -m \"Hello!\"`);\n } else {\n console.log(\n `Tip: Run \"${APP_NAME} init${force ? \" --force\" : \"\"}\" to re-run initialization if needed.`,\n );\n }\n };\n\n login = async (opts: LoginCommandOptions = {}): Promise<void> => {\n await this.init({ source: \"login\", auto: true });\n await this.platformAuthCommands.login(opts);\n };\n\n agent = async (opts: AgentCommandOptions): Promise<void> => {\n const configPath = getConfigPath();\n const kernel = new NextclawKernel({\n homeDir: getDataDir(),\n configPath,\n });\n const config = kernel.configManager.config;\n\n setPluginRuntimeBridge({\n loadConfig: () =>\n toPluginConfigView(\n resolveConfigSecrets(loadConfig(), { configPath }),\n kernel.extensions.getChannelBindings(),\n ),\n writeConfigFile: async (nextConfigView) => {\n if (\n !nextConfigView ||\n typeof nextConfigView !== \"object\" ||\n Array.isArray(nextConfigView)\n ) {\n throw new Error(\n \"plugin runtime writeConfigFile expects an object config\",\n );\n }\n const current = loadConfig();\n const next = mergePluginConfigView(\n current,\n nextConfigView,\n kernel.extensions.getChannelBindings(),\n );\n saveConfig(next);\n },\n });\n\n try {\n const providerManager = kernel.llmUsage.observeProviderManager(\n kernel.llmProviders,\n \"cli-agent\",\n );\n\n await runCliAgentCommand({\n logo: this.logo,\n opts,\n config,\n kernel,\n providerManager,\n });\n } finally {\n setPluginRuntimeBridge(null);\n }\n };\n\n update = async (opts: UpdateCommandOptions): Promise<void> => {\n const versionBefore = this.version;\n if (!opts.json) {\n const installationLabel = process.env.NEXTCLAW_DESKTOP_COMMAND_SURFACE === \"1\" ? \"desktop runtime\" : \"npm launcher\";\n console.log(`Current ${installationLabel} version: ${versionBefore}`);\n }\n const snapshot = await new NpmRuntimeUpdateCommandService().run(opts);\n if (snapshot.status === \"blocked\" || snapshot.status === \"failed\") {\n process.exit(1);\n }\n\n const state = managedServiceStateStore.read();\n if (snapshot.requiresRestart && state && isProcessRunning(state.pid)) {\n console.log(`Tip: restart ${APP_NAME} to apply the update.`);\n }\n };\n}\n\nexport const runNextclawNpmRuntimeLauncher = (\n argv: string[] = process.argv,\n): void => {\n const distribution = NextclawDistributionService.get();\n new NpmRuntimeLauncher({\n argv,\n launcherVersion: distribution.version,\n packagedAppEntrypoint: distribution.appEntrypoint,\n }).run();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,wBAAwB;AAoC9B,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA,qBAAsD;CACtD,oBAA4B;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA,YAAY,SAAwC;AAClD,kBAAgB,gCAAgC;AAChD,OAAK,OAAO,QAAQ,QAAQ;AAC5B,OAAK,mBAAmB,mBAAmB,uCAAuC,IAAI,iBAAiB,KAAK,KAAK,CAAC;AAClH,OAAK,wBAAwB,mBAAmB,6CAA6C,IAAI,sBAAsB;GACrH,iBAAiB,WAAW,KAAK,eAAe,OAAO;GACvD,+BAA+B,kBAAkB,KAAK,iBAAiB,yBAAyB,cAAc;GAC/G,CAAC,CAAC;AACH,OAAK,WAAW,KAAK,gBAAgB;AAErC,OAAK,qBAAqB,mBAAmB,yCAAyC,IAAI,mBAAmB;GAC3G,kBAAkB,yBAAyB;GAC3C;GACA,kBAAkB,QAAQ;GAC1B,0BAA0B,OAAO,WAC/B,KAAK,yBAAyB,OAAO;GACvC,sBAAsB,SAAS,WAC7B,KAAK,oBAAoB,SAAS,OAAO;GAC5C,CAAC,CAAC;AACH,OAAK,wBAAwB,IAAI,6BAA6B;GAC5D,4BAA4B,WAAW,KAAK,0BAA0B,OAAO;GAC7E,+BAA+B,OAAO,WACpC,MAAM,KAAK,mBAAmB,eAAe,OAAO;GACvD,CAAC;AACF,OAAK,UAAU;GACb,QAAQ,OAAO,OAAO,EAAE,KAAK;AAC3B,UAAM,KAAK,KAAK;KAAE,QAAQ;KAAkB,MAAM;KAAM,CAAC;AACzD,UAAM,KAAK,qBAAqB,cAAc,KAAK;;GAErD,aAAa,OAAO,UAAU,OAAO,EAAE,KAAK;AAC1C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,eAAe,CAE7B,OAAM,IAAI,MACR,0DACD;AAQH,eALa,sBADG,YAAY,EAG1B,gBACA,OAAO,WAAW,oBAAoB,CACvC,CACe;;GAEnB,CAAC;AAEF,MAAI;GACF,MAAM,kBAAkB,OAAO,SAAS,uBACtC,OAAO,cACP,YACD;AAED,SAAM,mBAAmB;IACvB,MAAM,KAAK;IACX;IACA;IACA;IACA;IACD,CAAC;YACM;AACR,0BAAuB,KAAK;;;CAIhC,SAAS,OAAO,SAA8C;EAC5D,MAAM,gBAAgB,KAAK;AAC3B,MAAI,CAAC,KAAK,MAAM;GACd,MAAM,oBAAoB,QAAQ,IAAI,qCAAqC,MAAM,oBAAoB;AACrG,WAAQ,IAAI,WAAW,kBAAkB,YAAY,gBAAgB;;EAEvE,MAAM,WAAW,MAAM,IAAI,gCAAgC,CAAC,IAAI,KAAK;AACrE,MAAI,SAAS,WAAW,aAAa,SAAS,WAAW,SACvD,SAAQ,KAAK,EAAE;EAGjB,MAAM,QAAQ,yBAAyB,MAAM;AAC7C,MAAI,SAAS,mBAAmB,SAAS,iBAAiB,MAAM,IAAI,CAClE,SAAQ,IAAI,gBAAgB,SAAS,uBAAuB;;;AAKlE,MAAa,iCACX,OAAiB,QAAQ,SAChB;CACT,MAAM,eAAe,4BAA4B,KAAK;AACtD,KAAI,mBAAmB;EACrB;EACA,iBAAiB,aAAa;EAC9B,uBAAuB,aAAa;EACrC,CAAC,CAAC,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.controller.d.ts","names":[],"sources":["../../../src/shared/controllers/gateway.controller.ts"],"mappings":";;;;KAcK,cAAA;EACH,aAAA,EAAe,aAAA;EACf,QAAA,EAAU,cAAA;EACV,IAAA,EAAM,WAAA;EACN,cAAA,GAAiB,cAAA;EACjB,cAAA,IAAkB,OAAA;IAAY,OAAA;IAAkB,MAAA;EAAA,MAAsB,OAAA;AAAA;AAAA,cAG3D,qBAAA,YAAiC,iBAAA;EAAA,QACxB,IAAA;cAAA,IAAA,EAAM,cAAA;EAAA,QAElB,uBAAA;EAAA,QAQA,sBAAA;EAAA,QA8CA,2BAAA;EAAA,QA6BA,cAAA;EAcR,MAAA,QAAa,MAAA;EAQb,YAAA,GAAsB,MAAA,cAAkB,OAAA;EAIxC,OAAA,GAAiB,OAAA;IAAY,OAAA;IAAkB,MAAA;IAAiB,UAAA;EAAA,MAAwB,OAAA;EAWxF,SAAA,QAAsB,OAAA,CAAQ,MAAA;EAI9B,eAAA,QAA4B,OAAA,CAAQ,MAAA;EAIpC,WAAA,GAAqB,MAAA;IACnB,GAAA;IACA,QAAA;IACA,IAAA;IACA,cAAA;IACA,UAAA;EAAA,MACE,OAAA,CAAQ,MAAA;EASZ,WAAA,GAAqB,MAAA;IACnB,GAAA;IACA,QAAA;IACA,IAAA;IACA,cAAA;IACA,UAAA;EAAA,MACE,OAAA,CAAQ,MAAA;EASZ,SAAA,GAAmB,MAAA;IACjB,IAAA;IACA,cAAA;IACA,SAAA;IACA,UAAA;EAAA,MACE,OAAA,CAAQ,MAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.controller.js","names":["getPackageVersion"],"sources":["../../../src/shared/controllers/gateway.controller.ts"],"sourcesContent":["import {\n type GatewayController,\n type CronService,\n type SessionManager\n} from \"@nextclaw/core\";\nimport type { ChannelManager, ConfigManager } from \"@nextclaw/kernel\";\nimport { getPackageVersion } from \"../utils/cli.utils.js\";\nimport { NpmRuntimeUpdateCommandService } from \"@nextclaw-service/launcher/npm-runtime-update-command.service.js\";\nimport {\n parseSessionKey,\n type RestartSentinelDeliveryContext,\n writeRestartSentinel\n} from \"../services/restart/restart-sentinel.service.js\";\n\ntype ControllerDeps = {\n configManager: ConfigManager;\n channels: ChannelManager;\n cron: CronService;\n sessionManager?: SessionManager;\n requestRestart?: (options?: { delayMs?: number; reason?: string }) => Promise<void> | void;\n};\n\nexport class GatewayControllerImpl implements GatewayController {\n constructor(private deps: ControllerDeps) {}\n\n private normalizeOptionalString = (value: unknown): string | undefined => {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed || undefined;\n };\n\n private resolveDeliveryContext = (sessionKey?: string): RestartSentinelDeliveryContext | undefined => {\n const normalizedSessionKey = this.normalizeOptionalString(sessionKey);\n const keyTarget = parseSessionKey(normalizedSessionKey);\n const keyRoute = keyTarget && keyTarget.channel !== \"agent\" ? keyTarget : null;\n const session = normalizedSessionKey ? this.deps.sessionManager?.getIfExists(normalizedSessionKey) : null;\n const metadata = session?.metadata ?? {};\n const rawContext = metadata.last_delivery_context;\n const cachedContext =\n rawContext && typeof rawContext === \"object\" && !Array.isArray(rawContext)\n ? (rawContext as Record<string, unknown>)\n : null;\n const cachedMetadataRaw = cachedContext?.metadata;\n const cachedMetadata =\n cachedMetadataRaw && typeof cachedMetadataRaw === \"object\" && !Array.isArray(cachedMetadataRaw)\n ? ({ ...(cachedMetadataRaw as Record<string, unknown>) } as Record<string, unknown>)\n : {};\n\n const channel = this.normalizeOptionalString(cachedContext?.channel) ?? keyRoute?.channel;\n const chatId =\n this.normalizeOptionalString(cachedContext?.chatId) ??\n this.normalizeOptionalString(metadata.last_to) ??\n keyRoute?.chatId;\n const replyTo =\n this.normalizeOptionalString(cachedContext?.replyTo) ??\n this.normalizeOptionalString(metadata.last_message_id);\n const accountId =\n this.normalizeOptionalString(cachedContext?.accountId) ??\n this.normalizeOptionalString(metadata.last_account_id);\n\n if (!channel || !chatId) {\n return undefined;\n }\n\n if (accountId && !this.normalizeOptionalString(cachedMetadata.accountId)) {\n cachedMetadata.accountId = accountId;\n }\n\n return {\n channel,\n chatId,\n ...(replyTo ? { replyTo } : {}),\n ...(accountId ? { accountId } : {}),\n ...(Object.keys(cachedMetadata).length > 0 ? { metadata: cachedMetadata } : {})\n };\n };\n\n private writeRestartSentinelPayload = async (params: {\n kind: \"config.apply\" | \"config.patch\" | \"update.run\" | \"restart\";\n status: \"ok\" | \"error\" | \"skipped\";\n sessionKey?: string;\n note?: string;\n reason?: string;\n strategy?: string;\n }): Promise<string | null> => {\n const { kind, note, reason, sessionKey: rawSessionKey, status, strategy } = params;\n const sessionKey = this.normalizeOptionalString(rawSessionKey);\n const deliveryContext = this.resolveDeliveryContext(sessionKey);\n try {\n return await writeRestartSentinel({\n kind,\n status,\n ts: Date.now(),\n sessionKey,\n deliveryContext,\n message: note ?? null,\n stats: {\n reason: reason ?? null,\n strategy: strategy ?? null\n }\n });\n } catch {\n return null;\n }\n };\n\n private requestRestart = async (options?: { delayMs?: number; reason?: string }): Promise<void> => {\n const { delayMs, reason } = options ?? {};\n if (this.deps.requestRestart) {\n await this.deps.requestRestart(options);\n return;\n }\n const delay =\n typeof delayMs === \"number\" && Number.isFinite(delayMs) ? Math.max(0, delayMs) : 100;\n console.log(`Gateway restart requested via tool${reason ? ` (${reason})` : \"\"}.`);\n setTimeout(() => {\n process.exit(0);\n }, delay);\n };\n\n status = (): Record<string, unknown> => {\n return {\n channels: this.deps.channels.enabledChannels,\n cron: this.deps.cron.status(),\n configPath: this.deps.configManager.configPath\n };\n };\n\n reloadConfig = async (reason?: string): Promise<string> => {\n return this.deps.configManager.reloadConfig(reason);\n };\n\n restart = async (options?: { delayMs?: number; reason?: string; sessionKey?: string }): Promise<string> => {\n await this.writeRestartSentinelPayload({\n kind: \"restart\",\n status: \"ok\",\n sessionKey: options?.sessionKey,\n reason: options?.reason ?? \"gateway.restart\"\n });\n await this.requestRestart(options);\n return \"Restart scheduled\";\n };\n\n getConfig = async (): Promise<Record<string, unknown>> => {\n return this.deps.configManager.getConfigSnapshot({ version: getPackageVersion() });\n };\n\n getConfigSchema = async (): Promise<Record<string, unknown>> => {\n return this.deps.configManager.getConfigSchema({ version: getPackageVersion() });\n };\n\n applyConfig = async (params: {\n raw: string;\n baseHash?: string;\n note?: string;\n restartDelayMs?: number;\n sessionKey?: string;\n }): Promise<Record<string, unknown>> => {\n return this.deps.configManager.applyRawConfig({\n raw: params.raw,\n baseHash: params.baseHash,\n note: params.note,\n version: getPackageVersion()\n });\n };\n\n patchConfig = async (params: {\n raw: string;\n baseHash?: string;\n note?: string;\n restartDelayMs?: number;\n sessionKey?: string;\n }): Promise<Record<string, unknown>> => {\n return this.deps.configManager.patchRawConfig({\n raw: params.raw,\n baseHash: params.baseHash,\n note: params.note,\n version: getPackageVersion()\n });\n };\n\n updateRun = async (params: {\n note?: string;\n restartDelayMs?: number;\n timeoutMs?: number;\n sessionKey?: string;\n }): Promise<Record<string, unknown>> => {\n const { note, restartDelayMs, sessionKey, timeoutMs } = params;\n const versionBefore = getPackageVersion();\n void timeoutMs;\n const snapshot = await new NpmRuntimeUpdateCommandService().runManaged({});\n if (snapshot.status === \"blocked\" || snapshot.status === \"failed\") {\n return {\n ok: false,\n error: snapshot.errorMessage ?? snapshot.blockReason ?? \"update failed\",\n snapshot,\n version: {\n before: versionBefore,\n after: getPackageVersion(),\n changed: false\n }\n };\n }\n\n const versionAfter = getPackageVersion();\n const delayMs = restartDelayMs ?? 0;\n const sentinelPath = await this.writeRestartSentinelPayload({\n kind: \"update.run\",\n status: \"ok\",\n sessionKey,\n note,\n reason: \"update.run\",\n strategy: \"runtime-bundle\"\n });\n await this.requestRestart({ delayMs, reason: \"update.run\" });\n return {\n ok: true,\n note: note ?? null,\n restart: { scheduled: true, delayMs },\n strategy: \"runtime-bundle\",\n snapshot,\n version: {\n before: versionBefore,\n after: versionAfter,\n changed: versionBefore !== versionAfter\n },\n sentinel: sentinelPath ? { path: sentinelPath } : null\n };\n };\n}\n"],"mappings":";;;;;;AAsBA,IAAa,wBAAb,MAAgE;CAC9D,YAAY,MAA8B;AAAtB,OAAA,OAAA;;CAEpB,2BAAmC,UAAuC;AACxE,MAAI,OAAO,UAAU,SACnB;AAGF,SADgB,MAAM,MAAM,IACV,KAAA;;CAGpB,0BAAkC,eAAoE;EACpG,MAAM,uBAAuB,KAAK,wBAAwB,WAAW;EACrE,MAAM,YAAY,gBAAgB,qBAAqB;EACv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c,eAAe;GAC5C,KAAK,OAAO;GACZ,UAAU,OAAO;GACjB,MAAM,OAAO;GACb,SAASA,qBAAmB;GAC7B,CAAC;;CAGJ,YAAY,OAAO,WAKqB;EACtC,MAAM,EAAE,MAAM,gBAAgB,YAAY,cAAc;EACxD,MAAM,gBAAgBA,qBAAmB;EAEzC,MAAM,WAAW,MAAM,IAAI,gCAAgC,CAAC,WAAW,EAAE,CAAC;AAC1E,MAAI,SAAS,WAAW,aAAa,SAAS,WAAW,SACvD,QAAO;GACL,IAAI;GACJ,OAAO,SAAS,gBAAgB,SAAS,eAAe;GACxD;GACA,SAAS;IACP,QAAQ;IACR,OAAOA,qBAAmB;IAC1B,SAAS;IACV;GACF;EAGH,MAAM,eAAeA,qBAAmB;EACxC,MAAM,UAAU,kBAAkB;EAClC,MAAM,eAAe,MAAM,KAAK,4BAA4B;GAC1D,MAAM;GACN,QAAQ;GACR;GACA;GACA,QAAQ;GACR,UAAU;GACX,CAAC;AACF,QAAM,KAAK,eAAe;GAAE;GAAS,QAAQ;GAAc,CAAC;AAC5D,SAAO;GACL,IAAI;GACJ,MAAM,QAAQ;GACd,SAAS;IAAE,WAAW;IAAM;IAAS;GACrC,UAAU;GACV;GACA,SAAS;IACP,QAAQ;IACR,OAAO;IACP,SAAS,kBAAkB;IAC5B;GACD,UAAU,eAAe,EAAE,MAAM,cAAc,GAAG;GACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-restart-wake.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/gateway-restart-wake.service.ts"],"mappings":";;;cAmBa,yBAAA;EAAA,iBACkB,OAAA;cAAA,OAAA,EAAS,sBAAA;EAEtC,uBAAA,QAAoC,OAAA;EAAA,QA4D5B,mCAAA;EAAA,QAiBA,sBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-restart-wake.service.js","names":[],"sources":["../../../../src/shared/services/gateway/gateway-restart-wake.service.ts"],"sourcesContent":["import {\n parseAgentScopedSessionKey,\n} from \"@nextclaw/core\";\nimport type { NextclawGatewayRuntime } from \"@nextclaw-service/shared/services/gateway/nextclaw-gateway-runtime.service.js\";\nimport {\n consumeRestartSentinel,\n formatRestartSentinelMessage,\n parseSessionKey,\n} from \"@nextclaw-service/shared/services/restart/restart-sentinel.service.js\";\nimport { resolveSessionRouteCandidate } from \"@nextclaw-service/shared/services/runtime/service-managed-startup.service.js\";\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed || undefined;\n}\n\nexport class GatewayRestartWakeService {\n constructor(private readonly gateway: NextclawGatewayRuntime) {}\n\n wakeFromRestartSentinel = async (): Promise<void> => {\n const sentinel = await consumeRestartSentinel();\n if (!sentinel) {\n return;\n }\n\n await new Promise((resolvePromise) => setTimeout(resolvePromise, 750));\n\n const payload = sentinel.payload;\n const summary = formatRestartSentinelMessage(payload);\n const sentinelSessionKey = normalizeOptionalString(payload.sessionKey);\n const fallbackSessionKey = sentinelSessionKey ? undefined : this.resolveMostRecentRoutableSessionKey();\n if (!sentinelSessionKey && fallbackSessionKey) {\n console.warn(`Warning: restart sentinel missing sessionKey; fallback to ${fallbackSessionKey}.`);\n }\n const sessionKey = sentinelSessionKey ?? fallbackSessionKey ?? \"cli:default\";\n const parsedSession = parseSessionKey(sessionKey);\n const parsedAgentSession = parseAgentScopedSessionKey(sessionKey);\n const parsedSessionRoute = parsedSession && parsedSession.channel !== \"agent\" ? parsedSession : null;\n\n const context = payload.deliveryContext;\n const channel =\n normalizeOptionalString(context?.channel) ??\n parsedSessionRoute?.channel ??\n normalizeOptionalString((this.gateway.sessionManager.getIfExists(sessionKey)?.metadata ?? {}).last_channel);\n const chatId =\n normalizeOptionalString(context?.chatId) ??\n parsedSessionRoute?.chatId ??\n normalizeOptionalString((this.gateway.sessionManager.getIfExists(sessionKey)?.metadata ?? {}).last_to);\n const replyTo = normalizeOptionalString(context?.replyTo);\n const accountId = normalizeOptionalString(context?.accountId);\n\n if (!channel || !chatId) {\n console.warn(`Warning: restart sentinel cannot resolve route for session ${sessionKey}.`);\n return;\n }\n\n await this.gateway.messageBus.publishInbound({\n channel: \"system\",\n senderId: \"restart-sentinel\",\n chatId: `${channel}:${chatId}`,\n content: this.buildRestartWakePrompt({\n summary,\n reason: normalizeOptionalString(payload.stats?.reason),\n note: normalizeOptionalString(payload.message),\n ...(replyTo ? { replyTo } : {}),\n }),\n timestamp: new Date(),\n attachments: [],\n metadata: {\n source: \"restart-sentinel\",\n restart_summary: summary,\n session_key_override: sessionKey,\n ...(replyTo ? { reply_to: replyTo } : {}),\n ...(parsedAgentSession ? { target_agent_id: parsedAgentSession.agentId } : {}),\n ...(accountId ? { account_id: accountId, accountId } : {}),\n },\n });\n };\n\n private resolveMostRecentRoutableSessionKey = (): string | undefined => {\n let best: { key: string; updatedAt: number } | null = null;\n for (const session of this.gateway.sessionManager.listSessions()) {\n const candidate = resolveSessionRouteCandidate({\n session,\n normalizeOptionalString,\n });\n if (!candidate) {\n continue;\n }\n if (!best || candidate.updatedAt >= best.updatedAt) {\n best = candidate;\n }\n }\n return best?.key;\n };\n\n private buildRestartWakePrompt = (params: {\n summary: string;\n reason?: string;\n note?: string;\n replyTo?: string;\n }): string => {\n const { note, reason, replyTo, summary } = params;\n const lines = [\n \"System event: the gateway has restarted successfully.\",\n \"Please send one short confirmation to the user that you are back online.\",\n \"Do not call any tools.\",\n \"Use the same language as the user's recent conversation.\",\n `Reference summary: ${summary}`,\n ];\n\n const normalizedReason = normalizeOptionalString(reason);\n if (normalizedReason) {\n lines.push(`Restart reason: ${normalizedReason}`);\n }\n\n const normalizedNote = normalizeOptionalString(note);\n if (normalizedNote) {\n lines.push(`Extra note: ${normalizedNote}`);\n }\n\n const normalizedReplyTo = normalizeOptionalString(replyTo);\n if (normalizedReplyTo) {\n lines.push(`Reply target message id: ${normalizedReplyTo}. If suitable, include [[reply_to:${normalizedRe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[],"sources":["../../../../../src/shared/services/gateway/managers/gateway-plugin.manager.ts"],"mappings":";;;;;;cAea,oBAAA;EAAA,iBAGkB,OAAA;EAAA,QAFrB,cAAA;cAEqB,OAAA,EAAS,sBAAA;EAEtC,kBAAA,QAAyB,oBAAA;EAEzB,aAAA,QAF6C,4BAAA,CAEhC,gBAAA;EAEb,IAAA,QAAiB,OAAA;EAmCjB,qBAAA,GAA+B,MAAA;IAC7B,MAAA,EAAQ,MAAA;IACR,YAAA;EAAA,MACE,OAAA;IAAU,eAAA;EAAA;EAad,qBAAA,GAA+B,YAAA,eAAyB,OAAA;EAWxD,aAAA,QAA0B,OAAA;EAuB1B,oBAAA;EAWA,eAAA,QAA4B,OAAA;EAK5B,YAAA,QAAyB,OAAA;EAAA,QAYjB,oBAAA;EAAA,QAgEA,wBAAA;EAAA,QAcA,yBAAA;EAAA,QA0BA,gBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-plugin.manager.js","names":[],"sources":["../../../../../src/shared/services/gateway/managers/gateway-plugin.manager.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport { eventKeys } from \"@nextclaw/shared\";\nimport {\n toPluginConfigView,\n type PluginChannelBinding,\n type PluginChannelGatewayHandle,\n type PluginDiagnostic,\n} from \"@nextclaw/openclaw-compat\";\nimport { logPluginDiagnostics } from \"@nextclaw-service/commands/plugin/index.js\";\nimport {\n logPluginGatewayDiagnostics,\n pluginGatewayLogger,\n} from \"@nextclaw-service/shared/services/gateway/service-startup-support.service.js\";\nimport type { NextclawGatewayRuntime } from \"@nextclaw-service/shared/services/gateway/nextclaw-gateway-runtime.service.js\";\n\nexport class GatewayPluginManager {\n private gatewayHandles: PluginChannelGatewayHandle[] = [];\n\n constructor(private readonly gateway: NextclawGatewayRuntime) {}\n\n getChannelBindings = (): PluginChannelBinding[] => this.gateway.kernel.extensions.getChannelBindings();\n\n getUiMetadata = () => this.gateway.kernel.extensions.getUiMetadata();\n\n load = async (): Promise<void> => {\n const config = this.gateway.configManager.loadConfig();\n let totalPluginCount = 0;\n this.gateway.bootstrapStatus.markChannelsPending();\n\n try {\n const result = await this.gateway.kernel.extensions.load({\n config,\n onLoadStart: ({ totalPluginCount: nextTotalPluginCount }) => {\n totalPluginCount = nextTotalPluginCount;\n this.gateway.bootstrapStatus.markPluginHydrationRunning({ totalPluginCount: nextTotalPluginCount });\n },\n onPluginProcessed: ({ loadedPluginCount: nextCount }) => {\n this.gateway.bootstrapStatus.markPluginHydrationProgress({\n loadedPluginCount: nextCount,\n totalPluginCount,\n });\n }\n });\n logPluginDiagnostics({ diagnostics: result.diagnostics });\n\n if (result.shouldRestartChannels) {\n await this.gateway.configManager.rebuildChannels(config, { start: false });\n }\n this.publishConfigChanges();\n this.gateway.bootstrapStatus.markPluginHydrationReady({\n loadedPluginCount: result.loadedPluginCount,\n totalPluginCount,\n });\n } catch (error) {\n this.gateway.bootstrapStatus.markPluginHydrationError(error instanceof Error ? error.message : String(error));\n throw error;\n }\n };\n\n reloadForConfigChange = async (params: {\n config: Config;\n changedPaths: string[];\n }): Promise<{ restartChannels: boolean }> => {\n const result = await this.gateway.kernel.extensions.reloadForConfigChange({\n config: params.config,\n changedPaths: params.changedPaths,\n });\n logPluginDiagnostics({ diagnostics: result.diagnostics });\n if (result.shouldRestartChannels) {\n await this.restartGateways();\n }\n this.publishConfigChanges();\n return { restartChannels: result.shouldRestartChannels };\n };\n\n reloadForDevHotReload = async (changedPaths: string[]): Promise<void> => {\n const config = this.gateway.configManager.loadConfig();\n const result = await this.reloadForConfigChange({\n config,\n changedPaths,\n });\n if (result.restartChannels) {\n await this.gateway.configManager.rebuildChannels(config, { start: true });\n }\n };\n\n startGateways = async (): Promise<void> => {\n const config = this.gateway.configManager.loadConfig();\n const diagnostics: PluginDiagnostic[] = [];\n const handles: PluginChannelGatewayHandle[] = [];\n const channelBindings = this.gateway.kernel.extensions.getChannelBindings();\n const configView = toPluginConfigView(config, channelBindings);\n\n for (const binding of channelBindings) {\n if (!this.isChannelEnabled(binding.channelId, configView)) {\n continue;\n }\n await this.startChannelGateways({\n binding,\n configView,\n diagnostics,\n handles,\n });\n }\n\n this.gatewayHandles = handles;\n logPluginGatewayDiagnostics(diagnostics);\n };\n\n publishConfigChanges = (): void => {\n this.gateway.appEventBus.emit(eventKeys.configUpdated, { path: \"channels\" }, {\n emittedAt: new Date().toISOString(),\n source: \"backend\",\n });\n this.gateway.appEventBus.emit(eventKeys.configUpdated, { path: \"plugins\" }, {\n emittedAt: new Date().toISOString(),\n source: \"backend\",\n });\n };\n\n restartGateways = async (): Promise<void> => {\n await this.stopGateways();\n await this.startGateways();\n };\n\n stopGateways = async (): Promise<void> => {\n for (const handle of this.gatewayHandles) {\n try {\n handle.abort?.();\n await handle.stop?.();\n } catch {\n // Ignore stop failures during shutdown.\n }\n }\n this.gatewayHandles = [];\n };\n\n private startChannelGateways = async (params: {\n binding: PluginChannelBinding;\n configView: Record<string, unknown>;\n diagnostics: PluginDiagnostic[];\n handles: PluginChannelGatewayHandle[];\n }): Promise<void> => {\n const { binding, configView, diagnostics, handles } = params;\n const gateway = binding.channel.gateway;\n if (!gateway?.startAccount) {\n return;\n }\n const accountIds = this.resolveGatewayAccountIds(binding, configView);\n for (const accountId of accountIds) {\n const abortController = new AbortController();\n let stopGateway: (() => void | Promise<void>) | undefined;\n const startTask = Promise.resolve()\n .then(async () =>\n await gateway.startAccount?.({\n accountId,\n channelId: binding.channelId,\n cfg: configView as Config,\n abortSignal: abortController.signal,\n runtime: {\n log: pluginGatewayLogger.info,\n info: pluginGatewayLogger.info,\n warn: pluginGatewayLogger.warn,\n error: pluginGatewayLogger.error,\n debug: pluginGatewayLogger.debug,\n },\n setStatus: () => undefined,\n log: pluginGatewayLogger,\n })\n )\n .then((started) => {\n if (started && typeof started === \"object\" && \"stop\" in started && typeof started.stop === \"function\") {\n stopGateway = started.stop.bind(started);\n }\n })\n .catch((error) => {\n if (abortController.signal.aborted) {\n return;\n }\n this.reportGatewayStartFailure({\n accountId,\n binding,\n diagnostics,\n error,\n });\n });\n\n handles.push({\n pluginId: binding.pluginId,\n channelId: binding.channelId,\n accountId,\n abort: () => abortController.abort(),\n stop: async () => {\n abortController.abort();\n await startTask;\n await stopGateway?.();\n },\n });\n }\n };\n\n private resolveGatewayAccountIds = (\n binding: PluginChannelBinding,\n configView: Record<string, unknown>,\n ): string[] => {\n const accountIdsRaw =\n binding.channel.config?.listAccountIds?.(configView) ?? [\n binding.channel.config?.defaultAccountId?.(configView) ?? \"default\",\n ];\n const accountIds = Array.from(\n new Set(accountIdsRaw.map((id) => (typeof id === \"string\" ? id.trim() : \"\")).filter(Boolean)),\n );\n return accountIds.length > 0 ? accountIds : [\"default\"];\n };\n\n private reportGatewayStartFailure = (params: {\n accountId: string;\n binding: PluginChannelBinding;\n diagnostics: PluginDiagnostic[];\n error: unknown;\n }): void => {\n const { accountId, binding, diagnostics, error } = params;\n const raw = String(error);\n const lower = raw.toLowerCase();\n const level =\n lower.includes(\"required\") || lower.includes(\"not configured\") || lower.includes(\"missing\")\n ? \"warn\"\n : \"error\";\n const message = `failed to start channel gateway for ${binding.channelId}/${accountId}: ${raw}`;\n diagnostics.push({\n level,\n pluginId: binding.pluginId,\n message,\n });\n if (level === \"error\") {\n pluginGatewayLogger.error(message);\n return;\n }\n pluginGatewayLogger.warn(message);\n };\n\n private isChannelEnabled = (\n channelId: string,\n configView: Record<string, unknown>,\n ): boolean => {\n const channels =\n configView.channels && typeof configView.channels === \"object\" && !Array.isArray(configView.channels)\n ? (configView.channels as Record<string, unknown>)\n : {};\n const channelConfig = channels[channelId];\n if (!channelConfig || typeof channelConfig !== \"object\" || Array.isArray(channelConfig)) {\n return false;\n }\n return (channelConfig as { enabled?: unknown }).enabled === true;\n };\n\n}\n"],"mappings":";;;;;AAeA,IAAa,uBAAb,MAAkC;CAChC,iBAAuD,EAAE;CAEzD,YAAY,SAAkD;AAAjC,OAAA,UAAA;;CAE7B,2BAAmD,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,iBAAiB,IAAI,MAAM,SAAS,UAAU,GACvF,SACA;EACN,MAAM,UAAU,uCAAuC,QAAQ,UAAU,GAAG,UAAU,IAAI;AAC1F,cAAY,KAAK;GACf;GACA,UAAU,QAAQ;GAClB;GACD,CAAC;AACF,MAAI,UAAU,SAAS;AACrB,uBAAoB,MAAM,QAAQ;AAClC;;AAEF,sBAAoB,KAAK,QAAQ;;CAGnC,oBACE,WACA,eACY;EAKZ,MAAM,iBAHJ,WAAW,YAAY,OAAO,WAAW,aAAa,YAAY,CAAC,MAAM,QAAQ,WAAW,SAAS,GAChG,WAAW,WACZ,EAAE,EACuB;AAC/B,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,YAAY,MAAM,QAAQ,cAAc,CACrF,QAAO;AAET,SAAQ,cAAwC,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-remote.manager.d.ts","names":[],"sources":["../../../../../src/shared/services/gateway/managers/gateway-remote.manager.ts"],"mappings":";;;;;;;;KAQK,qBAAA,GAAsB,UAAA,QAAkB,8BAAA;AAAA,cAEhC,oBAAA;EAAA,SACF,YAAA,EAAc,qBAAA;EAAA,SACd,YAAA,EAAc,kBAAA;cAEX,MAAA;IACV,IAAA,EAAM,kBAAA;IACN,aAAA,EAAe,aAAA;IACf,QAAA,EAAU,MAAA;IACV,mBAAA,IAAuB,KAAA,EAAO,kBAAA;EAAA;EAgBhC,IAAA,QAAiB,OAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-remote.manager.js","names":[],"sources":["../../../../../src/shared/services/gateway/managers/gateway-remote.manager.ts"],"sourcesContent":["import type { UiRemoteAccessHost } from \"@nextclaw/server\";\nimport type { RemoteRuntimeState } from \"@nextclaw/remote\";\nimport type { ConfigManager } from \"@nextclaw/kernel\";\nimport type { Config } from \"@nextclaw/core\";\nimport { createManagedRemoteModuleForUi } from \"@nextclaw-service/shared/services/runtime/utils/service-remote-runtime.utils.js\";\nimport { createRemoteAccessHost } from \"@nextclaw-service/shared/services/ui/service-remote-access.service.js\";\nimport type { GatewayRuntimeDeps } from \"../nextclaw-gateway-runtime.service.js\";\n\ntype RemoteServiceModule = ReturnType<typeof createManagedRemoteModuleForUi>;\n\nexport class GatewayRemoteManager {\n readonly remoteModule: RemoteServiceModule;\n readonly remoteAccess: UiRemoteAccessHost;\n\n constructor(params: {\n deps: GatewayRuntimeDeps;\n configManager: ConfigManager;\n uiConfig: Config[\"ui\"];\n onRemoteStateChange?: (state: RemoteRuntimeState) => void;\n }) {\n const { configManager, deps, uiConfig } = params;\n this.remoteModule = createManagedRemoteModuleForUi({\n loadConfig: configManager.loadConfig,\n uiConfig,\n onRemoteStateChange: params.onRemoteStateChange,\n });\n this.remoteAccess = createRemoteAccessHost({\n serviceCommands: deps,\n requestRestart: deps.requestRestart,\n uiConfig,\n remoteModule: this.remoteModule,\n });\n }\n\n stop = async (): Promise<void> => {\n await this.remoteModule?.stop();\n };\n}\n"],"mappings":";;;AAUA,IAAa,uBAAb,MAAkC;CAChC;CACA;CAEA,YAAY,QAKT;EACD,MAAM,EAAE,eAAe,MAAM,aAAa;AAC1C,OAAK,eAAe,+BAA+B;GACjD,YAAY,cAAc;GAC1B;GACA,qBAAqB,OAAO;GAC7B,CAAC;AACF,OAAK,eAAe,uBAAuB;GACzC,iBAAiB;GACjB,gBAAgB,KAAK;GACrB;GACA,cAAc,KAAK;GACpB,CAAC;;CAGJ,OAAO,YAA2B;AAChC,QAAM,KAAK,cAAc,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-app.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/nextclaw-app.service.ts"],"mappings":";;;KAIY,eAAA;EACV,QAAA;AAAA;AAAA,cAQW,WAAA;EAAA,iBAGkB,OAAA;EAAA,iBAFZ,MAAA;cAEY,OAAA,EAAS,sBAAA;EAItC,KAAA,QAAkB,OAAA;EAalB,eAAA,QAA4B,OAAA;EAc5B,4BAAA,QAAyC,OAAA;EAAA,iBAoBxB,wBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-app.service.js","names":[],"sources":["../../../../src/shared/services/gateway/nextclaw-app.service.ts"],"sourcesContent":["import type { NextclawKernel } from \"@nextclaw/kernel\";\nimport { logStartupTrace, measureStartupAsync } from \"@nextclaw-service/shared/utils/startup-trace.js\";\nimport type { NextclawGatewayRuntime } from \"@nextclaw-service/shared/services/gateway/nextclaw-gateway-runtime.service.js\";\n\nexport type UiStartupHandle = {\n endpoint: string;\n};\n\ntype NextclawAppKernel = Pick<\n NextclawKernel,\n \"extensions\" | \"start\"\n>;\n\nexport class NextclawApp {\n private readonly kernel: NextclawAppKernel;\n\n constructor(private readonly gateway: NextclawGatewayRuntime) {\n this.kernel = gateway.kernel;\n }\n\n start = async (): Promise<void> => {\n logStartupTrace(\"service.deferred_startup.begin\");\n try {\n await this.bootstrapKernel();\n } catch (error) {\n this.handleKernelStartupError(error);\n }\n\n await this.startDeferredRuntimeServices();\n console.log(\"✓ Deferred startup: plugin gateways and channels settled\");\n logStartupTrace(\"service.deferred_startup.end\");\n };\n\n bootstrapKernel = async (): Promise<void> => {\n this.gateway.bootstrapStatus.markNcpAgentRunning();\n await measureStartupAsync(\n \"service.deferred_startup.bootstrap_kernel\",\n async () => await this.kernel.start(),\n );\n this.gateway.bootstrapStatus.markNcpAgentReady();\n if (this.gateway.uiConfig.enabled) {\n console.log(\"✓ UI NCP agent: ready\");\n return;\n }\n console.log(\"✓ Service NCP agent: ready\");\n };\n\n startDeferredRuntimeServices = async (): Promise<void> => {\n await measureStartupAsync(\n \"service.deferred_startup.load_plugins\",\n this.gateway.plugins.load,\n );\n await measureStartupAsync(\n \"service.deferred_startup.start_plugin_gateways\",\n this.gateway.plugins.startGateways,\n );\n await measureStartupAsync(\n \"service.deferred_startup.start_extensions\",\n async () => await this.kernel.extensions.start({ endpoint: this.gateway.uiStartup.endpoint }),\n );\n await measureStartupAsync(\"service.deferred_startup.start_channels\", this.gateway.startDeferredChannels);\n await measureStartupAsync(\n \"service.deferred_startup.wake_restart_sentinel\",\n this.gateway.restartWake.wakeFromRestartSentinel,\n );\n };\n\n private readonly handleKernelStartupError = (error: unknown): void => {\n this.gateway.bootstrapStatus.markNcpAgentError(\n error instanceof Error ? error.message : String(error),\n );\n console.error(\n `UI NCP agent startup failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n };\n}\n"],"mappings":";;AAaA,IAAa,cAAb,MAAyB;CACvB;CAEA,YAAY,SAAkD;AAAjC,OAAA,UAAA;AAC3B,OAAK,SAAS,QAAQ;;CAGxB,QAAQ,YAA2B;AACjC,kBAAgB,iCAAiC;AACjD,MAAI;AACF,SAAM,KAAK,iBAAiB;WACrB,OAAO;AACd,QAAK,yBAAyB,MAAM;;AAGtC,QAAM,KAAK,8BAA8B;AACzC,UAAQ,IAAI,2DAA2D;AACvE,kBAAgB,+BAA+B;;CAGjD,kBAAkB,YAA2B;AAC3C,OAAK,QAAQ,gBAAgB,qBAAqB;AAClD,QAAM,oBACJ,6CACA,YAAY,MAAM,KAAK,OAAO,OAAO,CACtC;AACD,OAAK,QAAQ,gBAAgB,mBAAmB;AAChD,MAAI,KAAK,QAAQ,SAAS,SAAS;AACjC,WAAQ,IAAI,wBAAwB;AACpC;;AAEF,UAAQ,IAAI,6BAA6B;;CAG3C,+BAA+B,YAA2B;AACxD,QAAM,oBACJ,yCACA,KAAK,QAAQ,QAAQ,KACtB;AACD,QAAM,oBACJ,kDACA,KAAK,QAAQ,QAAQ,cACtB;AACD,QAAM,oBACJ,6CACA,YAAY,MAAM,KAAK,OAAO,WAAW,MAAM,EAAE,UAAU,KAAK,QAAQ,UAAU,UAAU,CAAC,CAC9F;AACD,QAAM,oBAAoB,2CAA2C,KAAK,QAAQ,sBAAsB;AACxG,QAAM,oBACJ,kDACA,KAAK,QAAQ,YAAY,wBAC1B;;CAGH,4BAA6C,UAAyB;AACpE,OAAK,QAAQ,gBAAgB,kBAC3B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CACvD;AACD,UAAQ,MACN,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACvF"}
|
|
@@ -83,4 +83,5 @@ declare class NextclawGatewayRuntime {
|
|
|
83
83
|
private configureIngressHandlers;
|
|
84
84
|
}
|
|
85
85
|
//#endregion
|
|
86
|
-
export { GatewayRuntimeDeps, NextclawGatewayRuntime };
|
|
86
|
+
export { GatewayRuntimeDeps, NextclawGatewayRuntime };
|
|
87
|
+
//# sourceMappingURL=nextclaw-gateway-runtime.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-gateway-runtime.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/nextclaw-gateway-runtime.service.ts"],"mappings":";;;;;;;;;;;;;;;KAkEK,QAAA,GAAS,YAAA,CAAa,MAAA;AAAA,KACtB,YAAA,GAAa,YAAA,CAAa,UAAA;AAAA,KAC1B,gBAAA,GAAiB,YAAA,CAAa,cAAA;AAAA,KAE9B,qBAAA;EACH,WAAA,GAAc,OAAA,CAAQ,QAAA;EACtB,WAAA;AAAA;AAAA,KAGU,kBAAA;EACV,cAAA,GAAiB,MAAA,EAAQ,oBAAA,KAAyB,OAAA;EAClD,4BAAA,GAA+B,aAAA;EAC/B,YAAA,GAAe,OAAA;IAAW,WAAA,EAAa,MAAA;IAAyB,IAAA;EAAA,MAAoB,OAAA;EACpF,WAAA,QAAmB,OAAA;EACnB,gBAAA,GAAmB,IAAA,eAAmB,OAAA;EACtC,8BAAA,GAAiC,IAAA,UAAc,KAAA;IAAiC,OAAA;IAAiB,MAAA;EAAA;AAAA;AAAA,cAGtF,sBAAA;EAAA,iBA4BQ,IAAA;EAAA,iBACA,OAAA;EAAA,SA5BV,MAAA,EAAQ,cAAA;EAAA,SACR,WAAA,EAAa,QAAA;EAAA,SACb,UAAA,EAAY,YAAA;EAAA,SACZ,cAAA,EAAgB,gBAAA;EAAA,SAChB,UAAA,EAAY,iBAAA;EAAA,SACZ,cAAA,EAAgB,oBAAA;EAAA,SAChB,aAAA,EAAe,mBAAA;EAAA,SACf,OAAA,EAAS,OAAA;EAAA,SACT,YAAA,EADgB,oBAAA;EAAA,SAEhB,cAAA;EAAA,SACA,eAAA,EAAiB,kBAAA;EAAA,SACjB,iBAAA,EAAmB,qBAAA;EAAA,SAEnB,aAAA,EAAe,aAAA;EAAA,SACf,QAAA,EAAU,QAAA;EAAA,SACV,WAAA;EAAA,SACA,SAAA;EAAA,SACA,aAAA,EAAe,oBAAA;EAAA,SACf,WAAA,EAAa,oBAAA;EAAA,SACb,OAAA,EAAS,oBAAA;EAAA,SACT,WAAA,EAAa,yBAAA;EACtB,eAAA,EAAiB,2BAAA;EACjB,SAAA,EAAW,eAAA;EAAA,SACF,YAAA,EAAY,0BAAA;EAAA,QACb,sBAAA;cAGW,IAAA,EAAM,kBAAA,EACN,OAAA,EAAS,qBAAA;EAyD5B,KAAA,QAAkB,OAAA;EAAA,QAcV,KAAA;EAAA,QAOA,qBAAA;EAAA,QAOA,uBAAA;EAAA,QAIA,cAAA;EAAA,QAiCA,qBAAA;EAAA,QAkBA,cAAA;EAAA,QAmBA,oBAAA;EAAA,SAKC,qBAAA,QAAkC,OAAA;EAAA,QAInC,0BAAA;EAAA,iBAcS,aAAA;EAAA,QAWT,iBAAA;EAAA,QASA,OAAA;EAAA,QASA,kBAAA;EAAA,QAKA,uBAAA;EAAA,QAqBA,oBAAA;EAAA,QAiBA,sBAAA;EAAA,QAIA,sBAAA;EAAA,QA2BA,wBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextclaw-gateway-runtime.service.js","names":["getConfigPath","getDataDir","getWorkspacePath","waitForNextTick"],"sources":["../../../../src/shared/services/gateway/nextclaw-gateway-runtime.service.ts"],"sourcesContent":["import * as NextclawCore from \"@nextclaw/core\";\nimport {\n NextclawKernel,\n runGatewayInboundLoop,\n type AutomationManager,\n type ConfigManager,\n type LlmProviderManager,\n} from \"@nextclaw/kernel\";\nimport type { EventBus, Ingress } from \"@nextclaw/shared\";\nimport {\n setPluginRuntimeBridge,\n} from \"@nextclaw/openclaw-compat\";\nimport {\n startUiServer,\n type MarketplaceApiConfig,\n type UiRouterOptions,\n type UiRuntimeControlHost,\n type UiRuntimeUpdateHost,\n} from \"@nextclaw/server\";\nimport { resolve } from \"node:path\";\nimport { setImmediate as waitForNextTick } from \"node:timers/promises\";\nimport { GatewayControllerImpl } from \"@nextclaw-service/shared/controllers/gateway.controller.js\";\nimport { GatewayPluginManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-plugin.manager.js\";\nimport { GatewayRemoteManager } from \"@nextclaw-service/shared/services/gateway/managers/gateway-remote.manager.js\";\nimport { GatewayRestartWakeService } from \"@nextclaw-service/shared/services/gateway/gateway-restart-wake.service.js\";\nimport { createCronJobHandler } from \"@nextclaw-service/shared/services/gateway/utils/cron-job-handler.utils.js\";\nimport { companionRuntimeService } from \"@nextclaw-service/shared/services/ui/companion-runtime.service.js\";\nimport { handleGatewayDeferredStartupError } from \"@nextclaw-service/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.js\";\nimport { NextclawApp, type UiStartupHandle } from \"@nextclaw-service/shared/services/gateway/nextclaw-app.service.js\";\nimport { NextclawDistributionService } from \"@nextclaw-service/shared/services/runtime/nextclaw-distribution.service.js\";\nimport { ServiceBootstrapStatusStore } from \"@nextclaw-service/shared/services/gateway/service-bootstrap-status.service.js\";\nimport { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from \"@nextclaw-service/shared/services/gateway/service-startup-support.service.js\";\nimport { installPluginRuntimeBridge } from \"@nextclaw-service/shared/services/plugin/utils/plugin-runtime-bridge.utils.js\";\nimport { wrapStartChannelsWithDevPluginHotReload } from \"@nextclaw-service/shared/services/plugin/utils/plugin-dev-hot-reload.utils.js\";\nimport { ServiceMarketplaceInstaller } from \"@nextclaw-service/shared/services/marketplace/service-marketplace-installer.service.js\";\nimport { NpmRuntimeUpdateHost } from \"@nextclaw-service/shared/services/ui/npm-runtime-update-host.service.js\";\nimport { createRuntimeControlHost } from \"@nextclaw-service/shared/services/ui/runtime-control-host.service.js\";\nimport { localUiRuntimeStore } from \"@nextclaw-service/shared/stores/local-ui-runtime.store.js\";\nimport { managedServiceStateStore } from \"@nextclaw-service/shared/stores/managed-service-state.store.js\";\nimport type { RequestRestartParams } from \"@nextclaw-service/shared/types/cli.types.js\";\nimport { openBrowser, resolveUiConfig, resolveUiStaticDir } from \"@nextclaw-service/shared/utils/cli.utils.js\";\nimport { logStartupTrace, measureStartupAsync, measureStartupSync } from \"@nextclaw-service/shared/utils/startup-trace.js\";\n\nconst {\n getConfigPath,\n getDataDir,\n getWorkspacePath,\n} = NextclawCore;\n\nconst DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS = 5_000;\n\nfunction resolveApplyRestartMode(uiPort: number): \"managed-service-restart\" | \"manual-process-restart\" {\n const serviceState = managedServiceStateStore.read();\n if (serviceState?.pid === process.pid) {\n return \"managed-service-restart\";\n }\n if (\n process.env.NEXTCLAW_RUNTIME_BUNDLE_CHILD === \"1\" &&\n typeof serviceState?.uiPort === \"number\" &&\n serviceState.uiPort === uiPort\n ) {\n return \"managed-service-restart\";\n }\n return \"manual-process-restart\";\n}\n\ntype Config = NextclawCore.Config;\ntype MessageBus = NextclawCore.MessageBus;\ntype SessionManager = NextclawCore.SessionManager;\n\ntype GatewayRuntimeOptions = {\n uiOverrides?: Partial<Config[\"ui\"]>;\n uiStaticDir?: string | null;\n};\n\nexport type GatewayRuntimeDeps = {\n requestRestart: (params: RequestRestartParams) => Promise<void>;\n initializeAgentHomeDirectory: (homeDirectory: string) => void;\n startService: (options: { uiOverrides: Record<string, unknown>; open: boolean }) => Promise<void>;\n stopService: () => Promise<void>;\n runCliSubcommand: (args: string[]) => Promise<string>;\n installBuiltinMarketplaceSkill: (slug: string, force: boolean | undefined) => { message: string; output?: string } | null;\n};\n\nexport class NextclawGatewayRuntime {\n readonly kernel: NextclawKernel;\n readonly appEventBus: EventBus;\n readonly messageBus: MessageBus;\n readonly sessionManager: SessionManager;\n readonly automation: AutomationManager;\n readonly runtimeControl: UiRuntimeControlHost;\n readonly runtimeUpdate: UiRuntimeUpdateHost | null;\n readonly ingress: Ingress;\n readonly distribution = NextclawDistributionService.get();\n readonly productVersion: string;\n readonly providerManager: LlmProviderManager;\n readonly gatewayController: GatewayControllerImpl;\n\n readonly configManager: ConfigManager;\n readonly uiConfig: Config[\"ui\"];\n readonly uiStaticDir: string | null;\n readonly workspace: string;\n readonly remoteManager: GatewayRemoteManager;\n readonly marketplace: MarketplaceApiConfig;\n readonly plugins: GatewayPluginManager;\n readonly restartWake: GatewayRestartWakeService;\n bootstrapStatus: ServiceBootstrapStatusStore;\n uiStartup: UiStartupHandle;\n readonly fileWatchers = new ServiceFileWatcherRegistry();\n private deferredChannelStarter: () => Promise<void>;\n\n constructor(\n private readonly deps: GatewayRuntimeDeps,\n private readonly options: GatewayRuntimeOptions,\n ) {\n const configPath = getConfigPath();\n this.kernel = measureStartupSync(\n \"service.gateway.kernel\",\n () => new NextclawKernel({\n homeDir: getDataDir(),\n configPath,\n }),\n );\n this.configManager = this.kernel.configManager;\n const config = this.configManager.config;\n this.uiConfig = resolveUiConfig(config, options.uiOverrides);\n this.uiStaticDir = options.uiStaticDir === undefined ? resolveUiStaticDir(this.distribution.uiDistDir) : options.uiStaticDir;\n this.workspace = getWorkspacePath(config.agents.defaults.workspace);\n this.appEventBus = this.kernel.eventBus;\n this.ingress = this.kernel.ingress;\n this.messageBus = this.kernel.messageBus;\n this.sessionManager = this.kernel.sessions;\n this.automation = this.kernel.automation;\n this.productVersion = this.distribution.version;\n this.plugins = new GatewayPluginManager(this);\n this.providerManager = this.kernel.llmProviders;\n this.installConfigHostHooks();\n this.restartWake = new GatewayRestartWakeService(this);\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.remoteManager = new GatewayRemoteManager({\n deps: this.deps,\n configManager: this.configManager,\n uiConfig: this.uiConfig,\n onRemoteStateChange: (state) => this.bootstrapStatus.syncRemoteRuntimeState(state),\n });\n this.marketplace = this.createMarketplace();\n this.runtimeControl = createRuntimeControlHost({\n serviceCommands: this.deps,\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.runtimeUpdate =\n process.env.NEXTCLAW_DISABLE_RUNTIME_UPDATE_HOST === \"1\"\n ? null\n : new NpmRuntimeUpdateHost({\n eventBus: this.appEventBus,\n applyRestartMode: resolveApplyRestartMode(this.uiConfig.port),\n requestRestart: this.deps.requestRestart,\n uiConfig: this.uiConfig,\n });\n this.gatewayController = this.createGatewayController();\n this.kernel.provideGatewayController(this.gatewayController);\n this.deferredChannelStarter = this.startChannels;\n this.automation.onJob = createCronJobHandler({\n agentRunRequests: this.kernel.agentRunRequestManager,\n bus: this.messageBus,\n });\n }\n\n start = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.begin\");\n await this.reset();\n this.configureIngressHandlers();\n this.uiStartup = await this.startUiRuntime();\n await companionRuntimeService.applyConfig(this.configManager.config);\n await this.markUiRuntimeReady();\n await this.startSupportServices();\n this.installChannelDevHotReload();\n await this.runRuntimeLoop();\n await companionRuntimeService.ensureStopped();\n logStartupTrace(\"service.start_gateway.end\");\n };\n\n private reset = async (): Promise<void> => {\n await this.fileWatchers.clear();\n this.bootstrapStatus = this.createBootstrapStatus();\n this.uiStartup = this.createDisabledUiStartup();\n this.deferredChannelStarter = this.startChannels;\n };\n\n private createBootstrapStatus = (): ServiceBootstrapStatusStore => {\n const bootstrapStatus = new ServiceBootstrapStatusStore();\n bootstrapStatus.markChannelsPending();\n bootstrapStatus.setRemoteState(this.configManager.config.remote.enabled ? \"pending\" : \"disabled\");\n return bootstrapStatus;\n };\n\n private createDisabledUiStartup = (): UiStartupHandle => ({\n endpoint: \"\",\n });\n\n private startUiRuntime = async (): Promise<UiStartupHandle> => {\n const uiStartup = await measureStartupAsync(\"service.start_ui_runtime\", async () => {\n logStartupTrace(\"service.start_ui_runtime.begin\");\n if (!this.uiConfig.enabled) {\n return this.createDisabledUiStartup();\n }\n const uiServer = await startUiServer(this.createUiRouterOptions());\n const uiUrl = NextclawCore.resolveLocalUiBaseUrl({\n host: uiServer.host,\n port: uiServer.port,\n });\n console.log(`✓ UI API: ${uiUrl}/api`);\n if (this.uiStaticDir) {\n console.log(`✓ UI frontend: ${uiUrl}`);\n }\n if (this.uiConfig.open) {\n openBrowser(uiUrl);\n }\n logStartupTrace(\"service.start_ui_runtime.ready\", {\n host: uiServer.host,\n port: uiServer.port,\n });\n return {\n endpoint: uiUrl,\n };\n });\n markLocalUiRuntimeIfStarted({\n uiStartup: this.uiConfig.enabled ? uiStartup : null,\n uiConfig: this.uiConfig,\n });\n return uiStartup;\n };\n\n private createUiRouterOptions = (): UiRouterOptions => ({\n kernel: this.kernel,\n configPath: this.configManager.configPath,\n appEventBus: this.appEventBus,\n uiConfig: this.uiConfig,\n uiStaticDir: this.uiStaticDir,\n productVersion: this.productVersion,\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,\n marketplace: this.marketplace,\n cron: this.automation,\n remoteAccess: this.remoteManager.remoteAccess,\n runtimeControl: this.runtimeControl,\n ...(this.runtimeUpdate ? { runtimeUpdate: this.runtimeUpdate } : {}),\n bootstrapStatus: this.bootstrapStatus,\n plugins: this.plugins,\n });\n\n private runRuntimeLoop = async (): Promise<void> => {\n logStartupTrace(\"service.start_gateway.runtime_loop_begin\");\n let startupTask: Promise<void> | null = null;\n try {\n const runtimeLoopTask = runGatewayInboundLoop(this);\n startupTask = this.startDeferredRuntime();\n void startupTask.catch((error) => handleGatewayDeferredStartupError({\n bootstrapStatus: this.bootstrapStatus,\n error,\n }));\n await runtimeLoopTask;\n } finally {\n if (startupTask) {\n await startupTask.catch(() => undefined);\n }\n await this.cleanup();\n }\n };\n\n private startDeferredRuntime = async (): Promise<void> => {\n const app = new NextclawApp(this);\n await app.start();\n };\n\n readonly startDeferredChannels = async (): Promise<void> => {\n await this.deferredChannelStarter();\n };\n\n private installChannelDevHotReload = (): void => {\n this.deferredChannelStarter = wrapStartChannelsWithDevPluginHotReload({\n startChannels: this.startChannels,\n watcherRegistry: this.fileWatchers,\n isRuntimeActive: () => true,\n reloadPlugins: async (pluginIds: string[]) => {\n await this.plugins.reloadForDevHotReload(\n pluginIds.map((pluginId) => `plugins.entries.${pluginId}.source`),\n );\n },\n startupSettleMs: DEV_PLUGIN_HOT_RELOAD_STARTUP_SETTLE_MS,\n });\n };\n\n private readonly startChannels = async (): Promise<void> => {\n await this.kernel.channels.start();\n const enabledChannels = this.kernel.channels.enabledChannels;\n if (enabledChannels.length > 0) {\n console.log(`✓ Channels enabled: ${enabledChannels.join(\", \")}`);\n } else {\n console.log(\"Warning: No channels enabled\");\n }\n this.bootstrapStatus.markChannelsReady(enabledChannels);\n };\n\n private createMarketplace = (): MarketplaceApiConfig => ({\n apiBaseUrl: process.env.NEXTCLAW_MARKETPLACE_API_BASE,\n installer: new ServiceMarketplaceInstaller({\n applyLiveConfigReload: this.configManager.applyLiveConfigReload,\n runCliSubcommand: this.deps.runCliSubcommand,\n installBuiltinSkill: this.deps.installBuiltinMarketplaceSkill,\n }).createInstaller(),\n });\n\n private cleanup = async (): Promise<void> => {\n localUiRuntimeStore.clearIfOwnedByProcess();\n await this.fileWatchers.clear();\n await this.kernel.extensions.stop();\n await this.remoteManager.stop();\n await this.plugins.stopGateways();\n setPluginRuntimeBridge(null);\n };\n\n private markUiRuntimeReady = async (): Promise<void> => {\n this.bootstrapStatus.markShellReady();\n await waitForNextTick();\n };\n\n private createGatewayController = (): GatewayControllerImpl => {\n return measureStartupSync(\n \"service.gateway.gateway_controller\",\n () => new GatewayControllerImpl({\n configManager: this.configManager,\n channels: this.kernel.channels,\n cron: this.automation,\n sessionManager: this.sessionManager,\n requestRestart: async (options) => {\n await this.deps.requestRestart({\n reason: options?.reason ?? \"gateway tool restart\",\n manualMessage: \"Restart the gateway to apply changes.\",\n strategy: \"background-service-or-exit\",\n delayMs: options?.delayMs,\n silentOnServiceRestart: true,\n });\n },\n })\n );\n };\n\n private startSupportServices = async (): Promise<void> => {\n this.plugins.publishConfigChanges();\n this.configurePluginRuntime();\n await measureStartupAsync(\"service.start_gateway_support_services\", async () =>\n await startGatewayRuntimeSupport({\n automation: this.automation,\n remoteModule: this.remoteManager.remoteModule,\n watchConfigFile: () => watchServiceConfigFile({\n configPath: resolve(getConfigPath()),\n watcherRegistry: this.fileWatchers,\n scheduleReload: (reason) => this.configManager.scheduleReload(reason)\n }),\n watcherRegistry: this.fileWatchers\n })\n );\n };\n\n private configurePluginRuntime = (): void => {\n installPluginRuntimeBridge(this);\n };\n\n private installConfigHostHooks = (): void => {\n this.configManager.installRuntimeHooks({\n reloadCompanion: async ({ config: nextConfig }) => {\n await companionRuntimeService.applyConfig(nextConfig);\n },\n reloadPlugins: async ({ config: nextConfig, changedPaths }) => {\n const result = await this.plugins.reloadForConfigChange({\n config: nextConfig,\n changedPaths,\n });\n if (result.restartChannels) {\n console.log(\"Config reload: plugin channel gateways restarted.\");\n }\n return { restartChannels: result.restartChannels };\n },\n onRestartRequired: (paths) => {\n void this.deps.requestRestart({\n changedPaths: paths,\n manualMessage: `已保存以下改动,等待你手动重启后生效:${paths.join(\", \")}`,\n mode: \"notify\",\n reason: `config reload requires restart: ${paths.join(\", \")}`,\n strategy: \"background-service-or-manual\",\n });\n },\n });\n };\n\n private configureIngressHandlers = (): void => {\n this.kernel.extensions.registerIngressHandlers();\n };\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,EACJ,eAAA,iBACA,YAAA,cACA,kBAAA,uBACE;AAEJ,MAAM,0CAA0C;AAEhD,SAAS,wBAAw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../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"mappings":";;;;cAOa,2BAAA;EAAA,QACH,KAAA;EAmBR,SAAA,CAAA,GAAa,mBAAA;EAab,cAAA,CAAA;EAKA,mBAAA,CAAA;EASA,iBAAA,CAAA;EASA,iBAAA,CAAkB,KAAA;EASlB,0BAAA,CAA2B,MAAA;IACzB,gBAAA;EAAA;EAcF,2BAAA,CAA4B,MAAA;IAC1B,iBAAA;IACA,gBAAA;EAAA;EAUF,wBAAA,CAAyB,MAAA;IACvB,iBAAA;IACA,gBAAA;EAAA;EAYF,wBAAA,CAAyB,KAAA;EAWzB,mBAAA,CAAA;EAOA,iBAAA,CAAkB,OAAA;EAWlB,iBAAA,CAAkB,KAAA;EAUlB,cAAA,CAAe,KAAA,EAAO,oBAAA,EAAsB,OAAA;EAO5C,sBAAA,CAAuB,OAAA,EAAS,kBAAA;EAWhC,SAAA,CAAU,KAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-bootstrap-status.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-bootstrap-status.service.ts"],"sourcesContent":["import type { BootstrapRemoteState, BootstrapStatusView } from \"@nextclaw/server\";\nimport type { RemoteRuntimeState } from \"@nextclaw/remote\";\n\nfunction now(): string {\n return new Date().toISOString();\n}\n\nexport class ServiceBootstrapStatusStore {\n private state: BootstrapStatusView = {\n phase: \"kernel-starting\",\n ncpAgent: {\n state: \"pending\",\n },\n pluginHydration: {\n state: \"pending\",\n loadedPluginCount: 0,\n totalPluginCount: 0\n },\n channels: {\n state: \"pending\",\n enabled: []\n },\n remote: {\n state: \"pending\"\n }\n };\n\n getStatus(): BootstrapStatusView {\n return {\n ...this.state,\n ncpAgent: { ...this.state.ncpAgent },\n pluginHydration: { ...this.state.pluginHydration },\n channels: {\n ...this.state.channels,\n enabled: [...this.state.channels.enabled]\n },\n remote: { ...this.state.remote }\n };\n }\n\n markShellReady(): void {\n this.state.phase = \"shell-ready\";\n this.state.shellReadyAt = this.state.shellReadyAt ?? now();\n }\n\n markNcpAgentRunning(): void {\n this.state.ncpAgent = {\n state: \"running\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markNcpAgentReady(): void {\n this.state.ncpAgent = {\n state: \"ready\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error: undefined\n };\n }\n\n markNcpAgentError(error: string): void {\n this.state.ncpAgent = {\n state: \"error\",\n startedAt: this.state.ncpAgent.startedAt ?? now(),\n completedAt: now(),\n error\n };\n }\n\n markPluginHydrationRunning(params: {\n totalPluginCount: number;\n }): void {\n this.state.phase = \"hydrating-capabilities\";\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"running\",\n loadedPluginCount: 0,\n totalPluginCount: params.totalPluginCount,\n startedAt: this.state.pluginHydration.startedAt ?? now(),\n completedAt: undefined,\n error: undefined\n };\n }\n\n markPluginHydrationProgress(params: {\n loadedPluginCount: number;\n totalPluginCount?: number;\n }): void {\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"running\",\n loadedPluginCount: params.loadedPluginCount,\n totalPluginCount: params.totalPluginCount ?? this.state.pluginHydration.totalPluginCount\n };\n }\n\n markPluginHydrationReady(params: {\n loadedPluginCount: number;\n totalPluginCount: number;\n }): void {\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"ready\",\n loadedPluginCount: params.loadedPluginCount,\n totalPluginCount: params.totalPluginCount,\n completedAt: now(),\n error: undefined\n };\n }\n\n markPluginHydrationError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.pluginHydration = {\n ...this.state.pluginHydration,\n state: \"error\",\n completedAt: now(),\n error\n };\n }\n\n markChannelsPending(): void {\n this.state.channels = {\n state: \"pending\",\n enabled: []\n };\n }\n\n markChannelsReady(enabled: string[]): void {\n this.state.channels = {\n state: \"ready\",\n enabled: [...enabled]\n };\n if (this.state.pluginHydration.state === \"ready\") {\n this.state.phase = \"ready\";\n this.state.lastError = undefined;\n }\n }\n\n markChannelsError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n this.state.channels = {\n state: \"error\",\n enabled: [...this.state.channels.enabled],\n error\n };\n }\n\n setRemoteState(state: BootstrapRemoteState, message?: string): void {\n this.state.remote = {\n state,\n ...(message ? { message } : {})\n };\n }\n\n syncRemoteRuntimeState(runtime: RemoteRuntimeState): void {\n const message = runtime.lastError?.trim() || undefined;\n const state =\n runtime.state === \"connected\" ? \"ready\"\n : runtime.state === \"disabled\" ? \"disabled\"\n : runtime.state === \"error\" && message?.includes(\"already owned\") ? \"conflict\"\n : runtime.state === \"error\" ? \"error\"\n : \"pending\";\n this.setRemoteState(state, message);\n }\n\n markError(error: string): void {\n this.state.phase = \"error\";\n this.state.lastError = error;\n }\n}\n"],"mappings":";AAGA,SAAS,MAAc;AACrB,yBAAO,IAAI,MAAM,EAAC,aAAa;;AAGjC,IAAa,8BAAb,MAAyC;CACvC,QAAqC;EACnC,OAAO;EACP,UAAU,EACR,OAAO,WACR;EACD,iBAAiB;GACf,OAAO;GACP,mBAAmB;GACnB,kBAAkB;GACnB;EACD,UAAU;GACR,OAAO;GACP,SAAS,EAAE;GACZ;EACD,QAAQ,EACN,OAAO,WACR;EACF;CAED,YAAiC;AAC/B,SAAO;GACL,GAAG,KAAK;GACR,UAAU,EAAE,GAAG,KAAK,MAAM,UAAU;GACpC,iBAAiB,EAAE,GAAG,KAAK,MAAM,iBAAiB;GAClD,UAAU;IACR,GAAG,KAAK,MAAM;IACd,SAAS,CAAC,GAAG,KAAK,MAAM,SAAS,QAAQ;IAC1C;GACD,QAAQ,EAAE,GAAG,KAAK,MAAM,QAAQ;GACjC;;CAGH,iBAAuB;AACrB,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,eAAe,KAAK,MAAM,gBAAgB,KAAK;;CAG5D,sBAA4B;AAC1B,OAAK,MAAM,WAAW;GACpB,OAAO;GACP,WAAW,KAA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MAAM,gBAAgB,UAAU,SAAS;AAChD,QAAK,MAAM,QAAQ;AACnB,QAAK,MAAM,YAAY,KAAA;;;CAI3B,kBAAkB,OAAqB;AACrC,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,YAAY;AACvB,OAAK,MAAM,WAAW;GACpB,OAAO;GACP,SAAS,CAAC,GAAG,KAAK,MAAM,SAAS,QAAQ;GACzC;GACD;;CAGH,eAAe,OAA6B,SAAwB;AAClE,OAAK,MAAM,SAAS;GAClB;GACA,GAAI,UAAU,EAAE,SAAS,GAAG,EAAE;GAC/B;;CAGH,uBAAuB,SAAmC;EACxD,MAAM,UAAU,QAAQ,WAAW,MAAM,IAAI,KAAA;EAC7C,MAAM,QACJ,QAAQ,UAAU,cAAc,UAC5B,QAAQ,UAAU,aAAa,aAC7B,QAAQ,UAAU,WAAW,SAAS,SAAS,gBAAgB,GAAG,aAChE,QAAQ,UAAU,UAAU,UAC1B;AACZ,OAAK,eAAe,OAAO,QAAQ;;CAGrC,UAAU,OAAqB;AAC7B,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,YAAY"}
|
|
@@ -39,4 +39,5 @@ declare function startGatewayRuntimeSupport(params: {
|
|
|
39
39
|
watcherRegistry: ServiceFileWatcherRegistry;
|
|
40
40
|
}): Promise<void>;
|
|
41
41
|
//#endregion
|
|
42
|
-
export { ServiceFileWatcherRegistry, logPluginGatewayDiagnostics, markLocalUiRuntimeIfStarted, pluginGatewayLogger, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
|
|
42
|
+
export { ServiceFileWatcherRegistry, logPluginGatewayDiagnostics, markLocalUiRuntimeIfStarted, pluginGatewayLogger, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
|
|
43
|
+
//# sourceMappingURL=service-startup-support.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-startup-support.service.d.ts","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"mappings":";;;;;;;cAQa,mBAAA;;;;;;iBAOG,2BAAA,CACd,WAAA,EAAa,gBAAA;AAAA,iBAaO,2BAAA,CAA4B,MAAA;EAChD,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;AAAA,IACE,OAAA;AAAA,iBAWY,kBAAA,CAAmB,UAAA,EAAY,iBAAA,GAAoB,SAAA;AAAA,iBAqBnD,sBAAA,CAAuB,MAAA;EACrC,UAAA;EACA,eAAA,EAAiB,0BAAA;EACjB,cAAA,GAAiB,MAAA;AAAA;AAAA,cA0BN,0BAAA;EAAA,iBACM,QAAA;EAAA,SAER,QAAA,GAAY,OAAA,EAAS,SAAA;EAAA,SAIrB,KAAA,QAAkB,OAAA;AAAA;AAAA,iBAYb,2BAAA,CAA4B,MAAA;EAC1C,SAAA;EACA,QAAA,EAAU,IAAA,CAAK,MAAA;AAAA;AAAA,iBAQK,0BAAA,CAA2B,MAAA;EAC/C,UAAA,EAAY,iBAAA;EACZ,YAAA,EAAc,mBAAA;EACd,eAAA;EACA,eAAA,EAAiB,0BAAA;AAAA,IACf,OAAA"}
|
|
@@ -94,3 +94,5 @@ async function startGatewayRuntimeSupport(params) {
|
|
|
94
94
|
}
|
|
95
95
|
//#endregion
|
|
96
96
|
export { ServiceFileWatcherRegistry, logPluginGatewayDiagnostics, markLocalUiRuntimeIfStarted, pluginGatewayLogger, startGatewayRuntimeSupport, startGatewaySupportServices, watchCronStoreFile, watchServiceConfigFile };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=service-startup-support.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-startup-support.service.js","names":[],"sources":["../../../../src/shared/services/gateway/service-startup-support.service.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport type { AutomationManager } from \"@nextclaw/kernel\";\nimport type { PluginDiagnostic } from \"@nextclaw/openclaw-compat\";\nimport type { RemoteServiceModule } from \"@nextclaw/remote\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport { resolve } from \"node:path\";\nimport { localUiRuntimeStore } from \"../../../shared/stores/local-ui-runtime.store.js\";\n\nexport const pluginGatewayLogger = {\n info: (message: string) => console.log(`[plugins] ${message}`),\n warn: (message: string) => console.warn(`[plugins] ${message}`),\n error: (message: string) => console.error(`[plugins] ${message}`),\n debug: (message: string) => console.debug(`[plugins] ${message}`)\n};\n\nexport function logPluginGatewayDiagnostics(\n diagnostics: PluginDiagnostic[],\n): void {\n for (const diag of diagnostics) {\n const prefix = diag.pluginId ? `${diag.pluginId}: ` : \"\";\n const text = `${prefix}${diag.message}`;\n if (diag.level === \"error\") {\n console.error(`[plugins] ${text}`);\n } else {\n console.warn(`[plugins] ${text}`);\n }\n }\n}\n\nexport async function startGatewaySupportServices(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n}): Promise<void> {\n const { automation, remoteModule, watchConfigFile } = params;\n const cronJobs = automation.status().jobs;\n if (cronJobs > 0) {\n console.log(`✓ Cron: ${cronJobs} scheduled jobs`);\n }\n remoteModule?.start();\n watchConfigFile();\n await automation.start();\n}\n\nexport function watchCronStoreFile(automation: AutomationManager): FSWatcher {\n const cronStorePath = resolve(automation.storePath);\n const watcher = chokidar.watch(cronStorePath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== cronStorePath) {\n return;\n }\n if (event === \"add\" || event === \"change\" || event === \"unlink\") {\n try {\n automation.reloadFromStore();\n } catch (error) {\n console.error(`Cron store reload failed (${event}): ${String(error)}`);\n }\n }\n });\n return watcher;\n}\n\nexport function watchServiceConfigFile(params: {\n configPath: string;\n watcherRegistry: ServiceFileWatcherRegistry;\n scheduleReload: (reason: string) => void;\n}): void {\n const configPath = resolve(params.configPath);\n const watcher = chokidar.watch(configPath, {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }\n });\n params.watcherRegistry.remember(watcher);\n watcher.on(\"all\", (event, changedPath) => {\n if (resolve(changedPath) !== configPath) {\n return;\n }\n if (event === \"add\") {\n params.scheduleReload(\"config add\");\n return;\n }\n if (event === \"change\") {\n params.scheduleReload(\"config change\");\n return;\n }\n if (event === \"unlink\") {\n params.scheduleReload(\"config unlink\");\n }\n });\n}\n\nexport class ServiceFileWatcherRegistry {\n private readonly watchers: FSWatcher[] = [];\n\n readonly remember = (watcher: FSWatcher): void => {\n this.watchers.push(watcher);\n };\n\n readonly clear = async (): Promise<void> => {\n const watchers = this.watchers.splice(0);\n await Promise.allSettled(watchers.map(async (watcher) => {\n try {\n await watcher.close();\n } catch {\n void 0;\n }\n }));\n };\n}\n\nexport function markLocalUiRuntimeIfStarted(params: {\n uiStartup: unknown | null | undefined;\n uiConfig: Pick<Config[\"ui\"], \"host\" | \"port\">;\n}): void {\n const { uiConfig, uiStartup } = params;\n if (uiStartup) {\n localUiRuntimeStore.writeCurrentProcess(uiConfig);\n }\n}\n\nexport async function startGatewayRuntimeSupport(params: {\n automation: AutomationManager;\n remoteModule: RemoteServiceModule | null;\n watchConfigFile: () => void;\n watcherRegistry: ServiceFileWatcherRegistry;\n}): Promise<void> {\n const {\n automation,\n remoteModule,\n watchConfigFile,\n watcherRegistry\n } = params;\n await startGatewaySupportServices({\n automation,\n remoteModule,\n watchConfigFile\n });\n watcherRegistry.remember(watchCronStoreFile(automation));\n}\n"],"mappings":";;;;AAQA,MAAa,sBAAsB;CACjC,OAAO,YAAoB,QAAQ,IAAI,aAAa,UAAU;CAC9D,OAAO,YAAoB,QAAQ,KAAK,aAAa,UAAU;CAC/D,QAAQ,YAAoB,QAAQ,MAAM,aAAa,UAAU;CACjE,QAAQ,YAAoB,QAAQ,MAAM,aAAa,UAAU;CAClE;AAED,SAAgB,4BACd,aACM;AACN,MAAK,MAAM,QAAQ,aAAa;EAE9B,MAAM,OAAO,G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AAGJ,IAAa,6BAAb,MAAwC;CACtC,WAAyC,EAAE;CAE3C,YAAqB,YAA6B;AAChD,OAAK,SAAS,KAAK,QAAQ;;CAG7B,QAAiB,YAA2B;EAC1C,MAAM,WAAW,KAAK,SAAS,OAAO,EAAE;AACxC,QAAM,QAAQ,WAAW,SAAS,IAAI,OAAO,YAAY;AACvD,OAAI;AACF,UAAM,QAAQ,OAAO;WACf;IAGR,CAAC;;;AAIP,SAAgB,4BAA4B,QAGnC;CACP,MAAM,EAAE,UAAU,cAAc;AAChC,KAAI,UACF,qBAAoB,oBAAoB,SAAS;;AAIrD,eAAsB,2BAA2B,QAK/B;CAChB,MAAM,EACJ,YACA,cACA,iBACA,oBACE;AACJ,OAAM,4BAA4B;EAChC;EACA;EACA;EACD,CAAC;AACF,iBAAgB,SAAS,mBAAmB,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-job-handler.utils.d.ts","names":[],"sources":["../../../../../src/shared/services/gateway/utils/cron-job-handler.utils.ts"],"mappings":";;;;KAGK,WAAA;EACH,EAAA;EACA,IAAA;EACA,OAAA;IACE,OAAA;IACA,OAAA;IACA,SAAA;IACA,OAAA;IACA,OAAA;IACA,EAAA;IACA,SAAA;EAAA;AAAA;AAAA,iBAsCY,oBAAA,CAAqB,MAAA;EACnC,gBAAA,EAAkB,cAAA;EAClB,GAAA,EAAK,UAAA;AAAA,KACF,GAAA,EAAK,WAAA,KAAgB,OAAA"}
|