agent-inspect 6.31.9 → 6.31.11

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/docs/NESTJS.md +56 -18
  4. package/package.json +1 -1
  5. package/packages/cli/dist/{chunk-SWUZRRDT.mjs → chunk-MQYHJL3W.mjs} +2216 -1938
  6. package/packages/cli/dist/chunk-MQYHJL3W.mjs.map +1 -0
  7. package/packages/cli/dist/index.cjs +975 -671
  8. package/packages/cli/dist/index.cjs.map +1 -1
  9. package/packages/cli/dist/index.mjs +32 -9
  10. package/packages/cli/dist/index.mjs.map +1 -1
  11. package/packages/cli/dist/{src-XFIPYODW.mjs → src-76R6E2LQ.mjs} +3 -3
  12. package/packages/cli/dist/{src-XFIPYODW.mjs.map → src-76R6E2LQ.mjs.map} +1 -1
  13. package/packages/core/dist/advanced.cjs +2079 -1879
  14. package/packages/core/dist/advanced.cjs.map +1 -1
  15. package/packages/core/dist/advanced.d.cts +56 -4
  16. package/packages/core/dist/advanced.d.ts +56 -4
  17. package/packages/core/dist/advanced.mjs +188 -23
  18. package/packages/core/dist/advanced.mjs.map +1 -1
  19. package/packages/core/dist/checks.cjs +126 -9
  20. package/packages/core/dist/checks.cjs.map +1 -1
  21. package/packages/core/dist/checks.d.cts +3 -3
  22. package/packages/core/dist/checks.d.ts +3 -3
  23. package/packages/core/dist/checks.mjs +3 -2
  24. package/packages/core/dist/{chunk-L5WLVBW4.mjs → chunk-AHUZNHFI.mjs} +4 -55
  25. package/packages/core/dist/chunk-AHUZNHFI.mjs.map +1 -0
  26. package/packages/core/dist/{chunk-2CCRUI42.mjs → chunk-CCYKNAOD.mjs} +119 -12
  27. package/packages/core/dist/chunk-CCYKNAOD.mjs.map +1 -0
  28. package/packages/core/dist/{chunk-7YYS742B.mjs → chunk-M3RJD3BP.mjs} +5 -5
  29. package/packages/core/dist/{chunk-7YYS742B.mjs.map → chunk-M3RJD3BP.mjs.map} +1 -1
  30. package/packages/core/dist/{chunk-2IRRUNIN.mjs → chunk-OAUNS5CS.mjs} +3 -3
  31. package/packages/core/dist/{chunk-2IRRUNIN.mjs.map → chunk-OAUNS5CS.mjs.map} +1 -1
  32. package/packages/core/dist/{chunk-IJJSPJXV.mjs → chunk-QOC3PJO3.mjs} +4 -4
  33. package/packages/core/dist/{chunk-IJJSPJXV.mjs.map → chunk-QOC3PJO3.mjs.map} +1 -1
  34. package/packages/core/dist/chunk-S6LQBLX5.mjs +67 -0
  35. package/packages/core/dist/chunk-S6LQBLX5.mjs.map +1 -0
  36. package/packages/core/dist/{chunk-3SPBELJB.mjs → chunk-SSG3ICI4.mjs} +16 -2
  37. package/packages/core/dist/chunk-SSG3ICI4.mjs.map +1 -0
  38. package/packages/core/dist/exporters.cjs +3 -3
  39. package/packages/core/dist/exporters.cjs.map +1 -1
  40. package/packages/core/dist/exporters.mjs +1 -1
  41. package/packages/core/dist/{index-EQihlEei.d.cts → index-DACU4Dy1.d.cts} +12 -0
  42. package/packages/core/dist/{index-CgOAGuM5.d.ts → index-b4tIGrzq.d.ts} +12 -0
  43. package/packages/core/dist/index.cjs +77 -0
  44. package/packages/core/dist/index.cjs.map +1 -1
  45. package/packages/core/dist/index.mjs +3 -2
  46. package/packages/core/dist/index.mjs.map +1 -1
  47. package/packages/core/dist/persisted.cjs +11 -0
  48. package/packages/core/dist/persisted.cjs.map +1 -1
  49. package/packages/core/dist/persisted.mjs +4 -3
  50. package/packages/core/dist/persisted.mjs.map +1 -1
  51. package/packages/core/dist/{programmatic-gZTWLObB.d.cts → programmatic-BLlC7Ytq.d.cts} +1 -1
  52. package/packages/core/dist/{programmatic-gZTWLObB.d.ts → programmatic-BLlC7Ytq.d.ts} +1 -1
  53. package/packages/core/dist/readers.cjs +11 -0
  54. package/packages/core/dist/readers.cjs.map +1 -1
  55. package/packages/core/dist/readers.d.cts +1 -1
  56. package/packages/core/dist/readers.d.ts +1 -1
  57. package/packages/core/dist/readers.mjs +4 -3
  58. package/packages/cli/dist/chunk-SWUZRRDT.mjs.map +0 -1
  59. package/packages/core/dist/chunk-2CCRUI42.mjs.map +0 -1
  60. package/packages/core/dist/chunk-3SPBELJB.mjs.map +0 -1
  61. package/packages/core/dist/chunk-L5WLVBW4.mjs.map +0 -1
