@mcpjam/cli 5.4.0 → 5.5.1
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 +343 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { mkdir, writeFile, readFile, chmod, rename, rm, open, unlink, stat } fro
|
|
|
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, cancelProjectServerConnectionOperation, 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, listProjectSkillsOperation, getProjectSkillOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, listServerToolsOperation, 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';
|
|
12
|
+
import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, cancelProjectServerConnectionOperation, 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, createSecretOperation, updateSecretOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, listEvalSuiteStageAnalyticsOperation, getEvalRunStageAnalyticsOperation, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listSecretsOperation, getSecretOperation, deleteSecretOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listProjectSkillsOperation, getProjectSkillOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, listServerToolsOperation, 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, MAX_IMPORT_NOTE_CHARS, isOpaqueId } from '@mcpjam/sdk/contract';
|
|
15
15
|
import { HOST_TEMPLATES, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
|
|
@@ -27,7 +27,7 @@ import { PostHog } from 'posthog-node';
|
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
29
|
var package_default = {
|
|
30
|
-
version: "5.
|
|
30
|
+
version: "5.5.1"};
|
|
31
31
|
function conformanceExitCode(result) {
|
|
32
32
|
if (result.outcome === "incomplete") return 3;
|
|
33
33
|
if (result.outcome === "failed") return 1;
|
|
@@ -601,9 +601,9 @@ function writeReporterResult(reporter, report) {
|
|
|
601
601
|
}
|
|
602
602
|
writeResult(renderStructuredRunJson(report), "json");
|
|
603
603
|
}
|
|
604
|
-
function writeEvalDecisionSummary(format, summary, destination = process.stdout) {
|
|
604
|
+
function writeEvalDecisionSummary(format, summary, destination = process.stdout, options = {}) {
|
|
605
605
|
if (format !== "human" || !summary) return;
|
|
606
|
-
destination.write(`${formatEvalRunDecisionSummary(summary)}
|
|
606
|
+
destination.write(`${formatEvalRunDecisionSummary(summary, options)}
|
|
607
607
|
`);
|
|
608
608
|
}
|
|
609
609
|
async function writeJsonArtifact(outputPath, payload) {
|
|
@@ -4942,7 +4942,7 @@ function registerEnvironmentsCommands(program) {
|
|
|
4942
4942
|
"Project-shared sandbox image (see `mcpjam cloud images`) to pin: eval runs boot a fresh sandbox from it"
|
|
4943
4943
|
).option(
|
|
4944
4944
|
"--file <path>",
|
|
4945
|
-
"Environment JSON file with any of name/hostId/description/serverAttachmentId/modelId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
|
|
4945
|
+
"Environment JSON file with any of name/hostId/description/serverAttachmentId/modelId/skillSelection/secretSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
|
|
4946
4946
|
).option("--json <json>", "Inline environment JSON (or @file, or -)").action(
|
|
4947
4947
|
async (options, command) => {
|
|
4948
4948
|
const globalOptions = getGlobalOptions(command);
|
|
@@ -5042,7 +5042,7 @@ function registerEnvironmentsCommands(program) {
|
|
|
5042
5042
|
}
|
|
5043
5043
|
);
|
|
5044
5044
|
environments.command("update").description(
|
|
5045
|
-
"Edit an environment. Only the fields you pass change; use --clear-model, or --file/--json with a null value, to clear serverAttachmentId, modelId, skillSelection, pluginVersionIds, or sandboxImageId"
|
|
5045
|
+
"Edit an environment. Only the fields you pass change; use --clear-model, or --file/--json with a null value, to clear serverAttachmentId, modelId, skillSelection, secretSelection, pluginVersionIds, or sandboxImageId"
|
|
5046
5046
|
).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
|
|
5047
5047
|
"--expected-revision <n>",
|
|
5048
5048
|
"The revision you last read (from `environments get`); a stale value is rejected instead of overwriting a concurrent edit"
|
|
@@ -8718,7 +8718,8 @@ async function runEvalCompare(options, command) {
|
|
|
8718
8718
|
report: outcome.report,
|
|
8719
8719
|
reporter,
|
|
8720
8720
|
out: options.out,
|
|
8721
|
-
format: globalOptions.format
|
|
8721
|
+
format: globalOptions.format,
|
|
8722
|
+
...outcome.decisionSummary ? { decisionSummary: outcome.decisionSummary } : {}
|
|
8722
8723
|
},
|
|
8723
8724
|
outcome.compare ? buildRunCompareReport(outcome.compare, outcome.report, {
|
|
8724
8725
|
flakyCases: outcome.flakyCases,
|
|
@@ -8900,7 +8901,16 @@ async function writeCompareResult(args, structured) {
|
|
|
8900
8901
|
return;
|
|
8901
8902
|
}
|
|
8902
8903
|
writeResult(
|
|
8903
|
-
{
|
|
8904
|
+
{
|
|
8905
|
+
compare: args.report,
|
|
8906
|
+
exitCode: evalGateExitCode(args.report),
|
|
8907
|
+
// JSON ONLY. `writeResult` pretty-prints this same object in human
|
|
8908
|
+
// format, so including it there would put the raw wire enums on the
|
|
8909
|
+
// terminal immediately above the label-aware block that exists to
|
|
8910
|
+
// replace them — the narrative twice, once unreadably. `eval status`
|
|
8911
|
+
// strips it for exactly this reason.
|
|
8912
|
+
...args.format === "json" && args.decisionSummary ? { decisionSummary: args.decisionSummary } : {}
|
|
8913
|
+
},
|
|
8904
8914
|
args.format
|
|
8905
8915
|
);
|
|
8906
8916
|
}
|
|
@@ -9500,7 +9510,7 @@ function registerEvalCommands(program) {
|
|
|
9500
9510
|
] : []
|
|
9501
9511
|
);
|
|
9502
9512
|
if (!needsReport) {
|
|
9503
|
-
const soloSummary =
|
|
9513
|
+
const soloSummary = result.targets.length === 1 && runs.length === 1 && TERMINAL_RUN_STATUSES.has(runs[0].status) ? await readEvalRunDecisionSummary(
|
|
9504
9514
|
client,
|
|
9505
9515
|
signal,
|
|
9506
9516
|
result.project.id,
|
|
@@ -9617,7 +9627,20 @@ function registerEvalCommands(program) {
|
|
|
9617
9627
|
writeReporterResult(reporter, report);
|
|
9618
9628
|
} else {
|
|
9619
9629
|
writeResult(
|
|
9620
|
-
{
|
|
9630
|
+
{
|
|
9631
|
+
launch: result,
|
|
9632
|
+
runs: completion.runs,
|
|
9633
|
+
// ONE DOCUMENT, and the decision belongs in it. `--format json` is
|
|
9634
|
+
// the stable contract and the human block below is not, so a
|
|
9635
|
+
// pipeline that reads stdout used to get run ids and a status and
|
|
9636
|
+
// had to make a second call to learn what the run decided.
|
|
9637
|
+
//
|
|
9638
|
+
// JSON ONLY, though: `writeResult` pretty-prints this same object
|
|
9639
|
+
// in human format, so leaving it ungated would print the raw wire
|
|
9640
|
+
// enums directly above the label-aware block written to replace
|
|
9641
|
+
// them. `eval status` strips it for the same reason.
|
|
9642
|
+
...globalOptions.format === "json" && completion.decisionSummary ? { decisionSummary: completion.decisionSummary } : {}
|
|
9643
|
+
},
|
|
9621
9644
|
globalOptions.format
|
|
9622
9645
|
);
|
|
9623
9646
|
writeRunGroupSummary(globalOptions.format, webOrigin, result);
|
|
@@ -9655,24 +9678,45 @@ function registerEvalCommands(program) {
|
|
|
9655
9678
|
);
|
|
9656
9679
|
addProjectOption(
|
|
9657
9680
|
evals.command("status").description("Get the status and summary of an eval run").requiredOption("--run <id>", "Eval run ID (from `eval run`)")
|
|
9681
|
+
).option(
|
|
9682
|
+
"--diagnostics-limit <n>",
|
|
9683
|
+
"Failure diagnostics per page (1\u2013200; default 20)"
|
|
9684
|
+
).option(
|
|
9685
|
+
"--diagnostics-cursor <cursor>",
|
|
9686
|
+
"Cursor from a previous response's decisionSummary.diagnostics.nextCursor"
|
|
9687
|
+
).option(
|
|
9688
|
+
"--stages",
|
|
9689
|
+
"Print all six user-value chain rows for each failing trial (human output)"
|
|
9658
9690
|
).action(
|
|
9659
9691
|
async (options, command) => {
|
|
9660
9692
|
const globalOptions = getGlobalOptions(command);
|
|
9661
9693
|
let webOrigin = DEFAULT_PLATFORM_ORIGIN;
|
|
9662
9694
|
let decisionSummary;
|
|
9663
9695
|
const resolved = resolveCloudProjectArgs(options);
|
|
9696
|
+
const input = validateOpInput(
|
|
9697
|
+
getEvalRunOperation,
|
|
9698
|
+
{
|
|
9699
|
+
runId: options.run,
|
|
9700
|
+
...resolved.project === void 0 ? {} : { project: resolved.project },
|
|
9701
|
+
...options.diagnosticsLimit !== void 0 ? {
|
|
9702
|
+
diagnosticsLimit: parsePositiveInteger(
|
|
9703
|
+
options.diagnosticsLimit,
|
|
9704
|
+
"--diagnostics-limit"
|
|
9705
|
+
)
|
|
9706
|
+
} : {},
|
|
9707
|
+
...options.diagnosticsCursor !== void 0 ? { diagnosticsCursor: options.diagnosticsCursor } : {}
|
|
9708
|
+
},
|
|
9709
|
+
{ projectOptional: true }
|
|
9710
|
+
);
|
|
9664
9711
|
const result = await runPlatformOperation(
|
|
9665
9712
|
platformOptionsOf(command),
|
|
9666
9713
|
globalOptions.timeout,
|
|
9667
9714
|
async (context) => {
|
|
9668
9715
|
webOrigin = context.webOrigin;
|
|
9669
|
-
const result2 = await getEvalRunOperation.execute(
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
},
|
|
9674
|
-
{ client: context.client, signal: context.signal }
|
|
9675
|
-
);
|
|
9716
|
+
const result2 = await getEvalRunOperation.execute(input, {
|
|
9717
|
+
client: context.client,
|
|
9718
|
+
signal: context.signal
|
|
9719
|
+
});
|
|
9676
9720
|
if (globalOptions.format === "human" && TERMINAL_RUN_STATUSES.has(result2.run.status) && result2.run.result !== "passed") {
|
|
9677
9721
|
decisionSummary = result2.decisionSummary;
|
|
9678
9722
|
}
|
|
@@ -9692,7 +9736,8 @@ function registerEvalCommands(program) {
|
|
|
9692
9736
|
writeEvalDecisionSummary(
|
|
9693
9737
|
globalOptions.format,
|
|
9694
9738
|
decisionSummary,
|
|
9695
|
-
process.stdout
|
|
9739
|
+
process.stdout,
|
|
9740
|
+
{ stages: options.stages === true }
|
|
9696
9741
|
);
|
|
9697
9742
|
writeRunLink(globalOptions.format, webOrigin, {
|
|
9698
9743
|
projectId: result.project.id,
|
|
@@ -9701,6 +9746,48 @@ function registerEvalCommands(program) {
|
|
|
9701
9746
|
});
|
|
9702
9747
|
}
|
|
9703
9748
|
);
|
|
9749
|
+
addProjectOption(
|
|
9750
|
+
evals.command("stage-analytics").description(
|
|
9751
|
+
"Read the user-value chain funnel for one run (--run) or a suite's runs as a trend series (--suite)"
|
|
9752
|
+
)
|
|
9753
|
+
).option("--run <id>", "Eval run ID \u2014 one run's funnel").option(
|
|
9754
|
+
"--suite <id-or-name>",
|
|
9755
|
+
"Eval suite name or ID \u2014 one page of runs, newest first"
|
|
9756
|
+
).option(
|
|
9757
|
+
"--cursor <cursor>",
|
|
9758
|
+
"Pagination cursor from a previous response (--suite only)"
|
|
9759
|
+
).option("--limit <n>", "Documents per page, 1-100 (--suite only)").action(
|
|
9760
|
+
async (options, command) => {
|
|
9761
|
+
if (options.run === void 0 === (options.suite === void 0)) {
|
|
9762
|
+
throw usageError(
|
|
9763
|
+
"Provide either --run <id> or --suite <id-or-name>, not both."
|
|
9764
|
+
);
|
|
9765
|
+
}
|
|
9766
|
+
const suiteMode = options.suite !== void 0;
|
|
9767
|
+
if (!suiteMode && (options.cursor !== void 0 || options.limit !== void 0)) {
|
|
9768
|
+
throw usageError("--cursor and --limit apply to --suite only.");
|
|
9769
|
+
}
|
|
9770
|
+
const operation = suiteMode ? listEvalSuiteStageAnalyticsOperation : getEvalRunStageAnalyticsOperation;
|
|
9771
|
+
const input = validateOpInput(
|
|
9772
|
+
operation,
|
|
9773
|
+
{
|
|
9774
|
+
...options.project === void 0 ? {} : { project: options.project },
|
|
9775
|
+
...suiteMode ? {
|
|
9776
|
+
suite: options.suite,
|
|
9777
|
+
...options.cursor !== void 0 ? { cursor: options.cursor } : {},
|
|
9778
|
+
...options.limit !== void 0 ? { limit: parsePositiveInteger(options.limit, "--limit") } : {}
|
|
9779
|
+
} : { runId: options.run }
|
|
9780
|
+
},
|
|
9781
|
+
{ projectOptional: true }
|
|
9782
|
+
);
|
|
9783
|
+
await executeOp(
|
|
9784
|
+
operation,
|
|
9785
|
+
input,
|
|
9786
|
+
options,
|
|
9787
|
+
command
|
|
9788
|
+
);
|
|
9789
|
+
}
|
|
9790
|
+
);
|
|
9704
9791
|
addProjectOption(
|
|
9705
9792
|
evals.command("cancel").description(
|
|
9706
9793
|
"Cancel an in-flight eval run (no-op if already cancelled; errors if it already finished)"
|
|
@@ -11863,6 +11950,243 @@ function registerScenariosCommands(program) {
|
|
|
11863
11950
|
}
|
|
11864
11951
|
);
|
|
11865
11952
|
}
|
|
11953
|
+
function resolveSecretValue(options, { required }) {
|
|
11954
|
+
const supplied = [
|
|
11955
|
+
options.value !== void 0 ? "--value" : null,
|
|
11956
|
+
options.valueFile !== void 0 ? "--value-file" : null,
|
|
11957
|
+
options.valueEnv !== void 0 ? "--value-env" : null
|
|
11958
|
+
].filter((flag) => flag !== null);
|
|
11959
|
+
if (supplied.length > 1) {
|
|
11960
|
+
throw usageError(
|
|
11961
|
+
`Provide exactly one of --value, --value-file, or --value-env (got ${supplied.join(
|
|
11962
|
+
", "
|
|
11963
|
+
)}).`
|
|
11964
|
+
);
|
|
11965
|
+
}
|
|
11966
|
+
if (supplied.length === 0) {
|
|
11967
|
+
if (!required) return void 0;
|
|
11968
|
+
throw usageError(
|
|
11969
|
+
"A value is required. Prefer --value-file <path>, --value-env <VAR>, or `--value -` to read stdin; --value <literal> works but is written to your shell history."
|
|
11970
|
+
);
|
|
11971
|
+
}
|
|
11972
|
+
if (options.valueEnv !== void 0) {
|
|
11973
|
+
const value = process.env[options.valueEnv];
|
|
11974
|
+
if (value === void 0 || value === "") {
|
|
11975
|
+
throw usageError(
|
|
11976
|
+
`Environment variable "${options.valueEnv}" is not set (or is empty).`
|
|
11977
|
+
);
|
|
11978
|
+
}
|
|
11979
|
+
return value;
|
|
11980
|
+
}
|
|
11981
|
+
const readStdinOrFile = (path9) => {
|
|
11982
|
+
try {
|
|
11983
|
+
return path9 === "-" ? readFileSync(0, "utf8") : readFileSync(path9, "utf8");
|
|
11984
|
+
} catch (error) {
|
|
11985
|
+
throw usageError(
|
|
11986
|
+
path9 === "-" ? "Failed to read the secret value from stdin." : `Failed to read the secret value from "${path9}".`,
|
|
11987
|
+
{ source: error instanceof Error ? error.message : String(error) }
|
|
11988
|
+
);
|
|
11989
|
+
}
|
|
11990
|
+
};
|
|
11991
|
+
const stripOneTrailingNewline = (text) => text.replace(/\r?\n$/, "");
|
|
11992
|
+
if (options.valueFile !== void 0) {
|
|
11993
|
+
const raw = readStdinOrFile(options.valueFile);
|
|
11994
|
+
const text = options.valueFile === "-" ? stripOneTrailingNewline(raw) : raw;
|
|
11995
|
+
if (text === "") throw usageError("The secret value is empty.");
|
|
11996
|
+
return text;
|
|
11997
|
+
}
|
|
11998
|
+
if (options.value === "-") {
|
|
11999
|
+
const text = stripOneTrailingNewline(readStdinOrFile("-"));
|
|
12000
|
+
if (text === "") throw usageError("The secret value is empty.");
|
|
12001
|
+
return text;
|
|
12002
|
+
}
|
|
12003
|
+
if (options.value === "") throw usageError("The secret value is empty.");
|
|
12004
|
+
return options.value;
|
|
12005
|
+
}
|
|
12006
|
+
function brokerFields(options) {
|
|
12007
|
+
return {
|
|
12008
|
+
...options.host !== void 0 && options.host.length > 0 ? { brokerHosts: options.host } : {},
|
|
12009
|
+
...options.header !== void 0 ? { brokerHeader: options.header } : {},
|
|
12010
|
+
...options.template !== void 0 ? { brokerTemplate: options.template } : {}
|
|
12011
|
+
};
|
|
12012
|
+
}
|
|
12013
|
+
function collectHost(value, previous = []) {
|
|
12014
|
+
return [...previous, value];
|
|
12015
|
+
}
|
|
12016
|
+
function registerSecretsCommands(program) {
|
|
12017
|
+
const secrets = program.command("secrets").description(
|
|
12018
|
+
"Store and manage the project credentials a workflow needs (stripe, gh, psql). Write-only: no command prints a value."
|
|
12019
|
+
);
|
|
12020
|
+
secrets.command("list").description(
|
|
12021
|
+
"List the project's secrets \u2014 metadata only. Shows the project-shared ones plus your own personal ones."
|
|
12022
|
+
).option(
|
|
12023
|
+
"--project <id-or-name>",
|
|
12024
|
+
"Project name or ID (defaults to the most recently updated project)"
|
|
12025
|
+
).action(
|
|
12026
|
+
async (options, command) => {
|
|
12027
|
+
const globalOptions = getGlobalOptions(command);
|
|
12028
|
+
const result = await runPlatformOperation(
|
|
12029
|
+
platformOptionsOf(command),
|
|
12030
|
+
globalOptions.timeout,
|
|
12031
|
+
({ client, signal }) => listSecretsOperation.execute(
|
|
12032
|
+
{ project: resolveCloudProjectArgs(options).project },
|
|
12033
|
+
{ client, signal }
|
|
12034
|
+
)
|
|
12035
|
+
);
|
|
12036
|
+
writeResult(result, globalOptions.format);
|
|
12037
|
+
}
|
|
12038
|
+
);
|
|
12039
|
+
secrets.command("show").description(
|
|
12040
|
+
"Show one secret's metadata: delivery mode, host binding, sharing, last delivery. Never its value."
|
|
12041
|
+
).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").action(
|
|
12042
|
+
async (options, command) => {
|
|
12043
|
+
const globalOptions = getGlobalOptions(command);
|
|
12044
|
+
const result = await runPlatformOperation(
|
|
12045
|
+
platformOptionsOf(command),
|
|
12046
|
+
globalOptions.timeout,
|
|
12047
|
+
({ client, signal }) => getSecretOperation.execute(
|
|
12048
|
+
{
|
|
12049
|
+
project: resolveCloudProjectArgs(options).project,
|
|
12050
|
+
secret: options.secret
|
|
12051
|
+
},
|
|
12052
|
+
{ client, signal }
|
|
12053
|
+
)
|
|
12054
|
+
);
|
|
12055
|
+
writeResult(result, globalOptions.format);
|
|
12056
|
+
}
|
|
12057
|
+
);
|
|
12058
|
+
secrets.command("set").description(
|
|
12059
|
+
"Create a secret. The value comes from --value-file, --value-env, or stdin \u2014 never a positional argument."
|
|
12060
|
+
).requiredOption(
|
|
12061
|
+
"--name <NAME>",
|
|
12062
|
+
"Environment-variable name (STRIPE_API_KEY). Uppercase, digits, underscores; not starting with a digit. Immutable."
|
|
12063
|
+
).requiredOption(
|
|
12064
|
+
"--delivery <mode>",
|
|
12065
|
+
"brokered (the proxy injects it outside the sandbox \u2014 extraction-proof, not use-proof, HTTPS only) or materialized (a real env var inside the box, which is what a CLI can read, and which `env` prints)"
|
|
12066
|
+
).option(
|
|
12067
|
+
"--value-file <path>",
|
|
12068
|
+
"Read the value from a file, VERBATIM \u2014 a trailing newline is kept, because in a PEM block it is part of the credential. `-` reads stdin instead, which drops one trailing newline. Preferred."
|
|
12069
|
+
).option("--value-env <VAR>", "Read the value from an environment variable.").option(
|
|
12070
|
+
"--value <literal>",
|
|
12071
|
+
"The value inline, or `-` to read stdin. SCRIPTING ONLY: an inline literal is written to your shell history and is visible in `ps` while the command runs."
|
|
12072
|
+
).option("--description <text>", "What this credential is for.").option(
|
|
12073
|
+
"--host <hostname>",
|
|
12074
|
+
"Brokered only, repeatable: an exact hostname the header is injected on (api.stripe.com). No scheme, no port, no wildcard.",
|
|
12075
|
+
collectHost
|
|
12076
|
+
).option(
|
|
12077
|
+
"--header <name>",
|
|
12078
|
+
"Brokered only: the header name, e.g. Authorization."
|
|
12079
|
+
).option(
|
|
12080
|
+
"--template <value>",
|
|
12081
|
+
'Brokered only: the header value with {} where the secret goes, e.g. "Bearer {}".'
|
|
12082
|
+
).option(
|
|
12083
|
+
"--sharing <scope>",
|
|
12084
|
+
"project (default; delivered to every member's sessions, admin-only) or user (personal; delivered only in sessions you start)"
|
|
12085
|
+
).option(
|
|
12086
|
+
"--idempotency-key <key>",
|
|
12087
|
+
"Retry key. Pass one: a retried create without it fails as a name conflict with the row the first attempt already made."
|
|
12088
|
+
).action(
|
|
12089
|
+
async (options, command) => {
|
|
12090
|
+
const globalOptions = getGlobalOptions(command);
|
|
12091
|
+
const value = resolveSecretValue(options, { required: true });
|
|
12092
|
+
const input = createSecretOperation.inputSchema.safeParse({
|
|
12093
|
+
project: resolveCloudProjectArgs(options).project,
|
|
12094
|
+
name: options.name,
|
|
12095
|
+
value,
|
|
12096
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
12097
|
+
delivery: options.delivery,
|
|
12098
|
+
...brokerFields(options),
|
|
12099
|
+
...options.sharing !== void 0 ? { sharing: options.sharing } : {},
|
|
12100
|
+
...options.idempotencyKey !== void 0 ? { idempotencyKey: options.idempotencyKey } : {}
|
|
12101
|
+
});
|
|
12102
|
+
if (!input.success) {
|
|
12103
|
+
throw usageError(
|
|
12104
|
+
`Invalid input: ${input.error.issues.map(
|
|
12105
|
+
(issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`
|
|
12106
|
+
).join("; ")}`
|
|
12107
|
+
);
|
|
12108
|
+
}
|
|
12109
|
+
const result = await runPlatformOperation(
|
|
12110
|
+
platformOptionsOf(command),
|
|
12111
|
+
globalOptions.timeout,
|
|
12112
|
+
({ client, signal }) => createSecretOperation.execute(input.data, { client, signal })
|
|
12113
|
+
);
|
|
12114
|
+
writeResult(result, globalOptions.format);
|
|
12115
|
+
}
|
|
12116
|
+
);
|
|
12117
|
+
secrets.command("update").description(
|
|
12118
|
+
"Rotate a secret's value and/or change how it is delivered. A rotation reaches NEW RUNS ONLY \u2014 a session already running keeps the value it was given."
|
|
12119
|
+
).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").option(
|
|
12120
|
+
"--value-file <path>",
|
|
12121
|
+
"Read the new value from a file, VERBATIM \u2014 a trailing newline is kept. `-` reads stdin instead, which drops one trailing newline. Preferred."
|
|
12122
|
+
).option(
|
|
12123
|
+
"--value-env <VAR>",
|
|
12124
|
+
"Read the new value from an environment variable."
|
|
12125
|
+
).option(
|
|
12126
|
+
"--value <literal>",
|
|
12127
|
+
"The new value inline, or `-` to read stdin. SCRIPTING ONLY \u2014 see `secrets set`."
|
|
12128
|
+
).option("--description <text>", "Replacement description.").option(
|
|
12129
|
+
"--clear-description",
|
|
12130
|
+
"Remove the description entirely, leaving the secret with none."
|
|
12131
|
+
).option(
|
|
12132
|
+
"--delivery <mode>",
|
|
12133
|
+
"brokered or materialized. Switching to brokered needs --host/--header/--template in the same call; switching to materialized clears them."
|
|
12134
|
+
).option("--host <hostname>", "Brokered only, repeatable.", collectHost).option("--header <name>", "Brokered only: the header name.").option("--template <value>", 'Brokered only: e.g. "Bearer {}".').action(
|
|
12135
|
+
async (options, command) => {
|
|
12136
|
+
const globalOptions = getGlobalOptions(command);
|
|
12137
|
+
if (options.description !== void 0 && options.clearDescription) {
|
|
12138
|
+
throw usageError(
|
|
12139
|
+
"Provide either --description or --clear-description, not both."
|
|
12140
|
+
);
|
|
12141
|
+
}
|
|
12142
|
+
const value = resolveSecretValue(options, { required: false });
|
|
12143
|
+
const input = updateSecretOperation.inputSchema.safeParse({
|
|
12144
|
+
project: resolveCloudProjectArgs(options).project,
|
|
12145
|
+
secret: options.secret,
|
|
12146
|
+
...value !== void 0 ? { value } : {},
|
|
12147
|
+
// `--clear-description` is the flag spelling of the `null` the REST
|
|
12148
|
+
// route and the SDK client already accept. Distinct from
|
|
12149
|
+
// `--description ""`, which SETS an empty description.
|
|
12150
|
+
...options.clearDescription ? { description: null } : {},
|
|
12151
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
12152
|
+
...options.delivery !== void 0 ? { delivery: options.delivery } : {},
|
|
12153
|
+
...brokerFields(options)
|
|
12154
|
+
});
|
|
12155
|
+
if (!input.success) {
|
|
12156
|
+
throw usageError(
|
|
12157
|
+
`Invalid input: ${input.error.issues.map(
|
|
12158
|
+
(issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`
|
|
12159
|
+
).join("; ")}`
|
|
12160
|
+
);
|
|
12161
|
+
}
|
|
12162
|
+
const result = await runPlatformOperation(
|
|
12163
|
+
platformOptionsOf(command),
|
|
12164
|
+
globalOptions.timeout,
|
|
12165
|
+
({ client, signal }) => updateSecretOperation.execute(input.data, { client, signal })
|
|
12166
|
+
);
|
|
12167
|
+
writeResult(result, globalOptions.format);
|
|
12168
|
+
}
|
|
12169
|
+
);
|
|
12170
|
+
secrets.command("rm").description(
|
|
12171
|
+
"Delete a secret. HARD: the row and the encrypted value both go, and MCPJam stops delivering it. Not blocked when an environment still selects it \u2014 deletion never waits on cleanup. This does NOT revoke the credential at the provider that issued it, and runs already in flight keep the value they were handed."
|
|
12172
|
+
).requiredOption("--secret <id>", "Secret ID, from `cloud secrets list`").option("--project <id-or-name>", "Project name or ID").action(
|
|
12173
|
+
async (options, command) => {
|
|
12174
|
+
const globalOptions = getGlobalOptions(command);
|
|
12175
|
+
const result = await runPlatformOperation(
|
|
12176
|
+
platformOptionsOf(command),
|
|
12177
|
+
globalOptions.timeout,
|
|
12178
|
+
({ client, signal }) => deleteSecretOperation.execute(
|
|
12179
|
+
{
|
|
12180
|
+
project: resolveCloudProjectArgs(options).project,
|
|
12181
|
+
secret: options.secret
|
|
12182
|
+
},
|
|
12183
|
+
{ client, signal }
|
|
12184
|
+
)
|
|
12185
|
+
);
|
|
12186
|
+
writeResult(result, globalOptions.format);
|
|
12187
|
+
}
|
|
12188
|
+
);
|
|
12189
|
+
}
|
|
11866
12190
|
function requireQuery(value) {
|
|
11867
12191
|
const trimmed2 = value?.trim() ?? "";
|
|
11868
12192
|
if (trimmed2.length === 0) {
|
|
@@ -13942,6 +14266,7 @@ function registerCloudCommands(program) {
|
|
|
13942
14266
|
registerEvalCommands(cloud);
|
|
13943
14267
|
registerClientsCommands(cloud);
|
|
13944
14268
|
registerEnvironmentsCommands(cloud);
|
|
14269
|
+
registerSecretsCommands(cloud);
|
|
13945
14270
|
registerImagesCommands(cloud);
|
|
13946
14271
|
registerSkillsCommands(cloud);
|
|
13947
14272
|
cloud.commandsGroup("Swarms and user testing:");
|