@nextclaw/service 0.3.15 → 0.3.17

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.
@@ -30,18 +30,18 @@ declare class RemoteCommands {
30
30
  constructor(deps?: {
31
31
  currentLocalOrigin?: string;
32
32
  });
33
- updateConfig(params?: {
33
+ updateConfig: (params?: {
34
34
  enabled?: boolean;
35
35
  apiBase?: string;
36
36
  name?: string;
37
- }): RemoteConfigChange;
38
- enableConfig(opts?: RemoteEnableCommandOptions): RemoteConfigChange;
39
- disableConfig(): RemoteConfigChange;
40
- connect(opts?: RemoteConnectCommandOptions): Promise<void>;
41
- getStatusView(): RemoteCommandStatusView;
42
- status(opts?: RemoteStatusCommandOptions): Promise<void>;
43
- getDoctorView(): Promise<RemoteCommandDoctorView>;
44
- doctor(opts?: RemoteDoctorCommandOptions): Promise<void>;
37
+ }) => RemoteConfigChange;
38
+ enableConfig: (opts?: RemoteEnableCommandOptions) => RemoteConfigChange;
39
+ disableConfig: () => RemoteConfigChange;
40
+ connect: (opts?: RemoteConnectCommandOptions) => Promise<void>;
41
+ getStatusView: () => RemoteCommandStatusView;
42
+ status: (opts?: RemoteStatusCommandOptions) => Promise<void>;
43
+ getDoctorView: () => Promise<RemoteCommandDoctorView>;
44
+ doctor: (opts?: RemoteDoctorCommandOptions) => Promise<void>;
45
45
  }
46
46
  //#endregion
47
47
  export { RemoteCommandDoctorCheck, RemoteCommandDoctorView, RemoteCommandStatusView, RemoteCommands, buildNextclawConfiguredRemoteState, buildPlatformApiBaseErrorMessage, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot, resolvePlatformApiBase };
@@ -1 +1 @@
1
- {"version":3,"file":"remote-command.controller.d.ts","names":[],"sources":["../../../src/controllers/commands/remote-command.controller.ts"],"mappings":";;;;;;KAyBK,kBAAA;EACH,OAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,uBAAA;EACV,iBAAA;EACA,OAAA,EAAS,oBAAA;EACT,WAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGU,wBAAA;EACV,IAAA;EACA,EAAA;EACA,MAAA;AAAA;AAAA,KAGU,uBAAA;EACV,WAAA;EACA,MAAA,EAAQ,wBAAA;EACR,QAAA,EAAU,oBAAA;AAAA;AAAA,cA4DC,cAAA;EAAA,iBACkB,IAAA;cAAA,IAAA;IAAQ,kBAAA;EAAA;EAErC,YAAA,CAAa,MAAA;IACX,OAAA;IACA,OAAA;IACA,IAAA;EAAA,IACO,kBAAA;EA0BT,YAAA,CAAa,IAAA,GAAM,0BAAA,GAAkC,kBAAA;EAQrD,aAAA,CAAA,GAAiB,kBAAA;EAIX,OAAA,CAAQ,IAAA,GAAM,2BAAA,GAAmC,OAAA;EAQvD,aAAA,CAAA,GAAiB,uBAAA;EAoBX,MAAA,CAAO,IAAA,GAAM,0BAAA,GAAkC,OAAA;EA2B/C,aAAA,CAAA,GAAiB,OAAA,CAAQ,uBAAA;EA0CzB,MAAA,CAAO,IAAA,GAAM,0BAAA,GAAkC,OAAA;AAAA"}
1
+ {"version":3,"file":"remote-command.controller.d.ts","names":[],"sources":["../../../src/controllers/commands/remote-command.controller.ts"],"mappings":";;;;;;KAyBK,kBAAA;EACH,OAAA;EACA,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,uBAAA;EACV,iBAAA;EACA,OAAA,EAAS,oBAAA;EACT,WAAA;EACA,UAAA;EACA,YAAA;AAAA;AAAA,KAGU,wBAAA;EACV,IAAA;EACA,EAAA;EACA,MAAA;AAAA;AAAA,KAGU,uBAAA;EACV,WAAA;EACA,MAAA,EAAQ,wBAAA;EACR,QAAA,EAAU,oBAAA;AAAA;AAAA,cA4FC,cAAA;EAAA,iBACkB,IAAA;cAAA,IAAA;IAAQ,kBAAA;EAAA;EAErC,YAAA,GAAgB,MAAA;IACd,OAAA;IACA,OAAA;IACA,IAAA;EAAA,MACO,kBAAA;EA0BT,YAAA,GACE,IAAA,GAAM,0BAAA,KACL,kBAAA;EAQH,aAAA,QAAoB,kBAAA;EAIpB,OAAA,GAAiB,IAAA,GAAM,2BAAA,KAAmC,OAAA;EAQ1D,aAAA,QAAoB,uBAAA;EAoBpB,MAAA,GAAgB,IAAA,GAAM,0BAAA,KAAkC,OAAA;EA+CxD,aAAA,QAA0B,OAAA,CAAQ,uBAAA;EA2ClC,MAAA,GAAgB,IAAA,GAAM,0BAAA,KAAkC,OAAA;AAAA"}
@@ -54,11 +54,31 @@ function describePlatformTokenCheck(token) {
54
54
  detail: "run remote browser login or \"nextclaw login\" first"
55
55
  };
56
56
  }
