gestalt-mobile 0.62.1 → 0.62.2

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
@@ -248,8 +248,10 @@ permissions are never broadened to repair them. Kimi behavior is unchanged.
248
248
  Managed launch provides `GESTALT_MANAGER_BIN`. Direct Mobile launch discovers
249
249
  `gestalt` on `PATH`, or accepts an absolute executable path through that same
250
250
  environment variable. Without a manager or installed xerj, chat starts normally.
251
- `XERJ_READY_TIMEOUT_MS` bounds optional readiness, including discovery and the
252
- actual connection, with a five-second default. Startup never installs xerj,
251
+ `XERJ_READY_TIMEOUT_MS` bounds optional backend preparation with a five-second
252
+ default. XERJ's native MCP handshake gets a separate five-second allowance;
253
+ connection verification gets another bounded five seconds after thread startup.
254
+ Slow preparation cannot consume the handshake budget. Startup never installs xerj,
253
255
  downloads models or indexes repositories. Install explicitly with
254
256
  `gestalt xerj install`; inspect readiness with `gestalt xerj status`.
255
257
 
@@ -28,7 +28,7 @@ export class CodexCapabilities {
28
28
  const serenaPath = input.skills.find((skill) => skill.name === 'gestalt:serena')?.path;
29
29
  const state = {
30
30
  repositories: new RepositoryReadiness(input.cwd),
31
- deadline: Math.max(input.deadline, serena.ready ? serena.deadline : input.deadline),
31
+ deadline: Math.max(input.deadline, xerj.ready ? xerj.deadline : input.deadline, serena.ready ? serena.deadline : input.deadline),
32
32
  get ready() {
33
33
  return xerj.ready || serena.ready;
34
34
  },
@@ -7,6 +7,7 @@ import { readFile } from 'node:fs/promises';
7
7
  import { ReadinessEvidence } from './readiness-evidence.js';
8
8
  export const xerjServerName = 'gestalt-xerj';
9
9
  export const xerjTools = ['xerj_search', 'xerj_map', 'xerj_code_search'];
10
+ const connectionTimeoutMs = 5_000;
10
11
  /** Ephemeral native thread configuration; no installation or daemon ownership. */
11
12
  export class CodexXerj {
12
13
  capability;
@@ -89,6 +90,10 @@ export class CodexXerj {
89
90
  const guidance = await beforeDeadline(readFile(skill.path, 'utf8'), input.deadline);
90
91
  if (guidance.length > 16_384)
91
92
  return state;
93
+ // Backend preparation must not leave the native MCP handshake with only
94
+ // a few milliseconds. These are separate, individually bounded phases.
95
+ state.deadline = Date.now() + connectionTimeoutMs;
96
+ state.verificationTimeoutMs = connectionTimeoutMs;
92
97
  state.skillsConfig = state.skillsConfig.map((entry) => ({
93
98
  ...entry,
94
99
  enabled: entry.path === skill.path ? true : entry.enabled,
@@ -106,7 +111,7 @@ export class CodexXerj {
106
111
  enabled: true,
107
112
  required: false,
108
113
  startup_readiness: 'connection',
109
- startup_timeout_ms: Math.max(1, input.deadline - Date.now()),
114
+ startup_timeout_ms: connectionTimeoutMs,
110
115
  enabled_tools: xerjTools,
111
116
  default_tools_approval_mode: 'approve',
112
117
  },
@@ -125,13 +130,17 @@ export class CodexXerj {
125
130
  async verify(rpc, threadId, state) {
126
131
  if (!state.ready)
127
132
  return false;
133
+ // thread/start can consume the handshake allowance before this method runs.
134
+ const deadline = state.verificationTimeoutMs
135
+ ? Date.now() + state.verificationTimeoutMs
136
+ : state.deadline;
128
137
  try {
129
- while (Date.now() < state.deadline) {
138
+ while (Date.now() < deadline) {
130
139
  const result = (await beforeDeadline(rpc.request('mcpServerStatus/list', {
131
140
  threadId,
132
141
  serverName: xerjServerName,
133
142
  detail: 'full',
134
- }), state.deadline));
143
+ }), deadline));
135
144
  const server = result.data?.find((entry) => entry.name === xerjServerName);
136
145
  if (server?.runtimeStatus === 'connected' &&
137
146
  !server.toolsError &&
@@ -143,7 +152,7 @@ export class CodexXerj {
143
152
  state.evidence?.connection('unavailable');
144
153
  return false;
145
154
  }
146
- await beforeDeadline(new Promise((resolve) => setTimeout(resolve, 25)), state.deadline);
155
+ await beforeDeadline(new Promise((resolve) => setTimeout(resolve, 25)), deadline);
147
156
  }
148
157
  state.evidence?.connection('unavailable');
149
158
  return false;
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright (C) 2026 Dyne.org foundation
3
+ * Designed by Denis Roio <jaromil@dyne.org>
4
+ * SPDX-License-Identifier: AGPL-3.0-or-later
5
+ */
6
+ import { createHash, randomUUID } from 'node:crypto';
7
+ import { mkdir, rename, rm, writeFile } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ /** Classify bounded native prose; never retain it or copy arbitrary native fields. */
10
+ export function xerjIndexDiagnostic(message) {
11
+ const text = typeof message === 'string' ? message.slice(0, 16_384) : '';
12
+ const code = text.includes('refusing ambiguous assignment')
13
+ ? 'ambiguous-assignment'
14
+ : /\b(timeout|timed out)\b/i.test(text)
15
+ ? 'timeout'
16
+ : /\b(unauthorized|forbidden|authentication)\b/i.test(text)
17
+ ? 'authentication'
18
+ : /\b(connection refused|connection reset|unreachable)\b/i.test(text)
19
+ ? 'connection'
20
+ : /\b(out of memory|no space left|disk full)\b/i.test(text)
21
+ ? 'capacity'
22
+ : 'unknown-warning';
23
+ return {
24
+ id: randomUUID(),
25
+ occurredAt: new Date().toISOString(),
26
+ code,
27
+ messageDigest: text ? createHash('sha256').update(text).digest('hex') : null,
28
+ };
29
+ }
30
+ /** One private atomic record per root; repeated warnings cannot grow a log. */
31
+ export async function saveXerjIndexDiagnostic(directory, diagnostic) {
32
+ await mkdir(directory, { recursive: true, mode: 0o700 });
33
+ const temporary = join(directory, `.gestalt-index-diagnostic.${randomUUID()}.tmp`);
34
+ try {
35
+ await writeFile(temporary, `${JSON.stringify(diagnostic)}\n`, { flag: 'wx', mode: 0o600 });
36
+ await rename(temporary, join(directory, '.gestalt-index-diagnostic.json'));
37
+ }
38
+ finally {
39
+ await rm(temporary, { force: true });
40
+ }
41
+ }
@@ -11,6 +11,7 @@ import { homedir } from 'node:os';
11
11
  import { checkXerjIndexConfig, saveXerjIndexConfig, xerjContentArguments, xerjIndexConfig, } from './xerj-index-config.js';
12
12
  import { xerjDeadline } from './managed-xerj.js';
13
13
  import { ReadinessEvidence } from './readiness-evidence.js';
14
+ import { saveXerjIndexDiagnostic, xerjIndexDiagnostic } from './xerj-index-diagnostic.js';
14
15
  // Native gitignore syntax, editable by the host operator. Hidden directories and
15
16
  // symlinks are already skipped by XERJ. Never replace an existing root policy.
16
17
  export const xerjDefaultIgnores = `# Gestalt source discovery. Edit these native XERJ rules to change scope.
@@ -65,6 +66,9 @@ export class XerjIndexer {
65
66
  closed = false;
66
67
  saveConfiguration;
67
68
  configurationSaved;
69
+ diagnosticDirectory;
70
+ pendingDiagnostic;
71
+ diagnosticSaved;
68
72
  constructor(root, mode, capability, environment = process.env, report = console.warn) {
69
73
  this.capability = capability;
70
74
  this.environment = environment;
@@ -119,6 +123,7 @@ export class XerjIndexer {
119
123
  }
120
124
  const directory = join(this.environment.CODEX_HOME ?? join(homedir(), '.codex-gestalt'), 'xerj-data', 'autoindex', namespace);
121
125
  const config = xerjIndexConfig(root, namespace, ready.endpoint);
126
+ this.diagnosticDirectory = directory;
122
127
  const compatibility = await checkXerjIndexConfig(directory, config);
123
128
  if (this.closed)
124
129
  return;
@@ -239,22 +244,47 @@ export class XerjIndexer {
239
244
  });
240
245
  }
241
246
  else if (event.event === 'warning') {
242
- if (typeof event.message === 'string' &&
243
- event.message.includes('refusing ambiguous assignment')) {
244
- this.fail('XERJ incremental dataset assignment failed; the index is stale. See the XERJ recovery guide for this upstream limitation.');
247
+ const diagnostic = xerjIndexDiagnostic(event.message);
248
+ this.value = { ...this.value, diagnostic };
249
+ this.pendingDiagnostic = diagnostic;
250
+ this.diagnosticSaved ??= this.saveDiagnostics();
251
+ const reference = ` Diagnostic: ${diagnostic.id} (${diagnostic.code}).`;
252
+ if (diagnostic.code === 'ambiguous-assignment') {
253
+ this.fail('XERJ incremental dataset assignment failed; the index is stale. See the XERJ recovery guide for this upstream limitation.' +
254
+ reference);
245
255
  return;
246
256
  }
247
- this.fail('XERJ reported an indexing warning. Inspect the index with gestalt xerj autoindex status; source changes trigger another pass.');
257
+ this.fail('XERJ reported an indexing warning. Inspect the index with gestalt xerj autoindex status; source changes trigger another pass.' +
258
+ reference);
248
259
  }
249
260
  }
250
261
  catch {
251
262
  /* Native diagnostics are not public status or application logs. */
252
263
  }
253
264
  }
265
+ async saveDiagnostics() {
266
+ try {
267
+ // Coalesce bursts to the latest warning instead of queuing unbounded writes.
268
+ while (this.pendingDiagnostic && this.diagnosticDirectory) {
269
+ const diagnostic = this.pendingDiagnostic;
270
+ this.pendingDiagnostic = undefined;
271
+ try {
272
+ await saveXerjIndexDiagnostic(this.diagnosticDirectory, diagnostic);
273
+ }
274
+ catch {
275
+ this.report('XERJ could not save its redacted indexing diagnostic.');
276
+ }
277
+ }
278
+ }
279
+ finally {
280
+ this.diagnosticSaved = undefined;
281
+ }
282
+ }
254
283
  async close() {
255
284
  this.closed = true;
256
285
  await this.task;
257
286
  await this.configurationSaved;
287
+ await this.diagnosticSaved;
258
288
  const child = this.child;
259
289
  if (child && child.exitCode === null && child.signalCode === null) {
260
290
  await new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.62.1",
3
+ "version": "0.62.2",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",