jg-agent-hq 5.0.1 → 6.1.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 (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -3
  3. package/api/README.md +19 -9
  4. package/dist/actions/actions.d.ts +2 -2
  5. package/dist/actions/actions.js +14 -2
  6. package/dist/cli/cli.js +7 -1
  7. package/dist/contracts/browser/types.d.ts +1 -0
  8. package/dist/contracts/constants.d.ts +4 -0
  9. package/dist/contracts/constants.js +5 -0
  10. package/dist/contracts/index.d.ts +3 -3
  11. package/dist/contracts/index.js +2 -2
  12. package/dist/contracts/types.d.ts +540 -0
  13. package/dist/contracts/types.js +99 -2
  14. package/dist/ipc/client.d.ts +1 -0
  15. package/dist/ipc/client.js +1 -0
  16. package/dist/providers/claude/agents/agents.d.ts +7 -5
  17. package/dist/providers/claude/agents/agents.js +29 -20
  18. package/dist/providers/claude/agents/types.d.ts +6 -0
  19. package/dist/providers/claude/agents/types.js +5 -0
  20. package/dist/providers/claude/claude.d.ts +1 -0
  21. package/dist/providers/claude/claude.js +1 -0
  22. package/dist/providers/claude/control/permissions.d.ts +9 -0
  23. package/dist/providers/claude/control/permissions.js +22 -0
  24. package/dist/providers/claude/control/stream.js +21 -1
  25. package/dist/providers/claude/history/history.model.d.ts +17 -0
  26. package/dist/providers/claude/history/history.model.js +106 -8
  27. package/dist/providers/claude/history/types.d.ts +168 -1
  28. package/dist/providers/claude/history/types.js +1 -1
  29. package/dist/providers/claude/history/utilities.d.ts +33 -2
  30. package/dist/providers/claude/history/utilities.js +168 -7
  31. package/dist/providers/codex/adapter.js +50 -15
  32. package/dist/providers/codex/codex.js +94 -17
  33. package/dist/providers/codex/constants.d.ts +5 -0
  34. package/dist/providers/codex/constants.js +8 -0
  35. package/dist/providers/codex/events.d.ts +1 -1
  36. package/dist/providers/codex/events.js +14 -3
  37. package/dist/providers/codex/rpc.d.ts +1 -0
  38. package/dist/providers/codex/rpc.js +1 -0
  39. package/dist/providers/codex/transformers.d.ts +30 -3
  40. package/dist/providers/codex/transformers.js +118 -4
  41. package/dist/providers/codex/types.d.ts +19 -1
  42. package/dist/providers/index.d.ts +1 -1
  43. package/dist/providers/index.js +1 -1
  44. package/dist/providers/process.d.ts +5 -0
  45. package/dist/providers/process.js +12 -0
  46. package/dist/providers/registry/validations.js +12 -0
  47. package/dist/providers/types.d.ts +6 -0
  48. package/dist/runtime/runtime.js +10 -5
  49. package/dist/runtime/types.d.ts +1 -0
  50. package/dist/sessions/images.d.ts +11 -0
  51. package/dist/sessions/images.js +44 -0
  52. package/dist/sessions/index.d.ts +4 -2
  53. package/dist/sessions/index.js +5 -4
  54. package/dist/sessions/sessions.d.ts +16 -4
  55. package/dist/sessions/sessions.js +86 -9
  56. package/dist/sessions/types.d.ts +6 -2
  57. package/dist/sessions/utilities.d.ts +57 -1
  58. package/dist/sessions/utilities.js +96 -0
  59. package/dist/store/control/constants.d.ts +1 -0
  60. package/dist/store/control/constants.js +8 -0
  61. package/dist/store/control/control.model.d.ts +14 -0
  62. package/dist/store/control/control.model.js +32 -1
  63. package/dist/store/sessions/sessions.model.js +11 -4
  64. package/dist/store/store.js +3 -0
  65. package/dist/store/store.worker.js +9 -0
  66. package/dist/store/types.d.ts +101 -0
  67. package/dist/store/types.js +12 -0
  68. package/errors/README.md +2 -0
  69. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.0
4
+
5
+ - Run HQ's own agent tools in Claude sessions without asking. A permission request for a tool of the session's agent bridge, named `mcp__<bridge server>__<tool>`, is allowed with its input unchanged and records no approval; every other tool still asks.
6
+ - Add `item-detail`, which returns one item of a turn with what a developer inspects in it: `command` with its output, exit code and duration, `tool` with its server, name, input and result, `files` with each changed file's diff, and `images`, every image it holds or names. Output and results longer than 65,536 UTF-16 code units keep their last 65,536. A Claude tool result takes its command or tool name from the call it answers.
7
+ - Add `item-image`, which returns one of an item's images in base64 when its first bytes are PNG, JPEG, GIF or WebP and it is at most 8 MiB: a Claude `base64` image block, or a Codex image view's or attached image's file, which is refused when it is a symbolic link or not a regular file, or its `data:` URL. No URL is fetched. Anything else fails with the new `image-unavailable` kind, `JG_AGENT_HQ_CLIENT_IMAGE_UNAVAILABLE`.
8
+ - Both reads are also CLI commands. A provider's `readHistory` receives them, and an answer of another kind fails the read with `JG_AGENT_HQ_PROVIDER_FAILED`; its other reads are unchanged.
9
+ - Keep 6.0.0's storage schema, so databases and snapshots written by 5.x and 6.0.0 open as they are.
10
+
11
+ ## 6.0.0
12
+
13
+ - List `threads` by last activity, newest first, for Claude and Codex, with cursors that continue in that order; they were listed by creation time.
14
+ - 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.
15
+ - 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.
16
+ - 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.
17
+ - 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.
18
+ - 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.
19
+ - Keep 5.x's storage schema, so databases and snapshots written by 5.x open as they are.
20
+
3
21
  ## 5.0.1
4
22
 
5
23
  - 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`. `item-detail` reads what a developer inspects in one item: its command and output, tool call, file diffs and images, and `item-image` returns one of its images. `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
 
@@ -79,7 +79,7 @@ Use `jg-agent-hq request --state-root <directory>` with a closed HQ command on s
79
79
 
80
80
  Trusted hosts can create collaboration tasks, add managed agents from any provider, and coordinate them through durable streams. Streams contain small indexed messages and optional directed or claimable requests. Subscription, reading, acknowledgement, assignment and completion are separate records. Metadata operations retain replay receipts and recover notification fan-out after restart. Directed requests can run through the existing native action ledger when the host enables automatic dispatch or explicitly selects a request. An assigned agent can publish direct child requests and yield with a bounded wait set. Exact child outcomes or requester clarifications continue the parent under its current authority; child completion never completes or approves the parent. Information, reads and acknowledgements do not start turns. HQ stores exact bounded outcome reports independently of native histories. Hosts issue exact task-scoped skill grants; role labels and message text grant no authority. See [task collaboration](api/README.md#task-collaboration).
81
81
 
82
- Controlled agents use `hq_identity` to recover their stable managed ID, task memberships, permissions and pending inbox counts. Codex uses experimental native dynamic tools; Claude uses a private session-specific stdio MCP bridge. Both use the same closed operations for streams, verified invocation context, requests, report chunks, session evidence and authorized managed spawning. Children can use either provider and inherit equal or narrower task permissions. The host sets a finite cumulative spawn budget. Native subagents share their owning HQ session identity. See [agent tools](api/README.md#agent-tools).
82
+ Controlled agents use `hq_identity` to recover their stable managed ID, task memberships, permissions and pending inbox counts. Codex uses experimental native dynamic tools; Claude uses a private session-specific stdio MCP bridge. Both use the same closed operations for streams, verified invocation context, requests, report chunks, session evidence and authorized managed spawning. Children can use either provider and inherit equal or narrower task permissions. The host sets a finite cumulative spawn budget. Native subagents share their owning HQ session identity. A Claude session runs these tools without asking for permission, and every other tool keeps native permission handling. See [agent tools](api/README.md#agent-tools).
83
83
 
84
84
  ## Plan coordination
85
85
 
package/api/README.md CHANGED
@@ -128,6 +128,8 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
128
128
  | `thread` | `provider`, `workspaceRoot`, `nativeId` | One native thread's metadata |
129
129
  | `turns` | Same target fields | Paged native turn metadata without hydrating items |
130
130
  | `items` | Same target fields | Newest-first persisted native items; optional `turnId`, `textLimit` and `nativeItemId` |
131
+ | `item-detail` | Same target fields, `turnId`, `nativeItemId` | One item with its command, tool call, file diffs and images, or null |
132
+ | `item-image` | Same target fields, `turnId`, `nativeItemId`, `index` | One image of an item as `{ mediaType, data }`, its bytes in base64 |
131
133
  | `session-evidence` | Same target fields | Newest-first bounded evidence, exact references and full normalized text continuation |
132
134
  | `account` | `provider` | Safe native account metadata with explicit unavailable observations |
133
135
  | `mcp-servers` | Managed `threadId` | Paged configured native MCP server identity, connection and auth metadata |
@@ -136,10 +138,14 @@ Import `HqRequestSchema`, `HqResponseSchema` and their inferred types from `jg-a
136
138
  | `login` | `actionId` | Live authentication presentation or known terminal state |
137
139
  | `usage` | `provider` | Actual subscription observations |
138
140
 
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.
141
+ 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
142
 
141
143
  `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
144
 
145
+ `item-detail` returns `IItemDetail` for one item of a turn, or null for a hidden or unknown item, or one outside that turn. `item` is the item as an `items` read of it returns it. `command` is `{ command, output, isOutputStartCut, exitCode, durationMs }` or null: a Codex `commandExecution` gives every field, a Claude `Bash` call its command, its result the command and its output, from the result's stdout and stderr or else its text, and a `!` shell input or output the same; Claude records no exit code or duration. `tool` is `{ server, name, input, result, isResultStartCut }` or null, with `input` and `result` as text: JSON for Codex `mcpToolCall` and `dynamicToolCall`, and for a Claude call its input as JSON and for its result the text of its content, an MCP tool's name split into its server and tool. A Claude result takes its command or tool name from the call it answers, which HQ looks for among its 32 nearest ancestors in its turn. `files` lists each changed file with `path`, `added`, `removed` and its unified `diff`, from Codex `fileChange` and Claude Edit and Write results; a created or deleted file without hunks is its whole content, every line added or removed. `images` lists every image the item holds or names, at most 64, in order: `{ index, mediaType, byteCount }`, where `mediaType` is `image/png`, `image/jpeg`, `image/gif` or `image/webp` when its first bytes are one of them, and both are null for an image the item only names, such as a Codex `imageView` or `localImage` path or a URL. Output and results longer than 65,536 UTF-16 code units keep their last 65,536, on a code-point boundary, with `isOutputStartCut` or `isResultStartCut` set.
146
+
147
+ `item-image` returns the image at `index`, from 0 to 63, in the item's `images`, as `{ mediaType, data }` with its bytes in base64. A Claude image comes from an `image` block with a `base64` source, in the record's message or in a tool result's content. A Codex image comes from an `imageView` item's path, a user message's `localImage` path, or an `image` part's base64 `data:` URL; no other URL is fetched. A path must be absolute. Its file is opened without following it when it is itself a symbolic link, and without waiting on a pipe, and it is read only when it is a regular file; directories in the path are resolved as usual. An image is returned only when its first bytes are PNG, JPEG, GIF or WebP, which set `mediaType`, and it is at most 8 MiB. Anything else, including a hidden or unknown item, one outside that turn, or an index past its images, fails with the `image-unavailable` kind. An image's base64 is about a third larger than its bytes, so through the IPC socket, whose responses are at most 8 MiB, an image over about 6 MiB fails as `operation-failed`; a host running the runtime in its own process reads every image up to 8 MiB.
148
+
143
149
  Threads expose native state, the live session `state` described under [session states](#session-states), `historyState` (`available` or `unavailable`), ownership (`external`, `managed` or `uncertain`) and nullable `managedId`. A managed thread uses its HQ name; an external thread retains its nullable native name. Timestamps use Unix milliseconds. Discovery projections are not authoritative transcript history and never cache a conversation body. Repeated Codex history reads go to its native APIs so a completed turn whose items have not flushed can be read again later. There is no resume-to-read behavior or Codex transcript-file parser.
144
150
 
145
151
  ## Bounded session evidence
@@ -237,7 +243,7 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
237
243
  | `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
244
  | `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
245
  | `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. |
246
+ | `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
247
  | `thread-resume` | `threadId`, `operatorConfirmation`. Resumes an inactive managed thread; HQ does not fetch its complete conversation bodies. |
242
248
  | `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
249
  | `thread-rename` | `threadId`, `name`. Changes the name only after the matching native acknowledgement. |
@@ -254,7 +260,7 @@ Message and queue input is a closed union: `{ kind: 'text', text }` or `{ kind:
254
260
 
255
261
  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
262
 
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.
263
+ 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
264
 
259
265
  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
266
 
@@ -281,7 +287,7 @@ Creation chooses a native UUID without inference, then names that exact session.
281
287
 
282
288
  An ordinary message is submitted only while idle. Its native UUID becomes the turn identity. A matching native replay or result acknowledges delivery, and the native result establishes completion. A request-success envelope can acknowledge a name change or interruption without a response body. HQ never writes queued follow-up input into Claude's own busy queue; the shared HQ queue dispatches it only after the previous result. Interruption acknowledgement alone does not establish a stop. An error result is classified as interrupted only when the qualified native interruption marker was observed for an explicitly interrupted input. Other terminal errors remain failed.
283
289
 
284
- Claude questions use exact question text as their answer identity and expose whether multiple selections are supported. Claude can_use_tool permissions use response `{ kind: 'decision', decision: 'accept' | 'decline' }`; question replies use `{ kind: 'answers', answers }`. The response kind `permission` with a turn/session scope belongs to Codex additional permissions. Tool permissions offer `accept` or `decline` for the displayed input only. Complete request details include native policy hints and reasons as untrusted display data; none authorizes a response. Unsupported permission fields or interaction surfaces receive an unsupported-request error. Requests requiring a native interaction card cannot be answered with generic approval; supported `AskUserQuestion` cards use their typed answer contract. Session-wide permission changes are unavailable; HQ does not apply native permission suggestions automatically. A reply is written through the separate control channel and acknowledged only by the matching tool result. Tool execution can still fail after that acknowledgement. Reused raw request IDs in different CLI processes have distinct controller scopes. Prompt bodies and replies remain out of SQLite.
290
+ Claude questions use exact question text as their answer identity and expose whether multiple selections are supported. Claude can_use_tool permissions use response `{ kind: 'decision', decision: 'accept' | 'decline' }`; question replies use `{ kind: 'answers', answers }`. The response kind `permission` with a turn/session scope belongs to Codex additional permissions. Tool permissions offer `accept` or `decline` for the displayed input only. Complete request details include native policy hints and reasons as untrusted display data; none authorizes a response. Unsupported permission fields or interaction surfaces receive an unsupported-request error. Requests requiring a native interaction card cannot be answered with generic approval; supported `AskUserQuestion` cards use their typed answer contract. Session-wide permission changes are unavailable; HQ does not apply native permission suggestions automatically. A tool request for the session's own agent bridge, named `mcp__<bridge server>__<tool>`, is allowed at once with its unchanged input and records no approval. A reply is written through the separate control channel and acknowledged only by the matching tool result. Tool execution can still fail after that acknowledgement. Reused raw request IDs in different CLI processes have distinct controller scopes. Prompt bodies and replies remain out of SQLite.
285
291
 
286
292
  Both providers support turn-correlated MCP `form` and `url` elicitation. Forms use bounded local JSON Schema validation (8 KiB, 16 levels, 1,024 nodes); responses stay within the action envelope’s 32 KiB budget. Unknown modes, unsupported schemas and Codex requests without a native turn are denied. Elicitation URLs are HTTP(S) links without embedded credentials; applications decide how to display or open them. Never render native strings as HTML or terminal instructions, and never infer a permission decision from model output or form metadata. Codex acknowledges an elicitation reply through its exact native request-resolution event. Claude supplies no equivalent form-reply acknowledgement: a successful write stays submitted, and terminal completion or cancellation expires the request and makes its unresolved reply uncertain. Retrying that same action returns its receipt without sending again.
287
293
 
@@ -319,16 +325,18 @@ Control pages default to 32 and cap at 128. Seek cursors are bound to their comp
319
325
 
320
326
  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
327
 
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.
328
+ 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
329
 
324
330
  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
331
 
326
332
  ## Session states
327
333
 
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.
334
+ 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
335
 
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.
336
+ 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.
337
+
338
+ - **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.
339
+ - **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
340
 
333
341
  `{ 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
342
 
@@ -347,6 +355,8 @@ Transitions survive restarts. Each new transition deletes up to 128 transitions
347
355
 
348
356
  `{ 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
357
 
358
+ `{ 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.
359
+
350
360
  `{ 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
361
 
352
362
  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 +383,7 @@ Every usage read requests current native observations; the last successful snaps
373
383
 
374
384
  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
385
 
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.
386
+ `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
387
 
378
388
  `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
389
 
@@ -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
@@ -32,6 +32,7 @@ const main = async () => {
32
32
  'native-id': { type: 'string' },
33
33
  'turn-id': { type: 'string' },
34
34
  'native-item-id': { type: 'string' },
35
+ index: { type: 'string' },
35
36
  'text-limit': { type: 'string' },
36
37
  'evidence-kind': { type: 'string', multiple: true },
37
38
  'thread-id': { type: 'string' },
@@ -53,7 +54,7 @@ const main = async () => {
53
54
  });
54
55
  const [kind] = positionals;
55
56
  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');
57
+ process.stdout.write('jg-agent-hq serve|status|stop|capabilities|threads|thread|turns|items|item-detail|item-image|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.\nitem-detail reads the detail of one item and takes --native-item-id and --turn-id.\nitem-image reads one image of an item and also takes --index <0..63>.\nobservation-pace takes --pace <live|background>.\nrequest reads one validated HQ command as JSON from stdin.\n');
57
58
  return;
58
59
  }
59
60
  if (positionals.length !== 1 || !values['state-root'])
@@ -111,6 +112,7 @@ const main = async () => {
111
112
  values['native-id'] ||
112
113
  values['turn-id'] ||
113
114
  values['native-item-id'] ||
115
+ values.index ||
114
116
  values['text-limit'] ||
115
117
  values['evidence-kind'] ||
116
118
  values['thread-id'] ||
@@ -248,9 +250,12 @@ const main = async () => {
248
250
  'provider',
249
251
  [
250
252
  'threads',
253
+ 'unstarted-threads',
251
254
  'thread',
252
255
  'turns',
253
256
  'items',
257
+ 'item-detail',
258
+ 'item-image',
254
259
  'sessions',
255
260
  'session-evidence',
256
261
  'usage',
@@ -267,6 +272,7 @@ const main = async () => {
267
272
  ['nativeId', values['native-id']],
268
273
  ['turnId', values['turn-id']],
269
274
  ['nativeItemId', values['native-item-id']],
275
+ ['index', values.index === undefined ? undefined : Number(values.index)],
270
276
  ['textLimit', values['text-limit'] === undefined ? undefined : Number(values['text-limit'])],
271
277
  ['kinds', values['evidence-kind']],
272
278
  ['threadId', values['thread-id']],
@@ -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";
@@ -1,6 +1,8 @@
1
1
  export declare const DEFAULT_PAGE_SIZE = 32;
2
2
  export declare const MAX_PAGE_SIZE = 128;
3
3
  export declare const MAX_ITEM_TEXT_LENGTH = 65536;
4
+ export declare const MAX_ITEM_IMAGES = 64;
5
+ export declare const MAX_ITEM_IMAGE_BYTES = 8388608;
4
6
  export declare const PUBLIC_ERROR_CODES: {
5
7
  readonly 'invalid-request': "JG_AGENT_HQ_CLIENT_INVALID_REQUEST";
6
8
  readonly 'authentication-required': "JG_AGENT_HQ_CLIENT_AUTHENTICATION_REQUIRED";
@@ -9,6 +11,7 @@ export declare const PUBLIC_ERROR_CODES: {
9
11
  readonly 'state-conflict': "JG_AGENT_HQ_CLIENT_STATE_CONFLICT";
10
12
  readonly 'agent-unavailable': "JG_AGENT_HQ_CLIENT_AGENT_UNAVAILABLE";
11
13
  readonly 'operation-failed': "JG_AGENT_HQ_CLIENT_OPERATION_FAILED";
14
+ readonly 'image-unavailable': "JG_AGENT_HQ_CLIENT_IMAGE_UNAVAILABLE";
12
15
  };
13
16
  export declare const PUBLIC_ERROR_MESSAGES: {
14
17
  readonly 'invalid-request': "Request is invalid.";
@@ -18,4 +21,5 @@ export declare const PUBLIC_ERROR_MESSAGES: {
18
21
  readonly 'state-conflict': "State changed. Refresh before continuing.";
19
22
  readonly 'agent-unavailable': "Coding agent is unavailable.";
20
23
  readonly 'operation-failed': "Operation could not be completed.";
24
+ readonly 'image-unavailable': "Image is unavailable.";
21
25
  };
@@ -3,6 +3,9 @@ export const DEFAULT_PAGE_SIZE = 32;
3
3
  export const MAX_PAGE_SIZE = 128;
4
4
  // the most text one history item carries, in UTF-16 code units
5
5
  export const MAX_ITEM_TEXT_LENGTH = 65_536;
6
+ // the most images one item's detail lists, and the largest one HQ returns, in bytes
7
+ export const MAX_ITEM_IMAGES = 64;
8
+ export const MAX_ITEM_IMAGE_BYTES = 8_388_608;
6
9
  // stable client codes for failures translated at IPC and browser boundaries
7
10
  export const PUBLIC_ERROR_CODES = {
8
11
  'invalid-request': 'JG_AGENT_HQ_CLIENT_INVALID_REQUEST',
@@ -12,6 +15,7 @@ export const PUBLIC_ERROR_CODES = {
12
15
  'state-conflict': 'JG_AGENT_HQ_CLIENT_STATE_CONFLICT',
13
16
  'agent-unavailable': 'JG_AGENT_HQ_CLIENT_AGENT_UNAVAILABLE',
14
17
  'operation-failed': 'JG_AGENT_HQ_CLIENT_OPERATION_FAILED',
18
+ 'image-unavailable': 'JG_AGENT_HQ_CLIENT_IMAGE_UNAVAILABLE',
15
19
  };
16
20
  // safe messages at IPC and browser boundaries
17
21
  export const PUBLIC_ERROR_MESSAGES = {
@@ -22,4 +26,5 @@ export const PUBLIC_ERROR_MESSAGES = {
22
26
  'state-conflict': 'State changed. Refresh before continuing.',
23
27
  'agent-unavailable': 'Coding agent is unavailable.',
24
28
  'operation-failed': 'Operation could not be completed.',
29
+ 'image-unavailable': 'Image is unavailable.',
25
30
  };
@@ -2,11 +2,11 @@ export { AccountControlCommandSchema, LoginObservationSchema, LoginRequestSchema
2
2
  export type { IAccountControlCommand, ILoginObservation, INativeControlResult, } from './accounts/index.js';
3
3
  export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  export type { IExtensionControlCommand } from './extensions/index.js';
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';
5
+ export { DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
6
+ export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, UnstartedThreadsSchema, TurnSummarySchema, HistoryFileSchema, HistoryItemSchema, ItemImageMediaTypeSchema, ItemDetailSchema, ItemImageSchema, 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, IItemImageMediaType, IItemDetail, IItemImage, 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';
@@ -2,9 +2,9 @@
2
2
  export { AccountControlCommandSchema, LoginObservationSchema, LoginRequestSchema, NativeControlResultSchema, } from './accounts/index.js';
3
3
  export { ExtensionControlCommandSchema } from './extensions/index.js';
4
4
  // constants
5
- export { DEFAULT_PAGE_SIZE, MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
5
+ export { DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, 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, ItemImageMediaTypeSchema, ItemDetailSchema, ItemImageSchema, 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