@songsid/agend 2.3.5-alpha.11 → 2.3.5-alpha.12

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 (75) hide show
  1. package/dist/accounts-view.d.ts +3 -0
  2. package/dist/accounts-view.js +2 -2
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/auth-api.js +12 -28
  5. package/dist/auth-api.js.map +1 -1
  6. package/dist/backend/claude-code.js +16 -3
  7. package/dist/backend/claude-code.js.map +1 -1
  8. package/dist/backend/credential-profile.d.ts +16 -0
  9. package/dist/backend/credential-profile.js +44 -0
  10. package/dist/backend/credential-profile.js.map +1 -1
  11. package/dist/backend/muse.d.ts +3 -1
  12. package/dist/backend/muse.js +31 -1
  13. package/dist/backend/muse.js.map +1 -1
  14. package/dist/backend/types.d.ts +12 -0
  15. package/dist/backend/types.js.map +1 -1
  16. package/dist/build-provenance.json +1 -1
  17. package/dist/create-host-account.d.ts +17 -0
  18. package/dist/create-host-account.js +47 -0
  19. package/dist/create-host-account.js.map +1 -0
  20. package/dist/daemon.d.ts +23 -0
  21. package/dist/daemon.js +114 -8
  22. package/dist/daemon.js.map +1 -1
  23. package/dist/delivery-outbox.js +7 -0
  24. package/dist/delivery-outbox.js.map +1 -1
  25. package/dist/fleet-manager.d.ts +32 -8
  26. package/dist/fleet-manager.js +146 -31
  27. package/dist/fleet-manager.js.map +1 -1
  28. package/dist/general-knowledge/skills/concepts/SKILL.md +1 -1
  29. package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
  30. package/dist/instance-lifecycle.js +29 -1
  31. package/dist/instance-lifecycle.js.map +1 -1
  32. package/dist/locale.js +7 -7
  33. package/dist/public-web-link.d.ts +5 -0
  34. package/dist/public-web-link.js +8 -0
  35. package/dist/public-web-link.js.map +1 -1
  36. package/dist/settings-api.js +5 -17
  37. package/dist/settings-api.js.map +1 -1
  38. package/dist/signin-keepalive.d.ts +25 -1
  39. package/dist/signin-keepalive.js +44 -1
  40. package/dist/signin-keepalive.js.map +1 -1
  41. package/dist/ui/accounts-view.js +9 -7
  42. package/dist/ui/hub-strings.js +6 -6
  43. package/dist/ui/panel-chat.js +2 -1
  44. package/dist/ui/panel-fleet.js +7 -1
  45. package/dist/ui/panel-settings.js +7 -1
  46. package/dist/ui/settings-access-overview.js +167 -0
  47. package/dist/ui/settings-access-strings.js +1 -1
  48. package/dist/ui/settings-devices.js +5 -5
  49. package/dist/ui/settings-layout.js +3 -1
  50. package/dist/ui/settings-strings.js +8 -8
  51. package/dist/ui/shared/app-shell.js +1 -1
  52. package/dist/ui/shared/app-store.js +2 -0
  53. package/dist/ui/shared/app.css +50 -12
  54. package/dist/ui/shared/chat-render.js +17 -5
  55. package/dist/ui/shared/device-roles.js +1 -1
  56. package/dist/ui/shared/signin.js +130 -43
  57. package/dist/ui/shared/usage-dialog.js +27 -15
  58. package/dist/ui/shared/web-authorize.js +2 -2
  59. package/dist/ui/signin.html +19 -8
  60. package/dist/usage/format-rich.js +1 -1
  61. package/dist/usage/format-rich.js.map +1 -1
  62. package/dist/usage/usage-api.d.ts +8 -2
  63. package/dist/usage/usage-api.js +12 -5
  64. package/dist/usage/usage-api.js.map +1 -1
  65. package/dist/web-api.d.ts +5 -0
  66. package/dist/web-api.js +58 -0
  67. package/dist/web-api.js.map +1 -1
  68. package/dist/web-backend-login.d.ts +2 -0
  69. package/dist/web-backend-login.js.map +1 -1
  70. package/dist/web-remote-access.d.ts +71 -3
  71. package/dist/web-remote-access.js +197 -6
  72. package/dist/web-remote-access.js.map +1 -1
  73. package/package.json +1 -1
  74. package/dist/ui/shared/signin-authenticator.js +0 -60
  75. package/dist/ui/signin-authenticator.html +0 -60
