@tangle-network/agent-eval 2.0.13 → 2.0.15

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/cli.js CHANGED
@@ -8,7 +8,7 @@ import { l as SEARCH_LEDGER_BATCH_MAX_BYTES, m as SearchRunKindSchema, r as ship
8
8
  import { n as createChatClient } from "./chat-client-TkNgQDLj.js";
9
9
  import { a as privacyHit, f as appendRolloutLines, n as runRolloutReleaseCli, r as PRIVACY_RULE_NAMES, u as gateReceiptRolloutLines } from "./hf-dataset-B0s2ZAhQ.js";
10
10
  import { i as harnessSessionRolloutLines, n as harnessSessionRefs } from "./harness-session-lines-CTh1-uOb.js";
11
- import { B as renderSkillUsageTable, H as claudeCodeSkillSessions, L as afterInvocation, R as buildSkillUsageReport, V as codexSkillSessions, W as readSkillFile, t as runAnalystBenchmarkCommand, z as instant } from "./benchmark-command-C7ObyGm9.js";
11
+ import { B as renderSkillUsageTable, H as claudeCodeSkillSessions, J as withChangeLedger, L as afterInvocation, R as buildSkillUsageReport, V as codexSkillSessions, W as readSkillFile, q as readChangeLedger, t as runAnalystBenchmarkCommand, z as instant } from "./benchmark-command-DgR1i30h.js";
12
12
  import { i as buildOpenApi, l as handleVersion, o as runRpcBatch, r as startServerAsync, s as runRpcOnce } from "./server-B-7vXS9T.js";
13
13
  import { b as editCreditText, f as landscape, g as surfaceTextEdits, l as metaSearch, m as formatLandscape, n as taskMatrix, o as skillManifold, r as formatSkillManifold, s as renderMetaSearchText, t as tree, v as front, y as editCredit } from "./tree-CljLPWVm.js";
14
14
  import { a as analyzeSupervisorRun, i as renderSupervisorRunMarkdown, r as renderSupervisorRunHeadline, t as runtimeRunRolloutLines } from "./runtime-rollouts-CE0MbQPq.js";
@@ -17,256 +17,6 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
17
17
  import { dirname, join, resolve } from "node:path";
18
18
  import { fileURLToPath, pathToFileURL } from "node:url";
19
19
  import { appendFile, open, readFile, rm, stat } from "node:fs/promises";
20
- // src/skill-usage/change-ledger.ts
21
- /**
22
- * The change ledger: one row per commit or pull request a session made, written
23
- * by the session's own harness at the moment the call returned, and the reader
24
- * that joins those rows to recorded sessions.
25
- *
26
- * A transcript names a pull request only when its output prints the URL, and
27
- * names no commit. The ledger is the harness's own record: each row carries the
28
- * tool call's id, so a change belongs to the typed turn whose span holds the
29
- * call, and the session's own commits and merges are counted, not guessed from
30
- * output text.
31
- *
32
- * Row format (JSON lines, `v` 1; a writer adds no other field the reader needs):
33
- *
34
- * | Field | Meaning |
35
- * |---|---|
36
- * | `at` | ISO time the call returned |
37
- * | `harness` | the harness that wrote it, as the session reader names it (`claude-code`) |
38
- * | `sessionId`, `agentId` | the session; inside a subagent, the subagent's id too (the id its own transcript carries) |
39
- * | `toolUseId` | the id of the tool call that made the change; null when the harness gave none |
40
- * | `action` | `commit`, `pr-create`, `pr-merge`, `observed`, or, from a writer that sees whole turns, `turn` and `push` |
41
- * | `remote` | the repository as `owner/repo` (or `host/path`); null when the writer could not find it |
42
- * | `sha`, `pr` | the commit or the pull request number; null when the call did not name it |
43
- *
44
- * `observed` is written once per session or subagent, at its first call. It says
45
- * the writer was running, which is the only thing that lets "no change rows"
46
- * mean "no change". A session with no row of any action is unknown, never none.
47
- *
48
- * A writer outside the harness, such as a gateway that runs the harness for a
49
- * caller (CLI Bridge), sees turns, not tool calls, and adds fields to its rows:
50
- *
51
- * | Field | Meaning |
52
- * |---|---|
53
- * | `sessionId` | the gateway's session id |
54
- * | `nativeSessionId` | the harness's own session id, the id its transcript carries; rows are keyed by it when present |
55
- * | `turnId`, `runId` | the gateway's turn and run |
56
- * | `turnStartedAt` | ISO time the turn began; with `at`, the window the change was made in |
57
- * | `incomplete` | on a `turn` row: why that turn's change rows may not be all of its changes (a checkout shared with another running turn, an unread pull request list); null when they are |
58
- * | `headBefore`, `head` | on a `turn` row: the working repository's HEAD when the turn began and when it ended |
59
- * | `branch` | on a `push` row: the remote branch the turn pushed |
60
- *
61
- * Such a row has no `toolUseId`. The change belongs to the last tool call of the
62
- * session record whose time lies in [`turnStartedAt`, `at`], so a record with no
63
- * times, or none in the window, leaves the change unplaced. A `turn` row with a
64
- * non-null `incomplete` makes the session's changes unknown, with a gap that says why.
65
- *
66
- * A row's `toolUseId` is the id the harness's hook saw. Where the session record
67
- * holds the call under that id, or names it in `callAliases`, the change belongs
68
- * to the turn that made the call. A row that matches neither makes the whole
69
- * session unknown, with a gap that says so: the change happened, and which turn
70
- * made it cannot be said, so no turn may be called change-free.
71
- */
72
- const CHANGE_LEDGER_ACTIONS = [
73
- "observed",
74
- "commit",
75
- "pr-create",
76
- "pr-merge",
77
- "turn",
78
- "push"
79
- ];
80
- const key = (harness, id) => `${harness}\u0000${id}`;
81
- function parseRow(line) {
82
- let value;
83
- try {
84
- value = JSON.parse(line);
85
- } catch {
86
- return null;
87
- }
88
- if (typeof value !== "object" || value === null) return null;
89
- const row = value;
90
- const text = (field) => {
91
- const raw = row[field];
92
- return typeof raw === "string" && raw !== "" ? raw : null;
93
- };
94
- const optional = (field) => {
95
- const raw = row[field];
96
- if (raw === null || raw === void 0) return null;
97
- return typeof raw === "string" && raw !== "" ? raw : void 0;
98
- };
99
- const action = row.action;
100
- const toolUseId = optional("toolUseId");
101
- const agentId = optional("agentId");
102
- const remote = optional("remote");
103
- const sha = optional("sha");
104
- const nativeSessionId = optional("nativeSessionId");
105
- const turnStartedAt = optional("turnStartedAt");
106
- const incomplete = optional("incomplete");
107
- const pr = row.pr ?? null;
108
- const at = text("at");
109
- const harness = text("harness");
110
- const sessionId = text("sessionId");
111
- if (row.v !== 1 || at === null || harness === null || sessionId === null || !CHANGE_LEDGER_ACTIONS.includes(action) || toolUseId === void 0 || agentId === void 0 || remote === void 0 || sha === void 0 || nativeSessionId === void 0 || turnStartedAt === void 0 || incomplete === void 0 || pr !== null && !(typeof pr === "number" && Number.isInteger(pr) && pr > 0)) return null;
112
- return {
113
- v: 1,
114
- at,
115
- harness,
116
- sessionId,
117
- agentId,
118
- toolUseId,
119
- action,
120
- remote,
121
- sha,
122
- pr,
123
- nativeSessionId,
124
- turnStartedAt,
125
- incomplete
126
- };
127
- }
128
- /** The reference the registry's outcome source names a change by: `owner/repo#123` or `owner/repo@<sha>`. */
129
- function refOf(row) {
130
- if (row.remote === null) return null;
131
- if (row.action === "commit") return row.sha === null ? null : `${row.remote}@${row.sha}`;
132
- if (row.action === "pr-create" || row.action === "pr-merge") return row.pr === null ? null : `${row.remote}#${row.pr}`;
133
- return null;
134
- }
135
- /** Read ledger text. A line that is not a row is counted, not skipped silently, and no row is guessed from it. */
136
- function parseChangeLedger(text) {
137
- const sessions = /* @__PURE__ */ new Map();
138
- let rows = 0;
139
- let malformed = 0;
140
- for (const line of text.split("\n")) {
141
- if (line.trim() === "") continue;
142
- const row = parseRow(line);
143
- if (row === null) {
144
- malformed += 1;
145
- continue;
146
- }
147
- rows += 1;
148
- const id = key(row.harness, row.agentId ?? row.nativeSessionId ?? row.sessionId);
149
- let session = sessions.get(id);
150
- if (session === void 0) {
151
- session = {
152
- observed: false,
153
- changes: [],
154
- unnamed: 0,
155
- timed: [],
156
- incomplete: /* @__PURE__ */ new Map()
157
- };
158
- sessions.set(id, session);
159
- }
160
- if (row.action === "observed" || row.action === "push") {
161
- session.observed = true;
162
- continue;
163
- }
164
- if (row.action === "turn") {
165
- session.observed = true;
166
- if (row.incomplete) session.incomplete.set(row.incomplete, (session.incomplete.get(row.incomplete) ?? 0) + 1);
167
- continue;
168
- }
169
- session.observed = true;
170
- const ref = refOf(row);
171
- if (ref === null) session.unnamed += 1;
172
- else if (row.toolUseId === null && row.turnStartedAt) session.timed.push({
173
- ref,
174
- from: row.turnStartedAt,
175
- to: row.at
176
- });
177
- else session.changes.push({
178
- ref,
179
- callId: row.toolUseId ?? "",
180
- at: row.at
181
- });
182
- }
183
- return {
184
- sessions,
185
- rows,
186
- malformed
187
- };
188
- }
189
- /** Read one or more ledger files as one ledger. A file that cannot be read throws: a missing ledger is not an empty one. */
190
- async function readChangeLedger(paths) {
191
- const texts = [];
192
- for (const path of paths) try {
193
- texts.push(await readFile(path, "utf8"));
194
- } catch (error) {
195
- throw new ValidationError(`readChangeLedger: cannot read ${path}: ${errorMessage(error)}`);
196
- }
197
- return parseChangeLedger(texts.join("\n"));
198
- }
199
- /** The last tool call or skill call of the record whose time lies in [from, to]; null when there is none. */
200
- function callInWindow(record, from, to) {
201
- const start = Date.parse(from);
202
- const end = Date.parse(to);
203
- if (!Number.isFinite(start) || !Number.isFinite(end)) return null;
204
- let found = null;
205
- for (const event of record.events) {
206
- if (event.kind === "model" || event.at === null) continue;
207
- const at = Date.parse(event.at);
208
- if (at >= start && at <= end) found = event.kind === "tool" ? event.id : event.callId;
209
- }
210
- return found;
211
- }
212
- function joinRead(read, ledger) {
213
- if (!read.succeeded) return read;
214
- const { value } = read;
215
- const held = ledger.sessions.get(key(value.harness, value.sessionId));
216
- const seen = /* @__PURE__ */ new Set();
217
- const changes = [];
218
- const aliases = value.callAliases ?? {};
219
- const placeable = new Set(value.events.flatMap((event) => event.kind === "tool" ? [event.id] : event.kind === "skill" ? [event.callId] : []));
220
- let unplaced = 0;
221
- const timed = [];
222
- for (const change of held?.timed ?? []) {
223
- const callId = callInWindow(value, change.from, change.to);
224
- if (callId === null) unplaced += 1;
225
- else timed.push({
226
- ref: change.ref,
227
- callId,
228
- at: change.to
229
- });
230
- }
231
- for (const row of [
232
- ...value.changes ?? [],
233
- ...held?.changes ?? [],
234
- ...timed
235
- ]) {
236
- const change = Object.hasOwn(aliases, row.callId) ? {
237
- ...row,
238
- callId: aliases[row.callId]
239
- } : row;
240
- if (!placeable.has(change.callId)) unplaced += 1;
241
- const id = `${change.ref}\u0000${change.callId}`;
242
- if (seen.has(id)) continue;
243
- seen.add(id);
244
- changes.push(change);
245
- }
246
- const gaps = [...value.gaps];
247
- if (held !== void 0 && held.unnamed > 0) gaps.push(`${held.unnamed} changes the change ledger recorded could not be named (no repository, or no commit or pull request number)`);
248
- if (unplaced > 0) gaps.push(`${unplaced} changes name a tool call this session record does not hold, so the turn that made them is unknown and no turn is reported as having made none`);
249
- const { changes: _transcriptChanges, ...rest } = value;
250
- const incomplete = [...held?.incomplete ?? []];
251
- if (incomplete.length > 0) gaps.push(`the change ledger's writer said some turns' changes may be incomplete (${incomplete.map(([why, n]) => `${why}: ${n}`).join(", ")}), so the session's changes are unknown`);
252
- const known = unplaced === 0 && incomplete.length === 0 && (held?.observed === true || changes.length > 0);
253
- return {
254
- ...read,
255
- value: {
256
- ...rest,
257
- gaps,
258
- ...known ? { changes } : {}
259
- }
260
- };
261
- }
262
- /**
263
- * The sessions of `source` with their changes taken from the ledger as well as
264
- * from the transcript. A session the ledger never observed keeps only the
265
- * changes its transcript shows, and has none recorded when it shows none.
266
- */
267
- async function* withChangeLedger(source, ledger) {
268
- for await (const read of source) yield joinRead(read, ledger);
269
- }
270
20
  // src/cli-config.ts
271
21
  /**
272
22
  * Provider configuration for the `agent-eval` binary.