jg-agent-hq 7.0.0 → 8.0.0

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.0.0
4
+
5
+ - 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`.
6
+ - Breaking: `provenance` gains `nativeInputSha256`, the SHA-256 of the text a user message's native input sent, or null, and a provider's items must carry it beside `nativeInputId`. Content a message holds after its sent text, such as an attached file, is no longer kept `unknown` on that account.
7
+ - Keep 7.0.0's storage schema, so databases and snapshots written by 5.x through 7.x open as they are.
8
+
3
9
  ## 7.0.0
4
10
 
5
11
  - Return an item's image only when it is at most 4 MiB, instead of 8 MiB, so one read holds less memory in a host that runs the runtime in its own process. An image over 4 MiB fails with `image-unavailable`. Its base64 now fits in one IPC response, so the CLI reads every image `item-image` returns.
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, 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 complete normalized text hash match the acknowledged action ledger. 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. Unverifiable, modified, attachment-expanded or skill-expanded content 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. 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
 
@@ -1328,6 +1328,7 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
1328
1328
  "agent-input": "agent-input";
1329
1329
  }>;
1330
1330
  nativeInputId: z.ZodNullable<z.ZodString>;
1331
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
1331
1332
  actionId: z.ZodNullable<z.ZodUUID>;
1332
1333
  contentBoundary: z.ZodLiteral<"untrusted">;
1333
1334
  grantsAuthority: z.ZodLiteral<false>;
@@ -23,6 +23,7 @@ export declare const HistoryProvenanceSchema: z.ZodObject<{
23
23
  "agent-input": "agent-input";
24
24
  }>;
25
25
  nativeInputId: z.ZodNullable<z.ZodString>;
26
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
26
27
  actionId: z.ZodNullable<z.ZodUUID>;
27
28
  contentBoundary: z.ZodLiteral<"untrusted">;
28
29
  grantsAuthority: z.ZodLiteral<false>;
@@ -91,6 +92,7 @@ export declare const EvidenceItemSchema: z.ZodObject<{
91
92
  "agent-input": "agent-input";
92
93
  }>;
93
94
  nativeInputId: z.ZodNullable<z.ZodString>;
95
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
94
96
  actionId: z.ZodNullable<z.ZodUUID>;
95
97
  contentBoundary: z.ZodLiteral<"untrusted">;
96
98
  grantsAuthority: z.ZodLiteral<false>;
@@ -141,6 +143,7 @@ export declare const EvidencePageSchema: z.ZodObject<{
141
143
  "agent-input": "agent-input";
142
144
  }>;
143
145
  nativeInputId: z.ZodNullable<z.ZodString>;
146
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
144
147
  actionId: z.ZodNullable<z.ZodUUID>;
145
148
  contentBoundary: z.ZodLiteral<"untrusted">;
146
149
  grantsAuthority: z.ZodLiteral<false>;
@@ -11,7 +11,11 @@ export const SessionDiscoveryRequestSchema = z.strictObject({
11
11
  limit: z.number().int().min(1).max(MAX_PAGE_SIZE).default(DEFAULT_PAGE_SIZE),
12
12
  cursor: CursorSchema.optional(),
13
13
  });
14
- // evidence is historical content, including any instructions or quotations within it
14
+ /*
15
+ * Evidence is historical content, including any instructions or quotations within it. A user
16
+ * message read from the provider carries its native input's ID and the SHA-256 of the text that
17
+ * input sent, before any attachment or cut, which link it to the action that sent it.
18
+ */
15
19
  export const HistoryProvenanceSchema = z.object({
16
20
  origin: z.enum(['operator', 'agent', 'tool', 'system', 'unknown']),
17
21
  source: z.enum([
@@ -22,6 +26,10 @@ export const HistoryProvenanceSchema = z.object({
22
26
  'unknown',
23
27
  ]),
24
28
  nativeInputId: NativeIdSchema.nullable(),
29
+ nativeInputSha256: z
30
+ .string()
31
+ .regex(/^[a-f0-9]{64}$/)
32
+ .nullable(),
25
33
  actionId: z.uuid().nullable(),
26
34
  contentBoundary: z.literal('untrusted'),
27
35
  grantsAuthority: z.literal(false),
@@ -1766,6 +1766,7 @@ export declare const HistoryItemSchema: z.ZodObject<{
1766
1766
  "agent-input": "agent-input";
1767
1767
  }>;
1768
1768
  nativeInputId: z.ZodNullable<z.ZodString>;
1769
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
1769
1770
  actionId: z.ZodNullable<z.ZodUUID>;
1770
1771
  contentBoundary: z.ZodLiteral<"untrusted">;
1771
1772
  grantsAuthority: z.ZodLiteral<false>;
@@ -1822,6 +1823,7 @@ export declare const ItemDetailSchema: z.ZodObject<{
1822
1823
  "agent-input": "agent-input";
1823
1824
  }>;
1824
1825
  nativeInputId: z.ZodNullable<z.ZodString>;
1826
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
1825
1827
  actionId: z.ZodNullable<z.ZodUUID>;
1826
1828
  contentBoundary: z.ZodLiteral<"untrusted">;
1827
1829
  grantsAuthority: z.ZodLiteral<false>;
@@ -1914,6 +1916,7 @@ export declare const LiveItemsSchema: z.ZodObject<{
1914
1916
  "agent-input": "agent-input";
1915
1917
  }>;
1916
1918
  nativeInputId: z.ZodNullable<z.ZodString>;
1919
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
1917
1920
  actionId: z.ZodNullable<z.ZodUUID>;
1918
1921
  contentBoundary: z.ZodLiteral<"untrusted">;
1919
1922
  grantsAuthority: z.ZodLiteral<false>;
@@ -2098,6 +2101,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2098
2101
  "agent-input": "agent-input";
2099
2102
  }>;
2100
2103
  nativeInputId: z.ZodNullable<z.ZodString>;
2104
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
2101
2105
  actionId: z.ZodNullable<z.ZodUUID>;
2102
2106
  contentBoundary: z.ZodLiteral<"untrusted">;
2103
2107
  grantsAuthority: z.ZodLiteral<false>;
@@ -6006,6 +6010,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6006
6010
  "agent-input": "agent-input";
6007
6011
  }>;
6008
6012
  nativeInputId: z.ZodNullable<z.ZodString>;
6013
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
6009
6014
  actionId: z.ZodNullable<z.ZodUUID>;
6010
6015
  contentBoundary: z.ZodLiteral<"untrusted">;
6011
6016
  grantsAuthority: z.ZodLiteral<false>;
@@ -6057,6 +6062,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6057
6062
  "agent-input": "agent-input";
6058
6063
  }>;
6059
6064
  nativeInputId: z.ZodNullable<z.ZodString>;
6065
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
6060
6066
  actionId: z.ZodNullable<z.ZodUUID>;
6061
6067
  contentBoundary: z.ZodLiteral<"untrusted">;
6062
6068
  grantsAuthority: z.ZodLiteral<false>;
@@ -6862,6 +6868,7 @@ export declare const HqResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6862
6868
  "agent-input": "agent-input";
6863
6869
  }>;
6864
6870
  nativeInputId: z.ZodNullable<z.ZodString>;
6871
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
6865
6872
  actionId: z.ZodNullable<z.ZodUUID>;
6866
6873
  contentBoundary: z.ZodLiteral<"untrusted">;
6867
6874
  grantsAuthority: z.ZodLiteral<false>;
@@ -8672,6 +8679,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8672
8679
  "agent-input": "agent-input";
8673
8680
  }>;
8674
8681
  nativeInputId: z.ZodNullable<z.ZodString>;
8682
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
8675
8683
  actionId: z.ZodNullable<z.ZodUUID>;
8676
8684
  contentBoundary: z.ZodLiteral<"untrusted">;
8677
8685
  grantsAuthority: z.ZodLiteral<false>;
@@ -12580,6 +12588,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12580
12588
  "agent-input": "agent-input";
12581
12589
  }>;
12582
12590
  nativeInputId: z.ZodNullable<z.ZodString>;
12591
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
12583
12592
  actionId: z.ZodNullable<z.ZodUUID>;
12584
12593
  contentBoundary: z.ZodLiteral<"untrusted">;
12585
12594
  grantsAuthority: z.ZodLiteral<false>;
@@ -12631,6 +12640,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12631
12640
  "agent-input": "agent-input";
12632
12641
  }>;
12633
12642
  nativeInputId: z.ZodNullable<z.ZodString>;
12643
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
12634
12644
  actionId: z.ZodNullable<z.ZodUUID>;
12635
12645
  contentBoundary: z.ZodLiteral<"untrusted">;
12636
12646
  grantsAuthority: z.ZodLiteral<false>;
@@ -13436,6 +13446,7 @@ export declare const IpcResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
13436
13446
  "agent-input": "agent-input";
13437
13447
  }>;
13438
13448
  nativeInputId: z.ZodNullable<z.ZodString>;
13449
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
13439
13450
  actionId: z.ZodNullable<z.ZodUUID>;
13440
13451
  contentBoundary: z.ZodLiteral<"untrusted">;
13441
13452
  grantsAuthority: z.ZodLiteral<false>;
@@ -45,6 +45,7 @@ export declare const ClaudeHistoryReadSchema: z.ZodUnion<readonly [z.ZodDiscrimi
45
45
  "agent-input": "agent-input";
46
46
  }>;
47
47
  nativeInputId: z.ZodNullable<z.ZodString>;
48
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
48
49
  actionId: z.ZodNullable<z.ZodUUID>;
49
50
  contentBoundary: z.ZodLiteral<"untrusted">;
50
51
  grantsAuthority: z.ZodLiteral<false>;
@@ -3953,6 +3954,7 @@ export declare const ClaudeHistoryReadSchema: z.ZodUnion<readonly [z.ZodDiscrimi
3953
3954
  "agent-input": "agent-input";
3954
3955
  }>;
3955
3956
  nativeInputId: z.ZodNullable<z.ZodString>;
3957
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
3956
3958
  actionId: z.ZodNullable<z.ZodUUID>;
3957
3959
  contentBoundary: z.ZodLiteral<"untrusted">;
3958
3960
  grantsAuthority: z.ZodLiteral<false>;
@@ -4004,6 +4006,7 @@ export declare const ClaudeHistoryReadSchema: z.ZodUnion<readonly [z.ZodDiscrimi
4004
4006
  "agent-input": "agent-input";
4005
4007
  }>;
4006
4008
  nativeInputId: z.ZodNullable<z.ZodString>;
4009
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
4007
4010
  actionId: z.ZodNullable<z.ZodUUID>;
4008
4011
  contentBoundary: z.ZodLiteral<"untrusted">;
4009
4012
  grantsAuthority: z.ZodLiteral<false>;
@@ -4809,6 +4812,7 @@ export declare const ClaudeHistoryReadSchema: z.ZodUnion<readonly [z.ZodDiscrimi
4809
4812
  "agent-input": "agent-input";
4810
4813
  }>;
4811
4814
  nativeInputId: z.ZodNullable<z.ZodString>;
4815
+ nativeInputSha256: z.ZodNullable<z.ZodString>;
4812
4816
  actionId: z.ZodNullable<z.ZodUUID>;
4813
4817
  contentBoundary: z.ZodLiteral<"untrusted">;
4814
4818
  grantsAuthority: z.ZodLiteral<false>;
@@ -186,6 +186,16 @@ const toUserPresentation = (record, text) => {
186
186
  }
187
187
  return { ...base, kind: 'user-message', text };
188
188
  };
189
+ // the text a user record's input sent: its whole content, or its first block when that is text
190
+ const readInputText = (record) => {
191
+ 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
+ };
189
199
  /** Presents a native record as the CLI shows it, or null for one it leaves out. */
190
200
  const toPresentation = (record) => {
191
201
  const base = { nativeType: record.type, callId: null, outcome: null, files: [] };
@@ -273,7 +283,9 @@ export const toClaudeItem = (record, turnId, fullBody = false) => {
273
283
  ...presentation,
274
284
  nativeId: record.uuid,
275
285
  turnId,
276
- provenance: nativeProvenance(presentation.kind, presentation.kind === 'user-message' ? record.uuid : null),
286
+ provenance: presentation.kind === 'user-message'
287
+ ? nativeProvenance(presentation.kind, record.uuid, readInputText(record))
288
+ : nativeProvenance(presentation.kind),
277
289
  text: text.slice(0, end),
278
290
  isTruncated: end < text.length,
279
291
  createdAt: Number.isFinite(createdAt) ? createdAt : null,
@@ -112,17 +112,21 @@ const toHistoryFile = (change) => {
112
112
  export const toHistoryItem = ({ turnId, item }, turn, fullBody = false) => {
113
113
  let kind = 'unsupported';
114
114
  let text = '';
115
+ // the text part a user message's input sent first, which links it to the action that sent it
116
+ let inputText = null;
115
117
  let files = [];
116
118
  let outcome = null;
117
119
  switch (item.type) {
118
120
  case 'reasoning':
119
121
  return null;
120
- case 'userMessage':
122
+ case 'userMessage': {
121
123
  kind = 'user-message';
122
- text = parseNative(TextPartsSchema, item)
123
- .content.map((part) => ('text' in part ? part.text : `[${part.type}]`))
124
- .join('\n');
124
+ const { content } = parseNative(TextPartsSchema, item);
125
+ text = content.map((part) => ('text' in part ? part.text : `[${part.type}]`)).join('\n');
126
+ const [first] = content;
127
+ inputText = first && 'text' in first ? first.text : null;
125
128
  break;
129
+ }
126
130
  case 'agentMessage':
127
131
  kind = 'agent-message';
128
132
  text = parseNative(MessageSchema, item).text;
@@ -181,7 +185,7 @@ export const toHistoryItem = ({ turnId, item }, turn, fullBody = false) => {
181
185
  turnId,
182
186
  nativeType: item.type,
183
187
  kind,
184
- provenance: nativeProvenance(kind, kind === 'user-message' && typeof item.clientId === 'string' ? item.clientId : null),
188
+ provenance: nativeProvenance(kind, kind === 'user-message' && typeof item.clientId === 'string' ? item.clientId : null, inputText),
185
189
  text: text.slice(0, end),
186
190
  isTruncated: end < text.length,
187
191
  // a Codex item holds its call and its result together
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  import { HistoryItemSchema, ThreadSummarySchema, MAX_PROVIDERS, ApprovalPresentationSchema, AccountObservationSchema, LoginObservationSchema, NativeControlResultSchema, MAX_MCP_CATALOG_BYTES, ProviderCapabilitySetSchema, ProviderIdSchema, ProviderStatusSchema, ProviderModelPageSchema, SessionConfigurationSchema, SessionStateSchema, UsageSnapshotSchema, } from '../../contracts/index.js';
5
5
  import { NativeIdSchema } from '../../contracts/identities/index.js';
6
6
  import { MAX_FRAME_BYTES } from '../../ipc/index.js';
7
- import { nativeProvenance } from '../../sessions/evidence/index.js';
7
+ import { resetProvenance } from '../../sessions/evidence/index.js';
8
8
  import { ApprovalRecordSchema } from '../../store/control/index.js';
9
9
  import { ProviderMcpServerPageSchema, ProviderMcpToolsSchema, ProviderMcpResourcesSchema, } from '../extensions/index.js';
10
10
  import { ProviderInspectionSchema, ProviderThreadSchema, ProviderSkillsSchema, } from '../index.js';
@@ -145,7 +145,7 @@ export const createProviderRegistry = (registrations, allowedRoots, runtimeEpoch
145
145
  }),
146
146
  item: (nativeId, item, complete, replacedIds) => deliver(() => {
147
147
  const normalized = HistoryItemSchema.parse(item);
148
- normalized.provenance = nativeProvenance(normalized.kind, normalized.provenance.nativeInputId);
148
+ normalized.provenance = resetProvenance(normalized.kind, normalized.provenance);
149
149
  handlers?.item(provider, NativeIdSchema.parse(nativeId), normalized, z.boolean().parse(complete), replacedIds === undefined
150
150
  ? undefined
151
151
  : z.array(NativeIdSchema).max(128).parse(replacedIds));
@@ -1,3 +1,3 @@
1
- export { buildEvidencePage, evidencePosition, evidenceCursor, verifyEvidencePage, evidenceHash, nativeProvenance, utf8Chunk, EVIDENCE_RESPONSE_BYTES, EVIDENCE_SOURCE_PAGE_SIZE, } from './utilities.js';
1
+ export { buildEvidencePage, evidencePosition, evidenceCursor, verifyEvidencePage, evidenceHash, nativeProvenance, resetProvenance, utf8Chunk, EVIDENCE_RESPONSE_BYTES, EVIDENCE_SOURCE_PAGE_SIZE, } from './utilities.js';
2
2
  export { EvidenceOriginsRequestSchema } from './types.js';
3
3
  export type { IEvidenceOriginsRequest } from './types.js';
@@ -1,4 +1,4 @@
1
1
  // bounded native evidence selection
2
- export { buildEvidencePage, evidencePosition, evidenceCursor, verifyEvidencePage, evidenceHash, nativeProvenance, utf8Chunk, EVIDENCE_RESPONSE_BYTES, EVIDENCE_SOURCE_PAGE_SIZE, } from './utilities.js';
2
+ export { buildEvidencePage, evidencePosition, evidenceCursor, verifyEvidencePage, evidenceHash, nativeProvenance, resetProvenance, utf8Chunk, EVIDENCE_RESPONSE_BYTES, EVIDENCE_SOURCE_PAGE_SIZE, } from './utilities.js';
3
3
  // private worker provenance lookup
4
4
  export { EvidenceOriginsRequestSchema } from './types.js';
@@ -5,7 +5,7 @@ export declare const EvidenceOriginsRequestSchema: z.ZodObject<{
5
5
  items: z.ZodArray<z.ZodObject<{
6
6
  nativeInputId: z.ZodNullable<z.ZodString>;
7
7
  turnId: z.ZodString;
8
- sha256: z.ZodString;
8
+ sha256: z.ZodNullable<z.ZodString>;
9
9
  }, z.core.$strict>>;
10
10
  }, z.core.$strict>;
11
11
  export type IEvidenceOriginsRequest = z.infer<typeof EvidenceOriginsRequestSchema>;
@@ -8,7 +8,10 @@ export const EvidenceOriginsRequestSchema = z.strictObject({
8
8
  .array(z.strictObject({
9
9
  nativeInputId: z.string().min(1).max(4096).nullable(),
10
10
  turnId: z.string().min(1).max(4096),
11
- sha256: z.string().regex(/^[a-f0-9]{64}$/),
11
+ sha256: z
12
+ .string()
13
+ .regex(/^[a-f0-9]{64}$/)
14
+ .nullable(),
12
15
  }))
13
16
  .max(128),
14
17
  });
@@ -2,8 +2,22 @@ import type { IEvidencePage, IEvidenceRequest, IHistoryItem, IHistoryProvenance
2
2
  import { type IEvidencePosition } from './types.js';
3
3
  export declare const EVIDENCE_RESPONSE_BYTES = 65536;
4
4
  export declare const EVIDENCE_SOURCE_PAGE_SIZE = 8;
5
- /** Returns native evidence of a kind, without inferring operator identity from a user role. */
6
- export declare const nativeProvenance: (kind: IHistoryItem["kind"], nativeInputId?: string | null) => IHistoryProvenance;
5
+ /**
6
+ * Returns native evidence of a kind, without inferring operator identity from a user role.
7
+ * @param kind The item's kind.
8
+ * @param nativeInputId The native input a user message came from, when the provider names one.
9
+ * @param nativeInputText The text that input sent, before attachments or a cut, which is hashed.
10
+ * @returns The provenance, which links to no action until the store matches one.
11
+ */
12
+ export declare const nativeProvenance: (kind: IHistoryItem["kind"], nativeInputId?: string | null, nativeInputText?: string | null) => IHistoryProvenance;
13
+ /**
14
+ * Keeps only the native input link a provider's item names, so provider assertions alone never
15
+ * establish an operator or an HQ action link.
16
+ * @param kind The item's kind.
17
+ * @param provenance The provenance the provider gave the item.
18
+ * @returns The provenance, with its native input ID and text hash and no action.
19
+ */
20
+ export declare const resetProvenance: (kind: IHistoryItem["kind"], { nativeInputId, nativeInputSha256 }: IHistoryProvenance) => IHistoryProvenance;
7
21
  /** Hashes exactly the normalized UTF-8 evidence content. */
8
22
  export declare const evidenceHash: (text: string) => string;
9
23
  /**
@@ -6,8 +6,14 @@ import { EvidencePositionSchema } from './types.js';
6
6
  export const EVIDENCE_RESPONSE_BYTES = 65_536;
7
7
  export const EVIDENCE_SOURCE_PAGE_SIZE = 8;
8
8
  const PAYLOAD_BYTES = EVIDENCE_RESPONSE_BYTES - 4096 - 16_384;
9
- /** Returns native evidence of a kind, without inferring operator identity from a user role. */
10
- export const nativeProvenance = (kind, nativeInputId = null) => ({
9
+ /**
10
+ * Returns native evidence of a kind, without inferring operator identity from a user role.
11
+ * @param kind The item's kind.
12
+ * @param nativeInputId The native input a user message came from, when the provider names one.
13
+ * @param nativeInputText The text that input sent, before attachments or a cut, which is hashed.
14
+ * @returns The provenance, which links to no action until the store matches one.
15
+ */
16
+ export const nativeProvenance = (kind, nativeInputId = null, nativeInputText = null) => ({
11
17
  origin: kind === 'agent-message'
12
18
  ? 'agent'
13
19
  : kind === 'tool' || kind === 'command' || kind === 'file-change'
@@ -17,10 +23,22 @@ export const nativeProvenance = (kind, nativeInputId = null) => ({
17
23
  : 'unknown',
18
24
  source: kind === 'unsupported' || kind === 'user-message' ? 'unknown' : 'native-kind',
19
25
  nativeInputId,
26
+ nativeInputSha256: nativeInputId === null || nativeInputText === null ? null : evidenceHash(nativeInputText),
20
27
  actionId: null,
21
28
  contentBoundary: 'untrusted',
22
29
  grantsAuthority: false,
23
30
  });
31
+ /**
32
+ * Keeps only the native input link a provider's item names, so provider assertions alone never
33
+ * establish an operator or an HQ action link.
34
+ * @param kind The item's kind.
35
+ * @param provenance The provenance the provider gave the item.
36
+ * @returns The provenance, with its native input ID and text hash and no action.
37
+ */
38
+ export const resetProvenance = (kind, { nativeInputId, nativeInputSha256 }) => ({
39
+ ...nativeProvenance(kind, nativeInputId),
40
+ nativeInputSha256: nativeInputId === null ? null : nativeInputSha256,
41
+ });
24
42
  /** Hashes exactly the normalized UTF-8 evidence content. */
25
43
  export const evidenceHash = (text) => createHash('sha256').update(text).digest('hex');
26
44
  /**
@@ -3,7 +3,7 @@ import { DEFAULT_PAGE_SIZE, HqResponseSchema, MAX_PAGE_SIZE, } from '../contract
3
3
  import { retainNativeLineage } from '../providers/index.js';
4
4
  import { resolveWorkspaceTarget } from '../runtime/state/index.js';
5
5
  import { imageUnavailable } from './utilities.js';
6
- import { evidencePosition, verifyEvidencePage, evidenceCursor, evidenceHash, utf8Chunk, nativeProvenance, EVIDENCE_SOURCE_PAGE_SIZE, } from './evidence/index.js';
6
+ import { evidencePosition, verifyEvidencePage, evidenceCursor, utf8Chunk, resetProvenance, EVIDENCE_SOURCE_PAGE_SIZE, } from './evidence/index.js';
7
7
  /**
8
8
  * Authorizes native history before loading content and records only its discovery projection.
9
9
  * @returns One provider-paged read result, never a complete transcript scan.
@@ -132,18 +132,20 @@ export const readNativeHistory = async (command, registry, projection, allowedRo
132
132
  ? [response.result.item]
133
133
  : [];
134
134
  if (items.length && 'nativeId' in command) {
135
- // provider assertions alone never establish an operator or an HQ action link
135
+ /*
136
+ * Provider assertions alone never establish an operator or an HQ action link. A user message
137
+ * links to the action whose input it holds by its native input and the hash of the text that
138
+ * input sent, so attachments and a cut text don't hide it.
139
+ */
136
140
  for (const item of items)
137
- item.provenance = nativeProvenance(item.kind, item.provenance.nativeInputId);
141
+ item.provenance = resetProvenance(item.kind, item.provenance);
138
142
  const origins = await projection.getEvidenceOrigins({
139
143
  provider: command.provider,
140
144
  nativeId: command.nativeId,
141
- items: items.map((item) => ({
142
- nativeInputId: item.kind === 'user-message' && (!('isTruncated' in item) || !item.isTruncated)
143
- ? item.provenance.nativeInputId
144
- : null,
145
+ items: items.map(({ kind, provenance, ...item }) => ({
146
+ nativeInputId: kind === 'user-message' ? provenance.nativeInputId : null,
145
147
  turnId: 'reference' in item ? item.reference.turnId : item.turnId,
146
- sha256: 'reference' in item ? item.reference.sha256 : evidenceHash(item.text),
148
+ sha256: provenance.nativeInputSha256,
147
149
  })),
148
150
  });
149
151
  for (const [index, origin] of origins.entries())
@@ -56,7 +56,7 @@ export class ControlModel {
56
56
  AND a.delivery = 'acknowledged' AND (a.native_request_id = ? OR a.native_turn_id = ?)
57
57
  ORDER BY a.id LIMIT 2`);
