jg-agent-hq 10.5.4 → 10.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.7.0
4
+
5
+ - Accept up to 16,777,216 bytes of files per input, each text file up to 262,144 bytes, up from 2,097,152 and 65,536. `capabilities.inputSchema` reports the new `maxFileBytes` and `maxTextFileBytes`.
6
+ - Carry native and IPC frames and Claude transcript records of up to 33,554,432 bytes, up from 8,388,608, so a Claude session whose transcript holds a large message, such as one with attached files, keeps its history. Claude indexing reads up to 64 MiB per batch. Every Claude history is indexed again once.
7
+ - Send a Codex message over 1,048,576 bytes as masked fragments of at most that size, so a large message never meets a WebSocket server's per-frame limit.
8
+
9
+ ## 10.6.0
10
+
11
+ - Steer a Claude session's active turn. Claude reports `steer` as supported and writes the text as a user message into the exact active turn, without interrupting it, and acknowledges the steer when Claude replays the message: at the turn's next tool boundary, where the turn takes it in and ends with one result, or, for text written while the turn's final answer streams, after the turn's result, where it runs as the session's next turn under the message's UUID. Either replay acknowledges the steer against the turn it named. A steer never replayed fails 30 seconds after that turn ends, and one pending when the process stops fails at once. Claude used to reject `steer` as unavailable.
12
+
3
13
  ## 10.5.4
4
14
 
5
15
  - Keep a Claude response's parallel tool calls in its history when their results finish out of order. Claude Code links each result to its own call, so a result that came back after a later call's result started a side branch, and history left out the later calls and results: they stayed `awaiting-flush` after the session's answer, and an open page's cursor was rejected as changed. Such a result now follows the latest record of its turn. Every Claude history is indexed again once.
