@songsid/agend 2.4.0-alpha.2 → 2.4.0-alpha.3
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/account-isolation.d.ts +6 -0
- package/dist/account-isolation.js +40 -0
- package/dist/account-isolation.js.map +1 -0
- package/dist/accounts-signout.d.ts +15 -2
- package/dist/accounts-signout.js +52 -4
- package/dist/accounts-signout.js.map +1 -1
- package/dist/accounts-view.d.ts +114 -27
- package/dist/accounts-view.js +123 -60
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-cli-instructions.md +9 -7
- package/dist/agent-cli.js +47 -20
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-endpoint.js +23 -8
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-list-output.d.ts +23 -0
- package/dist/agent-list-output.js +53 -0
- package/dist/agent-list-output.js.map +1 -0
- package/dist/agent-runtime-change.js +4 -4
- package/dist/agent-runtime-change.js.map +1 -1
- package/dist/agent-whats-new.js +2 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/antigravity-first-run.d.ts +4 -0
- package/dist/antigravity-first-run.js +57 -0
- package/dist/antigravity-first-run.js.map +1 -0
- package/dist/antigravity-identity.d.ts +6 -0
- package/dist/antigravity-identity.js +27 -0
- package/dist/antigravity-identity.js.map +1 -0
- package/dist/antigravity-store.d.ts +22 -0
- package/dist/antigravity-store.js +79 -0
- package/dist/antigravity-store.js.map +1 -0
- package/dist/auth-api.js +4 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/agy-onboarding.d.ts +14 -0
- package/dist/backend/agy-onboarding.js +114 -0
- package/dist/backend/agy-onboarding.js.map +1 -0
- package/dist/backend/antigravity.d.ts +15 -0
- package/dist/backend/antigravity.js +44 -4
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/credential-profile.d.ts +22 -3
- package/dist/backend/credential-profile.js +61 -9
- package/dist/backend/credential-profile.js.map +1 -1
- package/dist/backend-availability.d.ts +6 -0
- package/dist/backend-availability.js +11 -0
- package/dist/backend-availability.js.map +1 -1
- package/dist/browser-backend-signins.d.ts +9 -1
- package/dist/browser-backend-signins.js +9 -5
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +9 -9
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-auth-status.d.ts +1 -0
- package/dist/claude-auth-status.js +25 -0
- package/dist/claude-auth-status.js.map +1 -1
- package/dist/cli-capability.d.ts +104 -19
- package/dist/cli-capability.js +3 -1
- package/dist/cli-capability.js.map +1 -1
- package/dist/cli-caps-module.d.ts +14 -0
- package/dist/cli-caps-module.js +8 -1
- package/dist/cli-caps-module.js.map +1 -1
- package/dist/cli-registry-check.js +114 -18
- package/dist/cli-registry-check.js.map +1 -1
- package/dist/cli-registry.d.ts +116 -12
- package/dist/cli-registry.js +16 -1
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli-spec-antigravity.d.ts +53 -11
- package/dist/cli-spec-antigravity.js +44 -13
- package/dist/cli-spec-antigravity.js.map +1 -1
- package/dist/cli-spec-claude-code.d.ts +14 -1
- package/dist/cli-spec-claude-code.js +5 -4
- package/dist/cli-spec-claude-code.js.map +1 -1
- package/dist/cli-spec-codex.d.ts +8 -0
- package/dist/cli-spec-codex.js +4 -3
- package/dist/cli-spec-codex.js.map +1 -1
- package/dist/cli-spec-grok.d.ts +4 -0
- package/dist/cli-spec-grok.js +2 -1
- package/dist/cli-spec-grok.js.map +1 -1
- package/dist/cli-spec-kiro-cli.d.ts +7 -0
- package/dist/cli-spec-kiro-cli.js +3 -2
- package/dist/cli-spec-kiro-cli.js.map +1 -1
- package/dist/cli-spec-muse.d.ts +4 -0
- package/dist/cli-spec-muse.js +2 -1
- package/dist/cli-spec-muse.js.map +1 -1
- package/dist/cli-spec-opencode.d.ts +1 -0
- package/dist/cli-spec-opencode.js +1 -0
- package/dist/cli-spec-opencode.js.map +1 -1
- package/dist/credential-store-proof.d.ts +6 -0
- package/dist/credential-store-proof.js +30 -0
- package/dist/credential-store-proof.js.map +1 -0
- package/dist/daemon.js +2 -2
- package/dist/daemon.js.map +1 -1
- package/dist/decision-list.d.ts +5 -4
- package/dist/decision-list.js +22 -8
- package/dist/decision-list.js.map +1 -1
- package/dist/fleet-manager.d.ts +20 -1
- package/dist/fleet-manager.js +158 -54
- package/dist/fleet-manager.js.map +1 -1
- package/dist/fleet-windows-runtime.js +6 -6
- package/dist/fleet-windows-runtime.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +32 -4
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +23 -6
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +14 -6
- package/dist/general-knowledge/skills/fleet-health/SKILL.md +16 -0
- package/dist/general-knowledge/skills/hub/SKILL.md +361 -0
- package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +184 -36
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +5 -1
- package/dist/general-role.d.ts +1 -1
- package/dist/general-role.js +1 -0
- package/dist/general-role.js.map +1 -1
- package/dist/hub/buttons.d.ts +3 -0
- package/dist/hub/buttons.js +11 -11
- package/dist/hub/buttons.js.map +1 -1
- package/dist/hub/catalog.d.ts +13 -6
- package/dist/hub/catalog.js +106 -33
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +6 -0
- package/dist/hub/client.js +4 -1
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.js +15 -0
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +6 -0
- package/dist/hub/compose/server.js +9 -3
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +51 -0
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +14 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/enrolment-code.d.ts +1 -1
- package/dist/hub/enrolment-code.js +4 -4
- package/dist/hub/enrolment-code.js.map +1 -1
- package/dist/hub/grant-access.d.ts +11 -0
- package/dist/hub/grant-access.js +113 -0
- package/dist/hub/grant-access.js.map +1 -0
- package/dist/hub/grant-search.d.ts +9 -0
- package/dist/hub/grant-search.js +92 -0
- package/dist/hub/grant-search.js.map +1 -0
- package/dist/hub/group-policy/admin-impact.d.ts +2 -0
- package/dist/hub/group-policy/admin-impact.js +10 -2
- package/dist/hub/group-policy/admin-impact.js.map +1 -1
- package/dist/hub/group-policy/admin-inventory.js +1 -1
- package/dist/hub/group-policy/admin-inventory.js.map +1 -1
- package/dist/hub/group-policy/authorization.d.ts +5 -2
- package/dist/hub/group-policy/authorization.js +73 -32
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.js +20 -4
- package/dist/hub/group-policy/impact-inventory.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +4 -5
- package/dist/hub/group-policy/resources.js +26 -19
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.d.ts +18 -3
- package/dist/hub/group-policy/store.js +94 -80
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/group-policy/welcome.js.map +1 -1
- package/dist/hub/http/compose.js +39 -11
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +18 -0
- package/dist/hub/http/core.js +108 -7
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +8 -0
- package/dist/hub/http/schema.js +11 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/join/local.d.ts +5 -0
- package/dist/hub/join/local.js +28 -5
- package/dist/hub/join/local.js.map +1 -1
- package/dist/hub/join/service.d.ts +2 -0
- package/dist/hub/join/service.js +34 -35
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/member/pairing-api.js +4 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/pairing.d.ts +3 -0
- package/dist/hub/pairing.js +37 -16
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/policy.d.ts +1 -1
- package/dist/hub/policy.js +19 -6
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/protocol.d.ts +13 -0
- package/dist/hub/protocol.js +7 -2
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/quota.d.ts +2 -1
- package/dist/hub/quota.js +2 -2
- package/dist/hub/quota.js.map +1 -1
- package/dist/hub/roles/authority.d.ts +45 -0
- package/dist/hub/roles/authority.js +199 -0
- package/dist/hub/roles/authority.js.map +1 -0
- package/dist/hub/roles/change.d.ts +18 -0
- package/dist/hub/roles/change.js +76 -0
- package/dist/hub/roles/change.js.map +1 -0
- package/dist/hub/roles/convert.d.ts +11 -0
- package/dist/hub/roles/convert.js +27 -0
- package/dist/hub/roles/convert.js.map +1 -0
- package/dist/hub/roles/cutover-inventory.d.ts +14 -0
- package/dist/hub/roles/cutover-inventory.js +42 -0
- package/dist/hub/roles/cutover-inventory.js.map +1 -0
- package/dist/hub/roles/cutover.d.ts +32 -0
- package/dist/hub/roles/cutover.js +184 -0
- package/dist/hub/roles/cutover.js.map +1 -0
- package/dist/hub/roles/delegation.d.ts +24 -0
- package/dist/hub/roles/delegation.js +111 -0
- package/dist/hub/roles/delegation.js.map +1 -0
- package/dist/hub/roles/evaluate.d.ts +50 -0
- package/dist/hub/roles/evaluate.js +96 -0
- package/dist/hub/roles/evaluate.js.map +1 -0
- package/dist/hub/roles/expiry.d.ts +46 -0
- package/dist/hub/roles/expiry.js +180 -0
- package/dist/hub/roles/expiry.js.map +1 -0
- package/dist/hub/roles/mode-effects.d.ts +5 -0
- package/dist/hub/roles/mode-effects.js +21 -0
- package/dist/hub/roles/mode-effects.js.map +1 -0
- package/dist/hub/roles/model.d.ts +171 -0
- package/dist/hub/roles/model.js +79 -0
- package/dist/hub/roles/model.js.map +1 -0
- package/dist/hub/roles/read.d.ts +29 -0
- package/dist/hub/roles/read.js +47 -0
- package/dist/hub/roles/read.js.map +1 -0
- package/dist/hub/roles/writer.d.ts +80 -0
- package/dist/hub/roles/writer.js +427 -0
- package/dist/hub/roles/writer.js.map +1 -0
- package/dist/hub/rooms.d.ts +8 -0
- package/dist/hub/rooms.js +47 -27
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/server.d.ts +3 -0
- package/dist/hub/server.js +3 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sessions.js +5 -1
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-directory-decision.d.ts +2 -2
- package/dist/hub/settings-directory-decision.js +7 -5
- package/dist/hub/settings-directory-decision.js.map +1 -1
- package/dist/hub/settings-directory-proof.js +3 -1
- package/dist/hub/settings-directory-proof.js.map +1 -1
- package/dist/hub/settings-directory-recovery.js +3 -3
- package/dist/hub/settings-directory-recovery.js.map +1 -1
- package/dist/hub/sharing.d.ts +10 -0
- package/dist/hub/sharing.js +74 -0
- package/dist/hub/sharing.js.map +1 -0
- package/dist/hub/store.js +6 -2
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +17 -1
- package/dist/hub/web-origin.d.ts +80 -0
- package/dist/hub/web-origin.js +163 -0
- package/dist/hub/web-origin.js.map +1 -0
- package/dist/human-delivery-receipts.js +2 -2
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +13 -1
- package/dist/instance-lifecycle.js +32 -10
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +8 -2
- package/dist/instructions.js +28 -6
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +6 -6
- package/dist/locale.js.map +1 -1
- package/dist/login-flows.d.ts +24 -2
- package/dist/login-flows.js +53 -22
- package/dist/login-flows.js.map +1 -1
- package/dist/login-url.js +3 -0
- package/dist/login-url.js.map +1 -1
- package/dist/machine-accounts.d.ts +42 -12
- package/dist/machine-accounts.js +144 -46
- package/dist/machine-accounts.js.map +1 -1
- package/dist/machine-signins.d.ts +35 -13
- package/dist/machine-signins.js +57 -27
- package/dist/machine-signins.js.map +1 -1
- package/dist/native-instance-input.js +4 -4
- package/dist/native-instance-input.js.map +1 -1
- package/dist/native-instance-registry.d.ts +3 -3
- package/dist/native-instance-registry.js +11 -10
- package/dist/native-instance-registry.js.map +1 -1
- package/dist/outbound-handlers.js +19 -19
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +18 -0
- package/dist/outbound-schemas.js +22 -4
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/profile-signins.d.ts +5 -0
- package/dist/profile-signins.js +1 -0
- package/dist/profile-signins.js.map +1 -1
- package/dist/runtime-build-info.js +6 -2
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli.js +33 -11
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client.d.ts +18 -2
- package/dist/runtime-client.js +84 -21
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-credential-profiles.d.ts +36 -4
- package/dist/runtime-credential-profiles.js +82 -16
- package/dist/runtime-credential-profiles.js.map +1 -1
- package/dist/runtime-profile-ownership.d.ts +2 -2
- package/dist/runtime-profile-ownership.js +3 -3
- package/dist/runtime-profile-ownership.js.map +1 -1
- package/dist/runtime-protocol.d.ts +5 -3
- package/dist/runtime-protocol.js +4 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +72 -5
- package/dist/runtime-remote-accounts.js +293 -52
- package/dist/runtime-remote-accounts.js.map +1 -1
- package/dist/runtime-remote-setup.d.ts +2 -2
- package/dist/runtime-remote-setup.js +2 -2
- package/dist/runtime-remote-setup.js.map +1 -1
- package/dist/runtime-signin-transport.d.ts +22 -4
- package/dist/runtime-signin-transport.js +50 -12
- package/dist/runtime-signin-transport.js.map +1 -1
- package/dist/runtime-signin.d.ts +42 -0
- package/dist/runtime-signin.js +105 -9
- package/dist/runtime-signin.js.map +1 -1
- package/dist/runtime-windows-bridge.js +6 -1
- package/dist/runtime-windows-bridge.js.map +1 -1
- package/dist/scheduler/task-board.d.ts +1 -0
- package/dist/scheduler/task-board.js +10 -1
- package/dist/scheduler/task-board.js.map +1 -1
- package/dist/signin-keepalive.d.ts +31 -2
- package/dist/signin-keepalive.js +123 -12
- package/dist/signin-keepalive.js.map +1 -1
- package/dist/structured-signin-transport.d.ts +2 -2
- package/dist/structured-signin-transport.js +27 -6
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/structured-signin.d.ts +16 -2
- package/dist/structured-signin.js +59 -4
- package/dist/structured-signin.js.map +1 -1
- package/dist/task-board-tool.d.ts +0 -13
- package/dist/task-board-tool.js +42 -6
- package/dist/task-board-tool.js.map +1 -1
- package/dist/tool-receipt-output.d.ts +151 -0
- package/dist/tool-receipt-output.js +50 -0
- package/dist/tool-receipt-output.js.map +1 -0
- package/dist/ui/accounts-keepalive.js +15 -6
- package/dist/ui/accounts-manage.js +25 -5
- package/dist/ui/accounts-view.js +28 -24
- package/dist/ui/agent-proposals.js +22 -2
- package/dist/ui/agent-runtime-settings.js +3 -3
- package/dist/ui/backend-signin.js +4 -4
- package/dist/ui/cli-caps.js +7 -7
- package/dist/ui/credential-profile-select.js +32 -19
- package/dist/ui/hub-chat-store.js +8 -4
- package/dist/ui/hub-client.js +54 -19
- package/dist/ui/hub-enrolment-code.js +1 -1
- package/dist/ui/hub-grant-picker.js +100 -0
- package/dist/ui/hub-group-search.js +2 -2
- package/dist/ui/hub-join-one-strings.js +2 -2
- package/dist/ui/hub-join-steps.js +5 -2
- package/dist/ui/machine-signin.js +47 -14
- package/dist/ui/panel-fleet.js +2 -2
- package/dist/ui/panel-hub.js +55 -11
- package/dist/ui/panel-settings.js +2 -2
- package/dist/ui/settings-hub-company-join.js +1 -0
- package/dist/ui/settings-hub-section.js +2 -0
- package/dist/ui/settings-hub-web-address.js +233 -0
- package/dist/ui/settings-hub.js +6 -0
- package/dist/ui/shared/accounts-keepalive.css +8 -0
- package/dist/ui/shared/accounts-usage-pool.css +10 -0
- package/dist/ui/shared/accounts.css +9 -0
- package/dist/ui/shared/app.css +38 -5
- package/dist/ui/shared/hub-grant-picker.css +4 -0
- package/dist/ui/shared/hub-sharing.css +4 -0
- package/dist/ui/shared/view-strings.js +2 -2
- package/dist/ui/structured-signin.js +19 -6
- package/dist/ui/usage-pool.js +76 -0
- package/dist/usage/agent-output.d.ts +144 -0
- package/dist/usage/agent-output.js +75 -0
- package/dist/usage/agent-output.js.map +1 -0
- package/dist/usage/provider-alerts.d.ts +6 -0
- package/dist/usage/provider-alerts.js +6 -0
- package/dist/usage/provider-alerts.js.map +1 -1
- package/dist/usage/providers.d.ts +2 -2
- package/dist/usage/providers.js +60 -18
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.d.ts +12 -0
- package/dist/usage/usage-api.js +39 -0
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +27 -12
- package/dist/web-api.js.map +1 -1
- package/dist/web-backend-login.d.ts +4 -1
- package/dist/web-backend-login.js.map +1 -1
- package/dist/windows-cli-providers.js +5 -1
- package/dist/windows-cli-providers.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +33 -1
- package/dist/windows-cli-worker.js +150 -10
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +7 -1
- package/dist/windows-cli.js +19 -2
- package/dist/windows-cli.js.map +1 -1
- package/dist/workflow-templates/default.md +2 -2
- package/package.json +1 -1
|
@@ -10,18 +10,23 @@
|
|
|
10
10
|
* Built-ins and shared Runtime modules only: part of the Runtime bundle.
|
|
11
11
|
*/
|
|
12
12
|
import { isNativeProviderId, nativeProvider } from "./windows-cli-providers.js";
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
13
|
+
import { existsSync, lstatSync, unlinkSync } from "node:fs";
|
|
14
|
+
import { fingerprintStore, storeWrittenSince } from "./credential-store-proof.js";
|
|
15
|
+
import { join } from "node:path";
|
|
14
16
|
import { CliInstallError } from "./runtime-cli-install.js";
|
|
15
17
|
import { parseAccountIdentity } from "./claude-auth-status.js";
|
|
16
|
-
import { CredentialProfileRefusal, credentialProfileCaseClash, credentialProfileDirectory, isCredentialProfileCli, rememberCredentialStatus, withCredentialProfile } from "./runtime-credential-profiles.js";
|
|
18
|
+
import { CredentialProfileRefusal, PROFILE_CLI_NAMES, credentialProfileCaseClash, credentialProfileDirectory, credentialProfileLaunch, credentialProfileStore, isCredentialProfileCli, rememberCredentialStatus, withCredentialProfile } from "./runtime-credential-profiles.js";
|
|
17
19
|
import { ProfileOwnershipRefusal, createRuntimeProfile, deleteProfileBackups, removeOwnedProfile, requireOwnedProfile, withIsolatedOwnedProfile } from "./runtime-profile-ownership.js";
|
|
18
20
|
import { AuditLog, RemoteSetupRefusal, readRemoteSwitches, requireRemoteSwitch, validAuditActor } from "./runtime-remote-setup.js";
|
|
19
21
|
import { ProcessNotConfirmedEnded, RuntimeSignIn, RuntimeSignInSlot, SignInRefusal } from "./runtime-signin.js";
|
|
22
|
+
import { isRuntimeDefaultLoginCli, runtimeFacts } from "./cli-registry.js";
|
|
20
23
|
import { isRuntimeRemoteOperation, parseRuntimeRemotePayload } from "./runtime-protocol.js";
|
|
21
24
|
// Defined next to `killTree` (the installer needs it too, and this module imports the installer's error): re-exported here for the existing importers.
|
|
22
25
|
export { ProcessNotConfirmedEnded };
|
|
23
26
|
/** The key under which an install that could not be confirmed ended keeps the Runtime busy (no profile name can be this: it holds a NUL). */
|
|
24
27
|
const INSTALL_KEY = "\0cli-install";
|
|
28
|
+
/** What a CLI is called in a refusal (the registry's Runtime name for it). */
|
|
29
|
+
const cliName = (cli) => runtimeFacts(cli, "provider")?.name ?? cli;
|
|
25
30
|
const NOT_AVAILABLE = "This computer's Runtime is stopping or its connection changed, so nothing was done";
|
|
26
31
|
/** At most this many `accounts.check` at a time on the computer: each one can start PowerShell and the CLI. */
|
|
27
32
|
export const MAX_CONCURRENT_CHECKS = 2;
|
|
@@ -40,8 +45,28 @@ function reasonOf(error) {
|
|
|
40
45
|
return "failed";
|
|
41
46
|
}
|
|
42
47
|
const NEEDS_ACCOUNTS = ["models.refresh", "signin.start", "signin.capture", "signin.status", "signin.write", "accounts.check", "accounts.signout", "accounts.remove"];
|
|
48
|
+
/** The key of "a CLI's own login" in the pace table (no profile name can hold a NUL). */
|
|
49
|
+
const DEFAULT_KEY = "\0default-login:";
|
|
50
|
+
/** Deletes one plain file of an account's folder, by the registry's exact name: not a link, not a folder, and nothing else. A file that is not there is already signed out. */
|
|
51
|
+
function removeSignInFile(directory, name) {
|
|
52
|
+
const path = join(directory, name);
|
|
53
|
+
let stat;
|
|
54
|
+
try {
|
|
55
|
+
stat = lstatSync(path);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code === "ENOENT")
|
|
59
|
+
return;
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
63
|
+
throw new ProfileOwnershipRefusal("The account's sign-in file is not a plain file, so nothing is changed there", "link");
|
|
64
|
+
unlinkSync(path);
|
|
65
|
+
}
|
|
43
66
|
/** The least time between two sign-outs or removes of one profile. It only slows a server that keeps asking; the switch and its time window are what bound the risk. */
|
|
44
67
|
export const PROFILE_OP_MIN_GAP_MS = 5_000;
|
|
68
|
+
/** Under this pairing's folder (never under a CLI's profile folder, so it is never listed as an account): where the isolation probe's empty scratch folders are made. */
|
|
69
|
+
export const ISOLATION_SCRATCH = "isolation-scratch";
|
|
45
70
|
const SUBSCRIPTION_ONLY = "Signing in with an Anthropic Console account is not supported from AgEnD, because that sign-in is kept outside the profile's folder. On that computer run: agend-runtime login claude-code NAME";
|
|
46
71
|
export class RemoteAccounts {
|
|
47
72
|
deps;
|
|
@@ -53,6 +78,8 @@ export class RemoteAccounts {
|
|
|
53
78
|
busy = new Set();
|
|
54
79
|
/** Operations of which only one may be in progress on the whole computer (its `check` and `run` are separated by awaits). */
|
|
55
80
|
exclusive = new Set();
|
|
81
|
+
/** AGEND-250 (#3771 review P2-4): credentials held against new task admission (the computer's own login of a CLI, while a Disconnect deletes and verifies it). Read synchronously by `defaultReserved`. */
|
|
82
|
+
held = new Set();
|
|
56
83
|
/** When a sign-out or remove of a profile (lower-case name) last passed its checks. Only profiles this Runtime created get here. */
|
|
57
84
|
lastChange = new Map();
|
|
58
85
|
/** Closed to new work by `stop()`; and the connection the requests in flight belong to (a change ends the old ones' right to start anything). */
|
|
@@ -110,8 +137,10 @@ export class RemoteAccounts {
|
|
|
110
137
|
this.endWithRetry(this.meta.id, "closed");
|
|
111
138
|
}
|
|
112
139
|
/** Nothing of this module is running or being held: the update fence may ask. */
|
|
113
|
-
idle() { return this.pending.size === 0 && !this.slot.current() && this.busy.size === 0 && this.retained.size === 0 && this.activeChecks === 0 && this.exclusive.size === 0; }
|
|
140
|
+
idle() { return this.pending.size === 0 && !this.slot.current() && this.busy.size === 0 && this.retained.size === 0 && this.activeChecks === 0 && this.exclusive.size === 0 && this.held.size === 0; }
|
|
114
141
|
/** A change to this profile has been reserved or is under way: a task or terminal must not start under it now. */
|
|
142
|
+
/** Whether the computer's OWN login of this CLI is being changed by a Disconnect (from its first check until its verification has finished): a run or terminal that would use it is refused. */
|
|
143
|
+
defaultReserved(cli) { return this.held.has(`${DEFAULT_KEY}${cli}`); }
|
|
115
144
|
profileReserved(name) { const key = name.toLowerCase(); return this.busy.has(key) || this.retained.has(key); }
|
|
116
145
|
refreshHold() { if (this.hold && !this.slot.current()) {
|
|
117
146
|
const leave = this.hold;
|
|
@@ -126,9 +155,9 @@ export class RemoteAccounts {
|
|
|
126
155
|
requireRemoteSwitch(this.deps.pairingDirectory, switchName, this.now());
|
|
127
156
|
}
|
|
128
157
|
/** The last, synchronous look before a profile is renamed: the switch, the default, tasks and terminals, and a sign-in, all as they are at this instant. */
|
|
129
|
-
finalLook(ctx, name, forRemove) {
|
|
158
|
+
finalLook(ctx, name, forRemove, cli = "claude-code") {
|
|
130
159
|
this.gate(ctx, "accounts");
|
|
131
|
-
if (forRemove) {
|
|
160
|
+
if (forRemove && cli === "claude-code") {
|
|
132
161
|
let fallback;
|
|
133
162
|
try {
|
|
134
163
|
fallback = this.deps.defaultProfile();
|
|
@@ -208,6 +237,9 @@ export class RemoteAccounts {
|
|
|
208
237
|
}
|
|
209
238
|
this.exclusive.add(taken);
|
|
210
239
|
}
|
|
240
|
+
const hold = steps.hold;
|
|
241
|
+
if (hold !== undefined)
|
|
242
|
+
this.held.add(hold);
|
|
211
243
|
try {
|
|
212
244
|
// The switch and the connection are looked at again after the checks, which can wait a long time (PowerShell, a CLI lookup): a switch turned off or
|
|
213
245
|
// run out meanwhile, or a connection that has gone, stops the operation here, before anything is recorded as started.
|
|
@@ -234,13 +266,30 @@ export class RemoteAccounts {
|
|
|
234
266
|
this.busy.delete(key);
|
|
235
267
|
if (taken !== undefined)
|
|
236
268
|
this.exclusive.delete(taken);
|
|
269
|
+
if (hold !== undefined)
|
|
270
|
+
this.held.delete(hold);
|
|
237
271
|
}
|
|
238
272
|
}
|
|
239
273
|
cliOf(value) {
|
|
240
274
|
if (!isCredentialProfileCli(value))
|
|
241
|
-
throw new ProfileOwnershipRefusal(
|
|
275
|
+
throw new ProfileOwnershipRefusal(`Only ${PROFILE_CLI_NAMES()} accounts can be managed on a computer. Codex may keep its sign-in in the Windows Credential Manager, which a profile folder cannot hold or remove, so it is not offered yet`, "unsupported");
|
|
242
276
|
return value;
|
|
243
277
|
}
|
|
278
|
+
/** Whether a CLI is told its named account by an argument (Antigravity), which is why its sign-in is proven isolated first and its sign-out removes a file. */
|
|
279
|
+
static byArgument(cli) { const facts = runtimeFacts(cli, "namedAccounts"); return !!facts && "arg" in facts; }
|
|
280
|
+
/**
|
|
281
|
+
* AGEND-124: before a NAMED account of a CLI told its account by an argument is signed in, two things that need no change to be refused: the folder has a path the CLI can be given (a relative one: not
|
|
282
|
+
* across drives), and an empty scratch folder answers "signed out" under that launch (the CLI keeps a folder's sign-in in that folder, not in the Credential Manager that every folder shares). Anything
|
|
283
|
+
* else is `not_isolated`, and nothing is started. A CLI that moves its home with a variable needs neither.
|
|
284
|
+
*/
|
|
285
|
+
async proveIsolated(cli, directory) {
|
|
286
|
+
if (!RemoteAccounts.byArgument(cli))
|
|
287
|
+
return;
|
|
288
|
+
credentialProfileLaunch(this.deps.environment(), cli, directory); // throws a refusal of our own when there is no relative path
|
|
289
|
+
const scratch = join(this.deps.pairingDirectory, ISOLATION_SCRATCH);
|
|
290
|
+
if (!this.deps.isolated || !(await this.deps.isolated(cli, scratch)))
|
|
291
|
+
throw new ProfileOwnershipRefusal(`not_isolated: ${cliName(cli)} could not be shown to keep this account's sign-in in its own folder on this computer, so nothing was started (signing in would replace this Windows user's own login)`, "not_isolated");
|
|
292
|
+
}
|
|
244
293
|
async busyProfile(name) {
|
|
245
294
|
if (this.signInProfile()?.toLowerCase() === name.toLowerCase())
|
|
246
295
|
throw new SignInRefusal(`A sign-in for "${name}" is running; end it first`, "busy");
|
|
@@ -387,7 +436,7 @@ export class RemoteAccounts {
|
|
|
387
436
|
case "signin.status": {
|
|
388
437
|
const input = this.parse(operation, payload);
|
|
389
438
|
this.needSwitch();
|
|
390
|
-
return this.
|
|
439
|
+
return this.signInStatus(input.sessionId);
|
|
391
440
|
}
|
|
392
441
|
case "signin.write": return this.writeCode(this.parse(operation, payload), ctx);
|
|
393
442
|
case "signin.start": return this.startSignIn(this.parse(operation, payload), ctx);
|
|
@@ -413,9 +462,71 @@ export class RemoteAccounts {
|
|
|
413
462
|
throw new RemoteSetupRefusal("The request does not say who asked", "invalid_request");
|
|
414
463
|
return actor;
|
|
415
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* The one place that says which sign-in a request is. A request with a profile name is a NAMED account's: a CLI with named accounts here (Claude Code, Antigravity), in a folder this Runtime
|
|
467
|
+
* creates or created. A request without one is the computer's OWN login, and only a CLI whose spec says it has one (`runtime.signIn` `none` or `both`: Antigravity) is signed in that way; every
|
|
468
|
+
* other CLI needs a name, and a request without it is refused.
|
|
469
|
+
*/
|
|
416
470
|
async startSignIn(input, ctx) {
|
|
417
|
-
|
|
471
|
+
if (input.profile === undefined && isRuntimeDefaultLoginCli(input.cli))
|
|
472
|
+
return this.startDefaultSignIn(input.cli, input, ctx);
|
|
473
|
+
if (input.profile === undefined) {
|
|
474
|
+
this.actorOf(input.actor);
|
|
475
|
+
this.cliOf(input.cli);
|
|
476
|
+
throw new RemoteSetupRefusal("A sign-in names the credential profile it is for", "invalid_request");
|
|
477
|
+
}
|
|
478
|
+
return this.startProfileSignIn({ ...input, profile: input.profile }, ctx);
|
|
479
|
+
}
|
|
480
|
+
/** Common to both: the child is the Runtime's work while it lives, so the update fence waits for it; the watch ends it if the switch goes off. */
|
|
481
|
+
holdSignIn(session, ctx) {
|
|
482
|
+
// The sign-in is the Runtime's work for as long as its child lives: the update fence waits for it. If the Runtime stopped or the connection went
|
|
483
|
+
// while the child was being started, it is ended at once, over the same path as any other end.
|
|
484
|
+
try {
|
|
485
|
+
if (!ctx.alive())
|
|
486
|
+
throw new RemoteSetupRefusal(NOT_AVAILABLE, "failed");
|
|
487
|
+
this.hold = this.deps.enter?.() ?? null;
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
return this.endSignIn(session.id, "closed").catch(() => { }).then(() => { throw error; });
|
|
491
|
+
}
|
|
492
|
+
this.watchSwitch(session.id);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* AGEND-113: Antigravity's default login. `agy acp --login` under the Windows user's own login, with no profile, no folder and no ownership record: the one exception to "named
|
|
496
|
+
* profiles only", and only for this CLI. Everything else is the same as a profile's sign-in, because it is the same `audited` path: the local `accounts` switch, one sign-in at a
|
|
497
|
+
* time on this computer (`exclusive` and the slot), the start-rate limit, the ten-minute timeout and the switch watch, and a record in `audit.jsonl` before and after.
|
|
498
|
+
*/
|
|
499
|
+
async startDefaultSignIn(cli, input, ctx) {
|
|
500
|
+
const actor = this.actorOf(input.actor);
|
|
418
501
|
let executable = null;
|
|
502
|
+
return this.audited("signin", "accounts", actor, { cli }, ctx, {
|
|
503
|
+
exclusive: "signin-start",
|
|
504
|
+
check: async () => {
|
|
505
|
+
// A Google account (subscription) only: no Google Cloud project, no API key.
|
|
506
|
+
if (input.method !== "subscription")
|
|
507
|
+
throw new ProfileOwnershipRefusal(`Only a subscription sign-in is supported for ${cliName(cli)} from AgEnD`, "unsupported");
|
|
508
|
+
await this.settleEndedSignIn();
|
|
509
|
+
this.slot.check();
|
|
510
|
+
executable = await this.deps.find(cli);
|
|
511
|
+
if (!executable)
|
|
512
|
+
throw new SignInRefusal(`${cliName(cli)} is not installed on this computer`, "failed");
|
|
513
|
+
},
|
|
514
|
+
run: async () => {
|
|
515
|
+
const session = await this.slot.start(() => {
|
|
516
|
+
this.gate(ctx, "accounts");
|
|
517
|
+
return new RuntimeSignIn({ command: executable.command, args: executable.args, method: "subscription", cli,
|
|
518
|
+
env: this.deps.environment() }, { ...this.deps.signIn, now: this.deps.now, onTimeout: () => { this.endWithRetry(session.id, "timeout"); } });
|
|
519
|
+
});
|
|
520
|
+
this.meta = { id: session.id, actor, cli };
|
|
521
|
+
await this.holdSignIn(session, ctx);
|
|
522
|
+
return { sessionId: session.id };
|
|
523
|
+
},
|
|
524
|
+
openEnded: true,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
async startProfileSignIn(input, ctx) {
|
|
528
|
+
const actor = this.actorOf(input.actor), cli = this.cliOf(input.cli);
|
|
529
|
+
let executable = null, directory;
|
|
419
530
|
// A sign-in begins by creating the profile when it is new: this is "Add account". The record says so. Nothing is created until every refusal
|
|
420
531
|
// that does not need a change has been made (the slot, the profile's state, the CLI), so refused requests leave no folder behind.
|
|
421
532
|
return this.audited("signin", "accounts", actor, { cli, profile: input.profile }, ctx, {
|
|
@@ -424,10 +535,9 @@ export class RemoteAccounts {
|
|
|
424
535
|
check: async () => {
|
|
425
536
|
// Only a subscription sign-in: a Console sign-in may be kept outside the profile's folder, so a profile could not hold or remove it.
|
|
426
537
|
if (input.method !== "subscription")
|
|
427
|
-
throw new ProfileOwnershipRefusal(SUBSCRIPTION_ONLY
|
|
538
|
+
throw new ProfileOwnershipRefusal(cli === "claude-code" ? SUBSCRIPTION_ONLY : `Only a subscription sign-in is supported for ${cliName(cli)} from AgEnD`, "unsupported");
|
|
428
539
|
await this.settleEndedSignIn();
|
|
429
540
|
this.slot.check();
|
|
430
|
-
let directory;
|
|
431
541
|
try {
|
|
432
542
|
directory = credentialProfileDirectory(this.deps.credentialRoot, cli, input.profile);
|
|
433
543
|
}
|
|
@@ -445,7 +555,8 @@ export class RemoteAccounts {
|
|
|
445
555
|
}
|
|
446
556
|
executable = await this.deps.find(cli);
|
|
447
557
|
if (!executable)
|
|
448
|
-
throw new SignInRefusal(
|
|
558
|
+
throw new SignInRefusal(`${cliName(cli)} is not installed on this computer`, "failed");
|
|
559
|
+
await this.proveIsolated(cli, directory);
|
|
449
560
|
},
|
|
450
561
|
run: async () => {
|
|
451
562
|
const { credentialRoot, pairingDirectory } = this.deps;
|
|
@@ -462,25 +573,19 @@ export class RemoteAccounts {
|
|
|
462
573
|
}
|
|
463
574
|
const directory = await requireOwnedProfile(pairingDirectory, credentialRoot, cli, input.profile, this.deps.ownership);
|
|
464
575
|
// The switch and the connection once more, in the same synchronous step as the child is started (the slot waits before it calls this).
|
|
576
|
+
// The launch of this account: its variable (Claude Code), or the pin and `--app_data_dir <folder>` that go with the sign-in command (Antigravity).
|
|
577
|
+
const launch = credentialProfileLaunch(this.deps.environment(), cli, directory);
|
|
578
|
+
// AGEND-250 (review P2-1): the file an earlier attempt may have left, fingerprinted before this login starts; only a file that differs from it counts as this attempt's sign-in.
|
|
579
|
+
const storeName = RemoteAccounts.byArgument(cli) ? credentialProfileStore(cli) : null;
|
|
580
|
+
const storeBefore = storeName ? fingerprintStore(join(credentialProfileDirectory(credentialRoot, cli, input.profile), storeName)) : null;
|
|
465
581
|
const session = await this.slot.start(() => {
|
|
466
582
|
this.gate(ctx, "accounts");
|
|
467
|
-
return new RuntimeSignIn({ command: executable.command, args: executable.args, method: input.method,
|
|
468
|
-
env:
|
|
583
|
+
return new RuntimeSignIn({ command: executable.command, args: executable.args, profileArgs: launch.args, method: input.method, cli,
|
|
584
|
+
env: launch.env }, { ...this.deps.signIn, now: this.deps.now,
|
|
469
585
|
onTimeout: () => { this.endWithRetry(session.id, "timeout"); } });
|
|
470
586
|
});
|
|
471
|
-
this.meta = { id: session.id, actor, cli, profile: input.profile };
|
|
472
|
-
|
|
473
|
-
// while the child was being started, it is ended at once, over the same path as any other end.
|
|
474
|
-
try {
|
|
475
|
-
if (!ctx.alive())
|
|
476
|
-
throw new RemoteSetupRefusal(NOT_AVAILABLE, "failed");
|
|
477
|
-
this.hold = this.deps.enter?.() ?? null;
|
|
478
|
-
}
|
|
479
|
-
catch (error) {
|
|
480
|
-
await this.endSignIn(session.id, "closed").catch(() => { });
|
|
481
|
-
throw error;
|
|
482
|
-
}
|
|
483
|
-
this.watchSwitch(session.id);
|
|
587
|
+
this.meta = { id: session.id, actor, cli, profile: input.profile, storeBefore };
|
|
588
|
+
await this.holdSignIn(session, ctx);
|
|
484
589
|
return { sessionId: session.id };
|
|
485
590
|
},
|
|
486
591
|
openEnded: true,
|
|
@@ -500,6 +605,25 @@ export class RemoteAccounts {
|
|
|
500
605
|
run: async () => { this.gate(ctx, "accounts"); await session.write(input.input); return { accepted: true }; },
|
|
501
606
|
});
|
|
502
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* `signin.status`, and (AGEND-124) the proof after the fact for a NAMED account of a CLI told its account by an argument: when its command has ended with exit 0, the account's own folder must hold the CLI's
|
|
610
|
+
* sign-in file as a plain file. The pre-flight probe only shows the pin worked for an EMPTY folder while the Windows user was signed in; a CLI that stopped honouring the pin would have kept this login in the
|
|
611
|
+
* Credential Manager, as the Windows user's OWN login. Then the answer carries `isolated: false`, the dashboard ends the sign-in as `not_isolated`, and the record says so.
|
|
612
|
+
*/
|
|
613
|
+
signInStatus(sessionId) {
|
|
614
|
+
const session = this.slot.find(sessionId), status = session.status(), meta = this.meta;
|
|
615
|
+
if (meta && meta.id === sessionId && meta.profile !== undefined && !status.alive && status.exitCode === 0 && isCredentialProfileCli(meta.cli) && RemoteAccounts.byArgument(meta.cli)) {
|
|
616
|
+
const store = credentialProfileStore(meta.cli);
|
|
617
|
+
// AGEND-250 (review P2-1): a plain file that is not the one the attempt began with; an old file left in the folder proves nothing about where this login went.
|
|
618
|
+
const kept = !!store && storeWrittenSince(join(credentialProfileDirectory(this.deps.credentialRoot, meta.cli, meta.profile), store), meta.storeBefore ?? null);
|
|
619
|
+
if (!kept) {
|
|
620
|
+
meta.notIsolated = true;
|
|
621
|
+
meta.signedIn = false;
|
|
622
|
+
return { ...status, isolated: false };
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return status;
|
|
626
|
+
}
|
|
503
627
|
/** While a sign-in is open, look at its switch every few seconds: a switch that was turned off, or that ran out, ends it and says so in the record. */
|
|
504
628
|
watchSwitch(id) {
|
|
505
629
|
this.stopWatching();
|
|
@@ -540,7 +664,7 @@ export class RemoteAccounts {
|
|
|
540
664
|
if (meta && meta.id === sessionId) {
|
|
541
665
|
this.meta = null;
|
|
542
666
|
this.record({ actor: meta.actor, action: "signin", cli: meta.cli, profile: meta.profile, outcome: how === "closed" && meta.signedIn === true ? "ok" : "failed",
|
|
543
|
-
...(how === "closed" ? (meta.signedIn === true ? {} : { reason: "failed" }) : { reason: how === "timeout" ? "timeout" : "switch_off" }) }, false);
|
|
667
|
+
...(how === "closed" ? (meta.signedIn === true ? {} : { reason: meta.notIsolated ? "not_isolated" : "failed" }) : { reason: how === "timeout" ? "timeout" : "switch_off" }) }, false);
|
|
544
668
|
}
|
|
545
669
|
return { closed: true };
|
|
546
670
|
}
|
|
@@ -612,6 +736,46 @@ export class RemoteAccounts {
|
|
|
612
736
|
}
|
|
613
737
|
}
|
|
614
738
|
async check(input, ctx) {
|
|
739
|
+
if (input.profile === undefined && isRuntimeDefaultLoginCli(input.cli))
|
|
740
|
+
return this.checkDefault(input.cli, input, ctx);
|
|
741
|
+
this.gate(ctx, "accounts");
|
|
742
|
+
this.cliOf(input.cli);
|
|
743
|
+
if (input.profile === undefined)
|
|
744
|
+
throw new RemoteSetupRefusal("A check names the credential profile it is for", "invalid_request");
|
|
745
|
+
return this.checkProfile({ cli: input.cli, profile: input.profile }, ctx);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Antigravity's own login: `agy models` read by its exit code, nothing else (no e-mail, no plan). Not recorded, like a profile's check, and bounded the same way. Asked only
|
|
749
|
+
* because a person's request says so: the dashboard's page reads the last detection instead (agy is never started on a read).
|
|
750
|
+
*/
|
|
751
|
+
async checkDefault(cli, input, ctx) {
|
|
752
|
+
this.gate(ctx, "accounts");
|
|
753
|
+
if (this.activeChecks >= MAX_CONCURRENT_CHECKS)
|
|
754
|
+
throw new SignInRefusal("Other account checks are running on this computer; try again in a moment", "busy");
|
|
755
|
+
if (!this.deps.defaultStatus)
|
|
756
|
+
return { loggedIn: null };
|
|
757
|
+
this.activeChecks++;
|
|
758
|
+
try {
|
|
759
|
+
const loggedIn = await this.deps.defaultStatus(cli);
|
|
760
|
+
this.gate(ctx, "accounts");
|
|
761
|
+
if (this.meta && this.meta.cli === cli)
|
|
762
|
+
this.meta.signedIn = loggedIn === true;
|
|
763
|
+
// A yes or a no is the newest word on this login: the Runtime's inventory carries it, and is re-sent BEFORE the answer (as for a profile's check), so that a later report of the cached
|
|
764
|
+
// inventory (a reconnect, another account's change) does not bring back what was true before. "Could not be asked" says nothing and changes nothing.
|
|
765
|
+
if (loggedIn !== null) {
|
|
766
|
+
try {
|
|
767
|
+
this.deps.noteLogin?.(cli, loggedIn);
|
|
768
|
+
}
|
|
769
|
+
catch { /* the answer is still given */ }
|
|
770
|
+
await this.refreshed(ctx);
|
|
771
|
+
}
|
|
772
|
+
return { loggedIn };
|
|
773
|
+
}
|
|
774
|
+
finally {
|
|
775
|
+
this.activeChecks--;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
async checkProfile(input, ctx) {
|
|
615
779
|
this.gate(ctx, "accounts");
|
|
616
780
|
const cli = this.cliOf(input.cli), key = input.profile.toLowerCase();
|
|
617
781
|
if (this.busy.has(key) || this.retained.has(key))
|
|
@@ -627,7 +791,8 @@ export class RemoteAccounts {
|
|
|
627
791
|
// The shared parser already masked the address; check the masked form once more before anything is stored or sent.
|
|
628
792
|
const identity = answer.loggedIn === true && answer.identity ? parseAccountIdentity(answer.identity) : undefined;
|
|
629
793
|
rememberCredentialStatus(this.deps.credentialRoot, cli, input.profile, { loggedIn: answer.loggedIn, ...(identity ? { identity } : {}) });
|
|
630
|
-
|
|
794
|
+
// A sign-in that ended without leaving its file in the account's folder (`notIsolated`) stays failed: a later check that reads "signed in" from a store every folder shares must not turn it into a success.
|
|
795
|
+
if (this.meta && this.meta.profile === input.profile && !this.meta.notIsolated)
|
|
631
796
|
this.meta.signedIn = answer.loggedIn === true;
|
|
632
797
|
await this.refreshed(ctx);
|
|
633
798
|
return { loggedIn: answer.loggedIn, ...(identity ? { identity } : {}) };
|
|
@@ -637,29 +802,43 @@ export class RemoteAccounts {
|
|
|
637
802
|
}
|
|
638
803
|
}
|
|
639
804
|
/**
|
|
640
|
-
* Sign-out.
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
805
|
+
* Sign-out. A request with a profile name signs that NAMED account out; one without signs the computer's OWN login out (`signOutDefault`).
|
|
806
|
+
* A named account: the checks come first (ownership, in use, the CLI, the pace); then, with the folder taken out of reach of a swap (renamed and re-checked, as for a
|
|
807
|
+
* removal), the CLI's own logout runs against the renamed folder (`claude auth logout`) or — for a CLI with none (Antigravity) — the account's token file is removed, the folder is
|
|
808
|
+
* verified again, and the answer is the CLI's own status probe under that folder. So a folder replaced by a junction to the user's own sign-in after the checks is found before anything is
|
|
809
|
+
* run against it or deleted in it. The switch and the connection are looked at again immediately before the logout starts and before the backups or the file go.
|
|
644
810
|
*/
|
|
645
811
|
async signOut(input, ctx) {
|
|
646
|
-
|
|
812
|
+
if (input.profile === undefined)
|
|
813
|
+
return this.signOutDefault(input.cli, input.actor, ctx);
|
|
814
|
+
const profile = input.profile, actor = this.actorOf(input.actor), cli = this.cliOf(input.cli), key = profile.toLowerCase();
|
|
815
|
+
const facts = runtimeFacts(cli, "signOut");
|
|
816
|
+
if (!facts)
|
|
817
|
+
throw new ProfileOwnershipRefusal(`${cliName(cli)} accounts cannot be signed out from AgEnD`, "unsupported");
|
|
647
818
|
let executable = null;
|
|
648
|
-
return this.audited("profile.signout", "accounts", actor, { cli, profile
|
|
819
|
+
return this.audited("profile.signout", "accounts", actor, { cli, profile }, ctx, {
|
|
649
820
|
check: async () => {
|
|
650
|
-
this.paceCheck(
|
|
651
|
-
await requireOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli,
|
|
652
|
-
await this.busyProfile(
|
|
821
|
+
this.paceCheck(profile);
|
|
822
|
+
await requireOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli, profile, this.deps.ownership);
|
|
823
|
+
await this.busyProfile(profile);
|
|
653
824
|
executable = await this.deps.find(cli);
|
|
654
825
|
if (!executable)
|
|
655
|
-
throw new SignInRefusal(
|
|
656
|
-
this.paceMark(
|
|
826
|
+
throw new SignInRefusal(`${cliName(cli)} is not installed on this computer`, "failed");
|
|
827
|
+
this.paceMark(profile);
|
|
657
828
|
},
|
|
658
829
|
run: async () => {
|
|
659
|
-
const answer = await withIsolatedOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli,
|
|
830
|
+
const answer = await withIsolatedOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli, profile, { ...this.deps.ownership, ...(this.deps.report ? { report: this.deps.report } : {}), beforeCommit: () => this.finalLook(ctx, profile, false) }, async (directory, verify) => {
|
|
660
831
|
this.gate(ctx, "accounts");
|
|
832
|
+
if ("remove" in facts) {
|
|
833
|
+
// The sign-in is a file in the account's folder: proven to be this folder (verify), then removed (only a plain file of that exact name), and the CLI is asked.
|
|
834
|
+
await verify();
|
|
835
|
+
this.gate(ctx, "accounts");
|
|
836
|
+
for (const name of facts.remove)
|
|
837
|
+
removeSignInFile(directory, name);
|
|
838
|
+
return this.deps.status(cli, directory);
|
|
839
|
+
}
|
|
661
840
|
try {
|
|
662
|
-
await this.deps.runLogout(executable, [
|
|
841
|
+
await this.deps.runLogout(executable, [...facts.args], withCredentialProfile(this.deps.environment(), cli, directory));
|
|
663
842
|
}
|
|
664
843
|
catch (error) {
|
|
665
844
|
if (error instanceof ProcessNotConfirmedEnded) {
|
|
@@ -675,10 +854,69 @@ export class RemoteAccounts {
|
|
|
675
854
|
deleteProfileBackups(directory);
|
|
676
855
|
return this.deps.status(cli, directory);
|
|
677
856
|
});
|
|
678
|
-
rememberCredentialStatus(this.deps.credentialRoot, cli,
|
|
857
|
+
rememberCredentialStatus(this.deps.credentialRoot, cli, profile, { loggedIn: answer.loggedIn });
|
|
679
858
|
await this.refreshed(ctx);
|
|
680
859
|
if (answer.loggedIn !== false)
|
|
681
|
-
throw new SignInRefusal(`Credential profile "${
|
|
860
|
+
throw new SignInRefusal(`Credential profile "${profile}" is still signed in after sign-out`, "failed");
|
|
861
|
+
return { loggedIn: false };
|
|
862
|
+
},
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* AGEND-124: the computer's OWN login of a CLI that has one (Antigravity), signed out: the Credential Manager entry the registry names (`runtime.signOut.credential`; `cmdkey /delete:<name>` deletes the
|
|
867
|
+
* entry agy's own `/logout` does, measured on a decoy entry), then `agy models` says whether it took. Everything a sign-in of that login needs applies: the local `accounts` switch, no sign-in under way on
|
|
868
|
+
* this computer, one at a time, a pause between two, a record in `audit.jsonl`; and no native task running (it would lose its login under it). The entry's name is the registry's, never the request's.
|
|
869
|
+
*/
|
|
870
|
+
async signOutDefault(cliId, actorId, ctx) {
|
|
871
|
+
const actor = this.actorOf(actorId);
|
|
872
|
+
if (!isRuntimeDefaultLoginCli(cliId)) {
|
|
873
|
+
this.cliOf(cliId);
|
|
874
|
+
throw new RemoteSetupRefusal("A sign-out names the credential profile it is for", "invalid_request");
|
|
875
|
+
}
|
|
876
|
+
const cli = cliId, facts = runtimeFacts(cli, "signOut");
|
|
877
|
+
if (!facts || !("credential" in facts))
|
|
878
|
+
throw new ProfileOwnershipRefusal(`${cliName(cli)}'s own login on a computer cannot be signed out from AgEnD`, "unsupported");
|
|
879
|
+
const paceKey = `${DEFAULT_KEY}${cli}`;
|
|
880
|
+
return this.audited("login.signout", "accounts", actor, { cli }, ctx, {
|
|
881
|
+
exclusive: "signin-start",
|
|
882
|
+
hold: paceKey,
|
|
883
|
+
check: async () => {
|
|
884
|
+
await this.settleEndedSignIn();
|
|
885
|
+
if (this.slot.current())
|
|
886
|
+
throw new SignInRefusal("A sign-in is running on this computer; end it first", "busy");
|
|
887
|
+
if (!this.deps.deleteCredential || !this.deps.defaultStatus)
|
|
888
|
+
throw new ProfileOwnershipRefusal("This Runtime cannot sign this computer's own login out", "unsupported");
|
|
889
|
+
// Asked with `await`: the Runtime reads the computer's boot identity first, so a terminal recorded under an earlier boot is not counted as running.
|
|
890
|
+
if ((await this.deps.taskRunning?.()) !== false)
|
|
891
|
+
throw new ProfileOwnershipRefusal(`A task is running on this computer (or this Runtime could not tell), and it would lose its ${cliName(cli)} login; wait for it to finish`, "in_use");
|
|
892
|
+
const last = this.lastChange.get(paceKey);
|
|
893
|
+
if (last !== undefined && this.now() - last < PROFILE_OP_MIN_GAP_MS)
|
|
894
|
+
throw new SignInRefusal(`${cliName(cli)} was just signed out here; wait a few seconds`, "rate_limited");
|
|
895
|
+
this.lastChange.set(paceKey, this.now());
|
|
896
|
+
},
|
|
897
|
+
run: async () => {
|
|
898
|
+
this.gate(ctx, "accounts");
|
|
899
|
+
if (this.slot.current() || (await this.deps.taskRunning?.()) !== false)
|
|
900
|
+
throw new ProfileOwnershipRefusal("A sign-in or a task started on this computer; nothing was changed", "in_use");
|
|
901
|
+
// 0: deleted. 1: no such entry (already signed out). AGEND-250 (#3771 review P2-3): anything else (could not run, access denied, another exit) is a deletion that did not happen, and is not ignored:
|
|
902
|
+
// `agy models` below could then say "signed out" for a credential that is still there. The ONE reading that proves a sign-out is the explicit "Please sign in" (`defaultStatus`: false).
|
|
903
|
+
const deleted = await this.deps.deleteCredential(facts.credential);
|
|
904
|
+
if (deleted !== 0 && deleted !== 1)
|
|
905
|
+
throw new SignInRefusal(`${cliName(cli)}'s saved sign-in could not be removed from this computer, so it was not signed out`, "failed");
|
|
906
|
+
this.gate(ctx, "accounts");
|
|
907
|
+
const loggedIn = await this.deps.defaultStatus(cli);
|
|
908
|
+
this.gate(ctx, "accounts");
|
|
909
|
+
if (loggedIn !== null) {
|
|
910
|
+
try {
|
|
911
|
+
this.deps.noteLogin?.(cli, loggedIn);
|
|
912
|
+
}
|
|
913
|
+
catch { /* the answer is still given */ }
|
|
914
|
+
}
|
|
915
|
+
await this.refreshed(ctx);
|
|
916
|
+
if (loggedIn === null)
|
|
917
|
+
throw new SignInRefusal(`${cliName(cli)}'s sign-out could not be confirmed (the check did not say it is signed out; is the computer offline?), so it is not reported as signed out`, "failed");
|
|
918
|
+
if (loggedIn !== false)
|
|
919
|
+
throw new SignInRefusal(`${cliName(cli)} is still signed in on this computer after sign-out`, "failed");
|
|
682
920
|
return { loggedIn: false };
|
|
683
921
|
},
|
|
684
922
|
});
|
|
@@ -689,22 +927,25 @@ export class RemoteAccounts {
|
|
|
689
927
|
check: async () => {
|
|
690
928
|
this.paceCheck(input.profile);
|
|
691
929
|
await requireOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli, input.profile, this.deps.ownership);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
fallback
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
930
|
+
// The pairing's default profile is Claude Code's (an Antigravity account has none), so only a Claude profile is held back by it.
|
|
931
|
+
if (cli === "claude-code") {
|
|
932
|
+
let fallback;
|
|
933
|
+
try {
|
|
934
|
+
fallback = this.deps.defaultProfile();
|
|
935
|
+
}
|
|
936
|
+
catch {
|
|
937
|
+
throw new ProfileOwnershipRefusal("This computer could not confirm which credential profile is the default, so nothing was changed. Check that computer's Runtime folder", "unconfirmed");
|
|
938
|
+
}
|
|
939
|
+
if (fallback && fallback.toLowerCase() === input.profile.toLowerCase())
|
|
940
|
+
throw new ProfileOwnershipRefusal(`Credential profile "${input.profile}" is this computer's default for agents; change it there first: agend-runtime profile default NAME`, "default_profile");
|
|
698
941
|
}
|
|
699
|
-
if (fallback && fallback.toLowerCase() === input.profile.toLowerCase())
|
|
700
|
-
throw new ProfileOwnershipRefusal(`Credential profile "${input.profile}" is this computer's default for agents; change it there first: agend-runtime profile default NAME`, "default_profile");
|
|
701
942
|
await this.busyProfile(input.profile);
|
|
702
943
|
this.paceMark(input.profile);
|
|
703
944
|
},
|
|
704
945
|
run: async () => {
|
|
705
946
|
this.gate(ctx, "accounts");
|
|
706
947
|
// The protection (the default profile, tasks, terminals, the switch) is asked again, synchronously, immediately before the rename: `beforeCommit`.
|
|
707
|
-
await removeOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli, input.profile, { ...this.deps.ownership, ...(this.deps.report ? { report: this.deps.report } : {}), beforeCommit: () => this.finalLook(ctx, input.profile, true), beforeDelete: () => this.finalLook(ctx, input.profile, true) });
|
|
948
|
+
await removeOwnedProfile(this.deps.pairingDirectory, this.deps.credentialRoot, cli, input.profile, { ...this.deps.ownership, ...(this.deps.report ? { report: this.deps.report } : {}), beforeCommit: () => this.finalLook(ctx, input.profile, true, cli), beforeDelete: () => this.finalLook(ctx, input.profile, true, cli) });
|
|
708
949
|
await this.refreshed(ctx);
|
|
709
950
|
return { removed: true };
|
|
710
951
|
},
|