@mutagent/cli 0.1.67 → 0.1.68

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";
@@ -901,6 +900,7 @@ class SDKClientWrapper {
901
900
  }
902
901
  async listWorkspaces(filters) {
903
902
  try {
903
+ await this.ensureOrganizationId();
904
904
  const response = await this.sdk.workspaces.listWorkspaces({
905
905
  includeInactive: false
906
906
  });
@@ -917,6 +917,7 @@ class SDKClientWrapper {
917
917
  }
918
918
  async getWorkspace(id) {
919
919
  try {
920
+ await this.ensureOrganizationId();
920
921
  const response = await this.sdk.workspaces.getWorkspace({
921
922
  wsId: id
922
923
  });
@@ -998,26 +999,12 @@ class SDKClientWrapper {
998
999
  getCurrentOrgId() {
999
1000
  return this.organizationId;
1000
1001
  }
1001
- async ensureContext() {
1002
- if (this.organizationId && this.workspaceId)
1002
+ async ensureOrganizationId() {
1003
+ if (this.organizationId)
1003
1004
  return;
1004
- if (!this.organizationId) {
1005
- const orgs = await fetchOrganizations(this.apiKey, this.endpoint);
1006
- if (orgs.length > 0 && orgs[0]) {
1007
- this.organizationId = orgs[0].id;
1008
- }
1009
- }
1010
- if (!this.workspaceId && this.organizationId) {
1011
- try {
1012
- const response = await this.sdk.workspaces.listWorkspaces({ includeInactive: false });
1013
- const workspaces = response.workspaces;
1014
- if (workspaces.length > 0) {
1015
- const defaultWs = workspaces.find((ws) => ws.isDefault) ?? workspaces[0];
1016
- if (defaultWs) {
1017
- this.workspaceId = defaultWs.id;
1018
- }
1019
- }
1020
- } catch {}
1005
+ const orgs = await fetchOrganizations(this.apiKey, this.endpoint);
1006
+ if (orgs.length > 0 && orgs[0]) {
1007
+ this.organizationId = orgs[0].id;
1021
1008
  }
1022
1009
  }
1023
1010
  async testProvider(id) {
@@ -1083,17 +1070,11 @@ function getSDKClient() {
1083
1070
  workspaceId: config.defaultWorkspace,
1084
1071
  organizationId: config.defaultOrganization
1085
1072
  });
1086
- contextPromise = sdkClient.ensureContext().catch(() => {});
1087
1073
  }
1088
1074
  return sdkClient;
1089
1075
  }
1090
- async function ensureSDKContext() {
1091
- if (contextPromise)
1092
- await contextPromise;
1093
- }
1094
1076
  function resetSDKClient() {
1095
1077
  sdkClient = null;
1096
- contextPromise = null;
1097
1078
  }
1098
1079
  async function validateApiKey(apiKey, endpoint) {
1099
1080
  try {
@@ -1131,7 +1112,7 @@ async function fetchWorkspaces(apiKey, endpoint, orgId) {
1131
1112
  return [];
1132
1113
  }
1133
1114
  }
1134
- var sdkClient = null, contextPromise = null;
1115
+ var sdkClient = null;
1135
1116
  var init_sdk_client = __esm(() => {
1136
1117
  init_errors();
1137
1118
  init_config();
@@ -9058,5 +9039,5 @@ program.addCommand(createHooksCommand());
9058
9039
  program.addCommand(createFeedbackCommand());
9059
9040
  program.parse();
9060
9041
 
9061
- //# debugId=0286B65EFCF4F92064756E2164756E21
9042
+ //# debugId=EA3BD8A71195D63264756E2164756E21
9062
9043
  //# sourceMappingURL=cli.js.map