overlord-cli 3.24.0 → 3.25.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/bin/_cli/auth.mjs CHANGED
@@ -5,9 +5,15 @@ import { execFileSync } from 'node:child_process';
5
5
  import crypto from 'node:crypto';
6
6
  import http from 'node:http';
7
7
 
8
- import { buildAuthHeaders, clearCredentials, loadCredentials, loadRuntime, saveCredentials } from './credentials.mjs';
8
+ import {
9
+ buildAuthHeaders,
10
+ clearCredentials,
11
+ getDefaultOverlordUrl,
12
+ loadCredentials,
13
+ loadRuntime,
14
+ saveCredentials
15
+ } from './credentials.mjs';
9
16
 
10
- const DEFAULT_OVERLORD_URL = process.env.OVERLORD_URL ?? 'https://ovld.ai';
11
17
  const DEFAULT_CLI_REDIRECT_URI = 'http://127.0.0.1:45619/callback';
12
18
  const DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
13
19
 
@@ -412,13 +418,13 @@ export async function authLoginViaOAuthLoopback(platformUrl, localSecret) {
412
418
  // Public auth commands
413
419
  // ---------------------------------------------------------------------------
414
420
 
415
- export function resolveLoginPlatformUrl(runtime = loadRuntime()) {
416
- return process.env.OVERLORD_URL ?? runtime?.platform_url ?? DEFAULT_OVERLORD_URL;
421
+ export function resolveLoginPlatformUrl(runtime = null) {
422
+ return process.env.OVERLORD_URL ?? runtime?.platform_url ?? getDefaultOverlordUrl();
417
423
  }
418
424
 
419
425
  export async function authLogin() {
420
- const runtime = loadRuntime();
421
- const platformUrl = resolveLoginPlatformUrl(runtime);
426
+ const platformUrl = resolveLoginPlatformUrl();
427
+ const runtime = loadRuntime(platformUrl);
422
428
  const localSecret = runtime?.local_secret ?? process.env.OVERLORD_LOCAL_SECRET ?? '';
423
429
 
424
430
  console.log('Starting Overlord CLI authorization...\n');
@@ -5,11 +5,13 @@
5
5
  import fs from 'node:fs';
6
6
  import os from 'node:os';
7
7
  import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
8
9
 
9
10
  const CREDENTIALS_DIR = path.join(os.homedir(), '.ovld');
10
11
  const CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, 'credentials.json');
11
12
  const RUNTIME_FILE_PATTERN = /^runtime\..+\.json$/;
12
- const DEFAULT_OVERLORD_URL = 'http://localhost:3000';
13
+ const HOSTED_OVERLORD_URL = 'https://www.ovld.ai';
14
+ const LOCAL_DEV_OVERLORD_URL = 'http://localhost:3000';
13
15
  const LOCAL_SECRET_HEADER = 'X-Overlord-Local-Secret';
14
16
 
15
17
  /**
@@ -139,6 +141,14 @@ function isLocalhostUrl(value) {
139
141
  }
140
142
  }
141
143
 
144
+ function isLocalDevOverlordUrl(value) {
145
+ try {
146
+ return new URL(value).origin === LOCAL_DEV_OVERLORD_URL;
147
+ } catch {
148
+ return false;
149
+ }
150
+ }
151
+
142
152
  function isSupportedPlatformUrl(value) {
143
153
  try {
144
154
  const parsed = new URL(value);
@@ -198,37 +208,33 @@ export function buildAuthHeaders(token, localSecret) {
198
208
  return headers;
199
209
  }
200
210
 
211
+ export function getDefaultOverlordUrl() {
212
+ return isLocalDevCli() ? LOCAL_DEV_OVERLORD_URL : HOSTED_OVERLORD_URL;
213
+ }
214
+
215
+ function isLocalDevCli() {
216
+ const sourcePath = fileURLToPath(import.meta.url);
217
+ return !sourcePath.split(path.sep).includes('node_modules');
218
+ }
219
+
201
220
  /**
202
221
  * Resolve the overlord URL and agent token from credentials file or env vars.
203
222
  * @returns {{ platformUrl: string, agentToken: string }}
204
223
  */
205
224
  export function resolveAuth() {
206
225
  const creds = loadCredentials();
207
- const connectorUrlFromEnv = normalizePlatformUrl(process.env.OVERLORD_CONNECTOR_URL);
208
226
  const overlordUrlFromEnv = normalizePlatformUrl(process.env.OVERLORD_URL);
209
- const overlordUrlFromCreds = normalizePlatformUrl(creds?.platform_url);
210
-
211
- const runtimeTarget =
212
- connectorUrlFromEnv || isLocalhostUrl(overlordUrlFromEnv)
213
- ? (connectorUrlFromEnv || overlordUrlFromEnv)
214
- : null;
215
- const targetedRuntime = loadRuntime(runtimeTarget ?? null);
216
- const fallbackRuntime = targetedRuntime ?? loadRuntime(null);
217
- const runtime =
218
- targetedRuntime && isLocalhostUrl(targetedRuntime.platform_url)
219
- ? targetedRuntime
220
- : fallbackRuntime && isLocalhostUrl(fallbackRuntime.platform_url)
221
- ? fallbackRuntime
222
- : targetedRuntime;
227
+ const overlordUrlFromCreds = normalizeStoredPlatformUrl(creds?.platform_url);
228
+
229
+ const runtime = overlordUrlFromEnv && isLocalhostUrl(overlordUrlFromEnv)
230
+ ? loadRuntime(overlordUrlFromEnv)
231
+ : null;
223
232
  const runtimeOverlordUrl = runtime?.platform_url;
224
233
 
225
234
  const platformUrl =
226
- connectorUrlFromEnv ??
227
- (overlordUrlFromEnv && isLocalhostUrl(overlordUrlFromEnv) ? overlordUrlFromEnv : undefined) ??
228
- runtimeOverlordUrl ??
229
235
  overlordUrlFromEnv ??
230
236
  overlordUrlFromCreds ??
231
- DEFAULT_OVERLORD_URL;
237
+ getDefaultOverlordUrl();
232
238
  const localSecret =
233
239
  runtime &&
234
240
  runtime.local_secret &&
@@ -260,8 +266,18 @@ function normalizePlatformUrl(value) {
260
266
  try {
261
267
  const parsed = new URL(trimmed);
262
268
  if (!isSupportedPlatformUrl(parsed.toString())) return undefined;
269
+ if (parsed.protocol === 'https:' && parsed.hostname === 'ovld.ai') {
270
+ return HOSTED_OVERLORD_URL;
271
+ }
263
272
  return parsed.origin;
264
273
  } catch {
265
274
  return undefined;
266
275
  }
267
276
  }
277
+
278
+ function normalizeStoredPlatformUrl(value) {
279
+ const normalized = normalizePlatformUrl(value);
280
+ if (!normalized) return undefined;
281
+ if (isLocalhostUrl(normalized) && !isLocalDevOverlordUrl(normalized)) return undefined;
282
+ return normalized;
283
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overlord-cli",
3
- "version": "3.24.0",
3
+ "version": "3.25.0",
4
4
  "description": "Overlord CLI — launch AI agents on tickets from anywhere",
5
5
  "type": "module",
6
6
  "bin": {