jg-agent-hq 13.5.3 → 13.5.4

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 13.5.4
4
+
5
+ - Keep Claude control when a steering message is replayed before the preceding turn's result but its own answer completes afterward. Match that completion only to an exact live replay observed by the same controller, retaining bounded correlation metadata and rejecting unknown or consumed identities.
6
+ - Retire replay metadata on new explicit input, controller replacement and shutdown. Preserve existing action receipts, paused queues, storage schema and native history without sending input again.
7
+
3
8
  ## 13.5.3
4
9
 
5
10
  - Keep controller creation, adoption, resume and recovery in the existing preparation state until native readiness. Opening a session without input no longer reports a turn starting or completing, preventing false completion notifications. Genuine input and autonomous native turns retain their lifecycle events.
package/README.md CHANGED
@@ -71,6 +71,8 @@ Explicit actions create, name, adopt, resume, close and delete threads; send idl
71
71
 
72
72
  Claude can save a steer as a queued-command attachment without echoing a live user message. Reading that saved input through history, details or evidence confirms a submitted or uncertain delivery when its exact action, session, workspace, turn and original-text fingerprint match. The existing turn-completion history flush performs the same check. This also resolves receipts from an earlier runtime without restoring control or resending input.
73
73
 
74
+ A steering replay can arrive before the preceding turn's result even when Claude answers it in a following turn. That following completion can name the exact replayed input instead of HQ's generated live turn ID. The controller retains a bounded set of these observed identities within its process generation, consumes a matching completion once and retires them on a new explicit input or controller replacement. Unknown results remain unavailable. This changes no receipt ownership, storage schema or queue delivery and never resends input.
75
+
74
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).
75
77
 
76
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. The runtime 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.
@@ -206,6 +206,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
206
206
  conflict();
207
207
  session.parked = undefined;
208
208
  session.scope = randomUUID();
209
+ session.replayedSteers?.clear();
209
210
  const scope = session.scope;
210
211
  session.opening = start(session, session.hasInput, signal);
211
212
  try {
@@ -115,6 +115,7 @@ const acknowledge = (session, events) => {
115
115
  if (!input || input.isAcknowledged)
116
116
  return;
117
117
  input.isAcknowledged = true;
118
+ session.replayedSteers?.clear();
118
119
  clearTimeout(input.timer);
119
120
  input.resolve({ id: input.id });
120
121
  const request = parseActionRequest(input.requestId);
@@ -162,6 +163,8 @@ export const setBackgroundCommands = (session, count, events) => {
162
163
  * @param failure The shared control failure, when its diagnostic cause is available.
163
164
  */
164
165
  export const failSteers = (session, turnId, failure = HQ_ERRORS.create('claudeFailed', { data: { kind: 'agent-unavailable' } })) => {
166
+ if (turnId === undefined)
167
+ session.replayedSteers?.clear();
165
168
  for (const steer of session.steers.values()) {
166
169
  if (turnId !== undefined && steer.turnId !== turnId)
167
170
  continue;
@@ -176,6 +179,8 @@ export const failSteers = (session, turnId, failure = HQ_ERRORS.create('claudeFa
176
179
  * result, at once; a steer still unreplayed this long after its turn ended fails.
177
180
  */
178
181
  const STEER_REPLAY_GRACE_MS = 30_000;
182
+ // match the bounded late-control identity window; eviction never accepts an unknown result
183
+ const MAX_REPLAYED_STEERS = 64;
179
184
  /** Gives the steers of a turn that just ended their grace period for a replay after its result. */
180
185
  const awaitLateSteers = (session, turnId) => {
181
186
  for (const steer of session.steers.values())
@@ -183,13 +188,20 @@ const awaitLateSteers = (session, turnId) => {
183
188
  steer.timer = setTimeout(() => failSteers(session, turnId), STEER_REPLAY_GRACE_MS);
184
189
  };
185
190
  /**
186
- * Takes in a steer's replay. During the turn it named, the steer joined it; after that turn's
187
- * result, the steer runs as the session's next turn, under its own UUID, which its result names.
188
- * Either way the steer is acknowledged against the turn it named.
191
+ * Takes in a steer's replay, which can precede the old result even when its answer runs next.
192
+ * With no active turn, the replay starts that following turn under its own UUID; otherwise keep
193
+ * its identity for a later native completion. Acknowledge delivery against the turn it named.
189
194
  */
190
195
  const acknowledgeSteer = (session, steer, events) => {
191
196
  clearTimeout(steer.timer);
192
197
  session.steers.delete(steer.id);
198
+ const replayed = (session.replayedSteers ??= new Set());
199
+ replayed.add(steer.id);
200
+ if (replayed.size > MAX_REPLAYED_STEERS) {
201
+ const oldest = replayed.values().next().value;
202
+ if (oldest !== undefined)
203
+ replayed.delete(oldest);
204
+ }
193
205
  if (!getActiveTurn(session)) {
194
206
  session.nativeTurn = { id: steer.id, interruptRequested: false, hasInterruptionMarker: false };
195
207
  events?.observe({
@@ -364,10 +376,13 @@ export const receiveClaudeMessage = (session, raw, events) => {
364
376
  observeFastMode(session, raw);
365
377
  // a turn Claude started, or one a steer runs after its turn, has no action to capture its result
366
378
  if (result.user_message_uuid === undefined ||
367
- result.user_message_uuid === session.nativeTurn?.id) {
379
+ result.user_message_uuid === session.nativeTurn?.id ||
380
+ (session.nativeTurn !== undefined && session.replayedSteers?.has(result.user_message_uuid))) {
368
381
  const turn = session.nativeTurn;
369
382
  if (!turn)
370
383
  unavailable();
384
+ if (result.user_message_uuid !== undefined)
385
+ session.replayedSteers?.delete(result.user_message_uuid);
371
386
  session.nativeTurn = undefined;
372
387
  endTurn(session, events);
373
388
  awaitLateSteers(session, turn.id);
@@ -54,6 +54,7 @@ export type IClaudeSession = {
54
54
  input?: IClaudeInput;
55
55
  nativeTurn?: IClaudeNativeTurn;
56
56
  steers: Map<string, IClaudeSteer>;
57
+ replayedSteers?: Set<string>;
57
58
  backgroundTaskCount: number;
58
59
  fastMode?: IClaudeFastMode;
59
60
  apiMessageId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "13.5.3",
3
+ "version": "13.5.4",
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",