@agent-inspect/mcp-server 6.14.2 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7AL325ZU.mjs → chunk-JASWIBAT.mjs} +150 -10
- package/dist/chunk-JASWIBAT.mjs.map +1 -0
- package/dist/cli.cjs +148 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +148 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-7AL325ZU.mjs.map +0 -1
|
@@ -2568,6 +2568,59 @@ function diffRuns(left, right, options) {
|
|
|
2568
2568
|
return table;
|
|
2569
2569
|
})();
|
|
2570
2570
|
|
|
2571
|
+
// packages/core/src/diagnostics/programmatic.ts
|
|
2572
|
+
var PROGRAMMATIC_DIAGNOSTIC_SPECS = Object.freeze({
|
|
2573
|
+
AI_TRACE_INPUT_INVALID: {
|
|
2574
|
+
code: "AI_TRACE_INPUT_INVALID",
|
|
2575
|
+
summary: 'Expected { type: "file", path }, { type: "directory", path }, { type: "string", content }, { type: "buffer", content }, or { type: "stdin" }.',
|
|
2576
|
+
remediation: "For a file path, use openTraceFile(path).",
|
|
2577
|
+
relatedCodes: ["invalid_input"]
|
|
2578
|
+
},
|
|
2579
|
+
AI_TRACE_FORMAT_UNSUPPORTED: {
|
|
2580
|
+
code: "AI_TRACE_FORMAT_UNSUPPORTED",
|
|
2581
|
+
summary: "No trace reader could detect the input format.",
|
|
2582
|
+
remediation: "Pass an AgentInspect JSONL file via openTraceFile, or set options.format to a registered reader.",
|
|
2583
|
+
relatedCodes: ["unsupported_format"]
|
|
2584
|
+
},
|
|
2585
|
+
AI_TRACE_FORMAT_AMBIGUOUS: {
|
|
2586
|
+
code: "AI_TRACE_FORMAT_AMBIGUOUS",
|
|
2587
|
+
summary: "Multiple trace readers matched the input with equal confidence.",
|
|
2588
|
+
remediation: "Set options.format explicitly to disambiguate the reader.",
|
|
2589
|
+
relatedCodes: ["ambiguous_format"]
|
|
2590
|
+
},
|
|
2591
|
+
AI_TRACE_FACTS_INPUT_NOT_NORMALIZED: {
|
|
2592
|
+
code: "AI_TRACE_FACTS_INPUT_NOT_NORMALIZED",
|
|
2593
|
+
summary: "TraceFacts requires TraceReadResult or PersistedInspectEvent[].",
|
|
2594
|
+
remediation: "Use openTraceFile() to normalize a JSONL trace first."
|
|
2595
|
+
},
|
|
2596
|
+
AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED: {
|
|
2597
|
+
code: "AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED",
|
|
2598
|
+
summary: "Multiple runs are available; select a run before executing checks.",
|
|
2599
|
+
remediation: "Pass options.runId or TraceCheckInput.selectedRun.",
|
|
2600
|
+
relatedCodes: ["AI_CHECK_RUN_SELECTION_REQUIRED"]
|
|
2601
|
+
},
|
|
2602
|
+
AI_TRACE_RELATIONSHIP_SELF_PARENT: {
|
|
2603
|
+
code: "AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
2604
|
+
summary: "A parentId equals its own event/step id.",
|
|
2605
|
+
remediation: "Reject at capture (AI_LANGGRAPH_SELF_PARENT_REJECTED) or drop via logical projection; do not invent replacement parents.",
|
|
2606
|
+
relatedCodes: [
|
|
2607
|
+
"AI_LANGGRAPH_SELF_PARENT_REJECTED",
|
|
2608
|
+
"AI_LOGICAL_SELF_PARENT_REMOVED"
|
|
2609
|
+
]
|
|
2610
|
+
},
|
|
2611
|
+
AI_TRACE_RELATIONSHIP_CYCLE: {
|
|
2612
|
+
code: "AI_TRACE_RELATIONSHIP_CYCLE",
|
|
2613
|
+
summary: "Trace contains a parentId cycle.",
|
|
2614
|
+
remediation: "Use visibility-first tree linking for legacy fixtures; prefer acyclic capture for new adapter output.",
|
|
2615
|
+
relatedCodes: ["structure.cycle"]
|
|
2616
|
+
}
|
|
2617
|
+
});
|
|
2618
|
+
function formatProgrammaticDiagnostic(code, detail) {
|
|
2619
|
+
const spec = PROGRAMMATIC_DIAGNOSTIC_SPECS[code];
|
|
2620
|
+
const summary = detail?.trim() ? detail.trim() : spec.summary;
|
|
2621
|
+
return `${code}: ${summary} Remediation: ${spec.remediation}`;
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2571
2624
|
// packages/core/src/safety/sensitive-key.ts
|
|
2572
2625
|
function normalizeSensitiveKey(value) {
|
|
2573
2626
|
return value.toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
@@ -2833,7 +2886,10 @@ function projectLogicalEvents(events) {
|
|
|
2833
2886
|
if (originalParentId === event.eventId) {
|
|
2834
2887
|
diagnostics.push({
|
|
2835
2888
|
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
2836
|
-
message:
|
|
2889
|
+
message: formatProgrammaticDiagnostic(
|
|
2890
|
+
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
2891
|
+
`Removed self-parent edge on ${event.eventId}.`
|
|
2892
|
+
),
|
|
2837
2893
|
eventIds: [event.eventId]
|
|
2838
2894
|
});
|
|
2839
2895
|
const { parentId: _drop, ...rest } = event;
|
|
@@ -2865,7 +2921,10 @@ function projectLogicalEvents(events) {
|
|
|
2865
2921
|
if (nextParent === event.eventId) {
|
|
2866
2922
|
diagnostics.push({
|
|
2867
2923
|
code: "AI_LOGICAL_SELF_PARENT_REMOVED",
|
|
2868
|
-
message:
|
|
2924
|
+
message: formatProgrammaticDiagnostic(
|
|
2925
|
+
"AI_TRACE_RELATIONSHIP_SELF_PARENT",
|
|
2926
|
+
`Removed self-parent edge on ${event.eventId} (was ${originalParentId}).`
|
|
2927
|
+
),
|
|
2869
2928
|
eventIds: [event.eventId]
|
|
2870
2929
|
});
|
|
2871
2930
|
const { parentId: _drop, ...rest } = event;
|
|
@@ -2951,7 +3010,45 @@ function summarizeSemanticParity(events) {
|
|
|
2951
3010
|
diagnostics: projection.diagnostics
|
|
2952
3011
|
};
|
|
2953
3012
|
}
|
|
2954
|
-
|
|
3013
|
+
var TRACE_FACTS_INPUT_NOT_NORMALIZED = formatProgrammaticDiagnostic(
|
|
3014
|
+
"AI_TRACE_FACTS_INPUT_NOT_NORMALIZED"
|
|
3015
|
+
);
|
|
3016
|
+
function isTraceReadResult(input) {
|
|
3017
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
3018
|
+
return false;
|
|
3019
|
+
}
|
|
3020
|
+
const record = input;
|
|
3021
|
+
return Array.isArray(record.events) && Array.isArray(record.runs) && typeof record.format === "string" && Array.isArray(record.warnings);
|
|
3022
|
+
}
|
|
3023
|
+
function looksLikeRawV01TraceEvents(input) {
|
|
3024
|
+
if (!Array.isArray(input) || input.length === 0) return false;
|
|
3025
|
+
const first = input[0];
|
|
3026
|
+
if (typeof first !== "object" || first === null) return false;
|
|
3027
|
+
const row = first;
|
|
3028
|
+
return typeof row.event === "string" && (row.schemaVersion === "0.1" || row.eventId === void 0);
|
|
3029
|
+
}
|
|
3030
|
+
function isPersistedInspectEventArray(input) {
|
|
3031
|
+
if (!Array.isArray(input)) return false;
|
|
3032
|
+
if (input.length === 0) return true;
|
|
3033
|
+
const first = input[0];
|
|
3034
|
+
if (typeof first !== "object" || first === null) return false;
|
|
3035
|
+
const row = first;
|
|
3036
|
+
return typeof row.eventId === "string" && (row.schemaVersion === "0.2" || row.schemaVersion === "1.0" || row.schemaVersion === "0.1") && typeof row.event !== "string";
|
|
3037
|
+
}
|
|
3038
|
+
function resolveTraceFactsEvents(input) {
|
|
3039
|
+
if (isTraceReadResult(input)) {
|
|
3040
|
+
return input.events;
|
|
3041
|
+
}
|
|
3042
|
+
if (looksLikeRawV01TraceEvents(input)) {
|
|
3043
|
+
throw new TypeError(TRACE_FACTS_INPUT_NOT_NORMALIZED);
|
|
3044
|
+
}
|
|
3045
|
+
if (isPersistedInspectEventArray(input)) {
|
|
3046
|
+
return input;
|
|
3047
|
+
}
|
|
3048
|
+
throw new TypeError(TRACE_FACTS_INPUT_NOT_NORMALIZED);
|
|
3049
|
+
}
|
|
3050
|
+
function buildTraceFacts(input) {
|
|
3051
|
+
const events = resolveTraceFactsEvents(input);
|
|
2955
3052
|
const projection = projectLogicalEvents(events);
|
|
2956
3053
|
const toolsByName = /* @__PURE__ */ new Map();
|
|
2957
3054
|
const llmEvents = [];
|
|
@@ -3153,7 +3250,13 @@ function resolveSelectedRun(input, runId) {
|
|
|
3153
3250
|
if (input.read.runs.length === 0) {
|
|
3154
3251
|
return {
|
|
3155
3252
|
diagnostics: [
|
|
3156
|
-
diagnostic(
|
|
3253
|
+
diagnostic(
|
|
3254
|
+
"AI_CHECK_RUN_SELECTION_REQUIRED",
|
|
3255
|
+
formatProgrammaticDiagnostic(
|
|
3256
|
+
"AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED",
|
|
3257
|
+
"No runs are available for checks."
|
|
3258
|
+
)
|
|
3259
|
+
)
|
|
3157
3260
|
]
|
|
3158
3261
|
};
|
|
3159
3262
|
}
|
|
@@ -3161,7 +3264,7 @@ function resolveSelectedRun(input, runId) {
|
|
|
3161
3264
|
diagnostics: [
|
|
3162
3265
|
diagnostic(
|
|
3163
3266
|
"AI_CHECK_RUN_SELECTION_REQUIRED",
|
|
3164
|
-
"
|
|
3267
|
+
formatProgrammaticDiagnostic("AI_TRACE_CONTRACT_RUN_SELECTION_REQUIRED")
|
|
3165
3268
|
)
|
|
3166
3269
|
]
|
|
3167
3270
|
};
|
|
@@ -4307,6 +4410,38 @@ var TraceReadError = class extends Error {
|
|
|
4307
4410
|
this.warnings = warnings;
|
|
4308
4411
|
}
|
|
4309
4412
|
};
|
|
4413
|
+
var TRACE_INPUT_INVALID_MESSAGE = formatProgrammaticDiagnostic(
|
|
4414
|
+
"AI_TRACE_INPUT_INVALID"
|
|
4415
|
+
);
|
|
4416
|
+
function isTraceInput(input) {
|
|
4417
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
4418
|
+
return false;
|
|
4419
|
+
}
|
|
4420
|
+
const record = input;
|
|
4421
|
+
switch (record.type) {
|
|
4422
|
+
case "file":
|
|
4423
|
+
case "directory":
|
|
4424
|
+
return typeof record.path === "string";
|
|
4425
|
+
case "string":
|
|
4426
|
+
return typeof record.content === "string";
|
|
4427
|
+
case "buffer":
|
|
4428
|
+
return Buffer.isBuffer(record.content);
|
|
4429
|
+
case "stdin":
|
|
4430
|
+
return true;
|
|
4431
|
+
default:
|
|
4432
|
+
return false;
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
function assertTraceInput(input) {
|
|
4436
|
+
if (isTraceInput(input)) return;
|
|
4437
|
+
throw new TraceReadError("invalid_input", TRACE_INPUT_INVALID_MESSAGE, [
|
|
4438
|
+
{
|
|
4439
|
+
code: "AI_TRACE_INPUT_INVALID",
|
|
4440
|
+
message: TRACE_INPUT_INVALID_MESSAGE,
|
|
4441
|
+
severity: "error"
|
|
4442
|
+
}
|
|
4443
|
+
]);
|
|
4444
|
+
}
|
|
4310
4445
|
function normalizeCandidate(reader, candidate) {
|
|
4311
4446
|
const confidence = Number.isFinite(candidate.confidence) ? Math.max(0, Math.min(1, candidate.confidence)) : 0;
|
|
4312
4447
|
return {
|
|
@@ -5661,6 +5796,7 @@ var DEFAULT_TRACE_READERS = [
|
|
|
5661
5796
|
otlpJsonReader
|
|
5662
5797
|
];
|
|
5663
5798
|
async function detectTraceFormat(input, options = {}) {
|
|
5799
|
+
assertTraceInput(input);
|
|
5664
5800
|
const readers = options.readers ?? DEFAULT_TRACE_READERS;
|
|
5665
5801
|
if (options.format !== void 0) {
|
|
5666
5802
|
const reader = findReaderByFormat(options.format, readers);
|
|
@@ -5757,19 +5893,20 @@ async function detectTraceFormat(input, options = {}) {
|
|
|
5757
5893
|
};
|
|
5758
5894
|
}
|
|
5759
5895
|
async function readTrace(input, options = {}) {
|
|
5896
|
+
assertTraceInput(input);
|
|
5760
5897
|
const readers = options.readers ?? DEFAULT_TRACE_READERS;
|
|
5761
5898
|
const detection = await detectTraceFormat(input, options);
|
|
5762
5899
|
if (detection.status === "unsupported" || detection.format === void 0) {
|
|
5763
5900
|
throw new TraceReadError(
|
|
5764
5901
|
"unsupported_format",
|
|
5765
|
-
"
|
|
5902
|
+
formatProgrammaticDiagnostic("AI_TRACE_FORMAT_UNSUPPORTED"),
|
|
5766
5903
|
detection.warnings
|
|
5767
5904
|
);
|
|
5768
5905
|
}
|
|
5769
5906
|
if (detection.status === "ambiguous") {
|
|
5770
5907
|
throw new TraceReadError(
|
|
5771
5908
|
"ambiguous_format",
|
|
5772
|
-
"
|
|
5909
|
+
formatProgrammaticDiagnostic("AI_TRACE_FORMAT_AMBIGUOUS"),
|
|
5773
5910
|
detection.warnings
|
|
5774
5911
|
);
|
|
5775
5912
|
}
|
|
@@ -5777,7 +5914,10 @@ async function readTrace(input, options = {}) {
|
|
|
5777
5914
|
if (!reader) {
|
|
5778
5915
|
throw new TraceReadError(
|
|
5779
5916
|
"unsupported_format",
|
|
5780
|
-
|
|
5917
|
+
formatProgrammaticDiagnostic(
|
|
5918
|
+
"AI_TRACE_FORMAT_UNSUPPORTED",
|
|
5919
|
+
`No trace reader is registered for format "${detection.format}".`
|
|
5920
|
+
),
|
|
5781
5921
|
detection.warnings
|
|
5782
5922
|
);
|
|
5783
5923
|
}
|
|
@@ -7809,5 +7949,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
7809
7949
|
}
|
|
7810
7950
|
|
|
7811
7951
|
export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, READ_ONLY_TOOLS, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
|
|
7812
|
-
//# sourceMappingURL=chunk-
|
|
7813
|
-
//# sourceMappingURL=chunk-
|
|
7952
|
+
//# sourceMappingURL=chunk-JASWIBAT.mjs.map
|
|
7953
|
+
//# sourceMappingURL=chunk-JASWIBAT.mjs.map
|