orkestrator 2.37.3-beta → 2.37.4-beta

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.js CHANGED
@@ -527,12 +527,22 @@ var init_desktop = __esm(() => {
527
527
  denied: "A renderer asked for a permission the policy does not grant."
528
528
  }
529
529
  },
530
+ "desktop.webrequest": {
531
+ description: "Main-process webRequest listeners on Electron sessions. Listener names only; never a URL, header or error message.",
532
+ events: {
533
+ "listener.failed-closed": "A listener's decision threw or rejected, so it answered with its fail-closed response.",
534
+ "observer.failed": "A listener with no callback (a redirect observer) threw; its fallback ran.",
535
+ "callback.failed": "Electron's webRequest callback threw while a listener answered.",
536
+ ...THROTTLE_LOG_EVENTS
537
+ }
538
+ },
530
539
  "desktop.dialog": {
531
540
  description: "Native dialogs, whose modal loops hold the main thread while they are open.",
532
541
  events: {
533
542
  "attention-failed": "A dialog could not ask for the user's attention.",
534
543
  closed: "A native dialog closed.",
535
544
  "hidden-cancelled": "A hidden profile cancelled a dialog without opening native UI.",
545
+ "no-display-cancelled": "A headless Electron with no display cancelled a dialog instead of opening native UI.",
536
546
  "open-failed": "A dialog could not open; it was answered as cancelled.",
537
547
  opening: "A native dialog is opening.",
538
548
  "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
@@ -916,6 +926,7 @@ var init_native_agent = __esm(() => {
916
926
  "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
917
927
  "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
918
928
  "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
929
+ "monitor.silent": "The request monitor's stream stopped heartbeating, so it is replaced. `silenceMs` only.",
919
930
  "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
920
931
  "request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
921
932
  "credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why.",
@@ -938,6 +949,7 @@ var init_native_agent = __esm(() => {
938
949
  "host-server.terminate-failed": "A 2.x server that did not become ready could not be stopped; its process entry is kept for shutdown. Error class only.",
939
950
  "container-server.launched": "The start script of a container environment's 2.x server was run. Container port only.",
940
951
  "container-server.ready": "A container environment's 2.x server this backend started answered `/api/info` as 2.x. Environment id only.",
952
+ "container-server.cleanup-failed": "Cleanup after OpenCode startup failed; step names only, while the original startup error is preserved.",
941
953
  "container-server.warm-incomplete": "The first workspace request to a container's new 2.x server failed, so its plugins load on the next one. Error class only.",
942
954
  "resume-list.unavailable": "The 2.x sessions could not be listed for the resume picker, so it shows the 1.x list alone. Error class only.",
943
955
  "credential.mirrored": "A provider sign-in change was copied into the 2.x database. `outcome` (written, removed, unchanged, skipped) only; never a provider id or value.",
@@ -1188,6 +1200,7 @@ var init_tmux = __esm(() => {
1188
1200
  "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
1189
1201
  "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
1190
1202
  "cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
1203
+ "cleanup.kill-incomplete": "An environment's tmux sessions could not all be shown gone (a session survived, or the socket was unreachable while another tmux process might own it), so cleanup stays incomplete.",
1191
1204
  "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
1192
1205
  "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
1193
1206
  "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
@@ -1329,6 +1342,7 @@ var init_storage = __esm(() => {
1329
1342
  "config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
1330
1343
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
1331
1344
  "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
1345
+ "native-session-owners.backfill-failed": "Native-session rows could not be given their environment as owner at open; an environment delete then parses those rows instead, and the next open retries.",
1332
1346
  "lease.timed-out": "A waiter gave up on a lease; `lease` and `family` name it, `holderAgeMs` is the time since its holder's last heartbeat (null when the holder had just gone), `waitedMs` how long the waiter waited.",
1333
1347
  "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
1334
1348
  "scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
@@ -1382,6 +1396,7 @@ var init_build_pipeline = __esm(() => {
1382
1396
  "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
1383
1397
  "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
1384
1398
  "criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
1399
+ "completion-notes.publish-failed": "A finished pipeline's notes tab could not be added to the layout; the run stays complete.",
1385
1400
  "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
1386
1401
  "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
1387
1402
  "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
@@ -1431,6 +1446,8 @@ var init_change_tracking = __esm(() => {
1431
1446
  "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
1432
1447
  "turn.finalize-failed": "Finalizing a turn failed.",
1433
1448
  "turn.settle-failed": "Settling a late interrupted turn failed.",
1449
+ "turn.end-recovery": "A background retry of a turn end capture that timed out finished: recovered, done (no longer eligible) or exhausted.",
1450
+ "turn.end-recovery-failed": "A background retry of a turn end capture threw; it counts as a failed attempt.",
1434
1451
  "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
1435
1452
  "measurement.failed": "Recomputing a tool's measurement failed."
1436
1453
  }
@@ -1503,6 +1520,7 @@ var init_coordinator = __esm(() => {
1503
1520
  "node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
1504
1521
  "node-offline.notice-failed": "The notice that a node has been unreachable for a day could not be sent; the next failed read retries.",
1505
1522
  "node-offline.check-failed": "Whether a long-unreachable node's coordinators were told could not be checked; the next read retries.",
1523
+ "node-reconnect.notice-failed": "The message that a node a coordinator tried while it was disconnected is back could not be sent; it is not retried, since the coordinator already holds the refusal.",
1506
1524
  "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1507
1525
  "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1508
1526
  "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded (`fast-forwarded-fetched` when the fetch was slow or failed and the upstream commit already fetched was merged), or `outcome` says why not (`timed-out`, `failed`).",
@@ -1559,7 +1577,8 @@ var init_review = __esm(() => {
1559
1577
  "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
1560
1578
  "monitor.merged-tickets-closed": "The startup sweep moved Kanban tickets whose pull request had merged to done (`count`).",
1561
1579
  "monitor.merged-tickets-close-failed": "The startup sweep closing Kanban tickets whose pull request merged failed; the next backend start retries.",
1562
- "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
1580
+ "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink.",
1581
+ "branch-cleanup.kept": "A merge or cleanup kept a pull request's head branch because it is not the branch created for the environment (`reason`)."
1563
1582
  }
1564
1583
  }
1565
1584
  });
@@ -1599,6 +1618,8 @@ var init_agent_accounts = __esm(() => {
1599
1618
  "kept-note.failed": "Recording why a limit stop found no account to move to failed; the stop stands.",
1600
1619
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1601
1620
  "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1621
+ "shared-usage.save-failed": "The shared usage readings could not be saved; they stay in memory and the next reading saves them.",
1622
+ "shared-usage.record-failed": "A fresh usage reading could not be kept for sharing with other machines; the account's own reading stands.",
1602
1623
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1603
1624
  "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1604
1625
  "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
@@ -1620,6 +1641,7 @@ var init_docker = __esm(() => {
1620
1641
  "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
1621
1642
  "git-mirror.mount-withheld": "A new restricted container gets no project Git mirror because its firewall would not let it reach the project's remote, so it cannot read what the remote serves through the mirror either.",
1622
1643
  "git-mirror.refreshed": "A project's Git mirror was built or updated.",
1644
+ "git-mirror.access-changed": "A project's Git mirror was withdrawn because containers are now given a different credential (another access kind, or a token acting as another or an unreadable account), so no reader keeps what it could not fetch itself.",
1623
1645
  "git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
1624
1646
  "git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
1625
1647
  "git-mirror.refresh-failed": "A project's Git mirror could not be updated. New clones still work, from the mirror as it was or from the remote.",
@@ -1633,6 +1655,9 @@ var init_docker = __esm(() => {
1633
1655
  "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
1634
1656
  "project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
1635
1657
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1658
+ "opencode.listener-replaced": "The process on a container's OpenCode port (`provider`: `opencode` or `opencode2`) is not the server the backend launched and recorded, so its password was withheld and the next start replaces it. `stage` is `request` when the re-check after a refused connection or an unexpected answer found it (to-do 7550); that connection then sends nothing more.",
1659
+ "opencode.project-config-too-large": "A checkout's opencode.json or opencode.jsonc was larger than the limit, so a launched OpenCode server does not read it. File name only.",
1660
+ "opencode.project-config-filtered": "Values were left out of a checkout's OpenCode configuration before a launched server reads it (to-do 7550): counts of plugin keys, `{env:}` and `{file:}` references and dropped instructions (including separate instructionGlob and instructionUrl counts), and the names of files that were not a JSONC object. Never values.",
1636
1661
  "log-driver.unbounded": "The Docker daemon offers neither the local nor the json-file log driver, so new containers keep its default driver, whose log may be uncapped. Written once per backend.",
1637
1662
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1638
1663
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
@@ -1667,6 +1692,17 @@ var init_docker = __esm(() => {
1667
1692
  description: "A bridge process was launched in a container, for the first time there or as a relaunch; `provider` names it. A relaunch keeps the run before it in the previous log.",
1668
1693
  essential: true,
1669
1694
  fields: { provider: "label", containerPort: "number" }
1695
+ },
1696
+ "bridge.listener-refused": {
1697
+ description: "The socket listening on a container bridge's port is not the one the bridge the backend started opened (to-do 7250), so its token is not handed out and the next start replaces it. `reason` is a fixed label: `different-socket`, `several-sockets`, `pending` (a start has not recorded its bridge yet, or failed before it did) or `scan-incomplete`.",
1698
+ essential: true,
1699
+ fields: { provider: "label", reason: "label" }
1700
+ },
1701
+ "bridge.listener-adopted": "A running container bridge had no listener record, because a backend from before the record started it, so the socket on its port was recorded as the bridge's; `provider` names it.",
1702
+ "bridge.listener-unrecorded": {
1703
+ description: "A bridge the backend just launched could not be recorded as its port's listener, for the fixed `reason` given (`no-listener`, `several-sockets`, `launch-exited` or `scan-incomplete`); what listens on the port is stopped and the start fails.",
1704
+ essential: true,
1705
+ fields: { provider: "label", reason: "label" }
1670
1706
  }
1671
1707
  }
1672
1708
  },
@@ -1725,7 +1761,8 @@ var init_mcp = __esm(() => {
1725
1761
  "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
1726
1762
  "state-listener.failed": "A Control MCP state listener threw; the others still run.",
1727
1763
  "delegation.remote-open-failed": "A delegation could not be opened on another node.",
1728
- "delegation.open-failed": "A coordinator delegation could not be opened."
1764
+ "delegation.open-failed": "A coordinator delegation could not be opened.",
1765
+ "delegation.turn-origin-unreadable": "A coordinator's last turn origin could not be read, so its delegated prompt is marked as arising from agent mail."
1729
1766
  }
1730
1767
  },
1731
1768
  "mcp-management": {
@@ -1822,6 +1859,7 @@ var init_nodes = __esm(() => {
1822
1859
  "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1823
1860
  "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1824
1861
  "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released.",
1862
+ "usage-sync.failed": "Sharing usage readings with a node failed; the next reading or reconnect retries.",
1825
1863
  "fleet-update.requested": "The update policy asked an older leaf to install the command node's version.",
1826
1864
  "fleet-update.failed": "The update policy could not read or update a leaf; it retries later.",
1827
1865
  "fleet-update.policy-load-failed": "The stored update policy could not be read; it is off."
@@ -1938,6 +1976,24 @@ var init_scheduler = __esm(() => {
1938
1976
  });
1939
1977
  });
1940
1978
 
1979
+ // ../protocol/src/log-vocabulary/self-improvement.ts
1980
+ var SELF_IMPROVEMENT_LOG_AREAS;
1981
+ var init_self_improvement = __esm(() => {
1982
+ init_define();
1983
+ SELF_IMPROVEMENT_LOG_AREAS = defineLogAreas({
1984
+ "self-improvement": {
1985
+ description: "Self-improvement runs: diagnostics and conversation review turned into tickets. Counts and steps only, never conversation text.",
1986
+ events: {
1987
+ "run.started": "A run started; `trigger` is manual, daily or dry-run.",
1988
+ "run.finished": "A run finished; `created`, `verified`, `fixFailed` and `parts` count its tickets, confirmed fixes, failed fixes and conversation parts read.",
1989
+ "run.failed": "A run stopped before it finished; `reason` is a fixed label.",
1990
+ "review.call-failed": "One conversation review call failed; the run carries on and the part is read again next run.",
1991
+ "daily.check-failed": "The daily run check failed; the next check retries."
1992
+ }
1993
+ }
1994
+ });
1995
+ });
1996
+
1941
1997
  // ../protocol/src/log-vocabulary/web-app.ts
1942
1998
  var WEB_APP_LOG_AREAS;
1943
1999
  var init_web_app = __esm(() => {
@@ -2316,6 +2372,10 @@ var init_web_settings = __esm(() => {
2316
2372
  "web.settings": {
2317
2373
  description: "The settings screens.",
2318
2374
  events: {
2375
+ "self-improvement.status-failed": "Settings \u2192 Self-improvement could not read the status.",
2376
+ "self-improvement.projects-failed": "Settings \u2192 Self-improvement could not list the projects.",
2377
+ "self-improvement.save-failed": "Settings \u2192 Self-improvement could not save a setting.",
2378
+ "self-improvement.run-failed": "Settings \u2192 Self-improvement could not start a run.",
2319
2379
  "config.save-failed": "Global settings could not be saved.",
2320
2380
  "config.load-failed": "The settings page could not load the config.",
2321
2381
  "config.reload-failed": "Re-reading the workspace config after a save failed.",
@@ -2498,6 +2558,7 @@ var init_log_vocabulary = __esm(() => {
2498
2558
  init_host();
2499
2559
  init_transcript_artifacts();
2500
2560
  init_scheduler();
2561
+ init_self_improvement();
2501
2562
  init_web_app();
2502
2563
  init_web_build_pipeline();
2503
2564
  init_web_chat();
@@ -2550,6 +2611,7 @@ var init_log_vocabulary = __esm(() => {
2550
2611
  ...HOST_LOG_AREAS,
2551
2612
  ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
2552
2613
  ...SCHEDULER_LOG_AREAS,
2614
+ ...SELF_IMPROVEMENT_LOG_AREAS,
2553
2615
  ...WEB_APP_LOG_AREAS,
2554
2616
  ...WEB_BUILD_PIPELINE_LOG_AREAS,
2555
2617
  ...WEB_CHAT_LOG_AREAS,
@@ -2570,7 +2632,7 @@ var init_log_vocabulary = __esm(() => {
2570
2632
  var init_renderer_errors = () => {};
2571
2633
 
2572
2634
  // ../protocol/src/log-essential-labels.ts
2573
- var ERROR_NAMES, ERROR_CODES, SYSCALLS, SIGNALS, PROVIDERS, UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", SOURCE, STORAGE_DATABASES, STORAGE_OPERATIONS, TRANSACTION_MODES, STORAGE_TABLES;
2635
+ var ERROR_NAMES, ERROR_CODES, SYSCALLS, SIGNALS, PROVIDERS, BRIDGE_LISTENER_REASONS, UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", SOURCE, STORAGE_DATABASES, STORAGE_OPERATIONS, TRANSACTION_MODES, STORAGE_TABLES;
2574
2636
  var init_log_essential_labels = __esm(() => {
2575
2637
  init_log_vocabulary();
2576
2638
  init_renderer_errors();
@@ -2679,6 +2741,14 @@ var init_log_essential_labels = __esm(() => {
2679
2741
  "SIGXFSZ"
2680
2742
  ]);
2681
2743
  PROVIDERS = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
2744
+ BRIDGE_LISTENER_REASONS = new Set([
2745
+ "different-socket",
2746
+ "several-sockets",
2747
+ "pending",
2748
+ "scan-incomplete",
2749
+ "no-listener",
2750
+ "launch-exited"
2751
+ ]);
2682
2752
  SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
2683
2753
  STORAGE_DATABASES = new Set(["main", "ledger", "other"]);
2684
2754
  STORAGE_OPERATIONS = new Set([
@@ -11238,6 +11308,30 @@ var PUBLIC_ACTIONS = {
11238
11308
  milestone: "C",
11239
11309
  summary: "Fork the conversation into a new public session."
11240
11310
  },
11311
+ "session.rewind": {
11312
+ version: 1,
11313
+ mutation: true,
11314
+ effects: ["provider-session"],
11315
+ observation: "receipt",
11316
+ milestone: "C",
11317
+ summary: "Rewind the conversation to before one of its prompts (Codex, Pi, Cursor)."
11318
+ },
11319
+ "session.branches": {
11320
+ version: 1,
11321
+ mutation: false,
11322
+ effects: [],
11323
+ observation: "immediate",
11324
+ milestone: "C",
11325
+ summary: "List the conversation's other branches, such as turns a rewind removed (Pi)."
11326
+ },
11327
+ "session.branch": {
11328
+ version: 1,
11329
+ mutation: true,
11330
+ effects: ["provider-session"],
11331
+ observation: "receipt",
11332
+ milestone: "C",
11333
+ summary: "Switch the conversation to another of its branches (Pi)."
11334
+ },
11241
11335
  "session.interactions": {
11242
11336
  version: 1,
11243
11337
  mutation: false,
@@ -11870,6 +11964,22 @@ var PUBLIC_ACTIONS = {
11870
11964
  milestone: "D",
11871
11965
  summary: "Read one piece of a planned diagnostics bundle. Nothing is uploaded."
11872
11966
  },
11967
+ "self-improvement.status": {
11968
+ version: 1,
11969
+ mutation: false,
11970
+ effects: [],
11971
+ observation: "immediate",
11972
+ milestone: "D",
11973
+ summary: "Read self-improvement's settings, the run in progress, the last run's summary, tracked tickets and conversation themes."
11974
+ },
11975
+ "self-improvement.run": {
11976
+ version: 1,
11977
+ mutation: true,
11978
+ effects: ["metadata", "process"],
11979
+ observation: "receipt",
11980
+ milestone: "D",
11981
+ summary: "Start a self-improvement run in the background: diagnostics and, when on, the conversation review, filed as tickets. dryRun reports without filing or calling a model."
11982
+ },
11873
11983
  "host.status": {
11874
11984
  version: 1,
11875
11985
  mutation: false,
@@ -12950,6 +13060,8 @@ var CLAUDE_PINNED_RUNTIME_ENV = Object.freeze({
12950
13060
  DISABLE_AUTOUPDATER: "1",
12951
13061
  FORCE_AUTOUPDATE_PLUGINS: "1"
12952
13062
  });
13063
+ var QUOTED_ARG = String.raw`"((?:[^"\\]|\\[\\"$\x60])*)"`;
13064
+ var OPENCODE_LAUNCH_PATTERN = new RegExp("^" + Object.entries(OPENCODE_PINNED_RUNTIME_ENV).map(([name, value]) => `${name}=${value} `).join("") + `opencode(?: --model ${QUOTED_ARG})?(?: --prompt ${QUOTED_ARG})?(\\r?\\n)?$`);
12953
13065
 
12954
13066
  // src/client/fix.ts
12955
13067
  init_layout();
@@ -13123,7 +13235,7 @@ import path5 from "path";
13123
13235
  // ../../apps/backend/package.json
13124
13236
  var package_default = {
13125
13237
  name: "@orkestrator/backend",
13126
- version: "2.37.3-beta",
13238
+ version: "2.37.4-beta",
13127
13239
  private: true,
13128
13240
  type: "module",
13129
13241
  exports: {
@@ -13905,6 +14017,11 @@ var BACKGROUND_CAPABLE_SHELL_TOOL_NAMES = new Set([
13905
14017
  "run_terminal_cmd",
13906
14018
  "execute_command"
13907
14019
  ]);
14020
+ var NATIVE_AGENT_BRANCH_LIST_LIMITS = Object.freeze({
14021
+ branches: 50,
14022
+ promptChars: 280,
14023
+ entryIdChars: 512
14024
+ });
13908
14025
  var DEFAULT_NATIVE_AGENT_LIVE_WINDOW = {
13909
14026
  messages: 100,
13910
14027
  targetBytes: 512 * 1024
@@ -14815,6 +14932,9 @@ function defaultSleep(ms, signal) {
14815
14932
  signal?.addEventListener("abort", done, { once: true });
14816
14933
  });
14817
14934
  }
14935
+ function observationClock(io) {
14936
+ return io.sleep ? { sleep: io.sleep.bind(io), now: () => io.now() } : {};
14937
+ }
14818
14938
  function signalName(signal) {
14819
14939
  return signal?.reason === "SIGTERM" ? "SIGTERM" : "SIGINT";
14820
14940
  }
@@ -14923,7 +15043,11 @@ async function submitForWait(context, action, input, options2, timeoutMs) {
14923
15043
  return { done: false };
14924
15044
  throw lookup;
14925
15045
  }
14926
- }, { timeoutMs: Math.max(0, deadline - Date.now()), signal: context.signal });
15046
+ }, {
15047
+ timeoutMs: Math.max(0, deadline - Date.now()),
15048
+ signal: context.signal,
15049
+ ...observationClock(context.io)
15050
+ });
14927
15051
  } catch (lookup) {
14928
15052
  const stopped = context.signal?.aborted ? new ObservationStopped("signal", signalName(context.signal)) : lookup;
14929
15053
  if (stopped instanceof ObservationStopped && stopped.reason === "deadline")
@@ -15007,7 +15131,7 @@ async function waitForOperation(context, session, initial, timeoutMs, options2 =
15007
15131
  });
15008
15132
  }
15009
15133
  return { done: false };
15010
- }, { timeoutMs, signal: context.signal });
15134
+ }, { timeoutMs, signal: context.signal, ...observationClock(context.io) });
15011
15135
  } catch (error) {
15012
15136
  if (error instanceof ObservationStopped) {
15013
15137
  throw stoppedError(error, latest.action, latest, "the operation");
@@ -15076,7 +15200,7 @@ async function waitForEnvironment(context, session, environmentId, condition, re
15076
15200
  };
15077
15201
  }
15078
15202
  return { done: false };
15079
- }, { timeoutMs, signal: context.signal });
15203
+ }, { timeoutMs, signal: context.signal, ...observationClock(context.io) });
15080
15204
  } catch (error) {
15081
15205
  const stopped = context.signal?.aborted ? new ObservationStopped("signal", signalName(context.signal)) : Date.now() >= deadline && error instanceof CliError && error.code === "connection-failed" ? new ObservationStopped("deadline") : error;
15082
15206
  if (stopped instanceof ObservationStopped) {
@@ -15186,7 +15310,8 @@ var attentionCommands = [
15186
15310
  return { done: false };
15187
15311
  }, {
15188
15312
  timeoutMs: parsed.options.timeout ?? DEFAULT_WAIT_MS,
15189
- signal: context.signal
15313
+ signal: context.signal,
15314
+ ...observationClock(context.io)
15190
15315
  });
15191
15316
  } catch (error) {
15192
15317
  if (!(error instanceof ObservationStopped))
@@ -22209,6 +22334,83 @@ var sessionCommands = [
22209
22334
  };
22210
22335
  }
22211
22336
  },
22337
+ {
22338
+ path: ["session", "rewind"],
22339
+ action: "session.rewind",
22340
+ inputFields: { message: "messageId" },
22341
+ summary: "Rewind the conversation to before one of its prompts (Codex, Pi, Cursor).",
22342
+ description: "Removes that prompt, its response and every later turn from the conversation. Files are not reverted. Codex and Cursor cannot bring the turns back; Pi keeps them as a branch (`session branches`).",
22343
+ positionals: [{ name: "session", required: true }],
22344
+ options: [
22345
+ {
22346
+ name: "message",
22347
+ kind: "string",
22348
+ valueName: "MESSAGE_ID",
22349
+ description: "Required. A prompt (user message) ID from `session transcript`."
22350
+ },
22351
+ REQUEST_ID_OPTION
22352
+ ],
22353
+ async run(context, parsed) {
22354
+ if (typeof parsed.options.message !== "string" || !parsed.options.message) {
22355
+ throw new CliError("invalid-input", "--message is required");
22356
+ }
22357
+ const { session, result, receipt, warnings } = await submit(context, "session.rewind", { sessionId: parsed.positionals.session, messageId: parsed.options.message }, parsed.options);
22358
+ return {
22359
+ action: "session.rewind",
22360
+ result,
22361
+ receipt,
22362
+ warnings,
22363
+ connection: session.identity,
22364
+ human: [`rewound to before ${String(parsed.options.message)}`]
22365
+ };
22366
+ }
22367
+ },
22368
+ {
22369
+ path: ["session", "branches"],
22370
+ action: "session.branches",
22371
+ summary: "List the conversation's other branches, such as turns a rewind removed (Pi).",
22372
+ positionals: [{ name: "session", required: true }],
22373
+ options: [],
22374
+ idOutput: "branch entry IDs, one per line",
22375
+ async run(context, parsed) {
22376
+ const session = await context.session();
22377
+ const branches = await session.read("session.branches", { sessionId: parsed.positionals.session });
22378
+ return {
22379
+ action: "session.branches",
22380
+ result: branches,
22381
+ connection: session.identity,
22382
+ ids: branches.items.map((item) => item.id),
22383
+ human: table(["ENTRY ID", "PROMPT", "ENTRIES", "UPDATED"], branches.items.map((item) => [
22384
+ item.id,
22385
+ item.prompt,
22386
+ String(item.entries),
22387
+ String(item.updatedAt ?? "")
22388
+ ]))
22389
+ };
22390
+ }
22391
+ },
22392
+ {
22393
+ path: ["session", "branch"],
22394
+ action: "session.branch",
22395
+ summary: "Switch the conversation to another branch from `session branches` (Pi).",
22396
+ description: "The branch being left is kept and listed by `session branches`.",
22397
+ positionals: [
22398
+ { name: "session", required: true },
22399
+ { name: "entry-id", required: true }
22400
+ ],
22401
+ options: [REQUEST_ID_OPTION],
22402
+ async run(context, parsed) {
22403
+ const { session, result, receipt, warnings } = await submit(context, "session.branch", { sessionId: parsed.positionals.session, entryId: parsed.positionals["entry-id"] }, parsed.options);
22404
+ return {
22405
+ action: "session.branch",
22406
+ result,
22407
+ receipt,
22408
+ warnings,
22409
+ connection: session.identity,
22410
+ human: [`switched to branch ${parsed.positionals["entry-id"]}`]
22411
+ };
22412
+ }
22413
+ },
22212
22414
  {
22213
22415
  path: ["session", "interactions", "list"],
22214
22416
  action: "session.interactions",
@@ -22240,7 +22442,7 @@ var sessionCommands = [
22240
22442
  action: "session.interaction.resolve",
22241
22443
  inputFields: { revision: "expectedRevision", choose: "answers", text: "answers" },
22242
22444
  summary: "Answer one pending interaction at its current revision.",
22243
- description: "--revision must match the interaction's current revision; a replaced or expired interaction is refused (exit 8), never answered. Nothing is approved implicitly.",
22445
+ description: "--revision must match the interaction's current revision; a replaced or expired interaction is refused (exit 8), never answered. Nothing is approved implicitly. --action answer without --choose or --text approves an approval that has no questions; the backend refuses it for an interaction with a required question (exit 2).",
22244
22446
  positionals: [
22245
22447
  { name: "session", required: true },
22246
22448
  { name: "interaction", required: true }
@@ -22284,9 +22486,6 @@ var sessionCommands = [
22284
22486
  throw new CliError("invalid-input", "--revision is required");
22285
22487
  const action = oneOf(options2.action, ["answer", "approve-for-session", "decline", "deny", "cancel"], "--action");
22286
22488
  const answers = parseAnswers(options2);
22287
- if (action === "answer" && answers.length === 0) {
22288
- throw new CliError("invalid-input", "--action answer needs --choose or --text");
22289
- }
22290
22489
  if (action !== "answer" && answers.length > 0) {
22291
22490
  throw new CliError("invalid-input", "--choose/--text only apply to --action answer");
22292
22491
  }
@@ -22446,7 +22645,8 @@ var sessionCommands = [
22446
22645
  return { done: false };
22447
22646
  }, {
22448
22647
  timeoutMs: parsed.options.timeout ?? DEFAULT_WAIT_MS,
22449
- signal: context.signal
22648
+ signal: context.signal,
22649
+ ...observationClock(context.io)
22450
22650
  });
22451
22651
  } catch (error) {
22452
22652
  if (!(error instanceof ObservationStopped))
@@ -25840,6 +26040,145 @@ var diagnosticsCommands = [
25840
26040
  }
25841
26041
  ];
25842
26042
 
26043
+ // src/client/commands/self-improvement.ts
26044
+ var POLL_MS = 3000;
26045
+ var WAIT_LIMIT_MS = 60 * 60 * 1000;
26046
+ function runLines(run) {
26047
+ const refs = (items) => items.map((item) => `#${item.ticket} ${item.signature}`).join("; ");
26048
+ const lines = [
26049
+ `${run.trigger === "dry-run" ? "Preview" : run.trigger === "daily" ? "Daily run" : "Run"} ${run.outcome} at ${run.finishedAt}`
26050
+ ];
26051
+ if (run.error)
26052
+ lines.push(` ${run.error}`);
26053
+ for (const item of run.created)
26054
+ lines.push(` new ticket #${item.ticket}: ${item.title}`);
26055
+ for (const item of run.wouldCreate)
26056
+ lines.push(` would file: ${item.title}`);
26057
+ if (run.verified.length)
26058
+ lines.push(` fixed and confirmed: ${refs(run.verified)}`);
26059
+ if (run.fixFailed.length) {
26060
+ lines.push(` fix did not work, back to the backlog: ${refs(run.fixFailed)}`);
26061
+ }
26062
+ if (run.partly.length)
26063
+ lines.push(` partly better, your call: ${refs(run.partly)}`);
26064
+ if (run.markedFixed.length)
26065
+ lines.push(` done on the board, now checking: ${refs(run.markedFixed)}`);
26066
+ if (run.conversations.enabled) {
26067
+ lines.push(` conversations: read ${run.conversations.read}, ${run.conversations.notesAdded} new notes, ${run.conversations.themes} themes, about $${run.conversations.costUsd.toFixed(2)} at list prices`);
26068
+ }
26069
+ for (const error of run.conversations.errors)
26070
+ lines.push(` conversation review: ${error}`);
26071
+ return lines;
26072
+ }
26073
+ function statusLines(status) {
26074
+ const lines = [
26075
+ `Self-improvement: ${status.enabled ? "on" : "off (Settings \u2192 Experimental)"}`,
26076
+ `Project: ${status.project?.name ?? "not chosen (Settings \u2192 Self-improvement)"}`,
26077
+ `Conversation review: ${status.settings.conversationReview ? "on" : "off"}; daily run: ${status.settings.dailyRun ? `on, next ${status.nextDailyRunAt ?? "when due"}` : "off"}`
26078
+ ];
26079
+ if (status.running)
26080
+ lines.push(`Running: ${status.running.step}, started ${status.running.startedAt}`);
26081
+ if (status.lastRun)
26082
+ lines.push("", ...runLines(status.lastRun));
26083
+ if (status.tracked.length > 0) {
26084
+ lines.push("", "Tracked:");
26085
+ for (const item of status.tracked) {
26086
+ lines.push(` ${item.ticket ? `#${item.ticket}` : "-"} ${item.status} ${item.verdict ?? ""} ${item.title}`);
26087
+ }
26088
+ }
26089
+ return lines;
26090
+ }
26091
+ var selfImprovementCommands = [
26092
+ {
26093
+ path: ["self-improvement", "status"],
26094
+ action: "self-improvement.status",
26095
+ summary: "Show self-improvement's settings, the last run, tracked tickets and themes.",
26096
+ positionals: [],
26097
+ options: [],
26098
+ async run(context) {
26099
+ const session = await context.session();
26100
+ const status = await session.read("self-improvement.status", {});
26101
+ return {
26102
+ action: "self-improvement.status",
26103
+ result: status,
26104
+ connection: session.identity,
26105
+ human: statusLines(status)
26106
+ };
26107
+ }
26108
+ },
26109
+ {
26110
+ path: ["self-improvement", "run"],
26111
+ action: "self-improvement.run",
26112
+ summary: "Start a self-improvement run (experimental); --wait follows it to the end.",
26113
+ description: "Exports this machine's diagnostics, reviews conversations when that is on, and files what it finds on the chosen project's board. --dry-run reports what it would file without filing it or calling a model.",
26114
+ positionals: [],
26115
+ options: [
26116
+ {
26117
+ name: "dry-run",
26118
+ kind: "boolean",
26119
+ description: "Report without filing or calling a model."
26120
+ },
26121
+ {
26122
+ name: "wait",
26123
+ kind: "boolean",
26124
+ description: "Wait for the run to finish and print its summary."
26125
+ },
26126
+ REQUEST_ID_OPTION
26127
+ ],
26128
+ async run(context, parsed) {
26129
+ const dryRun = optionalBoolean(parsed.options, "dry-run") === true;
26130
+ const { session, result, receipt, warnings } = await submit(context, "self-improvement.run", dryRun ? { dryRun: true } : {}, parsed.options);
26131
+ if (optionalBoolean(parsed.options, "wait") !== true) {
26132
+ return {
26133
+ action: "self-improvement.run",
26134
+ result,
26135
+ receipt,
26136
+ warnings,
26137
+ connection: session.identity,
26138
+ human: [
26139
+ `Started ${dryRun ? "a preview" : "a run"}; see it with \`orkestrator self-improvement status\`.`
26140
+ ]
26141
+ };
26142
+ }
26143
+ const startedAt = typeof result.startedAt === "string" ? result.startedAt : null;
26144
+ const ours = (startedAtOfRun) => startedAt === null || startedAtOfRun === startedAt;
26145
+ const deadline = Date.now() + WAIT_LIMIT_MS;
26146
+ let status = await session.read("self-improvement.status", {});
26147
+ while (status.running && ours(status.running.startedAt)) {
26148
+ if (Date.now() > deadline) {
26149
+ throw new CliError("deadline-exceeded", "The run is still going; check it with `self-improvement status`.");
26150
+ }
26151
+ await new Promise((resolve) => setTimeout(resolve, POLL_MS));
26152
+ status = await session.read("self-improvement.status", {});
26153
+ }
26154
+ const lastRun = status.lastRun && ours(status.lastRun.startedAt) ? status.lastRun : null;
26155
+ if (!lastRun) {
26156
+ return {
26157
+ action: "self-improvement.run",
26158
+ result: { ...result, lastRun: null },
26159
+ receipt,
26160
+ warnings,
26161
+ connection: session.identity,
26162
+ human: [
26163
+ "This request's run is no longer the last one; see `orkestrator self-improvement status`."
26164
+ ]
26165
+ };
26166
+ }
26167
+ if (lastRun.outcome === "failed") {
26168
+ throw new CliError("run-failed", `The self-improvement run failed: ${lastRun.error ?? "see self-improvement status"}`, { receipt, details: { startedAt: lastRun.startedAt } });
26169
+ }
26170
+ return {
26171
+ action: "self-improvement.run",
26172
+ result: { ...result, lastRun },
26173
+ receipt,
26174
+ warnings,
26175
+ connection: session.identity,
26176
+ human: runLines(lastRun)
26177
+ };
26178
+ }
26179
+ }
26180
+ ];
26181
+
25843
26182
  // src/client/commands/completion.ts
25844
26183
  var SHELLS2 = ["bash", "zsh", "fish"];
25845
26184
  function flagsOf(options2) {
@@ -28118,7 +28457,7 @@ async function waitForReceipt(context, session, receipt, limit, action) {
28118
28457
  return { done: false };
28119
28458
  throw error;
28120
28459
  }
28121
- }, { timeoutMs: limit, signal: context.signal });
28460
+ }, { timeoutMs: limit, signal: context.signal, ...observationClock(context.io) });
28122
28461
  } catch (error) {
28123
28462
  if (error instanceof ObservationStopped)
28124
28463
  throw stopped(error, action, receipt);
@@ -28213,7 +28552,7 @@ var hostCommands = [
28213
28552
  host = await observe(async () => {
28214
28553
  const latest = await readHost(session);
28215
28554
  return latest.checkRequest?.id === requestId ? { done: false } : { done: true, value: latest };
28216
- }, { timeoutMs: limit, signal: context.signal });
28555
+ }, { timeoutMs: limit, signal: context.signal, ...observationClock(context.io) });
28217
28556
  } catch (error) {
28218
28557
  if (error instanceof ObservationStopped) {
28219
28558
  throw stopped(error, "host.update.check", receipt);
@@ -30428,7 +30767,7 @@ async function waitForGoal(context, session, sessionId, goalId, timeoutMs, optio
30428
30767
  ...receiptOption,
30429
30768
  details: goalDetails(sessionId, verdict.goal)
30430
30769
  });
30431
- }, { timeoutMs, signal: context.signal });
30770
+ }, { timeoutMs, signal: context.signal, ...observationClock(context.io) });
30432
30771
  } catch (error) {
30433
30772
  if (!(error instanceof ObservationStopped))
30434
30773
  throw error;
@@ -32330,6 +32669,7 @@ var CLIENT_COMMANDS = [
32330
32669
  ...toolchainCommands,
32331
32670
  ...hostCommands,
32332
32671
  ...diagnosticsCommands,
32672
+ ...selfImprovementCommands,
32333
32673
  ...serviceCommands,
32334
32674
  ...completionCommands(() => CLIENT_COMMANDS)
32335
32675
  ];