agent-inspect 6.31.35 → 6.31.36

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.31.36
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e4d8dc: Fail closed when a token budget is set but completed LLM calls record no usage (#534/#535; thanks Rodrigo). Recipe INV-08 now cross-checks Bezalel remediation relationship endpoints (#537). Docs clarify manual `inspectRun`/`step` still omit `Error.code` (#541), standalone starter install on 6.31.35, and dated Windows packed MCP evidence (#526). Publish workflow splits verify (read-only) from OIDC publish (#536/#539).
8
+
3
9
  ## 6.31.35
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -213,7 +213,7 @@ The root package is enough for custom capture, the CLI, checks, and Evidence wor
213
213
 
214
214
  ## Status and documentation
215
215
 
216
- **Current published baseline:** **6.31.35** · persisted schema `1.0` · Node.js `>=20` · MIT.
216
+ **Current published baseline:** **6.31.36** · persisted schema `1.0` · Node.js `>=20` · MIT.
217
217
 
218
218
  Legacy v0.1 and v0.2 traces remain readable. Check the npm badge and [changelog](CHANGELOG.md) for the current published version.
219
219
 
package/docs/API.md CHANGED
@@ -71,7 +71,7 @@ import {
71
71
  } from "agent-inspect";
72
72
  ```
73
73
 
74
- - **`inspectRun(name, fn, options?)`**: wraps a workflow in a local JSONL trace (`run_started` / `run_completed`), prints terminal progress, and swallows instrumentation failures (user errors are re-thrown). **Traces by default** when `enabled` is omitted or `true`. Pass **`enabled: false`** to run `fn` with no trace file, no execution context, and no terminal output.
74
+ - **`inspectRun(name, fn, options?)`**: wraps a workflow in a local JSONL trace (`run_started` / `run_completed`), prints terminal progress, and swallows instrumentation failures (user errors are re-thrown). **Traces by default** when `enabled` is omitted or `true`. Pass **`enabled: false`** to run `fn` with no trace file, no execution context, and no terminal output. On failure, persisted `error` is `{ message, stack? }` only — thrown `Error.code` / numeric `status` are **not** retained on this manual v0.1 path (use `createInspector()` when bounded `error.code` persistence matters; see §19 and [SCHEMA.md](./SCHEMA.md) §4).
75
75
  - **`redact`**: default `true` — redacts sensitive metadata keys before disk (`authorization`, `cookie`, `token`, `apiKey`, `password`, `secret`, `email`). Pass `false` to persist metadata as-is. Pass `{ rules?: RedactionRule[] }` for custom rules (defaults still apply). **`redact: false` wins** over `redactionProfile` for trace writing.
76
76
  - **`redactionProfile`**: optional preset — `local` (default), `share`, or `strict`. Adds extra key-based redaction and tighter metadata string bounds for trace writing. Key-based only — not compliance-grade DLP.
77
77
  - **`maxMetadataValueLength`**: max string length for metadata values (default `2000`).
@@ -474,7 +474,7 @@ Public methods:
474
474
 
475
475
  `capture` is explicit and metadata-only. `onSuccess: "metadata-only"` records safe type/length/key-count summaries in `outputSummary`; `onError: "metadata-only"` records thrown-value type/name summaries. It does not store raw return values, prompts, outputs, or thrown objects. Use `"none"` to disable a capture side.
476
476
 
477
- Persisted step/run errors keep `name` and `message`. When present, a **bounded safe** `code` is also retained: finite numeric `code`/`status` values (for example HTTP `404`) or short strings matching letters, digits, underscore, hyphen, dot, and colon (max 128 characters). Response bodies, headers, multiline values, and arbitrary enumerable error properties are not persisted.
477
+ Persisted step/run errors keep `name` and `message`. When present, a **bounded safe** `code` is also retained: finite numeric `code`/`status` values (for example HTTP `404` / `429`) or short strings matching letters, digits, underscore, hyphen, dot, and colon (max 128 characters, for example `ECONNRESET`). Response bodies, headers, multiline values, and arbitrary enumerable error properties are not persisted. This `code` retention applies to **`createInspector()`** schema 1.0 writers only — not to global `inspectRun` / `step` (those still omit codes; see [SCHEMA.md](./SCHEMA.md) §4).
478
478
 
479
479
  Pass structured tool arguments for contracts via step `metadata.arguments` / `metadata.input` / `metadata.toolArguments` (or top-level attributes with the same keys). TraceContract tool-argument checks read those locations; they do not enable default raw capture.
480
480
 
package/docs/CLI.md CHANGED
@@ -332,6 +332,7 @@ Options:
332
332
  - `--max-duration-ms <number>`: add `run.duration`
333
333
  - `--required-tool <name>` / `--forbidden-tool <name>` / `--forbid-tool <name>` (alias): add `tool.usage`
334
334
  - `--allowed-model <model>` / `--max-total-tokens <number>`: add `llm.usage`
335
+ - A token limit fails when no token usage is read for a completed LLM call, because the limit cannot be verified. A failed LLM call does not need to record usage.
335
336
  - `--session <id>`: check all runs in a workflow session (uses `--dir`; target may be `.`)
336
337
  - `--group <id>`: check all runs sharing a `groupId` metadata value
337
338
  - `--correlate-group`: when using `--session`, also match synthetic `group:` session keys
@@ -4,6 +4,7 @@ AgentInspect is **local-first** and **CLI-first**. These behaviors are intention
4
4
 
5
5
  ## Contracts and safety
6
6
 
7
+ - **Manual traces omit `Error.code`:** Global `inspectRun` / `step` still persist `{ message, stack? }` only. Bounded `error.code` retention shipped for `createInspector()` in 6.29.2 (#415); the issue title said “manual instrumentation,” but the manual helpers were not changed. Prefer `createInspector()` or explicit metadata `errorCode` when codes matter. Documented in [SCHEMA.md](./SCHEMA.md) §4 / [LIMITATIONS.md](./LIMITATIONS.md).
7
8
  - **Retry / side-effect rules (6.23+; chronology fixed in 6.25.1):** `requireIdempotencyEvidenceForRetry` applies to genuine retries including `error → success`, not only retries after a prior `ok`. Ambiguous attempt identity fails closed under that rule. Write timeouts remain **unknown completion** — safe write retry is not claimed.
8
9
  - **Omitted-payload digests:** inputs larger than 1 MiB are rejected after a length preflight; oversized rejection must not be treated as a free full-buffer copy path.
9
10
 
@@ -20,6 +20,7 @@ This document states what AgentInspect **does not** provide today. It complement
20
20
  ## Persisted event model
21
21
 
22
22
  - **Manual global tracing remains v0.1.** `inspectRun()` / `step()` still write `schemaVersion: "0.1"` JSONL for compatibility.
23
+ - **Manual `error` omits codes.** Thrown `Error.code` values (for example `429`, `ECONNRESET`) and numeric `status` are **not** written on the manual path (`formatError` → `{ message, stack? }` only). `createInspector()` retains bounded safe codes on schema 1.0 rows. Issue #415 shipped the inspector path; the manual helpers are unchanged. See [SCHEMA.md](./SCHEMA.md) §4.
23
24
  - **Persisted writer/runtime output targets schema 1.0.** `createInspector()` with built-in writers emits schema 1.0 persisted rows; v0.1 and v0.2 remain readable.
24
25
  - **Migration is explicit, not automatic.** `agent-inspect migrate <input> --to 1.0 --dry-run` reports what would change, and `--output <file>` writes a separate file. AgentInspect does not rewrite old traces in place.
25
26
 
package/docs/SCHEMA.md CHANGED
@@ -139,8 +139,17 @@ Records whether an external side effect matched expectations. Distinct from step
139
139
 
140
140
  ## 4. Error representation
141
141
 
142
- - Errors are structured as `{ message, stack? }`.
142
+ Writer paths differ; this is intentional compatibility, **not** a claim that manual tracing preserves `Error.code`:
143
+
144
+ | Writer path | Schema | Persisted `error` shape | `Error.code` / numeric `status` |
145
+ | ----------- | ------ | ----------------------- | -------------------------------- |
146
+ | Manual global helpers (`inspectRun` / `step` / `maybeInspectRun`) | `"0.1"` | `{ message, stack? }` (`ErrorInfo`) | **Omitted.** `formatError()` keeps message and optional stack only. |
147
+ | `createInspector()` + built-in persisted writers | `"1.0"` (also readable as v0.2 shape) | `{ name?, message, code? }` (`PersistedInspectError`) | **Bounded safe codes retained** when present (finite numeric `code`/`status`, or short alphanumeric strings). See [API.md](./API.md) §19. |
148
+
149
+ - Manual JSONL examples above use `{ message, stack? }` because that is what the v0.1 writer still emits.
150
+ - Persisted schema 1.0 rows may include `error.code` (for example `"429"` or `"ECONNRESET"`). Migrating a manual v0.1 file to 1.0 does **not** invent codes that were never written.
143
151
  - AgentInspect prints short human errors by default; verbose modes may include stack strings.
152
+ - Recovery / retry checks that need codes should prefer `createInspector()` traces, or place an explicit `errorCode` / `code` in start metadata when using the manual path (see recovery-operations notes in core).
144
153
 
145
154
  ## 5. Status representation
146
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-inspect",
3
- "version": "6.31.35",
3
+ "version": "6.31.36",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local evidence debugger and trajectory-test toolkit for TypeScript AI agents — execution trees, TraceContract checks, Evidence v2, and read-only MCP",
@@ -9148,6 +9148,9 @@ function createToolFailureRule(options) {
9148
9148
  }
9149
9149
  };
9150
9150
  }
9151
+ function recordsTokenUsage(event) {
9152
+ return Object.values(event.tokenUsage ?? {}).some((count) => typeof count === "number");
9153
+ }
9151
9154
  function createLlmUsageRule(options) {
9152
9155
  return {
9153
9156
  id: "llm.usage",
@@ -9205,6 +9208,21 @@ function createLlmUsageRule(options) {
9205
9208
  ["total", options.maxTotalTokens],
9206
9209
  ["cached", options.maxCachedTokens]
9207
9210
  ];
9211
+ const hasTokenLimit = tokenLimits.some(([, limit]) => limit !== void 0);
9212
+ const callsWithoutUsage = llms.filter(
9213
+ (event) => event.status !== "error" && !recordsTokenUsage(event)
9214
+ );
9215
+ if (hasTokenLimit && callsWithoutUsage.length > 0) {
9216
+ findings.push(
9217
+ failFinding(
9218
+ "llm.usage",
9219
+ `No token usage was read for ${callsWithoutUsage.length} of ${llms.length} LLM call(s), so the token limit cannot be verified.`,
9220
+ callsWithoutUsage.map((event) => eventEvidence3(event, "tokenUsage")),
9221
+ "token usage on every completed LLM call",
9222
+ { callsWithoutUsage: callsWithoutUsage.length, calls: llms.length }
9223
+ )
9224
+ );
9225
+ }
9208
9226
  for (const [key, limit] of tokenLimits) {
9209
9227
  if (limit !== void 0 && tokenTotals[key] > limit) {
9210
9228
  findings.push(
@@ -16225,5 +16243,5 @@ function renderGateReport(result, options = {}) {
16225
16243
  }
16226
16244
 
16227
16245
  export { ATTRIBUTION_CONFIDENCES, COHORT_METRIC_IDS, DEFAULT_REDACT_KEYS, DEFAULT_SUITE_ARTIFACTS_DIR, DELIVERY_CONFLICT_ATTR, DELIVERY_EVENT_BASE_ATTR, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, IDENTITY_CONFLICT_ATTR, Redactor, TraceDirectory, TraceReadError, TreeBuilder, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, applyProfileMetadataCaps, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceHtmlShell, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compactAttributes, createBaselineRegressionRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRunDepthRule, createRunDurationRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolUsageRule, defaultBundleOutputPath, defaultSuiteConfigTemplate, defineTraceContract, diffRuns, diffTraceEvents, enrichSessionRunRecord, escapeHtml, escapeMarkdown, evaluateTraceContract, extractMetadata, extractOutcomesFromTraceEvents, filterMetasBySessionScope, filterTraces, flattenTree, formatDuration2 as formatDuration, formatStepLabel, formatTimestamp, gateHasThresholds, getIndent, getTraceFilePath, inferEvidenceFileRole, isAgentInspectTrace, isAttributionConfidence, isCredentialSensitiveKey, isPersistedInspectEvent, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, manualTraceEventsToComparableRun, nanoid, normalizeBundleOutputPath, openTrace, parseCohortMetricList, parseDuration, parseDurationFilter, parseGateList, parseTraceJsonl, persistedInspectEventsToRunTrees, persistedInspectEventsToTraceEvents, projectLogicalEvents, renderActivitySummaryHuman, renderCohortReport, renderErrorLine, renderGateReport, renderObservedOutcomesHtml, renderObservedOutcomesMarkdown, renderRunDiff, renderRunWhat, renderStepLine, renderSuiteReport, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, runTraceChecks, safeString, sanitizeBundleRunId, searchTraces, serializeEvidenceManifest, sha256Hex, stableJson, stringContainsHighConfidenceCredential, summarizeObservedOutcomes, summarizeSemanticParity, traceEventToPersistedInspectEvent, truncateName, truncateStringForProfile, validateEvent, validateSuiteConfig, verifyEvidenceDirectory, zeroKinds };
16228
- //# sourceMappingURL=chunk-RLFYFWIZ.mjs.map
16229
- //# sourceMappingURL=chunk-RLFYFWIZ.mjs.map
16246
+ //# sourceMappingURL=chunk-Z3WXP44D.mjs.map
16247
+ //# sourceMappingURL=chunk-Z3WXP44D.mjs.map