jg-agent-hq 5.0.1 → 6.0.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 (53) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -2
  3. package/api/README.md +12 -8
  4. package/dist/actions/actions.d.ts +2 -2
  5. package/dist/actions/actions.js +14 -2
  6. package/dist/cli/cli.js +2 -1
  7. package/dist/contracts/browser/types.d.ts +1 -0
  8. package/dist/contracts/index.d.ts +2 -2
  9. package/dist/contracts/index.js +1 -1
  10. package/dist/contracts/types.d.ts +227 -0
  11. package/dist/contracts/types.js +21 -1
  12. package/dist/providers/claude/agents/agents.d.ts +7 -5
  13. package/dist/providers/claude/agents/agents.js +29 -20
  14. package/dist/providers/claude/agents/types.d.ts +6 -0
  15. package/dist/providers/claude/agents/types.js +5 -0
  16. package/dist/providers/claude/control/stream.js +3 -0
  17. package/dist/providers/claude/history/history.model.js +6 -5
  18. package/dist/providers/claude/history/types.d.ts +76 -1
  19. package/dist/providers/claude/history/types.js +1 -1
  20. package/dist/providers/claude/history/utilities.d.ts +2 -1
  21. package/dist/providers/claude/history/utilities.js +4 -1
  22. package/dist/providers/codex/adapter.js +40 -15
  23. package/dist/providers/codex/codex.js +50 -16
  24. package/dist/providers/codex/constants.d.ts +5 -0
  25. package/dist/providers/codex/constants.js +8 -0
  26. package/dist/providers/codex/events.d.ts +1 -1
  27. package/dist/providers/codex/events.js +14 -3
  28. package/dist/providers/codex/rpc.d.ts +1 -0
  29. package/dist/providers/codex/rpc.js +1 -0
  30. package/dist/providers/codex/transformers.d.ts +5 -2
  31. package/dist/providers/codex/transformers.js +11 -2
  32. package/dist/providers/codex/types.d.ts +3 -0
  33. package/dist/providers/index.d.ts +1 -1
  34. package/dist/providers/index.js +1 -1
  35. package/dist/providers/process.d.ts +5 -0
  36. package/dist/providers/process.js +12 -0
  37. package/dist/providers/types.d.ts +6 -0
  38. package/dist/runtime/runtime.js +10 -5
  39. package/dist/sessions/index.d.ts +2 -1
  40. package/dist/sessions/index.js +1 -2
  41. package/dist/sessions/sessions.d.ts +15 -4
  42. package/dist/sessions/sessions.js +72 -8
  43. package/dist/sessions/types.d.ts +5 -1
  44. package/dist/store/control/constants.d.ts +1 -0
  45. package/dist/store/control/constants.js +8 -0
  46. package/dist/store/control/control.model.d.ts +14 -0
  47. package/dist/store/control/control.model.js +32 -1
  48. package/dist/store/sessions/sessions.model.js +11 -4
  49. package/dist/store/store.js +3 -0
  50. package/dist/store/store.worker.js +9 -0
  51. package/dist/store/types.d.ts +68 -0
  52. package/dist/store/types.js +12 -0
  53. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.0
4
+
5
+ - List `threads` by last activity, newest first, for Claude and Codex, with cursors that continue in that order; they were listed by creation time.
6
+ - Add `unstarted-threads`, which returns a workspace's managed sessions that `thread-create` made empty and no turn has started, at most 32 and newest first. `thread` and `items` answer for them from their HQ records, so a new session opens before its provider writes any history.
7
+ - Read session states that were already live when the runtime connects. Each Codex connection reads the daemon's loaded threads, leaving out ephemeral ones, so a session already running shows as running. Claude states come from the fields `claude agents --json` reports: an entry without a `pid` isn't running, `status: "waiting"` is waiting, `status: "idle"` is idle and `state: "working"` is running, and the processes the runtime started are left out.
8
+ - Name the terminal that runs a Claude session. Thread summaries gain `terminal`: `interactive`, `background` with the `attachId` that `claude attach` takes, or null, and a provider's summaries must carry it. While a terminal runs a Claude session, HQ refuses to adopt or resume it or send it input.
9
+ - Adopt a Codex session a terminal holds between turns, resuming it without settings overrides; adoption during a turn is refused. A session HQ closed is observed again like any other, and HQ resumes it when the terminal still has it loaded. A collaboration request to a Codex session HQ adopted is refused, since its agent tools never join it.
10
+ - Give history and live items `createdAt`, in Unix milliseconds or null, and a provider's items must carry it. A Claude item takes its record's time, and a live one the time its frame arrived. A Codex item takes its turn's times: an operator message the turn's start, every other item its end, or its start while the turn runs. A Codex history page reads its items' turns newest first, 128 at a time and at most 8 times.
11
+ - Keep 5.x's storage schema, so databases and snapshots written by 5.x open as they are.
12
+
3
13
  ## 5.0.1
4
14
 
5
15
  - Index Claude transcripts with less memory. Each record is read once, instead of being copied again for every 64 KiB chunk it spans, and the SQLite worker's young generation is capped at 16 MiB. Indexing a 224 MB transcript held the runtime at about 200 MB instead of about 300 MB. The storage schema is unchanged, so databases and snapshots written by 5.0.0 open as they are.
package/README.md CHANGED
@@ -37,7 +37,7 @@ Intentional failures use `Exception` from `jg-exception`, with the named string
37
37
 
38
38
  ## Local controller
39
39
 
40
- Install the providers you want and sign in through their native CLIs, then start `jg-agent-hq serve --state-root .runtime --workspace-root /path/to/workspace`. Run `jg-agent-hq status --state-root .runtime` in a client. `threads`, `thread`, `turns`, `items` and `usage` read native information; `stop` waits for confirmed runtime shutdown.
40
+ Install the providers you want and sign in through their native CLIs, then start `jg-agent-hq serve --state-root .runtime --workspace-root /path/to/workspace`. Run `jg-agent-hq status --state-root .runtime` in a client. `threads`, `thread`, `turns`, `items` and `usage` read native information, and each item carries its time as `createdAt`; `stop` waits for confirmed runtime shutdown.
41
41
 
