@anhlp/alp-daemon 0.0.1-beta.3 → 0.0.1-beta.5

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 (95) hide show
  1. package/README.md +4 -0
  2. package/dist/THIRD-PARTY-NOTICES.txt +26 -1
  3. package/dist/alpd.js +29928 -14898
  4. package/dist/attachments.d.ts +187 -0
  5. package/dist/attachments.js +856 -0
  6. package/dist/build-manifest.json +34 -1
  7. package/dist/conversation.d.ts +119 -0
  8. package/dist/conversation.js +688 -0
  9. package/dist/disk.d.ts +67 -0
  10. package/dist/disk.js +152 -0
  11. package/dist/files.d.ts +154 -2
  12. package/dist/files.js +392 -68
  13. package/dist/git.d.ts +93 -0
  14. package/dist/git.js +1192 -0
  15. package/dist/gitignore.d.ts +5 -0
  16. package/dist/gitignore.js +7 -1
  17. package/dist/history.d.ts +24 -0
  18. package/dist/history.js +149 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +21 -1
  21. package/dist/lifecycle.d.ts +101 -0
  22. package/dist/lifecycle.js +239 -0
  23. package/dist/main.js +43 -11
  24. package/dist/native-terminal.d.ts +45 -0
  25. package/dist/native-terminal.js +198 -0
  26. package/dist/operations.d.ts +8 -2
  27. package/dist/operations.js +20 -10
  28. package/dist/registry.d.ts +89 -0
  29. package/dist/registry.js +343 -0
  30. package/dist/scheduler.d.ts +96 -0
  31. package/dist/scheduler.js +296 -0
  32. package/dist/schedules.d.ts +70 -0
  33. package/dist/schedules.js +246 -0
  34. package/dist/server.d.ts +14 -2
  35. package/dist/server.js +836 -90
  36. package/dist/store.d.ts +72 -2
  37. package/dist/store.js +111 -4
  38. package/dist/terminal-native/README.md +201 -0
  39. package/dist/terminal-native/prebuilt/darwin-arm64/manifest.json +11 -0
  40. package/dist/terminal-native/prebuilt/darwin-arm64/terminal-owner +0 -0
  41. package/dist/terminal-native/prebuilt/darwin-x64/manifest.json +11 -0
  42. package/dist/terminal-native/prebuilt/darwin-x64/terminal-owner +0 -0
  43. package/dist/terminal-native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  44. package/dist/terminal-native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  45. package/dist/terminal-native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  46. package/dist/terminal-native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  47. package/dist/terminal-native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  48. package/dist/terminal-native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  49. package/dist/terminal-native/prebuilt/linux-x64-musl/manifest.json +10 -0
  50. package/dist/terminal-native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  51. package/dist/terminal-native/terminal-owner.c +389 -0
  52. package/dist/terminal-screen.d.ts +24 -0
  53. package/dist/terminal-screen.js +99 -0
  54. package/dist/terminals.d.ts +193 -0
  55. package/dist/terminals.js +570 -0
  56. package/dist/windows-terminal.d.ts +29 -0
  57. package/dist/windows-terminal.js +122 -0
  58. package/dist/worktrees.d.ts +65 -0
  59. package/dist/worktrees.js +318 -0
  60. package/native/README.md +201 -0
  61. package/native/prebuilt/darwin-arm64/manifest.json +11 -0
  62. package/native/prebuilt/darwin-arm64/terminal-owner +0 -0
  63. package/native/prebuilt/darwin-x64/manifest.json +11 -0
  64. package/native/prebuilt/darwin-x64/terminal-owner +0 -0
  65. package/native/prebuilt/linux-arm64-glibc/manifest.json +10 -0
  66. package/native/prebuilt/linux-arm64-glibc/terminal-owner +0 -0
  67. package/native/prebuilt/linux-arm64-musl/manifest.json +10 -0
  68. package/native/prebuilt/linux-arm64-musl/terminal-owner +0 -0
  69. package/native/prebuilt/linux-x64-glibc/manifest.json +10 -0
  70. package/native/prebuilt/linux-x64-glibc/terminal-owner +0 -0
  71. package/native/prebuilt/linux-x64-musl/manifest.json +10 -0
  72. package/native/prebuilt/linux-x64-musl/terminal-owner +0 -0
  73. package/native/terminal-owner.c +389 -0
  74. package/package.json +70 -7
  75. package/src/attachments.ts +908 -0
  76. package/src/conversation.ts +857 -0
  77. package/src/disk.ts +175 -0
  78. package/src/files.ts +528 -82
  79. package/src/git.ts +1140 -0
  80. package/src/gitignore.ts +10 -0
  81. package/src/history.ts +118 -0
  82. package/src/index.ts +7 -0
  83. package/src/lifecycle.ts +283 -0
  84. package/src/main.ts +37 -12
  85. package/src/native-terminal.ts +122 -0
  86. package/src/operations.ts +27 -11
  87. package/src/registry.ts +238 -0
  88. package/src/scheduler.ts +432 -0
  89. package/src/schedules.ts +297 -0
  90. package/src/server.ts +948 -102
  91. package/src/store.ts +117 -4
  92. package/src/terminal-screen.ts +74 -0
  93. package/src/terminals.ts +641 -0
  94. package/src/windows-terminal.ts +123 -0
  95. package/src/worktrees.ts +382 -0
