@agent-inspect/adapter-sdk 2.6.0 → 3.1.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/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var persisted = require('agent-inspect/persisted');
4
4
  var readers = require('agent-inspect/readers');
5
+ var advanced = require('agent-inspect/advanced');
5
6
 
6
7
  // packages/adapter-sdk/src/registration.ts
7
8
  var registry = /* @__PURE__ */ new Map();
@@ -241,20 +242,169 @@ function findPairedLifecycle(events, kind, terminalStatus = "ok") {
241
242
  return { started: startedById, completed: completedById };
242
243
  }
243
244
 
245
+ // packages/adapter-sdk/src/transform.ts
246
+ function defineTransform(transform) {
247
+ if (!transform.id.trim()) throw new Error("transform id is required");
248
+ return transform;
249
+ }
250
+ function runTransformPipeline(input, transforms, options = {}) {
251
+ let events = [...input];
252
+ const warnings = [];
253
+ for (const transform of transforms) {
254
+ const result = transform.transform(events, options);
255
+ events = result.events;
256
+ warnings.push(...result.warnings);
257
+ }
258
+ return { events, warnings };
259
+ }
260
+ function createKindFilterTransform(kinds) {
261
+ const allowed = new Set(kinds);
262
+ return defineTransform({
263
+ id: `filter-kinds:${[...kinds].sort().join(",")}`,
264
+ transform(input) {
265
+ const filtered = input.filter(
266
+ (event) => allowed.has(event.kind) || event.kind === "RUN"
267
+ );
268
+ const removed = input.length - filtered.length;
269
+ return {
270
+ events: filtered,
271
+ warnings: removed > 0 ? [
272
+ {
273
+ code: "transform.filter.removed",
274
+ message: `removed ${removed} events outside allowed kinds`,
275
+ severity: "warning"
276
+ }
277
+ ] : []
278
+ };
279
+ }
280
+ });
281
+ }
282
+
283
+ // packages/adapter-sdk/src/renderer.ts
284
+ function defineRenderer(renderer) {
285
+ if (!renderer.format.trim()) throw new Error("renderer format is required");
286
+ return renderer;
287
+ }
288
+ function renderWithSafety(renderer, tree, options = {}) {
289
+ const rendered = renderer.render(tree, options);
290
+ const warnings = [...rendered.warnings];
291
+ const maxLen = options.maxContentLength ?? 5e5;
292
+ if (rendered.content.length > maxLen) {
293
+ warnings.push(
294
+ `renderer.truncated: content exceeded maxContentLength (${maxLen}); output truncated`
295
+ );
296
+ return {
297
+ content: rendered.content.slice(0, maxLen),
298
+ contentType: rendered.contentType,
299
+ warnings
300
+ };
301
+ }
302
+ if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {
303
+ for (const raw of options.forbiddenRawStrings) {
304
+ if (rendered.content.includes(raw)) {
305
+ warnings.push(
306
+ `renderer.forbidden-leak: output contains forbidden substring (${raw.length} chars)`
307
+ );
308
+ }
309
+ }
310
+ }
311
+ if (options.redactionProfile === "share" || options.redactionProfile === "strict") {
312
+ warnings.push(
313
+ `renderer.redaction-profile:${options.redactionProfile} \u2014 verify output before sharing`
314
+ );
315
+ }
316
+ return {
317
+ content: rendered.content,
318
+ contentType: rendered.contentType,
319
+ warnings
320
+ };
321
+ }
322
+ function defineIndexer(indexer) {
323
+ if (!indexer.id.trim()) throw new Error("indexer id is required");
324
+ return indexer;
325
+ }
326
+ function shouldInvalidateIndex(snapshot, options = {}) {
327
+ if (!options.invalidateBefore) return false;
328
+ const cutoff = Date.parse(options.invalidateBefore);
329
+ const builtAt = Date.parse(snapshot.builtAt);
330
+ if (Number.isNaN(cutoff) || Number.isNaN(builtAt)) return true;
331
+ return builtAt < cutoff;
332
+ }
333
+ async function indexIsStale(snapshot, traceDir) {
334
+ const builtMs = Date.parse(snapshot.builtAt);
335
+ if (Number.isNaN(builtMs)) return true;
336
+ const td = new advanced.TraceDirectory({ dir: traceDir });
337
+ const files = await td.list();
338
+ for (const file of files) {
339
+ const stats = await td.getFileStats(file);
340
+ if (stats.mtimeMs > builtMs) return true;
341
+ }
342
+ return false;
343
+ }
344
+ function createTraceDirectoryIndexer() {
345
+ return defineIndexer({
346
+ id: "trace-directory-metadata",
347
+ async rebuild(traceDir, options = {}) {
348
+ const warnings = [];
349
+ const td = new advanced.TraceDirectory({ dir: traceDir });
350
+ const files = await td.list();
351
+ const maxEntries = options.maxEntries ?? 1e4;
352
+ if (files.length > maxEntries) {
353
+ warnings.push(
354
+ `indexer.truncated: trace directory has ${files.length} files; indexing first ${maxEntries}`
355
+ );
356
+ }
357
+ const slice = files.slice(0, maxEntries);
358
+ const metas = await advanced.loadTraceMetadataList(
359
+ traceDir,
360
+ slice,
361
+ (fileName) => td.getPath(fileName)
362
+ );
363
+ const entries = metas.map((meta) => ({
364
+ runId: meta.runId,
365
+ path: meta.filePath,
366
+ name: meta.name,
367
+ startedAt: meta.startedAt,
368
+ status: meta.status
369
+ })).sort((a, b) => a.runId.localeCompare(b.runId));
370
+ if (entries.length < slice.length) {
371
+ warnings.push(
372
+ `indexer.partial: indexed ${entries.length} of ${slice.length} trace files`
373
+ );
374
+ }
375
+ return {
376
+ traceDir,
377
+ builtAt: (/* @__PURE__ */ new Date()).toISOString(),
378
+ entries,
379
+ warnings
380
+ };
381
+ }
382
+ });
383
+ }
384
+
244
385
  exports.PRIVACY_CHECKLIST_ITEMS = PRIVACY_CHECKLIST_ITEMS;
245
386
  exports.clearAdapterRegistry = clearAdapterRegistry;
246
387
  exports.createAdapterFixtureSkeleton = createAdapterFixtureSkeleton;
247
388
  exports.createAdapterRegistration = createAdapterRegistration;
248
389
  exports.createConformanceFixtureMeta = createConformanceFixtureMeta;
390
+ exports.createKindFilterTransform = createKindFilterTransform;
391
+ exports.createTraceDirectoryIndexer = createTraceDirectoryIndexer;
392
+ exports.defineIndexer = defineIndexer;
393
+ exports.defineRenderer = defineRenderer;
394
+ exports.defineTransform = defineTransform;
249
395
  exports.eventsToJsonl = eventsToJsonl;
250
396
  exports.extractPersistedKinds = extractPersistedKinds;
251
397
  exports.findPairedLifecycle = findPairedLifecycle;
252
398
  exports.flattenInspectNodes = flattenInspectNodes;
253
399
  exports.getRegisteredAdapter = getRegisteredAdapter;
400
+ exports.indexIsStale = indexIsStale;
254
401
  exports.listRegisteredAdapters = listRegisteredAdapters;
255
402
  exports.registerAdapter = registerAdapter;
403
+ exports.renderWithSafety = renderWithSafety;
256
404
  exports.runAdapterConformance = runAdapterConformance;
257
405
  exports.runPrivacyChecklist = runPrivacyChecklist;
406
+ exports.runTransformPipeline = runTransformPipeline;
407
+ exports.shouldInvalidateIndex = shouldInvalidateIndex;
258
408
  exports.stableStringify = stableStringify;
259
409
  //# sourceMappingURL=index.cjs.map
