@anhlp/alp-client 0.0.1-beta.8 → 0.0.1-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ See [docs/alp/client-sdk.md](../../docs/alp/client-sdk.md) for the transport con
22
22
  request lifecycle, the old-to-new API table and what still waits on the protocol (Task 06) and
23
23
  the gateway (Task 08).
24
24
 
25
- `startIntegration({ name, entry, home, args })` (or `startIntegration(name)`; `name` defaults to `web`) discovers an optional integration's descriptor and starts it detached with `--service` and then `args`, so the entry writes its own log; discovery and the selected `ALP_HOME` are pinned by tests. `name` is a single lowercase path segment (`assertIntegrationName`). With `entry`, that script runs with the current Node and no descriptor, environment or PATH discovery happens; a missing entry is an error even when a live owner would be reused. `web` is alp-web, the service of the ALP CLI (`alp web`): it is never discovered, so it needs its `entry`, and `"web": { "enabled": false }` in the home's settings refuses it and no other integration. Everything once registered under `web` (`integrations/web.json`, the `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its rename; `discoverIntegration('paseo')` reads `ALP_PASEO_INTEGRATION`, then `ALP_WEB_INTEGRATION` for one release, then `ALP_INTEGRATION_ENTRY`. Errors name the integration, the entry and its log under `<home>/logs/integrations`. Either way a live owner of `integrations/<name>.lock` is reused, and the call resolves once that lock is ready and `<home>/<name>.json` names the same pid. Restarting is non-destructive: a daemon left running by an older install is reported as older than the current CLI and is never killed in place.
25
+ `startIntegration({ name, entry, home, args })` (or `startIntegration(name)`; `name` defaults to `web`) discovers an optional integration's descriptor and starts it detached with `--service` and then `args`, so the entry writes its own log; discovery and the selected `ALP_HOME` are pinned by tests. `name` is a single lowercase path segment (`assertIntegrationName`). With `entry`, that script runs with the current Node and no descriptor, environment or PATH discovery happens; a missing entry is an error even when a live owner would be reused. `web` is alp-dashboard, the service of the ALP CLI (`alp dashboard`): it is never discovered, so it needs its `entry`, and `"dashboard": { "enabled": false }` in the home's settings refuses it and no other integration. Everything once registered under `web` (`integrations/web.json`, the `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its rename; `discoverIntegration('paseo')` reads `ALP_PASEO_INTEGRATION`, then `ALP_WEB_INTEGRATION` for one release, then `ALP_INTEGRATION_ENTRY`. Errors name the integration, the entry and its log under `<home>/logs/integrations`. Either way a live owner of `integrations/<name>.lock` is reused, and the call resolves once that lock is ready and `<home>/<name>.json` names the same pid. Restarting is non-destructive: a daemon left running by an older install is reported as older than the current CLI and is never killed in place.
26
26
 
27
27
  Build: `npm run build --workspace=@anhlp/alp-client`. Test: `npm run test --workspace=@anhlp/alp-client`.
28
28
 
package/dist/doctor.js CHANGED
@@ -79,7 +79,7 @@ async function serviceCheck(home, env) {
79
79
  const program2 = service && await installedProgram(service);
80
80
  if (!program2) return void 0;
81
81
  const missing = [];
82
- for (const file of program2) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
82
+ for (const file of program2.filter((arg) => path.isAbsolute(arg))) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
83
83
  return missing.length ? { id: "service", status: "fail", summary: `the ${service.kind} service ${service.name} runs files that are gone; run alp daemon install again`, details: missing } : { id: "service", status: "ok", summary: `${service.kind} runs alpd as ${service.name}` };
84
84
  }
85
85
  var seconds = (ms) => `${Math.round(ms / 1e3)} s`;
package/dist/index.d.ts CHANGED
@@ -153,8 +153,9 @@ export function ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleL
153
153
  /**
154
154
  * The entry of integration `name`: an environment override, a descriptor under the home or a
155
155
  * distribution root, or an `alp-<name>-integration` binary. Discovery never returns an entry for
156
- * `web`: that name belongs to alp-web, which ships with the CLI and is started with its explicit
157
- * entry. Everything once registered under `web` (the descriptor `integrations/web.json`, the
156
+ * `dashboard`: that is alp dashboard's service, which ships with the CLI and is started with its
157
+ * explicit entry; nor for `web`, its name before the rename (t-81b0.5). Everything once registered
158
+ * under `web` (the descriptor `integrations/web.json`, the
158
159
  * `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its
159
160
  * rename to `paseo`, which must never run under the web lock. `ALP_WEB_INTEGRATION` is read for
160
161
  * `paseo` only, after `ALP_PASEO_INTEGRATION`, for one release (like the alp-web-integration alias).
@@ -169,11 +170,11 @@ export function discoverIntegration(name?: string, options?: {
169
170
  }): Promise<string | undefined>;
170
171
  export function integrationAlive(lock: any): boolean;
171
172
  /**
172
- * Starts integration `name` (default `web`) detached with `--service` (then `args`) unless its lock
173
+ * Starts integration `name` (default `dashboard`) detached with `--service` (then `args`) unless its lock
173
174
  * already names a live owner, then waits until its ready lock and `<home>/<name>.json` name the same
174
175
  * pid. `entry` names the script to run with this Node and skips descriptor, environment and PATH
175
- * discovery; `web` (alp-web) is never discovered, so it needs its entry. `"web": { "enabled": false }`
176
- * in the home's settings.json refuses `web` only.
176
+ * discovery; `dashboard` is never discovered, so it needs its entry. `"dashboard": { "enabled": false }`
177
+ * in the home's settings.json (or `web.enabled`, its key before the rename) refuses `dashboard` only.
177
178
  * @param {string | { name?: string, entry?: string, home?: string, args?: string[] }} [nameOrOptions]
178
179
  */
179
180
  export function startIntegration(nameOrOptions?: string | {
package/dist/index.js CHANGED
@@ -8,7 +8,8 @@ import net from "node:net";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
10
10
  import { scrubText } from "@anhlp/alp-core/log";
11
- import { entryCommand } from "@anhlp/alp-core/packaged";
11
+ import { entryCommand, isNativeDaemonName, NATIVE_DAEMON } from "@anhlp/alp-core/packaged";
12
+ import { dashboardSettings } from "@anhlp/alp-core/user-settings";
12
13
  import { createSocketTransport } from "./ipc.js";
13
14
  import { AlpRpcClient } from "./rpc/client.js";
14
15
  import { hello } from "./rpc/handshake.js";
@@ -91,7 +92,7 @@ async function assertPrivateSocket(socketPath) {
91
92
  var isFile = (file) => stat(file).then((info) => info.isFile(), () => false);
92
93
  var BIN_DIRECTORIES = [path.join(os.homedir(), ".alp", "bin"), path.join(os.homedir(), ".npm-global", "bin"), path.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
93
94
  var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
94
- async function cliDaemonEntry(cli, depth = 0) {
95
+ async function cliDaemonEntry(cli, depth = 0, env = process.env) {
95
96
  const base = path.basename(cli).toLowerCase();
96
97
  const root = path.resolve(path.dirname(cli), "..");
97
98
  const alpd = (directory) => path.join(directory, "dist", "alpd.js");
@@ -101,7 +102,7 @@ async function cliDaemonEntry(cli, depth = 0) {
101
102
  const text = await stat(cli).then((info) => info.size <= 64 * 1024 ? readFile(cli, "utf8") : "", () => "");
102
103
  for (const [, quoted] of text.matchAll(/"([^"\r\n]+\.js)"/gi)) {
103
104
  const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path.dirname(cli)}${path.sep}`);
104
- const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1) : void 0;
105
+ const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1, env) : void 0;
105
106
  if (entry) return entry;
106
107
  }
107
108
  return void 0;
@@ -110,7 +111,8 @@ async function cliDaemonEntry(cli, depth = 0) {
110
111
  if (!await isFile(path.join(root, "alp-bundle.json"))) return void 0;
111
112
  const current = path.join(path.dirname(root), "current");
112
113
  const viaCurrent = await realpath(current).then((real) => real === root, () => false);
113
- candidates = [alpd(path.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
114
+ const bundle = viaCurrent ? current : root;
115
+ candidates = [...env.ALP_NATIVE_DAEMON === "0" ? [] : [path.join(bundle, "bin", NATIVE_DAEMON)], alpd(path.join(bundle, "lib", "node_modules", "@anhlp", "alp-cli"))];
114
116
  } else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
115
117
  candidates = [alpd(root)];
116
118
  } else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
@@ -132,7 +134,7 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
132
134
  for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...binDirectories]) {
133
135
  for (const name of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
134
136
  const cli = await realpath(path.join(directory, name)).catch(() => void 0);
135
- const entry = cli && await cliDaemonEntry(cli);
137
+ const entry = cli && await cliDaemonEntry(cli, 0, env);
136
138
  if (entry) return entry;
137
139
  }
138
140
  }
@@ -450,8 +452,10 @@ async function ensureDaemon({ home = alpHome(), entry = (
450
452
  signal?.throwIfAborted();
451
453
  await new Promise((resolve, reject) => {
452
454
  const launch = entryCommand(entry, "daemon", ["--detach", `--startup-timeout=${timeoutMs}`], execPath);
455
+ const launchEnv = { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" };
456
+ if (isNativeDaemonName(launch.command)) delete launchEnv.BUN_BE_BUN;
453
457
  const launcher = spawn(launch.command, launch.args, {
454
- env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" },
458
+ env: launchEnv,
455
459
  stdio: ["ignore", "ignore", "pipe"],
456
460
  windowsHide: true
457
461
  });
@@ -527,9 +531,9 @@ async function distributionRoots() {
527
531
  roots.push(process.cwd());
528
532
  return [...new Set(roots)];
529
533
  }
530
- async function discoverIntegration(name = "web", options = {}) {
534
+ async function discoverIntegration(name = "dashboard", options = {}) {
531
535
  assertIntegrationName(name);
532
- if (name === "web") return void 0;
536
+ if (name === "dashboard" || name === "web") return void 0;
533
537
  const { env = process.env, binDirectories = BIN_DIRECTORIES, roots } = options;
534
538
  const envCandidates = [
535
539
  env[`ALP_${name.toUpperCase()}_INTEGRATION`],
@@ -564,10 +568,10 @@ function integrationAlive(lock) {
564
568
  }
565
569
  function integrationText(name, home) {
566
570
  const logs = path.join(home, "logs", "integrations");
567
- if (name === "web") return {
568
- what: "alp web",
569
- log: path.join(logs, "alp-web.log"),
570
- missing: "alp web runs the alp-web service of the ALP CLI, which is started with its entry (packages/cli/dist/alp-web.js); run `alp web`"
571
+ if (name === "dashboard") return {
572
+ what: "alp dashboard",
573
+ log: path.join(logs, "alp-dashboard.log"),
574
+ missing: "alp dashboard runs the alp-dashboard service of the ALP CLI, which is started with its entry (packages/cli/dist/alp-dashboard.js); run `alp dashboard`"
571
575
  };
572
576
  if (name === "paseo") return {
573
577
  what: "The Paseo integration",
@@ -580,9 +584,9 @@ function integrationText(name, home) {
580
584
  missing: `ALP integration ${name} is not installed: no ALP_${name.toUpperCase()}_INTEGRATION, descriptor <home>/integrations/${name}.json or alp-${name}-integration binary was found.`
581
585
  };
582
586
  }
583
- async function startIntegration(nameOrOptions = "web") {
587
+ async function startIntegration(nameOrOptions = "dashboard") {
584
588
  const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions ?? {};
585
- const name = assertIntegrationName(options.name ?? "web");
589
+ const name = assertIntegrationName(options.name ?? "dashboard");
586
590
  if (options.entry !== void 0 && (typeof options.entry !== "string" || !options.entry)) throw new TypeError("startIntegration entry must be a non-empty path");
587
591
  const args = options.args ?? [];
588
592
  if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string")) throw new TypeError("startIntegration args must be a list of strings");
@@ -595,13 +599,13 @@ async function startIntegration(nameOrOptions = "web") {
595
599
  const lockPath = pathMod.join(home, "integrations", `${name}.lock`);
596
600
  const webPath = pathMod.join(home, `${name}.json`);
597
601
  const started = explicit ? ` (entry ${explicit})` : "";
598
- if (name === "web") {
602
+ if (name === "dashboard") {
599
603
  let settings = {};
600
604
  try {
601
605
  settings = JSON.parse(await fs.readFile(pathMod.join(home, "settings.json"), "utf8"));
602
606
  } catch {
603
607
  }
604
- if (settings?.web?.enabled === false) throw new Error('alp web is disabled by settings ("web.enabled": false).');
608
+ if (dashboardSettings(settings).enabled === false) throw new Error('alp dashboard is disabled by settings ("dashboard.enabled": false).');
605
609
  }
606
610
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
607
611
  const readLock2 = async () => {
@@ -626,7 +630,7 @@ async function startIntegration(nameOrOptions = "web") {
626
630
  const info = await readWeb();
627
631
  if (info && info.pid === lock2.pid) return lock2;
628
632
  }
629
- if (name === "web" && webStartupFailed()) throw new Error(`${text.what}${started} failed to start; see ${text.log}`);
633
+ if (name === "dashboard" && webStartupFailed()) throw new Error(`${text.what}${started} failed to start; see ${text.log}`);
630
634
  await sleep(100);
631
635
  }
632
636
  const lock = await readLock2();
@@ -642,7 +646,7 @@ async function startIntegration(nameOrOptions = "web") {
642
646
  const entry = explicit ?? await discoverIntegration(name, { home });
643
647
  if (!entry) throw new Error(text.missing);
644
648
  const { spawn: spawn2 } = await import("node:child_process");
645
- const launch = name === "web" ? entryCommand(entry, "web", ["--service", ...args]) : entryCommand(entry, "web", ["--service", ...args], void 0, { scriptOnly: true });
649
+ const launch = name === "dashboard" ? entryCommand(entry, "dashboard", ["--service", ...args]) : entryCommand(entry, "dashboard", ["--service", ...args], void 0, { scriptOnly: true });
646
650
  const child = spawn2(launch.command, launch.args, { stdio: "ignore", detached: true, env: { ...process.env, ALP_HOME: home } });
647
651
  let spawnError = null;
648
652
  child.on("error", (error) => {
package/dist/service.d.ts CHANGED
@@ -32,14 +32,14 @@ export function serviceFor({ home, env, platform, uid }: {
32
32
  ignore: boolean;
33
33
  })[][];
34
34
  } | undefined;
35
- /** The service definition that runs `entry` (alpd.js with `execPath`, or an `alp` command) for `home`. */
35
+ /** The service definition that runs `entry` (alpd.js with `execPath`, the native alpd, or an `alp` command) for `home`. */
36
36
  export function serviceDefinition(service: any, { home, entry, execPath, env }: {
37
37
  home: any;
38
38
  entry: any;
39
39
  execPath?: string | undefined;
40
40
  env?: NodeJS.ProcessEnv | undefined;
41
41
  }): string;
42
- /** The program an installed definition runs: [node, alpd.js], or undefined when it is not installed. */
42
+ /** The program an installed definition runs: [node, alpd.js] or [alpd, --service] (native, t-81b0.9), or undefined when it is not installed. */
43
43
  export function installedProgram(service: any): Promise<any[] | undefined>;
44
44
  /** Writes the definition and loads it, which starts alpd. */
45
45
  export function installService(service: any, options: any, run?: typeof runCommand): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-client",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.1-beta.9",
4
4
  "type": "module",
5
5
  "description": "ALP client: portable JSON-RPC SDK, WebSocket and Node IPC transports, daemon discovery and setup",
6
6
  "files": [
@@ -150,8 +150,8 @@
150
150
  "node": ">=22.12"
151
151
  },
152
152
  "dependencies": {
153
- "@anhlp/alp-core": "0.0.1-beta.8",
154
- "@anhlp/alp-protocol": "0.0.1-beta.8"
153
+ "@anhlp/alp-core": "0.0.1-beta.9",
154
+ "@anhlp/alp-protocol": "0.0.1-beta.9"
155
155
  },
156
156
  "scripts": {
157
157
  "build": "node ../../scripts/build-workspace.mjs client",
package/src/doctor.js CHANGED
@@ -78,13 +78,14 @@ async function runtimeChecks({ env, run }) {
78
78
  return checks;
79
79
  }
80
80
 
81
- /** An installed alpd service whose node or alpd.js moved can no longer start alpd. */
81
+ /** An installed alpd service whose node, alpd.js or native alpd moved can no longer start alpd. */
82
82
  async function serviceCheck(home, env) {
83
83
  const service = serviceFor({ home, env });
84
84
  const program = service && await installedProgram(service);
85
85
  if (!program) return undefined;
86
86
  const missing = [];
87
- for (const file of program) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
87
+ // [node, alpd.js], or [alpd, --service] for the native alpd (t-81b0.9): only the files.
88
+ for (const file of program.filter(arg => path.isAbsolute(arg))) if (!await lstat(file).then(() => true, () => false)) missing.push(file);
88
89
  return missing.length
89
90
  ? { id: 'service', status: 'fail', summary: `the ${service.kind} service ${service.name} runs files that are gone; run alp daemon install again`, details: missing }
90
91
  : { id: 'service', status: 'ok', summary: `${service.kind} runs alpd as ${service.name}` };
package/src/index.js CHANGED
@@ -8,7 +8,8 @@ import os from 'node:os';
8
8
  import path from 'node:path';
9
9
 
10
10
  import { scrubText } from '@anhlp/alp-core/log';
11
- import { entryCommand } from '@anhlp/alp-core/packaged';
11
+ import { entryCommand, isNativeDaemonName, NATIVE_DAEMON } from '@anhlp/alp-core/packaged';
12
+ import { dashboardSettings } from '@anhlp/alp-core/user-settings';
12
13
  import { createSocketTransport } from './ipc.js';
13
14
  import { AlpRpcClient } from './rpc/client.js';
14
15
  import { hello } from './rpc/handshake.js';
@@ -109,13 +110,13 @@ const BIN_DIRECTORIES = [path.join(os.homedir(), '.alp', 'bin'), path.join(os.ho
109
110
  const CLI_PACKAGES = ['@anhlp/alp', '@anhlp/alp-cli'];
110
111
 
111
112
  /**
112
- * alpd.js behind an `alp` found on PATH (its real path), or undefined: the ALP bundle's launcher
113
- * (<bundle>/bin/alp or alp.cmd, t-1807), npm's @anhlp/alp-cli (dist/cli.js) or the @anhlp/alp wrapper (bin/alp.js),
113
+ * alpd behind an `alp` found on PATH (its real path), or undefined: the ALP bundle's launcher
114
+ * (<bundle>/bin/alp or alp.cmd, t-1807; its native alpd when it ships one, t-81b0.9, else its alpd.js), npm's @anhlp/alp-cli (dist/cli.js) or the @anhlp/alp wrapper (bin/alp.js),
114
115
  * which depends on @anhlp/alp-cli (installed beside it, or in its own node_modules). On Windows an
115
116
  * alp.cmd shim of npm or install.ps1 is followed to the script it runs (t-1f14).
116
- * @param {string} cli @param {number} [depth]
117
+ * @param {string} cli @param {number} [depth] @param {NodeJS.ProcessEnv} [env]
117
118
  */
118
- async function cliDaemonEntry(cli, depth = 0) {
119
+ async function cliDaemonEntry(cli, depth = 0, env = process.env) {
119
120
  const base = path.basename(cli).toLowerCase();
120
121
  const root = path.resolve(path.dirname(cli), '..');
121
122
  const alpd = directory => path.join(directory, 'dist', 'alpd.js');
@@ -127,7 +128,7 @@ async function cliDaemonEntry(cli, depth = 0) {
127
128
  const text = await stat(cli).then(info => info.size <= 64 * 1024 ? readFile(cli, 'utf8') : '', () => '');
128
129
  for (const [, quoted] of text.matchAll(/"([^"\r\n]+\.js)"/gi)) {
129
130
  const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path.dirname(cli)}${path.sep}`);
130
- const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1) : undefined;
131
+ const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1, env) : undefined;
131
132
  if (entry) return entry;
132
133
  }
133
134
  return undefined;
@@ -137,7 +138,9 @@ async function cliDaemonEntry(cli, depth = 0) {
137
138
  if (!await isFile(path.join(root, 'alp-bundle.json'))) return undefined;
138
139
  const current = path.join(path.dirname(root), 'current');
139
140
  const viaCurrent = await realpath(current).then(real => real === root, () => false);
140
- candidates = [alpd(path.join(viaCurrent ? current : root, 'lib', 'node_modules', '@anhlp', 'alp-cli'))];
141
+ const bundle = viaCurrent ? current : root;
142
+ // The native alpd first (t-81b0.9), as the bundle's own `alp` starts it; alpd.js where it ships none.
143
+ candidates = [...(env.ALP_NATIVE_DAEMON === '0' ? [] : [path.join(bundle, 'bin', NATIVE_DAEMON)]), alpd(path.join(bundle, 'lib', 'node_modules', '@anhlp', 'alp-cli'))];
141
144
  } else if (base === 'cli.js' && CLI_PACKAGES.includes(await named(root))) {
142
145
  candidates = [alpd(root)];
143
146
  } else if (base === 'alp.js' && await named(root) === '@anhlp/alp') {
@@ -162,7 +165,7 @@ export async function findDaemonEntry({ home = alpHome(), env = process.env, can
162
165
  for (const directory of [...(env.PATH ?? '').split(path.delimiter).filter(Boolean), ...binDirectories]) {
163
166
  for (const name of process.platform === 'win32' ? ['alp.cmd', 'alp'] : ['alp']) {
164
167
  const cli = await realpath(path.join(directory, name)).catch(() => undefined);
165
- const entry = cli && await cliDaemonEntry(cli);
168
+ const entry = cli && await cliDaemonEntry(cli, 0, env);
166
169
  if (entry) return entry;
167
170
  }
168
171
  }
@@ -543,8 +546,11 @@ export async function ensureDaemon({ home = alpHome(), entry = /** @type {string
543
546
  signal?.throwIfAborted();
544
547
  await new Promise((resolve, reject) => {
545
548
  const launch = entryCommand(entry, 'daemon', ['--detach', `--startup-timeout=${timeoutMs}`], execPath);
549
+ // BUN_BE_BUN=1 would turn the native alpd (t-81b0.9) into the Bun CLI instead of starting alpd.
550
+ const launchEnv = { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: '1' };
551
+ if (isNativeDaemonName(launch.command)) delete launchEnv.BUN_BE_BUN;
546
552
  const launcher = spawn(launch.command, launch.args, {
547
- env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: '1' },
553
+ env: launchEnv,
548
554
  stdio: ['ignore', 'ignore', 'pipe'],
549
555
  windowsHide: true,
550
556
  });
@@ -631,18 +637,19 @@ async function distributionRoots() {
631
637
  /**
632
638
  * The entry of integration `name`: an environment override, a descriptor under the home or a
633
639
  * distribution root, or an `alp-<name>-integration` binary. Discovery never returns an entry for
634
- * `web`: that name belongs to alp-web, which ships with the CLI and is started with its explicit
635
- * entry. Everything once registered under `web` (the descriptor `integrations/web.json`, the
640
+ * `dashboard`: that is alp dashboard's service, which ships with the CLI and is started with its
641
+ * explicit entry; nor for `web`, its name before the rename (t-81b0.5). Everything once registered
642
+ * under `web` (the descriptor `integrations/web.json`, the
636
643
  * `alp-web-integration` binary, `ALP_WEB_INTEGRATION`) is the Paseo integration from before its
637
644
  * rename to `paseo`, which must never run under the web lock. `ALP_WEB_INTEGRATION` is read for
638
645
  * `paseo` only, after `ALP_PASEO_INTEGRATION`, for one release (like the alp-web-integration alias).
639
646
  * @param {string} [name]
640
647
  * @param {{ home?: string, env?: NodeJS.ProcessEnv, binDirectories?: string[], roots?: string[] }} [options]
641
648
  */
642
- export async function discoverIntegration(name = 'web', options = {}) {
649
+ export async function discoverIntegration(name = 'dashboard', options = {}) {
643
650
  // The name becomes a descriptor path under <home>/integrations, so it must stay one safe segment.
644
651
  assertIntegrationName(name);
645
- if (name === 'web') return undefined;
652
+ if (name === 'dashboard' || name === 'web') return undefined;
646
653
  const { env = process.env, binDirectories = BIN_DIRECTORIES, roots } = options;
647
654
  // Explicit environment override always wins: the integration's own, then the generic one.
648
655
  const envCandidates = [
@@ -684,17 +691,17 @@ export function integrationAlive(lock) {
684
691
  }
685
692
 
686
693
  /**
687
- * What startIntegration says about integration `name`, and where its service writes its log: alp-web
688
- * (`web`) is part of the CLI, Paseo (`paseo`) an optional package, anything else named as is.
694
+ * What startIntegration says about integration `name`, and where its service writes its log: alp
695
+ * dashboard (`dashboard`) is part of the CLI, Paseo (`paseo`) an optional package, anything else named as is.
689
696
  * @param {string} name
690
697
  * @param {string} home
691
698
  */
692
699
  function integrationText(name, home) {
693
700
  const logs = path.join(home, 'logs', 'integrations');
694
- if (name === 'web') return {
695
- what: 'alp web',
696
- log: path.join(logs, 'alp-web.log'),
697
- missing: 'alp web runs the alp-web service of the ALP CLI, which is started with its entry (packages/cli/dist/alp-web.js); run `alp web`',
701
+ if (name === 'dashboard') return {
702
+ what: 'alp dashboard',
703
+ log: path.join(logs, 'alp-dashboard.log'),
704
+ missing: 'alp dashboard runs the alp-dashboard service of the ALP CLI, which is started with its entry (packages/cli/dist/alp-dashboard.js); run `alp dashboard`',
698
705
  };
699
706
  if (name === 'paseo') return {
700
707
  what: 'The Paseo integration',
@@ -709,16 +716,16 @@ function integrationText(name, home) {
709
716
  }
710
717
 
711
718
  /**
712
- * Starts integration `name` (default `web`) detached with `--service` (then `args`) unless its lock
719
+ * Starts integration `name` (default `dashboard`) detached with `--service` (then `args`) unless its lock
713
720
  * already names a live owner, then waits until its ready lock and `<home>/<name>.json` name the same
714
721
  * pid. `entry` names the script to run with this Node and skips descriptor, environment and PATH
715
- * discovery; `web` (alp-web) is never discovered, so it needs its entry. `"web": { "enabled": false }`
716
- * in the home's settings.json refuses `web` only.
722
+ * discovery; `dashboard` is never discovered, so it needs its entry. `"dashboard": { "enabled": false }`
723
+ * in the home's settings.json (or `web.enabled`, its key before the rename) refuses `dashboard` only.
717
724
  * @param {string | { name?: string, entry?: string, home?: string, args?: string[] }} [nameOrOptions]
718
725
  */
719
- export async function startIntegration(nameOrOptions = 'web') {
726
+ export async function startIntegration(nameOrOptions = 'dashboard') {
720
727
  const options = typeof nameOrOptions === 'string' ? { name: nameOrOptions } : (nameOrOptions ?? {});
721
- const name = assertIntegrationName(options.name ?? 'web');
728
+ const name = assertIntegrationName(options.name ?? 'dashboard');
722
729
  if (options.entry !== undefined && (typeof options.entry !== 'string' || !options.entry)) throw new TypeError('startIntegration entry must be a non-empty path');
723
730
  const args = options.args ?? [];
724
731
  if (!Array.isArray(args) || !args.every(arg => typeof arg === 'string')) throw new TypeError('startIntegration args must be a list of strings');
@@ -734,11 +741,11 @@ export async function startIntegration(nameOrOptions = 'web') {
734
741
  const webPath = pathMod.join(home, `${name}.json`);
735
742
  const started = explicit ? ` (entry ${explicit})` : '';
736
743
 
737
- // web.enabled turns off alp web only; other integrations have their own switches.
738
- if (name === 'web') {
744
+ // dashboard.enabled turns off alp dashboard only; other integrations have their own switches.
745
+ if (name === 'dashboard') {
739
746
  let settings = {};
740
747
  try { settings = JSON.parse(await fs.readFile(pathMod.join(home, 'settings.json'), 'utf8')); } catch {}
741
- if (settings?.web?.enabled === false) throw new Error('alp web is disabled by settings ("web.enabled": false).');
748
+ if (dashboardSettings(settings).enabled === false) throw new Error('alp dashboard is disabled by settings ("dashboard.enabled": false).');
742
749
  }
743
750
 
744
751
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
@@ -760,10 +767,10 @@ export async function startIntegration(nameOrOptions = 'web') {
760
767
  const info = await readWeb();
761
768
  if (info && info.pid === lock.pid) return lock;
762
769
  }
763
- // alp-web can fail during bootstrap after the initial exit check (for example a
770
+ // alp dashboard can fail during bootstrap after the initial exit check (for example a
764
771
  // refused uncertain lock). Its service log carries the cause; do not mask it with
765
- // a readiness/web.json timeout. Check a concurrent winner's ready lock first.
766
- if (name === 'web' && webStartupFailed()) throw new Error(`${text.what}${started} failed to start; see ${text.log}`);
772
+ // a readiness/dashboard.json timeout. Check a concurrent winner's ready lock first.
773
+ if (name === 'dashboard' && webStartupFailed()) throw new Error(`${text.what}${started} failed to start; see ${text.log}`);
767
774
  await sleep(100);
768
775
  }
769
776
  const lock = await readLock();
@@ -786,8 +793,8 @@ export async function startIntegration(nameOrOptions = 'web') {
786
793
  // The child is detached with its stdio ignored, so it cannot rely on the parent's console. `--service`
787
794
  // is the generic contract: the entry writes its own log (the path its error messages advertise) and
788
795
  // keeps the process alive as a service. `--register` still prints to stdout and is not passed here.
789
- // alp-web may be an `alp` command (`alp web serve`); other integrations are scripts.
790
- const launch = name === 'web' ? entryCommand(entry, 'web', ['--service', ...args]) : entryCommand(entry, 'web', ['--service', ...args], undefined, { scriptOnly: true });
796
+ // alp dashboard may be an `alp` command (`alp dashboard serve`); other integrations are scripts.
797
+ const launch = name === 'dashboard' ? entryCommand(entry, 'dashboard', ['--service', ...args]) : entryCommand(entry, 'dashboard', ['--service', ...args], undefined, { scriptOnly: true });
791
798
  const child = spawn(launch.command, launch.args, { stdio: 'ignore', detached: true, env: { ...process.env, ALP_HOME: home } });
792
799
  let spawnError = null;
793
800
  child.on('error', error => { spawnError = error; });
@@ -174,7 +174,7 @@ export function createIntegrationLock(home, name) {
174
174
  try {
175
175
  try { await handle.writeFile(JSON.stringify(value)); info = await handle.stat(); }
176
176
  finally { await handle.close(); }
177
- // Readers (alp web status, a polling client) may hold the lock open; Windows then refuses the
177
+ // Readers (alp dashboard --status, a polling client) may hold the lock open; Windows then refuses the
178
178
  // replace with EPERM/EACCES/EBUSY for a moment, so moveFile retries it there.
179
179
  await moveFile(tmp, file);
180
180
  owned = { owner: value.owner, dev: info.dev, ino: info.ino };
package/src/service.js CHANGED
@@ -54,7 +54,7 @@ export function serviceFor({ home, env = process.env, platform = process.platfor
54
54
  return undefined;
55
55
  }
56
56
 
57
- /** The service definition that runs `entry` (alpd.js with `execPath`, or an `alp` command) for `home`. */
57
+ /** The service definition that runs `entry` (alpd.js with `execPath`, the native alpd, or an `alp` command) for `home`. */
58
58
  export function serviceDefinition(service, { home, entry, execPath = process.execPath, env = process.env }) {
59
59
  const variables = { ALP_HOME: path.resolve(home), PATH: env.PATH ?? '' };
60
60
  for (const name of CARRIED) if (env[name]) variables[name] = env[name];
@@ -115,7 +115,7 @@ WantedBy=default.target
115
115
  `;
116
116
  }
117
117
 
118
- /** The program an installed definition runs: [node, alpd.js], or undefined when it is not installed. */
118
+ /** The program an installed definition runs: [node, alpd.js] or [alpd, --service] (native, t-81b0.9), or undefined when it is not installed. */
119
119
  export async function installedProgram(service) {
120
120
  const text = await readFile(service.file, 'utf8').catch(() => undefined);
121
121
  if (text === undefined) return undefined;
package/src/supervise.js CHANGED
@@ -87,7 +87,7 @@ export function superviseDaemon({ home, entry, env = process.env, intervalMs = 5
87
87
  // Stopped while this check looked: start nothing.
88
88
  if (++missed >= misses && !stopped) await start('was down; started it again');
89
89
  };
90
- // `by` names the supervising service in the log, for example `Paseo` or `alp web`.
90
+ // `by` names the supervising service in the log, for example `Paseo` or `alp dashboard`.
91
91
  const initial = start(by ? `started with ${by}` : 'started', false);
92
92
  const timer = setInterval(() => { void check(); }, intervalMs);
93
93
  timer.unref?.();