cotal-ai 0.162.0 → 0.163.1

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.
Files changed (36) hide show
  1. package/dist/daemon/account.js +1 -2
  2. package/dist/daemon/command.js +47 -11
  3. package/dist/daemon/login.js +4 -3
  4. package/dist/daemon/manager.js +1 -1
  5. package/dist/daemon/setup.js +12 -1
  6. package/dist/daemon/update-entry.js +36 -9
  7. package/package.json +19 -19
  8. package/seeded-connectors/_shared/docs-bundle.bin +0 -0
  9. package/seeded-connectors/_shared/docs-index.bin +0 -0
  10. package/seeded-connectors/_shared/placements.json +2 -2
  11. package/seeded-connectors/claude/dist/app-host.d.ts +1 -1
  12. package/seeded-connectors/claude/dist/app-host.d.ts.map +1 -1
  13. package/seeded-connectors/claude/dist/approval-notice.d.ts.map +1 -1
  14. package/seeded-connectors/claude/dist/mcp.cjs +4 -4
  15. package/seeded-connectors/claude/dist/mcp.d.ts.map +1 -1
  16. package/seeded-connectors/claude/dist/monitor.cjs +1 -1
  17. package/seeded-connectors/claude/hooks/native-wake.js +2 -1
  18. package/seeded-connectors/claude/package.json +1 -1
  19. package/seeded-connectors/codex/dist/host.js +1 -1
  20. package/seeded-connectors/codex/dist/personal-host.d.ts +1 -1
  21. package/seeded-connectors/codex/dist/personal-host.d.ts.map +1 -1
  22. package/seeded-connectors/codex/dist/personal.d.ts.map +1 -1
  23. package/seeded-connectors/codex/dist/personal.js +2 -2
  24. package/seeded-connectors/codex/package.json +2 -2
  25. package/seeded-connectors/hermes/dist/launch.js +1 -1
  26. package/seeded-connectors/hermes/package.json +1 -1
  27. package/seeded-connectors/hermes/plugin/cotal/_sidecar/standalone.cjs +1 -1
  28. package/seeded-connectors/jcode/dist/host.js +1 -1
  29. package/seeded-connectors/jcode/dist/mcp.js +1 -1
  30. package/seeded-connectors/jcode/package.json +1 -1
  31. package/seeded-connectors/opencode/dist/plugin/index.js +1 -1
  32. package/seeded-connectors/opencode/package.json +1 -1
  33. package/seeded-connectors/pi/dist/index.js +1 -1
  34. package/seeded-connectors/pi/dist/standalone.js +1 -1
  35. package/seeded-connectors/pi/package.json +1 -1
  36. package/seeded-connectors/web/package.json +1 -1
@@ -1,4 +1,3 @@
1
- import { measureComputerVitals } from "@cotal-ai/manager";
2
1
  import { defaultComputerName, readComputerName, saveComputerName } from "./computer-name.js";
3
2
  import { findMesh } from "@cotal-ai/workspace";
4
3
  import { loadIdpSession, requestAccountMachine, signedInMachineAccounts, withIdpSessionDir } from "@cotal-ai/auth";
