@mcpjam/cli 4.2.0 → 5.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 +706 -152
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import { Command, CommanderError, Option } from 'commander';
|
|
3
3
|
import { realpathSync, readFileSync, existsSync, mkdirSync, writeFileSync, unlinkSync, statSync, closeSync, renameSync, openSync } from 'fs';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
-
import { probeMcpServer, redactForTelemetry, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, scoreFromAppsResult, MCPAppsConformanceSuite, MCPTasksConformanceTest, scoreFromTasksResult, runOAuthLogin, OAuthConformanceTest, scoreFromOAuthResult, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, scoreFromProtocolResult, MCPConformanceSuite, runConformance, isConformanceReportingConfigured, reportConformanceRun, reportConformanceRunSafely, OPENAI_SUBMISSION_MODES, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunHtml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, describeConformanceScore, toConformanceReport, buildConformanceRunReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, gatherClaudeReadinessEvidence, gradeClaudeReadiness, gatherOpenAIReadinessEvidence, xmldomParseXml, gradeOpenAIReadiness, openUrlInBrowser, buildEvalRunReport,
|
|
5
|
+
import { probeMcpServer, redactForTelemetry, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, scoreFromAppsResult, MCPAppsConformanceSuite, MCPTasksConformanceTest, scoreFromTasksResult, runOAuthLogin, OAuthConformanceTest, scoreFromOAuthResult, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, scoreFromProtocolResult, MCPConformanceSuite, runConformance, isConformanceReportingConfigured, reportConformanceRun, reportConformanceRunSafely, OPENAI_SUBMISSION_MODES, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunHtml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, describeConformanceScore, toConformanceReport, buildConformanceRunReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, gatherClaudeReadinessEvidence, gradeClaudeReadiness, gatherOpenAIReadinessEvidence, xmldomParseXml, gradeOpenAIReadiness, openUrlInBrowser, buildEvalRunReport, GATE_WAIVER_MAX_REASON_LENGTH, GATE_WAIVER_REASON_NOTICE, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, OPENAI_SUBMISSION_MODE_SHAPES, createDirectoryPluginFileSource, collectZipArchiveObservations, createZipPluginFileSource, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, loadEvalSuiteFile, formatEvalRunDecisionSummary, gateOutcomeVerdict, applyGateWaiver, formatGateReport, formatGateWaiverLine, detectFlakyCases, evaluateCompareGates, buildRunCompareReport, formatSuiteFileFindings, serializeEvalSuiteFile, MAX_SUITE_FILE_BYTES, buildCorpus, HostedOnlyCaseError, verifyCorpusLock, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, canonicalDigest, readEvalRunDecisionSummary as readEvalRunDecisionSummary$1, buildEvalRunDecisionSummary, evaluateGates, gateInputFromPlatformRun, isGateWaiverInForce, calculateLatencyStats, CORPUS_LOCK_VERSION, passRateFractionFromPercent, DEFAULT_MIN_EFFECT_SIZE, DEFAULT_MIN_SAMPLE_SIZE, suiteFilePointer, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
|
|
6
6
|
import path7, { join, dirname, basename } from 'path';
|
|
7
7
|
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
8
8
|
import { mkdir, writeFile, readFile, chmod, rename, rm, open, unlink, stat } from 'fs/promises';
|
|
9
9
|
import { spawn } from 'child_process';
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import os, { homedir } from 'os';
|
|
12
|
-
import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation,
|
|
12
|
+
import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createClientOperation, updateClientOperation, setClientServersOperation, duplicateClientOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, getCapabilitiesOperation, searchSessionsOperation, sendChatMessageOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getJourneyOperation, createJourneyOperation, updateJourneyOperation, archiveJourneyOperation, generateJourneysOperation, getSwarmOverviewOperation, getJourneyRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getWaveInsightsOperation, requestWaveInsightsOperation, cancelWaveInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, getUserTestingScenarioOperation, listUserTestingSessionsOperation, getUserTestingSessionOperation, getUserTestingMetricsOperation, getUserTestingUsageOperation, listUserTestingFindingsOperation, getUserTestingSignalsOperation, getUserTestingInsightsOperation, requestUserTestingInsightsOperation, cancelUserTestingInsightsOperation, dismissUserTestingFindingOperation, undismissUserTestingFindingOperation, updateUserTestingScenarioOperation, setUserTestingGuestExecutionOperation, rotateUserTestingLinkOperation, upsertUserTestingMemberOperation, removeUserTestingMemberOperation, rebindUserTestingScenarioOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
|
|
13
13
|
import { isDeepStrictEqual } from 'util';
|
|
14
14
|
import { MAX_BATCH_CREATE_CASES, evalSuiteFileSchema, isOpaqueId } from '@mcpjam/sdk/contract';
|
|
15
|
-
import { HOST_TEMPLATES
|
|
15
|
+
import { HOST_TEMPLATES, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
|
|
16
16
|
import http from 'http';
|
|
17
17
|
import https from 'https';
|
|
18
18
|
import { once } from 'events';
|
|
@@ -27,7 +27,7 @@ import { PostHog } from 'posthog-node';
|
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
29
|
var package_default = {
|
|
30
|
-
version: "
|
|
30
|
+
version: "5.1.0"};
|
|
31
31
|
function conformanceExitCode(result) {
|
|
32
32
|
if (result.outcome === "incomplete") return 3;
|
|
33
33
|
if (result.outcome === "failed") return 1;
|
|
@@ -603,7 +603,7 @@ function writeReporterResult(reporter, report) {
|
|
|
603
603
|
}
|
|
604
604
|
function writeEvalDecisionSummary(format, summary, destination = process.stdout) {
|
|
605
605
|
if (format !== "human" || !summary) return;
|
|
606
|
-
destination.write(`${
|
|
606
|
+
destination.write(`${formatEvalRunDecisionSummary(summary)}
|
|
607
607
|
`);
|
|
608
608
|
}
|
|
609
609
|
async function writeJsonArtifact(outputPath, payload) {
|
|
@@ -4336,6 +4336,13 @@ function hasCloudAncestor(command) {
|
|
|
4336
4336
|
function commandHasProjectOption(command) {
|
|
4337
4337
|
return command.options.some((option) => option.long === "--project");
|
|
4338
4338
|
}
|
|
4339
|
+
function writeHumanPermalinks(permalinks) {
|
|
4340
|
+
if (permalinks.length === 0) return;
|
|
4341
|
+
process.stdout.write(
|
|
4342
|
+
`${permalinks.map((permalink) => `View: ${permalink.url}`).join("\n")}
|
|
4343
|
+
`
|
|
4344
|
+
);
|
|
4345
|
+
}
|
|
4339
4346
|
function bindOperation(command, operation, buildInput, bindExtras = {}) {
|
|
4340
4347
|
if (!hasCloudAncestor(command)) {
|
|
4341
4348
|
addPlatformOptions(command);
|
|
@@ -4350,13 +4357,37 @@ function bindOperation(command, operation, buildInput, bindExtras = {}) {
|
|
|
4350
4357
|
const applyAmbient = (underCloud || bindExtras.ambientProject === true) && commandHasProjectOption(invoked);
|
|
4351
4358
|
const resolved = applyAmbient ? resolveCloudProjectArgs({ project: merged.project }) : void 0;
|
|
4352
4359
|
const inputOptions = resolved ? { ...options, project: resolved.project } : options;
|
|
4360
|
+
let permalinks = [];
|
|
4353
4361
|
const result = await runPlatformOperation(
|
|
4354
4362
|
platformOptionsOf(invoked),
|
|
4355
4363
|
globalOptions.timeout,
|
|
4356
|
-
({ client, signal }) =>
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4364
|
+
async ({ client, signal, webOrigin }) => {
|
|
4365
|
+
const input = buildInput(inputOptions, ...positionals);
|
|
4366
|
+
if (!operation.permalink || !operation.name) {
|
|
4367
|
+
return operation.execute(input, { client, signal });
|
|
4368
|
+
}
|
|
4369
|
+
const ran = await runOperationWithPermalinks(
|
|
4370
|
+
{
|
|
4371
|
+
name: operation.name,
|
|
4372
|
+
permalink: operation.permalink,
|
|
4373
|
+
execute: operation.execute
|
|
4374
|
+
},
|
|
4375
|
+
input,
|
|
4376
|
+
{ client, signal },
|
|
4377
|
+
{
|
|
4378
|
+
appOrigin: webOrigin,
|
|
4379
|
+
// stderr, so `--format json` stdout stays a parseable contract.
|
|
4380
|
+
onError: (error, operationName) => {
|
|
4381
|
+
process.stderr.write(
|
|
4382
|
+
`mcpjam: could not build a permalink for ${operationName}: ${error instanceof Error ? error.message : String(error)}
|
|
4383
|
+
`
|
|
4384
|
+
);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
);
|
|
4388
|
+
permalinks = ran.permalinks;
|
|
4389
|
+
return ran.result;
|
|
4390
|
+
},
|
|
4360
4391
|
{
|
|
4361
4392
|
announce: bindExtras.announce ?? underCloud,
|
|
4362
4393
|
quiet: globalOptions.quiet,
|
|
@@ -4366,12 +4397,20 @@ function bindOperation(command, operation, buildInput, bindExtras = {}) {
|
|
|
4366
4397
|
} : bindExtras.cloudScope ? { cloudScope: bindExtras.cloudScope } : {}
|
|
4367
4398
|
}
|
|
4368
4399
|
);
|
|
4369
|
-
if (
|
|
4370
|
-
|
|
4400
|
+
if (globalOptions.format === "human") {
|
|
4401
|
+
if (bindExtras.formatHuman) {
|
|
4402
|
+
process.stdout.write(`${bindExtras.formatHuman(result)}
|
|
4371
4403
|
`);
|
|
4404
|
+
} else {
|
|
4405
|
+
writeResult(result, globalOptions.format);
|
|
4406
|
+
}
|
|
4407
|
+
writeHumanPermalinks(permalinks);
|
|
4372
4408
|
return;
|
|
4373
4409
|
}
|
|
4374
|
-
writeResult(
|
|
4410
|
+
writeResult(
|
|
4411
|
+
permalinks.length > 0 ? withPermalinkEnvelope(result, permalinks) : result,
|
|
4412
|
+
globalOptions.format
|
|
4413
|
+
);
|
|
4375
4414
|
});
|
|
4376
4415
|
}
|
|
4377
4416
|
async function runCloudOp(command, options, execute, extra = {}) {
|
|
@@ -6180,6 +6219,14 @@ function evalGateExitCode(report) {
|
|
|
6180
6219
|
switch (report.outcome) {
|
|
6181
6220
|
case "passed":
|
|
6182
6221
|
return 0;
|
|
6222
|
+
// An authorized, recorded, time-boxed override of a real failure. Exit 0,
|
|
6223
|
+
// because unblocking the release is what a waiver is FOR — but it reaches
|
|
6224
|
+
// 0 by its own named outcome rather than by being turned into `passed`
|
|
6225
|
+
// upstream, so nothing downstream has to reconstruct which of the two
|
|
6226
|
+
// happened. The report, and every artifact built from it, still says the
|
|
6227
|
+
// gate failed and was waived.
|
|
6228
|
+
case "waived":
|
|
6229
|
+
return 0;
|
|
6183
6230
|
case "failed":
|
|
6184
6231
|
return 1;
|
|
6185
6232
|
case "usage_error":
|
|
@@ -6439,20 +6486,79 @@ function assertRunIdBaseline(baseline, runId) {
|
|
|
6439
6486
|
}
|
|
6440
6487
|
if (SHA_LIKE_BASELINE.test(normalized)) {
|
|
6441
6488
|
throw usageError(
|
|
6442
|
-
`--baseline "${baseline}" looks like a git SHA.
|
|
6489
|
+
`--baseline "${baseline}" looks like a git commit SHA. Pass it as --baseline-sha to pin the baseline by source SHA, or pass a run id to --baseline.`
|
|
6443
6490
|
);
|
|
6444
6491
|
}
|
|
6445
6492
|
return normalized;
|
|
6446
6493
|
}
|
|
6494
|
+
function assertCommitShaBaseline(baselineSha) {
|
|
6495
|
+
const normalized = baselineSha.trim();
|
|
6496
|
+
if (normalized === "") {
|
|
6497
|
+
throw usageError(
|
|
6498
|
+
`--baseline-sha must not be blank. Pass a commit SHA, or omit the flag entirely to gate on absolute thresholds only.`
|
|
6499
|
+
);
|
|
6500
|
+
}
|
|
6501
|
+
return normalized;
|
|
6502
|
+
}
|
|
6503
|
+
function resolveBaselineSelector(input) {
|
|
6504
|
+
if (input.baseline !== void 0 && input.baselineSha !== void 0) {
|
|
6505
|
+
throw usageError(
|
|
6506
|
+
`--baseline and --baseline-sha are mutually exclusive. Pass a run id to --baseline, or a source commit SHA to --baseline-sha, not both.`
|
|
6507
|
+
);
|
|
6508
|
+
}
|
|
6509
|
+
if (input.baselineSha !== void 0) {
|
|
6510
|
+
return {
|
|
6511
|
+
kind: "commitSha",
|
|
6512
|
+
commitSha: assertCommitShaBaseline(input.baselineSha)
|
|
6513
|
+
};
|
|
6514
|
+
}
|
|
6515
|
+
if (input.baseline !== void 0) {
|
|
6516
|
+
return {
|
|
6517
|
+
kind: "run",
|
|
6518
|
+
runId: assertRunIdBaseline(input.baseline, input.runId)
|
|
6519
|
+
};
|
|
6520
|
+
}
|
|
6521
|
+
return void 0;
|
|
6522
|
+
}
|
|
6523
|
+
function compareBaseSelector(input) {
|
|
6524
|
+
if (input.baseRun !== void 0 && input.baseSha !== void 0) {
|
|
6525
|
+
throw usageError(
|
|
6526
|
+
`--base-run and --base-sha are mutually exclusive. Pass a run id to --base-run, or a source commit SHA to --base-sha, not both.`
|
|
6527
|
+
);
|
|
6528
|
+
}
|
|
6529
|
+
if (input.baseSha !== void 0) {
|
|
6530
|
+
const normalized = input.baseSha.trim();
|
|
6531
|
+
if (normalized === "") {
|
|
6532
|
+
throw usageError(
|
|
6533
|
+
`--base-sha must not be blank. Pass a commit SHA, or omit the flag to compare against the nearest earlier completed run.`
|
|
6534
|
+
);
|
|
6535
|
+
}
|
|
6536
|
+
return { baseCommitSha: normalized };
|
|
6537
|
+
}
|
|
6538
|
+
if (input.baseRun !== void 0) {
|
|
6539
|
+
const normalized = input.baseRun.trim();
|
|
6540
|
+
if (normalized === "") {
|
|
6541
|
+
throw usageError(
|
|
6542
|
+
`--base-run must not be blank. Pass a run id, or omit the flag to compare against the nearest earlier completed run.`
|
|
6543
|
+
);
|
|
6544
|
+
}
|
|
6545
|
+
return { baseRunId: normalized };
|
|
6546
|
+
}
|
|
6547
|
+
return {};
|
|
6548
|
+
}
|
|
6549
|
+
function baselineCompareParams(baseline) {
|
|
6550
|
+
return baseline.kind === "run" ? { baseRunId: baseline.runId } : { baseCommitSha: baseline.commitSha };
|
|
6551
|
+
}
|
|
6447
6552
|
function comparePolicyFromGateOptions(options) {
|
|
6448
6553
|
const hasComparativeFlag = options.minSampleSize !== void 0 || options.minEffectSizePercent !== void 0 || options.gateDeterministicRegressions === true || options.maxP95LatencyIncreaseMs !== void 0;
|
|
6449
|
-
|
|
6554
|
+
const hasBaseline = Boolean(options.baseline) || Boolean(options.baselineSha);
|
|
6555
|
+
if (hasComparativeFlag && !hasBaseline) {
|
|
6450
6556
|
throw usageError(
|
|
6451
|
-
"--min-sample-size, --min-effect-size-percent, --gate-deterministic-regressions, and --max-p95-latency-increase-ms tune the baseline regression gate; pass --baseline to enable it."
|
|
6557
|
+
"--min-sample-size, --min-effect-size-percent, --gate-deterministic-regressions, and --max-p95-latency-increase-ms tune the baseline regression gate; pass --baseline or --baseline-sha to enable it."
|
|
6452
6558
|
);
|
|
6453
6559
|
}
|
|
6454
6560
|
return comparePolicyFromOptions({
|
|
6455
|
-
gateRegressions:
|
|
6561
|
+
gateRegressions: hasBaseline,
|
|
6456
6562
|
minSampleSize: options.minSampleSize,
|
|
6457
6563
|
minEffectSizePercent: options.minEffectSizePercent,
|
|
6458
6564
|
gateDeterministicRegressions: options.gateDeterministicRegressions,
|
|
@@ -6465,6 +6571,15 @@ function baselineNotFoundReason(error) {
|
|
|
6465
6571
|
}
|
|
6466
6572
|
var OUTCOME_RANK = {
|
|
6467
6573
|
passed: 0,
|
|
6574
|
+
// UNREACHABLE by construction: a waiver is folded in by `applyGateWaiver`
|
|
6575
|
+
// AFTER the two halves are merged, so no input to this function can carry
|
|
6576
|
+
// it. Ranked with `passed` rather than left to a lookup miss (`undefined`,
|
|
6577
|
+
// whose every comparison is false, would silently pin the merged outcome to
|
|
6578
|
+
// whichever side was evaluated first) — and ranked LOWEST deliberately: if
|
|
6579
|
+
// one half were ever waived, an unwaived failure on the other half must
|
|
6580
|
+
// still win. A waiver granted over the threshold gate is not consent to
|
|
6581
|
+
// ship a baseline regression.
|
|
6582
|
+
waived: 0,
|
|
6468
6583
|
incomplete: 1,
|
|
6469
6584
|
failed: 2,
|
|
6470
6585
|
usage_error: 3
|
|
@@ -6502,8 +6617,23 @@ function buildBaselineProvenance(requestedBaseline, compare, input, policy) {
|
|
|
6502
6617
|
compare.scoreContract.evaluationConfigChanged
|
|
6503
6618
|
)
|
|
6504
6619
|
}));
|
|
6620
|
+
const requested = {
|
|
6621
|
+
requestedBaselineKind: requestedBaseline.kind,
|
|
6622
|
+
...requestedBaseline.kind === "run" ? { requestedBaselineRunId: requestedBaseline.runId } : { requestedBaselineCommitSha: requestedBaseline.commitSha },
|
|
6623
|
+
// The RESOLVED source SHA as the backend echoed it, kept separate from
|
|
6624
|
+
// the requested one: a mixed-version backend can resolve without echoing,
|
|
6625
|
+
// and silently presenting the request as the answer would fabricate
|
|
6626
|
+
// confirmation the server never gave.
|
|
6627
|
+
...typeof compare.baseline.baseCommitSha === "string" ? { resolvedBaselineCommitSha: compare.baseline.baseCommitSha } : {}
|
|
6628
|
+
};
|
|
6629
|
+
const ambiguity = typeof compare.baseline.matchCount === "number" ? {
|
|
6630
|
+
baselineMatchCount: compare.baseline.matchCount,
|
|
6631
|
+
baselineMatchCountTruncated: compare.baseline.matchCountTruncated === true,
|
|
6632
|
+
baselineMatchUnique: false
|
|
6633
|
+
} : { baselineMatchUnique: true };
|
|
6505
6634
|
return {
|
|
6506
|
-
|
|
6635
|
+
...requested,
|
|
6636
|
+
...ambiguity,
|
|
6507
6637
|
baseline: compare.baseline,
|
|
6508
6638
|
baseRunId: compare.baseRun.id,
|
|
6509
6639
|
compareRunId: compare.compareRun.id,
|
|
@@ -6554,7 +6684,9 @@ async function evaluateBaselineComparison(input) {
|
|
|
6554
6684
|
{
|
|
6555
6685
|
projectId: input.projectId,
|
|
6556
6686
|
runId: input.runId,
|
|
6557
|
-
baseRunId
|
|
6687
|
+
// Exactly ONE of `baseRunId` / `baseCommitSha` — sending both is a 400
|
|
6688
|
+
// at the route and at the action alike.
|
|
6689
|
+
...baselineCompareParams(input.baseline)
|
|
6558
6690
|
},
|
|
6559
6691
|
{ signal: input.signal }
|
|
6560
6692
|
);
|
|
@@ -6628,6 +6760,40 @@ async function evaluateBaselineComparison(input) {
|
|
|
6628
6760
|
)
|
|
6629
6761
|
};
|
|
6630
6762
|
}
|
|
6763
|
+
function activeWaiverForRun(run, now = Date.now()) {
|
|
6764
|
+
const waiver = run?.gateWaiver;
|
|
6765
|
+
if (!waiver) return void 0;
|
|
6766
|
+
if (waiver.active !== true) return void 0;
|
|
6767
|
+
if (waiver.revokedAt !== null) return void 0;
|
|
6768
|
+
if (!isGateWaiverInForce(waiver, now)) return void 0;
|
|
6769
|
+
return {
|
|
6770
|
+
id: waiver.id,
|
|
6771
|
+
reason: waiver.reason,
|
|
6772
|
+
expiresAt: waiver.expiresAt,
|
|
6773
|
+
createdAt: waiver.createdAt,
|
|
6774
|
+
createdBy: waiver.createdBy,
|
|
6775
|
+
createdByEmail: waiver.createdByEmail,
|
|
6776
|
+
policySnapshot: waiver.policySnapshot
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
var DURATION_UNIT_MS = {
|
|
6780
|
+
m: 6e4,
|
|
6781
|
+
h: 36e5,
|
|
6782
|
+
d: 864e5
|
|
6783
|
+
};
|
|
6784
|
+
function parseWaiverExpiry(raw, now = Date.now()) {
|
|
6785
|
+
const match = /^(\d+)\s*([mhd])$/i.exec(raw.trim());
|
|
6786
|
+
if (!match) {
|
|
6787
|
+
throw usageError(
|
|
6788
|
+
`--expires-in must be a duration like 30m, 12h, or 7d, got "${raw}".`
|
|
6789
|
+
);
|
|
6790
|
+
}
|
|
6791
|
+
const amount = Number(match[1]);
|
|
6792
|
+
if (!Number.isFinite(amount) || amount <= 0) {
|
|
6793
|
+
throw usageError(`--expires-in must be greater than zero, got "${raw}".`);
|
|
6794
|
+
}
|
|
6795
|
+
return now + amount * DURATION_UNIT_MS[match[2].toLowerCase()];
|
|
6796
|
+
}
|
|
6631
6797
|
|
|
6632
6798
|
// src/lib/eval-run-exit-code.ts
|
|
6633
6799
|
var SEVERITY_ORDER = [1, 3, 4, 5, 0];
|
|
@@ -6698,6 +6864,19 @@ function classifyWaitErrorExitCode(code) {
|
|
|
6698
6864
|
if (code !== void 0 && AUTH_SHAPED_CODES.has(code)) return 3;
|
|
6699
6865
|
return 5;
|
|
6700
6866
|
}
|
|
6867
|
+
function decisionSummaryFromIterations(input) {
|
|
6868
|
+
return buildEvalRunDecisionSummary({
|
|
6869
|
+
projectId: input.projectId,
|
|
6870
|
+
run: input.run,
|
|
6871
|
+
iterations: input.iterations.items,
|
|
6872
|
+
page: { complete: input.iterations.complete }
|
|
6873
|
+
});
|
|
6874
|
+
}
|
|
6875
|
+
async function readEvalRunDecisionSummary(client, signal, projectId, run) {
|
|
6876
|
+
return readEvalRunDecisionSummary$1(client, signal, projectId, run, {
|
|
6877
|
+
limit: 200
|
|
6878
|
+
});
|
|
6879
|
+
}
|
|
6701
6880
|
|
|
6702
6881
|
// src/lib/terminal-image.ts
|
|
6703
6882
|
var ESC = "\x1B";
|
|
@@ -6910,14 +7089,24 @@ function writeRunLink(format, webOrigin, run) {
|
|
|
6910
7089
|
if (format !== "human") return;
|
|
6911
7090
|
const suiteId = run.suiteId?.trim();
|
|
6912
7091
|
const runId = run.runId?.trim();
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
7092
|
+
const projectId = run.projectId?.trim();
|
|
7093
|
+
if (!suiteId || !runId || !projectId) return;
|
|
7094
|
+
let permalink;
|
|
7095
|
+
try {
|
|
7096
|
+
permalink = buildAppPermalink(
|
|
7097
|
+
{
|
|
7098
|
+
type: "eval_run",
|
|
7099
|
+
id: runId,
|
|
7100
|
+
parent: { type: "eval_suite", id: suiteId },
|
|
7101
|
+
projectId
|
|
7102
|
+
},
|
|
7103
|
+
{ appOrigin: webOrigin }
|
|
7104
|
+
);
|
|
7105
|
+
} catch {
|
|
7106
|
+
return;
|
|
7107
|
+
}
|
|
7108
|
+
process.stdout.write(`View: ${permalink.url}
|
|
7109
|
+
`);
|
|
6921
7110
|
}
|
|
6922
7111
|
var JUDGE_LABELS = [
|
|
6923
7112
|
["goalCompletion", "goal completion"],
|
|
@@ -7242,10 +7431,11 @@ function launchFailureCases(result) {
|
|
|
7242
7431
|
});
|
|
7243
7432
|
}
|
|
7244
7433
|
function gateReportCase(report, baselineProvenance) {
|
|
7245
|
-
const
|
|
7434
|
+
const waived = report.outcome === "waived";
|
|
7435
|
+
const passed = report.outcome === "passed" || waived;
|
|
7246
7436
|
return {
|
|
7247
7437
|
id: "gate",
|
|
7248
|
-
title: "Eval gate",
|
|
7438
|
+
title: waived ? "Eval gate (WAIVED)" : "Eval gate",
|
|
7249
7439
|
category: "gate",
|
|
7250
7440
|
passed,
|
|
7251
7441
|
// Only a real FAILED gate is a confirmed regression. `incomplete` and
|
|
@@ -7253,10 +7443,26 @@ function gateReportCase(report, baselineProvenance) {
|
|
|
7253
7443
|
// way), but reporting them as `breaking` — the same class a genuine
|
|
7254
7444
|
// failure gets — would claim a defect the run never observed. Mirrors
|
|
7255
7445
|
// `gateCase` in sdk/src/run-compare.ts.
|
|
7256
|
-
classification: report.outcome === "failed" ? "breaking" : passed ? "non_breaking" : "informational",
|
|
7257
|
-
|
|
7258
|
-
|
|
7446
|
+
classification: report.outcome === "failed" ? "breaking" : waived ? "informational" : passed ? "non_breaking" : "informational",
|
|
7447
|
+
// The failing verdicts are carried on a WAIVED case too. The waiver
|
|
7448
|
+
// explains why the build was not blocked; it is not a reason to stop
|
|
7449
|
+
// saying what failed.
|
|
7450
|
+
...passed && !waived ? {} : {
|
|
7451
|
+
error: report.verdicts.filter(
|
|
7452
|
+
(verdict) => verdict.status !== "passed" && verdict.status !== "waived"
|
|
7453
|
+
).map((verdict) => verdict.message).join("; ")
|
|
7259
7454
|
},
|
|
7455
|
+
...report.waiver ? {
|
|
7456
|
+
waiver: {
|
|
7457
|
+
id: report.waiver.id,
|
|
7458
|
+
reason: report.waiver.reason,
|
|
7459
|
+
expiresAt: report.waiver.expiresAt,
|
|
7460
|
+
createdAt: report.waiver.createdAt,
|
|
7461
|
+
createdBy: report.waiver.createdBy,
|
|
7462
|
+
createdByEmail: report.waiver.createdByEmail,
|
|
7463
|
+
policySnapshot: report.waiver.policySnapshot
|
|
7464
|
+
}
|
|
7465
|
+
} : {},
|
|
7260
7466
|
// The baseline provenance rides along on the case row too, not only in
|
|
7261
7467
|
// the report's top-level metadata: `--reporter junit-xml` has no other
|
|
7262
7468
|
// place to carry it, and a regression visible in the exit code but
|
|
@@ -7267,13 +7473,21 @@ function gateReportCase(report, baselineProvenance) {
|
|
|
7267
7473
|
var DEFAULT_GATE_WAIT_TIMEOUT_MS = 6e5;
|
|
7268
7474
|
async function runEvalGate(options, command) {
|
|
7269
7475
|
const globalOptions = getGlobalOptions(command);
|
|
7476
|
+
const runId = options.run?.trim();
|
|
7477
|
+
if (!runId) {
|
|
7478
|
+
throw usageError("--run <id> is required. Pass the eval run to gate.");
|
|
7479
|
+
}
|
|
7270
7480
|
const reporter = parseReporterFormat(options.reporter);
|
|
7271
7481
|
const needsReport = reporter !== void 0 || options.out !== void 0;
|
|
7272
7482
|
const policy = policyFromOptions({
|
|
7273
7483
|
...options,
|
|
7274
7484
|
noGatingScoreErrors: options.gatingScoreErrors === false
|
|
7275
7485
|
});
|
|
7276
|
-
const baseline =
|
|
7486
|
+
const baseline = resolveBaselineSelector({
|
|
7487
|
+
baseline: options.baseline,
|
|
7488
|
+
baselineSha: options.baselineSha,
|
|
7489
|
+
runId
|
|
7490
|
+
});
|
|
7277
7491
|
const comparePolicy = comparePolicyFromGateOptions(options);
|
|
7278
7492
|
const waitTimeoutMs = options.waitTimeout !== void 0 ? parsePositiveInteger(options.waitTimeout, "--wait-timeout") : DEFAULT_GATE_WAIT_TIMEOUT_MS;
|
|
7279
7493
|
const resolved = resolveCloudProjectArgs(options);
|
|
@@ -7294,11 +7508,17 @@ async function runEvalGate(options, command) {
|
|
|
7294
7508
|
const project = resolution.project;
|
|
7295
7509
|
const deadline = Date.now() + waitTimeoutMs;
|
|
7296
7510
|
let run = await client.getEvalRun(
|
|
7297
|
-
{ projectId: project.id, runId
|
|
7511
|
+
{ projectId: project.id, runId },
|
|
7298
7512
|
{ signal }
|
|
7299
7513
|
);
|
|
7300
7514
|
while (!TERMINAL_RUN_STATUSES.has(run.status)) {
|
|
7301
7515
|
if (!options.wait) {
|
|
7516
|
+
decisionSummary = await readEvalRunDecisionSummary(
|
|
7517
|
+
client,
|
|
7518
|
+
signal,
|
|
7519
|
+
project.id,
|
|
7520
|
+
run
|
|
7521
|
+
);
|
|
7302
7522
|
return {
|
|
7303
7523
|
report: {
|
|
7304
7524
|
outcome: "incomplete",
|
|
@@ -7310,10 +7530,17 @@ async function runEvalGate(options, command) {
|
|
|
7310
7530
|
message: `run is ${run.status}; pass --wait, or gate it once it finishes`
|
|
7311
7531
|
}
|
|
7312
7532
|
]
|
|
7313
|
-
}
|
|
7533
|
+
},
|
|
7534
|
+
run
|
|
7314
7535
|
};
|
|
7315
7536
|
}
|
|
7316
7537
|
if (Date.now() >= deadline) {
|
|
7538
|
+
decisionSummary = await readEvalRunDecisionSummary(
|
|
7539
|
+
client,
|
|
7540
|
+
signal,
|
|
7541
|
+
project.id,
|
|
7542
|
+
run
|
|
7543
|
+
);
|
|
7317
7544
|
return {
|
|
7318
7545
|
report: {
|
|
7319
7546
|
outcome: "incomplete",
|
|
@@ -7325,12 +7552,13 @@ async function runEvalGate(options, command) {
|
|
|
7325
7552
|
message: `run still ${run.status} after ${waitTimeoutMs}ms`
|
|
7326
7553
|
}
|
|
7327
7554
|
]
|
|
7328
|
-
}
|
|
7555
|
+
},
|
|
7556
|
+
run
|
|
7329
7557
|
};
|
|
7330
7558
|
}
|
|
7331
7559
|
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
7332
7560
|
run = await client.getEvalRun(
|
|
7333
|
-
{ projectId: project.id, runId
|
|
7561
|
+
{ projectId: project.id, runId },
|
|
7334
7562
|
{ signal }
|
|
7335
7563
|
);
|
|
7336
7564
|
}
|
|
@@ -7342,13 +7570,23 @@ async function runEvalGate(options, command) {
|
|
|
7342
7570
|
client,
|
|
7343
7571
|
signal,
|
|
7344
7572
|
project.id,
|
|
7345
|
-
|
|
7573
|
+
runId
|
|
7346
7574
|
);
|
|
7347
7575
|
} catch (error) {
|
|
7348
7576
|
iterationError = error instanceof Error ? error.message : String(error);
|
|
7349
7577
|
}
|
|
7350
7578
|
}
|
|
7351
7579
|
if (isNonVerdictRunStatus(run.status) || isNonVerdictRunResult(run.result)) {
|
|
7580
|
+
decisionSummary = iterations && iterationError === void 0 ? decisionSummaryFromIterations({
|
|
7581
|
+
projectId: project.id,
|
|
7582
|
+
run,
|
|
7583
|
+
iterations
|
|
7584
|
+
}) : await readEvalRunDecisionSummary(
|
|
7585
|
+
client,
|
|
7586
|
+
signal,
|
|
7587
|
+
project.id,
|
|
7588
|
+
run
|
|
7589
|
+
);
|
|
7352
7590
|
return {
|
|
7353
7591
|
report: {
|
|
7354
7592
|
outcome: "incomplete",
|
|
@@ -7368,14 +7606,17 @@ async function runEvalGate(options, command) {
|
|
|
7368
7606
|
};
|
|
7369
7607
|
}
|
|
7370
7608
|
if (iterations) {
|
|
7371
|
-
decisionSummary =
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7609
|
+
decisionSummary = decisionSummaryFromIterations({
|
|
7610
|
+
projectId: project.id,
|
|
7611
|
+
run,
|
|
7612
|
+
iterations
|
|
7613
|
+
});
|
|
7614
|
+
} else {
|
|
7615
|
+
decisionSummary = await readEvalRunDecisionSummary(
|
|
7616
|
+
client,
|
|
7617
|
+
signal,
|
|
7618
|
+
project.id,
|
|
7619
|
+
run
|
|
7379
7620
|
);
|
|
7380
7621
|
}
|
|
7381
7622
|
const thresholdReport = iterationError ? {
|
|
@@ -7407,7 +7648,7 @@ async function runEvalGate(options, command) {
|
|
|
7407
7648
|
client,
|
|
7408
7649
|
signal,
|
|
7409
7650
|
projectId: project.id,
|
|
7410
|
-
runId
|
|
7651
|
+
runId,
|
|
7411
7652
|
baseline,
|
|
7412
7653
|
policy: comparePolicy,
|
|
7413
7654
|
compareIterations: iterations
|
|
@@ -7427,7 +7668,7 @@ async function runEvalGate(options, command) {
|
|
|
7427
7668
|
throw error;
|
|
7428
7669
|
}
|
|
7429
7670
|
const detail = error instanceof Error ? error.message : String(error);
|
|
7430
|
-
const
|
|
7671
|
+
const report2 = {
|
|
7431
7672
|
outcome: "incomplete",
|
|
7432
7673
|
scoreIntegrity: "unknown",
|
|
7433
7674
|
verdicts: [
|
|
@@ -7439,8 +7680,8 @@ async function runEvalGate(options, command) {
|
|
|
7439
7680
|
]
|
|
7440
7681
|
};
|
|
7441
7682
|
const structured2 = needsReport ? buildEvalRunReport([], {
|
|
7442
|
-
cases: [gateReportCase(
|
|
7443
|
-
verdict: gateOutcomeVerdict(
|
|
7683
|
+
cases: [gateReportCase(report2)],
|
|
7684
|
+
verdict: gateOutcomeVerdict(report2.outcome)
|
|
7444
7685
|
}) : void 0;
|
|
7445
7686
|
if (options.out && structured2) {
|
|
7446
7687
|
await writeReporterArtifact(
|
|
@@ -7453,14 +7694,18 @@ async function runEvalGate(options, command) {
|
|
|
7453
7694
|
writeReporterResult(reporter, structured2);
|
|
7454
7695
|
} else {
|
|
7455
7696
|
writeResult(
|
|
7456
|
-
{ gate:
|
|
7697
|
+
{ gate: report2, exitCode: EVAL_GATE_INCOMPLETE_EXIT_CODE },
|
|
7457
7698
|
globalOptions.format
|
|
7458
7699
|
);
|
|
7459
7700
|
}
|
|
7460
7701
|
setProcessExitCode(EVAL_GATE_INCOMPLETE_EXIT_CODE);
|
|
7461
7702
|
return;
|
|
7462
7703
|
}
|
|
7463
|
-
const
|
|
7704
|
+
const report = applyGateWaiver(
|
|
7705
|
+
outcome.report,
|
|
7706
|
+
activeWaiverForRun(outcome.run)
|
|
7707
|
+
);
|
|
7708
|
+
const exitCode = evalGateExitCode(report);
|
|
7464
7709
|
const structured = needsReport ? buildEvalRunReport(
|
|
7465
7710
|
outcome.run ? [
|
|
7466
7711
|
{
|
|
@@ -7471,8 +7716,8 @@ async function runEvalGate(options, command) {
|
|
|
7471
7716
|
}
|
|
7472
7717
|
] : [],
|
|
7473
7718
|
{
|
|
7474
|
-
cases: [gateReportCase(
|
|
7475
|
-
verdict: gateOutcomeVerdict(
|
|
7719
|
+
cases: [gateReportCase(report, outcome.baselineProvenance)],
|
|
7720
|
+
verdict: gateOutcomeVerdict(report.outcome),
|
|
7476
7721
|
...decisionSummary ? { decisionSummary } : {},
|
|
7477
7722
|
...outcome.baselineProvenance ? { metadata: { baselineComparison: outcome.baselineProvenance } } : {}
|
|
7478
7723
|
}
|
|
@@ -7487,10 +7732,17 @@ async function runEvalGate(options, command) {
|
|
|
7487
7732
|
if (reporter && structured) {
|
|
7488
7733
|
writeReporterResult(reporter, structured);
|
|
7489
7734
|
} else {
|
|
7490
|
-
writeResult(
|
|
7735
|
+
writeResult(
|
|
7736
|
+
globalOptions.format === "json" ? {
|
|
7737
|
+
gate: report,
|
|
7738
|
+
exitCode,
|
|
7739
|
+
...decisionSummary ? { decisionSummary } : {}
|
|
7740
|
+
} : { gate: report, exitCode },
|
|
7741
|
+
globalOptions.format
|
|
7742
|
+
);
|
|
7491
7743
|
}
|
|
7492
7744
|
if (globalOptions.format === "human" && !reporter) {
|
|
7493
|
-
process.stderr.write(`${formatGateReport(
|
|
7745
|
+
process.stderr.write(`${formatGateReport(report)}
|
|
7494
7746
|
`);
|
|
7495
7747
|
writeEvalDecisionSummary(
|
|
7496
7748
|
globalOptions.format,
|
|
@@ -7502,9 +7754,110 @@ async function runEvalGate(options, command) {
|
|
|
7502
7754
|
setProcessExitCode(exitCode);
|
|
7503
7755
|
}
|
|
7504
7756
|
}
|
|
7757
|
+
function gateSubcommandScope(command) {
|
|
7758
|
+
const parentOptions = command.parent?.opts() ?? {};
|
|
7759
|
+
const run = parentOptions.run?.trim();
|
|
7760
|
+
if (!run) {
|
|
7761
|
+
throw usageError("--run <id> is required. Pass the eval run to act on.");
|
|
7762
|
+
}
|
|
7763
|
+
return {
|
|
7764
|
+
run,
|
|
7765
|
+
...parentOptions.project !== void 0 ? { project: parentOptions.project } : {}
|
|
7766
|
+
};
|
|
7767
|
+
}
|
|
7768
|
+
async function runEvalGateWaive(options, command) {
|
|
7769
|
+
const globalOptions = getGlobalOptions(command);
|
|
7770
|
+
const scope = gateSubcommandScope(command);
|
|
7771
|
+
const expiresAt = parseWaiverExpiry(options.expiresIn);
|
|
7772
|
+
const resolved = resolveCloudProjectArgs(scope);
|
|
7773
|
+
if (globalOptions.format === "human") {
|
|
7774
|
+
process.stderr.write(`Gate waiver reason: ${GATE_WAIVER_REASON_NOTICE}
|
|
7775
|
+
`);
|
|
7776
|
+
}
|
|
7777
|
+
const result = await runPlatformOperation(
|
|
7778
|
+
platformOptionsOf(command),
|
|
7779
|
+
globalOptions.timeout,
|
|
7780
|
+
async ({ client, signal }) => {
|
|
7781
|
+
const projects = await client.listProjects({}, { signal });
|
|
7782
|
+
const resolution = resolveProject(projects.items, resolved.project);
|
|
7783
|
+
if (!resolution.ok) {
|
|
7784
|
+
throw usageError(
|
|
7785
|
+
appendProjectLinkHint(resolution.message, resolved.projectScope)
|
|
7786
|
+
);
|
|
7787
|
+
}
|
|
7788
|
+
return await client.createGateWaiver(
|
|
7789
|
+
{
|
|
7790
|
+
projectId: resolution.project.id,
|
|
7791
|
+
runId: scope.run,
|
|
7792
|
+
reason: options.reason,
|
|
7793
|
+
expiresAt
|
|
7794
|
+
},
|
|
7795
|
+
{ signal }
|
|
7796
|
+
);
|
|
7797
|
+
}
|
|
7798
|
+
);
|
|
7799
|
+
writeResult(result, globalOptions.format);
|
|
7800
|
+
if (globalOptions.format === "human") {
|
|
7801
|
+
process.stderr.write(
|
|
7802
|
+
`${result.status === "conflict" ? "A waiver was already in force over this run; it was NOT replaced." : "Gate waived."} ${formatGateWaiverLine(result.waiver)}
|
|
7803
|
+
`
|
|
7804
|
+
);
|
|
7805
|
+
process.stderr.write(
|
|
7806
|
+
`Republished ${result.republishedChecks} GitHub check run(s).
|
|
7807
|
+
`
|
|
7808
|
+
);
|
|
7809
|
+
}
|
|
7810
|
+
}
|
|
7811
|
+
async function runEvalGateUnwaive(options, command) {
|
|
7812
|
+
const globalOptions = getGlobalOptions(command);
|
|
7813
|
+
const scope = gateSubcommandScope(command);
|
|
7814
|
+
const resolved = resolveCloudProjectArgs(scope);
|
|
7815
|
+
const result = await runPlatformOperation(
|
|
7816
|
+
platformOptionsOf(command),
|
|
7817
|
+
globalOptions.timeout,
|
|
7818
|
+
async ({ client, signal }) => {
|
|
7819
|
+
const projects = await client.listProjects({}, { signal });
|
|
7820
|
+
const resolution = resolveProject(projects.items, resolved.project);
|
|
7821
|
+
if (!resolution.ok) {
|
|
7822
|
+
throw usageError(
|
|
7823
|
+
appendProjectLinkHint(resolution.message, resolved.projectScope)
|
|
7824
|
+
);
|
|
7825
|
+
}
|
|
7826
|
+
const projectId = resolution.project.id;
|
|
7827
|
+
let waiverId = options.waiver?.trim();
|
|
7828
|
+
if (!waiverId) {
|
|
7829
|
+
const { waiver } = await client.getGateWaiver(
|
|
7830
|
+
{ projectId, runId: scope.run },
|
|
7831
|
+
{ signal }
|
|
7832
|
+
);
|
|
7833
|
+
if (!waiver) {
|
|
7834
|
+
throw usageError(
|
|
7835
|
+
`No waiver is in force over run "${scope.run}". Pass --waiver <id> to revoke a specific one.`
|
|
7836
|
+
);
|
|
7837
|
+
}
|
|
7838
|
+
waiverId = waiver.id;
|
|
7839
|
+
}
|
|
7840
|
+
return await client.revokeGateWaiver(
|
|
7841
|
+
{ projectId, runId: scope.run, waiverId },
|
|
7842
|
+
{ signal }
|
|
7843
|
+
);
|
|
7844
|
+
}
|
|
7845
|
+
);
|
|
7846
|
+
writeResult(result, globalOptions.format);
|
|
7847
|
+
if (globalOptions.format === "human") {
|
|
7848
|
+
process.stderr.write(
|
|
7849
|
+
`${result.status === "already_revoked" ? "This waiver was already revoked; the existing revocation stands." : "Gate waiver revoked."} Republished ${result.republishedChecks} GitHub check run(s).
|
|
7850
|
+
`
|
|
7851
|
+
);
|
|
7852
|
+
}
|
|
7853
|
+
}
|
|
7505
7854
|
async function runEvalCompare(options, command) {
|
|
7506
7855
|
const globalOptions = getGlobalOptions(command);
|
|
7507
7856
|
const policy = comparePolicyFromOptions(options);
|
|
7857
|
+
const baseSelector = compareBaseSelector({
|
|
7858
|
+
baseRun: options.baseRun,
|
|
7859
|
+
baseSha: options.baseSha
|
|
7860
|
+
});
|
|
7508
7861
|
const reporter = parseReporterFormat(options.reporter);
|
|
7509
7862
|
const resolved = resolveCloudProjectArgs(options);
|
|
7510
7863
|
let outcome;
|
|
@@ -7525,7 +7878,7 @@ async function runEvalCompare(options, command) {
|
|
|
7525
7878
|
{
|
|
7526
7879
|
projectId: project.id,
|
|
7527
7880
|
runId: options.run,
|
|
7528
|
-
...
|
|
7881
|
+
...baseSelector
|
|
7529
7882
|
},
|
|
7530
7883
|
{ signal }
|
|
7531
7884
|
);
|
|
@@ -7573,18 +7926,20 @@ async function runEvalCompare(options, command) {
|
|
|
7573
7926
|
baseP95Ms: p95Of(baseIterations),
|
|
7574
7927
|
compareP95Ms: p95Of(compareIterations)
|
|
7575
7928
|
});
|
|
7929
|
+
const compareRunDetail = await client.getEvalRun(
|
|
7930
|
+
{ projectId: project.id, runId: compare.compareRun.id },
|
|
7931
|
+
{ signal }
|
|
7932
|
+
).catch(() => void 0);
|
|
7576
7933
|
return {
|
|
7577
7934
|
report: evaluateCompareGates(input, policy),
|
|
7578
7935
|
compare,
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
}
|
|
7587
|
-
) : void 0,
|
|
7936
|
+
// About the COMPARE side only. A baseline's own failures are a
|
|
7937
|
+
// different run's diagnostics and would read here as this run's.
|
|
7938
|
+
decisionSummary: compareIterations && compareRunDetail ? decisionSummaryFromIterations({
|
|
7939
|
+
projectId: project.id,
|
|
7940
|
+
run: compareRunDetail,
|
|
7941
|
+
iterations: compareIterations
|
|
7942
|
+
}) : void 0,
|
|
7588
7943
|
// Reported, NEVER gated. See `detectFlakyCases`.
|
|
7589
7944
|
flakyCases: compareIterations?.complete ? detectFlakyCases(flakyInputFrom(compareIterations.items)) : []
|
|
7590
7945
|
};
|
|
@@ -7633,6 +7988,11 @@ async function runEvalCompare(options, command) {
|
|
|
7633
7988
|
if (globalOptions.format === "human" && !reporter) {
|
|
7634
7989
|
process.stderr.write(`${formatGateReport(outcome.report)}
|
|
7635
7990
|
`);
|
|
7991
|
+
writeEvalDecisionSummary(
|
|
7992
|
+
globalOptions.format,
|
|
7993
|
+
outcome.decisionSummary,
|
|
7994
|
+
process.stderr
|
|
7995
|
+
);
|
|
7636
7996
|
}
|
|
7637
7997
|
if (exitCode !== 0) {
|
|
7638
7998
|
setProcessExitCode(exitCode);
|
|
@@ -8305,11 +8665,18 @@ function registerEvalCommands(program) {
|
|
|
8305
8665
|
] : []
|
|
8306
8666
|
);
|
|
8307
8667
|
if (!needsReport) {
|
|
8668
|
+
const soloSummary = globalOptions.format === "human" && result.targets.length === 1 && runs.length === 1 && TERMINAL_RUN_STATUSES.has(runs[0].status) ? await readEvalRunDecisionSummary(
|
|
8669
|
+
client,
|
|
8670
|
+
signal,
|
|
8671
|
+
result.project.id,
|
|
8672
|
+
runs[0]
|
|
8673
|
+
) : void 0;
|
|
8308
8674
|
return {
|
|
8309
8675
|
runs,
|
|
8310
8676
|
waitErrors,
|
|
8311
8677
|
reportInputs: [],
|
|
8312
|
-
iterationErrorCodes: /* @__PURE__ */ new Map()
|
|
8678
|
+
iterationErrorCodes: /* @__PURE__ */ new Map(),
|
|
8679
|
+
...soloSummary ? { decisionSummary: soloSummary } : {}
|
|
8313
8680
|
};
|
|
8314
8681
|
}
|
|
8315
8682
|
const iterationErrorCodes = /* @__PURE__ */ new Map();
|
|
@@ -8340,7 +8707,22 @@ function registerEvalCommands(program) {
|
|
|
8340
8707
|
}
|
|
8341
8708
|
})
|
|
8342
8709
|
);
|
|
8343
|
-
|
|
8710
|
+
const solo = result.targets.length === 1 && runs.length === 1 && reportInputs.length === 1 ? reportInputs[0] : void 0;
|
|
8711
|
+
const decisionSummary = solo && solo.iterationError === void 0 ? decisionSummaryFromIterations({
|
|
8712
|
+
projectId: result.project.id,
|
|
8713
|
+
run: solo.run,
|
|
8714
|
+
iterations: {
|
|
8715
|
+
items: [...solo.iterations],
|
|
8716
|
+
complete: solo.iterationsComplete
|
|
8717
|
+
}
|
|
8718
|
+
}) : void 0;
|
|
8719
|
+
return {
|
|
8720
|
+
runs,
|
|
8721
|
+
waitErrors,
|
|
8722
|
+
reportInputs,
|
|
8723
|
+
iterationErrorCodes,
|
|
8724
|
+
...decisionSummary ? { decisionSummary } : {}
|
|
8725
|
+
};
|
|
8344
8726
|
},
|
|
8345
8727
|
{
|
|
8346
8728
|
projectScope: resolved.projectScope,
|
|
@@ -8362,7 +8744,8 @@ function registerEvalCommands(program) {
|
|
|
8362
8744
|
project: result.project,
|
|
8363
8745
|
suite: result.suite,
|
|
8364
8746
|
...result.runGroupId ? { runGroupId: result.runGroupId } : {}
|
|
8365
|
-
}
|
|
8747
|
+
},
|
|
8748
|
+
...completion.decisionSummary ? { decisionSummary: completion.decisionSummary } : {}
|
|
8366
8749
|
}) : void 0;
|
|
8367
8750
|
const reportingErrors = completion.reportInputs.filter(
|
|
8368
8751
|
(input) => !input.iterationsComplete || input.iterationError
|
|
@@ -8403,6 +8786,11 @@ function registerEvalCommands(program) {
|
|
|
8403
8786
|
globalOptions.format
|
|
8404
8787
|
);
|
|
8405
8788
|
writeRunGroupSummary(globalOptions.format, webOrigin, result);
|
|
8789
|
+
writeEvalDecisionSummary(
|
|
8790
|
+
globalOptions.format,
|
|
8791
|
+
completion.decisionSummary,
|
|
8792
|
+
process.stdout
|
|
8793
|
+
);
|
|
8406
8794
|
}
|
|
8407
8795
|
if (outWriteError !== void 0) {
|
|
8408
8796
|
throw cliError("OUT_WRITE_FAILED", outWriteError, worstOf([code, 4]));
|
|
@@ -8450,25 +8838,8 @@ function registerEvalCommands(program) {
|
|
|
8450
8838
|
},
|
|
8451
8839
|
{ client: context.client, signal: context.signal }
|
|
8452
8840
|
);
|
|
8453
|
-
if (globalOptions.format === "human" && TERMINAL_RUN_STATUSES.has(result2.run.status) && result2.run.result
|
|
8454
|
-
|
|
8455
|
-
const iterations = await fetchAllIterations(
|
|
8456
|
-
context.client,
|
|
8457
|
-
context.signal,
|
|
8458
|
-
result2.project.id,
|
|
8459
|
-
result2.run.id
|
|
8460
|
-
);
|
|
8461
|
-
decisionSummary = buildEvalDecisionSummaryFromIterations(
|
|
8462
|
-
iterations.items,
|
|
8463
|
-
{
|
|
8464
|
-
total: result2.run.summary?.total,
|
|
8465
|
-
passed: result2.run.summary?.passed,
|
|
8466
|
-
failed: result2.run.summary?.failed,
|
|
8467
|
-
iterationWalkComplete: iterations.complete
|
|
8468
|
-
}
|
|
8469
|
-
);
|
|
8470
|
-
} catch {
|
|
8471
|
-
}
|
|
8841
|
+
if (globalOptions.format === "human" && TERMINAL_RUN_STATUSES.has(result2.run.status) && result2.run.result !== "passed") {
|
|
8842
|
+
decisionSummary = result2.decisionSummary;
|
|
8472
8843
|
}
|
|
8473
8844
|
return result2;
|
|
8474
8845
|
},
|
|
@@ -8477,18 +8848,22 @@ function registerEvalCommands(program) {
|
|
|
8477
8848
|
quiet: globalOptions.quiet
|
|
8478
8849
|
}
|
|
8479
8850
|
);
|
|
8480
|
-
|
|
8851
|
+
const resultForOutput = globalOptions.format === "human" ? (() => {
|
|
8852
|
+
const { decisionSummary: _decisionSummary, ...humanResult } = result;
|
|
8853
|
+
return humanResult;
|
|
8854
|
+
})() : result;
|
|
8855
|
+
writeResult(resultForOutput, globalOptions.format);
|
|
8481
8856
|
writeJudgeSummary(globalOptions.format, result.run.judges);
|
|
8482
|
-
writeRunLink(globalOptions.format, webOrigin, {
|
|
8483
|
-
projectId: result.project.id,
|
|
8484
|
-
suiteId: result.run.suiteId,
|
|
8485
|
-
runId: result.run.id
|
|
8486
|
-
});
|
|
8487
8857
|
writeEvalDecisionSummary(
|
|
8488
8858
|
globalOptions.format,
|
|
8489
8859
|
decisionSummary,
|
|
8490
8860
|
process.stdout
|
|
8491
8861
|
);
|
|
8862
|
+
writeRunLink(globalOptions.format, webOrigin, {
|
|
8863
|
+
projectId: result.project.id,
|
|
8864
|
+
suiteId: result.run.suiteId,
|
|
8865
|
+
runId: result.run.id
|
|
8866
|
+
});
|
|
8492
8867
|
}
|
|
8493
8868
|
);
|
|
8494
8869
|
addProjectOption(
|
|
@@ -8596,10 +8971,10 @@ function registerEvalCommands(program) {
|
|
|
8596
8971
|
);
|
|
8597
8972
|
}
|
|
8598
8973
|
);
|
|
8599
|
-
addProjectOption(
|
|
8974
|
+
const gateCommand = addProjectOption(
|
|
8600
8975
|
evals.command("gate").description(
|
|
8601
|
-
"Apply a pass/fail policy to a finished eval run and set an exit code (0 pass, 1 eval failure, 2 usage, 3 incomplete)"
|
|
8602
|
-
).
|
|
8976
|
+
"Apply a pass/fail policy to a finished eval run and set an exit code (0 pass or waived, 1 eval failure, 2 usage, 3 incomplete)"
|
|
8977
|
+
).option("--run <id>", "Eval run ID (from `eval run`)")
|
|
8603
8978
|
).option(
|
|
8604
8979
|
"--min-pass-rate-percent <0-100>",
|
|
8605
8980
|
"Minimum share of iterations that must pass, as a percentage"
|
|
@@ -8618,19 +8993,22 @@ function registerEvalCommands(program) {
|
|
|
8618
8993
|
[]
|
|
8619
8994
|
).option(
|
|
8620
8995
|
"--baseline <runId>",
|
|
8621
|
-
"Baseline run ID to gate a regression delta against
|
|
8996
|
+
"Baseline run ID to gate a regression delta against; mutually exclusive with --baseline-sha"
|
|
8997
|
+
).option(
|
|
8998
|
+
"--baseline-sha <sha>",
|
|
8999
|
+
"Baseline source commit SHA, resolved to the completed run in this suite recorded against it; mutually exclusive with --baseline"
|
|
8622
9000
|
).option(
|
|
8623
9001
|
"--min-sample-size <n>",
|
|
8624
|
-
"Iterations required on EACH side before a pass-rate regression is decidable (default 5); requires --baseline"
|
|
9002
|
+
"Iterations required on EACH side before a pass-rate regression is decidable (default 5); requires --baseline or --baseline-sha"
|
|
8625
9003
|
).option(
|
|
8626
9004
|
"--min-effect-size-percent <0-100>",
|
|
8627
|
-
"Smallest pass-rate drop worth failing on, as a percentage (default 1); requires --baseline"
|
|
9005
|
+
"Smallest pass-rate drop worth failing on, as a percentage (default 1); requires --baseline or --baseline-sha"
|
|
8628
9006
|
).option(
|
|
8629
9007
|
"--gate-deterministic-regressions",
|
|
8630
|
-
"Fail if a deterministic gating scorer flipped from passed to failed; requires --baseline"
|
|
9008
|
+
"Fail if a deterministic gating scorer flipped from passed to failed; requires --baseline or --baseline-sha"
|
|
8631
9009
|
).option(
|
|
8632
9010
|
"--max-p95-latency-increase-ms <ms>",
|
|
8633
|
-
"Fail if p95 end-to-end latency rose by more than this many milliseconds vs the baseline; requires --baseline"
|
|
9011
|
+
"Fail if p95 end-to-end latency rose by more than this many milliseconds vs the baseline; requires --baseline or --baseline-sha"
|
|
8634
9012
|
).option("--wait", "Poll until the run reaches a terminal status").option(
|
|
8635
9013
|
"--wait-timeout <ms>",
|
|
8636
9014
|
"Give up waiting after this many milliseconds (default 600000)"
|
|
@@ -8645,13 +9023,35 @@ function registerEvalCommands(program) {
|
|
|
8645
9023
|
await runEvalGate(options, command);
|
|
8646
9024
|
}
|
|
8647
9025
|
);
|
|
9026
|
+
gateCommand.command("waive").description(
|
|
9027
|
+
"Override a FAILING run's gate until an expiry you name. Does not make the run pass: the run keeps its result, and the waiver is named in every report and check."
|
|
9028
|
+
).requiredOption(
|
|
9029
|
+
"--reason <text>",
|
|
9030
|
+
`Why the gate is being overridden (max ${GATE_WAIVER_MAX_REASON_LENGTH} characters). ${GATE_WAIVER_REASON_NOTICE}`
|
|
9031
|
+
).requiredOption(
|
|
9032
|
+
"--expires-in <duration>",
|
|
9033
|
+
"How long the waiver lasts, e.g. 30m, 12h, 7d. Capped at 30 days by the platform \u2014 there is no permanent waiver."
|
|
9034
|
+
).action(async (options, command) => {
|
|
9035
|
+
await runEvalGateWaive(options, command);
|
|
9036
|
+
});
|
|
9037
|
+
gateCommand.command("unwaive").description(
|
|
9038
|
+
"Revoke a gate waiver, putting the gate and the GitHub Check Run back. Idempotent."
|
|
9039
|
+
).option(
|
|
9040
|
+
"--waiver <id>",
|
|
9041
|
+
"Waiver ID to revoke. Omit to revoke the waiver currently in force over --run."
|
|
9042
|
+
).action(async (options, command) => {
|
|
9043
|
+
await runEvalGateUnwaive(options, command);
|
|
9044
|
+
});
|
|
8648
9045
|
addProjectOption(
|
|
8649
9046
|
evals.command("compare").description(
|
|
8650
9047
|
"Compare a finished eval run against a baseline and set an exit code (0 pass, 1 regression, 2 usage, 3 incomplete)"
|
|
8651
9048
|
).requiredOption("--run <id>", "Eval run ID to compare")
|
|
8652
9049
|
).option(
|
|
8653
9050
|
"--base-run <id>",
|
|
8654
|
-
"Baseline run ID (defaults to the nearest earlier completed run in the same suite)"
|
|
9051
|
+
"Baseline run ID (defaults to the nearest earlier completed run in the same suite); mutually exclusive with --base-sha"
|
|
9052
|
+
).option(
|
|
9053
|
+
"--base-sha <sha>",
|
|
9054
|
+
"Baseline source commit SHA, resolved to the completed run in this suite recorded against it; mutually exclusive with --base-run"
|
|
8655
9055
|
).option(
|
|
8656
9056
|
"--gate-regressions",
|
|
8657
9057
|
"Fail on a statistically significant pass-rate regression"
|
|
@@ -9203,7 +9603,22 @@ function registerEvalCommands(program) {
|
|
|
9203
9603
|
}
|
|
9204
9604
|
);
|
|
9205
9605
|
}
|
|
9206
|
-
var
|
|
9606
|
+
var CLIENT_TEMPLATES = HOST_TEMPLATES.map(({ id, label }) => ({ id, label }));
|
|
9607
|
+
function selectorOf(options) {
|
|
9608
|
+
if (options.client !== void 0 && options.host !== void 0) {
|
|
9609
|
+
throw usageError(
|
|
9610
|
+
"Use either --client or its deprecated --host alias, not both."
|
|
9611
|
+
);
|
|
9612
|
+
}
|
|
9613
|
+
const selector = options.client ?? options.host;
|
|
9614
|
+
if (selector === void 0) {
|
|
9615
|
+
throw usageError("--client <id-or-name> is required.");
|
|
9616
|
+
}
|
|
9617
|
+
return selector;
|
|
9618
|
+
}
|
|
9619
|
+
function withClientSelector(command) {
|
|
9620
|
+
return command.option("--client <id-or-name>", "Client name or ID").option("--host <id-or-name>", "Deprecated alias for --client");
|
|
9621
|
+
}
|
|
9207
9622
|
function loadConfigObject(options) {
|
|
9208
9623
|
if (options.file !== void 0 && options.json !== void 0) {
|
|
9209
9624
|
throw usageError("Provide either --file or --json, not both.");
|
|
@@ -9232,62 +9647,164 @@ function loadConfigObject(options) {
|
|
|
9232
9647
|
return void 0;
|
|
9233
9648
|
}
|
|
9234
9649
|
if (typeof base !== "object" || base === null || Array.isArray(base)) {
|
|
9235
|
-
throw usageError("
|
|
9650
|
+
throw usageError("Client config must be a JSON object.");
|
|
9236
9651
|
}
|
|
9237
9652
|
return base;
|
|
9238
9653
|
}
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
"
|
|
9654
|
+
var SETTABLE_FIELDS = {
|
|
9655
|
+
modelId: {
|
|
9656
|
+
kind: "string",
|
|
9657
|
+
unsettable: false,
|
|
9658
|
+
note: "a client cannot be edited into one that pins no model"
|
|
9659
|
+
},
|
|
9660
|
+
// Required-resettable: --unset resets to the canonical default.
|
|
9661
|
+
systemPrompt: { kind: "string", unsettable: true },
|
|
9662
|
+
temperature: { kind: "number", unsettable: true },
|
|
9663
|
+
requireToolApproval: { kind: "boolean", unsettable: true },
|
|
9664
|
+
connectionDefaults: { kind: "json", unsettable: true },
|
|
9665
|
+
// Optional-clearable: --unset clears to absent.
|
|
9666
|
+
respectToolVisibility: { kind: "boolean", unsettable: true },
|
|
9667
|
+
progressiveToolDiscovery: { kind: "boolean", unsettable: true },
|
|
9668
|
+
harness: { kind: "string", unsettable: true },
|
|
9669
|
+
computer: { kind: "json", unsettable: true },
|
|
9670
|
+
builtInToolIds: { kind: "json", unsettable: true },
|
|
9671
|
+
skillSelection: { kind: "json", unsettable: true },
|
|
9672
|
+
modelVisibleMcpToolResults: { kind: "json", unsettable: true },
|
|
9673
|
+
mcpToolResultImageRendering: { kind: "json", unsettable: true },
|
|
9674
|
+
mcpProfile: { kind: "json", unsettable: true },
|
|
9675
|
+
hostCapabilitiesOverride: { kind: "json", unsettable: true },
|
|
9676
|
+
chatUiOverride: { kind: "json", unsettable: true }
|
|
9677
|
+
};
|
|
9678
|
+
var SETTABLE_FIELD_LIST = Object.keys(SETTABLE_FIELDS).join(", ");
|
|
9679
|
+
function fieldSpec(field) {
|
|
9680
|
+
return Object.hasOwn(SETTABLE_FIELDS, field) ? SETTABLE_FIELDS[field] : void 0;
|
|
9681
|
+
}
|
|
9682
|
+
function unknownFieldError(field) {
|
|
9683
|
+
throw usageError(
|
|
9684
|
+
`Unknown client field "${field}". Settable fields: ${SETTABLE_FIELD_LIST}.`
|
|
9242
9685
|
);
|
|
9243
|
-
|
|
9244
|
-
|
|
9686
|
+
}
|
|
9687
|
+
function parseSetPair(pair) {
|
|
9688
|
+
const separator = pair.indexOf("=");
|
|
9689
|
+
if (separator <= 0) {
|
|
9690
|
+
throw usageError(`--set expects key=value, got "${pair}".`);
|
|
9691
|
+
}
|
|
9692
|
+
const field = pair.slice(0, separator).trim();
|
|
9693
|
+
const raw = pair.slice(separator + 1);
|
|
9694
|
+
const spec = fieldSpec(field);
|
|
9695
|
+
if (!spec) unknownFieldError(field);
|
|
9696
|
+
switch (spec.kind) {
|
|
9697
|
+
case "string":
|
|
9698
|
+
return [field, raw];
|
|
9699
|
+
case "number": {
|
|
9700
|
+
const value = Number(raw);
|
|
9701
|
+
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
9702
|
+
throw usageError(`--set ${field} expects a number, got "${raw}".`);
|
|
9703
|
+
}
|
|
9704
|
+
return [field, value];
|
|
9705
|
+
}
|
|
9706
|
+
case "boolean":
|
|
9707
|
+
if (raw === "true") return [field, true];
|
|
9708
|
+
if (raw === "false") return [field, false];
|
|
9709
|
+
throw usageError(`--set ${field} expects true or false, got "${raw}".`);
|
|
9710
|
+
case "json":
|
|
9711
|
+
try {
|
|
9712
|
+
return [field, JSON.parse(raw)];
|
|
9713
|
+
} catch (error) {
|
|
9714
|
+
throw usageError(
|
|
9715
|
+
`--set ${field} expects JSON (it is an object or a list), got "${raw}".`,
|
|
9716
|
+
{ source: error instanceof Error ? error.message : String(error) }
|
|
9717
|
+
);
|
|
9718
|
+
}
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
function buildSetBlock(setPairs, unsetFields) {
|
|
9722
|
+
const set = /* @__PURE__ */ Object.create(null);
|
|
9723
|
+
for (const pair of setPairs ?? []) {
|
|
9724
|
+
const [field, value] = parseSetPair(pair);
|
|
9725
|
+
if (Object.hasOwn(set, field)) {
|
|
9726
|
+
throw usageError(`--set names "${field}" more than once; pass it once.`);
|
|
9727
|
+
}
|
|
9728
|
+
set[field] = value;
|
|
9729
|
+
}
|
|
9730
|
+
for (const field of unsetFields ?? []) {
|
|
9731
|
+
const spec = fieldSpec(field);
|
|
9732
|
+
if (!spec) unknownFieldError(field);
|
|
9733
|
+
if (!spec.unsettable) {
|
|
9734
|
+
throw usageError(
|
|
9735
|
+
`--unset ${field} is not allowed: ${spec.note ?? "this field has no cleared state"}.`
|
|
9736
|
+
);
|
|
9737
|
+
}
|
|
9738
|
+
if (Object.hasOwn(set, field)) {
|
|
9739
|
+
throw usageError(
|
|
9740
|
+
`--set and --unset both name "${field}"; pass one of them.`
|
|
9741
|
+
);
|
|
9742
|
+
}
|
|
9743
|
+
set[field] = null;
|
|
9744
|
+
}
|
|
9745
|
+
return Object.keys(set).length > 0 ? set : void 0;
|
|
9746
|
+
}
|
|
9747
|
+
function registerClientsCommands(program) {
|
|
9748
|
+
const clients = program.command("clients").alias("hosts").description(
|
|
9749
|
+
"List, create, and manage the clients in your hosted MCPJam projects"
|
|
9750
|
+
);
|
|
9751
|
+
clients.command("templates").description(
|
|
9752
|
+
"List the built-in templates usable with `clients create --template`"
|
|
9245
9753
|
).action((_options, command) => {
|
|
9246
9754
|
const globalOptions = getGlobalOptions(command);
|
|
9247
|
-
writeResult({ items:
|
|
9755
|
+
writeResult({ items: CLIENT_TEMPLATES }, globalOptions.format);
|
|
9248
9756
|
});
|
|
9249
|
-
|
|
9757
|
+
clients.command("list").description("List the clients saved in a project").option(
|
|
9250
9758
|
"--project <id-or-name>",
|
|
9251
9759
|
"Project name or ID (defaults to the most recently updated project)"
|
|
9252
|
-
).action(
|
|
9253
|
-
const globalOptions = getGlobalOptions(command);
|
|
9254
|
-
const result = await runPlatformOperation(
|
|
9255
|
-
platformOptionsOf(command),
|
|
9256
|
-
globalOptions.timeout,
|
|
9257
|
-
({ client, signal }) => listHostsOperation.execute(
|
|
9258
|
-
{ project: resolveCloudProjectArgs(options).project },
|
|
9259
|
-
{ client, signal }
|
|
9260
|
-
)
|
|
9261
|
-
);
|
|
9262
|
-
writeResult(result, globalOptions.format);
|
|
9263
|
-
});
|
|
9264
|
-
hosts.command("get").description("Show one host's full settings, including its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID").action(
|
|
9760
|
+
).action(
|
|
9265
9761
|
async (options, command) => {
|
|
9266
9762
|
const globalOptions = getGlobalOptions(command);
|
|
9267
9763
|
const result = await runPlatformOperation(
|
|
9268
9764
|
platformOptionsOf(command),
|
|
9269
9765
|
globalOptions.timeout,
|
|
9270
|
-
({ client, signal }) =>
|
|
9271
|
-
{ project: resolveCloudProjectArgs(options).project
|
|
9766
|
+
({ client, signal }) => listClientsOperation.execute(
|
|
9767
|
+
{ project: resolveCloudProjectArgs(options).project },
|
|
9272
9768
|
{ client, signal }
|
|
9273
9769
|
)
|
|
9274
9770
|
);
|
|
9275
9771
|
writeResult(result, globalOptions.format);
|
|
9276
9772
|
}
|
|
9277
9773
|
);
|
|
9278
|
-
|
|
9279
|
-
"
|
|
9280
|
-
|
|
9774
|
+
withClientSelector(
|
|
9775
|
+
clients.command("get").description(
|
|
9776
|
+
"Show one client's full settings, its configId (the token every edit takes), and what a config edit would affect"
|
|
9777
|
+
)
|
|
9778
|
+
).option("--project <id-or-name>", "Project name or ID").action(
|
|
9779
|
+
async (options, command) => {
|
|
9780
|
+
const globalOptions = getGlobalOptions(command);
|
|
9781
|
+
const result = await runPlatformOperation(
|
|
9782
|
+
platformOptionsOf(command),
|
|
9783
|
+
globalOptions.timeout,
|
|
9784
|
+
({ client, signal }) => getClientOperation.execute(
|
|
9785
|
+
{
|
|
9786
|
+
project: resolveCloudProjectArgs(options).project,
|
|
9787
|
+
client: selectorOf(options)
|
|
9788
|
+
},
|
|
9789
|
+
{ client, signal }
|
|
9790
|
+
)
|
|
9791
|
+
);
|
|
9792
|
+
writeResult(result, globalOptions.format);
|
|
9793
|
+
}
|
|
9794
|
+
);
|
|
9795
|
+
clients.command("create").description(
|
|
9796
|
+
"Create a client from a built-in template (--template) or a full config (--file/--json)"
|
|
9797
|
+
).requiredOption("--name <name>", "Display name for the new client").option("--project <id-or-name>", "Project name or ID").option(
|
|
9281
9798
|
"--template <id>",
|
|
9282
|
-
"Built-in template id (see `
|
|
9799
|
+
"Built-in template id (see `clients templates`), e.g. claude, chatgpt, cursor"
|
|
9283
9800
|
).option(
|
|
9284
9801
|
"--theme <theme>",
|
|
9285
9802
|
"Theme for the seeded config: light or dark (template only)"
|
|
9286
|
-
).option("--file <path>", "
|
|
9803
|
+
).option("--file <path>", "Client config v2 JSON file (or - for stdin)").option("--json <json>", "Inline client config v2 JSON (or @file, or -)").action(
|
|
9287
9804
|
async (options, command) => {
|
|
9288
9805
|
const globalOptions = getGlobalOptions(command);
|
|
9289
9806
|
const config = loadConfigObject(options);
|
|
9290
|
-
const input = validateInput2(
|
|
9807
|
+
const input = validateInput2(createClientOperation, {
|
|
9291
9808
|
project: resolveCloudProjectArgs(options).project,
|
|
9292
9809
|
name: options.name,
|
|
9293
9810
|
...options.template !== void 0 ? { template: options.template } : {},
|
|
@@ -9297,45 +9814,72 @@ function registerHostsCommands(program) {
|
|
|
9297
9814
|
const result = await runPlatformOperation(
|
|
9298
9815
|
platformOptionsOf(command),
|
|
9299
9816
|
globalOptions.timeout,
|
|
9300
|
-
({ client, signal }) =>
|
|
9817
|
+
({ client, signal }) => createClientOperation.execute(input, { client, signal })
|
|
9301
9818
|
);
|
|
9302
9819
|
writeResult(result, globalOptions.format);
|
|
9303
9820
|
}
|
|
9304
9821
|
);
|
|
9305
|
-
|
|
9822
|
+
withClientSelector(
|
|
9823
|
+
clients.command("update").description(
|
|
9824
|
+
"Edit a client's name and/or its config. Use --set/--unset for named fields, or --file/--json to replace the whole config"
|
|
9825
|
+
)
|
|
9826
|
+
).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option(
|
|
9827
|
+
"--expected-name <name>",
|
|
9828
|
+
"The name you last read (required with --name)"
|
|
9829
|
+
).option(
|
|
9830
|
+
"--expected-config-id <id>",
|
|
9831
|
+
"The configId you last read (required for any config edit)"
|
|
9832
|
+
).option(
|
|
9833
|
+
"--set <key=value...>",
|
|
9834
|
+
`Set one field. Repeatable. Fields: ${SETTABLE_FIELD_LIST}`
|
|
9835
|
+
).option(
|
|
9836
|
+
"--unset <key...>",
|
|
9837
|
+
"Clear an optional field to absent, or reset a required one to its default. Repeatable"
|
|
9838
|
+
).option(
|
|
9306
9839
|
"--file <path>",
|
|
9307
|
-
"Replacement
|
|
9840
|
+
"Replacement client config v2 JSON (or - for stdin)"
|
|
9308
9841
|
).option(
|
|
9309
9842
|
"--json <json>",
|
|
9310
|
-
"Inline replacement
|
|
9843
|
+
"Inline replacement client config v2 JSON (or @file, or -)"
|
|
9311
9844
|
).action(
|
|
9312
9845
|
async (options, command) => {
|
|
9313
9846
|
const globalOptions = getGlobalOptions(command);
|
|
9314
9847
|
const config = loadConfigObject(options);
|
|
9315
|
-
const
|
|
9848
|
+
const set = buildSetBlock(options.set, options.unset);
|
|
9849
|
+
if (config !== void 0 && set !== void 0) {
|
|
9850
|
+
throw usageError(
|
|
9851
|
+
"Use either --set/--unset (named fields) or --file/--json (whole-config replacement), not both."
|
|
9852
|
+
);
|
|
9853
|
+
}
|
|
9854
|
+
const input = validateInput2(updateClientOperation, {
|
|
9316
9855
|
project: resolveCloudProjectArgs(options).project,
|
|
9317
|
-
|
|
9856
|
+
client: selectorOf(options),
|
|
9318
9857
|
...options.name !== void 0 ? { name: options.name } : {},
|
|
9319
|
-
...
|
|
9858
|
+
...options.expectedName !== void 0 ? { expectedName: options.expectedName } : {},
|
|
9859
|
+
...options.expectedConfigId !== void 0 ? { expectedConfigId: options.expectedConfigId } : {},
|
|
9860
|
+
...config !== void 0 ? { config } : {},
|
|
9861
|
+
...set !== void 0 ? { set } : {}
|
|
9320
9862
|
});
|
|
9321
9863
|
const result = await runPlatformOperation(
|
|
9322
9864
|
platformOptionsOf(command),
|
|
9323
9865
|
globalOptions.timeout,
|
|
9324
|
-
({ client, signal }) =>
|
|
9866
|
+
({ client, signal }) => updateClientOperation.execute(input, { client, signal })
|
|
9325
9867
|
);
|
|
9326
9868
|
writeResult(result, globalOptions.format);
|
|
9327
9869
|
}
|
|
9328
9870
|
);
|
|
9329
|
-
|
|
9871
|
+
withClientSelector(
|
|
9872
|
+
clients.command("delete").description("Permanently delete a client from a project")
|
|
9873
|
+
).option("--project <id-or-name>", "Project name or ID").action(
|
|
9330
9874
|
async (options, command) => {
|
|
9331
9875
|
const globalOptions = getGlobalOptions(command);
|
|
9332
9876
|
const result = await runPlatformOperation(
|
|
9333
9877
|
platformOptionsOf(command),
|
|
9334
9878
|
globalOptions.timeout,
|
|
9335
|
-
({ client, signal }) =>
|
|
9879
|
+
({ client, signal }) => deleteClientOperation.execute(
|
|
9336
9880
|
{
|
|
9337
9881
|
project: resolveCloudProjectArgs(options).project,
|
|
9338
|
-
|
|
9882
|
+
client: selectorOf(options)
|
|
9339
9883
|
},
|
|
9340
9884
|
{ client, signal }
|
|
9341
9885
|
)
|
|
@@ -9343,42 +9887,52 @@ function registerHostsCommands(program) {
|
|
|
9343
9887
|
writeResult(result, globalOptions.format);
|
|
9344
9888
|
}
|
|
9345
9889
|
);
|
|
9346
|
-
|
|
9890
|
+
withClientSelector(
|
|
9891
|
+
clients.command("servers").description(
|
|
9892
|
+
"Replace a client's required and optional server attachments (servers you omit are detached)"
|
|
9893
|
+
)
|
|
9894
|
+
).requiredOption(
|
|
9347
9895
|
"--server-ids <id,...>",
|
|
9348
9896
|
"Comma-separated required server IDs"
|
|
9349
9897
|
).option(
|
|
9350
9898
|
"--optional-server-ids <id,...>",
|
|
9351
9899
|
"Comma-separated optional server IDs"
|
|
9900
|
+
).requiredOption(
|
|
9901
|
+
"--expected-config-id <id>",
|
|
9902
|
+
"The configId you last read for this client"
|
|
9352
9903
|
).option("--project <id-or-name>", "Project name or ID").action(
|
|
9353
9904
|
async (options, command) => {
|
|
9354
9905
|
const globalOptions = getGlobalOptions(command);
|
|
9355
9906
|
const splitIds = (value) => value.split(",").map((id) => id.trim()).filter(Boolean);
|
|
9356
|
-
const input = validateInput2(
|
|
9907
|
+
const input = validateInput2(setClientServersOperation, {
|
|
9357
9908
|
project: resolveCloudProjectArgs(options).project,
|
|
9358
|
-
|
|
9909
|
+
client: selectorOf(options),
|
|
9359
9910
|
serverIds: splitIds(options.serverIds),
|
|
9911
|
+
expectedConfigId: options.expectedConfigId,
|
|
9360
9912
|
...options.optionalServerIds ? { optionalServerIds: splitIds(options.optionalServerIds) } : {}
|
|
9361
9913
|
});
|
|
9362
9914
|
const result = await runPlatformOperation(
|
|
9363
9915
|
platformOptionsOf(command),
|
|
9364
9916
|
globalOptions.timeout,
|
|
9365
|
-
({ client, signal }) =>
|
|
9917
|
+
({ client, signal }) => setClientServersOperation.execute(input, { client, signal })
|
|
9366
9918
|
);
|
|
9367
9919
|
writeResult(result, globalOptions.format);
|
|
9368
9920
|
}
|
|
9369
9921
|
);
|
|
9370
|
-
|
|
9922
|
+
withClientSelector(
|
|
9923
|
+
clients.command("duplicate").description("Duplicate a client's current config into a new client")
|
|
9924
|
+
).option("--name <name>", "Name for the new client").option("--project <id-or-name>", "Project name or ID").action(
|
|
9371
9925
|
async (options, command) => {
|
|
9372
9926
|
const globalOptions = getGlobalOptions(command);
|
|
9373
|
-
const input = validateInput2(
|
|
9927
|
+
const input = validateInput2(duplicateClientOperation, {
|
|
9374
9928
|
project: resolveCloudProjectArgs(options).project,
|
|
9375
|
-
|
|
9929
|
+
client: selectorOf(options),
|
|
9376
9930
|
...options.name === void 0 ? {} : { name: options.name }
|
|
9377
9931
|
});
|
|
9378
9932
|
const result = await runPlatformOperation(
|
|
9379
9933
|
platformOptionsOf(command),
|
|
9380
9934
|
globalOptions.timeout,
|
|
9381
|
-
({ client, signal }) =>
|
|
9935
|
+
({ client, signal }) => duplicateClientOperation.execute(input, { client, signal })
|
|
9382
9936
|
);
|
|
9383
9937
|
writeResult(result, globalOptions.format);
|
|
9384
9938
|
}
|
|
@@ -12474,7 +13028,7 @@ function registerCloudCommands(program) {
|
|
|
12474
13028
|
registerTunnelCommands(cloud);
|
|
12475
13029
|
cloud.commandsGroup("Eval and environments:");
|
|
12476
13030
|
registerEvalCommands(cloud);
|
|
12477
|
-
|
|
13031
|
+
registerClientsCommands(cloud);
|
|
12478
13032
|
registerEnvironmentsCommands(cloud);
|
|
12479
13033
|
registerImagesCommands(cloud);
|
|
12480
13034
|
cloud.commandsGroup("Swarms and user testing:");
|