gestalt-mobile 0.49.7 → 0.50.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 +12 -3
- package/dist/client/assets/{index-BxgQCQyH.js → index-IkBR-U3-.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/server/server/composition.contracts.js +234 -17
- package/dist/server/server/composition.js +16 -39
- package/dist/server/server/features/autopilot/application/policy.js +27 -2
- package/dist/server/server/features/autopilot/application/service.js +97 -13
- package/dist/server/server/features/autopilot/domain/supervised-lifecycle.js +11 -2
- package/dist/server/server/features/control-plane-trace/export-trace.js +1 -0
- package/dist/server/server/features/org-plan-checkpoint/application/validate.js +3 -1
- package/dist/server/server/features/plans/application/parse-supervised-plan.js +45 -2
- package/dist/server/server/features/plans/domain/supervised-plan.js +12 -1
- package/dist/server/server/features/self-debug/create-session.js +5 -9
- package/dist/server/server/features/sessions/start-session/use-case.js +27 -24
- package/dist/server/server/platform/codex/codex-process-launcher.js +3 -2
- package/dist/server/server/platform/codex/session-runtime.js +5 -1
- package/dist/server/server/platform/kimi/kimi-web-server-manager.js +1 -0
- package/dist/server/server/platform/persistence/migrate.js +1 -0
- package/dist/server/server/platform/persistence/retention.js +4 -3
- package/dist/server/server/platform/persistence/sqlite-event-journal.js +14 -4
- package/dist/server/server/platform/plans/org-plan-capabilities.js +7 -0
- package/dist/server/server/platform/plans/plan-measurement-command.js +2 -0
- package/dist/server/server/platform/plans/plan-measurement-refresh.js +4 -1
- package/dist/server/shared/contracts/autopilot-audit.js +2 -2
- package/gestalt-supervision-capabilities.json +2 -1
- package/package.json +2 -1
|
@@ -2388,9 +2388,10 @@ describe('production composition', () => {
|
|
|
2388
2388
|
await fixture.app.close();
|
|
2389
2389
|
});
|
|
2390
2390
|
it.each([
|
|
2391
|
-
['transport-lost', new Error('CODEX_CONNECTION_LOST')],
|
|
2392
|
-
['ambiguous RPC failure', new CodexJsonRpcError(-32603, 'internal error')],
|
|
2393
|
-
|
|
2391
|
+
['transport-lost', new Error('CODEX_CONNECTION_LOST'), false],
|
|
2392
|
+
['ambiguous RPC failure', new CodexJsonRpcError(-32603, 'internal error'), false],
|
|
2393
|
+
['manual Off after RPC failure', new CodexJsonRpcError(-32603, 'internal error'), true],
|
|
2394
|
+
])('production recovers through the root after %s without replaying or replacing the executor', async (_scenario, failure, disableBeforeRecovery) => {
|
|
2394
2395
|
const timers = [];
|
|
2395
2396
|
const fixture = await createProductionAutopilotFixture({
|
|
2396
2397
|
autopilotActivity: (sessionId) => {
|
|
@@ -2449,16 +2450,27 @@ describe('production composition', () => {
|
|
|
2449
2450
|
await vi.waitFor(() => expect(fixture.handles
|
|
2450
2451
|
.flatMap((candidate) => candidate.requests)
|
|
2451
2452
|
.filter((request) => request.method === 'turn/start')).toHaveLength(1));
|
|
2452
|
-
// Drive the bounded reinspection once: the durable issued command blocks replay.
|
|
2453
|
-
const refresh = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2454
|
-
refresh.fired = true;
|
|
2455
|
-
refresh.callback();
|
|
2456
|
-
await Promise.resolve();
|
|
2457
|
-
await Promise.resolve();
|
|
2458
2453
|
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2454
|
+
const operationQuery = database.prepare("SELECT payload_json FROM session_events WHERE session_id = ? AND type = 'autopilot.operation-failed' ORDER BY sequence LIMIT 1");
|
|
2455
|
+
for (let attempt = 0; attempt < 8 && !operationQuery.get(fixture.sessionId); attempt++) {
|
|
2456
|
+
const pending = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2457
|
+
expect(pending).toBeDefined();
|
|
2458
|
+
pending.fired = true;
|
|
2459
|
+
pending.callback();
|
|
2460
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2461
|
+
}
|
|
2462
|
+
await vi.waitFor(() => expect(operationQuery.get(fixture.sessionId)).toBeDefined());
|
|
2463
|
+
const operation = operationQuery.get(fixture.sessionId);
|
|
2459
2464
|
const lifecycle = database
|
|
2460
2465
|
.prepare('SELECT lifecycle_json FROM autopilot_sessions WHERE session_id = ?')
|
|
2461
2466
|
.get(fixture.sessionId);
|
|
2467
|
+
if (failure instanceof CodexJsonRpcError)
|
|
2468
|
+
expect(JSON.parse(operation.payload_json)).toMatchObject({
|
|
2469
|
+
kind: 'executorResume',
|
|
2470
|
+
rpcCode: -32603,
|
|
2471
|
+
});
|
|
2472
|
+
else
|
|
2473
|
+
expect(JSON.parse(operation.payload_json)).not.toHaveProperty('rpcCode');
|
|
2462
2474
|
const replacements = database
|
|
2463
2475
|
.prepare("SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = 'autopilot.executor-replacement-scheduled'")
|
|
2464
2476
|
.get(fixture.sessionId);
|
|
@@ -2469,9 +2481,36 @@ describe('production composition', () => {
|
|
|
2469
2481
|
},
|
|
2470
2482
|
});
|
|
2471
2483
|
expect(replacements.count).toBe(0);
|
|
2472
|
-
|
|
2484
|
+
const starts = () => fixture.handles
|
|
2473
2485
|
.flatMap((candidate) => candidate.requests)
|
|
2474
|
-
.filter((request) => request.method === 'turn/start')
|
|
2486
|
+
.filter((request) => request.method === 'turn/start');
|
|
2487
|
+
const rootStarts = () => starts().filter((request) => request.params.threadId !== 'child-1');
|
|
2488
|
+
if (disableBeforeRecovery) {
|
|
2489
|
+
const pending = timers.filter((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2490
|
+
await fixture.app.inject({
|
|
2491
|
+
method: 'PUT',
|
|
2492
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2493
|
+
payload: { enabled: false },
|
|
2494
|
+
});
|
|
2495
|
+
for (const timer of pending)
|
|
2496
|
+
timer.callback();
|
|
2497
|
+
}
|
|
2498
|
+
else {
|
|
2499
|
+
for (let attempt = 0; attempt < 8 && rootStarts().length === 0; attempt++) {
|
|
2500
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2501
|
+
expect(timer).toBeDefined();
|
|
2502
|
+
timer.fired = true;
|
|
2503
|
+
timer.callback();
|
|
2504
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2505
|
+
}
|
|
2506
|
+
await vi.waitFor(() => expect(rootStarts()).toHaveLength(1));
|
|
2507
|
+
expect(rootStarts()[0].params.input[0].text).toContain('unconfirmed outcome');
|
|
2508
|
+
}
|
|
2509
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
2510
|
+
timer.callback();
|
|
2511
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2512
|
+
expect(starts().filter((request) => request.params.threadId === 'child-1')).toHaveLength(1);
|
|
2513
|
+
expect(rootStarts()).toHaveLength(disableBeforeRecovery ? 0 : 1);
|
|
2475
2514
|
await fixture.app.close();
|
|
2476
2515
|
});
|
|
2477
2516
|
it.each([
|
|
@@ -2642,6 +2681,155 @@ describe('production composition', () => {
|
|
|
2642
2681
|
await Promise.resolve();
|
|
2643
2682
|
expect(starts()).toHaveLength(1);
|
|
2644
2683
|
});
|
|
2684
|
+
it.each([false, true])('continues past a disconnected auxiliary helper after L2 completion, reported=%s', async (reported) => {
|
|
2685
|
+
const handles = [];
|
|
2686
|
+
const launch = liveAppServer(handles);
|
|
2687
|
+
const timers = [];
|
|
2688
|
+
const fixture = await createProductionAutopilotFixture({
|
|
2689
|
+
activitySchedule: () => () => { },
|
|
2690
|
+
autopilotSchedule: (callback) => {
|
|
2691
|
+
const timer = { callback, cancelled: false, fired: false };
|
|
2692
|
+
timers.push(timer);
|
|
2693
|
+
return () => {
|
|
2694
|
+
timer.cancelled = true;
|
|
2695
|
+
};
|
|
2696
|
+
},
|
|
2697
|
+
launchAppServer: () => {
|
|
2698
|
+
const server = launch();
|
|
2699
|
+
handles.at(-1).respond = (method) => {
|
|
2700
|
+
if (method === 'thread/list')
|
|
2701
|
+
return {
|
|
2702
|
+
data: [
|
|
2703
|
+
{
|
|
2704
|
+
id: 'old-helper',
|
|
2705
|
+
status: { type: 'notLoaded' },
|
|
2706
|
+
source: {
|
|
2707
|
+
subAgent: { thread_spawn: { agent_path: '/root/editorial_review' } },
|
|
2708
|
+
},
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
id: 'previous-executor',
|
|
2712
|
+
status: { type: 'idle' },
|
|
2713
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l1' } } },
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
id: 'executor',
|
|
2717
|
+
status: { type: 'idle' },
|
|
2718
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l2' } } },
|
|
2719
|
+
},
|
|
2720
|
+
],
|
|
2721
|
+
};
|
|
2722
|
+
if (method === 'thread/backgroundTerminals/list')
|
|
2723
|
+
return { terminals: [] };
|
|
2724
|
+
return undefined;
|
|
2725
|
+
};
|
|
2726
|
+
return server;
|
|
2727
|
+
},
|
|
2728
|
+
});
|
|
2729
|
+
onTestFinished(() => fixture.app.close());
|
|
2730
|
+
await fixture.app.inject({
|
|
2731
|
+
method: 'PUT',
|
|
2732
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2733
|
+
payload: { enabled: false },
|
|
2734
|
+
});
|
|
2735
|
+
await writeFile(join(fixture.workspacePath, 'autopilot.org'), acceptedL1WithNextTodoPlanText()
|
|
2736
|
+
.replace('* TODO [#B] Next parent', '* WIP [#B] Next parent')
|
|
2737
|
+
.replace('** TODO [#B] Next child', '** DONE [#B] Next child') +
|
|
2738
|
+
`
|
|
2739
|
+
** TODO [#B] Next child two
|
|
2740
|
+
:PROPERTIES:
|
|
2741
|
+
:ID: next-child-two
|
|
2742
|
+
:END:
|
|
2743
|
+
- Why :: Continue the same L1 after its first report.
|
|
2744
|
+
- Change :: Resume the canonical executor.
|
|
2745
|
+
- Tests :: Verify one fenced continuation.
|
|
2746
|
+
- Done when :: The next L2 starts.
|
|
2747
|
+
`);
|
|
2748
|
+
await expect
|
|
2749
|
+
.poll(async () => (await fixture.app.inject(`/api/sessions/${fixture.sessionId}/plan`)).json()
|
|
2750
|
+
.currentStepId)
|
|
2751
|
+
.toBe('next-parent');
|
|
2752
|
+
await fixture.app.inject({
|
|
2753
|
+
method: 'POST',
|
|
2754
|
+
url: `/api/sessions/${fixture.sessionId}/activity/refresh`,
|
|
2755
|
+
});
|
|
2756
|
+
expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()).toMatchObject({
|
|
2757
|
+
agentActivity: {
|
|
2758
|
+
confidence: 'fresh',
|
|
2759
|
+
aggregateSubagents: 'idle',
|
|
2760
|
+
subagents: expect.arrayContaining([
|
|
2761
|
+
expect.objectContaining({ id: 'old-helper', state: 'disconnected' }),
|
|
2762
|
+
expect.objectContaining({ id: 'previous-executor', state: 'idle' }),
|
|
2763
|
+
expect.objectContaining({ id: 'executor', state: 'idle' }),
|
|
2764
|
+
]),
|
|
2765
|
+
},
|
|
2766
|
+
});
|
|
2767
|
+
if (reported) {
|
|
2768
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2769
|
+
try {
|
|
2770
|
+
const row = database
|
|
2771
|
+
.prepare('SELECT lifecycle_json FROM autopilot_sessions WHERE session_id = ?')
|
|
2772
|
+
.get(fixture.sessionId);
|
|
2773
|
+
const lifecycle = JSON.parse(row.lifecycle_json);
|
|
2774
|
+
lifecycle.checkpoints = {
|
|
2775
|
+
protocolVersion: 1,
|
|
2776
|
+
planIdentity: createHash('sha256')
|
|
2777
|
+
.update(join(fixture.workspacePath, 'autopilot.org'))
|
|
2778
|
+
.digest('hex'),
|
|
2779
|
+
reportedL1Ids: ['parent'],
|
|
2780
|
+
reportedL2Ids: [
|
|
2781
|
+
JSON.stringify(['parent', 'child']),
|
|
2782
|
+
JSON.stringify(['next-parent', 'next-child']),
|
|
2783
|
+
],
|
|
2784
|
+
acceptedKeys: [],
|
|
2785
|
+
pendingTurnId: null,
|
|
2786
|
+
terminalReviewAccepted: false,
|
|
2787
|
+
};
|
|
2788
|
+
database
|
|
2789
|
+
.prepare('UPDATE autopilot_sessions SET lifecycle_json = ? WHERE session_id = ?')
|
|
2790
|
+
.run(JSON.stringify(lifecycle), fixture.sessionId);
|
|
2791
|
+
}
|
|
2792
|
+
finally {
|
|
2793
|
+
database.close();
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
await fixture.app.inject({
|
|
2797
|
+
method: 'PUT',
|
|
2798
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2799
|
+
payload: { enabled: true },
|
|
2800
|
+
});
|
|
2801
|
+
const starts = () => handles
|
|
2802
|
+
.flatMap((handle) => handle.requests)
|
|
2803
|
+
.filter((request) => request.method === 'turn/start');
|
|
2804
|
+
for (let attempt = 0; attempt < 8 && starts().length === 0; attempt += 1) {
|
|
2805
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2806
|
+
expect(timer).toBeDefined();
|
|
2807
|
+
timer.fired = true;
|
|
2808
|
+
timer.callback();
|
|
2809
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2810
|
+
}
|
|
2811
|
+
await vi.waitFor(() => expect(starts()).toHaveLength(1));
|
|
2812
|
+
const rootThreadId = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()
|
|
2813
|
+
.threadId;
|
|
2814
|
+
expect(starts()[0].params).toMatchObject({
|
|
2815
|
+
threadId: reported ? 'executor' : rootThreadId,
|
|
2816
|
+
});
|
|
2817
|
+
// Replayed timers cannot duplicate the root report or the later
|
|
2818
|
+
// continuation of the same canonical executor.
|
|
2819
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
2820
|
+
timer.callback();
|
|
2821
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2822
|
+
expect(starts()).toHaveLength(1);
|
|
2823
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2824
|
+
try {
|
|
2825
|
+
expect(database
|
|
2826
|
+
.prepare('SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = ?')
|
|
2827
|
+
.get(fixture.sessionId, reported ? 'autopilot.executor-resumed' : 'autopilot.control-issued')).toMatchObject({ count: 1 });
|
|
2828
|
+
}
|
|
2829
|
+
finally {
|
|
2830
|
+
database.close();
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2645
2833
|
it('refreshes unchanged idle evidence so a stale handoff can continue', async () => {
|
|
2646
2834
|
const timers = [];
|
|
2647
2835
|
const fixture = await createProductionAutopilotFixture({
|
|
@@ -4106,7 +4294,7 @@ describe('production composition', () => {
|
|
|
4106
4294
|
});
|
|
4107
4295
|
});
|
|
4108
4296
|
describeCompositionConcern('sessions', () => {
|
|
4109
|
-
it('starts Self DEBUG
|
|
4297
|
+
it('starts Self DEBUG with the source root model and exact skill profile instead of executor defaults', async () => {
|
|
4110
4298
|
const root = await mkdtemp(join(tmpdir(), 'gestalt-debug-root-'));
|
|
4111
4299
|
const dataDir = await mkdtemp(join(tmpdir(), 'gestalt-debug-state-'));
|
|
4112
4300
|
const homeDirectory = await mkdtemp(join(tmpdir(), 'gestalt-debug-home-'));
|
|
@@ -4144,7 +4332,9 @@ describe('production composition', () => {
|
|
|
4144
4332
|
startAppServers: true,
|
|
4145
4333
|
launchAppServer: liveAppServer(handles),
|
|
4146
4334
|
componentVersions: [{ id: 'codex', label: 'Codex', version: '0.144.3' }],
|
|
4147
|
-
sessionModelCatalog: {
|
|
4335
|
+
sessionModelCatalog: {
|
|
4336
|
+
list: async () => ['gpt-5.6-terra', 'configured-debug-model', 'source-root-model'],
|
|
4337
|
+
},
|
|
4148
4338
|
profiles: {
|
|
4149
4339
|
list: async () => [],
|
|
4150
4340
|
require: async () => ({ name: 'default', state: 'ok', status: 'ready' }),
|
|
@@ -4152,7 +4342,22 @@ describe('production composition', () => {
|
|
|
4152
4342
|
});
|
|
4153
4343
|
onTestFinished(() => app.close());
|
|
4154
4344
|
const sourceId = await createComposedSession(app);
|
|
4155
|
-
|
|
4345
|
+
const inheritedSkills = {
|
|
4346
|
+
selectedProfileName: 'js-devel',
|
|
4347
|
+
skills: [
|
|
4348
|
+
{ name: 'disabled', path: '/skills/disabled/SKILL.md', enabled: false },
|
|
4349
|
+
{ name: 'selected', path: '/skills/selected/SKILL.md', enabled: true },
|
|
4350
|
+
],
|
|
4351
|
+
};
|
|
4352
|
+
const database = new DatabaseSync(join(dataDir, 'relay.sqlite'));
|
|
4353
|
+
database
|
|
4354
|
+
.prepare('UPDATE relay_sessions SET model = ?, profile = ?, model_settings_json = ?, effective_skill_selection_json = ? WHERE id = ?')
|
|
4355
|
+
.run('source-root-model', 'supervisor', JSON.stringify({
|
|
4356
|
+
reasoningEffort: 'medium',
|
|
4357
|
+
executorModel: 'configured-debug-model',
|
|
4358
|
+
executorReasoningEffort: 'high',
|
|
4359
|
+
}), JSON.stringify(inheritedSkills), sourceId);
|
|
4360
|
+
database.close();
|
|
4156
4361
|
const confirmation = (await app.inject(`/api/sessions/${sourceId}/debug`)).json();
|
|
4157
4362
|
expect(confirmation.context.mobileSession).toBe(sourceId);
|
|
4158
4363
|
const response = await app.inject({
|
|
@@ -4164,15 +4369,27 @@ describe('production composition', () => {
|
|
|
4164
4369
|
const debug = response.json();
|
|
4165
4370
|
expect(debug.id).not.toBe(sourceId);
|
|
4166
4371
|
expect(debug.workspacePath).toBe(debugRoot);
|
|
4167
|
-
expect(debug.model).toBe('
|
|
4372
|
+
expect(debug.model).toBe('source-root-model');
|
|
4373
|
+
expect(debug.profile).toBe('supervisor');
|
|
4374
|
+
expect(debug.effectiveSkillSelection).toEqual(inheritedSkills);
|
|
4375
|
+
expect(debug.selfDebug.agent.name).toBe('root');
|
|
4168
4376
|
expect(debug.threadId).not.toBe(confirmation.context.codexThread);
|
|
4377
|
+
expect((await app.inject(`/api/sessions/${sourceId}`)).json()).toMatchObject({
|
|
4378
|
+
state: 'ready',
|
|
4379
|
+
activeTurnId: null,
|
|
4380
|
+
});
|
|
4381
|
+
expect(handles
|
|
4382
|
+
.flatMap((handle) => handle.requests)
|
|
4383
|
+
.filter((request) => request.method === 'turn/start' &&
|
|
4384
|
+
request.params.threadId ===
|
|
4385
|
+
confirmation.context.codexThread)).toHaveLength(0);
|
|
4169
4386
|
const request = handles
|
|
4170
4387
|
.flatMap((handle) => handle.requests)
|
|
4171
4388
|
.find((request) => request.method === 'turn/start' &&
|
|
4172
4389
|
request.params.threadId === debug.threadId);
|
|
4173
4390
|
expect(request?.params).toMatchObject({
|
|
4174
|
-
model: '
|
|
4175
|
-
effort: '
|
|
4391
|
+
model: 'source-root-model',
|
|
4392
|
+
effort: 'medium',
|
|
4176
4393
|
input: [{ type: 'text', text: expect.stringContaining('User detected an error') }],
|
|
4177
4394
|
});
|
|
4178
4395
|
expect((await app.inject('/api/sessions'))
|
|
@@ -305,7 +305,13 @@ export async function composeRelayApp(options) {
|
|
|
305
305
|
const continuationPrompt = launchIdentity
|
|
306
306
|
? autopilotExecutorLaunchPrompt(launchIdentity)
|
|
307
307
|
: AUTOPILOT_CONTINUATION_PROMPT;
|
|
308
|
-
const
|
|
308
|
+
const recovery = autopilotStore.find(sessionId);
|
|
309
|
+
const executorRecovery = recovery?.supervision?.outcome === 'probeRequired' &&
|
|
310
|
+
recovery.executor?.commands?.some((command) => command.status === 'issued' && !command.processAction);
|
|
311
|
+
const recoveryInstruction = executorRecovery
|
|
312
|
+
? ' The previous executor resume has an unconfirmed outcome. Inspect the existing canonical executor and its latest turn before continuing. Preserve its physical identity; do not replay an active turn or replace the executor merely because the resume reply failed. Resolve this probe with verified actionable work, a valid wait lease, or genuine structured attention.'
|
|
313
|
+
: '';
|
|
314
|
+
const started = await runtime.startTurn(writer.session, continuationPrompt + recoveryInstruction, controlId, new Date().toISOString());
|
|
309
315
|
if (!started.activeTurnId)
|
|
310
316
|
throw new Error('AUTOPILOT_START_UNAVAILABLE');
|
|
311
317
|
sessions.save(started);
|
|
@@ -1333,18 +1339,13 @@ export async function composeRelayApp(options) {
|
|
|
1333
1339
|
create: (context) => createSelfDebugSession(context, {
|
|
1334
1340
|
createId: randomUUID,
|
|
1335
1341
|
now: () => new Date().toISOString(),
|
|
1336
|
-
settings: async () => {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const defaults = await sessionDefaults.read();
|
|
1342
|
+
settings: async (source) => {
|
|
1343
|
+
if (!source.model || !source.effectiveSkillSelection)
|
|
1344
|
+
throw new Error('DEBUG_SOURCE_SETTINGS_UNAVAILABLE');
|
|
1340
1345
|
return {
|
|
1341
|
-
|
|
1342
|
-
model: source
|
|
1343
|
-
|
|
1344
|
-
installed.model,
|
|
1345
|
-
reasoningEffort: source?.modelSettings?.executorReasoningEffort ??
|
|
1346
|
-
defaults?.executorReasoningEffort ??
|
|
1347
|
-
installed.reasoningEffort,
|
|
1346
|
+
name: 'root',
|
|
1347
|
+
model: source.model,
|
|
1348
|
+
reasoningEffort: source.modelSettings?.reasoningEffort,
|
|
1348
1349
|
};
|
|
1349
1350
|
},
|
|
1350
1351
|
capture: async (id, capturedContext, agent) => {
|
|
@@ -1354,38 +1355,13 @@ export async function composeRelayApp(options) {
|
|
|
1354
1355
|
absoluteTracePath: join(captured.root, captured.debug.tracePath),
|
|
1355
1356
|
};
|
|
1356
1357
|
},
|
|
1357
|
-
|
|
1358
|
-
const source = sessions.find(context.mobileSession);
|
|
1359
|
-
if (source && source.threadId === (context.sourceThread ?? context.codexThread))
|
|
1360
|
-
await debugWorkspace.askSource(id, source, debug, async (prompt) => {
|
|
1361
|
-
const sourceRuntime = ownerRuntime(source);
|
|
1362
|
-
// Never resume or replace the source writer merely to ask for diagnostics.
|
|
1363
|
-
if (!sourceRuntime?.ownsWriter(source.id))
|
|
1364
|
-
throw new Error('DEBUG_SOURCE_UNAVAILABLE');
|
|
1365
|
-
if (source.state === 'turnActive' && source.activeTurnId)
|
|
1366
|
-
await sourceRuntime.queueTurnInput(source, source.activeTurnId, prompt, `self-debug-${id}`);
|
|
1367
|
-
else if (source.state === 'ready') {
|
|
1368
|
-
const started = await sourceRuntime.startTurn(source, prompt, `self-debug-${id}`, new Date().toISOString());
|
|
1369
|
-
saveSession(started);
|
|
1370
|
-
activity.observe({
|
|
1371
|
-
sessionId: source.id,
|
|
1372
|
-
occurredAt: started.updatedAt,
|
|
1373
|
-
kind: 'turnStarted',
|
|
1374
|
-
threadId: started.threadId,
|
|
1375
|
-
turnId: started.activeTurnId,
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
else
|
|
1379
|
-
throw new Error('DEBUG_SOURCE_UNAVAILABLE');
|
|
1380
|
-
});
|
|
1381
|
-
},
|
|
1382
|
-
createSession: async (id, root, agent) => {
|
|
1358
|
+
createSession: async (id, root, agent, source) => {
|
|
1383
1359
|
await debugWorkspace.prepare();
|
|
1384
1360
|
const debugCatalog = new FilesystemWorkspaceCatalog(root);
|
|
1385
1361
|
const [workspace] = await debugCatalog.list();
|
|
1386
1362
|
return startSession({
|
|
1387
1363
|
workspaceId: workspace.id,
|
|
1388
|
-
profile:
|
|
1364
|
+
profile: source.profile,
|
|
1389
1365
|
provider: 'codex',
|
|
1390
1366
|
model: agent.model,
|
|
1391
1367
|
reasoningEffort: agent.reasoningEffort,
|
|
@@ -1399,6 +1375,7 @@ export async function composeRelayApp(options) {
|
|
|
1399
1375
|
profiles: options.profiles,
|
|
1400
1376
|
skillProfiles,
|
|
1401
1377
|
skillCatalog,
|
|
1378
|
+
inheritedSkillSelection: source.effectiveSkillSelection,
|
|
1402
1379
|
sessionModels,
|
|
1403
1380
|
});
|
|
1404
1381
|
},
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
+
import { currentExecutableL1Index, } from '../../plans/domain/supervised-plan.js';
|
|
7
|
+
import { parseOrgPlanAgentIdentity } from '../../../../shared/org-plan-position.js';
|
|
6
8
|
export const AUTOPILOT_PROMPT_VERSION = 'v13';
|
|
7
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. 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.';
|
|
8
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.';
|
|
@@ -55,16 +57,35 @@ export function classifyAgentActivity(activity) {
|
|
|
55
57
|
* topology cannot indefinitely turn a fresh read into a reconciliation loop.
|
|
56
58
|
*/
|
|
57
59
|
function classifySupervisedActivity(activity, plan) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
+
const executable = currentExecutableL1Index(plan);
|
|
61
|
+
// A checkpoint authorizes a supervisor turn to resume the barrier, never executor dispatch.
|
|
62
|
+
const index = executable >= 0 ? executable : plan.steps.findIndex((step) => step.state === 'SUSPENDED');
|
|
60
63
|
if (index < 0)
|
|
61
64
|
return classifyAgentActivity(activity);
|
|
62
65
|
const position = index + 1;
|
|
63
66
|
const retained = activity.subagents.filter((child) => {
|
|
67
|
+
// An authoritative roster retains unloaded auxiliary threads after their
|
|
68
|
+
// work ends. They have no canonical assignment to resume, and rereading
|
|
69
|
+
// that same terminal status cannot advance the current Org milestone.
|
|
70
|
+
// Keep unknown identities and any outstanding process/result in the gate.
|
|
71
|
+
const retiredAuxiliary = child.state === 'disconnected' &&
|
|
72
|
+
child.reason === 'processExited' &&
|
|
73
|
+
child.taskPath &&
|
|
74
|
+
!child.canonicalPosition &&
|
|
75
|
+
!child.canonicalTaskName &&
|
|
76
|
+
!parseOrgPlanAgentIdentity(child.taskPath) &&
|
|
77
|
+
!child.ownedProcesses?.some((process) => process.state !== 'result-consumed' && process.state !== 'terminated-for-budget');
|
|
78
|
+
if (retiredAuxiliary)
|
|
79
|
+
return false;
|
|
64
80
|
const match = /^L([1-9]\d*)$/.exec(child.canonicalPosition ?? '');
|
|
65
81
|
if (!match)
|
|
66
82
|
return true;
|
|
67
83
|
const historical = Number(match[1]) < position;
|
|
84
|
+
const suspended = plan.steps[Number(match[1]) - 1]?.state === 'SUSPENDED';
|
|
85
|
+
if (suspended &&
|
|
86
|
+
['idle', 'blocked', 'disconnected'].includes(child.state) &&
|
|
87
|
+
!child.ownedProcesses?.some((process) => process.state === 'running' || process.state === 'detached-active'))
|
|
88
|
+
return false;
|
|
68
89
|
const supervisedProcess = child.ownedProcesses?.some((process) => process.ownership === 'supervisor' &&
|
|
69
90
|
(process.state === 'running' || process.state === 'detached-active'));
|
|
70
91
|
return !historical || supervisedProcess;
|
|
@@ -128,6 +149,10 @@ export function decideAutopilot(input) {
|
|
|
128
149
|
};
|
|
129
150
|
return { kind: 'complete' };
|
|
130
151
|
}
|
|
152
|
+
if (plan.steps.some((step) => step.state === 'SUSPENDED') &&
|
|
153
|
+
currentExecutableL1Index(plan) < 0 &&
|
|
154
|
+
!state.checkpoints?.rootContinuationFromTurnId)
|
|
155
|
+
return { kind: 'observe' };
|
|
131
156
|
// Quiz, approval, and other held requests are ordinary session work. Only a
|
|
132
157
|
// validated Org attention record may turn an incomplete plan into a human stop.
|
|
133
158
|
if (hasPendingInteraction)
|