toc-ocra 0.3.19 → 0.3.20
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/cli/cli.mjs +198 -65
- package/dist/service/agent.mjs +190 -57
- package/dist/src/providers/claude-quota.d.ts +4 -0
- package/dist/src/providers/claude-quota.js +92 -0
- package/dist/src/providers/claude-quota.js.map +1 -0
- package/dist/src/providers/model-catalog.d.ts +9 -2
- package/dist/src/providers/model-catalog.js +85 -9
- package/dist/src/providers/model-catalog.js.map +1 -1
- package/dist/src/providers/registry.js +2 -1
- package/dist/src/providers/registry.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/cli.mjs
CHANGED
|
@@ -4579,7 +4579,7 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
4579
4579
|
import { existsSync as existsSync8, mkdtempSync, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4580
4580
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
4581
4581
|
import { createRequire } from "node:module";
|
|
4582
|
-
import { dirname as dirname11, join as
|
|
4582
|
+
import { dirname as dirname11, join as join25, resolve as resolve9 } from "node:path";
|
|
4583
4583
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
4584
4584
|
|
|
4585
4585
|
// src/config.ts
|
|
@@ -25535,7 +25535,7 @@ function codexCatalogArgs() {
|
|
|
25535
25535
|
|
|
25536
25536
|
// src/providers/model-catalog.ts
|
|
25537
25537
|
import { spawn as spawn5 } from "node:child_process";
|
|
25538
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
25538
|
+
import { readdir, readFile as readFile3 } from "node:fs/promises";
|
|
25539
25539
|
import { homedir as homedir7 } from "node:os";
|
|
25540
25540
|
import { isAbsolute as isAbsolute2, join as join10, resolve as resolve3 } from "node:path";
|
|
25541
25541
|
|
|
@@ -25668,9 +25668,40 @@ var CLAUDE_REASONING_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
|
25668
25668
|
var CLAUDE_BUILTIN_MODELS = [
|
|
25669
25669
|
{ id: "opus", name: "Opus" },
|
|
25670
25670
|
{ id: "sonnet", name: "Sonnet" },
|
|
25671
|
-
{ id: "haiku", name: "Haiku" }
|
|
25671
|
+
{ id: "haiku", name: "Haiku" },
|
|
25672
|
+
{ id: "fable", name: "Fable" }
|
|
25672
25673
|
];
|
|
25673
|
-
function
|
|
25674
|
+
function parseClaudeCachedModels(cache) {
|
|
25675
|
+
const listed = objectValue(objectValue(objectValue(cache).catalog).config).models;
|
|
25676
|
+
if (!Array.isArray(listed)) return [];
|
|
25677
|
+
const entries = [];
|
|
25678
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25679
|
+
for (const raw of listed) {
|
|
25680
|
+
const model = objectValue(raw);
|
|
25681
|
+
const id = stringValue(model.id);
|
|
25682
|
+
if (!id || model.disabled === true || seen.has(id)) continue;
|
|
25683
|
+
seen.add(id);
|
|
25684
|
+
const runtime = objectValue(model.runtime);
|
|
25685
|
+
const efforts = Array.isArray(runtime.effort_levels) ? runtime.effort_levels.filter((value) => typeof value === "string" && value.trim() !== "") : [];
|
|
25686
|
+
const name = stringValue(model.name);
|
|
25687
|
+
const description = stringValue(model.description);
|
|
25688
|
+
const defaultEffort = stringValue(runtime.default_effort);
|
|
25689
|
+
const section = stringValue(model.section);
|
|
25690
|
+
entries.push({
|
|
25691
|
+
...section && { section },
|
|
25692
|
+
entry: {
|
|
25693
|
+
id,
|
|
25694
|
+
name: name ?? id,
|
|
25695
|
+
...description && { description },
|
|
25696
|
+
...defaultEffort && efforts.includes(defaultEffort) && { default_reasoning_effort: defaultEffort },
|
|
25697
|
+
supported_reasoning_efforts: efforts
|
|
25698
|
+
}
|
|
25699
|
+
});
|
|
25700
|
+
}
|
|
25701
|
+
const main2 = entries.filter((item) => item.section === "main");
|
|
25702
|
+
return (main2.length ? main2 : entries).map((item) => item.entry);
|
|
25703
|
+
}
|
|
25704
|
+
function parseClaudeModelCatalog(settings, environment = process.env, fetchedAt = (/* @__PURE__ */ new Date()).toISOString(), cachedModels = []) {
|
|
25674
25705
|
const source = objectValue(settings);
|
|
25675
25706
|
const mergedEnv = { ...objectValue(source.env), ...environment };
|
|
25676
25707
|
const models2 = /* @__PURE__ */ new Map();
|
|
@@ -25694,8 +25725,18 @@ function parseClaudeModelCatalog(settings, environment = process.env, fetchedAt
|
|
|
25694
25725
|
}
|
|
25695
25726
|
const defaultModel = stringValue(mergedEnv.ANTHROPIC_MODEL) ?? stringValue(source.model);
|
|
25696
25727
|
if (models2.size === 0) {
|
|
25697
|
-
if (
|
|
25698
|
-
|
|
25728
|
+
if (cachedModels.length) {
|
|
25729
|
+
for (const model of cachedModels) if (!models2.has(model.id)) models2.set(model.id, model);
|
|
25730
|
+
if (defaultModel && !models2.has(defaultModel)) {
|
|
25731
|
+
const rest = [...models2.values()];
|
|
25732
|
+
models2.clear();
|
|
25733
|
+
addModel(defaultModel);
|
|
25734
|
+
for (const model of rest) models2.set(model.id, model);
|
|
25735
|
+
}
|
|
25736
|
+
} else {
|
|
25737
|
+
if (defaultModel) addModel(defaultModel);
|
|
25738
|
+
for (const model of CLAUDE_BUILTIN_MODELS) addModel(model.id, model.name);
|
|
25739
|
+
}
|
|
25699
25740
|
}
|
|
25700
25741
|
return {
|
|
25701
25742
|
agent_type: "claude",
|
|
@@ -25721,7 +25762,23 @@ async function readClaudeModelCatalog() {
|
|
|
25721
25762
|
throw new Error("Claude \u672C\u673A settings.json \u4E0D\u662F\u6709\u6548 JSON");
|
|
25722
25763
|
}
|
|
25723
25764
|
}
|
|
25724
|
-
return parseClaudeModelCatalog(settings);
|
|
25765
|
+
return parseClaudeModelCatalog(settings, process.env, (/* @__PURE__ */ new Date()).toISOString(), await readClaudeCachedModels(home));
|
|
25766
|
+
}
|
|
25767
|
+
async function readClaudeCachedModels(home) {
|
|
25768
|
+
const dir = join10(home, "cache", "model-catalog");
|
|
25769
|
+
const names = await readdir(dir).catch(() => []);
|
|
25770
|
+
let newest;
|
|
25771
|
+
for (const name of names) {
|
|
25772
|
+
if (!name.endsWith(".json")) continue;
|
|
25773
|
+
try {
|
|
25774
|
+
const cache = JSON.parse(await readFile3(join10(dir, name), "utf8"));
|
|
25775
|
+
const models2 = parseClaudeCachedModels(cache);
|
|
25776
|
+
const fetchedAt = Number(objectValue(cache).fetchedAt) || 0;
|
|
25777
|
+
if (models2.length && (!newest || fetchedAt > newest.fetchedAt)) newest = { fetchedAt, models: models2 };
|
|
25778
|
+
} catch {
|
|
25779
|
+
}
|
|
25780
|
+
}
|
|
25781
|
+
return newest?.models ?? [];
|
|
25725
25782
|
}
|
|
25726
25783
|
function configValue(content, key) {
|
|
25727
25784
|
const match = content.match(new RegExp(`^\\s*${key}\\s*=\\s*["']([^"']+)["']\\s*(?:#.*)?$`, "m"));
|
|
@@ -26028,7 +26085,7 @@ async function readOpencodeModelCatalog() {
|
|
|
26028
26085
|
}
|
|
26029
26086
|
var TEN_MINUTES = 10 * 60 * 1e3;
|
|
26030
26087
|
var MODEL_SOURCES = {
|
|
26031
|
-
claude: { read: readClaudeModelCatalog, watchFiles: () => [join10(claudeHome(), "settings.json")] },
|
|
26088
|
+
claude: { read: readClaudeModelCatalog, watchFiles: () => [join10(claudeHome(), "settings.json"), join10(claudeHome(), "cache", "model-catalog")] },
|
|
26032
26089
|
codex: {
|
|
26033
26090
|
read: readCodexModelCatalog,
|
|
26034
26091
|
watchFiles: () => {
|
|
@@ -26156,7 +26213,7 @@ function classifySpawnError(error62, context) {
|
|
|
26156
26213
|
}
|
|
26157
26214
|
|
|
26158
26215
|
// src/providers/cli/kiro-session-log.ts
|
|
26159
|
-
import { open as open2, readdir, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
26216
|
+
import { open as open2, readdir as readdir2, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
26160
26217
|
import { homedir as homedir8 } from "node:os";
|
|
26161
26218
|
import { join as join11 } from "node:path";
|
|
26162
26219
|
var SHELL_TOOLS = /* @__PURE__ */ new Set(["shell", "execute_bash", "bash"]);
|
|
@@ -26189,7 +26246,7 @@ var KiroSessionLog = class {
|
|
|
26189
26246
|
* in the same folder) leave it unknown.
|
|
26190
26247
|
*/
|
|
26191
26248
|
async findFreshLog() {
|
|
26192
|
-
const names = await
|
|
26249
|
+
const names = await readdir2(this.directory).catch(() => []);
|
|
26193
26250
|
const found = [];
|
|
26194
26251
|
for (const name of names) {
|
|
26195
26252
|
if (!name.endsWith(".json")) continue;
|
|
@@ -29029,6 +29086,82 @@ var opencodeProvider = {
|
|
|
29029
29086
|
}
|
|
29030
29087
|
};
|
|
29031
29088
|
|
|
29089
|
+
// src/providers/claude-quota.ts
|
|
29090
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
29091
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
29092
|
+
import { homedir as homedir10 } from "node:os";
|
|
29093
|
+
import { join as join16 } from "node:path";
|
|
29094
|
+
import { promisify as promisify3 } from "node:util";
|
|
29095
|
+
var execFileAsync3 = promisify3(execFile5);
|
|
29096
|
+
var CLAUDE_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
29097
|
+
var WINDOWS = [
|
|
29098
|
+
{ key: "five_hour", label: "5 \u5C0F\u65F6\u989D\u5EA6", seconds: 5 * 3600 },
|
|
29099
|
+
{ key: "seven_day", label: "\u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 },
|
|
29100
|
+
{ key: "seven_day_opus", label: "Opus \xB7 \u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 },
|
|
29101
|
+
{ key: "seven_day_sonnet", label: "Sonnet \xB7 \u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 }
|
|
29102
|
+
];
|
|
29103
|
+
function objectValue2(value) {
|
|
29104
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
29105
|
+
}
|
|
29106
|
+
function resetSeconds(value) {
|
|
29107
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value > 1e10 ? value / 1e3 : value);
|
|
29108
|
+
if (typeof value === "string" && value.trim()) {
|
|
29109
|
+
const parsed = Date.parse(value);
|
|
29110
|
+
if (Number.isFinite(parsed)) return Math.floor(parsed / 1e3);
|
|
29111
|
+
}
|
|
29112
|
+
return 0;
|
|
29113
|
+
}
|
|
29114
|
+
function parseClaudeQuota(body) {
|
|
29115
|
+
const source = objectValue2(body);
|
|
29116
|
+
const windows = [];
|
|
29117
|
+
for (const { key, label, seconds } of WINDOWS) {
|
|
29118
|
+
const raw = source[key];
|
|
29119
|
+
if (!raw || typeof raw !== "object") continue;
|
|
29120
|
+
const window = objectValue2(raw);
|
|
29121
|
+
const utilization = Number(window.utilization);
|
|
29122
|
+
windows.push({
|
|
29123
|
+
key: `claude:${key}`,
|
|
29124
|
+
label,
|
|
29125
|
+
resets_at: resetSeconds(window.resets_at),
|
|
29126
|
+
window_seconds: seconds,
|
|
29127
|
+
...window.utilization !== null && Number.isFinite(utilization) && utilization >= 0 ? { used_percent: Math.min(100, Math.round(utilization * 100) / 100) } : {}
|
|
29128
|
+
});
|
|
29129
|
+
}
|
|
29130
|
+
return windows;
|
|
29131
|
+
}
|
|
29132
|
+
var claudeHome2 = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join16(homedir10(), ".claude");
|
|
29133
|
+
function tokenFrom(content) {
|
|
29134
|
+
try {
|
|
29135
|
+
const token = objectValue2(objectValue2(JSON.parse(content)).claudeAiOauth).accessToken;
|
|
29136
|
+
return typeof token === "string" && token.trim() ? token.trim() : void 0;
|
|
29137
|
+
} catch {
|
|
29138
|
+
return void 0;
|
|
29139
|
+
}
|
|
29140
|
+
}
|
|
29141
|
+
async function readClaudeAccessToken() {
|
|
29142
|
+
const fromEnv = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
|
|
29143
|
+
if (fromEnv) return fromEnv;
|
|
29144
|
+
const fromFile = tokenFrom(await readFile5(join16(claudeHome2(), ".credentials.json"), "utf8").catch(() => ""));
|
|
29145
|
+
if (fromFile) return fromFile;
|
|
29146
|
+
if (process.platform !== "darwin") return void 0;
|
|
29147
|
+
const { stdout } = await execFileAsync3("security", ["find-generic-password", "-s", "Claude Code-credentials", "-w"], { timeout: 1e4 }).catch(() => ({ stdout: "" }));
|
|
29148
|
+
return tokenFrom(String(stdout).trim());
|
|
29149
|
+
}
|
|
29150
|
+
async function readClaudeQuotaWindows() {
|
|
29151
|
+
const token = await readClaudeAccessToken();
|
|
29152
|
+
if (!token) throw new Error("Claude Code \u672A\u4F7F\u7528 Claude \u8D26\u53F7\u767B\u5F55\uFF08API Key \u65B9\u5F0F\u6CA1\u6709\u5957\u9910\u989D\u5EA6\uFF09\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C claude \u5E76 /login");
|
|
29153
|
+
const response = await fetch(CLAUDE_USAGE_URL, {
|
|
29154
|
+
headers: { authorization: `Bearer ${token}`, "anthropic-beta": "oauth-2025-04-20", accept: "application/json" },
|
|
29155
|
+
redirect: "error",
|
|
29156
|
+
signal: AbortSignal.timeout(15e3)
|
|
29157
|
+
});
|
|
29158
|
+
if (response.status === 401 || response.status === 403) throw new Error("Claude Code \u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C\u4E00\u6B21 claude \u5237\u65B0\u767B\u5F55\u540E\u518D\u8BD5");
|
|
29159
|
+
if (!response.ok) throw new Error(`Claude \u989D\u5EA6\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25 (${response.status})`);
|
|
29160
|
+
const windows = parseClaudeQuota(await response.json());
|
|
29161
|
+
if (!windows.length) throw new Error("Claude \u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u7684\u989D\u5EA6\u7A97\u53E3");
|
|
29162
|
+
return windows;
|
|
29163
|
+
}
|
|
29164
|
+
|
|
29032
29165
|
// src/providers/codex-quota.ts
|
|
29033
29166
|
import { spawn as spawn8 } from "node:child_process";
|
|
29034
29167
|
import { createInterface as createInterface4 } from "node:readline";
|
|
@@ -29127,10 +29260,10 @@ async function readCodexQuotaWindows() {
|
|
|
29127
29260
|
}
|
|
29128
29261
|
|
|
29129
29262
|
// src/providers/kiro-quota.ts
|
|
29130
|
-
import { execFile as
|
|
29263
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
29131
29264
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
29132
|
-
import { promisify as
|
|
29133
|
-
var
|
|
29265
|
+
import { promisify as promisify4, stripVTControlCharacters } from "node:util";
|
|
29266
|
+
var execFileAsync4 = promisify4(execFile6);
|
|
29134
29267
|
var amount = (value) => Number(value.replace(/,/g, ""));
|
|
29135
29268
|
var rounded = (value) => Math.round(value * 100) / 100;
|
|
29136
29269
|
function parseKiroQuota(stdout, now = /* @__PURE__ */ new Date()) {
|
|
@@ -29190,7 +29323,7 @@ async function readKiroQuotaWindows() {
|
|
|
29190
29323
|
const launch = launchCli({ spec: requireCliSpec("kiro"), args: ["chat", "--no-interactive", "/usage"] });
|
|
29191
29324
|
await requireKiroAuthentication(launch.env);
|
|
29192
29325
|
try {
|
|
29193
|
-
const { stdout, stderr } = await
|
|
29326
|
+
const { stdout, stderr } = await execFileAsync4(launch.executable, launch.args, { env: launch.env, cwd: tmpdir2(), timeout: 3e4, maxBuffer: 1024 * 1024, windowsHide: true });
|
|
29194
29327
|
return parseKiroQuota(`${stdout}
|
|
29195
29328
|
${stderr}`);
|
|
29196
29329
|
} catch (error62) {
|
|
@@ -29203,7 +29336,7 @@ ${stderr}`);
|
|
|
29203
29336
|
var ALL_LEVELS = ["read-only", "acceptEdits", "bypassPermissions"];
|
|
29204
29337
|
var NATIVE = {
|
|
29205
29338
|
codex: { headless: codexProvider, chat: codexChatProvider, models: MODEL_SOURCES.codex, quota: readCodexQuotaWindows, runSettings: { permissionModes: ALL_LEVELS, plan: "prompt", fast: true } },
|
|
29206
|
-
claude: { headless: claudeProvider, chat: (_request, attachments) => claudeChatProvider(attachments), models: MODEL_SOURCES.claude, runSettings: { permissionModes: ALL_LEVELS, plan: "native", fast: true } }
|
|
29339
|
+
claude: { headless: claudeProvider, chat: (_request, attachments) => claudeChatProvider(attachments), models: MODEL_SOURCES.claude, quota: readClaudeQuotaWindows, runSettings: { permissionModes: ALL_LEVELS, plan: "native", fast: true } }
|
|
29207
29340
|
};
|
|
29208
29341
|
var ACP_EXTRAS = {
|
|
29209
29342
|
kiro: { quota: readKiroQuotaWindows, legacy: { headless: kiroProvider, restrictedPermission: true, runSettings: { permissionModes: ["read-only", "bypassPermissions"], plan: "prompt" } } },
|
|
@@ -29390,12 +29523,12 @@ var cliDetection = new CliDetectionService();
|
|
|
29390
29523
|
// src/smoke/cli-smoke.ts
|
|
29391
29524
|
import { mkdtemp as mkdtemp2, realpath as realpath3, rm as rm5 } from "node:fs/promises";
|
|
29392
29525
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
29393
|
-
import { join as
|
|
29526
|
+
import { join as join21 } from "node:path";
|
|
29394
29527
|
|
|
29395
29528
|
// src/runs/run-supervisor.ts
|
|
29396
29529
|
import { spawn as spawn11 } from "node:child_process";
|
|
29397
29530
|
import { mkdir as mkdir7, realpath as realpath2, stat as stat5, writeFile as writeFile7 } from "node:fs/promises";
|
|
29398
|
-
import { basename as basename2, isAbsolute as isAbsolute4, join as
|
|
29531
|
+
import { basename as basename2, isAbsolute as isAbsolute4, join as join20, relative as relative2, resolve as resolve5 } from "node:path";
|
|
29399
29532
|
import { createInterface as createInterface6 } from "node:readline";
|
|
29400
29533
|
|
|
29401
29534
|
// src/providers/chat/index.ts
|
|
@@ -29764,19 +29897,19 @@ async function forkCodexThread(options) {
|
|
|
29764
29897
|
|
|
29765
29898
|
// src/runs/run-recorder.ts
|
|
29766
29899
|
import { appendFileSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
29767
|
-
import { homedir as
|
|
29768
|
-
import { join as
|
|
29900
|
+
import { homedir as homedir11 } from "node:os";
|
|
29901
|
+
import { join as join17 } from "node:path";
|
|
29769
29902
|
var RunRecorder = class _RunRecorder {
|
|
29770
29903
|
constructor(path) {
|
|
29771
29904
|
this.path = path;
|
|
29772
29905
|
}
|
|
29773
29906
|
path;
|
|
29774
|
-
home =
|
|
29907
|
+
home = homedir11();
|
|
29775
29908
|
static fromEnvironment(runId, meta3) {
|
|
29776
29909
|
const directory = process.env.TOC_OCRA_RECORD_DIR?.trim();
|
|
29777
29910
|
if (!directory) return void 0;
|
|
29778
29911
|
mkdirSync2(directory, { recursive: true });
|
|
29779
|
-
const recorder = new _RunRecorder(
|
|
29912
|
+
const recorder = new _RunRecorder(join17(directory, `${String(meta3.agent ?? "cli")}-${runId}.jsonl`));
|
|
29780
29913
|
recorder.write({ meta: meta3 });
|
|
29781
29914
|
return recorder;
|
|
29782
29915
|
}
|
|
@@ -29791,8 +29924,8 @@ var RunRecorder = class _RunRecorder {
|
|
|
29791
29924
|
};
|
|
29792
29925
|
|
|
29793
29926
|
// src/runs/run-transcript.ts
|
|
29794
|
-
import { chmod as chmod4, mkdir as mkdir5, readdir as
|
|
29795
|
-
import { join as
|
|
29927
|
+
import { chmod as chmod4, mkdir as mkdir5, readdir as readdir3, readFile as readFile6, rename as rename5, stat as stat3, unlink, writeFile as writeFile5 } from "node:fs/promises";
|
|
29928
|
+
import { join as join18 } from "node:path";
|
|
29796
29929
|
var MAX_TRANSCRIPT_ITEMS = 5e3;
|
|
29797
29930
|
var MAX_TRANSCRIPT_TEXT = 2e5;
|
|
29798
29931
|
var MAX_TRANSCRIPT_LINES = 2e4;
|
|
@@ -30057,7 +30190,7 @@ function transcriptFileName(runId) {
|
|
|
30057
30190
|
var TranscriptStore = class {
|
|
30058
30191
|
constructor(dataDir2, logger, env = process.env) {
|
|
30059
30192
|
this.logger = logger;
|
|
30060
|
-
this.directory = dataDir2 ?
|
|
30193
|
+
this.directory = dataDir2 ? join18(dataDir2, "transcripts") : "";
|
|
30061
30194
|
this.enabled = Boolean(dataDir2) && transcriptsOnDisk(env);
|
|
30062
30195
|
}
|
|
30063
30196
|
logger;
|
|
@@ -30112,7 +30245,7 @@ var TranscriptStore = class {
|
|
|
30112
30245
|
await this.writes.get(runId);
|
|
30113
30246
|
let text3;
|
|
30114
30247
|
try {
|
|
30115
|
-
text3 = await
|
|
30248
|
+
text3 = await readFile6(join18(this.directory, name), "utf8");
|
|
30116
30249
|
} catch (error62) {
|
|
30117
30250
|
if (errorCode(error62) !== "ENOENT") this.logger.warn("run-transcript-read-failed", { runId, error: errorMessage(error62) });
|
|
30118
30251
|
return void 0;
|
|
@@ -30177,7 +30310,7 @@ var TranscriptStore = class {
|
|
|
30177
30310
|
transcript.dirty = false;
|
|
30178
30311
|
const body = JSON.stringify(transcript.toFile());
|
|
30179
30312
|
await this.ensureDirectory();
|
|
30180
|
-
const file2 =
|
|
30313
|
+
const file2 = join18(this.directory, name);
|
|
30181
30314
|
const temporary = `${file2}.${process.pid}.tmp`;
|
|
30182
30315
|
await writeFile5(temporary, body, { mode: 384 });
|
|
30183
30316
|
await rename5(temporary, file2);
|
|
@@ -30206,7 +30339,7 @@ var TranscriptStore = class {
|
|
|
30206
30339
|
async pruneOnce() {
|
|
30207
30340
|
let names;
|
|
30208
30341
|
try {
|
|
30209
|
-
names = await
|
|
30342
|
+
names = await readdir3(this.directory);
|
|
30210
30343
|
} catch (error62) {
|
|
30211
30344
|
if (errorCode(error62) === "ENOENT") return;
|
|
30212
30345
|
throw error62;
|
|
@@ -30214,7 +30347,7 @@ var TranscriptStore = class {
|
|
|
30214
30347
|
const now = Date.now();
|
|
30215
30348
|
const files = [];
|
|
30216
30349
|
for (const name of names) {
|
|
30217
|
-
const path =
|
|
30350
|
+
const path = join18(this.directory, name);
|
|
30218
30351
|
if (name.endsWith(".tmp")) {
|
|
30219
30352
|
const info2 = await stat3(path).catch(() => void 0);
|
|
30220
30353
|
if (info2?.isFile() && now - info2.mtimeMs > STALE_TEMPORARY_MS) await unlink(path).catch(() => void 0);
|
|
@@ -30264,7 +30397,7 @@ function errorMessage(error62) {
|
|
|
30264
30397
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
30265
30398
|
import { constants as constants2 } from "node:fs";
|
|
30266
30399
|
import { lstat, mkdir as mkdir6, open as open3, realpath, rename as rename6, rm as rm4, writeFile as writeFile6 } from "node:fs/promises";
|
|
30267
|
-
import { basename, isAbsolute as isAbsolute3, join as
|
|
30400
|
+
import { basename, isAbsolute as isAbsolute3, join as join19, relative } from "node:path";
|
|
30268
30401
|
function within(root2, path) {
|
|
30269
30402
|
const segment = relative(root2, path);
|
|
30270
30403
|
return segment === "" || !segment.startsWith("..") && !isAbsolute3(segment);
|
|
@@ -30272,7 +30405,7 @@ function within(root2, path) {
|
|
|
30272
30405
|
async function attachmentDirectory(workdir, messageId) {
|
|
30273
30406
|
let directory = workdir;
|
|
30274
30407
|
for (const segment of [".echo", "attachments", `message-${encodeURIComponent(messageId).slice(0, 180)}`]) {
|
|
30275
|
-
directory =
|
|
30408
|
+
directory = join19(directory, segment);
|
|
30276
30409
|
await mkdir6(directory, { mode: 448 }).catch((error62) => {
|
|
30277
30410
|
if (error62.code !== "EEXIST") throw error62;
|
|
30278
30411
|
});
|
|
@@ -30280,7 +30413,7 @@ async function attachmentDirectory(workdir, messageId) {
|
|
|
30280
30413
|
if (metadata.isSymbolicLink() || !metadata.isDirectory() || !within(workdir, await realpath(directory))) {
|
|
30281
30414
|
throw new Error("\u9644\u4EF6\u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E CLI \u5DE5\u4F5C\u76EE\u5F55\u5185\uFF0C\u4E14\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");
|
|
30282
30415
|
}
|
|
30283
|
-
if (segment === ".echo") await writeFile6(
|
|
30416
|
+
if (segment === ".echo") await writeFile6(join19(directory, ".gitignore"), "*\n", { flag: "wx", mode: 384 }).catch((error62) => {
|
|
30284
30417
|
if (error62.code !== "EEXIST") throw error62;
|
|
30285
30418
|
});
|
|
30286
30419
|
}
|
|
@@ -30317,9 +30450,9 @@ async function prepareTaskAttachments(payload, workdir, download, signal2) {
|
|
|
30317
30450
|
const characters = Array.from(basename(file2.name.replace(/\\/g, "/")).replace(/[^\p{L}\p{N}._-]/gu, "_").replace(/\.+$/u, ""));
|
|
30318
30451
|
while (Buffer.byteLength(characters.join("")) > 160) characters.shift();
|
|
30319
30452
|
const name = characters.join("") || "attachment";
|
|
30320
|
-
const path =
|
|
30453
|
+
const path = join19(directory, `${file2.file_id}-${name}`);
|
|
30321
30454
|
if (!await matches(path, file2.size, file2.sha256, signal2)) {
|
|
30322
|
-
const temporary =
|
|
30455
|
+
const temporary = join19(directory, `.download-${file2.file_id}-${randomUUID2()}.part`);
|
|
30323
30456
|
try {
|
|
30324
30457
|
await download(payload.run_id, file2.file_id, temporary, file2.size, file2.sha256, signal2);
|
|
30325
30458
|
signal2.throwIfAborted();
|
|
@@ -30434,7 +30567,7 @@ var ChatEventForwarder = class {
|
|
|
30434
30567
|
|
|
30435
30568
|
// src/acp/chat-session.ts
|
|
30436
30569
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
30437
|
-
import { readFile as
|
|
30570
|
+
import { readFile as readFile7, stat as stat4 } from "node:fs/promises";
|
|
30438
30571
|
import { extname } from "node:path";
|
|
30439
30572
|
import { pathToFileURL } from "node:url";
|
|
30440
30573
|
|
|
@@ -31042,7 +31175,7 @@ var AcpChatSession = class {
|
|
|
31042
31175
|
if (file2.kind === "image" && mimeType && connection.imagePrompts) {
|
|
31043
31176
|
const size = await stat4(file2.path).then((info) => info.size).catch(() => 0);
|
|
31044
31177
|
if (size > 0 && size <= MAX_IMAGE_BYTES) {
|
|
31045
|
-
blocks.push({ type: "image", mimeType, data: (await
|
|
31178
|
+
blocks.push({ type: "image", mimeType, data: (await readFile7(file2.path)).toString("base64") });
|
|
31046
31179
|
continue;
|
|
31047
31180
|
}
|
|
31048
31181
|
}
|
|
@@ -31384,7 +31517,7 @@ var AcpChatHost = class {
|
|
|
31384
31517
|
};
|
|
31385
31518
|
|
|
31386
31519
|
// src/memory/providers.ts
|
|
31387
|
-
import { execFile as
|
|
31520
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
31388
31521
|
var MemoryCreateInputSchema = external_exports.object({
|
|
31389
31522
|
id: external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/),
|
|
31390
31523
|
name: external_exports.string().trim().min(1).max(200),
|
|
@@ -31406,7 +31539,7 @@ var runNmem = (args) => {
|
|
|
31406
31539
|
const env = providerEnvironment();
|
|
31407
31540
|
const launch = resolveExecutable("nmem", args, env, process.env.TOC_OCRA_NMEM_PATH);
|
|
31408
31541
|
return new Promise((resolve10) => {
|
|
31409
|
-
|
|
31542
|
+
execFile7(launch.executable, launch.args, { env: launch.env, timeout: COMMAND_TIMEOUT_MS, maxBuffer: MAX_OUTPUT_BYTES, windowsHide: true }, (error62, stdout) => {
|
|
31410
31543
|
if (!error62) {
|
|
31411
31544
|
resolve10({ stdout: String(stdout) });
|
|
31412
31545
|
return;
|
|
@@ -32384,12 +32517,12 @@ ${PLAN_MODE_PREFIX}` : payload.prompt;
|
|
|
32384
32517
|
async prepareChatAttachments(payload) {
|
|
32385
32518
|
if (!payload.attachments?.length) return [];
|
|
32386
32519
|
if (!this.reporter.chatMedia) throw new Error("\u9644\u4EF6\u8F6C\u53D1\u672A\u914D\u7F6E");
|
|
32387
|
-
const directory =
|
|
32520
|
+
const directory = join20(this.config.dataDir, "chat-media", encodeURIComponent(payload.chat_session_id ?? payload.run_id));
|
|
32388
32521
|
await mkdir7(directory, { recursive: true, mode: 448 });
|
|
32389
32522
|
const files = [];
|
|
32390
32523
|
for (const attachment of payload.attachments) {
|
|
32391
32524
|
const name = basename2(attachment.name).replace(/[^\p{L}\p{N}._-]/gu, "_").slice(-120) || "attachment";
|
|
32392
|
-
const path =
|
|
32525
|
+
const path = join20(directory, `${encodeURIComponent(attachment.media_id)}-${name}`);
|
|
32393
32526
|
const existing = await stat5(path).catch(() => void 0);
|
|
32394
32527
|
if (!existing?.isFile()) {
|
|
32395
32528
|
const data = await this.reporter.chatMedia(payload.run_id, attachment.media_id);
|
|
@@ -32590,7 +32723,7 @@ var silent = { debug() {
|
|
|
32590
32723
|
async function runCliSmoke(options = {}) {
|
|
32591
32724
|
const detection = await cliDetection.detect(true);
|
|
32592
32725
|
const ids = options.only?.length ? options.only.map((id) => catalogEntry(id)?.id ?? id) : CLI_CATALOG.filter((entry) => entry.headless && detection.detectedIds.includes(entry.id)).map((entry) => entry.id);
|
|
32593
|
-
const root2 = await realpath3(await mkdtemp2(
|
|
32726
|
+
const root2 = await realpath3(await mkdtemp2(join21(tmpdir3(), "toc-ocra-smoke-")));
|
|
32594
32727
|
const finished = /* @__PURE__ */ new Map();
|
|
32595
32728
|
const config2 = { allowedRoots: [root2], maxConcurrentRuns: 0, maxRunSeconds: options.timeoutSeconds ?? 300, dataDir: root2 };
|
|
32596
32729
|
const supervisor = new RunSupervisor(config2, silent, {
|
|
@@ -32667,7 +32800,7 @@ import { dirname as dirname10, resolve as resolve8 } from "node:path";
|
|
|
32667
32800
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32668
32801
|
|
|
32669
32802
|
// src/health/server.ts
|
|
32670
|
-
import { readFile as
|
|
32803
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
32671
32804
|
import { createServer } from "node:http";
|
|
32672
32805
|
var ControlError = class extends Error {
|
|
32673
32806
|
constructor(status, message, code2 = "bad_request") {
|
|
@@ -32848,7 +32981,7 @@ var HealthServer = class {
|
|
|
32848
32981
|
}
|
|
32849
32982
|
async recentEvents() {
|
|
32850
32983
|
try {
|
|
32851
|
-
const raw = await
|
|
32984
|
+
const raw = await readFile8(this.logFile, "utf8");
|
|
32852
32985
|
return raw.trim().split("\n").slice(-60).flatMap((line) => {
|
|
32853
32986
|
try {
|
|
32854
32987
|
const parsed = JSON.parse(line);
|
|
@@ -33025,7 +33158,7 @@ function createDiagnosticLogger(filePath, options = {}) {
|
|
|
33025
33158
|
|
|
33026
33159
|
// src/runtime/agent-runtime.ts
|
|
33027
33160
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
33028
|
-
import { join as
|
|
33161
|
+
import { join as join24 } from "node:path";
|
|
33029
33162
|
|
|
33030
33163
|
// src/exec/script-runner.ts
|
|
33031
33164
|
import { spawn as spawn12 } from "node:child_process";
|
|
@@ -33196,16 +33329,16 @@ async function readCLIQuotaReport(agentType) {
|
|
|
33196
33329
|
}
|
|
33197
33330
|
|
|
33198
33331
|
// src/providers/tb-switch-control.ts
|
|
33199
|
-
import { readFile as
|
|
33200
|
-
import { homedir as
|
|
33201
|
-
import { join as
|
|
33332
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
33333
|
+
import { homedir as homedir12 } from "node:os";
|
|
33334
|
+
import { join as join22 } from "node:path";
|
|
33202
33335
|
function dataDir() {
|
|
33203
|
-
return process.env.TB_SWITCH_HOME?.trim() ||
|
|
33336
|
+
return process.env.TB_SWITCH_HOME?.trim() || join22(homedir12(), ".tb-switch");
|
|
33204
33337
|
}
|
|
33205
33338
|
async function readLocalService() {
|
|
33206
33339
|
let discovery;
|
|
33207
33340
|
try {
|
|
33208
|
-
discovery = JSON.parse(await
|
|
33341
|
+
discovery = JSON.parse(await readFile9(join22(dataDir(), "api.json"), "utf8"));
|
|
33209
33342
|
} catch {
|
|
33210
33343
|
throw new Error("\u8FD9\u53F0\u8BBE\u5907\u4E0A\u7684 TB Switch \u670D\u52A1\u672A\u8FD0\u884C\uFF0C\u8BF7\u6253\u5F00\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
|
|
33211
33344
|
}
|
|
@@ -33221,7 +33354,7 @@ async function readLocalService() {
|
|
|
33221
33354
|
}
|
|
33222
33355
|
let token = process.env.TB_SWITCH_API_TOKEN?.trim() ?? "";
|
|
33223
33356
|
try {
|
|
33224
|
-
token = (await
|
|
33357
|
+
token = (await readFile9(join22(dataDir(), "api-token"), "utf8")).trim();
|
|
33225
33358
|
} catch {
|
|
33226
33359
|
}
|
|
33227
33360
|
if (!token) throw new Error("\u65E0\u6CD5\u8BFB\u53D6 TB Switch \u672C\u673A\u670D\u52A1\u51ED\u636E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
|
|
@@ -33311,7 +33444,7 @@ async function controlTbSwitch(payload) {
|
|
|
33311
33444
|
}
|
|
33312
33445
|
|
|
33313
33446
|
// src/runs/orphan-registry.ts
|
|
33314
|
-
import { mkdir as mkdir8, readFile as
|
|
33447
|
+
import { mkdir as mkdir8, readFile as readFile10, rename as rename7, writeFile as writeFile8 } from "node:fs/promises";
|
|
33315
33448
|
import { basename as basename3, dirname as dirname8 } from "node:path";
|
|
33316
33449
|
var OrphanRegistry = class {
|
|
33317
33450
|
constructor(file2) {
|
|
@@ -33340,7 +33473,7 @@ var OrphanRegistry = class {
|
|
|
33340
33473
|
async reapPrevious() {
|
|
33341
33474
|
let previous = [];
|
|
33342
33475
|
try {
|
|
33343
|
-
previous = JSON.parse(await
|
|
33476
|
+
previous = JSON.parse(await readFile10(this.file, "utf8"));
|
|
33344
33477
|
} catch {
|
|
33345
33478
|
return [];
|
|
33346
33479
|
}
|
|
@@ -33492,17 +33625,17 @@ var GatewayClient = class {
|
|
|
33492
33625
|
};
|
|
33493
33626
|
|
|
33494
33627
|
// src/workspace/directory-browser.ts
|
|
33495
|
-
import { mkdir as mkdir9, readdir as
|
|
33496
|
-
import { homedir as
|
|
33628
|
+
import { mkdir as mkdir9, readdir as readdir4, realpath as realpath4, stat as stat7 } from "node:fs/promises";
|
|
33629
|
+
import { homedir as homedir13 } from "node:os";
|
|
33497
33630
|
import { dirname as dirname9, isAbsolute as isAbsolute5, parse as parse3, resolve as resolve6 } from "node:path";
|
|
33498
33631
|
var MAX_ENTRIES = 1e3;
|
|
33499
33632
|
async function listDirectory(requested, allowedRoots) {
|
|
33500
|
-
const raw = requested.trim().replace(/^~(?=$|[\\/])/,
|
|
33633
|
+
const raw = requested.trim().replace(/^~(?=$|[\\/])/, homedir13()) || homedir13();
|
|
33501
33634
|
const directory = await realpath4(resolve6(raw)).catch(() => {
|
|
33502
33635
|
throw new Error(`\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${requested}`);
|
|
33503
33636
|
});
|
|
33504
33637
|
if (!(await stat7(directory)).isDirectory()) throw new Error("\u8FD9\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
33505
|
-
const entries = await
|
|
33638
|
+
const entries = await readdir4(directory, { withFileTypes: true }).catch((error62) => {
|
|
33506
33639
|
throw new Error(error62.code === "EACCES" || error62.code === "EPERM" ? "\u6CA1\u6709\u6743\u9650\u8BFB\u53D6\u8FD9\u4E2A\u76EE\u5F55" : error62.message);
|
|
33507
33640
|
});
|
|
33508
33641
|
const byName = (a, b) => a.name.localeCompare(b.name, void 0, { sensitivity: "base", numeric: true });
|
|
@@ -33515,8 +33648,8 @@ async function listDirectory(requested, allowedRoots) {
|
|
|
33515
33648
|
else if (entry.isFile()) files.push(item);
|
|
33516
33649
|
}
|
|
33517
33650
|
const parent = dirname9(directory);
|
|
33518
|
-
const places = [{ label: "\u4E3B\u76EE\u5F55", path:
|
|
33519
|
-
for (const root2 of allowedRoots) if (root2 !==
|
|
33651
|
+
const places = [{ label: "\u4E3B\u76EE\u5F55", path: homedir13() }];
|
|
33652
|
+
for (const root2 of allowedRoots) if (root2 !== homedir13()) places.push({ label: "\u5141\u8BB8\u7684\u76EE\u5F55", path: root2 });
|
|
33520
33653
|
places.push({ label: "\u6839\u76EE\u5F55", path: process.platform === "win32" ? parse3(directory).root : "/" });
|
|
33521
33654
|
return {
|
|
33522
33655
|
path: directory,
|
|
@@ -33554,7 +33687,7 @@ async function createDirectory(parentRequested, name) {
|
|
|
33554
33687
|
// src/workspace/workspace-manager.ts
|
|
33555
33688
|
import { spawn as spawn13 } from "node:child_process";
|
|
33556
33689
|
import { opendir, realpath as realpath5, stat as stat8 } from "node:fs/promises";
|
|
33557
|
-
import { homedir as
|
|
33690
|
+
import { homedir as homedir14 } from "node:os";
|
|
33558
33691
|
import { isAbsolute as isAbsolute6, relative as relative3, resolve as resolve7 } from "node:path";
|
|
33559
33692
|
var MAX_NODES = 2e3;
|
|
33560
33693
|
var MAX_DIRECTORY_ENTRIES = 12e3;
|
|
@@ -33590,7 +33723,7 @@ var WorkspaceManager = class {
|
|
|
33590
33723
|
return { root_path: rootPath, nodes, truncated: nodes.length >= MAX_NODES, duration_ms: Date.now() - startedAt };
|
|
33591
33724
|
}
|
|
33592
33725
|
validateRootPath(value) {
|
|
33593
|
-
const raw = value.trim().replace(/^~(?=$|[\\/])/,
|
|
33726
|
+
const raw = value.trim().replace(/^~(?=$|[\\/])/, homedir14());
|
|
33594
33727
|
const root2 = resolve7(raw);
|
|
33595
33728
|
if (!isAbsolute6(raw)) throw new Error("\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
|
|
33596
33729
|
if (relative3(root2, resolve7(root2, "..")) === "") throw new Error("\u4E0D\u80FD\u628A\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u4F5C\u4E3A\u76EE\u5F55\u6839");
|
|
@@ -33930,7 +34063,7 @@ var AgentRuntime = class {
|
|
|
33930
34063
|
}
|
|
33931
34064
|
};
|
|
33932
34065
|
this.workspaces = new WorkspaceManager(config2, this.logger);
|
|
33933
|
-
this.orphans = new OrphanRegistry(
|
|
34066
|
+
this.orphans = new OrphanRegistry(join24(config2.dataDir, "active-runs.json"));
|
|
33934
34067
|
this.runs = new RunSupervisor(config2, this.logger, reporter, this.orphans);
|
|
33935
34068
|
}
|
|
33936
34069
|
config;
|
|
@@ -34703,7 +34836,7 @@ async function runService(options = {}) {
|
|
|
34703
34836
|
}
|
|
34704
34837
|
|
|
34705
34838
|
// src/index.ts
|
|
34706
|
-
var { currentInstallation, installShared, ensureIdle, compareVersions: compareVersions2 } = createRequire(import.meta.url)(
|
|
34839
|
+
var { currentInstallation, installShared, ensureIdle, compareVersions: compareVersions2 } = createRequire(import.meta.url)(join25(agentPackageRoot(), "scripts", "installation.cjs"));
|
|
34707
34840
|
async function run() {
|
|
34708
34841
|
try {
|
|
34709
34842
|
await runService();
|
|
@@ -34830,7 +34963,7 @@ async function update(args) {
|
|
|
34830
34963
|
if (customConfig) process.env.TOC_OCRA_CONFIG = resolve9(customConfig);
|
|
34831
34964
|
await ensureIdle();
|
|
34832
34965
|
const npmPath = resolveCliCommand("npm");
|
|
34833
|
-
const temporary = mkdtempSync(
|
|
34966
|
+
const temporary = mkdtempSync(join25(tmpdir4(), "toc-ocra-update-"));
|
|
34834
34967
|
try {
|
|
34835
34968
|
const metadataResponse = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`, { headers: { accept: "application/json", "cache-control": "no-cache" }, signal: AbortSignal.timeout(15e3) });
|
|
34836
34969
|
if (!metadataResponse.ok) throw new Error("\u65E0\u6CD5\u8BFB\u53D6 npm \u6700\u65B0\u7248\u672C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
@@ -34857,7 +34990,7 @@ async function update(args) {
|
|
|
34857
34990
|
}
|
|
34858
34991
|
const archive = Buffer.concat(chunks);
|
|
34859
34992
|
if (`sha512-${createHash5("sha512").update(archive).digest("base64")}` !== dist.integrity) throw new Error("\u8BBE\u5907\u4EE3\u7406\u5B89\u88C5\u5305\u6821\u9A8C\u5931\u8D25\uFF0C\u5DF2\u505C\u6B62\u5347\u7EA7");
|
|
34860
|
-
const archivePath =
|
|
34993
|
+
const archivePath = join25(temporary, "toc-ocra.tgz");
|
|
34861
34994
|
writeFileSync3(archivePath, archive, { mode: 384 });
|
|
34862
34995
|
const npm = directLaunch2(npmPath, ["install", "--prefix", temporary, "--ignore-scripts", "--omit=dev", "--no-package-lock", "--no-audit", "--no-fund", "--prefer-online", "--registry=https://registry.npmjs.org", archivePath]);
|
|
34863
34996
|
const install = spawnSync(npm.executable, npm.args, { stdio: "inherit", shell: false, windowsHide: true });
|
|
@@ -34867,7 +35000,7 @@ async function update(args) {
|
|
|
34867
35000
|
return;
|
|
34868
35001
|
}
|
|
34869
35002
|
const previousVersion = agentVersion();
|
|
34870
|
-
const current = await installShared(
|
|
35003
|
+
const current = await installShared(join25(temporary, "node_modules", PACKAGE_NAME), { startService: existsSync8(defaultConfigPath()) });
|
|
34871
35004
|
if (current.version === previousVersion) process.stdout.write(`toc-ocra \u5DF2\u662F\u6700\u65B0\u7248\u672C ${current.version}
|
|
34872
35005
|
`);
|
|
34873
35006
|
else process.stdout.write(`toc-ocra \u5DF2\u5347\u7EA7\u5230 ${current.version}\uFF0C\u7EC8\u7AEF\u4E0E Echo \u63D2\u4EF6\u5171\u7528\u6B64\u7248\u672C
|
|
@@ -34895,7 +35028,7 @@ async function main() {
|
|
|
34895
35028
|
const selected = !shared || compareVersions2(agentVersion(), shared.version) > 0 ? await installShared(root2) : shared;
|
|
34896
35029
|
const same = (a, b) => process.platform === "win32" ? resolve9(a).toLowerCase() === resolve9(b).toLowerCase() : resolve9(a) === resolve9(b);
|
|
34897
35030
|
if (!same(selected.root, root2)) {
|
|
34898
|
-
await import(pathToFileURL2(
|
|
35031
|
+
await import(pathToFileURL2(join25(selected.root, "dist", "cli", "cli.mjs")).href);
|
|
34899
35032
|
return;
|
|
34900
35033
|
}
|
|
34901
35034
|
}
|