gestalt-mobile 0.44.2 → 0.44.3

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.
@@ -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-6WgZCe9g.js"></script>
20
- <link rel="stylesheet" crossorigin href="/assets/index-BKls66uM.css">
19
+ <script type="module" crossorigin src="/assets/index-DYZT_mLU.js"></script>
20
+ <link rel="stylesheet" crossorigin href="/assets/index-DEVCzFB9.css">
21
21
  </head>
22
22
  <body>
23
23
  <div id="app"></div>
@@ -1050,6 +1050,61 @@ describe('production composition', () => {
1050
1050
  expect(checkpoint.count).toBe(1);
1051
1051
  await fixture.app.close();
1052
1052
  });
1053
+ it('refreshes the published L2 boundary before selecting among multiple DONE children', async () => {
1054
+ const timers = [];
1055
+ const fixture = await createProductionAutopilotFixture({
1056
+ autopilotSchedule: (callback) => {
1057
+ const timer = { callback, cancelled: false };
1058
+ timers.push(timer);
1059
+ return () => {
1060
+ timer.cancelled = true;
1061
+ };
1062
+ },
1063
+ });
1064
+ timers.find((timer) => !timer.cancelled).callback();
1065
+ await vi.waitFor(async () => expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json().activeTurnId).toEqual(expect.any(String)));
1066
+ const session = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json();
1067
+ const handle = fixture.handles.find((candidate) => candidate.requests.some((request) => request.method === 'turn/start'));
1068
+ const planPath = join(fixture.workspacePath, 'autopilot.org');
1069
+ await writeFile(planPath, `${autopilotPlanText('DONE')}
1070
+ ** DONE [#A] Newly completed child
1071
+ :PROPERTIES:
1072
+ :ID: second-child
1073
+ :END:
1074
+ - Why :: Verify a resumed plan with earlier completed work.
1075
+ - Change :: Preserve the publication target.
1076
+ - Tests :: Checkpoint immediately after writing the signal.
1077
+ - Done when :: L1.2 is recorded exactly once.
1078
+ `);
1079
+ await writeFile(planStatusFilePath(planStatusDirectoryPath(fixture.workspacePath, fixture.sessionId), planPath), JSON.stringify({
1080
+ schemaVersion: 1,
1081
+ planPath,
1082
+ reason: 'l2:second-child:DONE',
1083
+ updatedAt: new Date().toISOString(),
1084
+ }));
1085
+ // No watcher wait or GET /plan refresh: the checkpoint itself is the barrier.
1086
+ await expect(handle.request({
1087
+ id: 818,
1088
+ method: 'item/tool/call',
1089
+ params: {
1090
+ threadId: session.threadId,
1091
+ turnId: session.activeTurnId,
1092
+ tool: 'gestalt_org_plan_checkpoint',
1093
+ arguments: { kind: 'l2Completed' },
1094
+ },
1095
+ })).resolves.toEqual(toOrgPlanCheckpointToolResponse('recorded'));
1096
+ const db = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
1097
+ const rows = db
1098
+ .prepare("SELECT payload_json FROM session_events WHERE session_id = ? AND type = 'org-plan.step-checkpointed'")
1099
+ .all(fixture.sessionId);
1100
+ expect(rows).toHaveLength(1);
1101
+ expect(JSON.parse(rows[0].payload_json)).toMatchObject({
1102
+ l2Id: 'second-child',
1103
+ position: 'L1.2',
1104
+ });
1105
+ db.close();
1106
+ await fixture.app.close();
1107
+ });
1053
1108
  it('records and idempotently replays accepted L1 after REVIEWED advances to the next TODO L1', async () => {
1054
1109
  const timers = [];
1055
1110
  const fixture = await createProductionAutopilotFixture({
@@ -2154,6 +2209,59 @@ describe('production composition', () => {
2154
2209
  });
2155
2210
  });
2156
2211
  describeCompositionConcern('attention', () => {
2212
+ it('includes the same blocked root turn explanation in attention and session reloads', async () => {
2213
+ const timers = [];
2214
+ const fixture = await createProductionAutopilotFixture({
2215
+ autopilotSchedule: (callback) => {
2216
+ const timer = { callback, cancelled: false };
2217
+ timers.push(timer);
2218
+ return () => {
2219
+ timer.cancelled = true;
2220
+ };
2221
+ },
2222
+ });
2223
+ timers.find((timer) => !timer.cancelled).callback();
2224
+ await vi.waitFor(async () => expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json().activeTurnId).toEqual(expect.any(String)));
2225
+ const session = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json();
2226
+ const handle = fixture.handles.find((candidate) => candidate.requests.some((request) => request.method === 'turn/start'));
2227
+ await expect(handle.request({
2228
+ id: 698,
2229
+ method: 'item/tool/call',
2230
+ params: {
2231
+ threadId: session.threadId,
2232
+ turnId: session.activeTurnId,
2233
+ tool: 'gestalt_org_plan_attention',
2234
+ arguments: { reason: 'hardBlock', resumeCondition: 'externalStateChanged' },
2235
+ },
2236
+ })).resolves.toEqual(toOrgPlanAttentionAcknowledgement());
2237
+ const report = 'The checkpoint cannot identify L1.2. Refresh plan state, then retry.';
2238
+ handle.notify({
2239
+ method: 'item/completed',
2240
+ params: {
2241
+ threadId: session.threadId,
2242
+ turnId: session.activeTurnId,
2243
+ item: { id: 'blocker-final', type: 'agentMessage', phase: 'final_answer', text: report },
2244
+ },
2245
+ });
2246
+ handle.notify({
2247
+ method: 'item/completed',
2248
+ params: {
2249
+ threadId: session.threadId,
2250
+ turnId: 'another-turn',
2251
+ item: {
2252
+ id: 'unrelated-final',
2253
+ type: 'agentMessage',
2254
+ phase: 'final_answer',
2255
+ text: 'Unrelated report',
2256
+ },
2257
+ },
2258
+ });
2259
+ expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}/attention`)).json()).toMatchObject({ supervisorReport: report });
2260
+ expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json().pendingInteractions).toEqual(expect.arrayContaining([
2261
+ expect.objectContaining({ requestId: '698', supervisorReport: report }),
2262
+ ]));
2263
+ await fixture.app.close();
2264
+ });
2157
2265
  it('bounds a wedged attention acknowledgement writer without losing durable attention', async () => {
2158
2266
  const fixture = await createProductionAutopilotFixture({
2159
2267
  attentionAcknowledgementDeadlineMs: 100,
@@ -116,7 +116,17 @@ export async function composeRelayApp(options) {
116
116
  const supervisedPlans = new SupervisedPlanRegistry();
117
117
  const planStatusSource = new FilesystemPlanStatusSource(join(dirname(databasePath), 'plans'));
118
118
  const planMeasurementHelperPath = options.planMeasurementHelperPath ?? process.env.GESTALT_MOBILE_ORG_PLAN_HELPER;
119
- const withPendingInteractions = (session) => (session ? { ...session, pendingInteractions: interactions.list(session.id) } : null);
119
+ const pendingInteractionsWithReports = (sessionId) => interactions.list(sessionId).map((interaction) => ({
120
+ ...interaction,
121
+ ...(interaction.kind === 'orgPlanAttention' && interaction.turnId && interaction.requestedAt
122
+ ? {
123
+ supervisorReport: journal.attentionReport(sessionId, interaction.turnId, interaction.requestedAt),
124
+ }
125
+ : {}),
126
+ }));
127
+ const withPendingInteractions = (session) => session
128
+ ? { ...session, pendingInteractions: pendingInteractionsWithReports(session.id) }
129
+ : null;
120
130
  const events = new SessionEventBus();
121
131
  let notifyAutopilotActivity = () => undefined;
122
132
  let publishSessionStatus = () => undefined;
@@ -764,8 +774,15 @@ export async function composeRelayApp(options) {
764
774
  events.publish(journal.append(sessionId, normalized.type, normalized.payload, normalized.occurredAt));
765
775
  if (completedSession)
766
776
  events.publish(journal.append(sessionId, 'session.updated', completedSession, occurredAt));
767
- }, (sessionId, request, origin) => {
777
+ }, async (sessionId, request, origin) => {
768
778
  let rawInteraction = toPendingInteraction(request);
779
+ const compactCheckpointKind = compactOrgPlanCheckpointKind(request);
780
+ if (compactCheckpointKind || rawInteraction?.kind === 'orgPlanCheckpoint') {
781
+ // A checkpoint is a read barrier, not a race against the debounced watcher.
782
+ const refreshed = await planStatusSource.refresh(sessionId);
783
+ if (refreshed?.kind !== 'updated')
784
+ return (runtime?.resolveServerRequest(sessionId, String(request.id), checkpointFailureResponse('planProjectionUnavailable')) === true);
785
+ }
769
786
  const session = withPendingInteractions(sessions.find(sessionId));
770
787
  if (!session)
771
788
  return false;
@@ -786,7 +803,6 @@ export async function composeRelayApp(options) {
786
803
  ],
787
804
  }) === true);
788
805
  }
789
- const compactCheckpointKind = compactOrgPlanCheckpointKind(request);
790
806
  if (!rawInteraction && compactCheckpointKind) {
791
807
  const retained = supervisedPlans.find(sessionId);
792
808
  const identity = supervisedPlans.identity(sessionId);
@@ -1470,9 +1486,7 @@ export async function composeRelayApp(options) {
1470
1486
  exists: (id) => sessions.find(id) !== null,
1471
1487
  reader: {
1472
1488
  active: (sessionId) => {
1473
- const interaction = interactions
1474
- .list(sessionId)
1475
- .find((item) => item.kind === 'orgPlanAttention');
1489
+ const interaction = pendingInteractionsWithReports(sessionId).find((item) => item.kind === 'orgPlanAttention');
1476
1490
  const attention = interaction ? parseOrgPlanAttention(interaction.payload) : null;
1477
1491
  return interaction && attention
1478
1492
  ? {
@@ -1480,6 +1494,9 @@ export async function composeRelayApp(options) {
1480
1494
  turnId: interaction.turnId ?? null,
1481
1495
  requestedAt: interaction.requestedAt ?? null,
1482
1496
  attention,
1497
+ ...(interaction.supervisorReport
1498
+ ? { supervisorReport: interaction.supervisorReport }
1499
+ : {}),
1483
1500
  }
1484
1501
  : null;
1485
1502
  },
@@ -8,7 +8,9 @@ export function buildResumeCommand(session) {
8
8
  if (!session.threadId)
9
9
  throw new Error('THREAD_REQUIRED');
10
10
  return [
11
- 'codex',
11
+ 'gestalt',
12
+ 'cli',
13
+ '--',
12
14
  'resume',
13
15
  session.threadId,
14
16
  '-C',
@@ -803,17 +803,22 @@ export class CodexSessionRuntime {
803
803
  return Promise.reject(new Error('CODEX_SERVER_REQUEST_DUPLICATE'));
804
804
  return new Promise((resolve, reject) => {
805
805
  resource.pendingRequests.set(requestId, { resolve, reject });
806
- let accepted = false;
806
+ const unsupported = () => {
807
+ if (resource.pendingRequests.delete(requestId))
808
+ reject(new Error('CODEX_SERVER_REQUEST_UNSUPPORTED'));
809
+ };
807
810
  try {
808
- accepted =
809
- this.onServerRequest?.(resource.sessionId, request, this.resolveNotificationOrigin(resource, request)) === true;
811
+ const accepted = this.onServerRequest?.(resource.sessionId, request, this.resolveNotificationOrigin(resource, request));
812
+ void Promise.resolve(accepted).then((value) => {
813
+ if (value !== true)
814
+ unsupported();
815
+ }, unsupported);
810
816
  }
811
817
  catch {
812
818
  // Publication failures are protocol failures, not permission to retain
813
819
  // an unreachable app-server request.
820
+ unsupported();
814
821
  }
815
- if (!accepted && resource.pendingRequests.delete(requestId))
816
- reject(new Error('CODEX_SERVER_REQUEST_UNSUPPORTED'));
817
822
  });
818
823
  }
819
824
  async startThread(process, session, skillsConfig, modelConfig = {}) {
@@ -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 { boundedAttentionReport } from '../../../shared/contracts/attention-report.js';
6
7
  export const autopilotAuditEventTypes = [
7
8
  'autopilot.turn-started',
8
9
  'autopilot.turn-failed',
@@ -89,6 +90,21 @@ export class SqliteEventJournal {
89
90
  payload: JSON.parse(row.payload_json),
90
91
  }));
91
92
  }
93
+ /** Same-turn root final only: never borrow another session, child, or commentary. */
94
+ attentionReport(sessionId, turnId, requestedAt) {
95
+ const row = this.db
96
+ .prepare(`
97
+ SELECT substr(json_extract(payload_json, '$.text'), 1, 4001) AS text
98
+ FROM session_events
99
+ WHERE session_id = ? AND type = 'agentMessageCompleted' AND occurred_at >= ?
100
+ AND json_extract(payload_json, '$.turnId') = ?
101
+ AND json_extract(payload_json, '$.phase') = 'final_answer'
102
+ AND json_type(payload_json, '$.text') = 'text'
103
+ ORDER BY sequence DESC LIMIT 1
104
+ `)
105
+ .get(sessionId, requestedAt, turnId);
106
+ return boundedAttentionReport(row?.text);
107
+ }
92
108
  /** Bounded chronological tail for redacted timeline projections. */
93
109
  tail(sessionId, limit) {
94
110
  const safeLimit = Math.max(1, Math.min(limit, 200));
@@ -0,0 +1,12 @@
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
+ /** Presentation context only; supervisor prose never changes control authority. */
7
+ export function boundedAttentionReport(value) {
8
+ if (typeof value !== 'string' || !value.trim())
9
+ return undefined;
10
+ const text = value.trim();
11
+ return text.length <= 4_000 ? text : `${text.slice(0, 3_999)}…`;
12
+ }
@@ -15,5 +15,6 @@ export const planSignalReasons = [
15
15
  export function isPlanSignalReason(value) {
16
16
  return (typeof value === 'string' &&
17
17
  (planSignalReasons.includes(value) ||
18
- /^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(value)));
18
+ /^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(value) ||
19
+ /^l2:[A-Za-z0-9._-]{1,128}:(WIP|DONE)$/.test(value)));
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.44.2",
3
+ "version": "0.44.3",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",