@@ -72,6 +72,17 @@ var PROGRAMMATIC_DIAGNOSTIC_SPECS = Object.freeze({
72
72
  summary: "Trace contains a parentId cycle.",
73
73
  remediation: "Use visibility-first tree linking for legacy fixtures; prefer acyclic capture for new adapter output.",
74
74
  relatedCodes: ["structure.cycle"]
75
+ },
76
+ AI_TRACE_CONTRACT_INPUT_INVALID: {
77
+ code: "AI_TRACE_CONTRACT_INPUT_INVALID",
78
+ summary: "evaluateTraceContract expects ({ read }, contract) or use evaluateTraceContractRead(read, contract).",
79
+ remediation: "Pass TraceCheckInput as the first argument: evaluateTraceContract({ read }, contract).",
80
+ relatedCodes: ["AI_CHECK_INVALID_ARGUMENTS"]
81
+ },
82
+ AI_INSPECT_RUN_UNSUPPORTED_OPTION: {
83
+ code: "AI_INSPECT_RUN_UNSUPPORTED_OPTION",
84
+ summary: 'inspectRun does not accept a "writer" option.',
85
+ remediation: "Use createInspector({ writer }) then inspector.run(...). inspectRun persists via the global JSONL path (schema 0.1)."
75
86
  }
76
87
  });
77
88
  function formatProgrammaticDiagnostic(code, detail) {
@@ -3145,7 +3156,17 @@ function emptyPassResult(input, runId) {
3145
3156
  status: "pass",
3146
3157
  format: input.read.format,
3147
3158
  ...runId !== void 0 ? { runId } : {},
3148
- summary: { passed: 0, failed: 0, warnings: 0, errors: 0, rulesEvaluated: 0 },
3159
+ summary: {
3160
+ passed: 0,
3161
+ failed: 0,
3162
+ warnings: 0,
3163
+ errors: 0,
3164
+ rulesEvaluated: 0,
3165
+ rulesPassed: 0,
3166
+ rulesWarning: 0,
3167
+ rulesFailed: 0,
3168
+ rulesError: 0
3169
+ },
3149
3170
  findings: [],
3150
3171
  diagnostics: [],
3151
3172
  ruleExecutions: []
@@ -3173,7 +3194,11 @@ function mergeContractResults(input, parts, extraFindings = []) {
3173
3194
  (finding) => finding.status === "warning" || finding.severity === "warning"
3174
3195
  ).length,
3175
3196
  errors,
3176
- rulesEvaluated: ruleExecutions.length
3197
+ rulesEvaluated: ruleExecutions.length,
3198
+ rulesPassed: ruleExecutions.filter((item) => item.status === "pass").length,
3199
+ rulesWarning: ruleExecutions.filter((item) => item.status === "warning").length,
3200
+ rulesFailed: ruleExecutions.filter((item) => item.status === "fail").length,
3201
+ rulesError: ruleExecutions.filter((item) => item.status === "error").length
3177
3202
  },
3178
3203
  findings,
3179
3204
  diagnostics,
@@ -3221,7 +3246,76 @@ function defineTraceContract(input) {
3221
3246
  ...alternatives ? { alternatives } : {}
3222
3247
  };
3223
3248
  }
