@mcpjam/cli 5.5.2 → 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 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.5.2"};
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;
@@ -12940,6 +12940,412 @@ function registerSwarmAuthoringCommands(program, journeys) {
12940
12940
  })
12941
12941
  );
12942
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
+ }
12943
13349
  function addRequiredOptionWithHiddenAlias(command, visibleFlags, hiddenLongFlag, description) {
12944
13350
  const option = new Option(
12945
13351
  `${hiddenLongFlag}, ${visibleFlags}`,
@@ -14336,6 +14742,8 @@ function registerCloudCommands(program) {
14336
14742
  registerSecretsCommands(cloud);
14337
14743
  registerImagesCommands(cloud);
14338
14744
  registerSkillsCommands(cloud);
14745
+ cloud.commandsGroup("Observability:");
14746
+ registerTraceDestinationsCommands(cloud);
14339
14747
  cloud.commandsGroup("Swarms and user testing:");
14340
14748
  const journeys = registerJourneysCommands(cloud);
14341
14749
  registerScenariosCommands(cloud);
@@ -16034,6 +16442,8 @@ function createMcpJamMcpServer(options) {
16034
16442
  url,
16035
16443
  accessToken,
16036
16444
  headers,
16445
+ // See the `server probe` command: this runs on the user's machine.
16446
+ allowPrivateNetwork: true,
16037
16447
  timeoutMs: timeoutMs ?? defaultTimeoutMs
16038
16448
  });
16039
16449
  return redactForTelemetry(result);
@@ -17123,12 +17533,18 @@ function registerOAuthCommands(program) {
17123
17533
  setProcessExitCode(3);
17124
17534
  }
17125
17535
  });
17126
- oauth.command("metadata").description("Fetch OAuth metadata from a URL").requiredOption("--url <url>", "OAuth metadata URL").action(async (options, command) => {
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) => {
17127
17540
  const format = getOAuthFormat(command);
17128
- const result = await runOAuthMetadata(options.url);
17541
+ const result = await runOAuthMetadata(
17542
+ options.url,
17543
+ options.httpsOnly === true
17544
+ );
17129
17545
  writeResult(result, format);
17130
17546
  });
17131
- oauth.command("proxy").description("Proxy an OAuth request with hosted-mode safety checks").requiredOption("--url <url>", "OAuth request URL").option("--method <method>", "HTTP method", "GET").option(
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(
17132
17548
  "--header <header>",
17133
17549
  'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
17134
17550
  (value, previous = []) => [...previous, value],
@@ -17136,12 +17552,17 @@ function registerOAuthCommands(program) {
17136
17552
  ).option(
17137
17553
  "--body <value>",
17138
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"
17139
17558
  ).action(async (options, command) => {
17140
17559
  const format = getOAuthFormat(command);
17141
17560
  const result = await runOAuthProxy(options);
17142
17561
  writeResult(result, format);
17143
17562
  });
17144
- oauth.command("debug-proxy").description("Proxy an OAuth debug request with hosted-mode safety checks").requiredOption("--url <url>", "OAuth request URL").option("--method <method>", "HTTP method", "GET").option(
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(
17145
17566
  "--header <header>",
17146
17567
  'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
17147
17568
  (value, previous = []) => [...previous, value],
@@ -17149,6 +17570,9 @@ function registerOAuthCommands(program) {
17149
17570
  ).option(
17150
17571
  "--body <value>",
17151
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"
17152
17576
  ).action(async (options, command) => {
17153
17577
  const format = getOAuthFormat(command);
17154
17578
  const result = await runOAuthDebugProxy(
@@ -17228,6 +17652,9 @@ function buildOAuthConformanceConfig(options, defaults) {
17228
17652
  serverUrl,
17229
17653
  protocolVersion,
17230
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,
17231
17658
  auth,
17232
17659
  client,
17233
17660
  scopes: options.scopes?.trim() || void 0,
@@ -17318,6 +17745,8 @@ function buildOAuthLoginConfig(options, defaults) {
17318
17745
  ...registrationStrategy ? { registrationStrategy } : {},
17319
17746
  protocolMode: protocolVersion ?? "auto",
17320
17747
  registrationMode: registrationStrategy ?? "auto",
17748
+ // See buildOAuthConformanceConfig: a local server under test is the norm.
17749
+ allowPrivateNetwork: true,
17321
17750
  auth,
17322
17751
  client,
17323
17752
  scopes: options.scopes?.trim() || void 0,
@@ -17439,9 +17868,12 @@ function parseAuthMode(value) {
17439
17868
  `Invalid auth mode "${value}". Use ${[...VALID_AUTH_MODES].join(", ")}.`
17440
17869
  );
17441
17870
  }
17442
- async function runOAuthMetadata(url) {
17871
+ async function runOAuthMetadata(url, httpsOnly = false) {
17443
17872
  try {
17444
- const result = await fetchOAuthMetadata(url, true);
17873
+ const result = await fetchOAuthMetadata(url, {
17874
+ httpsOnly,
17875
+ allowPrivateNetwork: !httpsOnly
17876
+ });
17445
17877
  if ("status" in result && result.status !== void 0) {
17446
17878
  throw cliError(
17447
17879
  statusToErrorCode(result.status),
@@ -17460,7 +17892,8 @@ async function runOAuthProxy(options) {
17460
17892
  method: options.method,
17461
17893
  headers: parseHeadersOption(options.header),
17462
17894
  body: parseProxyBody(options.body),
17463
- httpsOnly: true
17895
+ httpsOnly: options.httpsOnly === true,
17896
+ allowPrivateNetwork: options.httpsOnly !== true
17464
17897
  });
17465
17898
  } catch (error) {
17466
17899
  throw mapOAuthProxyError(error);
@@ -17473,7 +17906,8 @@ async function runOAuthDebugProxy(options) {
17473
17906
  method: options.method,
17474
17907
  headers: parseHeadersOption(options.header),
17475
17908
  body: parseProxyBody(options.body),
17476
- httpsOnly: true
17909
+ httpsOnly: options.httpsOnly === true,
17910
+ allowPrivateNetwork: options.httpsOnly !== true
17477
17911
  });
17478
17912
  } catch (error) {
17479
17913
  throw mapOAuthProxyError(error);
@@ -17737,7 +18171,10 @@ function buildXaaConfig(options, timeoutMs) {
17737
18171
  } : {},
17738
18172
  ...options.scopes?.trim() ? { scope: options.scopes.trim() } : {},
17739
18173
  ...timeoutMs !== void 0 ? { timeoutMs } : {},
17740
- 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
17741
18178
  };
17742
18179
  }
17743
18180
  function parseRegistration(value) {
@@ -18239,6 +18676,9 @@ function registerServerCommands(program) {
18239
18676
  result = await probeMcpServer({
18240
18677
  url: probeUrl,
18241
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,
18242
18682
  headers: parseHeadersOption(options.header),
18243
18683
  accessToken,
18244
18684
  clientCapabilities: "clientCapabilities" in config ? config.clientCapabilities : void 0,