gestalt-mobile 0.78.1 → 0.78.3

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.
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
16
16
  <link rel="icon" href="/icons/gestalt-mobile-192.png" />
17
17
  <link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
18
18
  <title>Gestalt Mobile</title>
19
- <script type="module" crossorigin src="/assets/index-C1RSPAku.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-jLy1t3Qp.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DRiZTklh.css">
21
21
  </head>
22
22
  <body>
@@ -29,6 +29,8 @@ export function registerForgetSession(app, deps) {
29
29
  });
30
30
  if (operation.phase !== 'completed')
31
31
  return reply.code(503).send({ code: 'SESSION_FORGET_FAILED', operation });
32
+ if (operation.scratchRetained && !operation.keepFilesRequested)
33
+ reply.header('x-gestalt-scratch-retained', 'true');
32
34
  return reply.code(204).send();
33
35
  }
34
36
  if (!deps.find(id))
@@ -395,6 +395,7 @@ export class CodexPlaywright {
395
395
  const prepared = this.prepared.get(state);
396
396
  if (!prepared?.enabled)
397
397
  return true;
398
+ let reason = 'connection-or-tools-unavailable';
398
399
  try {
399
400
  while (Date.now() < prepared.deadline) {
400
401
  const result = (await beforeDeadline(rpc.request('mcpServerStatus/list', {
@@ -403,10 +404,19 @@ export class CodexPlaywright {
403
404
  detail: 'full',
404
405
  }), prepared.deadline));
405
406
  const server = result.data?.find((entry) => entry.name === playwrightServerName);
406
- if (prepared.current() &&
407
- server?.runtimeStatus === 'connected' &&
408
- !server.toolsError &&
409
- playwrightTools.every((tool) => Object.hasOwn(server.tools ?? {}, tool))) {
407
+ if (!prepared.current()) {
408
+ reason = 'authority-changed';
409
+ break;
410
+ }
411
+ if (server?.runtimeStatus === 'connected') {
412
+ if (server.toolsError) {
413
+ reason = 'tool-discovery-failed';
414
+ break;
415
+ }
416
+ if (!playwrightTools.every((tool) => Object.hasOwn(server.tools ?? {}, tool))) {
417
+ reason = 'required-tools-missing';
418
+ break;
419
+ }
410
420
  prepared.binding.connected = true;
411
421
  prepared.binding.root = threadId;
412
422
  return true;
@@ -419,7 +429,7 @@ export class CodexPlaywright {
419
429
  catch {
420
430
  /* Keep chat and Serena usable. */
421
431
  }
422
- prepared.binding.reason = 'connection-or-tools-unavailable';
432
+ prepared.binding.reason = reason;
423
433
  prepared.fail();
424
434
  return false;
425
435
  }
@@ -445,7 +455,7 @@ export class CodexPlaywright {
445
455
  !['failed', 'cancelled', 'disconnected'].includes(String(value.status)))
446
456
  return;
447
457
  binding.connected = false;
448
- binding.reason = 'connection-or-tools-unavailable';
458
+ binding.reason ??= 'connection-or-tools-unavailable';
449
459
  }
450
460
  base(state) {
451
461
  return this.prepared.get(state)?.base ?? state;
@@ -43,7 +43,7 @@ async function prepareReadOnlyDirectories(root, directories) {
43
43
  }
44
44
  /** Only the managed namespace is traversed. There are no prefix/age/PID legacy recognizers. */
45
45
  export class FilesystemScratchCleanup {
46
- async cleanSession(session, authorized, protectedSessions) {
46
+ async cleanSession(session, authorized, protectedSessions, { retainBorrowed = false } = {}) {
47
47
  // A retained session can outlive its workspace (including Self DEBUG).
48
48
  // Only an absent workspace is already clean; existing links and invalid
49
49
  // paths must still pass the normal canonical-path checks below.
@@ -64,9 +64,20 @@ export class FilesystemScratchCleanup {
64
64
  throw error;
65
65
  }
66
66
  }
67
- const counts = await this.cleanWorkspace(session.workspacePath, protectedSessions, mobileScratchOwnerId(session.id), authorized);
68
- if (counts.skipped || counts.failed)
67
+ const ownerId = mobileScratchOwnerId(session.id);
68
+ const counts = await this.cleanWorkspace(session.workspacePath, protectedSessions, ownerId, authorized);
69
+ const borrowed = counts.leasedMobileSessions;
70
+ if (counts.failed ||
71
+ (counts.skipped && (!retainBorrowed || counts.skipped !== borrowed.length)))
69
72
  throw new Error('SESSION_CLEANUP_FAILED');
73
+ // A missing logical owner cannot prove that its external runtime was retired.
74
+ if (process.getuid &&
75
+ (await hasRuntimeOwner({ workspacePath: session.workspacePath, ownerId }, new Set(borrowed.flatMap(({ runtimeDirectory }) => runtimeDirectory ?? [])))))
76
+ throw new Error('SESSION_CLEANUP_FAILED');
77
+ if (!authorized())
78
+ throw new Error('SESSION_CLEANUP_FAILED');
79
+ if (borrowed.length)
80
+ return 'retained';
70
81
  }
71
82
  async canonicalWorkspace(path) {
72
83
  return canonicalScratchWorkspace(path);
@@ -96,21 +96,29 @@ export class FilesystemSessionScratch {
96
96
  !Array.isArray(current.consumers) ||
97
97
  JSON.stringify(current.consumers) !== JSON.stringify(record.consumers))
98
98
  throw new Error('SESSION_SCRATCH_LEASE_CHANGED');
99
- const staging = join(leases, `.${randomUUID()}.json`);
99
+ // Managed tools scan leases while old runtimes are retiring.
100
+ // Keep the staging file outside the catalog until publication.
101
+ const staging = join(context.directory, `.lease-${randomUUID()}.json`);
100
102
  const file = await open(staging, 'wx', 0o600);
101
103
  try {
102
- await file.writeFile(JSON.stringify({
103
- ...record,
104
- state: 'released',
105
- consumers: [],
106
- updatedAt: new Date().toISOString(),
107
- }));
108
- await file.sync();
104
+ try {
105
+ await file.writeFile(JSON.stringify({
106
+ ...record,
107
+ state: 'released',
108
+ consumers: [],
109
+ updatedAt: new Date().toISOString(),
110
+ }));
111
+ await file.sync();
112
+ }
113
+ finally {
114
+ await file.close();
115
+ }
116
+ await rename(staging, path);
109
117
  }
110
- finally {
111
- await file.close();
118
+ catch (error) {
119
+ await unlink(staging).catch(() => undefined);
120
+ throw error;
112
121
  }
113
- await rename(staging, path);
114
122
  released = true;
115
123
  },
116
124
  };
@@ -22,7 +22,9 @@ export class FilesystemWorkspaceForget {
22
22
  const workspace = canonicalSessionWorkspace(session.workspacePath);
23
23
  const others = knownSessions().filter((other) => other.id !== session.id);
24
24
  if (others.some((other) => canonicalSessionWorkspace(other.workspacePath) === workspace))
25
- return 'retained';
25
+ return new FilesystemScratchCleanup().cleanSession(session, authorized, knownSessions, {
26
+ retainBorrowed: true,
27
+ });
26
28
  const temporary = join(workspace, 'tmp');
27
29
  for (const other of others) {
28
30
  if (workspaceContains(temporary, canonicalSessionWorkspace(other.workspacePath)))
@@ -3,7 +3,12 @@
3
3
  * Designed by Denis Roio <jaromil@dyne.org>
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
- export const startupServers = ['context-mode', 'gestalt-context-mode', 'gestalt-serena'];
6
+ export const startupServers = [
7
+ 'context-mode',
8
+ 'gestalt-context-mode',
9
+ 'gestalt-serena',
10
+ 'gestalt-playwright',
11
+ ];
7
12
  export const startupPhases = ['artifact', 'spawn', 'initialize', 'startup'];
8
13
  export const startupFailureCodes = [
9
14
  'artifact-unavailable',
@@ -127,6 +132,8 @@ export function mcpStartupActivity(status) {
127
132
  };
128
133
  }
129
134
  export function startupToolLabel(server) {
135
+ if (server === 'gestalt-playwright')
136
+ return 'Playwright';
130
137
  return server === 'gestalt-serena' ? 'Serena' : 'Context Mode';
131
138
  }
132
139
  export function startupFailureReason(code) {
@@ -141,6 +148,8 @@ export function startupFailureReason(code) {
141
148
  }[code];
142
149
  }
143
150
  export function startupRecoveryGuidance(server) {
151
+ if (server === 'gestalt-playwright')
152
+ return 'Chat remains available. Check the session browser status before retrying activation.';
144
153
  return server === 'gestalt-serena'
145
154
  ? 'Optional tool unavailable. Continue with native code tools. Operators can inspect it with gestalt serena doctor.'
146
155
  : 'Required tool unavailable. The affected startup cannot continue until Context Mode is available. Operators can inspect it with ctx-doctor.';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.78.1",
3
+ "version": "0.78.3",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",