jg-agent-hq 10.5.4 → 10.6.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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.6.0
4
+
5
+ - 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.
6
+
3
7
  ## 10.5.4
4
8
 
5
9
  - 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,7 +75,7 @@ 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
 
package/api/README.md CHANGED
@@ -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 |
@@ -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
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "10.5.4",
3
+ "version": "10.6.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",