@@ -0,0 +1,198 @@
1
+ // packages/daemon/src/native-terminal.ts
2
+ import { spawn, spawnSync } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import { existsSync, readFileSync, statSync } from "node:fs";
5
+ import { fileURLToPath } from "node:url";
6
+ import path from "node:path";
7
+ import { StringDecoder } from "node:string_decoder";
8
+ var sha = (value) => createHash("sha256").update(value).digest("hex");
9
+ function binary() {
10
+ const libc = process.platform === "linux" ? process.report?.getReport()?.header?.glibcVersionRuntime ? "glibc" : "musl" : void 0;
11
+ const slot = [process.platform, process.arch, libc].filter(Boolean).join("-");
12
+ const assets = globalThis[Symbol.for("alp.packaged")]?.assetDir?.();
13
+ const adjacent = assets ? path.join(assets, "terminal-native") : path.join(path.dirname(fileURLToPath(import.meta.url)), "terminal-native");
14
+ const dir = assets || existsSync(adjacent) ? adjacent : path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../native");
15
+ const file = path.join(dir, "prebuilt", slot, "terminal-owner");
16
+ const manifest = JSON.parse(readFileSync(path.join(path.dirname(file), "manifest.json"), "utf8"));
17
+ if (!statSync(file).isFile() || manifest.protocol !== 1 || manifest.slot !== slot || manifest.source !== sha(readFileSync(path.join(dir, "terminal-owner.c"))) || manifest.sha256 !== sha(readFileSync(file))) throw new Error("Native helper manifest mismatch");
18
+ return file;
19
+ }
20
+ function nativeCapabilityOf(probe, platform) {
21
+ if (probe.status === 0 && probe.stdout.trim() === "alp-terminal-owner:1") return { available: true };
22
+ if (platform === "linux" && probe.status === 0 && probe.stdout.trim() === "alp-terminal-owner:1:root-only") return { available: true, protection: "root-only", reason: "bound_signal_unavailable" };
23
+ return { available: false, reason: "native_capability_unavailable" };
24
+ }
25
+ function nativeTerminalCapability() {
26
+ try {
27
+ const probe = spawnSync(binary(), ["--capability"], { encoding: "utf8", timeout: 2e3, maxBuffer: 4096 });
28
+ return nativeCapabilityOf(probe, process.platform);
29
+ } catch {
30
+ return { available: false, reason: "native_prebuilt_unavailable" };
31
+ }
32
+ }
33
+ async function nativePtySpawn(file, args, options) {
34
+ if (options.signal?.aborted) throw new Error("Native terminal startup cancelled");
35
+ const child = spawn(binary(), [...options.protection === "root-only" ? ["--root-only"] : [], String(options.cols), String(options.rows), String(options.killGraceMs ?? 1e3), options.cwd, file, ...args], { env: options.env, stdio: ["pipe", "pipe", "pipe", "pipe", "pipe"] });
36
+ const control = child.stdio[4];
37
+ const events = child.stdio[3];
38
+ const data = /* @__PURE__ */ new Set(), exits = /* @__PURE__ */ new Set();
39
+ const decoder = new StringDecoder("utf8");
40
+ let buffered = "", protocol = "", exit, pid = 0;
41
+ let readyResolve, readyReject, finish;
42
+ const ready = new Promise((resolve, reject) => {
43
+ readyResolve = resolve;
44
+ readyReject = reject;
45
+ });
46
+ const finished = new Promise((resolve) => {
47
+ finish = resolve;
48
+ });
49
+ let result, completed = false, closing = false, adapterFailed = false;
50
+ let controlBlocked = false, pendingResize;
51
+ const resizeCommand = (command) => {
52
+ if (closing || result) return;
53
+ if (controlBlocked) {
54
+ pendingResize = command;
55
+ return;
56
+ }
57
+ controlBlocked = !control.write(command);
58
+ };
59
+ control.on("drain", () => {
60
+ controlBlocked = false;
61
+ const next = pendingResize;
62
+ pendingResize = void 0;
63
+ if (next) resizeCommand(next);
64
+ });
65
+ const closeOwner = () => {
66
+ if (closing || result) return;
67
+ closing = true;
68
+ pendingResize = void 0;
69
+ control.destroy();
70
+ child.stdin?.end();
71
+ };
72
+ const fail = (reason) => {
73
+ adapterFailed = true;
74
+ readyReject(new Error(reason));
75
+ closeOwner();
76
+ };
77
+ const timer = setTimeout(() => fail("Native terminal startup timed out"), 5e3);
78
+ const complete = (value) => {
79
+ if (!completed) {
80
+ completed = true;
81
+ result = adapterFailed ? { ...value, uncertain: Math.max(1, value.uncertain) } : value;
82
+ finish(result);
83
+ }
84
+ };
85
+ child.on("error", (error) => {
86
+ fail(error.message);
87
+ complete({ observed: 0, live: 0, uncertain: 1 });
88
+ });
89
+ child.on("close", () => {
90
+ clearTimeout(timer);
91
+ if (!pid) readyReject(new Error("Native terminal refused startup"));
92
+ exit ??= { exitCode: null };
93
+ for (const listener of exits) listener(exit);
94
+ complete(result ?? { observed: 0, live: 0, uncertain: 1 });
95
+ });
96
+ child.stderr?.resume();
97
+ child.stdin?.on("error", () => {
98
+ });
99
+ control.on("error", () => {
100
+ });
101
+ child.stdout?.on("data", (chunk) => {
102
+ const text = decoder.write(chunk);
103
+ if (data.size) for (const listener of data) listener(text);
104
+ else if (Buffer.byteLength(buffered) + Buffer.byteLength(text) <= 1024 * 1024) buffered += text;
105
+ else fail("Native terminal output limit exceeded");
106
+ });
107
+ events.on("data", (chunk) => {
108
+ protocol += chunk.toString("utf8");
109
+ if (protocol.length > 8192) {
110
+ fail("Invalid native protocol");
111
+ return;
112
+ }
113
+ let newline;
114
+ while ((newline = protocol.indexOf("\n")) >= 0) {
115
+ const line = protocol.slice(0, newline);
116
+ protocol = protocol.slice(newline + 1);
117
+ try {
118
+ const value = JSON.parse(line);
119
+ if (value.ready && value.protocol === 1 && Number.isSafeInteger(value.ready) && value.ready > 1) {
120
+ pid = value.ready;
121
+ clearTimeout(timer);
122
+ readyResolve();
123
+ } else if ("exitCode" in value) {
124
+ exit = { exitCode: value.exitCode, signal: value.signal };
125
+ } else if (value.cleanup === true && ["observed", "live", "uncertain"].every((key) => Number.isSafeInteger(value[key]) && value[key] >= 0)) result = value;
126
+ else if (value.refused === "terminal_protection_ack_required" || value.refused === "terminal_unsupported") {
127
+ readyReject(Object.assign(new Error("Native terminal capability changed before startup"), { terminalReason: value.refused }));
128
+ } else if (value.error) fail(String(value.error));
129
+ else fail("Invalid native event");
130
+ } catch {
131
+ fail("Invalid native JSON");
132
+ }
133
+ }
134
+ });
135
+ const abort = () => fail("Native terminal startup cancelled");
136
+ options.signal?.addEventListener("abort", abort, { once: true });
137
+ if (options.signal?.aborted) abort();
138
+ try {
139
+ await ready;
140
+ } catch (error) {
141
+ const cleanupResult = await finished;
142
+ throw Object.assign(error instanceof Error ? error : new Error(String(error)), { cleanupResult });
143
+ } finally {
144
+ options.signal?.removeEventListener("abort", abort);
145
+ }
146
+ return {
147
+ pid,
148
+ write(value) {
149
+ if (closing || result) return;
150
+ if ((child.stdin?.writableLength ?? 0) + Buffer.byteLength(value) > 1024 * 1024) {
151
+ fail("Native input limit exceeded");
152
+ return;
153
+ }
154
+ child.stdin?.write(value);
155
+ },
156
+ resize(cols, rows) {
157
+ if (Number.isInteger(cols) && Number.isInteger(rows) && cols > 0 && cols <= 1e3 && rows > 0 && rows <= 1e3) resizeCommand(`R ${cols} ${rows}
158
+ `);
159
+ },
160
+ kill() {
161
+ closeOwner();
162
+ },
163
+ cleanup() {
164
+ closeOwner();
165
+ return finished;
166
+ },
167
+ onData(listener) {
168
+ data.add(listener);
169
+ if (buffered) {
170
+ const value = buffered;
171
+ buffered = "";
172
+ queueMicrotask(() => {
173
+ if (data.has(listener)) listener(value);
174
+ });
175
+ }
176
+ return { dispose() {
177
+ data.delete(listener);
178
+ } };
179
+ },
180
+ onExit(listener) {
181
+ exits.add(listener);
182
+ if (exit && completed) {
183
+ const value = exit;
184
+ queueMicrotask(() => {
185
+ if (exits.has(listener)) listener(value);
186
+ });
187
+ }
188
+ return { dispose() {
189
+ exits.delete(listener);
190
+ } };
191
+ }
192
+ };
193
+ }
194
+ export {
195
+ nativeCapabilityOf,
196
+ nativePtySpawn,
197
+ nativeTerminalCapability
198
+ };
@@ -12,9 +12,15 @@ export type OperationsOptions = {
12
12
  templates?: Record<string, string>;
13
13
  /** Project roots the daemon knows from its session records, for a team save's sync. */
14
14
  knownProjects?: () => Iterable<string>;
15
+ /** A gate changed through task.gate.resolve: the runtime syncs the project's gate cards and mail. */
16
+ onGateChange?: (projectRoot: string) => Promise<void> | void;
15
17
  };