@@ -366,7 +366,7 @@ import { PROVIDER_SECRET_SPECS, PUBLIC_TUNNEL_SECRET_SPEC, providerSecretSpec, p
366
366
  const SELF_RESTART_DEADLINE_MS = 300_000;
367
367
  import { APPLY_FLEET_TARGET, ApplyJobStore, viewOf, } from "./apply-job.js";
368
368
  import { kiroHome } from "./backend/kiro-kas-store.js";
369
- import { CHAT_PROFILE_LOGIN_BACKENDS, credentialHomeSpec, credentialProfileHome, credentialProfileEnv, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
369
+ import { CHAT_PROFILE_LOGIN_BACKENDS, claudeStoreEnded, credentialHomeSpec, credentialProfileHome, credentialProfileEnv, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
370
370
  import { carryClaudeConversation } from "./backend/claude-carry.js";
371
371
  import { classicProfile, mergeBackendOptions, profileKey, profileName, profileOf, readClassicBindings, readClassicBindingsStrict } from "./classic-bindings.js";
372
372
  import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, shortUsage, weeklyUsage } from "./accounts-view.js";
@@ -10114,6 +10114,24 @@ export class FleetManager {
10114
10114
  await this.retireNonceButtons(entry, entry.messageId ?? data.messageId, lastSteps ? renderPublicLinkProgress(lastSteps, performance.now(), outcome) : outcome, data.editClicked, failUrlButtons);
10115
10115
  return true;
10116
10116
  }
10117
+ /**
10118
+ * S-120 (D2a): POST /ui/public-link/close (web-api.ts checks who asks). Closes the open public link — this exposure only,
10119
+ * so a link opened since is left alone — and forgets its remembered owner, as the chat menu's 確定關閉 does. It only closes.
10120
+ * The outside link (#3008) is the owner's switch on this computer: refused (409 outside_link), left open.
10121
+ */
10122
+ async closePublicLinkFromWeb() {
10123
+ const link = this.publicWebLink, id = link?.exposureId;
10124
+ if (!link || !id || this.getPublicWebStatus().state === "closed")
10125
+ return { status: 200, body: { closed: false } };
10126
+ // Whatever its phase: an outside link still starting or reconnecting is the owner's switch too (Fable #3570 P3).
10127
+ const owner = link.ownerOf(id);
10128
+ if (owner && isOutsideLinkOwner(owner))
10129
+ return { status: 409, body: { error: "outside_link" } };
10130
+ const result = await link.close("admin close", id);
10131
+ this.forgetPublicLinkOwner();
10132
+ this.logger.info({ event: "public_link_closed_from_web" }, "Public link closed from Settings");
10133
+ return { status: 200, body: { closed: true, confirmed: result?.confirmed !== false } };
10134
+ }
10117
10135
  /** `/dashboard revoke`: sign out every browser and withdraw any unused code. */
10118
10136
  revokeWebSessions() {
10119
10137
  this.initializeWebSessions();
@@ -19539,9 +19557,7 @@ export class FleetManager {
19539
19557
  const open = this.outsideOn() ? this.publicWebLink?.openSignin() : null;
19540
19558
  const mine = !!open && isOutsideLinkOwner(open.owner);
19541
19559
  const linkStatus = this.outsideOn() ? this.getPublicWebStatus() : null;
19542
- const signinName = manager && manager.who !== HOST_ADMIN_KEY && status?.enrolled
19543
- ? this.signinHandleOf({ adapterId: manager.actor.adapter_id, userId: manager.actor.user_id }) ?? manager.actor.user_id : null;
19544
- return { webOnly: this.isWebOnlyFleet(), here, enrolled: !!status?.enrolled, enrolledAt: status?.enrolledAt ?? null, signinName,
19560
+ return { webOnly: this.isWebOnlyFleet(), here, enrolled: !!status?.enrolled, enrolledAt: status?.enrolledAt ?? null,
19545
19561
  manage: !!manager, codeNeeded: !!manager && !!store && this.authenticatorCodeAsked(manager, store), strict: !!status?.strict,
19546
19562
  outside: this.outsideOn(), pausedForMs: status?.pausedForMs ?? 0,
19547
19563
  link: linkStatus && linkStatus.state !== "closed" ? { ...linkStatus, ...(here && mine ? { url: open.url } : {}), quick: !publicLinkNamedHostname(this.fleetConfig?.web) } : null };
@@ -19786,12 +19802,16 @@ export class FleetManager {
19786
19802
  this.openOutsideLink(OUTSIDE_LINK_RETRY_MS);
19787
19803
  }
19788
19804
  /**
19789
- * #3486 (per admin; auth-api POST /auth/totp): a browser that is not signed in yet signs in as ONE admin, with
19790
- * the code of THAT admin's own authenticator — the same per-admin app their confirmations use. Who is not found by trying the code
19791
- * against everyone: the person types a name (`account`), which resolves — among the admins that have an app and are still admins —
19792
- * to at most one; the page lists nobody. A name that resolves to nobody (no such name, an admin with no app, a name two admins
19793
- * share, one no longer an admin) is answered exactly as a wrong code is, after the same work and the same counting (store.signIn).
19794
- * A web-only fleet has one admin (the host operator): its one app, no name needed.
19805
+ * #3486 (per admin; auth-api POST /auth/totp): a browser that is not signed in yet signs in as ONE admin, with the code of THAT
19806
+ * admin's own authenticator — the same per-admin app their confirmations use.
19807
+ *
19808
+ * **Code only (AGEND-155, the product owner's decision on #3486).** The browser types the 6-digit code and nothing else: the code is
19809
+ * compared with the app of every admin who has one and is still an admin of their connection (WebRemoteAccess.signInByCode — each,
19810
+ * every time, no early stop), and exactly one match signs that admin in. No match, or more than one (nobody is signed in and nothing
19811
+ * is spent), is the one 401 `wrong_code`. The page lists nobody, and nothing in an answer says which admins exist or have an app.
19812
+ * A request that still carries a name (`account`, accepted for compatibility; the UI no longer sends it) is resolved to at most
19813
+ * one admin by that name as before (resolveSignInAdmin) and is held by the per-name and per-admin counts too.
19814
+ * A web-only fleet has one admin (the host operator): its one app, no name needed either way.
19795
19815
  *
19796
19816
  * Where it works: a direct connection (LAN, tailnet, the owner's own proxy — and this computer's own browser) on any fleet; on a
19797
19817
  * chat fleet also a public link (TOTP_SIGNIN_OVER_PUBLIC_LINK, the one switch that takes that back); on a web-only fleet a link
@@ -19804,15 +19824,31 @@ export class FleetManager {
19804
19824
  const store = this.webRemoteAccess(), webOnly = this.isWebOnlyFleet(), { exposureId, peer } = input;
19805
19825
  if (!store || !this.webToken || !this.totpSignInOpen(exposureId, peer))
19806
19826
  return { kind: "closed" };
19807
- const { who, ident } = this.resolveSignInAdmin(store, webOnly, input.account);
19808
- const enrollment = who ? store.enrollmentOf(who) : null;
19809
- const epoch = this.webAuthorityState().epoch, now = Date.now();
19827
+ const webToken = this.webToken, epoch = this.webAuthorityState().epoch, now = Date.now();
19828
+ const named = this.signInNameTyped(input.account);
19810
19829
  // This browser: its cookie id, and on a direct connection the address too (over a link the gateway's peer is the tunnel, so the cookie alone).
19811
19830
  // A browser with a valid mark is counted by the MARK (a thief cannot shed it by dropping the cookie id), else by cookie id and address.
19812
- const mark = findSigninKnownEntry(this.webToken, input.knownCookie, who, enrollment, epoch, now);
19813
- const browser = mark ? { key: createHash("sha256").update(`agend-signin-mark\0${mark}`).digest("hex"), known: true }
19814
- : { key: createHash("sha256").update(`agend-signin-browser\0${input.browser.id}\0${input.browser.address ?? "link"}`).digest("hex"), known: false };
19815
- const v = store.signIn(who, ident, input.code, browser);
19831
+ const byCookie = { key: createHash("sha256").update(`agend-signin-browser\0${input.browser.id}\0${input.browser.address ?? "link"}`).digest("hex"), known: false };
19832
+ const byMark = (entry) => ({ key: createHash("sha256").update(`agend-signin-mark\0${entry}`).digest("hex"), known: true });
19833
+ let v;
19834
+ if (named) {
19835
+ const { who, ident } = this.resolveSignInAdmin(store, webOnly, input.account);
19836
+ const entry = findSigninKnownEntry(webToken, input.knownCookie, who, who ? store.enrollmentOf(who) : null, epoch, now);
19837
+ v = store.signIn(who, ident, input.code, entry ? byMark(entry) : byCookie);
19838
+ }
19839
+ else {
19840
+ // Every admin with an app, whether they are still an admin or not asked of each (no early stop); the marks this browser carries, one per admin they vouch for.
19841
+ const keys = webOnly ? (store.isEnrolled(HOST_ADMIN_KEY) ? [HOST_ADMIN_KEY] : []) : store.adminKeys;
19842
+ const candidates = keys.map(who => {
19843
+ const [adapterId, userId] = who.split("\u0000");
19844
+ return { who, eligible: webOnly || (!!adapterId && !!userId && this.adminGate(userId, adapterId) === "ok") };
19845
+ });
19846
+ const marks = candidates.flatMap(c => {
19847
+ const entry = c.eligible ? findSigninKnownEntry(webToken, input.knownCookie, c.who, store.enrollmentOf(c.who), epoch, now) : null;
19848
+ return entry ? [{ who: c.who, entry }] : [];
19849
+ });
19850
+ v = store.signInByCode(input.code, marks.length ? byMark(marks[0].entry) : byCookie, candidates, marks.map(m => m.who));
19851
+ }
19816
19852
  if (v.kind === "unavailable")
19817
19853
  return v;
19818
19854
  if (v.kind !== "ok") {
@@ -19831,7 +19867,8 @@ export class FleetManager {
19831
19867
  this.logger.debug("Sign-in with an authenticator code refused");
19832
19868
  return { kind: "wrong" };
19833
19869
  }
19834
- if (!who || !enrollment)
19870
+ const who = v.who, enrollment = store.enrollmentOf(who);
19871
+ if (!enrollment)
19835
19872
  return { kind: "wrong" };
19836
19873
  const actor = who === HOST_ADMIN_KEY ? null : (() => { const [adapterId, userId] = who.split("\u0000"); return adapterId && userId ? { adapterId, userId } : null; })();
19837
19874
  if (!actor && who !== HOST_ADMIN_KEY)
@@ -19839,7 +19876,7 @@ export class FleetManager {
19839
19876
  const outside = webOnly && exposureId !== undefined;
19840
19877
  return {
19841
19878
  kind: "ok",
19842
- knownCookie: addSigninKnownDevice(this.webToken, input.knownCookie, who, enrollment, epoch, now),
19879
+ knownCookie: addSigninKnownDevice(webToken, input.knownCookie, who, enrollment, epoch, now),
19843
19880
  session: outside ? { remote: "totp" } : actor ? { owner: actor } : {},
19844
19881
  // Asked again as the session is made: the same app, still an admin, still allowed here.
19845
19882
  commit: (record, label) => {
@@ -19856,6 +19893,10 @@ export class FleetManager {
19856
19893
  },
19857
19894
  };
19858
19895
  }
19896
+ /** Whether the request names an admin (`account`, legacy). Blank or missing: the code stands alone. */
19897
+ signInNameTyped(account) {
19898
+ return typeof account === "string" && account.normalize("NFKC").trim().replace(/^@+/, "") !== "";
19899
+ }
19859
19900
  /** The platform handle (Discord / Telegram user name) an account last signed in to the web with, exactly as the platform gave it; undefined when none is known. */
19860
19901
  signinHandleOf(owner) {
19861
19902
  const handle = this.webPrefs.profile(webPersonKey(owner))?.platformName;
@@ -21949,7 +21990,7 @@ export class FleetManager {
21949
21990
  const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
21950
21991
  const identity = this.signInIdentity(backend, profile);
21951
21992
  rows.push({ profile, state: (login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown"), signIn,
21952
- ...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}) });
21993
+ ...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}), ...(this.claudeSignInEnded(backend, profile) ? { reconnect: true } : {}) });
21953
21994
  }
21954
21995
  diskProfiles.set(backend, rows);
21955
21996
  }
