@centralu/host-win32-x64 0.1.0-beta.64 → 0.1.0-beta.66

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.
@@ -51,11 +51,13 @@ screen (`ui/index.html`) and agents call the same tools as functions. Same tools
51
51
  `process.stdout` yourself. stderr is shown to the person when the app fails.
52
52
  10. **Asking the agent**: inside a tool handler, `await centralu.agent('prompt', { schema, tool })`
53
53
  asks the agent of the person using Centralu. Each call runs in a new session under this app
54
- (the person can read it), with the `safe` approval setting, and returns the agent's final
55
- answer: text, or with `schema` (a JSON Schema whose top level is an object) JSON of that shape,
56
- checked by Centralu. Under `safe` the agent reads without asking, but every file write and
57
- command waits for the person to approve it in that session, so ask the agent for an answer and
58
- do the writing in your own tool code. Declare `"uses": { "agent": true }` in the manifest for the person's
54
+ (the person can read it) and returns the agent's final answer: text, or with `schema` (a JSON
55
+ Schema whose top level is an object) JSON of that shape, checked by Centralu. That session runs
56
+ under `auto`, but never above the lowest approval setting among the sessions calling into the
57
+ app. It runs under `safe` when nothing says who asked: no call is open, the calling session is
58
+ gone, or the chain of calls can no longer be followed. Under `safe` the agent reads without
59
+ asking, but every file write and command waits for the person to approve it in that session, so
60
+ ask the agent for an answer and do the writing in your own tool code. Declare `"uses": { "agent": true }` in the manifest for the person's
59
61
  default agent, or a list such as `["codex"]` to pick one with `tool`. The prompt reaches the
60
62
  agent marked as written by this app, not by the person, so say plainly what you need. A run
61
63
  takes seconds to minutes; the helper keeps the call alive while it waits. An app runs one agent
@@ -73,11 +75,12 @@ screen (`ui/index.html`) and agents call the same tools as functions. Same tools
73
75
  (the names shown in the sidebar and their states, never the conversations); `git.status` gives this project's branch and changed
74
76
  files (project apps only).
75
77
 
76
- All three throw an error that says what Centralu answered. The first time the app uses each of them (an
77
- agent tool, another app, a host name), Centralu asks the person once — on the session's approval card
78
- when an agent's call started it, on this app's screen when the screen did — and remembers the answer
79
- until the manifest's `uses` changes. The call waits while the person decides (up to 5 minutes). A
80
- refusal comes back as that error: show it plainly instead of retrying.
78
+ All three throw an error that says what Centralu answered. What the manifest declares in `uses` runs
79
+ with no question: the person trusted the app with it. Only while a session under the `safe` preset has a
80
+ call open into the app does Centralu ask the person, once per capability (an agent tool, another app, a
81
+ host name) — on the session's approval card when an agent's call started it, on this app's screen when
82
+ the screen did — and the call waits while the person decides (up to 5 minutes). A refusal, then or
83
+ remembered from before, comes back as that error: show it plainly instead of retrying.
81
84
 
82
85
  **Background work.** Centralu stops an app with no open screen and no call for 5 minutes. An app
83
86
  with work on its own clock (a timer that polls, a queue it drives) declares it in the manifest,
@@ -1,11 +1,11 @@
1
1
  {
2
- "commit": "5ec3da6",
2
+ "commit": "617c696",
3
3
  "protocolVersion": 1,
4
4
  "hostProof": 1,
5
5
  "tokenOnStdin": 1,
6
6
  "verifiers": 1,
7
7
  "keyPairing": 1,
8
- "builtAt": "2026-11-13T11:46:05.729Z",
8
+ "builtAt": "2026-11-13T16:32:50.688Z",
9
9
  "runtime": "system-node",
10
10
  "platform": "win32",
11
11
  "arch": "x64"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centralu",
3
- "version": "0.1.0-beta.64",
3
+ "version": "0.1.0-beta.66",
4
4
  "description": "Run, watch and steer several Claude Code and Codex CLI sessions from one window",
5
5
  "license": "MIT",
6
6
  "author": "ijun17",
@@ -38,9 +38,9 @@
38
38
  "win32"
39
39
  ],
40
40
  "optionalDependencies": {
41
- "@centralu/darwin-arm64": "0.1.0-beta.64",
42
- "@centralu/linux-arm64": "0.1.0-beta.64",
43
- "@centralu/linux-x64": "0.1.0-beta.64",
44
- "@centralu/win32-x64": "0.1.0-beta.64"
41
+ "@centralu/darwin-arm64": "0.1.0-beta.66",
42
+ "@centralu/linux-arm64": "0.1.0-beta.66",
43
+ "@centralu/linux-x64": "0.1.0-beta.66",
44
+ "@centralu/win32-x64": "0.1.0-beta.66"
45
45
  }
46
46
  }
package/host/main.mjs CHANGED
@@ -43046,7 +43046,7 @@ import { dirname as dirname27, join as join58 } from "node:path";
43046
43046
  import { mkdirSync as mkdirSync21, readFileSync as readFileSync27, writeSync as writeSync4 } from "node:fs";
43047
43047
 
43048
43048
  // packages/protocol/src/version.generated.ts
43049
- var APP_VERSION = "0.1.0-beta.64";
43049
+ var APP_VERSION = "0.1.0-beta.66";
43050
43050
 
43051
43051
  // packages/protocol/src/brand.ts
43052
43052
  var APP_NAME = "Centralu";
@@ -58505,6 +58505,10 @@ function usesLines(uses) {
58505
58505
  if (uses.notices) out.push("Post notices into the sessions that called it");
58506
58506
  return out;
58507
58507
  }
58508
+ function appCanLines(lines) {
58509
+ if (!lines.length) return ["Uses nothing beyond its own tools"];
58510
+ return lines.map((l) => `Can ${l.charAt(0).toLowerCase()}${l.slice(1)}`);
58511
+ }
58508
58512
  var HOST_DATA_WORDS = {
58509
58513
  "sessions.list": "the names and states of its project's sessions (sessions.list)",
58510
58514
  "git.status": "its project's branch and changed files (git.status)"
@@ -60888,7 +60892,7 @@ var appsParams = {
60888
60892
  }),
