jg-agent-hq 10.7.0 → 10.9.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/api/README.md +33 -26
  4. package/dist/actions/actions.js +4 -0
  5. package/dist/actions/live/live.d.ts +14 -0
  6. package/dist/actions/live/live.js +40 -2
  7. package/dist/actions/reads.js +7 -1
  8. package/dist/contracts/browser/types.d.ts +1 -0
  9. package/dist/contracts/types.d.ts +29 -0
  10. package/dist/contracts/types.js +10 -1
  11. package/dist/providers/claude/agents/agents.d.ts +14 -10
  12. package/dist/providers/claude/agents/agents.js +67 -5
  13. package/dist/providers/claude/agents/index.d.ts +1 -0
  14. package/dist/providers/claude/agents/types.d.ts +19 -0
  15. package/dist/providers/claude/agents/types.js +2 -0
  16. package/dist/providers/claude/background/background.d.ts +11 -0
  17. package/dist/providers/claude/background/background.js +175 -0
  18. package/dist/providers/claude/background/constants.d.ts +9 -0
  19. package/dist/providers/claude/background/constants.js +24 -0
  20. package/dist/providers/claude/background/index.d.ts +3 -0
  21. package/dist/providers/claude/background/index.js +4 -0
  22. package/dist/providers/claude/background/types.d.ts +56 -0
  23. package/dist/providers/claude/background/types.js +46 -0
  24. package/dist/providers/claude/background/utilities.d.ts +17 -0
  25. package/dist/providers/claude/background/utilities.js +65 -0
  26. package/dist/providers/claude/control/control.js +6 -3
  27. package/dist/providers/claude/control/stream.d.ts +8 -0
  28. package/dist/providers/claude/control/stream.js +14 -1
  29. package/dist/providers/claude/control/types.d.ts +1 -0
  30. package/dist/providers/claude/history/history.model.d.ts +5 -0
  31. package/dist/providers/claude/history/history.model.js +27 -4
  32. package/dist/providers/claude/history/index.d.ts +1 -0
  33. package/dist/providers/claude/history/index.js +2 -0
  34. package/dist/providers/claude/history/types.d.ts +11 -0
  35. package/dist/providers/claude/history/utilities.d.ts +10 -0
  36. package/dist/providers/claude/history/utilities.js +63 -1
  37. package/dist/providers/codex/transformers.js +2 -0
  38. package/dist/providers/registry/constants.d.ts +1 -0
  39. package/dist/providers/registry/constants.js +2 -0
  40. package/dist/providers/registry/registry.js +2 -0
  41. package/dist/providers/types.d.ts +3 -0
  42. package/dist/runtime/runtime.js +22 -4
  43. package/dist/sessions/sessions.d.ts +4 -4
  44. package/dist/sessions/sessions.js +21 -11
  45. package/dist/sessions/types.d.ts +6 -0
  46. package/dist/store/sessions/sessions.model.d.ts +14 -2
  47. package/dist/store/sessions/sessions.model.js +36 -10
  48. package/dist/store/sessions/types.d.ts +2 -0
  49. package/dist/store/sessions/types.js +3 -2
  50. package/dist/store/store.js +2 -1
  51. package/dist/store/store.worker.js +4 -1
  52. package/dist/store/types.d.ts +27 -2
  53. package/dist/store/types.js +15 -1
  54. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.9.0
4
+
5
+ - Report on every session summary how many background commands the session runs, as `backgroundCommands`. A session HQ runs reports the count Claude last reported. A Claude session a terminal runs reports the commands and agents its transcript records as started since its Claude process started and not yet ended. The `claude agents --json` poll counts before it records states, within one 67,108,864-byte read budget per run, and a `thread` read reads the transcript again first. Codex sessions report 0.
6
+ - List idle sessions that run background commands in `active-sessions`, beside the running and waiting ones.
7
+ - Report on a Claude session's summary the session its chat continues in, as `continuedIn`, when Claude Code moved the chat into a new session and left a `continued-in` record at the old transcript's end with no message after it. Other summaries carry null.
8
+ - Store nothing new: the counts and answers are kept in memory, so the schema and existing databases are unchanged.
9
+
10
+ ## 10.8.0
11
+
12
+ - Report how many commands a session runs in the background. The `live-items` window carries `backgroundCommands`, the count Claude last reported for a session HQ controls, 0 once its process stopped or when its provider reports none, and a change of it is a new revision, so a client that follows the window sees a command keep running after the turn that started it ended, until Claude resumes the session. Providers report it through a new `background` event.
13
+
3
14
  ## 10.7.0
4
15
 
5
16
  - Accept up to 16,777,216 bytes of files per input, each text file up to 262,144 bytes, up from 2,097,152 and 65,536. `capabilities.inputSchema` reports the new `maxFileBytes` and `maxTextFileBytes`.
