@anhlp/alp-daemon 0.0.0-stage → 0.0.1-beta.3
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 +10 -2
- package/dist/THIRD-PARTY-NOTICES.txt +431 -0
- package/dist/alp-templates.d.ts +5 -0
- package/dist/alpd.js +42558 -0
- package/dist/build-manifest.json +111 -0
- package/dist/files.d.ts +110 -0
- package/dist/files.js +350 -0
- package/dist/gitignore.d.ts +57 -0
- package/dist/gitignore.js +248 -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 +271 -0
- package/dist/operations.d.ts +23 -0
- package/dist/operations.js +275 -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 +1158 -0
- package/dist/store.d.ts +108 -0
- package/dist/store.js +279 -0
- package/package.json +100 -4
- package/src/alp-templates.d.ts +5 -0
- package/src/files.ts +438 -0
- package/src/gitignore.ts +267 -0
- package/src/index.ts +5 -0
- package/src/lock.ts +53 -0
- package/src/main.ts +286 -0
- package/src/operations.ts +300 -0
- package/src/rpc-error.ts +4 -0
- package/src/server.ts +1332 -0
- package/src/store.ts +336 -0
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Envelope, SessionSnapshot, SessionSpec } from '@anhlp/alp-runtime/index';
|
|
2
|
+
import type { SessionError, SessionStatus } from '@anhlp/alp-protocol/session';
|
|
3
|
+
/**
|
|
4
|
+
* alpd's durable state (plans/reference/ALPD.md §5, §66): one JSON record per session,
|
|
5
|
+
* written atomically, one append-only JSONL timeline per tree, and one receipt per
|
|
6
|
+
* delivered prompt. Writes survive a crash of the alpd process once their promise
|
|
7
|
+
* resolves; nothing is fsynced, so a power loss or a failing disk may lose recent writes.
|
|
8
|
+
*/
|
|
9
|
+
export type { SessionError, SessionStatus } from '@anhlp/alp-protocol/session';
|
|
10
|
+
export type SessionRecord = {
|
|
11
|
+
version: 1;
|
|
12
|
+
id: string;
|
|
13
|
+
rootId: string;
|
|
14
|
+
/** The client's request, kept for roots so they can be resumed. */
|
|
15
|
+
spec?: SessionSpec;
|
|
16
|
+
delegation?: boolean;
|
|
17
|
+
session?: SessionSnapshot;
|
|
18
|
+
status: SessionStatus;
|
|
19
|
+
lastError?: SessionError;
|
|
20
|
+
title?: string;
|
|
21
|
+
/** Set aside by the user: closed, and listed only when asked (ALPD §61). */
|
|
22
|
+
archived?: boolean;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Delivery of one clientMessageId; `pending` means alpd may have stopped while sending it.
|
|
28
|
+
* A completed receipt says what the runtime answered: `unknown` when the provider may or
|
|
29
|
+
* may not have the message (its process died or timed out mid-request).
|
|
30
|
+
*/
|
|
31
|
+
export type Receipt = {
|
|
32
|
+
version: 1;
|
|
33
|
+
sessionId: string;
|
|
34
|
+
clientMessageId: string;
|
|
35
|
+
fingerprint: string;
|
|
36
|
+
state: 'pending' | 'completed';
|
|
37
|
+
outcome?: 'accepted' | 'failed' | 'unknown';
|
|
38
|
+
error?: {
|
|
39
|
+
message: string;
|
|
40
|
+
code?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Completed at the next start from the tree's timeline, not by the delivery itself. */
|
|
43
|
+
reconciled?: boolean;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
};
|
|
46
|
+
/** A receipt file that exists but cannot be read as one: its delivery's outcome is unknown. */
|
|
47
|
+
export type UnreadableReceipt = {
|
|
48
|
+
version: 1;
|
|
49
|
+
state: 'unreadable';
|
|
50
|
+
};
|
|
51
|
+
/** Failed writes since alpd started; `ok` until the first one (ALPD §66). */
|
|
52
|
+
export type StoreHealth = {
|
|
53
|
+
ok: boolean;
|
|
54
|
+
failures: number;
|
|
55
|
+
lastError?: {
|
|
56
|
+
at: string;
|
|
57
|
+
operation: string;
|
|
58
|
+
message: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type Store = ReturnType<typeof createStore>;
|
|
62
|
+
export declare function createStore(root: string): {
|
|
63
|
+
put(record: SessionRecord): Promise<void>;
|
|
64
|
+
receipt(key: string): Promise<Receipt | UnreadableReceipt | undefined>;
|
|
65
|
+
putReceipt(key: string, receipt: Receipt): Promise<void>;
|
|
66
|
+
removeReceipt(key: string): Promise<void>;
|
|
67
|
+
/** Every readable receipt with its key and when its file was last written. */
|
|
68
|
+
receipts(): Promise<Array<{
|
|
69
|
+
key: string;
|
|
70
|
+
receipt: Receipt;
|
|
71
|
+
writtenAt: number;
|
|
72
|
+
}>>;
|
|
73
|
+
/** When the newest of these records' files was written (a restore writes them anew); 0 when none is there. */
|
|
74
|
+
writtenAt(ids: string[]): Promise<number>;
|
|
75
|
+
/**
|
|
76
|
+
* Deletes receipts not written for `maxAgeMs` and, with `temporaries` (only at start, when no
|
|
77
|
+
* write can be under way), temporary files a crash left behind.
|
|
78
|
+
*/
|
|
79
|
+
pruneReceipts(maxAgeMs: number, { temporaries }?: {
|
|
80
|
+
temporaries?: boolean | undefined;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
list(): Promise<SessionRecord[]>;
|
|
83
|
+
append(rootId: string, envelope: Envelope): Promise<void>;
|
|
84
|
+
timeline(rootId: string): Promise<Envelope[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Waits for the queued writes of these records and timelines, and names those that
|
|
87
|
+
* failed: a record whose last write failed, or a timeline that lost a line.
|
|
88
|
+
*/
|
|
89
|
+
drain({ records, timelines }: {
|
|
90
|
+
records?: string[] | undefined;
|
|
91
|
+
timelines?: string[] | undefined;
|
|
92
|
+
}): Promise<string[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the state directory can be read and written right now: a small file is written,
|
|
95
|
+
* read back and removed. `StoreHealth` only says what failed since alpd started.
|
|
96
|
+
*/
|
|
97
|
+
probe(): Promise<{
|
|
98
|
+
ok: boolean;
|
|
99
|
+
code?: string;
|
|
100
|
+
message?: string;
|
|
101
|
+
}>;
|
|
102
|
+
/** How many records, receipts and timelines are failed now: a later successful write clears a record, a lost timeline line never clears. */
|
|
103
|
+
failing(): number;
|
|
104
|
+
health(): StoreHealth;
|
|
105
|
+
/** Removes a whole tree: its records and its timeline. */
|
|
106
|
+
remove(rootId: string, ids: string[]): Promise<void>;
|
|
107
|
+
flush(): Promise<void>;
|
|
108
|
+
};
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// packages/daemon/src/store.ts
|
|
2
|
+
import { appendFile, mkdir, open, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { replaceFile } from "./lock.js";
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createLogger } from "@anhlp/alp-core/log";
|
|
7
|
+
var log = createLogger({ component: "store" });
|
|
8
|
+
var SAFE = /[^\w.:-]/g;
|
|
9
|
+
var fileName = (id) => id.replace(SAFE, "_");
|
|
10
|
+
var TAIL_CHUNK = 64 * 1024;
|
|
11
|
+
function createStore(root) {
|
|
12
|
+
const sessionsDir = path.join(root, "sessions");
|
|
13
|
+
const timelineDir = path.join(root, "timeline");
|
|
14
|
+
const receiptsDir = path.join(root, "receipts");
|
|
15
|
+
const writes = /* @__PURE__ */ new Map();
|
|
16
|
+
const appends = /* @__PURE__ */ new Map();
|
|
17
|
+
const failed = /* @__PURE__ */ new Map();
|
|
18
|
+
const repaired = /* @__PURE__ */ new Set();
|
|
19
|
+
const health = { ok: true, failures: 0 };
|
|
20
|
+
let ready;
|
|
21
|
+
const prepare = () => ready ??= Promise.all([
|
|
22
|
+
mkdir(sessionsDir, { recursive: true, mode: 448 }),
|
|
23
|
+
mkdir(timelineDir, { recursive: true, mode: 448 }),
|
|
24
|
+
mkdir(receiptsDir, { recursive: true, mode: 448 })
|
|
25
|
+
]).then(() => {
|
|
26
|
+
}, (error) => {
|
|
27
|
+
ready = void 0;
|
|
28
|
+
throw error;
|
|
29
|
+
});
|
|
30
|
+
async function writeAtomic(file, body) {
|
|
31
|
+
const temporary = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
32
|
+
try {
|
|
33
|
+
await writeFile(temporary, body, { mode: 384 });
|
|
34
|
+
await replaceFile(temporary, file);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
await rm(temporary, { force: true }).catch(() => {
|
|
37
|
+
});
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function queue(map, key, operation, work, sticky = false, ids = {}) {
|
|
42
|
+
const next = (map.get(key) ?? Promise.resolve()).then(prepare).then(work);
|
|
43
|
+
const failure = map === appends ? `timeline:${key}` : key;
|
|
44
|
+
const settled = next.then(
|
|
45
|
+
() => {
|
|
46
|
+
if (!sticky) failed.delete(failure);
|
|
47
|
+
},
|
|
48
|
+
(error) => {
|
|
49
|
+
failed.set(failure, error);
|
|
50
|
+
health.ok = false;
|
|
51
|
+
health.failures++;
|
|
52
|
+
health.lastError = { at: (/* @__PURE__ */ new Date()).toISOString(), operation, message: error?.message ?? String(error) };
|
|
53
|
+
log.error(`${operation} failed`, { code: "ALP_PERSISTENCE_WRITE_FAILED", operation, error, ...ids });
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
map.set(key, settled);
|
|
57
|
+
void settled.then(() => {
|
|
58
|
+
if (map.get(key) === settled) map.delete(key);
|
|
59
|
+
});
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
async function repairTail(file) {
|
|
63
|
+
const handle = await open(file, "r+").catch((error) => {
|
|
64
|
+
if (error?.code === "ENOENT") return void 0;
|
|
65
|
+
throw error;
|
|
66
|
+
});
|
|
67
|
+
if (!handle) return;
|
|
68
|
+
try {
|
|
69
|
+
const { size } = await handle.stat();
|
|
70
|
+
if (!size) return;
|
|
71
|
+
const last = Buffer.alloc(1);
|
|
72
|
+
await handle.read(last, 0, 1, size - 1);
|
|
73
|
+
if (last[0] === 10) return;
|
|
74
|
+
let start = 0;
|
|
75
|
+
for (let end = size; end > 0 && !start; end -= TAIL_CHUNK) {
|
|
76
|
+
const from = Math.max(0, end - TAIL_CHUNK);
|
|
77
|
+
const chunk = Buffer.alloc(end - from);
|
|
78
|
+
await handle.read(chunk, 0, chunk.length, from);
|
|
79
|
+
const newline = chunk.lastIndexOf(10);
|
|
80
|
+
if (newline >= 0) start = from + newline + 1;
|
|
81
|
+
}
|
|
82
|
+
const tail = Buffer.alloc(size - start);
|
|
83
|
+
await handle.read(tail, 0, tail.length, start);
|
|
84
|
+
let whole = false;
|
|
85
|
+
try {
|
|
86
|
+
JSON.parse(tail.toString("utf8"));
|
|
87
|
+
whole = true;
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
if (whole) await handle.write("\n", size);
|
|
91
|
+
else await handle.truncate(start);
|
|
92
|
+
log.warn(`${whole ? "completed" : "removed"} a timeline line cut short in ${path.basename(file)} (${tail.length} bytes)`, { code: "ALP_TIMELINE_REPAIRED", file: path.basename(file), bytes: tail.length });
|
|
93
|
+
} finally {
|
|
94
|
+
await handle.close();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function parseTimeline(text, name) {
|
|
98
|
+
const envelopes = [];
|
|
99
|
+
let cursor = 0;
|
|
100
|
+
let skipped = 0;
|
|
101
|
+
for (const line of text.split("\n")) {
|
|
102
|
+
if (!line) continue;
|
|
103
|
+
let envelope;
|
|
104
|
+
try {
|
|
105
|
+
envelope = JSON.parse(line);
|
|
106
|
+
} catch {
|
|
107
|
+
skipped++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
cursor = typeof envelope.cursor === "number" && envelope.cursor > cursor ? envelope.cursor : cursor + 1;
|
|
111
|
+
envelopes.push({ ...envelope, cursor });
|
|
112
|
+
}
|
|
113
|
+
if (skipped) log.warn(`skipped ${skipped} unreadable timeline lines in ${name}`, { code: "ALP_TIMELINE_UNREADABLE", file: name, skipped });
|
|
114
|
+
return envelopes;
|
|
115
|
+
}
|
|
116
|
+
const receiptFile = (key) => path.join(receiptsDir, `${fileName(key)}.json`);
|
|
117
|
+
return {
|
|
118
|
+
put(record) {
|
|
119
|
+
const file = path.join(sessionsDir, `${fileName(record.id)}.json`);
|
|
120
|
+
const body = JSON.stringify(record);
|
|
121
|
+
return queue(writes, record.id, `record ${record.id}`, () => writeAtomic(file, body), false, { sessionId: record.id, rootId: record.rootId });
|
|
122
|
+
},
|
|
123
|
+
async receipt(key) {
|
|
124
|
+
await writes.get(`receipt:${key}`);
|
|
125
|
+
let text;
|
|
126
|
+
try {
|
|
127
|
+
text = await readFile(receiptFile(key), "utf8");
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error?.code === "ENOENT") return void 0;
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const receipt = JSON.parse(text);
|
|
134
|
+
if (receipt?.version === 1 && typeof receipt.fingerprint === "string" && (receipt.state === "pending" || receipt.state === "completed")) return receipt;
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
return { version: 1, state: "unreadable" };
|
|
138
|
+
},
|
|
139
|
+
putReceipt(key, receipt) {
|
|
140
|
+
const body = JSON.stringify(receipt);
|
|
141
|
+
return queue(writes, `receipt:${key}`, `receipt ${receipt.clientMessageId}`, () => writeAtomic(receiptFile(key), body), false, { sessionId: receipt.sessionId, clientMessageId: receipt.clientMessageId });
|
|
142
|
+
},
|
|
143
|
+
removeReceipt(key) {
|
|
144
|
+
return queue(writes, `receipt:${key}`, `receipt removal ${key}`, () => rm(receiptFile(key), { force: true }));
|
|
145
|
+
},
|
|
146
|
+
/** Every readable receipt with its key and when its file was last written. */
|
|
147
|
+
async receipts() {
|
|
148
|
+
await prepare();
|
|
149
|
+
const found = [];
|
|
150
|
+
for (const name of await readdir(receiptsDir)) {
|
|
151
|
+
if (!name.endsWith(".json")) continue;
|
|
152
|
+
const key = name.slice(0, -".json".length);
|
|
153
|
+
try {
|
|
154
|
+
const file = path.join(receiptsDir, name);
|
|
155
|
+
const receipt = JSON.parse(await readFile(file, "utf8"));
|
|
156
|
+
if (receipt?.version === 1 && typeof receipt.sessionId === "string") found.push({ key, receipt, writtenAt: (await stat(file)).mtimeMs });
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return found;
|
|
161
|
+
},
|
|
162
|
+
/** When the newest of these records' files was written (a restore writes them anew); 0 when none is there. */
|
|
163
|
+
async writtenAt(ids) {
|
|
164
|
+
let newest = 0;
|
|
165
|
+
for (const id of ids) newest = Math.max(newest, await stat(path.join(sessionsDir, `${fileName(id)}.json`)).then((info) => info.mtimeMs, () => 0));
|
|
166
|
+
return newest;
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
* Deletes receipts not written for `maxAgeMs` and, with `temporaries` (only at start, when no
|
|
170
|
+
* write can be under way), temporary files a crash left behind.
|
|
171
|
+
*/
|
|
172
|
+
async pruneReceipts(maxAgeMs, { temporaries = true } = {}) {
|
|
173
|
+
await prepare();
|
|
174
|
+
const now = Date.now();
|
|
175
|
+
for (const directory of [sessionsDir, receiptsDir]) {
|
|
176
|
+
for (const name of await readdir(directory)) {
|
|
177
|
+
const file = path.join(directory, name);
|
|
178
|
+
if (name.endsWith(".tmp")) {
|
|
179
|
+
if (temporaries) await rm(file, { force: true });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (directory !== receiptsDir) continue;
|
|
183
|
+
const info = await stat(file).catch(() => void 0);
|
|
184
|
+
if (info && now - info.mtimeMs > maxAgeMs) await rm(file, { force: true });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
async list() {
|
|
189
|
+
await prepare();
|
|
190
|
+
const records = [];
|
|
191
|
+
for (const name of await readdir(sessionsDir)) {
|
|
192
|
+
if (!name.endsWith(".json")) continue;
|
|
193
|
+
try {
|
|
194
|
+
const record = JSON.parse(await readFile(path.join(sessionsDir, name), "utf8"));
|
|
195
|
+
if (record?.version === 1 && typeof record.id === "string") records.push(record);
|
|
196
|
+
else log.warn(`skipped invalid record ${name}`, { code: "ALP_RECORD_UNREADABLE", file: name });
|
|
197
|
+
} catch {
|
|
198
|
+
log.warn(`skipped unreadable record ${name}`, { code: "ALP_RECORD_UNREADABLE", file: name });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return records;
|
|
202
|
+
},
|
|
203
|
+
append(rootId, envelope) {
|
|
204
|
+
const file = path.join(timelineDir, `${fileName(rootId)}.jsonl`);
|
|
205
|
+
const line = `${JSON.stringify(envelope)}
|
|
206
|
+
`;
|
|
207
|
+
return queue(appends, rootId, `timeline ${rootId}`, async () => {
|
|
208
|
+
if (!repaired.has(rootId)) {
|
|
209
|
+
await repairTail(file);
|
|
210
|
+
repaired.add(rootId);
|
|
211
|
+
}
|
|
212
|
+
await appendFile(file, line, { mode: 384 });
|
|
213
|
+
}, true, { rootId });
|
|
214
|
+
},
|
|
215
|
+
async timeline(rootId) {
|
|
216
|
+
await appends.get(rootId);
|
|
217
|
+
const name = `${fileName(rootId)}.jsonl`;
|
|
218
|
+
try {
|
|
219
|
+
return parseTimeline(await readFile(path.join(timelineDir, name), "utf8"), name);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if (error?.code === "ENOENT") return [];
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
/**
|
|
226
|
+
* Waits for the queued writes of these records and timelines, and names those that
|
|
227
|
+
* failed: a record whose last write failed, or a timeline that lost a line.
|
|
228
|
+
*/
|
|
229
|
+
async drain({ records = [], timelines = [] }) {
|
|
230
|
+
await Promise.all([...records.map((id) => writes.get(id)), ...timelines.map((id) => appends.get(id))]);
|
|
231
|
+
return [...records.filter((id) => failed.has(id)), ...timelines.filter((id) => failed.has(`timeline:${id}`))];
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* Whether the state directory can be read and written right now: a small file is written,
|
|
235
|
+
* read back and removed. `StoreHealth` only says what failed since alpd started.
|
|
236
|
+
*/
|
|
237
|
+
async probe() {
|
|
238
|
+
const file = path.join(root, `.probe-${process.pid}-${randomBytes(3).toString("hex")}.tmp`);
|
|
239
|
+
const token = randomBytes(8).toString("hex");
|
|
240
|
+
let step = "write";
|
|
241
|
+
try {
|
|
242
|
+
await prepare();
|
|
243
|
+
await writeFile(file, token, { mode: 384 });
|
|
244
|
+
step = "read";
|
|
245
|
+
if (await readFile(file, "utf8") !== token) throw new Error("what was written is not what was read back");
|
|
246
|
+
return { ok: true };
|
|
247
|
+
} catch (error) {
|
|
248
|
+
return { ok: false, code: step === "write" ? "ALP_STATE_NOT_WRITABLE" : "ALP_STATE_NOT_READABLE", message: `${error?.code ? `${error.code}: ` : ""}${error?.message ?? error}` };
|
|
249
|
+
} finally {
|
|
250
|
+
await rm(file, { force: true }).catch(() => {
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
/** How many records, receipts and timelines are failed now: a later successful write clears a record, a lost timeline line never clears. */
|
|
255
|
+
failing() {
|
|
256
|
+
return failed.size;
|
|
257
|
+
},
|
|
258
|
+
health() {
|
|
259
|
+
return { ...health, ...health.lastError ? { lastError: { ...health.lastError } } : {} };
|
|
260
|
+
},
|
|
261
|
+
/** Removes a whole tree: its records and its timeline. */
|
|
262
|
+
async remove(rootId, ids) {
|
|
263
|
+
await Promise.all([...ids.map((id) => writes.get(id)), appends.get(rootId)]);
|
|
264
|
+
await Promise.all([
|
|
265
|
+
...ids.map((id) => rm(path.join(sessionsDir, `${fileName(id)}.json`), { force: true })),
|
|
266
|
+
rm(path.join(timelineDir, `${fileName(rootId)}.jsonl`), { force: true })
|
|
267
|
+
]);
|
|
268
|
+
for (const id of ids) failed.delete(id);
|
|
269
|
+
failed.delete(`timeline:${rootId}`);
|
|
270
|
+
repaired.delete(rootId);
|
|
271
|
+
},
|
|
272
|
+
async flush() {
|
|
273
|
+
await Promise.all([...writes.values(), ...appends.values()]);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
createStore
|
|
279
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,102 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anhlp/alp-daemon",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "ALP daemon module",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"dist",
|
|
9
|
+
"NOTICE"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
"./index": {
|
|
13
|
+
"alp-source": {
|
|
14
|
+
"types": "./src/index.ts",
|
|
15
|
+
"default": "./src/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
".": {
|
|
21
|
+
"alp-source": {
|
|
22
|
+
"types": "./src/index.ts",
|
|
23
|
+
"default": "./src/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./files": {
|
|
29
|
+
"alp-source": {
|
|
30
|
+
"types": "./src/files.ts",
|
|
31
|
+
"default": "./src/files.ts"
|
|
32
|
+
},
|
|
33
|
+
"types": "./dist/files.d.ts",
|
|
34
|
+
"default": "./dist/files.js"
|
|
35
|
+
},
|
|
36
|
+
"./lock": {
|
|
37
|
+
"alp-source": {
|
|
38
|
+
"types": "./src/lock.ts",
|
|
39
|
+
"default": "./src/lock.ts"
|
|
40
|
+
},
|
|
41
|
+
"types": "./dist/lock.d.ts",
|
|
42
|
+
"default": "./dist/lock.js"
|
|
43
|
+
},
|
|
44
|
+
"./main": {
|
|
45
|
+
"alp-source": {
|
|
46
|
+
"types": "./src/main.ts",
|
|
47
|
+
"default": "./src/main.ts"
|
|
48
|
+
},
|
|
49
|
+
"types": "./dist/main.d.ts",
|
|
50
|
+
"default": "./dist/main.js"
|
|
51
|
+
},
|
|
52
|
+
"./server": {
|
|
53
|
+
"alp-source": {
|
|
54
|
+
"types": "./src/server.ts",
|
|
55
|
+
"default": "./src/server.ts"
|
|
56
|
+
},
|
|
57
|
+
"types": "./dist/server.d.ts",
|
|
58
|
+
"default": "./dist/server.js"
|
|
59
|
+
},
|
|
60
|
+
"./store": {
|
|
61
|
+
"alp-source": {
|
|
62
|
+
"types": "./src/store.ts",
|
|
63
|
+
"default": "./src/store.ts"
|
|
64
|
+
},
|
|
65
|
+
"types": "./dist/store.d.ts",
|
|
66
|
+
"default": "./dist/store.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=22.12"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@anhlp/alp-core": "0.0.1-beta.3",
|
|
74
|
+
"@anhlp/alp-runtime": "0.0.1-beta.3",
|
|
75
|
+
"@anhlp/alp-client": "0.0.1-beta.3",
|
|
76
|
+
"@anhlp/alp-protocol": "0.0.1-beta.3",
|
|
77
|
+
"@anthropic-ai/sdk": "^0.131.0",
|
|
78
|
+
"ws": "^8.22.0",
|
|
79
|
+
"zod": "4.4.3",
|
|
80
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.292"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "node ../../scripts/build-workspace.mjs daemon",
|
|
84
|
+
"test": "node ../../scripts/test-package.mjs daemon",
|
|
85
|
+
"prepack": "npm run build"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public",
|
|
89
|
+
"registry": "https://registry.npmjs.org/",
|
|
90
|
+
"tag": "beta"
|
|
91
|
+
},
|
|
92
|
+
"license": "Apache-2.0",
|
|
93
|
+
"repository": {
|
|
94
|
+
"type": "git",
|
|
95
|
+
"url": "git+https://github.com/phucanh08/alp.git",
|
|
96
|
+
"directory": "packages/daemon"
|
|
97
|
+
},
|
|
98
|
+
"homepage": "https://github.com/phucanh08/alp/tree/main/packages/daemon#readme",
|
|
99
|
+
"bugs": {
|
|
100
|
+
"url": "https://github.com/phucanh08/alp/issues"
|
|
101
|
+
}
|
|
102
|
+
}
|