@growthub/cli 0.3.17 → 0.3.18

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.
@@ -123,7 +123,7 @@ export async function createApp(db, opts) {
123
123
  auth: {
124
124
  ...config.auth,
125
125
  token,
126
- growthubBaseUrl: normalizedPortalBaseUrl ?? config.auth.growthubBaseUrl,
126
+ growthubBaseUrl: config.auth.growthubBaseUrl,
127
127
  growthubPortalBaseUrl: normalizedPortalBaseUrl ?? config.auth.growthubPortalBaseUrl,
128
128
  growthubMachineLabel: machineLabel || config.auth.growthubMachineLabel,
129
129
  growthubWorkspaceLabel: workspaceLabel || config.auth.growthubWorkspaceLabel,
@@ -368,4 +368,4 @@ export async function createApp(db, opts) {
368
368
  });
369
369
  return app;
370
370
  }
371
- //# sourceMappingURL=app.js.map
371
+ //# sourceMappingURL=app.js.map
@@ -64,6 +64,7 @@ function getGrowthubConnectionState() {
64
64
  const config = readConfigFile();
65
65
  const baseUrl = config?.auth.growthubBaseUrl?.trim() ||
66
66
  process.env.GROWTHUB_BASE_URL?.trim() ||
67
+ config?.auth.growthubPortalBaseUrl?.trim() ||
67
68
  "";
68
69
  return {
69
70
  baseUrl,
@@ -147,26 +148,45 @@ export function gtmRoutes(db) {
147
148
  return;
148
149
  }
149
150
  try {
150
- const response = await fetch(new URL("/api/providers/growthub-local/probe", connection.baseUrl), {
151
- method: "POST",
152
- headers: {
153
- authorization: `Bearer ${connection.token}`,
154
- },
155
- });
156
- const data = (await response.json().catch(() => ({})));
157
- if (!response.ok) {
158
- res.status(response.status).json({
159
- error: (typeof data.error === "string" && data.error) ||
160
- "Growthub local probe failed.",
161
- });
162
- return;
151
+ const targets = [connection.baseUrl];
152
+ if (connection.portalBaseUrl && connection.portalBaseUrl !== connection.baseUrl) {
153
+ targets.push(connection.portalBaseUrl);
163
154
  }
164
- res.json({
165
- success: true,
166
- message: (typeof data.message === "string" && data.message) ||
167
- "Growthub local probe succeeded.",
168
- knowledgeItemId: typeof data.knowledgeItemId === "string" ? data.knowledgeItemId : null,
155
+ let lastFailure = null;
156
+ let lastError = null;
157
+ for (const target of targets) {
158
+ try {
159
+ const response = await fetch(new URL("/api/providers/growthub-local/probe", target), {
160
+ method: "POST",
161
+ headers: {
162
+ authorization: `Bearer ${connection.token}`,
163
+ },
164
+ });
165
+ const data = (await response.json().catch(() => ({})));
166
+ if (!response.ok) {
167
+ lastFailure = { status: response.status, data };
168
+ continue;
169
+ }
170
+ res.json({
171
+ success: true,
172
+ message: (typeof data.message === "string" && data.message) ||
173
+ "Growthub local probe succeeded.",
174
+ knowledgeItemId: typeof data.knowledgeItemId === "string" ? data.knowledgeItemId : null,
175
+ });
176
+ return;
177
+ }
178
+ catch (error) {
179
+ lastError = error;
180
+ }
181
+ }
182
+ if (lastError && !lastFailure) {
183
+ throw lastError;
184
+ }
185
+ res.status((lastFailure?.status) ?? 502).json({
186
+ error: (typeof lastFailure?.data?.error === "string" && lastFailure.data.error) ||
187
+ "Growthub local probe failed.",
169
188
  });
189
+ return;
170
190
  }
171
191
  catch (error) {
172
192
  res.status(502).json({
@@ -196,7 +216,7 @@ export function gtmRoutes(db) {
196
216
  },
197
217
  });
198
218
  res.json({
199
- baseUrl: config.auth.growthubBaseUrl?.trim() || "",
219
+ baseUrl: getGrowthubConnectionState().baseUrl,
200
220
  callbackUrl: "/auth/callback",
201
221
  connected: false,
202
222
  portalBaseUrl: "",
@@ -552,4 +572,4 @@ export function gtmRoutes(db) {
552
572
  });
553
573
  return router;
554
574
  }
555
- //# sourceMappingURL=gtm.js.map
575
+ //# sourceMappingURL=gtm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growthub/cli",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "Growthub CLI — orchestrate AI agent teams to run a business",
5
5
  "type": "module",
6
6
  "bin": {