package/README.md CHANGED
@@ -109,7 +109,7 @@ The [qualification matrix](api/README.md#qualification) records native journeys,
109
109
  - `src/runtime/`: trusted configuration and lifetime ownership.
110
110
  - `src/ipc/` and `src/cli/`: private local commands and the installed executable.
111
111
  - `src/providers/codex/`: the shared app-server daemon connection, native history and account protocol.
112
- - `src/providers/claude/`: native structured control and usage, the identity-validated, worker-owned local history reader and the active-session poll.
112
+ - `src/providers/claude/`: native structured control and usage, the identity-validated, worker-owned local history reader, the active-session poll and the background-task counter it reads transcripts with.
113
113
  - `src/providers/registry/`: lazy factories, normalized provider evidence, bounded lifecycle and source isolation.
114
114
  - `src/providers/inputs/` and `src/providers/results/`: checked file delivery and complete native result validation.
115
115
  - `src/providers/configuration/` and `src/providers/lineage/`: bounded native choices and confirmed immutable session relationships.
package/api/README.md CHANGED
@@ -327,18 +327,18 @@ Trusted runtime construction also accepts `codexExtraSkillRoots?: string[]` and
327
327
 
328
328
  ## Control reads and reconnect
329
329
 
330
- | Command | Fields | Result |
331
- | --------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
332
- | `managed-threads` | `workspaceRoot`, optional `limit`, `cursor` | Creation/UUID seek page of HQ records, including inactive and uncertain states. |
333
- | `managed-thread` | `threadId` | One HQ record or null. |
334
- | `managed-thread-name` | `name` | One HQ record or null, with case-insensitive lookup and the same workspace authorization. |
335
- | `suggest-thread-name` | `topic` | An editable lowercase label, with a currently free suffix when needed. This read does not reserve it. |
336
- | `receipt` | `actionId` | One receipt or null. |
337
- | `action-wait` | `actionId`, `until`, `timeoutMs` | The receipt once it reaches `until`, or as it stands when `timeoutMs` passes, with `isTimedOut`. |
338
- | `actions` | `threadId`, optional `limit`, `cursor` | Creation/UUID seek page of action metadata without queued bodies. |
339
- | `events` | `threadId`, optional `after` (default 0), `limit` | Ascending durable sequence page and `hasMore`; continue after the final sequence. |
340
- | `approvals` | `threadId`, optional `state`, `limit`, `cursor` | Durable approval metadata pages with nullable live presentation. |
341
- | `live-items` | `threadId` | Active/awaiting-flush item window, `hasGap`, `revision` and `unchanged`. Optional `afterRevision` omits bodies for an unchanged window. |
330
+ | Command | Fields | Result |
331
+ | --------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
332
+ | `managed-threads` | `workspaceRoot`, optional `limit`, `cursor` | Creation/UUID seek page of HQ records, including inactive and uncertain states. |
333
+ | `managed-thread` | `threadId` | One HQ record or null. |
334
+ | `managed-thread-name` | `name` | One HQ record or null, with case-insensitive lookup and the same workspace authorization. |
335
+ | `suggest-thread-name` | `topic` | An editable lowercase label, with a currently free suffix when needed. This read does not reserve it. |
336
+ | `receipt` | `actionId` | One receipt or null. |
337
+ | `action-wait` | `actionId`, `until`, `timeoutMs` | The receipt once it reaches `until`, or as it stands when `timeoutMs` passes, with `isTimedOut`. |
338
+ | `actions` | `threadId`, optional `limit`, `cursor` | Creation/UUID seek page of action metadata without queued bodies. |
339
+ | `events` | `threadId`, optional `after` (default 0), `limit` | Ascending durable sequence page and `hasMore`; continue after the final sequence. |
340
+ | `approvals` | `threadId`, optional `state`, `limit`, `cursor` | Durable approval metadata pages with nullable live presentation. |
341
+ | `live-items` | `threadId` | Active/awaiting-flush item window, `hasGap`, `revision`, `unchanged` and `backgroundCommands`, the commands the session runs in the background as its provider last reported, which Claude reports and 0 once its process stopped. A change of that count is a new revision. Optional `afterRevision` omits bodies for an unchanged window. |
342
342
 
343
343
  `{ kind: 'action-wait', actionId, until, timeoutMs }` waits on one receipt instead of polling `receipt`, and returns `{ receipt, isTimedOut }`. `until: 'native'` returns once the receipt has a `nativeThreadId`, as soon as HQ records a created or forked session's native ID, and `until: 'settled'` once its `delivery` is `acknowledged`, `uncertain`, `failed` or `canceled`, which only late native evidence or an operator's recovery changes. A `native` wait also returns once the receipt settles without a native thread ID, such as after a failed creation, because nothing can then give it one. `timeoutMs`, from 1 to 30,000, bounds the wait; when it passes first, the receipt comes as it stands with `isTimedOut: true`. An unknown action returns a null receipt at once. The receipt's workspace is authorized as for `receipt`. HQ reads the receipt again only after the actions module records a change that can affect it, never on a timer. A wait still running when the runtime starts closing ends at once with RUNTIME_NOT_RUNNING. A wait is admitted work, so `withStorageMaintenance` waits for it to end, and over IPC it holds one of the 32 connections; its 30-second limit fits the 35-second IPC deadline.
344
344
 
@@ -358,9 +358,15 @@ Every session has a live state: `running`, `waiting` (on the operator), `idle`,
358
358
 
359
359
  A Claude session's summary carries `terminal`: `{ kind: 'interactive' }`, or `{ kind: 'background', attachId }` with the short ID `claude attach` takes, while the latest `claude agents --json` run lists it with a `pid`, and null otherwise; Codex summaries always carry null. While it is set, `thread-adopt` and `thread-resume` of the session, and input to it, are refused with JG_AGENT_HQ_ACTION_CONFLICT, so a session HQ runs that a terminal resumed takes nothing from HQ until the terminal closes it. An approval request of a Codex turn reaches every client the daemon serves; when another answers first, HQ's prompt expires.
360
360
 
361
+ Every summary carries `backgroundCommands`, the background tasks the session runs, after which Claude resumes it on its own: commands it runs or moved to the background, and agents it launched there. A session HQ runs reports the count Claude last reported in `system/background_tasks_changed`, the same count its `live-items` window carries. A Claude session a terminal runs reports the tasks its transcript records since its listed process's `startedAt`, as the active-session poll below counts them. Codex sessions, and Claude sessions no run lists, report 0.
362
+
363
+ Every summary also carries `continuedIn`. When Claude Code moves a chat into a new session, it ends the old session's transcript with a `continued-in` record naming the new session in `continuedInSessionId`. A Claude session's summary from its indexed transcript carries that session's ID when the record is in the transcript's last 65,536 bytes with no `user` or `assistant` record after it, and the named session's transcript is in the same Claude project directory; otherwise, and for managed, Codex and `active-sessions` summaries, it is null. A session resumed after the move wrote messages after the record, so it continues in none. The answer is kept in memory per transcript, at most 1,024 of them, and read again once the transcript's size or modification time changes.
364
+
361
365
  - **Codex.** The shared daemon broadcasts every thread's status. HQ records the states of sessions inside the allowed workspaces, reading each session's workspace once, and their items stay readable with `items`. A session already running when the connection opens reports no change, so each time the connection opens, including after a reconnect, HQ reads the daemon's loaded threads (`thread/loaded/list`, 128 a page, at most 8 pages) and records each one's state from its status. An ephemeral session, which Codex doesn't save, such as a helper session Codex starts itself, is never observed. Observation runs while the Codex connection is open; the connection opens on the first Codex request.
362
366
  - **Claude.** While the runtime runs, HQ runs `claude agents --json` every 30 seconds, or every 5 seconds at the `live` pace, each run limited to 10 seconds and 65,536 bytes of output, and joins its entries to Claude discovery by `sessionId`. An entry without a `pid` isn't running, whatever its `state` says, so it counts as missing. Otherwise `status: "busy"` and a background session's `state: "working"` are running, `status: "waiting"` (a question or a permission prompt, for either kind of session) and an interactive `status: "blocked"` are waiting, `status: "idle"` is idle, and anything else is unknown; an entry missing from a run is closed. Entries whose `pid` is a native process this runtime started, its managed sessions and its metadata process, are left out. A failed, late, oversized or malformed run changes nothing. Sessions HQ manages keep their managed records.
363
367
 
368
+ Before a run records its states, it counts each listed session's background tasks from its transcript. That transcript is the one in the Claude project directory of the entry's `cwd`, or else of the workspace its indexed transcript was found in. A task starts with a tool result whose `toolUseResult` holds a `backgroundTaskId`, or an `isAsync` agent launch with its `agentId`, written at or after the entry's `startedAt`. It ends with a `<task-notification>` naming its `<task-id>`, in a message or a queued input, a `task_status` attachment whose status isn't `running`, or a TaskStop or KillShell call whose result isn't an error, in whichever order the call and result were written. Sidechain records and `api-request-blob` copies are skipped, and at most 256 tasks are tracked per session. Each run reads only what the transcripts gained since the last one, in 65,536-byte chunks and at most 67,108,864 bytes across all listed sessions, parsing only lines that hold one of those records. A session whose transcript the budget stopped short of its end reports 0 until a later run finishes it, and a transcript that can't be read reports 0. A `thread` read of a listed session reads its transcript first, with its own 67,108,864-byte budget, so a task that started after the latest run counts at once. The counts are kept in memory and rebuilt after a restart.
369
+
364
370
  `{ kind: 'session-states', afterSequence?, limit? }` returns state transitions in sequence order after `afterSequence` (default 0), at most `limit` per page (default 32, maximum 128), with `hasMore`. Continue after the last returned `sequence`. Each transition has `sequence`, `provider`, nullable `nativeId`, nullable `threadId` (managed sessions only), `ownership`, nullable `previousState`, `state`, `reason` and `recordedAt`. Every page also returns `latestSequence`, the highest sequence ever issued, or 0 before the first, so a reader can start after it to follow only new transitions, and `isReset`, true when the reader can't continue exactly after `afterSequence`: it is above `latestSequence`, as after a fresh state root or the restore of an older snapshot, or it is above 0 and its own transition was pruned. The page still holds the transitions after `afterSequence` that remain.
365
371
 
366
372
  | Reason | When |
@@ -376,7 +382,7 @@ A Claude session's summary carries `terminal`: `{ kind: 'interactive' }`, or `{
376
382
 
377
383
  Transitions survive restarts. Each new transition deletes up to 128 transitions older than seven days, and closed observed sessions are forgotten after seven days. A managed session's stopping phase records no transition of its own.
378
384
 
379
- `{ kind: 'active-sessions' }` returns every running and waiting session, managed and observed, at most 128 and newest state change first, with `isTruncated` when more are active. Each comes as the summary `threads` returns, with its workspace root, name and timestamps. A managed session reads them from its HQ record. An observed Claude session's workspace is the `cwd` the latest `claude agents --json` run reported, so it is left out until the first run after the runtime starts lists it; its name and timestamps come from its indexed transcript, and are null and its state's change time while the transcript isn't indexed. An observed Codex session's summary comes from `thread/read`, and other providers' observed sessions from their optional `readObservedThread`. A session outside the allowed workspaces, or one its provider can't read, is left out.
385
+ `{ kind: 'active-sessions' }` returns every running and waiting session, managed and observed, and every idle session with `backgroundCommands` above 0, at most 128 and newest state change first, with `isTruncated` when more are active. Each comes as the summary `threads` returns, with its workspace root, name and timestamps. A managed session reads them from its HQ record. An observed Claude session's workspace is the `cwd` the latest `claude agents --json` run reported, so it is left out until the first run after the runtime starts lists it; its name and timestamps come from its indexed transcript, and are null and its state's change time while the transcript isn't indexed. An observed Codex session's summary comes from `thread/read`, and other providers' observed sessions from their optional `readObservedThread`. A session outside the allowed workspaces, or one its provider can't read, is left out.
380
386
 
381
387
  `{ kind: 'unstarted-threads', provider, workspaceRoot }` returns that workspace's managed threads that no turn has started, at most 32 and newest first, with `isTruncated` when more exist: each was created empty with `thread-create`, has a native ID and no active or last turn, and is neither archived nor closed. Forks and adopted sessions start with native history, so they never count. Each comes as the summary `threads` returns, from its HQ record. `thread` answers for such a thread from its record too, and `items` with an empty page, so its session opens before the provider has written any history.
382
388
 
@@ -432,19 +438,20 @@ Live reads accept `afterRevision`. A matching revision returns `unchanged: true`
432
438
 
433
439
  The operation matrix describes the implemented native interfaces and their explicit unavailable surfaces. Executed qualification is narrower than every possible model, configuration and account state. Native versions below are observations, never admission rules.
434
440
 
435
- | Area | Executed evidence | Boundary |
436
- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
437
- | Provider integration | Public contract tests route a third provider, isolate unavailable providers and tolerate additive fields and future version labels. Native lifecycle, configuration, files, account and extension checks are listed in their sections above. | Each additional adapter needs its own native qualification. |
438
- | Identity and native interaction | Both providers retained managed/native identities after compaction and reconnect with a fresh runtime epoch. Codex interruption and continuation passed. Claude AskUserQuestion and scoped MCP permission replies used exact native identities. | A timed-out compaction retained uncertain delivery even when completion later arrived; it was not resent. Explicit resume followed confirmed controller shutdown. |
439
- | Recovery | After removing all eight qualification transcripts, offline recovery retained the host preference and providers stayed idle. | Native transcripts, repository files and authentication remain separate recovery responsibilities. |
440
- | Shared Codex daemon | Codex 0.164.0: a terminal `codex` session ran on the shared daemon and appeared in `thread/list`. Without subscribing, HQ saw its `thread/status/changed`; after rejoining with `thread/resume`, HQ received the terminal's live turn and item notifications. A thread HQ created appeared in the terminal's `codex resume` picker, and closing HQ's connection left the daemon and the terminal session running. The daemon confirmed HQ's interrupt and close. Per-thread skill roots and output schemas worked on HQ threads, while another client's catalog and thread never saw the roots. Sessions read their own thread ID from `CODEX_THREAD_ID`. | A terminal started with `-c` overrides runs its thread in its own process (`source: cli`): it is listed, but a second writer is refused, so it cannot be followed live. The restart check ran against a separate app-server on its own socket rather than the shared daemon, which was serving other work: within one keepalive interval the session became uncertain and nothing was resent. A session Codex reloads from disk loses its capability roots. |
441
- | Codex across restarts | Codex 0.166.0 on 2026-11-01: a turn whose client closed its connection mid-turn ran to completion in the daemon, which kept the session loaded and idle. A command approval that arrived before the connection closed stayed pending, with the session `waitingOnApproval`; after a new connection joined with `thread/resume`, the daemon sent it again under the same request ID, and answering it completed the turn. |
442
- | Claude permission requests | Claude Code 2.1.316 on 2026-11-01, in the default permission mode: a Write request carried `description`, `display_name`, `input`, `permission_suggestions`, `subtype`, `tool_name` and `tool_use_id`, and an error reply was recorded in the transcript as the tool call's failed result with the reply's text. | Fields such as `decision_reason_code` and `tool_kind` appear only in other modes, so their shape comes from the CLI's own code, not an observed request. |
443
- | Claude turns it starts itself | Claude Code 2.1.316 on 2026-11-01, in the auto permission mode with its input held open: when a background command finished after its turn, Claude sent `system:task_notification` and started a turn of its own, `system:init` then stream and assistant frames, ending in a `result` without `user_message_uuid`. Input written during that turn was replayed after its result as its own turn. Each HQ input's replayed message came before its turn's first stream and assistant frames. An interrupt ended such a turn with the interruption marker, then an `error_during_execution` result. `system:background_tasks_changed` listed the background commands running, and was empty once the last one ended. | The frame order is an observation of this version, not a native contract. |
444
- | Approvals on other clients' sessions | Codex 0.166.0 on 2026-11-01, on the shared daemon: connection A joined a thread connection B started, with `thread/resume`. When B's turn asked to run a command, the daemon sent the same approval request, with the same request ID, to both connections, and sent both `serverRequest/resolved` once B answered. | A thread only accepts `thread/resume` once its first turn has written its rollout. |
445
- | Large file inputs | Claude Code 2.1.316 and Codex 0.166.0 on 2026-11-02. Claude took one message with a 15,814,657-byte, three-page PDF and a 262,144-byte text file, 16,076,801 bytes in all, and answered from both; its transcript held the message as a 21,355,974-byte record, which history read on a page of its own. Codex took one message with seven PNG images of about 2.4 MB each and a text file, 16,531,190 bytes in all, sent to the shared daemon in 1,048,576-byte WebSocket fragments, and answered from every image. In each session a text-only follow-up turn then completed, and its history pages and every message's item detail read. | The provider's own limits on PDF pages and image sizes were not reached. A Claude session keeps each attachment in its transcript, so it grows by the attachments' base64 size. |
446
- | Claude active sessions | Claude Code 2.1.310 answered `claude agents --json` in 0.16 s. Interactive entries carry `status` (`busy`, `waiting`, `idle`) and `pid`; background entries carry `id` and `state` (`blocked`). Sessions HQ starts in structured mode are listed as interactive under their HQ name and disappear after close. | The list describes running processes only; history still comes from transcripts. |
447
- | Host coverage | Linux x86_64 package checks passed on Node 24.15.0 and 24.22.1. Identity, native interaction and recovery ran on the floor and on 24.22.1. | No macOS host was available for this run. Windows is outside the declared host contract. |
441
+ | Area | Executed evidence | Boundary |
442
+ | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
443
+ | Provider integration | Public contract tests route a third provider, isolate unavailable providers and tolerate additive fields and future version labels. Native lifecycle, configuration, files, account and extension checks are listed in their sections above. | Each additional adapter needs its own native qualification. |
444
+ | Identity and native interaction | Both providers retained managed/native identities after compaction and reconnect with a fresh runtime epoch. Codex interruption and continuation passed. Claude AskUserQuestion and scoped MCP permission replies used exact native identities. | A timed-out compaction retained uncertain delivery even when completion later arrived; it was not resent. Explicit resume followed confirmed controller shutdown. |
445
+ | Recovery | After removing all eight qualification transcripts, offline recovery retained the host preference and providers stayed idle. | Native transcripts, repository files and authentication remain separate recovery responsibilities. |
446
+ | Shared Codex daemon | Codex 0.164.0: a terminal `codex` session ran on the shared daemon and appeared in `thread/list`. Without subscribing, HQ saw its `thread/status/changed`; after rejoining with `thread/resume`, HQ received the terminal's live turn and item notifications. A thread HQ created appeared in the terminal's `codex resume` picker, and closing HQ's connection left the daemon and the terminal session running. The daemon confirmed HQ's interrupt and close. Per-thread skill roots and output schemas worked on HQ threads, while another client's catalog and thread never saw the roots. Sessions read their own thread ID from `CODEX_THREAD_ID`. | A terminal started with `-c` overrides runs its thread in its own process (`source: cli`): it is listed, but a second writer is refused, so it cannot be followed live. The restart check ran against a separate app-server on its own socket rather than the shared daemon, which was serving other work: within one keepalive interval the session became uncertain and nothing was resent. A session Codex reloads from disk loses its capability roots. |
447
+ | Codex across restarts | Codex 0.166.0 on 2026-11-01: a turn whose client closed its connection mid-turn ran to completion in the daemon, which kept the session loaded and idle. A command approval that arrived before the connection closed stayed pending, with the session `waitingOnApproval`; after a new connection joined with `thread/resume`, the daemon sent it again under the same request ID, and answering it completed the turn. |
448
+ | Claude permission requests | Claude Code 2.1.316 on 2026-11-01, in the default permission mode: a Write request carried `description`, `display_name`, `input`, `permission_suggestions`, `subtype`, `tool_name` and `tool_use_id`, and an error reply was recorded in the transcript as the tool call's failed result with the reply's text. | Fields such as `decision_reason_code` and `tool_kind` appear only in other modes, so their shape comes from the CLI's own code, not an observed request. |
449
+ | Claude turns it starts itself | Claude Code 2.1.316 on 2026-11-01, in the auto permission mode with its input held open: when a background command finished after its turn, Claude sent `system:task_notification` and started a turn of its own, `system:init` then stream and assistant frames, ending in a `result` without `user_message_uuid`. Input written during that turn was replayed after its result as its own turn. Each HQ input's replayed message came before its turn's first stream and assistant frames. An interrupt ended such a turn with the interruption marker, then an `error_during_execution` result. `system:background_tasks_changed` listed the background commands running, and was empty once the last one ended. | The frame order is an observation of this version, not a native contract. |
450
+ | Approvals on other clients' sessions | Codex 0.166.0 on 2026-11-01, on the shared daemon: connection A joined a thread connection B started, with `thread/resume`. When B's turn asked to run a command, the daemon sent the same approval request, with the same request ID, to both connections, and sent both `serverRequest/resolved` once B answered. | A thread only accepts `thread/resume` once its first turn has written its rollout. |
451
+ | Large file inputs | Claude Code 2.1.316 and Codex 0.166.0 on 2026-11-02. Claude took one message with a 15,814,657-byte, three-page PDF and a 262,144-byte text file, 16,076,801 bytes in all, and answered from both; its transcript held the message as a 21,355,974-byte record, which history read on a page of its own. Codex took one message with seven PNG images of about 2.4 MB each and a text file, 16,531,190 bytes in all, sent to the shared daemon in 1,048,576-byte WebSocket fragments, and answered from every image. In each session a text-only follow-up turn then completed, and its history pages and every message's item detail read. | The provider's own limits on PDF pages and image sizes were not reached. A Claude session keeps each attachment in its transcript, so it grows by the attachments' base64 size. |
452
+ | Claude active sessions | Claude Code 2.1.310 answered `claude agents --json` in 0.16 s. Interactive entries carry `status` (`busy`, `waiting`, `idle`) and `pid`; background entries carry `id` and `state` (`blocked`). Sessions HQ starts in structured mode are listed as interactive under their HQ name and disappear after close. | The list describes running processes only; history still comes from transcripts. |
453
+ | Claude background tasks and moved chats | Claude Code 2.1.317 records a command run in or moved to the background as a tool result whose `toolUseResult` holds `backgroundTaskId`, and an agent launched there as one with `isAsync` and `agentId`. A task's end is a `<task-notification>` with its `<task-id>` and `<status>` (`completed`, `failed`, `killed`, `stopped`), written as a message and as a queued input, or a `task_status` attachment after a compaction. A TaskStop result often comes with no notification, and can be written before the assistant record that holds its call. Moving a chat into a new session ends the old transcript with `continued-in` and `continuedInSessionId`, followed only by `ephemeral` and `cost-state` records. Before 10.9.0, the count matched the Bash tool shells of every idle listed session, of a running background command, and of one stopped with TaskStop. | Monitor tasks are not counted. A record shape another version changes counts as absent, which leaves a task's start or end unseen. |
454
+ | Host coverage | Linux x86_64 package checks passed on Node 24.15.0 and 24.22.1. Identity, native interaction and recovery ran on the floor and on 24.22.1. | No macOS host was available for this run. Windows is outside the declared host contract. |
448
455
 
449
456
  The identity and recovery checks used gpt-6.1-sol with medium effort and claude-opus-5-5 with medium effort in disposable workspaces on 2026-10-23. The shared-daemon and Claude active-session checks ran on 2026-10-25 with the installed CLIs' default models in disposable workspaces. The [Node release index](https://nodejs.org/dist/index.json) identified 24.22.1 as the current LTS patch at qualification time. Local checks do not establish a published npm release or a deployed website.
450
457
 
@@ -591,6 +591,10 @@ export const createActions = (registry, store, roots, epoch, actionKey, skills,
591
591
  if (controlled.has(key(provider, nativeId)))
592
592
  live.markGap(key(provider, nativeId));
593
593
  },
594
+ background(provider, nativeId, count) {
595
+ if (controlled.has(key(provider, nativeId)))
596
+ live.setBackgroundCommands(key(provider, nativeId), count);
597
+ },
594
598
  session(provider, nativeId, state) {
595
599
  observingProviders.add(provider);
596
600
  const sessionKey = key(provider, nativeId);
@@ -8,6 +8,19 @@ export declare class LiveItems {
8
8
  open(nativeId: string): void;
9
9
  /** Replaces one native item without persisting token or tool-output bodies. */
10
10
  put(nativeId: string, item: IHistoryItem, isComplete: boolean): void;
11
+ /** Records how many commands a session runs in the background, a change of its window. */
12
+ setBackgroundCommands(nativeId: string, count: number): void;
13
+ /**
14
+ * Reads how many commands a session runs in the background, as its provider last reported.
15
+ * @param nativeId The session's key.
16
+ * @returns The count, or 0 for a session without a window.
17
+ */
18
+ backgroundCommandsOf(nativeId: string): number;
19
+ /**
20
+ * Lists the sessions that run commands in the background.
21
+ * @returns Their keys.
22
+ */
23
+ backgroundKeys(): string[];
11
24
  /** Clears a reverted presentation and requires a fresh native history read. */
12
25
  reset(nativeId: string): void;
13
26
  /** Marks missing native stream evidence without discarding the surviving presentation. */
@@ -24,6 +37,7 @@ export declare class LiveItems {
24
37
  state: 'active' | 'awaiting-flush';
25
38
  })[];
26
39
  hasGap: boolean;
40
+ backgroundCommands: number;
27
41
  };
28
42
  /**
29
43
  * Drops completed items once persisted history holds them: with exactly matching normalized
@@ -11,7 +11,12 @@ export class LiveItems {
11
11
  return;
12
12
  if (this.__threads.size >= 32)
13
13
  this.__remove(this.__threads.keys().next().value);
14
- this.__threads.set(nativeId, { items: new Map(), hasGap: false, revision: ++this.__revision });
14
+ this.__threads.set(nativeId, {
15
+ items: new Map(),
16
+ hasGap: false,
17
+ revision: ++this.__revision,
18
+ backgroundCommands: 0,
19
+ });
15
20
  }
16
21
  /** Replaces one native item without persisting token or tool-output bodies. */
17
22
  put(nativeId, item, isComplete) {
@@ -19,7 +24,12 @@ export class LiveItems {
19
24
  if (!thread) {
20
25
  if (this.__threads.size >= 32)
21
26
  this.__remove(this.__threads.keys().next().value);
22
- thread = { items: new Map(), hasGap: true, revision: ++this.__revision };
27
+ thread = {
28
+ items: new Map(),
29
+ hasGap: true,
30
+ revision: ++this.__revision,
31
+ backgroundCommands: 0,
32
+ };
23
33
  this.__threads.set(nativeId, thread);
24
34
  }
25
35
  thread.revision = ++this.__revision;
@@ -39,10 +49,37 @@ export class LiveItems {
39
49
  this.__drop(candidate, candidate.items.keys().next().value);
40
50
  }
41
51
  }
52
+ /** Records how many commands a session runs in the background, a change of its window. */
53
+ setBackgroundCommands(nativeId, count) {
54
+ this.open(nativeId);
55
+ const thread = this.__threads.get(nativeId);
56
+ if (thread.backgroundCommands === count)
57
+ return;
58
+ thread.backgroundCommands = count;
59
+ thread.revision = ++this.__revision;
60
+ }
61
+ /**
62
+ * Reads how many commands a session runs in the background, as its provider last reported.
63
+ * @param nativeId The session's key.
64
+ * @returns The count, or 0 for a session without a window.
65
+ */
66
+ backgroundCommandsOf(nativeId) {
67
+ return this.__threads.get(nativeId)?.backgroundCommands ?? 0;
68
+ }
69
+ /**
70
+ * Lists the sessions that run commands in the background.
71
+ * @returns Their keys.
72
+ */
73
+ backgroundKeys() {
74
+ return [...this.__threads].flatMap(([key, thread]) => thread.backgroundCommands > 0 ? [key] : []);
75
+ }
42
76
  /** Clears a reverted presentation and requires a fresh native history read. */
43
77
  reset(nativeId) {
78
+ // the session's background commands outlive its reverted presentation
79
+ const backgroundCommands = this.__threads.get(nativeId)?.backgroundCommands ?? 0;
44
80
  this.__remove(nativeId);
45
81
  this.open(nativeId);
82
+ this.__threads.get(nativeId).backgroundCommands = backgroundCommands;
46
83
  this.markGap(nativeId);
47
84
  }
48
85
  /** Marks missing native stream evidence without discarding the surviving presentation. */
@@ -101,6 +138,7 @@ export class LiveItems {
101
138
  }))
