@nextclaw/service 0.1.1 → 0.1.3
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/launcher/npm-runtime-launcher.service.d.ts +3 -0
- package/dist/launcher/npm-runtime-launcher.service.js +6 -3
- package/dist/launcher/npm-runtime-update-command.service.d.ts +5 -0
- package/dist/launcher/npm-runtime-update-command.service.js +4 -1
- package/dist/service-runtime.service.d.ts +6 -1
- package/dist/service-runtime.service.js +11 -5
- package/package.json +8 -8
|
@@ -5,6 +5,8 @@ type NpmRuntimeLauncherOptions = {
|
|
|
5
5
|
argv: string[];
|
|
6
6
|
env?: NodeJS.ProcessEnv;
|
|
7
7
|
layout?: NpmRuntimeBundleLayoutStore;
|
|
8
|
+
launcherVersion?: string;
|
|
9
|
+
packagedAppEntrypoint?: string;
|
|
8
10
|
};
|
|
9
11
|
declare class NpmRuntimeLauncher {
|
|
10
12
|
private readonly options;
|
|
@@ -13,6 +15,7 @@ declare class NpmRuntimeLauncher {
|
|
|
13
15
|
constructor(options: NpmRuntimeLauncherOptions);
|
|
14
16
|
run: () => never;
|
|
15
17
|
private resolveRuntimeScriptPath;
|
|
18
|
+
private resolveLauncherVersion;
|
|
16
19
|
private resolvePackagedAppEntrypoint;
|
|
17
20
|
}
|
|
18
21
|
//#endregion
|
|
@@ -29,17 +29,18 @@ var NpmRuntimeLauncher = class {
|
|
|
29
29
|
process.exit(typeof result.status === "number" ? result.status : 1);
|
|
30
30
|
};
|
|
31
31
|
resolveRuntimeScriptPath = () => {
|
|
32
|
+
const launcherVersion = this.resolveLauncherVersion();
|
|
32
33
|
if (this.env.NEXTCLAW_DISABLE_RUNTIME_BUNDLE_LAUNCHER === "1" || this.env.NEXTCLAW_RUNTIME_BUNDLE_CHILD === "1") return this.resolvePackagedAppEntrypoint();
|
|
33
|
-
const stateStore = new NpmRuntimeUpdateStateStore(this.layout.getStatePath(), { defaultChannel: inferDefaultNpmRuntimeReleaseChannel(
|
|
34
|
+
const stateStore = new NpmRuntimeUpdateStateStore(this.layout.getStatePath(), { defaultChannel: inferDefaultNpmRuntimeReleaseChannel(launcherVersion) });
|
|
34
35
|
const bundleService = new NpmRuntimeBundleService({
|
|
35
36
|
layout: this.layout,
|
|
36
37
|
stateStore,
|
|
37
|
-
launcherVersion
|
|
38
|
+
launcherVersion
|
|
38
39
|
});
|
|
39
40
|
try {
|
|
40
41
|
const currentBundle = bundleService.resolveCurrentBundle();
|
|
41
42
|
if (currentBundle && shouldPreferPackagedNpmRuntime({
|
|
42
|
-
launcherVersion
|
|
43
|
+
launcherVersion,
|
|
43
44
|
currentBundleVersion: currentBundle.manifest.runtimeVersion ?? currentBundle.manifest.bundleVersion
|
|
44
45
|
})) return this.resolvePackagedAppEntrypoint();
|
|
45
46
|
return currentBundle?.runtimeScriptPath ?? this.resolvePackagedAppEntrypoint();
|
|
@@ -49,7 +50,9 @@ var NpmRuntimeLauncher = class {
|
|
|
49
50
|
return this.resolvePackagedAppEntrypoint();
|
|
50
51
|
}
|
|
51
52
|
};
|
|
53
|
+
resolveLauncherVersion = () => this.options.launcherVersion ?? getPackageVersion$1();
|
|
52
54
|
resolvePackagedAppEntrypoint = () => {
|
|
55
|
+
if (this.options.packagedAppEntrypoint) return this.options.packagedAppEntrypoint;
|
|
53
56
|
return resolve(dirname(fileURLToPath(import.meta.url)), "../app/index.js");
|
|
54
57
|
};
|
|
55
58
|
};
|
|
@@ -2,7 +2,12 @@ import { UpdateCommandOptions } from "../shared/types/cli.types.js";
|
|
|
2
2
|
import { UpdateSnapshot } from "@nextclaw/kernel/update-contract";
|
|
3
3
|
|
|
4
4
|
//#region src/launcher/npm-runtime-update-command.service.d.ts
|
|
5
|
+
type NpmRuntimeUpdateCommandServiceOptions = {
|
|
6
|
+
launcherVersion?: string;
|
|
7
|
+
};
|
|
5
8
|
declare class NpmRuntimeUpdateCommandService {
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(options?: NpmRuntimeUpdateCommandServiceOptions);
|
|
6
11
|
run: (opts: UpdateCommandOptions) => Promise<UpdateSnapshot>;
|
|
7
12
|
runManaged: (opts: UpdateCommandOptions) => Promise<UpdateSnapshot>;
|
|
8
13
|
private printProgress;
|
|
@@ -8,6 +8,9 @@ import { NpmRuntimeUpdateManager } from "./npm-runtime-update.manager.js";
|
|
|
8
8
|
import { NpmRuntimeUpdateService } from "./npm-runtime-update.service.js";
|
|
9
9
|
//#region src/launcher/npm-runtime-update-command.service.ts
|
|
10
10
|
var NpmRuntimeUpdateCommandService = class {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
11
14
|
run = async (opts) => {
|
|
12
15
|
const snapshot = await this.runManaged(opts);
|
|
13
16
|
if (opts.json) console.log(JSON.stringify(snapshot, null, 2));
|
|
@@ -16,7 +19,7 @@ var NpmRuntimeUpdateCommandService = class {
|
|
|
16
19
|
};
|
|
17
20
|
runManaged = async (opts) => {
|
|
18
21
|
const source = new NpmRuntimeUpdateSourceService();
|
|
19
|
-
const launcherVersion = getPackageVersion();
|
|
22
|
+
const launcherVersion = this.options.launcherVersion ?? getPackageVersion();
|
|
20
23
|
const channel = source.resolveChannel(opts.channel, launcherVersion);
|
|
21
24
|
const manifestUrl = source.resolveManifestUrl(channel, opts.manifestUrl);
|
|
22
25
|
const layout = new NpmRuntimeBundleLayoutStore();
|
|
@@ -23,6 +23,7 @@ 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;
|
|
26
27
|
};
|
|
27
28
|
type NextclawServiceRuntimeAccount = {
|
|
28
29
|
status: (opts?: {
|
|
@@ -58,6 +59,7 @@ type NextclawServiceCommands = {
|
|
|
58
59
|
};
|
|
59
60
|
declare class NextclawServiceRuntime {
|
|
60
61
|
private logo;
|
|
62
|
+
private productVersion;
|
|
61
63
|
private restartCoordinator;
|
|
62
64
|
private serviceRestartTask;
|
|
63
65
|
private selfRelaunchArmed;
|
|
@@ -86,6 +88,9 @@ declare class NextclawServiceRuntime {
|
|
|
86
88
|
agent: (opts: AgentCommandOptions) => Promise<void>;
|
|
87
89
|
update: (opts: UpdateCommandOptions) => Promise<void>;
|
|
88
90
|
}
|
|
89
|
-
declare const runNextclawNpmRuntimeLauncher: (argv?: string[]
|
|
91
|
+
declare const runNextclawNpmRuntimeLauncher: (argv?: string[], options?: {
|
|
92
|
+
launcherVersion?: string;
|
|
93
|
+
packagedAppEntrypoint?: string;
|
|
94
|
+
}) => void;
|
|
90
95
|
//#endregion
|
|
91
96
|
export { NextclawServiceCommands, NextclawServiceRuntime, NextclawServiceRuntimeAccount, NextclawServiceRuntimeOptions, runNextclawNpmRuntimeLauncher };
|
|
@@ -53,6 +53,7 @@ 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;
|
|
56
57
|
restartCoordinator;
|
|
57
58
|
serviceRestartTask = null;
|
|
58
59
|
selfRelaunchArmed = false;
|
|
@@ -66,6 +67,7 @@ var NextclawServiceRuntime = class {
|
|
|
66
67
|
constructor(options = {}) {
|
|
67
68
|
logStartupTrace("cli.runtime.constructor.begin");
|
|
68
69
|
this.logo = options.logo ?? "🤖";
|
|
70
|
+
this.productVersion = options.version ?? getPackageVersion$1();
|
|
69
71
|
this.workspaceManager = measureStartupSync("cli.runtime.workspace_manager", () => new WorkspaceManager(this.logo));
|
|
70
72
|
this.runtimeCommandService = measureStartupSync("cli.runtime.runtime_command_service", () => new RuntimeCommandService({
|
|
71
73
|
requestRestart: (params) => this.requestRestart(params),
|
|
@@ -164,7 +166,7 @@ var NextclawServiceRuntime = class {
|
|
|
164
166
|
};
|
|
165
167
|
};
|
|
166
168
|
get version() {
|
|
167
|
-
return
|
|
169
|
+
return this.productVersion;
|
|
168
170
|
}
|
|
169
171
|
scheduleProcessExit = (delayMs, reason) => {
|
|
170
172
|
console.warn(`Gateway restart requested (${reason}).`);
|
|
@@ -377,16 +379,20 @@ var NextclawServiceRuntime = class {
|
|
|
377
379
|
}
|
|
378
380
|
};
|
|
379
381
|
update = async (opts) => {
|
|
380
|
-
const versionBefore =
|
|
382
|
+
const versionBefore = this.version;
|
|
381
383
|
if (!opts.json) console.log(`Current npm launcher version: ${versionBefore}`);
|
|
382
|
-
const snapshot = await new NpmRuntimeUpdateCommandService().run(opts);
|
|
384
|
+
const snapshot = await new NpmRuntimeUpdateCommandService({ launcherVersion: versionBefore }).run(opts);
|
|
383
385
|
if (snapshot.status === "blocked" || snapshot.status === "failed") process.exit(1);
|
|
384
386
|
const state = managedServiceStateStore.read();
|
|
385
387
|
if (snapshot.requiresRestart && state && isProcessRunning(state.pid)) console.log(`Tip: restart ${APP_NAME} to apply the update.`);
|
|
386
388
|
};
|
|
387
389
|
};
|
|
388
|
-
const runNextclawNpmRuntimeLauncher = (argv = process.argv) => {
|
|
389
|
-
new NpmRuntimeLauncher({
|
|
390
|
+
const runNextclawNpmRuntimeLauncher = (argv = process.argv, options = {}) => {
|
|
391
|
+
new NpmRuntimeLauncher({
|
|
392
|
+
argv,
|
|
393
|
+
launcherVersion: options.launcherVersion,
|
|
394
|
+
packagedAppEntrypoint: options.packagedAppEntrypoint
|
|
395
|
+
}).run();
|
|
390
396
|
};
|
|
391
397
|
//#endregion
|
|
392
398
|
export { NextclawServiceRuntime, runNextclawNpmRuntimeLauncher };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/service",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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/channel-extension-weixin": "0.1.1",
|
|
38
|
-
"@nextclaw/core": "0.12.14",
|
|
39
37
|
"@nextclaw/kernel": "0.1.3",
|
|
40
|
-
"@nextclaw/ncp": "0.5.7",
|
|
41
38
|
"@nextclaw/mcp": "0.1.79",
|
|
39
|
+
"@nextclaw/channel-extension-weixin": "0.1.1",
|
|
40
|
+
"@nextclaw/core": "0.12.14",
|
|
42
41
|
"@nextclaw/ncp-agent-runtime": "0.3.17",
|
|
43
42
|
"@nextclaw/ncp-http-agent-server": "0.3.19",
|
|
44
43
|
"@nextclaw/ncp-mcp": "0.1.81",
|
|
45
|
-
"@nextclaw/ncp
|
|
44
|
+
"@nextclaw/ncp": "0.5.7",
|
|
46
45
|
"@nextclaw/nextclaw-hermes-acp-bridge": "0.1.6",
|
|
47
46
|
"@nextclaw/nextclaw-ncp-runtime-http-client": "0.1.6",
|
|
47
|
+
"@nextclaw/ncp-toolkit": "0.5.12",
|
|
48
48
|
"@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.1.7",
|
|
49
|
+
"@nextclaw/openclaw-compat": "1.0.14",
|
|
50
|
+
"@nextclaw/server": "0.12.14",
|
|
49
51
|
"@nextclaw/remote": "0.1.91",
|
|
50
|
-
"@nextclaw/runtime": "0.2.46",
|
|
51
52
|
"@nextclaw/shared": "0.1.1",
|
|
52
|
-
"@nextclaw/
|
|
53
|
-
"@nextclaw/openclaw-compat": "1.0.14"
|
|
53
|
+
"@nextclaw/runtime": "0.2.46"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^20.17.6",
|