@mcpjam/cli 5.5.1 → 5.6.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 +522 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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, 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';
|
|
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, listTraceDestinationsOperation, getTraceDestinationOperation, createTraceDestinationOperation, updateTraceDestinationOperation, deleteTraceDestinationOperation, testTraceDestinationOperation, pauseTraceDestinationOperation, resumeTraceDestinationOperation, backfillTraceDestinationOperation, listTraceDestinationBackfillsOperation, 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.6.0"};
|
|
31
31
|
function conformanceExitCode(result) {
|
|
32
32
|
if (result.outcome === "incomplete") return 3;
|
|
33
33
|
if (result.outcome === "failed") return 1;
|
|
@@ -4819,6 +4819,26 @@ async function assertModelOverridesSupported(options, timeoutMs, args) {
|
|
|
4819
4819
|
);
|
|
4820
4820
|
}
|
|
4821
4821
|
}
|
|
4822
|
+
async function assertSecretGrantsSupported(options, timeoutMs, args) {
|
|
4823
|
+
if (!args.supplied) return;
|
|
4824
|
+
const result = await runPlatformOperation(
|
|
4825
|
+
options,
|
|
4826
|
+
timeoutMs,
|
|
4827
|
+
({ client, signal }) => getEnvironmentCapabilitiesOperation.execute(
|
|
4828
|
+
{ project: args.project },
|
|
4829
|
+
{ client, signal }
|
|
4830
|
+
),
|
|
4831
|
+
{ announce: false }
|
|
4832
|
+
);
|
|
4833
|
+
if (result.capabilities.secretGrants !== true) {
|
|
4834
|
+
throw usageError(
|
|
4835
|
+
'This MCPJam deployment does not support environment secret grants. Upgrade the platform, or omit --secret / "secretSelection".'
|
|
4836
|
+
);
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
function suppliesSecretSelection(body) {
|
|
4840
|
+
return "secretSelection" in body;
|
|
4841
|
+
}
|
|
4822
4842
|
function resolveEnvironmentProject(options, body = {}) {
|
|
4823
4843
|
if (body.project !== void 0 && typeof body.project !== "string") {
|
|
4824
4844
|
throw usageError(
|
|
@@ -4957,6 +4977,14 @@ function registerEnvironmentsCommands(program) {
|
|
|
4957
4977
|
...project
|
|
4958
4978
|
}
|
|
4959
4979
|
);
|
|
4980
|
+
await assertSecretGrantsSupported(
|
|
4981
|
+
platformOptionsOf(command),
|
|
4982
|
+
globalOptions.timeout,
|
|
4983
|
+
{
|
|
4984
|
+
supplied: suppliesSecretSelection(body),
|
|
4985
|
+
...project
|
|
4986
|
+
}
|
|
4987
|
+
);
|
|
4960
4988
|
const input = validateInput(createEnvironmentOperation, {
|
|
4961
4989
|
...body,
|
|
4962
4990
|
...project,
|
|
@@ -4992,17 +5020,29 @@ function registerEnvironmentsCommands(program) {
|
|
|
4992
5020
|
).option(
|
|
4993
5021
|
"--skill <id...>",
|
|
4994
5022
|
"Project-shared skill IDs to pin on the composed stack"
|
|
5023
|
+
).option(
|
|
5024
|
+
"--secret <id...>",
|
|
5025
|
+
"Project SECRET IDs the composed stack grants to its runs. Without one a composed stack carries no credential \u2014 list them with `mcpjam secrets list`."
|
|
4995
5026
|
).action(
|
|
4996
5027
|
async (options, command) => {
|
|
4997
5028
|
const globalOptions = getGlobalOptions(command);
|
|
4998
5029
|
const resolved = resolveEnvironmentProject(options);
|
|
5030
|
+
await assertSecretGrantsSupported(
|
|
5031
|
+
platformOptionsOf(command),
|
|
5032
|
+
globalOptions.timeout,
|
|
5033
|
+
{
|
|
5034
|
+
supplied: (options.secret?.length ?? 0) > 0,
|
|
5035
|
+
...projectFields(resolved)
|
|
5036
|
+
}
|
|
5037
|
+
);
|
|
4999
5038
|
const input = validateInput(ensureAdhocEnvironmentOperation, {
|
|
5000
5039
|
...projectFields(resolved),
|
|
5001
5040
|
host: options.host,
|
|
5002
5041
|
...options.serverGroup !== void 0 ? { serverGroup: options.serverGroup } : {},
|
|
5003
5042
|
...options.model !== void 0 ? { model: options.model } : {},
|
|
5004
5043
|
...options.computer !== void 0 ? { computer: options.computer } : {},
|
|
5005
|
-
...options.skill?.length ? { skills: { mode: "explicit", skillIds: options.skill } } : {}
|
|
5044
|
+
...options.skill?.length ? { skills: { mode: "explicit", skillIds: options.skill } } : {},
|
|
5045
|
+
...options.secret?.length ? { secrets: { mode: "explicit", secretIds: options.secret } } : {}
|
|
5006
5046
|
});
|
|
5007
5047
|
const result = await runPlatformOperation(
|
|
5008
5048
|
platformOptionsOf(command),
|
|
@@ -5078,6 +5118,14 @@ function registerEnvironmentsCommands(program) {
|
|
|
5078
5118
|
...project
|
|
5079
5119
|
}
|
|
5080
5120
|
);
|
|
5121
|
+
await assertSecretGrantsSupported(
|
|
5122
|
+
platformOptionsOf(command),
|
|
5123
|
+
globalOptions.timeout,
|
|
5124
|
+
{
|
|
5125
|
+
supplied: suppliesSecretSelection(body),
|
|
5126
|
+
...project
|
|
5127
|
+
}
|
|
5128
|
+
);
|
|
5081
5129
|
const input = validateInput(updateEnvironmentOperation, {
|
|
5082
5130
|
...body,
|
|
5083
5131
|
...project,
|
|
@@ -7635,7 +7683,7 @@ function selectorField(singular, plural, values) {
|
|
|
7635
7683
|
}
|
|
7636
7684
|
function composeField(options) {
|
|
7637
7685
|
const models = Array.isArray(options.composeModel) ? options.composeModel : options.composeModel ? [options.composeModel] : void 0;
|
|
7638
|
-
const refinements = options.composeComputer !== void 0 || models !== void 0 || (options.composeServer?.length ?? 0) > 0 || options.composeServerGroup !== void 0 || options.composeHostServers === true || (options.composeSkill?.length ?? 0) > 0 || options.withClientDefault === true || options.saveTargets === true;
|
|
7686
|
+
const refinements = options.composeComputer !== void 0 || models !== void 0 || (options.composeServer?.length ?? 0) > 0 || options.composeServerGroup !== void 0 || options.composeHostServers === true || (options.composeSkill?.length ?? 0) > 0 || (options.composeSecret?.length ?? 0) > 0 || options.withClientDefault === true || options.saveTargets === true;
|
|
7639
7687
|
if (!options.composeHost) {
|
|
7640
7688
|
if (refinements) {
|
|
7641
7689
|
throw usageError(
|
|
@@ -7675,6 +7723,15 @@ function composeField(options) {
|
|
|
7675
7723
|
mode: "explicit",
|
|
7676
7724
|
skillIds: options.composeSkill
|
|
7677
7725
|
}
|
|
7726
|
+
} : {},
|
|
7727
|
+
// The credential axis. Absent means the composed cells grant NOTHING —
|
|
7728
|
+
// the environment is the grant boundary, so a run that needs a token
|
|
7729
|
+
// used to have no choice but a named environment.
|
|
7730
|
+
...options.composeSecret?.length ? {
|
|
7731
|
+
secrets: {
|
|
7732
|
+
mode: "explicit",
|
|
7733
|
+
secretIds: options.composeSecret
|
|
7734
|
+
}
|
|
7678
7735
|
} : {}
|
|
7679
7736
|
}
|
|
7680
7737
|
};
|
|
@@ -9311,6 +9368,9 @@ function registerEvalCommands(program) {
|
|
|
9311
9368
|
).option(
|
|
9312
9369
|
"--compose-skill <id...>",
|
|
9313
9370
|
"Project-shared skill IDs to pin on the composed stack"
|
|
9371
|
+
).option(
|
|
9372
|
+
"--compose-secret <id...>",
|
|
9373
|
+
"Project SECRET IDs the composed stack grants to its runs. Without one a composed stack carries no credential \u2014 list them with `mcpjam secrets list`."
|
|
9314
9374
|
).option(
|
|
9315
9375
|
"--allow-approximated <case...>",
|
|
9316
9376
|
"Approve an `approximated` imported case for THIS RUN ONLY (authored case id). Repeatable. --file only, and requires --approval-reason."
|
|
@@ -10433,6 +10493,9 @@ function registerEvalCommands(program) {
|
|
|
10433
10493
|
).option(
|
|
10434
10494
|
"--compose-skill <id...>",
|
|
10435
10495
|
"Project-shared skill IDs to pin on the composed stack"
|
|
10496
|
+
).option(
|
|
10497
|
+
"--compose-secret <id...>",
|
|
10498
|
+
"Project SECRET IDs the composed stack grants to its runs. Without one a composed stack carries no credential \u2014 list them with `mcpjam secrets list`."
|
|
10436
10499
|
).action(
|
|
10437
10500
|
async (options, command) => {
|
|
10438
10501
|
if (options.repetitions !== void 0 && options.iterations !== void 0) {
|
|
@@ -12327,13 +12390,16 @@ function registerSessionsCommands(program) {
|
|
|
12327
12390
|
"Stable key for THIS turn's intent. Reuse it when retrying: a retry with the same key replays the completed turn instead of running and billing it again. Do NOT generate a fresh key per attempt."
|
|
12328
12391
|
).option(
|
|
12329
12392
|
"--session <sessionId>",
|
|
12330
|
-
"Continue this session instead of starting one. Configuration is fixed at the first turn, so the flags below are refused with a session."
|
|
12393
|
+
"Continue this session instead of starting one. Configuration is fixed at the first turn, so the config flags below are refused with a session. The per-turn flags are not: --client, --max-steps and --max-tool-calls apply to whichever turn sends them, and --client in particular must be RE-SENT on every turn of a host-bound conversation \u2014 a session started with --client alone refuses a continuation that omits it."
|
|
12331
12394
|
).option(
|
|
12332
12395
|
"--model <modelId>",
|
|
12333
12396
|
'Provider-prefixed model id, e.g. "anthropic/claude-sonnet-5". Required to start a session; a bare id is rejected rather than guessed.'
|
|
12397
|
+
).option(
|
|
12398
|
+
"--client <hostId>",
|
|
12399
|
+
"Client ID (from `mcpjam cloud clients list`) to run the turn AS. A client that declares an agent harness (Claude Code, Codex, Cursor CLI) runs the REAL runtime; without one the turn runs MCPJam's emulated engine. Per-turn, NOT pinned to the session \u2014 pass it on every turn, and check the printed `engine` to see what ran. Continuing a session you started with --client alone REQUIRES it: without it the turn is refused rather than answered by the emulated engine. Alongside --environment it only asserts which host you expect (a mismatch is refused). It cannot be combined with --server: --client cannot be pinned beside a pinned server set, so a later turn that omitted it would run the emulated engine on a session established on the harness. Use --environment, or --client alone (which connects the client's own servers). A harness turn needs --tool-mode auto with no --max-tool-calls."
|
|
12334
12400
|
).option(
|
|
12335
12401
|
"--environment <environmentId>",
|
|
12336
|
-
"Run against this environment's servers (mutually exclusive with --server)"
|
|
12402
|
+
"Run against this environment's servers (mutually exclusive with --server). An environment pins its own host, so a harness environment runs its harness on every turn, continuations included."
|
|
12337
12403
|
).option(
|
|
12338
12404
|
"--server <serverId...>",
|
|
12339
12405
|
"Run against these project servers (mutually exclusive with --environment)"
|
|
@@ -12352,6 +12418,7 @@ function registerSessionsCommands(program) {
|
|
|
12352
12418
|
project: options.project,
|
|
12353
12419
|
sessionId: options.session,
|
|
12354
12420
|
modelId: options.model,
|
|
12421
|
+
hostId: options.client,
|
|
12355
12422
|
environmentId: options.environment,
|
|
12356
12423
|
serverIds: options.server,
|
|
12357
12424
|
systemPrompt: options.systemPrompt,
|
|
@@ -12873,6 +12940,412 @@ function registerSwarmAuthoringCommands(program, journeys) {
|
|
|
12873
12940
|
})
|
|
12874
12941
|
);
|
|
12875
12942
|
}
|
|
12943
|
+
function collect(value, previous = []) {
|
|
12944
|
+
return [...previous, value];
|
|
12945
|
+
}
|
|
12946
|
+
var HEADER_NAME_PATTERN = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
|
|
12947
|
+
function splitOnFirst(raw, separator, flag) {
|
|
12948
|
+
const index = raw.indexOf(separator);
|
|
12949
|
+
if (index <= 0) {
|
|
12950
|
+
throw usageError(
|
|
12951
|
+
`${flag} expects "Name${separator}value"; the argument had no "${separator}".`
|
|
12952
|
+
);
|
|
12953
|
+
}
|
|
12954
|
+
const name = raw.slice(0, index).trim();
|
|
12955
|
+
if (!name) {
|
|
12956
|
+
throw usageError(`${flag} has an empty header name.`);
|
|
12957
|
+
}
|
|
12958
|
+
return [name, raw.slice(index + separator.length)];
|
|
12959
|
+
}
|
|
12960
|
+
function resolveHeaders(options) {
|
|
12961
|
+
const headers = /* @__PURE__ */ Object.create(null);
|
|
12962
|
+
const seen = /* @__PURE__ */ new Map();
|
|
12963
|
+
const named = (options.header?.length ?? 0) + (options.headerEnv?.length ?? 0) + (options.headerFile?.length ?? 0);
|
|
12964
|
+
if (options.clearHeaders) {
|
|
12965
|
+
if (named > 0) {
|
|
12966
|
+
throw usageError(
|
|
12967
|
+
"--clear-headers removes every header, so it cannot be combined with a header flag. Pass one or the other."
|
|
12968
|
+
);
|
|
12969
|
+
}
|
|
12970
|
+
return {};
|
|
12971
|
+
}
|
|
12972
|
+
const put = (name, value, flag) => {
|
|
12973
|
+
if (!HEADER_NAME_PATTERN.test(name)) {
|
|
12974
|
+
throw usageError(
|
|
12975
|
+
`Header name "${name}" is not an HTTP token. Use letters, digits and !#$%&'*+.^_\`|~- only.`
|
|
12976
|
+
);
|
|
12977
|
+
}
|
|
12978
|
+
const key = name.toLowerCase();
|
|
12979
|
+
const previous = seen.get(key);
|
|
12980
|
+
if (previous !== void 0) {
|
|
12981
|
+
throw usageError(
|
|
12982
|
+
`Header "${name}" was given twice (already set by ${previous}). HTTP header names are case-insensitive.`
|
|
12983
|
+
);
|
|
12984
|
+
}
|
|
12985
|
+
if (/[\r\n\0]/.test(value)) {
|
|
12986
|
+
throw usageError(
|
|
12987
|
+
`Header "${name}" contains a newline or a null byte. A header value cannot span lines.`
|
|
12988
|
+
);
|
|
12989
|
+
}
|
|
12990
|
+
if (value === "") {
|
|
12991
|
+
throw usageError(`The value for header "${name}" is empty.`);
|
|
12992
|
+
}
|
|
12993
|
+
seen.set(key, flag);
|
|
12994
|
+
headers[name] = value;
|
|
12995
|
+
};
|
|
12996
|
+
for (const raw of options.header ?? []) {
|
|
12997
|
+
const [name, value] = splitOnFirst(raw, ":", "--header");
|
|
12998
|
+
put(name, value.trim(), "--header");
|
|
12999
|
+
}
|
|
13000
|
+
for (const raw of options.headerEnv ?? []) {
|
|
13001
|
+
const [name, variable] = splitOnFirst(raw, "=", "--header-env");
|
|
13002
|
+
const value = process.env[variable.trim()];
|
|
13003
|
+
if (value === void 0 || value === "") {
|
|
13004
|
+
throw usageError(
|
|
13005
|
+
`Environment variable "${variable.trim()}" is not set (or is empty).`
|
|
13006
|
+
);
|
|
13007
|
+
}
|
|
13008
|
+
put(name, value, "--header-env");
|
|
13009
|
+
}
|
|
13010
|
+
for (const raw of options.headerFile ?? []) {
|
|
13011
|
+
const [name, path9] = splitOnFirst(raw, "=", "--header-file");
|
|
13012
|
+
const target = path9.trim();
|
|
13013
|
+
let contents;
|
|
13014
|
+
try {
|
|
13015
|
+
contents = target === "-" ? readFileSync(0, "utf8") : readFileSync(target, "utf8");
|
|
13016
|
+
} catch (error) {
|
|
13017
|
+
throw usageError(
|
|
13018
|
+
target === "-" ? `Failed to read the value for header "${name}" from stdin.` : `Failed to read the value for header "${name}" from "${target}".`,
|
|
13019
|
+
{ source: error instanceof Error ? error.message : String(error) }
|
|
13020
|
+
);
|
|
13021
|
+
}
|
|
13022
|
+
put(name, contents.replace(/\r?\n$/, ""), "--header-file");
|
|
13023
|
+
}
|
|
13024
|
+
return Object.keys(headers).length > 0 ? { ...headers } : void 0;
|
|
13025
|
+
}
|
|
13026
|
+
function resolveAttributes(pairs) {
|
|
13027
|
+
if (!pairs || pairs.length === 0) return void 0;
|
|
13028
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
13029
|
+
for (const raw of pairs) {
|
|
13030
|
+
const [key, value] = splitOnFirst(raw, "=", "--attr");
|
|
13031
|
+
if (Object.prototype.hasOwnProperty.call(out, key)) {
|
|
13032
|
+
throw usageError(`Resource attribute "${key}" was given twice.`);
|
|
13033
|
+
}
|
|
13034
|
+
out[key] = value;
|
|
13035
|
+
}
|
|
13036
|
+
return { ...out };
|
|
13037
|
+
}
|
|
13038
|
+
var SOURCE_TYPES = ["eval", "scenario", "swarm", "direct"];
|
|
13039
|
+
function resolveSourceTypes(values) {
|
|
13040
|
+
if (!values || values.length === 0) return void 0;
|
|
13041
|
+
const out = [];
|
|
13042
|
+
for (const raw of values) {
|
|
13043
|
+
const value = raw.trim();
|
|
13044
|
+
if (!SOURCE_TYPES.includes(value)) {
|
|
13045
|
+
throw usageError(
|
|
13046
|
+
`--source expects one of ${SOURCE_TYPES.join(
|
|
13047
|
+
", "
|
|
13048
|
+
)} (got ${JSON.stringify(raw)}).`
|
|
13049
|
+
);
|
|
13050
|
+
}
|
|
13051
|
+
if (!out.includes(value)) out.push(value);
|
|
13052
|
+
}
|
|
13053
|
+
return out;
|
|
13054
|
+
}
|
|
13055
|
+
var ORG_FLAG_DESCRIPTION = "Organization ID, from `cloud organizations list`";
|
|
13056
|
+
function registerTraceDestinationsCommands(program) {
|
|
13057
|
+
const destinations = program.command("trace-destinations").alias("traces").description(
|
|
13058
|
+
"Stream an organization's traces to an OTLP/HTTP endpoint (Coralogix, Honeycomb, Grafana, a collector). Header values are write-only: no command prints one."
|
|
13059
|
+
);
|
|
13060
|
+
destinations.command("list").description(
|
|
13061
|
+
"List the organization's destinations \u2014 endpoint, sources, redaction setting and delivery health. Header names only, never their values."
|
|
13062
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).action(async (options, command) => {
|
|
13063
|
+
const globalOptions = getGlobalOptions(command);
|
|
13064
|
+
const result = await runPlatformOperation(
|
|
13065
|
+
platformOptionsOf(command),
|
|
13066
|
+
globalOptions.timeout,
|
|
13067
|
+
({ client, signal }) => listTraceDestinationsOperation.execute(
|
|
13068
|
+
{ organization: options.org },
|
|
13069
|
+
{ client, signal }
|
|
13070
|
+
),
|
|
13071
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13072
|
+
);
|
|
13073
|
+
writeResult(result, globalOptions.format);
|
|
13074
|
+
});
|
|
13075
|
+
destinations.command("show").description(
|
|
13076
|
+
"Show one destination in full, including delivery health: the last HTTP status the vendor answered with, sessions and spans delivered, and how many are still queued."
|
|
13077
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption(
|
|
13078
|
+
"--destination <id>",
|
|
13079
|
+
"Destination ID, from `cloud trace-destinations list`"
|
|
13080
|
+
).action(async (options, command) => {
|
|
13081
|
+
const globalOptions = getGlobalOptions(command);
|
|
13082
|
+
const result = await runPlatformOperation(
|
|
13083
|
+
platformOptionsOf(command),
|
|
13084
|
+
globalOptions.timeout,
|
|
13085
|
+
({ client, signal }) => getTraceDestinationOperation.execute(
|
|
13086
|
+
{ organization: options.org, destination: options.destination },
|
|
13087
|
+
{ client, signal }
|
|
13088
|
+
),
|
|
13089
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13090
|
+
);
|
|
13091
|
+
writeResult(result, globalOptions.format);
|
|
13092
|
+
});
|
|
13093
|
+
destinations.command("create").description(
|
|
13094
|
+
"Create a destination and start streaming. Header values come from --header-env or --header-file; --header takes one inline for scripting."
|
|
13095
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--name <name>", "Human label for this destination.").requiredOption(
|
|
13096
|
+
"--endpoint <url>",
|
|
13097
|
+
"The vendor's OTLP/HTTP intake, HTTPS only. `/v1/traces` is appended if the path does not already end there."
|
|
13098
|
+
).option(
|
|
13099
|
+
"--header-env <Name=VAR>",
|
|
13100
|
+
"Repeatable: read a header's value from an environment variable. Preferred.",
|
|
13101
|
+
collect
|
|
13102
|
+
).option(
|
|
13103
|
+
"--header-file <Name=path>",
|
|
13104
|
+
"Repeatable: read a header's value from a file (`-` reads stdin). One trailing newline is dropped \u2014 a header cannot span lines.",
|
|
13105
|
+
collect
|
|
13106
|
+
).option(
|
|
13107
|
+
"--header <Name: value>",
|
|
13108
|
+
"Repeatable, SCRIPTING ONLY: an inline header value is written to your shell history and is visible in `ps` while the command runs.",
|
|
13109
|
+
collect
|
|
13110
|
+
).option(
|
|
13111
|
+
"--attr <key=value>",
|
|
13112
|
+
"Repeatable: an extra OTel resource attribute (cx.application.name=mcpjam). `mcpjam.*` names are reserved by the exporter.",
|
|
13113
|
+
collect
|
|
13114
|
+
).option(
|
|
13115
|
+
"--source <type>",
|
|
13116
|
+
"Repeatable: eval, scenario, swarm or direct. `direct` is Playground, and only sessions SHARED to the workspace are ever sent. Defaults to the server's default set.",
|
|
13117
|
+
collect
|
|
13118
|
+
).option(
|
|
13119
|
+
"--include-content",
|
|
13120
|
+
"Send prompts, outputs, tool arguments and screenshots. OFF by default, and off is the safe reading \u2014 this decides whether customer content leaves the platform."
|
|
13121
|
+
).option(
|
|
13122
|
+
"--project <id>",
|
|
13123
|
+
"Repeatable: restrict to these projects. Omit for every project in the organization, present and future.",
|
|
13124
|
+
collect
|
|
13125
|
+
).option(
|
|
13126
|
+
"--compression <mode>",
|
|
13127
|
+
"gzip or none. gzip is optional in OTLP/HTTP and some intakes reject it."
|
|
13128
|
+
).option(
|
|
13129
|
+
"--preset <id>",
|
|
13130
|
+
"Vendor preset id this was created from (coralogix, honeycomb, \u2026). Labelling only."
|
|
13131
|
+
).option("--disabled", "Create it without starting the stream.").action(
|
|
13132
|
+
async (options, command) => {
|
|
13133
|
+
const globalOptions = getGlobalOptions(command);
|
|
13134
|
+
const headers = resolveHeaders(options);
|
|
13135
|
+
const resourceAttributes = resolveAttributes(options.attr);
|
|
13136
|
+
const sourceTypes = resolveSourceTypes(options.source);
|
|
13137
|
+
if (options.compression !== void 0 && options.compression !== "gzip" && options.compression !== "none") {
|
|
13138
|
+
throw usageError("--compression expects gzip or none.");
|
|
13139
|
+
}
|
|
13140
|
+
const result = await runPlatformOperation(
|
|
13141
|
+
platformOptionsOf(command),
|
|
13142
|
+
globalOptions.timeout,
|
|
13143
|
+
({ client, signal }) => createTraceDestinationOperation.execute(
|
|
13144
|
+
{
|
|
13145
|
+
organization: options.org,
|
|
13146
|
+
name: options.name,
|
|
13147
|
+
endpointUrl: options.endpoint,
|
|
13148
|
+
...headers ? { headers } : {},
|
|
13149
|
+
...resourceAttributes ? { resourceAttributes } : {},
|
|
13150
|
+
...sourceTypes ? { sourceTypes } : {},
|
|
13151
|
+
...options.includeContent ? { includeContent: true } : {},
|
|
13152
|
+
...options.project ? { projectIds: options.project } : {},
|
|
13153
|
+
...options.compression ? { compression: options.compression } : {},
|
|
13154
|
+
...options.preset ? { preset: options.preset } : {},
|
|
13155
|
+
...options.disabled ? { enabled: false } : {}
|
|
13156
|
+
},
|
|
13157
|
+
{ client, signal }
|
|
13158
|
+
),
|
|
13159
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13160
|
+
);
|
|
13161
|
+
writeResult(result, globalOptions.format);
|
|
13162
|
+
}
|
|
13163
|
+
);
|
|
13164
|
+
destinations.command("update").description(
|
|
13165
|
+
"Edit a destination. Any header flag REPLACES the whole header set; passing none leaves the stored headers alone."
|
|
13166
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").option("--name <name>", "New label.").option("--endpoint <url>", "New OTLP/HTTP intake, HTTPS only.").option(
|
|
13167
|
+
"--header-env <Name=VAR>",
|
|
13168
|
+
"Repeatable: read a header's value from an environment variable. Preferred.",
|
|
13169
|
+
collect
|
|
13170
|
+
).option(
|
|
13171
|
+
"--header-file <Name=path>",
|
|
13172
|
+
"Repeatable: read a header's value from a file (`-` reads stdin).",
|
|
13173
|
+
collect
|
|
13174
|
+
).option(
|
|
13175
|
+
"--header <Name: value>",
|
|
13176
|
+
"Repeatable, SCRIPTING ONLY: written to your shell history and visible in `ps`.",
|
|
13177
|
+
collect
|
|
13178
|
+
).option(
|
|
13179
|
+
"--clear-headers",
|
|
13180
|
+
"Remove every stored header. Reach for this before pointing a destination at a new endpoint that must not receive the old vendor's credentials \u2014 omitting the header flags LEAVES them, which is not the same thing."
|
|
13181
|
+
).option(
|
|
13182
|
+
"--attr <key=value>",
|
|
13183
|
+
"Repeatable: REPLACES the resource attributes.",
|
|
13184
|
+
collect
|
|
13185
|
+
).option("--source <type>", "Repeatable: REPLACES the source list.", collect).option("--include-content", "Start sending content. Audited.").option("--no-include-content", "Stop sending content; redact again.").option(
|
|
13186
|
+
"--project <id>",
|
|
13187
|
+
"Repeatable: REPLACES the project allowlist.",
|
|
13188
|
+
collect
|
|
13189
|
+
).option(
|
|
13190
|
+
"--all-projects",
|
|
13191
|
+
"Stream every project in the organization. The explicit way back \u2014 an empty --project list would mean a destination that matches nothing."
|
|
13192
|
+
).option("--compression <mode>", "gzip or none.").option("--enable", "Start streaming.").option("--disable", "Stop streaming, keeping the configuration.").action(
|
|
13193
|
+
async (options, command) => {
|
|
13194
|
+
const globalOptions = getGlobalOptions(command);
|
|
13195
|
+
if (options.enable && options.disable) {
|
|
13196
|
+
throw usageError("Pass --enable or --disable, not both.");
|
|
13197
|
+
}
|
|
13198
|
+
if (options.allProjects && options.project) {
|
|
13199
|
+
throw usageError(
|
|
13200
|
+
"Pass --all-projects or --project, not both \u2014 they are two answers to the same question."
|
|
13201
|
+
);
|
|
13202
|
+
}
|
|
13203
|
+
if (options.compression !== void 0 && options.compression !== "gzip" && options.compression !== "none") {
|
|
13204
|
+
throw usageError("--compression expects gzip or none.");
|
|
13205
|
+
}
|
|
13206
|
+
const headers = resolveHeaders(options);
|
|
13207
|
+
const resourceAttributes = resolveAttributes(options.attr);
|
|
13208
|
+
const sourceTypes = resolveSourceTypes(options.source);
|
|
13209
|
+
const enabled = options.enable ? true : options.disable ? false : void 0;
|
|
13210
|
+
const patch = {
|
|
13211
|
+
...options.name !== void 0 ? { name: options.name } : {},
|
|
13212
|
+
...options.endpoint !== void 0 ? { endpointUrl: options.endpoint } : {},
|
|
13213
|
+
...headers ? { headers } : {},
|
|
13214
|
+
...resourceAttributes ? { resourceAttributes } : {},
|
|
13215
|
+
...sourceTypes ? { sourceTypes } : {},
|
|
13216
|
+
// Commander's `--no-include-content` sets this to false, so the
|
|
13217
|
+
// tri-state survives: absent leaves it, true starts sending content,
|
|
13218
|
+
// false redacts again.
|
|
13219
|
+
...options.includeContent !== void 0 ? { includeContent: options.includeContent } : {},
|
|
13220
|
+
...options.project ? { projectIds: options.project } : {},
|
|
13221
|
+
...options.allProjects ? { allProjects: true } : {},
|
|
13222
|
+
...options.compression ? { compression: options.compression } : {},
|
|
13223
|
+
...enabled !== void 0 ? { enabled } : {}
|
|
13224
|
+
};
|
|
13225
|
+
if (Object.keys(patch).length === 0) {
|
|
13226
|
+
throw usageError("Nothing to update \u2014 pass at least one field.");
|
|
13227
|
+
}
|
|
13228
|
+
const result = await runPlatformOperation(
|
|
13229
|
+
platformOptionsOf(command),
|
|
13230
|
+
globalOptions.timeout,
|
|
13231
|
+
({ client, signal }) => updateTraceDestinationOperation.execute(
|
|
13232
|
+
{
|
|
13233
|
+
organization: options.org,
|
|
13234
|
+
destination: options.destination,
|
|
13235
|
+
...patch
|
|
13236
|
+
},
|
|
13237
|
+
{ client, signal }
|
|
13238
|
+
),
|
|
13239
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13240
|
+
);
|
|
13241
|
+
writeResult(result, globalOptions.format);
|
|
13242
|
+
}
|
|
13243
|
+
);
|
|
13244
|
+
destinations.command("rm").description(
|
|
13245
|
+
"Delete a destination. Streaming stops and anything queued is discarded \u2014 but traces ALREADY DELIVERED stay in the vendor's system, and nothing here can retract them."
|
|
13246
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").action(async (options, command) => {
|
|
13247
|
+
const globalOptions = getGlobalOptions(command);
|
|
13248
|
+
const result = await runPlatformOperation(
|
|
13249
|
+
platformOptionsOf(command),
|
|
13250
|
+
globalOptions.timeout,
|
|
13251
|
+
({ client, signal }) => deleteTraceDestinationOperation.execute(
|
|
13252
|
+
{ organization: options.org, destination: options.destination },
|
|
13253
|
+
{ client, signal }
|
|
13254
|
+
),
|
|
13255
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13256
|
+
);
|
|
13257
|
+
writeResult(result, globalOptions.format);
|
|
13258
|
+
});
|
|
13259
|
+
destinations.command("test").description(
|
|
13260
|
+
"Send one synthetic span, to prove the endpoint and credentials work. Returns as soon as the send is SCHEDULED \u2014 read the outcome from `show` a moment later."
|
|
13261
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").action(async (options, command) => {
|
|
13262
|
+
const globalOptions = getGlobalOptions(command);
|
|
13263
|
+
const result = await runPlatformOperation(
|
|
13264
|
+
platformOptionsOf(command),
|
|
13265
|
+
globalOptions.timeout,
|
|
13266
|
+
({ client, signal }) => testTraceDestinationOperation.execute(
|
|
13267
|
+
{ organization: options.org, destination: options.destination },
|
|
13268
|
+
{ client, signal }
|
|
13269
|
+
),
|
|
13270
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13271
|
+
);
|
|
13272
|
+
writeResult(result, globalOptions.format);
|
|
13273
|
+
});
|
|
13274
|
+
destinations.command("pause").description(
|
|
13275
|
+
"Stop delivering without deleting. NOTHING IS QUEUED while paused: the window becomes a gap, not a backlog, and only `backfill` can fill it."
|
|
13276
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").action(async (options, command) => {
|
|
13277
|
+
const globalOptions = getGlobalOptions(command);
|
|
13278
|
+
const result = await runPlatformOperation(
|
|
13279
|
+
platformOptionsOf(command),
|
|
13280
|
+
globalOptions.timeout,
|
|
13281
|
+
({ client, signal }) => pauseTraceDestinationOperation.execute(
|
|
13282
|
+
{ organization: options.org, destination: options.destination },
|
|
13283
|
+
{ client, signal }
|
|
13284
|
+
),
|
|
13285
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13286
|
+
);
|
|
13287
|
+
writeResult(result, globalOptions.format);
|
|
13288
|
+
});
|
|
13289
|
+
destinations.command("resume").description(
|
|
13290
|
+
"Start delivering again. Fix what caused an automatic pause first \u2014 `show` reports the reason \u2014 or it will pause again. Reports `pausedSince` so the gap can be sized."
|
|
13291
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").action(async (options, command) => {
|
|
13292
|
+
const globalOptions = getGlobalOptions(command);
|
|
13293
|
+
const result = await runPlatformOperation(
|
|
13294
|
+
platformOptionsOf(command),
|
|
13295
|
+
globalOptions.timeout,
|
|
13296
|
+
({ client, signal }) => resumeTraceDestinationOperation.execute(
|
|
13297
|
+
{ organization: options.org, destination: options.destination },
|
|
13298
|
+
{ client, signal }
|
|
13299
|
+
),
|
|
13300
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13301
|
+
);
|
|
13302
|
+
writeResult(result, globalOptions.format);
|
|
13303
|
+
});
|
|
13304
|
+
destinations.command("backfill").description(
|
|
13305
|
+
"Replay a window of history \u2014 for the gap a pause left, or to seed a new destination. Queues every eligible session in the window, so a wide window is a lot of vendor ingest."
|
|
13306
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").requiredOption(
|
|
13307
|
+
"--days <n>",
|
|
13308
|
+
"How far back to replay. 1 to 30.",
|
|
13309
|
+
(value) => {
|
|
13310
|
+
const days = Number(value.trim());
|
|
13311
|
+
if (!Number.isInteger(days) || days < 1 || days > 30) {
|
|
13312
|
+
throw usageError("--days expects a whole number between 1 and 30.");
|
|
13313
|
+
}
|
|
13314
|
+
return days;
|
|
13315
|
+
}
|
|
13316
|
+
).action(async (options, command) => {
|
|
13317
|
+
const globalOptions = getGlobalOptions(command);
|
|
13318
|
+
const result = await runPlatformOperation(
|
|
13319
|
+
platformOptionsOf(command),
|
|
13320
|
+
globalOptions.timeout,
|
|
13321
|
+
({ client, signal }) => backfillTraceDestinationOperation.execute(
|
|
13322
|
+
{
|
|
13323
|
+
organization: options.org,
|
|
13324
|
+
destination: options.destination,
|
|
13325
|
+
days: options.days
|
|
13326
|
+
},
|
|
13327
|
+
{ client, signal }
|
|
13328
|
+
),
|
|
13329
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13330
|
+
);
|
|
13331
|
+
writeResult(result, globalOptions.format);
|
|
13332
|
+
});
|
|
13333
|
+
destinations.command("backfills").description(
|
|
13334
|
+
"The 20 most recent backfills for a destination, newest first, with how many sessions each scanned and queued."
|
|
13335
|
+
).requiredOption("--org <id>", ORG_FLAG_DESCRIPTION).requiredOption("--destination <id>", "Destination ID").action(async (options, command) => {
|
|
13336
|
+
const globalOptions = getGlobalOptions(command);
|
|
13337
|
+
const result = await runPlatformOperation(
|
|
13338
|
+
platformOptionsOf(command),
|
|
13339
|
+
globalOptions.timeout,
|
|
13340
|
+
({ client, signal }) => listTraceDestinationBackfillsOperation.execute(
|
|
13341
|
+
{ organization: options.org, destination: options.destination },
|
|
13342
|
+
{ client, signal }
|
|
13343
|
+
),
|
|
13344
|
+
{ cloudScope: { kind: "organization", organization: options.org } }
|
|
13345
|
+
);
|
|
13346
|
+
writeResult(result, globalOptions.format);
|
|
13347
|
+
});
|
|
13348
|
+
}
|
|
12876
13349
|
function addRequiredOptionWithHiddenAlias(command, visibleFlags, hiddenLongFlag, description) {
|
|
12877
13350
|
const option = new Option(
|
|
12878
13351
|
`${hiddenLongFlag}, ${visibleFlags}`,
|
|
@@ -14269,6 +14742,8 @@ function registerCloudCommands(program) {
|
|
|
14269
14742
|
registerSecretsCommands(cloud);
|
|
14270
14743
|
registerImagesCommands(cloud);
|
|
14271
14744
|
registerSkillsCommands(cloud);
|
|
14745
|
+
cloud.commandsGroup("Observability:");
|
|
14746
|
+
registerTraceDestinationsCommands(cloud);
|
|
14272
14747
|
cloud.commandsGroup("Swarms and user testing:");
|
|
14273
14748
|
const journeys = registerJourneysCommands(cloud);
|
|
14274
14749
|
registerScenariosCommands(cloud);
|
|
@@ -15967,6 +16442,8 @@ function createMcpJamMcpServer(options) {
|
|
|
15967
16442
|
url,
|
|
15968
16443
|
accessToken,
|
|
15969
16444
|
headers,
|
|
16445
|
+
// See the `server probe` command: this runs on the user's machine.
|
|
16446
|
+
allowPrivateNetwork: true,
|
|
15970
16447
|
timeoutMs: timeoutMs ?? defaultTimeoutMs
|
|
15971
16448
|
});
|
|
15972
16449
|
return redactForTelemetry(result);
|
|
@@ -17056,12 +17533,18 @@ function registerOAuthCommands(program) {
|
|
|
17056
17533
|
setProcessExitCode(3);
|
|
17057
17534
|
}
|
|
17058
17535
|
});
|
|
17059
|
-
oauth.command("metadata").description("Fetch OAuth metadata from a URL").requiredOption("--url <url>", "OAuth metadata URL").
|
|
17536
|
+
oauth.command("metadata").description("Fetch OAuth metadata from a URL").requiredOption("--url <url>", "OAuth metadata URL").option(
|
|
17537
|
+
"--https-only",
|
|
17538
|
+
"Apply the hosted policy: reject non-HTTPS and private targets"
|
|
17539
|
+
).action(async (options, command) => {
|
|
17060
17540
|
const format = getOAuthFormat(command);
|
|
17061
|
-
const result = await runOAuthMetadata(
|
|
17541
|
+
const result = await runOAuthMetadata(
|
|
17542
|
+
options.url,
|
|
17543
|
+
options.httpsOnly === true
|
|
17544
|
+
);
|
|
17062
17545
|
writeResult(result, format);
|
|
17063
17546
|
});
|
|
17064
|
-
oauth.command("proxy").description("Proxy an OAuth request
|
|
17547
|
+
oauth.command("proxy").description("Proxy an OAuth request through the SSRF-hardened transport").requiredOption("--url <url>", "OAuth request URL").option("--method <method>", "HTTP method", "GET").option(
|
|
17065
17548
|
"--header <header>",
|
|
17066
17549
|
'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
|
|
17067
17550
|
(value, previous = []) => [...previous, value],
|
|
@@ -17069,12 +17552,17 @@ function registerOAuthCommands(program) {
|
|
|
17069
17552
|
).option(
|
|
17070
17553
|
"--body <value>",
|
|
17071
17554
|
"Request body as JSON, raw string, @path, or - for stdin"
|
|
17555
|
+
).option(
|
|
17556
|
+
"--https-only",
|
|
17557
|
+
"Apply the hosted policy: reject non-HTTPS and private targets"
|
|
17072
17558
|
).action(async (options, command) => {
|
|
17073
17559
|
const format = getOAuthFormat(command);
|
|
17074
17560
|
const result = await runOAuthProxy(options);
|
|
17075
17561
|
writeResult(result, format);
|
|
17076
17562
|
});
|
|
17077
|
-
oauth.command("debug-proxy").description(
|
|
17563
|
+
oauth.command("debug-proxy").description(
|
|
17564
|
+
"Proxy an OAuth debug request through the SSRF-hardened transport"
|
|
17565
|
+
).requiredOption("--url <url>", "OAuth request URL").option("--method <method>", "HTTP method", "GET").option(
|
|
17078
17566
|
"--header <header>",
|
|
17079
17567
|
'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
|
|
17080
17568
|
(value, previous = []) => [...previous, value],
|
|
@@ -17082,6 +17570,9 @@ function registerOAuthCommands(program) {
|
|
|
17082
17570
|
).option(
|
|
17083
17571
|
"--body <value>",
|
|
17084
17572
|
"Request body as JSON, raw string, @path, or - for stdin"
|
|
17573
|
+
).option(
|
|
17574
|
+
"--https-only",
|
|
17575
|
+
"Apply the hosted policy: reject non-HTTPS and private targets"
|
|
17085
17576
|
).action(async (options, command) => {
|
|
17086
17577
|
const format = getOAuthFormat(command);
|
|
17087
17578
|
const result = await runOAuthDebugProxy(
|
|
@@ -17161,6 +17652,9 @@ function buildOAuthConformanceConfig(options, defaults) {
|
|
|
17161
17652
|
serverUrl,
|
|
17162
17653
|
protocolVersion,
|
|
17163
17654
|
registrationStrategy,
|
|
17655
|
+
// The CLI runs on the user's machine, where the server under test is
|
|
17656
|
+
// routinely on loopback or a LAN address.
|
|
17657
|
+
allowPrivateNetwork: true,
|
|
17164
17658
|
auth,
|
|
17165
17659
|
client,
|
|
17166
17660
|
scopes: options.scopes?.trim() || void 0,
|
|
@@ -17251,6 +17745,8 @@ function buildOAuthLoginConfig(options, defaults) {
|
|
|
17251
17745
|
...registrationStrategy ? { registrationStrategy } : {},
|
|
17252
17746
|
protocolMode: protocolVersion ?? "auto",
|
|
17253
17747
|
registrationMode: registrationStrategy ?? "auto",
|
|
17748
|
+
// See buildOAuthConformanceConfig: a local server under test is the norm.
|
|
17749
|
+
allowPrivateNetwork: true,
|
|
17254
17750
|
auth,
|
|
17255
17751
|
client,
|
|
17256
17752
|
scopes: options.scopes?.trim() || void 0,
|
|
@@ -17372,9 +17868,12 @@ function parseAuthMode(value) {
|
|
|
17372
17868
|
`Invalid auth mode "${value}". Use ${[...VALID_AUTH_MODES].join(", ")}.`
|
|
17373
17869
|
);
|
|
17374
17870
|
}
|
|
17375
|
-
async function runOAuthMetadata(url) {
|
|
17871
|
+
async function runOAuthMetadata(url, httpsOnly = false) {
|
|
17376
17872
|
try {
|
|
17377
|
-
const result = await fetchOAuthMetadata(url,
|
|
17873
|
+
const result = await fetchOAuthMetadata(url, {
|
|
17874
|
+
httpsOnly,
|
|
17875
|
+
allowPrivateNetwork: !httpsOnly
|
|
17876
|
+
});
|
|
17378
17877
|
if ("status" in result && result.status !== void 0) {
|
|
17379
17878
|
throw cliError(
|
|
17380
17879
|
statusToErrorCode(result.status),
|
|
@@ -17393,7 +17892,8 @@ async function runOAuthProxy(options) {
|
|
|
17393
17892
|
method: options.method,
|
|
17394
17893
|
headers: parseHeadersOption(options.header),
|
|
17395
17894
|
body: parseProxyBody(options.body),
|
|
17396
|
-
httpsOnly: true
|
|
17895
|
+
httpsOnly: options.httpsOnly === true,
|
|
17896
|
+
allowPrivateNetwork: options.httpsOnly !== true
|
|
17397
17897
|
});
|
|
17398
17898
|
} catch (error) {
|
|
17399
17899
|
throw mapOAuthProxyError(error);
|
|
@@ -17406,7 +17906,8 @@ async function runOAuthDebugProxy(options) {
|
|
|
17406
17906
|
method: options.method,
|
|
17407
17907
|
headers: parseHeadersOption(options.header),
|
|
17408
17908
|
body: parseProxyBody(options.body),
|
|
17409
|
-
httpsOnly: true
|
|
17909
|
+
httpsOnly: options.httpsOnly === true,
|
|
17910
|
+
allowPrivateNetwork: options.httpsOnly !== true
|
|
17410
17911
|
});
|
|
17411
17912
|
} catch (error) {
|
|
17412
17913
|
throw mapOAuthProxyError(error);
|
|
@@ -17670,7 +18171,10 @@ function buildXaaConfig(options, timeoutMs) {
|
|
|
17670
18171
|
} : {},
|
|
17671
18172
|
...options.scopes?.trim() ? { scope: options.scopes.trim() } : {},
|
|
17672
18173
|
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
17673
|
-
httpsOnly: options.httpsOnly ?? false
|
|
18174
|
+
httpsOnly: options.httpsOnly ?? false,
|
|
18175
|
+
// The inverse of the hosted switch: without --https-only this is a local
|
|
18176
|
+
// dev run, and the mock IdP plus the RS it talks to are on loopback.
|
|
18177
|
+
allowPrivateNetwork: options.httpsOnly !== true
|
|
17674
18178
|
};
|
|
17675
18179
|
}
|
|
17676
18180
|
function parseRegistration(value) {
|
|
@@ -18172,6 +18676,9 @@ function registerServerCommands(program) {
|
|
|
18172
18676
|
result = await probeMcpServer({
|
|
18173
18677
|
url: probeUrl,
|
|
18174
18678
|
protocolVersion,
|
|
18679
|
+
// Local tool, local servers: probing http://127.0.0.1:3000/mcp is
|
|
18680
|
+
// the ordinary case, not the exception.
|
|
18681
|
+
allowPrivateNetwork: true,
|
|
18175
18682
|
headers: parseHeadersOption(options.header),
|
|
18176
18683
|
accessToken,
|
|
18177
18684
|
clientCapabilities: "clientCapabilities" in config ? config.clientCapabilities : void 0,
|