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

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 (168) hide show
  1. package/THIRD_PARTY_NOTICES.md +4 -0
  2. package/dist/accounts-view.d.ts +3 -0
  3. package/dist/accounts-view.js +2 -2
  4. package/dist/accounts-view.js.map +1 -1
  5. package/dist/agent-workspace.d.ts +1 -2
  6. package/dist/agent-workspace.js +8 -29
  7. package/dist/agent-workspace.js.map +1 -1
  8. package/dist/auth-api.js +15 -29
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/claude-code.js +16 -3
  11. package/dist/backend/claude-code.js.map +1 -1
  12. package/dist/backend/codex.d.ts +7 -14
  13. package/dist/backend/codex.js +25 -29
  14. package/dist/backend/codex.js.map +1 -1
  15. package/dist/backend/credential-profile.d.ts +16 -0
  16. package/dist/backend/credential-profile.js +44 -0
  17. package/dist/backend/credential-profile.js.map +1 -1
  18. package/dist/backend/grok-mcp.d.ts +5 -0
  19. package/dist/backend/grok-mcp.js +221 -0
  20. package/dist/backend/grok-mcp.js.map +1 -0
  21. package/dist/backend/grok.d.ts +0 -10
  22. package/dist/backend/grok.js +5 -82
  23. package/dist/backend/grok.js.map +1 -1
  24. package/dist/backend/muse.d.ts +3 -1
  25. package/dist/backend/muse.js +31 -1
  26. package/dist/backend/muse.js.map +1 -1
  27. package/dist/backend/types.d.ts +18 -1
  28. package/dist/backend/types.js.map +1 -1
  29. package/dist/build-provenance.json +1 -1
  30. package/dist/cli.js +18 -0
  31. package/dist/cli.js.map +1 -1
  32. package/dist/codex-pane-ownership.d.ts +13 -0
  33. package/dist/codex-pane-ownership.js +192 -0
  34. package/dist/codex-pane-ownership.js.map +1 -0
  35. package/dist/create-host-account.d.ts +17 -0
  36. package/dist/create-host-account.js +47 -0
  37. package/dist/create-host-account.js.map +1 -0
  38. package/dist/daemon.d.ts +25 -0
  39. package/dist/daemon.js +203 -16
  40. package/dist/daemon.js.map +1 -1
  41. package/dist/delivery-outbox.js +7 -0
  42. package/dist/delivery-outbox.js.map +1 -1
  43. package/dist/fleet-manager.d.ts +40 -9
  44. package/dist/fleet-manager.js +198 -47
  45. package/dist/fleet-manager.js.map +1 -1
  46. package/dist/general-knowledge/skills/concepts/SKILL.md +1 -1
  47. package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
  48. package/dist/hub/client.d.ts +1 -1
  49. package/dist/hub/client.js +11 -0
  50. package/dist/hub/client.js.map +1 -1
  51. package/dist/hub/compose/member.d.ts +2 -2
  52. package/dist/hub/compose/member.js +11 -3
  53. package/dist/hub/compose/member.js.map +1 -1
  54. package/dist/hub/member/exposure-api.d.ts +2 -0
  55. package/dist/hub/member/exposure-api.js +4 -2
  56. package/dist/hub/member/exposure-api.js.map +1 -1
  57. package/dist/hub/member/pairing-api.d.ts +2 -2
  58. package/dist/hub/member/pairing-api.js +2 -2
  59. package/dist/hub/member/pairing-api.js.map +1 -1
  60. package/dist/hub/server.js +8 -0
  61. package/dist/hub/server.js.map +1 -1
  62. package/dist/hub-pairing-summary.d.ts +3 -1
  63. package/dist/hub-pairing-summary.js +6 -3
  64. package/dist/hub-pairing-summary.js.map +1 -1
  65. package/dist/instance-lifecycle.js +29 -1
  66. package/dist/instance-lifecycle.js.map +1 -1
  67. package/dist/locale.js +13 -9
  68. package/dist/locale.js.map +1 -1
  69. package/dist/public-web-link.d.ts +5 -0
  70. package/dist/public-web-link.js +8 -0
  71. package/dist/public-web-link.js.map +1 -1
  72. package/dist/runtime-client-store.js +5 -0
  73. package/dist/runtime-client-store.js.map +1 -1
  74. package/dist/runtime-pane-private.d.ts +2 -0
  75. package/dist/runtime-pane-private.js +25 -0
  76. package/dist/runtime-pane-private.js.map +1 -1
  77. package/dist/runtime-pane-private.ps1 +74 -7
  78. package/dist/selection-card.d.ts +4 -3
  79. package/dist/selection-card.js +2 -1
  80. package/dist/selection-card.js.map +1 -1
  81. package/dist/settings-api.js +5 -17
  82. package/dist/settings-api.js.map +1 -1
  83. package/dist/settings-change.d.ts +2 -0
  84. package/dist/settings-change.js +74 -31
  85. package/dist/settings-change.js.map +1 -1
  86. package/dist/settings-confirmation.d.ts +23 -0
  87. package/dist/settings-confirmation.js +13 -2
  88. package/dist/settings-confirmation.js.map +1 -1
  89. package/dist/settings-effect.d.ts +4 -0
  90. package/dist/settings-effect.js +14 -14
  91. package/dist/settings-effect.js.map +1 -1
  92. package/dist/settings-http-confirmation.d.ts +3 -1
  93. package/dist/settings-http-confirmation.js +12 -7
  94. package/dist/settings-http-confirmation.js.map +1 -1
  95. package/dist/settings-summary.d.ts +24 -0
  96. package/dist/settings-summary.js +42 -0
  97. package/dist/settings-summary.js.map +1 -0
  98. package/dist/signin-keepalive.d.ts +25 -1
  99. package/dist/signin-keepalive.js +44 -1
  100. package/dist/signin-keepalive.js.map +1 -1
  101. package/dist/transcript-delta-reader.d.ts +9 -1
  102. package/dist/transcript-delta-reader.js +37 -8
  103. package/dist/transcript-delta-reader.js.map +1 -1
  104. package/dist/ui/accounts-view.js +9 -7
  105. package/dist/ui/agent-details-settings.js +253 -0
  106. package/dist/ui/agent-instructions-field.js +69 -0
  107. package/dist/ui/agent-page-strings.js +148 -0
  108. package/dist/ui/chat-quote.js +12 -17
  109. package/dist/ui/hub-client.js +1 -1
  110. package/dist/ui/hub-company-join-strings.js +1 -1
  111. package/dist/ui/hub-company-join.js +7 -0
  112. package/dist/ui/hub-strings.js +10 -6
  113. package/dist/ui/native-instance-settings.js +47 -14
  114. package/dist/ui/panel-chat.js +2 -1
  115. package/dist/ui/panel-details.js +38 -14
  116. package/dist/ui/panel-fleet.js +9 -3
  117. package/dist/ui/panel-settings.js +17 -8
  118. package/dist/ui/settings-access-overview.js +188 -0
  119. package/dist/ui/settings-access-strings.js +1 -1
  120. package/dist/ui/settings-confirm.js +5 -5
  121. package/dist/ui/settings-devices.js +5 -5
  122. package/dist/ui/settings-dialogs.js +208 -100
  123. package/dist/ui/settings-hub-company-join.js +69 -14
  124. package/dist/ui/settings-hub.js +13 -5
  125. package/dist/ui/settings-layout.js +1 -1
  126. package/dist/ui/settings-model.js +15 -0
  127. package/dist/ui/settings-strings.js +8 -8
  128. package/dist/ui/shared/access-overview.css +48 -0
  129. package/dist/ui/shared/app-i18n.js +2 -2
  130. package/dist/ui/shared/app-shell.js +145 -4
  131. package/dist/ui/shared/app-store.js +2 -0
  132. package/dist/ui/shared/app.css +69 -7
  133. package/dist/ui/shared/chat-render.js +17 -5
  134. package/dist/ui/shared/device-roles.js +1 -1
  135. package/dist/ui/shared/instance-nav.js +5 -1
  136. package/dist/ui/shared/signin.js +130 -43
  137. package/dist/ui/shared/usage-dialog.js +27 -15
  138. package/dist/ui/shared/view-strings.js +2 -0
  139. package/dist/ui/shared/web-authorize.js +2 -2
  140. package/dist/ui/signin.html +19 -8
  141. package/dist/update-dispatch.d.ts +50 -0
  142. package/dist/update-dispatch.js +58 -2
  143. package/dist/update-dispatch.js.map +1 -1
  144. package/dist/usage/format-rich.js +1 -1
  145. package/dist/usage/format-rich.js.map +1 -1
  146. package/dist/usage/usage-api.d.ts +8 -2
  147. package/dist/usage/usage-api.js +12 -5
  148. package/dist/usage/usage-api.js.map +1 -1
  149. package/dist/web-api.d.ts +5 -0
  150. package/dist/web-api.js +58 -0
  151. package/dist/web-api.js.map +1 -1
  152. package/dist/web-backend-login.d.ts +2 -0
  153. package/dist/web-backend-login.js.map +1 -1
  154. package/dist/web-remote-access.d.ts +71 -3
  155. package/dist/web-remote-access.js +197 -6
  156. package/dist/web-remote-access.js.map +1 -1
  157. package/dist/web-session.d.ts +4 -2
  158. package/dist/web-session.js +5 -2
  159. package/dist/web-session.js.map +1 -1
  160. package/dist/workspace-file-policy.d.ts +2 -0
  161. package/dist/workspace-file-policy.js +31 -0
  162. package/dist/workspace-file-policy.js.map +1 -0
  163. package/dist/workspace-follow.js +2 -1
  164. package/dist/workspace-follow.js.map +1 -1
  165. package/package.json +2 -2
  166. package/templates/runtime-assets/runtime-pane-private.ps1 +74 -7
  167. package/dist/ui/shared/signin-authenticator.js +0 -60
  168. package/dist/ui/signin-authenticator.html +0 -60
