@evident-ai/cli 3.5.1-dev.bf9e537 → 3.5.1
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 +40 -8
- 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
|
|
1161
|
+
var CLI_VERSION = (true ? "3.5.1" : void 0) ?? process.env.npm_package_version ?? "unknown";
|
|
1162
1162
|
function getCliVersion() {
|
|
1163
1163
|
return CLI_VERSION;
|
|
1164
1164
|
}
|
|
@@ -1620,6 +1620,9 @@ async function checkOpenCodeHealth(port) {
|
|
|
1620
1620
|
signal: AbortSignal.timeout(2e3)
|
|
1621
1621
|
// 2 second timeout
|
|
1622
1622
|
});
|
|
1623
|
+
if (response.status === 401) {
|
|
1624
|
+
return { healthy: false, authFailed: true, error: "HTTP 401" };
|
|
1625
|
+
}
|
|
1623
1626
|
if (!response.ok) {
|
|
1624
1627
|
return { healthy: false, error: `HTTP ${response.status}` };
|
|
1625
1628
|
}
|
|
@@ -1684,7 +1687,7 @@ async function waitForOpenCodeHealth(port, timeoutMs = 3e4) {
|
|
|
1684
1687
|
const startTime = Date.now();
|
|
1685
1688
|
while (Date.now() - startTime < timeoutMs) {
|
|
1686
1689
|
const health = await checkOpenCodeHealth(port);
|
|
1687
|
-
if (health.healthy) {
|
|
1690
|
+
if (health.healthy || health.authFailed) {
|
|
1688
1691
|
return health;
|
|
1689
1692
|
}
|
|
1690
1693
|
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
@@ -4311,6 +4314,9 @@ function isSessionDbProvenanceRecord(value) {
|
|
|
4311
4314
|
return typeof record.opencodeVersion === "string" && Array.isArray(record.migrationIds) && record.migrationIds.every((id) => typeof id === "string") && typeof record.updatedAt === "string";
|
|
4312
4315
|
}
|
|
4313
4316
|
|
|
4317
|
+
// src/lib/opencode/opencode2-package.ts
|
|
4318
|
+
var OPENCODE2_PACKAGE_SPEC = "@opencode-ai/cli@0.0.0-beta-17823";
|
|
4319
|
+
|
|
4314
4320
|
// src/lib/opencode/opencode-version-gate.ts
|
|
4315
4321
|
var QUEUE_VALIDATED_OPENCODE_VERSIONS = ["1.17.11", "1.18.3"];
|
|
4316
4322
|
function isQueueValidatedVersion(version2) {
|
|
@@ -4601,7 +4607,8 @@ async function startOpenCode(port, options = {}) {
|
|
|
4601
4607
|
const child = spawn3(command, args, {
|
|
4602
4608
|
detached: true,
|
|
4603
4609
|
stdio: options.inheritStdio ? "inherit" : "ignore",
|
|
4604
|
-
cwd: process.cwd()
|
|
4610
|
+
cwd: process.cwd(),
|
|
4611
|
+
env: { ...process.env, OPENCODE_SERVER_PASSWORD: void 0 }
|
|
4605
4612
|
});
|
|
4606
4613
|
return child;
|
|
4607
4614
|
}
|
|
@@ -4617,7 +4624,7 @@ async function startOpenCode2(port, options = {}) {
|
|
|
4617
4624
|
args = [
|
|
4618
4625
|
"-y",
|
|
4619
4626
|
"-p",
|
|
4620
|
-
|
|
4627
|
+
OPENCODE2_PACKAGE_SPEC,
|
|
4621
4628
|
"--",
|
|
4622
4629
|
"opencode2",
|
|
4623
4630
|
"serve",
|
|
@@ -4694,7 +4701,7 @@ async function promptOpenCodeInstall(interactive) {
|
|
|
4694
4701
|
npm: "npm install -g opencode-ai",
|
|
4695
4702
|
curl: "curl -fsSL https://opencode.ai/install.sh | sh",
|
|
4696
4703
|
v2: {
|
|
4697
|
-
npm:
|
|
4704
|
+
npm: `npm install -g ${OPENCODE2_PACKAGE_SPEC}`,
|
|
4698
4705
|
curl: "curl -fsSL https://opencode.ai/v2/install | bash"
|
|
4699
4706
|
}
|
|
4700
4707
|
}
|
|
@@ -11279,8 +11286,16 @@ function checkNonInteractivePortConflict(port, isPortInUseFn) {
|
|
|
11279
11286
|
);
|
|
11280
11287
|
}
|
|
11281
11288
|
}
|
|
11289
|
+
function unknownPasswordError(port) {
|
|
11290
|
+
return new Error(
|
|
11291
|
+
`OpenCode is already running on port ${port}, but this runner cannot authenticate to it. It may have been started with OPENCODE_SERVER_PASSWORD set in its environment. Free the port or pass --port.`
|
|
11292
|
+
);
|
|
11293
|
+
}
|
|
11282
11294
|
async function ensureOpenCodeRunning(ctx) {
|
|
11283
11295
|
const healthCheck = await checkOpenCodeHealth(ctx.port);
|
|
11296
|
+
if (healthCheck.authFailed) {
|
|
11297
|
+
throw unknownPasswordError(ctx.port);
|
|
11298
|
+
}
|
|
11284
11299
|
if (healthCheck.healthy) {
|
|
11285
11300
|
return {
|
|
11286
11301
|
port: ctx.port,
|
|
@@ -11331,6 +11346,14 @@ async function ensureOpenCodeRunning(ctx) {
|
|
|
11331
11346
|
const proc = await startOpenCode(ctx.port, { inheritStdio: ctx.inheritStdio });
|
|
11332
11347
|
const health = await waitForOpenCodeHealth(ctx.port, ctx.startTimeoutMs);
|
|
11333
11348
|
if (!health.healthy) {
|
|
11349
|
+
if (health.authFailed) {
|
|
11350
|
+
return {
|
|
11351
|
+
port: ctx.port,
|
|
11352
|
+
process: proc,
|
|
11353
|
+
version: null,
|
|
11354
|
+
notReadyReason: "it is answering with an authentication challenge, likely because OPENCODE_SERVER_PASSWORD is set in the environment of the process that started it; a longer start timeout will not resolve this"
|
|
11355
|
+
};
|
|
11356
|
+
}
|
|
11334
11357
|
return {
|
|
11335
11358
|
port: ctx.port,
|
|
11336
11359
|
process: proc,
|
|
@@ -11400,6 +11423,9 @@ Port ${port} is already in use.`));
|
|
|
11400
11423
|
const health = await waitForOpenCodeHealth(port, INTERACTIVE_START_TIMEOUT_MS);
|
|
11401
11424
|
if (!health.healthy) {
|
|
11402
11425
|
spinner.fail("Failed to start OpenCode");
|
|
11426
|
+
if (health.authFailed) {
|
|
11427
|
+
throw unknownPasswordError(port);
|
|
11428
|
+
}
|
|
11403
11429
|
throw new Error("OpenCode failed to start");
|
|
11404
11430
|
}
|
|
11405
11431
|
spinner.stop();
|
|
@@ -11412,7 +11438,7 @@ Port ${port} is already in use.`));
|
|
|
11412
11438
|
import chalk6 from "chalk";
|
|
11413
11439
|
import ora3 from "ora";
|
|
11414
11440
|
import { select as select3 } from "@inquirer/prompts";
|
|
11415
|
-
function
|
|
11441
|
+
function unknownPasswordError2(port) {
|
|
11416
11442
|
return new Error(
|
|
11417
11443
|
`OpenCode V2 (opencode2) is already running on port ${port} with a password this runner doesn't know. Free the port or pass --port.`
|
|
11418
11444
|
);
|
|
@@ -11421,7 +11447,7 @@ var INTERACTIVE_START_TIMEOUT_MS2 = 3e4;
|
|
|
11421
11447
|
async function ensureOpenCode2Running(ctx) {
|
|
11422
11448
|
const initialHealth = await checkOpenCode2Health(ctx.port);
|
|
11423
11449
|
if (initialHealth.authFailed) {
|
|
11424
|
-
throw
|
|
11450
|
+
throw unknownPasswordError2(ctx.port);
|
|
11425
11451
|
}
|
|
11426
11452
|
if (initialHealth.healthy) {
|
|
11427
11453
|
return {
|
|
@@ -11434,7 +11460,7 @@ async function ensureOpenCode2Running(ctx) {
|
|
|
11434
11460
|
}
|
|
11435
11461
|
if (!isOpenCode2Installed()) {
|
|
11436
11462
|
throw new Error(
|
|
11437
|
-
|
|
11463
|
+
`OpenCode V2 (opencode2) is not installed. Install it with: npm install -g ${OPENCODE2_PACKAGE_SPEC}`
|
|
11438
11464
|
);
|
|
11439
11465
|
}
|
|
11440
11466
|
let port = ctx.port;
|
|
@@ -13368,6 +13394,12 @@ async function run(options) {
|
|
|
13368
13394
|
"Skipping session-DB restore: OpenCode is already serving this database",
|
|
13369
13395
|
"debug"
|
|
13370
13396
|
);
|
|
13397
|
+
} else if (health.authFailed) {
|
|
13398
|
+
log2(
|
|
13399
|
+
state,
|
|
13400
|
+
"Skipping session-DB restore: OpenCode answered with an authentication challenge; assuming this database is in use",
|
|
13401
|
+
"debug"
|
|
13402
|
+
);
|
|
13371
13403
|
} else {
|
|
13372
13404
|
const result = await restoreAndVerifySessionDb({
|
|
13373
13405
|
dbPath: sessionDbPath(),
|