@anhlp/alp-cli 0.0.1-beta.4 → 0.0.1-beta.7

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 (66) hide show
  1. package/dist/THIRD-PARTY-NOTICES.txt +26 -1
  2. package/dist/acp/main.js +1 -1
  3. package/dist/acp.js +152 -33
  4. package/dist/alp-web/THIRD-PARTY-NOTICES.txt +666 -0
  5. package/dist/alp-web/alp-boundary.json +1 -0
  6. package/dist/alp-web/assets/TerminalPanel-BeMws9CP.js +22 -0
  7. package/dist/alp-web/assets/highlighter-BnicKQ_d.js +18 -0
  8. package/dist/alp-web/assets/index-Dl7motn1.js +59 -0
  9. package/dist/alp-web/assets/index-DwqDSiIi.css +1 -0
  10. package/dist/alp-web/index.html +2 -2
  11. package/dist/alp-web.js +529 -172
  12. package/dist/alpd.js +10623 -2570
  13. package/dist/backup.js +1 -1
  14. package/dist/build-manifest.json +22 -2
  15. package/dist/cli.js +28 -3
  16. package/dist/daemon.d.ts +1 -1
  17. package/dist/daemon.js +5 -0
  18. package/dist/interfaces.d.ts +13 -1
  19. package/dist/interfaces.js +95 -11
  20. package/dist/paths.d.ts +1 -0
  21. package/dist/paths.js +2 -1
  22. package/dist/roles.d.ts +15 -0
  23. package/dist/roles.js +16 -0
  24. package/dist/self-update.d.ts +149 -0
  25. package/dist/self-update.js +399 -0
  26. package/dist/sessions.d.ts +4 -0
  27. package/dist/sessions.js +22 -1
  28. package/dist/tasks.js +22 -8
  29. package/dist/terminal-native/README.md +201 -0
  30. package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
  31. package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
  32. package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
  33. package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
  34. package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  35. package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  36. package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  37. package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  38. package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  39. package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  40. package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
  41. package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  42. package/dist/terminal-native/terminal-owner.c +389 -0
  43. package/dist/terminal.d.ts +5 -0
  44. package/dist/terminal.js +4 -3
  45. package/dist/usage.d.ts +1 -1
  46. package/dist/usage.js +14 -5
  47. package/dist/web-service.d.ts +22 -4
  48. package/dist/web-service.js +32 -8
  49. package/package.json +6 -5
  50. package/src/cli.js +35 -4
  51. package/src/daemon.js +3 -0
  52. package/src/interfaces.js +101 -12
  53. package/src/paths.js +3 -1
  54. package/src/roles.js +26 -0
  55. package/src/self-update.js +406 -0
  56. package/src/sessions.js +23 -2
  57. package/src/tasks.js +22 -8
  58. package/src/terminal.js +4 -3
  59. package/src/usage.js +14 -5
  60. package/src/web-service.js +56 -13
  61. package/dist/alp-web/assets/TerminalPanel-PrU2l3u5.js +0 -16
  62. package/dist/alp-web/assets/index-BJdBTDFX.css +0 -1
  63. package/dist/alp-web/assets/index-DpfiPv5s.js +0 -52
  64. package/src/web/grant.js +0 -204
  65. package/src/web/main.js +0 -285
  66. package/src/web/serve.js +0 -144