260
410
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/registration.ts","../src/mapping.ts","../src/fixtures.ts","../src/privacy.ts","../src/conformance.ts"],"names":["persistedInspectEventsToRunTrees","persistedInspectEventsToTraceEvents","readTrace","openTrace"],"mappings":";;;;;;AAEA,IAAM,QAAA,uBAAe,GAAA,EAAiC;AAE/C,SAAS,0BACd,KAAA,EACqB;AACrB,EAAA,IAAI,CAAC,MAAM,EAAA,CAAG,IAAA,IAAQ,MAAM,IAAI,MAAM,wBAAwB,CAAA;AAC9D,EAAA,IAAI,CAAC,MAAM,IAAA,CAAK,IAAA,IAAQ,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAClE,EAAA,IAAI,CAAC,MAAM,OAAA,CAAQ,IAAA,IAAQ,MAAM,IAAI,MAAM,6BAA6B,CAAA;AACxE,EAAA,IAAI,CAAC,MAAM,SAAA,CAAU,IAAA,IAAQ,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAC5E,EAAA,OAAO,EAAE,GAAG,KAAA,EAAM;AACpB;AAEO,SAAS,gBAAgB,YAAA,EAAwD;AACtF,EAAA,MAAM,UAAA,GAAa,0BAA0B,YAAY,CAAA;AACzD,EAAA,QAAA,CAAS,GAAA,CAAI,UAAA,CAAW,EAAA,EAAI,UAAU,CAAA;AACtC,EAAA,OAAO,UAAA;AACT;AAEO,SAAS,qBAAqB,EAAA,EAA6C;AAChF,EAAA,OAAO,QAAA,CAAS,IAAI,EAAE,CAAA;AACxB;AAEO,SAAS,sBAAA,GAAyD;AACvE,EAAA,OAAO,CAAC,G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,IACA;AAAA,GACF;AACF;AAEO,SAAS,mBAAA,CACd,MAAA,EACA,IAAA,EACA,cAAA,GAAiC,IAAA,EACuC;AACxE,EAAA,MAAM,SAAS,MAAA,CAAO,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,SAAS,IAAI,CAAA;AAC3D,EAAA,MAAM,UAAU,MAAA,CAAO,IAAA,CAAK,CAAC,KAAA,KAAU,KAAA,CAAM,WAAW,SAAS,CAAA;AACjE,EAAA,MAAM,YAAY,MAAA,CAAO,IAAA;AAAA,IACvB,CAAC,KAAA,KAAU,KAAA,CAAM,MAAA,KAAW,cAAA,IAAkB,MAAM,MAAA,KAAW;AAAA,GACjE;AACA,EAAA,IAAI,OAAA,KAAY,MAAA,IAAa,SAAA,KAAc,MAAA,EAAW;AACpD,IAAA,OAAO,EAAE,SAAS,SAAA,EAAU;AAAA,EAC9B;AACA,EAAA,MAAM,aAAA,GAAgB,SAAA;AACtB,EAAA,MAAM,cAAc,MAAA,CAAO,IAAA;AAAA,IACzB,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,aAAA,CAAc,OAAA,IAAW,MAAM,MAAA,KAAW;AAAA,GACzE;AACA,EAAA,OAAO,EAAE,OAAA,EAAS,WAAA,EAAa,SAAA,EAAW,aAAA,EAAc;AAC1D","file":"index.cjs","sourcesContent":["import type { AdapterRegistration } from \"./types.js\";\n\nconst registry = new Map<string, AdapterRegistration>();\n\nexport function createAdapterRegistration(\n input: AdapterRegistration,\n): AdapterRegistration {\n if (!input.id.trim()) throw new Error(\"adapter id is required\");\n if (!input.name.trim()) throw new Error(\"adapter name is required\");\n if (!input.version.trim()) throw new Error(\"adapter version is required\");\n if (!input.framework.trim()) throw new Error(\"adapter framework is required\");\n return { ...input };\n}\n\nexport function registerAdapter(registration: AdapterRegistration): AdapterRegistration {\n const normalized = createAdapterRegistration(registration);\n registry.set(normalized.id, normalized);\n return normalized;\n}\n\nexport function getRegisteredAdapter(id: string): AdapterRegistration | undefined {\n return registry.get(id);\n}\n\nexport function listRegisteredAdapters(): readonly AdapterRegistration[] {\n return [...registry.values()].sort((a, b) => a.id.localeCompare(b.id));\n}\n\nexport function clearAdapterRegistry(): void {\n registry.clear();\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\n\nexport interface InspectNodeLike {\n event: { kind: string };\n children: InspectNodeLike[];\n}\n\nexport function eventsToJsonl(events: readonly unknown[]): string {\n return `${events.map((event) => JSON.stringify(event)).join(\"\\n\")}\\n`;\n}\n\nexport function flattenInspectNodes(nodes: readonly InspectNodeLike[]): InspectNodeLike[] {\n return nodes.flatMap((node) => [node, ...flattenInspectNodes(node.children)]);\n}\n\nexport function extractPersistedKinds(\n events: readonly PersistedInspectEvent[],\n): PersistedInspectEvent[\"kind\"][] {\n return events.map((event) => event.kind);\n}\n\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortJson(value)) ?? \"null\";\n}\n\nfunction sortJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => sortJson(item));\n }\n if (isPlainRecord(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = sortJson(value[key]);\n }\n return sorted;\n }\n return value === undefined ? null : value;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import type { AdapterFixtureSkeleton } from \"./types.js\";\n\nconst DEFAULT_COVERS = [\n \"run\",\n \"step\",\n \"tool\",\n \"llm\",\n \"error\",\n \"streaming\",\n \"metadata-bounds\",\n] as const;\n\nexport function createAdapterFixtureSkeleton(adapterId: string): AdapterFixtureSkeleton {\n return {\n adapterId,\n captureDefault: \"metadata-only\",\n network: \"none\",\n suggestedCovers: [...DEFAULT_COVERS],\n notes: [\n \"Use local mocks only; no provider API keys or network calls.\",\n \"Persist metadata-only by default; opt into preview/full capture explicitly.\",\n \"Include forbidden raw strings in conformance tests when prompts are mocked.\",\n \"Run runAdapterConformance against captured PersistedInspectEvent arrays.\",\n ],\n };\n}\n\nexport function createConformanceFixtureMeta(adapterId: string) {\n return {\n adapterId,\n defaults: {\n network: \"none\",\n upload: \"none\",\n capture: \"metadata-only\",\n },\n skeleton: createAdapterFixtureSkeleton(adapterId),\n };\n}\n","import type {\n ConformanceCheck,\n PrivacyChecklistInput,\n PrivacyChecklistItem,\n PrivacyChecklistResult,\n} from \"./types.js\";\n\nexport const PRIVACY_CHECKLIST_ITEMS: readonly PrivacyChecklistItem[] = [\n {\n id: \"capture-metadata-only-default\",\n label: \"Default capture is metadata-only (no full prompts/outputs on disk)\",\n required: true,\n },\n {\n id: \"no-network-by-default\",\n label: \"Adapter tests and defaults do not call external networks\",\n required: true,\n },\n {\n id: \"no-upload\",\n label: \"Adapter does not upload traces or logs to vendors by default\",\n required: true,\n },\n {\n id: \"redaction-documented\",\n label: \"Redaction/capture modes are documented for adapter users\",\n required: true,\n },\n {\n id: \"framework-deps-scoped\",\n label: \"Framework SDK dependencies stay in the optional adapter package\",\n required: true,\n },\n] as const;\n\nexport function runPrivacyChecklist(input: PrivacyChecklistInput = {}): PrivacyChecklistResult {\n const captureMode = input.captureMode ?? \"metadata-only\";\n const items: ConformanceCheck[] = [\n {\n id: \"capture-metadata-only-default\",\n ok: captureMode === \"metadata-only\",\n detail:\n captureMode === \"metadata-only\"\n ? undefined\n : `captureMode is ${captureMode}; metadata-only is required by default`,\n },\n {\n id: \"no-network-by-default\",\n ok: input.networkAllowed !== true,\n detail: input.networkAllowed ? \"network must be disabled in adapter defaults\" : undefined,\n },\n {\n id: \"no-upload\",\n ok: input.uploadAllowed !== true,\n detail: input.uploadAllowed ? \"upload must not be enabled by default\" : undefined,\n },\n {\n id: \"redaction-documented\",\n ok: input.redactionDocumented !== false,\n detail:\n input.redactionDocumented === false\n ? \"document capture/redaction behavior in adapter README\"\n : undefined,\n },\n {\n id: \"framework-deps-scoped\",\n ok: input.frameworkDepsPackageScoped !== false,\n detail:\n input.frameworkDepsPackageScoped === false\n ? \"keep framework SDK deps out of agent-inspect root/core\"\n : undefined,\n },\n ];\n\n const requiredFailed = items.some(\n (item) =>\n PRIVACY_CHECKLIST_ITEMS.find((def) => def.id === item.id)?.required && !item.ok,\n );\n\n return { ok: !requiredFailed, items };\n}\n","import {\n persistedInspectEventsToRunTrees,\n persistedInspectEventsToTraceEvents,\n type PersistedInspectEvent,\n} from \"agent-inspect/persisted\";\nimport { openTrace, readTrace } from \"agent-inspect/readers\";\n\nimport { eventsToJsonl, flattenInspectNodes, stableStringify } from \"./mapping.js\";\nimport type {\n AdapterConformanceOptions,\n AdapterConformanceResult,\n ConformanceCheck,\n} from \"./types.js\";\n\nexport async function runAdapterConformance(\n options: AdapterConformanceOptions,\n): Promise<AdapterConformanceResult> {\n const checks: ConformanceCheck[] = [];\n const { adapterId, events } = options;\n\n checks.push({\n id: \"events-non-empty\",\n ok: events.length > 0,\n detail: events.length > 0 ? undefined : \"expected at least one persisted event\",\n });\n\n const schemaOk = events.every(\n (event) => event.schemaVersion === \"0.2\" || event.schemaVersion === \"1.0\",\n );\n checks.push({\n id: \"schema-persisted\",\n ok: schemaOk,\n detail: schemaOk ? undefined : \"all events must use schemaVersion 0.2 or 1.0\",\n });\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n const serialized = JSON.stringify(events);\n const leaks = options.forbiddenRawStrings.filter((raw) => serialized.includes(raw));\n checks.push({\n id: \"no-forbidden-raw-strings\",\n ok: leaks.length === 0,\n detail:\n leaks.length === 0 ? undefined : `forbidden raw strings leaked: ${leaks.join(\", \")}`,\n });\n }\n\n try {\n const trees = persistedInspectEventsToRunTrees([...events]);\n checks.push({\n id: \"run-tree-built\",\n ok: trees.length > 0,\n detail: trees.length > 0 ? undefined : \"persistedInspectEventsToRunTrees returned no runs\",\n });\n\n if (options.expectedKinds && options.expectedKinds.length > 0 && trees[0]) {\n const kinds = flattenInspectNodes(trees[0].children).map((node) => node.event.kind);\n const kindsOk = stableStringify(kinds) === stableStringify([...options.expectedKinds]);\n checks.push({\n id: \"expected-kinds\",\n ok: kindsOk,\n detail: kindsOk\n ? undefined\n : `expected kinds ${options.expectedKinds.join(\",\")} but got ${kinds.join(\",\")}`,\n });\n }\n\n const normalized = persistedInspectEventsToTraceEvents([...events]);\n checks.push({\n id: \"legacy-normalization\",\n ok: normalized.length > 0,\n detail:\n normalized.length > 0 ? undefined : \"persistedInspectEventsToTraceEvents returned empty\",\n });\n\n const input = { type: \"string\" as const, content: eventsToJsonl(events) };\n const read = await readTrace(input, { format: \"agent-inspect-jsonl\" });\n const opened = await openTrace(input, { format: \"agent-inspect-jsonl\" });\n const roundTripOk = stableStringify(read.runs) === stableStringify(opened.runs);\n checks.push({\n id: \"reader-round-trip\",\n ok: roundTripOk,\n detail: roundTripOk ? undefined : \"readTrace and openTrace runs differ\",\n });\n } catch (error) {\n checks.push({\n id: \"conformance-runtime\",\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n ok: checks.every((check) => check.ok),\n adapterId,\n checks,\n };\n}\n\nexport function findPairedLifecycle(\n events: readonly PersistedInspectEvent[],\n kind: PersistedInspectEvent[\"kind\"],\n terminalStatus: \"ok\" | \"error\" = \"ok\",\n): { started?: PersistedInspectEvent; completed?: PersistedInspectEvent } {\n const ofKind = events.filter((event) => event.kind === kind);\n const started = ofKind.find((event) => event.status === \"running\");\n const completed = ofKind.find(\n (event) => event.status === terminalStatus || event.status === \"error\",\n );\n if (started !== undefined || completed === undefined) {\n return { started, completed };\n }\n const completedById = completed;\n const startedById = ofKind.find(\n (event) => event.eventId === completedById.eventId && event.status === \"running\",\n );\n return { started: startedById, completed: completedById };\n}\n"]}
1
+ {"version":3,"sources":["../src/registration.ts","../src/mapping.ts","../src/fixtures.ts","../src/privacy.ts","../src/conformance.ts","../src/transform.ts","../src/renderer.ts","../src/indexer.ts"],"names":["persistedInspectEventsToRunTrees","persistedInspectEventsToTraceEvents","readTrace","openTrace","TraceDirectory","loadTraceMetadataList"],"mappings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UAAU,CAAA;AACvC,MAAA,MAAM,QAAQ,MAAMC,8BAAA;AAAA,QAAsB,QAAA;AAAA,QAAU,KAAA;AAAA,QAAO,CAAC,QAAA,KAC1D,EAAA,CAAG,OAAA,CAAQ,QAAQ;AAAA,OACrB;AAEA,MAAA,MAAM,OAAA,GAA6B,KAAA,CAChC,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,QACd,OAAO,IAAA,CAAK,KAAA;AAAA,QACZ,MAAM,IAAA,CAAK,QAAA;AAAA,QACX,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,QAAQ,IAAA,CAAK;AAAA,OACf,CAAE,CAAA,CACD,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,KAAA,CAAM,aAAA,CAAc,CAAA,CAAE,KAAK,CAAC,CAAA;AAEhD,MAAA,IAAI,OAAA,CAAQ,MAAA,GAAS,KAAA,CAAM,MAAA,EAAQ;AACjC,QAAA,QAAA,CAAS,IAAA;AAAA,UACP,CAAA,yBAAA,EAA4B,OAAA,CAAQ,MAAM,CAAA,IAAA,EAAO,MAAM,MAAM,CAAA,YAAA;AAAA,SAC/D;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,QAAA;AAAA,QACA,OAAA,EAAA,iBAAS,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,QAChC,OAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { AdapterRegistration } from \"./types.js\";\n\nconst registry = new Map<string, AdapterRegistration>();\n\nexport function createAdapterRegistration(\n input: AdapterRegistration,\n): AdapterRegistration {\n if (!input.id.trim()) throw new Error(\"adapter id is required\");\n if (!input.name.trim()) throw new Error(\"adapter name is required\");\n if (!input.version.trim()) throw new Error(\"adapter version is required\");\n if (!input.framework.trim()) throw new Error(\"adapter framework is required\");\n return { ...input };\n}\n\nexport function registerAdapter(registration: AdapterRegistration): AdapterRegistration {\n const normalized = createAdapterRegistration(registration);\n registry.set(normalized.id, normalized);\n return normalized;\n}\n\nexport function getRegisteredAdapter(id: string): AdapterRegistration | undefined {\n return registry.get(id);\n}\n\nexport function listRegisteredAdapters(): readonly AdapterRegistration[] {\n return [...registry.values()].sort((a, b) => a.id.localeCompare(b.id));\n}\n\nexport function clearAdapterRegistry(): void {\n registry.clear();\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\n\nexport interface InspectNodeLike {\n event: { kind: string };\n children: InspectNodeLike[];\n}\n\nexport function eventsToJsonl(events: readonly unknown[]): string {\n return `${events.map((event) => JSON.stringify(event)).join(\"\\n\")}\\n`;\n}\n\nexport function flattenInspectNodes(nodes: readonly InspectNodeLike[]): InspectNodeLike[] {\n return nodes.flatMap((node) => [node, ...flattenInspectNodes(node.children)]);\n}\n\nexport function extractPersistedKinds(\n events: readonly PersistedInspectEvent[],\n): PersistedInspectEvent[\"kind\"][] {\n return events.map((event) => event.kind);\n}\n\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortJson(value)) ?? \"null\";\n}\n\nfunction sortJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => sortJson(item));\n }\n if (isPlainRecord(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = sortJson(value[key]);\n }\n return sorted;\n }\n return value === undefined ? null : value;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import type { AdapterFixtureSkeleton } from \"./types.js\";\n\nconst DEFAULT_COVERS = [\n \"run\",\n \"step\",\n \"tool\",\n \"llm\",\n \"error\",\n \"streaming\",\n \"metadata-bounds\",\n] as const;\n\nexport function createAdapterFixtureSkeleton(adapterId: string): AdapterFixtureSkeleton {\n return {\n adapterId,\n captureDefault: \"metadata-only\",\n network: \"none\",\n suggestedCovers: [...DEFAULT_COVERS],\n notes: [\n \"Use local mocks only; no provider API keys or network calls.\",\n \"Persist metadata-only by default; opt into preview/full capture explicitly.\",\n \"Include forbidden raw strings in conformance tests when prompts are mocked.\",\n \"Run runAdapterConformance against captured PersistedInspectEvent arrays.\",\n ],\n };\n}\n\nexport function createConformanceFixtureMeta(adapterId: string) {\n return {\n adapterId,\n defaults: {\n network: \"none\",\n upload: \"none\",\n capture: \"metadata-only\",\n },\n skeleton: createAdapterFixtureSkeleton(adapterId),\n };\n}\n","import type {\n ConformanceCheck,\n PrivacyChecklistInput,\n PrivacyChecklistItem,\n PrivacyChecklistResult,\n} from \"./types.js\";\n\nexport const PRIVACY_CHECKLIST_ITEMS: readonly PrivacyChecklistItem[] = [\n {\n id: \"capture-metadata-only-default\",\n label: \"Default capture is metadata-only (no full prompts/outputs on disk)\",\n required: true,\n },\n {\n id: \"no-network-by-default\",\n label: \"Adapter tests and defaults do not call external networks\",\n required: true,\n },\n {\n id: \"no-upload\",\n label: \"Adapter does not upload traces or logs to vendors by default\",\n required: true,\n },\n {\n id: \"redaction-documented\",\n label: \"Redaction/capture modes are documented for adapter users\",\n required: true,\n },\n {\n id: \"framework-deps-scoped\",\n label: \"Framework SDK dependencies stay in the optional adapter package\",\n required: true,\n },\n] as const;\n\nexport function runPrivacyChecklist(input: PrivacyChecklistInput = {}): PrivacyChecklistResult {\n const captureMode = input.captureMode ?? \"metadata-only\";\n const items: ConformanceCheck[] = [\n {\n id: \"capture-metadata-only-default\",\n ok: captureMode === \"metadata-only\",\n detail:\n captureMode === \"metadata-only\"\n ? undefined\n : `captureMode is ${captureMode}; metadata-only is required by default`,\n },\n {\n id: \"no-network-by-default\",\n ok: input.networkAllowed !== true,\n detail: input.networkAllowed ? \"network must be disabled in adapter defaults\" : undefined,\n },\n {\n id: \"no-upload\",\n ok: input.uploadAllowed !== true,\n detail: input.uploadAllowed ? \"upload must not be enabled by default\" : undefined,\n },\n {\n id: \"redaction-documented\",\n ok: input.redactionDocumented !== false,\n detail:\n input.redactionDocumented === false\n ? \"document capture/redaction behavior in adapter README\"\n : undefined,\n },\n {\n id: \"framework-deps-scoped\",\n ok: input.frameworkDepsPackageScoped !== false,\n detail:\n input.frameworkDepsPackageScoped === false\n ? \"keep framework SDK deps out of agent-inspect root/core\"\n : undefined,\n },\n ];\n\n const requiredFailed = items.some(\n (item) =>\n PRIVACY_CHECKLIST_ITEMS.find((def) => def.id === item.id)?.required && !item.ok,\n );\n\n return { ok: !requiredFailed, items };\n}\n","import {\n persistedInspectEventsToRunTrees,\n persistedInspectEventsToTraceEvents,\n type PersistedInspectEvent,\n} from \"agent-inspect/persisted\";\nimport { openTrace, readTrace } from \"agent-inspect/readers\";\n\nimport { eventsToJsonl, flattenInspectNodes, stableStringify } from \"./mapping.js\";\nimport type {\n AdapterConformanceOptions,\n AdapterConformanceResult,\n ConformanceCheck,\n} from \"./types.js\";\n\nexport async function runAdapterConformance(\n options: AdapterConformanceOptions,\n): Promise<AdapterConformanceResult> {\n const checks: ConformanceCheck[] = [];\n const { adapterId, events } = options;\n\n checks.push({\n id: \"events-non-empty\",\n ok: events.length > 0,\n detail: events.length > 0 ? undefined : \"expected at least one persisted event\",\n });\n\n const schemaOk = events.every(\n (event) => event.schemaVersion === \"0.2\" || event.schemaVersion === \"1.0\",\n );\n checks.push({\n id: \"schema-persisted\",\n ok: schemaOk,\n detail: schemaOk ? undefined : \"all events must use schemaVersion 0.2 or 1.0\",\n });\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n const serialized = JSON.stringify(events);\n const leaks = options.forbiddenRawStrings.filter((raw) => serialized.includes(raw));\n checks.push({\n id: \"no-forbidden-raw-strings\",\n ok: leaks.length === 0,\n detail:\n leaks.length === 0 ? undefined : `forbidden raw strings leaked: ${leaks.join(\", \")}`,\n });\n }\n\n try {\n const trees = persistedInspectEventsToRunTrees([...events]);\n checks.push({\n id: \"run-tree-built\",\n ok: trees.length > 0,\n detail: trees.length > 0 ? undefined : \"persistedInspectEventsToRunTrees returned no runs\",\n });\n\n if (options.expectedKinds && options.expectedKinds.length > 0 && trees[0]) {\n const kinds = flattenInspectNodes(trees[0].children).map((node) => node.event.kind);\n const kindsOk = stableStringify(kinds) === stableStringify([...options.expectedKinds]);\n checks.push({\n id: \"expected-kinds\",\n ok: kindsOk,\n detail: kindsOk\n ? undefined\n : `expected kinds ${options.expectedKinds.join(\",\")} but got ${kinds.join(\",\")}`,\n });\n }\n\n const normalized = persistedInspectEventsToTraceEvents([...events]);\n checks.push({\n id: \"legacy-normalization\",\n ok: normalized.length > 0,\n detail:\n normalized.length > 0 ? undefined : \"persistedInspectEventsToTraceEvents returned empty\",\n });\n\n const input = { type: \"string\" as const, content: eventsToJsonl(events) };\n const read = await readTrace(input, { format: \"agent-inspect-jsonl\" });\n const opened = await openTrace(input, { format: \"agent-inspect-jsonl\" });\n const roundTripOk = stableStringify(read.runs) === stableStringify(opened.runs);\n checks.push({\n id: \"reader-round-trip\",\n ok: roundTripOk,\n detail: roundTripOk ? undefined : \"readTrace and openTrace runs differ\",\n });\n } catch (error) {\n checks.push({\n id: \"conformance-runtime\",\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n ok: checks.every((check) => check.ok),\n adapterId,\n checks,\n };\n}\n\nexport function findPairedLifecycle(\n events: readonly PersistedInspectEvent[],\n kind: PersistedInspectEvent[\"kind\"],\n terminalStatus: \"ok\" | \"error\" = \"ok\",\n): { started?: PersistedInspectEvent; completed?: PersistedInspectEvent } {\n const ofKind = events.filter((event) => event.kind === kind);\n const started = ofKind.find((event) => event.status === \"running\");\n const completed = ofKind.find(\n (event) => event.status === terminalStatus || event.status === \"error\",\n );\n if (started !== undefined || completed === undefined) {\n return { started, completed };\n }\n const completedById = completed;\n const startedById = ofKind.find(\n (event) => event.eventId === completedById.eventId && event.status === \"running\",\n );\n return { started: startedById, completed: completedById };\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\nimport type { TraceReadWarning } from \"agent-inspect/readers\";\n\nexport interface TraceTransformResult {\n events: PersistedInspectEvent[];\n warnings: TraceReadWarning[];\n}\n\nexport interface TraceTransform {\n readonly id: string;\n transform(\n input: readonly PersistedInspectEvent[],\n options?: Record<string, unknown>,\n ): TraceTransformResult;\n}\n\nexport function defineTransform(transform: TraceTransform): TraceTransform {\n if (!transform.id.trim()) throw new Error(\"transform id is required\");\n return transform;\n}\n\nexport function runTransformPipeline(\n input: readonly PersistedInspectEvent[],\n transforms: readonly TraceTransform[],\n options: Record<string, unknown> = {},\n): TraceTransformResult {\n let events = [...input];\n const warnings: TraceReadWarning[] = [];\n\n for (const transform of transforms) {\n const result = transform.transform(events, options);\n events = result.events;\n warnings.push(...result.warnings);\n }\n\n return { events, warnings };\n}\n\nexport function createKindFilterTransform(\n kinds: readonly PersistedInspectEvent[\"kind\"][],\n): TraceTransform {\n const allowed = new Set(kinds);\n return defineTransform({\n id: `filter-kinds:${[...kinds].sort().join(\",\")}`,\n transform(input) {\n const filtered = input.filter(\n (event) => allowed.has(event.kind) || event.kind === \"RUN\",\n );\n const removed = input.length - filtered.length;\n return {\n events: filtered,\n warnings:\n removed > 0\n ? [\n {\n code: \"transform.filter.removed\",\n message: `removed ${removed} events outside allowed kinds`,\n severity: \"warning\",\n },\n ]\n : [],\n };\n },\n });\n}\n","import type { InspectRunTree } from \"agent-inspect/advanced\";\n\nexport type RenderRedactionProfile = \"local\" | \"share\" | \"strict\";\n\nexport interface RenderSafetyOptions {\n redactionProfile?: RenderRedactionProfile;\n maxContentLength?: number;\n forbiddenRawStrings?: readonly string[];\n}\n\nexport interface TraceRendererResult {\n content: string;\n contentType: string;\n warnings: string[];\n}\n\nexport interface TraceRendererOptions extends RenderSafetyOptions {\n [key: string]: unknown;\n}\n\nexport interface TraceRenderer {\n readonly format: string;\n render(tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;\n}\n\nexport function defineRenderer(renderer: TraceRenderer): TraceRenderer {\n if (!renderer.format.trim()) throw new Error(\"renderer format is required\");\n return renderer;\n}\n\nexport function renderWithSafety(\n renderer: TraceRenderer,\n tree: InspectRunTree,\n options: TraceRendererOptions = {},\n): TraceRendererResult {\n const rendered = renderer.render(tree, options);\n const warnings = [...rendered.warnings];\n const maxLen = options.maxContentLength ?? 500_000;\n\n if (rendered.content.length > maxLen) {\n warnings.push(\n `renderer.truncated: content exceeded maxContentLength (${maxLen}); output truncated`,\n );\n return {\n content: rendered.content.slice(0, maxLen),\n contentType: rendered.contentType,\n warnings,\n };\n }\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n for (const raw of options.forbiddenRawStrings) {\n if (rendered.content.includes(raw)) {\n warnings.push(\n `renderer.forbidden-leak: output contains forbidden substring (${raw.length} chars)`,\n );\n }\n }\n }\n\n if (options.redactionProfile === \"share\" || options.redactionProfile === \"strict\") {\n warnings.push(\n `renderer.redaction-profile:${options.redactionProfile} — verify output before sharing`,\n );\n }\n\n return {\n content: rendered.content,\n contentType: rendered.contentType,\n warnings,\n };\n}\n","import { loadTraceMetadataList, TraceDirectory } from \"agent-inspect/advanced\";\n\nexport interface TraceIndexEntry {\n runId: string;\n path: string;\n name?: string;\n startedAt?: number;\n status?: string;\n}\n\nexport interface TraceIndexSnapshot {\n traceDir: string;\n builtAt: string;\n entries: TraceIndexEntry[];\n warnings: string[];\n}\n\nexport interface TraceIndexOptions {\n maxEntries?: number;\n /** Rebuild when snapshot `builtAt` is older than this ISO timestamp. */\n invalidateBefore?: string;\n [key: string]: unknown;\n}\n\nexport interface TraceIndexer {\n readonly id: string;\n rebuild(traceDir: string, options?: TraceIndexOptions): Promise<TraceIndexSnapshot>;\n}\n\nexport function defineIndexer(indexer: TraceIndexer): TraceIndexer {\n if (!indexer.id.trim()) throw new Error(\"indexer id is required\");\n return indexer;\n}\n\nexport function shouldInvalidateIndex(\n snapshot: TraceIndexSnapshot,\n options: TraceIndexOptions = {},\n): boolean {\n if (!options.invalidateBefore) return false;\n const cutoff = Date.parse(options.invalidateBefore);\n const builtAt = Date.parse(snapshot.builtAt);\n if (Number.isNaN(cutoff) || Number.isNaN(builtAt)) return true;\n return builtAt < cutoff;\n}\n\nexport async function indexIsStale(\n snapshot: TraceIndexSnapshot,\n traceDir: string,\n): Promise<boolean> {\n const builtMs = Date.parse(snapshot.builtAt);\n if (Number.isNaN(builtMs)) return true;\n\n const td = new TraceDirectory({ dir: traceDir });\n const files = await td.list();\n for (const file of files) {\n const stats = await td.getFileStats(file);\n if (stats.mtimeMs > builtMs) return true;\n }\n return false;\n}\n\nexport function createTraceDirectoryIndexer(): TraceIndexer {\n return defineIndexer({\n id: \"trace-directory-metadata\",\n async rebuild(traceDir, options = {}) {\n const warnings: string[] = [];\n const td = new TraceDirectory({ dir: traceDir });\n const files = await td.list();\n const maxEntries = options.maxEntries ?? 10_000;\n\n if (files.length > maxEntries) {\n warnings.push(\n `indexer.truncated: trace directory has ${files.length} files; indexing first ${maxEntries}`,\n );\n }\n\n const slice = files.slice(0, maxEntries);\n const metas = await loadTraceMetadataList(traceDir, slice, (fileName) =>\n td.getPath(fileName),\n );\n\n const entries: TraceIndexEntry[] = metas\n .map((meta) => ({\n runId: meta.runId,\n path: meta.filePath,\n name: meta.name,\n startedAt: meta.startedAt,\n status: meta.status,\n }))\n .sort((a, b) => a.runId.localeCompare(b.runId));\n\n if (entries.length < slice.length) {\n warnings.push(\n `indexer.partial: indexed ${entries.length} of ${slice.length} trace files`,\n );\n }\n\n return {\n traceDir,\n builtAt: new Date().toISOString(),\n entries,\n warnings,\n };\n },\n });\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PersistedInspectEvent } from 'agent-inspect/persisted';
2
+ import { TraceReadWarning } from 'agent-inspect/readers';
2
3
 
3
4
  interface AdapterRegistration {
4
5
  id: string;
@@ -87,4 +88,105 @@ declare function findPairedLifecycle(events: readonly PersistedInspectEvent[], k
87
88
  completed?: PersistedInspectEvent;
88
89
  };
89
90
 
90
- export { type AdapterConformanceOptions, type AdapterConformanceResult, type AdapterFixtureSkeleton, type AdapterRegistration, type ConformanceCheck, PRIVACY_CHECKLIST_ITEMS, type PrivacyChecklistInput, type PrivacyChecklistItem, type PrivacyChecklistResult, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, listRegisteredAdapters, registerAdapter, runAdapterConformance, runPrivacyChecklist, stableStringify };
91
+ interface TraceTransformResult {
92
+ events: PersistedInspectEvent[];
93
+ warnings: TraceReadWarning[];
94
+ }
95
+ interface TraceTransform {
96
+ readonly id: string;
97
+ transform(input: readonly PersistedInspectEvent[], options?: Record<string, unknown>): TraceTransformResult;
98
+ }
99
+ declare function defineTransform(transform: TraceTransform): TraceTransform;
100
+ declare function runTransformPipeline(input: readonly PersistedInspectEvent[], transforms: readonly TraceTransform[], options?: Record<string, unknown>): TraceTransformResult;
101
+ declare function createKindFilterTransform(kinds: readonly PersistedInspectEvent["kind"][]): TraceTransform;
102
+
103
+ type AttributionConfidence = "explicit" | "correlated" | "heuristic" | "unknown";
104
+ type InspectKind = "RUN" | "AGENT" | "LLM" | "TOOL" | "CHAIN" | "RETRIEVER" | "DECISION" | "RESULT" | "ERROR" | "LOGIC" | "LOG";
105
+ interface EventSource {
106
+ type: "manual" | "json-log" | "log4js" | "pino" | "winston" | "adapter";
107
+ file?: string;
108
+ line?: number;
109
+ }
110
+ interface InspectEvent {
111
+ eventId: string;
112
+ runId: string;
113
+ parentId?: string;
114
+ name: string;
115
+ kind: InspectKind;
116
+ timestamp: number;
117
+ status?: "running" | "ok" | "error";
118
+ durationMs?: number;
119
+ attributes?: Record<string, unknown>;
120
+ confidence: AttributionConfidence;
121
+ source: EventSource;
122
+ }
123
+ interface InspectNode {
124
+ event: InspectEvent;
125
+ children: InspectNode[];
126
+ depth: number;
127
+ }
128
+ interface InspectRunTree {
129
+ runId: string;
130
+ name?: string;
131
+ status?: "running" | "ok" | "error";
132
+ startedAt?: number;
133
+ endedAt?: number;
134
+ durationMs?: number;
135
+ children: InspectNode[];
136
+ metadata: {
137
+ totalEvents: number;
138
+ confidenceBreakdown: Record<AttributionConfidence, number>;
139
+ kinds: Record<InspectKind, number>;
140
+ };
141
+ }
142
+
143
+ type RenderRedactionProfile = "local" | "share" | "strict";
144
+ interface RenderSafetyOptions {
145
+ redactionProfile?: RenderRedactionProfile;
146
+ maxContentLength?: number;
147
+ forbiddenRawStrings?: readonly string[];
148
+ }
149
+ interface TraceRendererResult {
150
+ content: string;
151
+ contentType: string;
152
+ warnings: string[];
153
+ }
154
+ interface TraceRendererOptions extends RenderSafetyOptions {
155
+ [key: string]: unknown;
156
+ }
157
+ interface TraceRenderer {
158
+ readonly format: string;
159
+ render(tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;
160
+ }
161
+ declare function defineRenderer(renderer: TraceRenderer): TraceRenderer;
162
+ declare function renderWithSafety(renderer: TraceRenderer, tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;
163
+
164
+ interface TraceIndexEntry {
165
+ runId: string;
166
+ path: string;
167
+ name?: string;
168
+ startedAt?: number;
169
+ status?: string;
170
+ }
171
+ interface TraceIndexSnapshot {
172
+ traceDir: string;
173
+ builtAt: string;
174
+ entries: TraceIndexEntry[];
175
+ warnings: string[];
176
+ }
177
+ interface TraceIndexOptions {
178
+ maxEntries?: number;
179
+ /** Rebuild when snapshot `builtAt` is older than this ISO timestamp. */
180
+ invalidateBefore?: string;
181
+ [key: string]: unknown;
182
+ }
183
+ interface TraceIndexer {
184
+ readonly id: string;
185
+ rebuild(traceDir: string, options?: TraceIndexOptions): Promise<TraceIndexSnapshot>;
186
+ }
187
+ declare function defineIndexer(indexer: TraceIndexer): TraceIndexer;
188
+ declare function shouldInvalidateIndex(snapshot: TraceIndexSnapshot, options?: TraceIndexOptions): boolean;
189
+ declare function indexIsStale(snapshot: TraceIndexSnapshot, traceDir: string): Promise<boolean>;
190
+ declare function createTraceDirectoryIndexer(): TraceIndexer;
191
+
192
+ export { type AdapterConformanceOptions, type AdapterConformanceResult, type AdapterFixtureSkeleton, type AdapterRegistration, type ConformanceCheck, PRIVACY_CHECKLIST_ITEMS, type PrivacyChecklistInput, type PrivacyChecklistItem, type PrivacyChecklistResult, type RenderRedactionProfile, type RenderSafetyOptions, type TraceIndexEntry, type TraceIndexOptions, type TraceIndexSnapshot, type TraceIndexer, type TraceRenderer, type TraceRendererOptions, type TraceRendererResult, type TraceTransform, type TraceTransformResult, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, createKindFilterTransform, createTraceDirectoryIndexer, defineIndexer, defineRenderer, defineTransform, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, indexIsStale, listRegisteredAdapters, registerAdapter, renderWithSafety, runAdapterConformance, runPrivacyChecklist, runTransformPipeline, shouldInvalidateIndex, stableStringify };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PersistedInspectEvent } from 'agent-inspect/persisted';
2
+ import { TraceReadWarning } from 'agent-inspect/readers';
2
3
 
3
4
  interface AdapterRegistration {
4
5
  id: string;
@@ -87,4 +88,105 @@ declare function findPairedLifecycle(events: readonly PersistedInspectEvent[], k
87
88
  completed?: PersistedInspectEvent;
88
89
  };
89
90
 
90
- export { type AdapterConformanceOptions, type AdapterConformanceResult, type AdapterFixtureSkeleton, type AdapterRegistration, type ConformanceCheck, PRIVACY_CHECKLIST_ITEMS, type PrivacyChecklistInput, type PrivacyChecklistItem, type PrivacyChecklistResult, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, listRegisteredAdapters, registerAdapter, runAdapterConformance, runPrivacyChecklist, stableStringify };
91
+ interface TraceTransformResult {
92
+ events: PersistedInspectEvent[];
93
+ warnings: TraceReadWarning[];
94
+ }
95
+ interface TraceTransform {
96
+ readonly id: string;
97
+ transform(input: readonly PersistedInspectEvent[], options?: Record<string, unknown>): TraceTransformResult;
98
+ }
99
+ declare function defineTransform(transform: TraceTransform): TraceTransform;
100
+ declare function runTransformPipeline(input: readonly PersistedInspectEvent[], transforms: readonly TraceTransform[], options?: Record<string, unknown>): TraceTransformResult;
101
+ declare function createKindFilterTransform(kinds: readonly PersistedInspectEvent["kind"][]): TraceTransform;
102
+
103
+ type AttributionConfidence = "explicit" | "correlated" | "heuristic" | "unknown";
104
+ type InspectKind = "RUN" | "AGENT" | "LLM" | "TOOL" | "CHAIN" | "RETRIEVER" | "DECISION" | "RESULT" | "ERROR" | "LOGIC" | "LOG";
105
+ interface EventSource {
106
+ type: "manual" | "json-log" | "log4js" | "pino" | "winston" | "adapter";
107
+ file?: string;
108
+ line?: number;
109
+ }
110
+ interface InspectEvent {
111
+ eventId: string;
112
+ runId: string;
113
+ parentId?: string;
114
+ name: string;
115
+ kind: InspectKind;
116
+ timestamp: number;
117
+ status?: "running" | "ok" | "error";
118
+ durationMs?: number;
119
+ attributes?: Record<string, unknown>;
120
+ confidence: AttributionConfidence;
121
+ source: EventSource;
122
+ }
123
+ interface InspectNode {
124
+ event: InspectEvent;
125
+ children: InspectNode[];
126
+ depth: number;
127
+ }
128
+ interface InspectRunTree {
129
+ runId: string;
130
+ name?: string;
131
+ status?: "running" | "ok" | "error";
132
+ startedAt?: number;
133
+ endedAt?: number;
134
+ durationMs?: number;
135
+ children: InspectNode[];
136
+ metadata: {
137
+ totalEvents: number;
138
+ confidenceBreakdown: Record<AttributionConfidence, number>;
139
+ kinds: Record<InspectKind, number>;
140
+ };
141
+ }
142
+
143
+ type RenderRedactionProfile = "local" | "share" | "strict";
144
+ interface RenderSafetyOptions {
145
+ redactionProfile?: RenderRedactionProfile;
146
+ maxContentLength?: number;
147
+ forbiddenRawStrings?: readonly string[];
148
+ }
149
+ interface TraceRendererResult {
150
+ content: string;
151
+ contentType: string;
152
+ warnings: string[];
153
+ }
154
+ interface TraceRendererOptions extends RenderSafetyOptions {
155
+ [key: string]: unknown;
156
+ }
157
+ interface TraceRenderer {
158
+ readonly format: string;
159
+ render(tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;
160
+ }
161
+ declare function defineRenderer(renderer: TraceRenderer): TraceRenderer;
162
+ declare function renderWithSafety(renderer: TraceRenderer, tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;
163
+
164
+ interface TraceIndexEntry {
165
+ runId: string;
166
+ path: string;
167
+ name?: string;
168
+ startedAt?: number;
169
+ status?: string;
170
+ }
171
+ interface TraceIndexSnapshot {
172
+ traceDir: string;
173
+ builtAt: string;
174
+ entries: TraceIndexEntry[];
175
+ warnings: string[];
176
+ }
177
+ interface TraceIndexOptions {
178
+ maxEntries?: number;
179
+ /** Rebuild when snapshot `builtAt` is older than this ISO timestamp. */
180
+ invalidateBefore?: string;
181
+ [key: string]: unknown;
182
+ }
183
+ interface TraceIndexer {
184
+ readonly id: string;
185
+ rebuild(traceDir: string, options?: TraceIndexOptions): Promise<TraceIndexSnapshot>;
186
+ }
187
+ declare function defineIndexer(indexer: TraceIndexer): TraceIndexer;
188
+ declare function shouldInvalidateIndex(snapshot: TraceIndexSnapshot, options?: TraceIndexOptions): boolean;
189
+ declare function indexIsStale(snapshot: TraceIndexSnapshot, traceDir: string): Promise<boolean>;
190
+ declare function createTraceDirectoryIndexer(): TraceIndexer;
191
+
192
+ export { type AdapterConformanceOptions, type AdapterConformanceResult, type AdapterFixtureSkeleton, type AdapterRegistration, type ConformanceCheck, PRIVACY_CHECKLIST_ITEMS, type PrivacyChecklistInput, type PrivacyChecklistItem, type PrivacyChecklistResult, type RenderRedactionProfile, type RenderSafetyOptions, type TraceIndexEntry, type TraceIndexOptions, type TraceIndexSnapshot, type TraceIndexer, type TraceRenderer, type TraceRendererOptions, type TraceRendererResult, type TraceTransform, type TraceTransformResult, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, createKindFilterTransform, createTraceDirectoryIndexer, defineIndexer, defineRenderer, defineTransform, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, indexIsStale, listRegisteredAdapters, registerAdapter, renderWithSafety, runAdapterConformance, runPrivacyChecklist, runTransformPipeline, shouldInvalidateIndex, stableStringify };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { persistedInspectEventsToRunTrees, persistedInspectEventsToTraceEvents } from 'agent-inspect/persisted';
2
2
  import { readTrace, openTrace } from 'agent-inspect/readers';
3
+ import { TraceDirectory, loadTraceMetadataList } from 'agent-inspect/advanced';
3
4
 
4
5
  // packages/adapter-sdk/src/registration.ts
5
6
  var registry = /* @__PURE__ */ new Map();
@@ -239,6 +240,146 @@ function findPairedLifecycle(events, kind, terminalStatus = "ok") {
239
240
  return { started: startedById, completed: completedById };
240
241
  }
241
242
 
242
- export { PRIVACY_CHECKLIST_ITEMS, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, listRegisteredAdapters, registerAdapter, runAdapterConformance, runPrivacyChecklist, stableStringify };
243
+ // packages/adapter-sdk/src/transform.ts
244
+ function defineTransform(transform) {
245
+ if (!transform.id.trim()) throw new Error("transform id is required");
246
+ return transform;
247
+ }
248
+ function runTransformPipeline(input, transforms, options = {}) {
249
+ let events = [...input];
250
+ const warnings = [];
251
+ for (const transform of transforms) {
252
+ const result = transform.transform(events, options);
253
+ events = result.events;
254
+ warnings.push(...result.warnings);
255
+ }
256
+ return { events, warnings };
257
+ }
258
+ function createKindFilterTransform(kinds) {
259
+ const allowed = new Set(kinds);
260
+ return defineTransform({
261
+ id: `filter-kinds:${[...kinds].sort().join(",")}`,
262
+ transform(input) {
263
+ const filtered = input.filter(
264
+ (event) => allowed.has(event.kind) || event.kind === "RUN"
265
+ );
266
+ const removed = input.length - filtered.length;
267
+ return {
268
+ events: filtered,
269
+ warnings: removed > 0 ? [
270
+ {
271
+ code: "transform.filter.removed",
272
+ message: `removed ${removed} events outside allowed kinds`,
273
+ severity: "warning"
274
+ }
275
+ ] : []
276
+ };
277
+ }
278
+ });
279
+ }
280
+
281
+ // packages/adapter-sdk/src/renderer.ts
282
+ function defineRenderer(renderer) {
283
+ if (!renderer.format.trim()) throw new Error("renderer format is required");
284
+ return renderer;
285
+ }
286
+ function renderWithSafety(renderer, tree, options = {}) {
287
+ const rendered = renderer.render(tree, options);
288
+ const warnings = [...rendered.warnings];
289
+ const maxLen = options.maxContentLength ?? 5e5;
290
+ if (rendered.content.length > maxLen) {
291
+ warnings.push(
292
+ `renderer.truncated: content exceeded maxContentLength (${maxLen}); output truncated`
293
+ );
294
+ return {
295
+ content: rendered.content.slice(0, maxLen),
296
+ contentType: rendered.contentType,
297
+ warnings
298
+ };
299
+ }
300
+ if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {
301
+ for (const raw of options.forbiddenRawStrings) {
302
+ if (rendered.content.includes(raw)) {
303
+ warnings.push(
304
+ `renderer.forbidden-leak: output contains forbidden substring (${raw.length} chars)`
305
+ );
306
+ }
307
+ }
308
+ }
309
+ if (options.redactionProfile === "share" || options.redactionProfile === "strict") {
310
+ warnings.push(
311
+ `renderer.redaction-profile:${options.redactionProfile} \u2014 verify output before sharing`
312
+ );
313
+ }
314
+ return {
315
+ content: rendered.content,
316
+ contentType: rendered.contentType,
317
+ warnings
318
+ };
319
+ }
320
+ function defineIndexer(indexer) {
321
+ if (!indexer.id.trim()) throw new Error("indexer id is required");
322
+ return indexer;
323
+ }
324
+ function shouldInvalidateIndex(snapshot, options = {}) {
325
+ if (!options.invalidateBefore) return false;
326
+ const cutoff = Date.parse(options.invalidateBefore);
327
+ const builtAt = Date.parse(snapshot.builtAt);
328
+ if (Number.isNaN(cutoff) || Number.isNaN(builtAt)) return true;
329
+ return builtAt < cutoff;
330
+ }
331
+ async function indexIsStale(snapshot, traceDir) {
332
+ const builtMs = Date.parse(snapshot.builtAt);
333
+ if (Number.isNaN(builtMs)) return true;
334
+ const td = new TraceDirectory({ dir: traceDir });
335
+ const files = await td.list();
336
+ for (const file of files) {
337
+ const stats = await td.getFileStats(file);
338
+ if (stats.mtimeMs > builtMs) return true;
339
+ }
340
+ return false;
341
+ }
342
+ function createTraceDirectoryIndexer() {
343
+ return defineIndexer({
344
+ id: "trace-directory-metadata",
345
+ async rebuild(traceDir, options = {}) {
346
+ const warnings = [];
347
+ const td = new TraceDirectory({ dir: traceDir });
348
+ const files = await td.list();
349
+ const maxEntries = options.maxEntries ?? 1e4;
350
+ if (files.length > maxEntries) {
351
+ warnings.push(
352
+ `indexer.truncated: trace directory has ${files.length} files; indexing first ${maxEntries}`
353
+ );
354
+ }
355
+ const slice = files.slice(0, maxEntries);
356
+ const metas = await loadTraceMetadataList(
357
+ traceDir,
358
+ slice,
359
+ (fileName) => td.getPath(fileName)
360
+ );
361
+ const entries = metas.map((meta) => ({
362
+ runId: meta.runId,
363
+ path: meta.filePath,
364
+ name: meta.name,
365
+ startedAt: meta.startedAt,
366
+ status: meta.status
367
+ })).sort((a, b) => a.runId.localeCompare(b.runId));
368
+ if (entries.length < slice.length) {
369
+ warnings.push(
370
+ `indexer.partial: indexed ${entries.length} of ${slice.length} trace files`
371
+ );
372
+ }
373
+ return {
374
+ traceDir,
375
+ builtAt: (/* @__PURE__ */ new Date()).toISOString(),
376
+ entries,
377
+ warnings
378
+ };
379
+ }
380
+ });
381
+ }
382
+
383
+ export { PRIVACY_CHECKLIST_ITEMS, clearAdapterRegistry, createAdapterFixtureSkeleton, createAdapterRegistration, createConformanceFixtureMeta, createKindFilterTransform, createTraceDirectoryIndexer, defineIndexer, defineRenderer, defineTransform, eventsToJsonl, extractPersistedKinds, findPairedLifecycle, flattenInspectNodes, getRegisteredAdapter, indexIsStale, listRegisteredAdapters, registerAdapter, renderWithSafety, runAdapterConformance, runPrivacyChecklist, runTransformPipeline, shouldInvalidateIndex, stableStringify };
243
384
  //# sourceMappingURL=index.mjs.map
244
385
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/registration.ts","../src/mapping.ts","../src/fixtures.ts","../src/privacy.ts","../src/conformance.ts"],"names":[],"mappings":";;;;AAEA,IAAM,QAAA,uBAAe,GAAA,EAAiC;AAE/C,SAAS,0BACd,KAAA,EACqB;AACrB,EAAA,IAAI,CAAC,MAAM,EAAA,CAAG,IAAA,IAAQ,MAAM,IAAI,MAAM,wBAAwB,CAAA;AAC9D,EAAA,IAAI,CAAC,MAAM,IAAA,CAAK,IAAA,IAAQ,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAClE,EAAA,IAAI,CAAC,MAAM,OAAA,CAAQ,IAAA,IAAQ,MAAM,IAAI,MAAM,6BAA6B,CAAA;AACxE,EAAA,IAAI,CAAC,MAAM,SAAA,CAAU,IAAA,IAAQ,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAC5E,EAAA,OAAO,EAAE,GAAG,KAAA,EAAM;AACpB;AAEO,SAAS,gBAAgB,YAAA,EAAwD;AACtF,EAAA,MAAM,UAAA,GAAa,0BAA0B,YAAY,CAAA;AACzD,EAAA,QAAA,CAAS,GAAA,CAAI,UAAA,CAAW,EAAA,EAAI,UAAU,CAAA;AACtC,EAAA,OAAO,UAAA;AACT;AAEO,SAAS,qBAAqB,EAAA,EAA6C;AAChF,EAAA,OAAO,QAAA,CAAS,IAAI,EAAE,CAAA;AACxB;AAEO,SAAS,sBAAA,GAAyD;AACvE,EAAA,OAAO,CAAC,GAAG,QAAA,CAAS,MAAA,EAAQ,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,EAAG,MAAM,CAAA,CAAE,EAAA,CAAG,aAAA,CAAc,CAAA,CAAE,EAAE,CAAC,CAAA;AACvE;AAEO,SAAS,oBAAA,GAA6B;AAC3C,EAAA,QAAA,CAAS,KAAA,EAAM;AACjB;;;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A,CAAK,CAAC,KAAA,KAAU,KAAA,CAAM,WAAW,SAAS,CAAA;AACjE,EAAA,MAAM,YAAY,MAAA,CAAO,IAAA;AAAA,IACvB,CAAC,KAAA,KAAU,KAAA,CAAM,MAAA,KAAW,cAAA,IAAkB,MAAM,MAAA,KAAW;AAAA,GACjE;AACA,EAAA,IAAI,OAAA,KAAY,MAAA,IAAa,SAAA,KAAc,MAAA,EAAW;AACpD,IAAA,OAAO,EAAE,SAAS,SAAA,EAAU;AAAA,EAC9B;AACA,EAAA,MAAM,aAAA,GAAgB,SAAA;AACtB,EAAA,MAAM,cAAc,MAAA,CAAO,IAAA;AAAA,IACzB,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,aAAA,CAAc,OAAA,IAAW,MAAM,MAAA,KAAW;AAAA,GACzE;AACA,EAAA,OAAO,EAAE,OAAA,EAAS,WAAA,EAAa,SAAA,EAAW,aAAA,EAAc;AAC1D","file":"index.mjs","sourcesContent":["import type { AdapterRegistration } from \"./types.js\";\n\nconst registry = new Map<string, AdapterRegistration>();\n\nexport function createAdapterRegistration(\n input: AdapterRegistration,\n): AdapterRegistration {\n if (!input.id.trim()) throw new Error(\"adapter id is required\");\n if (!input.name.trim()) throw new Error(\"adapter name is required\");\n if (!input.version.trim()) throw new Error(\"adapter version is required\");\n if (!input.framework.trim()) throw new Error(\"adapter framework is required\");\n return { ...input };\n}\n\nexport function registerAdapter(registration: AdapterRegistration): AdapterRegistration {\n const normalized = createAdapterRegistration(registration);\n registry.set(normalized.id, normalized);\n return normalized;\n}\n\nexport function getRegisteredAdapter(id: string): AdapterRegistration | undefined {\n return registry.get(id);\n}\n\nexport function listRegisteredAdapters(): readonly AdapterRegistration[] {\n return [...registry.values()].sort((a, b) => a.id.localeCompare(b.id));\n}\n\nexport function clearAdapterRegistry(): void {\n registry.clear();\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\n\nexport interface InspectNodeLike {\n event: { kind: string };\n children: InspectNodeLike[];\n}\n\nexport function eventsToJsonl(events: readonly unknown[]): string {\n return `${events.map((event) => JSON.stringify(event)).join(\"\\n\")}\\n`;\n}\n\nexport function flattenInspectNodes(nodes: readonly InspectNodeLike[]): InspectNodeLike[] {\n return nodes.flatMap((node) => [node, ...flattenInspectNodes(node.children)]);\n}\n\nexport function extractPersistedKinds(\n events: readonly PersistedInspectEvent[],\n): PersistedInspectEvent[\"kind\"][] {\n return events.map((event) => event.kind);\n}\n\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortJson(value)) ?? \"null\";\n}\n\nfunction sortJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => sortJson(item));\n }\n if (isPlainRecord(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = sortJson(value[key]);\n }\n return sorted;\n }\n return value === undefined ? null : value;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import type { AdapterFixtureSkeleton } from \"./types.js\";\n\nconst DEFAULT_COVERS = [\n \"run\",\n \"step\",\n \"tool\",\n \"llm\",\n \"error\",\n \"streaming\",\n \"metadata-bounds\",\n] as const;\n\nexport function createAdapterFixtureSkeleton(adapterId: string): AdapterFixtureSkeleton {\n return {\n adapterId,\n captureDefault: \"metadata-only\",\n network: \"none\",\n suggestedCovers: [...DEFAULT_COVERS],\n notes: [\n \"Use local mocks only; no provider API keys or network calls.\",\n \"Persist metadata-only by default; opt into preview/full capture explicitly.\",\n \"Include forbidden raw strings in conformance tests when prompts are mocked.\",\n \"Run runAdapterConformance against captured PersistedInspectEvent arrays.\",\n ],\n };\n}\n\nexport function createConformanceFixtureMeta(adapterId: string) {\n return {\n adapterId,\n defaults: {\n network: \"none\",\n upload: \"none\",\n capture: \"metadata-only\",\n },\n skeleton: createAdapterFixtureSkeleton(adapterId),\n };\n}\n","import type {\n ConformanceCheck,\n PrivacyChecklistInput,\n PrivacyChecklistItem,\n PrivacyChecklistResult,\n} from \"./types.js\";\n\nexport const PRIVACY_CHECKLIST_ITEMS: readonly PrivacyChecklistItem[] = [\n {\n id: \"capture-metadata-only-default\",\n label: \"Default capture is metadata-only (no full prompts/outputs on disk)\",\n required: true,\n },\n {\n id: \"no-network-by-default\",\n label: \"Adapter tests and defaults do not call external networks\",\n required: true,\n },\n {\n id: \"no-upload\",\n label: \"Adapter does not upload traces or logs to vendors by default\",\n required: true,\n },\n {\n id: \"redaction-documented\",\n label: \"Redaction/capture modes are documented for adapter users\",\n required: true,\n },\n {\n id: \"framework-deps-scoped\",\n label: \"Framework SDK dependencies stay in the optional adapter package\",\n required: true,\n },\n] as const;\n\nexport function runPrivacyChecklist(input: PrivacyChecklistInput = {}): PrivacyChecklistResult {\n const captureMode = input.captureMode ?? \"metadata-only\";\n const items: ConformanceCheck[] = [\n {\n id: \"capture-metadata-only-default\",\n ok: captureMode === \"metadata-only\",\n detail:\n captureMode === \"metadata-only\"\n ? undefined\n : `captureMode is ${captureMode}; metadata-only is required by default`,\n },\n {\n id: \"no-network-by-default\",\n ok: input.networkAllowed !== true,\n detail: input.networkAllowed ? \"network must be disabled in adapter defaults\" : undefined,\n },\n {\n id: \"no-upload\",\n ok: input.uploadAllowed !== true,\n detail: input.uploadAllowed ? \"upload must not be enabled by default\" : undefined,\n },\n {\n id: \"redaction-documented\",\n ok: input.redactionDocumented !== false,\n detail:\n input.redactionDocumented === false\n ? \"document capture/redaction behavior in adapter README\"\n : undefined,\n },\n {\n id: \"framework-deps-scoped\",\n ok: input.frameworkDepsPackageScoped !== false,\n detail:\n input.frameworkDepsPackageScoped === false\n ? \"keep framework SDK deps out of agent-inspect root/core\"\n : undefined,\n },\n ];\n\n const requiredFailed = items.some(\n (item) =>\n PRIVACY_CHECKLIST_ITEMS.find((def) => def.id === item.id)?.required && !item.ok,\n );\n\n return { ok: !requiredFailed, items };\n}\n","import {\n persistedInspectEventsToRunTrees,\n persistedInspectEventsToTraceEvents,\n type PersistedInspectEvent,\n} from \"agent-inspect/persisted\";\nimport { openTrace, readTrace } from \"agent-inspect/readers\";\n\nimport { eventsToJsonl, flattenInspectNodes, stableStringify } from \"./mapping.js\";\nimport type {\n AdapterConformanceOptions,\n AdapterConformanceResult,\n ConformanceCheck,\n} from \"./types.js\";\n\nexport async function runAdapterConformance(\n options: AdapterConformanceOptions,\n): Promise<AdapterConformanceResult> {\n const checks: ConformanceCheck[] = [];\n const { adapterId, events } = options;\n\n checks.push({\n id: \"events-non-empty\",\n ok: events.length > 0,\n detail: events.length > 0 ? undefined : \"expected at least one persisted event\",\n });\n\n const schemaOk = events.every(\n (event) => event.schemaVersion === \"0.2\" || event.schemaVersion === \"1.0\",\n );\n checks.push({\n id: \"schema-persisted\",\n ok: schemaOk,\n detail: schemaOk ? undefined : \"all events must use schemaVersion 0.2 or 1.0\",\n });\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n const serialized = JSON.stringify(events);\n const leaks = options.forbiddenRawStrings.filter((raw) => serialized.includes(raw));\n checks.push({\n id: \"no-forbidden-raw-strings\",\n ok: leaks.length === 0,\n detail:\n leaks.length === 0 ? undefined : `forbidden raw strings leaked: ${leaks.join(\", \")}`,\n });\n }\n\n try {\n const trees = persistedInspectEventsToRunTrees([...events]);\n checks.push({\n id: \"run-tree-built\",\n ok: trees.length > 0,\n detail: trees.length > 0 ? undefined : \"persistedInspectEventsToRunTrees returned no runs\",\n });\n\n if (options.expectedKinds && options.expectedKinds.length > 0 && trees[0]) {\n const kinds = flattenInspectNodes(trees[0].children).map((node) => node.event.kind);\n const kindsOk = stableStringify(kinds) === stableStringify([...options.expectedKinds]);\n checks.push({\n id: \"expected-kinds\",\n ok: kindsOk,\n detail: kindsOk\n ? undefined\n : `expected kinds ${options.expectedKinds.join(\",\")} but got ${kinds.join(\",\")}`,\n });\n }\n\n const normalized = persistedInspectEventsToTraceEvents([...events]);\n checks.push({\n id: \"legacy-normalization\",\n ok: normalized.length > 0,\n detail:\n normalized.length > 0 ? undefined : \"persistedInspectEventsToTraceEvents returned empty\",\n });\n\n const input = { type: \"string\" as const, content: eventsToJsonl(events) };\n const read = await readTrace(input, { format: \"agent-inspect-jsonl\" });\n const opened = await openTrace(input, { format: \"agent-inspect-jsonl\" });\n const roundTripOk = stableStringify(read.runs) === stableStringify(opened.runs);\n checks.push({\n id: \"reader-round-trip\",\n ok: roundTripOk,\n detail: roundTripOk ? undefined : \"readTrace and openTrace runs differ\",\n });\n } catch (error) {\n checks.push({\n id: \"conformance-runtime\",\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n ok: checks.every((check) => check.ok),\n adapterId,\n checks,\n };\n}\n\nexport function findPairedLifecycle(\n events: readonly PersistedInspectEvent[],\n kind: PersistedInspectEvent[\"kind\"],\n terminalStatus: \"ok\" | \"error\" = \"ok\",\n): { started?: PersistedInspectEvent; completed?: PersistedInspectEvent } {\n const ofKind = events.filter((event) => event.kind === kind);\n const started = ofKind.find((event) => event.status === \"running\");\n const completed = ofKind.find(\n (event) => event.status === terminalStatus || event.status === \"error\",\n );\n if (started !== undefined || completed === undefined) {\n return { started, completed };\n }\n const completedById = completed;\n const startedById = ofKind.find(\n (event) => event.eventId === completedById.eventId && event.status === \"running\",\n );\n return { started: startedById, completed: completedById };\n}\n"]}
1
+ {"version":3,"sources":["../src/registration.ts","../src/mapping.ts","../src/fixtures.ts","../src/privacy.ts","../src/conformance.ts","../src/transform.ts","../src/renderer.ts","../src/indexer.ts"],"names":[],"mappings":";;;;;AAEA,IAAM,QAAA,uBAAe,GAAA,EAAiC;AAE/C,SAAS,0BACd,KAAA,EACqB;AACrB,EAAA,IAAI,CAAC,MAAM,EAAA,CAAG,IAAA,IAAQ,MAAM,IAAI,MAAM,wBAAwB,CAAA;AAC9D,EAAA,IAAI,CAAC,MAAM,IAAA,CAAK,IAAA,IAAQ,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAClE,EAAA,IAAI,CAAC,MAAM,OAAA,CAAQ,IAAA,I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,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,QAAQ,IAAA,CAAK;AAAA,OACf,CAAE,CAAA,CACD,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,CAAE,KAAA,CAAM,aAAA,CAAc,CAAA,CAAE,KAAK,CAAC,CAAA;AAEhD,MAAA,IAAI,OAAA,CAAQ,MAAA,GAAS,KAAA,CAAM,MAAA,EAAQ;AACjC,QAAA,QAAA,CAAS,IAAA;AAAA,UACP,CAAA,yBAAA,EAA4B,OAAA,CAAQ,MAAM,CAAA,IAAA,EAAO,MAAM,MAAM,CAAA,YAAA;AAAA,SAC/D;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,QAAA;AAAA,QACA,OAAA,EAAA,iBAAS,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,QAChC,OAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,GACD,CAAA;AACH","file":"index.mjs","sourcesContent":["import type { AdapterRegistration } from \"./types.js\";\n\nconst registry = new Map<string, AdapterRegistration>();\n\nexport function createAdapterRegistration(\n input: AdapterRegistration,\n): AdapterRegistration {\n if (!input.id.trim()) throw new Error(\"adapter id is required\");\n if (!input.name.trim()) throw new Error(\"adapter name is required\");\n if (!input.version.trim()) throw new Error(\"adapter version is required\");\n if (!input.framework.trim()) throw new Error(\"adapter framework is required\");\n return { ...input };\n}\n\nexport function registerAdapter(registration: AdapterRegistration): AdapterRegistration {\n const normalized = createAdapterRegistration(registration);\n registry.set(normalized.id, normalized);\n return normalized;\n}\n\nexport function getRegisteredAdapter(id: string): AdapterRegistration | undefined {\n return registry.get(id);\n}\n\nexport function listRegisteredAdapters(): readonly AdapterRegistration[] {\n return [...registry.values()].sort((a, b) => a.id.localeCompare(b.id));\n}\n\nexport function clearAdapterRegistry(): void {\n registry.clear();\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\n\nexport interface InspectNodeLike {\n event: { kind: string };\n children: InspectNodeLike[];\n}\n\nexport function eventsToJsonl(events: readonly unknown[]): string {\n return `${events.map((event) => JSON.stringify(event)).join(\"\\n\")}\\n`;\n}\n\nexport function flattenInspectNodes(nodes: readonly InspectNodeLike[]): InspectNodeLike[] {\n return nodes.flatMap((node) => [node, ...flattenInspectNodes(node.children)]);\n}\n\nexport function extractPersistedKinds(\n events: readonly PersistedInspectEvent[],\n): PersistedInspectEvent[\"kind\"][] {\n return events.map((event) => event.kind);\n}\n\nexport function stableStringify(value: unknown): string {\n return JSON.stringify(sortJson(value)) ?? \"null\";\n}\n\nfunction sortJson(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => sortJson(item));\n }\n if (isPlainRecord(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = sortJson(value[key]);\n }\n return sorted;\n }\n return value === undefined ? null : value;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n","import type { AdapterFixtureSkeleton } from \"./types.js\";\n\nconst DEFAULT_COVERS = [\n \"run\",\n \"step\",\n \"tool\",\n \"llm\",\n \"error\",\n \"streaming\",\n \"metadata-bounds\",\n] as const;\n\nexport function createAdapterFixtureSkeleton(adapterId: string): AdapterFixtureSkeleton {\n return {\n adapterId,\n captureDefault: \"metadata-only\",\n network: \"none\",\n suggestedCovers: [...DEFAULT_COVERS],\n notes: [\n \"Use local mocks only; no provider API keys or network calls.\",\n \"Persist metadata-only by default; opt into preview/full capture explicitly.\",\n \"Include forbidden raw strings in conformance tests when prompts are mocked.\",\n \"Run runAdapterConformance against captured PersistedInspectEvent arrays.\",\n ],\n };\n}\n\nexport function createConformanceFixtureMeta(adapterId: string) {\n return {\n adapterId,\n defaults: {\n network: \"none\",\n upload: \"none\",\n capture: \"metadata-only\",\n },\n skeleton: createAdapterFixtureSkeleton(adapterId),\n };\n}\n","import type {\n ConformanceCheck,\n PrivacyChecklistInput,\n PrivacyChecklistItem,\n PrivacyChecklistResult,\n} from \"./types.js\";\n\nexport const PRIVACY_CHECKLIST_ITEMS: readonly PrivacyChecklistItem[] = [\n {\n id: \"capture-metadata-only-default\",\n label: \"Default capture is metadata-only (no full prompts/outputs on disk)\",\n required: true,\n },\n {\n id: \"no-network-by-default\",\n label: \"Adapter tests and defaults do not call external networks\",\n required: true,\n },\n {\n id: \"no-upload\",\n label: \"Adapter does not upload traces or logs to vendors by default\",\n required: true,\n },\n {\n id: \"redaction-documented\",\n label: \"Redaction/capture modes are documented for adapter users\",\n required: true,\n },\n {\n id: \"framework-deps-scoped\",\n label: \"Framework SDK dependencies stay in the optional adapter package\",\n required: true,\n },\n] as const;\n\nexport function runPrivacyChecklist(input: PrivacyChecklistInput = {}): PrivacyChecklistResult {\n const captureMode = input.captureMode ?? \"metadata-only\";\n const items: ConformanceCheck[] = [\n {\n id: \"capture-metadata-only-default\",\n ok: captureMode === \"metadata-only\",\n detail:\n captureMode === \"metadata-only\"\n ? undefined\n : `captureMode is ${captureMode}; metadata-only is required by default`,\n },\n {\n id: \"no-network-by-default\",\n ok: input.networkAllowed !== true,\n detail: input.networkAllowed ? \"network must be disabled in adapter defaults\" : undefined,\n },\n {\n id: \"no-upload\",\n ok: input.uploadAllowed !== true,\n detail: input.uploadAllowed ? \"upload must not be enabled by default\" : undefined,\n },\n {\n id: \"redaction-documented\",\n ok: input.redactionDocumented !== false,\n detail:\n input.redactionDocumented === false\n ? \"document capture/redaction behavior in adapter README\"\n : undefined,\n },\n {\n id: \"framework-deps-scoped\",\n ok: input.frameworkDepsPackageScoped !== false,\n detail:\n input.frameworkDepsPackageScoped === false\n ? \"keep framework SDK deps out of agent-inspect root/core\"\n : undefined,\n },\n ];\n\n const requiredFailed = items.some(\n (item) =>\n PRIVACY_CHECKLIST_ITEMS.find((def) => def.id === item.id)?.required && !item.ok,\n );\n\n return { ok: !requiredFailed, items };\n}\n","import {\n persistedInspectEventsToRunTrees,\n persistedInspectEventsToTraceEvents,\n type PersistedInspectEvent,\n} from \"agent-inspect/persisted\";\nimport { openTrace, readTrace } from \"agent-inspect/readers\";\n\nimport { eventsToJsonl, flattenInspectNodes, stableStringify } from \"./mapping.js\";\nimport type {\n AdapterConformanceOptions,\n AdapterConformanceResult,\n ConformanceCheck,\n} from \"./types.js\";\n\nexport async function runAdapterConformance(\n options: AdapterConformanceOptions,\n): Promise<AdapterConformanceResult> {\n const checks: ConformanceCheck[] = [];\n const { adapterId, events } = options;\n\n checks.push({\n id: \"events-non-empty\",\n ok: events.length > 0,\n detail: events.length > 0 ? undefined : \"expected at least one persisted event\",\n });\n\n const schemaOk = events.every(\n (event) => event.schemaVersion === \"0.2\" || event.schemaVersion === \"1.0\",\n );\n checks.push({\n id: \"schema-persisted\",\n ok: schemaOk,\n detail: schemaOk ? undefined : \"all events must use schemaVersion 0.2 or 1.0\",\n });\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n const serialized = JSON.stringify(events);\n const leaks = options.forbiddenRawStrings.filter((raw) => serialized.includes(raw));\n checks.push({\n id: \"no-forbidden-raw-strings\",\n ok: leaks.length === 0,\n detail:\n leaks.length === 0 ? undefined : `forbidden raw strings leaked: ${leaks.join(\", \")}`,\n });\n }\n\n try {\n const trees = persistedInspectEventsToRunTrees([...events]);\n checks.push({\n id: \"run-tree-built\",\n ok: trees.length > 0,\n detail: trees.length > 0 ? undefined : \"persistedInspectEventsToRunTrees returned no runs\",\n });\n\n if (options.expectedKinds && options.expectedKinds.length > 0 && trees[0]) {\n const kinds = flattenInspectNodes(trees[0].children).map((node) => node.event.kind);\n const kindsOk = stableStringify(kinds) === stableStringify([...options.expectedKinds]);\n checks.push({\n id: \"expected-kinds\",\n ok: kindsOk,\n detail: kindsOk\n ? undefined\n : `expected kinds ${options.expectedKinds.join(\",\")} but got ${kinds.join(\",\")}`,\n });\n }\n\n const normalized = persistedInspectEventsToTraceEvents([...events]);\n checks.push({\n id: \"legacy-normalization\",\n ok: normalized.length > 0,\n detail:\n normalized.length > 0 ? undefined : \"persistedInspectEventsToTraceEvents returned empty\",\n });\n\n const input = { type: \"string\" as const, content: eventsToJsonl(events) };\n const read = await readTrace(input, { format: \"agent-inspect-jsonl\" });\n const opened = await openTrace(input, { format: \"agent-inspect-jsonl\" });\n const roundTripOk = stableStringify(read.runs) === stableStringify(opened.runs);\n checks.push({\n id: \"reader-round-trip\",\n ok: roundTripOk,\n detail: roundTripOk ? undefined : \"readTrace and openTrace runs differ\",\n });\n } catch (error) {\n checks.push({\n id: \"conformance-runtime\",\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n ok: checks.every((check) => check.ok),\n adapterId,\n checks,\n };\n}\n\nexport function findPairedLifecycle(\n events: readonly PersistedInspectEvent[],\n kind: PersistedInspectEvent[\"kind\"],\n terminalStatus: \"ok\" | \"error\" = \"ok\",\n): { started?: PersistedInspectEvent; completed?: PersistedInspectEvent } {\n const ofKind = events.filter((event) => event.kind === kind);\n const started = ofKind.find((event) => event.status === \"running\");\n const completed = ofKind.find(\n (event) => event.status === terminalStatus || event.status === \"error\",\n );\n if (started !== undefined || completed === undefined) {\n return { started, completed };\n }\n const completedById = completed;\n const startedById = ofKind.find(\n (event) => event.eventId === completedById.eventId && event.status === \"running\",\n );\n return { started: startedById, completed: completedById };\n}\n","import type { PersistedInspectEvent } from \"agent-inspect/persisted\";\nimport type { TraceReadWarning } from \"agent-inspect/readers\";\n\nexport interface TraceTransformResult {\n events: PersistedInspectEvent[];\n warnings: TraceReadWarning[];\n}\n\nexport interface TraceTransform {\n readonly id: string;\n transform(\n input: readonly PersistedInspectEvent[],\n options?: Record<string, unknown>,\n ): TraceTransformResult;\n}\n\nexport function defineTransform(transform: TraceTransform): TraceTransform {\n if (!transform.id.trim()) throw new Error(\"transform id is required\");\n return transform;\n}\n\nexport function runTransformPipeline(\n input: readonly PersistedInspectEvent[],\n transforms: readonly TraceTransform[],\n options: Record<string, unknown> = {},\n): TraceTransformResult {\n let events = [...input];\n const warnings: TraceReadWarning[] = [];\n\n for (const transform of transforms) {\n const result = transform.transform(events, options);\n events = result.events;\n warnings.push(...result.warnings);\n }\n\n return { events, warnings };\n}\n\nexport function createKindFilterTransform(\n kinds: readonly PersistedInspectEvent[\"kind\"][],\n): TraceTransform {\n const allowed = new Set(kinds);\n return defineTransform({\n id: `filter-kinds:${[...kinds].sort().join(\",\")}`,\n transform(input) {\n const filtered = input.filter(\n (event) => allowed.has(event.kind) || event.kind === \"RUN\",\n );\n const removed = input.length - filtered.length;\n return {\n events: filtered,\n warnings:\n removed > 0\n ? [\n {\n code: \"transform.filter.removed\",\n message: `removed ${removed} events outside allowed kinds`,\n severity: \"warning\",\n },\n ]\n : [],\n };\n },\n });\n}\n","import type { InspectRunTree } from \"agent-inspect/advanced\";\n\nexport type RenderRedactionProfile = \"local\" | \"share\" | \"strict\";\n\nexport interface RenderSafetyOptions {\n redactionProfile?: RenderRedactionProfile;\n maxContentLength?: number;\n forbiddenRawStrings?: readonly string[];\n}\n\nexport interface TraceRendererResult {\n content: string;\n contentType: string;\n warnings: string[];\n}\n\nexport interface TraceRendererOptions extends RenderSafetyOptions {\n [key: string]: unknown;\n}\n\nexport interface TraceRenderer {\n readonly format: string;\n render(tree: InspectRunTree, options?: TraceRendererOptions): TraceRendererResult;\n}\n\nexport function defineRenderer(renderer: TraceRenderer): TraceRenderer {\n if (!renderer.format.trim()) throw new Error(\"renderer format is required\");\n return renderer;\n}\n\nexport function renderWithSafety(\n renderer: TraceRenderer,\n tree: InspectRunTree,\n options: TraceRendererOptions = {},\n): TraceRendererResult {\n const rendered = renderer.render(tree, options);\n const warnings = [...rendered.warnings];\n const maxLen = options.maxContentLength ?? 500_000;\n\n if (rendered.content.length > maxLen) {\n warnings.push(\n `renderer.truncated: content exceeded maxContentLength (${maxLen}); output truncated`,\n );\n return {\n content: rendered.content.slice(0, maxLen),\n contentType: rendered.contentType,\n warnings,\n };\n }\n\n if (options.forbiddenRawStrings && options.forbiddenRawStrings.length > 0) {\n for (const raw of options.forbiddenRawStrings) {\n if (rendered.content.includes(raw)) {\n warnings.push(\n `renderer.forbidden-leak: output contains forbidden substring (${raw.length} chars)`,\n );\n }\n }\n }\n\n if (options.redactionProfile === \"share\" || options.redactionProfile === \"strict\") {\n warnings.push(\n `renderer.redaction-profile:${options.redactionProfile} — verify output before sharing`,\n );\n }\n\n return {\n content: rendered.content,\n contentType: rendered.contentType,\n warnings,\n };\n}\n","import { loadTraceMetadataList, TraceDirectory } from \"agent-inspect/advanced\";\n\nexport interface TraceIndexEntry {\n runId: string;\n path: string;\n name?: string;\n startedAt?: number;\n status?: string;\n}\n\nexport interface TraceIndexSnapshot {\n traceDir: string;\n builtAt: string;\n entries: TraceIndexEntry[];\n warnings: string[];\n}\n\nexport interface TraceIndexOptions {\n maxEntries?: number;\n /** Rebuild when snapshot `builtAt` is older than this ISO timestamp. */\n invalidateBefore?: string;\n [key: string]: unknown;\n}\n\nexport interface TraceIndexer {\n readonly id: string;\n rebuild(traceDir: string, options?: TraceIndexOptions): Promise<TraceIndexSnapshot>;\n}\n\nexport function defineIndexer(indexer: TraceIndexer): TraceIndexer {\n if (!indexer.id.trim()) throw new Error(\"indexer id is required\");\n return indexer;\n}\n\nexport function shouldInvalidateIndex(\n snapshot: TraceIndexSnapshot,\n options: TraceIndexOptions = {},\n): boolean {\n if (!options.invalidateBefore) return false;\n const cutoff = Date.parse(options.invalidateBefore);\n const builtAt = Date.parse(snapshot.builtAt);\n if (Number.isNaN(cutoff) || Number.isNaN(builtAt)) return true;\n return builtAt < cutoff;\n}\n\nexport async function indexIsStale(\n snapshot: TraceIndexSnapshot,\n traceDir: string,\n): Promise<boolean> {\n const builtMs = Date.parse(snapshot.builtAt);\n if (Number.isNaN(builtMs)) return true;\n\n const td = new TraceDirectory({ dir: traceDir });\n const files = await td.list();\n for (const file of files) {\n const stats = await td.getFileStats(file);\n if (stats.mtimeMs > builtMs) return true;\n }\n return false;\n}\n\nexport function createTraceDirectoryIndexer(): TraceIndexer {\n return defineIndexer({\n id: \"trace-directory-metadata\",\n async rebuild(traceDir, options = {}) {\n const warnings: string[] = [];\n const td = new TraceDirectory({ dir: traceDir });\n const files = await td.list();\n const maxEntries = options.maxEntries ?? 10_000;\n\n if (files.length > maxEntries) {\n warnings.push(\n `indexer.truncated: trace directory has ${files.length} files; indexing first ${maxEntries}`,\n );\n }\n\n const slice = files.slice(0, maxEntries);\n const metas = await loadTraceMetadataList(traceDir, slice, (fileName) =>\n td.getPath(fileName),\n );\n\n const entries: TraceIndexEntry[] = metas\n .map((meta) => ({\n runId: meta.runId,\n path: meta.filePath,\n name: meta.name,\n startedAt: meta.startedAt,\n status: meta.status,\n }))\n .sort((a, b) => a.runId.localeCompare(b.runId));\n\n if (entries.length < slice.length) {\n warnings.push(\n `indexer.partial: indexed ${entries.length} of ${slice.length} trace files`,\n );\n }\n\n return {\n traceDir,\n builtAt: new Date().toISOString(),\n entries,\n warnings,\n };\n },\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-inspect/adapter-sdk",
3
- "version": "2.6.0",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Adapter authoring toolkit with conformance and privacy helpers",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "agent-inspect": "2.6.0"
36
+ "agent-inspect": "3.1.0"
37
37
  },
38
38
  "peerDependencies": {},
39
39
  "publishConfig": {