oh-my-opencode 5.1.78 → 5.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.de.md +0 -6
  2. package/README.es.md +0 -6
  3. package/README.fr.md +0 -6
  4. package/README.it.md +0 -6
  5. package/README.ja.md +0 -6
  6. package/README.ko.md +0 -5
  7. package/README.md +0 -6
  8. package/README.pt-br.md +0 -6
  9. package/README.ru.md +0 -6
  10. package/README.zh-cn.md +0 -6
  11. package/dist/cli/index.js +809 -302
  12. package/dist/cli/service-auth/commands.d.ts +3 -6
  13. package/dist/cli/service-auth/device-flow.d.ts +9 -1
  14. package/dist/cli/service-auth/device-name.d.ts +3 -3
  15. package/dist/cli/service-auth/devices.d.ts +17 -0
  16. package/dist/cli/service-auth/index.d.ts +5 -3
  17. package/dist/cli/service-auth/keychain-helper/fake-keychain.test-support.d.ts +1 -0
  18. package/dist/cli/service-auth/keystore.d.ts +10 -1
  19. package/dist/cli/service-auth/linux-store-route.d.ts +28 -0
  20. package/dist/cli/service-auth/login-prelude.d.ts +10 -0
  21. package/dist/cli/service-auth/secret-service-lock.d.ts +1 -0
  22. package/dist/cli/service-auth/session.d.ts +6 -5
  23. package/dist/cli/service-auth/state-file-cli.fixture.d.ts +1 -0
  24. package/dist/cli/service-auth/state-file-store.d.ts +38 -0
  25. package/dist/cli-node/index.js +809 -302
  26. package/dist/config/schema/keyword-detector.d.ts +1 -23
  27. package/dist/features/builtin-commands/templates/ulw-execute.d.ts +1 -1
  28. package/dist/hooks/ulw-execute/parse-user-request.d.ts +1 -0
  29. package/dist/hooks/ulw-execute/worktree-block.d.ts +2 -0
  30. package/dist/index.js +1786 -1753
  31. package/dist/skills/browser/runtime/omowright/manifest.json +1 -1
  32. package/dist/skills/programming/SKILL.md +1 -0
  33. package/dist/skills/ulw-execute/SKILL.md +15 -5
  34. package/dist/tools/delegate-task/builtin-categories.d.ts +1 -0
  35. package/dist/tools/delegate-task/categories.d.ts +2 -0
  36. package/dist/tools/delegate-task/category-prompt-append.d.ts +1 -0
  37. package/dist/tools/delegate-task/category-resolution-result.d.ts +15 -0
  38. package/dist/tools/delegate-task/category-resolver.d.ts +1 -14
  39. package/dist/tools/delegate-task/constants.d.ts +1 -1
  40. package/dist/tools/delegate-task/executor.d.ts +1 -1
  41. package/dist/tui.js +82 -67
  42. package/package.json +19 -16
  43. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  44. package/packages/omo-codex/plugin/README.md +1 -1
  45. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +83 -3
  46. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  47. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  48. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  49. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  50. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  51. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  52. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  53. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  54. package/packages/omo-codex/plugin/components/lcx/skills/lcx-doctor/SKILL.md +3 -3
  55. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
  56. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  57. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  58. package/packages/omo-codex/plugin/components/rules/README.md +1 -1
  59. package/packages/omo-codex/plugin/components/rules/dist/cli.js +6 -0
  60. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  61. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  62. package/packages/omo-codex/plugin/components/rules/src/post-compact-budget.ts +6 -0
  63. package/packages/omo-codex/plugin/components/rules/test/hephaestus-model-variant.test.ts +2 -2
  64. package/packages/omo-codex/plugin/components/rules/test/post-compact-budget.test.ts +14 -23
  65. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  66. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  67. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  68. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  69. package/packages/omo-codex/plugin/components/ultrawork/README.md +1 -1
  70. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-clone-fidelity-reviewer.toml +1 -1
  71. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-code-reviewer.toml +1 -1
  72. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +1 -1
  73. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-qa-executor.toml +1 -1
  74. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-high.toml +1 -1
  75. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-low.toml +1 -1
  76. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-worker-medium.toml +1 -1
  77. package/packages/omo-codex/plugin/components/ultrawork/agents/metis.toml +1 -1
  78. package/packages/omo-codex/plugin/components/ultrawork/agents/momus.toml +1 -1
  79. package/packages/omo-codex/plugin/components/ultrawork/agents/plan.toml +1 -1
  80. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  81. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  82. package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook-trigger-policy.test.ts +1 -1
  83. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  84. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  85. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  86. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  87. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  88. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  89. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  90. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  91. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  92. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  93. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  94. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  95. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  96. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  97. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  98. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  99. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  100. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  101. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  102. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  103. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  104. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  105. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  106. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  107. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  108. package/packages/omo-codex/plugin/model-catalog.json +14 -5
  109. package/packages/omo-codex/plugin/package-lock.json +12 -12
  110. package/packages/omo-codex/plugin/package.json +1 -1
  111. package/packages/omo-codex/plugin/scripts/migrate-codex-config/catalog.mjs +14 -5
  112. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
  113. package/packages/omo-codex/plugin/skills/lcx-doctor/SKILL.md +3 -3
  114. package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -0
  115. package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +15 -5
  116. package/packages/omo-codex/plugin/test/aggregate-agents.test.mjs +10 -10
  117. package/packages/omo-codex/plugin/test/aggregate-model-catalog.test.mjs +7 -7
  118. package/packages/omo-codex/plugin/test/auto-update.test.mjs +2 -2
  119. package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +44 -7
  120. package/packages/omo-codex/scripts/install-config-reasoning.test.mjs +3 -3
  121. package/packages/omo-codex/scripts/install-dist/install-local.mjs +85 -5
  122. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
  123. package/packages/shared-skills/skills/programming/SKILL.md +1 -0
  124. package/packages/shared-skills/skills/ulw-execute/SKILL.md +15 -5
