gestalt-mobile 0.71.5 → 0.72.1
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 +15 -48
- package/dist/client/assets/index-CwgSPgbi.css +1 -0
- package/dist/client/assets/index-ME1MRi_3.js +182 -0
- package/dist/client/index.html +2 -2
- package/dist/server/client/features/chat/activity-summary.js +11 -0
- package/dist/server/client/features/chat/chat-projection.js +6 -2
- package/dist/server/server/cli.js +0 -3
- package/dist/server/server/composition.contracts.js +0 -2
- package/dist/server/server/composition.js +8 -25
- package/dist/server/server/config.js +2 -5
- package/dist/server/server/features/agent-activity/registry.js +42 -15
- package/dist/server/server/features/catalog/get-bootstrap/use-case.js +0 -1
- package/dist/server/server/features/catalog/register-routes.js +0 -3
- package/dist/server/server/features/sessions/forget-session/use-case.js +6 -0
- package/dist/server/server/features/skills/list-available/endpoint.js +1 -1
- package/dist/server/server/features/skills/model/skill-profile.js +2 -3
- package/dist/server/server/platform/codex/capability-deadline.js +26 -0
- package/dist/server/server/platform/codex/codex-capabilities.js +23 -56
- package/dist/server/server/platform/codex/codex-playwright.js +3 -3
- package/dist/server/server/platform/codex/codex-serena.js +1 -1
- package/dist/server/server/platform/codex/mcp-startup-failure.js +0 -25
- package/dist/server/server/platform/codex/normalizer.js +0 -17
- package/dist/server/server/platform/codex/retired-capability-migration.js +105 -0
- package/dist/server/server/platform/codex/session-runtime.js +4 -52
- package/dist/server/server/platform/codex/startup-guidance.fixture.js +3 -3
- package/dist/server/server/platform/kimi/kimi-skill-catalog.js +2 -8
- package/dist/server/server/platform/retrieval/repository-readiness.js +2 -7
- package/dist/server/server/platform/scratch/containment-fence.js +76 -20
- package/dist/server/server/platform/scratch/filesystem-scratch-cleanup.js +139 -13
- package/dist/server/server/platform/scratch/filesystem-session-scratch.js +20 -11
- package/dist/server/server/platform/scratch/filesystem-workspace-forget.js +64 -8
- package/dist/server/server/platform/scratch/managed-scratch-owner.js +17 -1
- package/dist/server/server/platform/scratch/runtime-root.js +147 -0
- package/dist/server/server/platform/scratch/workspace-publication.js +67 -0
- package/dist/server/server/platform/skills/codex-skill-catalog.js +9 -7
- package/dist/server/shared/contracts/mcp-startup-failure.js +5 -30
- package/package.json +1 -1
- package/dist/client/assets/index-BOJci8Jh.css +0 -1
- package/dist/client/assets/index-Cb4qCgbe.js +0 -183
- package/dist/server/server/features/catalog/get-xerj-status/endpoint.js +0 -13
- package/dist/server/server/platform/retrieval/codex-xerj.js +0 -205
- package/dist/server/server/platform/retrieval/managed-xerj.js +0 -196
- package/dist/server/server/platform/retrieval/xerj-index-config.js +0 -70
- package/dist/server/server/platform/retrieval/xerj-index-diagnostic.js +0 -124
- package/dist/server/server/platform/retrieval/xerj-indexer.js +0 -399
- package/dist/server/shared/contracts/xerj-startup.js +0 -76
- /package/dist/server/{shared/contracts/xerj-status.js → server/platform/codex/capability-contracts.js} +0 -0
package/dist/client/index.html
CHANGED
|
@@ -16,8 +16,8 @@ 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-
|
|
20
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-ME1MRi_3.js"></script>
|
|
20
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CwgSPgbi.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
23
23
|
<div id="app"></div>
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
+
/** Ignore owned legacy telemetry in memory; leave persisted history and user work intact. */
|
|
7
|
+
export function isRetiredServiceActivity(value) {
|
|
8
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
9
|
+
return false;
|
|
10
|
+
const activity = value;
|
|
11
|
+
return (activity.id === 'gestalt-xerj-availability' ||
|
|
12
|
+
activity.mcpStartup?.serverName === 'gestalt-xerj' ||
|
|
13
|
+
(typeof activity.id === 'string' &&
|
|
14
|
+
activity.id.startsWith('mcp-startup:') &&
|
|
15
|
+
activity.id.endsWith(':gestalt-xerj')));
|
|
16
|
+
}
|
|
6
17
|
/** Runtime health belongs in diagnostics and failure notifications, outside the conversation. */
|
|
7
18
|
export function isServiceStatusActivity(activity) {
|
|
8
19
|
return (activity.mcpStartup !== undefined ||
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { autopilotAuditLabel, autopilotAuditAttention, } from '../../../shared/contracts/autopilot-audit.js';
|
|
7
|
-
import { toActivity } from './activity-summary.js';
|
|
7
|
+
import { isRetiredServiceActivity, toActivity } from './activity-summary.js';
|
|
8
8
|
import { parseMcpStartupStatus } from '../../../shared/contracts/mcp-startup-failure.js';
|
|
9
9
|
const empty = () => ({
|
|
10
10
|
sessionId: null,
|
|
@@ -329,6 +329,7 @@ export function hydrateCache(sessionId, cached) {
|
|
|
329
329
|
value.deletions >= 0);
|
|
330
330
|
}))) &&
|
|
331
331
|
(activity.turnId === undefined || typeof activity.turnId === 'string')))
|
|
332
|
+
.filter((activity) => !isRetiredServiceActivity(activity))
|
|
332
333
|
.map((activity) => {
|
|
333
334
|
const { mcpStartup, ...safe } = activity;
|
|
334
335
|
const status = parseMcpStartupStatus(mcpStartup);
|
|
@@ -405,7 +406,9 @@ export function acceptSnapshot(current, snapshot) {
|
|
|
405
406
|
.concat((snapshot.activities ?? []).map((activity) => ({
|
|
406
407
|
...activity,
|
|
407
408
|
key: `activity:${activity.id}`,
|
|
408
|
-
}))))
|
|
409
|
+
}))))
|
|
410
|
+
.filter((item) => !isRetiredServiceActivity(item))
|
|
411
|
+
.map((item) => ({
|
|
409
412
|
id: item.id,
|
|
410
413
|
label: item.label,
|
|
411
414
|
detail: item.detail,
|
|
@@ -670,6 +673,7 @@ export function applyProjectionEvent(current, event) {
|
|
|
670
673
|
else if (event.type === 'interaction.resolved' && typeof payload?.requestId === 'string')
|
|
671
674
|
next = resolveInteraction(next, payload.requestId, payload.outcome, occurredAt);
|
|
672
675
|
else if (event.type === 'activity.updated' &&
|
|
676
|
+
!isRetiredServiceActivity(payload) &&
|
|
673
677
|
typeof payload?.id === 'string' &&
|
|
674
678
|
typeof payload.label === 'string' &&
|
|
675
679
|
typeof payload.detail === 'string') {
|
|
@@ -32,7 +32,6 @@ Options:
|
|
|
32
32
|
--data-dir <path> Directory for persistent application data
|
|
33
33
|
--icon <path> SVG or PNG used as the installed PWA application icon
|
|
34
34
|
--disable-test-runner Disable host tests (default: runtime .gestalt/host-tests.json suites)
|
|
35
|
-
--xerj <mode> Source discovery: auto (default, index and watch), manual, off
|
|
36
35
|
--skills <profile> Use a global skill profile for every session
|
|
37
36
|
--skills list List saved global skill profiles without starting the server
|
|
38
37
|
--help Show this help
|
|
@@ -67,7 +66,6 @@ export function componentVersions(mobileVersion, codexVersion, environment = pro
|
|
|
67
66
|
version: managedVersion(environment.GESTALT_CONTEXT_MODE_VERSION),
|
|
68
67
|
},
|
|
69
68
|
{ id: 'codex', label: 'Codex CLI', version: codexVersion },
|
|
70
|
-
{ id: 'xerj', label: 'xerj', version: managedVersion(environment.GESTALT_XERJ_VERSION) },
|
|
71
69
|
{ id: 'serena', label: 'Serena', version: semanticVersion(environment.GESTALT_SERENA_VERSION) },
|
|
72
70
|
playwright,
|
|
73
71
|
{ id: 'uv', label: 'uv', version: semanticVersion(environment.GESTALT_UV_VERSION) },
|
|
@@ -311,7 +309,6 @@ export async function runCli(dependencies = {}) {
|
|
|
311
309
|
const mobileVersion = await packageVersion(moduleUrl);
|
|
312
310
|
const app = await (dependencies.compose ?? composeRelayApp)({
|
|
313
311
|
root: config.root,
|
|
314
|
-
xerj: config.xerj,
|
|
315
312
|
dataDir: config.dataDir,
|
|
316
313
|
testRunnerEnabled: config.testRunnerEnabled,
|
|
317
314
|
relyingParty: config.relyingParty,
|
|
@@ -7987,8 +7987,6 @@ describe('production composition', () => {
|
|
|
7987
7987
|
['HEAD', '/api/bootstrap', '/api/bootstrap', 'protected'],
|
|
7988
7988
|
['GET', '/api/codex/allowance', '/api/codex/allowance', 'protected'],
|
|
7989
7989
|
['HEAD', '/api/codex/allowance', '/api/codex/allowance', 'protected'],
|
|
7990
|
-
['GET', '/api/xerj', '/api/xerj', 'protected'],
|
|
7991
|
-
['HEAD', '/api/xerj', '/api/xerj', 'protected'],
|
|
7992
7990
|
['GET', '/api/session-defaults', '/api/session-defaults', 'protected'],
|
|
7993
7991
|
['HEAD', '/api/session-defaults', '/api/session-defaults', 'protected'],
|
|
7994
7992
|
['PUT', '/api/session-defaults', '/api/session-defaults', 'protected'],
|
|
@@ -91,9 +91,6 @@ import { CachedSkillCatalog } from './platform/skills/cached-skill-catalog.js';
|
|
|
91
91
|
import { ManagedSkillProvenance } from './platform/skills/managed-skill-provenance.js';
|
|
92
92
|
import { ManagedSkillCatalog } from './platform/skills/managed-skill-catalog.js';
|
|
93
93
|
import { VerifiedSkillCatalog } from './platform/skills/verified-skill-catalog.js';
|
|
94
|
-
import { XerjIndexer } from './platform/retrieval/xerj-indexer.js';
|
|
95
|
-
import { ManagedXerj, xerjDeadline } from './platform/retrieval/managed-xerj.js';
|
|
96
|
-
import { CodexXerj } from './platform/retrieval/codex-xerj.js';
|
|
97
94
|
import { CodexSerena } from './platform/codex/codex-serena.js';
|
|
98
95
|
import { ManagedSerena } from './platform/codex/managed-serena.js';
|
|
99
96
|
import { CodexCapabilities } from './platform/codex/codex-capabilities.js';
|
|
@@ -600,13 +597,8 @@ export async function composeRelayApp(options) {
|
|
|
600
597
|
const codexHome = process.env.CODEX_HOME ?? join(options.homeDirectory ?? homedir(), '.codex-gestalt');
|
|
601
598
|
const skillProvenance = new ManagedSkillProvenance(codexHome);
|
|
602
599
|
const kimiSkillCatalog = new VerifiedSkillCatalog(new KimiSkillCatalog(kimiManager ?? null, kimiManager != null, new ManagedSkillCatalog(codexHome)), skillProvenance);
|
|
603
|
-
const retrievalCapability = options.xerj === 'off'
|
|
604
|
-
? { check: async () => ({ status: 'absent' }) }
|
|
605
|
-
: (options.retrievalCapability ?? new ManagedXerj());
|
|
606
|
-
const xerjIndexer = new XerjIndexer(root, options.xerj ?? 'manual', retrievalCapability, process.env, console.warn, () => sessionScratch.allocateService(root, 'xerj-indexer'));
|
|
607
|
-
const xerj = new CodexXerj(retrievalCapability);
|
|
608
600
|
const serenaInstallation = new ManagedSerena();
|
|
609
|
-
const capabilities = new CodexCapabilities(
|
|
601
|
+
const capabilities = new CodexCapabilities(new CodexSerena(serenaInstallation));
|
|
610
602
|
const playwright = new CodexPlaywright(new ManagedPlaywright(), sessionScratch);
|
|
611
603
|
const playwrightAuthority = (session) => {
|
|
612
604
|
const plan = supervisedPlans.findCurrent(session.id);
|
|
@@ -631,18 +623,15 @@ export async function composeRelayApp(options) {
|
|
|
631
623
|
: kimiSkillCatalog.list(workspace), async (provider, _profile, workspace, result) => {
|
|
632
624
|
if (provider !== 'codex')
|
|
633
625
|
return result;
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
result.skills.some((skill) => skill.name === 'gestalt:serena' && skill.enabled)
|
|
639
|
-
? serenaInstallation.check()
|
|
640
|
-
: undefined,
|
|
641
|
-
]);
|
|
626
|
+
const serenaStatus = result.skills.some((skill) => skill.name === 'gestalt:serena' && skill.enabled)
|
|
627
|
+
? serenaInstallation.check()
|
|
628
|
+
: undefined;
|
|
629
|
+
const installedSerena = await serenaStatus;
|
|
642
630
|
return {
|
|
643
631
|
...result,
|
|
644
|
-
skills: result.skills.map((skill) =>
|
|
645
|
-
|
|
632
|
+
skills: result.skills.map((skill) => skill.name === 'gestalt:serena' &&
|
|
633
|
+
installedSerena &&
|
|
634
|
+
installedSerena.status !== 'installed'
|
|
646
635
|
? { ...skill, enabled: false }
|
|
647
636
|
: skill),
|
|
648
637
|
};
|
|
@@ -2161,7 +2150,6 @@ export async function composeRelayApp(options) {
|
|
|
2161
2150
|
}
|
|
2162
2151
|
: new CodexAllowanceReader(root, options.launchAppServer ?? launchCodexAppServer),
|
|
2163
2152
|
bootstrap: {
|
|
2164
|
-
xerj: () => xerjIndexer.status(),
|
|
2165
2153
|
sessionDefaults,
|
|
2166
2154
|
workspaces,
|
|
2167
2155
|
profiles: options.profiles,
|
|
@@ -2583,7 +2571,6 @@ export async function composeRelayApp(options) {
|
|
|
2583
2571
|
}
|
|
2584
2572
|
catch (error) {
|
|
2585
2573
|
await hostTests?.close();
|
|
2586
|
-
await retrievalCapability.close?.();
|
|
2587
2574
|
authorization?.close();
|
|
2588
2575
|
database.close();
|
|
2589
2576
|
throw error;
|
|
@@ -2612,8 +2599,6 @@ export async function composeRelayApp(options) {
|
|
|
2612
2599
|
app.addHook('onListen', async () => {
|
|
2613
2600
|
for (const id of forgetOperations.pendingIds())
|
|
2614
2601
|
void forgetSessions.execute(id).catch(() => undefined);
|
|
2615
|
-
if (options.xerj)
|
|
2616
|
-
xerjIndexer.start();
|
|
2617
2602
|
const profile = (await options.profiles.list()).find((item) => item.state === 'ok')?.name;
|
|
2618
2603
|
if (profile)
|
|
2619
2604
|
await editorSkillCatalog.refresh('codex', profile, root);
|
|
@@ -2652,8 +2637,6 @@ export async function composeRelayApp(options) {
|
|
|
2652
2637
|
app.addHook('onClose', async () => {
|
|
2653
2638
|
await hostTests?.close();
|
|
2654
2639
|
await forgetSessions.drain();
|
|
2655
|
-
await retrievalCapability.close?.();
|
|
2656
|
-
await xerjIndexer.close();
|
|
2657
2640
|
for (const [sessionId, timer] of capacityRecoveryTimers) {
|
|
2658
2641
|
clearTimeout(timer);
|
|
2659
2642
|
capacityRecoveries.delete(sessionId);
|
|
@@ -16,7 +16,6 @@ const optionNames = new Set([
|
|
|
16
16
|
'--public-origin',
|
|
17
17
|
'--skills',
|
|
18
18
|
'--icon',
|
|
19
|
-
'--xerj',
|
|
20
19
|
]);
|
|
21
20
|
const flagNames = new Set(['--disable-passkey-auth', '--disable-test-runner']);
|
|
22
21
|
export function parseConfig(args, cwd = process.cwd()) {
|
|
@@ -24,6 +23,8 @@ export function parseConfig(args, cwd = process.cwd()) {
|
|
|
24
23
|
const flags = new Set();
|
|
25
24
|
for (let index = 0; index < args.length; index += 1) {
|
|
26
25
|
const option = args[index];
|
|
26
|
+
if (option === '--xerj' || option.startsWith('--xerj='))
|
|
27
|
+
throw new CliUsageError('Xerj integration has been retired. Remove --xerj from this invocation.');
|
|
27
28
|
if (!option.startsWith('--'))
|
|
28
29
|
throw new CliUsageError(`Unexpected argument: ${option}`);
|
|
29
30
|
if (flagNames.has(option)) {
|
|
@@ -42,9 +43,6 @@ export function parseConfig(args, cwd = process.cwd()) {
|
|
|
42
43
|
values.set(option, value);
|
|
43
44
|
index += 1;
|
|
44
45
|
}
|
|
45
|
-
const xerj = values.get('--xerj') ?? 'auto';
|
|
46
|
-
if (xerj !== 'auto' && xerj !== 'manual' && xerj !== 'off')
|
|
47
|
-
throw new CliUsageError('--xerj must be auto, manual, or off');
|
|
48
46
|
const portValue = values.get('--port') ?? '3000';
|
|
49
47
|
const port = Number(portValue);
|
|
50
48
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
@@ -57,7 +55,6 @@ export function parseConfig(args, cwd = process.cwd()) {
|
|
|
57
55
|
return {
|
|
58
56
|
host,
|
|
59
57
|
port,
|
|
60
|
-
xerj,
|
|
61
58
|
passkeyAuthEnabled,
|
|
62
59
|
relyingParty: createRelyingPartyConfig(publicOrigin),
|
|
63
60
|
root: resolve(cwd, values.get('--cwd') ?? '.'),
|
|
@@ -44,10 +44,13 @@ export class AgentActivityRegistry {
|
|
|
44
44
|
const next = withActivityConfidence(projectAgentActivity(current, fact), fact.kind === 'collaboration' && !fact.childId ? 'stale' : 'fresh');
|
|
45
45
|
if (next !== snapshot) {
|
|
46
46
|
this.#snapshots.set(fact.sessionId, next);
|
|
47
|
-
this.publish(next, fact.occurredAt);
|
|
48
47
|
}
|
|
49
48
|
this.#generation.set(fact.sessionId, (this.#generation.get(fact.sessionId) ?? 0) + 1);
|
|
50
49
|
this.#armStaleness(fact.sessionId);
|
|
50
|
+
// Publish only after the observation owns its timer and generation. A
|
|
51
|
+
// synchronous lifecycle observer can then suspend or dispose both.
|
|
52
|
+
if (next !== snapshot)
|
|
53
|
+
this.publish(next, fact.occurredAt);
|
|
51
54
|
return next;
|
|
52
55
|
}
|
|
53
56
|
reconciling(sessionId, occurredAt) {
|
|
@@ -66,8 +69,7 @@ export class AgentActivityRegistry {
|
|
|
66
69
|
return next;
|
|
67
70
|
}
|
|
68
71
|
suspend(sessionId) {
|
|
69
|
-
this.#
|
|
70
|
-
this.#timers.delete(sessionId);
|
|
72
|
+
this.#cancelTimer(sessionId);
|
|
71
73
|
this.#generation.set(sessionId, (this.#generation.get(sessionId) ?? 0) + 1);
|
|
72
74
|
// The RPC cannot be cancelled, but a restart must not coalesce onto its
|
|
73
75
|
// obsolete promise. Generation guards suppress its eventual result.
|
|
@@ -177,23 +179,51 @@ export class AgentActivityRegistry {
|
|
|
177
179
|
dispose(sessionId) {
|
|
178
180
|
this.#disposed.add(sessionId);
|
|
179
181
|
this.#snapshots.delete(sessionId);
|
|
180
|
-
this.#
|
|
181
|
-
this.#timers.delete(sessionId);
|
|
182
|
+
this.#cancelTimer(sessionId);
|
|
182
183
|
this.#generation.delete(sessionId);
|
|
183
184
|
this.#inFlight.delete(sessionId);
|
|
184
185
|
}
|
|
185
186
|
#armStaleness(sessionId) {
|
|
186
|
-
if (!this.options.schedule || !this.options.reconcile)
|
|
187
|
+
if (this.#disposed.has(sessionId) || !this.options.schedule || !this.options.reconcile)
|
|
187
188
|
return;
|
|
188
|
-
this.#
|
|
189
|
-
|
|
189
|
+
this.#schedule(sessionId, () => void this.refresh(sessionId), this.options.staleAfterMs ?? 30_000);
|
|
190
|
+
}
|
|
191
|
+
#cancelTimer(sessionId) {
|
|
192
|
+
const cancel = this.#timers.get(sessionId);
|
|
193
|
+
this.#timers.delete(sessionId);
|
|
194
|
+
cancel?.();
|
|
195
|
+
}
|
|
196
|
+
#schedule(sessionId, callback, delayMs, onCancel) {
|
|
197
|
+
this.#cancelTimer(sessionId);
|
|
198
|
+
let active = true;
|
|
199
|
+
const cancelScheduled = this.options.schedule(() => {
|
|
200
|
+
// Cancellation cannot retract an already-dispatched callback. Slot
|
|
201
|
+
// identity prevents it from consuming a newer observation's timer.
|
|
202
|
+
if (!active || this.#timers.get(sessionId) !== cancel)
|
|
203
|
+
return;
|
|
204
|
+
active = false;
|
|
205
|
+
this.#timers.delete(sessionId);
|
|
206
|
+
callback();
|
|
207
|
+
}, delayMs);
|
|
208
|
+
const cancel = () => {
|
|
209
|
+
if (!active)
|
|
210
|
+
return;
|
|
211
|
+
active = false;
|
|
212
|
+
cancelScheduled();
|
|
213
|
+
onCancel?.();
|
|
214
|
+
};
|
|
215
|
+
this.#timers.set(sessionId, cancel);
|
|
190
216
|
}
|
|
191
217
|
async #attempt(sessionId, generation, attempt) {
|
|
192
218
|
if (this.#generation.get(sessionId) !== generation)
|
|
193
219
|
return;
|
|
194
|
-
|
|
220
|
+
// A foreground refresh must cancel the observed staleness timeout, not
|
|
221
|
+
// merely forget its handle. Fired retry callbacks already consumed theirs.
|
|
222
|
+
this.#cancelTimer(sessionId);
|
|
195
223
|
const now = this.options.now?.() ?? new Date().toISOString();
|
|
196
224
|
this.reconciling(sessionId, now);
|
|
225
|
+
if (this.#generation.get(sessionId) !== generation)
|
|
226
|
+
return;
|
|
197
227
|
try {
|
|
198
228
|
const observed = await this.options.reconcile?.(sessionId);
|
|
199
229
|
if (observed !== true)
|
|
@@ -232,12 +262,9 @@ export class AgentActivityRegistry {
|
|
|
232
262
|
// Otherwise a caller treats the intermediate reconciling projection as
|
|
233
263
|
// failure and can launch a new refresh that supersedes this retry.
|
|
234
264
|
await new Promise((resolve, reject) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// Suspension, disposal, or newer live evidence retires this read.
|
|
239
|
-
resolve();
|
|
240
|
-
});
|
|
265
|
+
this.#schedule(sessionId, () => void this.#attempt(sessionId, generation, attempt + 1).then(resolve, reject), delays[attempt - 1],
|
|
266
|
+
// Suspension, disposal, or newer live evidence retires this read.
|
|
267
|
+
resolve);
|
|
241
268
|
});
|
|
242
269
|
}
|
|
243
270
|
}
|
|
@@ -22,7 +22,6 @@ export async function getBootstrap(deps) {
|
|
|
22
22
|
}
|
|
23
23
|
return {
|
|
24
24
|
...(deps.sessionDefaults ? { sessionDefaults, sessionDefaultsError } : {}),
|
|
25
|
-
...(deps.xerj ? { xerj: deps.xerj() } : {}),
|
|
26
25
|
workspaces,
|
|
27
26
|
profiles,
|
|
28
27
|
models: { codex: codexModels, kimi: kimiModels },
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
import { registerXerjStatus } from './get-xerj-status/endpoint.js';
|
|
7
6
|
import { registerGetBootstrap } from './get-bootstrap/endpoint.js';
|
|
8
7
|
import { registerSessionDefaults } from './session-defaults/endpoint.js';
|
|
9
8
|
import { registerGetCodexAllowance, } from './get-codex-allowance/endpoint.js';
|
|
@@ -12,8 +11,6 @@ export function registerCatalogRoutes(app, deps) {
|
|
|
12
11
|
registerGetBootstrap(app, deps.bootstrap);
|
|
13
12
|
if (deps.codexAllowance)
|
|
14
13
|
registerGetCodexAllowance(app, deps.codexAllowance);
|
|
15
|
-
if (deps.bootstrap?.xerj)
|
|
16
|
-
registerXerjStatus(app, deps.bootstrap.xerj);
|
|
17
14
|
if (deps.sessionDefaults)
|
|
18
15
|
registerSessionDefaults(app, deps.sessionDefaults);
|
|
19
16
|
}
|
|
@@ -44,6 +44,7 @@ export class ForgetSession {
|
|
|
44
44
|
return operation;
|
|
45
45
|
};
|
|
46
46
|
let failureCode = 'SESSION_RELEASE_UNCONFIRMED';
|
|
47
|
+
let releaseCleanup;
|
|
47
48
|
try {
|
|
48
49
|
const session = this.deps.find(id);
|
|
49
50
|
if (!session)
|
|
@@ -56,6 +57,8 @@ export class ForgetSession {
|
|
|
56
57
|
if (advance('cleaning').phase === 'completed')
|
|
57
58
|
return operation;
|
|
58
59
|
const cleanup = await this.deps.clean(session, operation.operationId);
|
|
60
|
+
if (cleanup && typeof cleanup === 'object')
|
|
61
|
+
releaseCleanup = () => cleanup.release();
|
|
59
62
|
operation = { ...operation, scratchRetained: cleanup === 'retained' ? true : undefined };
|
|
60
63
|
failureCode = 'SESSION_FORGET_FAILED';
|
|
61
64
|
if (advance('finalizing').phase === 'completed')
|
|
@@ -77,5 +80,8 @@ export class ForgetSession {
|
|
|
77
80
|
this.deps.changed(operation);
|
|
78
81
|
return operation;
|
|
79
82
|
}
|
|
83
|
+
finally {
|
|
84
|
+
await releaseCleanup?.();
|
|
85
|
+
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
@@ -42,7 +42,7 @@ export function registerListAvailableSkills(app, deps) {
|
|
|
42
42
|
...(project?.capabilities ? { capabilities: project.capabilities } : {}),
|
|
43
43
|
errors: discovered.errors.map(({ message }) => ({ message })),
|
|
44
44
|
skills: skills
|
|
45
|
-
.filter((skill) => !isAlwaysAdvertisedSkill(skill)
|
|
45
|
+
.filter((skill) => !isAlwaysAdvertisedSkill(skill))
|
|
46
46
|
.sort((left, right) => left.path.localeCompare(right.path))
|
|
47
47
|
.map((skill) => ({
|
|
48
48
|
name: skill.name,
|
|
@@ -70,8 +70,7 @@ export const availableSkillSchema = z
|
|
|
70
70
|
*/
|
|
71
71
|
export function isAlwaysAdvertisedSkill(skill) {
|
|
72
72
|
return (isGestaltSkillName(skill.name) &&
|
|
73
|
-
(!['gestalt:
|
|
74
|
-
skill.enabled));
|
|
73
|
+
(!['gestalt:serena', 'gestalt:playwright'].includes(skill.name) || skill.enabled));
|
|
75
74
|
}
|
|
76
75
|
export function isGestaltSkillName(name) {
|
|
77
76
|
return name.startsWith('gestalt:');
|
|
@@ -181,7 +180,7 @@ export function applySkillSelectionSnapshot(discovered, selection) {
|
|
|
181
180
|
const enabledByPath = new Map(createSkillSelection(selection).map((entry) => [entry.path, entry.enabled]));
|
|
182
181
|
return catalog.map((skill) => ({
|
|
183
182
|
...skill,
|
|
184
|
-
enabled: ['gestalt:
|
|
183
|
+
enabled: ['gestalt:serena', 'gestalt:playwright'].includes(skill.name)
|
|
185
184
|
? skill.enabled
|
|
186
185
|
: isAlwaysAdvertisedSkill(skill)
|
|
187
186
|
? true
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
/** Shared startup budget for retained optional capabilities. */
|
|
7
|
+
export function capabilityDeadline(environment = process.env) {
|
|
8
|
+
const configured = Number(environment.GESTALT_CAPABILITY_TIMEOUT_MS);
|
|
9
|
+
return (Date.now() +
|
|
10
|
+
(Number.isInteger(configured) && configured >= 100 && configured <= 60_000 ? configured : 5_000));
|
|
11
|
+
}
|
|
12
|
+
export async function beforeDeadline(promise, deadline) {
|
|
13
|
+
let timer;
|
|
14
|
+
try {
|
|
15
|
+
return await Promise.race([
|
|
16
|
+
promise,
|
|
17
|
+
new Promise((_, reject) => {
|
|
18
|
+
timer = setTimeout(() => reject(new Error('CAPABILITY_READINESS_TIMEOUT')), Math.max(0, deadline - Date.now()));
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
if (timer)
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
import { beforeDeadline
|
|
6
|
+
import { beforeDeadline } from './capability-deadline.js';
|
|
7
7
|
import { CodexSerena } from './codex-serena.js';
|
|
8
8
|
import { RepositoryReadiness } from '../retrieval/repository-readiness.js';
|
|
9
9
|
import { withCapabilityInstructions } from './instruction-blocks.js';
|
|
10
10
|
import { prepareStartupGuidance } from './startup-guidance.js';
|
|
11
|
-
|
|
11
|
+
import { assertNoLegacyManagedConnection, retireLegacyCapabilityInstructions, } from './retired-capability-migration.js';
|
|
12
|
+
/** Compose retained capability guidance after the stable startup instructions. */
|
|
12
13
|
export class CodexCapabilities {
|
|
13
|
-
xerj;
|
|
14
14
|
serena;
|
|
15
15
|
states = new WeakMap();
|
|
16
|
-
constructor(
|
|
17
|
-
this.xerj = xerj;
|
|
16
|
+
constructor(serena) {
|
|
18
17
|
this.serena = serena;
|
|
19
18
|
}
|
|
20
19
|
async prepare(input) {
|
|
@@ -29,13 +28,15 @@ export class CodexCapabilities {
|
|
|
29
28
|
catch {
|
|
30
29
|
/* Native fallback remains available without optional guidance. */
|
|
31
30
|
}
|
|
31
|
+
await assertNoLegacyManagedConnection(native?.mcp_servers);
|
|
32
|
+
await assertNoLegacyManagedConnection(input.config.mcp_servers);
|
|
32
33
|
let startup;
|
|
33
34
|
const canComposeInstructions = native !== null || typeof input.config.developer_instructions === 'string';
|
|
34
|
-
let instructions = typeof input.config.developer_instructions === 'string'
|
|
35
|
+
let instructions = retireLegacyCapabilityInstructions(typeof input.config.developer_instructions === 'string'
|
|
35
36
|
? input.config.developer_instructions
|
|
36
37
|
: typeof native?.developer_instructions === 'string'
|
|
37
38
|
? native.developer_instructions
|
|
38
|
-
: '';
|
|
39
|
+
: '');
|
|
39
40
|
const prepareFreshStartup = async (deadline) => {
|
|
40
41
|
if (!native) {
|
|
41
42
|
startup = { status: 'unavailable', reason: 'native-config-unavailable' };
|
|
@@ -60,16 +61,11 @@ export class CodexCapabilities {
|
|
|
60
61
|
nativeConfig: native,
|
|
61
62
|
config: { ...input.config, developer_instructions: instructions },
|
|
62
63
|
};
|
|
63
|
-
// Connection verification
|
|
64
|
-
// optional XERJ probe must not spend Serena's entire connection allowance.
|
|
64
|
+
// Connection verification receives its own bounded allowance after preparation.
|
|
65
65
|
const serenaVerificationMs = Math.max(1, Math.min(5_000, input.deadline - Date.now()));
|
|
66
|
-
const
|
|
67
|
-
this.xerj.prepare(preparedInput),
|
|
68
|
-
this.serena.prepare(preparedInput),
|
|
69
|
-
]);
|
|
66
|
+
const serena = await this.serena.prepare(preparedInput);
|
|
70
67
|
if (serena.ready)
|
|
71
68
|
serena.deadline = Date.now() + serenaVerificationMs;
|
|
72
|
-
const serenaPath = input.skills.find((skill) => skill.name === 'gestalt:serena')?.path;
|
|
73
69
|
const state = {
|
|
74
70
|
get startup() {
|
|
75
71
|
return startup;
|
|
@@ -78,22 +74,12 @@ export class CodexCapabilities {
|
|
|
78
74
|
// runtime. Only the bounded instruction read/composition is repeated.
|
|
79
75
|
prepareFreshStartup: () => prepareFreshStartup(Date.now() + 5_000),
|
|
80
76
|
repositories: new RepositoryReadiness(input.cwd),
|
|
81
|
-
|
|
82
|
-
return xerj.backendPreparation;
|
|
83
|
-
},
|
|
84
|
-
deadline: Math.max(input.deadline, xerj.ready ? xerj.deadline : input.deadline, serena.ready ? serena.deadline : input.deadline),
|
|
77
|
+
deadline: Math.max(input.deadline, serena.ready ? serena.deadline : input.deadline),
|
|
85
78
|
get ready() {
|
|
86
|
-
return
|
|
79
|
+
return serena.ready;
|
|
87
80
|
},
|
|
88
81
|
get capabilities() {
|
|
89
82
|
return [
|
|
90
|
-
{
|
|
91
|
-
skillName: 'gestalt:xerj',
|
|
92
|
-
serverName: 'gestalt-xerj',
|
|
93
|
-
ready: xerj.ready,
|
|
94
|
-
diagnostic: xerj.diagnostic,
|
|
95
|
-
readiness: xerj.readiness,
|
|
96
|
-
},
|
|
97
83
|
{
|
|
98
84
|
skillName: 'gestalt:serena',
|
|
99
85
|
serverName: 'gestalt-serena',
|
|
@@ -104,28 +90,16 @@ export class CodexCapabilities {
|
|
|
104
90
|
];
|
|
105
91
|
},
|
|
106
92
|
get skillsConfig() {
|
|
107
|
-
return
|
|
108
|
-
? (serena.skillsConfig.find((candidate) => candidate.path === serenaPath) ?? entry)
|
|
109
|
-
: entry);
|
|
93
|
+
return serena.skillsConfig;
|
|
110
94
|
},
|
|
111
95
|
get config() {
|
|
112
96
|
let combined = instructions;
|
|
113
|
-
if (xerj.instructionBlock)
|
|
114
|
-
combined = withCapabilityInstructions(combined, 'xerj', xerj.instructionBlock);
|
|
115
97
|
if (serena.instructionBlock)
|
|
116
98
|
combined = withCapabilityInstructions(combined, 'serena', serena.instructionBlock);
|
|
117
99
|
const config = {
|
|
118
100
|
...input.config,
|
|
119
|
-
mcp_servers:
|
|
120
|
-
|
|
121
|
-
...serena.config.mcp_servers,
|
|
122
|
-
},
|
|
123
|
-
skills: {
|
|
124
|
-
config: [
|
|
125
|
-
...(xerj.config.skills?.config ?? []),
|
|
126
|
-
...(serena.config.skills?.config ?? []),
|
|
127
|
-
],
|
|
128
|
-
},
|
|
101
|
+
mcp_servers: serena.config.mcp_servers,
|
|
102
|
+
skills: serena.config.skills,
|
|
129
103
|
};
|
|
130
104
|
// A failed read does not establish that the native scalar is empty.
|
|
131
105
|
if (canComposeInstructions)
|
|
@@ -137,25 +111,18 @@ export class CodexCapabilities {
|
|
|
137
111
|
// verify already disables only the failed connection; runtime rebinds the composed config.
|
|
138
112
|
fallback() { },
|
|
139
113
|
};
|
|
140
|
-
this.states.set(state,
|
|
114
|
+
this.states.set(state, serena);
|
|
141
115
|
return state;
|
|
142
116
|
}
|
|
143
117
|
async verify(rpc, threadId, state) {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
118
|
+
const prepared = this.states.get(state);
|
|
119
|
+
if (!prepared)
|
|
146
120
|
return false;
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (!xerj) {
|
|
152
|
-
pair.xerj.fallback();
|
|
153
|
-
pair.xerj.diagnostic = 'connection-unavailable';
|
|
154
|
-
}
|
|
155
|
-
if (!serena) {
|
|
156
|
-
pair.serena.fallback();
|
|
157
|
-
pair.serena.diagnostic = 'connection-unavailable';
|
|
121
|
+
const verified = prepared.ready ? await this.serena.verify(rpc, threadId, prepared) : true;
|
|
122
|
+
if (!verified) {
|
|
123
|
+
prepared.fallback();
|
|
124
|
+
prepared.diagnostic = 'connection-unavailable';
|
|
158
125
|
}
|
|
159
|
-
return
|
|
126
|
+
return verified;
|
|
160
127
|
}
|
|
161
128
|
}
|
|
@@ -9,7 +9,7 @@ import { sessionScratchEnvironmentKeys } from '../scratch/child-environment.js';
|
|
|
9
9
|
import { withCapabilityInstructions } from './instruction-blocks.js';
|
|
10
10
|
import { managedPlaywrightRequestSchema } from '../../../shared/contracts/managed-playwright.js';
|
|
11
11
|
import { profileCapabilitiesSchema } from '../../../shared/contracts/profile-capabilities.js';
|
|
12
|
-
import { beforeDeadline } from '
|
|
12
|
+
import { beforeDeadline } from './capability-deadline.js';
|
|
13
13
|
import { ManagedPlaywright, playwrightServerName, playwrightTools, } from './managed-playwright.js';
|
|
14
14
|
/** One browser owner per relay root. This is a capability adapter, not a global MCP registry. */
|
|
15
15
|
export class CodexPlaywright {
|
|
@@ -370,7 +370,7 @@ export class CodexPlaywright {
|
|
|
370
370
|
return config;
|
|
371
371
|
},
|
|
372
372
|
// Each verifier already disables only its failed connection. A shared
|
|
373
|
-
// fallback must not disable a healthy browser after an
|
|
373
|
+
// fallback must not disable a healthy browser after an Serena failure.
|
|
374
374
|
fallback() { },
|
|
375
375
|
get turnInstructions() {
|
|
376
376
|
return binding.connected && current()
|
|
@@ -417,7 +417,7 @@ export class CodexPlaywright {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
catch {
|
|
420
|
-
/* Keep chat
|
|
420
|
+
/* Keep chat and Serena usable. */
|
|
421
421
|
}
|
|
422
422
|
prepared.binding.reason = 'connection-or-tools-unavailable';
|
|
423
423
|
prepared.fail();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { readFile } from 'node:fs/promises';
|
|
7
7
|
import { sessionScratchEnvironmentKeys } from '../scratch/child-environment.js';
|
|
8
|
-
import { beforeDeadline
|
|
8
|
+
import { beforeDeadline } from './capability-deadline.js';
|
|
9
9
|
import { ManagedSerena, serenaTools } from './managed-serena.js';
|
|
10
10
|
import { ReadinessEvidence } from '../retrieval/readiness-evidence.js';
|
|
11
11
|
import { withCapabilityInstructions } from './instruction-blocks.js';
|