@nextclaw/service 0.1.3 → 0.1.5

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 (22) hide show
  1. package/dist/cli/commands/diagnostics/services/diagnostics-commands.service.js +1 -1
  2. package/dist/commands/remote/index.d.ts +1 -1
  3. package/dist/commands/remote/index.js +1 -1
  4. package/dist/commands/remote/{services/remote-runtime-support.service.d.ts → utils/remote-runtime-support.utils.d.ts} +2 -2
  5. package/dist/commands/remote/{services/remote-runtime-support.service.js → utils/remote-runtime-support.utils.js} +4 -3
  6. package/dist/launcher/npm-runtime-update-command.service.d.ts +2 -1
  7. package/dist/launcher/npm-runtime-update-command.service.js +1 -1
  8. package/dist/launcher/npm-runtime-update-source.service.d.ts +2 -0
  9. package/dist/launcher/npm-runtime-update-source.service.js +3 -1
  10. package/dist/service-runtime.service.d.ts +2 -0
  11. package/dist/service-runtime.service.js +7 -2
  12. package/dist/shared/services/gateway/managers/gateway-remote.manager.d.ts +5 -3
  13. package/dist/shared/services/gateway/managers/gateway-remote.manager.js +3 -2
  14. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +1 -1
  15. package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +3 -5
  16. package/dist/shared/services/gateway/{service-bootstrap-status.d.ts → service-bootstrap-status.service.d.ts} +3 -4
  17. package/dist/shared/services/gateway/{service-bootstrap-status.js → service-bootstrap-status.service.js} +5 -15
  18. package/dist/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.d.ts +1 -1
  19. package/dist/shared/services/runtime/service-managed-startup.service.js +1 -1
  20. package/dist/shared/services/runtime/{service-remote-runtime.service.d.ts → utils/service-remote-runtime.utils.d.ts} +5 -3
  21. package/dist/shared/services/runtime/{service-remote-runtime.service.js → utils/service-remote-runtime.utils.js} +6 -5
  22. package/package.json +18 -18
@@ -1,6 +1,6 @@
1
1
  import { isProcessRunning, resolveUiApiBase, resolveUiConfig } from "../../../../shared/utils/cli.utils.js";
2
2
  import { managedServiceStateStore } from "../../../../shared/stores/managed-service-state.store.js";
3
- import { resolveNextclawRemoteStatusSnapshot } from "../../../../commands/remote/services/remote-runtime-support.service.js";
3
+ import { resolveNextclawRemoteStatusSnapshot } from "../../../../commands/remote/utils/remote-runtime-support.utils.js";
4
4
  import "../../../../commands/remote/index.js";
5
5
  import { printDoctorReport, printStatusReport } from "../utils/diagnostics-render.utils.js";
6
6
  import { APP_NAME, getConfigPath, getWorkspacePath, hasSecretRef, loadConfig, resolveAppLogPath } from "@nextclaw/core";
@@ -1,4 +1,4 @@
1
- import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot } from "./services/remote-runtime-support.service.js";
1
+ import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot } from "./utils/remote-runtime-support.utils.js";
2
2
  import { buildPlatformApiBaseErrorMessage, resolvePlatformApiBase } from "./utils/platform-api-base.utils.js";
3
3
  import { Config } from "@nextclaw/core";
4
4
  import { RemoteConnectCommandOptions, RemoteDoctorCommandOptions, RemoteEnableCommandOptions, RemoteStatusCommandOptions, RemoteStatusSnapshot } from "@nextclaw/remote";
@@ -1,6 +1,6 @@
1
1
  import { localUiDiscoveryService } from "../../shared/services/ui/local-ui-discovery.service.js";
2
2
  import { buildPlatformApiBaseErrorMessage, resolvePlatformApiBase } from "./utils/platform-api-base.utils.js";
3
- import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot } from "./services/remote-runtime-support.service.js";
3
+ import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot } from "./utils/remote-runtime-support.utils.js";
4
4
  import { getConfigPath, loadConfig, saveConfig } from "@nextclaw/core";
