jg-agent-hq 13.5.9 → 13.5.11
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 +9 -0
- package/api/README.md +3 -1
- package/dist/providers/claude/control/diagnostics.d.ts +3 -1
- package/dist/providers/claude/control/diagnostics.js +46 -9
- package/dist/providers/claude/control/stream.d.ts +3 -3
- package/dist/providers/claude/control/stream.js +13 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 13.5.11
|
|
4
|
+
|
|
5
|
+
- Reuse shared SHA-256 hashing for redacted Claude result subtype fingerprints.
|
|
6
|
+
|
|
7
|
+
## 13.5.10
|
|
8
|
+
|
|
9
|
+
- Keep Claude control when a valid result arrives without a user-message UUID and without an active turn. Empty cycles produce no live turn or completion notice, and any input still waiting for replay completes under its own identity.
|
|
10
|
+
- Include bounded result-shape metadata in empty-cycle and rejection diagnostics. Malformed results and conflicting turn or input evidence still quarantine the controller.
|
|
11
|
+
|
|
3
12
|
## 13.5.9
|
|
4
13
|
|
|
5
14
|
- Retain Codex control when the same controller records a valid native recovery turn while rejoining after a connection loss or runtime restart. Reconcile the observed turn instead of quarantining it against the pre-join snapshot.
|
package/api/README.md
CHANGED
|
@@ -407,6 +407,8 @@ Codex leaves `reasoning` items out as it reads them, so a Codex page can hold fe
|
|
|
407
407
|
|
|
408
408
|
Controller setup uses the managed record's existing `creating` preparation state for creation, adoption, resume and recovery. Until native readiness its session state is unknown, rather than a running inference turn. Readiness alone records `opened`, never `turn-completed`; `starting` is reserved for an action that actually submits turn input. Verified existing turns and autonomous native output still record their actual lifecycle.
|
|
409
409
|
|
|
410
|
+
A structurally valid Claude result with no user-message UUID and no active turn ends an empty autonomous cycle. It adds no turn transitions or live items, and leaves any written input waiting for its own replay and result. Background-command observations continue independently. A result without a UUID during an active HQ input remains a control conflict.
|
|
411
|
+
|
|
410
412
|
Every session has a live state: `running`, `waiting` (on the operator), `idle`, `closed`, `failed` or `unknown`. A managed session reports it from its managed record. A session another client drives is observed and listed with `ownership: 'external'`; the runtime sends it no input until `thread-adopt` records it as managed, and never stops, wakes or drives a session a terminal runs. A managed session the runtime closed is observed again, so a terminal that continues it shows its state.
|
|
411
413
|
|
|
412
414
|
A retained session with uncertain ownership also takes its live state from native observation, including loaded Codex sessions found at startup and later status changes. Thread reads, discovery and active-session summaries retain its managed ID and `ownership: 'uncertain'`. Observation never changes its control record, settles uncertain input, advances queued input or restores execution authority. Without a native observation its state remains unknown; explicit recovery is still required to regain control.
|
|
@@ -546,7 +548,7 @@ Use `models --provider <id>` for native model and effort choices, and `configura
|
|
|
546
548
|
|
|
547
549
|
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.
|
|
548
550
|
|
|
549
|
-
When Claude sends
|
|
551
|
+
When Claude sends conflicting turn evidence or other evidence HQ cannot interpret, HQ suspends that session's controls and live interpretation while its native work continues. Empty autonomous cycles and rejected results report bounded diagnostics with validated correlation IDs, known subtype or a fingerprint of a short unfamiliar subtype, error flag, turn count, and duration/usage presence. The diagnostics omit native content. It closes the quarantined controller automatically only after fresh native idle, a known empty task snapshot and no unresolved requests establish that work has finished. Unknown evidence or an unanswered approval keeps it alive; confirmed `thread-close` with `interrupt: true` explicitly stops its owned process group, including unfinished background work. Identity and transport-integrity failures retain their shutdown handling.
|
|
550
552
|
|
|
551
553
|
A quarantined known Codex identity offers confirmed recovery in the current runtime without an HQ restart. Recovery verifies the native turn before and after joining, sends no input or settings, keeps earlier queues paused and leaves uncertain receipts unresolved. Previously managed sessions also rejoin automatically after connection loss or runtime restart when their verified latest turn changed, without resolving earlier receipts or releasing old queues. Unknown state, pending submissions and a turn changing during the join still require inspection and explicit recovery. Native turn IDs do not prove exclusive control; keep other controlling clients closed.
|
|
552
554
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { IClaudeSession } from './types.js';
|
|
2
2
|
/** Reports one rejected result without exposing prompts, output, paths or parser payloads. */
|
|
3
|
-
export declare const reportRejectedClaudeResult: (session: IClaudeSession, result: unknown, reason: "invalid-result" | "
|
|
3
|
+
export declare const reportRejectedClaudeResult: (session: IClaudeSession, result: unknown, reason: "invalid-result" | "missing-input-uuid" | "input-mismatch") => void;
|
|
4
|
+
/** Reports an autonomous cycle that finished without opening a live turn. */
|
|
5
|
+
export declare const reportEmptyClaudeCycle: (session: IClaudeSession, result: unknown) => void;
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import { hashValue } from 'jg-crypto';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
//
|
|
3
|
+
// keep result diagnostics independent of structural validation so malformed results are visible too
|
|
3
4
|
const MAX_DIAGNOSTIC_IDS = 64;
|
|
4
|
-
const
|
|
5
|
+
const ResultDiagnosticSchema = z.object({
|
|
6
|
+
user_message_uuid: z.unknown().optional(),
|
|
7
|
+
subtype: z.unknown().optional(),
|
|
8
|
+
is_error: z.unknown().optional(),
|
|
9
|
+
num_turns: z.unknown().optional(),
|
|
10
|
+
duration_api_ms: z.unknown().optional(),
|
|
11
|
+
usage: z.unknown().optional(),
|
|
12
|
+
});
|
|
13
|
+
const KnownSubtypeSchema = z.enum([
|
|
14
|
+
'success',
|
|
15
|
+
'error_during_execution',
|
|
16
|
+
'error_max_turns',
|
|
17
|
+
'error_max_budget_usd',
|
|
18
|
+
'error_max_structured_output_retries',
|
|
19
|
+
]);
|
|
20
|
+
const TurnCountSchema = z.int().nonnegative();
|
|
5
21
|
const uuidOrNull = (candidate) => {
|
|
6
22
|
const parsed = z.uuid().safeParse(candidate);
|
|
7
23
|
return parsed.success ? parsed.data : null;
|
|
@@ -19,17 +35,38 @@ const collectIds = (identities) => {
|
|
|
19
35
|
}
|
|
20
36
|
return selected;
|
|
21
37
|
};
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Projects safe result metadata. Short unfamiliar subtypes get a stable fingerprint so repeated
|
|
40
|
+
* observations can be matched without copying arbitrary provider strings into logs.
|
|
41
|
+
*/
|
|
42
|
+
const describeResult = (session, result) => {
|
|
43
|
+
const { data: metadata } = ResultDiagnosticSchema.safeParse(result);
|
|
44
|
+
const subtype = metadata?.subtype;
|
|
45
|
+
const knownSubtype = KnownSubtypeSchema.safeParse(subtype);
|
|
46
|
+
return {
|
|
27
47
|
sessionId: uuidOrNull(session.id),
|
|
28
|
-
userMessageUuid:
|
|
48
|
+
userMessageUuid: uuidOrNull(metadata?.user_message_uuid),
|
|
49
|
+
hasUserMessageUuid: metadata?.user_message_uuid !== undefined,
|
|
29
50
|
inputId: uuidOrNull(session.input?.id),
|
|
30
51
|
nativeTurnId: uuidOrNull(session.nativeTurn?.id),
|
|
31
52
|
pendingSteerCount: session.steers.size,
|
|
32
53
|
pendingSteerIds: collectIds(session.steers.keys()),
|
|
33
54
|
replayedSteerIds: collectIds(session.replayedSteers ?? []),
|
|
34
|
-
|
|
55
|
+
subtype: knownSubtype.success ? knownSubtype.data : null,
|
|
56
|
+
subtypeFingerprint: !knownSubtype.success && typeof subtype === 'string' && subtype.length <= 64
|
|
57
|
+
? hashValue(subtype, 'sha256')
|
|
58
|
+
: null,
|
|
59
|
+
isError: typeof metadata?.is_error === 'boolean' ? metadata.is_error : null,
|
|
60
|
+
numTurns: TurnCountSchema.safeParse(metadata?.num_turns).data ?? null,
|
|
61
|
+
hasDurationApiMs: metadata?.duration_api_ms !== undefined,
|
|
62
|
+
hasUsage: metadata?.usage !== undefined,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/** Reports one rejected result without exposing prompts, output, paths or parser payloads. */
|
|
66
|
+
export const reportRejectedClaudeResult = (session, result, reason) => {
|
|
67
|
+
console.error('[jg-agent-hq] Claude result rejected', JSON.stringify({ reason, ...describeResult(session, result) }));
|
|
68
|
+
};
|
|
69
|
+
/** Reports an autonomous cycle that finished without opening a live turn. */
|
|
70
|
+
export const reportEmptyClaudeCycle = (session, result) => {
|
|
71
|
+
console.warn('[jg-agent-hq] Claude empty cycle completed', JSON.stringify(describeResult(session, result)));
|
|
35
72
|
};
|
|
@@ -20,9 +20,9 @@ export declare const setBackgroundCommands: (session: IClaudeSession, count: num
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const failSteers: (session: IClaudeSession, turnId?: string, failure?: unknown) => void;
|
|
22
22
|
/**
|
|
23
|
-
* Normalizes native stream evidence without retaining another conversation buffer.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Normalizes native stream evidence without retaining another conversation buffer. Autonomous
|
|
24
|
+
* output starts a native turn, and a valid UUID-free result with no active turn ends an empty
|
|
25
|
+
* cycle without publishing a turn or acknowledging input still waiting for replay.
|
|
26
26
|
* @throws
|
|
27
27
|
* - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
|
|
28
28
|
*/
|
|
@@ -6,7 +6,7 @@ import { toTurnResult } from '../../results/index.js';
|
|
|
6
6
|
import { parseActionRequest } from '../../utilities.js';
|
|
7
7
|
import { HQ_ERRORS } from '../../../errors/index.js';
|
|
8
8
|
import { createClaudePrompt } from './permissions.js';
|
|
9
|
-
import { reportRejectedClaudeResult } from './diagnostics.js';
|
|
9
|
+
import { reportEmptyClaudeCycle, reportRejectedClaudeResult } from './diagnostics.js';
|
|
10
10
|
const FrameSchema = z.object({
|
|
11
11
|
type: z.string(),
|
|
12
12
|
session_id: z.string().optional(),
|
|
@@ -270,9 +270,9 @@ const resolveRequests = (session, message, events) => {
|
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
/**
|
|
273
|
-
* Normalizes native stream evidence without retaining another conversation buffer.
|
|
274
|
-
*
|
|
275
|
-
*
|
|
273
|
+
* Normalizes native stream evidence without retaining another conversation buffer. Autonomous
|
|
274
|
+
* output starts a native turn, and a valid UUID-free result with no active turn ends an empty
|
|
275
|
+
* cycle without publishing a turn or acknowledging input still waiting for replay.
|
|
276
276
|
* @throws
|
|
277
277
|
* - JG_AGENT_HQ_CLAUDE_FAILED: The Claude integration failed
|
|
278
278
|
*/
|
|
@@ -402,13 +402,20 @@ export const receiveClaudeMessage = (session, raw, events) => {
|
|
|
402
402
|
}
|
|
403
403
|
const result = parsedResult.data;
|
|
404
404
|
observeFastMode(session, raw);
|
|
405
|
+
if (result.user_message_uuid === undefined && getActiveTurn(session) === undefined) {
|
|
406
|
+
// an empty cycle never started a turn, so the waiting input and idle steer deadline still apply
|
|
407
|
+
delete session.apiMessageId;
|
|
408
|
+
endTurn(session, events);
|
|
409
|
+
reportEmptyClaudeCycle(session, raw);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
405
412
|
// a turn Claude started, or one a steer runs after its turn, has no action to capture its result
|
|
406
413
|
if (result.user_message_uuid === undefined ||
|
|
407
414
|
result.user_message_uuid === session.nativeTurn?.id ||
|
|
408
415
|
(session.nativeTurn !== undefined && session.replayedSteers?.has(result.user_message_uuid))) {
|
|
409
416
|
const turn = session.nativeTurn;
|
|
410
417
|
if (!turn) {
|
|
411
|
-
reportRejectedClaudeResult(session,
|
|
418
|
+
reportRejectedClaudeResult(session, raw, 'missing-input-uuid');
|
|
412
419
|
unavailable();
|
|
413
420
|
}
|
|
414
421
|
if (result.user_message_uuid !== undefined)
|
|
@@ -427,7 +434,7 @@ export const receiveClaudeMessage = (session, raw, events) => {
|
|
|
427
434
|
}
|
|
428
435
|
const input = session.input;
|
|
429
436
|
if (!input || input.id !== result.user_message_uuid || session.nativeTurn) {
|
|
430
|
-
reportRejectedClaudeResult(session,
|
|
437
|
+
reportRejectedClaudeResult(session, raw, 'input-mismatch');
|
|
431
438
|
unavailable();
|
|
432
439
|
}
|
|
433
440
|
acknowledge(session, events);
|
package/package.json
CHANGED