gestalt-mobile 0.75.2 → 0.75.4
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/README.md
CHANGED
|
@@ -402,6 +402,22 @@ two local relay processes behind `https://relay.example.org`), but an RP-ID/
|
|
|
402
402
|
hostname change is refused once credentials exist because it would strand those
|
|
403
403
|
credentials. Do not expose `--host 0.0.0.0` before that boundary is in place.
|
|
404
404
|
|
|
405
|
+
### Move to a different hostname
|
|
406
|
+
|
|
407
|
+
Stop every Gestalt Mobile relay using the same account. Run the reset on the
|
|
408
|
+
machine hosting Mobile with the new public origin.
|
|
409
|
+
|
|
410
|
+
```sh
|
|
411
|
+
gestalt-mobile reset-passkeys --public-origin https://new-relay.example.org --confirm
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
With the Gestalt manager, use `npx gestalt mobile reset-passkeys` with the same
|
|
415
|
+
arguments. The reset revokes all passkeys and browser sessions for the old
|
|
416
|
+
hostname across the account's relays. Saved Codex sessions and workspaces
|
|
417
|
+
remain available. Start Mobile with the same workspace and state options and
|
|
418
|
+
the new `--public-origin`. Enroll the first device before making the relay
|
|
419
|
+
reachable over the network.
|
|
420
|
+
|
|
405
421
|
An empty authorization store is deliberately bootstrap-open: the first verified passkey becomes the owner. Register a device before exposing the service. The
|
|
406
422
|
final authorized device cannot be deleted; synced passkeys can represent more
|
|
407
423
|
than one physical device, and an enrollment QR/link is neither recovery nor
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { execFile } from 'node:child_process';
|
|
7
|
-
import {
|
|
8
|
-
import { probePlaywrightComponent } from './platform/codex/playwright-component.js';
|
|
7
|
+
import { readPlaywrightComponent } from './platform/codex/playwright-component.js';
|
|
9
8
|
import { existsSync } from 'node:fs';
|
|
10
9
|
import { readFile } from 'node:fs/promises';
|
|
11
10
|
import { homedir } from 'node:os';
|
|
@@ -13,7 +12,8 @@ import { dirname, resolve } from 'node:path';
|
|
|
13
12
|
import { fileURLToPath } from 'node:url';
|
|
14
13
|
import { promisify } from 'node:util';
|
|
15
14
|
import { composeRelayApp } from './composition.js';
|
|
16
|
-
import { CliUsageError, parseConfig } from './config.js';
|
|
15
|
+
import { CliUsageError, createRelyingPartyConfig, parseConfig, } from './config.js';
|
|
16
|
+
import { AuthorizationHostnameMismatchError, checkAuthorizationHostname, resetAuthorizationHostname, } from './platform/auth/sqlite-authorization-store.js';
|
|
17
17
|
import { LauncherProfileCatalog } from './platform/catalog/launcher-profile-catalog.js';
|
|
18
18
|
import { FilesystemSkillProfileStore } from './platform/skills/filesystem-skill-profile-store.js';
|
|
19
19
|
import { loadPwaIcon } from './platform/pwa/load-pwa-icon.js';
|
|
@@ -22,6 +22,7 @@ import { relayStatePath } from './platform/persistence/state-path.js';
|
|
|
22
22
|
const runFile = promisify(execFile);
|
|
23
23
|
export const usage = `Usage: gestalt-mobile [options]
|
|
24
24
|
gestalt-mobile trace <session-id> [--json] [--cwd <path>] [--data-dir <path>]
|
|
25
|
+
gestalt-mobile reset-passkeys --public-origin <origin> --confirm
|
|
25
26
|
|
|
26
27
|
Options:
|
|
27
28
|
--cwd <path> Workspace root (default: current directory)
|
|
@@ -78,26 +79,6 @@ export function componentVersions(mobileVersion, codexVersion, environment = pro
|
|
|
78
79
|
},
|
|
79
80
|
];
|
|
80
81
|
}
|
|
81
|
-
export async function runStartupDoctor(cwd) {
|
|
82
|
-
if (process.env.GESTALT_STARTUP_DIAGNOSTICS_DONE === '1')
|
|
83
|
-
return { ok: true, report: '' };
|
|
84
|
-
try {
|
|
85
|
-
const result = await runFile('gestalt', ['doctor'], {
|
|
86
|
-
cwd,
|
|
87
|
-
env: withoutSessionScratch(),
|
|
88
|
-
timeout: 60_000,
|
|
89
|
-
maxBuffer: 1024 * 1024,
|
|
90
|
-
});
|
|
91
|
-
return { ok: true, report: `${result.stdout}${result.stderr}` };
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
const failure = error;
|
|
95
|
-
return {
|
|
96
|
-
ok: false,
|
|
97
|
-
report: `${failure.stdout ?? ''}${failure.stderr ?? ''}${failure.message ? `${failure.message}\n` : ''}`,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
82
|
export function packageRoot(moduleUrl) {
|
|
102
83
|
let directory = dirname(fileURLToPath(moduleUrl));
|
|
103
84
|
while (true) {
|
|
@@ -165,6 +146,18 @@ export function installShutdownHandlers(app, signalSource = process) {
|
|
|
165
146
|
return shutdown;
|
|
166
147
|
}
|
|
167
148
|
function parseInvocation(args, cwd) {
|
|
149
|
+
if (args[0] === 'reset-passkeys') {
|
|
150
|
+
const options = args.slice(1);
|
|
151
|
+
const originIndex = options.indexOf('--public-origin');
|
|
152
|
+
const origin = options[originIndex + 1];
|
|
153
|
+
if (options.length !== 3 ||
|
|
154
|
+
originIndex < 0 ||
|
|
155
|
+
!origin ||
|
|
156
|
+
origin.startsWith('--') ||
|
|
157
|
+
!options.includes('--confirm'))
|
|
158
|
+
throw new CliUsageError('Passkey reset requires --public-origin <origin> and --confirm');
|
|
159
|
+
return { command: 'reset-passkeys', rpId: createRelyingPartyConfig(origin).rpId };
|
|
160
|
+
}
|
|
168
161
|
if (args[0] === 'trace') {
|
|
169
162
|
const sessionId = args[1];
|
|
170
163
|
if (!sessionId || sessionId.startsWith('--'))
|
|
@@ -230,12 +223,28 @@ async function listSkillProfiles(store, stdout, stderr) {
|
|
|
230
223
|
}
|
|
231
224
|
return failed ? 1 : 0;
|
|
232
225
|
}
|
|
226
|
+
function reportHostnameMismatch(error, publicOrigin, launcher, stderr) {
|
|
227
|
+
if (!(error instanceof AuthorizationHostnameMismatchError))
|
|
228
|
+
throw error;
|
|
229
|
+
// A WHATWG URL can accept characters with special meaning in a shell.
|
|
230
|
+
const originArgument = /^https?:\/\/[a-z\d.-]+(?::\d+)?$/i.test(publicOrigin)
|
|
231
|
+
? publicOrigin
|
|
232
|
+
: '"<new-origin>"';
|
|
233
|
+
stderr.write(`${error.message}. Stop every Gestalt Mobile relay on this account.\n` +
|
|
234
|
+
'Run the local reset command to revoke existing passkeys and browser sessions and enroll a new first device.\n' +
|
|
235
|
+
` ${launcher} reset-passkeys --public-origin ${originArgument} --confirm\n`);
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
233
238
|
export async function runCli(dependencies = {}) {
|
|
234
239
|
const args = dependencies.args ?? process.argv.slice(2);
|
|
235
240
|
const cwd = dependencies.cwd ?? process.cwd();
|
|
236
241
|
const moduleUrl = dependencies.moduleUrl ?? import.meta.url;
|
|
237
242
|
const stdout = dependencies.stdout ?? process.stdout;
|
|
238
243
|
const stderr = dependencies.stderr ?? process.stderr;
|
|
244
|
+
const home = dependencies.homeDirectory ?? homedir();
|
|
245
|
+
const launcher = (dependencies.environment ?? process.env).GESTALT_MANAGER_VERSION
|
|
246
|
+
? 'npx gestalt mobile'
|
|
247
|
+
: 'gestalt-mobile';
|
|
239
248
|
let invocation;
|
|
240
249
|
try {
|
|
241
250
|
invocation = parseInvocation(args, cwd);
|
|
@@ -254,6 +263,22 @@ export async function runCli(dependencies = {}) {
|
|
|
254
263
|
stdout.write(`${await packageVersion(moduleUrl)}\n`);
|
|
255
264
|
return 0;
|
|
256
265
|
}
|
|
266
|
+
if (invocation.command === 'reset-passkeys') {
|
|
267
|
+
try {
|
|
268
|
+
const result = resetAuthorizationHostname(home, invocation.rpId);
|
|
269
|
+
if (result === 'reset')
|
|
270
|
+
stdout.write('Passkeys and browser sessions cleared. Start Mobile with the new origin and enroll your first device.\n');
|
|
271
|
+
else if (result === 'alreadyConfigured')
|
|
272
|
+
stdout.write('The passkey hostname already matches the requested origin.\n');
|
|
273
|
+
else
|
|
274
|
+
stdout.write('There is no passkey hostname to reset. Start Mobile with the requested origin.\n');
|
|
275
|
+
return 0;
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
stderr.write(`Unable to reset passkeys: ${error instanceof Error ? error.message : 'unknown error'}\n`);
|
|
279
|
+
return 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
257
282
|
if (invocation.command === 'trace') {
|
|
258
283
|
const stateHome = dependencies.environment?.XDG_STATE_HOME ??
|
|
259
284
|
process.env.XDG_STATE_HOME ??
|
|
@@ -271,10 +296,18 @@ export async function runCli(dependencies = {}) {
|
|
|
271
296
|
return 1;
|
|
272
297
|
}
|
|
273
298
|
}
|
|
274
|
-
const skillProfiles = new FilesystemSkillProfileStore(
|
|
299
|
+
const skillProfiles = new FilesystemSkillProfileStore(home);
|
|
275
300
|
if (invocation.command === 'list')
|
|
276
301
|
return listSkillProfiles(skillProfiles, stdout, stderr);
|
|
277
302
|
const config = invocation.config;
|
|
303
|
+
if (config.passkeyAuthEnabled) {
|
|
304
|
+
try {
|
|
305
|
+
checkAuthorizationHostname(home, config.relyingParty.rpId);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
return reportHostnameMismatch(error, config.relyingParty.publicOrigin, launcher, stderr);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
278
311
|
if (!config.passkeyAuthEnabled)
|
|
279
312
|
stderr.write('WARNING: Passkey access control is disabled; anyone who can reach this server has full access.\n');
|
|
280
313
|
let explicitSkillProfile;
|
|
@@ -299,11 +332,6 @@ export async function runCli(dependencies = {}) {
|
|
|
299
332
|
stderr.write(`${error instanceof Error ? error.message : 'Invalid --icon file'}\n\n${usage}\n`);
|
|
300
333
|
return 2;
|
|
301
334
|
}
|
|
302
|
-
const diagnosis = await (dependencies.runStartupDoctor ?? runStartupDoctor)(cwd);
|
|
303
|
-
if (diagnosis.report)
|
|
304
|
-
stderr.write(diagnosis.report);
|
|
305
|
-
if (!diagnosis.ok)
|
|
306
|
-
stderr.write('WARNING: Startup diagnostics reported a problem; Gestalt Mobile will continue so it can show recovery controls.\n');
|
|
307
335
|
const installedCodexVersion = await (dependencies.probeCodexVersion ?? probeCodexVersion)();
|
|
308
336
|
const installedKimiVersion = await (dependencies.probeKimiVersion ?? probeKimiVersion)();
|
|
309
337
|
const mobileVersion = await packageVersion(moduleUrl);
|
|
@@ -318,12 +346,17 @@ export async function runCli(dependencies = {}) {
|
|
|
318
346
|
profiles: new LauncherProfileCatalog(),
|
|
319
347
|
installedCodexVersion,
|
|
320
348
|
installedKimiVersion,
|
|
321
|
-
componentVersions: componentVersions(mobileVersion, installedCodexVersion, dependencies.environment, await (dependencies.
|
|
349
|
+
componentVersions: componentVersions(mobileVersion, installedCodexVersion, dependencies.environment, await (dependencies.readPlaywrightComponent ?? readPlaywrightComponent)(dependencies.environment)),
|
|
322
350
|
startAppServers: true,
|
|
323
351
|
homeDirectory: dependencies.homeDirectory,
|
|
324
352
|
explicitSkillProfile,
|
|
325
353
|
planMeasurementBaseUrl: `http://${config.host}:${config.port}`,
|
|
354
|
+
}).catch((error) => {
|
|
355
|
+
reportHostnameMismatch(error, config.relyingParty.publicOrigin, launcher, stderr);
|
|
356
|
+
return null;
|
|
326
357
|
});
|
|
358
|
+
if (!app)
|
|
359
|
+
return 1;
|
|
327
360
|
installShutdownHandlers(app, dependencies.signalSource);
|
|
328
361
|
let address;
|
|
329
362
|
try {
|
|
@@ -3,8 +3,60 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
58
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
59
|
+
import { mkdirSync, chmodSync, statSync } from 'node:fs';
|
|
8
60
|
import { dirname, join, resolve } from 'node:path';
|
|
9
61
|
import { DatabaseSync } from 'node:sqlite';
|
|
10
62
|
import { authorizedDeviceId, localOwnerId, passkeyCeremonyId, webAuthnCredentialId, } from '../../features/auth/domain/identifiers.js';
|
|
@@ -21,6 +73,75 @@ const startupLockWaiter = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_
|
|
|
21
73
|
export function authorizationDatabasePath(homeDirectory) {
|
|
22
74
|
return join(resolve(homeDirectory), '.codex-gestalt', 'gestalt-mobile', 'auth.sqlite');
|
|
23
75
|
}
|
|
76
|
+
export class AuthorizationHostnameMismatchError extends Error {
|
|
77
|
+
constructor() {
|
|
78
|
+
super('WebAuthn RP ID hostname changed while credentials exist');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function storedRpId(db) {
|
|
82
|
+
if (!db.prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = 'auth_settings'").get())
|
|
83
|
+
return undefined;
|
|
84
|
+
const settings = db.prepare('SELECT rp_id FROM auth_settings WHERE singleton = 1').get();
|
|
85
|
+
return settings?.rp_id;
|
|
86
|
+
}
|
|
87
|
+
export function checkAuthorizationHostname(homeDirectory, rpId) {
|
|
88
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
89
|
+
try {
|
|
90
|
+
const path = authorizationDatabasePath(homeDirectory);
|
|
91
|
+
if (!statSync(path, { throwIfNoEntry: false }))
|
|
92
|
+
return;
|
|
93
|
+
const db = __addDisposableResource(env_1, new DatabaseSync(path, { readOnly: true, timeout: SQLITE_STARTUP_BUSY_TIMEOUT_MS }), false);
|
|
94
|
+
db.exec('BEGIN');
|
|
95
|
+
const stored = storedRpId(db);
|
|
96
|
+
if (stored !== undefined &&
|
|
97
|
+
stored !== rpId &&
|
|
98
|
+
db.prepare('SELECT 1 FROM auth_devices LIMIT 1').get())
|
|
99
|
+
throw new AuthorizationHostnameMismatchError();
|
|
100
|
+
}
|
|
101
|
+
catch (e_1) {
|
|
102
|
+
env_1.error = e_1;
|
|
103
|
+
env_1.hasError = true;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
__disposeResources(env_1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function resetAuthorizationHostname(homeDirectory, rpId) {
|
|
110
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
111
|
+
try {
|
|
112
|
+
const path = authorizationDatabasePath(homeDirectory);
|
|
113
|
+
if (!statSync(path, { throwIfNoEntry: false }))
|
|
114
|
+
return 'uninitialized';
|
|
115
|
+
const db = __addDisposableResource(env_2, new DatabaseSync(path, { timeout: SQLITE_STARTUP_BUSY_TIMEOUT_MS }), false);
|
|
116
|
+
// An exclusive WAL connection cannot acquire its lock while another relay
|
|
117
|
+
// has the shared auth database open. Keep the lock until the reset commits.
|
|
118
|
+
db.exec('PRAGMA locking_mode = EXCLUSIVE;');
|
|
119
|
+
try {
|
|
120
|
+
return withImmediateTransaction(db, () => {
|
|
121
|
+
const stored = storedRpId(db);
|
|
122
|
+
if (stored === undefined)
|
|
123
|
+
return 'uninitialized';
|
|
124
|
+
if (stored === rpId)
|
|
125
|
+
return 'alreadyConfigured';
|
|
126
|
+
db.exec('DELETE FROM auth_sessions; DELETE FROM auth_tickets; DELETE FROM auth_ceremonies; DELETE FROM auth_devices;');
|
|
127
|
+
db.prepare('UPDATE auth_settings SET rp_id = ?, user_handle = ? WHERE singleton = 1').run(rpId, randomBytes(32));
|
|
128
|
+
return 'reset';
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (isLocked(error))
|
|
133
|
+
throw new Error('Stop every Gestalt Mobile relay using this authorization database, then retry.');
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (e_2) {
|
|
138
|
+
env_2.error = e_2;
|
|
139
|
+
env_2.hasError = true;
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
__disposeResources(env_2);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
24
145
|
/** SQLite adapter for the auth bounded context. No SQLite types escape this file. */
|
|
25
146
|
export class SqliteAuthorizationStore {
|
|
26
147
|
path;
|
|
@@ -86,7 +207,7 @@ CREATE TABLE IF NOT EXISTS auth_sessions (token_hash TEXT PRIMARY KEY, device_id
|
|
|
86
207
|
.prepare('SELECT rp_id FROM auth_settings WHERE singleton = 1')
|
|
87
208
|
.get();
|
|
88
209
|
if (settings && settings.rp_id !== this.relyingParty.rpId && this.deviceCount() > 0)
|
|
89
|
-
throw new
|
|
210
|
+
throw new AuthorizationHostnameMismatchError();
|
|
90
211
|
});
|
|
91
212
|
}
|
|
92
213
|
initializeOwner(userHandle) {
|
|
@@ -101,7 +222,7 @@ CREATE TABLE IF NOT EXISTS auth_sessions (token_hash TEXT PRIMARY KEY, device_id
|
|
|
101
222
|
.prepare('INSERT INTO auth_settings (singleton, schema_version, rp_id, user_handle) VALUES (1, ?, ?, ?)')
|
|
102
223
|
.run(SCHEMA_VERSION, this.relyingParty.rpId, userHandle);
|
|
103
224
|
else if (current.rp_id !== this.relyingParty.rpId && this.deviceCount() > 0)
|
|
104
|
-
throw new
|
|
225
|
+
throw new AuthorizationHostnameMismatchError();
|
|
105
226
|
else if (current.rp_id !== this.relyingParty.rpId)
|
|
106
227
|
this.statements
|
|
107
228
|
.prepare('UPDATE auth_settings SET rp_id = ? WHERE singleton = 1')
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { ManagedPlaywright } from './managed-playwright.js';
|
|
7
|
-
/**
|
|
8
|
-
export async function
|
|
9
|
-
|
|
7
|
+
/** Read the installed version for Mobile's component list without launching Chrome. */
|
|
8
|
+
export async function readPlaywrightComponent(environment = process.env, adapter = new ManagedPlaywright(environment)) {
|
|
9
|
+
const component = {
|
|
10
10
|
id: 'playwright',
|
|
11
11
|
label: 'Playwright MCP',
|
|
12
12
|
version: null,
|
|
@@ -17,36 +17,18 @@ export async function probePlaywrightComponent(cwd, environment = process.env, a
|
|
|
17
17
|
const installation = await adapter.check();
|
|
18
18
|
if (installation.status !== 'installed')
|
|
19
19
|
return component;
|
|
20
|
-
component = { ...component, version: installation.version };
|
|
21
|
-
let readiness = await adapter.ready(installation.manager, cwd, Date.now() + 15000, [
|
|
22
|
-
'--launch',
|
|
23
|
-
]);
|
|
24
|
-
// Older managers reject --launch. Preserve prerequisite reporting during
|
|
25
|
-
// separate Mobile/manager upgrades, without claiming a browser was tested.
|
|
26
|
-
if (readiness.package === 'unknown' && readiness.chrome === 'unknown') {
|
|
27
|
-
readiness = await adapter.ready(installation.manager, cwd, Date.now() + 5000);
|
|
28
|
-
}
|
|
29
|
-
const engine = readiness.playwrightVersion ? `Playwright ${readiness.playwrightVersion}; ` : '';
|
|
30
20
|
return {
|
|
31
21
|
...component,
|
|
32
22
|
version: installation.version,
|
|
33
|
-
status:
|
|
34
|
-
|
|
35
|
-
? 'working'
|
|
36
|
-
: 'ready'
|
|
37
|
-
: 'unavailable',
|
|
38
|
-
detail: readiness.ready
|
|
39
|
-
? readiness.browserTest === 'passed'
|
|
40
|
-
? `${engine}Chrome ${readiness.chromeVersion ?? 'detected'}; browser page check passed at startup.`
|
|
41
|
-
: `${engine}Chrome ${readiness.chromeVersion ?? 'detected'}; prerequisites ready. Browser session has not been tested.`
|
|
42
|
-
: 'Playwright is installed; Chrome or runtime prerequisites are unavailable or unverified.',
|
|
23
|
+
status: 'unverified',
|
|
24
|
+
detail: 'Playwright is installed. Run gestalt update to check its prerequisites.',
|
|
43
25
|
};
|
|
44
26
|
}
|
|
45
27
|
catch {
|
|
46
28
|
return {
|
|
47
29
|
...component,
|
|
48
30
|
status: 'unverified',
|
|
49
|
-
detail: 'Playwright
|
|
31
|
+
detail: 'Playwright installation metadata could not be read.',
|
|
50
32
|
};
|
|
51
33
|
}
|
|
52
34
|
}
|