@anhlp/alp-cli 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.
Files changed (50) hide show
  1. package/dist/acp/main.js +1 -1
  2. package/dist/acp.js +180 -82
  3. package/dist/{alp-web → alp-dashboard}/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/{alp-web/assets/TerminalPanel-BbYa_Xkd.js → alp-dashboard/assets/TerminalPanel-BSjqIfNr.js} +1 -1
  5. package/dist/{alp-web/assets/index-DOJh89Ik.js → alp-dashboard/assets/index-CZFfSOIE.js} +5 -5
  6. package/dist/{alp-web → alp-dashboard}/index.html +1 -1
  7. package/dist/{alp-web.js → alp-dashboard.js} +349 -306
  8. package/dist/alpd.js +1308 -1271
  9. package/dist/backup.js +1 -1
  10. package/dist/build-manifest.json +14 -5
  11. package/dist/cli.js +4 -3
  12. package/dist/daemon.d.ts +1 -1
  13. package/dist/daemon.js +6 -6
  14. package/dist/dashboard-migrate.d.ts +31 -0
  15. package/dist/dashboard-migrate.js +127 -0
  16. package/dist/dashboard-service.d.ts +69 -0
  17. package/dist/{web-service.js → dashboard-service.js} +30 -32
  18. package/dist/desktop.d.ts +56 -0
  19. package/dist/desktop.js +91 -0
  20. package/dist/interfaces.d.ts +2 -2
  21. package/dist/interfaces.js +133 -43
  22. package/dist/paths.d.ts +6 -1
  23. package/dist/paths.js +4 -2
  24. package/dist/roles.d.ts +5 -5
  25. package/dist/self-update.d.ts +2 -1
  26. package/dist/self-update.js +7 -1
  27. package/dist/sessions.d.ts +0 -1
  28. package/dist/usage.d.ts +1 -1
  29. package/dist/usage.js +6 -4
  30. package/package.json +6 -6
  31. package/src/cli.js +3 -2
  32. package/src/daemon.js +7 -6
  33. package/src/dashboard-migrate.js +152 -0
  34. package/src/{web-service.js → dashboard-service.js} +54 -48
  35. package/src/desktop.js +122 -0
  36. package/src/interfaces.js +170 -61
  37. package/src/paths.js +9 -3
  38. package/src/roles.js +4 -4
  39. package/src/self-update.js +10 -2
  40. package/src/sessions.js +0 -2
  41. package/src/usage.js +6 -4
  42. package/dist/web-service.d.ts +0 -56
  43. /package/dist/{alp-web → alp-dashboard}/alp-boundary.json +0 -0
  44. /package/dist/{alp-web → alp-dashboard}/apple-touch-icon.png +0 -0
  45. /package/dist/{alp-web → alp-dashboard}/assets/TerminalPanel-DLuoa74B.css +0 -0
  46. /package/dist/{alp-web → alp-dashboard}/assets/highlighter-BnicKQ_d.js +0 -0
  47. /package/dist/{alp-web → alp-dashboard}/assets/index-DwqDSiIi.css +0 -0
  48. /package/dist/{alp-web → alp-dashboard}/favicon-attention.svg +0 -0
  49. /package/dist/{alp-web → alp-dashboard}/favicon-running.svg +0 -0
  50. /package/dist/{alp-web → alp-dashboard}/favicon.svg +0 -0
@@ -11,9 +11,10 @@ import { DAEMON_ENTRY, distributionEntry } from "./paths.js";
11
11
  import { entryCommand } from "@anhlp/alp-core/packaged";
12
12
  import { isAgentProcess } from "@anhlp/alp-core/tasks";
13
13
  import { runRole } from "./roles.js";
14
- import { alpWebEntry, alpWebScript, isWebClaimed, isWebReady, refusal, stopPreRenamePaseo, stopWebService, webOwner } from "./web-service.js";
14
+ import { DASHBOARD, LEGACY_WEB, dashboardEntry, dashboardScript, isDashboardReady, isServiceClaimed, refusal, serviceOwner, stopService } from "./dashboard-service.js";
15
+ import { legacyLeftovers, migrateDashboard } from "./dashboard-migrate.js";
16
+ import { dashboardSettings } from "@anhlp/alp-core/user-settings";
15
17
  var PASEO = "paseo";
