jg-agent-hq 13.6.0 → 13.6.1
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 +4 -0
- package/api/README.md +2 -0
- package/dist/providers/claude/control/control.js +5 -1
- package/dist/providers/claude/control/stream.js +2 -0
- package/dist/providers/claude/control/types.d.ts +2 -0
- package/dist/store/control/constants.d.ts +1 -0
- package/dist/store/control/constants.js +19 -0
- package/dist/store/control/outcomes/outcomes.model.js +4 -3
- package/dist/store/control/reads/reads.model.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 13.6.1
|
|
4
|
+
|
|
5
|
+
- Confirm Claude steers consumed by autonomous background follow-ups using the saved-history anchor captured by their current controller. Exact input identity, content, workspace and controller checks remain required.
|
|
6
|
+
|
|
3
7
|
## 13.6.0
|
|
4
8
|
|
|
5
9
|
- Retain bounded, redacted Codex turn diagnostics on selected receipts, including late completion errors and native reattachment reads.
|
package/api/README.md
CHANGED
|
@@ -297,6 +297,8 @@ Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one U
|
|
|
297
297
|
| `interrupt` | `threadId`, `expectedTurnId`. A native request acknowledgement leaves the thread stopping until native completion evidence arrives. |
|
|
298
298
|
| `native-reply` | `threadId`, `expectedTurnId`, `approvalId`, `response`. Answers one exact current native request; cannot consume queue text. |
|
|
299
299
|
|
|
300
|
+
For Claude steers into autonomous background follow-ups, saved input may use the last acknowledged input’s history turn, captured when that controller admitted the steer. Confirmation still requires the exact input UUID, content fingerprint, workspace and current controller. An unrelated saved turn cannot confirm it.
|
|
301
|
+
|
|
300
302
|
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, adding only optional top-level `files`. Text-only steers remain unchanged; skills and turn settings cannot be steered.
|
|
301
303
|
|
|
302
304
|
Names use lowercase ASCII letters, digits and hyphens, start with a letter or digit, and have at most 64 characters, the public `MAX_THREAD_NAME_LENGTH` from `jg-agent-hq/contracts`. The same bound applies to create, adopt, rename and managed-thread responses. Names are unique without regard to case in one state directory. Creation and adoption resolve collisions atomically with ordinal suffixes such as `build-usage-2`, truncating the base to keep the complete name within 64 characters. Explicit rename rejects an occupied or pending name. Provider/native-session pairs remain unique. At most 32 native sessions are controlled concurrently; close idle sessions to release capacity. Native discovery remains independent of that limit. Confirm that other native CLI controllers are closed before adoption, resume or recovery. An unloaded native status cannot prove another CLI has stopped. The runtime provides exclusive coordination within one canonical state directory; it does not impose a global lock on independent CLIs. Recovery requires inspected ownership evidence and a stopped producing runtime, except confirmed resume of a known quarantined Codex identity with no action in flight, which the current runtime can recover.
|
|
@@ -290,6 +290,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
|
|
|
290
290
|
session.isResumed = isResume;
|
|
291
291
|
// a new process has no turn of its own and no background commands yet
|
|
292
292
|
session.nativeTurn = undefined;
|
|
293
|
+
delete session.historyTurnId;
|
|
293
294
|
setBackgroundCommands(session, 0, nativeEvents);
|
|
294
295
|
const connection = await createClaudeRpc((reason) => {
|
|
295
296
|
if (reason !== 'unavailable' ||
|
|
@@ -448,7 +449,7 @@ export const createClaudeControl = (additionalDirectories = []) => {
|
|
|
448
449
|
steer.isAcknowledged ||
|
|
449
450
|
item.kind !== 'user-message' ||
|
|
450
451
|
item.provenance.nativeInputSha256 !== steer.inputSha256 ||
|
|
451
|
-
(turnId !== steer.turnId && turnId !== steer.id))
|
|
452
|
+
(turnId !== steer.turnId && turnId !== steer.id && turnId !== steer.historyTurnId))
|
|
452
453
|
continue;
|
|
453
454
|
// a later live replay still needs its exact identity to start its own native turn
|
|
454
455
|
steer.isAcknowledged = true;
|
|
@@ -636,6 +637,9 @@ export const createClaudeControl = (additionalDirectories = []) => {
|
|
|
636
637
|
session.steers.set(id, {
|
|
637
638
|
id,
|
|
638
639
|
turnId,
|
|
640
|
+
...(session.nativeTurn?.id === turnId && session.historyTurnId !== undefined
|
|
641
|
+
? { historyTurnId: session.historyTurnId }
|
|
642
|
+
: {}),
|
|
639
643
|
inputSha256: hashValue(text),
|
|
640
644
|
isAcknowledged: false,
|
|
641
645
|
resolve,
|
|
@@ -121,6 +121,7 @@ const acknowledge = (session, events) => {
|
|
|
121
121
|
if (!input || input.isAcknowledged)
|
|
122
122
|
return;
|
|
123
123
|
input.isAcknowledged = true;
|
|
124
|
+
session.historyTurnId = input.id;
|
|
124
125
|
pauseSteerExpiry(session);
|
|
125
126
|
session.replayedSteers?.clear();
|
|
126
127
|
clearTimeout(input.timer);
|
|
@@ -226,6 +227,7 @@ const acknowledgeSteer = (session, steer, events) => {
|
|
|
226
227
|
}
|
|
227
228
|
if (!getActiveTurn(session)) {
|
|
228
229
|
pauseSteerExpiry(session);
|
|
230
|
+
session.historyTurnId = steer.id;
|
|
229
231
|
session.nativeTurn = { id: steer.id, interruptRequested: false, hasInterruptionMarker: false };
|
|
230
232
|
events?.observe({
|
|
231
233
|
kind: 'turn-started',
|
|
@@ -23,6 +23,7 @@ export type IClaudeNativeTurn = {
|
|
|
23
23
|
export type IClaudeSteer = {
|
|
24
24
|
id: string;
|
|
25
25
|
turnId: string;
|
|
26
|
+
historyTurnId?: string;
|
|
26
27
|
inputSha256: string;
|
|
27
28
|
isAcknowledged: boolean;
|
|
28
29
|
resolve(turnId: string): void;
|
|
@@ -52,6 +53,7 @@ export type IClaudeSession = {
|
|
|
52
53
|
skills?: IProviderSkills | null;
|
|
53
54
|
input?: IClaudeInput;
|
|
54
55
|
nativeTurn?: IClaudeNativeTurn;
|
|
56
|
+
historyTurnId?: string;
|
|
55
57
|
steers: Map<string, IClaudeSteer>;
|
|
56
58
|
steerReplayTimer?: ReturnType<typeof setTimeout>;
|
|
57
59
|
replayedSteers?: Set<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const CONTROLLED_THREAD_CAPACITY = 32;
|
|
2
|
+
export declare const CLAUDE_STEER_TURN_CONDITION = "(a.native_turn_id = ? OR a.id = ? OR (\n length(a.native_turn_id) = 36\n AND a.native_turn_id LIKE '________-____-4___-____-____________'\n AND lower(substr(a.native_turn_id, 20, 1)) IN ('8', '9', 'a', 'b')\n AND lower(replace(a.native_turn_id, '-', '')) NOT GLOB '*[^0-9a-f]*'\n AND NOT EXISTS (SELECT 1 FROM agent_hq_action target\n WHERE target.thread_id = a.thread_id AND target.phase = 'turn'\n AND target.native_turn_id = a.native_turn_id)\n AND ? = (SELECT CASE WHEN anchor.phase = 'turn' THEN anchor.native_turn_id END\n FROM agent_hq_action anchor\n WHERE anchor.thread_id = a.thread_id AND anchor.runtime_epoch = a.runtime_epoch\n AND anchor.created_at < a.created_at AND anchor.delivery = 'acknowledged'\n AND anchor.kind IN ('message', 'queue', 'thread-create', 'thread-resume', 'thread-adopt', 'thread-recover')\n ORDER BY anchor.created_at DESC, anchor.id DESC LIMIT 1)\n))";
|
|
2
3
|
export declare const UNSTARTED_CONDITION = "active_turn_id IS NULL AND last_turn_id IS NULL\n AND state != 'inactive'\n AND EXISTS (SELECT 1 FROM agent_hq_action WHERE agent_hq_action.id = agent_hq_thread.registration_action_id\n AND agent_hq_action.kind = 'thread-create')";
|
|
3
4
|
export declare const KEPT_SESSION_CONDITION = "ownership = 'managed' AND native_id IS NOT NULL\n AND pending_action_id IS NULL AND provider = 'codex'";
|
|
4
5
|
export declare const THREAD_COLUMNS = "id, provider, native_id, native_lineage, name, workspace_root, ownership, runtime_epoch, active_turn_id, last_turn_id, last_turn_state, pending_action_id, state, registration_action_id, created_at, updated_at";
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
// open native sessions are bounded independently of the durable thread collection
|
|
2
2
|
export const CONTROLLED_THREAD_CAPACITY = 32;
|
|
3
|
+
/*
|
|
4
|
+
* Autonomous Claude turns have no input action. Their saved steer inherits the last acknowledged
|
|
5
|
+
* input from the same controller epoch; an intervening resume/adopt/recover fences that anchor.
|
|
6
|
+
*/
|
|
7
|
+
export const CLAUDE_STEER_TURN_CONDITION = `(a.native_turn_id = ? OR a.id = ? OR (
|
|
8
|
+
length(a.native_turn_id) = 36
|
|
9
|
+
AND a.native_turn_id LIKE '________-____-4___-____-____________'
|
|
10
|
+
AND lower(substr(a.native_turn_id, 20, 1)) IN ('8', '9', 'a', 'b')
|
|
11
|
+
AND lower(replace(a.native_turn_id, '-', '')) NOT GLOB '*[^0-9a-f]*'
|
|
12
|
+
AND NOT EXISTS (SELECT 1 FROM agent_hq_action target
|
|
13
|
+
WHERE target.thread_id = a.thread_id AND target.phase = 'turn'
|
|
14
|
+
AND target.native_turn_id = a.native_turn_id)
|
|
15
|
+
AND ? = (SELECT CASE WHEN anchor.phase = 'turn' THEN anchor.native_turn_id END
|
|
16
|
+
FROM agent_hq_action anchor
|
|
17
|
+
WHERE anchor.thread_id = a.thread_id AND anchor.runtime_epoch = a.runtime_epoch
|
|
18
|
+
AND anchor.created_at < a.created_at AND anchor.delivery = 'acknowledged'
|
|
19
|
+
AND anchor.kind IN ('message', 'queue', 'thread-create', 'thread-resume', 'thread-adopt', 'thread-recover')
|
|
20
|
+
ORDER BY anchor.created_at DESC, anchor.id DESC LIMIT 1)
|
|
21
|
+
))`;
|
|
3
22
|
/*
|
|
4
23
|
* A managed thread HQ created empty and still open, that no turn has started. Adopted sessions
|
|
5
24
|
* start with native history, so they never match.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ControlModel } from '../control.model.js';
|
|
2
|
+
import { CLAUDE_STEER_TURN_CONDITION } from '../constants.js';
|
|
2
3
|
import { toActionReceipt } from '../transformers.js';
|
|
3
4
|
/** Applies native request outcomes to the actions whose phases they answer. */
|
|
4
5
|
export class ControlOutcomes extends ControlModel {
|
|
@@ -15,14 +16,14 @@ export class ControlOutcomes extends ControlModel {
|
|
|
15
16
|
for (const item of command.items) {
|
|
16
17
|
if (item.nativeInputId === null || item.sha256 === null)
|
|
17
18
|
continue;
|
|
18
|
-
const updated = this._statements.get(`UPDATE agent_hq_action SET delivery = 'acknowledged', failure = NULL, updated_at = ?
|
|
19
|
+
const updated = this._statements.get(`UPDATE agent_hq_action AS a SET delivery = 'acknowledged', failure = NULL, updated_at = ?
|
|
19
20
|
WHERE id = ? AND provider = 'claude' AND kind = 'steer' AND phase = 'steer'
|
|
20
21
|
AND delivery IN ('submitted', 'uncertain') AND input_sha256 = ?
|
|
21
22
|
AND native_turn_id IS NOT NULL AND native_turn_id = expected_turn_id
|
|
22
|
-
AND
|
|
23
|
+
AND ${CLAUDE_STEER_TURN_CONDITION}
|
|
23
24
|
AND thread_id IN (SELECT id FROM agent_hq_thread
|
|
24
25
|
WHERE provider = 'claude' AND native_id = ? AND workspace_root = ?)
|
|
25
|
-
RETURNING thread_id`, Date.now(), item.nativeInputId, item.sha256, item.turnId, item.turnId, command.nativeId, command.workspaceRoot);
|
|
26
|
+
RETURNING thread_id`, Date.now(), item.nativeInputId, item.sha256, item.turnId, item.turnId, item.turnId, command.nativeId, command.workspaceRoot);
|
|
26
27
|
if (updated)
|
|
27
28
|
threads.add(updated.thread_id);
|
|
28
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControlModel } from '../control.model.js';
|
|
2
|
-
import { ACTION_METADATA_COLUMNS, THREAD_COLUMNS, UNSTARTED_CONDITION } from '../constants.js';
|
|
2
|
+
import { ACTION_METADATA_COLUMNS, CLAUDE_STEER_TURN_CONDITION, THREAD_COLUMNS, UNSTARTED_CONDITION, } from '../constants.js';
|
|
3
3
|
import { toActionSummary, toManagedThread } from '../transformers.js';
|
|
4
4
|
/** Reads the control ledger's receipts, threads and approvals without changing them. */
|
|
5
5
|
export class ControlReads extends ControlModel {
|
|
@@ -26,8 +26,8 @@ export class ControlReads extends ControlModel {
|
|
|
26
26
|
WHERE a.id = ? AND t.provider = 'claude' AND t.native_id = ?
|
|
27
27
|
AND a.kind = 'steer' AND a.phase = 'steer' AND a.delivery = 'acknowledged'
|
|
28
28
|
AND a.native_turn_id IS NOT NULL AND a.native_turn_id = a.expected_turn_id
|
|
29
|
-
AND a.input_sha256 = ? AND
|
|
30
|
-
LIMIT 1`, item.nativeInputId, command.nativeId, item.sha256, item.turnId, item.turnId);
|
|
29
|
+
AND a.input_sha256 = ? AND ${CLAUDE_STEER_TURN_CONDITION}
|
|
30
|
+
LIMIT 1`, item.nativeInputId, command.nativeId, item.sha256, item.turnId, item.turnId, item.turnId);
|
|
31
31
|
if (steer && !rows.some((row) => row.id === steer.id))
|
|
32
32
|
rows.push(steer);
|
|
33
33
|
}
|
package/package.json
CHANGED