gestalt-mobile 0.65.4 → 0.65.6
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/dist/client/assets/{index-CohraBWu.js → index-DGK0NUPm.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/client/features/chat/chat-projection.js +1 -0
- package/dist/server/server/composition.contracts.js +178 -0
- package/dist/server/server/composition.js +151 -395
- package/dist/server/server/features/org-plan-attention/application/acknowledgement.js +43 -0
- package/dist/server/server/features/org-plan-attention/application/resolve.js +130 -0
- package/dist/server/server/features/org-plan-checkpoint/application/coordinate.js +191 -0
- package/dist/server/server/platform/codex/json-rpc-client.js +4 -4
- package/dist/server/shared/contracts/autopilot-wait-lease.js +2 -2
- package/package.json +2 -1
|
@@ -20,6 +20,8 @@ import { CodexJsonRpcError } from './platform/codex/json-rpc-client.js';
|
|
|
20
20
|
import { CodexSessionRuntime } from './platform/codex/session-runtime.js';
|
|
21
21
|
import { SqliteAuthorizationStore } from './platform/auth/sqlite-authorization-store.js';
|
|
22
22
|
import { SqliteEventJournal } from './platform/persistence/sqlite-event-journal.js';
|
|
23
|
+
import { SqliteAutopilotStore } from './platform/persistence/sqlite-autopilot-store.js';
|
|
24
|
+
import { startSupervisionProtocol } from './features/autopilot/domain/supervision-protocol.js';
|
|
23
25
|
import { exportControlPlaneTrace } from './features/control-plane-trace/export-trace.js';
|
|
24
26
|
import { authorizationSessionId, authorizedDeviceId, localOwnerId, webAuthnCredentialId, } from './features/auth/domain/identifiers.js';
|
|
25
27
|
import { deviceNickname } from './features/auth/domain/device-nickname.js';
|
|
@@ -498,6 +500,84 @@ describe('production composition', () => {
|
|
|
498
500
|
.prepare("SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = 'autopilot.operation-failed'")
|
|
499
501
|
.get(fixture.sessionId)).toMatchObject({ count: 0 });
|
|
500
502
|
});
|
|
503
|
+
it.each([1, 2])('keeps a version %s wait validation error recoverable during a probe', async (version) => {
|
|
504
|
+
const fixture = await createProductionAutopilotFixture({
|
|
505
|
+
autopilotSchedule: () => () => { },
|
|
506
|
+
});
|
|
507
|
+
onTestFinished(() => fixture.app.close());
|
|
508
|
+
const started = await fixture.app.inject({
|
|
509
|
+
method: 'POST',
|
|
510
|
+
url: `/api/sessions/${fixture.sessionId}/turns`,
|
|
511
|
+
payload: { text: 'Synthetic wait validation fixture' },
|
|
512
|
+
});
|
|
513
|
+
expect(started.statusCode).toBe(202);
|
|
514
|
+
const session = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json();
|
|
515
|
+
const handle = fixture.handles.find((candidate) => candidate.calls.includes('turn/start'));
|
|
516
|
+
handle.notify({
|
|
517
|
+
method: 'turn/started',
|
|
518
|
+
params: { threadId: session.threadId, turn: { id: session.activeTurnId } },
|
|
519
|
+
});
|
|
520
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
521
|
+
onTestFinished(() => database.close());
|
|
522
|
+
const store = new SqliteAutopilotStore(database);
|
|
523
|
+
const state = store.find(fixture.sessionId);
|
|
524
|
+
store.save({
|
|
525
|
+
...state,
|
|
526
|
+
requestedEnabled: true,
|
|
527
|
+
state: 'monitoring',
|
|
528
|
+
supervision: {
|
|
529
|
+
...startSupervisionProtocol('probe-progress'),
|
|
530
|
+
outcome: 'probeRequired',
|
|
531
|
+
probeKey: 'probe-progress',
|
|
532
|
+
unchangedContinuations: 3,
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
let requestId = 9000;
|
|
536
|
+
const call = async (wakeConditions) => {
|
|
537
|
+
const response = (await handle.request({
|
|
538
|
+
id: ++requestId,
|
|
539
|
+
method: 'item/tool/call',
|
|
540
|
+
params: {
|
|
541
|
+
threadId: session.threadId,
|
|
542
|
+
turnId: session.activeTurnId,
|
|
543
|
+
tool: 'gestalt_autopilot_wait_lease',
|
|
544
|
+
arguments: {
|
|
545
|
+
version,
|
|
546
|
+
reportId: 'wait-validation-report',
|
|
547
|
+
leaseId: 'wait-validation-lease',
|
|
548
|
+
wakeConditions,
|
|
549
|
+
...(version === 2 ? { maxWaitMs: 180_000 } : {}),
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
}));
|
|
553
|
+
return JSON.parse(response.contentItems[0].text);
|
|
554
|
+
};
|
|
555
|
+
expect(await call(['unsupported'])).toEqual({
|
|
556
|
+
accepted: false,
|
|
557
|
+
reason: 'invalidWaitLease',
|
|
558
|
+
next: 'continueSameTurn',
|
|
559
|
+
});
|
|
560
|
+
expect(store.find(fixture.sessionId)).toMatchObject({
|
|
561
|
+
requestedEnabled: true,
|
|
562
|
+
state: 'monitoring',
|
|
563
|
+
supervision: { outcome: 'probeRequired' },
|
|
564
|
+
});
|
|
565
|
+
const wakeConditions = [
|
|
566
|
+
'processExited',
|
|
567
|
+
'processResultAvailable',
|
|
568
|
+
'planChanged',
|
|
569
|
+
'interactionChanged',
|
|
570
|
+
'executorChanged',
|
|
571
|
+
];
|
|
572
|
+
expect(await call(wakeConditions)).toEqual({ accepted: true });
|
|
573
|
+
expect(store.find(fixture.sessionId)).toMatchObject({
|
|
574
|
+
requestedEnabled: true,
|
|
575
|
+
supervision: { outcome: 'parked', waitLease: { wakeConditions } },
|
|
576
|
+
});
|
|
577
|
+
expect(database
|
|
578
|
+
.prepare("SELECT COUNT(*) AS count FROM session_events WHERE session_id = ? AND type = 'autopilot.safety-paused'")
|
|
579
|
+
.get(fixture.sessionId)?.count).toBe(0);
|
|
580
|
+
});
|
|
501
581
|
it('serves compact supervision deltas and wakes only for the selected host run', async () => {
|
|
502
582
|
let coordinator;
|
|
503
583
|
const f = await createProductionAutopilotFixture({
|
|
@@ -4863,6 +4943,104 @@ describe('production composition', () => {
|
|
|
4863
4943
|
});
|
|
4864
4944
|
});
|
|
4865
4945
|
describeCompositionConcern('attention', () => {
|
|
4946
|
+
it('coalesces concurrent attention guidance and rejects a competing operation before replaying settlement', async () => {
|
|
4947
|
+
const fixture = await createProductionAutopilotFixture({
|
|
4948
|
+
autopilotSchedule: () => () => { },
|
|
4949
|
+
});
|
|
4950
|
+
const handle = fixture.handles.find((candidate) => candidate.request);
|
|
4951
|
+
let releaseGuidance;
|
|
4952
|
+
const guidanceGate = new Promise((resolve) => {
|
|
4953
|
+
releaseGuidance = resolve;
|
|
4954
|
+
});
|
|
4955
|
+
let guidanceStarted = false;
|
|
4956
|
+
handle.respond = async (method) => {
|
|
4957
|
+
if (method !== 'turn/start')
|
|
4958
|
+
return;
|
|
4959
|
+
guidanceStarted = true;
|
|
4960
|
+
await guidanceGate;
|
|
4961
|
+
return { turn: { id: 'attention-guidance-turn' } };
|
|
4962
|
+
};
|
|
4963
|
+
const submit = (operationKey) => Promise.resolve(fixture.app.inject({
|
|
4964
|
+
method: 'POST',
|
|
4965
|
+
url: `/api/sessions/${fixture.sessionId}/attention/690/resolve`,
|
|
4966
|
+
payload: { operationKey, action: 'resume', guidance: 'Continue the bounded task.' },
|
|
4967
|
+
}));
|
|
4968
|
+
const resolutions = [];
|
|
4969
|
+
try {
|
|
4970
|
+
await expect(handle.request(attentionCall(690))).resolves.toEqual(toOrgPlanAttentionAcknowledgement());
|
|
4971
|
+
resolutions.push(submit('shared-guidance'));
|
|
4972
|
+
await vi.waitFor(() => expect(guidanceStarted).toBe(true));
|
|
4973
|
+
resolutions.push(submit('shared-guidance'));
|
|
4974
|
+
const competing = await submit('competing-guidance');
|
|
4975
|
+
expect(competing.statusCode).toBe(409);
|
|
4976
|
+
expect(competing.json()).toEqual({ code: 'ATTENTION_OPERATION_STALE' });
|
|
4977
|
+
expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}/attention`)).json()).toMatchObject({ requestId: '690' });
|
|
4978
|
+
releaseGuidance();
|
|
4979
|
+
const [first, duplicate] = await Promise.all(resolutions);
|
|
4980
|
+
expect(first.statusCode).toBe(202);
|
|
4981
|
+
expect(duplicate.statusCode).toBe(202);
|
|
4982
|
+
expect(duplicate.json()).toEqual(first.json());
|
|
4983
|
+
expect(first.json()).toMatchObject({ accepted: true, replayed: false });
|
|
4984
|
+
const replay = await submit('shared-guidance');
|
|
4985
|
+
expect(replay.statusCode).toBe(202);
|
|
4986
|
+
expect(replay.json()).toEqual({ ...first.json(), replayed: true });
|
|
4987
|
+
const delivered = handle.requests.filter((request) => request.method === 'turn/start');
|
|
4988
|
+
expect(delivered).toHaveLength(1);
|
|
4989
|
+
expect(JSON.stringify(delivered[0].params)).toContain('Continue the bounded task.');
|
|
4990
|
+
const history = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}/history`)).json();
|
|
4991
|
+
expect(history.interactions.filter((item) => item.requestId === '690')).toEqual([
|
|
4992
|
+
expect.objectContaining({ outcome: 'answered', resolvedAt: first.json().resolvedAt }),
|
|
4993
|
+
]);
|
|
4994
|
+
}
|
|
4995
|
+
finally {
|
|
4996
|
+
releaseGuidance();
|
|
4997
|
+
await Promise.allSettled(resolutions);
|
|
4998
|
+
await fixture.app.close();
|
|
4999
|
+
expect(handle.pendingResponses.size).toBe(0);
|
|
5000
|
+
}
|
|
5001
|
+
});
|
|
5002
|
+
it.each(['response settlement', 'relay shutdown'])('cancels the attention acknowledgement deadline after %s while retaining durable attention', async (boundary) => {
|
|
5003
|
+
const fixture = await createProductionAutopilotFixture({
|
|
5004
|
+
attentionAcknowledgementDeadlineMs: 300,
|
|
5005
|
+
autopilotSchedule: () => () => { },
|
|
5006
|
+
});
|
|
5007
|
+
const handle = fixture.handles.find((candidate) => candidate.request);
|
|
5008
|
+
handle.deferResponseSettlement = true;
|
|
5009
|
+
const response = handle.request(attentionCall(692));
|
|
5010
|
+
void response.catch(() => { });
|
|
5011
|
+
try {
|
|
5012
|
+
await vi.waitFor(() => expect(handle.pendingResponses.has(692)).toBe(true));
|
|
5013
|
+
const writersBefore = fixture.handles.length;
|
|
5014
|
+
if (boundary === 'response settlement') {
|
|
5015
|
+
handle.responseSettled({ id: 692, outcome: 'resultWritten' });
|
|
5016
|
+
await expect(response).resolves.toEqual(toOrgPlanAttentionAcknowledgement());
|
|
5017
|
+
}
|
|
5018
|
+
else {
|
|
5019
|
+
await fixture.app.close();
|
|
5020
|
+
await expect(response).rejects.toThrow('CODEX_SERVER_REQUEST_CANCELLED');
|
|
5021
|
+
}
|
|
5022
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
5023
|
+
expect(fixture.handles).toHaveLength(writersBefore);
|
|
5024
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
5025
|
+
try {
|
|
5026
|
+
expect(database
|
|
5027
|
+
.prepare('SELECT resolution_state, resolved_at, outcome FROM pending_interactions WHERE session_id = ? AND request_id = ?')
|
|
5028
|
+
.get(fixture.sessionId, '692')).toMatchObject({
|
|
5029
|
+
resolution_state: 'acknowledged',
|
|
5030
|
+
resolved_at: null,
|
|
5031
|
+
outcome: null,
|
|
5032
|
+
});
|
|
5033
|
+
}
|
|
5034
|
+
finally {
|
|
5035
|
+
database.close();
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
finally {
|
|
5039
|
+
await fixture.app.close();
|
|
5040
|
+
await Promise.allSettled([response]);
|
|
5041
|
+
expect(handle.pendingResponses.size).toBe(0);
|
|
5042
|
+
}
|
|
5043
|
+
});
|
|
4866
5044
|
it('includes the same blocked root turn explanation in attention and session reloads', async () => {
|
|
4867
5045
|
const timers = [];
|
|
4868
5046
|
const fixture = await createProductionAutopilotFixture({
|