gestalt-mobile 0.71.4 → 0.72.0

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.
Files changed (39) hide show
  1. package/README.md +15 -48
  2. package/dist/client/assets/index-CwgSPgbi.css +1 -0
  3. package/dist/client/assets/index-ME1MRi_3.js +182 -0
  4. package/dist/client/index.html +2 -2
  5. package/dist/server/client/features/chat/activity-summary.js +11 -0
  6. package/dist/server/client/features/chat/chat-projection.js +6 -2
  7. package/dist/server/server/cli.js +0 -3
  8. package/dist/server/server/composition.contracts.js +32 -3
  9. package/dist/server/server/composition.js +8 -25
  10. package/dist/server/server/config.js +2 -5
  11. package/dist/server/server/features/agent-activity/registry.js +42 -15
  12. package/dist/server/server/features/catalog/get-bootstrap/use-case.js +0 -1
  13. package/dist/server/server/features/catalog/register-routes.js +0 -3
  14. package/dist/server/server/features/skills/list-available/endpoint.js +1 -1
  15. package/dist/server/server/features/skills/model/skill-profile.js +2 -3
  16. package/dist/server/server/platform/codex/capability-deadline.js +26 -0
  17. package/dist/server/server/platform/codex/codex-capabilities.js +23 -56
  18. package/dist/server/server/platform/codex/codex-playwright.js +3 -3
  19. package/dist/server/server/platform/codex/codex-serena.js +1 -1
  20. package/dist/server/server/platform/codex/mcp-startup-failure.js +0 -25
  21. package/dist/server/server/platform/codex/normalizer.js +0 -17
  22. package/dist/server/server/platform/codex/retired-capability-migration.js +105 -0
  23. package/dist/server/server/platform/codex/session-runtime.js +13 -58
  24. package/dist/server/server/platform/codex/startup-guidance.fixture.js +3 -3
  25. package/dist/server/server/platform/kimi/kimi-skill-catalog.js +2 -8
  26. package/dist/server/server/platform/retrieval/repository-readiness.js +2 -7
  27. package/dist/server/server/platform/skills/codex-skill-catalog.js +9 -7
  28. package/dist/server/shared/contracts/mcp-startup-failure.js +5 -30
  29. package/package.json +1 -1
  30. package/dist/client/assets/index-BOJci8Jh.css +0 -1
  31. package/dist/client/assets/index-Cb4qCgbe.js +0 -183
  32. package/dist/server/server/features/catalog/get-xerj-status/endpoint.js +0 -13
  33. package/dist/server/server/platform/retrieval/codex-xerj.js +0 -205
  34. package/dist/server/server/platform/retrieval/managed-xerj.js +0 -196
  35. package/dist/server/server/platform/retrieval/xerj-index-config.js +0 -70
  36. package/dist/server/server/platform/retrieval/xerj-index-diagnostic.js +0 -124
  37. package/dist/server/server/platform/retrieval/xerj-indexer.js +0 -399
  38. package/dist/server/shared/contracts/xerj-startup.js +0 -76
  39. /package/dist/server/{shared/contracts/xerj-status.js → server/platform/codex/capability-contracts.js} +0 -0
