gestalt-mobile 0.65.4 → 0.65.5

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.
@@ -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({
@@ -1294,10 +1294,9 @@ export async function composeRelayApp(options) {
1294
1294
  scheduleAgentCapacityRecovery(sessionId, () => runtime?.resolveServerRequest(sessionId, String(request.id), agentCapacityRecoveryToolResponse()) === true));
1295
1295
  }
1296
1296
  if (!rawInteraction && isAutopilotWaitLeaseCall(request)) {
1297
- const rootOwned = origin.kind === 'root' && origin.physicalTurnId === session.activeTurnId;
1298
- if (rootOwned)
1299
- autopilot.rejectProbe(sessionId);
1300
- return (runtime?.resolveServerRequest(sessionId, String(request.id), autopilotWaitLeaseToolResponse(false)) === true);
1297
+ // Invalid tool arguments are recoverable in this turn. They do not
1298
+ // establish that supervision is stalled or revoke continuation.
1299
+ return (runtime?.resolveServerRequest(sessionId, String(request.id), autopilotWaitLeaseToolResponse(false, 'invalidWaitLease')) === true);
1301
1300
  }
1302
1301
  if (!rawInteraction)
1303
1302
  return false;
@@ -1319,8 +1318,6 @@ export async function composeRelayApp(options) {
1319
1318
  wakeConditions: lease.wakeConditions,
1320
1319
  }));
1321
1320
  if (registration !== true) {
1322
- if (rootOwned && registration === false)
1323
- autopilot.rejectProbe(sessionId);
1324
1321
  return (runtime?.resolveServerRequest(sessionId, rawInteraction.requestId, autopilotWaitLeaseToolResponse(false, registration === 'wakeAlreadySatisfied'
1325
1322
  ? 'wakeAlreadySatisfied'
1326
1323
  : 'automaticContinuationUnavailable')) === true);
@@ -32,7 +32,7 @@ export const gestaltAutopilotWaitLeaseDynamicTool = {
32
32
  wakeConditions: {
33
33
  type: 'array',
34
34
  minItems: 1,
35
- maxItems: 4,
35
+ maxItems: autopilotWaitWakeConditions.length,
36
36
  uniqueItems: true,
37
37
  items: { type: 'string', enum: autopilotWaitWakeConditions },
38
38
  },
@@ -55,7 +55,7 @@ export function parseAutopilotWaitLease(value) {
55
55
  return null;
56
56
  const wakeConditions = value.wakeConditions;
57
57
  if (wakeConditions.length < 1 ||
58
- wakeConditions.length > 4 ||
58
+ wakeConditions.length > autopilotWaitWakeConditions.length ||
59
59
  new Set(wakeConditions).size !== wakeConditions.length ||
60
60
  !wakeConditions.every((condition) => typeof condition === 'string' &&
61
61
  autopilotWaitWakeConditions.includes(condition)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.65.4",
3
+ "version": "0.65.5",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",