@mutagent/cli 0.1.71 → 0.1.73

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/bin/cli.js CHANGED
@@ -1001,7 +1001,11 @@ class SDKClientWrapper {
1001
1001
  if (this.organizationId && this.workspaceId)
1002
1002
  return;
1003
1003
  if (!this.organizationId) {
1004
- const orgs = await fetchOrganizations(this.apiKey, this.endpoint);
1004
+ let orgs = await fetchOrganizations(this.apiKey, this.endpoint).catch(() => []);
1005
+ if (orgs.length === 0) {
1006
+ await new Promise((r) => setTimeout(r, 1000));
1007
+ orgs = await fetchOrganizations(this.apiKey, this.endpoint).catch(() => []);
1008
+ }
1005
1009
  if (orgs.length > 0 && orgs[0]) {
1006
1010
  this.organizationId = orgs[0].id;
1007
1011
  }
@@ -1081,7 +1085,13 @@ async function getSDKClient() {
1081
1085
  workspaceId: config.defaultWorkspace,
1082
1086
  organizationId: config.defaultOrganization
1083
1087
  });
1084
- await sdkClient.ensureContext().catch(() => {});
1088
+ await sdkClient.ensureContext().catch((err) => {
1089
+ if (process.env.MUTAGENT_DEBUG) {
1090
+ const message = err instanceof Error ? err.message : String(err);
1091
+ process.stderr.write(`[mutagent] Context resolution failed: ${message}
1092
+ `);
1093
+ }
1094
+ });
1085
1095
  }
1086
1096
  return sdkClient;
1087
1097
  }
@@ -6180,11 +6190,15 @@ import { MutagentSpanExporter } from '@mutagent/vercel-ai';
6180
6190
  import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
6181
6191
  import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
6182
6192
 
6183
- // Set up OTel provider with MutagenT exporter (once at app startup)
6184
- const provider = new NodeTracerProvider();
6185
- provider.addSpanProcessor(
6186
- new SimpleSpanProcessor(new MutagentSpanExporter())
6187
- );
6193
+ // NOTE: OpenTelemetry v2.x required. The v1 API (addSpanProcessor) was removed.
6194
+ // Users on OTel v1 should upgrade or use createMutagentMiddleware() alternative.
6195
+
6196
+ // OpenTelemetry v2 API: Use constructor-based span processor registration
6197
+ const provider = new NodeTracerProvider({
6198
+ spanProcessors: [
6199
+ new SimpleSpanProcessor(new MutagentSpanExporter())
6200
+ ]
6201
+ });
6188
6202
  provider.register();
6189
6203
 
6190
6204
  // Enable telemetry on AI SDK calls — all calls are automatically traced
@@ -6872,6 +6886,7 @@ init_config();
6872
6886
  import { Command as Command10 } from "commander";
6873
6887
  import chalk19 from "chalk";
6874
6888
  init_errors();
6889
+ init_sdk_client();
6875
6890
  var VALID_CONFIG_KEYS = ["apiKey", "endpoint", "format", "timeout", "defaultWorkspace", "defaultOrganization"];
6876
6891
  function createConfigCommand() {
6877
6892
  const config = new Command10("config").description("Manage CLI configuration").addHelpText("after", `
@@ -6935,6 +6950,7 @@ ${chalk19.dim("Persists workspace ID so you don't need to pass headers on every
6935
6950
  const isJson = getJsonFlag(config);
6936
6951
  const output = new OutputFormatter(isJson ? "json" : "table");
6937
6952
  setDefaultWorkspace(id);
6953
+ resetSDKClient();
6938
6954
  if (isJson) {
6939
6955
  output.output({ success: true, defaultWorkspace: id });
6940
6956
  } else {
@@ -6950,6 +6966,7 @@ ${chalk19.dim("Persists organization ID for org-scoped API keys.")}
6950
6966
  const isJson = getJsonFlag(config);
6951
6967
  const output = new OutputFormatter(isJson ? "json" : "table");
6952
6968
  setDefaultOrganization(id);
6969
+ resetSDKClient();
6953
6970
  if (isJson) {
6954
6971
  output.output({ success: true, defaultOrganization: id });
6955
6972
  } else {
@@ -8953,7 +8970,7 @@ var program = new Command20;
8953
8970
  program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimization platform
8954
8971
 
8955
8972
  Documentation: https://docs.mutagent.io/cli
8956
- Dashboard: https://app.mutagent.io`).version(cliVersion, "-v, --version", "Display the version number").option("--json", "Output results as JSON (for AI agents)").option("--api-key <key>", "MutagenT API key").option("--endpoint <url>", "MutagenT server endpoint").option("--non-interactive", "Disable interactive prompts (for CI/AI agents)").configureHelp({
8973
+ Dashboard: https://app.mutagent.io`).option("-v, --version", "Display the version number").option("--json", "Output results as JSON (for AI agents)").option("--api-key <key>", "MutagenT API key").option("--endpoint <url>", "MutagenT server endpoint").option("--non-interactive", "Disable interactive prompts (for CI/AI agents)").configureHelp({
8957
8974
  sortSubcommands: true,
8958
8975
  showGlobalOptions: true
8959
8976
  });
@@ -9056,6 +9073,17 @@ ${!hasCredentials() ? `
9056
9073
  ` : ""}${!hasRcConfig() ? `
9057
9074
  ` + chalk31.green(" Get started: mutagent init") + `
9058
9075
  ` : ""}`);
9076
+ program.hook("preAction", (thisCommand) => {
9077
+ const opts = thisCommand.optsWithGlobals();
9078
+ if (opts.version) {
9079
+ if (opts.json) {
9080
+ console.log(JSON.stringify({ version: cliVersion }));
9081
+ } else {
9082
+ console.log(cliVersion);
9083
+ }
9084
+ process.exit(0);
9085
+ }
9086
+ });
9059
9087
  program.hook("preAction", (thisCommand) => {
9060
9088
  const globalOpts = thisCommand.optsWithGlobals();
9061
9089
  if (globalOpts.apiKey && !process.env.MUTAGENT_API_KEY) {
@@ -9086,5 +9114,5 @@ program.addCommand(createHooksCommand());
9086
9114
  program.addCommand(createFeedbackCommand());
9087
9115
  program.parse();
9088
9116
 
9089
- //# debugId=CE9FFC95F8AC5D9664756E2164756E21
9117
+ //# debugId=7EC4737925B3BC4B64756E2164756E21
9090
9118
  //# sourceMappingURL=cli.js.map