16
- type Handler = (params: any) => Promise<unknown>;
17
- export declare function createOperations({ home, templates, knownProjects }?: OperationsOptions): {
18
+ /** `caller.agent`: the connection said in daemon.hello that an ALP agent started it (t-ca1f). */
19
+ export type Caller = {
20
+ agent?: boolean;
21
+ };
22
+ type Handler = (params: any, caller?: Caller) => Promise<unknown>;
23
+ export declare function createOperations({ home, templates, knownProjects, onGateChange }?: OperationsOptions): {
18
24
  handlers: {
19
25
  [x: string]: Handler;
20
26
  };
@@ -3,11 +3,11 @@ import { createHash, createHmac, randomBytes } from "node:crypto";
3
3
  import { lstat, stat } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { CAPABILITY, ERROR, RPC_ERROR } from "@anhlp/alp-protocol";
6
- import { closeTask, createTask, epicReport, loadTasks, reopenTask, resolveGate } from "@anhlp/alp-core/tasks";
6
+ import { closeTask, createTask, epicReport, loadTasks, rejectGate, reopenTask, resolveGate } from "@anhlp/alp-core/tasks";
7
7
  import { taskRows } from "@anhlp/alp-core/task-rows";
8
8
  import { deleteEntry, duplicateEntry, getEntry, listEntries, renameEntry, saveEntry, setGivenSkills } from "@anhlp/alp-core/library-edit";
9
9
  import { listTeams } from "@anhlp/alp-core/teams";
10
- import { MODELS } from "@anhlp/alp-core/models";
10
+ import { catalogEntries } from "@anhlp/alp-runtime/index";
11
11
  import { listProviders } from "@anhlp/alp-core/providers";
12
12
  import { languageSetting, setLanguage, LANGUAGE_CHARS } from "@anhlp/alp-core/user-settings";
13
13
  import { syncProjectSettings } from "@anhlp/alp-core/init";
@@ -39,6 +39,8 @@ function fromCore(error, context = {}) {
39
39
  case "TASK_TAKEN":
40
40
  case "TASK_UNVERIFIED":
41
41
  return failure(ERROR.conflict, "task_state", message);
42
+ case "GATE_USER_ONLY":
43
+ return failure(ERROR.forbidden, "user_only", message);
42
44
  case "TASKS_LOCKED":
43
45
  return failure(ERROR.unavailable, "busy", message);
44
46
  case "IN_USE":
@@ -102,7 +104,7 @@ function unredact(kind, content, previous) {
102
104
  if (found !== void 0) throw failure(RPC_ERROR.invalidParams, "secret_marker", `${found || "content"} holds a secret marker where no secret is kept`);
103
105
  return next;
104
106
  }
105
- function createOperations({ home, templates, knownProjects = () => [] } = {}) {
107
+ function createOperations({ home, templates, knownProjects = () => [], onGateChange } = {}) {
106
108
  const revisionKey = randomBytes(32);
107
109
  const toWire = (revision) => revision == null ? null : `r${createHmac("sha256", revisionKey).update(revision).digest("base64url").slice(0, 22)}`;
108
110
  let writes = Promise.resolve();
@@ -133,9 +135,9 @@ function createOperations({ home, templates, knownProjects = () => [] } = {}) {
133
135
  throw error;
134
136
  }
135
137
  }
136
- const guard = (handler, context) => async (params) => {
138
+ const guard = (handler, context) => async (params, caller) => {
137
139
  try {
138
- return await handler(params);
140
+ return await handler(params, caller);
139
141
  } catch (error) {
140
142
  throw fromCore(error, context);
141
143
  }
@@ -167,21 +169,29 @@ function createOperations({ home, templates, knownProjects = () => [] } = {}) {
167
169
  });
168
170
  return result;
169
171
  }),
170
- "task.update": guard(async ({ projectRoot, id, action, note, ifRev }) => {
172
+ "task.update": guard(async ({ projectRoot, id, action, note, ifRev }, caller) => {
171
173
  const root = await project(projectRoot);
172
174
  const options = ifRev !== void 0 ? { ifRev } : void 0;
173
175
  if (action === "reopen") {
174
176
  const task2 = await reopenTask(root, id, { ...note ? { note } : {} }, "user", options);
175
177
  return { id: task2.id, status: task2.status, rev: task2.rev };
176
178
  }
177
- const task = await closeTask(root, id, { reason: "done", ...note ? { summary: note } : {} }, "user", options);
179
+ const task = await closeTask(root, id, { reason: "done", ...note ? { summary: note } : {}, agent: caller?.agent === true, channel: "web" }, "user", options);
178
180
  const { tasks } = await loadTasks(root);
179
181
  const landed = tasks.some((entry) => entry.parent === task.id) ? epicReport(task.id, tasks).text.split("\n")[0] : void 0;
180
182
  return { id: task.id, status: task.status, rev: task.rev, ...landed ? { landed } : {} };
181
183
  }),
182
- "task.gate.resolve": guard(async ({ projectRoot, id, gate, note, ifRev }) => {
184
+ // Approves a gate, or with reject records the user's rejection and leaves it open. Either way
185
+ // the runtime is told, so main gets the decision by mail once and the gate's card settles.
186
+ "task.gate.resolve": guard(async ({ projectRoot, id, gate, note, ifRev, choice, reject, channel = "web" }, caller) => {
183
187
  const root = await project(projectRoot);
184
- const task = await resolveGate(root, id, gate, { by: "user", ...note ? { note } : {}, ...ifRev !== void 0 ? { ifRev } : {} });
188
+ if (caller?.agent) {
189
+ const { tasks } = await loadTasks(root);
190
+ if (tasks.find((task2) => task2.id === id)?.gates.find((entry) => entry.id === gate)?.kind === "human") throw failure(ERROR.forbidden, "user_only", "Only the user decides a human gate; this connection was opened by an ALP agent");
191
+ }
192
+ const guarded = ifRev !== void 0 ? { ifRev } : {};
193
+ const task = reject === true ? await rejectGate(root, id, gate, { by: "user", channel, ...note ? { reason: note } : {}, ...guarded }) : await resolveGate(root, id, gate, { by: "user", channel, ...note ? { note } : {}, ...choice !== void 0 ? { choice } : {}, ...guarded });
194
+ await onGateChange?.(root);
185
195
  return { id: task.id, status: task.status, rev: task.rev };
186
196
  })
187
197
  };
@@ -250,7 +260,7 @@ function createOperations({ home, templates, knownProjects = () => [] } = {}) {
250
260
  })),
251
261
  "library.skills.set": guard(({ agent, skills }) => serial(() => setGivenSkills(agent, skills, { library: home })), { notFound: "invalid_entry" }),
252
262
  "library.models": guard(async () => {
253
- const models = MODELS.map((model) => ({ id: `${model.runtime}:${model.id}`, label: `${model.runtime} \xB7 ${model.label}`, efforts: model.efforts, ...model.effort ? { effort: model.effort } : {} }));
263
+ const models = catalogEntries.map((model) => ({ id: `${model.runtime}:${model.id}`, label: `${model.runtime} \xB7 ${model.label}`, efforts: model.efforts, ...model.effort ? { effort: model.effort } : {} }));
254
264
  for (const provider of await listProviders(home)) {
255
265
  if (provider.enabled === false || provider.kind === "antigravity") continue;
256
266
  models.push({ id: `acp:${provider.id}`, label: `${provider.label} \xB7 Provider default`, efforts: [] });
@@ -0,0 +1,89 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ export type ProjectRecord = {
3
+ id: string;
4
+ root: string;
5
+ canonical?: string;
6
+ customName?: string | null;
7
+ addedAt: string;
8
+ removedAt?: string | null;
9
+ };
10
+ export type WorkspaceRecord = {
11
+ id: string;
12
+ projectId: string;
13
+ directory: string;
14
+ canonical?: string;
15
+ title?: string | null;
16
+ pinnedAt?: string | null;
17
+ labels: string[];
18
+ createdAt: string;
19
+ archivedAt?: string | null;
20
+ idempotencyKey?: string;
21
+ worktree?: ManagedWorktree;
22
+ };
23
+ export type ManagedWorktree = {
24
+ kind: 'user';
25
+ sourceWorkspaceId: string;
26
+ source: string;
27
+ commonDir: string;
28
+ gitDir: string;
29
+ mappingId: string;
30
+ principalId: string;
31
+ grantEpoch: string;
32
+ requestId?: string;
33
+ ifRevision?: number;
34
+ branch: string;
35
+ head: string;
36
+ removedAt?: string;
37
+ };
38
+ export type Registry = {
39
+ version: 1;
40
+ revision: number;
41
+ projects: ProjectRecord[];
42
+ workspaces: WorkspaceRecord[];
43
+ sessions: Record<string, string>;
44
+ labels: {
45
+ generation: string;
46
+ seq: number;
47
+ catalog: {
48
+ name: string;
49
+ color: string;
50
+ }[];
51
+ };
52
+ worktreeJournal?: Record<string, {
53
+ fingerprint: string;
54
+ intent: any;
55
+ }>;
56
+ receipts: Record<string, {
57
+ fingerprint: string;
58
+ result: unknown;
59
+ }>;
60
+ };
61
+ export declare class RegistryError extends Error {
62
+ readonly code: number;
63
+ readonly data: {
64
+ reason: string;
65
+ };
66
+ constructor(code: number, message: string, data: {
67
+ reason: string;
68
+ });
69
+ }
70
+ /** Sole mutable owner. Failed writes never publish the draft or consume a requestId. */
71
+ export declare function createRegistry(home: string, options?: {
72
+ write?: typeof writeFile;
73
+ }): {
74
+ /** Native intent and receipt share the sole registry writer and atomic persistence boundary. */
75
+ nativeMutation: (method: string, args: any, context: {
76
+ actor: string;
77
+ requestId: string;
78
+ ifRevision: number;
79
+ }, prepare: (r: Registry) => Promise<any>, apply: (intent: any, draft: Registry) => Promise<any>) => Promise<any>;
80
+ snapshot: () => Promise<Registry>;
81
+ mutate: (method: string, args: any, context: {
82
+ actor?: string;
83
+ allowedRoots?: string[];
84
+ ifRevision?: number;
85
+ requestId: string;
86
+ }) => Promise<any>;
87
+ resolve(workspaceId: string, cwd?: string, includeArchived?: boolean): Promise<string>;
88
+ };
89
+ export type RegistryService = ReturnType<typeof createRegistry>;