@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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Where this process keeps its vault files, settled once by each entry point
|
|
2
|
+
// (the OpenCode 1 plugin, an OpenCode 2 activation, the CLI and setup) before
|
|
3
|
+
// it reads or writes any of them.
|
|
4
|
+
//
|
|
5
|
+
// `prepareVaultFolder` runs the one-time move of the vault files out of
|
|
6
|
+
// OpenCode's config folder (`runtime-layout.ts`) and returns the vault folder
|
|
7
|
+
// the decided layout names. When the move cannot settle a layout (vault files
|
|
8
|
+
// that conflict between the two folders, a damaged marker, a state folder that
|
|
9
|
+
// belongs to another config folder, a layout lock it could not take), it
|
|
10
|
+
// returns the refusal instead. The caller must then serve neither vault nor
|
|
11
|
+
// local accounts: which folder holds this host's vault enrollment is unknown,
|
|
12
|
+
// and serving local accounts could bypass a vault the user chose.
|
|
13
|
+
//
|
|
14
|
+
// A refusal is kept for the life of the process, like a decided layout: its
|
|
15
|
+
// message tells the user to restart OpenCode once it is resolved, and later
|
|
16
|
+
// plugin instances or OpenCode 2 locations in the same process get the same
|
|
17
|
+
// answer at once instead of waiting for the layout lock again.
|
|
18
|
+
import { createLogger } from './plugin/logger';
|
|
19
|
+
import { pluginPackageVersion } from './process-heartbeat';
|
|
20
|
+
import { prepareRuntimeLayout, RuntimeLayoutRefusal, } from './runtime-layout';
|
|
21
|
+
import { getVaultDir, runtimeLayoutLocation } from './runtime-paths';
|
|
22
|
+
// Refusals by config folder, on the global object because OpenCode 2 may load
|
|
23
|
+
// more than one copy of this bundle into one process.
|
|
24
|
+
const refusalsKey = Symbol.for('@cortexkit/antigravity-auth/vault-folder-refusals');
|
|
25
|
+
const globalState = globalThis;
|
|
26
|
+
const refusals = globalState[refusalsKey] ?? new Map();
|
|
27
|
+
globalState[refusalsKey] = refusals;
|
|
28
|
+
function locationKey() {
|
|
29
|
+
const location = runtimeLayoutLocation();
|
|
30
|
+
return `${location.stateHomeDir}\0${location.key}`;
|
|
31
|
+
}
|
|
32
|
+
/** Test seam: forget every refusal this process kept. */
|
|
33
|
+
export function __resetVaultFoldersForTest() {
|
|
34
|
+
refusals.clear();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Settle this process's vault folder for the config folder `accountFile`
|
|
38
|
+
* belongs to, moving the vault files first when that is safe. Resolves with
|
|
39
|
+
* the refusal rather than rejecting when the layout cannot be settled.
|
|
40
|
+
* `version` defaults to this package's own version (`unknown` when its
|
|
41
|
+
* manifest cannot be read, which other processes' version checks treat as
|
|
42
|
+
* blocking).
|
|
43
|
+
*/
|
|
44
|
+
export async function prepareVaultFolder(options) {
|
|
45
|
+
const { accountFile } = options;
|
|
46
|
+
const key = locationKey();
|
|
47
|
+
const kept = refusals.get(key);
|
|
48
|
+
if (kept)
|
|
49
|
+
return refused(accountFile, kept);
|
|
50
|
+
const log = options.log ?? createLogger('runtime-layout');
|
|
51
|
+
const version = options.version ?? (await pluginPackageVersion().catch(() => 'unknown'));
|
|
52
|
+
try {
|
|
53
|
+
await prepareRuntimeLayout({
|
|
54
|
+
version,
|
|
55
|
+
accountFile,
|
|
56
|
+
log,
|
|
57
|
+
...(options.layoutLockWaitMs === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: { layoutLockWaitMs: options.layoutLockWaitMs }),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const refusal = error instanceof RuntimeLayoutRefusal
|
|
64
|
+
? error
|
|
65
|
+
: new RuntimeLayoutRefusal(runtimeLayoutLocation().stateHomeDir, error instanceof Error ? error.name : typeof error);
|
|
66
|
+
if (!refusals.has(key)) {
|
|
67
|
+
refusals.set(key, refusal);
|
|
68
|
+
log.warn(refusal.message, {
|
|
69
|
+
stateDir: refusal.stateDir,
|
|
70
|
+
errorClass: refusal.errorClass,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return refused(accountFile, refusals.get(key) ?? refusal);
|
|
74
|
+
}
|
|
75
|
+
return { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The vault folder for code that runs after its entry point prepared: the
|
|
79
|
+
* kept refusal, or the folder of the decided layout. A process that never
|
|
80
|
+
* prepared follows the layout marker without taking a lock.
|
|
81
|
+
*/
|
|
82
|
+
export function currentVaultFolder(accountFile) {
|
|
83
|
+
const kept = refusals.get(locationKey());
|
|
84
|
+
return kept
|
|
85
|
+
? refused(accountFile, kept)
|
|
86
|
+
: { accountFile, vaultDir: getVaultDir(accountFile) };
|
|
87
|
+
}
|
|
88
|
+
function refused(accountFile, refusal) {
|
|
89
|
+
return { accountFile, vaultDir: getVaultDir(accountFile), refusal };
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=vault-folder.js.map
|
|
@@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C,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,CAAA;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;IACxC,OAAO,IAAI;QACT,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;QAC5B,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,CAAA;AACzD,CAAC;AAED,SAAS,OAAO,CACd,WAAmB,EACnB,OAA6B;IAE7B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** One live process that keeps the fence shut. */
|
|
2
|
+
export interface VersionFenceBlocker {
|
|
3
|
+
/** `'unknown'` when a whole directory could not be read. */
|
|
4
|
+
pid: number | 'unknown';
|
|
5
|
+
/** The version its heartbeat or port file names, or `'unknown'`. */
|
|
6
|
+
version: string;
|
|
7
|
+
/** The file or directory that showed it. */
|
|
8
|
+
detail: string;
|
|
9
|
+
}
|
|
10
|
+
export type VersionFenceResult = {
|
|
11
|
+
open: true;
|
|
12
|
+
} | {
|
|
13
|
+
open: false;
|
|
14
|
+
blockers: VersionFenceBlocker[];
|
|
15
|
+
};
|
|
16
|
+
export interface VersionFenceOptions {
|
|
17
|
+
/** The XDG state base; defaults to `$XDG_STATE_HOME` or `~/.local/state`. */
|
|
18
|
+
stateHome?: string;
|
|
19
|
+
/** Root holding the per-project RPC directories; defaults under the base. */
|
|
20
|
+
rpcDir?: string;
|
|
21
|
+
/** The version that wants to act. */
|
|
22
|
+
currentVersion: string;
|
|
23
|
+
isAlive?: (pid: number) => boolean;
|
|
24
|
+
/** This process, which never blocks itself. Defaults to `process.pid`. */
|
|
25
|
+
selfPid?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Set when the vault files are about to move: a live process that uses the
|
|
28
|
+
* legacy layout for any config folder, or that writes no layouts at all,
|
|
29
|
+
* also keeps the fence shut.
|
|
30
|
+
*/
|
|
31
|
+
layoutMove?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The XDG state base every state-home file of the plugin lives under:
|
|
35
|
+
* `$XDG_STATE_HOME`, else `~/.local/state`, on every OS. An empty
|
|
36
|
+
* XDG_STATE_HOME counts as unset, as it does for the heartbeat.
|
|
37
|
+
*/
|
|
38
|
+
export declare function defaultStateHome(): string;
|
|
39
|
+
/** Where a plugin process writes its heartbeat, `<pid>.json`. */
|
|
40
|
+
export declare function processHeartbeatDir(stateHome?: string): string;
|
|
41
|
+
/** The root of the plugin's per-project RPC directories. */
|
|
42
|
+
export declare function rpcStateRoot(stateHome?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Semver precedence of `a` against `b` (negative, zero, positive), or
|
|
45
|
+
* undefined when either is not a version. A pre-release sorts below its
|
|
46
|
+
* release; build metadata is ignored.
|
|
47
|
+
*/
|
|
48
|
+
export declare function compareVersions(a: string, b: string): number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Whether no other live process keeps the fence shut. Never throws: anything
|
|
51
|
+
* it cannot establish counts as a blocker.
|
|
52
|
+
*/
|
|
53
|
+
export declare function versionFenceOpen(options: VersionFenceOptions): Promise<VersionFenceResult>;
|
|
54
|
+
//# sourceMappingURL=version-fence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-fence.d.ts","sourceRoot":"","sources":["../../src/version-fence.ts"],"names":[],"mappings":"AAoCA,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAAA;AAEpD,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAClC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,SAAS,SAAqB,GAAG,MAAM,CAE1E;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,SAAS,SAAqB,GAAG,MAAM,CAEnE;AA+BD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA2BxE;AA0DD;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAwF7B"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// Decides whether the one-time move of the plugin's vault files out of
|
|
2
|
+
// OpenCode's config folder may run: only while no other live antigravity-auth
|
|
3
|
+
// process on this machine could still read or write the old files.
|
|
4
|
+
//
|
|
5
|
+
// A process is found through either of two files it leaves on disk:
|
|
6
|
+
//
|
|
7
|
+
// - a heartbeat, `<state>/cortexkit/antigravity-auth/processes/<pid>.json`
|
|
8
|
+
// holding `{ "pid", "version", "startedAt", "layouts" }`
|
|
9
|
+
// (`process-heartbeat.ts`), which versions from 3.0.13 on write;
|
|
10
|
+
// - an RPC port file,
|
|
11
|
+
// `<state>/cortexkit/antigravity-auth/rpc/<16 hex>/port-<pid>.json`, which
|
|
12
|
+
// OpenCode 1 plugin instances write. Versions before the move wrote it
|
|
13
|
+
// without a `version`, so such a file blocks.
|
|
14
|
+
//
|
|
15
|
+
// A process counts as running while its pid is alive. Each record must carry
|
|
16
|
+
// its own current-or-newer version: a heartbeat left by a crashed process
|
|
17
|
+
// cannot vouch for a port file written by an older process reusing that pid.
|
|
18
|
+
// The fence fails closed on unreadable records and missing or invalid
|
|
19
|
+
// versions.
|
|
20
|
+
//
|
|
21
|
+
// With `layoutMove`, a heartbeat must also name, under `layouts`, which file
|
|
22
|
+
// layout the process uses for each config folder. A live process on the
|
|
23
|
+
// legacy layout for any config folder keeps the fence shut, and so does a
|
|
24
|
+
// heartbeat with no `layouts` at all. Any folder, not just the one moving: a
|
|
25
|
+
// key written by another version may be spelled differently for the same
|
|
26
|
+
// folder, and blocking too widely only delays a move.
|
|
27
|
+
//
|
|
28
|
+
// What this cannot see: an OpenCode 2 location or a CLI run of a version
|
|
29
|
+
// before 3.0.13 writes neither file. Port files written under a custom
|
|
30
|
+
// ANTIGRAVITY_AUTH_RPC_DIR, or under an empty XDG_STATE_HOME (which the RPC
|
|
31
|
+
// writer treats as a relative path), are outside the folders read here.
|
|
32
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
33
|
+
import { homedir } from 'node:os';
|
|
34
|
+
import { join } from 'node:path';
|
|
35
|
+
/**
|
|
36
|
+
* The XDG state base every state-home file of the plugin lives under:
|
|
37
|
+
* `$XDG_STATE_HOME`, else `~/.local/state`, on every OS. An empty
|
|
38
|
+
* XDG_STATE_HOME counts as unset, as it does for the heartbeat.
|
|
39
|
+
*/
|
|
40
|
+
export function defaultStateHome() {
|
|
41
|
+
return process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state');
|
|
42
|
+
}
|
|
43
|
+
/** Where a plugin process writes its heartbeat, `<pid>.json`. */
|
|
44
|
+
export function processHeartbeatDir(stateHome = defaultStateHome()) {
|
|
45
|
+
return join(stateHome, 'cortexkit', 'antigravity-auth', 'processes');
|
|
46
|
+
}
|
|
47
|
+
/** The root of the plugin's per-project RPC directories. */
|
|
48
|
+
export function rpcStateRoot(stateHome = defaultStateHome()) {
|
|
49
|
+
return join(stateHome, 'cortexkit', 'antigravity-auth', 'rpc');
|
|
50
|
+
}
|
|
51
|
+
/** The plugin names each project's RPC directory by 16 hex digits. */
|
|
52
|
+
function isRpcProjectDir(name) {
|
|
53
|
+
return /^[0-9a-f]{16}$/.test(name);
|
|
54
|
+
}
|
|
55
|
+
function pidAlive(pid) {
|
|
56
|
+
try {
|
|
57
|
+
process.kill(pid, 0);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// EPERM: the process exists but belongs to someone else.
|
|
62
|
+
return error.code === 'EPERM';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function parseSemver(value) {
|
|
66
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/.exec(value.trim());
|
|
67
|
+
if (!match)
|
|
68
|
+
return undefined;
|
|
69
|
+
return {
|
|
70
|
+
core: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
71
|
+
pre: match[4] ? match[4].split('.') : [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Semver precedence of `a` against `b` (negative, zero, positive), or
|
|
76
|
+
* undefined when either is not a version. A pre-release sorts below its
|
|
77
|
+
* release; build metadata is ignored.
|
|
78
|
+
*/
|
|
79
|
+
export function compareVersions(a, b) {
|
|
80
|
+
const left = parseSemver(a);
|
|
81
|
+
const right = parseSemver(b);
|
|
82
|
+
if (!left || !right)
|
|
83
|
+
return undefined;
|
|
84
|
+
for (let i = 0; i < 3; i++) {
|
|
85
|
+
const diff = left.core[i] - right.core[i];
|
|
86
|
+
if (diff !== 0)
|
|
87
|
+
return Math.sign(diff);
|
|
88
|
+
}
|
|
89
|
+
if (left.pre.length === 0 || right.pre.length === 0)
|
|
90
|
+
return Math.sign(right.pre.length - left.pre.length);
|
|
91
|
+
for (let i = 0; i < Math.max(left.pre.length, right.pre.length); i++) {
|
|
92
|
+
const x = left.pre[i];
|
|
93
|
+
const y = right.pre[i];
|
|
94
|
+
if (x === undefined)
|
|
95
|
+
return -1;
|
|
96
|
+
if (y === undefined)
|
|
97
|
+
return 1;
|
|
98
|
+
const xNumeric = /^\d+$/.test(x);
|
|
99
|
+
const yNumeric = /^\d+$/.test(y);
|
|
100
|
+
if (xNumeric && yNumeric) {
|
|
101
|
+
const diff = Number(x) - Number(y);
|
|
102
|
+
if (diff !== 0)
|
|
103
|
+
return Math.sign(diff);
|
|
104
|
+
}
|
|
105
|
+
else if (xNumeric !== yNumeric) {
|
|
106
|
+
return xNumeric ? -1 : 1;
|
|
107
|
+
}
|
|
108
|
+
else if (x !== y) {
|
|
109
|
+
return x < y ? -1 : 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
/** A missing directory lists as empty; any other failure is reported. */
|
|
115
|
+
async function list(dir) {
|
|
116
|
+
try {
|
|
117
|
+
return { ok: true, names: await readdir(dir) };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const code = error.code;
|
|
121
|
+
if (code === 'ENOENT')
|
|
122
|
+
return { ok: true, names: [] };
|
|
123
|
+
return { ok: false, code, error: `${dir}: ${String(error)}` };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function readProcessRecord(path, pid) {
|
|
127
|
+
let text;
|
|
128
|
+
try {
|
|
129
|
+
text = await readFile(path, 'utf8');
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
// Removed between the listing and the read: that process has exited.
|
|
133
|
+
if (error.code === 'ENOENT')
|
|
134
|
+
return { kind: 'gone' };
|
|
135
|
+
return { kind: 'unreadable' };
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const value = JSON.parse(text);
|
|
139
|
+
if (value !== null &&
|
|
140
|
+
typeof value === 'object' &&
|
|
141
|
+
value.pid === pid &&
|
|
142
|
+
typeof value.version === 'string') {
|
|
143
|
+
const layouts = value.layouts;
|
|
144
|
+
return {
|
|
145
|
+
kind: 'ok',
|
|
146
|
+
version: value.version,
|
|
147
|
+
...(layouts !== null &&
|
|
148
|
+
typeof layouts === 'object' &&
|
|
149
|
+
!Array.isArray(layouts)
|
|
150
|
+
? { layouts: layouts }
|
|
151
|
+
: {}),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch { }
|
|
156
|
+
return { kind: 'unreadable' };
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Whether no other live process keeps the fence shut. Never throws: anything
|
|
160
|
+
* it cannot establish counts as a blocker.
|
|
161
|
+
*/
|
|
162
|
+
export async function versionFenceOpen(options) {
|
|
163
|
+
const isAlive = options.isAlive ?? pidAlive;
|
|
164
|
+
const self = options.selfPid ?? process.pid;
|
|
165
|
+
const blockers = new Map();
|
|
166
|
+
const block = (entry) => {
|
|
167
|
+
const key = entry.pid === 'unknown' ? `dir:${entry.detail}` : entry.pid;
|
|
168
|
+
if (!blockers.has(key))
|
|
169
|
+
blockers.set(key, entry);
|
|
170
|
+
};
|
|
171
|
+
const alive = (pid) => {
|
|
172
|
+
try {
|
|
173
|
+
return isAlive(pid);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const pidFrom = (name, pattern) => {
|
|
180
|
+
const match = pattern.exec(name);
|
|
181
|
+
const pid = match ? Number(match[1]) : Number.NaN;
|
|
182
|
+
return Number.isSafeInteger(pid) && pid >= 1 ? pid : undefined;
|
|
183
|
+
};
|
|
184
|
+
// Heartbeats: the version a live process says it runs.
|
|
185
|
+
const heartbeatDir = processHeartbeatDir(options.stateHome);
|
|
186
|
+
const heartbeats = await list(heartbeatDir);
|
|
187
|
+
if (!heartbeats.ok)
|
|
188
|
+
block({ pid: 'unknown', version: 'unknown', detail: heartbeats.error });
|
|
189
|
+
for (const name of heartbeats.ok ? heartbeats.names : []) {
|
|
190
|
+
const pid = pidFrom(name, /^(\d+)\.json$/);
|
|
191
|
+
if (pid === undefined || pid === self)
|
|
192
|
+
continue;
|
|
193
|
+
const path = join(heartbeatDir, name);
|
|
194
|
+
const heartbeat = await readProcessRecord(path, pid);
|
|
195
|
+
if (heartbeat.kind === 'gone')
|
|
196
|
+
continue;
|
|
197
|
+
if (!alive(pid))
|
|
198
|
+
continue;
|
|
199
|
+
if (heartbeat.kind === 'unreadable') {
|
|
200
|
+
block({ pid, version: 'unknown', detail: path });
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const order = compareVersions(heartbeat.version, options.currentVersion);
|
|
204
|
+
if (order === undefined || order < 0) {
|
|
205
|
+
block({ pid, version: heartbeat.version, detail: path });
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (options.layoutMove === true &&
|
|
209
|
+
(heartbeat.layouts === undefined ||
|
|
210
|
+
Object.values(heartbeat.layouts).includes('legacy')))
|
|
211
|
+
block({ pid, version: heartbeat.version, detail: path });
|
|
212
|
+
}
|
|
213
|
+
// Port files prove their version independently of heartbeats. Even an
|
|
214
|
+
// unreadable body still names a pid through `port-<pid>.json`.
|
|
215
|
+
const rpcRoot = options.rpcDir ?? rpcStateRoot(options.stateHome);
|
|
216
|
+
const projects = await list(rpcRoot);
|
|
217
|
+
if (!projects.ok)
|
|
218
|
+
block({ pid: 'unknown', version: 'unknown', detail: projects.error });
|
|
219
|
+
for (const project of projects.ok ? projects.names : []) {
|
|
220
|
+
if (!isRpcProjectDir(project))
|
|
221
|
+
continue;
|
|
222
|
+
const dir = join(rpcRoot, project);
|
|
223
|
+
const ports = await list(dir);
|
|
224
|
+
if (!ports.ok) {
|
|
225
|
+
// A plain file with a directory's name is not a project directory.
|
|
226
|
+
if (ports.code === 'ENOTDIR')
|
|
227
|
+
continue;
|
|
228
|
+
block({ pid: 'unknown', version: 'unknown', detail: ports.error });
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
for (const name of ports.names) {
|
|
232
|
+
const pid = pidFrom(name, /^port-(\d+)\.json$/);
|
|
233
|
+
if (pid === undefined || pid === self || !alive(pid))
|
|
234
|
+
continue;
|
|
235
|
+
const path = join(dir, name);
|
|
236
|
+
const port = await readProcessRecord(path, pid);
|
|
237
|
+
if (port.kind === 'gone')
|
|
238
|
+
continue;
|
|
239
|
+
const version = port.kind === 'ok' ? port.version : 'unknown';
|
|
240
|
+
const order = compareVersions(version, options.currentVersion);
|
|
241
|
+
if (order === undefined || order < 0)
|
|
242
|
+
block({ pid, version, detail: path });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Directory listings come in no fixed order; report blockers by pid.
|
|
246
|
+
const rank = (b) => b.pid === 'unknown' ? Number.POSITIVE_INFINITY : b.pid;
|
|
247
|
+
return blockers.size === 0
|
|
248
|
+
? { open: true }
|
|
249
|
+
: {
|
|
250
|
+
open: false,
|
|
251
|
+
blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b)),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=version-fence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-fence.js","sourceRoot":"","sources":["../../src/version-fence.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,8EAA8E;AAC9E,mEAAmE;AACnE,EAAE;AACF,oEAAoE;A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,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACxD,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC;QACxB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;QAChB,CAAC,CAAC;YACE,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;SACnE,CAAA;AACP,CAAC"}
|
package/dist/tui-build-map.json
CHANGED
package/dist/types/src/cli.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ export interface CliDependencies {
|
|
|
13
13
|
* driving `runCli` directly), no heartbeat is written.
|
|
14
14
|
*/
|
|
15
15
|
processHeartbeat?: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Settles where the plugin's vault files live, moving them out of
|
|
18
|
+
* OpenCode's config folder when that is safe, before a command that reads
|
|
19
|
+
* them (login, and setup on a real run) and before its heartbeat. Rejects
|
|
20
|
+
* with the reason when they cannot be settled; the command then fails with
|
|
21
|
+
* it. `runCliProcess` supplies it; when it is absent, commands read the
|
|
22
|
+
* vault files where the layout marker says, without moving anything.
|
|
23
|
+
*/
|
|
24
|
+
prepareVaultFolder?: () => Promise<void>;
|
|
16
25
|
prompt(message: string): Promise<string>;
|
|
17
26
|
openBrowser(url: string): Promise<void>;
|
|
18
27
|
isHeadless?(): boolean;
|
|
@@ -58,12 +67,14 @@ export type CliAccountsRead = {
|
|
|
58
67
|
};
|
|
59
68
|
export declare function runCli(argv: string[], deps: CliDependencies): Promise<number>;
|
|
60
69
|
/**
|
|
61
|
-
* Run one CLI command as this process's whole run. Commands
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
70
|
+
* Run one CLI command as this process's whole run. Commands settle the vault
|
|
71
|
+
* folder (when they read it) and put the heartbeat on disk through
|
|
72
|
+
* `prepareVaultFolder` and `processHeartbeat` only once they are about to use
|
|
73
|
+
* the plugin's data:
|
|
74
|
+
* never for help, a rejected command line, a setup preview or a setup that
|
|
75
|
+
* refuses before its first change, which must leave the disk untouched. The
|
|
76
|
+
* heartbeat is removed when the command finishes, because the process exits
|
|
77
|
+
* right after.
|
|
67
78
|
*/
|
|
68
79
|
export declare function runCliProcess(argv: string[], deps: CliDependencies): Promise<number>;
|
|
69
80
|
export declare function createDefaultCliDependencies(): CliDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAQtB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,OAAO,EACR,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,iBAAiB,EACtB,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,KAAK,gBAAgB,EAQtB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,OAAO,EACR,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,iBAAiB,EACtB,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAsB7B,UAA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CAAC,CAAA;IAC9D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAChE,+DAA+D;IAC/D,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CACnD;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAiN3C,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC,CA+HjB;AAID;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAYD,wBAAgB,4BAA4B,IAAI,eAAe,CAiE9D;AAmED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,iBAAiB,CAoC/D;AAqDD;;;;;GAKG;AACH,wBAAgB,mCAAmC,IAAI,sBAAsB,CAuB5E;AAsBD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -107,6 +107,15 @@ export interface EnrollmentAncestorOptions {
|
|
|
107
107
|
* sticky ancestors are accepted. Windows uses the shared safe-parent policy.
|
|
108
108
|
*/
|
|
109
109
|
export declare function refuseWritableAncestor(parent: string, options?: EnrollmentAncestorOptions): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Create `directory` owner-only, or make an existing one owner-only. POSIX:
|
|
112
|
+
* every component it creates gets mode 0700, a directory another user owns is
|
|
113
|
+
* refused, and one that group or others can reach is tightened to 0700.
|
|
114
|
+
* Windows: private-files creates missing components owner-only and verifies
|
|
115
|
+
* existing ones without modifying them. `what` names the directory in the
|
|
116
|
+
* ownership refusal.
|
|
117
|
+
*/
|
|
118
|
+
export declare function ensureClaustrumPrivateDirectory(directory: string, options?: EnrollmentAncestorOptions, what?: string): Promise<void>;
|
|
110
119
|
export declare function readClaustrumEnrollmentStatus(paths: ClaustrumEnrollmentPaths, proposedName: string): Promise<ClaustrumEnrollmentStatus>;
|
|
111
120
|
/**
|
|
112
121
|
* Resolve the host's account mode from its enrollment files. It never changes
|
|
@@ -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 {};
|
|
@@ -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';
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/ga/server/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AASzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEtE,eAAO,MAAM,kBAAkB,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/ga/server/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AASzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEtE,eAAO,MAAM,kBAAkB,sBAAsB,CAAA;AAcrD,mFAAmF;AACnF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE;IAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,CAAA;CAAE,EAC1E,SAAS,GAAE,MAAM,OAAO,CAAC,mBAAmB,CAAiB,EAC7D,KAAK,GAAE;IAAE,KAAK,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;CAAO,GACvE,OAAO,CAAC,YAAY,CAAC,CAoCvB"}
|