@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
package/dist/acp/main.js CHANGED
@@ -6,7 +6,7 @@ import { startDaemon } from "@anhlp/alp-client/supervise";
6
6
  import { createLogger } from "@anhlp/alp-core/log";
7
7
  import { createAcpAgent } from "./agent.js";
8
8
  async function runAcp({ daemonEntry }) {
9
- const version = true ? "0.0.1-beta.8" : "0.0.0";
9
+ const version = true ? "0.0.1-beta.9" : "0.0.0";
10
10
  const logger = createLogger({ component: "acp" });
11
11
  const log = (message, fields) => logger.warn(message, fields);
12
12
  const app = createAcpAgent({
package/dist/acp.js CHANGED
@@ -871,10 +871,10 @@ function mergeDefs(...defs) {
871
871
  function cloneDef(schema) {
872
872
  return mergeDefs(schema._zod.def);
873
873
  }
874
- function getElementAtPath(obj, path5) {
875
- if (!path5)
874
+ function getElementAtPath(obj, path6) {
875
+ if (!path6)
876
876
  return obj;
877
- return path5.reduce((acc, key) => acc?.[key], obj);
877
+ return path6.reduce((acc, key) => acc?.[key], obj);
878
878
  }
879
879
  function promiseAllObject(promisesObj) {
880
880
  const keys = Object.keys(promisesObj);
@@ -1214,11 +1214,11 @@ function explicitlyAborted(x, startIndex = 0) {
1214
1214
  }
1215
1215
  return false;
1216
1216
  }
1217
- function prefixIssues(path5, issues) {
1217
+ function prefixIssues(path6, issues) {
1218
1218
  return issues.map((iss) => {
1219
1219
  var _a3;
1220
1220
  (_a3 = iss).path ?? (_a3.path = []);
1221
- iss.path.unshift(path5);
1221
+ iss.path.unshift(path6);
1222
1222
  return iss;
1223
1223
  });
1224
1224
  }
@@ -1680,16 +1680,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
1680
1680
  }
1681
1681
  function formatError(error62, mapper = (issue2) => issue2.message) {
1682
1682
  const fieldErrors = { _errors: [] };
1683
- const processError = (error63, path5 = []) => {
1683
+ const processError = (error63, path6 = []) => {
1684
1684
  for (const issue2 of error63.issues) {
1685
1685
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1686
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
1686
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
1687
1687
  } else if (issue2.code === "invalid_key") {
1688
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1688
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1689
1689
  } else if (issue2.code === "invalid_element") {
1690
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1690
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1691
1691
  } else {
1692
- const fullpath = [...path5, ...issue2.path];
1692
+ const fullpath = [...path6, ...issue2.path];
1693
1693
  if (fullpath.length === 0) {
1694
1694
  fieldErrors._errors.push(mapper(issue2));
1695
1695
  } else {
@@ -1728,17 +1728,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
1728
1728
  }
1729
1729
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
1730
1730
  const result = { errors: [] };
1731
- const processError = (error63, path5 = []) => {
1731
+ const processError = (error63, path6 = []) => {
1732
1732
  var _a3;
1733
1733
  for (const issue2 of error63.issues) {
1734
1734
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1735
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
1735
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
1736
1736
  } else if (issue2.code === "invalid_key") {
1737
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1737
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1738
1738
  } else if (issue2.code === "invalid_element") {
1739
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
1739
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
1740
1740
  } else {
1741
- const fullpath = [...path5, ...issue2.path];
1741
+ const fullpath = [...path6, ...issue2.path];
1742
1742
  if (fullpath.length === 0) {
1743
1743
  result.errors.push(mapper(issue2));
1744
1744
  continue;
@@ -1777,8 +1777,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
1777
1777
  }
1778
1778
  function toDotPath(_path) {
1779
1779
  const segs = [];
1780
- const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1781
- for (const seg of path5) {
1780
+ const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1781
+ for (const seg of path6) {
1782
1782
  if (typeof seg === "number")
1783
1783
  segs.push(`[${seg}]`);
1784
1784
  else if (typeof seg === "symbol")
@@ -18916,13 +18916,13 @@ function resolveRef(ref, ctx) {
18916
18916
  if (!ref.startsWith("#")) {
18917
18917
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18918
18918
  }
18919
- const path5 = ref.slice(1).split("/").filter(Boolean);
18920
- if (path5.length === 0) {
18919
+ const path6 = ref.slice(1).split("/").filter(Boolean);
18920
+ if (path6.length === 0) {
18921
18921
  return ctx.rootSchema;
18922
18922
  }
18923
18923
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18924
- if (path5[0] === defsKey) {
18925
- const key = path5[1] === void 0 ? void 0 : decodeJSONPointerSegment(path5[1]);
18924
+ if (path6[0] === defsKey) {
18925
+ const key = path6[1] === void 0 ? void 0 : decodeJSONPointerSegment(path6[1]);
18926
18926
  if (!key || !ctx.defs[key]) {
18927
18927
  throw new Error(`Reference not found: ${ref}`);
18928
18928
  }
@@ -23624,11 +23624,11 @@ import { Readable, Writable } from "node:stream";
23624
23624
  import { setTimeout as delay } from "node:timers/promises";
23625
23625
  import { execFileSync, spawn } from "node:child_process";
23626
23626
  import { createHash, randomUUID } from "node:crypto";
23627
- import { fstatSync, readFileSync } from "node:fs";
23627
+ import { fstatSync, readFileSync as readFileSync2 } from "node:fs";
23628
23628
  import { open as open2, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, chmod, rename, rmdir, link } from "node:fs/promises";
23629
23629
  import net from "node:net";
23630
23630
  import os from "node:os";
23631
- import path from "node:path";
23631
+ import path2 from "node:path";
23632
23632
 
23633
23633
  // packages/core/src/log.js
23634
23634
  var LEVELS = Object.freeze({ debug: 10, info: 20, warn: 30, error: 40 });
@@ -23746,27 +23746,122 @@ function createLogger({ component, level, context = {}, write = stderrSink, now
23746
23746
  var TAIL_BYTES = 256 * 1024;
23747
23747
 
23748
23748
  // packages/core/src/packaged.js
23749
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
23750
+ import path from "node:path";
23751
+ var NATIVE = Symbol.for("alp.nativeDaemon");
23752
+ function nativeDaemon() {
23753
+ return (
23754
+ /** @type {any} */
23755
+ globalThis[NATIVE]
23756
+ );
23757
+ }
23758
+ var NATIVE_DAEMON = process.platform === "win32" ? "alpd.exe" : "alpd";
23759
+ var isNativeDaemonName = (file2) => /^alpd(\.exe)?$/i.test(file2.split(/[\\/]/).pop() ?? "");
23760
+ var isBundleDaemon = (file2) => isNativeDaemonName(file2) && path.basename(path.dirname(file2)) === "bin" && existsSync(path.join(path.dirname(path.dirname(file2)), "alp-bundle.json"));
23749
23761
  var ROLE_ARGS = Object.freeze({
23750
23762
  daemon: Object.freeze(["daemon", "run"]),
23751
- web: Object.freeze(["web", "serve"]),
23763
+ dashboard: Object.freeze(["dashboard", "serve"]),
23752
23764
  "bridge-acp": Object.freeze(["bridge", "acp"]),
23753
23765
  "bridge-antigravity": Object.freeze(["bridge", "antigravity"])
23754
23766
  });
23755
23767
  var isExecutableName = (file2) => /^alp(\.exe|\.cmd)?$/i.test(file2.split(/[\\/]/).pop() ?? "");
23756
23768
  var isScript = (file2) => /\.[cm]?js$/i.test(file2);
23769
+ var canonical = (file2) => {
23770
+ let resolved = path.resolve(file2);
23771
+ try {
23772
+ resolved = realpathSync.native(resolved);
23773
+ } catch {
23774
+ }
23775
+ return process.platform === "darwin" || process.platform === "win32" ? resolved.toLowerCase() : resolved;
23776
+ };
23777
+ var samePath = (a, b) => canonical(a) === canonical(b);
23757
23778
  function roleArgs(role) {
23758
23779
  const args = ROLE_ARGS[role];
23759
23780
  if (!args) throw new TypeError(`Unknown ALP role: ${role}`);
23760
23781
  return [...args];
23761
23782
  }
23783
+ var bundles = /* @__PURE__ */ new Map();
23784
+ function bundleInfo(execPath = process.execPath) {
23785
+ if (bundles.has(execPath)) return bundles.get(execPath);
23786
+ let info;
23787
+ try {
23788
+ const real = realpathSync(execPath);
23789
+ const native = isNativeDaemonName(real) && path.basename(path.dirname(real)) === "bin";
23790
+ const nodeDir = path.basename(path.dirname(real)) === "bin" ? path.dirname(path.dirname(real)) : path.dirname(real);
23791
+ const root = native ? nodeDir : path.dirname(nodeDir);
23792
+ if (native || path.basename(nodeDir) === "node") {
23793
+ const manifest = JSON.parse(readFileSync(path.join(root, "alp-bundle.json"), "utf8"));
23794
+ if (manifest?.name === "alp" && typeof manifest.version === "string") {
23795
+ const app = path.dirname(root);
23796
+ const current = path.join(app, "current");
23797
+ info = { root, version: manifest.version, platform: String(manifest.platform ?? ""), app, ...existsSync(current) && samePath(current, root) ? { current } : {} };
23798
+ }
23799
+ }
23800
+ } catch {
23801
+ }
23802
+ bundles.set(execPath, info);
23803
+ return info;
23804
+ }
23805
+ var bundleNode = (bundle) => path.join(bundle.root, "node", process.platform === "win32" ? "node.exe" : "bin/node");
23806
+ function nodeExecutable() {
23807
+ if (!nativeDaemon()) return process.execPath;
23808
+ const bundle = bundleInfo();
23809
+ return bundle ? bundleNode(bundle) : "node";
23810
+ }
23762
23811
  function entryCommand(entry, role, args = [], execPath = process.execPath, { scriptOnly = false } = {}) {
23812
+ if (!scriptOnly && role === "daemon" && isBundleDaemon(entry)) return { command: entry, args: [...args] };
23763
23813
  if (scriptOnly || isScript(entry) || !isExecutableName(entry)) return { command: execPath, args: [entry, ...args] };
23764
23814
  return { command: entry, args: [...roleArgs(role), ...args] };
23765
23815
  }
23766
23816
  function scriptCommand(script, args = []) {
23767
- return { command: process.execPath, args: [script, ...args] };
23817
+ return { command: nodeExecutable(), args: [script, ...args] };
23768
23818
  }
23769
23819
 
23820
+ // packages/core/src/models.js
23821
+ var codexFull = ["low", "medium", "high", "xhigh", "max", "ultra"];
23822
+ var codexStandard = ["low", "medium", "high", "xhigh", "max"];
23823
+ var claudeFull = ["low", "medium", "high", "xhigh", "max", "ultracode"];
23824
+ var claudeLegacy = ["off", "low", "medium", "high", "xhigh", "max", "ultracode"];
23825
+ var claude46 = ["off", "low", "medium", "high", "max"];
23826
+ var MODELS = [
23827
+ ["codex", "gpt-6.1-sol", "GPT-6.1-Sol", "Latest workhorse model for coding and everyday work.", codexFull, "low"],
23828
+ // ALP runs GPT-6 Astra at low effort only.
23829
+ ["codex", "gpt-6-astra", "GPT-6-Astra", "Frontier intelligence for the most demanding work.", ["low"], "low"],
23830
+ ["codex", "gpt-6-sol", "GPT-6-Sol", "Previous generation workhorse model.", codexFull, "low"],
23831
+ ["codex", "gpt-6-luna", "GPT-6-Luna", "Fast and affordable model for easier tasks.", codexStandard, "low"],
23832
+ ["codex", "gpt-5.6-sol", "GPT-5.6-Sol", "Older generation workhorse model.", codexFull, "low"],
23833
+ ["codex", "gpt-5.6-terra", "GPT-5.6-Terra", "Older balanced model for straightforward work.", codexFull, "low"],
23834
+ ["codex", "gpt-5.6-luna", "GPT-5.6-Luna", "Older fast and efficient model.", codexStandard, "low"],
23835
+ ["claude", "claude-opus-5-5", "Opus 5.5", "Latest release.", claudeFull, "medium"],
23836
+ ["claude", "claude-opus-5", "Opus 5", "Previous release.", claudeLegacy, "high"],
23837
+ ["claude", "claude-fable-5-1", "Fable 5.1", "Most powerful model.", claudeFull, "high"],
23838
+ ["claude", "claude-fable-5", "Fable 5", "Previous release.", claudeFull, "high"],
23839
+ ["claude", "claude-opus-4-8[1m]", "Opus 4.8 1M", "Opus 4.8 with 1M context window.", claudeLegacy, "high"],
23840
+ ["claude", "claude-opus-4-8", "Opus 4.8", "Previous release.", claudeLegacy, "high"],
23841
+ ["claude", "claude-sonnet-5-5", "Sonnet 5.5", "Best for everyday tasks.", claudeFull, "medium"],
23842
+ ["claude", "claude-sonnet-5", "Sonnet 5", "Previous release.", claudeLegacy, "high"],
23843
+ ["claude", "claude-sonnet-5[1m]", "Sonnet 5 1M", "Sonnet 5 with 1M context window.", claudeLegacy, "high"],
23844
+ ["claude", "claude-opus-4-7[1m]", "Opus 4.7 1M", "Opus 4.7 with 1M context window.", claudeLegacy, "high"],
23845
+ ["claude", "claude-opus-4-7", "Opus 4.7", "Previous release.", claudeLegacy, "high"],
23846
+ ["claude", "claude-opus-4-6[1m]", "Opus 4.6 1M", "Opus 4.6 with 1M context window.", claude46, "high"],
23847
+ ["claude", "claude-opus-4-6", "Opus 4.6", "Most capable for complex work.", claude46, "high"],
23848
+ ["claude", "claude-sonnet-4-6[1m]", "Sonnet 4.6 1M", "Sonnet 4.6 with 1M context window.", claude46, "high"],
23849
+ ["claude", "claude-sonnet-4-6", "Sonnet 4.6", "Best for everyday tasks.", claude46, "high"],
23850
+ ["claude", "claude-haiku-4-5", "Haiku 4.5", "Fastest for quick answers.", [], void 0],
23851
+ ["claude", "sonnet", "sonnet", "From Claude settings.json model.", [], void 0],
23852
+ ["antigravity", "gemini-3.8-flash-high", "Gemini 3.8 Flash (High)", "High reasoning effort workhorse for complex tasks.", [], void 0],
23853
+ ["antigravity", "gemini-3.8-flash-medium", "Gemini 3.8 Flash (Medium)", "Balanced speed and reasoning.", [], void 0],
23854
+ ["antigravity", "gemini-3.8-flash-low", "Gemini 3.8 Flash (Low)", "Fast and efficient for straightforward work.", [], void 0],
23855
+ ["antigravity", "gemini-2.5-pro", "Gemini 2.5 Pro", "Deep reasoning for coding and analysis.", [], void 0],
23856
+ ["antigravity", "gemini-2.5-flash", "Gemini 2.5 Flash", "Fast and versatile everyday model.", [], void 0],
23857
+ ["antigravity", "claude-sonnet-4-6", "Claude Sonnet 4.6", "Sonnet 4.6 via Antigravity.", [], void 0],
23858
+ ["antigravity", "claude-opus-4-6-thinking", "Claude Opus 4.6 Thinking", "Opus 4.6 with thinking via Antigravity.", [], void 0],
23859
+ ["antigravity", "gpt-oss-120b-medium", "GPT-OSS 120B (Medium)", "Open weights model via Antigravity.", [], void 0]
23860
+ ].map(([runtime, id, label, description, efforts, effort]) => ({ runtime, id, label, description, efforts, ...effort ? { effort } : {} }));
23861
+
23862
+ // packages/core/src/validation.js
23863
+ var DASHBOARD_SETTINGS = Object.freeze(["enabled", "port", "permissions"]);
23864
+
23770
23865
  // packages/protocol/src/wire.js
23771
23866
  var PROTOCOL_VERSION2 = 1;
23772
23867
  var MAX_FRAME = 16 * 1024 * 1024;
@@ -24261,27 +24356,27 @@ var CLOSE_CODE = Object.freeze({ unsupportedData: 4003, tooLarge: 4009 });
24261
24356
 
24262
24357
  // packages/client/src/index.js
24263
24358
  function alpHome(env = process.env) {
24264
- return path.resolve(env.ALP_HOME || path.join(os.homedir(), ".alp"));
24359
+ return path2.resolve(env.ALP_HOME || path2.join(os.homedir(), ".alp"));
24265
24360
  }
24266
24361
  function daemonPaths(home) {
24267
- const preferred = path.join(home, "alpd.sock");
24268
- const socket = process.platform === "win32" ? `\\\\.\\pipe\\alpd-${createHash("sha256").update(home).digest("hex").slice(0, 24)}` : Buffer.byteLength(preferred) < 100 ? preferred : path.join(os.tmpdir(), `alpd-${process.getuid?.() ?? "user"}-${createHash("sha256").update(home).digest("hex").slice(0, 12)}`, "rpc.sock");
24269
- return { home, lock: path.join(home, "alpd.lock"), socket, log: path.join(home, "logs", "alpd.log"), install: path.join(home, "alpd.json") };
24362
+ const preferred = path2.join(home, "alpd.sock");
24363
+ const socket = process.platform === "win32" ? `\\\\.\\pipe\\alpd-${createHash("sha256").update(home).digest("hex").slice(0, 24)}` : Buffer.byteLength(preferred) < 100 ? preferred : path2.join(os.tmpdir(), `alpd-${process.getuid?.() ?? "user"}-${createHash("sha256").update(home).digest("hex").slice(0, 12)}`, "rpc.sock");
24364
+ return { home, lock: path2.join(home, "alpd.lock"), socket, log: path2.join(home, "logs", "alpd.log"), install: path2.join(home, "alpd.json") };
24270
24365
  }
24271
24366
  async function assertSafeAncestors(directory) {
24272
24367
  if (process.platform === "win32") return;
24273
- const absolute = path.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
24274
- let current = path.parse(absolute).root;
24368
+ const absolute = path2.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
24369
+ let current = path2.parse(absolute).root;
24275
24370
  const pending = absolute.slice(current.length).split("/");
24276
24371
  let links = 0;
24277
24372
  while (pending.length) {
24278
24373
  const part = pending.shift();
24279
24374
  if (!part || part === ".") continue;
24280
24375
  if (part === "..") {
24281
- current = path.dirname(current);
24376
+ current = path2.dirname(current);
24282
24377
  continue;
24283
24378
  }
24284
- const candidate = path.join(current, part);
24379
+ const candidate = path2.join(current, part);
24285
24380
  const info = await lstat(candidate).catch((error62) => {
24286
24381
  if (error62.code !== "ENOENT") throw error62;
24287
24382
  });
@@ -24294,8 +24389,8 @@ async function assertSafeAncestors(directory) {
24294
24389
  if (info.isSymbolicLink()) {
24295
24390
  if (++links > 40) throw new Error("IPC ancestor symlink loop");
24296
24391
  const target = await readlink(candidate);
24297
- if (path.isAbsolute(target)) current = path.parse(target).root;
24298
- pending.unshift(...target.slice(path.isAbsolute(target) ? path.parse(target).root.length : 0).split("/"));
24392
+ if (path2.isAbsolute(target)) current = path2.parse(target).root;
24393
+ pending.unshift(...target.slice(path2.isAbsolute(target) ? path2.parse(target).root.length : 0).split("/"));
24299
24394
  continue;
24300
24395
  }
24301
24396
  if (!info.isDirectory() || info.mode & 18 && !(info.mode & 512)) {
@@ -24325,7 +24420,7 @@ async function assertPrivateDirectory(directory, { create = false } = {}) {
24325
24420
  }
24326
24421
  async function assertPrivateSocket(socketPath) {
24327
24422
  if (process.platform === "win32") return;
24328
- await assertPrivateDirectory(path.dirname(socketPath));
24423
+ await assertPrivateDirectory(path2.dirname(socketPath));
24329
24424
  const info = await lstat(socketPath);
24330
24425
  if (!info.isSocket() || info.uid !== process.getuid?.() || (info.mode & 63) !== 0) {
24331
24426
  throw new Error("IPC socket must be owned by the current user with private permissions (0600)");
@@ -24333,32 +24428,33 @@ async function assertPrivateSocket(socketPath) {
24333
24428
  return info;
24334
24429
  }
24335
24430
  var isFile = (file2) => stat(file2).then((info) => info.isFile(), () => false);
24336
- 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"];
24431
+ var BIN_DIRECTORIES = [path2.join(os.homedir(), ".alp", "bin"), path2.join(os.homedir(), ".npm-global", "bin"), path2.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
24337
24432
  var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
24338
- async function cliDaemonEntry(cli, depth = 0) {
24339
- const base = path.basename(cli).toLowerCase();
24340
- const root = path.resolve(path.dirname(cli), "..");
24341
- const alpd = (directory) => path.join(directory, "dist", "alpd.js");
24342
- const named = async (directory) => readFile(path.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
24433
+ async function cliDaemonEntry(cli, depth = 0, env = process.env) {
24434
+ const base = path2.basename(cli).toLowerCase();
24435
+ const root = path2.resolve(path2.dirname(cli), "..");
24436
+ const alpd = (directory) => path2.join(directory, "dist", "alpd.js");
24437
+ const named = async (directory) => readFile(path2.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
24343
24438
  let candidates = [];
24344
- if (base === "alp.cmd" && depth < 1 && !await isFile(path.join(root, "alp-bundle.json"))) {
24439
+ if (base === "alp.cmd" && depth < 1 && !await isFile(path2.join(root, "alp-bundle.json"))) {
24345
24440
  const text = await stat(cli).then((info) => info.size <= 64 * 1024 ? readFile(cli, "utf8") : "", () => "");
24346
24441
  for (const [, quoted] of text.matchAll(/"([^"\r\n]+\.js)"/gi)) {
24347
- const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path.dirname(cli)}${path.sep}`);
24348
- const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1) : void 0;
24442
+ const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path2.dirname(cli)}${path2.sep}`);
24443
+ const entry = path2.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1, env) : void 0;
24349
24444
  if (entry) return entry;
24350
24445
  }
24351
24446
  return void 0;
24352
24447
  }
24353
24448
  if (base === "alp" || base === "alp.cmd") {
24354
- if (!await isFile(path.join(root, "alp-bundle.json"))) return void 0;
24355
- const current = path.join(path.dirname(root), "current");
24449
+ if (!await isFile(path2.join(root, "alp-bundle.json"))) return void 0;
24450
+ const current = path2.join(path2.dirname(root), "current");
24356
24451
  const viaCurrent = await realpath(current).then((real) => real === root, () => false);
24357
- candidates = [alpd(path.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
24452
+ const bundle = viaCurrent ? current : root;
24453
+ candidates = [...env.ALP_NATIVE_DAEMON === "0" ? [] : [path2.join(bundle, "bin", NATIVE_DAEMON)], alpd(path2.join(bundle, "lib", "node_modules", "@anhlp", "alp-cli"))];
24358
24454
  } else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
24359
24455
  candidates = [alpd(root)];
24360
24456
  } else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
24361
- candidates = [alpd(path.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path.join(root, "..", "alp-cli"))];
24457
+ candidates = [alpd(path2.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path2.join(root, "..", "alp-cli"))];
24362
24458
  }
24363
24459
  for (const candidate of candidates) if (await isFile(candidate)) return candidate;
24364
24460
  return void 0;
@@ -24373,10 +24469,10 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
24373
24469
  if (typeof entry === "string" && await isFile(entry)) return entry;
24374
24470
  } catch {
24375
24471
  }
24376
- for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...binDirectories]) {
24472
+ for (const directory of [...(env.PATH ?? "").split(path2.delimiter).filter(Boolean), ...binDirectories]) {
24377
24473
  for (const name of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
24378
- const cli = await realpath(path.join(directory, name)).catch(() => void 0);
24379
- const entry = cli && await cliDaemonEntry(cli);
24474
+ const cli = await realpath(path2.join(directory, name)).catch(() => void 0);
24475
+ const entry = cli && await cliDaemonEntry(cli, 0, env);
24380
24476
  if (entry) return entry;
24381
24477
  }
24382
24478
  }
@@ -24387,7 +24483,7 @@ function bootId() {
24387
24483
  if (cachedBootId !== null) return cachedBootId;
24388
24484
  try {
24389
24485
  if (process.platform === "linux") {
24390
- const id = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
24486
+ const id = readFileSync2("/proc/sys/kernel/random/boot_id", "utf8").trim();
24391
24487
  if (id.length > 0) {
24392
24488
  cachedBootId = id;
24393
24489
  return cachedBootId;
@@ -24508,7 +24604,7 @@ async function tail(file2, lines = 30) {
24508
24604
  }
24509
24605
  }
24510
24606
  async function lifecycleOwners(home) {
24511
- const directory = path.join(home, "state", "alpd.starting");
24607
+ const directory = path2.join(home, "state", "alpd.starting");
24512
24608
  const names = await readdir(directory).catch((error62) => {
24513
24609
  if (error62.code === "ENOENT") return [];
24514
24610
  throw error62;
@@ -24532,14 +24628,14 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
24532
24628
  } catch (cause) {
24533
24629
  throw Object.assign(new Error(`ALP_HOME_UNUSABLE, alpd failed to start while preparing its home: ${cause.message}`, { cause }), { code: "ALP_HOME_UNUSABLE" });
24534
24630
  }
24535
- const state = path.join(home, "state");
24631
+ const state = path2.join(home, "state");
24536
24632
  await assertPrivateDirectory(state, { create: true });
24537
- const directory = path.join(state, "alpd.starting");
24633
+ const directory = path2.join(state, "alpd.starting");
24538
24634
  const currentBootId = bootId();
24539
24635
  const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
24540
- const candidate = path.join(state, `alpd.starting-${token}`);
24636
+ const candidate = path2.join(state, `alpd.starting-${token}`);
24541
24637
  await mkdir(candidate, { mode: 448 });
24542
- await writeFile(path.join(candidate, token), JSON.stringify({
24638
+ await writeFile(path2.join(candidate, token), JSON.stringify({
24543
24639
  pid: process.pid,
24544
24640
  bootTime: bootTime(),
24545
24641
  ...currentBootId ? { bootId: currentBootId } : {},
@@ -24552,7 +24648,7 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
24552
24648
  const owner = await readDaemonLifecycle(home);
24553
24649
  if (owner?.action === "start") {
24554
24650
  try {
24555
- await link(path.join(directory, owner.token), path.join(directory, token));
24651
+ await link(path2.join(directory, owner.token), path2.join(directory, token));
24556
24652
  joined = true;
24557
24653
  } catch (error62) {
24558
24654
  if (error62.code !== "ENOENT") throw error62;
@@ -24567,7 +24663,7 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
24567
24663
  } catch (error62) {
24568
24664
  if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error62.code)) throw error62;
24569
24665
  for (const owner of await lifecycleOwners(home)) {
24570
- if (!lockAlive(owner)) await unlink(path.join(directory, owner.token)).catch((error63) => {
24666
+ if (!lockAlive(owner)) await unlink(path2.join(directory, owner.token)).catch((error63) => {
24571
24667
  if (error63.code !== "ENOENT") throw error63;
24572
24668
  });
24573
24669
  }
@@ -24581,13 +24677,13 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
24581
24677
  signal?.throwIfAborted();
24582
24678
  return await run();
24583
24679
  } finally {
24584
- await unlink(path.join(directory, token));
24680
+ await unlink(path2.join(directory, token));
24585
24681
  await rmdir(directory).catch((error62) => {
24586
24682
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error62.code)) throw error62;
24587
24683
  });
24588
24684
  }
24589
24685
  } finally {
24590
- await unlink(path.join(candidate, token)).catch((error62) => {
24686
+ await unlink(path2.join(candidate, token)).catch((error62) => {
24591
24687
  if (error62.code !== "ENOENT") throw error62;
24592
24688
  });
24593
24689
  await rmdir(candidate).catch((error62) => {
@@ -24626,8 +24722,10 @@ async function ensureDaemon({ home = alpHome(), entry = (
24626
24722
  signal?.throwIfAborted();
24627
24723
  await new Promise((resolve, reject) => {
24628
24724
  const launch = entryCommand(entry, "daemon", ["--detach", `--startup-timeout=${timeoutMs}`], execPath);
24725
+ const launchEnv = { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" };
24726
+ if (isNativeDaemonName(launch.command)) delete launchEnv.BUN_BE_BUN;
24629
24727
  const launcher = spawn(launch.command, launch.args, {
24630
- env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" },
24728
+ env: launchEnv,
24631
24729
  stdio: ["ignore", "ignore", "pipe"],
24632
24730
  windowsHide: true
24633
24731
  });
@@ -24653,13 +24751,13 @@ ${log}` : ""}`);
24653
24751
 
24654
24752
  // packages/client/src/supervise.js
24655
24753
  import { mkdir as mkdir3, unlink as unlink3, writeFile as writeFile3, stat as stat2 } from "node:fs/promises";
24656
- import path3 from "node:path";
24754
+ import path4 from "node:path";
24657
24755
 
24658
24756
  // packages/client/src/service.js
24659
24757
  import { createHash as createHash2 } from "node:crypto";
24660
24758
  import { mkdir as mkdir2, readFile as readFile2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
24661
24759
  import os2 from "node:os";
24662
- import path2 from "node:path";
24760
+ import path3 from "node:path";
24663
24761
 
24664
24762
  // packages/client/src/command.js
24665
24763
  import { spawn as spawn2 } from "node:child_process";
@@ -24695,14 +24793,14 @@ function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 }
24695
24793
 
24696
24794
  // packages/client/src/service.js
24697
24795
  function serviceFor({ home, env = process.env, platform = process.platform, uid = process.getuid?.() ?? 0 }) {
24698
- const custom2 = path2.resolve(home) !== path2.join(os2.homedir(), ".alp");
24699
- const suffix = custom2 ? createHash2("sha256").update(path2.resolve(home)).digest("hex").slice(0, 8) : "";
24796
+ const custom2 = path3.resolve(home) !== path3.join(os2.homedir(), ".alp");
24797
+ const suffix = custom2 ? createHash2("sha256").update(path3.resolve(home)).digest("hex").slice(0, 8) : "";
24700
24798
  if (platform === "darwin") {
24701
24799
  const label = `com.alp.alpd${suffix ? `.${suffix}` : ""}`;
24702
- const directory = env.ALP_SERVICE_DIR || path2.join(os2.homedir(), "Library", "LaunchAgents");
24800
+ const directory = env.ALP_SERVICE_DIR || path3.join(os2.homedir(), "Library", "LaunchAgents");
24703
24801
  const launchctl = env.ALP_LAUNCHCTL || "launchctl";
24704
24802
  const target = `gui/${uid}/${label}`;
24705
- const file2 = path2.join(directory, `${label}.plist`);
24803
+ const file2 = path3.join(directory, `${label}.plist`);
24706
24804
  return {
24707
24805
  kind: "launchd",
24708
24806
  name: label,
@@ -24714,12 +24812,12 @@ function serviceFor({ home, env = process.env, platform = process.platform, uid
24714
24812
  }
24715
24813
  if (platform === "linux") {
24716
24814
  const name = `alpd${suffix ? `-${suffix}` : ""}`;
24717
- const directory = env.ALP_SERVICE_DIR || path2.join(env.XDG_CONFIG_HOME || path2.join(os2.homedir(), ".config"), "systemd", "user");
24815
+ const directory = env.ALP_SERVICE_DIR || path3.join(env.XDG_CONFIG_HOME || path3.join(os2.homedir(), ".config"), "systemd", "user");
24718
24816
  const systemctl = env.ALP_SYSTEMCTL || "systemctl";
24719
24817
  return {
24720
24818
  kind: "systemd",
24721
24819
  name,
24722
- file: path2.join(directory, `${name}.service`),
24820
+ file: path3.join(directory, `${name}.service`),
24723
24821
  install: [[systemctl, ["--user", "daemon-reload"]], [systemctl, ["--user", "enable", "--now", `${name}.service`]]],
24724
24822
  start: [[systemctl, ["--user", "start", `${name}.service`]]],
24725
24823
  uninstall: [[systemctl, ["--user", "disable", "--now", `${name}.service`], { ignore: true }]],
@@ -24750,7 +24848,7 @@ async function startService(service, run = runCommand) {
24750
24848
  }
24751
24849
 
24752
24850
  // packages/client/src/supervise.js
24753
- var holdFile = (home) => path3.join(home, "state", "alpd.held");
24851
+ var holdFile = (home) => path4.join(home, "state", "alpd.held");
24754
24852
  async function releaseHold(home) {
24755
24853
  await unlink3(holdFile(home)).catch(() => {
24756
24854
  });
@@ -24766,7 +24864,7 @@ async function whenReady(home, timeoutMs, signal) {
24766
24864
  if (lockAlive(lock) && lock.ready) return lock.socket;
24767
24865
  await new Promise((resolve) => setTimeout(resolve, 100));
24768
24866
  }
24769
- throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path3.join(home, "logs")}`);
24867
+ throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path4.join(home, "logs")}`);
24770
24868
  }
24771
24869
  async function startDaemon({ home, entry, env = process.env, timeoutMs = daemonStartTimeoutMs(env), automatic = false, signal }) {
24772
24870
  return withDaemonLifecycle(home, "start", async () => {
@@ -24789,7 +24887,7 @@ async function startDaemon({ home, entry, env = process.env, timeoutMs = daemonS
24789
24887
 
24790
24888
  // packages/cli/src/acp/agent.ts
24791
24889
  import { randomUUID as randomUUID2 } from "node:crypto";
24792
- import path4 from "node:path";
24890
+ import path5 from "node:path";
24793
24891
  var unlistedOf = ({ teams, team, teamLabel }) => teams.some((entry) => entry.id === team) ? void 0 : { id: team, label: teamLabel ?? (team === "custom" ? "Custom" : team) };
24794
24892
  var MODES = [
24795
24893
  { id: "read-only", name: "Read only", description: "Agents read and search; nothing is changed" },
@@ -24833,9 +24931,9 @@ ${resource.text}
24833
24931
  return text.trim();
24834
24932
  }
24835
24933
  function shown(file2, cwd) {
24836
- if (!cwd || !path4.isAbsolute(file2)) return file2;
24837
- const relative = path4.relative(cwd, file2);
24838
- return relative && !relative.startsWith("..") && !path4.isAbsolute(relative) ? relative : file2;
24934
+ if (!cwd || !path5.isAbsolute(file2)) return file2;
24935
+ const relative = path5.relative(cwd, file2);
24936
+ return relative && !relative.startsWith("..") && !path5.isAbsolute(relative) ? relative : file2;
24839
24937
  }
24840
24938
  function toolKind(item) {
24841
24939
  const detail = item.detail;
@@ -25172,8 +25270,8 @@ ${item2.text}`;
25172
25270
  return preview2;
25173
25271
  }
25174
25272
  const absolute = (cwd) => {
25175
- if (!path4.isAbsolute(cwd)) throw RequestError.invalidParams(void 0, "cwd must be an absolute path");
25176
- return path4.resolve(cwd);
25273
+ if (!path5.isAbsolute(cwd)) throw RequestError.invalidParams(void 0, "cwd must be an absolute path");
25274
+ return path5.resolve(cwd);
25177
25275
  };
25178
25276
  return agent({ name: "alp" }).onConnect((connection) => {
25179
25277
  editor = connection.client;
@@ -25199,7 +25297,7 @@ ${item2.text}`;
25199
25297
  const { session: record2 } = await request("session.get", { sessionId: params.sessionId }).catch(() => {
25200
25298
  throw RequestError.resourceNotFound(params.sessionId);
25201
25299
  });
25202
- if (record2.parentId || path4.resolve(record2.projectRoot) !== cwd) throw RequestError.invalidParams(void 0, "That ALP session belongs to another project");
25300
+ if (record2.parentId || path5.resolve(record2.projectRoot) !== cwd) throw RequestError.invalidParams(void 0, "That ALP session belongs to another project");
25203
25301
  const session = track(params.sessionId, cwd, hostServers(params.mcpServers), {
25204
25302
  teams: [{ id: record2.workflow?.mode ?? "pho", label: record2.teamLabel ?? record2.workflow?.mode ?? "pho" }],
25205
25303
  team: record2.workflow?.mode ?? "pho",
@@ -25217,7 +25315,7 @@ ${item2.text}`;
25217
25315
  send(session, { sessionUpdate: "available_commands_update", availableCommands: COMMANDS });
25218
25316
  return { configOptions: configOptions(session), modes: modeState(session) };
25219
25317
  }).onRequest("session/list", async ({ params }) => {
25220
- const { sessions: rows } = await request("session.list", { ...params.cwd ? { projectRoot: path4.resolve(params.cwd) } : {}, rootsOnly: true, includeClosed: true });
25318
+ const { sessions: rows } = await request("session.list", { ...params.cwd ? { projectRoot: path5.resolve(params.cwd) } : {}, rootsOnly: true, includeClosed: true });
25221
25319
  return {
25222
25320
  sessions: rows.filter((row) => row.persistent).slice(0, 100).map((row) => ({
25223
25321
  sessionId: row.id,
@@ -25268,7 +25366,7 @@ ${item2.text}`;
25268
25366
 
25269
25367
  // packages/cli/src/acp/main.ts
25270
25368
  async function runAcp({ daemonEntry }) {
25271
- const version2 = true ? "0.0.1-beta.8" : "0.0.0";
25369
+ const version2 = true ? "0.0.1-beta.9" : "0.0.0";
25272
25370
  const logger = createLogger({ component: "acp" });
25273
25371
  const log = (message, fields) => logger.warn(message, fields);
25274
25372
  const app = createAcpAgent({
@@ -1,4 +1,4 @@
1
- Third-party software bundled in the ALP web app (packages/cli/dist/alp-web)
1
+ Third-party software bundled in the ALP web app (packages/cli/dist/alp-dashboard)
2
2
 
3
3
  The bundled files of this package include code from the packages below; each keeps
4
4
  its own licence, reproduced here.