@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
@@ -3715,7 +3715,7 @@ var require_websocket_server = __commonJS({
3715
3715
  }
3716
3716
  });
3717
3717
 
3718
- // packages/cli/src/web/main.js
3718
+ // packages/cli/src/dashboard/main.js
3719
3719
  import { randomBytes as randomBytes5 } from "node:crypto";
3720
3720
  import { mkdirSync, openSync, watch, writeSync } from "node:fs";
3721
3721
  import { chmod as chmod3, link as link2, mkdir as mkdir6, readFile as readFile5, rename as rename4, unlink as unlink6, writeFile as writeFile6 } from "node:fs/promises";
@@ -3728,7 +3728,7 @@ import { setTimeout as delay } from "node:timers/promises";
3728
3728
  import { execFileSync, spawn } from "node:child_process";
3729
3729
  import { createHash, randomUUID } from "node:crypto";
3730
3730
  import { fstatSync, readFileSync as readFileSync2 } from "node:fs";
3731
- import { open, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, chmod, rename, rmdir, link } from "node:fs/promises";
3731
+ import { open, readFile, writeFile as writeFile2, realpath, stat, lstat, mkdir, readlink, unlink, readdir, chmod, rename as rename2, rmdir, link } from "node:fs/promises";
3732
3732
  import net from "node:net";
3733
3733
  import os from "node:os";
3734
3734
  import path2 from "node:path";
@@ -3761,14 +3761,14 @@ var PATTERNS = [
3761
3761
  // --token value, --api-key value
3762
3762
  [/(--[\w-]*(?:key|token|secret|passw(?:or)?d|credential)[\w-]*\s+)[^\s-][^\s]*/gi, `$1${REDACTED}`]
3763
3763
  ];
