@faithfulalabi/agent-lens 0.14.0 → 0.15.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.
@@ -139,7 +139,9 @@ const EVENT_COLUMNS = `id, turn_id, seq, kind, ts, request_id, block_index, name
139
139
  text, text_bytes, output_storage, spill_path, spill_bytes,
140
140
  model, tokens_in, tokens_out, tokens_cache_read, tokens_cache_write, est_cost,
141
141
  child_session_id, agent_type, agent_status, raw_type, raw_subtype, image_count,
142
- json_extract(attrs, '$.renderedRole') AS rendered_role`;
142
+ json_extract(attrs, '$.renderedRole') AS rendered_role,
143
+ json_extract(attrs, '$.permissionSource') AS permission_source,
144
+ json_extract(attrs, '$.permissionReasonType') AS permission_reason_type`;
143
145
  export function buildEventPageSql(session_id, query) {
144
146
  return {
145
147
  sql: `SELECT ${EVENT_COLUMNS} FROM events WHERE session_id = ? AND seq >= ?` +
@@ -272,6 +272,7 @@ CREATE TABLE events (
272
272
  attrs TEXT NOT NULL DEFAULT '{}' -- ALLOWLIST ONLY: attributionSkill,
273
273
  -- attributionAgent, effort, permissionMode,
274
274
  -- compactMetadata, toolDenialKind, renderedRole,
275
+ -- permissionSource, permissionReasonType,
275
276
  -- unknown_fields[]
276
277
  );
277
278
  CREATE UNIQUE INDEX idx_events_session_seq ON events(session_id, seq);
@@ -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 { apiErrorText, foldControlLines, foldSessionEnvelope, permissionDecision, promptGroupId, toolDenialKind, turnDurationMs, } from '../transcript/line.js';
5
+ import { apiErrorText, foldControlLines, foldSessionEnvelope, permissionDecision, permissionGrounds, 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';
@@ -138,6 +138,7 @@ export function runPipeline(lines, ctx) {
138
138
  is_error: block.is_error,
139
139
  denial: toolDenialKind(line),
140
140
  decision: permissionDecision(line),
141
+ grounds: permissionGrounds(line),
141
142
  launch: asyncAgentLaunch(line, output),
142
143
  ts: line.timestamp ?? '',
143
144
  result_offset: line.byte_offset,
@@ -113,6 +113,14 @@ export function joinToolCalls(events, results, notifications, drift) {
113
113
  statedDenial(result.decision) !== (result.denial !== undefined)) {
114
114
  drift.notePermissionDecisionMismatch();
115
115
  }
116
+ const { source, reasonType } = result.grounds;
117
+ if (source !== undefined || reasonType !== undefined) {
118
+ event.attrs = JSON.stringify({
119
+ ...JSON.parse(event.attrs),
120
+ permissionSource: source,
121
+ permissionReasonType: reasonType,
122
+ });
123
+ }
116
124
  if (event.name === 'Agent' && result.launch !== undefined) {
117
125
  backPatch(event, answers.get(event.id));
118
126
  continue;
@@ -308,6 +308,13 @@ export function permissionDecision(line) {
308
308
  return undefined;
309
309
  return str(obj(line.raw.permissionDecision, undefined)?.decision, '');
310
310
  }
311
+ export function permissionGrounds(line) {
312
+ const stated = obj(line.raw.permissionDecision, undefined);
313
+ return {
314
+ source: str(stated?.source, '') || undefined,
315
+ reasonType: str(stated?.reasonType, '') || undefined,
316
+ };
317
+ }
311
318
  export function turnDurationMs(line) {
312
319
  return line.kind === 'system' && line.subtype === 'turn_duration'
313
320
  ? num(line.raw.durationMs, undefined)
@@ -1 +1 @@
1
- export const PROJECTOR_VERSION = 19;
1
+ export const PROJECTOR_VERSION = 20;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faithfulalabi/agent-lens",
3
- "version": "0.14.0",
3
+ "version": "0.15.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",