@cortexkit/opencode-antigravity-auth 3.0.15 → 3.0.17

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 (84) hide show
  1. package/dist/cli.js +26740 -24394
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +549 -452
  4. package/dist/index.js +34088 -31689
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +608 -550
  7. package/dist/server.js +28837 -26421
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/__fixtures__/account-store-process.d.ts +2 -0
  11. package/dist/src/__fixtures__/account-store-process.d.ts.map +1 -0
  12. package/dist/src/__fixtures__/account-store-process.js +163 -0
  13. package/dist/src/__fixtures__/account-store-process.js.map +1 -0
  14. package/dist/src/cli.d.ts +22 -6
  15. package/dist/src/cli.d.ts.map +1 -1
  16. package/dist/src/cli.js +157 -9
  17. package/dist/src/cli.js.map +1 -1
  18. package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +13 -0
  19. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +159 -7
  20. package/dist/src/common-auth-embedded/pi-slot/lock.js +26 -1
  21. package/dist/src/common-auth-embedded/source-output.json +15 -15
  22. package/dist/src/ga/server/index.js +2 -2
  23. package/dist/src/ga/server/index.js.map +1 -1
  24. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  25. package/dist/src/plugin/ga-location-services.d.ts +2 -0
  26. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  27. package/dist/src/plugin/ga-location-services.js +3 -1
  28. package/dist/src/plugin/ga-location-services.js.map +1 -1
  29. package/dist/src/plugin/index.d.ts.map +1 -1
  30. package/dist/src/plugin/index.js +2 -2
  31. package/dist/src/plugin/index.js.map +1 -1
  32. package/dist/src/plugin/storage.d.ts +21 -0
  33. package/dist/src/plugin/storage.d.ts.map +1 -1
  34. package/dist/src/plugin/storage.js +103 -12
  35. package/dist/src/plugin/storage.js.map +1 -1
  36. package/dist/src/process-heartbeat.d.ts +33 -9
  37. package/dist/src/process-heartbeat.d.ts.map +1 -1
  38. package/dist/src/process-heartbeat.js +161 -61
  39. package/dist/src/process-heartbeat.js.map +1 -1
  40. package/dist/src/runtime-layout.d.ts +82 -1
  41. package/dist/src/runtime-layout.d.ts.map +1 -1
  42. package/dist/src/runtime-layout.js +415 -21
  43. package/dist/src/runtime-layout.js.map +1 -1
  44. package/dist/src/runtime-paths.d.ts +93 -9
  45. package/dist/src/runtime-paths.d.ts.map +1 -1
  46. package/dist/src/runtime-paths.js +153 -15
  47. package/dist/src/runtime-paths.js.map +1 -1
  48. package/dist/src/setup.d.ts.map +1 -1
  49. package/dist/src/setup.js +35 -7
  50. package/dist/src/setup.js.map +1 -1
  51. package/dist/src/vault-folder.d.ts +2 -0
  52. package/dist/src/vault-folder.d.ts.map +1 -1
  53. package/dist/src/vault-folder.js +8 -1
  54. package/dist/src/vault-folder.js.map +1 -1
  55. package/dist/src/version-fence.d.ts +37 -0
  56. package/dist/src/version-fence.d.ts.map +1 -1
  57. package/dist/src/version-fence.js +131 -12
  58. package/dist/src/version-fence.js.map +1 -1
  59. package/dist/tui-build-map.json +1 -1
  60. package/dist/tui-ga-build-map.json +1 -1
  61. package/dist/types/src/cli.d.ts +22 -6
  62. package/dist/types/src/cli.d.ts.map +1 -1
  63. package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +13 -0
  64. package/dist/types/src/plugin/ga-location-services.d.ts +2 -0
  65. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  66. package/dist/types/src/plugin/index.d.ts.map +1 -1
  67. package/dist/types/src/plugin/storage.d.ts +21 -0
  68. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  69. package/dist/types/src/process-heartbeat.d.ts +33 -9
  70. package/dist/types/src/process-heartbeat.d.ts.map +1 -1
  71. package/dist/types/src/runtime-layout.d.ts +82 -1
  72. package/dist/types/src/runtime-layout.d.ts.map +1 -1
  73. package/dist/types/src/runtime-paths.d.ts +93 -9
  74. package/dist/types/src/runtime-paths.d.ts.map +1 -1
  75. package/dist/types/src/setup.d.ts.map +1 -1
  76. package/dist/types/src/vault-folder.d.ts +2 -0
  77. package/dist/types/src/vault-folder.d.ts.map +1 -1
  78. package/dist/types/src/version-fence.d.ts +37 -0
  79. package/dist/types/src/version-fence.d.ts.map +1 -1
  80. package/package.json +3 -3
  81. package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +13 -0
  82. package/src/common-auth-embedded/fs/refresh-file-lock.js +159 -7
  83. package/src/common-auth-embedded/pi-slot/lock.js +26 -1
  84. package/src/common-auth-embedded/source-output.json +15 -15