16
- var WEB = "web";
17
18
  async function startPaseoIntegration(home) {
18
19
  const entry = await discoverIntegration(PASEO, { home });
19
20
  if (!entry) {
@@ -92,7 +93,7 @@ async function registerProject(home, directory, { timeoutMs = 5e3, connectClient
92
93
  }
93
94
  }
94
95
  async function waitForGrant(home, credentialId, project, { timeoutMs = 5e3 } = {}) {
95
- const credentialsFile = path.join(home, "web", "credentials.json");
96
+ const credentialsFile = path.join(home, "dashboard", "credentials.json");
96
97
  const canonical = await realpath(project).catch(() => project);
97
98
  const deadline = Date.now() + timeoutMs;
98
99
  while (Date.now() < deadline) {
@@ -108,35 +109,65 @@ async function waitForGrant(home, credentialId, project, { timeoutMs = 5e3 } = {
108
109
  }
109
110
  return false;
110
111
  }
111
- async function webDisabled(home) {
112
- const settings = await readFile(path.join(home, "settings.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
113
- return settings?.web?.enabled === false;
114
- }
115
- var DISABLED = 'alp web is disabled by settings ("web.enabled": false).';
116
- async function serveWeb(home, entry) {
117
- await stopPreRenamePaseo(home);
118
- const held = await webOwner(home);
119
- const published = await readFile(path.join(home, "web.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
120
- const lockPid = await readFile(path.join(home, "integrations", "web.lock"), "utf8").then((text) => JSON.parse(text)?.pid, () => void 0);
121
- const claimed = await isWebClaimed(published, lockPid, held);
122
- if ("reason" in held && held.alive && held.kind === "foreign" && !claimed) throw new Error(`${refusal(home)} (${held.reason}). Stop it, then run alp web again.`);
112
+ async function dashboardDisabled(home) {
113
+ const settings = await readJsonFile(path.join(home, "settings.json"));
114
+ return dashboardSettings(settings).enabled === false;
115
+ }
116
+ var DISABLED = 'alp dashboard is disabled by settings ("dashboard.enabled": false).';
117
+ var readJsonFile = (file) => readFile(file, "utf8").then((text) => {
118
+ try {
119
+ return JSON.parse(text);
120
+ } catch {
121
+ return void 0;
122
+ }
123
+ }, () => void 0);
124
+ var readPublished = (home) => readJsonFile(path.join(home, DASHBOARD.info));
125
+ var readServiceLock = (home) => readJsonFile(path.join(home, "integrations", `${DASHBOARD.lock}.lock`));
126
+ async function runningDashboard(home) {
127
+ const lock = await readServiceLock(home);
128
+ if (!Number.isSafeInteger(lock?.pid) || lock.pid <= 0) return void 0;
129
+ try {
130
+ process.kill(lock.pid, 0);
131
+ } catch (error) {
132
+ if (
133
+ /** @type {any} */
134
+ error?.code !== "EPERM"
135
+ ) return void 0;
136
+ }
137
+ const info = await readPublished(home);
138
+ if (info?.app === DASHBOARD.app && info.pid === lock.pid && typeof info.url === "string" && await isDashboardReady(info.url)) return { pid: info.pid, port: info.port, url: info.url };
139
+ return { held: lock.pid };
140
+ }
141
+ var LOOPBACK_HOSTS = ["127.0.0.1", "localhost"];
142
+ async function serveDashboard(home, entry, { port } = {}) {
143
+ const held = await serviceOwner(home);
144
+ const published = await readPublished(home);
145
+ const lockPid = (await readServiceLock(home))?.pid;
146
+ const claimed = await isServiceClaimed(published, lockPid, held);
147
+ if ("reason" in held && held.alive && held.kind === "foreign" && !claimed) throw new Error(`${refusal(home)} (${held.reason}). Stop it, then run alp dashboard again.`);
148
+ if (port !== void 0 && claimed && published.port !== port) {
149
+ throw new Error(`alp dashboard already runs on port ${published.port} (pid ${published.pid}); you asked for port ${port}. Stop it with \`alp dashboard --stop\`, or drop --port to use the running one.`);
150
+ }
123
151
  const project = await currentProject();
124
152
  let lock;
125
153
  try {
126
- lock = await startIntegration({ name: WEB, entry, home, args: project ? ["--project", project] : [] });
154
+ lock = await startIntegration({ name: DASHBOARD.lock, entry, home, args: [...project ? ["--project", project] : [], ...port !== void 0 ? ["--port", String(port)] : []] });
127
155
  } catch (error) {
128
- const owner = await webOwner(home);
156
+ const owner = await serviceOwner(home);
129
157
  if ("reason" in owner && owner.alive) throw new Error(`${error?.message ?? error}
130
- ${refusal(home)} (${owner.reason}). If it is not alp web, stop it, then run alp web again.`, { cause: error });
158
+ ${refusal(home)} (${owner.reason}). If it is not alp dashboard, stop it, then run alp dashboard again.`, { cause: error });
131
159
  throw error;
132
160
  }
133
- const info = await readFile(path.join(home, "web.json"), "utf8").then((text) => JSON.parse(text), () => void 0);
134
- if (info?.app !== "alp-web" || info.pid !== lock.pid) {
135
- const owner = await webOwner(home);
136
- throw new Error(`${refusal(home)}${"reason" in owner ? ` (${owner.reason})` : ""}. Stop pid ${lock.pid}, then run alp web again.`);
161
+ const info = await readPublished(home);
162
+ if (info?.app !== DASHBOARD.app || info.pid !== lock.pid) {
163
+ const owner = await serviceOwner(home);
164
+ throw new Error(`${refusal(home)}${"reason" in owner ? ` (${owner.reason})` : ""}. Stop pid ${lock.pid}, then run alp dashboard again.`);
137
165
  }
138
- if (typeof info.url !== "string" || typeof info.token !== "string" || !await isWebReady(info.url)) {
139
- throw new Error(`alp web published no address; see ${path.join(home, "logs", "integrations", "alp-web.log")}`);
166
+ if (typeof info.url !== "string" || typeof info.token !== "string" || !await isDashboardReady(info.url)) {
167
+ throw new Error(`alp dashboard published no address; see ${path.join(home, "logs", "integrations", "alp-dashboard.log")}`);
168
+ }
169
+ if (port !== void 0 && info.port !== port) {
170
+ throw new Error(`alp dashboard is running on port ${info.port}, not ${port} (port ${port} was busy or alp dashboard was starting already); it was left running there. Stop it with \`alp dashboard --stop\` and free port ${port}, or drop --port`);
140
171
  }
141
172
  if (project) {
142
173
  await registerProject(home, project);
@@ -144,33 +175,92 @@ ${refusal(home)} (${owner.reason}). If it is not alp web, stop it, then run alp
144
175
  }
145
176
  return `${info.url}#token=${info.token}`;
146
177
  }
147
- async function webCommand(args) {
148
- if (isAgentProcess()) throw new Error("alp web is the user's: it prints and rotates the user's credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set)");
178
+ function reportMigration(report) {
179
+ if (report.stopped) console.error(`Stopped ${LEGACY_WEB.what} (pid ${report.stopped}).`);
180
+ if (report.moved.length) console.error(`Moved alp web's files to alp dashboard's names: ${report.moved.join("; ")}`);
181
+ for (const warning of report.warnings) console.error(warning);
182
+ }
183
+ async function statusCommand(home) {
184
+ try {
185
+ const running2 = await runningDashboard(home);
186
+ if (running2 && "url" in running2) {
187
+ console.log("1 alp dashboard process running:");
188
+ console.log(` PID ${running2.pid} [dashboard]: ${running2.url} (port ${running2.port})`);
189
+ } else if (running2) {
190
+ const owner = await serviceOwner(home);
191
+ console.log(`No alp dashboard running. pid ${running2.held} holds ${path.join(home, "integrations", `${DASHBOARD.lock}.lock`)}${"reason" in owner ? ` (${owner.reason})` : ""}.`);
192
+ } else console.log("No alp dashboard running.");
193
+ if (await dashboardDisabled(home)) console.log(DISABLED);
194
+ const left = await legacyLeftovers(home);
195
+ if (left.legacy?.pid) console.log(`${LEGACY_WEB.what} still runs (pid ${left.legacy.pid}); \`alp dashboard\` or \`alp dashboard --stop\` stops it.`);
196
+ else if (left.legacy) console.log(`${refusal(home, LEGACY_WEB)} (${left.legacy.reason}).`);
197
+ for (const item of left.pending) console.log(`From before the rename to alp dashboard, moved by the next \`alp dashboard\`: ${item}`);
198
+ for (const item of left.kept) console.log(`Left from before the rename to alp dashboard, not used: ${item}`);
199
+ } catch (error) {
200
+ console.log(`alp dashboard could not tell everything: ${error?.message ?? error}`);
201
+ }
202
+ }
203
+ async function stopCommand(home) {
204
+ const report = await migrateDashboard(home);
205
+ reportMigration(report);
206
+ if (report.held) process.exitCode = 1;
207
+ const owner = await serviceOwner(home);
208
+ if (!owner.alive && !("pid" in owner)) {
209
+ if (!report.stopped) console.log("No alp dashboard running for this ALP home.");
210
+ return;
211
+ }
212
+ const pid = await stopService(home);
213
+ if (pid) console.log(`Stopped alp dashboard (pid ${pid}).`);
214
+ else console.log("No alp dashboard running for this ALP home.");
215
+ }
216
+ async function dashboardCommand(args) {
217
+ if (isAgentProcess()) throw new Error("alp dashboard is the user's: it prints and rotates the user's credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set)");
149
218
  if (args[0] === "pair") return pairCommand(args.slice(1));
150
219
  if (args[0] === "rotate") return rotateCommand(args.slice(1));
151
- if (args[0] === "serve") return runRole("web", alpWebScript(), args.slice(1));
152
- const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { print: { type: "boolean" } } });
220
+ if (args[0] === "serve") return runRole("dashboard", dashboardScript(), args.slice(1));
221
+ const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
222
+ print: { type: "boolean" },
223
+ "no-open": { type: "boolean" },
224
+ status: { type: "boolean" },
225
+ stop: { type: "boolean" },
226
+ port: { type: "string" },
227
+ host: { type: "string" }
228
+ } });
153
229
  if (positionals.length) throw new UsageError();
154
- const entry = alpWebEntry();
155
230
  const home = alpHome();
156
- if (await webDisabled(home)) throw new Error(DISABLED);
231
+ if (values.status && values.stop) throw new UsageError();
232
+ if (values.status) return statusCommand(home);
233
+ if (values.stop) return stopCommand(home);
234
+ let port;
235
+ if (values.port !== void 0) {
236
+ port = Number(values.port);
237
+ if (!/^\d+$/.test(values.port) || port < 1024 || port > 65535) throw new Error(`--port must be a port from 1024 to 65535, not ${values.port}`);
238
+ }
239
+ if (values.host !== void 0 && !LOOPBACK_HOSTS.includes(values.host)) {
240
+ throw new Error(`alp dashboard listens on this machine only (127.0.0.1): --host ${values.host} is refused. Reach it from another machine through an SSH tunnel to 127.0.0.1.`);
241
+ }
242
+ const entry = dashboardEntry();
243
+ reportMigration(await migrateDashboard(home, { strict: true }));
244
+ if (await dashboardDisabled(home)) throw new Error(DISABLED);
157
245
  await start();
158
- const url = await serveWeb(home, entry);
246
+ let url = await serveDashboard(home, entry, { port });
247
+ if (values.host === "localhost") url = url.replace("://127.0.0.1:", "://localhost:");
159
248
  console.log(url);
160
- if (values.print) return;
249
+ if (values.print || values["no-open"]) return;
161
250
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
162
251
  spawn(opener, [url], { stdio: "ignore", detached: true }).on("error", () => console.error("Open the address above in your browser")).unref();
163
252
  }
164
253
  async function rotateCommand(args) {
165
254
  if (args.length) throw new UsageError();
166
- const entry = alpWebEntry();
255
+ const entry = dashboardEntry();
167
256
  const home = alpHome();
257
+ reportMigration(await migrateDashboard(home, { strict: true }));
168
258
  await start();
169
259
  const project = await projectArgs();
170
260
  for (let attempt = 1; ; attempt++) {
171
- await stopWebService(home);
261
+ await stopService(home);
172
262
  const rotated = await new Promise((resolve) => {
173
- const rotate = entryCommand(entry, "web", ["--rotate", ...project]);
263
+ const rotate = entryCommand(entry, "dashboard", ["--rotate", ...project]);
174
264
  execFile(
175
265
  rotate.command,
176
266
  rotate.args,
@@ -179,14 +269,14 @@ async function rotateCommand(args) {
179
269
  );
180
270
  });
181
271
  if (rotated.code === 0) break;
182
- if (rotated.code !== 3 || attempt >= 3) throw new Error(`alp web could not rotate its token${rotated.output ? `:
272
+ if (rotated.code !== 3 || attempt >= 3) throw new Error(`alp dashboard could not rotate its token${rotated.output ? `:
183
273
  ${rotated.output.slice(-2e3)}` : ""}`);
184
274
  }
185
- if (await webDisabled(home)) {
186
- console.log(`alp web has a new token; the old one no longer works. ${DISABLED.replace(/\.$/, "")}, so it was not started.`);
275
+ if (await dashboardDisabled(home)) {
276
+ console.log(`alp dashboard has a new token; the old one no longer works. ${DISABLED.replace(/\.$/, "")}, so it was not started.`);
187
277
  return;
188
278
  }
189
- console.log(await serveWeb(home, entry));
279
+ console.log(await serveDashboard(home, entry));
190
280
  }
191
281
  async function requestPairing(client, params, attempts = 50) {
192
282
  let last;
@@ -198,7 +288,7 @@ async function requestPairing(client, params, attempts = 50) {
198
288
  if (!unknown) throw outcome.error;
199
289
  await new Promise((resolve) => setTimeout(resolve, 100));
200
290
  }
201
- throw last ?? new Error("alpd did not register web.pairing; run `alp web` to let the integration start, then retry");
291
+ throw last ?? new Error("alpd did not register web.pairing; run `alp dashboard pair` again to let the integration start");
202
292
  }
203
293
  async function pairCommand(args) {
204
294
  const { values, positionals } = parseArgs({ args, allowPositionals: true, options: { on: { type: "boolean" }, off: { type: "boolean" } } });
@@ -210,7 +300,7 @@ async function pairCommand(args) {
210
300
  try {
211
301
  const pairing = await requestPairing(client, values.on ? { enable: true } : values.off ? { enable: false } : {});
212
302
  if (!pairing.relayEnabled) {
213
- console.log(`The relay is off${values.off ? " now" : ""}. Turn it on with: alp web pair --on`);
303
+ console.log(`The relay is off${values.off ? " now" : ""}. Turn it on with: alp dashboard pair --on`);
214
304
  return;
215
305
  }
216
306
  console.log(`Relay ${pairing.endpoint}: ${pairing.connected ? "connected" : "connecting"}`);
@@ -234,9 +324,9 @@ async function acpCommand(args) {
234
324
  }
235
325
  export {
236
326
  acpCommand,
327
+ dashboardCommand,
237
328
  pairCommand,
238
329
  registerProject,
239
330
  requestPairing,
240
- startPaseoIntegration,
241
- webCommand
331
+ startPaseoIntegration
242
332
  };
package/dist/paths.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  /** Locate artifacts in either the independently shipped CLI or the legacy root build. */
2
2
  export function distributionEntry(name: any): URL;
3
- /** What starts alpd: alpd.js under Node (named through app/current in the ALP bundle). */
3
+ /** alpd.js, which `alp daemon run` runs in this process (named through app/current in the ALP bundle). */
4
+ export const DAEMON_SCRIPT: string;
5
+ /**
6
+ * What starts alpd: the bundle's native alpd when it ships one (t-81b0.9), else alpd.js under Node;
7
+ * ALP_NATIVE_DAEMON=0 keeps the Node alpd. Named through app/current in the ALP bundle.
8
+ */
4
9
  export const DAEMON_ENTRY: string;
package/dist/paths.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { existsSync } from "node:fs";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import path from "node:path";
5
- import { selfEntry } from "@anhlp/alp-core/packaged";
5
+ import { daemonEntry, selfEntry } from "@anhlp/alp-core/packaged";
6
6
  function distributionEntry(name) {
7
7
  const entry = process.argv[1] && path.basename(process.argv[1]) === "cli.js" ? pathToFileURL(path.resolve(process.argv[1])) : void 0;
8
8
  const candidates = [
@@ -12,8 +12,10 @@ function distributionEntry(name) {
12
12
  ];
13
13
  return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
14
14
  }
15
- var DAEMON_ENTRY = selfEntry(fileURLToPath(distributionEntry("alpd.js")));
15
+ var DAEMON_SCRIPT = selfEntry(fileURLToPath(distributionEntry("alpd.js")));
16
+ var DAEMON_ENTRY = daemonEntry(fileURLToPath(distributionEntry("alpd.js")));
16
17
  export {
17
18
  DAEMON_ENTRY,
19
+ DAEMON_SCRIPT,
18
20
  distributionEntry
19
21
  };
package/dist/roles.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * The role subcommands (t-1e02): `alp daemon run`, `alp web serve` and `alp bridge acp|antigravity`
3
- * run alpd, alp-web and the MCP bridges in this process: they import the same scripts that
4
- * `node alpd.js` and `node alp-web.js` run. Services and MCP entries written by the single-file
2
+ * The role subcommands (t-1e02): `alp daemon run`, `alp dashboard serve` and `alp bridge acp|antigravity`
3
+ * run alpd, alp-dashboard and the MCP bridges in this process: they import the same scripts that
4
+ * `node alpd.js` and `node alp-dashboard.js` run. Services and MCP entries written by the single-file
5
5
  * executable of 0.0.1-beta.5/6 still name them.
6
6
  *
7
7
  * The role's module reads its options from process.argv as when run directly, so argv is rewritten
8
8
  * to `[runtime, entry, ...args]` before the module loads.
9
- * @param {'daemon' | 'web' | 'acp'} role
9
+ * @param {'daemon' | 'dashboard' | 'acp'} role
10
10
  * @param {string} file the role's script beside this CLI
11
11
  * @param {string[]} args
12
12
  */
13
- export function runRole(role: "daemon" | "web" | "acp", file: string, args: string[]): Promise<any>;
13
+ export function runRole(role: "daemon" | "dashboard" | "acp", file: string, args: string[]): Promise<any>;
14
14
  /** alp bridge acp|antigravity: the stdio MCP bridge an agent CLI starts to reach alpd's tools. @param {string[]} args */
15
15
  export function bridgeCommand(args: string[]): void;
@@ -95,7 +95,7 @@ export function pruneVersions(app: string, keep: string[], fs?: typeof nodeFs, {
95
95
  * fetchBytes: (url: string) => Promise<Uint8Array>, confirm: (question: string) => Promise<boolean>,
96
96
  * provenance: (file: string, repo: string) => string, extract: typeof extract,
97
97
  * daemon: () => Promise<{ version: string, sessions?: number } | undefined>, restartDaemon: (root: string) => number,
98
- * runVersion: (root: string) => string,
98
+ * runVersion: (root: string) => string, runDaemonVersion: (root: string) => string,
99
99
  * }} UpdateDeps
100
100
  */
101
101
  /** @param {string[]} args @param {Partial<UpdateDeps>} [overrides] @returns {Promise<number>} the exit code */
@@ -138,6 +138,7 @@ export type UpdateDeps = {
138
138
  } | undefined>;
139
139
  restartDaemon: (root: string) => number;
140
140
  runVersion: (root: string) => string;
141
+ runDaemonVersion: (root: string) => string;
141
142
  };
142
143
  import { spawnSync } from 'node:child_process';
143
144
  /** Whether a program is on PATH. @param {string} name */
@@ -7,7 +7,7 @@ import path from "node:path";
7
7
  import { createInterface } from "node:readline/promises";
8
8
  import { fileURLToPath, pathToFileURL } from "node:url";
9
9
  import { parseArgs } from "node:util";
10
- import { bundleInfo, samePath } from "@anhlp/alp-core/packaged";
10
+ import { bundleInfo, NATIVE_DAEMON, samePath } from "@anhlp/alp-core/packaged";
11
11
  var DEFAULT_REPO = "phucanh08/alp";
12
12
  var SIGNER_WORKFLOW = ".github/workflows/release-binaries.yml";
13
13
  var NPM_PACKAGE = "@anhlp/alp";
@@ -256,6 +256,8 @@ async function selfUpdate(args, overrides = {}) {
256
256
  const run = bundleCommand(root);
257
257
  return spawnSync(run.command, [...run.args, "--version"], { encoding: "utf8", windowsHide: true, timeout: 6e4 }).stdout?.trim() ?? "";
258
258
  },
259
+ // Without BUN_BE_BUN, which would make the native alpd the Bun CLI.
260
+ runDaemonVersion: (root) => spawnSync(path.join(root, "bin", NATIVE_DAEMON), ["--version"], { encoding: "utf8", windowsHide: true, timeout: 6e4, env: Object.fromEntries(Object.entries(process.env).filter(([name]) => name !== "BUN_BE_BUN")) }).stdout?.trim() ?? "",
259
261
  ...overrides
260
262
  };
261
263
  const { bundle } = deps;
@@ -341,6 +343,10 @@ async function selfUpdate(args, overrides = {}) {
341
343
  if (manifest.version !== asset.version || manifest.platform && manifest.platform !== platform) throw new Error(`${asset.name} holds ALP ${manifest.version} for ${manifest.platform}, not ${asset.version} for ${platform}; nothing was changed`);
342
344
  const reported = deps.runVersion(unpacked);
343
345
  if (reported !== asset.version) throw new Error(`The downloaded ALP reports version ${JSON.stringify(reported)}, not ${asset.version}; nothing was changed`);
346
+ if (deps.env.ALP_NATIVE_DAEMON !== "0" && nodeFs.existsSync(path.join(unpacked, "bin", NATIVE_DAEMON))) {
347
+ const native = deps.runDaemonVersion(unpacked);
348
+ if (native !== asset.version) throw new Error(`The downloaded ALP's native alpd (bin/${NATIVE_DAEMON}) reports version ${JSON.stringify(native)}, not ${asset.version}, so it cannot run here; nothing was changed. To update with alpd on the bundled Node, set ALP_NATIVE_DAEMON=0 for this update and keep it set`);
349
+ }
344
350
  if (nodeFs.existsSync(target)) {
345
351
  if (samePath(target, bundle.root) || running?.version === asset.version) {
346
352
  const moved = `.alp-old-${randomBytes(6).toString("hex")}`;
@@ -41,7 +41,6 @@ export function pause(args: any): Promise<void>;
41
41
  export function resume(args: any): Promise<void>;
42
42
  /** alp language: the language the user reads (ALPD §54); new sessions use it. */
43
43
  export function recall(args: any): Promise<void>;
44
- /** alp web: opens the web app alpd serves on 127.0.0.1, with the token in the address (ALPD §61). */
45
44
  export function interrupt(args: any): Promise<void>;
46
45
  /** alp compact <session>: compacts a root's context now, or at its next turn boundary (t-0e56). */
47
46
  export function compact(args: any): Promise<void>;
package/dist/usage.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export const USAGE: "Usage:\n alp <init|update-template> [directory] create a project, or upgrade an older project's ALP template (upgrade is an alias)\n alp update [--check] [--yes] [--version X] update ALP from GitHub Releases (checksum and provenance checked)\n alp --version\n alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]\n [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]\n [--claude-oracle M] [--codex-oracle M] write Ph\u1EDF/Cafe's agent profiles to .alp/settings.json\n (keeps profiles written by hand; names other teams and the keys to edit)\n alp daemon <start|stop|restart>\n alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready\n alp daemon <install|uninstall> run alpd as a login service that restarts after a crash\n alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)\n alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio\n alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address\n alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)\n alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)\n alp web rotate give alp web a new token: open pages lose access; prints the new address\n alp web pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off\n alp terminal <allow [--paseo] --yes|deny [--paseo]|status> [--json] remote terminals (a shell as you on this host; a workspace is not a sandbox), off by default\n alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to\n alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file\n alp backup verify <file> [--json] | alp backup list [--json]\n alp restore <file> [--home-only] [--dry-run] [--stop] [--replace-newer] [--json] checks the whole backup first; keeps what it replaces\n alpd must be stopped for both; --stop stops it and starts it again after\n alp run [--agent A] [--team pho|cafe|ID] [--model M] [--mode read-only|workspace-write|full-access] [--thinking T] [--project DIR] [--json] <prompt>\n alp schedule create --session ID --at ISO_WITH_OFFSET --prompt TEXT [--project DIR] [--json]\n alp schedule list [--status pending|delivered|failed|cancelled] [--project DIR] [--json]\n alp schedule <show|cancel> ID [--project DIR] [--json] one-shot wake; timer gates only unblock tasks\n alp ps [--all]\n alp top [session] [--once]\n alp attach <session> [--json]\n alp send <session> [--prompt] [--json] <text>\n child default: user mail; --prompt: explicit new prompt to a live root or child\n alp questions [--json]\n alp answer <question> <text> | alp answer <question> --dismiss [--reason R]\n alp log <session> [--json]\n alp board [--project DIR] [--json]\n alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries\n alp skills --retired [--json] skills alp_skill_retire moved to ~/.alp/retired-skills\n alp providers [--json] ACP and Antigravity providers in your library\n alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules\n alp packs [--project DIR] [--json] optional skill packs ALP ships (backend, frontend, architecture, ...)\n alp pack install <id> [--project [DIR]] [--assign] [--json] copy a pack's skills, agents and teams; existing entries are kept\n alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]\n [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]\n alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...\n [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]\n [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]\n alp skill <new|edit> <name> [--project [DIR]] [--from S] [--file FILE]\n alp skill check [name|DIR] [--project [DIR]] [--strict] [--json] validate skills (format, references, links); exit 1 on errors\n alp skill restore <name> [--from DIR] [--roles a,b | --no-roles] bring back a retired skill; --roles needed if it was retired without retired.json\n alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)\n alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]\n alp provider add <id> --command C [--arg A]... [--env K=V]... [--label L] [-d text] [--models a,b] an ACP agent; use id antigravity for native agy\n alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]\n alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider\n without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed\n alp trust [--project DIR] | --revoke [--project DIR] | --list [--json] whether the project's hooks may run\n alp permissions [--project DIR] [--json] each agent's permission profile\n alp permissions check <agent> \"<command>\" what that agent's profile says about a command\n alp tasks [ready] [--all] [--status S] [--label L] [--project DIR] [--json]\n alp tasks gates [--json] open gates; checks GitHub ones\n alp tasks compact [--days 30] [--dry-run]\n alp tasks export [-o file.jsonl] as beads JSONL\n alp tasks import [file.jsonl] [--dry-run] beads JSONL; default .beads/issues.jsonl\n alp formula list | show <name> | pour <name> [--var k=v]... [--parent ID] [--dry-run]\n alp task add <title> [-d text] [-p 0-4] [-t task|bug|feature|chore|epic] [--parent ID] [--after ID]... [-l label]... [--path P]... [--from ID]\n alp task show <id> [--json]\n alp task report <epic> [--json] what an epic came to: tasks, time, rework, verification\n alp task edit <id> [--title T] [-d text] [-p N] [-t type] [-l label]... [--path P]... [-m note]\n alp task close <id> [--reason done|wontfix|duplicate|superseded] [-m summary] [--unverified \"why\"]\n alp verify [--project DIR] [--task ID] [--json] run the project's verify commands; --task records the result\n alp task reopen <id> [-m note]\n alp task dep <add|rm> <id> [--after ID]... [--parent ID] [--related ID]...\n alp task gate add <id> --human \"question\" [--option answer]... | --timer +2h|ISO | --pr N|owner/repo#N | --run N|owner/repo#N\n alp task gate clear <id> <gate> [--choice answer] [-m note] approve; main is told by mail\n alp task gate reject <id> <gate> [-m reason] the gate stays open; main is told by mail\n alp task gate rm <id> <gate> [-m note]\n alp pause [codex|claude] [--now] [-m reason] | alp pause status hold delegation; --now parks running assignments\n alp resume [codex|claude] lift a pause; parked assignments continue\n alp models [--refresh] [--json] the models alpd offers now, from each provider (cached; refreshed every 6 h)\n alp language [name | --reset] the language agents and ALP write to you in; default Vietnamese\n alp recall <assignment|task> [--project DIR] [--json] <question> ask a finished assignment about its work\n alp interrupt <session>\n alp compact <session>";
1
+ export const USAGE: "Usage:\n alp <init|update-template> [directory] create a project, or upgrade an older project's ALP template (upgrade is an alias)\n alp update [--check] [--yes] [--version X] update ALP from GitHub Releases (checksum and provenance checked)\n alp --version\n alp setup [directory] [--runtime codex|claude|mix] [--prefer claude|codex]\n [--claude-model M] [--codex-model M] [--claude-supervisor M] [--codex-supervisor M]\n [--claude-oracle M] [--codex-oracle M] write Ph\u1EDF/Cafe's agent profiles to .alp/settings.json\n (keeps profiles written by hand; names other teams and the keys to edit)\n alp daemon <start|stop|restart>\n alp daemon status [--json] liveness and readiness; exit 0 ready, 3 not running, 4 not ready\n alp daemon <install|uninstall> run alpd as a login service that restarts after a crash\n alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)\n alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio\n alp dashboard [--port N] [--host 127.0.0.1|localhost] [--no-open|--print] open ALP's dashboard in the browser (alp-dashboard, loopback only); --no-open/--print only print its address\n alp dashboard --status|--stop whether alp dashboard runs (address without its token) | stop it\n alp desktop open ALP's desktop app (ALP.app, else the checkout in ALP_DESKTOP_CHECKOUT)\n alp dashboard serve [--service|--rotate] [--project DIR] [--port N] run alp-dashboard in this process (what alp dashboard starts)\n alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)\n alp dashboard rotate give alp dashboard a new token: open pages lose access; prints the new address\n alp dashboard pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off\n alp terminal <allow [--paseo] --yes|deny [--paseo]|status> [--json] remote terminals (a shell as you on this host; a workspace is not a sandbox), off by default\n alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to\n alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file\n alp backup verify <file> [--json] | alp backup list [--json]\n alp restore <file> [--home-only] [--dry-run] [--stop] [--replace-newer] [--json] checks the whole backup first; keeps what it replaces\n alpd must be stopped for both; --stop stops it and starts it again after\n alp run [--agent A] [--team pho|cafe|ID] [--model M] [--mode read-only|workspace-write|full-access] [--thinking T] [--project DIR] [--json] <prompt>\n alp schedule create --session ID --at ISO_WITH_OFFSET --prompt TEXT [--project DIR] [--json]\n alp schedule list [--status pending|delivered|failed|cancelled] [--project DIR] [--json]\n alp schedule <show|cancel> ID [--project DIR] [--json] one-shot wake; timer gates only unblock tasks\n alp ps [--all]\n alp top [session] [--once]\n alp attach <session> [--json]\n alp send <session> [--prompt] [--json] <text>\n child default: user mail; --prompt: explicit new prompt to a live root or child\n alp questions [--json]\n alp answer <question> <text> | alp answer <question> --dismiss [--reason R]\n alp log <session> [--json]\n alp board [--project DIR] [--json]\n alp <agents|skills|mcp|hooks> [--project DIR] [--json] the library: built-in, ~/.alp and project entries\n alp skills --retired [--json] skills alp_skill_retire moved to ~/.alp/retired-skills\n alp providers [--json] ACP and Antigravity providers in your library\n alp teams [--project DIR] [--json] teams sessions run in: members, delegation, house rules\n alp packs [--project DIR] [--json] optional skill packs ALP ships (backend, frontend, architecture, ...)\n alp pack install <id> [--project [DIR]] [--assign] [--json] copy a pack's skills, agents and teams; existing entries are kept\n alp agent <new|edit> <name> [--project [DIR]] [--from A] [-d text] [--provider P] [--model M] [--thinking T] [--mode M]\n [--skills a,b] [--mcp a,b] [--hooks a,b] [--instructions FILE]\n alp team <new|edit> <id> [--project [DIR]] [--from ID] [--label L] [-d text] [--main A] [--member name=role]...\n [--member-model name=M]... [--member-thinking name=T]... [--delegate owner=a,b]... [--max-peers N]\n [--supervisor A] [--supervisor-model M] [--supervisor-thinking T] [--no-supervisor] [--rules FILE]\n alp skill <new|edit> <name> [--project [DIR]] [--from S] [--file FILE]\n alp skill check [name|DIR] [--project [DIR]] [--strict] [--json] validate skills (format, references, links); exit 1 on errors\n alp skill restore <name> [--from DIR] [--roles a,b | --no-roles] bring back a retired skill; --roles needed if it was retired without retired.json\n alp mcp add <name> [--project [DIR]] (--command C [--arg A]... [--env K=V]... [--cwd D] | --url U [--header K=V]...)\n alp hook add <name> [--project [DIR]] --event E --command C [--blocking] [--timeout SEC] [--match-agent A] [--match-label L]\n alp provider add <id> --command C [--arg A]... [--env K=V]... [--label L] [-d text] [--models a,b] an ACP agent; use id antigravity for native agy\n alp <agent|team|skill|mcp|hook|provider> <rm|show> <name> [--project [DIR]] | <cp|mv> <from> <to> [--project [DIR]]\n alp <mcp|hook|provider> test <name> [--project [DIR]] list an MCP server's tools; run a hook once; initialize a provider\n without --project, changes go to your library in ~/.alp; built-in agents and teams are never changed\n alp trust [--project DIR] | --revoke [--project DIR] | --list [--json] whether the project's hooks may run\n alp permissions [--project DIR] [--json] each agent's permission profile\n alp permissions check <agent> \"<command>\" what that agent's profile says about a command\n alp tasks [ready] [--all] [--status S] [--label L] [--project DIR] [--json]\n alp tasks gates [--json] open gates; checks GitHub ones\n alp tasks compact [--days 30] [--dry-run]\n alp tasks export [-o file.jsonl] as beads JSONL\n alp tasks import [file.jsonl] [--dry-run] beads JSONL; default .beads/issues.jsonl\n alp formula list | show <name> | pour <name> [--var k=v]... [--parent ID] [--dry-run]\n alp task add <title> [-d text] [-p 0-4] [-t task|bug|feature|chore|epic] [--parent ID] [--after ID]... [-l label]... [--path P]... [--from ID]\n alp task show <id> [--json]\n alp task report <epic> [--json] what an epic came to: tasks, time, rework, verification\n alp task edit <id> [--title T] [-d text] [-p N] [-t type] [-l label]... [--path P]... [-m note]\n alp task close <id> [--reason done|wontfix|duplicate|superseded] [-m summary] [--unverified \"why\"]\n alp verify [--project DIR] [--task ID] [--json] run the project's verify commands; --task records the result\n alp task reopen <id> [-m note]\n alp task dep <add|rm> <id> [--after ID]... [--parent ID] [--related ID]...\n alp task gate add <id> --human \"question\" [--option answer]... | --timer +2h|ISO | --pr N|owner/repo#N | --run N|owner/repo#N\n alp task gate clear <id> <gate> [--choice answer] [-m note] approve; main is told by mail\n alp task gate reject <id> <gate> [-m reason] the gate stays open; main is told by mail\n alp task gate rm <id> <gate> [-m note]\n alp pause [codex|claude] [--now] [-m reason] | alp pause status hold delegation; --now parks running assignments\n alp resume [codex|claude] lift a pause; parked assignments continue\n alp models [--refresh] [--json] the models alpd offers now, from each provider (cached; refreshed every 6 h)\n alp language [name | --reset] the language agents and ALP write to you in; default Vietnamese\n alp recall <assignment|task> [--project DIR] [--json] <question> ask a finished assignment about its work\n alp interrupt <session>\n alp compact <session>";
2
2
  export class UsageError extends Error {
3
3
  }
package/dist/usage.js CHANGED
@@ -12,11 +12,13 @@ var USAGE = `Usage:
12
12
  alp daemon <install|uninstall> run alpd as a login service that restarts after a crash
13
13
  alp daemon run [--detach] [--service] run alpd in this process (what services written by 0.0.1-beta.5/6 start)
14
14
  alp acp serve ALP to an editor (Zed, JetBrains) over the Agent Client Protocol on stdio
15
- alp web [--print] open the ALP web app on this machine (alp-web, loopback); --print only prints its address
16
- alp web serve [--service|--rotate] [--project DIR] run alp-web in this process (what alp web starts)
15
+ alp dashboard [--port N] [--host 127.0.0.1|localhost] [--no-open|--print] open ALP's dashboard in the browser (alp-dashboard, loopback only); --no-open/--print only print its address
16
+ alp dashboard --status|--stop whether alp dashboard runs (address without its token) | stop it
17
+ alp desktop open ALP's desktop app (ALP.app, else the checkout in ALP_DESKTOP_CHECKOUT)
18
+ alp dashboard serve [--service|--rotate] [--project DIR] [--port N] run alp-dashboard in this process (what alp dashboard starts)
17
19
  alp bridge <acp|antigravity> the stdio MCP bridge an agent CLI starts to reach alpd (internal)
18
- alp web rotate give alp web a new token: open pages lose access; prints the new address
19
- alp web pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off
20
+ alp dashboard rotate give alp dashboard a new token: open pages lose access; prints the new address
21
+ alp dashboard pair [--on|--off] the link that pairs Paseo's app on another device through the relay; --on or --off turns the relay on or off
20
22
  alp terminal <allow [--paseo] --yes|deny [--paseo]|status> [--json] remote terminals (a shell as you on this host; a workspace is not a sandbox), off by default
21
23
  alp doctor [--project DIR] [--fix] [--json] check this machine and project; --fix repairs what is safe to
22
24
  alp backup [-o FILE] [--project DIR]... [--no-projects] [--stop] [--json] sessions, settings, library and tasks in one file
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@anhlp/alp-cli",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.1-beta.9",
4
4
  "type": "module",
5
5
  "description": "ALP cli module",
6
6
  "files": [
7
7
  "src",
8
- "!src/web",
8
+ "!src/dashboard",
9
9
  "dist",
10
10
  "NOTICE"
11
11
  ],
@@ -127,9 +127,9 @@
127
127
  "node": ">=22.12"
128
128
  },
129
129
  "dependencies": {
130
- "@anhlp/alp-core": "0.0.1-beta.8",
131
- "@anhlp/alp-client": "0.0.1-beta.8",
132
- "@anhlp/alp-protocol": "0.0.1-beta.8",
130
+ "@anhlp/alp-core": "0.0.1-beta.9",
131
+ "@anhlp/alp-client": "0.0.1-beta.9",
132
+ "@anhlp/alp-protocol": "0.0.1-beta.9",
133
133
  "smol-toml": "1.9.0",
134
134
  "@agentclientprotocol/sdk": "1.7.0",
135
135
  "@anthropic-ai/claude-agent-sdk": "^0.3.292"
@@ -161,6 +161,6 @@
161
161
  "node-pty": "1.2.0-beta.15"
162
162
  },
163
163
  "devDependencies": {
164
- "@anhlp/alp-gateway": "0.0.1-beta.8"
164
+ "@anhlp/alp-gateway": "0.0.1-beta.9"
165
165
  }
166
166
  }
package/src/cli.js CHANGED
@@ -11,7 +11,8 @@ import { run, ps, attach, send, questions, answer, top, log, board, models, paus
11
11
  import { libraryCommand, editCommand, teamsCommand, packsCommand, packCommand } from './library.js';
12
12
  import { scheduleCommand } from './schedules.js';
13
13
  import { tasksCommand, formulaCommand, taskCommand } from './tasks.js';
14
- import { webCommand, acpCommand } from './interfaces.js';
14
+ import { dashboardCommand, acpCommand } from './interfaces.js';
15
+ import { desktopCommand } from './desktop.js';
15
16
  import { backupCommand, restoreCommand } from './backup.js';
16
17
  import { terminalCommand } from './terminal.js';
17
18
  import { bridgeCommand } from './roles.js';
@@ -47,7 +48,7 @@ async function updateCommand(args) {
47
48
  if (code) process.exitCode = code;
48
49
  }
49
50
 
50
- const commands = { schedule: scheduleCommand, setup: args => setup(args, alpHome()), init: args => project('init', args), 'update-template': args => project('upgrade', args), upgrade: args => project('upgrade', args), update: updateCommand, daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: args => libraryCommand('agents', args), skills: args => libraryCommand('skills', args), mcp: args => ['add', 'rm', 'mv', 'cp', 'test', 'show', 'edit'].includes(args[0]) ? editCommand('mcp', args) : libraryCommand('mcp', args), hooks: args => libraryCommand('hooks', args), providers: args => libraryCommand('providers', args), provider: args => editCommand('providers', args), teams: teamsCommand, packs: packsCommand, pack: packCommand, trust: trustCommand, agent: args => editCommand('agents', args), team: args => editCommand('teams', args), skill: args => editCommand('skills', args), hook: args => editCommand('hooks', args), verify, recall, pause, resume, language, models, interrupt, compact, acp: acpCommand, web: webCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
51
+ const commands = { schedule: scheduleCommand, setup: args => setup(args, alpHome()), init: args => project('init', args), 'update-template': args => project('upgrade', args), upgrade: args => project('upgrade', args), update: updateCommand, daemon, doctor, run, ps, top, attach, send, questions, answer, log, board, tasks: tasksCommand, task: taskCommand, formula: formulaCommand, permissions: permissionsCommand, agents: args => libraryCommand('agents', args), skills: args => libraryCommand('skills', args), mcp: args => ['add', 'rm', 'mv', 'cp', 'test', 'show', 'edit'].includes(args[0]) ? editCommand('mcp', args) : libraryCommand('mcp', args), hooks: args => libraryCommand('hooks', args), providers: args => libraryCommand('providers', args), provider: args => editCommand('providers', args), teams: teamsCommand, packs: packsCommand, pack: packCommand, trust: trustCommand, agent: args => editCommand('agents', args), team: args => editCommand('teams', args), skill: args => editCommand('skills', args), hook: args => editCommand('hooks', args), verify, recall, pause, resume, language, models, interrupt, compact, acp: acpCommand, dashboard: dashboardCommand, desktop: desktopCommand, backup: backupCommand, restore: restoreCommand, terminal: terminalCommand, bridge: bridgeCommand };
51
52
  const [command, ...args] = process.argv.slice(2);
52
53
  try {
53
54
  if (command === '--version') {
package/src/daemon.js CHANGED
@@ -5,14 +5,14 @@ import { holdDaemon, startDaemon } from '@anhlp/alp-client/supervise';
5
5
  import { alpHome, connect, daemonStartTimeoutMs, lockAlive, readLock, withDaemonLifecycle } from '@anhlp/alp-client/index';
6
6
  import { scrubText } from '@anhlp/alp-core/log';
7
7
  import { UsageError } from './usage.js';
8
- import { DAEMON_ENTRY } from './paths.js';
8
+ import { DAEMON_ENTRY, DAEMON_SCRIPT } from './paths.js';
9
9
  import { runRole } from './roles.js';
10
10
 
11
- async function built() {
11
+ async function built(entry = DAEMON_ENTRY) {
12
12
  try {
13
- await access(DAEMON_ENTRY);
13
+ await access(entry);
14
14
  } catch {
15
- throw new Error(`alpd is not built (${DAEMON_ENTRY}); run npm run build`);
15
+ throw new Error(`alpd is not built (${entry}); run npm run build`);
16
16
  }
17
17
  }
18
18
 
@@ -61,8 +61,9 @@ async function stop() {
61
61
  }
62
62
 
63
63
  async function daemon([action, ...rest]) {
64
- // alpd itself in this process; its own options (--detach, --service, --startup-timeout=MS) follow.
65
- if (action === 'run') { await built(); return runRole('daemon', DAEMON_ENTRY, rest); }
64
+ // alpd itself in this process (alpd.js on this Node, even where the bundle ships the native alpd);
65
+ // its own options (--detach, --service, --startup-timeout=MS) follow.
66
+ if (action === 'run') { await built(DAEMON_SCRIPT); return runRole('daemon', DAEMON_SCRIPT, rest); }
66
67
  if (rest.length && !(action === 'status' && rest.length === 1 && rest[0] === '--json')) throw new UsageError();
67
68
  if (action === 'start') {
68
69
  const socket = await start();