57
+ function describeRemoteConnectionStability(runtime) {
58
+ const connection = runtime?.connection;
59
+ if (!connection) return {
60
+ name: "connection-stability",
61
+ ok: false,
62
+ detail: "connection diagnostics unavailable"
63
+ };
64
+ if (connection.disconnectCount === 0) return {
65
+ name: "connection-stability",
66
+ ok: true,
67
+ detail: `no disconnects observed since ${connection.observedSince}`
68
+ };
69
+ const lastDisconnect = connection.lastDisconnect;
70
+ const recovery = connection.lastRecoveredAt ? `; last recovered in ${connection.lastRecoveryDurationMs ?? "unknown"}ms` : "; the latest disconnect has not recovered";
71
+ return {
72
+ name: "connection-stability",
73
+ ok: false,
74
+ detail: `${connection.disconnectCount} disconnect(s) observed since ${connection.observedSince}${lastDisconnect ? `; last ${lastDisconnect.source} at ${lastDisconnect.at}` : ""}` + recovery
75
+ };
76
+ }
57
77
  var RemoteCommands = class {
58
78
  constructor(deps = {}) {
59
79
  this.deps = deps;
60
80
  }
61
- updateConfig(params = {}) {
81
+ updateConfig = (params = {}) => {
62
82
  const config = loadConfig(getConfigPath());
63
83
  const nextEnabled = typeof params.enabled === "boolean" ? params.enabled : config.remote.enabled;
64
84
  const nextPlatformApiBase = typeof params.apiBase === "string" ? params.apiBase.trim() : config.remote.platformApiBase;
@@ -77,24 +97,24 @@ var RemoteCommands = class {
77
97
  changed: config.remote.enabled !== next.remote.enabled || config.remote.platformApiBase !== next.remote.platformApiBase || config.remote.deviceName !== next.remote.deviceName,
78
98
  config: next
79
99
  };
80
- }
81
- enableConfig(opts = {}) {
100
+ };
101
+ enableConfig = (opts = {}) => {
82
102
  return this.updateConfig({
83
103
  enabled: true,
84
104
  apiBase: typeof opts.apiBase === "string" ? opts.apiBase : void 0,
85
105
  name: typeof opts.name === "string" ? opts.name : void 0
86
106
  });
87
- }
88
- disableConfig() {
107
+ };
108
+ disableConfig = () => {
89
109
  return this.updateConfig({ enabled: false });
90
- }
91
- async connect(opts = {}) {
110
+ };
111
+ connect = async (opts = {}) => {
92
112
  await createNextclawRemoteConnector().run({
93
113
  ...opts,
94
114
  mode: "foreground"
95
115
  });
96
- }
97
- getStatusView() {
116
+ };
117
+ getStatusView = () => {
98
118
  const config = loadConfig(getConfigPath());
99
119
  const snapshot = resolveNextclawRemoteStatusSnapshot(config);
100
120
  const resolvedLocalOrigin = snapshot.runtime?.localOrigin ?? this.deps.currentLocalOrigin ?? resolveConfiguredLocalOrigin(config);
@@ -105,8 +125,8 @@ var RemoteCommands = class {
105
125
  deviceName: snapshot.runtime?.deviceName ?? normalizeOptionalString(config.remote.deviceName) ?? hostname(),
106
126
  platformBase: snapshot.runtime?.platformBase ?? normalizeOptionalString(config.remote.platformApiBase) ?? normalizeOptionalString(config.providers.nextclaw?.apiBase) ?? null
107
127
  };
108
- }
109
- async status(opts = {}) {
128
+ };
129
+ status = async (opts = {}) => {
110
130
  const view = this.getStatusView();
111
131
  if (opts.json) {
112
132
  console.log(JSON.stringify(view, null, 2));
@@ -123,8 +143,16 @@ var RemoteCommands = class {
123
143
  if (runtime?.deviceId) console.log(`Device ID: ${runtime.deviceId}`);
124
144
  if (runtime?.lastConnectedAt) console.log(`Last connected: ${runtime.lastConnectedAt}`);
125
145
  if (runtime?.lastError) console.log(`Last error: ${runtime.lastError}`);
126
- }
127
- async getDoctorView() {
146
+ if (runtime?.connection) {
147
+ console.log(`Connection ID: ${runtime.connection.connectionId ?? "none"}`);
148
+ console.log(`Disconnects observed: ${runtime.connection.disconnectCount}`);
149
+ console.log(`Heartbeat: ${runtime.connection.heartbeatSupported ? "acknowledged" : "compatibility mode"}`);
150
+ if (runtime.connection.lastDisconnect) console.log(`Last disconnect: ${runtime.connection.lastDisconnect.source} at ${runtime.connection.lastDisconnect.at}`);
151
+ if (runtime.connection.lastRecoveredAt) console.log(`Last recovery: ${runtime.connection.lastRecoveredAt} (${runtime.connection.lastRecoveryDurationMs ?? "unknown"}ms)`);
152
+ if (runtime.connection.nextReconnectAt) console.log(`Next reconnect: ${runtime.connection.nextReconnectAt}`);
153
+ }
154
+ };
155
+ getDoctorView = async () => {
128
156
  const config = loadConfig(getConfigPath());
129
157
  const snapshot = resolveNextclawRemoteStatusSnapshot(config);
130
158
  const localOrigin = snapshot.runtime?.localOrigin ?? this.deps.currentLocalOrigin ?? resolveConfiguredLocalOrigin(config);
@@ -152,15 +180,16 @@ var RemoteCommands = class {
152
180
  name: "service-runtime",
153
181
  ok: snapshot.runtime?.state === "connected",
154
182
  detail: snapshot.runtime ? snapshot.runtime.state : "no managed remote runtime detected"
155
- }
183
+ },
184
+ describeRemoteConnectionStability(snapshot.runtime)
156
185
  ];
157
186
  return {
158
187
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
159
188
  checks,
160
189
  snapshot
161
190
  };
162
- }
163
- async doctor(opts = {}) {
191
+ };
192
+ doctor = async (opts = {}) => {
164
193
  const report = await this.getDoctorView();
165
194
  if (opts.json) {
166
195
  console.log(JSON.stringify(report, null, 2));
@@ -168,7 +197,7 @@ var RemoteCommands = class {
168
197
  }
169
198
  console.log("NextClaw Remote Doctor");
170
199
  for (const check of report.checks) console.log(`${check.ok ? "✓" : "✗"} ${check.name}: ${check.detail}`);
171
- }
200
+ };
172
201
  };
173
202
  //#endregion
174
203
  export { RemoteCommands, buildNextclawConfiguredRemoteState, buildPlatformApiBaseErrorMessage, createNextclawRemoteConnector, createNextclawRemoteStatusStore, hasRunningNextclawManagedService, resolveNextclawRemoteStatusSnapshot, resolvePlatformApiBase };
@@ -1 +1 @@
1
- {"version":3,"file":"remote-command.controller.js","names":[],"sources":["../../../src/controllers/commands/remote-command.controller.ts"],"sourcesContent":["import { getConfigPath, loadConfig, saveConfig, type Config } from \"@nextclaw/core\";\nimport {\n readPlatformSessionTokenState,\n type RemoteConnectCommandOptions,\n type RemoteDoctorCommandOptions,\n type RemoteEnableCommandOptions,\n type RemoteStatusCommandOptions,\n type RemoteStatusSnapshot\n} from \"@nextclaw/remote\";\nimport { hostname } from \"node:os\";\nimport { localUiDiscoveryService } from \"@nextclaw-service/services/ui/local-ui-discovery.service.js\";\nimport { createNextclawRemoteConnector, resolveNextclawRemoteStatusSnapshot } from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\n\nexport {\n buildNextclawConfiguredRemoteState,\n createNextclawRemoteConnector,\n createNextclawRemoteStatusStore,\n hasRunningNextclawManagedService,\n resolveNextclawRemoteStatusSnapshot\n} from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\nexport {\n buildPlatformApiBaseErrorMessage,\n resolvePlatformApiBase\n} from \"@nextclaw-service/utils/remote/platform-api-base.utils.js\";\n\ntype RemoteConfigChange = {\n changed: boolean;\n config: Config;\n};\n\nexport type RemoteCommandStatusView = {\n configuredEnabled: boolean;\n runtime: RemoteStatusSnapshot[\"runtime\"];\n localOrigin: string;\n deviceName: string;\n platformBase: string | null;\n};\n\nexport type RemoteCommandDoctorCheck = {\n name: string;\n ok: boolean;\n detail: string;\n};\n\nexport type RemoteCommandDoctorView = {\n generatedAt: string;\n checks: RemoteCommandDoctorCheck[];\n snapshot: RemoteStatusSnapshot;\n};\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction resolveConfiguredLocalOrigin(config: Config): string {\n return localUiDiscoveryService.resolveLocalOrigin(config);\n}\n\nasync function probeLocalUi(localOrigin: string): Promise<{ ok: boolean; detail: string }> {\n try {\n const response = await fetch(`${localOrigin}/api/health`);\n if (!response.ok) {\n return { ok: false, detail: `health returned ${response.status}` };\n }\n return { ok: true, detail: \"health endpoint returned ok\" };\n } catch (error) {\n return {\n ok: false,\n detail: error instanceof Error ? error.message : String(error)\n };\n }\n}\n\nfunction describePlatformTokenCheck(token: string | undefined): RemoteCommandDoctorCheck {\n const tokenState = readPlatformSessionTokenState(token);\n if (tokenState.valid) {\n return {\n name: \"platform-token\",\n ok: true,\n detail: \"platform session token configured\"\n };\n }\n if (tokenState.reason === \"expired\") {\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'platform session token expired; run remote browser login or \"nextclaw login\" again'\n };\n }\n if (tokenState.reason === \"malformed\") {\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'platform session token invalid; run remote browser login or \"nextclaw login\" again'\n };\n }\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'run remote browser login or \"nextclaw login\" first'\n };\n}\n\nexport class RemoteCommands {\n constructor(private readonly deps: { currentLocalOrigin?: string } = {}) {}\n\n updateConfig(params: {\n enabled?: boolean;\n apiBase?: string;\n name?: string;\n } = {}): RemoteConfigChange {\n const config = loadConfig(getConfigPath());\n const nextEnabled = typeof params.enabled === \"boolean\" ? params.enabled : config.remote.enabled;\n const nextPlatformApiBase =\n typeof params.apiBase === \"string\" ? params.apiBase.trim() : config.remote.platformApiBase;\n const nextDeviceName =\n typeof params.name === \"string\" ? params.name.trim() : config.remote.deviceName;\n const next: Config = {\n ...config,\n remote: {\n ...config.remote,\n enabled: nextEnabled,\n platformApiBase: nextPlatformApiBase,\n deviceName: nextDeviceName\n }\n };\n saveConfig(next);\n return {\n changed:\n config.remote.enabled !== next.remote.enabled ||\n config.remote.platformApiBase !== next.remote.platformApiBase ||\n config.remote.deviceName !== next.remote.deviceName,\n config: next\n };\n }\n\n enableConfig(opts: RemoteEnableCommandOptions = {}): RemoteConfigChange {\n return this.updateConfig({\n enabled: true,\n apiBase: typeof opts.apiBase === \"string\" ? opts.apiBase : undefined,\n name: typeof opts.name === \"string\" ? opts.name : undefined\n });\n }\n\n disableConfig(): RemoteConfigChange {\n return this.updateConfig({ enabled: false });\n }\n\n async connect(opts: RemoteConnectCommandOptions = {}): Promise<void> {\n const connector = createNextclawRemoteConnector();\n await connector.run({\n ...opts,\n mode: \"foreground\"\n });\n }\n\n getStatusView(): RemoteCommandStatusView {\n const config = loadConfig(getConfigPath());\n const snapshot = resolveNextclawRemoteStatusSnapshot(config);\n const resolvedLocalOrigin =\n snapshot.runtime?.localOrigin ??\n this.deps.currentLocalOrigin ??\n resolveConfiguredLocalOrigin(config);\n return {\n configuredEnabled: snapshot.configuredEnabled,\n runtime: snapshot.runtime,\n localOrigin: resolvedLocalOrigin,\n deviceName: snapshot.runtime?.deviceName ?? normalizeOptionalString(config.remote.deviceName) ?? hostname(),\n platformBase:\n snapshot.runtime?.platformBase ??\n normalizeOptionalString(config.remote.platformApiBase) ??\n normalizeOptionalString(config.providers.nextclaw?.apiBase) ??\n null\n };\n }\n\n async status(opts: RemoteStatusCommandOptions = {}): Promise<void> {\n const view = this.getStatusView();\n\n if (opts.json) {\n console.log(JSON.stringify(view, null, 2));\n return;\n }\n\n const runtime = view.runtime;\n console.log(\"NextClaw Remote Status\");\n console.log(`Enabled: ${view.configuredEnabled ? \"yes\" : \"no\"}`);\n console.log(`Mode: ${runtime?.mode ?? \"service\"}`);\n console.log(`State: ${runtime?.state ?? \"disabled\"}`);\n console.log(`Device: ${view.deviceName}`);\n console.log(`Platform: ${view.platformBase ?? \"not set\"}`);\n console.log(`Local origin: ${runtime?.localOrigin ?? view.localOrigin}`);\n if (runtime?.deviceId) {\n console.log(`Device ID: ${runtime.deviceId}`);\n }\n if (runtime?.lastConnectedAt) {\n console.log(`Last connected: ${runtime.lastConnectedAt}`);\n }\n if (runtime?.lastError) {\n console.log(`Last error: ${runtime.lastError}`);\n }\n }\n\n async getDoctorView(): Promise<RemoteCommandDoctorView> {\n const config = loadConfig(getConfigPath());\n const snapshot = resolveNextclawRemoteStatusSnapshot(config);\n const localOrigin =\n snapshot.runtime?.localOrigin ??\n this.deps.currentLocalOrigin ??\n resolveConfiguredLocalOrigin(config);\n const localUi = await probeLocalUi(localOrigin);\n const token = normalizeOptionalString(config.providers.nextclaw?.apiKey);\n const platformApiBase =\n normalizeOptionalString(config.remote.platformApiBase) ??\n normalizeOptionalString(config.providers.nextclaw?.apiBase);\n const checks = [\n {\n name: \"remote-enabled\",\n ok: snapshot.configuredEnabled,\n detail: snapshot.configuredEnabled ? \"enabled in config\" : \"disabled in config\"\n },\n describePlatformTokenCheck(token),\n {\n name: \"platform-api-base\",\n ok: Boolean(platformApiBase),\n detail: platformApiBase ?? \"set remote.platformApiBase or login with --api-base\"\n },\n {\n name: \"local-ui\",\n ok: localUi.ok,\n detail: `${localOrigin} (${localUi.detail})`\n },\n {\n name: \"service-runtime\",\n ok: snapshot.runtime?.state === \"connected\",\n detail: snapshot.runtime ? snapshot.runtime.state : \"no managed remote runtime detected\"\n }\n ];\n return {\n generatedAt: new Date().toISOString(),\n checks,\n snapshot\n };\n }\n\n async doctor(opts: RemoteDoctorCommandOptions = {}): Promise<void> {\n const report = await this.getDoctorView();\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2));\n return;\n }\n\n console.log(\"NextClaw Remote Doctor\");\n for (const check of report.checks) {\n console.log(`${check.ok ? \"✓\" : \"✗\"} ${check.name}: ${check.detail}`);\n }\n }\n}\n"],"mappings":";;;;;;;AAkDA,SAAS,wBAAwB,OAAoC;AACnE,KAAI,OAAO,UAAU,SACnB;CAEF,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,QAAQ,SAAS,IAAI,UAAU,KAAA;;AAGxC,SAAS,6BAA6B,QAAwB;AAC5D,QAAO,wBAAwB,mBAAmB,OAAO;;AAG3D,eAAe,aAAa,aAA+D;AACzF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,GAAG,YAA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AAK,IAAI,MAAM,SAAS"}
1
+ {"version":3,"file":"remote-command.controller.js","names":[],"sources":["../../../src/controllers/commands/remote-command.controller.ts"],"sourcesContent":["import { getConfigPath, loadConfig, saveConfig, type Config } from \"@nextclaw/core\";\nimport {\n readPlatformSessionTokenState,\n type RemoteConnectCommandOptions,\n type RemoteDoctorCommandOptions,\n type RemoteEnableCommandOptions,\n type RemoteStatusCommandOptions,\n type RemoteStatusSnapshot\n} from \"@nextclaw/remote\";\nimport { hostname } from \"node:os\";\nimport { localUiDiscoveryService } from \"@nextclaw-service/services/ui/local-ui-discovery.service.js\";\nimport { createNextclawRemoteConnector, resolveNextclawRemoteStatusSnapshot } from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\n\nexport {\n buildNextclawConfiguredRemoteState,\n createNextclawRemoteConnector,\n createNextclawRemoteStatusStore,\n hasRunningNextclawManagedService,\n resolveNextclawRemoteStatusSnapshot\n} from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\nexport {\n buildPlatformApiBaseErrorMessage,\n resolvePlatformApiBase\n} from \"@nextclaw-service/utils/remote/platform-api-base.utils.js\";\n\ntype RemoteConfigChange = {\n changed: boolean;\n config: Config;\n};\n\nexport type RemoteCommandStatusView = {\n configuredEnabled: boolean;\n runtime: RemoteStatusSnapshot[\"runtime\"];\n localOrigin: string;\n deviceName: string;\n platformBase: string | null;\n};\n\nexport type RemoteCommandDoctorCheck = {\n name: string;\n ok: boolean;\n detail: string;\n};\n\nexport type RemoteCommandDoctorView = {\n generatedAt: string;\n checks: RemoteCommandDoctorCheck[];\n snapshot: RemoteStatusSnapshot;\n};\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction resolveConfiguredLocalOrigin(config: Config): string {\n return localUiDiscoveryService.resolveLocalOrigin(config);\n}\n\nasync function probeLocalUi(localOrigin: string): Promise<{ ok: boolean; detail: string }> {\n try {\n const response = await fetch(`${localOrigin}/api/health`);\n if (!response.ok) {\n return { ok: false, detail: `health returned ${response.status}` };\n }\n return { ok: true, detail: \"health endpoint returned ok\" };\n } catch (error) {\n return {\n ok: false,\n detail: error instanceof Error ? error.message : String(error)\n };\n }\n}\n\nfunction describePlatformTokenCheck(token: string | undefined): RemoteCommandDoctorCheck {\n const tokenState = readPlatformSessionTokenState(token);\n if (tokenState.valid) {\n return {\n name: \"platform-token\",\n ok: true,\n detail: \"platform session token configured\"\n };\n }\n if (tokenState.reason === \"expired\") {\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'platform session token expired; run remote browser login or \"nextclaw login\" again'\n };\n }\n if (tokenState.reason === \"malformed\") {\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'platform session token invalid; run remote browser login or \"nextclaw login\" again'\n };\n }\n return {\n name: \"platform-token\",\n ok: false,\n detail: 'run remote browser login or \"nextclaw login\" first'\n };\n}\n\nfunction describeRemoteConnectionStability(\n runtime: RemoteStatusSnapshot[\"runtime\"],\n): RemoteCommandDoctorCheck {\n const connection = runtime?.connection;\n if (!connection) {\n return {\n name: \"connection-stability\",\n ok: false,\n detail: \"connection diagnostics unavailable\",\n };\n }\n if (connection.disconnectCount === 0) {\n return {\n name: \"connection-stability\",\n ok: true,\n detail: `no disconnects observed since ${connection.observedSince}`,\n };\n }\n const lastDisconnect = connection.lastDisconnect;\n const recovery = connection.lastRecoveredAt\n ? `; last recovered in ${connection.lastRecoveryDurationMs ?? \"unknown\"}ms`\n : \"; the latest disconnect has not recovered\";\n return {\n name: \"connection-stability\",\n ok: false,\n detail:\n `${connection.disconnectCount} disconnect(s) observed since ${connection.observedSince}` +\n `${lastDisconnect ? `; last ${lastDisconnect.source} at ${lastDisconnect.at}` : \"\"}` +\n recovery,\n };\n}\n\nexport class RemoteCommands {\n constructor(private readonly deps: { currentLocalOrigin?: string } = {}) {}\n\n updateConfig = (params: {\n enabled?: boolean;\n apiBase?: string;\n name?: string;\n } = {}): RemoteConfigChange => {\n const config = loadConfig(getConfigPath());\n const nextEnabled = typeof params.enabled === \"boolean\" ? params.enabled : config.remote.enabled;\n const nextPlatformApiBase =\n typeof params.apiBase === \"string\" ? params.apiBase.trim() : config.remote.platformApiBase;\n const nextDeviceName =\n typeof params.name === \"string\" ? params.name.trim() : config.remote.deviceName;\n const next: Config = {\n ...config,\n remote: {\n ...config.remote,\n enabled: nextEnabled,\n platformApiBase: nextPlatformApiBase,\n deviceName: nextDeviceName\n }\n };\n saveConfig(next);\n return {\n changed:\n config.remote.enabled !== next.remote.enabled ||\n config.remote.platformApiBase !== next.remote.platformApiBase ||\n config.remote.deviceName !== next.remote.deviceName,\n config: next\n };\n };\n\n enableConfig = (\n opts: RemoteEnableCommandOptions = {},\n ): RemoteConfigChange => {\n return this.updateConfig({\n enabled: true,\n apiBase: typeof opts.apiBase === \"string\" ? opts.apiBase : undefined,\n name: typeof opts.name === \"string\" ? opts.name : undefined\n });\n };\n\n disableConfig = (): RemoteConfigChange => {\n return this.updateConfig({ enabled: false });\n };\n\n connect = async (opts: RemoteConnectCommandOptions = {}): Promise<void> => {\n const connector = createNextclawRemoteConnector();\n await connector.run({\n ...opts,\n mode: \"foreground\"\n });\n };\n\n getStatusView = (): RemoteCommandStatusView => {\n const config = loadConfig(getConfigPath());\n const snapshot = resolveNextclawRemoteStatusSnapshot(config);\n const resolvedLocalOrigin =\n snapshot.runtime?.localOrigin ??\n this.deps.currentLocalOrigin ??\n resolveConfiguredLocalOrigin(config);\n return {\n configuredEnabled: snapshot.configuredEnabled,\n runtime: snapshot.runtime,\n localOrigin: resolvedLocalOrigin,\n deviceName: snapshot.runtime?.deviceName ?? normalizeOptionalString(config.remote.deviceName) ?? hostname(),\n platformBase:\n snapshot.runtime?.platformBase ??\n normalizeOptionalString(config.remote.platformApiBase) ??\n normalizeOptionalString(config.providers.nextclaw?.apiBase) ??\n null\n };\n };\n\n status = async (opts: RemoteStatusCommandOptions = {}): Promise<void> => {\n const view = this.getStatusView();\n\n if (opts.json) {\n console.log(JSON.stringify(view, null, 2));\n return;\n }\n\n const runtime = view.runtime;\n console.log(\"NextClaw Remote Status\");\n console.log(`Enabled: ${view.configuredEnabled ? \"yes\" : \"no\"}`);\n console.log(`Mode: ${runtime?.mode ?? \"service\"}`);\n console.log(`State: ${runtime?.state ?? \"disabled\"}`);\n console.log(`Device: ${view.deviceName}`);\n console.log(`Platform: ${view.platformBase ?? \"not set\"}`);\n console.log(`Local origin: ${runtime?.localOrigin ?? view.localOrigin}`);\n if (runtime?.deviceId) {\n console.log(`Device ID: ${runtime.deviceId}`);\n }\n if (runtime?.lastConnectedAt) {\n console.log(`Last connected: ${runtime.lastConnectedAt}`);\n }\n if (runtime?.lastError) {\n console.log(`Last error: ${runtime.lastError}`);\n }\n if (runtime?.connection) {\n console.log(`Connection ID: ${runtime.connection.connectionId ?? \"none\"}`);\n console.log(`Disconnects observed: ${runtime.connection.disconnectCount}`);\n console.log(\n `Heartbeat: ${runtime.connection.heartbeatSupported ? \"acknowledged\" : \"compatibility mode\"}`,\n );\n if (runtime.connection.lastDisconnect) {\n console.log(\n `Last disconnect: ${runtime.connection.lastDisconnect.source} at ${runtime.connection.lastDisconnect.at}`,\n );\n }\n if (runtime.connection.lastRecoveredAt) {\n console.log(\n `Last recovery: ${runtime.connection.lastRecoveredAt} (${runtime.connection.lastRecoveryDurationMs ?? \"unknown\"}ms)`,\n );\n }\n if (runtime.connection.nextReconnectAt) {\n console.log(`Next reconnect: ${runtime.connection.nextReconnectAt}`);\n }\n }\n };\n\n getDoctorView = async (): Promise<RemoteCommandDoctorView> => {\n const config = loadConfig(getConfigPath());\n const snapshot = resolveNextclawRemoteStatusSnapshot(config);\n const localOrigin =\n snapshot.runtime?.localOrigin ??\n this.deps.currentLocalOrigin ??\n resolveConfiguredLocalOrigin(config);\n const localUi = await probeLocalUi(localOrigin);\n const token = normalizeOptionalString(config.providers.nextclaw?.apiKey);\n const platformApiBase =\n normalizeOptionalString(config.remote.platformApiBase) ??\n normalizeOptionalString(config.providers.nextclaw?.apiBase);\n const checks = [\n {\n name: \"remote-enabled\",\n ok: snapshot.configuredEnabled,\n detail: snapshot.configuredEnabled ? \"enabled in config\" : \"disabled in config\"\n },\n describePlatformTokenCheck(token),\n {\n name: \"platform-api-base\",\n ok: Boolean(platformApiBase),\n detail: platformApiBase ?? \"set remote.platformApiBase or login with --api-base\"\n },\n {\n name: \"local-ui\",\n ok: localUi.ok,\n detail: `${localOrigin} (${localUi.detail})`\n },\n {\n name: \"service-runtime\",\n ok: snapshot.runtime?.state === \"connected\",\n detail: snapshot.runtime ? snapshot.runtime.state : \"no managed remote runtime detected\"\n },\n describeRemoteConnectionStability(snapshot.runtime),\n ];\n return {\n generatedAt: new Date().toISOString(),\n checks,\n snapshot\n };\n };\n\n doctor = async (opts: RemoteDoctorCommandOptions = {}): Promise<void> => {\n const report = await this.getDoctorView();\n\n if (opts.json) {\n console.log(JSON.stringify(report, null, 2));\n return;\n }\n\n console.log(\"NextClaw Remote Doctor\");\n for (const check of report.checks) {\n console.log(`${check.ok ? \"✓\" : \"✗\"} ${check.name}: ${check.detail}`);\n }\n };\n}\n"],"mappings":";;;;;;;AAkDA,SAAS,wBAAwB,OAAoC;AACnE,KAAI,OAAO,UAAU,SACnB;CAEF,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,QAAQ,SAAS,IAAI,UAAU,KAAA;;AAGxC,SAAS,6BAA6B,QAAwB;AAC5D,QAAO,wBAAwB,mBAAmB,OAAO;;AAG3D,eAAe,aAAa,aAA+D;AACzF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,GAAG,YAAY,aAAa;AACzD,MAAI,CAAC,SAAS,GACZ,QAAO;GAAE,IAAI;GAAO,QAAQ,mBAAmB,SAAS;GAAU;AAEpE,SAAO;GAAE,IAAI;GAAM,QAAQ;GAA+B;UACnD,OAAO;AACd,SAAO;GACL,IAAI;GACJ,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,O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,UAAU,QAAQ;EAC7D,MAAM,SAAS;GACb;IACE,MAAM;IACN,IAAI,SAAS;IACb,QAAQ,SAAS,oBAAoB,sBAAsB;IAC5D;GACD,2BAA2B,MAAM;GACjC;IACE,MAAM;IACN,IAAI,QAAQ,gBAAgB;IAC5B,QAAQ,mBAAmB;IAC5B;GACD;IACE,MAAM;IACN,IAAI,QAAQ;IACZ,QAAQ,GAAG,YAAY,IAAI,QAAQ,OAAO;IAC3C;GACD;IACE,MAAM;IACN,IAAI,SAAS,SAAS,UAAU;IAChC,QAAQ,SAAS,UAAU,SAAS,QAAQ,QAAQ;IACrD;GACD,kCAAkC,SAAS,QAAQ;GACpD;AACD,SAAO;GACL,8BAAa,IAAI,MAAM,EAAC,aAAa;GACrC;GACA;GACD;;CAGH,SAAS,OAAO,OAAmC,EAAE,KAAoB;EACvE,MAAM,SAAS,MAAM,KAAK,eAAe;AAEzC,MAAI,KAAK,MAAM;AACb,WAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC;AAC5C;;AAGF,UAAQ,IAAI,yBAAyB;AACrC,OAAK,MAAM,SAAS,OAAO,OACzB,SAAQ,IAAI,GAAG,MAAM,KAAK,MAAM,IAAI,GAAG,MAAM,KAAK,IAAI,MAAM,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"remote-access-host.service.d.ts","names":[],"sources":["../../../src/services/remote/remote-access-host.service.ts"],"mappings":";;;;;;cAmDa,gBAAA,YAA4B,kBAAA;EAAA,iBAEpB,IAAA;cAAA,IAAA;IACf,eAAA,EAAiB,+BAAA;IACjB,4BAAA,GAA+B,OAAA;MAAY,MAAA;MAAiB,MAAA;IAAA,MAAsB,OAAA;IAClF,cAAA,EAAgB,cAAA;IAChB,oBAAA,EAAsB,oBAAA;IACtB,SAAA;MACE,IAAA;MACA,IAAA;IAAA;IAEF,uBAAA,GAA0B,uBAAA;EAAA;EAI9B,SAAA,QAAgB,gBAAA;EAuBhB,KAAA,GAAe,KAAA;IACb,KA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AAA,GAAwB,MAAA,EAAQ,mBAAA,KAAsB,OAAA,CAAQ,yBAAA;EAAA,QAItD,eAAA;EA4BR,aAAA,GAAuB,KAAA;IAAS,QAAA;EAAA,MAAqB,OAAA,CAAQ,gBAAA;AAAA"}
@@ -19,6 +19,7 @@ function toRemoteRuntimeView(runtime) {
19
19
  localOrigin: runtime.localOrigin,
20
20
  lastConnectedAt: runtime.lastConnectedAt,
21
21
  lastError: runtime.lastError,
22
+ connection: runtime.connection,
22
23
  updatedAt: runtime.updatedAt
23
24
  };
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remote-access-host.service.js","names":[],"sources":["../../../src/services/remote/remote-access-host.service.ts"],"sourcesContent":["import { getConfigPath, loadConfig } from \"@nextclaw/core\";\nimport { readPlatformSessionTokenState } from \"@nextclaw/remote\";\nimport type {\n RemoteAccessView,\n RemoteAccountView,\n RemoteBrowserAuthPollRequest,\n RemoteBrowserAuthPollResult,\n RemoteBrowserAuthStartRequest,\n RemoteBrowserAuthStartResult,\n RemoteDoctorView,\n RemoteRuntimeView,\n RemoteServiceAction,\n RemoteServiceActionResult,\n RemoteSettingsUpdateRequest,\n UiRemoteAccessHost\n} from \"@nextclaw/server\";\nimport type { PlatformAuthCommands } from \"@nextclaw-service/controllers/commands/platform-auth-command.controller.js\";\nimport type { RemoteCommands } from \"@nextclaw-service/controllers/commands/remote-command.controller.js\";\nimport {\n controlRemoteService,\n resolveRemoteServiceView,\n type RemoteAccessHostServiceCommands,\n type RemoteRuntimeController\n} from \"./remote-service-control.service.js\";\n\nfunction normalizeOptionalString(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction toRemoteRuntimeView(runtime: ReturnType<RemoteCommands[\"getStatusView\"]>[\"runtime\"]): RemoteRuntimeView | null {\n if (!runtime) {\n return null;\n }\n return {\n enabled: runtime.enabled,\n mode: runtime.mode,\n state: runtime.state,\n deviceId: runtime.deviceId,\n deviceName: runtime.deviceName,\n platformBase: runtime.platformBase,\n localOrigin: runtime.localOrigin,\n lastConnectedAt: runtime.lastConnectedAt,\n lastError: runtime.lastError,\n updatedAt: runtime.updatedAt\n };\n}\n\nexport class RemoteAccessHost implements UiRemoteAccessHost {\n constructor(\n private readonly deps: {\n serviceCommands: RemoteAccessHostServiceCommands;\n requestManagedServiceRestart: (options?: { uiPort?: number; reason?: string }) => Promise<void>;\n remoteCommands: RemoteCommands;\n platformAuthCommands: PlatformAuthCommands;\n currentUi?: {\n host: string;\n port: number;\n };\n remoteRuntimeController?: RemoteRuntimeController | null;\n }\n ) {}\n\n getStatus = (): RemoteAccessView => {\n const config = loadConfig(getConfigPath());\n const status = this.deps.remoteCommands.getStatusView();\n const account = this.readAccountView({\n token: normalizeOptionalString(config.providers.nextclaw?.apiKey),\n apiBase: normalizeOptionalString(config.providers.nextclaw?.apiBase),\n platformBase: status.platformBase\n });\n return {\n account,\n settings: {\n enabled: config.remote.enabled,\n deviceName: config.remote.deviceName,\n platformApiBase: config.remote.platformApiBase\n },\n service: resolveRemoteServiceView(this.deps.currentUi),\n localOrigin: status.localOrigin,\n configuredEnabled: status.configuredEnabled,\n platformBase: status.platformBase,\n runtime: toRemoteRuntimeView(status.runtime)\n };\n };\n\n login = async (input: {\n email: string;\n password: string;\n apiBase?: string;\n }): Promise<RemoteAccessView> => {\n await this.deps.platformAuthCommands.loginResult(input);\n return this.getStatus();\n };\n\n startBrowserAuth = async (input: RemoteBrowserAuthStartRequest): Promise<RemoteBrowserAuthStartResult> => {\n const result = await this.deps.platformAuthCommands.startBrowserAuth({\n apiBase: input.apiBase\n });\n return {\n sessionId: result.sessionId,\n verificationUri: result.verificationUri,\n expiresAt: result.expiresAt,\n intervalMs: result.intervalMs\n };\n };\n\n pollBrowserAuth = async (input: RemoteBrowserAuthPollRequest): Promise<RemoteBrowserAuthPollResult> => {\n const config = loadConfig(getConfigPath());\n const result = await this.deps.platformAuthCommands.pollBrowserAuth({\n apiBase: normalizeOptionalString(input.apiBase)\n ?? normalizeOptionalString(config.remote.platformApiBase)\n ?? normalizeOptionalString(config.providers.nextclaw?.apiBase)\n ?? undefined,\n sessionId: input.sessionId\n });\n if (result.status !== \"authorized\") {\n return result;\n }\n return {\n status: \"authorized\",\n email: result.email,\n role: result.role\n };\n };\n\n logout = (): RemoteAccessView => {\n this.deps.platformAuthCommands.logout();\n return this.getStatus();\n };\n\n updateSettings = (input: RemoteSettingsUpdateRequest): RemoteAccessView => {\n this.deps.remoteCommands.updateConfig({\n enabled: input.enabled,\n apiBase: input.platformApiBase,\n name: input.deviceName\n });\n return this.getStatus();\n };\n\n runDoctor = async (): Promise<RemoteDoctorView> => {\n const report = await this.deps.remoteCommands.getDoctorView();\n return {\n generatedAt: report.generatedAt,\n checks: report.checks,\n snapshot: {\n configuredEnabled: report.snapshot.configuredEnabled,\n runtime: toRemoteRuntimeView(report.snapshot.runtime)\n }\n };\n };\n\n controlService = async (action: RemoteServiceAction): Promise<RemoteServiceActionResult> => {\n return controlRemoteService(action, this.deps);\n };\n\n private readAccountView = (params: {\n token: string | null;\n apiBase: string | null;\n platformBase: string | null;\n }): RemoteAccountView => {\n const { apiBase, platformBase, token } = params;\n const tokenState = readPlatformSessionTokenState(token);\n if (!tokenState.valid) {\n return {\n loggedIn: false,\n apiBase,\n platformBase\n };\n }\n const payload = tokenState.payload;\n const email = typeof payload?.email === \"string\" ? payload.email : undefined;\n const username = typeof payload?.username === \"string\" ? payload.username : undefined;\n const role = typeof payload?.role === \"string\" ? payload.role : undefined;\n return {\n loggedIn: true,\n email,\n username,\n role,\n apiBase,\n platformBase\n };\n };\n\n updateProfile = async (input: { username: string }): Promise<RemoteAccessView> => {\n await this.deps.platformAuthCommands.updateProfile({\n username: input.username\n });\n return this.getStatus();\n };\n}\n"],"mappings":";;;;AAyBA,SAAS,wBAAwB,OAA+B;AAC9D,KAAI,OAAO,UAAU,SACnB,QAAO;CAET,MAAM,UAAU,MAAM,MAAM;A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AU,MAAM,UACjB,CAAC;AACF,SAAO,KAAK,WAAW"}
1
+ {"version":3,"file":"remote-access-host.service.js","names":[],"sources":["../../../src/services/remote/remote-access-host.service.ts"],"sourcesContent":["import { getConfigPath, loadConfig } from \"@nextclaw/core\";\nimport { readPlatformSessionTokenState } from \"@nextclaw/remote\";\nimport type {\n RemoteAccessView,\n RemoteAccountView,\n RemoteBrowserAuthPollRequest,\n RemoteBrowserAuthPollResult,\n RemoteBrowserAuthStartRequest,\n RemoteBrowserAuthStartResult,\n RemoteDoctorView,\n RemoteRuntimeView,\n RemoteServiceAction,\n RemoteServiceActionResult,\n RemoteSettingsUpdateRequest,\n UiRemoteAccessHost\n} from \"@nextclaw/server\";\nimport type { PlatformAuthCommands } from \"@nextclaw-service/controllers/commands/platform-auth-command.controller.js\";\nimport type { RemoteCommands } from \"@nextclaw-service/controllers/commands/remote-command.controller.js\";\nimport {\n controlRemoteService,\n resolveRemoteServiceView,\n type RemoteAccessHostServiceCommands,\n type RemoteRuntimeController\n} from \"./remote-service-control.service.js\";\n\nfunction normalizeOptionalString(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction toRemoteRuntimeView(runtime: ReturnType<RemoteCommands[\"getStatusView\"]>[\"runtime\"]): RemoteRuntimeView | null {\n if (!runtime) {\n return null;\n }\n return {\n enabled: runtime.enabled,\n mode: runtime.mode,\n state: runtime.state,\n deviceId: runtime.deviceId,\n deviceName: runtime.deviceName,\n platformBase: runtime.platformBase,\n localOrigin: runtime.localOrigin,\n lastConnectedAt: runtime.lastConnectedAt,\n lastError: runtime.lastError,\n connection: runtime.connection,\n updatedAt: runtime.updatedAt\n };\n}\n\nexport class RemoteAccessHost implements UiRemoteAccessHost {\n constructor(\n private readonly deps: {\n serviceCommands: RemoteAccessHostServiceCommands;\n requestManagedServiceRestart: (options?: { uiPort?: number; reason?: string }) => Promise<void>;\n remoteCommands: RemoteCommands;\n platformAuthCommands: PlatformAuthCommands;\n currentUi?: {\n host: string;\n port: number;\n };\n remoteRuntimeController?: RemoteRuntimeController | null;\n }\n ) {}\n\n getStatus = (): RemoteAccessView => {\n const config = loadConfig(getConfigPath());\n const status = this.deps.remoteCommands.getStatusView();\n const account = this.readAccountView({\n token: normalizeOptionalString(config.providers.nextclaw?.apiKey),\n apiBase: normalizeOptionalString(config.providers.nextclaw?.apiBase),\n platformBase: status.platformBase\n });\n return {\n account,\n settings: {\n enabled: config.remote.enabled,\n deviceName: config.remote.deviceName,\n platformApiBase: config.remote.platformApiBase\n },\n service: resolveRemoteServiceView(this.deps.currentUi),\n localOrigin: status.localOrigin,\n configuredEnabled: status.configuredEnabled,\n platformBase: status.platformBase,\n runtime: toRemoteRuntimeView(status.runtime)\n };\n };\n\n login = async (input: {\n email: string;\n password: string;\n apiBase?: string;\n }): Promise<RemoteAccessView> => {\n await this.deps.platformAuthCommands.loginResult(input);\n return this.getStatus();\n };\n\n startBrowserAuth = async (input: RemoteBrowserAuthStartRequest): Promise<RemoteBrowserAuthStartResult> => {\n const result = await this.deps.platformAuthCommands.startBrowserAuth({\n apiBase: input.apiBase\n });\n return {\n sessionId: result.sessionId,\n verificationUri: result.verificationUri,\n expiresAt: result.expiresAt,\n intervalMs: result.intervalMs\n };\n };\n\n pollBrowserAuth = async (input: RemoteBrowserAuthPollRequest): Promise<RemoteBrowserAuthPollResult> => {\n const config = loadConfig(getConfigPath());\n const result = await this.deps.platformAuthCommands.pollBrowserAuth({\n apiBase: normalizeOptionalString(input.apiBase)\n ?? normalizeOptionalString(config.remote.platformApiBase)\n ?? normalizeOptionalString(config.providers.nextclaw?.apiBase)\n ?? undefined,\n sessionId: input.sessionId\n });\n if (result.status !== \"authorized\") {\n return result;\n }\n return {\n status: \"authorized\",\n email: result.email,\n role: result.role\n };\n };\n\n logout = (): RemoteAccessView => {\n this.deps.platformAuthCommands.logout();\n return this.getStatus();\n };\n\n updateSettings = (input: RemoteSettingsUpdateRequest): RemoteAccessView => {\n this.deps.remoteCommands.updateConfig({\n enabled: input.enabled,\n apiBase: input.platformApiBase,\n name: input.deviceName\n });\n return this.getStatus();\n };\n\n runDoctor = async (): Promise<RemoteDoctorView> => {\n const report = await this.deps.remoteCommands.getDoctorView();\n return {\n generatedAt: report.generatedAt,\n checks: report.checks,\n snapshot: {\n configuredEnabled: report.snapshot.configuredEnabled,\n runtime: toRemoteRuntimeView(report.snapshot.runtime)\n }\n };\n };\n\n controlService = async (action: RemoteServiceAction): Promise<RemoteServiceActionResult> => {\n return controlRemoteService(action, this.deps);\n };\n\n private readAccountView = (params: {\n token: string | null;\n apiBase: string | null;\n platformBase: string | null;\n }): RemoteAccountView => {\n const { apiBase, platformBase, token } = params;\n const tokenState = readPlatformSessionTokenState(token);\n if (!tokenState.valid) {\n return {\n loggedIn: false,\n apiBase,\n platformBase\n };\n }\n const payload = tokenState.payload;\n const email = typeof payload?.email === \"string\" ? payload.email : undefined;\n const username = typeof payload?.username === \"string\" ? payload.username : undefined;\n const role = typeof payload?.role === \"string\" ? payload.role : undefined;\n return {\n loggedIn: true,\n email,\n username,\n role,\n apiBase,\n platformBase\n };\n };\n\n updateProfile = async (input: { username: string }): Promise<RemoteAccessView> => {\n await this.deps.platformAuthCommands.updateProfile({\n username: input.username\n });\n return this.getStatus();\n };\n}\n"],"mappings":";;;;AAyBA,SAAS,wBAAwB,OAA+B;AAC9D,KAAI,OAAO,UAAU,SACnB,QAAO;CAET,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAO,QAAQ,SAAS,IAAI,UAAU;;AAGxC,SAAS,oBAAoB,SAA2F;AACtH,KAAI,CAAC,QACH,QAAO;AAET,QAAO;EACL,SAAS,QAAQ;EACjB,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,UAAU,QAAQ;EAClB,YAAY,QAAQ;EACpB,cAAc,QAAQ;EACtB,aAAa,QAAQ;EACrB,iBAAiB,QAAQ;EACzB,WAAW,QAAQ;EACnB,YAAY,QAA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OAAO;GACd;;CAGH,eAAiC;AAC/B,OAAK,KAAK,qBAAqB,QAAQ;AACvC,SAAO,KAAK,WAAW;;CAGzB,kBAAkB,UAAyD;AACzE,OAAK,KAAK,eAAe,aAAa;GACpC,SAAS,MAAM;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACb,CAAC;AACF,SAAO,KAAK,WAAW;;CAGzB,YAAY,YAAuC;EACjD,MAAM,SAAS,MAAM,KAAK,KAAK,eAAe,eAAe;AAC7D,SAAO;GACL,aAAa,OAAO;GACpB,QAAQ,OAAO;GACf,UAAU;IACR,mBAAmB,OAAO,SAAS;IACnC,SAAS,oBAAoB,OAAO,SAAS,QAAQ;IACtD;GACF;;CAGH,iBAAiB,OAAO,WAAoE;AAC1F,SAAO,qBAAqB,QAAQ,KAAK,KAAK;;CAGhD,mBAA2B,WAIF;EACvB,MAAM,EAAE,SAAS,cAAc,UAAU;EACzC,MAAM,aAAa,8BAA8B,MAAM;AACvD,MAAI,CAAC,WAAW,MACd,QAAO;GACL,UAAU;GACV;GACA;GACD;EAEH,MAAM,UAAU,WAAW;AAI3B,SAAO;GACL,UAAU;GACV,OALY,OAAO,SAAS,UAAU,WAAW,QAAQ,QAAQ,KAAA;GAMjE,UALe,OAAO,SAAS,aAAa,WAAW,QAAQ,WAAW,KAAA;GAM1E,MALW,OAAO,SAAS,SAAS,WAAW,QAAQ,OAAO,KAAA;GAM9D;GACA;GACD;;CAGH,gBAAgB,OAAO,UAA2D;AAChF,QAAM,KAAK,KAAK,qBAAqB,cAAc,EACjD,UAAU,MAAM,UACjB,CAAC;AACF,SAAO,KAAK,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"service-remote-runtime.utils.d.ts","names":[],"sources":["../../../src/utils/runtime/service-remote-runtime.utils.ts"],"mappings":";;;;;KA0BK,sBAAA;EACH,GAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;AAAA;AAAA,KASG,2BAAA;EAAgC,EAAA;EAAU,OAAA;AAAA;EAA0B,EAAA;EAAW,KAAA;AAAA;AAAA,iBA4IpE,kCAAA,CAAmC,MAAA;EACjD,WAAA;EACA,QAAA;EACA,UAAA;EACA,GAAA;EACA,kBAAA,IAAsB,GAAA;EACtB,kBAAA,SAA2B,mBAAA;AAAA,IACzB,2BAAA;AAAA,iBAuCY,yBAAA,CAA0B,MAAA;EACxC,UAAA,QAAkB,MAAA;EAClB,SAAA;EACA,WAAA;EACA,mBAAA,IAAuB,KAAA,EAAO,kBAAA;AAAA,IAC5B,mBAAA;AAAA,iBAoBY,8BAAA,CAA+B,MAAA;EAC7C,UAAA,QAAkB,MAAA;EAClB,QAAA,EAAU,IAAA,CAAK,MAAA;EACf,mBAAA;EAA8B,mBAAA,IAAuB,KAAA,EAAO,kBAAA;AAAA,IAC1D,mBAAA;AAAA,iBAcY,+BAAA,CAAgC,MAAA;EAC9C,MAAA,EAAQ,MAAA;EACR,KAAA,GAAQ,mBAAA;EACR,kBAAA;EACA,QAAA,EAAU,sBAAA;AAAA;AAAA,iBAmBI,6BAAA,CAA8B,MAAA;EAC5C,KAAA,GAAQ,mBAAA;EACR,kBAAA;EACA,SAAA;IAAa,KAAA;IAAgB,cAAA;EAAA;EAC7B,QAAA,EAAU,sBAAA;AAAA,IACR,mBAAA"}
1
+ {"version":3,"file":"service-remote-runtime.utils.d.ts","names":[],"sources":["../../../src/utils/runtime/service-remote-runtime.utils.ts"],"mappings":";;;;;KA0BK,sBAAA;EACH,GAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;AAAA;AAAA,KASG,2BAAA;EAAgC,EAAA;EAAU,OAAA;AAAA;EAA0B,EAAA;EAAW,KAAA;AAAA;AAAA,iBA4IpE,kCAAA,CAAmC,MAAA;EACjD,WAAA;EACA,QAAA;EACA,UAAA;EACA,GAAA;EACA,kBAAA,IAAsB,GAAA;EACtB,kBAAA,SAA2B,mBAAA;AAAA,IACzB,2BAAA;AAAA,iBAuCY,yBAAA,CAA0B,MAAA;EACxC,UAAA,QAAkB,MAAA;EAClB,SAAA;EACA,WAAA;EACA,mBAAA,IAAuB,KAAA,EAAO,kBAAA;AAAA,IAC5B,mBAAA;AAAA,iBA0BY,8BAAA,CAA+B,MAAA;EAC7C,UAAA,QAAkB,MAAA;EAClB,QAAA,EAAU,IAAA,CAAK,MAAA;EACf,mBAAA;EAA8B,mBAAA,IAAuB,KAAA,EAAO,kBAAA;AAAA,IAC1D,mBAAA;AAAA,iBAcY,+BAAA,CAAgC,MAAA;EAC9C,MAAA,EAAQ,MAAA;EACR,KAAA,GAAQ,mBAAA;EACR,kBAAA;EACA,QAAA,EAAU,sBAAA;AAAA;AAAA,iBAmBI,6BAAA,CAA8B,MAAA;EAC5C,KAAA,GAAQ,mBAAA;EACR,kBAAA;EACA,SAAA;IAAa,KAAA;IAAgB,cAAA;EAAA;EAC7B,QAAA,EAAU,sBAAA;AAAA,IACR,mBAAA"}
@@ -124,9 +124,9 @@ function createManagedRemoteModule(params) {
124
124
  createConnector: (logger) => createNextclawRemoteConnector({ logger }),
125
125
  claimOwnership: () => claimManagedRemoteRuntimeOwnership({ localOrigin }),
126
126
  logger: {
127
- info: (message) => console.log(`[remote] ${message}`),
128
- warn: (message) => console.warn(`[remote] ${message}`),
129
- error: (message) => console.error(`[remote] ${message}`)
127
+ info: (message, context) => context ? console.log(`[remote] ${message}`, context) : console.log(`[remote] ${message}`),
128
+ warn: (message, context) => context ? console.warn(`[remote] ${message}`, context) : console.warn(`[remote] ${message}`),
129
+ error: (message, context) => context ? console.error(`[remote] ${message}`, context) : console.error(`[remote] ${message}`)
130
130
  }
131
131
  });
