@cortexkit/opencode-antigravity-auth 3.0.13 → 3.0.14

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 (167) hide show
  1. package/dist/cli.js +1865 -571
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +291 -52
  4. package/dist/index.js +2166 -751
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +326 -72
  7. package/dist/server.js +3898 -2452
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/__fixtures__/runtime-layout-process.d.ts +2 -0
  11. package/dist/src/__fixtures__/runtime-layout-process.d.ts.map +1 -0
  12. package/dist/src/__fixtures__/runtime-layout-process.js +88 -0
  13. package/dist/src/__fixtures__/runtime-layout-process.js.map +1 -0
  14. package/dist/src/cli.d.ts +17 -6
  15. package/dist/src/cli.d.ts.map +1 -1
  16. package/dist/src/cli.js +26 -9
  17. package/dist/src/cli.js.map +1 -1
  18. package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  19. package/dist/src/common-auth-embedded/claustrum/enrollment.js +15 -8
  20. package/dist/src/common-auth-embedded/claustrum/hub.js +86 -42
  21. package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +16 -3
  22. package/dist/src/common-auth-embedded/setup/command.js +4 -49
  23. package/dist/src/common-auth-embedded/setup/flags.d.ts +50 -0
  24. package/dist/src/common-auth-embedded/setup/flags.js +123 -0
  25. package/dist/src/common-auth-embedded/setup/index.d.ts +1 -0
  26. package/dist/src/common-auth-embedded/setup/index.js +1 -0
  27. package/dist/src/common-auth-embedded/setup/types.d.ts +7 -1
  28. package/dist/src/common-auth-embedded/source-output.json +47 -31
  29. package/dist/src/ga/server/auth.d.ts.map +1 -1
  30. package/dist/src/ga/server/auth.js +7 -2
  31. package/dist/src/ga/server/auth.js.map +1 -1
  32. package/dist/src/ga/server/index.d.ts.map +1 -1
  33. package/dist/src/ga/server/index.js +18 -4
  34. package/dist/src/ga/server/index.js.map +1 -1
  35. package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts +7 -0
  36. package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts.map +1 -0
  37. package/dist/src/plugin/__fixtures__/controlled-timeouts.js +41 -0
  38. package/dist/src/plugin/__fixtures__/controlled-timeouts.js.map +1 -0
  39. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts +2 -0
  40. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -0
  41. package/dist/src/plugin/__fixtures__/release-model-ids.js +11 -0
  42. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -0
  43. package/dist/src/plugin/__fixtures__/verified-store.d.ts +3 -0
  44. package/dist/src/plugin/__fixtures__/verified-store.d.ts.map +1 -0
  45. package/dist/src/plugin/__fixtures__/verified-store.js +50 -0
  46. package/dist/src/plugin/__fixtures__/verified-store.js.map +1 -0
  47. package/dist/src/plugin/auth-loader.d.ts +7 -1
  48. package/dist/src/plugin/auth-loader.d.ts.map +1 -1
  49. package/dist/src/plugin/auth-loader.js +4 -4
  50. package/dist/src/plugin/auth-loader.js.map +1 -1
  51. package/dist/src/plugin/cache/signature-cache.d.ts +7 -1
  52. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  53. package/dist/src/plugin/cache/signature-cache.js +10 -13
  54. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  55. package/dist/src/plugin/config/loader.d.ts +2 -1
  56. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  57. package/dist/src/plugin/config/loader.js +4 -2
  58. package/dist/src/plugin/config/loader.js.map +1 -1
  59. package/dist/src/plugin/config/schema.js +1 -1
  60. package/dist/src/plugin/debug.d.ts.map +1 -1
  61. package/dist/src/plugin/debug.js +18 -19
  62. package/dist/src/plugin/debug.js.map +1 -1
  63. package/dist/src/plugin/errors.js +1 -1
  64. package/dist/src/plugin/errors.js.map +1 -1
  65. package/dist/src/plugin/ga-location-services.d.ts +1 -1
  66. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  67. package/dist/src/plugin/ga-location-services.js +50 -27
  68. package/dist/src/plugin/ga-location-services.js.map +1 -1
  69. package/dist/src/plugin/ga-shared-vault-custody.d.ts +19 -5
  70. package/dist/src/plugin/ga-shared-vault-custody.d.ts.map +1 -1
  71. package/dist/src/plugin/ga-shared-vault-custody.js +12 -4
  72. package/dist/src/plugin/ga-shared-vault-custody.js.map +1 -1
  73. package/dist/src/plugin/index.d.ts.map +1 -1
  74. package/dist/src/plugin/index.js +31 -9
  75. package/dist/src/plugin/index.js.map +1 -1
  76. package/dist/src/plugin/shared/source-sidebar.d.ts +6 -0
  77. package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -1
  78. package/dist/src/plugin/shared/source-sidebar.js +1 -1
  79. package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
  80. package/dist/src/plugin/storage.d.ts +5 -2
  81. package/dist/src/plugin/storage.d.ts.map +1 -1
  82. package/dist/src/plugin/storage.js +5 -4
  83. package/dist/src/plugin/storage.js.map +1 -1
  84. package/dist/src/plugin/vault-custody.d.ts +29 -8
  85. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  86. package/dist/src/plugin/vault-custody.js +61 -10
  87. package/dist/src/plugin/vault-custody.js.map +1 -1
  88. package/dist/src/process-heartbeat.d.ts +22 -2
  89. package/dist/src/process-heartbeat.d.ts.map +1 -1
  90. package/dist/src/process-heartbeat.js +47 -10
  91. package/dist/src/process-heartbeat.js.map +1 -1
  92. package/dist/src/rpc/rpc-server.d.ts +8 -0
  93. package/dist/src/rpc/rpc-server.d.ts.map +1 -1
  94. package/dist/src/rpc/rpc-server.js +26 -1
  95. package/dist/src/rpc/rpc-server.js.map +1 -1
  96. package/dist/src/runtime-layout.d.ts +100 -0
  97. package/dist/src/runtime-layout.d.ts.map +1 -0
  98. package/dist/src/runtime-layout.js +1242 -0
  99. package/dist/src/runtime-layout.js.map +1 -0
  100. package/dist/src/runtime-paths.d.ts +132 -0
  101. package/dist/src/runtime-paths.d.ts.map +1 -0
  102. package/dist/src/runtime-paths.js +214 -0
  103. package/dist/src/runtime-paths.js.map +1 -0
  104. package/dist/src/setup.d.ts.map +1 -1
  105. package/dist/src/setup.js +30 -7
  106. package/dist/src/setup.js.map +1 -1
  107. package/dist/src/vault-folder.d.ts +38 -0
  108. package/dist/src/vault-folder.d.ts.map +1 -0
  109. package/dist/src/vault-folder.js +91 -0
  110. package/dist/src/vault-folder.js.map +1 -0
  111. package/dist/src/version-fence.d.ts +54 -0
  112. package/dist/src/version-fence.d.ts.map +1 -0
  113. package/dist/src/version-fence.js +254 -0
  114. package/dist/src/version-fence.js.map +1 -0
  115. package/dist/tui-build-map.json +1 -1
  116. package/dist/tui-ga-build-map.json +1 -1
  117. package/dist/types/src/cli.d.ts +17 -6
  118. package/dist/types/src/cli.d.ts.map +1 -1
  119. package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  120. package/dist/types/src/common-auth-embedded/setup/flags.d.ts +50 -0
  121. package/dist/types/src/common-auth-embedded/setup/index.d.ts +1 -0
  122. package/dist/types/src/common-auth-embedded/setup/types.d.ts +7 -1
  123. package/dist/types/src/ga/server/auth.d.ts.map +1 -1
  124. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  125. package/dist/types/src/plugin/auth-loader.d.ts +7 -1
  126. package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
  127. package/dist/types/src/plugin/cache/signature-cache.d.ts +7 -1
  128. package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -1
  129. package/dist/types/src/plugin/config/loader.d.ts +2 -1
  130. package/dist/types/src/plugin/config/loader.d.ts.map +1 -1
  131. package/dist/types/src/plugin/debug.d.ts.map +1 -1
  132. package/dist/types/src/plugin/ga-location-services.d.ts +1 -1
  133. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  134. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts +19 -5
  135. package/dist/types/src/plugin/ga-shared-vault-custody.d.ts.map +1 -1
  136. package/dist/types/src/plugin/index.d.ts.map +1 -1
  137. package/dist/types/src/plugin/shared/source-sidebar.d.ts +6 -0
  138. package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -1
  139. package/dist/types/src/plugin/storage.d.ts +5 -2
  140. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  141. package/dist/types/src/plugin/vault-custody.d.ts +29 -8
  142. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  143. package/dist/types/src/process-heartbeat.d.ts +22 -2
  144. package/dist/types/src/process-heartbeat.d.ts.map +1 -1
  145. package/dist/types/src/rpc/rpc-server.d.ts +8 -0
  146. package/dist/types/src/rpc/rpc-server.d.ts.map +1 -1
  147. package/dist/types/src/runtime-layout.d.ts +100 -0
  148. package/dist/types/src/runtime-layout.d.ts.map +1 -0
  149. package/dist/types/src/runtime-paths.d.ts +132 -0
  150. package/dist/types/src/runtime-paths.d.ts.map +1 -0
  151. package/dist/types/src/setup.d.ts.map +1 -1
  152. package/dist/types/src/vault-folder.d.ts +38 -0
  153. package/dist/types/src/vault-folder.d.ts.map +1 -0
  154. package/dist/types/src/version-fence.d.ts +54 -0
  155. package/dist/types/src/version-fence.d.ts.map +1 -0
  156. package/package.json +2 -2
  157. package/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
  158. package/src/common-auth-embedded/claustrum/enrollment.js +15 -8
  159. package/src/common-auth-embedded/claustrum/hub.js +86 -42
  160. package/src/common-auth-embedded/fs/refresh-file-lock.js +16 -3
  161. package/src/common-auth-embedded/setup/command.js +4 -49
  162. package/src/common-auth-embedded/setup/flags.d.ts +50 -0
  163. package/src/common-auth-embedded/setup/flags.js +123 -0
  164. package/src/common-auth-embedded/setup/index.d.ts +1 -0
  165. package/src/common-auth-embedded/setup/index.js +1 -0
  166. package/src/common-auth-embedded/setup/types.d.ts +7 -1
  167. package/src/common-auth-embedded/source-output.json +47 -31