42
42
  The Node API exposes `createAgentHq({ stateRoot, allowedRoots })` and `requestAgentHq(stateRoot, command)`. Configuration comes from these trusted operator inputs. Coding-instruction files are not runtime configuration.
43
43
 
@@ -49,7 +49,7 @@ Trusted Node hosts can open the database described by `hq.storage` and keep appl
49
49
 
50
50
  `createHqSnapshot(hq, destination)` captures local state through SQLite's backup API while agents keep working, including host tables, stored reports, action.key and registered plan companions. HQ-mediated plan writes wait for it; the host keeps its own connections from writing host tables until it resolves. A plan that changed during capture is marked, and restore withholds its execution authority. `inspectHqSnapshot(directory)` verifies the complete snapshot; `restoreHqSnapshot({ snapshotDirectory, destination })` validates and stages it into a new private recovery workspace. `packHqSnapshot(snapshotDirectory, archivePath, key)` encrypts a snapshot into one AES-256-GCM file for off-machine copies, and `unpackHqSnapshot(archivePath, destination, key)` verifies and writes it back as a snapshot directory. Snapshots from another schema are refused by the package version that wrote them. Restored automation is paused, skill grants are revoked, native ownership needs reconciliation and allowed roots must be selected explicitly. Hosts own the key and remote backups; a failed disk can lose changes since the last successful off-machine backup. See [snapshot and restore](api/README.md#snapshot-and-restore) and [recovery](docs/recovery.md).
51
51
 
