@mcpjam/cli 5.16.1 → 6.0.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 +41 -138
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { spawn } from 'child_process';
|
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import os, { homedir, tmpdir } from 'os';
|
|
12
12
|
import { RUN_LAUNCH_HEADERS, getRegistryDirectoryServerOperation, isPlatformApiError, resolveProject, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, cancelProjectServerConnectionOperation, listChatSessionsOperation, sendChatMessageOperation, createTunnelOperation, listEvalSuiteRunsOperation, listEvalSuiteRevisionsOperation, runEvalSuiteOperation, getEvalRunOperation, getEvalRunRouteFactsOperation, getEvalRunServerFactsOperation, proposeEvalDescriptionRewriteOperation, startEvalDescriptionExperimentOperation, getEvalDescriptionExperimentOperation, cancelEvalRunOperation, backtestEvalRunJudgeOperation, backtestEvalRunOperation, requestEvalRunJudgeOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, importEvalCasesOperation, createClientOperation, updateClientOperation, setClientServersOperation, duplicateClientOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createSecretOperation, updateSecretOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, listTraceDestinationsOperation, getTraceDestinationOperation, createTraceDestinationOperation, updateTraceDestinationOperation, deleteTraceDestinationOperation, testTraceDestinationOperation, pauseTraceDestinationOperation, resumeTraceDestinationOperation, backfillTraceDestinationOperation, listTraceDestinationBackfillsOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, driveChatSessionBrowserOperation, observeChatSessionBrowserOperation, describePlatformRefusal, platformRefusalHint, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, listEvalSuiteStageAnalyticsOperation, getEvalRunStageAnalyticsOperation, listEvalGithubReposOperation, connectEvalGithubRepoOperation, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listSecretsOperation, getSecretOperation, deleteSecretOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listProjectSkillsOperation, getProjectSkillOperation, listGoalsOperation, listGoalRunsOperation, getGoalRunOperation, launchGoalRunOperation, cancelGoalRunOperation, listGoalRunSessionsOperation, platformBrowserToolPolicySchema, listServerToolsOperation, runEvalCaseOperation, sendFeedbackOperation, getCapabilitiesOperation, getStudyOperation, listStudySessionsOperation, getStudySessionOperation, getStudyMetricsOperation, getStudyUsageOperation, listStudyFindingsOperation, getStudySignalsOperation, getStudyInsightsOperation, requestStudyInsightsOperation, cancelStudyInsightsOperation, dismissStudyFindingOperation, undismissStudyFindingOperation, updateStudyOperation, setStudyGuestExecutionOperation, rotateStudyLinkOperation, upsertStudyMemberOperation, removeStudyMemberOperation, rebindStudyOperation, listStudiesOperation, publishStudyOperation, unpublishStudyOperation, searchSessionsOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getGoalOperation, createGoalOperation, updateGoalOperation, archiveGoalOperation, generateGoalsOperation, getSwarmOverviewOperation, getGoalRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getSwarmRunInsightsOperation, requestSwarmRunInsightsOperation, cancelSwarmRunInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, startMuseReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
|
|
13
|
+
import { getAuthFilePath, readStoredAuth, clearStoredAuth, getOAuthAccessToken as getOAuthAccessToken$1, exchangePlatformToken, writeStoredAuth as writeStoredAuth$1 } from '@mcpjam/sdk/platform-auth';
|
|
13
14
|
import { isDeepStrictEqual } from 'util';
|
|
14
15
|
import { swarmVerdictLabel, composeSuiteGateWithBaseReport, EVAL_SUITE_SCHEMA_VERSION, EVAL_SUITE_SCHEMA_VERSIONS, MAX_BATCH_CREATE_CASES, filterSuppressedSuiteAssertions, DEFAULT_SUITE_WIDE_THRESHOLD_PERCENT, evalSuiteFileSchema, MAX_IMPORT_NOTE_CHARS, isOpaqueId } from '@mcpjam/sdk/contract';
|
|
15
16
|
import { HOST_TEMPLATES, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
|
|
@@ -29,7 +30,7 @@ import { selectPluginMcpServerMap, detectPluginMcpTransport } from '@mcpjam/sdk/
|
|
|
29
30
|
|
|
30
31
|
// package.json
|
|
31
32
|
var package_default = {
|
|
32
|
-
version: "
|
|
33
|
+
version: "6.0.0"};
|
|
33
34
|
function conformanceExitCode(result) {
|
|
34
35
|
if (result.outcome === "incomplete") return 3;
|
|
35
36
|
if (result.outcome === "failed") return 1;
|
|
@@ -3720,93 +3721,20 @@ function appendProjectLinkHint(message, scope) {
|
|
|
3720
3721
|
return `${message}
|
|
3721
3722
|
Selector came from ${scope.linkPath} \u2014 re-run \`mcpjam cloud link\`.`;
|
|
3722
3723
|
}
|
|
3723
|
-
var AUTH_STORE_VERSION = 1;
|
|
3724
|
-
function getAuthFilePath(options = {}) {
|
|
3725
|
-
const env = options.env ?? process.env;
|
|
3726
|
-
const platform = options.platform ?? process.platform;
|
|
3727
|
-
const homeDirectory = options.homeDirectory ?? homedir();
|
|
3728
|
-
if (env.MCPJAM_AUTH_FILE) {
|
|
3729
|
-
return env.MCPJAM_AUTH_FILE;
|
|
3730
|
-
}
|
|
3731
|
-
if (platform === "win32") {
|
|
3732
|
-
return join(
|
|
3733
|
-
env.APPDATA || join(homeDirectory, "AppData", "Roaming"),
|
|
3734
|
-
"mcpjam",
|
|
3735
|
-
"auth.json"
|
|
3736
|
-
);
|
|
3737
|
-
}
|
|
3738
|
-
return join(
|
|
3739
|
-
env.XDG_CONFIG_HOME || join(homeDirectory, ".config"),
|
|
3740
|
-
"mcpjam",
|
|
3741
|
-
"auth.json"
|
|
3742
|
-
);
|
|
3743
|
-
}
|
|
3744
|
-
function readStoredAuth(filePath) {
|
|
3745
|
-
let raw;
|
|
3746
|
-
try {
|
|
3747
|
-
raw = readFileSync(filePath, "utf8");
|
|
3748
|
-
} catch {
|
|
3749
|
-
return null;
|
|
3750
|
-
}
|
|
3751
|
-
let parsed;
|
|
3752
|
-
try {
|
|
3753
|
-
parsed = JSON.parse(raw);
|
|
3754
|
-
} catch {
|
|
3755
|
-
return null;
|
|
3756
|
-
}
|
|
3757
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
3758
|
-
return null;
|
|
3759
|
-
}
|
|
3760
|
-
const record = parsed;
|
|
3761
|
-
if (record.version !== AUTH_STORE_VERSION || typeof record.issuer !== "string" || typeof record.clientId !== "string" || typeof record.tokenEndpoint !== "string" || typeof record.accessToken !== "string") {
|
|
3762
|
-
return null;
|
|
3763
|
-
}
|
|
3764
|
-
return {
|
|
3765
|
-
version: AUTH_STORE_VERSION,
|
|
3766
|
-
issuer: record.issuer,
|
|
3767
|
-
clientId: record.clientId,
|
|
3768
|
-
tokenEndpoint: record.tokenEndpoint,
|
|
3769
|
-
accessToken: record.accessToken,
|
|
3770
|
-
// Hand-edited files may hold a non-URL; dropping it here means readers
|
|
3771
|
-
// fall back to the default base URL instead of producing broken requests.
|
|
3772
|
-
...typeof record.apiUrl === "string" && URL.canParse(record.apiUrl) ? { apiUrl: record.apiUrl } : {},
|
|
3773
|
-
...typeof record.refreshToken === "string" ? { refreshToken: record.refreshToken } : {},
|
|
3774
|
-
...typeof record.expiresAt === "number" ? { expiresAt: record.expiresAt } : {},
|
|
3775
|
-
...typeof record.email === "string" && record.email.trim() ? { email: record.email.trim() } : {},
|
|
3776
|
-
...typeof record.plan === "string" && record.plan.trim() ? { plan: record.plan.trim() } : {}
|
|
3777
|
-
};
|
|
3778
|
-
}
|
|
3779
3724
|
async function writeStoredAuth(contents, filePath) {
|
|
3780
|
-
const directory = dirname(filePath);
|
|
3781
|
-
const temporaryPath = join(
|
|
3782
|
-
directory,
|
|
3783
|
-
`.${basename(filePath)}.${randomUUID()}.tmp`
|
|
3784
|
-
);
|
|
3785
3725
|
try {
|
|
3786
|
-
await
|
|
3787
|
-
await writeFile(temporaryPath, `${JSON.stringify(contents, null, 2)}
|
|
3788
|
-
`, {
|
|
3789
|
-
encoding: "utf8",
|
|
3790
|
-
mode: 384
|
|
3791
|
-
});
|
|
3792
|
-
await chmod(temporaryPath, 384);
|
|
3793
|
-
await rename(temporaryPath, filePath);
|
|
3726
|
+
return await writeStoredAuth$1(contents, filePath);
|
|
3794
3727
|
} catch (error) {
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3728
|
+
throw operationalError(
|
|
3729
|
+
error instanceof Error ? error.message : String(error),
|
|
3730
|
+
{
|
|
3731
|
+
source: error instanceof Error && error.cause instanceof Error ? error.cause.message : String(error)
|
|
3732
|
+
}
|
|
3733
|
+
);
|
|
3799
3734
|
}
|
|
3800
|
-
return filePath;
|
|
3801
|
-
}
|
|
3802
|
-
async function clearStoredAuth(filePath) {
|
|
3803
|
-
const existed = readStoredAuth(filePath) !== null;
|
|
3804
|
-
await rm(filePath, { force: true });
|
|
3805
|
-
return existed;
|
|
3806
3735
|
}
|
|
3807
3736
|
var DEFAULT_PLATFORM_ORIGIN = "https://app.mcpjam.com";
|
|
3808
3737
|
var LEGACY_API_KEY_PREFIX = "mcpjam_";
|
|
3809
|
-
var TOKEN_REFRESH_SKEW_MS = 6e4;
|
|
3810
3738
|
var DEFAULT_LOGIN_TIMEOUT_MS = 5 * 6e4;
|
|
3811
3739
|
var LEGACY_KEY_REMEDY = "Legacy mcpjam_ API keys are not supported by platform commands. Create an sk_ key at https://app.mcpjam.com/settings/api-keys or run `mcpjam cloud login`.";
|
|
3812
3740
|
function inspectExplicitApiKey(value) {
|
|
@@ -3848,42 +3776,11 @@ function resolvePlatformCredential(options, deps = {}) {
|
|
|
3848
3776
|
};
|
|
3849
3777
|
}
|
|
3850
3778
|
async function getOAuthAccessToken(deps) {
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
const now = deps.now ?? Date.now;
|
|
3856
|
-
const expiresSoon = stored.expiresAt !== void 0 && stored.expiresAt - now() <= TOKEN_REFRESH_SKEW_MS;
|
|
3857
|
-
if (!expiresSoon) {
|
|
3858
|
-
return stored.accessToken;
|
|
3859
|
-
}
|
|
3860
|
-
if (!stored.refreshToken) {
|
|
3861
|
-
throw operationalError("Login expired. Run `mcpjam cloud login` again.");
|
|
3779
|
+
try {
|
|
3780
|
+
return await getOAuthAccessToken$1(deps);
|
|
3781
|
+
} catch (error) {
|
|
3782
|
+
throw operationalError(error instanceof Error ? error.message : String(error));
|
|
3862
3783
|
}
|
|
3863
|
-
const refreshed = await refreshStoredAuth(stored, deps);
|
|
3864
|
-
return refreshed.accessToken;
|
|
3865
|
-
}
|
|
3866
|
-
async function refreshStoredAuth(stored, deps) {
|
|
3867
|
-
const tokens = await exchangeToken(
|
|
3868
|
-
stored.tokenEndpoint,
|
|
3869
|
-
{
|
|
3870
|
-
grant_type: "refresh_token",
|
|
3871
|
-
client_id: stored.clientId,
|
|
3872
|
-
refresh_token: stored.refreshToken
|
|
3873
|
-
},
|
|
3874
|
-
deps.fetchFn ?? fetch,
|
|
3875
|
-
"Token refresh failed. Run `mcpjam cloud login` again.",
|
|
3876
|
-
deps.now
|
|
3877
|
-
);
|
|
3878
|
-
const refreshed = {
|
|
3879
|
-
...stored,
|
|
3880
|
-
accessToken: tokens.accessToken,
|
|
3881
|
-
// AuthKit rotates refresh tokens; keep the old one only if none returned.
|
|
3882
|
-
...tokens.refreshToken ? { refreshToken: tokens.refreshToken } : {},
|
|
3883
|
-
...tokens.expiresAt !== void 0 ? { expiresAt: tokens.expiresAt } : {}
|
|
3884
|
-
};
|
|
3885
|
-
await writeStoredAuth(refreshed, deps.authFilePath);
|
|
3886
|
-
return refreshed;
|
|
3887
3784
|
}
|
|
3888
3785
|
async function runPlatformLogin(target, deps = {}) {
|
|
3889
3786
|
const fetchFn = deps.fetchFn ?? fetch;
|
|
@@ -4042,29 +3939,12 @@ async function fetchCliAuthConfig(platformOrigin, fetchFn) {
|
|
|
4042
3939
|
redirectUri: body.redirectUri
|
|
4043
3940
|
};
|
|
4044
3941
|
}
|
|
4045
|
-
async function exchangeToken(
|
|
4046
|
-
let response;
|
|
3942
|
+
async function exchangeToken(...args) {
|
|
4047
3943
|
try {
|
|
4048
|
-
|
|
4049
|
-
method: "POST",
|
|
4050
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
4051
|
-
body: new URLSearchParams(params).toString()
|
|
4052
|
-
});
|
|
3944
|
+
return await exchangePlatformToken(...args);
|
|
4053
3945
|
} catch (error) {
|
|
4054
|
-
throw operationalError(
|
|
4055
|
-
`${failureMessage} Could not reach ${tokenEndpoint}: ${error instanceof Error ? error.message : String(error)}`
|
|
4056
|
-
);
|
|
3946
|
+
throw operationalError(error instanceof Error ? error.message : String(error));
|
|
4057
3947
|
}
|
|
4058
|
-
const body = await response.json().catch(() => null);
|
|
4059
|
-
if (!response.ok || typeof body?.access_token !== "string") {
|
|
4060
|
-
const detail = typeof body?.error_description === "string" ? body.error_description : typeof body?.error === "string" ? body.error : `HTTP ${response.status}`;
|
|
4061
|
-
throw operationalError(`${failureMessage} (${detail})`);
|
|
4062
|
-
}
|
|
4063
|
-
return {
|
|
4064
|
-
accessToken: body.access_token,
|
|
4065
|
-
...typeof body.refresh_token === "string" ? { refreshToken: body.refresh_token } : {},
|
|
4066
|
-
...typeof body.expires_in === "number" && Number.isFinite(body.expires_in) ? { expiresAt: now() + body.expires_in * 1e3 } : {}
|
|
4067
|
-
};
|
|
4068
3948
|
}
|
|
4069
3949
|
function readGithubEvent(env) {
|
|
4070
3950
|
if (!env.GITHUB_EVENT_PATH) return void 0;
|
|
@@ -23702,6 +23582,15 @@ function createMcpjamConnectionResolver(options, deps) {
|
|
|
23702
23582
|
message
|
|
23703
23583
|
);
|
|
23704
23584
|
};
|
|
23585
|
+
const selectedKey = options.apiKey ?? deps.env.MCPJAM_API_KEY;
|
|
23586
|
+
if (selectedKey !== void 0 && !selectedKey.trim().startsWith("sk_")) {
|
|
23587
|
+
throw new SuiteFileRunError({
|
|
23588
|
+
code: "CREDENTIALS_REJECTED",
|
|
23589
|
+
phase: "setup",
|
|
23590
|
+
category: "credentials",
|
|
23591
|
+
message: "This MCPJam API key is invalid or retired. Create an sk_ key or run `mcpjam cloud login`."
|
|
23592
|
+
});
|
|
23593
|
+
}
|
|
23705
23594
|
const credentialDeps = {
|
|
23706
23595
|
env: deps.env,
|
|
23707
23596
|
warn,
|
|
@@ -24206,10 +24095,19 @@ function readSuiteFile(filePath, cwd) {
|
|
|
24206
24095
|
throw usageError(`Suite file ${resolvedPath} is not valid UTF-8.`);
|
|
24207
24096
|
}
|
|
24208
24097
|
}
|
|
24209
|
-
function progressWriter(quiet) {
|
|
24098
|
+
function progressWriter(quiet, credentialSource) {
|
|
24210
24099
|
return (event) => {
|
|
24211
24100
|
if (quiet) return;
|
|
24212
24101
|
switch (event.type) {
|
|
24102
|
+
case "identity":
|
|
24103
|
+
process.stderr.write(
|
|
24104
|
+
`MCPJam identity: ${credentialSource}; organization ${event.organizationId}; project ${event.projectId}.
|
|
24105
|
+
`
|
|
24106
|
+
);
|
|
24107
|
+
process.stderr.write(
|
|
24108
|
+
"Run start recorded. Planned iterations are not completed usage. Results remain local.\n"
|
|
24109
|
+
);
|
|
24110
|
+
return;
|
|
24213
24111
|
case "setup":
|
|
24214
24112
|
if (event.stage === "connect" && event.server) {
|
|
24215
24113
|
process.stderr.write(`Connecting to ${event.server}\u2026
|
|
@@ -24376,6 +24274,8 @@ Received ${signal}; stopping and writing the partial report\u2026
|
|
|
24376
24274
|
}
|
|
24377
24275
|
}
|
|
24378
24276
|
const runOptions = {
|
|
24277
|
+
surface: "cli",
|
|
24278
|
+
clientVersion: program.version(),
|
|
24379
24279
|
servers,
|
|
24380
24280
|
...caseIds ? { caseIds } : {},
|
|
24381
24281
|
inference: {
|
|
@@ -24404,7 +24304,10 @@ Received ${signal}; stopping and writing the partial report\u2026
|
|
|
24404
24304
|
setupTimeoutMs: globalOptions.timeout,
|
|
24405
24305
|
signal: controller.signal,
|
|
24406
24306
|
// Progress is always stderr, so stdout stays one document.
|
|
24407
|
-
onProgress: progressWriter(
|
|
24307
|
+
onProgress: progressWriter(
|
|
24308
|
+
globalOptions.quiet,
|
|
24309
|
+
describeCloudCredential(options, { env }).credential.source
|
|
24310
|
+
)
|
|
24408
24311
|
};
|
|
24409
24312
|
const runner = dependencies.runtime ? createSuiteFileRunner(dependencies.runtime) : { run: runSuiteFile };
|
|
24410
24313
|
try {
|