@zenera/neo 1.3.49 → 1.3.51
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inspect/report.js +10 -0
- package/dist/kernel.js +2 -1
- package/dist/recordedRequest.d.ts +12 -0
- package/dist/recordedRequest.js +73 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from './payload-stores/index.ts';
|
|
|
32
32
|
export * from './payload.ts';
|
|
33
33
|
export * from './project/index.ts';
|
|
34
34
|
export * from './prompt.ts';
|
|
35
|
+
export * from './recordedRequest.ts';
|
|
35
36
|
export * from './runner.ts';
|
|
36
37
|
export * from './services.ts';
|
|
37
38
|
export * from './skill-providers/index.ts';
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./payload-stores/index.js";
|
|
|
32
32
|
export * from "./payload.js";
|
|
33
33
|
export * from "./project/index.js";
|
|
34
34
|
export * from "./prompt.js";
|
|
35
|
+
export * from "./recordedRequest.js";
|
|
35
36
|
export * from "./runner.js";
|
|
36
37
|
export * from "./services.js";
|
|
37
38
|
export * from "./skill-providers/index.js";
|
package/dist/inspect/report.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildMemorySlice } from "../memory/report.js";
|
|
2
2
|
import { collectPayloads } from "../payload.js";
|
|
3
|
+
import { expandRecordedRequest } from "../recordedRequest.js";
|
|
3
4
|
// ---------------------------------------------------------------------------
|
|
4
5
|
// Run inspector — a single HTML file that explains a run
|
|
5
6
|
//
|
|
@@ -37,6 +38,15 @@ export async function buildRunReport(state, payloads, opts = {}) {
|
|
|
37
38
|
const limit = opts.maxBlobBytes ?? MAX_BLOB_BYTES;
|
|
38
39
|
const refs = collectPayloads(state);
|
|
39
40
|
const values = await payloads.getMany(refs);
|
|
41
|
+
// A request recorded as references is shown as the request it stands for.
|
|
42
|
+
for (const node of state.trajectory) {
|
|
43
|
+
if (node.type !== 'llm_call' || !node.request)
|
|
44
|
+
continue;
|
|
45
|
+
const value = values.get(node.request.sha256);
|
|
46
|
+
if (value !== undefined) {
|
|
47
|
+
values.set(node.request.sha256, await expandRecordedRequest(value, node.request.store, payloads));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
40
50
|
const blobs = {};
|
|
41
51
|
const truncated = [];
|
|
42
52
|
const media = [];
|
package/dist/kernel.js
CHANGED
|
@@ -6,6 +6,7 @@ import { renderPreferences } from "./memory/render.js";
|
|
|
6
6
|
import { memoryTools } from "./memory/tools.js";
|
|
7
7
|
import { hash } from "./payload.js";
|
|
8
8
|
import { composePrompt } from "./prompt.js";
|
|
9
|
+
import { putRequest } from "./recordedRequest.js";
|
|
9
10
|
import { allows, lockedSkillTools, renderSkillIndex, renderSkills, skillContentHash, skillTools, } from "./skills.js";
|
|
10
11
|
import { lastOfType, projectMessages, projected, totalUsage, } from "./trajectory.js";
|
|
11
12
|
import { FINAL_OUTPUT_TOOL, FORK_TOOL, addUsage, parseArgs, toContent, zeroUsage, } from "./types.js";
|
|
@@ -448,7 +449,7 @@ export async function applyLlmResponse(state, res, model, env, opts = {}) {
|
|
|
448
449
|
model,
|
|
449
450
|
...(opts.ref ? { ref: opts.ref } : {}),
|
|
450
451
|
requestDigest: opts.digest ?? (opts.request ? requestDigest(opts.request) : ''),
|
|
451
|
-
request: opts.request ? await put(env,
|
|
452
|
+
request: opts.request ? await putRequest((v) => put(env, v), opts.request) : undefined,
|
|
452
453
|
text: await put(env, res.text),
|
|
453
454
|
thinking: res.thinking ? await put(env, res.thinking) : undefined,
|
|
454
455
|
toolCalls,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModelRequest } from './model.ts';
|
|
2
|
+
import type { Payload, PayloadResolver } from './payload.ts';
|
|
3
|
+
export declare const REQUEST_MANIFEST_FORMAT = "refs/1";
|
|
4
|
+
export declare function isRequestManifest(value: string): boolean;
|
|
5
|
+
export declare function putRequest(put: (value: string) => Promise<Payload>, req: ModelRequest): Promise<Payload>;
|
|
6
|
+
export declare function loadRecordedRequest(payloads: PayloadResolver, ref: Payload): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* `value` as `serializeRequest` wrote it: a manifest is rebuilt from its parts
|
|
9
|
+
* (read from `store`), anything else is returned as it is.
|
|
10
|
+
*/
|
|
11
|
+
export declare function expandRecordedRequest(value: string, store: string, payloads: PayloadResolver): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=recordedRequest.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Recorded requests — what an `llm_call` node's `request` points at
|
|
3
|
+
//
|
|
4
|
+
// A request repeats the whole conversation, so storing each one whole makes a
|
|
5
|
+
// session grow with the square of its length. Stored instead as a manifest of
|
|
6
|
+
// references, the system prompt, the tool schemas and every message are blobs
|
|
7
|
+
// of their own, each kept once however many requests send it: a request costs
|
|
8
|
+
// its new messages and a list of addresses. Context that is rewritten before it
|
|
9
|
+
// is sent (compaction, summaries) is just a new message blob.
|
|
10
|
+
//
|
|
11
|
+
// Readers get back exactly the text `serializeRequest` gave, so a request
|
|
12
|
+
// recorded whole (before this format) and one recorded as references read the
|
|
13
|
+
// same.
|
|
14
|
+
// putRequest - stores a request as a manifest, returns its ref
|
|
15
|
+
// loadRecordedRequest - a recorded request's text, from its ref
|
|
16
|
+
// expandRecordedRequest - the same, from the blob already read
|
|
17
|
+
// isRequestManifest - whether a blob is a manifest rather than a request
|
|
18
|
+
// Used by kernel.ts (llm_call nodes) and by everything that shows a request:
|
|
19
|
+
// inspect/report.ts, the server's trace, the CLI's trace and `zen inspect`.
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
export const REQUEST_MANIFEST_FORMAT = 'refs/1';
|
|
22
|
+
// Unambiguous: a request recorded whole is pretty-printed, so it starts `{\n`.
|
|
23
|
+
const MANIFEST_PREFIX = `{"format":"${REQUEST_MANIFEST_FORMAT}"`;
|
|
24
|
+
export function isRequestManifest(value) {
|
|
25
|
+
return value.startsWith(MANIFEST_PREFIX);
|
|
26
|
+
}
|
|
27
|
+
export async function putRequest(put, req) {
|
|
28
|
+
const { signal: _signal, system, messages, tools, toolChoice, ...unrecorded } = req;
|
|
29
|
+
// A field added to ModelRequest has to be recorded here too, or it is lost.
|
|
30
|
+
unrecorded;
|
|
31
|
+
const [systemRef, toolsRef, messageRefs] = await Promise.all([
|
|
32
|
+
system === undefined ? undefined : put(system),
|
|
33
|
+
put(JSON.stringify(tools)),
|
|
34
|
+
Promise.all(messages.map((m) => put(JSON.stringify(m)))),
|
|
35
|
+
]);
|
|
36
|
+
const manifest = {
|
|
37
|
+
format: REQUEST_MANIFEST_FORMAT,
|
|
38
|
+
...(systemRef ? { system: systemRef.sha256 } : {}),
|
|
39
|
+
messages: messageRefs.map((r) => r.sha256),
|
|
40
|
+
tools: toolsRef.sha256,
|
|
41
|
+
...(toolChoice === undefined ? {} : { toolChoice }),
|
|
42
|
+
};
|
|
43
|
+
return put(JSON.stringify(manifest));
|
|
44
|
+
}
|
|
45
|
+
export async function loadRecordedRequest(payloads, ref) {
|
|
46
|
+
return expandRecordedRequest(await payloads.get(ref), ref.store, payloads);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `value` as `serializeRequest` wrote it: a manifest is rebuilt from its parts
|
|
50
|
+
* (read from `store`), anything else is returned as it is.
|
|
51
|
+
*/
|
|
52
|
+
export async function expandRecordedRequest(value, store, payloads) {
|
|
53
|
+
if (!isRequestManifest(value))
|
|
54
|
+
return value;
|
|
55
|
+
const m = JSON.parse(value);
|
|
56
|
+
const addresses = [...(m.system ? [m.system] : []), m.tools, ...m.messages];
|
|
57
|
+
const parts = await payloads.getMany(addresses.map((sha256) => ({ store, sha256, size: 0 })));
|
|
58
|
+
const part = (sha256) => {
|
|
59
|
+
const text = parts.get(sha256);
|
|
60
|
+
if (text === undefined)
|
|
61
|
+
throw new Error(`recorded request part ${sha256} is missing`);
|
|
62
|
+
return text;
|
|
63
|
+
};
|
|
64
|
+
// The order Kernel.buildRequest gives a request, which serializeRequest kept.
|
|
65
|
+
const request = {
|
|
66
|
+
system: m.system ? part(m.system) : undefined,
|
|
67
|
+
messages: m.messages.map((sha) => JSON.parse(part(sha))),
|
|
68
|
+
tools: JSON.parse(part(m.tools)),
|
|
69
|
+
toolChoice: m.toolChoice,
|
|
70
|
+
};
|
|
71
|
+
return JSON.stringify(request, null, 2);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=recordedRequest.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenera/neo",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.51",
|
|
4
4
|
"description": "A multi-agent runtime for Node.js: agents, models, tools, skills, memory and an append-only trajectory.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"prepack": "tsc -b"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@zenera/sandbox": "^1.3.
|
|
65
|
+
"@zenera/sandbox": "^1.3.51",
|
|
66
66
|
"graphology": "^0.26.0",
|
|
67
67
|
"yaml": "^2.9.1",
|
|
68
68
|
"zod": "^4.6.7"
|