52
- Sessions started in a terminal show up too. Codex sessions on the shared daemon and Claude sessions from `claude agents --json` report a live state (`running`, `waiting`, `idle`, `closed`, `failed` or `unknown`) with external ownership, and HQ sends them no input until they are closed there and handed over with `thread-adopt`. Every state change of a managed or observed session is recorded in order; read them with `{ kind: 'session-states', afterSequence }` or `session-states`. `active-sessions` lists every running and waiting session with its workspace, and `observation-pace` polls Claude every 5 seconds instead of 30 while a client follows sessions live. See [session states](api/README.md#session-states).
52
+ Sessions started in a terminal show up too. Codex sessions on the shared daemon and Claude sessions from `claude agents --json` report a live state (`running`, `waiting`, `idle`, `closed`, `failed` or `unknown`) with external ownership. HQ builds on what each CLI offers and never stops, wakes or drives a session a terminal runs: it adopts a Codex session the terminal holds between turns, through the shared daemon, and a Claude session only once no terminal runs it, while a Claude session's `terminal` field names the terminal that does. Every state change of a managed or observed session is recorded in order; read them with `{ kind: 'session-states', afterSequence }` or `session-states`. `active-sessions` lists every running and waiting session with its workspace, `unstarted-threads` lists the sessions HQ created before their first turn, and `observation-pace` polls Claude every 5 seconds instead of 30 while a client follows sessions live. See [session states](api/README.md#session-states).
53
53
 
54
54
  Provider IDs are bounded lowercase identifiers. Codex and Claude are built in; trusted Node hosts can register additional `IAgentProviderFactory` implementations through `providerFactories`. Capabilities report current operation support, provider/session scope and unavailable reasons. Native version labels are diagnostic metadata and never determine admission. Unknown essential control data fails explicitly. `jg-agent-hq/contracts` contains browser-safe schemas and types; importing it does not import the host runtime.
55
55
 
package/api/README.md CHANGED
@@ -136,7 +136,7 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
136
136
  | `login` | `actionId` | Live authentication presentation or known terminal state |
137
137
  | `usage` | `provider` | Actual subscription observations |
138
138
 
139
- Paged commands accept `limit` (default 32, maximum 128) and an opaque `cursor`. Continue with exactly the same command, target, filters and limit. The cursor binds those fields to the provider continuation. Codex requests descending creation order for threads, descending turns and descending items. Claude orders discovery by creation time/native UUID descending, turns by native chain position ascending and items by native chain position descending. Workspace authorization is rechecked for each request, independently of cursor validation, before selected-thread items are fetched.
139
+ Paged commands accept `limit` (default 32, maximum 128) and an opaque `cursor`. Continue with exactly the same command, target, filters and limit. The cursor binds those fields to the provider continuation. Codex requests threads by last activity (`updated_at`), descending, with descending turns and descending items. Claude orders discovery by last activity, the later of a transcript's modification time and its newest record, then native UUID, descending, turns by native chain position ascending and items by native chain position descending. Workspace authorization is rechecked for each request, independently of cursor validation, before selected-thread items are fetched.
140
140
 
141
141
  `items` reads newest first, its only order, and its cursor continues toward older items. `textLimit`, from 1 to 65,536 and 65,536 by default, cuts each item's `text` to that many UTF-16 code units on a code-point boundary and marks it `isTruncated`. `nativeItemId` with its `turnId`, and without a cursor, returns that item alone, cut at `textLimit` like any page; a hidden item, an unknown one, or one outside that turn returns an empty page. Codex has no lookup of one item, so it reads that turn's items, 128 at a time, until it finds the item.
142
142
 
@@ -237,7 +237,7 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
237
237
  | `thread-compact` | Idle owned `threadId`. Records native admission separately from its correlated turn completion. Clears the live presentation and requires a fresh history read. |
238
238
  | `thread-revert` | Idle owned `threadId`, exact `beforeTurnId`. Removes that native turn and later history; files and historical HQ receipts remain unchanged. Clears the live presentation and requires a fresh history read. |
239
239
  | `thread-create` | `provider` (a registered provider ID), `workspaceRoot`, `name`. Creates an empty native thread and sets its readable name before reporting acknowledgement. |
240
- | `thread-adopt` | The same fields plus `nativeId`, `operatorConfirmation`. Explicitly transfers an external thread after confirmed inactive ownership. Codex must report it unloaded; Claude requires qualified workspace history and the native idle/session-identity checks. |
240
+ | `thread-adopt` | The same fields plus `nativeId`, `operatorConfirmation`. Explicitly records an external thread as managed. Codex accepts it unloaded or idle, between turns of a terminal that still holds it, and resumes it without settings overrides; Claude requires qualified workspace history and the native idle/session-identity checks, and refuses while a terminal runs it. |
241
241
  | `thread-resume` | `threadId`, `operatorConfirmation`. Resumes an inactive managed thread; HQ does not fetch its complete conversation bodies. |
242
242
  | `thread-recover` | `threadId`, `operatorConfirmation`, `recovery`. The recovery is `{ kind: 'resume' }` for a known native identity, `{ kind: 'attach', nativeId }` for an inspected identity after uncertain creation, or `{ kind: 'create' }` to explicitly create a fresh empty thread when no native identity was recorded. The latter can leave an empty orphan from the uncertain creation; it never repeats a message. |
243
243
  | `thread-rename` | `threadId`, `name`. Changes the name only after the matching native acknowledgement. |
@@ -254,7 +254,7 @@ Message and queue input is a closed union: `{ kind: 'text', text }` or `{ kind:
254
254
 
255
255
  Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 32 characters. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 32 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. HQ provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery is permitted only after the producing runtime has stopped and its ownership evidence has been inspected.
256
256
 
257
- Codex may keep an idle native thread loaded after `thread/unsubscribe`. An explicitly confirmed resume may reacquire that thread only when its known HQ control is inactive and managed. Active native threads, uncertain HQ ownership and already controlled idle sessions remain blocked. Other adoption and recovery checks are unchanged.
257
+ Codex may keep an idle native thread loaded after `thread/unsubscribe`, as when a terminal still holds it. An explicitly confirmed resume may reacquire that thread when its known HQ control is inactive and managed, without settings overrides. Active native threads, uncertain HQ ownership and already controlled idle sessions remain blocked. Other adoption and recovery checks are unchanged.
258
258
 
259
259
  Receipts separate `delivery` (`queued`, `submitted`, `acknowledged`, `uncertain`, `failed`, `canceled`) from nullable native turn `completion` (`completed`, `failed`, `interrupted`). Acknowledgement means the exact native request was accepted, not that the turn or tool completed. Permission replies remain submitted after a pipe write and become acknowledged only when Codex resolves the exact native request or Claude returns a tool-result block for the exact tool-use identity. Claude cancellation expires the prompt and leaves an unacknowledged written reply uncertain. Resolution does not prove a tool ran. The receipt includes HQ/native identity, request phase, digest, timestamps, safe failure classification and optional related action. Only selected receipts expose undelivered `queuedInput` and the nullable complete native `result`; collection reads omit both. Queued input retains prepared text, native skill identity, content-bound file references and explicit turn settings, never file bytes or skill content. It is cleared after delivery acknowledgement or cancellation.
260
260
 
@@ -319,16 +319,18 @@ Control pages default to 32 and cap at 128. Seek cursors are bound to their comp
319
319
 
320
320
  Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page contains exactly matching normalized content or the bounded cache evicts them. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
321
321
 
322
- Items expose only normalized presentation fields, and one mapping per provider presents `items`, live items and `session-evidence` alike, as the provider's CLI shows them. Kinds are `user-message`, `agent-message`, `command`, `tool`, `file-change`, `notice` and `unsupported`. `callId` pairs a tool call with its result, or is null. `outcome` is `succeeded`, `failed`, or null when unknown or still running. `files` lists each file a file change touched, at most 128, with its added and removed lines, and is empty on other items. `outcome` and `files` come from the full native record, so `textLimit` never changes them. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly.
322
+ Items expose only normalized presentation fields, and one mapping per provider presents `items`, live items and `session-evidence` alike, as the provider's CLI shows them. Kinds are `user-message`, `agent-message`, `command`, `tool`, `file-change`, `notice` and `unsupported`. `callId` pairs a tool call with its result, or is null. `outcome` is `succeeded`, `failed`, or null when unknown or still running. `files` lists each file a file change touched, at most 128, with its added and removed lines, and is empty on other items. `outcome` and `files` come from the full native record, so `textLimit` never changes them. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly. `createdAt` is the item's time in Unix milliseconds, or null when the provider records none. A Claude item takes its record's `timestamp`, and a live one the time its frame arrived. A Codex item takes its turn's times, which Codex records across all of its history: an operator message takes its turn's start and every other item its turn's end, or its start while the turn runs. A Codex history page reads the turns of its items newest first, 128 at a time and at most 8 times, so a recent page takes one read and an item whose turn lies further back has no time. A live Codex item takes its running turn's start.
323
323
 
324
324
  Codex leaves `reasoning` items out as it reads them, so a Codex page can hold fewer items than its limit. `contextCompaction` is a `notice` with empty text, because Codex records no summary. `webSearch` and `imageView` are `tool` items reading the query or the image path. A command, file change or tool call takes its `outcome` from its `status`: `completed` succeeded, and `failed` or `declined` failed. `files` counts each change's diff, and an added or deleted file without hunks counts its whole content. A Codex item holds its call and its result together, so its `callId` is null. Claude's rules are under [Claude history](#claude-history).
325
325
 
326
326
  ## Session states
327
327
 
328
- Every session has a live state: `running`, `waiting` (on the operator), `idle`, `closed`, `failed` or `unknown`. A managed session reports it from its HQ record. A session another client drives is observed and listed with `ownership: 'external'`; HQ sends it no input. Hand it over with `thread-adopt` once it is closed in its terminal, which Codex reports as unloaded.
328
+ Every session has a live state: `running`, `waiting` (on the operator), `idle`, `closed`, `failed` or `unknown`. A managed session reports it from its HQ record. A session another client drives is observed and listed with `ownership: 'external'`; HQ sends it no input until `thread-adopt` records it as managed, and never stops, wakes or drives a session a terminal runs. A managed session HQ closed is observed again, so a terminal that continues it shows its state.
329
329
 
330
- - **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`. 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.
331
- - **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`. `busy` is running, `waiting` (an interactive session's question or permission prompt) and `blocked` (a background session) are waiting, and `idle` is idle; an entry missing from a run is closed. A failed, late, oversized or malformed run changes nothing. Sessions HQ manages keep their managed records.
330
+ 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. HQ's agent tools never join a Codex session it adopted, so a collaboration request to one is refused with JG_AGENT_HQ_CAPABILITY_UNAVAILABLE and waits with `dispatchBlockedReason: 'provider-unavailable'`. An approval request of a Codex turn reaches every client the daemon serves; when another answers first, HQ's prompt expires.
331
+
332
+ - **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.
333
+ - **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.
332
334
 
333
335
  `{ 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`.
334
336
 
@@ -347,6 +349,8 @@ Transitions survive restarts. Each new transition deletes up to 128 transitions
347
349
 
348
350
  `{ 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.
349
351
 
352
+ `{ 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.
353
+
350
354
  `{ kind: 'observation-pace', pace: 'live' | 'background' }` sets the Claude poll to every 5 seconds or every 30, taking effect with an immediate run; the runtime starts at `background`. A host sets `live` while a client follows sessions live.
351
355
 
352
356
  When the Codex daemon restarts, HQ's connection ends: its sessions become uncertain, observed Codex sessions become unknown, and nothing is sent again. The provider reports unavailable until the next Codex read reconnects; recover uncertain sessions with `thread-recover`.
@@ -373,7 +377,7 @@ Every usage read requests current native observations; the last successful snaps
373
377
 
374
378
  Output is one JSON line with `schemaVersion: 1`. Read output includes the command `kind` and `result`. Startup reports `kind: ready`. Confirmed shutdown reports `kind: stop` with `result.state: stopped`. Failure output goes to stderr with a safe error kind/message and exit status 1. The CLI never prints diagnostic causes or native payloads in an error response.
375
379
 
376
- `jg-agent-hq session-states --state-root <directory> [--after-sequence <sequence>] [--limit <1..128>]` reads one page of session state transitions. `jg-agent-hq active-sessions --state-root <directory>` reads the active sessions, and `jg-agent-hq observation-pace --state-root <directory> --pace live|background` sets the Claude poll's pace.
380
+ `jg-agent-hq session-states --state-root <directory> [--after-sequence <sequence>] [--limit <1..128>]` reads one page of session state transitions. `jg-agent-hq active-sessions --state-root <directory>` reads the active sessions, `jg-agent-hq unstarted-threads --state-root <directory> --workspace-root <path> [--provider <provider-id>]` reads the unstarted threads, and `jg-agent-hq observation-pace --state-root <directory> --pace live|background` sets the Claude poll's pace.
377
381
 
378
382
  `jg-agent-hq request --state-root <directory>` reads one complete HQ request from stdin, validates it, and prints the usual response. It accepts no extra target flags. This exposes action and reconnect operations without putting message text or question answers in command-line arguments. Its `stop` response acknowledges admission; use the dedicated `stop` command for confirmed shutdown.
379
383
 
@@ -1,4 +1,4 @@
1
- import type { IActionEnvelope, IActionReceipt, IManagedThread, INativeApproval, INativeApprovalSummary, IPlanRevisionWorkflow, ILoginObservation } from '../contracts/index.js';
1
+ import type { IActionEnvelope, IActionReceipt, IManagedThread, INativeApproval, INativeApprovalSummary, IPlanRevisionWorkflow, ILoginObservation, ISessionTerminal } from '../contracts/index.js';
2
2
  import { type createProviderRegistry } from '../providers/registry/index.js';
3
3
  import type { createSkills } from '../skills/index.js';
4
4
  import type { IStore } from '../store/index.js';
@@ -14,7 +14,7 @@ type IAdmissionScopes = {
14
14
  * Owns admitted native work across client disconnects, with durable delivery evidence.
15
15
  * @returns The runtime-scoped action controller. Close must precede worker shutdown.
16
16
  */
17
- export declare const createActions: (registry: ReturnType<typeof createProviderRegistry>, store: IStore, roots: string[], epoch: string, actionKey: Uint8Array, skills: ReturnType<typeof createSkills>, plans: ReturnType<typeof createPlans>, runBackground: (operation: () => Promise<void>) => Promise<void>, invalidateNativeCatalogs: () => void) => {
17
+ export declare const createActions: (registry: ReturnType<typeof createProviderRegistry>, store: IStore, roots: string[], epoch: string, actionKey: Uint8Array, skills: ReturnType<typeof createSkills>, plans: ReturnType<typeof createPlans>, runBackground: (operation: () => Promise<void>) => Promise<void>, invalidateNativeCatalogs: () => void, claudeTerminalOf: (nativeId: string) => ISessionTerminal | null) => {
18
18
  /** Registers a runtime-owned event-driven recovery wakeup, without awaiting it on the event lane. */
19
19
  setChangeHandler(handler: () => void): void;
20
20
  /** Lets ordinary native queues advance after outcome collection releases the dispatch guard. */
@@ -15,7 +15,7 @@ const NativeRejectionSchema = z.union([
15
15
  * Owns admitted native work across client disconnects, with durable delivery evidence.
16
16
  * @returns The runtime-scoped action controller. Close must precede worker shutdown.
17
17
  */
18
- export const createActions = (registry, store, roots, epoch, actionKey, skills, plans, runBackground, invalidateNativeCatalogs) => {
18
+ export const createActions = (registry, store, roots, epoch, actionKey, skills, plans, runBackground, invalidateNativeCatalogs, claudeTerminalOf) => {
19
19
  const prompts = new Map();
20
20
  const controlled = new Map();
21
21
  const key = (provider, nativeId) => JSON.stringify([provider, nativeId]);
@@ -776,8 +776,12 @@ export const createActions = (registry, store, roots, epoch, actionKey, skills,
776
776
  prepared.workspaceRoot = workspaceRoot;
777
777
  }
778
778
  if (command.kind === 'thread-adopt') {
779
+ // a terminal that runs a Claude session keeps it; HQ takes it only once it runs nowhere
780
+ if (command.provider === 'claude' && claudeTerminalOf(command.nativeId))
781
+ conflict();
779
782
  const target = await control.inspectThread(command.nativeId, prepared.workspaceRoot);
780
- if (!target.canAdopt ||
783
+ // nobody holds it, or the client that does is between turns, as a Codex terminal can be
784
+ if ((!target.canAdopt && !target.canResume) ||
781
785
  (await resolveWorkspaceTarget(target.thread.workspaceRoot, roots)) !==
782
786
  prepared.workspaceRoot)
783
787
  conflict();
@@ -791,6 +795,8 @@ export const createActions = (registry, store, roots, epoch, actionKey, skills,
791
795
  const nativeId = command.kind === 'thread-recover' && command.recovery.kind === 'attach'
792
796
  ? command.recovery.nativeId
793
797
  : thread.nativeId;
798
+ if (nativeId && thread.provider === 'claude' && claudeTerminalOf(nativeId))
799
+ conflict();
794
800
  if (nativeId) {
795
801
  const target = await control.inspectThread(nativeId, thread.workspaceRoot);
796
802
  const canResume = target.canAdopt ||
@@ -817,9 +823,15 @@ export const createActions = (registry, store, roots, epoch, actionKey, skills,
817
823
  const thread = await store.getThread(command.threadId);
818
824
  if (!thread?.nativeId)
819
825
  conflict();
826
+ // a terminal that resumed a Claude session HQ runs has it now, so HQ sends nothing
827
+ if (thread.provider === 'claude' && claudeTerminalOf(thread.nativeId))
828
+ conflict();
820
829
  const files = await readInputFiles(command.input.files ?? [], thread.workspaceRoot, roots);
821
830
  let selection = command.input;
822
831
  if (scopes.collaboration) {
832
+ // HQ's agent tools never join a Codex session it adopted, since the terminal's session holds it
833
+ if (thread.provider === 'codex' && (await store.isAdoptedThread(thread.id)))
834
+ capabilityUnavailable();
823
835
  const job = await store.dispatchJob(scopes.collaboration.taskId, scopes.collaboration.requestId);
824
836
  if (command.kind !== 'message' ||
825
837
  command.input.kind !== 'text' ||
package/dist/cli/cli.js CHANGED
@@ -53,7 +53,7 @@ const main = async () => {
53
53
  });
54
54
  const [kind] = positionals;
55
55
  if (values.help || !kind || kind === 'help') {
56
- process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|plan-status|plan-milestones|session-states|active-sessions|observation-pace|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--directory <path>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory, and --coordination-root for a separate existing coordination directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nitems reads newest first and accepts --text-limit <1..65536>, and --native-item-id with --turn-id for one item.\nobservation-pace takes --pace <live|background>.\nrequest reads one validated HQ command as JSON from stdin.\n');
56
+ process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|sessions|session-evidence|usage|account|models|configuration|mcp-servers|mcp-tools|mcp-resources|managed-thread-name|suggest-thread-name|skills|skill-preview|plan-status|plan-milestones|session-states|active-sessions|unstarted-threads|observation-pace|request --state-root <path> [--provider <provider-id>] [--workspace-root <path>] [--native-id <id>] [--limit <1..128>] [--cursor <cursor>] [--name <name>] [--topic <topic>] [--thread-id <id>] [--server-name <name>] [--skill-id <id>] [--arguments <text>] [--directory <path>] [--after-sequence <sequence>]\nserve accepts repeated --codex-extra-skill-root and --claude-additional-directory, and --coordination-root for a separate existing coordination directory.\nsession-evidence accepts --native-item-id and repeated --evidence-kind.\nitems reads newest first and accepts --text-limit <1..65536>, and --native-item-id with --turn-id for one item.\nobservation-pace takes --pace <live|background>.\nrequest reads one validated HQ command as JSON from stdin.\n');
57
57
  return;
58
58
  }
59
59
  if (positionals.length !== 1 || !values['state-root'])
@@ -248,6 +248,7 @@ const main = async () => {
248
248
  'provider',
249
249
  [
250
250
  'threads',
251
+ 'unstarted-threads',
251
252
  'thread',
252
253
  'turns',
253
254
  'items',
@@ -1344,6 +1344,7 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
1344
1344
  added: z.ZodNumber;
1345
1345
  removed: z.ZodNumber;
1346
1346
  }, z.core.$strip>>;
1347
+ createdAt: z.ZodNullable<z.ZodNumber>;
1347
1348
  state: z.ZodEnum<{
1348
1349
  active: "active";
1349
1350
  "awaiting-flush": "awaiting-flush";
@@ -3,10 +3,10 @@ export type { IAccountControlCommand, ILoginObservation, INativeControlResult, }
3
3
  export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  export type { IExtensionControlCommand } from './extensions/index.js';
5
5
  export { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
- export { HqRequestSchema, ThreadSummarySchema, ActiveSessionsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
6
+ export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, UnstartedThreadsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
7
7
  export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, MAX_PROVIDERS, } from './providers/index.js';
8
8
  export type { IProviderId, IProviderCapability, IProviderCapabilitySet, IProviderCapabilities, IProviderStatus, } from './providers/index.js';
9
- export type { IHqRequest, IHqRequestInput, IThreadSummary, IActiveSessions, ITurnSummary, IHistoryFile, IHistoryItem, IUsageSnapshot, IUsageCredits, IUsageResetCredits, IUsageWindowScope, IRuntimeStatus, IHqResponse, IErrorKind, IIpcResponse, } from './types.js';
9
+ export type { IHqRequest, IHqRequestInput, ISessionTerminal, IThreadSummary, IActiveSessions, IUnstartedThreads, ITurnSummary, IHistoryFile, IHistoryItem, IUsageSnapshot, IUsageCredits, IUsageResetCredits, IUsageWindowScope, IRuntimeStatus, IHqResponse, IErrorKind, IIpcResponse, } from './types.js';
10
10
  export { NativeLineageSchema } from './identities/index.js';
11
11
  export type { INativeLineage } from './identities/index.js';
12
12
  export { ProviderModelSchema, ProviderModelsRequestSchema, ProviderModelPageSchema, } from './models/index.js';
@@ -4,7 +4,7 @@ export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  // constants
5
5
  export { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
6
  // wire contracts
7
- export { HqRequestSchema, ThreadSummarySchema, ActiveSessionsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
7
+ export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, UnstartedThreadsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
8
8
  // provider identity and capability discovery
9
9
  export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, MAX_PROVIDERS, } from './providers/index.js';
10
10
  // native identities
@@ -1542,6 +1542,10 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1542
1542
  limit: z.ZodDefault<z.ZodNumber>;
1543
1543
  }, z.core.$strict>, z.ZodObject<{
1544
1544
  kind: z.ZodLiteral<"active-sessions">;
1545
+ }, z.core.$strict>, z.ZodObject<{
1546
+ kind: z.ZodLiteral<"unstarted-threads">;
1547
+ provider: z.ZodString;
1548
+ workspaceRoot: z.ZodString;
1545
1549
  }, z.core.$strict>, z.ZodObject<{
1546
1550
  kind: z.ZodLiteral<"observation-pace">;
1547
1551
  pace: z.ZodEnum<{
@@ -1551,6 +1555,13 @@ export declare const HqRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1551
1555
  }, z.core.$strict>], "kind">;
1552
1556
  export type IHqRequest = z.infer<typeof HqRequestSchema>;
1553
1557
  export type IHqRequestInput = z.input<typeof HqRequestSchema>;
1558
+ export declare const SessionTerminalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1559
+ kind: z.ZodLiteral<"interactive">;
1560
+ }, z.core.$strip>, z.ZodObject<{
1561
+ kind: z.ZodLiteral<"background">;
1562
+ attachId: z.ZodString;
1563
+ }, z.core.$strip>], "kind">;
1564
+ export type ISessionTerminal = z.infer<typeof SessionTerminalSchema>;
1554
1565
  export declare const ThreadSummarySchema: z.ZodObject<{
1555
1566
  provider: z.ZodString;
1556
1567
  nativeId: z.ZodString;
@@ -1588,6 +1599,12 @@ export declare const ThreadSummarySchema: z.ZodObject<{
1588
1599
  unavailable: "unavailable";
1589
1600
  available: "available";
1590
1601
  }>;
1602
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
1603
+ kind: z.ZodLiteral<"interactive">;
1604
+ }, z.core.$strip>, z.ZodObject<{
1605
+ kind: z.ZodLiteral<"background">;
1606
+ attachId: z.ZodString;
1607
+ }, z.core.$strip>], "kind">>;
1591
1608
  }, z.core.$strip>;
1592
1609
  export type IThreadSummary = z.infer<typeof ThreadSummarySchema>;
1593
1610
  export declare const ActiveSessionsSchema: z.ZodObject<{
@@ -1628,10 +1645,64 @@ export declare const ActiveSessionsSchema: z.ZodObject<{
1628
1645
  unavailable: "unavailable";
1629
1646
  available: "available";
1630
1647
  }>;
1648
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
1649
+ kind: z.ZodLiteral<"interactive">;
1650
+ }, z.core.$strip>, z.ZodObject<{
1651
+ kind: z.ZodLiteral<"background">;
1652
+ attachId: z.ZodString;
1653
+ }, z.core.$strip>], "kind">>;
1631
1654
  }, z.core.$strip>>;
1632
1655
  isTruncated: z.ZodBoolean;
1633
1656
  }, z.core.$strip>;
1634
1657
  export type IActiveSessions = z.infer<typeof ActiveSessionsSchema>;
1658
+ export declare const UnstartedThreadsSchema: z.ZodObject<{
1659
+ data: z.ZodArray<z.ZodObject<{
1660
+ provider: z.ZodString;
1661
+ nativeId: z.ZodString;
1662
+ nativeLineage: z.ZodNullable<z.ZodObject<{
1663
+ sessionId: z.ZodNullable<z.ZodString>;
1664
+ parentThreadId: z.ZodNullable<z.ZodString>;
1665
+ forkedFromId: z.ZodNullable<z.ZodString>;
1666
+ }, z.core.$strip>>;
1667
+ workspaceRoot: z.ZodString;
1668
+ name: z.ZodNullable<z.ZodString>;
1669
+ createdAt: z.ZodNumber;
1670
+ updatedAt: z.ZodNumber;
1671
+ nativeState: z.ZodEnum<{
1672
+ unknown: "unknown";
1673
+ idle: "idle";
1674
+ active: "active";
1675
+ notLoaded: "notLoaded";
1676
+ systemError: "systemError";
1677
+ }>;
1678
+ state: z.ZodEnum<{
1679
+ unknown: "unknown";
1680
+ idle: "idle";
1681
+ failed: "failed";
1682
+ running: "running";
1683
+ waiting: "waiting";
1684
+ closed: "closed";
1685
+ }>;
1686
+ ownership: z.ZodEnum<{
1687
+ external: "external";
1688
+ managed: "managed";
1689
+ uncertain: "uncertain";
1690
+ }>;
1691
+ managedId: z.ZodNullable<z.ZodUUID>;
1692
+ historyState: z.ZodEnum<{
1693
+ unavailable: "unavailable";
1694
+ available: "available";
1695
+ }>;
1696
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
1697
+ kind: z.ZodLiteral<"interactive">;
1698
+ }, z.core.$strip>, z.ZodObject<{
1699
+ kind: z.ZodLiteral<"background">;
1700
+ attachId: z.ZodString;
1701
+ }, z.core.$strip>], "kind">>;
1702
+ }, z.core.$strip>>;
1703
+ isTruncated: z.ZodBoolean;
1704
+ }, z.core.$strip>;
1705
+ export type IUnstartedThreads = z.infer<typeof UnstartedThreadsSchema>;
1635
1706
  export declare const TurnSummarySchema: z.ZodObject<{
1636
1707
  nativeId: z.ZodString;
1637
1708
  state: z.ZodEnum<{
@@ -1696,6 +1767,7 @@ export declare const HistoryItemSchema: z.ZodObject<{
1696
1767
  added: z.ZodNumber;
1697
1768
  removed: z.ZodNumber;
1698
1769
  }, z.core.$strip>>;
1770
+ createdAt: z.ZodNullable<z.ZodNumber>;
1699
1771
  }, z.core.$strip>;
1700
1772
  export type IHistoryItem = z.infer<typeof HistoryItemSchema>;
1701
1773
  export declare const LiveItemsSchema: z.ZodObject<{
@@ -1746,6 +1818,7 @@ export declare const LiveItemsSchema: z.ZodObject<{
1746
1818
  added: z.ZodNumber;
1747
1819
  removed: z.ZodNumber;
1748
1820
  }, z.core.$strip>>;
1821
+ createdAt: z.ZodNullable<z.ZodNumber>;
1749
1822
  state: z.ZodEnum<{
1750
1823
  active: "active";
1751
1824
  "awaiting-flush": "awaiting-flush";
@@ -1973,6 +2046,12 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1973
2046
  unavailable: "unavailable";
1974
2047
  available: "available";
1975
2048
  }>;
2049
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
2050
+ kind: z.ZodLiteral<"interactive">;
2051
+ }, z.core.$strip>, z.ZodObject<{
2052
+ kind: z.ZodLiteral<"background">;
2053
+ attachId: z.ZodString;
2054
+ }, z.core.$strip>], "kind">>;
1976
2055
  isNameTruncated: z.ZodBoolean;
1977
2056
  }, z.core.$strip>>;
1978
2057
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -5708,6 +5787,12 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5708
5787
  unavailable: "unavailable";
5709
5788
  available: "available";
5710
5789
  }>;
5790
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
5791
+ kind: z.ZodLiteral<"interactive">;
5792
+ }, z.core.$strip>, z.ZodObject<{
5793
+ kind: z.ZodLiteral<"background">;
5794
+ attachId: z.ZodString;
5795
+ }, z.core.$strip>], "kind">>;
5711
5796
  }, z.core.$strip>>;
5712
5797
  }, z.core.$strip>;
5713
5798
  }, z.core.$strip>, z.ZodObject<{
@@ -5749,6 +5834,12 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5749
5834
  unavailable: "unavailable";
5750
5835
  available: "available";
5751
5836
  }>;
5837
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
5838
+ kind: z.ZodLiteral<"interactive">;
5839
+ }, z.core.$strip>, z.ZodObject<{
5840
+ kind: z.ZodLiteral<"background">;
5841
+ attachId: z.ZodString;
5842
+ }, z.core.$strip>], "kind">>;
5752
5843
  }, z.core.$strip>;
5753
5844
  }, z.core.$strip>, z.ZodObject<{
5754
5845
  kind: z.ZodLiteral<"turns">;
@@ -5819,6 +5910,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5819
5910
  added: z.ZodNumber;
5820
5911
  removed: z.ZodNumber;
5821
5912
  }, z.core.$strip>>;
5913
+ createdAt: z.ZodNullable<z.ZodNumber>;
5822
5914
  }, z.core.$strip>>;
5823
5915
  }, z.core.$strip>;
5824
5916
  }, z.core.$strip>, z.ZodObject<{
@@ -6582,6 +6674,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6582
6674
  added: z.ZodNumber;
6583
6675
  removed: z.ZodNumber;
6584
6676
  }, z.core.$strip>>;
6677
+ createdAt: z.ZodNullable<z.ZodNumber>;
6585
6678
  state: z.ZodEnum<{
6586
6679
  active: "active";
6587
6680
  "awaiting-flush": "awaiting-flush";
@@ -6672,6 +6765,61 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6672
6765
  unavailable: "unavailable";
6673
6766
  available: "available";
6674
6767
  }>;
6768
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
6769
+ kind: z.ZodLiteral<"interactive">;
6770
+ }, z.core.$strip>, z.ZodObject<{
6771
+ kind: z.ZodLiteral<"background">;
6772
+ attachId: z.ZodString;
6773
+ }, z.core.$strip>], "kind">>;
6774
+ }, z.core.$strip>>;
6775
+ isTruncated: z.ZodBoolean;
6776
+ }, z.core.$strip>;
6777
+ }, z.core.$strip>, z.ZodObject<{
6778
+ kind: z.ZodLiteral<"unstarted-threads">;
6779
+ result: z.ZodObject<{
6780
+ data: z.ZodArray<z.ZodObject<{
6781
+ provider: z.ZodString;
6782
+ nativeId: z.ZodString;
6783
+ nativeLineage: z.ZodNullable<z.ZodObject<{
6784
+ sessionId: z.ZodNullable<z.ZodString>;
6785
+ parentThreadId: z.ZodNullable<z.ZodString>;
6786
+ forkedFromId: z.ZodNullable<z.ZodString>;
6787
+ }, z.core.$strip>>;
6788
+ workspaceRoot: z.ZodString;
6789
+ name: z.ZodNullable<z.ZodString>;
6790
+ createdAt: z.ZodNumber;
6791
+ updatedAt: z.ZodNumber;
6792
+ nativeState: z.ZodEnum<{
6793
+ unknown: "unknown";
6794
+ idle: "idle";
6795
+ active: "active";
6796
+ notLoaded: "notLoaded";
6797
+ systemError: "systemError";
6798
+ }>;
6799
+ state: z.ZodEnum<{
6800
+ unknown: "unknown";
6801
+ idle: "idle";
6802
+ failed: "failed";
6803
+ running: "running";
6804
+ waiting: "waiting";
6805
+ closed: "closed";
6806
+ }>;
6807
+ ownership: z.ZodEnum<{
6808
+ external: "external";
6809
+ managed: "managed";
6810
+ uncertain: "uncertain";
6811
+ }>;
6812
+ managedId: z.ZodNullable<z.ZodUUID>;
6813
+ historyState: z.ZodEnum<{
6814
+ unavailable: "unavailable";
6815
+ available: "available";
6816
+ }>;
6817
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
6818
+ kind: z.ZodLiteral<"interactive">;
6819
+ }, z.core.$strip>, z.ZodObject<{
6820
+ kind: z.ZodLiteral<"background">;
6821
+ attachId: z.ZodString;
6822
+ }, z.core.$strip>], "kind">>;
6675
6823
  }, z.core.$strip>>;
6676
6824
  isTruncated: z.ZodBoolean;
6677
6825
  }, z.core.$strip>;
@@ -8242,6 +8390,10 @@ export declare const IpcRequestSchema: z.ZodObject<{
8242
8390
  limit: z.ZodDefault<z.ZodNumber>;
8243
8391
  }, z.core.$strict>, z.ZodObject<{
8244
8392
  kind: z.ZodLiteral<"active-sessions">;
8393
+ }, z.core.$strict>, z.ZodObject<{
8394
+ kind: z.ZodLiteral<"unstarted-threads">;
8395
+ provider: z.ZodString;
8396
+ workspaceRoot: z.ZodString;
8245
8397
  }, z.core.$strict>, z.ZodObject<{
8246
8398
  kind: z.ZodLiteral<"observation-pace">;
8247
8399
  pace: z.ZodEnum<{
@@ -8360,6 +8512,12 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8360
8512
  unavailable: "unavailable";
8361
8513
  available: "available";
8362
8514
  }>;
8515
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
8516
+ kind: z.ZodLiteral<"interactive">;
8517
+ }, z.core.$strip>, z.ZodObject<{
8518
+ kind: z.ZodLiteral<"background">;
8519
+ attachId: z.ZodString;
8520
+ }, z.core.$strip>], "kind">>;
8363
8521
  isNameTruncated: z.ZodBoolean;
8364
8522
  }, z.core.$strip>>;
8365
8523
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -12095,6 +12253,12 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12095
12253
  unavailable: "unavailable";
12096
12254
  available: "available";
12097
12255
  }>;
12256
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
12257
+ kind: z.ZodLiteral<"interactive">;
12258
+ }, z.core.$strip>, z.ZodObject<{
12259
+ kind: z.ZodLiteral<"background">;
12260
+ attachId: z.ZodString;
12261
+ }, z.core.$strip>], "kind">>;
12098
12262
  }, z.core.$strip>>;
12099
12263
  }, z.core.$strip>;
12100
12264
  }, z.core.$strip>, z.ZodObject<{
@@ -12136,6 +12300,12 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12136
12300
  unavailable: "unavailable";
12137
12301
  available: "available";
12138
12302
  }>;
12303
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
12304
+ kind: z.ZodLiteral<"interactive">;
12305
+ }, z.core.$strip>, z.ZodObject<{
12306
+ kind: z.ZodLiteral<"background">;
12307
+ attachId: z.ZodString;
12308
+ }, z.core.$strip>], "kind">>;
12139
12309
  }, z.core.$strip>;
12140
12310
  }, z.core.$strip>, z.ZodObject<{
12141
12311
  kind: z.ZodLiteral<"turns">;
@@ -12206,6 +12376,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12206
12376
  added: z.ZodNumber;
12207
12377
  removed: z.ZodNumber;
12208
12378
  }, z.core.$strip>>;
12379
+ createdAt: z.ZodNullable<z.ZodNumber>;
12209
12380
  }, z.core.$strip>>;
12210
12381
  }, z.core.$strip>;
12211
12382
  }, z.core.$strip>, z.ZodObject<{
@@ -12969,6 +13140,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12969
13140
  added: z.ZodNumber;
12970
13141
  removed: z.ZodNumber;
12971
13142
  }, z.core.$strip>>;
13143
+ createdAt: z.ZodNullable<z.ZodNumber>;
12972
13144
  state: z.ZodEnum<{
12973
13145
  active: "active";
12974
13146
  "awaiting-flush": "awaiting-flush";
@@ -13059,6 +13231,61 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
13059
13231
  unavailable: "unavailable";
13060
13232
  available: "available";
13061
13233
  }>;
13234
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
13235
+ kind: z.ZodLiteral<"interactive">;
13236
+ }, z.core.$strip>, z.ZodObject<{
13237
+ kind: z.ZodLiteral<"background">;
13238
+ attachId: z.ZodString;
13239
+ }, z.core.$strip>], "kind">>;
13240
+ }, z.core.$strip>>;
13241
+ isTruncated: z.ZodBoolean;
13242
+ }, z.core.$strip>;
13243
+ }, z.core.$strip>, z.ZodObject<{
13244
+ kind: z.ZodLiteral<"unstarted-threads">;
13245
+ result: z.ZodObject<{
13246
+ data: z.ZodArray<z.ZodObject<{
13247
+ provider: z.ZodString;
13248
+ nativeId: z.ZodString;
13249
+ nativeLineage: z.ZodNullable<z.ZodObject<{
13250
+ sessionId: z.ZodNullable<z.ZodString>;
13251
+ parentThreadId: z.ZodNullable<z.ZodString>;
13252
+ forkedFromId: z.ZodNullable<z.ZodString>;
13253
+ }, z.core.$strip>>;
13254
+ workspaceRoot: z.ZodString;
13255
+ name: z.ZodNullable<z.ZodString>;
13256
+ createdAt: z.ZodNumber;
13257
+ updatedAt: z.ZodNumber;
13258
+ nativeState: z.ZodEnum<{
13259
+ unknown: "unknown";
13260
+ idle: "idle";
13261
+ active: "active";
13262
+ notLoaded: "notLoaded";
13263
+ systemError: "systemError";
13264
+ }>;
13265
+ state: z.ZodEnum<{
13266
+ unknown: "unknown";
13267
+ idle: "idle";
13268
+ failed: "failed";
13269
+ running: "running";
13270
+ waiting: "waiting";
13271
+ closed: "closed";
13272
+ }>;
13273
+ ownership: z.ZodEnum<{
13274
+ external: "external";
13275
+ managed: "managed";
13276
+ uncertain: "uncertain";
13277
+ }>;
13278
+ managedId: z.ZodNullable<z.ZodUUID>;
13279
+ historyState: z.ZodEnum<{
13280
+ unavailable: "unavailable";
13281
+ available: "available";
13282
+ }>;
13283
+ terminal: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
13284
+ kind: z.ZodLiteral<"interactive">;
13285
+ }, z.core.$strip>, z.ZodObject<{
13286
+ kind: z.ZodLiteral<"background">;
13287
+ attachId: z.ZodString;
13288
+ }, z.core.$strip>], "kind">>;
13062
13289
  }, z.core.$strip>>;
13063
13290
  isTruncated: z.ZodBoolean;
13064
13291
  }, z.core.$strip>;