@cortexkit/opencode-antigravity-auth 3.0.6 → 3.0.8
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 +1621 -183
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +228 -62
- package/dist/index.js +2728 -883
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +291 -104
- package/dist/server.js +2255 -390
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/src/common-auth-embedded/claustrum/index.js +4 -1
- package/dist/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/dist/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +10 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/dist/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/dist/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/src/common-auth-embedded/quota/format.js +203 -18
- package/dist/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/src/common-auth-embedded/quota/index.js +1 -1
- package/dist/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/src/common-auth-embedded/setup/command-error.js +79 -0
- package/dist/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/dist/src/common-auth-embedded/setup/command.js +75 -19
- package/dist/src/common-auth-embedded/setup/enroll.js +17 -5
- package/dist/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/register.js +8 -2
- package/dist/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/src/common-auth-embedded/source-output.json +142 -94
- package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/pool.js +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/dist/src/ga/server/index.d.ts +2 -0
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +18 -3
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +37 -3
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +2 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +5 -4
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +2 -1
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +8 -6
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +7 -3
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +2 -5
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +3 -3
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +2 -5
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/request.d.ts +1 -2
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +8 -12
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/src/plugin/shared/after-handoff.js +89 -0
- package/dist/src/plugin/shared/after-handoff.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +193 -90
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +17 -1
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +16 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +60 -10
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/sidebar-projection.d.ts +4 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -1
- package/dist/src/sidebar-projection.js +6 -2
- package/dist/src/sidebar-projection.js.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +94 -0
- package/dist/src/tui/quota-layout.d.ts.map +1 -0
- package/dist/src/tui/quota-layout.js +139 -0
- package/dist/src/tui/quota-layout.js.map +1 -0
- package/dist/src/tui/route-layout.d.ts +8 -0
- package/dist/src/tui/route-layout.d.ts.map +1 -0
- package/dist/src/tui/route-layout.js +36 -0
- package/dist/src/tui/route-layout.js.map +1 -0
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +105 -191
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +60 -31
- package/dist/tui-ga-build-map.json +46 -17
- package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/dist/types/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/dist/types/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/types/src/ga/server/index.d.ts +2 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts +2 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts +2 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +1 -2
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/after-handoff.d.ts +14 -0
- package/dist/types/src/plugin/shared/after-handoff.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +16 -3
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +13 -4
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +16 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/common-auth-embedded/claustrum/availability.d.ts +89 -0
- package/src/common-auth-embedded/claustrum/availability.js +106 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +41 -1
- package/src/common-auth-embedded/claustrum/consumer.js +152 -6
- package/src/common-auth-embedded/claustrum/custody.d.ts +135 -14
- package/src/common-auth-embedded/claustrum/custody.js +311 -16
- package/src/common-auth-embedded/claustrum/errors.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +5 -3
- package/src/common-auth-embedded/claustrum/index.js +4 -1
- package/src/common-auth-embedded/claustrum/insula.d.ts +48 -0
- package/src/common-auth-embedded/claustrum/insula.js +286 -21
- package/src/common-auth-embedded/claustrum/watch.d.ts +141 -0
- package/src/common-auth-embedded/claustrum/watch.js +254 -0
- package/src/common-auth-embedded/fs/private-files.js +10 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +6 -1
- package/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/src/common-auth-embedded/quota/format.d.ts +17 -3
- package/src/common-auth-embedded/quota/format.js +203 -18
- package/src/common-auth-embedded/quota/index.d.ts +2 -2
- package/src/common-auth-embedded/quota/index.js +1 -1
- package/src/common-auth-embedded/quota/projection.d.ts +16 -0
- package/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/src/common-auth-embedded/setup/command-error.js +79 -0
- package/src/common-auth-embedded/setup/command-runner.js +118 -24
- package/src/common-auth-embedded/setup/command.js +75 -19
- package/src/common-auth-embedded/setup/enroll.js +17 -5
- package/src/common-auth-embedded/setup/index.d.ts +2 -1
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/register.js +8 -2
- package/src/common-auth-embedded/setup/types.d.ts +14 -0
- package/src/common-auth-embedded/source-output.json +142 -94
- package/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/src/common-auth-embedded/store/pool.js +0 -1
- package/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-compiled/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-compiled/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-compiled/tui/quota-layout.js +378 -0
- package/src/tui-compiled/tui/route-layout.js +30 -0
- package/src/tui-compiled/tui.js +245 -501
- package/src/tui-ga-compiled/host-ga.js +82 -52
- package/src/tui-ga-compiled/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +378 -0
- package/src/tui-ga-raw/host-ga.tsx +71 -30
- package/src/tui-ga-raw/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +203 -18
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +1 -1
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +391 -0
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +10 -2
- package/src/tui-raw/common-auth-embedded/quota/format.js +203 -18
- package/src/tui-raw/common-auth-embedded/quota/index.js +1 -1
- package/src/tui-raw/tui/quota-layout.tsx +391 -0
- package/src/tui-raw/tui/route-layout.js +30 -0
- package/src/tui-raw/tui.tsx +171 -411
- package/src/tui.tsx +171 -411
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { select } from '../auth-menu/select.js';
|
|
2
2
|
import { isInteractive, printLine, processTerminal, } from '../auth-menu/terminal.js';
|
|
3
|
-
import { hostEnrollmentPaths } from '../claustrum/enrollment.js';
|
|
3
|
+
import { enrollmentAuthority, hostEnrollmentPaths, } from '../claustrum/enrollment.js';
|
|
4
|
+
import { recordSetupEnrollment, setupEnrollmentLine } from './command-error.js';
|
|
4
5
|
import { defaultCommandRunner } from './command-runner.js';
|
|
5
6
|
import { detectHosts } from './detect.js';
|
|
6
|
-
import { connectSetupHost } from './enroll.js';
|
|
7
|
+
import { connectSetupHost, HostNotEnrolledError } from './enroll.js';
|
|
7
8
|
import { setupPaths } from './paths.js';
|
|
8
9
|
import { assertHostsStopped, createProcessFence, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
|
|
9
10
|
import { selectSetupHosts } from './prompts.js';
|
|
@@ -52,6 +53,29 @@ function validatePlugin(plugin) {
|
|
|
52
53
|
throw new Error('Setup requires lowercase vault names containing only letters, digits and dashes.');
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Turn what setup recorded into one outcome per selected host, in setup order.
|
|
58
|
+
* A host setup never reached was never asked to enroll. Only a host whose
|
|
59
|
+
* enrollment was in flight when setup failed is checked on disk, by reading its
|
|
60
|
+
* enrollment files once with `enrollmentAuthority`; if that read fails it stays
|
|
61
|
+
* `unknown`.
|
|
62
|
+
*/
|
|
63
|
+
async function enrollmentReport(plugin, hosts, recorded) {
|
|
64
|
+
const report = [];
|
|
65
|
+
for (const host of hosts) {
|
|
66
|
+
let outcome = recorded.get(host) ?? 'not-enrolled';
|
|
67
|
+
if (outcome === 'unknown') {
|
|
68
|
+
const { name, paths } = plugin.vault.hosts[host];
|
|
69
|
+
const authority = await enrollmentAuthority(hostEnrollmentPaths(paths), name).catch(() => 'unreadable');
|
|
70
|
+
if (authority === 'vault')
|
|
71
|
+
outcome = 'enrolled';
|
|
72
|
+
else if (authority === 'local')
|
|
73
|
+
outcome = 'not-enrolled';
|
|
74
|
+
}
|
|
75
|
+
report.push({ host, outcome });
|
|
76
|
+
}
|
|
77
|
+
return report;
|
|
78
|
+
}
|
|
55
79
|
export async function runSetup(plugin, argv = [], io = {}) {
|
|
56
80
|
const options = flags(argv);
|
|
57
81
|
validatePlugin(plugin);
|
|
@@ -190,23 +214,55 @@ export async function runSetup(plugin, argv = [], io = {}) {
|
|
|
190
214
|
hosts: Object.freeze([...hosts]),
|
|
191
215
|
piAgentDir: detection.pi.directory,
|
|
192
216
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
await
|
|
199
|
-
|
|
200
|
-
await
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
// Each host's vault enrollment as it happens. A host the operator approved
|
|
218
|
+
// stays enrolled if a later step fails, so a failure reports this record.
|
|
219
|
+
const enrollment = new Map();
|
|
220
|
+
try {
|
|
221
|
+
for (const host of hosts) {
|
|
222
|
+
await stopped();
|
|
223
|
+
await plugin.beforeSignIn?.(host, context);
|
|
224
|
+
await stopped();
|
|
225
|
+
if (useVault) {
|
|
226
|
+
enrollment.set(host, 'unknown');
|
|
227
|
+
try {
|
|
228
|
+
await connectSetupHost(plugin, host, io, terminal, stopped);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (error instanceof HostNotEnrolledError)
|
|
232
|
+
enrollment.set(host, 'not-enrolled');
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
enrollment.set(host, 'enrolled');
|
|
236
|
+
}
|
|
237
|
+
else
|
|
238
|
+
await plugin.signInLocal(host, context);
|
|
239
|
+
await stopped();
|
|
240
|
+
await plugin.beforeRegister?.(host, mode, context);
|
|
241
|
+
await stopped();
|
|
242
|
+
if (host === 'opencode')
|
|
243
|
+
await registerOpenCode(writes, stopped);
|
|
244
|
+
else
|
|
245
|
+
await registerPi(plugin, detection.pi.executable, io);
|
|
246
|
+
await stopped();
|
|
247
|
+
await plugin.migrate(host, context);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
// Before any enrollment began nothing is connected: nothing to report.
|
|
252
|
+
if (enrollment.size === 0)
|
|
253
|
+
throw error;
|
|
254
|
+
// A host the operator approved stays enrolled after a later step fails.
|
|
255
|
+
// Print which hosts are connected and record it for `setupEnrollment`,
|
|
256
|
+
// then rethrow the original value untouched. Reporting must never
|
|
257
|
+
// replace the failure, so its own errors are ignored.
|
|
258
|
+
try {
|
|
259
|
+
const report = await enrollmentReport(plugin, hosts, enrollment);
|
|
260
|
+
recordSetupEnrollment(error, report);
|
|
261
|
+
for (const entry of report)
|
|
262
|
+
printLine(terminal, setupEnrollmentLine(entry));
|
|
263
|
+
}
|
|
264
|
+
catch { }
|
|
265
|
+
throw error;
|
|
210
266
|
}
|
|
211
267
|
}
|
|
212
268
|
printLine(terminal, `${options.dryRun ? 'Planned' : 'Configured'} ${plugin.displayName} for ${hosts.join(', ')} (${mode}).`);
|
|
@@ -3,6 +3,16 @@ import { writeEnrollmentTokenFile } from '@cortexkit/claustrum-client';
|
|
|
3
3
|
import { printLine } from '../auth-menu/terminal.js';
|
|
4
4
|
import { ClaustrumEnrollmentManager, connectClaustrumEnrollmentClient, hostEnrollmentPaths, } from '../claustrum/enrollment.js';
|
|
5
5
|
import { ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
|
|
6
|
+
const ENROLLMENT_INCOMPLETE_MESSAGE = 'Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.';
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when the enrollment ended without writing the host's token: the vault
|
|
9
|
+
* could not be reached, it refused the request, or approval never came before
|
|
10
|
+
* setup stopped waiting. Setup can then report the host as not connected
|
|
11
|
+
* without reading its files. The message is the same one a plain error would
|
|
12
|
+
* carry, so the user sees no difference.
|
|
13
|
+
*/
|
|
14
|
+
export class HostNotEnrolledError extends Error {
|
|
15
|
+
}
|
|
6
16
|
/** Enroll an independently revocable host; plugin callbacks choose its credential store and account permissions. */
|
|
7
17
|
export async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
8
18
|
const { name, paths: input } = plugin.vault.hosts[host];
|
|
@@ -12,7 +22,7 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
12
22
|
connectionFile: plugin.vault.connectionFile,
|
|
13
23
|
handshakeTimeoutMs: 2000,
|
|
14
24
|
}).catch(() => {
|
|
15
|
-
throw new
|
|
25
|
+
throw new HostNotEnrolledError('Claustrum connection failed; start ck and rerun setup.');
|
|
16
26
|
});
|
|
17
27
|
try {
|
|
18
28
|
const manager = new ClaustrumEnrollmentManager({
|
|
@@ -42,12 +52,12 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
42
52
|
return;
|
|
43
53
|
}
|
|
44
54
|
if (status.state !== 'pending' && status.state !== 'busy')
|
|
45
|
-
throw new
|
|
55
|
+
throw new HostNotEnrolledError('Claustrum enrollment refused; inspect its status with ck before rerunning setup.');
|
|
46
56
|
if (status.state === 'pending' &&
|
|
47
57
|
status.requestId &&
|
|
48
58
|
status.requestId !== printedRequest) {
|
|
49
59
|
if (!/^[a-zA-Z0-9_-]+$/.test(status.requestId))
|
|
50
|
-
throw new
|
|
60
|
+
throw new HostNotEnrolledError('Invalid enrollment request id.');
|
|
51
61
|
printedRequest = status.requestId;
|
|
52
62
|
printLine(terminal, 'Waiting for approval. In another terminal, run:');
|
|
53
63
|
printLine(terminal, ` ck auth enroll approve --request-id ${status.requestId} --name ${name}`);
|
|
@@ -55,14 +65,16 @@ export async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
55
65
|
}
|
|
56
66
|
await (io.wait ?? delay)(1000);
|
|
57
67
|
}
|
|
58
|
-
throw new
|
|
68
|
+
throw new HostNotEnrolledError('Claustrum approval is still pending; approve with ck and rerun setup.');
|
|
59
69
|
}
|
|
60
70
|
catch (error) {
|
|
61
71
|
if (error instanceof ProcessFenceViolationError ||
|
|
62
72
|
error instanceof ProcessInspectionError)
|
|
63
73
|
throw error;
|
|
64
74
|
// Enrollment exceptions can carry request secrets or bearer tokens; never display them.
|
|
65
|
-
|
|
75
|
+
if (error instanceof HostNotEnrolledError)
|
|
76
|
+
throw new HostNotEnrolledError(ENROLLMENT_INCOMPLETE_MESSAGE);
|
|
77
|
+
throw new Error(ENROLLMENT_INCOMPLETE_MESSAGE);
|
|
66
78
|
}
|
|
67
79
|
finally {
|
|
68
80
|
client.close();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AMBIGUOUS_OPENCODE_MESSAGE, runSetup } from './command.js';
|
|
2
|
+
export { SetupCommandError, setupEnrollment } from './command-error.js';
|
|
2
3
|
export { detectHosts, detectOpenCodeGeneration, findExecutableOnPath, openCodeDesktopMarkers, } from './detect.js';
|
|
3
4
|
export { assertHostsStopped, createProcessFence, listSetupProcesses, ProcessFenceViolationError, ProcessInspectionError, type ProcessInspectionStep, } from './process-fence.js';
|
|
4
5
|
export { type PlannedWrite, planOpenCodeRegistration, registerOpenCode, registerPi, updatePluginConfig, } from './register.js';
|
|
5
|
-
export type { CommandResult, CommandRunner, HostDetection, OpenCodeGeneration, ProcessFence, SetupCallbackContext, SetupDetection, SetupEnvironment, SetupFileSystem, SetupHost, SetupIO, SetupPlugin, SetupResult, } from './types.js';
|
|
6
|
+
export type { CommandResult, CommandRunner, HostDetection, OpenCodeGeneration, ProcessFence, SetupCallbackContext, SetupDetection, SetupEnrollmentOutcome, SetupEnvironment, SetupFileSystem, SetupHost, SetupHostEnrollment, SetupIO, SetupPlugin, SetupResult, } from './types.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AMBIGUOUS_OPENCODE_MESSAGE, runSetup } from './command.js';
|
|
2
|
+
export { SetupCommandError, setupEnrollment } from './command-error.js';
|
|
2
3
|
export { detectHosts, detectOpenCodeGeneration, findExecutableOnPath, openCodeDesktopMarkers, } from './detect.js';
|
|
3
4
|
export { assertHostsStopped, createProcessFence, listSetupProcesses, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
|
|
4
5
|
export { planOpenCodeRegistration, registerOpenCode, registerPi, updatePluginConfig, } from './register.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyEdits, createScanner, findNodeAtLocation, modify, parse, parseTree, } from 'jsonc-parser';
|
|
2
|
+
import { SetupCommandError } from './command-error.js';
|
|
2
3
|
import { defaultCommandRunner, runResolvedCommand } from './command-runner.js';
|
|
3
4
|
import { writeHostConfigAtomic } from './config-write.js';
|
|
4
5
|
import { defaultSetupFileSystem } from './detect.js';
|
|
@@ -125,6 +126,11 @@ export async function registerOpenCode(writes, beforeWrite) {
|
|
|
125
126
|
export async function registerPi(plugin, executable, io = {}) {
|
|
126
127
|
const { platform, env } = setupPaths(io);
|
|
127
128
|
const result = await runResolvedCommand(io.runner ?? defaultCommandRunner, platform, executable, ['install', `npm:${plugin.packages.pi}@${plugin.version}`], env);
|
|
128
|
-
if (result.exitCode !== 0)
|
|
129
|
-
throw new
|
|
129
|
+
if (result.exitCode !== 0 || result.timedOut)
|
|
130
|
+
throw new SetupCommandError({
|
|
131
|
+
exitCode: result.spawnError ? null : result.exitCode,
|
|
132
|
+
signal: result.signal ?? null,
|
|
133
|
+
stderrTail: result.stderr,
|
|
134
|
+
stderrTruncated: result.stderrTruncated ?? false,
|
|
135
|
+
});
|
|
130
136
|
}
|
|
@@ -3,6 +3,18 @@ import type { ClaustrumEnrollmentConnection, hostEnrollmentPaths } from '../clau
|
|
|
3
3
|
export type SetupHost = 'opencode' | 'pi';
|
|
4
4
|
export type OpenCodeGeneration = '1' | '2' | 'both';
|
|
5
5
|
export type SetupEnvironment = Record<string, string | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* What a setup run recorded about one host's vault enrollment when it failed:
|
|
8
|
+
* `enrolled` once approval landed and the token was written, `not-enrolled`
|
|
9
|
+
* when the host was never asked or its enrollment was refused or gave up
|
|
10
|
+
* waiting, and `unknown` when setup failed while the enrollment was still in
|
|
11
|
+
* flight and the host's token file could not settle it.
|
|
12
|
+
*/
|
|
13
|
+
export type SetupEnrollmentOutcome = 'enrolled' | 'not-enrolled' | 'unknown';
|
|
14
|
+
export interface SetupHostEnrollment {
|
|
15
|
+
host: SetupHost;
|
|
16
|
+
outcome: SetupEnrollmentOutcome;
|
|
17
|
+
}
|
|
6
18
|
/**
|
|
7
19
|
* What setup decided before calling a plugin callback. The OpenCode generation
|
|
8
20
|
* is the one being registered, after `--opencode` or the interactive choice, so
|
|
@@ -57,6 +69,8 @@ export interface CommandResult {
|
|
|
57
69
|
exitCode: number;
|
|
58
70
|
stdout: string;
|
|
59
71
|
stderr: string;
|
|
72
|
+
spawnError?: boolean;
|
|
73
|
+
stderrTruncated?: boolean;
|
|
60
74
|
signal?: NodeJS.Signals | null;
|
|
61
75
|
timedOut?: boolean;
|
|
62
76
|
durationMs?: number;
|