@cortexkit/opencode-antigravity-auth 3.1.4 → 3.1.5

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 (46) hide show
  1. package/README.md +3 -2
  2. package/dist/cli.js +158 -74
  3. package/dist/cli.js.map +4 -4
  4. package/dist/cli.meta.json +88 -15
  5. package/dist/index.js +244 -96
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.meta.json +92 -19
  8. package/dist/server.js +242 -94
  9. package/dist/server.js.map +4 -4
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/auth-menu/login.js +4 -1
  12. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  13. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
  14. package/dist/src/common-auth-embedded/setup/command.js +40 -19
  15. package/dist/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  16. package/dist/src/common-auth-embedded/setup/enroll.js +12 -7
  17. package/dist/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  18. package/dist/src/common-auth-embedded/setup/process-fence.js +52 -8
  19. package/dist/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  20. package/dist/src/common-auth-embedded/setup/process-guard.js +32 -0
  21. package/dist/src/common-auth-embedded/setup/register.d.ts +2 -1
  22. package/dist/src/common-auth-embedded/setup/register.js +12 -2
  23. package/dist/src/common-auth-embedded/source-output.json +54 -38
  24. package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
  25. package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
  26. package/dist/tui-build-map.json +1 -1
  27. package/dist/tui-ga-build-map.json +1 -1
  28. package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  29. package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  30. package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  31. package/dist/types/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  32. package/dist/types/src/common-auth-embedded/setup/register.d.ts +2 -1
  33. package/package.json +2 -2
  34. package/src/common-auth-embedded/auth-menu/login.js +4 -1
  35. package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +2 -2
  36. package/src/common-auth-embedded/routing-accessor/cache-policy.js +1 -0
  37. package/src/common-auth-embedded/setup/command.js +40 -19
  38. package/src/common-auth-embedded/setup/enroll.d.ts +2 -1
  39. package/src/common-auth-embedded/setup/enroll.js +12 -7
  40. package/src/common-auth-embedded/setup/process-fence.d.ts +9 -0
  41. package/src/common-auth-embedded/setup/process-fence.js +52 -8
  42. package/src/common-auth-embedded/setup/process-guard.d.ts +12 -0
  43. package/src/common-auth-embedded/setup/process-guard.js +32 -0
  44. package/src/common-auth-embedded/setup/register.d.ts +2 -1
  45. package/src/common-auth-embedded/setup/register.js +12 -2
  46. package/src/common-auth-embedded/source-output.json +54 -38
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.50.0",
4
+ "version": "0.52.0",
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.50.0.tgz",
77
- "tarballSha256": "702354411ac071087977826325327d6473857eb5341099ae69aa557ea71980d6",
78
- "sri": "sha512-F5u9B24VedALgT8BFmCIaCOvkBP/4iEUEHMcZ/NkiDv3poL8RN5qdX+W69pmUKtKLLvqf2NJMoyoL8e9sTnsSw==",
79
- "shasum": "f83862cf8bff04848eb523cd00c56a95bd29a1c6",
80
- "canonicalFiles": 254,
81
- "canonicalBytes": 1508156,
76
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.52.0.tgz",
77
+ "tarballSha256": "c29dfd830c1515a2d2785d575726b20be4efdb77991c37eaf4de940ee0486df5",
78
+ "sri": "sha512-rl6Y0fr5ljXxukT/XcG0uh4qjt3+Xp6Cgt+BM8jRuIGxtf71sH5GSUcyyGk9Ptr7le27Z04f+RXjv5MhBtASfg==",
79
+ "shasum": "17cee2f576a4bd9005f2732adb3b48659137c1c5",
80
+ "canonicalFiles": 256,
81
+ "canonicalBytes": 1514810,
82
82
  "generator": {
83
83
  "path": "packages/opencode/scripts/embed-common-auth.ts",
84
84
  "version": 4,
85
- "sha256": "4d4b79708092e9fcb697c321b1785aa4d956a68eefc5fb4ff5d4a8b0cc7e9e75"
85
+ "sha256": "c9d52ac06eed3eaf0eea74a60694d0a87d38b949a68fb986d726c0d88138f765"
86
86
  },
