@nextclaw/service 0.1.7 → 0.1.9

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.
Files changed (83) hide show
  1. package/dist/cli/commands/agent/agent-runtime.utils.js +2 -2
  2. package/dist/cli/commands/agent/cli-agent-runner.utils.js +2 -2
  3. package/dist/cli/commands/agent/index.js +1 -1
  4. package/dist/cli/commands/config/services/config-commands.service.js +1 -1
  5. package/dist/cli/commands/cron/services/cron-commands.service.js +2 -2
  6. package/dist/cli/commands/cron/services/cron-local.service.d.ts +1 -1
  7. package/dist/cli/commands/cron/services/cron-local.service.js +1 -1
  8. package/dist/cli/commands/restart/index.js +2 -2
  9. package/dist/cli/commands/skills/marketplace.metadata.js +1 -1
  10. package/dist/cli/commands/skills/marketplace.service.js +2 -2
  11. package/dist/cli/commands/skills/skills-query.service.js +1 -1
  12. package/dist/commands/channel/index.js +2 -2
  13. package/dist/commands/plugin/development-source/dev-plugin-overrides.utils.js +3 -3
  14. package/dist/commands/plugin/development-source/{first-party-plugin-load-paths.d.ts → first-party-plugin-load-paths.utils.d.ts} +1 -1
  15. package/dist/commands/plugin/development-source/{first-party-plugin-load-paths.js → first-party-plugin-load-paths.utils.js} +3 -3
  16. package/dist/commands/plugin/index.d.ts +1 -1
  17. package/dist/commands/plugin/index.js +5 -5
  18. package/dist/commands/plugin/plugin-command-utils.d.ts +1 -1
  19. package/dist/commands/plugin/plugin-mutation-actions.js +2 -2
  20. package/dist/commands/plugin/{plugin-registry-loader.d.ts → plugin-registry-loader.utils.d.ts} +1 -1
  21. package/dist/commands/plugin/{plugin-registry-loader.js → plugin-registry-loader.utils.js} +2 -2
  22. package/dist/commands/remote/services/remote-service-control.service.js +1 -1
  23. package/dist/commands/remote/utils/remote-runtime-support.utils.js +1 -1
  24. package/dist/commands/service/services/autostart/host-autostart-runtime.service.js +2 -2
  25. package/dist/commands/service/services/autostart/linux-systemd-autostart.service.js +2 -2
  26. package/dist/commands/service/services/autostart/macos-launch-agent-autostart.service.js +2 -2
  27. package/dist/commands/service/services/autostart/windows-task-autostart.service.js +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/launcher/npm-runtime-bundle-layout.store.js +1 -1
  30. package/dist/launcher/npm-runtime-bundle.service.js +1 -1
  31. package/dist/launcher/npm-runtime-bundle.types.d.ts +1 -1
  32. package/dist/launcher/npm-runtime-launcher.service.js +5 -5
  33. package/dist/launcher/npm-runtime-update-command.service.js +4 -3
  34. package/dist/launcher/npm-runtime-update-source.service.js +2 -2
  35. package/dist/launcher/npm-runtime-update-state.store.js +1 -1
  36. package/dist/launcher/npm-runtime-update.manager.d.ts +2 -2
  37. package/dist/launcher/npm-runtime-update.manager.js +8 -4
  38. package/dist/launcher/npm-runtime-update.service.d.ts +1 -1
  39. package/dist/launcher/npm-runtime-update.service.js +3 -3
  40. package/dist/service-runtime.service.d.ts +0 -2
  41. package/dist/service-runtime.service.js +31 -33
  42. package/dist/shared/controllers/gateway.controller.js +7 -9
  43. package/dist/shared/services/extensions/extension-lifecycle.service.js +1 -1
  44. package/dist/shared/services/extensions/service-extension-runtime.service.d.ts +1 -1
  45. package/dist/shared/services/extensions/service-extension-runtime.service.js +7 -6
  46. package/dist/shared/services/gateway/gateway-restart-wake.service.js +2 -1
  47. package/dist/shared/services/gateway/managers/gateway-plugin.manager.js +17 -3
  48. package/dist/shared/services/gateway/managers/gateway-remote.manager.d.ts +2 -2
  49. package/dist/shared/services/gateway/managers/gateway-remote.manager.js +1 -1
  50. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +1 -1
  51. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +10 -10
  52. package/dist/shared/services/gateway/service-bootstrap-status.service.d.ts +1 -1
  53. package/dist/shared/services/gateway/service-startup-support.service.d.ts +1 -1
  54. package/dist/shared/services/marketplace/service-marketplace-installer.service.js +2 -2
  55. package/dist/shared/services/plugin/utils/plugin-runtime-bridge.utils.js +1 -1
  56. package/dist/shared/services/restart/restart-sentinel.service.js +1 -1
  57. package/dist/shared/services/runtime/runtime-command.service.d.ts +3 -0
  58. package/dist/shared/services/runtime/runtime-command.service.js +27 -3
  59. package/dist/shared/services/runtime/service-managed-startup.service.d.ts +4 -28
  60. package/dist/shared/services/runtime/service-managed-startup.service.js +61 -65
  61. package/dist/shared/services/runtime/utils/managed-service-routing.utils.d.ts +30 -0
  62. package/dist/shared/services/runtime/utils/managed-service-routing.utils.js +62 -0
  63. package/dist/shared/services/runtime/utils/service-remote-runtime.utils.js +2 -2
  64. package/dist/shared/services/session/service-deferred-ncp-agent.service.d.ts +1 -1
  65. package/dist/shared/services/ui/companion-runtime.service.d.ts +2 -0
  66. package/dist/shared/services/ui/companion-runtime.service.js +40 -8
  67. package/dist/shared/services/ui/local-ui-discovery.service.js +1 -1
  68. package/dist/shared/services/ui/npm-runtime-update-host.service.js +2 -2
  69. package/dist/shared/services/ui/runtime-control-host.service.js +1 -1
  70. package/dist/shared/services/ui/service-remote-access.service.js +1 -1
  71. package/dist/shared/services/workspace/workspace-manager.service.js +3 -3
  72. package/dist/shared/stores/companion-runtime.store.js +1 -1
  73. package/dist/shared/stores/local-ui-runtime.store.js +1 -1
  74. package/dist/shared/stores/managed-service-state.store.js +1 -1
  75. package/dist/shared/types/cli.types.d.ts +2 -14
  76. package/dist/shared/utils/cli.utils.js +2 -2
  77. package/dist/shared/utils/marketplace/cli-subcommand-launch.utils.js +1 -1
  78. package/dist/shared/utils/package/package-manifest.utils.js +2 -2
  79. package/package.json +21 -19
  80. package/dist/cli/commands/companion/index.d.ts +0 -15
  81. package/dist/cli/commands/companion/index.js +0 -24
  82. package/dist/cli/commands/companion/services/companion-process.service.d.ts +0 -17
  83. package/dist/cli/commands/companion/services/companion-process.service.js +0 -49
