jg-agent-hq 6.1.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 +11 -0
- package/api/README.md +2 -2
- package/dist/contracts/browser/types.d.ts +1 -0
- package/dist/contracts/constants.d.ts +1 -1
- package/dist/contracts/constants.js +1 -1
- package/dist/contracts/evidence/types.d.ts +3 -0
- package/dist/contracts/evidence/types.js +9 -1
- package/dist/contracts/types.d.ts +11 -0
- package/dist/contracts/types.js +1 -1
- package/dist/providers/claude/history/types.d.ts +4 -0
- package/dist/providers/claude/history/utilities.js +13 -1
- package/dist/providers/codex/transformers.js +9 -5
- package/dist/providers/registry/registry.js +2 -2
- package/dist/sessions/evidence/index.d.ts +1 -1
- package/dist/sessions/evidence/index.js +1 -1
- package/dist/sessions/evidence/types.d.ts +1 -1
- package/dist/sessions/evidence/types.js +4 -1
- package/dist/sessions/evidence/utilities.d.ts +16 -2
- package/dist/sessions/evidence/utilities.js +20 -2
- package/dist/sessions/images.d.ts +2 -2
- package/dist/sessions/images.js +2 -2
- package/dist/sessions/sessions.js +10 -8
- package/dist/sessions/utilities.d.ts +2 -2
- package/dist/sessions/utilities.js +2 -2
- package/dist/store/control/control.model.js +2 -1
- package/dist/store/types.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
9
|
+
## 7.0.0
|
|
10
|
+
|
|
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.
|
|
12
|
+
- Keep 6.x's storage schema, so databases and snapshots written by 5.x and 6.x open as they are.
|
|
13
|
+
|
|
3
14
|
## 6.1.0
|
|
4
15
|
|
|
5
16
|
- Run HQ's own agent tools in Claude sessions without asking. A permission request for a tool of the session's agent bridge, named `mcp__<bridge server>__<tool>`, is allowed with its input unchanged and records no approval; every other tool still asks.
|
package/api/README.md
CHANGED
|
@@ -144,7 +144,7 @@ Paged commands accept `limit` (default 32, maximum 128) and an opaque `cursor`.
|
|
|
144
144
|
|
|
145
145
|
`item-detail` returns `IItemDetail` for one item of a turn, or null for a hidden or unknown item, or one outside that turn. `item` is the item as an `items` read of it returns it. `command` is `{ command, output, isOutputStartCut, exitCode, durationMs }` or null: a Codex `commandExecution` gives every field, a Claude `Bash` call its command, its result the command and its output, from the result's stdout and stderr or else its text, and a `!` shell input or output the same; Claude records no exit code or duration. `tool` is `{ server, name, input, result, isResultStartCut }` or null, with `input` and `result` as text: JSON for Codex `mcpToolCall` and `dynamicToolCall`, and for a Claude call its input as JSON and for its result the text of its content, an MCP tool's name split into its server and tool. A Claude result takes its command or tool name from the call it answers, which HQ looks for among its 32 nearest ancestors in its turn. `files` lists each changed file with `path`, `added`, `removed` and its unified `diff`, from Codex `fileChange` and Claude Edit and Write results; a created or deleted file without hunks is its whole content, every line added or removed. `images` lists every image the item holds or names, at most 64, in order: `{ index, mediaType, byteCount }`, where `mediaType` is `image/png`, `image/jpeg`, `image/gif` or `image/webp` when its first bytes are one of them, and both are null for an image the item only names, such as a Codex `imageView` or `localImage` path or a URL. Output and results longer than 65,536 UTF-16 code units keep their last 65,536, on a code-point boundary, with `isOutputStartCut` or `isResultStartCut` set.
|
|
146
146
|
|
|
147
|
-
`item-image` returns the image at `index`, from 0 to 63, in the item's `images`, as `{ mediaType, data }` with its bytes in base64. A Claude image comes from an `image` block with a `base64` source, in the record's message or in a tool result's content. A Codex image comes from an `imageView` item's path, a user message's `localImage` path, or an `image` part's base64 `data:` URL; no other URL is fetched. A path must be absolute. Its file is opened without following it when it is itself a symbolic link, and without waiting on a pipe, and it is read only when it is a regular file; directories in the path are resolved as usual. An image is returned only when its first bytes are PNG, JPEG, GIF or WebP, which set `mediaType`, and it is at most
|
|
147
|
+
`item-image` returns the image at `index`, from 0 to 63, in the item's `images`, as `{ mediaType, data }` with its bytes in base64. A Claude image comes from an `image` block with a `base64` source, in the record's message or in a tool result's content. A Codex image comes from an `imageView` item's path, a user message's `localImage` path, or an `image` part's base64 `data:` URL; no other URL is fetched. A path must be absolute. Its file is opened without following it when it is itself a symbolic link, and without waiting on a pipe, and it is read only when it is a regular file; directories in the path are resolved as usual. An image is returned only when its first bytes are PNG, JPEG, GIF or WebP, which set `mediaType`, and it is at most 4 MiB, so its base64 fits in one IPC response. Anything else, including a hidden or unknown item, one outside that turn, or an index past its images, fails with the `image-unavailable` kind.
|
|
148
148
|
|
|
149
149
|
Threads expose native state, the live session `state` described under [session states](#session-states), `historyState` (`available` or `unavailable`), ownership (`external`, `managed` or `uncertain`) and nullable `managedId`. A managed thread uses its HQ name; an external thread retains its nullable native name. Timestamps use Unix milliseconds. Discovery projections are not authoritative transcript history and never cache a conversation body. Repeated Codex history reads go to its native APIs so a completed turn whose items have not flushed can be read again later. There is no resume-to-read behavior or Codex transcript-file parser.
|
|
150
150
|
|
|
@@ -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
|
|
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>;
|
|
@@ -2,7 +2,7 @@ export declare const DEFAULT_PAGE_SIZE = 32;
|
|
|
2
2
|
export declare const MAX_PAGE_SIZE = 128;
|
|
3
3
|
export declare const MAX_ITEM_TEXT_LENGTH = 65536;
|
|
4
4
|
export declare const MAX_ITEM_IMAGES = 64;
|
|
5
|
-
export declare const MAX_ITEM_IMAGE_BYTES =
|
|
5
|
+
export declare const MAX_ITEM_IMAGE_BYTES = 4194304;
|
|
6
6
|
export declare const PUBLIC_ERROR_CODES: {
|
|
7
7
|
readonly 'invalid-request': "JG_AGENT_HQ_CLIENT_INVALID_REQUEST";
|
|
8
8
|
readonly 'authentication-required': "JG_AGENT_HQ_CLIENT_AUTHENTICATION_REQUIRED";
|
|
@@ -5,7 +5,7 @@ export const MAX_PAGE_SIZE = 128;
|
|
|
5
5
|
export const MAX_ITEM_TEXT_LENGTH = 65_536;
|
|
6
6
|
// the most images one item's detail lists, and the largest one HQ returns, in bytes
|
|
7
7
|
export const MAX_ITEM_IMAGES = 64;
|
|
8
|
-
export const MAX_ITEM_IMAGE_BYTES =
|
|
8
|
+
export const MAX_ITEM_IMAGE_BYTES = 4_194_304;
|
|
9
9
|
// stable client codes for failures translated at IPC and browser boundaries
|
|
10
10
|
export const PUBLIC_ERROR_CODES = {
|
|
11
11
|
'invalid-request': 'JG_AGENT_HQ_CLIENT_INVALID_REQUEST',
|
|
@@ -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
|
-
|
|
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>;
|
package/dist/contracts/types.js
CHANGED
|
@@ -256,7 +256,7 @@ export const ItemDetailSchema = z.object({
|
|
|
256
256
|
}))
|
|
257
257
|
.max(MAX_ITEM_IMAGES),
|
|
258
258
|
});
|
|
259
|
-
// an image's bytes in base64, recognized by its first bytes and at most
|
|
259
|
+
// an image's bytes in base64, recognized by its first bytes and at most 4 MiB
|
|
260
260
|
export const ItemImageSchema = z.object({
|
|
261
261
|
mediaType: ItemImageMediaTypeSchema,
|
|
262
262
|
data: z
|
|
@@ -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:
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 {
|
|
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 =
|
|
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
|
|
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
|
-
/**
|
|
6
|
-
|
|
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
|
-
/**
|
|
10
|
-
|
|
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
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type IItemImage } from '../contracts/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Reads an image file an item names. A file that is itself a symbolic link is refused, as the
|
|
4
|
-
* open doesn't follow it, a pipe is never waited on, and only a regular file of at most
|
|
5
|
-
* read; a file that grew past
|
|
4
|
+
* open doesn't follow it, a pipe is never waited on, and only a regular file of at most 4 MiB is
|
|
5
|
+
* read; a file that grew past 4 MiB since it was measured is refused.
|
|
6
6
|
* @param path The file's absolute path.
|
|
7
7
|
* @returns A promise that resolves to the image.
|
|
8
8
|
* @throws
|
package/dist/sessions/images.js
CHANGED
|
@@ -6,8 +6,8 @@ import { MAX_ITEM_IMAGE_BYTES } from '../contracts/index.js';
|
|
|
6
6
|
import { imageUnavailable, toItemImage } from './utilities.js';
|
|
7
7
|
/**
|
|
8
8
|
* Reads an image file an item names. A file that is itself a symbolic link is refused, as the
|
|
9
|
-
* open doesn't follow it, a pipe is never waited on, and only a regular file of at most
|
|
10
|
-
* read; a file that grew past
|
|
9
|
+
* open doesn't follow it, a pipe is never waited on, and only a regular file of at most 4 MiB is
|
|
10
|
+
* read; a file that grew past 4 MiB since it was measured is refused.
|
|
11
11
|
* @param path The file's absolute path.
|
|
12
12
|
* @returns A promise that resolves to the image.
|
|
13
13
|
* @throws
|
|
@@ -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,
|
|
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
|
-
|
|
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 =
|
|
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:
|
|
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:
|
|
148
|
+
sha256: provenance.nativeInputSha256,
|
|
147
149
|
})),
|
|
148
150
|
});
|
|
149
151
|
for (const [index, origin] of origins.entries())
|
|
@@ -56,14 +56,14 @@ export declare const describeBase64Image: (data: string) => {
|
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* Refuses an image HQ doesn't return: one the item doesn't hold, one that isn't a recognized
|
|
59
|
-
* image or is over
|
|
59
|
+
* image or is over 4 MiB, a file that is a symbolic link or not a regular file, or a URL.
|
|
60
60
|
* @param cause The failure that made the image unreadable, when there is one.
|
|
61
61
|
* @throws
|
|
62
62
|
* - JG_AGENT_HQ_IMAGE_UNAVAILABLE: The HQ image is unavailable
|
|
63
63
|
*/
|
|
64
64
|
export declare const imageUnavailable: (cause?: unknown) => never;
|
|
65
65
|
/**
|
|
66
|
-
* Returns an image's bytes when they are a recognized image of at most
|
|
66
|
+
* Returns an image's bytes when they are a recognized image of at most 4 MiB.
|
|
67
67
|
* @param bytes The image's bytes.
|
|
68
68
|
* @returns The image, its format set by its first bytes.
|
|
69
69
|
* @throws
|
|
@@ -123,7 +123,7 @@ export const describeBase64Image = (data) => ({
|
|
|
123
123
|
});
|
|
124
124
|
/**
|
|
125
125
|
* Refuses an image HQ doesn't return: one the item doesn't hold, one that isn't a recognized
|
|
126
|
-
* image or is over
|
|
126
|
+
* image or is over 4 MiB, a file that is a symbolic link or not a regular file, or a URL.
|
|
127
127
|
* @param cause The failure that made the image unreadable, when there is one.
|
|
128
128
|
* @throws
|
|
129
129
|
* - JG_AGENT_HQ_IMAGE_UNAVAILABLE: The HQ image is unavailable
|
|
@@ -136,7 +136,7 @@ export const imageUnavailable = (cause) => {
|
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
|
-
* Returns an image's bytes when they are a recognized image of at most
|
|
139
|
+
* Returns an image's bytes when they are a recognized image of at most 4 MiB.
|
|
140
140
|
* @param bytes The image's bytes.
|
|
141
141
|
* @returns The image, its format set by its first bytes.
|
|
142
142
|
* @throws
|
|
@@ -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
|
};
|
package/dist/store/types.d.ts
CHANGED
|
@@ -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<{
|