@mcpjam/cli 4.0.0 → 4.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.js CHANGED
@@ -27,7 +27,7 @@ import { PostHog } from 'posthog-node';
27
27
 
28
28
  // package.json
29
29
  var package_default = {
30
- version: "4.0.0"};
30
+ version: "4.1.0"};
31
31
  function conformanceExitCode(result) {
32
32
  if (result.outcome === "incomplete") return 3;
33
33
  if (result.outcome === "failed") return 1;
@@ -5128,23 +5128,6 @@ function percentToFraction(percent) {
5128
5128
  if (!Number.isFinite(value)) return null;
5129
5129
  return plainDecimal(value) === normalized ? value : null;
5130
5130
  }
5131
- function fractionToPercent(fraction) {
5132
- if (!Number.isFinite(fraction)) return null;
5133
- const text = plainDecimal(fraction);
5134
- const match = /^(-?)(\d+)(?:\.(\d+))?$/.exec(text);
5135
- if (!match) return null;
5136
- const [, sign, whole, decimals = ""] = match;
5137
- const digits = `${whole}${decimals}`;
5138
- const newPoint = whole.length + 2;
5139
- const padded = digits.padEnd(newPoint, "0");
5140
- const shifted = newPoint >= padded.length ? `${padded}.0` : `${padded.slice(0, newPoint)}.${padded.slice(newPoint)}`;
5141
- const stripped = `${sign}${shifted}`.replace(/^(-?)0+(?=\d)/, "$1").replace(/\.?0+$/, "");
5142
- const normalized = stripped === "" || stripped === "-" ? "0" : stripped;
5143
- const value = Number(normalized);
5144
- if (!Number.isFinite(value)) return null;
5145
- if (plainDecimal(value) !== normalized) return null;
5146
- return percentToFraction(value) === fraction ? value : null;
5147
- }
5148
5131
  function plainDecimal(value) {
5149
5132
  const text = value.toString();
5150
5133
  const match = /^(-?)(\d)(?:\.(\d+))?e-(\d+)$/.exec(text);
@@ -5588,6 +5571,8 @@ function fileCaseToCreateBody(testCase) {
5588
5571
  title: testCase.title,
5589
5572
  steps: testCase.steps,
5590
5573
  iterations: testCase.repetitions,
5574
+ repetitions: testCase.repetitions,
5575
+ passThreshold: testCase.passThreshold,
5591
5576
  ...testCase.expectedOutput !== void 0 ? { expectedOutput: testCase.expectedOutput } : {},
5592
5577
  ...testCase.isNegativeTest ? { isNegative: true } : {},
5593
5578
  models: fileCaseModels(testCase),
@@ -5599,6 +5584,8 @@ function fileCaseToUpdateBody(testCase) {
5599
5584
  title: testCase.title,
5600
5585
  steps: testCase.steps,
5601
5586
  iterations: testCase.repetitions,
5587
+ repetitions: testCase.repetitions,
5588
+ passThreshold: testCase.passThreshold,
5602
5589
  expectedOutput: testCase.expectedOutput ?? "",
5603
5590
  isNegative: testCase.isNegativeTest,
5604
5591
  models: fileCaseModels(testCase),
@@ -5622,26 +5609,6 @@ function refuseUnsupportedHostedSemantics(loaded) {
5622
5609
  SUITE_FILE_RUN_INVALID_EXIT_CODE
5623
5610
  );
5624
5611
  }
5625
- const validity = loaded.authored.defaults.validity;
5626
- if (validity.minEligibleTrials !== void 0 || validity.minCompletionRate !== void 0 || validity.maxEvaluatorErrorRate !== void 0) {
5627
- throw cliError(
5628
- "VALIDITY_UNSUPPORTED",
5629
- "defaults.validity sets a gate the hosted runner does not enforce (minEligibleTrials, minCompletionRate, or maxEvaluatorErrorRate). A run could be reported as a pass or fail when the file would call it INVALID. Leave validity as {} \u2014 or run the suite locally.",
5630
- SUITE_FILE_RUN_INVALID_EXIT_CODE
5631
- );
5632
- }
5633
- }
5634
- function refusePerCasePassThreshold(loaded) {
5635
- const suiteThreshold = loaded.resolved.defaults.passThreshold;
5636
- for (const testCase of loaded.resolved.enabledCases) {
5637
- if (testCase.passThreshold !== suiteThreshold) {
5638
- throw cliError(
5639
- "CASE_PASS_THRESHOLD",
5640
- `Hosted runs grade every case against the suite's defaults.passThreshold (${suiteThreshold}); case "${testCase.id}" overrides passThreshold to ${testCase.passThreshold}. The platform has no per-case pass threshold, so this file is refused rather than graded against a different bar than it declares.`,
5641
- SUITE_FILE_RUN_INVALID_EXIT_CODE
5642
- );
5643
- }
5644
- }
5645
5612
  }
5646
5613
  function refuseRepetitions(loaded) {
5647
5614
  const suiteReps = loaded.resolved.defaults.repetitions;
@@ -5841,7 +5808,7 @@ function deriveFileRunIdempotencyKey(params) {
5841
5808
  environments: params.knobs.environment ?? (params.fileEnvironment ? [params.fileEnvironment] : null),
5842
5809
  hosts: params.knobs.host ?? null,
5843
5810
  allTargets: params.knobs.allTargets === true,
5844
- iterations: params.knobs.iterations ?? null,
5811
+ repetitions: params.knobs.repetitions ?? params.knobs.iterations ?? null,
5845
5812
  cases: params.knobs.case ?? null,
5846
5813
  excludeSkills: params.knobs.excludeSkills === true,
5847
5814
  refreshSnapshot: params.knobs.refreshSnapshot === true,
@@ -5905,17 +5872,8 @@ async function executeEvalRunFromFile(context, params) {
5905
5872
  throw suiteFileLoadError(params.label, loaded);
5906
5873
  }
5907
5874
  refuseRepetitions(loaded);
5908
- refusePerCasePassThreshold(loaded);
5909
5875
  refuseEmptyEnabledSet(loaded);
5910
5876
  refuseUnsupportedHostedSemantics(loaded);
5911
- const passPercent = fractionToPercent(loaded.resolved.defaults.passThreshold);
5912
- if (passPercent === null) {
5913
- throw cliError(
5914
- "PASS_THRESHOLD",
5915
- `defaults.passThreshold ${loaded.resolved.defaults.passThreshold} cannot be converted to a hosted percent without losing a digit.`,
5916
- SUITE_FILE_RUN_INVALID_EXIT_CODE
5917
- );
5918
- }
5919
5877
  const sourceHash = sha256HexOfBuffer(params.source.buffer);
5920
5878
  const authored = loaded.authored;
5921
5879
  const servers = authored.target.servers ?? [];
@@ -5928,6 +5886,12 @@ async function executeEvalRunFromFile(context, params) {
5928
5886
  ...authored.suite.description !== void 0 ? { description: authored.suite.description } : {},
5929
5887
  sourceHash,
5930
5888
  ...authored.provenance ? { provenance: authored.provenance } : {},
5889
+ verdictPolicyVersion: 2,
5890
+ verdictPolicyDefaults: {
5891
+ repetitions: loaded.resolved.defaults.repetitions,
5892
+ passThreshold: loaded.resolved.defaults.passThreshold,
5893
+ validity: loaded.resolved.defaults.validity
5894
+ },
5931
5895
  environment: {
5932
5896
  servers: servers.map((server) => server.name),
5933
5897
  ...servers.some((server) => server.id) ? {
@@ -5941,8 +5905,7 @@ async function executeEvalRunFromFile(context, params) {
5941
5905
  modelId: authored.defaults.model,
5942
5906
  ...authored.defaults.systemPrompt !== void 0 ? { systemPrompt: authored.defaults.systemPrompt } : {},
5943
5907
  ...authored.defaults.temperature !== void 0 ? { temperature: authored.defaults.temperature } : {}
5944
- },
5945
- defaultPassCriteria: { minimumPassRate: passPercent }
5908
+ }
5946
5909
  }
5947
5910
  },
5948
5911
  { signal: context.signal }
@@ -6010,7 +5973,7 @@ async function executeEvalRunFromFile(context, params) {
6010
5973
  ...knobs.environment?.length === 1 ? { environment: knobs.environment[0] } : knobs.environment?.length ? { environments: knobs.environment } : fileEnvironment ? { environment: fileEnvironment } : {},
6011
5974
  ...knobs.host?.length === 1 ? { host: knobs.host[0] } : knobs.host?.length ? { hosts: knobs.host } : fileHosts?.length === 1 ? { host: fileHosts[0] } : fileHosts?.length ? { hosts: fileHosts } : {},
6012
5975
  ...knobs.allTargets ? { allAttached: true } : {},
6013
- ...knobs.iterations !== void 0 ? { iterations: knobs.iterations } : {},
5976
+ ...knobs.repetitions !== void 0 || knobs.iterations !== void 0 ? { repetitions: knobs.repetitions ?? knobs.iterations } : {},
6014
5977
  cases: runCases,
6015
5978
  ...knobs.excludeSkills ? { excludeSkills: true } : {},
6016
5979
  ...knobs.refreshSnapshot ? { refreshSnapshot: true } : {},
@@ -6019,7 +5982,12 @@ async function executeEvalRunFromFile(context, params) {
6019
5982
  ...knobs.matchOptions ? { matchOptions: knobs.matchOptions } : {},
6020
5983
  ...knobs.compose ? { compose: knobs.compose } : {}
6021
5984
  },
6022
- { client: context.client, signal: context.signal }
5985
+ {
5986
+ client: context.client,
5987
+ signal: context.signal,
5988
+ onDisclosure: context.onDisclosure,
5989
+ onDisclosureUnavailable: context.onDisclosureUnavailable
5990
+ }
6023
5991
  );
6024
5992
  }
6025
5993
  var DEFAULT_CORPUS_LOCK_PATH = "mcpjam-evals.lock.json";
@@ -6224,6 +6192,9 @@ var NON_VERDICT_STATUSES = /* @__PURE__ */ new Set(["cancelled", "timed_out", "f
6224
6192
  function isNonVerdictRunStatus(status) {
6225
6193
  return status !== void 0 && NON_VERDICT_STATUSES.has(status);
6226
6194
  }
6195
+ function isNonVerdictRunResult(result) {
6196
+ return result === "inconclusive";
6197
+ }
6227
6198
  var EVAL_GATE_INCOMPLETE_EXIT_CODE = 3;
6228
6199
  var EVAL_GATE_USAGE_EXIT_CODE = 2;
6229
6200
  function parsePercent(raw, flag) {
@@ -6584,6 +6555,67 @@ function writeRunGroupSummary(format, webOrigin, result) {
6584
6555
  );
6585
6556
  }
6586
6557
  }
6558
+ function writeRunDisclosure(format, disclosure, stream = process.stdout) {
6559
+ if (format !== "human" || !disclosure) return;
6560
+ const lines = ["Pre-run disclosure:"];
6561
+ if (disclosure.execution) {
6562
+ const execution = disclosure.execution;
6563
+ const locus = execution.locus.known === true ? execution.locus.hosted ? "MCPJam-hosted" : "your own machine" : "unknown";
6564
+ lines.push(` Execution: ${execution.engine} \xB7 ${locus}`);
6565
+ if (execution.models.length > 0) {
6566
+ for (const model of execution.models) {
6567
+ const destination = model.byok?.baseUrlHost ? model.byok.baseUrlHost : model.rail.managed ? `${model.rail.possibleDestinations.join(" or ")} (currently: ${model.rail.outcomeIfRunNow.destination})` : model.tenantEgress;
6568
+ lines.push(` Model: ${model.modelId} \u2014 ${destination}`);
6569
+ }
6570
+ } else if (execution.modelsUnresolved) {
6571
+ lines.push(` Models: not derivable \u2014 ${execution.modelsUnresolved.reason}`);
6572
+ }
6573
+ if (execution.sandbox.engaged) {
6574
+ lines.push(` Sandbox: engaged (${execution.sandbox.vendor ?? "?"})`);
6575
+ }
6576
+ } else if (disclosure.executionAbsence) {
6577
+ const { kind, reason } = disclosure.executionAbsence;
6578
+ lines.push(
6579
+ kind === "ingested-run" ? ` Execution: none \u2014 this run was ingested, MCPJam did not execute it (${reason})` : ` Execution: not yet resolved \u2014 this run WILL execute and WILL call models, they are just not derivable yet (${reason})`
6580
+ );
6581
+ }
6582
+ lines.push(
6583
+ ` Capture: ${disclosure.capture.captureLevel} \xB7 reporting ${disclosure.capture.reportingMode}`
6584
+ );
6585
+ lines.push(
6586
+ ` Redaction: ${disclosure.capture.redaction.kind}` + (disclosure.capture.redaction.isDlp ? "" : ` \u2014 NOT a DLP system (${disclosure.capture.redaction.limitation})`)
6587
+ );
6588
+ lines.push(
6589
+ ` Export defaults: ${disclosure.capture.exportDefaults.includeContent ? "includes content" : "excludes content"} (${disclosure.capture.exportDefaults.note})`
6590
+ );
6591
+ const firingAnalysis = disclosure.analysis.filter(
6592
+ (touchpoint) => typeof touchpoint.fires === "string"
6593
+ );
6594
+ if (firingAnalysis.length > 0) {
6595
+ for (const touchpoint of firingAnalysis) {
6596
+ const firesLabel = touchpoint.fires === "auto-on-completion" ? "fires automatically on completion" : "fires only if explicitly requested";
6597
+ lines.push(
6598
+ ` Analysis: ${touchpoint.label} ${firesLabel}, may send evidence to ${touchpoint.destinations.join(", ")}`
6599
+ );
6600
+ }
6601
+ } else {
6602
+ lines.push(" Analysis: no analyzer/judge touchpoint can fire for this run");
6603
+ }
6604
+ lines.push(
6605
+ disclosure.retention.effectiveToday === "kept-indefinitely" ? " Retention: kept indefinitely" : ` Retention: swept after ${disclosure.retention.policyDays ?? "?"} day(s)`
6606
+ );
6607
+ lines.push(
6608
+ disclosure.region.stated ? ` Region: ${disclosure.region.value}` : " Region: not stated"
6609
+ );
6610
+ const engaged = disclosure.subprocessors.filter((entry) => entry.engaged);
6611
+ if (engaged.length > 0) {
6612
+ lines.push(
6613
+ ` Subprocessors: ${engaged.map((entry) => entry.vendor).join(", ")}`
6614
+ );
6615
+ }
6616
+ stream.write(`${lines.join("\n")}
6617
+ `);
6618
+ }
6587
6619
  function writeRunLink(format, webOrigin, run) {
6588
6620
  if (format !== "human") return;
6589
6621
  const suiteId = run.suiteId?.trim();
@@ -7014,7 +7046,7 @@ async function runEvalGate(options, command) {
7014
7046
  iterationError = error instanceof Error ? error.message : String(error);
7015
7047
  }
7016
7048
  }
7017
- if (isNonVerdictRunStatus(run.status)) {
7049
+ if (isNonVerdictRunStatus(run.status) || isNonVerdictRunResult(run.result)) {
7018
7050
  return {
7019
7051
  report: {
7020
7052
  outcome: "incomplete",
@@ -7023,7 +7055,7 @@ async function runEvalGate(options, command) {
7023
7055
  {
7024
7056
  gate: "run",
7025
7057
  status: "non_gateable",
7026
- message: `run is ${run.status}; no verdict was established`
7058
+ message: isNonVerdictRunResult(run.result) ? "run is inconclusive; no verdict was established" : `run is ${run.status}; no verdict was established`
7027
7059
  }
7028
7060
  ]
7029
7061
  },
@@ -7707,9 +7739,13 @@ function registerEvalCommands(program) {
7707
7739
  ).option(
7708
7740
  "--all-targets",
7709
7741
  "Run EVERY attached environment (or, if none, every attached host) \u2014 one PAID RUN per target"
7742
+ ).option(
7743
+ "--repetitions <n>",
7744
+ "Run each case this many times under verdict policy 2 (1-10)",
7745
+ (v) => parseIntOption(v, "--repetitions")
7710
7746
  ).option(
7711
7747
  "--iterations <n>",
7712
- "Run each case this many times (1-10)",
7748
+ "Deprecated alias for --repetitions",
7713
7749
  (v) => parseIntOption(v, "--iterations")
7714
7750
  ).option(
7715
7751
  "--case <id-or-title...>",
@@ -7768,6 +7804,11 @@ function registerEvalCommands(program) {
7768
7804
  if (!options.file && !options.suite) {
7769
7805
  throw usageError("Provide --suite <id-or-name> or --file <path>.");
7770
7806
  }
7807
+ if (options.repetitions !== void 0 && options.iterations !== void 0) {
7808
+ throw usageError(
7809
+ "Use either --repetitions or its deprecated --iterations alias, not both."
7810
+ );
7811
+ }
7771
7812
  if ((options.reporter !== void 0 || options.out !== void 0) && !options.wait) {
7772
7813
  throw usageError("--reporter and --out require --wait.");
7773
7814
  }
@@ -7784,10 +7825,28 @@ function registerEvalCommands(program) {
7784
7825
  globalOptions.timeout,
7785
7826
  (context) => {
7786
7827
  webOrigin = context.webOrigin;
7828
+ const onDisclosure = (disclosure) => {
7829
+ writeRunDisclosure(
7830
+ globalOptions.format,
7831
+ disclosure,
7832
+ reporter === void 0 ? process.stdout : process.stderr
7833
+ );
7834
+ };
7835
+ const onDisclosureUnavailable = (reason) => {
7836
+ if (globalOptions.format !== "human") return;
7837
+ const stream = reporter === void 0 ? process.stdout : process.stderr;
7838
+ stream.write(`Pre-run disclosure unavailable: ${reason}
7839
+ `);
7840
+ };
7787
7841
  if (options.file) {
7788
7842
  const source = readSuiteFileInput(options.file);
7789
7843
  return executeEvalRunFromFile(
7790
- { client: context.client, signal: context.signal },
7844
+ {
7845
+ client: context.client,
7846
+ signal: context.signal,
7847
+ onDisclosure,
7848
+ onDisclosureUnavailable
7849
+ },
7791
7850
  {
7792
7851
  source,
7793
7852
  label: options.file === "-" ? "<stdin>" : options.file,
@@ -7797,7 +7856,7 @@ function registerEvalCommands(program) {
7797
7856
  ...options.environment ? { environment: options.environment } : {},
7798
7857
  ...options.host ? { host: options.host } : {},
7799
7858
  ...options.allTargets ? { allTargets: true } : {},
7800
- ...options.iterations !== void 0 ? { iterations: options.iterations } : {},
7859
+ ...options.repetitions !== void 0 || options.iterations !== void 0 ? { repetitions: options.repetitions ?? options.iterations } : {},
7801
7860
  ...options.case?.length ? { case: options.case } : {},
7802
7861
  ...options.excludeSkills ? { excludeSkills: true } : {},
7803
7862
  ...options.refreshSnapshot ? { refreshSnapshot: true } : {},
@@ -7825,7 +7884,7 @@ function registerEvalCommands(program) {
7825
7884
  ...selectorField("environment", "environments", options.environment),
7826
7885
  ...selectorField("host", "hosts", options.host),
7827
7886
  ...options.allTargets ? { allAttached: true } : {},
7828
- ...options.iterations !== void 0 ? { iterations: options.iterations } : {},
7887
+ ...options.repetitions !== void 0 ? { repetitions: options.repetitions } : options.iterations !== void 0 ? { iterations: options.iterations } : {},
7829
7888
  ...options.case?.length ? { cases: options.case } : {},
7830
7889
  ...options.excludeSkills ? { excludeSkills: true } : {},
7831
7890
  ...options.refreshSnapshot ? { refreshSnapshot: true } : {},
@@ -7835,7 +7894,12 @@ function registerEvalCommands(program) {
7835
7894
  ...options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {},
7836
7895
  ...composeField(options)
7837
7896
  },
7838
- { client: context.client, signal: context.signal }
7897
+ {
7898
+ client: context.client,
7899
+ signal: context.signal,
7900
+ onDisclosure,
7901
+ onDisclosureUnavailable
7902
+ }
7839
7903
  );
7840
7904
  },
7841
7905
  { projectScope: resolved.projectScope }
@@ -8603,9 +8667,13 @@ function registerEvalCommands(program) {
8603
8667
  ).option(
8604
8668
  "--host <id-or-name>",
8605
8669
  "Attached host to run against, so the run is stamped with that host's config"
8670
+ ).option(
8671
+ "--repetitions <n>",
8672
+ "Run the case this many times under verdict policy 2 (1-10)",
8673
+ (v) => parseIntOption(v, "--repetitions")
8606
8674
  ).option(
8607
8675
  "--iterations <n>",
8608
- "Run the case this many times (1-10)",
8676
+ "Deprecated alias for --repetitions",
8609
8677
  (v) => parseIntOption(v, "--iterations")
8610
8678
  ).option(
8611
8679
  "--idempotency-key <key>",
@@ -8627,6 +8695,11 @@ function registerEvalCommands(program) {
8627
8695
  "Project-shared skill IDs to pin on the composed stack"
8628
8696
  ).action(
8629
8697
  async (options, command) => {
8698
+ if (options.repetitions !== void 0 && options.iterations !== void 0) {
8699
+ throw usageError(
8700
+ "Use either --repetitions or its deprecated --iterations alias, not both."
8701
+ );
8702
+ }
8630
8703
  await executeOp(
8631
8704
  runEvalCaseOperation,
8632
8705
  {
@@ -8636,7 +8709,7 @@ function registerEvalCommands(program) {
8636
8709
  ...options.server?.length ? { servers: options.server } : {},
8637
8710
  ...options.environment ? { environment: options.environment } : {},
8638
8711
  ...options.host ? { host: options.host } : {},
8639
- ...options.iterations !== void 0 ? { iterations: options.iterations } : {},
8712
+ ...options.repetitions !== void 0 ? { repetitions: options.repetitions } : options.iterations !== void 0 ? { iterations: options.iterations } : {},
8640
8713
  ...options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {},
8641
8714
  ...composeField(options)
8642
8715
  },