@@ -1,54 +1,53 @@
1
+ import { RestartCoordinator } from "./shared/services/restart/restart-coordinator.service.js";
2
+ import { initializeConfigIfMissing } from "./shared/services/runtime/runtime-config-init.service.js";
3
+ import { writeRestartSentinel } from "./shared/services/restart/restart-sentinel.service.js";
4
+ import { createTopLevelNextclawCommandEnv } from "./shared/utils/top-level-nextclaw-command-env.utils.js";
5
+ import { logStartupTrace, measureStartupSync } from "./shared/utils/startup-trace.js";
1
6
  import { isProcessRunning } from "./shared/utils/cli.utils.js";
2
- import { NpmRuntimeLauncher } from "./launcher/npm-runtime-launcher.service.js";
3
7
  import { NextclawDistributionService } from "./shared/services/runtime/nextclaw-distribution.service.js";
4
8
  import { NpmRuntimeUpdateCommandService } from "./launcher/npm-runtime-update-command.service.js";
9
+ import { NpmRuntimeLauncher } from "./launcher/npm-runtime-launcher.service.js";
5
10
  import { managedServiceStateStore } from "./shared/stores/managed-service-state.store.js";
6
- import { logStartupTrace, measureStartupSync } from "./shared/utils/startup-trace.js";
7
- import { createTopLevelNextclawCommandEnv } from "./shared/utils/top-level-nextclaw-command-env.utils.js";
8
- import { writeRestartSentinel } from "./shared/services/restart/restart-sentinel.service.js";
9
- import { hasRunningNextclawManagedService } from "./commands/remote/utils/remote-runtime-support.utils.js";
10
- import { RemoteCommands } from "./commands/remote/index.js";
11
- import { PlatformAuthCommands } from "./commands/platform-auth/services/platform-auth-commands.service.js";
12
- import "./commands/platform-auth/index.js";
13
- import { WorkspaceManager } from "./shared/services/workspace/workspace-manager.service.js";
14
11
  import { toExtensionRegistry } from "./commands/plugin/plugin-extension-registry.js";
15
12
  import { PluginCommands, loadPluginRegistry, logPluginDiagnostics, mergePluginConfigView, toPluginConfigView as toPluginConfigView$1 } from "./commands/plugin/index.js";
16
- import { RuntimeCommandService } from "./shared/services/runtime/runtime-command.service.js";
17
- import { initializeConfigIfMissing } from "./shared/services/runtime/runtime-config-init.service.js";
18
- import { RuntimeRestartRequestService } from "./shared/services/restart/runtime-restart-request.service.js";
19
- import { RestartCoordinator } from "./shared/services/restart/restart-coordinator.service.js";
20
- import { UiCommands } from "./cli/commands/ui/index.js";
21
13
  import { ChannelCommands } from "./commands/channel/index.js";
22
14
  import { ConfigCommands } from "./cli/commands/config/services/config-commands.service.js";
23
15
  import "./cli/commands/config/index.js";
