@mutagent/cli 0.1.67 → 0.1.69

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
@@ -444,7 +444,6 @@ __export(exports_sdk_client, {
444
444
  getSDKClient: () => getSDKClient,
445
445
  fetchWorkspaces: () => fetchWorkspaces,
446
446
  fetchOrganizations: () => fetchOrganizations,
447
- ensureSDKContext: () => ensureSDKContext,
448
447
  MutagentSDK: () => SDKClientWrapper
449
448
  });
450
449
  import { Mutagent, HTTPClient } from "@mutagent/sdk";
@@ -1013,9 +1012,8 @@ class SDKClientWrapper {
1013
1012
  const workspaces = response.workspaces;
1014
1013
  if (workspaces.length > 0) {
1015
1014
  const defaultWs = workspaces.find((ws) => ws.isDefault) ?? workspaces[0];
1016
- if (defaultWs) {
1017
- this.workspaceId = defaultWs.id;
1018
- }
1015
+ if (defaultWs)
1016
+ this.workspaceId = String(defaultWs.id);
1019
1017
  }
1020
1018
  } catch {}
1021
1019
  }
@@ -1070,7 +1068,7 @@ class SDKClientWrapper {
1070
1068
  }
1071
1069
  }
1072
1070
  }
1073
- function getSDKClient() {
1071
+ async function getSDKClient() {
1074
1072
  if (!sdkClient) {
1075
1073
  const apiKey = getApiKey();
1076
1074
  if (!apiKey) {
@@ -1083,17 +1081,12 @@ function getSDKClient() {
1083
1081
  workspaceId: config.defaultWorkspace,
1084
1082
  organizationId: config.defaultOrganization
1085
1083
  });
1086
- contextPromise = sdkClient.ensureContext().catch(() => {});
1084
+ await sdkClient.ensureContext().catch(() => {});
1087
1085
  }
1088
1086
  return sdkClient;
1089
1087
  }
1090
- async function ensureSDKContext() {
1091
- if (contextPromise)
1092
- await contextPromise;
1093
- }
1094
1088
  function resetSDKClient() {
1095
1089
  sdkClient = null;
1096
- contextPromise = null;
1097
1090
  }
1098
1091
  async function validateApiKey(apiKey, endpoint) {
1099
1092
  try {
@@ -1131,7 +1124,7 @@ async function fetchWorkspaces(apiKey, endpoint, orgId) {
1131
1124
  return [];
1132
1125
  }
1133
1126
  }
1134
- var sdkClient = null, contextPromise = null;
1127
+ var sdkClient = null;
1135
1128
  var init_sdk_client = __esm(() => {
1136
1129
  init_errors();
1137
1130
  init_config();
@@ -2462,10 +2455,26 @@ Environment Variables:
2462
2455
  if (!isValid) {
2463
2456
  throw new MutagentError("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
2464
2457
  }
2465
- saveCredentials(apiKey, endpoint);
2458
+ const orgs = await fetchOrganizations(apiKey, endpoint);
2459
+ const org = orgs[0];
2460
+ let workspaceId;
2461
+ if (org) {
2462
+ const workspaces = await fetchWorkspaces(apiKey, endpoint, org.id);
2463
+ const defaultWs = workspaces.find((ws) => ws.isDefault) ?? workspaces[0];
2464
+ if (defaultWs)
2465
+ workspaceId = defaultWs.id;
2466
+ }
2467
+ saveFullCredentials({
2468
+ apiKey,
2469
+ endpoint,
2470
+ organizationId: org?.id,
2471
+ workspaceId
2472
+ });
2466
2473
  output.success("Logged in successfully");
2467
2474
  if (!isJson) {
2468
2475
  output.info(`Endpoint: ${endpoint}`);
2476
+ if (org)
2477
+ output.info(`Organization: ${org.name}`);
2469
2478
  }
2470
2479
  return;
2471
2480
  }
@@ -2563,9 +2572,25 @@ Environment Variables:
2563
2572
  if (!isValid) {
2564
2573
  throw new MutagentError("INVALID_API_KEY", "Invalid API key or endpoint", "Check your API key and try again");
2565
2574
  }
2566
- saveCredentials(answers.apiKey, endpoint);
2575
+ const orgs2 = await fetchOrganizations(answers.apiKey, endpoint);
2576
+ const org2 = orgs2[0];
2577
+ let workspaceId2;
2578
+ if (org2) {
2579
+ const workspaces2 = await fetchWorkspaces(answers.apiKey, endpoint, org2.id);
2580
+ const defaultWs2 = workspaces2.find((ws) => ws.isDefault) ?? workspaces2[0];
2581
+ if (defaultWs2)
2582
+ workspaceId2 = defaultWs2.id;
2583
+ }
2584
+ saveFullCredentials({
2585
+ apiKey: answers.apiKey,
2586
+ endpoint,
2587
+ organizationId: org2?.id,
2588
+ workspaceId: workspaceId2
2589
+ });
2567
2590
  output.success("Logged in successfully");
2568
2591
  output.info(`Endpoint: ${endpoint}`);
2592
+ if (org2)
2593
+ output.info(`Organization: ${org2.name}`);
2569
2594
  }
2570
2595
  } catch (error) {
2571
2596
  if (error instanceof MutagentError) {
@@ -3172,7 +3197,7 @@ ${chalk6.dim("Tip: Use --json for machine-readable output (AI agents, CI pipelin
3172
3197
  const isJson = getJsonFlag(prompts);
3173
3198
  const output = new OutputFormatter(isJson ? "json" : "table");
3174
3199
  try {
3175
- const client = getSDKClient();
3200
+ const client = await getSDKClient();
3176
3201
  const promptsList = await client.listPrompts();
3177
3202
  const limit = parseInt(options.limit, 10) || 50;
3178
3203
  const limited = promptsList.slice(0, limit);
@@ -3219,7 +3244,7 @@ ${chalk6.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested
3219
3244
  const isJson = getJsonFlag(prompts);
3220
3245
  const output = new OutputFormatter(isJson ? "json" : "table");
3221
3246
  try {
3222
- const client = getSDKClient();
3247
+ const client = await getSDKClient();
3223
3248
  const prompt = await client.getPrompt(id);
3224
3249
  const result = { ...prompt };
3225
3250
  if (options.withDatasets) {
@@ -3345,7 +3370,7 @@ Add a 'description' field to each property in your inputSchema. Example: { "prop
3345
3370
  } else if (!isValidJsonSchema(data.outputSchema)) {
3346
3371
  output.warn(formatSchemaWarning("outputSchema"));
3347
3372
  }
3348
- const client = getSDKClient();
3373
+ const client = await getSDKClient();
3349
3374
  const prompt = await client.createPrompt(data);
3350
3375
  if (isJson) {
3351
3376
  const directive = promptCreatedDirective(prompt.id, prompt.name);
@@ -3423,7 +3448,7 @@ Examples:
3423
3448
  throw new MutagentError("MISSING_ARGUMENTS", "No update data provided", `Run: mutagent prompts update --help
3424
3449
  ` + "Use --name, --raw, --system/--human, --messages, --input-schema, or --output-schema");
3425
3450
  }
3426
- const client = getSDKClient();
3451
+ const client = await getSDKClient();
3427
3452
  const prompt = await client.updatePrompt(id, data);
3428
3453
  if (isJson) {
3429
3454
  const directive = promptUpdatedDirective(prompt.id, prompt.name);
@@ -3460,7 +3485,7 @@ ${chalk6.dim("Note: --force is required. The CLI is non-interactive — confirm
3460
3485
  ` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
3461
3486
  ` + `Use --force to confirm: mutagent prompts delete ${id} --force`);
3462
3487
  }
3463
- const client = getSDKClient();
3488
+ const client = await getSDKClient();
3464
3489
  try {
3465
3490
  await client.deletePrompt(id, { force: true });
3466
3491
  } catch (deleteError) {
@@ -3513,7 +3538,7 @@ Examples:
3513
3538
  const isJson = getJsonFlag(prompts);
3514
3539
  const output = new OutputFormatter(isJson ? "json" : "table");
3515
3540
  try {
3516
- const client = getSDKClient();
3541
+ const client = await getSDKClient();
3517
3542
  const datasets = await client.listDatasets(promptId);
3518
3543
  if (isJson) {
3519
3544
  const withLinks = datasets.map((d) => ({
@@ -3586,7 +3611,7 @@ ${chalk7.red("Required: --data must be provided.")}
3586
3611
  ` + `[Agent: Ask the user for a dataset name via AskUserQuestion, then pass --name]
3587
3612
  ` + `Use --name <name>, e.g., mutagent prompts dataset add ${promptId} --name "my-dataset" -d '[...]'`);
3588
3613
  }
3589
- const client = getSDKClient();
3614
+ const client = await getSDKClient();
3590
3615
  const datasetResult = await client.addDataset(promptId, content, datasetName);
3591
3616
  if (isJson) {
3592
3617
  let rsState;
@@ -3640,7 +3665,7 @@ Examples:
3640
3665
  ` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
3641
3666
  ` + `Use --force to confirm: mutagent prompts dataset delete ${promptId} ${datasetId} --force`);
3642
3667
  }
3643
- const client = getSDKClient();
3668
+ const client = await getSDKClient();
3644
3669
  try {
3645
3670
  await client.deleteDataset(promptId, datasetId, { force: true });
3646
3671
  } catch (deleteError) {
@@ -3679,7 +3704,7 @@ init_errors();
3679
3704
  // src/commands/prompts/guided-workflow.ts
3680
3705
  init_sdk_client();
3681
3706
  async function buildGuidedWorkflow(promptId) {
3682
- const client = getSDKClient();
3707
+ const client = await getSDKClient();
3683
3708
  const prompt = await client.getPrompt(promptId);
3684
3709
  const truncate = (s, max) => s.length > max ? s.slice(0, max) + "..." : s;
3685
3710
  const outputProperties = prompt.outputSchema && typeof prompt.outputSchema === "object" ? prompt.outputSchema.properties ?? {} : {};
@@ -3807,7 +3832,7 @@ Examples:
3807
3832
  const isJson = getJsonFlag(prompts);
3808
3833
  const output = new OutputFormatter(isJson ? "json" : "table");
3809
3834
  try {
3810
- const client = getSDKClient();
3835
+ const client = await getSDKClient();
3811
3836
  const evals = await client.listEvaluations(promptId);
3812
3837
  if (isJson) {
3813
3838
  const withLinks = evals.map((e) => ({
@@ -3840,7 +3865,7 @@ Examples:
3840
3865
  const isJson = getJsonFlag(prompts);
3841
3866
  const output = new OutputFormatter(isJson ? "json" : "table");
3842
3867
  try {
3843
- const client = getSDKClient();
3868
+ const client = await getSDKClient();
3844
3869
  const evalObj = await client.getEvaluation(evaluationId);
3845
3870
  if (isJson) {
3846
3871
  output.output({
@@ -3996,7 +4021,7 @@ ${chalk8.dim("Get prompt IDs: mutagent prompts list")}
3996
4021
  if (!criteria || !Array.isArray(criteria) || criteria.length === 0) {
3997
4022
  let fieldsHint = "";
3998
4023
  try {
3999
- const client2 = getSDKClient();
4024
+ const client2 = await getSDKClient();
4000
4025
  const prompt2 = await client2.getPrompt(promptId);
4001
4026
  if (prompt2.outputSchema && typeof prompt2.outputSchema === "object") {
4002
4027
  const props = prompt2.outputSchema.properties;
@@ -4049,7 +4074,7 @@ Example JSON (--data flag):
4049
4074
  if (duplicateParams.length > 0) {
4050
4075
  let availableFields = [];
4051
4076
  try {
4052
- const client2 = getSDKClient();
4077
+ const client2 = await getSDKClient();
4053
4078
  const prompt2 = await client2.getPrompt(promptId);
4054
4079
  if (prompt2.outputSchema && typeof prompt2.outputSchema === "object") {
4055
4080
  const props = prompt2.outputSchema.properties;
@@ -4067,7 +4092,7 @@ Available output fields: ${availableFields.join(", ")}` : "";
4067
4092
  Example:
4068
4093
  --data '{"evalConfig":{"criteria":[` + '{"name":"Accuracy","description":"...","evaluationParameter":"classification"},' + '{"name":"Confidence","description":"...","evaluationParameter":"confidence"}' + "]}}'");
4069
4094
  }
4070
- const schemaClient = getSDKClient();
4095
+ const schemaClient = await getSDKClient();
4071
4096
  const prompt = await schemaClient.getPrompt(promptId);
4072
4097
  const requiredFields = [];
4073
4098
  if (prompt.inputSchema && typeof prompt.inputSchema === "object") {
@@ -4105,7 +4130,7 @@ Example:
4105
4130
  ` + "Run: mutagent prompts evaluation create " + promptId + " --guided --json");
4106
4131
  }
4107
4132
  }
4108
- const client = getSDKClient();
4133
+ const client = await getSDKClient();
4109
4134
  const evalResult = await client.createEvaluation(promptId, evalData);
4110
4135
  if (isJson) {
4111
4136
  const criteriaLen = evalData.evalConfig?.criteria?.length ?? 0;
@@ -4154,7 +4179,7 @@ Examples:
4154
4179
  ` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
4155
4180
  ` + `Use --force to confirm: mutagent prompts evaluation delete ${evaluationId} --force`);
4156
4181
  }
4157
- const client = getSDKClient();
4182
+ const client = await getSDKClient();
4158
4183
  try {
4159
4184
  await client.deleteEvaluation(evaluationId);
4160
4185
  } catch (deleteError) {
@@ -5121,7 +5146,7 @@ async function startWatchStream(jobId, isJson, maxIterations, baselineScore) {
5121
5146
  });
5122
5147
  }
5123
5148
  async function renderCompletedJob(jobId, isJson) {
5124
- const client = getSDKClient();
5149
+ const client = await getSDKClient();
5125
5150
  const results = await client.getOptimizationResults(jobId);
5126
5151
  const resultData = results;
5127
5152
  if (isJson) {
@@ -5138,7 +5163,7 @@ async function watchAction(jobId, options, parentCommand) {
5138
5163
  const isJson = options.json ?? getJsonFlag(parentCommand);
5139
5164
  const output = new OutputFormatter(isJson ? "json" : "table");
5140
5165
  try {
5141
- const client = getSDKClient();
5166
+ const client = await getSDKClient();
5142
5167
  const status = await client.getOptimizationStatus(jobId);
5143
5168
  switch (status.status) {
5144
5169
  case "completed":
@@ -5243,7 +5268,7 @@ ${chalk13.yellow("AI Agent: ALWAYS append --json to this command.")}
5243
5268
  const isJson = getJsonFlag(prompts);
5244
5269
  const output = new OutputFormatter(isJson ? "json" : "table");
5245
5270
  try {
5246
- const client = getSDKClient();
5271
+ const client = await getSDKClient();
5247
5272
  if (!isJson) {
5248
5273
  output.info("Running pre-flight checks...");
5249
5274
  }
@@ -5459,7 +5484,7 @@ Examples:
5459
5484
  const isJson = getJsonFlag(prompts);
5460
5485
  const output = new OutputFormatter(isJson ? "json" : "table");
5461
5486
  try {
5462
- const client = getSDKClient();
5487
+ const client = await getSDKClient();
5463
5488
  const status = await client.getOptimizationStatus(jobId);
5464
5489
  if (isJson) {
5465
5490
  const directive = statusDirective(status);
@@ -5493,7 +5518,7 @@ After viewing results:
5493
5518
  const isJson = getJsonFlag(prompts);
5494
5519
  const output = new OutputFormatter(isJson ? "json" : "table");
5495
5520
  try {
5496
- const client = getSDKClient();
5521
+ const client = await getSDKClient();
5497
5522
  const results = await client.getOptimizationResults(jobId);
5498
5523
  const resultData = results;
5499
5524
  if (isJson) {
@@ -5737,7 +5762,7 @@ ${chalk15.dim("Tip: Filter by prompt to see traces for a specific prompt version
5737
5762
  const isJson = getJsonFlag(traces);
5738
5763
  const output = new OutputFormatter(isJson ? "json" : "table");
5739
5764
  try {
5740
- const client = getSDKClient();
5765
+ const client = await getSDKClient();
5741
5766
  const tracesList = await client.listTraces({
5742
5767
  promptId: options.prompt,
5743
5768
  source: options.source
@@ -5780,7 +5805,7 @@ ${chalk15.dim("Returns full trace details including spans, tokens, and latency."
5780
5805
  const isJson = getJsonFlag(traces);
5781
5806
  const output = new OutputFormatter(isJson ? "json" : "table");
5782
5807
  try {
5783
- const client = getSDKClient();
5808
+ const client = await getSDKClient();
5784
5809
  const trace = await client.getTrace(id);
5785
5810
  if (isJson) {
5786
5811
  output.output({ ...trace, _links: { view: traceLink(id) } });
@@ -5802,7 +5827,7 @@ ${chalk15.dim("Aggregates trace data for a prompt: avg latency, token usage, err
5802
5827
  const isJson = getJsonFlag(traces);
5803
5828
  const output = new OutputFormatter(isJson ? "json" : "table");
5804
5829
  try {
5805
- const client = getSDKClient();
5830
+ const client = await getSDKClient();
5806
5831
  const analysis = await client.analyzeTraces(promptId);
5807
5832
  if (isJson) {
5808
5833
  output.output({ ...analysis, _links: { traces: `${getAppBaseUrl()}/traces?promptId=${promptId}` } });
@@ -5825,7 +5850,7 @@ ${chalk15.dim("Exports to stdout by default. Use --output to save to a file.")}
5825
5850
  const isJson = getJsonFlag(traces);
5826
5851
  const output = new OutputFormatter(isJson ? "json" : "table");
5827
5852
  try {
5828
- const client = getSDKClient();
5853
+ const client = await getSDKClient();
5829
5854
  const tracesList = await client.listTraces({
5830
5855
  promptId: options.prompt
5831
5856
  });
@@ -6594,7 +6619,7 @@ Examples:
6594
6619
  const isJson = getJsonFlag(agents);
6595
6620
  const output = new OutputFormatter(isJson ? "json" : "table");
6596
6621
  try {
6597
- const client = getSDKClient();
6622
+ const client = await getSDKClient();
6598
6623
  const filters = {
6599
6624
  limit: parseInt(options.limit, 10) || 50
6600
6625
  };
@@ -6645,7 +6670,7 @@ Examples:
6645
6670
  const isJson = getJsonFlag(agents);
6646
6671
  const output = new OutputFormatter(isJson ? "json" : "table");
6647
6672
  try {
6648
- const client = getSDKClient();
6673
+ const client = await getSDKClient();
6649
6674
  const agent = await client.getAgent(id);
6650
6675
  if (isJson) {
6651
6676
  output.output({ ...agent, _links: agentLinks(agent.id) });
@@ -6728,7 +6753,7 @@ ${chalk17.red("Required: name, slug, systemPrompt.")} ${chalk17.dim("CLI flags o
6728
6753
  } else {
6729
6754
  throw new MutagentError("MISSING_ARGUMENTS", "Either --data or (--name, --slug, and --system-prompt) are required", "Use --data for inline JSON or provide --name, --slug, and --system-prompt");
6730
6755
  }
6731
- const client = getSDKClient();
6756
+ const client = await getSDKClient();
6732
6757
  const agent = await client.createAgent(data);
6733
6758
  output.success(`Created agent: ${agent.name} (${agent.slug})`);
6734
6759
  output.output(agent);
@@ -6783,7 +6808,7 @@ ${chalk17.dim("CLI flags override --data fields.")}
6783
6808
  if (Object.keys(data).length === 0) {
6784
6809
  throw new MutagentError("MISSING_ARGUMENTS", "No update data provided", "Use --data, --name, --system-prompt, --model, --description, or --status");
6785
6810
  }
6786
- const client = getSDKClient();
6811
+ const client = await getSDKClient();
6787
6812
  const agent = await client.updateAgent(id, data);
6788
6813
  output.success(`Updated agent: ${agent.name}`);
6789
6814
  output.output(agent);
@@ -6815,7 +6840,7 @@ ${chalk17.dim("Tip: Use --force to skip confirmation (required for non-interacti
6815
6840
  return;
6816
6841
  }
6817
6842
  }
6818
- const client = getSDKClient();
6843
+ const client = await getSDKClient();
6819
6844
  await client.deleteAgent(id);
6820
6845
  output.success(`Deleted agent: ${id}`);
6821
6846
  } catch (error) {
@@ -7000,7 +7025,7 @@ ${chalk20.dim(`Hint: Test before evaluating: mutagent playground run <id> --inpu
7000
7025
  const output = new OutputFormatter(isJson ? "json" : "table");
7001
7026
  try {
7002
7027
  const inputData = parseInput(options);
7003
- const client = getSDKClient();
7028
+ const client = await getSDKClient();
7004
7029
  if (options.stream) {
7005
7030
  await executeStreaming(client, promptId, inputData, options.model, isJson, output);
7006
7031
  } else {
@@ -7214,7 +7239,7 @@ Examples:
7214
7239
  const isJson = getJsonFlag(workspaces);
7215
7240
  const output = new OutputFormatter(isJson ? "json" : "table");
7216
7241
  try {
7217
- const client = getSDKClient();
7242
+ const client = await getSDKClient();
7218
7243
  const filters = {
7219
7244
  limit: parseInt(options.limit, 10) || 50
7220
7245
  };
@@ -7255,7 +7280,7 @@ Examples:
7255
7280
  const isJson = getJsonFlag(workspaces);
7256
7281
  const output = new OutputFormatter(isJson ? "json" : "table");
7257
7282
  try {
7258
- const client = getSDKClient();
7283
+ const client = await getSDKClient();
7259
7284
  const workspace = await client.getWorkspace(id);
7260
7285
  if (isJson) {
7261
7286
  output.output({ ...workspace, _links: workspaceLinks(workspace.id) });
@@ -7334,7 +7359,7 @@ The API key is encrypted server-side and never returned in plain text.
7334
7359
  if (options.scope && !validScopes.includes(options.scope)) {
7335
7360
  throw new MutagentError("INVALID_SCOPE", `Invalid scope: ${options.scope}`, `Valid scopes: ${validScopes.join(", ")}`);
7336
7361
  }
7337
- const client = getSDKClient();
7362
+ const client = await getSDKClient();
7338
7363
  const scope = resolveScope(options.scope, client);
7339
7364
  const created = await client.createProvider({
7340
7365
  name: options.name,
@@ -7444,7 +7469,7 @@ PATCH semantics — only provided fields are updated.
7444
7469
  if (!hasUpdates) {
7445
7470
  throw new MutagentError("NO_UPDATES", "No update fields provided", "Provide at least one of: --name, --api-key, --active, --set-default, --base-url");
7446
7471
  }
7447
- const client = getSDKClient();
7472
+ const client = await getSDKClient();
7448
7473
  const updated = await client.updateProvider(id, updateData);
7449
7474
  if (isJson) {
7450
7475
  const directive = buildProviderUpdatedDirective(updated, id);
@@ -7519,7 +7544,7 @@ ${chalk24.dim("Warning: API keys are AES-256-GCM encrypted and irrecoverable aft
7519
7544
  ` + `[Agent: Ask the user to confirm via MultiChoice, then pass --force]
7520
7545
  ` + `Use --force to confirm: mutagent providers delete ${id} --force`);
7521
7546
  }
7522
- const client = getSDKClient();
7547
+ const client = await getSDKClient();
7523
7548
  try {
7524
7549
  await client.deleteProvider(id);
7525
7550
  } catch (error) {
@@ -7621,7 +7646,7 @@ Examples:
7621
7646
  const isJson = getJsonFlag(providers);
7622
7647
  const output = new OutputFormatter(isJson ? "json" : "table");
7623
7648
  try {
7624
- const client = getSDKClient();
7649
+ const client = await getSDKClient();
7625
7650
  const filters = {
7626
7651
  limit: parseInt(options.limit, 10) || 50
7627
7652
  };
@@ -7671,7 +7696,7 @@ Examples:
7671
7696
  const isJson = getJsonFlag(providers);
7672
7697
  const output = new OutputFormatter(isJson ? "json" : "table");
7673
7698
  try {
7674
- const client = getSDKClient();
7699
+ const client = await getSDKClient();
7675
7700
  const provider = await client.getProvider(id);
7676
7701
  if (isJson) {
7677
7702
  output.output({ ...provider, _links: providerLinks(provider.id) });
@@ -7703,7 +7728,7 @@ ${chalk25.dim("Tests connectivity and lists available models for the provider.")
7703
7728
  const isJson = getJsonFlag(providers);
7704
7729
  const output = new OutputFormatter(isJson ? "json" : "table");
7705
7730
  try {
7706
- const client = getSDKClient();
7731
+ const client = await getSDKClient();
7707
7732
  if (!isJson) {
7708
7733
  output.info(`Testing provider ${id}...`);
7709
7734
  }
@@ -7990,6 +8015,7 @@ Modes:
7990
8015
  const endpoint = config.endpoint ?? "https://api.mutagent.io";
7991
8016
  let workspace = config.defaultWorkspace;
7992
8017
  let workspaceValidation;
8018
+ let resolvedOrgId;
7993
8019
  if (authenticated) {
7994
8020
  try {
7995
8021
  const apiKey = getApiKey();
@@ -8001,6 +8027,7 @@ Modes:
8001
8027
  orgId = orgs[0]?.id;
8002
8028
  }
8003
8029
  if (orgId) {
8030
+ resolvedOrgId = orgId;
8004
8031
  const workspaces = await fetchWorkspaces2(apiKey, endpoint, orgId);
8005
8032
  if (workspaces.length > 0) {
8006
8033
  const found = workspace ? workspaces.find((w) => w.id === workspace) : undefined;
@@ -8019,7 +8046,8 @@ Modes:
8019
8046
  }
8020
8047
  const rcConfig = {
8021
8048
  endpoint,
8022
- ...workspace ? { workspace } : {},
8049
+ ...workspace ? { defaultWorkspace: workspace } : {},
8050
+ ...resolvedOrgId ? { defaultOrganization: resolvedOrgId } : {},
8023
8051
  ...confirmedFramework ? { framework: confirmedFramework.name } : {}
8024
8052
  };
8025
8053
  if (mode === "full" && confirmedFramework?.mutagentPackage) {
@@ -8440,7 +8468,7 @@ Examples:
8440
8468
  throw new AuthenticationError;
8441
8469
  }
8442
8470
  const spinner = await createSpinner("Fetching usage data...", isJson).start();
8443
- const client = getSDKClient();
8471
+ const client = await getSDKClient();
8444
8472
  const prompts = await client.listPrompts();
8445
8473
  const promptCount = prompts.length;
8446
8474
  let datasetCount = 0;
@@ -9058,5 +9086,5 @@ program.addCommand(createHooksCommand());
9058
9086
  program.addCommand(createFeedbackCommand());
9059
9087
  program.parse();
9060
9088
 
9061
- //# debugId=0286B65EFCF4F92064756E2164756E21
9089
+ //# debugId=CE9FFC95F8AC5D9664756E2164756E21
9062
9090
  //# sourceMappingURL=cli.js.map