@faithfulalabi/agent-lens 0.10.0 → 0.11.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.
@@ -197,11 +197,6 @@ CREATE TABLE events (
197
197
  seq INTEGER NOT NULL, -- thread order; deterministic from the file bytes
198
198
  kind TEXT NOT NULL, -- prompt | text | thinking | tool_call
199
199
  -- | error | compaction | unknown
200
- -- MEASURED 2026-09-11 (30,286 events): 'error'
201
- -- has 0 rows, REACHABLE BUT UNOBSERVED — writer
202
- -- pipeline.ts:306, gated on the harness line
203
- -- subtype 'api_error'. Keep the arm; see
204
- -- task 0.12.
205
200
  ts TEXT NOT NULL,
206
201
  request_id TEXT, -- groups the N lines of ONE assistant response
207
202
  -- (1:1 with message.id; 13,629/13,630 lines = 1 block)
@@ -2,7 +2,7 @@ import { asyncAgentLaunch, taskNotification } from '../transcript/agents.js';
2
2
  import { attachmentRecord } from '../transcript/attachments.js';
3
3
  import { contentBlocks, imageCount, resultText } from '../transcript/blocks.js';
4
4
  import { isHumanPrompt, MACHINERY_TAGS } from '../transcript/human.js';
5
- import { foldControlLines, foldSessionEnvelope, permissionDecision, promptGroupId, toolDenialKind, turnDurationMs, } from '../transcript/line.js';
5
+ import { apiErrorText, foldControlLines, foldSessionEnvelope, permissionDecision, promptGroupId, toolDenialKind, turnDurationMs, } from '../transcript/line.js';
6
6
  import { foldRequestGroup, groupByRequestId, modelOfRequestGroup, requestIdOf, } from '../transcript/usage.js';
7
7
  import { joinToolCalls, NO_INPUT, NO_WIRE_INPUT, toolInput, wireInput, } from './tools.js';
8
8
  import { wireInputOf } from '../transcript/wire.js';
@@ -178,7 +178,7 @@ export function runPipeline(lines, ctx) {
178
178
  const blocks = blocksAt[index];
179
179
  const human = humanAt[index];
180
180
  const usage = usageAt.get(index);
181
- const lineText = blocks.length === 0 ? attachmentRecord(line)?.text : undefined;
181
+ const lineText = blocks.length === 0 ? (attachmentRecord(line)?.text ?? apiErrorText(line)) : undefined;
182
182
  let stamped = false;
183
183
  const emit = (block, blockIndex) => {
184
184
  if (block?.kind === 'unknown_block')
@@ -107,6 +107,11 @@ const LINE_TYPES = new Map([
107
107
  'hookAdditionalContext',
108
108
  'pendingBackgroundAgentCount',
109
109
  'pendingWorkflowCount',
110
+ 'error',
111
+ 'maxRetries',
112
+ 'retryAttempt',
113
+ 'retryInMs',
114
+ 'source',
110
115
  ]),
111
116
  },
112
117
  ],
@@ -275,6 +280,33 @@ export function turnDurationMs(line) {
275
280
  ? num(line.raw.durationMs, undefined)
276
281
  : undefined;
277
282
  }
283
+ function phrase(value) {
284
+ let text = str(value, '').trim();
285
+ while (/[.!?:;,]/.test(text.slice(-1)))
286
+ text = text.slice(0, -1).trimEnd();
287
+ return text === '' ? undefined : text;
288
+ }
289
+ export function apiErrorText(line) {
290
+ if (line.kind !== 'system' || line.subtype !== 'api_error')
291
+ return undefined;
292
+ const error = obj(line.raw.error, undefined);
293
+ const cause = phrase(error?.formatted) ?? phrase(error?.message);
294
+ const code = phrase(obj(error?.connection, undefined)?.code);
295
+ const ceiling = num(line.raw.maxRetries, undefined);
296
+ const delayMs = num(line.raw.retryInMs, undefined);
297
+ const retry = [
298
+ num(line.raw.retryAttempt, undefined),
299
+ ceiling === undefined ? undefined : `of ${ceiling}`,
300
+ delayMs === undefined ? undefined : `in ${delayMs} ms`,
301
+ ].filter((part) => part !== undefined);
302
+ const clauses = [];
303
+ const what = cause !== undefined && code !== undefined ? `${cause} (${code})` : (cause ?? code);
304
+ if (what !== undefined)
305
+ clauses.push(`${what}.`);
306
+ if (retry.length > 0)
307
+ clauses.push(`Retry ${retry.join(' ')}.`);
308
+ return clauses.length === 0 ? undefined : clauses.join(' ');
309
+ }
278
310
  const SYNTHETIC_MODEL = '<synthetic>';
279
311
  export function foldSessionEnvelope(lines) {
280
312
  const envelope = {
@@ -1 +1 @@
1
- export const PROJECTOR_VERSION = 16;
1
+ export const PROJECTOR_VERSION = 17;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faithfulalabi/agent-lens",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Local-first agentic tracing platform: inspect everything your agent did in a session.",
5
5
  "type": "module",
6
6
  "license": "MIT",