gestalt-mobile 0.61.0 → 0.62.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.
- package/README.md +44 -7
- package/dist/client/assets/{index-Cp-JfcNd.css → index-CRnoGk06.css} +1 -1
- package/dist/client/assets/{index-DeNYHfGR.js → index-DehRk2EQ.js} +7 -3
- package/dist/client/index.html +2 -2
- package/dist/server/server/composition.contracts.js +23 -6
- package/dist/server/server/composition.js +53 -3
- package/dist/server/server/features/autopilot/application/policy.js +3 -3
- package/dist/server/server/features/plans/application/parse-model-policy.js +4 -4
- package/dist/server/server/features/plans/application/parse-supervised-plan.js +5 -0
- package/dist/server/server/features/plans/application/supervised-plan-registry.js +11 -2
- package/dist/server/server/features/plans/domain/model-policy-admission.js +14 -12
- package/dist/server/server/features/plans/domain/supervised-plan.js +4 -0
- package/dist/server/server/features/sessions/model/relay-session.js +17 -2
- package/dist/server/server/features/sessions/start-session/use-case.js +1 -0
- package/dist/server/server/features/skills/list-available/endpoint.js +1 -0
- package/dist/server/server/features/skills/list-profiles/endpoint.js +1 -0
- package/dist/server/server/features/skills/model/skill-profile.js +20 -7
- package/dist/server/server/features/skills/replace-profile/endpoint.js +6 -1
- package/dist/server/server/platform/codex/codex-playwright.js +399 -0
- package/dist/server/server/platform/codex/managed-playwright.js +150 -0
- package/dist/server/server/platform/codex/session-runtime.js +38 -7
- package/dist/server/server/platform/skills/codex-skill-catalog.js +1 -1
- package/dist/server/shared/contracts/managed-playwright.js +34 -0
- package/dist/server/shared/contracts/profile-capabilities.js +13 -0
- package/package.json +1 -1
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-DehRk2EQ.js"></script>
|
|
20
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CRnoGk06.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
23
23
|
<div id="app"></div>
|
|
@@ -916,6 +916,8 @@ describe('production composition', () => {
|
|
|
916
916
|
it.each([
|
|
917
917
|
'match',
|
|
918
918
|
'mismatch',
|
|
919
|
+
'supervisor-terra',
|
|
920
|
+
'unsupported-terra-effort',
|
|
919
921
|
'off-during-read',
|
|
920
922
|
'policy-during-read',
|
|
921
923
|
'same-plan-during-read',
|
|
@@ -962,7 +964,11 @@ describe('production composition', () => {
|
|
|
962
964
|
timer.cancelled = true;
|
|
963
965
|
};
|
|
964
966
|
},
|
|
965
|
-
},
|
|
967
|
+
}, ['supervisor-terra', 'unsupported-terra-effort'].includes(scenario)
|
|
968
|
+
? versionedText()
|
|
969
|
+
.replace(':MODEL: gpt-6.1-sol', ':MODEL: gpt-6.1-terra')
|
|
970
|
+
.replace(':REASONING_EFFORT: medium', ':REASONING_EFFORT: high')
|
|
971
|
+
: versionedText());
|
|
966
972
|
onTestFinished(() => f.app.close());
|
|
967
973
|
const actualRootThreadId = (await f.app.inject(`/api/sessions/${f.sessionId}`)).json()
|
|
968
974
|
.threadId;
|
|
@@ -980,7 +986,18 @@ describe('production composition', () => {
|
|
|
980
986
|
for (const handle of f.handles)
|
|
981
987
|
handle.respond = async (method, params) => {
|
|
982
988
|
if (method === 'model/list')
|
|
983
|
-
return
|
|
989
|
+
return ['supervisor-terra', 'unsupported-terra-effort'].includes(scenario)
|
|
990
|
+
? {
|
|
991
|
+
data: [
|
|
992
|
+
{
|
|
993
|
+
id: 'gpt-6.1-terra',
|
|
994
|
+
supportedReasoningEfforts: [
|
|
995
|
+
{ reasoningEffort: scenario === 'supervisor-terra' ? 'high' : 'medium' },
|
|
996
|
+
],
|
|
997
|
+
},
|
|
998
|
+
],
|
|
999
|
+
}
|
|
1000
|
+
: policyCatalog;
|
|
984
1001
|
if (method === 'thread/read' && params.threadId === 'child-1') {
|
|
985
1002
|
sawRead = true;
|
|
986
1003
|
if (['off-during-read', 'policy-during-read', 'same-plan-during-read'].includes(scenario))
|
|
@@ -1052,15 +1069,15 @@ describe('production composition', () => {
|
|
|
1052
1069
|
}
|
|
1053
1070
|
pendingRead.resolve({});
|
|
1054
1071
|
pendingRecovery.resolve({});
|
|
1055
|
-
if (
|
|
1072
|
+
if (['match', 'mismatch', 'supervisor-terra', 'same-plan-during-read'].includes(scenario)) {
|
|
1056
1073
|
await vi.waitFor(() => expect(childStarts).toBe(1));
|
|
1057
1074
|
const call = f.handles
|
|
1058
1075
|
.flatMap((handle) => handle.requests)
|
|
1059
1076
|
.find((call) => call.method === 'turn/start');
|
|
1060
1077
|
expect(call?.params).toMatchObject({
|
|
1061
1078
|
threadId: 'child-1',
|
|
1062
|
-
model: 'gpt-6.1-sol',
|
|
1063
|
-
effort: 'medium',
|
|
1079
|
+
model: scenario === 'supervisor-terra' ? 'gpt-6.1-terra' : 'gpt-6.1-sol',
|
|
1080
|
+
effort: scenario === 'supervisor-terra' ? 'high' : 'medium',
|
|
1064
1081
|
});
|
|
1065
1082
|
}
|
|
1066
1083
|
else {
|
|
@@ -3713,7 +3730,7 @@ describe('production composition', () => {
|
|
|
3713
3730
|
// rejected child continuation; it must never target the dead child.
|
|
3714
3731
|
expect((starts[3]?.params).threadId).not.toBe('child-1');
|
|
3715
3732
|
expect((starts[3]?.params).input?.[0]?.text).toContain('Launch task_name l1_g2 for canonical L1');
|
|
3716
|
-
expect((starts[3]?.params).input?.[0]?.text).toContain('
|
|
3733
|
+
expect((starts[3]?.params).input?.[0]?.text).toContain('The supervisor chooses the exact runtime-supported model');
|
|
3717
3734
|
// Capacity recovery is allowed only for the active root control. It
|
|
3718
3735
|
// recycles that writer but must retain the one durable g2 handoff.
|
|
3719
3736
|
const rootHandle = fixture.handles.find((candidate) => candidate.requests.some((request) => request.method === 'turn/start' &&
|
|
@@ -78,6 +78,9 @@ import { CodexXerj } from './platform/retrieval/codex-xerj.js';
|
|
|
78
78
|
import { CodexSerena } from './platform/codex/codex-serena.js';
|
|
79
79
|
import { ManagedSerena } from './platform/codex/managed-serena.js';
|
|
80
80
|
import { CodexCapabilities } from './platform/codex/codex-capabilities.js';
|
|
81
|
+
import { CodexPlaywright } from './platform/codex/codex-playwright.js';
|
|
82
|
+
import { ManagedPlaywright } from './platform/codex/managed-playwright.js';
|
|
83
|
+
import { isManagedPlaywrightCall } from '../shared/contracts/managed-playwright.js';
|
|
81
84
|
import { compileSkillOverride } from './features/skills/model/skill-profile.js';
|
|
82
85
|
import { SupervisedPlanRegistry } from './features/plans/application/supervised-plan-registry.js';
|
|
83
86
|
import { FilesystemPlanStatusSource } from './platform/plans/filesystem-plan-status-source.js';
|
|
@@ -484,6 +487,22 @@ export async function composeRelayApp(options) {
|
|
|
484
487
|
const xerj = new CodexXerj(retrievalCapability);
|
|
485
488
|
const serenaInstallation = new ManagedSerena();
|
|
486
489
|
const capabilities = new CodexCapabilities(xerj, new CodexSerena(serenaInstallation));
|
|
490
|
+
const playwright = new CodexPlaywright(new ManagedPlaywright());
|
|
491
|
+
const playwrightAuthority = (session) => {
|
|
492
|
+
const plan = supervisedPlans.findCurrent(session.id);
|
|
493
|
+
const active = plan?.steps[currentExecutableL1Index(plan)];
|
|
494
|
+
const control = autopilotStore.find(session.id);
|
|
495
|
+
return {
|
|
496
|
+
session,
|
|
497
|
+
planIdentity: supervisedPlans.identity(session.id),
|
|
498
|
+
activePlanId: active?.id ?? null,
|
|
499
|
+
declared: active?.state === 'WIP' && active.managedMcp?.includes('playwright') === true,
|
|
500
|
+
fenced: control?.stopReason === 'manualDisabled' ||
|
|
501
|
+
control?.state === 'safetyPaused' ||
|
|
502
|
+
control?.state === 'attentionRequired' ||
|
|
503
|
+
blockingInteractions(session.id).length > 0,
|
|
504
|
+
};
|
|
505
|
+
};
|
|
487
506
|
const skillCatalog = (provider, profile) => provider === 'kimi'
|
|
488
507
|
? kimiSkillCatalog
|
|
489
508
|
: new CodexSkillCatalog(profile, options.launchAppServer ?? launchCodexAppServer);
|
|
@@ -948,6 +967,15 @@ export async function composeRelayApp(options) {
|
|
|
948
967
|
const session = withPendingInteractions(sessions.find(sessionId));
|
|
949
968
|
if (!session)
|
|
950
969
|
return false;
|
|
970
|
+
if (isManagedPlaywrightCall(request)) {
|
|
971
|
+
const result = await playwright.control(playwrightAuthority(session), request.params.arguments, origin.kind === 'root' &&
|
|
972
|
+
origin.physicalThreadId === session.threadId &&
|
|
973
|
+
origin.physicalTurnId === session.activeTurnId);
|
|
974
|
+
return (runtime?.resolveServerRequest(sessionId, String(request.id), {
|
|
975
|
+
success: true,
|
|
976
|
+
contentItems: [{ type: 'inputText', text: JSON.stringify(result) }],
|
|
977
|
+
}) === true);
|
|
978
|
+
}
|
|
951
979
|
const toolCall = request.params;
|
|
952
980
|
if (request.method === 'item/tool/call' &&
|
|
953
981
|
toolCall?.tool === gestaltTestRunnerDynamicTool.name) {
|
|
@@ -1240,7 +1268,7 @@ export async function composeRelayApp(options) {
|
|
|
1240
1268
|
explicit: session.effectiveSkillSelection?.skills ?? options.explicitSkillProfile?.skills,
|
|
1241
1269
|
project: project?.skills,
|
|
1242
1270
|
});
|
|
1243
|
-
|
|
1271
|
+
const state = await capabilities.prepare({
|
|
1244
1272
|
cwd: session.workspacePath,
|
|
1245
1273
|
approvalPolicy: session.executionPolicy?.approvalPolicy ?? 'on-request',
|
|
1246
1274
|
rpc,
|
|
@@ -1250,8 +1278,25 @@ export async function composeRelayApp(options) {
|
|
|
1250
1278
|
skillsConfig: selected.skillsConfig,
|
|
1251
1279
|
start: true,
|
|
1252
1280
|
});
|
|
1281
|
+
return playwright.prepare(state, playwrightAuthority(session), {
|
|
1282
|
+
rpc,
|
|
1283
|
+
skills: catalog.skills,
|
|
1284
|
+
deadline: Date.now() + 5_000,
|
|
1285
|
+
current: () => playwrightAuthority(sessions.find(session.id) ?? session),
|
|
1286
|
+
});
|
|
1253
1287
|
},
|
|
1254
|
-
verify: (rpc, threadId, state) =>
|
|
1288
|
+
verify: async (rpc, threadId, state) => {
|
|
1289
|
+
const base = playwright.base(state);
|
|
1290
|
+
const [retrievalReady, browserReady] = await Promise.all([
|
|
1291
|
+
capabilities.verify(rpc, threadId, base),
|
|
1292
|
+
playwright.verify(rpc, threadId, state),
|
|
1293
|
+
]);
|
|
1294
|
+
return retrievalReady && browserReady;
|
|
1295
|
+
},
|
|
1296
|
+
needsResume: (session) => playwright.needsResume(playwrightAuthority(session)),
|
|
1297
|
+
release: (sessionId) => playwright.release(sessionId),
|
|
1298
|
+
observe: (sessionId, notification) => playwright.observe(sessionId, notification),
|
|
1299
|
+
bound: (state, threadId) => playwright.bound(state, threadId),
|
|
1255
1300
|
}, async (sessionId, threadId) => {
|
|
1256
1301
|
requireOrgExecutionAdmission(sessionId);
|
|
1257
1302
|
const plan = supervisedPlans.find(sessionId);
|
|
@@ -1276,9 +1321,10 @@ export async function composeRelayApp(options) {
|
|
|
1276
1321
|
assertCurrent();
|
|
1277
1322
|
const report = await executorModelEvidence.read(sessionId);
|
|
1278
1323
|
assertCurrent();
|
|
1324
|
+
const settingsChange = report && ['MODEL_MISMATCH', 'EFFORT_MISMATCH'].includes(report.code);
|
|
1279
1325
|
if (!report ||
|
|
1280
1326
|
report.child.threadId !== threadId ||
|
|
1281
|
-
report.configuration === 'mismatch' ||
|
|
1327
|
+
(report.configuration === 'mismatch' && !settingsChange) ||
|
|
1282
1328
|
[
|
|
1283
1329
|
'CONTROLLER_BINDING_INVALID',
|
|
1284
1330
|
'CONTEXT_CHANGED',
|
|
@@ -1286,6 +1332,10 @@ export async function composeRelayApp(options) {
|
|
|
1286
1332
|
'OBSERVATION_CHANGED',
|
|
1287
1333
|
].includes(report.code))
|
|
1288
1334
|
throw new Error(`EXECUTOR_POLICY_BLOCKED:${report?.code ?? 'CHILD_BINDING_UNKNOWN'}`);
|
|
1335
|
+
// The supervisor's current L1 choice is applied at this safe turn
|
|
1336
|
+
// boundary, including a deliberate change from the child's old model.
|
|
1337
|
+
await runtime.validateExecutorPolicy(sessionId, report.requested);
|
|
1338
|
+
assertCurrent();
|
|
1289
1339
|
return { ...report.requested, assertCurrent };
|
|
1290
1340
|
})
|
|
1291
1341
|
: null;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { currentExecutableL1Index, } from '../../plans/domain/supervised-plan.js';
|
|
7
7
|
import { parseOrgPlanAgentIdentity } from '../../../../shared/org-plan-position.js';
|
|
8
|
-
export const AUTOPILOT_PROMPT_VERSION = '
|
|
8
|
+
export const AUTOPILOT_PROMPT_VERSION = 'v14';
|
|
9
9
|
export const AUTOPILOT_CONTINUATION_PROMPT = 'Inspect the active supervised Org Plan. Refer to every L1 as L<a> and each nested L2 as L<a>.<b>, using one-based positions. Spawn exactly one executor per L1 and pass the exact literal task_name l<a>: l1 for L1, l2 for L2, and so on. Never create an L2-specific task name or append a title, role, nickname, plan name, or generated label. A validated DONE L2 and an accepted L1 are mandatory answer boundaries. The corresponding gestalt_org_plan_checkpoint call must be the last tool call of that root turn: immediately emit exactly one boundary final and end the turn, without followup_task, review, executor launch, or later milestone work. An accepted L1 always ends the root turn with a chat answer: never continue into the next L1 or emit post-acceptance documentation as commentary. Roll up commentary, files, verification, and commands since the previous boundary into that one answer; all later milestone activity belongs to a new root turn. On this later Autopilot turn, resume the same executor after an L2 boundary or launch exactly one fresh canonical executor for the next L1 after an accepted-L1 boundary. Treat a status question as an interruption: answer briefly, then perform the applicable continuation in the same turn. Before sending any blocker response or yielding because progress cannot continue safely, call gestalt_org_plan_attention for the matching decision-table blocker; never rely on blocker prose as the signal. When explicit human permission is required for a physical executor replacement, include executorReplacement with the exact canonicalTaskName; Mobile alone computes and persists the physical generation. Do not call attention for routine progress or a recoverable failure. Before yielding for known long work, call gestalt_autopilot_wait_lease version 2 with relevant observable wake conditions and a bounded maxWaitMs; it is one episode, so reassess before registering another in a later turn. Yield only when its response contains accepted:true; accepted:false means no continuation was registered and requires same-turn supervision. For GitHub PR CI, start an owned gh pr checks --watch process and lease processExited plus processResultAvailable while it runs. Timestamp watcher state-change and terminal observations in UTC; distinguish observation time from upstream updated_at and process exit time. When the Autopilot probe is active, register the compatible wait lease, declare genuine attention, or immediately do actionable work; never acknowledge waiting in prose. Do not send a status-only response.';
|
|
10
10
|
export const AUTOPILOT_EXECUTOR_CONTINUATION_PROMPT = 'Continue the same assigned Org L1 from its durable state. A prior turn ending did not complete the objective. Consume any supplied process result and take the next legal L2 action. Whenever an L2 reaches DONE, return its concise structured evidence and end the executor turn so the root can publish that mandatory answer boundary. Also report at the L1 review boundary or through structured attention.';
|
|
11
11
|
/** Builds a physical launch instruction while keeping durable L1 identity canonical. */
|
|
@@ -13,10 +13,10 @@ export function autopilotExecutorLaunchPrompt(identity, plan) {
|
|
|
13
13
|
const policy = plan?.steps.find((_, index) => `L${index + 1}` === identity.canonicalPosition)?.modelPolicy;
|
|
14
14
|
const launch = policy
|
|
15
15
|
? `Launch task_name ${identity.taskName} for canonical ${identity.canonicalPosition}, preferring agent_type default, fork_turns none, explicit model ${policy.model} and reasoning_effort ${policy.reasoningEffort}. If explicit overrides are unavailable, use the verified fixed org-plan-executor role only when both pins exactly match ${policy.model}/${policy.reasoningEffort}, omitting ineffective overrides. Load the executor duties and full L1 assignment from the Org-plan launch contract. Validate actual host support and sandbox/approval inheritance before spawning; unsupported routes are capability blockers. Assurance is configured compatibility: unavailable runtime metadata remains unknown and does not require repeated human approval. Reject observed settings mismatches; never call requested settings observed or runtime-enforced. Preserve one writer, independent review, checkpoint and terminal review gates.`
|
|
16
|
-
: `Launch task_name ${identity.taskName} for canonical ${identity.canonicalPosition}
|
|
16
|
+
: `Launch task_name ${identity.taskName} for canonical ${identity.canonicalPosition}. The supervisor chooses the exact runtime-supported model and reasoning effort for this L1. For an explicit choice use agent_type default, fork_turns none, explicit model and reasoning_effort, and supply the executor duties and full assignment. The configured org-plan-executor role is a fallback only when no L1 choice is supplied; omit ineffective overrides on a fixed role. Retain canonical identity, permissions and review gates.`;
|
|
17
17
|
if (identity.generation === 1)
|
|
18
18
|
return `${AUTOPILOT_CONTINUATION_PROMPT} ${launch}`;
|
|
19
|
-
return `${AUTOPILOT_CONTINUATION_PROMPT} ${launch} This exact replacement generation ${identity.generation} is durably authorized by Mobile; do not infer another generation from this prompt or the roster; the durable ${identity.canonicalTaskName} slot may remain reserved. Do not reuse that task_name or
|
|
19
|
+
return `${AUTOPILOT_CONTINUATION_PROMPT} ${launch} This exact replacement generation ${identity.generation} is durably authorized by Mobile; do not infer another generation from this prompt or the roster; the durable ${identity.canonicalTaskName} slot may remain reserved. Do not reuse that task_name or treat a model change as replacement authorization. Apply updated model/effort only at a safe turn boundary. Interrupt the previous physical executor if it is still running, then spawn the authorized ${identity.taskName}. Transfer sole ${identity.canonicalPosition} ownership and continue from its durable Org Plan and worktree state.`;
|
|
20
20
|
}
|
|
21
21
|
export const defaultAutopilotPolicy = Object.freeze({
|
|
22
22
|
quiescenceMs: 1_000,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
import { validPlanModel, validPlanEffort } from '../domain/supervised-plan.js';
|
|
7
7
|
const required = [
|
|
8
8
|
'MODEL',
|
|
9
9
|
'REASONING_EFFORT',
|
|
@@ -37,11 +37,11 @@ export function parseModelPolicy(properties, level, version) {
|
|
|
37
37
|
invalid();
|
|
38
38
|
const model = properties.get('MODEL');
|
|
39
39
|
const reasoningEffort = properties.get('REASONING_EFFORT');
|
|
40
|
-
if (!
|
|
40
|
+
if (!validPlanModel(model) || !validPlanEffort(reasoningEffort))
|
|
41
41
|
invalid();
|
|
42
42
|
const rawFallbacks = properties.get('MODEL_FALLBACKS');
|
|
43
43
|
const allowedFallbacks = rawFallbacks === 'none' ? [] : rawFallbacks.split(' ');
|
|
44
|
-
if (allowedFallbacks.some((id) => !
|
|
44
|
+
if (allowedFallbacks.some((id) => !validPlanModel(id) || id === model) ||
|
|
45
45
|
new Set(allowedFallbacks).size !== allowedFallbacks.length)
|
|
46
46
|
invalid();
|
|
47
47
|
let necessity = null;
|
|
@@ -49,7 +49,7 @@ export function parseModelPolicy(properties, level, version) {
|
|
|
49
49
|
if (exception.some((key) => properties.has(key)))
|
|
50
50
|
invalid();
|
|
51
51
|
}
|
|
52
|
-
else {
|
|
52
|
+
else if (exception.some((key) => properties.has(key))) {
|
|
53
53
|
if (exception.slice(0, 5).some((key) => !properties.get(key)?.trim()) ||
|
|
54
54
|
!['unresolved-correctness', 'specific-reasoning'].includes(properties.get('EFFORT_NECESSITY_KIND')) ||
|
|
55
55
|
(reasoningEffort === 'xhigh' && !properties.get('SCOPE_REASSESSMENT')?.trim()))
|
|
@@ -191,6 +191,9 @@ function makeStep(heading) {
|
|
|
191
191
|
const measurement = measurementFor(heading);
|
|
192
192
|
if (!description || measurement === null)
|
|
193
193
|
return null;
|
|
194
|
+
const managed = heading.descriptions.get('Managed MCP');
|
|
195
|
+
if (managed !== undefined && (heading.level !== 1 || managed !== 'playwright'))
|
|
196
|
+
return null;
|
|
194
197
|
if (heading.level === 1) {
|
|
195
198
|
const reviewStatus = heading.properties.get('REVIEW_STATUS');
|
|
196
199
|
const skills = heading.properties.get('SKILLS');
|
|
@@ -204,6 +207,7 @@ function makeStep(heading) {
|
|
|
204
207
|
priority: heading.priority,
|
|
205
208
|
reviewStatus: reviewStatus,
|
|
206
209
|
skills: skills.split(/\s+/).filter(Boolean),
|
|
210
|
+
...(managed === 'playwright' ? { managedMcp: ['playwright'] } : {}),
|
|
207
211
|
description,
|
|
208
212
|
...(measurement ? { measurement } : {}),
|
|
209
213
|
children: [],
|
|
@@ -399,6 +403,7 @@ function freezePlan(plan) {
|
|
|
399
403
|
const freezeStep = (step) => Object.freeze({
|
|
400
404
|
...step,
|
|
401
405
|
...(step.skills ? { skills: Object.freeze([...step.skills]) } : {}),
|
|
406
|
+
...(step.managedMcp ? { managedMcp: Object.freeze(['playwright']) } : {}),
|
|
402
407
|
description: Object.freeze({ ...step.description }),
|
|
403
408
|
children: Object.freeze(step.children.map(freezeStep)),
|
|
404
409
|
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
/** Retains at most one validated plan projection for each relay session. */
|
|
7
7
|
export class SupervisedPlanRegistry {
|
|
8
8
|
policyUnavailable = new Set();
|
|
9
|
+
currentUnavailable = new Set();
|
|
9
10
|
plans = new Map();
|
|
10
11
|
accept(sessionId, update) {
|
|
11
12
|
if (update.kind === 'updated') {
|
|
@@ -15,9 +16,12 @@ export class SupervisedPlanRegistry {
|
|
|
15
16
|
publicationReason: update.reason,
|
|
16
17
|
});
|
|
17
18
|
this.policyUnavailable.delete(sessionId);
|
|
19
|
+
this.currentUnavailable.delete(sessionId);
|
|
18
20
|
}
|
|
19
|
-
else
|
|
20
|
-
this.
|
|
21
|
+
else {
|
|
22
|
+
this.currentUnavailable.add(sessionId);
|
|
23
|
+
if (update.modelPolicyRequired || this.find(sessionId)?.modelPolicyVersion === 1)
|
|
24
|
+
this.policyUnavailable.add(sessionId);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
/** An invalid mandatory publication cannot silently reuse a legacy execution policy. */
|
|
@@ -31,6 +35,10 @@ export class SupervisedPlanRegistry {
|
|
|
31
35
|
find(sessionId) {
|
|
32
36
|
return this.plans.get(sessionId)?.plan ?? null;
|
|
33
37
|
}
|
|
38
|
+
/** Retained display state cannot authorize a capability after an invalid publication. */
|
|
39
|
+
findCurrent(sessionId) {
|
|
40
|
+
return this.currentUnavailable.has(sessionId) ? null : this.find(sessionId);
|
|
41
|
+
}
|
|
34
42
|
identity(sessionId) {
|
|
35
43
|
return this.plans.get(sessionId)?.identity ?? null;
|
|
36
44
|
}
|
|
@@ -40,5 +48,6 @@ export class SupervisedPlanRegistry {
|
|
|
40
48
|
clear(sessionId) {
|
|
41
49
|
this.plans.delete(sessionId);
|
|
42
50
|
this.policyUnavailable.delete(sessionId);
|
|
51
|
+
this.currentUnavailable.delete(sessionId);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
+
import { validPlanModel, validPlanEffort } from './supervised-plan.js';
|
|
6
7
|
/** Scope is automatic Org execution, not the supervisor's manual model selection or repair input. */
|
|
7
8
|
export function assessModelPolicyAdmission(plan, status = 'legacy') {
|
|
8
9
|
const blocked = (reason) => ({
|
|
@@ -23,23 +24,24 @@ export function assessModelPolicyAdmission(plan, status = 'legacy') {
|
|
|
23
24
|
return blocked('POLICY_VERSION_UNSUPPORTED');
|
|
24
25
|
if (!plan?.steps.length || plan.steps.some((step) => step.modelPolicy?.version !== 1))
|
|
25
26
|
return blocked('POLICY_FIELDS_INVALID');
|
|
26
|
-
if (plan.steps.some((step) => !
|
|
27
|
+
if (plan.steps.some((step) => !validPlanModel(step.modelPolicy.model)))
|
|
27
28
|
return blocked('MODEL_PROHIBITED');
|
|
28
29
|
if (plan.steps.some((step) => {
|
|
29
30
|
const policy = step.modelPolicy;
|
|
30
31
|
const necessity = policy.necessity;
|
|
31
|
-
return (!
|
|
32
|
+
return (!validPlanEffort(policy.reasoningEffort) ||
|
|
32
33
|
(policy.reasoningEffort === 'medium'
|
|
33
34
|
? necessity !== null
|
|
34
|
-
:
|
|
35
|
-
!
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
: necessity !== null &&
|
|
36
|
+
(!necessity ||
|
|
37
|
+
!['unresolved-correctness', 'specific-reasoning'].includes(necessity.kind) ||
|
|
38
|
+
![
|
|
39
|
+
necessity.whyMediumInadequate,
|
|
40
|
+
necessity.evidence,
|
|
41
|
+
necessity.affectedScope,
|
|
42
|
+
necessity.returnToMedium,
|
|
43
|
+
...(policy.reasoningEffort === 'xhigh' ? [necessity.scopeReassessment] : []),
|
|
44
|
+
].every((value) => typeof value === 'string' && value.trim()))));
|
|
43
45
|
}))
|
|
44
46
|
return blocked('EFFORT_UNSUPPORTED');
|
|
45
47
|
const assurance = plan.modelPolicyAssurance ?? 'configured';
|
|
@@ -52,7 +54,7 @@ export function assessModelPolicyAdmission(plan, status = 'legacy') {
|
|
|
52
54
|
scope: 'configured',
|
|
53
55
|
assurance: 'configured',
|
|
54
56
|
runtimeEnforcement: false,
|
|
55
|
-
action: 'Compatibility mode: validate
|
|
57
|
+
action: 'Compatibility mode: validate the supervisor-selected L1 settings against the runtime catalog and preserve controller-owned executor identity. Apply changed settings at the next safe turn, never repin them to session defaults. Missing observations remain unknown; no runtime attestation is claimed.',
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
export class ModelPolicyAdmissionError extends Error {
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
+
export const validPlanModel = (value) => typeof value === 'string' &&
|
|
7
|
+
value !== 'none' &&
|
|
8
|
+
/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,63}$/.test(value);
|
|
9
|
+
export const validPlanEffort = (value) => typeof value === 'string' && /^[a-z][a-z0-9_-]{0,23}$/.test(value);
|
|
6
10
|
/** Suspended work is a barrier: no later implementation may be selected. */
|
|
7
11
|
export function currentExecutableL1Index(plan) {
|
|
8
12
|
const boundary = plan.steps.findIndex((step) => step.state === 'SUSPENDED');
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { DomainError } from './errors.js';
|
|
7
|
+
import { profileCapabilitiesSchema, } from '../../../../shared/contracts/profile-capabilities.js';
|
|
7
8
|
import { createSkillSelection, normalizeSkillProfileName, } from '../../skills/model/skill-profile.js';
|
|
8
9
|
import { interactionId, profileName, sessionId, threadId, turnId, workspaceId, workspacePath, } from './value-objects.js';
|
|
9
10
|
/** A durable thread can be read even when this relay has no live writer. */
|
|
@@ -37,6 +38,9 @@ export function createSessionExecutionPolicy(input) {
|
|
|
37
38
|
export function createEffectiveSkillSelection(input) {
|
|
38
39
|
const warnings = (input.warnings ?? []).filter((warning) => typeof warning === 'string' && warning.length > 0);
|
|
39
40
|
return {
|
|
41
|
+
...(input.capabilities === undefined
|
|
42
|
+
? {}
|
|
43
|
+
: { capabilities: profileCapabilitiesSchema.parse(input.capabilities) }),
|
|
40
44
|
...(input.selectedProfileName === undefined
|
|
41
45
|
? {}
|
|
42
46
|
: { selectedProfileName: normalizeSkillProfileName(input.selectedProfileName) }),
|
|
@@ -62,7 +66,12 @@ export class RelaySession {
|
|
|
62
66
|
...(input.model === undefined ? {} : { model: input.model }),
|
|
63
67
|
...(input.modelSettings === undefined ? {} : { modelSettings: { ...input.modelSettings } }),
|
|
64
68
|
...(input.branch === undefined ? {} : { branch: input.branch }),
|
|
65
|
-
effectiveSkillSelection: createEffectiveSkillSelection(
|
|
69
|
+
effectiveSkillSelection: createEffectiveSkillSelection({
|
|
70
|
+
...input.effectiveSkillSelection,
|
|
71
|
+
...(input.provider === 'kimi' && input.effectiveSkillSelection.capabilities !== undefined
|
|
72
|
+
? { capabilities: { playwright: { enabled: false } } }
|
|
73
|
+
: {}),
|
|
74
|
+
}),
|
|
66
75
|
executionPolicy: createSessionExecutionPolicy(input),
|
|
67
76
|
threadId: null,
|
|
68
77
|
state: 'starting',
|
|
@@ -180,7 +189,13 @@ function copy(snapshot) {
|
|
|
180
189
|
...(snapshot.effectiveSkillSelection === undefined
|
|
181
190
|
? {}
|
|
182
191
|
: {
|
|
183
|
-
effectiveSkillSelection: createEffectiveSkillSelection(
|
|
192
|
+
effectiveSkillSelection: createEffectiveSkillSelection({
|
|
193
|
+
...snapshot.effectiveSkillSelection,
|
|
194
|
+
...(snapshot.provider === 'kimi' &&
|
|
195
|
+
snapshot.effectiveSkillSelection.capabilities !== undefined
|
|
196
|
+
? { capabilities: { playwright: { enabled: false } } }
|
|
197
|
+
: {}),
|
|
198
|
+
}),
|
|
184
199
|
}),
|
|
185
200
|
pendingInteractions: snapshot.pendingInteractions.map((item) => ({ ...item })),
|
|
186
201
|
};
|
|
@@ -45,6 +45,7 @@ export async function startSession(input, deps) {
|
|
|
45
45
|
const sourceProfile = selectedProfile ?? projectProfile;
|
|
46
46
|
const reconciledSkills = reconcileSkillSelectionSnapshot(catalog.skills, sourceProfile?.skills);
|
|
47
47
|
effectiveSkillSelection = {
|
|
48
|
+
...(sourceProfile?.capabilities ? { capabilities: sourceProfile.capabilities } : {}),
|
|
48
49
|
...(selectedProfile ? { selectedProfileName: selectedProfile.name } : {}),
|
|
49
50
|
skills: [
|
|
50
51
|
...reconciledSkills.skills.map((skill) => ({
|
|
@@ -39,6 +39,7 @@ export function registerListAvailableSkills(app, deps) {
|
|
|
39
39
|
const skills = applySkillSelectionSnapshot(discovered.skills, project?.skills);
|
|
40
40
|
return {
|
|
41
41
|
source: project ? 'project' : 'native',
|
|
42
|
+
...(project?.capabilities ? { capabilities: project.capabilities } : {}),
|
|
42
43
|
errors: discovered.errors.map(({ message }) => ({ message })),
|
|
43
44
|
skills: skills
|
|
44
45
|
.filter((skill) => !isAlwaysAdvertisedSkill(skill) && skill.name !== 'gestalt:xerj')
|
|
@@ -7,6 +7,7 @@ import { isAbsolute, normalize } from 'node:path';
|
|
|
7
7
|
import { parseDocument, stringify } from 'yaml';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { SkillProfileError } from './errors.js';
|
|
10
|
+
import { profileCapabilitiesSchema, } from '../../../../shared/contracts/profile-capabilities.js';
|
|
10
11
|
const profileNamePattern = /^[a-z0-9](?:[a-z0-9-]{0,62})?$/;
|
|
11
12
|
/**
|
|
12
13
|
* A path-keyed skill record. `name` is display metadata only: a skill's path is
|
|
@@ -61,18 +62,26 @@ export const availableSkillSchema = z
|
|
|
61
62
|
*/
|
|
62
63
|
export function isAlwaysAdvertisedSkill(skill) {
|
|
63
64
|
return (isGestaltSkillName(skill.name) &&
|
|
64
|
-
(!['gestalt:xerj', 'gestalt:serena'].includes(skill.name) ||
|
|
65
|
+
(!['gestalt:xerj', 'gestalt:serena', 'gestalt:playwright'].includes(skill.name) ||
|
|
66
|
+
skill.enabled));
|
|
65
67
|
}
|
|
66
68
|
export function isGestaltSkillName(name) {
|
|
67
69
|
return name.startsWith('gestalt:');
|
|
68
70
|
}
|
|
69
|
-
const
|
|
71
|
+
const legacyProfileDocumentSchema = z
|
|
70
72
|
.object({
|
|
71
73
|
version: z.literal(1),
|
|
72
74
|
name: z.string().min(1),
|
|
73
75
|
skills: z.array(skillSelectionEntrySchema),
|
|
74
76
|
})
|
|
75
77
|
.strict();
|
|
78
|
+
const profileDocumentSchema = z.discriminatedUnion('version', [
|
|
79
|
+
legacyProfileDocumentSchema,
|
|
80
|
+
legacyProfileDocumentSchema.extend({
|
|
81
|
+
version: z.literal(2),
|
|
82
|
+
capabilities: profileCapabilitiesSchema,
|
|
83
|
+
}),
|
|
84
|
+
]);
|
|
76
85
|
/**
|
|
77
86
|
* Normalize a profile name before using it in its global filename. The output
|
|
78
87
|
* is deliberately narrow so a profile name can never become a path traversal.
|
|
@@ -164,7 +173,7 @@ export function applySkillSelectionSnapshot(discovered, selection) {
|
|
|
164
173
|
const enabledByPath = new Map(createSkillSelection(selection).map((entry) => [entry.path, entry.enabled]));
|
|
165
174
|
return catalog.map((skill) => ({
|
|
166
175
|
...skill,
|
|
167
|
-
enabled: ['gestalt:xerj', 'gestalt:serena'].includes(skill.name)
|
|
176
|
+
enabled: ['gestalt:xerj', 'gestalt:serena', 'gestalt:playwright'].includes(skill.name)
|
|
168
177
|
? skill.enabled
|
|
169
178
|
: isAlwaysAdvertisedSkill(skill)
|
|
170
179
|
? true
|
|
@@ -218,16 +227,20 @@ export function compileSkillOverride(input) {
|
|
|
218
227
|
}
|
|
219
228
|
/** Construct the single profile contract shared by global and project YAML files. */
|
|
220
229
|
export function createSkillProfile(input) {
|
|
230
|
+
const capabilities = input.capabilities === undefined
|
|
231
|
+
? undefined
|
|
232
|
+
: profileCapabilitiesSchema.parse(input.capabilities);
|
|
221
233
|
return {
|
|
222
|
-
version: 1,
|
|
234
|
+
version: capabilities === undefined ? 1 : 2,
|
|
223
235
|
name: normalizeSkillProfileName(input.name),
|
|
236
|
+
...(capabilities === undefined ? {} : { capabilities }),
|
|
224
237
|
// Gestalt skills are mandatory thread infrastructure. Legacy profiles are
|
|
225
238
|
// normalized on read so they cannot pin a stale plugin-cache version or
|
|
226
239
|
// expose a meaningless enable/disable control in the editor.
|
|
227
240
|
skills: createSkillSelection(input.skills.filter((skill) => !isGestaltSkillName(skill.name))),
|
|
228
241
|
};
|
|
229
242
|
}
|
|
230
|
-
/**
|
|
243
|
+
/** Import strict versioned YAML without silently dropping unknown fields. */
|
|
231
244
|
export function parseSkillProfileYaml(source) {
|
|
232
245
|
const document = parseDocument(source, { prettyErrors: false, strict: true, uniqueKeys: true });
|
|
233
246
|
if (document.errors.length > 0) {
|
|
@@ -239,8 +252,8 @@ export function parseSkillProfileYaml(source) {
|
|
|
239
252
|
}
|
|
240
253
|
return createSkillProfile(parsed.data);
|
|
241
254
|
}
|
|
242
|
-
/**
|
|
255
|
+
/** Export deterministic YAML, retaining explicit capability choices. */
|
|
243
256
|
export function serializeSkillProfileYaml(profile) {
|
|
244
257
|
const canonical = createSkillProfile(profile);
|
|
245
|
-
return stringify(
|
|
258
|
+
return stringify(canonical);
|
|
246
259
|
}
|
|
@@ -7,13 +7,18 @@ import { z } from 'zod';
|
|
|
7
7
|
import { createSkillProfile, normalizeSkillProfileName } from '../model/skill-profile.js';
|
|
8
8
|
import { SkillProfileError } from '../model/errors.js';
|
|
9
9
|
import { problem } from '../../../platform/http/problem.js';
|
|
10
|
-
|
|
10
|
+
import { profileCapabilitiesSchema } from '../../../../shared/contracts/profile-capabilities.js';
|
|
11
|
+
const legacyRequestSchema = z
|
|
11
12
|
.object({
|
|
12
13
|
version: z.literal(1),
|
|
13
14
|
name: z.string(),
|
|
14
15
|
skills: z.array(z.object({ name: z.string(), path: z.string(), enabled: z.boolean() }).strict()),
|
|
15
16
|
})
|
|
16
17
|
.strict();
|
|
18
|
+
const requestSchema = z.discriminatedUnion('version', [
|
|
19
|
+
legacyRequestSchema,
|
|
20
|
+
legacyRequestSchema.extend({ version: z.literal(2), capabilities: profileCapabilitiesSchema }),
|
|
21
|
+
]);
|
|
17
22
|
export function registerReplaceSkillProfile(app, deps) {
|
|
18
23
|
app.put('/api/skill-profiles/:name', { bodyLimit: 64 * 1024 }, async (request, reply) => {
|
|
19
24
|
const body = requestSchema.safeParse(request.body);
|