jg-agent-hq 8.0.0 → 8.0.2

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.0.2
4
+
5
+ - Clear a finished command, tool call or file change from the live window once history holds it with the same outcome. Codex shortens long command output when it saves it, so the saved text never matched the live text and the item stayed `awaiting-flush` until the window evicted it. An item without an outcome, such as a message, still needs exactly matching content.
6
+ - Keep 7.0.0's storage schema, so databases and snapshots written by 5.x through 8.0.1 open as they are.
7
+
8
+ ## 8.0.1
9
+
10
+ - Link a Claude message that invokes a skill or slash command to the action that sent it. Claude records the `/name args` it received as command markup, so its hash never matched the action's and a Claude reviewer's review request stayed `unknown`. `nativeInputSha256` now hashes the `/name args` the markup holds.
11
+ - Keep 7.0.0's storage schema, so databases and snapshots written by 5.x through 8.0.0 open as they are.
12
+
3
13
  ## 8.0.0
4
14
 
5
15
  - Correlate a message HQ sent with a skill or attached files, or one longer than a page keeps, with the action that sent it. Correlation hashed the message's whole presented text, which for Codex holds a `[skill]` line and its attached files after the text, and for Claude a `[Native document]` or image line, and it skipped a message a page cut, so all of them stayed `unknown`. Provenance now matches the SHA-256 of the text the native input sent, before the parts the same input added and before any cut. A Codex reviewer's review request, which always carries its skill, now reads `agent-input`.