58
58
  return command.items.map((item) => {
59
- if (item.nativeInputId === null)
59
+ if (item.nativeInputId === null || item.sha256 === null)
60
60
  return null;
61
61
  const rows = query.all(command.provider, command.nativeId, item.turnId, item.sha256, item.nativeInputId, item.nativeInputId);
62
62
  if (rows.length !== 1)
@@ -77,6 +77,7 @@ export class ControlModel {
77
77
  : 'host-action',
78
78
  actionId: row.id,
79
79
  nativeInputId: item.nativeInputId,
80
+ nativeInputSha256: item.sha256,
80
81
  contentBoundary: 'untrusted',
81
82
  grantsAuthority: false,
82
83
  };
@@ -629,7 +629,7 @@ export declare const StoreCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
629
629
  items: z.ZodArray<z.ZodObject<{
630
630
  nativeInputId: z.ZodNullable<z.ZodString>;
631
631
  turnId: z.ZodString;
632
- sha256: z.ZodString;
632
+ sha256: z.ZodNullable<z.ZodString>;
633
633
  }, z.core.$strict>>;
634
634
  }, z.core.$strict>;
635
635
  }, z.core.$strict>, z.ZodObject<{
@@ -4154,7 +4154,7 @@ export declare const StoreRequestSchema: z.ZodObject<{
4154
4154
  items: z.ZodArray<z.ZodObject<{
4155
4155
  nativeInputId: z.ZodNullable<z.ZodString>;
4156
4156
  turnId: z.ZodString;
4157
- sha256: z.ZodString;
4157
+ sha256: z.ZodNullable<z.ZodString>;
4158
4158
  }, z.core.$strict>>;
4159
4159
  }, z.core.$strict>;
4160
4160
  }, z.core.$strict>, z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jg-agent-hq",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
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",