@evident-ai/cli 3.4.1-dev.ecb0236 → 3.4.1-dev.ee4e02f
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 +100 -76
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,8 +11,8 @@ import chalk2 from "chalk";
|
|
|
11
11
|
|
|
12
12
|
// src/lib/config.ts
|
|
13
13
|
import Conf from "conf";
|
|
14
|
-
import { chmodSync, existsSync, statSync } from "fs";
|
|
15
|
-
import { dirname } from "path";
|
|
14
|
+
import { chmodSync, existsSync, statSync } from "node:fs";
|
|
15
|
+
import { dirname } from "node:path";
|
|
16
16
|
var PRODUCTION_API_URL = "https://api.production.evident.run/v1";
|
|
17
17
|
var PRODUCTION_TUNNEL_URL = "wss://tunnel.production.evident.run";
|
|
18
18
|
var defaults = {
|
|
@@ -1009,10 +1009,10 @@ async function status(options = {}) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
|
|
1011
1011
|
// src/lib/claude-usage.ts
|
|
1012
|
-
import { execFileSync } from "child_process";
|
|
1013
|
-
import { readFileSync } from "fs";
|
|
1014
|
-
import { homedir } from "os";
|
|
1015
|
-
import { join } from "path";
|
|
1012
|
+
import { execFileSync } from "node:child_process";
|
|
1013
|
+
import { readFileSync } from "node:fs";
|
|
1014
|
+
import { homedir } from "node:os";
|
|
1015
|
+
import { join } from "node:path";
|
|
1016
1016
|
var CLAUDE_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
1017
1017
|
var CLAUDE_PROFILE_URL = "https://api.anthropic.com/api/oauth/profile";
|
|
1018
1018
|
var CLAUDE_PROFILE_TIMEOUT_MS = 2e3;
|
|
@@ -1192,9 +1192,9 @@ async function claudeUsage() {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
|
|
1194
1194
|
// src/commands/run.ts
|
|
1195
|
-
import { chmodSync as chmodSync3, existsSync as existsSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
|
|
1196
|
-
import { homedir as homedir5 } from "os";
|
|
1197
|
-
import { isAbsolute as isAbsolute3, join as join9, parse, resolve as resolvePath2 } from "path";
|
|
1195
|
+
import { chmodSync as chmodSync3, existsSync as existsSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
1196
|
+
import { homedir as homedir5 } from "node:os";
|
|
1197
|
+
import { isAbsolute as isAbsolute3, join as join9, parse, resolve as resolvePath2 } from "node:path";
|
|
1198
1198
|
import chalk6 from "chalk";
|
|
1199
1199
|
|
|
1200
1200
|
// ../../packages/types/src/agents/index.ts
|
|
@@ -1505,8 +1505,8 @@ function forwardRunnerActivity(entry, context) {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
|
|
1507
1507
|
// src/lib/opencode/session-db-recovery-report.ts
|
|
1508
|
-
import { readFileSync as readFileSync2, unlinkSync } from "fs";
|
|
1509
|
-
import { join as join2 } from "path";
|
|
1508
|
+
import { readFileSync as readFileSync2, unlinkSync } from "node:fs";
|
|
1509
|
+
import { join as join2 } from "node:path";
|
|
1510
1510
|
function sessionDbRecoveryReportPath(homeDir, env) {
|
|
1511
1511
|
const override = env.EVIDENT_SESSION_DB_RECOVERY_REPORT?.trim();
|
|
1512
1512
|
return override || join2(homeDir, ".local", "state", "evident", "session-db-recovery.jsonl");
|
|
@@ -1719,13 +1719,13 @@ async function waitForOpenCodeHealth(port, timeoutMs = 3e4) {
|
|
|
1719
1719
|
}
|
|
1720
1720
|
|
|
1721
1721
|
// src/lib/opencode/session-db-boot.ts
|
|
1722
|
-
import { spawn as spawn2 } from "child_process";
|
|
1723
|
-
import { mkdirSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync } from "fs";
|
|
1724
|
-
import { homedir as homedir2 } from "os";
|
|
1725
|
-
import { dirname as dirname2, resolve as resolvePath } from "path";
|
|
1722
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
1723
|
+
import { mkdirSync, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync } from "node:fs";
|
|
1724
|
+
import { homedir as homedir2 } from "node:os";
|
|
1725
|
+
import { dirname as dirname2, resolve as resolvePath } from "node:path";
|
|
1726
1726
|
|
|
1727
1727
|
// src/lib/runner-synchroniser.ts
|
|
1728
|
-
import { spawn } from "child_process";
|
|
1728
|
+
import { spawn } from "node:child_process";
|
|
1729
1729
|
function appendError(stderr, error2) {
|
|
1730
1730
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
1731
1731
|
return stderr === "" ? message : `${stderr}
|
|
@@ -2250,9 +2250,9 @@ async function restoreAndVerifySessionDb(options) {
|
|
|
2250
2250
|
}
|
|
2251
2251
|
|
|
2252
2252
|
// src/lib/opencode/session-db-provenance.ts
|
|
2253
|
-
import { createRequire } from "module";
|
|
2254
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
2255
|
-
import { dirname as dirname3, join as join3 } from "path";
|
|
2253
|
+
import { createRequire } from "node:module";
|
|
2254
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2255
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
2256
2256
|
var require2 = createRequire(import.meta.url);
|
|
2257
2257
|
function readSessionDbMigrationIds(dbPath) {
|
|
2258
2258
|
let db;
|
|
@@ -3522,8 +3522,8 @@ function resolveSessionCleanupConfig(flags, env = process.env) {
|
|
|
3522
3522
|
}
|
|
3523
3523
|
|
|
3524
3524
|
// src/lib/opencode/session-db-size.ts
|
|
3525
|
-
import { statSync as statSync3 } from "fs";
|
|
3526
|
-
import { join as join4 } from "path";
|
|
3525
|
+
import { statSync as statSync3 } from "node:fs";
|
|
3526
|
+
import { join as join4 } from "node:path";
|
|
3527
3527
|
var LARGE_DB_THRESHOLD_BYTES = 268435456;
|
|
3528
3528
|
function statSessionDbBytes(homeDir) {
|
|
3529
3529
|
const dbPath = join4(homeDir, ".local", "share", "opencode", "opencode.db");
|
|
@@ -3554,8 +3554,12 @@ function buildSessionStoreSizeWarning(input) {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
|
|
3556
3556
|
// src/lib/opencode/session-db-reclaim.ts
|
|
3557
|
-
import { statSync as statSync4, statfsSync } from "fs";
|
|
3558
|
-
import { dirname as dirname4 } from "path";
|
|
3557
|
+
import { statSync as statSync4, statfsSync } from "node:fs";
|
|
3558
|
+
import { dirname as dirname4 } from "node:path";
|
|
3559
|
+
function errorMessage(error2) {
|
|
3560
|
+
if (!(error2 instanceof Error)) return String(error2);
|
|
3561
|
+
return error2.cause instanceof Error ? error2.cause.message : error2.message;
|
|
3562
|
+
}
|
|
3559
3563
|
function insufficientSpaceReason(dbPath, requiredBytes) {
|
|
3560
3564
|
try {
|
|
3561
3565
|
const fsStats = statfsSync(dirname4(dbPath));
|
|
@@ -3581,17 +3585,17 @@ async function probeReclaimAvailability(input) {
|
|
|
3581
3585
|
const { dbPath, requiredBytes } = input;
|
|
3582
3586
|
let sqlite;
|
|
3583
3587
|
try {
|
|
3584
|
-
sqlite = await import("sqlite");
|
|
3588
|
+
sqlite = await import("node:sqlite");
|
|
3585
3589
|
} catch (err) {
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
return "sqlite-unavailable";
|
|
3590
|
+
const detail = `Node ${process.version}: ${errorMessage(err)}`;
|
|
3591
|
+
console.warn(`[probeReclaimAvailability] node:sqlite unavailable for ${dbPath}: ` + detail);
|
|
3592
|
+
return { reason: "sqlite-unavailable", detail };
|
|
3590
3593
|
}
|
|
3591
3594
|
let autoVacuum = null;
|
|
3592
3595
|
try {
|
|
3593
3596
|
const db = new sqlite.DatabaseSync(dbPath, { readOnly: true });
|
|
3594
3597
|
try {
|
|
3598
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
3595
3599
|
autoVacuum = db.prepare("PRAGMA auto_vacuum").get().auto_vacuum;
|
|
3596
3600
|
} finally {
|
|
3597
3601
|
db.close();
|
|
@@ -3602,23 +3606,25 @@ async function probeReclaimAvailability(input) {
|
|
|
3602
3606
|
);
|
|
3603
3607
|
}
|
|
3604
3608
|
if (autoVacuum !== 0) return null;
|
|
3605
|
-
return insufficientSpaceReason(dbPath, requiredBytes) !== null ? "insufficient-disk-space" : null;
|
|
3609
|
+
return insufficientSpaceReason(dbPath, requiredBytes) !== null ? { reason: "insufficient-disk-space" } : null;
|
|
3606
3610
|
}
|
|
3607
3611
|
async function reclaimSessionDbSpace(input) {
|
|
3608
3612
|
const { dbPath, maxPages, allowFullVacuum = true } = input;
|
|
3609
3613
|
let sqlite;
|
|
3610
3614
|
try {
|
|
3611
|
-
sqlite = await import("sqlite");
|
|
3615
|
+
sqlite = await import("node:sqlite");
|
|
3612
3616
|
} catch (err) {
|
|
3617
|
+
const detail = `Node ${process.version}: ${errorMessage(err)}`;
|
|
3613
3618
|
console.warn(
|
|
3614
|
-
`[reclaimSessionDbSpace] node:sqlite unavailable (need Node >=22.5, >=22.13 unflagged) for ${dbPath}: ${
|
|
3619
|
+
`[reclaimSessionDbSpace] node:sqlite unavailable (need Node >=22.5, >=22.13 unflagged) for ${dbPath}: ${detail}`
|
|
3615
3620
|
);
|
|
3616
|
-
return { ok: false, skipped: "sqlite-unavailable" };
|
|
3621
|
+
return { ok: false, skipped: "sqlite-unavailable", detail };
|
|
3617
3622
|
}
|
|
3618
3623
|
const { DatabaseSync } = sqlite;
|
|
3619
3624
|
let db;
|
|
3620
3625
|
try {
|
|
3621
3626
|
db = new DatabaseSync(dbPath);
|
|
3627
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
3622
3628
|
const autoVacuum = db.prepare("PRAGMA auto_vacuum").get().auto_vacuum;
|
|
3623
3629
|
if (autoVacuum === 0) {
|
|
3624
3630
|
if (!allowFullVacuum) {
|
|
@@ -3655,10 +3661,12 @@ async function reclaimSessionDbSpace(input) {
|
|
|
3655
3661
|
);
|
|
3656
3662
|
return { ok: false, skipped: "auto-vacuum-not-applicable" };
|
|
3657
3663
|
} catch (err) {
|
|
3658
|
-
console.error(
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3664
|
+
console.error(`[reclaimSessionDbSpace] reclaim failed for ${dbPath}: ` + errorMessage(err));
|
|
3665
|
+
return {
|
|
3666
|
+
ok: false,
|
|
3667
|
+
skipped: "reclaim-error",
|
|
3668
|
+
detail: errorMessage(err)
|
|
3669
|
+
};
|
|
3662
3670
|
} finally {
|
|
3663
3671
|
db?.close();
|
|
3664
3672
|
}
|
|
@@ -3950,8 +3958,8 @@ function connectTunnel(options) {
|
|
|
3950
3958
|
try {
|
|
3951
3959
|
message = JSON.parse(data.toString());
|
|
3952
3960
|
} catch (error2) {
|
|
3953
|
-
const
|
|
3954
|
-
onError?.(`Failed to handle message: ${
|
|
3961
|
+
const errorMessage3 = error2 instanceof Error ? error2.message : "Unknown error";
|
|
3962
|
+
onError?.(`Failed to handle message: ${errorMessage3}`);
|
|
3955
3963
|
return;
|
|
3956
3964
|
}
|
|
3957
3965
|
if (isStreamFrame(message)) {
|
|
@@ -4095,7 +4103,7 @@ var RunnerConnection = class {
|
|
|
4095
4103
|
};
|
|
4096
4104
|
|
|
4097
4105
|
// src/lib/tunnel/ready-marker.ts
|
|
4098
|
-
import { writeFileSync as writeFileSync3 } from "fs";
|
|
4106
|
+
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
4099
4107
|
function writeTunnelReadyMarker(path, agentId) {
|
|
4100
4108
|
try {
|
|
4101
4109
|
writeFileSync3(path, `${agentId}
|
|
@@ -4107,7 +4115,7 @@ function writeTunnelReadyMarker(path, agentId) {
|
|
|
4107
4115
|
}
|
|
4108
4116
|
|
|
4109
4117
|
// src/lib/replication.ts
|
|
4110
|
-
import { spawn as spawn4 } from "child_process";
|
|
4118
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
4111
4119
|
function startSessionDbReplication(configPath) {
|
|
4112
4120
|
return spawn4("litestream", ["replicate", "-config", configPath], {
|
|
4113
4121
|
stdio: "inherit"
|
|
@@ -4123,7 +4131,7 @@ async function stopSessionDbReplication(child, timeoutMs) {
|
|
|
4123
4131
|
}
|
|
4124
4132
|
|
|
4125
4133
|
// src/lib/process-liveness.ts
|
|
4126
|
-
import { readFileSync as readFileSync4 } from "fs";
|
|
4134
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
4127
4135
|
function isProcessAlive(pid) {
|
|
4128
4136
|
try {
|
|
4129
4137
|
process.kill(pid, 0);
|
|
@@ -4149,9 +4157,9 @@ function isProcessAlive(pid) {
|
|
|
4149
4157
|
}
|
|
4150
4158
|
|
|
4151
4159
|
// src/lib/openai-usage.ts
|
|
4152
|
-
import { readFileSync as readFileSync5 } from "fs";
|
|
4153
|
-
import { homedir as homedir3 } from "os";
|
|
4154
|
-
import { join as join5 } from "path";
|
|
4160
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
4161
|
+
import { homedir as homedir3 } from "node:os";
|
|
4162
|
+
import { join as join5 } from "node:path";
|
|
4155
4163
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
4156
4164
|
var OPENCODE_AUTH_SEGMENTS = [".local", "share", "opencode", "auth.json"];
|
|
4157
4165
|
var OpenAiUsageError = class extends Error {
|
|
@@ -4427,8 +4435,8 @@ function resolveResourceUsageReportingEnabled(flagValue, env) {
|
|
|
4427
4435
|
}
|
|
4428
4436
|
|
|
4429
4437
|
// src/lib/resource-usage.ts
|
|
4430
|
-
import { cpus, totalmem, freemem } from "os";
|
|
4431
|
-
import { statfsSync as statfsSync2 } from "fs";
|
|
4438
|
+
import { cpus, totalmem, freemem } from "node:os";
|
|
4439
|
+
import { statfsSync as statfsSync2 } from "node:fs";
|
|
4432
4440
|
|
|
4433
4441
|
// src/lib/ecs-task-metadata.ts
|
|
4434
4442
|
var ECS_METADATA_TIMEOUT_MS = 2e3;
|
|
@@ -4595,15 +4603,15 @@ function createResourceUsageCollector(homeDir) {
|
|
|
4595
4603
|
}
|
|
4596
4604
|
|
|
4597
4605
|
// src/lib/channels/driver.ts
|
|
4598
|
-
import { homedir as homedir4 } from "os";
|
|
4606
|
+
import { homedir as homedir4 } from "node:os";
|
|
4599
4607
|
|
|
4600
4608
|
// src/lib/runner-file-sync.ts
|
|
4601
|
-
import { join as join7 } from "path";
|
|
4609
|
+
import { join as join7 } from "node:path";
|
|
4602
4610
|
|
|
4603
4611
|
// src/lib/file-push.ts
|
|
4604
|
-
import { randomUUID } from "crypto";
|
|
4605
|
-
import { chmod, mkdir, open as open2, realpath, rename, unlink } from "fs/promises";
|
|
4606
|
-
import { basename, dirname as dirname5, isAbsolute, join as join6, relative, resolve as resolve2, sep } from "path";
|
|
4612
|
+
import { randomUUID } from "node:crypto";
|
|
4613
|
+
import { chmod, mkdir, open as open2, realpath, rename, unlink } from "node:fs/promises";
|
|
4614
|
+
import { basename, dirname as dirname5, isAbsolute, join as join6, relative, resolve as resolve2, sep } from "node:path";
|
|
4607
4615
|
var FILE_MODE = 384;
|
|
4608
4616
|
var DIRECTORY_MODE = 448;
|
|
4609
4617
|
async function writePushedFile(request) {
|
|
@@ -5795,7 +5803,7 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
5795
5803
|
this.signalDispatchNotStarted(conv, message, "session_existence_unknown");
|
|
5796
5804
|
break;
|
|
5797
5805
|
}
|
|
5798
|
-
const
|
|
5806
|
+
const errorMessage3 = err instanceof Error ? err.message : String(err);
|
|
5799
5807
|
this.sessions.delete(conv.id);
|
|
5800
5808
|
this.supersede(conv.id, sessionId);
|
|
5801
5809
|
this.log({
|
|
@@ -5804,7 +5812,7 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
5804
5812
|
conversation_id: conv.id,
|
|
5805
5813
|
message_id: message.id
|
|
5806
5814
|
});
|
|
5807
|
-
await this.markFailed(conv.id, message.id, null,
|
|
5815
|
+
await this.markFailed(conv.id, message.id, null, errorMessage3).catch((markErr) => {
|
|
5808
5816
|
this.log({
|
|
5809
5817
|
level: "warn",
|
|
5810
5818
|
message: `markFailed PATCH for message ${message.id.slice(0, 8)} (conversation ${conv.id.slice(0, 8)}) failed (best-effort, not retried): ${markErr instanceof Error ? markErr.message : String(markErr)}`,
|
|
@@ -5815,7 +5823,7 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
5815
5823
|
});
|
|
5816
5824
|
this.log({
|
|
5817
5825
|
level: "error",
|
|
5818
|
-
message: `Message ${message.id.slice(0, 8)} dispatch failed: ${
|
|
5826
|
+
message: `Message ${message.id.slice(0, 8)} dispatch failed: ${errorMessage3}`,
|
|
5819
5827
|
conversation_id: conv.id,
|
|
5820
5828
|
message_id: message.id
|
|
5821
5829
|
});
|
|
@@ -5836,14 +5844,14 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
5836
5844
|
this.unconfirmedDispatchFailures.delete(message.id);
|
|
5837
5845
|
this.sessions.delete(conv.id);
|
|
5838
5846
|
this.supersede(conv.id, sessionId);
|
|
5839
|
-
const
|
|
5847
|
+
const errorMessage3 = `OpenCode accepted this message ${streak} times in a row but never confirmed its assigned id (session ${sessionId.slice(0, 8)}'s message list could not be read back) \u2014 the session was abandoned; a fresh one is used for further messages.`;
|
|
5840
5848
|
this.log({
|
|
5841
5849
|
level: "error",
|
|
5842
|
-
message:
|
|
5850
|
+
message: errorMessage3,
|
|
5843
5851
|
conversation_id: conv.id,
|
|
5844
5852
|
message_id: message.id
|
|
5845
5853
|
});
|
|
5846
|
-
await this.markFailed(conv.id, message.id, null,
|
|
5854
|
+
await this.markFailed(conv.id, message.id, null, errorMessage3).catch((markErr) => {
|
|
5847
5855
|
this.log({
|
|
5848
5856
|
level: "warn",
|
|
5849
5857
|
message: `markFailed PATCH for message ${message.id.slice(0, 8)} (conversation ${conv.id.slice(0, 8)}) failed (best-effort, not retried): ${markErr instanceof Error ? markErr.message : String(markErr)}`,
|
|
@@ -7826,14 +7834,14 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
7826
7834
|
this.unconfirmedDispatchFailures.delete(row.id);
|
|
7827
7835
|
this.sessions.delete(readoptConv.id);
|
|
7828
7836
|
this.supersede(readoptConv.id, sessionId);
|
|
7829
|
-
const
|
|
7837
|
+
const errorMessage3 = `OpenCode accepted this re-dispatched message ${streak} times in a row but never confirmed its assigned id (session ${sessionId.slice(0, 8)}'s message list could not be read back) \u2014 the session was abandoned; a fresh one is used for further messages.`;
|
|
7830
7838
|
this.log({
|
|
7831
7839
|
level: "error",
|
|
7832
|
-
message:
|
|
7840
|
+
message: errorMessage3,
|
|
7833
7841
|
conversation_id: row.conversation_id,
|
|
7834
7842
|
message_id: row.id
|
|
7835
7843
|
});
|
|
7836
|
-
await this.markFailed(row.conversation_id, row.id, null,
|
|
7844
|
+
await this.markFailed(row.conversation_id, row.id, null, errorMessage3).catch((markErr) => {
|
|
7837
7845
|
this.log({
|
|
7838
7846
|
level: "warn",
|
|
7839
7847
|
message: `markFailed PATCH for message ${row.id.slice(0, 8)} (conversation ${row.conversation_id.slice(0, 8)}) failed (best-effort, not retried): ${markErr instanceof Error ? markErr.message : String(markErr)}`,
|
|
@@ -9071,8 +9079,8 @@ Port ${port} is already in use.`));
|
|
|
9071
9079
|
}
|
|
9072
9080
|
|
|
9073
9081
|
// src/lib/runner-credentials.ts
|
|
9074
|
-
import { chmodSync as chmodSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
9075
|
-
import { spawn as spawn5 } from "child_process";
|
|
9082
|
+
import { chmodSync as chmodSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
9083
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
9076
9084
|
var RUNNER_SECRET_FETCH_TIMEOUT_MS = 6e4;
|
|
9077
9085
|
var CREDENTIAL_RESTORE_TIMEOUT_MS = 6e4;
|
|
9078
9086
|
var GITHUB_PROBE_TIMEOUT_MS = 1e4;
|
|
@@ -9344,9 +9352,9 @@ async function configureGitHubAccess({ env, log: log3 }) {
|
|
|
9344
9352
|
}
|
|
9345
9353
|
|
|
9346
9354
|
// src/lib/opencode/config-overlay.ts
|
|
9347
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
9348
|
-
import { copyFileSync, existsSync as existsSync2, statSync as statSync5 } from "fs";
|
|
9349
|
-
import { isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "path";
|
|
9355
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
9356
|
+
import { copyFileSync, existsSync as existsSync2, statSync as statSync5 } from "node:fs";
|
|
9357
|
+
import { isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "node:path";
|
|
9350
9358
|
function isFile(filePath) {
|
|
9351
9359
|
return existsSync2(filePath) && statSync5(filePath).isFile();
|
|
9352
9360
|
}
|
|
@@ -9381,7 +9389,7 @@ function applyRunnerOpenCodeConfig({
|
|
|
9381
9389
|
}
|
|
9382
9390
|
|
|
9383
9391
|
// src/lib/credential-sync.ts
|
|
9384
|
-
import { renameSync, writeFileSync as writeFileSync5 } from "fs";
|
|
9392
|
+
import { renameSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
9385
9393
|
var CREDENTIAL_SYNC_TICK_TIMEOUT_MS = 3e4;
|
|
9386
9394
|
var CREDENTIAL_FLUSH_DEADLINE_MS = 8e3;
|
|
9387
9395
|
var CREDENTIAL_FLUSH_ABORT_GRACE_MS = 500;
|
|
@@ -9391,7 +9399,7 @@ var MAX_FLUSH_PASSES = 2;
|
|
|
9391
9399
|
function outcomesWith(outcome) {
|
|
9392
9400
|
return { claude: outcome, opencode: outcome };
|
|
9393
9401
|
}
|
|
9394
|
-
function
|
|
9402
|
+
function errorMessage2(error2) {
|
|
9395
9403
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
9396
9404
|
}
|
|
9397
9405
|
function waitForSettlement(promise, timeoutMs) {
|
|
@@ -9418,7 +9426,7 @@ function writeMarker(markerPath, outcomes, log3) {
|
|
|
9418
9426
|
writeFileSync5(temporaryPath, body, { mode: 384 });
|
|
9419
9427
|
renameSync(temporaryPath, markerPath);
|
|
9420
9428
|
} catch (error2) {
|
|
9421
|
-
log3(`CREDENTIAL-FLUSH-MARKER-UNWRITABLE: ${markerPath}: ${
|
|
9429
|
+
log3(`CREDENTIAL-FLUSH-MARKER-UNWRITABLE: ${markerPath}: ${errorMessage2(error2)}`, "warn");
|
|
9422
9430
|
}
|
|
9423
9431
|
}
|
|
9424
9432
|
function intervalSeconds(env, log3) {
|
|
@@ -9450,7 +9458,7 @@ async function runFlushStore(store, env, synchroniserRunner, log3, deadlineAt) {
|
|
|
9450
9458
|
},
|
|
9451
9459
|
(error2) => {
|
|
9452
9460
|
failed = true;
|
|
9453
|
-
log3(`CREDENTIAL-FLUSH-ERROR: ${store}: ${
|
|
9461
|
+
log3(`CREDENTIAL-FLUSH-ERROR: ${store}: ${errorMessage2(error2)}`, "warn");
|
|
9454
9462
|
}
|
|
9455
9463
|
);
|
|
9456
9464
|
const abortTimer = setTimeout(() => controller.abort(), remainingMs);
|
|
@@ -9510,7 +9518,7 @@ function createCredentialSync({
|
|
|
9510
9518
|
outcomes[store] = !result.timedOut && result.code === 0 ? "ok" : "failed";
|
|
9511
9519
|
} catch (error2) {
|
|
9512
9520
|
outcomes[store] = "failed";
|
|
9513
|
-
log3(`CREDENTIAL-SYNC-TICK-ERROR: ${store}: ${
|
|
9521
|
+
log3(`CREDENTIAL-SYNC-TICK-ERROR: ${store}: ${errorMessage2(error2)}`, "debug");
|
|
9514
9522
|
}
|
|
9515
9523
|
}
|
|
9516
9524
|
const failed = STORES.some((store) => outcomes[store] === "failed");
|
|
@@ -9958,8 +9966,8 @@ async function driveChannels(state, driver) {
|
|
|
9958
9966
|
state.running = false;
|
|
9959
9967
|
break;
|
|
9960
9968
|
}
|
|
9961
|
-
const
|
|
9962
|
-
logActivity(state, { type: "error", error: `Channel processing error: ${
|
|
9969
|
+
const errorMessage3 = error2 instanceof Error ? error2.message : String(error2);
|
|
9970
|
+
logActivity(state, { type: "error", error: `Channel processing error: ${errorMessage3}` });
|
|
9963
9971
|
if (state.interactive) displayStatus(state);
|
|
9964
9972
|
if (driver.hasInFlightWatchers()) {
|
|
9965
9973
|
consecutiveDrainFailures = 0;
|
|
@@ -9997,7 +10005,16 @@ async function driveChannels(state, driver) {
|
|
|
9997
10005
|
}
|
|
9998
10006
|
}
|
|
9999
10007
|
var SESSION_CLEANUP_FIRST_SWEEP_MS = 1e4;
|
|
10000
|
-
var SESSION_DB_RECLAIM_MAX_PAGES =
|
|
10008
|
+
var SESSION_DB_RECLAIM_MAX_PAGES = 2e4;
|
|
10009
|
+
function shouldWarnForReclaimSkip(reason) {
|
|
10010
|
+
if (reason !== "sqlite-unavailable") return false;
|
|
10011
|
+
const version2 = /^v(\d+)\.(\d+)\.(\d+)$/.exec(process.version);
|
|
10012
|
+
if (!version2) return false;
|
|
10013
|
+
const major = Number(version2[1]);
|
|
10014
|
+
const minor = Number(version2[2]);
|
|
10015
|
+
const patch = Number(version2[3]);
|
|
10016
|
+
return major > 22 || major === 22 && (minor > 13 || minor === 13 && patch >= 0);
|
|
10017
|
+
}
|
|
10001
10018
|
function sessionDbPath() {
|
|
10002
10019
|
return join9(homedir5(), ".local", "share", "opencode", "opencode.db");
|
|
10003
10020
|
}
|
|
@@ -10095,7 +10112,7 @@ async function runSweep(state, driver, config) {
|
|
|
10095
10112
|
} else {
|
|
10096
10113
|
logActivity(state, {
|
|
10097
10114
|
type: "info",
|
|
10098
|
-
message: `Session cleanup: session-db space reclaim skipped (${reclaimResult.skipped})`
|
|
10115
|
+
message: `Session cleanup: session-db space reclaim skipped (${reclaimResult.skipped})` + (reclaimResult.detail ? `: ${reclaimResult.detail}` : "")
|
|
10099
10116
|
});
|
|
10100
10117
|
}
|
|
10101
10118
|
} catch (error2) {
|
|
@@ -10120,11 +10137,18 @@ function scheduleSessionCleanup(state, driver, options) {
|
|
|
10120
10137
|
}
|
|
10121
10138
|
const dbBytes = statSessionDbBytes(homedir5());
|
|
10122
10139
|
void (async () => {
|
|
10123
|
-
const
|
|
10140
|
+
const reclaimAvailability = dbBytes !== null && config.enabled ? await probeReclaimAvailability({ dbPath: sessionDbPath(), requiredBytes: dbBytes }) : null;
|
|
10141
|
+
if (reclaimAvailability !== null) {
|
|
10142
|
+
logActivity(state, {
|
|
10143
|
+
type: "info",
|
|
10144
|
+
level: shouldWarnForReclaimSkip(reclaimAvailability.reason) ? "warn" : "info",
|
|
10145
|
+
message: `Session cleanup: reclaim preflight skipped (${reclaimAvailability.reason})` + (reclaimAvailability.detail ? `: ${reclaimAvailability.detail}` : "")
|
|
10146
|
+
});
|
|
10147
|
+
}
|
|
10124
10148
|
const sizeWarning = buildSessionStoreSizeWarning({
|
|
10125
10149
|
dbBytes,
|
|
10126
10150
|
cleanupEnabled: config.enabled,
|
|
10127
|
-
reclaimSkipReason
|
|
10151
|
+
reclaimSkipReason: reclaimAvailability?.reason ?? null
|
|
10128
10152
|
});
|
|
10129
10153
|
if (sizeWarning !== null) {
|
|
10130
10154
|
logActivity(state, { type: "info", level: "warn", message: sizeWarning });
|