@@ -1,3 +1,4 @@
1
+ import { settingsSummary, translatedSummary } from "./settings-summary.js";
1
2
  import { readInstalledBuild } from "./build-provenance.js";
2
3
  import { buildNativeFleetInstructions } from "./instructions.js";
3
4
  import { GENERAL_ROLE_INSTRUCTIONS } from "./general-role.js";
@@ -307,6 +308,7 @@ import { isRemovedBackend, removedBackendMessage } from "./backend/removed.js";
307
308
  import { presentationState, interactionSummary, sameInteractionOwner } from "./interaction-observation.js";
308
309
  import { describeSelfOom } from "./session-oom.js";
309
310
  import { assertNoSessionOomStop, readSessionOomStop, captureSessionOomRetry, clearSessionOomStopForRetry, SessionOomStoppedError, sessionOomStopHint } from "./session-oom-stop.js";
311
+ import { redactSecrets } from "./tool-progress.js";
310
312
  import { idleGateTimeoutLog } from "./idle-gate-log.js";
311
313
  import { DEFAULT_STUCK_TIMEOUT_MS, readLastInboundAt } from "./daemon.js";
312
314
  import { clearPausedMarker, readPausedAt, readPauseReason, writePausedMarker } from "./pause-marker.js";
@@ -366,7 +368,7 @@ import { PROVIDER_SECRET_SPECS, PUBLIC_TUNNEL_SECRET_SPEC, providerSecretSpec, p
366
368
  const SELF_RESTART_DEADLINE_MS = 300_000;
367
369
  import { APPLY_FLEET_TARGET, ApplyJobStore, viewOf, } from "./apply-job.js";
368
370
  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";
371
+ import { CHAT_PROFILE_LOGIN_BACKENDS, claudeStoreEnded, credentialHomeSpec, credentialProfileHome, credentialProfileEnv, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
370
372
  import { carryClaudeConversation } from "./backend/claude-carry.js";
371
373
  import { classicProfile, mergeBackendOptions, profileKey, profileName, profileOf, readClassicBindings, readClassicBindingsStrict } from "./classic-bindings.js";
372
374
  import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, shortUsage, weeklyUsage } from "./accounts-view.js";
@@ -634,7 +636,8 @@ const WEB_ONLY_REPLY_SINK = {
634
636
  /**
635
637
  * Where an instance-health prompt (hang, clean exit, interactive prompt) is posted on a fleet with no chat platform:
636
638
  * nowhere but the dashboard (#1307 item 6). Posting "succeeds" with an id of its own, so the prompt is armed and
637
- * offered on the web exactly as a platform prompt is; there are no platform buttons to edit afterwards, and the
639
+ * offered on the web exactly as a platform prompt is; also used for CLI dialogs belonging to public Classic rooms
640
+ * (#3334). There are no platform buttons to edit afterwards, and the
638
641
  * outcome reaches the page through prompt_resolved as for any web-answered prompt.
639
642
  */
640
643
  const WEB_ONLY_PROMPT_SINK = {
@@ -1675,7 +1678,7 @@ export class FleetManager {
1675
1678
  if (input.target.location === "host") {
1676
1679
  if (!record)
1677
1680
  throw Error("General's saved host location is unavailable");
1678
- return { input, connections, summary: [t("general_location.confirm_host"), t("general_location.history")] };
1681
+ return { input, connections, ...settingsSummary([translatedSummary("general_location.confirm_host"), translatedSummary("general_location.history")]) };
1679
1682
  }
1680
1683
  const active = record?.windows.find(row => row.id === record.active);
1681
1684
  if (!record?.pending && record?.hold !== "start" && active?.machineId === input.target.machineId && active.cli === input.target.cli)
@@ -1686,7 +1689,7 @@ export class FleetManager {
1686
1689
  const provider = input.target.cli;
1687
1690
  if (!machine.inventory?.clis.some(cli => cli.id === provider && cli.runnable))
1688
1691
  throw Error("The chosen Windows CLI is unavailable");
1689
- return { input, connections, summary: [t("general_location.confirm_windows", settingsDisplay(machine.name)), t("general_location.history")] };
1692
+ return { input, connections, ...settingsSummary([translatedSummary("general_location.confirm_windows", settingsDisplay(machine.name)), translatedSummary("general_location.history")]) };
1690
1693
  }
1691
1694
  /** All entry points, including automatic native recovery, must respect an interrupted binding switch. */
1692
1695
  assertGeneralBindingStart(name, config) {
@@ -2184,7 +2187,7 @@ export class FleetManager {
2184
2187
  attachAttention: read => this.attachHubExecutionAttention(read),
2185
2188
  attachPairingNotices: read => { this.hubPairingNotices = read; },
2186
2189
  pokeAttention: () => this.needsYou?.poke(),
2187
- linkState: state => { this.hubMemberLink = state; },
2190
+ linkState: (state, digest) => { this.hubMemberLink = state; this.hubMemberLinkBinding = digest ?? null; },
2188
2191
  },
2189
2192
  });
2190
2193
  // Stop began during the import: it holds this promise and closes the runtime; do not hand it out again.
@@ -2215,8 +2218,9 @@ export class FleetManager {
2215
2218
  home: this.dataDir,
2216
2219
  notices: () => this.hubPairingNotices?.() ?? [],
2217
2220
  enabled: () => this.rawFleetConfig?.hub_member?.enabled === true,
2218
- link: () => (this.hubMemberLink === "online" ? "online" : "offline"),
2219
- hold: () => (this.hubMemberLink === "revoked" ? "revoked" : null),
2221
+ link: digest => (digest === this.hubMemberLinkBinding && this.hubMemberLink === "online" ? "online" : "offline"),
2222
+ hold: digest => digest === this.hubMemberLinkBinding
2223
+ ? this.hubMemberLink === "revoked" ? "revoked" : this.hubMemberLink === "rejected" ? "rejected" : null : null,
2220
2224
  // Disconnect: stop the member client now (the runtime re-composes from the saved binding, fencing first).
2221
2225
  fence: () => { void this.hubRuntime?.refresh(); },
2222
2226
  // A claim saved, a disconnect tombstone or a cancel: re-compose the member side for the new binding.
@@ -2569,6 +2573,7 @@ export class FleetManager {
2569
2573
  hubMemberBinding = null;
2570
2574
  /** The member link as the "Connect to a Hub" view shows it (S5's client lifecycle). */
2571
2575
  hubMemberLink = "offline";
2576
+ hubMemberLinkBinding = null;
2572
2577
  /** OutboundContext: the Hub representative's answer hook (null: no member service running, or not a Hub answer). */
2573
2578
  hubReport(input) {
2574
2579
  return this.hubReports?.(input) ?? null;
@@ -3540,6 +3545,7 @@ export class FleetManager {
3540
3545
  directAgentCreation: true,
3541
3546
  directHostInstall: true,
3542
3547
  directCompanyJoin: true,
3548
+ companyJoinPolicy: req => this.settingsCompanyJoinAllowed(req),
3543
3549
  job: async (id) => {
3544
3550
  const settlement = this.settingsJobSettlements.get(id);
3545
3551
  if (!settlement)
@@ -3619,6 +3625,11 @@ export class FleetManager {
3619
3625
  },
3620
3626
  };
3621
3627
  }
3628
+ /** Company Start is the signed-in admin’s consent; a personal enforced remote code still applies. */
3629
+ settingsCompanyJoinAllowed(req) {
3630
+ const { role } = this.settingsRole(req, { ignoreSwitch: true });
3631
+ return role.ok && (role.onHost || !this.strictFor(role.actor));
3632
+ }
3622
3633
  /**
3623
3634
  * AGEND-122 (Prism P2): whether the ordinary New Agent shortcut — created at once, web-confirmed, with no held change — is open to
3624
3635
  * this request. It is the same policy as Apply now: refused where "Only this computer can authorize" is on and this is not the
@@ -3759,9 +3770,19 @@ export class FleetManager {
3759
3770
  * that opens a link is never confirmed over a link (the public gateway, bound by the gateway itself, never by a header), the
3760
3771
  * code or not. The code is the authority; the session only carries it.
3761
3772
  */
3773
+ /** Only the server-attested company Start carries its own policy, bound to the original live private cookie. */
3774
+ settingsCodeRole(req, proof) {
3775
+ if (proof?.kind !== "company-start")
3776
+ return this.settingsRole(req);
3777
+ const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
3778
+ if (auth.kind !== "ok" || gatewayRequestContext(req) || !proof.current(auth.session.idHash))
3779
+ return { role: { ok: false, reason: "not_session" }, handle: null };
3780
+ return this.settingsRole(req, { ignoreSwitch: true });
3781
+ }
3762
3782
  settingsCodeSession(store, req, id) {
3783
+ const proof = store.codePolicy(id);
3763
3784
  const check = (asking) => {
3764
- const { role, handle } = this.settingsRole(req);
3785
+ const { role, handle } = this.settingsCodeRole(req, proof);
3765
3786
  if (!role.ok || !handle || role.onHost)
3766
3787
  return null;
3767
3788
  if (asking && !this.strictFor(role.actor))
@@ -3810,7 +3831,7 @@ export class FleetManager {
3810
3831
  return webPeerOf(req) !== "loopback";
3811
3832
  }
3812
3833
  settingsTotpState(store, req, id) {
3813
- const { role } = this.settingsRole(req);
3834
+ const { role } = this.settingsCodeRole(req, store.codePolicy(id));
3814
3835
  // The owner turned on "Only this computer can authorize": a page that is not on this computer is told so, in plain words.
3815
3836
  if (!role.ok)
3816
3837
  return role.reason === "loopback_only" ? "host_only" : null;
@@ -10114,6 +10135,24 @@ export class FleetManager {
10114
10135
  await this.retireNonceButtons(entry, entry.messageId ?? data.messageId, lastSteps ? renderPublicLinkProgress(lastSteps, performance.now(), outcome) : outcome, data.editClicked, failUrlButtons);
10115
10136
  return true;
10116
10137
  }
10138
+ /**
10139
+ * S-120 (D2a): POST /ui/public-link/close (web-api.ts checks who asks). Closes the open public link — this exposure only,
10140
+ * so a link opened since is left alone — and forgets its remembered owner, as the chat menu's 確定關閉 does. It only closes.
10141
+ * The outside link (#3008) is the owner's switch on this computer: refused (409 outside_link), left open.
10142
+ */
10143
+ async closePublicLinkFromWeb() {
10144
+ const link = this.publicWebLink, id = link?.exposureId;
10145
+ if (!link || !id || this.getPublicWebStatus().state === "closed")
10146
+ return { status: 200, body: { closed: false } };
10147
+ // Whatever its phase: an outside link still starting or reconnecting is the owner's switch too (Fable #3570 P3).
10148
+ const owner = link.ownerOf(id);
10149
+ if (owner && isOutsideLinkOwner(owner))
10150
+ return { status: 409, body: { error: "outside_link" } };
10151
+ const result = await link.close("admin close", id);
10152
+ this.forgetPublicLinkOwner();
10153
+ this.logger.info({ event: "public_link_closed_from_web" }, "Public link closed from Settings");
10154
+ return { status: 200, body: { closed: true, confirmed: result?.confirmed !== false } };
10155
+ }
10117
10156
  /** `/dashboard revoke`: sign out every browser and withdraw any unused code. */
10118
10157
  revokeWebSessions() {
10119
10158
  this.initializeWebSessions();
@@ -19539,9 +19578,7 @@ export class FleetManager {
19539
19578
  const open = this.outsideOn() ? this.publicWebLink?.openSignin() : null;
19540
19579
  const mine = !!open && isOutsideLinkOwner(open.owner);
19541
19580
  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,
19581
+ return { webOnly: this.isWebOnlyFleet(), here, enrolled: !!status?.enrolled, enrolledAt: status?.enrolledAt ?? null,
19545
19582
  manage: !!manager, codeNeeded: !!manager && !!store && this.authenticatorCodeAsked(manager, store), strict: !!status?.strict,
19546
19583
  outside: this.outsideOn(), pausedForMs: status?.pausedForMs ?? 0,
19547
19584
  link: linkStatus && linkStatus.state !== "closed" ? { ...linkStatus, ...(here && mine ? { url: open.url } : {}), quick: !publicLinkNamedHostname(this.fleetConfig?.web) } : null };
@@ -19786,12 +19823,16 @@ export class FleetManager {
19786
19823
  this.openOutsideLink(OUTSIDE_LINK_RETRY_MS);
19787
19824
  }
19788
19825
  /**
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.
19826
+ * #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
19827
+ * admin's own authenticator — the same per-admin app their confirmations use.
19828
+ *
19829
+ * **Code only (AGEND-155, the product owner's decision on #3486).** The browser types the 6-digit code and nothing else: the code is
19830
+ * compared with the app of every admin who has one and is still an admin of their connection (WebRemoteAccess.signInByCode — each,
19831
+ * 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
19832
+ * 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.
19833
+ * A request that still carries a name (`account`, accepted for compatibility; the UI no longer sends it) is resolved to at most
19834
+ * one admin by that name as before (resolveSignInAdmin) and is held by the per-name and per-admin counts too.
19835
+ * A web-only fleet has one admin (the host operator): its one app, no name needed either way.
19795
19836
  *
19796
19837
  * 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
19838
  * 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 +19845,31 @@ export class FleetManager {
19804
19845
  const store = this.webRemoteAccess(), webOnly = this.isWebOnlyFleet(), { exposureId, peer } = input;
19805
19846
  if (!store || !this.webToken || !this.totpSignInOpen(exposureId, peer))
19806
19847
  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();
19848
+ const webToken = this.webToken, epoch = this.webAuthorityState().epoch, now = Date.now();
19849
+ const named = this.signInNameTyped(input.account);
19810
19850
  // 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
19851
  // 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);
19852
+ const byCookie = { key: createHash("sha256").update(`agend-signin-browser\0${input.browser.id}\0${input.browser.address ?? "link"}`).digest("hex"), known: false };
19853
+ const byMark = (entry) => ({ key: createHash("sha256").update(`agend-signin-mark\0${entry}`).digest("hex"), known: true });
19854
+ let v;
19855
+ if (named) {
19856
+ const { who, ident } = this.resolveSignInAdmin(store, webOnly, input.account);
19857
+ const entry = findSigninKnownEntry(webToken, input.knownCookie, who, who ? store.enrollmentOf(who) : null, epoch, now);
19858
+ v = store.signIn(who, ident, input.code, entry ? byMark(entry) : byCookie);
19859
+ }
19860
+ else {
19861
+ // 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.
19862
+ const keys = webOnly ? (store.isEnrolled(HOST_ADMIN_KEY) ? [HOST_ADMIN_KEY] : []) : store.adminKeys;
19863
+ const candidates = keys.map(who => {
19864
+ const [adapterId, userId] = who.split("\u0000");
19865
+ return { who, eligible: webOnly || (!!adapterId && !!userId && this.adminGate(userId, adapterId) === "ok") };
19866
+ });
19867
+ const marks = candidates.flatMap(c => {
19868
+ const entry = c.eligible ? findSigninKnownEntry(webToken, input.knownCookie, c.who, store.enrollmentOf(c.who), epoch, now) : null;
19869
+ return entry ? [{ who: c.who, entry }] : [];
19870
+ });
19871
+ v = store.signInByCode(input.code, marks.length ? byMark(marks[0].entry) : byCookie, candidates, marks.map(m => m.who));
19872
+ }
19816
19873
  if (v.kind === "unavailable")
19817
19874
  return v;
19818
19875
  if (v.kind !== "ok") {
@@ -19831,7 +19888,8 @@ export class FleetManager {
19831
19888
  this.logger.debug("Sign-in with an authenticator code refused");
19832
19889
  return { kind: "wrong" };
19833
19890
  }
19834
- if (!who || !enrollment)
19891
+ const who = v.who, enrollment = store.enrollmentOf(who);
19892
+ if (!enrollment)
19835
19893
  return { kind: "wrong" };
19836
19894
  const actor = who === HOST_ADMIN_KEY ? null : (() => { const [adapterId, userId] = who.split("\u0000"); return adapterId && userId ? { adapterId, userId } : null; })();
19837
19895
  if (!actor && who !== HOST_ADMIN_KEY)
@@ -19839,7 +19897,7 @@ export class FleetManager {
19839
19897
  const outside = webOnly && exposureId !== undefined;
19840
19898
  return {
19841
19899
  kind: "ok",
19842
- knownCookie: addSigninKnownDevice(this.webToken, input.knownCookie, who, enrollment, epoch, now),
19900
+ knownCookie: addSigninKnownDevice(webToken, input.knownCookie, who, enrollment, epoch, now),
19843
19901
  session: outside ? { remote: "totp" } : actor ? { owner: actor } : {},
19844
19902
  // Asked again as the session is made: the same app, still an admin, still allowed here.
19845
19903
  commit: (record, label) => {
@@ -19856,6 +19914,10 @@ export class FleetManager {
19856
19914
  },
19857
19915
  };
19858
19916
  }
19917
+ /** Whether the request names an admin (`account`, legacy). Blank or missing: the code stands alone. */
19918
+ signInNameTyped(account) {
19919
+ return typeof account === "string" && account.normalize("NFKC").trim().replace(/^@+/, "") !== "";
19920
+ }
19859
19921
  /** 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
19922
  signinHandleOf(owner) {
19861
19923
  const handle = this.webPrefs.profile(webPersonKey(owner))?.platformName;
@@ -20758,22 +20820,31 @@ export class FleetManager {
20758
20820
  * was gone; this is the fallback).
20759
20821
  */
20760
20822
  async postRemoteCard(instanceName, card) {
20761
- // #2910 D4: a CLI's own dialog read as a card (selection-card.ts) is put to people only on a web-only fleet — the
20762
- // dashboard; a chat fleet keeps its parked notice and its General's controls, as before.
20763
- if (card.kind === "question" && card.webOnly && !this.webOnlyPromptPlace())
20764
- return;
20823
+ // #3334: CLI-owned dialogs also reach chat fleets. Their legacy webOnly marker now requires the owning
20824
+ // adapter's fleet admin to answer; ordinary agent questions retain their existing conversation authority.
20765
20825
  this.retireRemoteCard(instanceName, null, t("card.answered_in_pane"));
20766
- const place = this.remoteCardPlace(instanceName);
20826
+ const requiresAdmin = card.kind === "question" && card.webOnly === true;
20827
+ // Classic rooms may include people outside the fleet. Keep their generic parked notice; the full CLI dialog
20828
+ // and its approval live only on the existing admin dashboard, never in that room or an assumed-private General.
20829
+ const privateDashboard = requiresAdmin && this.classicChannels?.getChannelIdByInstance(instanceName) !== undefined;
20830
+ const place = privateDashboard ? { adapter: WEB_ONLY_PROMPT_SINK, adapterId: "web", chatId: "web" } : this.remoteCardPlace(instanceName);
20767
20831
  if (!place) {
20768
20832
  this.logger.warn({ instanceName }, "A card is waiting on screen but the instance has no place to post it — the parked notice stands");
20769
20833
  return;
20770
20834
  }
20771
- const prompt = remoteCardPrompt(instanceName, card);
20835
+ // Redact before labels are clipped. Keep the raw request's identity for the pane check, and retain only the
20836
+ // displayed option titles for the chat outcome too, so selecting an option cannot re-disclose its secret.
20837
+ const shown = card.kind === "question" && requiresAdmin && place.adapter.type !== "web" ? {
20838
+ ...card, title: redactSecrets(card.title), question: redactSecrets(card.question),
20839
+ options: card.options.map(o => ({ ...o, title: redactSecrets(o.title), description: o.description === null ? null : redactSecrets(o.description) })),
20840
+ } : card;
20841
+ const prompt = remoteCardPrompt(instanceName, shown);
20772
20842
  const nonce = await this.postNonceButtonPrompt({
20773
20843
  prefix: REMOTE_CARD_CALLBACK_PREFIX, alertType: "interactive_prompt", instanceName, ...place,
20774
20844
  message: prompt.message, choices: prompt.choices, webInput: prompt.webInput,
20775
20845
  expiredText: t("card.expired", instanceName), timeoutMs: REMOTE_CARD_TIMEOUT_MS,
20776
- extra: { remoteCard: { identity: card.identity, kind: card.kind, options: card.kind === "question" ? card.options.map(o => ({ n: o.n, title: o.title })) : [] } },
20846
+ extra: { remoteCard: { identity: card.identity, kind: card.kind, options: shown.kind === "question" ? shown.options.map(o => ({ n: o.n, title: o.title })) : [],
20847
+ requiresAdmin, ownerAdapterId: this.getInstanceAdapterId(instanceName) } },
20777
20848
  });
20778
20849
  if (nonce)
20779
20850
  this.remoteCardPosts.set(instanceName, nonce);
@@ -20797,8 +20868,10 @@ export class FleetManager {
20797
20868
  clearTimeout(entry.timer);
20798
20869
  void this.retireNonceButtons(entry, entry.messageId ?? "", text);
20799
20870
  }
20800
- /** Who may answer an instance's card: whoever may already talk to it there (a ClassicBot room is open to all). */
20871
+ /** CLI-owned dialogs need the owning adapter's fleet admin; ordinary agent questions follow conversation access. */
20801
20872
  mayAnswerRemoteCard(userId, entry) {
20873
+ if (entry.remoteCard?.requiresAdmin)
20874
+ return this.isFleetAdmin(userId, entry.adapterId);
20802
20875
  if (this.classicChannels?.getChannelIdByInstance(entry.instanceName) === entry.chatId)
20803
20876
  return true;
20804
20877
  const am = this.worlds.get(entry.adapterId)?.accessManager ?? this.accessManager;
@@ -20873,6 +20946,10 @@ export class FleetManager {
20873
20946
  let outcome;
20874
20947
  if (!card || !action)
20875
20948
  outcome = { outcome: "refused", reason: "malformed" };
20949
+ // The worker may have moved since posting. Its owner is distinct from the private dashboard's display sink.
20950
+ // Check here for platform buttons, typed replies and dashboard claims alike, before invoking the CLI answer.
20951
+ else if (card.requiresAdmin && card.ownerAdapterId !== this.getInstanceAdapterId(entry.instanceName))
20952
+ outcome = { outcome: "stale" };
20876
20953
  else if (!daemon?.answerRemoteCard)
20877
20954
  outcome = { outcome: "stale" };
20878
20955
  else {
@@ -21949,7 +22026,7 @@ export class FleetManager {
21949
22026
  const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
21950
22027
  const identity = this.signInIdentity(backend, profile);
21951
22028
  rows.push({ profile, state: (login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown"), signIn,
21952
- ...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}) });
22029
+ ...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}), ...(this.claudeSignInEnded(backend, profile) ? { reconnect: true } : {}) });
21953
22030
  }
21954
22031
  diskProfiles.set(backend, rows);
21955
22032
  }
@@ -22048,6 +22125,7 @@ export class FleetManager {
22048
22125
  * admitCredentialUse) from the configuration it launched with — never re-resolved against today's defaults. An entry
22049
22126
  * whose start ended without a daemon, or whose daemon is gone, is dropped when next read.
22050
22127
  */
22128
+ // M-2825 review: with the sign-in as launched (backend, profile as written) — what is in use until the agent restarts.
22051
22129
  credentialLeases = new Map();
22052
22130
  /** #3292 review: Keep sign-in alive runs in flight, by sign-in: a start on that sign-in waits for its end. */
22053
22131
  keepAliveRenewing = new Map();
@@ -22057,14 +22135,15 @@ export class FleetManager {
22057
22135
  * Daemon's clone of that config hands its CLI. Never today's defaults: an older config object keeps its own.
22058
22136
  */
22059
22137
  launchCredentialKey(config, backend) {
22060
- let profile = null;
22138
+ return this.credentialKey(backend, this.launchCredentialProfile(config, backend));
22139
+ }
22140
+ launchCredentialProfile(config, backend) {
22061
22141
  try {
22062
- profile = resolveCredentialProfile(config.backend_options?.[backend]);
22142
+ return resolveCredentialProfile(config.backend_options?.[backend]);
22063
22143
  }
22064
22144
  catch {
22065
- profile = null;
22145
+ return null;
22066
22146
  }
22067
- return this.credentialKey(backend, profile);
22068
22147
  }
22069
22148
  /**
22070
22149
  * #3313 review r2: failed starts whose CLI was not proven gone keep holding their sign-in (across a retry of the same
@@ -22103,7 +22182,7 @@ export class FleetManager {
22103
22182
  assertCurrent();
22104
22183
  key = this.launchCredentialKey(config, backend);
22105
22184
  }
22106
- const lease = { key, starting: true };
22185
+ const lease = { key, starting: true, backend, profile: this.launchCredentialProfile(config, backend) };
22107
22186
  this.credentialLeases.set(name, lease);
22108
22187
  const drop = () => { if (this.credentialLeases.get(name) === lease)
22109
22188
  this.credentialLeases.delete(name); };
@@ -22112,7 +22191,7 @@ export class FleetManager {
22112
22191
  release: drop,
22113
22192
  current: c => this.launchCredentialKey(c, backend) === key,
22114
22193
  // 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(); },
22194
+ unknownEnd: ended => { drop(); this.credentialOrphans.set(Symbol(name), { key, ended, backend, profile: lease.profile }); this.recheckCredentialOrphans(); },
22116
22195
  };
22117
22196
  }
22118
22197
  /**
@@ -22209,14 +22288,69 @@ export class FleetManager {
22209
22288
  const ka = this.signInKeepAlive;
22210
22289
  if (!ka)
22211
22290
  return [];
22212
- const day = (ms) => ms === undefined ? "?" : new Date(ms).toISOString().slice(0, 10);
22291
+ // 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
22292
+ // in Taipei), with the hour for an end date — a day's notice needs to say when that day ends.
22293
+ const p2 = (n) => String(n).padStart(2, "0");
22294
+ const day = (ms, at = false) => {
22295
+ if (ms === undefined)
22296
+ return "?";
22297
+ const d = new Date(ms);
22298
+ return `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())}${at ? ` ${p2(d.getHours())}:${p2(d.getMinutes())}` : ""}`;
22299
+ };
22213
22300
  const owner = this.worlds.keys().next().value;
22214
- return ka.attention().map(a => ({
22301
+ return ka.attention(this.signInsInUse()).map(a => ({
22215
22302
  backend: a.backend, profile: a.profile, kind: a.kind, since: a.since, signIn: dashboardSignInSupported(a.backend, a.profile),
22216
22303
  ...(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)),
22304
+ 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
22305
  }));
22219
22306
  }
22307
+ /**
22308
+ * M-2825: the host sign-ins in use, once each — whose end date is warned about even when it is not kept alive:
22309
+ * - each agent's and ClassicBot room's as configured (accountUses: a paired computer's agents use that computer's own);
22310
+ * - #3577 review P2: the one each host agent is starting or running on AS LAUNCHED (its lease; a failed start whose CLI
22311
+ * may still run; a running agent with no lease, by its own launch snapshot) — a profile saved but not yet applied
22312
+ * leaves the old one in use until the restart, as keepAliveInUse() counts it.
22313
+ */
22314
+ signInsInUse() {
22315
+ const seen = new Set(), out = [];
22316
+ const add = (backend, profile) => {
22317
+ if (!backend)
22318
+ return;
22319
+ const key = this.credentialKey(backend, profile ?? null);
22320
+ if (!seen.has(key)) {
22321
+ seen.add(key);
22322
+ out.push({ backend, profile: profile ?? null });
22323
+ }
22324
+ };
22325
+ try {
22326
+ const uses = this.accountUses();
22327
+ for (const u of [...uses.agents, ...uses.classic])
22328
+ add(u.backend, u.profile);
22329
+ }
22330
+ catch { /* the launched ones below still count */ }
22331
+ for (const [name, lease] of this.credentialLeases)
22332
+ if (lease.starting || this.daemons?.has(name))
22333
+ add(lease.backend, lease.profile);
22334
+ for (const o of this.credentialOrphans.values())
22335
+ add(o.backend, o.profile);
22336
+ const defaultBackend = this.fleetConfig?.defaults?.backend ?? "claude-code";
22337
+ for (const [name, daemon] of this.daemons ?? []) {
22338
+ if (this.credentialLeases.has(name))
22339
+ continue;
22340
+ let snap;
22341
+ try {
22342
+ snap = daemon.getConfigSnapshot?.();
22343
+ }
22344
+ catch {
22345
+ snap = undefined;
22346
+ }
22347
+ if (!snap || isWindowsInstance(snap))
22348
+ continue;
22349
+ const backend = snap.backend ?? defaultBackend;
22350
+ add(backend, this.launchCredentialProfile(snap, backend));
22351
+ }
22352
+ return out;
22353
+ }
22220
22354
  /** #3292: Settings → Accounts → Keep sign-in alive (POST /ui/accounts/keep-alive). `by`: the session's label, for the fleet log. */
22221
22355
  setAccountKeepAlive(backend, profile, enabled, fallback, by) {
22222
22356
  const r = this.keepAliveService().set(backend, profile, enabled, fallback);
@@ -22446,14 +22580,30 @@ export class FleetManager {
22446
22580
  this.logger.info({ backend, profile: shown, by, refused: result.error }, "Account sign-out refused");
22447
22581
  return result;
22448
22582
  }
22583
+ /** M-2825: a host Claude sign-in whose own file says it is over (credential-profile.ts claudeStoreEnded); false for other CLIs. */
22584
+ claudeSignInEnded(backend, profile) {
22585
+ if (backend !== "claude-code")
22586
+ return false;
22587
+ try {
22588
+ const home = profile ? credentialProfileStoreHome(this.dataDir, backend, profile) : credentialHomeSpec(backend)?.sharedRoot();
22589
+ return !!home && claudeStoreEnded(home);
22590
+ }
22591
+ catch {
22592
+ return false;
22593
+ }
22594
+ }
22449
22595
  backendSignInTargets() {
22450
22596
  const out = [];
22451
22597
  for (const row of this.backendAvailabilityRows()) {
22452
22598
  const flow = LOGIN_FLOWS[row.backend];
22453
22599
  const install = BACKEND_INSTALLATION_INFO[row.backend]?.install;
22600
+ // M-2825: `claude auth status` says loggedIn after a refused refresh and past the sign-in's end date — the file says
22601
+ // whether it is over, and then it is not signed in (never the other way: the file can't vouch for a login).
22602
+ const ended = row.state === "usable" && this.claudeSignInEnded(row.backend, null);
22454
22603
  out.push({
22455
22604
  // 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),
22605
+ backend: row.backend, state: ended ? "not_signed_in" : row.state, ...(ended ? { reconnect: true } : {}),
22606
+ signIn: row.state !== "not_installed" && row.state !== "too_old" && dashboardSignInSupported(row.backend),
22457
22607
  ...(flow?.remoteLogin === "unsupported" ? { hostCommand: flow.command } : {}),
22458
22608
  ...(row.state === "not_installed" && install ? { install } : {}),
22459
22609
  ...(row.state === "too_old" && install ? { update: install } : {}),
@@ -22475,7 +22625,8 @@ export class FleetManager {
22475
22625
  const signIn = dashboardSignInSupported(backend, profile);
22476
22626
  const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
22477
22627
  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) } : {}) });
22628
+ ...(hostCommand ? { hostCommand } : {}), ...(this.signInIdentity(backend, profile) ? { identity: this.signInIdentity(backend, profile) } : {}),
22629
+ ...(this.claudeSignInEnded(backend, profile) ? { reconnect: true } : {}) });
22479
22630
  }
22480
22631
  return out;
22481
22632
  }