@songsid/agend 2.3.5-alpha.7 → 2.3.5-alpha.9
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-profiles.d.ts +6 -0
- package/dist/accounts-profiles.js +16 -0
- package/dist/accounts-profiles.js.map +1 -1
- package/dist/accounts-view.d.ts +17 -0
- package/dist/accounts-view.js +33 -6
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +1 -1
- package/dist/agent-cli.js +5 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-whats-new.js +5 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/apply-job.d.ts +5 -0
- package/dist/apply-job.js +10 -3
- package/dist/apply-job.js.map +1 -1
- package/dist/auth-api.d.ts +1 -1
- package/dist/auth-api.js +4 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/company-join.d.ts +16 -0
- package/dist/authority/company-join.js +37 -0
- package/dist/authority/company-join.js.map +1 -0
- package/dist/authority/hub-initialization.d.ts +13 -0
- package/dist/authority/hub-initialization.js +30 -0
- package/dist/authority/hub-initialization.js.map +1 -0
- package/dist/backend/claude-code.d.ts +1 -0
- package/dist/backend/claude-code.js +13 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/types.d.ts +4 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +2 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-model-minimum.d.ts +7 -0
- package/dist/claude-model-minimum.js +16 -0
- package/dist/claude-model-minimum.js.map +1 -0
- package/dist/config-validator.js +2 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/daemon.d.ts +43 -1
- package/dist/daemon.js +176 -27
- package/dist/daemon.js.map +1 -1
- package/dist/decision-list.d.ts +2 -0
- package/dist/decision-list.js +1 -1
- package/dist/decision-list.js.map +1 -1
- package/dist/fleet-manager.d.ts +75 -3
- package/dist/fleet-manager.js +462 -53
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +14 -3
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/general-knowledge/steering/core-rules.md +1 -1
- package/dist/hub/catalog.d.ts +1 -1
- package/dist/hub/catalog.js +151 -33
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.js +4 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +6 -0
- package/dist/hub/compose/member.js +9 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +55 -1
- package/dist/hub/compose/server.js +76 -10
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +2 -0
- package/dist/hub/directory/directory.js +49 -4
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +2 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/enrollment-budget.d.ts +6 -0
- package/dist/hub/enrollment-budget.js +24 -0
- package/dist/hub/enrollment-budget.js.map +1 -0
- package/dist/hub/group-policy/admin-api.d.ts +30 -0
- package/dist/hub/group-policy/admin-api.js +83 -0
- package/dist/hub/group-policy/admin-api.js.map +1 -0
- package/dist/hub/group-policy/admin-control.d.ts +34 -0
- package/dist/hub/group-policy/admin-control.js +258 -0
- package/dist/hub/group-policy/admin-control.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +9 -1
- package/dist/hub/group-policy/admin-dto.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +17 -0
- package/dist/hub/group-policy/admin-facts.js +33 -0
- package/dist/hub/group-policy/admin-facts.js.map +1 -0
- package/dist/hub/group-policy/admin-impact.d.ts +51 -0
- package/dist/hub/group-policy/admin-impact.js +88 -0
- package/dist/hub/group-policy/admin-impact.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +22 -0
- package/dist/hub/group-policy/authorization.js +147 -2
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
- package/dist/hub/group-policy/impact-inventory.js +75 -0
- package/dist/hub/group-policy/impact-inventory.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +13 -1
- package/dist/hub/group-policy/resources.js +92 -23
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.d.ts +11 -0
- package/dist/hub/group-policy/store.js +57 -2
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/group-policy/welcome.d.ts +36 -0
- package/dist/hub/group-policy/welcome.js +55 -0
- package/dist/hub/group-policy/welcome.js.map +1 -0
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +184 -8
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +2 -0
- package/dist/hub/http/core.js +10 -1
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +10 -0
- package/dist/hub/http/schema.js +4 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/browser-certificate.d.ts +6 -1
- package/dist/hub/init/browser-certificate.js +22 -1
- package/dist/hub/init/browser-certificate.js.map +1 -1
- package/dist/hub/init/initializer.d.ts +11 -1
- package/dist/hub/init/initializer.js +202 -83
- package/dist/hub/init/initializer.js.map +1 -1
- package/dist/hub/init/layout.js +1 -1
- package/dist/hub/init/layout.js.map +1 -1
- package/dist/hub/init/text.js +2 -2
- package/dist/hub/init/text.js.map +1 -1
- package/dist/hub/init/types.d.ts +32 -4
- package/dist/hub/init/types.js.map +1 -1
- package/dist/hub/init/web-audit-import.d.ts +12 -0
- package/dist/hub/init/web-audit-import.js +39 -0
- package/dist/hub/init/web-audit-import.js.map +1 -0
- package/dist/hub/init/web-audit.d.ts +30 -0
- package/dist/hub/init/web-audit.js +42 -0
- package/dist/hub/init/web-audit.js.map +1 -0
- package/dist/hub/init/web-error.d.ts +6 -0
- package/dist/hub/init/web-error.js +8 -0
- package/dist/hub/init/web-error.js.map +1 -0
- package/dist/hub/init/web-http.d.ts +9 -0
- package/dist/hub/init/web-http.js +103 -0
- package/dist/hub/init/web-http.js.map +1 -0
- package/dist/hub/init/web.d.ts +118 -0
- package/dist/hub/init/web.js +428 -0
- package/dist/hub/init/web.js.map +1 -0
- package/dist/hub/init/wizard.js +1 -3
- package/dist/hub/init/wizard.js.map +1 -1
- package/dist/hub/join/client.d.ts +35 -0
- package/dist/hub/join/client.js +112 -0
- package/dist/hub/join/client.js.map +1 -0
- package/dist/hub/join/descriptor.d.ts +45 -0
- package/dist/hub/join/descriptor.js +52 -0
- package/dist/hub/join/descriptor.js.map +1 -0
- package/dist/hub/join/fleet-authority.d.ts +2 -0
- package/dist/hub/join/fleet-authority.js +3 -0
- package/dist/hub/join/fleet-authority.js.map +1 -0
- package/dist/hub/join/http.d.ts +8 -0
- package/dist/hub/join/http.js +112 -0
- package/dist/hub/join/http.js.map +1 -0
- package/dist/hub/join/invitation.d.ts +28 -0
- package/dist/hub/join/invitation.js +28 -0
- package/dist/hub/join/invitation.js.map +1 -0
- package/dist/hub/join/local-journal.d.ts +84 -0
- package/dist/hub/join/local-journal.js +65 -0
- package/dist/hub/join/local-journal.js.map +1 -0
- package/dist/hub/join/local.d.ts +116 -0
- package/dist/hub/join/local.js +419 -0
- package/dist/hub/join/local.js.map +1 -0
- package/dist/hub/join/private.d.ts +3 -0
- package/dist/hub/join/private.js +46 -0
- package/dist/hub/join/private.js.map +1 -0
- package/dist/hub/join/protocol.d.ts +69 -0
- package/dist/hub/join/protocol.js +96 -0
- package/dist/hub/join/protocol.js.map +1 -0
- package/dist/hub/join/receipt.d.ts +42 -0
- package/dist/hub/join/receipt.js +75 -0
- package/dist/hub/join/receipt.js.map +1 -0
- package/dist/hub/join/service.d.ts +177 -0
- package/dist/hub/join/service.js +564 -0
- package/dist/hub/join/service.js.map +1 -0
- package/dist/hub/join/store.d.ts +97 -0
- package/dist/hub/join/store.js +87 -0
- package/dist/hub/join/store.js.map +1 -0
- package/dist/hub/join/trust.d.ts +13 -0
- package/dist/hub/join/trust.js +68 -0
- package/dist/hub/join/trust.js.map +1 -0
- package/dist/hub/member/pairing-api.d.ts +2 -0
- package/dist/hub/member/pairing-api.js +7 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/pairing-notices.d.ts +18 -0
- package/dist/hub/member/pairing-notices.js +60 -0
- package/dist/hub/member/pairing-notices.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +47 -0
- package/dist/hub/pairing-notices.js +246 -0
- package/dist/hub/pairing-notices.js.map +1 -0
- package/dist/hub/pairing.d.ts +39 -1
- package/dist/hub/pairing.js +316 -16
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +61 -0
- package/dist/hub/protocol.js +8 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-read-pacer.d.ts +14 -0
- package/dist/hub/room-read-pacer.js +51 -0
- package/dist/hub/room-read-pacer.js.map +1 -0
- package/dist/hub/rooms.d.ts +7 -1
- package/dist/hub/rooms.js +25 -13
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +8 -1
- package/dist/hub/runtime.js +13 -0
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +3 -0
- package/dist/hub/server.js +18 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-directory-transition.d.ts +48 -0
- package/dist/hub/session-directory-transition.js +118 -0
- package/dist/hub/session-directory-transition.js.map +1 -0
- package/dist/hub/session-epoch.d.ts +16 -0
- package/dist/hub/session-epoch.js +50 -0
- package/dist/hub/session-epoch.js.map +1 -0
- package/dist/hub/sessions.d.ts +13 -0
- package/dist/hub/sessions.js +36 -16
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-api.d.ts +50 -0
- package/dist/hub/settings-api.js +92 -0
- package/dist/hub/settings-api.js.map +1 -0
- package/dist/hub/settings-commit.d.ts +95 -0
- package/dist/hub/settings-commit.js +490 -0
- package/dist/hub/settings-commit.js.map +1 -0
- package/dist/hub/settings-directory-decision.d.ts +433 -0
- package/dist/hub/settings-directory-decision.js +236 -0
- package/dist/hub/settings-directory-decision.js.map +1 -0
- package/dist/hub/settings-directory-proof.d.ts +77 -0
- package/dist/hub/settings-directory-proof.js +303 -0
- package/dist/hub/settings-directory-proof.js.map +1 -0
- package/dist/hub/store.d.ts +12 -2
- package/dist/hub/store.js +9 -5
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +15 -2
- package/dist/hub-host-settings.d.ts +48 -0
- package/dist/hub-host-settings.js +85 -0
- package/dist/hub-host-settings.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +3 -0
- package/dist/instance-lifecycle.js +4 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +54 -30
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +9 -1
- package/dist/login-controller.js +20 -1
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +4 -2
- package/dist/login-flows.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.js +1 -1
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +2 -0
- package/dist/outbound-schemas.js +4 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-port.d.ts +1 -1
- package/dist/profile-signins.d.ts +107 -0
- package/dist/profile-signins.js +249 -0
- package/dist/profile-signins.js.map +1 -0
- package/dist/quickstart-api.js +2 -2
- package/dist/quickstart-api.js.map +1 -1
- package/dist/reply-buttons-controller.d.ts +5 -1
- package/dist/reply-buttons-controller.js +8 -4
- package/dist/reply-buttons-controller.js.map +1 -1
- package/dist/reply-buttons.d.ts +6 -2
- package/dist/reply-buttons.js +7 -3
- package/dist/reply-buttons.js.map +1 -1
- package/dist/scheduler/db.d.ts +10 -0
- package/dist/scheduler/db.js +38 -11
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/types.d.ts +6 -1
- package/dist/settings-api.d.ts +9 -1
- package/dist/settings-api.js +200 -4
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-confirmation.d.ts +1 -1
- package/dist/settings-confirmation.js +1 -1
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.js +58 -0
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -0
- package/dist/settings-http-confirmation.js +8 -5
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +5 -0
- package/dist/settings-request-capability.js +6 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/signin-keepalive.d.ts +2 -0
- package/dist/signin-keepalive.js +30 -2
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/structured-signin-transport.d.ts +20 -2
- package/dist/structured-signin-transport.js +57 -6
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/team-membership.d.ts +7 -0
- package/dist/team-membership.js +10 -0
- package/dist/team-membership.js.map +1 -0
- package/dist/tmux-manager.d.ts +1 -1
- package/dist/tmux-manager.js +4 -1
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.js +1 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/ui/accounts-keepalive.js +10 -5
- package/dist/ui/accounts-manage.js +29 -11
- package/dist/ui/accounts-view.js +75 -28
- package/dist/ui/backend-signin.js +61 -16
- package/dist/ui/hub-attachments.js +3 -3
- package/dist/ui/hub-chat-strings.js +2 -0
- package/dist/ui/hub-client.js +50 -4
- package/dist/ui/hub-company-join-strings.js +74 -0
- package/dist/ui/hub-company-join.js +119 -0
- package/dist/ui/hub-group-policy.js +175 -0
- package/dist/ui/hub-group-strings.js +97 -0
- package/dist/ui/hub-owner-strings.js +12 -12
- package/dist/ui/hub-pairing-progress-strings.js +15 -0
- package/dist/ui/hub-quick-pairing.js +209 -0
- package/dist/ui/hub-quick-strings.js +43 -0
- package/dist/ui/hub-read-strings.js +7 -0
- package/dist/ui/hub-this-hub.js +112 -0
- package/dist/ui/hub-welcome.js +102 -0
- package/dist/ui/panel-hub.js +217 -28
- package/dist/ui/panel-needs.js +1 -1
- package/dist/ui/panel-settings.js +7 -4
- package/dist/ui/settings-apply.js +12 -5
- package/dist/ui/settings-devices.js +2 -2
- package/dist/ui/settings-dialogs.js +3 -1
- package/dist/ui/settings-hub-company-join.js +90 -0
- package/dist/ui/settings-hub-membership.js +20 -5
- package/dist/ui/settings-hub-preview.js +74 -0
- package/dist/ui/settings-hub-run.js +60 -0
- package/dist/ui/settings-hub-section.js +30 -3
- package/dist/ui/settings-hub.js +52 -11
- package/dist/ui/settings-registry.js +2 -0
- package/dist/ui/settings-restart-strings.js +17 -0
- package/dist/ui/settings-strings.js +6 -4
- package/dist/ui/shared/accounts-keepalive.css +11 -6
- package/dist/ui/shared/accounts.css +68 -18
- package/dist/ui/shared/app-i18n.js +4 -1
- package/dist/ui/shared/app-shell.js +39 -25
- package/dist/ui/shared/app.css +9 -8
- package/dist/ui/shared/chat-strings.js +13 -13
- package/dist/ui/shared/hub-chat.css +12 -0
- package/dist/ui/shared/hub-groups.css +28 -0
- package/dist/ui/shared/hub-owner.css +19 -1
- package/dist/ui/shared/hub.css +8 -1
- package/dist/ui/shared/setup-host-text.js +4 -1
- package/dist/ui/shared/signin.js +3 -1
- package/dist/ui/shared/usage-dialog.js +3 -72
- package/dist/ui/shared/usage-meter.js +84 -0
- package/dist/ui/shared/web-authorize.js +4 -4
- package/dist/ui/structured-signin.js +24 -6
- package/dist/update-dispatch.d.ts +32 -4
- package/dist/update-dispatch.js +146 -16
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +2 -2
- package/dist/update-launch.js.map +1 -1
- package/dist/update-marker.d.ts +2 -0
- package/dist/update-marker.js.map +1 -1
- package/dist/view-api.d.ts +2 -8
- package/dist/view-api.js +3 -9
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +7 -1
- package/dist/web-api.js +91 -14
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +16 -2
- package/dist/web-backend-login.js +14 -0
- package/dist/web-backend-login.js.map +1 -1
- package/dist/web-notices.d.ts +9 -0
- package/dist/web-notices.js +19 -0
- package/dist/web-notices.js.map +1 -1
- package/dist/web-terminal.d.ts +7 -0
- package/dist/web-terminal.js +14 -2
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
package/dist/fleet-manager.js
CHANGED
|
@@ -59,7 +59,7 @@ import { withinBudget } from "./monotonic-budget.js";
|
|
|
59
59
|
import { measureSyncWork } from "./sync-work-attribution.js";
|
|
60
60
|
import { RuntimeCpuProfiler, ProfileBusyError, profileDuration } from "./runtime-cpu-profile.js";
|
|
61
61
|
import { ProfileControlServer } from "./profile-control.js";
|
|
62
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync, rmSync, readdirSync, renameSync, copyFileSync, chmodSync, statSync, realpathSync, lstatSync, closeSync } from "node:fs";
|
|
62
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync, rmSync, readdirSync, renameSync, copyFileSync, chmodSync, statSync, realpathSync, lstatSync, constants as fsConstants, openSync, closeSync, fsyncSync } from "node:fs";
|
|
63
63
|
import { atomicWriteFileSync } from "./atomic-write.js";
|
|
64
64
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
65
65
|
import { freemem, totalmem, homedir, hostname } from "node:os";
|
|
@@ -342,6 +342,8 @@ import { SessionAuthorizationRequests } from "./web-session-authorization.js";
|
|
|
342
342
|
import { GuestLoginCodes, WebLoginCodes, LOGIN_CODE_TTL_MS } from "./web-login.js";
|
|
343
343
|
import { decisionListAnswer } from "./decision-list.js";
|
|
344
344
|
import { CodeRequestLimiter, ReturningDevices } from "./web-returning-device.js";
|
|
345
|
+
import { hubInitializationSession } from "./authority/hub-initialization.js";
|
|
346
|
+
import { companyJoinSession } from "./authority/company-join.js";
|
|
345
347
|
import { allowedHostNames, applyWebSecurityHeaders, hostnameOf, isHostAllowed, LOOPBACK_HOST_NAMES, WEB_HOST_REJECTED_MESSAGE } from "./web-host-guard.js";
|
|
346
348
|
import { createPreviewListener, normalizeOrigin, previewAvailability, previewSettings } from "./web-preview.js";
|
|
347
349
|
import { isCanvasWorkerTool, CANVAS_WORKER_EXPERIMENTAL_MESSAGE } from "./web-experimental.js";
|
|
@@ -359,11 +361,12 @@ import { kiroHome } from "./backend/kiro-kas-store.js";
|
|
|
359
361
|
import { CHAT_PROFILE_LOGIN_BACKENDS, credentialHomeSpec, credentialProfileHome, credentialProfileEnv, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
|
|
360
362
|
import { carryClaudeConversation } from "./backend/claude-carry.js";
|
|
361
363
|
import { classicProfile, mergeBackendOptions, profileKey, profileName, profileOf, readClassicBindings, readClassicBindingsStrict } from "./classic-bindings.js";
|
|
362
|
-
import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, weeklyUsage } from "./accounts-view.js";
|
|
363
|
-
import { addAccountProfile, removeAccountProfile } from "./accounts-profiles.js";
|
|
364
|
+
import { ACCOUNT_CLIS, PROFILE_CLIS, buildAccountsView, profilesOnDisk, shortUsage, weeklyUsage } from "./accounts-view.js";
|
|
365
|
+
import { accountFolderExists, addAccountProfile, removeAccountProfile } from "./accounts-profiles.js";
|
|
364
366
|
import { signOutAccount } from "./accounts-signout.js";
|
|
365
367
|
import { MachineAccounts, machineAgents } from "./machine-accounts.js";
|
|
366
368
|
import { MachineSignIns } from "./machine-signins.js";
|
|
369
|
+
import { ProfileSignIns } from "./profile-signins.js";
|
|
367
370
|
import { runQuiet } from "./quiet-run.js";
|
|
368
371
|
const ACCOUNT_SIGN_OUT_DEPS = {
|
|
369
372
|
platform: process.platform,
|
|
@@ -521,6 +524,11 @@ const CANCEL_BTN_MAX_LIFETIME_MS = 24 * 60 * 60_000;
|
|
|
521
524
|
const STALE_CANCEL_CLICK_COOLDOWN_MS = 10_000;
|
|
522
525
|
/** Orphaned-button ledger, swept at startup. Lives in the fleet data dir. */
|
|
523
526
|
const CANCEL_BTN_LEDGER_FILE = "cancel-buttons.json";
|
|
527
|
+
/**
|
|
528
|
+
* S-92: the restart marker's target for a web-only fleet's Settings restart (no chat message carries its progress). It is
|
|
529
|
+
* known by its `surface: "web"` (#3373 review P3: never by this id, which a chat connection could also be called).
|
|
530
|
+
*/
|
|
531
|
+
const WEB_RESTART_TARGET = "web-settings";
|
|
524
532
|
/**
|
|
525
533
|
* How often the cancel button's text is refreshed with elapsed working time.
|
|
526
534
|
*
|
|
@@ -725,6 +733,7 @@ export class RestartSupersededError extends Error {
|
|
|
725
733
|
}
|
|
726
734
|
export class FleetManager {
|
|
727
735
|
dataDir;
|
|
736
|
+
decisionSnapshot = [];
|
|
728
737
|
static signalTarget = null;
|
|
729
738
|
static sighupHandlerInstalled = false;
|
|
730
739
|
/** Test seam: inject a spy to verify saveFleetConfig calls fsync. Default: fsyncSync. */
|
|
@@ -1315,8 +1324,100 @@ export class FleetManager {
|
|
|
1315
1324
|
hubMemberExposureApi = null;
|
|
1316
1325
|
hubMemberExposures() { return this.hubMemberExposureApi; }
|
|
1317
1326
|
attachHubMemberExposures(api) { this.hubMemberExposureApi = api; }
|
|
1318
|
-
/**
|
|
1327
|
+
/** M-2687: local host-session setup; controller creation stays lazy while the Hub is off. */
|
|
1328
|
+
hubSetupController = null;
|
|
1329
|
+
hubSetupInit = null;
|
|
1330
|
+
hubSetupSession(req) {
|
|
1331
|
+
const token = this.webToken, sessions = this.webSessions, epoch = this.webAuthorityState().epoch;
|
|
1332
|
+
return hubInitializationSession(req, { token, sessions, config: this.fleetConfig, epoch, current: () => !this.shuttingDown
|
|
1333
|
+
&& token === this.webToken && sessions === this.webSessions && epoch === this.webAuthorityState().epoch });
|
|
1334
|
+
}
|
|
1335
|
+
async hubSetup() {
|
|
1336
|
+
this.hubSetupInit ??= (async () => {
|
|
1337
|
+
const { createHubWebInitializer } = await import("./hub/init/web.js");
|
|
1338
|
+
if (this.shuttingDown)
|
|
1339
|
+
throw Error("Fleet is stopping");
|
|
1340
|
+
const controller = createHubWebInitializer({ home: this.dataDir, readConfig: () => this.getRawFleetConfig(),
|
|
1341
|
+
writeFleet: patches => this.saveFleetConfig(patches), committed: () => this.applyHubSwitches() });
|
|
1342
|
+
this.hubSetupController = controller;
|
|
1343
|
+
return controller;
|
|
1344
|
+
})();
|
|
1345
|
+
try {
|
|
1346
|
+
return await this.hubSetupInit;
|
|
1347
|
+
}
|
|
1348
|
+
catch (error) {
|
|
1349
|
+
this.hubSetupInit = null;
|
|
1350
|
+
throw error;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
/** The member's company sign-in controller; separate from host-owned Hub initialization. */
|
|
1354
|
+
companyJoinController = null;
|
|
1355
|
+
companyJoinInit = null;
|
|
1356
|
+
companyObservedMembership = null;
|
|
1357
|
+
companyMembershipWrite = false;
|
|
1358
|
+
hubCompanySession(req) {
|
|
1359
|
+
const epoch = this.webAuthorityState().epoch, token = this.webToken, sessions = this.webSessions, generation = this.settingsGeneration;
|
|
1360
|
+
return companyJoinSession(req, { token, sessions, config: this.fleetConfig, epoch, current: () => !this.shuttingDown
|
|
1361
|
+
&& generation === this.settingsGeneration && token === this.webToken && sessions === this.webSessions && epoch === this.webAuthorityState().epoch });
|
|
1362
|
+
}
|
|
1363
|
+
async hubCompanyJoin() {
|
|
1364
|
+
const incarnation = this.settingsGeneration;
|
|
1365
|
+
const initialization = this.companyJoinInit ??= (async () => {
|
|
1366
|
+
const { CompanyJoinController } = await import("./hub/join/local.js");
|
|
1367
|
+
const { currentBinding } = await import("./hub/member/pairing-api.js");
|
|
1368
|
+
this.hubMemberBinding = currentBinding;
|
|
1369
|
+
if (this.shuttingDown || incarnation !== this.settingsGeneration)
|
|
1370
|
+
throw Error("Fleet is stopping");
|
|
1371
|
+
const controller = new CompanyJoinController({ home: this.dataDir,
|
|
1372
|
+
snapshot: () => {
|
|
1373
|
+
const state = join(this.dataDir, "hub-member/state.json");
|
|
1374
|
+
return { membership: this.rawFleetConfig?.hub_member?.enabled === true,
|
|
1375
|
+
binding: existsSync(state) ? createHash("sha256").update(readFileSync(state)).digest("hex") : null };
|
|
1376
|
+
},
|
|
1377
|
+
enableMembership: (current, accept) => {
|
|
1378
|
+
if (!current() || !this.configPath || !this.fleetConfig)
|
|
1379
|
+
throw Error("Join operation changed");
|
|
1380
|
+
this.companyMembershipWrite = true;
|
|
1381
|
+
try {
|
|
1382
|
+
this.saveFleetConfig([{ path: ["hub_member", "enabled"], value: true }]);
|
|
1383
|
+
// Strict durability for the joined profile+journal, including this internally enabled switch.
|
|
1384
|
+
const fd = openSync(this.configPath, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
|
1385
|
+
try {
|
|
1386
|
+
fsyncSync(fd);
|
|
1387
|
+
}
|
|
1388
|
+
finally {
|
|
1389
|
+
closeSync(fd);
|
|
1390
|
+
}
|
|
1391
|
+
const parent = openSync(dirname(this.configPath), fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
|
1392
|
+
try {
|
|
1393
|
+
fsyncSync(parent);
|
|
1394
|
+
}
|
|
1395
|
+
finally {
|
|
1396
|
+
closeSync(parent);
|
|
1397
|
+
}
|
|
1398
|
+
accept();
|
|
1399
|
+
}
|
|
1400
|
+
finally {
|
|
1401
|
+
this.companyMembershipWrite = false;
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
activate: () => { void this.applyHubSwitches().then(() => this.hubRuntime?.refresh()).catch(() => { }); },
|
|
1405
|
+
link: () => this.hubMemberLink === "online" ? "online" : "offline", });
|
|
1406
|
+
this.companyJoinController = controller;
|
|
1407
|
+
return controller;
|
|
1408
|
+
})();
|
|
1409
|
+
try {
|
|
1410
|
+
return await initialization;
|
|
1411
|
+
}
|
|
1412
|
+
catch (error) {
|
|
1413
|
+
if (this.companyJoinInit === initialization)
|
|
1414
|
+
this.companyJoinInit = null;
|
|
1415
|
+
throw error;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
invalidateHubCompanyJoin() { this.companyJoinController?.invalidate(); }
|
|
1319
1419
|
hubMemberPairingApi = null;
|
|
1420
|
+
hubPairingNotices = null;
|
|
1320
1421
|
hubMemberPairing() { return this.hubMemberPairingApi; }
|
|
1321
1422
|
attachHubMemberPairing(api) { this.hubMemberPairingApi = api; }
|
|
1322
1423
|
generalLocationFlights = new Map();
|
|
@@ -1776,6 +1877,12 @@ export class FleetManager {
|
|
|
1776
1877
|
*/
|
|
1777
1878
|
/** S-51: the Hub switches follow the configuration in force (load, save, reload rollback), like the runtime ones. */
|
|
1778
1879
|
observeHubSwitches() {
|
|
1880
|
+
const enabled = this.rawFleetConfig?.hub_member?.enabled === true;
|
|
1881
|
+
if (this.companyObservedMembership !== null && enabled !== this.companyObservedMembership) {
|
|
1882
|
+
if (!this.companyMembershipWrite)
|
|
1883
|
+
this.companyJoinController?.invalidate();
|
|
1884
|
+
}
|
|
1885
|
+
this.companyObservedMembership = enabled;
|
|
1779
1886
|
this.observeHubAgentIncarnations();
|
|
1780
1887
|
if (!this.hubEffectsReady || this.hubEffectsScheduled || this.shuttingDown)
|
|
1781
1888
|
return;
|
|
@@ -1795,6 +1902,16 @@ export class FleetManager {
|
|
|
1795
1902
|
if (this.shuttingDown || !this.hubEffectsReady)
|
|
1796
1903
|
return; // Stop owns it now (fenced in stopAll, closed in doStopAll)
|
|
1797
1904
|
await this.observeHubMemberPairing(raw?.hub_member?.enabled === true);
|
|
1905
|
+
// M-2682: an interrupted sealed-settings commit is finished (or rolled back) before the Hub mounts its pair. A refusal
|
|
1906
|
+
// overwrites nothing; the mount then holds on the mismatch, visibly, until the files are put right.
|
|
1907
|
+
if (this.hubSettingsWriter?.pending()) {
|
|
1908
|
+
try {
|
|
1909
|
+
this.hubSettingsWriter.recover();
|
|
1910
|
+
}
|
|
1911
|
+
catch (err) {
|
|
1912
|
+
this.logger.warn({ err: err?.message ?? String(err) }, "Hub settings recovery refused");
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1798
1915
|
const current = this.rawFleetConfig;
|
|
1799
1916
|
await runtime.apply({ hub: current?.hub, hub_member: current?.hub_member });
|
|
1800
1917
|
}
|
|
@@ -1802,12 +1919,22 @@ export class FleetManager {
|
|
|
1802
1919
|
this.logger.warn({ err: err?.message ?? String(err) }, "Hub switches could not be applied");
|
|
1803
1920
|
}
|
|
1804
1921
|
}
|
|
1922
|
+
/** M-2682: the one writer for sealed Hub settings, created with the Hub runtime. */
|
|
1923
|
+
hubSettingsWriter = null;
|
|
1805
1924
|
/** Single flight: one import, one runtime, assigned once; every caller (and Stop) gets that same runtime. */
|
|
1806
1925
|
hubRuntimeCreated() {
|
|
1807
1926
|
this.hubRuntimeInit ??= (async () => {
|
|
1808
1927
|
const { HubRuntime } = await import("./hub/runtime.js");
|
|
1928
|
+
// M-2682: the one writer for sealed Hub settings (a rename from Hub Administration). It saves hub.* through this
|
|
1929
|
+
// fleet's own synchronous writer, so nothing else here runs between its commit point and the new pair in force.
|
|
1930
|
+
const { createHubSettingsWriter } = await import("./hub/settings-commit.js");
|
|
1931
|
+
this.hubSettingsWriter ??= createHubSettingsWriter({ home: this.dataDir,
|
|
1932
|
+
readHub: () => this.rawFleetConfig?.hub,
|
|
1933
|
+
saveHub: patches => this.saveFleetConfig(patches) });
|
|
1809
1934
|
const runtime = new HubRuntime({
|
|
1810
1935
|
home: this.dataDir,
|
|
1936
|
+
settingsWriter: this.hubSettingsWriter,
|
|
1937
|
+
version: agendVersion(),
|
|
1811
1938
|
log: (level, message, meta) => this.logger[level](meta ?? {}, message),
|
|
1812
1939
|
onHoldsChanged: holds => { this.hubHolds = holds; this.needsYou?.poke(); },
|
|
1813
1940
|
// S-51 PR 2b: the fleet's side of a Hub membership (pairing binding, local agents, attachment points).
|
|
@@ -1828,6 +1955,7 @@ export class FleetManager {
|
|
|
1828
1955
|
},
|
|
1829
1956
|
attachExposures: api => this.attachHubMemberExposures(api),
|
|
1830
1957
|
attachAttention: read => this.attachHubExecutionAttention(read),
|
|
1958
|
+
attachPairingNotices: read => { this.hubPairingNotices = read; },
|
|
1831
1959
|
pokeAttention: () => this.needsYou?.poke(),
|
|
1832
1960
|
linkState: state => { this.hubMemberLink = state; },
|
|
1833
1961
|
},
|
|
@@ -1858,6 +1986,7 @@ export class FleetManager {
|
|
|
1858
1986
|
this.hubMemberBinding = currentBinding;
|
|
1859
1987
|
this.attachHubMemberPairing(createHubMemberPairingApi({
|
|
1860
1988
|
home: this.dataDir,
|
|
1989
|
+
notices: () => this.hubPairingNotices?.() ?? [],
|
|
1861
1990
|
enabled: () => this.rawFleetConfig?.hub_member?.enabled === true,
|
|
1862
1991
|
link: () => (this.hubMemberLink === "online" ? "online" : "offline"),
|
|
1863
1992
|
hold: () => (this.hubMemberLink === "revoked" ? "revoked" : null),
|
|
@@ -2132,6 +2261,10 @@ export class FleetManager {
|
|
|
2132
2261
|
}
|
|
2133
2262
|
hubBrowserCertificate() { return this.hubRuntime?.browserCertificateSettings() ?? null; }
|
|
2134
2263
|
hubRetention() { return this.hubRuntime?.retentionSettings() ?? null; }
|
|
2264
|
+
/** M-2682: an unfinished sealed-settings commit; Hub setting saves wait until recover() has run. */
|
|
2265
|
+
hubSettingsBusy() { return this.hubSettingsWriter?.pending() === true || this.hubSetupController?.pending() === true; }
|
|
2266
|
+
/** #3298 S-89: this fleet's own Hub offers group permissions (the page mark that shows Settings → Hub's Group permissions row). */
|
|
2267
|
+
hubGroupPermissions() { return this.hubRuntime?.groupPermissionsAvailable() ?? false; }
|
|
2135
2268
|
observeRuntimeSwitches() {
|
|
2136
2269
|
setConfiguredRuntimeSwitches(this.fleetConfig?.runtimes);
|
|
2137
2270
|
if (!this.runtimeEffects || this.runtimeEffectsScheduled)
|
|
@@ -3156,7 +3289,7 @@ export class FleetManager {
|
|
|
3156
3289
|
if (auth.kind !== "ok" || !current())
|
|
3157
3290
|
return null;
|
|
3158
3291
|
const record = auth.session, sessions = this.webSessions, exposure = gatewayRequestContext(req);
|
|
3159
|
-
return { id: record.idHash, label: record.label, source: exposure ? "public_link" : "web_session",
|
|
3292
|
+
return { localSession: this.hubCompanySession(req) ?? undefined, id: record.idHash, label: record.label, source: exposure ? "public_link" : "web_session",
|
|
3160
3293
|
localAdmin: () => record.tier === "admin" && record.surface === "local" && !exposure,
|
|
3161
3294
|
current: () => current() && sessions === this.webSessions && !!this.webToken
|
|
3162
3295
|
&& sessions.isCurrent(record, tokenEpoch(this.webToken)) && (!exposure || exposure.isCurrent()) };
|
|
@@ -3164,6 +3297,7 @@ export class FleetManager {
|
|
|
3164
3297
|
selfConfirm: (req, id) => this.settingsSelfConfirmation(store, req, id),
|
|
3165
3298
|
totp: { state: (req, id) => this.settingsTotpState(store, req, id), confirm: (req, id, code, digest) => this.settingsTotpConfirm(store, req, id, code, digest) },
|
|
3166
3299
|
directAgentCreation: true,
|
|
3300
|
+
directCompanyJoin: true,
|
|
3167
3301
|
job: async (id) => {
|
|
3168
3302
|
const settlement = this.settingsJobSettlements.get(id);
|
|
3169
3303
|
if (!settlement)
|
|
@@ -5689,7 +5823,7 @@ export class FleetManager {
|
|
|
5689
5823
|
}
|
|
5690
5824
|
const origin = `slash /update by ${adapterId}:${data.userId}`;
|
|
5691
5825
|
recordInternalRequest(this.dataDir, "update", origin);
|
|
5692
|
-
const launch = await resolveUpdateLaunch(installed.agend);
|
|
5826
|
+
const launch = await resolveUpdateLaunch(installed.agend, undefined, installed.npmDir);
|
|
5693
5827
|
if (!launch.ok) {
|
|
5694
5828
|
this.failUpdateProgress(`${t("update.failure.shell")} ${t("update.failure.independent", launch.reason)}`);
|
|
5695
5829
|
return;
|
|
@@ -8356,6 +8490,22 @@ export class FleetManager {
|
|
|
8356
8490
|
* Stopped/paused ClassicBot entries count too; their workspace is exactly
|
|
8357
8491
|
* the one startClassicInstance builds, not this FleetManager's dataDir.
|
|
8358
8492
|
*/
|
|
8493
|
+
/** Take the startup snapshot of every active decision (text cut to 200 characters); see activeDecisions. */
|
|
8494
|
+
snapshotActiveDecisions() {
|
|
8495
|
+
try {
|
|
8496
|
+
const decisions = this.scheduler?.db.listAllActiveDecisions() ?? [];
|
|
8497
|
+
this.decisionSnapshot = decisions.map(d => ({ title: d.title, content: (d.content ?? "").slice(0, 200), scope: d.scope, project_root: d.project_root, ...(d.team ? { team: d.team } : {}) }));
|
|
8498
|
+
if (decisions.length > 0)
|
|
8499
|
+
this.logger.info({ count: decisions.length }, "Active decisions snapshotted for instance instructions");
|
|
8500
|
+
}
|
|
8501
|
+
catch (err) {
|
|
8502
|
+
this.logger.debug({ err }, "Decision injection skipped (no decisions db or query failed)");
|
|
8503
|
+
}
|
|
8504
|
+
}
|
|
8505
|
+
/** The startup snapshot of active decisions, for a daemon's Active Decisions (it selects and caps its own). */
|
|
8506
|
+
activeDecisions() {
|
|
8507
|
+
return this.decisionSnapshot;
|
|
8508
|
+
}
|
|
8359
8509
|
kiroPeerWorkingDirectories(name) {
|
|
8360
8510
|
if (!this.fleetConfig || !this.classicChannels)
|
|
8361
8511
|
throw new Error("Kiro peer configuration is not loaded");
|
|
@@ -10110,35 +10260,64 @@ export class FleetManager {
|
|
|
10110
10260
|
...(threadId ? { threadId } : {}),
|
|
10111
10261
|
messageId,
|
|
10112
10262
|
};
|
|
10263
|
+
return this.launchTrackedFullRestart(target, text => this.reportFullRestartFailure(adapter, chatId, threadId, messageId, text), () => this.startUpdateProgressMonitor(adapter));
|
|
10264
|
+
}
|
|
10265
|
+
/**
|
|
10266
|
+
* S-92: the same tracked reload for a web-only fleet's Settings restart — no chat message to carry its progress: the
|
|
10267
|
+
* marker names the web (WEB_RESTART_TARGET), a refusal is a fleet Notice, and the next fleet says it is back as one.
|
|
10268
|
+
*/
|
|
10269
|
+
async requestWebFullRestart(onLateFailure) {
|
|
10270
|
+
const target = { surface: "web", adapterId: WEB_RESTART_TARGET, chatId: WEB_RESTART_TARGET, messageId: `settings-${Date.now()}` };
|
|
10271
|
+
const say = async (text) => { this.recordWebNotice("fleet", text); };
|
|
10272
|
+
// No progress monitor reads the marker for the web: a helper that fails after its launch is said here, and settled.
|
|
10273
|
+
return this.launchTrackedFullRestart(target, say, null, (detail) => {
|
|
10274
|
+
void say(t("restart.full_launch_failed"));
|
|
10275
|
+
onLateFailure?.(detail);
|
|
10276
|
+
});
|
|
10277
|
+
}
|
|
10278
|
+
/**
|
|
10279
|
+
* S-92: a fleet (with no chat connection) that comes up from a web-only Settings restart says it is back as a fleet
|
|
10280
|
+
* Notice — the restart was announced as one. Anything else (a chat restart, an update, a plain boot): nothing here.
|
|
10281
|
+
*/
|
|
10282
|
+
async announceWebRestartDone(pending) {
|
|
10283
|
+
if (!pending || updateProgressOperation(pending.progress) !== "full-restart" || pending.progress.target.surface !== "web")
|
|
10284
|
+
return false;
|
|
10285
|
+
const { createRequire } = await import("node:module");
|
|
10286
|
+
const version = createRequire(import.meta.url)("../package.json").version ?? "unknown";
|
|
10287
|
+
return this.recordWebNotice("fleet", t("restart.settings_done", version));
|
|
10288
|
+
}
|
|
10289
|
+
async launchTrackedFullRestart(target, fail, startMonitor,
|
|
10290
|
+
/** After the launch: the helper failed before the hand-off (with no progress monitor to say so). */
|
|
10291
|
+
lateFailure) {
|
|
10113
10292
|
// This check is synchronous with the marker write below. A second command
|
|
10114
10293
|
// cannot slip through between them on Node's event loop and replace the
|
|
10115
10294
|
// first command's delivery target or launch a competing restart helper.
|
|
10116
10295
|
if (this.shuttingDown || isUpdateInProgress(this.dataDir)) {
|
|
10117
|
-
this.logger.warn({ adapterId:
|
|
10118
|
-
await
|
|
10296
|
+
this.logger.warn({ adapterId: target.adapterId }, "Full restart refused because another planned restart is active");
|
|
10297
|
+
await fail(t("restart.full_busy"));
|
|
10119
10298
|
return false;
|
|
10120
10299
|
}
|
|
10121
10300
|
if (!persistFullRestartProgress(this.dataDir, target)) {
|
|
10122
|
-
this.logger.error({ adapterId:
|
|
10123
|
-
await
|
|
10301
|
+
this.logger.error({ adapterId: target.adapterId }, "Full restart marker could not be persisted — reload refused");
|
|
10302
|
+
await fail(t("restart.full_launch_failed"));
|
|
10124
10303
|
return false;
|
|
10125
10304
|
}
|
|
10126
10305
|
const ownedMarker = readUpdateProgress(this.dataDir);
|
|
10127
10306
|
if (!ownedMarker) {
|
|
10128
|
-
this.logger.error({ adapterId:
|
|
10129
|
-
await
|
|
10307
|
+
this.logger.error({ adapterId: target.adapterId }, "Full restart marker disappeared after persistence — reload refused");
|
|
10308
|
+
await fail(t("restart.full_launch_failed"));
|
|
10130
10309
|
return false;
|
|
10131
10310
|
}
|
|
10132
10311
|
this.lastUpdateProgressText = null;
|
|
10133
|
-
|
|
10312
|
+
startMonitor?.();
|
|
10134
10313
|
await this.waitForFullRestartIdleGrace();
|
|
10135
10314
|
// An update can begin while the idle wait yields. Never launch a second
|
|
10136
10315
|
// process replacement against a marker we no longer own.
|
|
10137
10316
|
if (this.shuttingDown || !this.isOwnedFullRestartMarker(ownedMarker.startedAt, target)) {
|
|
10138
|
-
this.logger.warn({ adapterId:
|
|
10317
|
+
this.logger.warn({ adapterId: target.adapterId }, "Full restart superseded during idle wait — reload refused");
|
|
10139
10318
|
if (this.isOwnedFullRestartMarker(ownedMarker.startedAt, target))
|
|
10140
10319
|
clearUpdateMarker(this.dataDir);
|
|
10141
|
-
await
|
|
10320
|
+
await fail(t("restart.full_busy"));
|
|
10142
10321
|
return false;
|
|
10143
10322
|
}
|
|
10144
10323
|
let helper;
|
|
@@ -10149,7 +10328,7 @@ export class FleetManager {
|
|
|
10149
10328
|
this.logger.error({ err }, "Full restart helper failed to spawn — reload refused");
|
|
10150
10329
|
if (this.isOwnedFullRestartMarker(ownedMarker.startedAt, target))
|
|
10151
10330
|
clearUpdateMarker(this.dataDir);
|
|
10152
|
-
await
|
|
10331
|
+
await fail(t("restart.full_launch_failed"));
|
|
10153
10332
|
return false;
|
|
10154
10333
|
}
|
|
10155
10334
|
void helper.completion.then(result => {
|
|
@@ -10167,6 +10346,7 @@ export class FleetManager {
|
|
|
10167
10346
|
: `reload helper exited before process hand-off (code ${result.code ?? "null"}, signal ${result.signal ?? "none"})`;
|
|
10168
10347
|
this.logger.error({ result }, "Full restart helper exited before the fleet began shutting down");
|
|
10169
10348
|
setUpdateProgressStage(this.dataDir, "failed", { error: detail });
|
|
10349
|
+
lateFailure?.(detail);
|
|
10170
10350
|
});
|
|
10171
10351
|
return true;
|
|
10172
10352
|
}
|
|
@@ -10811,20 +10991,12 @@ export class FleetManager {
|
|
|
10811
10991
|
this.logger.warn({ err }, "Failed to send daily tip");
|
|
10812
10992
|
}));
|
|
10813
10993
|
this.dailyTipScheduler.start();
|
|
10814
|
-
//
|
|
10815
|
-
//
|
|
10816
|
-
//
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
const capped = decisions.slice(0, 20).map(d => ({ title: d.title, content: (d.content ?? "").slice(0, 200), scope: d.scope, project_root: d.project_root }));
|
|
10821
|
-
process.env.AGEND_DECISIONS = JSON.stringify(capped);
|
|
10822
|
-
this.logger.info({ count: decisions.length, injected: capped.length }, "Injected active decisions into env");
|
|
10823
|
-
}
|
|
10824
|
-
}
|
|
10825
|
-
catch (err) {
|
|
10826
|
-
this.logger.debug({ err }, "Decision injection skipped (no decisions db or query failed)");
|
|
10827
|
-
}
|
|
10994
|
+
// Active decisions for each instance's instructions, snapshotted at startup — new decisions via post_decision are
|
|
10995
|
+
// available through list_decisions but not auto-injected until restart. The whole active set is kept here (each
|
|
10996
|
+
// entry's text cut to 200 characters) and handed to each daemon at spawn (activeDecisions): the daemon selects
|
|
10997
|
+
// its own — fleet, its teams, its directory — and only then applies its caps, so other teams' or directories'
|
|
10998
|
+
// rows can never crowd an instance's own out (#3421 review). Nothing unbounded goes into process.env.
|
|
10999
|
+
this.snapshotActiveDecisions();
|
|
10828
11000
|
}
|
|
10829
11001
|
// Phase 1: Start general instances first and wait for them
|
|
10830
11002
|
// M-2457: a held fleet starts no agent (the hold's Needs-you line says why and what to do).
|
|
@@ -10889,7 +11061,7 @@ export class FleetManager {
|
|
|
10889
11061
|
this.reportClassicUnrecoverableIds();
|
|
10890
11062
|
})();
|
|
10891
11063
|
progressStart = adapterStartup.then(() => {
|
|
10892
|
-
if (pendingUpdateProgress) {
|
|
11064
|
+
if (pendingUpdateProgress && pendingUpdateProgress.progress.target.surface !== "web") {
|
|
10893
11065
|
const saved = pendingUpdateProgress.progress.target;
|
|
10894
11066
|
const target = {
|
|
10895
11067
|
adapter: this.adapters.get(saved.adapterId),
|
|
@@ -11073,6 +11245,9 @@ export class FleetManager {
|
|
|
11073
11245
|
// #named-link-ttl: a named link with auto_open comes back now — after the web listener and the chat connections.
|
|
11074
11246
|
this.startPublicLinkAutoOpen();
|
|
11075
11247
|
}
|
|
11248
|
+
else {
|
|
11249
|
+
await this.announceWebRestartDone(pendingUpdateProgress);
|
|
11250
|
+
}
|
|
11076
11251
|
// #3008: connections from outside were on when the fleet stopped: the link opens again (its address is new for a
|
|
11077
11252
|
// quick link — Settings shows it on this computer).
|
|
11078
11253
|
if (this.outsideOn())
|
|
@@ -14396,6 +14571,11 @@ export class FleetManager {
|
|
|
14396
14571
|
let result;
|
|
14397
14572
|
switch (msg.type) {
|
|
14398
14573
|
case "fleet_decision_create": {
|
|
14574
|
+
const scoped = this.decisionScopeFor(instanceName, payload.scope, payload.team);
|
|
14575
|
+
if ("error" in scoped) {
|
|
14576
|
+
ipc.send({ type: "fleet_decision_response", fleetRequestId, error: scoped.error });
|
|
14577
|
+
return;
|
|
14578
|
+
}
|
|
14399
14579
|
const supersedes = this.decisionSupersedes("ipc-typed", instanceName, payload.supersedes);
|
|
14400
14580
|
if ("error" in supersedes) {
|
|
14401
14581
|
ipc.send({ type: "fleet_decision_response", fleetRequestId, error: supersedes.error });
|
|
@@ -14405,7 +14585,9 @@ export class FleetManager {
|
|
|
14405
14585
|
db.pruneExpiredDecisions();
|
|
14406
14586
|
result = db.createDecision({
|
|
14407
14587
|
project_root: projectRoot,
|
|
14408
|
-
scope:
|
|
14588
|
+
scope: scoped.scope,
|
|
14589
|
+
team: scoped.team,
|
|
14590
|
+
poster_teams: scoped.teams,
|
|
14409
14591
|
title: payload.title,
|
|
14410
14592
|
content: payload.content,
|
|
14411
14593
|
tags: payload.tags,
|
|
@@ -14421,10 +14603,16 @@ export class FleetManager {
|
|
|
14421
14603
|
result = decisionListAnswer(db.listDecisions(projectRoot, {
|
|
14422
14604
|
includeArchived: payload.include_archived,
|
|
14423
14605
|
tags: payload.tags,
|
|
14606
|
+
teams: instanceTeams(this.fleetConfig?.teams, instanceName),
|
|
14424
14607
|
}), { id: payload.id, full: payload.full });
|
|
14425
14608
|
break;
|
|
14426
14609
|
case "fleet_decision_update": {
|
|
14427
14610
|
const id = payload.id;
|
|
14611
|
+
const hidden = this.decisionHiddenFrom(instanceName, id);
|
|
14612
|
+
if (hidden) {
|
|
14613
|
+
ipc.send({ type: "fleet_decision_response", fleetRequestId, error: hidden });
|
|
14614
|
+
return;
|
|
14615
|
+
}
|
|
14428
14616
|
if (payload.archive) {
|
|
14429
14617
|
db.archiveDecision(id);
|
|
14430
14618
|
result = { archived: true, id };
|
|
@@ -14603,6 +14791,47 @@ export class FleetManager {
|
|
|
14603
14791
|
return { error: `Superseding a decision needs update_decision. ${permitted.message}` };
|
|
14604
14792
|
return { id: value };
|
|
14605
14793
|
}
|
|
14794
|
+
/**
|
|
14795
|
+
* The scope (and team) a new decision gets. Team membership is read from fleet.yaml now. Omitted scope: the poster's
|
|
14796
|
+
* team when they are in exactly one, project (this exact directory) when they are in none; in several, they choose.
|
|
14797
|
+
* A team decision goes only to a team the poster is in.
|
|
14798
|
+
*/
|
|
14799
|
+
decisionScopeFor(instance, scope, team) {
|
|
14800
|
+
const teams = instanceTeams(this.fleetConfig?.teams, instance);
|
|
14801
|
+
const named = typeof team === "string" && team.trim() ? team.trim() : undefined;
|
|
14802
|
+
if (scope !== undefined && scope !== null && scope !== "project" && scope !== "team" && scope !== "fleet") {
|
|
14803
|
+
return { error: `scope must be "project", "team" or "fleet"` };
|
|
14804
|
+
}
|
|
14805
|
+
if (scope === "project" || scope === "fleet") {
|
|
14806
|
+
return named ? { error: `team goes with scope "team", not "${scope}"` } : { scope, teams };
|
|
14807
|
+
}
|
|
14808
|
+
if (named) {
|
|
14809
|
+
if (!teams.includes(named)) {
|
|
14810
|
+
return { error: teams.length ? `You are not in team "${named}". Your teams: ${teams.join(", ")}` : `You are not in team "${named}" (you are in no team)` };
|
|
14811
|
+
}
|
|
14812
|
+
return { scope: "team", team: named, teams };
|
|
14813
|
+
}
|
|
14814
|
+
if (teams.length === 1)
|
|
14815
|
+
return { scope: "team", team: teams[0], teams };
|
|
14816
|
+
if (teams.length > 1)
|
|
14817
|
+
return { error: `You are in several teams (${teams.join(", ")}): name one with team, or use scope "project" or "fleet"` };
|
|
14818
|
+
if (scope === "team")
|
|
14819
|
+
return { error: `You are in no team: use scope "project" (this directory) or "fleet"` };
|
|
14820
|
+
return { scope: "project", teams };
|
|
14821
|
+
}
|
|
14822
|
+
/**
|
|
14823
|
+
* #3421 review: a team decision is only for its team's current members — reading it back through an update (even an
|
|
14824
|
+
* empty one) or archiving it is refused to anyone else, exactly as list/get and supersede are. The refusal names it
|
|
14825
|
+
* "not found", as for an id that does not exist, and changes nothing. Project and fleet decisions: as before.
|
|
14826
|
+
*/
|
|
14827
|
+
decisionHiddenFrom(instance, id) {
|
|
14828
|
+
if (typeof id !== "string" || !this.scheduler)
|
|
14829
|
+
return null;
|
|
14830
|
+
const d = this.scheduler.db.getDecision(id);
|
|
14831
|
+
if (!d || d.scope !== "team")
|
|
14832
|
+
return null;
|
|
14833
|
+
return d.team && instanceTeams(this.fleetConfig?.teams, instance).includes(d.team) ? null : `Decision "${id}" not found`;
|
|
14834
|
+
}
|
|
14606
14835
|
async handleDecisionCrudHttp(instance, op, args) {
|
|
14607
14836
|
if (!this.scheduler)
|
|
14608
14837
|
return { error: "Scheduler not available" };
|
|
@@ -14617,14 +14846,18 @@ export class FleetManager {
|
|
|
14617
14846
|
const content = asStr(args.content);
|
|
14618
14847
|
if (!title || !content)
|
|
14619
14848
|
return { error: "title and content are required" };
|
|
14620
|
-
const
|
|
14849
|
+
const scoped = this.decisionScopeFor(instance, args.scope, args.team);
|
|
14850
|
+
if ("error" in scoped)
|
|
14851
|
+
return { error: scoped.error };
|
|
14621
14852
|
const supersedes = this.decisionSupersedes("agent-endpoint", instance, args.supersedes);
|
|
14622
14853
|
if ("error" in supersedes)
|
|
14623
14854
|
return { error: supersedes.error };
|
|
14624
14855
|
try {
|
|
14625
14856
|
return db.createDecision({
|
|
14626
14857
|
project_root: projectRoot,
|
|
14627
|
-
scope,
|
|
14858
|
+
scope: scoped.scope,
|
|
14859
|
+
team: scoped.team,
|
|
14860
|
+
poster_teams: scoped.teams,
|
|
14628
14861
|
title,
|
|
14629
14862
|
content,
|
|
14630
14863
|
tags: asStrArr(args.tags),
|
|
@@ -14646,11 +14879,15 @@ export class FleetManager {
|
|
|
14646
14879
|
return decisionListAnswer(db.listDecisions(projectRoot, {
|
|
14647
14880
|
includeArchived: args.includeArchived === true || args.include_archived === true,
|
|
14648
14881
|
tags: asStrArr(args.tags),
|
|
14882
|
+
teams: instanceTeams(this.fleetConfig?.teams, instance),
|
|
14649
14883
|
}), { id: op === "get" ? asStr(args.id) ?? "" : args.id, full: args.full });
|
|
14650
14884
|
case "update": {
|
|
14651
14885
|
const id = asStr(args.id);
|
|
14652
14886
|
if (!id)
|
|
14653
14887
|
return { error: "id is required" };
|
|
14888
|
+
const hidden = this.decisionHiddenFrom(instance, id);
|
|
14889
|
+
if (hidden)
|
|
14890
|
+
return { error: hidden };
|
|
14654
14891
|
return db.updateDecision(id, {
|
|
14655
14892
|
content: asStr(args.content),
|
|
14656
14893
|
tags: asStrArr(args.tags),
|
|
@@ -15295,6 +15532,9 @@ export class FleetManager {
|
|
|
15295
15532
|
* non-identity instance leaves are canonicalized to inheritance afterward.
|
|
15296
15533
|
*/
|
|
15297
15534
|
saveFleetConfig(explicitPatches = []) {
|
|
15535
|
+
if (!this.companyMembershipWrite && explicitPatches.some(p => p.path[0] === "hub_member"
|
|
15536
|
+
&& (p.path[1] === "enabled" ? p.value !== true || p.remove : p.path.length === 1)))
|
|
15537
|
+
this.invalidateHubCompanyJoin();
|
|
15298
15538
|
this.publicWebLink?.refresh();
|
|
15299
15539
|
this.enforceGuestSwitch(); // #1920: a Settings save turning guests off ends their sessions
|
|
15300
15540
|
this.observeWebAuthority(); // #2453 review: so is a web-authority switch (off is always seen)
|
|
@@ -17331,6 +17571,17 @@ export class FleetManager {
|
|
|
17331
17571
|
this.emitSseEvent("notice", { notice, unread: store.unread() });
|
|
17332
17572
|
return true;
|
|
17333
17573
|
}
|
|
17574
|
+
/** #3373 review P2: recordWebNotice for a notice that must be on disk first — true only once it was written. */
|
|
17575
|
+
recordWebNoticeDurable(kind, text) {
|
|
17576
|
+
if (!this.webOnlyPromptPlace())
|
|
17577
|
+
return false;
|
|
17578
|
+
const store = this.webNoticeStore();
|
|
17579
|
+
const notice = store?.addDurable({ kind, text: stripPlaceRefs(text) }) ?? null;
|
|
17580
|
+
if (!notice)
|
|
17581
|
+
return false;
|
|
17582
|
+
this.emitSseEvent("notice", { notice, unread: store.unread() });
|
|
17583
|
+
return true;
|
|
17584
|
+
}
|
|
17334
17585
|
static FLEET_ERROR_THROTTLE_MS = 10 * 60_000;
|
|
17335
17586
|
fleetErrorNotices = new Map();
|
|
17336
17587
|
/**
|
|
@@ -20742,8 +20993,10 @@ export class FleetManager {
|
|
|
20742
20993
|
}
|
|
20743
20994
|
catch { /* safe metadata only */ }
|
|
20744
20995
|
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
20745
|
-
if (event.phase === "done")
|
|
20996
|
+
if (event.phase === "done") {
|
|
20746
20997
|
this.forgetSignInIdentities(); // a sign-in may be a different account now
|
|
20998
|
+
this.keepAliveAfterSignIn(event.backend, null); // its file changed, whoever is watching: a "needs sign-in" left from before is no longer the answer
|
|
20999
|
+
}
|
|
20747
21000
|
this.needsYou?.poke();
|
|
20748
21001
|
if (!this.browserSignInOwnerCurrent(owner))
|
|
20749
21002
|
return;
|
|
@@ -20759,6 +21012,51 @@ export class FleetManager {
|
|
|
20759
21012
|
},
|
|
20760
21013
|
});
|
|
20761
21014
|
}
|
|
21015
|
+
profileSignInsInstance = null;
|
|
21016
|
+
/**
|
|
21017
|
+
* #3212: a NAMED account's sign-in on this host from Settings → Accounts — #2599's StructuredSignIn (press Sign in, open the page, paste the code), pointed at
|
|
21018
|
+
* that profile's own folder (`CLAUDE_CONFIG_DIR`), under the host's login window like every other credential writer. Not the default account's checklist.
|
|
21019
|
+
*/
|
|
21020
|
+
get profileSignIns() {
|
|
21021
|
+
return this.profileSignInsInstance ??= new ProfileSignIns({
|
|
21022
|
+
lock: this.loginWindow,
|
|
21023
|
+
current: owner => this.browserSignInOwnerCurrent(owner),
|
|
21024
|
+
installed: backend => this.isCliInstalledOffLoop(backend),
|
|
21025
|
+
known: (backend, profile) => accountFolderExists(this.dataDir, backend, profile) ? "exists" : this.configuredProfileNames(backend).has(profile) ? "configured" : "unknown",
|
|
21026
|
+
add: (backend, profile) => {
|
|
21027
|
+
const result = addAccountProfile(this.dataDir, backend, profile, this.configuredProfileNames(backend));
|
|
21028
|
+
if (result.ok)
|
|
21029
|
+
this.logger.info({ backend, profile }, "Credential profile added by the first sign-in of an account the configuration names");
|
|
21030
|
+
return result.ok;
|
|
21031
|
+
},
|
|
21032
|
+
checkAuth: (backend, profile) => {
|
|
21033
|
+
const env = credentialProfileEnv(this.dataDir, backend, profile);
|
|
21034
|
+
return env ? checkAuthStatus(LOGIN_FLOWS[backend].authCheck, env) : Promise.resolve("unknown");
|
|
21035
|
+
},
|
|
21036
|
+
transport: target => createStructuredSignInTransport({ backend: target.backend, dataDir: this.dataDir }),
|
|
21037
|
+
changed: (event, owner, launched) => {
|
|
21038
|
+
try {
|
|
21039
|
+
this.eventLog?.insert("login", "browser_profile_signin", event);
|
|
21040
|
+
}
|
|
21041
|
+
catch { /* safe metadata only */ }
|
|
21042
|
+
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
21043
|
+
if (event.phase === "done") {
|
|
21044
|
+
this.forgetSignInIdentities(); // a sign-in may be a different account now
|
|
21045
|
+
this.keepAliveAfterSignIn(event.backend, event.profile);
|
|
21046
|
+
}
|
|
21047
|
+
this.needsYou?.poke();
|
|
21048
|
+
if (!this.browserSignInOwnerCurrent(owner))
|
|
21049
|
+
return;
|
|
21050
|
+
if (event.phase === "starting") {
|
|
21051
|
+
const record = owner;
|
|
21052
|
+
this.notifyFleetError(t("login.web_dashboard_notice", t("login.profile_label", event.backend, event.profile), record.label, record.handle.slice(0, 8)));
|
|
21053
|
+
}
|
|
21054
|
+
// A live CLI holds the old token in memory: the agents on THIS account (and no other) wake or restart, as after the other sign-in flows.
|
|
21055
|
+
if (event.phase === "done" && launched)
|
|
21056
|
+
void this.recoverBackendInstances(event.backend, undefined, event.profile).catch(() => this.logger.warn({ backend: event.backend, profile: event.profile }, "Post sign-in recovery failed"));
|
|
21057
|
+
},
|
|
21058
|
+
});
|
|
21059
|
+
}
|
|
20762
21060
|
needsYouBackendSignIns() {
|
|
20763
21061
|
const pending = readPendingBackendSignIns(this.dataDir).pending;
|
|
20764
21062
|
for (const backend of this.pendingBackendSince?.keys() ?? [])
|
|
@@ -20778,7 +21076,7 @@ export class FleetManager {
|
|
|
20778
21076
|
start: (backend, chat, opts) => this.startWebDashboardLogin(backend, chat, opts),
|
|
20779
21077
|
accessToken: sink => this.loginController?.webAccessToken(sink) ?? null,
|
|
20780
21078
|
isActiveFor: sink => this.loginController?.isActiveFor(sink) ?? false,
|
|
20781
|
-
cancelFor: sink => this.loginController?.cancelFor(sink) ?? Promise.resolve(false),
|
|
21079
|
+
cancelFor: (sink, opts) => this.loginController?.cancelFor(sink, opts) ?? Promise.resolve(false),
|
|
20782
21080
|
cancel: () => this.cancelLoginSession(),
|
|
20783
21081
|
notice: ({ shown, label, handle }) => this.notifyFleetError(t("login.web_dashboard_notice", shown, label, handle.slice(0, 8))),
|
|
20784
21082
|
// No details in the event: each page reads its own view (GET /ui/backend-login), as its session may see it.
|
|
@@ -20891,8 +21189,9 @@ export class FleetManager {
|
|
|
20891
21189
|
diskProfiles.set(backend, rows);
|
|
20892
21190
|
}
|
|
20893
21191
|
const { agents, classic, fleetDefaults } = this.accountUses();
|
|
20894
|
-
// Weekly usage, from the usage panel's own (cached, never forced) read.
|
|
21192
|
+
// Weekly and short-window (5h) usage, from the usage panel's own (cached, never forced) read.
|
|
20895
21193
|
const usage = new Map();
|
|
21194
|
+
const shortWindow = new Map();
|
|
20896
21195
|
const ids = new Map(); // provider id → backend\0profile
|
|
20897
21196
|
for (const backend of ACCOUNT_CLIS) {
|
|
20898
21197
|
const pid = usageProviderIdForBackend(backend);
|
|
@@ -20906,9 +21205,14 @@ export class FleetManager {
|
|
|
20906
21205
|
const payload = await Promise.race([getUsageSnapshot(false, undefined, { allowStale: true }), new Promise(r => { const tm = setTimeout(() => r(null), usageWaitMs); tm.unref?.(); })]);
|
|
20907
21206
|
for (const provider of payload?.providers ?? []) {
|
|
20908
21207
|
const at = ids.get(provider.id);
|
|
20909
|
-
|
|
20910
|
-
|
|
21208
|
+
if (!at)
|
|
21209
|
+
continue;
|
|
21210
|
+
const w = weeklyUsage(provider);
|
|
21211
|
+
if (w)
|
|
20911
21212
|
usage.set(at, w);
|
|
21213
|
+
const sh = shortUsage(provider);
|
|
21214
|
+
if (sh)
|
|
21215
|
+
shortWindow.set(at, sh);
|
|
20912
21216
|
}
|
|
20913
21217
|
}
|
|
20914
21218
|
catch { /* the view without usage */ }
|
|
@@ -20935,7 +21239,26 @@ export class FleetManager {
|
|
|
20935
21239
|
this.logger.debug({ err: err.message }, "Computer accounts not read");
|
|
20936
21240
|
}
|
|
20937
21241
|
}
|
|
20938
|
-
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, keepAlive, machines });
|
|
21242
|
+
return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, shortUsage: shortWindow, keepAlive, machines });
|
|
21243
|
+
}
|
|
21244
|
+
/**
|
|
21245
|
+
* 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
|
|
21246
|
+
* "the last check" is not the one from before the sign-in. Never awaited, and never allowed to fail the sign-in's own follow-up.
|
|
21247
|
+
*/
|
|
21248
|
+
keepAliveAfterSignIn(backend, profile) {
|
|
21249
|
+
if (!isKeepAliveBackend(backend))
|
|
21250
|
+
return;
|
|
21251
|
+
// Building the service can throw as well as the check, and the follow-up of a sign-in (waking its agents) must not depend on either.
|
|
21252
|
+
const failed = (err) => { try {
|
|
21253
|
+
this.logger.debug({ err: String(err?.message ?? err), backend }, "Keep-alive check after a sign-in failed");
|
|
21254
|
+
}
|
|
21255
|
+
catch { /* nothing to say it to */ } };
|
|
21256
|
+
try {
|
|
21257
|
+
this.keepAliveService().tick({ only: { backend, profile } }).catch(failed);
|
|
21258
|
+
}
|
|
21259
|
+
catch (err) {
|
|
21260
|
+
failed(err);
|
|
21261
|
+
}
|
|
20939
21262
|
}
|
|
20940
21263
|
/** #3292: the keep-alive service (built on first use, so the Accounts view can read settings before startup finishes). */
|
|
20941
21264
|
keepAliveService() {
|
|
@@ -21083,7 +21406,7 @@ export class FleetManager {
|
|
|
21083
21406
|
if (cli === backend && same(profileName(classicProfile(b.backend_options, defaults?.backend_options, cli))))
|
|
21084
21407
|
return true;
|
|
21085
21408
|
}
|
|
21086
|
-
return this.loginController?.signingIn(backend, profile) ?? false;
|
|
21409
|
+
return (this.loginController?.signingIn(backend, profile) ?? false) || (profile !== null && (this.profileSignInsInstance?.signingIn(backend, profile) ?? false)); // #3212: the dashboard's structured sign-in of a named account counts too
|
|
21087
21410
|
}
|
|
21088
21411
|
/**
|
|
21089
21412
|
* #3292 review: one keep-alive run's admission, decided synchronously: not in use, the shared login window taken, and the
|
|
@@ -21161,6 +21484,13 @@ export class FleetManager {
|
|
|
21161
21484
|
// #3190 Part 3c: on a paired computer the profile's folder is made by its Runtime when the first sign-in starts; this only checks what can be checked first.
|
|
21162
21485
|
if (machine)
|
|
21163
21486
|
return this.machineAccounts.add(backend, name, machine.id, by);
|
|
21487
|
+
const result = addAccountProfile(this.dataDir, backend, name, this.configuredProfileNames(backend));
|
|
21488
|
+
if (result.ok)
|
|
21489
|
+
this.logger.info({ backend, profile: name, by }, "Credential profile added from Settings → Accounts");
|
|
21490
|
+
return result;
|
|
21491
|
+
}
|
|
21492
|
+
/** The profile names the configuration refers to for this backend — an agent, a ClassicBot room, the fleet default — whether or not their folders exist yet. */
|
|
21493
|
+
configuredProfileNames(backend) {
|
|
21164
21494
|
const { agents, classic, fleetDefaults } = this.accountUses();
|
|
21165
21495
|
const configured = new Set();
|
|
21166
21496
|
for (const x of [...agents, ...classic])
|
|
@@ -21169,21 +21499,27 @@ export class FleetManager {
|
|
|
21169
21499
|
const fd = fleetDefaults.get(backend);
|
|
21170
21500
|
if (fd)
|
|
21171
21501
|
configured.add(fd);
|
|
21172
|
-
|
|
21173
|
-
if (result.ok)
|
|
21174
|
-
this.logger.info({ backend, profile: name, by }, "Credential profile added from Settings → Accounts");
|
|
21175
|
-
return result;
|
|
21502
|
+
return configured;
|
|
21176
21503
|
}
|
|
21177
21504
|
/**
|
|
21178
21505
|
* #3212 PR 2: Settings → Accounts → Remove. Refused while anything uses it or a sign-in for it runs (the login controller,
|
|
21179
21506
|
* or the login window held for this backend by a sign-in whose profile is not known yet); see accounts-profiles.ts.
|
|
21180
21507
|
* The fleet log records who removed which backend's profile — never what was in it.
|
|
21181
21508
|
*/
|
|
21182
|
-
async removeAccountProfile(backend, name, confirm, by, machine) {
|
|
21509
|
+
async removeAccountProfile(backend, name, confirm, by, machine, opts) {
|
|
21183
21510
|
if (machine)
|
|
21184
21511
|
return this.machineAccounts.remove(backend, name, confirm, machine.id, machine, by); // #3190 Part 3c: that computer's Runtime deletes its own folder
|
|
21185
21512
|
const profile = typeof name === "string" ? name : "";
|
|
21186
21513
|
const shown = validCredentialProfileName(name) ? name : "(invalid)";
|
|
21514
|
+
// #3321 review ("Cancel sign-in and remove"): the sign-in of exactly this account is ended first — no other account's, and a start whose profile is
|
|
21515
|
+
// not known yet is not guessed at — and every Remove check below is then made as usual: what is still signing in refuses (`signing_in`).
|
|
21516
|
+
if (opts?.cancelSignIn && validCredentialProfileName(name)) {
|
|
21517
|
+
// The account's sign-in is either the dashboard's structured one (ProfileSignIns) or the chat/terminal one (the login controller); at most one runs on the host.
|
|
21518
|
+
const ended = (await this.profileSignInsInstance?.cancelAccount(backend, name).catch(() => false))
|
|
21519
|
+
|| (await this.loginController?.cancelAccount(backend, name).catch(() => false));
|
|
21520
|
+
if (ended)
|
|
21521
|
+
this.logger.info({ backend, profile: shown, by }, "Sign-in cancelled for Remove");
|
|
21522
|
+
}
|
|
21187
21523
|
const refused = (r) => { if (!r.ok)
|
|
21188
21524
|
this.logger.info({ backend, profile: shown, by, refused: r.error }, "Credential profile removal refused"); return r; };
|
|
21189
21525
|
// #3212 PR 3: on macOS, Claude Code keeps the account's token in the Keychain, outside the folder — its own logout
|
|
@@ -21270,8 +21606,8 @@ export class FleetManager {
|
|
|
21270
21606
|
fleetDefault: same(fleetDefaults.get(backend)),
|
|
21271
21607
|
};
|
|
21272
21608
|
const held = this.loginWindow.current;
|
|
21273
|
-
const signingIn = (this.loginController?.signingIn(backend, profile) ?? false)
|
|
21274
|
-
|| (!!held && held !== ownClaim && held.backend === backend && !this.loginController?.activeBackend);
|
|
21609
|
+
const signingIn = (this.loginController?.signingIn(backend, profile) ?? false) || (this.profileSignInsInstance?.signingIn(backend, profile) ?? false)
|
|
21610
|
+
|| (!!held && held !== ownClaim && held.backend === backend && !this.loginController?.activeBackend && !this.profileSignInsInstance?.active); // a named account's sign-in holds the window too, and says WHICH account (above)
|
|
21275
21611
|
return { backend, name, confirm, users, signingIn, usersUnknown: rooms.kind === "unknown" };
|
|
21276
21612
|
}
|
|
21277
21613
|
/**
|
|
@@ -21327,7 +21663,7 @@ export class FleetManager {
|
|
|
21327
21663
|
const shown = named === null ? "(default)" : validCredentialProfileName(named) ? named : "(invalid)";
|
|
21328
21664
|
// #3305 review P2-3: the logout holds the shared login window from before it runs until its cleanup is done — no
|
|
21329
21665
|
// sign-in (chat, dashboard, install) and no other logout starts meanwhile; one already running refuses this.
|
|
21330
|
-
const signingIn = this.loginController?.signingIn(backend, named) ?? false;
|
|
21666
|
+
const signingIn = (this.loginController?.signingIn(backend, named) ?? false) || (named !== null && (this.profileSignInsInstance?.signingIn(backend, named) ?? false));
|
|
21331
21667
|
const claim = signingIn ? null : this.loginWindow.tryClaim("web", backend);
|
|
21332
21668
|
let result;
|
|
21333
21669
|
if (!claim)
|
|
@@ -21717,6 +22053,15 @@ export class FleetManager {
|
|
|
21717
22053
|
else
|
|
21718
22054
|
this.logger.error("A computer's account sign-in could not be confirmed ended; check that computer's Runtime window.");
|
|
21719
22055
|
}), "machine-signins"),
|
|
22056
|
+
// #3212: a named account's sign-in on this host is ended too; one that could not be shown gone keeps sign-in admission closed, as the default account's.
|
|
22057
|
+
bounded(this.profileSignInsInstance?.close().then(confirmed => {
|
|
22058
|
+
if (confirmed)
|
|
22059
|
+
this.profileSignInsInstance = null;
|
|
22060
|
+
else {
|
|
22061
|
+
this.structuredLoginCleanupFailed = true;
|
|
22062
|
+
this.logger.error("A named account's structured login cleanup failed; sign-in admission remains closed until the host is restarted.");
|
|
22063
|
+
}
|
|
22064
|
+
}), "profile-signins"),
|
|
21720
22065
|
bounded(this.loginController?.shutdown(), "web-login"),
|
|
21721
22066
|
bounded(this.activeInstall?.session.cancel("cancelled"), "install"),
|
|
21722
22067
|
// #3305 review P2-3: an account logout in flight (its CLI) — the closed window fences its cleanup; this waits for it.
|
|
@@ -21742,6 +22087,10 @@ export class FleetManager {
|
|
|
21742
22087
|
this.browserBackendSignInsInstance = null;
|
|
21743
22088
|
return confirmed ? t("login.cancelled", browserBackend) : t("login.browser_cleanup_failed");
|
|
21744
22089
|
}
|
|
22090
|
+
// #3212: a named account's sign-in on this host ("Cancel sign-in and remove" and `/login cancel` end it as they end the others).
|
|
22091
|
+
const ended = await this.profileSignInsInstance?.cancelActive();
|
|
22092
|
+
if (ended)
|
|
22093
|
+
return ended.confirmed ? t("login.cancelled", t("login.profile_label", ended.target.backend, ended.target.profile)) : t("login.browser_cleanup_failed");
|
|
21745
22094
|
if (this.loginController?.isActive())
|
|
21746
22095
|
return this.loginController.cancel();
|
|
21747
22096
|
return t("login.no_session");
|
|
@@ -21766,6 +22115,7 @@ export class FleetManager {
|
|
|
21766
22115
|
async recoverBackendInstances(backend, deadlineMs = POST_LOGIN_RECOVERY_DEADLINE_MS,
|
|
21767
22116
|
/** #1699 part 2: the login just signed in — a profile, or null for the backend's default one. */
|
|
21768
22117
|
profile = null) {
|
|
22118
|
+
this.keepAliveAfterSignIn(backend, profile ?? null);
|
|
21769
22119
|
const woken = [];
|
|
21770
22120
|
const restarted = [];
|
|
21771
22121
|
const pending = [];
|
|
@@ -25450,6 +25800,16 @@ export class FleetManager {
|
|
|
25450
25800
|
clearInterval(this.updateProgressTimer);
|
|
25451
25801
|
this.updateProgressTimer = null;
|
|
25452
25802
|
}
|
|
25803
|
+
// close() fences setup synchronously; its physical drain joins the asynchronous phase below.
|
|
25804
|
+
// Awaiting even an absent controller here would yield before the remaining shutdown fences.
|
|
25805
|
+
const setupClosed = this.hubSetupController?.close().catch(() => {
|
|
25806
|
+
this.logger.warn("Hub setup scratch cleanup is unconfirmed; setup remains fenced");
|
|
25807
|
+
});
|
|
25808
|
+
this.hubSetupController = null;
|
|
25809
|
+
this.hubSetupInit = null;
|
|
25810
|
+
this.companyJoinController?.close();
|
|
25811
|
+
this.companyJoinController = null;
|
|
25812
|
+
this.companyJoinInit = null;
|
|
25453
25813
|
this.settingsGeneration++;
|
|
25454
25814
|
this.settingsConfirmation?.store.close();
|
|
25455
25815
|
this.settingsConfirmation = null;
|
|
@@ -25514,6 +25874,7 @@ export class FleetManager {
|
|
|
25514
25874
|
// timer and HTTP listener living in THIS process: without an explicit
|
|
25515
25875
|
// shutdown it would outlive us as an owner-less login CLI (sol B3).
|
|
25516
25876
|
await inboundStopped;
|
|
25877
|
+
await setupClosed;
|
|
25517
25878
|
await publicStopped;
|
|
25518
25879
|
await sharesStopped?.catch(() => { });
|
|
25519
25880
|
await profileStopped;
|
|
@@ -26193,7 +26554,7 @@ export class FleetManager {
|
|
|
26193
26554
|
* audit notice — and only once all of that holds is the attempt written to
|
|
26194
26555
|
* disk and fsynced, before anything spawns.
|
|
26195
26556
|
*/
|
|
26196
|
-
async requestSettingsSelfRestart(
|
|
26557
|
+
async requestSettingsSelfRestart(requestedJobId, key) {
|
|
26197
26558
|
// A retry after a lost response must not restart a second time. The key is
|
|
26198
26559
|
// recorded on the job, which survives the restart it triggers.
|
|
26199
26560
|
const already = this.applyJobs.findByRestartKey(key);
|
|
@@ -26210,6 +26571,31 @@ export class FleetManager {
|
|
|
26210
26571
|
error: `fleet.yaml and the running configuration disagree on ${this.fleetSignatureMismatch.join(", ")} — check daemon.log before restarting`,
|
|
26211
26572
|
};
|
|
26212
26573
|
}
|
|
26574
|
+
// S-92 (#3326 D1): a restart asked for the pending changes themselves (`requestedJobId` null) — the restart notice
|
|
26575
|
+
// with no Settings job behind it (a hand edit of fleet.yaml). Only when a fleet-level restart is pending
|
|
26576
|
+
// (settingsRestartPending, the notice's own test): its newest job carries it, else one is made here to carry it, once
|
|
26577
|
+
// (the next ask finds that one). Everything below is the same path as a Save's restart.
|
|
26578
|
+
let jobId = requestedJobId;
|
|
26579
|
+
if (jobId === null) {
|
|
26580
|
+
// One already asked for is in flight (its row "running"): never a second job, nor a second restart.
|
|
26581
|
+
// #3373 review P2: a consumed restart job (and its row) runs until the next process settles it (settleAfterRestart)
|
|
26582
|
+
// or its launch fails (finish) — so this sees only a restart still in flight, never an old one.
|
|
26583
|
+
if (this.applyJobs.all().some(item => item.restart_key && item.targets.some(r => r.target === APPLY_FLEET_TARGET && r.status === "running"))) {
|
|
26584
|
+
return { ok: false, status: 409, error: "a restart is already running" };
|
|
26585
|
+
}
|
|
26586
|
+
const pending = this.settingsRestartPending();
|
|
26587
|
+
if (!pending)
|
|
26588
|
+
return { ok: false, status: 409, error: "no fleet-level change is pending any more" };
|
|
26589
|
+
if (pending.job_id)
|
|
26590
|
+
jobId = pending.job_id;
|
|
26591
|
+
else {
|
|
26592
|
+
const made = this.applyJobs.create(`restart-pending:${key}`, [{ target: APPLY_FLEET_TARGET, kind: "restart" }]);
|
|
26593
|
+
this.applyJobs.setTargetStatus(made.id, APPLY_FLEET_TARGET, "restart-required");
|
|
26594
|
+
this.applyJobs.finish(made.id);
|
|
26595
|
+
this.logger.info({ jobId: made.id, keys: pending.keys }, "Settings restart for pending changes with no Settings job: a job now carries it");
|
|
26596
|
+
jobId = made.id;
|
|
26597
|
+
}
|
|
26598
|
+
}
|
|
26213
26599
|
const job = this.applyJobs.get(jobId);
|
|
26214
26600
|
const row = job?.targets.find(item => item.target === APPLY_FLEET_TARGET);
|
|
26215
26601
|
if (!job || !row || row.status !== "restart-required") {
|
|
@@ -26257,8 +26643,19 @@ export class FleetManager {
|
|
|
26257
26643
|
// the admins are. Refusing when it cannot be posted is the same rule as
|
|
26258
26644
|
// refusing when the progress marker cannot be written: no untraceable
|
|
26259
26645
|
// restarts.
|
|
26260
|
-
|
|
26261
|
-
|
|
26646
|
+
// S-92 (leader's ruling, cid-a6-ui-feedback): a web-only fleet has no General to announce it in — its trace is the
|
|
26647
|
+
// dashboard's own fleet Notice (where its admins are) plus the log line below. Every other guard above and below is
|
|
26648
|
+
// the same. A chat fleet is unchanged: General is the trace.
|
|
26649
|
+
const webOnly = this.isWebOnlyFleet();
|
|
26650
|
+
const notice = webOnly ? null : await this.postSelfRestartNotice();
|
|
26651
|
+
if (webOnly) {
|
|
26652
|
+
if (!this.recordWebNoticeDurable("fleet", t("restart.settings_triggered"))) {
|
|
26653
|
+
this.logger.error({ jobId }, "Could not record the Settings-triggered restart as a fleet Notice — refusing to restart silently");
|
|
26654
|
+
return { ok: false, status: 503, error: "couldn't record the restart; try again" };
|
|
26655
|
+
}
|
|
26656
|
+
this.logger.info({ jobId, trace: "web-notice" }, "Settings-triggered restart announced as a fleet Notice (web-only fleet)");
|
|
26657
|
+
}
|
|
26658
|
+
else if (!notice) {
|
|
26262
26659
|
return {
|
|
26263
26660
|
ok: false,
|
|
26264
26661
|
status: 409,
|
|
@@ -26271,11 +26668,23 @@ export class FleetManager {
|
|
|
26271
26668
|
const target = current.targets.find(item => item.target === APPLY_FLEET_TARGET);
|
|
26272
26669
|
if (target)
|
|
26273
26670
|
target.status = "running";
|
|
26671
|
+
// #3373 review P2: the job runs again while its restart does (its deadline is the restart's): the next process
|
|
26672
|
+
// settles it (settleAfterRestart only touches running jobs), a failed launch finishes it.
|
|
26673
|
+
current.status = "running";
|
|
26674
|
+
delete current.finishedAt;
|
|
26675
|
+
current.restartStartedAt = Date.now(); // its time counts from now, not from the Save (#3373 review P3)
|
|
26274
26676
|
current.restart_key = key;
|
|
26275
26677
|
current.deadlineMs = SELF_RESTART_DEADLINE_MS;
|
|
26276
26678
|
});
|
|
26277
26679
|
this.emitSseEvent("apply_progress", viewOf(this.applyJobs.get(jobId)));
|
|
26278
|
-
|
|
26680
|
+
// #3373 review P2: a web restart's helper that fails after it was launched (the answer already said "restarting") is
|
|
26681
|
+
// said as a fleet Notice by requestWebFullRestart, and its job settles here as failed.
|
|
26682
|
+
const settleLateFailure = (detail) => {
|
|
26683
|
+
this.applyJobs.setTargetStatus(jobId, APPLY_FLEET_TARGET, "failed", detail);
|
|
26684
|
+
this.applyJobs.finish(jobId, detail);
|
|
26685
|
+
this.emitSseEvent("apply_progress", viewOf(this.applyJobs.get(jobId)));
|
|
26686
|
+
};
|
|
26687
|
+
const launched = await (notice ? this.requestFullRestart(notice.adapter, notice.chatId, notice.threadId, notice.messageId) : this.requestWebFullRestart(settleLateFailure))
|
|
26279
26688
|
.catch(err => {
|
|
26280
26689
|
this.logger.error({ err }, "Settings-triggered self restart failed to launch");
|
|
26281
26690
|
return false;
|