16
+ import { McpCommands } from "./cli/commands/mcp/index.js";
24
17
  import { SecretsCommands } from "./cli/commands/secrets/index.js";
25
- import { StartCommands } from "./cli/commands/start/index.js";
26
- import { StopCommands } from "./cli/commands/stop/index.js";
27
- import { LlmUsageCommandService } from "./cli/commands/usage/services/llm-usage-command.service.js";
28
- import "./cli/commands/usage/index.js";
29
- import { runCliAgentCommand } from "./cli/commands/agent/cli-agent-runner.utils.js";
18
+ import { CronCommands } from "./cli/commands/cron/services/cron-commands.service.js";
19
+ import "./cli/commands/cron/index.js";
30
20
  import { AgentCommands } from "./cli/commands/agent/services/agent-commands.service.js";
21
+ import { runCliAgentCommand } from "./cli/commands/agent/cli-agent-runner.utils.js";
31
22
  import "./cli/commands/agent/index.js";
32
- import { McpCommands } from "./cli/commands/mcp/index.js";
33
- import { RestartCommands } from "./cli/commands/restart/index.js";
34
- import { LogsCommands } from "./cli/commands/logs/index.js";
23
+ import { hasRunningNextclawManagedService } from "./commands/remote/utils/remote-runtime-support.utils.js";
24
+ import { RemoteCommands } from "./commands/remote/index.js";
25
+ import { PlatformAuthCommands } from "./commands/platform-auth/services/platform-auth-commands.service.js";
26
+ import "./commands/platform-auth/index.js";
35
27
  import { DiagnosticsCommands } from "./cli/commands/diagnostics/services/diagnostics-commands.service.js";
36
28
  import "./cli/commands/diagnostics/index.js";
29
+ import { LogsCommands } from "./cli/commands/logs/index.js";
30
+ import { RuntimeCommandService } from "./shared/services/runtime/runtime-command.service.js";
31
+ import { ServiceCommands } from "./commands/service/index.js";
32
+ import { WorkspaceManager } from "./shared/services/workspace/workspace-manager.service.js";
33
+ import { RuntimeRestartRequestService } from "./shared/services/restart/runtime-restart-request.service.js";
37
34
  import { SkillsCommands } from "./cli/commands/skills/index.js";
38
- import { ServeCommands } from "./cli/commands/serve/index.js";
39
35
  import { GatewayCommands } from "./cli/commands/gateway/index.js";
40
- import { CronCommands } from "./cli/commands/cron/services/cron-commands.service.js";
41
- import "./cli/commands/cron/index.js";
42
- import { CompanionCommands } from "./cli/commands/companion/index.js";
43
- import { ServiceCommands } from "./commands/service/index.js";
44
- import { spawn } from "node:child_process";
45
- import { fileURLToPath } from "node:url";
46
- import { join } from "node:path";
36
+ import { UiCommands } from "./cli/commands/ui/index.js";
37
+ import { StartCommands } from "./cli/commands/start/index.js";
38
+ import { RestartCommands } from "./cli/commands/restart/index.js";
39
+ import { ServeCommands } from "./cli/commands/serve/index.js";
40
+ import { StopCommands } from "./cli/commands/stop/index.js";
41
+ import { LlmUsageCommandService } from "./cli/commands/usage/services/llm-usage-command.service.js";
42
+ import "./cli/commands/usage/index.js";
47
43
  import { APP_NAME, DEFAULT_WORKSPACE_DIR, DEFAULT_WORKSPACE_PATH, expandHome, getConfigPath, getDataDir, getWorkspacePath, loadConfig, resolveConfigSecrets, saveConfig } from "@nextclaw/core";
48
- import { existsSync, mkdirSync } from "node:fs";
44
+ import { NextclawKernel } from "@nextclaw/kernel";
49
45
  import { RemoteRuntimeActions } from "@nextclaw/remote";
50
46
  import { getPluginChannelBindings, resolvePluginChannelMessageToolHints, setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
51
- import { NextclawKernel } from "@nextclaw/kernel";
47
+ import { existsSync, mkdirSync } from "node:fs";
48
+ import { join } from "node:path";
49
+ import { fileURLToPath } from "node:url";
50
+ import { spawn } from "node:child_process";
52
51
  //#region src/service-runtime.service.ts
53
52
  const FORCED_PUBLIC_UI_HOST = "0.0.0.0";
54
53
  var NextclawServiceRuntime = class {
@@ -159,7 +158,6 @@ var NextclawServiceRuntime = class {
159
158
  forcedPublicHost: FORCED_PUBLIC_UI_HOST
160
159
  })),
161
160
  stop: measureStartupSync("cli.runtime.stop_commands", () => new StopCommands({ runtimeCommandService: this.runtimeCommandService })),
162
- companion: measureStartupSync("cli.runtime.companion_commands", () => new CompanionCommands()),
163
161
  usage: measureStartupSync("cli.runtime.usage_commands", () => new LlmUsageCommandService())
164
162
  };
165
163
  };
