@centralu/win32-x64 0.1.0-beta.80 → 0.1.0-beta.81
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.
|
@@ -43046,7 +43046,7 @@ import { dirname as dirname27, join as join57 } from "node:path";
|
|
|
43046
43046
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync28, 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.81";
|
|
43050
43050
|
|
|
43051
43051
|
// packages/protocol/src/brand.ts
|
|
43052
43052
|
var APP_NAME = "Centralu";
|
|
@@ -60589,8 +60589,9 @@ var HubMailParams = external_exports.object({
|
|
|
60589
60589
|
report: TaskReport.optional()
|
|
60590
60590
|
});
|
|
60591
60591
|
var HubMailResult = external_exports.union([
|
|
60592
|
-
// `address`: the recipient as the hub names it, which the sender's copy is kept under
|
|
60593
|
-
|
|
60592
|
+
// `address`: the recipient as the hub names it, which the sender's copy is kept under. `quiet` (#2520, additive): the receiver, which owns its wake,
|
|
60593
|
+
// wrote it as an answer that wakes no one (D3); a side from before it never says, and its sender says nothing of it
|
|
60594
|
+
external_exports.object({ ok: external_exports.literal(true), messageId: external_exports.string().min(1).max(200), to: external_exports.string().max(500), address: external_exports.string().max(300).optional(), quiet: external_exports.literal(true).optional() }),
|
|
60594
60595
|
external_exports.object({ ok: external_exports.literal(false), why: external_exports.string().min(1).max(100), text: external_exports.string().max(4e3) })
|
|
60595
60596
|
]);
|
|
60596
60597
|
var HostMailParams = external_exports.object({
|
|
@@ -60912,6 +60913,8 @@ var hostParams = {
|
|
|
60912
60913
|
*/
|
|
60913
60914
|
"host.cards": external_exports.object({ sessionId: SessionId, caller: HubCaller }),
|
|
60914
60915
|
"host.answerCard": external_exports.object({ sessionId: SessionId, caller: HubCaller, card: external_exports.string().min(1).max(200), text: external_exports.string().max(2e4) }),
|
|
60916
|
+
/** The call of the hub's session `caller` that gave task `task` was cancelled: this host stops the turn that task alone started (#2485) */
|
|
60917
|
+
"host.stopTask": external_exports.object({ sessionId: SessionId, caller: HubCaller, task: external_exports.string().min(1).max(200) }),
|
|
60915
60918
|
/** docs/plans/remote-hub.md §13. Only on a connection a hub offered apps on; never routed */
|
|
60916
60919
|
"host.apps": LinkedAppsParams,
|
|
60917
60920
|
"host.appCall": LinkedAppCallParams,
|
|
@@ -60992,7 +60995,7 @@ var hostResults = {
|
|
|
60992
60995
|
}),
|
|
60993
60996
|
// As `hub.mail` answers (machines-hub.ts `HubMailResult`, which the window's bundle leaves out)
|
|
60994
60997
|
"host.mail": external_exports.union([
|
|
60995
|
-
external_exports.object({ ok: external_exports.literal(true), messageId: external_exports.string().min(1).max(200), to: external_exports.string().max(500), address: external_exports.string().max(300).optional() }),
|
|
60998
|
+
external_exports.object({ ok: external_exports.literal(true), messageId: external_exports.string().min(1).max(200), to: external_exports.string().max(500), address: external_exports.string().max(300).optional(), quiet: external_exports.literal(true).optional() }),
|
|
60996
60999
|
external_exports.object({ ok: external_exports.literal(false), why: external_exports.string().min(1).max(100), text: external_exports.string().max(4e3) })
|
|
60997
61000
|
]),
|
|
60998
61001
|
"host.mailRows": external_exports.object({ ok: external_exports.literal(true) }),
|
|
@@ -61000,6 +61003,7 @@ var hostResults = {
|
|
|
61000
61003
|
"host.mailMove": external_exports.union([external_exports.object({ ok: external_exports.literal(true), moved: external_exports.number().int().min(0) }), external_exports.object({ ok: external_exports.literal(false), why: external_exports.string().min(1).max(100), text: external_exports.string().max(4e3) })]),
|
|
61001
61004
|
"host.cards": external_exports.object({ cards: external_exports.array(external_exports.object({ card: external_exports.string().max(200), requestId: external_exports.string().max(200), kind: external_exports.enum(["question", "approval"]), answerable: external_exports.boolean() })).max(50) }),
|
|
61002
61005
|
"host.answerCard": external_exports.object({ ok: external_exports.literal(true) }),
|
|
61006
|
+
"host.stopTask": external_exports.object({ stopped: external_exports.boolean() }),
|
|
61003
61007
|
"host.apps": LinkedAppsResult,
|
|
61004
61008
|
"host.appCall": LinkedAppCallResult,
|
|
61005
61009
|
"host.appCancel": external_exports.object({ ok: external_exports.literal(true) }),
|
|
@@ -66095,6 +66099,7 @@ var METHOD_RIGHTS = {
|
|
|
66095
66099
|
"host.mailMove": "link",
|
|
66096
66100
|
"host.cards": "link",
|
|
66097
66101
|
"host.answerCard": "link",
|
|
66102
|
+
"host.stopTask": "link",
|
|
66098
66103
|
// From a hub that offered apps on the same connection only (rpc.ts), as `host.mail` (#1938)
|
|
66099
66104
|
"host.apps": "link",
|
|
66100
66105
|
"host.appCall": "link",
|
|
@@ -104146,16 +104151,16 @@ function readBook(raw) {
|
|
|
104146
104151
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { assigned: {}, retired: [] };
|
|
104147
104152
|
const { assigned, retired, ...rest } = raw;
|
|
104148
104153
|
const book = { ...rest, assigned: {}, retired: [] };
|
|
104149
|
-
const
|
|
104154
|
+
const unread4 = [];
|
|
104150
104155
|
if (assigned && typeof assigned === "object") {
|
|
104151
104156
|
for (const [k2, v] of Object.entries(assigned)) {
|
|
104152
104157
|
if (validPort(v)) book.assigned[k2] = v;
|
|
104153
|
-
else portsIn(v,
|
|
104158
|
+
else portsIn(v, unread4);
|
|
104154
104159
|
}
|
|
104155
104160
|
}
|
|
104156
|
-
if (Array.isArray(retired)) for (const p of retired) (validPort(p) ? book.retired :
|
|
104161
|
+
if (Array.isArray(retired)) for (const p of retired) (validPort(p) ? book.retired : unread4).push(...portsIn(p));
|
|
104157
104162
|
const used = /* @__PURE__ */ new Set([...Object.values(book.assigned), ...book.retired]);
|
|
104158
|
-
for (const p of
|
|
104163
|
+
for (const p of unread4) {
|
|
104159
104164
|
if (used.has(p)) continue;
|
|
104160
104165
|
used.add(p);
|
|
104161
104166
|
book.retired.push(p);
|
|
@@ -105225,7 +105230,7 @@ function taskLine(task, max = 160) {
|
|
|
105225
105230
|
const flat = oneLineText(task);
|
|
105226
105231
|
return flat.length > max ? `${flat.slice(0, max)}\u2026 (cut here; ${flat.length} characters in all)` : flat;
|
|
105227
105232
|
}
|
|
105228
|
-
var ANSWER_GROUNDS = "In your answer, say what each claim rests on (a file, a command's output, a message) and mark what you did not check as unchecked.";
|
|
105233
|
+
var ANSWER_GROUNDS = "In your answer, say what each claim rests on (a file, a command's output, a message) and mark what you did not check as unchecked. Name each part of the task you did not do, with the issue that carries it or why it was dropped.";
|
|
105229
105234
|
function askBeforeFinish(to) {
|
|
105230
105235
|
return `To ask it something before you finish, call mail with \`to: "${to}"\` and \`kind: "question"\``;
|
|
105231
105236
|
}
|
|
@@ -105597,7 +105602,7 @@ var AcrossCore = class {
|
|
|
105597
105602
|
if (!parsed.success) return { ok: false, why: "link_down", maybe: true, text: `${peer.name} answered in a form this computer does not read, so it is not known whether the message arrived. ${AGAIN}` };
|
|
105598
105603
|
const r = parsed.data;
|
|
105599
105604
|
if (!r.ok) return { ok: false, why: /^[a-z_]{1,40}$/.test(r.why) ? r.why : "refused", text: r.text.length > 4e3 ? `${r.text.slice(0, 4e3)}\u2026` : r.text };
|
|
105600
|
-
return { ok: true, messageId: oneLineText(r.messageId, 200), to: oneLineText(r.to, 120), ...r.address ? { address: r.address } : {} };
|
|
105605
|
+
return { ok: true, messageId: oneLineText(r.messageId, 200), to: oneLineText(r.to, 120), ...r.address ? { address: r.address } : {}, ...r.quiet ? { quiet: true } : {} };
|
|
105601
105606
|
}
|
|
105602
105607
|
/** A session here as the other side's answer names it, to `reader` there in its terms; written whatever its label */
|
|
105603
105608
|
label(to, reader) {
|
|
@@ -107261,10 +107266,10 @@ function remoteAgentFrame(parentName, task, instructions = "") {
|
|
|
107261
107266
|
}
|
|
107262
107267
|
function agentBranch(task, id3, max = 35) {
|
|
107263
107268
|
const full = task.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
107264
|
-
let
|
|
107265
|
-
if (full.length > max && full[max] !== "-" &&
|
|
107266
|
-
|
|
107267
|
-
return `${APP_SLUG}/${
|
|
107269
|
+
let slug2 = full.slice(0, max);
|
|
107270
|
+
if (full.length > max && full[max] !== "-" && slug2.includes("-")) slug2 = slug2.slice(0, slug2.lastIndexOf("-"));
|
|
107271
|
+
slug2 = slug2.replace(/-+$/, "");
|
|
107272
|
+
return `${APP_SLUG}/${slug2 || "agent"}-${id3.replace(/[^a-z0-9]/gi, "").slice(0, 4).toLowerCase()}`;
|
|
107268
107273
|
}
|
|
107269
107274
|
function agentName(task, max = 48) {
|
|
107270
107275
|
return oneLineText(task, max) || "Agent";
|
|
@@ -107544,14 +107549,17 @@ function agentRunText(r) {
|
|
|
107544
107549
|
text: `No session yet: starting ${r.tool} is waiting for the person's answer on the card in your session (request ${r.sessionId}). Carry on with other work, and do not do this with your own subagents instead. If they allow it, the session starts and you will be told when its turn ends; if they refuse or it is withdrawn, you will be told. ${NO_POLLING} agent_session(sessionId="${r.sessionId}", action="wait") waits for the answer, action="stop" withdraws the request.`
|
|
107545
107550
|
};
|
|
107546
107551
|
}
|
|
107547
|
-
const who = `the ${r.tool} session "${r.sessionName}" [${r.sessionId}]` + (r.via === "fork" ? `, a fork of [${r.forkedFrom}]` : "");
|
|
107552
|
+
const who = `the ${r.tool ? `${r.tool} ` : ""}session "${r.sessionName}" [${r.sessionId}]` + (r.via === "fork" ? `, a fork of [${r.forkedFrom}]` : "");
|
|
107548
107553
|
return agentStateText(r, who);
|
|
107549
107554
|
}
|
|
107555
|
+
function askedWait(project2, sessionId) {
|
|
107556
|
+
return `To wait for its answer, call ask_project with ${project2 ? `project "${project2}"` : "its project"}, session "${sessionId}" and no task.`;
|
|
107557
|
+
}
|
|
107550
107558
|
function agentStateText(r, who) {
|
|
107551
107559
|
switch (r.state) {
|
|
107552
107560
|
case "working":
|
|
107553
107561
|
return {
|
|
107554
|
-
text: `${who} is working on it${r.notice ? ` \u2014 ${r.notice}` : ""}.${progressText(r.progress)} ` + (r.reported ? `You will be told when it ends. ${NO_POLLING} ` : "") + `agent_session(sessionId="${r.sessionId}", action="wait") waits for its answer, action="stop" stops it.`
|
|
107562
|
+
text: `${who} is working on it${r.notice ? ` \u2014 ${r.notice}` : ""}.${progressText(r.progress)} ` + (r.reported ? `You will be told when it ends. ${NO_POLLING} ` : "") + (r.askedOf !== void 0 ? askedWait(r.askedOf, r.sessionId) : `agent_session(sessionId="${r.sessionId}", action="wait") waits for its answer, action="stop" stops it.`)
|
|
107555
107563
|
};
|
|
107556
107564
|
case "asking":
|
|
107557
107565
|
return {
|
|
@@ -107562,7 +107570,7 @@ agent_session(sessionId="${r.sessionId}", action="answer", card=\u2026, text=\u2
|
|
|
107562
107570
|
case "mailed":
|
|
107563
107571
|
return { text: `${mailedText(r, "mail")} agent_session(sessionId="${r.sessionId}", action="stop") withdraws it until it is delivered.` };
|
|
107564
107572
|
case "answered":
|
|
107565
|
-
return { text: `Answered card ${r.card} in ${who}; it goes on. agent_session(sessionId="${r.sessionId}", action="wait") waits for its answer.` };
|
|
107573
|
+
return { text: `Answered card ${r.card} in ${who}; it goes on. ${r.askedOf !== void 0 ? askedWait(r.askedOf, r.sessionId) : `agent_session(sessionId="${r.sessionId}", action="wait") waits for its answer.`}` };
|
|
107566
107574
|
case "stopped":
|
|
107567
107575
|
if (!r.sessionName) return { text: `Withdrew request ${r.sessionId}: its card is gone and no session was started.` };
|
|
107568
107576
|
return { text: `Stopped ${who}.${r.notice ? ` ${r.notice}` : ""}` };
|
|
@@ -108905,7 +108913,7 @@ var MailDelivery = class {
|
|
|
108905
108913
|
if (attempts >= this.o.maxAttempts) {
|
|
108906
108914
|
this.records.transaction(() => {
|
|
108907
108915
|
this.records.failedTry(recipient, messageIds, error51, this.now());
|
|
108908
|
-
this.service.hold(recipient, messageIds.map((messageId) => ({ messageId, reason: "failed" })));
|
|
108916
|
+
this.service.holds.hold(recipient, messageIds.map((messageId) => ({ messageId, reason: "failed" })));
|
|
108909
108917
|
});
|
|
108910
108918
|
this.tellHeldFailed(recipient, messageIds, error51);
|
|
108911
108919
|
return;
|
|
@@ -108938,14 +108946,14 @@ var MailDelivery = class {
|
|
|
108938
108946
|
* The tool failed a wake after the wait for it ran out and the wake was counted as taken (§7.6.2). Counted as taken, the mail was
|
|
108939
108947
|
* delivered and read; failed, it must not stay so. It is not sent again by itself, though: a failure told this late (the session was
|
|
108940
108948
|
* stopped or closed, a turn that took the input among others ended in an error) does not prove the tool never ran it, and sending
|
|
108941
|
-
* work twice is worse than asking. So it is treated as a restart's uncertain delivery (§7.6.5, `
|
|
108949
|
+
* work twice is worse than asking. So it is treated as a restart's uncertain delivery (§7.6.5, `HeldMail.deliveryFailedLate`): unread
|
|
108942
108950
|
* and undelivered again, held `uncertain` for the person (Inbox: Send again), said in the thread to the sender and in the receiver's
|
|
108943
108951
|
* conversation, and never sent again by itself, unless it is news that starts no work. Only the receipts that wake delivered:
|
|
108944
108952
|
* mail delivered again since by another wake, handled, or held is left alone
|
|
108945
108953
|
*/
|
|
108946
108954
|
takeBack(recipient, messageIds, deliveredAt, cause2) {
|
|
108947
108955
|
console.error(`[mail] ${recipient}: the tool failed a wake after it had been counted as taken (${errorMessage(cause2)}); not sent again by itself`);
|
|
108948
|
-
const { held: held3 } = this.service.deliveryFailedLate(recipient, messageIds, deliveredAt);
|
|
108956
|
+
const { held: held3 } = this.service.holds.deliveryFailedLate(recipient, messageIds, deliveredAt);
|
|
108949
108957
|
const party = parseAddress(recipient);
|
|
108950
108958
|
if (held3 > 0 && party?.kind === "session") {
|
|
108951
108959
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
@@ -108955,7 +108963,7 @@ var MailDelivery = class {
|
|
|
108955
108963
|
/** A delivery the previous host left half done is held or sent again (`reconcileInterrupted`), and the receiver is told when it is held */
|
|
108956
108964
|
sayWhatWasLeftHalfDone() {
|
|
108957
108965
|
try {
|
|
108958
|
-
for (const { recipient, held: held3 } of this.service.reconcileInterrupted()) {
|
|
108966
|
+
for (const { recipient, held: held3 } of this.service.holds.reconcileInterrupted()) {
|
|
108959
108967
|
const party = parseAddress(recipient);
|
|
108960
108968
|
if (held3 > 0 && party?.kind === "session") {
|
|
108961
108969
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
@@ -109019,7 +109027,7 @@ var MailDelivery = class {
|
|
|
109019
109027
|
const drain = (skipping) => this.service.drain(recipient, { ...skipping ? { skip: skipping } : {}, ...state.joins ? { joining: true } : {} });
|
|
109020
109028
|
let drained2 = drain(skip);
|
|
109021
109029
|
if (!waiting && state.live && this.cutoff !== null && drained2.wake) drained2 = drain(void 0);
|
|
109022
|
-
this.service.hold(recipient, drained2.heldBack);
|
|
109030
|
+
this.service.holds.hold(recipient, drained2.heldBack);
|
|
109023
109031
|
if (drained2.messageIds.length === 0) return { drained: drained2, go: false, waitMs: 0 };
|
|
109024
109032
|
const goesAtTurnEnd = this.delegatedTask(drained2) !== void 0 && this.turns?.current(sessionId) === void 0;
|
|
109025
109033
|
if (drained2.wake && !drained2.immediate && !state.joins && !goesAtTurnEnd) {
|
|
@@ -111957,6 +111965,14 @@ ${spentWords(tries)}` } };
|
|
|
111957
111965
|
stands(sessionId) {
|
|
111958
111966
|
return this.held.get(sessionId)?.phase === "waiting";
|
|
111959
111967
|
}
|
|
111968
|
+
/**
|
|
111969
|
+
* Whether the session's turn waits to be continued, with nothing running: a held retry, a network or limit stop's wait, or a turn an update cut. A
|
|
111970
|
+
* Stop ends that wait and the turn (`TurnInputs.interrupt`, `cancel`)
|
|
111971
|
+
*/
|
|
111972
|
+
waitsToContinue(sessionId) {
|
|
111973
|
+
const u = this.updates.get(sessionId);
|
|
111974
|
+
return this.stops.has(sessionId) || this.held.has(sessionId) || !!u && u.phase !== "waking" && !!u.turn;
|
|
111975
|
+
}
|
|
111960
111976
|
/**
|
|
111961
111977
|
* The person's Stop, or an end of the turn: takes the session's waits away. Returns where a held retry was, or null when none
|
|
111962
111978
|
* stood. Handed, the tool's turn is running and is the caller's to stop
|
|
@@ -112332,8 +112348,8 @@ function labelHere(offered, name, taken) {
|
|
|
112332
112348
|
return (offered === null ? null : unique(offered, t)) ?? hubLabel(name, t);
|
|
112333
112349
|
}
|
|
112334
112350
|
function slugOf(name) {
|
|
112335
|
-
const
|
|
112336
|
-
return
|
|
112351
|
+
const slug2 = name.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "").slice(0, 24);
|
|
112352
|
+
return slug2 && MACHINE_ID_RE.test(slug2) ? slug2 : null;
|
|
112337
112353
|
}
|
|
112338
112354
|
function unique(base2, taken) {
|
|
112339
112355
|
if (!taken.has(base2)) return base2;
|
|
@@ -112887,8 +112903,8 @@ var SessionAppsHub = class {
|
|
|
112887
112903
|
let server2 = book[key2];
|
|
112888
112904
|
if (!server2) {
|
|
112889
112905
|
const base2 = appServerName(a.appId);
|
|
112890
|
-
const
|
|
112891
|
-
server2 = !taken.has(base2) ? base2 : freeServerName(a.appId, taken,
|
|
112906
|
+
const slug2 = a.projectId ? nameSlug(this.opts.projectName?.(a.projectId) ?? "") || a.projectId.slice(0, 8).toLowerCase() : "user";
|
|
112907
|
+
server2 = !taken.has(base2) ? base2 : freeServerName(a.appId, taken, slug2);
|
|
112892
112908
|
book[key2] = server2;
|
|
112893
112909
|
taken.add(server2);
|
|
112894
112910
|
added = true;
|
|
@@ -114043,7 +114059,7 @@ var MailFacts = external_exports.looseObject({
|
|
|
114043
114059
|
asker: external_exports.string().optional(),
|
|
114044
114060
|
/** On Centralu's notice to a giver of a session's open work (docs/plans/mailbox.md §10.6.4): the card the session raised, never its text */
|
|
114045
114061
|
card: external_exports.object({ session: external_exports.string(), requestId: external_exports.string(), handle: external_exports.string(), kind: external_exports.enum(["question", "approval"]) }).optional(),
|
|
114046
|
-
/** On Centralu's notice of moved mail; on a task a handoff gave again from the heir (`
|
|
114062
|
+
/** On Centralu's notice of moved mail; on a task a handoff gave again from the heir (`Handoffs.handOver`): its words are the previous giver's */
|
|
114047
114063
|
handedOver: external_exports.boolean().optional(),
|
|
114048
114064
|
legacyKind: external_exports.string().optional(),
|
|
114049
114065
|
/** The recipients an older build's person released a moved message to: never held again for them (§6.3) */
|
|
@@ -114298,6 +114314,14 @@ var MailboxRecords = class {
|
|
|
114298
114314
|
movedTo(sender, recipient) {
|
|
114299
114315
|
return this.messages(`m.sender = ? AND m.legacy_thread IS NOT NULL AND EXISTS (SELECT 1 FROM mail_recipients r WHERE r.message_id = m.id AND r.recipient = ?) LIMIT 1`, sender, recipient).length > 0;
|
|
114300
114316
|
}
|
|
114317
|
+
/** The oldest task of `origin` to `recipient`, settled or not: the start_agent task a hub's session started a session here with names that session */
|
|
114318
|
+
firstTask(recipient, origin) {
|
|
114319
|
+
return this.messages(
|
|
114320
|
+
`m.id IN (SELECT message_id FROM mail_recipients WHERE recipient = ?) AND m.kind = 'task' AND m.origin = ? ORDER BY m.created_at, m.id LIMIT 1`,
|
|
114321
|
+
recipient,
|
|
114322
|
+
origin
|
|
114323
|
+
)[0];
|
|
114324
|
+
}
|
|
114301
114325
|
/** The newest task from `sender` whose row to `recipient` is not settled */
|
|
114302
114326
|
newestTask(sender, recipient) {
|
|
114303
114327
|
return this.messages(
|
|
@@ -114766,11 +114790,11 @@ var MailboxRecords = class {
|
|
|
114766
114790
|
* A handoff: `from`'s rows that are watched and not settled, or not read (settled or not: a moved `legacy` row too),
|
|
114767
114791
|
* go to `to`, in `scope`. A row not read is delivered
|
|
114768
114792
|
* afresh, with the holds about `from`'s delivery let go. Its reminders were `from`'s: their count and clock start again at `to` (docs/plans/mailbox.md §10.11). When `to` already has a row for the message, or sent it, `to`'s
|
|
114769
|
-
* side stays as it is: `from`'s row is deleted, or (for `to`'s own message) left. Returns the ids of the messages moved
|
|
114793
|
+
* side stays as it is: `from`'s row is deleted, or (for `to`'s own message) left. `only`: of those, these messages alone. Returns the ids of the messages moved
|
|
114770
114794
|
*/
|
|
114771
|
-
moveRows(from, to, scope) {
|
|
114795
|
+
moveRows(from, to, scope, only) {
|
|
114772
114796
|
return this.transaction(() => {
|
|
114773
|
-
const ids = this.movable(from, to, scope);
|
|
114797
|
+
const ids = this.movable(from, to, scope).filter((id3) => !only || only.includes(id3));
|
|
114774
114798
|
this.db.prepare(
|
|
114775
114799
|
`UPDATE OR IGNORE mail_recipients SET recipient = @to, turn_seq = NULL, reminded = 0, reminded_at = NULL,
|
|
114776
114800
|
delivered_at = CASE WHEN read_at IS NULL THEN NULL ELSE delivered_at END,
|
|
@@ -114855,12 +114879,12 @@ var MailboxRecords = class {
|
|
|
114855
114879
|
(r.settled IS NULL AND r.released_at IS NULL AND ${WATCHED})
|
|
114856
114880
|
OR (r.delivered_at IS NULL AND ${WAITING})
|
|
114857
114881
|
OR (${HELD})))`;
|
|
114858
|
-
const
|
|
114882
|
+
const unread4 = `EXISTS (SELECT 1 FROM mail_recipients r WHERE r.message_id = m.id AND r.read_at IS NULL)`;
|
|
114859
114883
|
const pick5 = this.db.prepare(
|
|
114860
114884
|
`SELECT m.id FROM mail m
|
|
114861
114885
|
WHERE m.created_at <= @waiting
|
|
114862
114886
|
OR (m.created_at <= @settled AND NOT ${waits})
|
|
114863
|
-
OR (m.kind = 'notice' AND m.created_at <= @notice AND NOT ${waits} AND NOT ${
|
|
114887
|
+
OR (m.kind = 'notice' AND m.created_at <= @notice AND NOT ${waits} AND NOT ${unread4})
|
|
114864
114888
|
ORDER BY m.created_at LIMIT @batch`
|
|
114865
114889
|
);
|
|
114866
114890
|
let messages2 = 0;
|
|
@@ -120284,7 +120308,22 @@ var SessionStarts = class {
|
|
|
120284
120308
|
...o.outputSchema ? { outputSchema: o.outputSchema } : {}
|
|
120285
120309
|
};
|
|
120286
120310
|
}
|
|
120287
|
-
|
|
120311
|
+
/**
|
|
120312
|
+
* A conversation the tool itself says it has no record of (`conversation_gone`), in a session the agent never wrote into (#2479): nothing of it is lost, so the
|
|
120313
|
+
* session starts a new conversation instead of failing to wake. Cursor keeps a conversation only once a model turn has run, so
|
|
120314
|
+
* a session opened and never answered is refused at every wake (#1676); once idle sessions sleep, each of them would hit it.
|
|
120315
|
+
* Null (the wake fails as it did) when the agent has written anything here, or the session was imported.
|
|
120316
|
+
*/
|
|
120317
|
+
async startOver(m, tool) {
|
|
120318
|
+
if (m.importedFrom || this.host.store.messages.hasAgentRows(m.id)) return null;
|
|
120319
|
+
if (this.host.leaving.has(m.id) || !this.host.meta.has(m.id) || m.tool !== tool) return null;
|
|
120320
|
+
console.error(`[agent-host] ${m.id.slice(0, 8)} tool=${m.tool}: conversation ${m.externalId ?? "?"} is gone and the agent wrote nothing here, starting a new one`);
|
|
120321
|
+
m.externalId = null;
|
|
120322
|
+
this.host.store.sessions.upsertSession(m);
|
|
120323
|
+
this.host.store.settings.setAppSetting(freshStartKey(m.id), String(this.host.store.messages.loadMessages(m.id, 1)[0]?.seq ?? 0));
|
|
120324
|
+
return this.doResumeSession(m.id, true);
|
|
120325
|
+
}
|
|
120326
|
+
async doResumeSession(sessionId, startedOver = false) {
|
|
120288
120327
|
const m = this.host.openSession(sessionId);
|
|
120289
120328
|
if (this.host.handles.has(sessionId)) return { session: m, resumed: true };
|
|
120290
120329
|
const tool = m.tool;
|
|
@@ -120416,7 +120455,12 @@ var SessionStarts = class {
|
|
|
120416
120455
|
return { session: m, resumed: true };
|
|
120417
120456
|
} catch (err) {
|
|
120418
120457
|
this.host.modelWindows.forget(sessionId);
|
|
120419
|
-
const
|
|
120458
|
+
const toldGone = err instanceof Error && Reflect.get(err, "code") === "conversation_gone";
|
|
120459
|
+
if (toldGone && !startedOver) {
|
|
120460
|
+
const again = await this.startOver(m, tool);
|
|
120461
|
+
if (again) return again;
|
|
120462
|
+
}
|
|
120463
|
+
const gone3 = toldGone || await withTimeout(this.host.externals.externalGone(m, cwd), 8e3, "Checking the tool").catch(() => false);
|
|
120420
120464
|
if (gone3) {
|
|
120421
120465
|
return { session: m, resumed: false, reason: externalMissingReason(this.host.toolLabel(m.tool), cwd) };
|
|
120422
120466
|
}
|
|
@@ -121850,6 +121894,9 @@ var AgentSessionActions = class {
|
|
|
121850
121894
|
}
|
|
121851
121895
|
const remote = opts.sessionId.includes(".") ? this.flow.remote.of(opts.sessionId) : void 0;
|
|
121852
121896
|
if (remote) return this.flow.remote.agentSession(callerId, remote, opts, signal);
|
|
121897
|
+
if (opts.sessionId.includes(".") && this.host.linkedReader?.machineOf(opts.sessionId) && this.host.linkedTasks?.open(callerId, opts.sessionId)) {
|
|
121898
|
+
return this.flow.remote.askedThere(callerId, opts.sessionId, opts);
|
|
121899
|
+
}
|
|
121853
121900
|
const gone2 = this.flow.handedOverAnswer(callerId, opts.sessionId);
|
|
121854
121901
|
if (gone2) return gone2;
|
|
121855
121902
|
const request = this.host.children.agentStarts.get(opts.sessionId);
|
|
@@ -122085,6 +122132,8 @@ var RemoteAgents = class {
|
|
|
122085
122132
|
loaded = null;
|
|
122086
122133
|
/** The calls waiting on a child's report, each ended at once when the child is deleted there (`observe`) */
|
|
122087
122134
|
waits = /* @__PURE__ */ new Map();
|
|
122135
|
+
/** The waits woken by a card a machine's session raised (`untilCard`): session -> wakers */
|
|
122136
|
+
cardWaits = /* @__PURE__ */ new Map();
|
|
122088
122137
|
/**
|
|
122089
122138
|
* At startup: a record a build before #1948 step 6 kept owed its caller the end of the child's turn by the relayed report, which is gone. Its
|
|
122090
122139
|
* caller is told once, in one notice for all its children, where to read it, and the old fields are dropped, so no later start tells it again
|
|
@@ -122160,7 +122209,7 @@ var RemoteAgents = class {
|
|
|
122160
122209
|
}
|
|
122161
122210
|
/**
|
|
122162
122211
|
* A handoff gave the original's work to `to` (#693): its children on linked machines are the heir's. Returns them, whose tasks the handoff moves
|
|
122163
|
-
* with the original's mail (`
|
|
122212
|
+
* with the original's mail (`Handoffs.handOver`, #1948 step 6)
|
|
122164
122213
|
*/
|
|
122165
122214
|
moveCaller(from, to) {
|
|
122166
122215
|
const moving = this.records().filter((r) => r.callerId === from);
|
|
@@ -122352,6 +122401,28 @@ var RemoteAgents = class {
|
|
|
122352
122401
|
const sent = tasks ? await tasks.send(callerId, rec.sessionId, text3, { origin: "agent_session", note: true }) : { ok: false, text: NO_MAIL };
|
|
122353
122402
|
return sent.ok ? { ok: true, messageId: sent.messageId, name: `${rec.name} on ${rec.machine}` } : { ok: false, error: `Could not send to "${rec.name}" on ${rec.machine}: ${bare(sent.text)}.` };
|
|
122354
122403
|
}
|
|
122404
|
+
/**
|
|
122405
|
+
* agent_session on a machine's session the caller gave an ask_project task that is not settled (#2485), as on one here (docs/plans/mailbox.md
|
|
122406
|
+
* §10.6.4): its cards are the caller's to read and to answer as that machine's rule lets it; nothing else of that session is, and ask_project
|
|
122407
|
+
* with no task waits on it
|
|
122408
|
+
*/
|
|
122409
|
+
async askedThere(callerId, sessionId, opts) {
|
|
122410
|
+
const reader = this.host.linkedReader;
|
|
122411
|
+
const machine = reader?.machineOf(sessionId);
|
|
122412
|
+
if (!reader || !machine) return { ok: false, error: `${sessionId} is on a linked machine, and no machine is linked to this computer now.` };
|
|
122413
|
+
const seen = reader.describe(sessionId);
|
|
122414
|
+
const there = { sessionId, callerId, name: seen?.name ?? sessionId, machine, tool: "" };
|
|
122415
|
+
const askedOf = seen ? `${sessionId.slice(0, sessionId.indexOf("."))}/${seen.projectName}` : "";
|
|
122416
|
+
if (opts.action === "answer") {
|
|
122417
|
+
const r = await this.answer(there, opts.card, opts.text ?? "", reader);
|
|
122418
|
+
return r.ok ? { ...r, askedOf } : r;
|
|
122419
|
+
}
|
|
122420
|
+
if (opts.action !== "status") {
|
|
122421
|
+
return { ok: false, error: `"${there.name}" is another project's session: you can read and answer the cards of the work you gave it (status, answer). To wait on it, call ask_project with ${askedOf ? `project "${askedOf}"` : "its project"}, session "${sessionId}" and no task.` };
|
|
122422
|
+
}
|
|
122423
|
+
const cards = await this.cardsOf(there, reader);
|
|
122424
|
+
return cards.length ? this.asking(there, cards) : { ...this.working(there, false), askedOf };
|
|
122425
|
+
}
|
|
122355
122426
|
async act(callerId, rec, opts, signal) {
|
|
122356
122427
|
if (rec.callerId !== callerId) return { ok: false, error: `${rec.sessionId} is not a session this session started. agent_session works only on sessions start_agent started from here.` };
|
|
122357
122428
|
const reader = this.host.linkedReader;
|
|
@@ -122443,11 +122514,30 @@ var RemoteAgents = class {
|
|
|
122443
122514
|
*/
|
|
122444
122515
|
observe(e) {
|
|
122445
122516
|
if (e.type === "machine_resync") return void this.caughtUp(e.machineId);
|
|
122517
|
+
if ((e.type === "question_request" || e.type === "approval_request") && typeof e.sessionId === "string") {
|
|
122518
|
+
for (const wake of [...this.cardWaits.get(e.sessionId) ?? []]) wake();
|
|
122519
|
+
return;
|
|
122520
|
+
}
|
|
122446
122521
|
if (e.type !== "session_deleted" || typeof e.sessionId !== "string" || !this.of(e.sessionId)) return;
|
|
122447
122522
|
this.forget(e.sessionId);
|
|
122448
122523
|
for (const end of [...this.waits.get(e.sessionId) ?? []]) end();
|
|
122449
122524
|
}
|
|
122450
122525
|
// ── Waits ───────────────────────────────────────────────────────────────────────────────
|
|
122526
|
+
/** Resolves once a machine's session (`sessionId`, qualified) raises a card, as its relayed event says; `done` stops the wait */
|
|
122527
|
+
untilCard(sessionId) {
|
|
122528
|
+
let wake;
|
|
122529
|
+
const raised = new Promise((resolve21) => wake = resolve21);
|
|
122530
|
+
const wakers = this.cardWaits.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
122531
|
+
wakers.add(wake);
|
|
122532
|
+
this.cardWaits.set(sessionId, wakers);
|
|
122533
|
+
return {
|
|
122534
|
+
raised,
|
|
122535
|
+
done: () => {
|
|
122536
|
+
wakers.delete(wake);
|
|
122537
|
+
if (!wakers.size && this.cardWaits.get(sessionId) === wakers) this.cardWaits.delete(sessionId);
|
|
122538
|
+
}
|
|
122539
|
+
};
|
|
122540
|
+
}
|
|
122451
122541
|
/**
|
|
122452
122542
|
* Waits up to the bound for Centralu's report on the caller's task `taskId` (#1948 step 6), which comes back from the machine as mail; or for the
|
|
122453
122543
|
* task to end with none (withdrawn, released there). Past the bound the child is working, and the report reaches the caller as mail
|
|
@@ -123511,6 +123601,10 @@ var MailSessionsView = class {
|
|
|
123511
123601
|
withdrawTasks(callerId, sessionId) {
|
|
123512
123602
|
return this.hooks?.withdrawTasks?.(callerId, sessionId) ?? 0;
|
|
123513
123603
|
}
|
|
123604
|
+
/** `MailHooks.cancelGiven`; false without a mailbox */
|
|
123605
|
+
cancelGiven(sessionId, giver, taskId) {
|
|
123606
|
+
return this.hooks?.cancelGiven?.(sessionId, giver, taskId) ?? false;
|
|
123607
|
+
}
|
|
123514
123608
|
/** The session still takes mail as the delivery planned it: woken at rest, or joining its turn. Otherwise the mail waits (`MailNotAtRest`) and is planned again */
|
|
123515
123609
|
takesAsPlanned(id3, joins) {
|
|
123516
123610
|
const r = this.mailReceiver(id3);
|
|
@@ -125903,19 +125997,23 @@ var CoreSession = class {
|
|
|
125903
125997
|
proc.on("error", (err) => gone2(null, err));
|
|
125904
125998
|
}
|
|
125905
125999
|
send(text3, opts) {
|
|
125906
|
-
void this.enqueue(text3, opts?.id ?? null, opts?.compact === true);
|
|
126000
|
+
void this.enqueue(text3, opts?.id ?? null, opts?.compact === true, void 0, opts?.origin);
|
|
125907
126001
|
}
|
|
125908
126002
|
sendTracked(text3, observer, opts) {
|
|
125909
|
-
return this.enqueue(text3, opts?.id ?? null, false, observer);
|
|
126003
|
+
return this.enqueue(text3, opts?.id ?? null, false, observer, opts?.origin);
|
|
125910
126004
|
}
|
|
125911
|
-
enqueue(text3, named3, compact, observer) {
|
|
126005
|
+
enqueue(text3, named3, compact, observer, origin) {
|
|
125912
126006
|
const receipt = this.receipts.create(observer);
|
|
125913
126007
|
if (this.phase === "closed") {
|
|
125914
126008
|
this.receipts.fail([receipt.id], new Error(`${this.wire.label} session is closed`));
|
|
125915
126009
|
return receipt.done;
|
|
125916
126010
|
}
|
|
125917
126011
|
this.queue.push({ input: { id: receipt.id, text: text3, compact }, named: named3 });
|
|
125918
|
-
this.
|
|
126012
|
+
if (this.turn && this.wire.turns.interruptForInput && origin?.kind === "human") {
|
|
126013
|
+
this.interruptForInput();
|
|
126014
|
+
} else {
|
|
126015
|
+
this.drain();
|
|
126016
|
+
}
|
|
125919
126017
|
return receipt.done;
|
|
125920
126018
|
}
|
|
125921
126019
|
/** The names of the inputs the last turn took (`SessionHandle.turnInputs`) */
|
|
@@ -126026,6 +126124,24 @@ var CoreSession = class {
|
|
|
126026
126124
|
this.process.interrupt();
|
|
126027
126125
|
}
|
|
126028
126126
|
}
|
|
126127
|
+
/** A new human input interrupts the running turn so it can run immediately, without dropping the queue */
|
|
126128
|
+
interruptForInput() {
|
|
126129
|
+
const turn = this.turn;
|
|
126130
|
+
if (!turn || this.phase !== "ready" || turn.stopAsked) return;
|
|
126131
|
+
turn.stopAsked = true;
|
|
126132
|
+
this.wire.interrupt?.();
|
|
126133
|
+
this.wire.releaseCards();
|
|
126134
|
+
if (!turn.stopTimer) {
|
|
126135
|
+
turn.stopTimer = setTimeout(() => {
|
|
126136
|
+
if (this.turn === turn) this.emit(stopNotEnded(this.sessionId, this.wire.label));
|
|
126137
|
+
}, this.stopConfirmMs);
|
|
126138
|
+
turn.stopTimer.unref?.();
|
|
126139
|
+
}
|
|
126140
|
+
if (this.wire.turns.interruptEndsProcess) {
|
|
126141
|
+
this.expectedExits.add(turn.proc);
|
|
126142
|
+
this.process.interrupt();
|
|
126143
|
+
}
|
|
126144
|
+
}
|
|
126029
126145
|
endTurn(turn, ending, events2) {
|
|
126030
126146
|
if (this.turn !== turn || this.phase === "closed") return;
|
|
126031
126147
|
if (turn.stopTimer) clearTimeout(turn.stopTimer);
|
|
@@ -126741,7 +126857,7 @@ var InitializeResult = external_exports.looseObject({
|
|
|
126741
126857
|
),
|
|
126742
126858
|
agentInfo: nullish3(external_exports.looseObject({ name: nullish3(external_exports.string()), version: nullish3(external_exports.string()) }))
|
|
126743
126859
|
});
|
|
126744
|
-
var SelectOption = external_exports.looseObject({ value: external_exports.string(), name:
|
|
126860
|
+
var SelectOption = external_exports.looseObject({ value: external_exports.string(), name: external_exports.string().nullish().optional() });
|
|
126745
126861
|
var ConfigOption = external_exports.looseObject({
|
|
126746
126862
|
id: external_exports.string(),
|
|
126747
126863
|
category: nullish3(external_exports.string()),
|
|
@@ -127114,8 +127230,15 @@ var AcpSession = class extends CoreSession {
|
|
|
127114
127230
|
new AcpWire(opts, deps)
|
|
127115
127231
|
);
|
|
127116
127232
|
this.opts = opts;
|
|
127233
|
+
if (deps.shape?.supportsModelOption) {
|
|
127234
|
+
this.updateSettings = (s) => this.wire.updateSettings(s);
|
|
127235
|
+
}
|
|
127117
127236
|
}
|
|
127118
127237
|
opts;
|
|
127238
|
+
updateSettings;
|
|
127239
|
+
takeOpenedSettings() {
|
|
127240
|
+
return this.wire.takeOpenedSettings();
|
|
127241
|
+
}
|
|
127119
127242
|
/**
|
|
127120
127243
|
* The Stop also stops this session's app calls, a card standing for one included, with or without a turn running: an ACP agent
|
|
127121
127244
|
* reaches apps through the bridge's `app` tool since #2231, and the agent sends no cancellation to it. As on Claude and Codex
|
|
@@ -127124,6 +127247,10 @@ var AcpSession = class extends CoreSession {
|
|
|
127124
127247
|
this.opts.apps?.cancelAll();
|
|
127125
127248
|
super.interrupt();
|
|
127126
127249
|
}
|
|
127250
|
+
interruptForInput() {
|
|
127251
|
+
this.opts.apps?.cancelAll();
|
|
127252
|
+
super.interruptForInput();
|
|
127253
|
+
}
|
|
127127
127254
|
respondApproval(requestId, decision, _scope, matcher2) {
|
|
127128
127255
|
return this.wire.respondApproval(requestId, decision, matcher2);
|
|
127129
127256
|
}
|
|
@@ -127164,6 +127291,10 @@ var AcpWire = class {
|
|
|
127164
127291
|
this.label = deps.label;
|
|
127165
127292
|
if (deps.install !== void 0) this.install = deps.install;
|
|
127166
127293
|
this.preset = opts.permissionPreset;
|
|
127294
|
+
this.turns = {
|
|
127295
|
+
interruptEndsProcess: false,
|
|
127296
|
+
...deps.shape?.interruptForInput ? { interruptForInput: true } : {}
|
|
127297
|
+
};
|
|
127167
127298
|
this.launch = async () => deps.spec;
|
|
127168
127299
|
this.normalizer = new AcpNormalizer(opts.sessionId, deps.label);
|
|
127169
127300
|
this.unmapped = new UnmappedTypes(deps.label, opts.sessionId, KNOWN_UPDATES);
|
|
@@ -127174,7 +127305,7 @@ var AcpWire = class {
|
|
|
127174
127305
|
label;
|
|
127175
127306
|
install;
|
|
127176
127307
|
/** ACP runs one prompt at a time (§5.4); a cancel ends the turn with `cancelled`, so the Stop's timer applies */
|
|
127177
|
-
turns
|
|
127308
|
+
turns;
|
|
127178
127309
|
launch;
|
|
127179
127310
|
/** ACP's `auto` allows (`core/grants.ts`) */
|
|
127180
127311
|
grants = new Grants("allow");
|
|
@@ -127211,6 +127342,11 @@ var AcpWire = class {
|
|
|
127211
127342
|
opening = null;
|
|
127212
127343
|
/** This process's conversation is open (`open` answered): until then a failed open ends the process, after it the wire does */
|
|
127213
127344
|
opened = false;
|
|
127345
|
+
openedSettings = null;
|
|
127346
|
+
currentModel = null;
|
|
127347
|
+
currentEffort = null;
|
|
127348
|
+
effortConfigId = "thought_level";
|
|
127349
|
+
settingsQueue = Promise.resolve();
|
|
127214
127350
|
/**
|
|
127215
127351
|
* The agent wants an interactive sign-in inside this session's process (`SignInWanted`): it would wait for a browser
|
|
127216
127352
|
* nobody asked for, and `session/new` would end in "No response" two minutes later with the tool still said ready. What
|
|
@@ -127234,6 +127370,71 @@ var AcpWire = class {
|
|
|
127234
127370
|
emit(e) {
|
|
127235
127371
|
this.io.emit(e);
|
|
127236
127372
|
}
|
|
127373
|
+
updateEffortId(options) {
|
|
127374
|
+
const thought = options.find((c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level");
|
|
127375
|
+
if (thought?.id) this.effortConfigId = thought.id;
|
|
127376
|
+
}
|
|
127377
|
+
handleConfigOptions(options) {
|
|
127378
|
+
this.updateEffortId(options);
|
|
127379
|
+
if (this.deps.shape?.supportsModelOption) {
|
|
127380
|
+
const currentModel = options.find((c) => c.id === "model" || c.category === "model")?.currentValue;
|
|
127381
|
+
const currentEffort = options.find((c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level")?.currentValue;
|
|
127382
|
+
if (typeof currentModel === "string") this.currentModel = currentModel;
|
|
127383
|
+
if (typeof currentEffort === "string") this.currentEffort = currentEffort;
|
|
127384
|
+
if (this.currentModel !== null || this.currentEffort !== null) {
|
|
127385
|
+
this.openedSettings = {
|
|
127386
|
+
model: this.currentModel,
|
|
127387
|
+
effort: this.currentEffort
|
|
127388
|
+
};
|
|
127389
|
+
}
|
|
127390
|
+
this.deps.shape.onConfigOptions?.(options);
|
|
127391
|
+
}
|
|
127392
|
+
}
|
|
127393
|
+
async setConfigOption(configId, value) {
|
|
127394
|
+
if (!this.conversation) return false;
|
|
127395
|
+
try {
|
|
127396
|
+
await this.conn.request("session/set_config_option", {
|
|
127397
|
+
sessionId: this.conversation,
|
|
127398
|
+
configId,
|
|
127399
|
+
value
|
|
127400
|
+
}, 2e4);
|
|
127401
|
+
return true;
|
|
127402
|
+
} catch (err) {
|
|
127403
|
+
console.error(`[${this.label}] session/set_config_option failed (${configId}=${value}):`, err);
|
|
127404
|
+
return false;
|
|
127405
|
+
}
|
|
127406
|
+
}
|
|
127407
|
+
takeOpenedSettings() {
|
|
127408
|
+
const s = this.openedSettings;
|
|
127409
|
+
this.openedSettings = null;
|
|
127410
|
+
return s;
|
|
127411
|
+
}
|
|
127412
|
+
updateSettings(settings) {
|
|
127413
|
+
if (!this.deps.shape?.supportsModelOption) return;
|
|
127414
|
+
this.settingsQueue = this.settingsQueue.then(async () => {
|
|
127415
|
+
if (settings.model) {
|
|
127416
|
+
const ok = await this.setConfigOption("model", settings.model);
|
|
127417
|
+
if (ok) {
|
|
127418
|
+
this.currentModel = settings.model;
|
|
127419
|
+
this.openedSettings = {
|
|
127420
|
+
model: this.currentModel,
|
|
127421
|
+
effort: this.currentEffort
|
|
127422
|
+
};
|
|
127423
|
+
}
|
|
127424
|
+
}
|
|
127425
|
+
if (settings.effort) {
|
|
127426
|
+
const ok = await this.setConfigOption(this.effortConfigId, settings.effort);
|
|
127427
|
+
if (ok) {
|
|
127428
|
+
this.currentEffort = settings.effort;
|
|
127429
|
+
this.openedSettings = {
|
|
127430
|
+
model: this.currentModel,
|
|
127431
|
+
effort: this.currentEffort
|
|
127432
|
+
};
|
|
127433
|
+
}
|
|
127434
|
+
}
|
|
127435
|
+
}).catch(() => {
|
|
127436
|
+
});
|
|
127437
|
+
}
|
|
127237
127438
|
async open(io2, resume) {
|
|
127238
127439
|
this.io = io2;
|
|
127239
127440
|
this.opened = false;
|
|
@@ -127277,8 +127478,9 @@ var AcpWire = class {
|
|
|
127277
127478
|
if (!method) throw rpcError(`${this.label} cannot reopen a conversation`, "session_not_found");
|
|
127278
127479
|
this.replaying = method === "session/load";
|
|
127279
127480
|
this.opening = resume.externalId;
|
|
127481
|
+
let opened = null;
|
|
127280
127482
|
try {
|
|
127281
|
-
OpenedSession.parse(await this.conn.request(method, { ...base2, sessionId: resume.externalId }, 15e4) ?? {});
|
|
127483
|
+
opened = OpenedSession.parse(await this.conn.request(method, { ...base2, sessionId: resume.externalId }, 15e4) ?? {});
|
|
127282
127484
|
} catch (err) {
|
|
127283
127485
|
this.replaying = false;
|
|
127284
127486
|
this.opening = null;
|
|
@@ -127288,14 +127490,36 @@ var AcpWire = class {
|
|
|
127288
127490
|
this.opening = null;
|
|
127289
127491
|
}
|
|
127290
127492
|
this.conversation = resume.externalId;
|
|
127493
|
+
if (opened?.configOptions) {
|
|
127494
|
+
this.handleConfigOptions(opened.configOptions);
|
|
127495
|
+
}
|
|
127291
127496
|
this.costTotal = this.opts.runningCost?.last ?? null;
|
|
127292
127497
|
} else {
|
|
127293
127498
|
const opened = OpenedSession.parse(await this.conn.request("session/new", base2, 12e4));
|
|
127294
127499
|
if (!opened.sessionId) throw new Error(`${this.label} opened a session without an id`);
|
|
127295
127500
|
this.conversation = opened.sessionId;
|
|
127501
|
+
if (opened.configOptions) {
|
|
127502
|
+
this.handleConfigOptions(opened.configOptions);
|
|
127503
|
+
}
|
|
127296
127504
|
this.costTotal = 0;
|
|
127297
127505
|
this.opts.runningCost?.keep(0);
|
|
127298
127506
|
}
|
|
127507
|
+
if (this.deps.shape?.supportsModelOption) {
|
|
127508
|
+
if (this.opts.model) {
|
|
127509
|
+
const ok = await this.setConfigOption("model", this.opts.model);
|
|
127510
|
+
if (ok) {
|
|
127511
|
+
this.currentModel = this.opts.model;
|
|
127512
|
+
this.openedSettings = { model: this.currentModel, effort: this.currentEffort };
|
|
127513
|
+
}
|
|
127514
|
+
}
|
|
127515
|
+
if (this.opts.effort) {
|
|
127516
|
+
const ok = await this.setConfigOption(this.effortConfigId, this.opts.effort);
|
|
127517
|
+
if (ok) {
|
|
127518
|
+
this.currentEffort = this.opts.effort;
|
|
127519
|
+
this.openedSettings = { model: this.currentModel, effort: this.currentEffort };
|
|
127520
|
+
}
|
|
127521
|
+
}
|
|
127522
|
+
}
|
|
127299
127523
|
this.opened = true;
|
|
127300
127524
|
return { externalId: this.conversation };
|
|
127301
127525
|
} catch (err) {
|
|
@@ -127497,6 +127721,10 @@ var AcpWire = class {
|
|
|
127497
127721
|
this.commands = read2.update.availableCommands.map((c) => ({ name: c.name, ...c.description ? { description: c.description } : {}, ...c.input?.hint ? { argumentHint: c.input.hint } : {} }));
|
|
127498
127722
|
return;
|
|
127499
127723
|
}
|
|
127724
|
+
if ("update" in read2 && read2.update.sessionUpdate === "config_option_update" && (read2.sessionId === this.conversation || read2.sessionId === this.opening)) {
|
|
127725
|
+
this.handleConfigOptions(read2.update.configOptions);
|
|
127726
|
+
return;
|
|
127727
|
+
}
|
|
127500
127728
|
if (read2.sessionId !== this.conversation || this.replaying) return;
|
|
127501
127729
|
const turn = this.turn;
|
|
127502
127730
|
this.resendLostCancel();
|
|
@@ -127721,6 +127949,8 @@ var AcpAdapter = class {
|
|
|
127721
127949
|
if (localUsage) this.localUsage = localUsage;
|
|
127722
127950
|
const sweep = profile.sweepSessionFiles?.bind(profile);
|
|
127723
127951
|
if (sweep) this.sweepSessionFiles = sweep;
|
|
127952
|
+
const listModels = profile.listModels?.bind(profile);
|
|
127953
|
+
if (listModels) this.listModels = listModels;
|
|
127724
127954
|
}
|
|
127725
127955
|
profile;
|
|
127726
127956
|
spawn;
|
|
@@ -127729,6 +127959,8 @@ var AcpAdapter = class {
|
|
|
127729
127959
|
listUsage;
|
|
127730
127960
|
/** What the tool's own command says about its usage (the profile's `localUsage`), when it has one */
|
|
127731
127961
|
localUsage;
|
|
127962
|
+
/** The models available to choose from (the profile's `listModels`), when it has them */
|
|
127963
|
+
listModels;
|
|
127732
127964
|
/** What the tool keeps per session, swept (the profile's `sweepSessionFiles`), when it keeps any */
|
|
127733
127965
|
sweepSessionFiles;
|
|
127734
127966
|
get descriptor() {
|
|
@@ -127992,6 +128224,21 @@ function agyPlatformKey(platform = HOST_PLATFORM, arch = process.arch) {
|
|
|
127992
128224
|
if (platform === "win32") return `windows-${cpu}`;
|
|
127993
128225
|
return null;
|
|
127994
128226
|
}
|
|
128227
|
+
async function usagePlace(home) {
|
|
128228
|
+
const cwd = resolve13(join34(home.root, "usage"));
|
|
128229
|
+
await mkdir5(cwd, { recursive: true });
|
|
128230
|
+
const file2 = join34(home.root, "usage-session.json");
|
|
128231
|
+
const kept = await readFile5(file2, "utf8").then((text3) => asObj(JSON.parse(text3)).sessionId).catch(() => null);
|
|
128232
|
+
return { cwd, kept: typeof kept === "string" && kept !== "" ? kept : null, keep: (sessionId) => writeFile5(file2, `${JSON.stringify({ sessionId })}
|
|
128233
|
+
`) };
|
|
128234
|
+
}
|
|
128235
|
+
var AGY_MODELS_CACHE = "models.json";
|
|
128236
|
+
async function readCachedAgyModels(home) {
|
|
128237
|
+
return readFile5(join34(home.root, AGY_MODELS_CACHE), "utf8").catch(() => null);
|
|
128238
|
+
}
|
|
128239
|
+
async function writeCachedAgyModels(home, text3) {
|
|
128240
|
+
await writeFile5(join34(home.root, AGY_MODELS_CACHE), text3, "utf8");
|
|
128241
|
+
}
|
|
127995
128242
|
function agyHome(dataDir, version2) {
|
|
127996
128243
|
const root3 = join34(dataDir, "tools", "antigravity");
|
|
127997
128244
|
return { root: root3, versionDir: join34(root3, version2), geminiHome: join34(root3, "gemini-home") };
|
|
@@ -128858,6 +129105,245 @@ var AGY_SURFACE = {
|
|
|
128858
129105
|
baseline: BASELINE
|
|
128859
129106
|
};
|
|
128860
129107
|
|
|
129108
|
+
// packages/agent-host/src/adapters/antigravity/usage.ts
|
|
129109
|
+
var READ_TIMEOUT_MS = 12e3;
|
|
129110
|
+
var AgyQuota = external_exports.array(
|
|
129111
|
+
external_exports.object({
|
|
129112
|
+
name: external_exports.string().min(1),
|
|
129113
|
+
buckets: external_exports.array(external_exports.object({ label: external_exports.string().min(1), remaining: external_exports.number().min(0).max(100), resetsAt: external_exports.iso.datetime() })).min(1)
|
|
129114
|
+
})
|
|
129115
|
+
).min(1);
|
|
129116
|
+
async function readAgyUsage(home, archive, signedOut, deps = {}) {
|
|
129117
|
+
const timeoutMs = deps.timeoutMs ?? READ_TIMEOUT_MS;
|
|
129118
|
+
const folder = await browserFolder(home, deps.platform, deps.helperPlaces);
|
|
129119
|
+
if (folder.browser === "") throw new Error(`Antigravity cannot say its usage: ${folder.why}`);
|
|
129120
|
+
const place = await usagePlace(home);
|
|
129121
|
+
const launch2 = agyLaunch(home, archive, folder);
|
|
129122
|
+
const proc = startToolProcess({ ...launch2, cwd: place.cwd, env: { ...process.env, ...launch2.env } }, deps.spawn ? { spawn: deps.spawn } : {});
|
|
129123
|
+
let text3 = "";
|
|
129124
|
+
const stray = { what: null };
|
|
129125
|
+
let wantsSignIn = false;
|
|
129126
|
+
let timedOut2 = false;
|
|
129127
|
+
let hasUsageCommand = null;
|
|
129128
|
+
const conn = new AcpConnection(
|
|
129129
|
+
proc,
|
|
129130
|
+
{
|
|
129131
|
+
onNotification: (method, params) => {
|
|
129132
|
+
const u = method === "session/update" ? readUpdate(params) : null;
|
|
129133
|
+
if (!u || !("update" in u)) return;
|
|
129134
|
+
if (u.update.sessionUpdate === "agent_message_chunk" && u.update.content.type === "text") text3 += u.update.content.text ?? "";
|
|
129135
|
+
if (u.update.sessionUpdate === "tool_call") stray.what ??= "a tool call";
|
|
129136
|
+
if (u.update.sessionUpdate === "available_commands_update") {
|
|
129137
|
+
hasUsageCommand = u.update.availableCommands.some((c) => c.name === "usage");
|
|
129138
|
+
}
|
|
129139
|
+
},
|
|
129140
|
+
onRequest: async (_id, method) => {
|
|
129141
|
+
stray.what ??= method;
|
|
129142
|
+
throw new RpcError(METHOD_NOT_FOUND2, `Method not found: ${method}`);
|
|
129143
|
+
},
|
|
129144
|
+
onExit: () => {
|
|
129145
|
+
}
|
|
129146
|
+
},
|
|
129147
|
+
"Antigravity usage",
|
|
129148
|
+
agyStderrLine
|
|
129149
|
+
);
|
|
129150
|
+
folder.watch((address) => {
|
|
129151
|
+
if (!agentSignInUrl(address)) return;
|
|
129152
|
+
wantsSignIn = true;
|
|
129153
|
+
void conn.dispose(500);
|
|
129154
|
+
});
|
|
129155
|
+
const timer = setTimeout(() => {
|
|
129156
|
+
timedOut2 = true;
|
|
129157
|
+
void conn.dispose(500);
|
|
129158
|
+
}, timeoutMs);
|
|
129159
|
+
try {
|
|
129160
|
+
await conn.request("initialize", { protocolVersion: 1, clientInfo: { name: "centralu", version: "1" }, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } }, timeoutMs);
|
|
129161
|
+
const base2 = { cwd: place.cwd, mcpServers: [] };
|
|
129162
|
+
let sessionId = place.kept && await conn.request("session/resume", { ...base2, sessionId: place.kept }, timeoutMs).then(() => place.kept, () => null);
|
|
129163
|
+
if (!sessionId) {
|
|
129164
|
+
sessionId = OpenedSession.parse(await conn.request("session/new", base2, timeoutMs)).sessionId ?? null;
|
|
129165
|
+
if (!sessionId) throw new Error("Antigravity opened a conversation without an id");
|
|
129166
|
+
await place.keep(sessionId);
|
|
129167
|
+
}
|
|
129168
|
+
if (hasUsageCommand === false) throw new Error('Antigravity does not support "/usage" in this version');
|
|
129169
|
+
text3 = "";
|
|
129170
|
+
const done2 = PromptResult.parse(await conn.request("session/prompt", { sessionId, prompt: [{ type: "text", text: "/usage" }] }, timeoutMs));
|
|
129171
|
+
if (stray.what) throw new Error(`Antigravity answered "/usage" with ${stray.what}, not its usage`);
|
|
129172
|
+
const reason = typeof done2.stopReason === "string" ? done2.stopReason : "";
|
|
129173
|
+
if (reason !== "end_turn") throw new Error(`Antigravity's "/usage" ended "${reason}", not with its usage`);
|
|
129174
|
+
return readAgyQuota(text3);
|
|
129175
|
+
} catch (err) {
|
|
129176
|
+
if (wantsSignIn || err instanceof RpcError && err.code === AUTH_REQUIRED) throw signedOut();
|
|
129177
|
+
if (timedOut2) throw new Error(`Antigravity did not say its usage within ${Math.round(timeoutMs / 1e3)} s`);
|
|
129178
|
+
if (err instanceof RpcError) throw new Error(`Antigravity could not say its usage (error ${err.code})`);
|
|
129179
|
+
throw err;
|
|
129180
|
+
} finally {
|
|
129181
|
+
clearTimeout(timer);
|
|
129182
|
+
await conn.dispose(5e3).catch(() => {
|
|
129183
|
+
});
|
|
129184
|
+
await folder.remove();
|
|
129185
|
+
}
|
|
129186
|
+
}
|
|
129187
|
+
var GROUP = /^- \*\*(.+)\*\*$/;
|
|
129188
|
+
var NOTE = /^\*\(.*\)\*$/;
|
|
129189
|
+
var BUCKET = /^- \*\*(.+):\*\* (\d+(?:\.\d+)?)% remaining \(resets (.+)\)$/;
|
|
129190
|
+
var RESET = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{1,2}), (\d{4}), (\d{2}):(\d{2}) UTC$/;
|
|
129191
|
+
var MONTHS2 = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
129192
|
+
function unread2(what) {
|
|
129193
|
+
return new Error(`Antigravity's usage answer has a form Centralu does not read (${what})`);
|
|
129194
|
+
}
|
|
129195
|
+
function readAgyQuota(markdown2) {
|
|
129196
|
+
const groups = [];
|
|
129197
|
+
let inQuota = false;
|
|
129198
|
+
for (const raw of markdown2.split("\n")) {
|
|
129199
|
+
const line = raw.trim();
|
|
129200
|
+
if (line.startsWith("### ")) {
|
|
129201
|
+
inQuota = line === "### Quota Limits";
|
|
129202
|
+
continue;
|
|
129203
|
+
}
|
|
129204
|
+
if (!inQuota || line === "" || NOTE.test(line)) continue;
|
|
129205
|
+
const bucket = BUCKET.exec(line);
|
|
129206
|
+
if (bucket) {
|
|
129207
|
+
const group2 = groups.at(-1);
|
|
129208
|
+
if (!group2) throw unread2("a limit before any group");
|
|
129209
|
+
const resetStr = bucket[3];
|
|
129210
|
+
const reset = resetStr ? RESET.exec(resetStr) : null;
|
|
129211
|
+
if (!reset) throw unread2("a reset time");
|
|
129212
|
+
const [, month, day4, year, hour, minute] = reset;
|
|
129213
|
+
const label = bucket[1];
|
|
129214
|
+
const remainingStr = bucket[2];
|
|
129215
|
+
if (!month || !day4 || !year || !hour || !minute || !label || !remainingStr) throw unread2("a reset time");
|
|
129216
|
+
const at2 = new Date(Date.UTC(Number(year), MONTHS2.indexOf(month), Number(day4), Number(hour), Number(minute)));
|
|
129217
|
+
group2.buckets.push({ label, remaining: Number(remainingStr), resetsAt: at2.toISOString() });
|
|
129218
|
+
continue;
|
|
129219
|
+
}
|
|
129220
|
+
const group = GROUP.exec(line);
|
|
129221
|
+
if (!group || !group[1]) throw unread2("a line of a kind it does not know");
|
|
129222
|
+
groups.push({ name: group[1], buckets: [] });
|
|
129223
|
+
}
|
|
129224
|
+
const quota = AgyQuota.safeParse(groups);
|
|
129225
|
+
if (!quota.success) throw unread2(groups.length === 0 ? "no limits" : "a group with no limits, or a value out of range");
|
|
129226
|
+
return quota.data;
|
|
129227
|
+
}
|
|
129228
|
+
var slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
129229
|
+
function agyUsageSnapshot(quota, plan) {
|
|
129230
|
+
const windows3 = quota.flatMap(
|
|
129231
|
+
(g5) => g5.buckets.map((b2) => {
|
|
129232
|
+
const label = b2.label.replace(/\s+Limit(\s+Remaining)?$/, "");
|
|
129233
|
+
return { id: `${slug(g5.name)}:${slug(label)}`, label, percent: 100 - b2.remaining, resetsAt: b2.resetsAt, scope: g5.name };
|
|
129234
|
+
})
|
|
129235
|
+
);
|
|
129236
|
+
return { plan, windows: windows3, daily: [] };
|
|
129237
|
+
}
|
|
129238
|
+
|
|
129239
|
+
// packages/agent-host/src/adapters/antigravity/models.ts
|
|
129240
|
+
var AGY_BASELINE_MODELS = [
|
|
129241
|
+
{
|
|
129242
|
+
id: "gemini-4-argon",
|
|
129243
|
+
label: "Gemini 4 Argon",
|
|
129244
|
+
efforts: ["low", "medium", "high"],
|
|
129245
|
+
defaultEffort: "medium",
|
|
129246
|
+
tiers: []
|
|
129247
|
+
},
|
|
129248
|
+
{
|
|
129249
|
+
id: "gemini-3.8-flash",
|
|
129250
|
+
label: "Gemini 3.8 Flash",
|
|
129251
|
+
efforts: ["low", "medium", "high"],
|
|
129252
|
+
defaultEffort: "medium",
|
|
129253
|
+
tiers: []
|
|
129254
|
+
},
|
|
129255
|
+
{
|
|
129256
|
+
id: "claude-opus-5-5",
|
|
129257
|
+
label: "Claude Opus 5.5",
|
|
129258
|
+
efforts: ["low", "medium", "high"],
|
|
129259
|
+
defaultEffort: "medium",
|
|
129260
|
+
tiers: []
|
|
129261
|
+
},
|
|
129262
|
+
{
|
|
129263
|
+
id: "claude-sonnet-5-5",
|
|
129264
|
+
label: "Claude Sonnet 5.5",
|
|
129265
|
+
efforts: ["low", "medium", "high"],
|
|
129266
|
+
defaultEffort: "medium",
|
|
129267
|
+
tiers: []
|
|
129268
|
+
},
|
|
129269
|
+
{
|
|
129270
|
+
id: "gpt-oss-120b-medium",
|
|
129271
|
+
label: "GPT-OSS 120B (Medium)",
|
|
129272
|
+
efforts: ["low", "medium", "high"],
|
|
129273
|
+
defaultEffort: "medium",
|
|
129274
|
+
tiers: []
|
|
129275
|
+
}
|
|
129276
|
+
];
|
|
129277
|
+
function extractSelectOptions(options) {
|
|
129278
|
+
if (!Array.isArray(options)) return [];
|
|
129279
|
+
const out = [];
|
|
129280
|
+
for (const raw of options) {
|
|
129281
|
+
const opt = asObj(raw);
|
|
129282
|
+
if (Array.isArray(opt.options)) {
|
|
129283
|
+
for (const nestedRaw of opt.options) {
|
|
129284
|
+
const nested = asObj(nestedRaw);
|
|
129285
|
+
if (typeof nested.value === "string") {
|
|
129286
|
+
out.push({ value: nested.value, ...typeof nested.name === "string" ? { name: nested.name } : {} });
|
|
129287
|
+
}
|
|
129288
|
+
}
|
|
129289
|
+
} else if (typeof opt.value === "string") {
|
|
129290
|
+
out.push({ value: opt.value, ...typeof opt.name === "string" ? { name: opt.name } : {} });
|
|
129291
|
+
}
|
|
129292
|
+
}
|
|
129293
|
+
return out;
|
|
129294
|
+
}
|
|
129295
|
+
function toModelOptions(configOptions) {
|
|
129296
|
+
const modelOpt = configOptions.find((c) => c.id === "model" || c.category === "model");
|
|
129297
|
+
if (!modelOpt) return [];
|
|
129298
|
+
const thoughtOpt = configOptions.find(
|
|
129299
|
+
(c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level"
|
|
129300
|
+
);
|
|
129301
|
+
const rawEfforts = extractSelectOptions(thoughtOpt?.options);
|
|
129302
|
+
const efforts = [...new Set(rawEfforts.map((o) => o.value))];
|
|
129303
|
+
const defaultEffort = typeof thoughtOpt?.currentValue === "string" && efforts.includes(thoughtOpt.currentValue) ? thoughtOpt.currentValue : efforts.length > 0 ? efforts.includes("medium") ? "medium" : efforts[0] ?? null : null;
|
|
129304
|
+
const modelItems = extractSelectOptions(modelOpt.options);
|
|
129305
|
+
const seen = /* @__PURE__ */ new Set();
|
|
129306
|
+
const result = [];
|
|
129307
|
+
for (const item of modelItems) {
|
|
129308
|
+
if (!seen.has(item.value)) {
|
|
129309
|
+
seen.add(item.value);
|
|
129310
|
+
result.push({
|
|
129311
|
+
id: item.value,
|
|
129312
|
+
label: item.name || item.value,
|
|
129313
|
+
efforts: [...efforts],
|
|
129314
|
+
defaultEffort,
|
|
129315
|
+
tiers: []
|
|
129316
|
+
});
|
|
129317
|
+
}
|
|
129318
|
+
}
|
|
129319
|
+
return result;
|
|
129320
|
+
}
|
|
129321
|
+
async function saveAgyModels(home, models) {
|
|
129322
|
+
if (models.length === 0) return;
|
|
129323
|
+
await writeCachedAgyModels(home, `${JSON.stringify(models, null, 2)}
|
|
129324
|
+
`);
|
|
129325
|
+
}
|
|
129326
|
+
async function listAgyModels(home, archive, setup, signedOut, label, install) {
|
|
129327
|
+
if (!archive || !setup.installed()) {
|
|
129328
|
+
throw toolNotInstalled(label, install);
|
|
129329
|
+
}
|
|
129330
|
+
if (setup.current().state !== "ready") {
|
|
129331
|
+
throw signedOut();
|
|
129332
|
+
}
|
|
129333
|
+
try {
|
|
129334
|
+
const raw = await readCachedAgyModels(home);
|
|
129335
|
+
if (raw) {
|
|
129336
|
+
const parsed = JSON.parse(raw);
|
|
129337
|
+
const checked2 = external_exports.array(ModelOption).safeParse(parsed);
|
|
129338
|
+
if (checked2.success && checked2.data.length > 0) {
|
|
129339
|
+
return checked2.data;
|
|
129340
|
+
}
|
|
129341
|
+
}
|
|
129342
|
+
} catch {
|
|
129343
|
+
}
|
|
129344
|
+
return [...AGY_BASELINE_MODELS];
|
|
129345
|
+
}
|
|
129346
|
+
|
|
128861
129347
|
// packages/agent-host/src/adapters/antigravity/index.ts
|
|
128862
129348
|
var CAPABILITIES = {
|
|
128863
129349
|
// What the agent does or lacks beyond these fields (`roleText`, `attachments` and `keepsRepoFilesOut` stay at the ACP defaults):
|
|
@@ -128865,7 +129351,7 @@ var CAPABILITIES = {
|
|
|
128865
129351
|
// skill as `skills/system/run-workflow/SKILL.md` into the session's project at `session/new`; Windows 1.4.3 writes none
|
|
128866
129352
|
// (#2320, docs/plans/antigravity-acp.md §1 has the cause)
|
|
128867
129353
|
// - Not offered yet: role text (`_meta.antigravity.systemPrompt.append` exists, unmeasured), untrusted projects (it reads
|
|
128868
|
-
// the project's own instruction files, as the other ACP tools), images in the prompt
|
|
129354
|
+
// the project's own instruction files, as the other ACP tools), images in the prompt
|
|
128869
129355
|
...ACP_CAPABILITIES,
|
|
128870
129356
|
autoTitle: false
|
|
128871
129357
|
};
|
|
@@ -128881,6 +129367,11 @@ function antigravityProfile(deps = {}) {
|
|
|
128881
129367
|
const archive = key2 ? AGY_RELEASE.archives[key2] : null;
|
|
128882
129368
|
const home = agyHome(deps.dataDir ?? dataRoot(), AGY_RELEASE.version);
|
|
128883
129369
|
const setup = new AgySetup({ home, archive, version: AGY_RELEASE.version, appFound: agyAppFinder(deps.platform), ...deps });
|
|
129370
|
+
const signedOut = () => {
|
|
129371
|
+
setup.noteSignedOut();
|
|
129372
|
+
return rpcError(notSignedIn(DESCRIPTOR, "centralu"), "not_logged_in");
|
|
129373
|
+
};
|
|
129374
|
+
let reading = null;
|
|
128884
129375
|
return {
|
|
128885
129376
|
descriptor: DESCRIPTOR,
|
|
128886
129377
|
capabilities: CAPABILITIES,
|
|
@@ -128926,10 +129417,32 @@ function antigravityProfile(deps = {}) {
|
|
|
128926
129417
|
isQuestion: isAgyQuestion,
|
|
128927
129418
|
editRunsAsNewCall: true,
|
|
128928
129419
|
stderrLine: agyStderrLine,
|
|
128929
|
-
signedOut
|
|
128930
|
-
|
|
128931
|
-
|
|
129420
|
+
signedOut,
|
|
129421
|
+
supportsModelOption: true,
|
|
129422
|
+
interruptForInput: true,
|
|
129423
|
+
onConfigOptions: (options) => {
|
|
129424
|
+
const models = toModelOptions(options);
|
|
129425
|
+
if (models.length > 0) void saveAgyModels(home, models).catch(() => {
|
|
129426
|
+
});
|
|
128932
129427
|
}
|
|
129428
|
+
},
|
|
129429
|
+
listModels() {
|
|
129430
|
+
return listAgyModels(home, archive, setup, signedOut, DESCRIPTOR.label, DESCRIPTOR.install);
|
|
129431
|
+
},
|
|
129432
|
+
/*
|
|
129433
|
+
* Its weekly and five-hour limits per model group, from the agent Centralu signed in (`readAgyUsage`), one read at a
|
|
129434
|
+
* time. No `account()`: the sign-in is this machine's Centralu's own (plan §0), so a linked machine's usage is read there
|
|
129435
|
+
*/
|
|
129436
|
+
listUsage() {
|
|
129437
|
+
if (!archive || !setup.installed()) return Promise.reject(toolNotInstalled(DESCRIPTOR.label, DESCRIPTOR.install));
|
|
129438
|
+
if (setup.current().state !== "ready") return Promise.reject(signedOut());
|
|
129439
|
+
reading ??= readAgyUsage(home, archive, signedOut, { platform: deps.platform, helperPlaces: deps.helperPlaces, ...deps.usage }).then((quota) => agyUsageSnapshot(quota, setup.current().plan?.name ?? null)).catch((err) => {
|
|
129440
|
+
console.error(`[usage] antigravity: ${err instanceof Error ? err.message : String(err)}`);
|
|
129441
|
+
throw err;
|
|
129442
|
+
}).finally(() => {
|
|
129443
|
+
reading = null;
|
|
129444
|
+
});
|
|
129445
|
+
return reading;
|
|
128933
129446
|
}
|
|
128934
129447
|
};
|
|
128935
129448
|
}
|
|
@@ -134593,7 +135106,7 @@ async function collectModels(fetchPage) {
|
|
|
134593
135106
|
let cursor = null;
|
|
134594
135107
|
for (let page = 0; page < MAX_PAGES; page++) {
|
|
134595
135108
|
const res = await fetchPage(cursor);
|
|
134596
|
-
out.push(...
|
|
135109
|
+
out.push(...toModelOptions2(res?.data));
|
|
134597
135110
|
cursor = typeof res?.nextCursor === "string" && res.nextCursor ? res.nextCursor : null;
|
|
134598
135111
|
if (!cursor) return out;
|
|
134599
135112
|
}
|
|
@@ -134613,7 +135126,7 @@ async function listCodexModels(command) {
|
|
|
134613
135126
|
});
|
|
134614
135127
|
});
|
|
134615
135128
|
}
|
|
134616
|
-
function
|
|
135129
|
+
function toModelOptions2(data) {
|
|
134617
135130
|
const rows3 = Array.isArray(data) ? data : [];
|
|
134618
135131
|
const out = [];
|
|
134619
135132
|
for (const r of rows3) {
|
|
@@ -138626,6 +139139,15 @@ var LinkedHost = class {
|
|
|
138626
139139
|
if (!r.ok) throw rpcError(r.error);
|
|
138627
139140
|
return { ok: true };
|
|
138628
139141
|
}
|
|
139142
|
+
/** `host.stopTask` (#2485), as `MailHooks.cancelGiven` decides */
|
|
139143
|
+
hubStopTask(sessionId, giver, taskId) {
|
|
139144
|
+
this.directedFromHub(sessionId);
|
|
139145
|
+
const running2 = inTurn(this.host.meta.get(sessionId)?.state ?? "idle") || this.host.turnContinue.waitsToContinue(sessionId);
|
|
139146
|
+
const alone = this.host.mail.cancelGiven(sessionId, giver, taskId);
|
|
139147
|
+
if (!running2 || !alone) return { stopped: false };
|
|
139148
|
+
this.host.inputs.interrupt(sessionId);
|
|
139149
|
+
return { stopped: true };
|
|
139150
|
+
}
|
|
138629
139151
|
/**
|
|
138630
139152
|
* A hub's Assistant's instruction to one of this host's sessions (`host.send`, #82 phase 4 step 2), as a hub from before #1948 step 6 sends work. Delivered as
|
|
138631
139153
|
* `send_to_session` delivers one here, recorded as sent by `fromName`, to a session a hub is shown and no other.
|
|
@@ -139642,6 +140164,12 @@ var MessageRecords = class {
|
|
|
139642
140164
|
const payload = row ? parseJson(row.payload) : void 0;
|
|
139643
140165
|
return row && isObj(payload) ? { seq: row.seq, ts: row.ts, text: typeof payload.text === "string" ? payload.text : "" } : null;
|
|
139644
140166
|
}
|
|
140167
|
+
/** Whether the agent has written anything into this session: an `assistant` row, or a tool step it made (stored as `system`); the person's messages and notices do not count */
|
|
140168
|
+
hasAgentRows(sessionId) {
|
|
140169
|
+
return this.db.prepare(
|
|
140170
|
+
`SELECT 1 AS n FROM messages WHERE session_id = ? AND (role = 'assistant' OR (role <> 'user' AND kind IN ('tool_call', 'tool_result', 'approval', 'image', 'reasoning', 'app_view'))) LIMIT 1`
|
|
140171
|
+
).get(sessionId) !== void 0;
|
|
140172
|
+
}
|
|
139645
140173
|
nextSeq(sessionId) {
|
|
139646
140174
|
const row = oneRow(this.db.prepare(`SELECT COALESCE(MAX(seq), 0) as m FROM messages WHERE session_id = ?`).get(sessionId));
|
|
139647
140175
|
return row.m + 1;
|
|
@@ -139779,7 +140307,7 @@ var ChildOwnershipRecords = class {
|
|
|
139779
140307
|
* transaction: each moved session's `asked_by_session_id` and `parent_session_id` where they name the original, and its start_agent requests still waiting for the person (`agent_start_requests`, whose
|
|
139780
140308
|
* stored request names its caller too). A crash before the commit leaves every row on the original; after it, every
|
|
139781
140309
|
* row on the new session, so the next host (a swap or a restart) reads one owner either way.
|
|
139782
|
-
* `then`: the rest of the handoff's move that is stored elsewhere (the mail, `
|
|
140310
|
+
* `then`: the rest of the handoff's move that is stored elsewhere (the mail, `Handoffs.handOver`), run last in the same
|
|
139783
140311
|
* transaction, so a refusal there leaves every row of both on the original.
|
|
139784
140312
|
*/
|
|
139785
140313
|
moveChildren(from, to, move, then2) {
|
|
@@ -141714,7 +142242,7 @@ var StepsV41ToV47 = class extends MigrationRange {
|
|
|
141714
142242
|
* Expand only (#292): `grid_panels` stays as v9 made it for a v41 host, whose insert names neither NOT NULL
|
|
141715
142243
|
* `panel_key` nor `kind`. Its rows whose session still exists (an orphan would fail the key; listGridView joins
|
|
141716
142244
|
* `sessions`) are copied once, when this table is created; after that the builds' grids may differ, a layout,
|
|
141717
|
-
* not a record.
|
|
142245
|
+
* not a record. Step 78 drops `grid_panels`.
|
|
141718
142246
|
*/
|
|
141719
142247
|
run: () => {
|
|
141720
142248
|
const has = (name) => this.db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name = ?`).get(name) !== void 0;
|
|
@@ -142883,6 +143411,29 @@ var StepsV75 = class extends MigrationRange {
|
|
|
142883
143411
|
* backfilled: no build marked one.
|
|
142884
143412
|
*/
|
|
142885
143413
|
run: () => this.addColumn("mail_recipients", "given_again_at", "INTEGER")
|
|
143414
|
+
},
|
|
143415
|
+
{
|
|
143416
|
+
to: 78,
|
|
143417
|
+
breaksOlderReaders: true,
|
|
143418
|
+
minReader: 75,
|
|
143419
|
+
/**
|
|
143420
|
+
* Two clean-ups that ran at every start or waited for a breaking step (#2481), done once here.
|
|
143421
|
+
*
|
|
143422
|
+
* `grid_panels` goes: step 47 copied it into the workspace, and only migration steps up to 47 name it. The builds the floor (75) admits
|
|
143423
|
+
* neither read nor write it, so they open the store.
|
|
143424
|
+
*
|
|
143425
|
+
* Every "always allow" rule whose matcher ends in `*` goes (#838; the owner's yes on #1143, 2026-11-12, session-manager-split.md §7). A build
|
|
143426
|
+
* before #908 read such a rule as a prefix; since #908 a rule matches exactly and none of them allows anything. Every start deleted them
|
|
143427
|
+
* until now. Once is enough: the builds before #908 are far below the floor and cannot open the store, so a rule ending in `*` written
|
|
143428
|
+
* later is inert in every build that can.
|
|
143429
|
+
*
|
|
143430
|
+
* Breaking, as a drop and a delete of the person's rules are (rule 2 above `migrationSteps`), so the store is copied first; the floor stays 75:
|
|
143431
|
+
* the builds of v75 to v77 name neither, and open the store.
|
|
143432
|
+
*/
|
|
143433
|
+
run: () => {
|
|
143434
|
+
this.db.exec(`DROP TABLE IF EXISTS grid_panels`);
|
|
143435
|
+
this.db.exec(`DELETE FROM approval_rules WHERE substr(matcher, -1) = '*'`);
|
|
143436
|
+
}
|
|
142886
143437
|
}
|
|
142887
143438
|
];
|
|
142888
143439
|
}
|
|
@@ -143040,15 +143591,6 @@ var PermissionRecords = class {
|
|
|
143040
143591
|
ORDER BY created_at DESC`
|
|
143041
143592
|
).all();
|
|
143042
143593
|
}
|
|
143043
|
-
/**
|
|
143044
|
-
* Deletes every "always allow" rule whose matcher ends in `*` (#838): a build before #908 read such a rule as a prefix.
|
|
143045
|
-
* Since #908 a command ending in `*` has no key and a rule matches exactly, so none of them allows anything; left in
|
|
143046
|
-
* the store, they would widen again under a build that reads them as before. Deleting only narrows: an older build serving the same
|
|
143047
|
-
* store asks for those commands again. Returns how many went.
|
|
143048
|
-
*/
|
|
143049
|
-
dropWildcardApprovalRules() {
|
|
143050
|
-
return this.db.prepare(`DELETE FROM approval_rules WHERE substr(matcher, -1) = '*'`).run().changes;
|
|
143051
|
-
}
|
|
143052
143594
|
/** A rule has to be deletable — saving without being able to delete would make "show the outcome" only half true */
|
|
143053
143595
|
deleteApprovalRule(id3) {
|
|
143054
143596
|
this.db.prepare(`DELETE FROM approval_rules WHERE id = ?`).run(id3);
|
|
@@ -143958,7 +144500,7 @@ var Store = class extends MigrationRunner {
|
|
|
143958
144500
|
/** The records of deleted app-agent sessions, kept in the session archive (#378) */
|
|
143959
144501
|
keptRuns;
|
|
143960
144502
|
children;
|
|
143961
|
-
/** Mail without threads: messages and each recipient's row (#1684, v65)
|
|
144503
|
+
/** Mail without threads: messages and each recipient's row (#1684, v65) */
|
|
143962
144504
|
mailbox;
|
|
143963
144505
|
machines;
|
|
143964
144506
|
/** Limit readings and tokens per hour, kept for the usage history (docs/agent-host/usage.md "Usage over time") */
|
|
@@ -144476,9 +145018,9 @@ function linkedTasksOf(mail, records, across, changes) {
|
|
|
144476
145018
|
const answer = task ? records.reportsOn(task.id).at(-1)?.facts.answer : void 0;
|
|
144477
145019
|
return typeof answer === "string" ? answer : void 0;
|
|
144478
145020
|
},
|
|
144479
|
-
withdraw: (callerId, childId) => {
|
|
145021
|
+
withdraw: (callerId, childId, taskId) => {
|
|
144480
145022
|
const caller = mail.sessionAddress(callerId);
|
|
144481
|
-
return tasksTo(caller, mail.sessionAddress(childId)).reduce((n, r) => n + mail.done(caller, r.messageId).settled, 0);
|
|
145023
|
+
return tasksTo(caller, mail.sessionAddress(childId)).filter((r) => taskId === void 0 || r.messageId === taskId).reduce((n, r) => n + mail.done(caller, r.messageId).settled, 0);
|
|
144482
145024
|
},
|
|
144483
145025
|
gone: (childId) => mail.stops.partyGone(mail.sessionAddress(childId))
|
|
144484
145026
|
};
|
|
@@ -144758,9 +145300,8 @@ var AskProjectFlow = class {
|
|
|
144758
145300
|
* is, at the depth this caller's work makes it, and its engine reports it. The call waits for that report as start_agent
|
|
144759
145301
|
* does for a child there; the answer is the session's words there, and the paths it names are that machine's files,
|
|
144760
145302
|
* listed and none opened to the caller. A call with no task waits again on the caller's task still open there.
|
|
144761
|
-
*
|
|
144762
|
-
*
|
|
144763
|
-
* stopping the machine's turn when the call is cancelled.
|
|
145303
|
+
* A card there that machine shows the caller ends the wait as one here does, and the caller answers it with agent_session as that machine's rule
|
|
145304
|
+
* lets it (#2485); a cancelled call stops the turn its task alone started there (`cancelAsk`).
|
|
144764
145305
|
*/
|
|
144765
145306
|
async askLinkedProject(callerId, callerProjectId, callerProject, target, reader, opts, signal) {
|
|
144766
145307
|
const label = `${target.name} on ${target.machine}`;
|
|
@@ -144770,7 +145311,7 @@ var AskProjectFlow = class {
|
|
|
144770
145311
|
const wanted = opts.session?.trim();
|
|
144771
145312
|
const of2 = (g5, sessionName) => ({ taskId: g5.taskId, sessionId: g5.sessionId, child: g5.sessionId, sessionName, project: project2 });
|
|
144772
145313
|
if (target.away) {
|
|
144773
|
-
const there = given.filter((g5) => reader.describe(g5.sessionId)?.
|
|
145314
|
+
const there = given.filter((g5) => reader.describe(g5.sessionId)?.projectName === target.name && (!wanted || g5.sessionId === wanted));
|
|
144774
145315
|
const [only] = there;
|
|
144775
145316
|
if (!opts.task && only && there.length === 1) return this.awaitAsk(callerId, of2(only, reader.describe(only.sessionId)?.name ?? only.sessionId), reader, signal);
|
|
144776
145317
|
return { ok: false, error: awayRefusal(target.machine, target.away, `${label} cannot be asked`) };
|
|
@@ -144877,10 +145418,27 @@ var AskProjectFlow = class {
|
|
|
144877
145418
|
async awaitAsk(callerId, ask, reader, signal) {
|
|
144878
145419
|
const tasks = this.host.linkedTasks;
|
|
144879
145420
|
const base2 = { project: ask.project, sessionId: ask.sessionId, sessionName: ask.sessionName };
|
|
144880
|
-
const
|
|
144881
|
-
|
|
145421
|
+
const remote = this.host.delegationFlow.remote;
|
|
145422
|
+
const cardsThere = async () => {
|
|
145423
|
+
const r5 = reader ? await reader.cards(ask.sessionId, callerId) : null;
|
|
145424
|
+
return r5?.ok ? r5.cards : [];
|
|
145425
|
+
};
|
|
145426
|
+
const asking = (cards) => ({ ok: true, state: "asking", ...base2, cards });
|
|
145427
|
+
const standing2 = await cardsThere();
|
|
145428
|
+
if (standing2.length) return asking(standing2);
|
|
145429
|
+
const card = reader ? remote.untilCard(ask.sessionId) : void 0;
|
|
145430
|
+
let r;
|
|
145431
|
+
try {
|
|
145432
|
+
r = await tasks.settled(ask.taskId, ASK_WAIT_MS, { signal, ...card ? { until: card.raised } : {} });
|
|
145433
|
+
} finally {
|
|
145434
|
+
card?.done();
|
|
145435
|
+
}
|
|
145436
|
+
if (r === "aborted") return reader ? this.cancelAsk(callerId, ask, reader) : { ok: false, error: `The call was cancelled; ${ask.project}'s session "${ask.sessionName}" was left running.` };
|
|
144882
145437
|
const s = tasks.standing(ask.taskId);
|
|
144883
|
-
if (r === "bound" || s.state === "open")
|
|
145438
|
+
if (r === "bound" || s.state === "open") {
|
|
145439
|
+
const cards = s.state === "open" ? await cardsThere() : [];
|
|
145440
|
+
return cards.length ? asking(cards) : { ok: true, state: "working", ...base2 };
|
|
145441
|
+
}
|
|
144884
145442
|
this.host.children.answered(callerId, ask.child);
|
|
144885
145443
|
const failed5 = unfinished(s);
|
|
144886
145444
|
if (failed5 !== null || s.state !== "reported") return { ok: false, error: `${ask.project}'s session "${ask.sessionName}" [${ask.sessionId}] did not finish: ${failed5}. Tell the person, or ask again with a clearer task.` };
|
|
@@ -144897,6 +145455,22 @@ var AskProjectFlow = class {
|
|
|
144897
145455
|
...paused ? { paused: pausedWords(paused, ask.sessionId, " there") } : {}
|
|
144898
145456
|
};
|
|
144899
145457
|
}
|
|
145458
|
+
/**
|
|
145459
|
+
* A cancelled call to a machine's session stops its task's turn there, as a cancelled ask here does (#2485): the machine withdraws the task and stops
|
|
145460
|
+
* the session's turn only when that task alone started it (`host.stopTask`); a turn of the person's, or one the task joined or has not started, runs
|
|
145461
|
+
* on. Withdrawn here too once the machine answered; a machine that cannot be asked (an older build, a link that is down) keeps the task, whose
|
|
145462
|
+
* report comes as mail. A host that is quitting asks nothing: its calls end with it, and the work there goes on
|
|
145463
|
+
*/
|
|
145464
|
+
async cancelAsk(callerId, ask, reader) {
|
|
145465
|
+
const where2 = `${ask.project}'s session "${ask.sessionName}"`;
|
|
145466
|
+
const tasks = this.host.linkedTasks;
|
|
145467
|
+
if (this.host.closing || !reader.stopTask || !tasks) return { ok: false, error: `The call was cancelled; ${where2} was left running.` };
|
|
145468
|
+
const r = await reader.stopTask(ask.sessionId, callerId, ask.taskId);
|
|
145469
|
+
if (!r.ok) return { ok: false, error: `The call was cancelled, but ${where2} could not be asked to stop (${r.error}), so it was left running; its answer comes as mail.` };
|
|
145470
|
+
tasks.withdraw(callerId, ask.sessionId, ask.taskId);
|
|
145471
|
+
if (r.stopped) return { ok: false, error: `The call was cancelled, so ${where2} was stopped.` };
|
|
145472
|
+
return { ok: false, error: `The call was cancelled and its task withdrawn. ${where2} was not stopped: no turn there is that task's alone (not started yet, or the person or other work had a part in it).` };
|
|
145473
|
+
}
|
|
144900
145474
|
/** Waits for a delegation up to the bound (`awaitTurn`), and turns its outcome into what the caller reads */
|
|
144901
145475
|
async awaitDelegation(key2, d2, signal) {
|
|
144902
145476
|
const sessionName = () => this.host.meta.get(d2.sessionId)?.name ?? d2.sessionId;
|
|
@@ -147293,8 +147867,6 @@ var SessionManager = class {
|
|
|
147293
147867
|
void this.trash.sweepSessionFiles();
|
|
147294
147868
|
this.worktreeSweep = this.worktrees.sweepLeftoverWorktrees().catch((e) => console.error(`[worktree] the sweep of leftover worktrees stopped: ${e.message}`));
|
|
147295
147869
|
this.recoveryRepair = repairWorktreeRecoveryRemovals((id3) => store2.trash.isTrashed(id3)).catch((e) => console.error(`[archive] recovery folders left by an interrupted purge were not repaired: ${e.message}`));
|
|
147296
|
-
const wildcards = store2.permissions.dropWildcardApprovalRules();
|
|
147297
|
-
if (wildcards > 0) console.error(`[permissions] removed ${wildcards} "always allow" rule(s) ending in * (#838): their commands are asked again`);
|
|
147298
147870
|
for (const pid of new Set(
|
|
147299
147871
|
[...this.meta.values()].filter((s) => s.worktree && s.projectId).map((s) => s.projectId)
|
|
147300
147872
|
)) {
|
|
@@ -148303,9 +148875,11 @@ function mailReach(host) {
|
|
|
148303
148875
|
askGroupMembers: (address) => host.askGroupMembers(address),
|
|
148304
148876
|
projectOf: (address) => sessionOf(address)?.info?.projectId ?? null,
|
|
148305
148877
|
parentOf: (address) => {
|
|
148306
|
-
const
|
|
148878
|
+
const s = sessionOf(address);
|
|
148307
148879
|
const party = parseAddress(address);
|
|
148308
|
-
|
|
148880
|
+
if (!s?.info || party?.kind !== "session") return null;
|
|
148881
|
+
if (s.info.askedBy) return sessionAddress(party.host, s.info.askedBy);
|
|
148882
|
+
return s.info.host === "here" ? host.starterElsewhere?.(s.id) ?? null : null;
|
|
148309
148883
|
},
|
|
148310
148884
|
labelOf: (address, reader) => sessionOf(address)?.info?.name ?? shownId(address, reader),
|
|
148311
148885
|
shownId,
|
|
@@ -148435,6 +149009,200 @@ var HeldMail = class {
|
|
|
148435
149009
|
return rows3.length;
|
|
148436
149010
|
});
|
|
148437
149011
|
}
|
|
149012
|
+
/**
|
|
149013
|
+
* What a host that died left half done (§7.6.5 of the old plan): a delivery whose attempt was written and whose acceptance was not. It is not sent
|
|
149014
|
+
* again on its own, since an inline task the tool took just before the host died would start the same work twice: it is held `uncertain`, for the
|
|
149015
|
+
* person to resend or dismiss. News and Centralu's own words go again, and their next frame says it may be a repeat
|
|
149016
|
+
*/
|
|
149017
|
+
reconcileInterrupted() {
|
|
149018
|
+
const byRecipient = /* @__PURE__ */ new Map();
|
|
149019
|
+
for (const r of this.d.records.interrupted()) byRecipient.set(r.recipient, [...byRecipient.get(r.recipient) ?? [], r.messageId]);
|
|
149020
|
+
return this.d.run(() => [...byRecipient].map(([recipient, ids]) => ({ recipient, ...this.settleUncertain(recipient, ids) })));
|
|
149021
|
+
}
|
|
149022
|
+
/** A wake the tool failed after the wait for it ran out: the rows it delivered at `deliveredAt` are undelivered again, and treated as a restart's */
|
|
149023
|
+
deliveryFailedLate(recipient, ids, deliveredAt) {
|
|
149024
|
+
return this.d.run(() => this.settleUncertain(recipient, this.d.records.undeliver(recipient, ids, deliveredAt)));
|
|
149025
|
+
}
|
|
149026
|
+
/**
|
|
149027
|
+
* The person says send it: mail held `uncertain` or `failed` goes now. Mail held for the project's trust has its own way out, and so does a
|
|
149028
|
+
* row an earlier build held `loop` (`HeldMail.resumeHeld`)
|
|
149029
|
+
*/
|
|
149030
|
+
resendHeld(recipient, ids) {
|
|
149031
|
+
return this.d.run(() => {
|
|
149032
|
+
const released = this.heldBy(recipient, ids, ["uncertain", "failed"]);
|
|
149033
|
+
const n = this.d.records.release(recipient, released, this.d.now());
|
|
149034
|
+
for (const id3 of released) {
|
|
149035
|
+
const m = this.d.records.message(id3);
|
|
149036
|
+
if (m) this.d.changed(m, [recipient, PERSON]);
|
|
149037
|
+
}
|
|
149038
|
+
return n;
|
|
149039
|
+
});
|
|
149040
|
+
}
|
|
149041
|
+
/** The delivery held these rows for the person (the one hold): written, and the Inbox is told */
|
|
149042
|
+
hold(recipient, held3) {
|
|
149043
|
+
if (held3.length === 0) return;
|
|
149044
|
+
this.d.run(() => {
|
|
149045
|
+
for (const reason of new Set(held3.map((h) => h.reason))) this.d.records.hold(recipient, held3.filter((h) => h.reason === reason).map((h) => h.messageId), reason);
|
|
149046
|
+
for (const h of held3) {
|
|
149047
|
+
const m = this.d.records.message(h.messageId);
|
|
149048
|
+
if (m) this.d.changed(m, [PERSON]);
|
|
149049
|
+
}
|
|
149050
|
+
});
|
|
149051
|
+
}
|
|
149052
|
+
/**
|
|
149053
|
+
* The person says never: held mail is left undelivered, and not held against anyone. `uncertain` and `failed` by default; the person's window may
|
|
149054
|
+
* dismiss any hold it shows, and a dismissed answer leaves the question it answers open (D8)
|
|
149055
|
+
*/
|
|
149056
|
+
dismissHeld(recipient, ids, why2 = ["uncertain", "failed"]) {
|
|
149057
|
+
return this.d.run(() => {
|
|
149058
|
+
const dismissed = this.heldBy(recipient, ids, why2);
|
|
149059
|
+
for (const id3 of dismissed) this.d.records.answerDropped(id3);
|
|
149060
|
+
const n = this.d.records.dismiss(recipient, dismissed);
|
|
149061
|
+
for (const id3 of dismissed) this.d.records.settle(id3, recipient, "withdrawn", this.d.now());
|
|
149062
|
+
for (const id3 of dismissed) {
|
|
149063
|
+
const m = this.d.records.message(id3);
|
|
149064
|
+
if (m) this.d.changed(m, [PERSON]);
|
|
149065
|
+
}
|
|
149066
|
+
return n;
|
|
149067
|
+
});
|
|
149068
|
+
}
|
|
149069
|
+
/** Mail whose delivery may or may not have gone: news and Centralu's own words go again, the rest is held `uncertain` for the person */
|
|
149070
|
+
settleUncertain(recipient, ids) {
|
|
149071
|
+
const messages2 = ids.flatMap((id3) => this.d.records.message(id3) ?? []);
|
|
149072
|
+
const again = messages2.filter((m) => m.kind === "notice" || m.sender === CENTRALU).map((m) => m.id);
|
|
149073
|
+
const unsure = messages2.filter((m) => !again.includes(m.id)).map((m) => m.id);
|
|
149074
|
+
if (again.length > 0) this.d.records.markMaybeRepeated(recipient, again, this.d.now());
|
|
149075
|
+
if (unsure.length > 0) this.d.records.markUncertain(recipient, unsure);
|
|
149076
|
+
for (const m of messages2) this.d.changed(m, again.includes(m.id) ? [recipient, PERSON] : [PERSON]);
|
|
149077
|
+
return { resent: again.length, held: unsure.length };
|
|
149078
|
+
}
|
|
149079
|
+
/** The ids of those of `ids` that `recipient`'s rows hold for one of `why` */
|
|
149080
|
+
heldBy(recipient, ids, why2) {
|
|
149081
|
+
return ids.filter((id3) => why2.includes(this.d.records.recipient(id3, recipient)?.held ?? ""));
|
|
149082
|
+
}
|
|
149083
|
+
};
|
|
149084
|
+
|
|
149085
|
+
// packages/agent-host/src/mail/handoff.ts
|
|
149086
|
+
var Handoffs = class {
|
|
149087
|
+
constructor(d2) {
|
|
149088
|
+
this.d = d2;
|
|
149089
|
+
}
|
|
149090
|
+
d;
|
|
149091
|
+
/** Tasks across a link a handoff re-pointed, for `takeMoves` */
|
|
149092
|
+
queuedMoves = [];
|
|
149093
|
+
/**
|
|
149094
|
+
* The handoff (§7.7, §10.6.5), its one move: `from`'s unsettled watched rows and unread mail move to `to`, and the tasks `from` gave the sessions that
|
|
149095
|
+
* move (`children`) become `to`'s; the successor is told of each message. Called inside the children's move
|
|
149096
|
+
*/
|
|
149097
|
+
handOver(from, to, scope, children = scope === "all" ? [] : scope.senders) {
|
|
149098
|
+
return this.d.run(() => {
|
|
149099
|
+
const plan = this.handOverPreview(from, to, scope);
|
|
149100
|
+
const fresh = plan.filter((p) => this.d.records.recipient(p.messageId, to) === void 0);
|
|
149101
|
+
this.d.records.moveRows(from, to, scope);
|
|
149102
|
+
const across = [];
|
|
149103
|
+
for (const row of this.d.records.watchedFrom(from)) {
|
|
149104
|
+
const m = children.includes(row.recipient) ? this.d.records.message(row.messageId) : void 0;
|
|
149105
|
+
if (m?.kind !== "task") continue;
|
|
149106
|
+
if (this.d.across(row.recipient)) {
|
|
149107
|
+
this.d.records.repoint(m.id, to, this.d.reach.projectOf(to), { ...m.facts, handedOver: true });
|
|
149108
|
+
across.push(m.id);
|
|
149109
|
+
continue;
|
|
149110
|
+
}
|
|
149111
|
+
this.d.records.settle(m.id, row.recipient, "withdrawn", this.d.now());
|
|
149112
|
+
const again = this.d.put({ sender: to, kind: "task", body: m.body, causeId: m.causeId, origin: m.origin, facts: { ...m.facts, handedOver: true } }, [this.d.row(row.recipient, { dueAt: row.dueAt, deliveredAt: row.deliveredAt, readAt: row.readAt })]);
|
|
149113
|
+
if (row.releasedAt !== null && row.releasedWhy !== null) this.d.records.markReleased(again.id, row.recipient, row.releasedAt, row.releasedWhy);
|
|
149114
|
+
}
|
|
149115
|
+
const name = (address) => `\u201C${this.d.labelOf(address)}\u201D [${this.d.shownId(address)}]`;
|
|
149116
|
+
for (const child of children) {
|
|
149117
|
+
if (this.d.reach.parentOf(child) !== from) continue;
|
|
149118
|
+
const body = `[Centralu] ${name(from)}, which started you, handed over to ${name(to)}: that session is your parent now, and its work and mail for you are your parent's.`;
|
|
149119
|
+
this.d.notice(child, { body, facts: { quiet: true }, dedupeKey: `parent:${child}:${to}:${this.d.now()}` });
|
|
149120
|
+
}
|
|
149121
|
+
this.movedNotice(to, fresh.map((p) => p.messageId), this.foldReports(to, fresh.map((p) => p.messageId)));
|
|
149122
|
+
for (const child of children.filter((c) => this.d.across(c))) {
|
|
149123
|
+
const first = this.d.records.firstTask(child, "start_agent");
|
|
149124
|
+
if (first?.sender !== from || across.includes(first.id)) continue;
|
|
149125
|
+
this.d.records.repoint(first.id, to, this.d.reach.projectOf(to), { ...first.facts, handedOver: true });
|
|
149126
|
+
across.push(first.id);
|
|
149127
|
+
}
|
|
149128
|
+
for (const p of plan) if (this.d.across(this.d.records.message(p.messageId)?.sender ?? "")) across.push(p.messageId);
|
|
149129
|
+
if (across.length) this.queuedMoves.push({ from, to, ids: across });
|
|
149130
|
+
return plan;
|
|
149131
|
+
});
|
|
149132
|
+
}
|
|
149133
|
+
/**
|
|
149134
|
+
* On a machine: a hub's handoff gave the tasks it sent here (`ids`) from its session `from` to its session `to` (`host.mailMove`, #1948 step 6). Only an
|
|
149135
|
+
* open task of this host's that `from` sent is moved, and its start_agent task, settled or not, which names a session's parent here (#2520); it keeps its rows, its delivery and the turn it runs in, and reads as handed over (fact
|
|
149136
|
+
* `handedOver`), so an heir's words never pass for the Assistant's. A message a session here sent `from` that the hub moved gives its row to `to`
|
|
149137
|
+
* (#2530), so the heir's reply answers one it may read. The caller checks that both are that hub's. Returns how many moved
|
|
149138
|
+
*/
|
|
149139
|
+
moveAcross(from, to, ids) {
|
|
149140
|
+
return this.d.run(() => {
|
|
149141
|
+
let moved = 0;
|
|
149142
|
+
for (const id3 of new Set(ids)) {
|
|
149143
|
+
const m = this.d.records.message(id3);
|
|
149144
|
+
if (m && m.sender !== from && parseAddress(m.sender)?.kind === "session" && !this.d.across(m.sender)) {
|
|
149145
|
+
moved += this.d.records.moveRows(from, to, "all", [id3]).length;
|
|
149146
|
+
continue;
|
|
149147
|
+
}
|
|
149148
|
+
if (!m || m.sender !== from || m.kind !== "task" && m.kind !== "message") continue;
|
|
149149
|
+
if (m.origin !== "start_agent" && !this.d.records.recipients(id3).some((r) => r.settled === null)) continue;
|
|
149150
|
+
this.d.records.repoint(id3, to, null, { ...m.facts, handedOver: true });
|
|
149151
|
+
moved++;
|
|
149152
|
+
}
|
|
149153
|
+
return moved;
|
|
149154
|
+
});
|
|
149155
|
+
}
|
|
149156
|
+
/** The handoffs that moved tasks across a link, for the links to tell the machines (`MailAcross.movedAcross`); taken once */
|
|
149157
|
+
takeMoves() {
|
|
149158
|
+
return this.queuedMoves.splice(0);
|
|
149159
|
+
}
|
|
149160
|
+
/** What `handOver` would move, read only: each message by id and the first line of its words, for the handoff note to quote */
|
|
149161
|
+
handOverPreview(from, to, scope = "all") {
|
|
149162
|
+
return this.d.records.movable(from, to, scope).flatMap((id3) => {
|
|
149163
|
+
const m = this.d.records.message(id3);
|
|
149164
|
+
return m ? [{ messageId: id3, firstLine: firstLineOf(m.body, 160), kind: m.kind, unread: this.d.records.recipient(id3, from)?.readAt === null, ...m.facts.about ? { about: m.facts.about.session } : {} }] : [];
|
|
149165
|
+
});
|
|
149166
|
+
}
|
|
149167
|
+
/** The Assistant's role is `to`'s (D15): rows sent to the role that another session held are delivered afresh, read or not, and the new Assistant is told of each. Returns how many */
|
|
149168
|
+
roleMoved(to) {
|
|
149169
|
+
return this.d.run(() => {
|
|
149170
|
+
const ids = this.d.records.moveRole(to);
|
|
149171
|
+
this.movedNotice(to, ids);
|
|
149172
|
+
return ids.length;
|
|
149173
|
+
});
|
|
149174
|
+
}
|
|
149175
|
+
/**
|
|
149176
|
+
* Of the reports among `ids` just moved to `to` (Centralu's, and unread: only a watched row moves read, and a report is not watched), each that a
|
|
149177
|
+
* newer one on the same session follows is marked read (#2474): a handoff moves one report per turn ended, days of them, and the newest says how
|
|
149178
|
+
* that session stands. The notice names the others, which may each carry a task's answer, so the heir reads one by its id. Returns their ids
|
|
149179
|
+
*/
|
|
149180
|
+
foldReports(to, ids) {
|
|
149181
|
+
const reports = ids.flatMap((id3) => {
|
|
149182
|
+
const m = this.d.records.message(id3);
|
|
149183
|
+
const session2 = m?.kind === "report" ? m.facts.about?.session : void 0;
|
|
149184
|
+
return m && session2 ? [{ m, session: session2 }] : [];
|
|
149185
|
+
});
|
|
149186
|
+
const newest = /* @__PURE__ */ new Map();
|
|
149187
|
+
for (const { m, session: session2 } of reports) {
|
|
149188
|
+
const kept = newest.get(session2);
|
|
149189
|
+
if (!kept || m.createdAt > kept.createdAt || m.createdAt === kept.createdAt && m.id > kept.id) newest.set(session2, m);
|
|
149190
|
+
}
|
|
149191
|
+
const folded = reports.filter(({ m, session: session2 }) => newest.get(session2) !== m).map(({ m }) => m.id);
|
|
149192
|
+
if (folded.length > 0) this.d.records.markRead(to, folded, this.d.now());
|
|
149193
|
+
return folded;
|
|
149194
|
+
}
|
|
149195
|
+
/** Rows came to `to` from another holder (a handoff, the role's move): one quiet notice for the move, so it knows why the messages are there (key `handover:`) */
|
|
149196
|
+
movedNotice(to, messageIds, folded = []) {
|
|
149197
|
+
if (messageIds.length === 0 || parseAddress(to)?.kind !== "session") return;
|
|
149198
|
+
const moved = messageIds.length === 1 ? "A message addressed to the previous holder was moved to you." : `${messageIds.length} messages addressed to the previous holder were moved to you.`;
|
|
149199
|
+
this.d.centralu(to, {
|
|
149200
|
+
kind: "notice",
|
|
149201
|
+
body: folded.length === 0 ? moved : `${moved} Marked read, since a newer report on the same session follows: ${folded.map((id3) => `[${id3}]`).join(" ")}. The newest report on each session says how it stands; read an older one by its id for its answer.`,
|
|
149202
|
+
facts: { quiet: true, handedOver: true },
|
|
149203
|
+
dedupeKey: `handover:${to}:${hash16(messageIds)}`
|
|
149204
|
+
});
|
|
149205
|
+
}
|
|
148438
149206
|
};
|
|
148439
149207
|
|
|
148440
149208
|
// packages/agent-host/src/mail/send-guards.ts
|
|
@@ -148572,25 +149340,24 @@ var StopNotices = class {
|
|
|
148572
149340
|
return (this.d.readsAs?.(sender, stopped) ?? null) !== null && this.alone(stopped, sender, { turnSeq });
|
|
148573
149341
|
}
|
|
148574
149342
|
/**
|
|
148575
|
-
* Whether `session`'s turn `turnSeq` (its latest when absent) is `sender`'s alone: what a stop notice may quote to it
|
|
148576
|
-
*
|
|
148577
|
-
* must hold: the turn is the session's latest and `sender`'s own message started it (a mail the mailbox delivered, or work
|
|
148578
|
-
*
|
|
148579
|
-
*
|
|
148580
|
-
*
|
|
148581
|
-
*
|
|
148582
|
-
*
|
|
148583
|
-
*
|
|
148584
|
-
* task came from another computer), never a mail of another kind, nor a task that joined a turn already running.
|
|
149343
|
+
* Whether `session`'s turn `turnSeq` (its latest when absent) is `sender`'s alone: what a stop notice may quote to it (`quotes`), whether it may
|
|
149344
|
+
* answer the session's cards as its work's giver (docs/plans/mailbox.md §10.6.4), and whether its cancelled ask stops the turn (`starter`, #2485).
|
|
149345
|
+
* All of it must hold: the turn is the session's latest and `sender`'s own message started it (a mail the mailbox delivered, or work `sender` gave
|
|
149346
|
+
* it); a turn the CLI started by itself (`cli`), or the person's, is never `sender`'s alone, even when it goes on with a task's work; every message
|
|
149347
|
+
* the mailbox gave into it is from `sender`; and everything else that may have entered it (`turnInputs`: each user row stored since the turn before
|
|
149348
|
+
* began, and a question card answered since) was sent by `sender`, none from the person, an app, a script, a relayed report or another session.
|
|
149349
|
+
* A turn anyone else had a part in, or one these records cannot tell, is no one's alone. `gaveIt`: only work `sender` gave it started the turn:
|
|
149350
|
+
* `send`, its send (a `caller` turn); `work`, that or its task the mailbox delivered to start one (the session was busy at the send, or the task
|
|
149351
|
+
* came from another computer), never a mail of another kind, nor a task that joined a turn already running. `starter`: that message alone did.
|
|
148585
149352
|
*/
|
|
148586
|
-
alone(session2, sender, { turnSeq, gaveIt } = {}) {
|
|
149353
|
+
alone(session2, sender, { turnSeq, gaveIt, starter: only } = {}) {
|
|
148587
149354
|
const [party, from] = [parseAddress(session2), parseAddress(sender)];
|
|
148588
149355
|
if (party?.kind !== "session" || from?.kind !== "session") return false;
|
|
148589
149356
|
const seq = turnSeq ?? this.d.records.nextTurnSeq(party.sessionId) - 1;
|
|
148590
149357
|
if (this.d.records.nextTurnSeq(party.sessionId) !== seq + 1) return false;
|
|
148591
149358
|
const turn = this.d.records.turn(party.sessionId, seq);
|
|
148592
149359
|
const starter = turn?.starterId == null ? void 0 : this.d.records.message(turn.starterId);
|
|
148593
|
-
if (!turn || starter?.sender !== sender) return false;
|
|
149360
|
+
if (!turn || starter?.sender !== sender || only !== void 0 && starter.id !== only) return false;
|
|
148594
149361
|
if (turn.startedBy !== "caller" && (turn.startedBy !== "mail" || gaveIt === "send" || gaveIt === "work" && starter.kind !== "task")) return false;
|
|
148595
149362
|
if (this.d.records.inTurn(session2, seq).some((r) => r.message.sender !== sender)) return false;
|
|
148596
149363
|
const given = this.d.turnInputs?.(party.sessionId);
|
|
@@ -148841,6 +149608,19 @@ var MessageService = class {
|
|
|
148841
149608
|
this.ulids = opts.ids ?? new UlidMaker();
|
|
148842
149609
|
this.stops = new StopNotices({ ...opts, records, reach, now: this.now, run: (fn2) => this.run(fn2), notice: (to, n) => this.centralu(to, n) });
|
|
148843
149610
|
this.holds = new HeldMail({ records, reach, now: this.now, run: (fn2) => this.run(fn2), notice: (to, n) => this.centralu(to, n), changed: (msg, to) => this.changed(msg, to) });
|
|
149611
|
+
this.handoffs = new Handoffs({
|
|
149612
|
+
records,
|
|
149613
|
+
reach,
|
|
149614
|
+
now: this.now,
|
|
149615
|
+
run: (fn2) => this.run(fn2),
|
|
149616
|
+
put: (m, rows3) => this.put(m, rows3),
|
|
149617
|
+
row: (to, over) => this.row(to, over),
|
|
149618
|
+
notice: (to, n) => this.notice(to, n),
|
|
149619
|
+
centralu: (to, n) => this.centralu(to, n),
|
|
149620
|
+
labelOf: (a) => this.labelOf(a),
|
|
149621
|
+
shownId: (a) => this.shownId(a),
|
|
149622
|
+
across: (a) => this.across(a)
|
|
149623
|
+
});
|
|
148844
149624
|
}
|
|
148845
149625
|
records;
|
|
148846
149626
|
reach;
|
|
@@ -148849,13 +149629,13 @@ var MessageService = class {
|
|
|
148849
149629
|
ulids;
|
|
148850
149630
|
listeners = createListeners((e) => console.error(`[mail] a listener failed: ${errorMessage(e)}`));
|
|
148851
149631
|
queued = [];
|
|
148852
|
-
/** Tasks across a link a handoff re-pointed, for `takeMoves` */
|
|
148853
|
-
queuedMoves = [];
|
|
148854
149632
|
running = false;
|
|
148855
149633
|
/** Who hears that a session stopped or went (mailbox.md §10.6.1) */
|
|
148856
149634
|
stops;
|
|
148857
|
-
/**
|
|
149635
|
+
/** Mail held for the person: the delivery's holds and the person's acts on them, trusting or dismissing a project (§7.4) */
|
|
148858
149636
|
holds;
|
|
149637
|
+
/** A party that goes and one that takes over (§7.7): a handoff, the Assistant's role, and on a machine a hub's handoff */
|
|
149638
|
+
handoffs;
|
|
148859
149639
|
sessionAddress(sessionId) {
|
|
148860
149640
|
return sessionAddress(this.opts.hostId, sessionId);
|
|
148861
149641
|
}
|
|
@@ -149220,7 +150000,7 @@ var MessageService = class {
|
|
|
149220
150000
|
return m?.kind === "message" && !isHidden(row) ? [m] : [];
|
|
149221
150001
|
}).map((m) => this.item(m, reader, turn));
|
|
149222
150002
|
const listed2 = new Set(needReply.map((i) => i.message.id));
|
|
149223
|
-
const
|
|
150003
|
+
const unread4 = this.records.unreadFor(reader).filter((p) => !listed2.has(p.message.id)).map((p) => this.item(p.message, reader, turn));
|
|
149224
150004
|
const waiting = this.records.watchedFrom(reader).flatMap((row) => {
|
|
149225
150005
|
const message = messageOf2(row);
|
|
149226
150006
|
return message?.kind === "message" && message.needsReply && row.held !== LINK_HOLD ? [{ row, message }] : [];
|
|
@@ -149232,7 +150012,7 @@ var MessageService = class {
|
|
|
149232
150012
|
}),
|
|
149233
150013
|
...this.records.heldForLink(reader).map((p) => ({ ...p, why: LINK_HOLD }))
|
|
149234
150014
|
];
|
|
149235
|
-
return { needReply, unread:
|
|
150015
|
+
return { needReply, unread: unread4, waiting, held: held3 };
|
|
149236
150016
|
}
|
|
149237
150017
|
/**
|
|
149238
150018
|
* Whether mail that wakes `recipient` waits for it, due or not yet (the debounce makes a message wait a moment before it is due): a turn of its own is
|
|
@@ -149321,67 +150101,10 @@ var MessageService = class {
|
|
|
149321
150101
|
asker: turnStarts && toAssistant ? picked : null
|
|
149322
150102
|
};
|
|
149323
150103
|
}
|
|
149324
|
-
/**
|
|
149325
|
-
* What a host that died left half done (§7.6.5 of the old plan): a delivery whose attempt was written and whose acceptance was not. It is not sent
|
|
149326
|
-
* again on its own, since an inline task the tool took just before the host died would start the same work twice: it is held `uncertain`, for the
|
|
149327
|
-
* person to resend or dismiss. News and Centralu's own words go again, and their next frame says it may be a repeat
|
|
149328
|
-
*/
|
|
149329
|
-
reconcileInterrupted() {
|
|
149330
|
-
const byRecipient = /* @__PURE__ */ new Map();
|
|
149331
|
-
for (const r of this.records.interrupted()) byRecipient.set(r.recipient, [...byRecipient.get(r.recipient) ?? [], r.messageId]);
|
|
149332
|
-
return this.run(() => [...byRecipient].map(([recipient, ids]) => ({ recipient, ...this.settleUncertain(recipient, ids) })));
|
|
149333
|
-
}
|
|
149334
|
-
/** A wake the tool failed after the wait for it ran out: the rows it delivered at `deliveredAt` are undelivered again, and treated as a restart's */
|
|
149335
|
-
deliveryFailedLate(recipient, ids, deliveredAt) {
|
|
149336
|
-
return this.run(() => this.settleUncertain(recipient, this.records.undeliver(recipient, ids, deliveredAt)));
|
|
149337
|
-
}
|
|
149338
|
-
/**
|
|
149339
|
-
* The person says send it: mail held `uncertain` or `failed` goes now. Mail held for the project's trust has its own way out, and so does a
|
|
149340
|
-
* row an earlier build held `loop` (`HeldMail.resumeHeld`)
|
|
149341
|
-
*/
|
|
149342
|
-
resendHeld(recipient, ids) {
|
|
149343
|
-
return this.run(() => {
|
|
149344
|
-
const released = this.heldBy(recipient, ids, ["uncertain", "failed"]);
|
|
149345
|
-
const n = this.records.release(recipient, released, this.now());
|
|
149346
|
-
for (const id3 of released) {
|
|
149347
|
-
const m = this.records.message(id3);
|
|
149348
|
-
if (m) this.changed(m, [recipient, PERSON]);
|
|
149349
|
-
}
|
|
149350
|
-
return n;
|
|
149351
|
-
});
|
|
149352
|
-
}
|
|
149353
|
-
/** The delivery held these rows for the person (the one hold): written, and the Inbox is told */
|
|
149354
|
-
hold(recipient, held3) {
|
|
149355
|
-
if (held3.length === 0) return;
|
|
149356
|
-
this.run(() => {
|
|
149357
|
-
for (const reason of new Set(held3.map((h) => h.reason))) this.records.hold(recipient, held3.filter((h) => h.reason === reason).map((h) => h.messageId), reason);
|
|
149358
|
-
for (const h of held3) {
|
|
149359
|
-
const m = this.records.message(h.messageId);
|
|
149360
|
-
if (m) this.changed(m, [PERSON]);
|
|
149361
|
-
}
|
|
149362
|
-
});
|
|
149363
|
-
}
|
|
149364
150104
|
/** Something the Inbox shows changed that is no message (the question about sleeping sessions): the listeners hear an empty change for the person */
|
|
149365
150105
|
announce(rootId = "") {
|
|
149366
150106
|
this.listeners.emit({ messageId: "", rootId, recipients: [PERSON] });
|
|
149367
150107
|
}
|
|
149368
|
-
/**
|
|
149369
|
-
* The person says never: held mail is left undelivered, and not held against anyone. `uncertain` and `failed` by default; the person's window may
|
|
149370
|
-
* dismiss any hold it shows, and a dismissed answer leaves the question it answers open (D8)
|
|
149371
|
-
*/
|
|
149372
|
-
dismissHeld(recipient, ids, why2 = ["uncertain", "failed"]) {
|
|
149373
|
-
return this.run(() => {
|
|
149374
|
-
const dismissed = this.heldBy(recipient, ids, why2);
|
|
149375
|
-
for (const id3 of dismissed) this.records.answerDropped(id3);
|
|
149376
|
-
const n = this.records.dismiss(recipient, dismissed);
|
|
149377
|
-
for (const id3 of dismissed) this.records.settle(id3, recipient, "withdrawn", this.now());
|
|
149378
|
-
for (const id3 of dismissed) {
|
|
149379
|
-
const m = this.records.message(id3);
|
|
149380
|
-
if (m) this.changed(m, [PERSON]);
|
|
149381
|
-
}
|
|
149382
|
-
return n;
|
|
149383
|
-
});
|
|
149384
|
-
}
|
|
149385
150108
|
// ── The Assistant's requests (§7.6) ──
|
|
149386
150109
|
/** The Assistant's turn on `asker`'s requests ended (§7.6): the requests that turn carried are settled `reported`. Returns how many */
|
|
149387
150110
|
requestTurnEnded(assistant, asker, turnSeq) {
|
|
@@ -149416,77 +150139,7 @@ var MessageService = class {
|
|
|
149416
150139
|
const asker = this.isRequest(m, assistant) ? m.sender : m.kind === "notice" && m.sender === CENTRALU ? m.facts.asker : void 0;
|
|
149417
150140
|
return asker !== void 0 && parseAddress(asker)?.kind === "session" ? asker : void 0;
|
|
149418
150141
|
}
|
|
149419
|
-
// ──
|
|
149420
|
-
/**
|
|
149421
|
-
* The handoff (§7.7, §10.6.5), its one move: `from`'s unsettled watched rows and unread mail move to `to`, and the tasks `from` gave the sessions that
|
|
149422
|
-
* move (`children`) become `to`'s; the successor is told of each message. Called inside the children's move
|
|
149423
|
-
*/
|
|
149424
|
-
handOver(from, to, scope, children = scope === "all" ? [] : scope.senders) {
|
|
149425
|
-
return this.run(() => {
|
|
149426
|
-
const plan = this.handOverPreview(from, to, scope);
|
|
149427
|
-
const fresh = plan.filter((p) => this.records.recipient(p.messageId, to) === void 0);
|
|
149428
|
-
this.records.moveRows(from, to, scope);
|
|
149429
|
-
const across = [];
|
|
149430
|
-
for (const row of this.records.watchedFrom(from)) {
|
|
149431
|
-
const m = children.includes(row.recipient) ? this.records.message(row.messageId) : void 0;
|
|
149432
|
-
if (m?.kind !== "task") continue;
|
|
149433
|
-
if (this.across(row.recipient)) {
|
|
149434
|
-
this.records.repoint(m.id, to, this.reach.projectOf(to), { ...m.facts, handedOver: true });
|
|
149435
|
-
across.push(m.id);
|
|
149436
|
-
continue;
|
|
149437
|
-
}
|
|
149438
|
-
this.records.settle(m.id, row.recipient, "withdrawn", this.now());
|
|
149439
|
-
const again = this.put({ sender: to, kind: "task", body: m.body, causeId: m.causeId, origin: m.origin, facts: { ...m.facts, handedOver: true } }, [this.row(row.recipient, { dueAt: row.dueAt, deliveredAt: row.deliveredAt, readAt: row.readAt })]);
|
|
149440
|
-
if (row.releasedAt !== null && row.releasedWhy !== null) this.records.markReleased(again.id, row.recipient, row.releasedAt, row.releasedWhy);
|
|
149441
|
-
}
|
|
149442
|
-
const name = (address) => `\u201C${this.labelOf(address)}\u201D [${this.shownId(address)}]`;
|
|
149443
|
-
for (const child of children) {
|
|
149444
|
-
if (this.reach.parentOf(child) !== from) continue;
|
|
149445
|
-
const body = `[Centralu] ${name(from)}, which started you, handed over to ${name(to)}: that session is your parent now, and its work and mail for you are your parent's.`;
|
|
149446
|
-
this.notice(child, { body, facts: { quiet: true }, dedupeKey: `parent:${child}:${to}:${this.now()}` });
|
|
149447
|
-
}
|
|
149448
|
-
this.movedNotice(to, fresh.map((p) => p.messageId), this.foldReports(to, fresh.map((p) => p.messageId)));
|
|
149449
|
-
if (across.length) this.queuedMoves.push({ from, to, ids: across });
|
|
149450
|
-
return plan;
|
|
149451
|
-
});
|
|
149452
|
-
}
|
|
149453
|
-
/**
|
|
149454
|
-
* On a machine: a hub's handoff gave the tasks it sent here (`ids`) from its session `from` to its session `to` (`host.mailMove`, #1948 step 6). Only an
|
|
149455
|
-
* open task of this host's that `from` sent is moved; it keeps its rows, its delivery and the turn it runs in, and reads as handed over (fact
|
|
149456
|
-
* `handedOver`), so an heir's words never pass for the Assistant's. The caller checks that both are that hub's. Returns how many moved
|
|
149457
|
-
*/
|
|
149458
|
-
moveAcross(from, to, ids) {
|
|
149459
|
-
return this.run(() => {
|
|
149460
|
-
let moved = 0;
|
|
149461
|
-
for (const id3 of new Set(ids)) {
|
|
149462
|
-
const m = this.records.message(id3);
|
|
149463
|
-
if (!m || m.sender !== from || m.kind !== "task" && m.kind !== "message") continue;
|
|
149464
|
-
if (!this.records.recipients(id3).some((r) => r.settled === null)) continue;
|
|
149465
|
-
this.records.repoint(id3, to, null, { ...m.facts, handedOver: true });
|
|
149466
|
-
moved++;
|
|
149467
|
-
}
|
|
149468
|
-
return moved;
|
|
149469
|
-
});
|
|
149470
|
-
}
|
|
149471
|
-
/** The handoffs that moved tasks across a link, for the links to tell the machines (`MailAcross.movedAcross`); taken once */
|
|
149472
|
-
takeMoves() {
|
|
149473
|
-
return this.queuedMoves.splice(0);
|
|
149474
|
-
}
|
|
149475
|
-
/** What `handOver` would move, read only: each message by id and the first line of its words, for the handoff note to quote */
|
|
149476
|
-
handOverPreview(from, to, scope = "all") {
|
|
149477
|
-
return this.records.movable(from, to, scope).flatMap((id3) => {
|
|
149478
|
-
const m = this.records.message(id3);
|
|
149479
|
-
return m ? [{ messageId: id3, firstLine: firstLineOf(m.body, 160), kind: m.kind, unread: this.records.recipient(id3, from)?.readAt === null, ...m.facts.about ? { about: m.facts.about.session } : {} }] : [];
|
|
149480
|
-
});
|
|
149481
|
-
}
|
|
149482
|
-
/** The Assistant's role is `to`'s (D15): rows sent to the role that another session held are delivered afresh, read or not, and the new Assistant is told of each. Returns how many */
|
|
149483
|
-
roleMoved(to) {
|
|
149484
|
-
return this.run(() => {
|
|
149485
|
-
const ids = this.records.moveRole(to);
|
|
149486
|
-
this.movedNotice(to, ids);
|
|
149487
|
-
return ids.length;
|
|
149488
|
-
});
|
|
149489
|
-
}
|
|
150142
|
+
// ── Upkeep ──
|
|
149490
150143
|
sweep() {
|
|
149491
150144
|
return this.records.sweep(this.now());
|
|
149492
150145
|
}
|
|
@@ -149603,37 +150256,6 @@ var MessageService = class {
|
|
|
149603
150256
|
dedupeKey: `answer_held:${question.sender}:${answer.id}:policy`
|
|
149604
150257
|
});
|
|
149605
150258
|
}
|
|
149606
|
-
/**
|
|
149607
|
-
* Of the reports among `ids` just moved to `to` (Centralu's, and unread: only a watched row moves read, and a report is not watched), each that a
|
|
149608
|
-
* newer one on the same session follows is marked read (#2474): a handoff moves one report per turn ended, days of them, and the newest says how
|
|
149609
|
-
* that session stands. The notice names the others, which may each carry a task's answer, so the heir reads one by its id. Returns their ids
|
|
149610
|
-
*/
|
|
149611
|
-
foldReports(to, ids) {
|
|
149612
|
-
const reports = ids.flatMap((id3) => {
|
|
149613
|
-
const m = this.records.message(id3);
|
|
149614
|
-
const session2 = m?.kind === "report" ? m.facts.about?.session : void 0;
|
|
149615
|
-
return m && session2 ? [{ m, session: session2 }] : [];
|
|
149616
|
-
});
|
|
149617
|
-
const newest = /* @__PURE__ */ new Map();
|
|
149618
|
-
for (const { m, session: session2 } of reports) {
|
|
149619
|
-
const kept = newest.get(session2);
|
|
149620
|
-
if (!kept || m.createdAt > kept.createdAt || m.createdAt === kept.createdAt && m.id > kept.id) newest.set(session2, m);
|
|
149621
|
-
}
|
|
149622
|
-
const folded = reports.filter(({ m, session: session2 }) => newest.get(session2) !== m).map(({ m }) => m.id);
|
|
149623
|
-
if (folded.length > 0) this.records.markRead(to, folded, this.now());
|
|
149624
|
-
return folded;
|
|
149625
|
-
}
|
|
149626
|
-
/** Rows came to `to` from another holder (a handoff, the role's move): one quiet notice for the move, so it knows why the messages are there (key `handover:`) */
|
|
149627
|
-
movedNotice(to, messageIds, folded = []) {
|
|
149628
|
-
if (messageIds.length === 0 || parseAddress(to)?.kind !== "session") return;
|
|
149629
|
-
const moved = messageIds.length === 1 ? "A message addressed to the previous holder was moved to you." : `${messageIds.length} messages addressed to the previous holder were moved to you.`;
|
|
149630
|
-
this.centralu(to, {
|
|
149631
|
-
kind: "notice",
|
|
149632
|
-
body: folded.length === 0 ? moved : `${moved} Marked read, since a newer report on the same session follows: ${folded.map((id3) => `[${id3}]`).join(" ")}. The newest report on each session says how it stands; read an older one by its id for its answer.`,
|
|
149633
|
-
facts: { quiet: true, handedOver: true },
|
|
149634
|
-
dedupeKey: `handover:${to}:${hash16(messageIds)}`
|
|
149635
|
-
});
|
|
149636
|
-
}
|
|
149637
150259
|
/** A reminder whose messages are all settled, released, answered by a held answer or moved away has nothing to say (§8.2 step 1) */
|
|
149638
150260
|
reminderSettled(m, recipient) {
|
|
149639
150261
|
return m.kind === "notice" && m.facts.reminder !== void 0 && (m.facts.of ?? []).every((id3) => {
|
|
@@ -149647,20 +150269,6 @@ var MessageService = class {
|
|
|
149647
150269
|
const cause2 = task?.causeId ? this.records.message(task.causeId) : void 0;
|
|
149648
150270
|
return cause2?.kind === "task" && this.records.recipient(cause2.id, recipient)?.settled === null ? cause2.id : void 0;
|
|
149649
150271
|
}
|
|
149650
|
-
/** Mail whose delivery may or may not have gone: news and Centralu's own words go again, the rest is held `uncertain` for the person */
|
|
149651
|
-
settleUncertain(recipient, ids) {
|
|
149652
|
-
const messages2 = ids.flatMap((id3) => this.records.message(id3) ?? []);
|
|
149653
|
-
const again = messages2.filter((m) => m.kind === "notice" || m.sender === CENTRALU).map((m) => m.id);
|
|
149654
|
-
const unsure = messages2.filter((m) => !again.includes(m.id)).map((m) => m.id);
|
|
149655
|
-
if (again.length > 0) this.records.markMaybeRepeated(recipient, again, this.now());
|
|
149656
|
-
if (unsure.length > 0) this.records.markUncertain(recipient, unsure);
|
|
149657
|
-
for (const m of messages2) this.changed(m, again.includes(m.id) ? [recipient, PERSON] : [PERSON]);
|
|
149658
|
-
return { resent: again.length, held: unsure.length };
|
|
149659
|
-
}
|
|
149660
|
-
/** The ids of those of `ids` that `recipient`'s rows hold for one of `why` */
|
|
149661
|
-
heldBy(recipient, ids, why2) {
|
|
149662
|
-
return ids.filter((id3) => why2.includes(this.records.recipient(id3, recipient)?.held ?? ""));
|
|
149663
|
-
}
|
|
149664
150272
|
// ── What the reader sees ──
|
|
149665
150273
|
/** Centralu's word for how the sender stands to the receiver (§8.3). Never a name another party wrote */
|
|
149666
150274
|
relation(recipient, m) {
|
|
@@ -149987,7 +150595,7 @@ var MailPerson = class {
|
|
|
149987
150595
|
if (!stored || !now) return;
|
|
149988
150596
|
const at2 = this.records.recipient(stored.id, t.address)?.deliveredAt;
|
|
149989
150597
|
this.host.tell(sessionId, text3).catch(() => {
|
|
149990
|
-
if (at2 != null) this.service.deliveryFailedLate(t.address, [stored.id], at2);
|
|
150598
|
+
if (at2 != null) this.service.holds.deliveryFailedLate(t.address, [stored.id], at2);
|
|
149991
150599
|
});
|
|
149992
150600
|
}
|
|
149993
150601
|
/**
|
|
@@ -149995,14 +150603,14 @@ var MailPerson = class {
|
|
|
149995
150603
|
* row held for its project's trust goes when the person trusts the project (§7.4): its Release says so. A dismissed answer leaves its question open (D8)
|
|
149996
150604
|
*/
|
|
149997
150605
|
held(action, recipient, messageIds) {
|
|
149998
|
-
if (action === "dismiss") return { changed: this.service.dismissHeld(recipient, messageIds, PERSON_HOLDS) };
|
|
150606
|
+
if (action === "dismiss") return { changed: this.service.holds.dismissHeld(recipient, messageIds, PERSON_HOLDS) };
|
|
149999
150607
|
const projects = new Set(messageIds.flatMap((id3) => this.records.recipient(id3, recipient)?.held === "policy" ? this.records.message(id3)?.senderProject ?? [] : []));
|
|
150000
150608
|
const still = [...projects].find((p) => this.host.untrusted(p));
|
|
150001
150609
|
if (still !== void 0) throw refuse4("untrusted_project", `${this.host.projectLabel(still)} is not trusted: what its sessions send out of it waits until you trust the project, and then goes in order.`);
|
|
150002
150610
|
const policy = messageIds.filter((id3) => this.records.recipient(id3, recipient)?.held === "policy");
|
|
150003
150611
|
for (const p of projects) this.trusted(p);
|
|
150004
150612
|
const letGo = policy.filter((id3) => this.records.recipient(id3, recipient)?.held !== "policy").length;
|
|
150005
|
-
return { changed: letGo + this.service.resendHeld(recipient, messageIds) };
|
|
150613
|
+
return { changed: letGo + this.service.holds.resendHeld(recipient, messageIds) };
|
|
150006
150614
|
}
|
|
150007
150615
|
/**
|
|
150008
150616
|
* Resume on what an earlier build paused (#2014: nothing pauses mail now): a chain's rows held `loop` (an old thread's id names the chains moved
|
|
@@ -150519,7 +151127,7 @@ var Watches = class {
|
|
|
150519
151127
|
this.changed(address, "gone");
|
|
150520
151128
|
}
|
|
150521
151129
|
/**
|
|
150522
|
-
* A handoff moves `from`'s mailbox to `to` (`moveMail`: `
|
|
151130
|
+
* A handoff moves `from`'s mailbox to `to` (`moveMail`: `Handoffs.handOver`, scope `all`), in one transaction with this: its active watches
|
|
150523
151131
|
* are `to`'s, the same rows, and the watches others keep on `from` wait for `to`, from `to`'s state now. One that would have `to` watch itself (the
|
|
150524
151132
|
* original's on its heir, or the heir's on the original) ends, and nobody is told: no one set a watch on itself
|
|
150525
151133
|
*/
|
|
@@ -150765,6 +151373,9 @@ var HELD_WHY = {
|
|
|
150765
151373
|
policy: (m) => `waits until the person trusts ${m.senderProject ?? "your project"}`,
|
|
150766
151374
|
[LINK_HOLD]: (m, calls) => `${heldLine("its computer")} Once the link is back, ${sendOrDrop(calls, m.id)}`
|
|
150767
151375
|
};
|
|
151376
|
+
function quietLine(name) {
|
|
151377
|
+
return `It answers a message that needed no reply and needs none itself, so it reaches ${name} without waking it, at its next turn. If ${name} must act on it, send it again as a question.`;
|
|
151378
|
+
}
|
|
150768
151379
|
var MailTool = class {
|
|
150769
151380
|
constructor(service, records, reach, host) {
|
|
150770
151381
|
this.service = service;
|
|
@@ -150836,7 +151447,7 @@ var MailTool = class {
|
|
|
150836
151447
|
if (!r.ok) return { text: `Refused (${r.why}): ${r.text}`, isError: true };
|
|
150837
151448
|
const who = far.address === "parent" ? `your parent ${JSON.stringify(r.to)}` : far.person ? "the person" : `${JSON.stringify(r.to)}${r.address ? ` (${this.reach.shownId(r.address)})` : ""}`;
|
|
150838
151449
|
const head = r.held ? `Held ${r.messageId} for ${who}: ${heldLine(r.computer)} Drop it with ${mailCalls(this.host.form(sessionId)).done(r.messageId)}.` : `Sent ${r.messageId} to ${who} on ${r.computer}.`;
|
|
150839
|
-
const lines = [head, ...far.replyTo ? [`It answers ${far.replyTo}.`] : [], ...waitLine({ needsReply, answers: far.replyTo !== void 0, clarifies })];
|
|
151450
|
+
const lines = [head, ...far.replyTo ? [`It answers ${far.replyTo}.`] : [], ...r.quiet ? [quietLine(r.to)] : waitLine({ needsReply, answers: far.replyTo !== void 0, clarifies })];
|
|
150840
151451
|
return { text: lines.join(" ") };
|
|
150841
151452
|
} catch (e) {
|
|
150842
151453
|
return failed4(e);
|
|
@@ -151018,7 +151629,7 @@ var MailTool = class {
|
|
|
151018
151629
|
lines.push(`It answers ${answered.id} from ${this.reach.labelOf(answered.sender)}${withdrawn ? ` (${isPerson(answered.sender) ? "the person" : "its sender"} withdrew it)` : ""}.`);
|
|
151019
151630
|
}
|
|
151020
151631
|
if (r.asWork) lines.push(`As an answer to a question about the work you gave ${name}, it is given as work: ${name}'s turn on it is reported to you.`);
|
|
151021
|
-
else if (r.quiet) lines.push(
|
|
151632
|
+
else if (r.quiet) lines.push(quietLine(name));
|
|
151022
151633
|
else if (m.kind === "message") lines.push(...waitLine({ needsReply: m.needsReply, answers: answered !== void 0, clarifies: typeof m.facts.clarifies === "string" }));
|
|
151023
151634
|
if (r.held.length > 0) lines.push(this.heldLine(m.senderProject));
|
|
151024
151635
|
return lines.join(" ");
|
|
@@ -151228,19 +151839,21 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151228
151839
|
};
|
|
151229
151840
|
}
|
|
151230
151841
|
/**
|
|
151231
|
-
* On a hub: a handoff moved tasks it gave linked machines' sessions to another session here (`
|
|
151232
|
-
* told, so its copy names the heir and reads as handed over; the report it sends back goes to the heir either way, by this host's task
|
|
151842
|
+
* On a hub: a handoff moved tasks it gave linked machines' sessions to another session here (`Handoffs.handOver`, #1948 step 6). Each machine is
|
|
151843
|
+
* told, so its copy names the heir and reads as handed over; the report it sends back goes to the heir either way, by this host's task. A message a
|
|
151844
|
+
* machine's session sent that moved goes to that machine (#2530), which gives its row to the heir
|
|
151233
151845
|
*/
|
|
151234
151846
|
async movedAcross(moves) {
|
|
151235
151847
|
for (const move of moves) {
|
|
151236
151848
|
const byMachine = /* @__PURE__ */ new Map();
|
|
151237
151849
|
for (const id3 of move.ids) {
|
|
151238
|
-
|
|
151239
|
-
|
|
151240
|
-
|
|
151850
|
+
const parties = [...this.d.records.recipients(id3).map((row) => row.recipient), this.d.records.message(id3)?.sender ?? ""];
|
|
151851
|
+
for (const party of parties) {
|
|
151852
|
+
const r = this.route(party);
|
|
151853
|
+
if (r?.kind === "machine") byMachine.set(r.machineId, (byMachine.get(r.machineId) ?? /* @__PURE__ */ new Set()).add(id3));
|
|
151241
151854
|
}
|
|
151242
151855
|
}
|
|
151243
|
-
for (const [machineId, ids] of byMachine) await this.tellMove(machineId, { from: move.from, to: move.to, ids });
|
|
151856
|
+
for (const [machineId, ids] of byMachine) await this.tellMove(machineId, { from: move.from, to: move.to, ids: [...ids] });
|
|
151244
151857
|
}
|
|
151245
151858
|
}
|
|
151246
151859
|
/**
|
|
@@ -151253,13 +151866,13 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151253
151866
|
const part = { ...params, ids: params.ids.slice(i, i + MOVE_IDS_PER_CALL) };
|
|
151254
151867
|
const r = m?.reachable ? await m.call("host.mailMove", part).then(() => null, (e) => errorMessage(e)) : "not reachable";
|
|
151255
151868
|
if (!r) continue;
|
|
151256
|
-
this.d.log?.(`[mail] ${m?.name ?? machineId} could not be told that ${part.ids.length}
|
|
151869
|
+
this.d.log?.(`[mail] ${m?.name ?? machineId} could not be told that ${part.ids.length} message(s) went from ${params.from} to ${params.to} in a handoff: ${r}; told again later`);
|
|
151257
151870
|
if (!older(r)) this.untoldMoves.set(machineId, [...this.untoldMoves.get(machineId) ?? [], part]);
|
|
151258
151871
|
}
|
|
151259
151872
|
}
|
|
151260
151873
|
/**
|
|
151261
151874
|
* On a machine: a hub's handoff moved the tasks it gave here (`host.mailMove`). Only from and to that hub's own sessions (never this machine's, never
|
|
151262
|
-
* another host's), and only tasks that hub's sessions sent; anything else is refused and logged
|
|
151875
|
+
* another host's), and only tasks that hub's sessions sent and rows of messages this machine's sessions sent `from` (#2530); anything else is refused and logged
|
|
151263
151876
|
*/
|
|
151264
151877
|
moveFromHub(hub, p) {
|
|
151265
151878
|
const [from, to] = [this.fromHubNames(hub.id, p.from), this.fromHubNames(hub.id, p.to)];
|
|
@@ -151271,8 +151884,8 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151271
151884
|
this.d.log?.(`[mail] ${hub.name} asked to move tasks from ${oneLineText(p.from, 200)} to ${oneLineText(p.to, 200)}, which are not both its sessions: refused`);
|
|
151272
151885
|
return { ok: false, why: "not_allowed", text: `${hub.name} may move only work its own sessions gave here.` };
|
|
151273
151886
|
}
|
|
151274
|
-
const moved = this.d.service.moveAcross(from, to, p.ids);
|
|
151275
|
-
if (moved < p.ids.length) this.d.log?.(`[mail] ${hub.name} moved ${moved} of ${p.ids.length}
|
|
151887
|
+
const moved = this.d.service.handoffs.moveAcross(from, to, p.ids);
|
|
151888
|
+
if (moved < p.ids.length) this.d.log?.(`[mail] ${hub.name} moved ${moved} of ${p.ids.length} message(s) from ${from}: the rest are no open task it gave here, nor unread or open mail a session here sent it`);
|
|
151276
151889
|
return { ok: true, moved };
|
|
151277
151890
|
}
|
|
151278
151891
|
// ── Receipts ──
|
|
@@ -151912,14 +152525,15 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
151912
152525
|
const address = to && this.route(to) && this.foreign(to) ? to : null;
|
|
151913
152526
|
if (address) {
|
|
151914
152527
|
this.names.set(address, `${r.to} on ${computer}`);
|
|
151915
|
-
if (this.d.records.message(r.messageId))
|
|
151916
|
-
|
|
151917
|
-
|
|
151918
|
-
|
|
151919
|
-
|
|
152528
|
+
if (!this.d.records.message(r.messageId)) {
|
|
152529
|
+
try {
|
|
152530
|
+
this.d.service.sentAcross(sender, { id: r.messageId, to: address, ...fields5 });
|
|
152531
|
+
} catch (e) {
|
|
152532
|
+
this.d.log?.(`[mail] the copy of ${r.messageId}, which ${computer} took, could not be kept here: ${errorMessage(e)}`);
|
|
152533
|
+
}
|
|
151920
152534
|
}
|
|
151921
152535
|
}
|
|
151922
|
-
return { ok: true, messageId: r.messageId, to: r.to, address: address ?? "", computer };
|
|
152536
|
+
return { ok: true, messageId: r.messageId, to: r.to, address: address ?? "", computer, ...r.quiet ? { quiet: true } : {} };
|
|
151923
152537
|
}
|
|
151924
152538
|
// ── Taking from the other side ──
|
|
151925
152539
|
/**
|
|
@@ -151948,7 +152562,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
151948
152562
|
const m = this.peers?.machine?.(route.machineId);
|
|
151949
152563
|
if (!m) return { ok: false, why: "link_down", text: `No machine linked to ${this.selfName()} now goes by ${route.machineId}, and no computer that links yours does either, so nothing was sent.` };
|
|
151950
152564
|
const r = await this.ask(m, "host.mail", { from: sender, name: this.names.get(sender) ?? p.name, to: route.sessionId, text: p.text, ...pick4(p) });
|
|
151951
|
-
return r.ok ? { ok: true, messageId: r.messageId, to: `${r.to} on ${m.name}`, address: to } : r;
|
|
152565
|
+
return r.ok ? { ok: true, messageId: r.messageId, to: `${r.to} on ${m.name}`, address: to, ...r.quiet ? { quiet: true } : {} } : r;
|
|
151952
152566
|
}
|
|
151953
152567
|
return this.write(sender, to, p);
|
|
151954
152568
|
}
|
|
@@ -152021,7 +152635,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
152021
152635
|
if (!FOREIGN_ID.test(p.id) || p.id.startsWith(`${this.d.hostId}.`)) return { ok: false, why: "bad_value", text: `${oneLineText(p.id, 200)} is not an id another computer may give a message.` };
|
|
152022
152636
|
const had = this.d.records.message(p.id);
|
|
152023
152637
|
if (had) {
|
|
152024
|
-
if (had.sender === from && this.d.records.recipient(p.id, to)) return { ok: true, messageId: p.id, to: this.label(to, from), address: to };
|
|
152638
|
+
if (had.sender === from && this.d.records.recipient(p.id, to)) return { ok: true, messageId: p.id, to: this.label(to, from), address: to, ...had.facts.quiet === true ? { quiet: true } : {} };
|
|
152025
152639
|
return { ok: false, why: "bad_value", text: `${oneLineText(p.id, 200)} is the id of another message on ${this.selfName()}.` };
|
|
152026
152640
|
}
|
|
152027
152641
|
}
|
|
@@ -152035,7 +152649,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
152035
152649
|
return { ok: false, why: "not_allowed", text: `${oneLineText(this.nameOf(from), 200)} may send a notice only to a session that mailed it, and ${this.label(to, from)} did not, so nothing was written.` };
|
|
152036
152650
|
}
|
|
152037
152651
|
const sent = this.d.service.send(from, { to: [to], text: p.text, needsReply: p.notice ? false : p.needsReply ?? true, ...p.urgent && !p.notice ? { urgent: true } : {}, ...p.replyTo && !p.notice ? { replyTo: p.replyTo } : {}, ...p.id ? { id: p.id } : {}, ...p.subject ? { subject: p.subject } : {}, ...p.choices ? { choices: p.choices } : {} });
|
|
152038
|
-
return { ok: true, messageId: sent.message.id, to: this.label(to), address: to };
|
|
152652
|
+
return { ok: true, messageId: sent.message.id, to: this.label(to), address: to, ...sent.quiet ? { quiet: true } : {} };
|
|
152039
152653
|
} catch (e) {
|
|
152040
152654
|
const why2 = refusalReason(e);
|
|
152041
152655
|
const lost = why2 === "unknown_message" && p.replyTo !== void 0 && !this.d.records.message(p.replyTo);
|
|
@@ -152512,6 +153126,16 @@ function hostMail(store2, sessions, opts) {
|
|
|
152512
153126
|
},
|
|
152513
153127
|
// A session of a hub this host is linked to (#2067 item 2), by the name it was last heard by
|
|
152514
153128
|
foreign: (address) => far.across?.foreignName(address),
|
|
153129
|
+
/*
|
|
153130
|
+
* A session a hub's session started here keeps no parent here (#2520): its start_agent task names that session, by its address there, and a handoff
|
|
153131
|
+
* there moves it (`host.mailMove`). Read as its parent, its replies wake the session as a parent's do (`quietAnswer`)
|
|
153132
|
+
*/
|
|
153133
|
+
starterElsewhere: (id3) => {
|
|
153134
|
+
if (!sessions.sessionInfo(id3)?.startedFromHub) return null;
|
|
153135
|
+
const sender = store2.mailbox.firstTask(addressOf(id3), "start_agent")?.sender;
|
|
153136
|
+
const party = sender ? parseAddress(sender) : null;
|
|
153137
|
+
return sender && party?.kind === "session" && party.host !== hostId ? sender : null;
|
|
153138
|
+
},
|
|
152515
153139
|
hubPerson: (hostId2) => far.across?.isHub(hostId2) === true,
|
|
152516
153140
|
shown: (address, reader) => refs.shown(address, reader),
|
|
152517
153141
|
assistantId: () => sessions.assistantId(),
|
|
@@ -152704,13 +153328,13 @@ function hostMail(store2, sessions, opts) {
|
|
|
152704
153328
|
},
|
|
152705
153329
|
handOver: (from, to, which, children) => {
|
|
152706
153330
|
const moveMail = () => {
|
|
152707
|
-
const moved = service.handOver(addressOf(from), addressOf(to), which === "all" ? "all" : { senders: which.senders.map(addressOf) }, children.map(addressOf));
|
|
152708
|
-
void across.movedAcross(service.takeMoves());
|
|
153331
|
+
const moved = service.handoffs.handOver(addressOf(from), addressOf(to), which === "all" ? "all" : { senders: which.senders.map(addressOf) }, children.map(addressOf));
|
|
153332
|
+
void across.movedAcross(service.handoffs.takeMoves());
|
|
152709
153333
|
return moved;
|
|
152710
153334
|
};
|
|
152711
153335
|
return aboutSessions(which === "all" ? watches.handOver(addressOf(from), addressOf(to), moveMail) : moveMail());
|
|
152712
153336
|
},
|
|
152713
|
-
handOverPreview: (from, to) => aboutSessions(service.handOverPreview(addressOf(from), addressOf(to))),
|
|
153337
|
+
handOverPreview: (from, to) => aboutSessions(service.handoffs.handOverPreview(addressOf(from), addressOf(to))),
|
|
152714
153338
|
openWork: (id3) => openWork(service, store2, addressOf(id3)),
|
|
152715
153339
|
sessionChanged: (id3) => delivery.poke(id3),
|
|
152716
153340
|
notice: (id3, body, dedupeKey) => {
|
|
@@ -152777,11 +153401,18 @@ function hostMail(store2, sessions, opts) {
|
|
|
152777
153401
|
turn: (id3) => store2.mailbox.nextTurnSeq(id3) - 1,
|
|
152778
153402
|
ended: (id3) => withdrawEndedCards(store2.mailbox, addressOf(id3), cardStands)
|
|
152779
153403
|
},
|
|
153404
|
+
// A giver on another computer is named by its address. Read before the withdrawal, which the turn's own record does not depend on
|
|
153405
|
+
cancelGiven: (id3, giver, taskId) => {
|
|
153406
|
+
const from = parseAddress(giver) ? giver : addressOf(giver);
|
|
153407
|
+
const alone = service.stops.alone(addressOf(id3), from, { gaveIt: "work", starter: taskId });
|
|
153408
|
+
if (store2.mailbox.message(taskId)?.sender === from) service.done(from, taskId);
|
|
153409
|
+
return alone;
|
|
153410
|
+
},
|
|
152780
153411
|
turnInputs: (id3, turn) => delivery.turnInputs(addressOf(id3), turn),
|
|
152781
153412
|
turnStarted: turnRecorder(service, store2.mailbox, mailTurns),
|
|
152782
153413
|
refusesDelegation: (callerId, target, call2) => refusesDelegation(service, reach, callerId, target, call2),
|
|
152783
153414
|
roleMoved: (to) => {
|
|
152784
|
-
if (service.roleMoved(addressOf(to)) > 0) delivery.poke(to);
|
|
153415
|
+
if (service.handoffs.roleMoved(addressOf(to)) > 0) delivery.poke(to);
|
|
152785
153416
|
}
|
|
152786
153417
|
};
|
|
152787
153418
|
return {
|
|
@@ -153730,7 +154361,7 @@ function pickStrays(rows3, cwdOf, roots, selfPid, marks, mark) {
|
|
|
153730
154361
|
}
|
|
153731
154362
|
var LIST_TIMEOUT_MS = 12e3;
|
|
153732
154363
|
var exec = (file2, args, opts) => execText(file2, args, opts);
|
|
153733
|
-
function
|
|
154364
|
+
function unread3(what, e) {
|
|
153734
154365
|
console.error(`[strays] ${what} could not be read (${isObj(e) && typeof e.message === "string" ? e.message.split("\n")[0] : String(e)}); leftovers may be missing from the list`);
|
|
153735
154366
|
}
|
|
153736
154367
|
async function psRows(run2) {
|
|
@@ -153738,7 +154369,7 @@ async function psRows(run2) {
|
|
|
153738
154369
|
const { stdout } = await run2("ps", ["-U", userInfo2().username, "-o", "pid=,ppid=,tty=,command="], { maxBuffer: 8 * 1024 * 1024, timeoutMs: LIST_TIMEOUT_MS });
|
|
153739
154370
|
return parsePsRows(stdout);
|
|
153740
154371
|
} catch (e) {
|
|
153741
|
-
|
|
154372
|
+
unread3("the process list", e);
|
|
153742
154373
|
return [];
|
|
153743
154374
|
}
|
|
153744
154375
|
}
|
|
@@ -153749,7 +154380,7 @@ async function cwdsOf(run2, pids) {
|
|
|
153749
154380
|
return parseLsofCwd(stdout);
|
|
153750
154381
|
} catch (e) {
|
|
153751
154382
|
const partial2 = isObj(e) && typeof e.stdout === "string" ? e.stdout : void 0;
|
|
153752
|
-
if (isObj(e) && (e.ended !== void 0 || e.signal != null || typeof e.code === "string"))
|
|
154383
|
+
if (isObj(e) && (e.ended !== void 0 || e.signal != null || typeof e.code === "string")) unread3("the working folders", e);
|
|
153753
154384
|
return partial2 ? parseLsofCwd(partial2) : /* @__PURE__ */ new Map();
|
|
153754
154385
|
}
|
|
153755
154386
|
}
|
|
@@ -153762,7 +154393,7 @@ async function ownerMarks(pids) {
|
|
|
153762
154393
|
try {
|
|
153763
154394
|
return await environmentValues(OWNER_MARK, pids);
|
|
153764
154395
|
} catch (e) {
|
|
153765
|
-
|
|
154396
|
+
unread3("the processes' owner marks", e);
|
|
153766
154397
|
return /* @__PURE__ */ new Map();
|
|
153767
154398
|
}
|
|
153768
154399
|
}
|
|
@@ -154610,6 +155241,11 @@ function createRpcHandler(mgr2, adapters2, { settleDeletedProjects, deleteOutloo
|
|
|
154610
155241
|
if (!hub) throw rpcError("Only a hub that offered on this connection answers the cards of work it gave here");
|
|
154611
155242
|
return mgr2.linkedHost.hubAnswer(p.sessionId, sessionAddress(hub.id, p.caller), p.card, p.text);
|
|
154612
155243
|
},
|
|
155244
|
+
"host.stopTask": async (p, ctx) => {
|
|
155245
|
+
const hub = ctx ? hubs2?.on?.(ctx.client) : void 0;
|
|
155246
|
+
if (!hub) throw rpcError("Only a hub that offered on this connection stops the work it gave here");
|
|
155247
|
+
return mgr2.linkedHost.hubStopTask(p.sessionId, sessionAddress(hub.id, p.caller), p.task);
|
|
155248
|
+
},
|
|
154613
155249
|
"host.apps": async (p, ctx) => {
|
|
154614
155250
|
const { hub, calls } = appsHub(ctx);
|
|
154615
155251
|
return { apps: await calls.list(hub, p.session, p.start) };
|
|
@@ -156013,10 +156649,6 @@ var AgentVersionService = class {
|
|
|
156013
156649
|
readAutoApply: () => true,
|
|
156014
156650
|
writeAutoApply: () => {
|
|
156015
156651
|
},
|
|
156016
|
-
readSeen: () => ({}),
|
|
156017
|
-
writeSeen: () => {
|
|
156018
|
-
},
|
|
156019
|
-
capabilityCheck: ({ tool, from, to }) => console.error(`[agent-versions] ${tool} ${from} -> ${to}; no capability check runs yet (#270)`),
|
|
156020
156652
|
now: Date.now,
|
|
156021
156653
|
quietMs: QUIET_MS,
|
|
156022
156654
|
...deps
|
|
@@ -156061,21 +156693,6 @@ var AgentVersionService = class {
|
|
|
156061
156693
|
const tools = this.deps.tools().filter((t) => t.installedVersion);
|
|
156062
156694
|
const read2 = await Promise.all(tools.map(async (t) => [t.tool, await t.installedVersion().catch(() => null)]));
|
|
156063
156695
|
const installed = Object.fromEntries(read2);
|
|
156064
|
-
const seen = this.deps.readSeen();
|
|
156065
|
-
const nextSeen = { ...seen };
|
|
156066
|
-
for (const [tool, version2] of read2) {
|
|
156067
|
-
if (!version2) continue;
|
|
156068
|
-
const before = seen[tool];
|
|
156069
|
-
if (before && before !== version2) {
|
|
156070
|
-
try {
|
|
156071
|
-
this.deps.capabilityCheck({ tool, from: before, to: version2 });
|
|
156072
|
-
} catch (err) {
|
|
156073
|
-
console.error(`[agent-versions] the capability check for ${tool} failed: ${err.message}`);
|
|
156074
|
-
}
|
|
156075
|
-
}
|
|
156076
|
-
nextSeen[tool] = version2;
|
|
156077
|
-
}
|
|
156078
|
-
if (JSON.stringify(nextSeen) !== JSON.stringify(seen)) this.deps.writeSeen(nextSeen);
|
|
156079
156696
|
this.status = { ...this.status, installed, checkedAt: this.deps.now() };
|
|
156080
156697
|
this.deps.publish(this.current());
|
|
156081
156698
|
if (this.status.autoApply) for (const s of this.deps.sessions.listSessions()) this.lookSoon(s.id);
|
|
@@ -157599,6 +158216,23 @@ function runSsh(opts) {
|
|
|
157599
158216
|
});
|
|
157600
158217
|
}
|
|
157601
158218
|
|
|
158219
|
+
// packages/agent-host/src/links/away.ts
|
|
158220
|
+
var SSH_FAILED = /^ssh could not reach .*?: /;
|
|
158221
|
+
var CONNECT_FAILED = "Operation timed out|Connection timed out|No route to host|Network is unreachable|Host is down";
|
|
158222
|
+
var NO_ANSWER2 = new RegExp(
|
|
158223
|
+
[
|
|
158224
|
+
`^(?:ssh: )?connect to host \\S+ port \\d+: (?:${CONNECT_FAILED})\\.?$`,
|
|
158225
|
+
"^(?:ssh: )?Could not resolve hostname \\S+: .+$",
|
|
158226
|
+
`^channel \\d+: open failed: connect failed: (?:${CONNECT_FAILED})\\.?$`,
|
|
158227
|
+
"^Connection to UNKNOWN port 65535 timed out$"
|
|
158228
|
+
].join("|"),
|
|
158229
|
+
"i"
|
|
158230
|
+
);
|
|
158231
|
+
function isNoAnswer(message) {
|
|
158232
|
+
const failed5 = SSH_FAILED.exec(message);
|
|
158233
|
+
return failed5 !== null && NO_ANSWER2.test(message.slice(failed5[0].length).trim());
|
|
158234
|
+
}
|
|
158235
|
+
|
|
157602
158236
|
// packages/agent-host/src/links/tunnel.ts
|
|
157603
158237
|
function parseConnectionLine(stdout, spec) {
|
|
157604
158238
|
const lines = stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
@@ -157940,7 +158574,7 @@ var SshTunnel = class {
|
|
|
157940
158574
|
const remote = this.opts.remote ?? { shell: "posix" };
|
|
157941
158575
|
const r = await this.run([...this.config(), "-T", "-o", "BatchMode=yes", "-o", "ConnectTimeout=15", "--", this.opts.target, detachCommand(remote, this.opts.hubName ?? hostname3())], void 0, this.opts.detachTimeoutMs ?? SSH_DETACH_TIMEOUT_MS);
|
|
157942
158576
|
this.ifClosed();
|
|
157943
|
-
if (r.code === 255) throw new Error(
|
|
158577
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
157944
158578
|
if (r.stdout.includes(NOT_FOUND2)) throw notInstalled(this.where, remote);
|
|
157945
158579
|
let answer;
|
|
157946
158580
|
try {
|
|
@@ -158004,7 +158638,7 @@ var SshTunnel = class {
|
|
|
158004
158638
|
throw again;
|
|
158005
158639
|
}
|
|
158006
158640
|
}
|
|
158007
|
-
if (r.code === 255) throw new Error(
|
|
158641
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
158008
158642
|
return markers.length ? { ...r, stdout: r.stdout.split(/\r?\n/).filter((l) => !markers.includes(l.trim())).join("\n") } : r;
|
|
158009
158643
|
}
|
|
158010
158644
|
/** The connection line again until the link-bound host answers, or the forward that runs it ends */
|
|
@@ -158068,7 +158702,7 @@ var SshTunnel = class {
|
|
|
158068
158702
|
this.pairs = true;
|
|
158069
158703
|
return this.connectionLine();
|
|
158070
158704
|
}
|
|
158071
|
-
if (r.code === 255) throw new Error(
|
|
158705
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
158072
158706
|
if (r.stdout.includes(NOT_FOUND2)) throw notInstalled(this.where, remote);
|
|
158073
158707
|
try {
|
|
158074
158708
|
const line = parseConnectionLine(r.stdout, remote);
|
|
@@ -158196,11 +158830,15 @@ function withoutClixml(s) {
|
|
|
158196
158830
|
parts.push(plainPart(text3));
|
|
158197
158831
|
return parts.join("").replace(ANSI2, "").split(/\r?\n/);
|
|
158198
158832
|
}
|
|
158833
|
+
var NAMES_AN_ERROR = new RegExp(`error|denied|refused|timed out|not found|cannot|could not|${CONNECT_FAILED}`, "i");
|
|
158199
158834
|
function lastLine(s, ansi = ansiText) {
|
|
158200
158835
|
const lines = withoutClixml(s).map((l) => l.trim()).filter((l) => l && !l.startsWith("**") && !/^Node\.js v\d/.test(l) && !/^at /.test(l));
|
|
158201
|
-
const line = [...lines].reverse().find((l) =>
|
|
158836
|
+
const line = [...lines].reverse().find((l) => NAMES_AN_ERROR.test(l)) ?? lines.at(-1) ?? "";
|
|
158202
158837
|
return unescapeBytes(line, ansi);
|
|
158203
158838
|
}
|
|
158839
|
+
function sshFailure(target, stderr) {
|
|
158840
|
+
return `ssh could not reach ${target}: ${lastLine(stderr) || "no answer"}`;
|
|
158841
|
+
}
|
|
158204
158842
|
function unescapeBytes(line, ansi = ansiText) {
|
|
158205
158843
|
return line.replace(/(?:\\[23][0-7]{2})+/g, (run2) => {
|
|
158206
158844
|
const bytes2 = Buffer.from(run2.slice(1).split("\\").map((o) => parseInt(o, 8)));
|
|
@@ -159258,23 +159896,6 @@ function channel(version2) {
|
|
|
159258
159896
|
return version2.slice(dash + 1).split(".")[0] ?? "stable";
|
|
159259
159897
|
}
|
|
159260
159898
|
|
|
159261
|
-
// packages/agent-host/src/links/away.ts
|
|
159262
|
-
var SSH_FAILED = /^ssh could not reach .*?: /;
|
|
159263
|
-
var CONNECT_FAILED = "Operation timed out|Connection timed out|No route to host|Network is unreachable|Host is down";
|
|
159264
|
-
var NO_ANSWER2 = new RegExp(
|
|
159265
|
-
[
|
|
159266
|
-
`^(?:ssh: )?connect to host \\S+ port \\d+: (?:${CONNECT_FAILED})\\.?$`,
|
|
159267
|
-
"^(?:ssh: )?Could not resolve hostname \\S+: .+$",
|
|
159268
|
-
`^channel \\d+: open failed: connect failed: (?:${CONNECT_FAILED})\\.?$`,
|
|
159269
|
-
"^Connection to UNKNOWN port 65535 timed out$"
|
|
159270
|
-
].join("|"),
|
|
159271
|
-
"i"
|
|
159272
|
-
);
|
|
159273
|
-
function isNoAnswer(message) {
|
|
159274
|
-
const failed5 = SSH_FAILED.exec(message);
|
|
159275
|
-
return failed5 !== null && NO_ANSWER2.test(message.slice(failed5[0].length).trim());
|
|
159276
|
-
}
|
|
159277
|
-
|
|
159278
159899
|
// packages/agent-host/src/links/update.ts
|
|
159279
159900
|
import { randomUUID as randomUUID29 } from "node:crypto";
|
|
159280
159901
|
function parseStopLine(stdout) {
|
|
@@ -160901,7 +161522,7 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
160901
161522
|
c.step(step, count);
|
|
160902
161523
|
this.deps.log?.(`[links] ${this.name}: ${why2}`);
|
|
160903
161524
|
};
|
|
160904
|
-
const
|
|
161525
|
+
const unread4 = () => show("wait_unread", "what runs there cannot be read now; the update keeps waiting, since the sessions there may be in a turn (Cancel ends it)");
|
|
160905
161526
|
const busy = (a) => {
|
|
160906
161527
|
const turns = turnsRunning(a);
|
|
160907
161528
|
show("wait_idle", `the update waits for ${turns} ${turns === 1 ? "session" : "sessions"} in a turn`, turns);
|
|
@@ -160919,10 +161540,10 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
160919
161540
|
return null;
|
|
160920
161541
|
}
|
|
160921
161542
|
if (again.activity) busy(again.activity);
|
|
160922
|
-
else
|
|
161543
|
+
else unread4();
|
|
160923
161544
|
} else busy(r.activity);
|
|
160924
161545
|
} else if (seen) {
|
|
160925
|
-
|
|
161546
|
+
unread4();
|
|
160926
161547
|
} else if (r.cannot || ++blind > ACTIVITY_UNREAD_RETRIES) {
|
|
160927
161548
|
this.deps.log?.(`[links] ${this.name}: it cannot be told what runs there, so the update does not wait for it`);
|
|
160928
161549
|
return null;
|
|
@@ -161122,7 +161743,7 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
161122
161743
|
if (!exec2) throw linkError2(`This computer has no shell on ${this.name} to withdraw a credential`);
|
|
161123
161744
|
if (this.endpoint?.line.credential === credentialId) throw linkError2(`That is this computer's own credential on ${this.name}, made again at each link`);
|
|
161124
161745
|
const r = await exec2(revokeCommand(this.record.remote, credentialId));
|
|
161125
|
-
if (r.code === 255) throw linkError2(
|
|
161746
|
+
if (r.code === 255) throw linkError2(sshFailure(this.record.sshTarget, r.stderr));
|
|
161126
161747
|
const said = parseRevoke(r.stdout);
|
|
161127
161748
|
if (said === null) throw linkError2(`${this.name} did not say whether it withdrew the credential${lastLine(r.stderr) ? `: ${lastLine(r.stderr)}` : ""}`);
|
|
161128
161749
|
this.revokedHere.add(credentialId);
|
|
@@ -161897,6 +162518,14 @@ function linkedSessions(machines, route = notRouted, options = {}) {
|
|
|
161897
162518
|
return {};
|
|
161898
162519
|
});
|
|
161899
162520
|
},
|
|
162521
|
+
stopTask(sessionId, callerId, taskId) {
|
|
162522
|
+
return viaSession(sessionId, async (m) => {
|
|
162523
|
+
const r = await m.call("host.stopTask", { sessionId: m.q.strip(sessionId, "The session"), caller: callerId, task: taskId }).catch((e) => {
|
|
162524
|
+
throw /Unknown method/i.test(errorMessage(e)) ? new Error(`${m.name} runs an older Centralu, which cannot stop work from this computer. Update Centralu on ${m.name}`) : e;
|
|
162525
|
+
});
|
|
162526
|
+
return { stopped: isObj(r) && r.stopped === true };
|
|
162527
|
+
});
|
|
162528
|
+
},
|
|
161900
162529
|
machineLinked(machineId) {
|
|
161901
162530
|
return !!machineById(machineId);
|
|
161902
162531
|
},
|
|
@@ -161974,7 +162603,8 @@ function linkedSessions(machines, route = notRouted, options = {}) {
|
|
|
161974
162603
|
const s = (m.lastKnown("sessions") ?? []).find((x) => isObj(x) && x.id === at2.id);
|
|
161975
162604
|
if (!isObj(s)) return null;
|
|
161976
162605
|
const p = (m.lastKnown("projects") ?? []).find((x) => isObj(x) && x.id === s.projectId);
|
|
161977
|
-
|
|
162606
|
+
const projectName = isObj(p) ? oneLine4(p.name) : "(none)";
|
|
162607
|
+
return { name: oneLine4(s.name), project: `${projectName} on ${m.name}`, projectName };
|
|
161978
162608
|
},
|
|
161979
162609
|
lastWords(sessionId, maxChars, opts) {
|
|
161980
162610
|
return viaSession(
|
|
@@ -162394,6 +163024,7 @@ var ROUTES = {
|
|
|
162394
163024
|
"host.mailMove": HUB,
|
|
162395
163025
|
"host.cards": HUB,
|
|
162396
163026
|
"host.answerCard": HUB,
|
|
163027
|
+
"host.stopTask": HUB,
|
|
162397
163028
|
// A project's app here used by the hub's sessions (#1938): answered here, never passed on
|
|
162398
163029
|
"host.apps": HUB,
|
|
162399
163030
|
"host.appCall": HUB,
|
|
@@ -163678,7 +164309,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
|
|
|
163678
164309
|
console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
|
|
163679
164310
|
process.exit(1);
|
|
163680
164311
|
}) : launch.token;
|
|
163681
|
-
var BUILD = true ? "
|
|
164312
|
+
var BUILD = true ? "dba860f" : "dev";
|
|
163682
164313
|
var { values } = parseArgs({
|
|
163683
164314
|
options: {
|
|
163684
164315
|
port: { type: "string", default: "5175" },
|
|
@@ -163904,7 +164535,6 @@ mgr.useUpdates(updates);
|
|
|
163904
164535
|
var updateApply = new UpdateApplyBroker({ push: (e) => events.push(e), windows: () => server.clientCount });
|
|
163905
164536
|
mgr.useUpdateApply(updateApply);
|
|
163906
164537
|
var AUTO_APPLY_AGENT_VERSIONS_KEY = "agents.autoApplyVersions";
|
|
163907
|
-
var AGENT_VERSIONS_SEEN_KEY = "agents.versionsSeen";
|
|
163908
164538
|
var autoApplyAgentVersions = flagSetting(store.settings, AUTO_APPLY_AGENT_VERSIONS_KEY, true);
|
|
163909
164539
|
var agentVersions = new AgentVersionService({
|
|
163910
164540
|
tools: () => [...adapters.values()].map((a) => ({ tool: a.tool, installedVersion: a.installedVersion?.bind(a) })),
|
|
@@ -163914,9 +164544,7 @@ var agentVersions = new AgentVersionService({
|
|
|
163914
164544
|
// Not listening yet: the first window asks
|
|
163915
164545
|
publish: (status) => events.push({ type: "agent_versions", status }),
|
|
163916
164546
|
readAutoApply: autoApplyAgentVersions.read,
|
|
163917
|
-
writeAutoApply: autoApplyAgentVersions.write
|
|
163918
|
-
readSeen: () => asObj(parseJson(store.settings.appSetting(AGENT_VERSIONS_SEEN_KEY))),
|
|
163919
|
-
writeSeen: (seen) => store.settings.setAppSetting(AGENT_VERSIONS_SEEN_KEY, JSON.stringify(seen))
|
|
164547
|
+
writeAutoApply: autoApplyAgentVersions.write
|
|
163920
164548
|
});
|
|
163921
164549
|
for (const a of adapters.values()) a.setup?.onChange((setup) => events.push({ type: "tool_setup", tool: a.tool, setup }));
|
|
163922
164550
|
versionsRef.current = agentVersions;
|