@cortexkit/opencode-antigravity-auth 3.1.0 → 3.1.2

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 (62) hide show
  1. package/dist/cli.js +828 -620
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +118 -60
  4. package/dist/index.js +4695 -4086
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +154 -81
  7. package/dist/server.js +4636 -4027
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/fs/canonical-file-path.d.ts +17 -0
  11. package/dist/src/common-auth-embedded/fs/canonical-file-path.js +53 -0
  12. package/dist/src/common-auth-embedded/fs/index.d.ts +1 -0
  13. package/dist/src/common-auth-embedded/fs/index.js +3 -0
  14. package/dist/src/common-auth-embedded/settings/fs.js +1 -0
  15. package/dist/src/common-auth-embedded/settings/update.js +4 -22
  16. package/dist/src/common-auth-embedded/source-output.json +39 -23
  17. package/dist/src/common-auth-embedded/tui-prefs/watcher.js +9 -2
  18. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  19. package/dist/src/ga/tui/host-ga.js +1 -0
  20. package/dist/src/ga/tui/host-ga.js.map +1 -1
  21. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  22. package/dist/src/plugin/config/loader.d.ts +2 -2
  23. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  24. package/dist/src/plugin/config/loader.js +18 -9
  25. package/dist/src/plugin/config/loader.js.map +1 -1
  26. package/dist/src/plugin/request.d.ts.map +1 -1
  27. package/dist/src/plugin/request.js +3 -1
  28. package/dist/src/plugin/request.js.map +1 -1
  29. package/dist/src/plugin/shared/request-services.d.ts +1 -0
  30. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  31. package/dist/src/plugin/shared/request-services.js +55 -1
  32. package/dist/src/plugin/shared/request-services.js.map +1 -1
  33. package/dist/src/plugin/shared/vault-menu.d.ts +1 -1
  34. package/dist/src/plugin/shared/vault-menu.d.ts.map +1 -1
  35. package/dist/src/plugin/shared/vault-menu.js +21 -14
  36. package/dist/src/plugin/shared/vault-menu.js.map +1 -1
  37. package/dist/src/plugin/shared/vault-request-credentials.d.ts +2 -0
  38. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  39. package/dist/src/plugin/shared/vault-request-credentials.js +136 -15
  40. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  41. package/dist/tui-build-map.json +1 -1
  42. package/dist/tui-ga-build-map.json +5 -5
  43. package/dist/types/src/plugin/config/loader.d.ts +2 -2
  44. package/dist/types/src/plugin/config/loader.d.ts.map +1 -1
  45. package/dist/types/src/plugin/request.d.ts.map +1 -1
  46. package/dist/types/src/plugin/shared/request-services.d.ts +1 -0
  47. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  48. package/dist/types/src/plugin/shared/vault-menu.d.ts +1 -1
  49. package/dist/types/src/plugin/shared/vault-menu.d.ts.map +1 -1
  50. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +2 -0
  51. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/common-auth-embedded/fs/canonical-file-path.d.ts +17 -0
  54. package/src/common-auth-embedded/fs/canonical-file-path.js +53 -0
  55. package/src/common-auth-embedded/fs/index.d.ts +1 -0
  56. package/src/common-auth-embedded/fs/index.js +3 -0
  57. package/src/common-auth-embedded/settings/fs.js +1 -0
  58. package/src/common-auth-embedded/settings/update.js +4 -22
  59. package/src/common-auth-embedded/source-output.json +39 -23
  60. package/src/common-auth-embedded/tui-prefs/watcher.js +9 -2
  61. package/src/tui-ga-compiled/host-ga.js +1 -1
  62. package/src/tui-ga-raw/host-ga.tsx +5 -0