package/dist/alp-web.js CHANGED
@@ -3717,19 +3717,21 @@ var require_websocket_server = __commonJS({
3717
3717
 
3718
3718
  // packages/cli/src/web/main.js
3719
3719
  import { randomBytes as randomBytes5 } from "node:crypto";
3720
- import { mkdirSync, openSync, writeSync } from "node:fs";
3721
- import { chmod as chmod2, link as link2, mkdir as mkdir6, readFile as readFile5, rename as rename4, unlink as unlink6, writeFile as writeFile5 } from "node:fs/promises";
3722
- import path9 from "node:path";
3720
+ import { mkdirSync, openSync, watch, writeSync } from "node:fs";
3721
+ import { chmod as chmod2, link as link2, mkdir as mkdir6, readFile as readFile5, rename as rename4, unlink as unlink6, writeFile as writeFile6 } from "node:fs/promises";
3722
+ import path10 from "node:path";
3723
3723
  import { fileURLToPath } from "node:url";
3724
3724
  import { parseArgs } from "node:util";
3725
3725
 
3726
3726
  // packages/client/src/index.js
3727
- import { spawn } from "node:child_process";
3727
+ import { setTimeout as delay } from "node:timers/promises";
3728
+ import { execFileSync, spawn } from "node:child_process";
3728
3729
  import { createHash, randomUUID } from "node:crypto";
3730
+ import { readFileSync as readFileSync2 } from "node:fs";
3729
3731
  import { open, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, rename, rmdir, link } from "node:fs/promises";
3730
3732
  import net from "node:net";
3731
3733
  import os from "node:os";
3732
- import path from "node:path";
3734
+ import path2 from "node:path";
3733
3735
 
3734
3736
  // packages/core/src/log.js
3735
3737
  var LEVELS = Object.freeze({ debug: 10, info: 20, warn: 30, error: 40 });
@@ -3846,6 +3848,75 @@ function createLogger({ component, level, context = {}, write = stderrSink, now
3846
3848
  }
3847
3849
  var TAIL_BYTES = 256 * 1024;
3848
3850
 
3851
+ // packages/core/src/packaged.js
3852
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
3853
+ import path from "node:path";
3854
+ var ROLE_ARGS = Object.freeze({
3855
+ daemon: Object.freeze(["daemon", "run"]),
3856
+ web: Object.freeze(["web", "serve"]),
3857
+ "bridge-acp": Object.freeze(["bridge", "acp"]),
3858
+ "bridge-antigravity": Object.freeze(["bridge", "antigravity"])
3859
+ });
3860
+ var isExecutableName = (file) => /^alp(\.exe|\.cmd)?$/i.test(file.split(/[\\/]/).pop() ?? "");
3861
+ var isScript = (file) => /\.[cm]?js$/i.test(file);
3862
+ var canonical = (file) => {
3863
+ let resolved = path.resolve(file);
3864
+ try {
3865
+ resolved = realpathSync.native(resolved);
3866
+ } catch {
3867
+ }
3868
+ return process.platform === "darwin" || process.platform === "win32" ? resolved.toLowerCase() : resolved;
3869
+ };
3870
+ var samePath = (a, b) => canonical(a) === canonical(b);
3871
+ function roleArgs(role) {
3872
+ const args = ROLE_ARGS[role];
3873
+ if (!args) throw new TypeError(`Unknown ALP role: ${role}`);
3874
+ return [...args];
3875
+ }
3876
+ var bundles = /* @__PURE__ */ new Map();
3877
+ function bundleInfo(execPath = process.execPath) {
3878
+ if (bundles.has(execPath)) return bundles.get(execPath);
3879
+ let info;
3880
+ try {
3881
+ const real = realpathSync(execPath);
3882
+ 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") {
3885
+ const manifest = JSON.parse(readFileSync(path.join(root, "alp-bundle.json"), "utf8"));
3886
+ if (manifest?.name === "alp" && typeof manifest.version === "string") {
3887
+ const app = path.dirname(root);
3888
+ const current = path.join(app, "current");
3889
+ info = { root, version: manifest.version, platform: String(manifest.platform ?? ""), app, ...existsSync(current) && samePath(current, root) ? { current } : {} };
3890
+ }
3891
+ }
3892
+ } catch {
3893
+ }
3894
+ bundles.set(execPath, info);
3895
+ return info;
3896
+ }
3897
+ function stablePath(file, { bundle = bundleInfo() } = {}) {
3898
+ if (!bundle?.current) return file;
3899
+ let real;
3900
+ try {
3901
+ real = realpathSync(file);
3902
+ } catch {
3903
+ return file;
3904
+ }
3905
+ const relative = path.relative(bundle.root, real);
3906
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return file;
3907
+ return path.join(bundle.current, relative);
3908
+ }
3909
+ function entryCommand(entry, role, args = [], execPath = process.execPath, { scriptOnly = false } = {}) {
3910
+ if (scriptOnly || isScript(entry) || !isExecutableName(entry)) return { command: execPath, args: [entry, ...args] };
3911
+ return { command: entry, args: [...roleArgs(role), ...args] };
3912
+ }
3913
+ function scriptCommand(script, args = []) {
3914
+ return { command: process.execPath, args: [script, ...args] };
3915
+ }
3916
+ function selfEntry(script) {
3917
+ return stablePath(script);
3918
+ }
3919
+
3849
3920
  // packages/protocol/src/wire.js
3850
3921
  var PROTOCOL_VERSION = 1;
3851
3922
  var MAX_FRAME = 16 * 1024 * 1024;
@@ -3858,11 +3929,11 @@ var AlpRpcError = class extends Error {
3858
3929
  };
3859
3930
  var ERROR = Object.freeze({ failed: 1e3, notFound: 1001, forbidden: 1003, conflict: 1004, unavailable: 1005, protocol: 1006 });
3860
3931
  var RPC_ERROR = Object.freeze({ parseError: -32700, invalidRequest: -32600, methodNotFound: -32601, invalidParams: -32602 });
3861
- var CAPABILITY = Object.freeze({ sessionInterruptTurn: "session.interrupt.turn", attachAfter: "attach.after", sessionHistory: "session.history", workspaceRegistry: "workspace.registry", workspaceWorktree: "workspace.worktree", workspaceGit: "workspace.git", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", libraryProjectWrite: "library.project.write", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", sessionAttention: "session.attention", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", promptImages: "prompt.images", schedule: "schedule", attachments: "attachments", sessionFork: "session.fork", sessionRewind: "session.rewind", sessionReload: "session.reload", sessionResumeCommand: "session.resumeCommand", sessionConfigureLive: "session.configure.live", terminal: "terminal" });
3932
+ var CAPABILITY = Object.freeze({ sessionInterruptTurn: "session.interrupt.turn", catalogLive: "catalog.live", attachAfter: "attach.after", sessionHistory: "session.history", workspaceRegistry: "workspace.registry", workspaceWorktree: "workspace.worktree", workspaceGit: "workspace.git", workspaceGitFacts: "workspace.git.facts", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", libraryProjectWrite: "library.project.write", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", sessionAttention: "session.attention", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", workspaceFilesBrowse: "workspace.files.browse", hostDirectories: "host.directories", promptImages: "prompt.images", schedule: "schedule", attachments: "attachments", sessionFork: "session.fork", sessionRewind: "session.rewind", sessionReload: "session.reload", sessionResumeCommand: "session.resumeCommand", sessionCommands: "session.commands", sessionConfigureLive: "session.configure.live", terminal: "terminal", terminalCapture: "terminal.capture", terminalWatch: "terminal.watch" });
3862
3933
  var PROMPT_IMAGES = Object.freeze({ mimeTypes: Object.freeze(["image/png", "image/jpeg", "image/gif", "image/webp"]), maxCount: 8, maxBytes: 5 * 1024 * 1024, maxTotalBytes: 11 * 1024 * 1024 });
3863
3934
  var base64Bytes = (data) => Math.floor(data.length * 3 / 4) - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
3864
- var RPC_METHODS = Object.freeze(["assignment.recall", "attachment.abort", "attachment.begin", "attachment.chunk", "attachment.commit", "attachment.delete", "attachment.get", "board.list", "catalog.get", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "project.list", "project.register", "project.remove", "question.answer", "question.list", "question.watch", "registry.owner", "registry.worktree", "schedule.cancel", "schedule.create", "schedule.get", "schedule.list", "session.archive", "session.attach", "session.attention.clear", "session.close", "session.configure", "session.configure.preview", "session.create", "session.fork", "session.get", "session.history", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.reload", "session.rename", "session.resumeCommand", "session.rewind", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "terminal.attach", "terminal.close", "terminal.create", "terminal.input", "terminal.list", "terminal.resize", "terminal.revoke", "workspace.files.list", "workspace.files.read", "workspace.files.search", "workspace.get", "workspace.git.diff", "workspace.git.status", "workspace.list", "workspace.update", "workspace.worktree.create", "workspace.worktree.options", "workspace.worktree.remove"]);
3865
- var WORKSPACE_FILES = Object.freeze({ maxReadBytes: 1024 * 1024, maxListEntries: 1e3, maxPathLength: 4096 });
3935
+ var RPC_METHODS = Object.freeze(["assignment.recall", "attachment.abort", "attachment.begin", "attachment.chunk", "attachment.commit", "attachment.delete", "attachment.get", "board.list", "catalog.get", "catalog.refresh", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "host.directories.search", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "project.list", "project.register", "project.remove", "question.answer", "question.list", "question.watch", "registry.owner", "registry.worktree", "schedule.cancel", "schedule.create", "schedule.get", "schedule.list", "session.archive", "session.attach", "session.attention.clear", "session.close", "session.commands", "session.compact", "session.configure", "session.configure.preview", "session.create", "session.fork", "session.get", "session.history", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.reload", "session.rename", "session.resumeCommand", "session.rewind", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "terminal.attach", "terminal.close", "terminal.capture", "terminal.create", "terminal.input", "terminal.list", "terminal.watch", "terminal.unwatch", "terminal.resize", "terminal.revoke", "workspace.files.find", "workspace.files.list", "workspace.files.preview", "workspace.files.read", "workspace.files.search", "workspace.get", "workspace.git.diff", "workspace.git.facts", "workspace.git.status", "workspace.list", "workspace.update", "workspace.worktree.create", "workspace.worktree.options", "workspace.worktree.remove"]);
3936
+ var WORKSPACE_FILES = Object.freeze({ maxReadBytes: 1024 * 1024, maxListEntries: 1e3, maxPathLength: 4096, maxPreviewBytes: 50 * 1024 * 1024, maxPreviewChunkBytes: 8 * 1024 * 1024, maxFindEntries: 1e3 });
3866
3937
  var WORKSPACE_GIT = Object.freeze({ maxFileBytes: 1024 * 1024, maxTotalBytes: 2 * 1024 * 1024, maxUntracked: 200, maxStatusFiles: 1e3, maxRefLength: 255 });
3867
3938
  var ATTACHMENTS = Object.freeze({
3868
3939
  maxObjectBytes: 20 * 1024 * 1024,
@@ -4183,9 +4254,9 @@ var AlpRpcClient = class {
4183
4254
  if (this.#closeError) return Promise.reject(new AlpClientError(CLOSED, { reason: this.#closeError.reason === "closed" ? "closed" : "disconnected", cause: this.#closeError }));
4184
4255
  if (signal?.aborted) return Promise.reject(abortError(signal));
4185
4256
  if (this.#pending.size >= this.#maxPending) return Promise.reject(new AlpClientError(`Too many ALP requests waiting for an answer (${this.#maxPending})`, { reason: "overloaded" }));
4186
- let delay;
4257
+ let delay2;
4187
4258
  try {
4188
- delay = timerDelay(timeoutMs);
4259
+ delay2 = timerDelay(timeoutMs);
4189
4260
  } catch (error) {
4190
4261
  return Promise.reject(error);
4191
4262
  }
@@ -4213,12 +4284,12 @@ var AlpRpcClient = class {
4213
4284
  signal?.removeEventListener("abort", onAbort);
4214
4285
  };
4215
4286
  this.#pending.set(id, { resolve: resolve2, reject, cleanup });
4216
- if (delay !== void 0) {
4287
+ if (delay2 !== void 0) {
4217
4288
  timer = setTimeout(() => {
4218
4289
  if (!this.#pending.delete(id)) return;
4219
4290
  cleanup();
4220
4291
  reject(new AlpClientError(`ALP request ${method} timed out after ${timeoutMs} ms`, { reason: "timeout" }));
4221
- }, delay);
4292
+ }, delay2);
4222
4293
  }
4223
4294
  signal?.addEventListener("abort", onAbort, { once: true });
4224
4295
  try {
@@ -4393,8 +4464,9 @@ var AlpRpcClient = class {
4393
4464
  };
4394
4465
 
4395
4466
  // packages/client/src/rpc/handshake.js
4396
- function hello(client, info = { name: "alp", version: "0" }, options) {
4397
- return client.request("daemon.hello", { protocolVersion: PROTOCOL_VERSION, client: info }, options);
4467
+ var AGENT_CAPABILITY = "principal.agent";
4468
+ function hello(client, info = { name: "alp", version: "0" }, options, { agent = false } = {}) {
4469
+ return client.request("daemon.hello", { protocolVersion: PROTOCOL_VERSION, client: info, ...agent ? { capabilities: [AGENT_CAPABILITY] } : {} }, options);
4398
4470
  }
4399
4471
 
4400
4472
  // packages/client/src/rpc/reconnect.js
@@ -4622,27 +4694,27 @@ var CLOSE_CODE = Object.freeze({ unsupportedData: 4003, tooLarge: 4009 });
4622
4694
 
4623
4695
  // packages/client/src/index.js
4624
4696
  function alpHome(env = process.env) {
4625
- return path.resolve(env.ALP_HOME || path.join(os.homedir(), ".alp"));
4697
+ return path2.resolve(env.ALP_HOME || path2.join(os.homedir(), ".alp"));
4626
4698
  }
4627
4699
  function daemonPaths(home) {
4628
- const preferred = path.join(home, "alpd.sock");
4629
- 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");
4630
- return { home, lock: path.join(home, "alpd.lock"), socket, log: path.join(home, "logs", "alpd.log"), install: path.join(home, "alpd.json") };
4700
+ const preferred = path2.join(home, "alpd.sock");
4701
+ 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");
4702
+ return { home, lock: path2.join(home, "alpd.lock"), socket, log: path2.join(home, "logs", "alpd.log"), install: path2.join(home, "alpd.json") };
4631
4703
  }
4632
4704
  async function assertSafeAncestors(directory) {
4633
4705
  if (process.platform === "win32") return;
4634
- const absolute = path.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
4635
- let current = path.parse(absolute).root;
4706
+ const absolute = path2.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
4707
+ let current = path2.parse(absolute).root;
4636
4708
  const pending = absolute.slice(current.length).split("/");
4637
4709
  let links = 0;
4638
4710
  while (pending.length) {
4639
4711
  const part = pending.shift();
4640
4712
  if (!part || part === ".") continue;
4641
4713
  if (part === "..") {
4642
- current = path.dirname(current);
4714
+ current = path2.dirname(current);
4643
4715
  continue;
4644
4716
  }
4645
- const candidate = path.join(current, part);
4717
+ const candidate = path2.join(current, part);
4646
4718
  const info = await lstat(candidate).catch((error) => {
4647
4719
  if (error.code !== "ENOENT") throw error;
4648
4720
  });
@@ -4655,8 +4727,8 @@ async function assertSafeAncestors(directory) {
4655
4727
  if (info.isSymbolicLink()) {
4656
4728
  if (++links > 40) throw new Error("IPC ancestor symlink loop");
4657
4729
  const target = await readlink(candidate);
4658
- if (path.isAbsolute(target)) current = path.parse(target).root;
4659
- pending.unshift(...target.slice(path.isAbsolute(target) ? path.parse(target).root.length : 0).split("/"));
4730
+ if (path2.isAbsolute(target)) current = path2.parse(target).root;
4731
+ pending.unshift(...target.slice(path2.isAbsolute(target) ? path2.parse(target).root.length : 0).split("/"));
4660
4732
  continue;
4661
4733
  }
4662
4734
  if (!info.isDirectory() || info.mode & 18 && !(info.mode & 512)) {
@@ -4676,7 +4748,7 @@ async function assertPrivateDirectory(directory, { create = false } = {}) {
4676
4748
  }
4677
4749
  async function assertPrivateSocket(socketPath) {
4678
4750
  if (process.platform === "win32") return;
4679
- await assertPrivateDirectory(path.dirname(socketPath));
4751
+ await assertPrivateDirectory(path2.dirname(socketPath));
4680
4752
  const info = await lstat(socketPath);
4681
4753
  if (!info.isSocket() || info.uid !== process.getuid?.() || (info.mode & 63) !== 0) {
4682
4754
  throw new Error("IPC socket must be owned by the current user with private permissions (0600)");
@@ -4684,8 +4756,27 @@ async function assertPrivateSocket(socketPath) {
4684
4756
  return info;
4685
4757
  }
4686
4758
  var isFile = (file) => stat(file).then((info) => info.isFile(), () => false);
4687
- var BIN_DIRECTORIES = [path.join(os.homedir(), ".npm-global", "bin"), path.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
4759
+ 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"];
4688
4760
  var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
4761
+ async function cliDaemonEntry(cli) {
4762
+ const base = path2.basename(cli).toLowerCase();
4763
+ const root = path2.resolve(path2.dirname(cli), "..");
4764
+ const alpd = (directory) => path2.join(directory, "dist", "alpd.js");
4765
+ const named = async (directory) => readFile(path2.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
4766
+ let candidates = [];
4767
+ if (base === "alp" || base === "alp.cmd") {
4768
+ if (!await isFile(path2.join(root, "alp-bundle.json"))) return void 0;
4769
+ const current = path2.join(path2.dirname(root), "current");
4770
+ const viaCurrent = await realpath(current).then((real) => real === root, () => false);
4771
+ candidates = [alpd(path2.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
4772
+ } else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
4773
+ candidates = [alpd(root)];
4774
+ } else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
4775
+ candidates = [alpd(path2.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path2.join(root, "..", "alp-cli"))];
4776
+ }
4777
+ for (const candidate of candidates) if (await isFile(candidate)) return candidate;
4778
+ return void 0;
4779
+ }
4689
4780
  async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = (
4690
4781
  /** @type {Array<string | undefined>} */
4691
4782
  []
@@ -4696,13 +4787,12 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
4696
4787
  if (typeof entry === "string" && await isFile(entry)) return entry;
4697
4788
  } catch {
4698
4789
  }
4699
- for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...BIN_DIRECTORIES]) {
4700
- const cli = await realpath(path.join(directory, "alp")).catch(() => void 0);
4701
- if (!cli || path.basename(cli) !== "cli.js") continue;
4702
- const root = path.resolve(path.dirname(cli), "..");
4703
- const name2 = await readFile(path.join(root, "package.json"), "utf8").then((text) => JSON.parse(text).name, () => void 0);
4704
- const entry = path.join(root, "dist", "alpd.js");
4705
- if (CLI_PACKAGES.includes(name2) && await isFile(entry)) return entry;
4790
+ for (const directory of [...(env.PATH ?? "").split(path2.delimiter).filter(Boolean), ...BIN_DIRECTORIES]) {
4791
+ for (const name2 of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
4792
+ const cli = await realpath(path2.join(directory, name2)).catch(() => void 0);
4793
+ const entry = cli && await cliDaemonEntry(cli);
4794
+ if (entry) return entry;
4795
+ }
4706
4796
  }
4707
4797
  return void 0;
4708
4798
  }
@@ -4710,9 +4800,45 @@ function assertIntegrationName(name2) {
4710
4800
  if (typeof name2 !== "string" || !/^[a-z0-9][a-z0-9-]*$/.test(name2)) throw new TypeError(`Invalid integration name: ${JSON.stringify(name2)}`);
4711
4801
  return name2;
4712
4802
  }
4803
+ var cachedBootId = null;
4804
+ function bootId() {
4805
+ if (cachedBootId !== null) return cachedBootId;
4806
+ try {
4807
+ if (process.platform === "linux") {
4808
+ const id = readFileSync2("/proc/sys/kernel/random/boot_id", "utf8").trim();
4809
+ if (id.length > 0) {
4810
+ cachedBootId = id;
4811
+ return cachedBootId;
4812
+ }
4813
+ } else if (process.platform === "darwin") {
4814
+ const id = execFileSync("sysctl", ["-n", "kern.bootsessionuuid"], {
4815
+ encoding: "utf8",
4816
+ stdio: ["ignore", "pipe", "ignore"],
4817
+ timeout: 2e3
4818
+ }).trim();
4819
+ if (id.length > 0) {
4820
+ cachedBootId = id;
4821
+ return cachedBootId;
4822
+ }
4823
+ }
4824
+ } catch {
4825
+ }
4826
+ cachedBootId = void 0;
4827
+ return cachedBootId;
4828
+ }
4713
4829
  function bootTime() {
4714
4830
  return Math.round((Date.now() - os.uptime() * 1e3) / 1e3);
4715
4831
  }
4832
+ function isSameBoot(lock, { bootId: curBootId = bootId(), bootTime: curBootTime = bootTime() } = {}) {
4833
+ if (!lock) return false;
4834
+ if (typeof lock.bootId === "string" && lock.bootId.length > 0 && typeof curBootId === "string" && curBootId.length > 0) {
4835
+ return lock.bootId === curBootId;
4836
+ }
4837
+ if (typeof lock.bootTime === "number" && Number.isFinite(lock.bootTime) && Number.isFinite(curBootTime)) {
4838
+ return Math.abs(lock.bootTime - curBootTime) <= 30;
4839
+ }
4840
+ return false;
4841
+ }
4716
4842
  async function readLock(home) {
4717
4843
  try {
4718
4844
  return JSON.parse(await readFile(daemonPaths(home).lock, "utf8"));
@@ -4722,7 +4848,7 @@ async function readLock(home) {
4722
4848
  }
4723
4849
  }
4724
4850
  function lockAlive(lock) {
4725
- if (!lock || !Number.isSafeInteger(lock.pid) || Math.abs((lock.bootTime ?? 0) - bootTime()) > 30) return false;
4851
+ if (!lock || !Number.isSafeInteger(lock.pid) || !isSameBoot(lock)) return false;
4726
4852
  try {
4727
4853
  process.kill(lock.pid, 0);
4728
4854
  return true;
@@ -4733,6 +4859,12 @@ function lockAlive(lock) {
4733
4859
  var AlpClient = class extends AlpRpcClient {
4734
4860
  /** Host features captured by connect's handshake. @type {readonly string[]} */
4735
4861
  capabilities = [];
4862
+ /** Limits captured by connect's handshake. @type {import('@anhlp/alp-protocol').AttachmentLimits | undefined} */
4863
+ attachmentLimits;
4864
+ /** @type {{ readonly maxCount: number; readonly maxBytes: number; readonly maxTotalBytes: number } | undefined} */
4865
+ promptImageLimits;
4866
+ /** @type {import('@anhlp/alp-protocol').TerminalLimits | undefined} */
4867
+ terminalLimits;
4736
4868
  /**
4737
4869
  * @param {import('node:net').Socket} socket a connected or connecting socket; the client owns it
4738
4870
  * @param {import('./rpc/client.js').AlpRpcClientOptions & import('./ipc.js').SocketTransportOptions} [options]
@@ -4761,8 +4893,17 @@ async function connectSocket(socketPath, options) {
4761
4893
  async function connect(socketPath, client = { name: "alp", version: "0" }, options = {}) {
4762
4894
  const connection = new AlpClient(await openSocket(socketPath), options);
4763
4895
  try {
4764
- const greeting = await hello(connection, client);
4896
+ const greeting = await hello(connection, client, void 0, { agent: typeof process.env.ALP_AGENT_SESSION === "string" && process.env.ALP_AGENT_SESSION !== "" });
4765
4897
  connection.capabilities = Object.freeze(Array.isArray(greeting.capabilities) ? greeting.capabilities.filter((value) => typeof value === "string") : []);
4898
+ if (greeting.attachmentLimits && typeof greeting.attachmentLimits === "object") {
4899
+ connection.attachmentLimits = Object.freeze({ ...greeting.attachmentLimits });
4900
+ }
4901
+ if (greeting.promptImageLimits && typeof greeting.promptImageLimits === "object") {
4902
+ connection.promptImageLimits = Object.freeze({ ...greeting.promptImageLimits });
4903
+ }
4904
+ if (greeting.terminalLimits && typeof greeting.terminalLimits === "object") {
4905
+ connection.terminalLimits = Object.freeze({ ...greeting.terminalLimits });
4906
+ }
4766
4907
  } catch (error) {
4767
4908
  connection.close();
4768
4909
  throw error;
@@ -4788,7 +4929,7 @@ async function tail(file, lines = 30) {
4788
4929
  }
4789
4930
  }
4790
4931
  async function lifecycleOwners(home) {
4791
- const directory = path.join(home, "state", "alpd.starting");
4932
+ const directory = path2.join(home, "state", "alpd.starting");
4792
4933
  const names2 = await readdir(directory).catch((error) => {
4793
4934
  if (error.code === "ENOENT") return [];
4794
4935
  throw error;
@@ -4802,26 +4943,37 @@ async function lifecycleOwners(home) {
4802
4943
  async function readDaemonLifecycle(home) {
4803
4944
  return (await lifecycleOwners(home)).find((owner) => lockAlive(owner));
4804
4945
  }
4805
- async function withDaemonLifecycle(home, action, run2, { joinStart = false } = {}) {
4946
+ async function withDaemonLifecycle(home, action, run2, { joinStart = false, signal = (
4947
+ /** @type {AbortSignal | undefined} */
4948
+ void 0
4949
+ ) } = {}) {
4950
+ signal?.throwIfAborted();
4806
4951
  try {
4807
4952
  await assertPrivateDirectory(home, { create: true });
4808
4953
  } catch (cause) {
4809
4954
  throw Object.assign(new Error(`ALP_HOME_UNUSABLE, alpd failed to start while preparing its home: ${cause.message}`, { cause }), { code: "ALP_HOME_UNUSABLE" });
4810
4955
  }
4811
- const state = path.join(home, "state");
4956
+ const state = path2.join(home, "state");
4812
4957
  await assertPrivateDirectory(state, { create: true });
4813
- const directory = path.join(state, "alpd.starting");
4958
+ const directory = path2.join(state, "alpd.starting");
4959
+ const currentBootId = bootId();
4814
4960
  const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
4815
- const candidate = path.join(state, `alpd.starting-${token}`);
4961
+ const candidate = path2.join(state, `alpd.starting-${token}`);
4816
4962
  await mkdir(candidate, { mode: 448 });
4817
- await writeFile(path.join(candidate, token), JSON.stringify({ pid: process.pid, bootTime: bootTime(), action }), { mode: 384 });
4963
+ await writeFile(path2.join(candidate, token), JSON.stringify({
4964
+ pid: process.pid,
4965
+ bootTime: bootTime(),
4966
+ ...currentBootId ? { bootId: currentBootId } : {},
4967
+ startedUptime: Math.floor(os.uptime()),
4968
+ action
4969
+ }), { mode: 384 });
4818
4970
  try {
4819
4971
  let joined = false;
4820
4972
  if (joinStart) {
4821
4973
  const owner = await readDaemonLifecycle(home);
4822
4974
  if (owner?.action === "start") {
4823
4975
  try {
4824
- await link(path.join(directory, owner.token), path.join(directory, token));
4976
+ await link(path2.join(directory, owner.token), path2.join(directory, token));
4825
4977
  joined = true;
4826
4978
  } catch (error) {
4827
4979
  if (error.code !== "ENOENT") throw error;
@@ -4829,32 +4981,34 @@ async function withDaemonLifecycle(home, action, run2, { joinStart = false } = {
4829
4981
  }
4830
4982
  }
4831
4983
  while (!joined) {
4984
+ signal?.throwIfAborted();
4832
4985
  try {
4833
4986
  await rename(candidate, directory);
4834
4987
  break;
4835
4988
  } catch (error) {
4836
4989
  if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error.code)) throw error;
4837
4990
  for (const owner of await lifecycleOwners(home)) {
4838
- if (!lockAlive(owner)) await unlink(path.join(directory, owner.token)).catch((error2) => {
4991
+ if (!lockAlive(owner)) await unlink(path2.join(directory, owner.token)).catch((error2) => {
4839
4992
  if (error2.code !== "ENOENT") throw error2;
4840
4993
  });
4841
4994
  }
4842
4995
  await rmdir(directory).catch((error2) => {
4843
4996
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error2.code)) throw error2;
4844
4997
  });
4845
- await new Promise((resolve2) => setTimeout(resolve2, 25));
4998
+ await delay(25, void 0, { signal });
4846
4999
  }
4847
5000
  }
4848
5001
  try {
5002
+ signal?.throwIfAborted();
4849
5003
  return await run2();
4850
5004
  } finally {
4851
- await unlink(path.join(directory, token));
5005
+ await unlink(path2.join(directory, token));
4852
5006
  await rmdir(directory).catch((error) => {
4853
5007
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error.code)) throw error;
4854
5008
  });
4855
5009
  }
4856
5010
  } finally {
4857
- await unlink(path.join(candidate, token)).catch((error) => {
5011
+ await unlink(path2.join(candidate, token)).catch((error) => {
4858
5012
  if (error.code !== "ENOENT") throw error;
4859
5013
  });
4860
5014
  await rmdir(candidate).catch((error) => {
@@ -4865,8 +5019,12 @@ async function withDaemonLifecycle(home, action, run2, { joinStart = false } = {
4865
5019
  async function ensureDaemon({ home = alpHome(), entry = (
4866
5020
  /** @type {string | undefined} */
4867
5021
  void 0
4868
- ), env = process.env, execPath = process.execPath, timeoutMs = 15e3, lifecycleLocked = false } = {}) {
4869
- if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleLocked: true }));
5022
+ ), env = process.env, execPath = process.execPath, timeoutMs = 15e3, lifecycleLocked = false, signal = (
5023
+ /** @type {AbortSignal | undefined} */
5024
+ void 0
5025
+ ) } = {}) {
5026
+ signal?.throwIfAborted();
5027
+ if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleLocked: true, signal }), { signal });
4870
5028
  const ready = async () => {
4871
5029
  const lock = await readLock(home);
4872
5030
  return lockAlive(lock) && lock.ready ? lock.socket : void 0;
@@ -4878,8 +5036,10 @@ async function ensureDaemon({ home = alpHome(), entry = (
4878
5036
  if (!lockAlive(held)) {
4879
5037
  entry ??= await findDaemonEntry({ home, env });
4880
5038
  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");
5039
+ signal?.throwIfAborted();
4881
5040
  await new Promise((resolve2, reject) => {
4882
- const launcher = spawn(execPath, [entry, "--detach", `--startup-timeout=${timeoutMs}`], {
5041
+ const launch = entryCommand(entry, "daemon", ["--detach", `--startup-timeout=${timeoutMs}`], execPath);
5042
+ const launcher = spawn(launch.command, launch.args, {
4883
5043
  env: { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" },
4884
5044
  stdio: ["ignore", "ignore", "pipe"],
4885
5045
  windowsHide: true
@@ -4894,6 +5054,7 @@ async function ensureDaemon({ home = alpHome(), entry = (
4894
5054
  }
4895
5055
  const deadline = Date.now() + timeoutMs;
4896
5056
  while (Date.now() < deadline) {
5057
+ signal?.throwIfAborted();
4897
5058
  const socket = await ready();
4898
5059
  if (socket) return socket;
4899
5060
  await new Promise((resolve2) => setTimeout(resolve2, 100));
@@ -4905,16 +5066,33 @@ ${log}` : ""}`);
4905
5066
 
4906
5067
  // packages/client/src/integration-lock.js
4907
5068
  import { randomUUID as randomUUID2 } from "node:crypto";
4908
- import { mkdir as mkdir2, open as open2, rename as rename2, rmdir as rmdir2, unlink as unlink2 } from "node:fs/promises";
4909
- import path2 from "node:path";
5069
+ import { mkdir as mkdir2, open as open2, rmdir as rmdir2, unlink as unlink2 } from "node:fs/promises";
5070
+ import os2 from "node:os";
5071
+ import path3 from "node:path";
5072
+
5073
+ // packages/core/src/atomic.js
5074
+ import { rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
5075
+ async function moveFile(from, to) {
5076
+ for (let attempt = 0; ; attempt++) {
5077
+ try {
5078
+ return await rename2(from, to);
5079
+ } catch (error) {
5080
+ if (process.platform !== "win32" || attempt >= 20 || !["EPERM", "EACCES", "EBUSY"].includes(error?.code)) throw error;
5081
+ await new Promise((resolve2) => setTimeout(resolve2, 10 + attempt * 10));
5082
+ }
5083
+ }
5084
+ }
5085
+
5086
+ // packages/client/src/integration-lock.js
4910
5087
  function createIntegrationLock(home, name2) {
4911
- const file = path2.join(home, "integrations", `${assertIntegrationName(name2)}.lock`);
5088
+ const file = path3.join(home, "integrations", `${assertIntegrationName(name2)}.lock`);
4912
5089
  const guard = `${file}.reclaim`;
4913
5090
  let phase = "new";
4914
5091
  let owned;
5092
+ let readyQueue = Promise.resolve();
4915
5093
  const recovery = (reason) => new Error(`${reason}. Stop ALL integration processes using this ALP_HOME before manual lock-only recovery of ${file} and ${guard}; see docs/modular-monorepo.md`);
4916
5094
  async function guarded(run2) {
4917
- await mkdir2(path2.dirname(file), { recursive: true, mode: 448 });
5095
+ await mkdir2(path3.dirname(file), { recursive: true, mode: 448 });
4918
5096
  const deadline = Date.now() + 2e4;
4919
5097
  for (; ; ) {
4920
5098
  try {
@@ -4929,7 +5107,7 @@ function createIntegrationLock(home, name2) {
4929
5107
  await new Promise((resolve2) => setTimeout(resolve2, 25));
4930
5108
  }
4931
5109
  }
4932
- const token = path2.join(guard, `owner-${process.pid}-${randomUUID2()}`);
5110
+ const token = path3.join(guard, `owner-${process.pid}-${randomUUID2()}`);
4933
5111
  try {
4934
5112
  const handle = await open2(token, "wx", 384);
4935
5113
  await handle.close();
@@ -4980,7 +5158,7 @@ function createIntegrationLock(home, name2) {
4980
5158
  }
4981
5159
  }
4982
5160
  function complete(value) {
4983
- return value && Number.isSafeInteger(value.pid) && value.pid > 0 && typeof value.bootTime === "number" && Number.isFinite(value.bootTime) && value.bootTime > 0 && typeof value.startedAt === "string" && Number.isFinite(Date.parse(value.startedAt)) && typeof value.ready === "boolean" && (value.lockVersion === void 0 && value.owner === void 0 || value.lockVersion === 1 && typeof value.owner === "string" && /^[a-f0-9-]{36}$/.test(value.owner));
5161
+ return value && Number.isSafeInteger(value.pid) && value.pid > 0 && typeof value.bootTime === "number" && Number.isFinite(value.bootTime) && value.bootTime > 0 && (value.bootId === void 0 || typeof value.bootId === "string" && value.bootId.length > 0) && (value.startedUptime === void 0 || typeof value.startedUptime === "number" && Number.isFinite(value.startedUptime)) && typeof value.startedAt === "string" && Number.isFinite(Date.parse(value.startedAt)) && typeof value.ready === "boolean" && (value.lockVersion === void 0 && value.owner === void 0 || value.lockVersion === 1 && typeof value.owner === "string" && /^[a-f0-9-]{36}$/.test(value.owner));
4984
5162
  }
4985
5163
  function dead(value) {
4986
5164
  try {
@@ -4991,7 +5169,7 @@ function createIntegrationLock(home, name2) {
4991
5169
  /** @type {any} */
4992
5170
  error?.code !== "ESRCH"
4993
5171
  ) return false;
4994
- if (Math.abs(value.bootTime - bootTime()) > 30) throw recovery("Integration owner boot context is uncertain");
5172
+ if (!isSameBoot(value)) throw recovery("Integration owner boot context is uncertain");
4995
5173
  return true;
4996
5174
  }
4997
5175
  }
@@ -5013,7 +5191,17 @@ function createIntegrationLock(home, name2) {
5013
5191
  }
5014
5192
  await unlink2(file);
5015
5193
  }
5016
- const value = { pid: process.pid, bootTime: bootTime(), startedAt: (/* @__PURE__ */ new Date()).toISOString(), ready: false, lockVersion: 1, owner: randomUUID2() };
5194
+ const currentBootId = bootId();
5195
+ const value = {
5196
+ pid: process.pid,
5197
+ bootTime: bootTime(),
5198
+ ...currentBootId ? { bootId: currentBootId } : {},
5199
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
5200
+ startedUptime: Math.floor(os2.uptime()),
5201
+ ready: false,
5202
+ lockVersion: 1,
5203
+ owner: randomUUID2()
5204
+ };
5017
5205
  const handle = await open2(file, "wx", 384);
5018
5206
  let info;
5019
5207
  try {
@@ -5034,34 +5222,41 @@ function createIntegrationLock(home, name2) {
5034
5222
  },
5035
5223
  async setReady(ready) {
5036
5224
  if (phase !== "owned") return false;
5037
- return guarded(async () => {
5225
+ const execute = async () => {
5038
5226
  if (phase !== "owned") return false;
5039
- const current = await snapshot();
5040
- if (!current || !matches(current)) {
5041
- phase = "retired";
5042
- owned = void 0;
5043
- return false;
5044
- }
5045
- const value = { ...current.value, ready };
5046
- const tmp = `${file}.${randomUUID2()}.tmp`;
5047
- const handle = await open2(tmp, "wx", 384);
5048
- let info;
5049
- try {
5227
+ return guarded(async () => {
5228
+ if (phase !== "owned") return false;
5229
+ const current = await snapshot();
5230
+ if (!current || !matches(current)) {
5231
+ phase = "retired";
5232
+ owned = void 0;
5233
+ return false;
5234
+ }
5235
+ const value = { ...current.value, ready };
5236
+ const tmp = `${file}.${randomUUID2()}.tmp`;
5237
+ const handle = await open2(tmp, "wx", 384);
5238
+ let info;
5050
5239
  try {
5051
- await handle.writeFile(JSON.stringify(value));
5052
- info = await handle.stat();
5240
+ try {
5241
+ await handle.writeFile(JSON.stringify(value));
5242
+ info = await handle.stat();
5243
+ } finally {
5244
+ await handle.close();
5245
+ }
5246
+ await moveFile(tmp, file);
5247
+ owned = { owner: value.owner, dev: info.dev, ino: info.ino };
5248
+ return true;
5053
5249
  } finally {
5054
- await handle.close();
5250
+ await unlink2(tmp).catch((error) => {
5251
+ if (error?.code !== "ENOENT") throw error;
5252
+ });
5055
5253
  }
5056
- await rename2(tmp, file);
5057
- owned = { owner: value.owner, dev: info.dev, ino: info.ino };
5058
- return true;
5059
- } finally {
5060
- await unlink2(tmp).catch((error) => {
5061
- if (error?.code !== "ENOENT") throw error;
5062
- });
5063
- }
5254
+ });
5255
+ };
5256
+ const chained = readyQueue.then(execute, execute);
5257
+ readyQueue = chained.catch(() => {
5064
5258
  });
5259
+ return chained;
5065
5260
  },
5066
5261
  async release() {
5067
5262
  if (phase !== "owned") return false;
@@ -5080,14 +5275,14 @@ function createIntegrationLock(home, name2) {
5080
5275
  }
5081
5276
 
5082
5277
  // packages/client/src/supervise.js
5083
- import { mkdir as mkdir4, unlink as unlink4, writeFile as writeFile3, stat as stat2 } from "node:fs/promises";
5084
- import path4 from "node:path";
5278
+ import { mkdir as mkdir4, unlink as unlink4, writeFile as writeFile4, stat as stat2 } from "node:fs/promises";
5279
+ import path5 from "node:path";
5085
5280
 
5086
5281
  // packages/client/src/service.js
5087
5282
  import { createHash as createHash2 } from "node:crypto";
5088
- import { mkdir as mkdir3, readFile as readFile2, unlink as unlink3, writeFile as writeFile2 } from "node:fs/promises";
5089
- import os2 from "node:os";
5090
- import path3 from "node:path";
5283
+ import { mkdir as mkdir3, readFile as readFile2, unlink as unlink3, writeFile as writeFile3 } from "node:fs/promises";
5284
+ import os3 from "node:os";
5285
+ import path4 from "node:path";
5091
5286
 
5092
5287
  // packages/client/src/command.js
5093
5288
  import { spawn as spawn2 } from "node:child_process";
@@ -5095,8 +5290,9 @@ function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 }
5095
5290
  return new Promise((resolve2) => {
5096
5291
  let child;
5097
5292
  const script = process.platform === "win32" && /\.[cm]?js$/i.test(command);
5293
+ const run2 = script ? scriptCommand(command, args) : { command, args };
5098
5294
  try {
5099
- child = spawn2(script ? process.execPath : command, script ? [command, ...args] : args, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
5295
+ child = spawn2(run2.command, run2.args, { cwd, env: run2.env ? { ...env, ...run2.env } : env, stdio: ["ignore", "pipe", "pipe"] });
5100
5296
  } catch (error) {
5101
5297
  resolve2({ code: -1, stdout: "", stderr: error.message });
5102
5298
  return;
@@ -5122,14 +5318,14 @@ function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 }
5122
5318
 
5123
5319
  // packages/client/src/service.js
5124
5320
  function serviceFor({ home, env = process.env, platform = process.platform, uid = process.getuid?.() ?? 0 }) {
5125
- const custom = path3.resolve(home) !== path3.join(os2.homedir(), ".alp");
5126
- const suffix = custom ? createHash2("sha256").update(path3.resolve(home)).digest("hex").slice(0, 8) : "";
5321
+ const custom = path4.resolve(home) !== path4.join(os3.homedir(), ".alp");
5322
+ const suffix = custom ? createHash2("sha256").update(path4.resolve(home)).digest("hex").slice(0, 8) : "";
5127
5323
  if (platform === "darwin") {
5128
5324
  const label = `com.alp.alpd${suffix ? `.${suffix}` : ""}`;
5129
- const directory = env.ALP_SERVICE_DIR || path3.join(os2.homedir(), "Library", "LaunchAgents");
5325
+ const directory = env.ALP_SERVICE_DIR || path4.join(os3.homedir(), "Library", "LaunchAgents");
5130
5326
  const launchctl = env.ALP_LAUNCHCTL || "launchctl";
5131
5327
  const target = `gui/${uid}/${label}`;
5132
- const file = path3.join(directory, `${label}.plist`);
5328
+ const file = path4.join(directory, `${label}.plist`);
5133
5329
  return {
5134
5330
  kind: "launchd",
5135
5331
  name: label,
@@ -5141,12 +5337,12 @@ function serviceFor({ home, env = process.env, platform = process.platform, uid
5141
5337
  }
5142
5338
  if (platform === "linux") {
5143
5339
  const name2 = `alpd${suffix ? `-${suffix}` : ""}`;
5144
- const directory = env.ALP_SERVICE_DIR || path3.join(env.XDG_CONFIG_HOME || path3.join(os2.homedir(), ".config"), "systemd", "user");
5340
+ const directory = env.ALP_SERVICE_DIR || path4.join(env.XDG_CONFIG_HOME || path4.join(os3.homedir(), ".config"), "systemd", "user");
5145
5341
  const systemctl = env.ALP_SYSTEMCTL || "systemctl";
5146
5342
  return {
5147
5343
  kind: "systemd",
5148
5344
  name: name2,
5149
- file: path3.join(directory, `${name2}.service`),
5345
+ file: path4.join(directory, `${name2}.service`),
5150
5346
  install: [[systemctl, ["--user", "daemon-reload"]], [systemctl, ["--user", "enable", "--now", `${name2}.service`]]],
5151
5347
  start: [[systemctl, ["--user", "start", `${name2}.service`]]],
5152
5348
  uninstall: [[systemctl, ["--user", "disable", "--now", `${name2}.service`], { ignore: true }]],
@@ -5177,7 +5373,7 @@ async function startService(service, run2 = runCommand) {
5177
5373
  }
5178
5374
 
5179
5375
  // packages/client/src/supervise.js
5180
- var holdFile = (home) => path4.join(home, "state", "alpd.held");
5376
+ var holdFile = (home) => path5.join(home, "state", "alpd.held");
5181
5377
  async function releaseHold(home) {
5182
5378
  await unlink4(holdFile(home)).catch(() => {
5183
5379
  });
@@ -5185,29 +5381,33 @@ async function releaseHold(home) {
5185
5381
  async function daemonHeld(home) {
5186
5382
  return stat2(holdFile(home)).then(() => true, () => false);
5187
5383
  }
5188
- async function whenReady(home, timeoutMs) {
5384
+ async function whenReady(home, timeoutMs, signal) {
5189
5385
  const deadline = Date.now() + timeoutMs;
5190
5386
  while (Date.now() < deadline) {
5387
+ signal?.throwIfAborted();
5191
5388
  const lock = await readLock(home);
5192
5389
  if (lockAlive(lock) && lock.ready) return lock.socket;
5193
5390
  await new Promise((resolve2) => setTimeout(resolve2, 100));
5194
5391
  }
5195
- throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path4.join(home, "logs")}`);
5392
+ throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path5.join(home, "logs")}`);
5196
5393
  }
5197
- async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3, automatic = false }) {
5394
+ async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3, automatic = false, signal }) {
5198
5395
  return withDaemonLifecycle(home, "start", async () => {
5396
+ signal?.throwIfAborted();
5199
5397
  if (automatic) {
5200
5398
  if (await daemonHeld(home)) return;
5201
5399
  } else await releaseHold(home);
5202
5400
  const lock = await readLock(home);
5203
- if (lockAlive(lock)) return lock.ready ? lock.socket : whenReady(home, timeoutMs);
5401
+ signal?.throwIfAborted();
5402
+ if (lockAlive(lock)) return lock.ready ? lock.socket : whenReady(home, timeoutMs, signal);
5204
5403
  const service = serviceFor({ home, env });
5205
5404
  if (service && await installedProgram(service)) {
5405
+ signal?.throwIfAborted();
5206
5406
  await startService(service);
5207
- return whenReady(home, timeoutMs);
5407
+ return whenReady(home, timeoutMs, signal);
5208
5408
  }
5209
- return ensureDaemon({ home, entry, env, timeoutMs, lifecycleLocked: true });
5210
- });
5409
+ return ensureDaemon({ home, entry, env, timeoutMs, lifecycleLocked: true, signal });
5410
+ }, { signal });
5211
5411
  }
5212
5412
  function superviseDaemon({ home, entry, env = process.env, intervalMs = 5e3, misses = 2, log = () => {
5213
5413
  }, by }) {
@@ -5363,7 +5563,7 @@ var nonempty = (value) => typeof value === "string" && value.trim().length > 0;
5363
5563
  function requireValue(condition, code, source, message) {
5364
5564
  if (!condition) throw new AlpError(code, `${source}: ${message}`);
5365
5565
  }
5366
- var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "web"];
5566
+ var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "web", "curate"];
5367
5567
  var RETIRED_SETTINGS = { project: {}, user: {} };
5368
5568
  function distance(a, b) {
5369
5569
  const row = Array.from({ length: b.length + 1 }, (_, index) => index);
@@ -5393,11 +5593,18 @@ function settingsKeys(settings, known, retired = {}) {
5393
5593
  return { unknown, retired: old };
5394
5594
  }
5395
5595
  var unknownMessage = (unknown, known) => `unknown setting '${unknown.key}'${unknown.suggestion ? `; did you mean '${unknown.suggestion}'?` : `; known settings are ${known.filter((key2) => !key2.startsWith("$")).join(", ")}`}`;
5596
+ function checkCurate(settings, check2) {
5597
+ if (settings.curate === void 0) return;
5598
+ check2(object2(settings.curate), "curate must be an object");
5599
+ check2(Object.keys(settings.curate).every((key2) => key2 === "monthly"), "unsupported curate field; use monthly");
5600
+ if (settings.curate.monthly !== void 0) check2(typeof settings.curate.monthly === "boolean", "curate.monthly must be true or false");
5601
+ }
5396
5602
  function validateUserSettings(settings, source) {
5397
5603
  const check2 = (ok, message) => requireValue(ok, "INVALID_SETTINGS", source, message);
5398
5604
  check2(object2(settings), "expected an object");
5399
5605
  const { unknown } = settingsKeys(settings, USER_SETTINGS, RETIRED_SETTINGS.user);
5400
5606
  check2(!unknown.length, unknown.length ? unknownMessage(unknown[0], USER_SETTINGS) : "");
5607
+ checkCurate(settings, check2);
5401
5608
  for (const key2 of ["limits", "recovery"]) {
5402
5609
  if (settings[key2] === void 0) continue;
5403
5610
  check2(object2(settings[key2]), `${key2} must be an object`);
@@ -5449,7 +5656,7 @@ import { createCipheriv, createDecipheriv, randomBytes, createHash as createHash
5449
5656
  import { homedir } from "node:os";
5450
5657
 
5451
5658
  // packages/protocol/src/contract-v1.js
5452
- var METHODS_V1 = { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://alp.dev/schemas/methods-v1.json", "protocolVersion": 1, "errors": { "parseError": -32700, "invalidRequest": -32600, "methodNotFound": -32601, "invalidParams": -32602, "failed": 1e3, "notFound": 1001, "forbidden": 1003, "conflict": 1004, "unavailable": 1005, "protocol": 1006 }, "capabilities": { "attach.after": "session.attach accepts `after` and answers `cursor`/`reset`; envelopes kept in a tree timeline carry `cursor`.", "prompt.receipts": "session.prompt is answered at most once per (sessionId, clientMessageId) from a durable receipt; repeats answer the first outcome or outcome_unknown.", "extension.methods": "extension.register/unregister, and the daemon sends extension.invoke requests to the owning connection.", "team": "team.list: the teams a project can use, from the daemon host's built-ins, library and project.", "task": "task.list, task.create, task.update and task.gate.resolve on a project's .alp/tasks, written by the daemon under the task lock.", "library": "library.list/get/save/delete/duplicate/rename, library.skills.set and library.models on the daemon user's library and a project's .alp overrides; secrets are redacted on read.", "settings.language": "settings.language.get/set: the language the daemon user reads, in the daemon's ALP_HOME/settings.json.", "session.list.page": "session.list accepts `limit`, `cursor` and `query` and answers `nextCursor` while more sessions follow; without them it answers every session as before.", "question.watch": "question.watch: the connection is told of `question` and `question.resolved` in every tree (of a projectRoot when given), attached or not.", "question.watch.turns": "question.watch accepts `turns`: the connection is also told of `turn.ended` of every root in the trees it watches.", "session.attention": "question.watch accepts `attention`: its answer holds each watched root's finished or error attention, kept by alpd for every client, and the connection is told when one is set or cleared (an `attention` event); session.attention.clear acknowledges one.", "workspace.files": "workspace.files.search: files under a directory whose relative path matches a query; read-only, names only, links never followed.", "workspace.files.read": "workspace.files.list and workspace.files.read: the entries of a directory and the content of a UTF-8 text file (at most 1 MiB) under a directory; read-only, links never followed, .git, .env* and key or credential files refused, .gitignore'd paths hidden unless asked.", "prompt.images": 'session.prompt takes inline image parts { type: "image", mimeType, data } (base64, no paths or URLs) within the image limits; a session snapshot says whether its runtime takes them in promptImages.', "library.project.write": "library save/delete/duplicate/rename accept policy project-data: only project-only pure-data agents and skills, no executable configuration, sidecars or library/built-in collisions.", "schedule": "schedule.create/list/get/cancel: one-shot continuations of a root session. alpd opens the turn by itself when the time comes; a job that comes due late says how late it is, and a job that cannot run says why.", "session.history": "Durable bounded backward envelope pages, persisted generation and numeric attach watermark.", "workspace.registry": "Daemon-owned project/workspace registry, durable pins, revision CAS and requestId replay.", "workspace.worktree": "Host-approved managed user worktrees; opt-in workspace.manage and named destination mappings.", "workspace.git": "workspace.git.status and workspace.git.diff: a registered workspace's read-only Git status and structured diff hunks by workspaceId; enumerated comparisons only, bounded (1 MiB per file, 2 MiB per page, 200 untracked files) with an opaque snapshot and next cursor; blocked secret paths withheld on both sides of a rename; no Git mutation.", "attachments": 'attachment.begin/chunk/commit/abort/get/delete: daemon-owned immutable non-image attachments by opaque id, uploaded in bounded chunks, and session.prompt content parts `{ type: "attachment", attachmentId }`; daemon.hello carries `attachmentLimits`. Listed only with a home and a store, on macOS and Linux.', "session.fork": "session.fork: a new root whose conversation is a root's up to a completed turn (or a branch a rewind set aside), by native fork of Codex and Claude sessions; files are never copied or changed. Listed with a store and a runtime that forks native conversations, on macOS and Linux (not Windows).", "session.rewind": "session.rewind: a root's conversation from before a turn on, under the same session id; the later turns stay a recoverable branch, files are never changed, history generation advances (`history.reset` event). Same condition as session.fork.", "session.reload": "session.reload: restarts a live root's native process on its own conversation and configuration at the idle barrier (no turn, child, question, mail or parked work), keeping its session id, history and receipts; through the lifecycle journal. Listed with a store and a runtime that restarts a root on its own conversation, on macOS and Linux (not Windows).", "session.resumeCommand": "session.resumeCommand: the ALP CLI command (`alp attach <sessionId>`) that follows a session in a terminal, as argv and POSIX and Windows (cmd.exe) command lines built by alpd; for the clipboard only, never run, never a native runtime's command, credential, env or path.", "session.configure.live": "session.configure takes model, thinking and team (with requestId and ifGeneration) besides mode, and session.configure.preview answers the configuration a change would run with: a live root's model, effort or team changes at the idle barrier (no turn, child, question, mail or parked work) through a controlled restart of its native process on the same conversation; the effective configuration is written only after the runtime took it, through the lifecycle journal (\xA712.9). Never another runtime and never more permissions. Listed with a store and a runtime that restarts a root with a new configuration, on macOS and Linux (not Windows).", "terminal": "terminal.create/list/attach/input/resize/close/revoke and terminal.event notifications: a real PTY shell on the daemon host as the daemon's account (a cwd is not a sandbox), served only when the host owner opted in (<ALP_HOME>/terminal.json allowRemoteTerminal) on macOS and Linux.", "session.interrupt.turn": "session.interrupt accepts turnId and atomically cancels only that active turn, including its subtree. Conditional requests answer interrupted:true when canceled, false when the named turn is no longer active; false changes nothing. Without this capability clients must not send turnId or infer targeted cancellation from a legacy interrupt." }, "methods": { "assignment.recall": { "x-alp": { "effect": "mutation", "scope": { "kind": "project", "param": "projectRoot", "required": false, "alternatives": ["assignmentId", "taskId"] }, "idempotent": false, "risks": ["model call"] }, "params": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "taskId": { "type": "string" }, "projectRoot": { "type": "string" }, "question": { "type": "string" } }, "required": ["question"], "additionalProperties": true }, "result": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "agent": { "type": "string" }, "taskId": { "type": "string" }, "finishedAt": { "type": "string" }, "answer": { "type": "string" } }, "required": ["assignmentId", "agent", "finishedAt", "answer"], "additionalProperties": true } }, "board.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "pins": { "type": "array", "items": { "$ref": "#/$defs/pin" } } }, "required": ["pins"], "additionalProperties": true } }, "catalog.get": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "models": { "type": "array", "items": { "type": "object" } }, "modes": { "type": "array", "items": { "type": "object" } }, "thinkingOptions": {}, "defaultModel": { "type": "string" } }, "required": ["models", "modes", "defaultModel"], "additionalProperties": true } }, "daemon.hello": { "x-alp": { "effect": "query", "scope": { "kind": "connection" }, "idempotent": true }, "params": { "type": "object", "properties": { "protocolVersion": { "const": 1 }, "client": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" } }, "required": ["name", "version"], "additionalProperties": true }, "capabilities": { "type": "array", "items": { "type": "string" } } }, "required": ["protocolVersion"], "additionalProperties": true }, "result": { "type": "object", "properties": { "protocolVersion": { "const": 1 }, "daemonVersion": { "type": "string" }, "pid": { "type": "integer" }, "hostname": { "type": "string" }, "capabilities": { "type": "array", "items": { "type": "string" } }, "promptImageLimits": { "type": "object", "description": "Optional effective inline image limits for this connection, when prompt.images is advertised. Missing on older peers. Byte limits count decoded bytes.", "properties": { "maxCount": { "type": "integer", "minimum": 0 }, "maxBytes": { "type": "integer", "minimum": 0 }, "maxTotalBytes": { "type": "integer", "minimum": 0 } }, "required": ["maxCount", "maxBytes", "maxTotalBytes"], "additionalProperties": false }, "attachmentLimits": { "type": "object", "description": "Effective attachment limits for this connection, when `attachments` is advertised. Byte limits count decoded bytes; times are milliseconds. An operator or a gateway may lower them, never raise them.", "properties": { "maxObjectBytes": { "type": "integer", "minimum": 0 }, "maxPerPrompt": { "type": "integer", "minimum": 0 }, "maxPromptBytes": { "type": "integer", "minimum": 0 }, "maxChunkBytes": { "type": "integer", "minimum": 0 }, "maxActiveUploads": { "type": "integer", "minimum": 0 }, "maxPrincipalBytes": { "type": "integer", "minimum": 0 }, "maxDaemonBytes": { "type": "integer", "minimum": 0 }, "uploadTimeoutMs": { "type": "integer", "minimum": 0 }, "unreferencedRetentionMs": { "type": "integer", "minimum": 0 }, "releasedGraceMs": { "type": "integer", "minimum": 0 } }, "required": ["maxObjectBytes", "maxPerPrompt", "maxPromptBytes", "maxChunkBytes", "maxActiveUploads", "maxPrincipalBytes", "maxDaemonBytes", "uploadTimeoutMs", "unreferencedRetentionMs", "releasedGraceMs"], "additionalProperties": false }, "terminalLimits": { "type": "object", "description": "Effective terminal limits for this connection, when `terminal` is advertised. Byte limits count UTF-8 bytes; times are milliseconds. An operator or a gateway may lower them, never raise them.", "properties": { "maxPerPrincipal": { "type": "integer", "minimum": 0 }, "maxPerDaemon": { "type": "integer", "minimum": 0 }, "maxInputBytes": { "type": "integer", "minimum": 0 }, "maxOutputFrameBytes": { "type": "integer", "minimum": 0 }, "replayBytes": { "type": "integer", "minimum": 0 }, "idleMs": { "type": "integer", "minimum": 0 }, "maxLifetimeMs": { "type": "integer", "minimum": 0 }, "reconnectMs": { "type": "integer", "minimum": 0 } }, "required": ["maxPerPrincipal", "maxPerDaemon", "maxInputBytes", "maxOutputFrameBytes", "replayBytes", "idleMs", "maxLifetimeMs", "reconnectMs"], "additionalProperties": false } }, "required": ["protocolVersion"], "additionalProperties": true } }, "daemon.pause": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": { "runtime": { "enum": ["codex", "claude", "acp", "antigravity"] }, "now": { "type": "boolean" }, "reason": { "type": "string" } }, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.pauses": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.resume": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": { "runtime": { "enum": ["codex", "claude", "acp", "antigravity"] } }, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.shutdown": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "daemon.status": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "pid": { "type": "integer" }, "startedAt": { "type": "string" }, "version": { "type": "string" }, "protocolVersion": { "type": "integer" }, "sessions": { "type": "integer" }, "questions": { "type": "integer" }, "previousExit": { "type": "object", "properties": { "kind": { "enum": ["clean", "crash"] }, "at": { "type": "string" } }, "required": ["kind"], "additionalProperties": true }, "persistence": { "type": "object" }, "health": { "$ref": "#/$defs/health" } }, "required": ["pid", "startedAt", "version", "protocolVersion", "sessions", "questions", "health"], "additionalProperties": true } }, "daemon.usage": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true, "risks": ["refresh asks every provider (spawns on the daemon host)"] }, "params": { "type": "object", "properties": { "refresh": { "type": "boolean" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "providers": { "type": "array", "items": { "type": "object" } } }, "required": ["providers"], "additionalProperties": true } }, "extension.register": { "x-alp": { "effect": "mutation", "scope": { "kind": "connection" }, "idempotent": false, "risks": ["admin"] }, "params": { "type": "object", "properties": { "method": { "type": "string" } }, "required": ["method"], "additionalProperties": true }, "result": { "type": "object", "properties": { "registered": { "type": "string" } }, "required": ["registered"], "additionalProperties": true } }, "extension.unregister": { "x-alp": { "effect": "mutation", "scope": { "kind": "connection" }, "idempotent": false, "risks": ["admin"] }, "params": { "type": "object", "properties": { "method": { "type": "string" } }, "required": ["method"], "additionalProperties": true }, "result": { "type": "object", "properties": { "unregistered": { "type": "string" } }, "required": ["unregistered"], "additionalProperties": true } }, "library.delete": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": false }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "revision": { "type": "string" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "name", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "removed": { "const": true }, "now": { "enum": ["builtin", "library"] } }, "required": ["removed"], "additionalProperties": true } }, "library.duplicate": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope", "reads": ["builtin", "library"] }, "idempotent": false, "risks": ["exec-config when kind is mcp, hooks or providers"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "from": { "$ref": "#/$defs/entryName" }, "to": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "from", "to", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" } }, "required": ["revision"], "additionalProperties": true } }, "library.get": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true, "redacts": ["mcp /server/env/*", "mcp /server/headers/*", "providers /provider/env/*"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "scope": { "$ref": "#/$defs/libraryScope" } }, "required": ["kind", "name"], "additionalProperties": true }, "result": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "content": { "type": "object" }, "revision": { "$ref": "#/$defs/libraryRevision" }, "usedBy": { "type": "array", "items": { "type": "string" } }, "librarySkills": { "type": "array", "items": { "type": "string" } }, "secrets": { "type": "array", "items": { "type": "string" } } }, "required": ["kind", "name", "source", "content", "revision", "usedBy"], "additionalProperties": true } }, "library.list": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["kind"], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": ["string", "null"] }, "entries": { "type": "array", "items": { "$ref": "#/$defs/libraryEntryRow" } } }, "required": ["projectRoot", "entries"], "additionalProperties": true } }, "library.models": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "models": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "efforts": { "type": "array", "items": { "type": "string" } }, "effort": { "type": "string" } }, "required": ["id", "label", "efforts"], "additionalProperties": true } } }, "required": ["models"], "additionalProperties": true } }, "library.rename": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": false, "risks": ["exec-config when kind is mcp, hooks or providers"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "from": { "$ref": "#/$defs/entryName" }, "to": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "from", "to", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" } }, "required": ["revision"], "additionalProperties": true } }, "library.save": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": "with revision (a repeat fails revision_conflict)", "risks": ["exec-config when kind is mcp, hooks or providers, or agents naming mcp/hooks/provider", "writes every known project's .alp/settings.json when kind is teams and sync is known-projects"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "content": { "type": "object" }, "revision": { "$ref": "#/$defs/libraryRevision" }, "sync": { "enum": ["none", "known-projects"] }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "name", "scope", "content"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" }, "syncedProjects": { "type": "integer", "minimum": 0 }, "syncErrors": { "type": "array", "items": { "type": "string" } } }, "required": ["revision"], "additionalProperties": true } }, "library.skills.set": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "host" }, "writes": ["ALP_HOME/role-skills.json"], "idempotent": true }, "params": { "type": "object", "properties": { "agent": { "$ref": "#/$defs/entryName" }, "skills": { "type": "array", "items": { "$ref": "#/$defs/entryName" }, "maxItems": 100 } }, "required": ["agent", "skills"], "additionalProperties": true }, "result": { "type": "object", "properties": { "skills": { "type": "array", "items": { "type": "string" } } }, "required": ["skills"], "additionalProperties": true } }, "question.answer": { "x-alp": { "effect": "mutation", "scope": { "kind": "question", "param": "questionId", "prefix": true }, "idempotent": false }, "params": { "type": "object", "properties": { "questionId": { "type": "string" }, "text": { "type": "string" }, "dismiss": { "type": "boolean" }, "reason": { "type": "string" } }, "required": ["questionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "questionId": { "type": "string" } }, "required": ["questionId"], "additionalProperties": true } }, "question.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } } }, "required": ["questions"], "additionalProperties": true } }, "question.watch": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true, "capability": "question.watch" }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "turns": { "type": "boolean" }, "attention": { "type": "boolean" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } }, "attention": { "type": "array", "items": { "type": "object", "properties": { "sessionId": { "type": "string" }, "attention": { "$ref": "#/$defs/attention" } }, "required": ["sessionId", "attention"], "additionalProperties": true } } }, "required": ["questions"], "additionalProperties": true } }, "session.attention.clear": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true, "capability": "session.attention" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "at": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "cleared": { "type": "boolean" } }, "required": ["cleared"], "additionalProperties": true } }, "schedule.create": { "x-alp": { "effect": "mutation", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["ALP_HOME/schedules"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "dueAt": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?(Z|[+-]\\d{2}:\\d{2})$" }, "prompt": { "type": "string", "minLength": 1, "maxLength": 8e3, "pattern": "\\S" } }, "required": ["projectRoot", "sessionId", "dueAt", "prompt"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "schedule.list": { "x-alp": { "effect": "query", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "status": { "enum": ["pending", "delivered", "failed", "cancelled"] } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "jobs": { "type": "array", "items": { "$ref": "#/$defs/scheduleJob" } } }, "required": ["jobs"], "additionalProperties": true } }, "schedule.get": { "x-alp": { "effect": "query", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["id", "projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "schedule.cancel": { "x-alp": { "effect": "mutation", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["ALP_HOME/schedules"], "idempotent": true }, "params": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["id", "projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "session.archive": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "archived": { "type": "boolean" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.attach": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "replay": { "type": "boolean" }, "after": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "generation": { "type": "string", "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "cursor": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "reset": { "const": true } }, "required": ["session", "cursor"], "additionalProperties": true } }, "session.close": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": false }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "session.configure": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": "mode alone: yes; with model, thinking or team: with requestId", "risks": ["with model, thinking or team: restarts the root's native process on its own conversation; never another runtime, never more permissions"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "mode": { "type": "string" }, "model": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Native model, or runtime-prefixed (codex:/claude:); the session's own runtime only (capability session.configure.live)." }, "thinking": { "type": "string", "minLength": 1, "maxLength": 200, "description": "An effort the model takes (capability session.configure.live)." }, "team": { "type": "string", "minLength": 1, "maxLength": 200, "description": "A team id the daemon host defines (capability session.configure.live); no path or configuration." }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": ["sessionId"], "anyOf": [{ "not": { "anyOf": [{ "required": ["model"] }, { "required": ["thinking"] }, { "required": ["team"] }] } }, { "required": ["requestId", "ifGeneration"] }], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/session" }, "configured": { "$ref": "#/$defs/configureOutcome" }, "duplicate": { "const": true } }, "required": ["session"], "additionalProperties": true } }, "session.configure.preview": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.configure.live", "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "mode": { "type": "string" }, "model": { "type": "string", "minLength": 1, "maxLength": 200 }, "thinking": { "type": "string", "minLength": 1, "maxLength": 200 }, "team": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "preview": { "$ref": "#/$defs/configurePreview" } }, "required": ["preview"], "additionalProperties": true } }, "session.create": { "x-alp": { "effect": "mutation", "scope": { "kind": "project", "param": "spec.cwd" }, "idempotent": false, "risks": ["exec: spec.env and stdio spec.mcpServers run on the daemon host", "spec.workdir/writeRoot/copy*/restore/keepThread are internal"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$" }, "spec": { "anyOf": [{ "$ref": "#/$defs/spec" }, { "type": "object", "properties": { "agent": { "type": "string" }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "persist": { "type": "boolean" }, "workflow": { "type": "string" } }, "required": [], "additionalProperties": false }] }, "history": { "enum": ["skip", "replay"] }, "delegation": { "type": "boolean" }, "resume": { "type": "boolean" }, "workspaceId": { "type": "string" } }, "required": ["spec"], "additionalProperties": true, "anyOf": [{ "required": ["workspaceId"] }, { "properties": { "spec": { "$ref": "#/$defs/spec" } } }] }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/session" }, "attached": { "type": "boolean" }, "resumed": { "const": true }, "durable": { "type": "boolean" } }, "required": ["session", "attached"], "additionalProperties": true } }, "session.get": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.interrupt": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "turnId": { "type": "string", "minLength": 1 } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "interrupted": { "type": "boolean" } }, "required": [], "additionalProperties": true } }, "session.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "rootsOnly": { "type": "boolean" }, "includeClosed": { "type": "boolean" }, "includeArchived": { "type": "boolean" }, "limit": { "type": "integer", "minimum": 1, "maximum": 1e3 }, "cursor": { "type": "string", "minLength": 1, "maxLength": 1024 }, "query": { "type": "string", "maxLength": 200 }, "projectRoots": { "type": "array", "items": { "type": "string" }, "minItems": 1, "maxItems": 1024 } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "sessions": { "type": "array", "items": { "$ref": "#/$defs/sessionSummary" } }, "nextCursor": { "type": "string", "minLength": 1 } }, "required": ["sessions"], "additionalProperties": true } }, "session.log": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "rootId": { "type": "string" }, "entries": { "type": "array", "items": { "type": "object" } } }, "required": ["rootId", "entries"], "additionalProperties": true } }, "session.message": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": false }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "text": { "type": "string" } }, "required": ["sessionId", "text"], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "session.preview": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "spec.cwd" }, "idempotent": true }, "params": { "type": "object", "properties": { "spec": { "$ref": "#/$defs/spec" } }, "required": ["spec"], "additionalProperties": true }, "result": { "type": "object", "properties": { "preview": { "$ref": "#/$defs/preview" } }, "required": ["preview"], "additionalProperties": true } }, "session.prompt": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": "with prompt.receipts" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "clientMessageId": { "type": "string" }, "delivery": { "enum": ["auto", "steer"] }, "content": { "type": "array", "items": { "anyOf": [{ "type": "object", "properties": { "type": { "const": "text" }, "text": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "$ref": "#/$defs/promptImage" }, { "type": "object", "properties": { "type": { "const": "attachment" }, "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" } }, "required": ["type", "attachmentId"], "additionalProperties": false }, { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["text", "image", "attachment"] } } }, "required": ["type"], "additionalProperties": true }] } }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "clientMessageId", "content"], "additionalProperties": true }, "result": { "type": "object", "properties": { "outcome": { "enum": ["accepted", "failed"] }, "error": { "$ref": "#/$defs/alpError" }, "duplicate": { "type": "boolean" }, "durable": { "type": "boolean" } }, "required": [], "additionalProperties": true } }, "session.release": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "closed": { "type": "boolean" } }, "required": ["closed"], "additionalProperties": true } }, "session.rename": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "title": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "\\S" } }, "required": ["sessionId", "title"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.status": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "status": { "$ref": "#/$defs/treeStatus" } }, "required": ["status"], "additionalProperties": true } }, "settings.language.get": { "x-alp": { "effect": "query", "capability": "settings.language", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/languageSetting" } }, "settings.language.set": { "x-alp": { "effect": "mutation", "capability": "settings.language", "scope": { "kind": "host" }, "writes": ["ALP_HOME/settings.json"], "idempotent": true }, "params": { "type": "object", "properties": { "language": { "anyOf": [{ "type": "string", "minLength": 1, "maxLength": 40, "pattern": "\\S" }, { "type": "null" }] } }, "required": ["language"], "additionalProperties": true }, "result": { "$ref": "#/$defs/languageSetting" } }, "task.create": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": "per requestId within one alpd process (10 minutes)" }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "title": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "\\S" }, "priority": { "type": "integer", "minimum": 0, "maximum": 4 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["projectRoot", "title"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "duplicate": { "const": true } }, "required": ["id"], "additionalProperties": true } }, "task.gate.resolve": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "id": { "$ref": "#/$defs/taskId" }, "gate": { "type": "string", "minLength": 1, "maxLength": 128 }, "note": { "type": "string", "maxLength": 2e3 }, "ifRev": { "type": "integer", "minimum": 0 } }, "required": ["projectRoot", "id", "gate"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "status": { "type": "string" }, "rev": { "type": "integer", "minimum": 0 } }, "required": ["id", "status", "rev"], "additionalProperties": true } }, "task.list": { "x-alp": { "effect": "query", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "tasks": { "type": "array", "items": { "$ref": "#/$defs/taskRow" } }, "unreadable": { "type": "array", "items": { "type": "object", "properties": { "file": { "type": "string" }, "error": { "type": "string" } }, "required": ["file", "error"], "additionalProperties": true } }, "revision": { "type": "string" } }, "required": ["projectRoot", "tasks", "unreadable", "revision"], "additionalProperties": true } }, "task.update": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "id": { "$ref": "#/$defs/taskId" }, "action": { "enum": ["close", "reopen"] }, "note": { "type": "string", "maxLength": 2e3 }, "ifRev": { "type": "integer", "minimum": 0 } }, "required": ["projectRoot", "id", "action"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "status": { "type": "string" }, "rev": { "type": "integer", "minimum": 0 }, "landed": { "type": "string" } }, "required": ["id", "status", "rev"], "additionalProperties": true } }, "team.list": { "x-alp": { "effect": "query", "capability": "team", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": ["string", "null"] }, "teams": { "type": "array", "items": { "$ref": "#/$defs/teamRow" } } }, "required": ["projectRoot", "teams"], "additionalProperties": true } }, "workspace.files.search": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files", "risks": ["lists file names of the directory (not contents)"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "query": { "type": "string", "maxLength": 200 }, "limit": { "type": "integer", "minimum": 1, "maximum": 100 } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "files": { "type": "array", "maxItems": 100, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 } }, "required": ["path"], "additionalProperties": true } }, "truncated": { "type": "boolean" } }, "required": ["files"], "additionalProperties": true } }, "workspace.files.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.read", "risks": ["lists names, kinds, sizes and times of a directory's entries (not contents)"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "includeIgnored": { "type": "boolean" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "entries": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "name": { "type": "string", "minLength": 1 }, "path": { "type": "string", "minLength": 1 }, "kind": { "enum": ["file", "directory"] }, "size": { "type": "integer", "minimum": 0 }, "modifiedAt": { "type": "string" } }, "required": ["name", "path", "kind"], "additionalProperties": true } }, "truncated": { "type": "boolean" } }, "required": ["entries"], "additionalProperties": true } }, "workspace.files.read": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.read", "risks": ["returns the content of a text file under the directory"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "includeIgnored": { "type": "boolean" } }, "required": ["projectRoot", "path"], "additionalProperties": true }, "result": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 }, "content": { "type": "string" }, "size": { "type": "integer", "minimum": 0, "maximum": 1048576 }, "modifiedAt": { "type": "string" } }, "required": ["path", "content", "size"], "additionalProperties": true } }, "session.history": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true, "capability": "session.history" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "before": { "type": "string", "maxLength": 4096 }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "maxBytes": { "type": "integer", "minimum": 2048, "maximum": 524288 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "generation": { "type": "string" }, "items": { "type": "array", "maxItems": 500, "items": { "oneOf": [{ "$ref": "#/$defs/envelope" }, { "type": "object", "properties": { "cursor": { "type": "integer", "minimum": 0 }, "oversized": { "type": "object", "properties": { "bytes": { "type": "integer", "minimum": 1 } }, "required": ["bytes"] } }, "required": ["cursor", "oversized"], "additionalProperties": false }] } }, "olderCursor": { "type": "string" }, "hasOlder": { "type": "boolean" }, "tipCursor": { "type": "integer", "minimum": 0 } }, "required": ["generation", "items", "hasOlder", "tipCursor"], "additionalProperties": true } }, "project.list": { "params": { "type": "object", "properties": { "cursor": { "type": "string", "pattern": "^[0-9]+$" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "projectRoots": { "type": "array", "items": { "type": "string" } }, "includeRemoved": { "type": "boolean" } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "projects": { "type": "array", "items": { "$ref": "#/$defs/registryProject" } }, "revision": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 }, "nextCursor": { "type": ["string", "null"] } }, "required": ["projects", "revision", "total", "nextCursor"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.list": { "params": { "type": "object", "properties": { "cursor": { "type": "string", "pattern": "^[0-9]+$" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "projectRoots": { "type": "array", "items": { "type": "string" } }, "includeArchived": { "type": "boolean" } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspaces": { "type": "array", "items": { "$ref": "#/$defs/registryWorkspace" } }, "revision": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 }, "nextCursor": { "type": ["string", "null"] } }, "required": ["workspaces", "revision", "total", "nextCursor"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.get": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "project.register": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "directory": { "type": "string" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["directory", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "project": { "$ref": "#/$defs/registryProject" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["project", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "project.remove": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "projectId": { "type": "string" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["projectId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "project": { "$ref": "#/$defs/registryProject" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["project", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.update": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "workspaceId": { "type": "string" }, "title": { "type": ["string", "null"] }, "pinned": { "type": "boolean" }, "archived": { "type": "boolean" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["workspaceId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "registry.owner": { "params": { "type": "object", "properties": { "operation": { "enum": ["project.add", "project.rename", "project.remove", "workspace.create", "workspace.update", "placement.prepare", "placement.assign", "label.assign", "label.update", "label.delete", "placement.remove"] }, "args": { "type": "object" }, "requestId": { "type": "string" }, "ifRevision": { "type": "integer", "minimum": 0 } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "registry": { "type": "object" } }, "required": ["registry"] }, "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "capability": "workspace.registry", "idempotent": false } }, "workspace.worktree.create": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "mappingId": { "type": "string", "maxLength": 64 }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId", "requestId", "ifRevision", "mappingId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 }, "filesRemoved": { "type": "boolean" }, "branchRetained": { "type": "boolean" } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "workspace.worktree.remove": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 }, "filesRemoved": { "type": "boolean" }, "branchRetained": { "type": "boolean" } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "workspace.worktree.options": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "mappingIds": { "type": "array", "items": { "type": "string" } } }, "required": ["mappingIds"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "registry.worktree": { "params": { "type": "object", "properties": { "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "principalEpoch": { "type": "string" } }, "additionalProperties": false }, "result": { "type": "object", "additionalProperties": true }, "x-alp": { "effect": "query", "scope": { "kind": "host" }, "capability": "workspace.worktree" } }, "workspace.git.status": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.git", "idempotent": true, "risks": ["lists the changed file paths, branch and remote of a workspace checkout"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1 } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "state": { "enum": ["repository", "not_repository", "unsupported"] }, "reason": { "type": "string" }, "branch": { "type": ["string", "null"] }, "detached": { "type": "boolean" }, "head": { "type": ["string", "null"] }, "upstream": { "type": ["object", "null"], "properties": { "ref": { "type": "string" }, "ahead": { "type": "integer", "minimum": 0 }, "behind": { "type": "integer", "minimum": 0 } }, "required": ["ref", "ahead", "behind"], "additionalProperties": false }, "baseRef": { "type": ["string", "null"] }, "aheadBehind": { "type": ["object", "null"], "properties": { "ahead": { "type": "integer", "minimum": 0 }, "behind": { "type": "integer", "minimum": 0 } }, "required": ["ahead", "behind"], "additionalProperties": false }, "hasRemote": { "type": "boolean" }, "remoteUrl": { "type": ["string", "null"] }, "dirty": { "type": "boolean" }, "files": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "oldPath": { "type": "string", "minLength": 1, "maxLength": 4096 }, "change": { "enum": ["modified", "added", "deleted", "renamed", "copied", "typechange", "untracked", "conflicted"] }, "staged": { "type": "boolean" }, "unstaged": { "type": "boolean" } }, "required": ["path", "change", "staged", "unstaged"], "additionalProperties": false } }, "hiddenCount": { "type": "integer", "minimum": 0 }, "truncated": { "type": "boolean" }, "snapshot": { "type": "string", "maxLength": 1024 } }, "required": ["state", "branch", "detached", "head", "upstream", "baseRef", "aheadBehind", "hasRemote", "remoteUrl", "dirty", "files", "hiddenCount", "truncated", "snapshot"], "additionalProperties": false } }, "workspace.git.diff": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.git", "idempotent": true, "risks": ["returns changed file content of a workspace checkout as diff hunks, including deleted and historical lines"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1 }, "compare": { "type": "object", "properties": { "mode": { "enum": ["uncommitted", "staged", "unstaged", "base"] }, "baseRef": { "type": "string", "minLength": 1, "maxLength": 255 }, "ignoreWhitespace": { "type": "boolean" } }, "required": ["mode"], "additionalProperties": false }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "cursor": { "type": "string", "minLength": 1, "maxLength": 1024 } }, "required": ["workspaceId", "compare"], "additionalProperties": false }, "result": { "type": "object", "properties": { "compare": { "type": "object", "properties": { "mode": { "enum": ["uncommitted", "staged", "unstaged", "base"] }, "baseRef": { "type": "string" }, "ignoreWhitespace": { "type": "boolean" } }, "required": ["mode", "ignoreWhitespace"], "additionalProperties": false }, "snapshot": { "type": "string", "maxLength": 1024 }, "files": { "type": "array", "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "oldPath": { "type": "string", "minLength": 1, "maxLength": 4096 }, "change": { "enum": ["modified", "added", "deleted", "renamed", "copied", "typechange", "untracked", "conflicted"] }, "kind": { "enum": ["text", "binary", "too_large", "withheld", "symlink", "submodule"] }, "additions": { "type": "integer", "minimum": 0 }, "deletions": { "type": "integer", "minimum": 0 }, "hunks": { "type": "array", "items": { "type": "object", "properties": { "oldStart": { "type": "integer", "minimum": 0 }, "oldCount": { "type": "integer", "minimum": 0 }, "newStart": { "type": "integer", "minimum": 0 }, "newCount": { "type": "integer", "minimum": 0 }, "context": { "type": "string" }, "lines": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": ["add", "remove", "context"] }, "content": { "type": "string" }, "noNewline": { "const": true } }, "required": ["type", "content"], "additionalProperties": false } } }, "required": ["oldStart", "oldCount", "newStart", "newCount", "lines"], "additionalProperties": false } } }, "required": ["path", "change", "kind", "additions", "deletions", "hunks"], "additionalProperties": false } }, "hiddenCount": { "type": "integer", "minimum": 0 }, "truncated": { "type": "boolean" }, "nextCursor": { "type": "string", "minLength": 1, "maxLength": 1024 } }, "required": ["compare", "snapshot", "files", "hiddenCount", "truncated"], "additionalProperties": false } }, "attachment.begin": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "attachments", "idempotent": "with requestId", "risks": ["reserves stored bytes of the daemon host for a file the client uploads"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$" }, "name": { "type": "string", "minLength": 1, "maxLength": 1024 }, "size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "mimeType": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$" }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "name", "size", "mimeType", "requestId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "state": { "enum": ["uploading", "committed"] }, "received": { "type": "integer", "minimum": 0 }, "size": { "type": "integer", "minimum": 0 }, "maxChunkBytes": { "type": "integer", "minimum": 1 }, "expiresAt": { "type": "string" }, "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" } }, "required": ["uploadId", "state", "received", "size", "maxChunkBytes"], "additionalProperties": false } }, "attachment.chunk": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": "same offset and bytes", "risks": ["writes uploaded bytes to the daemon host"] }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "data": { "type": "string", "minLength": 4, "maxLength": 349528, "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId", "offset", "data"], "additionalProperties": false }, "result": { "type": "object", "properties": { "received": { "type": "integer", "minimum": 0 }, "size": { "type": "integer", "minimum": 0 } }, "required": ["received", "size"], "additionalProperties": false } }, "attachment.commit": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": true }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId", "sha256"], "additionalProperties": false }, "result": { "type": "object", "properties": { "attachment": { "$ref": "#/$defs/attachment" } }, "required": ["attachment"], "additionalProperties": false } }, "attachment.abort": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": false }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "aborted": { "const": true } }, "required": ["aborted"], "additionalProperties": false } }, "attachment.get": { "x-alp": { "effect": "query", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": true }, "params": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["attachmentId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "attachment": { "$ref": "#/$defs/attachment" } }, "required": ["attachment"], "additionalProperties": false } }, "attachment.delete": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": false }, "params": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["attachmentId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "deleted": { "const": true } }, "required": ["deleted"], "additionalProperties": false } }, "session.fork": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.fork", "idempotent": "with requestId", "risks": ["creates a new root session in the source workspace or a granted destination workspace; files are never copied, restored or changed"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "boundary": { "oneOf": [{ "type": "object", "properties": { "throughTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["throughTurnId"], "additionalProperties": false }, { "type": "object", "properties": { "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["beforeTurnId"], "additionalProperties": false }] }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "newSessionId": { "type": "string", "pattern": "^[\\w.:-]{1,128}$" }, "title": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "requestId", "ifGeneration"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "forkedFrom": { "$ref": "#/$defs/forkProvenance" }, "duplicate": { "const": true } }, "required": ["session", "forkedFrom"], "additionalProperties": true } }, "session.rewind": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.rewind", "idempotent": "with requestId", "risks": ["replaces the conversation the runtime continues from; the later turns stay recoverable and no file is changed"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["sessionId", "requestId", "ifGeneration", "beforeTurnId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "generation": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "branch": { "$ref": "#/$defs/conversationBranch" }, "duplicate": { "const": true } }, "required": ["session", "generation", "branch"], "additionalProperties": true } }, "session.reload": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.reload", "idempotent": "with requestId", "risks": ["restarts the root's native process; its conversation, configuration, history and receipts are kept"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": ["sessionId", "requestId", "ifGeneration"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "duplicate": { "const": true } }, "required": ["session"], "additionalProperties": true } }, "session.resumeCommand": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.resumeCommand", "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "argv": { "type": "array", "minItems": 1, "maxItems": 16, "items": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "^[^\\u0000-\\u001f\\u007f]+$" } }, "posix": { "type": "string", "minLength": 1, "maxLength": 2048 }, "windows": { "type": "string", "minLength": 1, "maxLength": 2048 }, "display": { "type": "string", "minLength": 1, "maxLength": 2048 }, "platform": { "enum": ["posix", "windows"] } }, "required": ["argv", "posix", "windows", "display", "platform"], "additionalProperties": false } }, "terminal.create": { "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "terminal", "idempotent": false, "risks": ["starts a shell on the daemon host as the daemon's account: host-level execution, not confined to the workspace"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["workspaceId", "cols", "rows", "requestId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminal": { "$ref": "#/$defs/terminal" } }, "required": ["terminal"], "additionalProperties": false } }, "terminal.list": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "terminal", "idempotent": true }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminals": { "type": "array", "items": { "$ref": "#/$defs/terminal" } } }, "required": ["terminals"], "additionalProperties": false } }, "terminal.attach": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": true, "risks": ["streams the terminal's output, which may show anything the shell printed"] }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "after": { "type": "integer", "minimum": 0 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminal": { "$ref": "#/$defs/terminal" }, "nextSeq": { "type": "integer", "minimum": 1 }, "gap": { "type": "object", "properties": { "fromSeq": { "type": "integer", "minimum": 1 }, "toSeq": { "type": "integer", "minimum": 1 } }, "required": ["fromSeq", "toSeq"], "additionalProperties": false } }, "required": ["terminal", "nextSeq"], "additionalProperties": false } }, "terminal.input": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": false, "risks": ["types into a host shell: runs any command as the daemon's account"] }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "data": { "type": "string", "minLength": 1, "maxLength": 65536 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId", "data"], "additionalProperties": false }, "result": { "type": "object", "properties": { "bytes": { "type": "integer", "minimum": 1 } }, "required": ["bytes"], "additionalProperties": false } }, "terminal.resize": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": true }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId", "cols", "rows"], "additionalProperties": false }, "result": { "type": "object", "properties": { "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 } }, "required": ["cols", "rows"], "additionalProperties": false } }, "terminal.close": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": false }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "closed": { "const": true } }, "required": ["closed"], "additionalProperties": false } }, "terminal.revoke": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "capability": "terminal", "idempotent": true, "risks": ["kills every terminal of a principal; for a trusted gateway, never exposed"] }, "params": { "type": "object", "properties": { "principalId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["principalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "closed": { "type": "integer", "minimum": 0 } }, "required": ["closed"], "additionalProperties": false } } }, "$defs": { "error": { "type": "object", "properties": { "code": { "type": "integer" }, "message": { "type": "string" }, "data": {} }, "required": ["code", "message"], "additionalProperties": true }, "session": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "promptImages": { "type": "boolean" }, "promptAttachments": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "enum": ["file.path", "document.native", "text.extract"] } }, "usage": { "$ref": "#/$defs/usage" } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy"], "additionalProperties": true }, "usage": { "type": "object", "properties": { "contextWindowUsedTokens": { "type": "integer", "minimum": 0 }, "contextWindowMaxTokens": { "type": "integer", "minimum": 1 }, "inputTokens": { "type": "integer", "minimum": 0 }, "cachedInputTokens": { "type": "integer", "minimum": 0 }, "outputTokens": { "type": "integer", "minimum": 0 }, "totalCostUsd": { "type": "number", "minimum": 0 } }, "additionalProperties": true }, "assignment": { "type": "object", "properties": { "id": { "type": "string" }, "agent": { "type": "string" }, "mode": { "type": "string" }, "status": { "type": "string" }, "startedAt": { "type": "string" }, "worktree": { "type": "object", "properties": { "branch": { "type": "string" }, "path": { "type": "string" } }, "required": ["branch", "path"], "additionalProperties": true } }, "required": ["id", "agent", "mode", "status", "startedAt"], "additionalProperties": true }, "mail": { "type": "object", "properties": { "id": { "type": "string" }, "kind": { "enum": ["question", "answer", "note", "steer", "result", "stalled", "board", "checkin"] }, "from": { "type": "string" }, "assignment": { "type": "string" }, "body": { "type": "string" }, "replyTo": { "type": "string" }, "result": { "type": "object" }, "redelivered": { "type": "boolean" } }, "required": ["id", "kind", "from", "assignment"], "additionalProperties": true }, "pin": { "type": "object", "properties": { "id": { "type": "string" }, "project": { "type": "string" }, "kind": { "enum": ["claim", "decision", "finding"] }, "body": { "type": "string" }, "paths": { "type": "array", "items": { "type": "string" } }, "agent": { "type": "string" }, "sessionId": { "type": "string" }, "rootId": { "type": "string" }, "at": { "type": "string" }, "released": { "type": "string" }, "task": { "type": "string" } }, "required": ["id", "project", "kind", "body", "agent", "sessionId", "rootId", "at"], "additionalProperties": true }, "question": { "type": "object", "properties": { "id": { "type": "string" }, "sessionId": { "type": "string" }, "rootId": { "type": "string" }, "agent": { "type": "string" }, "body": { "type": "string" }, "options": { "type": "array", "items": { "type": "string" } }, "askedAt": { "type": "string" } }, "required": ["id", "sessionId", "rootId", "agent", "body", "askedAt"], "additionalProperties": true }, "attention": { "type": "object", "properties": { "reason": { "enum": ["finished", "error"] }, "at": { "type": "string" }, "turnId": { "type": "string" }, "message": { "type": "string" } }, "required": ["reason", "at"], "additionalProperties": true }, "spec": { "type": "object", "properties": { "cwd": { "type": "string" }, "agent": { "type": "string" }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "persist": { "type": "boolean" }, "restore": { "type": "object" } }, "required": ["cwd"], "additionalProperties": true }, "item": { "anyOf": [{ "$ref": "#/$defs/knownItem" }, { "$ref": "#/$defs/unknownItem" }] }, "event": { "anyOf": [{ "$ref": "#/$defs/knownEvent" }, { "$ref": "#/$defs/unknownEvent" }] }, "envelope": { "type": "object", "properties": { "sessionId": { "type": "string" }, "epoch": { "type": "string" }, "seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "ts": { "type": "string" }, "event": { "$ref": "#/$defs/event" }, "cursor": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, "required": ["sessionId", "epoch", "seq", "ts", "event"], "additionalProperties": true }, "request": { "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }] }, "method": { "type": "string" }, "params": { "type": "object" } }, "required": ["jsonrpc", "method", "id"], "additionalProperties": true }, "response": { "oneOf": [{ "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" }] }, "result": {} }, "required": ["jsonrpc", "id", "result"], "additionalProperties": true }, { "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" }] }, "error": { "$ref": "#/$defs/error" } }, "required": ["jsonrpc", "id", "error"], "additionalProperties": true }] }, "notification": { "oneOf": [{ "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "event" }, "params": { "$ref": "#/$defs/envelope" } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }, { "type": "object", "description": "A terminal's output, exit or detach (capability terminal, \xA712.10).", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "terminal.event" }, "params": { "$ref": "#/$defs/terminalEvent" } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }] }, "knownEvent": { "oneOf": [{ "type": "object", "properties": { "type": { "const": "session.opened" }, "session": { "$ref": "#/$defs/session" }, "cwd": { "type": "string" }, "effective": { "type": "object", "properties": { "model": { "type": "string" }, "thinking": { "type": "string" } }, "required": ["model", "thinking"], "additionalProperties": true } }, "required": ["type", "session", "cwd", "effective"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.ready" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.updated" }, "session": { "$ref": "#/$defs/session" } }, "required": ["type", "session"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.closed" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.failed" }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "error"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "prompt.accepted" }, "clientMessageId": { "type": "string" }, "result": { "enum": ["turn", "steer"] }, "turnId": { "type": "string" } }, "required": ["type", "clientMessageId", "result", "turnId"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "prompt.failed" }, "clientMessageId": { "type": "string" }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "clientMessageId", "error"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "turn.started" }, "turnId": { "type": "string" }, "origin": { "enum": ["user", "wake", "assignment", "runtime"] } }, "required": ["type", "turnId", "origin"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "turn.ended" }, "turnId": { "type": "string" }, "state": { "enum": ["completed", "failed", "canceled"] }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "turnId", "state"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "item" }, "item": { "$ref": "#/$defs/item" } }, "required": ["type", "item"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "usage" }, "usage": { "$ref": "#/$defs/usage" } }, "required": ["type", "usage"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "mail" }, "mail": { "$ref": "#/$defs/mail" } }, "required": ["type", "mail"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "assignment" }, "assignment": { "$ref": "#/$defs/assignment" } }, "required": ["type", "assignment"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "question" }, "question": { "$ref": "#/$defs/question" } }, "required": ["type", "question"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "question.resolved" }, "questionId": { "type": "string" }, "outcome": { "enum": ["answered", "dismissed", "timeout", "canceled"] }, "answer": { "type": "string" } }, "required": ["type", "questionId", "outcome"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "pin" }, "pin": { "$ref": "#/$defs/pin" } }, "required": ["type", "pin"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "unpin" }, "pinId": { "type": "string" }, "reason": { "enum": ["unpinned", "session_ended"] } }, "required": ["type", "pinId", "reason"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "attention" }, "attention": { "$ref": "#/$defs/attention" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "history.reset" }, "generation": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "reason": { "const": "rewind" }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" } }, "required": ["type", "generation", "reason", "branchId"], "additionalProperties": true }] }, "unknownEvent": { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["session.opened", "session.ready", "session.updated", "session.closed", "session.failed", "prompt.accepted", "prompt.failed", "turn.started", "turn.ended", "item", "usage", "mail", "assignment", "question", "question.resolved", "pin", "unpin", "attention", "history.reset"] } } }, "required": ["type"], "additionalProperties": true }, "knownItem": { "oneOf": [{ "type": "object", "properties": { "kind": { "const": "user_message" }, "id": { "type": "string" }, "text": { "type": "string" }, "clientMessageId": { "type": "string" }, "images": { "type": "integer", "minimum": 1 }, "attachments": { "type": "array", "items": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "name": { "type": "string" }, "mimeType": { "type": "string" }, "size": { "type": "integer", "minimum": 0 } }, "required": ["attachmentId", "name", "mimeType", "size"], "additionalProperties": false } }, "origin": { "enum": ["user", "wake", "assignment", "runtime"] } }, "required": ["kind", "id", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "assistant_message" }, "id": { "type": "string" }, "text": { "type": "string" } }, "required": ["kind", "id", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "notice" }, "id": { "type": "string" }, "level": { "enum": ["info", "warning", "error"] }, "text": { "type": "string" } }, "required": ["kind", "id", "level", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "compaction" }, "id": { "type": "string" }, "status": { "enum": ["running", "completed", "failed"] }, "trigger": { "type": "string" }, "preTokens": { "type": "integer" }, "postTokens": { "type": "integer" } }, "required": ["kind", "id", "status"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "todo" }, "id": { "type": "string" }, "items": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "text": { "type": "string" }, "status": { "enum": ["pending", "in_progress", "completed"] } }, "required": ["id", "text", "status"], "additionalProperties": true } } }, "required": ["kind", "id", "items"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "tool_call" }, "id": { "type": "string" }, "callId": { "type": "string" }, "name": { "type": "string" }, "status": { "enum": ["running", "completed", "failed"] }, "error": { "type": "string" }, "detail": { "$ref": "#/$defs/toolCallDetail" } }, "required": ["kind", "id", "callId", "name", "status", "detail"], "additionalProperties": true }] }, "unknownItem": { "type": "object", "properties": { "kind": { "type": "string", "not": { "enum": ["user_message", "assistant_message", "notice", "compaction", "todo", "tool_call"] } }, "id": { "type": "string" } }, "required": ["kind", "id"], "additionalProperties": true }, "toolCallDetail": { "oneOf": [{ "type": "object", "properties": { "type": { "const": "shell" }, "command": { "type": "string" }, "cwd": { "type": "string" }, "output": { "type": "string" }, "exitCode": { "type": ["integer", "null"] } }, "required": ["type", "command", "output"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "read" }, "filePath": { "type": "string" }, "content": { "type": "string" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "edit" }, "filePath": { "type": "string" }, "oldString": { "type": "string" }, "newString": { "type": "string" }, "unifiedDiff": { "type": "string" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "write" }, "filePath": { "type": "string" }, "content": { "type": "string" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "search" }, "query": { "type": "string" }, "toolName": { "enum": ["search", "grep", "glob", "web_search"] }, "content": { "type": "string" }, "filePaths": { "type": "array", "items": { "type": "string" } }, "webResults": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string" }, "url": { "type": "string" } }, "required": ["title", "url"], "additionalProperties": true } }, "numFiles": { "type": "integer" }, "numMatches": { "type": "integer" }, "truncated": { "type": "boolean" } }, "required": ["type", "query"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "fetch" }, "url": { "type": "string" }, "prompt": { "type": "string" }, "result": { "type": "string" }, "code": { "type": "integer" } }, "required": ["type", "url"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "sub_agent" }, "subAgentType": { "type": "string" }, "description": { "type": "string" }, "log": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "plan" }, "text": { "type": "string" } }, "required": ["type", "text"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "plain_text" }, "label": { "type": "string" }, "text": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "unknown" }, "input": {}, "output": {} }, "required": ["type", "input", "output"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["shell", "read", "edit", "write", "search", "fetch", "sub_agent", "plan", "plain_text", "unknown"] } } }, "required": ["type"], "additionalProperties": true }] }, "alpError": { "type": "object", "properties": { "message": { "type": "string" }, "code": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "sessionSummary": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "status": { "enum": ["initializing", "idle", "running", "error", "closed"] }, "title": { "type": "string" }, "archived": { "type": "boolean" }, "attention": { "$ref": "#/$defs/attention" }, "lastError": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" }, "conversation": { "type": "object", "properties": { "fork": { "type": "boolean" }, "rewind": { "type": "boolean" }, "reload": { "type": "boolean", "description": "Whether session.reload can restart this root's native process (\xA712.8); the root must also be open and idle." }, "reason": { "enum": ["runtime_unsupported", "not_persistent", "not_root"] }, "configure": { "type": "boolean", "description": "Whether session.configure can change this root's model, effort or team (\xA712.9); the root must also be open and idle." } }, "required": ["fork", "rewind"], "additionalProperties": true }, "forkedFrom": { "$ref": "#/$defs/forkProvenance" }, "branches": { "type": "array", "maxItems": 100, "items": { "$ref": "#/$defs/conversationBranch" } }, "promptAttachments": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "enum": ["file.path", "document.native", "text.extract"] } } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy", "status"], "additionalProperties": true }, "pause": { "type": "object", "properties": { "since": { "type": "string" }, "by": { "type": "string" }, "reason": { "type": "string" }, "resetsAt": { "type": "string" }, "checkedAt": { "type": "string" } }, "required": ["since", "by", "reason"], "additionalProperties": true }, "pauseState": { "type": "object", "properties": { "all": { "$ref": "#/$defs/pause" }, "runtimes": { "type": "object", "additionalProperties": { "$ref": "#/$defs/pause" } }, "parked": { "type": "array", "items": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "type": "string" }, "rootId": { "type": "string" }, "reason": { "type": "string" }, "since": { "type": "string" } }, "required": ["assignmentId", "agent", "runtime", "rootId", "reason", "since"], "additionalProperties": true } } }, "required": ["runtimes", "parked"], "additionalProperties": true }, "preview": { "type": "object", "properties": { "teams": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" } }, "required": ["id", "label"], "additionalProperties": true } }, "team": { "type": "string" }, "teamLabel": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" } }, "required": ["teams", "team", "agent", "runtime", "model", "mode", "thinking"], "additionalProperties": true }, "treeStatus": { "type": "object", "properties": { "rootId": { "type": "string" }, "sessions": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "state": { "enum": ["running", "waiting", "waiting_parent", "waiting_user", "idle"] }, "idleMs": { "type": "number" }, "workdir": { "type": "string" }, "unreadMail": { "type": "integer", "minimum": 0 } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy", "state", "idleMs", "workdir", "unreadMail"], "additionalProperties": true } }, "assignments": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "requester": { "type": "string" }, "isolation": { "enum": ["shared", "worktree"] }, "idleMs": { "type": "number" } }, "required": ["id", "requester", "isolation", "idleMs"], "additionalProperties": true } }, "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } }, "worktrees": { "type": "array", "items": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "requester": { "type": "string" }, "agent": { "type": "string" }, "branch": { "type": "string" }, "files": { "type": "array", "items": { "type": "string" } }, "stat": { "type": "string" } }, "required": ["assignmentId", "requester", "agent", "branch", "files", "stat"], "additionalProperties": true } }, "leases": { "type": "array", "items": { "type": "object", "properties": { "checkout": { "type": "string" }, "assignmentId": { "type": "string" }, "agent": { "type": "string" } }, "required": ["checkout", "assignmentId", "agent"], "additionalProperties": true } }, "claims": { "type": "array", "items": { "$ref": "#/$defs/pin" } } }, "required": ["rootId", "sessions", "assignments", "questions", "worktrees", "leases", "claims"], "additionalProperties": true }, "health": { "type": "object", "properties": { "live": { "type": "boolean" }, "ready": { "type": "boolean" }, "checks": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "ok": { "type": "boolean" }, "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["id", "ok"], "additionalProperties": true } } }, "required": ["live", "ready", "checks"], "additionalProperties": true }, "projectRoot": { "type": "string", "minLength": 1, "maxLength": 4096, "description": "An absolute, normalized path on the daemon host to a directory holding .alp/. Compared as is: the daemon never walks up to a parent." }, "taskId": { "type": "string", "pattern": "^t-[0-9a-f]{4,12}(?:\\.\\d+)*$" }, "taskRow": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "title": { "type": "string" }, "type": { "type": "string" }, "priority": { "type": "integer" }, "status": { "enum": ["open", "in_progress", "review", "closed"] }, "rev": { "type": "integer", "minimum": 0 }, "parent": { "type": "string" }, "assignee": { "type": "string" }, "ready": { "type": "boolean" }, "blockedBy": { "type": "array", "items": { "type": "string" } }, "waits": { "type": "array", "items": { "type": "string" } }, "approvals": { "type": "array", "items": { "type": "object", "properties": { "gate": { "type": "string" }, "note": { "type": "string" } }, "required": ["gate", "note"], "additionalProperties": true } }, "handoff": { "type": "object", "properties": { "outcome": { "type": "string" }, "summary": { "type": "string" }, "agent": { "type": "string" } }, "required": ["outcome", "summary"], "additionalProperties": true }, "closed": { "type": "object", "properties": { "reason": { "type": "string" }, "summary": { "type": "string" }, "at": { "type": "string" } }, "required": ["reason", "at"], "additionalProperties": true }, "description": { "type": "string" }, "labels": { "type": "array", "items": { "type": "string" } }, "paths": { "type": "array", "items": { "type": "string" } }, "progress": { "type": "object", "properties": { "done": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 } }, "required": ["done", "total"], "additionalProperties": true }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" } }, "required": ["id", "title", "type", "priority", "status", "rev", "ready", "updatedAt"], "additionalProperties": true }, "libraryKind": { "enum": ["agents", "skills", "mcp", "hooks", "teams", "providers"] }, "libraryScope": { "enum": ["library", "project"] }, "librarySource": { "enum": ["builtin", "library", "project"] }, "entryName": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_.-]+$", "not": { "enum": [".", ".."] } }, "libraryRevision": { "type": ["string", "null"] }, "libraryEntryRow": { "type": "object", "properties": { "name": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "description": { "type": "string" }, "usedBy": { "type": "array", "items": { "type": "string" } } }, "required": ["name", "source"], "additionalProperties": true }, "secretMarker": { "type": "object", "properties": { "$secret": { "const": "keep" } }, "required": ["$secret"], "additionalProperties": false, "description": "Stands for a stored secret value: read results carry it in place of the value; a save that sends it back keeps the stored value." }, "languageSetting": { "type": "object", "properties": { "language": { "type": ["string", "null"] }, "applies": { "type": "string" }, "default": { "type": "string" } }, "required": ["language", "applies", "default"], "additionalProperties": true }, "teamRow": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "error": { "type": "string" } }, "required": ["id", "source"], "additionalProperties": true }, "promptImage": { "type": "object", "properties": { "type": { "const": "image" }, "mimeType": { "enum": ["image/png", "image/jpeg", "image/gif", "image/webp"] }, "data": { "type": "string", "minLength": 4, "maxLength": 6990508, "pattern": "^[A-Za-z0-9+/]+={0,2}$" }, "name": { "type": "string", "maxLength": 255 } }, "required": ["type", "mimeType", "data"], "additionalProperties": false }, "scheduleId": { "type": "string", "pattern": "^sch_[0-9a-f]{16}$" }, "scheduleError": { "type": "object", "properties": { "message": { "type": "string" }, "code": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "scheduleJob": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "sessionId": { "type": "string" }, "prompt": { "type": "string" }, "dueAt": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?(Z|[+-]\\d{2}:\\d{2})$" }, "status": { "enum": ["pending", "delivered", "failed", "cancelled"] }, "attempts": { "type": "integer", "minimum": 0 }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" }, "deliveredAt": { "type": "string" }, "failedAt": { "type": "string" }, "cancelledAt": { "type": "string" }, "attemptedAt": { "type": "string" }, "lateByMs": { "type": "integer", "minimum": 0 }, "lastError": { "$ref": "#/$defs/scheduleError" } }, "required": ["id", "projectRoot", "sessionId", "prompt", "dueAt", "status", "attempts", "createdAt", "updatedAt"], "additionalProperties": true }, "registryProject": { "type": "object", "properties": { "id": { "type": "string" }, "root": { "type": "string" }, "customName": { "type": ["string", "null"] }, "addedAt": { "type": "string" }, "removedAt": { "type": ["string", "null"] }, "revision": { "type": "integer", "minimum": 0 }, "canonical": { "type": "string" } }, "required": ["id", "root", "addedAt"], "additionalProperties": false }, "registryWorkspace": { "type": "object", "properties": { "id": { "type": "string" }, "projectId": { "type": "string" }, "directory": { "type": "string" }, "title": { "type": ["string", "null"] }, "pinnedAt": { "type": ["string", "null"] }, "archivedAt": { "type": ["string", "null"] }, "labels": { "type": "array", "items": { "type": "string" } }, "createdAt": { "type": "string" }, "revision": { "type": "integer", "minimum": 0 }, "canonical": { "type": "string" }, "idempotencyKey": { "type": "string" }, "branch": { "type": ["string", "null"] }, "managedWorktree": { "type": "boolean" } }, "required": ["id", "projectId", "directory", "labels", "createdAt"], "additionalProperties": false }, "attachment": { "type": "object", "description": "A committed attachment as clients see it: ids, display metadata and its digest, never a host path or URL.", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "name": { "type": "string", "minLength": 1, "maxLength": 255 }, "mimeType": { "type": "string", "minLength": 3, "maxLength": 255 }, "detectedMimeType": { "type": "string", "minLength": 3, "maxLength": 255 }, "size": { "type": "integer", "minimum": 0 }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "createdAt": { "type": "string" }, "committedAt": { "type": "string" }, "referenced": { "type": "boolean" } }, "required": ["attachmentId", "sessionId", "name", "mimeType", "detectedMimeType", "size", "sha256", "createdAt", "committedAt", "referenced"], "additionalProperties": false }, "forkProvenance": { "type": "object", "description": "Where a fork came from (\xA712.7): the source root, and the turn its conversation was cut at.", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "turnId": { "type": "string", "minLength": 1, "maxLength": 200 }, "boundary": { "enum": ["through", "before", "whole"] }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "at": { "type": "string", "minLength": 1, "maxLength": 64 } }, "required": ["sessionId", "boundary", "at"], "additionalProperties": true }, "conversationBranch": { "type": "object", "description": "Later turns a rewind set aside (\xA712.7): kept, never deleted, recoverable as a new session with session.fork { branchId }.", "properties": { "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 }, "turns": { "type": "integer", "minimum": 0 }, "at": { "type": "string", "minLength": 1, "maxLength": 64 } }, "required": ["branchId", "beforeTurnId", "turns", "at"], "additionalProperties": true }, "effectiveConfig": { "type": "object", "description": "The configuration a root runs with, or would after a change, as alpd resolved it (\xA712.9).", "properties": { "team": { "type": "string" }, "teamLabel": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "thinking": { "type": "string" }, "mode": { "type": "string" }, "permissionProfile": { "type": "string", "description": "The permission profile capping the agent's mode, when one does." }, "supervisor": { "type": "boolean" }, "maxPeers": { "type": "integer" }, "delegates": { "type": "array", "items": { "type": "string" }, "description": "Agents the root may delegate to." }, "tools": { "type": "array", "items": { "type": "string" }, "description": "ALP tools the root's agent is given." }, "mcpServers": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "kind": { "enum": ["stdio", "http"] } }, "required": ["name", "kind"], "additionalProperties": true } }, "hooks": { "type": "integer", "minimum": 0, "description": "How many hook commands the agent runs." }, "instructionsSha": { "type": "string" } }, "required": ["team", "agent", "runtime", "model", "thinking", "mode", "supervisor", "delegates", "tools", "mcpServers", "hooks"], "additionalProperties": true }, "configurePreview": { "type": "object", "properties": { "current": { "$ref": "#/$defs/effectiveConfig" }, "proposed": { "$ref": "#/$defs/effectiveConfig" }, "changes": { "type": "array", "items": { "enum": ["model", "thinking", "team", "mode"] } }, "restart": { "type": "boolean", "description": "Whether applying it restarts the root's native process (on its own conversation)." }, "allowed": { "type": "boolean", "description": "Whether session.configure would take it now; a busy tree may still refuse it later." }, "reason": { "enum": ["session_busy", "session_closed", "not_root", "runtime_unsupported", "runtime_mismatch", "agent_mismatch", "permission_escalation", "team_not_found", "invalid_params", "not_persistent"] }, "message": { "type": "string" }, "teams": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" } }, "required": ["id", "label"], "additionalProperties": true } } }, "required": ["current", "proposed", "changes", "restart", "allowed", "teams"], "additionalProperties": true }, "configureOutcome": { "type": "object", "properties": { "status": { "enum": ["applied", "unchanged"] }, "requested": { "type": "object", "properties": { "model": { "type": "string" }, "thinking": { "type": "string" }, "team": { "type": "string" }, "mode": { "type": "string" } }, "additionalProperties": false }, "effective": { "$ref": "#/$defs/effectiveConfig" }, "restarted": { "type": "boolean" } }, "required": ["status", "requested", "effective", "restarted"], "additionalProperties": true }, "terminal": { "type": "object", "description": "A terminal as clients see it: ids, size and state, never a process id, shell path or host path.", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "title": { "type": "string", "maxLength": 64 }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "state": { "enum": ["running", "exited"] }, "attached": { "type": "boolean" }, "createdAt": { "type": "string", "format": "date-time" }, "lastActivityAt": { "type": "string", "format": "date-time" }, "expiresAt": { "type": "string", "format": "date-time" }, "exitCode": { "type": ["integer", "null"] }, "signal": { "type": ["integer", "null"] }, "endReason": { "enum": ["exited", "closed", "idle", "lifetime", "detached", "revoked", "disabled", "shutdown"] } }, "required": ["terminalId", "workspaceId", "title", "cols", "rows", "state", "attached", "createdAt", "lastActivityAt", "expiresAt"], "additionalProperties": false }, "terminalEvent": { "description": "params of a terminal.event notification (\xA712.10): sent only to the connection attached to the terminal.", "oneOf": [{ "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "output" }, "seq": { "type": "integer", "minimum": 1 }, "data": { "type": "string", "minLength": 1, "maxLength": 65536 } }, "required": ["terminalId", "type", "seq", "data"], "additionalProperties": false }, { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "exit" }, "seq": { "type": "integer", "minimum": 1 }, "exitCode": { "type": ["integer", "null"] }, "signal": { "type": ["integer", "null"] }, "reason": { "enum": ["exited", "closed", "idle", "lifetime", "detached", "revoked", "disabled", "shutdown"] } }, "required": ["terminalId", "type", "seq", "exitCode", "signal", "reason"], "additionalProperties": false }, { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "detached" }, "reason": { "enum": ["replaced", "slow_consumer"] } }, "required": ["terminalId", "type", "reason"], "additionalProperties": false }] } } };
5659
+ var METHODS_V1 = { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://alp.dev/schemas/methods-v1.json", "protocolVersion": 1, "errors": { "parseError": -32700, "invalidRequest": -32600, "methodNotFound": -32601, "invalidParams": -32602, "failed": 1e3, "notFound": 1001, "forbidden": 1003, "conflict": 1004, "unavailable": 1005, "protocol": 1006 }, "capabilities": { "attach.after": "session.attach accepts `after` and answers `cursor`/`reset`; envelopes kept in a tree timeline carry `cursor`.", "prompt.receipts": "session.prompt is answered at most once per (sessionId, clientMessageId) from a durable receipt; repeats answer the first outcome or outcome_unknown.", "extension.methods": "extension.register/unregister, and the daemon sends extension.invoke requests to the owning connection.", "team": "team.list: the teams a project can use, from the daemon host's built-ins, library and project.", "task": "task.list, task.create, task.update and task.gate.resolve on a project's .alp/tasks, written by the daemon under the task lock.", "library": "library.list/get/save/delete/duplicate/rename, library.skills.set and library.models on the daemon user's library and a project's .alp overrides; secrets are redacted on read.", "settings.language": "settings.language.get/set: the language the daemon user reads, in the daemon's ALP_HOME/settings.json.", "session.list.page": "session.list accepts `limit`, `cursor` and `query` and answers `nextCursor` while more sessions follow; without them it answers every session as before.", "question.watch": "question.watch: the connection is told of `question` and `question.resolved` in every tree (of a projectRoot when given), attached or not.", "question.watch.turns": "question.watch accepts `turns`: the connection is also told of `turn.ended` of every root in the trees it watches.", "session.attention": "question.watch accepts `attention`: its answer holds each watched root's finished or error attention, kept by alpd for every client, and the connection is told when one is set or cleared (an `attention` event); session.attention.clear acknowledges one.", "workspace.files": "workspace.files.search: files under a directory whose relative path matches a query; read-only, names only, links never followed.", "workspace.files.read": "workspace.files.list and workspace.files.read: the entries of a directory and the content of a UTF-8 text file (at most 1 MiB) under a directory; read-only, links never followed, .git, .env* and key or credential files refused, .gitignore'd paths hidden unless asked.", "workspace.files.browse": "workspace.files.find (every file and directory name under a directory, in pages of a snapshot, by its letters in order or by suffix), workspace.files.preview (a text, image or binary file of at most 50 MiB, its bytes in chunks of at most 8 MiB) and workspace.files.list's cursor and internalLinks (pages past 1000 entries; links whose real path is inside the directory, never outside); read-only, the block list and .gitignore as workspace.files.read. For the daemon host's own clients: the gateway exposes none of it.", "host.directories": "host.directories.search: directories of the daemon host whose path completes a typed path (absolute or under ~) or whose name matches a word under the home directory; names only, links never listed, bounded. For the daemon host's own clients: never remote.", "prompt.images": 'session.prompt takes inline image parts { type: "image", mimeType, data } (base64, no paths or URLs) within the image limits; a session snapshot says whether its runtime takes them in promptImages.', "library.project.write": "library save/delete/duplicate/rename accept policy project-data: only project-only pure-data agents and skills, no executable configuration, sidecars or library/built-in collisions.", "schedule": "schedule.create/list/get/cancel: one-shot continuations of a root session. alpd opens the turn by itself when the time comes; a job that comes due late says how late it is, and a job that cannot run says why.", "session.history": "Durable bounded backward envelope pages, persisted generation and numeric attach watermark.", "workspace.registry": "Daemon-owned project/workspace registry, durable pins, revision CAS and requestId replay.", "workspace.worktree": "Host-approved managed user worktrees; opt-in workspace.manage and named destination mappings.", "workspace.git": "workspace.git.status and workspace.git.diff: a registered workspace's read-only Git status and structured diff hunks by workspaceId; enumerated comparisons only, bounded (1 MiB per file, 2 MiB per page, 200 untracked files) with an opaque snapshot and next cursor; blocked secret paths withheld on both sides of a rename; no Git mutation.", "workspace.git.facts": "workspace.git.facts: the read-only Git checkout facts (repository root, branch, HEAD, remote, dirty) of an absolute host directory that need not be a registry workspace: a repository's top level (ok), a folder nested in one (not_repository_root, facts of the enclosing repository), no repository at or above it (unknown) or one alpd will not read (unsupported); owner only, never forwarded by a gateway; no Git mutation.", "attachments": 'attachment.begin/chunk/commit/abort/get/delete: daemon-owned immutable non-image attachments by opaque id, uploaded in bounded chunks, and session.prompt content parts `{ type: "attachment", attachmentId }`; daemon.hello carries `attachmentLimits`. Listed only with a home and a store, on macOS and Linux.', "session.fork": "session.fork: a new root whose conversation is a root's up to a completed turn (or a branch a rewind set aside), by native fork of Codex and Claude sessions; files are never copied or changed. Listed with a store and a runtime that forks native conversations, on macOS and Linux (not Windows).", "session.rewind": "session.rewind: a root's conversation from before a turn on, under the same session id; the later turns stay a recoverable branch, files are never changed, history generation advances (`history.reset` event). Same condition as session.fork.", "session.reload": "session.reload: restarts a live root's native process on its own conversation and configuration at the idle barrier (no turn, child, question, mail or parked work), keeping its session id, history and receipts; through the lifecycle journal. Listed with a store and a runtime that restarts a root on its own conversation, on macOS and Linux (not Windows).", "session.resumeCommand": "session.resumeCommand: the ALP CLI command (`alp attach <sessionId>`) that follows a session in a terminal, as argv and POSIX and Windows (cmd.exe) command lines built by alpd; for the clipboard only, never run, never a native runtime's command, credential, env or path.", "session.commands": `session.commands: the slash commands and skills a live session's composer offers after "/" (its runtime's, then its agent's ALP skills): names, descriptions and argument hints only, never a path.`, "session.configure.live": "session.configure takes model, thinking and team (with requestId and ifGeneration) besides mode, and session.configure.preview answers the configuration a change would run with: a live root's model, effort or team changes at the idle barrier (no turn, child, question, mail or parked work) through a controlled restart of its native process on the same conversation; the effective configuration is written only after the runtime took it, through the lifecycle journal (\xA712.9). Never another runtime and never more permissions. Listed with a store and a runtime that restarts a root with a new configuration, on macOS and Linux (not Windows).", "terminal": "terminal.create/list/attach/input/resize/close/revoke and terminal.event notifications: a real PTY shell on the daemon host as the daemon's account (a cwd is not a sandbox), served only when the host owner opted in (<ALP_HOME>/terminal.json allowRemoteTerminal) on macOS (full protection), Linux and Windows (best-effort).", "session.interrupt.turn": "session.interrupt accepts turnId and atomically cancels only that active turn, including its subtree. Conditional requests answer interrupted:true when canceled, false when the named turn is no longer active; false changes nothing. Without this capability clients must not send turnId or infer targeted cancellation from a legacy interrupt.", "terminal.capture": "terminal.capture: bounded daemon-owned rendered text, inclusive zero-based/negative line ranges; same terminal principal/host opt-in. Exceeding resource/result limits is an explicit refusal.", "terminal.watch": "terminal.watch/unwatch and terminal.changed: atomic scoped snapshot/subscription. Opaque per-subscription cursor, latest snapshot replaces invalidation history on reconnect/reset; older hosts use explicit polling fallback.", "catalog.live": "catalog.get answers the live model catalog (provider lists merged over ALP's static rows) with fetchedAt and per-provider status; catalog.refresh asks the providers again; alpd sends catalog.updated to every helloed connection when the catalog changes." }, "methods": { "assignment.recall": { "x-alp": { "effect": "mutation", "scope": { "kind": "project", "param": "projectRoot", "required": false, "alternatives": ["assignmentId", "taskId"] }, "idempotent": false, "risks": ["model call"] }, "params": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "taskId": { "type": "string" }, "projectRoot": { "type": "string" }, "question": { "type": "string" } }, "required": ["question"], "additionalProperties": true }, "result": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "agent": { "type": "string" }, "taskId": { "type": "string" }, "finishedAt": { "type": "string" }, "answer": { "type": "string" } }, "required": ["assignmentId", "agent", "finishedAt", "answer"], "additionalProperties": true } }, "board.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "pins": { "type": "array", "items": { "$ref": "#/$defs/pin" } } }, "required": ["pins"], "additionalProperties": true } }, "catalog.get": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "models": { "type": "array", "items": { "type": "object" } }, "modes": { "type": "array", "items": { "type": "object" } }, "thinkingOptions": {}, "defaultModel": { "type": "string" }, "fetchedAt": { "type": "string" }, "providers": { "type": "object" } }, "required": ["models", "modes", "defaultModel"], "additionalProperties": true } }, "catalog.refresh": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "models": { "type": "array", "items": { "type": "object" } }, "modes": { "type": "array", "items": { "type": "object" } }, "thinkingOptions": {}, "defaultModel": { "type": "string" }, "fetchedAt": { "type": "string" }, "providers": { "type": "object" } }, "required": ["models", "modes", "defaultModel"], "additionalProperties": true } }, "daemon.hello": { "x-alp": { "effect": "query", "scope": { "kind": "connection" }, "idempotent": true }, "params": { "type": "object", "properties": { "protocolVersion": { "const": 1 }, "client": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" } }, "required": ["name", "version"], "additionalProperties": true }, "capabilities": { "type": "array", "items": { "type": "string" } } }, "required": ["protocolVersion"], "additionalProperties": true }, "result": { "type": "object", "properties": { "protocolVersion": { "const": 1 }, "daemonVersion": { "type": "string" }, "pid": { "type": "integer" }, "hostname": { "type": "string" }, "capabilities": { "type": "array", "items": { "type": "string" } }, "promptImageLimits": { "type": "object", "description": "Optional effective inline image limits for this connection, when prompt.images is advertised. Missing on older peers. Byte limits count decoded bytes.", "properties": { "maxCount": { "type": "integer", "minimum": 0 }, "maxBytes": { "type": "integer", "minimum": 0 }, "maxTotalBytes": { "type": "integer", "minimum": 0 } }, "required": ["maxCount", "maxBytes", "maxTotalBytes"], "additionalProperties": false }, "attachmentLimits": { "type": "object", "description": "Effective attachment limits for this connection, when `attachments` is advertised. Byte limits count decoded bytes; times are milliseconds. An operator or a gateway may lower them, never raise them.", "properties": { "maxObjectBytes": { "type": "integer", "minimum": 0 }, "maxPerPrompt": { "type": "integer", "minimum": 0 }, "maxPromptBytes": { "type": "integer", "minimum": 0 }, "maxChunkBytes": { "type": "integer", "minimum": 0 }, "maxActiveUploads": { "type": "integer", "minimum": 0 }, "maxPrincipalBytes": { "type": "integer", "minimum": 0 }, "maxDaemonBytes": { "type": "integer", "minimum": 0 }, "uploadTimeoutMs": { "type": "integer", "minimum": 0 }, "unreferencedRetentionMs": { "type": "integer", "minimum": 0 }, "releasedGraceMs": { "type": "integer", "minimum": 0 } }, "required": ["maxObjectBytes", "maxPerPrompt", "maxPromptBytes", "maxChunkBytes", "maxActiveUploads", "maxPrincipalBytes", "maxDaemonBytes", "uploadTimeoutMs", "unreferencedRetentionMs", "releasedGraceMs"], "additionalProperties": false }, "terminalLimits": { "type": "object", "description": "Effective terminal limits for this connection, when `terminal` is advertised. Byte limits count UTF-8 bytes; times are milliseconds. An operator or a gateway may lower them, never raise them.", "properties": { "maxPerPrincipal": { "type": "integer", "minimum": 0 }, "maxPerDaemon": { "type": "integer", "minimum": 0 }, "maxInputBytes": { "type": "integer", "minimum": 0 }, "maxOutputFrameBytes": { "type": "integer", "minimum": 0 }, "replayBytes": { "type": "integer", "minimum": 0 }, "idleMs": { "type": "integer", "minimum": 0 }, "maxLifetimeMs": { "type": "integer", "minimum": 0 }, "reconnectMs": { "type": "integer", "minimum": 0 } }, "required": ["maxPerPrincipal", "maxPerDaemon", "maxInputBytes", "maxOutputFrameBytes", "replayBytes", "idleMs", "maxLifetimeMs", "reconnectMs"], "additionalProperties": false } }, "required": ["protocolVersion"], "additionalProperties": true } }, "daemon.pause": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": { "runtime": { "enum": ["codex", "claude", "acp", "antigravity"] }, "now": { "type": "boolean" }, "reason": { "type": "string" } }, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.pauses": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.resume": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": { "runtime": { "enum": ["codex", "claude", "acp", "antigravity"] } }, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/pauseState" } }, "daemon.shutdown": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "idempotent": true, "risks": ["admin"] }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "daemon.status": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "pid": { "type": "integer" }, "startedAt": { "type": "string" }, "version": { "type": "string" }, "protocolVersion": { "type": "integer" }, "sessions": { "type": "integer" }, "questions": { "type": "integer" }, "previousExit": { "type": "object", "properties": { "kind": { "enum": ["clean", "crash"] }, "at": { "type": "string" } }, "required": ["kind"], "additionalProperties": true }, "persistence": { "type": "object" }, "health": { "$ref": "#/$defs/health" } }, "required": ["pid", "startedAt", "version", "protocolVersion", "sessions", "questions", "health"], "additionalProperties": true } }, "daemon.usage": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true, "risks": ["refresh asks every provider (spawns on the daemon host)"] }, "params": { "type": "object", "properties": { "refresh": { "type": "boolean" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "providers": { "type": "array", "items": { "type": "object" } } }, "required": ["providers"], "additionalProperties": true } }, "extension.register": { "x-alp": { "effect": "mutation", "scope": { "kind": "connection" }, "idempotent": false, "risks": ["admin"] }, "params": { "type": "object", "properties": { "method": { "type": "string" } }, "required": ["method"], "additionalProperties": true }, "result": { "type": "object", "properties": { "registered": { "type": "string" } }, "required": ["registered"], "additionalProperties": true } }, "extension.unregister": { "x-alp": { "effect": "mutation", "scope": { "kind": "connection" }, "idempotent": false, "risks": ["admin"] }, "params": { "type": "object", "properties": { "method": { "type": "string" } }, "required": ["method"], "additionalProperties": true }, "result": { "type": "object", "properties": { "unregistered": { "type": "string" } }, "required": ["unregistered"], "additionalProperties": true } }, "library.delete": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": false }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "revision": { "type": "string" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "name", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "removed": { "const": true }, "now": { "enum": ["builtin", "library"] } }, "required": ["removed"], "additionalProperties": true } }, "library.duplicate": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope", "reads": ["builtin", "library"] }, "idempotent": false, "risks": ["exec-config when kind is mcp, hooks or providers"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "from": { "$ref": "#/$defs/entryName" }, "to": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "from", "to", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" } }, "required": ["revision"], "additionalProperties": true } }, "library.get": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true, "redacts": ["mcp /server/env/*", "mcp /server/headers/*", "providers /provider/env/*"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "scope": { "$ref": "#/$defs/libraryScope" } }, "required": ["kind", "name"], "additionalProperties": true }, "result": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "content": { "type": "object" }, "revision": { "$ref": "#/$defs/libraryRevision" }, "usedBy": { "type": "array", "items": { "type": "string" } }, "librarySkills": { "type": "array", "items": { "type": "string" } }, "secrets": { "type": "array", "items": { "type": "string" } } }, "required": ["kind", "name", "source", "content", "revision", "usedBy"], "additionalProperties": true } }, "library.list": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["kind"], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": ["string", "null"] }, "entries": { "type": "array", "items": { "$ref": "#/$defs/libraryEntryRow" } } }, "required": ["projectRoot", "entries"], "additionalProperties": true } }, "library.models": { "x-alp": { "effect": "query", "capability": "library", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "models": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "efforts": { "type": "array", "items": { "type": "string" } }, "effort": { "type": "string" } }, "required": ["id", "label", "efforts"], "additionalProperties": true } } }, "required": ["models"], "additionalProperties": true } }, "library.rename": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": false, "risks": ["exec-config when kind is mcp, hooks or providers"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "from": { "$ref": "#/$defs/entryName" }, "to": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "from", "to", "scope"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" } }, "required": ["revision"], "additionalProperties": true } }, "library.save": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "library-or-project", "param": "projectRoot", "selector": "scope" }, "idempotent": "with revision (a repeat fails revision_conflict)", "risks": ["exec-config when kind is mcp, hooks or providers, or agents naming mcp/hooks/provider", "writes every known project's .alp/settings.json when kind is teams and sync is known-projects"] }, "params": { "type": "object", "properties": { "kind": { "$ref": "#/$defs/libraryKind" }, "name": { "$ref": "#/$defs/entryName" }, "scope": { "$ref": "#/$defs/libraryScope" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "content": { "type": "object" }, "revision": { "$ref": "#/$defs/libraryRevision" }, "sync": { "enum": ["none", "known-projects"] }, "policy": { "enum": ["project-data"], "description": "Opt-in strict project-only non-executable mutation policy; requires library.project.write capability." } }, "required": ["kind", "name", "scope", "content"], "additionalProperties": true }, "result": { "type": "object", "properties": { "revision": { "$ref": "#/$defs/libraryRevision" }, "syncedProjects": { "type": "integer", "minimum": 0 }, "syncErrors": { "type": "array", "items": { "type": "string" } } }, "required": ["revision"], "additionalProperties": true } }, "library.skills.set": { "x-alp": { "effect": "mutation", "capability": "library", "scope": { "kind": "host" }, "writes": ["ALP_HOME/role-skills.json"], "idempotent": true }, "params": { "type": "object", "properties": { "agent": { "$ref": "#/$defs/entryName" }, "skills": { "type": "array", "items": { "$ref": "#/$defs/entryName" }, "maxItems": 100 } }, "required": ["agent", "skills"], "additionalProperties": true }, "result": { "type": "object", "properties": { "skills": { "type": "array", "items": { "type": "string" } } }, "required": ["skills"], "additionalProperties": true } }, "question.answer": { "x-alp": { "effect": "mutation", "scope": { "kind": "question", "param": "questionId", "prefix": true }, "idempotent": false }, "params": { "type": "object", "properties": { "questionId": { "type": "string" }, "text": { "type": "string" }, "dismiss": { "type": "boolean" }, "reason": { "type": "string" } }, "required": ["questionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "questionId": { "type": "string" } }, "required": ["questionId"], "additionalProperties": true } }, "question.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } } }, "required": ["questions"], "additionalProperties": true } }, "question.watch": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true, "capability": "question.watch" }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "turns": { "type": "boolean" }, "attention": { "type": "boolean" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } }, "attention": { "type": "array", "items": { "type": "object", "properties": { "sessionId": { "type": "string" }, "attention": { "$ref": "#/$defs/attention" } }, "required": ["sessionId", "attention"], "additionalProperties": true } } }, "required": ["questions"], "additionalProperties": true } }, "session.attention.clear": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true, "capability": "session.attention" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "at": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "cleared": { "type": "boolean" } }, "required": ["cleared"], "additionalProperties": true } }, "schedule.create": { "x-alp": { "effect": "mutation", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["ALP_HOME/schedules"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "dueAt": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?(Z|[+-]\\d{2}:\\d{2})$" }, "prompt": { "type": "string", "minLength": 1, "maxLength": 8e3, "pattern": "\\S" } }, "required": ["projectRoot", "sessionId", "dueAt", "prompt"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "schedule.list": { "x-alp": { "effect": "query", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "status": { "enum": ["pending", "delivered", "failed", "cancelled"] } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "jobs": { "type": "array", "items": { "$ref": "#/$defs/scheduleJob" } } }, "required": ["jobs"], "additionalProperties": true } }, "schedule.get": { "x-alp": { "effect": "query", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["id", "projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "schedule.cancel": { "x-alp": { "effect": "mutation", "capability": "schedule", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["ALP_HOME/schedules"], "idempotent": true }, "params": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["id", "projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "job": { "$ref": "#/$defs/scheduleJob" } }, "required": ["job"], "additionalProperties": true } }, "session.archive": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "archived": { "type": "boolean" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.attach": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "replay": { "type": "boolean" }, "after": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "generation": { "type": "string", "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "cursor": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "reset": { "const": true } }, "required": ["session", "cursor"], "additionalProperties": true } }, "session.close": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": false }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "session.compact": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "risks": ["main writes a checkpoint in a turn of its own, then its context is compacted natively or replaced by a fresh conversation seeded with the checkpoint"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "status": { "enum": ["started", "deferred", "running"] } }, "required": ["status"], "additionalProperties": false } }, "session.commands": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.commands", "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "commands": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "^[^\\s\\u0000-\\u001f\\u007f]+$" }, "description": { "type": "string", "maxLength": 4096 }, "argumentHint": { "type": "string", "maxLength": 256 }, "kind": { "enum": ["command", "skill"] } }, "required": ["name", "description", "kind"], "additionalProperties": false } } }, "required": ["commands"], "additionalProperties": false } }, "session.configure": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": "mode alone: yes; with model, thinking or team: with requestId", "risks": ["with model, thinking or team: restarts the root's native process on its own conversation; never another runtime, never more permissions"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "mode": { "type": "string" }, "model": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Native model, or runtime-prefixed (codex:/claude:); the session's own runtime only (capability session.configure.live)." }, "thinking": { "type": "string", "minLength": 1, "maxLength": 200, "description": "An effort the model takes (capability session.configure.live)." }, "team": { "type": "string", "minLength": 1, "maxLength": 200, "description": "A team id the daemon host defines (capability session.configure.live); no path or configuration." }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": ["sessionId"], "anyOf": [{ "not": { "anyOf": [{ "required": ["model"] }, { "required": ["thinking"] }, { "required": ["team"] }] } }, { "required": ["requestId", "ifGeneration"] }], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/session" }, "configured": { "$ref": "#/$defs/configureOutcome" }, "duplicate": { "const": true } }, "required": ["session"], "additionalProperties": true } }, "session.configure.preview": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.configure.live", "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "mode": { "type": "string" }, "model": { "type": "string", "minLength": 1, "maxLength": 200 }, "thinking": { "type": "string", "minLength": 1, "maxLength": 200 }, "team": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "preview": { "$ref": "#/$defs/configurePreview" } }, "required": ["preview"], "additionalProperties": true } }, "session.create": { "x-alp": { "effect": "mutation", "scope": { "kind": "project", "param": "spec.cwd" }, "idempotent": false, "risks": ["exec: spec.env and stdio spec.mcpServers run on the daemon host", "spec.workdir/writeRoot/copy*/restore/keepThread are internal"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$" }, "spec": { "anyOf": [{ "$ref": "#/$defs/spec" }, { "type": "object", "properties": { "agent": { "type": "string" }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "persist": { "type": "boolean" }, "workflow": { "type": "string" } }, "required": [], "additionalProperties": false }] }, "history": { "enum": ["skip", "replay"] }, "delegation": { "type": "boolean" }, "resume": { "type": "boolean" }, "workspaceId": { "type": "string" } }, "required": ["spec"], "additionalProperties": true, "anyOf": [{ "required": ["workspaceId"] }, { "properties": { "spec": { "$ref": "#/$defs/spec" } } }] }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/session" }, "attached": { "type": "boolean" }, "resumed": { "const": true }, "durable": { "type": "boolean" } }, "required": ["session", "attached"], "additionalProperties": true } }, "session.get": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.interrupt": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "turnId": { "type": "string", "minLength": 1 } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "interrupted": { "type": "boolean" } }, "required": [], "additionalProperties": true } }, "session.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": false }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "rootsOnly": { "type": "boolean" }, "includeClosed": { "type": "boolean" }, "includeArchived": { "type": "boolean" }, "limit": { "type": "integer", "minimum": 1, "maximum": 1e3 }, "cursor": { "type": "string", "minLength": 1, "maxLength": 1024 }, "query": { "type": "string", "maxLength": 200 }, "projectRoots": { "type": "array", "items": { "type": "string" }, "minItems": 1, "maxItems": 1024 } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "sessions": { "type": "array", "items": { "$ref": "#/$defs/sessionSummary" } }, "nextCursor": { "type": "string", "minLength": 1 } }, "required": ["sessions"], "additionalProperties": true } }, "session.log": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "rootId": { "type": "string" }, "entries": { "type": "array", "items": { "type": "object" } } }, "required": ["rootId", "entries"], "additionalProperties": true } }, "session.message": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": false }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "text": { "type": "string" } }, "required": ["sessionId", "text"], "additionalProperties": true }, "result": { "type": "object", "properties": {}, "required": [], "additionalProperties": true } }, "session.preview": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "spec.cwd" }, "idempotent": true }, "params": { "type": "object", "properties": { "spec": { "$ref": "#/$defs/spec" } }, "required": ["spec"], "additionalProperties": true }, "result": { "type": "object", "properties": { "preview": { "$ref": "#/$defs/preview" } }, "required": ["preview"], "additionalProperties": true } }, "session.prompt": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": "with prompt.receipts" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "clientMessageId": { "type": "string" }, "delivery": { "enum": ["auto", "steer"] }, "content": { "type": "array", "items": { "anyOf": [{ "type": "object", "properties": { "type": { "const": "text" }, "text": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "$ref": "#/$defs/promptImage" }, { "type": "object", "properties": { "type": { "const": "attachment" }, "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" } }, "required": ["type", "attachmentId"], "additionalProperties": false }, { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["text", "image", "attachment"] } } }, "required": ["type"], "additionalProperties": true }] } }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "clientMessageId", "content"], "additionalProperties": true }, "result": { "type": "object", "properties": { "outcome": { "enum": ["accepted", "failed"] }, "error": { "$ref": "#/$defs/alpError" }, "duplicate": { "type": "boolean" }, "durable": { "type": "boolean" } }, "required": [], "additionalProperties": true } }, "session.release": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "closed": { "type": "boolean" } }, "required": ["closed"], "additionalProperties": true } }, "session.rename": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "title": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "\\S" } }, "required": ["sessionId", "title"], "additionalProperties": true }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" } }, "required": ["session"], "additionalProperties": true } }, "session.status": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" } }, "required": ["sessionId"], "additionalProperties": true }, "result": { "type": "object", "properties": { "status": { "$ref": "#/$defs/treeStatus" } }, "required": ["status"], "additionalProperties": true } }, "settings.language.get": { "x-alp": { "effect": "query", "capability": "settings.language", "scope": { "kind": "host" }, "idempotent": true }, "params": { "type": "object", "properties": {}, "required": [], "additionalProperties": true }, "result": { "$ref": "#/$defs/languageSetting" } }, "settings.language.set": { "x-alp": { "effect": "mutation", "capability": "settings.language", "scope": { "kind": "host" }, "writes": ["ALP_HOME/settings.json"], "idempotent": true }, "params": { "type": "object", "properties": { "language": { "anyOf": [{ "type": "string", "minLength": 1, "maxLength": 40, "pattern": "\\S" }, { "type": "null" }] } }, "required": ["language"], "additionalProperties": true }, "result": { "$ref": "#/$defs/languageSetting" } }, "task.create": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": "per requestId within one alpd process (10 minutes)" }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "title": { "type": "string", "minLength": 1, "maxLength": 200, "pattern": "\\S" }, "priority": { "type": "integer", "minimum": 0, "maximum": 4 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["projectRoot", "title"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "duplicate": { "const": true } }, "required": ["id"], "additionalProperties": true } }, "task.gate.resolve": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "id": { "$ref": "#/$defs/taskId" }, "gate": { "type": "string", "minLength": 1, "maxLength": 128 }, "note": { "type": "string", "maxLength": 2e3 }, "ifRev": { "type": "integer", "minimum": 0 }, "choice": { "type": "string", "minLength": 1, "maxLength": 200 }, "reject": { "type": "boolean" }, "channel": { "type": "string", "enum": ["paseo", "web"] } }, "required": ["projectRoot", "id", "gate"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "status": { "type": "string" }, "rev": { "type": "integer", "minimum": 0 } }, "required": ["id", "status", "rev"], "additionalProperties": true } }, "task.list": { "x-alp": { "effect": "query", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "tasks": { "type": "array", "items": { "$ref": "#/$defs/taskRow" } }, "unreadable": { "type": "array", "items": { "type": "object", "properties": { "file": { "type": "string" }, "error": { "type": "string" } }, "required": ["file", "error"], "additionalProperties": true } }, "revision": { "type": "string" } }, "required": ["projectRoot", "tasks", "unreadable", "revision"], "additionalProperties": true } }, "task.update": { "x-alp": { "effect": "mutation", "capability": "task", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "writes": ["<projectRoot>/.alp/tasks"], "idempotent": false }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" }, "id": { "$ref": "#/$defs/taskId" }, "action": { "enum": ["close", "reopen"] }, "note": { "type": "string", "maxLength": 2e3 }, "ifRev": { "type": "integer", "minimum": 0 } }, "required": ["projectRoot", "id", "action"], "additionalProperties": true }, "result": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "status": { "type": "string" }, "rev": { "type": "integer", "minimum": 0 }, "landed": { "type": "string" } }, "required": ["id", "status", "rev"], "additionalProperties": true } }, "team.list": { "x-alp": { "effect": "query", "capability": "team", "scope": { "kind": "project", "param": "projectRoot", "required": false, "reads": ["builtin", "library"] }, "idempotent": true }, "params": { "type": "object", "properties": { "projectRoot": { "$ref": "#/$defs/projectRoot" } }, "required": [], "additionalProperties": true }, "result": { "type": "object", "properties": { "projectRoot": { "type": ["string", "null"] }, "teams": { "type": "array", "items": { "$ref": "#/$defs/teamRow" } } }, "required": ["projectRoot", "teams"], "additionalProperties": true } }, "workspace.files.search": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files", "risks": ["lists file names of the directory (not contents)"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "query": { "type": "string", "maxLength": 200 }, "limit": { "type": "integer", "minimum": 1, "maximum": 100 } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "files": { "type": "array", "maxItems": 100, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 } }, "required": ["path"], "additionalProperties": true } }, "truncated": { "type": "boolean" } }, "required": ["files"], "additionalProperties": true } }, "workspace.files.list": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.read", "risks": ["lists names, kinds, sizes and times of a directory's entries (not contents)"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "includeIgnored": { "type": "boolean" }, "cursor": { "type": "string", "minLength": 1, "maxLength": 1024 }, "internalLinks": { "type": "boolean" } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "entries": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "name": { "type": "string", "minLength": 1 }, "path": { "type": "string", "minLength": 1 }, "kind": { "enum": ["file", "directory"] }, "size": { "type": "integer", "minimum": 0 }, "modifiedAt": { "type": "string" }, "target": { "type": "string", "minLength": 1 } }, "required": ["name", "path", "kind"], "additionalProperties": true } }, "truncated": { "type": "boolean" }, "nextCursor": { "type": "string", "minLength": 1, "maxLength": 1024 }, "target": { "type": "string", "minLength": 1 } }, "required": ["entries"], "additionalProperties": true } }, "workspace.files.read": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.read", "risks": ["returns the content of a text file under the directory"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "includeIgnored": { "type": "boolean" } }, "required": ["projectRoot", "path"], "additionalProperties": true }, "result": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 }, "content": { "type": "string" }, "size": { "type": "integer", "minimum": 0, "maximum": 1048576 }, "modifiedAt": { "type": "string" } }, "required": ["path", "content", "size"], "additionalProperties": true } }, "workspace.files.find": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.browse", "risks": ["lists every file and directory name of the directory (not contents)"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "query": { "type": "string", "maxLength": 200 }, "kinds": { "type": "array", "items": { "enum": ["file", "directory"] }, "minItems": 1, "maxItems": 2, "uniqueItems": true }, "matchMode": { "enum": ["subsequence", "suffix"] }, "limit": { "type": "integer", "minimum": 1, "maximum": 1e3 }, "cursor": { "type": "string", "minLength": 1, "maxLength": 256 } }, "required": ["projectRoot"], "additionalProperties": true }, "result": { "type": "object", "properties": { "entries": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 }, "kind": { "enum": ["file", "directory"] } }, "required": ["path", "kind"], "additionalProperties": true } }, "nextCursor": { "type": "string", "minLength": 1, "maxLength": 256 }, "truncated": { "type": "boolean" } }, "required": ["entries"], "additionalProperties": true } }, "workspace.files.preview": { "x-alp": { "effect": "query", "scope": { "kind": "project", "param": "projectRoot", "required": true }, "idempotent": true, "capability": "workspace.files.browse", "risks": ["returns the bytes of a file under the directory, text, image or binary, up to 50 MiB in chunks"] }, "params": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "includeIgnored": { "type": "boolean" }, "internalLinks": { "type": "boolean" }, "maxBytes": { "type": "integer", "minimum": 1, "maximum": 52428800 }, "offset": { "type": "integer", "minimum": 0, "maximum": 52428800 }, "revision": { "type": "string", "minLength": 1, "maxLength": 64 } }, "required": ["projectRoot", "path"], "additionalProperties": true }, "result": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 }, "target": { "type": "string", "minLength": 1 }, "kind": { "enum": ["text", "image", "binary"] }, "mimeType": { "type": "string", "minLength": 1, "maxLength": 255 }, "size": { "type": "integer", "minimum": 0, "maximum": 52428800 }, "modifiedAt": { "type": "string" }, "revision": { "type": "string", "minLength": 1, "maxLength": 64 }, "encoding": { "enum": ["base64", "none"] }, "content": { "type": "string", "maxLength": 11184812 }, "offset": { "type": "integer", "minimum": 0 }, "nextOffset": { "type": "integer", "minimum": 1 } }, "required": ["path", "kind", "mimeType", "size", "modifiedAt", "revision", "encoding"], "additionalProperties": true } }, "host.directories.search": { "x-alp": { "effect": "query", "scope": { "kind": "host" }, "idempotent": true, "capability": "host.directories", "risks": ["lists names of directories on the daemon host outside any workspace"] }, "params": { "type": "object", "properties": { "query": { "type": "string", "maxLength": 4096 }, "limit": { "type": "integer", "minimum": 1, "maximum": 100 } }, "required": ["query"], "additionalProperties": true }, "result": { "type": "object", "properties": { "entries": { "type": "array", "maxItems": 100, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1 } }, "required": ["path"], "additionalProperties": true } }, "truncated": { "type": "boolean" } }, "required": ["entries"], "additionalProperties": true } }, "session.history": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "idempotent": true, "capability": "session.history" }, "params": { "type": "object", "properties": { "sessionId": { "type": "string" }, "before": { "type": "string", "maxLength": 4096 }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "maxBytes": { "type": "integer", "minimum": 2048, "maximum": 524288 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "generation": { "type": "string" }, "items": { "type": "array", "maxItems": 500, "items": { "oneOf": [{ "$ref": "#/$defs/envelope" }, { "type": "object", "properties": { "cursor": { "type": "integer", "minimum": 0 }, "oversized": { "type": "object", "properties": { "bytes": { "type": "integer", "minimum": 1 } }, "required": ["bytes"] } }, "required": ["cursor", "oversized"], "additionalProperties": false }] } }, "olderCursor": { "type": "string" }, "hasOlder": { "type": "boolean" }, "tipCursor": { "type": "integer", "minimum": 0 } }, "required": ["generation", "items", "hasOlder", "tipCursor"], "additionalProperties": true } }, "project.list": { "params": { "type": "object", "properties": { "cursor": { "type": "string", "pattern": "^[0-9]+$" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "projectRoots": { "type": "array", "items": { "type": "string" } }, "includeRemoved": { "type": "boolean" } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "projects": { "type": "array", "items": { "$ref": "#/$defs/registryProject" } }, "revision": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 }, "nextCursor": { "type": ["string", "null"] } }, "required": ["projects", "revision", "total", "nextCursor"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.list": { "params": { "type": "object", "properties": { "cursor": { "type": "string", "pattern": "^[0-9]+$" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "projectRoots": { "type": "array", "items": { "type": "string" } }, "includeArchived": { "type": "boolean" } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspaces": { "type": "array", "items": { "$ref": "#/$defs/registryWorkspace" } }, "revision": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 }, "nextCursor": { "type": ["string", "null"] } }, "required": ["workspaces", "revision", "total", "nextCursor"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.get": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "project.register": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "directory": { "type": "string" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["directory", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "project": { "$ref": "#/$defs/registryProject" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["project", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "project.remove": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "projectId": { "type": "string" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["projectId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "project": { "$ref": "#/$defs/registryProject" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["project", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "workspace.update": { "params": { "type": "object", "properties": { "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "workspaceId": { "type": "string" }, "title": { "type": ["string", "null"] }, "pinned": { "type": "boolean" }, "archived": { "type": "boolean" }, "authorizedRoots": { "type": "array", "items": { "type": "string" } } }, "required": ["workspaceId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.registry", "idempotent": true } }, "registry.owner": { "params": { "type": "object", "properties": { "operation": { "enum": ["project.add", "project.rename", "project.remove", "workspace.create", "workspace.update", "placement.prepare", "placement.assign", "label.assign", "label.update", "label.delete", "placement.remove"] }, "args": { "type": "object" }, "requestId": { "type": "string" }, "ifRevision": { "type": "integer", "minimum": 0 } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "registry": { "type": "object" } }, "required": ["registry"] }, "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "capability": "workspace.registry", "idempotent": false } }, "workspace.worktree.create": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "mappingId": { "type": "string", "maxLength": 64 }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId", "requestId", "ifRevision", "mappingId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 }, "filesRemoved": { "type": "boolean" }, "branchRetained": { "type": "boolean" } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "workspace.worktree.remove": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "ifRevision": { "type": "integer", "minimum": 0 }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId", "requestId", "ifRevision"], "additionalProperties": false }, "result": { "type": "object", "properties": { "workspace": { "$ref": "#/$defs/registryWorkspace" }, "revision": { "type": "integer", "minimum": 0 }, "filesRemoved": { "type": "boolean" }, "branchRetained": { "type": "boolean" } }, "required": ["workspace", "revision"], "additionalProperties": false }, "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "workspace.worktree.options": { "params": { "type": "object", "properties": { "workspaceId": { "type": "string" }, "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "principalEpoch": { "type": "string" } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "mappingIds": { "type": "array", "items": { "type": "string" } } }, "required": ["mappingIds"], "additionalProperties": false }, "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.worktree", "idempotent": true } }, "registry.worktree": { "params": { "type": "object", "properties": { "principalId": { "type": "string" }, "mappingIds": { "type": "array", "items": { "type": "string" } }, "authorizedRoots": { "type": "array", "items": { "type": "string" } }, "principalEpoch": { "type": "string" } }, "additionalProperties": false }, "result": { "type": "object", "additionalProperties": true }, "x-alp": { "effect": "query", "scope": { "kind": "host" }, "capability": "workspace.worktree" } }, "workspace.git.status": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.git", "idempotent": true, "risks": ["lists the changed file paths, branch and remote of a workspace checkout"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1 } }, "required": ["workspaceId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "state": { "enum": ["repository", "not_repository", "unsupported"] }, "reason": { "type": "string" }, "branch": { "type": ["string", "null"] }, "detached": { "type": "boolean" }, "head": { "type": ["string", "null"] }, "upstream": { "type": ["object", "null"], "properties": { "ref": { "type": "string" }, "ahead": { "type": "integer", "minimum": 0 }, "behind": { "type": "integer", "minimum": 0 } }, "required": ["ref", "ahead", "behind"], "additionalProperties": false }, "baseRef": { "type": ["string", "null"] }, "aheadBehind": { "type": ["object", "null"], "properties": { "ahead": { "type": "integer", "minimum": 0 }, "behind": { "type": "integer", "minimum": 0 } }, "required": ["ahead", "behind"], "additionalProperties": false }, "hasRemote": { "type": "boolean" }, "remoteUrl": { "type": ["string", "null"] }, "dirty": { "type": "boolean" }, "files": { "type": "array", "maxItems": 1e3, "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "oldPath": { "type": "string", "minLength": 1, "maxLength": 4096 }, "change": { "enum": ["modified", "added", "deleted", "renamed", "copied", "typechange", "untracked", "conflicted"] }, "staged": { "type": "boolean" }, "unstaged": { "type": "boolean" } }, "required": ["path", "change", "staged", "unstaged"], "additionalProperties": false } }, "hiddenCount": { "type": "integer", "minimum": 0 }, "truncated": { "type": "boolean" }, "snapshot": { "type": "string", "maxLength": 1024 } }, "required": ["state", "branch", "detached", "head", "upstream", "baseRef", "aheadBehind", "hasRemote", "remoteUrl", "dirty", "files", "hiddenCount", "truncated", "snapshot"], "additionalProperties": false } }, "workspace.git.facts": { "x-alp": { "effect": "query", "scope": { "kind": "host", "param": "directory" }, "capability": "workspace.git.facts", "idempotent": true, "risks": ["names the host path, branch and remote of a directory's enclosing Git checkout (owner only, never remote)"] }, "params": { "type": "object", "properties": { "directory": { "type": "string", "minLength": 1, "maxLength": 4096 } }, "required": ["directory"], "additionalProperties": false }, "result": { "oneOf": [{ "type": "object", "properties": { "kind": { "const": "ok" }, "repoRoot": { "type": "string", "minLength": 1 }, "branch": { "type": ["string", "null"] }, "detached": { "type": "boolean" }, "head": { "type": ["string", "null"] }, "hasRemote": { "type": "boolean" }, "remoteUrl": { "type": ["string", "null"] }, "dirty": { "type": "boolean" } }, "required": ["kind", "repoRoot", "branch", "detached", "head", "hasRemote", "remoteUrl", "dirty"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "const": "not_repository_root" }, "repoRoot": { "type": "string", "minLength": 1 }, "branch": { "type": ["string", "null"] }, "detached": { "type": "boolean" }, "head": { "type": ["string", "null"] }, "hasRemote": { "type": "boolean" }, "remoteUrl": { "type": ["string", "null"] }, "dirty": { "type": "boolean" } }, "required": ["kind", "repoRoot", "branch", "detached", "head", "hasRemote", "remoteUrl", "dirty"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "const": "unknown" } }, "required": ["kind"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "const": "unsupported" }, "reason": { "enum": ["worktree_elsewhere", "inside_git_dir"] } }, "required": ["kind", "reason"], "additionalProperties": false }] } }, "workspace.git.diff": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "workspace.git", "idempotent": true, "risks": ["returns changed file content of a workspace checkout as diff hunks, including deleted and historical lines"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1 }, "compare": { "type": "object", "properties": { "mode": { "enum": ["uncommitted", "staged", "unstaged", "base"] }, "baseRef": { "type": "string", "minLength": 1, "maxLength": 255 }, "ignoreWhitespace": { "type": "boolean" } }, "required": ["mode"], "additionalProperties": false }, "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "cursor": { "type": "string", "minLength": 1, "maxLength": 1024 } }, "required": ["workspaceId", "compare"], "additionalProperties": false }, "result": { "type": "object", "properties": { "compare": { "type": "object", "properties": { "mode": { "enum": ["uncommitted", "staged", "unstaged", "base"] }, "baseRef": { "type": "string" }, "ignoreWhitespace": { "type": "boolean" } }, "required": ["mode", "ignoreWhitespace"], "additionalProperties": false }, "snapshot": { "type": "string", "maxLength": 1024 }, "files": { "type": "array", "items": { "type": "object", "properties": { "path": { "type": "string", "minLength": 1, "maxLength": 4096 }, "oldPath": { "type": "string", "minLength": 1, "maxLength": 4096 }, "change": { "enum": ["modified", "added", "deleted", "renamed", "copied", "typechange", "untracked", "conflicted"] }, "kind": { "enum": ["text", "binary", "too_large", "withheld", "symlink", "submodule"] }, "additions": { "type": "integer", "minimum": 0 }, "deletions": { "type": "integer", "minimum": 0 }, "hunks": { "type": "array", "items": { "type": "object", "properties": { "oldStart": { "type": "integer", "minimum": 0 }, "oldCount": { "type": "integer", "minimum": 0 }, "newStart": { "type": "integer", "minimum": 0 }, "newCount": { "type": "integer", "minimum": 0 }, "context": { "type": "string" }, "lines": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": ["add", "remove", "context"] }, "content": { "type": "string" }, "noNewline": { "const": true } }, "required": ["type", "content"], "additionalProperties": false } } }, "required": ["oldStart", "oldCount", "newStart", "newCount", "lines"], "additionalProperties": false } } }, "required": ["path", "change", "kind", "additions", "deletions", "hunks"], "additionalProperties": false } }, "hiddenCount": { "type": "integer", "minimum": 0 }, "truncated": { "type": "boolean" }, "nextCursor": { "type": "string", "minLength": 1, "maxLength": 1024 } }, "required": ["compare", "snapshot", "files", "hiddenCount", "truncated"], "additionalProperties": false } }, "attachment.begin": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "attachments", "idempotent": "with requestId", "risks": ["reserves stored bytes of the daemon host for a file the client uploads"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_.:-]{1,128}$" }, "name": { "type": "string", "minLength": 1, "maxLength": 1024 }, "size": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "mimeType": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$" }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "requestId": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "name", "size", "mimeType", "requestId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "state": { "enum": ["uploading", "committed"] }, "received": { "type": "integer", "minimum": 0 }, "size": { "type": "integer", "minimum": 0 }, "maxChunkBytes": { "type": "integer", "minimum": 1 }, "expiresAt": { "type": "string" }, "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" } }, "required": ["uploadId", "state", "received", "size", "maxChunkBytes"], "additionalProperties": false } }, "attachment.chunk": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": "same offset and bytes", "risks": ["writes uploaded bytes to the daemon host"] }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "offset": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "data": { "type": "string", "minLength": 4, "maxLength": 349528, "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId", "offset", "data"], "additionalProperties": false }, "result": { "type": "object", "properties": { "received": { "type": "integer", "minimum": 0 }, "size": { "type": "integer", "minimum": 0 } }, "required": ["received", "size"], "additionalProperties": false } }, "attachment.commit": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": true }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId", "sha256"], "additionalProperties": false }, "result": { "type": "object", "properties": { "attachment": { "$ref": "#/$defs/attachment" } }, "required": ["attachment"], "additionalProperties": false } }, "attachment.abort": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": false }, "params": { "type": "object", "properties": { "uploadId": { "type": "string", "pattern": "^upl_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["uploadId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "aborted": { "const": true } }, "required": ["aborted"], "additionalProperties": false } }, "attachment.get": { "x-alp": { "effect": "query", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": true }, "params": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["attachmentId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "attachment": { "$ref": "#/$defs/attachment" } }, "required": ["attachment"], "additionalProperties": false } }, "attachment.delete": { "x-alp": { "effect": "mutation", "scope": { "kind": "session" }, "capability": "attachments", "idempotent": false }, "params": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["attachmentId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "deleted": { "const": true } }, "required": ["deleted"], "additionalProperties": false } }, "session.fork": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.fork", "idempotent": "with requestId", "risks": ["creates a new root session in the source workspace or a granted destination workspace; files are never copied, restored or changed"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "boundary": { "oneOf": [{ "type": "object", "properties": { "throughTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["throughTurnId"], "additionalProperties": false }, { "type": "object", "properties": { "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["beforeTurnId"], "additionalProperties": false }] }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "newSessionId": { "type": "string", "pattern": "^[\\w.:-]{1,128}$" }, "title": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the bound project must be one of them." } }, "required": ["sessionId", "requestId", "ifGeneration"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "forkedFrom": { "$ref": "#/$defs/forkProvenance" }, "duplicate": { "const": true } }, "required": ["session", "forkedFrom"], "additionalProperties": true } }, "session.rewind": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.rewind", "idempotent": "with requestId", "risks": ["replaces the conversation the runtime continues from; the later turns stay recoverable and no file is changed"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["sessionId", "requestId", "ifGeneration", "beforeTurnId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "generation": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "branch": { "$ref": "#/$defs/conversationBranch" }, "duplicate": { "const": true } }, "required": ["session", "generation", "branch"], "additionalProperties": true } }, "session.reload": { "x-alp": { "effect": "mutation", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.reload", "idempotent": "with requestId", "risks": ["restarts the root's native process; its conversation, configuration, history and receipts are kept"] }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "ifGeneration": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": ["sessionId", "requestId", "ifGeneration"], "additionalProperties": false }, "result": { "type": "object", "properties": { "session": { "$ref": "#/$defs/sessionSummary" }, "duplicate": { "const": true } }, "required": ["session"], "additionalProperties": true } }, "session.resumeCommand": { "x-alp": { "effect": "query", "scope": { "kind": "session", "param": "sessionId" }, "capability": "session.resumeCommand", "idempotent": true }, "params": { "type": "object", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["sessionId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "argv": { "type": "array", "minItems": 1, "maxItems": 16, "items": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "^[^\\u0000-\\u001f\\u007f]+$" } }, "posix": { "type": "string", "minLength": 1, "maxLength": 2048 }, "windows": { "type": "string", "minLength": 1, "maxLength": 2048 }, "display": { "type": "string", "minLength": 1, "maxLength": 2048 }, "platform": { "enum": ["posix", "windows"] } }, "required": ["argv", "posix", "windows", "display", "platform"], "additionalProperties": false } }, "terminal.create": { "x-alp": { "effect": "mutation", "scope": { "kind": "project" }, "capability": "terminal", "idempotent": false, "risks": ["starts a shell on the daemon host as the daemon's account: host-level execution, not confined to the workspace"] }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "requestId": { "type": "string", "minLength": 1, "maxLength": 128 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." }, "protectionAcknowledgment": { "const": "linux-root-only-v1", "description": "Deprecated and ignored: accepted for compatibility with older clients. Reduced-protection terminals open without it; clients disclose the terminal's protection field instead." } }, "required": ["workspaceId", "cols", "rows", "requestId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminal": { "$ref": "#/$defs/terminal" } }, "required": ["terminal"], "additionalProperties": false } }, "terminal.list": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "terminal", "idempotent": true }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminals": { "type": "array", "items": { "$ref": "#/$defs/terminal" } } }, "required": ["terminals"], "additionalProperties": false } }, "terminal.attach": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": true, "risks": ["streams the terminal's output, which may show anything the shell printed"] }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "after": { "type": "integer", "minimum": 0 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." }, "protectionAcknowledgment": { "const": "linux-root-only-v1", "description": "Deprecated and ignored: accepted for compatibility with older clients. Reduced-protection terminals open without it; clients disclose the terminal's protection field instead." } }, "required": ["terminalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminal": { "$ref": "#/$defs/terminal" }, "nextSeq": { "type": "integer", "minimum": 1 }, "gap": { "type": "object", "properties": { "fromSeq": { "type": "integer", "minimum": 1 }, "toSeq": { "type": "integer", "minimum": 1 } }, "required": ["fromSeq", "toSeq"], "additionalProperties": false } }, "required": ["terminal", "nextSeq"], "additionalProperties": false } }, "terminal.input": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": false, "risks": ["types into a host shell: runs any command as the daemon's account"] }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "data": { "type": "string", "minLength": 1, "maxLength": 65536 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId", "data"], "additionalProperties": false }, "result": { "type": "object", "properties": { "bytes": { "type": "integer", "minimum": 1 } }, "required": ["bytes"], "additionalProperties": false } }, "terminal.resize": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": true }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId", "cols", "rows"], "additionalProperties": false }, "result": { "type": "object", "properties": { "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 } }, "required": ["cols", "rows"], "additionalProperties": false } }, "terminal.close": { "x-alp": { "effect": "mutation", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal", "idempotent": false }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." } }, "required": ["terminalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "closed": { "const": true } }, "required": ["closed"], "additionalProperties": false } }, "terminal.revoke": { "x-alp": { "effect": "mutation", "scope": { "kind": "host" }, "capability": "terminal", "idempotent": true, "risks": ["kills every terminal of a principal; for a trusted gateway, never exposed"] }, "params": { "type": "object", "properties": { "principalId": { "type": "string", "minLength": 1, "maxLength": 200 } }, "required": ["principalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "closed": { "type": "integer", "minimum": 0 } }, "required": ["closed"], "additionalProperties": false } }, "terminal.capture": { "x-alp": { "effect": "query", "scope": { "kind": "terminal", "param": "terminalId" }, "capability": "terminal.capture", "idempotent": true, "risks": ["Reads terminal screen text, which may contain secrets the shell printed"] }, "params": { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." }, "start": { "type": "integer" }, "end": { "type": "integer" }, "stripAnsi": { "type": "boolean" } }, "required": ["terminalId"], "additionalProperties": false }, "result": { "type": "object", "properties": { "lines": { "type": "array", "maxItems": 1200, "items": { "type": "string" } }, "totalLines": { "type": "integer", "minimum": 0 } }, "required": ["lines", "totalLines"], "additionalProperties": false } }, "terminal.watch": { "x-alp": { "effect": "query", "scope": { "kind": "project" }, "capability": "terminal.watch", "idempotent": true, "description": "Connection-local read subscription management, like question.watch/session.attach; no host or terminal mutation." }, "params": { "type": "object", "properties": { "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "principalId": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Set by a trusted gateway on its own connection: the remote principal the request acts for. Absent: the local owner." }, "principalEpoch": { "type": "string", "minLength": 1, "maxLength": 200, "description": "The grant epoch of principalId (a gateway credential scope). Absent: the local owner." }, "authorizedRoots": { "type": "array", "maxItems": 1024, "items": { "type": "string", "minLength": 1, "maxLength": 4096 }, "description": "Set by a trusted gateway: the canonical workspaces the principal may use now; the terminal's workspace must be one of them." }, "after": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": [], "additionalProperties": false }, "result": { "type": "object", "properties": { "terminals": { "type": "array", "items": { "$ref": "#/$defs/terminal" } }, "watchId": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "cursor": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "reset": { "type": "boolean" } }, "required": ["terminals", "watchId", "cursor", "reset"], "additionalProperties": false } }, "terminal.unwatch": { "x-alp": { "effect": "query", "scope": { "kind": "connection" }, "capability": "terminal.watch", "idempotent": true, "description": "Connection-local read subscription management, like question.watch/session.attach; no host or terminal mutation." }, "params": { "type": "object", "properties": {}, "additionalProperties": false }, "result": { "type": "object", "properties": { "closed": { "const": true } }, "required": ["closed"], "additionalProperties": false } } }, "$defs": { "error": { "type": "object", "properties": { "code": { "type": "integer" }, "message": { "type": "string" }, "data": {} }, "required": ["code", "message"], "additionalProperties": true }, "session": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "promptImages": { "type": "boolean" }, "promptAttachments": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "enum": ["file.path", "document.native", "text.extract"] } }, "usage": { "$ref": "#/$defs/usage" } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy"], "additionalProperties": true }, "usage": { "type": "object", "properties": { "contextWindowUsedTokens": { "type": "integer", "minimum": 0 }, "contextWindowMaxTokens": { "type": "integer", "minimum": 1 }, "inputTokens": { "type": "integer", "minimum": 0 }, "cachedInputTokens": { "type": "integer", "minimum": 0 }, "outputTokens": { "type": "integer", "minimum": 0 }, "totalCostUsd": { "type": "number", "minimum": 0 } }, "additionalProperties": true }, "assignment": { "type": "object", "properties": { "id": { "type": "string" }, "agent": { "type": "string" }, "mode": { "type": "string" }, "status": { "type": "string" }, "startedAt": { "type": "string" }, "worktree": { "type": "object", "properties": { "branch": { "type": "string" }, "path": { "type": "string" } }, "required": ["branch", "path"], "additionalProperties": true } }, "required": ["id", "agent", "mode", "status", "startedAt"], "additionalProperties": true }, "mail": { "type": "object", "properties": { "id": { "type": "string" }, "kind": { "enum": ["question", "answer", "note", "steer", "result", "stalled", "board", "checkin"] }, "from": { "type": "string" }, "assignment": { "type": "string" }, "body": { "type": "string" }, "replyTo": { "type": "string" }, "result": { "type": "object" }, "redelivered": { "type": "boolean" } }, "required": ["id", "kind", "from", "assignment"], "additionalProperties": true }, "pin": { "type": "object", "properties": { "id": { "type": "string" }, "project": { "type": "string" }, "kind": { "enum": ["claim", "decision", "finding"] }, "body": { "type": "string" }, "paths": { "type": "array", "items": { "type": "string" } }, "agent": { "type": "string" }, "sessionId": { "type": "string" }, "rootId": { "type": "string" }, "at": { "type": "string" }, "released": { "type": "string" }, "task": { "type": "string" } }, "required": ["id", "project", "kind", "body", "agent", "sessionId", "rootId", "at"], "additionalProperties": true }, "question": { "type": "object", "properties": { "id": { "type": "string" }, "sessionId": { "type": "string" }, "rootId": { "type": "string" }, "agent": { "type": "string" }, "body": { "type": "string" }, "options": { "type": "array", "items": { "type": "string" } }, "askedAt": { "type": "string" }, "gate": { "type": "object", "properties": { "projectRoot": { "type": "string" }, "taskId": { "type": "string" }, "gateId": { "type": "string" } }, "required": ["projectRoot", "taskId", "gateId"], "additionalProperties": true } }, "required": ["id", "sessionId", "rootId", "agent", "body", "askedAt"], "additionalProperties": true }, "attention": { "type": "object", "properties": { "reason": { "enum": ["finished", "error"] }, "at": { "type": "string" }, "turnId": { "type": "string" }, "message": { "type": "string" } }, "required": ["reason", "at"], "additionalProperties": true }, "spec": { "type": "object", "properties": { "cwd": { "type": "string" }, "agent": { "type": "string" }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "persist": { "type": "boolean" }, "restore": { "type": "object" } }, "required": ["cwd"], "additionalProperties": true }, "item": { "anyOf": [{ "$ref": "#/$defs/knownItem" }, { "$ref": "#/$defs/unknownItem" }] }, "event": { "anyOf": [{ "$ref": "#/$defs/knownEvent" }, { "$ref": "#/$defs/unknownEvent" }] }, "envelope": { "type": "object", "properties": { "sessionId": { "type": "string" }, "epoch": { "type": "string" }, "seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "ts": { "type": "string" }, "event": { "$ref": "#/$defs/event" }, "cursor": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } }, "required": ["sessionId", "epoch", "seq", "ts", "event"], "additionalProperties": true }, "request": { "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }] }, "method": { "type": "string" }, "params": { "type": "object" } }, "required": ["jsonrpc", "method", "id"], "additionalProperties": true }, "response": { "oneOf": [{ "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" }] }, "result": {} }, "required": ["jsonrpc", "id", "result"], "additionalProperties": true }, { "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "id": { "anyOf": [{ "type": "string", "maxLength": 128 }, { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, { "type": "null" }] }, "error": { "$ref": "#/$defs/error" } }, "required": ["jsonrpc", "id", "error"], "additionalProperties": true }] }, "notification": { "oneOf": [{ "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "event" }, "params": { "$ref": "#/$defs/envelope" } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }, { "type": "object", "description": "A terminal's output, exit or detach (capability terminal, \xA712.10).", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "terminal.event" }, "params": { "$ref": "#/$defs/terminalEvent" } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }, { "type": "object", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "terminal.changed" }, "params": { "$ref": "#/$defs/terminalChanged" } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }, { "type": "object", "description": "The live model catalog changed (capability catalog.live): re-read catalog.get.", "properties": { "jsonrpc": { "const": "2.0" }, "method": { "const": "catalog.updated" }, "params": { "type": "object", "properties": { "fetchedAt": { "type": "string" } }, "additionalProperties": true } }, "required": ["jsonrpc", "method", "params"], "additionalProperties": true }] }, "knownEvent": { "oneOf": [{ "type": "object", "properties": { "type": { "const": "session.opened" }, "session": { "$ref": "#/$defs/session" }, "cwd": { "type": "string" }, "effective": { "type": "object", "properties": { "model": { "type": "string" }, "thinking": { "type": "string" } }, "required": ["model", "thinking"], "additionalProperties": true } }, "required": ["type", "session", "cwd", "effective"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.ready" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.updated" }, "session": { "$ref": "#/$defs/session" } }, "required": ["type", "session"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.closed" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "session.failed" }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "error"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "prompt.accepted" }, "clientMessageId": { "type": "string" }, "result": { "enum": ["turn", "steer"] }, "turnId": { "type": "string" } }, "required": ["type", "clientMessageId", "result", "turnId"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "prompt.failed" }, "clientMessageId": { "type": "string" }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "clientMessageId", "error"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "turn.started" }, "turnId": { "type": "string" }, "origin": { "enum": ["user", "wake", "assignment", "runtime"] } }, "required": ["type", "turnId", "origin"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "turn.ended" }, "turnId": { "type": "string" }, "state": { "enum": ["completed", "failed", "canceled"] }, "error": { "$ref": "#/$defs/alpError" } }, "required": ["type", "turnId", "state"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "item" }, "item": { "$ref": "#/$defs/item" } }, "required": ["type", "item"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "usage" }, "usage": { "$ref": "#/$defs/usage" } }, "required": ["type", "usage"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "mail" }, "mail": { "$ref": "#/$defs/mail" } }, "required": ["type", "mail"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "assignment" }, "assignment": { "$ref": "#/$defs/assignment" } }, "required": ["type", "assignment"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "question" }, "question": { "$ref": "#/$defs/question" } }, "required": ["type", "question"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "question.resolved" }, "questionId": { "type": "string" }, "outcome": { "enum": ["answered", "dismissed", "timeout", "canceled"] }, "answer": { "type": "string" } }, "required": ["type", "questionId", "outcome"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "pin" }, "pin": { "$ref": "#/$defs/pin" } }, "required": ["type", "pin"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "unpin" }, "pinId": { "type": "string" }, "reason": { "enum": ["unpinned", "session_ended"] } }, "required": ["type", "pinId", "reason"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "attention" }, "attention": { "$ref": "#/$defs/attention" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "history.reset" }, "generation": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "reason": { "const": "rewind" }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" } }, "required": ["type", "generation", "reason", "branchId"], "additionalProperties": true }] }, "unknownEvent": { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["session.opened", "session.ready", "session.updated", "session.closed", "session.failed", "prompt.accepted", "prompt.failed", "turn.started", "turn.ended", "item", "usage", "mail", "assignment", "question", "question.resolved", "pin", "unpin", "attention", "history.reset"] } } }, "required": ["type"], "additionalProperties": true }, "knownItem": { "oneOf": [{ "type": "object", "properties": { "kind": { "const": "user_message" }, "id": { "type": "string" }, "text": { "type": "string" }, "clientMessageId": { "type": "string" }, "images": { "type": "integer", "minimum": 1 }, "attachments": { "type": "array", "items": { "type": "object", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "name": { "type": "string" }, "mimeType": { "type": "string" }, "size": { "type": "integer", "minimum": 0 } }, "required": ["attachmentId", "name", "mimeType", "size"], "additionalProperties": false } }, "origin": { "enum": ["user", "wake", "assignment", "runtime"] } }, "required": ["kind", "id", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "assistant_message" }, "id": { "type": "string" }, "text": { "type": "string" } }, "required": ["kind", "id", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "notice" }, "id": { "type": "string" }, "level": { "enum": ["info", "warning", "error"] }, "text": { "type": "string" } }, "required": ["kind", "id", "level", "text"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "compaction" }, "id": { "type": "string" }, "status": { "enum": ["running", "completed", "failed"] }, "trigger": { "type": "string" }, "preTokens": { "type": "integer" }, "postTokens": { "type": "integer" } }, "required": ["kind", "id", "status"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "todo" }, "id": { "type": "string" }, "items": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "text": { "type": "string" }, "status": { "enum": ["pending", "in_progress", "completed"] } }, "required": ["id", "text", "status"], "additionalProperties": true } } }, "required": ["kind", "id", "items"], "additionalProperties": true }, { "type": "object", "properties": { "kind": { "const": "tool_call" }, "id": { "type": "string" }, "callId": { "type": "string" }, "name": { "type": "string" }, "status": { "enum": ["running", "completed", "failed"] }, "error": { "type": "string" }, "detail": { "$ref": "#/$defs/toolCallDetail" } }, "required": ["kind", "id", "callId", "name", "status", "detail"], "additionalProperties": true }] }, "unknownItem": { "type": "object", "properties": { "kind": { "type": "string", "not": { "enum": ["user_message", "assistant_message", "notice", "compaction", "todo", "tool_call"] } }, "id": { "type": "string" } }, "required": ["kind", "id"], "additionalProperties": true }, "toolCallDetail": { "oneOf": [{ "type": "object", "properties": { "type": { "const": "shell" }, "command": { "type": "string" }, "cwd": { "type": "string" }, "output": { "type": "string" }, "exitCode": { "type": ["integer", "null"] } }, "required": ["type", "command", "output"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "read" }, "filePath": { "type": "string" }, "content": { "type": "string" }, "offset": { "type": "integer" }, "limit": { "type": "integer" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "edit" }, "filePath": { "type": "string" }, "oldString": { "type": "string" }, "newString": { "type": "string" }, "unifiedDiff": { "type": "string" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "write" }, "filePath": { "type": "string" }, "content": { "type": "string" } }, "required": ["type", "filePath"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "search" }, "query": { "type": "string" }, "toolName": { "enum": ["search", "grep", "glob", "web_search"] }, "content": { "type": "string" }, "filePaths": { "type": "array", "items": { "type": "string" } }, "webResults": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string" }, "url": { "type": "string" } }, "required": ["title", "url"], "additionalProperties": true } }, "numFiles": { "type": "integer" }, "numMatches": { "type": "integer" }, "truncated": { "type": "boolean" } }, "required": ["type", "query"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "fetch" }, "url": { "type": "string" }, "prompt": { "type": "string" }, "result": { "type": "string" }, "code": { "type": "integer" } }, "required": ["type", "url"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "sub_agent" }, "subAgentType": { "type": "string" }, "description": { "type": "string" }, "log": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "plan" }, "text": { "type": "string" } }, "required": ["type", "text"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "plain_text" }, "label": { "type": "string" }, "text": { "type": "string" } }, "required": ["type"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "const": "unknown" }, "input": {}, "output": {} }, "required": ["type", "input", "output"], "additionalProperties": true }, { "type": "object", "properties": { "type": { "type": "string", "not": { "enum": ["shell", "read", "edit", "write", "search", "fetch", "sub_agent", "plan", "plain_text", "unknown"] } } }, "required": ["type"], "additionalProperties": true }] }, "alpError": { "type": "object", "properties": { "message": { "type": "string" }, "code": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "sessionSummary": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "status": { "enum": ["initializing", "idle", "running", "error", "closed"] }, "title": { "type": "string" }, "archived": { "type": "boolean" }, "attention": { "$ref": "#/$defs/attention" }, "lastError": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" }, "conversation": { "type": "object", "properties": { "fork": { "type": "boolean" }, "rewind": { "type": "boolean" }, "reload": { "type": "boolean", "description": "Whether session.reload can restart this root's native process (\xA712.8); the root must also be open and idle." }, "reason": { "enum": ["runtime_unsupported", "not_persistent", "not_root"] }, "configure": { "type": "boolean", "description": "Whether session.configure can change this root's model, effort or team (\xA712.9); the root must also be open and idle." } }, "required": ["fork", "rewind"], "additionalProperties": true }, "forkedFrom": { "$ref": "#/$defs/forkProvenance" }, "branches": { "type": "array", "maxItems": 100, "items": { "$ref": "#/$defs/conversationBranch" } }, "promptAttachments": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "enum": ["file.path", "document.native", "text.extract"] } } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy", "status"], "additionalProperties": true }, "pause": { "type": "object", "properties": { "since": { "type": "string" }, "by": { "type": "string" }, "reason": { "type": "string" }, "resetsAt": { "type": "string" }, "checkedAt": { "type": "string" } }, "required": ["since", "by", "reason"], "additionalProperties": true }, "pauseState": { "type": "object", "properties": { "all": { "$ref": "#/$defs/pause" }, "runtimes": { "type": "object", "additionalProperties": { "$ref": "#/$defs/pause" } }, "parked": { "type": "array", "items": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "type": "string" }, "rootId": { "type": "string" }, "reason": { "type": "string" }, "since": { "type": "string" } }, "required": ["assignmentId", "agent", "runtime", "rootId", "reason", "since"], "additionalProperties": true } } }, "required": ["runtimes", "parked"], "additionalProperties": true }, "preview": { "type": "object", "properties": { "teams": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" } }, "required": ["id", "label"], "additionalProperties": true } }, "team": { "type": "string" }, "teamLabel": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" } }, "required": ["teams", "team", "agent", "runtime", "model", "mode", "thinking"], "additionalProperties": true }, "treeStatus": { "type": "object", "properties": { "rootId": { "type": "string" }, "sessions": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "projectRoot": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "mode": { "type": "string" }, "thinking": { "type": "string" }, "workflow": { "type": "object", "properties": { "mode": { "type": "string" }, "maxPeers": { "type": "integer" }, "supervisor": { "type": "boolean" } }, "required": ["mode", "maxPeers", "supervisor"], "additionalProperties": true }, "threadId": { "type": "string" }, "persistent": { "type": "boolean" }, "busy": { "type": "boolean" }, "parentId": { "type": "string" }, "toolCallId": { "type": "string" }, "activeTurnId": { "type": "string" }, "parked": { "type": "string" }, "instructionsSha": { "type": "string" }, "teamLabel": { "type": "string" }, "state": { "enum": ["running", "waiting", "waiting_parent", "waiting_user", "idle"] }, "idleMs": { "type": "number" }, "workdir": { "type": "string" }, "unreadMail": { "type": "integer", "minimum": 0 } }, "required": ["id", "projectRoot", "agent", "runtime", "model", "mode", "thinking", "workflow", "threadId", "persistent", "busy", "state", "idleMs", "workdir", "unreadMail"], "additionalProperties": true } }, "assignments": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "requester": { "type": "string" }, "isolation": { "enum": ["shared", "worktree"] }, "idleMs": { "type": "number" } }, "required": ["id", "requester", "isolation", "idleMs"], "additionalProperties": true } }, "questions": { "type": "array", "items": { "$ref": "#/$defs/question" } }, "worktrees": { "type": "array", "items": { "type": "object", "properties": { "assignmentId": { "type": "string" }, "requester": { "type": "string" }, "agent": { "type": "string" }, "branch": { "type": "string" }, "files": { "type": "array", "items": { "type": "string" } }, "stat": { "type": "string" } }, "required": ["assignmentId", "requester", "agent", "branch", "files", "stat"], "additionalProperties": true } }, "leases": { "type": "array", "items": { "type": "object", "properties": { "checkout": { "type": "string" }, "assignmentId": { "type": "string" }, "agent": { "type": "string" } }, "required": ["checkout", "assignmentId", "agent"], "additionalProperties": true } }, "claims": { "type": "array", "items": { "$ref": "#/$defs/pin" } } }, "required": ["rootId", "sessions", "assignments", "questions", "worktrees", "leases", "claims"], "additionalProperties": true }, "health": { "type": "object", "properties": { "live": { "type": "boolean" }, "ready": { "type": "boolean" }, "checks": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "ok": { "type": "boolean" }, "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["id", "ok"], "additionalProperties": true } } }, "required": ["live", "ready", "checks"], "additionalProperties": true }, "projectRoot": { "type": "string", "minLength": 1, "maxLength": 4096, "description": "An absolute, normalized path on the daemon host to a directory holding .alp/. Compared as is: the daemon never walks up to a parent." }, "taskId": { "type": "string", "pattern": "^t-[0-9a-f]{4,12}(?:\\.\\d+)*$" }, "taskRow": { "type": "object", "properties": { "id": { "$ref": "#/$defs/taskId" }, "title": { "type": "string" }, "type": { "type": "string" }, "priority": { "type": "integer" }, "status": { "enum": ["open", "in_progress", "review", "closed"] }, "rev": { "type": "integer", "minimum": 0 }, "parent": { "type": "string" }, "assignee": { "type": "string" }, "ready": { "type": "boolean" }, "blockedBy": { "type": "array", "items": { "type": "string" } }, "waits": { "type": "array", "items": { "type": "string" } }, "approvals": { "type": "array", "items": { "type": "object", "properties": { "gate": { "type": "string" }, "note": { "type": "string" } }, "required": ["gate", "note"], "additionalProperties": true } }, "handoff": { "type": "object", "properties": { "outcome": { "type": "string" }, "summary": { "type": "string" }, "agent": { "type": "string" } }, "required": ["outcome", "summary"], "additionalProperties": true }, "closed": { "type": "object", "properties": { "reason": { "type": "string" }, "summary": { "type": "string" }, "at": { "type": "string" } }, "required": ["reason", "at"], "additionalProperties": true }, "description": { "type": "string" }, "labels": { "type": "array", "items": { "type": "string" } }, "paths": { "type": "array", "items": { "type": "string" } }, "progress": { "type": "object", "properties": { "done": { "type": "integer", "minimum": 0 }, "total": { "type": "integer", "minimum": 0 } }, "required": ["done", "total"], "additionalProperties": true }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" } }, "required": ["id", "title", "type", "priority", "status", "rev", "ready", "updatedAt"], "additionalProperties": true }, "libraryKind": { "enum": ["agents", "skills", "mcp", "hooks", "teams", "providers"] }, "libraryScope": { "enum": ["library", "project"] }, "librarySource": { "enum": ["builtin", "library", "project"] }, "entryName": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_.-]+$", "not": { "enum": [".", ".."] } }, "libraryRevision": { "type": ["string", "null"] }, "libraryEntryRow": { "type": "object", "properties": { "name": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "description": { "type": "string" }, "usedBy": { "type": "array", "items": { "type": "string" } } }, "required": ["name", "source"], "additionalProperties": true }, "secretMarker": { "type": "object", "properties": { "$secret": { "const": "keep" } }, "required": ["$secret"], "additionalProperties": false, "description": "Stands for a stored secret value: read results carry it in place of the value; a save that sends it back keeps the stored value." }, "languageSetting": { "type": "object", "properties": { "language": { "type": ["string", "null"] }, "applies": { "type": "string" }, "default": { "type": "string" } }, "required": ["language", "applies", "default"], "additionalProperties": true }, "teamRow": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" }, "source": { "$ref": "#/$defs/librarySource" }, "overrides": { "$ref": "#/$defs/librarySource" }, "error": { "type": "string" } }, "required": ["id", "source"], "additionalProperties": true }, "promptImage": { "type": "object", "properties": { "type": { "const": "image" }, "mimeType": { "enum": ["image/png", "image/jpeg", "image/gif", "image/webp"] }, "data": { "type": "string", "minLength": 4, "maxLength": 6990508, "pattern": "^[A-Za-z0-9+/]+={0,2}$" }, "name": { "type": "string", "maxLength": 255 } }, "required": ["type", "mimeType", "data"], "additionalProperties": false }, "scheduleId": { "type": "string", "pattern": "^sch_[0-9a-f]{16}$" }, "scheduleError": { "type": "object", "properties": { "message": { "type": "string" }, "code": { "type": "string" } }, "required": ["message"], "additionalProperties": true }, "scheduleJob": { "type": "object", "properties": { "id": { "$ref": "#/$defs/scheduleId" }, "projectRoot": { "$ref": "#/$defs/projectRoot" }, "sessionId": { "type": "string" }, "prompt": { "type": "string" }, "dueAt": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?(Z|[+-]\\d{2}:\\d{2})$" }, "status": { "enum": ["pending", "delivered", "failed", "cancelled"] }, "attempts": { "type": "integer", "minimum": 0 }, "createdAt": { "type": "string" }, "updatedAt": { "type": "string" }, "deliveredAt": { "type": "string" }, "failedAt": { "type": "string" }, "cancelledAt": { "type": "string" }, "attemptedAt": { "type": "string" }, "lateByMs": { "type": "integer", "minimum": 0 }, "lastError": { "$ref": "#/$defs/scheduleError" } }, "required": ["id", "projectRoot", "sessionId", "prompt", "dueAt", "status", "attempts", "createdAt", "updatedAt"], "additionalProperties": true }, "registryProject": { "type": "object", "properties": { "id": { "type": "string" }, "root": { "type": "string" }, "customName": { "type": ["string", "null"] }, "addedAt": { "type": "string" }, "removedAt": { "type": ["string", "null"] }, "revision": { "type": "integer", "minimum": 0 }, "canonical": { "type": "string" } }, "required": ["id", "root", "addedAt"], "additionalProperties": false }, "registryWorkspace": { "type": "object", "properties": { "id": { "type": "string" }, "projectId": { "type": "string" }, "directory": { "type": "string" }, "title": { "type": ["string", "null"] }, "pinnedAt": { "type": ["string", "null"] }, "archivedAt": { "type": ["string", "null"] }, "labels": { "type": "array", "items": { "type": "string" } }, "createdAt": { "type": "string" }, "revision": { "type": "integer", "minimum": 0 }, "canonical": { "type": "string" }, "idempotencyKey": { "type": "string" }, "branch": { "type": ["string", "null"] }, "managedWorktree": { "type": "boolean" } }, "required": ["id", "projectId", "directory", "labels", "createdAt"], "additionalProperties": false }, "attachment": { "type": "object", "description": "A committed attachment as clients see it: ids, display metadata and its digest, never a host path or URL.", "properties": { "attachmentId": { "type": "string", "pattern": "^att_[0-9a-f]{32}$" }, "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "name": { "type": "string", "minLength": 1, "maxLength": 255 }, "mimeType": { "type": "string", "minLength": 3, "maxLength": 255 }, "detectedMimeType": { "type": "string", "minLength": 3, "maxLength": 255 }, "size": { "type": "integer", "minimum": 0 }, "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }, "createdAt": { "type": "string" }, "committedAt": { "type": "string" }, "referenced": { "type": "boolean" } }, "required": ["attachmentId", "sessionId", "name", "mimeType", "detectedMimeType", "size", "sha256", "createdAt", "committedAt", "referenced"], "additionalProperties": false }, "forkProvenance": { "type": "object", "description": "Where a fork came from (\xA712.7): the source root, and the turn its conversation was cut at.", "properties": { "sessionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "turnId": { "type": "string", "minLength": 1, "maxLength": 200 }, "boundary": { "enum": ["through", "before", "whole"] }, "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "at": { "type": "string", "minLength": 1, "maxLength": 64 } }, "required": ["sessionId", "boundary", "at"], "additionalProperties": true }, "conversationBranch": { "type": "object", "description": "Later turns a rewind set aside (\xA712.7): kept, never deleted, recoverable as a new session with session.fork { branchId }.", "properties": { "branchId": { "type": "string", "pattern": "^br_[0-9a-f]{16}$" }, "beforeTurnId": { "type": "string", "minLength": 1, "maxLength": 200 }, "turns": { "type": "integer", "minimum": 0 }, "at": { "type": "string", "minLength": 1, "maxLength": 64 } }, "required": ["branchId", "beforeTurnId", "turns", "at"], "additionalProperties": true }, "effectiveConfig": { "type": "object", "description": "The configuration a root runs with, or would after a change, as alpd resolved it (\xA712.9).", "properties": { "team": { "type": "string" }, "teamLabel": { "type": "string" }, "agent": { "type": "string" }, "runtime": { "enum": ["claude", "codex", "acp", "antigravity"] }, "model": { "type": "string" }, "thinking": { "type": "string" }, "mode": { "type": "string" }, "permissionProfile": { "type": "string", "description": "The permission profile capping the agent's mode, when one does." }, "supervisor": { "type": "boolean" }, "maxPeers": { "type": "integer" }, "delegates": { "type": "array", "items": { "type": "string" }, "description": "Agents the root may delegate to." }, "tools": { "type": "array", "items": { "type": "string" }, "description": "ALP tools the root's agent is given." }, "mcpServers": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "kind": { "enum": ["stdio", "http"] } }, "required": ["name", "kind"], "additionalProperties": true } }, "hooks": { "type": "integer", "minimum": 0, "description": "How many hook commands the agent runs." }, "instructionsSha": { "type": "string" } }, "required": ["team", "agent", "runtime", "model", "thinking", "mode", "supervisor", "delegates", "tools", "mcpServers", "hooks"], "additionalProperties": true }, "configurePreview": { "type": "object", "properties": { "current": { "$ref": "#/$defs/effectiveConfig" }, "proposed": { "$ref": "#/$defs/effectiveConfig" }, "changes": { "type": "array", "items": { "enum": ["model", "thinking", "team", "mode"] } }, "restart": { "type": "boolean", "description": "Whether applying it restarts the root's native process (on its own conversation)." }, "allowed": { "type": "boolean", "description": "Whether session.configure would take it now; a busy tree may still refuse it later." }, "reason": { "enum": ["session_busy", "session_closed", "not_root", "runtime_unsupported", "runtime_mismatch", "agent_mismatch", "permission_escalation", "team_not_found", "invalid_params", "not_persistent"] }, "message": { "type": "string" }, "teams": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "description": { "type": "string" } }, "required": ["id", "label"], "additionalProperties": true } } }, "required": ["current", "proposed", "changes", "restart", "allowed", "teams"], "additionalProperties": true }, "configureOutcome": { "type": "object", "properties": { "status": { "enum": ["applied", "unchanged"] }, "requested": { "type": "object", "properties": { "model": { "type": "string" }, "thinking": { "type": "string" }, "team": { "type": "string" }, "mode": { "type": "string" } }, "additionalProperties": false }, "effective": { "$ref": "#/$defs/effectiveConfig" }, "restarted": { "type": "boolean" } }, "required": ["status", "requested", "effective", "restarted"], "additionalProperties": true }, "terminal": { "type": "object", "description": "A terminal as clients see it: ids, size and state, never a process id, shell path or host path.", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "workspaceId": { "type": "string", "minLength": 1, "maxLength": 200 }, "title": { "type": "string", "maxLength": 64 }, "cols": { "type": "integer", "minimum": 2, "maximum": 500 }, "rows": { "type": "integer", "minimum": 1, "maximum": 200 }, "state": { "enum": ["running", "exited"] }, "attached": { "type": "boolean" }, "createdAt": { "type": "string", "format": "date-time" }, "lastActivityAt": { "type": "string", "format": "date-time" }, "expiresAt": { "type": "string", "format": "date-time" }, "exitCode": { "type": ["integer", "null"] }, "signal": { "type": ["integer", "null"] }, "endReason": { "enum": ["exited", "closed", "idle", "lifetime", "detached", "revoked", "disabled", "shutdown"] }, "protection": { "enum": ["root-only", "none"], "description": "Absent: full native process protection (macOS, supported Linux). root-only: best-effort Linux; closing ends the shell, but processes it started may keep running. none: Windows platform PTY (ConPTY); cleanup is best-effort and not guaranteed. Clients show a non-blocking notice." } }, "required": ["terminalId", "workspaceId", "title", "cols", "rows", "state", "attached", "createdAt", "lastActivityAt", "expiresAt"], "additionalProperties": false }, "terminalEvent": { "description": "params of a terminal.event notification (\xA712.10): sent only to the connection attached to the terminal.", "oneOf": [{ "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "output" }, "seq": { "type": "integer", "minimum": 1 }, "data": { "type": "string", "minLength": 1, "maxLength": 65536 } }, "required": ["terminalId", "type", "seq", "data"], "additionalProperties": false }, { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "exit" }, "seq": { "type": "integer", "minimum": 1 }, "exitCode": { "type": ["integer", "null"] }, "signal": { "type": ["integer", "null"] }, "reason": { "enum": ["exited", "closed", "idle", "lifetime", "detached", "revoked", "disabled", "shutdown"] } }, "required": ["terminalId", "type", "seq", "exitCode", "signal", "reason"], "additionalProperties": false }, { "type": "object", "properties": { "terminalId": { "type": "string", "pattern": "^term_[0-9a-f]{32}$" }, "type": { "const": "detached" }, "reason": { "enum": ["replaced", "slow_consumer"] } }, "required": ["terminalId", "type", "reason"], "additionalProperties": false }] }, "terminalChanged": { "type": "object", "properties": { "watchId": { "type": "string", "pattern": "^[0-9a-f]{32}$" }, "cursor": { "type": "string", "pattern": "^[0-9a-f]{32}$" } }, "required": ["watchId", "cursor"], "additionalProperties": false } } };
5453
5660
 
5454
5661
  // packages/protocol/src/validate.js
5455
5662
  var MAX_ISSUES = 8;
@@ -5617,7 +5824,7 @@ var TERMINAL_EXEC_WARNING = `Warning: this credential holds terminal.exec. Whoev
5617
5824
  daemon host as the account that runs alpd (its files, programs and network), in any granted workspace;
5618
5825
  a workspace is NOT a sandbox. Terminals open only while the host owner allows them (alp terminal allow).`;
5619
5826
  var DEFAULT_PERMISSIONS = Object.freeze(["session.read", "session.write", "project.read", "project.write"]);
5620
- var FORWARDED_CAPABILITIES = Object.freeze([CAPABILITY.sessionInterruptTurn, CAPABILITY.workspaceRegistry, CAPABILITY.workspaceWorktree, CAPABILITY.sessionHistory, CAPABILITY.attachAfter, CAPABILITY.promptReceipts, CAPABILITY.task, CAPABILITY.team, CAPABILITY.library, CAPABILITY.libraryProjectWrite, CAPABILITY.settingsLanguage, CAPABILITY.sessionListPage, CAPABILITY.questionWatch, CAPABILITY.questionWatchTurns, CAPABILITY.sessionAttention, CAPABILITY.workspaceFiles, CAPABILITY.workspaceFilesRead, CAPABILITY.promptImages, CAPABILITY.workspaceGit, CAPABILITY.attachments, CAPABILITY.sessionFork, CAPABILITY.sessionRewind, CAPABILITY.sessionReload, CAPABILITY.sessionResumeCommand, CAPABILITY.sessionConfigureLive, CAPABILITY.terminal]);
5827
+ var FORWARDED_CAPABILITIES = Object.freeze([CAPABILITY.sessionInterruptTurn, CAPABILITY.sessionCommands, CAPABILITY.workspaceRegistry, CAPABILITY.workspaceWorktree, CAPABILITY.sessionHistory, CAPABILITY.attachAfter, CAPABILITY.promptReceipts, CAPABILITY.task, CAPABILITY.team, CAPABILITY.library, CAPABILITY.libraryProjectWrite, CAPABILITY.settingsLanguage, CAPABILITY.sessionListPage, CAPABILITY.questionWatch, CAPABILITY.questionWatchTurns, CAPABILITY.sessionAttention, CAPABILITY.workspaceFiles, CAPABILITY.workspaceFilesRead, CAPABILITY.promptImages, CAPABILITY.workspaceGit, CAPABILITY.attachments, CAPABILITY.sessionFork, CAPABILITY.sessionRewind, CAPABILITY.sessionReload, CAPABILITY.sessionResumeCommand, CAPABILITY.sessionConfigureLive, CAPABILITY.terminal, CAPABILITY.terminalCapture, CAPABILITY.terminalWatch]);
5621
5828
  var GATEWAY_ERROR = Object.freeze({ forbidden: ERROR.forbidden, unavailable: ERROR.unavailable });
5622
5829
  var GATEWAY_REASON = Object.freeze({
5623
5830
  notExposed: "not_exposed",
@@ -5709,6 +5916,10 @@ function projectTerminal(raw) {
5709
5916
  if (!TERMINAL_END.has(raw.endReason)) return void 0;
5710
5917
  terminal.endReason = raw.endReason;
5711
5918
  }
5919
+ if (raw.protection !== void 0) {
5920
+ if (raw.protection !== "root-only" && raw.protection !== "none") return void 0;
5921
+ terminal.protection = raw.protection;
5922
+ }
5712
5923
  return (
5713
5924
  /** @type {import('@anhlp/alp-protocol').TerminalInfo} */
5714
5925
  /** @type {unknown} */
@@ -5732,6 +5943,8 @@ function projectTerminalEvent(raw, maxOutputFrameBytes) {
5732
5943
  return void 0;
5733
5944
  }
5734
5945
  var TERMINAL_REFUSALS = Object.freeze({
5946
+ terminal_capture_unavailable: "Terminal capture exceeded its resource limit or its screen was released",
5947
+ terminal_capture_too_large: "Terminal capture is too large; select a smaller line range",
5735
5948
  not_found: "No such terminal",
5736
5949
  terminal_disabled: "The daemon host has not allowed remote terminals (its owner runs alp terminal allow)",
5737
5950
  terminal_unsupported: "Terminals are not available on the daemon host",
@@ -6068,7 +6281,8 @@ function isModelId(value) {
6068
6281
  }
6069
6282
  var EXPOSURE = Object.freeze({
6070
6283
  "daemon.hello": { status: "gateway", scope: "connection", reason: "Answered by the gateway after its own hello to alpd: capabilities are alpd's intersected with FORWARDED_CAPABILITIES; alpd's hostname when hostLabel accepts it; no pid.", tests: ["handshake"] },
6071
- "catalog.get": { status: "exposed", permission: "session.read", scope: "none: the static model and mode catalogue", params: [], tests: ["permission"] },
6284
+ "catalog.get": { status: "exposed", permission: "session.read", scope: "none: the model and mode catalogue (live provider lists merged over static rows, t-e5ee)", params: [], tests: ["permission"] },
6285
+ "catalog.refresh": { status: "denied", scope: "host: runs each provider CLI on the daemon host to list its models", reason: "Starts provider processes on the host; remote clients read the catalog alpd refreshes on start, every 6 h and from turns (catalog.get), and the gateway forwards no catalog.updated." },
6072
6286
  "session.list": { status: "exposed", permission: "session.read", scope: "result: sessions whose tree lies in a granted workspace; projectRoot must name one; with limit, alpd pages are read until the filtered page is full", params: ["projectRoot", "rootsOnly", "includeClosed", "includeArchived", "limit", "cursor", "query"], tests: ["permission", "workspace-param", "result-filter", "paging"] },
6073
6287
  "session.get": { status: "exposed", permission: "session.read", scope: "session: its tree's root and itself in a granted workspace", params: ["sessionId"], tests: ["permission", "session-scope"] },
6074
6288
  "session.status": { status: "exposed", permission: "session.read", scope: "session; the answer must be the checked root's tree with every session in a granted workspace. Rows carry host paths of that tree (workdir, lease checkouts)", params: ["sessionId"], tests: ["permission", "session-scope", "tree-scope"] },
@@ -6096,9 +6310,12 @@ var EXPOSURE = Object.freeze({
6096
6310
  "session.prompt": { status: "exposed", permission: "session.write", scope: "session; text, inline images within GATEWAY_PROMPT_IMAGES, and attachments by attachmentId alone (attachments.write as well; alpd resolves them for this principal, grant epoch, an authorized project and this session, and refuses them 1005 attachment_unsupported where the runtime cannot read them); drives: the modes of the session and every ancestor, looked up afresh, within the grant's modes", capability: CAPABILITY.promptReceipts, params: ["sessionId", "clientMessageId", "delivery", "content"], tests: ["permission", "session-scope", "content", "mode", "binding"] },
6097
6311
  // Terminals (§5.18, docs/protocol/alp-json-rpc-v1.md §12.10): a real shell as the daemon's account,
6098
6312
  // only with the opt-in terminal.exec and the host owner's own switch; a workspace is not a sandbox.
6099
- "terminal.create": { status: "exposed", permission: "terminal.exec", scope: "workspace: workspaceId a registry workspace whose directory a grant names exactly, looked up afresh; alpd binds the terminal to this credential, its grant epoch and the grant's canonical workspaces (authorizedRoots), and picks the shell, its environment and directory itself (no shell, command, args, env, cwd or pid is a param); answer projected by projectTerminal", capability: CAPABILITY.terminal, params: ["workspaceId", "cols", "rows", "requestId"], tests: ["permission", "registry-scope", "binding"] },
6313
+ "terminal.create": { status: "exposed", permission: "terminal.exec", scope: "workspace: workspaceId a registry workspace whose directory a grant names exactly, looked up afresh; alpd binds the terminal to this credential, its grant epoch and the grant's canonical workspaces (authorizedRoots), and picks the shell, its environment and directory itself (no shell, command, args, env, cwd or pid is a param); answer projected by projectTerminal", capability: CAPABILITY.terminal, params: ["workspaceId", "cols", "rows", "requestId", "protectionAcknowledgment"], tests: ["permission", "registry-scope", "binding"] },
6100
6314
  "terminal.list": { status: "exposed", permission: "terminal.exec", scope: "principal: only this credential's own terminals of its grant epoch and canonical workspaces (alpd filters); a workspaceId given is checked as for terminal.create", capability: CAPABILITY.terminal, params: ["workspaceId"], tests: ["permission", "binding"] },
6101
- "terminal.attach": { status: "exposed", permission: "terminal.exec", scope: "terminal: alpd checks the binding (credential, grant epoch, authorized workspace); terminal.event notifications of attached terminals only, re-checked and projected (projectTerminalEvent)", capability: CAPABILITY.terminal, params: ["terminalId", "after"], tests: ["permission", "binding"] },
6315
+ "terminal.watch": { status: "exposed", permission: "terminal.exec", scope: "principal: atomic snapshot and cursor subscription, same credential epoch/authorized roots; optional registry workspace checked", capability: CAPABILITY.terminalWatch, params: ["workspaceId", "after"], tests: ["permission", "binding", "cursor"] },
6316
+ "terminal.unwatch": { status: "exposed", permission: "terminal.exec", scope: "connection: stops only this connection subscription", capability: CAPABILITY.terminalWatch, params: [], tests: ["permission"] },
6317
+ "terminal.capture": { status: "exposed", permission: "terminal.exec", scope: "terminal: same principal, epoch and authorized roots; bounded rendered text only, explicit frame refusal", capability: CAPABILITY.terminalCapture, params: ["terminalId", "start", "end", "stripAnsi"], tests: ["permission", "binding", "frame"] },
6318
+ "terminal.attach": { status: "exposed", permission: "terminal.exec", scope: "terminal: alpd checks the binding (credential, grant epoch, authorized workspace); terminal.event notifications of attached terminals only, re-checked and projected (projectTerminalEvent)", capability: CAPABILITY.terminal, params: ["terminalId", "after", "protectionAcknowledgment"], tests: ["permission", "binding"] },
6102
6319
  "terminal.input": { status: "exposed", permission: "terminal.exec", scope: "terminal: as terminal.attach, from the connection that attached it; never logged", capability: CAPABILITY.terminal, params: ["terminalId", "data"], tests: ["permission", "binding"] },
6103
6320
  "terminal.resize": { status: "exposed", permission: "terminal.exec", scope: "terminal: as terminal.input", capability: CAPABILITY.terminal, params: ["terminalId", "cols", "rows"], tests: ["permission", "binding"] },
6104
6321
  "terminal.close": { status: "exposed", permission: "terminal.exec", scope: "terminal: as terminal.attach", capability: CAPABILITY.terminal, params: ["terminalId"], tests: ["permission", "binding"] },
@@ -6112,6 +6329,7 @@ var EXPOSURE = Object.freeze({
6112
6329
  "session.fork": { status: "exposed", permission: "session.write", alsoRequires: ["session.read"], scope: "session: sessionId a root in a granted workspace, looked up afresh (it reads that conversation, so session.read too); workspaceId, when given, a registry workspace whose directory a grant names exactly (as session.create), else the fork stays in the source's workspace; newSessionId, when given, never a session outside the grant. The principal context is the gateway's own, never the client's (alpd re-authorizes the source's attachments for it); requestId namespaced per credential; for a grant with modes, the modes of the source and its tree, looked up afresh, within them (as session.prompt: the fork inherits its configuration). Only conversation is copied, never a file. The created root is checked again (a root in the grant, and in the destination asked for) before it is answered; forkedFrom must name the checked source; a forkedFrom in any summary passes only when its source is in the grant (projectForkedFrom). alpd errors rewritten to fixed text keeping code, reason and a generation", capability: CAPABILITY.sessionFork, params: ["sessionId", "requestId", "ifGeneration", "boundary", "branchId", "workspaceId", "newSessionId", "title"], tests: ["permission", "session-scope", "registry-scope", "binding", "result-filter", "mode"] },
6113
6330
  "session.rewind": { status: "exposed", permission: "session.write", scope: "session: sessionId a root in a granted workspace, looked up afresh; for a grant with modes, the modes of the root and its tree, looked up afresh, within them (as session.prompt); conversation only under the same session id, no file is changed, the later turns stay a branch session.fork { branchId } recovers; requestId namespaced per credential; the answer must be that session, its branch and generation projected; alpd errors rewritten to fixed text keeping code, reason and a generation. history.reset reaches the root's attached connections as alpd sent it", capability: CAPABILITY.sessionRewind, params: ["sessionId", "requestId", "ifGeneration", "beforeTurnId"], tests: ["permission", "session-scope", "result-filter", "event-filter", "mode"] },
6114
6331
  "session.reload": { status: "exposed", permission: "session.write", scope: "session: sessionId a root in a granted workspace, looked up afresh; for a grant with modes, the modes of the root and its tree, looked up afresh, within them (as session.prompt: the restarted process drives the session); restarts its native process on its own conversation and configuration, nothing else; requestId namespaced per credential; the answer must be that root, projected; alpd errors rewritten to fixed text keeping code and reason", capability: CAPABILITY.sessionReload, params: ["sessionId", "requestId", "ifGeneration"], tests: ["permission", "session-scope", "result-filter", "mode"] },
6332
+ "session.commands": { status: "exposed", permission: "session.read", scope: "session: its tree's root and itself in a granted workspace; the answer projected (name, description, argumentHint, kind of each, never a path)", capability: CAPABILITY.sessionCommands, params: ["sessionId"], tests: ["permission", "session-scope", "result-filter"] },
6115
6333
  "session.resumeCommand": { status: "exposed", permission: "session.read", scope: "session: its tree's root and itself in a granted workspace; the answer is rebuilt by the gateway from the session id (resumeCommandOf, `alp attach <id>`) and refused unless alpd answered the same, so no path, env, credential or native runtime command passes; for the clipboard only, never run", capability: CAPABILITY.sessionResumeCommand, params: ["sessionId"], tests: ["permission", "session-scope", "result-filter"] },
6116
6334
  "session.interrupt": { status: "exposed", permission: "session.write", scope: "session; stops: a root always, an assignment when its requesters' modes are within the grant's", params: ["sessionId", "turnId"], tests: ["permission", "session-scope", "mode"] },
6117
6335
  "session.configure": { status: "exposed", permission: "session.write", scope: "session; mode within the grant's modes. With model, thinking or team (capability session.configure.live, \xA712.9): sessionId a root in a granted workspace, looked up afresh; for a grant with modes, the modes of the root and its tree, looked up afresh, within them (as session.prompt), and the mode alpd would run it with (session.configure.preview, asked first) too; team needs session.team.write as well; requestId namespaced per credential; the answer must be that root, projected, with its configuration projected (projectConfigured); alpd errors rewritten to fixed text keeping code, reason and the action session.create", params: ["sessionId", "mode", "model", "thinking", "team", "requestId", "ifGeneration"], tests: ["permission", "session-scope", "mode", "result-filter", "binding"] },
@@ -6125,12 +6343,16 @@ var EXPOSURE = Object.freeze({
6125
6343
  "workspace.files.search": { status: "exposed", permission: "project.read", scope: "workspace: projectRoot names a granted workspace and is sent as its canonical path; alpd lists file names under it only (no link followed, no contents); answered paths must be relative without . or .. segments, others dropped", capability: CAPABILITY.workspaceFiles, params: ["projectRoot", "query", "limit"], tests: ["permission", "workspace-param", "result-filter"] },
6126
6344
  "workspace.files.list": { status: "exposed", permission: "files.read", scope: "workspace: projectRoot names a granted workspace and is sent as its canonical path; path relative, no . or .. segment, never a blocked one (blockedFilePath, refused by the gateway before alpd); alpd lists regular files and directories under it, no link followed; answered entries must be direct children of path, plainly relative and not blocked, others dropped; alpd errors rewritten to fixed text", capability: CAPABILITY.workspaceFilesRead, params: ["projectRoot", "path", "includeIgnored"], tests: ["permission", "workspace-param", "result-filter", "path-filter"] },
6127
6345
  "workspace.files.read": { status: "exposed", permission: "files.read", scope: "workspace: as workspace.files.list; alpd reads one UTF-8 text file of at most WORKSPACE_FILES.maxReadBytes, no link or hard link; the answer must name the requested path and fit the limit, else refused; alpd errors rewritten to fixed text", capability: CAPABILITY.workspaceFilesRead, params: ["projectRoot", "path", "includeIgnored"], tests: ["permission", "workspace-param", "result-filter", "path-filter"] },
6346
+ "workspace.files.find": { status: "denied", scope: "workspace: projectRoot; every file and directory name under it, in pages of a snapshot alpd keeps for the connection that asked", reason: "For the daemon host's own clients (the Paseo bridge, t-bb87): no grant covers a whole-tree listing or its snapshots yet; remote clients search names with workspace.files.search (project.read)." },
6347
+ "workspace.files.preview": { status: "denied", scope: "workspace: projectRoot and path; the bytes of any text, image or binary file up to 50 MiB, in chunks", reason: "For the daemon host's own clients (the Paseo bridge, t-bb87): files.read covers UTF-8 text of at most 1 MiB only; remote clients read files with workspace.files.read." },
6348
+ "host.directories.search": { status: "prohibited", scope: "host", reason: "Names of the daemon host's directories outside any workspace (home, typed absolute paths): the host owner's own, never remote." },
6128
6349
  "workspace.git.status": { status: "exposed", permission: "project.read", scope: "workspace: workspaceId names a registry workspace whose directory a grant names exactly (#registryWorkspace, managed worktrees included); read only, never a Git mutation; answer projected by projectGitStatus: listed fields only, rows whose path or old path is not plainly relative or is blocked dropped and counted hidden, a local remote URL answered null; alpd errors rewritten to fixed text", capability: CAPABILITY.workspaceGit, params: ["workspaceId"], tests: ["permission", "registry-scope", "result-filter"] },
6129
6350
  "workspace.git.diff": { status: "exposed", permission: "project.read", alsoRequires: ["files.read"], scope: "workspace: as workspace.git.status; hunks are file content, so files.read too (never a default); compare re-projected to mode, baseRef, ignoreWhitespace; path relative and not blocked, refused by the gateway before alpd; answer projected by projectGitDiff: files of other paths, non-relative or blocked ones dropped (counted hidden), each file's patch and the page within WORKSPACE_GIT or the answer refused, pages split to fit the client's frame (sealed gateway cursors); alpd errors rewritten to fixed text", capability: CAPABILITY.workspaceGit, params: ["workspaceId", "compare", "path", "cursor"], tests: ["permission", "registry-scope", "result-filter", "path-filter"] },
6351
+ "workspace.git.facts": { status: "prohibited", scope: "host", reason: "Owner-only checkout facts of any host directory, named by host path rather than a granted workspace; the answer names host paths. Its capability is not forwarded either." },
6130
6352
  "task.list": { status: "exposed", permission: "project.read", scope: "workspace: projectRoot", capability: CAPABILITY.task, params: ["projectRoot"], tests: ["permission", "workspace-param"] },
6131
6353
  "task.create": { status: "exposed", permission: "project.write", scope: "workspace: projectRoot; requestId dedupes within one alpd process for 10 minutes only, so read task.list before retrying after 1000 or a restart", capability: CAPABILITY.task, params: ["projectRoot", "title", "priority", "requestId"], tests: ["permission", "workspace-param"] },
6132
6354
  "task.update": { status: "exposed", permission: "project.write", scope: "workspace: projectRoot", capability: CAPABILITY.task, params: ["projectRoot", "id", "action", "note", "ifRev"], tests: ["permission", "workspace-param"] },
6133
- "task.gate.resolve": { status: "exposed", permission: "project.write", scope: "workspace: projectRoot", capability: CAPABILITY.task, params: ["projectRoot", "id", "gate", "note", "ifRev"], tests: ["permission", "workspace-param"] },
6355
+ "task.gate.resolve": { status: "exposed", permission: "project.write", scope: "workspace: projectRoot", capability: CAPABILITY.task, params: ["projectRoot", "id", "gate", "note", "ifRev", "choice", "reject", "channel"], tests: ["permission", "workspace-param"] },
6134
6356
  "library.list": { status: "exposed", permission: "project.read", scope: "workspace: projectRoot (required by the gateway); rows (names, descriptions, sources, users) also come from the library and built-in layers; LIBRARY_ROW_FIELDS only, never content", capability: CAPABILITY.library, params: ["kind", "projectRoot"], tests: ["permission", "workspace-param", "row-fields"] },
6135
6357
  "library.models": { status: "exposed", permission: "session.read", scope: "none: model ids and labels, as catalog.get; MODEL_ROW_FIELDS only", capability: CAPABILITY.library, params: [], tests: ["permission", "row-fields"] },
6136
6358
  "settings.language.get": { status: "exposed", permission: "session.read", scope: "none: the language the user reads", capability: CAPABILITY.settingsLanguage, params: [], tests: ["permission"] },
@@ -6147,6 +6369,7 @@ var EXPOSURE = Object.freeze({
6147
6369
  "daemon.pause": { status: "denied", scope: "host", reason: "host.admin" },
6148
6370
  "daemon.resume": { status: "denied", scope: "host", reason: "host.admin" },
6149
6371
  "daemon.pauses": { status: "denied", scope: "host", reason: "host.admin" },
6372
+ "session.compact": { status: "prohibited", scope: "session", reason: "Compacting main is a local CLI operation (alp compact) for now; remote clients may get it later." },
6150
6373
  "daemon.shutdown": { status: "prohibited", scope: "host", reason: "Stops alpd." },
6151
6374
  "extension.register": { status: "prohibited", scope: "host", reason: "Would let a remote client serve methods every local client calls." },
6152
6375
  "extension.unregister": { status: "prohibited", scope: "host", reason: "Extension methods are never remote." },
@@ -6263,7 +6486,7 @@ function gitDiffFile(raw) {
6263
6486
  }
6264
6487
  return { path: source.path, ...source.oldPath !== void 0 ? { oldPath: source.oldPath } : {}, change: source.change, kind: source.kind, additions: source.additions, deletions: source.deletions, hunks };
6265
6488
  }
6266
- function projectGitDiff(raw, { path: path10 } = {}) {
6489
+ function projectGitDiff(raw, { path: path11 } = {}) {
6267
6490
  if (!plain(raw)) return { refused: "shape" };
6268
6491
  const source = (
6269
6492
  /** @type {Record<string, any>} */
@@ -6285,7 +6508,7 @@ function projectGitDiff(raw, { path: path10 } = {}) {
6285
6508
  hidden++;
6286
6509
  continue;
6287
6510
  }
6288
- if (path10 !== void 0 && file.path !== path10 && file.oldPath !== path10) {
6511
+ if (path11 !== void 0 && file.path !== path11 && file.oldPath !== path11) {
6289
6512
  foreign++;
6290
6513
  continue;
6291
6514
  }
@@ -6314,9 +6537,9 @@ function projectGitDiff(raw, { path: path10 } = {}) {
6314
6537
  }
6315
6538
 
6316
6539
  // packages/core/src/resolver.js
6317
- import path5 from "node:path";
6540
+ import path6 from "node:path";
6318
6541
  var KINDS = {
6319
- skills: (name2) => path5.join(name2, "SKILL.md"),
6542
+ skills: (name2) => path6.join(name2, "SKILL.md"),
6320
6543
  mcp: (name2) => `${name2}.json`,
6321
6544
  hooks: (name2) => `${name2}.json`,
6322
6545
  // ACP providers (ALPD §46) live only in the library.
@@ -6511,7 +6734,7 @@ var CONVERSATION_REFUSALS = Object.freeze({
6511
6734
  request_conflict: "A session with this newSessionId already exists",
6512
6735
  invalid_params: "The daemon host refused these parameters for this session"
6513
6736
  });
6514
- var ATTACHMENT_ERROR_DATA = Object.freeze(["received", "size", "max", "limit", "maxPerPrompt", "maxPromptBytes"]);
6737
+ var ATTACHMENT_ERROR_DATA = Object.freeze(["received", "size", "max", "limit", "maxPerPrompt", "maxPromptBytes", "attachmentId"]);
6515
6738
  var GIT_PAGE_PREFIX = "alp-gateway-page:";
6516
6739
  var MAX_GIT_PAGES = 64;
6517
6740
  var requestedFile = (file) => relativeFile(file) && !String(file).includes("\\");
@@ -6588,6 +6811,9 @@ var ClientConnection = class {
6588
6811
  #queue = [];
6589
6812
  #queuedBytes = 0;
6590
6813
  #helloed = false;
6814
+ /** The client said in daemon.hello that an ALP agent started it: the re-hello that says so on its alpd connection (t-e706). */
6815
+ /** @type {Promise<unknown> | undefined} */
6816
+ #agent;
6591
6817
  /** A hello waiting for alpd: requests pipelined behind it wait too, as alpd answers hello at once. */
6592
6818
  /** @type {Promise<unknown> | undefined} */
6593
6819
  #helloing;
@@ -6612,6 +6838,7 @@ var ClientConnection = class {
6612
6838
  #terminalLimits = gatewayTerminalLimits(void 0);
6613
6839
  /** alpd's terminal output events do not fit this gateway's frames: terminal.* is refused. */
6614
6840
  #terminalFramesTooSmall = false;
6841
+ #terminalWatching = false;
6615
6842
  /** Terminals this connection attached: only their terminal.event notifications leave (§5.18). @type {Set<string>} */
6616
6843
  #terminals = /* @__PURE__ */ new Set();
6617
6844
  /**
@@ -6664,17 +6891,20 @@ var ClientConnection = class {
6664
6891
  this.#capabilities = FORWARDED_CAPABILITIES.filter((capability) => listed.includes(capability));
6665
6892
  this.#attachmentLimits = gatewayAttachmentLimits(hello2.attachmentLimits, this.#limits.maxFrame);
6666
6893
  this.#terminalLimits = gatewayTerminalLimits(hello2.terminalLimits, this.#limits.maxFrame);
6667
- const daemonFrames = (
6894
+ const advertisedFrames = (
6668
6895
  /** @type {any} */
6669
6896
  hello2.terminalLimits?.maxOutputFrameBytes
6670
6897
  );
6671
- if (this.#capabilities.includes("terminal") && !(Number.isSafeInteger(daemonFrames) && daemonFrames <= this.#terminalLimits.maxOutputFrameBytes)) {
6672
- this.#capabilities = this.#capabilities.filter((capability) => capability !== "terminal");
6898
+ const daemonFrames = !listed.includes("terminal") && advertisedFrames === void 0 ? TERMINAL.maxOutputFrameBytes : advertisedFrames;
6899
+ this.#terminalFramesTooSmall = !(Number.isSafeInteger(daemonFrames) && daemonFrames <= this.#terminalLimits.maxOutputFrameBytes);
6900
+ if (this.#terminalFramesTooSmall) {
6901
+ this.#capabilities = this.#capabilities.filter((capability) => capability !== "terminal" && capability !== "terminal.capture");
6673
6902
  this.#terminalFramesTooSmall = true;
6674
6903
  this.#log.warn("alpd's terminal output does not fit this gateway's frame limit; terminals are not forwarded", { code: "ALP_GATEWAY_TERMINAL_FRAME" });
6675
6904
  }
6676
6905
  client.onNotification((method, params) => {
6677
6906
  if (method === "terminal.event") this.#terminalEvent(params);
6907
+ else if (method === "terminal.changed") this.#terminalChanged(params);
6678
6908
  });
6679
6909
  client.onEvent((envelope) => {
6680
6910
  if (!this.#capabilities.includes("workspace.worktree") || !this.#grant.permissions.has("workspace.manage")) {
@@ -6964,11 +7194,11 @@ var ClientConnection = class {
6964
7194
  async #handle(method, params) {
6965
7195
  if (method === "daemon.hello") {
6966
7196
  const greeting = this.#hello(params);
6967
- this.#helloing = greeting.catch(() => {
6968
- });
7197
+ this.#helloing = Promise.all([this.#helloing, greeting.catch(() => {
7198
+ })]);
6969
7199
  return greeting;
6970
7200
  }
6971
- if (!this.#helloed && this.#helloing) await this.#helloing;
7201
+ if (this.#helloing) await this.#helloing;
6972
7202
  if (!this.#helloed) throw new GatewayError(ERROR.protocol, "daemon.hello is required first", { reason: "hello_required" });
6973
7203
  await this.#refreshWorktrees();
6974
7204
  const exposure = exposureOf(method);
@@ -6993,6 +7223,15 @@ var ClientConnection = class {
6993
7223
  await this.#ready.catch(() => {
6994
7224
  throw new GatewayError(GATEWAY_ERROR.unavailable, "alpd is unavailable", { reason: GATEWAY_REASON.daemonDisconnected });
6995
7225
  });
7226
+ if (Array.isArray(params.capabilities) && params.capabilities.includes(AGENT_CAPABILITY)) this.#agent ??= this.#call("daemon.hello", { protocolVersion: PROTOCOL_VERSION, client: { name: "alp-gateway", version: "0" }, capabilities: [AGENT_CAPABILITY] });
7227
+ if (this.#agent) {
7228
+ try {
7229
+ await this.#agent;
7230
+ } catch {
7231
+ this.close(CLOSE_CODE2.internal, "Could not mark the agent connection to alpd; reconnect");
7232
+ throw new GatewayError(GATEWAY_ERROR.unavailable, "alpd is unavailable", { reason: GATEWAY_REASON.daemonDisconnected });
7233
+ }
7234
+ }
6996
7235
  this.#helloed = true;
6997
7236
  return {
6998
7237
  protocolVersion: PROTOCOL_VERSION,
@@ -7352,7 +7591,9 @@ var ClientConnection = class {
7352
7591
  const data = reason ? { reason } : {};
7353
7592
  for (const key2 of ATTACHMENT_ERROR_DATA) {
7354
7593
  const value = error.data?.[key2];
7355
- if (Number.isSafeInteger(value) && value >= 0 || key2 === "limit" && typeof value === "string" && /^[a-z_]{1,32}$/.test(value)) data[key2] = value;
7594
+ if (Number.isSafeInteger(value) && value >= 0 || key2 === "limit" && typeof value === "string" && /^[a-z_]{1,32}$/.test(value) || key2 === "attachmentId" && typeof value === "string" && /^att_[0-9a-f]{32}$/.test(value)) {
7595
+ data[key2] = value;
7596
+ }
7356
7597
  }
7357
7598
  return new GatewayError(error.code, reason ? ATTACHMENT_REFUSALS[reason] : "The attachment request failed on the daemon host", Object.keys(data).length ? data : void 0);
7358
7599
  }
@@ -7364,6 +7605,14 @@ var ClientConnection = class {
7364
7605
  */
7365
7606
  #terminalEvent(raw) {
7366
7607
  if (this.#closed) return;
7608
+ const candidate = (
7609
+ /** @type {any} */
7610
+ raw
7611
+ );
7612
+ if (candidate?.type === "output" && typeof candidate.data === "string" && this.#terminals.has(candidate.terminalId) && this.#grant.permissions.has("terminal.exec") && Buffer.byteLength(candidate.data) > this.#terminalLimits.maxOutputFrameBytes) {
7613
+ this.close(CLOSE_CODE2.internal, "Terminal output exceeds the negotiated frame limit; reconnect");
7614
+ return;
7615
+ }
7367
7616
  const event = projectTerminalEvent(raw, this.#terminalLimits.maxOutputFrameBytes);
7368
7617
  if (!event || !this.#terminals.has(event.terminalId) || !this.#grant.permissions.has("terminal.exec")) {
7369
7618
  this.#log.warn("dropped a terminal event this connection may not get", { code: "ALP_GATEWAY_EVENT_OUT_OF_SCOPE" });
@@ -7372,6 +7621,13 @@ var ClientConnection = class {
7372
7621
  if (event.type === "detached") this.#terminals.delete(event.terminalId);
7373
7622
  this.#push(JSON.stringify({ jsonrpc: "2.0", method: "terminal.event", params: event }));
7374
7623
  }
7624
+ /** Only this connection's authorized watch gets opaque invalidations; never host terminal data.
7625
+ * @param {any} raw */
7626
+ #terminalChanged(raw) {
7627
+ if (this.#closed || !this.#terminalWatching || !this.#grant.permissions.has("terminal.exec")) return;
7628
+ if (!/^[0-9a-f]{32}$/.test(raw?.watchId) || !/^[0-9a-f]{32}$/.test(raw?.cursor)) return;
7629
+ this.#push(JSON.stringify({ jsonrpc: "2.0", method: "terminal.changed", params: { watchId: raw.watchId, cursor: raw.cursor } }));
7630
+ }
7375
7631
  /** alpd's refusal of a terminal call: a fixed text per known reason, its code and reason, `limit` only. @param {unknown} caught */
7376
7632
  #terminalError(caught) {
7377
7633
  const error = (
@@ -7536,8 +7792,8 @@ var ClientConnection = class {
7536
7792
  * @param {unknown} directory */
7537
7793
  async #registryDirectory(directory) {
7538
7794
  const grant = this.#workspace(directory);
7539
- const canonical = await registryRealpath(grant.path).catch(() => void 0);
7540
- if (!canonical || canonical !== grant.canonical || !(await registryStat(canonical)).isDirectory()) throw forbidden("Granted directory changed; ask the owner to update the credential", GATEWAY_REASON.outsideWorkspace);
7795
+ const canonical2 = await registryRealpath(grant.path).catch(() => void 0);
7796
+ if (!canonical2 || canonical2 !== grant.canonical || !(await registryStat(canonical2)).isDirectory()) throw forbidden("Granted directory changed; ask the owner to update the credential", GATEWAY_REASON.outsideWorkspace);
7541
7797
  return grant;
7542
7798
  }
7543
7799
  async #registryRoots() {
@@ -7562,8 +7818,8 @@ var ClientConnection = class {
7562
7818
  throw forbidden("Workspace is unavailable to this credential", GATEWAY_REASON.outsideWorkspace);
7563
7819
  });
7564
7820
  const grant = await this.#registryDirectory(result?.workspace?.directory);
7565
- const canonical = await registryRealpath(result.workspace.directory).catch(() => void 0);
7566
- if (canonical !== grant.canonical || result.workspace.canonical && result.workspace.canonical !== canonical) throw forbidden("Workspace directory changed", GATEWAY_REASON.outsideWorkspace);
7821
+ const canonical2 = await registryRealpath(result.workspace.directory).catch(() => void 0);
7822
+ if (canonical2 !== grant.canonical || result.workspace.canonical && result.workspace.canonical !== canonical2) throw forbidden("Workspace directory changed", GATEWAY_REASON.outsideWorkspace);
7567
7823
  return result;
7568
7824
  }
7569
7825
  /** Principal-scoped durable IDs without trusting an actor field from the client. @param {string} id */
@@ -7633,7 +7889,11 @@ var ClientConnection = class {
7633
7889
  const result = await this.#registryCall("project.remove", { ...params, authorizedRoots: await this.#registryRoots(), requestId: this.#registryRequestId(params.requestId) });
7634
7890
  return { project: this.#registryProjection(result.project, "project"), revision: result.revision };
7635
7891
  },
7636
- "catalog.get": () => this.#call("catalog.get", {}),
7892
+ // Provider errors can name host paths and exit codes: remote clients get each provider's status only (t-e5ee).
7893
+ "catalog.get": async () => {
7894
+ const { providers, ...catalog } = await this.#call("catalog.get", {});
7895
+ return providers && typeof providers === "object" ? { ...catalog, providers: Object.fromEntries(Object.entries(providers).map(([runtime, state]) => [runtime, { status: state?.status, ...typeof state?.fetchedAt === "string" ? { fetchedAt: state.fetchedAt } : {} }])) } : catalog;
7896
+ },
7637
7897
  "session.list": async (params) => {
7638
7898
  const only = params.projectRoot === void 0 ? void 0 : this.#workspace(params.projectRoot);
7639
7899
  const { projectRoot: _projectRoot, cursor: sealed, ...rest } = params;
@@ -7852,6 +8112,14 @@ ${session.id}`.toLowerCase().includes(word))));
7852
8112
  await this.#seeForkSources([session]);
7853
8113
  return { session: this.#safeSession(session), ...result.duplicate === true ? { duplicate: true } : {} };
7854
8114
  },
8115
+ // The composer's "/" list: known fields of each entry only, never a path.
8116
+ "session.commands": async (params) => {
8117
+ await this.#resolve(params.sessionId);
8118
+ const result = await this.#call("session.commands", params);
8119
+ const text = (value, max) => typeof value === "string" ? value.slice(0, max) : "";
8120
+ const commands = (Array.isArray(result?.commands) ? result.commands : []).filter((entry) => entry && typeof entry.name === "string" && /^[^\s\u0000-\u001f\u007f]{1,256}$/.test(entry.name)).slice(0, 1e3).map((entry) => ({ name: entry.name, description: text(entry.description, 4096), ...typeof entry.argumentHint === "string" && entry.argumentHint ? { argumentHint: text(entry.argumentHint, 256) } : {}, kind: entry.kind === "skill" ? "skill" : "command" }));
8121
+ return { commands };
8122
+ },
7855
8123
  // The ALP CLI command for the clipboard: rebuilt here from the id, passed on only when alpd's is the same.
7856
8124
  "session.resumeCommand": async (params) => {
7857
8125
  await this.#resolve(params.sessionId);
@@ -8092,6 +8360,38 @@ ${session.id}`.toLowerCase().includes(word))));
8092
8360
  if (!Array.isArray(result?.terminals)) throw new GatewayError(ERROR.failed, "The daemon host answered a list the gateway does not pass on");
8093
8361
  return { terminals: result.terminals.map((entry) => this.#terminalAnswer(entry, "terminal.list")) };
8094
8362
  },
8363
+ "terminal.watch": async (params) => {
8364
+ if (params.workspaceId !== void 0) await this.#registryWorkspace(params.workspaceId);
8365
+ this.#terminalWatching = true;
8366
+ try {
8367
+ const result = (
8368
+ /** @type {any} */
8369
+ await this.#terminalCall("terminal.watch", params)
8370
+ );
8371
+ if (!Array.isArray(result?.terminals) || !/^[0-9a-f]{32}$/.test(result.watchId) || !/^[0-9a-f]{32}$/.test(result.cursor) || typeof result.reset !== "boolean") throw new GatewayError(ERROR.failed, "Invalid terminal snapshot from daemon host");
8372
+ const safe = { terminals: result.terminals.map((entry) => this.#terminalAnswer(entry, "terminal.watch")), watchId: result.watchId, cursor: result.cursor, reset: result.reset };
8373
+ if (Buffer.byteLength(JSON.stringify(safe)) > (this.#limits.maxFrame ?? 512 * 1024) - 1024) throw new GatewayError(GATEWAY_ERROR.unavailable, "Terminal snapshot exceeds this gateway frame limit; select a workspace", { reason: "terminal_snapshot_too_large" });
8374
+ return safe;
8375
+ } catch (error) {
8376
+ this.#terminalWatching = false;
8377
+ throw error;
8378
+ }
8379
+ },
8380
+ "terminal.unwatch": async () => {
8381
+ this.#terminalWatching = false;
8382
+ await this.#call("terminal.unwatch", {});
8383
+ return { closed: true };
8384
+ },
8385
+ "terminal.capture": async (params) => {
8386
+ const result = (
8387
+ /** @type {any} */
8388
+ await this.#terminalCall("terminal.capture", params)
8389
+ );
8390
+ if (!Array.isArray(result?.lines) || !result.lines.every((line) => typeof line === "string") || !Number.isSafeInteger(result.totalLines) || result.totalLines < 0 || result.lines.length > result.totalLines) throw new GatewayError(ERROR.failed, "The daemon host answered a capture the gateway does not pass on");
8391
+ const safe = { lines: result.lines, totalLines: result.totalLines };
8392
+ if (Buffer.byteLength(JSON.stringify(safe)) > (this.#limits.maxFrame ?? 512 * 1024) - 1024) throw new GatewayError(GATEWAY_ERROR.unavailable, "Terminal capture exceeds this gateway frame limit; select a smaller line range", { reason: "terminal_capture_too_large" });
8393
+ return safe;
8394
+ },
8095
8395
  "terminal.attach": async (params) => {
8096
8396
  const known = this.#terminals.has(params.terminalId);
8097
8397
  this.#terminals.add(params.terminalId);
@@ -8446,6 +8746,11 @@ function createGateway({ config, store, openTransport, logger, version, monitorI
8446
8746
  const tickets = new TicketBook({ ttlMs: limits.ticketTtlMs });
8447
8747
  const connections = /* @__PURE__ */ new Set();
8448
8748
  const perPrincipal = /* @__PURE__ */ new Map();
8749
+ const decrementPrincipal = (id) => {
8750
+ const next = (perPrincipal.get(id) ?? 1) - 1;
8751
+ if (next <= 0) perPrincipal.delete(id);
8752
+ else perPrincipal.set(id, next);
8753
+ };
8449
8754
  let opening = 0;
8450
8755
  const failures = /* @__PURE__ */ new Map();
8451
8756
  const connectUpstream = upstreamConnector({ openTransport, version, maxPending: limits.maxPending });
@@ -8611,7 +8916,7 @@ Content-Length: 0\r
8611
8916
  socket.once("close", () => {
8612
8917
  if (!settled) {
8613
8918
  release();
8614
- perPrincipal.set(grant.id, (perPrincipal.get(grant.id) ?? 1) - 1);
8919
+ decrementPrincipal(grant.id);
8615
8920
  }
8616
8921
  });
8617
8922
  wss.handleUpgrade(request, socket, head, (ws) => {
@@ -8622,8 +8927,7 @@ Content-Length: 0\r
8622
8927
  const uncount = () => {
8623
8928
  if (!counted) return;
8624
8929
  counted = false;
8625
- perPrincipal.set(grant.id, Math.max(0, (perPrincipal.get(grant.id) ?? 1) - 1));
8626
- if (!perPrincipal.get(grant.id)) perPrincipal.delete(grant.id);
8930
+ decrementPrincipal(grant.id);
8627
8931
  };
8628
8932
  try {
8629
8933
  const connection = new ClientConnection({
@@ -8698,6 +9002,7 @@ Content-Length: 0\r
8698
9002
  return {
8699
9003
  connections,
8700
9004
  tickets,
9005
+ perPrincipal,
8701
9006
  get monitor() {
8702
9007
  return monitor;
8703
9008
  },
@@ -8763,12 +9068,39 @@ Content-Length: 0\r
8763
9068
 
8764
9069
  // apps/gateway/src/credentials.js
8765
9070
  import { createHash as createHash5, randomBytes as randomBytes4, timingSafeEqual } from "node:crypto";
8766
- import { lstat as lstat2, readFile as readFile4, realpath as realpath2, rename as rename3, stat as stat3, writeFile as writeFile4, chmod, unlink as unlink5 } from "node:fs/promises";
8767
- import path6 from "node:path";
9071
+ import { lstat as lstat2, readFile as readFile4, realpath as realpath2, rename as rename3, stat as stat3, writeFile as writeFile5, chmod, unlink as unlink5 } from "node:fs/promises";
9072
+ import { setTimeout as sleep } from "node:timers/promises";
9073
+ import path7 from "node:path";
9074
+ var RETRIABLE_RENAME_ERRORS = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
9075
+ var RENAME_MAX_RETRIES = 8;
9076
+ var RENAME_INITIAL_BACKOFF_MS = 10;
9077
+ var RENAME_MAX_BACKOFF_MS = 80;
9078
+ async function renameWithRetry(temporary, destination, {
9079
+ retries = RENAME_MAX_RETRIES,
9080
+ initialBackoffMs = RENAME_INITIAL_BACKOFF_MS,
9081
+ maxBackoffMs = RENAME_MAX_BACKOFF_MS,
9082
+ sleep: delayFn = sleep
9083
+ } = {}) {
9084
+ for (let attempt = 0; ; attempt++) {
9085
+ try {
9086
+ await rename3(temporary, destination);
9087
+ return;
9088
+ } catch (error) {
9089
+ if (!RETRIABLE_RENAME_ERRORS.has(
9090
+ /** @type {any} */
9091
+ error?.code
9092
+ ) || attempt >= retries) {
9093
+ throw error;
9094
+ }
9095
+ const delay2 = Math.min(initialBackoffMs * 2 ** attempt, maxBackoffMs);
9096
+ await delayFn(delay2);
9097
+ }
9098
+ }
9099
+ }
8768
9100
  var TOKEN = /^alpgw1\.([a-f0-9]{16})\.([A-Za-z0-9_-]{43})$/;
8769
9101
  var FILE_VERSION = 1;
8770
9102
  var MODE = /^[a-z][a-z0-9-]{0,63}$/;
8771
- var credentialsFile = (home) => path6.join(home, "credentials.json");
9103
+ var credentialsFile = (home) => path7.join(home, "credentials.json");
8772
9104
  var digest = (secret) => createHash5("sha256").update(secret, "utf8").digest("hex");
8773
9105
  function parseToken(token) {
8774
9106
  const match = typeof token === "string" ? TOKEN.exec(token) : null;
@@ -8799,10 +9131,10 @@ async function writeCredentials(home, data) {
8799
9131
  const file = credentialsFile(home);
8800
9132
  const temporary = `${file}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`;
8801
9133
  try {
8802
- await writeFile4(temporary, `${JSON.stringify(data, null, 2)}
9134
+ await writeFile5(temporary, `${JSON.stringify(data, null, 2)}
8803
9135
  `, { mode: 384, flag: "wx" });
8804
9136
  await chmod(temporary, 384);
8805
- await rename3(temporary, file);
9137
+ await renameWithRetry(temporary, file);
8806
9138
  } catch (error) {
8807
9139
  await unlink5(temporary).catch(() => {
8808
9140
  });
@@ -8816,12 +9148,12 @@ async function resolveWorkspaces(workspaces) {
8816
9148
  if (!Array.isArray(workspaces) || !workspaces.length) throw new Error("A credential needs at least one workspace");
8817
9149
  const resolved = [];
8818
9150
  for (const entry of workspaces) {
8819
- if (typeof entry !== "string" || !path6.isAbsolute(entry) || path6.resolve(entry) !== entry || entry.includes("\0")) {
9151
+ if (typeof entry !== "string" || !path7.isAbsolute(entry) || path7.resolve(entry) !== entry || entry.includes("\0")) {
8820
9152
  throw new Error(`Workspace ${JSON.stringify(entry)} must be an absolute, normalized path`);
8821
9153
  }
8822
- const canonical = await realpath2(entry);
8823
- if (!(await stat3(canonical)).isDirectory()) throw new Error(`Workspace ${entry} is not a directory`);
8824
- if (!resolved.some((known) => known.canonical === canonical)) resolved.push({ path: entry, canonical });
9154
+ const canonical2 = await realpath2(entry);
9155
+ if (!(await stat3(canonical2)).isDirectory()) throw new Error(`Workspace ${entry} is not a directory`);
9156
+ if (!resolved.some((known) => known.canonical === canonical2)) resolved.push({ path: entry, canonical: canonical2 });
8825
9157
  }
8826
9158
  return resolved;
8827
9159
  }
@@ -8897,7 +9229,7 @@ function grantOf(stored, now) {
8897
9229
  if (stored.revokedAt) return void 0;
8898
9230
  const expiresAt = stored.expiresAt === void 0 ? void 0 : Date.parse(stored.expiresAt);
8899
9231
  if (expiresAt !== void 0 && !(expiresAt > now)) return void 0;
8900
- const workspaces = Array.isArray(stored.workspaces) ? stored.workspaces.filter((entry) => typeof entry?.path === "string" && typeof entry?.canonical === "string" && path6.isAbsolute(entry.path) && path6.isAbsolute(entry.canonical)) : [];
9232
+ const workspaces = Array.isArray(stored.workspaces) ? stored.workspaces.filter((entry) => typeof entry?.path === "string" && typeof entry?.canonical === "string" && path7.isAbsolute(entry.path) && path7.isAbsolute(entry.canonical)) : [];
8901
9233
  const permissions = Array.isArray(stored.permissions) ? stored.permissions.filter((permission) => PERMISSIONS.includes(permission)) : [];
8902
9234
  if (!workspaces.length || !permissions.length || typeof stored.hash !== "string" || !/^[a-f0-9]{64}$/.test(stored.hash)) return void 0;
8903
9235
  let mappingIds;
@@ -8912,7 +9244,7 @@ function grantOf(stored, now) {
8912
9244
  {
8913
9245
  id: stored.id,
8914
9246
  label: String(stored.label ?? ""),
8915
- workspaces: workspaces.map(({ path: given, canonical }) => ({ path: given, canonical })),
9247
+ workspaces: workspaces.map(({ path: given, canonical: canonical2 }) => ({ path: given, canonical: canonical2 })),
8916
9248
  permissions: new Set(permissions),
8917
9249
  worktreeMappings: mappingIds,
8918
9250
  scopeId: stored.scopeId ?? digest(JSON.stringify([workspaces, permissions, stored.worktreeMappings ?? []])),
@@ -9055,10 +9387,10 @@ function createGatewayLogger({ write, level, env } = {}) {
9055
9387
 
9056
9388
  // packages/cli/src/web/grant.js
9057
9389
  import { mkdir as mkdir5, realpath as realpath3, stat as stat4 } from "node:fs/promises";
9058
- import path7 from "node:path";
9390
+ import path8 from "node:path";
9059
9391
  var LABEL = "alp web (this machine)";
9060
9392
  var BASE_PERMISSIONS = Object.freeze([...DEFAULT_PERMISSIONS, "workspace.write"]);
9061
- var webGatewayHome = (home) => path7.join(home, "web");
9393
+ var webGatewayHome = (home) => path8.join(home, "web");
9062
9394
  function grantPermissions(extra, warn = () => {
9063
9395
  }) {
9064
9396
  const wanted = new Set(BASE_PERMISSIONS);
@@ -9078,10 +9410,10 @@ function grantPermissions(extra, warn = () => {
9078
9410
  async function existingWorkspaces(paths) {
9079
9411
  const found = [];
9080
9412
  for (const entry of paths) {
9081
- if (typeof entry !== "string" || !path7.isAbsolute(entry) || path7.resolve(entry) !== entry || entry.includes("\0")) continue;
9082
- const canonical = await realpath3(entry).catch(() => void 0);
9083
- if (!canonical || !await stat4(canonical).then((info) => info.isDirectory(), () => false)) continue;
9084
- if (!found.some((known) => known.canonical === canonical)) found.push({ path: entry, canonical });
9413
+ if (typeof entry !== "string" || !path8.isAbsolute(entry) || path8.resolve(entry) !== entry || entry.includes("\0")) continue;
9414
+ const canonical2 = await realpath3(entry).catch(() => void 0);
9415
+ if (!canonical2 || !await stat4(canonical2).then((info) => info.isDirectory(), () => false)) continue;
9416
+ if (!found.some((known) => known.canonical === canonical2)) found.push({ path: entry, canonical: canonical2 });
9085
9417
  }
9086
9418
  return found;
9087
9419
  }
@@ -9146,7 +9478,7 @@ var samePermissions = (a, b) => JSON.stringify([...a].sort()) === JSON.stringify
9146
9478
  function createGrant({ home, store, permissions, project, socket, log = () => {
9147
9479
  } }) {
9148
9480
  const credentialsHome = webGatewayHome(home);
9149
- const placeholder = path7.join(credentialsHome, "no-project");
9481
+ const placeholder = path8.join(credentialsHome, "no-project");
9150
9482
  let tail2 = Promise.resolve();
9151
9483
  const serial = (run2) => {
9152
9484
  const result = tail2.then(run2);
@@ -9232,7 +9564,7 @@ function createGrant({ home, store, permissions, project, socket, log = () => {
9232
9564
  // packages/cli/src/web/serve.js
9233
9565
  import { createReadStream } from "node:fs";
9234
9566
  import { realpath as realpath4, stat as stat5 } from "node:fs/promises";
9235
- import path8 from "node:path";
9567
+ import path9 from "node:path";
9236
9568
  var TYPES = {
9237
9569
  ".html": "text/html; charset=utf-8",
9238
9570
  ".js": "text/javascript; charset=utf-8",
@@ -9286,10 +9618,10 @@ function parseTarget(raw) {
9286
9618
  var isFile2 = (file) => stat5(file).then((info) => info.isFile(), () => false);
9287
9619
  function createStaticServer({ dir, csp, log = () => {
9288
9620
  } }) {
9289
- const configured = path8.resolve(dir);
9621
+ const configured = path9.resolve(dir);
9290
9622
  let root;
9291
9623
  const appRoot = async () => {
9292
- const found = await (root ??= realpath4(configured).then(async (real) => await isFile2(path8.join(real, "index.html")) ? real : void 0, () => void 0));
9624
+ const found = await (root ??= realpath4(configured).then(async (real) => await isFile2(path9.join(real, "index.html")) ? real : void 0, () => void 0));
9293
9625
  if (!found) root = void 0;
9294
9626
  return found;
9295
9627
  };
@@ -9308,14 +9640,14 @@ function createStaticServer({ dir, csp, log = () => {
9308
9640
  response.end(request.method === "HEAD" ? void 0 : text);
9309
9641
  }
9310
9642
  async function contained(base, segments) {
9311
- const candidate = path8.join(base, ...segments);
9643
+ const candidate = path9.join(base, ...segments);
9312
9644
  let real;
9313
9645
  try {
9314
9646
  real = await realpath4(candidate);
9315
9647
  } catch {
9316
9648
  return void 0;
9317
9649
  }
9318
- if (real !== base && !real.startsWith(base + path8.sep)) return void 0;
9650
+ if (real !== base && !real.startsWith(base + path9.sep)) return void 0;
9319
9651
  return await isFile2(real) ? real : void 0;
9320
9652
  }
9321
9653
  return async function serveStatic(request, response) {
@@ -9335,7 +9667,7 @@ function createStaticServer({ dir, csp, log = () => {
9335
9667
  let file = segments.length ? await contained(base, segments) : void 0;
9336
9668
  if (!file) {
9337
9669
  const last = segments.at(-1) ?? "";
9338
- if (path8.extname(last)) {
9670
+ if (path9.extname(last)) {
9339
9671
  plain3(request, response, 404, "Not found");
9340
9672
  return true;
9341
9673
  }
@@ -9345,8 +9677,8 @@ function createStaticServer({ dir, csp, log = () => {
9345
9677
  return true;
9346
9678
  }
9347
9679
  }
9348
- const relative = path8.relative(base, file).split(path8.sep).join("/");
9349
- const type = TYPES[path8.extname(file).toLowerCase()] ?? "application/octet-stream";
9680
+ const relative = path9.relative(base, file).split(path9.sep).join("/");
9681
+ const type = TYPES[path9.extname(file).toLowerCase()] ?? "application/octet-stream";
9350
9682
  const cache = relative === "index.html" ? "no-cache" : relative.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-cache";
9351
9683
  const { size } = await stat5(file);
9352
9684
  response.writeHead(200, { ...headers(type, cache), "content-length": String(size) });
@@ -9363,18 +9695,18 @@ function createStaticServer({ dir, csp, log = () => {
9363
9695
  }
9364
9696
 
9365
9697
  // packages/cli/src/web/main.js
9366
- var VERSION = true ? "0.0.1-beta.4" : "0.0.0-source";
9698
+ var VERSION = true ? "0.0.1-beta.7" : "0.0.0-source";
9367
9699
  var DEFAULT_WEB_PORT = 7433;
9368
9700
  var PORT_TRIES = 10;
9369
9701
  var REFRESH_MS = Number(process.env.ALP_WEB_GRANT_REFRESH_MS) > 0 ? Number(process.env.ALP_WEB_GRANT_REFRESH_MS) : 5e3;
9370
9702
  var WEB_FILE_VERSION = 2;
9371
- var here = path9.dirname(fileURLToPath(import.meta.url));
9372
- var appDir = () => path9.resolve(process.env.ALP_WEB_APP || path9.join(here, "alp-web"));
9373
- var daemonEntry = () => process.env.ALP_DAEMON_ENTRY ?? path9.join(here, "alpd.js");
9374
- var webFile = (home) => path9.join(home, "web.json");
9703
+ var here = path10.dirname(fileURLToPath(import.meta.url));
9704
+ var appDir = () => path10.resolve(process.env.ALP_WEB_APP || path10.join(here, "alp-web"));
9705
+ var daemonEntry = () => process.env.ALP_DAEMON_ENTRY ?? selfEntry(path10.join(here, "alpd.js"));
9706
+ var webFile = (home) => path10.join(home, "web.json");
9375
9707
  function serviceLog(home) {
9376
- const file = path9.join(home, "logs", "integrations", "alp-web.log");
9377
- mkdirSync(path9.dirname(file), { recursive: true, mode: 448 });
9708
+ const file = path10.join(home, "logs", "integrations", "alp-web.log");
9709
+ mkdirSync(path10.dirname(file), { recursive: true, mode: 448 });
9378
9710
  const fd = openSync(file, "a", 384);
9379
9711
  for (const stream of [process.stdout, process.stderr]) {
9380
9712
  stream.write = /** @type {any} */
@@ -9389,7 +9721,7 @@ function serviceLog(home) {
9389
9721
  }
9390
9722
  }
9391
9723
  async function userSettings(home, log) {
9392
- const file = path9.join(home, "settings.json");
9724
+ const file = path10.join(home, "settings.json");
9393
9725
  let text;
9394
9726
  try {
9395
9727
  text = await readFile5(file, "utf8");
@@ -9420,10 +9752,10 @@ async function publish(home, info) {
9420
9752
  const file = webFile(home);
9421
9753
  const temporary = `${file}.${process.pid}.${randomBytes5(4).toString("hex")}.tmp`;
9422
9754
  try {
9423
- await writeFile5(temporary, `${JSON.stringify(info)}
9755
+ await writeFile6(temporary, `${JSON.stringify(info)}
9424
9756
  `, { mode: 384, flag: "wx" });
9425
9757
  await chmod2(temporary, 384);
9426
- await rename4(temporary, file);
9758
+ await renameWithRetry(temporary, file);
9427
9759
  } catch (error) {
9428
9760
  await unlink6(temporary).catch(() => {
9429
9761
  });
@@ -9444,10 +9776,10 @@ async function carryPaseoIdentity(home, log) {
9444
9776
  ...typeof legacy.serverId === "string" && /^alp-[a-f0-9]{16}$/.test(legacy.serverId) ? { serverId: legacy.serverId } : {}
9445
9777
  };
9446
9778
  if (!Object.keys(identity).length) return false;
9447
- const target = path9.join(home, "paseo.json");
9779
+ const target = path10.join(home, "paseo.json");
9448
9780
  const temporary = `${target}.${process.pid}.${randomBytes5(4).toString("hex")}.tmp`;
9449
9781
  try {
9450
- await writeFile5(temporary, `${JSON.stringify(identity)}
9782
+ await writeFile6(temporary, `${JSON.stringify(identity)}
9451
9783
  `, { mode: 384, flag: "wx" });
9452
9784
  await chmod2(temporary, 384);
9453
9785
  await link2(temporary, target);
@@ -9520,12 +9852,12 @@ async function run() {
9520
9852
  if (values.service) serviceLog(home);
9521
9853
  const log = createGatewayLogger();
9522
9854
  const settings = await userSettings(home, log);
9523
- if (values.rotate) return rotate(home, values.project ? path9.resolve(values.project) : void 0, settings, log);
9855
+ if (values.rotate) return rotate(home, values.project ? path10.resolve(values.project) : void 0, settings, log);
9524
9856
  if (settings?.web?.enabled === false) {
9525
9857
  log.info('alp web is disabled by settings ("web.enabled": false)', { code: "ALP_WEB_DISABLED" });
9526
9858
  process.exit(0);
9527
9859
  }
9528
- const project = values.project ? path9.resolve(values.project) : void 0;
9860
+ const project = values.project ? path10.resolve(values.project) : void 0;
9529
9861
  const lock = createIntegrationLock(home, "web");
9530
9862
  const { acquired, lock: held } = await lock.acquire();
9531
9863
  if (!acquired) {
@@ -9610,11 +9942,12 @@ async function run() {
9610
9942
  } catch (error) {
9611
9943
  await candidate.close().catch(() => {
9612
9944
  });
9613
- if (
9945
+ const code = (
9614
9946
  /** @type {any} */
9615
- error?.code !== "EADDRINUSE" || attempt + 1 >= PORT_TRIES
9616
- ) throw error;
9617
- log.info(`port ${port} is in use; trying ${port + 1}`, { code: "ALP_WEB_PORT_BUSY" });
9947
+ error?.code
9948
+ );
9949
+ if (code !== "EADDRINUSE" && code !== "EACCES" || attempt + 1 >= PORT_TRIES) throw error;
9950
+ log.info(`port ${port} is ${code === "EACCES" ? "not available" : "in use"}; trying ${port + 1}`, { code: "ALP_WEB_PORT_BUSY" });
9618
9951
  }
9619
9952
  }
9620
9953
  if (shuttingDown) return;
@@ -9626,6 +9959,27 @@ async function run() {
9626
9959
  }, REFRESH_MS);
9627
9960
  timer.unref();
9628
9961
  cleanups.push(async () => clearInterval(timer));
9962
+ const stateDir = path10.join(home, "state");
9963
+ try {
9964
+ await mkdir6(stateDir, { recursive: true, mode: 448 });
9965
+ let debounce;
9966
+ const watcher = watch(stateDir, (_eventType, filename) => {
9967
+ const name2 = typeof filename === "string" ? filename : void 0;
9968
+ if (!name2 || name2 === "web-workspaces.json" || name2.startsWith("web-workspaces.json")) {
9969
+ clearTimeout(debounce);
9970
+ debounce = setTimeout(() => {
9971
+ if (!shuttingDown) void grant.refresh();
9972
+ }, 20);
9973
+ debounce?.unref?.();
9974
+ }
9975
+ });
9976
+ watcher.unref();
9977
+ cleanups.push(async () => {
9978
+ clearTimeout(debounce);
9979
+ watcher.close();
9980
+ });
9981
+ } catch {
9982
+ }
9629
9983
  if (!await lock.setReady(true)) throw new Error("the web lock is no longer held by this process");
9630
9984
  log.info(`alp web on ${url}`, { code: "ALP_WEB_LISTENING" });
9631
9985
  })();
@@ -9634,7 +9988,10 @@ async function run() {
9634
9988
  void shutdown(1);
9635
9989
  });
9636
9990
  }
9637
- await run();
9991
+ await run().catch((error) => {
9992
+ createGatewayLogger().error("alp web did not start", { code: "ALP_WEB_START_FAILED", error });
9993
+ process.exitCode = 1;
9994
+ });
9638
9995
  export {
9639
9996
  DEFAULT_WEB_PORT
9640
9997
  };