@nextclaw/service 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/launcher/npm-runtime-update-command.service.d.ts +0 -6
- package/dist/launcher/npm-runtime-update-command.service.js +4 -7
- package/dist/service-runtime.service.d.ts +2 -9
- package/dist/service-runtime.service.js +8 -14
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.d.ts +3 -1
- package/dist/shared/services/gateway/nextclaw-gateway-runtime.service.js +5 -4
- package/dist/shared/services/runtime/nextclaw-distribution.service.d.ts +10 -0
- package/dist/shared/services/runtime/nextclaw-distribution.service.js +13 -0
- package/dist/shared/services/runtime/runtime-command.service.js +5 -3
- package/dist/shared/services/runtime/service-managed-startup.service.d.ts +1 -0
- package/dist/shared/services/runtime/service-managed-startup.service.js +3 -3
- package/dist/shared/services/ui/npm-runtime-update-host.service.js +23 -17
- package/dist/shared/types/distribution.types.d.ts +10 -0
- package/dist/shared/types/distribution.types.js +1 -0
- package/dist/shared/utils/cli.utils.d.ts +2 -5
- package/dist/shared/utils/cli.utils.js +5 -16
- package/dist/shared/utils/package/package-manifest.utils.d.ts +1 -5
- package/dist/shared/utils/package/package-manifest.utils.js +8 -18
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AccountCommandOptions, AccountSetUsernameCommandOptions, AgentCommandOptions, AgentsListCommandOptions, AgentsNewCommandOptions, AgentsRemoveCommandOptions, AgentsRuntimesCommandOptions, AgentsUpdateCommandOptions, ChannelsAddOptions, ChannelsLoginOptions, CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions, ConfigGetOptions, ConfigSetOptions, CronAddOptions, DoctorCommandOptions, GatewayCommandOptions, HealthProbe, LoginCommandOptions, LogsTailCommandOptions, MarketplaceSkillsRecommendCommandOptions, MarketplaceSkillsSearchCommandOptions, McpAddCommandOptions, McpDoctorOptions, McpListOptions, PluginsInfoOptions, PluginsInstallOptions, PluginsListOptions, PluginsUninstallOptions, RemoteConnectCommandOptions, RemoteDoctorCommandOptions, RemoteEnableCommandOptions, RemoteStatusCommandOptions, RequestRestartParams, RuntimeStatusReport, SecretsApplyOptions, SecretsAuditOptions, SecretsConfigureOptions, SecretsReloadOptions, ServiceAutostartCommandOptions, SkillsInfoCommandOptions, SkillsInstalledCommandOptions, StartCommandOptions, StatusCommandOptions, UiCommandOptions, UpdateCommandOptions, UsageCommandOptions } from "./shared/types/cli.types.js";
|
|
2
2
|
import { NextclawServiceRuntime, NextclawServiceRuntimeOptions, runNextclawNpmRuntimeLauncher } from "./service-runtime.service.js";
|
|
3
|
+
import { NextclawDistribution } from "./shared/types/distribution.types.js";
|
|
4
|
+
import { NextclawDistributionService } from "./shared/services/runtime/nextclaw-distribution.service.js";
|
|
3
5
|
import { readLearningLoopRuntimeConfig } from "@nextclaw/kernel";
|
|
4
|
-
export { AccountCommandOptions, AccountSetUsernameCommandOptions, AgentCommandOptions, AgentsListCommandOptions, AgentsNewCommandOptions, AgentsRemoveCommandOptions, AgentsRuntimesCommandOptions, AgentsUpdateCommandOptions, ChannelsAddOptions, ChannelsLoginOptions, CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions, ConfigGetOptions, ConfigSetOptions, CronAddOptions, DoctorCommandOptions, GatewayCommandOptions, HealthProbe, LoginCommandOptions, LogsTailCommandOptions, MarketplaceSkillsRecommendCommandOptions, MarketplaceSkillsSearchCommandOptions, McpAddCommandOptions, McpDoctorOptions, McpListOptions, NextclawServiceRuntime, type NextclawServiceRuntimeOptions, PluginsInfoOptions, PluginsInstallOptions, PluginsListOptions, PluginsUninstallOptions, RemoteConnectCommandOptions, RemoteDoctorCommandOptions, RemoteEnableCommandOptions, RemoteStatusCommandOptions, RequestRestartParams, RuntimeStatusReport, SecretsApplyOptions, SecretsAuditOptions, SecretsConfigureOptions, SecretsReloadOptions, ServiceAutostartCommandOptions, SkillsInfoCommandOptions, SkillsInstalledCommandOptions, StartCommandOptions, StatusCommandOptions, UiCommandOptions, UpdateCommandOptions, UsageCommandOptions, readLearningLoopRuntimeConfig, runNextclawNpmRuntimeLauncher };
|
|
6
|
+
export { AccountCommandOptions, AccountSetUsernameCommandOptions, AgentCommandOptions, AgentsListCommandOptions, AgentsNewCommandOptions, AgentsRemoveCommandOptions, AgentsRuntimesCommandOptions, AgentsUpdateCommandOptions, ChannelsAddOptions, ChannelsLoginOptions, CompanionDisableCommandOptions, CompanionEnableCommandOptions, CompanionStartCommandOptions, CompanionStatusCommandOptions, CompanionStopCommandOptions, ConfigGetOptions, ConfigSetOptions, CronAddOptions, DoctorCommandOptions, GatewayCommandOptions, HealthProbe, LoginCommandOptions, LogsTailCommandOptions, MarketplaceSkillsRecommendCommandOptions, MarketplaceSkillsSearchCommandOptions, McpAddCommandOptions, McpDoctorOptions, McpListOptions, type NextclawDistribution, NextclawDistributionService, NextclawServiceRuntime, type NextclawServiceRuntimeOptions, PluginsInfoOptions, PluginsInstallOptions, PluginsListOptions, PluginsUninstallOptions, RemoteConnectCommandOptions, RemoteDoctorCommandOptions, RemoteEnableCommandOptions, RemoteStatusCommandOptions, RequestRestartParams, RuntimeStatusReport, SecretsApplyOptions, SecretsAuditOptions, SecretsConfigureOptions, SecretsReloadOptions, ServiceAutostartCommandOptions, SkillsInfoCommandOptions, SkillsInstalledCommandOptions, StartCommandOptions, StatusCommandOptions, UiCommandOptions, UpdateCommandOptions, UsageCommandOptions, readLearningLoopRuntimeConfig, runNextclawNpmRuntimeLauncher };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NextclawDistributionService } from "./shared/services/runtime/nextclaw-distribution.service.js";
|
|
1
2
|
import { NextclawServiceRuntime, runNextclawNpmRuntimeLauncher } from "./service-runtime.service.js";
|
|
2
3
|
import { readLearningLoopRuntimeConfig } from "@nextclaw/kernel";
|
|
3
|
-
export { NextclawServiceRuntime, readLearningLoopRuntimeConfig, runNextclawNpmRuntimeLauncher };
|
|
4
|
+
export { NextclawDistributionService, NextclawServiceRuntime, readLearningLoopRuntimeConfig, runNextclawNpmRuntimeLauncher };
|
|
@@ -2,13 +2,7 @@ import { UpdateCommandOptions } from "../shared/types/cli.types.js";
|
|
|
2
2
|
import { UpdateSnapshot } from "@nextclaw/kernel";
|
|
3
3
|
|
|
4
4
|
//#region src/launcher/npm-runtime-update-command.service.d.ts
|
|
5
|
-
type NpmRuntimeUpdateCommandServiceOptions = {
|
|
6
|
-
launcherVersion?: string;
|
|
7
|
-
packagedPublicKeyPath?: string;
|
|
8
|
-
};
|
|
9
5
|
declare class NpmRuntimeUpdateCommandService {
|
|
10
|
-
private readonly options;
|
|
11
|
-
constructor(options?: NpmRuntimeUpdateCommandServiceOptions);
|
|
12
6
|
run: (opts: UpdateCommandOptions) => Promise<UpdateSnapshot>;
|
|
13
7
|
runManaged: (opts: UpdateCommandOptions) => Promise<UpdateSnapshot>;
|
|
14
8
|
private printProgress;
|
|
@@ -2,15 +2,11 @@ import { NpmRuntimeBundleLayoutStore } from "./npm-runtime-bundle-layout.store.j
|
|
|
2
2
|
import { NpmRuntimeBundleService } from "./npm-runtime-bundle.service.js";
|
|
3
3
|
import { NpmRuntimeUpdateSourceService } from "./npm-runtime-update-source.service.js";
|
|
4
4
|
import { NpmRuntimeUpdateStateStore } from "./npm-runtime-update-state.store.js";
|
|
5
|
-
import { getPackageVersion } from "../shared/utils/package/package-manifest.utils.js";
|
|
6
|
-
import "../shared/utils/cli.utils.js";
|
|
7
5
|
import { NpmRuntimeUpdateManager } from "./npm-runtime-update.manager.js";
|
|
8
6
|
import { NpmRuntimeUpdateService } from "./npm-runtime-update.service.js";
|
|
7
|
+
import { NextclawDistributionService } from "../shared/services/runtime/nextclaw-distribution.service.js";
|
|
9
8
|
//#region src/launcher/npm-runtime-update-command.service.ts
|
|
10
9
|
var NpmRuntimeUpdateCommandService = class {
|
|
11
|
-
constructor(options = {}) {
|
|
12
|
-
this.options = options;
|
|
13
|
-
}
|
|
14
10
|
run = async (opts) => {
|
|
15
11
|
const snapshot = await this.runManaged(opts);
|
|
16
12
|
if (opts.json) console.log(JSON.stringify(snapshot, null, 2));
|
|
@@ -18,8 +14,9 @@ var NpmRuntimeUpdateCommandService = class {
|
|
|
18
14
|
return snapshot;
|
|
19
15
|
};
|
|
20
16
|
runManaged = async (opts) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
17
|
+
const distribution = NextclawDistributionService.get();
|
|
18
|
+
const source = new NpmRuntimeUpdateSourceService({ packagedPublicKeyPath: distribution.runtimeUpdatePublicKeyPath });
|
|
19
|
+
const launcherVersion = distribution.version;
|
|
23
20
|
const channel = source.resolveChannel(opts.channel, launcherVersion);
|
|
24
21
|
const manifestUrl = source.resolveManifestUrl(channel, opts.manifestUrl);
|
|
25
22
|
const layout = new NpmRuntimeBundleLayoutStore();
|
|
@@ -23,8 +23,6 @@ import { RemoteRuntimeActions } from "@nextclaw/remote";
|
|
|
23
23
|
//#region src/service-runtime.service.d.ts
|
|
24
24
|
type NextclawServiceRuntimeOptions = {
|
|
25
25
|
logo?: string;
|
|
26
|
-
version?: string;
|
|
27
|
-
packagedPublicKeyPath?: string;
|
|
28
26
|
};
|
|
29
27
|
type NextclawServiceRuntimeAccount = {
|
|
30
28
|
status: (opts?: {
|
|
@@ -60,8 +58,6 @@ type NextclawServiceCommands = {
|
|
|
60
58
|
};
|
|
61
59
|
declare class NextclawServiceRuntime {
|
|
62
60
|
private logo;
|
|
63
|
-
private productVersion;
|
|
64
|
-
private packagedPublicKeyPath?;
|
|
65
61
|
private restartCoordinator;
|
|
66
62
|
private serviceRestartTask;
|
|
67
63
|
private selfRelaunchArmed;
|
|
@@ -72,7 +68,7 @@ declare class NextclawServiceRuntime {
|
|
|
72
68
|
private remoteCommands;
|
|
73
69
|
account: NextclawServiceRuntimeAccount;
|
|
74
70
|
commands: NextclawServiceCommands;
|
|
75
|
-
constructor(options
|
|
71
|
+
constructor(options: NextclawServiceRuntimeOptions);
|
|
76
72
|
private createCommands;
|
|
77
73
|
get version(): string;
|
|
78
74
|
private scheduleProcessExit;
|
|
@@ -90,9 +86,6 @@ declare class NextclawServiceRuntime {
|
|
|
90
86
|
agent: (opts: AgentCommandOptions) => Promise<void>;
|
|
91
87
|
update: (opts: UpdateCommandOptions) => Promise<void>;
|
|
92
88
|
}
|
|
93
|
-
declare const runNextclawNpmRuntimeLauncher: (argv?: string[]
|
|
94
|
-
launcherVersion?: string;
|
|
95
|
-
packagedAppEntrypoint?: string;
|
|
96
|
-
}) => void;
|
|
89
|
+
declare const runNextclawNpmRuntimeLauncher: (argv?: string[]) => void;
|
|
97
90
|
//#endregion
|
|
98
91
|
export { NextclawServiceCommands, NextclawServiceRuntime, NextclawServiceRuntimeAccount, NextclawServiceRuntimeOptions, runNextclawNpmRuntimeLauncher };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getPackageVersion as getPackageVersion$1 } from "./shared/utils/package/package-manifest.utils.js";
|
|
2
1
|
import { isProcessRunning } from "./shared/utils/cli.utils.js";
|
|
3
2
|
import { NpmRuntimeLauncher } from "./launcher/npm-runtime-launcher.service.js";
|
|
3
|
+
import { NextclawDistributionService } from "./shared/services/runtime/nextclaw-distribution.service.js";
|
|
4
4
|
import { NpmRuntimeUpdateCommandService } from "./launcher/npm-runtime-update-command.service.js";
|
|
5
5
|
import { managedServiceStateStore } from "./shared/stores/managed-service-state.store.js";
|
|
6
6
|
import { logStartupTrace, measureStartupSync } from "./shared/utils/startup-trace.js";
|
|
@@ -53,8 +53,6 @@ import { NextclawKernel } from "@nextclaw/kernel";
|
|
|
53
53
|
const FORCED_PUBLIC_UI_HOST = "0.0.0.0";
|
|
54
54
|
var NextclawServiceRuntime = class {
|
|
55
55
|
logo;
|
|
56
|
-
productVersion;
|
|
57
|
-
packagedPublicKeyPath;
|
|
58
56
|
restartCoordinator;
|
|
59
57
|
serviceRestartTask = null;
|
|
60
58
|
selfRelaunchArmed = false;
|
|
@@ -65,11 +63,9 @@ var NextclawServiceRuntime = class {
|
|
|
65
63
|
remoteCommands;
|
|
66
64
|
account;
|
|
67
65
|
commands;
|
|
68
|
-
constructor(options
|
|
66
|
+
constructor(options) {
|
|
69
67
|
logStartupTrace("cli.runtime.constructor.begin");
|
|
70
68
|
this.logo = options.logo ?? "🤖";
|
|
71
|
-
this.productVersion = options.version ?? getPackageVersion$1();
|
|
72
|
-
this.packagedPublicKeyPath = options.packagedPublicKeyPath;
|
|
73
69
|
this.workspaceManager = measureStartupSync("cli.runtime.workspace_manager", () => new WorkspaceManager(this.logo));
|
|
74
70
|
this.runtimeCommandService = measureStartupSync("cli.runtime.runtime_command_service", () => new RuntimeCommandService({
|
|
75
71
|
requestRestart: (params) => this.requestRestart(params),
|
|
@@ -168,7 +164,7 @@ var NextclawServiceRuntime = class {
|
|
|
168
164
|
};
|
|
169
165
|
};
|
|
170
166
|
get version() {
|
|
171
|
-
return
|
|
167
|
+
return NextclawDistributionService.get().version;
|
|
172
168
|
}
|
|
173
169
|
scheduleProcessExit = (delayMs, reason) => {
|
|
174
170
|
console.warn(`Gateway restart requested (${reason}).`);
|
|
@@ -383,20 +379,18 @@ var NextclawServiceRuntime = class {
|
|
|
383
379
|
update = async (opts) => {
|
|
384
380
|
const versionBefore = this.version;
|
|
385
381
|
if (!opts.json) console.log(`Current npm launcher version: ${versionBefore}`);
|
|
386
|
-
const snapshot = await new NpmRuntimeUpdateCommandService(
|
|
387
|
-
launcherVersion: versionBefore,
|
|
388
|
-
packagedPublicKeyPath: this.packagedPublicKeyPath
|
|
389
|
-
}).run(opts);
|
|
382
|
+
const snapshot = await new NpmRuntimeUpdateCommandService().run(opts);
|
|
390
383
|
if (snapshot.status === "blocked" || snapshot.status === "failed") process.exit(1);
|
|
391
384
|
const state = managedServiceStateStore.read();
|
|
392
385
|
if (snapshot.requiresRestart && state && isProcessRunning(state.pid)) console.log(`Tip: restart ${APP_NAME} to apply the update.`);
|
|
393
386
|
};
|
|
394
387
|
};
|
|
395
|
-
const runNextclawNpmRuntimeLauncher = (argv = process.argv
|
|
388
|
+
const runNextclawNpmRuntimeLauncher = (argv = process.argv) => {
|
|
389
|
+
const distribution = NextclawDistributionService.get();
|
|
396
390
|
new NpmRuntimeLauncher({
|
|
397
391
|
argv,
|
|
398
|
-
launcherVersion:
|
|
399
|
-
packagedAppEntrypoint:
|
|
392
|
+
launcherVersion: distribution.version,
|
|
393
|
+
packagedAppEntrypoint: distribution.appEntrypoint
|
|
400
394
|
}).run();
|
|
401
395
|
};
|
|
402
396
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RequestRestartParams } from "../../types/cli.types.js";
|
|
2
|
+
import { NextclawDistribution } from "../../types/distribution.types.js";
|
|
2
3
|
import { GatewayControllerImpl } from "../../controllers/gateway.controller.js";
|
|
3
4
|
import { GatewayPluginManager } from "./managers/gateway-plugin.manager.js";
|
|
4
5
|
import { GatewayRemoteManager } from "./managers/gateway-remote.manager.js";
|
|
@@ -45,6 +46,7 @@ declare class NextclawGatewayRuntime {
|
|
|
45
46
|
readonly runtimeControl: UiRuntimeControlHost;
|
|
46
47
|
readonly runtimeUpdate: UiRuntimeUpdateHost | null;
|
|
47
48
|
readonly ingress: Ingress;
|
|
49
|
+
readonly distribution: NextclawDistribution;
|
|
48
50
|
readonly productVersion: string;
|
|
49
51
|
readonly providerManager: LlmProviderManager;
|
|
50
52
|
readonly gatewayController: GatewayControllerImpl;
|
|
@@ -62,7 +64,7 @@ declare class NextclawGatewayRuntime {
|
|
|
62
64
|
liveAgentRuntime: AgentRuntimeHandle | null;
|
|
63
65
|
readonly fileWatchers: ServiceFileWatcherRegistry;
|
|
64
66
|
private deferredChannelStarter;
|
|
65
|
-
constructor(deps: GatewayRuntimeDeps, options
|
|
67
|
+
constructor(deps: GatewayRuntimeDeps, options: GatewayRuntimeOptions);
|
|
66
68
|
start: () => Promise<void>;
|
|
67
69
|
private reset;
|
|
68
70
|
get ncpAgent(): UiNcpAgent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getPackageVersion as getPackageVersion$1 } from "../../utils/package/package-manifest.utils.js";
|
|
2
1
|
import { openBrowser, resolveUiConfig, resolveUiStaticDir } from "../../utils/cli.utils.js";
|
|
2
|
+
import { NextclawDistributionService } from "../runtime/nextclaw-distribution.service.js";
|
|
3
3
|
import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
|
|
4
4
|
import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
|
|
5
5
|
import { logStartupTrace, measureStartupAsync, measureStartupSync } from "../../utils/startup-trace.js";
|
|
@@ -45,6 +45,7 @@ var NextclawGatewayRuntime = class {
|
|
|
45
45
|
runtimeControl;
|
|
46
46
|
runtimeUpdate;
|
|
47
47
|
ingress;
|
|
48
|
+
distribution = NextclawDistributionService.get();
|
|
48
49
|
productVersion;
|
|
49
50
|
providerManager;
|
|
50
51
|
gatewayController;
|
|
@@ -62,7 +63,7 @@ var NextclawGatewayRuntime = class {
|
|
|
62
63
|
liveAgentRuntime = null;
|
|
63
64
|
fileWatchers = new ServiceFileWatcherRegistry();
|
|
64
65
|
deferredChannelStarter;
|
|
65
|
-
constructor(deps, options
|
|
66
|
+
constructor(deps, options) {
|
|
66
67
|
this.deps = deps;
|
|
67
68
|
this.options = options;
|
|
68
69
|
const configPath = getConfigPath$1();
|
|
@@ -73,14 +74,14 @@ var NextclawGatewayRuntime = class {
|
|
|
73
74
|
this.configManager = this.kernel.configManager;
|
|
74
75
|
const config = this.configManager.config;
|
|
75
76
|
this.uiConfig = resolveUiConfig(config, options.uiOverrides);
|
|
76
|
-
this.uiStaticDir = options.uiStaticDir === void 0 ? resolveUiStaticDir() : options.uiStaticDir;
|
|
77
|
+
this.uiStaticDir = options.uiStaticDir === void 0 ? resolveUiStaticDir(this.distribution.uiDistDir) : options.uiStaticDir;
|
|
77
78
|
this.workspace = getWorkspacePath$1(config.agents.defaults.workspace);
|
|
78
79
|
this.appEventBus = this.kernel.eventBus;
|
|
79
80
|
this.ingress = this.kernel.ingress;
|
|
80
81
|
this.messageBus = this.kernel.messageBus;
|
|
81
82
|
this.sessionManager = this.kernel.sessions;
|
|
82
83
|
this.automation = this.kernel.automation;
|
|
83
|
-
this.productVersion =
|
|
84
|
+
this.productVersion = this.distribution.version;
|
|
84
85
|
this.plugins = new GatewayPluginManager(this);
|
|
85
86
|
this.providerManager = this.kernel.llmProviders;
|
|
86
87
|
this.installConfigRuntimeHooks();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NextclawDistribution } from "../../types/distribution.types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/services/runtime/nextclaw-distribution.service.d.ts
|
|
4
|
+
declare class NextclawDistributionService {
|
|
5
|
+
private static currentDistribution;
|
|
6
|
+
static configure(distribution: NextclawDistribution): void;
|
|
7
|
+
static get(): NextclawDistribution;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { NextclawDistributionService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/shared/services/runtime/nextclaw-distribution.service.ts
|
|
2
|
+
var NextclawDistributionService = class NextclawDistributionService {
|
|
3
|
+
static currentDistribution = null;
|
|
4
|
+
static configure(distribution) {
|
|
5
|
+
NextclawDistributionService.currentDistribution = distribution;
|
|
6
|
+
}
|
|
7
|
+
static get() {
|
|
8
|
+
if (!NextclawDistributionService.currentDistribution) throw new Error("NextClaw distribution is not configured.");
|
|
9
|
+
return NextclawDistributionService.currentDistribution;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { NextclawDistributionService };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isLoopbackHost, resolvePublicIp } from "../../utils/cli.utils.js";
|
|
1
|
+
import { isLoopbackHost, resolvePublicIp, resolveUiStaticDir } from "../../utils/cli.utils.js";
|
|
2
|
+
import { NextclawDistributionService } from "./nextclaw-distribution.service.js";
|
|
2
3
|
import { describeUnmanagedHealthyTargetMessage, inspectUiTarget } from "../../utils/service-port-probe.utils.js";
|
|
3
4
|
import { buildMarketplaceSkillInstallArgs, pickUserFacingCommandSummary } from "../../utils/marketplace/service-marketplace-helpers.utils.js";
|
|
4
5
|
import { resolveCliSubcommandEntry } from "../../utils/marketplace/cli-subcommand-launch.utils.js";
|
|
@@ -15,7 +16,8 @@ var RuntimeCommandService = class {
|
|
|
15
16
|
startGateway: async (options) => await this.startGateway(options),
|
|
16
17
|
printPublicUiUrls: async (host, port) => await this.printPublicUiUrls(host, port),
|
|
17
18
|
printServiceControlHints: () => this.printServiceControlHints(),
|
|
18
|
-
checkUiPortPreflight: async (params) => await this.checkUiPortPreflight(params)
|
|
19
|
+
checkUiPortPreflight: async (params) => await this.checkUiPortPreflight(params),
|
|
20
|
+
resolveUiStaticDir: () => resolveUiStaticDir(NextclawDistributionService.get().uiDistDir)
|
|
19
21
|
});
|
|
20
22
|
constructor(deps) {
|
|
21
23
|
this.deps = deps;
|
|
@@ -29,7 +31,7 @@ var RuntimeCommandService = class {
|
|
|
29
31
|
stopService: this.stopService,
|
|
30
32
|
runCliSubcommand: this.runCliSubcommand,
|
|
31
33
|
installBuiltinMarketplaceSkill: this.installBuiltinMarketplaceSkill
|
|
32
|
-
}, options).start();
|
|
34
|
+
}, { ...options }).start();
|
|
33
35
|
};
|
|
34
36
|
startService = async (options) => {
|
|
35
37
|
await this.managedServiceCommandService.startService(options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isProcessRunning, openBrowser, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig,
|
|
1
|
+
import { isProcessRunning, openBrowser, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, waitForExit } from "../../utils/cli.utils.js";
|
|
2
2
|
import { localUiRuntimeStore } from "../../stores/local-ui-runtime.store.js";
|
|
3
3
|
import { managedServiceStateStore } from "../../stores/managed-service-state.store.js";
|
|
4
4
|
import { probeHealthEndpoint } from "../../utils/service-port-probe.utils.js";
|
|
@@ -171,7 +171,7 @@ var ManagedServiceCommandService = class {
|
|
|
171
171
|
if (options.open) openBrowser(uiUrl);
|
|
172
172
|
await this.deps.startGateway({
|
|
173
173
|
uiOverrides: options.uiOverrides,
|
|
174
|
-
uiStaticDir: resolveUiStaticDir()
|
|
174
|
+
uiStaticDir: this.deps.resolveUiStaticDir()
|
|
175
175
|
});
|
|
176
176
|
};
|
|
177
177
|
startService = async (options) => {
|
|
@@ -181,7 +181,7 @@ var ManagedServiceCommandService = class {
|
|
|
181
181
|
const uiConfig = resolveUiConfig(config, uiOverrides);
|
|
182
182
|
const uiUrl = resolveUiApiBase(uiConfig.host, uiConfig.port);
|
|
183
183
|
const apiUrl = `${uiUrl}/api`;
|
|
184
|
-
const staticDir = resolveUiStaticDir();
|
|
184
|
+
const staticDir = this.deps.resolveUiStaticDir();
|
|
185
185
|
const existing = managedServiceStateStore.read();
|
|
186
186
|
if (existing && isProcessRunning(existing.pid)) {
|
|
187
187
|
await this.handleExistingManagedService({
|
|
@@ -2,10 +2,9 @@ import { NpmRuntimeBundleLayoutStore } from "../../../launcher/npm-runtime-bundl
|
|
|
2
2
|
import { NpmRuntimeBundleService } from "../../../launcher/npm-runtime-bundle.service.js";
|
|
3
3
|
import { NpmRuntimeUpdateSourceService } from "../../../launcher/npm-runtime-update-source.service.js";
|
|
4
4
|
import { NpmRuntimeUpdateStateStore } from "../../../launcher/npm-runtime-update-state.store.js";
|
|
5
|
-
import { getPackageVersion } from "../../utils/package/package-manifest.utils.js";
|
|
6
|
-
import "../../utils/cli.utils.js";
|
|
7
5
|
import { NpmRuntimeUpdateManager } from "../../../launcher/npm-runtime-update.manager.js";
|
|
8
6
|
import { NpmRuntimeUpdateService } from "../../../launcher/npm-runtime-update.service.js";
|
|
7
|
+
import { NextclawDistributionService } from "../runtime/nextclaw-distribution.service.js";
|
|
9
8
|
import { requestManagedServiceRestart } from "./service-remote-access.service.js";
|
|
10
9
|
import { eventKeys } from "@nextclaw/shared";
|
|
11
10
|
//#region src/shared/services/ui/npm-runtime-update-host.service.ts
|
|
@@ -15,26 +14,33 @@ const INITIAL_DOWNLOAD_PROGRESS = {
|
|
|
15
14
|
percent: null
|
|
16
15
|
};
|
|
17
16
|
var NpmRuntimeUpdateHost = class {
|
|
18
|
-
source
|
|
19
|
-
layout
|
|
20
|
-
launcherVersion
|
|
21
|
-
stateStore
|
|
22
|
-
bundleService
|
|
23
|
-
|
|
24
|
-
stateStore: this.stateStore,
|
|
25
|
-
launcherVersion: this.launcherVersion
|
|
26
|
-
});
|
|
27
|
-
updateService = new NpmRuntimeUpdateService({
|
|
28
|
-
layout: this.layout,
|
|
29
|
-
bundleService: this.bundleService,
|
|
30
|
-
launcherVersion: this.launcherVersion,
|
|
31
|
-
bundlePublicKey: this.source.resolveBundlePublicKey() ?? void 0
|
|
32
|
-
});
|
|
17
|
+
source;
|
|
18
|
+
layout;
|
|
19
|
+
launcherVersion;
|
|
20
|
+
stateStore;
|
|
21
|
+
bundleService;
|
|
22
|
+
updateService;
|
|
33
23
|
snapshot;
|
|
34
24
|
activeTask = null;
|
|
35
25
|
automaticSyncStarted = false;
|
|
36
26
|
constructor(deps) {
|
|
37
27
|
this.deps = deps;
|
|
28
|
+
const distribution = NextclawDistributionService.get();
|
|
29
|
+
this.source = new NpmRuntimeUpdateSourceService({ packagedPublicKeyPath: distribution.runtimeUpdatePublicKeyPath });
|
|
30
|
+
this.layout = new NpmRuntimeBundleLayoutStore();
|
|
31
|
+
this.launcherVersion = distribution.version;
|
|
32
|
+
this.stateStore = new NpmRuntimeUpdateStateStore(this.layout.getStatePath(), { defaultChannel: this.source.resolveChannel(void 0, this.launcherVersion) });
|
|
33
|
+
this.bundleService = new NpmRuntimeBundleService({
|
|
34
|
+
layout: this.layout,
|
|
35
|
+
stateStore: this.stateStore,
|
|
36
|
+
launcherVersion: this.launcherVersion
|
|
37
|
+
});
|
|
38
|
+
this.updateService = new NpmRuntimeUpdateService({
|
|
39
|
+
layout: this.layout,
|
|
40
|
+
bundleService: this.bundleService,
|
|
41
|
+
launcherVersion: this.launcherVersion,
|
|
42
|
+
bundlePublicKey: this.source.resolveBundlePublicKey() ?? void 0
|
|
43
|
+
});
|
|
38
44
|
this.snapshot = this.createManager().getSnapshot();
|
|
39
45
|
this.startAutomaticSync();
|
|
40
46
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/shared/types/distribution.types.d.ts
|
|
2
|
+
type NextclawDistribution = {
|
|
3
|
+
version: string;
|
|
4
|
+
packageRoot: string;
|
|
5
|
+
appEntrypoint: string;
|
|
6
|
+
uiDistDir: string;
|
|
7
|
+
runtimeUpdatePublicKeyPath: string;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { NextclawDistribution };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,9 +7,6 @@ declare function resolveUiConfig(config: Config, overrides?: Partial<Config["ui"
|
|
|
7
7
|
declare function resolveUiApiBase(host: string, port: number): string;
|
|
8
8
|
declare function isLoopbackHost(host: string): boolean;
|
|
9
9
|
declare function resolvePublicIp(timeoutMs?: number): Promise<string | null>;
|
|
10
|
-
declare function buildServeArgs(options: {
|
|
11
|
-
uiPort: number;
|
|
12
|
-
}): string[];
|
|
13
10
|
declare function resolveServiceLogPath(): string;
|
|
14
11
|
declare function isProcessRunning(pid: number): boolean;
|
|
15
12
|
declare function waitForExit(pid: number, timeoutMs: number): Promise<boolean>;
|
|
@@ -18,7 +15,7 @@ type ListeningProcessInfo = {
|
|
|
18
15
|
command: string | null;
|
|
19
16
|
};
|
|
20
17
|
declare function findListeningProcessByPort(port: number): ListeningProcessInfo | null;
|
|
21
|
-
declare function resolveUiStaticDir(
|
|
18
|
+
declare function resolveUiStaticDir(packagedUiDistDir?: string | null): string | null;
|
|
22
19
|
declare function openBrowser(url: string): boolean;
|
|
23
20
|
type ExecutableLookupEnv = {
|
|
24
21
|
[key: string]: string | undefined;
|
|
@@ -31,4 +28,4 @@ declare function findExecutableOnPath(binary: string, env?: ExecutableLookupEnv,
|
|
|
31
28
|
declare function printAgentResponse(response: string): void;
|
|
32
29
|
declare function prompt(rl: Interface, question: string): Promise<string>;
|
|
33
30
|
//#endregion
|
|
34
|
-
export { ExecutableLookupEnv, ListeningProcessInfo,
|
|
31
|
+
export { ExecutableLookupEnv, ListeningProcessInfo, findExecutableOnPath, findListeningProcessByPort, getPackageVersion, isLoopbackHost, isProcessRunning, openBrowser, printAgentResponse, prompt, resolvePublicIp, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, resolveUiStaticDir, waitForExit };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getPackageVersion } from "./package/package-manifest.utils.js";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
3
|
import { join, resolve } from "node:path";
|
|
5
4
|
import { createExternalCommandEnv, getLogsPath, resolveLocalUiBaseUrl } from "@nextclaw/core";
|
|
6
5
|
import { existsSync } from "node:fs";
|
|
@@ -52,14 +51,6 @@ async function resolvePublicIp(timeoutMs = 1500) {
|
|
|
52
51
|
}
|
|
53
52
|
return null;
|
|
54
53
|
}
|
|
55
|
-
function buildServeArgs(options) {
|
|
56
|
-
return [
|
|
57
|
-
fileURLToPath(new URL("../../app/index.js", import.meta.url)),
|
|
58
|
-
"serve",
|
|
59
|
-
"--ui-port",
|
|
60
|
-
String(options.uiPort)
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
54
|
function resolveServiceLogPath() {
|
|
64
55
|
return resolve(getLogsPath(), "service.log");
|
|
65
56
|
}
|
|
@@ -171,14 +162,12 @@ function findListeningProcessByPort(port) {
|
|
|
171
162
|
command: lookupProcessCommandByPid(pid)
|
|
172
163
|
};
|
|
173
164
|
}
|
|
174
|
-
function resolveUiStaticDir(
|
|
165
|
+
function resolveUiStaticDir(packagedUiDistDir) {
|
|
175
166
|
if (process.env.NEXTCLAW_DISABLE_STATIC_UI === "1") return null;
|
|
176
167
|
const envDir = process.env.NEXTCLAW_UI_STATIC_DIR;
|
|
177
168
|
if (envDir) return existsSync(join(envDir, "index.html")) ? envDir : null;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const bundledDir = join(pkgRoot, "ui-dist");
|
|
181
|
-
return existsSync(join(bundledDir, "index.html")) ? bundledDir : null;
|
|
169
|
+
if (!packagedUiDistDir) return null;
|
|
170
|
+
return existsSync(join(packagedUiDistDir, "index.html")) ? packagedUiDistDir : null;
|
|
182
171
|
}
|
|
183
172
|
function openBrowser(url) {
|
|
184
173
|
const platform = process.platform;
|
|
@@ -259,4 +248,4 @@ async function prompt(rl, question) {
|
|
|
259
248
|
});
|
|
260
249
|
}
|
|
261
250
|
//#endregion
|
|
262
|
-
export {
|
|
251
|
+
export { findExecutableOnPath, findListeningProcessByPort, getPackageVersion, isLoopbackHost, isProcessRunning, openBrowser, printAgentResponse, prompt, resolvePublicIp, resolveServiceLogPath, resolveUiApiBase, resolveUiConfig, resolveUiStaticDir, waitForExit };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
//#region src/shared/utils/package/package-manifest.utils.d.ts
|
|
2
|
-
declare function findNearestPackageManifest(startDir: string, expectedName?: string): {
|
|
3
|
-
rootDir: string;
|
|
4
|
-
version?: string;
|
|
5
|
-
} | null;
|
|
6
2
|
declare function getPackageVersion(importMetaUrl?: string): string;
|
|
7
3
|
//#endregion
|
|
8
|
-
export {
|
|
4
|
+
export { getPackageVersion };
|
|
@@ -5,44 +5,34 @@ import { readFileSync } from "node:fs";
|
|
|
5
5
|
//#region src/shared/utils/package/package-manifest.utils.ts
|
|
6
6
|
function readPackageManifest(pkgPath) {
|
|
7
7
|
try {
|
|
8
|
-
|
|
9
|
-
return JSON.parse(raw);
|
|
8
|
+
return JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
10
9
|
} catch {
|
|
11
10
|
return null;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
|
-
function
|
|
13
|
+
function findNearestPackageVersion(startDir, expectedName) {
|
|
15
14
|
let current = resolve(startDir);
|
|
16
15
|
while (current.length > 0) {
|
|
17
16
|
const parsed = readPackageManifest(join(current, "package.json"));
|
|
18
|
-
if (parsed && (!expectedName || parsed.name === expectedName)) return
|
|
19
|
-
rootDir: current,
|
|
20
|
-
version: typeof parsed.version === "string" ? parsed.version : void 0
|
|
21
|
-
};
|
|
17
|
+
if (parsed && (!expectedName || parsed.name === expectedName)) return typeof parsed.version === "string" ? parsed.version : void 0;
|
|
22
18
|
const parent = resolve(current, "..");
|
|
23
19
|
if (parent === current) break;
|
|
24
20
|
current = parent;
|
|
25
21
|
}
|
|
26
|
-
return null;
|
|
27
22
|
}
|
|
28
|
-
function
|
|
23
|
+
function findWorkspacePackageVersion(startDir, packageName) {
|
|
29
24
|
let current = resolve(startDir);
|
|
30
25
|
while (current.length > 0) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
if (parsed?.name === packageName) return {
|
|
34
|
-
rootDir,
|
|
35
|
-
version: typeof parsed.version === "string" ? parsed.version : void 0
|
|
36
|
-
};
|
|
26
|
+
const parsed = readPackageManifest(join(join(current, "packages", packageName), "package.json"));
|
|
27
|
+
if (parsed?.name === packageName) return typeof parsed.version === "string" ? parsed.version : void 0;
|
|
37
28
|
const parent = resolve(current, "..");
|
|
38
29
|
if (parent === current) break;
|
|
39
30
|
current = parent;
|
|
40
31
|
}
|
|
41
|
-
return null;
|
|
42
32
|
}
|
|
43
33
|
function getPackageVersion(importMetaUrl = import.meta.url) {
|
|
44
34
|
const cliDir = resolve(fileURLToPath(new URL(".", importMetaUrl)));
|
|
45
|
-
return
|
|
35
|
+
return findNearestPackageVersion(cliDir, "nextclaw") ?? findWorkspacePackageVersion(cliDir, "nextclaw") ?? findNearestPackageVersion(cliDir) ?? getPackageVersion$1();
|
|
46
36
|
}
|
|
47
37
|
//#endregion
|
|
48
|
-
export {
|
|
38
|
+
export { getPackageVersion };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/service",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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/mcp": "0.1.80",
|
|
38
|
-
"@nextclaw/kernel": "0.1.4",
|
|
39
37
|
"@nextclaw/channel-extension-weixin": "0.1.2",
|
|
40
38
|
"@nextclaw/core": "0.12.15",
|
|
41
39
|
"@nextclaw/ncp-agent-runtime": "0.3.18",
|
|
40
|
+
"@nextclaw/kernel": "0.1.4",
|
|
41
|
+
"@nextclaw/ncp-http-agent-server": "0.3.20",
|
|
42
42
|
"@nextclaw/ncp": "0.5.8",
|
|
43
43
|
"@nextclaw/ncp-mcp": "0.1.82",
|
|
44
|
-
"@nextclaw/nextclaw-hermes-acp-bridge": "0.1.7",
|
|
45
44
|
"@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
45
|
"@nextclaw/ncp-toolkit": "0.5.13",
|
|
46
|
+
"@nextclaw/mcp": "0.1.80",
|
|
47
|
+
"@nextclaw/openclaw-compat": "1.0.15",
|
|
49
48
|
"@nextclaw/remote": "0.1.92",
|
|
50
|
-
"@nextclaw/ncp-
|
|
51
|
-
"@nextclaw/runtime": "0.2.47",
|
|
49
|
+
"@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.8",
|
|
52
50
|
"@nextclaw/shared": "0.1.2",
|
|
53
|
-
"@nextclaw/server": "0.12.15"
|
|
51
|
+
"@nextclaw/server": "0.12.15",
|
|
52
|
+
"@nextclaw/runtime": "0.2.47",
|
|
53
|
+
"@nextclaw/nextclaw-hermes-acp-bridge": "0.1.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^20.17.6",
|