60889
60893
  /** The remembered capability answers for one app (M4 D-4) — shown next to the run history panel (B-7) and can be forgotten there */
60890
60894
  "apps.permissions": external_exports.object({ appId: AppId, projectId: ProjectId.nullable(), ...machineParam }),
60891
- /** Forgets one remembered answer (M4 D-4) — the next attempt to use that capability asks again */
60895
+ /** Forgets one remembered answer (M4 D-4): a forgotten allow makes a caller under `safe` ask again, a forgotten deny lets the app use that again (#2237) */
60892
60896
  "apps.forgetPermission": external_exports.object({
60893
60897
  appId: AppId,
60894
60898
  projectId: ProjectId.nullable(),
@@ -85491,7 +85495,7 @@ var RunAgentArgs = external_exports.object({
85491
85495
  schema: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
85492
85496
  });
85493
85497
  function deniedText(tool, appName, text3) {
85494
- return `${tool} refused: the person did not allow ${appName} to ${text3}. They can change this in the app's Runs panel (Permissions \u2192 Forget), and Centralu asks again when the app's manifest changes what it uses.`;
85498
+ return `${tool} refused: the person did not allow ${appName} to ${text3}. They can change this in the app's Runs panel (Permissions \u2192 Forget).`;
85495
85499
  }
85496
85500
  var NOT_DECLARED = 'this app did not declare "uses": { "agent": \u2026 } in centralu.app.json \u2014 an app may run an agent only if its manifest says so';
85497
85501
  var say = (text3) => ({ status: "ok", result: { content: [{ type: "text", text: text3 }] } });
@@ -85807,15 +85811,20 @@ var BrokerDesk = class {
85807
85811
  return { status: "delegated", result: { content: [{ type: "text", text: `call_app: ${id3}.${tool} ${how} \u2014 ${o.error ?? "no reason was given"}` }], isError: true } };
85808
85812
  }
85809
85813
  /**
85810
- * Capability approval (D-4) — asks the person once, the **first** time a request past the
85811
- * declaration uses that capability. Returns the result to give the app if denied, or null if
85812
- * allowed.
85814
+ * Capability approval (D-4, #2237) — the one decision on a request past the declaration. Returns the
85815
+ * result to give the app if denied, or null if allowed. In this order:
85813
85816
  *
85814
- * The answer is remembered per (app, capability) — an allow and a deny alike. This is the promise
85815
- * that the person is never asked the same thing twice, and an answer pressed by mistake can be
85816
- * forgotten from the runs panel's list (`apps.forgetPermission`). If the manifest's `uses` changes,
85817
- * the fingerprint changes with it and the remembered answer is no longer used — the app's builder
85818
- * has restated what it uses, so the person looks at it again too.
85817
+ * 1. A remembered deny (or any word but `allow`) refuses, whatever `uses` it was given against: with
85818
+ * no card after it, a deny that lapsed on a manifest change would become an allow nobody gave. It
85819
+ * holds until forgotten.
85820
+ * 2. A remembered allow given against the current `uses` allows.
85821
+ * 3. Otherwise the request runs with no card and nothing remembered: the declaration is the consent,
85822
+ * read where it is enforced (an app runs only once the person trusted it with its `uses`), so
85823
+ * nothing is stored that could outlive it. Except:
85824
+ * 4. When the lowest preset among the calls open into the app is `safe` (`BrokerHost.asksPerson`),
85825
+ * the person is asked once per (app, capability), where the chain started, and the answer is
85826
+ * remembered with the `uses` fingerprint: a `safe` session never gains through an app what
85827
+ * `start_agent` would ask it for (#673, #606). A changed `uses` asks it again.
85819
85828
  *
85820
85829
  * The app's call stays alive while this waits (a progress notification over the broker conduit,
85821
85830
  * `broker.ts`). If the person never answers and the cap (5 minutes) passes, this closes as a
@@ -85830,9 +85839,11 @@ var BrokerDesk = class {
85830
85839
  this.apps.denied(call2.parentRunId, { app: app2.ref, name: app2.name, capability: key, text: text3 });
85831
85840
  return refuse2(deniedText(tool, app2.name, text3));
85832
85841
  };
85833
- if (known && known.stamp === stamp2) return known.decision === "allow" ? null : denied();
85842
+ if (known && known.decision !== "allow") return denied();
85843
+ if (known && known.stamp === stamp2) return null;
85834
85844
  const host = this.host;
85835
85845
  if (!host) return refuse2("the broker is unavailable: there is no one to ask for permission");
85846
+ if (!host.asksPerson(this.apps.agentCallers(app2.ref))) return null;
85836
85847
  const slot = `${appKeyOf(app2.ref)} ${key}`;
85837
85848
  let q2 = this.asking.get(slot);
85838
85849
  if (!q2) {
@@ -85892,12 +85903,12 @@ var BrokerDesk = class {
85892
85903
  }
85893
85904
  /**
85894
85905
  * The remembered answers for one app (D-4) — shown and forgettable in the runs panel. `current`
85895
- * means the answer was given against the same fingerprint as the manifest's current declaration; if
85896
- * not, that answer is no longer used (it is asked again).
85906
+ * means the answer is still used: a deny always (`permit` rule 1), an allow when it was given against
85907
+ * the manifest's current declaration (otherwise a `safe` caller is asked again).
85897
85908
  */
85898
85909
  permissions(ref, manifestUses) {
85899
85910
  const stamp2 = manifestUses === null ? null : usesStamp(manifestUses);
85900
- return this.book.list(ref).sort((a, b2) => b2.decidedAt - a.decidedAt).map((d2) => ({ capability: d2.capability, text: d2.text, decision: d2.decision, decidedAt: d2.decidedAt, current: d2.stamp === stamp2 }));
85911
+ return this.book.list(ref).sort((a, b2) => b2.decidedAt - a.decidedAt).map((d2) => ({ capability: d2.capability, text: d2.text, decision: d2.decision, decidedAt: d2.decidedAt, current: d2.decision !== "allow" || d2.stamp === stamp2 }));
85901
85912
  }
85902
85913
  forgetPermission(ref, capability) {
85903
85914
  this.book.forget(ref, capability);
@@ -104468,16 +104479,16 @@ var ExternalApps = class {
104468
104479
  this.desk.attach(host);
104469
104480
  }
104470
104481
  /**
104471
- * The remembered capability answers for one app (D-4), most recent first. `current` means it was
104472
- * given against the manifest's current `uses`; otherwise it is no longer used. Everything is
104473
- * non-current if the manifest is invalid or the app is gone.
104482
+ * The remembered capability answers for one app (D-4), most recent first. `current` means it is
104483
+ * still used: a deny always, an allow when it was given against the manifest's current `uses`
104484
+ * (`BrokerDesk.permissions`). An allow is non-current if the manifest is invalid or the app is gone.
104474
104485
  */
104475
104486
  permissions(ref) {
104476
104487
  ref = this.resolve(ref);
104477
104488
  const m = this.find(ref)?.manifest;
104478
104489
  return this.desk.permissions(ref, m ? m.uses : null);
104479
104490
  }
104480
- /** Forgets one remembered answer (D-4) — the next time that capability is needed, it is asked again */
104491
+ /** Forgets one remembered answer (D-4) — the next time that capability is needed, `permit` decides afresh (#2237) */
104481
104492
  forgetPermission(ref, capability) {
104482
104493
  ref = this.resolve(ref);
104483
104494
  this.desk.forgetPermission(ref, capability);
@@ -109565,7 +109576,8 @@ var UNDOABLE = /* @__PURE__ */ new Set([
109565
109576
  // the person decides on the proposal
109566
109577
  "propose_skill",
109567
109578
  // the same
109568
- // Three that take a remembered answer away, so that step asks again: the person answers it again
109579
+ // Three that take a remembered answer away, so that step asks again: the person answers it again. Forgetting an app's deny
109580
+ // widens instead (#2237): what the app declares then runs unasked, so that command raises its own card (TrustFlow.forgetAnswer)
109569
109581
  "remove_approval_rule",
109570
109582
  "revoke_project_consent",
109571
109583
  "forget_app_answer"
@@ -110857,7 +110869,7 @@ var CENTRALU_TOOLS = [
110857
110869
  },
110858
110870
  {
110859
110871
  name: "forget_app_answer",
110860
- description: "Forgets an app grant: the person's remembered answer to one thing an app asked for, so it asks again. Acts at once.",
110872
+ description: "Forgets an app grant, the person's answer to one thing an app asked for: an allow at once, a deny once the person agrees.",
110861
110873
  schema: external_exports.object({ app: external_exports.string().describe("Its id or name."), project: external_exports.string().optional(), capability: external_exports.string().describe("As list_app_grants names it.") }).strict()
110862
110874
  },
110863
110875
  {
@@ -119101,21 +119113,19 @@ var ROWS2 = 50;
119101
119113
  function rows2(items, line) {
119102
119114
  return [...items.slice(0, ROWS2).map(line), ...items.length > ROWS2 ? [`- and ${items.length - ROWS2} more`] : []];
119103
119115
  }
119104
- function asksLines(a, indent2, lead) {
119116
+ function canLines(a, indent2) {
119105
119117
  if (!a.uses) {
119106
- if (a.status === "invalid") return [`${indent2}What it may ask for is not known: its manifest could not be read (${manifestText(a.error ?? "invalid", 300)}).`];
119107
- if (a.machine) return [`${indent2}What it may ask for is not known: its machine did not say (it runs an older Centralu).`];
119118
+ if (a.status === "invalid") return [`${indent2}What it can do is not known: its manifest could not be read (${manifestText(a.error ?? "invalid", 300)}).`];
119119
+ if (a.machine) return [`${indent2}What it can do is not known: its machine did not say (it runs an older Centralu).`];
119108
119120
  }
119109
- const asks = a.uses ? usesLines(a.uses) : [];
119110
- if (!asks.length) return [`${indent2}Asks for nothing beyond its own tools.`];
119111
- return asks.map((l) => `${indent2}${lead}${manifestText(l.charAt(0).toLowerCase() + l.slice(1))}`);
119121
+ return appCanLines(a.uses ? usesLines(a.uses) : []).map((l) => `${indent2}${manifestText(l)}`);
119112
119122
  }
119113
119123
  function appLines(a) {
119114
119124
  const title = a.name?.trim() ? a.name : a.appId;
119115
119125
  const description = a.description?.trim() ? `: ${plainQuoted(a.description.trim(), 2e3)}` : "";
119116
119126
  const out = [`- ${shown2(title)} (id ${shown2(a.appId)})${description}`];
119117
119127
  if (a.root) out.push(" This project is this app: the Assistant and your other projects can use it.");
119118
- out.push(...asksLines(a, " ", "May ask to: "));
119128
+ out.push(...canLines(a, " "));
119119
119129
  return out;
119120
119130
  }
119121
119131
  var LIMITS = [
@@ -119163,7 +119173,7 @@ var TrustFlow = class {
119163
119173
  case "list_app_grants":
119164
119174
  return await this.listAppGrants(rpc, req.app, req.project);
119165
119175
  case "forget_app_answer":
119166
- return await this.forgetAnswer(rpc, req.app, req.project, req.capability);
119176
+ return await this.forgetAnswer(rpc, sessionId, req.app, req.project, req.capability, signal);
119167
119177
  case "revoke_consent":
119168
119178
  return await this.revokeConsent(rpc, req.from, req.to, req.kind);
119169
119179
  case "share_app":
@@ -119307,7 +119317,7 @@ var TrustFlow = class {
119307
119317
  //
119308
119318
  // An app's own trust follows its project's (#1141: a root app and its inner apps run when the project is trusted, and an
119309
119319
  // imported app is enabled by trusting its project), so trusting is `set_project_trust`. What is left: the answers the
119310
- // person gave to an app's capability questions (forgetting one only makes it ask again), the remembered consents of one
119320
+ // person gave to an app's capability questions (asked only with a caller under safe, #2237), the remembered consents of one
119311
119321
  // project reaching another (revoking one makes the next reach ask again), and sharing a project app with the person's
119312
119322
  // other projects, which widens who can attach it and so asks.
119313
119323
  async listAppGrants(rpc, named3, project2) {
@@ -119329,12 +119339,12 @@ var TrustFlow = class {
119329
119339
  out.push(`- ${appLabel2(a, all)}: ${a.trusted ? "trusted" : "untrusted"}; ${sharing}`);
119330
119340
  if (answers2 === null) out.push(" Its remembered answers could not be read just now.");
119331
119341
  for (const p of answers2 ?? []) {
119332
- out.push(` ${p.decision === "allow" ? "Allowed" : "Denied"}: ${shown2(p.capability)} (${plainQuoted(p.text, 300)}), since ${new Date(p.decidedAt).toISOString().slice(0, 10)}${p.current ? "" : "; no longer applies, its uses changed"}`);
119342
+ out.push(` ${p.decision === "allow" ? "Allowed" : "Denied"}: ${shown2(p.capability)} (${plainQuoted(p.text, 300)}), since ${new Date(p.decidedAt).toISOString().slice(0, 10)}${p.current ? "" : "; its uses changed, so a calling session under safe is asked again"}`);
119333
119343
  }
119334
119344
  }
119335
119345
  if (pool.length > ROWS2) out.push(`- and ${pool.length - ROWS2} more apps`);
119336
119346
  const lines = [
119337
- pool.length ? `${pool.length} ${pool.length === 1 ? "app" : "apps"}, with the answers the person gave to what each asked for (forget_app_answer forgets one, so it asks again; share_app shares a project app):` : "No app.",
119347
+ pool.length ? `${pool.length} ${pool.length === 1 ? "app" : "apps"}, with the answers the person gave when asked (only a calling session under safe asks; forget_app_answer forgets one; share_app shares a project app):` : "No app.",
119338
119348
  ...out
119339
119349
  ];
119340
119350
  if (!named3?.trim() && !project2?.trim()) {
@@ -119346,16 +119356,33 @@ var TrustFlow = class {
119346
119356
  lines.push(...awayLine(all, "the apps and answers kept"));
119347
119357
  return { ok: true, text: lines.join("\n") };
119348
119358
  }
119349
- async forgetAnswer(rpc, named3, project2, capability) {
119359
+ /**
119360
+ * Forgetting an allow only narrows (a caller under `safe` is asked again), so it acts at once. Forgetting a deny widens
119361
+ * since #2237: what the app declares then runs unasked for every caller not under `safe`, so it waits for the person,
119362
+ * on the card every widening raises, and acts only if the deny is still there after Allow.
119363
+ */
119364
+ async forgetAnswer(rpc, caller, named3, project2, capability, signal) {
119350
119365
  const [apps, all] = await Promise.all([callWindow(rpc, "apps.list", {}), readProjects(rpc)]);
119351
119366
  const found = findApp(apps, all, named3, project2);
119352
119367
  if ("error" in found) return { ok: false, error: found.error };
119353
119368
  const a = found.app;
119354
- const answers2 = await callWindow(rpc, "apps.permissions", { appId: a.appId, projectId: a.projectId, ...onMachine(a) });
119355
- const answer = answers2.find((p) => p.capability === capability.trim());
119356
- if (!answer) return { ok: false, error: `${appLabel2(a, all)} has no remembered answer for ${shown2(capability.trim())}; list_app_grants names them.` };
119369
+ const label = appLabel2(a, all);
119370
+ const remembered = async () => (await callWindow(rpc, "apps.permissions", { appId: a.appId, projectId: a.projectId, ...onMachine(a) })).find((p) => p.capability === capability.trim());
119371
+ const answer = await remembered();
119372
+ if (!answer) return { ok: false, error: `${label} has no remembered answer for ${shown2(capability.trim())}; list_app_grants names them.` };
119373
+ if (answer.decision !== "allow") {
119374
+ const question = [
119375
+ `Forget that you denied ${label} to ${plainQuoted(answer.text, 300)} (${shown2(answer.capability)})?`,
119376
+ "The app declares it, so it can then do it without asking, unless a session set to Safe calls it."
119377
+ ].join("\n");
119378
+ const refused2 = await this.ask(caller, question, signal, "forgotten");
119379
+ if (refused2) return { ok: false, error: refused2 };
119380
+ const now = await remembered();
119381
+ if (now?.decision !== answer.decision) return { ok: false, error: `The answer for ${shown2(answer.capability)} of ${label} changed while the card stood, so nothing was forgotten.` };
119382
+ }
119357
119383
  await callWindow(rpc, "apps.forgetPermission", { appId: a.appId, projectId: a.projectId, capability: answer.capability, ...onMachine(a) });
119358
- return { ok: true, text: `Forgot the answer ${answer.decision === "allow" ? "allowing" : "denying"} ${shown2(answer.capability)} for ${appLabel2(a, all)}: the next time it asks for that, the person is asked again.` };
119384
+ const after = answer.decision === "allow" ? "a calling session under safe is asked again before the app uses that" : "the app can use that again, asked first only when a calling session is under safe";
119385
+ return { ok: true, text: `Forgot the answer ${answer.decision === "allow" ? "allowing" : "denying"} ${shown2(answer.capability)} for ${label}: ${after}.` };
119359
119386
  }
119360
119387
  async revokeConsent(rpc, from, to, kind) {
119361
119388
  const [consents, all] = await Promise.all([callWindow(rpc, "projectConsents.list", {}), readProjects(rpc)]);
@@ -119390,14 +119417,14 @@ var TrustFlow = class {
119390
119417
  `Share the app ${label} with your other projects?`,
119391
119418
  "A session in another project can then find it and attach it (find_apps, attach_app), after you allow that pair of projects once.",
119392
119419
  ...home && !home.trusted ? [`Its project is untrusted, so it attaches nowhere until you trust ${shown2(home.name)}.`] : [],
119393
- ...asksLines(a, "", "It may ask to: ")
119420
+ ...canLines(a, "")
119394
119421
  ].join("\n");
119395
119422
  const refused2 = await this.ask(caller, question, signal, "shared");
119396
119423
  if (refused2) return { ok: false, error: refused2 };
119397
119424
  const now = (await callWindow(rpc, "apps.list", {})).find((x) => sameApp(x, a));
119398
119425
  if (!now) return { ok: false, error: `${label} was removed while the card stood, so nothing was shared.` };
119399
119426
  if (now.shared) return { ok: true, text: `${label} was shared while the card stood; nothing more changed.` };
119400
- if (appsKey([now]) !== appsKey([a])) return { ok: false, error: `What ${label} may ask for changed while the card stood, so it is not what the card named and nothing was shared. Ask again to show the person what it asks for now.` };
119427
+ if (appsKey([now]) !== appsKey([a])) return { ok: false, error: `What ${label} can do changed while the card stood, so it is not what the card named and nothing was shared. Ask again to show the person what it can do now.` };
119401
119428
  await callWindow(rpc, "apps.setShared", { ...ref, shared: true });
119402
119429
  return { ok: true, text: `${label} is shared now: a session in another project can attach it once the person allows that pair of projects.` };
119403
119430
  }
@@ -120784,6 +120811,7 @@ var SessionAppWiring = class {
120784
120811
  hostData: (name, app2) => this.host.appSessions.appHostData(name, app2),
120785
120812
  agentLabel: (tool) => this.host.adapters.get(tool)?.descriptor.label ?? tool,
120786
120813
  askCapability: (q2, signal) => this.host.hostCards.askCapability(q2, signal),
120814
+ asksPerson: (callers) => this.host.appSessions.callersPreset(callers) === "safe",
120787
120815
  agentRunEnded: (run2) => this.host.appSessions.agentRunEnded(run2),
120788
120816
  appNotice: (sessionId, text3, app2) => this.host.appNotice(sessionId, text3, app2)
120789
120817
  };
@@ -135449,6 +135477,7 @@ function launchedThreads(n) {
135449
135477
  if (str(item.type) !== "collabAgentToolCall" || str(item.tool) !== "spawnAgent" || !codexItemOk(item)) return [];
135450
135478
  return (Array.isArray(item.receiverThreadIds) ? item.receiverThreadIds : []).filter((t) => typeof t === "string" && t !== "");
135451
135479
  }
135480
+ var GOAL_ID = "goal";
135452
135481
  var CodexChildTracker = class {
135453
135482
  constructor(sessionId) {
135454
135483
  this.sessionId = sessionId;
@@ -135470,6 +135499,12 @@ var CodexChildTracker = class {
135470
135499
  held = /* @__PURE__ */ new Map();
135471
135500
  /** Children whose turn already ended, so a launch result arriving after that is not held (the latest few) */
135472
135501
  done = [];
135502
+ /** The session's own commands started and not completed, by item id; `kept` once a turn ended with it running (#2027) */
135503
+ commands = /* @__PURE__ */ new Map();
135504
+ /** The objective of the thread's goal while it is active (#2027) */
135505
+ goal = null;
135506
+ /** Whether the active goal is left idle by a stopped turn: not listed until Codex says more of it or a turn starts */
135507
+ goalStopped = false;
135473
135508
  /** A launch call's result, held while the children it started run; false when it goes out now (none still runs) */
135474
135509
  hold(result, threads) {
135475
135510
  const running2 = threads.filter((t) => !this.done.includes(t));
@@ -135525,13 +135560,54 @@ var CodexChildTracker = class {
135525
135560
  }
135526
135561
  return [];
135527
135562
  }
135563
+ /** A notification of the session's own thread: the commands and the goal it keeps past a turn (#2027) */
135564
+ own(n) {
135565
+ const p = asObj(n.params);
135566
+ if (n.method === "item/started" || n.method === "item/completed") {
135567
+ const item = asObj(p.item);
135568
+ const id3 = str(item.id);
135569
+ if (str(item.type) !== "commandExecution" || !id3) return [];
135570
+ if (n.method === "item/started") {
135571
+ if (!this.commands.has(id3)) this.commands.set(id3, { command: str(item.command), kept: false });
135572
+ return [];
135573
+ }
135574
+ const c = this.commands.get(id3);
135575
+ this.commands.delete(id3);
135576
+ return c?.kept ? this.changed([{ ...this.keptTask(id3, c.command), status: codexItemOk(item) ? "completed" : "failed" }]) : [];
135577
+ }
135578
+ if (n.method === "turn/started" && this.goalStopped) {
135579
+ this.goalStopped = false;
135580
+ return this.changed();
135581
+ }
135582
+ if (n.method === "turn/completed") {
135583
+ const open6 = [...this.commands.values()].filter((c) => !c.kept);
135584
+ for (const c of open6) c.kept = true;
135585
+ const stopped = this.goal !== null && !this.goalStopped && str(asObj(p.turn).status) === "interrupted";
135586
+ if (stopped) this.goalStopped = true;
135587
+ return open6.length > 0 || stopped ? this.changed() : [];
135588
+ }
135589
+ if (n.method === "thread/goal/updated") return this.goalIs(goalFromCodex(asObj(p.goal)));
135590
+ if (n.method === "thread/goal/cleared") return this.goalIs(null);
135591
+ return [];
135592
+ }
135593
+ /** The thread's goal as read: a notification, or `thread/goal/get` on resume */
135594
+ goalIs(g5) {
135595
+ const objective = g5?.status === "active" ? g5.objective : null;
135596
+ if (objective === this.goal && !this.goalStopped) return [];
135597
+ this.goal = objective;
135598
+ this.goalStopped = false;
135599
+ return this.changed();
135600
+ }
135528
135601
  /** The turn to interrupt to stop this child, if one is running. */
135529
135602
  turnOf(thread) {
135530
135603
  return this.threads.get(thread)?.turnId ?? null;
135531
135604
  }
135532
135605
  /** The app-server went away and its child threads with it. */
135533
135606
  release(why2) {
135534
- const live2 = this.live();
135607
+ const live2 = this.live().filter((t) => t.id !== GOAL_ID);
135608
+ this.commands.clear();
135609
+ this.goal = null;
135610
+ this.goalStopped = false;
135535
135611
  for (const t of this.threads.values()) {
135536
135612
  t.active = false;
135537
135613
  t.turnId = null;
@@ -135539,7 +135615,7 @@ var CodexChildTracker = class {
135539
135615
  const held3 = [...this.held.keys()].map((callId) => ({ type: "tool_result", sessionId: this.sessionId, callId, ok: false, summary: why2 }));
135540
135616
  const carded = new Set(this.held.keys());
135541
135617
  this.held.clear();
135542
- if (live2.length === 0) return held3;
135618
+ if (live2.length === 0) return [...this.changed(), ...held3];
135543
135619
  return [...this.changed(live2.map((task) => ({ ...task, status: "stopped", summary: why2 })), carded), ...held3];
135544
135620
  }
135545
135621
  ended(thread, status, summary) {
@@ -135560,12 +135636,17 @@ var CodexChildTracker = class {
135560
135636
  status: "running"
135561
135637
  };
135562
135638
  }
135639
+ keptTask(id3, command) {
135640
+ return { id: id3, kind: "shell", description: firstLine2(command.trim()) || "Command", parentCallId: id3, stopsWithTurn: false, stoppable: false, status: "running" };
135641
+ }
135563
135642
  live() {
135564
135643
  const out = [];
135565
135644
  for (const [thread, t] of this.threads) {
135566
135645
  const task = t.active ? this.task(thread) : null;
135567
135646
  if (task) out.push(task);
135568
135647
  }
135648
+ for (const [id3, c] of this.commands) if (c.kept) out.push(this.keptTask(id3, c.command));
135649
+ if (this.goal !== null && !this.goalStopped) out.push({ id: GOAL_ID, kind: "other", description: `Goal: ${firstLine2(this.goal.trim())}`, stopsWithTurn: false, stoppable: false, status: "running" });
135569
135650
  return out;
135570
135651
  }
135571
135652
  /** The event when the live set or an ending moved; nothing when neither did. */
@@ -136451,8 +136532,8 @@ var CodexSession = class {
136451
136532
  * way to find the actual cause.
136452
136533
  */
136453
136534
  /*
136454
- * The ledger says whether it went with work in flight (a crash) or idle (asleep: a Codex session keeps its app-server
136455
- * while idle, #568, so a shutdown or a kill lands on sessions doing nothing, #1397). What it printed last is the reason
136535
+ * The ledger says whether it went with work in flight (a crash) or idle (asleep: an idle Codex session keeps its
136536
+ * app-server until it is put to sleep, #568, #2027, so a shutdown or a kill lands on sessions doing nothing, #1397). What it printed last is the reason
136456
136537
  * a person can act on: a lock, a bad config line, a panic
136457
136538
  */
136458
136539
  onExit: (code2, expected) => this.ledger.exited(expected, withStderrTail(`codex app-server exited (code ${code2 ?? "null"})`, this.client))
@@ -136599,6 +136680,7 @@ var CodexSession = class {
136599
136680
  void this.client.request("thread/goal/get", { threadId: this.threadId }).then((r) => {
136600
136681
  const g5 = r.goal ? goalFromCodex(r.goal) : null;
136601
136682
  if (g5) this.emit({ type: "goal", sessionId: this.sessionId, goal: g5 });
136683
+ for (const e of this.childThreads.children.goalIs(g5)) this.emit(e);
136602
136684
  }).catch(() => {
136603
136685
  });
136604
136686
  } else {
@@ -136668,6 +136750,7 @@ var CodexSession = class {
136668
136750
  return;
136669
136751
  }
136670
136752
  if (n.method === "mcpServer/startupStatus/updated" && !this.threadServers.firstMcpFailure(n.params)) return;
136753
+ for (const e of this.childThreads.children.own(n)) this.emit(e);
136671
136754
  this.emitNotification(n);
136672
136755
  this.childThreads.noteSpawn(n);
136673
136756
  this.childThreads.noteTurnEnd(n);
@@ -137236,7 +137319,7 @@ var CodexAdapter = class {
137236
137319
  // translates). This is a guarantee that every record change while we hold the handle is ours,
137237
137320
  // and the manager marks a catch-up skip on top of it (the basis for skipping a 48.6MB/8-second thread/read).
137238
137321
  exclusiveWriter: true,
137239
- // Child agents, from their threads' status and turns (#290, CodexChildTracker)
137322
+ // Child agents, from their threads' status and turns (#290), and a command or an active goal kept past a turn (#2027): CodexChildTracker
137240
137323
  backgroundTasks: true,
137241
137324
  toolDeferral: false,
137242
137325
  instructionChannel: "developer",
@@ -137247,11 +137330,12 @@ var CodexAdapter = class {
137247
137330
  // 0.160 TurnStartParams: turn/start steers an already-active regular turn; compact/review input is queued.
137248
137331
  midTurnInput: true,
137249
137332
  /*
137250
- * Not put to sleep (#568). Waking a large thread measured 7-13 s (`thread/resume` scales with the rollout, ~13.5 s for
137251
- * 550 MB), and its cache on resume is unmeasured. The memory is better won by one shared app-server per account
137252
- * (#561 E3: 379 MB vs 2,584 MB for ten threads), decided separately.
137333
+ * Put to sleep like Claude (#568, #2027; docs/plans/sleep-every-tool.md §3a, measured 2026-11-13 on codex-cli 0.160.0,
137334
+ * gpt-5.6-luna): the woken turn read the cache as the live one did (.99 against .91-.97 live, at 2 and 16 min, rollouts
137335
+ * of 1, 47 and 513 MB), and the wake added 3.4-4.8 s, nearly all of it the new process's first model request: a new
137336
+ * app-server was ready in 30-70 ms and `thread/resume` without turns took 33-73 ms even for 513 MB.
137253
137337
  */
137254
- sleep: false
137338
+ sleep: true
137255
137339
  };
137256
137340
  launchSettingsFingerprint(settings) {
137257
137341
  return JSON.stringify({ v: 2, cwd: settings.cwd, permission: launchPreset(settings.permissionPreset), sandbox: permissionOptionsFor2(settings.permissionPreset).sandbox, trusted: !!settings.projectTrusted, noSettings: !!settings.noSettingFiles });
@@ -141041,7 +141125,7 @@ function kindOf3(m, threadOrigin) {
141041
141125
  if (m.kind === "assign" && (threadOrigin === "person" || DELEGATION_ORIGINS.some((o) => o === threadOrigin))) return { kind: "task", needsReply: false };
141042
141126
  return { kind: kinds[m.kind], needsReply: m.kind === "question" };
141043
141127
  }
141044
- function movePendingThreadMail(db, now, projectOf) {
141128
+ function movePendingThreadMail(db, now, projectOf, holdsNow) {
141045
141129
  return db.transaction(() => {
141046
141130
  const pending = db.prepare(
141047
141131
  `SELECT m.*, r.recipient AS r_recipient, r.due_at AS r_due_at, r.attempt_at AS r_attempt_at, r.delivered_at AS r_delivered_at,
@@ -141078,6 +141162,7 @@ function movePendingThreadMail(db, now, projectOf) {
141078
141162
  for (const p of pending) {
141079
141163
  const m = toMessage(p);
141080
141164
  const sender = parseAddress(m.sender);
141165
+ const senderProject = sender?.kind === "session" ? projectOf(m.sender) ?? (m.sender === p.t_owner ? p.t_project_id : null) : null;
141081
141166
  const target = m.replyTo === null ? void 0 : rootOf.get(m.replyTo);
141082
141167
  const { kind, needsReply } = kindOf3(m, p.t_origin);
141083
141168
  const facts = {
@@ -141091,7 +141176,7 @@ function movePendingThreadMail(db, now, projectOf) {
141091
141176
  messages2 += insertMail.run({
141092
141177
  id: m.id,
141093
141178
  sender: m.sender,
141094
- senderProject: sender?.kind === "session" ? projectOf(m.sender) ?? (m.sender === p.t_owner ? p.t_project_id : null) : null,
141179
+ senderProject,
141095
141180
  kind,
141096
141181
  needsReply: needsReply ? 1 : 0,
141097
141182
  replyTo: target ? m.replyTo : null,
@@ -141103,18 +141188,21 @@ function movePendingThreadMail(db, now, projectOf) {
141103
141188
  legacyThread: m.threadId,
141104
141189
  createdAt: m.createdAt
141105
141190
  }).changes;
141191
+ const via = p.r_recipient === p.t_assignee && to?.assistant === 1 && p.t_owner !== p.r_recipient ? ROLE_VIA : null;
141192
+ const carried = p.r_held !== null && CARRIED_HOLDS.has(p.r_held) ? p.r_held : null;
141193
+ const ended2 = carried === "budget" || carried === "policy" && !holdsNow({ kind, senderProject }, p.r_recipient);
141106
141194
  recipients += insertRow.run({
141107
141195
  messageId: m.id,
141108
141196
  recipient: p.r_recipient,
141109
- via: p.r_recipient === p.t_assignee && to?.assistant === 1 && p.t_owner !== p.r_recipient ? ROLE_VIA : null,
141197
+ via,
141110
141198
  settled: kind === "task" && to?.trashed === 1 ? "gone" : "legacy",
141111
141199
  dueAt: p.r_due_at,
141112
- attemptAt: p.r_attempt_at,
141200
+ attemptAt: ended2 ? null : p.r_attempt_at,
141113
141201
  deliveredAt: p.r_delivered_at,
141114
141202
  readAt: p.r_read_at,
141115
- held: p.r_held !== null && CARRIED_HOLDS.has(p.r_held) ? p.r_held : null,
141116
- attempts: p.r_attempts,
141117
- lastError: p.r_last_error,
141203
+ held: ended2 ? "dismissed" : carried,
141204
+ attempts: ended2 ? 0 : p.r_attempts,
141205
+ lastError: ended2 ? null : p.r_last_error,
141118
141206
  now
141119
141207
  }).changes;
141120
141208
  handled.run({ now, id: m.id, recipient: p.r_recipient });
@@ -143564,6 +143652,53 @@ var StepsV65 = class extends MigrationRange {
143564
143652
  run: () => {
143565
143653
  this.addColumn("mail", "subject", "TEXT");
143566
143654
  }
143655
+ },
143656
+ {
143657
+ to: 72,
143658
+ breaksOlderReaders: false,
143659
+ /**
143660
+ * The holds of an earlier build, ended (#2243). The mail token guard (`budget`) went with D32 (#2014, beta.49) and the `auto` receiver's
143661
+ * first-contact hold (`holdsInbound`) with D10, but the rows an earlier build held kept their hold when the v65 move carried them (settled
143662
+ * `legacy`), so the Inbox's Waiting listed "Paused: this session has used its share of turns started by mail" and "Held: this session runs
143663
+ * without asking" weeks after nothing could write such a hold.
143664
+ *
143665
+ * **One meaning: a hold from an earlier build stays only if today's gate would hold the mail now.** `budget` is never set by today's code, so every
143666
+ * such row goes. A `policy` row settled `legacy` stays while `reach.holdFor` (mail/reach.ts) would hold it: a `message` from an untrusted project (a
143667
+ * missing project row is untrusted) to a session of another project, which is how a genuine untrusted asker's request is still held. The
143668
+ * delivery also holds moved rows that way (it judges a `legacy` row like any other, and `records.hold` writes `held` alone), so the same row looks
143669
+ * the same whoever held it, and this step cannot tell them apart; it asks the gate, as the move asks it for the rows it moves from now on. What the
143670
+ * gate would not hold goes, and what goes is `dismissed`, the hold word the person's Dismiss sets (not held for the person, never delivered):
143671
+ * `gone` says a sender or recipient is gone and `withdrawn` that the sender said it no longer waits, and neither is so. `settled` stays `legacy`.
143672
+ *
143673
+ * **This is a frozen copy of `holdFor`'s conditions, on purpose.** A step runs once on every store and must not call code that may change later;
143674
+ * if `holdFor` changes, this step does not. It mirrors: `m.kind === 'message'`; `leaves(senderProject, recipientProject)` = the sender's project is
143675
+ * not null and untrusted (`projects.trusted = 0`, or no such project) and is not the recipient session's project; the recipient is a session of this
143676
+ * host that is kept (a `sessions` row with `deleted_at` NULL: the live session lookup skips a trashed one, so the gate holds nothing for it). The
143677
+ * recipient's project is read from `sessions.project_id` and the sender's from `mail.sender_project`, as the move wrote it.
143678
+ *
143679
+ * **Not mirrored: a recipient on another machine** (a linked hub's session, a linked-machine child), which the live gate holds and this step
143680
+ * dismisses, since it compares the session id with this host's `sessions` rows only. That is acceptable: no such row is on the owner's store (read
143681
+ * only, 2026-11-13: all six held rows leave), and an old hold on another machine's session could not be released from this one in any case (Release
143682
+ * sends through this host's delivery to a session it keeps). There is no cheap exact way: the far session's project is not stored here.
143683
+ *
143684
+ * **Rewrite data one way (#292's rule 1).** An older build reads `dismissed` as it reads the person's own Dismiss (it is in its `HELD` filter),
143685
+ * and does not bring the holds back. Nothing is deleted: the message and its row stay. The sender is not told: the person did not dismiss it.
143686
+ */
143687
+ run: () => {
143688
+ if (this.db.prepare(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'mail_recipients'`).get() === void 0) return;
143689
+ if (this.db.prepare(`SELECT 1 FROM mail_recipients WHERE held IN ('budget', 'policy') LIMIT 1`).get() === void 0) return;
143690
+ this.db.exec(
143691
+ `UPDATE mail_recipients SET held = 'dismissed', attempt_at = NULL, last_error = NULL, attempts = 0
143692
+ WHERE held = 'budget'
143693
+ OR (held = 'policy' AND settled = 'legacy' AND NOT EXISTS (
143694
+ SELECT 1 FROM mail m, sessions s
143695
+ WHERE m.id = mail_recipients.message_id AND m.kind = 'message' AND s.deleted_at IS NULL
143696
+ AND m.sender_project IS NOT NULL
143697
+ AND COALESCE((SELECT p.trusted FROM projects p WHERE p.id = m.sender_project), 0) = 0
143698
+ AND mail_recipients.recipient LIKE 'session:%' AND substr(mail_recipients.recipient, instr(mail_recipients.recipient, '/') + 1) = s.id
143699
+ AND s.project_id IS NOT m.sender_project))`
143700
+ );
143701
+ }
143567
143702
  }
143568
143703
  ];
143569
143704
  }
@@ -144621,8 +144756,8 @@ var Store = class extends MigrationRunner {
144621
144756
  * The thread mail an older build left pending, moved into the message tables and marked handled in the old ones, in one transaction
144622
144757
  * (docs/plans/mailbox.md §6.3): run after every `ready` from M3a to M7, before delivery starts. A second run finds nothing
144623
144758
  */
144624
- movePendingThreadMail(now, projectOf) {
144625
- return movePendingThreadMail(this.db, now, projectOf);
144759
+ movePendingThreadMail(now, projectOf, holdsNow) {
144760
+ return movePendingThreadMail(this.db, now, projectOf, holdsNow);
144626
144761
  }
144627
144762
  /** An old thread's messages, read-only (§6.3): the earlier history of a moved message (`legacy_thread`) */
144628
144763
  legacyChain(threadId, before, limit) {
@@ -146752,6 +146887,14 @@ var AppSessions = class {
146752
146887
  }
146753
146888
  }
146754
146889
  }
146890
+ /**
146891
+ * The lowest preset among the calls open into an app (`appAgentPreset` over `AppCalls.agentCallers`): what its agent
146892
+ * runs under, and, at `safe`, whether the person is asked before the app uses what it declares (#2237,
146893
+ * `BrokerHost.asksPerson`). One reading for both, so an agent that would run under `safe` is exactly one that asks first
146894
+ */
146895
+ callersPreset(callers) {
146896
+ return appAgentPreset(callers, (sessionId) => this.host.meta.get(sessionId)?.permissionPreset);
146897
+ }
146755
146898
  /**
146756
146899
  * Runs an agent an app asked for (M4 D-1, plan decision 6) — stands up **a new session per
146757
146900
  * request** under that app, and returns the answer once the turn ends.
@@ -146810,7 +146953,7 @@ var AppSessions = class {
146810
146953
  projectId: req.app.projectId,
146811
146954
  cwd,
146812
146955
  tool: req.tool,
146813
- permissionPreset: appAgentPreset(req.callers, (sessionId) => this.host.meta.get(sessionId)?.permissionPreset),
146956
+ permissionPreset: this.callersPreset(req.callers),
146814
146957
  appId: req.app.appId,
146815
146958
  appAgent: req.schema ? { outputSchema: req.schema } : {}
146816
146959
  });
@@ -151951,7 +152094,11 @@ function hostMail(store2, sessions, opts) {
151951
152094
  console.error(`[mail] taking back the notices of ended cards failed: ${errorMessage(e)}`);
151952
152095
  }
151953
152096
  try {
151954
- const moved = store2.movePendingThreadMail(now(), (address) => reach.projectOf(address));
152097
+ const moved = store2.movePendingThreadMail(
152098
+ now(),
152099
+ (address) => reach.projectOf(address),
152100
+ (m, recipient) => reach.holdFor(m, recipient) !== null
152101
+ );
151955
152102
  if (moved.messages > 0) console.error(`[mail] moved ${moved.messages} pending message(s) an older build left in its threads`);
151956
152103
  } catch (e) {
151957
152104
  console.error(`[mail] moving the thread mail an older build left pending failed: ${errorMessage(e)}`);
@@ -162130,7 +162277,7 @@ var handedToken = launch.tokenOnStdin ? await readHandedToken(process.stdin).cat
162130
162277
  console.error(`[agent-host] the launcher did not hand over the token: ${e.message}`);
162131
162278
  process.exit(1);
162132
162279
  }) : launch.token;
162133
- var BUILD = true ? "5ec3da6" : "dev";
162280
+ var BUILD = true ? "617c696" : "dev";
162134
162281
  var { values } = parseArgs({
162135
162282
  options: {
162136
162283
  port: { type: "string", default: "5175" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centralu/host-win32-x64",
3
- "version": "0.1.0-beta.64",
3
+ "version": "0.1.0-beta.66",
4
4
  "description": "Centralu's host without the window, for Windows on x86-64: what a hub installs on a linked machine",
5
5
  "license": "MIT",
6
6
  "author": "ijun17",