87
87
  "files": [
88
88
  {
@@ -176,9 +176,9 @@
176
176
  {
177
177
  "source": "package/dist/auth-menu/login.js",
178
178
  "output": "auth-menu/login.js",
179
- "bytes": 3972,
180
- "sourceSha256": "f55cb1e2a40cab6ef99b5386682615dca059e8d7d982f4a508306c225084f647",
181
- "outputSha256": "f55cb1e2a40cab6ef99b5386682615dca059e8d7d982f4a508306c225084f647",
179
+ "bytes": 4283,
180
+ "sourceSha256": "7df6059976bad7bac619ee3f593cce57eb05b818d9df6c6fba03f7b9e2505d94",
181
+ "outputSha256": "7df6059976bad7bac619ee3f593cce57eb05b818d9df6c6fba03f7b9e2505d94",
182
182
  "transform": "verbatim"
183
183
  },
184
184
  {
@@ -1584,9 +1584,9 @@
1584
1584
  {
1585
1585
  "source": "package/dist/setup/command.js",
1586
1586
  "output": "setup/command.js",
1587
- "bytes": 15044,
1588
- "sourceSha256": "edbaa8a02ccd4aad9462906ee76a7e1a02f115d34ce3d8fc516d9514ebc315c1",
1589
- "outputSha256": "edbaa8a02ccd4aad9462906ee76a7e1a02f115d34ce3d8fc516d9514ebc315c1",
1587
+ "bytes": 16225,
1588
+ "sourceSha256": "64e62236825cb70fa772991fdf467e7dd7e779e348fb123137fa60edec6eddbe",
1589
+ "outputSha256": "64e62236825cb70fa772991fdf467e7dd7e779e348fb123137fa60edec6eddbe",
1590
1590
  "transform": "verbatim"
1591
1591
  },
1592
1592
  {
@@ -1616,17 +1616,17 @@
1616
1616
  {
1617
1617
  "source": "package/dist/setup/enroll.d.ts",
1618
1618
  "output": "setup/enroll.d.ts",
1619
- "bytes": 2326,
1620
- "sourceSha256": "52113737bb13d5e65e1cf48b199a4c487215c9a154ebf8136bd5e50107ee68ca",
1621
- "outputSha256": "52113737bb13d5e65e1cf48b199a4c487215c9a154ebf8136bd5e50107ee68ca",
1619
+ "bytes": 2404,
1620
+ "sourceSha256": "3b5cd16579c2b6a830508a28f4217b8076a4846faeabcd844d6c4109379a8391",
1621
+ "outputSha256": "3b5cd16579c2b6a830508a28f4217b8076a4846faeabcd844d6c4109379a8391",
1622
1622
  "transform": "verbatim"
1623
1623
  },
1624
1624
  {
1625
1625
  "source": "package/dist/setup/enroll.js",
1626
1626
  "output": "setup/enroll.js",
1627
- "bytes": 9707,
1628
- "sourceSha256": "6d63da24cfe89385889d190323b4781c0dfd223b4d9077f97679ff79f9c9091a",
1629
- "outputSha256": "6d63da24cfe89385889d190323b4781c0dfd223b4d9077f97679ff79f9c9091a",
1627
+ "bytes": 10204,
1628
+ "sourceSha256": "b2bf96e7af9f0d04ec654f7821bcfc6cf149d86779b680d9791b99fd82198c51",
1629
+ "outputSha256": "b2bf96e7af9f0d04ec654f7821bcfc6cf149d86779b680d9791b99fd82198c51",
1630
1630
  "transform": "verbatim"
1631
1631
  },
1632
1632
  {
@@ -1680,17 +1680,33 @@
1680
1680
  {
1681
1681
  "source": "package/dist/setup/process-fence.d.ts",
1682
1682
  "output": "setup/process-fence.d.ts",
1683
- "bytes": 2223,
1684
- "sourceSha256": "ed246d2c16821cc51170e4099466450e26821c81fc3b96ad2d7fde18ea4ee9c6",
1685
- "outputSha256": "ed246d2c16821cc51170e4099466450e26821c81fc3b96ad2d7fde18ea4ee9c6",
1683
+ "bytes": 2699,
1684
+ "sourceSha256": "63ecbcd232c70547f168156e0bff44d3a1b9ecfd746e1a16dd8c84db112f637f",
1685
+ "outputSha256": "63ecbcd232c70547f168156e0bff44d3a1b9ecfd746e1a16dd8c84db112f637f",
1686
1686
  "transform": "verbatim"
1687
1687
  },
1688
1688
  {
1689
1689
  "source": "package/dist/setup/process-fence.js",
1690
1690
  "output": "setup/process-fence.js",
1691
- "bytes": 14008,
1692
- "sourceSha256": "8ca9546a205fe9d6daecc2604c7e4608df5d09e0bd0f774fe8da40f26a3ffefb",
1693
- "outputSha256": "8ca9546a205fe9d6daecc2604c7e4608df5d09e0bd0f774fe8da40f26a3ffefb",
1691
+ "bytes": 15880,
1692
+ "sourceSha256": "1d7ee431c9b63aec37e1868df53f0f9c776ccd45d7935282493d1f1d3d6c6127",
1693
+ "outputSha256": "1d7ee431c9b63aec37e1868df53f0f9c776ccd45d7935282493d1f1d3d6c6127",
1694
+ "transform": "verbatim"
1695
+ },
1696
+ {
1697
+ "source": "package/dist/setup/process-guard.d.ts",
1698
+ "output": "setup/process-guard.d.ts",
1699
+ "bytes": 474,
1700
+ "sourceSha256": "61a878c9dcd34adca08d2dbfa9a4e9b697d8982084a9f6534bae9f9cce2414fe",
1701
+ "outputSha256": "61a878c9dcd34adca08d2dbfa9a4e9b697d8982084a9f6534bae9f9cce2414fe",
1702
+ "transform": "verbatim"
1703
+ },
1704
+ {
1705
+ "source": "package/dist/setup/process-guard.js",
1706
+ "output": "setup/process-guard.js",
1707
+ "bytes": 1050,
1708
+ "sourceSha256": "8326c61a43fbc56929eea0d6a6710b3f227d6b2d6848ccc0d6db623ca8b1a3db",
1709
+ "outputSha256": "8326c61a43fbc56929eea0d6a6710b3f227d6b2d6848ccc0d6db623ca8b1a3db",
1694
1710
  "transform": "verbatim"
1695
1711
  },
1696
1712
  {
@@ -1704,17 +1720,17 @@
1704
1720
  {
1705
1721
  "source": "package/dist/setup/register.d.ts",
1706
1722
  "output": "setup/register.d.ts",
1707
- "bytes": 816,
1708
- "sourceSha256": "9f9c32e5eaea9623594b07dde03be3a03dec5e9569e882a7e769a9e14d67c317",
1709
- "outputSha256": "9f9c32e5eaea9623594b07dde03be3a03dec5e9569e882a7e769a9e14d67c317",
1723
+ "bytes": 894,
1724
+ "sourceSha256": "64e1c96e58f18a8975a01b93ba6d9aace2b7ed697900782c820b6f61cc9bcd84",
1725
+ "outputSha256": "64e1c96e58f18a8975a01b93ba6d9aace2b7ed697900782c820b6f61cc9bcd84",
1710
1726
  "transform": "verbatim"
1711
1727
  },
1712
1728
  {
1713
1729
  "source": "package/dist/setup/register.js",
1714
1730
  "output": "setup/register.js",
1715
- "bytes": 9616,
1716
- "sourceSha256": "6318e5747df8b6e56ab4ac5e26fbc2d7446f4ab550d7a700cbc6ce19d8f80e7a",
1717
- "outputSha256": "6318e5747df8b6e56ab4ac5e26fbc2d7446f4ab550d7a700cbc6ce19d8f80e7a",
1731
+ "bytes": 10191,
1732
+ "sourceSha256": "14990618445beb7d781a7f3957d95efec78fc972388ac18bd943743f0a41370a",
1733
+ "outputSha256": "14990618445beb7d781a7f3957d95efec78fc972388ac18bd943743f0a41370a",
1718
1734
  "transform": "verbatim"
1719
1735
  },
1720
1736
  {
@@ -2080,17 +2096,17 @@
2080
2096
  {
2081
2097
  "source": "package/dist/routing-accessor/cache-policy.d.ts",
2082
2098
  "output": "routing-accessor/cache-policy.d.ts",
2083
- "bytes": 2499,
2084
- "sourceSha256": "941d59d7758fe9958c7ad50f744d8d127419f71d0cc44c043af49750089d5dbc",
2085
- "outputSha256": "941d59d7758fe9958c7ad50f744d8d127419f71d0cc44c043af49750089d5dbc",
2099
+ "bytes": 2538,
2100
+ "sourceSha256": "ba03659d97c5b80770452a467dfdcf2d2ca2c2a9e734c5ce8c3e1c46a35b3d89",
2101
+ "outputSha256": "ba03659d97c5b80770452a467dfdcf2d2ca2c2a9e734c5ce8c3e1c46a35b3d89",
2086
2102
  "transform": "verbatim"
2087
2103
  },
2088
2104
  {
2089
2105
  "source": "package/dist/routing-accessor/cache-policy.js",
2090
2106
  "output": "routing-accessor/cache-policy.js",
2091
- "bytes": 7035,
2092
- "sourceSha256": "3dd1190a495f02c9a35638065c22f34372b7aaf37817ceb31920eead004abcf2",
2093
- "outputSha256": "3dd1190a495f02c9a35638065c22f34372b7aaf37817ceb31920eead004abcf2",
2107
+ "bytes": 7058,
2108
+ "sourceSha256": "1a6eb0ccd5d7786dfaf356e6b3955931ecbc75fd8d15d01d0e457bcee7a8a569",
2109
+ "outputSha256": "1a6eb0ccd5d7786dfaf356e6b3955931ecbc75fd8d15d01d0e457bcee7a8a569",
2094
2110
  "transform": "verbatim"
2095
2111
  },
2096
2112
  {
@@ -1,3 +1,3 @@
1
- /** Verify the published archive identity and every store/fs member before loading executable code. */
1
+ /** Verify the candidate archive identity and every store/fs member before loading executable code. */
2
2
  export declare function loadVerifiedStoreModules(): Promise<import("@cortexkit/antigravity-auth-core").CommonAuthStoreModules>;
3
3
  //# sourceMappingURL=verified-store.d.ts.map
@@ -4,8 +4,8 @@ import { dirname, join } from 'node:path';
4
4
  import { loadCommonAuthStoreModules } from '@cortexkit/antigravity-auth-core';
5
5
  const PIN = {
6
6
  package: '@cortexkit/common-auth',
7
- version: '0.50.0',
8
- tarballSha256: '702354411ac071087977826325327d6473857eb5341099ae69aa557ea71980d6',
7
+ version: '0.52.0',
8
+ tarballSha256: 'c29dfd830c1515a2d2785d575726b20be4efdb77991c37eaf4de940ee0486df5',
9
9
  };
10
10
  async function filesBelow(root, dir) {
11
11
  const out = [];
@@ -18,7 +18,7 @@ async function filesBelow(root, dir) {
18
18
  }
19
19
  return out;
20
20
  }
21
- /** Verify the published archive identity and every store/fs member before loading executable code. */
21
+ /** Verify the candidate archive identity and every store/fs member before loading executable code. */
22
22
  export async function loadVerifiedStoreModules() {
23
23
  const root = dirname(dirname(Bun.resolveSync('@cortexkit/antigravity-auth-core/common-auth/store', import.meta.dir)));
24
24
  const receipt = JSON.parse(await readFile(join(root, 'source-output.json'), 'utf8'));
@@ -27,7 +27,7 @@ export async function loadVerifiedStoreModules() {
27
27
  receipt.artifactStatus !== 'published' ||
28
28
  receipt.tarballSha256 !== PIN.tarballSha256 ||
29
29
  !Array.isArray(receipt.files)) {
30
- throw new Error(`the embedded common-auth receipt is not the pinned published ${PIN.version}`);
30
+ throw new Error(`the embedded common-auth receipt is not the pinned candidate ${PIN.version}`);
31
31
  }
32
32
  const recorded = receipt.files.filter((file) => /^(store|fs)\//.test(file.output));
33
33
  const present = [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": 1,
3
- "compiler": "@cortexkit/common-auth/tui-build@0.50.0",
3
+ "compiler": "@cortexkit/common-auth/tui-build@0.52.0",
4
4
  "bun": "1.4.2",
5
5
  "raw": {
6
6
  "selector": "selector.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": 1,
3
- "compiler": "@cortexkit/common-auth/tui-build@0.50.0",
3
+ "compiler": "@cortexkit/common-auth/tui-build@0.52.0",
4
4
  "bun": "1.4.2",
5
5
  "raw": {
6
6
  "selector": "selector.js",
@@ -14,14 +14,14 @@ export interface SessionToolWait {
14
14
  /** Epoch milliseconds when the oldest running plan tool started. */
15
15
  since: number;
16
16
  }
17
- export declare const CACHE_WARM_STOP_REASONS: readonly ['cost-cap', 'count-cap', 'outside-hours', 'session-ended', 'unsupported'];
17
+ export declare const CACHE_WARM_STOP_REASONS: readonly ['cost-cap', 'count-cap', 'deadline-missed', 'outside-hours', 'session-ended', 'unsupported'];
18
18
  /** Billing rejects unknown stop reasons; omit them rather than guessing. */
19
19
  export declare function isCacheWarmStopReason(value: unknown): value is (typeof CACHE_WARM_STOP_REASONS)[number];
20
20
  /**
21
21
  * The stop reasons the llm-runner contract defines today; any other string is
22
22
  * accepted too, for reasons that contract adds later.
23
23
  */
24
- export type CacheWarmStopReason = 'cost-cap' | 'count-cap' | 'outside-hours' | 'session-ended' | 'unsupported' | (string & Record<never, never>);
24
+ export type CacheWarmStopReason = 'cost-cap' | 'count-cap' | 'deadline-missed' | 'outside-hours' | 'session-ended' | 'unsupported' | (string & Record<never, never>);
25
25
  export interface CacheTouchInput {
26
26
  /** Integer epoch milliseconds when the provider answered. */
27
27
  at: number;
@@ -1,4 +1,5 @@
1
1
  import { type MenuTerminal } from '../auth-menu/terminal.js';
2
+ import { SetupProcessGuard } from './process-guard.js';
2
3
  import type { SetupEnrollmentAccess, SetupHost, SetupIO, SetupPlugin } from './types.js';
3
4
  /** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
4
5
  export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read \"Upgrading from v0.1.3\" in its release notes first), or run setup without --claustrum to use local accounts.";
@@ -31,4 +32,4 @@ export declare class HostNotEnrolledError extends Error {
31
32
  });
32
33
  }
33
34
  /** Enroll an independently revocable host; plugin callbacks choose its credential store and account permissions. */
34
- export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: () => Promise<void>): Promise<SetupEnrollmentAccess | undefined>;
35
+ export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: (() => Promise<void>) | SetupProcessGuard): Promise<SetupEnrollmentAccess | undefined>;
@@ -1,6 +1,8 @@
1
1
  import type { CommandRunner, ProcessFence, SetupEnvironment } from './types.js';
2
2
  export interface ProcessInspectionStep {
3
3
  step: 'tasklist' | 'CIM' | 'ps';
4
+ /** The selected CIM interpreter; absent for tasklist and ps. */
5
+ program?: 'pwsh' | 'powershell';
4
6
  exitCode: number | null;
5
7
  signal: NodeJS.Signals | null;
6
8
  timedOut: boolean;
@@ -9,6 +11,7 @@ export interface ProcessInspectionStep {
9
11
  export declare class ProcessInspectionError extends Error implements ProcessInspectionStep {
10
12
  readonly code = "process-inspection-failed";
11
13
  readonly step: ProcessInspectionStep['step'];
14
+ readonly program?: ProcessInspectionStep['program'];
12
15
  readonly exitCode: number | null;
13
16
  readonly signal: NodeJS.Signals | null;
14
17
  readonly timedOut: boolean;
@@ -30,6 +33,10 @@ export declare class ProcessFenceViolationError extends Error {
30
33
  export declare function listSetupProcesses(runner?: CommandRunner, options?: {
31
34
  platform?: string;
32
35
  env?: SetupEnvironment;
36
+ /** Tests can replace the regular-file check for the fixed pwsh location. */
37
+ isFile?: (file: string) => boolean;
38
+ /** Reports before each slow Windows ARM PowerShell 5.1 check. */
39
+ onProgress?: (line: string) => void;
33
40
  onStep?: (details: ProcessInspectionStep) => void;
34
41
  /** False skips the Windows PowerShell query for Node and Bun command lines. */
35
42
  inspectRuntimes?: boolean;
@@ -53,5 +60,7 @@ export declare function listSetupProcesses(runner?: CommandRunner, options?: {
53
60
  export declare function createProcessFence(runner?: CommandRunner, options?: {
54
61
  platform?: string;
55
62
  selfPid?: number;
63
+ isFile?: (file: string) => boolean;
64
+ onProgress?: (line: string) => void;
56
65
  }): ProcessFence;
57
66
  export declare function assertHostsStopped(fence: ProcessFence, env?: SetupEnvironment): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /** Reuse an inspection only while setup has done nothing a running host could observe. */
2
+ export declare class SetupProcessGuard {
3
+ #private;
4
+ private readonly inspect;
5
+ private readonly now;
6
+ constructor(inspect: () => Promise<void>, now?: () => number);
7
+ check(options?: {
8
+ reuse?: boolean;
9
+ }): Promise<void>;
10
+ /** Callbacks, writes and waits can all make an earlier inspection stale. */
11
+ step<T>(run: () => T | Promise<T>): Promise<T>;
12
+ }
@@ -1,3 +1,4 @@
1
+ import { SetupProcessGuard } from './process-guard.js';
1
2
  import type { OpenCodeGeneration, SetupIO, SetupPlugin } from './types.js';
2
3
  export interface PlannedWrite {
3
4
  path: string;
@@ -9,5 +10,5 @@ export interface PlannedWrite {
9
10
  /** Edit only array entries so unrelated JSONC text, including comments, survives. */
10
11
  export declare function updatePluginConfig(text: string, key: 'plugin' | 'plugins', pkg: string, version: string): string;
11
12
  export declare function planOpenCodeRegistration(plugin: SetupPlugin, generation: OpenCodeGeneration, io?: SetupIO): PlannedWrite[];
12
- export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: () => Promise<void>): Promise<void>;
13
+ export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: (() => Promise<void>) | SetupProcessGuard): Promise<void>;
13
14
  export declare function registerPi(plugin: SetupPlugin, executable: string, io?: SetupIO): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-antigravity-auth",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "Google Antigravity OAuth auth plugin for OpenCode - access Gemini and Claude models using Google credentials",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -132,7 +132,7 @@
132
132
  "dependencies": {
133
133
  "@cortexkit/claustrum-client": "0.18.0",
134
134
  "@cortexkit/subc-client": "0.24.0",
135
- "@cortexkit/antigravity-auth-core": "3.1.4",
135
+ "@cortexkit/antigravity-auth-core": "3.1.5",
136
136
  "@cortexkit/private-files": "0.2.2",
137
137
  "jsonc-parser": "^3.3.1",
138
138
  "xdg-basedir": "^5.1.0",
@@ -1,4 +1,5 @@
1
1
  import { spawn as defaultSpawn } from 'node:child_process';
2
+ import { win32 } from 'node:path';
2
3
  /** Opens a URL with the platform's opener; false when it could not start. */
3
4
  export function openBrowserForMenu(url, platform = process.platform, spawn = defaultSpawn) {
4
5
  try {
@@ -13,7 +14,9 @@ export function openBrowserForMenu(url, platform = process.platform, spawn = def
13
14
  // opened. It is not detached: a detached PowerShell has no console and
14
15
  // never ran the command on any Windows runner.
15
16
  const command = `Start-Process '${url.replaceAll("'", "''")}'`;
16
- const child = spawn('powershell.exe', [
17
+ // Spawn PowerShell by its system path: a bare name can resolve to a
18
+ // program planted in the current directory or earlier on PATH.
19
+ const child = spawn(win32.resolve(process.env.SystemRoot ?? process.env.windir ?? 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'), [
17
20
  '-NoProfile',
18
21
  '-NonInteractive',
19
22
  '-WindowStyle',
@@ -14,14 +14,14 @@ export interface SessionToolWait {
14
14
  /** Epoch milliseconds when the oldest running plan tool started. */
15
15
  since: number;
16
16
  }
17
- export declare const CACHE_WARM_STOP_REASONS: readonly ['cost-cap', 'count-cap', 'outside-hours', 'session-ended', 'unsupported'];
17
+ export declare const CACHE_WARM_STOP_REASONS: readonly ['cost-cap', 'count-cap', 'deadline-missed', 'outside-hours', 'session-ended', 'unsupported'];
18
18
  /** Billing rejects unknown stop reasons; omit them rather than guessing. */
19
19
  export declare function isCacheWarmStopReason(value: unknown): value is (typeof CACHE_WARM_STOP_REASONS)[number];
20
20
  /**
21
21
  * The stop reasons the llm-runner contract defines today; any other string is
22
22
  * accepted too, for reasons that contract adds later.
23
23
  */
24
- export type CacheWarmStopReason = 'cost-cap' | 'count-cap' | 'outside-hours' | 'session-ended' | 'unsupported' | (string & Record<never, never>);
24
+ export type CacheWarmStopReason = 'cost-cap' | 'count-cap' | 'deadline-missed' | 'outside-hours' | 'session-ended' | 'unsupported' | (string & Record<never, never>);
25
25
  export interface CacheTouchInput {
26
26
  /** Integer epoch milliseconds when the provider answered. */
27
27
  at: number;
@@ -2,6 +2,7 @@ import { routingHandle } from './handle.js';
2
2
  export const CACHE_WARM_STOP_REASONS = [
3
3
  'cost-cap',
4
4
  'count-cap',
5
+ 'deadline-missed',
5
6
  'outside-hours',
6
7
  'session-ended',
7
8
  'unsupported',
@@ -10,6 +10,7 @@ import { confirmEnrollmentAccess } from './enrollment-access.js';
10
10
  import { parseSetupFlags, UNAVAILABLE_HOST_MESSAGE } from './flags.js';
11
11
  import { setupPaths } from './paths.js';
12
12
  import { assertHostsStopped, createProcessFence, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
13
+ import { SetupProcessGuard } from './process-guard.js';
13
14
  import { selectSetupHosts } from './prompts.js';
14
15
  import { planOpenCodeRegistration, registerOpenCode, registerPi, } from './register.js';
15
16
  export const AMBIGUOUS_OPENCODE_MESSAGE = 'Multiple OpenCode generations found. Choose --opencode=1|2|both before running noninteractive setup.';
@@ -120,7 +121,11 @@ export async function runSetup(plugin, argv = [], io = {}) {
120
121
  }
121
122
  const { env, platform } = setupPaths(io);
122
123
  const fence = io.fence ??
123
- createProcessFence(io.runner ?? defaultCommandRunner, { platform });
124
+ createProcessFence(io.runner ?? defaultCommandRunner, {
125
+ platform,
126
+ isFile: io.fs?.isFile.bind(io.fs),
127
+ onProgress: (line) => printLine(terminal, line),
128
+ });
124
129
  const stopped = async () => {
125
130
  try {
126
131
  await assertHostsStopped(fence, env);
@@ -131,6 +136,7 @@ export async function runSetup(plugin, argv = [], io = {}) {
131
136
  throw error;
132
137
  }
133
138
  };
139
+ const guard = new SetupProcessGuard(stopped, io.now);
134
140
  printLine(terminal, 'Checking that OpenCode and Pi are not running…');
135
141
  if (options.dryRun) {
136
142
  try {
@@ -150,8 +156,10 @@ export async function runSetup(plugin, argv = [], io = {}) {
150
156
  printLine(terminal, error.refusalText);
151
157
  }
152
158
  }
153
- else
154
- await stopped();
159
+ else {
160
+ // Refuse before asking questions; the first write can reuse this check.
161
+ await guard.check();
162
+ }
155
163
  if ((options.claustrum || options.enrollOnly) &&
156
164
  !detection.claustrum.available)
157
165
  throw new Error('Claustrum is not available. Start ck, or omit vault-only flags and use --no-claustrum for local sign-in.');
@@ -164,10 +172,10 @@ export async function runSetup(plugin, argv = [], io = {}) {
164
172
  isInteractive(terminal)) {
165
173
  // Not `confirm`: it reads Escape and Ctrl-C as "No", and "No" here means
166
174
  // a local sign-in. Cancelling must stop setup before anything changes.
167
- const choice = await select(terminal, [
175
+ const choice = await guard.step(() => select(terminal, [
168
176
  { label: 'No', value: false },
169
177
  { label: 'Yes', value: true },
170
- ], { message: 'Connect these hosts to the Claustrum vault?' });
178
+ ], { message: 'Connect these hosts to the Claustrum vault?' }));
171
179
  if (choice === null) {
172
180
  printLine(terminal, 'Setup cancelled. Nothing was changed.');
173
181
  return { hosts: [], dryRun: options.dryRun, mode: 'local', detection };
@@ -224,13 +232,15 @@ export async function runSetup(plugin, argv = [], io = {}) {
224
232
  const enrollmentAccess = new Map();
225
233
  try {
226
234
  for (const host of hosts) {
227
- await stopped();
228
- await plugin.beforeSignIn?.(host, context);
229
- await stopped();
235
+ if (plugin.beforeSignIn) {
236
+ // The callback can change credentials or wait for consent.
237
+ await guard.check({ reuse: true });
238
+ await guard.step(() => plugin.beforeSignIn?.(host, context));
239
+ }
230
240
  if (useVault) {
231
241
  enrollment.set(host, 'unknown');
232
242
  try {
233
- const access = await connectSetupHost(plugin, host, io, terminal, stopped);
243
+ const access = await connectSetupHost(plugin, host, io, terminal, guard);
234
244
  if (access)
235
245
  enrollmentAccess.set(host, access);
236
246
  }
@@ -241,19 +251,30 @@ export async function runSetup(plugin, argv = [], io = {}) {
241
251
  }
242
252
  enrollment.set(host, 'enrolled');
243
253
  }
244
- else
245
- await plugin.signInLocal(host, context);
246
- await stopped();
254
+ else {
255
+ // Local sign-in can write credentials and wait for a browser.
256
+ await guard.check({ reuse: true });
257
+ await guard.step(() => plugin.signInLocal(host, context));
258
+ }
247
259
  if (options.enrollOnly)
248
260
  continue;
249
- await plugin.beforeRegister?.(host, mode, context);
250
- await stopped();
261
+ if (plugin.beforeRegister) {
262
+ // Registration callbacks may write provider-specific files.
263
+ await guard.check({ reuse: true });
264
+ await guard.step(() => plugin.beforeRegister?.(host, mode, context));
265
+ }
251
266
  if (host === 'opencode')
252
- await registerOpenCode(writes, stopped);
253
- else
254
- await registerPi(plugin, detection.pi.executable, io);
255
- await stopped();
256
- await plugin.migrate?.(host, context);
267
+ await registerOpenCode(writes, guard);
268
+ else {
269
+ // Pi's CLI writes its plugin registration.
270
+ await guard.check({ reuse: true });
271
+ await guard.step(() => registerPi(plugin, detection.pi.executable, io));
272
+ }
273
+ if (plugin.migrate) {
274
+ // Migration is a plugin callback and may write host credentials.
275
+ await guard.check({ reuse: true });
276
+ await guard.step(() => plugin.migrate?.(host, context));
277
+ }
257
278
  }
258
279
  }
259
280
  catch (error) {
@@ -1,4 +1,5 @@
1
1
  import { type MenuTerminal } from '../auth-menu/terminal.js';
2
+ import { SetupProcessGuard } from './process-guard.js';
2
3
  import type { SetupEnrollmentAccess, SetupHost, SetupIO, SetupPlugin } from './types.js';
3
4
  /** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
4
5
  export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read \"Upgrading from v0.1.3\" in its release notes first), or run setup without --claustrum to use local accounts.";
@@ -31,4 +32,4 @@ export declare class HostNotEnrolledError extends Error {
31
32
  });
32
33
  }
33
34
  /** Enroll an independently revocable host; plugin callbacks choose its credential store and account permissions. */
34
- export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: () => Promise<void>): Promise<SetupEnrollmentAccess | undefined>;
35
+ export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: (() => Promise<void>) | SetupProcessGuard): Promise<SetupEnrollmentAccess | undefined>;
@@ -5,6 +5,7 @@ import { ClaustrumEnrollmentManager, connectClaustrumEnrollmentClient, hostEnrol
5
5
  import { hasVaultHost, VAULT_HOST_CONNECT_REFUSAL } from '../claustrum/host.js';
6
6
  import { confirmEnrollmentAccess, enrollmentAccessLines, } from './enrollment-access.js';
7
7
  import { ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
8
+ import { SetupProcessGuard } from './process-guard.js';
8
9
  const ENROLLMENT_INCOMPLETE_MESSAGE = 'Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.';
9
10
  /** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
10
11
  export const UNSUPPORTED_VAULT_MESSAGE = 'This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read "Upgrading from v0.1.3" in its release notes first), or run setup without --claustrum to use local accounts.';
@@ -57,7 +58,9 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
57
58
  throw new Error(VAULT_HOST_CONNECT_REFUSAL);
58
59
  const { name, displayName, requestedGrants, grantFallback, paths: input, } = plugin.vault.hosts[host];
59
60
  const paths = hostEnrollmentPaths(input);
60
- await fence();
61
+ const guard = typeof fence === 'function' ? new SetupProcessGuard(fence, io.now) : fence;
62
+ // Fail before connecting; an uninterrupted caller inspection is sufficient.
63
+ await guard.check({ reuse: true });
61
64
  const client = await (io.connect ?? connectClaustrumEnrollmentClient)({
62
65
  connectionFile: plugin.vault.connectionFile,
63
66
  handshakeTimeoutMs: 2000,
@@ -79,11 +82,10 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
79
82
  client,
80
83
  writeTokenFile: async (path, file) => {
81
84
  // Writing the token is what connects the host: check once more.
82
- await fence();
83
- await writeEnrollmentTokenFile(path, file);
85
+ await guard.check();
86
+ await guard.step(() => writeEnrollmentTokenFile(path, file));
84
87
  },
85
88
  });
86
- await fence();
87
89
  const initial = await manager.status();
88
90
  if (initial.state === 'approved') {
89
91
  printLine(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
@@ -100,7 +102,9 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
100
102
  let reportedCode;
101
103
  let failedProposals = 0;
102
104
  for (;;) {
103
- const status = await manager.reconcile();
105
+ // Reconcile may create or update the host's enrollment state.
106
+ await guard.check({ reuse: true });
107
+ const status = await guard.step(() => manager.reconcile());
104
108
  if (status.state === 'approved') {
105
109
  printLine(terminal, `Connected ${host} to Claustrum.`);
106
110
  const access = await confirmEnrollmentAccess(client, status, paths.tokenPath, requestedGrants);
@@ -153,8 +157,9 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
153
157
  const remaining = deadline - now();
154
158
  if (remaining <= 0)
155
159
  break;
156
- await wait(Math.min(pause, remaining));
157
- await fence();
160
+ await guard.step(() => wait(Math.min(pause, remaining)));
161
+ // Approval waits allow a host to start before the next reconcile.
162
+ await guard.check();
158
163
  }
159
164
  if (printedRequest)
160
165
  throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
@@ -1,6 +1,8 @@
1
1
  import type { CommandRunner, ProcessFence, SetupEnvironment } from './types.js';
2
2
  export interface ProcessInspectionStep {
3
3
  step: 'tasklist' | 'CIM' | 'ps';
4
+ /** The selected CIM interpreter; absent for tasklist and ps. */
5
+ program?: 'pwsh' | 'powershell';
4
6
  exitCode: number | null;
5
7
  signal: NodeJS.Signals | null;
6
8
  timedOut: boolean;
@@ -9,6 +11,7 @@ export interface ProcessInspectionStep {
9
11
  export declare class ProcessInspectionError extends Error implements ProcessInspectionStep {
10
12
  readonly code = "process-inspection-failed";
11
13
  readonly step: ProcessInspectionStep['step'];
14
+ readonly program?: ProcessInspectionStep['program'];
12
15
  readonly exitCode: number | null;
13
16
  readonly signal: NodeJS.Signals | null;
14
17
  readonly timedOut: boolean;
@@ -30,6 +33,10 @@ export declare class ProcessFenceViolationError extends Error {
30
33
  export declare function listSetupProcesses(runner?: CommandRunner, options?: {
31
34
  platform?: string;
32
35
  env?: SetupEnvironment;
36
+ /** Tests can replace the regular-file check for the fixed pwsh location. */
37
+ isFile?: (file: string) => boolean;
38
+ /** Reports before each slow Windows ARM PowerShell 5.1 check. */
39
+ onProgress?: (line: string) => void;
33
40
  onStep?: (details: ProcessInspectionStep) => void;
34
41
  /** False skips the Windows PowerShell query for Node and Bun command lines. */
35
42
  inspectRuntimes?: boolean;
@@ -53,5 +60,7 @@ export declare function listSetupProcesses(runner?: CommandRunner, options?: {
53
60
  export declare function createProcessFence(runner?: CommandRunner, options?: {
54
61
  platform?: string;
55
62
  selfPid?: number;
63
+ isFile?: (file: string) => boolean;
64
+ onProgress?: (line: string) => void;
56
65
  }): ProcessFence;
57
66
  export declare function assertHostsStopped(fence: ProcessFence, env?: SetupEnvironment): Promise<void>;