@faithfulalabi/agent-lens 0.7.1 → 0.9.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/dist/src/content/resolve.js +44 -5
- package/dist/src/project/pipeline.js +1 -2
- package/dist/src/server/api.js +6 -0
- package/dist/src/server/start.js +2 -1
- package/dist/src/transcript/version.js +1 -1
- package/package.json +1 -1
- package/ui/dist/assets/index-Dt-L4gyy.js +254 -0
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/index-BGFMl-Rd.js +0 -254
|
@@ -8,7 +8,7 @@ import { classifyLine } from '../transcript/line.js';
|
|
|
8
8
|
function byteLength(text) {
|
|
9
9
|
return Buffer.byteLength(text, 'utf8');
|
|
10
10
|
}
|
|
11
|
-
function lineAt(env, archivePath, byteOffset, len) {
|
|
11
|
+
function lineAt(env, archivePath, byteOffset, len, drift) {
|
|
12
12
|
let bytes;
|
|
13
13
|
try {
|
|
14
14
|
bytes = env.reader.read(archivePath, byteOffset, len);
|
|
@@ -22,7 +22,7 @@ function lineAt(env, archivePath, byteOffset, len) {
|
|
|
22
22
|
return classifyLine(JSON.parse(bytes.toString('utf8')), {
|
|
23
23
|
byteOffset,
|
|
24
24
|
byteLength: len,
|
|
25
|
-
drift
|
|
25
|
+
drift,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
catch {
|
|
@@ -30,8 +30,42 @@ function lineAt(env, archivePath, byteOffset, len) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function blockAt(env, archivePath, byteOffset, len, blockIndex) {
|
|
33
|
-
const line = lineAt(env, archivePath, byteOffset, len);
|
|
34
|
-
|
|
33
|
+
const line = lineAt(env, archivePath, byteOffset, len, new DriftCounter());
|
|
34
|
+
if (line === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
try {
|
|
37
|
+
return contentBlocks(line)[blockIndex];
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function unrecognisedFieldsAt(env, archivePath, byteOffset, len, tag) {
|
|
44
|
+
const drift = new DriftCounter();
|
|
45
|
+
const line = lineAt(env, archivePath, byteOffset, len, drift);
|
|
46
|
+
if (line === undefined)
|
|
47
|
+
return [];
|
|
48
|
+
try {
|
|
49
|
+
const counted = JSON.parse(drift.serialize()).unknown_top_level_fields;
|
|
50
|
+
if (typeof counted !== 'object' || counted === null)
|
|
51
|
+
return [];
|
|
52
|
+
const names = new Set(Object.keys(counted));
|
|
53
|
+
return Object.entries(line.raw)
|
|
54
|
+
.filter(([name]) => names.has(name))
|
|
55
|
+
.map(([name, value]) => ({ line: tag, name, value: JSON.stringify(value) }));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function resolveUnrecognisedFields(row, archivePath, env) {
|
|
62
|
+
if (archivePath === undefined)
|
|
63
|
+
return [];
|
|
64
|
+
const own = unrecognisedFieldsAt(env, archivePath, row.src_offset, row.src_len, 'emitting');
|
|
65
|
+
const { result_offset, result_len } = row;
|
|
66
|
+
if (result_offset === null || result_len === null)
|
|
67
|
+
return own;
|
|
68
|
+
return [...own, ...unrecognisedFieldsAt(env, archivePath, result_offset, result_len, 'result')];
|
|
35
69
|
}
|
|
36
70
|
function stored(row, field) {
|
|
37
71
|
const text = (field === 'text' ? row.text : row.input) ?? '';
|
|
@@ -164,7 +198,9 @@ export function resolveImage(row, ordinal, archivePath, env) {
|
|
|
164
198
|
return { ok: false, reason: 'gone' };
|
|
165
199
|
if (at.len > IMAGE_LINE_MAX)
|
|
166
200
|
return { ok: false, reason: 'too_large' };
|
|
167
|
-
const line = archivePath === undefined
|
|
201
|
+
const line = archivePath === undefined
|
|
202
|
+
? undefined
|
|
203
|
+
: lineAt(env, archivePath, at.offset, at.len, new DriftCounter());
|
|
168
204
|
const source = line === undefined ? undefined : imageSourceAt(line, at.block, ordinal);
|
|
169
205
|
if (source === undefined)
|
|
170
206
|
return { ok: false, reason: 'gone' };
|
|
@@ -185,6 +221,9 @@ export function createContentEnv(reader, roots) {
|
|
|
185
221
|
export function createContentResolver(archivePathOf, env) {
|
|
186
222
|
return (row, field) => resolveContent(row, field, archivePathOf(row.session_id), env);
|
|
187
223
|
}
|
|
224
|
+
export function createUnrecognisedFieldsResolver(archivePathOf, env) {
|
|
225
|
+
return (row) => resolveUnrecognisedFields(row, archivePathOf(row.session_id), env);
|
|
226
|
+
}
|
|
188
227
|
export function createSpillLocator(archivePathOf, env) {
|
|
189
228
|
return (row) => spillSource(row, archivePathOf(row.session_id), env);
|
|
190
229
|
}
|
|
@@ -51,14 +51,13 @@ function blockText(block) {
|
|
|
51
51
|
function eventKind(line, block, human) {
|
|
52
52
|
switch (block?.kind) {
|
|
53
53
|
case 'text':
|
|
54
|
+
case 'image':
|
|
54
55
|
return human ? 'prompt' : 'text';
|
|
55
56
|
case 'thinking':
|
|
56
57
|
case 'thinking_elided':
|
|
57
58
|
return 'thinking';
|
|
58
59
|
case 'tool_use':
|
|
59
60
|
return 'tool_call';
|
|
60
|
-
case 'image':
|
|
61
|
-
return 'text';
|
|
62
61
|
}
|
|
63
62
|
if (line.kind === 'system') {
|
|
64
63
|
if (line.subtype === 'compact_boundary')
|
package/dist/src/server/api.js
CHANGED
|
@@ -276,4 +276,10 @@ export function registerApi(app, deps) {
|
|
|
276
276
|
schema_version: readMeta(db, 'schema_version') ?? null,
|
|
277
277
|
projector_version: readMeta(db, 'projector_version') ?? null,
|
|
278
278
|
}));
|
|
279
|
+
app.get('/api/events/:id/unrecognised-fields', (c) => {
|
|
280
|
+
const row = readEventContentRow(db, c.req.param('id'));
|
|
281
|
+
if (row === undefined)
|
|
282
|
+
return jsonNotFound(c);
|
|
283
|
+
return c.json({ id: row.id, fields: deps.resolveUnrecognisedFields?.(row) ?? [] });
|
|
284
|
+
});
|
|
279
285
|
}
|
package/dist/src/server/start.js
CHANGED
|
@@ -5,7 +5,7 @@ import { mkdirSync } from 'node:fs';
|
|
|
5
5
|
import { readOrCreateToken } from '../shared/index.js';
|
|
6
6
|
import { resolveArchiveRoot, resolveTranscriptRoot } from '../archive/index.js';
|
|
7
7
|
import { createArchiveReader } from '../archive/read.js';
|
|
8
|
-
import { createContentEnv, createContentResolver, createImageResolver, } from '../content/resolve.js';
|
|
8
|
+
import { createContentEnv, createContentResolver, createImageResolver, createUnrecognisedFieldsResolver, } from '../content/resolve.js';
|
|
9
9
|
import { createCorpusSweep } from '../corpus/watch.js';
|
|
10
10
|
import { createProjectionEnv } from '../corpus/env.js';
|
|
11
11
|
import { openDb } from '../db/open.js';
|
|
@@ -77,6 +77,7 @@ export async function startServer(options = {}) {
|
|
|
77
77
|
warm,
|
|
78
78
|
resolveContent: createContentResolver(archivePathOf, contentEnv),
|
|
79
79
|
resolveImage: createImageResolver(archivePathOf, contentEnv),
|
|
80
|
+
resolveUnrecognisedFields: createUnrecognisedFieldsResolver(archivePathOf, contentEnv),
|
|
80
81
|
});
|
|
81
82
|
const fetch = app.fetch;
|
|
82
83
|
const explicit = options.port !== undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PROJECTOR_VERSION =
|
|
1
|
+
export const PROJECTOR_VERSION = 16;
|