3764
- function secretValues(env) {
3764
+ function secretValues(env2) {
3765
3765
  const values = /* @__PURE__ */ new Set();
3766
- for (const [name2, value] of Object.entries(env ?? {})) if (typeof value === "string" && value.length >= 8 && SECRET_NAME.test(name2)) values.add(value);
3766
+ for (const [name2, value] of Object.entries(env2 ?? {})) if (typeof value === "string" && value.length >= 8 && SECRET_NAME.test(name2)) values.add(value);
3767
3767
  return [...values].sort((a, b) => b.length - a.length);
3768
3768
  }
3769
- function scrubText(text, { env = process.env, max = MAX_STRING } = {}) {
3769
+ function scrubText(text, { env: env2 = process.env, max = MAX_STRING } = {}) {
3770
3770
  let result = String(text);
3771
- for (const value of secretValues(env)) result = result.split(value).join(REDACTED);
3771
+ for (const value of secretValues(env2)) result = result.split(value).join(REDACTED);
3772
3772
  for (const [pattern, replacement] of PATTERNS) result = result.replace(pattern, replacement);
3773
3773
  return result.length > max ? `${result.slice(0, max)}... (${result.length - max} more characters)` : result;
3774
3774
  }
@@ -3810,9 +3810,9 @@ var stderrSink = (line) => {
3810
3810
  } catch {
3811
3811
  }
3812
3812
  };
3813
- function createLogger({ component, level, context = {}, write = stderrSink, now = () => /* @__PURE__ */ new Date(), env = process.env } = {}) {
3814
- const threshold = LEVELS[level ?? env.ALP_LOG_LEVEL] ?? LEVELS.info;
3815
- const options = { env };
3813
+ function createLogger({ component, level, context = {}, write = stderrSink, now = () => /* @__PURE__ */ new Date(), env: env2 = process.env } = {}) {
3814
+ const threshold = LEVELS[level ?? env2.ALP_LOG_LEVEL] ?? LEVELS.info;
3815
+ const options = { env: env2 };
3816
3816
  const emit = (name2, message, fields = {}) => {
3817
3817
  if (LEVELS[name2] < threshold) return;
3818
3818
  try {
@@ -3843,7 +3843,7 @@ function createLogger({ component, level, context = {}, write = stderrSink, now
3843
3843
  info: (message, fields) => emit("info", message, fields),
3844
3844
  warn: (message, fields) => emit("warn", message, fields),
3845
3845
  error: (message, fields) => emit("error", message, fields),
3846
- child: (extra = {}, name2 = component) => createLogger({ component: name2, level, context: { ...context, ...extra }, write, now, env })
3846
+ child: (extra = {}, name2 = component) => createLogger({ component: name2, level, context: { ...context, ...extra }, write, now, env: env2 })
3847
3847
  };
3848
3848
  }
3849
3849
  var TAIL_BYTES = 256 * 1024;
@@ -3851,9 +3851,19 @@ var TAIL_BYTES = 256 * 1024;
3851
3851
  // packages/core/src/packaged.js
3852
3852
  import { existsSync, readFileSync, realpathSync } from "node:fs";
3853
3853
  import path from "node:path";
3854
+ var NATIVE = Symbol.for("alp.nativeDaemon");
3855
+ function nativeDaemon() {
3856
+ return (
3857
+ /** @type {any} */
3858
+ globalThis[NATIVE]
3859
+ );
3860
+ }
3861
+ var NATIVE_DAEMON = process.platform === "win32" ? "alpd.exe" : "alpd";
3862
+ var isNativeDaemonName = (file) => /^alpd(\.exe)?$/i.test(file.split(/[\\/]/).pop() ?? "");
3863
+ var isBundleDaemon = (file) => isNativeDaemonName(file) && path.basename(path.dirname(file)) === "bin" && existsSync(path.join(path.dirname(path.dirname(file)), "alp-bundle.json"));
3854
3864
  var ROLE_ARGS = Object.freeze({
3855
3865
  daemon: Object.freeze(["daemon", "run"]),
3856
- web: Object.freeze(["web", "serve"]),
3866
+ dashboard: Object.freeze(["dashboard", "serve"]),
3857
3867
  "bridge-acp": Object.freeze(["bridge", "acp"]),
3858
3868
  "bridge-antigravity": Object.freeze(["bridge", "antigravity"])
3859
3869
  });
@@ -3879,9 +3889,10 @@ function bundleInfo(execPath = process.execPath) {
3879
3889
  let info;
3880
3890
  try {
3881
3891
  const real = realpathSync(execPath);
3892
+ const native = isNativeDaemonName(real) && path.basename(path.dirname(real)) === "bin";
3882
3893
  const nodeDir = path.basename(path.dirname(real)) === "bin" ? path.dirname(path.dirname(real)) : path.dirname(real);
3883
- const root = path.dirname(nodeDir);
3884
- if (path.basename(nodeDir) === "node") {
3894
+ const root = native ? nodeDir : path.dirname(nodeDir);
3895
+ if (native || path.basename(nodeDir) === "node") {
3885
3896
  const manifest = JSON.parse(readFileSync(path.join(root, "alp-bundle.json"), "utf8"));
3886
3897
  if (manifest?.name === "alp" && typeof manifest.version === "string") {
3887
3898
  const app = path.dirname(root);
@@ -3894,6 +3905,13 @@ function bundleInfo(execPath = process.execPath) {
3894
3905
  bundles.set(execPath, info);
3895
3906
  return info;
3896
3907
  }
3908
+ var bundleNode = (bundle) => path.join(bundle.root, "node", process.platform === "win32" ? "node.exe" : "bin/node");
3909
+ var bundleDaemon = (bundle) => path.join(bundle.root, "bin", NATIVE_DAEMON);
3910
+ function nodeExecutable() {
3911
+ if (!nativeDaemon()) return process.execPath;
3912
+ const bundle = bundleInfo();
3913
+ return bundle ? bundleNode(bundle) : "node";
3914
+ }
3897
3915
  function stablePath(file, { bundle = bundleInfo() } = {}) {
3898
3916
  if (!bundle?.current) return file;
3899
3917
  let real;
@@ -3907,14 +3925,232 @@ function stablePath(file, { bundle = bundleInfo() } = {}) {
3907
3925
  return path.join(bundle.current, relative);
3908
3926
  }
3909
3927
  function entryCommand(entry, role, args = [], execPath = process.execPath, { scriptOnly = false } = {}) {
3928
+ if (!scriptOnly && role === "daemon" && isBundleDaemon(entry)) return { command: entry, args: [...args] };
3910
3929
  if (scriptOnly || isScript(entry) || !isExecutableName(entry)) return { command: execPath, args: [entry, ...args] };
3911
3930
  return { command: entry, args: [...roleArgs(role), ...args] };
3912
3931
  }
3913
3932
  function scriptCommand(script, args = []) {
3914
- return { command: process.execPath, args: [script, ...args] };
3933
+ return { command: nodeExecutable(), args: [script, ...args] };
3934
+ }
3935
+ function daemonEntry(script, { bundle = bundleInfo(), env: env2 = process.env } = {}) {
3936
+ const native = bundle && env2.ALP_NATIVE_DAEMON !== "0" ? bundleDaemon(bundle) : void 0;
3937
+ return stablePath(native && existsSync(native) ? native : script, { bundle });
3938
+ }
3939
+
3940
+ // packages/core/src/atomic.js
3941
+ import { rename, rm, writeFile } from "node:fs/promises";
3942
+ async function moveFile(from, to) {
3943
+ for (let attempt = 0; ; attempt++) {
3944
+ try {
3945
+ return await rename(from, to);
3946
+ } catch (error) {
3947
+ if (process.platform !== "win32" || attempt >= 20 || !["EPERM", "EACCES", "EBUSY"].includes(error?.code)) throw error;
3948
+ await new Promise((resolve2) => setTimeout(resolve2, 10 + attempt * 10));
3949
+ }
3950
+ }
3951
+ }
3952
+
3953
+ // packages/core/src/errors.js
3954
+ var AlpError = class extends Error {
3955
+ constructor(code, message, options) {
3956
+ super(message, options);
3957
+ this.name = "AlpError";
3958
+ this.code = code;
3959
+ }
3960
+ };
3961
+
3962
+ // packages/core/src/models.js
3963
+ var codexFull = ["low", "medium", "high", "xhigh", "max", "ultra"];
3964
+ var codexStandard = ["low", "medium", "high", "xhigh", "max"];
3965
+ var claudeFull = ["low", "medium", "high", "xhigh", "max", "ultracode"];
3966
+ var claudeLegacy = ["off", "low", "medium", "high", "xhigh", "max", "ultracode"];
3967
+ var claude46 = ["off", "low", "medium", "high", "max"];
3968
+ var MODELS = [
3969
+ ["codex", "gpt-6.1-sol", "GPT-6.1-Sol", "Latest workhorse model for coding and everyday work.", codexFull, "low"],
3970
+ // ALP runs GPT-6 Astra at low effort only.
3971
+ ["codex", "gpt-6-astra", "GPT-6-Astra", "Frontier intelligence for the most demanding work.", ["low"], "low"],
3972
+ ["codex", "gpt-6-sol", "GPT-6-Sol", "Previous generation workhorse model.", codexFull, "low"],
3973
+ ["codex", "gpt-6-luna", "GPT-6-Luna", "Fast and affordable model for easier tasks.", codexStandard, "low"],
3974
+ ["codex", "gpt-5.6-sol", "GPT-5.6-Sol", "Older generation workhorse model.", codexFull, "low"],
3975
+ ["codex", "gpt-5.6-terra", "GPT-5.6-Terra", "Older balanced model for straightforward work.", codexFull, "low"],
3976
+ ["codex", "gpt-5.6-luna", "GPT-5.6-Luna", "Older fast and efficient model.", codexStandard, "low"],
3977
+ ["claude", "claude-opus-5-5", "Opus 5.5", "Latest release.", claudeFull, "medium"],
3978
+ ["claude", "claude-opus-5", "Opus 5", "Previous release.", claudeLegacy, "high"],
3979
+ ["claude", "claude-fable-5-1", "Fable 5.1", "Most powerful model.", claudeFull, "high"],
3980
+ ["claude", "claude-fable-5", "Fable 5", "Previous release.", claudeFull, "high"],
3981
+ ["claude", "claude-opus-4-8[1m]", "Opus 4.8 1M", "Opus 4.8 with 1M context window.", claudeLegacy, "high"],
3982
+ ["claude", "claude-opus-4-8", "Opus 4.8", "Previous release.", claudeLegacy, "high"],
3983
+ ["claude", "claude-sonnet-5-5", "Sonnet 5.5", "Best for everyday tasks.", claudeFull, "medium"],
3984
+ ["claude", "claude-sonnet-5", "Sonnet 5", "Previous release.", claudeLegacy, "high"],
3985
+ ["claude", "claude-sonnet-5[1m]", "Sonnet 5 1M", "Sonnet 5 with 1M context window.", claudeLegacy, "high"],
3986
+ ["claude", "claude-opus-4-7[1m]", "Opus 4.7 1M", "Opus 4.7 with 1M context window.", claudeLegacy, "high"],
3987
+ ["claude", "claude-opus-4-7", "Opus 4.7", "Previous release.", claudeLegacy, "high"],
3988
+ ["claude", "claude-opus-4-6[1m]", "Opus 4.6 1M", "Opus 4.6 with 1M context window.", claude46, "high"],
3989
+ ["claude", "claude-opus-4-6", "Opus 4.6", "Most capable for complex work.", claude46, "high"],
3990
+ ["claude", "claude-sonnet-4-6[1m]", "Sonnet 4.6 1M", "Sonnet 4.6 with 1M context window.", claude46, "high"],
3991
+ ["claude", "claude-sonnet-4-6", "Sonnet 4.6", "Best for everyday tasks.", claude46, "high"],
3992
+ ["claude", "claude-haiku-4-5", "Haiku 4.5", "Fastest for quick answers.", [], void 0],
3993
+ ["claude", "sonnet", "sonnet", "From Claude settings.json model.", [], void 0],
3994
+ ["antigravity", "gemini-3.8-flash-high", "Gemini 3.8 Flash (High)", "High reasoning effort workhorse for complex tasks.", [], void 0],
3995
+ ["antigravity", "gemini-3.8-flash-medium", "Gemini 3.8 Flash (Medium)", "Balanced speed and reasoning.", [], void 0],
3996
+ ["antigravity", "gemini-3.8-flash-low", "Gemini 3.8 Flash (Low)", "Fast and efficient for straightforward work.", [], void 0],
3997
+ ["antigravity", "gemini-2.5-pro", "Gemini 2.5 Pro", "Deep reasoning for coding and analysis.", [], void 0],
3998
+ ["antigravity", "gemini-2.5-flash", "Gemini 2.5 Flash", "Fast and versatile everyday model.", [], void 0],
3999
+ ["antigravity", "claude-sonnet-4-6", "Claude Sonnet 4.6", "Sonnet 4.6 via Antigravity.", [], void 0],
4000
+ ["antigravity", "claude-opus-4-6-thinking", "Claude Opus 4.6 Thinking", "Opus 4.6 with thinking via Antigravity.", [], void 0],
4001
+ ["antigravity", "gpt-oss-120b-medium", "GPT-OSS 120B (Medium)", "Open weights model via Antigravity.", [], void 0]
4002
+ ].map(([runtime, id, label, description, efforts, effort]) => ({ runtime, id, label, description, efforts, ...effort ? { effort } : {} }));
4003
+
4004
+ // packages/core/src/permissions.js
4005
+ var BASES = ["read-only", "workspace-write", "full-access"];
4006
+ var MAX_RULES = 200;
4007
+ var NAME = /^[\w.-]{1,64}$/;
4008
+ var RULE = /^([A-Za-z][\w-]*)(?:\((.*)\))?$/s;
4009
+ var TOOLS = ["Bash", "Read", "Edit", "Write", "MultiEdit", "NotebookEdit", "Glob", "Grep", "WebFetch", "WebSearch", "Skill"];
4010
+ var setOwn = (value, key2, entry) => Object.defineProperty(value, key2, { value: entry, enumerable: true, writable: true, configurable: true });
4011
+ var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
4012
+ var fail = (source, message) => {
4013
+ throw new AlpError("INVALID_SETTINGS", `${source}: ${message}`);
4014
+ };
4015
+ function parseRule(rule, source = "rule") {
4016
+ if (typeof rule !== "string" || rule.length > 500) fail(source, "a rule is text of at most 500 characters");
4017
+ const match = RULE.exec(rule.trim());
4018
+ if (!match) fail(source, `${JSON.stringify(rule)} is not Tool or Tool(specifier)`);
4019
+ const [, tool, specifier] = match;
4020
+ if (!TOOLS.includes(tool) && !/^mcp__[\w-]+(__[\w-]+)?$/.test(tool)) fail(source, `${JSON.stringify(rule)} names unknown tool ${tool}; use ${TOOLS.join(", ")} or mcp__<server>__<tool>`);
4021
+ if (specifier !== void 0 && !specifier.trim()) fail(source, `${JSON.stringify(rule)} has an empty specifier`);
4022
+ return { tool, ...specifier !== void 0 && specifier.trim() !== "*" ? { specifier: specifier.trim() } : {} };
4023
+ }
4024
+ function validatePermissions(value, source) {
4025
+ if (value === void 0) return { profiles: {}, agents: {} };
4026
+ if (!object(value)) fail(source, "permissions must be an object");
4027
+ for (const key2 of Object.keys(value)) if (!["profiles", "agents"].includes(key2)) fail(source, `unsupported permissions field '${key2}'`);
4028
+ const profiles = {};
4029
+ if (value.profiles !== void 0) {
4030
+ if (!object(value.profiles)) fail(source, "permissions.profiles must be an object");
4031
+ for (const [name2, profile] of Object.entries(value.profiles)) {
4032
+ const where = `permissions.profiles.${name2}`;
4033
+ if (!NAME.test(name2)) fail(source, `${where}: a profile name has letters, digits, dots, dashes and underscores`);
4034
+ if (!object(profile)) fail(source, `${where} must be an object`);
4035
+ for (const key2 of Object.keys(profile)) if (!["base", "allow", "ask", "deny", "beyondMode", "workdir"].includes(key2)) fail(source, `${where}: unsupported field '${key2}'`);
4036
+ if (profile.workdir !== void 0 && profile.workdir !== "copy") fail(source, `${where}.workdir must be copy`);
4037
+ if (profile.workdir === "copy" && profile.base !== void 0 && profile.base !== "read-only") fail(source, `${where}: workdir copy is for read-only profiles; writers use worktree isolation`);
4038
+ if (profile.base !== void 0 && !BASES.includes(profile.base)) fail(source, `${where}.base must be ${BASES.join(", ")}`);
4039
+ if (profile.beyondMode !== void 0 && !["refuse", "ask"].includes(profile.beyondMode)) fail(source, `${where}.beyondMode must be refuse or ask`);
4040
+ const rules = {};
4041
+ for (const kind of ["allow", "ask", "deny"]) {
4042
+ const list = profile[kind] ?? [];
4043
+ if (!Array.isArray(list) || list.length > MAX_RULES) fail(source, `${where}.${kind} must list at most ${MAX_RULES} rules`);
4044
+ for (const rule of list) parseRule(rule, `${source}: ${where}.${kind}`);
4045
+ rules[kind] = list.map((rule) => rule.trim());
4046
+ }
4047
+ setOwn(profiles, name2, { ...profile.base ? { base: profile.base } : {}, ...profile.beyondMode ? { beyondMode: profile.beyondMode } : {}, ...profile.workdir ? { workdir: profile.workdir } : {}, ...rules });
4048
+ }
4049
+ }
4050
+ const agents = {};
4051
+ if (value.agents !== void 0) {
4052
+ if (!object(value.agents)) fail(source, "permissions.agents must be an object");
4053
+ for (const [agent, profile] of Object.entries(value.agents)) {
4054
+ if (typeof profile !== "string" || !NAME.test(profile)) fail(source, `permissions.agents.${agent} must name a profile`);
4055
+ setOwn(agents, agent, profile);
4056
+ }
4057
+ }
4058
+ return { profiles, agents };
4059
+ }
4060
+
4061
+ // packages/core/src/validation.js
4062
+ var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
4063
+ var nonempty = (value) => typeof value === "string" && value.trim().length > 0;
4064
+ function requireValue(condition, code, source, message) {
4065
+ if (!condition) throw new AlpError(code, `${source}: ${message}`);
4066
+ }
4067
+ var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "dashboard", "web", "curate"];
4068
+ var DASHBOARD_SETTINGS = Object.freeze(["enabled", "port", "permissions"]);
4069
+ var RETIRED_SETTINGS = { project: {}, user: {} };
4070
+ function distance(a, b) {
4071
+ const row = Array.from({ length: b.length + 1 }, (_, index) => index);
4072
+ for (let i = 1; i <= a.length; i++) {
4073
+ let previous = row[0];
4074
+ row[0] = i;
4075
+ for (let j = 1; j <= b.length; j++) {
4076
+ const kept = row[j];
4077
+ row[j] = Math.min(row[j] + 1, row[j - 1] + 1, previous + (a[i - 1].toLowerCase() === b[j - 1].toLowerCase() ? 0 : 1));
4078
+ previous = kept;
4079
+ }
4080
+ }
4081
+ return row[b.length];
4082
+ }
4083
+ function settingsKeys(settings, known, retired = {}) {
4084
+ const unknown = [];
4085
+ const old = [];
4086
+ for (const key2 of Object.keys(object2(settings) ? settings : {})) {
4087
+ if (known.includes(key2)) continue;
4088
+ if (Object.hasOwn(retired, key2)) {
4089
+ old.push({ key: key2, instead: retired[key2] });
4090
+ continue;
4091
+ }
4092
+ const near = known.filter((candidate) => !candidate.startsWith("$")).map((candidate) => ({ candidate, d: distance(key2, candidate) })).sort((a, b) => a.d - b.d)[0];
4093
+ unknown.push({ key: key2, ...near && near.d <= 2 ? { suggestion: near.candidate } : {} });
4094
+ }
4095
+ return { unknown, retired: old };
3915
4096
  }
3916
- function selfEntry(script) {
3917
- return stablePath(script);
4097
+ var unknownMessage = (unknown, known) => `unknown setting '${unknown.key}'${unknown.suggestion ? `; did you mean '${unknown.suggestion}'?` : `; known settings are ${known.filter((key2) => !key2.startsWith("$")).join(", ")}`}`;
4098
+ function checkCurate(settings, check2) {
4099
+ if (settings.curate === void 0) return;
4100
+ check2(object2(settings.curate), "curate must be an object");
4101
+ check2(Object.keys(settings.curate).every((key2) => key2 === "monthly"), "unsupported curate field; use monthly");
4102
+ if (settings.curate.monthly !== void 0) check2(typeof settings.curate.monthly === "boolean", "curate.monthly must be true or false");
4103
+ }
4104
+ function validateUserSettings(settings, source) {
4105
+ const check2 = (ok, message) => requireValue(ok, "INVALID_SETTINGS", source, message);
4106
+ check2(object2(settings), "expected an object");
4107
+ const { unknown } = settingsKeys(settings, USER_SETTINGS, RETIRED_SETTINGS.user);
4108
+ check2(!unknown.length, unknown.length ? unknownMessage(unknown[0], USER_SETTINGS) : "");
4109
+ checkCurate(settings, check2);
4110
+ for (const key2 of ["limits", "recovery"]) {
4111
+ if (settings[key2] === void 0) continue;
4112
+ check2(object2(settings[key2]), `${key2} must be an object`);
4113
+ const extra = Object.keys(settings[key2]).find((field) => field !== "autoResume");
4114
+ check2(!extra, `unsupported ${key2} field '${extra}'; use autoResume`);
4115
+ if (settings[key2].autoResume !== void 0) check2(typeof settings[key2].autoResume === "boolean", `${key2}.autoResume must be true or false`);
4116
+ }
4117
+ for (const key2 of ["dashboard", "web"]) {
4118
+ const section = settings[key2];
4119
+ if (section === void 0) continue;
4120
+ check2(object2(section), `${key2} must be an object`);
4121
+ const allowed = key2 === "web" ? [...DASHBOARD_SETTINGS, "relay"] : DASHBOARD_SETTINGS;
4122
+ const extra = Object.keys(section).find((field) => !allowed.includes(field));
4123
+ check2(!extra, `unsupported ${key2} field '${extra}'; use ${allowed.slice(0, -1).join(", ")} or ${allowed.at(-1)}`);
4124
+ if (section.permissions !== void 0) check2(Array.isArray(section.permissions) && section.permissions.every((entry) => typeof entry === "string" && /^[a-z][a-z.]*$/.test(entry)), `${key2}.permissions must be a list of permission names, such as files.read`);
4125
+ if (section.enabled !== void 0) check2(typeof section.enabled === "boolean", `${key2}.enabled must be true or false`);
4126
+ if (section.port !== void 0) check2(Number.isInteger(section.port) && section.port >= 1024 && section.port <= 65535, `${key2}.port must be a port from 1024 to 65535`);
4127
+ }
4128
+ if (settings.web !== void 0) {
4129
+ const relay = settings.web.relay;
4130
+ if (relay !== void 0) {
4131
+ check2(object2(relay), "web.relay must be an object");
4132
+ const unsupported = Object.keys(relay).find((field) => !["enabled", "endpoint", "useTls"].includes(field));
4133
+ check2(!unsupported, `unsupported web.relay field '${unsupported}'; use enabled, endpoint or useTls`);
4134
+ if (relay.enabled !== void 0) check2(typeof relay.enabled === "boolean", "web.relay.enabled must be true or false");
4135
+ if (relay.endpoint !== void 0) check2(typeof relay.endpoint === "string" && /^[a-z0-9.-]+:\d{1,5}$/i.test(relay.endpoint), "web.relay.endpoint must be host:port, such as relay.paseo.sh:443");
4136
+ if (relay.useTls !== void 0) check2(typeof relay.useTls === "boolean", "web.relay.useTls must be true or false");
4137
+ }
4138
+ }
4139
+ if (settings.language !== void 0) check2(nonempty(settings.language) && settings.language.trim().length <= 40, "language must be a language name of at most 40 characters, such as Vietnamese or English");
4140
+ validatePermissions(settings.permissions, source);
4141
+ return settings;
4142
+ }
4143
+
4144
+ // packages/core/src/user-settings.js
4145
+ function dashboardSettings(settings) {
4146
+ const now = settings?.dashboard ?? {};
4147
+ const before = settings?.web ?? {};
4148
+ const result = {};
4149
+ for (const key2 of DASHBOARD_SETTINGS) {
4150
+ const value = now[key2] !== void 0 ? now[key2] : before[key2];
4151
+ if (value !== void 0) result[key2] = value;
4152
+ }
4153
+ return result;
3918
4154
  }
3919
4155
 
3920
4156
  // packages/protocol/src/wire.js
@@ -4694,8 +4930,8 @@ function createReconnectingClient({ connect: connect2, onConnect, onDisconnect,
4694
4930
  var CLOSE_CODE = Object.freeze({ unsupportedData: 4003, tooLarge: 4009 });
4695
4931
 
4696
4932
  // packages/client/src/index.js
4697
- function alpHome(env = process.env) {
4698
- return path2.resolve(env.ALP_HOME || path2.join(os.homedir(), ".alp"));
4933
+ function alpHome(env2 = process.env) {
4934
+ return path2.resolve(env2.ALP_HOME || path2.join(os.homedir(), ".alp"));
4699
4935
  }
4700
4936
  function daemonPaths(home) {
4701
4937
  const preferred = path2.join(home, "alpd.sock");
@@ -4769,7 +5005,7 @@ async function assertPrivateSocket(socketPath) {
4769
5005
  var isFile = (file) => stat(file).then((info) => info.isFile(), () => false);
4770
5006
  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"];
4771
5007
  var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
4772
- async function cliDaemonEntry(cli, depth = 0) {
5008
+ async function cliDaemonEntry(cli, depth = 0, env2 = process.env) {
4773
5009
  const base = path2.basename(cli).toLowerCase();
4774
5010
  const root = path2.resolve(path2.dirname(cli), "..");
4775
5011
  const alpd = (directory) => path2.join(directory, "dist", "alpd.js");
@@ -4779,7 +5015,7 @@ async function cliDaemonEntry(cli, depth = 0) {
4779
5015
  const text = await stat(cli).then((info) => info.size <= 64 * 1024 ? readFile(cli, "utf8") : "", () => "");
4780
5016
  for (const [, quoted] of text.matchAll(/"([^"\r\n]+\.js)"/gi)) {
4781
5017
  const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path2.dirname(cli)}${path2.sep}`);
4782
- const entry = path2.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1) : void 0;
5018
+ const entry = path2.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1, env2) : void 0;
4783
5019
  if (entry) return entry;
4784
5020
  }
4785
5021
  return void 0;
@@ -4788,7 +5024,8 @@ async function cliDaemonEntry(cli, depth = 0) {
4788
5024
  if (!await isFile(path2.join(root, "alp-bundle.json"))) return void 0;
4789
5025
  const current = path2.join(path2.dirname(root), "current");
4790
5026
  const viaCurrent = await realpath(current).then((real) => real === root, () => false);
4791
- candidates = [alpd(path2.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
5027
+ const bundle = viaCurrent ? current : root;
5028
+ candidates = [...env2.ALP_NATIVE_DAEMON === "0" ? [] : [path2.join(bundle, "bin", NATIVE_DAEMON)], alpd(path2.join(bundle, "lib", "node_modules", "@anhlp", "alp-cli"))];
4792
5029
  } else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
4793
5030
  candidates = [alpd(root)];
4794
5031
  } else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
@@ -4797,7 +5034,7 @@ async function cliDaemonEntry(cli, depth = 0) {
4797
5034
  for (const candidate of candidates) if (await isFile(candidate)) return candidate;
4798
5035
  return void 0;
4799
5036
  }
4800
- async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = (
5037
+ async function findDaemonEntry({ home = alpHome(), env: env2 = process.env, candidates = (
4801
5038
  /** @type {Array<string | undefined>} */
4802
5039
  []
4803
5040
  ), binDirectories = BIN_DIRECTORIES } = {}) {
@@ -4807,10 +5044,10 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
4807
5044
  if (typeof entry === "string" && await isFile(entry)) return entry;
4808
5045
  } catch {
4809
5046
  }
4810
- for (const directory of [...(env.PATH ?? "").split(path2.delimiter).filter(Boolean), ...binDirectories]) {
5047
+ for (const directory of [...(env2.PATH ?? "").split(path2.delimiter).filter(Boolean), ...binDirectories]) {
4811
5048
  for (const name2 of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
4812
5049
  const cli = await realpath(path2.join(directory, name2)).catch(() => void 0);
4813
- const entry = cli && await cliDaemonEntry(cli);
5050
+ const entry = cli && await cliDaemonEntry(cli, 0, env2);
4814
5051
  if (entry) return entry;
4815
5052
  }
4816
5053
  }
@@ -4980,7 +5217,7 @@ async function withDaemonLifecycle(home, action, run2, { joinStart = false, sign
4980
5217
  const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
4981
5218
  const candidate = path2.join(state, `alpd.starting-${token}`);
4982
5219
  await mkdir(candidate, { mode: 448 });
4983
- await writeFile(path2.join(candidate, token), JSON.stringify({
5220
+ await writeFile2(path2.join(candidate, token), JSON.stringify({
4984
5221
  pid: process.pid,
4985
5222
  bootTime: bootTime(),
4986
5223
  ...currentBootId ? { bootId: currentBootId } : {},
@@ -5003,7 +5240,7 @@ async function withDaemonLifecycle(home, action, run2, { joinStart = false, sign
5003
5240
  while (!joined) {
5004
5241
  signal?.throwIfAborted();
5005
5242
  try {
5006
- await rename(candidate, directory);
5243
+ await rename2(candidate, directory);
5007
5244
  break;
5008
5245
  } catch (error) {
5009
5246
  if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error.code)) throw error;
@@ -5038,8 +5275,8 @@ async function withDaemonLifecycle(home, action, run2, { joinStart = false, sign
5038
5275
  }
5039
5276
  var DAEMON_START_TIMEOUT_MS = 6e4;
5040
5277
  var DAEMON_START_TIMEOUT_MAX_MS = 36e5;
5041
- function daemonStartTimeoutMs(env = process.env) {
5042
- const raw = env.ALP_DAEMON_START_TIMEOUT_MS?.trim();
5278
+ function daemonStartTimeoutMs(env2 = process.env) {
5279
+ const raw = env2.ALP_DAEMON_START_TIMEOUT_MS?.trim();
5043
5280
  if (!raw || !/^[0-9]+$/.test(raw)) return DAEMON_START_TIMEOUT_MS;
5044
5281
  const value = Number(raw);
5045
5282
  return value > 0 && value <= DAEMON_START_TIMEOUT_MAX_MS ? value : DAEMON_START_TIMEOUT_MS;
@@ -5047,12 +5284,12 @@ function daemonStartTimeoutMs(env = process.env) {
5047
5284
  async function ensureDaemon({ home = alpHome(), entry = (
5048
5285
  /** @type {string | undefined} */
5049
5286
  void 0
5050
- ), env = process.env, execPath = process.execPath, timeoutMs = daemonStartTimeoutMs(env), lifecycleLocked = false, signal = (
5287
+ ), env: env2 = process.env, execPath = process.execPath, timeoutMs = daemonStartTimeoutMs(env2), lifecycleLocked = false, signal = (
5051
5288
  /** @type {AbortSignal | undefined} */
5052
5289
  void 0
5053
5290
  ) } = {}) {
5054
5291
  signal?.throwIfAborted();
5055
- if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleLocked: true, signal }), { signal });
5292
+ if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env: env2, execPath, timeoutMs, lifecycleLocked: true, signal }), { signal });
5056
5293
  const ready = async () => {
5057
5294
  const lock = await readLock(home);
5058
5295
  return lockAlive(lock) && lock.ready ? lock.socket : void 0;
@@ -5062,13 +5299,15 @@ async function ensureDaemon({ home = alpHome(), entry = (
5062
5299
  const held = await readLock(home);
5063
5300
  if (lockAlive(held) && held.maintenance) throw new Error(`ALP is busy: alp ${held.maintenance} runs (pid ${held.pid}); alpd starts again when it finishes`);
5064
5301
  if (!lockAlive(held)) {
5065
- entry ??= await findDaemonEntry({ home, env });
5302
+ entry ??= await findDaemonEntry({ home, env: env2 });
5066
5303
  if (!entry) throw new Error("ALP daemon is not running and alpd.js was not found. Install the ALP CLI and run `alp daemon start`, or set ALP_DAEMON_ENTRY to alpd.js");
5067
5304
  signal?.throwIfAborted();
5068
5305
  await new Promise((resolve2, reject) => {
5069
5306
  const launch = entryCommand(entry, "daemon", ["--detach", `--startup-timeout=${timeoutMs}`], execPath);
5307
+ const launchEnv = { ...env2, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" };
5308
+ if (isNativeDaemonName(launch.command)) delete launchEnv.BUN_BE_BUN;
5070
5309
  const launcher = spawn(launch.command, launch.args, {
5071
- env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" },
5310
+ env: launchEnv,
5072
5311
  stdio: ["ignore", "ignore", "pipe"],
5073
5312
  windowsHide: true
5074
5313
  });
@@ -5097,21 +5336,6 @@ import { randomUUID as randomUUID2 } from "node:crypto";
5097
5336
  import { mkdir as mkdir2, open as open2, rmdir as rmdir2, unlink as unlink2 } from "node:fs/promises";
5098
5337
  import os2 from "node:os";
5099
5338
  import path3 from "node:path";
5100
-
5101
- // packages/core/src/atomic.js
5102
- import { rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
5103
- async function moveFile(from, to) {
5104
- for (let attempt = 0; ; attempt++) {
5105
- try {
5106
- return await rename2(from, to);
5107
- } catch (error) {
5108
- if (process.platform !== "win32" || attempt >= 20 || !["EPERM", "EACCES", "EBUSY"].includes(error?.code)) throw error;
5109
- await new Promise((resolve2) => setTimeout(resolve2, 10 + attempt * 10));
5110
- }
5111
- }
5112
- }
5113
-
5114
- // packages/client/src/integration-lock.js
5115
5339
  function createIntegrationLock(home, name2) {
5116
5340
  const file = path3.join(home, "integrations", `${assertIntegrationName(name2)}.lock`);
5117
5341
  const guard = `${file}.reclaim`;
@@ -5314,13 +5538,13 @@ import path4 from "node:path";
5314
5538
 
5315
5539
  // packages/client/src/command.js
5316
5540
  import { spawn as spawn2 } from "node:child_process";
5317
- function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 } = {}) {
5541
+ function runCommand(command, args, { cwd, env: env2 = process.env, timeoutMs = 15e3 } = {}) {
5318
5542
  return new Promise((resolve2) => {
5319
5543
  let child;
5320
5544
  const script = process.platform === "win32" && /\.[cm]?js$/i.test(command);
5321
5545
  const run2 = script ? scriptCommand(command, args) : { command, args };
5322
5546
  try {
5323
- child = spawn2(run2.command, run2.args, { cwd, env: run2.env ? { ...env, ...run2.env } : env, stdio: ["ignore", "pipe", "pipe"] });
5547
+ child = spawn2(run2.command, run2.args, { cwd, env: run2.env ? { ...env2, ...run2.env } : env2, stdio: ["ignore", "pipe", "pipe"] });
5324
5548
  } catch (error) {
5325
5549
  resolve2({ code: -1, stdout: "", stderr: error.message });
5326
5550
  return;
@@ -5345,13 +5569,13 @@ function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 }
5345
5569
  }
5346
5570
 
5347
5571
  // packages/client/src/service.js
5348
- function serviceFor({ home, env = process.env, platform = process.platform, uid = process.getuid?.() ?? 0 }) {
5572
+ function serviceFor({ home, env: env2 = process.env, platform = process.platform, uid = process.getuid?.() ?? 0 }) {
5349
5573
  const custom = path4.resolve(home) !== path4.join(os3.homedir(), ".alp");
5350
5574
  const suffix = custom ? createHash2("sha256").update(path4.resolve(home)).digest("hex").slice(0, 8) : "";
5351
5575
  if (platform === "darwin") {
5352
5576
  const label = `com.alp.alpd${suffix ? `.${suffix}` : ""}`;
5353
- const directory = env.ALP_SERVICE_DIR || path4.join(os3.homedir(), "Library", "LaunchAgents");
5354
- const launchctl = env.ALP_LAUNCHCTL || "launchctl";
5577
+ const directory = env2.ALP_SERVICE_DIR || path4.join(os3.homedir(), "Library", "LaunchAgents");
5578
+ const launchctl = env2.ALP_LAUNCHCTL || "launchctl";
5355
5579
  const target = `gui/${uid}/${label}`;
5356
5580
  const file = path4.join(directory, `${label}.plist`);
5357
5581
  return {
@@ -5365,8 +5589,8 @@ function serviceFor({ home, env = process.env, platform = process.platform, uid
5365
5589
  }
5366
5590
  if (platform === "linux") {
5367
5591
  const name2 = `alpd${suffix ? `-${suffix}` : ""}`;
5368
- const directory = env.ALP_SERVICE_DIR || path4.join(env.XDG_CONFIG_HOME || path4.join(os3.homedir(), ".config"), "systemd", "user");
5369
- const systemctl = env.ALP_SYSTEMCTL || "systemctl";
5592
+ const directory = env2.ALP_SERVICE_DIR || path4.join(env2.XDG_CONFIG_HOME || path4.join(os3.homedir(), ".config"), "systemd", "user");
5593
+ const systemctl = env2.ALP_SYSTEMCTL || "systemctl";
5370
5594
  return {
5371
5595
  kind: "systemd",
5372
5596
  name: name2,
@@ -5419,7 +5643,7 @@ async function whenReady(home, timeoutMs, signal) {
5419
5643
  }
5420
5644
  throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path5.join(home, "logs")}`);
5421
5645
  }
5422
- async function startDaemon({ home, entry, env = process.env, timeoutMs = daemonStartTimeoutMs(env), automatic = false, signal }) {
5646
+ async function startDaemon({ home, entry, env: env2 = process.env, timeoutMs = daemonStartTimeoutMs(env2), automatic = false, signal }) {
5423
5647
  return withDaemonLifecycle(home, "start", async () => {
5424
5648
  signal?.throwIfAborted();
5425
5649
  if (automatic) {
@@ -5428,22 +5652,22 @@ async function startDaemon({ home, entry, env = process.env, timeoutMs = daemonS
5428
5652
  const lock = await readLock(home);
5429
5653
  signal?.throwIfAborted();
5430
5654
  if (lockAlive(lock)) return lock.ready ? lock.socket : whenReady(home, timeoutMs, signal);
5431
- const service = serviceFor({ home, env });
5655
+ const service = serviceFor({ home, env: env2 });
5432
5656
  if (service && await installedProgram(service)) {
5433
5657
  signal?.throwIfAborted();
5434
5658
  await startService(service);
5435
5659
  return whenReady(home, timeoutMs, signal);
5436
5660
  }
5437
- return ensureDaemon({ home, entry, env, timeoutMs, lifecycleLocked: true, signal });
5661
+ return ensureDaemon({ home, entry, env: env2, timeoutMs, lifecycleLocked: true, signal });
5438
5662
  }, { signal });
5439
5663
  }
5440
- function superviseDaemon({ home, entry, env = process.env, intervalMs = 5e3, misses = 2, log = () => {
5664
+ function superviseDaemon({ home, entry, env: env2 = process.env, intervalMs = 5e3, misses = 2, log = () => {
5441
5665
  }, by }) {
5442
5666
  let stopped = false;
5443
5667
  let missed = 0;
5444
5668
  let starting;
5445
5669
  const start = (reason, automatic = true) => {
5446
- starting ??= startDaemon({ home, entry: typeof entry === "function" ? entry() : entry, env, automatic }).then((socket) => {
5670
+ starting ??= startDaemon({ home, entry: typeof entry === "function" ? entry() : entry, env: env2, automatic }).then((socket) => {
5447
5671
  if (socket) log(`alpd ${reason}`);
5448
5672
  }, (error) => log(`could not start alpd: ${error?.message ?? error}`)).finally(() => {
5449
5673
  starting = void 0;
@@ -5477,191 +5701,6 @@ function superviseDaemon({ home, entry, env = process.env, intervalMs = 5e3, mis
5477
5701
  return stop;
5478
5702
  }
5479
5703
 
5480
- // packages/core/src/errors.js
5481
- var AlpError = class extends Error {
5482
- constructor(code, message, options) {
5483
- super(message, options);
5484
- this.name = "AlpError";
5485
- this.code = code;
5486
- }
5487
- };
5488
-
5489
- // packages/core/src/models.js
5490
- var codexFull = ["low", "medium", "high", "xhigh", "max", "ultra"];
5491
- var codexStandard = ["low", "medium", "high", "xhigh", "max"];
5492
- var claudeFull = ["low", "medium", "high", "xhigh", "max", "ultracode"];
5493
- var claudeLegacy = ["off", "low", "medium", "high", "xhigh", "max", "ultracode"];
5494
- var claude46 = ["off", "low", "medium", "high", "max"];
5495
- var MODELS = [
5496
- ["codex", "gpt-6.1-sol", "GPT-6.1-Sol", "Latest workhorse model for coding and everyday work.", codexFull, "low"],
5497
- // ALP runs GPT-6 Astra at low effort only.
5498
- ["codex", "gpt-6-astra", "GPT-6-Astra", "Frontier intelligence for the most demanding work.", ["low"], "low"],
5499
- ["codex", "gpt-6-sol", "GPT-6-Sol", "Previous generation workhorse model.", codexFull, "low"],
5500
- ["codex", "gpt-6-luna", "GPT-6-Luna", "Fast and affordable model for easier tasks.", codexStandard, "low"],
5501
- ["codex", "gpt-5.6-sol", "GPT-5.6-Sol", "Older generation workhorse model.", codexFull, "low"],
5502
- ["codex", "gpt-5.6-terra", "GPT-5.6-Terra", "Older balanced model for straightforward work.", codexFull, "low"],
5503
- ["codex", "gpt-5.6-luna", "GPT-5.6-Luna", "Older fast and efficient model.", codexStandard, "low"],
5504
- ["claude", "claude-opus-5-5", "Opus 5.5", "Latest release.", claudeFull, "medium"],
5505
- ["claude", "claude-opus-5", "Opus 5", "Previous release.", claudeLegacy, "high"],
5506
- ["claude", "claude-fable-5-1", "Fable 5.1", "Most powerful model.", claudeFull, "high"],
5507
- ["claude", "claude-fable-5", "Fable 5", "Previous release.", claudeFull, "high"],
5508
- ["claude", "claude-opus-4-8[1m]", "Opus 4.8 1M", "Opus 4.8 with 1M context window.", claudeLegacy, "high"],
5509
- ["claude", "claude-opus-4-8", "Opus 4.8", "Previous release.", claudeLegacy, "high"],
5510
- ["claude", "claude-sonnet-5-5", "Sonnet 5.5", "Best for everyday tasks.", claudeFull, "medium"],
5511
- ["claude", "claude-sonnet-5", "Sonnet 5", "Previous release.", claudeLegacy, "high"],
5512
- ["claude", "claude-sonnet-5[1m]", "Sonnet 5 1M", "Sonnet 5 with 1M context window.", claudeLegacy, "high"],
5513
- ["claude", "claude-opus-4-7[1m]", "Opus 4.7 1M", "Opus 4.7 with 1M context window.", claudeLegacy, "high"],
5514
- ["claude", "claude-opus-4-7", "Opus 4.7", "Previous release.", claudeLegacy, "high"],
5515
- ["claude", "claude-opus-4-6[1m]", "Opus 4.6 1M", "Opus 4.6 with 1M context window.", claude46, "high"],
5516
- ["claude", "claude-opus-4-6", "Opus 4.6", "Most capable for complex work.", claude46, "high"],
5517
- ["claude", "claude-sonnet-4-6[1m]", "Sonnet 4.6 1M", "Sonnet 4.6 with 1M context window.", claude46, "high"],
5518
- ["claude", "claude-sonnet-4-6", "Sonnet 4.6", "Best for everyday tasks.", claude46, "high"],
5519
- ["claude", "claude-haiku-4-5", "Haiku 4.5", "Fastest for quick answers.", [], void 0],
5520
- ["claude", "sonnet", "sonnet", "From Claude settings.json model.", [], void 0],
5521
- ["antigravity", "gemini-3.8-flash-high", "Gemini 3.8 Flash (High)", "High reasoning effort workhorse for complex tasks.", [], void 0],
5522
- ["antigravity", "gemini-3.8-flash-medium", "Gemini 3.8 Flash (Medium)", "Balanced speed and reasoning.", [], void 0],
5523
- ["antigravity", "gemini-3.8-flash-low", "Gemini 3.8 Flash (Low)", "Fast and efficient for straightforward work.", [], void 0],
5524
- ["antigravity", "gemini-2.5-pro", "Gemini 2.5 Pro", "Deep reasoning for coding and analysis.", [], void 0],
5525
- ["antigravity", "gemini-2.5-flash", "Gemini 2.5 Flash", "Fast and versatile everyday model.", [], void 0],
5526
- ["antigravity", "claude-sonnet-4-6", "Claude Sonnet 4.6", "Sonnet 4.6 via Antigravity.", [], void 0],
5527
- ["antigravity", "claude-opus-4-6-thinking", "Claude Opus 4.6 Thinking", "Opus 4.6 with thinking via Antigravity.", [], void 0],
5528
- ["antigravity", "gpt-oss-120b-medium", "GPT-OSS 120B (Medium)", "Open weights model via Antigravity.", [], void 0]
5529
- ].map(([runtime, id, label, description, efforts, effort]) => ({ runtime, id, label, description, efforts, ...effort ? { effort } : {} }));
5530
-
5531
- // packages/core/src/permissions.js
5532
- var BASES = ["read-only", "workspace-write", "full-access"];
5533
- var MAX_RULES = 200;
5534
- var NAME = /^[\w.-]{1,64}$/;
5535
- var RULE = /^([A-Za-z][\w-]*)(?:\((.*)\))?$/s;
5536
- var TOOLS = ["Bash", "Read", "Edit", "Write", "MultiEdit", "NotebookEdit", "Glob", "Grep", "WebFetch", "WebSearch", "Skill"];
5537
- var setOwn = (value, key2, entry) => Object.defineProperty(value, key2, { value: entry, enumerable: true, writable: true, configurable: true });
5538
- var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5539
- var fail = (source, message) => {
5540
- throw new AlpError("INVALID_SETTINGS", `${source}: ${message}`);
5541
- };
5542
- function parseRule(rule, source = "rule") {
5543
- if (typeof rule !== "string" || rule.length > 500) fail(source, "a rule is text of at most 500 characters");
5544
- const match = RULE.exec(rule.trim());
5545
- if (!match) fail(source, `${JSON.stringify(rule)} is not Tool or Tool(specifier)`);
5546
- const [, tool, specifier] = match;
5547
- if (!TOOLS.includes(tool) && !/^mcp__[\w-]+(__[\w-]+)?$/.test(tool)) fail(source, `${JSON.stringify(rule)} names unknown tool ${tool}; use ${TOOLS.join(", ")} or mcp__<server>__<tool>`);
5548
- if (specifier !== void 0 && !specifier.trim()) fail(source, `${JSON.stringify(rule)} has an empty specifier`);
5549
- return { tool, ...specifier !== void 0 && specifier.trim() !== "*" ? { specifier: specifier.trim() } : {} };
5550
- }
5551
- function validatePermissions(value, source) {
5552
- if (value === void 0) return { profiles: {}, agents: {} };
5553
- if (!object(value)) fail(source, "permissions must be an object");
5554
- for (const key2 of Object.keys(value)) if (!["profiles", "agents"].includes(key2)) fail(source, `unsupported permissions field '${key2}'`);
5555
- const profiles = {};
5556
- if (value.profiles !== void 0) {
5557
- if (!object(value.profiles)) fail(source, "permissions.profiles must be an object");
5558
- for (const [name2, profile] of Object.entries(value.profiles)) {
5559
- const where = `permissions.profiles.${name2}`;
5560
- if (!NAME.test(name2)) fail(source, `${where}: a profile name has letters, digits, dots, dashes and underscores`);
5561
- if (!object(profile)) fail(source, `${where} must be an object`);
5562
- for (const key2 of Object.keys(profile)) if (!["base", "allow", "ask", "deny", "beyondMode", "workdir"].includes(key2)) fail(source, `${where}: unsupported field '${key2}'`);
5563
- if (profile.workdir !== void 0 && profile.workdir !== "copy") fail(source, `${where}.workdir must be copy`);
5564
- if (profile.workdir === "copy" && profile.base !== void 0 && profile.base !== "read-only") fail(source, `${where}: workdir copy is for read-only profiles; writers use worktree isolation`);
5565
- if (profile.base !== void 0 && !BASES.includes(profile.base)) fail(source, `${where}.base must be ${BASES.join(", ")}`);
5566
- if (profile.beyondMode !== void 0 && !["refuse", "ask"].includes(profile.beyondMode)) fail(source, `${where}.beyondMode must be refuse or ask`);
5567
- const rules = {};
5568
- for (const kind of ["allow", "ask", "deny"]) {
5569
- const list = profile[kind] ?? [];
5570
- if (!Array.isArray(list) || list.length > MAX_RULES) fail(source, `${where}.${kind} must list at most ${MAX_RULES} rules`);
5571
- for (const rule of list) parseRule(rule, `${source}: ${where}.${kind}`);
5572
- rules[kind] = list.map((rule) => rule.trim());
5573
- }
5574
- setOwn(profiles, name2, { ...profile.base ? { base: profile.base } : {}, ...profile.beyondMode ? { beyondMode: profile.beyondMode } : {}, ...profile.workdir ? { workdir: profile.workdir } : {}, ...rules });
5575
- }
5576
- }
5577
- const agents = {};
5578
- if (value.agents !== void 0) {
5579
- if (!object(value.agents)) fail(source, "permissions.agents must be an object");
5580
- for (const [agent, profile] of Object.entries(value.agents)) {
5581
- if (typeof profile !== "string" || !NAME.test(profile)) fail(source, `permissions.agents.${agent} must name a profile`);
5582
- setOwn(agents, agent, profile);
5583
- }
5584
- }
5585
- return { profiles, agents };
5586
- }
5587
-
5588
- // packages/core/src/validation.js
5589
- var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5590
- var nonempty = (value) => typeof value === "string" && value.trim().length > 0;
5591
- function requireValue(condition, code, source, message) {
5592
- if (!condition) throw new AlpError(code, `${source}: ${message}`);
5593
- }
5594
- var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "web", "curate"];
5595
- var RETIRED_SETTINGS = { project: {}, user: {} };
5596
- function distance(a, b) {
5597
- const row = Array.from({ length: b.length + 1 }, (_, index) => index);
5598
- for (let i = 1; i <= a.length; i++) {
5599
- let previous = row[0];
5600
- row[0] = i;
5601
- for (let j = 1; j <= b.length; j++) {
5602
- const kept = row[j];
5603
- row[j] = Math.min(row[j] + 1, row[j - 1] + 1, previous + (a[i - 1].toLowerCase() === b[j - 1].toLowerCase() ? 0 : 1));
5604
- previous = kept;
5605
- }
5606
- }
5607
- return row[b.length];
5608
- }
5609
- function settingsKeys(settings, known, retired = {}) {
5610
- const unknown = [];
5611
- const old = [];
5612
- for (const key2 of Object.keys(object2(settings) ? settings : {})) {
5613
- if (known.includes(key2)) continue;
5614
- if (Object.hasOwn(retired, key2)) {
5615
- old.push({ key: key2, instead: retired[key2] });
5616
- continue;
5617
- }
5618
- const near = known.filter((candidate) => !candidate.startsWith("$")).map((candidate) => ({ candidate, d: distance(key2, candidate) })).sort((a, b) => a.d - b.d)[0];
5619
- unknown.push({ key: key2, ...near && near.d <= 2 ? { suggestion: near.candidate } : {} });
5620
- }
5621
- return { unknown, retired: old };
5622
- }
5623
- var unknownMessage = (unknown, known) => `unknown setting '${unknown.key}'${unknown.suggestion ? `; did you mean '${unknown.suggestion}'?` : `; known settings are ${known.filter((key2) => !key2.startsWith("$")).join(", ")}`}`;
5624
- function checkCurate(settings, check2) {
5625
- if (settings.curate === void 0) return;
5626
- check2(object2(settings.curate), "curate must be an object");
5627
- check2(Object.keys(settings.curate).every((key2) => key2 === "monthly"), "unsupported curate field; use monthly");
5628
- if (settings.curate.monthly !== void 0) check2(typeof settings.curate.monthly === "boolean", "curate.monthly must be true or false");
5629
- }
5630
- function validateUserSettings(settings, source) {
5631
- const check2 = (ok, message) => requireValue(ok, "INVALID_SETTINGS", source, message);
5632
- check2(object2(settings), "expected an object");
5633
- const { unknown } = settingsKeys(settings, USER_SETTINGS, RETIRED_SETTINGS.user);
5634
- check2(!unknown.length, unknown.length ? unknownMessage(unknown[0], USER_SETTINGS) : "");
5635
- checkCurate(settings, check2);
5636
- for (const key2 of ["limits", "recovery"]) {
5637
- if (settings[key2] === void 0) continue;
5638
- check2(object2(settings[key2]), `${key2} must be an object`);
5639
- const extra = Object.keys(settings[key2]).find((field) => field !== "autoResume");
5640
- check2(!extra, `unsupported ${key2} field '${extra}'; use autoResume`);
5641
- if (settings[key2].autoResume !== void 0) check2(typeof settings[key2].autoResume === "boolean", `${key2}.autoResume must be true or false`);
5642
- }
5643
- if (settings.web !== void 0) {
5644
- check2(object2(settings.web), "web must be an object");
5645
- const extra = Object.keys(settings.web).find((field) => !["enabled", "port", "relay", "permissions"].includes(field));
5646
- check2(!extra, `unsupported web field '${extra}'; use enabled, port, relay or permissions`);
5647
- if (settings.web.permissions !== void 0) check2(Array.isArray(settings.web.permissions) && settings.web.permissions.every((entry) => typeof entry === "string" && /^[a-z][a-z.]*$/.test(entry)), "web.permissions must be a list of permission names, such as files.read");
5648
- const relay = settings.web.relay;
5649
- if (relay !== void 0) {
5650
- check2(object2(relay), "web.relay must be an object");
5651
- const unsupported = Object.keys(relay).find((field) => !["enabled", "endpoint", "useTls"].includes(field));
5652
- check2(!unsupported, `unsupported web.relay field '${unsupported}'; use enabled, endpoint or useTls`);
5653
- if (relay.enabled !== void 0) check2(typeof relay.enabled === "boolean", "web.relay.enabled must be true or false");
5654
- if (relay.endpoint !== void 0) check2(typeof relay.endpoint === "string" && /^[a-z0-9.-]+:\d{1,5}$/i.test(relay.endpoint), "web.relay.endpoint must be host:port, such as relay.paseo.sh:443");
5655
- if (relay.useTls !== void 0) check2(typeof relay.useTls === "boolean", "web.relay.useTls must be true or false");
5656
- }
5657
- if (settings.web.enabled !== void 0) check2(typeof settings.web.enabled === "boolean", "web.enabled must be true or false");
5658
- if (settings.web.port !== void 0) check2(Number.isInteger(settings.web.port) && settings.web.port >= 1024 && settings.web.port <= 65535, "web.port must be a port from 1024 to 65535");
5659
- }
5660
- if (settings.language !== void 0) check2(nonempty(settings.language) && settings.language.trim().length <= 40, "language must be a language name of at most 40 characters, such as Vietnamese or English");
5661
- validatePermissions(settings.permissions, source);
5662
- return settings;
5663
- }
5664
-
5665
5704
  // apps/gateway/src/server.js
5666
5705
  import { randomBytes as randomBytes3 } from "node:crypto";
5667
5706
  import { readFile as readFile3 } from "node:fs/promises";
@@ -9485,7 +9524,7 @@ function scrubGatewaySecrets(line) {
9485
9524
  );
9486
9525
  return result;
9487
9526
  }
9488
- function createGatewayLogger({ write, level, env } = {}) {
9527
+ function createGatewayLogger({ write, level, env: env2 } = {}) {
9489
9528
  const sink = write ?? ((line) => {
9490
9529
  try {
9491
9530
  process.stderr.write(`${line}
@@ -9493,16 +9532,16 @@ function createGatewayLogger({ write, level, env } = {}) {
9493
9532
  } catch {
9494
9533
  }
9495
9534
  });
9496
- return createLogger({ component: "alp-gateway", level, env, write: (line) => sink(scrubGatewaySecrets(line)) });
9535
+ return createLogger({ component: "alp-gateway", level, env: env2, write: (line) => sink(scrubGatewaySecrets(line)) });
9497
9536
  }
9498
9537
 
9499
- // packages/cli/src/web/grant.js
9538
+ // packages/cli/src/dashboard/grant.js
9500
9539
  import { mkdir as mkdir5, realpath as realpath3, stat as stat4 } from "node:fs/promises";
9501
9540
  import path8 from "node:path";
9502
9541
 
9503
9542
  // packages/core/src/tasks.js
9504
9543
  var AGENT_MARKER = "ALP_AGENT_SESSION";
9505
- var isAgentProcess = (env = process.env) => typeof env[AGENT_MARKER] === "string" && env[AGENT_MARKER] !== "";
9544
+ var isAgentProcess = (env2 = process.env) => typeof env2[AGENT_MARKER] === "string" && env2[AGENT_MARKER] !== "";
9506
9545
  var LOCK = ".lock";
9507
9546
  var GITIGNORE = `${LOCK}
9508
9547
  *.tmp
@@ -9511,10 +9550,10 @@ var GATE_REJECT_LABELS = ["Reject", "T\u1EEB ch\u1ED1i"];
9511
9550
  var labelKey = (text) => text.normalize("NFC").trim().toLowerCase();
9512
9551
  var REJECT_KEYS = new Set(GATE_REJECT_LABELS.map(labelKey));
9513
9552
 
9514
- // packages/cli/src/web/grant.js
9515
- var LABEL = "alp web (this machine)";
9553
+ // packages/cli/src/dashboard/grant.js
9554
+ var LABEL = "alp dashboard (this machine)";
9516
9555
  var BASE_PERMISSIONS = Object.freeze([...DEFAULT_PERMISSIONS, "workspace.write"]);
9517
- var webGatewayHome = (home) => path8.join(home, "web");
9556
+ var dashboardGatewayHome = (home) => path8.join(home, "dashboard");
9518
9557
  function grantPermissions(extra, warn = () => {
9519
9558
  }) {
9520
9559
  const wanted = new Set(BASE_PERMISSIONS);
@@ -9525,7 +9564,7 @@ function grantPermissions(extra, warn = () => {
9525
9564
  /** @type {string[]} */
9526
9565
  extra
9527
9566
  ) wanted.add(entry);
9528
- else warn(`ignoring web.permissions: ${unknown.map((entry) => JSON.stringify(entry)).join(", ")} ${unknown.length === 1 ? "is not a permission" : "are not permissions"} a credential may hold (${PERMISSIONS.join(", ")}); the default grant (${BASE_PERMISSIONS.join(", ")}) is in use`);
9567
+ else warn(`ignoring dashboard.permissions: ${unknown.map((entry) => JSON.stringify(entry)).join(", ")} ${unknown.length === 1 ? "is not a permission" : "are not permissions"} a credential may hold (${PERMISSIONS.join(", ")}); the default grant (${BASE_PERMISSIONS.join(", ")}) is in use`);
9529
9568
  }
9530
9569
  if (wanted.has("session.write")) wanted.add("session.read");
9531
9570
  if (wanted.has("project.write") || wanted.has("library.write")) wanted.add("project.read");
@@ -9571,7 +9610,7 @@ async function registryRoots(socket, { timeoutMs = 3e3 } = {}) {
9571
9610
  async function listRoots(socket, opened) {
9572
9611
  let client;
9573
9612
  try {
9574
- client = await connect(socket, { name: "alp-web", version: "1" });
9613
+ client = await connect(socket, { name: "alp-dashboard", version: "1" });
9575
9614
  opened(client);
9576
9615
  const roots = [];
9577
9616
  let cursor;
@@ -9601,7 +9640,7 @@ var sameWorkspaces = (a, b) => {
9601
9640
  var samePermissions = (a, b) => JSON.stringify([...a].sort()) === JSON.stringify([...b].sort());
9602
9641
  function createGrant({ home, store, permissions, project, socket, log = () => {
9603
9642
  } }) {
9604
- const credentialsHome = webGatewayHome(home);
9643
+ const credentialsHome = dashboardGatewayHome(home);
9605
9644
  const placeholder = path8.join(credentialsHome, "no-project");
9606
9645
  let tail2 = Promise.resolve();
9607
9646
  const serial = (run2) => {
@@ -9629,13 +9668,13 @@ function createGrant({ home, store, permissions, project, socket, log = () => {
9629
9668
  settled: () => tail2.then(() => void 0),
9630
9669
  /**
9631
9670
  * Reuses the credential of `token` when it still verifies, else creates one; revokes every other
9632
- * live credential in alp-web's file. Returns the token to publish.
9633
- * @param {{ token?: unknown, credentialId?: unknown }} previous what web.json held
9671
+ * live credential in alp dashboard's file. Returns the token to publish.
9672
+ * @param {{ token?: unknown, credentialId?: unknown }} previous what dashboard.json held
9634
9673
  */
9635
9674
  ensure: (previous) => serial(async () => {
9636
- if (isAgentProcess()) throw new Error("alp web hands out a user credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set), so it is refused");
9675
+ if (isAgentProcess()) throw new Error("alp dashboard hands out a user credential; this process was started by an ALP agent (ALP_AGENT_SESSION is set), so it is refused");
9637
9676
  await assertPrivateDirectory(credentialsHome, { create: true }).catch((error) => {
9638
- throw new Error(`alp web keeps its credentials in ${credentialsHome}, which must be a directory owned by you with private permissions (0700); run chmod 700 on it (${error?.message ?? error})`, { cause: error });
9677
+ throw new Error(`alp dashboard keeps its credentials in ${credentialsHome}, which must be a directory owned by you with private permissions (0700); run chmod 700 on it (${error?.message ?? error})`, { cause: error });
9639
9678
  });
9640
9679
  await store.reload();
9641
9680
  const reused = typeof previous.token === "string" ? store.verify(previous.token) : void 0;
@@ -9686,7 +9725,7 @@ function createGrant({ home, store, permissions, project, socket, log = () => {
9686
9725
  };
9687
9726
  }
9688
9727
 
9689
- // packages/cli/src/web/serve.js
9728
+ // packages/cli/src/dashboard/serve.js
9690
9729
  import { createReadStream } from "node:fs";
9691
9730
  import { realpath as realpath4, stat as stat5 } from "node:fs/promises";
9692
9731
  import path9 from "node:path";
@@ -9714,16 +9753,16 @@ var TYPES = {
9714
9753
  };
9715
9754
  var FORBIDDEN_IN_SEGMENT = /[\u0000-\u001f\u007f/\\:]/;
9716
9755
  var missingPage = (dir) => `<!doctype html><meta charset="utf-8"><title>ALP</title><body style="font:16px system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem">
9717
- <h1>ALP web is not built</h1><p>The web app's files are missing from <code>${dir.replace(/[&<>"]/g, (char) => `&#${char.charCodeAt(0)};`)}</code>. Build them from a checkout with <code>node scripts/build-workspace.mjs cli</code> (or <code>node scripts/build-alp-web.mjs</code>), or install ALP from npm, which carries them. The gateway on this address keeps running.</p>`;
9756
+ <h1>ALP dashboard is not built</h1><p>The web app's files are missing from <code>${dir.replace(/[&<>"]/g, (char) => `&#${char.charCodeAt(0)};`)}</code>. Build them from a checkout with <code>node scripts/build-workspace.mjs cli</code> (or <code>node scripts/build-alp-dashboard.mjs</code>), or install ALP from npm, which carries them. The gateway on this address keeps running.</p>`;
9718
9757
  function parseTarget(raw) {
9719
9758
  if (typeof raw !== "string" || !raw.startsWith("/") || raw.includes("\\") || /%5c/i.test(raw) || raw.includes("\0")) return { status: 400 };
9720
9759
  let url;
9721
9760
  try {
9722
- url = new URL(`http://alp-web.invalid${raw}`);
9761
+ url = new URL(`http://alp-dashboard.invalid${raw}`);
9723
9762
  } catch {
9724
9763
  return { status: 400 };
9725
9764
  }
9726
- if (url.host !== "alp-web.invalid") return { status: 400 };
9765
+ if (url.host !== "alp-dashboard.invalid") return { status: 400 };
9727
9766
  const parts = url.pathname.split("/").slice(1);
9728
9767
  const segments = [];
9729
9768
  for (let index = 0; index < parts.length; index++) {
@@ -9819,18 +9858,20 @@ function createStaticServer({ dir, csp, log = () => {
9819
9858
  };
9820
9859
  }
9821
9860
 
9822
- // packages/cli/src/web/main.js
9823
- var VERSION = true ? "0.0.1-beta.8" : "0.0.0-source";
9861
+ // packages/cli/src/dashboard/main.js
9862
+ var VERSION = true ? "0.0.1-beta.9" : "0.0.0-source";
9824
9863
  var DEFAULT_WEB_PORT = 7433;
9825
9864
  var PORT_TRIES = 10;
9826
- var REFRESH_MS = Number(process.env.ALP_WEB_GRANT_REFRESH_MS) > 0 ? Number(process.env.ALP_WEB_GRANT_REFRESH_MS) : 5e3;
9865
+ var env = (name2) => process.env[`ALP_DASHBOARD_${name2}`] || process.env[`ALP_WEB_${name2}`] || void 0;
9866
+ var REFRESH_MS = Number(env("GRANT_REFRESH_MS")) > 0 ? Number(env("GRANT_REFRESH_MS")) : 5e3;
9827
9867
  var WEB_FILE_VERSION = 2;
9828
9868
  var here = path10.dirname(fileURLToPath(import.meta.url));
9829
- var appDir = () => path10.resolve(process.env.ALP_WEB_APP || path10.join(here, "alp-web"));
9830
- var daemonEntry = () => process.env.ALP_DAEMON_ENTRY ?? selfEntry(path10.join(here, "alpd.js"));
9831
- var webFile = (home) => path10.join(home, "web.json");
9869
+ var appDir = () => path10.resolve(env("APP") || path10.join(here, "alp-dashboard"));
9870
+ var daemonEntry2 = () => process.env.ALP_DAEMON_ENTRY ?? daemonEntry(path10.join(here, "alpd.js"));
9871
+ var webFile = (home) => path10.join(home, "dashboard.json");
9872
+ var legacyWebFile = (home) => path10.join(home, "web.json");
9832
9873
  function serviceLog(home) {
9833
- const file = path10.join(home, "logs", "integrations", "alp-web.log");
9874
+ const file = path10.join(home, "logs", "integrations", "alp-dashboard.log");
9834
9875
  mkdirSync(path10.dirname(file), { recursive: true, mode: 448 });
9835
9876
  const fd = openSync(file, "a", 384);
9836
9877
  for (const stream of [process.stdout, process.stderr]) {
@@ -9867,7 +9908,7 @@ async function userSettings(home, log) {
9867
9908
  async function previousWeb(home) {
9868
9909
  try {
9869
9910
  const kept = JSON.parse(await readFile5(webFile(home), "utf8"));
9870
- if (kept?.app !== "alp-web" || kept?.version !== WEB_FILE_VERSION || !parseToken(kept.token)) return {};
9911
+ if (kept?.app !== "alp-dashboard" || kept?.version !== WEB_FILE_VERSION || !parseToken(kept.token)) return {};
9871
9912
  return { token: kept.token, credentialId: kept.credentialId };
9872
9913
  } catch {
9873
9914
  return {};
@@ -9891,7 +9932,7 @@ var LOCK_HELD = 3;
9891
9932
  async function carryPaseoIdentity(home, log) {
9892
9933
  let legacy;
9893
9934
  try {
9894
- legacy = JSON.parse(await readFile5(webFile(home), "utf8"));
9935
+ legacy = JSON.parse(await readFile5(legacyWebFile(home), "utf8"));
9895
9936
  } catch {
9896
9937
  return false;
9897
9938
  }
@@ -9913,44 +9954,44 @@ async function carryPaseoIdentity(home, log) {
9913
9954
  /** @type {any} */
9914
9955
  error?.code === "EEXIST"
9915
9956
  ) return false;
9916
- throw new Error(`the Paseo integration's identity in ${webFile(home)} could not be kept in ${target}, so alp web leaves web.json alone: ${/** @type {any} */
9957
+ throw new Error(`the Paseo integration's identity in ${legacyWebFile(home)} could not be kept in ${target}, so alp dashboard does not start: ${/** @type {any} */
9917
9958
  error?.message ?? error}`, { cause: error });
9918
9959
  } finally {
9919
9960
  await unlink6(temporary).catch(() => {
9920
9961
  });
9921
9962
  }
9922
- log.info(`kept the Paseo integration's identity from web.json in ${target}, so paired devices stay paired`, { code: "ALP_WEB_PASEO_IDENTITY" });
9963
+ log.info(`kept the Paseo integration's identity from web.json in ${target}, so paired devices stay paired`, { code: "ALP_DASHBOARD_PASEO_IDENTITY" });
9923
9964
  return true;
9924
9965
  }
9925
- async function rotate(home, project, settings, log) {
9926
- const lock = createIntegrationLock(home, "web");
9966
+ async function rotate(home, project, dashboard, log) {
9967
+ const lock = createIntegrationLock(home, "dashboard");
9927
9968
  const { acquired, lock: held } = await lock.acquire();
9928
9969
  if (!acquired) {
9929
- process.stderr.write(`alp web runs (pid ${held.pid}); it must stop before its token is rotated
9970
+ process.stderr.write(`alp dashboard runs (pid ${held.pid}); it must stop before its token is rotated
9930
9971
  `);
9931
9972
  process.exit(LOCK_HELD);
9932
9973
  }
9933
9974
  let code = 0;
9934
9975
  try {
9935
9976
  await carryPaseoIdentity(home, log);
9936
- const permissions = grantPermissions(settings?.web?.permissions, (message) => log.warn(message, { code: "ALP_WEB_PERMISSIONS_IGNORED" }));
9937
- const store = new CredentialStore({ home: webGatewayHome(home), logger: log });
9977
+ const permissions = grantPermissions(dashboard.permissions, (message) => log.warn(message, { code: "ALP_DASHBOARD_PERMISSIONS_IGNORED" }));
9978
+ const store = new CredentialStore({ home: dashboardGatewayHome(home), logger: log });
9938
9979
  try {
9939
9980
  const socket = daemonPaths(home).socket;
9940
- const grant = createGrant({ home, store, permissions, project, socket: () => socket, log: (message) => log.info(message, { code: "ALP_WEB_GRANT" }) });
9981
+ const grant = createGrant({ home, store, permissions, project, socket: () => socket, log: (message) => log.info(message, { code: "ALP_DASHBOARD_GRANT" }) });
9941
9982
  const token = await grant.ensure({});
9942
9983
  await grant.settled();
9943
- await publish(home, { version: WEB_FILE_VERSION, app: "alp-web", token, credentialId: grant.id });
9944
- log.info(`rotated the token: credential ${grant.id}`, { code: "ALP_WEB_ROTATED" });
9984
+ await publish(home, { version: WEB_FILE_VERSION, app: "alp-dashboard", token, credentialId: grant.id });
9985
+ log.info(`rotated the token: credential ${grant.id}`, { code: "ALP_DASHBOARD_ROTATED" });
9945
9986
  } finally {
9946
9987
  store.close();
9947
9988
  }
9948
9989
  } catch (error) {
9949
- log.error("alp web could not rotate its token", { code: "ALP_WEB_ROTATE_FAILED", error });
9990
+ log.error("alp dashboard could not rotate its token", { code: "ALP_DASHBOARD_ROTATE_FAILED", error });
9950
9991
  code = 1;
9951
9992
  }
9952
9993
  await lock.release().catch((error) => {
9953
- log.error("web lock not released", { code: "ALP_LOCK_RELEASE_FAILED", error });
9994
+ log.error("dashboard lock not released", { code: "ALP_LOCK_RELEASE_FAILED", error });
9954
9995
  code = 1;
9955
9996
  });
9956
9997
  process.exit(code);
@@ -9971,25 +10012,27 @@ var policy = (port) => {
9971
10012
  ].join("; ");
9972
10013
  };
9973
10014
  async function run() {
9974
- const { values } = parseArgs({ options: { service: { type: "boolean" }, rotate: { type: "boolean" }, project: { type: "string" } }, strict: true });
10015
+ const { values } = parseArgs({ options: { service: { type: "boolean" }, rotate: { type: "boolean" }, project: { type: "string" }, port: { type: "string" } }, strict: true });
10016
+ const portOption = values.port === void 0 ? void 0 : Number(values.port);
10017
+ if (portOption !== void 0 && !(Number.isInteger(portOption) && portOption >= 1024 && portOption <= 65535)) throw new Error(`--port must be a port from 1024 to 65535, not ${values.port}`);
9975
10018
  const home = alpHome();
9976
10019
  await mkdir6(home, { recursive: true, mode: 448 });
9977
10020
  if (values.service) serviceLog(home);
9978
10021
  const log = createGatewayLogger();
9979
- const settings = await userSettings(home, log);
9980
- if (values.rotate) return rotate(home, values.project ? path10.resolve(values.project) : void 0, settings, log);
9981
- if (settings?.web?.enabled === false) {
9982
- log.info('alp web is disabled by settings ("web.enabled": false)', { code: "ALP_WEB_DISABLED" });
10022
+ const dashboard = dashboardSettings(await userSettings(home, log));
10023
+ if (values.rotate) return rotate(home, values.project ? path10.resolve(values.project) : void 0, dashboard, log);
10024
+ if (dashboard.enabled === false) {
10025
+ log.info('alp dashboard is disabled by settings ("dashboard.enabled": false)', { code: "ALP_DASHBOARD_DISABLED" });
9983
10026
  process.exit(0);
9984
10027
  }
9985
10028
  const project = values.project ? path10.resolve(values.project) : void 0;
9986
- const lock = createIntegrationLock(home, "web");
10029
+ const lock = createIntegrationLock(home, "dashboard");
9987
10030
  const { acquired, lock: held } = await lock.acquire();
9988
10031
  if (!acquired) {
9989
- log.info(`alp web already runs (pid ${held.pid})`, { code: "ALP_LOCK_HELD" });
10032
+ log.info(`alp dashboard already runs (pid ${held.pid})`, { code: "ALP_LOCK_HELD" });
9990
10033
  process.exit(0);
9991
10034
  }
9992
- const releaseLock = () => lock.release().catch((error) => log.error("web lock not released; alp web stops anyway", { code: "ALP_LOCK_RELEASE_FAILED", error }));
10035
+ const releaseLock = () => lock.release().catch((error) => log.error("dashboard lock not released; alp dashboard stops anyway", { code: "ALP_LOCK_RELEASE_FAILED", error }));
9993
10036
  const cleanups = [];
9994
10037
  let shuttingDown = false;
9995
10038
  let startup = Promise.resolve();
@@ -9999,7 +10042,7 @@ async function run() {
9999
10042
  try {
10000
10043
  await startup.catch(() => {
10001
10044
  });
10002
- for (const cleanup of cleanups.reverse()) await cleanup().catch((error) => log.warn("a shutdown step failed", { code: "ALP_WEB_SHUTDOWN_STEP", error }));
10045
+ for (const cleanup of cleanups.reverse()) await cleanup().catch((error) => log.warn("a shutdown step failed", { code: "ALP_DASHBOARD_SHUTDOWN_STEP", error }));
10003
10046
  await releaseLock();
10004
10047
  } finally {
10005
10048
  process.exit(code);
@@ -10011,16 +10054,16 @@ async function run() {
10011
10054
  ["SIGINT", "SIGTERM"]
10012
10055
  ) process.on(signal, () => void shutdown());
10013
10056
  process.on("uncaughtException", (error) => {
10014
- log.error("uncaught exception; alp web stops", { code: "ALP_FATAL", error });
10057
+ log.error("uncaught exception; alp dashboard stops", { code: "ALP_FATAL", error });
10015
10058
  void shutdown(1);
10016
10059
  });
10017
10060
  startup = (async () => {
10018
10061
  const stopDaemon = process.env.ALP_SUPERVISE === "0" ? async () => {
10019
- } : superviseDaemon({ home, entry: daemonEntry, by: "alp web", log: (message) => log.warn(message, { code: "ALP_DAEMON_SUPERVISION" }) });
10062
+ } : superviseDaemon({ home, entry: daemonEntry2, by: "alp dashboard", log: (message) => log.warn(message, { code: "ALP_DAEMON_SUPERVISION" }) });
10020
10063
  cleanups.push(() => stopDaemon());
10021
- const permissions = grantPermissions(settings?.web?.permissions, (message) => log.warn(message, { code: "ALP_WEB_PERMISSIONS_IGNORED" }));
10022
- if (permissions.includes("terminal.exec")) log.warn(TERMINAL_EXEC_WARNING, { code: "ALP_WEB_TERMINAL_EXEC" });
10023
- const store = new CredentialStore({ home: webGatewayHome(home), logger: log });
10064
+ const permissions = grantPermissions(dashboard.permissions, (message) => log.warn(message, { code: "ALP_DASHBOARD_PERMISSIONS_IGNORED" }));
10065
+ if (permissions.includes("terminal.exec")) log.warn(TERMINAL_EXEC_WARNING, { code: "ALP_DASHBOARD_TERMINAL_EXEC" });
10066
+ const store = new CredentialStore({ home: dashboardGatewayHome(home), logger: log });
10024
10067
  cleanups.push(async () => store.close());
10025
10068
  const socket = daemonPaths(home).socket;
10026
10069
  const grant = createGrant({
@@ -10029,7 +10072,7 @@ async function run() {
10029
10072
  permissions,
10030
10073
  project,
10031
10074
  socket: () => socket,
10032
- log: (message) => log.info(message, { code: "ALP_WEB_GRANT" })
10075
+ log: (message) => log.info(message, { code: "ALP_DASHBOARD_GRANT" })
10033
10076
  });
10034
10077
  cleanups.push(() => grant.settled());
10035
10078
  await carryPaseoIdentity(home, log);
@@ -10040,8 +10083,8 @@ async function run() {
10040
10083
  if (shuttingDown) return;
10041
10084
  const dir = appDir();
10042
10085
  let bound = 0;
10043
- const serveStatic = createStaticServer({ dir, csp: () => policy(bound), log: (message) => log.warn(message, { code: "ALP_WEB_STATIC" }) });
10044
- const base = settings?.web?.port ?? DEFAULT_WEB_PORT;
10086
+ const serveStatic = createStaticServer({ dir, csp: () => policy(bound), log: (message) => log.warn(message, { code: "ALP_DASHBOARD_STATIC" }) });
10087
+ const base = portOption ?? dashboard.port ?? DEFAULT_WEB_PORT;
10045
10088
  for (let attempt = 0; ; attempt++) {
10046
10089
  if (shuttingDown) return;
10047
10090
  const port = base + attempt;
@@ -10072,12 +10115,12 @@ async function run() {
10072
10115
  error?.code
10073
10116
  );
10074
10117
  if (code !== "EADDRINUSE" && code !== "EACCES" || attempt + 1 >= PORT_TRIES) throw error;
10075
- log.info(`port ${port} is ${code === "EACCES" ? "not available" : "in use"}; trying ${port + 1}`, { code: "ALP_WEB_PORT_BUSY" });
10118
+ log.info(`port ${port} is ${code === "EACCES" ? "not available" : "in use"}; trying ${port + 1}`, { code: "ALP_DASHBOARD_PORT_BUSY" });
10076
10119
  }
10077
10120
  }
10078
10121
  if (shuttingDown) return;
10079
10122
  const url = `http://127.0.0.1:${bound}/`;
10080
- await publish(home, { version: WEB_FILE_VERSION, app: "alp-web", pid: process.pid, port: bound, url, token, credentialId: grant.id });
10123
+ await publish(home, { version: WEB_FILE_VERSION, app: "alp-dashboard", pid: process.pid, port: bound, url, token, credentialId: grant.id });
10081
10124
  if (shuttingDown) return;
10082
10125
  const timer = setInterval(() => {
10083
10126
  if (!shuttingDown) void grant.refresh();
@@ -10105,16 +10148,16 @@ async function run() {
10105
10148
  });
10106
10149
  } catch {
10107
10150
  }
10108
- if (!await lock.setReady(true)) throw new Error("the web lock is no longer held by this process");
10109
- log.info(`alp web on ${url}`, { code: "ALP_WEB_LISTENING" });
10151
+ if (!await lock.setReady(true)) throw new Error("the dashboard lock is no longer held by this process");
10152
+ log.info(`alp dashboard on ${url}`, { code: "ALP_DASHBOARD_LISTENING" });
10110
10153
  })();
10111
10154
  await startup.catch((error) => {
10112
- log.error("alp web did not start", { code: "ALP_WEB_START_FAILED", error });
10155
+ log.error("alp dashboard did not start", { code: "ALP_DASHBOARD_START_FAILED", error });
10113
10156
  void shutdown(1);
10114
10157
  });
10115
10158
  }
10116
10159
  await run().catch((error) => {
10117
- createGatewayLogger().error("alp web did not start", { code: "ALP_WEB_START_FAILED", error });
10160
+ createGatewayLogger().error("alp dashboard did not start", { code: "ALP_DASHBOARD_START_FAILED", error });
10118
10161
  process.exitCode = 1;
10119
10162
  });
10120
10163
  export {