jg-agent-hq 10.5.3 → 10.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 +4 -0
- package/api/README.md +1 -1
- package/dist/providers/claude/history/history.model.d.ts +9 -0
- package/dist/providers/claude/history/history.model.js +39 -8
- package/dist/providers/claude/history/types.d.ts +1 -0
- package/dist/providers/claude/history/types.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 10.5.4
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
|
|
3
7
|
## 10.5.3
|
|
4
8
|
|
|
5
9
|
- Leave a Claude subagent's stream frames, which name the Agent call that started it, out of a session's live items and turns. History leaves the subagent's sidechain out, so its prompt, tool calls and results stayed `awaiting-flush` after the session's answer, its prompt read as the operator's message, and a background subagent's frames after the session's turn started a turn of Claude's own that never ended, which held the next message as starting. A subagent's tool results still settle the approvals it asked for.
|
package/api/README.md
CHANGED
|
@@ -241,7 +241,7 @@ The existing SQLite worker incrementally records file identity, complete-line of
|
|
|
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
|
|
|
244
|
-
Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item and turn continuations. Only the current parent-linked conversation chain is returned. Text is reread from the native file for the selected page and normalized as plain text. Thinking blocks are left out, and a record holding only thinking is hidden, as are `<task-notification>` records and a subagent's sidechain records. Live items leave a subagent's stream frames out likewise, and those frames start no turn, though a subagent's tool results still settle the approvals it asked for. Compaction summaries, `<local-command-stdout>` output and interruption markers are `notice` items, and a slash command is a `user-message` reading `/name args`. A `!` shell input and its output are `command` items, the output's `callId` being the input's UUID. A tool call shows its native name and input, with the block's ID as `callId`, which is null for a record calling several tools; its result is a `tool` item carrying that ID, `failed` when it has `is_error` and `succeeded` otherwise. An Edit or Write result whose metadata has a `filePath` and a `structuredPatch` is a `file-change` item reading the path and its patch lines, or a created file's content, every line of which counts as added. A result Claude Code saved to a file reads `Output too large (<size>), saved to a file` followed by its preview, without the file's path. A result made of content blocks, such as a screenshot with its caption, reads as its text blocks, each image as `[Image]`. Other non-text content has explicit native block labels. The index stores each entry's presented kind and visibility, so evidence kind filters match `items` and hidden records never shorten a page. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
|
|
244
|
+
Selected history reads refresh only that file, retain incomplete tails, and detect truncation or replaced identity. Changed branch/file revisions invalidate item and turn continuations. Only the current parent-linked conversation chain is returned. Claude Code links each tool result to its own call, so parallel calls whose results finish out of order would leave the later calls and results on a side branch; such a result follows the latest record of its call's turn instead, keeping every call of the response and all their results on the chain without changing its revision. Text is reread from the native file for the selected page and normalized as plain text. Thinking blocks are left out, and a record holding only thinking is hidden, as are `<task-notification>` records and a subagent's sidechain records. Live items leave a subagent's stream frames out likewise, and those frames start no turn, though a subagent's tool results still settle the approvals it asked for. Compaction summaries, `<local-command-stdout>` output and interruption markers are `notice` items, and a slash command is a `user-message` reading `/name args`. A `!` shell input and its output are `command` items, the output's `callId` being the input's UUID. A tool call shows its native name and input, with the block's ID as `callId`, which is null for a record calling several tools; its result is a `tool` item carrying that ID, `failed` when it has `is_error` and `succeeded` otherwise. An Edit or Write result whose metadata has a `filePath` and a `structuredPatch` is a `file-change` item reading the path and its patch lines, or a created file's content, every line of which counts as added. A result Claude Code saved to a file reads `Output too large (<size>), saved to a file` followed by its preview, without the file's path. A result made of content blocks, such as a screenshot with its caption, reads as its text blocks, each image as `[Image]`. Other non-text content has explicit native block labels. The index stores each entry's presented kind and visibility, so evidence kind filters match `items` and hidden records never shorten a page. An unknown record containing content is returned as an `unsupported` item when its identity and chain are trustworthy; it cannot imply an agent response, idle state or completion. Each selected page reads at most 4 MiB of record bytes beyond its first record and returns at most 4 MiB of serialized item presentation, so a large-text page can contain fewer rows than its requested limit.
|
|
245
245
|
|
|
246
246
|
File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. A turn starts at a message the operator sends, including a slash command; task notifications, compaction summaries, local command output, interruption markers and `!` shell records belong to the turn before them. Grouping follows parent links and is not an authoritative execution boundary. A compaction starts a new chain whose first record names the record before it, so history reads on past the compaction to the start of the conversation.
|
|
247
247
|
|
|
@@ -63,6 +63,15 @@ export declare class ClaudeHistoryModel {
|
|
|
63
63
|
* - JG_AGENT_HQ_CLAUDE_HISTORY_UNAVAILABLE: The Claude history is unavailable
|
|
64
64
|
*/
|
|
65
65
|
private __record;
|
|
66
|
+
/**
|
|
67
|
+
* Claude Code links a tool result to its own call. When parallel calls finish out of order, an
|
|
68
|
+
* earlier call is no longer the leaf, so its result would start a side branch that the current
|
|
69
|
+
* chain leaves out, with the calls and results written after that call. Such a result follows
|
|
70
|
+
* the leaf of its call's turn instead, which keeps one response's calls and all their results
|
|
71
|
+
* on the chain; the record after them follows the last result written, the leaf by then.
|
|
72
|
+
* @returns The record the result follows in the projection: the leaf, or its own call.
|
|
73
|
+
*/
|
|
74
|
+
private __resultParent;
|
|
66
75
|
private __hasEntry;
|
|
67
76
|
private __unavailable;
|
|
68
77
|
}
|
|
@@ -8,7 +8,7 @@ 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 =
|
|
11
|
+
const HISTORY_PROJECTION_VERSION = 8;
|
|
12
12
|
// one record, such as a tool result holding images, and an indexing read, which fits the largest
|
|
13
13
|
const MAX_RECORD_BYTES = 8_388_608;
|
|
14
14
|
const MAX_REFRESH_BYTES = 16_777_216;
|
|
@@ -40,7 +40,7 @@ export class ClaudeHistoryModel {
|
|
|
40
40
|
constructor(database) {
|
|
41
41
|
this.__database = database;
|
|
42
42
|
this.__recordStatements = {
|
|
43
|
-
parentTurn: database.prepare(`SELECT turn_id, turn_start_offset, anchor_id FROM hq_claude_entry
|
|
43
|
+
parentTurn: database.prepare(`SELECT turn_id, turn_start_offset, anchor_id, is_current FROM hq_claude_entry
|
|
44
44
|
WHERE workspace_root = ? AND native_id = ? AND uuid = ?`),
|
|
45
45
|
recordedParent: database.prepare('SELECT parent_uuid FROM hq_claude_entry WHERE workspace_root = ? AND native_id = ? AND uuid = ?'),
|
|
46
46
|
upsert: database.prepare(`INSERT INTO hq_claude_entry (workspace_root, native_id, uuid, parent_uuid, turn_id, byte_offset,
|
|
@@ -703,26 +703,40 @@ export class ClaudeHistoryModel {
|
|
|
703
703
|
this.__unavailable();
|
|
704
704
|
const createdAt = Date.parse(record.timestamp);
|
|
705
705
|
const statements = this.__recordStatements;
|
|
706
|
-
const
|
|
707
|
-
const
|
|
706
|
+
const nativeParentUuid = readClaudeParentUuid(record);
|
|
707
|
+
const nativeParent = nativeParentUuid
|
|
708
|
+
? statements.parentTurn.get(root, nativeId, nativeParentUuid)
|
|
709
|
+
: undefined;
|
|
708
710
|
// the CLI's presentation decides what is shown, the kind evidence filters on and where turns start
|
|
709
711
|
const item = record.message !== undefined && !record.isMeta ? toClaudeItem(record, record.uuid) : null;
|
|
710
712
|
const visible = item !== null;
|
|
711
|
-
if (
|
|
713
|
+
if (nativeParentUuid === record.uuid)
|
|
712
714
|
this.__unavailable();
|
|
713
|
-
if (
|
|
715
|
+
if (nativeParentUuid && !nativeParent) {
|
|
714
716
|
if (visible)
|
|
715
717
|
this.__unavailable();
|
|
716
718
|
if (!isOrphanAllowed)
|
|
717
|
-
return
|
|
719
|
+
return nativeParentUuid;
|
|
718
720
|
}
|
|
721
|
+
const previous = statements.recordedParent.get(root, nativeId, record.uuid);
|
|
722
|
+
const isCallResult = item?.nativeType === 'tool-result' &&
|
|
723
|
+
nativeParentUuid !== null &&
|
|
724
|
+
record.sourceToolAssistantUUID === nativeParentUuid;
|
|
725
|
+
// a result indexed again keeps the record it was made to follow
|
|
726
|
+
const parentUuid = isCallResult && typeof previous?.parent_uuid === 'string'
|
|
727
|
+
? previous.parent_uuid
|
|
728
|
+
: isCallResult && !previous
|
|
729
|
+
? this.__resultParent(root, nativeId, row, nativeParentUuid, nativeParent)
|
|
730
|
+
: nativeParentUuid;
|
|
731
|
+
const parent = parentUuid === nativeParentUuid
|
|
732
|
+
? nativeParent
|
|
733
|
+
: statements.parentTurn.get(root, nativeId, parentUuid);
|
|
719
734
|
const textPrompt = item?.kind === 'user-message';
|
|
720
735
|
const turnId = textPrompt
|
|
721
736
|
? record.uuid
|
|
722
737
|
: typeof parent?.turn_id === 'string'
|
|
723
738
|
? parent.turn_id
|
|
724
739
|
: record.uuid;
|
|
725
|
-
const previous = statements.recordedParent.get(root, nativeId, record.uuid);
|
|
726
740
|
if (previous && previous.parent_uuid !== parentUuid)
|
|
727
741
|
this.__unavailable();
|
|
728
742
|
const isAppend = row.leaf_id === null || parent?.anchor_id === row.leaf_id;
|
|
@@ -752,6 +766,23 @@ export class ClaudeHistoryModel {
|
|
|
752
766
|
row.updated_at = Math.max(row.updated_at, createdAt);
|
|
753
767
|
return null;
|
|
754
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* Claude Code links a tool result to its own call. When parallel calls finish out of order, an
|
|
771
|
+
* earlier call is no longer the leaf, so its result would start a side branch that the current
|
|
772
|
+
* chain leaves out, with the calls and results written after that call. Such a result follows
|
|
773
|
+
* the leaf of its call's turn instead, which keeps one response's calls and all their results
|
|
774
|
+
* on the chain; the record after them follows the last result written, the leaf by then.
|
|
775
|
+
* @returns The record the result follows in the projection: the leaf, or its own call.
|
|
776
|
+
*/
|
|
777
|
+
__resultParent(root, nativeId, row, callUuid, call) {
|
|
778
|
+
if (row.leaf_id === null ||
|
|
779
|
+
call?.is_current !== 1 ||
|
|
780
|
+
call.anchor_id !== callUuid ||
|
|
781
|
+
call.anchor_id === row.leaf_id)
|
|
782
|
+
return callUuid;
|
|
783
|
+
const leaf = this.__recordStatements.parentTurn.get(root, nativeId, row.leaf_id);
|
|
784
|
+
return leaf?.is_current === 1 && leaf.turn_id === call.turn_id ? row.leaf_id : callUuid;
|
|
785
|
+
}
|
|
755
786
|
__hasEntry(root, nativeId, uuid) {
|
|
756
787
|
return this.__recordStatements.hasEntry.get(root, nativeId, uuid) !== undefined;
|
|
757
788
|
}
|
|
@@ -2288,6 +2288,7 @@ export declare const RecordSchema: z.ZodObject<{
|
|
|
2288
2288
|
content: z.ZodUnknown;
|
|
2289
2289
|
}, z.core.$strip>>;
|
|
2290
2290
|
toolUseResult: z.ZodOptional<z.ZodUnknown>;
|
|
2291
|
+
sourceToolAssistantUUID: z.ZodOptional<z.ZodString>;
|
|
2291
2292
|
}, z.core.$strip>;
|
|
2292
2293
|
export type IRecord = z.infer<typeof RecordSchema>;
|
|
2293
2294
|
export declare const FilePatchSchema: z.ZodObject<{
|
|
@@ -56,6 +56,8 @@ export const RecordSchema = z.object({
|
|
|
56
56
|
message: z.object({ role: z.string(), content: z.unknown() }).optional(),
|
|
57
57
|
// the CLI's own result metadata, such as an edit's patch, which live frames call tool_use_result
|
|
58
58
|
toolUseResult: z.unknown().optional(),
|
|
59
|
+
// the call a tool result answers, which Claude Code also writes as the result's parent
|
|
60
|
+
sourceToolAssistantUUID: z.string().optional(),
|
|
59
61
|
});
|
|
60
62
|
// the file Claude Code records on an Edit or Write result; a created file's patch is empty
|
|
61
63
|
export const FilePatchSchema = z.object({
|
package/package.json
CHANGED