@anhlp/alp-daemon 0.0.0-beta.1
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.
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +11 -0
- package/dist/THIRD-PARTY-NOTICES.txt +431 -0
- package/dist/alp-templates.d.ts +5 -0
- package/dist/alpd.js +41053 -0
- package/dist/build-manifest.json +108 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/lock.d.ts +21 -0
- package/dist/lock.js +42 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +238 -0
- package/dist/operations.d.ts +23 -0
- package/dist/operations.js +272 -0
- package/dist/rpc-error.d.ts +6 -0
- package/dist/rpc-error.js +11 -0
- package/dist/server.d.ts +48 -0
- package/dist/server.js +1020 -0
- package/dist/store.d.ts +108 -0
- package/dist/store.js +279 -0
- package/package.json +94 -0
- package/src/alp-templates.d.ts +5 -0
- package/src/index.ts +5 -0
- package/src/lock.ts +53 -0
- package/src/main.ts +250 -0
- package/src/operations.ts +298 -0
- package/src/rpc-error.ts +4 -0
- package/src/server.ts +1159 -0
- package/src/store.ts +336 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// packages/daemon/src/operations.ts
|
|
2
|
+
import { createHash, createHmac, randomBytes } from "node:crypto";
|
|
3
|
+
import { lstat, stat } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { CAPABILITY, ERROR, RPC_ERROR } from "@anhlp/alp-protocol";
|
|
6
|
+
import { closeTask, createTask, epicReport, loadTasks, reopenTask, resolveGate } from "@anhlp/alp-core/tasks";
|
|
7
|
+
import { taskRows } from "@anhlp/alp-core/task-rows";
|
|
8
|
+
import { deleteEntry, duplicateEntry, getEntry, listEntries, renameEntry, saveEntry, setGivenSkills } from "@anhlp/alp-core/library-edit";
|
|
9
|
+
import { listTeams } from "@anhlp/alp-core/teams";
|
|
10
|
+
import { MODELS } from "@anhlp/alp-core/models";
|
|
11
|
+
import { listProviders } from "@anhlp/alp-core/providers";
|
|
12
|
+
import { languageSetting, setLanguage, LANGUAGE_CHARS } from "@anhlp/alp-core/user-settings";
|
|
13
|
+
import { syncProjectSettings } from "@anhlp/alp-core/init";
|
|
14
|
+
import { RpcError } from "./rpc-error.js";
|
|
15
|
+
var REQUEST_TTL_MS = 10 * 60 * 1e3;
|
|
16
|
+
var MAX_REQUESTS = 1e4;
|
|
17
|
+
var MARKER = "$secret";
|
|
18
|
+
var KEEP = "keep";
|
|
19
|
+
var SECRET_MAPS = {
|
|
20
|
+
mcp: [["server", "env"], ["server", "headers"]],
|
|
21
|
+
providers: [["provider", "env"]]
|
|
22
|
+
};
|
|
23
|
+
var failure = (code, reason, message, extra = {}) => new RpcError(code, message, { reason, ...extra });
|
|
24
|
+
function fromCore(error, context = {}) {
|
|
25
|
+
if (error instanceof RpcError || typeof error?.code !== "string" || error?.name !== "AlpError") return error;
|
|
26
|
+
const message = error.message;
|
|
27
|
+
switch (error.code) {
|
|
28
|
+
case "UNSAFE_PATH":
|
|
29
|
+
return failure(ERROR.forbidden, "unsafe_path", message);
|
|
30
|
+
case "TASK_NOT_FOUND":
|
|
31
|
+
return failure(ERROR.notFound, "unknown_task", message);
|
|
32
|
+
case "TASK_CHANGED":
|
|
33
|
+
case "REVISION_CONFLICT":
|
|
34
|
+
return failure(ERROR.conflict, "revision_conflict", message);
|
|
35
|
+
case "INVALID_TASK":
|
|
36
|
+
case "TASK_CYCLE":
|
|
37
|
+
case "TASK_TAKEN":
|
|
38
|
+
case "TASK_UNVERIFIED":
|
|
39
|
+
return failure(ERROR.conflict, "task_state", message);
|
|
40
|
+
case "TASKS_LOCKED":
|
|
41
|
+
return failure(ERROR.unavailable, "busy", message);
|
|
42
|
+
case "IN_USE":
|
|
43
|
+
return failure(ERROR.conflict, "in_use", message);
|
|
44
|
+
case "INVALID_SCOPE":
|
|
45
|
+
return failure(RPC_ERROR.invalidParams, "invalid_scope", message);
|
|
46
|
+
case "INVALID_LIBRARY":
|
|
47
|
+
case "INVALID_SETTINGS":
|
|
48
|
+
return failure(ERROR.failed, "unreadable", message);
|
|
49
|
+
}
|
|
50
|
+
if (error.code === "NOT_FOUND" || error.code.endsWith("_NOT_FOUND")) {
|
|
51
|
+
return context.notFound === "invalid_entry" ? failure(RPC_ERROR.invalidParams, "invalid_entry", message) : failure(ERROR.notFound, "not_found", message);
|
|
52
|
+
}
|
|
53
|
+
if (error.code.startsWith("INVALID_")) return failure(RPC_ERROR.invalidParams, "invalid_entry", message);
|
|
54
|
+
return error;
|
|
55
|
+
}
|
|
56
|
+
var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
57
|
+
var pointer = (parts) => parts.map((part) => `/${part.replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
|
|
58
|
+
var isMarker = (value) => object(value) && Object.keys(value).length === 1 && value[MARKER] === KEEP;
|
|
59
|
+
var at = (content, parts) => parts.reduce((value, part) => object(value) ? value[part] : void 0, content);
|
|
60
|
+
function redact(kind, content) {
|
|
61
|
+
const copy = structuredClone(content);
|
|
62
|
+
const secrets = [];
|
|
63
|
+
for (const parts of SECRET_MAPS[kind] ?? []) {
|
|
64
|
+
const map = at(copy, parts);
|
|
65
|
+
if (!object(map)) continue;
|
|
66
|
+
for (const key of Object.keys(map)) {
|
|
67
|
+
if (typeof map[key] !== "string") continue;
|
|
68
|
+
map[key] = { [MARKER]: KEEP };
|
|
69
|
+
secrets.push(pointer([...parts, key]));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { content: copy, secrets };
|
|
73
|
+
}
|
|
74
|
+
function unredact(kind, content, previous) {
|
|
75
|
+
const next = structuredClone(content);
|
|
76
|
+
for (const parts of SECRET_MAPS[kind] ?? []) {
|
|
77
|
+
const map = at(next, parts);
|
|
78
|
+
if (!object(map)) continue;
|
|
79
|
+
const stored = at(previous, parts);
|
|
80
|
+
for (const key of Object.keys(map)) {
|
|
81
|
+
if (!isMarker(map[key])) continue;
|
|
82
|
+
const value = object(stored) ? stored[key] : void 0;
|
|
83
|
+
if (typeof value !== "string") throw failure(RPC_ERROR.invalidParams, "secret_marker", `There is no stored value of ${pointer([...parts, key])} to keep; send the value instead`);
|
|
84
|
+
map[key] = value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const stray = (value, parts) => {
|
|
88
|
+
if (isMarker(value) || object(value) && Object.hasOwn(value, MARKER)) return pointer(parts);
|
|
89
|
+
if (Array.isArray(value)) for (const [index, item] of value.entries()) {
|
|
90
|
+
const found2 = stray(item, [...parts, String(index)]);
|
|
91
|
+
if (found2) return found2;
|
|
92
|
+
}
|
|
93
|
+
if (object(value)) for (const [key, item] of Object.entries(value)) {
|
|
94
|
+
const found2 = stray(item, [...parts, key]);
|
|
95
|
+
if (found2) return found2;
|
|
96
|
+
}
|
|
97
|
+
return void 0;
|
|
98
|
+
};
|
|
99
|
+
const found = stray(next, []);
|
|
100
|
+
if (found !== void 0) throw failure(RPC_ERROR.invalidParams, "secret_marker", `${found || "content"} holds a secret marker where no secret is kept`);
|
|
101
|
+
return next;
|
|
102
|
+
}
|
|
103
|
+
function createOperations({ home, templates, knownProjects = () => [] } = {}) {
|
|
104
|
+
const revisionKey = randomBytes(32);
|
|
105
|
+
const toWire = (revision) => revision == null ? null : `r${createHmac("sha256", revisionKey).update(revision).digest("base64url").slice(0, 22)}`;
|
|
106
|
+
let writes = Promise.resolve();
|
|
107
|
+
const serial = (work) => {
|
|
108
|
+
const run = writes.catch(() => {
|
|
109
|
+
}).then(work);
|
|
110
|
+
writes = run;
|
|
111
|
+
return run;
|
|
112
|
+
};
|
|
113
|
+
const requests = /* @__PURE__ */ new Map();
|
|
114
|
+
async function project(value) {
|
|
115
|
+
if (!path.isAbsolute(value) || path.resolve(value) !== value) throw failure(RPC_ERROR.invalidParams, "invalid_path", "projectRoot must be an absolute, normalized path");
|
|
116
|
+
if (!(await stat(value).catch(() => void 0))?.isDirectory()) throw failure(ERROR.notFound, "not_alp_project", `${value} is not a directory`);
|
|
117
|
+
const alp = await lstat(path.join(value, ".alp")).catch(() => void 0);
|
|
118
|
+
if (alp?.isSymbolicLink()) throw failure(ERROR.forbidden, "unsafe_path", `${path.join(value, ".alp")} is a symlink`);
|
|
119
|
+
if (!alp?.isDirectory()) throw failure(ERROR.notFound, "not_alp_project", `${value} is not an ALP project; run alp init there`);
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
async function where(projectRoot, scope) {
|
|
123
|
+
if (scope === "project" && projectRoot === void 0) throw failure(RPC_ERROR.invalidParams, "invalid_scope", "scope project needs projectRoot");
|
|
124
|
+
return { root: projectRoot === void 0 ? void 0 : await project(projectRoot), library: home, templates };
|
|
125
|
+
}
|
|
126
|
+
async function layer(kind, name, options, scope) {
|
|
127
|
+
try {
|
|
128
|
+
return await getEntry(kind, name, { ...options, ...scope ? { scope } : {} });
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error?.code === "NOT_FOUND") return void 0;
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const guard = (handler, context) => async (params) => {
|
|
135
|
+
try {
|
|
136
|
+
return await handler(params);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
throw fromCore(error, context);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const taskHandlers = {
|
|
142
|
+
"task.list": guard(async ({ projectRoot }) => {
|
|
143
|
+
const root = await project(projectRoot);
|
|
144
|
+
const { tasks, unreadable } = await taskRows(root);
|
|
145
|
+
return { projectRoot: root, tasks, unreadable, revision: createHash("sha256").update(JSON.stringify([tasks, unreadable])).digest("hex").slice(0, 16) };
|
|
146
|
+
}),
|
|
147
|
+
"task.create": guard(async ({ projectRoot, title, priority, requestId }) => {
|
|
148
|
+
const root = await project(projectRoot);
|
|
149
|
+
const create = () => createTask(root, { title: title.trim(), ...priority !== void 0 ? { priority } : {} }, "user").then((task) => ({ id: task.id }));
|
|
150
|
+
if (requestId === void 0) return create();
|
|
151
|
+
const now = Date.now();
|
|
152
|
+
for (const [key2, entry] of requests) if (now - entry.at > REQUEST_TTL_MS) requests.delete(key2);
|
|
153
|
+
const key = JSON.stringify([root, requestId]);
|
|
154
|
+
const fingerprint = JSON.stringify([title.trim(), priority ?? null]);
|
|
155
|
+
const existing = requests.get(key);
|
|
156
|
+
if (existing) {
|
|
157
|
+
if (existing.fingerprint !== fingerprint) throw failure(ERROR.conflict, "key_conflict", `Request ${requestId} was already used for another task`);
|
|
158
|
+
return { ...await existing.result, duplicate: true };
|
|
159
|
+
}
|
|
160
|
+
const result = create();
|
|
161
|
+
if (requests.size >= MAX_REQUESTS) requests.delete(requests.keys().next().value);
|
|
162
|
+
requests.set(key, { fingerprint, at: now, result });
|
|
163
|
+
result.catch(() => {
|
|
164
|
+
if (requests.get(key)?.result === result) requests.delete(key);
|
|
165
|
+
});
|
|
166
|
+
return result;
|
|
167
|
+
}),
|
|
168
|
+
"task.update": guard(async ({ projectRoot, id, action, note, ifRev }) => {
|
|
169
|
+
const root = await project(projectRoot);
|
|
170
|
+
const options = ifRev !== void 0 ? { ifRev } : void 0;
|
|
171
|
+
if (action === "reopen") {
|
|
172
|
+
const task2 = await reopenTask(root, id, { ...note ? { note } : {} }, "user", options);
|
|
173
|
+
return { id: task2.id, status: task2.status, rev: task2.rev };
|
|
174
|
+
}
|
|
175
|
+
const task = await closeTask(root, id, { reason: "done", ...note ? { summary: note } : {} }, "user", options);
|
|
176
|
+
const { tasks } = await loadTasks(root);
|
|
177
|
+
const landed = tasks.some((entry) => entry.parent === task.id) ? epicReport(task.id, tasks).text.split("\n")[0] : void 0;
|
|
178
|
+
return { id: task.id, status: task.status, rev: task.rev, ...landed ? { landed } : {} };
|
|
179
|
+
}),
|
|
180
|
+
"task.gate.resolve": guard(async ({ projectRoot, id, gate, note, ifRev }) => {
|
|
181
|
+
const root = await project(projectRoot);
|
|
182
|
+
const task = await resolveGate(root, id, gate, { by: "user", ...note ? { note } : {}, ...ifRev !== void 0 ? { ifRev } : {} });
|
|
183
|
+
return { id: task.id, status: task.status, rev: task.rev };
|
|
184
|
+
})
|
|
185
|
+
};
|
|
186
|
+
const libraryHandlers = {
|
|
187
|
+
"team.list": guard(async ({ projectRoot }) => {
|
|
188
|
+
const { root } = await where(projectRoot);
|
|
189
|
+
const teams = await listTeams(root, { library: home, templates });
|
|
190
|
+
return { projectRoot: root ?? null, teams: teams.map(({ path: _path, ...team }) => team) };
|
|
191
|
+
}),
|
|
192
|
+
"library.list": guard(async ({ kind, projectRoot }) => {
|
|
193
|
+
const options = await where(projectRoot);
|
|
194
|
+
const entries = await listEntries(kind, options);
|
|
195
|
+
return { projectRoot: options.root ?? null, entries: entries.map(({ path: _path, ...entry }) => entry) };
|
|
196
|
+
}),
|
|
197
|
+
"library.get": guard(async ({ kind, name, projectRoot, scope }) => {
|
|
198
|
+
const options = await where(projectRoot, scope);
|
|
199
|
+
const entry = await getEntry(kind, name, { ...options, ...scope ? { scope } : {} });
|
|
200
|
+
const { content, secrets } = redact(kind, entry.content);
|
|
201
|
+
return { ...entry, content, revision: toWire(entry.revision), ...secrets.length ? { secrets } : {} };
|
|
202
|
+
}),
|
|
203
|
+
"library.save": guard(({ kind, name, scope, projectRoot, content, revision, sync = "none" }) => serial(async () => {
|
|
204
|
+
const options = await where(projectRoot, scope);
|
|
205
|
+
const current = await layer(kind, name, options, scope);
|
|
206
|
+
if (revision !== void 0 && revision !== toWire(current?.revision ?? null)) {
|
|
207
|
+
throw failure(ERROR.conflict, "revision_conflict", current === void 0 ? `${kind} '${name}' is not in the ${scope}` : revision === null ? `${kind} '${name}' already exists in the ${scope}` : `${kind} '${name}' changed in the ${scope} since you opened it; reload it and apply your change again`);
|
|
208
|
+
}
|
|
209
|
+
const previous = current?.content ?? (await layer(kind, name, options))?.content;
|
|
210
|
+
const next = unredact(kind, content, previous);
|
|
211
|
+
const saved = await saveEntry(kind, name, next, { ...options, scope, ...revision !== void 0 ? { revision: current?.revision ?? null } : {} });
|
|
212
|
+
if (kind !== "teams" || sync !== "known-projects") return { revision: toWire(saved.revision) };
|
|
213
|
+
const roots = new Set(options.root ? [options.root] : []);
|
|
214
|
+
if (scope === "library") {
|
|
215
|
+
for (const root of knownProjects()) if (typeof root === "string" && path.isAbsolute(root)) roots.add(path.resolve(root));
|
|
216
|
+
}
|
|
217
|
+
let syncedProjects = 0;
|
|
218
|
+
const syncErrors = [];
|
|
219
|
+
for (const root of roots) {
|
|
220
|
+
try {
|
|
221
|
+
if (await syncProjectSettings(root, { library: home, templates, teamIds: [name], replaceModels: true })) syncedProjects += 1;
|
|
222
|
+
} catch (error) {
|
|
223
|
+
syncErrors.push(`${root}: ${error instanceof Error ? error.message : String(error)}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { revision: toWire(saved.revision), syncedProjects, syncErrors };
|
|
227
|
+
}), { notFound: "invalid_entry" }),
|
|
228
|
+
"library.delete": guard(({ kind, name, scope, projectRoot, revision }) => serial(async () => {
|
|
229
|
+
const options = await where(projectRoot, scope);
|
|
230
|
+
const current = await layer(kind, name, options, scope);
|
|
231
|
+
if (!current) throw failure(ERROR.notFound, "not_found", `No ${kind} entry '${name}' in the ${scope}`);
|
|
232
|
+
if (revision !== void 0 && revision !== toWire(current.revision)) throw failure(ERROR.conflict, "revision_conflict", `${kind} '${name}' changed in the ${scope} since you opened it`);
|
|
233
|
+
return deleteEntry(kind, name, { ...options, scope, ...revision !== void 0 ? { revision: current.revision } : {} });
|
|
234
|
+
})),
|
|
235
|
+
"library.duplicate": guard(({ kind, from, to, scope, projectRoot }) => serial(async () => {
|
|
236
|
+
const options = await where(projectRoot, scope);
|
|
237
|
+
try {
|
|
238
|
+
await getEntry(kind, from, options);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
throw fromCore(error, { notFound: "not_found" });
|
|
241
|
+
}
|
|
242
|
+
return { revision: toWire((await duplicateEntry(kind, from, to, { ...options, scope })).revision) };
|
|
243
|
+
}), { notFound: "invalid_entry" }),
|
|
244
|
+
"library.rename": guard(({ kind, from, to, scope, projectRoot }) => serial(async () => {
|
|
245
|
+
const options = await where(projectRoot, scope);
|
|
246
|
+
return { revision: toWire((await renameEntry(kind, from, to, { ...options, scope })).revision) };
|
|
247
|
+
})),
|
|
248
|
+
"library.skills.set": guard(({ agent, skills }) => serial(() => setGivenSkills(agent, skills, { library: home })), { notFound: "invalid_entry" }),
|
|
249
|
+
"library.models": guard(async () => {
|
|
250
|
+
const models = MODELS.map((model) => ({ id: `${model.runtime}:${model.id}`, label: `${model.runtime} \xB7 ${model.label}`, efforts: model.efforts, ...model.effort ? { effort: model.effort } : {} }));
|
|
251
|
+
for (const provider of await listProviders(home)) {
|
|
252
|
+
if (provider.enabled === false || provider.kind === "antigravity") continue;
|
|
253
|
+
models.push({ id: `acp:${provider.id}`, label: `${provider.label} \xB7 Provider default`, efforts: [] });
|
|
254
|
+
for (const model of [...provider.models ?? [], ...provider.additionalModels ?? []]) models.push({ id: `acp:${provider.id}/${model.id}`, label: `${provider.label} \xB7 ${model.label ?? model.id}`, efforts: [] });
|
|
255
|
+
}
|
|
256
|
+
return { models: [...new Map(models.map((model) => [model.id, model])).values()] };
|
|
257
|
+
}),
|
|
258
|
+
"settings.language.get": guard(async () => languageSetting(home)),
|
|
259
|
+
"settings.language.set": guard(async ({ language }) => {
|
|
260
|
+
if (language !== null && language.trim().length > LANGUAGE_CHARS) throw failure(RPC_ERROR.invalidParams, "invalid_params", `A language is a name of at most ${LANGUAGE_CHARS} characters`);
|
|
261
|
+
return serial(() => setLanguage(home, language));
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
const library = home !== void 0;
|
|
265
|
+
return {
|
|
266
|
+
handlers: { ...taskHandlers, ...library ? libraryHandlers : {} },
|
|
267
|
+
capabilities: [CAPABILITY.task, ...library ? [CAPABILITY.team, CAPABILITY.library, CAPABILITY.settingsLanguage] : []]
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
createOperations
|
|
272
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** An error alpd answers with as is: its code, message and `data` (docs/protocol/alp-json-rpc-v1.md §5). */
|
|
2
|
+
export declare class RpcError extends Error {
|
|
3
|
+
code: number;
|
|
4
|
+
data?: unknown | undefined;
|
|
5
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
|
6
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { ERROR } from '@anhlp/alp-protocol';
|
|
2
|
+
import { type AlpRuntime } from '@anhlp/alp-runtime/index';
|
|
3
|
+
import type { Store } from './store.js';
|
|
4
|
+
import type { SessionSummary } from '@anhlp/alp-protocol/session';
|
|
5
|
+
import { type OperationsOptions } from './operations.js';
|
|
6
|
+
/** What clients need from a daemon connection; AlpClient implements it over the socket. */
|
|
7
|
+
import type { DaemonConnection } from '@anhlp/alp-protocol/connection';
|
|
8
|
+
export type { DaemonConnection } from '@anhlp/alp-protocol/connection';
|
|
9
|
+
export type DaemonServer = {
|
|
10
|
+
listen(): Promise<void>;
|
|
11
|
+
/** An in-process connection that delivers events synchronously, for embedding. */
|
|
12
|
+
local(): DaemonConnection;
|
|
13
|
+
/**
|
|
14
|
+
* A connection over another transport, such as the web app's WebSocket (ALPD §61):
|
|
15
|
+
* it says daemon.hello first, as a socket client does, and gets JSON-RPC messages back through `send`.
|
|
16
|
+
*/
|
|
17
|
+
accept(send: (message: unknown) => void): {
|
|
18
|
+
receive(message: unknown): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
};
|
|
21
|
+
/** Adds a method that lives outside the runtime, such as the web app's pairing link (ALPD §64). */
|
|
22
|
+
extend(method: string, handler: (params: any) => Promise<unknown> | unknown): void;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
/** A session as clients list it: its last snapshot plus lifecycle (ALPD §18). The protocol owns the
|
|
26
|
+
* shape so every viewer agrees; re-exported here to keep `@anhlp/alp-daemon/server`'s API. */
|
|
27
|
+
export type { SessionSummary };
|
|
28
|
+
export declare function createDaemonServer({ runtime, socketPath, version, onShutdown, store, runLogDir, previousExit, retentionSweepMs, home, templates }: {
|
|
29
|
+
runtime: AlpRuntime;
|
|
30
|
+
socketPath: string;
|
|
31
|
+
version: string;
|
|
32
|
+
onShutdown?: () => void;
|
|
33
|
+
/** Durable records and timelines; without it sessions live only in memory. */
|
|
34
|
+
store?: Store;
|
|
35
|
+
/** Where crash reconciliation reports assignments it ends, as the runtime does. */
|
|
36
|
+
runLogDir?: string;
|
|
37
|
+
/** How the previous alpd ended, for daemon.status. */
|
|
38
|
+
previousExit?: {
|
|
39
|
+
kind: 'clean' | 'crash';
|
|
40
|
+
at?: string;
|
|
41
|
+
};
|
|
42
|
+
/** How often retention runs while alpd runs (ALPD §68); tests shorten it. */
|
|
43
|
+
retentionSweepMs?: number;
|
|
44
|
+
/** The daemon user's ALP_HOME, for the library, team and settings methods; without it alpd does not serve them. */
|
|
45
|
+
home?: OperationsOptions['home'];
|
|
46
|
+
/** ALP's built-in agents and teams, for the library and team methods. */
|
|
47
|
+
templates?: OperationsOptions['templates'];
|
|
48
|
+
}): DaemonServer;
|