132
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service-remote-runtime.utils.js","names":[],"sources":["../../../src/utils/runtime/service-remote-runtime.utils.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport { RemoteServiceModule, type RemoteRuntimeState } from \"@nextclaw/remote\";\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync\n} from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { getRunPath } from \"@nextclaw/core\";\nimport { resolveUiApiBase, isProcessRunning } from \"@nextclaw-service/utils/cli.utils.js\";\nimport {\n managedServiceStateStore,\n type ManagedServiceLease,\n type ManagedServiceState\n} from \"@nextclaw-service/stores/managed-service-state.store.js\";\nimport {\n buildNextclawConfiguredRemoteState,\n createNextclawRemoteConnector,\n createNextclawRemoteStatusStore\n} from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\n\ntype ManagedServiceSnapshot = {\n pid: number;\n uiUrl: string;\n apiUrl: string;\n uiHost: string;\n uiPort: number;\n logPath: string;\n};\n\ntype RemoteRuntimeOwnerRecord = {\n pid: number;\n localOrigin: string;\n claimedAt: string;\n};\n\ntype RemoteRuntimeOwnershipClaim = { ok: true; release: () => void } | { ok: false; error: string };\n\nfunction resolveRemoteOwnershipLockPath(): string {\n return resolve(getRunPath(), \"remote-owner.lock.json\");\n}\n\nfunction readRemoteOwnershipRecord(lockPath: string): RemoteRuntimeOwnerRecord | null {\n try {\n const raw = JSON.parse(readFileSync(lockPath, \"utf-8\")) as Partial<RemoteRuntimeOwnerRecord>;\n if (typeof raw.pid !== \"number\" || !Number.isFinite(raw.pid)) {\n return null;\n }\n return {\n pid: raw.pid,\n localOrigin: typeof raw.localOrigin === \"string\" ? raw.localOrigin : \"\",\n claimedAt: typeof raw.claimedAt === \"string\" ? raw.claimedAt : \"\"\n };\n } catch {\n return null;\n }\n}\n\nfunction removeRemoteOwnershipLock(lockPath: string): void {\n if (!existsSync(lockPath)) {\n return;\n }\n try {\n unlinkSync(lockPath);\n } catch {\n try {\n rmSync(lockPath, { force: true });\n } catch {\n // Ignore cleanup failures.\n }\n }\n}\n\nfunction buildManagedServiceOwnershipError(params: {\n pid: number;\n ownerOrigin?: string;\n}): string {\n return (\n `Remote access is already owned by running NextClaw service PID ${params.pid}`\n + `${params.ownerOrigin ? ` (${params.ownerOrigin})` : \"\"}. `\n + \"Stop that service or disable remote there before starting another process with the same NEXTCLAW_HOME.\"\n );\n}\n\nfunction buildLocalProcessOwnershipError(record: RemoteRuntimeOwnerRecord): string {\n const originText = record.localOrigin ? ` (${record.localOrigin})` : \"\";\n return (\n `Remote access is already owned by local NextClaw process PID ${record.pid}${originText}. `\n + \"Stop that process or use a different NEXTCLAW_HOME before starting another remote-enabled process.\"\n );\n}\n\nfunction createRemoteOwnershipRelease(params: {\n lockPath: string;\n claim: RemoteRuntimeOwnerRecord;\n}): () => void {\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n const current = readRemoteOwnershipRecord(params.lockPath);\n if (!current || (current.pid === params.claim.pid && current.claimedAt === params.claim.claimedAt)) {\n removeRemoteOwnershipLock(params.lockPath);\n }\n };\n}\n\nfunction detectManagedRemoteOwnershipConflict(params: {\n currentPid: number;\n isProcessRunningFn: (pid: number) => boolean;\n readServiceStateFn: () => ManagedServiceState | null;\n}): string | null {\n const runningService = params.readServiceStateFn();\n if (\n !runningService\n || runningService.pid === params.currentPid\n || !params.isProcessRunningFn(runningService.pid)\n || !runningService.remote?.enabled\n ) {\n return null;\n }\n\n return buildManagedServiceOwnershipError({\n pid: runningService.pid,\n ownerOrigin: runningService.remote.localOrigin ?? runningService.uiUrl\n });\n}\n\nfunction tryClaimRemoteOwnershipLock(params: {\n lockPath: string;\n claim: RemoteRuntimeOwnerRecord;\n currentPid: number;\n isProcessRunningFn: (pid: number) => boolean;\n}): RemoteRuntimeOwnershipClaim {\n const { claim, currentPid, isProcessRunningFn, lockPath } = params;\n for (let attempt = 0; attempt < 2; attempt += 1) {\n try {\n const fd = openSync(lockPath, \"wx\");\n writeFileSync(fd, `${JSON.stringify(claim, null, 2)}\\n`, \"utf-8\");\n closeSync(fd);\n return {\n ok: true,\n release: createRemoteOwnershipRelease({\n lockPath,\n claim\n })\n };\n } catch (error) {\n const code = typeof error === \"object\" && error && \"code\" in error ? String(error.code) : \"\";\n if (code !== \"EEXIST\") {\n return {\n ok: false,\n error: `Failed to claim local remote runtime ownership: ${error instanceof Error ? error.message : String(error)}`\n };\n }\n\n const existing = readRemoteOwnershipRecord(lockPath);\n if (existing && existing.pid !== currentPid && isProcessRunningFn(existing.pid)) {\n return {\n ok: false,\n error: buildLocalProcessOwnershipError(existing)\n };\n }\n\n removeRemoteOwnershipLock(lockPath);\n }\n }\n\n return {\n ok: false,\n error: \"Failed to claim local remote runtime ownership after clearing a stale lock.\"\n };\n}\n\nexport function claimManagedRemoteRuntimeOwnership(params: {\n localOrigin: string;\n lockPath?: string;\n currentPid?: number;\n now?: () => string;\n isProcessRunningFn?: (pid: number) => boolean;\n readServiceStateFn?: () => ManagedServiceState | null;\n}): RemoteRuntimeOwnershipClaim {\n const {\n localOrigin,\n lockPath: lockPathOverride,\n currentPid: currentPidOverride,\n now: nowOverride,\n isProcessRunningFn: isProcessRunningOverride,\n readServiceStateFn: readServiceStateOverride\n } = params;\n const lockPath = lockPathOverride ?? resolveRemoteOwnershipLockPath();\n const currentPid = currentPidOverride ?? process.pid;\n const now = nowOverride ?? (() => new Date().toISOString());\n const isProcessRunningFn = isProcessRunningOverride ?? isProcessRunning;\n const readServiceStateFn = readServiceStateOverride ?? managedServiceStateStore.read;\n const managedConflict = detectManagedRemoteOwnershipConflict({\n currentPid,\n isProcessRunningFn,\n readServiceStateFn\n });\n if (managedConflict) {\n return {\n ok: false,\n error: managedConflict\n };\n }\n\n mkdirSync(dirname(lockPath), { recursive: true });\n return tryClaimRemoteOwnershipLock({\n lockPath,\n claim: {\n pid: currentPid,\n localOrigin,\n claimedAt: now()\n },\n currentPid,\n isProcessRunningFn\n });\n}\n\nexport function createManagedRemoteModule(params: {\n loadConfig: () => Config;\n uiEnabled: boolean;\n localOrigin: string;\n onRemoteStateChange?: (state: RemoteRuntimeState) => void;\n}): RemoteServiceModule | null {\n const { loadConfig, localOrigin, onRemoteStateChange, uiEnabled } = params;\n if (!uiEnabled) {\n return null;\n }\n return new RemoteServiceModule({\n loadConfig,\n uiEnabled,\n localOrigin,\n statusStore: createNextclawRemoteStatusStore(\"service\", onRemoteStateChange),\n createConnector: (logger) => createNextclawRemoteConnector({ logger }),\n claimOwnership: () => claimManagedRemoteRuntimeOwnership({ localOrigin }),\n logger: {\n info: (message) => console.log(`[remote] ${message}`),\n warn: (message) => console.warn(`[remote] ${message}`),\n error: (message) => console.error(`[remote] ${message}`)\n }\n });\n}\n\nexport function createManagedRemoteModuleForUi(params: {\n loadConfig: () => Config;\n uiConfig: Pick<Config[\"ui\"], \"enabled\" | \"host\" | \"port\">;\n localOriginOverride?: string; onRemoteStateChange?: (state: RemoteRuntimeState) => void;\n}): RemoteServiceModule | null {\n const { loadConfig, localOriginOverride, onRemoteStateChange, uiConfig } = params;\n const explicitLocalOrigin = localOriginOverride?.trim() ?? process.env.NEXTCLAW_REMOTE_LOCAL_ORIGIN?.trim();\n return createManagedRemoteModule({\n loadConfig,\n uiEnabled: uiConfig.enabled,\n onRemoteStateChange,\n localOrigin:\n explicitLocalOrigin && explicitLocalOrigin.length > 0\n ? explicitLocalOrigin.replace(/\\/+$/, \"\")\n : resolveUiApiBase(uiConfig.host, uiConfig.port)\n });\n}\n\nexport function writeInitialManagedServiceState(params: {\n config: Config;\n lease?: ManagedServiceLease;\n readinessTimeoutMs: number;\n snapshot: ManagedServiceSnapshot;\n}): void {\n const { config, lease, readinessTimeoutMs, snapshot } = params;\n managedServiceStateStore.write({\n pid: snapshot.pid,\n startedAt: new Date().toISOString(),\n uiUrl: snapshot.uiUrl,\n apiUrl: snapshot.apiUrl,\n uiHost: snapshot.uiHost,\n uiPort: snapshot.uiPort,\n logPath: snapshot.logPath,\n ...(lease ? { lease } : {}),\n startupLastProbeError: null,\n startupTimeoutMs: readinessTimeoutMs,\n startupCheckedAt: new Date().toISOString(),\n ...(config.remote.enabled ? { remote: buildNextclawConfiguredRemoteState(config) } : {})\n });\n}\n\nexport function writeReadyManagedServiceState(params: {\n lease?: ManagedServiceLease;\n readinessTimeoutMs: number;\n readiness: { ready: boolean; lastProbeError: string | null };\n snapshot: ManagedServiceSnapshot;\n}): ManagedServiceState {\n const { lease, readiness, readinessTimeoutMs, snapshot } = params;\n const currentState = managedServiceStateStore.read();\n const state: ManagedServiceState = {\n pid: snapshot.pid,\n startedAt: currentState?.startedAt ?? new Date().toISOString(),\n uiUrl: snapshot.uiUrl,\n apiUrl: snapshot.apiUrl,\n uiHost: snapshot.uiHost,\n uiPort: snapshot.uiPort,\n logPath: snapshot.logPath,\n ...(lease ? { lease } : currentState?.lease ? { lease: currentState.lease } : {}),\n startupState: readiness.ready ? \"ready\" : \"degraded\",\n startupLastProbeError: readiness.lastProbeError,\n startupTimeoutMs: readinessTimeoutMs,\n startupCheckedAt: new Date().toISOString(),\n ...(currentState?.remote ? { remote: currentState.remote } : {})\n };\n managedServiceStateStore.write(state);\n return state;\n}\n"],"mappings":";;;;;;;;AA2CA,SAAS,iCAAyC;AAChD,QAAO,QAAQ,YAAY,EAAE,yBAAyB;;AAGxD,SAAS,0BAA0B,UAAmD;AACpF,KAAI;EACF,MAAM,MAAM,KAAK,MAAM,aAAa,UAAU,QAAQ,CAAC;AACvD,MAAI,OAAO,IAAI,QAAQ,YAAY,CAAC,OAAO,SAAS,IAAI,IAAI,CAC1D,QAAO;AAET,SAAO;GACL,KAAK,IAAI;GACT,aAAa,OAAO,IAAI,gBAAgB,WAAW,IAAI,cAAc;GACrE,WAAW,OAAO,IAAI,cAAc,WAAW,IAAI,YAAY;GAChE;SACK;AACN,SAAO;;;AAIX,SAAS,0BAA0B,UAAwB;AACzD,KAAI,CAAC,WAAW,SAAS,CACvB;AAEF,KAAI;AACF,aAAW,SAAS;SACd;AACN,MAAI;AACF,UAAO,UAAU,EAAE,OAAO,MAAM,CAAC;UAC3B;;;AAMZ,SAAS,kCAAkC,QAGhC;AACT,QACE,kEAAkE,OAAO,MACpE,OAAO,cAAc,KAAK,OAAO,YAAY,KAAK,GAA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
1
+ {"version":3,"file":"service-remote-runtime.utils.js","names":[],"sources":["../../../src/utils/runtime/service-remote-runtime.utils.ts"],"sourcesContent":["import type { Config } from \"@nextclaw/core\";\nimport { RemoteServiceModule, type RemoteRuntimeState } from \"@nextclaw/remote\";\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync\n} from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { getRunPath } from \"@nextclaw/core\";\nimport { resolveUiApiBase, isProcessRunning } from \"@nextclaw-service/utils/cli.utils.js\";\nimport {\n managedServiceStateStore,\n type ManagedServiceLease,\n type ManagedServiceState\n} from \"@nextclaw-service/stores/managed-service-state.store.js\";\nimport {\n buildNextclawConfiguredRemoteState,\n createNextclawRemoteConnector,\n createNextclawRemoteStatusStore\n} from \"@nextclaw-service/utils/remote/remote-runtime-support.utils.js\";\n\ntype ManagedServiceSnapshot = {\n pid: number;\n uiUrl: string;\n apiUrl: string;\n uiHost: string;\n uiPort: number;\n logPath: string;\n};\n\ntype RemoteRuntimeOwnerRecord = {\n pid: number;\n localOrigin: string;\n claimedAt: string;\n};\n\ntype RemoteRuntimeOwnershipClaim = { ok: true; release: () => void } | { ok: false; error: string };\n\nfunction resolveRemoteOwnershipLockPath(): string {\n return resolve(getRunPath(), \"remote-owner.lock.json\");\n}\n\nfunction readRemoteOwnershipRecord(lockPath: string): RemoteRuntimeOwnerRecord | null {\n try {\n const raw = JSON.parse(readFileSync(lockPath, \"utf-8\")) as Partial<RemoteRuntimeOwnerRecord>;\n if (typeof raw.pid !== \"number\" || !Number.isFinite(raw.pid)) {\n return null;\n }\n return {\n pid: raw.pid,\n localOrigin: typeof raw.localOrigin === \"string\" ? raw.localOrigin : \"\",\n claimedAt: typeof raw.claimedAt === \"string\" ? raw.claimedAt : \"\"\n };\n } catch {\n return null;\n }\n}\n\nfunction removeRemoteOwnershipLock(lockPath: string): void {\n if (!existsSync(lockPath)) {\n return;\n }\n try {\n unlinkSync(lockPath);\n } catch {\n try {\n rmSync(lockPath, { force: true });\n } catch {\n // Ignore cleanup failures.\n }\n }\n}\n\nfunction buildManagedServiceOwnershipError(params: {\n pid: number;\n ownerOrigin?: string;\n}): string {\n return (\n `Remote access is already owned by running NextClaw service PID ${params.pid}`\n + `${params.ownerOrigin ? ` (${params.ownerOrigin})` : \"\"}. `\n + \"Stop that service or disable remote there before starting another process with the same NEXTCLAW_HOME.\"\n );\n}\n\nfunction buildLocalProcessOwnershipError(record: RemoteRuntimeOwnerRecord): string {\n const originText = record.localOrigin ? ` (${record.localOrigin})` : \"\";\n return (\n `Remote access is already owned by local NextClaw process PID ${record.pid}${originText}. `\n + \"Stop that process or use a different NEXTCLAW_HOME before starting another remote-enabled process.\"\n );\n}\n\nfunction createRemoteOwnershipRelease(params: {\n lockPath: string;\n claim: RemoteRuntimeOwnerRecord;\n}): () => void {\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n const current = readRemoteOwnershipRecord(params.lockPath);\n if (!current || (current.pid === params.claim.pid && current.claimedAt === params.claim.claimedAt)) {\n removeRemoteOwnershipLock(params.lockPath);\n }\n };\n}\n\nfunction detectManagedRemoteOwnershipConflict(params: {\n currentPid: number;\n isProcessRunningFn: (pid: number) => boolean;\n readServiceStateFn: () => ManagedServiceState | null;\n}): string | null {\n const runningService = params.readServiceStateFn();\n if (\n !runningService\n || runningService.pid === params.currentPid\n || !params.isProcessRunningFn(runningService.pid)\n || !runningService.remote?.enabled\n ) {\n return null;\n }\n\n return buildManagedServiceOwnershipError({\n pid: runningService.pid,\n ownerOrigin: runningService.remote.localOrigin ?? runningService.uiUrl\n });\n}\n\nfunction tryClaimRemoteOwnershipLock(params: {\n lockPath: string;\n claim: RemoteRuntimeOwnerRecord;\n currentPid: number;\n isProcessRunningFn: (pid: number) => boolean;\n}): RemoteRuntimeOwnershipClaim {\n const { claim, currentPid, isProcessRunningFn, lockPath } = params;\n for (let attempt = 0; attempt < 2; attempt += 1) {\n try {\n const fd = openSync(lockPath, \"wx\");\n writeFileSync(fd, `${JSON.stringify(claim, null, 2)}\\n`, \"utf-8\");\n closeSync(fd);\n return {\n ok: true,\n release: createRemoteOwnershipRelease({\n lockPath,\n claim\n })\n };\n } catch (error) {\n const code = typeof error === \"object\" && error && \"code\" in error ? String(error.code) : \"\";\n if (code !== \"EEXIST\") {\n return {\n ok: false,\n error: `Failed to claim local remote runtime ownership: ${error instanceof Error ? error.message : String(error)}`\n };\n }\n\n const existing = readRemoteOwnershipRecord(lockPath);\n if (existing && existing.pid !== currentPid && isProcessRunningFn(existing.pid)) {\n return {\n ok: false,\n error: buildLocalProcessOwnershipError(existing)\n };\n }\n\n removeRemoteOwnershipLock(lockPath);\n }\n }\n\n return {\n ok: false,\n error: \"Failed to claim local remote runtime ownership after clearing a stale lock.\"\n };\n}\n\nexport function claimManagedRemoteRuntimeOwnership(params: {\n localOrigin: string;\n lockPath?: string;\n currentPid?: number;\n now?: () => string;\n isProcessRunningFn?: (pid: number) => boolean;\n readServiceStateFn?: () => ManagedServiceState | null;\n}): RemoteRuntimeOwnershipClaim {\n const {\n localOrigin,\n lockPath: lockPathOverride,\n currentPid: currentPidOverride,\n now: nowOverride,\n isProcessRunningFn: isProcessRunningOverride,\n readServiceStateFn: readServiceStateOverride\n } = params;\n const lockPath = lockPathOverride ?? resolveRemoteOwnershipLockPath();\n const currentPid = currentPidOverride ?? process.pid;\n const now = nowOverride ?? (() => new Date().toISOString());\n const isProcessRunningFn = isProcessRunningOverride ?? isProcessRunning;\n const readServiceStateFn = readServiceStateOverride ?? managedServiceStateStore.read;\n const managedConflict = detectManagedRemoteOwnershipConflict({\n currentPid,\n isProcessRunningFn,\n readServiceStateFn\n });\n if (managedConflict) {\n return {\n ok: false,\n error: managedConflict\n };\n }\n\n mkdirSync(dirname(lockPath), { recursive: true });\n return tryClaimRemoteOwnershipLock({\n lockPath,\n claim: {\n pid: currentPid,\n localOrigin,\n claimedAt: now()\n },\n currentPid,\n isProcessRunningFn\n });\n}\n\nexport function createManagedRemoteModule(params: {\n loadConfig: () => Config;\n uiEnabled: boolean;\n localOrigin: string;\n onRemoteStateChange?: (state: RemoteRuntimeState) => void;\n}): RemoteServiceModule | null {\n const { loadConfig, localOrigin, onRemoteStateChange, uiEnabled } = params;\n if (!uiEnabled) {\n return null;\n }\n return new RemoteServiceModule({\n loadConfig,\n uiEnabled,\n localOrigin,\n statusStore: createNextclawRemoteStatusStore(\"service\", onRemoteStateChange),\n createConnector: (logger) => createNextclawRemoteConnector({ logger }),\n claimOwnership: () => claimManagedRemoteRuntimeOwnership({ localOrigin }),\n logger: {\n info: (message, context) => context\n ? console.log(`[remote] ${message}`, context)\n : console.log(`[remote] ${message}`),\n warn: (message, context) => context\n ? console.warn(`[remote] ${message}`, context)\n : console.warn(`[remote] ${message}`),\n error: (message, context) => context\n ? console.error(`[remote] ${message}`, context)\n : console.error(`[remote] ${message}`)\n }\n });\n}\n\nexport function createManagedRemoteModuleForUi(params: {\n loadConfig: () => Config;\n uiConfig: Pick<Config[\"ui\"], \"enabled\" | \"host\" | \"port\">;\n localOriginOverride?: string; onRemoteStateChange?: (state: RemoteRuntimeState) => void;\n}): RemoteServiceModule | null {\n const { loadConfig, localOriginOverride, onRemoteStateChange, uiConfig } = params;\n const explicitLocalOrigin = localOriginOverride?.trim() ?? process.env.NEXTCLAW_REMOTE_LOCAL_ORIGIN?.trim();\n return createManagedRemoteModule({\n loadConfig,\n uiEnabled: uiConfig.enabled,\n onRemoteStateChange,\n localOrigin:\n explicitLocalOrigin && explicitLocalOrigin.length > 0\n ? explicitLocalOrigin.replace(/\\/+$/, \"\")\n : resolveUiApiBase(uiConfig.host, uiConfig.port)\n });\n}\n\nexport function writeInitialManagedServiceState(params: {\n config: Config;\n lease?: ManagedServiceLease;\n readinessTimeoutMs: number;\n snapshot: ManagedServiceSnapshot;\n}): void {\n const { config, lease, readinessTimeoutMs, snapshot } = params;\n managedServiceStateStore.write({\n pid: snapshot.pid,\n startedAt: new Date().toISOString(),\n uiUrl: snapshot.uiUrl,\n apiUrl: snapshot.apiUrl,\n uiHost: snapshot.uiHost,\n uiPort: snapshot.uiPort,\n logPath: snapshot.logPath,\n ...(lease ? { lease } : {}),\n startupLastProbeError: null,\n startupTimeoutMs: readinessTimeoutMs,\n startupCheckedAt: new Date().toISOString(),\n ...(config.remote.enabled ? { remote: buildNextclawConfiguredRemoteState(config) } : {})\n });\n}\n\nexport function writeReadyManagedServiceState(params: {\n lease?: ManagedServiceLease;\n readinessTimeoutMs: number;\n readiness: { ready: boolean; lastProbeError: string | null };\n snapshot: ManagedServiceSnapshot;\n}): ManagedServiceState {\n const { lease, readiness, readinessTimeoutMs, snapshot } = params;\n const currentState = managedServiceStateStore.read();\n const state: ManagedServiceState = {\n pid: snapshot.pid,\n startedAt: currentState?.startedAt ?? new Date().toISOString(),\n uiUrl: snapshot.uiUrl,\n apiUrl: snapshot.apiUrl,\n uiHost: snapshot.uiHost,\n uiPort: snapshot.uiPort,\n logPath: snapshot.logPath,\n ...(lease ? { lease } : currentState?.lease ? { lease: currentState.lease } : {}),\n startupState: readiness.ready ? \"ready\" : \"degraded\",\n startupLastProbeError: readiness.lastProbeError,\n startupTimeoutMs: readinessTimeoutMs,\n startupCheckedAt: new Date().toISOString(),\n ...(currentState?.remote ? { remote: currentState.remote } : {})\n };\n managedServiceStateStore.write(state);\n return state;\n}\n"],"mappings":";;;;;;;;AA2CA,SAAS,iCAAyC;AAChD,QAAO,QAAQ,YAAY,EAAE,yBAAyB;;AAGxD,SAAS,0BAA0B,UAAmD;AACpF,KAAI;EACF,MAAM,MAAM,KAAK,MAAM,aAAa,UAAU,QAAQ,CAAC;AACvD,MAAI,OAAO,IAAI,QAAQ,YAAY,CAAC,OAAO,SAAS,IAAI,IAAI,CAC1D,QAAO;AAET,SAAO;GACL,KAAK,IAAI;GACT,aAAa,OAAO,IAAI,gBAAgB,WAAW,IAAI,cAAc;GACrE,WAAW,OAAO,IAAI,cAAc,WAAW,I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AS;EACd,WAAW,cAAc,8BAAa,IAAI,MAAM,EAAC,aAAa;EAC9D,OAAO,SAAS;EAChB,QAAQ,SAAS;EACjB,QAAQ,SAAS;EACjB,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,GAAI,QAAQ,EAAE,OAAO,GAAG,cAAc,QAAQ,EAAE,OAAO,aAAa,OAAO,GAAG,EAAE;EAChF,cAAc,UAAU,QAAQ,UAAU;EAC1C,uBAAuB,UAAU;EACjC,kBAAkB;EAClB,mCAAkB,IAAI,MAAM,EAAC,aAAa;EAC1C,GAAI,cAAc,SAAS,EAAE,QAAQ,aAAa,QAAQ,GAAG,EAAE;EAChE;AACD,0BAAyB,MAAM,MAAM;AACrC,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/service",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "private": false,
5
5
  "description": "NextClaw long-running service host and runtime lifecycle.",
6
6
  "type": "module",
@@ -42,31 +42,31 @@
42
42
  "chokidar": "^3.6.0",
43
43
  "commander": "^12.1.0",
44
44
  "jszip": "^3.10.1",
45
- "@nextclaw/channel-extension-dingtalk": "0.2.13",
46
- "@nextclaw/channel-extension-slack": "0.2.13",
47
- "@nextclaw/channel-extension-email": "0.2.13",
48
- "@nextclaw/channel-extension-telegram": "0.2.13",
49
- "@nextclaw/channel-extension-discord": "0.2.13",
50
- "@nextclaw/channel-extension-wecom": "0.2.13",
51
- "@nextclaw/channel-extension-whatsapp": "0.2.13",
52
- "@nextclaw/client-sdk": "0.5.15",
53
- "@nextclaw/channel-extension-qq": "0.2.12",
54
- "@nextclaw/channel-extension-weixin": "0.2.13",
55
- "@nextclaw/core": "0.15.13",
56
- "@nextclaw/kernel": "0.6.15",
57
- "@nextclaw/channel-extension-feishu": "0.2.13",
58
- "@nextclaw/ncp-mcp": "0.2.13",
59
- "@nextclaw/ncp": "0.7.11",
60
- "@nextclaw/mcp": "0.3.13",
61
- "@nextclaw/nextclaw-hermes-acp-bridge": "0.3.11",
62
- "@nextclaw/nextclaw-ncp-runtime-http-client": "0.3.11",
63
- "@nextclaw/runtime": "0.4.13",
64
- "@nextclaw/ncp-agent-runtime": "0.4.11",
65
- "@nextclaw/ncp-toolkit": "0.6.12",
66
- "@nextclaw/remote": "0.3.15",
67
- "@nextclaw/server": "0.15.15",
68
- "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.14",
69
- "@nextclaw/shared": "0.4.12"
45
+ "@nextclaw/channel-extension-dingtalk": "0.2.15",
46
+ "@nextclaw/channel-extension-discord": "0.2.15",
47
+ "@nextclaw/channel-extension-email": "0.2.15",
48
+ "@nextclaw/channel-extension-feishu": "0.2.15",
49
+ "@nextclaw/channel-extension-qq": "0.2.14",
50
+ "@nextclaw/channel-extension-slack": "0.2.15",
51
+ "@nextclaw/channel-extension-telegram": "0.2.15",
52
+ "@nextclaw/channel-extension-wecom": "0.2.15",
53
+ "@nextclaw/channel-extension-whatsapp": "0.2.15",
54
+ "@nextclaw/core": "0.15.15",
55
+ "@nextclaw/channel-extension-weixin": "0.2.15",
56
+ "@nextclaw/client-sdk": "0.5.17",
57
+ "@nextclaw/kernel": "0.6.17",
58
+ "@nextclaw/mcp": "0.3.15",
59
+ "@nextclaw/ncp": "0.7.13",
60
+ "@nextclaw/ncp-agent-runtime": "0.4.13",
61
+ "@nextclaw/ncp-mcp": "0.2.15",
62
+ "@nextclaw/ncp-toolkit": "0.6.14",
63
+ "@nextclaw/nextclaw-hermes-acp-bridge": "0.3.13",
64
+ "@nextclaw/nextclaw-ncp-runtime-http-client": "0.3.13",
65
+ "@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.16",
66
+ "@nextclaw/remote": "0.3.17",
67
+ "@nextclaw/runtime": "0.4.15",
68
+ "@nextclaw/server": "0.15.17",
69
+ "@nextclaw/shared": "0.4.14"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^20.17.6",