@songsid/agend 2.3.5-alpha.10 → 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.
- package/dist/accounts-view.d.ts +17 -0
- package/dist/accounts-view.js +24 -8
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +2 -2
- package/dist/auth-api.d.ts +48 -16
- package/dist/auth-api.js +83 -32
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/settings-role.d.ts +56 -0
- package/dist/authority/settings-role.js +48 -0
- package/dist/authority/settings-role.js.map +1 -0
- package/dist/backend/claude-code.d.ts +2 -0
- package/dist/backend/claude-code.js +32 -6
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/cli-env-probe.js +6 -2
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/backend/codex.d.ts +5 -3
- package/dist/backend/codex.js +31 -13
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +18 -0
- package/dist/backend/credential-profile.js +46 -0
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/muse.d.ts +3 -1
- package/dist/backend/muse.js +31 -1
- package/dist/backend/muse.js.map +1 -1
- package/dist/backend/types.d.ts +17 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +15 -0
- package/dist/backend-availability.js +37 -1
- package/dist/backend-availability.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/bundled-tmux-guard.d.ts +4 -0
- package/dist/bundled-tmux-guard.js +7 -0
- package/dist/bundled-tmux-guard.js.map +1 -1
- package/dist/claude-auth-status.d.ts +20 -8
- package/dist/claude-auth-status.js +38 -22
- package/dist/claude-auth-status.js.map +1 -1
- package/dist/cli-audited.d.ts +60 -0
- package/dist/cli-audited.js +84 -0
- package/dist/cli-audited.js.map +1 -0
- package/dist/cli-capability.d.ts +36 -5
- package/dist/cli-capability.js +2 -2
- package/dist/cli-capability.js.map +1 -1
- package/dist/cli-caps-module.d.ts +5 -1
- package/dist/cli-caps-module.js +4 -2
- package/dist/cli-caps-module.js.map +1 -1
- package/dist/cli-registry-check.js +16 -2
- package/dist/cli-registry-check.js.map +1 -1
- package/dist/cli-registry.d.ts +56 -4
- package/dist/cli-registry.js +1 -1
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli-spec-antigravity.d.ts +12 -1
- package/dist/cli-spec-antigravity.js +13 -1
- package/dist/cli-spec-antigravity.js.map +1 -1
- package/dist/cli-spec-claude-code.d.ts +9 -0
- package/dist/cli-spec-claude-code.js +4 -2
- package/dist/cli-spec-claude-code.js.map +1 -1
- package/dist/cli-spec-codex.d.ts +10 -1
- package/dist/cli-spec-codex.js +5 -3
- package/dist/cli-spec-codex.js.map +1 -1
- package/dist/cli-spec-grok.d.ts +5 -0
- package/dist/cli-spec-grok.js +6 -1
- package/dist/cli-spec-grok.js.map +1 -1
- package/dist/cli-spec-kiro-cli.d.ts +7 -1
- package/dist/cli-spec-kiro-cli.js +7 -3
- package/dist/cli-spec-kiro-cli.js.map +1 -1
- package/dist/cli-spec-muse.d.ts +2 -0
- package/dist/cli-spec-muse.js +3 -1
- package/dist/cli-spec-muse.js.map +1 -1
- package/dist/cli-spec-opencode.d.ts +11 -1
- package/dist/cli-spec-opencode.js +7 -2
- package/dist/cli-spec-opencode.js.map +1 -1
- package/dist/cli.js +28 -1
- package/dist/cli.js.map +1 -1
- package/dist/create-host-account.d.ts +17 -0
- package/dist/create-host-account.js +47 -0
- package/dist/create-host-account.js.map +1 -0
- package/dist/daemon.d.ts +26 -0
- package/dist/daemon.js +131 -10
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.js +7 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-context.d.ts +5 -1
- package/dist/fleet-manager.d.ts +363 -71
- package/dist/fleet-manager.js +1374 -367
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-process-handlers.d.ts +1 -1
- package/dist/fleet-process-handlers.js +3 -2
- package/dist/fleet-process-handlers.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +21 -14
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +9 -8
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +9 -1
- package/dist/general-knowledge/skills/kiro-engine-migration/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +27 -20
- package/dist/instance-lifecycle.js +33 -3
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.js +29 -6
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +125 -81
- package/dist/locale.js.map +1 -1
- package/dist/login-manager.d.ts +2 -2
- package/dist/login-manager.js +3 -2
- package/dist/login-manager.js.map +1 -1
- package/dist/native-model-catalog.d.ts +20 -0
- package/dist/native-model-catalog.js +107 -2
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/public-web-gateway.js +1 -1
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +5 -0
- package/dist/public-web-link.js +8 -0
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-api.d.ts +1 -1
- package/dist/runtime-api.js +104 -12
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-autostart.d.ts +61 -0
- package/dist/runtime-autostart.js +161 -0
- package/dist/runtime-autostart.js.map +1 -0
- package/dist/runtime-background.d.ts +200 -0
- package/dist/runtime-background.js +480 -0
- package/dist/runtime-background.js.map +1 -0
- package/dist/runtime-build-info.js +5 -5
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-background.d.ts +92 -0
- package/dist/runtime-cli-background.js +336 -0
- package/dist/runtime-cli-background.js.map +1 -0
- package/dist/runtime-cli-install.d.ts +148 -8
- package/dist/runtime-cli-install.js +253 -59
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/runtime-cli.d.ts +8 -1
- package/dist/runtime-cli.js +206 -44
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +11 -0
- package/dist/runtime-client-store.js +20 -5
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +23 -1
- package/dist/runtime-client.js +92 -6
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-connection.d.ts +1 -1
- package/dist/runtime-connection.js +1 -1
- package/dist/runtime-connection.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +95 -1
- package/dist/runtime-coordinator.js +344 -10
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-enroll-notice.d.ts +4 -0
- package/dist/runtime-enroll-notice.js +21 -0
- package/dist/runtime-enroll-notice.js.map +1 -0
- package/dist/runtime-enrollment.d.ts +21 -0
- package/dist/runtime-enrollment.js +52 -0
- package/dist/runtime-enrollment.js.map +1 -0
- package/dist/runtime-pane-native.js +4 -4
- package/dist/runtime-pane-native.js.map +1 -1
- package/dist/runtime-protocol.d.ts +78 -1
- package/dist/runtime-protocol.js +95 -5
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +12 -0
- package/dist/runtime-remote-accounts.js +56 -5
- package/dist/runtime-remote-accounts.js.map +1 -1
- package/dist/runtime-remote-setup.d.ts +4 -1
- package/dist/runtime-remote-setup.js +4 -1
- package/dist/runtime-remote-setup.js.map +1 -1
- package/dist/runtime-update-controller.d.ts +11 -0
- package/dist/runtime-update-controller.js +56 -4
- package/dist/runtime-update-controller.js.map +1 -1
- package/dist/settings-api.d.ts +13 -1
- package/dist/settings-api.js +44 -20
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +5 -13
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +11 -13
- package/dist/settings-confirmation.js +2 -6
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +5 -0
- package/dist/settings-effect.js +76 -10
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +8 -1
- package/dist/settings-http-confirmation.js +39 -13
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +7 -0
- package/dist/settings-request-capability.js +3 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/setup-i18n.js +4 -4
- package/dist/setup-i18n.js.map +1 -1
- package/dist/signin-keepalive.d.ts +25 -1
- package/dist/signin-keepalive.js +44 -1
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/subagent-records.d.ts +45 -0
- package/dist/subagent-records.js +214 -0
- package/dist/subagent-records.js.map +1 -0
- package/dist/subagent-service.d.ts +27 -0
- package/dist/subagent-service.js +199 -0
- package/dist/subagent-service.js.map +1 -0
- package/dist/tmux-manager.d.ts +2 -2
- package/dist/tmux-manager.js +5 -3
- package/dist/tmux-manager.js.map +1 -1
- package/dist/ui/account-identity.js +7 -5
- package/dist/ui/accounts-keepalive.js +17 -17
- package/dist/ui/accounts-manage.js +34 -34
- package/dist/ui/accounts-view.js +68 -24
- package/dist/ui/agent-runtime-settings.js +1 -1
- package/dist/ui/backend-signin.js +67 -67
- package/dist/ui/chat-msg-actions.js +50 -4
- package/dist/ui/chat-quote.js +256 -0
- package/dist/ui/chat-store.js +9 -4
- package/dist/ui/cli-caps.js +7 -7
- package/dist/ui/credential-profile-select.js +4 -4
- package/dist/ui/general-location.js +1 -1
- package/dist/ui/host-install.js +290 -0
- package/dist/ui/hub-company-join-strings.js +3 -0
- package/dist/ui/hub-company-join.js +20 -2
- package/dist/ui/hub-owner-strings.js +5 -4
- package/dist/ui/hub-pairing-progress-strings.js +1 -1
- package/dist/ui/hub-quick-strings.js +4 -4
- package/dist/ui/hub-strings.js +6 -6
- package/dist/ui/machine-signin.js +4 -4
- package/dist/ui/model-picker.js +68 -0
- package/dist/ui/panel-chat.js +74 -13
- package/dist/ui/panel-fleet.js +8 -2
- package/dist/ui/panel-hub.js +8 -4
- package/dist/ui/panel-needs.js +2 -2
- package/dist/ui/panel-runtimes.js +232 -33
- package/dist/ui/panel-settings.js +7 -1
- package/dist/ui/panel-windows-cli.js +1 -1
- package/dist/ui/runtime-cli-install.js +99 -20
- package/dist/ui/runtime-commands.d.ts +2 -0
- package/dist/ui/runtime-commands.js +34 -1
- package/dist/ui/runtime-update-status.js +2 -2
- package/dist/ui/search-dialog.js +1 -0
- package/dist/ui/settings-access-overview.js +167 -0
- package/dist/ui/settings-access-strings.js +1 -1
- package/dist/ui/settings-catalog.js +19 -3
- package/dist/ui/settings-confirm.js +2 -2
- package/dist/ui/settings-devices.js +59 -25
- package/dist/ui/settings-dialogs.js +12 -13
- package/dist/ui/settings-guests.js +1 -1
- package/dist/ui/settings-hub-company-join.js +10 -7
- package/dist/ui/settings-hub-connection.js +121 -0
- package/dist/ui/settings-hub-membership.js +1 -1
- package/dist/ui/settings-hub-run.js +5 -6
- package/dist/ui/settings-hub-section.js +3 -6
- package/dist/ui/settings-hub.js +12 -7
- package/dist/ui/settings-layout.js +9 -7
- package/dist/ui/settings-outside.js +87 -19
- package/dist/ui/settings-registry.js +2 -1
- package/dist/ui/settings-revoke-strings.js +28 -0
- package/dist/ui/settings-strings.js +25 -25
- package/dist/ui/settings-web-authority.js +11 -4
- package/dist/ui/shared/accounts.css +11 -1
- package/dist/ui/shared/agend-auth.js +8 -1
- package/dist/ui/shared/app-i18n.js +10 -12
- package/dist/ui/shared/app-session.js +13 -16
- package/dist/ui/shared/app-shell.js +37 -37
- package/dist/ui/shared/app-store.js +2 -0
- package/dist/ui/shared/app.css +85 -14
- package/dist/ui/shared/chat-render.js +17 -5
- package/dist/ui/shared/chat-strings.js +4 -4
- package/dist/ui/shared/device-roles.js +27 -0
- package/dist/ui/shared/host-install.css +10 -0
- package/dist/ui/shared/hub-owner.css +6 -0
- package/dist/ui/shared/model-picker.css +21 -0
- package/dist/ui/shared/runtime-install.css +26 -1
- package/dist/ui/shared/setup-host-text.js +4 -4
- package/dist/ui/shared/signin.js +171 -64
- package/dist/ui/shared/subagent-row.css +15 -0
- package/dist/ui/shared/usage-dialog.js +28 -16
- package/dist/ui/shared/view-strings.js +7 -7
- package/dist/ui/shared/web-authorize.js +54 -4
- package/dist/ui/signin.html +19 -8
- package/dist/ui/structured-signin.js +30 -30
- package/dist/ui/subagent-row.js +72 -0
- package/dist/ui/web-terminal/terminal.js +9 -9
- package/dist/update-launch.js +4 -1
- package/dist/update-launch.js.map +1 -1
- package/dist/update-npm-env.d.ts +70 -0
- package/dist/update-npm-env.js +128 -0
- package/dist/update-npm-env.js.map +1 -0
- package/dist/usage/format-rich.js +1 -1
- package/dist/usage/format-rich.js.map +1 -1
- package/dist/usage/providers.js +2 -2
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.d.ts +8 -2
- package/dist/usage/usage-api.js +12 -5
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +38 -4
- package/dist/web-api.js +370 -18
- package/dist/web-api.js.map +1 -1
- package/dist/web-auth.js +1 -1
- package/dist/web-auth.js.map +1 -1
- package/dist/web-backend-login.d.ts +2 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-channel-echo.js +3 -1
- package/dist/web-channel-echo.js.map +1 -1
- package/dist/web-commands.d.ts +9 -1
- package/dist/web-commands.js +7 -1
- package/dist/web-commands.js.map +1 -1
- package/dist/web-host-install.d.ts +127 -0
- package/dist/web-host-install.js +165 -0
- package/dist/web-host-install.js.map +1 -0
- package/dist/web-remote-access.d.ts +194 -11
- package/dist/web-remote-access.js +458 -34
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-session.d.ts +11 -3
- package/dist/web-session.js.map +1 -1
- package/dist/web-signin-device.d.ts +16 -0
- package/dist/web-signin-device.js +81 -0
- package/dist/web-signin-device.js.map +1 -0
- package/dist/web-update.js +3 -1
- package/dist/web-update.js.map +1 -1
- package/dist/windows-cli-api.js +2 -1
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +14 -0
- package/dist/windows-cli-worker.js +145 -1
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +4 -0
- package/dist/windows-cli.js +9 -1
- package/dist/windows-cli.js.map +1 -1
- package/launcher/agend-install.cjs +16 -3
- package/package.json +1 -1
- package/templates/runtime-install/install.ps1 +219 -12
package/dist/fleet-manager.js
CHANGED
|
@@ -5,6 +5,7 @@ import { NativePaneRecoveryError } from "./native-pane-recovery.js";
|
|
|
5
5
|
import { nativePaneToolAvailable, nativePaneToolRefusal } from "./native-pane-tools.js";
|
|
6
6
|
import { windowsAgentsFor } from "./windows-agents.js";
|
|
7
7
|
import { AgentRuntimeChanges } from "./agent-runtime-change.js";
|
|
8
|
+
import { SubagentService } from "./subagent-service.js";
|
|
8
9
|
import { QuotaNotices } from "./usage/quota-notices.js";
|
|
9
10
|
import { quotaNoticeRule } from "./quota-notice-config.js";
|
|
10
11
|
import { onUsageSnapshot } from "./usage/usage-api.js";
|
|
@@ -224,6 +225,7 @@ import { RuntimeWindowsBridge } from "./runtime-windows-bridge.js";
|
|
|
224
225
|
import { FleetWindowsRuntime } from "./fleet-windows-runtime.js";
|
|
225
226
|
import { NativeMcpSessions } from "./native-mcp.js";
|
|
226
227
|
import { nativeProviderMcpSupported } from "./windows-cli-providers.js";
|
|
228
|
+
import { cachedNativeModelCatalog } from "./native-model-catalog.js";
|
|
227
229
|
import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED, nativeCredentialProfile } from "./native-instance-registry.js";
|
|
228
230
|
import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./native-instance-api.js";
|
|
229
231
|
import { NativeInstanceConfigEdit, parseNativeInstanceCreate } from "./native-instance-input.js";
|
|
@@ -281,6 +283,8 @@ import { resolveUpdateLaunch, openUpdateLog, updateLogPath, watchUpdateLaunch }
|
|
|
281
283
|
import { isWebUpdateTarget, readLogTail, RUNNING_AGEND_VERSION, updateOffer, webProgressOf, webUpdateTarget } from "./web-update.js";
|
|
282
284
|
import { admitProfileLogin, LoginController, LOGIN_TOKEN_RESEND_PREFIX, POST_LOGIN_RECOVERY_DEADLINE_MS } from "./login-controller.js";
|
|
283
285
|
import { WebBackendLogins, dashboardSignInSupported } from "./web-backend-login.js";
|
|
286
|
+
import { WebHostInstalls, hostUpdatePlan } from "./web-host-install.js";
|
|
287
|
+
import { cliUpdateView, versionOf } from "./cli-audited.js";
|
|
284
288
|
import { runBeforeDeadline } from "./deadline.js";
|
|
285
289
|
import { LoginWindowLock } from "./login-window-lock.js";
|
|
286
290
|
import { BrowserBackendSignIns } from "./browser-backend-signins.js";
|
|
@@ -334,9 +338,12 @@ import { bypassesWebGate, handleAuthRequest, serveGuestRefusedPage, serveSigninP
|
|
|
334
338
|
import { isWebPageNavigation } from "./web-shell-routes.js";
|
|
335
339
|
import { guestSessionPolicy, localSessionPolicy, sessionVia, tokenEpoch, WebSessionStore } from "./web-session.js";
|
|
336
340
|
import { WebNotices, WEB_NOTICES_FILE } from "./web-notices.js";
|
|
341
|
+
import { enrolledRuntimeNotice } from "./runtime-enroll-notice.js";
|
|
337
342
|
import { DeviceLoginRequests } from "./web-device-login.js";
|
|
338
|
-
import {
|
|
339
|
-
import {
|
|
343
|
+
import { findSigninKnownEntry, addSigninKnownDevice } from "./web-signin-device.js";
|
|
344
|
+
import { adminKey, HOST_ADMIN_KEY, isOutsideLinkOwner, OUTSIDE_LINK_OWNER, OUTSIDE_LINK_RETRY_MS, OUTSIDE_OWN_CLOSES, outsideDuration, outsideTimer, TOTP_SIGNIN_OVER_PUBLIC_LINK, TOTP_STEP_SECONDS, WEB_REMOTE_ACCESS_FILE, WebRemoteAccess } from "./web-remote-access.js";
|
|
345
|
+
import { evaluateSettingsRole } from "./authority/settings-role.js";
|
|
346
|
+
import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
|
|
340
347
|
import { AuthorityStateStore } from "./authority/authority-state.js";
|
|
341
348
|
import { SessionAuthorizations } from "./authority/session-authorizations.js";
|
|
342
349
|
import { SessionAuthorizationRequests } from "./web-session-authorization.js";
|
|
@@ -359,7 +366,7 @@ import { PROVIDER_SECRET_SPECS, PUBLIC_TUNNEL_SECRET_SPEC, providerSecretSpec, p
|
|
|
359
366
|
const SELF_RESTART_DEADLINE_MS = 300_000;
|
|
360
367
|
import { APPLY_FLEET_TARGET, ApplyJobStore, viewOf, } from "./apply-job.js";
|
|
361
368
|
import { kiroHome } from "./backend/kiro-kas-store.js";
|
|
362
|
-
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";
|
|
363
370
|
import { carryClaudeConversation } from "./backend/claude-carry.js";
|
|
364
371
|
import { classicProfile, mergeBackendOptions, profileKey, profileName, profileOf, readClassicBindings, readClassicBindingsStrict } from "./classic-bindings.js";
|
|
365
372
|
import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, shortUsage, weeklyUsage } from "./accounts-view.js";
|
|
@@ -840,6 +847,123 @@ export class FleetManager {
|
|
|
840
847
|
localPaneRelay = null;
|
|
841
848
|
openingLocalPane = null;
|
|
842
849
|
runtimeHub = null;
|
|
850
|
+
/**
|
|
851
|
+
* A message the owner must get (a computer joined with an install-command token, so nobody approved it). It is written to `pending-owner-notices.json` FIRST and removed only
|
|
852
|
+
* when a delivery is acknowledged: the platform took the message (the send's promise resolved) or the dashboard's Notices recorded it. So none of these loses it: no place to
|
|
853
|
+
* send it yet (a chat-connected fleet with no General and no primary notice target, adapters not up), a send the platform refuses after it was dispatched, a retry that is
|
|
854
|
+
* refused again, a restart. Each kept notice is tried again every minute until it is acknowledged. The file is private. Capacity is explicit, never silent: past
|
|
855
|
+
* OWNER_NOTICE_CAP undelivered notices the oldest are folded into ONE notice that says how many computers joined without a delivered notice and tells the owner to review
|
|
856
|
+
* Settings → Runtime, so the fact is never dropped. Delivery is at least once: a crash between the send and its acknowledgement can send a notice twice.
|
|
857
|
+
*/
|
|
858
|
+
ownerNoticeTimer = null;
|
|
859
|
+
/** One physical send per kept notice at a time: the claim is held until THAT attempt settles (never aged out) and each attempt's callbacks only act on its own claim. */
|
|
860
|
+
ownerNoticeLive = new Set();
|
|
861
|
+
ownerNoticeInFlight = new Map();
|
|
862
|
+
pendingOwnerNoticesFile() { return this.dataDir ? join(this.dataDir, "pending-owner-notices.json") : null; }
|
|
863
|
+
readPendingOwnerNotices() {
|
|
864
|
+
const file = this.pendingOwnerNoticesFile();
|
|
865
|
+
try {
|
|
866
|
+
const value = file && existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : [];
|
|
867
|
+
if (!Array.isArray(value))
|
|
868
|
+
return [];
|
|
869
|
+
const rows = [];
|
|
870
|
+
for (const row of value) {
|
|
871
|
+
if (typeof row === "string" && row.length > 0 && row.length <= 4000)
|
|
872
|
+
rows.push({ id: `legacy-${createHash("sha256").update(row).digest("hex").slice(0, 16)}`, text: row });
|
|
873
|
+
else if (row && typeof row === "object" && typeof row.id === "string" && typeof row.text === "string" && row.text.length > 0 && row.text.length <= 4000) {
|
|
874
|
+
const folded = row.folded;
|
|
875
|
+
rows.push({ id: row.id, text: row.text, ...(Number.isSafeInteger(folded) && folded > 0 ? { folded: folded } : {}) });
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return rows;
|
|
879
|
+
}
|
|
880
|
+
catch {
|
|
881
|
+
return [];
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
writePendingOwnerNotices(rows) {
|
|
885
|
+
const file = this.pendingOwnerNoticesFile();
|
|
886
|
+
if (!file)
|
|
887
|
+
return;
|
|
888
|
+
try {
|
|
889
|
+
if (rows.length)
|
|
890
|
+
atomicWriteFileSync(file, JSON.stringify(rows), { mode: 0o600 });
|
|
891
|
+
else
|
|
892
|
+
rmSync(file, { force: true });
|
|
893
|
+
}
|
|
894
|
+
catch (error) {
|
|
895
|
+
this.logger.warn({ err: error }, "Could not keep a pending owner notice");
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
static OWNER_NOTICE_CAP = 100;
|
|
899
|
+
/** Past the cap, the oldest are folded into one notice (a count, and where to look); it never silently disappears. */
|
|
900
|
+
foldOwnerNotices(rows) {
|
|
901
|
+
const cap = FleetManager.OWNER_NOTICE_CAP;
|
|
902
|
+
if (rows.length <= cap)
|
|
903
|
+
return rows;
|
|
904
|
+
const old = rows.slice(0, rows.length - (cap - 1)), keep = rows.slice(rows.length - (cap - 1));
|
|
905
|
+
const folded = old.reduce((sum, row) => sum + (row.folded ?? 1), 0);
|
|
906
|
+
this.logger.warn({ folded }, "Too many undelivered owner notices: the oldest were folded into one summary notice");
|
|
907
|
+
for (const row of old)
|
|
908
|
+
this.ownerNoticeInFlight.delete(row.id);
|
|
909
|
+
return [{ id: randomUUID(), text: t("runtime.enroll_folded", String(folded)), folded }, ...keep];
|
|
910
|
+
}
|
|
911
|
+
/** Keeps the notice, then tries to deliver it; it stays on disk until a delivery is acknowledged. */
|
|
912
|
+
deliverOwnerNotice(text) {
|
|
913
|
+
const entry = { id: randomUUID(), text };
|
|
914
|
+
this.writePendingOwnerNotices(this.foldOwnerNotices([...this.readPendingOwnerNotices(), entry]));
|
|
915
|
+
this.attemptOwnerNotice(entry.id, text);
|
|
916
|
+
this.scheduleOwnerNoticeFlush();
|
|
917
|
+
}
|
|
918
|
+
attemptOwnerNotice(id, text) {
|
|
919
|
+
if (this.ownerNoticeInFlight.has(id))
|
|
920
|
+
return; // a send is still waiting for its answer: it keeps the claim until it settles
|
|
921
|
+
const claim = Symbol(id);
|
|
922
|
+
this.ownerNoticeInFlight.set(id, claim);
|
|
923
|
+
let settled = false;
|
|
924
|
+
const finish = (delivered) => {
|
|
925
|
+
if (settled)
|
|
926
|
+
return;
|
|
927
|
+
settled = true;
|
|
928
|
+
if (this.ownerNoticeInFlight.get(id) === claim)
|
|
929
|
+
this.ownerNoticeInFlight.delete(id); // only its own claim: a late answer never retires a successor
|
|
930
|
+
if (delivered)
|
|
931
|
+
this.writePendingOwnerNotices(this.readPendingOwnerNotices().filter(row => row.id !== id));
|
|
932
|
+
};
|
|
933
|
+
let dispatched = false;
|
|
934
|
+
try {
|
|
935
|
+
dispatched = this.notifyFleetError(text, { throttle: false, ack: finish });
|
|
936
|
+
}
|
|
937
|
+
catch {
|
|
938
|
+
dispatched = false;
|
|
939
|
+
}
|
|
940
|
+
if (!dispatched)
|
|
941
|
+
finish(false);
|
|
942
|
+
}
|
|
943
|
+
/** Tries every kept notice that has no attempt in flight (oldest first); returns how many are kept. */
|
|
944
|
+
flushOwnerNotices() {
|
|
945
|
+
for (const row of this.readPendingOwnerNotices())
|
|
946
|
+
this.attemptOwnerNotice(row.id, row.text);
|
|
947
|
+
return this.readPendingOwnerNotices().length;
|
|
948
|
+
}
|
|
949
|
+
scheduleOwnerNoticeFlush(delayMs = 60_000) {
|
|
950
|
+
if (this.ownerNoticeTimer || !this.pendingOwnerNoticesFile())
|
|
951
|
+
return;
|
|
952
|
+
this.ownerNoticeTimer = setTimeout(() => {
|
|
953
|
+
this.ownerNoticeTimer = null;
|
|
954
|
+
let left = 0;
|
|
955
|
+
try {
|
|
956
|
+
left = this.flushOwnerNotices();
|
|
957
|
+
}
|
|
958
|
+
catch (error) {
|
|
959
|
+
this.logger.warn({ err: error }, "Could not deliver a pending owner notice");
|
|
960
|
+
left = 1;
|
|
961
|
+
}
|
|
962
|
+
if (left > 0)
|
|
963
|
+
this.scheduleOwnerNoticeFlush();
|
|
964
|
+
}, delayMs);
|
|
965
|
+
this.ownerNoticeTimer.unref?.();
|
|
966
|
+
}
|
|
843
967
|
runtimeInstall;
|
|
844
968
|
/** One service for the public installer routes and the administrator API: the hash the dashboard shows is the hash of what is sent. */
|
|
845
969
|
runtimeInstaller() { return this.runtimeInstall ??= new RuntimeInstallService(); }
|
|
@@ -850,10 +974,27 @@ export class FleetManager {
|
|
|
850
974
|
runtimeCoordinator() {
|
|
851
975
|
if (!remoteRuntimeEnabled())
|
|
852
976
|
throw new Error("Remote runtimes are not enabled");
|
|
977
|
+
if (!this.runtimeHub && this.readPendingOwnerNotices().length)
|
|
978
|
+
this.scheduleOwnerNoticeFlush(30_000); // a notice kept before a restart is delivered once the fleet is up
|
|
853
979
|
return this.runtimeHub ??= new RuntimeCoordinator(this.dataDir, {
|
|
854
980
|
handleMcp: (machineId, runId, body) => this.runtimeWindowsExecutor().mcp(machineId, runId, body),
|
|
855
981
|
handlePaneMcp: async (machineId, body, current) => (await this.nativePanes()).handle(machineId, body, current),
|
|
856
982
|
warn: (fields, message) => this.logger.warn(fields, message),
|
|
983
|
+
// Issue, use, revocation (and a refused use) of an install-command token: ids and an opaque actor handle only, never the token.
|
|
984
|
+
audit: entry => {
|
|
985
|
+
this.logger[entry.event === "rejected" || entry.event === "throttled" ? "warn" : "info"]({ runtimeEnrollment: entry }, `Runtime install-command token ${entry.event}`);
|
|
986
|
+
// A computer that joined with a token was approved by the token alone: tell the owner out of band (never lets a failure here change the join).
|
|
987
|
+
if (entry.event === "used")
|
|
988
|
+
try {
|
|
989
|
+
const text = enrolledRuntimeNotice(entry, entry.machineId ? this.runtimeHub?.machine(entry.machineId) ?? null : null);
|
|
990
|
+
// Kept first, removed only when a delivery is acknowledged (see deliverOwnerNotice): no destination yet, a refused send and a restart do not lose it.
|
|
991
|
+
if (text)
|
|
992
|
+
this.deliverOwnerNotice(text);
|
|
993
|
+
}
|
|
994
|
+
catch (error) {
|
|
995
|
+
this.logger.warn({ err: error }, "Could not announce a computer that joined with an install-command token");
|
|
996
|
+
}
|
|
997
|
+
},
|
|
857
998
|
changed: event => {
|
|
858
999
|
if (event?.type === "machine")
|
|
859
1000
|
this.needsYou?.poke();
|
|
@@ -1487,6 +1628,19 @@ export class FleetManager {
|
|
|
1487
1628
|
hubMemberPairingApi = null;
|
|
1488
1629
|
hubPairingNotices = null;
|
|
1489
1630
|
hubMemberPairing() { return this.hubMemberPairingApi; }
|
|
1631
|
+
/** Explicit owner Settings read only. A paused binding is not permission to mount or connect a member. */
|
|
1632
|
+
async hubMemberPairingView() {
|
|
1633
|
+
const raw = this.rawFleetConfig;
|
|
1634
|
+
if (this.shuttingDown)
|
|
1635
|
+
throw Error("Fleet is stopping");
|
|
1636
|
+
if (hubMembershipSettings(raw).enabled && this.hubMemberPairingApi)
|
|
1637
|
+
return this.hubMemberPairingApi.view();
|
|
1638
|
+
const { createHubMemberPairingApi } = await import("./hub/member/pairing-api.js");
|
|
1639
|
+
if (this.shuttingDown || this.rawFleetConfig !== raw)
|
|
1640
|
+
throw Error("Hub membership changed");
|
|
1641
|
+
// This factory schedules nothing; only its private-file projection is called. No write method escapes.
|
|
1642
|
+
return createHubMemberPairingApi({ home: this.dataDir, enabled: () => false }).view();
|
|
1643
|
+
}
|
|
1490
1644
|
attachHubMemberPairing(api) { this.hubMemberPairingApi = api; }
|
|
1491
1645
|
generalLocationFlights = new Map();
|
|
1492
1646
|
generalAttentionEpisodes = new Map();
|
|
@@ -3374,14 +3528,17 @@ export class FleetManager {
|
|
|
3374
3528
|
if (auth.kind !== "ok" || !current())
|
|
3375
3529
|
return null;
|
|
3376
3530
|
const record = auth.session, sessions = this.webSessions, exposure = gatewayRequestContext(req);
|
|
3377
|
-
return { localSession: this.hubCompanySession(req) ?? undefined, id: record.idHash, label: record.label, source: exposure ? "public_link" : "web_session",
|
|
3531
|
+
return { requester: { handle: record.handle, label: record.label }, localSession: this.hubCompanySession(req) ?? undefined, id: record.idHash, label: record.label, source: exposure ? "public_link" : "web_session",
|
|
3378
3532
|
localAdmin: () => record.tier === "admin" && record.surface === "local" && !exposure,
|
|
3379
3533
|
current: () => current() && sessions === this.webSessions && !!this.webToken
|
|
3380
3534
|
&& sessions.isCurrent(record, tokenEpoch(this.webToken)) && (!exposure || exposure.isCurrent()) };
|
|
3381
3535
|
}, baseline: () => baselines.read(), snapshot: () => baselines.snapshot(),
|
|
3382
3536
|
selfConfirm: (req, id) => this.settingsSelfConfirmation(store, req, id),
|
|
3383
3537
|
totp: { state: (req, id) => this.settingsTotpState(store, req, id), confirm: (req, id, code, digest) => this.settingsTotpConfirm(store, req, id, code, digest) },
|
|
3538
|
+
remote: req => this.settingsPageIsRemote(req),
|
|
3539
|
+
directCreationPolicy: req => this.settingsDirectCreationAllowed(req),
|
|
3384
3540
|
directAgentCreation: true,
|
|
3541
|
+
directHostInstall: true,
|
|
3385
3542
|
directCompanyJoin: true,
|
|
3386
3543
|
job: async (id) => {
|
|
3387
3544
|
const settlement = this.settingsJobSettlements.get(id);
|
|
@@ -3398,199 +3555,308 @@ export class FleetManager {
|
|
|
3398
3555
|
return gate;
|
|
3399
3556
|
}
|
|
3400
3557
|
/**
|
|
3401
|
-
* #
|
|
3402
|
-
*
|
|
3403
|
-
*
|
|
3404
|
-
*
|
|
3405
|
-
*
|
|
3406
|
-
* -
|
|
3407
|
-
*
|
|
3408
|
-
* -
|
|
3409
|
-
*
|
|
3410
|
-
*
|
|
3411
|
-
*
|
|
3412
|
-
*
|
|
3413
|
-
* in, its cookie) confirms the same way. A public link never qualifies (evaluateWebAuthority refuses it). General
|
|
3414
|
-
* still hears it: a notice, not a step.
|
|
3558
|
+
* AGEND-122 (upstream #3486, R1): a held change confirmed by the request itself — by the role of whoever asks, not by a
|
|
3559
|
+
* proof given once per browser. A signed-in human fleet admin on a web cookie session may press Apply now from wherever
|
|
3560
|
+
* the dashboard is reached (this computer, a LAN or tailnet name, a link), for every kind of change, on a chat fleet and
|
|
3561
|
+
* on a web-only one alike. settings-role.ts has the checks, asked of the live session now and again at execution:
|
|
3562
|
+
* - a cookie session of an admin (a guest, a read-only session, a header token, the CLI and an agent's request never);
|
|
3563
|
+
* - the owner's own knobs: the web authorization switch, "Only this computer can authorize", and the link option of a
|
|
3564
|
+
* link the session arrived over;
|
|
3565
|
+
* - a chat account is still an admin of its connection, and of every connection the change touches (the scope the
|
|
3566
|
+
* store holds; when that is not known, its own connection's admin list is all there is to ask).
|
|
3567
|
+
* It no longer asks that a chat card could have been posted, that the account confirmed this browser in a DM (#1939),
|
|
3568
|
+
* or that the host's own session confirms: those were what sent a remote admin to the AgEnD computer. The chat card
|
|
3569
|
+
* stays another way to confirm; General is told of a change a chat account confirmed here, when one can be.
|
|
3415
3570
|
*/
|
|
3416
3571
|
settingsSelfConfirmation(store, req, id) {
|
|
3417
|
-
const
|
|
3418
|
-
if (
|
|
3572
|
+
const first = this.settingsRole(req);
|
|
3573
|
+
if (!first.role.ok || !first.handle)
|
|
3419
3574
|
return null;
|
|
3420
|
-
|
|
3421
|
-
//
|
|
3422
|
-
//
|
|
3423
|
-
|
|
3424
|
-
// (A web-only fleet's host operator has its own rule below, with its revocable authorization.) The noSelfConfirm changes
|
|
3425
|
-
// the leader ruled on are included: the outward Hub changes (hostLocalConfirm) and a link option turned on
|
|
3426
|
-
// (hostSessionOnly, cid-d3) — this session is exactly the one those allow.
|
|
3427
|
-
// "No card": none could be posted now, or the one tried could not be (posting failed or ran out — the view says
|
|
3428
|
-
// host_cli; #3362 review N1).
|
|
3429
|
-
const noCard = () => !this.settingsCardPossible(store, id) || store.inspect(id)?.confirmation.kind === "host_cli";
|
|
3430
|
-
if (!this.isWebOnlyFleet() && hostSessionHere(auth.session, req) && noCard()
|
|
3431
|
-
&& (store.selfConfirmable(id) || store.hostLocalConfirmable(id) || store.hostSessionConfirmable(id))) {
|
|
3432
|
-
// A card that could not be posted stays unposted (no card is attached later): fixed now, not re-read at execution,
|
|
3433
|
-
// where the store has already marked the change as confirmed from the web.
|
|
3434
|
-
const handle = auth.session.handle, postFailed = store.inspect(id)?.confirmation.kind === "host_cli";
|
|
3435
|
-
const here = () => {
|
|
3436
|
-
const now = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3437
|
-
return now.kind === "ok" && now.session.handle === handle && hostSessionHere(now.session, req) && !this.isWebOnlyFleet();
|
|
3438
|
-
};
|
|
3439
|
-
return {
|
|
3440
|
-
label: t("settings_confirm.host_operator_label"),
|
|
3441
|
-
current: () => here() && (postFailed || !this.settingsCardPossible(store, id)),
|
|
3442
|
-
done: view => { this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed from the web by this computer's admin (no General could take it)"); },
|
|
3443
|
-
};
|
|
3444
|
-
}
|
|
3445
|
-
// #2453 (§0.2): never over the public link — not even a named-link session that is web-verified there. #3008: except
|
|
3446
|
-
// this computer's admin signed in from outside (the authenticator's code, over the link connections from outside
|
|
3447
|
-
// opened): the web-only fleet's owner, judged below by the same authority as here (hostOperator).
|
|
3448
|
-
if (gatewayRequestContext(req) && auth.session.remote !== "totp")
|
|
3575
|
+
const handle = first.handle, actor = first.role.actor, account = first.role.account;
|
|
3576
|
+
// This admin's own stricter switch: off this computer, each of THEIR confirmations takes their authenticator's code instead
|
|
3577
|
+
// (settingsCodeSession) — never Apply now, whatever the session is (a link's, the owner signed in from outside, a LAN's).
|
|
3578
|
+
if (this.strictFor(first.role.actor) && !first.role.onHost)
|
|
3449
3579
|
return null;
|
|
3450
|
-
|
|
3451
|
-
// ruling on #3352 F1; threat model A 64a289a0): the outward Hub changes (hostLocalConfirm) are the one exception — for
|
|
3452
|
-
// the host operator's own local session only (below).
|
|
3453
|
-
if (!store.selfConfirmable(id) && !store.hostLocalConfirmable(id) && !store.hostSessionConfirmable(id))
|
|
3580
|
+
if (account && !this.settingsAccountMayConfirm(store, id, actor))
|
|
3454
3581
|
return null;
|
|
3455
|
-
|
|
3456
|
-
const
|
|
3457
|
-
const now = this.
|
|
3458
|
-
|
|
3459
|
-
|
|
3582
|
+
// Asked again at execution, from the same request's cookie: still this session, still this role, still an admin.
|
|
3583
|
+
const current = () => {
|
|
3584
|
+
const now = this.settingsRole(req);
|
|
3585
|
+
return now.role.ok && now.handle === handle && now.role.actor.user_id === actor.user_id && now.role.actor.adapter_id === actor.adapter_id
|
|
3586
|
+
&& (!now.role.account || this.settingsAccountMayConfirm(store, id, actor));
|
|
3460
3587
|
};
|
|
3461
|
-
const
|
|
3462
|
-
if (!
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
// link option turned on (hostSessionOnly — the outside sign-in, a gateway, never may).
|
|
3471
|
-
const hostLocal = () => hostSessionHere(record, req);
|
|
3472
|
-
if (hostOperator(actor) && (store.selfConfirmable(id) || hostLocal())) {
|
|
3473
|
-
return {
|
|
3474
|
-
label: t("settings_confirm.host_operator_label"),
|
|
3475
|
-
current: () => hostOperator(verified()) && (store.selfConfirmable(id) || hostLocal()),
|
|
3476
|
-
done: view => { this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed from the web by this computer's admin"); },
|
|
3477
|
-
};
|
|
3588
|
+
const notice = this.settingsRemoteNoticeKind(store, id, first.role.onHost);
|
|
3589
|
+
if (!account) {
|
|
3590
|
+
const who = t("settings_confirm.host_operator_label");
|
|
3591
|
+
return { label: who, current,
|
|
3592
|
+
done: view => {
|
|
3593
|
+
this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed from the web by this fleet's admin");
|
|
3594
|
+
if (notice)
|
|
3595
|
+
this.postSettingsRemoteNotice(view, notice, who);
|
|
3596
|
+
} };
|
|
3478
3597
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3598
|
+
const name = this.webPerson({ adapterId: actor.adapter_id, userId: actor.user_id }).name;
|
|
3599
|
+
// General hears of it when a chat card could have been posted (the old rule's own scope); it is a notice, not a step.
|
|
3481
3600
|
const chat = this.settingsChatAuthority(store, id);
|
|
3482
|
-
if (!chat)
|
|
3483
|
-
return null;
|
|
3484
|
-
const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
|
|
3485
|
-
const own = channels.filter(ch => (ch.id ?? ch.type) === actor.adapter_id);
|
|
3486
|
-
if (own.length !== 1 || own[0].type !== chat.platform || !chat.admin(actor.user_id))
|
|
3487
|
-
return null;
|
|
3488
3601
|
const affected = [...store.affectedConnections(id)]; // read now: a finished change no longer has them
|
|
3489
|
-
const destinations = this.settingsNoticeGenerals(affected, chat.platform);
|
|
3490
|
-
if (!destinations.length)
|
|
3491
|
-
return null;
|
|
3492
|
-
const name = this.webPerson({ adapterId: actor.adapter_id, userId: actor.user_id }).name;
|
|
3602
|
+
const destinations = chat ? this.settingsNoticeGenerals(affected, chat.platform) : [];
|
|
3493
3603
|
return {
|
|
3494
3604
|
label: t("settings_confirm.web_verified_label", name),
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3605
|
+
current,
|
|
3606
|
+
...(destinations.length ? { followStop: async (stopped, begin) => {
|
|
3607
|
+
const route = destinations.find(item => item.current());
|
|
3608
|
+
if (!route)
|
|
3609
|
+
throw Error("Settings route expired");
|
|
3610
|
+
await route.followStop(stopped, begin);
|
|
3611
|
+
} } : {}),
|
|
3612
|
+
done: view => {
|
|
3613
|
+
if (notice) {
|
|
3614
|
+
this.postSettingsRemoteNotice(view, notice, name);
|
|
3615
|
+
return;
|
|
3616
|
+
} // that Notice says it already, to General or the web
|
|
3617
|
+
if (chat && destinations.length)
|
|
3618
|
+
return this.settingsWebConfirmedNotice(view, affected, name, chat.platform);
|
|
3619
|
+
},
|
|
3500
3620
|
};
|
|
3501
3621
|
}
|
|
3502
3622
|
/**
|
|
3503
|
-
*
|
|
3504
|
-
*
|
|
3505
|
-
*
|
|
3506
|
-
*
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
//
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
//
|
|
3517
|
-
|
|
3518
|
-
|
|
3623
|
+
* AGEND-122 (Prism P2): whether the ordinary New Agent shortcut — created at once, web-confirmed, with no held change — is open to
|
|
3624
|
+
* this request. It is the same policy as Apply now: refused where "Only this computer can authorize" is on and this is not the
|
|
3625
|
+
* AgEnD computer, and off the computer for an admin whose own "ask for my code" switch is on (the creation then waits as a held
|
|
3626
|
+
* change and takes their code). Everything else is as before the role existed.
|
|
3627
|
+
*/
|
|
3628
|
+
settingsDirectCreationAllowed(req) {
|
|
3629
|
+
// Admin eligibility is asked with the web authorization switch taken OUT of the question (`ignoreSwitch`): that switch governs
|
|
3630
|
+
// what a web message carries to an agent and has never stopped a local admin creating one, but it must not stand in for the
|
|
3631
|
+
// other checks — an admin tier session, the token epoch, "Only this computer can authorize", and a chat account that is
|
|
3632
|
+
// still an admin of its connection (or the host's / a web-only fleet's own admin). A refused role is not permission.
|
|
3633
|
+
const { role } = this.settingsRole(req, { ignoreSwitch: true });
|
|
3634
|
+
if (!role.ok)
|
|
3635
|
+
return false;
|
|
3636
|
+
// Switch off: no Apply now exists, so nothing is asked of an admin's own "ask for my code" switch either (the legacy path).
|
|
3637
|
+
if (!this.webAuthorityState().enabled)
|
|
3638
|
+
return true;
|
|
3639
|
+
return role.onHost || !this.strictFor(role.actor);
|
|
3640
|
+
}
|
|
3641
|
+
/** AGEND-122: this request's role over a held change — its cookie session asked afresh each time (settings-role.ts). */
|
|
3642
|
+
settingsRole(req, opts = {}) {
|
|
3643
|
+
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3644
|
+
if (auth.kind !== "ok")
|
|
3645
|
+
return { role: { ok: false, reason: "not_session" }, handle: null };
|
|
3646
|
+
const state = this.webAuthorityState();
|
|
3647
|
+
const role = evaluateSettingsRole({
|
|
3648
|
+
session: auth.session, gateway: !!gatewayRequestContext(req), peer: webPeerOf(req),
|
|
3649
|
+
tokenEpoch: this.webToken ? tokenEpoch(this.webToken) : null, webOnly: this.isWebOnlyFleet(),
|
|
3650
|
+
policy: { enabled: state.enabled || opts.ignoreSwitch === true, loopbackOnly: state.loopbackOnly, namedLink: state.namedLink, quickLink: state.quickLink },
|
|
3651
|
+
isAdmin: (userId, adapterId) => this.adminGate(userId, adapterId) === "ok", outside: this.outsideLink(),
|
|
3652
|
+
});
|
|
3653
|
+
return { role, handle: auth.session.handle };
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* AGEND-122 (upstream R1): a change that opens a link, or one that changes a secret, confirmed from another device always
|
|
3657
|
+
* posts a Notice — the audit trail alone is not what the owner sees. Null: not one of those, or confirmed on this computer.
|
|
3658
|
+
*/
|
|
3659
|
+
settingsRemoteNoticeKind(store, id, onHost) {
|
|
3660
|
+
if (onHost)
|
|
3661
|
+
return null;
|
|
3662
|
+
if (store.opensLink(id))
|
|
3663
|
+
return "link";
|
|
3664
|
+
return store.inspect(id)?.section === "secret" ? "secret" : null;
|
|
3665
|
+
}
|
|
3666
|
+
/**
|
|
3667
|
+
* Where that Notice goes: a web-only fleet's dashboard Notices; a chat fleet's General, else its primary connection's notice
|
|
3668
|
+
* target (notifyFleetError) — and when nothing could be posted there, the web Notices, which a chat fleet's dashboard then
|
|
3669
|
+
* shows. Never throttled, and never silent. It names the change as the card showed it (redacted), who confirmed and how.
|
|
3670
|
+
*/
|
|
3671
|
+
postSettingsRemoteNotice(view, kind, who) {
|
|
3672
|
+
const outcome = view.outcome ? view.outcome.message : view.state;
|
|
3673
|
+
const text = t("settings_confirm.remote_notice", who, t(`settings_confirm.remote_kind_${kind}`), view.summary.join("\n"), outcome);
|
|
3674
|
+
this.postFleetSecurityNotice(text, view.id);
|
|
3675
|
+
}
|
|
3676
|
+
/**
|
|
3677
|
+
* A security Notice that must not be silent: where a fleet notice goes (General, else the primary connection's notice target,
|
|
3678
|
+
* else a web-only fleet's dashboard Notices) and, when nothing could be posted there, the web Notices store directly — which a
|
|
3679
|
+
* chat fleet's dashboard then shows (recordWebNotice itself refuses a chat fleet). Never throttled; redacted like any Notice.
|
|
3680
|
+
*/
|
|
3681
|
+
postFleetSecurityNotice(text, id) {
|
|
3682
|
+
// The usual fleet notice (General, else the primary connection's notice target; a web-only fleet's dashboard Notices) ...
|
|
3683
|
+
let sent = false;
|
|
3684
|
+
try {
|
|
3685
|
+
sent = this.notifyFleetError(text, { throttle: false });
|
|
3686
|
+
}
|
|
3687
|
+
catch (err) {
|
|
3688
|
+
this.logger.warn({ err, id }, "A security Notice could not be sent to the primary General");
|
|
3689
|
+
}
|
|
3690
|
+
if (this.isWebOnlyFleet()) {
|
|
3691
|
+
if (sent)
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
else {
|
|
3695
|
+
// ... and every OTHER connection's General too: their admin lists can be disjoint, so the primary one is not everyone.
|
|
3696
|
+
const generals = Object.entries(this.fleetConfig?.instances ?? {}).filter(([, cfg]) => cfg.general_topic === true).map(([name]) => name);
|
|
3697
|
+
for (const name of generals.slice(1)) {
|
|
3698
|
+
try {
|
|
3699
|
+
this.notifyInstanceTopic(name, text);
|
|
3700
|
+
}
|
|
3701
|
+
catch (err) {
|
|
3702
|
+
this.logger.warn({ err, id }, "A security Notice could not be sent to one General");
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
// And on a chat fleet always the shared web Notices — persisted, shown to every admin of the dashboard: a chat send reports a
|
|
3707
|
+
// dispatch, not a delivery, and may fail afterwards or never reach an admin of another connection.
|
|
3708
|
+
const store = this.webNoticeStore(), note = store?.add({ kind: "fleet", text: stripPlaceRefs(text) });
|
|
3709
|
+
if (note && store)
|
|
3710
|
+
this.emitSseEvent("notice", { notice: note, unread: store.unread() });
|
|
3711
|
+
else
|
|
3712
|
+
this.logger.warn({ id }, "A security Notice could not be announced on the dashboard");
|
|
3713
|
+
}
|
|
3714
|
+
/** Who an authenticator action is named after in its Notice. */
|
|
3715
|
+
adminName(actor) {
|
|
3716
|
+
return actor.adapter_id === HOST_OPERATOR.adapterId && actor.user_id === HOST_OPERATOR.userId
|
|
3717
|
+
? t("settings_confirm.host_operator_label") : this.webPerson({ adapterId: actor.adapter_id, userId: actor.user_id }).name;
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* AGEND-122: a chat account confirms a change only as an admin of every connection it touches — settingsChatAuthority's own
|
|
3721
|
+
* rule, without needing a General to post to: the scope the store holds (a scope not known: none, fail closed), and, for a
|
|
3722
|
+
* change with `primaryGeneral` (the Hub, the connection list and order, whole-fleet sensitive settings), the connection that owns
|
|
3723
|
+
* the primary General too. Every connection involved, the account's own included, is configured exactly once and on one platform
|
|
3724
|
+
* (user ids are per platform). Asked at entry and again by `current()`.
|
|
3725
|
+
*/
|
|
3726
|
+
settingsAccountMayConfirm(store, id, actor) {
|
|
3727
|
+
const scope = store.authorityOf(id);
|
|
3728
|
+
if (!scope || scope.unknown || !actor.user_id)
|
|
3729
|
+
return false;
|
|
3730
|
+
const targets = new Set(scope.connections);
|
|
3731
|
+
if (scope.primaryGeneral) {
|
|
3732
|
+
const primary = this.settingsPrimaryGeneral();
|
|
3733
|
+
if (!primary)
|
|
3734
|
+
return false;
|
|
3735
|
+
targets.add(primary.owner);
|
|
3736
|
+
}
|
|
3737
|
+
const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
|
|
3738
|
+
const configured = (connection) => channels.filter(ch => (ch.id ?? ch.type) === connection);
|
|
3739
|
+
if ([actor.adapter_id, ...targets].some(connection => configured(connection).length !== 1))
|
|
3740
|
+
return false;
|
|
3741
|
+
const platform = configured(actor.adapter_id)[0].type;
|
|
3742
|
+
return [...targets].every(connection => configured(connection)[0].type === platform && this.isFleetAdmin(actor.user_id, connection));
|
|
3743
|
+
}
|
|
3744
|
+
/**
|
|
3745
|
+
* AGEND-122 (upstream #3486, per admin): each admin's own stricter switch — off by default, kept with their own authenticator
|
|
3746
|
+
* (web-remote-access.ts) and never in fleet.yaml. While it is on, THEIR confirmations from a page that is not the browser on the
|
|
3747
|
+
* AgEnD computer itself do not press Apply now: each takes the code of their own app, bound to that one change
|
|
3748
|
+
* (settingsTotpConfirm). Another admin is never asked, and cannot turn it on or off for them. The computer's own browser is not
|
|
3749
|
+
* asked. The switch lives in the app's record, so it can only be on while the app is set up.
|
|
3750
|
+
*/
|
|
3751
|
+
strictFor(actor) {
|
|
3752
|
+
return !!this.webRemoteAccess()?.strictOf(adminKey(actor.adapter_id, actor.user_id));
|
|
3753
|
+
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Who is asked for the code: a session with a role over a held change (settings-role.ts) that is not on this computer,
|
|
3756
|
+
* while the option is on. The role carries every check Apply now has — the web authorization switch, "Only this computer
|
|
3757
|
+
* can authorize" (Q6), the link options, a chat account still an admin of the connections the change touches — asked at
|
|
3758
|
+
* entry and again by `current()` at execution, so a demoted admin's pending change never runs. One refusal on top: a change
|
|
3759
|
+
* that opens a link is never confirmed over a link (the public gateway, bound by the gateway itself, never by a header), the
|
|
3760
|
+
* code or not. The code is the authority; the session only carries it.
|
|
3761
|
+
*/
|
|
3762
|
+
settingsCodeSession(store, req, id) {
|
|
3763
|
+
const check = (asking) => {
|
|
3764
|
+
const { role, handle } = this.settingsRole(req);
|
|
3765
|
+
if (!role.ok || !handle || role.onHost)
|
|
3519
3766
|
return null;
|
|
3520
|
-
|
|
3521
|
-
if (auth.kind !== "ok")
|
|
3767
|
+
if (asking && !this.strictFor(role.actor))
|
|
3522
3768
|
return null;
|
|
3523
|
-
|
|
3524
|
-
if (s.tier !== "admin" || s.owner)
|
|
3769
|
+
if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
|
|
3525
3770
|
return null;
|
|
3526
|
-
if (
|
|
3771
|
+
if (store.opensLink(id) && gatewayRequestContext(req))
|
|
3527
3772
|
return null;
|
|
3528
|
-
|
|
3529
|
-
return s.surface === "local" && (peer === "loopback" || peer === "lan") ? { handle: s.handle } : null;
|
|
3773
|
+
return { handle, actor: role.actor, account: role.account };
|
|
3530
3774
|
};
|
|
3531
|
-
const first =
|
|
3775
|
+
const first = check(true);
|
|
3532
3776
|
if (!first)
|
|
3533
3777
|
return null;
|
|
3534
|
-
|
|
3778
|
+
// Asked again at execution: the same session and account, the same role (an option turned off since stays what was confirmed).
|
|
3779
|
+
return { ...first, current: () => { const now = check(false); return !!now && now.handle === first.handle && now.actor.user_id === first.actor.user_id && now.actor.adapter_id === first.actor.adapter_id; } };
|
|
3780
|
+
}
|
|
3781
|
+
/** One look at a code, for every place that asks for one: the fleet-wide wrong-code limit and a clock that looks off, logged and noticed the same way. */
|
|
3782
|
+
checkAuthenticatorCode(access, who, code, what) {
|
|
3783
|
+
const enrollment = access.enrollmentOf(who);
|
|
3784
|
+
const v = access.verify(code, who);
|
|
3785
|
+
if (v.kind === "ok")
|
|
3786
|
+
return enrollment ? { ok: true, enrollment } : { ok: false, error: "not_here" };
|
|
3787
|
+
if (v.kind === "paused")
|
|
3788
|
+
return { ok: false, error: "paused", retryAfterMs: v.retryAfterMs };
|
|
3789
|
+
if (v.kind === "not_enrolled")
|
|
3790
|
+
return { ok: false, error: "not_here" };
|
|
3791
|
+
if (v.kind === "unavailable")
|
|
3792
|
+
return { ok: false, error: "unavailable" };
|
|
3793
|
+
if (v.skewSteps !== null)
|
|
3794
|
+
this.logger.warn({ offsetSeconds: v.skewSteps * TOTP_STEP_SECONDS }, "A wrong authenticator code matched a nearby time step: this computer's clock may be off");
|
|
3795
|
+
this.logger.info({ what }, "A wrong authenticator code was refused");
|
|
3796
|
+
if (v.paused) {
|
|
3797
|
+
this.logger.warn({ waitMs: v.retryAfterMs }, "Authenticator codes paused after wrong codes");
|
|
3798
|
+
this.recordWebNotice("fleet", t("outside.notice_paused", outsideDuration(v.retryAfterMs), v.wrong));
|
|
3799
|
+
return { ok: false, error: "paused", retryAfterMs: v.retryAfterMs };
|
|
3800
|
+
}
|
|
3801
|
+
return { ok: false, error: "wrong" };
|
|
3802
|
+
}
|
|
3803
|
+
/**
|
|
3804
|
+
* AGEND-122: a page that is not the browser on the AgEnD computer itself — a LAN or tailnet connection (a Host that is
|
|
3805
|
+
* not loopback, a forwarding header, a peer that is not this machine) or a link. Said to the card so it names no host
|
|
3806
|
+
* command and no "go to that computer" step the reader cannot take; asked per request and never a check: what a page may
|
|
3807
|
+
* confirm is still settingsSelfConfirmation / settingsCodeSession, and the card's wording is all this changes.
|
|
3808
|
+
*/
|
|
3809
|
+
settingsPageIsRemote(req) {
|
|
3810
|
+
return webPeerOf(req) !== "loopback";
|
|
3535
3811
|
}
|
|
3536
3812
|
settingsTotpState(store, req, id) {
|
|
3537
|
-
|
|
3538
|
-
//
|
|
3539
|
-
if (
|
|
3540
|
-
return
|
|
3541
|
-
|
|
3813
|
+
const { role } = this.settingsRole(req);
|
|
3814
|
+
// The owner turned on "Only this computer can authorize": a page that is not on this computer is told so, in plain words.
|
|
3815
|
+
if (!role.ok)
|
|
3816
|
+
return role.reason === "loopback_only" ? "host_only" : null;
|
|
3817
|
+
// Apply now is open to it (the option is off, or this is the AgEnD computer's own browser): no code is asked.
|
|
3818
|
+
if (!this.strictFor(role.actor) || role.onHost)
|
|
3542
3819
|
return null;
|
|
3543
|
-
|
|
3544
|
-
if (gatewayRequestContext(req))
|
|
3545
|
-
return this.isWebOnlyFleet() && !this.settingsSelfConfirmation(store, req, id) ? "on_host" : null;
|
|
3546
|
-
if (!this.settingsTotpSession(req))
|
|
3820
|
+
if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
|
|
3547
3821
|
return null;
|
|
3548
|
-
if (
|
|
3549
|
-
return
|
|
3550
|
-
return this.webRemoteAccess()?.
|
|
3822
|
+
if (store.opensLink(id) && gatewayRequestContext(req))
|
|
3823
|
+
return "on_host";
|
|
3824
|
+
return this.webRemoteAccess()?.isEnrolled(adminKey(role.actor.adapter_id, role.actor.user_id)) ? "ready" : "not_set_up";
|
|
3551
3825
|
}
|
|
3826
|
+
/**
|
|
3827
|
+
* The code, checked: the change's digest first (a stale page never burns a code), then one use per time step and the
|
|
3828
|
+
* fleet-wide wrong-code limit (web-remote-access.ts), then a confirmation asked again at execution (`current`) — the same
|
|
3829
|
+
* session and role, the same enrolment (an app replaced, or removed and set up again, while the change waits ends it for good).
|
|
3830
|
+
*/
|
|
3552
3831
|
settingsTotpConfirm(store, req, id, code, digest) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
const
|
|
3556
|
-
if (!local || !local.current() || !access?.
|
|
3832
|
+
const local = this.settingsCodeSession(store, req, id), access = this.webRemoteAccess();
|
|
3833
|
+
// The code checked is the CONFIRMING admin's own: their record, never another admin's or the fleet's.
|
|
3834
|
+
const mine = local ? adminKey(local.actor.adapter_id, local.actor.user_id) : "";
|
|
3835
|
+
if (!local || !local.current() || !access?.isEnrolled(mine))
|
|
3557
3836
|
return { error: "not_here" };
|
|
3558
3837
|
// #3352 security review, point 2: the code confirms exactly the change the page showed — checked before the code is.
|
|
3559
3838
|
if (digest !== store.confirmDigest(id))
|
|
3560
3839
|
return { error: "changed" };
|
|
3561
3840
|
const shown = store.inspectHost(id)?.view.summary ?? [];
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
if (v.kind === "not_enrolled")
|
|
3582
|
-
return { error: "not_here" };
|
|
3583
|
-
if (v.kind === "unavailable")
|
|
3584
|
-
return { error: "unavailable" };
|
|
3585
|
-
if (v.skewSteps !== null)
|
|
3586
|
-
this.logger.warn({ offsetSeconds: v.skewSteps * TOTP_STEP_SECONDS }, "A wrong authenticator code matched a nearby time step: this computer's clock may be off");
|
|
3587
|
-
this.logger.info({ id, handle: local.handle }, "Settings change: a wrong authenticator code was refused");
|
|
3588
|
-
if (v.paused) {
|
|
3589
|
-
this.logger.warn({ waitMs: v.retryAfterMs }, "Authenticator codes paused after wrong codes");
|
|
3590
|
-
this.recordWebNotice("fleet", t("outside.notice_paused", outsideDuration(v.retryAfterMs), v.wrong));
|
|
3591
|
-
return { error: "paused", retryAfterMs: v.retryAfterMs };
|
|
3592
|
-
}
|
|
3593
|
-
return { error: "wrong" };
|
|
3841
|
+
const checked = this.checkAuthenticatorCode(access, mine, code, "settings change");
|
|
3842
|
+
if (!checked.ok)
|
|
3843
|
+
return { error: checked.error, ...(checked.retryAfterMs !== undefined ? { retryAfterMs: checked.retryAfterMs } : {}) };
|
|
3844
|
+
const enrollment = checked.enrollment;
|
|
3845
|
+
this.logger.info({ id, handle: local.handle }, "Settings change confirmed with the authenticator code");
|
|
3846
|
+
const notice = this.settingsRemoteNoticeKind(store, id, false); // the code is asked off this computer only
|
|
3847
|
+
const who = `${this.adminName(local.actor)} · ${t("settings_confirm.totp_label")}`;
|
|
3848
|
+
let lost = false;
|
|
3849
|
+
const current = () => {
|
|
3850
|
+
if (!lost && !(local.current() && this.webRemoteAccess()?.enrollmentOf(mine) === enrollment))
|
|
3851
|
+
lost = true;
|
|
3852
|
+
return !lost;
|
|
3853
|
+
};
|
|
3854
|
+
return { label: t("settings_confirm.totp_label"), current, audit: { confirmed_with: "authenticator_code", summary: shown },
|
|
3855
|
+
done: view => {
|
|
3856
|
+
this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed with the authenticator code: done");
|
|
3857
|
+
if (notice)
|
|
3858
|
+
this.postSettingsRemoteNotice(view, notice, who);
|
|
3859
|
+
} };
|
|
3594
3860
|
}
|
|
3595
3861
|
/**
|
|
3596
3862
|
* alpha.2 (M-2300; #2973's agent requests, junsion's §6): on a fleet with no chat connection there is no General to
|
|
@@ -3637,72 +3903,123 @@ export class FleetManager {
|
|
|
3637
3903
|
return this.fleetConfig?.web?.login_qr === true;
|
|
3638
3904
|
}
|
|
3639
3905
|
/**
|
|
3640
|
-
* GET /ui/devices: is this a web-only fleet, may THIS session
|
|
3641
|
-
*
|
|
3642
|
-
*
|
|
3643
|
-
*
|
|
3644
|
-
*
|
|
3906
|
+
* GET /ui/devices — the one device list, for every fleet (AGEND-138, #3486): is this a web-only fleet, may THIS session
|
|
3907
|
+
* approve a new device (web-only: the verified owner) and end the others' (`canEndOthers`), and — to an admin session,
|
|
3908
|
+
* never to a guest or the CLI's header token — every signed-in session of any tier, one row each (webDeviceRows).
|
|
3909
|
+
* `owner`: the verified owner (web-only: this computer's admin here or from outside; a chat fleet: an admin whose chat
|
|
3910
|
+
* account confirmed this session). `authority`: web authorization is on; with it off nobody is an owner, so on a web-only
|
|
3911
|
+
* fleet nobody may add a device or sign another out and the page says so.
|
|
3645
3912
|
*/
|
|
3646
3913
|
webDevicesStatus(req) {
|
|
3647
3914
|
const webOnly = this.isWebOnlyFleet();
|
|
3648
|
-
const owner = webOnly
|
|
3649
|
-
|
|
3915
|
+
const owner = webOnly ? !!this.deviceApprovalOwner(req) : !!this.webAuthorityRevoker(req);
|
|
3916
|
+
const rule = this.sessionEndRule(req);
|
|
3917
|
+
return { webOnly, owner, authority: this.webAuthorityState().enabled, canEndOthers: !!rule && (webOnly ? owner : true), devices: this.webDeviceRows(req) };
|
|
3918
|
+
}
|
|
3919
|
+
/**
|
|
3920
|
+
* AGEND-138 (#3486): which sessions may this ADMIN request sign out — one rule for every way in (POST /ui/devices/signout,
|
|
3921
|
+
* DELETE /auth/sessions[/<handle>]) and for the list's `canSignOut`; asked of the live session each time. Null: not an
|
|
3922
|
+
* admin session (a guest or read-only one ends only its own account's, auth-api; the header token none).
|
|
3923
|
+
* - a web-only fleet: the verified owner ends any; every other admin only itself (`any: false`);
|
|
3924
|
+
* - a fleet with a chat connection: an admin ends their OWN other devices (the same chat account) and any guest's or
|
|
3925
|
+
* read-only one; ANOTHER admin's devices only that admin. Every admin sign-in there records its account (`owner`: /web,
|
|
3926
|
+
* /dashboard and the per-admin authenticator); only a session with NO chat account (the host's own `agend web --code`,
|
|
3927
|
+
* or one persisted before accounts were recorded) counts as the host's — one principal that only another such session
|
|
3928
|
+
* may end, and that ends no chat admin's. It does not re-check that the account is still an admin (an existing
|
|
3929
|
+
* limitation of every admin API; follow-up).
|
|
3930
|
+
* Revoke-all (`revokeWebSessions`, /dashboard revoke) is the host's emergency button and is not this rule.
|
|
3931
|
+
*/
|
|
3932
|
+
sessionEndRule(req) {
|
|
3933
|
+
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3934
|
+
if (auth.kind !== "ok" || auth.session.tier !== "admin")
|
|
3935
|
+
return null;
|
|
3936
|
+
const me = auth.session;
|
|
3937
|
+
if (this.isWebOnlyFleet()) {
|
|
3938
|
+
const owner = !!this.deviceApprovalOwner(req);
|
|
3939
|
+
return { session: me, any: owner, may: r => r.handle === me.handle || owner, blocked: "owner_required" };
|
|
3940
|
+
}
|
|
3941
|
+
const principal = (r) => (r.owner ? `${r.owner.adapterId}\u0000${r.owner.userId}` : "\u0000host");
|
|
3942
|
+
return { session: me, any: true, may: r => r.handle === me.handle || r.tier !== "admin" || principal(r) === principal(me), blocked: "other_admin" };
|
|
3650
3943
|
}
|
|
3651
3944
|
/**
|
|
3652
|
-
*
|
|
3653
|
-
*
|
|
3654
|
-
*
|
|
3945
|
+
* AGEND-138: auth-api's narrowing of `DELETE /auth/sessions[/<handle>]` for an admin. Three answers, never confused:
|
|
3946
|
+
* a predicate (what this caller may end), `undefined` (a web-only fleet: no narrowing here, its own owner check stands) and
|
|
3947
|
+
* `null` — the caller could not be authenticated AGAIN just now (expired or signed out since auth-api's first check): a denial,
|
|
3948
|
+
* which must never be read as "no restriction" (PR #3553 review).
|
|
3949
|
+
*/
|
|
3950
|
+
endableSessions(req) {
|
|
3951
|
+
if (this.isWebOnlyFleet())
|
|
3952
|
+
return undefined;
|
|
3953
|
+
return this.sessionEndRule(req)?.may ?? null;
|
|
3954
|
+
}
|
|
3955
|
+
/**
|
|
3956
|
+
* Refs #3061 (P2b), AGEND-138: the device list — every signed-in session of any tier, newest activity first: its tier,
|
|
3957
|
+
* how it was approved, whether it carries owner authority, whether it is the reader's own, and whether the reader may sign
|
|
3958
|
+
* it out (and if not, why). Only an admin session reads it: a guest, a read-only session and the header token get none,
|
|
3959
|
+
* so no one sees another person's devices unless they are an admin.
|
|
3655
3960
|
*
|
|
3656
|
-
* `
|
|
3657
|
-
*
|
|
3658
|
-
* not an owner until the authenticator vouches for it. Display only — the checks that act
|
|
3961
|
+
* `verified` is the §3 verdict for an admin session as it would be used from where it signs in (a host session from this
|
|
3962
|
+
* computer, a session from outside over the link, a chat account's confirmed one): one that signed in with a one-time
|
|
3963
|
+
* code or a device approval is not an owner until the authenticator vouches for it. Display only — the checks that act
|
|
3964
|
+
* on it run again at each use.
|
|
3659
3965
|
*/
|
|
3660
3966
|
webDeviceRows(req) {
|
|
3661
|
-
const
|
|
3662
|
-
if (
|
|
3967
|
+
const rule = this.sessionEndRule(req);
|
|
3968
|
+
if (!rule || !this.webSessions)
|
|
3663
3969
|
return [];
|
|
3664
3970
|
const authorizations = this.sessionAuthorizationStore();
|
|
3665
|
-
return this.webSessions.list(
|
|
3971
|
+
return this.webSessions.list(rule.session.idHash, () => true).map(summary => {
|
|
3666
3972
|
const record = this.webSessions.findByHandle(summary.handle);
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3973
|
+
// The reader's own row is judged on the request that asks (as the session menu's /ui/authorization is: tests/…-138), another
|
|
3974
|
+
// session as it signed in (we cannot know where it is now).
|
|
3975
|
+
const gateway = summary.current ? !!gatewayRequestContext(req) : summary.surface === "gateway";
|
|
3976
|
+
const peer = summary.current ? webPeerOf(req)
|
|
3977
|
+
: gateway ? authorizations?.get(summary.handle)?.peer ?? "quick_link" : record?.host === true ? "loopback" : authorizations?.get(summary.handle)?.peer ?? "lan";
|
|
3978
|
+
const verified = summary.tier === "admin" && !!record && !this.webAuthority({ session: record, gateway, peer }).refusal;
|
|
3979
|
+
const may = !summary.current && !!record && rule.may(record);
|
|
3980
|
+
return { handle: summary.handle, label: summary.label, tier: summary.tier, via: summary.via, verified, current: summary.current, surface: summary.surface,
|
|
3670
3981
|
created: summary.created, lastSeen: summary.lastSeen, expiresAt: Math.min(summary.absoluteExpiry, summary.idleExpiry),
|
|
3671
|
-
|
|
3982
|
+
canSignOut: may, ...(!summary.current && !may ? { signOutBlocked: rule.blocked } : {}) };
|
|
3672
3983
|
});
|
|
3673
3984
|
}
|
|
3674
3985
|
/**
|
|
3675
3986
|
* Refs #3061 (P2b): may this request's session end ANOTHER session — one signed in elsewhere, or all of them (auth-api
|
|
3676
3987
|
* `DELETE /auth/sessions…`, which an admin session could always do). On a web-only fleet that is the verified owner's:
|
|
3677
3988
|
* a session a code or a device approval made is signed in but not an owner, and could otherwise sign out the owner's
|
|
3678
|
-
* own. A fleet with a chat connection
|
|
3989
|
+
* own. A fleet with a chat connection: yes for an admin, within endableSessions' rule (AGEND-138). Ending one's OWN
|
|
3990
|
+
* session is never this.
|
|
3679
3991
|
*/
|
|
3680
3992
|
mayEndOtherSessions(req) {
|
|
3681
3993
|
return !this.isWebOnlyFleet() || !!this.deviceApprovalOwner(req);
|
|
3682
3994
|
}
|
|
3683
3995
|
/**
|
|
3684
|
-
* Refs #3061 (P2b): POST /ui/devices/signout {handle} —
|
|
3685
|
-
*
|
|
3686
|
-
* 403
|
|
3687
|
-
*
|
|
3688
|
-
*
|
|
3996
|
+
* Refs #3061 (P2b), AGEND-138: POST /ui/devices/signout {handle} — an admin ends another signed-in session, by the one
|
|
3997
|
+
* rule (sessionEndRule), asked of the live session each time. A web-only fleet: only the verified owner, and a non-owner
|
|
3998
|
+
* is refused (403 `owner_required`) BEFORE any handle is looked up, so it learns nothing about which handles exist. A chat
|
|
3999
|
+
* fleet: any admin for their own devices and any guest's or read-only one; another admin's device is refused (403
|
|
4000
|
+
* `other_admin`). Never the reader's own session here (Sign out is /auth/logout). The device's authorization goes with
|
|
4001
|
+
* it, so a copy of its cookie is nobody's.
|
|
3689
4002
|
*/
|
|
3690
4003
|
webDeviceSignOut(req, handle) {
|
|
3691
|
-
if (!this.
|
|
4004
|
+
if (!this.webSessions)
|
|
3692
4005
|
return { status: 404, body: { error: "not_found" } };
|
|
3693
|
-
const
|
|
3694
|
-
if (!
|
|
4006
|
+
const rule = this.sessionEndRule(req);
|
|
4007
|
+
if (!rule)
|
|
4008
|
+
return { status: 403, body: { error: "owner_required" } }; // not an admin session at all: the header token, a guest
|
|
4009
|
+
if (this.isWebOnlyFleet() && !rule.any)
|
|
3695
4010
|
return { status: 403, body: { error: "owner_required" } };
|
|
3696
|
-
if (handle ===
|
|
4011
|
+
if (handle === rule.session.handle)
|
|
3697
4012
|
return { status: 400, body: { error: "this_device" } };
|
|
3698
4013
|
const target = this.webSessions.findByHandle(handle);
|
|
3699
|
-
if (!target
|
|
4014
|
+
if (!target)
|
|
3700
4015
|
return { status: 404, body: { error: "not_found" } };
|
|
3701
|
-
|
|
4016
|
+
if (!rule.may(target))
|
|
4017
|
+
return { status: 403, body: { error: rule.blocked } };
|
|
4018
|
+
const { found, durable } = this.webSessions.revokeByHandle(handle);
|
|
3702
4019
|
if (!found)
|
|
3703
4020
|
return { status: 404, body: { error: "not_found" } };
|
|
3704
4021
|
this.sessionAuthorizationStore()?.prune(a => a.handle !== handle);
|
|
3705
|
-
this.logger.info({ by:
|
|
4022
|
+
this.logger.info({ by: rule.session.handle.slice(0, 8), handle, label: target.label, tier: target.tier, via: sessionVia(target), durable }, "Device signed out by an admin");
|
|
3706
4023
|
if (!durable)
|
|
3707
4024
|
return { status: 500, body: { ok: false, durable: false, error: "not_durable" } };
|
|
3708
4025
|
return { status: 200, body: { ok: true } };
|
|
@@ -3816,6 +4133,13 @@ export class FleetManager {
|
|
|
3816
4133
|
}
|
|
3817
4134
|
this.logger.info({ id: view.id }, "Settings change confirmed from the web: no General reachable for the notice");
|
|
3818
4135
|
}
|
|
4136
|
+
/** The primary General: the General on the primary connection, else the first one — and the connection that owns it. */
|
|
4137
|
+
settingsPrimaryGeneral() {
|
|
4138
|
+
const generals = Object.entries(this.fleetConfig?.instances ?? {}).filter(([, cfg]) => cfg.general_topic === true);
|
|
4139
|
+
const selected = generals.find(([name]) => this.getInstanceAdapterId(name) === this.getPrimaryAdapterId()) ?? generals[0];
|
|
4140
|
+
const owner = selected && this.getInstanceAdapterId(selected[0]);
|
|
4141
|
+
return selected && owner ? { name: selected[0], owner } : undefined;
|
|
4142
|
+
}
|
|
3819
4143
|
/** Exact configured effect owners; this does not depend on prompt location. */
|
|
3820
4144
|
settingsChatAuthority(store, id) {
|
|
3821
4145
|
const scope = store.authorityOf(id);
|
|
@@ -3824,12 +4148,7 @@ export class FleetManager {
|
|
|
3824
4148
|
const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
|
|
3825
4149
|
const targets = new Set(scope.connections);
|
|
3826
4150
|
let primaryGeneral;
|
|
3827
|
-
const selectPrimary = () =>
|
|
3828
|
-
const generals = Object.entries(this.fleetConfig?.instances ?? {}).filter(([, cfg]) => cfg.general_topic === true);
|
|
3829
|
-
const selected = generals.find(([name]) => this.getInstanceAdapterId(name) === this.getPrimaryAdapterId()) ?? generals[0];
|
|
3830
|
-
const owner = selected && this.getInstanceAdapterId(selected[0]);
|
|
3831
|
-
return selected && owner ? { name: selected[0], owner } : undefined;
|
|
3832
|
-
};
|
|
4151
|
+
const selectPrimary = () => this.settingsPrimaryGeneral();
|
|
3833
4152
|
if (scope.primaryGeneral) {
|
|
3834
4153
|
primaryGeneral = selectPrimary();
|
|
3835
4154
|
if (!primaryGeneral)
|
|
@@ -6483,6 +6802,8 @@ export class FleetManager {
|
|
|
6483
6802
|
}
|
|
6484
6803
|
/** #1218: GET /ui/steps — an instance's steps, read on demand (null: no such instance). */
|
|
6485
6804
|
logSteps(name, q) { return this.log.steps(name, q); }
|
|
6805
|
+
subagentReader = new SubagentService(name => this.lifecycle.daemons.get(name)?.subagentSource() ?? null);
|
|
6806
|
+
subagentRuns(name) { return this.subagentReader.read(name); }
|
|
6486
6807
|
/**
|
|
6487
6808
|
* #1218: where an instance's steps are read from, resolved only when its Log asks: the transcript its daemon follows
|
|
6488
6809
|
* now; for claude-code, also the path its statusline last named (so a stopped instance's Log still shows its last
|
|
@@ -9198,12 +9519,14 @@ export class FleetManager {
|
|
|
9198
9519
|
* A single-use login code for the dashboard, for a channel only the operator
|
|
9199
9520
|
* can read (`/dashboard`). Null while the panel is closed (no web.token).
|
|
9200
9521
|
*/
|
|
9201
|
-
issueDashboardLogin() {
|
|
9522
|
+
issueDashboardLogin(recipient) {
|
|
9202
9523
|
const token = this.webToken;
|
|
9203
9524
|
if (!token)
|
|
9204
9525
|
return null;
|
|
9205
9526
|
this.initializeWebSessions();
|
|
9206
|
-
|
|
9527
|
+
// AGEND-138 (#3486): given the admin it is for, the session this code makes is that admin's own (auth-api binds the session's
|
|
9528
|
+
// `owner` to the recipient) — so the devices rule (sessionEndRule) tells two admins apart. Without one: no account, the host's.
|
|
9529
|
+
const issued = this.webLoginCodes.issue({ tier: "admin", epoch: tokenEpoch(token), ...(recipient ? { recipient } : {}) });
|
|
9207
9530
|
return { display: issued.display, expiresAt: issued.expiresAt, ttlMinutes: Math.round(LOGIN_CODE_TTL_MS / 60_000) };
|
|
9208
9531
|
}
|
|
9209
9532
|
tunnelPurposeLane = null;
|
|
@@ -9791,6 +10114,24 @@ export class FleetManager {
|
|
|
9791
10114
|
await this.retireNonceButtons(entry, entry.messageId ?? data.messageId, lastSteps ? renderPublicLinkProgress(lastSteps, performance.now(), outcome) : outcome, data.editClicked, failUrlButtons);
|
|
9792
10115
|
return true;
|
|
9793
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
|
+
}
|
|
9794
10135
|
/** `/dashboard revoke`: sign out every browser and withdraw any unused code. */
|
|
9795
10136
|
revokeWebSessions() {
|
|
9796
10137
|
this.initializeWebSessions();
|
|
@@ -10917,6 +11258,8 @@ export class FleetManager {
|
|
|
10917
11258
|
if (ch.adapterId)
|
|
10918
11259
|
this.instanceWorldBinding.set(ch.instanceName, ch.adapterId);
|
|
10919
11260
|
}
|
|
11261
|
+
// #3526: catalogs belong to the fleet, including a fleet with no chat adapter.
|
|
11262
|
+
this.probeCliEnvs();
|
|
10920
11263
|
// #1565: the web chat as it was before this process — the configured instances' only (fleet.yaml and ClassicBot
|
|
10921
11264
|
// rooms), before the dashboard serves anything; from now on every change is written back (off the loop).
|
|
10922
11265
|
this.restoreWebChat(fleet);
|
|
@@ -12111,9 +12454,6 @@ export class FleetManager {
|
|
|
12111
12454
|
}, this.logger, "adapter.slash_command"));
|
|
12112
12455
|
// This adapter's own Telegram menus — each Telegram adapter registers its own when it starts (#1191).
|
|
12113
12456
|
this.registerTelegramCommandsFor(channelConfig);
|
|
12114
|
-
// Background-probe each backend's CLI env (version/models) → cli-env cache.
|
|
12115
|
-
// Non-blocking: /model & status views read the cache; never delays startup.
|
|
12116
|
-
this.probeCliEnvs();
|
|
12117
12457
|
adapter.on("started", safeHandler((username, userId) => {
|
|
12118
12458
|
if (!isCurrentAdapter())
|
|
12119
12459
|
return;
|
|
@@ -14085,6 +14425,13 @@ export class FleetManager {
|
|
|
14085
14425
|
isWebOnlyFleet() {
|
|
14086
14426
|
return isWebOnlyFleetConfig(this.fleetConfig);
|
|
14087
14427
|
}
|
|
14428
|
+
/**
|
|
14429
|
+
* S-117 story 1: the sign-in page's "no chat" words (no /web to send) — a web-only fleet, or one whose chat is not
|
|
14430
|
+
* connected yet (a fresh install whose bot is still being set up, or is down): /web cannot answer there.
|
|
14431
|
+
*/
|
|
14432
|
+
signinWithoutChat() {
|
|
14433
|
+
return this.isWebOnlyFleet() || ![...this.adapterState.values()].some(state => state.status === "connected");
|
|
14434
|
+
}
|
|
14088
14435
|
/** On a fleet with no chat platform, the dashboard is where an instance-health prompt is posted (#1307 item 6). */
|
|
14089
14436
|
webOnlyPromptPlace() {
|
|
14090
14437
|
return this.worlds.size === 0 && this.isWebOnlyFleet() ? { adapter: WEB_ONLY_PROMPT_SINK, adapterId: "web", chatId: "web" } : null;
|
|
@@ -15784,8 +16131,10 @@ export class FleetManager {
|
|
|
15784
16131
|
delete current[key];
|
|
15785
16132
|
Object.assign(current, resolved);
|
|
15786
16133
|
}
|
|
16134
|
+
const previousCatalogConfig = this.savedFleetConfigSnapshot;
|
|
15787
16135
|
this.savedFleetConfigSnapshot = structuredClone(this.fleetConfig);
|
|
15788
16136
|
this.nativeMcpStore?.observePolicies();
|
|
16137
|
+
this.probeChangedCliEnvs(previousCatalogConfig);
|
|
15789
16138
|
this.agentCredentialsCache?.observePolicies();
|
|
15790
16139
|
this.refreshSavedDashboardPermissions();
|
|
15791
16140
|
this.logger.info({ path: this.configPath, strippedDefaults: redundantPaths.length }, "Saved fleet config (lossless patch)");
|
|
@@ -17626,8 +17975,17 @@ export class FleetManager {
|
|
|
17626
17975
|
// rejects the message afterwards still consumes the throttle window, which
|
|
17627
17976
|
// is the pre-existing semantic and not something this change alters.
|
|
17628
17977
|
let dispatched = false;
|
|
17629
|
-
|
|
17630
|
-
|
|
17978
|
+
// A native-exec General is a web-chat status line (an SSE event with no browser receipt and no store): fine for a message nobody must not miss, never an acknowledgement.
|
|
17979
|
+
// For a caller that needs one it is shown best-effort (once) and delivery goes on to the primary channel or the durable Notice.
|
|
17980
|
+
const generalIsNative = !!general && isNativeExecInstance(this.fleetConfig?.instances[general]);
|
|
17981
|
+
if (general && opts.ack && generalIsNative && !this.ownerNoticeLive.has(body)) {
|
|
17982
|
+
this.ownerNoticeLive.add(body);
|
|
17983
|
+
if (this.ownerNoticeLive.size > 200)
|
|
17984
|
+
this.ownerNoticeLive.delete(this.ownerNoticeLive.values().next().value);
|
|
17985
|
+
this.emitSseEvent("message", { instance: general, role: "status", sender: "AgEnD", text: body, ts: new Date().toISOString() });
|
|
17986
|
+
}
|
|
17987
|
+
if (general && !(opts.ack && generalIsNative)) {
|
|
17988
|
+
dispatched = this.notifyInstanceTopic(general, body, undefined, opts.ack);
|
|
17631
17989
|
}
|
|
17632
17990
|
else {
|
|
17633
17991
|
// No General instance — fall back to the primary channel's own notice
|
|
@@ -17637,14 +17995,20 @@ export class FleetManager {
|
|
|
17637
17995
|
if (this.adapter && target) {
|
|
17638
17996
|
const out = this.renderPlaces(this.getPrimaryAdapterId(), body, target.opts);
|
|
17639
17997
|
this.adapter.sendText(target.chatId, out.text, out.opts)
|
|
17640
|
-
.
|
|
17998
|
+
.then(() => opts.ack?.(true), err => { this.logger.warn({ err }, "Failed to send fleet error notification"); opts.ack?.(false); });
|
|
17641
17999
|
dispatched = true;
|
|
17642
18000
|
}
|
|
17643
18001
|
}
|
|
17644
18002
|
// #2910 D2: a web-only fleet has no General: the notice goes to the dashboard's Notices instead (and spends the
|
|
17645
18003
|
// throttle window like a post would).
|
|
17646
|
-
|
|
17647
|
-
|
|
18004
|
+
// A caller that needs an acknowledgement (the owner notice) gets one only from a Notice that was WRITTEN: WebNotices.add keeps its item in memory even when the file cannot be written.
|
|
18005
|
+
if (!dispatched) {
|
|
18006
|
+
const recorded = opts.ack ? this.recordWebNoticeDurable("fleet", body) : this.recordWebNotice("fleet", body);
|
|
18007
|
+
if (recorded) {
|
|
18008
|
+
dispatched = true;
|
|
18009
|
+
opts.ack?.(true);
|
|
18010
|
+
}
|
|
18011
|
+
}
|
|
17648
18012
|
if (!dispatched) {
|
|
17649
18013
|
// Do NOT record the throttle key. It used to be claimed before delivery
|
|
17650
18014
|
// was attempted, so a message nobody could receive — every fleet error
|
|
@@ -17669,7 +18033,9 @@ export class FleetManager {
|
|
|
17669
18033
|
}
|
|
17670
18034
|
webNotices = null;
|
|
17671
18035
|
/** #2910 D2 (web-api): the Notices on a web-only fleet; null on any other (its General says them). */
|
|
17672
|
-
webNoticesFeed() { return this.
|
|
18036
|
+
webNoticesFeed() { return this.hasWebNotices() ? this.webNoticeStore() : null; }
|
|
18037
|
+
/** A web-only fleet always has its Notices; a chat fleet only once something was put there (AGEND-122: a confirmation that nothing else could carry). */
|
|
18038
|
+
hasWebNotices() { return !!this.webOnlyPromptPlace() || (this.webNoticeStore()?.newest() ?? 0) > 0; }
|
|
17673
18039
|
/** #2910 D2: the web-only fleet's Notices (web-notices.json), read on first use. */
|
|
17674
18040
|
webNoticeStore() {
|
|
17675
18041
|
if (!this.dataDir)
|
|
@@ -17693,11 +18059,12 @@ export class FleetManager {
|
|
|
17693
18059
|
return true;
|
|
17694
18060
|
}
|
|
17695
18061
|
/** #3373 review P2: recordWebNotice for a notice that must be on disk first — true only once it was written. */
|
|
17696
|
-
recordWebNoticeDurable(kind, text) {
|
|
18062
|
+
recordWebNoticeDurable(kind, text, instance) {
|
|
17697
18063
|
if (!this.webOnlyPromptPlace())
|
|
17698
18064
|
return false;
|
|
17699
18065
|
const store = this.webNoticeStore();
|
|
17700
|
-
const
|
|
18066
|
+
const known = instance !== undefined && Object.hasOwn(this.fleetConfig?.instances ?? {}, instance) ? instance : undefined;
|
|
18067
|
+
const notice = store?.addDurable({ kind, text: stripPlaceRefs(text), ...(known ? { instance: known } : {}) }) ?? null;
|
|
17701
18068
|
if (!notice)
|
|
17702
18069
|
return false;
|
|
17703
18070
|
this.emitSseEvent("notice", { notice, unread: store.unread() });
|
|
@@ -17715,18 +18082,23 @@ export class FleetManager {
|
|
|
17715
18082
|
* rejection surfaces only as a warn in its .catch. True delivery confirmation
|
|
17716
18083
|
* would have to make this async and change every caller.
|
|
17717
18084
|
*/
|
|
17718
|
-
notifyInstanceTopic(instanceName, text, extraOpts) {
|
|
18085
|
+
notifyInstanceTopic(instanceName, text, extraOpts, ack) {
|
|
17719
18086
|
if (isNativeExecInstance(this.fleetConfig?.instances[instanceName])) {
|
|
17720
18087
|
this.emitSseEvent("message", { instance: instanceName, role: "status", sender: "AgEnD", text, ts: new Date().toISOString() });
|
|
17721
|
-
return
|
|
18088
|
+
return !ack; // an SSE event is no acknowledgement
|
|
17722
18089
|
}
|
|
17723
18090
|
// #2910 D2: a web-only fleet has no topics: what the agent's topic would have been told is a Notice about it.
|
|
17724
|
-
if (this.webOnlyPromptPlace())
|
|
17725
|
-
|
|
18091
|
+
if (this.webOnlyPromptPlace()) {
|
|
18092
|
+
const recorded = ack ? this.recordWebNoticeDurable("instance", text, instanceName) : this.recordWebNotice("instance", text, instanceName);
|
|
18093
|
+
if (recorded)
|
|
18094
|
+
ack?.(true);
|
|
18095
|
+
return recorded;
|
|
18096
|
+
}
|
|
17726
18097
|
const send = this.sendToInstanceTopic(instanceName, text, extraOpts);
|
|
17727
18098
|
if (!send)
|
|
17728
18099
|
return false;
|
|
17729
|
-
|
|
18100
|
+
// `ack` (a caller that must not lose the message) is told when the platform took it or refused it; everyone else only gets the log line.
|
|
18101
|
+
send.sent.then(() => ack?.(true), e => { this.logger.warn({ err: e, instanceName }, send.failure); ack?.(false); });
|
|
17730
18102
|
return true;
|
|
17731
18103
|
}
|
|
17732
18104
|
/**
|
|
@@ -19040,7 +19412,7 @@ export class FleetManager {
|
|
|
19040
19412
|
tokenEpoch: this.webToken ? tokenEpoch(this.webToken) : null,
|
|
19041
19413
|
...(input.instance !== undefined ? { target: { adapterId: this.getInstanceAdapterId(input.instance) } } : {}),
|
|
19042
19414
|
isAdmin: (userId, adapterId) => this.adminGate(userId, adapterId) === "ok",
|
|
19043
|
-
authorization: input.session ? this.sessionAuthorizationStore()?.get(input.session.handle) ?? null : null,
|
|
19415
|
+
authorization: input.authorization !== undefined ? input.authorization : input.session ? this.sessionAuthorizationStore()?.get(input.session.handle) ?? null : null,
|
|
19044
19416
|
policy: { ...webAuthorityPolicy(this.fleetConfig?.web), enabled: state.enabled, loopbackOnly: state.loopbackOnly, namedLink: state.namedLink, quickLink: state.quickLink }, epoch: state.epoch, now: Date.now(),
|
|
19045
19417
|
hostOperator: this.isWebOnlyFleet(), outside: this.outsideLink(),
|
|
19046
19418
|
});
|
|
@@ -19172,56 +19544,173 @@ export class FleetManager {
|
|
|
19172
19544
|
isOutsideLink(exposureId) {
|
|
19173
19545
|
return this.outsideLink()?.exposureId === exposureId;
|
|
19174
19546
|
}
|
|
19175
|
-
/**
|
|
19547
|
+
/**
|
|
19548
|
+
* What Settings shows: THIS admin's own authenticator (set up or not, when, their own "ask for my code" switch), whether they
|
|
19549
|
+
* may set it up or change it here and whether that asks their current code; and, for the host operator on a web-only fleet,
|
|
19550
|
+
* the outside switch, a wait in force and the link — its address only to this computer.
|
|
19551
|
+
*/
|
|
19176
19552
|
webOutsideStatus(req) {
|
|
19177
|
-
const store = this.webRemoteAccess()
|
|
19553
|
+
const store = this.webRemoteAccess();
|
|
19554
|
+
const manager = this.authenticatorOwner(req);
|
|
19555
|
+
const status = store?.status(manager?.who ?? HOST_ADMIN_KEY);
|
|
19178
19556
|
const here = !!this.liveOwner(req, { hostOnly: true });
|
|
19179
19557
|
const open = this.outsideOn() ? this.publicWebLink?.openSignin() : null;
|
|
19180
19558
|
const mine = !!open && isOutsideLinkOwner(open.owner);
|
|
19181
19559
|
const linkStatus = this.outsideOn() ? this.getPublicWebStatus() : null;
|
|
19182
19560
|
return { webOnly: this.isWebOnlyFleet(), here, enrolled: !!status?.enrolled, enrolledAt: status?.enrolledAt ?? null,
|
|
19561
|
+
manage: !!manager, codeNeeded: !!manager && !!store && this.authenticatorCodeAsked(manager, store), strict: !!status?.strict,
|
|
19183
19562
|
outside: this.outsideOn(), pausedForMs: status?.pausedForMs ?? 0,
|
|
19184
19563
|
link: linkStatus && linkStatus.state !== "closed" ? { ...linkStatus, ...(here && mine ? { url: open.url } : {}), quick: !publicLinkNamedHostname(this.fleetConfig?.web) } : null };
|
|
19185
19564
|
}
|
|
19186
|
-
/**
|
|
19187
|
-
|
|
19188
|
-
|
|
19565
|
+
/**
|
|
19566
|
+
* AGEND-122 (per admin): who may set up, replace or remove an authenticator, and turn its switch on or off — an admin with a
|
|
19567
|
+
* role over held changes (settings-role.ts) on a direct connection (never a link), on a chat fleet and a web-only one alike, and
|
|
19568
|
+
* only THEIR OWN (`who`: their connection and account; a web-only fleet's one admin and a chat fleet's host session are the host
|
|
19569
|
+
* operator's). Another admin's is never reachable from here: a stolen session can lock out at most the admin it belongs to, and
|
|
19570
|
+
* every such change posts a Notice to the fleet. On the AgEnD computer's own browser no code is asked. Connections from outside
|
|
19571
|
+
* and their switch are another thing and stay a web-only fleet's, on its own computer (liveOwner).
|
|
19572
|
+
*/
|
|
19573
|
+
authenticatorOwner(req) {
|
|
19574
|
+
if (gatewayRequestContext(req))
|
|
19575
|
+
return null;
|
|
19576
|
+
const first = this.settingsRole(req);
|
|
19577
|
+
if (!first.role.ok || !first.handle)
|
|
19578
|
+
return null;
|
|
19579
|
+
const handle = first.handle, actor = first.role.actor, who = adminKey(actor.adapter_id, actor.user_id);
|
|
19580
|
+
return { handle, who, actor, onHost: first.role.onHost,
|
|
19581
|
+
current: () => { const now = this.settingsRole(req); return now.role.ok && now.handle === handle && adminKey(now.role.actor.adapter_id, now.role.actor.user_id) === who; } };
|
|
19582
|
+
}
|
|
19583
|
+
/**
|
|
19584
|
+
* Changing an app that exists — replacing it, removing it, turning its switch off — is the OWNER'S, proven by its current code off
|
|
19585
|
+
* the AgEnD computer, whatever the "ask for my code on confirmations" switch says (that switch is about ordinary Settings
|
|
19586
|
+
* confirmations; this is lifecycle ownership). With no app there is no old code to ask: a first set-up asks nothing, and the AgEnD
|
|
19587
|
+
* computer's own browser is never asked — the recovery controls.
|
|
19588
|
+
*/
|
|
19589
|
+
authenticatorCodeAsked(owner, access) {
|
|
19590
|
+
return !owner.onHost && access.isEnrolled(owner.who);
|
|
19591
|
+
}
|
|
19592
|
+
/** What changing the app asks of this session: nothing, or the current code (of its own app). */
|
|
19593
|
+
authenticatorStep(owner, access, code) {
|
|
19594
|
+
if (owner.onHost)
|
|
19595
|
+
return { ok: true, verified: true };
|
|
19596
|
+
if (!this.authenticatorCodeAsked(owner, access))
|
|
19597
|
+
return { ok: true, verified: false };
|
|
19598
|
+
if (typeof code !== "string" || code.trim() === "")
|
|
19599
|
+
return { ok: false, error: "code_required" };
|
|
19600
|
+
const checked = this.checkAuthenticatorCode(access, owner.who, code, "authenticator change");
|
|
19601
|
+
return checked.ok ? { ok: true, verified: true } : checked;
|
|
19602
|
+
}
|
|
19603
|
+
/**
|
|
19604
|
+
* An app being set up, per session handle: whether that start was on this computer or passed the code. A set-up begun while the
|
|
19605
|
+
* code was not asked (the secret lives ten minutes) must not be finished by a session whose switch is on by then, and one begun
|
|
19606
|
+
* on this computer is not finished from another device: it never passed the code, so the finish is refused. A "code" start also
|
|
19607
|
+
* records WHICH app the code proved (`enrollment`, the opaque id of the owner's app at that moment, null when there was none): a
|
|
19608
|
+
* code is a proof about that app and about nothing that replaces it — the finish is refused once the owner's app has been
|
|
19609
|
+
* replaced or removed since (say, a recovery on the computer), so an earlier remote set-up can never overwrite the newer app.
|
|
19610
|
+
*/
|
|
19611
|
+
authenticatorStarts = new Map();
|
|
19612
|
+
/** Set up (or set up again) your own: a new secret, shown once. Null: not you. A code is asked first when your switch needs one. */
|
|
19613
|
+
webOutsideBeginEnrollment(req, code) {
|
|
19614
|
+
const owner = this.authenticatorOwner(req), store = this.webRemoteAccess();
|
|
19189
19615
|
if (!owner || !store)
|
|
19190
19616
|
return null;
|
|
19191
|
-
|
|
19617
|
+
const step = this.authenticatorStep(owner, store, code);
|
|
19618
|
+
if (!step.ok) {
|
|
19619
|
+
if (step.error === "not_here")
|
|
19620
|
+
return null;
|
|
19621
|
+
return { error: step.error, ...(step.retryAfterMs !== undefined ? { retryAfterMs: step.retryAfterMs } : {}) };
|
|
19622
|
+
}
|
|
19623
|
+
if (!owner.current() || !store.hasRoom(owner.who))
|
|
19624
|
+
return null;
|
|
19625
|
+
const begun = store.beginEnrollment(owner.handle, hostname() || "fleet", owner.who);
|
|
19626
|
+
this.authenticatorStarts.set(owner.handle, { kind: owner.onHost ? "host" : step.verified ? "code" : "none", enrollment: store.enrollmentOf(owner.who) });
|
|
19627
|
+
if (this.authenticatorStarts.size > 64)
|
|
19628
|
+
this.authenticatorStarts.delete(this.authenticatorStarts.keys().next().value);
|
|
19629
|
+
return begun;
|
|
19192
19630
|
}
|
|
19193
|
-
/** The new app's first code: on "ok" it replaces the old one,
|
|
19631
|
+
/** The new app's first code: on "ok" it is now yours (the host operator's replaces the old one, ending the sessions from outside). */
|
|
19194
19632
|
webOutsideConfirmEnrollment(req, code) {
|
|
19195
|
-
const owner = this.
|
|
19633
|
+
const owner = this.authenticatorOwner(req), store = this.webRemoteAccess();
|
|
19196
19634
|
if (!owner || !store || !owner.current())
|
|
19197
19635
|
return "not_here";
|
|
19198
|
-
const had = store.
|
|
19199
|
-
|
|
19636
|
+
const had = store.isEnrolled(owner.who);
|
|
19637
|
+
// Asked again here, not only at the start: the switch may have been turned on since (see authenticatorStarts).
|
|
19638
|
+
const start = this.authenticatorStarts.get(owner.handle);
|
|
19639
|
+
// A set-up is finished only by the attempt that was started, and only while what its start proved still holds. No start on
|
|
19640
|
+
// record (never made here, or already refused) and a start whose app is no longer the owner's (replaced or removed since —
|
|
19641
|
+
// a recovery on the computer, say; for a start with no app, one has appeared) VOID the attempt for good: its secret is dropped
|
|
19642
|
+
// from the store too, so repeating the same finish can never revive it. The only way on is a fresh begin.
|
|
19643
|
+
if (!start || (start.kind !== "host" && start.enrollment !== store.enrollmentOf(owner.who))) {
|
|
19644
|
+
this.authenticatorStarts.delete(owner.handle);
|
|
19645
|
+
store.cancelEnrollment(owner.handle);
|
|
19646
|
+
return "not_here";
|
|
19647
|
+
}
|
|
19648
|
+
if (!owner.onHost && this.authenticatorCodeAsked(owner, store) && start.kind !== "code")
|
|
19649
|
+
return "not_here";
|
|
19650
|
+
const r = store.confirmEnrollment(owner.handle, code, { physicalHost: owner.onHost });
|
|
19200
19651
|
if (r === "ok") {
|
|
19201
|
-
this.
|
|
19202
|
-
|
|
19652
|
+
this.authenticatorStarts.delete(owner.handle);
|
|
19653
|
+
this.logger.info({ again: had, here: owner.onHost }, "Authenticator app set up");
|
|
19654
|
+
if (owner.who === HOST_ADMIN_KEY)
|
|
19203
19655
|
this.endOutsideSessions();
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
this.notifyFleetError(t("outside.reenrolled_notice"));
|
|
19207
|
-
}
|
|
19656
|
+
// Every set-up or replacement, from anywhere, is said to the fleet's admins (#3327; AGEND-122): a set-up they did not make is noticed.
|
|
19657
|
+
this.postFleetSecurityNotice(t(had ? "outside.reenrolled_notice_by" : "outside.enrolled_notice_by", this.adminName(owner.actor)));
|
|
19208
19658
|
}
|
|
19209
19659
|
return r;
|
|
19210
19660
|
}
|
|
19211
|
-
/** Forget
|
|
19212
|
-
webOutsideRemove(req) {
|
|
19213
|
-
const owner = this.
|
|
19661
|
+
/** Forget your own app (your switch with it). A code is asked first when your switch needs one. Nothing set up: nothing happens. */
|
|
19662
|
+
webOutsideRemove(req, code) {
|
|
19663
|
+
const owner = this.authenticatorOwner(req), store = this.webRemoteAccess();
|
|
19214
19664
|
if (!owner || !store || !owner.current())
|
|
19215
19665
|
return "not_here";
|
|
19666
|
+
// Nothing of yours to remove: never reaches the store — a set-up another session (the host's recovery) has begun stays as it is.
|
|
19667
|
+
if (!store.isEnrolled(owner.who))
|
|
19668
|
+
return owner.onHost ? "ok" : "not_here";
|
|
19669
|
+
const step = this.authenticatorStep(owner, store, code);
|
|
19670
|
+
if (!step.ok) {
|
|
19671
|
+
if (step.error === "not_here")
|
|
19672
|
+
return "not_here";
|
|
19673
|
+
return { error: step.error, ...(step.retryAfterMs !== undefined ? { retryAfterMs: step.retryAfterMs } : {}) };
|
|
19674
|
+
}
|
|
19675
|
+
if (!owner.current())
|
|
19676
|
+
return "not_here";
|
|
19216
19677
|
// #3008 review (Prism P2 1): shut at once whatever the disk says; say so when it could not be saved (retried).
|
|
19217
|
-
const
|
|
19218
|
-
|
|
19219
|
-
|
|
19220
|
-
|
|
19221
|
-
|
|
19222
|
-
this.logger.info({ saved }, "Authenticator app removed; connections from outside off");
|
|
19678
|
+
const saved = store.remove(owner.who);
|
|
19679
|
+
if (owner.who === HOST_ADMIN_KEY)
|
|
19680
|
+
this.closeOutsideLink("outside removed");
|
|
19681
|
+
this.postFleetSecurityNotice(t("outside.removed_notice_by", this.adminName(owner.actor)));
|
|
19682
|
+
this.logger.info({ saved }, "Authenticator app removed");
|
|
19223
19683
|
return saved ? "ok" : "unsaved";
|
|
19224
19684
|
}
|
|
19685
|
+
/**
|
|
19686
|
+
* Turn your own "ask for my code to confirm from other devices" switch on or off. On needs your app set up and asks nothing (it
|
|
19687
|
+
* only tightens); off asks your current code off the AgEnD computer — so a session it restricts cannot lift the restriction for
|
|
19688
|
+
* you without it. Never anyone else's. Either way a Notice goes to the fleet's admins.
|
|
19689
|
+
*/
|
|
19690
|
+
webOutsideStrict(req, on, code) {
|
|
19691
|
+
const owner = this.authenticatorOwner(req), store = this.webRemoteAccess();
|
|
19692
|
+
if (!owner || !store || !owner.current())
|
|
19693
|
+
return "not_here";
|
|
19694
|
+
if (!store.isEnrolled(owner.who))
|
|
19695
|
+
return "not_enrolled";
|
|
19696
|
+
if (store.strictOf(owner.who) === on)
|
|
19697
|
+
return "ok";
|
|
19698
|
+
if (!on) {
|
|
19699
|
+
const step = this.authenticatorStep(owner, store, code);
|
|
19700
|
+
if (!step.ok) {
|
|
19701
|
+
if (step.error === "not_here")
|
|
19702
|
+
return "not_here";
|
|
19703
|
+
return { error: step.error, ...(step.retryAfterMs !== undefined ? { retryAfterMs: step.retryAfterMs } : {}) };
|
|
19704
|
+
}
|
|
19705
|
+
if (!owner.current())
|
|
19706
|
+
return "not_here";
|
|
19707
|
+
}
|
|
19708
|
+
const r = store.setStrict(owner.who, on);
|
|
19709
|
+
if (r === "not_enrolled")
|
|
19710
|
+
return r;
|
|
19711
|
+
this.postFleetSecurityNotice(t(on ? "outside.strict_on_notice_by" : "outside.strict_off_notice_by", this.adminName(owner.actor)));
|
|
19712
|
+
return r;
|
|
19713
|
+
}
|
|
19225
19714
|
/** The switch. On: needs an app set up; the link opens. Off: it closes and every session from outside ends. */
|
|
19226
19715
|
webOutsideSwitch(req, on) {
|
|
19227
19716
|
const owner = this.liveOwner(req, { hostOnly: true }), store = this.webRemoteAccess();
|
|
@@ -19313,34 +19802,148 @@ export class FleetManager {
|
|
|
19313
19802
|
this.openOutsideLink(OUTSIDE_LINK_RETRY_MS);
|
|
19314
19803
|
}
|
|
19315
19804
|
/**
|
|
19316
|
-
* #
|
|
19317
|
-
*
|
|
19318
|
-
*
|
|
19319
|
-
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
|
|
19324
|
-
|
|
19325
|
-
|
|
19326
|
-
|
|
19327
|
-
|
|
19328
|
-
|
|
19329
|
-
|
|
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.
|
|
19815
|
+
*
|
|
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
|
|
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
|
|
19818
|
+
* only as before (#3008): the one "Allow connections from outside" opened. "Only this computer can authorize" closes all of it.
|
|
19819
|
+
* What it makes: a chat admin's session is that account's own (owner), exactly as a sign-in code from the chat makes it; a web-only
|
|
19820
|
+
* fleet's is that fleet's admin session (and over the outside link the #3008 `remote` one, authorized as before). No authority beyond
|
|
19821
|
+
* that: no "Authorize this browser", nothing an agent would take as a go-ahead. Every success tells every admin (a Notice).
|
|
19822
|
+
*/
|
|
19823
|
+
totpSignIn(input) {
|
|
19824
|
+
const store = this.webRemoteAccess(), webOnly = this.isWebOnlyFleet(), { exposureId, peer } = input;
|
|
19825
|
+
if (!store || !this.webToken || !this.totpSignInOpen(exposureId, peer))
|
|
19330
19826
|
return { kind: "closed" };
|
|
19827
|
+
const webToken = this.webToken, epoch = this.webAuthorityState().epoch, now = Date.now();
|
|
19828
|
+
const named = this.signInNameTyped(input.account);
|
|
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).
|
|
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.
|
|
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
|
+
}
|
|
19331
19852
|
if (v.kind === "unavailable")
|
|
19332
19853
|
return v;
|
|
19333
|
-
if (v.
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
|
|
19338
|
-
|
|
19854
|
+
if (v.kind !== "ok") {
|
|
19855
|
+
// Half-way through a real admin's count, or the whole sign-in's: said once per cycle — nothing of the code or the name typed in it.
|
|
19856
|
+
if (v.began.halfFleet || v.began.halfAdmin)
|
|
19857
|
+
this.postFleetSecurityNotice(t("signin.totp_notice_attempts"));
|
|
19858
|
+
// A shared wait that starts is said to the admins when it is the whole sign-in's or a real admin's — never for a name that is nobody's (a flood of those must not be a flood of Notices).
|
|
19859
|
+
if (v.began.fleet || v.began.admin) {
|
|
19860
|
+
this.logger.warn({ fleet: v.began.fleet }, "Sign-in with authenticator codes paused after wrong codes");
|
|
19861
|
+
this.postFleetSecurityNotice(t("signin.totp_notice_paused", outsideDuration(v.began.waitMs)));
|
|
19862
|
+
}
|
|
19863
|
+
if (v.kind === "paused")
|
|
19864
|
+
return { kind: "paused", retryAfterMs: v.retryAfterMs };
|
|
19865
|
+
if (v.skewSteps !== undefined)
|
|
19866
|
+
this.logger.warn({ offsetSeconds: v.skewSteps * TOTP_STEP_SECONDS }, "A wrong authenticator code matched a nearby time step: this computer's clock may be off");
|
|
19867
|
+
this.logger.debug("Sign-in with an authenticator code refused");
|
|
19868
|
+
return { kind: "wrong" };
|
|
19869
|
+
}
|
|
19870
|
+
const who = v.who, enrollment = store.enrollmentOf(who);
|
|
19871
|
+
if (!enrollment)
|
|
19872
|
+
return { kind: "wrong" };
|
|
19873
|
+
const actor = who === HOST_ADMIN_KEY ? null : (() => { const [adapterId, userId] = who.split("\u0000"); return adapterId && userId ? { adapterId, userId } : null; })();
|
|
19874
|
+
if (!actor && who !== HOST_ADMIN_KEY)
|
|
19875
|
+
return { kind: "wrong" };
|
|
19876
|
+
const outside = webOnly && exposureId !== undefined;
|
|
19877
|
+
return {
|
|
19878
|
+
kind: "ok",
|
|
19879
|
+
knownCookie: addSigninKnownDevice(webToken, input.knownCookie, who, enrollment, epoch, now),
|
|
19880
|
+
session: outside ? { remote: "totp" } : actor ? { owner: actor } : {},
|
|
19881
|
+
// Asked again as the session is made: the same app, still an admin, still allowed here.
|
|
19882
|
+
commit: (record, label) => {
|
|
19883
|
+
if (!this.totpSignInOpen(exposureId, peer) || store.enrollmentOf(who) !== enrollment)
|
|
19884
|
+
return false;
|
|
19885
|
+
if (actor ? this.adminGate(actor.userId, actor.adapterId) !== "ok" : !webOnly)
|
|
19886
|
+
return false;
|
|
19887
|
+
if (outside)
|
|
19888
|
+
return this.authorizeOutsideSession(record, peer, label);
|
|
19889
|
+
const name = actor ? this.webPerson({ adapterId: actor.adapterId, userId: actor.userId }).name : t("settings_confirm.host_operator_label");
|
|
19890
|
+
this.logger.info({ handle: record.handle, surface: record.surface }, "Web sign-in with an admin's authenticator code");
|
|
19891
|
+
this.postFleetSecurityNotice(t("signin.totp_notice_signed_in", name, label, t(exposureId === undefined ? "signin.totp_where_direct" : "signin.totp_where_link")));
|
|
19892
|
+
return true;
|
|
19893
|
+
},
|
|
19894
|
+
};
|
|
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
|
+
}
|
|
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. */
|
|
19901
|
+
signinHandleOf(owner) {
|
|
19902
|
+
const handle = this.webPrefs.profile(webPersonKey(owner))?.platformName;
|
|
19903
|
+
return typeof handle === "string" && handle ? handle : undefined;
|
|
19904
|
+
}
|
|
19905
|
+
/** Where the new-device authenticator sign-in is open: the owner's knobs and the link rules in one place (asked again as the session is made). */
|
|
19906
|
+
totpSignInOpen(exposureId, peer) {
|
|
19907
|
+
// "Only this computer can authorize" closes this too: only this computer's own browser, never a link.
|
|
19908
|
+
if (this.webAuthorityState().loopbackOnly && (exposureId !== undefined || peer !== "loopback"))
|
|
19909
|
+
return false;
|
|
19910
|
+
if (exposureId === undefined)
|
|
19911
|
+
return true;
|
|
19912
|
+
if (this.isWebOnlyFleet())
|
|
19913
|
+
return this.outsideLink()?.exposureId === exposureId;
|
|
19914
|
+
return TOTP_SIGNIN_OVER_PUBLIC_LINK && this.publicWebLink?.openSignin()?.exposureId === exposureId;
|
|
19915
|
+
}
|
|
19916
|
+
/**
|
|
19917
|
+
* The admin a typed name stands for, among the chat admins that have an authenticator AND are still admins of their connection: by
|
|
19918
|
+
* the platform user name they sign in with (Discord / Telegram handle, no "@", any case), their user id, or `connection:id`. Exactly
|
|
19919
|
+
* one: a name two of them answer to is nobody's here (they use `connection:id`). The loop never stops early, so it takes as long
|
|
19920
|
+
* for a name that is nobody's. `ident` is the normalized text, for the limiter.
|
|
19921
|
+
*/
|
|
19922
|
+
resolveSignInAdmin(store, webOnly, account) {
|
|
19923
|
+
// A web-only fleet has one admin and one app: no name to give, nothing to tell apart.
|
|
19924
|
+
if (webOnly)
|
|
19925
|
+
return { who: store.isEnrolled(HOST_ADMIN_KEY) ? HOST_ADMIN_KEY : null, ident: "host" };
|
|
19926
|
+
const norm = (v) => (typeof v === "string" ? v.normalize("NFKC").trim().replace(/^@+/, "").toLowerCase().slice(0, 128) : "");
|
|
19927
|
+
const ident = norm(account), found = [];
|
|
19928
|
+
for (const key of store.adminKeys) {
|
|
19929
|
+
const [adapterId, userId] = key.split("\u0000");
|
|
19930
|
+
if (!adapterId || !userId)
|
|
19931
|
+
continue;
|
|
19932
|
+
let platformName = "";
|
|
19933
|
+
try {
|
|
19934
|
+
platformName = norm(this.signinHandleOf({ adapterId, userId }));
|
|
19935
|
+
}
|
|
19936
|
+
catch { /* no handle known: the id still works */ }
|
|
19937
|
+
const answers = [norm(userId), norm(`${adapterId}:${userId}`), platformName].includes(ident) && ident !== "";
|
|
19938
|
+
// Asked of every key, whether or not the name matches it: a name that belongs to a record does no more work than one that belongs to nobody.
|
|
19939
|
+
const admin = this.adminGate(userId, adapterId) === "ok";
|
|
19940
|
+
if (answers && admin)
|
|
19941
|
+
found.push(key);
|
|
19339
19942
|
}
|
|
19340
|
-
return {
|
|
19943
|
+
return { who: found.length === 1 ? found[0] : null, ident };
|
|
19341
19944
|
}
|
|
19342
19945
|
/**
|
|
19343
|
-
* #3008: a session just made by
|
|
19946
|
+
* #3008: a session just made by totpSignIn's "ok" over the outside link is this computer's admin for its authorization's life. False: it
|
|
19344
19947
|
* could not be admitted (its handle not saved, #3015 review r3) — the caller ends it.
|
|
19345
19948
|
*/
|
|
19346
19949
|
authorizeOutsideSession(session, peer, label) {
|
|
@@ -19424,7 +20027,7 @@ export class FleetManager {
|
|
|
19424
20027
|
* written), what fleet.yaml says, the hosts that make the dashboard reachable from elsewhere (the warning while
|
|
19425
20028
|
* loopback_only is off), and the sessions authorized now (§0): each one's device, account, and when it runs out.
|
|
19426
20029
|
*/
|
|
19427
|
-
webAuthorityOverview() {
|
|
20030
|
+
webAuthorityOverview(req) {
|
|
19428
20031
|
const configured = this.fleetConfig?.web?.verified_authority ?? {};
|
|
19429
20032
|
const lanHosts = (this.fleetConfig?.web?.allowed_hosts ?? []).filter(h => { const name = hostnameOf(String(h)); return name !== null && !LOOPBACK_HOST_NAMES.includes(name); });
|
|
19430
20033
|
const state = this.webAuthorityState(), maxMs = webAuthorityPolicy(this.fleetConfig?.web).maxSessionMs, now = Date.now();
|
|
@@ -19439,7 +20042,9 @@ export class FleetManager {
|
|
|
19439
20042
|
// Over a link: the temporary one (§0.3), else the named one (a record from before §0.3 has no peer).
|
|
19440
20043
|
...(sessions.get(a.handle).surface === "gateway" ? (a.peer === "quick_link" ? { quick: true } : { named: true }) : {}) })) : [];
|
|
19441
20044
|
const host = this.fleetConfig?.web?.public_link?.hostname;
|
|
19442
|
-
|
|
20045
|
+
const own = req ? authorizeSession(req, this.webToken, this.webSessions, { touch: false }) : null;
|
|
20046
|
+
return { you: { handle: own && own.kind === "ok" ? own.session.handle : null, canRevoke: !!req && !!this.webAuthorityRevoker(req) },
|
|
20047
|
+
state, configured, hours: VERIFIED_SESSION_HOURS, lanHosts, authorized, namedHost: typeof host === "string" && host ? host : null, webOnly: this.isWebOnlyFleet() };
|
|
19443
20048
|
}
|
|
19444
20049
|
authorizationRequests = null;
|
|
19445
20050
|
/**
|
|
@@ -19566,15 +20171,66 @@ export class FleetManager {
|
|
|
19566
20171
|
return { state: "pending", expiresInMs: pending.expiresInMs };
|
|
19567
20172
|
return { state: "none", reason: this.webAuthorityQualifies(input) ?? (verdict.refusal ?? "not_authorized") };
|
|
19568
20173
|
}
|
|
19569
|
-
/**
|
|
19570
|
-
|
|
20174
|
+
/**
|
|
20175
|
+
* #1939 §10: revoke every web authority given so far (receipts read as none), without signing anyone out.
|
|
20176
|
+
* AGEND-138: `keep` — the session that asked (the verified owner's own): the epoch still moves, so every other session
|
|
20177
|
+
* and every stored receipt is ended, but this one is authorized again under the new epoch at once (§3 asked afresh,
|
|
20178
|
+
* with the end it already had: a revocation never stretches an authorization). A host session only where it is
|
|
20179
|
+
* allowed to be one — on this computer — as at sign-in.
|
|
20180
|
+
*/
|
|
20181
|
+
revokeWebAuthority(keep) {
|
|
19571
20182
|
this.webAuthorityState(); // any switch change first, then this revocation
|
|
20183
|
+
const store = this.sessionAuthorizationStore();
|
|
20184
|
+
const prev = keep ? store?.get(keep.session.handle) ?? null : null;
|
|
19572
20185
|
const result = this.authorityStateStore?.revoke() ?? { epoch: 0, durable: false };
|
|
19573
20186
|
if (result.durable)
|
|
19574
20187
|
this.logger.info({ epoch: result.epoch }, "Web authority revoked");
|
|
19575
20188
|
else
|
|
19576
20189
|
this.logger.warn({ epoch: result.epoch }, "Web authority revoked in memory only — web authority stays off until its state can be written; a restart before then undoes this revocation");
|
|
19577
|
-
|
|
20190
|
+
let kept = false;
|
|
20191
|
+
if (keep && prev && store) {
|
|
20192
|
+
const now = Date.now(), epoch = this.webAuthorityState().epoch;
|
|
20193
|
+
const again = { ...prev, epoch };
|
|
20194
|
+
if (!this.webAuthority({ session: keep.session, gateway: keep.gateway, peer: keep.peer, authorization: again }).refusal) {
|
|
20195
|
+
const live = new Set(this.webSessions?.list(undefined, () => true).map(r => r.handle) ?? []);
|
|
20196
|
+
store.prune(a => a.handle === prev.handle && live.has(a.handle)); // every other authorization ends with the old epoch
|
|
20197
|
+
store.authorize(prev.handle, prev.owner, prev.authorizedAt, epoch, prev.until, prev.peer);
|
|
20198
|
+
kept = true;
|
|
20199
|
+
this.logger.info({ handle: prev.handle, at: now }, "Web authority revoked: the owner's own session kept");
|
|
20200
|
+
}
|
|
20201
|
+
}
|
|
20202
|
+
return { ...result, kept };
|
|
20203
|
+
}
|
|
20204
|
+
/**
|
|
20205
|
+
* AGEND-138: who may "Revoke authorization of other devices" — the verified owner only, asked of the LIVE session each
|
|
20206
|
+
* time. A web-only fleet: its owner (this computer's admin here, or signed in from outside). A fleet with a chat
|
|
20207
|
+
* connection: an admin session that is web-verified now (its account confirmed in Discord / Telegram) — the same §3
|
|
20208
|
+
* verdict the rest of web authority uses. A guest, a read-only session, an admin not verified (a device-code or one-time-code
|
|
20209
|
+
* sign-in), the header token: null. `revoke()` ends everyone else's and keeps this session verified.
|
|
20210
|
+
*/
|
|
20211
|
+
webAuthorityRevoker(req) {
|
|
20212
|
+
if (gatewayRequestContext(req))
|
|
20213
|
+
return null;
|
|
20214
|
+
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
20215
|
+
if (auth.kind !== "ok" || auth.session.tier !== "admin")
|
|
20216
|
+
return null;
|
|
20217
|
+
const handle = auth.session.handle, peer = webPeerOf(req);
|
|
20218
|
+
const live = () => {
|
|
20219
|
+
const now = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
20220
|
+
return now.kind === "ok" && now.session.handle === handle && now.session.tier === "admin" ? now.session : null;
|
|
20221
|
+
};
|
|
20222
|
+
const verified = () => {
|
|
20223
|
+
const session = live();
|
|
20224
|
+
if (!session)
|
|
20225
|
+
return false;
|
|
20226
|
+
if (this.isWebOnlyFleet())
|
|
20227
|
+
return !!this.liveOwner(req, { hostOnly: false })?.current();
|
|
20228
|
+
const v = this.webAuthority({ session, gateway: false, peer });
|
|
20229
|
+
return !v.refusal && v.authority.kind === "web-verified" && v.authority.session?.handle === handle;
|
|
20230
|
+
};
|
|
20231
|
+
if (!verified())
|
|
20232
|
+
return null;
|
|
20233
|
+
return { handle, current: verified, revoke: () => { const session = live(); return this.revokeWebAuthority(session ? { session, peer, gateway: false } : undefined); } };
|
|
19578
20234
|
}
|
|
19579
20235
|
/** #1269: an instance's chat command from the web chat (web-commands.ts); `publicLink`: a gateway request. */
|
|
19580
20236
|
/** #2855: the table scope of an instance the web chat may command (a fleet instance or a ClassicBot room), else null. */
|
|
@@ -19598,13 +20254,17 @@ export class FleetManager {
|
|
|
19598
20254
|
...(opts.guest ? { webGuest: true } : {}), // #2855: a guest's /steer or /btw reaches the agent as a guest's
|
|
19599
20255
|
};
|
|
19600
20256
|
};
|
|
19601
|
-
const choicesFromCache = (instance) => {
|
|
20257
|
+
const choicesFromCache = async (instance, more = false) => {
|
|
20258
|
+
if (isWindowsInstance(this.fleetConfig?.instances[instance])) {
|
|
20259
|
+
const catalog = await this.listModelCatalog({ instanceName: instance });
|
|
20260
|
+
return { current: catalog.current_model, options: catalog.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] };
|
|
20261
|
+
}
|
|
19602
20262
|
const backend = this.backendNameForInstance(instance);
|
|
19603
|
-
const
|
|
19604
|
-
if (!cached?.models.length)
|
|
19605
|
-
return null;
|
|
20263
|
+
const env = this.webModelEnv(backend, instance);
|
|
19606
20264
|
const current = this.resolveInstanceModel(instance).model;
|
|
19607
|
-
|
|
20265
|
+
const models = more ? this.modelCatalogFor(backend, instance) : env?.models ?? [];
|
|
20266
|
+
return { current, options: this.withCurrentModel(models, current).map(o => ({ id: o.id, label: this.modelChoiceLabel(o, current) })),
|
|
20267
|
+
actions: more ? ["refreshAll"] : backend === "claude-code" ? ["refresh", "more"] : ["refresh"] };
|
|
19608
20268
|
};
|
|
19609
20269
|
return runWebCommand({
|
|
19610
20270
|
scope: (instance) => this.webCommandScope(instance),
|
|
@@ -19628,6 +20288,31 @@ export class FleetManager {
|
|
|
19628
20288
|
},
|
|
19629
20289
|
applyModel: (instance, name) => this.applyModel(instance, name),
|
|
19630
20290
|
modelChoices: choicesFromCache,
|
|
20291
|
+
modelAction: async (instance, command, args, action, actionOpts) => {
|
|
20292
|
+
const tokens = backendArgs(args);
|
|
20293
|
+
if ((command === "model" && args) || (command === "backend" && (tokens.length !== 1 || action !== "refresh")))
|
|
20294
|
+
return { error: t("menu.click_stale") };
|
|
20295
|
+
const backend = command === "model" ? this.backendNameForInstance(instance) : tokens[0];
|
|
20296
|
+
if (command === "backend") {
|
|
20297
|
+
const refusal = this.backendCommandRefusal(instance);
|
|
20298
|
+
if (refusal)
|
|
20299
|
+
return { error: refusal };
|
|
20300
|
+
const step = await backendStep(this.backendCommandDeps(instance, { live: false }), instance, tokens);
|
|
20301
|
+
if (step.kind !== "choose" || step.step !== "model")
|
|
20302
|
+
return { error: step.kind === "refuse" ? step.text : t("menu.click_stale") };
|
|
20303
|
+
}
|
|
20304
|
+
if (action === "more" && backend !== "claude-code")
|
|
20305
|
+
return { error: t("menu.click_stale") };
|
|
20306
|
+
if (action !== "more" || !this.webModelEnv(backend, instance)?.apiModels?.length) {
|
|
20307
|
+
const result = await this.refreshModelCatalogFor(backend, instance);
|
|
20308
|
+
if (!result.refreshed)
|
|
20309
|
+
return { error: t("model.refresh_failed") };
|
|
20310
|
+
}
|
|
20311
|
+
if (command === "model")
|
|
20312
|
+
return { choices: await choicesFromCache(instance, action !== "refresh") };
|
|
20313
|
+
// Re-enter the shared backend→model→effort→confirm flow; no configuration write during refresh.
|
|
20314
|
+
return this.webCommand({ instance, command: "backend", args }, { ...opts, publicLink: actionOpts.publicLink }).then(r => r.body);
|
|
20315
|
+
},
|
|
19631
20316
|
applyEffort: (instance, level) => this.applyEffort(instance, level),
|
|
19632
20317
|
effortChoices: (instance) => {
|
|
19633
20318
|
const levels = this.effortLevelsFor(instance);
|
|
@@ -19641,12 +20326,12 @@ export class FleetManager {
|
|
|
19641
20326
|
if (refusal)
|
|
19642
20327
|
return { error: refusal };
|
|
19643
20328
|
// The cached model lists only, as the web's /model: never a live probe on this path.
|
|
19644
|
-
const step = await backendStep(this.backendCommandDeps(instance, { live: false }), instance, backendArgs(args));
|
|
20329
|
+
const step = await backendStep({ ...this.backendCommandDeps(instance, { live: false }), models: async (backend) => this.modelCatalogFor(backend, instance) }, instance, backendArgs(args));
|
|
19645
20330
|
if (step.kind === "refuse")
|
|
19646
20331
|
return step.noop ? { text: step.text } : { error: step.text };
|
|
19647
20332
|
if (step.kind === "choose") {
|
|
19648
20333
|
const id = (token) => joinBackendArgs([...step.args, token]);
|
|
19649
|
-
return { choices: { prompt: step.text, current: step.current === null ? null : id(step.current), options: step.choices.map(c => {
|
|
20334
|
+
return { choices: { step: step.step, args: joinBackendArgs(step.args), ...(step.step === "model" ? { actions: ["refresh"] } : {}), prompt: step.text, current: step.current === null ? null : id(step.current), options: step.choices.map(c => {
|
|
19650
20335
|
// #2233: the web offers Sign in beside it, so its reason is no longer "use /login".
|
|
19651
20336
|
// Not over the public link: Sign in is refused there, so the choice keeps its "(use /login)" (#2262 review).
|
|
19652
20337
|
const signIn = c.signIn && !stepOpts?.publicLink && dashboardSignInSupported(c.signIn) ? c.signIn : null;
|
|
@@ -21305,7 +21990,7 @@ export class FleetManager {
|
|
|
21305
21990
|
const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
|
|
21306
21991
|
const identity = this.signInIdentity(backend, profile);
|
|
21307
21992
|
rows.push({ profile, state: (login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown"), signIn,
|
|
21308
|
-
...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}) });
|
|
21993
|
+
...(hostCommand ? { hostCommand } : {}), ...(identity ? { identity } : {}), ...(this.claudeSignInEnded(backend, profile) ? { reconnect: true } : {}) });
|
|
21309
21994
|
}
|
|
21310
21995
|
diskProfiles.set(backend, rows);
|
|
21311
21996
|
}
|
|
@@ -21360,7 +22045,8 @@ export class FleetManager {
|
|
|
21360
22045
|
this.logger.debug({ err: err.message }, "Computer accounts not read");
|
|
21361
22046
|
}
|
|
21362
22047
|
}
|
|
21363
|
-
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, shortUsage: shortWindow, keepAlive, machines
|
|
22048
|
+
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, shortUsage: shortWindow, keepAlive, machines, installShown: this.webHostInstalls.view()?.backend ?? null,
|
|
22049
|
+
versions: new Map(this.backendAvailabilityRows().map(row => [row.backend, row.version ?? null])) });
|
|
21364
22050
|
}
|
|
21365
22051
|
/**
|
|
21366
22052
|
* A sign-in just finished for this account: look at its Keep sign-in alive setting once now (when it is on), so what the Accounts row says about
|
|
@@ -21403,6 +22089,7 @@ export class FleetManager {
|
|
|
21403
22089
|
* admitCredentialUse) from the configuration it launched with — never re-resolved against today's defaults. An entry
|
|
21404
22090
|
* whose start ended without a daemon, or whose daemon is gone, is dropped when next read.
|
|
21405
22091
|
*/
|
|
22092
|
+
// M-2825 review: with the sign-in as launched (backend, profile as written) — what is in use until the agent restarts.
|
|
21406
22093
|
credentialLeases = new Map();
|
|
21407
22094
|
/** #3292 review: Keep sign-in alive runs in flight, by sign-in: a start on that sign-in waits for its end. */
|
|
21408
22095
|
keepAliveRenewing = new Map();
|
|
@@ -21412,14 +22099,15 @@ export class FleetManager {
|
|
|
21412
22099
|
* Daemon's clone of that config hands its CLI. Never today's defaults: an older config object keeps its own.
|
|
21413
22100
|
*/
|
|
21414
22101
|
launchCredentialKey(config, backend) {
|
|
21415
|
-
|
|
22102
|
+
return this.credentialKey(backend, this.launchCredentialProfile(config, backend));
|
|
22103
|
+
}
|
|
22104
|
+
launchCredentialProfile(config, backend) {
|
|
21416
22105
|
try {
|
|
21417
|
-
|
|
22106
|
+
return resolveCredentialProfile(config.backend_options?.[backend]);
|
|
21418
22107
|
}
|
|
21419
22108
|
catch {
|
|
21420
|
-
|
|
22109
|
+
return null;
|
|
21421
22110
|
}
|
|
21422
|
-
return this.credentialKey(backend, profile);
|
|
21423
22111
|
}
|
|
21424
22112
|
/**
|
|
21425
22113
|
* #3313 review r2: failed starts whose CLI was not proven gone keep holding their sign-in (across a retry of the same
|
|
@@ -21458,7 +22146,7 @@ export class FleetManager {
|
|
|
21458
22146
|
assertCurrent();
|
|
21459
22147
|
key = this.launchCredentialKey(config, backend);
|
|
21460
22148
|
}
|
|
21461
|
-
const lease = { key, starting: true };
|
|
22149
|
+
const lease = { key, starting: true, backend, profile: this.launchCredentialProfile(config, backend) };
|
|
21462
22150
|
this.credentialLeases.set(name, lease);
|
|
21463
22151
|
const drop = () => { if (this.credentialLeases.get(name) === lease)
|
|
21464
22152
|
this.credentialLeases.delete(name); };
|
|
@@ -21467,7 +22155,7 @@ export class FleetManager {
|
|
|
21467
22155
|
release: drop,
|
|
21468
22156
|
current: c => this.launchCredentialKey(c, backend) === key,
|
|
21469
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.
|
|
21470
|
-
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(); },
|
|
21471
22159
|
};
|
|
21472
22160
|
}
|
|
21473
22161
|
/**
|
|
@@ -21564,14 +22252,69 @@ export class FleetManager {
|
|
|
21564
22252
|
const ka = this.signInKeepAlive;
|
|
21565
22253
|
if (!ka)
|
|
21566
22254
|
return [];
|
|
21567
|
-
|
|
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
|
+
};
|
|
21568
22264
|
const owner = this.worlds.keys().next().value;
|
|
21569
|
-
return ka.attention().map(a => ({
|
|
22265
|
+
return ka.attention(this.signInsInUse()).map(a => ({
|
|
21570
22266
|
backend: a.backend, profile: a.profile, kind: a.kind, since: a.since, signIn: dashboardSignInSupported(a.backend, a.profile),
|
|
21571
22267
|
...(owner ? { owner } : {}),
|
|
21572
|
-
detail: t(`keepalive.${a.kind}`, BACKEND_LABELS[a.backend] ?? a.backend, a.profile ?? t("keepalive.default_name"),
|
|
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")),
|
|
21573
22269
|
}));
|
|
21574
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
|
+
}
|
|
21575
22318
|
/** #3292: Settings → Accounts → Keep sign-in alive (POST /ui/accounts/keep-alive). `by`: the session's label, for the fleet log. */
|
|
21576
22319
|
setAccountKeepAlive(backend, profile, enabled, fallback, by) {
|
|
21577
22320
|
const r = this.keepAliveService().set(backend, profile, enabled, fallback);
|
|
@@ -21801,14 +22544,30 @@ export class FleetManager {
|
|
|
21801
22544
|
this.logger.info({ backend, profile: shown, by, refused: result.error }, "Account sign-out refused");
|
|
21802
22545
|
return result;
|
|
21803
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
|
+
}
|
|
21804
22559
|
backendSignInTargets() {
|
|
21805
22560
|
const out = [];
|
|
21806
22561
|
for (const row of this.backendAvailabilityRows()) {
|
|
21807
22562
|
const flow = LOGIN_FLOWS[row.backend];
|
|
21808
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);
|
|
21809
22567
|
out.push({
|
|
21810
22568
|
// Not installed or too old: signing in would not help — the row says how to install (or update) it instead.
|
|
21811
|
-
backend: row.backend, state:
|
|
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),
|
|
21812
22571
|
...(flow?.remoteLogin === "unsupported" ? { hostCommand: flow.command } : {}),
|
|
21813
22572
|
...(row.state === "not_installed" && install ? { install } : {}),
|
|
21814
22573
|
...(row.state === "too_old" && install ? { update: install } : {}),
|
|
@@ -21830,7 +22589,8 @@ export class FleetManager {
|
|
|
21830
22589
|
const signIn = dashboardSignInSupported(backend, profile);
|
|
21831
22590
|
const hostCommand = signIn ? null : credentialProfileLoginCommand(this.dataDir, backend, profile);
|
|
21832
22591
|
out.push({ backend, profile, state: login === "logged-in" ? "usable" : login === "signed-out" ? "not_signed_in" : "unknown", signIn,
|
|
21833
|
-
...(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 } : {}) });
|
|
21834
22594
|
}
|
|
21835
22595
|
return out;
|
|
21836
22596
|
}
|
|
@@ -22369,39 +23129,6 @@ export class FleetManager {
|
|
|
22369
23129
|
}
|
|
22370
23130
|
if (!claim)
|
|
22371
23131
|
return this.loginWindow.busyMessage();
|
|
22372
|
-
let tmux;
|
|
22373
|
-
try {
|
|
22374
|
-
const sessionName = getTmuxSession();
|
|
22375
|
-
await TmuxManager.ensureSession(sessionName);
|
|
22376
|
-
if (!this.loginWindow.isCurrent(claim)) {
|
|
22377
|
-
this.loginWindow.release(claim);
|
|
22378
|
-
return t("login.web_shutting_down");
|
|
22379
|
-
}
|
|
22380
|
-
tmux = new TmuxManager(sessionName, "");
|
|
22381
|
-
}
|
|
22382
|
-
catch (err) {
|
|
22383
|
-
this.loginWindow.release(claim);
|
|
22384
|
-
return t("install.failed", backend, err.message);
|
|
22385
|
-
}
|
|
22386
|
-
// A synthetic flow: success is decided by the installer's exit code
|
|
22387
|
-
// (LoginSession treats a clean exit as success), never by pane text. The
|
|
22388
|
-
// session only judges that verdict; it does not read the output for URLs or prompts.
|
|
22389
|
-
// M-2281 (#2980): no terminal to ask on, low priority, stoppable as a whole, the user's own $SHELL — see
|
|
22390
|
-
// unattended-install.ts. A prompt nobody can answer fails at once instead of waiting out the timeout.
|
|
22391
|
-
const shell = (await loginShell()) ?? null;
|
|
22392
|
-
if (!this.loginWindow.isCurrent(claim)) {
|
|
22393
|
-
this.loginWindow.release(claim);
|
|
22394
|
-
return t("login.web_shutting_down");
|
|
22395
|
-
}
|
|
22396
|
-
// The wrapper says its own exit code after this marker: tmux may never record it (unattended-install.ts).
|
|
22397
|
-
const exitMarker = installExitMarker();
|
|
22398
|
-
const flow = {
|
|
22399
|
-
backend,
|
|
22400
|
-
command: unattendedInstallCommand(info.unattended ?? info.install, shell, exitMarker),
|
|
22401
|
-
exitMarker,
|
|
22402
|
-
successPattern: /$^/,
|
|
22403
|
-
timeoutMs: this.installTimeoutMs,
|
|
22404
|
-
};
|
|
22405
23132
|
// M-2281: the installer's output, live, in the chat that asked — no page shows this window.
|
|
22406
23133
|
// Telegram gets its own <pre> (its markdown conversion keeps a fence as literal backticks); others a fenced block.
|
|
22407
23134
|
const frameStyle = chat.adapter.type === "telegram" ? "html" : "markdown";
|
|
@@ -22411,7 +23138,7 @@ export class FleetManager {
|
|
|
22411
23138
|
warn: (message, err) => this.logger.debug({ backend, err: err?.message ?? String(err) }, message),
|
|
22412
23139
|
}, t("install.stream_running", backend), undefined, undefined, frameStyle);
|
|
22413
23140
|
const minutes = String(Math.max(1, Math.round(this.installTimeoutMs / 60_000)));
|
|
22414
|
-
const
|
|
23141
|
+
const opened = await this.openInstallWindow(backend, info, claim, {
|
|
22415
23142
|
onProgress: pane => stream.update(pane),
|
|
22416
23143
|
onDone: async ({ ok, detail, cleanupFailed }) => {
|
|
22417
23144
|
this.activeInstall = null;
|
|
@@ -22444,7 +23171,7 @@ export class FleetManager {
|
|
|
22444
23171
|
// fresh login shell sees that, the fleet process's PATH may not.
|
|
22445
23172
|
// #3009 (leader, cid-3017-3029-overlap): both lookups off the fleet's main thread — the login shell's own check,
|
|
22446
23173
|
// then the installer's own directories through backend-availability's check (a killable child tests each one).
|
|
22447
|
-
const installedAt =
|
|
23174
|
+
const installedAt = await this.locateInstalledCli(backend, info.binary);
|
|
22448
23175
|
if (handoff.cancelled || this.installHandoff !== handoff)
|
|
22449
23176
|
return;
|
|
22450
23177
|
if (!installedAt) {
|
|
@@ -22485,29 +23212,217 @@ export class FleetManager {
|
|
|
22485
23212
|
.catch(err => this.logger.warn({ err, backend }, "Could not post the sign-in step after an install"));
|
|
22486
23213
|
}
|
|
22487
23214
|
},
|
|
22488
|
-
}
|
|
22489
|
-
|
|
23215
|
+
});
|
|
23216
|
+
if ("failure" in opened) {
|
|
23217
|
+
if (opened.failure === "shutting_down")
|
|
23218
|
+
return t("login.web_shutting_down");
|
|
23219
|
+
if (opened.failure === "cancelled")
|
|
23220
|
+
return this.loginWindow.isClosed ? t("login.web_shutting_down") : t("install.cancelled", backend);
|
|
23221
|
+
const text = t("install.failed", backend, opened.message);
|
|
23222
|
+
return opened.cleanupFailed ? `${text}\n${t("login.web_cleanup_failed", backend)}` : text;
|
|
23223
|
+
}
|
|
23224
|
+
return t("install.started", backend);
|
|
23225
|
+
}
|
|
23226
|
+
/**
|
|
23227
|
+
* The install window itself, for `/login`'s chat install and the dashboard's Install button alike (AGEND-133): a tmux window running the registry's
|
|
23228
|
+
* command through `unattendedInstallCommand` (no terminal to ask on, low priority, stoppable as a whole, the user's own $SHELL), judged by the installer's
|
|
23229
|
+
* own exit code. The caller holds `claim` (taken before its first await) and gets it released here on every failure; once the session is running,
|
|
23230
|
+
* `events.onDone` owns the release. `activeInstall` is set while it runs, so `/login cancel`, the dashboard's Cancel and a fleet stop all reach it.
|
|
23231
|
+
*/
|
|
23232
|
+
async openInstallWindow(backend, info, claim, events, execution) {
|
|
23233
|
+
let tmux;
|
|
22490
23234
|
try {
|
|
22491
|
-
|
|
23235
|
+
const sessionName = getTmuxSession();
|
|
23236
|
+
await TmuxManager.ensureSession(sessionName);
|
|
23237
|
+
execution?.assert();
|
|
23238
|
+
if (!this.loginWindow.isCurrent(claim)) {
|
|
23239
|
+
this.loginWindow.release(claim);
|
|
23240
|
+
return { failure: "shutting_down" };
|
|
23241
|
+
}
|
|
23242
|
+
tmux = new TmuxManager(sessionName, "");
|
|
23243
|
+
}
|
|
23244
|
+
catch (err) {
|
|
23245
|
+
this.loginWindow.release(claim);
|
|
23246
|
+
return { failure: "start", message: err.message, cleanupFailed: false };
|
|
23247
|
+
}
|
|
23248
|
+
// A synthetic flow: success is decided by the installer's exit code
|
|
23249
|
+
// (LoginSession treats a clean exit as success), never by pane text. The
|
|
23250
|
+
// session only judges that verdict; it does not read the output for URLs or prompts.
|
|
23251
|
+
// M-2281 (#2980): no terminal to ask on, low priority, stoppable as a whole, the user's own $SHELL — see
|
|
23252
|
+
// unattended-install.ts. A prompt nobody can answer fails at once instead of waiting out the timeout.
|
|
23253
|
+
const shell = (await loginShell()) ?? null;
|
|
23254
|
+
if (!this.loginWindow.isCurrent(claim) || (execution && !execution.current())) {
|
|
23255
|
+
this.loginWindow.release(claim);
|
|
23256
|
+
return { failure: "shutting_down" };
|
|
23257
|
+
}
|
|
23258
|
+
// The wrapper says its own exit code after this marker: tmux may never record it (unattended-install.ts).
|
|
23259
|
+
const exitMarker = installExitMarker();
|
|
23260
|
+
const flow = {
|
|
23261
|
+
backend,
|
|
23262
|
+
command: unattendedInstallCommand(info.unattended ?? info.install, shell, exitMarker),
|
|
23263
|
+
exitMarker,
|
|
23264
|
+
successPattern: /$^/,
|
|
23265
|
+
timeoutMs: this.installTimeoutMs,
|
|
23266
|
+
};
|
|
23267
|
+
const session = new LoginSession(flow, tmux, events, this.logger);
|
|
23268
|
+
this.activeInstall = { session, backend };
|
|
23269
|
+
try {
|
|
23270
|
+
// Admission ends at the actual tmux command dispatch, after its own asynchronous preparation.
|
|
23271
|
+
if (execution)
|
|
23272
|
+
await session.start(() => execution.complete());
|
|
23273
|
+
else
|
|
23274
|
+
await session.start();
|
|
22492
23275
|
}
|
|
22493
23276
|
catch (err) {
|
|
22494
23277
|
this.activeInstall = null;
|
|
22495
23278
|
this.loginWindow.release(claim);
|
|
22496
|
-
|
|
22497
|
-
return err.cleanupFailed ? `${text}\n${t("login.web_cleanup_failed", backend)}` : text;
|
|
23279
|
+
return { failure: "start", message: err.message, cleanupFailed: !!err.cleanupFailed };
|
|
22498
23280
|
}
|
|
22499
23281
|
if (session.state === "done") {
|
|
22500
23282
|
this.activeInstall = null;
|
|
22501
23283
|
this.loginWindow.release(claim);
|
|
22502
|
-
return
|
|
23284
|
+
return { failure: "cancelled" };
|
|
22503
23285
|
}
|
|
22504
23286
|
if (!this.loginWindow.isCurrent(claim)) {
|
|
22505
23287
|
await session.cancel("cancelled").catch(() => { });
|
|
22506
23288
|
this.activeInstall = null;
|
|
22507
23289
|
this.loginWindow.release(claim);
|
|
22508
|
-
return
|
|
23290
|
+
return { failure: "shutting_down" };
|
|
22509
23291
|
}
|
|
22510
|
-
return
|
|
23292
|
+
return { session };
|
|
23293
|
+
}
|
|
23294
|
+
/** AGEND-133: the dashboard's Install button — what the Accounts page asks of `/login`'s install, with no chat to report in. */
|
|
23295
|
+
webHostInstallsInstance = null;
|
|
23296
|
+
get webHostInstalls() {
|
|
23297
|
+
this.webHostInstallsInstance ??= new WebHostInstalls({
|
|
23298
|
+
isLocalAdmin: handle => this.isLocalAdminSession(handle),
|
|
23299
|
+
installable: backend => !isRemovedBackend(backend) && !!BACKEND_INSTALLATION_INFO[backend],
|
|
23300
|
+
updatable: backend => !isRemovedBackend(backend) && !!BACKEND_INSTALLATION_INFO[backend] && !!hostUpdatePlan(backend),
|
|
23301
|
+
start: (backend, reporter, execution, mode) => this.startWebInstall(backend, reporter, execution, mode),
|
|
23302
|
+
cancel: async () => { if (!this.activeInstall)
|
|
23303
|
+
return false; await this.cancelInstallSession(); return true; },
|
|
23304
|
+
// No details in the event: each page reads GET /ui/host-install. The Accounts list reads itself again on the same event (the CLI is installed now).
|
|
23305
|
+
changed: () => { broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed")); },
|
|
23306
|
+
});
|
|
23307
|
+
return this.webHostInstallsInstance;
|
|
23308
|
+
}
|
|
23309
|
+
/**
|
|
23310
|
+
* AGEND-133: install a CLI for the dashboard. Only the CLI's id arrives (the caller validated it against the registry's table); the command is
|
|
23311
|
+
* `info.unattended ?? info.install` read here, the window and its judgement are `/login`'s (openInstallWindow). The verdict is then checked the way chat's
|
|
23312
|
+
* is — a fresh login shell, else the installer's own directories — and the availability probe reads the version for the page. Everything is
|
|
23313
|
+
* reported through `reporter`; nothing is posted to any chat, and no sign-in is started (the page offers Sign in itself).
|
|
23314
|
+
*/
|
|
23315
|
+
async startWebInstall(backendArg, reporter, execution, mode = "install") {
|
|
23316
|
+
execution?.assert();
|
|
23317
|
+
const backend = LOGIN_BACKEND_ALIASES[backendArg.toLowerCase()] ?? backendArg.toLowerCase();
|
|
23318
|
+
const base = BACKEND_INSTALLATION_INFO[backend];
|
|
23319
|
+
if (!base || isRemovedBackend(backend))
|
|
23320
|
+
return { refused: "unsupported" };
|
|
23321
|
+
// AGEND-136: an update runs the registry's `host.update` command with the audited release in it (hostUpdatePlan); the window, its judgement and its release are the install's.
|
|
23322
|
+
const plan = mode === "update" ? hostUpdatePlan(backend) : null;
|
|
23323
|
+
if (mode === "update" && !plan)
|
|
23324
|
+
return { refused: "unsupported" };
|
|
23325
|
+
const info = plan ? { install: plan.command } : base;
|
|
23326
|
+
// The fleet-wide window, claimed before the first await (shared with /login, chat's install and sign-in).
|
|
23327
|
+
const claim = this.loginWindow.tryClaim("install", backend);
|
|
23328
|
+
if (!claim)
|
|
23329
|
+
return { refused: this.loginWindow.isClosed ? "shutting_down" : "busy" };
|
|
23330
|
+
// #3542 / AGEND-144 (Prism on #3539): the claim is a lock, not the asker's authority. The confirmed change's own execution (its session, role, confirmation and the settings it was held
|
|
23331
|
+
// against) is asked again after each wait (the binary check, the version refresh), and its admission ends at the tmux command that starts the installer (openInstallWindow → `launch`).
|
|
23332
|
+
const asker = () => { try {
|
|
23333
|
+
return !execution || execution.current();
|
|
23334
|
+
}
|
|
23335
|
+
catch {
|
|
23336
|
+
return false;
|
|
23337
|
+
} };
|
|
23338
|
+
const present = await checkBinaryInstalledAsync(base.binary);
|
|
23339
|
+
if (mode === "install" && present) {
|
|
23340
|
+
this.loginWindow.release(claim);
|
|
23341
|
+
return { refused: "already" };
|
|
23342
|
+
}
|
|
23343
|
+
// An update needs the CLI where the Accounts page found it: on the fleet's PATH, else (a fresh login shell, then) the installer's own directories (~/.grok/bin, ~/.opencode/bin …).
|
|
23344
|
+
if (mode === "update" && !present && !(await this.locateInstalledCli(backend, base.binary).catch(() => null))) {
|
|
23345
|
+
this.loginWindow.release(claim);
|
|
23346
|
+
return { refused: "not_installed" };
|
|
23347
|
+
}
|
|
23348
|
+
if (!asker()) {
|
|
23349
|
+
this.loginWindow.release(claim);
|
|
23350
|
+
return { refused: "failed" };
|
|
23351
|
+
}
|
|
23352
|
+
let versionBefore = null;
|
|
23353
|
+
if (plan) {
|
|
23354
|
+
// The version the page shows as "before" is the binary probe's own, read now (not the last snapshot), and an update only starts when the CLI is really behind the audited release.
|
|
23355
|
+
// AGEND-144 (Prism on #3539, P2-3): that reading must be FRESH, SUCCESSFUL and of the executable that resolves now. The published row is not enough: a forced refresh keeps the previous
|
|
23356
|
+
// version when the new probe fails for the same path (right for the pickers, which fail open), so a replaced binary whose version cannot be read would still carry the old
|
|
23357
|
+
// number and an update to an older release would be accepted. Unreadable refuses. (The published row is refreshed too, as before, for the pickers and the page.)
|
|
23358
|
+
// AGEND-148 (Prism R3 on #3539, P2-3): the admission's reading comes AFTER the other awaited preparation (the forced refresh publishes a probe of its own), so it is the newest
|
|
23359
|
+
// observation — a version published while this update was being prepared is never discarded for an earlier one.
|
|
23360
|
+
await this.backendAvailability.refresh([backend], { force: true }).catch(() => { });
|
|
23361
|
+
const fresh = await this.backendAvailability.freshVersion(backend).catch(() => null);
|
|
23362
|
+
versionBefore = fresh?.version ?? null;
|
|
23363
|
+
if (!this.loginWindow.isCurrent(claim)) {
|
|
23364
|
+
this.loginWindow.release(claim);
|
|
23365
|
+
return { refused: "shutting_down" };
|
|
23366
|
+
}
|
|
23367
|
+
if (!asker()) {
|
|
23368
|
+
this.loginWindow.release(claim);
|
|
23369
|
+
return { refused: "failed" };
|
|
23370
|
+
}
|
|
23371
|
+
if (!fresh) {
|
|
23372
|
+
this.loginWindow.release(claim);
|
|
23373
|
+
return { refused: "version_unreadable" };
|
|
23374
|
+
}
|
|
23375
|
+
// AGEND-153: the named exception (`release: "latest-unaudited"`) is offered at any readable version (it goes to the vendor's newest, not to our audited release), so "behind" does not decide it.
|
|
23376
|
+
if (cliUpdateView(backend, versionBefore, true, plan.target === null)?.button !== true) {
|
|
23377
|
+
this.loginWindow.release(claim);
|
|
23378
|
+
return { refused: "up_to_date" };
|
|
23379
|
+
}
|
|
23380
|
+
try {
|
|
23381
|
+
reporter.update?.(versionOf(versionBefore), plan.target);
|
|
23382
|
+
}
|
|
23383
|
+
catch { /* a view never stops the update */ }
|
|
23384
|
+
}
|
|
23385
|
+
else
|
|
23386
|
+
this.recordLoginFlow(backend, "install_only", "web");
|
|
23387
|
+
const opened = await this.openInstallWindow(backend, info, claim, {
|
|
23388
|
+
onProgress: pane => { try {
|
|
23389
|
+
reporter.progress(pane);
|
|
23390
|
+
}
|
|
23391
|
+
catch { /* a view never stops the install */ } },
|
|
23392
|
+
onDone: async ({ ok, detail, cleanupFailed }) => {
|
|
23393
|
+
this.activeInstall = null;
|
|
23394
|
+
this.loginWindow.release(claim);
|
|
23395
|
+
let verified = false, version = null;
|
|
23396
|
+
if (ok) {
|
|
23397
|
+
// The installer may only have added the binary to a profile PATH; a fresh login shell sees that, the fleet's own PATH may not.
|
|
23398
|
+
const installedAt = await this.locateInstalledCli(backend, base.binary).catch(() => null);
|
|
23399
|
+
if (installedAt) {
|
|
23400
|
+
verified = true;
|
|
23401
|
+
this.adoptBinaryDirectory(installedAt, backend);
|
|
23402
|
+
// The binary probe: the same refresh that makes the pickers know it (#2072) — awaited here, for the version the page shows.
|
|
23403
|
+
await this.backendAvailability.refresh([backend], { force: true }).catch(() => { });
|
|
23404
|
+
version = this.backendAvailabilityRows().find(row => row.backend === backend)?.version ?? null;
|
|
23405
|
+
}
|
|
23406
|
+
}
|
|
23407
|
+
this.logger.info({ backend, mode, ok, verified, ...(plan ? { to: plan.target } : {}), ...(ok ? {} : { detail }) }, mode === "update" ? "Dashboard update ended" : "Dashboard install ended");
|
|
23408
|
+
try {
|
|
23409
|
+
reporter.done({ ok, detail, cleanupFailed, verified, version, signIn: !!LOGIN_FLOWS[backend] && dashboardSignInSupported(backend) });
|
|
23410
|
+
}
|
|
23411
|
+
catch { /* a view never stops the install */ }
|
|
23412
|
+
},
|
|
23413
|
+
}, execution);
|
|
23414
|
+
if ("failure" in opened) {
|
|
23415
|
+
if (opened.failure === "shutting_down")
|
|
23416
|
+
return { refused: "shutting_down" };
|
|
23417
|
+
if (opened.failure === "cancelled")
|
|
23418
|
+
return { refused: this.loginWindow.isClosed ? "shutting_down" : "failed", message: "cancelled" };
|
|
23419
|
+
return { refused: "failed", message: opened.message };
|
|
23420
|
+
}
|
|
23421
|
+
return { started: true };
|
|
23422
|
+
}
|
|
23423
|
+
/** A fresh login shell's answer for `binary`, else the installer's own directories (see locateBinaryOnLoginShell / locateInstalledBackend). */
|
|
23424
|
+
async locateInstalledCli(backend, binary) {
|
|
23425
|
+
return (await this.locateBinaryOnLoginShell(binary)) ?? (await this.locateInstalledBackend(backend));
|
|
22511
23426
|
}
|
|
22512
23427
|
/** Whether this backend's CLI is on the fleet's PATH (what `/login` installs when it is not). */
|
|
22513
23428
|
isCliInstalled(backend) {
|
|
@@ -23718,7 +24633,7 @@ export class FleetManager {
|
|
|
23718
24633
|
/** #1806: null on a switch INTO claude-code — the configured model then belongs to the backend being left. */
|
|
23719
24634
|
configured = this.fleetConfig?.instances[instanceName]?.model ?? this.fleetConfig?.defaults?.model) {
|
|
23720
24635
|
const aliases = ["default", "sonnet", "opus", "haiku", "opusplan", "Fable"];
|
|
23721
|
-
const api = (this.
|
|
24636
|
+
const api = (this.webModelEnv("claude-code", instanceName)?.apiModels ?? []).map(m => m.id);
|
|
23722
24637
|
const lower = model.trim().toLowerCase();
|
|
23723
24638
|
const bare = lower.replace(/\[1m\]$/, "");
|
|
23724
24639
|
const known = aliases.some(a => a.toLowerCase() === bare)
|
|
@@ -23861,6 +24776,8 @@ export class FleetManager {
|
|
|
23861
24776
|
this.pendingCliEnvProbes.clear();
|
|
23862
24777
|
this.pendingVendorCliEnvProbes.clear();
|
|
23863
24778
|
this.pendingInstanceModelProbes.clear();
|
|
24779
|
+
this.webModelRefreshes.clear();
|
|
24780
|
+
this.webModelCatalogs.clear();
|
|
23864
24781
|
}
|
|
23865
24782
|
runBackendProbeWorker(key, input) {
|
|
23866
24783
|
if (this.shuttingDown)
|
|
@@ -24034,20 +24951,37 @@ export class FleetManager {
|
|
|
24034
24951
|
// indefinitely — each is wrapped by CLI_ENV_PROBE_DEADLINE_MS.
|
|
24035
24952
|
for (const b of backends)
|
|
24036
24953
|
void this.probeBackendBounded(b);
|
|
24037
|
-
|
|
24038
|
-
|
|
24039
|
-
|
|
24954
|
+
this.probeChangedCliEnvs(null);
|
|
24955
|
+
}
|
|
24956
|
+
/** Maintain discovery after committed config changes; a model-field read remains passive. */
|
|
24957
|
+
probeChangedCliEnvs(previous) {
|
|
24958
|
+
const signature = (fleet, name) => {
|
|
24959
|
+
const inst = fleet?.instances[name];
|
|
24960
|
+
if (!inst)
|
|
24961
|
+
return null;
|
|
24962
|
+
const backend = inst.backend ?? fleet?.defaults?.backend ?? "claude-code";
|
|
24963
|
+
return JSON.stringify({ backend, options: { ...fleet?.defaults?.backend_options?.[backend], ...inst.backend_options?.[backend] } });
|
|
24964
|
+
};
|
|
24040
24965
|
for (const name of Object.keys(this.fleetConfig?.instances ?? {})) {
|
|
24041
24966
|
if (isWindowsInstance(this.fleetConfig?.instances[name]))
|
|
24042
24967
|
continue;
|
|
24043
|
-
|
|
24968
|
+
const backend = this.backendNameForInstance(name);
|
|
24969
|
+
const binding = this.webModelBinding(backend, name);
|
|
24970
|
+
// A named agy account has no verified relocation/discovery contract. In particular,
|
|
24971
|
+
// never publish the ambient account's models under that profile (#3526 / D7).
|
|
24972
|
+
if (!binding || (binding.profile && !credentialHomeSpec(backend)))
|
|
24973
|
+
continue;
|
|
24974
|
+
// A description/defaults save can retire a scoped answer's full binding even
|
|
24975
|
+
// though its account signature is unchanged. Keep the conservative fence and
|
|
24976
|
+
// re-arm the current binding, unless its answer or flight is already present.
|
|
24977
|
+
if (previous && signature(previous, name) === signature(this.fleetConfig, name)
|
|
24978
|
+
&& (!binding.scoped || this.webModelEnv(backend, name) || this.webModelRefreshes.has(binding.key)))
|
|
24044
24979
|
continue;
|
|
24045
|
-
const
|
|
24046
|
-
|
|
24047
|
-
|
|
24980
|
+
const work = binding.scoped
|
|
24981
|
+
? this.refreshModelCatalogFor(backend, name)
|
|
24982
|
+
: this.probeBackendBounded(backend, { profile: binding.profile });
|
|
24983
|
+
void work.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
|
|
24048
24984
|
}
|
|
24049
|
-
for (const profile of profiles)
|
|
24050
|
-
void this.probeBackendBounded("claude-code", { profile });
|
|
24051
24985
|
}
|
|
24052
24986
|
/** Best-effort model list for `/model`: cached CLI env first, else live probe. Never throws. */
|
|
24053
24987
|
async getModelOptions(instanceName, refresh = false, onLiveProbe) {
|
|
@@ -24125,9 +25059,11 @@ export class FleetManager {
|
|
|
24125
25059
|
inventory = await this.runtimeWindowsExecutor().probe({ force: false, machineId: config.machine_id });
|
|
24126
25060
|
}
|
|
24127
25061
|
catch { /* offline remains unavailable */ }
|
|
25062
|
+
const refreshed = cachedNativeModelCatalog(this, { backend, instance: instanceName });
|
|
25063
|
+
const profile = config.backend_options?.[backend]?.credential_profile || (backend === "claude-code" ? inventory?.credentialProfiles?.default : undefined);
|
|
24128
25064
|
const row = inventory?.clis.find(value => value.id === backend);
|
|
24129
25065
|
return { backend, scope: "instance", instance: instanceName, current_model: config.model || null,
|
|
24130
|
-
models: (row?.models ?? []).map(value => ({ id: value.id, label: value.name ?? value.id, ...(value.description ? { description: value.description } : {}) })),
|
|
25066
|
+
models: refreshed?.models ?? (profile ? [] : row?.models ?? []).map(value => ({ id: value.id, label: value.name ?? value.id, ...(value.description ? { description: value.description } : {}) })),
|
|
24131
25067
|
source: row?.models?.length ? "cache" : "fallback",
|
|
24132
25068
|
...(inventory?.probedAt ? { probed_at: new Date(inventory.probedAt).toISOString() } : {}),
|
|
24133
25069
|
note: "Windows runtime's last detected inventory; no coordinator account or live probe is used." };
|
|
@@ -25001,7 +25937,7 @@ export class FleetManager {
|
|
|
25001
25937
|
currentBackend: (name) => this.backendNameForInstance(name),
|
|
25002
25938
|
currentDisplay: (name) => `${this.backendNameForInstance(name)} · ${this.resolveInstanceModel(name).display}`,
|
|
25003
25939
|
availability: () => this.backendAvailabilityFor(instanceName),
|
|
25004
|
-
models: (backend) => this.backendModelOptions(backend, opts),
|
|
25940
|
+
models: (backend) => this.backendModelOptions(backend, { ...opts, instance: instanceName }),
|
|
25005
25941
|
// #1808: the same rule update_instance_config's switch applies (backendModelVerdict).
|
|
25006
25942
|
modelKnown: (backend, model) => this.backendModelVerdict(instanceName, backend, model).ok,
|
|
25007
25943
|
effortLevels: (backend, model) => this.backendEffortLevels(instanceName, backend, model),
|
|
@@ -25056,7 +25992,7 @@ export class FleetManager {
|
|
|
25056
25992
|
// review): only the launch-line rule applies — never the account's list or the default provider's naming pattern.
|
|
25057
25993
|
if (opts.provider)
|
|
25058
25994
|
return modelNameCarried(backend, model) ? { ok: true } : { ok: false, choices: [] };
|
|
25059
|
-
const listed = this.
|
|
25995
|
+
const listed = this.webModelEnv(backend, instanceName)?.models ?? [];
|
|
25060
25996
|
const choices = listed.slice(0, 24).map(o => o.id);
|
|
25061
25997
|
if (!modelNameCarried(backend, model))
|
|
25062
25998
|
return { ok: false, choices };
|
|
@@ -25110,21 +26046,85 @@ export class FleetManager {
|
|
|
25110
26046
|
* #2072 part 3: the models a Settings field offers for `backend` — the cached catalog (an instance's own credential
|
|
25111
26047
|
* profile's, when it is named and has one), claude's account catalog included. Read only: never a probe.
|
|
25112
26048
|
*/
|
|
25113
|
-
|
|
25114
|
-
|
|
25115
|
-
|
|
26049
|
+
webModelTargetIds = new WeakMap();
|
|
26050
|
+
webModelTargetSequence = 0;
|
|
26051
|
+
webModelCatalogs = new Map();
|
|
26052
|
+
webModelRefreshes = new Map();
|
|
26053
|
+
/** Resolve only trusted config; the browser never supplies a home, provider URL or credentials. */
|
|
26054
|
+
webModelBinding(backend, instance, selection) {
|
|
26055
|
+
this.webModelTargetIds ??= new WeakMap();
|
|
26056
|
+
this.webModelTargetSequence ??= 0;
|
|
26057
|
+
this.webModelCatalogs ??= new Map();
|
|
26058
|
+
this.webModelRefreshes ??= new Map();
|
|
25116
26059
|
if (!KNOWN_BACKENDS.includes(backend) || backend === "mock")
|
|
25117
|
-
return
|
|
25118
|
-
const
|
|
25119
|
-
|
|
25120
|
-
const
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
26060
|
+
return null;
|
|
26061
|
+
const instances = this.fleetConfig?.instances ?? {};
|
|
26062
|
+
const own = instance && Object.hasOwn(instances, instance) ? instances[instance] : null;
|
|
26063
|
+
const classic = instance && !own ? this.classicChannels?.getAll().find(c => c.instanceName === instance) : null;
|
|
26064
|
+
if (instance && !own && !classic || own && isWindowsInstance(own))
|
|
26065
|
+
return null;
|
|
26066
|
+
const options = { ...this.fleetConfig?.defaults?.backend_options?.[backend], ...(own?.backend_options?.[backend] ?? (instance ? this.classicChannels?.getBackendOptionsByInstance(instance)?.[backend] : undefined)) };
|
|
26067
|
+
if (selection?.profile !== undefined) {
|
|
26068
|
+
if (selection.profile && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(selection.profile))
|
|
26069
|
+
return null;
|
|
26070
|
+
options.credential_profile = selection.profile || this.fleetConfig?.defaults?.backend_options?.[backend]?.credential_profile || undefined;
|
|
26071
|
+
}
|
|
26072
|
+
const profile = typeof options.credential_profile === "string" ? options.credential_profile : null;
|
|
26073
|
+
const instanceDir = instance ? this.getInstanceDir(instance) : join(getAgendHome(), "cli-env");
|
|
26074
|
+
const config = structuredClone({ workingDirectory: own?.working_directory ?? "", instanceDir,
|
|
26075
|
+
instanceName: instance ?? `probe-${backend}`, mcpServers: {}, backendOptions: options,
|
|
26076
|
+
...(profile ? { credentialStoreHome: credentialProfileStoreHome(getAgendHome(), backend, profile) } : {}) });
|
|
26077
|
+
const target = own ?? classic;
|
|
26078
|
+
if (target && !this.webModelTargetIds.has(target))
|
|
26079
|
+
this.webModelTargetIds.set(target, ++this.webModelTargetSequence);
|
|
26080
|
+
const targetId = target ? this.webModelTargetIds.get(target) : 0;
|
|
26081
|
+
const key = JSON.stringify({ backend, instance, config, targetId, target: own ?? classic, defaults: this.fleetConfig?.defaults });
|
|
26082
|
+
return { key, own, classic, profile, config, scoped: !!options.provider || (!!profile && backend !== "claude-code") };
|
|
26083
|
+
}
|
|
26084
|
+
webModelEnv(backend, instance, selection) {
|
|
26085
|
+
const binding = this.webModelBinding(backend, instance, selection);
|
|
26086
|
+
if (!binding)
|
|
26087
|
+
return null;
|
|
26088
|
+
const disk = binding.scoped ? null : this.readCliEnv(backend, binding.profile);
|
|
26089
|
+
const hit = this.webModelCatalogs.get(binding.key);
|
|
26090
|
+
if (hit && Date.now() - hit.probedAt < CLI_ENV_TTL_MS && (!disk || hit.probedAt >= disk.probedAt))
|
|
26091
|
+
return hit;
|
|
26092
|
+
return disk;
|
|
26093
|
+
}
|
|
26094
|
+
modelCatalogFor(backend, instance, selection) {
|
|
26095
|
+
const env = this.webModelEnv(backend, instance, selection);
|
|
26096
|
+
const seen = new Set();
|
|
26097
|
+
return [...(env?.models ?? []), ...(env?.apiModels ?? [])].filter(m => !seen.has(m.id) && !!seen.add(m.id));
|
|
26098
|
+
}
|
|
26099
|
+
/** Explicit, bounded vendor rediscovery. Never publish an answer under a different account/config/instance. */
|
|
26100
|
+
async refreshModelCatalogFor(backend, instance, selection) {
|
|
26101
|
+
const binding = this.webModelBinding(backend, instance, selection);
|
|
26102
|
+
if (!binding || this.shuttingDown)
|
|
26103
|
+
return { models: [], refreshed: false };
|
|
26104
|
+
const pending = this.webModelRefreshes.get(binding.key);
|
|
26105
|
+
if (pending)
|
|
26106
|
+
return pending;
|
|
26107
|
+
const epoch = this.cliEnvProbeEpoch;
|
|
26108
|
+
const current = () => {
|
|
26109
|
+
const next = this.webModelBinding(backend, instance, selection);
|
|
26110
|
+
return !this.shuttingDown && epoch === this.cliEnvProbeEpoch && next?.key === binding.key && next.own === binding.own && next.classic === binding.classic;
|
|
26111
|
+
};
|
|
26112
|
+
const work = this.runBackendProbeWorker(binding.scoped && !binding.profile ? `instance:${backend}:${binding.config.instanceDir}` : `global:${backend}${binding.profile ? `@${binding.profile}` : ""}`, {
|
|
26113
|
+
mode: "env", backend, instanceDir: binding.config.instanceDir, config: binding.config, refreshVendorCatalog: true,
|
|
26114
|
+
}).then(result => {
|
|
26115
|
+
if (!current())
|
|
26116
|
+
return { models: [], refreshed: false };
|
|
26117
|
+
// Raw failure/empty discovery never masquerades as a successful refresh of the retained catalog.
|
|
26118
|
+
if (!result || Array.isArray(result) || (!Array.isArray(result.models) || !result.models.length || result.catalogRefreshFailed))
|
|
26119
|
+
return { models: this.modelCatalogFor(backend, instance, selection), refreshed: false };
|
|
26120
|
+
if (this.webModelCatalogs.size >= 64)
|
|
26121
|
+
this.webModelCatalogs.delete(this.webModelCatalogs.keys().next().value);
|
|
26122
|
+
this.webModelCatalogs.set(binding.key, { ...result, backend, probedAt: Date.now() });
|
|
26123
|
+
return { models: this.modelCatalogFor(backend, instance, selection), refreshed: true };
|
|
26124
|
+
}).finally(() => { if (this.webModelRefreshes.get(binding.key) === work)
|
|
26125
|
+
this.webModelRefreshes.delete(binding.key); });
|
|
26126
|
+
this.webModelRefreshes.set(binding.key, work);
|
|
26127
|
+
return work;
|
|
25128
26128
|
}
|
|
25129
26129
|
/** Host-default fallback only: Grok has no modeled profile home. Never construct a backend or start a probe. */
|
|
25130
26130
|
async cliModelCatalogFor(backend, instance) {
|
|
@@ -25208,6 +26208,8 @@ export class FleetManager {
|
|
|
25208
26208
|
}
|
|
25209
26209
|
/** The models `/model` would offer on a backend: the cached CLI env, else (live) a bounded probe. Never throws. */
|
|
25210
26210
|
async backendModelOptions(backend, opts) {
|
|
26211
|
+
if (!opts.live && opts.instance)
|
|
26212
|
+
return this.modelCatalogFor(backend, opts.instance);
|
|
25211
26213
|
const cached = this.readCliEnv(backend);
|
|
25212
26214
|
if (!opts.live || (cached?.models.length && !this.cliEnvNeedsRefresh(cached)))
|
|
25213
26215
|
return cached?.models ?? [];
|
|
@@ -25829,6 +26831,10 @@ export class FleetManager {
|
|
|
25829
26831
|
this.fleetWindowsRuntime = null;
|
|
25830
26832
|
this.runtimeHub?.close();
|
|
25831
26833
|
this.runtimeHub = null;
|
|
26834
|
+
if (this.ownerNoticeTimer) {
|
|
26835
|
+
clearTimeout(this.ownerNoticeTimer);
|
|
26836
|
+
this.ownerNoticeTimer = null;
|
|
26837
|
+
}
|
|
25832
26838
|
this.localPaneRelay?.stop();
|
|
25833
26839
|
this.localPaneRelay = null;
|
|
25834
26840
|
closeWindowsBridge(this);
|
|
@@ -26373,6 +27379,7 @@ export class FleetManager {
|
|
|
26373
27379
|
this.agentCredentialsCache?.observePolicies();
|
|
26374
27380
|
if (this.loadedFleetSource)
|
|
26375
27381
|
this.getConfigHistory().accepted("fleet.yaml", this.configPath, this.loadedFleetSource);
|
|
27382
|
+
this.probeChangedCliEnvs(oldConfig);
|
|
26376
27383
|
this.migrateOfficeStorage();
|
|
26377
27384
|
this.migrateNoticeDeliveryStorage();
|
|
26378
27385
|
// Classic behavior settings share the fleet defaults but are not entries
|
|
@@ -28749,7 +29756,7 @@ export class FleetManager {
|
|
|
28749
29756
|
&& String(req.headers.accept ?? "").includes("text/html")
|
|
28750
29757
|
&& isWebPageNavigation(requestPath)) {
|
|
28751
29758
|
const link = gatewayRequestContext(req);
|
|
28752
|
-
serveSigninPage(res, 401, { webOnly: this.isWebOnlyFleet(), outside: !!link && this.isOutsideLink(link.exposureId), deviceLogin: !link && this.deviceLoginAvailable(), loginQr: this.loginQrEnabled() });
|
|
29759
|
+
serveSigninPage(res, 401, { webOnly: this.isWebOnlyFleet(), noChat: this.signinWithoutChat(), outside: !!link && this.isOutsideLink(link.exposureId), deviceLogin: !link && this.deviceLoginAvailable(), loginQr: this.loginQrEnabled() });
|
|
28753
29760
|
return;
|
|
28754
29761
|
}
|
|
28755
29762
|
res.writeHead(decision.status);
|
|
@@ -29485,7 +30492,7 @@ export class FleetManager {
|
|
|
29485
30492
|
// shown here rather than in chat). null when normal, unknown or advisory.
|
|
29486
30493
|
host_memory: this.hostMemoryIndicator(),
|
|
29487
30494
|
// #2910 D2: a web-only fleet's newest Notice — a polling page (no SSE `notice`) reads the list again when it moves.
|
|
29488
|
-
...(this.
|
|
30495
|
+
...(this.hasWebNotices() ? { notices_newest: this.webNoticeStore()?.newest() ?? 0 } : {}),
|
|
29489
30496
|
// alpha.2 (M-2300, #2997 review): agents' requests changed — the owner's page reads GET /ui/agent-proposals again.
|
|
29490
30497
|
...(this.isWebOnlyFleet() ? { agent_proposals_rev: this.agentProposalsRev } : {}),
|
|
29491
30498
|
// #2015: the largest processes while it lasts (name, pid, RSS, and whose: an instance, the fleet or tmux).
|