@@ -10,7 +9,7 @@ export function createAccountComputer(home, version, reconciler) {
10
9
  let vitals;
11
10
  let vitalsError;
12
11
  let sampling;
13
- const sample = () => sampling ??= measureComputerVitals().then(value => { vitals = value; vitalsError = undefined; }).catch(() => { vitalsError = "Computer vitals could not be measured; no new sample was sent."; }).finally(() => { sampling = undefined; });
12
+ const sample = () => sampling ??= import("@cotal-ai/manager").then(({ measureComputerVitals }) => measureComputerVitals()).then(value => { vitals = value; vitalsError = undefined; }).catch(() => { vitalsError = "Computer vitals could not be measured; no new sample was sent."; }).finally(() => { sampling = undefined; });
14
13
  let name;
15
14
  let nameWarning;
16
15
  try {
@@ -25,8 +25,9 @@ import { readFileSync, realpathSync } from "node:fs";
25
25
  import { dirname, isAbsolute, join } from "node:path";
26
26
  import { fileURLToPath } from "node:url";
27
27
  import { registry } from "@cotal-ai/core";
28
- import { CommandFailure, codeSpan, homeCotalDir, readUpdateRecovery, jsonFlag, plainFlag, presentationOf, recordOperationContext, renderReport, writeResult } from "@cotal-ai/workspace";
29
- import { IdpConfigurationError, normalizeIdpUrl } from "@cotal-ai/auth";
28
+ import { CommandFailure, codeSpan, homeCotalDir, keptCatalogCredentials, readUpdateRecovery, jsonFlag, plainFlag, presentationOf, recordOperationContext, renderReport, writeResult } from "@cotal-ai/workspace";
29
+ import { openLoginBrowser, cloudAuthUrl } from "@cotal-ai/workspace";
30
+ import { chooseAccount, IdpConfigurationError, normalizeIdpUrl } from "@cotal-ai/auth";
30
31
  import { EndpointRefusal, defaultPeerUid, defaultPeerPid, checkDir, daemonPaths, daemonPathsFor } from "./endpoint.js";
31
32
  import { serveDaemon } from "./server.js";
32
33
  import { loginFromCli } from "./cli-login.js";
@@ -43,6 +44,8 @@ import { nativeDaemonLog } from "./native-log.js";
43
44
  export const daemonFlags = [
44
45
  jsonFlag,
45
46
  plainFlag,
47
+ { name: "cloud", type: "boolean", description: "sign in to Cotal Cloud" },
48
+ { name: "no-browser", type: "boolean", description: "print approval instructions without opening a browser" },
46
49
  { name: "idp", type: "string", value: "<auth base URL>", description: "the provider's auth base URL, e.g. <origin>/api/auth" },
47
50
  { name: "client-id", type: "string", value: "<id>", description: "the OAuth device-flow client id" },
48
51
  { name: "daemon-home", type: "string", value: "<abs dir>", completion: "files", description: "run or reach the daemon whose state lives in this directory (absolute, yours, mode 0700, not the Cotal home): its own sign-in, identity and registration, its own socket and lifetime lock. Without it, run or reach the default daemon, whose state lives in the Cotal home." },
@@ -176,11 +179,20 @@ async function status(args) {
176
179
  async function login(args) {
177
180
  const presentation = presentationOf(args.values);
178
181
  const values = args.values;
179
- if (typeof values.idp !== "string")
180
- throw new CommandFailure("refused", "USAGE_INVALID", "cotal daemon login needs --idp <auth base URL>");
182
+ if (values.idp !== undefined) {
183
+ try {
184
+ normalizeIdpUrl(cloudAuthUrl(values.idp));
185
+ }
186
+ catch {
187
+ throw new CommandFailure("refused", "USAGE_INVALID", "use an HTTPS provider auth URL, or an HTTP loopback IP URL, without embedded credentials, a query or a fragment");
188
+ }
189
+ }
190
+ const chosen = await chooseAccount(args, "login");
191
+ if (chosen === undefined)
192
+ return;
181
193
  let idp;
182
194
  try {
183
- idp = normalizeIdpUrl(values.idp);
195
+ idp = normalizeIdpUrl(chosen);
184
196
  }
185
197
  catch {
186
198
  throw new CommandFailure("refused", "USAGE_INVALID", "use an HTTPS provider auth URL, or an HTTP loopback IP URL, without embedded credentials, a query or a fragment");
@@ -199,6 +211,7 @@ async function login(args) {
199
211
  { kind: "fields", rows: [["Provider", idp], ["Open", p.verificationUriComplete], ["Or open", p.verificationUri], ["Approval code", p.userCode], ["Expires", p.expiresAt]] },
200
212
  { kind: "lines", lines: [{ text: "Waiting for the provider's approval. The daemon keeps the session. Ctrl-C cancels this sign-in on this machine. Do not share the approval link or code.", tone: "hint" }] },
201
213
  ] }] }, presentation === "plain" ? "plain" : "rich", process.stderr)}\n`);
214
+ openLoginBrowser(p.verificationUriComplete, args.values);
202
215
  },
203
216
  });
204
217
  }
@@ -224,7 +237,9 @@ async function login(args) {
224
237
  throw new CommandFailure("refused", "PERMISSION_DENIED", `${r.message}; no session was saved`, native);
225
238
  throw new CommandFailure("failed", "OPERATION_FAILED", `${r.message}; a session may have been saved before the failure, so sign in again`, native);
226
239
  }
227
- writeResult(presentation, { command: "daemon login", target: { idp }, result: { attempt: reply.attempt, ...r } }, () => ({ sections: [
240
+ // The switch is done; a credential file it could not delete leaves the run partial.
241
+ const partial = r.credentialsKept?.length ? keptCatalogCredentials(r.credentialsKept) : undefined;
242
+ writeResult(presentation, { command: "daemon login", target: { idp }, result: { attempt: reply.attempt, ...r }, ...(partial ? { partial } : {}) }, () => ({ sections: [
228
243
  { title: "Signed in", blocks: [{ kind: "fields", rows: [["Account", r.label || r.sub], ["Subject", r.sub], ["Provider", r.idp]] }, { kind: "lines", lines: [...(r.previousSub ? [`Replaced account: ${r.previousSub}`] : []), { text: "The daemon holds this session in the machine's Cotal home. No session token is printed. Each space's grants decide access separately.", tone: "hint" }] }] },
229
244
  ] }));
230
245
  }
@@ -409,10 +424,14 @@ async function setupUnderClosure(args) {
409
424
  throw new CommandFailure("refused", "USAGE_INVALID", "--no-manager and --wait require --space <s>");
410
425
  if (space && !SPACE_PATTERN.test(space))
411
426
  throw new CommandFailure("refused", "USAGE_INVALID", "space must be 1-64 characters of [A-Za-z0-9_-]", { native: { code: "BAD_FIELD" } });
427
+ if (args.values.cloud && values.idp !== undefined)
428
+ throw new CommandFailure("refused", "USAGE_INVALID", "--cloud and --idp cannot be combined");
412
429
  let idp;
430
+ if (args.values.cloud === true)
431
+ idp = await chooseAccount(args, "login");
413
432
  if (values.idp !== undefined) {
414
433
  try {
415
- idp = normalizeIdpUrl(values.idp);
434
+ idp = normalizeIdpUrl(cloudAuthUrl(values.idp));
416
435
  }
417
436
  catch {
418
437
  throw new CommandFailure("refused", "USAGE_INVALID", "use an HTTPS provider auth URL, or an HTTP loopback IP URL, without embedded credentials, a query or a fragment");
@@ -426,6 +445,22 @@ async function setupUnderClosure(args) {
426
445
  if (values.wait !== undefined && values["no-manager"] !== true)
427
446
  throw new CommandFailure("refused", "USAGE_INVALID", "--wait requires --no-manager; Manager setup never waits for machine approval");
428
447
  const { paths, home } = resolveTarget(args);
448
+ let newSignIn = values.idp !== undefined || args.values.cloud === true;
449
+ if (!space && !idp) {
450
+ let installed = true;
451
+ try {
452
+ planUninstall(paths, home);
453
+ }
454
+ catch {
455
+ installed = false;
456
+ }
457
+ if (!installed) {
458
+ idp = await chooseAccount(args, "login");
459
+ if (idp === undefined)
460
+ return;
461
+ newSignIn = true;
462
+ }
463
+ }
429
464
  const plain = presentation === "plain";
430
465
  // Progress goes to stderr so a --json caller still reads one document on stdout.
431
466
  const report = (line) => { process.stderr.write(`${line}\n`); };
@@ -453,9 +488,9 @@ async function setupUnderClosure(args) {
453
488
  throw new CommandFailure("refused", "USAGE_INVALID", `The daemon is signed in to several providers (${providers.join(", ")}); pass --idp <url> to choose one`);
454
489
  idp = providers[0];
455
490
  }
456
- const r = await runAccountSetup({ paths, daemonHome: home, peerUid, peerPid, report, version: binVersion(), idp: idp, existingSignInOnly: values.idp === undefined,
491
+ const r = await runAccountSetup({ paths, daemonHome: home, peerUid, peerPid, report, version: binVersion(), idp: idp, existingSignInOnly: !newSignIn,
457
492
  ...(values["client-id"] !== undefined ? { clientId: values["client-id"] } : {}),
458
- onPrompt: p => { process.stderr.write(`Approve this machine\nOpen: ${p.verificationUriComplete}\nApproval code: ${p.userCode}\n`); }, });
493
+ onPrompt: p => { process.stderr.write(`Approve this machine\nOpen: ${p.verificationUriComplete}\nApproval code: ${p.userCode}\n`); openLoginBrowser(p.verificationUriComplete, args.values); }, });
459
494
  writeResult(presentation, { command: "daemon setup", target: { idp: idp }, result: r }, () => ({ sections: [
460
495
  { title: "Connected to your account", blocks: [{ kind: "fields", rows: [["Account", r.label || "Signed in"], ["Computer", r.computer]] },
461
496
  { kind: "lines", lines: [r.spaces.length ? `Spaces using this computer: ${r.spaces.join(", ")}` : "Turn on the spaces that can use this computer in the dashboard."] }] },
@@ -473,6 +508,7 @@ async function setupUnderClosure(args) {
473
508
  { kind: "fields", rows: [["Provider", idp], ["Open", p.verificationUriComplete], ["Or open", p.verificationUri], ["Approval code", p.userCode], ["Expires", p.expiresAt]] },
474
509
  { kind: "lines", lines: [{ text: "Open that link on any device with a browser. This machine needs none. Do not share the approval link or code.", tone: "hint" }] },
475
510
  ] }] }, plain ? "plain" : "rich", process.stderr)}\n`);
