@centralu/host-win32-x64 0.1.0-beta.71 → 0.1.0-beta.72
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/host/bundle-info.json +2 -2
- package/host/centralu-package.json +5 -5
- package/host/main.mjs +199 -46
- package/package.json +1 -1
package/host/bundle-info.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "e17e3b5",
|
|
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-16T05:09:09.492Z",
|
|
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.72",
|
|
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.72",
|
|
42
|
+
"@centralu/linux-arm64": "0.1.0-beta.72",
|
|
43
|
+
"@centralu/linux-x64": "0.1.0-beta.72",
|
|
44
|
+
"@centralu/win32-x64": "0.1.0-beta.72"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/host/main.mjs
CHANGED
|
@@ -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.72";
|
|
43050
43050
|
|
|
43051
43051
|
// packages/protocol/src/brand.ts
|
|
43052
43052
|
var APP_NAME = "Centralu";
|
|
@@ -61346,6 +61346,7 @@ var SessionInfo = external_exports.object({
|
|
|
61346
61346
|
compactAt: external_exports.number().optional()
|
|
61347
61347
|
}).nullable().default(null)
|
|
61348
61348
|
});
|
|
61349
|
+
var LiveStateFields = SessionInfo.pick({ state: true, waitingSince: true, pendingApproval: true, pendingQuestions: true, activity: true, limit: true });
|
|
61349
61350
|
var SettingsApplied = external_exports.enum(["restarted", "after_turn", "saved"]);
|
|
61350
61351
|
var UpdateSettingsResult = SessionInfo.extend({ applied: SettingsApplied.optional() });
|
|
61351
61352
|
function sessionLiveDefaults() {
|
|
@@ -64138,6 +64139,9 @@ var ProofServer = external_exports.object({
|
|
|
64138
64139
|
sig: external_exports.string().regex(base64urlShape(LINK_SIGNATURE_BYTES)).optional().catch(void 0)
|
|
64139
64140
|
});
|
|
64140
64141
|
var CANCEL_CALL_METHOD = "call.cancel";
|
|
64142
|
+
var HOLD_CALL_METHOD = "call.hold";
|
|
64143
|
+
var HoldCallParams = external_exports.object({ id: external_exports.string().max(200), held: external_exports.boolean() });
|
|
64144
|
+
var CALL_HOLD_MAX_MS = 4 * 60 * 6e4;
|
|
64141
64145
|
var ServerFrame = external_exports.union([
|
|
64142
64146
|
HelloServer,
|
|
64143
64147
|
ProofServer,
|
|
@@ -65196,6 +65200,9 @@ function openCodeMatchesAnyCase(platform = HOST_PLATFORM) {
|
|
|
65196
65200
|
function programFile(name, platform = HOST_PLATFORM) {
|
|
65197
65201
|
return platform === "win32" ? `${name}.exe` : name;
|
|
65198
65202
|
}
|
|
65203
|
+
function npmMachine(platform = HOST_PLATFORM, arch = process.arch) {
|
|
65204
|
+
return `${platform}-${arch}`;
|
|
65205
|
+
}
|
|
65199
65206
|
function rustTarget(platform = HOST_PLATFORM, arch = process.arch) {
|
|
65200
65207
|
const cpu = arch === "x64" ? "x86_64" : arch === "arm64" ? "aarch64" : null;
|
|
65201
65208
|
if (!cpu) return null;
|
|
@@ -68820,6 +68827,12 @@ var HostServer = class _HostServer {
|
|
|
68820
68827
|
if (bridgeOf2 === null && !limited) this.answered(ws2, frame.data);
|
|
68821
68828
|
return;
|
|
68822
68829
|
}
|
|
68830
|
+
if (frame.data.method === HOLD_CALL_METHOD) {
|
|
68831
|
+
const hold = HoldCallParams.safeParse(frame.data.params);
|
|
68832
|
+
if (hold.success && bridgeOf2 === null && !limited) this.calls.get(ws2)?.get(hold.data.id)?.hold(hold.data.held);
|
|
68833
|
+
this.sendTo(ws2, JSON.stringify({ kind: "res", id: frame.data.id, ok: true, result: { ok: true } }));
|
|
68834
|
+
return;
|
|
68835
|
+
}
|
|
68823
68836
|
const { method, params, id: id3 } = frame.data;
|
|
68824
68837
|
if (bridgeOf2 !== null) {
|
|
68825
68838
|
const refusal2 = bridgeRefusal(bridgeOf2, method, params);
|
|
@@ -68886,6 +68899,10 @@ var HostServer = class _HostServer {
|
|
|
68886
68899
|
* over the socket the hub opened, and nowhere else. Fails at once when that connection is gone; withdrawn with
|
|
68887
68900
|
* `call.cancel` when `signal` fires, and when `timeoutMs` runs out (a call nobody answers is not held for good, and its
|
|
68888
68901
|
* work on the other side, a card standing there, is not left waiting for nobody: #550 review).
|
|
68902
|
+
*
|
|
68903
|
+
* The hub may hold the limit while what the call waits on is out of the person's sight (`call.hold`, #2271): the time
|
|
68904
|
+
* stops while held and runs on with what was left when released. Held for `holdMaxMs` in all (`CALL_HOLD_MAX_MS`), the
|
|
68905
|
+
* call is withdrawn as one that ran out of time. A held call still ends when its socket goes or `signal` fires.
|
|
68889
68906
|
*/
|
|
68890
68907
|
call(client, method, params, opts = {}) {
|
|
68891
68908
|
const ws2 = this.byClient.get(client);
|
|
@@ -68908,12 +68925,29 @@ var HostServer = class _HostServer {
|
|
|
68908
68925
|
withdraw();
|
|
68909
68926
|
reject(rpcError("The call was cancelled", "internal"));
|
|
68910
68927
|
};
|
|
68911
|
-
const
|
|
68928
|
+
const expire = (why2) => () => {
|
|
68912
68929
|
if (!calls.has(id3)) return;
|
|
68913
68930
|
done2();
|
|
68914
68931
|
withdraw();
|
|
68915
|
-
reject(rpcError(
|
|
68916
|
-
}
|
|
68932
|
+
reject(rpcError(why2, "internal", { retryable: true }));
|
|
68933
|
+
};
|
|
68934
|
+
const late = expire(`The other side did not answer ${method} in time`);
|
|
68935
|
+
let left = opts.timeoutMs ?? REVERSE_CALL_TIMEOUT_MS;
|
|
68936
|
+
let heldFor = 0;
|
|
68937
|
+
let held3 = false;
|
|
68938
|
+
let since = Date.now();
|
|
68939
|
+
let timer = setTimeout(late, left);
|
|
68940
|
+
const hold = (h) => {
|
|
68941
|
+
if (h === held3 || !calls.has(id3)) return;
|
|
68942
|
+
const now = Date.now();
|
|
68943
|
+
clearTimeout(timer);
|
|
68944
|
+
if (h) left -= now - since;
|
|
68945
|
+
else heldFor += now - since;
|
|
68946
|
+
held3 = h;
|
|
68947
|
+
since = now;
|
|
68948
|
+
const holdMax = opts.holdMaxMs ?? CALL_HOLD_MAX_MS;
|
|
68949
|
+
timer = h ? setTimeout(expire(`The other side held ${method} longer than ${durationText(holdMax)}`), Math.max(0, holdMax - heldFor)) : setTimeout(late, Math.max(0, left));
|
|
68950
|
+
};
|
|
68917
68951
|
calls.set(id3, {
|
|
68918
68952
|
resolve: (v) => {
|
|
68919
68953
|
done2();
|
|
@@ -68922,7 +68956,8 @@ var HostServer = class _HostServer {
|
|
|
68922
68956
|
reject: (e) => {
|
|
68923
68957
|
done2();
|
|
68924
68958
|
reject(e);
|
|
68925
|
-
}
|
|
68959
|
+
},
|
|
68960
|
+
hold
|
|
68926
68961
|
});
|
|
68927
68962
|
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
68928
68963
|
if (!this.sendTo(ws2, JSON.stringify({ kind: "rpc", id: id3, method, params }))) {
|
|
@@ -109683,6 +109718,10 @@ function isPerson(address) {
|
|
|
109683
109718
|
function senderKind(address) {
|
|
109684
109719
|
return isPerson(address) ? "person" : parseAddress(address)?.kind;
|
|
109685
109720
|
}
|
|
109721
|
+
var SESSION_ID_RE2 = new RegExp(`^${SEGMENT}$`);
|
|
109722
|
+
function isSessionId2(id3) {
|
|
109723
|
+
return typeof id3 === "string" && SESSION_ID_RE2.test(id3);
|
|
109724
|
+
}
|
|
109686
109725
|
function sessionAddress(host, sessionId) {
|
|
109687
109726
|
return checked(`session:${host}/${sessionId}`);
|
|
109688
109727
|
}
|
|
@@ -112312,13 +112351,13 @@ function entryOf(row) {
|
|
|
112312
112351
|
by: work ? "work" : "person",
|
|
112313
112352
|
source: p.relayed === true ? "report" : p.fromApp !== void 0 ? "app" : "caller",
|
|
112314
112353
|
...hub.success && isHubSender(hub.data.from.sessionId) ? { origin: hub.data } : {},
|
|
112315
|
-
...
|
|
112354
|
+
...isSessionId2(from) ? { from } : from !== void 0 ? { unowned: true } : {}
|
|
112316
112355
|
};
|
|
112317
112356
|
}
|
|
112318
112357
|
function starterFor(ran) {
|
|
112319
112358
|
const work = ran.find((e) => e.by === "work");
|
|
112320
112359
|
if (!work) return ran.length ? { turn: { by: "person" }, cli: false, source: "caller" } : { turn: { by: "work" }, cli: true, source: "caller" };
|
|
112321
|
-
return { turn: { by: "work", ...ran.some((e) => e.by === "person") ? { wrote: true } : {} }, cli: false, source: work.source, ...work.from ? { from: work.from } : {} };
|
|
112360
|
+
return { turn: { by: "work", ...ran.some((e) => e.by === "person") ? { wrote: true } : {} }, cli: false, source: work.source, ...work.from ? { from: work.from } : {}, ...work.unowned ? { unowned: true } : {} };
|
|
112322
112361
|
}
|
|
112323
112362
|
var turnSpanKey = (sessionId) => `turn_span:${sessionId}`;
|
|
112324
112363
|
var TURN_STARTS_KEPT = 8;
|
|
@@ -112558,7 +112597,7 @@ var ChildOwnership = class {
|
|
|
112558
112597
|
const rows3 = this.store.messages.loadUserRowsFrom(sessionId, from).map((row) => {
|
|
112559
112598
|
const p = asObj(row.payload);
|
|
112560
112599
|
const sender = asObj(p.from).sessionId;
|
|
112561
|
-
return
|
|
112600
|
+
return isSessionId2(sender) && p.relayed !== true ? sender : null;
|
|
112562
112601
|
});
|
|
112563
112602
|
return answered >= from ? [...rows3, null] : rows3;
|
|
112564
112603
|
}
|
|
@@ -112611,9 +112650,16 @@ var ChildOwnership = class {
|
|
|
112611
112650
|
if (again && was && was.turn.by === decided.turn.by && !!was.turn.wrote === !!decided.turn.wrote && was.cli === decided.cli) return;
|
|
112612
112651
|
this.starters.set(sessionId, decided);
|
|
112613
112652
|
if (!this.turnStartedHook) return;
|
|
112614
|
-
const ownerId = decided.from ?? [...this.runs.values()].find((d2) => d2.sessionId === sessionId && !d2.settled)?.callerId;
|
|
112653
|
+
const ownerId = decided.unowned ? void 0 : decided.from ?? [...this.runs.values()].find((d2) => d2.sessionId === sessionId && !d2.settled)?.callerId;
|
|
112615
112654
|
try {
|
|
112616
|
-
this.turnStartedHook(sessionId, {
|
|
112655
|
+
this.turnStartedHook(sessionId, {
|
|
112656
|
+
by: decided.turn.by,
|
|
112657
|
+
cli: decided.cli,
|
|
112658
|
+
source: decided.source,
|
|
112659
|
+
...ownerId ? { ownerId } : {},
|
|
112660
|
+
...decided.unowned ? { unowned: true } : {},
|
|
112661
|
+
...again ? { again: true } : {}
|
|
112662
|
+
});
|
|
112617
112663
|
} catch (e) {
|
|
112618
112664
|
console.error(`[mail] could not record a turn of ${sessionId.slice(0, 8)} (${errorMessage(e)})`);
|
|
112619
112665
|
}
|
|
@@ -115347,7 +115393,7 @@ var HANDLERS = {
|
|
|
115347
115393
|
if (!s) return { text: "Centralu update is unavailable.", isError: true };
|
|
115348
115394
|
const apply = callForm(caller.profile, "update_centralu", { action: "apply" });
|
|
115349
115395
|
const applies = `The person applies the installed build from Centralu${apply ? `, or ${apply} does` : ""}; their automatic-update setting was not changed.`;
|
|
115350
|
-
if (s.phase === "failed") return { text: `Centralu update failed: ${s.error}
|
|
115396
|
+
if (s.phase === "failed") return { text: `Centralu update failed: ${(s.error ?? "unknown error").replace(/\.$/, "")}. ${namedCall(caller.profile, "update_centralu", { action: "install" })} tries again.` };
|
|
115351
115397
|
if (s.phase === "updating" || s.phase === "waiting_for_npm") return { text: `Installing Centralu ${s.latest ?? ""}. ${applies}` };
|
|
115352
115398
|
if (action === "check") {
|
|
115353
115399
|
if (s.phase === "restart_required") return { text: `Centralu ${s.latest ?? ""} is installed and waits for a restart. ${applies}` };
|
|
@@ -124079,6 +124125,7 @@ var SessionEvents = class {
|
|
|
124079
124125
|
const from = m.state;
|
|
124080
124126
|
if (applySessionState(m, e, Date.now()).illegal) console.warn(`[agent-host] ignored ${e.type} for ${m.id.slice(0, 8)}: ${from} cannot go to ${nextStateFor(e)}`);
|
|
124081
124127
|
this.trackLiveFacts(e, m);
|
|
124128
|
+
this.host.hostCards.noteStanding(m.id);
|
|
124082
124129
|
}
|
|
124083
124130
|
/**
|
|
124084
124131
|
* An adapter's card raised between turns closes back into that rest once answered (#428), as the host's own cards do
|
|
@@ -131860,6 +131907,10 @@ var CLAUDE_KNOWN_TYPES = /* @__PURE__ */ new Set([
|
|
|
131860
131907
|
"system/hook_progress",
|
|
131861
131908
|
"system/hook_response",
|
|
131862
131909
|
"system/thinking_tokens",
|
|
131910
|
+
// ignored: what they say arrives some other way (#2291)
|
|
131911
|
+
"system/commands_changed",
|
|
131912
|
+
"command_lifecycle",
|
|
131913
|
+
"system/permission_denied",
|
|
131863
131914
|
// correctly ignored
|
|
131864
131915
|
"system/control_request_progress",
|
|
131865
131916
|
"system/plugin_install",
|
|
@@ -133421,7 +133472,7 @@ var CLAUDE_LIMITATIONS = [
|
|
|
133421
133472
|
note: "Declared, but the CLI writes it to stdout only in a remote session, so the goal badge is read off the stream (`ClaudeGoalTracker`). When a CLI sends it, the tracker stands down."
|
|
133422
133473
|
},
|
|
133423
133474
|
// The #58 survey's "show or store it, wire it when it is seen" rows: out of CLAUDE_KNOWN_TYPES on purpose
|
|
133424
|
-
...["auth_status", "tool_use_summary", "system/
|
|
133475
|
+
...["auth_status", "tool_use_summary", "system/memory_recall"].map(
|
|
133425
133476
|
(name) => ({
|
|
133426
133477
|
kind: "message",
|
|
133427
133478
|
name,
|
|
@@ -145360,7 +145411,7 @@ function turnRecorder(mail, records, turns) {
|
|
|
145360
145411
|
return (sessionId, turn) => {
|
|
145361
145412
|
const child = mail.sessionAddress(sessionId);
|
|
145362
145413
|
const taskId = turn.ownerId && turn.by === "work" ? records.newestTask(mail.sessionAddress(turn.ownerId), child)?.id ?? null : null;
|
|
145363
|
-
const personWork = () => turn.ownerId ? null : records.newestTask(PERSON, child)?.id ?? null;
|
|
145414
|
+
const personWork = () => turn.ownerId || turn.unowned ? null : records.newestTask(PERSON, child)?.id ?? null;
|
|
145364
145415
|
const record2 = (by, messageId, owner) => turn.again ? turns.restate(sessionId, by, messageId, owner) : turns.beginOther(sessionId, by, messageId, owner);
|
|
145365
145416
|
if (turn.by === "person") record2("person", null);
|
|
145366
145417
|
else if (turn.source === "report") record2("report", null);
|
|
@@ -146020,7 +146071,7 @@ var HostCards = class {
|
|
|
146020
146071
|
return new Promise((resolve21) => {
|
|
146021
146072
|
if (signal?.aborted) return resolve21(null);
|
|
146022
146073
|
const requestId = card.requestId ?? `${detail.kind === "project_access" ? "xp" : detail.kind === "agent_start" ? "ag" : detail.kind === "centralu_update" || isCentraluApply(detail) ? "up" : "mk"}-${randomUUID25()}`;
|
|
146023
|
-
const ask = { requestId, sessionId, detail, shown: card.shown ?? false, resolve: resolve21 };
|
|
146074
|
+
const ask = { requestId, sessionId, detail, shown: card.shown ?? false, resolve: resolve21, ...card.onHeld ? { onHeld: card.onHeld } : {} };
|
|
146024
146075
|
this.hostAsks.set(requestId, ask);
|
|
146025
146076
|
signal?.addEventListener("abort", () => this.withdrawHostAsk(requestId), { once: true });
|
|
146026
146077
|
this.raiseHostAsks(sessionId);
|
|
@@ -146115,6 +146166,26 @@ var HostCards = class {
|
|
|
146115
146166
|
* conversation never ends up with the same card as two separate lines).
|
|
146116
146167
|
*/
|
|
146117
146168
|
raiseHostAsks(sessionId) {
|
|
146169
|
+
this.raiseNext(sessionId);
|
|
146170
|
+
this.noteStanding(sessionId);
|
|
146171
|
+
}
|
|
146172
|
+
/**
|
|
146173
|
+
* Tells the callers of a session's cards whether each is in the person's sight (#2271): standing in the session's slot,
|
|
146174
|
+
* or not (another card stands there, or the person's own turn cleared the slot, `cardsDead`, until the turn ends and
|
|
146175
|
+
* raises it again, #673). Only a change is told. Run after every change of the slot (`applyStateHint`) and every raise;
|
|
146176
|
+
* a caller that waits on the person holds its limit meanwhile (a linked machine's ask, `call.hold`)
|
|
146177
|
+
*/
|
|
146178
|
+
noteStanding(sessionId) {
|
|
146179
|
+
const slot = this.host.meta.get(sessionId)?.pendingApproval?.requestId;
|
|
146180
|
+
for (const ask of this.hostAsks.values()) {
|
|
146181
|
+
if (ask.sessionId !== sessionId || !ask.onHeld) continue;
|
|
146182
|
+
const held3 = slot !== ask.requestId;
|
|
146183
|
+
if (held3 === (ask.held ?? false)) continue;
|
|
146184
|
+
ask.held = held3;
|
|
146185
|
+
ask.onHeld(held3);
|
|
146186
|
+
}
|
|
146187
|
+
}
|
|
146188
|
+
raiseNext(sessionId) {
|
|
146118
146189
|
const m = this.host.meta.get(sessionId);
|
|
146119
146190
|
if (!m || m.pendingApproval) return;
|
|
146120
146191
|
const next = [...this.hostAsks.values()].find((a) => a.sessionId === sessionId);
|
|
@@ -147833,8 +147904,11 @@ var MachineAsks = class {
|
|
|
147833
147904
|
ordinary(projectId) {
|
|
147834
147905
|
return [...this.host.meta.values()].filter((s) => s.projectId === projectId && isOrdinary(s)).map((s) => ({ id: s.id, name: s.name, state: s.state }));
|
|
147835
147906
|
}
|
|
147836
|
-
/**
|
|
147837
|
-
|
|
147907
|
+
/**
|
|
147908
|
+
* `hub.askProject`: one ask of a machine's session, as `ask_project` is here. `hold` holds the call's limit on the machine
|
|
147909
|
+
* while the pair's card is out of the person's sight (#2271)
|
|
147910
|
+
*/
|
|
147911
|
+
async ask(machine, p, signal, hold) {
|
|
147838
147912
|
const shut = this.gate(machine);
|
|
147839
147913
|
if (shut) return { ok: false, error: shut };
|
|
147840
147914
|
const here = this.selfName();
|
|
@@ -147891,9 +147965,11 @@ var MachineAsks = class {
|
|
|
147891
147965
|
closing.signal,
|
|
147892
147966
|
/*
|
|
147893
147967
|
* Raised whatever the target session's preset (#550 review): its `auto` is its own, and answers no card of another
|
|
147894
|
-
* machine, as start_agent's on another computer is asked every time (#1038)
|
|
147968
|
+
* machine, as start_agent's on another computer is asked every time (#1038). The machine's call waits on the person,
|
|
147969
|
+
* so its limit stops while the person cannot see the card (#2271): their own turn in that session hides it until the
|
|
147970
|
+
* turn ends (#673), or another card stands in its place
|
|
147895
147971
|
*/
|
|
147896
|
-
{ alwaysAsk: true }
|
|
147972
|
+
{ alwaysAsk: true, ...hold ? { onHeld: hold } : {} }
|
|
147897
147973
|
).finally(() => {
|
|
147898
147974
|
signal?.removeEventListener("abort", onAbort);
|
|
147899
147975
|
mine2.delete(closing);
|
|
@@ -155457,6 +155533,7 @@ var CommandRunner = class {
|
|
|
155457
155533
|
|
|
155458
155534
|
// packages/agent-host/src/updates.ts
|
|
155459
155535
|
import { existsSync as existsSync27, readFileSync as readFileSync23 } from "node:fs";
|
|
155536
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
155460
155537
|
import { dirname as dirname26, join as join54 } from "node:path";
|
|
155461
155538
|
var REGISTRY_URL = `https://registry.npmjs.org/${APP_SLUG}/latest`;
|
|
155462
155539
|
var CHECK_INTERVAL_MS = 6 * 60 * 60 * 1e3;
|
|
@@ -155481,7 +155558,27 @@ async function npmGlobalPackage() {
|
|
|
155481
155558
|
const root3 = out.trim().split(/\r?\n/).at(-1)?.trim();
|
|
155482
155559
|
if (!root3) return null;
|
|
155483
155560
|
const launcher = join54(root3, APP_SLUG, "bin", `${APP_SLUG}.mjs`);
|
|
155484
|
-
|
|
155561
|
+
if (!existsSync27(launcher)) return null;
|
|
155562
|
+
const manifest = join54(root3, APP_SLUG, "package.json");
|
|
155563
|
+
return { launcher, version: packageVersion(manifest), platform: platformPackage(launcher, manifest, npmMachine()) };
|
|
155564
|
+
}
|
|
155565
|
+
function platformPackage(launcher, manifest, machine) {
|
|
155566
|
+
const name = `@${APP_SLUG}/${machine}`;
|
|
155567
|
+
if (!Object.hasOwn(optionalDependencies(manifest), name)) return null;
|
|
155568
|
+
try {
|
|
155569
|
+
return { name, version: packageVersion(createRequire4(launcher).resolve(`${name}/package.json`)) };
|
|
155570
|
+
} catch {
|
|
155571
|
+
return { name, version: null };
|
|
155572
|
+
}
|
|
155573
|
+
}
|
|
155574
|
+
function optionalDependencies(file2) {
|
|
155575
|
+
try {
|
|
155576
|
+
const pkg = JSON.parse(readFileSync23(file2, "utf8"));
|
|
155577
|
+
const deps = typeof pkg === "object" && pkg !== null && "optionalDependencies" in pkg ? pkg.optionalDependencies : null;
|
|
155578
|
+
return typeof deps === "object" && deps !== null ? { ...deps } : {};
|
|
155579
|
+
} catch {
|
|
155580
|
+
return {};
|
|
155581
|
+
}
|
|
155485
155582
|
}
|
|
155486
155583
|
function existingCopy(path2, platform = HOST_PLATFORM) {
|
|
155487
155584
|
if (!existsSync27(path2)) return null;
|
|
@@ -155567,15 +155664,15 @@ function runCommand(file2, args, resolve21) {
|
|
|
155567
155664
|
);
|
|
155568
155665
|
}
|
|
155569
155666
|
var UpdateService = class {
|
|
155570
|
-
constructor(publish, deps
|
|
155667
|
+
constructor(publish, deps) {
|
|
155571
155668
|
this.publish = publish;
|
|
155572
155669
|
this.deps = {
|
|
155573
155670
|
current: deps.current ?? APP_VERSION,
|
|
155574
155671
|
build: deps.build ?? "",
|
|
155575
|
-
fetchLatest: deps.fetchLatest
|
|
155576
|
-
run: deps.run
|
|
155577
|
-
installedCopy: deps.installedCopy
|
|
155578
|
-
installedCopyVersion: deps.installedCopyVersion
|
|
155672
|
+
fetchLatest: deps.fetchLatest,
|
|
155673
|
+
run: deps.run,
|
|
155674
|
+
installedCopy: deps.installedCopy,
|
|
155675
|
+
installedCopyVersion: deps.installedCopyVersion,
|
|
155579
155676
|
now: deps.now ?? Date.now,
|
|
155580
155677
|
schedule: deps.schedule ?? ((fn2, ms3) => {
|
|
155581
155678
|
const t = setTimeout(fn2, ms3);
|
|
@@ -155592,7 +155689,7 @@ var UpdateService = class {
|
|
|
155592
155689
|
writeAutoApply: deps.writeAutoApply ?? (() => {
|
|
155593
155690
|
}),
|
|
155594
155691
|
wait: deps.wait ?? sleep,
|
|
155595
|
-
globalPackage: deps.globalPackage
|
|
155692
|
+
globalPackage: deps.globalPackage,
|
|
155596
155693
|
node: deps.node ?? process.execPath
|
|
155597
155694
|
};
|
|
155598
155695
|
this.status = {
|
|
@@ -155792,7 +155889,8 @@ var UpdateService = class {
|
|
|
155792
155889
|
this.emit();
|
|
155793
155890
|
return this.current();
|
|
155794
155891
|
}
|
|
155795
|
-
const
|
|
155892
|
+
const failed5 = this.retry?.version;
|
|
155893
|
+
const failure4 = kept?.phase === "failed" && !(failed5 && isNewerVersion(latest, failed5)) ? kept : null;
|
|
155796
155894
|
this.status = {
|
|
155797
155895
|
...this.status,
|
|
155798
155896
|
latest,
|
|
@@ -155924,7 +156022,8 @@ var UpdateService = class {
|
|
|
155924
156022
|
* The same two steps as an install from the app (`runApply`): `npm i -g centralu@<this version>`, pinned since the hub
|
|
155925
156023
|
* decides it, then the npm package's own launcher's `install` by its path (`installCopy`), which on Windows renames the
|
|
155926
156024
|
* running copy aside. A global package already at or above this version is never taken down to it: only its `install`
|
|
155927
|
-
* runs
|
|
156025
|
+
* runs, after npm installs that package's own version again when its platform package is missing or at another version
|
|
156026
|
+
* (#2282: an npm that skipped it would otherwise fail every start until a newer release). Nobody sees it: no status changes. A failure is one line on stderr and is tried again at the next host start,
|
|
155928
156027
|
* which is also when the hub's next update arrives. Never beside an install from the app: one running leaves this for
|
|
155929
156028
|
* the next start, and one asked for meanwhile waits for this to end (`runApply`).
|
|
155930
156029
|
*/
|
|
@@ -155943,7 +156042,8 @@ var UpdateService = class {
|
|
|
155943
156042
|
async runFollow(copy, was, to) {
|
|
155944
156043
|
try {
|
|
155945
156044
|
const global2 = await this.deps.globalPackage();
|
|
155946
|
-
if (!atLeast(global2?.version ?? null, to)) await this.
|
|
156045
|
+
if (!atLeast(global2?.version ?? null, to)) await this.installGlobal(to);
|
|
156046
|
+
else if (global2?.version && global2.platform && global2.platform.version !== global2.version) await this.installGlobal(global2.version);
|
|
155947
156047
|
if (this.stopped) return;
|
|
155948
156048
|
await this.installCopy();
|
|
155949
156049
|
console.error(`[updates] the installed copy at ${copy} was refreshed from the npm package at ${global2?.version && atLeast(global2.version, to) ? global2.version : to} (it held ${was ?? "an unreadable version"}; this host is ${to})`);
|
|
@@ -155962,7 +156062,8 @@ var UpdateService = class {
|
|
|
155962
156062
|
/**
|
|
155963
156063
|
* A just-published release can be visible from `latest` before its package is on the npm edge
|
|
155964
156064
|
* this machine reaches: `notarget`/ETARGET while the packument lacks it, or E404 on its own tarball while the packument
|
|
155965
|
-
* already lists it (#2279, the registry edge serves the two apart)
|
|
156065
|
+
* already lists it (#2279, the registry edge serves the two apart), or an exit 0 without this machine's platform
|
|
156066
|
+
* package, whose tarball the edge did not serve yet (#2282, `installGlobal`). That narrow condition only; credentials, disk and
|
|
155966
156067
|
* package errors still fail immediately. The ten minute cap makes this a wait with an end, not
|
|
155967
156068
|
* a hidden retry loop. `--prefer-online` makes npm revalidate instead of trusting its stale cache.
|
|
155968
156069
|
*/
|
|
@@ -155972,11 +156073,11 @@ var UpdateService = class {
|
|
|
155972
156073
|
for (; ; ) {
|
|
155973
156074
|
if (this.stopped) return;
|
|
155974
156075
|
try {
|
|
155975
|
-
await this.
|
|
156076
|
+
await this.installGlobal(version2);
|
|
155976
156077
|
return;
|
|
155977
156078
|
} catch (err) {
|
|
155978
156079
|
if (this.stopped) return;
|
|
155979
|
-
if (!npmHasNotServedVersion(err, version2)) throw err;
|
|
156080
|
+
if (!(err instanceof PlatformPackageMissing) && !npmHasNotServedVersion(err, version2)) throw err;
|
|
155980
156081
|
if (this.deps.now() - started >= NPM_RETRY_WINDOW_MS) throw Object.assign(new Error(`npm did not serve ${version2} within ${NPM_RETRY_WINDOW_MS / 6e4} minutes: ${errorMessage(err)}`), err);
|
|
155981
156082
|
this.status = { ...this.status, phase: "waiting_for_npm", error: `Waiting for npm to serve ${version2}${notice ? `. ${notice}` : ""}` };
|
|
155982
156083
|
this.emit();
|
|
@@ -155987,6 +156088,19 @@ var UpdateService = class {
|
|
|
155987
156088
|
}
|
|
155988
156089
|
}
|
|
155989
156090
|
}
|
|
156091
|
+
/**
|
|
156092
|
+
* `npm i -g centralu@<version>`, and this machine's platform package with it (#2282): npm skips an optional dependency
|
|
156093
|
+
* whose tarball the registry edge does not serve yet and exits 0, which leaves a launcher with no app and no host.
|
|
156094
|
+
* That is the same publish race as a 404 on `centralu`'s own tarball, so it throws `PlatformPackageMissing`, which
|
|
156095
|
+
* the install waits out (`installPackage`). A global package npm root does not lead to is left to `installCopy`,
|
|
156096
|
+
* which says so.
|
|
156097
|
+
*/
|
|
156098
|
+
async installGlobal(version2) {
|
|
156099
|
+
await this.deps.run("npm", ["i", "-g", "--prefer-online", `${APP_SLUG}@${version2}`]);
|
|
156100
|
+
if (this.stopped) return;
|
|
156101
|
+
const platform = (await this.deps.globalPackage())?.platform;
|
|
156102
|
+
if (platform && platform.version !== version2) throw new PlatformPackageMissing(`npm installed ${APP_SLUG} ${version2} without ${platform.name}@${version2}`);
|
|
156103
|
+
}
|
|
155990
156104
|
/** `version` is past the release installed and waiting, or nothing is waiting */
|
|
155991
156105
|
passesInstalled(version2) {
|
|
155992
156106
|
return !this.installed || isNewerVersion(version2, this.installed.version);
|
|
@@ -156005,6 +156119,18 @@ var UpdateService = class {
|
|
|
156005
156119
|
this.publish(this.current());
|
|
156006
156120
|
}
|
|
156007
156121
|
};
|
|
156122
|
+
function realUpdateService(publish, options = {}) {
|
|
156123
|
+
return new UpdateService(publish, {
|
|
156124
|
+
...options,
|
|
156125
|
+
fetchLatest: fetchLatestFromRegistry,
|
|
156126
|
+
run: runCommand,
|
|
156127
|
+
installedCopy: () => existingCopy(installedCopyPath()),
|
|
156128
|
+
installedCopyVersion: (copy) => readInstalledCopyVersion(copy),
|
|
156129
|
+
globalPackage: npmGlobalPackage
|
|
156130
|
+
});
|
|
156131
|
+
}
|
|
156132
|
+
var PlatformPackageMissing = class extends Error {
|
|
156133
|
+
};
|
|
156008
156134
|
function npmHasNotServedVersion(err, version2) {
|
|
156009
156135
|
const tarball = `/${APP_SLUG}/-/${APP_SLUG}-${version2}.tgz`.replace(/[.+]/g, "\\$&");
|
|
156010
156136
|
return /\bETARGET\b|\bnotarget\b/i.test(errorMessage(err)) || new RegExp(`\\b404 Not Found - GET \\S+${tarball}(?!\\S)`, "i").test(stderrOf(err));
|
|
@@ -159405,7 +159531,11 @@ var RemoteClient = class {
|
|
|
159405
159531
|
if (this.incoming.size >= MAX_INCOMING_CALLS) return refuse8("Too many calls at once; try again shortly", "internal", true);
|
|
159406
159532
|
const ctl = new AbortController();
|
|
159407
159533
|
this.incoming.set(id3, ctl);
|
|
159408
|
-
|
|
159534
|
+
const hold = (held3) => {
|
|
159535
|
+
if (this.ws !== ws2 || this.incoming.get(id3) !== ctl) return;
|
|
159536
|
+
this.call(HOLD_CALL_METHOD, { id: id3, held: held3 }).catch(() => void 0);
|
|
159537
|
+
};
|
|
159538
|
+
void handle2(method, params, ctl.signal, hold).then(
|
|
159409
159539
|
(result) => answer({ ok: true, result: result ?? null }),
|
|
159410
159540
|
(err) => {
|
|
159411
159541
|
const e = asObj(err);
|
|
@@ -160747,7 +160877,7 @@ var LinkedMachineConnection = class {
|
|
|
160747
160877
|
hello: (h) => void this.onHello(client, h),
|
|
160748
160878
|
event: (e) => this.onEvent(e),
|
|
160749
160879
|
// The machine's calls to this hub (#550): answered as this machine, whatever they say, by the hub's allowlist
|
|
160750
|
-
...this.deps.reverse ? { call: (method, params, signal) => this.deps.reverse({ id: this.id, name: this.name }, method, params, signal) } : {},
|
|
160880
|
+
...this.deps.reverse ? { call: (method, params, signal, hold) => this.deps.reverse({ id: this.id, name: this.name }, method, params, signal, hold) } : {},
|
|
160751
160881
|
terminal: (f) => this.deps.terminal({ ...f, terminalId: this.q.id(f.terminalId) }),
|
|
160752
160882
|
down: (reason, detail) => {
|
|
160753
160883
|
if (this.client !== client) return;
|
|
@@ -160805,9 +160935,12 @@ var LinkedMachineConnection = class {
|
|
|
160805
160935
|
if (!mayConnect(v)) return;
|
|
160806
160936
|
}
|
|
160807
160937
|
try {
|
|
160808
|
-
|
|
160809
|
-
|
|
160810
|
-
|
|
160938
|
+
await Promise.all(
|
|
160939
|
+
["sessions", "projects"].map(async (kind) => {
|
|
160940
|
+
const list2 = await client.call(kind === "sessions" ? "sessions.list" : "projects.list", {});
|
|
160941
|
+
if (Array.isArray(list2)) this.observe(kind, list2);
|
|
160942
|
+
})
|
|
160943
|
+
);
|
|
160811
160944
|
} catch (err) {
|
|
160812
160945
|
this.deps.log?.(`[links] ${this.name}: could not read its lists after connecting: ${err.message}`);
|
|
160813
160946
|
}
|
|
@@ -160868,15 +161001,31 @@ var LinkedMachineConnection = class {
|
|
|
160868
161001
|
this.deps.mirror.removeSession(this.id, sid);
|
|
160869
161002
|
} else if (raw.type === "session_title" && typeof raw.title === "string") {
|
|
160870
161003
|
this.deps.mirror.patchSession(this.id, sid, { name: raw.title });
|
|
160871
|
-
} else if (raw.type === "state_change" && typeof raw.state === "string") {
|
|
160872
|
-
this.deps.mirror.patchSession(this.id, sid, { state: raw.state });
|
|
160873
161004
|
} else if (raw.type === "session_owner") {
|
|
160874
161005
|
this.deps.mirror.patchSession(this.id, sid, { askedBy: raw.askedBy ?? null, parentSessionId: raw.parentSessionId ?? null });
|
|
161006
|
+
} else {
|
|
161007
|
+
this.followState(sid, raw);
|
|
160875
161008
|
}
|
|
160876
161009
|
}
|
|
160877
161010
|
const out = this.q.event(raw);
|
|
160878
161011
|
if (out) this.deps.broadcast(out);
|
|
160879
161012
|
}
|
|
161013
|
+
/**
|
|
161014
|
+
* The mirror's row follows every event that moves the session's state (#2288), by the one state rule the machine's host
|
|
161015
|
+
* and the windows run (`applySessionState`). It used to take `state_change` alone, so a turn's end (`turn_complete`), a
|
|
161016
|
+
* card, a limit or an error left the row as it was: a session that had finished its turn still read as working to every
|
|
161017
|
+
* reader of the mirror. An `activity` (a compaction, a review, a retry: rare) is followed too, as the rule writes it. An
|
|
161018
|
+
* event or a row this build cannot read changes nothing; the machine's next list replaces the rows whole (`observe`).
|
|
161019
|
+
*/
|
|
161020
|
+
followState(sid, raw) {
|
|
161021
|
+
const e = NormalizedEvent.safeParse(raw);
|
|
161022
|
+
if (!e.success || nextStateFor(e.data) === null && e.data.type !== "activity") return;
|
|
161023
|
+
const row = (this.deps.mirror.read(this.id, "sessions") ?? []).find((s) => isObj(s) && s.id === sid);
|
|
161024
|
+
const live2 = LiveStateFields.safeParse(row);
|
|
161025
|
+
if (!live2.success) return;
|
|
161026
|
+
applySessionState(live2.data, e.data, Date.now());
|
|
161027
|
+
this.deps.mirror.patchSession(this.id, sid, live2.data);
|
|
161028
|
+
}
|
|
160880
161029
|
classify(s) {
|
|
160881
161030
|
if (!isObj(s) || typeof s.id !== "string") return;
|
|
160882
161031
|
if (!hiddenKind(s)) this.shown.add(s.id);
|
|
@@ -163157,7 +163306,11 @@ var LinkedHubs = class {
|
|
|
163157
163306
|
if (h.client === null) return { ok: false, error: `${h.name} is ${NOT_REACHABLE}. Try again once its link is back.` };
|
|
163158
163307
|
let raw;
|
|
163159
163308
|
try {
|
|
163160
|
-
raw = await this.deps.call(h.client, "hub.askProject", params, {
|
|
163309
|
+
raw = await this.deps.call(h.client, "hub.askProject", params, {
|
|
163310
|
+
signal,
|
|
163311
|
+
...this.deps.askTimeoutMs ? { timeoutMs: this.deps.askTimeoutMs } : {},
|
|
163312
|
+
...this.deps.askHoldMaxMs ? { holdMaxMs: this.deps.askHoldMaxMs } : {}
|
|
163313
|
+
});
|
|
163161
163314
|
} catch (err) {
|
|
163162
163315
|
if (signal?.aborted) return { ok: false, error: "The call was cancelled." };
|
|
163163
163316
|
if (older3(err)) return { ok: false, error: `${h.name} runs a Centralu from before this, so it cannot be asked. Update it there.` };
|
|
@@ -163244,7 +163397,7 @@ var LinkedHubs = class {
|
|
|
163244
163397
|
|
|
163245
163398
|
// packages/agent-host/src/links/reverse-calls.ts
|
|
163246
163399
|
function reverseCalls(o) {
|
|
163247
|
-
return async (machine, method, params, signal) => {
|
|
163400
|
+
return async (machine, method, params, signal, hold) => {
|
|
163248
163401
|
const apps = o.apps;
|
|
163249
163402
|
if (apps && method === "hub.apps") {
|
|
163250
163403
|
const p2 = read(HubMethods["hub.apps"].params.safeParse(params));
|
|
@@ -163275,7 +163428,7 @@ function reverseCalls(o) {
|
|
|
163275
163428
|
if (method === "hub.projects") return { projects: o.projects() };
|
|
163276
163429
|
const p = HubMethods["hub.askProject"].params.safeParse(params);
|
|
163277
163430
|
if (!p.success) throw rpcError("Not an ask this computer reads");
|
|
163278
|
-
return o.ask(machine, p.data, signal);
|
|
163431
|
+
return o.ask(machine, p.data, signal, hold);
|
|
163279
163432
|
};
|
|
163280
163433
|
}
|
|
163281
163434
|
function read(parsed) {
|
|
@@ -163512,7 +163665,7 @@ function workJobLine(job) {
|
|
|
163512
163665
|
// packages/agent-host/src/dev-services/broker-pty.ts
|
|
163513
163666
|
import { spawn as startProcess } from "node:child_process";
|
|
163514
163667
|
import { existsSync as existsSync30 } from "node:fs";
|
|
163515
|
-
import { createRequire as
|
|
163668
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
163516
163669
|
import { createInterface as createInterface2 } from "node:readline";
|
|
163517
163670
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
163518
163671
|
function parseBrokerEvent(line) {
|
|
@@ -163688,7 +163841,7 @@ function openInHost(url2) {
|
|
|
163688
163841
|
} catch {
|
|
163689
163842
|
}
|
|
163690
163843
|
}
|
|
163691
|
-
var require4 =
|
|
163844
|
+
var require4 = createRequire5(import.meta.url);
|
|
163692
163845
|
function loadNodePty() {
|
|
163693
163846
|
const loaded = require4("node-pty");
|
|
163694
163847
|
if (!isPtyModule(loaded)) throw new Error("node-pty did not load as a terminal module");
|
|
@@ -163744,7 +163897,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
|
|
|
163744
163897
|
console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
|
|
163745
163898
|
process.exit(1);
|
|
163746
163899
|
}) : launch.token;
|
|
163747
|
-
var BUILD = true ? "
|
|
163900
|
+
var BUILD = true ? "e17e3b5" : "dev";
|
|
163748
163901
|
var { values } = parseArgs({
|
|
163749
163902
|
options: {
|
|
163750
163903
|
port: { type: "string", default: "5175" },
|
|
@@ -163955,7 +164108,7 @@ var installByDefault = installsByDefault({
|
|
|
163955
164108
|
var { auto: autoUpdateCheck, autoApply: autoApplyUpdates } = updateSwitches(store.settings, { installByDefault });
|
|
163956
164109
|
var themes = new ThemeFiles(join58(dataRoot(), "themes"), () => events.push({ type: "themes_changed" }));
|
|
163957
164110
|
await themes.start().catch((e) => console.error(`[themes] the themes folder is unavailable: ${e.message}`));
|
|
163958
|
-
var updates =
|
|
164111
|
+
var updates = realUpdateService((status) => events.push({ type: "update_status", status }), {
|
|
163959
164112
|
// A host from source never installs by itself, whatever is stored (#1501 review, `installsByItself`)
|
|
163960
164113
|
build: BUILD,
|
|
163961
164114
|
// On by default when nothing has been saved yet. Since the check is read-only and every failure
|
|
@@ -164090,7 +164243,7 @@ var links = new Links(linkDepsFor(store, {
|
|
|
164090
164243
|
reverse: reverseCalls({
|
|
164091
164244
|
allowed: (machineId) => store.machines.linkedMachineAsks(machineId),
|
|
164092
164245
|
projects: () => mgr.projectsForMachines(),
|
|
164093
|
-
ask: (machine, params, signal) => mgr.machineAsks.ask(machine, params, signal),
|
|
164246
|
+
ask: (machine, params, signal, hold) => mgr.machineAsks.ask(machine, params, signal, hold),
|
|
164094
164247
|
selfName: hubName,
|
|
164095
164248
|
// Every session on a machine mails every session this hub reaches, and finds them (#2067, docs/plans/linked-mail.md §5 to §8)
|
|
164096
164249
|
across: hostMailbox.across,
|
package/package.json
CHANGED