@centralu/win32-x64 0.1.0-beta.75 → 0.1.0-beta.77
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/Centralu/centralu.exe
CHANGED
|
Binary file
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
* its own. Spacing (margins, padding, gaps) has no theme variable and stays literal.
|
|
17
17
|
*/
|
|
18
18
|
:root {
|
|
19
|
-
--bg: var(--color-background-secondary, #
|
|
20
|
-
--bg-hover: var(--color-background-tertiary, #
|
|
21
|
-
--ink: var(--color-text-primary, #
|
|
22
|
-
--danger: var(--color-text-danger, #
|
|
23
|
-
--edge: var(--color-border-secondary, #
|
|
24
|
-
--ring: var(--color-ring-primary, #
|
|
19
|
+
--bg: var(--color-background-secondary, #2c2c2e);
|
|
20
|
+
--bg-hover: var(--color-background-tertiary, #48484a);
|
|
21
|
+
--ink: var(--color-text-primary, #f5f5f7);
|
|
22
|
+
--danger: var(--color-text-danger, #ff9f97);
|
|
23
|
+
--edge: var(--color-border-secondary, #545456);
|
|
24
|
+
--ring: var(--color-ring-primary, #409cff);
|
|
25
25
|
--sans: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', system-ui, sans-serif);
|
|
26
26
|
--text: var(--font-text-md-size, 13px);
|
|
27
27
|
--leading: var(--font-text-md-line-height, 1.65);
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
--sb-inset: var(--centralu-scrollbar-inset, 3px);
|
|
35
35
|
--sb-radius: var(--centralu-scrollbar-radius, 999px);
|
|
36
36
|
--sb-track: var(--centralu-scrollbar-track, transparent);
|
|
37
|
-
--sb-thumb: var(--centralu-scrollbar-thumb, #
|
|
38
|
-
--sb-thumb-hover: var(--centralu-scrollbar-thumb-hover, #
|
|
37
|
+
--sb-thumb: var(--centralu-scrollbar-thumb, #48484a);
|
|
38
|
+
--sb-thumb-hover: var(--centralu-scrollbar-thumb-hover, #636366);
|
|
39
39
|
}
|
|
40
40
|
body {
|
|
41
41
|
margin: 16px;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "d0e9e70",
|
|
3
3
|
"protocolVersion": 1,
|
|
4
4
|
"hostProof": 1,
|
|
5
5
|
"tokenOnStdin": 1,
|
|
6
6
|
"verifiers": 1,
|
|
7
7
|
"keyPairing": 1,
|
|
8
|
-
"builtAt": "2026-11-
|
|
8
|
+
"builtAt": "2026-11-18T14:08:34.088Z",
|
|
9
9
|
"runtime": "system-node",
|
|
10
10
|
"platform": "win32",
|
|
11
11
|
"arch": "x64"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "centralu",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.77",
|
|
4
4
|
"description": "Run, watch and steer several Claude Code and Codex CLI sessions from one window",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ijun17",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"win32"
|
|
39
39
|
],
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@centralu/darwin-arm64": "0.1.0-beta.
|
|
42
|
-
"@centralu/linux-arm64": "0.1.0-beta.
|
|
43
|
-
"@centralu/linux-x64": "0.1.0-beta.
|
|
44
|
-
"@centralu/win32-x64": "0.1.0-beta.
|
|
41
|
+
"@centralu/darwin-arm64": "0.1.0-beta.77",
|
|
42
|
+
"@centralu/linux-arm64": "0.1.0-beta.77",
|
|
43
|
+
"@centralu/linux-x64": "0.1.0-beta.77",
|
|
44
|
+
"@centralu/win32-x64": "0.1.0-beta.77"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -43046,7 +43046,7 @@ import { dirname as dirname27, join as join58 } from "node:path";
|
|
|
43046
43046
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync27, writeSync as writeSync4 } from "node:fs";
|
|
43047
43047
|
|
|
43048
43048
|
// packages/protocol/src/version.generated.ts
|
|
43049
|
-
var APP_VERSION = "0.1.0-beta.
|
|
43049
|
+
var APP_VERSION = "0.1.0-beta.77";
|
|
43050
43050
|
|
|
43051
43051
|
// packages/protocol/src/brand.ts
|
|
43052
43052
|
var APP_NAME = "Centralu";
|
|
@@ -59798,6 +59798,7 @@ var appScoped = { sessionId: external_exports.string().optional() };
|
|
|
59798
59798
|
var persistedSeq = { seq: external_exports.number().optional() };
|
|
59799
59799
|
var APP_VIEWS_LIVE_PER_SESSION = 3;
|
|
59800
59800
|
var STOP_NOT_CONFIRMED_LABEL = "stop not confirmed";
|
|
59801
|
+
var MailDelivered = external_exports.object({ threadId: external_exports.string(), messageId: external_exports.string() });
|
|
59801
59802
|
var AppChangeCause = external_exports.looseObject({ kind: external_exports.string(), instanceId: external_exports.string().optional() });
|
|
59802
59803
|
var MessageDelta = external_exports.object({
|
|
59803
59804
|
...base,
|
|
@@ -60220,7 +60221,7 @@ var NormalizedEvent = external_exports.discriminatedUnion("type", [
|
|
|
60220
60221
|
oncePerSession: external_exports.boolean().optional(),
|
|
60221
60222
|
/** Who is speaking, as the person knows the tool: `Codex`, `Claude Code` */
|
|
60222
60223
|
from: external_exports.string().optional(),
|
|
60223
|
-
/** What kind of notice, in a few words: `config warning`, `deprecation`, `warning` */
|
|
60224
|
+
/** What kind of notice, in a few words: `config warning`, `deprecation`, `warning`; for Centralu's own lines, what happened (`next step after compaction`) */
|
|
60224
60225
|
label: external_exports.string().optional(),
|
|
60225
60226
|
/**
|
|
60226
60227
|
* Who has to act. `you`: the person's own setup (their `config.toml`, an MCP server they added). `centralu`: how
|
|
@@ -60233,7 +60234,13 @@ var NormalizedEvent = external_exports.discriminatedUnion("type", [
|
|
|
60233
60234
|
/** What the explanation names, one per line (the settings Codex ignored) */
|
|
60234
60235
|
items: external_exports.array(external_exports.string()).optional(),
|
|
60235
60236
|
/** What would make the notice go away, or that nothing needs doing */
|
|
60236
|
-
hint: external_exports.string().optional()
|
|
60237
|
+
hint: external_exports.string().optional(),
|
|
60238
|
+
/**
|
|
60239
|
+
* A mail delivery's line (`label: 'mail'`, #2333): the messages it delivered, each with the chain it is in (`mail.thread`'s `threadId`), so the
|
|
60240
|
+
* window can fold the line open to show them. Absent from an older host, from a row stored before it and from the mailbox's other lines: the line
|
|
60241
|
+
* then does not fold. Malformed, it reads as absent
|
|
60242
|
+
*/
|
|
60243
|
+
mail: external_exports.array(MailDelivered).optional().catch(void 0)
|
|
60237
60244
|
}),
|
|
60238
60245
|
/**
|
|
60239
60246
|
* This session was born from a handoff, and the predecessor's note is pinned here (#102).
|
|
@@ -63722,8 +63729,7 @@ var THEME_PRESETS = [
|
|
|
63722
63729
|
{ id: "dark", name: "Dark", base: "dark" },
|
|
63723
63730
|
{ id: "light", name: "Light", base: "light" },
|
|
63724
63731
|
{ id: "hc-dark", name: "High contrast dark", base: "dark" },
|
|
63725
|
-
{ id: "hc-light", name: "High contrast light", base: "light" }
|
|
63726
|
-
{ id: "graphite", name: "Graphite", base: "dark" }
|
|
63732
|
+
{ id: "hc-light", name: "High contrast light", base: "light" }
|
|
63727
63733
|
];
|
|
63728
63734
|
function themeSlug(name) {
|
|
63729
63735
|
return name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "theme";
|
|
@@ -66885,7 +66891,25 @@ var files = {
|
|
|
66885
66891
|
writeSync: (fd, data) => typeof data === "string" ? fs.writeSync(fd, data) : fs.writeSync(fd, data),
|
|
66886
66892
|
fstatSync: (fd) => toStats(fs.fstatSync(fd, { bigint: true })),
|
|
66887
66893
|
fchmodSync: (fd, mode) => fs.fchmodSync(fd, mode),
|
|
66894
|
+
fsyncSync: (fd) => fs.fsyncSync(fd),
|
|
66895
|
+
fsyncDirSync: (p) => {
|
|
66896
|
+
if (HOST_FAMILY === "windows") return;
|
|
66897
|
+
const fd = fs.openSync(p, "r");
|
|
66898
|
+
try {
|
|
66899
|
+
fs.fsyncSync(fd);
|
|
66900
|
+
} finally {
|
|
66901
|
+
fs.closeSync(fd);
|
|
66902
|
+
}
|
|
66903
|
+
},
|
|
66888
66904
|
closeSync: (fd) => fs.closeSync(fd),
|
|
66905
|
+
freeBytesSync: (p) => {
|
|
66906
|
+
try {
|
|
66907
|
+
const s = fs.statfsSync(p);
|
|
66908
|
+
return s.bavail * s.bsize;
|
|
66909
|
+
} catch {
|
|
66910
|
+
return null;
|
|
66911
|
+
}
|
|
66912
|
+
},
|
|
66889
66913
|
createReadStream: (p, o) => fs.createReadStream(p, o),
|
|
66890
66914
|
watch: (p, o, listener) => fs.watch(
|
|
66891
66915
|
p,
|
|
@@ -67143,7 +67167,12 @@ var realOsValue = {
|
|
|
67143
67167
|
},
|
|
67144
67168
|
clock,
|
|
67145
67169
|
sqlite: {
|
|
67146
|
-
|
|
67170
|
+
// The port's three and only those that are set: better-sqlite3 refuses one that is named and undefined
|
|
67171
|
+
open: (path2, { readonly: readonly2, fileMustExist, timeout } = {}) => new Database(path2, {
|
|
67172
|
+
...readonly2 !== void 0 && { readonly: readonly2 },
|
|
67173
|
+
...fileMustExist !== void 0 && { fileMustExist },
|
|
67174
|
+
...timeout !== void 0 && { timeout }
|
|
67175
|
+
})
|
|
67147
67176
|
},
|
|
67148
67177
|
traits
|
|
67149
67178
|
};
|
|
@@ -110143,7 +110172,13 @@ var WARNING_TEXT = {
|
|
|
110143
110172
|
/** The three guards that refuse rather than warn (#1684, #2035): the person hears of the first refusal of each kind a clock hour */
|
|
110144
110173
|
repeat: (sender, to) => `Centralu refused mail from ${sender} to ${to}: the same text again within ${durationText(REPEAT_WINDOW_MS)}. ${sender} was told; nothing else was stopped.`,
|
|
110145
110174
|
rate_limited: (sender, limit) => `Centralu refused mail from ${sender}: more than ${limit} messages in a minute. ${sender} was told to wait; nothing else was stopped.`,
|
|
110146
|
-
ask_rate: (sender) => `Centralu refused a request from ${sender} to the Assistant: its project's sessions asked ${ASKS_PER_HOUR} times in the last hour. ${sender} was told to wait or write to you
|
|
110175
|
+
ask_rate: (sender) => `Centralu refused a request from ${sender} to the Assistant: its project's sessions asked ${ASKS_PER_HOUR} times in the last hour. ${sender} was told to wait or write to you.`,
|
|
110176
|
+
/**
|
|
110177
|
+
* An update changed the store past what an older build reads without the copy kept before it (#2304): the disk was
|
|
110178
|
+
* `short` of the room a copy is made with, or (null) the copy could not be written, which the log explains. Said
|
|
110179
|
+
* plainly, since nothing brings back what the change removed
|
|
110180
|
+
*/
|
|
110181
|
+
noStoreCopy: (short2) => `This update changed Centralu's data on this computer without keeping a copy first: ${short2 ? `the disk has ${short2.free} free, and the copy is made only when ${short2.needed} is free (twice the size of the data)` : "the copy could not be written"}. The change cannot be undone, and there is no copy to go back to. Centralu works as usual.`
|
|
110147
110182
|
};
|
|
110148
110183
|
var TASK_CUT = "\n[Centralu: cut here. The full task is in the session's conversation (read_session).]";
|
|
110149
110184
|
function cutTask(text3, limit) {
|
|
@@ -110478,7 +110513,7 @@ var MailDelivery = class {
|
|
|
110478
110513
|
const party = parseAddress(recipient);
|
|
110479
110514
|
if (held3 > 0 && party?.kind === "session") {
|
|
110480
110515
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
110481
|
-
this.sessions.note(party.sessionId,
|
|
110516
|
+
this.sessions.note(party.sessionId, `${n} may have reached you although the tool reported a failure, and was not sent again: the Inbox has Resend and Dismiss`);
|
|
110482
110517
|
}
|
|
110483
110518
|
}
|
|
110484
110519
|
/** A delivery the previous host left half done is held or sent again (`reconcileInterrupted`), and the receiver is told when it is held */
|
|
@@ -110488,7 +110523,7 @@ var MailDelivery = class {
|
|
|
110488
110523
|
const party = parseAddress(recipient);
|
|
110489
110524
|
if (held3 > 0 && party?.kind === "session") {
|
|
110490
110525
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
110491
|
-
this.sessions.note(party.sessionId,
|
|
110526
|
+
this.sessions.note(party.sessionId, `${n} may not have arrived when Centralu restarted, and was not sent again: the Inbox has Resend and Dismiss`);
|
|
110492
110527
|
}
|
|
110493
110528
|
}
|
|
110494
110529
|
} catch (e) {
|
|
@@ -110575,7 +110610,7 @@ var MailDelivery = class {
|
|
|
110575
110610
|
const inputId = joins ? randomUUID11() : void 0;
|
|
110576
110611
|
const depth = Math.max(0, ...drained.messageIds.map((id3) => this.records.message(id3)?.facts.agentDepth ?? 0));
|
|
110577
110612
|
try {
|
|
110578
|
-
await this.sessions.deliver(sessionId, { text: drained.text, quiet: quiet2, line: drained.line, wanted: () => drained.messageIds.some((id3) => this.records.recipient(id3, recipient)?.settled !== "withdrawn"), ...joins ? { joins, id: inputId } : {}, ...shown3 ? { shown: shown3 } : {}, ...depth ? { depth } : {} }, (e) => {
|
|
110613
|
+
await this.sessions.deliver(sessionId, { text: drained.text, quiet: quiet2, line: drained.line, listed: drained.listed, wanted: () => drained.messageIds.some((id3) => this.records.recipient(id3, recipient)?.settled !== "withdrawn"), ...joins ? { joins, id: inputId } : {}, ...shown3 ? { shown: shown3 } : {}, ...depth ? { depth } : {} }, (e) => {
|
|
110579
110614
|
cancelTurn();
|
|
110580
110615
|
if (delivered.at !== void 0) this.takeBack(recipient, drained.messageIds, delivered.at, e);
|
|
110581
110616
|
});
|
|
@@ -110644,7 +110679,7 @@ var MailDelivery = class {
|
|
|
110644
110679
|
const work = drained.workMessage === null ? void 0 : this.records.message(drained.workMessage);
|
|
110645
110680
|
const m = drained.workMessage === null ? drained.messageIds.map((id3) => this.records.message(id3)).find((n) => n !== void 0 && isSendNote(n)) : work?.kind === "task" && SEND_ORIGINS.has(work.origin ?? "") ? work : void 0;
|
|
110646
110681
|
const from = m && parseAddress(m.sender);
|
|
110647
|
-
return m && from?.kind === "session" ? { senderId: from.sessionId, text: m.body } : void 0;
|
|
110682
|
+
return m && from?.kind === "session" ? { senderId: from.sessionId, text: m.body, messageId: m.id } : void 0;
|
|
110648
110683
|
}
|
|
110649
110684
|
/** What the receiver's conversation shows as a session's message (`MailInput.shown`): the delegated task, else a card's notice, from its session */
|
|
110650
110685
|
shownOf(drained) {
|
|
@@ -110654,7 +110689,7 @@ var MailDelivery = class {
|
|
|
110654
110689
|
for (const id3 of drained.messageIds) {
|
|
110655
110690
|
const m = this.records.message(id3);
|
|
110656
110691
|
const about = m?.facts.card ? parseAddress(m.facts.card.session) : void 0;
|
|
110657
|
-
if (m && about?.kind === "session") return { senderId: about.sessionId, text: m.body, alone };
|
|
110692
|
+
if (m && about?.kind === "session") return { senderId: about.sessionId, text: m.body, alone, messageId: id3 };
|
|
110658
110693
|
}
|
|
110659
110694
|
return void 0;
|
|
110660
110695
|
}
|
|
@@ -119595,6 +119630,8 @@ var MailFacts = external_exports.looseObject({
|
|
|
119595
119630
|
watch: external_exports.object({ id: external_exports.string(), source: external_exports.string(), change: external_exports.string(), late: external_exports.boolean().optional() }).optional(),
|
|
119596
119631
|
/** On Centralu's warning to the person (#1684): a send a guard refused (`repeat`, `rate_limited`, `ask_rate`), and whose */
|
|
119597
119632
|
guardRefused: external_exports.object({ sender: external_exports.string(), reason: external_exports.string() }).optional(),
|
|
119633
|
+
/** On Centralu's notice to the person (#2304): the store step that broke older readers and ran without a copy of the store before it, and why (`low_disk`, `failed`) */
|
|
119634
|
+
storeCopySkipped: external_exports.object({ step: external_exports.number(), reason: external_exports.string() }).optional(),
|
|
119598
119635
|
answerHeld: external_exports.object({ question: external_exports.string(), answer: external_exports.string() }).optional(),
|
|
119599
119636
|
refused: external_exports.object({ tool: external_exports.string(), target: external_exports.string(), firstLine: external_exports.string(), projectId: external_exports.string() }).optional(),
|
|
119600
119637
|
trusted: external_exports.object({ project: external_exports.string(), refused: external_exports.array(external_exports.string()) }).optional(),
|
|
@@ -120700,7 +120737,16 @@ function buildMessageFrame(items, calls = PLAIN_MESSAGE_CALLS, budget = MAIL_FRA
|
|
|
120700
120737
|
});
|
|
120701
120738
|
}
|
|
120702
120739
|
function deliveryLine(messages2, relations) {
|
|
120703
|
-
|
|
120740
|
+
const parties = [...relations];
|
|
120741
|
+
const from = parties.length > 1 ? `${parties.slice(0, -1).join(", ")} and ${parties.at(-1)}` : parties[0] ?? "";
|
|
120742
|
+
return `${messages2} ${messages2 === 1 ? "message" : "messages"} from ${from}`;
|
|
120743
|
+
}
|
|
120744
|
+
function mailLine(listed2, leaveOut) {
|
|
120745
|
+
const rest = listed2.filter((l) => l.messageId !== leaveOut);
|
|
120746
|
+
return {
|
|
120747
|
+
line: rest.length === 0 ? "" : deliveryLine(rest.length, new Set(rest.map((l) => l.relation))),
|
|
120748
|
+
mail: rest.map(({ threadId, messageId }) => ({ threadId, messageId }))
|
|
120749
|
+
};
|
|
120704
120750
|
}
|
|
120705
120751
|
|
|
120706
120752
|
// packages/agent-host/src/sessions/script-messages.ts
|
|
@@ -124392,7 +124438,8 @@ ${attachments.map((a) => `@${a.path}`).join("\n")}` : text3;
|
|
|
124392
124438
|
}
|
|
124393
124439
|
if (input.skipLine?.()) return;
|
|
124394
124440
|
const shown3 = !input.quiet && input.shown !== void 0 && this.showSent(sessionId, input.shown);
|
|
124395
|
-
|
|
124441
|
+
const { line, mail } = input.listed ? mailLine(input.listed, shown3 ? input.shown?.messageId : void 0) : { line: input.line, mail: [] };
|
|
124442
|
+
if (line) this.onEvent({ type: "notice", sessionId, level: "info", from: "Centralu", label: input.label ?? "mail", ...input.audience ? { audience: input.audience } : {}, text: line, ...mail.length ? { mail } : {} });
|
|
124396
124443
|
}
|
|
124397
124444
|
/**
|
|
124398
124445
|
* A delegated task or a card's notice the mailbox gave, written in the receiver's conversation as its sender's message (`deliverMail`): stored and shown, never
|
|
@@ -124578,7 +124625,7 @@ var MailSessionsView = class {
|
|
|
124578
124625
|
/** Puts a notice from Centralu into the session's process, quietly (`tellsMailNow`). It stops nothing: the person's close tells a session its work is not wanted, and the session decides */
|
|
124579
124626
|
async tellMailNow(sessionId, text3) {
|
|
124580
124627
|
try {
|
|
124581
|
-
await this.host.events.deliverMail(sessionId, { text: `[Centralu] ${text3}`, quiet: true, line: "
|
|
124628
|
+
await this.host.events.deliverMail(sessionId, { text: `[Centralu] ${text3}`, quiet: true, line: "Centralu told it the person closed its work" });
|
|
124582
124629
|
} catch (e) {
|
|
124583
124630
|
console.error(`[mail] could not tell ${sessionId.slice(0, 8)} that the person closed its work (${errorMessage(e)}); the notice goes with its next mail`);
|
|
124584
124631
|
throw e;
|
|
@@ -125681,6 +125728,22 @@ function settingThenKeep(settings) {
|
|
|
125681
125728
|
}
|
|
125682
125729
|
|
|
125683
125730
|
// packages/agent-host/src/sessions/self-compaction.ts
|
|
125731
|
+
var COMPACT_LABELS = {
|
|
125732
|
+
/** The next step, sent once the compaction is done */
|
|
125733
|
+
stepAfter: "next step after compaction",
|
|
125734
|
+
/** A compaction that did not happen, said when it did not (the reason is in its folded text); its step goes on and adds no line */
|
|
125735
|
+
refused: "nothing compacted",
|
|
125736
|
+
/** A compaction that did not happen, and a next step that was not sent (said once, whichever path found it) */
|
|
125737
|
+
refusedStepLost: "nothing compacted, next step not sent",
|
|
125738
|
+
/** A next step that could not be given to the session, after a compaction that happened */
|
|
125739
|
+
stepNotSent: "next step not sent",
|
|
125740
|
+
/** The turn that told the agent to go on after Centralu restarted ("host" is an internal word, ux-writing §1.9) */
|
|
125741
|
+
wentOnAfterRestart: "went on after a restart",
|
|
125742
|
+
/** What was said of a compaction asked for when Centralu restarted */
|
|
125743
|
+
restarted: "restart during a compaction",
|
|
125744
|
+
/** The note that the context is filling up (`ContextNudges`) */
|
|
125745
|
+
contextFilling: "context filling up"
|
|
125746
|
+
};
|
|
125684
125747
|
var COMPACT_FLOOR_TOKENS = 1e5;
|
|
125685
125748
|
var IDLE_COMPACT_MINUTES = 10;
|
|
125686
125749
|
var SWEEP_MS = 6e4;
|
|
@@ -125805,9 +125868,9 @@ var SelfCompaction = class {
|
|
|
125805
125868
|
return this.stepping.delete(sessionId);
|
|
125806
125869
|
}
|
|
125807
125870
|
/** Sends a next step as a turn of the session's own (`SelfCompactionHost.sendThen`), the turn it opens marked as going on with the work (`stepOpens`) */
|
|
125808
|
-
async goOn(id3, text3, line) {
|
|
125871
|
+
async goOn(id3, text3, line, label) {
|
|
125809
125872
|
this.stepping.add(id3);
|
|
125810
|
-
await this.host.sendThen(id3, text3, line).catch((err) => {
|
|
125873
|
+
await this.host.sendThen(id3, text3, line, label).catch((err) => {
|
|
125811
125874
|
this.stepping.delete(id3);
|
|
125812
125875
|
throw err;
|
|
125813
125876
|
});
|
|
@@ -125863,10 +125926,9 @@ var SelfCompaction = class {
|
|
|
125863
125926
|
mine.compacted = true;
|
|
125864
125927
|
if (e.failed && mine.then) {
|
|
125865
125928
|
mine.refused = `the tool reported the compaction failed${e.reason ? `: ${e.reason}` : ""}`;
|
|
125866
|
-
this.
|
|
125929
|
+
this.refusal(id3, mine.refused);
|
|
125867
125930
|
}
|
|
125868
125931
|
this.stage(id3, mine, mine.refused === null ? "compacted" : "refused");
|
|
125869
|
-
if (!e.failed) this.host.notice(id3, `Compacted by Centralu (${mine.why})`);
|
|
125870
125932
|
}
|
|
125871
125933
|
const live2 = this.pending.get(id3);
|
|
125872
125934
|
if (e.type === "context_update" && live2 && live2.endedAt !== null) return this.decide(id3, e.used, m.tool);
|
|
@@ -126000,7 +126062,7 @@ var SelfCompaction = class {
|
|
|
126000
126062
|
if (used === null) return this.refused(id3, null, "no size of the context was read since the last compaction, so it could not be told to be over the floor");
|
|
126001
126063
|
if (used < COMPACT_FLOOR_TOKENS) return this.refused(id3, used, `the context was ${Math.round(used / 1e3)}k tokens, under the ${COMPACT_FLOOR_TOKENS / 1e3}k floor`);
|
|
126002
126064
|
this.settle(id3);
|
|
126003
|
-
this.fire(id3,
|
|
126065
|
+
this.fire(id3, req.focus, tool, req.then);
|
|
126004
126066
|
}
|
|
126005
126067
|
/** The request is refused at this size: remembered, so the same request asked again is answered in the tool result; its `then` still comes once */
|
|
126006
126068
|
refused(id3, used, why2) {
|
|
@@ -126012,12 +126074,19 @@ var SelfCompaction = class {
|
|
|
126012
126074
|
const then2 = c.then;
|
|
126013
126075
|
c.then = null;
|
|
126014
126076
|
this.stopSettling(id3);
|
|
126015
|
-
if (then2) this.tell(id3, then2, why2);
|
|
126077
|
+
if (then2) this.tell(id3, then2, why2, c.compacted && c.refused === null);
|
|
126078
|
+
}
|
|
126079
|
+
/**
|
|
126080
|
+
* The one line a refused compaction leaves, said when it is refused (owner, 2026-11-18): the session may be busy in a long turn for a long while before its step can
|
|
126081
|
+
* go, and a refusal nobody sees looks like a stall. The step's own turn then adds no line (`sendThen`), so the refusal is one line; a step that cannot be sent still says so
|
|
126082
|
+
*/
|
|
126083
|
+
refusal(id3, why2) {
|
|
126084
|
+
this.host.notice(id3, `The compaction did not happen (${why2}): the next step the agent set goes on without it`, COMPACT_LABELS.refused);
|
|
126016
126085
|
}
|
|
126017
126086
|
/** A request that did not compact and has a step: it is held like the step of a compaction (`ended`, so a turn of someone else's that begins goes first) and goes as a turn that says why */
|
|
126018
126087
|
refuseRequest(id3, then2, why2) {
|
|
126019
|
-
|
|
126020
|
-
this.
|
|
126088
|
+
this.refusal(id3, why2);
|
|
126089
|
+
const entry = { sentAt: this.now(), started: true, compacted: true, ended: true, then: then2, refused: why2, focusAside: null, ahead: false };
|
|
126021
126090
|
this.compacting.set(id3, entry);
|
|
126022
126091
|
this.stage(id3, entry, "refused");
|
|
126023
126092
|
this.settleThen(id3, entry);
|
|
@@ -126028,7 +126097,7 @@ var SelfCompaction = class {
|
|
|
126028
126097
|
this.compacting.delete(id3);
|
|
126029
126098
|
return;
|
|
126030
126099
|
}
|
|
126031
|
-
this.
|
|
126100
|
+
this.refusal(id3, why2);
|
|
126032
126101
|
c.refused = why2;
|
|
126033
126102
|
c.started = true;
|
|
126034
126103
|
c.compacted = true;
|
|
@@ -126094,7 +126163,7 @@ var SelfCompaction = class {
|
|
|
126094
126163
|
}
|
|
126095
126164
|
if (!won) return;
|
|
126096
126165
|
try {
|
|
126097
|
-
await this.goOn(id3, thenTurn(rec), rec.why === null ? "Centralu sent the agent its next step after the compaction" : "
|
|
126166
|
+
await this.goOn(id3, thenTurn(rec), rec.why === null ? "Centralu sent the agent its next step after the compaction" : "", COMPACT_LABELS.stepAfter);
|
|
126098
126167
|
this.erase(id3);
|
|
126099
126168
|
this.counted(id3);
|
|
126100
126169
|
} catch (err) {
|
|
@@ -126112,17 +126181,22 @@ var SelfCompaction = class {
|
|
|
126112
126181
|
console.error(`[compact] ${id3.slice(0, 8)}: could not count the cycle: ${err instanceof Error ? err.message : String(err)}`);
|
|
126113
126182
|
}
|
|
126114
126183
|
}
|
|
126115
|
-
/** Tells the session, quietly, that its `then` was not sent; the person's window gets a line too */
|
|
126116
|
-
tell(id3, then2, why2) {
|
|
126184
|
+
/** Tells the session, quietly, that its `then` was not sent; the person's window gets a line too. `done`: the compaction happened, which is not said to have not */
|
|
126185
|
+
tell(id3, then2, why2, done2 = false) {
|
|
126117
126186
|
this.erase(id3);
|
|
126118
|
-
|
|
126187
|
+
if (done2) {
|
|
126188
|
+
this.host.notice(id3, `The compaction is done, but the next step the agent set was not sent (${why2})`, COMPACT_LABELS.stepNotSent);
|
|
126189
|
+
this.deliver(id3, `[Centralu] The compaction you asked for is done, but your \`then\` was not sent (${why2}). It was: ${then2}`);
|
|
126190
|
+
return;
|
|
126191
|
+
}
|
|
126192
|
+
this.host.notice(id3, `The compaction did not happen (${why2}): the next step the agent set was not sent`, COMPACT_LABELS.refusedStepLost);
|
|
126119
126193
|
this.deliver(id3, `[Centralu] Your compact_self request did not compact (${why2}), so your \`then\` was not sent. It was: ${then2}`);
|
|
126120
126194
|
}
|
|
126121
126195
|
/** The step could not be given to the session: said as it was, for what it did (a compaction that happened is not said to have not) */
|
|
126122
126196
|
notTaken(id3, rec) {
|
|
126123
126197
|
this.erase(id3);
|
|
126124
126198
|
const what = rec.why === null ? "The compaction you asked for is done" : `Your compact_self request did not compact (${rec.why})`;
|
|
126125
|
-
this.host.notice(id3, `${rec.why === null ? "The compaction is done" : "The compaction did not happen"}, but the next step the agent set could not be sent
|
|
126199
|
+
this.host.notice(id3, `${rec.why === null ? "The compaction is done" : "The compaction did not happen"}, but the next step the agent set could not be sent`, rec.why === null ? COMPACT_LABELS.stepNotSent : COMPACT_LABELS.refusedStepLost);
|
|
126126
126200
|
this.deliver(id3, `[Centralu] ${what}, but the session could not take your \`then\`. If you were not continued, go on with it yourself. It was: ${rec.then}`);
|
|
126127
126201
|
}
|
|
126128
126202
|
/**
|
|
@@ -126134,13 +126208,13 @@ var SelfCompaction = class {
|
|
|
126134
126208
|
const text3 = `[Centralu] Centralu changed hosts while your compact_self request was pending (${how}), so it cannot tell whether the conversation was compacted or your \`then\` was sent. If you were not continued, go on with it yourself. It was: ${then2}`;
|
|
126135
126209
|
const reached = await this.reach(id3, text3);
|
|
126136
126210
|
const outcome2 = { turn: "the agent was woken with its next step", note: "the agent was told its next step", held: "the agent is told its next step at its next input" }[reached];
|
|
126137
|
-
this.host.notice(id3, `Centralu
|
|
126211
|
+
this.host.notice(id3, `Centralu restarted while a compaction was asked for (${how}): ${outcome2}`, COMPACT_LABELS.restarted);
|
|
126138
126212
|
}
|
|
126139
126213
|
/** A turn for the session when it can take one (it wakes), else a quiet note; `held` when neither could be given (kept for its next input) */
|
|
126140
126214
|
async reach(id3, text3) {
|
|
126141
126215
|
if (!this.stopped && this.host.ready(id3)) {
|
|
126142
126216
|
try {
|
|
126143
|
-
await this.goOn(id3, text3, "Centralu told the agent to go on: it
|
|
126217
|
+
await this.goOn(id3, text3, "Centralu told the agent to go on: it restarted while a compaction was asked for", COMPACT_LABELS.wentOnAfterRestart);
|
|
126144
126218
|
return "turn";
|
|
126145
126219
|
} catch {
|
|
126146
126220
|
}
|
|
@@ -126202,7 +126276,7 @@ var SelfCompaction = class {
|
|
|
126202
126276
|
/** What one kept step asks of the host that finds it (`recover`) */
|
|
126203
126277
|
resume(m, rec) {
|
|
126204
126278
|
const id3 = m.id;
|
|
126205
|
-
if (this.now() - rec.at > THEN_KEEP_MS) return this.tell(id3, rec.then, `it was kept for more than ${durationText(THEN_KEEP_MS)} without going on, and what it followed is long past
|
|
126279
|
+
if (this.now() - rec.at > THEN_KEEP_MS) return this.tell(id3, rec.then, `it was kept for more than ${durationText(THEN_KEEP_MS)} without going on, and what it followed is long past`, rec.stage === "compacted" && rec.why === null);
|
|
126206
126280
|
if (rec.stage === "compacted" || rec.stage === "refused") {
|
|
126207
126281
|
if (this.host.ready(id3) && this.queuedNow(id3) !== true) void this.sendThen(id3, rec);
|
|
126208
126282
|
else this.keepHeld(id3, rec);
|
|
@@ -126210,7 +126284,7 @@ var SelfCompaction = class {
|
|
|
126210
126284
|
}
|
|
126211
126285
|
/** Holds a kept step that cannot go yet, like the step of a compaction in this host that ended: `sweep` sends it once the session is ready */
|
|
126212
126286
|
keepHeld(id3, rec) {
|
|
126213
|
-
this.compacting.set(id3, {
|
|
126287
|
+
this.compacting.set(id3, { sentAt: this.now(), started: true, compacted: true, ended: true, then: rec.then, refused: rec.why, focusAside: rec.focusAside, ahead: rec.ahead });
|
|
126214
126288
|
}
|
|
126215
126289
|
/** The notes the tool could not take at the time, tried again: a turn of the session has begun, or its running turn made a request */
|
|
126216
126290
|
flushOwed(id3) {
|
|
@@ -126243,7 +126317,7 @@ var SelfCompaction = class {
|
|
|
126243
126317
|
return false;
|
|
126244
126318
|
}
|
|
126245
126319
|
}
|
|
126246
|
-
fire(id3,
|
|
126320
|
+
fire(id3, focus, tool, then2 = null) {
|
|
126247
126321
|
const text3 = this.host.command(id3, tool, focus);
|
|
126248
126322
|
if (text3 === null) {
|
|
126249
126323
|
if (then2) this.refuseRequest(id3, then2, "this tool has no compact command");
|
|
@@ -126252,7 +126326,7 @@ var SelfCompaction = class {
|
|
|
126252
126326
|
this.refusedAt.delete(id3);
|
|
126253
126327
|
const focusAside = focus !== null && text3 === this.host.command(id3, tool, null) ? focus : null;
|
|
126254
126328
|
try {
|
|
126255
|
-
const entry = {
|
|
126329
|
+
const entry = { sentAt: this.now(), started: false, compacted: false, ended: false, then: then2, refused: null, focusAside, ahead: false };
|
|
126256
126330
|
this.compacting.set(id3, entry);
|
|
126257
126331
|
this.stage(id3, entry, "sent");
|
|
126258
126332
|
this.host.send(id3, text3);
|
|
@@ -126272,7 +126346,7 @@ var SelfCompaction = class {
|
|
|
126272
126346
|
for (const m of this.host.sessions()) {
|
|
126273
126347
|
if (this.pending.get(m.id)?.held) this.releaseHeld(m.id, m);
|
|
126274
126348
|
if (!this.due(m, setting, now)) continue;
|
|
126275
|
-
this.fire(m.id,
|
|
126349
|
+
this.fire(m.id, null, m.tool);
|
|
126276
126350
|
if (this.compacting.has(m.id)) sent.push(m.id);
|
|
126277
126351
|
}
|
|
126278
126352
|
return sent;
|
|
@@ -126444,7 +126518,7 @@ var ContextNudges = class {
|
|
|
126444
126518
|
const answered = (took2) => {
|
|
126445
126519
|
if (!took2) return;
|
|
126446
126520
|
c.waiting = null;
|
|
126447
|
-
this.host.notice(id3, `Centralu told it its context is ${percent}% full: call compact_self with then set to its next step
|
|
126521
|
+
this.host.notice(id3, `Centralu told it its context is ${percent}% full: call compact_self with then set to its next step`, COMPACT_LABELS.contextFilling);
|
|
126448
126522
|
};
|
|
126449
126523
|
let took;
|
|
126450
126524
|
try {
|
|
@@ -128787,7 +128861,7 @@ var ACP_CAPABILITIES = {
|
|
|
128787
128861
|
import { spawn as spawnChild } from "node:child_process";
|
|
128788
128862
|
import { createHash as createHash12 } from "node:crypto";
|
|
128789
128863
|
import { closeSync as closeSync5, createReadStream as createReadStream3, createWriteStream, existsSync as existsSync18, fstatSync as fstatSync4, openSync as openSync5, readdirSync as readdirSync11, readFileSync as readFileSync12, readSync as readSync4, watch as watch3 } from "node:fs";
|
|
128790
|
-
import { chmod as chmod3, lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp3, readdir as readdir8, readFile as readFile4, realpath as realpath7, stat as stat7,
|
|
128864
|
+
import { chmod as chmod3, lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp3, readdir as readdir8, readFile as readFile4, realpath as realpath7, stat as stat7, writeFile as writeFile5 } from "node:fs/promises";
|
|
128791
128865
|
import { homedir as homedir8 } from "node:os";
|
|
128792
128866
|
import { dirname as dirname17, join as join34, resolve as resolve13 } from "node:path";
|
|
128793
128867
|
import { Transform } from "node:stream";
|
|
@@ -129011,14 +129085,7 @@ var realInstallIo = {
|
|
|
129011
129085
|
if (!res.ok || !res.body) throw new InstallFailure("network", `The download answered ${res.status} ${res.statusText}`.trim());
|
|
129012
129086
|
return { total: decodedLength(res.headers), chunks: chunksOf(res.body) };
|
|
129013
129087
|
},
|
|
129014
|
-
|
|
129015
|
-
try {
|
|
129016
|
-
const s = await statfs(dir);
|
|
129017
|
-
return s.bavail * s.bsize;
|
|
129018
|
-
} catch {
|
|
129019
|
-
return null;
|
|
129020
|
-
}
|
|
129021
|
-
}
|
|
129088
|
+
freeBytes: (dir) => Promise.resolve(realOs().files.freeBytesSync(dir))
|
|
129022
129089
|
};
|
|
129023
129090
|
function decodedLength(headers) {
|
|
129024
129091
|
const encoding = headers.get("content-encoding")?.trim().toLowerCase();
|
|
@@ -141391,6 +141458,168 @@ function floorOf(raw) {
|
|
|
141391
141458
|
return raw.trim() !== "" && Number.isInteger(n) && n >= 0 ? n : null;
|
|
141392
141459
|
}
|
|
141393
141460
|
|
|
141461
|
+
// packages/agent-host/src/dev-services/store/store-copy.ts
|
|
141462
|
+
var COPY_KEPT_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
141463
|
+
var FREE_STORE_SIZES = 2;
|
|
141464
|
+
var PARTIAL = ".partial";
|
|
141465
|
+
var UNFINISHED = new RegExp(`\\${PARTIAL}(-journal)?$`);
|
|
141466
|
+
var StoreCopies = class {
|
|
141467
|
+
constructor(os2, db, dbPath2) {
|
|
141468
|
+
this.os = os2;
|
|
141469
|
+
this.db = db;
|
|
141470
|
+
this.dbPath = dbPath2;
|
|
141471
|
+
const { path: path2 } = os2.paths;
|
|
141472
|
+
this.dir = path2.dirname(dbPath2);
|
|
141473
|
+
this.prefix = `${path2.basename(dbPath2, path2.extname(dbPath2))}.before-`;
|
|
141474
|
+
}
|
|
141475
|
+
os;
|
|
141476
|
+
db;
|
|
141477
|
+
dbPath;
|
|
141478
|
+
dir;
|
|
141479
|
+
/** `store.before-` for `store.db`: what every copy's name starts with */
|
|
141480
|
+
prefix;
|
|
141481
|
+
/** Every open: what a stopped host left half written goes, and so does a copy older than 14 days */
|
|
141482
|
+
sweep() {
|
|
141483
|
+
const now = this.os.clock.now();
|
|
141484
|
+
for (const name of this.names()) {
|
|
141485
|
+
if (UNFINISHED.test(name)) {
|
|
141486
|
+
this.remove(name, "a host stopped while writing it");
|
|
141487
|
+
continue;
|
|
141488
|
+
}
|
|
141489
|
+
if (now - this.writtenAt(name) > COPY_KEPT_MS) this.remove(name, "it is older than 14 days");
|
|
141490
|
+
}
|
|
141491
|
+
}
|
|
141492
|
+
/** When the copy was written, by the file's own time; now for one that cannot be read, which is left */
|
|
141493
|
+
writtenAt(name) {
|
|
141494
|
+
try {
|
|
141495
|
+
return this.os.files.statSync(this.at(name)).mtimeMs;
|
|
141496
|
+
} catch {
|
|
141497
|
+
return this.os.clock.now();
|
|
141498
|
+
}
|
|
141499
|
+
}
|
|
141500
|
+
/**
|
|
141501
|
+
* Keeps the store as it is now, before `step` runs. Called outside a transaction (`VACUUM` refuses one) and under
|
|
141502
|
+
* the host's lock, so no other writer runs: `VACUUM INTO` reads one snapshot, the WAL's commits included.
|
|
141503
|
+
*
|
|
141504
|
+
* A copy that cannot be made never keeps the host from starting: the step runs without one, and what is returned
|
|
141505
|
+
* says so.
|
|
141506
|
+
*/
|
|
141507
|
+
copyBefore(step) {
|
|
141508
|
+
const name = `${this.prefix}${step}.db`;
|
|
141509
|
+
if (this.holdsTheStoreAsItIs(name)) {
|
|
141510
|
+
console.error(`[store] ${name} is kept as the copy before step ${step}: an earlier start wrote it, and the store has not changed since`);
|
|
141511
|
+
} else {
|
|
141512
|
+
const skipped = this.write(name, step);
|
|
141513
|
+
if (skipped) return skipped;
|
|
141514
|
+
}
|
|
141515
|
+
try {
|
|
141516
|
+
this.os.files.fsyncDirSync(this.dir);
|
|
141517
|
+
} catch (err) {
|
|
141518
|
+
console.error(`[store] the name of ${name} could not be synced to the disk, so a power cut now could lose the copy: ${errorMessage(err)}`);
|
|
141519
|
+
}
|
|
141520
|
+
return null;
|
|
141521
|
+
}
|
|
141522
|
+
/**
|
|
141523
|
+
* Whether this step's copy is there already and nothing was committed to the store since: a host wrote it and its
|
|
141524
|
+
* step did not commit (the store is still below the step), stopped before the step, in it, or by the step's own
|
|
141525
|
+
* error. It is the copy then, and writing it again would only add a rename over it that can be refused (Windows,
|
|
141526
|
+
* while a backup or a scanner holds the file), with a notice that says there is no copy beside a whole one, and
|
|
141527
|
+
* the copy's time again at every start of a host that stops in a long step.
|
|
141528
|
+
*
|
|
141529
|
+
* By the files' own times, the WAL's included, since a commit reaches the WAL first. A WAL written after the copy
|
|
141530
|
+
* counts only for the commits in it: an open makes an empty one new, and a step stopped before its commit leaves the
|
|
141531
|
+
* part that outgrew SQLite's memory, which SQLite drops. A store written since is copied again: its step failed and
|
|
141532
|
+
* the person went on with the build they had, and the earlier copy lacks that work. A time that wrongly reads as
|
|
141533
|
+
* written since costs one more copy; one that wrongly reads as not (a clock set back, a store put back from a backup
|
|
141534
|
+
* with its old time) keeps a copy without the work since.
|
|
141535
|
+
*/
|
|
141536
|
+
holdsTheStoreAsItIs(name) {
|
|
141537
|
+
const stat13 = (path2) => this.os.files.statSync(path2, { throwIfNoEntry: false });
|
|
141538
|
+
try {
|
|
141539
|
+
const copy = stat13(this.at(name));
|
|
141540
|
+
if (!copy?.isFile() || (stat13(this.dbPath)?.mtimeMs ?? Infinity) > copy.mtimeMs) return false;
|
|
141541
|
+
const wal = stat13(`${this.dbPath}-wal`);
|
|
141542
|
+
return !wal?.size || wal.mtimeMs <= copy.mtimeMs || !this.walHoldsCommits();
|
|
141543
|
+
} catch {
|
|
141544
|
+
return false;
|
|
141545
|
+
}
|
|
141546
|
+
}
|
|
141547
|
+
/**
|
|
141548
|
+
* Whether the WAL holds a commit, copied back to the store or not. Asked with a checkpoint that waits for nobody,
|
|
141549
|
+
* which says it without reading the WAL's frames here: what it copies back is in the store either way.
|
|
141550
|
+
*/
|
|
141551
|
+
walHoldsCommits() {
|
|
141552
|
+
const answer = this.db.pragma("wal_checkpoint(PASSIVE)");
|
|
141553
|
+
const row = Array.isArray(answer) ? answer[0] : void 0;
|
|
141554
|
+
return !(isObj(row) && row.log === 0);
|
|
141555
|
+
}
|
|
141556
|
+
/** Writes the copy `name` from the store's own connection, or says why not, with nothing unfinished left behind */
|
|
141557
|
+
write(name, step) {
|
|
141558
|
+
const { files: files2, clock: clock4 } = this.os;
|
|
141559
|
+
const partial2 = this.at(name + PARTIAL);
|
|
141560
|
+
const t02 = clock4.now();
|
|
141561
|
+
try {
|
|
141562
|
+
const store2 = files2.statSync(this.dbPath);
|
|
141563
|
+
const size2 = store2.size + (files2.statSync(`${this.dbPath}-wal`, { throwIfNoEntry: false })?.size ?? 0);
|
|
141564
|
+
const needed = FREE_STORE_SIZES * size2;
|
|
141565
|
+
const free = files2.freeBytesSync(this.dir);
|
|
141566
|
+
if (free !== null && free < needed) {
|
|
141567
|
+
console.error(
|
|
141568
|
+
`[store] no copy before step ${step}: the disk has ${bytesText(free)} free and the copy is made with ${bytesText(needed)} (twice the store); the step runs without one`
|
|
141569
|
+
);
|
|
141570
|
+
return { step, reason: "low_disk", free, needed };
|
|
141571
|
+
}
|
|
141572
|
+
console.error(`[store] copying the store (${bytesText(size2)}) to ${this.at(name)} before step ${step}, which an older Centralu cannot read past`);
|
|
141573
|
+
const mode = store2.mode & 511;
|
|
141574
|
+
const made = files2.openSync(partial2, "wx", mode);
|
|
141575
|
+
try {
|
|
141576
|
+
if (this.os.traits.modesGuardFiles) files2.fchmodSync(made, mode);
|
|
141577
|
+
} finally {
|
|
141578
|
+
files2.closeSync(made);
|
|
141579
|
+
}
|
|
141580
|
+
this.db.prepare("VACUUM INTO ?").run(partial2);
|
|
141581
|
+
const written = files2.openSync(partial2, "r+");
|
|
141582
|
+
try {
|
|
141583
|
+
files2.fsyncSync(written);
|
|
141584
|
+
} finally {
|
|
141585
|
+
files2.closeSync(written);
|
|
141586
|
+
}
|
|
141587
|
+
files2.renameSync(partial2, this.at(name));
|
|
141588
|
+
} catch (err) {
|
|
141589
|
+
console.error(`[store] no copy before step ${step}: ${errorMessage(err)}; the step runs without one`);
|
|
141590
|
+
for (const left of this.names()) if (UNFINISHED.test(left)) this.remove(left, "the copy failed");
|
|
141591
|
+
return { step, reason: "failed" };
|
|
141592
|
+
}
|
|
141593
|
+
console.error(`[store] copied in ${clock4.now() - t02}ms; the copy is deleted after 14 days`);
|
|
141594
|
+
return null;
|
|
141595
|
+
}
|
|
141596
|
+
at(name) {
|
|
141597
|
+
return this.os.paths.path.join(this.dir, name);
|
|
141598
|
+
}
|
|
141599
|
+
/** The copies beside the store, whole and unfinished: `<prefix><step>.db` with a step number and nothing else */
|
|
141600
|
+
names() {
|
|
141601
|
+
try {
|
|
141602
|
+
return this.os.files.readdirSync(this.dir).filter((name) => {
|
|
141603
|
+
const whole = name.replace(UNFINISHED, "");
|
|
141604
|
+
return whole.startsWith(this.prefix) && /^\d+\.db$/.test(whole.slice(this.prefix.length));
|
|
141605
|
+
});
|
|
141606
|
+
} catch (err) {
|
|
141607
|
+
console.error(`[store] could not look for copies of the store in ${this.dir}: ${errorMessage(err)}`);
|
|
141608
|
+
return [];
|
|
141609
|
+
}
|
|
141610
|
+
}
|
|
141611
|
+
/** A copy that cannot be deleted is said and left: the next open tries again */
|
|
141612
|
+
remove(name, why2) {
|
|
141613
|
+
try {
|
|
141614
|
+
if (!this.os.files.existsSync(this.at(name))) return;
|
|
141615
|
+
this.os.files.rmSync(this.at(name), { force: true });
|
|
141616
|
+
console.error(`[store] deleted ${name}: ${why2}`);
|
|
141617
|
+
} catch (err) {
|
|
141618
|
+
console.error(`[store] could not delete ${name} (${why2}): ${errorMessage(err)}`);
|
|
141619
|
+
}
|
|
141620
|
+
}
|
|
141621
|
+
};
|
|
141622
|
+
|
|
141394
141623
|
// packages/agent-host/src/dev-services/store/vacuum.ts
|
|
141395
141624
|
var VACUUM_FREE_BYTES = 16 * 1024 * 1024;
|
|
141396
141625
|
var VACUUM_OWED_KEY = "vacuum_owed";
|
|
@@ -141443,6 +141672,8 @@ var MigrationRunner = class extends ReaderGate {
|
|
|
141443
141672
|
* cost quietly grows, and nobody notices. Counting it lets a test ask.
|
|
141444
141673
|
*/
|
|
141445
141674
|
migrationsRun = 0;
|
|
141675
|
+
/** A step that breaks older readers ran at this open without a copy of the store before it (#2304), and why; null otherwise */
|
|
141676
|
+
copySkipped = null;
|
|
141446
141677
|
/**
|
|
141447
141678
|
* The migration runner (E-0).
|
|
141448
141679
|
*
|
|
@@ -141483,9 +141714,16 @@ var MigrationRunner = class extends ReaderGate {
|
|
|
141483
141714
|
const deferred = new Set(this.storedDeferred());
|
|
141484
141715
|
const owed = steps.filter((s) => s.to <= current && deferred.has(s.to)).map((s) => s.to);
|
|
141485
141716
|
this.sayUnreadableDeferred();
|
|
141717
|
+
const copies = current > 0 && this.dbPath !== ":memory:" ? new StoreCopies(this.os, this.db, this.dbPath) : null;
|
|
141718
|
+
copies?.sweep();
|
|
141719
|
+
let copied = false;
|
|
141486
141720
|
for (const step of steps) {
|
|
141487
141721
|
const due2 = current < step.to || deferred.has(step.to);
|
|
141488
141722
|
if (!due2) continue;
|
|
141723
|
+
if (copies && step.breaksOlderReaders && !copied) {
|
|
141724
|
+
this.copySkipped = copies.copyBefore(step.to);
|
|
141725
|
+
copied = true;
|
|
141726
|
+
}
|
|
141489
141727
|
floor = this.runStep(step, floor, () => {
|
|
141490
141728
|
if (step.to > this.schemaVersion) this.db.pragma(`user_version = ${step.to}`);
|
|
141491
141729
|
if (deferred.delete(step.to)) this.writeDeferred([...deferred]);
|
|
@@ -143800,6 +144038,36 @@ var StepsV75 = class extends MigrationRange {
|
|
|
143800
144038
|
* it opens the store and serves it as before. The tables stay for it, unread by this build, and go in the next step.
|
|
143801
144039
|
*/
|
|
143802
144040
|
run: () => this.moveThreadMail()
|
|
144041
|
+
},
|
|
144042
|
+
{
|
|
144043
|
+
to: 76,
|
|
144044
|
+
breaksOlderReaders: true,
|
|
144045
|
+
minReader: 75,
|
|
144046
|
+
/**
|
|
144047
|
+
* What nothing reads any more goes (#2258, docs/plans/mailbox.md M7): the thread tables of v61 (`mail_threads`, `mail_participants`,
|
|
144048
|
+
* `mail_blockers`, `mail_messages`, `mail_receipts`), the index that found a thread's open turn (`mail_turns_open`), the three tables
|
|
144049
|
+
* of owed work from before mail (`report_marks`, `delegated_turns`, `queued_requests`) and `sessions.mail_args`. Step 74 made tasks of
|
|
144050
|
+
* the owed work and step 75 moved the pending thread mail, so what is deleted here is history: thread messages that were handled, or
|
|
144051
|
+
* were older than step 75's 180 days, are kept only in the copy of the store the open that runs this step makes, for its 14 days,
|
|
144052
|
+
* and nowhere when that copy could not be made (rule 5 above `migrationSteps`; the copy is named after that open's first breaking
|
|
144053
|
+
* step, so `store.before-75.db` from version 74). No vacuum, so the step is not `heavy`: later writes reuse the pages the tables held.
|
|
144054
|
+
*
|
|
144055
|
+
* One release after step 75, whose build was the first to name none of these (rule 2 above `migrationSteps`). `schema.sql` creates
|
|
144056
|
+
* none of them, so a new store and a migrated one end with the same tables.
|
|
144057
|
+
*
|
|
144058
|
+
* **Breaks the build of v74 (beta.70 to beta.72): the floor goes to 75.** That build reads the thread tables at every start and for the
|
|
144059
|
+
* lines before a moved message, deletes from `report_marks` at every start and from two of the thread tables when a session is
|
|
144060
|
+
* purged; it is refused (`StoreTooNewError`). The build of v75 opens the store as it is. No release read or wrote `sessions.mail_args`:
|
|
144061
|
+
* the second version of the mail tool it was added for was not built (M3b).
|
|
144062
|
+
*/
|
|
144063
|
+
run: () => {
|
|
144064
|
+
for (const table of ["mail_blockers", "mail_participants", "mail_receipts", "mail_messages", "mail_threads", "report_marks", "delegated_turns", "queued_requests"]) {
|
|
144065
|
+
this.db.exec(`DROP TABLE IF EXISTS ${table}`);
|
|
144066
|
+
}
|
|
144067
|
+
this.db.exec(`DROP INDEX IF EXISTS mail_turns_open`);
|
|
144068
|
+
const cols = this.db.prepare(`PRAGMA table_info(sessions)`).all();
|
|
144069
|
+
if (cols.some((c) => c.name === "mail_args")) this.db.exec(`ALTER TABLE sessions DROP COLUMN mail_args`);
|
|
144070
|
+
}
|
|
143803
144071
|
}
|
|
143804
144072
|
];
|
|
143805
144073
|
}
|
|
@@ -144872,9 +145140,10 @@ function resolveSchemaPath() {
|
|
|
144872
145140
|
}
|
|
144873
145141
|
var SCHEMA_PATH = resolveSchemaPath();
|
|
144874
145142
|
var Store = class extends MigrationRunner {
|
|
144875
|
-
constructor(dbPath2 = ":memory:") {
|
|
145143
|
+
constructor(dbPath2 = ":memory:", os2 = realOs()) {
|
|
144876
145144
|
super();
|
|
144877
145145
|
this.dbPath = dbPath2;
|
|
145146
|
+
this.os = os2;
|
|
144878
145147
|
const path2 = dbPath2;
|
|
144879
145148
|
this.db = new Database3(path2);
|
|
144880
145149
|
this.projects = new ProjectRecords(this.db);
|
|
@@ -144909,6 +145178,7 @@ var Store = class extends MigrationRunner {
|
|
|
144909
145178
|
this.checkpoint();
|
|
144910
145179
|
}
|
|
144911
145180
|
dbPath;
|
|
145181
|
+
os;
|
|
144912
145182
|
db;
|
|
144913
145183
|
/*
|
|
144914
145184
|
* The records, one module per concept in `store/`, each holding its queries and the comments that say what they do.
|
|
@@ -148276,7 +148546,7 @@ var SessionManager = class {
|
|
|
148276
148546
|
}
|
|
148277
148547
|
});
|
|
148278
148548
|
const compactSetting = () => autoCompactOf(this.prefs.uiPreferences());
|
|
148279
|
-
const compactNotice = (id3, text3) => this.events.onEvent({ type: "notice", sessionId: id3, level: "info", from: "Centralu", label: "
|
|
148549
|
+
const compactNotice = (id3, text3, label) => this.events.onEvent({ type: "notice", sessionId: id3, level: "info", from: "Centralu", label, audience: "centralu", text: text3 });
|
|
148280
148550
|
this.selfCompaction = new SelfCompaction({
|
|
148281
148551
|
sessions: () => this.listSessions(),
|
|
148282
148552
|
session: (id3) => this.meta.get(id3),
|
|
@@ -148292,7 +148562,7 @@ var SessionManager = class {
|
|
|
148292
148562
|
},
|
|
148293
148563
|
send: (id3, text3) => this.events.sendCompact(id3, text3),
|
|
148294
148564
|
// An ordinary turn of the session's own, in Centralu's channel with no user row; a session with no process is woken for it
|
|
148295
|
-
sendThen: (id3, text3, line) => this.events.deliverMail(id3, { text: text3, quiet: false, line, label: "
|
|
148565
|
+
sendThen: (id3, text3, line, label) => this.events.deliverMail(id3, { text: text3, quiet: false, line, label, audience: "centralu" }, { leaving: () => this.tenure.disposing, atRest: () => this.mail.takesTurn(id3) }),
|
|
148296
148566
|
// What waits to start a turn behind the compact turn: what the tool holds (a tool that cannot say answers null) and mail waiting for the session
|
|
148297
148567
|
queued: (id3) => {
|
|
148298
148568
|
const held3 = this.handles.get(id3)?.queuedInputs?.();
|
|
@@ -148541,8 +148811,10 @@ var SessionManager = class {
|
|
|
148541
148811
|
);
|
|
148542
148812
|
for (const s of leavesFirst) await this.trash.trashSession(s.id).catch(() => {
|
|
148543
148813
|
});
|
|
148544
|
-
const
|
|
148814
|
+
const row = this.projectRegistry.projectRow(projectId);
|
|
148815
|
+
const root3 = row?.path;
|
|
148545
148816
|
this.store.trash.deleteProject(projectId);
|
|
148817
|
+
if (row) this.emit({ type: "projects_changed" });
|
|
148546
148818
|
this.apps.appsHub?.rt.forgetProject(projectId);
|
|
148547
148819
|
this.files.forgetProject(projectId, root3);
|
|
148548
148820
|
}
|
|
@@ -150128,7 +150400,7 @@ var MessageService = class {
|
|
|
150128
150400
|
const kept = turnStarts ? candidates.filter((c) => !isWork(c) || groupOf(c) === picked) : candidates;
|
|
150129
150401
|
const workMessage = !turnStarts || opts.joining ? null : handedOn ?? (toAssistant ? kept.find((c) => c.request)?.message.id ?? null : picked);
|
|
150130
150402
|
const items = [];
|
|
150131
|
-
const
|
|
150403
|
+
const given = [];
|
|
150132
150404
|
let wake = false;
|
|
150133
150405
|
let immediate = false;
|
|
150134
150406
|
let needsReply = false;
|
|
@@ -150137,10 +150409,11 @@ var MessageService = class {
|
|
|
150137
150409
|
if (message.urgent || isPerson(message.sender)) immediate = true;
|
|
150138
150410
|
if (message.kind === "message" && message.needsReply) needsReply = true;
|
|
150139
150411
|
const relation = this.relation(recipient, message);
|
|
150140
|
-
|
|
150412
|
+
given.push({ threadId: message.rootId, messageId: message.id, relation });
|
|
150141
150413
|
items.push(this.frameItem(recipient, message, relation, down && row.deliveredAt === null, row.lastError === "maybe_repeated"));
|
|
150142
150414
|
}
|
|
150143
150415
|
const frame = buildMessageFrame(items, this.opts.calls?.(recipient));
|
|
150416
|
+
const listed2 = given.filter((l) => frame.shown.includes(l.messageId));
|
|
150144
150417
|
return {
|
|
150145
150418
|
text: frame.text,
|
|
150146
150419
|
messageIds: frame.shown,
|
|
@@ -150149,7 +150422,8 @@ var MessageService = class {
|
|
|
150149
150422
|
wake,
|
|
150150
150423
|
immediate,
|
|
150151
150424
|
needsReply,
|
|
150152
|
-
line:
|
|
150425
|
+
line: mailLine(listed2).line,
|
|
150426
|
+
listed: listed2,
|
|
150153
150427
|
heldBack,
|
|
150154
150428
|
workMessage,
|
|
150155
150429
|
asker: turnStarts && toAssistant ? picked : null
|
|
@@ -153465,6 +153739,15 @@ function hostMail(store2, sessions, opts) {
|
|
|
153465
153739
|
} catch (e) {
|
|
153466
153740
|
console.error(`[mail] telling the senders of the turns the last host's end cut failed: ${errorMessage(e)}`);
|
|
153467
153741
|
}
|
|
153742
|
+
try {
|
|
153743
|
+
const skipped = store2.copySkipped;
|
|
153744
|
+
if (skipped) {
|
|
153745
|
+
const short2 = skipped.reason === "low_disk" ? { free: bytesText(skipped.free), needed: bytesText(skipped.needed) } : null;
|
|
153746
|
+
service.notice(PERSON, { body: WARNING_TEXT.noStoreCopy(short2), facts: { storeCopySkipped: { step: skipped.step, reason: skipped.reason } }, dedupeKey: `storecopy:${skipped.step}` });
|
|
153747
|
+
}
|
|
153748
|
+
} catch (e) {
|
|
153749
|
+
console.error(`[mail] telling the person that the store was changed without a copy failed: ${errorMessage(e)}`);
|
|
153750
|
+
}
|
|
153468
153751
|
delivery.start();
|
|
153469
153752
|
for (const s of sessions.listSessions()) sessions.settleAtRest?.(s.id);
|
|
153470
153753
|
}
|
|
@@ -153669,8 +153952,13 @@ var Qualifier = class {
|
|
|
153669
153952
|
if ("projectId" in p) out.projectId = this.maybeId(p.projectId);
|
|
153670
153953
|
if (typeof p.instanceId === "string") out.instanceId = this.id(p.instanceId);
|
|
153671
153954
|
if (isObj(p.detail)) out.detail = this.approvalDetail(p.detail);
|
|
153955
|
+
if (p.type === "notice" && "mail" in p) out.mail = this.delivered(p.mail);
|
|
153672
153956
|
return out;
|
|
153673
153957
|
}
|
|
153958
|
+
/** A mail line's messages (#2333): each chain qualified, so the line opens it on the machine it is on (`mail.thread`). The message id is every host's */
|
|
153959
|
+
delivered(mail) {
|
|
153960
|
+
return Array.isArray(mail) ? mail.map((d2) => isObj(d2) ? { ...d2, threadId: this.maybeId(d2.threadId) } : d2) : mail;
|
|
153961
|
+
}
|
|
153674
153962
|
/** `ApprovalDetail`: the kinds that name a project */
|
|
153675
153963
|
approvalDetail(d2) {
|
|
153676
153964
|
if (!isObj(d2)) return d2;
|
|
@@ -153863,6 +154151,9 @@ var Qualifier = class {
|
|
|
153863
154151
|
}
|
|
153864
154152
|
case "handoff":
|
|
153865
154153
|
return { ...base2, fromSessionId: this.maybeId(e.fromSessionId) };
|
|
154154
|
+
// A mail line live, as `payload` qualifies it stored
|
|
154155
|
+
case "notice":
|
|
154156
|
+
return "mail" in e ? { ...base2, mail: this.delivered(e.mail) } : base2;
|
|
153866
154157
|
case "session_owner":
|
|
153867
154158
|
return { ...base2, askedBy: (sid !== void 0 ? this.ownerOf?.(sid) : void 0) ?? this.maybeId(e.askedBy), parentSessionId: this.maybeId(e.parentSessionId) };
|
|
153868
154159
|
case "approval_request":
|
|
@@ -159479,6 +159770,92 @@ async function askHubAuto(call2, allowed) {
|
|
|
159479
159770
|
// packages/agent-host/src/links/linked-machine-connection.ts
|
|
159480
159771
|
import { randomBytes as randomBytes15 } from "node:crypto";
|
|
159481
159772
|
|
|
159773
|
+
// packages/agent-host/src/links/pending-project-deletes.ts
|
|
159774
|
+
var TRIES = 5;
|
|
159775
|
+
var PendingProjectDeletes = class {
|
|
159776
|
+
constructor(host) {
|
|
159777
|
+
this.host = host;
|
|
159778
|
+
}
|
|
159779
|
+
host;
|
|
159780
|
+
/** The failures in a row of each delete asked in this run, by project */
|
|
159781
|
+
failed = /* @__PURE__ */ new Map();
|
|
159782
|
+
/** This machine's, oldest first */
|
|
159783
|
+
owed() {
|
|
159784
|
+
return this.host.list.read().filter((d2) => d2.machine === this.host.machine.id);
|
|
159785
|
+
}
|
|
159786
|
+
drop(keeps) {
|
|
159787
|
+
const all = this.host.list.read();
|
|
159788
|
+
const left = all.filter((d2) => d2.machine !== this.host.machine.id || keeps(d2));
|
|
159789
|
+
if (left.length !== all.length) this.host.list.write(left);
|
|
159790
|
+
}
|
|
159791
|
+
/** Whether a delete is still owed: one the machine failed is asked again while the link holds (`readLists`) */
|
|
159792
|
+
get any() {
|
|
159793
|
+
return this.owed().length > 0;
|
|
159794
|
+
}
|
|
159795
|
+
/** Whether one is owed that the machine was not asked for yet: kept while it was being asked for the others */
|
|
159796
|
+
get unasked() {
|
|
159797
|
+
return this.owed().some((d2) => !this.failed.has(d2.projectId));
|
|
159798
|
+
}
|
|
159799
|
+
/**
|
|
159800
|
+
* Keeps the delete of `projectId` (the machine's own id) and takes the project and its sessions out of the hub's
|
|
159801
|
+
* lists at once. Asked twice, it is kept once
|
|
159802
|
+
*/
|
|
159803
|
+
keep(projectId) {
|
|
159804
|
+
const { machine, mirror } = this.host;
|
|
159805
|
+
const id3 = machine.id;
|
|
159806
|
+
const projects = mirror.read(id3, "projects") ?? [];
|
|
159807
|
+
const project2 = projects.find((p) => isObj(p) && p.id === projectId);
|
|
159808
|
+
const owed = this.owed().find((d2) => d2.projectId === projectId);
|
|
159809
|
+
const name = owed?.name ?? (isObj(project2) && typeof project2.name === "string" ? project2.name : projectId);
|
|
159810
|
+
if (!owed) this.host.list.write([...this.host.list.read(), { machine: id3, projectId, name, at: Date.now() }]);
|
|
159811
|
+
for (const s of mirror.read(id3, "sessions") ?? []) {
|
|
159812
|
+
if (isObj(s) && s.projectId === projectId && typeof s.id === "string") this.host.heard({ type: "session_deleted", sessionId: s.id });
|
|
159813
|
+
}
|
|
159814
|
+
if (project2 !== void 0) mirror.replace(id3, "projects", projects.filter((p) => p !== project2));
|
|
159815
|
+
this.host.heard({ type: "projects_changed" });
|
|
159816
|
+
this.host.log(`[links] ${machine.name}: project "${name}" was deleted here while it is away; it is deleted there when the link is back`);
|
|
159817
|
+
}
|
|
159818
|
+
/**
|
|
159819
|
+
* Asks the machine for every delete owed, at its hello and again while one it failed stays owed. `linkUp` says whether
|
|
159820
|
+
* the link still holds after a call failed: an answer that never came over a link that went is no try
|
|
159821
|
+
*/
|
|
159822
|
+
async apply(call2, linkUp) {
|
|
159823
|
+
const { name } = this.host.machine;
|
|
159824
|
+
const log = (line) => this.host.log(line);
|
|
159825
|
+
for (const d2 of this.owed()) {
|
|
159826
|
+
try {
|
|
159827
|
+
await call2("projects.delete", { projectId: d2.projectId });
|
|
159828
|
+
log(`[links] ${name}: deleted project "${d2.name}", as asked here while it was away`);
|
|
159829
|
+
if (this.failed.has(d2.projectId)) this.host.heard({ type: "projects_changed" });
|
|
159830
|
+
} catch (err) {
|
|
159831
|
+
if (!linkUp()) {
|
|
159832
|
+
log(`[links] ${name}: the link went before it answered the delete of project "${d2.name}"; it is asked again when the link is back`);
|
|
159833
|
+
return;
|
|
159834
|
+
}
|
|
159835
|
+
const failed5 = (this.failed.get(d2.projectId) ?? 0) + 1;
|
|
159836
|
+
const why2 = older2(err) ? `${name} runs an older Centralu, which cannot do this` : errorMessage(err);
|
|
159837
|
+
if (!older2(err) && failed5 < TRIES) {
|
|
159838
|
+
this.failed.set(d2.projectId, failed5);
|
|
159839
|
+
log(`[links] ${name}: could not delete project "${d2.name}", as asked here while it was away: ${why2}. It is asked again`);
|
|
159840
|
+
continue;
|
|
159841
|
+
}
|
|
159842
|
+
log(`[links] ${name}: could not delete project "${d2.name}", as asked here while it was away: ${why2}. The project is listed again`);
|
|
159843
|
+
this.host.tell(
|
|
159844
|
+
`Couldn't delete "${d2.name}" on ${name}, so it's back in the list. ${older2(err) ? `Update Centralu on ${name}, then delete it again.` : "Delete it again to try once more."}`,
|
|
159845
|
+
`project-delete:${d2.machine}:${d2.projectId}:${d2.at}`
|
|
159846
|
+
);
|
|
159847
|
+
}
|
|
159848
|
+
this.failed.delete(d2.projectId);
|
|
159849
|
+
this.drop((x) => x.projectId !== d2.projectId);
|
|
159850
|
+
}
|
|
159851
|
+
}
|
|
159852
|
+
/** The machine was removed from the hub: nothing is owed to it */
|
|
159853
|
+
forget() {
|
|
159854
|
+
this.failed.clear();
|
|
159855
|
+
this.drop(() => false);
|
|
159856
|
+
}
|
|
159857
|
+
};
|
|
159858
|
+
|
|
159482
159859
|
// packages/agent-host/src/links/remote-client.ts
|
|
159483
159860
|
var MAX_INCOMING_CALLS = 16;
|
|
159484
159861
|
var DEFAULT_CALL_TIMEOUT_MS = 2e5;
|
|
@@ -160026,6 +160403,7 @@ function hiddenKind(s) {
|
|
|
160026
160403
|
var RETRY_MS2 = [2e3, 5 * 6e4];
|
|
160027
160404
|
var LINK_REDIALS = 5;
|
|
160028
160405
|
var STABLE_MS = 6e4;
|
|
160406
|
+
var DELETE_RETRY_MS = 15e3;
|
|
160029
160407
|
var RESTARTS = { max: 3, windowMs: 10 * 6e4 };
|
|
160030
160408
|
var KEEPS_TRYING = "reconnecting";
|
|
160031
160409
|
var WAITS_FOR_PERSON = "press Connect to try again";
|
|
@@ -160048,6 +160426,14 @@ var LinkedMachineConnection = class {
|
|
|
160048
160426
|
this.tunnel = tunnel;
|
|
160049
160427
|
this.deps = deps;
|
|
160050
160428
|
this.q = new Qualifier(record2.id, record2.slot, deps.ownerOf);
|
|
160429
|
+
this.pendingDeletes = new PendingProjectDeletes({
|
|
160430
|
+
machine: this,
|
|
160431
|
+
list: deps.projectDeletes,
|
|
160432
|
+
mirror: deps.mirror,
|
|
160433
|
+
heard: (event) => this.onEvent(event),
|
|
160434
|
+
tell: deps.tellPerson,
|
|
160435
|
+
log: (line) => deps.log?.(line)
|
|
160436
|
+
});
|
|
160051
160437
|
for (const s of deps.mirror.read(record2.id, "sessions") ?? []) this.classify(s);
|
|
160052
160438
|
this.lastConnectedAt = record2.lastConnectedAt ?? null;
|
|
160053
160439
|
for (const [credential, at2] of Object.entries(record2.revoked ?? {})) {
|
|
@@ -160061,6 +160447,8 @@ var LinkedMachineConnection = class {
|
|
|
160061
160447
|
tunnel;
|
|
160062
160448
|
deps;
|
|
160063
160449
|
q;
|
|
160450
|
+
/** The projects the person deleted while this machine could not be asked, deleted there at its next hello (#2330) */
|
|
160451
|
+
pendingDeletes;
|
|
160064
160452
|
status = "connecting";
|
|
160065
160453
|
error = null;
|
|
160066
160454
|
versions = null;
|
|
@@ -160124,6 +160512,8 @@ var LinkedMachineConnection = class {
|
|
|
160124
160512
|
attempt = 0;
|
|
160125
160513
|
/** Starts the backoff over once the host that last said hello has stayed up `STABLE_MS` */
|
|
160126
160514
|
stableTimer;
|
|
160515
|
+
/** The next try of a delete the machine failed (`readLists`) */
|
|
160516
|
+
deleteRetryTimer;
|
|
160127
160517
|
/** When the link started a host there by itself, within the last `RESTARTS.windowMs` (#1143) */
|
|
160128
160518
|
autoStarts = [];
|
|
160129
160519
|
/**
|
|
@@ -161121,22 +161511,42 @@ var LinkedMachineConnection = class {
|
|
|
161121
161511
|
this.client = client;
|
|
161122
161512
|
client.connect();
|
|
161123
161513
|
}
|
|
161514
|
+
/**
|
|
161515
|
+
* The machine's lists, into the mirror. What the person deleted here while it was away goes first (#2330), so the lists
|
|
161516
|
+
* read after are without it; and again at once when a delete was kept while they were being read. Nothing awaits
|
|
161517
|
+
* between the lists and `connected` (`onHello`), so no delete waits unasked for a machine that can be asked. A delete the
|
|
161518
|
+
* machine failed stays owed (pending-project-deletes.ts): it is asked again, and the lists read again, after a pause
|
|
161519
|
+
* for as long as this link holds; the next hello asks it otherwise
|
|
161520
|
+
*/
|
|
161521
|
+
async readLists(client) {
|
|
161522
|
+
clearTimeout(this.deleteRetryTimer);
|
|
161523
|
+
do {
|
|
161524
|
+
await this.pendingDeletes.apply((method, params) => client.call(method, params), () => client.connected);
|
|
161525
|
+
try {
|
|
161526
|
+
await Promise.all(
|
|
161527
|
+
["sessions", "projects"].map(async (kind) => {
|
|
161528
|
+
const list2 = await client.call(kind === "sessions" ? "sessions.list" : "projects.list", {});
|
|
161529
|
+
if (Array.isArray(list2)) this.observe(kind, list2);
|
|
161530
|
+
})
|
|
161531
|
+
);
|
|
161532
|
+
} catch (err) {
|
|
161533
|
+
this.deps.log?.(`[links] ${this.name}: could not read its lists after connecting: ${err.message}`);
|
|
161534
|
+
}
|
|
161535
|
+
} while (this.client === client && client.connected && this.pendingDeletes.unasked);
|
|
161536
|
+
if (this.client !== client || !client.connected || !this.pendingDeletes.any) return;
|
|
161537
|
+
clearTimeout(this.deleteRetryTimer);
|
|
161538
|
+
this.deleteRetryTimer = setTimeout(() => {
|
|
161539
|
+
if (this.client === client && client.connected) void this.readLists(client);
|
|
161540
|
+
}, this.deps.deleteRetryMs ?? DELETE_RETRY_MS);
|
|
161541
|
+
this.deleteRetryTimer.unref?.();
|
|
161542
|
+
}
|
|
161124
161543
|
async onHello(client, h) {
|
|
161125
161544
|
if (this.client !== client) return;
|
|
161126
161545
|
if (h.build) {
|
|
161127
161546
|
const v = this.check({ version: h.build.version ?? this.versions?.remote.version ?? "unknown", protocolVersion: h.build.protocolVersion, dev: h.build.commit === "dev" });
|
|
161128
161547
|
if (!mayConnect(v)) return;
|
|
161129
161548
|
}
|
|
161130
|
-
|
|
161131
|
-
await Promise.all(
|
|
161132
|
-
["sessions", "projects"].map(async (kind) => {
|
|
161133
|
-
const list2 = await client.call(kind === "sessions" ? "sessions.list" : "projects.list", {});
|
|
161134
|
-
if (Array.isArray(list2)) this.observe(kind, list2);
|
|
161135
|
-
})
|
|
161136
|
-
);
|
|
161137
|
-
} catch (err) {
|
|
161138
|
-
this.deps.log?.(`[links] ${this.name}: could not read its lists after connecting: ${err.message}`);
|
|
161139
|
-
}
|
|
161549
|
+
await this.readLists(client);
|
|
161140
161550
|
if (this.client !== client) return;
|
|
161141
161551
|
clearTimeout(this.stableTimer);
|
|
161142
161552
|
this.stableTimer = setTimeout(() => {
|
|
@@ -162058,6 +162468,7 @@ var Links = class {
|
|
|
162058
162468
|
await m.stop();
|
|
162059
162469
|
this.deps.registry.remove(id3);
|
|
162060
162470
|
this.deps.mirror.forget(id3);
|
|
162471
|
+
m.pendingDeletes.forget();
|
|
162061
162472
|
this.deps.broadcast({ type: "machine_resync", machineId: id3 });
|
|
162062
162473
|
}
|
|
162063
162474
|
async stop() {
|
|
@@ -162996,7 +163407,13 @@ var Router = class {
|
|
|
162996
163407
|
throw rpcError(`A script's message is not sent to ${m.name}: Centralu there would store it as the person's. Run the script on ${m.name} instead.`);
|
|
162997
163408
|
}
|
|
162998
163409
|
if (!m.reachable && ctx === void 0) await m.reachForCall?.();
|
|
162999
|
-
if (!m.reachable)
|
|
163410
|
+
if (!m.reachable) {
|
|
163411
|
+
if (method === "projects.delete" && m.pendingDeletes && isObj(params) && typeof params.projectId === "string") {
|
|
163412
|
+
m.pendingDeletes.keep(params.projectId);
|
|
163413
|
+
return { ok: true };
|
|
163414
|
+
}
|
|
163415
|
+
throw new MachineUnreachableError(m, ctx?.window === true);
|
|
163416
|
+
}
|
|
163000
163417
|
return callOn(m, method, params, ctx);
|
|
163001
163418
|
}
|
|
163002
163419
|
async byKey(method, params, key2, route, ctx) {
|
|
@@ -163384,7 +163801,7 @@ function tunnelsFor(store2, log) {
|
|
|
163384
163801
|
}
|
|
163385
163802
|
function linkDepsFor(store2, rest) {
|
|
163386
163803
|
const log = (line) => rest.log?.(stamped(line));
|
|
163387
|
-
return { ...rest, log, mirror: storeMirror(store2), registry: storeRegistry(store2), tunnelFor: tunnelsFor(store2, log) };
|
|
163804
|
+
return { ...rest, log, mirror: storeMirror(store2), registry: storeRegistry(store2), tunnelFor: tunnelsFor(store2, log), projectDeletes: storeProjectDeletes(store2) };
|
|
163388
163805
|
}
|
|
163389
163806
|
var kindOf3 = (k2) => k2 === "sessions" ? "session" : "project";
|
|
163390
163807
|
var withIds = (list2) => list2.filter((x) => isObj(x) && typeof x.id === "string");
|
|
@@ -163409,6 +163826,14 @@ function storeProjectOrder(store2) {
|
|
|
163409
163826
|
write: (orderedIds) => store2.settings.setAppSetting(PROJECT_ORDER_KEY, JSON.stringify(orderedIds))
|
|
163410
163827
|
};
|
|
163411
163828
|
}
|
|
163829
|
+
var PENDING_PROJECT_DELETES_KEY = "hub.pendingProjectDeletes";
|
|
163830
|
+
function storeProjectDeletes(store2) {
|
|
163831
|
+
return listSetting(
|
|
163832
|
+
store2.settings,
|
|
163833
|
+
PENDING_PROJECT_DELETES_KEY,
|
|
163834
|
+
(x) => typeof x.machine === "string" && typeof x.projectId === "string" && typeof x.name === "string" && typeof x.at === "number"
|
|
163835
|
+
);
|
|
163836
|
+
}
|
|
163412
163837
|
|
|
163413
163838
|
// packages/agent-host/src/links/linked-hubs.ts
|
|
163414
163839
|
var MAIL_MS = 3e4;
|
|
@@ -164145,7 +164570,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
|
|
|
164145
164570
|
console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
|
|
164146
164571
|
process.exit(1);
|
|
164147
164572
|
}) : launch.token;
|
|
164148
|
-
var BUILD = true ? "
|
|
164573
|
+
var BUILD = true ? "d0e9e70" : "dev";
|
|
164149
164574
|
var { values } = parseArgs({
|
|
164150
164575
|
options: {
|
|
164151
164576
|
port: { type: "string", default: "5175" },
|
|
@@ -164484,6 +164909,8 @@ var links = new Links(linkDepsFor(store, {
|
|
|
164484
164909
|
// A machine that took this hub's mail at a connect hears what became of mail that crossed while it was away (#2067 review); the tasks it says never arrived are settled (#2289)
|
|
164485
164910
|
onOfferAnswered: (machineId, lacks) => hostMailbox.across.offerAnswered(machineId, lacks),
|
|
164486
164911
|
openTasks: (machineId) => hostMailbox.across.openTasksTo(machineId),
|
|
164912
|
+
// What the person asked for here and a machine did not do (#2330) reaches them as Centralu's notice in the Inbox
|
|
164913
|
+
tellPerson: (body, dedupeKey) => void hostMailbox.service.notice(PERSON, { body, facts: {}, dedupeKey }),
|
|
164487
164914
|
// When agents compact: this hub's setting governs the machines it links (#1376)
|
|
164488
164915
|
autoCompact: () => autoCompactOf(mgr.prefs.uiPreferences()),
|
|
164489
164916
|
// Automatic updates cover the linked machines too (#1508): one on an older release follows this hub's version; none starts while this host drains to stop
|