@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.
- package/dist/cli.js +1865 -571
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +291 -52
- package/dist/index.js +2166 -751
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +326 -72
- package/dist/server.js +3898 -2452
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/__fixtures__/runtime-layout-process.d.ts +2 -0
- package/dist/src/__fixtures__/runtime-layout-process.d.ts.map +1 -0
- package/dist/src/__fixtures__/runtime-layout-process.js +88 -0
- package/dist/src/__fixtures__/runtime-layout-process.js.map +1 -0
- package/dist/src/cli.d.ts +17 -6
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +26 -9
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +15 -8
- package/dist/src/common-auth-embedded/claustrum/hub.js +86 -42
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +16 -3
- package/dist/src/common-auth-embedded/setup/command.js +4 -49
- package/dist/src/common-auth-embedded/setup/flags.d.ts +50 -0
- package/dist/src/common-auth-embedded/setup/flags.js +123 -0
- package/dist/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/types.d.ts +7 -1
- package/dist/src/common-auth-embedded/source-output.json +47 -31
- package/dist/src/ga/server/auth.d.ts.map +1 -1
- package/dist/src/ga/server/auth.js +7 -2
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +18 -4
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts +7 -0
- package/dist/src/plugin/__fixtures__/controlled-timeouts.d.ts.map +1 -0
- package/dist/src/plugin/__fixtures__/controlled-timeouts.js +41 -0
- package/dist/src/plugin/__fixtures__/controlled-timeouts.js.map +1 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts +2 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.js +11 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -0
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +3 -0
- package/dist/src/plugin/__fixtures__/verified-store.d.ts.map +1 -0
- package/dist/src/plugin/__fixtures__/verified-store.js +50 -0
- package/dist/src/plugin/__fixtures__/verified-store.js.map +1 -0
- package/dist/src/plugin/auth-loader.d.ts +7 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +4 -4
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +7 -1
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +10 -13
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +2 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +4 -2
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/schema.js +1 -1
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +18 -19
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/errors.js +1 -1
- package/dist/src/plugin/errors.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +50 -27
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/ga-shared-vault-custody.d.ts +19 -5
- package/dist/src/plugin/ga-shared-vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/ga-shared-vault-custody.js +12 -4
- package/dist/src/plugin/ga-shared-vault-custody.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +31 -9
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/shared/source-sidebar.d.ts +6 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -1
- package/dist/src/plugin/shared/source-sidebar.js +1 -1
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
- package/dist/src/plugin/storage.d.ts +5 -2
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +5 -4
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +29 -8
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +61 -10
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/process-heartbeat.d.ts +22 -2
- package/dist/src/process-heartbeat.d.ts.map +1 -1
- package/dist/src/process-heartbeat.js +47 -10
- package/dist/src/process-heartbeat.js.map +1 -1
- package/dist/src/rpc/rpc-server.d.ts +8 -0
- package/dist/src/rpc/rpc-server.d.ts.map +1 -1
- package/dist/src/rpc/rpc-server.js +26 -1
- package/dist/src/rpc/rpc-server.js.map +1 -1
- package/dist/src/runtime-layout.d.ts +100 -0
- package/dist/src/runtime-layout.d.ts.map +1 -0
- package/dist/src/runtime-layout.js +1242 -0
- package/dist/src/runtime-layout.js.map +1 -0
- package/dist/src/runtime-paths.d.ts +132 -0
- package/dist/src/runtime-paths.d.ts.map +1 -0
- package/dist/src/runtime-paths.js +214 -0
- package/dist/src/runtime-paths.js.map +1 -0
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +30 -7
- package/dist/src/setup.js.map +1 -1
- package/dist/src/vault-folder.d.ts +38 -0
- package/dist/src/vault-folder.d.ts.map +1 -0
- package/dist/src/vault-folder.js +91 -0
- package/dist/src/vault-folder.js.map +1 -0
- package/dist/src/version-fence.d.ts +54 -0
- package/dist/src/version-fence.d.ts.map +1 -0
- package/dist/src/version-fence.js +254 -0
- package/dist/src/version-fence.js.map +1 -0
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/cli.d.ts +17 -6
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
- package/dist/types/src/common-auth-embedded/setup/flags.d.ts +50 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +7 -1
- package/dist/types/src/ga/server/auth.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts +7 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/cache/signature-cache.d.ts +7 -1
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/types/src/plugin/config/loader.d.ts +2 -1
- package/dist/types/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/types/src/plugin/debug.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-shared-vault-custody.d.ts +19 -5
- package/dist/types/src/plugin/ga-shared-vault-custody.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/source-sidebar.d.ts +6 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +5 -2
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +29 -8
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/process-heartbeat.d.ts +22 -2
- package/dist/types/src/process-heartbeat.d.ts.map +1 -1
- package/dist/types/src/rpc/rpc-server.d.ts +8 -0
- package/dist/types/src/rpc/rpc-server.d.ts.map +1 -1
- package/dist/types/src/runtime-layout.d.ts +100 -0
- package/dist/types/src/runtime-layout.d.ts.map +1 -0
- package/dist/types/src/runtime-paths.d.ts +132 -0
- package/dist/types/src/runtime-paths.d.ts.map +1 -0
- package/dist/types/src/setup.d.ts.map +1 -1
- package/dist/types/src/vault-folder.d.ts +38 -0
- package/dist/types/src/vault-folder.d.ts.map +1 -0
- package/dist/types/src/version-fence.d.ts +54 -0
- package/dist/types/src/version-fence.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +9 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +15 -8
- package/src/common-auth-embedded/claustrum/hub.js +86 -42
- package/src/common-auth-embedded/fs/refresh-file-lock.js +16 -3
- package/src/common-auth-embedded/setup/command.js +4 -49
- package/src/common-auth-embedded/setup/flags.d.ts +50 -0
- package/src/common-auth-embedded/setup/flags.js +123 -0
- package/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/types.d.ts +7 -1
- 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
|
-
|
|
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 =
|
|
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
|
-
|
|
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.
|
|
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.
|
|
65
|
-
"tarballSha256": "
|
|
66
|
-
"sri": "sha512-
|
|
67
|
-
"canonicalFiles":
|
|
68
|
-
"canonicalBytes":
|
|
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": "
|
|
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":
|
|
287
|
-
"sourceSha256": "
|
|
288
|
-
"outputSha256": "
|
|
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":
|
|
295
|
-
"sourceSha256": "
|
|
296
|
-
"outputSha256": "
|
|
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":
|
|
343
|
-
"sourceSha256": "
|
|
344
|
-
"outputSha256": "
|
|
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":
|
|
631
|
-
"sourceSha256": "
|
|
632
|
-
"outputSha256": "
|
|
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":
|
|
1191
|
-
"sourceSha256": "
|
|
1192
|
-
"outputSha256": "
|
|
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":
|
|
1239
|
-
"sourceSha256": "
|
|
1240
|
-
"outputSha256": "
|
|
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":
|
|
1247
|
-
"sourceSha256": "
|
|
1248
|
-
"outputSha256": "
|
|
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":
|
|
1303
|
-
"sourceSha256": "
|
|
1304
|
-
"outputSha256": "
|
|
1318
|
+
"bytes": 6038,
|
|
1319
|
+
"sourceSha256": "f4091b3f1f5018e9ac9b3da4329cb388302ef1c12c7c927fb43c631e1a0295f6",
|
|
1320
|
+
"outputSha256": "f4091b3f1f5018e9ac9b3da4329cb388302ef1c12c7c927fb43c631e1a0295f6",
|
|
1305
1321
|
"transform": "verbatim"
|
|
1306
1322
|
},
|
|
1307
1323
|
{
|