gestalt-mobile 0.53.0 → 0.54.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.
@@ -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-CcNWv_qG.js"></script>
20
- <link rel="stylesheet" crossorigin href="/assets/index-Dxg3mu2e.css">
19
+ <script type="module" crossorigin src="/assets/index-DhQ2D-7J.js"></script>
20
+ <link rel="stylesheet" crossorigin href="/assets/index-BRDqtTQi.css">
21
21
  </head>
22
22
  <body>
23
23
  <div id="app"></div>
@@ -6,7 +6,7 @@
6
6
  import { currentExecutableL1Index, } from '../../plans/domain/supervised-plan.js';
7
7
  import { parseOrgPlanAgentIdentity } from '../../../../shared/org-plan-position.js';
8
8
  export const AUTOPILOT_PROMPT_VERSION = 'v13';
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.';
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. */
12
12
  export function autopilotExecutorLaunchPrompt(identity) {
@@ -293,7 +293,20 @@ export class AutopilotCoordinator {
293
293
  return false;
294
294
  this.cancelWaitTimer(sessionId);
295
295
  this.parkedSubscriptions.delete(sessionId);
296
- this.persist({ ...state, supervision: nextProtocol, updatedAt: this.deps.now() });
296
+ const now = this.deps.now();
297
+ this.persist({ ...state, supervision: nextProtocol, updatedAt: now }, undefined, [
298
+ {
299
+ sessionId,
300
+ type: 'autopilot.wait-woken',
301
+ occurredAt: now,
302
+ payload: {
303
+ leaseId: wake.leaseId,
304
+ reportId: state.supervision.lastReportId,
305
+ wakeCondition: wake.condition,
306
+ resumeAt: state.supervision.waitLease?.resumeAt ?? null,
307
+ },
308
+ },
309
+ ]);
297
310
  this.evaluate(sessionId);
298
311
  return true;
299
312
  }
@@ -310,8 +323,33 @@ export class AutopilotCoordinator {
310
323
  }
311
324
  /** Bridges a completed root-owned background command into its one active wait episode. */
312
325
  rootProcessCompleted(sessionId, processId) {
313
- const lease = this.deps.store.find(sessionId)?.supervision?.waitLease;
314
- if (!lease || !processId || processId.length > 256)
326
+ if (!processId || processId.length > 256)
327
+ return false;
328
+ const state = this.deps.store.find(sessionId);
329
+ if (!state)
330
+ return false;
331
+ const lease = state.supervision?.waitLease;
332
+ const observedAt = this.deps.now();
333
+ // Record receipt even when an earlier deadline already consumed the lease.
334
+ // This is relay observation time, not an inferred process exit timestamp.
335
+ this.commit({
336
+ events: [
337
+ {
338
+ sessionId,
339
+ type: 'autopilot.root-process-observed',
340
+ occurredAt: observedAt,
341
+ payload: {
342
+ processId,
343
+ observedAt,
344
+ leaseId: lease?.id ?? null,
345
+ reportId: state.supervision?.lastReportId ?? null,
346
+ status: 'completed',
347
+ },
348
+ },
349
+ ],
350
+ });
351
+ this.flushOutbox(sessionId);
352
+ if (!lease)
315
353
  return false;
316
354
  const condition = lease.wakeConditions.includes('processResultAvailable')
317
355
  ? 'processResultAvailable'
@@ -496,7 +534,10 @@ export class AutopilotCoordinator {
496
534
  case 'observe':
497
535
  break;
498
536
  case 'reconcile':
499
- next = { ...prior, state: 'monitoring', nextEvaluationAt: null, updatedAt: now };
537
+ // Refreshing evidence does not start a new backoff episode. Retain the
538
+ // durable deadline so frequent reconciling/fresh observations cannot
539
+ // continually postpone the same scheduled control.
540
+ next = { ...prior, state: 'monitoring', updatedAt: now };
500
541
  if (!this.reconciling.has(sessionId)) {
501
542
  this.reconciling.add(sessionId);
502
543
  this.enqueue(sessionId, async () => {
@@ -564,6 +605,8 @@ export class AutopilotCoordinator {
564
605
  type: 'autopilot.continuation-scheduled',
565
606
  payload: {
566
607
  controlId: scheduledControlId,
608
+ reportId: prior.supervision?.lastReportId ?? null,
609
+ nextEvaluationAt: decision.at,
567
610
  ...(prior.checkpoints?.activeHandoffId
568
611
  ? { traceId: prior.checkpoints.activeHandoffId }
569
612
  : {}),
@@ -1196,11 +1239,54 @@ export class AutopilotCoordinator {
1196
1239
  return true;
1197
1240
  }
1198
1241
  persist(next, control, events = []) {
1242
+ const prior = this.deps.store.find(next.sessionId);
1243
+ const previousLease = prior?.supervision?.waitLease;
1244
+ const nextLease = next.supervision?.waitLease;
1245
+ const diagnostics = [];
1246
+ if (nextLease && nextLease.id !== previousLease?.id)
1247
+ diagnostics.push({
1248
+ sessionId: next.sessionId,
1249
+ type: 'autopilot.wait-registered',
1250
+ occurredAt: next.updatedAt,
1251
+ payload: {
1252
+ leaseId: nextLease.id,
1253
+ reportId: next.supervision?.lastReportId,
1254
+ resumeAt: nextLease.resumeAt ?? null,
1255
+ wakeConditions: nextLease.wakeConditions,
1256
+ },
1257
+ });
1258
+ if (previousLease &&
1259
+ previousLease.id !== nextLease?.id &&
1260
+ !events.some((event) => event.type === 'autopilot.wait-expired' || event.type === 'autopilot.wait-woken'))
1261
+ diagnostics.push({
1262
+ sessionId: next.sessionId,
1263
+ type: 'autopilot.wait-ended',
1264
+ occurredAt: next.updatedAt,
1265
+ payload: {
1266
+ leaseId: previousLease.id,
1267
+ reportId: prior?.supervision?.lastReportId,
1268
+ resumeAt: previousLease.resumeAt ?? null,
1269
+ reason: next.stopReason ?? 'superseded',
1270
+ state: next.state,
1271
+ },
1272
+ });
1273
+ if (control?.status === 'cancelled' &&
1274
+ this.deps.store.findControl(next.sessionId, control.controlId)?.status !== 'cancelled')
1275
+ diagnostics.push({
1276
+ sessionId: next.sessionId,
1277
+ type: 'autopilot.control-cancelled',
1278
+ occurredAt: next.updatedAt,
1279
+ payload: {
1280
+ controlId: control.controlId,
1281
+ reportId: prior?.supervision?.lastReportId ?? null,
1282
+ reason: next.stopReason ?? 'superseded',
1283
+ },
1284
+ });
1199
1285
  const snapshotEvents = this.snapshotEvents(next, control);
1200
1286
  this.commit({
1201
1287
  state: next,
1202
1288
  ...(control ? { control } : {}),
1203
- events: [...snapshotEvents, ...events],
1289
+ events: [...snapshotEvents, ...diagnostics, ...events],
1204
1290
  });
1205
1291
  this.storeRecoveryAttempts.delete(next.sessionId);
1206
1292
  if (snapshotEvents.length)
@@ -1239,9 +1325,19 @@ export class AutopilotCoordinator {
1239
1325
  return;
1240
1326
  }
1241
1327
  const session = this.deps.session(sessionId);
1328
+ const decision = this.decision(sessionId, current);
1329
+ if (!session?.activeTurnId &&
1330
+ !this.deps.pendingInteraction(sessionId) &&
1331
+ decision.kind === 'reconcile') {
1332
+ // The deadline can coincide with a roster refresh. Reconcile before
1333
+ // dispatch, preserving this control and its elapsed backoff. A fresh
1334
+ // result re-arms it; unavailable evidence uses the bounded watchdog.
1335
+ this.evaluate(sessionId);
1336
+ return;
1337
+ }
1242
1338
  if (session?.activeTurnId ||
1243
1339
  this.deps.pendingInteraction(sessionId) ||
1244
- this.decision(sessionId, current).kind !== 'scheduleContinuation') {
1340
+ decision.kind !== 'scheduleContinuation') {
1245
1341
  const now = this.deps.now();
1246
1342
  const cancelled = this.cancelScheduledControl(current, now);
1247
1343
  this.persist({
@@ -1404,7 +1500,15 @@ export class AutopilotCoordinator {
1404
1500
  return;
1405
1501
  }
1406
1502
  this.parkedSubscriptions.delete(sessionId);
1407
- this.persist({ ...state, supervision: protocol, updatedAt: this.deps.now() });
1503
+ const observedAt = this.deps.now();
1504
+ this.persist({ ...state, supervision: protocol, updatedAt: observedAt }, undefined, [
1505
+ {
1506
+ sessionId,
1507
+ type: 'autopilot.wait-expired',
1508
+ occurredAt: observedAt,
1509
+ payload: { leaseId, reportId: state.supervision.lastReportId, resumeAt, observedAt },
1510
+ },
1511
+ ]);
1408
1512
  this.evaluate(sessionId);
1409
1513
  }, Math.max(0, Date.parse(resumeAt) - Date.parse(this.deps.now()))));
1410
1514
  }
@@ -9,6 +9,13 @@ const relevant = /^(?:org-plan\.|autopilot\.|agent\.activity\.|session\.status\.
9
9
  const statusTypes = ['autopilot.updated', 'agent.activity.updated', 'session.status.updated'];
10
10
  // Export structural telemetry only. Event types alone do not imply payload safety.
11
11
  const diagnosticFields = new Set([
12
+ 'leaseId',
13
+ 'reportId',
14
+ 'resumeAt',
15
+ 'wakeCondition',
16
+ 'wakeConditions',
17
+ 'nextEvaluationAt',
18
+ 'processId',
12
19
  'traceId',
13
20
  'handoffId',
14
21
  'controlId',
@@ -84,7 +91,7 @@ function objectPayload(value) {
84
91
  }
85
92
  }
86
93
  function correlation(payload) {
87
- for (const key of ['traceId', 'handoffId', 'controlId', 'turnId', 'requestId'])
94
+ for (const key of ['traceId', 'handoffId', 'controlId', 'leaseId', 'turnId', 'requestId'])
88
95
  if (typeof payload[key] === 'string' && payload[key])
89
96
  return String(payload[key]);
90
97
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",
@@ -27,7 +27,8 @@
27
27
  "dist/client",
28
28
  "README.md",
29
29
  "LICENSE",
30
- "gestalt-supervision-capabilities.json"
30
+ "gestalt-supervision-capabilities.json",
31
+ "scripts/watch-github-run.mjs"
31
32
  ],
32
33
  "engines": {
33
34
  "node": ">=24.0.0"
@@ -0,0 +1,86 @@
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
+
7
+ import { execFile } from 'node:child_process';
8
+ import { promisify } from 'node:util';
9
+ import { pathToFileURL } from 'node:url';
10
+ import { setTimeout as sleep } from 'node:timers/promises';
11
+
12
+ const execute = promisify(execFile);
13
+
14
+ /** Emits structural observations only; timestamps distinguish polling from upstream updates. */
15
+ export async function watchGithubRun({
16
+ repository,
17
+ runId,
18
+ read = async () => {
19
+ const { stdout } = await execute(
20
+ 'gh',
21
+ ['run', 'view', runId, '--repo', repository, '--json', 'status,conclusion,updatedAt'],
22
+ { timeout: 60_000 },
23
+ );
24
+ return JSON.parse(stdout);
25
+ },
26
+ wait = () => sleep(30_000),
27
+ now = () => new Date().toISOString(),
28
+ write = (record) => process.stdout.write(`${JSON.stringify(record)}\n`),
29
+ }) {
30
+ if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repository) || !/^\d+$/.test(runId))
31
+ throw new Error('Expected repository owner/name and numeric run ID');
32
+ for (;;) {
33
+ let run;
34
+ try {
35
+ run = await read();
36
+ } catch {
37
+ write({ event: 'githubRunObservationFailed', observedAt: now(), runId });
38
+ return 1;
39
+ }
40
+ if (
41
+ !run ||
42
+ !['queued', 'in_progress', 'completed', 'waiting', 'requested', 'pending'].includes(
43
+ run.status,
44
+ )
45
+ ) {
46
+ write({ event: 'githubRunObservationFailed', observedAt: now(), runId });
47
+ return 1;
48
+ }
49
+ const conclusion = [
50
+ 'success',
51
+ 'failure',
52
+ 'cancelled',
53
+ 'timed_out',
54
+ 'action_required',
55
+ 'neutral',
56
+ 'skipped',
57
+ 'stale',
58
+ 'startup_failure',
59
+ ].includes(run.conclusion)
60
+ ? run.conclusion
61
+ : null;
62
+ write({
63
+ event: 'githubRunObserved',
64
+ observedAt: now(),
65
+ runId,
66
+ status: run.status,
67
+ conclusion,
68
+ upstreamUpdatedAt:
69
+ typeof run.updatedAt === 'string' && Number.isFinite(Date.parse(run.updatedAt))
70
+ ? new Date(run.updatedAt).toISOString()
71
+ : null,
72
+ });
73
+ if (run.status === 'completed') return conclusion === 'success' ? 0 : 1;
74
+ await wait();
75
+ }
76
+ }
77
+
78
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
79
+ const [repository, runId] = process.argv.slice(2);
80
+ try {
81
+ process.exitCode = await watchGithubRun({ repository, runId });
82
+ } catch {
83
+ process.stderr.write('Usage: node watch-github-run.mjs OWNER/REPO RUN_ID\n');
84
+ process.exitCode = 1;
85
+ }
86
+ }