@centralu/win32-x64 0.1.0-beta.80 → 0.1.0-beta.82
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.82";
|
|
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({
|
|
@@ -60896,6 +60897,8 @@ var hostParams = {
|
|
|
60896
60897
|
* --window` and cannot write to a host it did not start. `cancelled`: the announced end was called off
|
|
60897
60898
|
*/
|
|
60898
60899
|
"host.systemEnding": external_exports.object({ cancelled: external_exports.boolean().optional() }),
|
|
60900
|
+
/** Local dev:live tab pairing code for human message attribution on this socket only */
|
|
60901
|
+
"host.trustDevTab": external_exports.object({ code: external_exports.string().regex(/^[A-Z0-9]{3}-[A-Z0-9]{3}$/) }),
|
|
60899
60902
|
/**
|
|
60900
60903
|
* docs/plans/remote-hub.md §12.7: sent at every connect and when its switch changes. This host calls that hub back only
|
|
60901
60904
|
* on the connection the offer came in on, and shows it "not reachable" once that is gone.
|
|
@@ -60912,6 +60915,8 @@ var hostParams = {
|
|
|
60912
60915
|
*/
|
|
60913
60916
|
"host.cards": external_exports.object({ sessionId: SessionId, caller: HubCaller }),
|
|
60914
60917
|
"host.answerCard": external_exports.object({ sessionId: SessionId, caller: HubCaller, card: external_exports.string().min(1).max(200), text: external_exports.string().max(2e4) }),
|
|
60918
|
+
/** The call of the hub's session `caller` that gave task `task` was cancelled: this host stops the turn that task alone started (#2485) */
|
|
60919
|
+
"host.stopTask": external_exports.object({ sessionId: SessionId, caller: HubCaller, task: external_exports.string().min(1).max(200) }),
|
|
60915
60920
|
/** docs/plans/remote-hub.md §13. Only on a connection a hub offered apps on; never routed */
|
|
60916
60921
|
"host.apps": LinkedAppsParams,
|
|
60917
60922
|
"host.appCall": LinkedAppCallParams,
|
|
@@ -60977,6 +60982,7 @@ var hostResults = {
|
|
|
60977
60982
|
]),
|
|
60978
60983
|
"host.handover": external_exports.object({ ok: external_exports.literal(true) }),
|
|
60979
60984
|
"host.systemEnding": external_exports.object({ ok: external_exports.literal(true) }),
|
|
60985
|
+
"host.trustDevTab": external_exports.object({ ok: external_exports.literal(true) }),
|
|
60980
60986
|
// `mail`: this host takes `host.mail`, so the hub's task for a child here says to mail
|
|
60981
60987
|
// `apps`: this host answers `host.apps` and `host.appCall`
|
|
60982
60988
|
// `tasks`: this host takes the hub's tasks as mail and reports them back (`host.mail` with `task`)
|
|
@@ -60992,7 +60998,7 @@ var hostResults = {
|
|
|
60992
60998
|
}),
|
|
60993
60999
|
// As `hub.mail` answers (machines-hub.ts `HubMailResult`, which the window's bundle leaves out)
|
|
60994
61000
|
"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() }),
|
|
61001
|
+
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
61002
|
external_exports.object({ ok: external_exports.literal(false), why: external_exports.string().min(1).max(100), text: external_exports.string().max(4e3) })
|
|
60997
61003
|
]),
|
|
60998
61004
|
"host.mailRows": external_exports.object({ ok: external_exports.literal(true) }),
|
|
@@ -61000,6 +61006,7 @@ var hostResults = {
|
|
|
61000
61006
|
"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
61007
|
"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
61008
|
"host.answerCard": external_exports.object({ ok: external_exports.literal(true) }),
|
|
61009
|
+
"host.stopTask": external_exports.object({ stopped: external_exports.boolean() }),
|
|
61003
61010
|
"host.apps": LinkedAppsResult,
|
|
61004
61011
|
"host.appCall": LinkedAppCallResult,
|
|
61005
61012
|
"host.appCancel": external_exports.object({ ok: external_exports.literal(true) }),
|
|
@@ -61183,6 +61190,11 @@ var MessageImage = external_exports.discriminatedUnion("ok", [
|
|
|
61183
61190
|
file: external_exports.string().optional()
|
|
61184
61191
|
})
|
|
61185
61192
|
]);
|
|
61193
|
+
var MessageFileRefusal = external_exports.enum(["not_mentioned", "not_found", "unreadable"]);
|
|
61194
|
+
var MessageFile = external_exports.discriminatedUnion("ok", [
|
|
61195
|
+
external_exports.object({ ok: external_exports.literal(true), file: external_exports.string() }),
|
|
61196
|
+
external_exports.object({ ok: external_exports.literal(false), reason: MessageFileRefusal, message: external_exports.string() })
|
|
61197
|
+
]);
|
|
61186
61198
|
var FsResolvePurpose = external_exports.enum(["trash", "reveal", "open", "project"]);
|
|
61187
61199
|
|
|
61188
61200
|
// packages/protocol/src/commands/projects.ts
|
|
@@ -61685,6 +61697,8 @@ var sessionsParams = {
|
|
|
61685
61697
|
* `path` as the reply wrote it; the host resolves `~`, a path relative to the session's folder and a `file://` URL.
|
|
61686
61698
|
*/
|
|
61687
61699
|
"messages.image": external_exports.object({ sessionId: SessionId, path: external_exports.string().min(1).max(4096) }),
|
|
61700
|
+
/** Resolves a local file or folder link a reply named for native reveal; refuses unmentioned or off-machine paths */
|
|
61701
|
+
"messages.resolveFile": external_exports.object({ sessionId: SessionId, path: external_exports.string().min(1).max(4096) }),
|
|
61688
61702
|
"messages.search": external_exports.object({ query: external_exports.string(), limit: external_exports.number().optional() }),
|
|
61689
61703
|
"sessions.reorder": external_exports.object({ projectId: ProjectId, orderedIds: external_exports.array(external_exports.string()) }),
|
|
61690
61704
|
"sessions.list": external_exports.object({}),
|
|
@@ -61877,6 +61891,7 @@ var sessionsResults = {
|
|
|
61877
61891
|
"agents.sleepPolicy": SleepPolicy,
|
|
61878
61892
|
"agents.setSleepPolicy": SleepPolicy,
|
|
61879
61893
|
"messages.image": MessageImage,
|
|
61894
|
+
"messages.resolveFile": MessageFile,
|
|
61880
61895
|
"messages.search": external_exports.array(external_exports.object({ sessionId: external_exports.string(), seq: external_exports.number(), snippet: external_exports.string() })),
|
|
61881
61896
|
"sessions.reorder": external_exports.array(SessionInfo),
|
|
61882
61897
|
"sessions.list": external_exports.array(SessionInfo),
|
|
@@ -62423,7 +62438,9 @@ var HelloServer = external_exports.object({
|
|
|
62423
62438
|
* The turns this host continues because an update cut them (`host.stop { forUpdate }`), `at` on this host's clock.
|
|
62424
62439
|
* Empty: it continues such turns; absent: it predates that
|
|
62425
62440
|
*/
|
|
62426
|
-
updateContinued: external_exports.array(external_exports.object({ sessionId: external_exports.string(), at: external_exports.number() })).optional().catch(void 0)
|
|
62441
|
+
updateContinued: external_exports.array(external_exports.object({ sessionId: external_exports.string(), at: external_exports.number() })).optional().catch(void 0),
|
|
62442
|
+
/** Sent when the socket authenticated with the limited credential (`'limited'`); absent on full connections and older hosts */
|
|
62443
|
+
rights: external_exports.enum(["full", "limited"]).optional().catch(void 0)
|
|
62427
62444
|
});
|
|
62428
62445
|
var RpcRequest = external_exports.object({
|
|
62429
62446
|
kind: external_exports.literal("rpc"),
|
|
@@ -62726,7 +62743,9 @@ var LONG_CALLS = /* @__PURE__ */ new Set([
|
|
|
62726
62743
|
var GIT_WRITE_BUDGET_MS = GIT_WRITE_TIMEOUT_MS + 6e4;
|
|
62727
62744
|
var GIT_WRITE_CALLS = /* @__PURE__ */ new Set(["git.stage", "git.commit", "git.checkout", "git.push"]);
|
|
62728
62745
|
var APP_CALL_BUDGET_MS = APP_CAPABILITY_QUESTION_MS + APP_CALL_TIMEOUT_MS;
|
|
62746
|
+
var HOST_REQUEST_BUDGET_MS = 15 * 6e4 + 6e4;
|
|
62729
62747
|
function callBudgetMs(method) {
|
|
62748
|
+
if (method === "host.trustDevTab") return HOST_REQUEST_BUDGET_MS;
|
|
62730
62749
|
if (method === "apps.invoke") return APP_CALL_BUDGET_MS;
|
|
62731
62750
|
if (GIT_WRITE_CALLS.has(method)) return GIT_WRITE_BUDGET_MS;
|
|
62732
62751
|
return LONG_CALLS.has(method) ? LONG_CALL_BUDGET_MS : DEFAULT_CALL_BUDGET_MS;
|
|
@@ -63221,10 +63240,10 @@ function samePath(a, b2, family2, cwd) {
|
|
|
63221
63240
|
return pathKey(a, family2, cwd) === pathKey(b2, family2, cwd);
|
|
63222
63241
|
}
|
|
63223
63242
|
function isInside(root3, candidate, family2, cwd) {
|
|
63224
|
-
const
|
|
63243
|
+
const sep14 = pathRules(family2).sep;
|
|
63225
63244
|
const r = pathKey(root3, family2, cwd);
|
|
63226
63245
|
const c = pathKey(candidate, family2, cwd);
|
|
63227
|
-
return c === r || c.startsWith(r.endsWith(
|
|
63246
|
+
return c === r || c.startsWith(r.endsWith(sep14) ? r : r + sep14);
|
|
63228
63247
|
}
|
|
63229
63248
|
function expandHome(path2, home, family2) {
|
|
63230
63249
|
if (path2 === "~") return home;
|
|
@@ -65877,6 +65896,7 @@ var METHOD_RIGHTS = {
|
|
|
65877
65896
|
"agents.account": "everyday",
|
|
65878
65897
|
"usage.history": "everyday",
|
|
65879
65898
|
"messages.image": "everyday",
|
|
65899
|
+
"messages.resolveFile": "everyday",
|
|
65880
65900
|
"messages.search": "everyday",
|
|
65881
65901
|
"messages.load": "everyday",
|
|
65882
65902
|
"messages.subagent": "everyday",
|
|
@@ -66088,6 +66108,11 @@ var METHOD_RIGHTS = {
|
|
|
66088
66108
|
* plant a false end that relabels a real crash as the system's (#1397)
|
|
66089
66109
|
*/
|
|
66090
66110
|
"host.systemEnding": "window",
|
|
66111
|
+
/**
|
|
66112
|
+
* A local `dev:live` browser tab asking the person (via a card with a pairing code and origin) to attribute
|
|
66113
|
+
* messages on that single open WebSocket as human rather than script. Never grants full/window rights.
|
|
66114
|
+
*/
|
|
66115
|
+
"host.trustDevTab": "asks",
|
|
66091
66116
|
"host.hubOffer": "link",
|
|
66092
66117
|
// From a hub that offered on the same connection only (rpc.ts), as `host.hubOffer` (#2067 item 2)
|
|
66093
66118
|
"host.mail": "link",
|
|
@@ -66095,6 +66120,7 @@ var METHOD_RIGHTS = {
|
|
|
66095
66120
|
"host.mailMove": "link",
|
|
66096
66121
|
"host.cards": "link",
|
|
66097
66122
|
"host.answerCard": "link",
|
|
66123
|
+
"host.stopTask": "link",
|
|
66098
66124
|
// From a hub that offered apps on the same connection only (rpc.ts), as `host.mail` (#1938)
|
|
66099
66125
|
"host.apps": "link",
|
|
66100
66126
|
"host.appCall": "link",
|
|
@@ -66718,6 +66744,12 @@ function drainToolResult(e) {
|
|
|
66718
66744
|
}
|
|
66719
66745
|
|
|
66720
66746
|
// packages/agent-host/src/transport/server.ts
|
|
66747
|
+
var DEV_TAB_ORIGINS = /* @__PURE__ */ new Set([
|
|
66748
|
+
"http://127.0.0.1:5173",
|
|
66749
|
+
"http://127.0.0.1:5174",
|
|
66750
|
+
"http://localhost:5173",
|
|
66751
|
+
"http://localhost:5174"
|
|
66752
|
+
]);
|
|
66721
66753
|
var DEFAULT_ALLOWED_ORIGINS = [
|
|
66722
66754
|
"http://127.0.0.1:5173",
|
|
66723
66755
|
"http://127.0.0.1:5174",
|
|
@@ -67000,9 +67032,12 @@ var HostServer = class _HostServer {
|
|
|
67000
67032
|
setTimeout(() => ws2.terminate(), this.limits.closeGraceMs).unref();
|
|
67001
67033
|
}
|
|
67002
67034
|
onConnection(ws2, req) {
|
|
67035
|
+
const origin = typeof req.headers.origin === "string" ? req.headers.origin : null;
|
|
67003
67036
|
let authed = false;
|
|
67004
67037
|
let bridgeOf2 = null;
|
|
67005
67038
|
let limited = false;
|
|
67039
|
+
let trustedDev = false;
|
|
67040
|
+
let trustingDev = false;
|
|
67006
67041
|
let session2;
|
|
67007
67042
|
let label = null;
|
|
67008
67043
|
const leaving = new AbortController();
|
|
@@ -67134,7 +67169,7 @@ var HostServer = class _HostServer {
|
|
|
67134
67169
|
this.showing.add(ws2);
|
|
67135
67170
|
this.opts.onShowing?.(this.showing.size);
|
|
67136
67171
|
}
|
|
67137
|
-
this.greet(ws2, frame.data.afterSeq ?? 0, frame.data.streamEpoch);
|
|
67172
|
+
this.greet(ws2, frame.data.afterSeq ?? 0, frame.data.streamEpoch, limited);
|
|
67138
67173
|
return;
|
|
67139
67174
|
}
|
|
67140
67175
|
if (!authed) {
|
|
@@ -67157,10 +67192,93 @@ var HostServer = class _HostServer {
|
|
|
67157
67192
|
if (refusal2 !== null) return this.sendError(ws2, id3, { code: "internal", message: refusal2, retryable: false });
|
|
67158
67193
|
}
|
|
67159
67194
|
if (limited) {
|
|
67195
|
+
if (method === "host.trustDevTab") {
|
|
67196
|
+
const who = `client=${client} label=${JSON.stringify(label)} origin=${JSON.stringify(origin)}`;
|
|
67197
|
+
if (this.opts.servedBy === "serve" || this.opts.fullCredentials !== void 0) {
|
|
67198
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): serve host`);
|
|
67199
|
+
return this.sendError(ws2, id3, {
|
|
67200
|
+
code: "internal",
|
|
67201
|
+
message: "host.trustDevTab is only available on a local desktop host, not a centralu serve host",
|
|
67202
|
+
retryable: false,
|
|
67203
|
+
data: { refused: "rights", rights: "asks" }
|
|
67204
|
+
});
|
|
67205
|
+
}
|
|
67206
|
+
if (session2 !== void 0) {
|
|
67207
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): session credential`);
|
|
67208
|
+
return this.sendError(ws2, id3, {
|
|
67209
|
+
code: "internal",
|
|
67210
|
+
message: "A session credential cannot ask to trust a dev browser tab",
|
|
67211
|
+
retryable: false,
|
|
67212
|
+
data: { refused: "rights", rights: "asks" }
|
|
67213
|
+
});
|
|
67214
|
+
}
|
|
67215
|
+
if (origin === null || !DEV_TAB_ORIGINS.has(origin)) {
|
|
67216
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): non-dev origin`);
|
|
67217
|
+
return this.sendError(ws2, id3, {
|
|
67218
|
+
code: "internal",
|
|
67219
|
+
message: "host.trustDevTab is only allowed from a local dev browser origin (127.0.0.1 or localhost on port 5173 or 5174)",
|
|
67220
|
+
retryable: false,
|
|
67221
|
+
data: { refused: "rights", rights: "asks" }
|
|
67222
|
+
});
|
|
67223
|
+
}
|
|
67224
|
+
const parsed = RpcMethods["host.trustDevTab"].params.safeParse(params);
|
|
67225
|
+
if (!parsed.success) {
|
|
67226
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): invalid params`);
|
|
67227
|
+
return this.sendError(ws2, id3, {
|
|
67228
|
+
code: "internal",
|
|
67229
|
+
message: `host.trustDevTab was not done: ${parsed.error.issues[0]?.message ?? "invalid parameters"}.`,
|
|
67230
|
+
retryable: false,
|
|
67231
|
+
data: { refused: "not_done" }
|
|
67232
|
+
});
|
|
67233
|
+
}
|
|
67234
|
+
if (trustedDev) {
|
|
67235
|
+
this.sendTo(ws2, JSON.stringify({ kind: "res", id: id3, ok: true, result: { ok: true } }));
|
|
67236
|
+
return;
|
|
67237
|
+
}
|
|
67238
|
+
if (trustingDev) {
|
|
67239
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): already waiting`);
|
|
67240
|
+
return this.sendError(ws2, id3, {
|
|
67241
|
+
code: "internal",
|
|
67242
|
+
message: "A trust request for this dev browser tab is already waiting in the Centralu window",
|
|
67243
|
+
retryable: false,
|
|
67244
|
+
data: { refused: "not_done" }
|
|
67245
|
+
});
|
|
67246
|
+
}
|
|
67247
|
+
if (!this.opts.onAsk) {
|
|
67248
|
+
console.error(`[agent-host] refused "host.trustDevTab" (${who}): no host-request handler`);
|
|
67249
|
+
const refusal3 = limitedRefusal(method, params, this.opts.rightsHost ?? null);
|
|
67250
|
+
return this.sendError(ws2, id3, {
|
|
67251
|
+
code: "internal",
|
|
67252
|
+
message: refusal3?.message ?? "host.trustDevTab requires the Centralu window",
|
|
67253
|
+
retryable: false,
|
|
67254
|
+
data: { refused: "rights", rights: refusal3?.rights ?? "asks" }
|
|
67255
|
+
});
|
|
67256
|
+
}
|
|
67257
|
+
trustingDev = true;
|
|
67258
|
+
try {
|
|
67259
|
+
const result = await this.opts.onAsk(method, parsed.data, { client: label, origin }, leaving.signal);
|
|
67260
|
+
if (!leaving.signal.aborted) {
|
|
67261
|
+
trustedDev = true;
|
|
67262
|
+
console.error(`[agent-host] trusted dev tab for human message attribution (${who})`);
|
|
67263
|
+
}
|
|
67264
|
+
this.sendTo(ws2, JSON.stringify({ kind: "res", id: id3, ok: true, result }));
|
|
67265
|
+
} catch (err) {
|
|
67266
|
+
const data = err !== null && typeof err === "object" && "data" in err ? err.data : void 0;
|
|
67267
|
+
this.sendError(ws2, id3, { code: "internal", message: errorMessage(err), retryable: err instanceof DrainCut, ...data !== void 0 ? { data } : {} });
|
|
67268
|
+
} finally {
|
|
67269
|
+
trustingDev = false;
|
|
67270
|
+
}
|
|
67271
|
+
return;
|
|
67272
|
+
}
|
|
67160
67273
|
const refusal2 = limitedRefusal(method, params, this.opts.rightsHost ?? null);
|
|
67161
67274
|
if (refusal2?.rights === "asks" && this.opts.onAsk) {
|
|
67162
67275
|
try {
|
|
67163
|
-
const result = await this.opts.onAsk(
|
|
67276
|
+
const result = await this.opts.onAsk(
|
|
67277
|
+
method,
|
|
67278
|
+
params,
|
|
67279
|
+
{ client: label, ...session2 ? { session: session2 } : {}, ...trustedDev ? { trustedDev: true } : {} },
|
|
67280
|
+
leaving.signal
|
|
67281
|
+
);
|
|
67164
67282
|
this.sendTo(ws2, JSON.stringify({ kind: "res", id: id3, ok: true, result }));
|
|
67165
67283
|
} catch (err) {
|
|
67166
67284
|
const data = err !== null && typeof err === "object" && "data" in err ? err.data : void 0;
|
|
@@ -67175,7 +67293,15 @@ var HostServer = class _HostServer {
|
|
|
67175
67293
|
}
|
|
67176
67294
|
try {
|
|
67177
67295
|
const covered = limited && conditionalRight(method);
|
|
67178
|
-
const run2 = () => this.opts.onRpc(method, params, {
|
|
67296
|
+
const run2 = () => this.opts.onRpc(method, params, {
|
|
67297
|
+
client,
|
|
67298
|
+
rights: limited ? "limited" : "full",
|
|
67299
|
+
label,
|
|
67300
|
+
...covered ? { covered: true } : {},
|
|
67301
|
+
...session2 ? { session: session2 } : {},
|
|
67302
|
+
...trustedDev ? { trustedDev: true } : {},
|
|
67303
|
+
...this.showing.has(ws2) ? { window: true } : {}
|
|
67304
|
+
});
|
|
67179
67305
|
const result = await (this.opts.drain ? this.opts.drain.track(`rpc ${method}`, run2) : run2());
|
|
67180
67306
|
this.sendTo(ws2, JSON.stringify({ kind: "res", id: id3, ok: true, result }));
|
|
67181
67307
|
} catch (err) {
|
|
@@ -67295,7 +67421,7 @@ var HostServer = class _HostServer {
|
|
|
67295
67421
|
this.calls.delete(ws2);
|
|
67296
67422
|
for (const call2 of [...pending.values()]) call2.reject(rpcError(why2, "internal", { retryable: false }));
|
|
67297
67423
|
}
|
|
67298
|
-
helloOk(resyncRequired) {
|
|
67424
|
+
helloOk(resyncRequired, limited = false) {
|
|
67299
67425
|
return JSON.stringify({
|
|
67300
67426
|
kind: "hello_ok",
|
|
67301
67427
|
protocolVersion: PROTOCOL_VERSION,
|
|
@@ -67306,7 +67432,8 @@ var HostServer = class _HostServer {
|
|
|
67306
67432
|
...elevatedField(this.opts.elevated?.()),
|
|
67307
67433
|
...this.opts.logon?.() ? { logon: this.opts.logon() } : {},
|
|
67308
67434
|
...this.opts.handover?.() ? { handover: this.opts.handover() } : {},
|
|
67309
|
-
...this.opts.updateContinued ? { updateContinued: this.opts.updateContinued() } : {}
|
|
67435
|
+
...this.opts.updateContinued ? { updateContinued: this.opts.updateContinued() } : {},
|
|
67436
|
+
...limited ? { rights: "limited" } : {}
|
|
67310
67437
|
});
|
|
67311
67438
|
}
|
|
67312
67439
|
/**
|
|
@@ -67316,17 +67443,17 @@ var HostServer = class _HostServer {
|
|
|
67316
67443
|
* cursor where it was, and the next reconnect would ask for the same oversized window, a loop that never converges (the
|
|
67317
67444
|
* livelock of #91; measured: a 2,000 x 50 kB history replayed to a stalled peer left 99.6 MB buffered)
|
|
67318
67445
|
*/
|
|
67319
|
-
greet(ws2, afterSeq, streamEpoch) {
|
|
67446
|
+
greet(ws2, afterSeq, streamEpoch, limited) {
|
|
67320
67447
|
const window2 = this.log.since(afterSeq, streamEpoch);
|
|
67321
67448
|
const hub = this.hubLinks.has(ws2);
|
|
67322
67449
|
const frames = window2.events.filter((e) => hub || e.event.type !== "host_credential_used").map((e) => JSON.stringify({ kind: "event", seq: e.seq, event: e.event }));
|
|
67323
|
-
let bytes2 = ws2.bufferedAmount + wireBytes(this.helloOk(window2.resyncRequired));
|
|
67450
|
+
let bytes2 = ws2.bufferedAmount + wireBytes(this.helloOk(window2.resyncRequired, limited));
|
|
67324
67451
|
for (const f of frames) bytes2 += wireBytes(f);
|
|
67325
67452
|
if (bytes2 > this.limits.replayBudgetBytes) {
|
|
67326
|
-
this.sendTo(ws2, this.helloOk(true));
|
|
67453
|
+
this.sendTo(ws2, this.helloOk(true, limited));
|
|
67327
67454
|
return;
|
|
67328
67455
|
}
|
|
67329
|
-
this.sendTo(ws2, this.helloOk(window2.resyncRequired));
|
|
67456
|
+
this.sendTo(ws2, this.helloOk(window2.resyncRequired, limited));
|
|
67330
67457
|
for (const f of frames) this.sendTo(ws2, f);
|
|
67331
67458
|
}
|
|
67332
67459
|
sendError(ws2, id3, error51) {
|
|
@@ -104146,16 +104273,16 @@ function readBook(raw) {
|
|
|
104146
104273
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { assigned: {}, retired: [] };
|
|
104147
104274
|
const { assigned, retired, ...rest } = raw;
|
|
104148
104275
|
const book = { ...rest, assigned: {}, retired: [] };
|
|
104149
|
-
const
|
|
104276
|
+
const unread4 = [];
|
|
104150
104277
|
if (assigned && typeof assigned === "object") {
|
|
104151
104278
|
for (const [k2, v] of Object.entries(assigned)) {
|
|
104152
104279
|
if (validPort(v)) book.assigned[k2] = v;
|
|
104153
|
-
else portsIn(v,
|
|
104280
|
+
else portsIn(v, unread4);
|
|
104154
104281
|
}
|
|
104155
104282
|
}
|
|
104156
|
-
if (Array.isArray(retired)) for (const p of retired) (validPort(p) ? book.retired :
|
|
104283
|
+
if (Array.isArray(retired)) for (const p of retired) (validPort(p) ? book.retired : unread4).push(...portsIn(p));
|
|
104157
104284
|
const used = /* @__PURE__ */ new Set([...Object.values(book.assigned), ...book.retired]);
|
|
104158
|
-
for (const p of
|
|
104285
|
+
for (const p of unread4) {
|
|
104159
104286
|
if (used.has(p)) continue;
|
|
104160
104287
|
used.add(p);
|
|
104161
104288
|
book.retired.push(p);
|
|
@@ -105225,7 +105352,7 @@ function taskLine(task, max = 160) {
|
|
|
105225
105352
|
const flat = oneLineText(task);
|
|
105226
105353
|
return flat.length > max ? `${flat.slice(0, max)}\u2026 (cut here; ${flat.length} characters in all)` : flat;
|
|
105227
105354
|
}
|
|
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.";
|
|
105355
|
+
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
105356
|
function askBeforeFinish(to) {
|
|
105230
105357
|
return `To ask it something before you finish, call mail with \`to: "${to}"\` and \`kind: "question"\``;
|
|
105231
105358
|
}
|
|
@@ -105597,7 +105724,7 @@ var AcrossCore = class {
|
|
|
105597
105724
|
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
105725
|
const r = parsed.data;
|
|
105599
105726
|
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 } : {} };
|
|
105727
|
+
return { ok: true, messageId: oneLineText(r.messageId, 200), to: oneLineText(r.to, 120), ...r.address ? { address: r.address } : {}, ...r.quiet ? { quiet: true } : {} };
|
|
105601
105728
|
}
|
|
105602
105729
|
/** A session here as the other side's answer names it, to `reader` there in its terms; written whatever its label */
|
|
105603
105730
|
label(to, reader) {
|
|
@@ -107261,10 +107388,10 @@ function remoteAgentFrame(parentName, task, instructions = "") {
|
|
|
107261
107388
|
}
|
|
107262
107389
|
function agentBranch(task, id3, max = 35) {
|
|
107263
107390
|
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}/${
|
|
107391
|
+
let slug2 = full.slice(0, max);
|
|
107392
|
+
if (full.length > max && full[max] !== "-" && slug2.includes("-")) slug2 = slug2.slice(0, slug2.lastIndexOf("-"));
|
|
107393
|
+
slug2 = slug2.replace(/-+$/, "");
|
|
107394
|
+
return `${APP_SLUG}/${slug2 || "agent"}-${id3.replace(/[^a-z0-9]/gi, "").slice(0, 4).toLowerCase()}`;
|
|
107268
107395
|
}
|
|
107269
107396
|
function agentName(task, max = 48) {
|
|
107270
107397
|
return oneLineText(task, max) || "Agent";
|
|
@@ -107544,14 +107671,17 @@ function agentRunText(r) {
|
|
|
107544
107671
|
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
107672
|
};
|
|
107546
107673
|
}
|
|
107547
|
-
const who = `the ${r.tool} session "${r.sessionName}" [${r.sessionId}]` + (r.via === "fork" ? `, a fork of [${r.forkedFrom}]` : "");
|
|
107674
|
+
const who = `the ${r.tool ? `${r.tool} ` : ""}session "${r.sessionName}" [${r.sessionId}]` + (r.via === "fork" ? `, a fork of [${r.forkedFrom}]` : "");
|
|
107548
107675
|
return agentStateText(r, who);
|
|
107549
107676
|
}
|
|
107677
|
+
function askedWait(project2, sessionId) {
|
|
107678
|
+
return `To wait for its answer, call ask_project with ${project2 ? `project "${project2}"` : "its project"}, session "${sessionId}" and no task.`;
|
|
107679
|
+
}
|
|
107550
107680
|
function agentStateText(r, who) {
|
|
107551
107681
|
switch (r.state) {
|
|
107552
107682
|
case "working":
|
|
107553
107683
|
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.`
|
|
107684
|
+
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
107685
|
};
|
|
107556
107686
|
case "asking":
|
|
107557
107687
|
return {
|
|
@@ -107562,7 +107692,7 @@ agent_session(sessionId="${r.sessionId}", action="answer", card=\u2026, text=\u2
|
|
|
107562
107692
|
case "mailed":
|
|
107563
107693
|
return { text: `${mailedText(r, "mail")} agent_session(sessionId="${r.sessionId}", action="stop") withdraws it until it is delivered.` };
|
|
107564
107694
|
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.` };
|
|
107695
|
+
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
107696
|
case "stopped":
|
|
107567
107697
|
if (!r.sessionName) return { text: `Withdrew request ${r.sessionId}: its card is gone and no session was started.` };
|
|
107568
107698
|
return { text: `Stopped ${who}.${r.notice ? ` ${r.notice}` : ""}` };
|
|
@@ -108905,7 +109035,7 @@ var MailDelivery = class {
|
|
|
108905
109035
|
if (attempts >= this.o.maxAttempts) {
|
|
108906
109036
|
this.records.transaction(() => {
|
|
108907
109037
|
this.records.failedTry(recipient, messageIds, error51, this.now());
|
|
108908
|
-
this.service.hold(recipient, messageIds.map((messageId) => ({ messageId, reason: "failed" })));
|
|
109038
|
+
this.service.holds.hold(recipient, messageIds.map((messageId) => ({ messageId, reason: "failed" })));
|
|
108909
109039
|
});
|
|
108910
109040
|
this.tellHeldFailed(recipient, messageIds, error51);
|
|
108911
109041
|
return;
|
|
@@ -108938,14 +109068,14 @@ var MailDelivery = class {
|
|
|
108938
109068
|
* 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
109069
|
* 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
109070
|
* 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, `
|
|
109071
|
+
* work twice is worse than asking. So it is treated as a restart's uncertain delivery (§7.6.5, `HeldMail.deliveryFailedLate`): unread
|
|
108942
109072
|
* and undelivered again, held `uncertain` for the person (Inbox: Send again), said in the thread to the sender and in the receiver's
|
|
108943
109073
|
* conversation, and never sent again by itself, unless it is news that starts no work. Only the receipts that wake delivered:
|
|
108944
109074
|
* mail delivered again since by another wake, handled, or held is left alone
|
|
108945
109075
|
*/
|
|
108946
109076
|
takeBack(recipient, messageIds, deliveredAt, cause2) {
|
|
108947
109077
|
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);
|
|
109078
|
+
const { held: held3 } = this.service.holds.deliveryFailedLate(recipient, messageIds, deliveredAt);
|
|
108949
109079
|
const party = parseAddress(recipient);
|
|
108950
109080
|
if (held3 > 0 && party?.kind === "session") {
|
|
108951
109081
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
@@ -108955,7 +109085,7 @@ var MailDelivery = class {
|
|
|
108955
109085
|
/** A delivery the previous host left half done is held or sent again (`reconcileInterrupted`), and the receiver is told when it is held */
|
|
108956
109086
|
sayWhatWasLeftHalfDone() {
|
|
108957
109087
|
try {
|
|
108958
|
-
for (const { recipient, held: held3 } of this.service.reconcileInterrupted()) {
|
|
109088
|
+
for (const { recipient, held: held3 } of this.service.holds.reconcileInterrupted()) {
|
|
108959
109089
|
const party = parseAddress(recipient);
|
|
108960
109090
|
if (held3 > 0 && party?.kind === "session") {
|
|
108961
109091
|
const n = held3 === 1 ? "A delivery" : `${held3} deliveries`;
|
|
@@ -109019,7 +109149,7 @@ var MailDelivery = class {
|
|
|
109019
109149
|
const drain = (skipping) => this.service.drain(recipient, { ...skipping ? { skip: skipping } : {}, ...state.joins ? { joining: true } : {} });
|
|
109020
109150
|
let drained2 = drain(skip);
|
|
109021
109151
|
if (!waiting && state.live && this.cutoff !== null && drained2.wake) drained2 = drain(void 0);
|
|
109022
|
-
this.service.hold(recipient, drained2.heldBack);
|
|
109152
|
+
this.service.holds.hold(recipient, drained2.heldBack);
|
|
109023
109153
|
if (drained2.messageIds.length === 0) return { drained: drained2, go: false, waitMs: 0 };
|
|
109024
109154
|
const goesAtTurnEnd = this.delegatedTask(drained2) !== void 0 && this.turns?.current(sessionId) === void 0;
|
|
109025
109155
|
if (drained2.wake && !drained2.immediate && !state.joins && !goesAtTurnEnd) {
|
|
@@ -111957,6 +112087,14 @@ ${spentWords(tries)}` } };
|
|
|
111957
112087
|
stands(sessionId) {
|
|
111958
112088
|
return this.held.get(sessionId)?.phase === "waiting";
|
|
111959
112089
|
}
|
|
112090
|
+
/**
|
|
112091
|
+
* 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
|
|
112092
|
+
* Stop ends that wait and the turn (`TurnInputs.interrupt`, `cancel`)
|
|
112093
|
+
*/
|
|
112094
|
+
waitsToContinue(sessionId) {
|
|
112095
|
+
const u = this.updates.get(sessionId);
|
|
112096
|
+
return this.stops.has(sessionId) || this.held.has(sessionId) || !!u && u.phase !== "waking" && !!u.turn;
|
|
112097
|
+
}
|
|
111960
112098
|
/**
|
|
111961
112099
|
* 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
112100
|
* stood. Handed, the tool's turn is running and is the caller's to stop
|
|
@@ -112332,8 +112470,8 @@ function labelHere(offered, name, taken) {
|
|
|
112332
112470
|
return (offered === null ? null : unique(offered, t)) ?? hubLabel(name, t);
|
|
112333
112471
|
}
|
|
112334
112472
|
function slugOf(name) {
|
|
112335
|
-
const
|
|
112336
|
-
return
|
|
112473
|
+
const slug2 = name.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "").slice(0, 24);
|
|
112474
|
+
return slug2 && MACHINE_ID_RE.test(slug2) ? slug2 : null;
|
|
112337
112475
|
}
|
|
112338
112476
|
function unique(base2, taken) {
|
|
112339
112477
|
if (!taken.has(base2)) return base2;
|
|
@@ -112887,8 +113025,8 @@ var SessionAppsHub = class {
|
|
|
112887
113025
|
let server2 = book[key2];
|
|
112888
113026
|
if (!server2) {
|
|
112889
113027
|
const base2 = appServerName(a.appId);
|
|
112890
|
-
const
|
|
112891
|
-
server2 = !taken.has(base2) ? base2 : freeServerName(a.appId, taken,
|
|
113028
|
+
const slug2 = a.projectId ? nameSlug(this.opts.projectName?.(a.projectId) ?? "") || a.projectId.slice(0, 8).toLowerCase() : "user";
|
|
113029
|
+
server2 = !taken.has(base2) ? base2 : freeServerName(a.appId, taken, slug2);
|
|
112892
113030
|
book[key2] = server2;
|
|
112893
113031
|
taken.add(server2);
|
|
112894
113032
|
added = true;
|
|
@@ -114043,7 +114181,7 @@ var MailFacts = external_exports.looseObject({
|
|
|
114043
114181
|
asker: external_exports.string().optional(),
|
|
114044
114182
|
/** 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
114183
|
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 (`
|
|
114184
|
+
/** 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
114185
|
handedOver: external_exports.boolean().optional(),
|
|
114048
114186
|
legacyKind: external_exports.string().optional(),
|
|
114049
114187
|
/** The recipients an older build's person released a moved message to: never held again for them (§6.3) */
|
|
@@ -114298,6 +114436,14 @@ var MailboxRecords = class {
|
|
|
114298
114436
|
movedTo(sender, recipient) {
|
|
114299
114437
|
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
114438
|
}
|
|
114439
|
+
/** 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 */
|
|
114440
|
+
firstTask(recipient, origin) {
|
|
114441
|
+
return this.messages(
|
|
114442
|
+
`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`,
|
|
114443
|
+
recipient,
|
|
114444
|
+
origin
|
|
114445
|
+
)[0];
|
|
114446
|
+
}
|
|
114301
114447
|
/** The newest task from `sender` whose row to `recipient` is not settled */
|
|
114302
114448
|
newestTask(sender, recipient) {
|
|
114303
114449
|
return this.messages(
|
|
@@ -114766,11 +114912,11 @@ var MailboxRecords = class {
|
|
|
114766
114912
|
* A handoff: `from`'s rows that are watched and not settled, or not read (settled or not: a moved `legacy` row too),
|
|
114767
114913
|
* go to `to`, in `scope`. A row not read is delivered
|
|
114768
114914
|
* 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
|
|
114915
|
+
* 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
114916
|
*/
|
|
114771
|
-
moveRows(from, to, scope) {
|
|
114917
|
+
moveRows(from, to, scope, only) {
|
|
114772
114918
|
return this.transaction(() => {
|
|
114773
|
-
const ids = this.movable(from, to, scope);
|
|
114919
|
+
const ids = this.movable(from, to, scope).filter((id3) => !only || only.includes(id3));
|
|
114774
114920
|
this.db.prepare(
|
|
114775
114921
|
`UPDATE OR IGNORE mail_recipients SET recipient = @to, turn_seq = NULL, reminded = 0, reminded_at = NULL,
|
|
114776
114922
|
delivered_at = CASE WHEN read_at IS NULL THEN NULL ELSE delivered_at END,
|
|
@@ -114855,12 +115001,12 @@ var MailboxRecords = class {
|
|
|
114855
115001
|
(r.settled IS NULL AND r.released_at IS NULL AND ${WATCHED})
|
|
114856
115002
|
OR (r.delivered_at IS NULL AND ${WAITING})
|
|
114857
115003
|
OR (${HELD})))`;
|
|
114858
|
-
const
|
|
115004
|
+
const unread4 = `EXISTS (SELECT 1 FROM mail_recipients r WHERE r.message_id = m.id AND r.read_at IS NULL)`;
|
|
114859
115005
|
const pick5 = this.db.prepare(
|
|
114860
115006
|
`SELECT m.id FROM mail m
|
|
114861
115007
|
WHERE m.created_at <= @waiting
|
|
114862
115008
|
OR (m.created_at <= @settled AND NOT ${waits})
|
|
114863
|
-
OR (m.kind = 'notice' AND m.created_at <= @notice AND NOT ${waits} AND NOT ${
|
|
115009
|
+
OR (m.kind = 'notice' AND m.created_at <= @notice AND NOT ${waits} AND NOT ${unread4})
|
|
114864
115010
|
ORDER BY m.created_at LIMIT @batch`
|
|
114865
115011
|
);
|
|
114866
115012
|
let messages2 = 0;
|
|
@@ -120284,7 +120430,22 @@ var SessionStarts = class {
|
|
|
120284
120430
|
...o.outputSchema ? { outputSchema: o.outputSchema } : {}
|
|
120285
120431
|
};
|
|
120286
120432
|
}
|
|
120287
|
-
|
|
120433
|
+
/**
|
|
120434
|
+
* 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
|
|
120435
|
+
* session starts a new conversation instead of failing to wake. Cursor keeps a conversation only once a model turn has run, so
|
|
120436
|
+
* a session opened and never answered is refused at every wake (#1676); once idle sessions sleep, each of them would hit it.
|
|
120437
|
+
* Null (the wake fails as it did) when the agent has written anything here, or the session was imported.
|
|
120438
|
+
*/
|
|
120439
|
+
async startOver(m, tool) {
|
|
120440
|
+
if (m.importedFrom || this.host.store.messages.hasAgentRows(m.id)) return null;
|
|
120441
|
+
if (this.host.leaving.has(m.id) || !this.host.meta.has(m.id) || m.tool !== tool) return null;
|
|
120442
|
+
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`);
|
|
120443
|
+
m.externalId = null;
|
|
120444
|
+
this.host.store.sessions.upsertSession(m);
|
|
120445
|
+
this.host.store.settings.setAppSetting(freshStartKey(m.id), String(this.host.store.messages.loadMessages(m.id, 1)[0]?.seq ?? 0));
|
|
120446
|
+
return this.doResumeSession(m.id, true);
|
|
120447
|
+
}
|
|
120448
|
+
async doResumeSession(sessionId, startedOver = false) {
|
|
120288
120449
|
const m = this.host.openSession(sessionId);
|
|
120289
120450
|
if (this.host.handles.has(sessionId)) return { session: m, resumed: true };
|
|
120290
120451
|
const tool = m.tool;
|
|
@@ -120416,7 +120577,12 @@ var SessionStarts = class {
|
|
|
120416
120577
|
return { session: m, resumed: true };
|
|
120417
120578
|
} catch (err) {
|
|
120418
120579
|
this.host.modelWindows.forget(sessionId);
|
|
120419
|
-
const
|
|
120580
|
+
const toldGone = err instanceof Error && Reflect.get(err, "code") === "conversation_gone";
|
|
120581
|
+
if (toldGone && !startedOver) {
|
|
120582
|
+
const again = await this.startOver(m, tool);
|
|
120583
|
+
if (again) return again;
|
|
120584
|
+
}
|
|
120585
|
+
const gone3 = toldGone || await withTimeout(this.host.externals.externalGone(m, cwd), 8e3, "Checking the tool").catch(() => false);
|
|
120420
120586
|
if (gone3) {
|
|
120421
120587
|
return { session: m, resumed: false, reason: externalMissingReason(this.host.toolLabel(m.tool), cwd) };
|
|
120422
120588
|
}
|
|
@@ -121850,6 +122016,9 @@ var AgentSessionActions = class {
|
|
|
121850
122016
|
}
|
|
121851
122017
|
const remote = opts.sessionId.includes(".") ? this.flow.remote.of(opts.sessionId) : void 0;
|
|
121852
122018
|
if (remote) return this.flow.remote.agentSession(callerId, remote, opts, signal);
|
|
122019
|
+
if (opts.sessionId.includes(".") && this.host.linkedReader?.machineOf(opts.sessionId) && this.host.linkedTasks?.open(callerId, opts.sessionId)) {
|
|
122020
|
+
return this.flow.remote.askedThere(callerId, opts.sessionId, opts);
|
|
122021
|
+
}
|
|
121853
122022
|
const gone2 = this.flow.handedOverAnswer(callerId, opts.sessionId);
|
|
121854
122023
|
if (gone2) return gone2;
|
|
121855
122024
|
const request = this.host.children.agentStarts.get(opts.sessionId);
|
|
@@ -122085,6 +122254,8 @@ var RemoteAgents = class {
|
|
|
122085
122254
|
loaded = null;
|
|
122086
122255
|
/** The calls waiting on a child's report, each ended at once when the child is deleted there (`observe`) */
|
|
122087
122256
|
waits = /* @__PURE__ */ new Map();
|
|
122257
|
+
/** The waits woken by a card a machine's session raised (`untilCard`): session -> wakers */
|
|
122258
|
+
cardWaits = /* @__PURE__ */ new Map();
|
|
122088
122259
|
/**
|
|
122089
122260
|
* 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
122261
|
* 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 +122331,7 @@ var RemoteAgents = class {
|
|
|
122160
122331
|
}
|
|
122161
122332
|
/**
|
|
122162
122333
|
* 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 (`
|
|
122334
|
+
* with the original's mail (`Handoffs.handOver`, #1948 step 6)
|
|
122164
122335
|
*/
|
|
122165
122336
|
moveCaller(from, to) {
|
|
122166
122337
|
const moving = this.records().filter((r) => r.callerId === from);
|
|
@@ -122352,6 +122523,28 @@ var RemoteAgents = class {
|
|
|
122352
122523
|
const sent = tasks ? await tasks.send(callerId, rec.sessionId, text3, { origin: "agent_session", note: true }) : { ok: false, text: NO_MAIL };
|
|
122353
122524
|
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
122525
|
}
|
|
122526
|
+
/**
|
|
122527
|
+
* 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
|
|
122528
|
+
* §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
|
|
122529
|
+
* with no task waits on it
|
|
122530
|
+
*/
|
|
122531
|
+
async askedThere(callerId, sessionId, opts) {
|
|
122532
|
+
const reader = this.host.linkedReader;
|
|
122533
|
+
const machine = reader?.machineOf(sessionId);
|
|
122534
|
+
if (!reader || !machine) return { ok: false, error: `${sessionId} is on a linked machine, and no machine is linked to this computer now.` };
|
|
122535
|
+
const seen = reader.describe(sessionId);
|
|
122536
|
+
const there = { sessionId, callerId, name: seen?.name ?? sessionId, machine, tool: "" };
|
|
122537
|
+
const askedOf = seen ? `${sessionId.slice(0, sessionId.indexOf("."))}/${seen.projectName}` : "";
|
|
122538
|
+
if (opts.action === "answer") {
|
|
122539
|
+
const r = await this.answer(there, opts.card, opts.text ?? "", reader);
|
|
122540
|
+
return r.ok ? { ...r, askedOf } : r;
|
|
122541
|
+
}
|
|
122542
|
+
if (opts.action !== "status") {
|
|
122543
|
+
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.` };
|
|
122544
|
+
}
|
|
122545
|
+
const cards = await this.cardsOf(there, reader);
|
|
122546
|
+
return cards.length ? this.asking(there, cards) : { ...this.working(there, false), askedOf };
|
|
122547
|
+
}
|
|
122355
122548
|
async act(callerId, rec, opts, signal) {
|
|
122356
122549
|
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
122550
|
const reader = this.host.linkedReader;
|
|
@@ -122443,11 +122636,30 @@ var RemoteAgents = class {
|
|
|
122443
122636
|
*/
|
|
122444
122637
|
observe(e) {
|
|
122445
122638
|
if (e.type === "machine_resync") return void this.caughtUp(e.machineId);
|
|
122639
|
+
if ((e.type === "question_request" || e.type === "approval_request") && typeof e.sessionId === "string") {
|
|
122640
|
+
for (const wake of [...this.cardWaits.get(e.sessionId) ?? []]) wake();
|
|
122641
|
+
return;
|
|
122642
|
+
}
|
|
122446
122643
|
if (e.type !== "session_deleted" || typeof e.sessionId !== "string" || !this.of(e.sessionId)) return;
|
|
122447
122644
|
this.forget(e.sessionId);
|
|
122448
122645
|
for (const end of [...this.waits.get(e.sessionId) ?? []]) end();
|
|
122449
122646
|
}
|
|
122450
122647
|
// ── Waits ───────────────────────────────────────────────────────────────────────────────
|
|
122648
|
+
/** Resolves once a machine's session (`sessionId`, qualified) raises a card, as its relayed event says; `done` stops the wait */
|
|
122649
|
+
untilCard(sessionId) {
|
|
122650
|
+
let wake;
|
|
122651
|
+
const raised = new Promise((resolve21) => wake = resolve21);
|
|
122652
|
+
const wakers = this.cardWaits.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
122653
|
+
wakers.add(wake);
|
|
122654
|
+
this.cardWaits.set(sessionId, wakers);
|
|
122655
|
+
return {
|
|
122656
|
+
raised,
|
|
122657
|
+
done: () => {
|
|
122658
|
+
wakers.delete(wake);
|
|
122659
|
+
if (!wakers.size && this.cardWaits.get(sessionId) === wakers) this.cardWaits.delete(sessionId);
|
|
122660
|
+
}
|
|
122661
|
+
};
|
|
122662
|
+
}
|
|
122451
122663
|
/**
|
|
122452
122664
|
* 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
122665
|
* 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 +123723,10 @@ var MailSessionsView = class {
|
|
|
123511
123723
|
withdrawTasks(callerId, sessionId) {
|
|
123512
123724
|
return this.hooks?.withdrawTasks?.(callerId, sessionId) ?? 0;
|
|
123513
123725
|
}
|
|
123726
|
+
/** `MailHooks.cancelGiven`; false without a mailbox */
|
|
123727
|
+
cancelGiven(sessionId, giver, taskId) {
|
|
123728
|
+
return this.hooks?.cancelGiven?.(sessionId, giver, taskId) ?? false;
|
|
123729
|
+
}
|
|
123514
123730
|
/** 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
123731
|
takesAsPlanned(id3, joins) {
|
|
123516
123732
|
const r = this.mailReceiver(id3);
|
|
@@ -125903,19 +126119,23 @@ var CoreSession = class {
|
|
|
125903
126119
|
proc.on("error", (err) => gone2(null, err));
|
|
125904
126120
|
}
|
|
125905
126121
|
send(text3, opts) {
|
|
125906
|
-
void this.enqueue(text3, opts?.id ?? null, opts?.compact === true);
|
|
126122
|
+
void this.enqueue(text3, opts?.id ?? null, opts?.compact === true, void 0, opts?.origin);
|
|
125907
126123
|
}
|
|
125908
126124
|
sendTracked(text3, observer, opts) {
|
|
125909
|
-
return this.enqueue(text3, opts?.id ?? null, false, observer);
|
|
126125
|
+
return this.enqueue(text3, opts?.id ?? null, false, observer, opts?.origin);
|
|
125910
126126
|
}
|
|
125911
|
-
enqueue(text3, named3, compact, observer) {
|
|
126127
|
+
enqueue(text3, named3, compact, observer, origin) {
|
|
125912
126128
|
const receipt = this.receipts.create(observer);
|
|
125913
126129
|
if (this.phase === "closed") {
|
|
125914
126130
|
this.receipts.fail([receipt.id], new Error(`${this.wire.label} session is closed`));
|
|
125915
126131
|
return receipt.done;
|
|
125916
126132
|
}
|
|
125917
126133
|
this.queue.push({ input: { id: receipt.id, text: text3, compact }, named: named3 });
|
|
125918
|
-
this.
|
|
126134
|
+
if (this.turn && this.wire.turns.interruptForInput && origin?.kind === "human") {
|
|
126135
|
+
this.interruptForInput();
|
|
126136
|
+
} else {
|
|
126137
|
+
this.drain();
|
|
126138
|
+
}
|
|
125919
126139
|
return receipt.done;
|
|
125920
126140
|
}
|
|
125921
126141
|
/** The names of the inputs the last turn took (`SessionHandle.turnInputs`) */
|
|
@@ -126026,6 +126246,24 @@ var CoreSession = class {
|
|
|
126026
126246
|
this.process.interrupt();
|
|
126027
126247
|
}
|
|
126028
126248
|
}
|
|
126249
|
+
/** A new human input interrupts the running turn so it can run immediately, without dropping the queue */
|
|
126250
|
+
interruptForInput() {
|
|
126251
|
+
const turn = this.turn;
|
|
126252
|
+
if (!turn || this.phase !== "ready" || turn.stopAsked) return;
|
|
126253
|
+
turn.stopAsked = true;
|
|
126254
|
+
this.wire.interrupt?.();
|
|
126255
|
+
this.wire.releaseCards();
|
|
126256
|
+
if (!turn.stopTimer) {
|
|
126257
|
+
turn.stopTimer = setTimeout(() => {
|
|
126258
|
+
if (this.turn === turn) this.emit(stopNotEnded(this.sessionId, this.wire.label));
|
|
126259
|
+
}, this.stopConfirmMs);
|
|
126260
|
+
turn.stopTimer.unref?.();
|
|
126261
|
+
}
|
|
126262
|
+
if (this.wire.turns.interruptEndsProcess) {
|
|
126263
|
+
this.expectedExits.add(turn.proc);
|
|
126264
|
+
this.process.interrupt();
|
|
126265
|
+
}
|
|
126266
|
+
}
|
|
126029
126267
|
endTurn(turn, ending, events2) {
|
|
126030
126268
|
if (this.turn !== turn || this.phase === "closed") return;
|
|
126031
126269
|
if (turn.stopTimer) clearTimeout(turn.stopTimer);
|
|
@@ -126741,7 +126979,7 @@ var InitializeResult = external_exports.looseObject({
|
|
|
126741
126979
|
),
|
|
126742
126980
|
agentInfo: nullish3(external_exports.looseObject({ name: nullish3(external_exports.string()), version: nullish3(external_exports.string()) }))
|
|
126743
126981
|
});
|
|
126744
|
-
var SelectOption = external_exports.looseObject({ value: external_exports.string(), name:
|
|
126982
|
+
var SelectOption = external_exports.looseObject({ value: external_exports.string(), name: external_exports.string().nullish().optional() });
|
|
126745
126983
|
var ConfigOption = external_exports.looseObject({
|
|
126746
126984
|
id: external_exports.string(),
|
|
126747
126985
|
category: nullish3(external_exports.string()),
|
|
@@ -127114,8 +127352,15 @@ var AcpSession = class extends CoreSession {
|
|
|
127114
127352
|
new AcpWire(opts, deps)
|
|
127115
127353
|
);
|
|
127116
127354
|
this.opts = opts;
|
|
127355
|
+
if (deps.shape?.supportsModelOption) {
|
|
127356
|
+
this.updateSettings = (s) => this.wire.updateSettings(s);
|
|
127357
|
+
}
|
|
127117
127358
|
}
|
|
127118
127359
|
opts;
|
|
127360
|
+
updateSettings;
|
|
127361
|
+
takeOpenedSettings() {
|
|
127362
|
+
return this.wire.takeOpenedSettings();
|
|
127363
|
+
}
|
|
127119
127364
|
/**
|
|
127120
127365
|
* 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
127366
|
* 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 +127369,10 @@ var AcpSession = class extends CoreSession {
|
|
|
127124
127369
|
this.opts.apps?.cancelAll();
|
|
127125
127370
|
super.interrupt();
|
|
127126
127371
|
}
|
|
127372
|
+
interruptForInput() {
|
|
127373
|
+
this.opts.apps?.cancelAll();
|
|
127374
|
+
super.interruptForInput();
|
|
127375
|
+
}
|
|
127127
127376
|
respondApproval(requestId, decision, _scope, matcher2) {
|
|
127128
127377
|
return this.wire.respondApproval(requestId, decision, matcher2);
|
|
127129
127378
|
}
|
|
@@ -127164,6 +127413,10 @@ var AcpWire = class {
|
|
|
127164
127413
|
this.label = deps.label;
|
|
127165
127414
|
if (deps.install !== void 0) this.install = deps.install;
|
|
127166
127415
|
this.preset = opts.permissionPreset;
|
|
127416
|
+
this.turns = {
|
|
127417
|
+
interruptEndsProcess: false,
|
|
127418
|
+
...deps.shape?.interruptForInput ? { interruptForInput: true } : {}
|
|
127419
|
+
};
|
|
127167
127420
|
this.launch = async () => deps.spec;
|
|
127168
127421
|
this.normalizer = new AcpNormalizer(opts.sessionId, deps.label);
|
|
127169
127422
|
this.unmapped = new UnmappedTypes(deps.label, opts.sessionId, KNOWN_UPDATES);
|
|
@@ -127174,7 +127427,7 @@ var AcpWire = class {
|
|
|
127174
127427
|
label;
|
|
127175
127428
|
install;
|
|
127176
127429
|
/** ACP runs one prompt at a time (§5.4); a cancel ends the turn with `cancelled`, so the Stop's timer applies */
|
|
127177
|
-
turns
|
|
127430
|
+
turns;
|
|
127178
127431
|
launch;
|
|
127179
127432
|
/** ACP's `auto` allows (`core/grants.ts`) */
|
|
127180
127433
|
grants = new Grants("allow");
|
|
@@ -127211,6 +127464,11 @@ var AcpWire = class {
|
|
|
127211
127464
|
opening = null;
|
|
127212
127465
|
/** This process's conversation is open (`open` answered): until then a failed open ends the process, after it the wire does */
|
|
127213
127466
|
opened = false;
|
|
127467
|
+
openedSettings = null;
|
|
127468
|
+
currentModel = null;
|
|
127469
|
+
currentEffort = null;
|
|
127470
|
+
effortConfigId = "thought_level";
|
|
127471
|
+
settingsQueue = Promise.resolve();
|
|
127214
127472
|
/**
|
|
127215
127473
|
* The agent wants an interactive sign-in inside this session's process (`SignInWanted`): it would wait for a browser
|
|
127216
127474
|
* nobody asked for, and `session/new` would end in "No response" two minutes later with the tool still said ready. What
|
|
@@ -127234,6 +127492,71 @@ var AcpWire = class {
|
|
|
127234
127492
|
emit(e) {
|
|
127235
127493
|
this.io.emit(e);
|
|
127236
127494
|
}
|
|
127495
|
+
updateEffortId(options) {
|
|
127496
|
+
const thought = options.find((c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level");
|
|
127497
|
+
if (thought?.id) this.effortConfigId = thought.id;
|
|
127498
|
+
}
|
|
127499
|
+
handleConfigOptions(options) {
|
|
127500
|
+
this.updateEffortId(options);
|
|
127501
|
+
if (this.deps.shape?.supportsModelOption) {
|
|
127502
|
+
const currentModel = options.find((c) => c.id === "model" || c.category === "model")?.currentValue;
|
|
127503
|
+
const currentEffort = options.find((c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level")?.currentValue;
|
|
127504
|
+
if (typeof currentModel === "string") this.currentModel = currentModel;
|
|
127505
|
+
if (typeof currentEffort === "string") this.currentEffort = currentEffort;
|
|
127506
|
+
if (this.currentModel !== null || this.currentEffort !== null) {
|
|
127507
|
+
this.openedSettings = {
|
|
127508
|
+
model: this.currentModel,
|
|
127509
|
+
effort: this.currentEffort
|
|
127510
|
+
};
|
|
127511
|
+
}
|
|
127512
|
+
this.deps.shape.onConfigOptions?.(options);
|
|
127513
|
+
}
|
|
127514
|
+
}
|
|
127515
|
+
async setConfigOption(configId, value) {
|
|
127516
|
+
if (!this.conversation) return false;
|
|
127517
|
+
try {
|
|
127518
|
+
await this.conn.request("session/set_config_option", {
|
|
127519
|
+
sessionId: this.conversation,
|
|
127520
|
+
configId,
|
|
127521
|
+
value
|
|
127522
|
+
}, 2e4);
|
|
127523
|
+
return true;
|
|
127524
|
+
} catch (err) {
|
|
127525
|
+
console.error(`[${this.label}] session/set_config_option failed (${configId}=${value}):`, err);
|
|
127526
|
+
return false;
|
|
127527
|
+
}
|
|
127528
|
+
}
|
|
127529
|
+
takeOpenedSettings() {
|
|
127530
|
+
const s = this.openedSettings;
|
|
127531
|
+
this.openedSettings = null;
|
|
127532
|
+
return s;
|
|
127533
|
+
}
|
|
127534
|
+
updateSettings(settings) {
|
|
127535
|
+
if (!this.deps.shape?.supportsModelOption) return;
|
|
127536
|
+
this.settingsQueue = this.settingsQueue.then(async () => {
|
|
127537
|
+
if (settings.model) {
|
|
127538
|
+
const ok = await this.setConfigOption("model", settings.model);
|
|
127539
|
+
if (ok) {
|
|
127540
|
+
this.currentModel = settings.model;
|
|
127541
|
+
this.openedSettings = {
|
|
127542
|
+
model: this.currentModel,
|
|
127543
|
+
effort: this.currentEffort
|
|
127544
|
+
};
|
|
127545
|
+
}
|
|
127546
|
+
}
|
|
127547
|
+
if (settings.effort) {
|
|
127548
|
+
const ok = await this.setConfigOption(this.effortConfigId, settings.effort);
|
|
127549
|
+
if (ok) {
|
|
127550
|
+
this.currentEffort = settings.effort;
|
|
127551
|
+
this.openedSettings = {
|
|
127552
|
+
model: this.currentModel,
|
|
127553
|
+
effort: this.currentEffort
|
|
127554
|
+
};
|
|
127555
|
+
}
|
|
127556
|
+
}
|
|
127557
|
+
}).catch(() => {
|
|
127558
|
+
});
|
|
127559
|
+
}
|
|
127237
127560
|
async open(io2, resume) {
|
|
127238
127561
|
this.io = io2;
|
|
127239
127562
|
this.opened = false;
|
|
@@ -127277,8 +127600,9 @@ var AcpWire = class {
|
|
|
127277
127600
|
if (!method) throw rpcError(`${this.label} cannot reopen a conversation`, "session_not_found");
|
|
127278
127601
|
this.replaying = method === "session/load";
|
|
127279
127602
|
this.opening = resume.externalId;
|
|
127603
|
+
let opened = null;
|
|
127280
127604
|
try {
|
|
127281
|
-
OpenedSession.parse(await this.conn.request(method, { ...base2, sessionId: resume.externalId }, 15e4) ?? {});
|
|
127605
|
+
opened = OpenedSession.parse(await this.conn.request(method, { ...base2, sessionId: resume.externalId }, 15e4) ?? {});
|
|
127282
127606
|
} catch (err) {
|
|
127283
127607
|
this.replaying = false;
|
|
127284
127608
|
this.opening = null;
|
|
@@ -127288,14 +127612,36 @@ var AcpWire = class {
|
|
|
127288
127612
|
this.opening = null;
|
|
127289
127613
|
}
|
|
127290
127614
|
this.conversation = resume.externalId;
|
|
127615
|
+
if (opened?.configOptions) {
|
|
127616
|
+
this.handleConfigOptions(opened.configOptions);
|
|
127617
|
+
}
|
|
127291
127618
|
this.costTotal = this.opts.runningCost?.last ?? null;
|
|
127292
127619
|
} else {
|
|
127293
127620
|
const opened = OpenedSession.parse(await this.conn.request("session/new", base2, 12e4));
|
|
127294
127621
|
if (!opened.sessionId) throw new Error(`${this.label} opened a session without an id`);
|
|
127295
127622
|
this.conversation = opened.sessionId;
|
|
127623
|
+
if (opened.configOptions) {
|
|
127624
|
+
this.handleConfigOptions(opened.configOptions);
|
|
127625
|
+
}
|
|
127296
127626
|
this.costTotal = 0;
|
|
127297
127627
|
this.opts.runningCost?.keep(0);
|
|
127298
127628
|
}
|
|
127629
|
+
if (this.deps.shape?.supportsModelOption) {
|
|
127630
|
+
if (this.opts.model) {
|
|
127631
|
+
const ok = await this.setConfigOption("model", this.opts.model);
|
|
127632
|
+
if (ok) {
|
|
127633
|
+
this.currentModel = this.opts.model;
|
|
127634
|
+
this.openedSettings = { model: this.currentModel, effort: this.currentEffort };
|
|
127635
|
+
}
|
|
127636
|
+
}
|
|
127637
|
+
if (this.opts.effort) {
|
|
127638
|
+
const ok = await this.setConfigOption(this.effortConfigId, this.opts.effort);
|
|
127639
|
+
if (ok) {
|
|
127640
|
+
this.currentEffort = this.opts.effort;
|
|
127641
|
+
this.openedSettings = { model: this.currentModel, effort: this.currentEffort };
|
|
127642
|
+
}
|
|
127643
|
+
}
|
|
127644
|
+
}
|
|
127299
127645
|
this.opened = true;
|
|
127300
127646
|
return { externalId: this.conversation };
|
|
127301
127647
|
} catch (err) {
|
|
@@ -127497,6 +127843,10 @@ var AcpWire = class {
|
|
|
127497
127843
|
this.commands = read2.update.availableCommands.map((c) => ({ name: c.name, ...c.description ? { description: c.description } : {}, ...c.input?.hint ? { argumentHint: c.input.hint } : {} }));
|
|
127498
127844
|
return;
|
|
127499
127845
|
}
|
|
127846
|
+
if ("update" in read2 && read2.update.sessionUpdate === "config_option_update" && (read2.sessionId === this.conversation || read2.sessionId === this.opening)) {
|
|
127847
|
+
this.handleConfigOptions(read2.update.configOptions);
|
|
127848
|
+
return;
|
|
127849
|
+
}
|
|
127500
127850
|
if (read2.sessionId !== this.conversation || this.replaying) return;
|
|
127501
127851
|
const turn = this.turn;
|
|
127502
127852
|
this.resendLostCancel();
|
|
@@ -127721,6 +128071,8 @@ var AcpAdapter = class {
|
|
|
127721
128071
|
if (localUsage) this.localUsage = localUsage;
|
|
127722
128072
|
const sweep = profile.sweepSessionFiles?.bind(profile);
|
|
127723
128073
|
if (sweep) this.sweepSessionFiles = sweep;
|
|
128074
|
+
const listModels = profile.listModels?.bind(profile);
|
|
128075
|
+
if (listModels) this.listModels = listModels;
|
|
127724
128076
|
}
|
|
127725
128077
|
profile;
|
|
127726
128078
|
spawn;
|
|
@@ -127729,6 +128081,8 @@ var AcpAdapter = class {
|
|
|
127729
128081
|
listUsage;
|
|
127730
128082
|
/** What the tool's own command says about its usage (the profile's `localUsage`), when it has one */
|
|
127731
128083
|
localUsage;
|
|
128084
|
+
/** The models available to choose from (the profile's `listModels`), when it has them */
|
|
128085
|
+
listModels;
|
|
127732
128086
|
/** What the tool keeps per session, swept (the profile's `sweepSessionFiles`), when it keeps any */
|
|
127733
128087
|
sweepSessionFiles;
|
|
127734
128088
|
get descriptor() {
|
|
@@ -127992,6 +128346,21 @@ function agyPlatformKey(platform = HOST_PLATFORM, arch = process.arch) {
|
|
|
127992
128346
|
if (platform === "win32") return `windows-${cpu}`;
|
|
127993
128347
|
return null;
|
|
127994
128348
|
}
|
|
128349
|
+
async function usagePlace(home) {
|
|
128350
|
+
const cwd = resolve13(join34(home.root, "usage"));
|
|
128351
|
+
await mkdir5(cwd, { recursive: true });
|
|
128352
|
+
const file2 = join34(home.root, "usage-session.json");
|
|
128353
|
+
const kept = await readFile5(file2, "utf8").then((text3) => asObj(JSON.parse(text3)).sessionId).catch(() => null);
|
|
128354
|
+
return { cwd, kept: typeof kept === "string" && kept !== "" ? kept : null, keep: (sessionId) => writeFile5(file2, `${JSON.stringify({ sessionId })}
|
|
128355
|
+
`) };
|
|
128356
|
+
}
|
|
128357
|
+
var AGY_MODELS_CACHE = "models.json";
|
|
128358
|
+
async function readCachedAgyModels(home) {
|
|
128359
|
+
return readFile5(join34(home.root, AGY_MODELS_CACHE), "utf8").catch(() => null);
|
|
128360
|
+
}
|
|
128361
|
+
async function writeCachedAgyModels(home, text3) {
|
|
128362
|
+
await writeFile5(join34(home.root, AGY_MODELS_CACHE), text3, "utf8");
|
|
128363
|
+
}
|
|
127995
128364
|
function agyHome(dataDir, version2) {
|
|
127996
128365
|
const root3 = join34(dataDir, "tools", "antigravity");
|
|
127997
128366
|
return { root: root3, versionDir: join34(root3, version2), geminiHome: join34(root3, "gemini-home") };
|
|
@@ -128273,20 +128642,20 @@ function notOwnFolder(facts, uid) {
|
|
|
128273
128642
|
}
|
|
128274
128643
|
async function browserFolder(home, platform = HOST_PLATFORM, places = {}, session2) {
|
|
128275
128644
|
const node = places.node ?? process.execPath;
|
|
128276
|
-
const
|
|
128277
|
-
const nodeBad = platform === "win32" ? unusableIn(node,
|
|
128645
|
+
const sep14 = platform === "win32" ? ";" : ":";
|
|
128646
|
+
const nodeBad = platform === "win32" ? unusableIn(node, sep14) : "";
|
|
128278
128647
|
if (nodeBad) return noHelper(`the Node program Centralu runs on is at ${node}, and Antigravity cannot be given a path with ${nodeBad} in it. Install Centralu (or that Node) in a folder whose path has none.`);
|
|
128279
128648
|
await mkdir5(home.root, { recursive: true });
|
|
128280
128649
|
await removeStale(home.root, ".sign-in-");
|
|
128281
128650
|
let dir = resolve13(await mkdtemp3(join34(home.root, `.sign-in-${ownerTag()}-`)));
|
|
128282
|
-
const dataBad = unusableIn(dir,
|
|
128651
|
+
const dataBad = unusableIn(dir, sep14);
|
|
128283
128652
|
if (dataBad) {
|
|
128284
128653
|
await realOs().files.promises.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
128285
128654
|
});
|
|
128286
128655
|
const spare = resolve13(places.spare ?? spareFolder(platform));
|
|
128287
128656
|
const data = `Centralu's data folder is at ${home.root}, and Antigravity cannot be given a path with ${dataBad} in it`;
|
|
128288
128657
|
const move = "Move the data folder to a path without them.";
|
|
128289
|
-
const spareBad = unusableIn(join34(spare, ".sign-in-x"),
|
|
128658
|
+
const spareBad = unusableIn(join34(spare, ".sign-in-x"), sep14);
|
|
128290
128659
|
if (spareBad) return noHelper(`${data}; nor ${spareBad} in ${spare}, the folder Centralu tries instead. ${move}`);
|
|
128291
128660
|
try {
|
|
128292
128661
|
await mkdir5(spare, { recursive: true, mode: 448 });
|
|
@@ -128324,7 +128693,7 @@ exit 0
|
|
|
128324
128693
|
if (browser === "") {
|
|
128325
128694
|
await realOs().files.promises.rm(dir, { recursive: true, force: true }).catch(() => {
|
|
128326
128695
|
});
|
|
128327
|
-
return noHelper(`the helper's folder ${dir} has a path Antigravity cannot be given (it holds ${unusableIn(dir,
|
|
128696
|
+
return noHelper(`the helper's folder ${dir} has a path Antigravity cannot be given (it holds ${unusableIn(dir, sep14)}).`);
|
|
128328
128697
|
}
|
|
128329
128698
|
if (temp) {
|
|
128330
128699
|
try {
|
|
@@ -128858,6 +129227,245 @@ var AGY_SURFACE = {
|
|
|
128858
129227
|
baseline: BASELINE
|
|
128859
129228
|
};
|
|
128860
129229
|
|
|
129230
|
+
// packages/agent-host/src/adapters/antigravity/usage.ts
|
|
129231
|
+
var READ_TIMEOUT_MS = 12e3;
|
|
129232
|
+
var AgyQuota = external_exports.array(
|
|
129233
|
+
external_exports.object({
|
|
129234
|
+
name: external_exports.string().min(1),
|
|
129235
|
+
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)
|
|
129236
|
+
})
|
|
129237
|
+
).min(1);
|
|
129238
|
+
async function readAgyUsage(home, archive, signedOut, deps = {}) {
|
|
129239
|
+
const timeoutMs = deps.timeoutMs ?? READ_TIMEOUT_MS;
|
|
129240
|
+
const folder = await browserFolder(home, deps.platform, deps.helperPlaces);
|
|
129241
|
+
if (folder.browser === "") throw new Error(`Antigravity cannot say its usage: ${folder.why}`);
|
|
129242
|
+
const place = await usagePlace(home);
|
|
129243
|
+
const launch2 = agyLaunch(home, archive, folder);
|
|
129244
|
+
const proc = startToolProcess({ ...launch2, cwd: place.cwd, env: { ...process.env, ...launch2.env } }, deps.spawn ? { spawn: deps.spawn } : {});
|
|
129245
|
+
let text3 = "";
|
|
129246
|
+
const stray = { what: null };
|
|
129247
|
+
let wantsSignIn = false;
|
|
129248
|
+
let timedOut2 = false;
|
|
129249
|
+
let hasUsageCommand = null;
|
|
129250
|
+
const conn = new AcpConnection(
|
|
129251
|
+
proc,
|
|
129252
|
+
{
|
|
129253
|
+
onNotification: (method, params) => {
|
|
129254
|
+
const u = method === "session/update" ? readUpdate(params) : null;
|
|
129255
|
+
if (!u || !("update" in u)) return;
|
|
129256
|
+
if (u.update.sessionUpdate === "agent_message_chunk" && u.update.content.type === "text") text3 += u.update.content.text ?? "";
|
|
129257
|
+
if (u.update.sessionUpdate === "tool_call") stray.what ??= "a tool call";
|
|
129258
|
+
if (u.update.sessionUpdate === "available_commands_update") {
|
|
129259
|
+
hasUsageCommand = u.update.availableCommands.some((c) => c.name === "usage");
|
|
129260
|
+
}
|
|
129261
|
+
},
|
|
129262
|
+
onRequest: async (_id, method) => {
|
|
129263
|
+
stray.what ??= method;
|
|
129264
|
+
throw new RpcError(METHOD_NOT_FOUND2, `Method not found: ${method}`);
|
|
129265
|
+
},
|
|
129266
|
+
onExit: () => {
|
|
129267
|
+
}
|
|
129268
|
+
},
|
|
129269
|
+
"Antigravity usage",
|
|
129270
|
+
agyStderrLine
|
|
129271
|
+
);
|
|
129272
|
+
folder.watch((address) => {
|
|
129273
|
+
if (!agentSignInUrl(address)) return;
|
|
129274
|
+
wantsSignIn = true;
|
|
129275
|
+
void conn.dispose(500);
|
|
129276
|
+
});
|
|
129277
|
+
const timer = setTimeout(() => {
|
|
129278
|
+
timedOut2 = true;
|
|
129279
|
+
void conn.dispose(500);
|
|
129280
|
+
}, timeoutMs);
|
|
129281
|
+
try {
|
|
129282
|
+
await conn.request("initialize", { protocolVersion: 1, clientInfo: { name: "centralu", version: "1" }, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } }, timeoutMs);
|
|
129283
|
+
const base2 = { cwd: place.cwd, mcpServers: [] };
|
|
129284
|
+
let sessionId = place.kept && await conn.request("session/resume", { ...base2, sessionId: place.kept }, timeoutMs).then(() => place.kept, () => null);
|
|
129285
|
+
if (!sessionId) {
|
|
129286
|
+
sessionId = OpenedSession.parse(await conn.request("session/new", base2, timeoutMs)).sessionId ?? null;
|
|
129287
|
+
if (!sessionId) throw new Error("Antigravity opened a conversation without an id");
|
|
129288
|
+
await place.keep(sessionId);
|
|
129289
|
+
}
|
|
129290
|
+
if (hasUsageCommand === false) throw new Error('Antigravity does not support "/usage" in this version');
|
|
129291
|
+
text3 = "";
|
|
129292
|
+
const done2 = PromptResult.parse(await conn.request("session/prompt", { sessionId, prompt: [{ type: "text", text: "/usage" }] }, timeoutMs));
|
|
129293
|
+
if (stray.what) throw new Error(`Antigravity answered "/usage" with ${stray.what}, not its usage`);
|
|
129294
|
+
const reason = typeof done2.stopReason === "string" ? done2.stopReason : "";
|
|
129295
|
+
if (reason !== "end_turn") throw new Error(`Antigravity's "/usage" ended "${reason}", not with its usage`);
|
|
129296
|
+
return readAgyQuota(text3);
|
|
129297
|
+
} catch (err) {
|
|
129298
|
+
if (wantsSignIn || err instanceof RpcError && err.code === AUTH_REQUIRED) throw signedOut();
|
|
129299
|
+
if (timedOut2) throw new Error(`Antigravity did not say its usage within ${Math.round(timeoutMs / 1e3)} s`);
|
|
129300
|
+
if (err instanceof RpcError) throw new Error(`Antigravity could not say its usage (error ${err.code})`);
|
|
129301
|
+
throw err;
|
|
129302
|
+
} finally {
|
|
129303
|
+
clearTimeout(timer);
|
|
129304
|
+
await conn.dispose(5e3).catch(() => {
|
|
129305
|
+
});
|
|
129306
|
+
await folder.remove();
|
|
129307
|
+
}
|
|
129308
|
+
}
|
|
129309
|
+
var GROUP = /^- \*\*(.+)\*\*$/;
|
|
129310
|
+
var NOTE = /^\*\(.*\)\*$/;
|
|
129311
|
+
var BUCKET = /^- \*\*(.+):\*\* (\d+(?:\.\d+)?)% remaining \(resets (.+)\)$/;
|
|
129312
|
+
var RESET = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{1,2}), (\d{4}), (\d{2}):(\d{2}) UTC$/;
|
|
129313
|
+
var MONTHS2 = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
129314
|
+
function unread2(what) {
|
|
129315
|
+
return new Error(`Antigravity's usage answer has a form Centralu does not read (${what})`);
|
|
129316
|
+
}
|
|
129317
|
+
function readAgyQuota(markdown2) {
|
|
129318
|
+
const groups = [];
|
|
129319
|
+
let inQuota = false;
|
|
129320
|
+
for (const raw of markdown2.split("\n")) {
|
|
129321
|
+
const line = raw.trim();
|
|
129322
|
+
if (line.startsWith("### ")) {
|
|
129323
|
+
inQuota = line === "### Quota Limits";
|
|
129324
|
+
continue;
|
|
129325
|
+
}
|
|
129326
|
+
if (!inQuota || line === "" || NOTE.test(line)) continue;
|
|
129327
|
+
const bucket = BUCKET.exec(line);
|
|
129328
|
+
if (bucket) {
|
|
129329
|
+
const group2 = groups.at(-1);
|
|
129330
|
+
if (!group2) throw unread2("a limit before any group");
|
|
129331
|
+
const resetStr = bucket[3];
|
|
129332
|
+
const reset = resetStr ? RESET.exec(resetStr) : null;
|
|
129333
|
+
if (!reset) throw unread2("a reset time");
|
|
129334
|
+
const [, month, day4, year, hour, minute] = reset;
|
|
129335
|
+
const label = bucket[1];
|
|
129336
|
+
const remainingStr = bucket[2];
|
|
129337
|
+
if (!month || !day4 || !year || !hour || !minute || !label || !remainingStr) throw unread2("a reset time");
|
|
129338
|
+
const at2 = new Date(Date.UTC(Number(year), MONTHS2.indexOf(month), Number(day4), Number(hour), Number(minute)));
|
|
129339
|
+
group2.buckets.push({ label, remaining: Number(remainingStr), resetsAt: at2.toISOString() });
|
|
129340
|
+
continue;
|
|
129341
|
+
}
|
|
129342
|
+
const group = GROUP.exec(line);
|
|
129343
|
+
if (!group || !group[1]) throw unread2("a line of a kind it does not know");
|
|
129344
|
+
groups.push({ name: group[1], buckets: [] });
|
|
129345
|
+
}
|
|
129346
|
+
const quota = AgyQuota.safeParse(groups);
|
|
129347
|
+
if (!quota.success) throw unread2(groups.length === 0 ? "no limits" : "a group with no limits, or a value out of range");
|
|
129348
|
+
return quota.data;
|
|
129349
|
+
}
|
|
129350
|
+
var slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
129351
|
+
function agyUsageSnapshot(quota, plan) {
|
|
129352
|
+
const windows3 = quota.flatMap(
|
|
129353
|
+
(g5) => g5.buckets.map((b2) => {
|
|
129354
|
+
const label = b2.label.replace(/\s+Limit(\s+Remaining)?$/, "");
|
|
129355
|
+
return { id: `${slug(g5.name)}:${slug(label)}`, label, percent: 100 - b2.remaining, resetsAt: b2.resetsAt, scope: g5.name };
|
|
129356
|
+
})
|
|
129357
|
+
);
|
|
129358
|
+
return { plan, windows: windows3, daily: [] };
|
|
129359
|
+
}
|
|
129360
|
+
|
|
129361
|
+
// packages/agent-host/src/adapters/antigravity/models.ts
|
|
129362
|
+
var AGY_BASELINE_MODELS = [
|
|
129363
|
+
{
|
|
129364
|
+
id: "gemini-4-argon",
|
|
129365
|
+
label: "Gemini 4 Argon",
|
|
129366
|
+
efforts: ["low", "medium", "high"],
|
|
129367
|
+
defaultEffort: "medium",
|
|
129368
|
+
tiers: []
|
|
129369
|
+
},
|
|
129370
|
+
{
|
|
129371
|
+
id: "gemini-3.8-flash",
|
|
129372
|
+
label: "Gemini 3.8 Flash",
|
|
129373
|
+
efforts: ["low", "medium", "high"],
|
|
129374
|
+
defaultEffort: "medium",
|
|
129375
|
+
tiers: []
|
|
129376
|
+
},
|
|
129377
|
+
{
|
|
129378
|
+
id: "claude-opus-5-5",
|
|
129379
|
+
label: "Claude Opus 5.5",
|
|
129380
|
+
efforts: ["low", "medium", "high"],
|
|
129381
|
+
defaultEffort: "medium",
|
|
129382
|
+
tiers: []
|
|
129383
|
+
},
|
|
129384
|
+
{
|
|
129385
|
+
id: "claude-sonnet-5-5",
|
|
129386
|
+
label: "Claude Sonnet 5.5",
|
|
129387
|
+
efforts: ["low", "medium", "high"],
|
|
129388
|
+
defaultEffort: "medium",
|
|
129389
|
+
tiers: []
|
|
129390
|
+
},
|
|
129391
|
+
{
|
|
129392
|
+
id: "gpt-oss-120b-medium",
|
|
129393
|
+
label: "GPT-OSS 120B (Medium)",
|
|
129394
|
+
efforts: ["low", "medium", "high"],
|
|
129395
|
+
defaultEffort: "medium",
|
|
129396
|
+
tiers: []
|
|
129397
|
+
}
|
|
129398
|
+
];
|
|
129399
|
+
function extractSelectOptions(options) {
|
|
129400
|
+
if (!Array.isArray(options)) return [];
|
|
129401
|
+
const out = [];
|
|
129402
|
+
for (const raw of options) {
|
|
129403
|
+
const opt = asObj(raw);
|
|
129404
|
+
if (Array.isArray(opt.options)) {
|
|
129405
|
+
for (const nestedRaw of opt.options) {
|
|
129406
|
+
const nested = asObj(nestedRaw);
|
|
129407
|
+
if (typeof nested.value === "string") {
|
|
129408
|
+
out.push({ value: nested.value, ...typeof nested.name === "string" ? { name: nested.name } : {} });
|
|
129409
|
+
}
|
|
129410
|
+
}
|
|
129411
|
+
} else if (typeof opt.value === "string") {
|
|
129412
|
+
out.push({ value: opt.value, ...typeof opt.name === "string" ? { name: opt.name } : {} });
|
|
129413
|
+
}
|
|
129414
|
+
}
|
|
129415
|
+
return out;
|
|
129416
|
+
}
|
|
129417
|
+
function toModelOptions(configOptions) {
|
|
129418
|
+
const modelOpt = configOptions.find((c) => c.id === "model" || c.category === "model");
|
|
129419
|
+
if (!modelOpt) return [];
|
|
129420
|
+
const thoughtOpt = configOptions.find(
|
|
129421
|
+
(c) => c.category === "thought_level" || c.id === "thought_level" || c.id === "thinking_level"
|
|
129422
|
+
);
|
|
129423
|
+
const rawEfforts = extractSelectOptions(thoughtOpt?.options);
|
|
129424
|
+
const efforts = [...new Set(rawEfforts.map((o) => o.value))];
|
|
129425
|
+
const defaultEffort = typeof thoughtOpt?.currentValue === "string" && efforts.includes(thoughtOpt.currentValue) ? thoughtOpt.currentValue : efforts.length > 0 ? efforts.includes("medium") ? "medium" : efforts[0] ?? null : null;
|
|
129426
|
+
const modelItems = extractSelectOptions(modelOpt.options);
|
|
129427
|
+
const seen = /* @__PURE__ */ new Set();
|
|
129428
|
+
const result = [];
|
|
129429
|
+
for (const item of modelItems) {
|
|
129430
|
+
if (!seen.has(item.value)) {
|
|
129431
|
+
seen.add(item.value);
|
|
129432
|
+
result.push({
|
|
129433
|
+
id: item.value,
|
|
129434
|
+
label: item.name || item.value,
|
|
129435
|
+
efforts: [...efforts],
|
|
129436
|
+
defaultEffort,
|
|
129437
|
+
tiers: []
|
|
129438
|
+
});
|
|
129439
|
+
}
|
|
129440
|
+
}
|
|
129441
|
+
return result;
|
|
129442
|
+
}
|
|
129443
|
+
async function saveAgyModels(home, models) {
|
|
129444
|
+
if (models.length === 0) return;
|
|
129445
|
+
await writeCachedAgyModels(home, `${JSON.stringify(models, null, 2)}
|
|
129446
|
+
`);
|
|
129447
|
+
}
|
|
129448
|
+
async function listAgyModels(home, archive, setup, signedOut, label, install) {
|
|
129449
|
+
if (!archive || !setup.installed()) {
|
|
129450
|
+
throw toolNotInstalled(label, install);
|
|
129451
|
+
}
|
|
129452
|
+
if (setup.current().state !== "ready") {
|
|
129453
|
+
throw signedOut();
|
|
129454
|
+
}
|
|
129455
|
+
try {
|
|
129456
|
+
const raw = await readCachedAgyModels(home);
|
|
129457
|
+
if (raw) {
|
|
129458
|
+
const parsed = JSON.parse(raw);
|
|
129459
|
+
const checked2 = external_exports.array(ModelOption).safeParse(parsed);
|
|
129460
|
+
if (checked2.success && checked2.data.length > 0) {
|
|
129461
|
+
return checked2.data;
|
|
129462
|
+
}
|
|
129463
|
+
}
|
|
129464
|
+
} catch {
|
|
129465
|
+
}
|
|
129466
|
+
return [...AGY_BASELINE_MODELS];
|
|
129467
|
+
}
|
|
129468
|
+
|
|
128861
129469
|
// packages/agent-host/src/adapters/antigravity/index.ts
|
|
128862
129470
|
var CAPABILITIES = {
|
|
128863
129471
|
// What the agent does or lacks beyond these fields (`roleText`, `attachments` and `keepsRepoFilesOut` stay at the ACP defaults):
|
|
@@ -128865,7 +129473,7 @@ var CAPABILITIES = {
|
|
|
128865
129473
|
// skill as `skills/system/run-workflow/SKILL.md` into the session's project at `session/new`; Windows 1.4.3 writes none
|
|
128866
129474
|
// (#2320, docs/plans/antigravity-acp.md §1 has the cause)
|
|
128867
129475
|
// - 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
|
|
129476
|
+
// the project's own instruction files, as the other ACP tools), images in the prompt
|
|
128869
129477
|
...ACP_CAPABILITIES,
|
|
128870
129478
|
autoTitle: false
|
|
128871
129479
|
};
|
|
@@ -128881,6 +129489,11 @@ function antigravityProfile(deps = {}) {
|
|
|
128881
129489
|
const archive = key2 ? AGY_RELEASE.archives[key2] : null;
|
|
128882
129490
|
const home = agyHome(deps.dataDir ?? dataRoot(), AGY_RELEASE.version);
|
|
128883
129491
|
const setup = new AgySetup({ home, archive, version: AGY_RELEASE.version, appFound: agyAppFinder(deps.platform), ...deps });
|
|
129492
|
+
const signedOut = () => {
|
|
129493
|
+
setup.noteSignedOut();
|
|
129494
|
+
return rpcError(notSignedIn(DESCRIPTOR, "centralu"), "not_logged_in");
|
|
129495
|
+
};
|
|
129496
|
+
let reading = null;
|
|
128884
129497
|
return {
|
|
128885
129498
|
descriptor: DESCRIPTOR,
|
|
128886
129499
|
capabilities: CAPABILITIES,
|
|
@@ -128926,10 +129539,32 @@ function antigravityProfile(deps = {}) {
|
|
|
128926
129539
|
isQuestion: isAgyQuestion,
|
|
128927
129540
|
editRunsAsNewCall: true,
|
|
128928
129541
|
stderrLine: agyStderrLine,
|
|
128929
|
-
signedOut
|
|
128930
|
-
|
|
128931
|
-
|
|
129542
|
+
signedOut,
|
|
129543
|
+
supportsModelOption: true,
|
|
129544
|
+
interruptForInput: true,
|
|
129545
|
+
onConfigOptions: (options) => {
|
|
129546
|
+
const models = toModelOptions(options);
|
|
129547
|
+
if (models.length > 0) void saveAgyModels(home, models).catch(() => {
|
|
129548
|
+
});
|
|
128932
129549
|
}
|
|
129550
|
+
},
|
|
129551
|
+
listModels() {
|
|
129552
|
+
return listAgyModels(home, archive, setup, signedOut, DESCRIPTOR.label, DESCRIPTOR.install);
|
|
129553
|
+
},
|
|
129554
|
+
/*
|
|
129555
|
+
* Its weekly and five-hour limits per model group, from the agent Centralu signed in (`readAgyUsage`), one read at a
|
|
129556
|
+
* time. No `account()`: the sign-in is this machine's Centralu's own (plan §0), so a linked machine's usage is read there
|
|
129557
|
+
*/
|
|
129558
|
+
listUsage() {
|
|
129559
|
+
if (!archive || !setup.installed()) return Promise.reject(toolNotInstalled(DESCRIPTOR.label, DESCRIPTOR.install));
|
|
129560
|
+
if (setup.current().state !== "ready") return Promise.reject(signedOut());
|
|
129561
|
+
reading ??= readAgyUsage(home, archive, signedOut, { platform: deps.platform, helperPlaces: deps.helperPlaces, ...deps.usage }).then((quota) => agyUsageSnapshot(quota, setup.current().plan?.name ?? null)).catch((err) => {
|
|
129562
|
+
console.error(`[usage] antigravity: ${err instanceof Error ? err.message : String(err)}`);
|
|
129563
|
+
throw err;
|
|
129564
|
+
}).finally(() => {
|
|
129565
|
+
reading = null;
|
|
129566
|
+
});
|
|
129567
|
+
return reading;
|
|
128933
129568
|
}
|
|
128934
129569
|
};
|
|
128935
129570
|
}
|
|
@@ -132085,7 +132720,7 @@ var IDENT = /^[A-Za-z_$][\w$]*$/;
|
|
|
132085
132720
|
function stripComments(text3) {
|
|
132086
132721
|
return text3.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
132087
132722
|
}
|
|
132088
|
-
function splitTop(text3,
|
|
132723
|
+
function splitTop(text3, sep14) {
|
|
132089
132724
|
const parts = [];
|
|
132090
132725
|
let depth = 0;
|
|
132091
132726
|
let quote = "";
|
|
@@ -132100,7 +132735,7 @@ function splitTop(text3, sep13) {
|
|
|
132100
132735
|
if (c === "'" || c === '"' || c === "`") quote = c;
|
|
132101
132736
|
else if ("{[(<".includes(c)) depth++;
|
|
132102
132737
|
else if ("}])>".includes(c) && !(c === ">" && text3[i - 1] === "=")) depth--;
|
|
132103
|
-
else if (c ===
|
|
132738
|
+
else if (c === sep14 && depth === 0) {
|
|
132104
132739
|
parts.push(text3.slice(start3, i));
|
|
132105
132740
|
start3 = i + 1;
|
|
132106
132741
|
}
|
|
@@ -134593,7 +135228,7 @@ async function collectModels(fetchPage) {
|
|
|
134593
135228
|
let cursor = null;
|
|
134594
135229
|
for (let page = 0; page < MAX_PAGES; page++) {
|
|
134595
135230
|
const res = await fetchPage(cursor);
|
|
134596
|
-
out.push(...
|
|
135231
|
+
out.push(...toModelOptions2(res?.data));
|
|
134597
135232
|
cursor = typeof res?.nextCursor === "string" && res.nextCursor ? res.nextCursor : null;
|
|
134598
135233
|
if (!cursor) return out;
|
|
134599
135234
|
}
|
|
@@ -134613,7 +135248,7 @@ async function listCodexModels(command) {
|
|
|
134613
135248
|
});
|
|
134614
135249
|
});
|
|
134615
135250
|
}
|
|
134616
|
-
function
|
|
135251
|
+
function toModelOptions2(data) {
|
|
134617
135252
|
const rows3 = Array.isArray(data) ? data : [];
|
|
134618
135253
|
const out = [];
|
|
134619
135254
|
for (const r of rows3) {
|
|
@@ -138626,6 +139261,15 @@ var LinkedHost = class {
|
|
|
138626
139261
|
if (!r.ok) throw rpcError(r.error);
|
|
138627
139262
|
return { ok: true };
|
|
138628
139263
|
}
|
|
139264
|
+
/** `host.stopTask` (#2485), as `MailHooks.cancelGiven` decides */
|
|
139265
|
+
hubStopTask(sessionId, giver, taskId) {
|
|
139266
|
+
this.directedFromHub(sessionId);
|
|
139267
|
+
const running2 = inTurn(this.host.meta.get(sessionId)?.state ?? "idle") || this.host.turnContinue.waitsToContinue(sessionId);
|
|
139268
|
+
const alone = this.host.mail.cancelGiven(sessionId, giver, taskId);
|
|
139269
|
+
if (!running2 || !alone) return { stopped: false };
|
|
139270
|
+
this.host.inputs.interrupt(sessionId);
|
|
139271
|
+
return { stopped: true };
|
|
139272
|
+
}
|
|
138629
139273
|
/**
|
|
138630
139274
|
* 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
139275
|
* `send_to_session` delivers one here, recorded as sent by `fromName`, to a session a hub is shown and no other.
|
|
@@ -139642,6 +140286,12 @@ var MessageRecords = class {
|
|
|
139642
140286
|
const payload = row ? parseJson(row.payload) : void 0;
|
|
139643
140287
|
return row && isObj(payload) ? { seq: row.seq, ts: row.ts, text: typeof payload.text === "string" ? payload.text : "" } : null;
|
|
139644
140288
|
}
|
|
140289
|
+
/** 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 */
|
|
140290
|
+
hasAgentRows(sessionId) {
|
|
140291
|
+
return this.db.prepare(
|
|
140292
|
+
`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`
|
|
140293
|
+
).get(sessionId) !== void 0;
|
|
140294
|
+
}
|
|
139645
140295
|
nextSeq(sessionId) {
|
|
139646
140296
|
const row = oneRow(this.db.prepare(`SELECT COALESCE(MAX(seq), 0) as m FROM messages WHERE session_id = ?`).get(sessionId));
|
|
139647
140297
|
return row.m + 1;
|
|
@@ -139779,7 +140429,7 @@ var ChildOwnershipRecords = class {
|
|
|
139779
140429
|
* 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
140430
|
* stored request names its caller too). A crash before the commit leaves every row on the original; after it, every
|
|
139781
140431
|
* 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, `
|
|
140432
|
+
* `then`: the rest of the handoff's move that is stored elsewhere (the mail, `Handoffs.handOver`), run last in the same
|
|
139783
140433
|
* transaction, so a refusal there leaves every row of both on the original.
|
|
139784
140434
|
*/
|
|
139785
140435
|
moveChildren(from, to, move, then2) {
|
|
@@ -141714,7 +142364,7 @@ var StepsV41ToV47 = class extends MigrationRange {
|
|
|
141714
142364
|
* Expand only (#292): `grid_panels` stays as v9 made it for a v41 host, whose insert names neither NOT NULL
|
|
141715
142365
|
* `panel_key` nor `kind`. Its rows whose session still exists (an orphan would fail the key; listGridView joins
|
|
141716
142366
|
* `sessions`) are copied once, when this table is created; after that the builds' grids may differ, a layout,
|
|
141717
|
-
* not a record.
|
|
142367
|
+
* not a record. Step 78 drops `grid_panels`.
|
|
141718
142368
|
*/
|
|
141719
142369
|
run: () => {
|
|
141720
142370
|
const has = (name) => this.db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name = ?`).get(name) !== void 0;
|
|
@@ -142883,6 +143533,29 @@ var StepsV75 = class extends MigrationRange {
|
|
|
142883
143533
|
* backfilled: no build marked one.
|
|
142884
143534
|
*/
|
|
142885
143535
|
run: () => this.addColumn("mail_recipients", "given_again_at", "INTEGER")
|
|
143536
|
+
},
|
|
143537
|
+
{
|
|
143538
|
+
to: 78,
|
|
143539
|
+
breaksOlderReaders: true,
|
|
143540
|
+
minReader: 75,
|
|
143541
|
+
/**
|
|
143542
|
+
* Two clean-ups that ran at every start or waited for a breaking step (#2481), done once here.
|
|
143543
|
+
*
|
|
143544
|
+
* `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
|
|
143545
|
+
* neither read nor write it, so they open the store.
|
|
143546
|
+
*
|
|
143547
|
+
* 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
|
|
143548
|
+
* 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
|
|
143549
|
+
* 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
|
|
143550
|
+
* later is inert in every build that can.
|
|
143551
|
+
*
|
|
143552
|
+
* 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:
|
|
143553
|
+
* the builds of v75 to v77 name neither, and open the store.
|
|
143554
|
+
*/
|
|
143555
|
+
run: () => {
|
|
143556
|
+
this.db.exec(`DROP TABLE IF EXISTS grid_panels`);
|
|
143557
|
+
this.db.exec(`DELETE FROM approval_rules WHERE substr(matcher, -1) = '*'`);
|
|
143558
|
+
}
|
|
142886
143559
|
}
|
|
142887
143560
|
];
|
|
142888
143561
|
}
|
|
@@ -143040,15 +143713,6 @@ var PermissionRecords = class {
|
|
|
143040
143713
|
ORDER BY created_at DESC`
|
|
143041
143714
|
).all();
|
|
143042
143715
|
}
|
|
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
143716
|
/** A rule has to be deletable — saving without being able to delete would make "show the outcome" only half true */
|
|
143053
143717
|
deleteApprovalRule(id3) {
|
|
143054
143718
|
this.db.prepare(`DELETE FROM approval_rules WHERE id = ?`).run(id3);
|
|
@@ -143958,7 +144622,7 @@ var Store = class extends MigrationRunner {
|
|
|
143958
144622
|
/** The records of deleted app-agent sessions, kept in the session archive (#378) */
|
|
143959
144623
|
keptRuns;
|
|
143960
144624
|
children;
|
|
143961
|
-
/** Mail without threads: messages and each recipient's row (#1684, v65)
|
|
144625
|
+
/** Mail without threads: messages and each recipient's row (#1684, v65) */
|
|
143962
144626
|
mailbox;
|
|
143963
144627
|
machines;
|
|
143964
144628
|
/** Limit readings and tokens per hour, kept for the usage history (docs/agent-host/usage.md "Usage over time") */
|
|
@@ -144476,9 +145140,9 @@ function linkedTasksOf(mail, records, across, changes) {
|
|
|
144476
145140
|
const answer = task ? records.reportsOn(task.id).at(-1)?.facts.answer : void 0;
|
|
144477
145141
|
return typeof answer === "string" ? answer : void 0;
|
|
144478
145142
|
},
|
|
144479
|
-
withdraw: (callerId, childId) => {
|
|
145143
|
+
withdraw: (callerId, childId, taskId) => {
|
|
144480
145144
|
const caller = mail.sessionAddress(callerId);
|
|
144481
|
-
return tasksTo(caller, mail.sessionAddress(childId)).reduce((n, r) => n + mail.done(caller, r.messageId).settled, 0);
|
|
145145
|
+
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
145146
|
},
|
|
144483
145147
|
gone: (childId) => mail.stops.partyGone(mail.sessionAddress(childId))
|
|
144484
145148
|
};
|
|
@@ -144758,9 +145422,8 @@ var AskProjectFlow = class {
|
|
|
144758
145422
|
* 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
145423
|
* does for a child there; the answer is the session's words there, and the paths it names are that machine's files,
|
|
144760
145424
|
* 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.
|
|
145425
|
+
* 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
|
|
145426
|
+
* lets it (#2485); a cancelled call stops the turn its task alone started there (`cancelAsk`).
|
|
144764
145427
|
*/
|
|
144765
145428
|
async askLinkedProject(callerId, callerProjectId, callerProject, target, reader, opts, signal) {
|
|
144766
145429
|
const label = `${target.name} on ${target.machine}`;
|
|
@@ -144770,7 +145433,7 @@ var AskProjectFlow = class {
|
|
|
144770
145433
|
const wanted = opts.session?.trim();
|
|
144771
145434
|
const of2 = (g5, sessionName) => ({ taskId: g5.taskId, sessionId: g5.sessionId, child: g5.sessionId, sessionName, project: project2 });
|
|
144772
145435
|
if (target.away) {
|
|
144773
|
-
const there = given.filter((g5) => reader.describe(g5.sessionId)?.
|
|
145436
|
+
const there = given.filter((g5) => reader.describe(g5.sessionId)?.projectName === target.name && (!wanted || g5.sessionId === wanted));
|
|
144774
145437
|
const [only] = there;
|
|
144775
145438
|
if (!opts.task && only && there.length === 1) return this.awaitAsk(callerId, of2(only, reader.describe(only.sessionId)?.name ?? only.sessionId), reader, signal);
|
|
144776
145439
|
return { ok: false, error: awayRefusal(target.machine, target.away, `${label} cannot be asked`) };
|
|
@@ -144877,10 +145540,27 @@ var AskProjectFlow = class {
|
|
|
144877
145540
|
async awaitAsk(callerId, ask, reader, signal) {
|
|
144878
145541
|
const tasks = this.host.linkedTasks;
|
|
144879
145542
|
const base2 = { project: ask.project, sessionId: ask.sessionId, sessionName: ask.sessionName };
|
|
144880
|
-
const
|
|
144881
|
-
|
|
145543
|
+
const remote = this.host.delegationFlow.remote;
|
|
145544
|
+
const cardsThere = async () => {
|
|
145545
|
+
const r5 = reader ? await reader.cards(ask.sessionId, callerId) : null;
|
|
145546
|
+
return r5?.ok ? r5.cards : [];
|
|
145547
|
+
};
|
|
145548
|
+
const asking = (cards) => ({ ok: true, state: "asking", ...base2, cards });
|
|
145549
|
+
const standing2 = await cardsThere();
|
|
145550
|
+
if (standing2.length) return asking(standing2);
|
|
145551
|
+
const card = reader ? remote.untilCard(ask.sessionId) : void 0;
|
|
145552
|
+
let r;
|
|
145553
|
+
try {
|
|
145554
|
+
r = await tasks.settled(ask.taskId, ASK_WAIT_MS, { signal, ...card ? { until: card.raised } : {} });
|
|
145555
|
+
} finally {
|
|
145556
|
+
card?.done();
|
|
145557
|
+
}
|
|
145558
|
+
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
145559
|
const s = tasks.standing(ask.taskId);
|
|
144883
|
-
if (r === "bound" || s.state === "open")
|
|
145560
|
+
if (r === "bound" || s.state === "open") {
|
|
145561
|
+
const cards = s.state === "open" ? await cardsThere() : [];
|
|
145562
|
+
return cards.length ? asking(cards) : { ok: true, state: "working", ...base2 };
|
|
145563
|
+
}
|
|
144884
145564
|
this.host.children.answered(callerId, ask.child);
|
|
144885
145565
|
const failed5 = unfinished(s);
|
|
144886
145566
|
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 +145577,22 @@ var AskProjectFlow = class {
|
|
|
144897
145577
|
...paused ? { paused: pausedWords(paused, ask.sessionId, " there") } : {}
|
|
144898
145578
|
};
|
|
144899
145579
|
}
|
|
145580
|
+
/**
|
|
145581
|
+
* 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
|
|
145582
|
+
* 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
|
|
145583
|
+
* 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
|
|
145584
|
+
* report comes as mail. A host that is quitting asks nothing: its calls end with it, and the work there goes on
|
|
145585
|
+
*/
|
|
145586
|
+
async cancelAsk(callerId, ask, reader) {
|
|
145587
|
+
const where2 = `${ask.project}'s session "${ask.sessionName}"`;
|
|
145588
|
+
const tasks = this.host.linkedTasks;
|
|
145589
|
+
if (this.host.closing || !reader.stopTask || !tasks) return { ok: false, error: `The call was cancelled; ${where2} was left running.` };
|
|
145590
|
+
const r = await reader.stopTask(ask.sessionId, callerId, ask.taskId);
|
|
145591
|
+
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.` };
|
|
145592
|
+
tasks.withdraw(callerId, ask.sessionId, ask.taskId);
|
|
145593
|
+
if (r.stopped) return { ok: false, error: `The call was cancelled, so ${where2} was stopped.` };
|
|
145594
|
+
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).` };
|
|
145595
|
+
}
|
|
144900
145596
|
/** Waits for a delegation up to the bound (`awaitTurn`), and turns its outcome into what the caller reads */
|
|
144901
145597
|
async awaitDelegation(key2, d2, signal) {
|
|
144902
145598
|
const sessionName = () => this.host.meta.get(d2.sessionId)?.name ?? d2.sessionId;
|
|
@@ -145341,6 +146037,9 @@ var HostCards = class {
|
|
|
145341
146037
|
}
|
|
145342
146038
|
};
|
|
145343
146039
|
|
|
146040
|
+
// packages/agent-host/src/sessions/session-record.ts
|
|
146041
|
+
import { sep as sep12 } from "node:path";
|
|
146042
|
+
|
|
145344
146043
|
// packages/agent-host/src/dev-services/message-image.ts
|
|
145345
146044
|
import { constants as constants8 } from "node:fs";
|
|
145346
146045
|
import { open as open5, realpath as realpath11 } from "node:fs/promises";
|
|
@@ -145358,12 +146057,23 @@ function sniffImage2(b2) {
|
|
|
145358
146057
|
return null;
|
|
145359
146058
|
}
|
|
145360
146059
|
function writtenForms(written) {
|
|
145361
|
-
|
|
146060
|
+
const forms = /* @__PURE__ */ new Set([written]);
|
|
145362
146061
|
try {
|
|
145363
|
-
|
|
146062
|
+
forms.add(encodeURI(written));
|
|
145364
146063
|
} catch {
|
|
145365
146064
|
}
|
|
145366
|
-
|
|
146065
|
+
if (/^file:/i.test(written)) {
|
|
146066
|
+
try {
|
|
146067
|
+
forms.add(decodeURI(written));
|
|
146068
|
+
} catch {
|
|
146069
|
+
}
|
|
146070
|
+
}
|
|
146071
|
+
for (const form of [...forms]) {
|
|
146072
|
+
if (form.includes("(") || form.includes(")")) {
|
|
146073
|
+
forms.add(form.replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
|
146074
|
+
}
|
|
146075
|
+
}
|
|
146076
|
+
return [...forms];
|
|
145367
146077
|
}
|
|
145368
146078
|
var BEFORE = /[\s(<"'`]/;
|
|
145369
146079
|
var AFTER2 = /[\s)>"'`]/;
|
|
@@ -145441,6 +146151,44 @@ async function readMessageImage(abs, max = IMAGE_PREVIEW_MAX_BYTES) {
|
|
|
145441
146151
|
await handle2.close();
|
|
145442
146152
|
}
|
|
145443
146153
|
}
|
|
146154
|
+
function stripFileLocation(written) {
|
|
146155
|
+
if (/^file:/i.test(written)) {
|
|
146156
|
+
const hashAt = written.indexOf("#");
|
|
146157
|
+
const base2 = hashAt >= 0 ? written.slice(0, hashAt) : written;
|
|
146158
|
+
const stripped2 = base2.replace(/:\d+(?::\d+)?$/, "");
|
|
146159
|
+
if (!stripped2 || stripped2 === base2 || /^file:\/\/(?:\/|localhost\/)[A-Za-z]:?$/i.test(stripped2)) return null;
|
|
146160
|
+
return stripped2;
|
|
146161
|
+
}
|
|
146162
|
+
if (/^[A-Za-z]:\d+(?::\d+)?$/.test(written)) return null;
|
|
146163
|
+
const stripped = written.replace(/(?:#L\d+(?:C\d+)?(?:-L?\d+(?:C\d+)?)?|:\d+(?::\d+)?)$/i, "");
|
|
146164
|
+
if (!stripped || stripped === written || /^[A-Za-z]:$/.test(stripped) || stripped === "~") return null;
|
|
146165
|
+
return stripped;
|
|
146166
|
+
}
|
|
146167
|
+
async function resolveMessageFile(abs) {
|
|
146168
|
+
const windows3 = sep11 === "\\";
|
|
146169
|
+
if (windows3) {
|
|
146170
|
+
const walk2 = await walkLinks(abs);
|
|
146171
|
+
if (!walk2.ok && walk2.reason === "elsewhere") {
|
|
146172
|
+
return { ok: false, reason: "not_found", message: `${abs} leads to ${walk2.why}, which is not on this machine` };
|
|
146173
|
+
}
|
|
146174
|
+
if (!walk2.ok) return { ok: false, reason: "unreadable", message: `Centralu cannot check where ${abs} leads: ${walk2.why}` };
|
|
146175
|
+
}
|
|
146176
|
+
let file2;
|
|
146177
|
+
try {
|
|
146178
|
+
file2 = await realpath11(abs);
|
|
146179
|
+
} catch (e) {
|
|
146180
|
+
const code2 = errnoCode(e);
|
|
146181
|
+
if (code2 === "EACCES" || code2 === "EPERM") return { ok: false, reason: "unreadable", message: `Centralu may not inspect ${abs}` };
|
|
146182
|
+
return { ok: false, reason: "not_found", message: `There is no file or folder at ${abs}` };
|
|
146183
|
+
}
|
|
146184
|
+
if (windows3 && !DRIVE_PATH.test(file2)) {
|
|
146185
|
+
return { ok: false, reason: "not_found", message: `${abs} leads to ${file2}, which is not on this machine` };
|
|
146186
|
+
}
|
|
146187
|
+
if (file2 === "/" || /^[A-Za-z]:[\\/]?$/.test(file2)) {
|
|
146188
|
+
return { ok: false, reason: "unreadable", message: `${file2} is a root folder and cannot be revealed` };
|
|
146189
|
+
}
|
|
146190
|
+
return { ok: true, file: file2 };
|
|
146191
|
+
}
|
|
145444
146192
|
|
|
145445
146193
|
// packages/agent-host/src/dev-services/attachments.ts
|
|
145446
146194
|
import { lstat as lstat12, mkdir as mkdir8, readdir as readdir14, writeFile as writeFile6 } from "node:fs/promises";
|
|
@@ -145720,9 +146468,34 @@ var SessionRecord = class {
|
|
|
145720
146468
|
if (!this.repliesName(sessionId, written)) {
|
|
145721
146469
|
return { ok: false, reason: "not_mentioned", message: "No reply in this session names this path, so it is not read" };
|
|
145722
146470
|
}
|
|
145723
|
-
const
|
|
146471
|
+
const cwd = this.host.cwdFor(m);
|
|
146472
|
+
const abs = resolveWrittenPath(written, cwd);
|
|
146473
|
+
if (abs === null) return { ok: false, reason: "not_found", message: `${written} is not a path on this machine` };
|
|
146474
|
+
const first = await readMessageImage(abs);
|
|
146475
|
+
if (first.ok || !shouldRetryWithoutLocation(written, first.reason)) return first;
|
|
146476
|
+
const stripped = stripFileLocation(written);
|
|
146477
|
+
if (!stripped) return first;
|
|
146478
|
+
const fallbackAbs = resolveWrittenPath(stripped, cwd);
|
|
146479
|
+
return fallbackAbs === null ? first : readMessageImage(fallbackAbs);
|
|
146480
|
+
}
|
|
146481
|
+
/**
|
|
146482
|
+
* Resolves a local file or folder one of this session's replies linked (`messages.resolveFile`).
|
|
146483
|
+
* Checks `repliesName` before touching disk so unmentioned paths learn nothing about existence.
|
|
146484
|
+
*/
|
|
146485
|
+
async messageFile(sessionId, written) {
|
|
146486
|
+
const m = this.host.sessionOf(sessionId);
|
|
146487
|
+
if (!this.repliesName(sessionId, written)) {
|
|
146488
|
+
return { ok: false, reason: "not_mentioned", message: "No reply in this session names this path, so it is not opened" };
|
|
146489
|
+
}
|
|
146490
|
+
const cwd = this.host.cwdFor(m);
|
|
146491
|
+
const abs = resolveWrittenPath(written, cwd);
|
|
145724
146492
|
if (abs === null) return { ok: false, reason: "not_found", message: `${written} is not a path on this machine` };
|
|
145725
|
-
|
|
146493
|
+
const first = await resolveMessageFile(abs);
|
|
146494
|
+
if (first.ok || !shouldRetryWithoutLocation(written, first.reason)) return first;
|
|
146495
|
+
const stripped = stripFileLocation(written);
|
|
146496
|
+
if (!stripped) return first;
|
|
146497
|
+
const fallbackAbs = resolveWrittenPath(stripped, cwd);
|
|
146498
|
+
return fallbackAbs === null ? first : resolveMessageFile(fallbackAbs);
|
|
145726
146499
|
}
|
|
145727
146500
|
repliesName(sessionId, written) {
|
|
145728
146501
|
const open6 = this.streams.get(sessionId);
|
|
@@ -145772,6 +146545,10 @@ var SessionRecord = class {
|
|
|
145772
146545
|
);
|
|
145773
146546
|
}
|
|
145774
146547
|
};
|
|
146548
|
+
function shouldRetryWithoutLocation(written, reason) {
|
|
146549
|
+
if (reason === "not_found") return true;
|
|
146550
|
+
return sep12 === "\\" && reason === "unreadable" && /:\d+(?::\d+)?(?:#.*)?$/.test(written);
|
|
146551
|
+
}
|
|
145775
146552
|
|
|
145776
146553
|
// packages/agent-host/src/sessions/tool-queries.ts
|
|
145777
146554
|
var MODEL_LIST_READ_MS = 6e4;
|
|
@@ -147293,8 +148070,6 @@ var SessionManager = class {
|
|
|
147293
148070
|
void this.trash.sweepSessionFiles();
|
|
147294
148071
|
this.worktreeSweep = this.worktrees.sweepLeftoverWorktrees().catch((e) => console.error(`[worktree] the sweep of leftover worktrees stopped: ${e.message}`));
|
|
147295
148072
|
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
148073
|
for (const pid of new Set(
|
|
147299
148074
|
[...this.meta.values()].filter((s) => s.worktree && s.projectId).map((s) => s.projectId)
|
|
147300
148075
|
)) {
|
|
@@ -148303,9 +149078,11 @@ function mailReach(host) {
|
|
|
148303
149078
|
askGroupMembers: (address) => host.askGroupMembers(address),
|
|
148304
149079
|
projectOf: (address) => sessionOf(address)?.info?.projectId ?? null,
|
|
148305
149080
|
parentOf: (address) => {
|
|
148306
|
-
const
|
|
149081
|
+
const s = sessionOf(address);
|
|
148307
149082
|
const party = parseAddress(address);
|
|
148308
|
-
|
|
149083
|
+
if (!s?.info || party?.kind !== "session") return null;
|
|
149084
|
+
if (s.info.askedBy) return sessionAddress(party.host, s.info.askedBy);
|
|
149085
|
+
return s.info.host === "here" ? host.starterElsewhere?.(s.id) ?? null : null;
|
|
148309
149086
|
},
|
|
148310
149087
|
labelOf: (address, reader) => sessionOf(address)?.info?.name ?? shownId(address, reader),
|
|
148311
149088
|
shownId,
|
|
@@ -148435,6 +149212,200 @@ var HeldMail = class {
|
|
|
148435
149212
|
return rows3.length;
|
|
148436
149213
|
});
|
|
148437
149214
|
}
|
|
149215
|
+
/**
|
|
149216
|
+
* 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
|
|
149217
|
+
* 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
|
|
149218
|
+
* person to resend or dismiss. News and Centralu's own words go again, and their next frame says it may be a repeat
|
|
149219
|
+
*/
|
|
149220
|
+
reconcileInterrupted() {
|
|
149221
|
+
const byRecipient = /* @__PURE__ */ new Map();
|
|
149222
|
+
for (const r of this.d.records.interrupted()) byRecipient.set(r.recipient, [...byRecipient.get(r.recipient) ?? [], r.messageId]);
|
|
149223
|
+
return this.d.run(() => [...byRecipient].map(([recipient, ids]) => ({ recipient, ...this.settleUncertain(recipient, ids) })));
|
|
149224
|
+
}
|
|
149225
|
+
/** 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 */
|
|
149226
|
+
deliveryFailedLate(recipient, ids, deliveredAt) {
|
|
149227
|
+
return this.d.run(() => this.settleUncertain(recipient, this.d.records.undeliver(recipient, ids, deliveredAt)));
|
|
149228
|
+
}
|
|
149229
|
+
/**
|
|
149230
|
+
* 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
|
|
149231
|
+
* row an earlier build held `loop` (`HeldMail.resumeHeld`)
|
|
149232
|
+
*/
|
|
149233
|
+
resendHeld(recipient, ids) {
|
|
149234
|
+
return this.d.run(() => {
|
|
149235
|
+
const released = this.heldBy(recipient, ids, ["uncertain", "failed"]);
|
|
149236
|
+
const n = this.d.records.release(recipient, released, this.d.now());
|
|
149237
|
+
for (const id3 of released) {
|
|
149238
|
+
const m = this.d.records.message(id3);
|
|
149239
|
+
if (m) this.d.changed(m, [recipient, PERSON]);
|
|
149240
|
+
}
|
|
149241
|
+
return n;
|
|
149242
|
+
});
|
|
149243
|
+
}
|
|
149244
|
+
/** The delivery held these rows for the person (the one hold): written, and the Inbox is told */
|
|
149245
|
+
hold(recipient, held3) {
|
|
149246
|
+
if (held3.length === 0) return;
|
|
149247
|
+
this.d.run(() => {
|
|
149248
|
+
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);
|
|
149249
|
+
for (const h of held3) {
|
|
149250
|
+
const m = this.d.records.message(h.messageId);
|
|
149251
|
+
if (m) this.d.changed(m, [PERSON]);
|
|
149252
|
+
}
|
|
149253
|
+
});
|
|
149254
|
+
}
|
|
149255
|
+
/**
|
|
149256
|
+
* The person says never: held mail is left undelivered, and not held against anyone. `uncertain` and `failed` by default; the person's window may
|
|
149257
|
+
* dismiss any hold it shows, and a dismissed answer leaves the question it answers open (D8)
|
|
149258
|
+
*/
|
|
149259
|
+
dismissHeld(recipient, ids, why2 = ["uncertain", "failed"]) {
|
|
149260
|
+
return this.d.run(() => {
|
|
149261
|
+
const dismissed = this.heldBy(recipient, ids, why2);
|
|
149262
|
+
for (const id3 of dismissed) this.d.records.answerDropped(id3);
|
|
149263
|
+
const n = this.d.records.dismiss(recipient, dismissed);
|
|
149264
|
+
for (const id3 of dismissed) this.d.records.settle(id3, recipient, "withdrawn", this.d.now());
|
|
149265
|
+
for (const id3 of dismissed) {
|
|
149266
|
+
const m = this.d.records.message(id3);
|
|
149267
|
+
if (m) this.d.changed(m, [PERSON]);
|
|
149268
|
+
}
|
|
149269
|
+
return n;
|
|
149270
|
+
});
|
|
149271
|
+
}
|
|
149272
|
+
/** 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 */
|
|
149273
|
+
settleUncertain(recipient, ids) {
|
|
149274
|
+
const messages2 = ids.flatMap((id3) => this.d.records.message(id3) ?? []);
|
|
149275
|
+
const again = messages2.filter((m) => m.kind === "notice" || m.sender === CENTRALU).map((m) => m.id);
|
|
149276
|
+
const unsure = messages2.filter((m) => !again.includes(m.id)).map((m) => m.id);
|
|
149277
|
+
if (again.length > 0) this.d.records.markMaybeRepeated(recipient, again, this.d.now());
|
|
149278
|
+
if (unsure.length > 0) this.d.records.markUncertain(recipient, unsure);
|
|
149279
|
+
for (const m of messages2) this.d.changed(m, again.includes(m.id) ? [recipient, PERSON] : [PERSON]);
|
|
149280
|
+
return { resent: again.length, held: unsure.length };
|
|
149281
|
+
}
|
|
149282
|
+
/** The ids of those of `ids` that `recipient`'s rows hold for one of `why` */
|
|
149283
|
+
heldBy(recipient, ids, why2) {
|
|
149284
|
+
return ids.filter((id3) => why2.includes(this.d.records.recipient(id3, recipient)?.held ?? ""));
|
|
149285
|
+
}
|
|
149286
|
+
};
|
|
149287
|
+
|
|
149288
|
+
// packages/agent-host/src/mail/handoff.ts
|
|
149289
|
+
var Handoffs = class {
|
|
149290
|
+
constructor(d2) {
|
|
149291
|
+
this.d = d2;
|
|
149292
|
+
}
|
|
149293
|
+
d;
|
|
149294
|
+
/** Tasks across a link a handoff re-pointed, for `takeMoves` */
|
|
149295
|
+
queuedMoves = [];
|
|
149296
|
+
/**
|
|
149297
|
+
* 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
|
|
149298
|
+
* move (`children`) become `to`'s; the successor is told of each message. Called inside the children's move
|
|
149299
|
+
*/
|
|
149300
|
+
handOver(from, to, scope, children = scope === "all" ? [] : scope.senders) {
|
|
149301
|
+
return this.d.run(() => {
|
|
149302
|
+
const plan = this.handOverPreview(from, to, scope);
|
|
149303
|
+
const fresh = plan.filter((p) => this.d.records.recipient(p.messageId, to) === void 0);
|
|
149304
|
+
this.d.records.moveRows(from, to, scope);
|
|
149305
|
+
const across = [];
|
|
149306
|
+
for (const row of this.d.records.watchedFrom(from)) {
|
|
149307
|
+
const m = children.includes(row.recipient) ? this.d.records.message(row.messageId) : void 0;
|
|
149308
|
+
if (m?.kind !== "task") continue;
|
|
149309
|
+
if (this.d.across(row.recipient)) {
|
|
149310
|
+
this.d.records.repoint(m.id, to, this.d.reach.projectOf(to), { ...m.facts, handedOver: true });
|
|
149311
|
+
across.push(m.id);
|
|
149312
|
+
continue;
|
|
149313
|
+
}
|
|
149314
|
+
this.d.records.settle(m.id, row.recipient, "withdrawn", this.d.now());
|
|
149315
|
+
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 })]);
|
|
149316
|
+
if (row.releasedAt !== null && row.releasedWhy !== null) this.d.records.markReleased(again.id, row.recipient, row.releasedAt, row.releasedWhy);
|
|
149317
|
+
}
|
|
149318
|
+
const name = (address) => `\u201C${this.d.labelOf(address)}\u201D [${this.d.shownId(address)}]`;
|
|
149319
|
+
for (const child of children) {
|
|
149320
|
+
if (this.d.reach.parentOf(child) !== from) continue;
|
|
149321
|
+
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.`;
|
|
149322
|
+
this.d.notice(child, { body, facts: { quiet: true }, dedupeKey: `parent:${child}:${to}:${this.d.now()}` });
|
|
149323
|
+
}
|
|
149324
|
+
this.movedNotice(to, fresh.map((p) => p.messageId), this.foldReports(to, fresh.map((p) => p.messageId)));
|
|
149325
|
+
for (const child of children.filter((c) => this.d.across(c))) {
|
|
149326
|
+
const first = this.d.records.firstTask(child, "start_agent");
|
|
149327
|
+
if (first?.sender !== from || across.includes(first.id)) continue;
|
|
149328
|
+
this.d.records.repoint(first.id, to, this.d.reach.projectOf(to), { ...first.facts, handedOver: true });
|
|
149329
|
+
across.push(first.id);
|
|
149330
|
+
}
|
|
149331
|
+
for (const p of plan) if (this.d.across(this.d.records.message(p.messageId)?.sender ?? "")) across.push(p.messageId);
|
|
149332
|
+
if (across.length) this.queuedMoves.push({ from, to, ids: across });
|
|
149333
|
+
return plan;
|
|
149334
|
+
});
|
|
149335
|
+
}
|
|
149336
|
+
/**
|
|
149337
|
+
* 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
|
|
149338
|
+
* 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
|
|
149339
|
+
* `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`
|
|
149340
|
+
* (#2530), so the heir's reply answers one it may read. The caller checks that both are that hub's. Returns how many moved
|
|
149341
|
+
*/
|
|
149342
|
+
moveAcross(from, to, ids) {
|
|
149343
|
+
return this.d.run(() => {
|
|
149344
|
+
let moved = 0;
|
|
149345
|
+
for (const id3 of new Set(ids)) {
|
|
149346
|
+
const m = this.d.records.message(id3);
|
|
149347
|
+
if (m && m.sender !== from && parseAddress(m.sender)?.kind === "session" && !this.d.across(m.sender)) {
|
|
149348
|
+
moved += this.d.records.moveRows(from, to, "all", [id3]).length;
|
|
149349
|
+
continue;
|
|
149350
|
+
}
|
|
149351
|
+
if (!m || m.sender !== from || m.kind !== "task" && m.kind !== "message") continue;
|
|
149352
|
+
if (m.origin !== "start_agent" && !this.d.records.recipients(id3).some((r) => r.settled === null)) continue;
|
|
149353
|
+
this.d.records.repoint(id3, to, null, { ...m.facts, handedOver: true });
|
|
149354
|
+
moved++;
|
|
149355
|
+
}
|
|
149356
|
+
return moved;
|
|
149357
|
+
});
|
|
149358
|
+
}
|
|
149359
|
+
/** The handoffs that moved tasks across a link, for the links to tell the machines (`MailAcross.movedAcross`); taken once */
|
|
149360
|
+
takeMoves() {
|
|
149361
|
+
return this.queuedMoves.splice(0);
|
|
149362
|
+
}
|
|
149363
|
+
/** What `handOver` would move, read only: each message by id and the first line of its words, for the handoff note to quote */
|
|
149364
|
+
handOverPreview(from, to, scope = "all") {
|
|
149365
|
+
return this.d.records.movable(from, to, scope).flatMap((id3) => {
|
|
149366
|
+
const m = this.d.records.message(id3);
|
|
149367
|
+
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 } : {} }] : [];
|
|
149368
|
+
});
|
|
149369
|
+
}
|
|
149370
|
+
/** 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 */
|
|
149371
|
+
roleMoved(to) {
|
|
149372
|
+
return this.d.run(() => {
|
|
149373
|
+
const ids = this.d.records.moveRole(to);
|
|
149374
|
+
this.movedNotice(to, ids);
|
|
149375
|
+
return ids.length;
|
|
149376
|
+
});
|
|
149377
|
+
}
|
|
149378
|
+
/**
|
|
149379
|
+
* 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
|
|
149380
|
+
* 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
|
|
149381
|
+
* 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
|
|
149382
|
+
*/
|
|
149383
|
+
foldReports(to, ids) {
|
|
149384
|
+
const reports = ids.flatMap((id3) => {
|
|
149385
|
+
const m = this.d.records.message(id3);
|
|
149386
|
+
const session2 = m?.kind === "report" ? m.facts.about?.session : void 0;
|
|
149387
|
+
return m && session2 ? [{ m, session: session2 }] : [];
|
|
149388
|
+
});
|
|
149389
|
+
const newest = /* @__PURE__ */ new Map();
|
|
149390
|
+
for (const { m, session: session2 } of reports) {
|
|
149391
|
+
const kept = newest.get(session2);
|
|
149392
|
+
if (!kept || m.createdAt > kept.createdAt || m.createdAt === kept.createdAt && m.id > kept.id) newest.set(session2, m);
|
|
149393
|
+
}
|
|
149394
|
+
const folded = reports.filter(({ m, session: session2 }) => newest.get(session2) !== m).map(({ m }) => m.id);
|
|
149395
|
+
if (folded.length > 0) this.d.records.markRead(to, folded, this.d.now());
|
|
149396
|
+
return folded;
|
|
149397
|
+
}
|
|
149398
|
+
/** 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:`) */
|
|
149399
|
+
movedNotice(to, messageIds, folded = []) {
|
|
149400
|
+
if (messageIds.length === 0 || parseAddress(to)?.kind !== "session") return;
|
|
149401
|
+
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.`;
|
|
149402
|
+
this.d.centralu(to, {
|
|
149403
|
+
kind: "notice",
|
|
149404
|
+
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.`,
|
|
149405
|
+
facts: { quiet: true, handedOver: true },
|
|
149406
|
+
dedupeKey: `handover:${to}:${hash16(messageIds)}`
|
|
149407
|
+
});
|
|
149408
|
+
}
|
|
148438
149409
|
};
|
|
148439
149410
|
|
|
148440
149411
|
// packages/agent-host/src/mail/send-guards.ts
|
|
@@ -148572,25 +149543,24 @@ var StopNotices = class {
|
|
|
148572
149543
|
return (this.d.readsAs?.(sender, stopped) ?? null) !== null && this.alone(stopped, sender, { turnSeq });
|
|
148573
149544
|
}
|
|
148574
149545
|
/**
|
|
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.
|
|
149546
|
+
* 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
|
|
149547
|
+
* 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).
|
|
149548
|
+
* 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
|
|
149549
|
+
* 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
|
|
149550
|
+
* 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
|
|
149551
|
+
* 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.
|
|
149552
|
+
* 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:
|
|
149553
|
+
* `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
|
|
149554
|
+
* 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
149555
|
*/
|
|
148586
|
-
alone(session2, sender, { turnSeq, gaveIt } = {}) {
|
|
149556
|
+
alone(session2, sender, { turnSeq, gaveIt, starter: only } = {}) {
|
|
148587
149557
|
const [party, from] = [parseAddress(session2), parseAddress(sender)];
|
|
148588
149558
|
if (party?.kind !== "session" || from?.kind !== "session") return false;
|
|
148589
149559
|
const seq = turnSeq ?? this.d.records.nextTurnSeq(party.sessionId) - 1;
|
|
148590
149560
|
if (this.d.records.nextTurnSeq(party.sessionId) !== seq + 1) return false;
|
|
148591
149561
|
const turn = this.d.records.turn(party.sessionId, seq);
|
|
148592
149562
|
const starter = turn?.starterId == null ? void 0 : this.d.records.message(turn.starterId);
|
|
148593
|
-
if (!turn || starter?.sender !== sender) return false;
|
|
149563
|
+
if (!turn || starter?.sender !== sender || only !== void 0 && starter.id !== only) return false;
|
|
148594
149564
|
if (turn.startedBy !== "caller" && (turn.startedBy !== "mail" || gaveIt === "send" || gaveIt === "work" && starter.kind !== "task")) return false;
|
|
148595
149565
|
if (this.d.records.inTurn(session2, seq).some((r) => r.message.sender !== sender)) return false;
|
|
148596
149566
|
const given = this.d.turnInputs?.(party.sessionId);
|
|
@@ -148841,6 +149811,19 @@ var MessageService = class {
|
|
|
148841
149811
|
this.ulids = opts.ids ?? new UlidMaker();
|
|
148842
149812
|
this.stops = new StopNotices({ ...opts, records, reach, now: this.now, run: (fn2) => this.run(fn2), notice: (to, n) => this.centralu(to, n) });
|
|
148843
149813
|
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) });
|
|
149814
|
+
this.handoffs = new Handoffs({
|
|
149815
|
+
records,
|
|
149816
|
+
reach,
|
|
149817
|
+
now: this.now,
|
|
149818
|
+
run: (fn2) => this.run(fn2),
|
|
149819
|
+
put: (m, rows3) => this.put(m, rows3),
|
|
149820
|
+
row: (to, over) => this.row(to, over),
|
|
149821
|
+
notice: (to, n) => this.notice(to, n),
|
|
149822
|
+
centralu: (to, n) => this.centralu(to, n),
|
|
149823
|
+
labelOf: (a) => this.labelOf(a),
|
|
149824
|
+
shownId: (a) => this.shownId(a),
|
|
149825
|
+
across: (a) => this.across(a)
|
|
149826
|
+
});
|
|
148844
149827
|
}
|
|
148845
149828
|
records;
|
|
148846
149829
|
reach;
|
|
@@ -148849,13 +149832,13 @@ var MessageService = class {
|
|
|
148849
149832
|
ulids;
|
|
148850
149833
|
listeners = createListeners((e) => console.error(`[mail] a listener failed: ${errorMessage(e)}`));
|
|
148851
149834
|
queued = [];
|
|
148852
|
-
/** Tasks across a link a handoff re-pointed, for `takeMoves` */
|
|
148853
|
-
queuedMoves = [];
|
|
148854
149835
|
running = false;
|
|
148855
149836
|
/** Who hears that a session stopped or went (mailbox.md §10.6.1) */
|
|
148856
149837
|
stops;
|
|
148857
|
-
/**
|
|
149838
|
+
/** Mail held for the person: the delivery's holds and the person's acts on them, trusting or dismissing a project (§7.4) */
|
|
148858
149839
|
holds;
|
|
149840
|
+
/** 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 */
|
|
149841
|
+
handoffs;
|
|
148859
149842
|
sessionAddress(sessionId) {
|
|
148860
149843
|
return sessionAddress(this.opts.hostId, sessionId);
|
|
148861
149844
|
}
|
|
@@ -149220,7 +150203,7 @@ var MessageService = class {
|
|
|
149220
150203
|
return m?.kind === "message" && !isHidden(row) ? [m] : [];
|
|
149221
150204
|
}).map((m) => this.item(m, reader, turn));
|
|
149222
150205
|
const listed2 = new Set(needReply.map((i) => i.message.id));
|
|
149223
|
-
const
|
|
150206
|
+
const unread4 = this.records.unreadFor(reader).filter((p) => !listed2.has(p.message.id)).map((p) => this.item(p.message, reader, turn));
|
|
149224
150207
|
const waiting = this.records.watchedFrom(reader).flatMap((row) => {
|
|
149225
150208
|
const message = messageOf2(row);
|
|
149226
150209
|
return message?.kind === "message" && message.needsReply && row.held !== LINK_HOLD ? [{ row, message }] : [];
|
|
@@ -149232,7 +150215,7 @@ var MessageService = class {
|
|
|
149232
150215
|
}),
|
|
149233
150216
|
...this.records.heldForLink(reader).map((p) => ({ ...p, why: LINK_HOLD }))
|
|
149234
150217
|
];
|
|
149235
|
-
return { needReply, unread:
|
|
150218
|
+
return { needReply, unread: unread4, waiting, held: held3 };
|
|
149236
150219
|
}
|
|
149237
150220
|
/**
|
|
149238
150221
|
* 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 +150304,10 @@ var MessageService = class {
|
|
|
149321
150304
|
asker: turnStarts && toAssistant ? picked : null
|
|
149322
150305
|
};
|
|
149323
150306
|
}
|
|
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
150307
|
/** Something the Inbox shows changed that is no message (the question about sleeping sessions): the listeners hear an empty change for the person */
|
|
149365
150308
|
announce(rootId = "") {
|
|
149366
150309
|
this.listeners.emit({ messageId: "", rootId, recipients: [PERSON] });
|
|
149367
150310
|
}
|
|
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
150311
|
// ── The Assistant's requests (§7.6) ──
|
|
149386
150312
|
/** The Assistant's turn on `asker`'s requests ended (§7.6): the requests that turn carried are settled `reported`. Returns how many */
|
|
149387
150313
|
requestTurnEnded(assistant, asker, turnSeq) {
|
|
@@ -149416,77 +150342,7 @@ var MessageService = class {
|
|
|
149416
150342
|
const asker = this.isRequest(m, assistant) ? m.sender : m.kind === "notice" && m.sender === CENTRALU ? m.facts.asker : void 0;
|
|
149417
150343
|
return asker !== void 0 && parseAddress(asker)?.kind === "session" ? asker : void 0;
|
|
149418
150344
|
}
|
|
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
|
-
}
|
|
150345
|
+
// ── Upkeep ──
|
|
149490
150346
|
sweep() {
|
|
149491
150347
|
return this.records.sweep(this.now());
|
|
149492
150348
|
}
|
|
@@ -149603,37 +150459,6 @@ var MessageService = class {
|
|
|
149603
150459
|
dedupeKey: `answer_held:${question.sender}:${answer.id}:policy`
|
|
149604
150460
|
});
|
|
149605
150461
|
}
|
|
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
150462
|
/** 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
150463
|
reminderSettled(m, recipient) {
|
|
149639
150464
|
return m.kind === "notice" && m.facts.reminder !== void 0 && (m.facts.of ?? []).every((id3) => {
|
|
@@ -149647,20 +150472,6 @@ var MessageService = class {
|
|
|
149647
150472
|
const cause2 = task?.causeId ? this.records.message(task.causeId) : void 0;
|
|
149648
150473
|
return cause2?.kind === "task" && this.records.recipient(cause2.id, recipient)?.settled === null ? cause2.id : void 0;
|
|
149649
150474
|
}
|
|
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
150475
|
// ── What the reader sees ──
|
|
149665
150476
|
/** Centralu's word for how the sender stands to the receiver (§8.3). Never a name another party wrote */
|
|
149666
150477
|
relation(recipient, m) {
|
|
@@ -149987,7 +150798,7 @@ var MailPerson = class {
|
|
|
149987
150798
|
if (!stored || !now) return;
|
|
149988
150799
|
const at2 = this.records.recipient(stored.id, t.address)?.deliveredAt;
|
|
149989
150800
|
this.host.tell(sessionId, text3).catch(() => {
|
|
149990
|
-
if (at2 != null) this.service.deliveryFailedLate(t.address, [stored.id], at2);
|
|
150801
|
+
if (at2 != null) this.service.holds.deliveryFailedLate(t.address, [stored.id], at2);
|
|
149991
150802
|
});
|
|
149992
150803
|
}
|
|
149993
150804
|
/**
|
|
@@ -149995,14 +150806,14 @@ var MailPerson = class {
|
|
|
149995
150806
|
* 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
150807
|
*/
|
|
149997
150808
|
held(action, recipient, messageIds) {
|
|
149998
|
-
if (action === "dismiss") return { changed: this.service.dismissHeld(recipient, messageIds, PERSON_HOLDS) };
|
|
150809
|
+
if (action === "dismiss") return { changed: this.service.holds.dismissHeld(recipient, messageIds, PERSON_HOLDS) };
|
|
149999
150810
|
const projects = new Set(messageIds.flatMap((id3) => this.records.recipient(id3, recipient)?.held === "policy" ? this.records.message(id3)?.senderProject ?? [] : []));
|
|
150000
150811
|
const still = [...projects].find((p) => this.host.untrusted(p));
|
|
150001
150812
|
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
150813
|
const policy = messageIds.filter((id3) => this.records.recipient(id3, recipient)?.held === "policy");
|
|
150003
150814
|
for (const p of projects) this.trusted(p);
|
|
150004
150815
|
const letGo = policy.filter((id3) => this.records.recipient(id3, recipient)?.held !== "policy").length;
|
|
150005
|
-
return { changed: letGo + this.service.resendHeld(recipient, messageIds) };
|
|
150816
|
+
return { changed: letGo + this.service.holds.resendHeld(recipient, messageIds) };
|
|
150006
150817
|
}
|
|
150007
150818
|
/**
|
|
150008
150819
|
* 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 +151330,7 @@ var Watches = class {
|
|
|
150519
151330
|
this.changed(address, "gone");
|
|
150520
151331
|
}
|
|
150521
151332
|
/**
|
|
150522
|
-
* A handoff moves `from`'s mailbox to `to` (`moveMail`: `
|
|
151333
|
+
* A handoff moves `from`'s mailbox to `to` (`moveMail`: `Handoffs.handOver`, scope `all`), in one transaction with this: its active watches
|
|
150523
151334
|
* 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
151335
|
* 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
151336
|
*/
|
|
@@ -150765,6 +151576,9 @@ var HELD_WHY = {
|
|
|
150765
151576
|
policy: (m) => `waits until the person trusts ${m.senderProject ?? "your project"}`,
|
|
150766
151577
|
[LINK_HOLD]: (m, calls) => `${heldLine("its computer")} Once the link is back, ${sendOrDrop(calls, m.id)}`
|
|
150767
151578
|
};
|
|
151579
|
+
function quietLine(name) {
|
|
151580
|
+
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.`;
|
|
151581
|
+
}
|
|
150768
151582
|
var MailTool = class {
|
|
150769
151583
|
constructor(service, records, reach, host) {
|
|
150770
151584
|
this.service = service;
|
|
@@ -150836,7 +151650,7 @@ var MailTool = class {
|
|
|
150836
151650
|
if (!r.ok) return { text: `Refused (${r.why}): ${r.text}`, isError: true };
|
|
150837
151651
|
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
151652
|
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 })];
|
|
151653
|
+
const lines = [head, ...far.replyTo ? [`It answers ${far.replyTo}.`] : [], ...r.quiet ? [quietLine(r.to)] : waitLine({ needsReply, answers: far.replyTo !== void 0, clarifies })];
|
|
150840
151654
|
return { text: lines.join(" ") };
|
|
150841
151655
|
} catch (e) {
|
|
150842
151656
|
return failed4(e);
|
|
@@ -151018,7 +151832,7 @@ var MailTool = class {
|
|
|
151018
151832
|
lines.push(`It answers ${answered.id} from ${this.reach.labelOf(answered.sender)}${withdrawn ? ` (${isPerson(answered.sender) ? "the person" : "its sender"} withdrew it)` : ""}.`);
|
|
151019
151833
|
}
|
|
151020
151834
|
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(
|
|
151835
|
+
else if (r.quiet) lines.push(quietLine(name));
|
|
151022
151836
|
else if (m.kind === "message") lines.push(...waitLine({ needsReply: m.needsReply, answers: answered !== void 0, clarifies: typeof m.facts.clarifies === "string" }));
|
|
151023
151837
|
if (r.held.length > 0) lines.push(this.heldLine(m.senderProject));
|
|
151024
151838
|
return lines.join(" ");
|
|
@@ -151228,19 +152042,21 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151228
152042
|
};
|
|
151229
152043
|
}
|
|
151230
152044
|
/**
|
|
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
|
|
152045
|
+
* On a hub: a handoff moved tasks it gave linked machines' sessions to another session here (`Handoffs.handOver`, #1948 step 6). Each machine is
|
|
152046
|
+
* 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
|
|
152047
|
+
* machine's session sent that moved goes to that machine (#2530), which gives its row to the heir
|
|
151233
152048
|
*/
|
|
151234
152049
|
async movedAcross(moves) {
|
|
151235
152050
|
for (const move of moves) {
|
|
151236
152051
|
const byMachine = /* @__PURE__ */ new Map();
|
|
151237
152052
|
for (const id3 of move.ids) {
|
|
151238
|
-
|
|
151239
|
-
|
|
151240
|
-
|
|
152053
|
+
const parties = [...this.d.records.recipients(id3).map((row) => row.recipient), this.d.records.message(id3)?.sender ?? ""];
|
|
152054
|
+
for (const party of parties) {
|
|
152055
|
+
const r = this.route(party);
|
|
152056
|
+
if (r?.kind === "machine") byMachine.set(r.machineId, (byMachine.get(r.machineId) ?? /* @__PURE__ */ new Set()).add(id3));
|
|
151241
152057
|
}
|
|
151242
152058
|
}
|
|
151243
|
-
for (const [machineId, ids] of byMachine) await this.tellMove(machineId, { from: move.from, to: move.to, ids });
|
|
152059
|
+
for (const [machineId, ids] of byMachine) await this.tellMove(machineId, { from: move.from, to: move.to, ids: [...ids] });
|
|
151244
152060
|
}
|
|
151245
152061
|
}
|
|
151246
152062
|
/**
|
|
@@ -151253,13 +152069,13 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151253
152069
|
const part = { ...params, ids: params.ids.slice(i, i + MOVE_IDS_PER_CALL) };
|
|
151254
152070
|
const r = m?.reachable ? await m.call("host.mailMove", part).then(() => null, (e) => errorMessage(e)) : "not reachable";
|
|
151255
152071
|
if (!r) continue;
|
|
151256
|
-
this.d.log?.(`[mail] ${m?.name ?? machineId} could not be told that ${part.ids.length}
|
|
152072
|
+
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
152073
|
if (!older(r)) this.untoldMoves.set(machineId, [...this.untoldMoves.get(machineId) ?? [], part]);
|
|
151258
152074
|
}
|
|
151259
152075
|
}
|
|
151260
152076
|
/**
|
|
151261
152077
|
* 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
|
|
152078
|
+
* 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
152079
|
*/
|
|
151264
152080
|
moveFromHub(hub, p) {
|
|
151265
152081
|
const [from, to] = [this.fromHubNames(hub.id, p.from), this.fromHubNames(hub.id, p.to)];
|
|
@@ -151271,8 +152087,8 @@ var AcrossReceipts = class extends AcrossCore {
|
|
|
151271
152087
|
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
152088
|
return { ok: false, why: "not_allowed", text: `${hub.name} may move only work its own sessions gave here.` };
|
|
151273
152089
|
}
|
|
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}
|
|
152090
|
+
const moved = this.d.service.handoffs.moveAcross(from, to, p.ids);
|
|
152091
|
+
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
152092
|
return { ok: true, moved };
|
|
151277
152093
|
}
|
|
151278
152094
|
// ── Receipts ──
|
|
@@ -151912,14 +152728,15 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
151912
152728
|
const address = to && this.route(to) && this.foreign(to) ? to : null;
|
|
151913
152729
|
if (address) {
|
|
151914
152730
|
this.names.set(address, `${r.to} on ${computer}`);
|
|
151915
|
-
if (this.d.records.message(r.messageId))
|
|
151916
|
-
|
|
151917
|
-
|
|
151918
|
-
|
|
151919
|
-
|
|
152731
|
+
if (!this.d.records.message(r.messageId)) {
|
|
152732
|
+
try {
|
|
152733
|
+
this.d.service.sentAcross(sender, { id: r.messageId, to: address, ...fields5 });
|
|
152734
|
+
} catch (e) {
|
|
152735
|
+
this.d.log?.(`[mail] the copy of ${r.messageId}, which ${computer} took, could not be kept here: ${errorMessage(e)}`);
|
|
152736
|
+
}
|
|
151920
152737
|
}
|
|
151921
152738
|
}
|
|
151922
|
-
return { ok: true, messageId: r.messageId, to: r.to, address: address ?? "", computer };
|
|
152739
|
+
return { ok: true, messageId: r.messageId, to: r.to, address: address ?? "", computer, ...r.quiet ? { quiet: true } : {} };
|
|
151923
152740
|
}
|
|
151924
152741
|
// ── Taking from the other side ──
|
|
151925
152742
|
/**
|
|
@@ -151948,7 +152765,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
151948
152765
|
const m = this.peers?.machine?.(route.machineId);
|
|
151949
152766
|
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
152767
|
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;
|
|
152768
|
+
return r.ok ? { ok: true, messageId: r.messageId, to: `${r.to} on ${m.name}`, address: to, ...r.quiet ? { quiet: true } : {} } : r;
|
|
151952
152769
|
}
|
|
151953
152770
|
return this.write(sender, to, p);
|
|
151954
152771
|
}
|
|
@@ -152021,7 +152838,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
152021
152838
|
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
152839
|
const had = this.d.records.message(p.id);
|
|
152023
152840
|
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 };
|
|
152841
|
+
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
152842
|
return { ok: false, why: "bad_value", text: `${oneLineText(p.id, 200)} is the id of another message on ${this.selfName()}.` };
|
|
152026
152843
|
}
|
|
152027
152844
|
}
|
|
@@ -152035,7 +152852,7 @@ var MailAcross = class extends AcrossReceipts {
|
|
|
152035
152852
|
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
152853
|
}
|
|
152037
152854
|
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 };
|
|
152855
|
+
return { ok: true, messageId: sent.message.id, to: this.label(to), address: to, ...sent.quiet ? { quiet: true } : {} };
|
|
152039
152856
|
} catch (e) {
|
|
152040
152857
|
const why2 = refusalReason(e);
|
|
152041
152858
|
const lost = why2 === "unknown_message" && p.replyTo !== void 0 && !this.d.records.message(p.replyTo);
|
|
@@ -152512,6 +153329,16 @@ function hostMail(store2, sessions, opts) {
|
|
|
152512
153329
|
},
|
|
152513
153330
|
// A session of a hub this host is linked to (#2067 item 2), by the name it was last heard by
|
|
152514
153331
|
foreign: (address) => far.across?.foreignName(address),
|
|
153332
|
+
/*
|
|
153333
|
+
* 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
|
|
153334
|
+
* there moves it (`host.mailMove`). Read as its parent, its replies wake the session as a parent's do (`quietAnswer`)
|
|
153335
|
+
*/
|
|
153336
|
+
starterElsewhere: (id3) => {
|
|
153337
|
+
if (!sessions.sessionInfo(id3)?.startedFromHub) return null;
|
|
153338
|
+
const sender = store2.mailbox.firstTask(addressOf(id3), "start_agent")?.sender;
|
|
153339
|
+
const party = sender ? parseAddress(sender) : null;
|
|
153340
|
+
return sender && party?.kind === "session" && party.host !== hostId ? sender : null;
|
|
153341
|
+
},
|
|
152515
153342
|
hubPerson: (hostId2) => far.across?.isHub(hostId2) === true,
|
|
152516
153343
|
shown: (address, reader) => refs.shown(address, reader),
|
|
152517
153344
|
assistantId: () => sessions.assistantId(),
|
|
@@ -152704,13 +153531,13 @@ function hostMail(store2, sessions, opts) {
|
|
|
152704
153531
|
},
|
|
152705
153532
|
handOver: (from, to, which, children) => {
|
|
152706
153533
|
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());
|
|
153534
|
+
const moved = service.handoffs.handOver(addressOf(from), addressOf(to), which === "all" ? "all" : { senders: which.senders.map(addressOf) }, children.map(addressOf));
|
|
153535
|
+
void across.movedAcross(service.handoffs.takeMoves());
|
|
152709
153536
|
return moved;
|
|
152710
153537
|
};
|
|
152711
153538
|
return aboutSessions(which === "all" ? watches.handOver(addressOf(from), addressOf(to), moveMail) : moveMail());
|
|
152712
153539
|
},
|
|
152713
|
-
handOverPreview: (from, to) => aboutSessions(service.handOverPreview(addressOf(from), addressOf(to))),
|
|
153540
|
+
handOverPreview: (from, to) => aboutSessions(service.handoffs.handOverPreview(addressOf(from), addressOf(to))),
|
|
152714
153541
|
openWork: (id3) => openWork(service, store2, addressOf(id3)),
|
|
152715
153542
|
sessionChanged: (id3) => delivery.poke(id3),
|
|
152716
153543
|
notice: (id3, body, dedupeKey) => {
|
|
@@ -152777,11 +153604,18 @@ function hostMail(store2, sessions, opts) {
|
|
|
152777
153604
|
turn: (id3) => store2.mailbox.nextTurnSeq(id3) - 1,
|
|
152778
153605
|
ended: (id3) => withdrawEndedCards(store2.mailbox, addressOf(id3), cardStands)
|
|
152779
153606
|
},
|
|
153607
|
+
// A giver on another computer is named by its address. Read before the withdrawal, which the turn's own record does not depend on
|
|
153608
|
+
cancelGiven: (id3, giver, taskId) => {
|
|
153609
|
+
const from = parseAddress(giver) ? giver : addressOf(giver);
|
|
153610
|
+
const alone = service.stops.alone(addressOf(id3), from, { gaveIt: "work", starter: taskId });
|
|
153611
|
+
if (store2.mailbox.message(taskId)?.sender === from) service.done(from, taskId);
|
|
153612
|
+
return alone;
|
|
153613
|
+
},
|
|
152780
153614
|
turnInputs: (id3, turn) => delivery.turnInputs(addressOf(id3), turn),
|
|
152781
153615
|
turnStarted: turnRecorder(service, store2.mailbox, mailTurns),
|
|
152782
153616
|
refusesDelegation: (callerId, target, call2) => refusesDelegation(service, reach, callerId, target, call2),
|
|
152783
153617
|
roleMoved: (to) => {
|
|
152784
|
-
if (service.roleMoved(addressOf(to)) > 0) delivery.poke(to);
|
|
153618
|
+
if (service.handoffs.roleMoved(addressOf(to)) > 0) delivery.poke(to);
|
|
152785
153619
|
}
|
|
152786
153620
|
};
|
|
152787
153621
|
return {
|
|
@@ -153730,7 +154564,7 @@ function pickStrays(rows3, cwdOf, roots, selfPid, marks, mark) {
|
|
|
153730
154564
|
}
|
|
153731
154565
|
var LIST_TIMEOUT_MS = 12e3;
|
|
153732
154566
|
var exec = (file2, args, opts) => execText(file2, args, opts);
|
|
153733
|
-
function
|
|
154567
|
+
function unread3(what, e) {
|
|
153734
154568
|
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
154569
|
}
|
|
153736
154570
|
async function psRows(run2) {
|
|
@@ -153738,7 +154572,7 @@ async function psRows(run2) {
|
|
|
153738
154572
|
const { stdout } = await run2("ps", ["-U", userInfo2().username, "-o", "pid=,ppid=,tty=,command="], { maxBuffer: 8 * 1024 * 1024, timeoutMs: LIST_TIMEOUT_MS });
|
|
153739
154573
|
return parsePsRows(stdout);
|
|
153740
154574
|
} catch (e) {
|
|
153741
|
-
|
|
154575
|
+
unread3("the process list", e);
|
|
153742
154576
|
return [];
|
|
153743
154577
|
}
|
|
153744
154578
|
}
|
|
@@ -153749,7 +154583,7 @@ async function cwdsOf(run2, pids) {
|
|
|
153749
154583
|
return parseLsofCwd(stdout);
|
|
153750
154584
|
} catch (e) {
|
|
153751
154585
|
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"))
|
|
154586
|
+
if (isObj(e) && (e.ended !== void 0 || e.signal != null || typeof e.code === "string")) unread3("the working folders", e);
|
|
153753
154587
|
return partial2 ? parseLsofCwd(partial2) : /* @__PURE__ */ new Map();
|
|
153754
154588
|
}
|
|
153755
154589
|
}
|
|
@@ -153762,7 +154596,7 @@ async function ownerMarks(pids) {
|
|
|
153762
154596
|
try {
|
|
153763
154597
|
return await environmentValues(OWNER_MARK, pids);
|
|
153764
154598
|
} catch (e) {
|
|
153765
|
-
|
|
154599
|
+
unread3("the processes' owner marks", e);
|
|
153766
154600
|
return /* @__PURE__ */ new Map();
|
|
153767
154601
|
}
|
|
153768
154602
|
}
|
|
@@ -154052,7 +154886,7 @@ function createRpcHandler(mgr2, adapters2, { settleDeletedProjects, deleteOutloo
|
|
|
154052
154886
|
if (!r.ok) throw rpcError(r.error ?? "unknown skill");
|
|
154053
154887
|
return { ok: true };
|
|
154054
154888
|
};
|
|
154055
|
-
const scriptAuthor = (_call, ctx) => ctx?.rights === "limited" ? { credential: scriptLabel(ctx.label) } : void 0;
|
|
154889
|
+
const scriptAuthor = (_call, ctx) => ctx?.rights === "limited" && !ctx.trustedDev ? { credential: scriptLabel(ctx.label) } : void 0;
|
|
154056
154890
|
const builderDeps = (call2, ctx) => {
|
|
154057
154891
|
const fromScript = scriptAuthor(call2, ctx);
|
|
154058
154892
|
return { apps: requireExternalApps(), views: views2, builderOf: (ref) => mgr2.appSessions.builderOf(ref), send: (id3, t, a) => mgr2.inputs.send(id3, t, a, void 0, false, fromScript), byScript: fromScript !== void 0 };
|
|
@@ -154447,6 +155281,9 @@ function createRpcHandler(mgr2, adapters2, { settleDeletedProjects, deleteOutloo
|
|
|
154447
155281
|
"messages.image": async ({ sessionId, path: path2 }) => {
|
|
154448
155282
|
return mgr2.record.messageImage(sessionId, path2);
|
|
154449
155283
|
},
|
|
155284
|
+
"messages.resolveFile": async ({ sessionId, path: path2 }) => {
|
|
155285
|
+
return mgr2.record.messageFile(sessionId, path2);
|
|
155286
|
+
},
|
|
154450
155287
|
"messages.subagent": async ({ sessionId, parentCallId, afterSeq, limit }) => {
|
|
154451
155288
|
return mgr2.record.loadSubagentMessages(sessionId, parentCallId, afterSeq, limit);
|
|
154452
155289
|
},
|
|
@@ -154610,6 +155447,11 @@ function createRpcHandler(mgr2, adapters2, { settleDeletedProjects, deleteOutloo
|
|
|
154610
155447
|
if (!hub) throw rpcError("Only a hub that offered on this connection answers the cards of work it gave here");
|
|
154611
155448
|
return mgr2.linkedHost.hubAnswer(p.sessionId, sessionAddress(hub.id, p.caller), p.card, p.text);
|
|
154612
155449
|
},
|
|
155450
|
+
"host.stopTask": async (p, ctx) => {
|
|
155451
|
+
const hub = ctx ? hubs2?.on?.(ctx.client) : void 0;
|
|
155452
|
+
if (!hub) throw rpcError("Only a hub that offered on this connection stops the work it gave here");
|
|
155453
|
+
return mgr2.linkedHost.hubStopTask(p.sessionId, sessionAddress(hub.id, p.caller), p.task);
|
|
155454
|
+
},
|
|
154613
155455
|
"host.apps": async (p, ctx) => {
|
|
154614
155456
|
const { hub, calls } = appsHub(ctx);
|
|
154615
155457
|
return { apps: await calls.list(hub, p.session, p.start) };
|
|
@@ -154685,7 +155527,8 @@ function createRpcHandler(mgr2, adapters2, { settleDeletedProjects, deleteOutloo
|
|
|
154685
155527
|
return {};
|
|
154686
155528
|
},
|
|
154687
155529
|
"host.handover": async ({ handover: h }) => ack(handover2?.(h)),
|
|
154688
|
-
"host.systemEnding": async ({ cancelled: cancelled2 }) => ack(systemEnding2?.(cancelled2 === true))
|
|
155530
|
+
"host.systemEnding": async ({ cancelled: cancelled2 }) => ack(systemEnding2?.(cancelled2 === true)),
|
|
155531
|
+
"host.trustDevTab": async (_p2) => ({ ok: true })
|
|
154689
155532
|
};
|
|
154690
155533
|
const routes = { ...raw, ...handlers };
|
|
154691
155534
|
return async (method, params, ctx) => {
|
|
@@ -156013,10 +156856,6 @@ var AgentVersionService = class {
|
|
|
156013
156856
|
readAutoApply: () => true,
|
|
156014
156857
|
writeAutoApply: () => {
|
|
156015
156858
|
},
|
|
156016
|
-
readSeen: () => ({}),
|
|
156017
|
-
writeSeen: () => {
|
|
156018
|
-
},
|
|
156019
|
-
capabilityCheck: ({ tool, from, to }) => console.error(`[agent-versions] ${tool} ${from} -> ${to}; no capability check runs yet (#270)`),
|
|
156020
156859
|
now: Date.now,
|
|
156021
156860
|
quietMs: QUIET_MS,
|
|
156022
156861
|
...deps
|
|
@@ -156061,21 +156900,6 @@ var AgentVersionService = class {
|
|
|
156061
156900
|
const tools = this.deps.tools().filter((t) => t.installedVersion);
|
|
156062
156901
|
const read2 = await Promise.all(tools.map(async (t) => [t.tool, await t.installedVersion().catch(() => null)]));
|
|
156063
156902
|
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
156903
|
this.status = { ...this.status, installed, checkedAt: this.deps.now() };
|
|
156080
156904
|
this.deps.publish(this.current());
|
|
156081
156905
|
if (this.status.autoApply) for (const s of this.deps.sessions.listSessions()) this.lookSoon(s.id);
|
|
@@ -156466,6 +157290,8 @@ var HostRequests = class {
|
|
|
156466
157290
|
if (early) throw unanswered(method, early);
|
|
156467
157291
|
const p = fields3(params);
|
|
156468
157292
|
switch (method) {
|
|
157293
|
+
case "host.trustDevTab":
|
|
157294
|
+
return this.trustDevTab(params, from, signal);
|
|
156469
157295
|
case "trash.purge":
|
|
156470
157296
|
return this.viaTrash(method, from, signal, { action: "delete", sessionId: str5(p.sessionId), what: "session" }, () => ({ ok: true }));
|
|
156471
157297
|
case "trash.purgeSubagentSteps":
|
|
@@ -156476,6 +157302,21 @@ var HostRequests = class {
|
|
|
156476
157302
|
return this.generic(method, params, from, signal);
|
|
156477
157303
|
}
|
|
156478
157304
|
}
|
|
157305
|
+
/**
|
|
157306
|
+
* A local `dev:live` browser tab asking to attribute messages on its single open WebSocket as typed by the person
|
|
157307
|
+
* rather than as a script. The card displays the reported `Origin` header and the tab's 6-char pairing code — the code
|
|
157308
|
+
* match in the desktop window is the security boundary (local processes can spoof `Origin`). Never grants full/window rights.
|
|
157309
|
+
*/
|
|
157310
|
+
async trustDevTab(params, from, signal) {
|
|
157311
|
+
const runs = asItRuns("host.trustDevTab", params);
|
|
157312
|
+
if (!runs.ok) throw refused("not_done", `host.trustDevTab was not done: ${runs.why}.`);
|
|
157313
|
+
if (!from.origin) throw refused("not_done", "host.trustDevTab was not done: no dev browser origin was provided.");
|
|
157314
|
+
const code2 = str5(fields3(runs.params).code);
|
|
157315
|
+
const question = `Trust the dev browser tab at ${plainQuoted(from.origin, 120)} (code ${code2}) to send messages as you? Messages from this open tab (including to linked machines) will be recorded as typed by you rather than as a script until the tab reloads or disconnects. It stays on the limited credential: approvals, deletions, mail, and security settings still require the Centralu desktop window. Allow only if you clicked Trust this tab and see the same code there.`;
|
|
157316
|
+
const answer = await this.card("host.trustDevTab", question, from, signal);
|
|
157317
|
+
if (answer.decision !== "allow") throw unanswered("host.trustDevTab", answer.outcome);
|
|
157318
|
+
return { ok: true };
|
|
157319
|
+
}
|
|
156479
157320
|
/**
|
|
156480
157321
|
* Any other method's card (host-request-targets.ts): the call as its schema parses it is what the card shows and what runs,
|
|
156481
157322
|
* with what it acts on by name and what it loses. After Allow the names are read again, and a call whose target changed
|
|
@@ -156497,7 +157338,7 @@ var HostRequests = class {
|
|
|
156497
157338
|
if (!now.ok || now.text !== targets.text) {
|
|
156498
157339
|
throw refused("not_done", `${method} was not done: what its card named changed while it stood (${now.ok ? `now ${now.text}` : now.why}).`);
|
|
156499
157340
|
}
|
|
156500
|
-
return this.deps.rpc(method, runs.params, { client: -1, rights: "limited", label: from.client });
|
|
157341
|
+
return this.deps.rpc(method, runs.params, { client: -1, rights: "limited", label: from.client, ...from.trustedDev ? { trustedDev: true } : {} });
|
|
156501
157342
|
}
|
|
156502
157343
|
/** The requests waiting, oldest first */
|
|
156503
157344
|
list() {
|
|
@@ -157599,6 +158440,23 @@ function runSsh(opts) {
|
|
|
157599
158440
|
});
|
|
157600
158441
|
}
|
|
157601
158442
|
|
|
158443
|
+
// packages/agent-host/src/links/away.ts
|
|
158444
|
+
var SSH_FAILED = /^ssh could not reach .*?: /;
|
|
158445
|
+
var CONNECT_FAILED = "Operation timed out|Connection timed out|No route to host|Network is unreachable|Host is down";
|
|
158446
|
+
var NO_ANSWER2 = new RegExp(
|
|
158447
|
+
[
|
|
158448
|
+
`^(?:ssh: )?connect to host \\S+ port \\d+: (?:${CONNECT_FAILED})\\.?$`,
|
|
158449
|
+
"^(?:ssh: )?Could not resolve hostname \\S+: .+$",
|
|
158450
|
+
`^channel \\d+: open failed: connect failed: (?:${CONNECT_FAILED})\\.?$`,
|
|
158451
|
+
"^Connection to UNKNOWN port 65535 timed out$"
|
|
158452
|
+
].join("|"),
|
|
158453
|
+
"i"
|
|
158454
|
+
);
|
|
158455
|
+
function isNoAnswer(message) {
|
|
158456
|
+
const failed5 = SSH_FAILED.exec(message);
|
|
158457
|
+
return failed5 !== null && NO_ANSWER2.test(message.slice(failed5[0].length).trim());
|
|
158458
|
+
}
|
|
158459
|
+
|
|
157602
158460
|
// packages/agent-host/src/links/tunnel.ts
|
|
157603
158461
|
function parseConnectionLine(stdout, spec) {
|
|
157604
158462
|
const lines = stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
@@ -157940,7 +158798,7 @@ var SshTunnel = class {
|
|
|
157940
158798
|
const remote = this.opts.remote ?? { shell: "posix" };
|
|
157941
158799
|
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
158800
|
this.ifClosed();
|
|
157943
|
-
if (r.code === 255) throw new Error(
|
|
158801
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
157944
158802
|
if (r.stdout.includes(NOT_FOUND2)) throw notInstalled(this.where, remote);
|
|
157945
158803
|
let answer;
|
|
157946
158804
|
try {
|
|
@@ -158004,7 +158862,7 @@ var SshTunnel = class {
|
|
|
158004
158862
|
throw again;
|
|
158005
158863
|
}
|
|
158006
158864
|
}
|
|
158007
|
-
if (r.code === 255) throw new Error(
|
|
158865
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
158008
158866
|
return markers.length ? { ...r, stdout: r.stdout.split(/\r?\n/).filter((l) => !markers.includes(l.trim())).join("\n") } : r;
|
|
158009
158867
|
}
|
|
158010
158868
|
/** The connection line again until the link-bound host answers, or the forward that runs it ends */
|
|
@@ -158068,7 +158926,7 @@ var SshTunnel = class {
|
|
|
158068
158926
|
this.pairs = true;
|
|
158069
158927
|
return this.connectionLine();
|
|
158070
158928
|
}
|
|
158071
|
-
if (r.code === 255) throw new Error(
|
|
158929
|
+
if (r.code === 255) throw new Error(sshFailure(this.opts.target, r.stderr));
|
|
158072
158930
|
if (r.stdout.includes(NOT_FOUND2)) throw notInstalled(this.where, remote);
|
|
158073
158931
|
try {
|
|
158074
158932
|
const line = parseConnectionLine(r.stdout, remote);
|
|
@@ -158196,11 +159054,15 @@ function withoutClixml(s) {
|
|
|
158196
159054
|
parts.push(plainPart(text3));
|
|
158197
159055
|
return parts.join("").replace(ANSI2, "").split(/\r?\n/);
|
|
158198
159056
|
}
|
|
159057
|
+
var NAMES_AN_ERROR = new RegExp(`error|denied|refused|timed out|not found|cannot|could not|${CONNECT_FAILED}`, "i");
|
|
158199
159058
|
function lastLine(s, ansi = ansiText) {
|
|
158200
159059
|
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) =>
|
|
159060
|
+
const line = [...lines].reverse().find((l) => NAMES_AN_ERROR.test(l)) ?? lines.at(-1) ?? "";
|
|
158202
159061
|
return unescapeBytes(line, ansi);
|
|
158203
159062
|
}
|
|
159063
|
+
function sshFailure(target, stderr) {
|
|
159064
|
+
return `ssh could not reach ${target}: ${lastLine(stderr) || "no answer"}`;
|
|
159065
|
+
}
|
|
158204
159066
|
function unescapeBytes(line, ansi = ansiText) {
|
|
158205
159067
|
return line.replace(/(?:\\[23][0-7]{2})+/g, (run2) => {
|
|
158206
159068
|
const bytes2 = Buffer.from(run2.slice(1).split("\\").map((o) => parseInt(o, 8)));
|
|
@@ -158576,7 +159438,7 @@ function probeTarget(target, opts = {}) {
|
|
|
158576
159438
|
// packages/agent-host/src/links/ssh-config.ts
|
|
158577
159439
|
import { readdirSync as readdirSync18, readFileSync as readFileSync27, statSync as statSync18 } from "node:fs";
|
|
158578
159440
|
import { homedir as homedir17 } from "node:os";
|
|
158579
|
-
import { isAbsolute as isAbsolute10, join as join56, normalize, parse as parse5, sep as
|
|
159441
|
+
import { isAbsolute as isAbsolute10, join as join56, normalize, parse as parse5, sep as sep13 } from "node:path";
|
|
158580
159442
|
var MAX_DEPTH = 16;
|
|
158581
159443
|
function splitConfigLine(raw) {
|
|
158582
159444
|
const m = /^\s*([^\s=#]+)\s*(?:=\s*)?([\s\S]*)$/.exec(raw);
|
|
@@ -158637,7 +159499,7 @@ function expandGlob(path2) {
|
|
|
158637
159499
|
const norm = normalize(path2);
|
|
158638
159500
|
const root3 = parse5(norm).root;
|
|
158639
159501
|
let found = [root3 || "."];
|
|
158640
|
-
for (const seg of norm.slice(root3.length).split(
|
|
159502
|
+
for (const seg of norm.slice(root3.length).split(sep13)) {
|
|
158641
159503
|
if (seg === "") continue;
|
|
158642
159504
|
const next = [];
|
|
158643
159505
|
for (const base2 of found) {
|
|
@@ -158668,7 +159530,7 @@ function expandGlob(path2) {
|
|
|
158668
159530
|
});
|
|
158669
159531
|
}
|
|
158670
159532
|
function tildePath(path2, home) {
|
|
158671
|
-
return path2 === home ? "~" : path2.startsWith(home +
|
|
159533
|
+
return path2 === home ? "~" : path2.startsWith(home + sep13) ? `~${path2.slice(home.length)}` : path2;
|
|
158672
159534
|
}
|
|
158673
159535
|
function readSshConfig(opts) {
|
|
158674
159536
|
const hosts = [];
|
|
@@ -159258,23 +160120,6 @@ function channel(version2) {
|
|
|
159258
160120
|
return version2.slice(dash + 1).split(".")[0] ?? "stable";
|
|
159259
160121
|
}
|
|
159260
160122
|
|
|
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
160123
|
// packages/agent-host/src/links/update.ts
|
|
159279
160124
|
import { randomUUID as randomUUID29 } from "node:crypto";
|
|
159280
160125
|
function parseStopLine(stdout) {
|
|
@@ -160901,7 +161746,7 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
160901
161746
|
c.step(step, count);
|
|
160902
161747
|
this.deps.log?.(`[links] ${this.name}: ${why2}`);
|
|
160903
161748
|
};
|
|
160904
|
-
const
|
|
161749
|
+
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
161750
|
const busy = (a) => {
|
|
160906
161751
|
const turns = turnsRunning(a);
|
|
160907
161752
|
show("wait_idle", `the update waits for ${turns} ${turns === 1 ? "session" : "sessions"} in a turn`, turns);
|
|
@@ -160919,10 +161764,10 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
160919
161764
|
return null;
|
|
160920
161765
|
}
|
|
160921
161766
|
if (again.activity) busy(again.activity);
|
|
160922
|
-
else
|
|
161767
|
+
else unread4();
|
|
160923
161768
|
} else busy(r.activity);
|
|
160924
161769
|
} else if (seen) {
|
|
160925
|
-
|
|
161770
|
+
unread4();
|
|
160926
161771
|
} else if (r.cannot || ++blind > ACTIVITY_UNREAD_RETRIES) {
|
|
160927
161772
|
this.deps.log?.(`[links] ${this.name}: it cannot be told what runs there, so the update does not wait for it`);
|
|
160928
161773
|
return null;
|
|
@@ -161122,7 +161967,7 @@ var LinkedMachine = class extends LinkedMachineConnection {
|
|
|
161122
161967
|
if (!exec2) throw linkError2(`This computer has no shell on ${this.name} to withdraw a credential`);
|
|
161123
161968
|
if (this.endpoint?.line.credential === credentialId) throw linkError2(`That is this computer's own credential on ${this.name}, made again at each link`);
|
|
161124
161969
|
const r = await exec2(revokeCommand(this.record.remote, credentialId));
|
|
161125
|
-
if (r.code === 255) throw linkError2(
|
|
161970
|
+
if (r.code === 255) throw linkError2(sshFailure(this.record.sshTarget, r.stderr));
|
|
161126
161971
|
const said = parseRevoke(r.stdout);
|
|
161127
161972
|
if (said === null) throw linkError2(`${this.name} did not say whether it withdrew the credential${lastLine(r.stderr) ? `: ${lastLine(r.stderr)}` : ""}`);
|
|
161128
161973
|
this.revokedHere.add(credentialId);
|
|
@@ -161897,6 +162742,14 @@ function linkedSessions(machines, route = notRouted, options = {}) {
|
|
|
161897
162742
|
return {};
|
|
161898
162743
|
});
|
|
161899
162744
|
},
|
|
162745
|
+
stopTask(sessionId, callerId, taskId) {
|
|
162746
|
+
return viaSession(sessionId, async (m) => {
|
|
162747
|
+
const r = await m.call("host.stopTask", { sessionId: m.q.strip(sessionId, "The session"), caller: callerId, task: taskId }).catch((e) => {
|
|
162748
|
+
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;
|
|
162749
|
+
});
|
|
162750
|
+
return { stopped: isObj(r) && r.stopped === true };
|
|
162751
|
+
});
|
|
162752
|
+
},
|
|
161900
162753
|
machineLinked(machineId) {
|
|
161901
162754
|
return !!machineById(machineId);
|
|
161902
162755
|
},
|
|
@@ -161974,7 +162827,8 @@ function linkedSessions(machines, route = notRouted, options = {}) {
|
|
|
161974
162827
|
const s = (m.lastKnown("sessions") ?? []).find((x) => isObj(x) && x.id === at2.id);
|
|
161975
162828
|
if (!isObj(s)) return null;
|
|
161976
162829
|
const p = (m.lastKnown("projects") ?? []).find((x) => isObj(x) && x.id === s.projectId);
|
|
161977
|
-
|
|
162830
|
+
const projectName = isObj(p) ? oneLine4(p.name) : "(none)";
|
|
162831
|
+
return { name: oneLine4(s.name), project: `${projectName} on ${m.name}`, projectName };
|
|
161978
162832
|
},
|
|
161979
162833
|
lastWords(sessionId, maxChars, opts) {
|
|
161980
162834
|
return viaSession(
|
|
@@ -162153,6 +163007,16 @@ var ROUTES = {
|
|
|
162153
163007
|
const { file: _file2, ...rest } = r;
|
|
162154
163008
|
return rest;
|
|
162155
163009
|
}),
|
|
163010
|
+
// A file on a linked machine cannot be revealed in this computer's file manager — refuse locally without forwarding
|
|
163011
|
+
"messages.resolveFile": {
|
|
163012
|
+
kind: "noRemote",
|
|
163013
|
+
key: "sessionId",
|
|
163014
|
+
refuse: () => ({
|
|
163015
|
+
ok: false,
|
|
163016
|
+
reason: "not_found",
|
|
163017
|
+
message: "This file is on another machine and cannot be revealed here"
|
|
163018
|
+
})
|
|
163019
|
+
},
|
|
162156
163020
|
"trash.read": session(messages),
|
|
162157
163021
|
"trash.restore": session(fields4({ session: sessionInfo, project: projectInfo })),
|
|
162158
163022
|
"trash.purge": session(),
|
|
@@ -162373,6 +163237,8 @@ var ROUTES = {
|
|
|
162373
163237
|
"host.handover": HUB,
|
|
162374
163238
|
// The window of this machine telling its own host the system is ending (#1970); never through a link
|
|
162375
163239
|
"host.systemEnding": HUB,
|
|
163240
|
+
// A local dev:live browser tab asking its own host for human message attribution; never through a link
|
|
163241
|
+
"host.trustDevTab": HUB,
|
|
162376
163242
|
"machines.acceptVersions": HUB,
|
|
162377
163243
|
"machines.install": HUB,
|
|
162378
163244
|
"machines.update": HUB,
|
|
@@ -162394,6 +163260,7 @@ var ROUTES = {
|
|
|
162394
163260
|
"host.mailMove": HUB,
|
|
162395
163261
|
"host.cards": HUB,
|
|
162396
163262
|
"host.answerCard": HUB,
|
|
163263
|
+
"host.stopTask": HUB,
|
|
162397
163264
|
// A project's app here used by the hub's sessions (#1938): answered here, never passed on
|
|
162398
163265
|
"host.apps": HUB,
|
|
162399
163266
|
"host.appCall": HUB,
|
|
@@ -162472,7 +163339,10 @@ var Router = class {
|
|
|
162472
163339
|
case "view":
|
|
162473
163340
|
return this.byView(method, params, route, ctx);
|
|
162474
163341
|
case "noRemote": {
|
|
162475
|
-
if (this.owner(isObj(params) ? params[route.key] : void 0))
|
|
163342
|
+
if (this.owner(isObj(params) ? params[route.key] : void 0)) {
|
|
163343
|
+
if (route.refuse) return route.refuse();
|
|
163344
|
+
throw new NotOnRemoteError(method);
|
|
163345
|
+
}
|
|
162476
163346
|
return this.opts.local(method, params, ctx);
|
|
162477
163347
|
}
|
|
162478
163348
|
case "machine":
|
|
@@ -162493,7 +163363,7 @@ var Router = class {
|
|
|
162493
163363
|
return typeof id3 === "string" ? findMachine(this.opts.machines(), id3) : null;
|
|
162494
163364
|
}
|
|
162495
163365
|
async forward(m, method, params, ctx) {
|
|
162496
|
-
if (ctx?.rights === "limited" && SCRIPT_TEXT.has(method)) {
|
|
163366
|
+
if (ctx?.rights === "limited" && !ctx.trustedDev && SCRIPT_TEXT.has(method)) {
|
|
162497
163367
|
throw rpcError(`A script's message is not sent to ${m.name}: Centralu there would store it as the person's. Run the script on ${m.name} instead.`);
|
|
162498
163368
|
}
|
|
162499
163369
|
if (!m.reachable && ctx === void 0) await m.reachForCall?.();
|
|
@@ -163678,7 +164548,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
|
|
|
163678
164548
|
console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
|
|
163679
164549
|
process.exit(1);
|
|
163680
164550
|
}) : launch.token;
|
|
163681
|
-
var BUILD = true ? "
|
|
164551
|
+
var BUILD = true ? "9684dfb" : "dev";
|
|
163682
164552
|
var { values } = parseArgs({
|
|
163683
164553
|
options: {
|
|
163684
164554
|
port: { type: "string", default: "5175" },
|
|
@@ -163904,7 +164774,6 @@ mgr.useUpdates(updates);
|
|
|
163904
164774
|
var updateApply = new UpdateApplyBroker({ push: (e) => events.push(e), windows: () => server.clientCount });
|
|
163905
164775
|
mgr.useUpdateApply(updateApply);
|
|
163906
164776
|
var AUTO_APPLY_AGENT_VERSIONS_KEY = "agents.autoApplyVersions";
|
|
163907
|
-
var AGENT_VERSIONS_SEEN_KEY = "agents.versionsSeen";
|
|
163908
164777
|
var autoApplyAgentVersions = flagSetting(store.settings, AUTO_APPLY_AGENT_VERSIONS_KEY, true);
|
|
163909
164778
|
var agentVersions = new AgentVersionService({
|
|
163910
164779
|
tools: () => [...adapters.values()].map((a) => ({ tool: a.tool, installedVersion: a.installedVersion?.bind(a) })),
|
|
@@ -163914,9 +164783,7 @@ var agentVersions = new AgentVersionService({
|
|
|
163914
164783
|
// Not listening yet: the first window asks
|
|
163915
164784
|
publish: (status) => events.push({ type: "agent_versions", status }),
|
|
163916
164785
|
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))
|
|
164786
|
+
writeAutoApply: autoApplyAgentVersions.write
|
|
163920
164787
|
});
|
|
163921
164788
|
for (const a of adapters.values()) a.setup?.onChange((setup) => events.push({ type: "tool_setup", tool: a.tool, setup }));
|
|
163922
164789
|
versionsRef.current = agentVersions;
|