@@ -1,7 +1,7 @@
1
+ import { parseSessionKey, writeRestartSentinel } from "../services/restart/restart-sentinel.service.js";
1
2
  import { getPackageVersion as getPackageVersion$1 } from "../utils/package/package-manifest.utils.js";
2
3
  import "../utils/cli.utils.js";
3
4
  import { NpmRuntimeUpdateCommandService } from "../../launcher/npm-runtime-update-command.service.js";
4
- import { parseSessionKey, writeRestartSentinel } from "../services/restart/restart-sentinel.service.js";
5
5
  import { ConfigSchema, buildConfigSchema, buildReloadPlan, diffConfigPaths, normalizeInlineSecretRefs, redactConfigObject } from "@nextclaw/core";
6
6
  import { existsSync, readFileSync } from "node:fs";
7
7
  import { createHash } from "node:crypto";
@@ -267,11 +267,9 @@ var GatewayControllerImpl = class {
267
267
  });
268
268
  };
269
269
  updateRun = async (params) => {
270
+ const { note, restartDelayMs, sessionKey, timeoutMs } = params;
270
271
  const versionBefore = getPackageVersion$1();
271
- params.timeoutMs;
272
- const updateCommand = new NpmRuntimeUpdateCommandService();
273
- const downloadedSnapshot = await updateCommand.runManaged({ download: true });
274
- const snapshot = downloadedSnapshot.status === "downloaded" ? await updateCommand.runManaged({ apply: true }) : downloadedSnapshot;
272
+ const snapshot = await new NpmRuntimeUpdateCommandService().runManaged({});
275
273
  if (snapshot.status === "blocked" || snapshot.status === "failed") return {
276
274
  ok: false,
277
275
  error: snapshot.errorMessage ?? snapshot.blockReason ?? "update failed",
@@ -283,12 +281,12 @@ var GatewayControllerImpl = class {
283
281
  }
284
282
  };
285
283
  const versionAfter = getPackageVersion$1();
286
- const delayMs = params.restartDelayMs ?? 0;
284
+ const delayMs = restartDelayMs ?? 0;
287
285
  const sentinelPath = await this.writeRestartSentinelPayload({
288
286
  kind: "update.run",
289
287
  status: "ok",
290
- sessionKey: params.sessionKey,
291
- note: params.note,
288
+ sessionKey,
289
+ note,
292
290
  reason: "update.run",
293
291
  strategy: "runtime-bundle"
294
292
  });
@@ -298,7 +296,7 @@ var GatewayControllerImpl = class {
298
296
  });
299
297
  return {
300
298
  ok: true,
301
- note: params.note ?? null,
299
+ note: note ?? null,
302
300
  restart: {
303
301
  scheduled: true,
304
302
  delayMs
@@ -1,5 +1,5 @@
1
- import { spawn } from "node:child_process";
2
1
  import { dirname, join } from "node:path";
2
+ import { spawn } from "node:child_process";
3
3
  import { readFile, readdir } from "node:fs/promises";
4
4
  //#region src/shared/services/extensions/extension-lifecycle.service.ts
5
5
  const EXTENSION_MANIFEST_FILE = "nextclaw.extension.json";
@@ -1,8 +1,8 @@
1
1
  import { ExtensionLifecycleService, ExtensionManifestDiscoveryService, RunningExtensionProcess } from "./extension-lifecycle.service.js";
2
2
  import { NextclawGatewayRuntime } from "../gateway/nextclaw-gateway-runtime.service.js";
3
3
  import * as NextclawCore from "@nextclaw/core";
4
- import { Ingress } from "@nextclaw/shared";
5
4
  import { PluginChannelBinding, PluginUiMetadata } from "@nextclaw/openclaw-compat";
5
+ import { Ingress } from "@nextclaw/shared";
6
6
 
7
7
  //#region src/shared/services/extensions/service-extension-runtime.service.d.ts
8
8
  type Config$1 = NextclawCore.Config;
@@ -1,10 +1,10 @@
1
- import { resolveDevFirstPartyPluginDir } from "../../../commands/plugin/development-source/first-party-plugin-load-paths.js";
1
+ import { resolveDevFirstPartyPluginDir } from "../../../commands/plugin/development-source/first-party-plugin-load-paths.utils.js";
2
2
  import { ExtensionLifecycleService, ExtensionManifestDiscoveryService } from "./extension-lifecycle.service.js";
3
3
  import { createRequire } from "node:module";
4
- import { fileURLToPath } from "node:url";
5
- import { dirname, join, resolve } from "node:path";
6
4
  import { getDataPath } from "@nextclaw/core";
7
5
  import { existsSync, readFileSync, readdirSync } from "node:fs";
6
+ import { dirname, join, resolve } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
8
  import { randomUUID } from "node:crypto";
9
9
  //#region src/shared/services/extensions/service-extension-runtime.service.ts
10
10
  const EXTENSION_CONFIG_GET_INGRESS_TYPE = "extension.channel.config.get";
@@ -27,13 +27,14 @@ var ExtensionChannelAuthClient = class {
27
27
  verbose
28
28
  }
29
29
  });