@@ -1,399 +0,0 @@
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 { spawn } from 'node:child_process';
7
- import { withoutSessionScratch } from '../scratch/child-environment.js';
8
- import { stopOwnedProcessGroup } from '../scratch/owned-process-group.js';
9
- import { createHash } from 'node:crypto';
10
- import { realpath, writeFile } from 'node:fs/promises';
11
- import { join } from 'node:path';
12
- import { homedir } from 'node:os';
13
- import { checkXerjIndexConfig, saveXerjIndexConfig, xerjContentArguments, xerjIndexConfig, } from './xerj-index-config.js';
14
- import { xerjStartupTimeout } from './managed-xerj.js';
15
- import { ReadinessEvidence } from './readiness-evidence.js';
16
- import { saveXerjIndexDiagnostic, xerjIndexDiagnostic } from './xerj-index-diagnostic.js';
17
- import { parseXerjStartupReason, xerjStartupMessage, } from '../../../shared/contracts/xerj-startup.js';
18
- // Native gitignore syntax, editable by the host operator. Hidden directories and
19
- // symlinks are already skipped by XERJ. Never replace an existing root policy.
20
- export const xerjDefaultIgnores = `# Gestalt source discovery. Edit these native XERJ rules to change scope.
21
- # Keep useful vendored source; XERJ otherwise excludes vendor by default.
22
- !vendor/
23
- node_modules/
24
- target/
25
- build/
26
- dist/
27
- coverage/
28
- __pycache__/
29
- .cache/
30
- .next/
31
- .astro/
32
- *.o
33
- *.obj
34
- *.a
35
- *.so
36
- *.dll
37
- *.exe
38
- *.class
39
- *.pyc
40
- *.wasm
41
- *.map
42
- *.min.js
43
- *.lock
44
- *.tmp
45
- *.swp
46
- *.log
47
- *.zip
48
- *.tar
49
- *.gz
50
- *.sqlite*
51
- *.db
52
- *.pem
53
- *.key
54
- id_rsa*
55
- id_ed25519*
56
- credentials*
57
- secrets/
58
- package-cache/
59
- `;
60
- /** One host-owned child; backend supervision and watcher locking stay in the manager. */
61
- export class XerjIndexer {
62
- capability;
63
- environment;
64
- report;
65
- serviceScratch;
66
- value;
67
- evidence = new ReadinessEvidence();
68
- child;
69
- scratch;
70
- task;
71
- closed = false;
72
- saveConfiguration;
73
- configurationSaved;
74
- diagnosticDirectory;
75
- pendingDiagnostic;
76
- diagnosticSaved;
77
- diskBudgetRefused = false;
78
- currentFailure;
79
- constructor(root, mode, capability, environment = process.env, report = console.warn, serviceScratch) {
80
- this.capability = capability;
81
- this.environment = environment;
82
- this.report = report;
83
- this.serviceScratch = serviceScratch;
84
- this.value = { root, mode, state: mode === 'off' ? 'disabled' : 'starting' };
85
- }
86
- status() {
87
- return { ...this.value, readiness: this.evidence.snapshot() };
88
- }
89
- start() {
90
- if (this.task || this.closed || this.value.mode === 'off')
91
- return;
92
- this.task = this.launch().catch((error) => {
93
- if (!this.closed)
94
- this.reportFailure(error);
95
- });
96
- }
97
- fail(message) {
98
- this.evidence.coverage(this.value.lastUpdate ? 'stale' : 'unavailable');
99
- this.value = { ...this.value, state: 'error', phase: undefined, percent: undefined, message };
100
- this.report(message);
101
- }
102
- rememberDiagnostic(diagnostic) {
103
- this.currentFailure = diagnostic;
104
- this.value = { ...this.value, diagnostic };
105
- this.pendingDiagnostic = diagnostic;
106
- this.diagnosticSaved ??= this.saveDiagnostics();
107
- }
108
- reportFailure(message) {
109
- const diagnostic = xerjIndexDiagnostic(message);
110
- if (this.currentFailure?.summary && this.genericFailure(diagnostic))
111
- return;
112
- this.rememberDiagnostic(diagnostic);
113
- this.fail(`XERJ indexing failed: ${diagnostic.summary ?? 'No error cause was supplied'}. Index freshness is unverified.`);
114
- }
115
- genericFailure(diagnostic) {
116
- return (!diagnostic.summary ||
117
- /^(?:needs-decision|unknown (?:error|cause)|(?:indexing|autoindex|operation|pass) failed)$/i.test(diagnostic.summary));
118
- }
119
- async launch() {
120
- const root = await realpath(this.value.root);
121
- const namespace = `ax-${createHash('sha256').update(root).digest('hex').slice(0, 16)}`;
122
- this.value = { ...this.value, root, namespace };
123
- const ready = await this.capability.check({
124
- cwd: root,
125
- // This background task waits for backend startup, not the chat allowance.
126
- // Leave room for the owned manager client's bounded shutdown.
127
- deadline: Date.now() + xerjStartupTimeout(this.environment) + 1_000,
128
- start: true,
129
- });
130
- if (this.closed)
131
- return;
132
- if (ready.status === 'absent') {
133
- this.evidence.connection('unavailable');
134
- this.evidence.coverage('unavailable');
135
- this.value = {
136
- ...this.value,
137
- state: 'absent',
138
- };
139
- return;
140
- }
141
- if (ready.status !== 'ready') {
142
- this.evidence.connection('unavailable');
143
- this.fail(`${xerjStartupMessage(parseXerjStartupReason(ready.status === 'unavailable' ? ready.reason : 'unknown'))} Inspect gestalt xerj status.`);
144
- return;
145
- }
146
- this.evidence.connection('ready');
147
- if (this.value.mode === 'manual') {
148
- this.value = { ...this.value, state: 'ready', message: 'Automatic indexing is disabled.' };
149
- return;
150
- }
151
- const directory = join(this.environment.CODEX_HOME ?? join(homedir(), '.codex-gestalt'), 'xerj-data', 'autoindex', namespace);
152
- const config = xerjIndexConfig(root, namespace, ready.endpoint);
153
- this.diagnosticDirectory = directory;
154
- const compatibility = await checkXerjIndexConfig(directory, config);
155
- if (this.closed)
156
- return;
157
- if (compatibility === 'incompatible') {
158
- this.fail('XERJ index settings differ from the saved fingerprint. Restore the previous settings or explicitly rebuild this root index; indexing was not started.');
159
- this.evidence.coverage('stale');
160
- return;
161
- }
162
- if (compatibility === 'missing')
163
- this.saveConfiguration = () => saveXerjIndexConfig(directory, config);
164
- try {
165
- await writeFile(join(root, '.xerjignore'), xerjDefaultIgnores, { flag: 'wx', mode: 0o600 });
166
- }
167
- catch (error) {
168
- if (error.code !== 'EEXIST')
169
- throw error;
170
- }
171
- if (this.closed)
172
- return;
173
- this.scratch = await this.serviceScratch?.();
174
- if (this.closed) {
175
- await this.scratch?.release();
176
- return;
177
- }
178
- const child = spawn(ready.manager, [
179
- 'xerj',
180
- 'autoindex',
181
- root,
182
- '--url',
183
- ready.endpoint,
184
- '--prefix',
185
- namespace,
186
- '--watch',
187
- ...xerjContentArguments,
188
- '--yes',
189
- '--workers',
190
- '2',
191
- '--pdf-workers',
192
- '1',
193
- '--bulk-mb',
194
- '4',
195
- '--debounce',
196
- '2000',
197
- '--progress',
198
- 'json',
199
- ], {
200
- cwd: root,
201
- env: { ...withoutSessionScratch(this.environment), ...this.scratch?.environment },
202
- shell: false,
203
- detached: true,
204
- stdio: ['ignore', 'pipe', 'pipe'],
205
- });
206
- this.child = child;
207
- this.value = { ...this.value, state: 'indexing' };
208
- // Retain only redacted error summaries and allowlisted counters/phases;
209
- // bound even a malformed unterminated line.
210
- // Native budget decisions use stdout; progress and watch failures use stderr.
211
- // Keep separate line buffers so interleaved streams cannot corrupt JSON.
212
- for (const stream of [child.stdout, child.stderr]) {
213
- let pending = '';
214
- stream?.on('data', (data) => {
215
- pending += data.toString();
216
- const lines = pending.split('\n');
217
- pending = lines.pop() ?? '';
218
- if (pending.length > 16_384)
219
- pending = '';
220
- for (const line of lines)
221
- if (line.length <= 16_384)
222
- this.progress(line);
223
- });
224
- }
225
- child.once('error', (error) => {
226
- if (!this.closed)
227
- this.reportFailure(error);
228
- });
229
- child.once('close', (code) => {
230
- // Retain the live-owned group handle: leader exit does not prove descendants stopped.
231
- if (this.closed)
232
- return;
233
- if (code === 75) {
234
- this.evidence.coverage('unknown');
235
- this.value = {
236
- ...this.value,
237
- state: 'shared',
238
- message: 'Another watcher owns this root. Progress is available in its Mobile instance.',
239
- };
240
- }
241
- else {
242
- this.fail(`XERJ watcher stopped${this.currentFailure?.summary ? `: ${this.currentFailure.summary}` : ` (exit ${code ?? 'signal'})`}. Run gestalt doctor before restarting Mobile.`);
243
- }
244
- });
245
- }
246
- progress(line) {
247
- if (this.closed)
248
- return;
249
- try {
250
- const event = JSON.parse(line);
251
- if (event.xerj === 'autoindex-budget' && event.decision_required === true) {
252
- const disk = event.disk;
253
- if (disk?.threshold_enabled === true &&
254
- typeof disk.used_percent === 'number' &&
255
- typeof disk.flood_stage === 'number' &&
256
- disk.flood_stage > 0 &&
257
- disk.used_percent <= 100 &&
258
- disk.used_percent >= disk.flood_stage) {
259
- this.diskBudgetRefused = true;
260
- const diagnostic = xerjIndexDiagnostic('no space left: disk flood-stage budget');
261
- this.rememberDiagnostic(diagnostic);
262
- this.fail('XERJ indexing refused: disk flood-stage threshold reached. Free space or move the index to a larger volume. Index freshness is unverified.');
263
- }
264
- else {
265
- this.reportFailure(event.error ?? event.refused ?? 'Indexing requires an operator decision');
266
- }
267
- }
268
- else if (event.event === 'progress') {
269
- this.diskBudgetRefused = false;
270
- this.currentFailure = undefined;
271
- this.evidence.invalidate();
272
- this.evidence.connection('ready');
273
- this.evidence.coverage(this.value.lastUpdate ? 'stale' : 'unknown');
274
- const phase = typeof event.phase === 'string' && /^[a-z-]{1,32}$/.test(event.phase)
275
- ? event.phase
276
- : undefined;
277
- const percent = typeof event.pct === 'number' && event.pct >= 0 && event.pct <= 100
278
- ? event.pct
279
- : undefined;
280
- this.value = {
281
- ...this.value,
282
- state: 'indexing',
283
- phase,
284
- percent,
285
- message: 'XERJ indexing is in progress. Index coverage is unverified until this pass succeeds.',
286
- };
287
- }
288
- else if (event.event === 'done') {
289
- if (event.ok !== true) {
290
- if (this.diskBudgetRefused)
291
- return;
292
- const detail = event.error ?? event.message;
293
- if (detail || !this.currentFailure)
294
- this.reportFailure(detail ?? event.reason);
295
- return;
296
- }
297
- if (this.saveConfiguration && !this.configurationSaved) {
298
- this.configurationSaved = this.saveConfiguration().catch(() => {
299
- this.fail('XERJ indexed successfully but could not save its configuration fingerprint. Check write access to the managed index directory.');
300
- });
301
- }
302
- this.value = {
303
- ...this.value,
304
- state: 'watching',
305
- phase: undefined,
306
- percent: undefined,
307
- lastUpdate: new Date().toISOString(),
308
- message: undefined,
309
- ...(count(event.files) !== undefined ? { files: count(event.files) } : {}),
310
- ...(count(event.records) !== undefined ? { records: count(event.records) } : {}),
311
- };
312
- this.diskBudgetRefused = false;
313
- this.currentFailure = undefined;
314
- const records = count(event.records);
315
- this.evidence.coverage(records === undefined ? 'unknown' : records === 0 ? 'unavailable' : 'ready', {
316
- files: count(event.files),
317
- records,
318
- });
319
- }
320
- else if (event.event === 'warning' || event.event === 'error') {
321
- const diagnostic = xerjIndexDiagnostic(event.error ?? event.message ?? event.reason);
322
- if ((this.currentFailure?.summary && this.genericFailure(diagnostic)) ||
323
- (this.diskBudgetRefused &&
324
- ['watch-pass-failed', 'unknown-warning'].includes(diagnostic.code)))
325
- return;
326
- this.rememberDiagnostic(diagnostic);
327
- if (diagnostic.code === 'watch-rescan') {
328
- this.currentFailure = undefined;
329
- // Native XERJ already schedules a full pass after dropped watch events.
330
- // This invalidates coverage, but is not a failed pass or lost connection.
331
- this.evidence.coverage(this.value.lastUpdate ? 'stale' : 'unknown');
332
- this.value = {
333
- ...this.value,
334
- state: 'indexing',
335
- phase: undefined,
336
- percent: undefined,
337
- message: 'XERJ is rescanning the workspace after filesystem events were dropped.',
338
- };
339
- return;
340
- }
341
- if (diagnostic.code === 'rebuild-required') {
342
- this.fail(`XERJ indexing failed: ${diagnostic.summary ?? 'Saved index configuration changed'}. A new index generation is required; source changes alone cannot repair it.`);
343
- return;
344
- }
345
- if (diagnostic.code === 'ambiguous-assignment') {
346
- this.fail(`XERJ indexing failed: ${diagnostic.summary ?? 'Ambiguous dataset assignment'}. The index is stale; see the XERJ recovery guide.`);
347
- return;
348
- }
349
- const cause = {
350
- timeout: 'An indexing operation timed out.',
351
- authentication: 'The indexing backend rejected authentication or access.',
352
- connection: 'The indexing backend connection failed.',
353
- capacity: 'Indexing ran out of memory or disk space.',
354
- 'watch-pass-failed': 'The underlying cause could not be classified.',
355
- 'unknown-warning': 'The warning could not be classified.',
356
- }[diagnostic.code];
357
- this.fail(`XERJ indexing failed: ${diagnostic.summary ?? cause.replace(/\.$/, '')}. The watcher is still running; index freshness is unverified.`);
358
- }
359
- }
360
- catch {
361
- // Ignore ordinary stdout and partial payloads. Only explicit error lines
362
- // are eligible for redaction and display.
363
- if (/^\s*(?:error|fatal|caused by):/i.test(line))
364
- this.reportFailure(line);
365
- }
366
- }
367
- async saveDiagnostics() {
368
- try {
369
- // Coalesce bursts to the latest warning instead of queuing unbounded writes.
370
- while (this.pendingDiagnostic && this.diagnosticDirectory) {
371
- const diagnostic = this.pendingDiagnostic;
372
- this.pendingDiagnostic = undefined;
373
- try {
374
- await saveXerjIndexDiagnostic(this.diagnosticDirectory, diagnostic);
375
- }
376
- catch {
377
- this.report('XERJ could not save its redacted indexing diagnostic.');
378
- }
379
- }
380
- }
381
- finally {
382
- this.diagnosticSaved = undefined;
383
- }
384
- }
385
- async close() {
386
- this.closed = true;
387
- await this.task;
388
- await this.configurationSaved;
389
- await this.diagnosticSaved;
390
- const child = this.child;
391
- if (child && (await stopOwnedProcessGroup(child)))
392
- await this.scratch?.release();
393
- this.value = { ...this.value, state: this.value.mode === 'off' ? 'disabled' : 'stopped' };
394
- this.evidence.connection('unavailable');
395
- }
396
- }
397
- function count(value) {
398
- return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
399
- }
@@ -1,76 +0,0 @@
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
- /** Manager reason codes only; never propagate subprocess prose or environment values. */
7
- const reasons = [
8
- 'cancelled',
9
- 'timeout',
10
- 'readiness-timeout',
11
- 'unsafe-path',
12
- 'unsupported-installation',
13
- 'unsupported-version',
14
- 'unsupported-binary',
15
- 'unsafe-endpoint',
16
- 'credentials-unavailable',
17
- 'authentication-failed',
18
- 'backend-unavailable',
19
- 'invalid-backend',
20
- 'invalid-mcp',
21
- 'incompatible-mcp',
22
- 'invalid-deadline',
23
- 'invalid-lifecycle-record',
24
- 'lifecycle-busy',
25
- 'endpoint-in-use',
26
- 'launch-failed',
27
- 'probe-failed',
28
- 'manager-unavailable',
29
- 'invalid-manager-response',
30
- 'unknown',
31
- ];
32
- export function parseXerjStartupReason(value) {
33
- return typeof value === 'string' && reasons.includes(value)
34
- ? value
35
- : 'unknown';
36
- }
37
- export function xerjStartupMessage(reason) {
38
- switch (reason) {
39
- case 'timeout':
40
- case 'readiness-timeout':
41
- return 'XERJ backend preparation exceeded its time budget.';
42
- case 'credentials-unavailable':
43
- case 'authentication-failed':
44
- return 'XERJ backend authentication is unavailable or was rejected.';
45
- case 'endpoint-in-use':
46
- return 'The selected XERJ endpoint is already occupied.';
47
- case 'unsafe-path':
48
- case 'unsafe-endpoint':
49
- case 'unsupported-installation':
50
- case 'invalid-lifecycle-record':
51
- case 'invalid-deadline':
52
- return 'XERJ manager configuration or managed state failed validation.';
53
- case 'unsupported-version':
54
- case 'unsupported-binary':
55
- case 'incompatible-mcp':
56
- return 'The installed XERJ runtime is incompatible or unavailable.';
57
- case 'manager-unavailable':
58
- return 'The Gestalt manager could not be executed.';
59
- case 'backend-unavailable':
60
- return 'The XERJ backend could not be reached.';
61
- case 'launch-failed':
62
- return 'The managed XERJ backend could not be started.';
63
- case 'probe-failed':
64
- return 'The Gestalt manager could not complete its readiness check.';
65
- case 'invalid-backend':
66
- case 'invalid-mcp':
67
- case 'invalid-manager-response':
68
- return 'XERJ readiness returned an invalid response.';
69
- case 'lifecycle-busy':
70
- return 'Another XERJ lifecycle operation is still in progress.';
71
- case 'cancelled':
72
- return 'XERJ backend preparation was cancelled.';
73
- default:
74
- return 'XERJ backend preparation failed; no more specific cause is available.';
75
- }
76
- }