package/README.md CHANGED
@@ -75,13 +75,13 @@ Use `account --provider <id>` for safe native account metadata, and `mcp-servers
75
75
 
76
76
  Use `models --provider <id>` for native model and effort choices, and `configuration --provider <id> --workspace-root <path> [--thread-id <id>]` for known effective settings and paged native agent/profile metadata. Creation and explicit resume accept typed startup settings; messages can select a model and effort for the next turn. Startup instructions, native Claude agents and permission settings require an idle session restart. Capability schemas describe supported selections and change modes. Unknown settings remain explicit, and native configuration files stay with each CLI. See the [configuration contract](api/README.md#native-configuration).
77
77
 
78
- Native execution settings, instructions, skills and tool permissions remain with each CLI. Claude uses an owned structured process per controlled session, closes it after 60 idle minutes and reopens it for the next input, and reports immediate steering as unavailable. Close other CLI controllers before confirming adoption, resume or recovery. HQ coordinates sessions sharing one state directory; it cannot lock independently running native CLIs. Integrating browser hosts can use durable host-action admission and operator-scoped reconciliation through the programmatic API; see the [browser host contract](api/README.md#browser-host-integration). The standalone CLI advertises only commands it implements.
78
+ Native execution settings, instructions, skills and tool permissions remain with each CLI. Claude uses an owned structured process per controlled session, closes it after 60 idle minutes and reopens it for the next input, and steers its active turn with a structured user message. Close other CLI controllers before confirming adoption, resume or recovery. HQ coordinates sessions sharing one state directory; it cannot lock independently running native CLIs. Integrating browser hosts can use durable host-action admission and operator-scoped reconciliation through the programmatic API; see the [browser host contract](api/README.md#browser-host-integration). The standalone CLI advertises only commands it implements.
79
79
 
80
80
  Approval reads return indexed, cursor-paginated pending, answered and expired metadata after reconnect or restart. Sensitive presentation is available only while the exact native request is live. Native permissions require explicit responses; unknown request kinds or scopes are denied. See [native replies and reconnect reads](api/README.md#thread-control-and-live-input).
81
81
 
82
82
  Durable state includes `action.key`, which must stay private and accompany its SQLite database. Queued undelivered inputs and complete bounded final results are saved; ordinary input bodies and question answers are not.
83
83
 
84
- Text and skill inputs can attach bounded workspace files by path and media type. HQ verifies their content hashes again before queued delivery. Output schemas use native Codex turn parameters or Claude's structured-session flag; complete validated results and known token usage remain available on selected receipts after reconnect. Live previews stay bounded and explicitly mark truncation. See [file inputs and complete results](api/README.md#file-inputs-and-complete-results).
84
+ Text and skill inputs can attach up to 8 workspace files by path and media type, 16 MiB in all and 256 KiB per text file. HQ verifies their content hashes again before queued delivery. Output schemas use native Codex turn parameters or Claude's structured-session flag; complete validated results and known token usage remain available on selected receipts after reconnect. Live previews stay bounded and explicitly mark truncation. See [file inputs and complete results](api/README.md#file-inputs-and-complete-results).
85
85
 
86
86
  Use `suggest-thread-name --topic "Build usage" --state-root <directory>` for an editable label and `managed-thread-name --name build-usage --state-root <directory>` to resolve it. Creation adds a short ordinal suffix when a name is occupied. Actions and relationships retain immutable IDs.
87
87
 
package/api/README.md CHANGED
@@ -70,7 +70,7 @@ The controller exclusively creates `hq-owner.json`. A live, inactive, incomplete
70
70
 
71
71
  Codex sessions outlive the runtime, because they run in Codex's shared app-server daemon. Shutdown leaves them running: it doesn't interrupt their turns, clean their background terminals or answer a request still waiting on one, and their managed records stay bound to the stopped runtime. At startup, the next runtime rejoins each one that had no action in flight, one at a time in the background. It reads the session's state and latest turn from the daemon, binds the record to its own epoch, then joins with `thread/resume` without settings. A turn still running stays the session's active turn. A turn that finished meanwhile completes its action's receipt, without a `result`, and lets a queued entry waiting on it advance. The daemon sends a still-waiting request again on joining, and it opens as a new approval in the new epoch. A session whose latest turn isn't the one HQ recorded, because another client ran one, or that can't be read or joined, has its ownership marked uncertain for explicit recovery. A crash leaves the same bound records, so those sessions are rejoined too. A restored snapshot marks every session uncertain, so it never rejoins one. Claude sessions are processes the runtime owns: their turns stop with it, and they wait inactive for an explicit resume.
72
72
 
73
- One Codex connection carries every managed Codex session, so a message HQ can't validate never fails it. A notification about items, text deltas, token usage or a session's status that fails validation is dropped, and a session HQ controls reports a gap in its live window; a status newer than HQ knows makes the session `unknown`. A message over 8,388,608 bytes, including its continuation fragments, is skipped through its final fragment without being buffered; a request whose response was skipped fails at its 30-second deadline. A turn start, turn end or approval resolution that fails validation, or a skipped message, whose session can't be known so every session HQ controls is affected, is made up for by reading the session from the daemon, one session at a time and outside the order other sessions' events keep:
73
+ One Codex connection carries every managed Codex session, so a message HQ can't validate never fails it. A notification about items, text deltas, token usage or a session's status that fails validation is dropped, and a session HQ controls reports a gap in its live window; a status newer than HQ knows makes the session `unknown`. A message over 33,554,432 bytes, including its continuation fragments, is skipped through its final fragment without being buffered; a request whose response was skipped fails at its 30-second deadline. A turn start, turn end or approval resolution that fails validation, or a skipped message, whose session can't be known so every session HQ controls is affected, is made up for by reading the session from the daemon, one session at a time and outside the order other sessions' events keep:
74
74
 
75
75
  - a turn the saved history shows finished completes its receipt, without a `result`, and lets queued input waiting on it advance;
76
76
  - a running turn whose start was lost continues, and after a skipped message it continues watched: when Codex next reports the session neither running nor waiting while that turn is still recorded as active, the session is read as if the turn's end had been lost;
@@ -82,7 +82,7 @@ A session with an action in flight when a message is skipped, or when its turn s
82
82
 
83
83
  `requestAgentHq(stateRoot, command, signal?)` is a one-command IPC client. It verifies the private owner and socket, binds the command to the runtime epoch and checks the matching response. Cancellation closes that client's socket and reports transport failure; it never undoes an admitted action. Closing a client does not close the host. `stop` accepts a shutdown request; the SDK caller must await `runtime.closed` when it owns the runtime. The CLI confirms owner removal before reporting `state: stopped`.
84
84
 
85
- The socket accepts at most 32 simultaneous connections. Requests are bounded to 65,536 UTF-8 bytes; native and IPC response frames to 8,388,608 bytes. Structured transports reject malformed UTF-8/JSON, oversized frames and incomplete tails. Each native connection has at most 32 pending calls with a 30-second response deadline. IPC connections have a 35-second deadline. The SQLite worker bounds its queue to 128 commands, accommodating client reads, native lifecycle observations and action dispatch; collection operations remain limited to one page. Database work runs off the host event loop. The state directory is a same-user trust boundary, not a sandbox against other code running as that user.
85
+ The socket accepts at most 32 simultaneous connections. Requests are bounded to 65,536 UTF-8 bytes; native and IPC response frames to 33,554,432 bytes. HQ sends a Codex message over 1,048,576 bytes as fragments of at most that size. Structured transports reject malformed UTF-8/JSON, oversized frames and incomplete tails. Each native connection has at most 32 pending calls with a 30-second response deadline. IPC connections have a 35-second deadline. The SQLite worker bounds its queue to 128 commands, accommodating client reads, native lifecycle observations and action dispatch; collection operations remain limited to one page. Database work runs off the host event loop. The state directory is a same-user trust boundary, not a sandbox against other code running as that user.
86
86
 
87
87
  ## Provider adapters and capabilities
88
88
 
@@ -101,7 +101,7 @@ The current built-in surfaces map to these native entry points:
101
101
  | Create/adopt/resume | `thread/start`, `thread/read`, `thread/resume` | Structured session creation/resume and idle/session-ID fences |
102
102
  | Rename | `thread/name/set` | `rename_session` control request |
103
103
  | Message/queue | `turn/start` with explicit native input | Structured user messages with matching acknowledgements |
104
- | Steer | `turn/steer` for the exact active turn | Explicitly unsupported by the structured interface |
104
+ | Steer | `turn/steer` for the exact active turn | A structured user message into the exact active turn, acknowledged by its replay |
105
105
  | Interrupt | `turn/interrupt` | `interrupt` control request; completion remains separate |
106
106
  | Close/recover | Native background-terminal cleanup/verification and `thread/unsubscribe` | Confirmed process-group shutdown and explicit session release/resume |
107
107
  | Runtime restart | Sessions keep running, and the next runtime rejoins them | Turns stop with the runtime; sessions wait inactive for an explicit resume |
@@ -172,7 +172,7 @@ Text chunks contain at most 32,768 UTF-8 bytes and shrink when escaping or metad
172
172
 
173
173
  `HistoryItemSchema` and evidence fragments expose `provenance: { origin, source, nativeInputId, nativeInputSha256, actionId, contentBoundary: 'untrusted', grantsAuthority: false }`. Origins are operator, agent, tool, system or unknown. Native assistant/tool kinds establish only their observed category. A native user role, quoted operator text or an imported message cannot establish an operator. HQ correlates a submitted input only when its exact native message/client identity, thread/turn and `nativeInputSha256` match the acknowledged action ledger. A provider's user message carries `nativeInputSha256`, the SHA-256 of the text its native input sent: a Codex message's first text part, or a Claude record's string content or first text block, with a slash command or skill, which Claude records as command markup, read back as the `/name args` it sent. It is hashed before the parts the same input added after the text, such as a skill or attached files, and before a page cuts the text, so those messages correlate too. Programmatic host submissions have source `host-action` and unknown actor. An authenticated browser submission additionally requires the same selected thread and text fingerprint, yielding `authenticated-host-action` and operator provenance. A message without a native input identity, or whose sent text differs from the action's, stays unknown. Provenance remains historical evidence and grants no current approval, execution authority or tool permission; quotations remain inside its untrusted content boundary.
174
174
 
175
- Codex uses its native descending item API with unloaded thread metadata. It never reads Codex transcript files. Claude uses indexed current-chain byte locations, exact UUID lookups and separate bounded seeks per selected kind. Its cold index uses 16 MiB batches and a 30-second operation budget; selected evidence reads parse at most 4 MiB of records beyond the first. Continuation revalidates and rereads one bounded native page to detect content changes rather than caching transcript bodies. Work and memory per read are bounded independently of history growth; reconstructing a large body may reread that source page. No conversation-body cache is maintained.
175
+ Codex uses its native descending item API with unloaded thread metadata. It never reads Codex transcript files. Claude uses indexed current-chain byte locations, exact UUID lookups and separate bounded seeks per selected kind. Its cold index uses 64 MiB batches and a 30-second operation budget; selected evidence reads parse at most 4 MiB of records beyond the first. Continuation revalidates and rereads one bounded native page to detect content changes rather than caching transcript bodies. Work and memory per read are bounded independently of history growth; reconstructing a large body may reread that source page. No conversation-body cache is maintained.
176
176
 
177
177
  ## Native accounts and extensions
178
178
 
@@ -217,13 +217,13 @@ Managed threads expose `nativeLineage: { sessionId, parentThreadId, forkedFromId
217
217
 
218
218
  Text and native skill inputs accept optional `files: [{ path, mediaType }]`. Paths may be absolute or relative to the managed workspace and must resolve inside an operator-authorized root. HQ opens a checked regular-file descriptor, validates UTF-8 or the declared format signature, and binds the canonical path, byte count and SHA-256 before admission. It rereads and verifies that binding immediately before native delivery. Missing, changed or escaping queued files fail without sending input. Symlinks cannot redirect delivery outside the trusted roots. URLs are never fetched.
219
219
 
220
- The fixed limits are 8 references, 2,097,152 aggregate file bytes and 65,536 bytes per UTF-8 text file. Empty files, NUL-containing or invalid UTF-8 text, wrong signatures, unsupported media and oversized input are rejected. The 32,768-byte action envelope contains references, never base64. File bytes are encoded only inside the native 8 MiB frame; the file limits leave room even for worst-case JSON escaping.
220
+ The fixed limits are 8 references, 16,777,216 aggregate file bytes and 262,144 bytes per UTF-8 text file. Empty files, NUL-containing or invalid UTF-8 text, wrong signatures, unsupported media and oversized input are rejected. The 32,768-byte action envelope contains references, never base64. File bytes are encoded only inside the native 32 MiB frame; the file limits leave room even for worst-case JSON escaping.
221
221
 
222
222
  Codex supports PNG, JPEG, WebP and UTF-8 text. Images use native `image` data inputs; text files become complete text inputs labeled with their canonical path and hash. Claude supports those formats plus GIF and PDF, using native image/document blocks. Media signatures establish the declared format, not complete image/PDF validity; native decoder or model rejection remains a provider failure. `capabilities.inputSchema` includes `supportedMediaTypes`, `maxFiles`, `maxFileBytes` and `maxTextFileBytes`. Native model-specific media limitations remain native errors.
223
223
 
224
224
  Select a bounded JSON `outputSchema` in session settings or, for Codex, on a message/queue entry. Schemas are limited to 8,192 serialized UTF-8 bytes, 16 levels and 1,024 visited nodes, and must be supported by the installed Zod JSON Schema validator. External references are rejected and no remote schema is retrieved. Codex sends the selected schema as `turn/start.outputSchema`. Claude starts its owned structured process with `--json-schema`; a different schema requires close and explicit resume of the same native session. Its capability descriptor marks this as `idle-restart`.
225
225
 
226
- Selected action receipts expose nullable `result: { state, format, text, structuredOutput, isComplete, failure, usage }`. Results come from the complete native final message/result, independently of the 65,536-character history/live preview. The serialized result budget is 8,257,536 UTF-8 bytes, leaving 128 KiB of the 8 MiB IPC frame for action and transport metadata. Structured results retain the complete parsed value with `text: null`, avoiding a second escaped copy of the same JSON. This admits a 1 MiB UTF-8 result even when JSON escaping expands its content. HQ validates native structured output against the requested schema without stripping fields. Invalid or missing schema output fails the turn; oversized capture fails explicitly with no saved excerpt. Invalid but bounded JSON remains untrusted evidence in `structuredOutput`. The result is saved with native turn completion, survives a runtime restart and is omitted from action-list reads.
226
+ Selected action receipts expose nullable `result: { state, format, text, structuredOutput, isComplete, failure, usage }`. Results come from the complete native final message/result, independently of the 65,536-character history/live preview. The serialized result budget is 8,257,536 UTF-8 bytes, which leaves room in the 32 MiB IPC frame for action and transport metadata. Structured results retain the complete parsed value with `text: null`, avoiding a second escaped copy of the same JSON. This admits a 1 MiB UTF-8 result even when JSON escaping expands its content. HQ validates native structured output against the requested schema without stripping fields. Invalid or missing schema output fails the turn; oversized capture fails explicitly with no saved excerpt. Invalid but bounded JSON remains untrusted evidence in `structuredOutput`. The result is saved with native turn completion, survives a runtime restart and is omitted from action-list reads.
227
227
 
228
228
  `failure` is null or `native-error`, `invalid-structured-output`, `result-too-large`, or `missing-result`. A native turn can complete without a final assistant message; without a requested schema, that remains completed with `isComplete: false` and `missing-result`. It cannot supply a complete report. Interrupted native execution remains interrupted unless capture itself exceeds the result budget. None of these outcomes causes automatic replay.
229
229
 
@@ -233,11 +233,11 @@ Selected action receipts expose nullable `result: { state, format, text, structu
233
233
 
234
234
  Claude connects on its first read through `claude --print --input-format stream-json --output-format stream-json --verbose`. No user prompt, bare mode, permission bypass or SDK dependency is used. Runtime status reports this adapter as `idle`, `ready` or `unavailable`, with its observed CLI version. History reads start this process only until it has once started and initialized: the runtime keeps that check, so later history reads use the transcripts alone, while usage, models and other reads that use the connection still open it. This session-less process closes after 5 minutes without a read and opens again on the next read that needs it; while it is closed, status reports `idle` with the last observed version. An unavailable native lane requires restarting the host after resolving the native problem.
235
235
 
236
- The structured CLI interface has no session-history listing operation. The Claude-owned reader therefore uses direct UUID JSONL files in the native project's directory beneath `CLAUDE_CONFIG_DIR`, or the normal `.claude` directory. CLI and transcript version labels do not gate reads. Required session identity, workspace, parent links, timestamps and message roles are validated, while additive fields and mixed version labels are tolerated. Claude Code can write a hidden record, such as an attachment or a scheduled-task event, a few lines before the record it follows; the reader holds it back until that parent is indexed, and one whose parent the read doesn't reach starts a turn of its own. A message whose parent is unknown is never accepted. Encoded project keys longer than 200 characters, directory/file links, malformed required fields and records larger than 8 MiB report unavailable. Discovery never recurses into subdirectories, including excluded directories. Unsupported discovered sessions have `historyState: unavailable`; they do not prevent supported sessions from being listed.
236
+ The structured CLI interface has no session-history listing operation. The Claude-owned reader therefore uses direct UUID JSONL files in the native project's directory beneath `CLAUDE_CONFIG_DIR`, or the normal `.claude` directory. CLI and transcript version labels do not gate reads. Required session identity, workspace, parent links, timestamps and message roles are validated, while additive fields and mixed version labels are tolerated. Claude Code can write a hidden record, such as an attachment or a scheduled-task event, a few lines before the record it follows; the reader holds it back until that parent is indexed, and one whose parent the read doesn't reach starts a turn of its own. A message whose parent is unknown is never accepted. Encoded project keys longer than 200 characters, directory/file links, malformed required fields and records larger than 32 MiB report unavailable. Discovery never recurses into subdirectories, including excluded directories. Unsupported discovered sessions have `historyState: unavailable`; they do not prevent supported sessions from being listed.
237
237
 
238
238
  Discovery verifies the workspace recorded inside each transcript before returning its identity or title. A matching native directory name alone is insufficient because punctuation replacement can produce colliding directory keys, so a transcript belongs to the selected workspace once one of its records ran there: in the workspace or a subdirectory, including a removed one, whose nearest existing path ancestor resolves inside the workspace without excluded segments. A symlink escape doesn't count as inside. The session's other records may name any other folder, such as a sibling task worktree it moved into, and are listed and read with the rest. Every record must carry the session's own ID, and no record's folder, nor its nearest existing ancestor's real path, may have an excluded segment; otherwise the history is unavailable. A transcript with no record inside the workspace is omitted until one is written. If a file's workspace cannot be established, discovery reports unavailable rather than inventing an empty result.
239
239
 
240
- The existing SQLite worker incrementally records file identity, complete-line offsets, message identities and parent links. It does not save message bodies. File identity includes the current reader projection revision and a native prefix hash, so source changes invalidate the derived projection. Each worker batch inspects at most 128 directory entries and reads at most 16 MiB of new transcript bytes, one file at a time, which fits the largest record. The adapter continues batches with a host-event-loop yield between them, within a 30-second operation budget. If that budget is reached, the read reports unavailable and subsequent reads continue indexing. At most four incomplete discovery iterators remain open. Shutdown closes them. Discovery continuations use that projection without starting another directory scan; start a fresh first page to refresh discovery. A transcript whose identity, size and modification time match a projection that reached its end is neither read nor written again. Each directory scan keeps the transcripts it has seen in memory, and only a complete scan removes the others from the projection, so reads over unchanged transcripts write nothing to SQLite. No additional cache infrastructure or browser cache is used.
240
+ The existing SQLite worker incrementally records file identity, complete-line offsets, message identities and parent links. It does not save message bodies. File identity includes the current reader projection revision and a native prefix hash, so source changes invalidate the derived projection. Each worker batch inspects at most 128 directory entries and reads at most 64 MiB of new transcript bytes, one file at a time, which fits the largest record. The adapter continues batches with a host-event-loop yield between them, within a 30-second operation budget. If that budget is reached, the read reports unavailable and subsequent reads continue indexing. At most four incomplete discovery iterators remain open. Shutdown closes them. Discovery continuations use that projection without starting another directory scan; start a fresh first page to refresh discovery. A transcript whose identity, size and modification time match a projection that reached its end is neither read nor written again. Each directory scan keeps the transcripts it has seen in memory, and only a complete scan removes the others from the projection, so reads over unchanged transcripts write nothing to SQLite. No additional cache infrastructure or browser cache is used.
241
241
 
242
242
  Current-chain membership and turn starts are indexed as metadata. Ordinary item and turn continuations seek those indexes; they do not walk the full chain per page. A changed branch rebuilds membership before exposing that revision. Repeated native message identities can replace content while retaining their parent; a changed parent for the same identity is an unsupported format.
243
243
 
@@ -249,26 +249,26 @@ File timestamps and records do not prove that a native process is idle or a turn
249
249
 
250
250
  Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one UUID per user intent, take the epoch from `status`, and retain the complete envelope until its receipt can be read. The validated envelope is limited to 32,768 UTF-8 bytes. It is recorded before native writes. Reusing the UUID with the identical envelope returns the saved receipt without dispatch; a changed envelope conflicts. This check also works for an original request read after restart. A new UUID with an expired epoch cannot execute.
251
251
 
252
- | Action | Fields and behavior |
253
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
254
- | `thread-fork` | Source `threadId`, child `name`. Requires an idle owned source or an inactive managed source. Creates a distinct native session and retains `forkedFromThreadId` and exact native lineage. |
255
- | `thread-archive` | Idle owned `threadId`. Confirms native background cleanup, archives natively and releases control. |
256
- | `thread-unarchive` | Inactive archived `threadId`. Unarchives the exact native session and leaves it inactive. |
257
- | `thread-compact` | Idle owned `threadId`. Records native admission separately from its correlated turn completion. Clears the live presentation and requires a fresh history read. |
258
- | `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. |
259
- | `thread-create` | `provider` (a registered provider ID), `workspaceRoot`, `name`. Creates an empty native thread and sets its readable name before reporting acknowledgement. |
260
- | `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 with optional `settings`, which it refuses while another client holds the thread; Claude requires qualified workspace history and the native idle/session-identity checks, and refuses while a terminal runs it. |
261
- | `thread-resume` | `threadId`, `operatorConfirmation`. Resumes an inactive managed thread; HQ does not fetch its complete conversation bodies. |
262
- | `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. |
263
- | `thread-rename` | `threadId`, `name`. Changes the name only after the matching native acknowledgement. |
264
- | `thread-close` | `threadId`. Requires an idle thread and pauses its queue. Codex cleans and verifies its native terminal list before unsubscribe. Claude closes the owned CLI and proves process-group exit before releasing control. |
265
- | `message` | `threadId`, `input`. Starts a turn only while idle. |
266
- | `steer` | `threadId`, `expectedTurnId`, `text`. Codex uses native `turn/steer`. Claude rejects this operation; it never substitutes interruption. A finished or changed turn cannot become a new turn. |
267
- | `queue` | `threadId`, `expectedTurnId`, `input`. Saves an explicit next-turn message or skill invocation, never a permission or question answer. |
268
- | `queue-send` | `queuedActionId`. Explicitly authorizes a still-undelivered queue entry, including a queue paused by restart or interruption. |
269
- | `queue-cancel` | `queuedActionId`. Cancels only an undelivered queue entry and clears its saved body. |
270
- | `interrupt` | `threadId`, `expectedTurnId`. A native request acknowledgement leaves the thread stopping until native completion evidence arrives. |
271
- | `native-reply` | `threadId`, `expectedTurnId`, `approvalId`, `response`. Answers one exact current native request; cannot consume queue text. |
252
+ | Action | Fields and behavior |
253
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
254
+ | `thread-fork` | Source `threadId`, child `name`. Requires an idle owned source or an inactive managed source. Creates a distinct native session and retains `forkedFromThreadId` and exact native lineage. |
255
+ | `thread-archive` | Idle owned `threadId`. Confirms native background cleanup, archives natively and releases control. |
256
+ | `thread-unarchive` | Inactive archived `threadId`. Unarchives the exact native session and leaves it inactive. |
257
+ | `thread-compact` | Idle owned `threadId`. Records native admission separately from its correlated turn completion. Clears the live presentation and requires a fresh history read. |
258
+ | `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. |
259
+ | `thread-create` | `provider` (a registered provider ID), `workspaceRoot`, `name`. Creates an empty native thread and sets its readable name before reporting acknowledgement. |
260
+ | `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 with optional `settings`, which it refuses while another client holds the thread; Claude requires qualified workspace history and the native idle/session-identity checks, and refuses while a terminal runs it. |
261
+ | `thread-resume` | `threadId`, `operatorConfirmation`. Resumes an inactive managed thread; HQ does not fetch its complete conversation bodies. |
262
+ | `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. |
263
+ | `thread-rename` | `threadId`, `name`. Changes the name only after the matching native acknowledgement. |
264
+ | `thread-close` | `threadId`. Requires an idle thread and pauses its queue. Codex cleans and verifies its native terminal list before unsubscribe. Claude closes the owned CLI and proves process-group exit before releasing control. |
265
+ | `message` | `threadId`, `input`. Starts a turn only while idle. |
266
+ | `steer` | `threadId`, `expectedTurnId`, `text`. Codex uses native `turn/steer`. Claude writes the text as a user message into the exact active turn, never interrupting it, and acknowledges it when Claude replays it: at the turn's next tool boundary, where the turn takes it in and ends with one result, or, for text written while the turn's final answer streams, after the turn's result, where it runs as the session's next turn under its own UUID. Either replay acknowledges the steer against the turn it named. A Claude steer never replayed fails 30 seconds after that turn ends, and one pending when the process stops fails at once. Otherwise a finished or changed turn cannot become a new turn. |
267
+ | `queue` | `threadId`, `expectedTurnId`, `input`. Saves an explicit next-turn message or skill invocation, never a permission or question answer. |
268
+ | `queue-send` | `queuedActionId`. Explicitly authorizes a still-undelivered queue entry, including a queue paused by restart or interruption. |
269
+ | `queue-cancel` | `queuedActionId`. Cancels only an undelivered queue entry and clears its saved body. |
270
+ | `interrupt` | `threadId`, `expectedTurnId`. A native request acknowledgement leaves the thread stopping until native completion evidence arrives. |
271
+ | `native-reply` | `threadId`, `expectedTurnId`, `approvalId`, `response`. Answers one exact current native request; cannot consume queue text. |
272
272
 
273
273
  Message and queue input is a closed union: `{ kind: 'text', text }` or `{ kind: 'skill', skillId, arguments }`. Text is nonempty and at most 65,536 characters; skill arguments may be empty and cap at 16,384 characters. The envelope's UTF-8 limit still applies. A selected skill is resolved through the target thread's current native catalog before admission. Unavailable, missing or disabled selections cannot dispatch. Normal text needs no catalog read. Steering retains its `text` field and exact active-turn target.
274
274
 
@@ -442,6 +442,7 @@ The operation matrix describes the implemented native interfaces and their expli
442
442
  | Claude permission requests | Claude Code 2.1.316 on 2026-11-01, in the default permission mode: a Write request carried `description`, `display_name`, `input`, `permission_suggestions`, `subtype`, `tool_name` and `tool_use_id`, and an error reply was recorded in the transcript as the tool call's failed result with the reply's text. | Fields such as `decision_reason_code` and `tool_kind` appear only in other modes, so their shape comes from the CLI's own code, not an observed request. |
443
443
  | Claude turns it starts itself | Claude Code 2.1.316 on 2026-11-01, in the auto permission mode with its input held open: when a background command finished after its turn, Claude sent `system:task_notification` and started a turn of its own, `system:init` then stream and assistant frames, ending in a `result` without `user_message_uuid`. Input written during that turn was replayed after its result as its own turn. Each HQ input's replayed message came before its turn's first stream and assistant frames. An interrupt ended such a turn with the interruption marker, then an `error_during_execution` result. `system:background_tasks_changed` listed the background commands running, and was empty once the last one ended. | The frame order is an observation of this version, not a native contract. |
444
444
  | Approvals on other clients' sessions | Codex 0.166.0 on 2026-11-01, on the shared daemon: connection A joined a thread connection B started, with `thread/resume`. When B's turn asked to run a command, the daemon sent the same approval request, with the same request ID, to both connections, and sent both `serverRequest/resolved` once B answered. | A thread only accepts `thread/resume` once its first turn has written its rollout. |
445
+ | Large file inputs | Claude Code 2.1.316 and Codex 0.166.0 on 2026-11-02. Claude took one message with a 15,814,657-byte, three-page PDF and a 262,144-byte text file, 16,076,801 bytes in all, and answered from both; its transcript held the message as a 21,355,974-byte record, which history read on a page of its own. Codex took one message with seven PNG images of about 2.4 MB each and a text file, 16,531,190 bytes in all, sent to the shared daemon in 1,048,576-byte WebSocket fragments, and answered from every image. In each session a text-only follow-up turn then completed, and its history pages and every message's item detail read. | The provider's own limits on PDF pages and image sizes were not reached. A Claude session keeps each attachment in its transcript, so it grows by the attachments' base64 size. |
445
446
  | Claude active sessions | Claude Code 2.1.310 answered `claude agents --json` in 0.16 s. Interactive entries carry `status` (`busy`, `waiting`, `idle`) and `pid`; background entries carry `id` and `state` (`blocked`). Sessions HQ starts in structured mode are listed as interactive under their HQ name and disappear after close. | The list describes running processes only; history still comes from transcripts. |
446
447
  | Host coverage | Linux x86_64 package checks passed on Node 24.15.0 and 24.22.1. Identity, native interaction and recovery ran on the floor and on 24.22.1. | No macOS host was available for this run. Windows is outside the declared host contract. |
447
448
 
@@ -1,4 +1,4 @@
1
- // serialized accounting includes escaping/identifiers and leaves space inside the 8 MiB IPC frame
1
+ // serialized accounting includes escaping/identifiers and leaves space inside the IPC frame
2
2
  const MAX_LIVE_BYTES = 4 * 1024 * 1024;
3
3
  /** Keeps a bounded presentation window until matching native history has been flushed. */
4
4
  export class LiveItems {
@@ -1,4 +1,7 @@
1
1
  import { z } from 'zod';
2
+ export declare const MAX_INPUT_FILES = 8;
3
+ export declare const MAX_INPUT_FILE_BYTES = 16777216;
4
+ export declare const MAX_TEXT_FILE_BYTES = 262144;
2
5
  export declare const InputFileSchema: z.ZodObject<{
3
6
  path: z.ZodString;
4
7
  mediaType: z.ZodEnum<{
@@ -25,6 +28,3 @@ export declare const BoundInputFileSchema: z.ZodObject<{
25
28
  bytes: z.ZodNumber;
26
29
  }, z.core.$strict>;
27
30
  export type IBoundInputFile = z.infer<typeof BoundInputFileSchema>;
28
- export declare const MAX_INPUT_FILES = 8;
29
- export declare const MAX_INPUT_FILE_BYTES = 2097152;
30
- export declare const MAX_TEXT_FILE_BYTES = 65536;
@@ -1,4 +1,12 @@
1
1
  import { z } from 'zod';
2
+ /*
3
+ * Fixed aggregate budgets leave headroom in the native 32 MiB structured frame: in the worst
4
+ * case, seven text files of characters JSON escapes six times over plus one binary file in
5
+ * base64 fill about 30 MiB of it.
6
+ */
7
+ export const MAX_INPUT_FILES = 8;
8
+ export const MAX_INPUT_FILE_BYTES = 16_777_216;
9
+ export const MAX_TEXT_FILE_BYTES = 262_144;
2
10
  // references travel over local IPC; file bytes are read only inside the trusted host
3
11
  export const InputFileSchema = z.strictObject({
4
12
  path: z.string().min(1).max(4096),
@@ -13,9 +21,5 @@ export const InputFileSchema = z.strictObject({
13
21
  });
14
22
  export const BoundInputFileSchema = InputFileSchema.extend({
15
23
  sha256: z.string().regex(/^[a-f0-9]{64}$/),
16
- bytes: z.number().int().positive().max(2_097_152),
24
+ bytes: z.number().int().positive().max(MAX_INPUT_FILE_BYTES),
17
25
  });
18
- // fixed aggregate budgets leave headroom in the native 8 MiB structured frame
19
- export const MAX_INPUT_FILES = 8;
20
- export const MAX_INPUT_FILE_BYTES = 2_097_152;
21
- export const MAX_TEXT_FILE_BYTES = 65_536;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- // reserve 128 KiB in the 8 MiB frame for action and transport metadata
2
+ // a result keeps its 8 MiB less 128 KiB budget, which leaves room in the IPC frame for metadata
3
3
  export const MAX_RESULT_BYTES = 8_388_608 - 131_072;
4
4
  /** Rejects pathological schema depth and size before recursive library validation. */
5
5
  const boundSchema = (input) => {
@@ -1,5 +1,5 @@
1
1
  export declare const MAX_CONNECTIONS = 32;
2
2
  export declare const MAX_REQUEST_BYTES = 65536;
3
- export declare const MAX_FRAME_BYTES = 8388608;
3
+ export declare const MAX_FRAME_BYTES = 33554432;
4
4
  export declare const IPC_TIMEOUT_MS = 35000;
5
5
  export declare const CONTROL_SOCKET = "hq.sock";
@@ -1,6 +1,6 @@
1
1
  // limits bound simultaneous local clients and all buffered protocol input
2
2
  export const MAX_CONNECTIONS = 32;
3
3
  export const MAX_REQUEST_BYTES = 65_536;
4
- export const MAX_FRAME_BYTES = 8_388_608;
4
+ export const MAX_FRAME_BYTES = 33_554_432;
5
5
  export const IPC_TIMEOUT_MS = 35_000;
6
6
  export const CONTROL_SOCKET = 'hq.sock';
@@ -73,14 +73,7 @@ export const createClaudeProviderFactory = (store, additionalDirectories) => ({
73
73
  close: SUPPORTED_PROVIDER_OPERATION,
74
74
  interrupt: SUPPORTED_PROVIDER_OPERATION,
75
75
  recover: SUPPORTED_PROVIDER_OPERATION,
76
- steer: {
77
- state: 'unsupported',
78
- changeMode: null,
79
- reason: {
80
- code: 'native-control-unsupported',
81
- message: 'The structured Claude interface does not support steering an active turn.',
82
- },
83
- },
76
+ steer: SUPPORTED_PROVIDER_OPERATION,
84
77
  history: SUPPORTED_PROVIDER_OPERATION,
85
78
  usage: SUPPORTED_PROVIDER_OPERATION,
86
79
  models,
@@ -273,7 +266,7 @@ export const createClaudeProviderFactory = (store, additionalDirectories) => ({
273
266
  control.validateInput(nativeId, input.settings);
274
267
  },
275
268
  startTurn: (requestId, nativeId, text, _skill, settings, files, call) => control.startTurn(requestId, nativeId, text, settings, call.signal, files),
276
- steer: async () => capabilityUnavailable(),
269
+ steer: (requestId, nativeId, expectedTurnId, text) => control.steer(requestId, nativeId, expectedTurnId, text),
277
270
  interrupt: (requestId, nativeId, nativeTurnId) => control.interrupt(requestId, nativeId, nativeTurnId),
278
271
  cleanThread: (requestId, nativeId) => control.stopSession(requestId, nativeId),
279
272
  releaseThread: (requestId, nativeId) => control.releaseSession(requestId, nativeId),
@@ -232,6 +232,21 @@ export declare const createClaudeControl: (additionalDirectories?: string[]) =>
232
232
  startTurn(requestId: string, nativeId: string, text: string, settings?: ITurnSettings, signal?: AbortSignal, files?: IProviderInputFile[]): Promise<{
233
233
  id: string;
234
234
  }>;
235
+ /**
236
+ * Writes text into the exact active turn, HQ input's or one Claude started, without
237
+ * interrupting it. Claude takes it in at the turn's next tool boundary and replays it there,
238
+ * or, for text written while the turn's final answer streams, replays it after the turn's
239
+ * result and runs it as the session's next turn. Either replay acknowledges the steer against
240
+ * the turn it named; a stopped process, or no replay within 30 seconds of that turn's end,
241
+ * fails it.
242
+ * @returns The turn the steer named, once Claude replayed it.
243
+ * @throws
244
+ * - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
245
+ * - JG_AGENT_HQ_CAPABILITY_UNAVAILABLE: The HQ capability is unavailable
246
+ * - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
247
+ * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
248
+ */
249
+ steer(_requestId: string, nativeId: string, turnId: string, text: string): Promise<string>;
235
250
  /**
236
251
  * Requests interruption of the exact active turn, HQ input's or one Claude started; completion
237
252
  * arrives separately.
@@ -7,7 +7,7 @@ import { toClaudeConfiguration } from '../configuration/index.js';
7
7
  import { createClaudeExtensions } from '../extensions/index.js';
8
8
  import { createClaudeRpc } from '../rpc.js';
9
9
  import { ClaudeInitializeSchema } from '../types.js';
10
- import { receiveClaudeMessage } from './stream.js';
10
+ import { failSteers, getActiveTurn, receiveClaudeMessage } from './stream.js';
11
11
  import { toClaudeSkills } from './skills.js';
12
12
  // a session idle this long since its last turn ended gives up its process until it is needed
13
13
  const IDLE_STOP_SECONDS = 3_600;
@@ -231,6 +231,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
231
231
  const connection = await createClaudeRpc((reason) => {
232
232
  if (reason !== 'unavailable' || session.isClosing || session.parked)
233
233
  return;
234
+ failSteers(session);
234
235
  if (session.input) {
235
236
  clearTimeout(session.input.timer);
236
237
  session.input.reject(new Exception('The Claude integration failed', {
@@ -337,6 +338,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
337
338
  opening: Promise.resolve(),
338
339
  previews: new Map(),
339
340
  requests: new Map(),
341
+ steers: new Map(),
340
342
  };
341
343
  sessions.set(nativeId, session);
342
344
  session.opening = start(session, isResume, forkSourceNativeId, signal);
@@ -622,6 +624,45 @@ export const createClaudeControl = (additionalDirectories = []) => {
622
624
  });
623
625
  }, signal);
624
626
  },
627
+ /**
628
+ * Writes text into the exact active turn, HQ input's or one Claude started, without
629
+ * interrupting it. Claude takes it in at the turn's next tool boundary and replays it there,
630
+ * or, for text written while the turn's final answer streams, replays it after the turn's
631
+ * result and runs it as the session's next turn. Either replay acknowledges the steer against
632
+ * the turn it named; a stopped process, or no replay within 30 seconds of that turn's end,
633
+ * fails it.
634
+ * @returns The turn the steer named, once Claude replayed it.
635
+ * @throws
636
+ * - JG_AGENT_HQ_ACTION_CONFLICT: The HQ action conflicts with its recorded state
637
+ * - JG_AGENT_HQ_CAPABILITY_UNAVAILABLE: The HQ capability is unavailable
638
+ * - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
639
+ * - JG_AGENT_HQ_TRANSPORT_FAILED: The HQ transport failed
640
+ */
641
+ async steer(_requestId, nativeId, turnId, text) {
642
+ // a parked session is idle, so it has no turn to steer
643
+ return withSession(nativeId, false, (session) => {
644
+ if (getActiveTurn(session)?.id !== turnId)
645
+ conflict();
646
+ if (session.isClosing || !session.connection?.isAvailable)
647
+ unavailable();
648
+ return new Promise((resolve, reject) => {
649
+ const id = randomUUID();
650
+ session.steers.set(id, { id, turnId, resolve, reject });
651
+ void session
652
+ .connection.write({
653
+ type: 'user',
654
+ uuid: id,
655
+ session_id: nativeId,
656
+ message: { role: 'user', content: text },
657
+ parent_tool_use_id: null,
658
+ })
659
+ .catch((error) => {
660
+ session.steers.delete(id);
661
+ reject(error);
662
+ });
663
+ });
664
+ });
665
+ },
625
666
  /**
626
667
  * Requests interruption of the exact active turn, HQ input's or one Claude started; completion
627
668
  * arrives separately.
@@ -654,6 +695,8 @@ export const createClaudeControl = (additionalDirectories = []) => {
654
695
  conflict();
655
696
  cancelIdleStop(session);
656
697
  session.isClosing = true;
698
+ // a stopped process replays nothing more
699
+ failSteers(session);
657
700
  // a parked session finishes without a process
658
701
  await session.transition?.catch(() => undefined);
659
702
  await session.opening.catch((cause) => {
@@ -689,6 +732,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
689
732
  const results = await Promise.allSettled([...sessions.values()].map(async (session) => {
690
733
  cancelIdleStop(session);
691
734
  session.isClosing = true;
735
+ failSteers(session);
692
736
  if (session.input) {
693
737
  clearTimeout(session.input.timer);
694
738
  session.input.reject(new Exception('The Claude integration failed', {
@@ -1,4 +1,15 @@
1
- import type { IClaudeControlEvents, IClaudeSession } from './types.js';
1
+ import type { IClaudeControlEvents, IClaudeSession, IClaudeTurn } from './types.js';
2
+ /**
3
+ * Returns the turn the session's frames belong to: a turn Claude started, or the acknowledged
4
+ * input's. Input still waiting for its replay has no turn yet.
5
+ */
6
+ export declare const getActiveTurn: (session: IClaudeSession) => IClaudeTurn | undefined;
7
+ /**
8
+ * Fails the steers Claude never replayed, as when its process stops, so no steer waits forever.
9
+ * @param session The session.
10
+ * @param turnId The turn whose steers fail, or every pending steer when omitted.
11
+ */
12
+ export declare const failSteers: (session: IClaudeSession, turnId?: string) => void;
2
13
  /**
3
14
  * Normalizes native stream evidence without retaining another conversation buffer. A turn frame
4
15
  * that arrives while no turn is active, and isn't the waiting input's replay, starts a turn of
@@ -90,7 +90,7 @@ const unavailable = () => {
90
90
  * Returns the turn the session's frames belong to: a turn Claude started, or the acknowledged
91
91
  * input's. Input still waiting for its replay has no turn yet.
92
92
  */
93
- const getActiveTurn = (session) => session.nativeTurn ?? (session.input?.isAcknowledged ? session.input : undefined);
93
+ export const getActiveTurn = (session) => session.nativeTurn ?? (session.input?.isAcknowledged ? session.input : undefined);
94
94
  /** Acknowledges the single current input before forwarding its ordered turn evidence. */
95
95
  const acknowledge = (session, events) => {
96
96
  const input = session.input;
@@ -127,6 +127,53 @@ const startNativeTurn = (session, events) => {
127
127
  });
128
128
  return turn;
129
129
  };
130
+ /**
131
+ * Fails the steers Claude never replayed, as when its process stops, so no steer waits forever.
132
+ * @param session The session.
133
+ * @param turnId The turn whose steers fail, or every pending steer when omitted.
134
+ */
135
+ export const failSteers = (session, turnId) => {
136
+ for (const steer of session.steers.values()) {
137
+ if (turnId !== undefined && steer.turnId !== turnId)
138
+ continue;
139
+ clearTimeout(steer.timer);
140
+ session.steers.delete(steer.id);
141
+ steer.reject(new Exception('The Claude integration failed', {
142
+ code: 'JG_AGENT_HQ_CLAUDE_FAILED',
143
+ data: { kind: 'agent-unavailable' },
144
+ }));
145
+ }
146
+ };
147
+ /*
148
+ * Claude replays a steer written while a turn's final answer streams only after that turn's
149
+ * result, at once; a steer still unreplayed this long after its turn ended fails.
150
+ */
151
+ const STEER_REPLAY_GRACE_MS = 30_000;
152
+ /** Gives the steers of a turn that just ended their grace period for a replay after its result. */
153
+ const awaitLateSteers = (session, turnId) => {
154
+ for (const steer of session.steers.values())
155
+ if (steer.turnId === turnId && steer.timer === undefined)
156
+ steer.timer = setTimeout(() => failSteers(session, turnId), STEER_REPLAY_GRACE_MS);
157
+ };
158
+ /**
159
+ * Takes in a steer's replay. During the turn it named, the steer joined it; after that turn's
160
+ * result, the steer runs as the session's next turn, under its own UUID, which its result names.
161
+ * Either way the steer is acknowledged against the turn it named.
162
+ */
163
+ const acknowledgeSteer = (session, steer, events) => {
164
+ clearTimeout(steer.timer);
165
+ session.steers.delete(steer.id);
166
+ if (!getActiveTurn(session)) {
167
+ session.nativeTurn = { id: steer.id, interruptRequested: false, hasInterruptionMarker: false };
168
+ events?.observe({
169
+ kind: 'turn-started',
170
+ provider: 'claude',
171
+ nativeThreadId: session.id,
172
+ nativeTurnId: steer.id,
173
+ });
174
+ }
175
+ steer.resolve(steer.turnId);
176
+ };
130
177
  /** Classifies a result: interrupted only after the marker of an interrupt HQ requested. */
131
178
  const toTurnState = (result, turn) => !result.is_error && result.subtype === 'success'
132
179
  ? 'completed'
@@ -184,6 +231,9 @@ export const receiveClaudeMessage = (session, raw, events) => {
184
231
  }
185
232
  if (frame.type === 'user' || frame.type === 'assistant') {
186
233
  const message = MessageSchema.parse(raw);
234
+ const steer = frame.type === 'user' ? session.steers.get(message.uuid) : undefined;
235
+ if (steer)
236
+ acknowledgeSteer(session, steer, events);
187
237
  const isReplay = frame.type === 'user' && session.input !== undefined && message.uuid === session.input.id;
188
238
  if (isReplay) {
189
239
  // Claude replays input written during its own turn only after that turn's result
@@ -286,13 +336,15 @@ export const receiveClaudeMessage = (session, raw, events) => {
286
336
  else if (frame.type === 'result') {
287
337
  const result = ResultSchema.parse(raw);
288
338
  observeFastMode(session, raw);
289
- if (result.user_message_uuid === undefined) {
290
- // a turn Claude started completes without a captured result, since no action owns it
339
+ // a turn Claude started, or one a steer runs after its turn, has no action to capture its result
340
+ if (result.user_message_uuid === undefined ||
341
+ result.user_message_uuid === session.nativeTurn?.id) {
291
342
  const turn = session.nativeTurn;
292
343
  if (!turn)
293
344
  unavailable();
294
345
  session.nativeTurn = undefined;
295
346
  endTurn(session, events);
347
+ awaitLateSteers(session, turn.id);
296
348
  events?.observe({
297
349
  kind: 'turn-completed',
298
350
  provider: 'claude',
@@ -309,6 +361,7 @@ export const receiveClaudeMessage = (session, raw, events) => {
309
361
  const state = toTurnState(result, input);
310
362
  session.input = undefined;
311
363
  endTurn(session, events);
364
+ awaitLateSteers(session, input.id);
312
365
  const observedUsage = UsageSchema.safeParse(result.usage);
313
366
  const usage = observedUsage.success
314
367
  ? {
@@ -29,6 +29,13 @@ export type IClaudeNativeTurn = {
29
29
  interruptRequested: boolean;
30
30
  hasInterruptionMarker: boolean;
31
31
  };
32
+ export type IClaudeSteer = {
33
+ id: string;
34
+ turnId: string;
35
+ resolve(turnId: string): void;
36
+ reject(error: unknown): void;
37
+ timer?: ReturnType<typeof setTimeout>;
38
+ };
32
39
  export type IClaudeTurn = IClaudeInput | IClaudeNativeTurn;
33
40
  export type IClaudeFastMode = {
34
41
  state: 'on' | 'cooldown' | 'off';
@@ -47,6 +54,7 @@ export type IClaudeSession = {
47
54
  skills?: IProviderSkills | null;
48
55
  input?: IClaudeInput;
49
56
  nativeTurn?: IClaudeNativeTurn;
57
+ steers: Map<string, IClaudeSteer>;
50
58
  backgroundTaskCount: number;
51
59
  fastMode?: IClaudeFastMode;
52
60
  apiMessageId?: string;
@@ -8,11 +8,11 @@ import { evidencePosition, buildEvidencePage, EVIDENCE_SOURCE_PAGE_SIZE, } from
8
8
  import { EntryRowSchema, EntrySeekSchema, FileRowSchema, RecordSchema, ApiRequestMetadataSchema, SeekSchema, } from './types.js';
9
9
  import { isClaudeAnswer, isClaudeCallFor, isClaudeRecordCwd, isClaudeWorkspaceCwd, openTranscript, projectDirectory, readClaudeParentUuid, toClaudeDetail, toClaudeImageData, toClaudeItem, } from './utilities.js';
10
10
  // identifies the path and record interpretation used by persisted projection entries
11
- const HISTORY_PROJECTION_VERSION = 8;
11
+ const HISTORY_PROJECTION_VERSION = 9;
12
12
  // one record, such as a tool result holding images, and an indexing read, which fits the largest
13
- const MAX_RECORD_BYTES = 8_388_608;
14
- const MAX_REFRESH_BYTES = 16_777_216;
15
- // the record bytes and serialized items of one page, which stays inside the 8 MiB IPC frame
13
+ const MAX_RECORD_BYTES = 33_554_432;
14
+ const MAX_REFRESH_BYTES = 67_108_864;
15
+ // the record bytes and serialized items of one page, which stays well inside the IPC frame
16
16
  const MAX_PAGE_BYTES = 4_194_304;
17
17
  // hidden records awaiting a parent later in the file; Claude Code writes them a few lines early
18
18
  const MAX_HELD_BACK_RECORDS = 64;
@@ -1,6 +1,7 @@
1
1
  export declare const WEBSOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
2
2
  export declare const MAX_HANDSHAKE_BYTES = 16384;
3
3
  export declare const KEEPALIVE_INTERVAL_MS = 10000;
4
+ export declare const MAX_OUTGOING_FRAGMENT_BYTES = 1048576;
4
5
  export declare const WEBSOCKET_OPCODES: {
5
6
  readonly continuation: 0;
6
7
  readonly text: 1;
@@ -7,6 +7,11 @@ export const MAX_HANDSHAKE_BYTES = 16_384;
7
7
  * dead daemon fails that write at once; a hung one misses the pong until the next ping.
8
8
  */
9
9
  export const KEEPALIVE_INTERVAL_MS = 10_000;
10
+ /*
11
+ * The largest payload one outgoing frame carries. A larger message goes as fragments, which RFC
12
+ * 6455 requires servers to accept, so no single frame meets a server's per-frame limit.
13
+ */
14
+ export const MAX_OUTGOING_FRAGMENT_BYTES = 1_048_576;
10
15
  // RFC 6455 frame opcodes used by the daemon connection
11
16
  export const WEBSOCKET_OPCODES = {
12
17
  continuation: 0x0,
@@ -1,7 +1,7 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { Exception } from 'jg-exception';
3
3
  import { MAX_FRAME_BYTES } from '../../../ipc/index.js';
4
- import { KEEPALIVE_INTERVAL_MS, MAX_HANDSHAKE_BYTES, WEBSOCKET_GUID, WEBSOCKET_OPCODES, } from './constants.js';
4
+ import { KEEPALIVE_INTERVAL_MS, MAX_HANDSHAKE_BYTES, MAX_OUTGOING_FRAGMENT_BYTES, WEBSOCKET_GUID, WEBSOCKET_OPCODES, } from './constants.js';
5
5
  /**
6
6
  * Rejects bytes that break the WebSocket contract.
7
7
  * @throws
@@ -15,13 +15,14 @@ const invalid = (cause) => {
15
15
  });
16
16
  };
17
17
  /**
18
- * Builds one final client frame, masked as RFC 6455 requires of clients.
18
+ * Builds one client frame, masked as RFC 6455 requires of clients.
19
+ * @param isFinal Whether the frame ends its message; a fragment before the last one is not.
19
20
  * @returns The complete frame bytes.
20
21
  */
21
- const encodeFrame = (opcode, payload) => {
22
+ const encodeFrame = (opcode, payload, isFinal = true) => {
22
23
  const lengthBytes = payload.length < 126 ? 0 : payload.length < 65_536 ? 2 : 8;
23
24
  const header = Buffer.alloc(2 + lengthBytes + 4);
24
- header[0] = 0x80 | opcode;
25
+ header[0] = (isFinal ? 0x80 : 0) | opcode;
25
26
  if (lengthBytes === 0)
26
27
  header[1] = 0x80 | payload.length;
27
28
  else if (lengthBytes === 2) {
@@ -39,6 +40,22 @@ const encodeFrame = (opcode, payload) => {
39
40
  masked[index] = payload[index] ^ mask[index & 3];
40
41
  return Buffer.concat([header, masked]);
41
42
  };
43
+ /**
44
+ * Builds one text message: a single final frame of at most MAX_OUTGOING_FRAGMENT_BYTES, or else a
45
+ * non-final text frame followed by continuation frames of at most that size, the last one final.
46
+ * @returns The frames' bytes, in order.
47
+ */
48
+ const encodeTextMessage = (payload) => {
49
+ if (payload.length <= MAX_OUTGOING_FRAGMENT_BYTES)
50
+ return encodeFrame(WEBSOCKET_OPCODES.text, payload);
51
+ const frames = [];
52
+ for (let start = 0; start < payload.length; start += MAX_OUTGOING_FRAGMENT_BYTES) {
53
+ const end = Math.min(start + MAX_OUTGOING_FRAGMENT_BYTES, payload.length);
54
+ const opcode = start === 0 ? WEBSOCKET_OPCODES.text : WEBSOCKET_OPCODES.continuation;
55
+ frames.push(encodeFrame(opcode, payload.subarray(start, end), end === payload.length));
56
+ }
57
+ return Buffer.concat(frames);
58
+ };
42
59
  /**
43
60
  * Speaks WebSocket over a byte stream, such as the Codex daemon's stdio proxy: an HTTP upgrade
44
61
  * with a verified accept key, masked text frames out, and bounded server frames in.
@@ -51,7 +68,7 @@ export const createWebSocketFraming = () => {
51
68
  .digest('base64');
52
69
  return {
53
70
  preamble: Buffer.from(`GET / HTTP/1.1\r\nHost: localhost\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${key}\r\nSec-WebSocket-Version: 13\r\n\r\n`, 'latin1'),
54
- encode: (message) => encodeFrame(WEBSOCKET_OPCODES.text, Buffer.from(JSON.stringify(message), 'utf8')),
71
+ encode: (message) => encodeTextMessage(Buffer.from(JSON.stringify(message), 'utf8')),
55
72
  createDecoder({ receive, reply, open, fail, discard }) {
56
73
  const chunks = [];
57
74
  let buffered = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "10.5.4",
3
+ "version": "10.7.0",
4
4
  "description": "Native Claude Code and Codex session control, history, usage and recoverable local storage for Node.js apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",