@centralu/win32-x64 0.1.0-beta.76 → 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.
Binary file
@@ -1,11 +1,11 @@
1
1
  {
2
- "commit": "f6d2451",
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-17T16:06:01.502Z",
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.76",
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.76",
42
- "@centralu/linux-arm64": "0.1.0-beta.76",
43
- "@centralu/linux-x64": "0.1.0-beta.76",
44
- "@centralu/win32-x64": "0.1.0-beta.76"
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.76";
43049
+ var APP_VERSION = "0.1.0-beta.77";
43050
43050
 
43051
43051
  // packages/protocol/src/brand.ts
43052
43052
  var APP_NAME = "Centralu";
@@ -60221,7 +60221,7 @@ var NormalizedEvent = external_exports.discriminatedUnion("type", [
60221
60221
  oncePerSession: external_exports.boolean().optional(),
60222
60222
  /** Who is speaking, as the person knows the tool: `Codex`, `Claude Code` */
60223
60223
  from: external_exports.string().optional(),
60224
- /** 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`) */
60225
60225
  label: external_exports.string().optional(),
60226
60226
  /**
60227
60227
  * Who has to act. `you`: the person's own setup (their `config.toml`, an MCP server they added). `centralu`: how
@@ -66891,7 +66891,25 @@ var files = {
66891
66891
  writeSync: (fd, data) => typeof data === "string" ? fs.writeSync(fd, data) : fs.writeSync(fd, data),
66892
66892
  fstatSync: (fd) => toStats(fs.fstatSync(fd, { bigint: true })),
66893
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
+ },
66894
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
+ },
66895
66913
  createReadStream: (p, o) => fs.createReadStream(p, o),
66896
66914
  watch: (p, o, listener) => fs.watch(
66897
66915
  p,
@@ -67149,7 +67167,12 @@ var realOsValue = {
67149
67167
  },
67150
67168
  clock,
67151
67169
  sqlite: {
67152
- open: (path2, o = {}) => new Database(path2, { readonly: o.readonly, fileMustExist: o.fileMustExist, timeout: o.timeout })
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
+ })
67153
67176
  },
67154
67177
  traits
67155
67178
  };
@@ -110149,7 +110172,13 @@ var WARNING_TEXT = {
110149
110172
  /** The three guards that refuse rather than warn (#1684, #2035): the person hears of the first refusal of each kind a clock hour */
110150
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.`,
110151
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.`,
110152
- 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.`
110153
110182
  };
110154
110183
  var TASK_CUT = "\n[Centralu: cut here. The full task is in the session's conversation (read_session).]";
110155
110184
  function cutTask(text3, limit) {
@@ -119601,6 +119630,8 @@ var MailFacts = external_exports.looseObject({
119601
119630
  watch: external_exports.object({ id: external_exports.string(), source: external_exports.string(), change: external_exports.string(), late: external_exports.boolean().optional() }).optional(),
119602
119631
  /** On Centralu's warning to the person (#1684): a send a guard refused (`repeat`, `rate_limited`, `ask_rate`), and whose */
119603
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(),
119604
119635
  answerHeld: external_exports.object({ question: external_exports.string(), answer: external_exports.string() }).optional(),
119605
119636
  refused: external_exports.object({ tool: external_exports.string(), target: external_exports.string(), firstLine: external_exports.string(), projectId: external_exports.string() }).optional(),
119606
119637
  trusted: external_exports.object({ project: external_exports.string(), refused: external_exports.array(external_exports.string()) }).optional(),
@@ -124408,7 +124439,7 @@ ${attachments.map((a) => `@${a.path}`).join("\n")}` : text3;
124408
124439
  if (input.skipLine?.()) return;
124409
124440
  const shown3 = !input.quiet && input.shown !== void 0 && this.showSent(sessionId, input.shown);
124410
124441
  const { line, mail } = input.listed ? mailLine(input.listed, shown3 ? input.shown?.messageId : void 0) : { line: input.line, mail: [] };
124411
- if (line) this.onEvent({ type: "notice", sessionId, level: "info", from: "Centralu", label: input.label ?? "mail", text: line, ...mail.length ? { 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 } : {} });
124412
124443
  }
124413
124444
  /**
124414
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
@@ -125697,6 +125728,22 @@ function settingThenKeep(settings) {
125697
125728
  }
125698
125729
 
125699
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
+ };
125700
125747
  var COMPACT_FLOOR_TOKENS = 1e5;
125701
125748
  var IDLE_COMPACT_MINUTES = 10;
125702
125749
  var SWEEP_MS = 6e4;
@@ -125821,9 +125868,9 @@ var SelfCompaction = class {
125821
125868
  return this.stepping.delete(sessionId);
125822
125869
  }
125823
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`) */
125824
- async goOn(id3, text3, line) {
125871
+ async goOn(id3, text3, line, label) {
125825
125872
  this.stepping.add(id3);
125826
- await this.host.sendThen(id3, text3, line).catch((err) => {
125873
+ await this.host.sendThen(id3, text3, line, label).catch((err) => {
125827
125874
  this.stepping.delete(id3);
125828
125875
  throw err;
125829
125876
  });
@@ -125879,10 +125926,9 @@ var SelfCompaction = class {
125879
125926
  mine.compacted = true;
125880
125927
  if (e.failed && mine.then) {
125881
125928
  mine.refused = `the tool reported the compaction failed${e.reason ? `: ${e.reason}` : ""}`;
125882
- this.host.notice(id3, `The compaction did not happen (${mine.refused}): the next step the agent set goes on without it`);
125929
+ this.refusal(id3, mine.refused);
125883
125930
  }
125884
125931
  this.stage(id3, mine, mine.refused === null ? "compacted" : "refused");
125885
- if (!e.failed) this.host.notice(id3, `Compacted by Centralu (${mine.why})`);
125886
125932
  }
125887
125933
  const live2 = this.pending.get(id3);
125888
125934
  if (e.type === "context_update" && live2 && live2.endedAt !== null) return this.decide(id3, e.used, m.tool);
@@ -126016,7 +126062,7 @@ var SelfCompaction = class {
126016
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");
126017
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`);
126018
126064
  this.settle(id3);
126019
- this.fire(id3, "the agent asked to after finishing its turn", req.focus, tool, req.then);
126065
+ this.fire(id3, req.focus, tool, req.then);
126020
126066
  }
126021
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 */
126022
126068
  refused(id3, used, why2) {
@@ -126028,12 +126074,19 @@ var SelfCompaction = class {
126028
126074
  const then2 = c.then;
126029
126075
  c.then = null;
126030
126076
  this.stopSettling(id3);
126031
- 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);
126032
126085
  }
126033
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 */
126034
126087
  refuseRequest(id3, then2, why2) {
126035
- const entry = { why: "refused", sentAt: this.now(), started: true, compacted: true, ended: true, then: then2, refused: why2, focusAside: null, ahead: false };
126036
- this.host.notice(id3, `The compaction did not happen (${why2}): the next step the agent set goes on without it`);
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 };
126037
126090
  this.compacting.set(id3, entry);
126038
126091
  this.stage(id3, entry, "refused");
126039
126092
  this.settleThen(id3, entry);
@@ -126044,7 +126097,7 @@ var SelfCompaction = class {
126044
126097
  this.compacting.delete(id3);
126045
126098
  return;
126046
126099
  }
126047
- this.host.notice(id3, `The compaction did not happen (${why2}): the next step the agent set goes on without it`);
126100
+ this.refusal(id3, why2);
126048
126101
  c.refused = why2;
126049
126102
  c.started = true;
126050
126103
  c.compacted = true;
@@ -126110,7 +126163,7 @@ var SelfCompaction = class {
126110
126163
  }
126111
126164
  if (!won) return;
126112
126165
  try {
126113
- await this.goOn(id3, thenTurn(rec), rec.why === null ? "Centralu sent the agent its next step after the compaction" : "Centralu sent the agent its next step: nothing was compacted");
126166
+ await this.goOn(id3, thenTurn(rec), rec.why === null ? "Centralu sent the agent its next step after the compaction" : "", COMPACT_LABELS.stepAfter);
126114
126167
  this.erase(id3);
126115
126168
  this.counted(id3);
126116
126169
  } catch (err) {
@@ -126128,17 +126181,22 @@ var SelfCompaction = class {
126128
126181
  console.error(`[compact] ${id3.slice(0, 8)}: could not count the cycle: ${err instanceof Error ? err.message : String(err)}`);
126129
126182
  }
126130
126183
  }
126131
- /** Tells the session, quietly, that its `then` was not sent; the person's window gets a line too */
126132
- 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) {
126133
126186
  this.erase(id3);
126134
- this.host.notice(id3, `The compaction did not happen (${why2}): the next step the agent set was not sent`);
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);
126135
126193
  this.deliver(id3, `[Centralu] Your compact_self request did not compact (${why2}), so your \`then\` was not sent. It was: ${then2}`);
126136
126194
  }
126137
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) */
126138
126196
  notTaken(id3, rec) {
126139
126197
  this.erase(id3);
126140
126198
  const what = rec.why === null ? "The compaction you asked for is done" : `Your compact_self request did not compact (${rec.why})`;
126141
- 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);
126142
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}`);
126143
126201
  }
126144
126202
  /**
@@ -126150,13 +126208,13 @@ var SelfCompaction = class {
126150
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}`;
126151
126209
  const reached = await this.reach(id3, text3);
126152
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];
126153
- this.host.notice(id3, `Centralu changed hosts while a compaction was asked for (${how}): ${outcome2}`);
126211
+ this.host.notice(id3, `Centralu restarted while a compaction was asked for (${how}): ${outcome2}`, COMPACT_LABELS.restarted);
126154
126212
  }
126155
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) */
126156
126214
  async reach(id3, text3) {
126157
126215
  if (!this.stopped && this.host.ready(id3)) {
126158
126216
  try {
126159
- await this.goOn(id3, text3, "Centralu told the agent to go on: it changed hosts while a compaction was asked for");
126217
+ await this.goOn(id3, text3, "Centralu told the agent to go on: it restarted while a compaction was asked for", COMPACT_LABELS.wentOnAfterRestart);
126160
126218
  return "turn";
126161
126219
  } catch {
126162
126220
  }
@@ -126218,7 +126276,7 @@ var SelfCompaction = class {
126218
126276
  /** What one kept step asks of the host that finds it (`recover`) */
126219
126277
  resume(m, rec) {
126220
126278
  const id3 = m.id;
126221
- 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);
126222
126280
  if (rec.stage === "compacted" || rec.stage === "refused") {
126223
126281
  if (this.host.ready(id3) && this.queuedNow(id3) !== true) void this.sendThen(id3, rec);
126224
126282
  else this.keepHeld(id3, rec);
@@ -126226,7 +126284,7 @@ var SelfCompaction = class {
126226
126284
  }
126227
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 */
126228
126286
  keepHeld(id3, rec) {
126229
- this.compacting.set(id3, { why: "kept through a host change", sentAt: this.now(), started: true, compacted: true, ended: true, then: rec.then, refused: rec.why, focusAside: rec.focusAside, ahead: rec.ahead });
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 });
126230
126288
  }
126231
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 */
126232
126290
  flushOwed(id3) {
@@ -126259,7 +126317,7 @@ var SelfCompaction = class {
126259
126317
  return false;
126260
126318
  }
126261
126319
  }
126262
- fire(id3, why2, focus, tool, then2 = null) {
126320
+ fire(id3, focus, tool, then2 = null) {
126263
126321
  const text3 = this.host.command(id3, tool, focus);
126264
126322
  if (text3 === null) {
126265
126323
  if (then2) this.refuseRequest(id3, then2, "this tool has no compact command");
@@ -126268,7 +126326,7 @@ var SelfCompaction = class {
126268
126326
  this.refusedAt.delete(id3);
126269
126327
  const focusAside = focus !== null && text3 === this.host.command(id3, tool, null) ? focus : null;
126270
126328
  try {
126271
- const entry = { why: why2, sentAt: this.now(), started: false, compacted: false, ended: false, then: then2, refused: null, focusAside, ahead: false };
126329
+ const entry = { sentAt: this.now(), started: false, compacted: false, ended: false, then: then2, refused: null, focusAside, ahead: false };
126272
126330
  this.compacting.set(id3, entry);
126273
126331
  this.stage(id3, entry, "sent");
126274
126332
  this.host.send(id3, text3);
@@ -126288,7 +126346,7 @@ var SelfCompaction = class {
126288
126346
  for (const m of this.host.sessions()) {
126289
126347
  if (this.pending.get(m.id)?.held) this.releaseHeld(m.id, m);
126290
126348
  if (!this.due(m, setting, now)) continue;
126291
- this.fire(m.id, `at rest for ${IDLE_COMPACT_MINUTES} minutes, over ${Math.round(setting.idleShare * 100)}% of the window`, null, m.tool);
126349
+ this.fire(m.id, null, m.tool);
126292
126350
  if (this.compacting.has(m.id)) sent.push(m.id);
126293
126351
  }
126294
126352
  return sent;
@@ -126460,7 +126518,7 @@ var ContextNudges = class {
126460
126518
  const answered = (took2) => {
126461
126519
  if (!took2) return;
126462
126520
  c.waiting = null;
126463
- 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);
126464
126522
  };
126465
126523
  let took;
126466
126524
  try {
@@ -128803,7 +128861,7 @@ var ACP_CAPABILITIES = {
128803
128861
  import { spawn as spawnChild } from "node:child_process";
128804
128862
  import { createHash as createHash12 } from "node:crypto";
128805
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";
128806
- 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, statfs, writeFile as writeFile5 } from "node:fs/promises";
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";
128807
128865
  import { homedir as homedir8 } from "node:os";
128808
128866
  import { dirname as dirname17, join as join34, resolve as resolve13 } from "node:path";
128809
128867
  import { Transform } from "node:stream";
@@ -129027,14 +129085,7 @@ var realInstallIo = {
129027
129085
  if (!res.ok || !res.body) throw new InstallFailure("network", `The download answered ${res.status} ${res.statusText}`.trim());
129028
129086
  return { total: decodedLength(res.headers), chunks: chunksOf(res.body) };
129029
129087
  },
129030
- async freeBytes(dir) {
129031
- try {
129032
- const s = await statfs(dir);
129033
- return s.bavail * s.bsize;
129034
- } catch {
129035
- return null;
129036
- }
129037
- }
129088
+ freeBytes: (dir) => Promise.resolve(realOs().files.freeBytesSync(dir))
129038
129089
  };
129039
129090
  function decodedLength(headers) {
129040
129091
  const encoding = headers.get("content-encoding")?.trim().toLowerCase();
@@ -141407,6 +141458,168 @@ function floorOf(raw) {
141407
141458
  return raw.trim() !== "" && Number.isInteger(n) && n >= 0 ? n : null;
141408
141459
  }
141409
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
+
141410
141623
  // packages/agent-host/src/dev-services/store/vacuum.ts
141411
141624
  var VACUUM_FREE_BYTES = 16 * 1024 * 1024;
141412
141625
  var VACUUM_OWED_KEY = "vacuum_owed";
@@ -141459,6 +141672,8 @@ var MigrationRunner = class extends ReaderGate {
141459
141672
  * cost quietly grows, and nobody notices. Counting it lets a test ask.
141460
141673
  */
141461
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;
141462
141677
  /**
141463
141678
  * The migration runner (E-0).
141464
141679
  *
@@ -141499,9 +141714,16 @@ var MigrationRunner = class extends ReaderGate {
141499
141714
  const deferred = new Set(this.storedDeferred());
141500
141715
  const owed = steps.filter((s) => s.to <= current && deferred.has(s.to)).map((s) => s.to);
141501
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;
141502
141720
  for (const step of steps) {
141503
141721
  const due2 = current < step.to || deferred.has(step.to);
141504
141722
  if (!due2) continue;
141723
+ if (copies && step.breaksOlderReaders && !copied) {
141724
+ this.copySkipped = copies.copyBefore(step.to);
141725
+ copied = true;
141726
+ }
141505
141727
  floor = this.runStep(step, floor, () => {
141506
141728
  if (step.to > this.schemaVersion) this.db.pragma(`user_version = ${step.to}`);
141507
141729
  if (deferred.delete(step.to)) this.writeDeferred([...deferred]);
@@ -143816,6 +144038,36 @@ var StepsV75 = class extends MigrationRange {
143816
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.
143817
144039
  */
143818
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
+ }
143819
144071
  }
143820
144072
  ];
143821
144073
  }
@@ -144888,9 +145140,10 @@ function resolveSchemaPath() {
144888
145140
  }
144889
145141
  var SCHEMA_PATH = resolveSchemaPath();
144890
145142
  var Store = class extends MigrationRunner {
144891
- constructor(dbPath2 = ":memory:") {
145143
+ constructor(dbPath2 = ":memory:", os2 = realOs()) {
144892
145144
  super();
144893
145145
  this.dbPath = dbPath2;
145146
+ this.os = os2;
144894
145147
  const path2 = dbPath2;
144895
145148
  this.db = new Database3(path2);
144896
145149
  this.projects = new ProjectRecords(this.db);
@@ -144925,6 +145178,7 @@ var Store = class extends MigrationRunner {
144925
145178
  this.checkpoint();
144926
145179
  }
144927
145180
  dbPath;
145181
+ os;
144928
145182
  db;
144929
145183
  /*
144930
145184
  * The records, one module per concept in `store/`, each holding its queries and the comments that say what they do.
@@ -148292,7 +148546,7 @@ var SessionManager = class {
148292
148546
  }
148293
148547
  });
148294
148548
  const compactSetting = () => autoCompactOf(this.prefs.uiPreferences());
148295
- const compactNotice = (id3, text3) => this.events.onEvent({ type: "notice", sessionId: id3, level: "info", from: "Centralu", label: "compaction", text: text3 });
148549
+ const compactNotice = (id3, text3, label) => this.events.onEvent({ type: "notice", sessionId: id3, level: "info", from: "Centralu", label, audience: "centralu", text: text3 });
148296
148550
  this.selfCompaction = new SelfCompaction({
148297
148551
  sessions: () => this.listSessions(),
148298
148552
  session: (id3) => this.meta.get(id3),
@@ -148308,7 +148562,7 @@ var SessionManager = class {
148308
148562
  },
148309
148563
  send: (id3, text3) => this.events.sendCompact(id3, text3),
148310
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
148311
- sendThen: (id3, text3, line) => this.events.deliverMail(id3, { text: text3, quiet: false, line, label: "compaction" }, { leaving: () => this.tenure.disposing, atRest: () => this.mail.takesTurn(id3) }),
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) }),
148312
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
148313
148567
  queued: (id3) => {
148314
148568
  const held3 = this.handles.get(id3)?.queuedInputs?.();
@@ -153485,6 +153739,15 @@ function hostMail(store2, sessions, opts) {
153485
153739
  } catch (e) {
153486
153740
  console.error(`[mail] telling the senders of the turns the last host's end cut failed: ${errorMessage(e)}`);
153487
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
+ }
153488
153751
  delivery.start();
153489
153752
  for (const s of sessions.listSessions()) sessions.settleAtRest?.(s.id);
153490
153753
  }
@@ -164307,7 +164570,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
164307
164570
  console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
164308
164571
  process.exit(1);
164309
164572
  }) : launch.token;
164310
- var BUILD = true ? "f6d2451" : "dev";
164573
+ var BUILD = true ? "d0e9e70" : "dev";
164311
164574
  var { values } = parseArgs({
164312
164575
  options: {
164313
164576
  port: { type: "string", default: "5175" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centralu/win32-x64",
3
- "version": "0.1.0-beta.76",
3
+ "version": "0.1.0-beta.77",
4
4
  "description": "Centralu app folder for Windows on x86-64",
5
5
  "license": "MIT",
6
6
  "author": "ijun17",