102
139
  : [],
103
140
  hasGap: thread?.hasGap ?? true,
141
+ backgroundCommands: thread?.backgroundCommands ?? 0,
104
142
  };
105
143
  }
106
144
  /**
@@ -143,6 +143,12 @@ export const readControl = async (command, store, actions, roots) => {
143
143
  kind: 'live-items',
144
144
  result: thread.nativeId
145
145
  ? actions.live.read(JSON.stringify([thread.provider, thread.nativeId]), command.afterRevision)
146
- : { data: [], hasGap: false, revision: 0, unchanged: command.afterRevision === 0 },
146
+ : {
147
+ data: [],
148
+ hasGap: false,
149
+ revision: 0,
150
+ unchanged: command.afterRevision === 0,
151
+ backgroundCommands: 0,
152
+ },
147
153
  };
148
154
  };
@@ -814,6 +814,7 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
814
814
  }>;
815
815
  }, z.core.$strip>>;
816
816
  hasGap: z.ZodBoolean;
817
+ backgroundCommands: z.ZodNumber;
817
818
  }, z.core.$strip>;
818
819
  actions: z.ZodObject<{
819
820
  data: z.ZodArray<z.ZodObject<{
@@ -508,6 +508,8 @@ export declare const ThreadSummarySchema: z.ZodObject<{
508
508
  kind: z.ZodLiteral<"background">;
509
509
  attachId: z.ZodString;
510
510
  }, z.core.$strip>], "kind">>;
511
+ backgroundCommands: z.ZodNumber;
512
+ continuedIn: z.ZodNullable<z.ZodString>;
511
513
  }, z.core.$strip>;
512
514
  export type IThreadSummary = z.infer<typeof ThreadSummarySchema>;
513
515
  export declare const ActiveSessionsSchema: z.ZodObject<{
@@ -554,6 +556,8 @@ export declare const ActiveSessionsSchema: z.ZodObject<{
554
556
  kind: z.ZodLiteral<"background">;
555
557
  attachId: z.ZodString;
556
558
  }, z.core.$strip>], "kind">>;
559
+ backgroundCommands: z.ZodNumber;
560
+ continuedIn: z.ZodNullable<z.ZodString>;
557
561
  }, z.core.$strip>>;
558
562
  isTruncated: z.ZodBoolean;
559
563
  }, z.core.$strip>;
@@ -602,6 +606,8 @@ export declare const UnstartedThreadsSchema: z.ZodObject<{
602
606
  kind: z.ZodLiteral<"background">;
603
607
  attachId: z.ZodString;
604
608
  }, z.core.$strip>], "kind">>;
609
+ backgroundCommands: z.ZodNumber;
610
+ continuedIn: z.ZodNullable<z.ZodString>;
605
611
  }, z.core.$strip>>;
606
612
  isTruncated: z.ZodBoolean;
607
613
  }, z.core.$strip>;
@@ -825,6 +831,7 @@ export declare const LiveItemsSchema: z.ZodObject<{
825
831
  }>;
826
832
  }, z.core.$strip>>;
827
833
  hasGap: z.ZodBoolean;
834
+ backgroundCommands: z.ZodNumber;
828
835
  }, z.core.$strip>;
829
836
  export declare const UsageCreditsSchema: z.ZodObject<{
830
837
  bucket: z.ZodString;
@@ -1043,6 +1050,8 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1043
1050
  kind: z.ZodLiteral<"background">;
1044
1051
  attachId: z.ZodString;
1045
1052
  }, z.core.$strip>], "kind">>;
1053
+ backgroundCommands: z.ZodNumber;
1054
+ continuedIn: z.ZodNullable<z.ZodString>;
1046
1055
  isNameTruncated: z.ZodBoolean;
1047
1056
  }, z.core.$strip>>;
1048
1057
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -1953,6 +1962,8 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1953
1962
  kind: z.ZodLiteral<"background">;
1954
1963
  attachId: z.ZodString;
1955
1964
  }, z.core.$strip>], "kind">>;
1965
+ backgroundCommands: z.ZodNumber;
1966
+ continuedIn: z.ZodNullable<z.ZodString>;
1956
1967
  }, z.core.$strip>>;
1957
1968
  }, z.core.$strip>;
1958
1969
  }, z.core.$strip>, z.ZodObject<{
@@ -2000,6 +2011,8 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2000
2011
  kind: z.ZodLiteral<"background">;
2001
2012
  attachId: z.ZodString;
2002
2013
  }, z.core.$strip>], "kind">>;
2014
+ backgroundCommands: z.ZodNumber;
2015
+ continuedIn: z.ZodNullable<z.ZodString>;
2003
2016
  }, z.core.$strip>;
2004
2017
  }, z.core.$strip>, z.ZodObject<{
2005
2018
  kind: z.ZodLiteral<"turns">;
@@ -2992,6 +3005,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2992
3005
  }>;
2993
3006
  }, z.core.$strip>>;
2994
3007
  hasGap: z.ZodBoolean;
3008
+ backgroundCommands: z.ZodNumber;
2995
3009
  }, z.core.$strip>;
2996
3010
  }, z.core.$strip>, z.ZodObject<{
2997
3011
  kind: z.ZodLiteral<"session-states">;
@@ -3084,6 +3098,8 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3084
3098
  kind: z.ZodLiteral<"background">;
3085
3099
  attachId: z.ZodString;
3086
3100
  }, z.core.$strip>], "kind">>;
3101
+ backgroundCommands: z.ZodNumber;
3102
+ continuedIn: z.ZodNullable<z.ZodString>;
3087
3103
  }, z.core.$strip>>;
3088
3104
  isTruncated: z.ZodBoolean;
3089
3105
  }, z.core.$strip>;
@@ -3133,6 +3149,8 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3133
3149
  kind: z.ZodLiteral<"background">;
3134
3150
  attachId: z.ZodString;
3135
3151
  }, z.core.$strip>], "kind">>;
3152
+ backgroundCommands: z.ZodNumber;
3153
+ continuedIn: z.ZodNullable<z.ZodString>;
3136
3154
  }, z.core.$strip>>;
3137
3155
  isTruncated: z.ZodBoolean;
3138
3156
  }, z.core.$strip>;
@@ -3753,6 +3771,8 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3753
3771
  kind: z.ZodLiteral<"background">;
3754
3772
  attachId: z.ZodString;
3755
3773
  }, z.core.$strip>], "kind">>;
3774
+ backgroundCommands: z.ZodNumber;
3775
+ continuedIn: z.ZodNullable<z.ZodString>;
3756
3776
  isNameTruncated: z.ZodBoolean;
3757
3777
  }, z.core.$strip>>;
3758
3778
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -4663,6 +4683,8 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4663
4683
  kind: z.ZodLiteral<"background">;
4664
4684
  attachId: z.ZodString;
4665
4685
  }, z.core.$strip>], "kind">>;
4686
+ backgroundCommands: z.ZodNumber;
4687
+ continuedIn: z.ZodNullable<z.ZodString>;
4666
4688
  }, z.core.$strip>>;
4667
4689
  }, z.core.$strip>;
4668
4690
  }, z.core.$strip>, z.ZodObject<{
@@ -4710,6 +4732,8 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4710
4732
  kind: z.ZodLiteral<"background">;
4711
4733
  attachId: z.ZodString;
4712
4734
  }, z.core.$strip>], "kind">>;
4735
+ backgroundCommands: z.ZodNumber;
4736
+ continuedIn: z.ZodNullable<z.ZodString>;
4713
4737
  }, z.core.$strip>;
4714
4738
  }, z.core.$strip>, z.ZodObject<{
4715
4739
  kind: z.ZodLiteral<"turns">;
@@ -5702,6 +5726,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5702
5726
  }>;
5703
5727
  }, z.core.$strip>>;
5704
5728
  hasGap: z.ZodBoolean;
5729
+ backgroundCommands: z.ZodNumber;
5705
5730
  }, z.core.$strip>;
5706
5731
  }, z.core.$strip>, z.ZodObject<{
5707
5732
  kind: z.ZodLiteral<"session-states">;
@@ -5794,6 +5819,8 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5794
5819
  kind: z.ZodLiteral<"background">;
5795
5820
  attachId: z.ZodString;
5796
5821
  }, z.core.$strip>], "kind">>;
5822
+ backgroundCommands: z.ZodNumber;
5823
+ continuedIn: z.ZodNullable<z.ZodString>;
5797
5824
  }, z.core.$strip>>;
5798
5825
  isTruncated: z.ZodBoolean;
5799
5826
  }, z.core.$strip>;
@@ -5843,6 +5870,8 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5843
5870
  kind: z.ZodLiteral<"background">;
5844
5871
  attachId: z.ZodString;
5845
5872
  }, z.core.$strip>], "kind">>;
5873
+ backgroundCommands: z.ZodNumber;
5874
+ continuedIn: z.ZodNullable<z.ZodString>;
5846
5875
  }, z.core.$strip>>;
5847
5876
  isTruncated: z.ZodBoolean;
5848
5877
  }, z.core.$strip>;
@@ -169,8 +169,15 @@ export const ThreadSummarySchema = z.object({
169
169
  historyState: z.enum(['available', 'unavailable']),
170
170
  // the terminal that runs the session, while one does; always null for Codex
171
171
  terminal: SessionTerminalSchema.nullable(),
172
+ // the background tasks the session runs, which Claude resumes it after; 0 when none or unknown
173
+ backgroundCommands: z.number().int().nonnegative(),
174
+ // the session a Claude session's chat continues in, when its transcript names one beside it
175
+ continuedIn: NativeIdSchema.nullable(),
172
176
  });
173
- // every running and waiting session, newest state change first, with whether more are active
177
+ /*
178
+ * Every running and waiting session, and every idle one that runs background commands, newest
179
+ * state change first, with whether more are active.
180
+ */
174
181
  export const ActiveSessionsSchema = z.object({
175
182
  data: z.array(ThreadSummarySchema).max(MAX_PAGE_SIZE),
176
183
  isTruncated: z.boolean(),
@@ -272,6 +279,8 @@ export const LiveItemsSchema = z.object({
272
279
  unchanged: z.boolean(),
273
280
  data: z.array(HistoryItemSchema.extend({ state: z.enum(['active', 'awaiting-flush']) })).max(128),
274
281
  hasGap: z.boolean(),
282
+ // the commands the session runs in the background, as its provider last reported, 0 for none
283
+ backgroundCommands: z.number().int().nonnegative(),
275
284
  });
276
285
  // exact native credit observations; balances have no assumed currency or arithmetic semantics
277
286
  export const UsageCreditsSchema = z.object({
@@ -1,5 +1,5 @@
1
- import type { IObservationPace, ISessionState, ISessionTerminal } from '../../../contracts/index.js';
2
- import { type IClaudeAgent } from './types.js';
1
+ import type { ISessionState } from '../../../contracts/index.js';
2
+ import { type IClaudeAgent, type IClaudeAgentsObserver } from './types.js';
3
3
  /**
4
4
  * Maps a running session's report to the shared session state. A session waiting on a question or
5
5
  * a permission prompt reports `status: "waiting"`, as an interactive one may also report
@@ -11,15 +11,19 @@ export declare const toAgentState: (agent: IClaudeAgent) => ISessionState;
11
11
  * sessions inside the allowed workspaces, so a session missing from a run is closed. A failed,
12
12
  * late, oversized or malformed run changes nothing. Runs follow one another at the `background`
13
13
  * pace until `setPace` selects another, which takes effect with an immediate run.
14
- * @returns A handle that sets the pace, reports each listed session's `cwd` and the terminal that
15
- * runs it from the latest run, and whose close stops polling and waits for a run in progress.
14
+ *
15
+ * Before it records their states, each run counts every listed session's background tasks from
16
+ * its transcript, read since its Claude process started, within one byte budget for the whole run.
17
+ * A transcript is looked for in the Claude project directory of the session's `cwd`, then in that
18
+ * of the workspace `locateTranscript` resolves for its indexed transcript.
19
+ * @param record Records the states of the sessions a run listed.
20
+ * @param allowedRoots The workspaces whose sessions are observed.
21
+ * @param locateTranscript Resolves to the workspace root of a session's indexed transcript, or null.
22
+ * @returns A handle that sets the pace, reports each listed session's `cwd`, the terminal that runs
23
+ * it and its background tasks from the latest run, reads a session's tasks again on request, and
24
+ * whose close stops polling and waits for a run in progress.
16
25
  */
17
26
  export declare const observeClaudeAgents: (record: (sessions: {
18
27
  nativeId: string;
19
28
  state: ISessionState;
20
- }[]) => Promise<void>, allowedRoots: string[]) => {
21
- setPace(pace: IObservationPace): void;
22
- workspaceOf(nativeId: string): string | undefined;
23
- terminalOf(nativeId: string): ISessionTerminal | null;
24
- close(): Promise<void>;
25
- };
29
+ }[]) => Promise<void>, allowedRoots: string[], locateTranscript: (nativeId: string) => Promise<string | null>) => IClaudeAgentsObserver;