package/api/README.md CHANGED
@@ -156,7 +156,7 @@ Threads expose native state, the live session `state` described under [session s
156
156
 
157
157
  Text chunks contain at most 32,768 UTF-8 bytes and shrink when escaping or metadata consumes the response budget. Cursors bind all query fields and the content of a partially consumed native page. Changed content, changed query scope or a changed Claude chain revision uses CURSOR_INVALID; start a fresh read rather than joining different evidence. New native pages use the provider's continuation, not an immutable transcript snapshot. Newly arriving or removed history may therefore require a fresh discovery/evidence read. Authorization is rechecked on every request before content access, and no alternate raw-file path bypasses a denial.
158
158
 
159
- `HistoryItemSchema` and evidence fragments expose `provenance: { origin, source, nativeInputId, nativeInputSha256, actionId, contentBoundary: 'untrusted', grantsAuthority: false }`. Origins are operator, agent, tool, system or unknown. Native assistant/tool kinds establish only their observed category. A native user role, quoted operator text or an imported message cannot establish an operator. HQ correlates a submitted input only when its exact native message/client identity, thread/turn and `nativeInputSha256` match the acknowledged action ledger. A provider's user message carries `nativeInputSha256`, the SHA-256 of the text its native input sent: a Codex message's first text part, or a Claude record's string content or first text block. It is hashed before the parts the same input added after the text, such as a skill or attached files, and before a page cuts the text, so those messages correlate too. Programmatic host submissions have source `host-action` and unknown actor. An authenticated browser submission additionally requires the same selected thread and text fingerprint, yielding `authenticated-host-action` and operator provenance. A message without a native input identity, or whose sent text differs from the action's, stays unknown. Provenance remains historical evidence and grants no current approval, execution authority or tool permission; quotations remain inside its untrusted content boundary.
159
+ `HistoryItemSchema` and evidence fragments expose `provenance: { origin, source, nativeInputId, nativeInputSha256, actionId, contentBoundary: 'untrusted', grantsAuthority: false }`. Origins are operator, agent, tool, system or unknown. Native assistant/tool kinds establish only their observed category. A native user role, quoted operator text or an imported message cannot establish an operator. HQ correlates a submitted input only when its exact native message/client identity, thread/turn and `nativeInputSha256` match the acknowledged action ledger. A provider's user message carries `nativeInputSha256`, the SHA-256 of the text its native input sent: a Codex message's first text part, or a Claude record's string content or first text block, with a slash command or skill, which Claude records as command markup, read back as the `/name args` it sent. It is hashed before the parts the same input added after the text, such as a skill or attached files, and before a page cuts the text, so those messages correlate too. Programmatic host submissions have source `host-action` and unknown actor. An authenticated browser submission additionally requires the same selected thread and text fingerprint, yielding `authenticated-host-action` and operator provenance. A message without a native input identity, or whose sent text differs from the action's, stays unknown. Provenance remains historical evidence and grants no current approval, execution authority or tool permission; quotations remain inside its untrusted content boundary.
160
160
 
161
161
  Codex uses its native descending item API with unloaded thread metadata. It never reads Codex transcript files. Claude uses indexed current-chain byte locations, exact UUID lookups and separate bounded seeks per selected kind. Its cold index uses 16 MiB batches and a 30-second operation budget; selected evidence reads parse at most 4 MiB of records beyond the first. Continuation revalidates and rereads one bounded native page to detect content changes rather than caching transcript bodies. Work and memory per read are bounded independently of history growth; reconstructing a large body may reread that source page. No conversation-body cache is maintained.
162
162
 
@@ -323,7 +323,7 @@ The installed CLI exposes `managed-thread-name --name <name>` and `suggest-threa
323
323
 
324
324
  Control pages default to 32 and cap at 128. Seek cursors are bound to their complete query and ordering. Reads recheck allowed workspaces. Rejected controls retain their known thread association, and native availability failures appear in each affected thread's replay. Lifecycle replay contains metadata, not token or tool output. Each provider has a bounded native lifecycle backlog; overflow stops that source and marks its state uncertain rather than losing events silently. Other providers retain their independent connection and admission state.
325
325
 
326
- Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page contains exactly matching normalized content or the bounded cache evicts them. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
326
+ Live item presentation is bounded to 128 items per cached thread, 32 windows and 4 MiB of serialized presentation across the runtime, including escaped text and identifiers. This leaves room inside the IPC response limit. Display text uses the same truncation contract as native history. Eviction, an unavailable window or missing chunks sets `hasGap`. Completed items remain `awaiting-flush` after thread closure until a native history page holds the same item, with exactly matching normalized content or, for an item with an outcome, the same final outcome, or the bounded cache evicts them. The outcome is enough because Codex shortens long command output when it saves it. Read persisted history and the live window together after reconnect; a process restart cannot reconstruct unflushed in-memory content.
327
327
 
328
328
  Items expose only normalized presentation fields, and one mapping per provider presents `items`, live items and `session-evidence` alike, as the provider's CLI shows them. Kinds are `user-message`, `agent-message`, `command`, `tool`, `file-change`, `notice` and `unsupported`. `callId` pairs a tool call with its result, or is null. `outcome` is `succeeded`, `failed`, or null when unknown or still running. `files` lists each file a file change touched, at most 128, with its added and removed lines, and is empty on other items. `outcome` and `files` come from the full native record, so `textLimit` never changes them. Unknown native kinds report `unsupported` without copying arbitrary payloads. Display text is bounded to 65,536 UTF-16 code units without splitting a surrogate pair; `isTruncated` reports omissions. An unsupported or oversized native transport frame fails explicitly. `createdAt` is the item's time in Unix milliseconds, or null when the provider records none. A Claude item takes its record's `timestamp`, and a live one the time its frame arrived. A Codex item takes its turn's times, which Codex records across all of its history: an operator message takes its turn's start and every other item its turn's end, or its start while the turn runs. A Codex history page reads the turns of its items newest first, 128 at a time and at most 8 times, so a recent page takes one read and an item whose turn lies further back has no time. A live Codex item takes its running turn's start.
329
329
 
@@ -25,7 +25,11 @@ export declare class LiveItems {
25
25
  })[];
26
26
  hasGap: boolean;
27
27
  };
28
- /** Drops completed items only after their normalized persisted content matches exactly. */
28
+ /**
29
+ * Drops completed items once persisted history holds them: with exactly matching normalized
30
+ * content, or, for an item with an outcome, the same final outcome, since a provider can shorten
31
+ * long output when it saves it, as Codex does.
32
+ */
29
33
  reconcile(nativeId: string, persisted: IHistoryItem[]): void;
30
34
  /** Keeps interrupted partial items available while their final native history is pending. */
31
35
  completeTurn(nativeId: string, turnId: string): void;
@@ -103,7 +103,11 @@ export class LiveItems {
103
103
  hasGap: thread?.hasGap ?? true,
104
104
  };
105
105
  }
106
- /** Drops completed items only after their normalized persisted content matches exactly. */
106
+ /**
107
+ * Drops completed items once persisted history holds them: with exactly matching normalized
108
+ * content, or, for an item with an outcome, the same final outcome, since a provider can shorten
109
+ * long output when it saves it, as Codex does.
110
+ */
107
111
  reconcile(nativeId, persisted) {
108
112
  const thread = this.__threads.get(nativeId);
109
113
  if (!thread)
@@ -114,8 +118,8 @@ export class LiveItems {
114
118
  if (entry?.isComplete &&
115
119
  entry.item.nativeType === item.nativeType &&
116
120
  entry.item.kind === item.kind &&
117
- entry.item.text === item.text &&
118
- entry.item.isTruncated === item.isTruncated) {
121
+ ((entry.item.text === item.text && entry.item.isTruncated === item.isTruncated) ||
122
+ (item.outcome !== null && entry.item.outcome === item.outcome))) {
119
123
  this.__bytes -= entry.bytes;
120
124
  thread.items.delete(key);
121
125
  thread.revision = ++this.__revision;
@@ -159,6 +159,14 @@ const toFileChange = (patch) => {
159
159
  * Presents an operator-side text record; a task notification, which the CLI doesn't show, is
160
160
  * dropped, and a `!` shell output takes its input's UUID as its call.
161
161
  */
162
+ // the `/name args` the operator typed, which Claude records as command markup, or null for other text
163
+ const readCommandText = (text) => {
164
+ const name = COMMAND.test(text) ? COMMAND_NAME.exec(text)?.[1] : undefined;
165
+ if (!name)
166
+ return null;
167
+ const args = COMMAND_ARGS.exec(text)?.[1]?.trim();
168
+ return args ? `/${name} ${args}` : `/${name}`;
169
+ };
162
170
  const toUserPresentation = (record, text) => {
163
171
  const base = { nativeType: record.type, callId: null, outcome: null, files: [] };
164
172
  if (text.startsWith('<task-notification>'))
@@ -179,22 +187,17 @@ const toUserPresentation = (record, text) => {
179
187
  text: [output[1], output[2]].filter(Boolean).join('\n'),
180
188
  callId: record.parentUuid ?? null,
181
189
  };
182
- const name = COMMAND.test(text) ? COMMAND_NAME.exec(text)?.[1] : undefined;
183
- if (name) {
184
- const args = COMMAND_ARGS.exec(text)?.[1]?.trim();
185
- return { ...base, kind: 'user-message', text: args ? `/${name} ${args}` : `/${name}` };
186
- }
187
- return { ...base, kind: 'user-message', text };
190
+ return { ...base, kind: 'user-message', text: readCommandText(text) ?? text };
188
191
  };
189
- // the text a user record's input sent: its whole content, or its first block when that is text
192
+ /*
193
+ * The text a user record's input sent: its whole content, or its first block when that is text,
194
+ * with a slash command or skill as the `/name args` that was sent, not the markup Claude records.
195
+ */
190
196
  const readInputText = (record) => {
191
197
  const content = record.message?.content;
192
- if (typeof content === 'string')
193
- return content;
194
- if (!Array.isArray(content))
195
- return null;
196
- const first = BlockSchema.safeParse(content[0]).data;
197
- return first?.type === 'text' ? (first.text ?? null) : null;
198
+ const first = Array.isArray(content) ? BlockSchema.safeParse(content[0]).data : undefined;
199
+ const text = typeof content === 'string' ? content : first?.type === 'text' ? (first.text ?? null) : null;
200
+ return text === null ? null : (readCommandText(text) ?? text);
198
201
  };
199
202
  /** Presents a native record as the CLI shows it, or null for one it leaves out. */
200
203
  const toPresentation = (record) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "8.0.0",
3
+ "version": "8.0.2",
4
4
  "description": "Native coding-agent session control, agent streams and durable collaboration for Node.js apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",