@@ -14,7 +14,8 @@
14
14
  import { appendFileSync, copyFileSync, existsSync, promises as fs, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
15
15
  import { homedir } from 'node:os';
16
16
  import { dirname, join, resolve } from 'node:path';
17
- import { AccountStorageUnreadableError, assertLegacyAccountStorageWritable, clearAccountStorage as coreClearAccountStorage, deduplicateAccountsByEmail as coreDeduplicateAccountsByEmail, loadAccountStorage as coreLoadAccountStorage, mergeAccountStorage as coreMergeAccountStorage, migrateV2ToV3 as coreMigrateV2ToV3, mutateAccountStorage as coreMutateAccountStorage, saveAccountStorage as coreSaveAccountStorage, saveAccountStorageReplace as coreSaveAccountStorageReplace, initializeFreshAccountStore, readAccountStoreAdmission, readAccountStoreBinding, } from '@cortexkit/antigravity-auth-core';
17
+ import { AccountStorageUnreadableError, accountStorePointerPath, assertLegacyAccountStorageWritable, clearAccountStorage as coreClearAccountStorage, deduplicateAccountsByEmail as coreDeduplicateAccountsByEmail, loadAccountStorage as coreLoadAccountStorage, mergeAccountStorage as coreMergeAccountStorage, migrateV2ToV3 as coreMigrateV2ToV3, mutateAccountStorage as coreMutateAccountStorage, saveAccountStorage as coreSaveAccountStorage, saveAccountStorageReplace as coreSaveAccountStorageReplace, initializeFreshAccountStore, readAccountStoreAdmission, readAccountStoreBinding, } from '@cortexkit/antigravity-auth-core';
18
+ import { decidedAccountStoreAnchor, decidedRuntimeLayout, readForwardedAccountStore, runtimeLayoutLocation, stateHomeAccountFile, } from '../runtime-paths';
18
19
  import { createLogger } from './logger';
19
20
  const log = createLogger('storage');
20
21
  /**
@@ -204,6 +205,40 @@ function migrateLegacyWindowsConfig() {
204
205
  return false;
205
206
  }
206
207
  }
208
+ /**
209
+ * Picks the Windows anchor that owns the accounts, without moving anything.
210
+ *
211
+ * A migrated store is found by its pointer file at either anchor, not only
212
+ * by the presence of the pool file: the migration retires the pool file, so
213
+ * after a migration at the `%APPDATA%\opencode` anchor no pool file is left
214
+ * to fall back on. The `%APPDATA%\opencode` anchor wins when only it
215
+ * publishes a store, the config anchor wins when only it does, and pointers
216
+ * at both anchors refuse instead of silently picking one. When neither
217
+ * anchor publishes a store, the unmigrated pool file still decides, exactly
218
+ * as before (missing at the config anchor but present at the legacy anchor
219
+ * means the legacy anchor).
220
+ *
221
+ * `legacyAccountFile()` in `runtime-paths.ts` shares this resolution for
222
+ * read paths that must not move files.
223
+ */
224
+ export function resolveWindowsAccountAnchor(newPath, legacyPath) {
225
+ const standard = resolve(newPath);
226
+ const legacy = resolve(legacyPath);
227
+ // The two spellings can name one file: OPENCODE_CONFIG_DIR may point at
228
+ // the legacy folder, and Windows volumes are usually case-insensitive.
229
+ if (standard.toLowerCase() === legacy.toLowerCase())
230
+ return newPath;
231
+ const standardPointer = existsSync(accountStorePointerPath(standard));
232
+ const legacyPointer = existsSync(accountStorePointerPath(legacy));
233
+ if (standardPointer && legacyPointer) {
234
+ throw new Error(`Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`);
235
+ }
236
+ if (legacyPointer && !standardPointer)
237
+ return legacyPath;
238
+ if (!existsSync(standard) && existsSync(legacy))
239
+ return legacyPath;
240
+ return newPath;
241
+ }
207
242
  /**
208
243
  * Gets the storage path, migrating from legacy Windows location if needed.
209
244
  * On Windows, attempts to move legacy config to new path for alignment.
@@ -212,21 +247,73 @@ function getStoragePathWithMigration() {
212
247
  const newPath = join(getConfigDir(), 'antigravity-accounts.json');
213
248
  if (process.platform === 'win32') {
214
249
  migrateLegacyWindowsConfig();
215
- if (!existsSync(newPath)) {
216
- const legacyPath = join(getLegacyWindowsConfigDir(), 'antigravity-accounts.json');
217
- if (existsSync(legacyPath)) {
218
- log.info('Using legacy Windows config path (migration failed)', {
219
- legacyPath,
220
- newPath,
221
- });
222
- return legacyPath;
223
- }
250
+ const legacyPath = join(getLegacyWindowsConfigDir(), 'antigravity-accounts.json');
251
+ const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
252
+ if (resolve(anchored).toLowerCase() !== resolve(newPath).toLowerCase() &&
253
+ !existsSync(accountStorePointerPath(resolve(anchored)))) {
254
+ log.info('Using legacy Windows config path (migration failed)', {
255
+ legacyPath,
256
+ newPath,
257
+ });
224
258
  }
259
+ return anchored;
225
260
  }
226
261
  return newPath;
227
262
  }
263
+ /**
264
+ * The account file path for a store kept in the state-home folder: the same
265
+ * file name in the state-home folder this config folder's vault files live
266
+ * in, spelled with that folder's real path (the store refuses a path whose
267
+ * folder goes through a link, and the state home often does).
268
+ */
269
+ function stateHomeStoragePath() {
270
+ return stateHomeAccountFile(runtimeLayoutLocation());
271
+ }
272
+ /** Locate vault files without inspecting a possibly unauthorized account store. */
273
+ export function accountFileForVault(configDir = getConfigDir()) {
274
+ const configured = join(configDir, 'antigravity-accounts.json');
275
+ if (process.platform !== 'win32')
276
+ return configured;
277
+ const legacyDir = getLegacyWindowsConfigDir();
278
+ if (resolve(configDir).toLowerCase() === resolve(legacyDir).toLowerCase())
279
+ return configured;
280
+ const configuredVault = join(configDir, 'antigravity-auth-vault');
281
+ const legacyVault = join(legacyDir, 'antigravity-auth-vault');
282
+ const configuredPresent = existsSync(configuredVault);
283
+ const legacyPresent = existsSync(legacyVault);
284
+ if (configuredPresent && legacyPresent)
285
+ throw new Error(`Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`);
286
+ return legacyPresent
287
+ ? join(legacyDir, 'antigravity-accounts.json')
288
+ : configured;
289
+ }
290
+ /** Finish a vault-only start's store decision before its first local opening. */
291
+ export async function prepareLocalAccountStore() {
292
+ if (!decidedRuntimeLayout(runtimeLayoutLocation()))
293
+ return;
294
+ const { prepareAccountStore } = await import('../runtime-layout');
295
+ const { pluginPackageVersion } = await import('../process-heartbeat');
296
+ if ((await prepareAccountStore({ version: await pluginPackageVersion() })) ===
297
+ undefined)
298
+ throw new Error('Vault enrollment does not authorize local account access');
299
+ }
228
300
  export function getStoragePath() {
229
- return getStoragePathWithMigration();
301
+ // `prepareAccountStore` settles the anchor under the layout lock after
302
+ // checking local authority. A decided anchor never switches in this process.
303
+ const anchor = decidedAccountStoreAnchor(runtimeLayoutLocation());
304
+ if (anchor === 'state-home')
305
+ return stateHomeStoragePath();
306
+ if (anchor === 'config')
307
+ return getStoragePathWithMigration();
308
+ const location = runtimeLayoutLocation();
309
+ // A prepared vault-only process has not authorized any store inspection.
310
+ // Its first local opening prepares the store before resolving the path.
311
+ if (decidedRuntimeLayout(location))
312
+ return join(location.configDir, 'antigravity-accounts.json');
313
+ // Standalone callers follow a published forward. Unmigrated Windows pool
314
+ // files retain their existing move into the configured config folder.
315
+ const configPath = getStoragePathWithMigration();
316
+ return readForwardedAccountStore(configPath)?.legacyPath ?? configPath;
230
317
  }
231
318
  /**
232
319
  * Gets the config directory path. Exported for use by other modules.
@@ -286,6 +373,8 @@ function refusalMessage(admission) {
286
373
  * canonical binding read (no second pointer or journal decoder here).
287
374
  */
288
375
  async function bindingOf(options) {
376
+ if (options.legacyPath === undefined)
377
+ await prepareLocalAccountStore();
289
378
  const now = options.now ?? (() => Date.now());
290
379
  const legacyPath = resolve(options.legacyPath ?? getStoragePath());
291
380
  return {
@@ -393,7 +482,9 @@ export async function openAccountStoreForRecovery(options) {
393
482
  * `initializeFreshAccountStore` refuses
394
483
  * when a pool file exists or appears, or when unrelated store files exist.
395
484
  */
396
- export function initializeFreshAccountStoreFor(modules, options = {}) {
485
+ export async function initializeFreshAccountStoreFor(modules, options = {}) {
486
+ if (options.legacyPath === undefined)
487
+ await prepareLocalAccountStore();
397
488
  return initializeFreshAccountStore(modules, {
398
489
  legacyPath: resolve(options.legacyPath ?? getStoragePath()),
399
490
  now: options.now ?? (() => Date.now()),
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/plugin/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,EACV,QAAQ,IAAI,EAAE,EACd,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAclD,OAAO,EAIL,6BAA6B,EAK7B,kCAAkC,EAElC,mBAAmB,IAAI,uBAAuB,EAC9C,0BAA0B,IAAI,8BAA8B,EAC5D,kBAAkB,IAAI,sBAAsB,EAC5C,mBAAmB,IAAI,uBAAuB,EAC9C,aAAa,IAAI,iBAAiB,EAClC,oBAAoB,IAAI,wBAAwB,EAChD,kBAAkB,IAAI,sBAAsB,EAC5C,yBAAyB,IAAI,6BAA6B,EAC1D,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,GAAG,GAAG,YAAY,CAAC,SAAS,CAAC,CAAA;AA0BnC;;;;;;;GAOG;AACH,OAAO,EAAE,6BAA6B,EAAE,CAAA;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,8BAA8B,CAAA;AACxE,MAAM,CAAC,MAAM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AC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;QAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CACpC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,KAAK,YAAY,CAC3C,CAAA;QACD,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,OAAO,OAAO,CAAA;QAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACpC,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAA;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,CAAC,OAAO;YAAE,OAAO,OAAO,CAAA;QAC5B,MAAM,GAAG,MAAM,CAAA;QACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;QAC9B,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type HeartbeatStoreRecord } from './runtime-paths.js';
1
2
  /** Where one process keeps one config folder's runtime files. */
2
3
  export type ProcessLayout = 'legacy' | 'state-home';
3
4
  export interface ProcessHeartbeat {
@@ -6,6 +7,12 @@ export interface ProcessHeartbeat {
6
7
  startedAt: number;
7
8
  /** Config folder key (`processConfigFolderKey()`) to its layout. */
8
9
  layouts: Record<string, ProcessLayout>;
10
+ /**
11
+ * Config folder key to where that folder's account store is kept, for a
12
+ * process that decided. Absent from a heartbeat of a version that predates
13
+ * the store move.
14
+ */
15
+ stores?: Record<string, HeartbeatStoreRecord>;
9
16
  }
10
17
  /**
11
18
  * The heartbeat directory, resolved the same way as the RPC directory:
@@ -37,16 +44,17 @@ export interface ProcessHeartbeatHandle {
37
44
  release(): Promise<void>;
38
45
  }
39
46
  /**
40
- * Record this process as running `version`, with `layouts` added to the
41
- * layouts it already holds. Never throws: a failed write is logged at warn
42
- * and tried again at the next owner start. The file is written only when
43
- * this process has not written it yet or its layouts changed, so later
47
+ * Record this process as running `version`, with `layouts` and `stores`
48
+ * added to what it already holds. Never throws: a failed write is logged at
49
+ * warn and tried again at the next owner start. The file is written only
50
+ * when this process has not written it yet or its records changed, so later
44
51
  * owners of a process whose file is current write nothing.
45
52
  */
46
53
  export declare function startProcessHeartbeat(input: {
47
54
  version: string;
48
55
  logger: HeartbeatLogger;
49
56
  layouts?: Record<string, ProcessLayout>;
57
+ stores?: Record<string, HeartbeatStoreRecord>;
50
58
  now?: () => number;
51
59
  pid?: number;
52
60
  dir?: string;
@@ -58,11 +66,11 @@ export declare function startProcessHeartbeat(input: {
58
66
  */
59
67
  export declare function removeProcessHeartbeat(logger: HeartbeatLogger): Promise<void>;
60
68
  /**
61
- * Record which layout this process uses for one config folder. A `legacy`
62
- * choice is written to the heartbeat file at once, because another process
63
- * deciding whether it may move the files reads it; the caller makes the
64
- * choice and this write while it holds the layout lock. A `state-home`
65
- * choice only goes into the next heartbeat write. Throws when the write
69
+ * Record which layout this process uses for one config folder and write the
70
+ * heartbeat at once, because another process deciding whether it may move
71
+ * the files reads it. A start makes the choice and this write while it holds
72
+ * the layout lock, so a process deciding later sees it; a start whose vault
73
+ * files moved long ago records it without that lock. Throws when the write
66
74
  * fails, unlike `startProcessHeartbeat`.
67
75
  */
68
76
  export declare function recordProcessLayout(input: {
@@ -73,6 +81,22 @@ export declare function recordProcessLayout(input: {
73
81
  pid?: number;
74
82
  dir?: string;
75
83
  }): Promise<void>;
84
+ /**
85
+ * Record where this process keeps one config folder's account store (see
86
+ * `HeartbeatStoreRecord` in `runtime-paths.ts`) and write the heartbeat at
87
+ * once, because a process deciding whether it may move the store reads it.
88
+ * A start makes the choice and this write while it holds the layout lock, so
89
+ * a process deciding later sees it. Throws when the write fails, unlike
90
+ * `startProcessHeartbeat`.
91
+ */
92
+ export declare function recordProcessAnchor(input: {
93
+ key: string;
94
+ anchor: HeartbeatStoreRecord;
95
+ version: string;
96
+ now?: () => number;
97
+ pid?: number;
98
+ dir?: string;
99
+ }): Promise<void>;
76
100
  /** This plugin's version, from its package manifest. */
77
101
  export declare function pluginPackageVersion(): Promise<string>;
78
102
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"process-heartbeat.d.ts","sourceRoot":"","sources":["../../src/process-heartbeat.ts"],"names":[],"mappings":"AAqCA,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,YAAY,CAAA;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAG5C;AAED,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAoB,EACzB,GAAG,GAAE,MAA8B,GAClC,MAAM,CAER;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAO/C;AA0DD,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;CAC/D;AAED,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AA6BD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACvC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,GAAG,CAAC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ACrB,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhB;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhB;AAoDD,wDAAwD;AACxD,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,sBAAsB,CAAC,CAkBjC;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,+DAA+D;AAC/D,wBAAgB,8BAA8B,IAAI,IAAI,CAOrD"}
@@ -17,22 +17,29 @@
17
17
  // folder itself (`legacy`) or in the state home (`state-home`), see
18
18
  // `runtime-paths.ts`. A process that has not decided records `legacy` (or
19
19
  // no layout at all when it cannot read its own package manifest, which the
20
- // move also treats as blocking). A
21
- // process that runs on the legacy layout keeps its file until it exits, even
22
- // after its last owner released it, because its paths stay fixed for its
23
- // whole life and the move must wait for it.
20
+ // move also treats as blocking). A process that runs on the legacy layout
21
+ // keeps its file until it exits, even after its last owner released it,
22
+ // because its paths stay fixed for its whole life and the move must wait for
23
+ // it.
24
24
  //
25
- // One write is not best-effort: `recordProcessLayout` records a `legacy`
26
- // decision while the deciding process holds the layout lock, and throws when
27
- // that write fails, because a process on the old files that other processes
28
- // cannot see must not start.
25
+ // `stores` sits beside `layouts` and records, per config folder, where the
26
+ // account store is kept: `config` (OpenCode's config folder) or `state-home`
27
+ // (`runtime-paths.ts`). A process that has not decided records `config`.
28
+ // Versions that predate the store move ignore the field, and a store move
29
+ // refuses to run while any live process still names `config`, so a process
30
+ // that keeps the old anchor is never bypassed.
31
+ //
32
+ // One write is not best-effort: `recordProcessLayout` and
33
+ // `recordProcessAnchor` record a decision while the deciding process holds
34
+ // the layout lock, and throw when that write fails, because a process on the
35
+ // old files that other processes cannot see must not start.
29
36
  import { randomUUID } from 'node:crypto';
30
37
  import { realpathSync, rmSync } from 'node:fs';
31
38
  import { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
32
39
  import { homedir } from 'node:os';
33
40
  import { join, resolve } from 'node:path';
34
41
  import { getConfigDir } from './plugin/storage';
35
- import { decidedRuntimeLayout, runtimeLayoutLocation } from './runtime-paths';
42
+ import { decidedAccountStoreAnchor, decidedRuntimeLayout, runtimeLayoutLocation, } from './runtime-paths';
36
43
  /**
37
44
  * The heartbeat directory, resolved the same way as the RPC directory:
38
45
  * `$XDG_STATE_HOME/cortexkit/antigravity-auth/processes`, with
@@ -69,6 +76,7 @@ const shared = globalState[stateKey] ?? {
69
76
  owners: 0,
70
77
  startedAt: undefined,
71
78
  layouts: new Map(),
79
+ stores: new Map(),
72
80
  writtenPath: undefined,
73
81
  writtenLayouts: undefined,
74
82
  exitHookInstalled: false,
@@ -77,12 +85,37 @@ globalState[stateKey] = shared;
77
85
  function layoutsRecord() {
78
86
  return Object.fromEntries(shared.layouts);
79
87
  }
88
+ /**
89
+ * `stores` for the heartbeat. Empty when no anchor is decided: a heartbeat
90
+ * with no `stores` is what a version before the store move writes, and a
91
+ * store move treats a live one as still using the config folder.
92
+ */
93
+ function storesRecord() {
94
+ return Object.fromEntries(shared.stores);
95
+ }
96
+ /** What the process's file should say, to tell whether it is current. */
97
+ function recordSignature() {
98
+ return JSON.stringify([layoutsRecord(), storesRecord()]);
99
+ }
80
100
  function holdsLegacyLayout() {
81
101
  for (const layout of shared.layouts.values())
82
102
  if (layout === 'legacy')
83
103
  return true;
84
104
  return false;
85
105
  }
106
+ /**
107
+ * A process keeps its heartbeat until it exits when its paths stay fixed for
108
+ * its whole life: the legacy vault layout, or the config-folder account
109
+ * store. The store move waits for it either way.
110
+ */
111
+ function holdsFixedOldPaths() {
112
+ if (holdsLegacyLayout())
113
+ return true;
114
+ for (const anchor of shared.stores.values())
115
+ if (anchor === 'config')
116
+ return true;
117
+ return false;
118
+ }
86
119
  // Remove the file when the process exits, where Node still runs exit
87
120
  // handlers. A process killed outright leaves the file; its dead pid then
88
121
  // counts as absent.
@@ -101,10 +134,32 @@ function installExitHook() {
101
134
  }
102
135
  });
103
136
  }
137
+ /**
138
+ * A heartbeat write that failed: the folder could not be created or kept
139
+ * private, or the temporary file could not be written or renamed into place.
140
+ * Raised by `recordProcessLayout` and `recordProcessAnchor` callers, which
141
+ * must not run on the old paths unregistered; `startProcessHeartbeat` logs a
142
+ * failed write instead. A failed attempt publishes no heartbeat file.
143
+ */
144
+ class HeartbeatWriteFailure extends Error {
145
+ constructor(cause) {
146
+ super(errorText(cause));
147
+ this.name = 'HeartbeatWriteFailure';
148
+ }
149
+ }
104
150
  async function writeHeartbeatFile(dir, heartbeat) {
105
- await mkdir(dir, { recursive: true, mode: 0o700 });
106
- // mkdir's mode does not apply to a directory that already exists.
107
- await chmod(dir, 0o700);
151
+ try {
152
+ await mkdir(dir, { recursive: true, mode: 0o700 });
153
+ // mkdir's mode does not apply to a directory that already exists.
154
+ await chmod(dir, 0o700);
155
+ }
156
+ catch (error) {
157
+ // One heartbeat folder serves the whole plugin. A process whose
158
+ // heartbeat cannot be written also cannot keep its account store or
159
+ // vault files under that path, so nothing is recorded and the decision's
160
+ // caller learns it through its own write.
161
+ throw new HeartbeatWriteFailure(error);
162
+ }
108
163
  const target = processHeartbeatPath(heartbeat.pid, dir);
109
164
  // Written to a temporary name and renamed into place, so a reader never
110
165
  // sees a half-written file.
@@ -125,10 +180,10 @@ function errorText(error) {
125
180
  return error instanceof Error ? error.message : String(error);
126
181
  }
127
182
  /**
128
- * Record this process as running `version`, with `layouts` added to the
129
- * layouts it already holds. Never throws: a failed write is logged at warn
130
- * and tried again at the next owner start. The file is written only when
131
- * this process has not written it yet or its layouts changed, so later
183
+ * Record this process as running `version`, with `layouts` and `stores`
184
+ * added to what it already holds. Never throws: a failed write is logged at
185
+ * warn and tried again at the next owner start. The file is written only
186
+ * when this process has not written it yet or its records changed, so later
132
187
  * owners of a process whose file is current write nothing.
133
188
  */
134
189
  export async function startProcessHeartbeat(input) {
@@ -138,31 +193,17 @@ export async function startProcessHeartbeat(input) {
138
193
  shared.owners++;
139
194
  for (const [key, layout] of Object.entries(input.layouts ?? {}))
140
195
  shared.layouts.set(key, layout);
141
- const target = processHeartbeatPath(pid, dir);
142
- const layouts = layoutsRecord();
143
- const signature = JSON.stringify(layouts);
196
+ for (const [key, anchor] of Object.entries(input.stores ?? {}))
197
+ shared.stores.set(key, anchor);
144
198
  let path;
145
- if (shared.writtenPath === target && shared.writtenLayouts === signature) {
146
- path = target;
199
+ try {
200
+ path = await writeCurrentRecords(dir, pid, input.version);
147
201
  }
148
- else {
149
- try {
150
- path = await writeHeartbeatFile(dir, {
151
- pid,
152
- version: input.version,
153
- startedAt: shared.startedAt,
154
- layouts,
155
- });
156
- shared.writtenPath = path;
157
- shared.writtenLayouts = signature;
158
- installExitHook();
159
- }
160
- catch (error) {
161
- input.logger.warn('process heartbeat not written', {
162
- dir,
163
- error: errorText(error),
164
- });
165
- }
202
+ catch (error) {
203
+ input.logger.warn('process heartbeat not written', {
204
+ dir,
205
+ error: errorText(error),
206
+ });
166
207
  }
167
208
  let released = false;
168
209
  return {
@@ -174,13 +215,36 @@ export async function startProcessHeartbeat(input) {
174
215
  shared.owners = Math.max(0, shared.owners - 1);
175
216
  if (shared.owners > 0)
176
217
  return;
177
- // A legacy-layout process keeps using the old paths until it exits.
178
- if (holdsLegacyLayout())
218
+ // A process whose paths stay fixed until it exits keeps using them.
219
+ if (holdsFixedOldPaths())
179
220
  return;
180
221
  await removeHeartbeatFile(input.logger);
181
222
  },
182
223
  };
183
224
  }
225
+ /**
226
+ * Write this process's heartbeat when the file is missing or its layouts and
227
+ * store anchors changed, so later owners of a current file write nothing.
228
+ * Returns the file's path, or undefined when it is current already.
229
+ */
230
+ async function writeCurrentRecords(dir, pid, version) {
231
+ const target = processHeartbeatPath(pid, dir);
232
+ const signature = recordSignature();
233
+ if (shared.writtenPath === target && shared.writtenLayouts === signature)
234
+ return target;
235
+ const stores = storesRecord();
236
+ const path = await writeHeartbeatFile(dir, {
237
+ pid,
238
+ version,
239
+ startedAt: shared.startedAt,
240
+ layouts: layoutsRecord(),
241
+ ...(Object.keys(stores).length > 0 ? { stores } : {}),
242
+ });
243
+ shared.writtenPath = path;
244
+ shared.writtenLayouts = signature;
245
+ installExitHook();
246
+ return path;
247
+ }
184
248
  async function removeHeartbeatFile(logger) {
185
249
  const path = shared.writtenPath;
186
250
  if (!path)
@@ -203,28 +267,59 @@ export async function removeProcessHeartbeat(logger) {
203
267
  await removeHeartbeatFile(logger);
204
268
  }
205
269
  /**
206
- * Record which layout this process uses for one config folder. A `legacy`
207
- * choice is written to the heartbeat file at once, because another process
208
- * deciding whether it may move the files reads it; the caller makes the
209
- * choice and this write while it holds the layout lock. A `state-home`
210
- * choice only goes into the next heartbeat write. Throws when the write
270
+ * Record which layout this process uses for one config folder and write the
271
+ * heartbeat at once, because another process deciding whether it may move
272
+ * the files reads it. A start makes the choice and this write while it holds
273
+ * the layout lock, so a process deciding later sees it; a start whose vault
274
+ * files moved long ago records it without that lock. Throws when the write
211
275
  * fails, unlike `startProcessHeartbeat`.
212
276
  */
213
277
  export async function recordProcessLayout(input) {
214
278
  shared.layouts.set(input.key, input.layout);
215
- if (input.layout !== 'legacy')
216
- return;
279
+ await writeRecords(markStartedAt(input));
280
+ }
281
+ /**
282
+ * Record where this process keeps one config folder's account store (see
283
+ * `HeartbeatStoreRecord` in `runtime-paths.ts`) and write the heartbeat at
284
+ * once, because a process deciding whether it may move the store reads it.
285
+ * A start makes the choice and this write while it holds the layout lock, so
286
+ * a process deciding later sees it. Throws when the write fails, unlike
287
+ * `startProcessHeartbeat`.
288
+ */
289
+ export async function recordProcessAnchor(input) {
290
+ shared.stores.set(input.key, input.anchor);
291
+ await writeRecords(markStartedAt(input));
292
+ }
293
+ /**
294
+ * A record write that starts the process's clock only when nothing has
295
+ * started it yet: the first write that finds it unset is the start time a
296
+ * caller's `now` reports.
297
+ */
298
+ function markStartedAt(input) {
217
299
  shared.startedAt ??= (input.now ?? Date.now)();
218
- const layouts = layoutsRecord();
219
- const path = await writeHeartbeatFile(input.dir ?? processHeartbeatDir(), {
220
- pid: input.pid ?? process.pid,
221
- version: input.version,
300
+ return {
222
301
  startedAt: shared.startedAt,
223
- layouts,
224
- });
225
- shared.writtenPath = path;
226
- shared.writtenLayouts = JSON.stringify(layouts);
227
- installExitHook();
302
+ version: input.version,
303
+ ...(input.pid === undefined ? {} : { pid: input.pid }),
304
+ ...(input.dir === undefined ? {} : { dir: input.dir }),
305
+ };
306
+ }
307
+ /**
308
+ * Write the process's heartbeat now, with its layouts and store anchors. The
309
+ * caller holds the layout lock, and has already claimed the start time with
310
+ * `markStartedAt`.
311
+ */
312
+ async function writeRecords(input) {
313
+ try {
314
+ await writeCurrentRecords(input.dir ?? processHeartbeatDir(), input.pid ?? process.pid, input.version);
315
+ }
316
+ catch (error) {
317
+ // A later attempt retries the write; the records themselves are kept.
318
+ shared.writtenLayouts = undefined;
319
+ throw error instanceof HeartbeatWriteFailure
320
+ ? error
321
+ : new HeartbeatWriteFailure(error);
322
+ }
228
323
  }
229
324
  // The plugin's own version, read from the package manifest. This module sits
230
325
  // directly under `src/`, and the bundles it is built into sit directly under
@@ -251,18 +346,22 @@ export function pluginPackageVersion() {
251
346
  export async function startRuntimeProcessHeartbeat(logger) {
252
347
  let version = 'unknown';
253
348
  let layouts = {};
349
+ let stores = {};
254
350
  try {
255
351
  version = await pluginPackageVersion();
256
- layouts = {
257
- [processConfigFolderKey()]: decidedRuntimeLayout(runtimeLayoutLocation()) ?? 'legacy',
258
- };
352
+ const location = runtimeLayoutLocation();
353
+ const key = processConfigFolderKey();
354
+ layouts = { [key]: decidedRuntimeLayout(location) ?? 'legacy' };
355
+ // Vault-only starts open no store. Before their first local use they
356
+ // decide under the layout lock, following any forward published meanwhile.
357
+ stores = { [key]: decidedAccountStoreAnchor(location) ?? 'undecided' };
259
358
  }
260
359
  catch (error) {
261
360
  logger.warn('process heartbeat details unavailable', {
262
361
  error: errorText(error),
263
362
  });
264
363
  }
265
- return startProcessHeartbeat({ version, logger, layouts });
364
+ return startProcessHeartbeat({ version, logger, layouts, stores });
266
365
  }
267
366
  /**
268
367
  * The standalone CLI's owner of this process's heartbeat. Commands call it only
@@ -279,6 +378,7 @@ export function __resetProcessHeartbeatForTest() {
279
378
  shared.owners = 0;
280
379
  shared.startedAt = undefined;
281
380
  shared.layouts.clear();
381
+ shared.stores.clear();
282
382
  shared.writtenPath = undefined;
283
383
  shared.writtenLayouts = undefined;
284
384
  }