5
5
  import { readPlatformSessionTokenState } from "@nextclaw/remote";
6
6
  import { hostname } from "node:os";
@@ -1,13 +1,13 @@
1
1
  import { Config } from "@nextclaw/core";
2
2
  import { RemoteConnector, RemoteLogger, RemotePlatformClient, RemoteRuntimeState, RemoteStatusSnapshot, RemoteStatusStore } from "@nextclaw/remote";
3
3
 
4
- //#region src/commands/remote/services/remote-runtime-support.service.d.ts
4
+ //#region src/commands/remote/utils/remote-runtime-support.utils.d.ts
5
5
  declare function hasRunningNextclawManagedService(): boolean;
6
6
  declare function createNextclawRemotePlatformClient(): RemotePlatformClient;
7
7
  declare function createNextclawRemoteConnector(params?: {
8
8
  logger?: RemoteLogger;
9
9
  }): RemoteConnector;
10
- declare function createNextclawRemoteStatusStore(mode: RemoteRuntimeState["mode"]): RemoteStatusStore;
10
+ declare function createNextclawRemoteStatusStore(mode: RemoteRuntimeState["mode"], onChange?: (next: RemoteRuntimeState) => void): RemoteStatusStore;
11
11
  declare function buildNextclawConfiguredRemoteState(config: Config): RemoteRuntimeState;
12
12
  declare function readCurrentNextclawRemoteRuntimeState(): RemoteRuntimeState | null;
13
13
  declare function resolveNextclawRemoteStatusSnapshot(config: Config): RemoteStatusSnapshot;
@@ -2,10 +2,10 @@ import { getPackageVersion as getPackageVersion$1 } from "../../../shared/utils/
2
2
  import { isProcessRunning } from "../../../shared/utils/cli.utils.js";
3
3
  import { localUiRuntimeStore } from "../../../shared/stores/local-ui-runtime.store.js";
4
4
  import { managedServiceStateStore } from "../../../shared/stores/managed-service-state.store.js";
5
- import { resolvePlatformApiBase } from "../utils/platform-api-base.utils.js";
5
+ import { resolvePlatformApiBase } from "./platform-api-base.utils.js";
6
6
  import { getConfigPath, getDataDir, loadConfig } from "@nextclaw/core";
7
7
  import { RemoteConnector, RemotePlatformClient, RemoteStatusStore, buildConfiguredRemoteState, resolveRemoteStatusSnapshot } from "@nextclaw/remote";
8
- //#region src/commands/remote/services/remote-runtime-support.service.ts
8
+ //#region src/commands/remote/utils/remote-runtime-support.utils.ts
9
9
  let currentProcessRemoteRuntimeState = null;
10
10
  function hasRunningNextclawManagedService() {
11
11
  const state = managedServiceStateStore.read();
@@ -37,9 +37,10 @@ function createNextclawRemoteConnector(params = {}) {
37
37
  logger: params.logger
38
38
  });
39
39
  }