@@ -358,8 +358,19 @@ export async function acquireRefreshFileLockWithClock(options) {
358
358
  return 'missing';
359
359
  throw error;
360
360
  }
361
- if (windowsPrivateFiles)
362
- await verifyPrivate(evictPath, 'directory', true);
361
+ if (windowsPrivateFiles) {
362
+ try {
363
+ await verifyPrivate(evictPath, 'directory', true);
364
+ }
365
+ catch (error) {
366
+ // The marker's holder can remove it between the stat above and this
367
+ // check. Absence means the marker is free, as when the stat finds
368
+ // nothing; every other refusal still escapes.
369
+ if (error.code === 'ENOENT')
370
+ return 'missing';
371
+ throw error;
372
+ }
373
+ }
363
374
  if (evictStat.mtimeMs + EVICT_TTL > now())
364
375
  return 'fresh';
365
376
  if (options.onStep)
@@ -386,11 +397,13 @@ export async function acquireRefreshFileLockWithClock(options) {
386
397
  catch (error) {
387
398
  if (error.code === 'EEXIST') {
388
399
  if (windowsPrivateFiles) {
389
- await verifyPrivate(evictPath, 'directory', true);
390
400
  try {
401
+ await verifyPrivate(evictPath, 'directory', true);
391
402
  await readPrivateText(evictOwnerPath, true);
392
403
  }
393
404
  catch (ownerError) {
405
+ // A marker removed by its holder after the failed create is free:
406
+ // report it as unavailable for now so the caller retries.
394
407
  if (ownerError.code !== 'ENOENT')
395
408
  throw ownerError;
396
409
  }
@@ -5,57 +5,12 @@ import { recordSetupEnrollment, setupEnrollmentLine } from './command-error.js';
5
5
  import { defaultCommandRunner } from './command-runner.js';
6
6
  import { detectHosts } from './detect.js';
7
7
  import { connectSetupHost, HostNotEnrolledError } from './enroll.js';
8
+ import { parseSetupFlags, UNAVAILABLE_HOST_MESSAGE } from './flags.js';
8
9
  import { setupPaths } from './paths.js';
9
10
  import { assertHostsStopped, createProcessFence, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
10
11
  import { selectSetupHosts } from './prompts.js';
11
12
  import { planOpenCodeRegistration, registerOpenCode, registerPi, } from './register.js';
12
13
  export const AMBIGUOUS_OPENCODE_MESSAGE = 'Multiple OpenCode generations found. Choose --opencode=1|2|both before running noninteractive setup.';
13
- const UNAVAILABLE_HOST_MESSAGE = 'Requested setup host is unknown or unavailable. Use --host=opencode or --host=pi with a detected host.';
14
- function flags(argv) {
15
- const result = {
16
- yes: false,
17
- dryRun: false,
18
- claustrum: false,
19
- noClaustrum: false,
20
- login: false,
21
- enrollOnly: false,
22
- hosts: [],
23
- opencode: undefined,
24
- };
25
- for (const arg of argv) {
26
- if (arg === '--yes')
27
- result.yes = true;
28
- else if (arg === '--dry-run')
29
- result.dryRun = true;
30
- else if (arg === '--claustrum')
31
- result.claustrum = true;
32
- else if (arg === '--no-claustrum')
33
- result.noClaustrum = true;
34
- else if (arg === '--login')
35
- result.login = true;
36
- else if (arg === '--enroll-only')
37
- result.enrollOnly = true;
38
- else if (arg.startsWith('--host=')) {
39
- const host = arg.slice('--host='.length);
40
- if (host !== 'opencode' && host !== 'pi')
41
- throw new Error(UNAVAILABLE_HOST_MESSAGE);
42
- result.hosts.push(host);
43
- }
44
- else if (/^--opencode=(1|2|both)$/.test(arg))
45
- result.opencode = arg.slice('--opencode='.length);
46
- else
47
- throw new Error(`Unknown setup argument: ${arg}`);
48
- }
49
- if (result.claustrum && result.noClaustrum)
50
- throw new Error('--claustrum and --no-claustrum cannot be used together.');
51
- if (result.login && result.claustrum)
52
- throw new Error('--login and --claustrum cannot be used together.');
53
- if (result.enrollOnly && result.login)
54
- throw new Error('--enroll-only and --login cannot be used together.');
55
- if (result.enrollOnly && result.noClaustrum)
56
- throw new Error('--enroll-only and --no-claustrum cannot be used together.');
57
- return result;
58
- }
59
14
  function validatePlugin(plugin) {
60
15
  for (const pkg of Object.values(plugin.packages)) {
61
16
  if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(pkg))
@@ -92,7 +47,7 @@ async function enrollmentReport(plugin, hosts, recorded) {
92
47
  return report;
93
48
  }
94
49
  export async function runSetup(plugin, argv = [], io = {}) {
95
- const options = flags(argv);
50
+ const options = parseSetupFlags(argv);
96
51
  validatePlugin(plugin);
97
52
  const terminal = io.terminal ?? processTerminal();
98
53
  const detection = await detectHosts(plugin, io);
@@ -234,7 +189,7 @@ export async function runSetup(plugin, argv = [], io = {}) {
234
189
  printLine(terminal, `${write.changed ? 'Would write' : 'Unchanged'} ${write.path}:\n${write.content}`);
235
190
  if (!options.enrollOnly && hosts.includes('pi'))
236
191
  printLine(terminal, `Would run ${detection.pi.executable} install npm:${plugin.packages.pi}@${plugin.version}`);
237
- if (!options.enrollOnly)
192
+ if (!options.enrollOnly && plugin.migrate)
238
193
  for (const host of hosts)
239
194
  printLine(terminal, `Would migrate ${host} using the plugin callback (provider-specific writes).`);
240
195
  }
@@ -277,7 +232,7 @@ export async function runSetup(plugin, argv = [], io = {}) {
277
232
  else
278
233
  await registerPi(plugin, detection.pi.executable, io);
279
234
  await stopped();
280
- await plugin.migrate(host, context);
235
+ await plugin.migrate?.(host, context);
281
236
  }
282
237
  }
283
238
  catch (error) {
@@ -0,0 +1,50 @@
1
+ import type { OpenCodeGeneration, SetupHost } from './types.js';
2
+ export declare const UNAVAILABLE_HOST_MESSAGE = "Requested setup host is unknown or unavailable. Use --host=opencode or --host=pi with a detected host.";
3
+ type SwitchKey = 'yes' | 'dryRun' | 'claustrum' | 'noClaustrum' | 'login' | 'enrollOnly';
4
+ /**
5
+ * One flag the shared setup parser accepts. A switch sets `key` to true; a
6
+ * value flag takes one of `values` as `--name=value`, and also as the next
7
+ * argument (`--name value`) when `spaceForm` is set. `invalid` replaces the
8
+ * unknown-argument refusal when a value flag gets a value it does not accept.
9
+ */
10
+ export type SetupFlag = {
11
+ name: string;
12
+ key: SwitchKey;
13
+ description: string;
14
+ } | {
15
+ name: string;
16
+ key: 'hosts' | 'opencode';
17
+ values: readonly string[];
18
+ spaceForm?: boolean;
19
+ invalid?: string;
20
+ description: string;
21
+ };
22
+ /**
23
+ * Every flag `runSetup` accepts. The parser and `setupUsage` both read this
24
+ * table, so the help a plugin prints cannot list a flag the parser refuses or
25
+ * leave out one it accepts.
26
+ */
27
+ export declare const SETUP_FLAGS: readonly SetupFlag[];
28
+ export interface SetupFlags {
29
+ yes: boolean;
30
+ dryRun: boolean;
31
+ claustrum: boolean;
32
+ noClaustrum: boolean;
33
+ login: boolean;
34
+ enrollOnly: boolean;
35
+ hosts: SetupHost[];
36
+ opencode: OpenCodeGeneration | undefined;
37
+ }
38
+ /** Parse setup's arguments against `SETUP_FLAGS`, refusing anything else. */
39
+ export declare function parseSetupFlags(argv: readonly string[]): SetupFlags;
40
+ /**
41
+ * The flags `runSetup` accepts, one per line, for a plugin's `setup --help`.
42
+ * The shared parser has no `--help` of its own: the plugin's bin checks for
43
+ * `--help` or `-h` before calling `runSetup`, prints this text and any lines of
44
+ * its own, and exits 0. With `command` the text starts with a usage line, such
45
+ * as `Usage: example-auth setup [flags]`.
46
+ */
47
+ export declare function setupUsage(options?: {
48
+ command?: string;
49
+ }): string;
50
+ export {};
@@ -0,0 +1,123 @@
1
+ export const UNAVAILABLE_HOST_MESSAGE = 'Requested setup host is unknown or unavailable. Use --host=opencode or --host=pi with a detected host.';
2
+ /**
3
+ * Every flag `runSetup` accepts. The parser and `setupUsage` both read this
4
+ * table, so the help a plugin prints cannot list a flag the parser refuses or
5
+ * leave out one it accepts.
6
+ */
7
+ export const SETUP_FLAGS = [
8
+ {
9
+ name: '--yes',
10
+ key: 'yes',
11
+ description: 'Run without questions and set up every found host. Does not choose the vault.',
12
+ },
13
+ {
14
+ name: '--dry-run',
15
+ key: 'dryRun',
16
+ description: 'Print what setup would do without changing anything.',
17
+ },
18
+ {
19
+ name: '--host',
20
+ key: 'hosts',
21
+ values: ['opencode', 'pi'],
22
+ spaceForm: true,
23
+ invalid: UNAVAILABLE_HOST_MESSAGE,
24
+ description: 'Set up only this host; repeat the flag for both. Also written --host=<host>.',
25
+ },
26
+ {
27
+ name: '--opencode',
28
+ key: 'opencode',
29
+ values: ['1', '2', 'both'],
30
+ description: 'Register for this OpenCode generation.',
31
+ },
32
+ {
33
+ name: '--claustrum',
34
+ key: 'claustrum',
35
+ description: 'Connect the hosts to the Claustrum vault.',
36
+ },
37
+ {
38
+ name: '--no-claustrum',
39
+ key: 'noClaustrum',
40
+ description: 'Do not offer the Claustrum vault; sign in locally.',
41
+ },
42
+ {
43
+ name: '--login',
44
+ key: 'login',
45
+ description: 'Sign in locally instead of using the Claustrum vault.',
46
+ },
47
+ {
48
+ name: '--enroll-only',
49
+ key: 'enrollOnly',
50
+ description: 'Only connect the hosts to the Claustrum vault; register nothing and migrate nothing.',
51
+ },
52
+ ];
53
+ function unknownArgument(arg) {
54
+ return new Error(`Unknown setup argument: ${arg}. Run the plugin's own setup --help to list the flags setup accepts.`);
55
+ }
56
+ /** Parse setup's arguments against `SETUP_FLAGS`, refusing anything else. */
57
+ export function parseSetupFlags(argv) {
58
+ const result = {
59
+ yes: false,
60
+ dryRun: false,
61
+ claustrum: false,
62
+ noClaustrum: false,
63
+ login: false,
64
+ enrollOnly: false,
65
+ hosts: [],
66
+ opencode: undefined,
67
+ };
68
+ for (let index = 0; index < argv.length; index++) {
69
+ const arg = argv[index];
70
+ const equals = arg.indexOf('=');
71
+ const name = equals === -1 ? arg : arg.slice(0, equals);
72
+ const flag = SETUP_FLAGS.find((entry) => entry.name === name);
73
+ if (!flag)
74
+ throw unknownArgument(arg);
75
+ if (!('values' in flag)) {
76
+ if (equals !== -1)
77
+ throw unknownArgument(arg);
78
+ result[flag.key] = true;
79
+ continue;
80
+ }
81
+ let value;
82
+ if (equals !== -1)
83
+ value = arg.slice(equals + 1);
84
+ else if (flag.spaceForm)
85
+ value = argv[++index];
86
+ else
87
+ throw unknownArgument(arg);
88
+ if (value === undefined || !flag.values.includes(value))
89
+ throw flag.invalid ? new Error(flag.invalid) : unknownArgument(arg);
90
+ if (flag.key === 'hosts')
91
+ result.hosts.push(value);
92
+ else
93
+ result.opencode = value;
94
+ }
95
+ if (result.claustrum && result.noClaustrum)
96
+ throw new Error('--claustrum and --no-claustrum cannot be used together.');
97
+ if (result.login && result.claustrum)
98
+ throw new Error('--login and --claustrum cannot be used together.');
99
+ if (result.enrollOnly && result.login)
100
+ throw new Error('--enroll-only and --login cannot be used together.');
101
+ if (result.enrollOnly && result.noClaustrum)
102
+ throw new Error('--enroll-only and --no-claustrum cannot be used together.');
103
+ return result;
104
+ }
105
+ /**
106
+ * The flags `runSetup` accepts, one per line, for a plugin's `setup --help`.
107
+ * The shared parser has no `--help` of its own: the plugin's bin checks for
108
+ * `--help` or `-h` before calling `runSetup`, prints this text and any lines of
109
+ * its own, and exits 0. With `command` the text starts with a usage line, such
110
+ * as `Usage: example-auth setup [flags]`.
111
+ */
112
+ export function setupUsage(options = {}) {
113
+ const labels = SETUP_FLAGS.map((flag) => 'values' in flag
114
+ ? `${flag.name}${flag.spaceForm ? ' ' : '='}${flag.values.join('|')}`
115
+ : flag.name);
116
+ const width = Math.max(...labels.map((label) => label.length));
117
+ const lines = SETUP_FLAGS.map((flag, index) => ` ${labels[index].padEnd(width)} ${flag.description}`);
118
+ return [
119
+ ...(options.command ? [`Usage: ${options.command} [flags]`, ''] : []),
120
+ 'Flags:',
121
+ ...lines,
122
+ ].join('\n');
123
+ }
@@ -2,6 +2,7 @@ export { AMBIGUOUS_OPENCODE_MESSAGE, runSetup } from './command.js';
2
2
  export { SetupCommandError, setupEnrollment } from './command-error.js';
3
3
  export { detectHosts, detectOpenCodeGeneration, findExecutableOnPath, openCodeDesktopMarkers, } from './detect.js';
4
4
  export { ENROLLMENT_WAIT_MS, HostNotEnrolledError, type HostNotEnrolledReason, UNSUPPORTED_VAULT_MESSAGE, } from './enroll.js';
5
+ export { setupUsage } from './flags.js';
5
6
  export { assertHostsStopped, createProcessFence, listSetupProcesses, ProcessFenceViolationError, ProcessInspectionError, type ProcessInspectionStep, } from './process-fence.js';
6
7
  export { type PlannedWrite, planOpenCodeRegistration, registerOpenCode, registerPi, updatePluginConfig, } from './register.js';
7
8
  export type { CommandResult, CommandRunner, HostDetection, OpenCodeGeneration, ProcessFence, SetupCallbackContext, SetupDetection, SetupEnrollmentOutcome, SetupEnvironment, SetupFileSystem, SetupHost, SetupHostEnrollment, SetupIO, SetupPlugin, SetupResult, } from './types.js';
@@ -2,5 +2,6 @@ export { AMBIGUOUS_OPENCODE_MESSAGE, runSetup } from './command.js';
2
2
  export { SetupCommandError, setupEnrollment } from './command-error.js';
3
3
  export { detectHosts, detectOpenCodeGeneration, findExecutableOnPath, openCodeDesktopMarkers, } from './detect.js';
4
4
  export { ENROLLMENT_WAIT_MS, HostNotEnrolledError, UNSUPPORTED_VAULT_MESSAGE, } from './enroll.js';
5
+ export { setupUsage } from './flags.js';
5
6
  export { assertHostsStopped, createProcessFence, listSetupProcesses, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
6
7
  export { planOpenCodeRegistration, registerOpenCode, registerPi, updatePluginConfig, } from './register.js';
@@ -61,7 +61,13 @@ export interface SetupPlugin {
61
61
  */
62
62
  beforeSignIn?(host: SetupHost, context: SetupCallbackContext): Promise<void>;
63
63
  signInLocal(host: SetupHost, context: SetupCallbackContext): Promise<void>;
64
- migrate(host: SetupHost, context: SetupCallbackContext): Promise<void>;
64
+ /**
65
+ * Moves the host's existing provider credentials into place after the host
66
+ * is registered. Optional: a plugin with nothing to migrate (one that only
67
+ * reads credentials from the vault) leaves it out, and setup then neither
68
+ * calls it nor mentions migration in its dry-run plan.
69
+ */
70
+ migrate?(host: SetupHost, context: SetupCallbackContext): Promise<void>;
65
71
  /** Reject mixed local/vault credentials and activate provider-specific vault access before registration. */
66
72
  beforeRegister?(host: SetupHost, mode: 'local' | 'claustrum', context: SetupCallbackContext): Promise<void>;
67
73
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "package": "@cortexkit/common-auth",
4
- "version": "0.27.1",
4
+ "version": "0.28.0",
5
5
  "artifactStatus": "published",
6
6
  "publicRoots": {
7
7
  "./rpc": {
@@ -61,15 +61,15 @@
61
61
  "import": "./dist/opencode2/index.js"
62
62
  }
63
63
  },
64
- "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.27.1.tgz",
65
- "tarballSha256": "a74507a1f746c9d591501ab24a630fe8bab20fb305c92738770902f003edb387",
66
- "sri": "sha512-k5oKV38HxXKqwVi7qU8K9fD+P0ca7kXu52TlulHJoiGO0Q8Ebv0URtW1UXKLYawOm3ZwfVwFEBzAhuj8kMh6rg==",
67
- "canonicalFiles": 193,
68
- "canonicalBytes": 1211539,
64
+ "input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.28.0.tgz",
65
+ "tarballSha256": "8070e3c1882238d78ac5e955fb140484e08d9f97ed0f2d5d40f35928c60fbbc5",
66
+ "sri": "sha512-PRyppMdE3y8dTzF3iQHcFruo5ksPPhgSQExe7g4Ij/oPynDLbalSQqBaInKdSV/v5qyrY0iJs/D0Yu7fbWh3NQ==",
67
+ "canonicalFiles": 195,
68
+ "canonicalBytes": 1220682,
69
69
  "generator": {
70
70
  "path": "packages/opencode/scripts/embed-common-auth.ts",
71
71
  "version": 3,
72
- "sha256": "79e2db6c01d1048f7a8b90a5105848710890e68ebb0ff096ec5623ec96eb1012"
72
+ "sha256": "32e05acc65fbec2114dce8a43e29e3eca2d6f02594f20e3f6e7bc3b1ec9b8aa3"
73
73
  },
74
74
  "files": [
75
75
  {
@@ -283,17 +283,17 @@
283
283
  {
284
284
  "source": "package/dist/claustrum/enrollment.d.ts",
285
285
  "output": "claustrum/enrollment.d.ts",
286
- "bytes": 7976,
287
- "sourceSha256": "d6b4e8561ccc0ff2f9b4386856c5fe3dc7c475e13f98314a0666d0b20458d43b",
288
- "outputSha256": "d6b4e8561ccc0ff2f9b4386856c5fe3dc7c475e13f98314a0666d0b20458d43b",
286
+ "bytes": 8530,
287
+ "sourceSha256": "8e44065db1b28f930f01b9c267aacb23e2f4f9d5d7d358b815fdc8c5080450ff",
288
+ "outputSha256": "8e44065db1b28f930f01b9c267aacb23e2f4f9d5d7d358b815fdc8c5080450ff",
289
289
  "transform": "verbatim"
290
290
  },
291
291
  {
292
292
  "source": "package/dist/claustrum/enrollment.js",
293
293
  "output": "claustrum/enrollment.js",
294
- "bytes": 36501,
295
- "sourceSha256": "0a6aa09a8927ae9ba11e4cc4fbe81cd8a3248d5f7db71e8592667bc870899078",
296
- "outputSha256": "0a6aa09a8927ae9ba11e4cc4fbe81cd8a3248d5f7db71e8592667bc870899078",
294
+ "bytes": 36868,
295
+ "sourceSha256": "7dab3edbc03542bcd75578449f6c3b92959671f0669332c62b2ad4525aa9c829",
296
+ "outputSha256": "7dab3edbc03542bcd75578449f6c3b92959671f0669332c62b2ad4525aa9c829",
297
297
  "transform": "verbatim"
298
298
  },
299
299
  {
@@ -339,9 +339,9 @@
339
339
  {
340
340
  "source": "package/dist/claustrum/hub.js",
341
341
  "output": "claustrum/hub.js",
342
- "bytes": 40718,
343
- "sourceSha256": "50d57557ccd6e59989424e0df63df75570d97cdb5f71da37ce865d75f76297fd",
344
- "outputSha256": "50d57557ccd6e59989424e0df63df75570d97cdb5f71da37ce865d75f76297fd",
342
+ "bytes": 43086,
343
+ "sourceSha256": "f156151cba0a628828a9c28cdeea757a4c959e4398a79c423001b2b2857c2ec7",
344
+ "outputSha256": "f156151cba0a628828a9c28cdeea757a4c959e4398a79c423001b2b2857c2ec7",
345
345
  "transform": "verbatim"
346
346
  },
347
347
  {
@@ -627,9 +627,9 @@
627
627
  {
628
628
  "source": "package/dist/fs/refresh-file-lock.js",
629
629
  "output": "fs/refresh-file-lock.js",
630
- "bytes": 30222,
631
- "sourceSha256": "314dadbe39b9f0664b6f2f6abff674197c8d86f61ba657e2031d5a8b08ec1030",
632
- "outputSha256": "314dadbe39b9f0664b6f2f6abff674197c8d86f61ba657e2031d5a8b08ec1030",
630
+ "bytes": 30833,
631
+ "sourceSha256": "c0e4de79b0c0bb8fac09b13c5cf861eaa008434b336e87ce761d7f0713203a90",
632
+ "outputSha256": "c0e4de79b0c0bb8fac09b13c5cf861eaa008434b336e87ce761d7f0713203a90",
633
633
  "transform": "verbatim"
634
634
  },
635
635
  {
@@ -1187,9 +1187,9 @@
1187
1187
  {
1188
1188
  "source": "package/dist/setup/command.js",
1189
1189
  "output": "setup/command.js",
1190
- "bytes": 15313,
1191
- "sourceSha256": "69c58fd28873929126ee975eff1d4d7de2dafb483af5ccb630f5feb2e3c9abb2",
1192
- "outputSha256": "69c58fd28873929126ee975eff1d4d7de2dafb483af5ccb630f5feb2e3c9abb2",
1190
+ "bytes": 13573,
1191
+ "sourceSha256": "182db608585e2ab5d47a6c388fb46973739364d72f5df9b035875f765b7a6f79",
1192
+ "outputSha256": "182db608585e2ab5d47a6c388fb46973739364d72f5df9b035875f765b7a6f79",
1193
1193
  "transform": "verbatim"
1194
1194
  },
1195
1195
  {
@@ -1232,20 +1232,36 @@
1232
1232
  "outputSha256": "dd21599c916733c327bca81c48372034a349a2840e50fac7d2d30b33668a1537",
1233
1233
  "transform": "verbatim"
1234
1234
  },
1235
+ {
1236
+ "source": "package/dist/setup/flags.d.ts",
1237
+ "output": "setup/flags.d.ts",
1238
+ "bytes": 1975,
1239
+ "sourceSha256": "8475bfc500aaaae2ccc4f6d6a90be029911c88082e1f6fe646d9a02e24aecd3c",
1240
+ "outputSha256": "8475bfc500aaaae2ccc4f6d6a90be029911c88082e1f6fe646d9a02e24aecd3c",
1241
+ "transform": "verbatim"
1242
+ },
1243
+ {
1244
+ "source": "package/dist/setup/flags.js",
1245
+ "output": "setup/flags.js",
1246
+ "bytes": 4610,
1247
+ "sourceSha256": "6c424773289587568500e53a76e7a64074867bab6e97318ff9b619b93c694bfb",
1248
+ "outputSha256": "6c424773289587568500e53a76e7a64074867bab6e97318ff9b619b93c694bfb",
1249
+ "transform": "verbatim"
1250
+ },
1235
1251
  {
1236
1252
  "source": "package/dist/setup/index.d.ts",
1237
1253
  "output": "setup/index.d.ts",
1238
- "bytes": 970,
1239
- "sourceSha256": "f443b8d501334f8384878606ff19beee0241e70e7f4cc3dd0d0fd4636f8433c5",
1240
- "outputSha256": "f443b8d501334f8384878606ff19beee0241e70e7f4cc3dd0d0fd4636f8433c5",
1254
+ "bytes": 1011,
1255
+ "sourceSha256": "4a0f5a26bca035276077740d5fab9187000d15e575a6c195a0772d64d8c7e9f0",
1256
+ "outputSha256": "4a0f5a26bca035276077740d5fab9187000d15e575a6c195a0772d64d8c7e9f0",
1241
1257
  "transform": "verbatim"
1242
1258
  },
1243
1259
  {
1244
1260
  "source": "package/dist/setup/index.js",
1245
1261
  "output": "setup/index.js",
1246
- "bytes": 617,
1247
- "sourceSha256": "3ab259b0ba5e5e6d83ea9077adf11e2c561d4a7788710adbb6e8e0ed88dcd44b",
1248
- "outputSha256": "3ab259b0ba5e5e6d83ea9077adf11e2c561d4a7788710adbb6e8e0ed88dcd44b",
1262
+ "bytes": 658,
1263
+ "sourceSha256": "218409be186bc7e52d0606699502ccb272f024676018a1d1835a45573e2ea787",
1264
+ "outputSha256": "218409be186bc7e52d0606699502ccb272f024676018a1d1835a45573e2ea787",
1249
1265
  "transform": "verbatim"
1250
1266
  },
1251
1267
  {
@@ -1299,9 +1315,9 @@
1299
1315
  {
1300
1316
  "source": "package/dist/setup/types.d.ts",
1301
1317
  "output": "setup/types.d.ts",
1302
- "bytes": 5722,
1303
- "sourceSha256": "db068b3f2428734ad731c120443c7e5a432f5d568a8a61c21c7978855e613063",
1304
- "outputSha256": "db068b3f2428734ad731c120443c7e5a432f5d568a8a61c21c7978855e613063",
1318
+ "bytes": 6038,
1319
+ "sourceSha256": "f4091b3f1f5018e9ac9b3da4329cb388302ef1c12c7c927fb43c631e1a0295f6",
1320
+ "outputSha256": "f4091b3f1f5018e9ac9b3da4329cb388302ef1c12c7c927fb43c631e1a0295f6",
1305
1321
  "transform": "verbatim"
1306
1322
  },
1307
1323
  {