jg-agent-hq 10.5.2 → 10.5.3
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/control/stream.js +39 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 10.5.3
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
|
|
3
7
|
## 10.5.2
|
|
4
8
|
|
|
5
9
|
- Show a Claude tool result made of content blocks, such as a browser tool's caption and screenshot, as its text, with each image as `[Image]`. Such results used to read `[Native tool_result]`.
|
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. 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. 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
|
|
|
@@ -5,7 +5,12 @@ import { RecordSchema, toClaudeItem } from '../history/index.js';
|
|
|
5
5
|
import { MAX_RESULT_BYTES } from '../../../contracts/index.js';
|
|
6
6
|
import { toTurnResult } from '../../results/index.js';
|
|
7
7
|
import { createClaudePrompt } from './permissions.js';
|
|
8
|
-
const FrameSchema = z.object({
|
|
8
|
+
const FrameSchema = z.object({
|
|
9
|
+
type: z.string(),
|
|
10
|
+
session_id: z.string().optional(),
|
|
11
|
+
// the Agent call whose subagent a frame comes from, which history keeps out of the session
|
|
12
|
+
parent_tool_use_id: z.string().nullish(),
|
|
13
|
+
});
|
|
9
14
|
const MessageSchema = z.object({
|
|
10
15
|
uuid: z.string().min(1).max(4096),
|
|
11
16
|
message: z.object({ role: z.string(), content: z.unknown() }),
|
|
@@ -135,6 +140,26 @@ const endTurn = (session, events) => {
|
|
|
135
140
|
session.previews.clear();
|
|
136
141
|
session.requests.clear();
|
|
137
142
|
};
|
|
143
|
+
/** Settles the approvals a user frame's tool results answer, as Claude ran or refused each tool. */
|
|
144
|
+
const resolveRequests = (session, message, events) => {
|
|
145
|
+
const results = ToolResultsSchema.safeParse(message.message.content);
|
|
146
|
+
if (!results.success)
|
|
147
|
+
return;
|
|
148
|
+
for (const result of results.data) {
|
|
149
|
+
if (result.type !== 'tool_result' || !result.tool_use_id)
|
|
150
|
+
continue;
|
|
151
|
+
for (const [id, request] of session.requests)
|
|
152
|
+
if (request.toolId === result.tool_use_id) {
|
|
153
|
+
events?.observe({
|
|
154
|
+
kind: 'request-resolved',
|
|
155
|
+
provider: 'claude',
|
|
156
|
+
nativeThreadId: session.id,
|
|
157
|
+
requestId: request.scopedId,
|
|
158
|
+
});
|
|
159
|
+
session.requests.delete(id);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
138
163
|
/**
|
|
139
164
|
* Normalizes native stream evidence without retaining another conversation buffer. A turn frame
|
|
140
165
|
* that arrives while no turn is active, and isn't the waiting input's replay, starts a turn of
|
|
@@ -146,6 +171,17 @@ export const receiveClaudeMessage = (session, raw, events) => {
|
|
|
146
171
|
const frame = FrameSchema.parse(raw);
|
|
147
172
|
if (frame.session_id && frame.session_id !== session.id)
|
|
148
173
|
unavailable();
|
|
174
|
+
/*
|
|
175
|
+
* A subagent's frames name the Agent call that started it. History leaves its sidechain out, so
|
|
176
|
+
* they show no live item, start no turn and hold no result, even after the session's turn ended
|
|
177
|
+
* while a background subagent runs on; its tool results still settle the approvals it asked for.
|
|
178
|
+
*/
|
|
179
|
+
if (frame.parent_tool_use_id &&
|
|
180
|
+
(frame.type === 'user' || frame.type === 'assistant' || frame.type === 'stream_event')) {
|
|
181
|
+
if (frame.type === 'user')
|
|
182
|
+
resolveRequests(session, MessageSchema.parse(raw), events);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
149
185
|
if (frame.type === 'user' || frame.type === 'assistant') {
|
|
150
186
|
const message = MessageSchema.parse(raw);
|
|
151
187
|
const isReplay = frame.type === 'user' && session.input !== undefined && message.uuid === session.input.id;
|
|
@@ -208,24 +244,8 @@ export const receiveClaudeMessage = (session, raw, events) => {
|
|
|
208
244
|
}
|
|
209
245
|
if (item)
|
|
210
246
|
events?.item(session.id, item, true, replacedIds);
|
|
211
|
-
if (frame.type === 'user')
|
|
212
|
-
|
|
213
|
-
if (results.success)
|
|
214
|
-
for (const result of results.data) {
|
|
215
|
-
if (result.type !== 'tool_result' || !result.tool_use_id)
|
|
216
|
-
continue;
|
|
217
|
-
for (const [id, request] of session.requests)
|
|
218
|
-
if (request.toolId === result.tool_use_id) {
|
|
219
|
-
events?.observe({
|
|
220
|
-
kind: 'request-resolved',
|
|
221
|
-
provider: 'claude',
|
|
222
|
-
nativeThreadId: session.id,
|
|
223
|
-
requestId: request.scopedId,
|
|
224
|
-
});
|
|
225
|
-
session.requests.delete(id);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
247
|
+
if (frame.type === 'user')
|
|
248
|
+
resolveRequests(session, message, events);
|
|
229
249
|
}
|
|
230
250
|
else if (frame.type === 'stream_event') {
|
|
231
251
|
const turn = getActiveTurn(session) ?? startNativeTurn(session, events);
|
package/package.json
CHANGED