@@ -0,0 +1,53 @@
1
+ import { basename, dirname, join, resolve } from 'node:path';
2
+ const maxSymlinkHops = 40;
3
+ /**
4
+ * Canonical path of a file that other processes may replace by write-and-rename.
5
+ *
6
+ * On Linux, Bun's realpath on such a file can answer "<file> (deleted)" (Bun
7
+ * 1.3) or ENOENT (Bun 1.4) during the rename. So this resolves the folder with
8
+ * realpath and appends the name, then follows a file symlink one readlink hop at
9
+ * a time, at most 40 hops. A missing file resolves to its would-be path; a
10
+ * dangling link or a loop throws. Pass `node:fs/promises` (or a test double).
11
+ */
12
+ export async function canonicalFilePath(file, fs) {
13
+ let target = file;
14
+ for (let hops = 0;; hops++) {
15
+ // Bun can report an unlinked inode's " (deleted)" name for realpath(file).
16
+ target = join(await fs.realpath(dirname(target)), basename(target));
17
+ let isSymlink;
18
+ try {
19
+ isSymlink = (await fs.lstat(target)).isSymbolicLink();
20
+ }
21
+ catch (error) {
22
+ if (error.code === 'ENOENT' && hops === 0)
23
+ return target;
24
+ throw error;
25
+ }
26
+ if (!isSymlink)
27
+ return target;
28
+ if (hops >= maxSymlinkHops)
29
+ throw new Error('Too many file symlink hops');
30
+ target = resolve(dirname(target), await fs.readlink(target));
31
+ }
32
+ }
33
+ /** Synchronous counterpart of canonicalFilePath; pass `node:fs`. */
34
+ export function canonicalFilePathSync(file, fs) {
35
+ let target = file;
36
+ for (let hops = 0;; hops++) {
37
+ target = join(fs.realpathSync(dirname(target)), basename(target));
38
+ let isSymlink;
39
+ try {
40
+ isSymlink = fs.lstatSync(target).isSymbolicLink();
41
+ }
42
+ catch (error) {
43
+ if (error.code === 'ENOENT' && hops === 0)
44
+ return target;
45
+ throw error;
46
+ }
47
+ if (!isSymlink)
48
+ return target;
49
+ if (hops >= maxSymlinkHops)
50
+ throw new Error('Too many file symlink hops');
51
+ target = resolve(dirname(target), fs.readlinkSync(target));
52
+ }
53
+ }
@@ -1,5 +1,6 @@
1
1
  export type { AtomicWriteOptions } from './atomic-write.js';
2
2
  export { writeJsonAtomic } from './atomic-write.js';
3
+ export { canonicalFilePath, canonicalFilePathSync, } from './canonical-file-path.js';
3
4
  export { WRITER_LOCK_CONSTANTS } from './lock-constants.js';
4
5
  export type { PrivateWriteOutcome } from './private-files.js';
5
6
  export { PrivateFileError } from './private-files.js';
@@ -1,4 +1,7 @@
1
1
  export { writeJsonAtomic } from './atomic-write.js';
2
+ // Canonical path of a file other processes may atomically replace: resolves
3
+ // the folder, never the file itself (see canonical-file-path.ts).
4
+ export { canonicalFilePath, canonicalFilePathSync, } from './canonical-file-path.js';
2
5
  export { WRITER_LOCK_CONSTANTS } from './lock-constants.js';
3
6
  export { PrivateFileError } from './private-files.js';
4
7
  // The try-once lock underneath withLock, for callers that hold a lock across
