@evident-ai/cli 3.5.1-dev.4a593b3 → 3.5.1-dev.7db3e09
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/index.js +37 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1158,7 +1158,7 @@ import ora4 from "ora";
|
|
|
1158
1158
|
import { select as select4 } from "@inquirer/prompts";
|
|
1159
1159
|
|
|
1160
1160
|
// src/lib/telemetry.ts
|
|
1161
|
-
var CLI_VERSION = (true ? "3.5.1-dev.
|
|
1161
|
+
var CLI_VERSION = (true ? "3.5.1-dev.7db3e09" : void 0) ?? process.env.npm_package_version ?? "unknown";
|
|
1162
1162
|
function getCliVersion() {
|
|
1163
1163
|
return CLI_VERSION;
|
|
1164
1164
|
}
|
|
@@ -1630,12 +1630,18 @@ async function checkOpenCodeHealth(port) {
|
|
|
1630
1630
|
return { healthy: false, error: message };
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
1633
|
+
function bodyExcerpt(body) {
|
|
1634
|
+
const excerpt = body.replace(/\s+/g, " ").trim().slice(0, 160);
|
|
1635
|
+
return excerpt ? ` (body="${excerpt}")` : " (empty body)";
|
|
1636
|
+
}
|
|
1633
1637
|
async function checkOpenCode2Health(port, password) {
|
|
1634
1638
|
try {
|
|
1635
|
-
const
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
+
const headers = {};
|
|
1640
|
+
if (password !== void 0) {
|
|
1641
|
+
headers.Authorization = buildOpenCodeBasicAuthHeader(password);
|
|
1642
|
+
}
|
|
1643
|
+
const response = await fetch(`http://127.0.0.1:${port}/api/health`, {
|
|
1644
|
+
headers,
|
|
1639
1645
|
signal: AbortSignal.timeout(2e3)
|
|
1640
1646
|
});
|
|
1641
1647
|
if (response.status === 401) {
|
|
@@ -1644,8 +1650,31 @@ async function checkOpenCode2Health(port, password) {
|
|
|
1644
1650
|
if (!response.ok) {
|
|
1645
1651
|
return { healthy: false, error: `HTTP ${response.status}` };
|
|
1646
1652
|
}
|
|
1647
|
-
const
|
|
1648
|
-
|
|
1653
|
+
const body = await response.text();
|
|
1654
|
+
const excerpt = bodyExcerpt(body);
|
|
1655
|
+
let data;
|
|
1656
|
+
try {
|
|
1657
|
+
data = JSON.parse(body);
|
|
1658
|
+
} catch (error2) {
|
|
1659
|
+
return {
|
|
1660
|
+
healthy: false,
|
|
1661
|
+
error: `Invalid JSON health response${excerpt}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
1665
|
+
return {
|
|
1666
|
+
healthy: false,
|
|
1667
|
+
error: `Invalid health response${excerpt}: expected healthy=true`
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
const health = data;
|
|
1671
|
+
if (health.healthy !== true) {
|
|
1672
|
+
return {
|
|
1673
|
+
healthy: false,
|
|
1674
|
+
error: `Invalid health response${excerpt}: expected healthy=true`
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
return typeof health.version === "string" ? { healthy: true, version: health.version } : { healthy: true };
|
|
1649
1678
|
} catch (error2) {
|
|
1650
1679
|
const message = error2 instanceof Error ? error2.message : "Unknown error";
|
|
1651
1680
|
return { healthy: false, error: message };
|
|
@@ -11383,25 +11412,6 @@ Port ${port} is already in use.`));
|
|
|
11383
11412
|
import chalk6 from "chalk";
|
|
11384
11413
|
import ora3 from "ora";
|
|
11385
11414
|
import { select as select3 } from "@inquirer/prompts";
|
|
11386
|
-
async function probeOpenCode2WithoutPassword(port) {
|
|
11387
|
-
try {
|
|
11388
|
-
const response = await fetch(`http://127.0.0.1:${port}/global/health`, {
|
|
11389
|
-
signal: AbortSignal.timeout(2e3)
|
|
11390
|
-
});
|
|
11391
|
-
if (response.status === 401) {
|
|
11392
|
-
return { healthy: false, authFailed: true, error: "HTTP 401" };
|
|
11393
|
-
}
|
|
11394
|
-
if (!response.ok) {
|
|
11395
|
-
return { healthy: false, error: `HTTP ${response.status}` };
|
|
11396
|
-
}
|
|
11397
|
-
return { healthy: true };
|
|
11398
|
-
} catch (error2) {
|
|
11399
|
-
return {
|
|
11400
|
-
healthy: false,
|
|
11401
|
-
error: error2 instanceof Error ? error2.message : "Unknown error"
|
|
11402
|
-
};
|
|
11403
|
-
}
|
|
11404
|
-
}
|
|
11405
11415
|
function unknownPasswordError(port) {
|
|
11406
11416
|
return new Error(
|
|
11407
11417
|
`OpenCode V2 (opencode2) is already running on port ${port} with a password this runner doesn't know. Free the port or pass --port.`
|
|
@@ -11409,7 +11419,7 @@ function unknownPasswordError(port) {
|
|
|
11409
11419
|
}
|
|
11410
11420
|
var INTERACTIVE_START_TIMEOUT_MS2 = 3e4;
|
|
11411
11421
|
async function ensureOpenCode2Running(ctx) {
|
|
11412
|
-
const initialHealth = await
|
|
11422
|
+
const initialHealth = await checkOpenCode2Health(ctx.port);
|
|
11413
11423
|
if (initialHealth.authFailed) {
|
|
11414
11424
|
throw unknownPasswordError(ctx.port);
|
|
11415
11425
|
}
|