511
+ openLoginBrowser(p.verificationUriComplete, args.values);
476
512
  },
477
513
  });
478
514
  }
@@ -675,12 +711,12 @@ const daemonCommand = {
675
711
  { name: "spaces", usage: "cotal daemon spaces [--refresh] [--daemon-home <dir>] [--json|--plain]", examples: [{ command: "cotal daemon spaces", note: "list registered spaces" }, { command: "cotal daemon spaces --refresh", note: "refresh catalogs before listing spaces" }], summary: "list registered spaces; optionally refresh catalogs using the daemon-held sign-in", flagNames: ["refresh", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
676
712
  { name: "start", usage: "cotal daemon start [--daemon-home <dir>] [--json|--plain]", examples: [{ command: "cotal daemon start", note: "start the recorded daemon service" }], summary: "start the unchanged, recorded daemon service without restarting a running instance", flagNames: ["daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
677
713
  { name: "desktop", usage: "cotal daemon desktop [--daemon-home <dir>]", examples: [{ command: "cotal daemon desktop < request.json", note: "serve one desktop request from a file" }], summary: "serve one bounded JSON request from the desktop app on stdin; credentials remain in the daemon", flagNames: ["daemon-home"], prepareMeshTarget: false },
678
- { name: "setup", usage: "cotal daemon setup [--idp <url>] [--space <s>] [--client-id <id>] [--no-manager [--wait <seconds>]] [--daemon-home <dir>] [--json|--plain]", summary: "connect this computer to an account, or rerun using its sole signed-in provider; with --space, host its Manager (--no-manager and --wait require --space)", examples: [{ command: "cotal daemon setup", note: "refresh apps using the sole signed-in provider" }, { command: "cotal daemon setup --idp <url>", note: "connect your account, then enable spaces in the dashboard" }, { command: "cotal daemon setup --space <space> --no-manager --wait 0", note: "report machine-service approval without hosting a Manager" }], flagNames: ["space", "idp", "client-id", "wait", "no-manager", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
714
+ { name: "setup", usage: "cotal daemon setup [--cloud | --idp <url>] [--no-browser] [--space <s>] [--client-id <id>] [--no-manager [--wait <seconds>]] [--daemon-home <dir>] [--json|--plain]", summary: "connect this computer to an account, or rerun using its sole signed-in provider; with --space, host its Manager (--no-manager and --wait require --space)", examples: [{ command: "cotal daemon setup", note: "refresh apps using the sole signed-in provider" }, { command: "cotal daemon setup --idp <url>", note: "connect your account, then enable spaces in the dashboard" }, { command: "cotal daemon setup --space <space> --no-manager --wait 0", note: "report machine-service approval without hosting a Manager" }], flagNames: ["space", "cloud", "no-browser", "idp", "client-id", "wait", "no-manager", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
679
715
  { name: "status", usage: "cotal daemon status [--space <s>] [--daemon-home <dir>] [--json|--plain]", summary: "ask the running daemon for its status and hosted Managers over the local endpoint", examples: [{ command: "cotal daemon status", note: "ask the running daemon for its status" }, { command: "cotal daemon status --json", note: "the same as one JSON document" }], flagNames: ["space", "daemon-home", "json", "plain"], outputs: ["json", "plain"], reads: true, prepareMeshTarget: false },
680
716
  { name: "serve", usage: "cotal daemon serve [--daemon-home <dir>] [--json|--plain]", summary: "run the daemon in the foreground and serve its local endpoint (refusals honor --json)", examples: [{ command: "cotal daemon serve", note: "run the machine daemon in this terminal" }], flagNames: ["daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
681
717
  { name: "install", usage: "cotal daemon install [--daemon-home <dir>] [--dry-run] [--json|--plain]", summary: "install the daemon as this platform's user service; Linux also enables linger", examples: [{ command: "cotal daemon install", note: "run it as a persistent user service" }, { command: "cotal daemon install --dry-run", note: "show the unit it would write" }], flagNames: ["daemon-home", "dry-run", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
682
718
  { name: "uninstall", usage: "cotal daemon uninstall [--daemon-home <dir>] [--yes|--dry-run] [--json|--plain]", summary: "stop the daemon's user service, disable autostart and remove its unit", examples: [{ command: "cotal daemon uninstall", note: "remove its login unit" }], flagNames: ["daemon-home", "yes", "dry-run", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
683
- { name: "login", usage: "cotal daemon login --idp <auth base URL> [--client-id <id>] [--daemon-home <dir>] [--json|--plain]", summary: "sign the running daemon in to a provider with device approval; the daemon keeps the session", examples: [{ command: "cotal daemon login --idp <url>", note: "sign the daemon in with device approval" }], flagNames: ["idp", "client-id", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
719
+ { name: "login", usage: "cotal daemon login [--cloud | --idp <auth base URL>] [--no-browser] [--client-id <id>] [--daemon-home <dir>] [--json|--plain]", summary: "sign the running daemon in to a provider with device approval; the daemon keeps the session", examples: [{ command: "cotal daemon login --idp <url>", note: "sign the daemon in with device approval" }], flagNames: ["cloud", "no-browser", "idp", "client-id", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
684
720
  { name: "connect-check", usage: "cotal daemon connect-check --space <s> [--daemon-home <dir>] [--json|--plain]", summary: "ask the running daemon whether it could register with a space as its own service; registers nothing", examples: [{ command: "cotal daemon connect-check --space <space>", note: "check whether it could register" }], flagNames: ["space", "daemon-home", "json", "plain"], outputs: ["json", "plain"], reads: true, prepareMeshTarget: false },
685
721
  { name: "register", usage: "cotal daemon register --space <s> [--daemon-home <dir>] [--json|--plain]", summary: "ask the running daemon to request its own service registration with a space; the space owner must approve it, and it does not connect", examples: [{ command: "cotal daemon register --space <space>", note: "ask a space to approve it as a service" }], flagNames: ["space", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
686
722
  { name: "service-connect", usage: "cotal daemon service-connect --space <s> [--daemon-home <dir>] [--json|--plain]", summary: "connect the running daemon to a space as its own approved service; succeeds only when the broker accepts the connection and the space accepts it as ready", examples: [{ command: "cotal daemon service-connect --space <space>", note: "connect it to a space" }], flagNames: ["space", "daemon-home", "json", "plain"], outputs: ["json", "plain"], prepareMeshTarget: false },
@@ -18,7 +18,7 @@
18
18
  import { randomBytes } from "node:crypto";
19
19
  import { resolve } from "node:path";
20
20
  import { deleteIdpSpaceCatalog, establishIdpSession, IdpDeviceAuthorizationRefusedError, IdpLoginCancelled, IdpUnreachableError } from "@cotal-ai/auth";
21
- import { homeCotalDir, isCommandFailure, removeCatalogMeshes } from "@cotal-ai/workspace";
21
+ import { homeCotalDir, isCommandFailure, removeCatalogAccount } from "@cotal-ai/workspace";
22
22
  /** The client id stock `cotal login` presents by default. */
23
23
  export const DEFAULT_CLIENT_ID = "cotal-cli";
24
24
  /** How many finished attempt ids are remembered, so a late cancel still gets a truthful answer. */
@@ -55,13 +55,14 @@ export function createLoginCoordinator(opts) {
55
55
  expiresAt: new Date(Date.now() + p.expiresInSec * 1000).toISOString(),
56
56
  }),
57
57
  });
58
+ let credentialsKept = [];
58
59
  if (r.previousSub) {
59
60
  const owner = deleteIdpSpaceCatalog(opts.sessionDir, req.idp, r.previousSub);
60
61
  // A separate daemon owns its catalog cache, not the shared registry or its credentials.
61
62
  if (resolve(opts.sessionDir) === resolve(homeCotalDir()))
62
- removeCatalogMeshes(owner);
63
+ ({ credentialsKept } = removeCatalogAccount(owner));
63
64
  }
64
- return { outcome: "signed-in", idp: req.idp, sub: r.sub, ...(r.label ? { label: r.label } : {}), ...(r.previousSub ? { previousSub: r.previousSub } : {}) };
65
+ return { outcome: "signed-in", idp: req.idp, sub: r.sub, ...(r.label ? { label: r.label } : {}), ...(r.previousSub ? { previousSub: r.previousSub } : {}), ...(credentialsKept.length ? { credentialsKept } : {}) };
65
66
  }
66
67
  catch (e) {
67
68
  if (e instanceof IdpLoginCancelled)
@@ -4,7 +4,6 @@ import { spawn } from "node:child_process";
4
4
  import { appendFileSync, chmodSync, existsSync, lstatSync, readFileSync, readdirSync, renameSync, rmSync, statSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { assertLifecycleToken, mkSecretDir, parseRemoteEndpointDeregisterResult, registry, writeSecretFileAtomic } from "@cotal-ai/core";
7
- import { remoteManagerClient } from "@cotal-ai/manager";
8
7
  import { daemonArgv } from "@cotal-ai/cli/self-exec";
9
8
  import { writeDefaultPersonaForLaunch } from "@cotal-ai/cli/default-persona";
10
9
  import { loadIdpSession, retainManagerAuthorityRoute, withIdpSessionDir } from "@cotal-ai/auth";
@@ -830,6 +829,7 @@ export function createHostedManagers(home = homeCotalDir(), version = installedG
830
829
  if (held.view.registrationCleanup === "unknown")
831
830
  incomplete("Manager registration removal is unconfirmed; no automatic request was repeated");
832
831
  try {
832
+ const { remoteManagerClient } = await import("@cotal-ai/manager");
833
833
  instanceId = remoteManagerClient.loadRemoteManagerInstanceId(daemonManagerRoot(space, home), space) ?? instanceId;
834
834
  }
835
835
  catch {
@@ -14,7 +14,7 @@ import { ensureHostedManager, hostingPrerequisite } from "./hosting.js";
14
14
  * It composes the existing commands and adds no new authority. Pausing, renaming and disconnecting
15
15
  * stay separate commands; this one does not absorb them.
16
16
  */
17
- import { codeSpan, CommandFailure, resolveOnPath } from "@cotal-ai/workspace";
17
+ import { codeSpan, CommandFailure, keptCatalogCredentials, resolveOnPath } from "@cotal-ai/workspace";
18
18
  import { normalizeIdpUrl } from "@cotal-ai/auth";
19
19
  import { EndpointRefusal } from "./endpoint.js";
20
20
  import { loginFromCli } from "./cli-login.js";
@@ -183,6 +183,14 @@ async function refreshApplications(opts, steps) {
183
183
  await waitForDaemon(opts, 60);
184
184
  return true;
185
185
  }
186
+ /** A sign-in that replaced an account but could not delete some of that account's discovered-space
187
+ * credential files stops setup as partial. The session is already switched, so a rerun continues. */
188
+ function credentialsRemoved(r) {
189
+ if (r.outcome !== "signed-in" || !r.credentialsKept?.length)
190
+ return;
191
+ const { message, remedy } = keptCatalogCredentials(r.credentialsKept);
192
+ throw new CommandFailure("partial", "OPERATION_PARTIAL", message, { remedy: `${remedy}, then run this setup again` });
193
+ }
186
194
  /** Connect this computer to an account without changing any space intent. */
187
195
  export async function runAccountSetup(opts) {
188
196
  const steps = [];
@@ -203,6 +211,7 @@ export async function runAccountSetup(opts) {
203
211
  throw new CommandFailure("refused", "AUTH_REQUIRED", signed.message, { native: { code: signed.code } });
204
212
  if (signed.result.outcome === "failed")
205
213
  throw new CommandFailure("refused", "AUTH_REQUIRED", signed.result.message);
214
+ credentialsRemoved(signed.result);
206
215
  steps.push({ step: "sign-in", outcome: "signed-in", detail: `signed in as ${signed.result.label || signed.result.sub}` });
207
216
  }
208
217
  else
@@ -289,6 +298,7 @@ async function ensureSignedIn(opts, steps) {
289
298
  throw new CommandFailure("refused", "PERMISSION_DENIED", `${r.message}; no session was saved and nothing was registered`, native);
290
299
  throw new CommandFailure("failed", "OPERATION_FAILED", `${r.message}; a session may have been saved before the failure, so run this again`, native);
291
300
  }
301
+ credentialsRemoved(r);
292
302
  steps.push({ step: "sign-in", outcome: "signed-in", detail: `signed in as ${r.label || r.sub}` });
293
303
  opts.report(`sign-in: signed in as ${r.label || r.sub}`, steps.at(-1));
294
304
  }
@@ -376,6 +386,7 @@ export async function runSetup(opts) {
376
386
  throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", failed.message, { native: { code: failed.reason.toUpperCase() }, remedy: failed.remedy });
377
387
  throw new CommandFailure("refused", failed.reason === "unreachable" || failed.reason === "authorization-refused" ? "DEPENDENCY_UNAVAILABLE" : "PERMISSION_DENIED", failed.message, { native: { code: failed.reason.toUpperCase().replaceAll("-", "_") }, remedy: `run ${codeSpan(daemonCommandCopy("login", opts.daemonHome, [["--idp", opts.idp]]))}` });
378
388
  }
389
+ credentialsRemoved(signed.result);
379
390
  steps.push({ step: "sign-in", outcome: "signed-in", detail: `signed in as ${signed.result.label || signed.result.sub}` });
380
391
  opts.report(`sign-in: signed in as ${signed.result.label || signed.result.sub}`, steps.at(-1));
381
392
  discoveredSignIn = true;
@@ -1,9 +1,9 @@
1
1
  /** The binary composes machine-daemon custody with the stock package updater. */
2
2
  import { existsSync } from "node:fs";
3
3
  import { registry } from "@cotal-ai/core";
4
- import { update, updateRuntime } from "@cotal-ai/cli/update";
4
+ import { update, updateRuntime, localUpdateManagers, readManagerContinuity, updateManagerPin } from "@cotal-ai/cli/update";
5
5
  import { withIdpSessionDir, withRemoteExchangeRetry } from "@cotal-ai/auth";
6
- import { CommandFailure, homeCotalDir, readUpdateRecovery, claimUpdateClosureAccess, resolveControlTarget, shellPath } from "@cotal-ai/workspace";
6
+ import { brokerAddressKey, assertRecordIdentity, CommandFailure, homeCotalDir, readUpdateRecovery, claimUpdateClosureAccess, resolveControlTarget, shellPath } from "@cotal-ai/workspace";
7
7
  import { askManager } from "@cotal-ai/workspace/control";
8
8
  import { daemonPaths, EndpointRefusal } from "./endpoint.js";
9
9
  import { managerViaDaemon, queryDaemon } from "./client.js";
@@ -18,7 +18,11 @@ const composed = { ...command, async run(args) {
18
18
  let daemonObserved = false;
19
19
  let preparedRestart = false;
20
20
  let absentRecoveryHost = false;
21
- await update(args, { ...updateRuntime, async automaticUpdateAdvice() {
21
+ let currentPackages = false;
22
+ await update(args, { ...updateRuntime, isCurrent() {
23
+ currentPackages = updateRuntime.isCurrent?.() === true;
24
+ return currentPackages;
25
+ }, async automaticUpdateAdvice() {
22
26
  try {
23
27
  const reply = await queryDaemon({ paths: daemonPaths() });
24
28
  if (!reply.ok)
@@ -120,25 +124,48 @@ const composed = { ...command, async run(args) {
120
124
  if (!reply.ok)
121
125
  throw new Error(reply.error ?? "hosted Manager status did not answer");
122
126
  const status = reply.data;
123
- if (status.custody === "legacy" && status.agentCount !== 0) {
127
+ if (!currentPackages && status.custody === "legacy" && status.agentCount !== 0) {
124
128
  const names = status.stopImpact?.agents.map((agent) => agent.name);
125
129
  throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `hosted Manager ${manager.instanceId} cannot preserve running agents on this computer during update${names?.length ? ` (${names.join(", ")})` : ""}; restarting it would end them`, { remedy: `save their work; stop each with \`cotal stop <name> --on ${manager.instanceId} --space ${shellPath(manager.space)}\`, then rerun the same update command. To list agents, use \`cotal ps --on ${manager.instanceId} --space ${shellPath(manager.space)}\` (requires admin scope)` });
126
130
  }
131
+ if (currentPackages && status.custody === "legacy" && status.agentCount !== 0) {
132
+ const names = status.stopImpact?.agents.map(agent => agent.name);
133
+ console.log(`hosted Manager ${manager.instanceId}: a later update will require stopping its agents${names?.length ? ` (${names.join(", ")})` : ""}`);
134
+ }
127
135
  console.log(`hosted Manager ${manager.space}: instance ${manager.instanceId} answered; ${status.agentCount ?? "unknown"} seat(s)`);
128
136
  }
129
- // The stock resolver still inspects other locally hosted spaces when one is not selected.
130
- if (typeof flags.space !== "string") {
137
+ // A daemon child is only one form of local custody. Read service and foreground Managers
138
+ // from this install too, including another instance serving the same space.
139
+ let localVerdict = "none";
140
+ if (process.platform === "linux" && typeof flags.creds !== "string") {
141
+ const on = await updateManagerPin(flags, "cotal update");
142
+ for (const manager of localUpdateManagers({ ...flags, ...(on === undefined ? {} : { on }) })) {
143
+ if (active.some(hosted => hosted.instanceId === manager.instanceId))
144
+ continue;
145
+ if (typeof flags.space === "string" && flags.space !== manager.space)
146
+ continue;
147
+ if (typeof flags.server === "string" && brokerAddressKey(flags.server) !== brokerAddressKey(manager.server))
148
+ continue;
149
+ if (on !== undefined && on !== manager.instanceId)
150
+ continue;
151
+ if (manager.process && assertRecordIdentity(manager.process).kind !== "match")
152
+ throw new Error(`local Manager ${manager.instanceId} changed before its continuity read`);
153
+ if (await readManagerContinuity({ ...flags, space: manager.space, server: manager.server, on: manager.instanceId }) === "legacy")
154
+ localVerdict = "legacy";
155
+ }
156
+ }
157
+ if (process.platform !== "linux" && typeof flags.space !== "string") {
131
158
  const { readMeshRegistry } = await import("@cotal-ai/workspace");
132
159
  for (const entry of readMeshRegistry().entries) {
133
- if (active.some((manager) => manager.space === entry.space))
160
+ if (active.some(manager => manager.space === entry.space))
134
161
  continue;
135
162
  if (await updateRuntime.reportRunningManager({ ...flags, space: entry.space }) === "legacy")
136
163
  return "legacy";
137
164
  }
138
165
  }
139
- return "none";
166
+ return localVerdict;
140
167
  }) });
141
- if (args.values.check === true || args.values.auto || args.values.notify || process.exitCode || !daemonObserved)
168
+ if (currentPackages || args.values.check === true || args.values.auto || args.values.notify || process.exitCode || !daemonObserved)
142
169
  return;
143
170
  // The daemon started this update and restarts itself once this process has exited. A restart
144
171
  // asked for from here would stop this process with the rest of the service.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cotal-ai",
3
- "version": "0.162.0",
3
+ "version": "0.163.1",
4
4
  "description": "Cotal — lateral agent coordination over NATS. Run `npx cotal-ai` for the CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -33,28 +33,28 @@
33
33
  "node": ">=22.10"
34
34
  },
35
35
  "dependencies": {
36
- "@cotal-ai/auth": "0.162.0",
37
- "@cotal-ai/cli": "0.162.0",
38
- "@cotal-ai/connector-core": "0.162.0",
39
- "@cotal-ai/core": "0.162.0",
40
- "@cotal-ai/delivery": "0.162.0",
41
- "@cotal-ai/manager": "0.162.0",
42
- "@cotal-ai/registry": "0.162.0",
43
- "@cotal-ai/runtime": "0.162.0",
44
- "@cotal-ai/seat": "0.162.0",
45
- "@cotal-ai/workspace": "0.162.0",
36
+ "@cotal-ai/auth": "0.163.1",
37
+ "@cotal-ai/cli": "0.163.1",
38
+ "@cotal-ai/connector-core": "0.163.1",
39
+ "@cotal-ai/core": "0.163.1",
40
+ "@cotal-ai/delivery": "0.163.1",
41
+ "@cotal-ai/manager": "0.163.1",
42
+ "@cotal-ai/registry": "0.163.1",
43
+ "@cotal-ai/runtime": "0.163.1",
44
+ "@cotal-ai/seat": "0.163.1",
45
+ "@cotal-ai/workspace": "0.163.1",
46
46
  "jose": "^6.2.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@cotal-ai/connector-claude-code": "0.162.0",
50
- "@cotal-ai/connector-codex": "0.162.0",
51
- "@cotal-ai/connector-hermes": "0.162.0",
52
- "@cotal-ai/connector-jcode": "0.162.0",
53
- "@cotal-ai/connector-opencode": "0.162.0",
54
- "@cotal-ai/linear": "0.162.0",
55
- "@cotal-ai/pi": "0.162.0",
49
+ "@cotal-ai/connector-claude-code": "0.163.1",
50
+ "@cotal-ai/connector-codex": "0.163.1",
51
+ "@cotal-ai/connector-hermes": "0.163.1",
52
+ "@cotal-ai/connector-jcode": "0.163.1",
53
+ "@cotal-ai/connector-opencode": "0.163.1",
54
+ "@cotal-ai/linear": "0.163.1",
55
+ "@cotal-ai/pi": "0.163.1",
56
56
  "@cotal-ai/smoke-kit": "0.0.0",
57
- "@cotal-ai/web": "0.162.0",
57
+ "@cotal-ai/web": "0.163.1",
58
58
  "@nats-io/jetstream": "^3.4.0",
59
59
  "@nats-io/transport-node": "^3.4.0",
60
60
  "typescript": "^5.9.3"
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "v": 1,
3
3
  "files": {
4
- "docs-bundle.bin": "c7963a1480354098e4ce4da4c3418b2f4ff2ecf452bf9dfdeb44d0dd4829ce99",
5
- "docs-index.bin": "b61ab564f19fdb007b14229bcac57f206aa8fb04cc7b3773ca1efa9a0d5989b6"
4
+ "docs-bundle.bin": "0d78ebcce12222457a4d90b63db9eb0cb8afcc676740ab6a7d16f67e9682d1ac",
5
+ "docs-index.bin": "c1d373fb23cae5bd6238d5ad3572f029d058b91a195e6421b527f647086d03aa"
6
6
  },
7
7
  "placements": {
8
8
  "claude": [
@@ -9,7 +9,7 @@ declare const WATCH: {
9
9
  * conversation already holds; an approved request is finished with `cotal_connect` and that id. */
10
10
  export interface ApprovalNotice {
11
11
  name: string;
12
- status: "approved" | "denied" | "expired";
12
+ status: "approved" | "denied" | "expired" | "refused";
13
13
  id: string;
14
14
  }
15
15
  export interface AppHostOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"app-host.d.ts","sourceRoot":"","sources":["../src/app-host.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyF,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAkB,KAAK,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAQ9N;mGACmG;AACnG,QAAA,MAAM,KAAK;;;CAAsC,CAAC;AAElD;oGACoG;AACpG,MAAM,WAAW,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;AAEvG,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;IAC9D,+EAA+E;IAC/E,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACvF,oFAAoF;IACpF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C;AAyDD,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAqPxD"}
1
+ {"version":3,"file":"app-host.d.ts","sourceRoot":"","sources":["../src/app-host.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyF,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAkB,KAAK,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAQ9N;mGACmG;AACnG,QAAA,MAAM,KAAK;;;CAAsC,CAAC;AAElD;oGACoG;AACpG,MAAM,WAAW,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;AAEnH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;IAC9D,+EAA+E;IAC/E,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACvF,oFAAoF;IACpF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C;AAyDD,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAkQxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"approval-notice.d.ts","sourceRoot":"","sources":["../src/approval-notice.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,WAAW,QAAmB,CAAC;AAG5C,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQxE;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAUvD"}
1
+ {"version":3,"file":"approval-notice.d.ts","sourceRoot":"","sources":["../src/approval-notice.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,WAAW,QAAmB,CAAC;AAG5C,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQxE;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAYvD"}