40
- function createNextclawRemoteStatusStore(mode) {
40
+ function createNextclawRemoteStatusStore(mode, onChange) {
41
41
  return new RemoteStatusStore(mode, { writeRemoteState: (next) => {
42
42
  currentProcessRemoteRuntimeState = next;
43
+ onChange?.(next);
43
44
  if (localUiRuntimeStore.read()?.pid === process.pid) localUiRuntimeStore.update((state) => ({
44
45
  ...state,
45
46
  remote: next
@@ -1,9 +1,10 @@
1
1
  import { UpdateCommandOptions } from "../shared/types/cli.types.js";
2
- import { UpdateSnapshot } from "@nextclaw/kernel/update-contract";
2
+ import { UpdateSnapshot } from "@nextclaw/kernel";
3
3
 
4
4
  //#region src/launcher/npm-runtime-update-command.service.d.ts
5
5
  type NpmRuntimeUpdateCommandServiceOptions = {
6
6
  launcherVersion?: string;
7
+ packagedPublicKeyPath?: string;
7
8
  };
8
9
  declare class NpmRuntimeUpdateCommandService {
9
10
  private readonly options;
@@ -18,7 +18,7 @@ var NpmRuntimeUpdateCommandService = class {
18
18
  return snapshot;
19
19
  };
20
20
  runManaged = async (opts) => {
21
- const source = new NpmRuntimeUpdateSourceService();
21
+ const source = new NpmRuntimeUpdateSourceService({ packagedPublicKeyPath: this.options.packagedPublicKeyPath });
22
22
  const launcherVersion = this.options.launcherVersion ?? getPackageVersion();
23
23
  const channel = source.resolveChannel(opts.channel, launcherVersion);
24
24
  const manifestUrl = source.resolveManifestUrl(channel, opts.manifestUrl);
@@ -4,12 +4,14 @@ type NpmRuntimeUpdateSourceServiceOptions = {
4
4
  env?: NodeJS.ProcessEnv;
5
5
  platform?: NodeJS.Platform;
6
6
  arch?: string;
7
+ packagedPublicKeyPath?: string;
7
8
  };
8
9
  declare function inferDefaultNpmRuntimeReleaseChannel(launcherVersion?: string | null): NpmRuntimeReleaseChannel;
9
10
  declare class NpmRuntimeUpdateSourceService {
10
11
  private readonly env;
11
12
  private readonly platform;
12
13
  private readonly arch;
14
+ private readonly packagedPublicKeyPath?;
13
15
  constructor(options?: NpmRuntimeUpdateSourceServiceOptions);
14
16
  resolveChannel: (explicitChannel?: unknown, launcherVersion?: string | null) => NpmRuntimeReleaseChannel;
15
17
  resolveManifestUrl: (channel: NpmRuntimeReleaseChannel, explicitManifestUrl?: unknown) => string | null;
@@ -27,10 +27,12 @@ var NpmRuntimeUpdateSourceService = class {
27
27
  env;
28
28
  platform;
29
29
  arch;
30
+ packagedPublicKeyPath;
30
31
  constructor(options = {}) {
31
32
  this.env = options.env ?? process.env;
32
33
  this.platform = options.platform ?? process.platform;
33
34
  this.arch = options.arch ?? process.arch;
35
+ this.packagedPublicKeyPath = options.packagedPublicKeyPath;
34
36
  }
35
37
  resolveChannel = (explicitChannel, launcherVersion) => {
36
38
  if (explicitChannel !== void 0 || this.env.NEXTCLAW_UPDATE_CHANNEL !== void 0) return normalizeChannel(explicitChannel ?? this.env.NEXTCLAW_UPDATE_CHANNEL);
@@ -47,7 +49,7 @@ var NpmRuntimeUpdateSourceService = class {
47
49
  if (explicitPublicKey) return explicitPublicKey;
48
50
  const publicKeyPath = normalizeOptionalString(this.env.NEXTCLAW_UPDATE_BUNDLE_PUBLIC_KEY_PATH);
49
51
  if (!publicKeyPath || !existsSync(publicKeyPath)) {
50
- const packagedPublicKeyPath = resolvePackagedPublicKeyPath();
52
+ const packagedPublicKeyPath = this.packagedPublicKeyPath ?? resolvePackagedPublicKeyPath();
51
53
  return existsSync(packagedPublicKeyPath) ? readFileSync(packagedPublicKeyPath, "utf8").trim() : null;
52
54
  }
53
55
  return readFileSync(publicKeyPath, "utf8").trim();
@@ -24,6 +24,7 @@ import { RemoteRuntimeActions } from "@nextclaw/remote";
24
24
  type NextclawServiceRuntimeOptions = {
25
25
  logo?: string;
26
26
  version?: string;
27
+ packagedPublicKeyPath?: string;
27
28
  };
28
29
  type NextclawServiceRuntimeAccount = {
29
30
  status: (opts?: {
@@ -60,6 +61,7 @@ type NextclawServiceCommands = {
60
61
  declare class NextclawServiceRuntime {
61
62
  private logo;
62
63
  private productVersion;
64
+ private packagedPublicKeyPath?;
63
65
  private restartCoordinator;
64
66
  private serviceRestartTask;
65
67
  private selfRelaunchArmed;
@@ -6,7 +6,7 @@ import { managedServiceStateStore } from "./shared/stores/managed-service-state.
6
6
  import { logStartupTrace, measureStartupSync } from "./shared/utils/startup-trace.js";
7
7
  import { createTopLevelNextclawCommandEnv } from "./shared/utils/top-level-nextclaw-command-env.utils.js";
8
8
  import { writeRestartSentinel } from "./shared/services/restart/restart-sentinel.service.js";
9
- import { hasRunningNextclawManagedService } from "./commands/remote/services/remote-runtime-support.service.js";
9
+ import { hasRunningNextclawManagedService } from "./commands/remote/utils/remote-runtime-support.utils.js";
10
10
  import { RemoteCommands } from "./commands/remote/index.js";
11
11
  import { PlatformAuthCommands } from "./commands/platform-auth/services/platform-auth-commands.service.js";
12
12
  import "./commands/platform-auth/index.js";
@@ -54,6 +54,7 @@ const FORCED_PUBLIC_UI_HOST = "0.0.0.0";
54
54
  var NextclawServiceRuntime = class {
55
55
  logo;
56
56
  productVersion;
57
+ packagedPublicKeyPath;
57
58
  restartCoordinator;
58
59
  serviceRestartTask = null;
59
60
  selfRelaunchArmed = false;
@@ -68,6 +69,7 @@ var NextclawServiceRuntime = class {
68
69
  logStartupTrace("cli.runtime.constructor.begin");
69
70
  this.logo = options.logo ?? "🤖";
70
71
  this.productVersion = options.version ?? getPackageVersion$1();
72
+ this.packagedPublicKeyPath = options.packagedPublicKeyPath;
71
73
  this.workspaceManager = measureStartupSync("cli.runtime.workspace_manager", () => new WorkspaceManager(this.logo));
72
74
  this.runtimeCommandService = measureStartupSync("cli.runtime.runtime_command_service", () => new RuntimeCommandService({
73
75
  requestRestart: (params) => this.requestRestart(params),
@@ -381,7 +383,10 @@ var NextclawServiceRuntime = class {
381
383
  update = async (opts) => {
382
384
  const versionBefore = this.version;
383
385
  if (!opts.json) console.log(`Current npm launcher version: ${versionBefore}`);
384
- const snapshot = await new NpmRuntimeUpdateCommandService({ launcherVersion: versionBefore }).run(opts);
386
+ const snapshot = await new NpmRuntimeUpdateCommandService({
387
+ launcherVersion: versionBefore,
388
+ packagedPublicKeyPath: this.packagedPublicKeyPath
389
+ }).run(opts);
385
390
  if (snapshot.status === "blocked" || snapshot.status === "failed") process.exit(1);
386
391
  const state = managedServiceStateStore.read();
387
392
  if (snapshot.requiresRestart && state && isProcessRunning(state.pid)) console.log(`Tip: restart ${APP_NAME} to apply the update.`);
@@ -1,18 +1,20 @@
1
- import { createManagedRemoteModuleForUi } from "../../runtime/service-remote-runtime.service.js";
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
4
  import { UiRemoteAccessHost } from "@nextclaw/server";
5
+ import { RemoteRuntimeState } from "@nextclaw/remote";
5
6
  import { ConfigManager } from "@nextclaw/kernel";
6
7
 
7
8
  //#region src/shared/services/gateway/managers/gateway-remote.manager.d.ts
8
- type RemoteServiceModule = ReturnType<typeof createManagedRemoteModuleForUi>;
9
+ type RemoteServiceModule$1 = ReturnType<typeof createManagedRemoteModuleForUi>;
9
10
  declare class GatewayRemoteManager {
10
- readonly remoteModule: RemoteServiceModule;
11
+ readonly remoteModule: RemoteServiceModule$1;
11
12
  readonly remoteAccess: UiRemoteAccessHost;
12
13
  constructor(params: {
13
14
  deps: GatewayRuntimeDeps;
14
15
  configManager: ConfigManager;
15
16
  uiConfig: Config["ui"];
17
+ onRemoteStateChange?: (state: RemoteRuntimeState) => void;
16
18
  });
17
19
  stop: () => Promise<void>;
18
20
  }
@@ -1,5 +1,5 @@
1
1
  import { createRemoteAccessHost } from "../../ui/service-remote-access.service.js";
2
- import { createManagedRemoteModuleForUi } from "../../runtime/service-remote-runtime.service.js";
2
+ import { createManagedRemoteModuleForUi } from "../../runtime/utils/service-remote-runtime.utils.js";
3
3
  //#region src/shared/services/gateway/managers/gateway-remote.manager.ts
4
4
  var GatewayRemoteManager = class {
5
5
  remoteModule;
@@ -8,7 +8,8 @@ var GatewayRemoteManager = class {
8
8
  const { configManager, deps, uiConfig } = params;
9
9
  this.remoteModule = createManagedRemoteModuleForUi({
10
10
  loadConfig: configManager.loadConfig,
11
- uiConfig
11
+ uiConfig,
12
+ onRemoteStateChange: params.onRemoteStateChange
12
13
  });
13
14
  this.remoteAccess = createRemoteAccessHost({
14
15
  serviceCommands: deps,
@@ -4,7 +4,7 @@ import { GatewayPluginManager } from "./managers/gateway-plugin.manager.js";
4
4
  import { GatewayRemoteManager } from "./managers/gateway-remote.manager.js";
5
5
  import { GatewayRestartWakeService } from "./gateway-restart-wake.service.js";
6
6
  import { UiStartupHandle } from "./nextclaw-app.service.js";
7
- import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.js";
7
+ import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.js";
8
8
  import { ServiceFileWatcherRegistry } from "./service-startup-support.service.js";
9
9
  import { ServiceExtensionRuntime } from "../extensions/service-extension-runtime.service.js";
10
10
  import * as NextclawCore from "@nextclaw/core";
@@ -17,7 +17,7 @@ import { GatewayRestartWakeService } from "./gateway-restart-wake.service.js";
17
17
  import { createCronJobHandler } from "./cron-job-handler.service.js";
18
18
  import { handleGatewayDeferredStartupError } from "./utils/gateway-runtime-lifecycle.utils.js";
19
19
  import { NextclawApp } from "./nextclaw-app.service.js";
20
- import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.js";
20
+ import { ServiceBootstrapStatusStore } from "./service-bootstrap-status.service.js";
21
21
  import { createDeferredUiNcpAgent } from "../session/service-deferred-ncp-agent.service.js";
22
22
  import { installPluginRuntimeBridge } from "../plugin/utils/plugin-runtime-bridge.utils.js";
23
23
  import { wrapStartChannelsWithDevPluginHotReload } from "../plugin/utils/plugin-dev-hot-reload.utils.js";
@@ -91,7 +91,8 @@ var NextclawGatewayRuntime = class {
91
91
  this.remoteManager = new GatewayRemoteManager({
92
92
  deps: this.deps,
93
93
  configManager: this.configManager,
94
- uiConfig: this.uiConfig
94
+ uiConfig: this.uiConfig,
95
+ onRemoteStateChange: (state) => this.bootstrapStatus.syncRemoteRuntimeState(state)
95
96
  });
96
97
  this.marketplace = this.createMarketplace();
97
98
  this.runtimeControl = createRuntimeControlHost({
@@ -143,8 +144,6 @@ var NextclawGatewayRuntime = class {
143
144
  };
144
145
  createBootstrapStatus = () => {
145
146
  const bootstrapStatus = new ServiceBootstrapStatusStore();
146
- bootstrapStatus.markNcpAgentPending();
147
- bootstrapStatus.markPluginHydrationPending();
148
147
  bootstrapStatus.markChannelsPending();
149
148
  bootstrapStatus.setRemoteState(this.configManager.config.remote.enabled ? "pending" : "disabled");
150
149
  return bootstrapStatus;
@@ -240,7 +239,6 @@ var NextclawGatewayRuntime = class {
240
239
  if (enabledChannels.length > 0) console.log(`✓ Channels enabled: ${enabledChannels.join(", ")}`);
241
240
  else console.log("Warning: No channels enabled");
242
241
  this.bootstrapStatus.markChannelsReady(enabledChannels);
243
- this.bootstrapStatus.markReady();
244
242
  };
245
243
  createMarketplace = () => ({
246
244
  apiBaseUrl: process.env.NEXTCLAW_MARKETPLACE_API_BASE,
@@ -1,15 +1,14 @@
1
1
  import { BootstrapRemoteState, BootstrapStatusView } from "@nextclaw/server";
2
+ import { RemoteRuntimeState } from "@nextclaw/remote";
2
3
 
3
- //#region src/shared/services/gateway/service-bootstrap-status.d.ts
4
+ //#region src/shared/services/gateway/service-bootstrap-status.service.d.ts
4
5
  declare class ServiceBootstrapStatusStore {
5
6
  private state;
6
7
  getStatus(): BootstrapStatusView;
7
8
  markShellReady(): void;
8
- markNcpAgentPending(): void;
9
9
  markNcpAgentRunning(): void;
10
10
  markNcpAgentReady(): void;
11
11
  markNcpAgentError(error: string): void;
12
- markPluginHydrationPending(): void;
13
12
  markPluginHydrationRunning(params: {
14
13
  totalPluginCount: number;
15
14
  }): void;
@@ -26,7 +25,7 @@ declare class ServiceBootstrapStatusStore {
26
25
  markChannelsReady(enabled: string[]): void;
27
26
  markChannelsError(error: string): void;
28
27
  setRemoteState(state: BootstrapRemoteState, message?: string): void;
29
- markReady(): void;
28
+ syncRemoteRuntimeState(runtime: RemoteRuntimeState): void;
30
29
  markError(error: string): void;
31
30
  }
32
31
  //#endregion
@@ -1,4 +1,4 @@
1
- //#region src/shared/services/gateway/service-bootstrap-status.ts
1
+ //#region src/shared/services/gateway/service-bootstrap-status.service.ts
2
2
  function now() {
3
3
  return (/* @__PURE__ */ new Date()).toISOString();
4
4
  }
@@ -33,9 +33,6 @@ var ServiceBootstrapStatusStore = class {
33
33
  this.state.phase = "shell-ready";
34
34
  this.state.shellReadyAt = this.state.shellReadyAt ?? now();
35
35
  }
36
- markNcpAgentPending() {
37
- this.state.ncpAgent = { state: "pending" };
38
- }
39
36
  markNcpAgentRunning() {
40
37
  this.state.ncpAgent = {
41
38
  state: "running",
@@ -60,14 +57,6 @@ var ServiceBootstrapStatusStore = class {
60
57
  error
61
58
  };
62
59
  }
63
- markPluginHydrationPending() {
64
- this.state.pluginHydration = {
65
- ...this.state.pluginHydration,
66
- state: "pending",
67
- loadedPluginCount: 0,
68
- totalPluginCount: 0
69
- };
70
- }
71
60
  markPluginHydrationRunning(params) {
72
61
  this.state.phase = "hydrating-capabilities";
73
62
  this.state.pluginHydration = {
@@ -139,9 +128,10 @@ var ServiceBootstrapStatusStore = class {
139
128
  ...message ? { message } : {}
140
129
  };
141
130
  }
142
- markReady() {
143
- this.state.phase = "ready";
144
- this.state.lastError = void 0;
131
+ syncRemoteRuntimeState(runtime) {
132
+ const message = runtime.lastError?.trim() || void 0;
133
+ const state = runtime.state === "connected" ? "ready" : runtime.state === "disabled" ? "disabled" : runtime.state === "error" && message?.includes("already owned") ? "conflict" : runtime.state === "error" ? "error" : "pending";
134
+ this.setRemoteState(state, message);
145
135
  }
146
136
  markError(error) {
147
137
  this.state.phase = "error";
@@ -1,4 +1,4 @@
1
- import { ServiceBootstrapStatusStore } from "../service-bootstrap-status.js";
1
+ import { ServiceBootstrapStatusStore } from "../service-bootstrap-status.service.js";
2
2
 
3
3
  //#region src/shared/services/gateway/utils/gateway-runtime-lifecycle.utils.d.ts
4
4
  declare function handleGatewayDeferredStartupError(params: {
@@ -4,7 +4,7 @@ import { managedServiceStateStore } from "../../stores/managed-service-state.sto
4
4
  import { probeHealthEndpoint } from "../../utils/service-port-probe.utils.js";
5
5
  import { resolveCliSubcommandLaunch } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
6
6
  import { createTopLevelNextclawCommandEnv } from "../../utils/top-level-nextclaw-command-env.utils.js";
7
- import { writeInitialManagedServiceState, writeReadyManagedServiceState } from "./service-remote-runtime.service.js";
7
+ import { writeInitialManagedServiceState, writeReadyManagedServiceState } from "./utils/service-remote-runtime.utils.js";
8
8
  import { spawn } from "node:child_process";
9
9
  import { dirname } from "node:path";
10
10
  import * as NextclawCore from "@nextclaw/core";
@@ -1,8 +1,8 @@
1
- import { ManagedServiceState } from "../../stores/managed-service-state.store.js";
1
+ import { ManagedServiceState } from "../../../stores/managed-service-state.store.js";
2
2
  import { Config } from "@nextclaw/core";
3
- import { RemoteServiceModule } from "@nextclaw/remote";
3
+ import { RemoteRuntimeState, RemoteServiceModule } from "@nextclaw/remote";
4
4
 
5
- //#region src/shared/services/runtime/service-remote-runtime.service.d.ts
5
+ //#region src/shared/services/runtime/utils/service-remote-runtime.utils.d.ts
6
6
  type ManagedServiceSnapshot = {
7
7
  pid: number;
8
8
  uiUrl: string;
@@ -30,11 +30,13 @@ declare function createManagedRemoteModule(params: {
30
30
  loadConfig: () => Config;
31
31
  uiEnabled: boolean;
32
32
  localOrigin: string;
33
+ onRemoteStateChange?: (state: RemoteRuntimeState) => void;
33
34
  }): RemoteServiceModule | null;
34
35
  declare function createManagedRemoteModuleForUi(params: {
35
36
  loadConfig: () => Config;
36
37
  uiConfig: Pick<Config["ui"], "enabled" | "host" | "port">;
37
38
  localOriginOverride?: string;
39
+ onRemoteStateChange?: (state: RemoteRuntimeState) => void;
38
40
  }): RemoteServiceModule | null;
39
41
  declare function writeInitialManagedServiceState(params: {
40
42
  config: Config;
@@ -1,11 +1,11 @@
1
- import { isProcessRunning, resolveUiApiBase } from "../../utils/cli.utils.js";
2
- import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
3
- import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore } from "../../../commands/remote/services/remote-runtime-support.service.js";
1
+ import { isProcessRunning, resolveUiApiBase } from "../../../utils/cli.utils.js";
2
+ import { managedServiceStateStore } from "../../../stores/managed-service-state.store.js";
3
+ import { buildNextclawConfiguredRemoteState, createNextclawRemoteConnector, createNextclawRemoteStatusStore } from "../../../../commands/remote/utils/remote-runtime-support.utils.js";
4
4
  import { dirname, resolve } from "node:path";
5
5
  import { getDataDir } from "@nextclaw/core";
6
6
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
7
7
  import { RemoteServiceModule } from "@nextclaw/remote";
8
- //#region src/shared/services/runtime/service-remote-runtime.service.ts
8
+ //#region src/shared/services/runtime/utils/service-remote-runtime.utils.ts
9
9
  function resolveRemoteOwnershipLockPath() {
10
10
  return resolve(getDataDir(), "run", "remote-owner.lock.json");
11
11
  }
@@ -117,7 +117,7 @@ function createManagedRemoteModule(params) {
117
117
  loadConfig: params.loadConfig,
118
118
  uiEnabled: params.uiEnabled,
119
119
  localOrigin: params.localOrigin,
120
- statusStore: createNextclawRemoteStatusStore("service"),
120
+ statusStore: createNextclawRemoteStatusStore("service", params.onRemoteStateChange),
121
121
  createConnector: (logger) => createNextclawRemoteConnector({ logger }),
122
122
  claimOwnership: () => claimManagedRemoteRuntimeOwnership({ localOrigin: params.localOrigin }),
123
123
  logger: {
@@ -132,6 +132,7 @@ function createManagedRemoteModuleForUi(params) {
132
132
  return createManagedRemoteModule({
133
133
  loadConfig: params.loadConfig,
134
134
  uiEnabled: params.uiConfig.enabled,
135
+ onRemoteStateChange: params.onRemoteStateChange,
135
136
  localOrigin: explicitLocalOrigin && explicitLocalOrigin.length > 0 ? explicitLocalOrigin.replace(/\/+$/, "") : resolveUiApiBase(params.uiConfig.host, params.uiConfig.port)
136
137
  });
137
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/service",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "description": "NextClaw long-running service host and runtime lifecycle.",
6
6
  "type": "module",
@@ -34,23 +34,23 @@
34
34
  "commander": "^12.1.0",
35
35
  "jszip": "^3.10.1",
36
36
  "yaml": "^2.8.1",
37
- "@nextclaw/kernel": "0.1.3",
38
- "@nextclaw/mcp": "0.1.79",
39
- "@nextclaw/channel-extension-weixin": "0.1.1",
40
- "@nextclaw/core": "0.12.14",
41
- "@nextclaw/ncp-agent-runtime": "0.3.17",
42
- "@nextclaw/ncp-http-agent-server": "0.3.19",
43
- "@nextclaw/ncp-mcp": "0.1.81",
44
- "@nextclaw/ncp": "0.5.7",
45
- "@nextclaw/nextclaw-hermes-acp-bridge": "0.1.6",
46
- "@nextclaw/nextclaw-ncp-runtime-http-client": "0.1.6",
47
- "@nextclaw/ncp-toolkit": "0.5.12",
48
- "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.7",
49
- "@nextclaw/openclaw-compat": "1.0.14",
50
- "@nextclaw/server": "0.12.14",
51
- "@nextclaw/remote": "0.1.91",
52
- "@nextclaw/shared": "0.1.1",
53
- "@nextclaw/runtime": "0.2.46"
37
+ "@nextclaw/mcp": "0.1.80",
38
+ "@nextclaw/kernel": "0.1.4",
39
+ "@nextclaw/channel-extension-weixin": "0.1.2",
40
+ "@nextclaw/core": "0.12.15",
41
+ "@nextclaw/ncp-agent-runtime": "0.3.18",
42
+ "@nextclaw/ncp": "0.5.8",
43
+ "@nextclaw/ncp-mcp": "0.1.82",
44
+ "@nextclaw/nextclaw-hermes-acp-bridge": "0.1.7",
45
+ "@nextclaw/nextclaw-ncp-runtime-http-client": "0.1.7",
46
+ "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.8",
47
+ "@nextclaw/openclaw-compat": "1.0.15",
48
+ "@nextclaw/ncp-toolkit": "0.5.13",
49
+ "@nextclaw/remote": "0.1.92",
50
+ "@nextclaw/ncp-http-agent-server": "0.3.20",
51
+ "@nextclaw/runtime": "0.2.47",
52
+ "@nextclaw/shared": "0.1.2",
53
+ "@nextclaw/server": "0.12.15"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^20.17.6",