@@ -1,11 +1,7 @@
1
1
  import { Command } from "commander";
2
+ import { beginLogin } from "./login-prelude";
2
3
  import { type ListedDevice } from "./protocol";
3
- import { type DeviceServiceHandoff, type Session } from "./session";
4
- /**
5
- * Login order (#6503): refuse a second device from the stored sign-in and the machine's device service before
6
- * `/v1/health`. A logged-out computer is the one that waits on accounts being reachable.
7
- */
8
- export declare function beginLogin(session: Pick<Session, "accessSnapshot" | "request">, deviceService: DeviceServiceHandoff | undefined, api: string): Promise<unknown>;
4
+ import { type DeviceServiceHandoff } from "./session";
9
5
  type Options = {
10
6
  readonly api?: string;
11
7
  readonly accounts?: string;
@@ -18,6 +14,7 @@ type Options = {
18
14
  export type ServiceAuthHooks = {
19
15
  readonly deviceService?: (api: string) => DeviceServiceHandoff;
20
16
  };
17
+ export { beginLogin };
21
18
  export declare function deviceChoices(devices: readonly ListedDevice[]): {
22
19
  value: string;
23
20
  label: string;
@@ -1,10 +1,18 @@
1
- import { type ChooseDevice, type MachineDevice, type Platform } from "./protocol";
1
+ import { type ChooseDevice, type MachineDevice, type Platform, SignInError } from "./protocol";
2
2
  import type { Session } from "./session";
3
3
  export type DisplayCode = {
4
4
  readonly verificationUri: string;
5
5
  readonly userCode: string;
6
6
  readonly matchingCode: string;
7
+ /** When the code stops working (ISO 8601), as the service minted it. */
8
+ readonly expiresAt: string;
7
9
  };
10
+ /** Why a device sign-in stopped: callers branch on the code, never on the message. */
11
+ export type DeviceSignInRefusalCode = "approval_denied" | "approval_expired" | "device_limit" | "replace_unsupported" | "replace_mismatch";
12
+ export declare class DeviceSignInRefused extends SignInError {
13
+ readonly code: DeviceSignInRefusalCode;
14
+ constructor(code: DeviceSignInRefusalCode, message: string);
15
+ }
8
16
  export type DeviceLoginOptions = {
9
17
  readonly name: string;
10
18
  readonly platform: Platform;
@@ -1,9 +1,9 @@
1
1
  import { type Platform } from "./protocol";
2
2
  export declare function deviceName(host?: string): string;
3
3
  /**
4
- * Whether omo generated this device name itself (#13651): the pre-#14044 `omo CLI on <host>` label, the unnamed
5
- * fallback, or the name built from the kernel hostname a Mac registered under before LocalHostName. Any other name is
6
- * one the person chose, and omo never replaces it.
4
+ * Whether omo generated this device name itself (#13651): a pre-#14044 `omo CLI on <host>` or `OmO Desktop on <host>`
5
+ * label, the unnamed fallback, or the name built from the kernel hostname a Mac registered under before LocalHostName.
6
+ * Any other name is one the person chose, and omo never replaces it.
7
7
  */
8
8
  export declare function isGeneratedDeviceName(name: string): boolean;
9
9
  export declare function devicePlatform(): Platform;
@@ -0,0 +1,17 @@
1
+ import type { Session } from "./session";
2
+ /** A device the account still lists as signed in; `current` is the device whose token made the request. */
3
+ export type LiveDevice = {
4
+ readonly id: string;
5
+ readonly name: string;
6
+ readonly kind?: string;
7
+ readonly platform?: string;
8
+ readonly createdAt?: string;
9
+ readonly lastSeenAt?: string;
10
+ readonly machineBound?: boolean;
11
+ /** Whether the device takes part in the account's memory sync; absent when the service is older than the field. */
12
+ readonly syncing?: boolean;
13
+ readonly current: boolean;
14
+ };
15
+ export declare function listLiveDevices(session: Pick<Session, "accessToken" | "request">): Promise<LiveDevice[]>;
16
+ /** Renames a device of this account; the service answers 404 `not_found` for an id the account does not have. */
17
+ export declare function renameDevice(session: Pick<Session, "accessToken" | "request">, id: string, name: string): Promise<void>;
@@ -1,6 +1,8 @@
1
1
  export { accountHome, credentialLockPaths, withCredentialLock } from "./credential-lock";
2
+ export { type LiveDevice, listLiveDevices, renameDevice } from "./devices";
2
3
  export { currentServiceDevice } from "./protocol";
3
- export { CredentialIdentityChanged, type CredentialStore, createCredentialStore, KeychainApprovalPendingError, quietNotice, } from "./keystore";
4
- export { type Credentials, SignInError, serviceOrigin } from "./protocol";
5
- export { type BeforeKeysDiscarded, createSession, type DiscardedCredential, type Session } from "./session";
4
+ export { CredentialIdentityChanged, type CredentialStore, CredentialStoreError, createCredentialStore, KeychainApprovalPendingError, KeychainLockedError, quietNotice, SecretServiceUnavailableError, } from "./keystore";
5
+ export { RecoveryExhausted, RecoveryPending } from "./owned-refresh";
6
+ export { ApiRefusal, type Credentials, RequestFailure, SignInError, serviceOrigin } from "./protocol";
7
+ export { type BeforeKeysDiscarded, createSession, type DiscardedCredential, type Session, SessionEnded, } from "./session";
6
8
  export { retireSyncPinOnDiscard } from "./sync-pin-retire";
@@ -74,6 +74,7 @@ export declare function helperSession(keychain: ReturnType<typeof fakeKeychain>,
74
74
  update<T>(action: (current: Credentials | null) => Promise<T>, options?: {
75
75
  readonly replaceInvalid?: boolean;
76
76
  }): Promise<T>;
77
+ discard: (current: Credentials, cause: "refused" | "forget" | "replaced") => Promise<void>;
77
78
  forget(): Promise<void>;
78
79
  accessSnapshot: () => Promise<Credentials | null>;
79
80
  accountEmail: () => Promise<string | undefined>;
@@ -5,6 +5,7 @@ import { type KeychainHelperOptions } from "./keychain-helper/darwin-backend";
5
5
  import { type WriteIntent } from "./keychain-helper/darwin-store";
6
6
  import { type LockedStore } from "./keychain-helper/store-binding";
7
7
  import { type SecretServiceLockProbe } from "./secret-service-lock";
8
+ import { type KeyringRelation } from "./linux-store-route";
8
9
  type SecretKey = {
9
10
  readonly service: string;
10
11
  readonly name: string;
@@ -17,6 +18,8 @@ export type SecretApi = {
17
18
  readonly delete: (key: SecretKey) => Promise<boolean>;
18
19
  };
19
20
  export type { LockedStore };
21
+ /** Where the stored sign-in lives: the OS store, or the private state file on a Linux machine with no Secret Service. */
22
+ export type CredentialStorage = "keyring" | "file";
20
23
  export type SealedStore<T> = {
21
24
  readonly read: () => Promise<T | null>;
22
25
  /** A read started now that never joins a coalesced read begun earlier; credential transactions use it under the lock. */
@@ -33,6 +36,8 @@ export type SealedStore<T> = {
33
36
  readonly underLock?: (lease: HelperLease) => Promise<LockedStore<T> | null>;
34
37
  /** True while the last read came from an item the helper does not own yet: the token path then takes the lock once. */
35
38
  readonly migrationPending?: () => Promise<boolean>;
39
+ /** Where the last operation found or put the sign-in. */
40
+ readonly storage?: () => CredentialStorage;
36
41
  };
37
42
  export type CredentialStore = SealedStore<Credentials>;
38
43
  export declare class CredentialStoreError extends SignInError {
@@ -82,4 +87,8 @@ export declare function createCredentialStore(api: string, options?: {
82
87
  readonly home?: string;
83
88
  readonly keychainHelper?: KeychainHelperOptions;
84
89
  }): CredentialStore;
85
- export declare function createSealedStore<T>(api: string, namespace: "omo-cli" | "omo-cli-v2" | "omo-cli-revocations-v2", schema: z.ZodType<T>, secrets?: SecretApi | null, platform?: NodeJS.Platform, lockProbe?: SecretServiceLockProbe, notice?: (message: string) => void, wait?: CredentialReadWait, amendWrite?: (previous: T | null, next: T) => T, keychainHelper?: KeychainHelperOptions): SealedStore<T>;
90
+ export declare function createSealedStore<T>(api: string, namespace: "omo-cli" | "omo-cli-v2" | "omo-cli-revocations-v2", schema: z.ZodType<T>, secrets?: SecretApi | null, platform?: NodeJS.Platform, lockProbe?: SecretServiceLockProbe, notice?: (message: string) => void, wait?: CredentialReadWait, amendWrite?: (previous: T | null, next: T) => T, keychainHelper?: KeychainHelperOptions, linux?: {
91
+ readonly home?: string;
92
+ /** Absent, only a byte-identical keyring item counts as the file's own sign-in. */
93
+ readonly relate?: (keyring: T, file: T) => KeyringRelation;
94
+ }): SealedStore<T>;
@@ -0,0 +1,28 @@
1
+ import type { SealedStore } from "./keystore";
2
+ import type { StateFileStore } from "./state-file-store";
3
+ export type OpenKeyringState = "unlocked" | "absent" | "unknown";
4
+ /**
5
+ * What the keyring holds next to a state file: nothing, the same sign-in with a token no fresher than the file's
6
+ * ("older"), the same sign-in with a fresher token ("newer"), or another (or unreadable) sign-in.
7
+ */
8
+ export type KeyringRelation = "empty" | "older" | "newer" | "other";
9
+ /**
10
+ * Where the shared Linux sign-in lives (#7185b): the Secret Service whenever one exists, the private state file only
11
+ * when none is on the session bus (or Bun has no OS store). A probe that cannot answer keeps an existing file in use
12
+ * and otherwise asks libsecret, as before. Once the Secret Service answers unlocked, a state file moves into it under
13
+ * the credential lock, only over an empty slot or an older copy of the same sign-in, and is deleted only after the
14
+ * keyring returned exactly what was written. "No Secret Service" is per process (cron, su, ssh with no session bus), so
15
+ * a file can hold a sign-in written beside one the keyring already holds: that keyring sign-in is never replaced.
16
+ */
17
+ export declare function routeLinuxStore<T>(input: {
18
+ readonly api: string;
19
+ readonly home?: string;
20
+ readonly keyring: SealedStore<T>;
21
+ readonly file: StateFileStore<T>;
22
+ /** Throws for a locked keyring, which never falls back to the file. */
23
+ readonly probe: () => Promise<OpenKeyringState>;
24
+ readonly relation: (text: string) => Promise<KeyringRelation>;
25
+ /** Writes the stored text to the keyring and reads it back; throws, keeping the file, when either step fails. */
26
+ readonly moveToKeyring: (text: string) => Promise<void>;
27
+ readonly notice: (message: string) => void;
28
+ }): SealedStore<T>;
@@ -0,0 +1,10 @@
1
+ import { SignInError } from "./protocol";
2
+ import type { DeviceServiceHandoff, Session } from "./session";
3
+ /** The account service did not answer its health probe, so no sign-in started. */
4
+ export declare class AccountsUnreachable extends SignInError {
5
+ }
6
+ /**
7
+ * Login order (#6503): refuse a second device from the stored sign-in and the machine's device service before
8
+ * `/v1/health`. A logged-out computer is the one that waits on accounts being reachable.
9
+ */
10
+ export declare function beginLogin(session: Pick<Session, "accessSnapshot" | "request">, deviceService: DeviceServiceHandoff | undefined, api: string): Promise<unknown>;
@@ -1,4 +1,5 @@
1
1
  export type SecretServiceLockState = "locked" | "unlocked" | "absent" | "unknown";
2
2
  export type SecretServiceLockProbe = () => Promise<SecretServiceLockState>;
3
3
  export declare const parseLockedReply: (stdout: string) => SecretServiceLockState | null;
4
+ export declare const classifyProbeFailure: (stderr: string) => SecretServiceLockState;
4
5
  export declare const probeSecretServiceLock: SecretServiceLockProbe;
@@ -22,7 +22,7 @@ export type DiscardedCredential = {
22
22
  readonly kind: "unreadable";
23
23
  };
24
24
  export type BeforeKeysDiscarded = ((discarded: DiscardedCredential) => Promise<void>) & {
25
- /** Whether a sign-in that names no account should have it read before logout revokes the device. */
25
+ /** Whether a sign-in that names no account should have it read from the service before its keys are discarded. */
26
26
  readonly wantsAccount?: () => Promise<boolean>;
27
27
  };
28
28
  /**
@@ -53,7 +53,6 @@ export type DeviceServiceHandoff = {
53
53
  */
54
54
  readonly machineDevice?: () => Promise<MachineDeviceState>;
55
55
  };
56
- export declare const discardedOf: (credentials: Credentials, cause: "refused" | "forget" | "logout" | "replaced") => DiscardedCredential;
57
56
  export declare function createSession(options: {
58
57
  readonly api: string;
59
58
  readonly store: CredentialStore;
@@ -83,10 +82,12 @@ export declare function createSession(options: {
83
82
  update<T>(action: (current: Credentials | null) => Promise<T>, options?: {
84
83
  readonly replaceInvalid?: boolean;
85
84
  }): Promise<T>;
85
+ /** The hook for a principal a caller discards inside `update` (`omo account forget --device`, `adopt --replace`). */
86
+ discard: (current: Credentials, cause: "refused" | "forget" | "replaced") => Promise<void>;
86
87
  /**
87
- * Deletes the item without reading it (a corrupt or locked item must still be removable, with one
88
- * native call), so it cannot name the account whose pin to retire: `omo account forget --device`
89
- * and `logout` read first and retire; this one leaves the pin (a stale pin is harmless for keys).
88
+ * Every sign-out retires the pin of the account it signs out of (#12308): the item is read first to name it. An item
89
+ * that cannot be read (corrupt, or a store that fails the read) is still deleted, and once it is gone its pin is
90
+ * reported left with one line; a delete that fails too (a locked store) discarded nothing and reports only its error.
90
91
  */
91
92
  forget(): Promise<void>;
92
93
  accessSnapshot: () => Promise<Credentials | null>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { type Stats } from "node:fs";
2
+ import type { SealedStore } from "./keystore";
3
+ export type StateFileRefusal = "dir-not-a-directory" | "dir-other-owner" | "dir-open" | "symlink" | "not-a-file" | "other-owner" | "open";
4
+ /** The file or its directory is not private to this user: it is never used and never written to. */
5
+ export declare class StateFileRefused extends Error {
6
+ readonly refusal: StateFileRefusal;
7
+ constructor(refusal: StateFileRefusal);
8
+ }
9
+ export declare const stateFileDirectory: (home: string) => string;
10
+ /** The directory's own entry (never followed): a real directory of this user nobody else can enter. */
11
+ export declare const dirRefusal: (stat: Stats, uid: number) => StateFileRefusal | undefined;
12
+ /** The opened file itself: a regular file of this user nobody else can read or write. */
13
+ export declare const fileRefusal: (stat: Stats, uid: number) => StateFileRefusal | undefined;
14
+ /**
15
+ * Replaces the file atomically: a temp file created 0600 (never wider, whatever the umask) in the same private dir,
16
+ * written and synced, then renamed over the old one, then the dir synced. A refused dir is never written to.
17
+ */
18
+ export declare function writeStateFile(dir: string, name: string, contents: string, uid: number): Promise<void>;
19
+ export type StateFileStore<T> = SealedStore<T> & {
20
+ /** The stored text as written, or null when there is none or it was refused (one line, never its content). */
21
+ readonly text: () => Promise<string | null>;
22
+ /** True while any entry sits at the file's path, refused or not. */
23
+ readonly present: () => Promise<boolean>;
24
+ readonly directory: () => string;
25
+ };
26
+ export declare function createStateFileStore<T>(input: {
27
+ readonly api: string;
28
+ readonly name: string;
29
+ /** The credential lock's home; the file sits beside the lock, so every process of this user meets on both. */
30
+ readonly home?: string;
31
+ readonly codec: {
32
+ readonly parse: (text: string) => T;
33
+ readonly serialize: (value: T) => string;
34
+ readonly amend?: (previous: string | null, next: T) => T;
35
+ };
36
+ readonly failure: (message: string) => Error;
37
+ readonly log?: (line: string) => void;
38
+ }): StateFileStore<T>;