@@ -3,6 +3,7 @@ const defaults = {
3
3
  readFile: fs.readFile,
4
4
  stat: fs.stat,
5
5
  lstat: fs.lstat,
6
+ readlink: fs.readlink,
6
7
  realpath: fs.realpath,
7
8
  open: fs.open,
8
9
  rename: fs.rename,
@@ -1,4 +1,5 @@
1
- import { basename, dirname, join } from 'node:path';
1
+ import { dirname } from 'node:path';
2
+ import { canonicalFilePath } from '../fs/canonical-file-path.js';
2
3
  import { ensurePrivateDirectory } from '../fs/private-files.js';
3
4
  import { withLock } from '../fs/with-lock.js';
4
5
  import { deepFreeze } from './descriptors.js';
@@ -19,29 +20,10 @@ function unavailable(file, cause) {
19
20
  }
20
21
  async function writeTarget(file) {
21
22
  try {
22
- return await SettingsFs.realpath(file);
23
+ return await canonicalFilePath(file, SettingsFs);
23
24
  }
24
25
  catch (error) {
25
- if (error.code !== 'ENOENT')
26
- unavailable(file, error);
27
- let isSymlink = false;
28
- try {
29
- isSymlink = (await SettingsFs.lstat(file)).isSymbolicLink();
30
- }
31
- catch (lstatError) {
32
- if (lstatError.code !== 'ENOENT')
33
- unavailable(file, lstatError);
34
- }
35
- // Only a symlink whose realpath is missing is a dangling entry.
36
- if (isSymlink)
37
- unavailable(file, error);
38
- // Bun 1.4 can fail realpath for regular files during a concurrent atomic replace.
39
- try {
40
- return join(await SettingsFs.realpath(dirname(file)), basename(file));
41
- }
42
- catch (parentError) {
43
- unavailable(file, parentError);
44
- }
26
+ unavailable(file, error);
45
27
  }
46
28
  }
47
29
  /** Lock the canonical user file so symlink aliases serialize the same edits. */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.49.1",
4
+ "version": "0.49.2",
5
5
  "artifactStatus": "published",
6
6
  "publicRoots": {
7
7
  "./rpc": {
@@ -73,16 +73,16 @@
73
73
  "import": "./src/quota-sidebar/index.tsx"
74
74
  }
75
75
  },
76
- "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.49.1.tgz",
77
- "tarballSha256": "51f844a7cdc018ce795b642b8ac9bc3fb42e3fd5a5c23b6977bf097c854fe1ca",
78
- "sri": "sha512-bN32JvabenbUQU0HeYFzrf2PhgH9p+YO5T7jIDspMSM6lOf/jRykdX0TZ154nUo95ZbhS/4f4b4BxU7kMt6+LQ==",
79
- "shasum": "5e3e69e6aa76b884374dc816066f0c887c52d21b",
80
- "canonicalFiles": 252,
81
- "canonicalBytes": 1503837,
76
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.49.2.tgz",
77
+ "tarballSha256": "b7e8f8da2b91b920507362f88d8329b5f002bc77df9738773d69ef4045985557",
78
+ "sri": "sha512-gY3AWxr1UPLsENzm5uj5IF1LNnAwXUay/wsgqhJZLgcZX2SlO8fOSKL2UPEGh+pOpvZ6h8zkmxeWz1pP7J+yDA==",
79
+ "shasum": "3b7fc671e107350e62c529567465e3ccd9f134f2",
80
+ "canonicalFiles": 254,
81
+ "canonicalBytes": 1506987,
82
82
  "generator": {
83
83
  "path": "packages/opencode/scripts/embed-common-auth.ts",
84
84
  "version": 4,
85
- "sha256": "b4c837b90ca6f9266a0bfcd74a6412b64db0b98475aa40cef05c4be65d4a6770"
85
+ "sha256": "9f98c2b294c9fa1ec983a908c16250834825555ef3c0c94af7c36ea4fbd15dd1"
86
86
  },
87
87
  "files": [
88
88
  {
@@ -605,6 +605,22 @@
605
605
  "outputSha256": "80779a8078e673ef68deaa7fdee3a0e1322078521a1f4156c0a595814c374044",
606
606
  "transform": "verbatim"
607
607
  },
608
+ {
609
+ "source": "package/dist/fs/canonical-file-path.d.ts",
610
+ "output": "fs/canonical-file-path.d.ts",
611
+ "bytes": 992,
612
+ "sourceSha256": "4c8360a283be9b00bbc3f41d61682582fda47af25ceed43f286cabcf95255697",
613
+ "outputSha256": "4c8360a283be9b00bbc3f41d61682582fda47af25ceed43f286cabcf95255697",
614
+ "transform": "verbatim"
615
+ },
616
+ {
617
+ "source": "package/dist/fs/canonical-file-path.js",
618
+ "output": "fs/canonical-file-path.js",
619
+ "bytes": 2058,
620
+ "sourceSha256": "459c381a274053cefe98cf5e88a8d4a5554b222a744365ba44fa3b7970fe382c",
621
+ "outputSha256": "459c381a274053cefe98cf5e88a8d4a5554b222a744365ba44fa3b7970fe382c",
622
+ "transform": "verbatim"
623
+ },
608
624
  {
609
625
  "source": "package/dist/fs/file-read-cache.js",
610
626
  "output": "fs/file-read-cache.js",
@@ -616,17 +632,17 @@
616
632
  {
617
633
  "source": "package/dist/fs/index.d.ts",
618
634
  "output": "fs/index.d.ts",
619
- "bytes": 626,
620
- "sourceSha256": "31ad80c3a005dfd3c78d1b8d1a2d4c23ce9d47dd9f6b5b8c3b9ec4f07c4b5cdb",
621
- "outputSha256": "31ad80c3a005dfd3c78d1b8d1a2d4c23ce9d47dd9f6b5b8c3b9ec4f07c4b5cdb",
635
+ "bytes": 712,
636
+ "sourceSha256": "3f72bbc610a4b99ba8d36546387861cb21a6b916043732edfe6472432077822a",
637
+ "outputSha256": "3f72bbc610a4b99ba8d36546387861cb21a6b916043732edfe6472432077822a",
622
638
  "transform": "verbatim"
623
639
  },
624
640
  {
625
641
  "source": "package/dist/fs/index.js",
626
642
  "output": "fs/index.js",
627
- "bytes": 509,
628
- "sourceSha256": "26127c5a818c2ff0f66374f2dbbd93f57c6de7266acb2b2f61117e6e17e57f2b",
629
- "outputSha256": "26127c5a818c2ff0f66374f2dbbd93f57c6de7266acb2b2f61117e6e17e57f2b",
643
+ "bytes": 739,
644
+ "sourceSha256": "897c37f6302a86c98099075959bf3254968571f214d2355b84aa7cfb4063a67b",
645
+ "outputSha256": "897c37f6302a86c98099075959bf3254968571f214d2355b84aa7cfb4063a67b",
630
646
  "transform": "verbatim"
631
647
  },
632
648
  {
@@ -1352,9 +1368,9 @@
1352
1368
  {
1353
1369
  "source": "package/dist/settings/fs.js",
1354
1370
  "output": "settings/fs.js",
1355
- "bytes": 597,
1356
- "sourceSha256": "ea80efd40e62102b9853b39ba372ad5a6298226f136ac4828b487fb73f3160cf",
1357
- "outputSha256": "ea80efd40e62102b9853b39ba372ad5a6298226f136ac4828b487fb73f3160cf",
1371
+ "bytes": 624,
1372
+ "sourceSha256": "a6ce13d630aff0bda53c2672535bf234ca853213c816a5dc067cca648d6a2eb2",
1373
+ "outputSha256": "a6ce13d630aff0bda53c2672535bf234ca853213c816a5dc067cca648d6a2eb2",
1358
1374
  "transform": "verbatim"
1359
1375
  },
1360
1376
  {
@@ -1520,9 +1536,9 @@
1520
1536
  {
1521
1537
  "source": "package/dist/settings/update.js",
1522
1538
  "output": "settings/update.js",
1523
- "bytes": 6482,
1524
- "sourceSha256": "f3d7446d74d22d59131563c2b915f46ea00973d89378bceceffd7bb757d26570",
1525
- "outputSha256": "f3d7446d74d22d59131563c2b915f46ea00973d89378bceceffd7bb757d26570",
1539
+ "bytes": 5825,
1540
+ "sourceSha256": "023abdeb144bb3f39bdc667eca99a6020253f4ec1cb5fe3506ed75628361df9a",
1541
+ "outputSha256": "023abdeb144bb3f39bdc667eca99a6020253f4ec1cb5fe3506ed75628361df9a",
1526
1542
  "transform": "verbatim"
1527
1543
  },
1528
1544
  {
@@ -2016,9 +2032,9 @@
2016
2032
  {
2017
2033
  "source": "package/dist/tui-prefs/watcher.js",
2018
2034
  "output": "tui-prefs/watcher.js",
2019
- "bytes": 7749,
2020
- "sourceSha256": "8300e3fc6c5d0834b70aeff50de95e35bda96bdbb59311083a60b190e2cfe089",
2021
- "outputSha256": "8300e3fc6c5d0834b70aeff50de95e35bda96bdbb59311083a60b190e2cfe089",
2035
+ "bytes": 8163,
2036
+ "sourceSha256": "57f187e2298b4db58a0abac2b7cdf6cca6a0830f5e05373c9cb28a6f058a51e7",
2037
+ "outputSha256": "57f187e2298b4db58a0abac2b7cdf6cca6a0830f5e05373c9cb28a6f058a51e7",
2022
2038
  "transform": "verbatim"
2023
2039
  },
2024
2040
  {
@@ -1,8 +1,15 @@
1
- import { readFileSync, realpathSync, statSync, watch, } from 'node:fs';
1
+ import { lstatSync, readFileSync, readlinkSync, realpathSync, statSync, watch, } from 'node:fs';
2
2
  import { readFile, stat } from 'node:fs/promises';
3
3
  import { basename, dirname, join, resolve } from 'node:path';
4
4
  import { clearTimeout, setTimeout } from 'node:timers';
5
+ import { canonicalFilePathSync } from '../fs/canonical-file-path.js';
5
6
  import { PrivateFileError, readPrivateText, windowsPrivateFiles, } from '../fs/private-files.js';
7
+ const pathFsDefaults = { lstatSync, readlinkSync, realpathSync };
8
+ const pathFs = { ...pathFsDefaults };
9
+ /** Internal test hook; omitted path operations use the native implementation. */
10
+ export function setTuiPreferencesPathFsForTest(overrides) {
11
+ Object.assign(pathFs, pathFsDefaults, overrides);
12
+ }
6
13
  function canonicalPath(file) {
7
14
  const path = resolve(file);
8
15
  // Leave reparse points in the path for private-files' ancestor walk to reject;
@@ -10,7 +17,7 @@ function canonicalPath(file) {
10
17
  if (windowsPrivateFiles)
11
18
  return path;
12
19
  try {
13
- return realpathSync(path);
20
+ return canonicalFilePathSync(path, pathFs);
14
21
  }
15
22
  catch {
16
23
  // Resolve existing ancestors even when the preferences file is not yet present.
@@ -623,7 +623,7 @@ export function buildGaMenu(snapshot, now) {
623
623
  id: `${ACCOUNT_ITEM_PREFIX}${account.selector}`,
624
624
  label: account.label,
625
625
  detail: `${projected.status} · ${projected.health}`,
626
- actions: [account.enabled ? use('disable', 'Disable', 'Stop routing requests to this account.') : use('enable', 'Enable', 'Route requests to this account again.'), use('select-active', 'Use for all models', 'Make this the current account.'), use('select-claude', 'Use for Claude', 'Make this the current Claude account.'), use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'), ...(snapshot.vaultHostStatus || settings.selectionStrategy === 'vault' ? [] : [{
626
+ actions: [account.enabled ? use('disable', 'Disable', 'Stop routing requests to this account.') : use('enable', 'Enable', 'Route requests to this account again.'), use('select-active', 'Use for all models', 'Make this the current account.'), use('select-claude', 'Use for Claude', 'Make this the current Claude account.'), use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'), use('clear-limits', 'Clear limits', 'Remove stored quota reset limits.'), ...(snapshot.vaultHostStatus || settings.selectionStrategy === 'vault' ? [] : [{
627
627
  id: 'remove',
628
628
  label: 'Remove',
629
629
  description: 'Delete this account from this machine.',
@@ -1031,6 +1031,11 @@ export function buildGaMenu(snapshot: GaSnapshot, now: number): MenuModel {
1031
1031
  'Use for Gemini',
1032
1032
  'Make this the current Gemini account.',
1033
1033
  ),
1034
+ use(
1035
+ 'clear-limits',
1036
+ 'Clear limits',
1037
+ 'Remove stored quota reset limits.',
1038
+ ),
1034
1039
  ...(snapshot.vaultHostStatus ||
1035
1040
  settings.selectionStrategy === 'vault'
1036
1041
  ? []