@@ -22048,6 +22089,7 @@ export class FleetManager {
22048
22089
  * admitCredentialUse) from the configuration it launched with — never re-resolved against today's defaults. An entry
22049
22090
  * whose start ended without a daemon, or whose daemon is gone, is dropped when next read.
22050
22091
  */
22092
+ // M-2825 review: with the sign-in as launched (backend, profile as written) — what is in use until the agent restarts.
22051
22093
  credentialLeases = new Map();
22052
22094
  /** #3292 review: Keep sign-in alive runs in flight, by sign-in: a start on that sign-in waits for its end. */
22053
22095
  keepAliveRenewing = new Map();
@@ -22057,14 +22099,15 @@ export class FleetManager {
22057
22099
  * Daemon's clone of that config hands its CLI. Never today's defaults: an older config object keeps its own.
22058
22100
  */
22059
22101
  launchCredentialKey(config, backend) {
22060
- let profile = null;
22102
+ return this.credentialKey(backend, this.launchCredentialProfile(config, backend));
22103
+ }
22104
+ launchCredentialProfile(config, backend) {
22061
22105
  try {
22062
- profile = resolveCredentialProfile(config.backend_options?.[backend]);
22106
+ return resolveCredentialProfile(config.backend_options?.[backend]);
22063
22107
  }
22064
22108
  catch {
22065
- profile = null;
22109
+ return null;
22066
22110
  }
22067
- return this.credentialKey(backend, profile);
22068
22111
  }
22069
22112
  /**
22070
22113
  * #3313 review r2: failed starts whose CLI was not proven gone keep holding their sign-in (across a retry of the same
@@ -22103,7 +22146,7 @@ export class FleetManager {
22103
22146
  assertCurrent();
22104
22147
  key = this.launchCredentialKey(config, backend);
22105
22148
  }
22106
- const lease = { key, starting: true };
22149
+ const lease = { key, starting: true, backend, profile: this.launchCredentialProfile(config, backend) };
22107
22150
  this.credentialLeases.set(name, lease);
22108
22151
  const drop = () => { if (this.credentialLeases.get(name) === lease)
22109
22152
  this.credentialLeases.delete(name); };
@@ -22112,7 +22155,7 @@ export class FleetManager {
22112
22155
  release: drop,
22113
22156
  current: c => this.launchCredentialKey(c, backend) === key,
22114
22157
  // A failed start whose CLI may still run: the sign-in stays held (by itself, not by the agent's name) until it is seen gone.
22115
- unknownEnd: ended => { drop(); this.credentialOrphans.set(Symbol(name), { key, ended }); this.recheckCredentialOrphans(); },
22158
+ unknownEnd: ended => { drop(); this.credentialOrphans.set(Symbol(name), { key, ended, backend, profile: lease.profile }); this.recheckCredentialOrphans(); },
22116
22159
  };
22117
22160
  }
22118
22161
  /**
@@ -22209,14 +22252,69 @@ export class FleetManager {
22209
22252
  const ka = this.signInKeepAlive;
22210
22253
  if (!ka)
22211
22254
  return [];
22212
- const day = (ms) => ms === undefined ? "?" : new Date(ms).toISOString().slice(0, 10);
22255
+ // M-2825: in the host's own time (the people reading it are where the fleet runs; a UTC day was a day off near midnight
22256
+ // in Taipei), with the hour for an end date — a day's notice needs to say when that day ends.
22257
+ const p2 = (n) => String(n).padStart(2, "0");
22258
+ const day = (ms, at = false) => {
22259
+ if (ms === undefined)
22260
+ return "?";
22261
+ const d = new Date(ms);
22262
+ return `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())}${at ? ` ${p2(d.getHours())}:${p2(d.getMinutes())}` : ""}`;
22263
+ };
22213
22264
  const owner = this.worlds.keys().next().value;
22214
- return ka.attention().map(a => ({
22265
+ return ka.attention(this.signInsInUse()).map(a => ({
22215
22266
  backend: a.backend, profile: a.profile, kind: a.kind, since: a.since, signIn: dashboardSignInSupported(a.backend, a.profile),
22216
22267
  ...(owner ? { owner } : {}),
22217
- detail: t(`keepalive.${a.kind}`, BACKEND_LABELS[a.backend] ?? a.backend, a.profile ?? t("keepalive.default_name"), day(a.kind === "transient" ? a.failedSince ?? a.since : a.endsAt)),
22268
+ detail: t(`keepalive.${a.kind}`, BACKEND_LABELS[a.backend] ?? a.backend, a.profile ?? t("keepalive.default_name"), a.kind === "transient" ? day(a.failedSince ?? a.since) : day(a.endsAt, a.kind === "ending" || a.kind === "ended")),
22218
22269
  }));
22219
22270
  }
22271
+ /**
22272
+ * M-2825: the host sign-ins in use, once each — whose end date is warned about even when it is not kept alive:
22273
+ * - each agent's and ClassicBot room's as configured (accountUses: a paired computer's agents use that computer's own);
22274
+ * - #3577 review P2: the one each host agent is starting or running on AS LAUNCHED (its lease; a failed start whose CLI
22275
+ * may still run; a running agent with no lease, by its own launch snapshot) — a profile saved but not yet applied
22276
+ * leaves the old one in use until the restart, as keepAliveInUse() counts it.
22277
+ */
22278
+ signInsInUse() {
22279
+ const seen = new Set(), out = [];
22280
+ const add = (backend, profile) => {
22281
+ if (!backend)
22282
+ return;
22283
+ const key = this.credentialKey(backend, profile ?? null);
22284
+ if (!seen.has(key)) {
22285
+ seen.add(key);
22286
+ out.push({ backend, profile: profile ?? null });
22287
+ }
22288
+ };
22289
+ try {
22290
+ const uses = this.accountUses();
22291
+ for (const u of [...uses.agents, ...uses.classic])
22292
+ add(u.backend, u.profile);
22293
+ }
22294
+ catch { /* the launched ones below still count */ }
22295
+ for (const [name, lease] of this.credentialLeases)
22296
+ if (lease.starting || this.daemons?.has(name))
22297
+ add(lease.backend, lease.profile);
22298
+ for (const o of this.credentialOrphans.values())
22299
+ add(o.backend, o.profile);
22300
+ const defaultBackend = this.fleetConfig?.defaults?.backend ?? "claude-code";
22301
+ for (const [name, daemon] of this.daemons ?? []) {
22302
+ if (this.credentialLeases.has(name))
22303
+ continue;
22304
+ let snap;
22305
+ try {
22306
+ snap = daemon.getConfigSnapshot?.();
22307
+ }
22308
+ catch {
22309
+ snap = undefined;
22310
+ }
22311
+ if (!snap || isWindowsInstance(snap))
22312
+ continue;
22313
+ const backend = snap.backend ?? defaultBackend;
22314
+ add(backend, this.launchCredentialProfile(snap, backend));
22315
+ }
22316
+ return out;
22317
+ }
22220
22318
  /** #3292: Settings → Accounts → Keep sign-in alive (POST /ui/accounts/keep-alive). `by`: the session's label, for the fleet log. */
22221
22319
  setAccountKeepAlive(backend, profile, enabled, fallback, by) {
22222
22320
  const r = this.keepAliveService().set(backend, profile, enabled, fallback);
@@ -22446,14 +22544,30 @@ export class FleetManager {
22446
22544
  this.logger.info({ backend, profile: shown, by, refused: result.error }, "Account sign-out refused");
22447
22545
  return result;
22448
22546
  }
22547
+ /** M-2825: a host Claude sign-in whose own file says it is over (credential-profile.ts claudeStoreEnded); false for other CLIs. */
22548
+ claudeSignInEnded(backend, profile) {
22549
+ if (backend !== "claude-code")
22550
+ return false;
22551
+ try {
22552
+ const home = profile ? credentialProfileStoreHome(this.dataDir, backend, profile) : credentialHomeSpec(backend)?.sharedRoot();
22553
+ return !!home && claudeStoreEnded(home);
22554
+ }
22555
+ catch {
22556
+ return false;
22557
+ }
22558
+ }
22449
22559
  backendSignInTargets() {
22450
22560
  const out = [];
22451
22561
  for (const row of this.backendAvailabilityRows()) {
22452
22562
  const flow = LOGIN_FLOWS[row.backend];
22453
22563
  const install = BACKEND_INSTALLATION_INFO[row.backend]?.install;
22564
+ // M-2825: `claude auth status` says loggedIn after a refused refresh and past the sign-in's end date — the file says
22565
+ // whether it is over, and then it is not signed in (never the other way: the file can't vouch for a login).
22566
+ const ended = row.state === "usable" && this.claudeSignInEnded(row.backend, null);
22454
22567
  out.push({
22455
22568
  // Not installed or too old: signing in would not help — the row says how to install (or update) it instead.
22456
- backend: row.backend, state: row.state, signIn: row.state !== "not_installed" && row.state !== "too_old" && dashboardSignInSupported(row.backend),
22569
+ backend: row.backend, state: ended ? "not_signed_in" : row.state, ...(ended ? { reconnect: true } : {}),
22570
+ signIn: row.state !== "not_installed" && row.state !== "too_old" && dashboardSignInSupported(row.backend),
22457
22571
  ...(flow?.remoteLogin === "unsupported" ? { hostCommand: flow.command } : {}),
22458
22572
  ...(row.state === "not_installed" && install ? { install } : {}),
22459
22573
  ...(row.state === "too_old" && install ? { update: install } : {}),
@@ -22475,7 +22589,8 @@ export class FleetManager {
22475
22589
  const signIn = dashboardSignInSupported(backend, profile);
22476
22590
  const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
22477
22591
  out.push({ backend, profile, state: login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown", signIn,
22478
- ...(hostCommand ? { hostCommand } : {}), ...(this.signInIdentity(backend, profile) ? { identity: this.signInIdentity(backend, profile) } : {}) });
22592
+ ...(hostCommand ? { hostCommand } : {}), ...(this.signInIdentity(backend, profile) ? { identity: this.signInIdentity(backend, profile) } : {}),
22593
+ ...(this.claudeSignInEnded(backend, profile) ? { reconnect: true } : {}) });
22479
22594
  }
22480
22595
  return out;
22481
22596
  }