30
- start = async ({ accountId, baseUrl }) => await this.params.request({
30
+ start = async (params) => await this.params.request({
31
31
  extensionId: this.params.extensionId,
32
32
  kind: "channel.auth.start",
33
33
  payload: {
34
34
  channelId: this.params.channelId,
35
- accountId,
36
- baseUrl
35
+ accountId: params.accountId,
36
+ baseUrl: params.baseUrl,
37
+ domain: params.domain
37
38
  }
38
39
  });
39
40
  poll = async ({ sessionId }) => await this.params.request({
@@ -1,5 +1,6 @@
1
1
  import { consumeRestartSentinel, formatRestartSentinelMessage, parseSessionKey } from "../restart/restart-sentinel.service.js";
2
- import { resolveSessionRouteCandidate } from "../runtime/service-managed-startup.service.js";
2
+ import { resolveSessionRouteCandidate } from "../runtime/utils/managed-service-routing.utils.js";
3
+ import "../runtime/service-managed-startup.service.js";
3
4
  import { parseAgentScopedSessionKey } from "@nextclaw/core";
4
5
  //#region src/shared/services/gateway/gateway-restart-wake.service.ts
5
6
  function normalizeOptionalString(value) {
@@ -1,18 +1,32 @@
1
1
  import { toExtensionRegistry } from "../../../../commands/plugin/plugin-extension-registry.js";
2
- import { createEmptyPluginRegistry, discoverPluginRegistryStatus, loadPluginRegistryProgressively } from "../../../../commands/plugin/plugin-registry-loader.js";
2
+ import { createEmptyPluginRegistry, discoverPluginRegistryStatus, loadPluginRegistryProgressively } from "../../../../commands/plugin/plugin-registry-loader.utils.js";
3
3
  import { logPluginDiagnostics } from "../../../../commands/plugin/index.js";
4
4
  import { shouldRestartChannelsForPluginReload } from "../../../../commands/plugin/plugin-reload.js";
5
5
  import { logPluginGatewayDiagnostics, pluginGatewayLogger } from "../service-startup-support.service.js";
6
6
  import { getWorkspacePath } from "@nextclaw/core";
7
- import { eventKeys } from "@nextclaw/shared";
8
7
  import { getPluginChannelBindings, getPluginUiMetadataFromRegistry, toPluginConfigView } from "@nextclaw/openclaw-compat";
8
+ import { eventKeys } from "@nextclaw/shared";
9
9
  //#region src/shared/services/gateway/managers/gateway-plugin.manager.ts
10
+ function toManifestChannelRegistrations(channelBindings) {
11
+ return channelBindings.map((binding) => ({
12
+ extensionId: binding.pluginId,
13
+ channel: binding.channel,
14
+ source: "extension-manifest"
15
+ }));
16
+ }
10
17
  function buildSnapshot(registry, extensionContributions) {
11
18
  const extensionChannelIds = new Set(extensionContributions.channelBindings.map((binding) => binding.channelId));
12
19
  const extensionPluginIds = new Set(extensionContributions.uiMetadata.map((metadata) => metadata.id));
20
+ const registryExtensionRegistry = toExtensionRegistry(registry);
13
21
  return {
14
22
  registry,
15
- extensionRegistry: toExtensionRegistry(registry),
23
+ extensionRegistry: {
24
+ ...registryExtensionRegistry,
25
+ channels: [...registryExtensionRegistry.channels.filter((registration) => {
26
+ const channelId = registration.channel.id?.trim();
27
+ return !channelId || !extensionChannelIds.has(channelId);
28
+ }), ...toManifestChannelRegistrations(extensionContributions.channelBindings)]
29
+ },
16
30
  channelBindings: [...getPluginChannelBindings(registry).filter((binding) => !extensionChannelIds.has(binding.channelId)), ...extensionContributions.channelBindings],
17
31
  uiMetadata: [...getPluginUiMetadataFromRegistry(registry).filter((metadata) => !extensionPluginIds.has(metadata.id)), ...extensionContributions.uiMetadata]
18
32
  };
@@ -1,9 +1,9 @@
1
1
  import { createManagedRemoteModuleForUi } from "../../runtime/utils/service-remote-runtime.utils.js";
2
2
  import { GatewayRuntimeDeps } from "../nextclaw-gateway-runtime.service.js";
3
3
  import { Config } from "@nextclaw/core";
4
- import { UiRemoteAccessHost } from "@nextclaw/server";
5
- import { RemoteRuntimeState } from "@nextclaw/remote";
6
4
  import { ConfigManager } from "@nextclaw/kernel";
5
+ import { RemoteRuntimeState } from "@nextclaw/remote";
6
+ import { UiRemoteAccessHost } from "@nextclaw/server";
7
7
 
8
8
  //#region src/shared/services/gateway/managers/gateway-remote.manager.d.ts
9
9
  type RemoteServiceModule$1 = ReturnType<typeof createManagedRemoteModuleForUi>;
@@ -1,5 +1,5 @@
1
- import { createRemoteAccessHost } from "../../ui/service-remote-access.service.js";
2
1
  import { createManagedRemoteModuleForUi } from "../../runtime/utils/service-remote-runtime.utils.js";
2
+ import { createRemoteAccessHost } from "../../ui/service-remote-access.service.js";
3
3
  //#region src/shared/services/gateway/managers/gateway-remote.manager.ts
4
4
  var GatewayRemoteManager = class {
5
5
  remoteModule;
@@ -9,9 +9,9 @@ import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.
9
9
  import { ServiceFileWatcherRegistry } from "./service-startup-support.service.js";
10
10
  import { ServiceExtensionRuntime } from "../extensions/service-extension-runtime.service.js";
11
11
  import * as NextclawCore from "@nextclaw/core";
12
+ import { AgentRuntimeHandle, AutomationManager, ConfigManager, LlmProviderManager, NextclawKernel } from "@nextclaw/kernel";
12
13
  import { MarketplaceApiConfig, UiNcpAgent, UiRuntimeControlHost, UiRuntimeUpdateHost } from "@nextclaw/server";
13
14
  import { EventBus, Ingress } from "@nextclaw/shared";
14
- import { AgentRuntimeHandle, AutomationManager, ConfigManager, LlmProviderManager, NextclawKernel } from "@nextclaw/kernel";
15
15
 
16
16
  //#region src/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts
17
17
  type Config$1 = NextclawCore.Config;
@@ -1,31 +1,31 @@
1
+ import { logStartupTrace, measureStartupAsync, measureStartupSync } from "../../utils/startup-trace.js";
1
2
  import { openBrowser, resolveUiConfig, resolveUiStaticDir } from "../../utils/cli.utils.js";
2
3
  import { NextclawDistributionService } from "../runtime/nextclaw-distribution.service.js";
3
- import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
4
4
  import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
5
- import { logStartupTrace, measureStartupAsync, measureStartupSync } from "../../utils/startup-trace.js";
6
- import { GatewayControllerImpl } from "../../controllers/gateway.controller.js";
7
- import { companionRuntimeService } from "../ui/companion-runtime.service.js";
8
- import { createRuntimeControlHost } from "../ui/runtime-control-host.service.js";
9
- import { NpmRuntimeUpdateHost } from "../ui/npm-runtime-update-host.service.js";
10
- import { ServiceMarketplaceInstaller } from "../marketplace/service-marketplace-installer.service.js";
11
5
  import { resolveChannelConfigView } from "../../../commands/channel/channel-config-view.js";
6
+ import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
7
+ import { GatewayControllerImpl } from "../../controllers/gateway.controller.js";
12
8
  import { ServiceExtensionRuntime } from "../extensions/service-extension-runtime.service.js";
13
9
  import { ServiceFileWatcherRegistry, markLocalUiRuntimeIfStarted, startGatewayRuntimeSupport, watchServiceConfigFile } from "./service-startup-support.service.js";
14
10
  import { GatewayPluginManager } from "./managers/gateway-plugin.manager.js";
15
11
  import { GatewayRemoteManager } from "./managers/gateway-remote.manager.js";
16
12
  import { GatewayRestartWakeService } from "./gateway-restart-wake.service.js";
17
13
  import { createCronJobHandler } from "./cron-job-handler.service.js";
14
+ import { companionRuntimeService } from "../ui/companion-runtime.service.js";
18
15
  import { handleGatewayDeferredStartupError } from "./utils/gateway-runtime-lifecycle.utils.js";
19
16
  import { NextclawApp } from "./nextclaw-app.service.js";
20
17
  import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.js";
21
18
  import { createDeferredUiNcpAgent } from "../session/service-deferred-ncp-agent.service.js";
22
19
  import { installPluginRuntimeBridge } from "../plugin/utils/plugin-runtime-bridge.utils.js";
23
20
  import { wrapStartChannelsWithDevPluginHotReload } from "../plugin/utils/plugin-dev-hot-reload.utils.js";
24
- import { resolve } from "node:path";
21
+ import { ServiceMarketplaceInstaller } from "../marketplace/service-marketplace-installer.service.js";
22
+ import { NpmRuntimeUpdateHost } from "../ui/npm-runtime-update-host.service.js";
23
+ import { createRuntimeControlHost } from "../ui/runtime-control-host.service.js";
25
24
  import * as NextclawCore from "@nextclaw/core";
26
- import { startUiServer } from "@nextclaw/server";
27
- import { setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
28
25
  import { NextclawKernel, runGatewayInboundLoop } from "@nextclaw/kernel";
26
+ import { setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
27
+ import { resolve } from "node:path";
28
+ import { startUiServer } from "@nextclaw/server";
29
29
  import { setImmediate } from "node:timers/promises";
30
30
  //#region src/shared/services/gateway/nextclaw-gateway-runtime.service.ts
31
31
  const { getConfigPath: getConfigPath$1, getDataDir: getDataDir$1, getWorkspacePath: getWorkspacePath$1, saveConfig: saveConfig$1 } = NextclawCore;
@@ -1,5 +1,5 @@
1
- import { BootstrapRemoteState, BootstrapStatusView } from "@nextclaw/server";
2
1
  import { RemoteRuntimeState } from "@nextclaw/remote";
2
+ import { BootstrapRemoteState, BootstrapStatusView } from "@nextclaw/server";
3
3
 
4
4
  //#region src/shared/services/gateway/service-bootstrap-status.service.d.ts
5
5
  declare class ServiceBootstrapStatusStore {
@@ -1,7 +1,7 @@
1
1
  import { Config } from "@nextclaw/core";
2
+ import { AutomationManager } from "@nextclaw/kernel";
2
3
  import { RemoteServiceModule } from "@nextclaw/remote";
3
4
  import { PluginDiagnostic } from "@nextclaw/openclaw-compat";
4
- import { AutomationManager } from "@nextclaw/kernel";
5
5
  import { FSWatcher } from "chokidar";
6
6
 
7
7
  //#region src/shared/services/gateway/service-startup-support.service.d.ts
@@ -1,9 +1,9 @@
1
- import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
2
1
  import { disablePluginMutation, enablePluginMutation, installPluginMutation, uninstallPluginMutation } from "../../../commands/plugin/plugin-mutation-actions.js";
2
+ import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
3
3
  import { ServiceMcpMarketplaceOps } from "./service-mcp-marketplace-ops.js";
4
- import { join } from "node:path";
5
4
  import { getWorkspacePath, loadConfig } from "@nextclaw/core";
6
5
  import { existsSync, rmSync } from "node:fs";
6
+ import { join } from "node:path";
7
7
  //#region src/shared/services/marketplace/service-marketplace-installer.service.ts
8
8
  var ServiceMarketplaceInstaller = class {
9
9
  constructor(deps) {
@@ -1,6 +1,6 @@
1
1
  import { loadConfig, saveConfig } from "@nextclaw/core";
2
- import { setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
3
2
  import { dispatchPromptOverNcp } from "@nextclaw/kernel";
3
+ import { setPluginRuntimeBridge } from "@nextclaw/openclaw-compat";
4
4
  //#region src/shared/services/plugin/utils/plugin-runtime-bridge.utils.ts
5
5
  function installPluginRuntimeBridge(gateway) {
6
6
  setPluginRuntimeBridge({
@@ -1,6 +1,6 @@
1
- import { resolve } from "node:path";
2
1
  import { getDataDir } from "@nextclaw/core";
3
2
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
4
  //#region src/shared/services/restart/restart-sentinel.service.ts
5
5
  const RESTART_SENTINEL_FILENAME = "restart-sentinel.json";
6
6
  const PENDING_SYSTEM_EVENTS_KEY = "pending_system_events";
@@ -9,6 +9,8 @@ type Config$1 = NextclawCore.Config;
9
9
  declare class RuntimeCommandService {
10
10
  private deps;
11
11
  private loggingInstalled;
12
+ private processExitLoggingInstalled;
13
+ private readonly runtimeLogger;
12
14
  private readonly managedServiceCommandService;
13
15
  constructor(deps: {
14
16
  requestRestart: (params: RequestRestartParams) => Promise<void>;
@@ -29,6 +31,7 @@ declare class RuntimeCommandService {
29
31
  private runCliSubcommand;
30
32
  private runCommand;
31
33
  private ensureRuntimeLoggingInstalled;
34
+ private installProcessExitLogging;
32
35
  private checkUiPortPreflight;
33
36
  private printPublicUiUrls;
34
37
  private printServiceControlHints;
@@ -1,17 +1,19 @@
1
1
  import { isLoopbackHost, resolvePublicIp, resolveUiStaticDir } from "../../utils/cli.utils.js";
2
2
  import { NextclawDistributionService } from "./nextclaw-distribution.service.js";
3
- import { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from "../../utils/service-port-probe.utils.js";
4
- import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
5
3
  import { resolveCliSubcommandEntry } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
4
+ import { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from "../../utils/service-port-probe.utils.js";
6
5
  import { ManagedServiceCommandService } from "./service-managed-startup.service.js";
6
+ import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
7
7
  import { NextclawGatewayRuntime } from "../gateway/nextclaw-gateway-runtime.service.js";
8
8
  import { createSkillsLoader } from "./utils/skills-loader.utils.js";
9
- import { spawn } from "node:child_process";
10
9
  import * as NextclawCore from "@nextclaw/core";
10
+ import { spawn } from "node:child_process";
11
11
  //#region src/shared/services/runtime/runtime-command.service.ts
12
12
  const { getWorkspacePath: getWorkspacePath$1, loadConfig: loadConfig$1 } = NextclawCore;
13
13
  var RuntimeCommandService = class {
14
14
  loggingInstalled = false;
15
+ processExitLoggingInstalled = false;
16
+ runtimeLogger = NextclawCore.getAppLogger("service.runtime");
15
17
  managedServiceCommandService = new ManagedServiceCommandService({
16
18
  startGateway: async (options) => await this.startGateway(options),
17
19
  printPublicUiUrls: async (host, port) => await this.printPublicUiUrls(host, port),
@@ -24,6 +26,12 @@ var RuntimeCommandService = class {
24
26
  }
25
27
  startGateway = async (options = {}) => {
26
28
  this.ensureRuntimeLoggingInstalled();
29
+ this.installProcessExitLogging();
30
+ this.runtimeLogger.info("runtime.process.started", {
31
+ runtimeKind: "serve-process",
32
+ pid: process.pid,
33
+ source: "RuntimeCommandService.startGateway"
34
+ });
27
35
  await new NextclawGatewayRuntime({
28
36
  requestRestart: this.deps.requestRestart,
29
37
  initializeAgentHomeDirectory: this.deps.initializeAgentHomeDirectory,
@@ -32,6 +40,11 @@ var RuntimeCommandService = class {
32
40
  runCliSubcommand: this.runCliSubcommand,
33
41
  installBuiltinMarketplaceSkill: this.installBuiltinMarketplaceSkill
34
42
  }, { ...options }).start();
43
+ this.runtimeLogger.info("runtime.process.ready", {
44
+ runtimeKind: "serve-process",
45
+ pid: process.pid,
46
+ source: "RuntimeCommandService.startGateway"
47
+ });
35
48
  };
36
49
  startService = async (options) => {
37
50
  await this.managedServiceCommandService.startService(options);
@@ -115,6 +128,17 @@ var RuntimeCommandService = class {
115
128
  });
116
129
  this.loggingInstalled = true;
117
130
  };
131
+ installProcessExitLogging = () => {
132
+ if (this.processExitLoggingInstalled) return;
133
+ this.processExitLoggingInstalled = true;
134
+ process.once("exit", (code) => {
135
+ this.runtimeLogger.warn("runtime.process.exited", {
136
+ runtimeKind: "serve-process",
137
+ pid: process.pid,
138
+ code
139
+ });
140
+ });
141
+ };
118
142
  checkUiPortPreflight = async (params) => {
119
143
  const target = await inspectUiTarget(params);
120
144
  if (target.state === "available") return {
@@ -1,7 +1,6 @@
1
- import { ManagedServiceState } from "../../stores/managed-service-state.store.js";
2
- import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
3
- import { spawn } from "node:child_process";
1
+ import { ManagedServiceSnapshot, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate } from "./utils/managed-service-routing.utils.js";
4
2
  import * as NextclawCore from "@nextclaw/core";
3
+ import { spawn } from "node:child_process";
5
4
 
6
5
  //#region src/shared/services/runtime/service-managed-startup.service.d.ts
7
6
  type Config$1 = NextclawCore.Config;
@@ -10,30 +9,6 @@ type StartServiceOptions = {
10
9
  open: boolean;
11
10
  startupTimeoutMs?: number;
12
11
  };
13
- type ManagedServiceSnapshot = {
14
- pid: number;
15
- uiUrl: string;
16
- apiUrl: string;
17
- uiHost: string;
18
- uiPort: number;
19
- logPath: string;
20
- };
21
- declare function resolveManagedServiceReadySnapshot(params: {
22
- snapshot: ManagedServiceSnapshot;
23
- readLocalUiRuntimeState?: typeof localUiRuntimeStore.read;
24
- isProcessRunningFn?: (pid: number) => boolean;
25
- }): ManagedServiceSnapshot;
26
- declare function resolveManagedServiceUiBinding(state: ManagedServiceState): {
27
- host: string;
28
- port: number;
29
- };
30
- declare function resolveSessionRouteCandidate(params: {
31
- session: unknown;
32
- normalizeOptionalString: (value: unknown) => string | undefined;
33
- }): {
34
- key: string;
35
- updatedAt: number;
36
- } | null;
37
12
  declare function spawnManagedService(params: {
38
13
  appName: string;
39
14
  config: NextclawCore.Config;
@@ -109,6 +84,7 @@ declare class ManagedServiceCommandService {
109
84
  private readonly deps;
110
85
  private readonly loggingRuntime;
111
86
  private readonly serviceLogger;
87
+ private readonly startupLogger;
112
88
  constructor(deps: {
113
89
  startGateway: (options: {
114
90
  uiOverrides: Partial<Config$1["ui"]>;
@@ -144,4 +120,4 @@ declare class ManagedServiceCommandService {
144
120
  private printStartupFailureDiagnostics;
145
121
  }
146
122
  //#endregion
147
- export { ManagedServiceCommandService, ManagedServiceSnapshot, StartServiceOptions, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate, spawnManagedService, waitForManagedServiceReadiness };
123
+ export { ManagedServiceCommandService, StartServiceOptions, reportManagedServiceStart, resolveManagedServiceReadySnapshot, resolveManagedServiceUiBinding, resolveSessionRouteCandidate, spawnManagedService, waitForManagedServiceReadiness };