3249
+ function isTraceReadLike(value) {
3250
+ if (typeof value !== "object" || value === null) return false;
3251
+ const candidate = value;
3252
+ return typeof candidate.format === "string" && Array.isArray(candidate.runs) && Array.isArray(candidate.events);
3253
+ }
3254
+ function isTraceCheckInputLike(value) {
3255
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
3256
+ return false;
3257
+ }
3258
+ return isTraceReadLike(value.read);
3259
+ }
3260
+ function looksLikeTraceContract(value) {
3261
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
3262
+ return false;
3263
+ }
3264
+ if (isTraceReadLike(value) || isTraceCheckInputLike(value)) {
3265
+ return false;
3266
+ }
3267
+ return true;
3268
+ }
3269
+ function invalidContractInputResult() {
3270
+ return {
3271
+ ok: false,
3272
+ status: "error",
3273
+ format: "unknown",
3274
+ summary: {
3275
+ passed: 0,
3276
+ failed: 0,
3277
+ warnings: 0,
3278
+ errors: 1,
3279
+ rulesEvaluated: 0,
3280
+ rulesPassed: 0,
3281
+ rulesWarning: 0,
3282
+ rulesFailed: 0,
3283
+ rulesError: 0
3284
+ },
3285
+ findings: [],
3286
+ diagnostics: [
3287
+ {
3288
+ code: "AI_CHECK_INVALID_ARGUMENTS",
3289
+ message: formatProgrammaticDiagnostic("AI_TRACE_CONTRACT_INPUT_INVALID"),
3290
+ severity: "error"
3291
+ }
3292
+ ],
3293
+ ruleExecutions: []
3294
+ };
3295
+ }
3296
+ function validateEvaluateTraceContractArgs(input, contract) {
3297
+ if (isTraceCheckInputLike(input) && looksLikeTraceContract(contract)) {
3298
+ return void 0;
3299
+ }
3300
+ if (looksLikeTraceContract(input) && (isTraceCheckInputLike(contract) || isTraceReadLike(contract))) {
3301
+ return invalidContractInputResult();
3302
+ }
3303
+ if (isTraceReadLike(input)) {
3304
+ return invalidContractInputResult();
3305
+ }
3306
+ if (!isTraceCheckInputLike(input)) {
3307
+ return invalidContractInputResult();
3308
+ }
3309
+ if (!looksLikeTraceContract(contract)) {
3310
+ return invalidContractInputResult();
3311
+ }
3312
+ return void 0;
3313
+ }
3224
3314
  function evaluateTraceContract(input, contract, options = {}) {
3315
+ const inputGuard = validateEvaluateTraceContractArgs(input, contract);
3316
+ if (inputGuard !== void 0) {
3317
+ return inputGuard;
3318
+ }
3225
3319
  const shapeErrors = [
3226
3320
  ...validateAllowedStatusesShape(contract.run?.allowedStatuses),
3227
3321
  ...validateAlternativesShape(contract.alternatives),
@@ -3239,7 +3333,11 @@ function evaluateTraceContract(input, contract, options = {}) {
3239
3333
  failed: 0,
3240
3334
  warnings: 0,
3241
3335
  errors: shapeErrors.length,
3242
- rulesEvaluated: 0
3336
+ rulesEvaluated: 0,
3337
+ rulesPassed: 0,
3338
+ rulesWarning: 0,
3339
+ rulesFailed: 0,
3340
+ rulesError: 0
3243
3341
  },
3244
3342
  findings: [],
3245
3343
  diagnostics: shapeErrors.map((item) => ({
@@ -3264,7 +3362,11 @@ function evaluateTraceContract(input, contract, options = {}) {
3264
3362
  failed: 0,
3265
3363
  warnings: 0,
3266
3364
  errors: scoped.diagnostics.length,
3267
- rulesEvaluated: 0
3365
+ rulesEvaluated: 0,
3366
+ rulesPassed: 0,
3367
+ rulesWarning: 0,
3368
+ rulesFailed: 0,
3369
+ rulesError: 0
3268
3370
  },
3269
3371
  findings: [],
3270
3372
  diagnostics: scoped.diagnostics,
@@ -3360,6 +3462,9 @@ function evaluateTraceContract(input, contract, options = {}) {
3360
3462
  );
3361
3463
  }
3362
3464
  function evaluateTraceContractRead(read, contract, options = {}) {
3465
+ if (!isTraceReadLike(read) || !looksLikeTraceContract(contract)) {
3466
+ return invalidContractInputResult();
3467
+ }
3363
3468
  return evaluateTraceContract({ read }, contract, options);
3364
3469
  }
3365
3470
  function lintTraceContract(contract) {
@@ -3650,7 +3755,11 @@ function emptySummary() {
3650
3755
  failed: 0,
3651
3756
  warnings: 0,
3652
3757
  errors: 0,
3653
- rulesEvaluated: 0
3758
+ rulesEvaluated: 0,
3759
+ rulesPassed: 0,
3760
+ rulesWarning: 0,
3761
+ rulesFailed: 0,
3762
+ rulesError: 0
3654
3763
  };
3655
3764
  }
3656
3765
  function errorResult(input, diagnostics, selectedRun, ruleExecutions = []) {
@@ -3662,7 +3771,11 @@ function errorResult(input, diagnostics, selectedRun, ruleExecutions = []) {
3662
3771
  summary: {
3663
3772
  ...emptySummary(),
3664
3773
  errors: diagnostics.filter((item) => item.severity === "error").length,
3665
- rulesEvaluated: ruleExecutions.length
3774
+ rulesEvaluated: ruleExecutions.length,
3775
+ rulesPassed: ruleExecutions.filter((item) => item.status === "pass").length,
3776
+ rulesWarning: ruleExecutions.filter((item) => item.status === "warning").length,
3777
+ rulesFailed: ruleExecutions.filter((item) => item.status === "fail").length,
3778
+ rulesError: ruleExecutions.filter((item) => item.status === "error").length
3666
3779
  },
3667
3780
  findings: [],
3668
3781
  diagnostics: [...diagnostics],
@@ -3822,7 +3935,7 @@ function normalizeFinding(rule, finding) {
3822
3935
  ...finding.action !== void 0 ? { action: finding.action } : {}
3823
3936
  };
3824
3937
  }
3825
- function summarize(findings, diagnostics, rulesEvaluated) {
3938
+ function summarize(findings, diagnostics, ruleExecutions) {
3826
3939
  return {
3827
3940
  passed: findings.filter((finding) => finding.status === "pass").length,
3828
3941
  failed: findings.filter(
@@ -3832,7 +3945,11 @@ function summarize(findings, diagnostics, rulesEvaluated) {
3832
3945
  (finding) => finding.status === "warning" || finding.severity === "warning"
3833
3946
  ).length,
3834
3947
  errors: diagnostics.filter((item) => item.severity === "error").length,
3835
- rulesEvaluated
3948
+ rulesEvaluated: ruleExecutions.length,
3949
+ rulesPassed: ruleExecutions.filter((item) => item.status === "pass").length,
3950
+ rulesWarning: ruleExecutions.filter((item) => item.status === "warning").length,
3951
+ rulesFailed: ruleExecutions.filter((item) => item.status === "fail").length,
3952
+ rulesError: ruleExecutions.filter((item) => item.status === "error").length
3836
3953
  };
3837
3954
  }
3838
3955
  function classifyRuleExecution(findings, threw) {
@@ -5640,7 +5757,7 @@ function runTraceChecks(input, options = {}) {
5640
5757
  }
5641
5758
  const eventById = new Map(input.read.events.map((event) => [event.eventId, event]));
5642
5759
  const sortedFindings = findings.sort(compareFindings(eventById));
5643
- const summary = summarize(sortedFindings, diagnostics, ruleExecutions.length);
5760
+ const summary = summarize(sortedFindings, diagnostics, ruleExecutions);
5644
5761
  const status = summary.failed > 0 ? "fail" : "pass";
5645
5762
  return {
5646
5763
  ok: status === "pass",