toc-ocra 0.3.9 → 0.3.11
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/README.md +5 -8
- package/dist/cli/cli.mjs +126 -101
- package/dist/plugin/renderer.js +1 -1
- package/dist/plugin/renderer.js.map +3 -3
- package/dist/service/agent.mjs +120 -94
- package/dist/src/acp/acp-launch-specs.d.ts +1 -1
- package/dist/src/acp/acp-launch-specs.js +0 -77
- package/dist/src/acp/acp-launch-specs.js.map +1 -1
- package/dist/src/acp/acp-model-catalog-probe.js +1 -1
- package/dist/src/acp/acp-model-catalog-probe.js.map +1 -1
- package/dist/src/index.js +4 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/platform/posix.js +8 -1
- package/dist/src/platform/posix.js.map +1 -1
- package/dist/src/platform/win32.js +84 -12
- package/dist/src/platform/win32.js.map +1 -1
- package/dist/src/providers/cli-specs.js +0 -11
- package/dist/src/providers/cli-specs.js.map +1 -1
- package/dist/src/providers/detection.js +10 -6
- package/dist/src/providers/detection.js.map +1 -1
- package/dist/src/providers/provider.js +1 -1
- package/dist/src/providers/provider.js.map +1 -1
- package/dist/src/runtime/agent-service.js +4 -2
- package/dist/src/runtime/agent-service.js.map +1 -1
- package/dist/src/shared/node-cli-command-resolution.js +5 -1
- package/dist/src/shared/node-cli-command-resolution.js.map +1 -1
- package/locales/en.json +1 -0
- package/locales/zh-CN.json +1 -0
- package/package.json +1 -1
- package/scripts/service.mjs +48 -12
- package/dist/src/providers/acp/acp-agents.d.ts +0 -14
- package/dist/src/providers/acp/acp-agents.js +0 -55
- package/dist/src/providers/acp/acp-agents.js.map +0 -1
package/README.md
CHANGED
|
@@ -48,8 +48,8 @@ node dist/src/index.js run
|
|
|
48
48
|
|
|
49
49
|
**其他电脑**(一条命令接入)
|
|
50
50
|
|
|
51
|
-
1. 选择系统(Linux / macOS / Windows)和设备名,插件在当前工作空间创建设备、生成配对码,并给出一条命令,例如 `npm install -g toc-ocra@latest && toc-ocra setup --code ABCD-EFGH --server https://echo.example.com`(Windows PowerShell:`npm install -g toc-ocra@latest; if ($?) { toc-ocra setup ... }
|
|
52
|
-
2. `toc-ocra setup` = 配对 + 安装后台服务(macOS LaunchAgent / Linux systemd 用户服务 / Windows
|
|
51
|
+
1. 选择系统(Linux / macOS / Windows)和设备名,插件在当前工作空间创建设备、生成配对码,并给出一条命令,例如 `npm install -g toc-ocra@latest && toc-ocra setup --code ABCD-EFGH --server https://echo.example.com`(Windows PowerShell:`npm.cmd install -g toc-ocra@latest; if ($?) { toc-ocra.cmd setup ... }`,使用 `.cmd` 避免 PowerShell 拦截 npm 的 `.ps1` 启动脚本)。
|
|
52
|
+
2. `toc-ocra setup` = 配对 + 安装后台服务(macOS LaunchAgent / Linux systemd 用户服务 / Windows 计划任务)。后台服务使用配对时实际保存的配置文件和数据目录,包括 `--config`、`TOC_OCRA_CONFIG`、`TOC_OCRA_DATA_DIR`;安装完成前会确认服务版本、设备身份和服务器绑定地址,启动失败或读取了其他配置时会报错。插件轮询到新凭据且在线后显示「已匹配」。
|
|
53
53
|
3. 「接收任务」开关调用 `PUT /api/devices/:id/enabled`:关闭即停用,保留配对、不再派发任务,重新打开立即恢复,不需要操作那台电脑。彻底卸载在那台电脑执行 `toc-ocra service:uninstall`。
|
|
54
54
|
4. 服务器地址必须能被那台电脑访问,填 `127.0.0.1` / `localhost` 时插件会提示。
|
|
55
55
|
|
|
@@ -103,6 +103,8 @@ kiro-cli chat --no-interactive --trust-all-tools --model gpt-5.6-luna --effort h
|
|
|
103
103
|
|
|
104
104
|
数据目录:macOS `~/Library/Application Support/toc-ocra`,Linux `~/.local/state/toc-ocra`,Windows `%APPDATA%\toc-ocra`。与旧的 `echo-cli-agent` 互不影响,可以同时安装。
|
|
105
105
|
|
|
106
|
+
Windows CLI 探测会读取系统和用户 PATH、实际的 `%APPDATA%` / `%LOCALAPPDATA%`、npm 自定义 prefix、pnpm / NVM / fnm / Volta / Scoop 目录,并从当前用户安装的 ChatGPT / Codex 应用资源中查找内置 `codex.exe`。用户 PATH 优先于应用内置 CLI。指定 `TOC_OCRA_CODEX_PATH` 等变量时,探测与执行共用该路径;配置失效时,`toc-ocra doctor` 会指出变量名和路径。插件连接本机服务后会立即尝试绑定当前服务器,自动绑定失败会显示具体原因。
|
|
107
|
+
|
|
106
108
|
## 设计要点
|
|
107
109
|
|
|
108
110
|
- **不保持长连接**:每 30 秒一次心跳,另有一个长轮询拉指令(有指令立即返回,最长等 25 秒)。超过 90 秒没有心跳,服务端判定设备离线。
|
|
@@ -124,11 +126,6 @@ kiro-cli chat --no-interactive --trust-all-tools --model gpt-5.6-luna --effort h
|
|
|
124
126
|
- CLI 自己的扩展和怪癖写在 `acp/acp-dialects/`(错误文字、工具名、shell 输出格式、私有通知、模型档位),没有就是 `GENERIC_ACP_DIALECT`。
|
|
125
127
|
- 模型列表(`acp/acp-model-catalog-probe.ts`):有自己读法的 CLI 用原来的读取器;只在会话里列模型的(如 OMP)开一个临时会话读选项,用完删除会话或删掉临时目录。
|
|
126
128
|
- **现在的 ACP 行**:Kiro(`kiro-cli acp`)、Gemini(`gemini --acp`)、Grok(`grok agent stdio`)、OpenCode(`opencode acp`,≥ 1.18.31 / 2.0.14)、OMP(`omp acp`,≥ 17.0.5)跑任务和实时聊天;Claude Code、Codex 任务仍用原生驱动,实时聊天走 Lody 的 ACP 适配器。Grok、OpenCode、OMP 的参数、环境、版本下限和 dialect 来自 Orca。
|
|
127
|
-
- **国内 CLI 的 ACP 行**(命令来自各家文档和 acpx 的 agent 注册表):Qwen Code(`qwen --acp`,每轮固定 `--approval-mode default`,完全访问用 `yolo`;它默认的 Auto 模式会自己批准)、Kimi Code(`kimi acp`,先在终端 `/login`)、Qoder CLI(`qodercli --acp`,终端登录或 `QODER_PERSONAL_ACCESS_TOKEN`)、Qoder CN CLI(`qoderclicn --acp`)、CodeBuddy Code(`codebuddy --acp`,国内版 `CODEBUDDY_API_KEY` 配 `CODEBUDDY_INTERNET_ENVIRONMENT=internal`)、TRAE CLI(`traecli acp serve`,不认同名的 `trae-cli`)、MiMo Code(`mimo acp`,OpenCode 衍生,用 OpenCode 的 dialect 和 `MIMOCODE_` 环境变量)、DeepSeek Harness(`dsh --profile acp`)。
|
|
128
|
-
- 实测(2026-11,未登录):Qwen Code 0.26.5、Kimi Code 2.4.1、Qoder CLI / Qoder CN CLI 1.1.81、CodeBuddy Code 2.179.1、DeepSeek Harness 0.2.1-rc.5 都能按上面的命令启动 ACP,未登录时报“未登录”。各家声明的登录方式都要在终端里交互(Qoder 的 `qodercli-login` 未登录时 `authenticate` 不返回),所以一律不替用户登录。MiMo Code、TRAE CLI 没有装来测。
|
|
129
|
-
- 这些 CLI 的模式 id 没有文档,都不设绕过参数和 CLI 自己的模式:每个权限级别由驱动回答权限请求来执行,完全访问逐个批准。CLI 自己的配置设成全自动时它不再发请求,只读级别就拦不住。
|
|
130
|
-
- 模型经 ACP 设置(`session/set_model` 或 model 选项);模型列表从临时会话读,CLI 不支持 `session/delete` 时报“不能删除会话”而不留下会话(Kimi、Qoder 支持;Qwen、CodeBuddy 目前不支持,用 CLI 自己的默认模型)。DeepSeek Harness 明确不支持删除,不读模型列表。
|
|
131
|
-
- iFlow CLI 已于 2026-04-17 停止服务,ZCode(智谱)没有官方 ACP,都没有加。
|
|
132
129
|
- **回退**:`TOC_OCRA_<ID>_DRIVER=legacy`(如 `TOC_OCRA_GROK_DRIVER=legacy`)改回原来的驱动;装的版本低于行里的最低版本时自动用原来的驱动,也不提供实时聊天。原来的 Gemini、Grok、OpenCode 驱动不支持受限权限。
|
|
133
130
|
- 其余 CLI(Codex、Claude 的任务)一个文件解析自己的 JSON 输出。ACP 下提示词走 stdin 的 JSON,不受命令行长度限制;会话 ID 由 `session/new` 直接返回;原会话不存在时同一进程内改开新会话。
|
|
134
131
|
- **实时聊天(直接回复)走常驻 ACP 连接**(`src/acp/`,对应 Lody 的 `AgentClient` + 回合运行时):每个聊天会话一个长期运行的 ACP 进程,`initialize` 只做一次,之后每轮只发 `session/prompt`,回合以 `stopReason` 结束,不再是“一轮一个进程、进程退出才算结束”。
|
|
@@ -140,7 +137,7 @@ kiro-cli chat --no-interactive --trust-all-tools --model gpt-5.6-luna --effort h
|
|
|
140
137
|
- **统一错误**:`src/providers/cli-failure.ts` 定义失败类型(未安装、未登录、额度用完、限流、模型不可用、会话丢失、超时、卡住等)和中文提示;各 CLI 只用 `failureRules` 把自己的报错对应到类型。回报里带 `failure_kind`。
|
|
141
138
|
- **本机冒烟检查**:`toc-ocra smoke` 对每个已安装、能运行的 CLI 发一句最小提示,经过和任务完全相同的执行器与驱动,逐个给出结果和失败类型;`--full` 再测执行命令、续接会话、原会话不存在三种情况;也可指定 CLI,如 `toc-ocra smoke kiro codex`。`toc-ocra doctor --smoke` 在诊断信息后附带这项检查。
|
|
142
139
|
- **录制回放测试**:`toc-ocra smoke --full --record <目录>` 把每轮与 CLI 的原始通信存成 JSONL,`node scripts/import-recordings.mjs <目录>` 导入 `tests/recordings/`。`tests/recordings.test.ts` 把录制内容当作 CLI 回放,跑真实的执行器和驱动,结果和运行日志必须与录制时一致;新增 CLI 的覆盖只需要录制,不用写测试代码。也可在运行中设置 `TOC_OCRA_RECORD_DIR` 录制任意一轮。
|
|
143
|
-
- **加一个 CLI**:先在 `cli-specs.ts` 加一行(检测用)。支持 ACP 的,再在 `acp/acp-launch-specs.ts` 加一行,任务、实时聊天、模型列表和运行设置就都有了;只有它扩展或偏离协议时才写 dialect。不支持 ACP 的,在 `src/providers/cli/` 新增一个文件实现 `HeadlessProvider`,`buildLaunch` 里调用 `launchCli({ spec, args, prompt })`,在 `registry.ts` 挂上。不要在 provider 里判断操作系统。服务端和网页的 CLI 类型列表(`agent_type
|
|
140
|
+
- **加一个 CLI**:先在 `cli-specs.ts` 加一行(检测用)。支持 ACP 的,再在 `acp/acp-launch-specs.ts` 加一行,任务、实时聊天、模型列表和运行设置就都有了;只有它扩展或偏离协议时才写 dialect。不支持 ACP 的,在 `src/providers/cli/` 新增一个文件实现 `HeadlessProvider`,`buildLaunch` 里调用 `launchCli({ spec, args, prompt })`,在 `registry.ts` 挂上。不要在 provider 里判断操作系统。服务端和网页的 CLI 类型列表(`agent_type`)目前是固定的六种,新的 CLI 类型要在那边一起加上。
|
|
144
141
|
|
|
145
142
|
### 记忆(Nowledge Mem)
|
|
146
143
|
对应 Lody 的记忆系统。记忆本身保存在设备上的 [Nowledge Mem](https://mem.nowledge.co) 里,Echo 只记录每台设备导入了哪些记忆体(Agent 身份),角色绑定其中一个,会话创建时从角色复制过来。
|
package/dist/cli/cli.mjs
CHANGED
|
@@ -4579,7 +4579,7 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
4579
4579
|
import { existsSync as existsSync7, mkdtempSync, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
4580
4580
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
4581
4581
|
import { createRequire } from "node:module";
|
|
4582
|
-
import { dirname as
|
|
4582
|
+
import { dirname as dirname11, join as join23, 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
|
|
@@ -24868,7 +24868,14 @@ function createPosixPlatform(id) {
|
|
|
24868
24868
|
// Why: pnpm uses platform-specific global bin directories that differ
|
|
24869
24869
|
// from npm's ~/.local/bin.
|
|
24870
24870
|
id === "darwin" ? join4(home, "Library", "pnpm") : join4(home, ".local", "share", "pnpm"),
|
|
24871
|
-
join4(home, ".yarn", "bin")
|
|
24871
|
+
join4(home, ".yarn", "bin"),
|
|
24872
|
+
// ChatGPT ships the Codex CLI inside the app bundle. GUI-launched
|
|
24873
|
+
// services do not inherit the app's private PATH entry, so include the
|
|
24874
|
+
// stable bundle bin location when resolving installed CLIs on macOS.
|
|
24875
|
+
...id === "darwin" ? [
|
|
24876
|
+
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin",
|
|
24877
|
+
join4(home, "Applications", "ChatGPT.app", "Contents", "Resources", "codex-cli", "bin")
|
|
24878
|
+
] : []
|
|
24872
24879
|
],
|
|
24873
24880
|
fallbackBinDirectories: (home) => ["/opt/homebrew/bin", "/usr/local/bin", join4(home, ".local", "bin")],
|
|
24874
24881
|
normalizeEnvironment: (env) => ({ ...env }),
|
|
@@ -24899,11 +24906,12 @@ function createPosixPlatform(id) {
|
|
|
24899
24906
|
|
|
24900
24907
|
// src/platform/win32.ts
|
|
24901
24908
|
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
24902
|
-
import { readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
24903
|
-
import { join as join5, win32 } from "node:path";
|
|
24909
|
+
import { readFileSync as readFileSync3, readdirSync, statSync as statSync2 } from "node:fs";
|
|
24910
|
+
import { dirname as dirname2, join as join5, win32 } from "node:path";
|
|
24904
24911
|
var SYSTEM_ROOT = process.env.SystemRoot || process.env.windir || "C:\\Windows";
|
|
24905
24912
|
var POWERSHELL = join5(SYSTEM_ROOT, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
24906
24913
|
var HELPER_TIMEOUT_MS = 5e3;
|
|
24914
|
+
var bundledCliDirectories = [];
|
|
24907
24915
|
var SHIM_TARGET_RE = /%~?dp0%?\\?([^"%\r\n]+)/gi;
|
|
24908
24916
|
var SHIM_TARGET_EXTENSIONS = /\.(c|m)?js$|\.exe$/i;
|
|
24909
24917
|
var MAX_SHIM_BYTES = 64 * 1024;
|
|
@@ -24952,6 +24960,47 @@ function runPowerShell(script) {
|
|
|
24952
24960
|
function expandVariables(value) {
|
|
24953
24961
|
return value.replace(/%([^%;]+)%/g, (whole2, name) => process.env[name] ?? whole2);
|
|
24954
24962
|
}
|
|
24963
|
+
async function bundledCodexDirectories() {
|
|
24964
|
+
const local = process.env.LOCALAPPDATA;
|
|
24965
|
+
const roots = [local, process.env.ProgramFiles, process.env["ProgramFiles(x86)"]].filter((value) => Boolean(value)).flatMap((base) => ["ChatGPT", "Codex", join5("Programs", "ChatGPT"), join5("Programs", "Codex")].map((name) => join5(base, name)));
|
|
24966
|
+
const result = await runPowerShell("@(Get-AppxPackage -ErrorAction SilentlyContinue | Where-Object { $_.Name -match 'OpenAI|ChatGPT|Codex' } | Select-Object -ExpandProperty InstallLocation) | ConvertTo-Json -Compress");
|
|
24967
|
+
if (result.ok) {
|
|
24968
|
+
try {
|
|
24969
|
+
const locations = JSON.parse(result.stdout.trim());
|
|
24970
|
+
for (const location of Array.isArray(locations) ? locations : [locations]) {
|
|
24971
|
+
if (typeof location === "string" && location) roots.push(location);
|
|
24972
|
+
}
|
|
24973
|
+
} catch {
|
|
24974
|
+
}
|
|
24975
|
+
}
|
|
24976
|
+
const found = /* @__PURE__ */ new Set();
|
|
24977
|
+
for (const root2 of new Set(roots)) {
|
|
24978
|
+
const pending = ["resources", join5("app", "resources"), "codex-cli", join5("app", "codex-cli")].map((relative4) => ({ directory: join5(root2, relative4), depth: 0 }));
|
|
24979
|
+
for (let visited = 0; pending.length && visited < 256; visited++) {
|
|
24980
|
+
const { directory, depth } = pending.shift();
|
|
24981
|
+
try {
|
|
24982
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
24983
|
+
const file2 = join5(directory, entry.name);
|
|
24984
|
+
if (entry.isFile() && entry.name.toLowerCase() === "codex.exe") found.add(dirname2(file2));
|
|
24985
|
+
else if (entry.isDirectory() && depth < 5) pending.push({ directory: file2, depth: depth + 1 });
|
|
24986
|
+
}
|
|
24987
|
+
} catch {
|
|
24988
|
+
}
|
|
24989
|
+
}
|
|
24990
|
+
}
|
|
24991
|
+
return [...found];
|
|
24992
|
+
}
|
|
24993
|
+
function npmPrefix(home) {
|
|
24994
|
+
let prefix = process.env.npm_config_prefix ?? process.env.NPM_CONFIG_PREFIX;
|
|
24995
|
+
if (!prefix) {
|
|
24996
|
+
try {
|
|
24997
|
+
prefix = /^\s*prefix\s*=\s*(.+?)\s*$/mi.exec(readFileSync3(process.env.NPM_CONFIG_USERCONFIG ?? join5(home, ".npmrc"), "utf8"))?.[1];
|
|
24998
|
+
} catch {
|
|
24999
|
+
}
|
|
25000
|
+
}
|
|
25001
|
+
if (!prefix) return void 0;
|
|
25002
|
+
return expandVariables(prefix.replace(/^(["'])(.*)\1$/, "$2").replace(/^~(?=[\\/]|$)/, home).replace(/\$\{([^}]+)\}/g, (whole2, name) => process.env[name] ?? whole2));
|
|
25003
|
+
}
|
|
24955
25004
|
async function readRegistryEnvironment() {
|
|
24956
25005
|
const names = [...new Set(PROXY_KEYS.map((key) => key.toLowerCase()))];
|
|
24957
25006
|
const script = [
|
|
@@ -24962,7 +25011,8 @@ async function readRegistryEnvironment() {
|
|
|
24962
25011
|
"$v=[Environment]::GetEnvironmentVariable($k,'User');if(-not $v){$v=[Environment]::GetEnvironmentVariable($k,'Machine')};if($v){$r.proxy[$k]=$v}};",
|
|
24963
25012
|
"$r|ConvertTo-Json -Compress -Depth 4"
|
|
24964
25013
|
].join("");
|
|
24965
|
-
const result = await runPowerShell(script);
|
|
25014
|
+
const [result, bundled] = await Promise.all([runPowerShell(script), bundledCodexDirectories()]);
|
|
25015
|
+
bundledCliDirectories = bundled;
|
|
24966
25016
|
if (!result.ok) return { ok: false, segments: [], failureReason: result.reason };
|
|
24967
25017
|
let parsed;
|
|
24968
25018
|
try {
|
|
@@ -24971,7 +25021,7 @@ async function readRegistryEnvironment() {
|
|
|
24971
25021
|
return { ok: false, segments: [], failureReason: "empty_path" };
|
|
24972
25022
|
}
|
|
24973
25023
|
const raw = (Array.isArray(parsed.path) ? parsed.path : [parsed.path]).filter((value) => typeof value === "string");
|
|
24974
|
-
const segments = [...new Set(raw.flatMap((value) => value.split(";")).map((segment) => expandVariables(segment.trim())).filter(Boolean))];
|
|
25024
|
+
const segments = [...new Set(raw.flatMap((value) => value.split(";")).map((segment) => expandVariables(segment.trim().replace(/^"(.*)"$/, "$1"))).filter(Boolean))];
|
|
24975
25025
|
if (segments.length === 0) return { ok: false, segments: [], failureReason: "empty_path" };
|
|
24976
25026
|
const proxyEnv = Object.fromEntries(Object.entries(parsed.proxy ?? {}).filter((entry) => typeof entry[1] === "string" && entry[1].length > 0));
|
|
24977
25027
|
return { ok: true, segments, proxyEnv, failureReason: "none" };
|
|
@@ -24986,14 +25036,29 @@ var win32Platform = {
|
|
|
24986
25036
|
return false;
|
|
24987
25037
|
}
|
|
24988
25038
|
},
|
|
24989
|
-
userBinDirectories: (home) =>
|
|
24990
|
-
|
|
24991
|
-
|
|
24992
|
-
|
|
24993
|
-
|
|
24994
|
-
|
|
24995
|
-
|
|
24996
|
-
|
|
25039
|
+
userBinDirectories: (home) => {
|
|
25040
|
+
const roaming = process.env.APPDATA ?? join5(home, "AppData", "Roaming");
|
|
25041
|
+
const local = process.env.LOCALAPPDATA ?? join5(home, "AppData", "Local");
|
|
25042
|
+
return [
|
|
25043
|
+
// Native Windows CLI installers use this directory even without PATH.
|
|
25044
|
+
join5(home, ".local", "bin"),
|
|
25045
|
+
join5(roaming, "npm"),
|
|
25046
|
+
join5(roaming, "pnpm"),
|
|
25047
|
+
join5(local, "pnpm"),
|
|
25048
|
+
join5(local, "Yarn", "bin"),
|
|
25049
|
+
join5(local, "Microsoft", "WindowsApps"),
|
|
25050
|
+
join5(local, "Microsoft", "WinGet", "Links"),
|
|
25051
|
+
join5(home, "npm-global"),
|
|
25052
|
+
join5(process.env.SCOOP ?? join5(home, "scoop"), "shims"),
|
|
25053
|
+
npmPrefix(home),
|
|
25054
|
+
process.env.PNPM_HOME,
|
|
25055
|
+
process.env.NVM_SYMLINK,
|
|
25056
|
+
process.env.NVM_HOME,
|
|
25057
|
+
process.env.FNM_MULTISHELL_PATH,
|
|
25058
|
+
process.env.VOLTA_HOME && join5(process.env.VOLTA_HOME, "bin"),
|
|
25059
|
+
...bundledCliDirectories
|
|
25060
|
+
].filter((value) => Boolean(value));
|
|
25061
|
+
},
|
|
24997
25062
|
fallbackBinDirectories: (home) => [join5(home, ".local", "bin")],
|
|
24998
25063
|
normalizeEnvironment(env) {
|
|
24999
25064
|
const copy = { ...env };
|
|
@@ -25081,17 +25146,6 @@ var SOURCES = [
|
|
|
25081
25146
|
{ id: "opencode", label: "OpenCode", command: "opencode", versionArguments: ["--version"], installHint: "npm i -g opencode-ai" },
|
|
25082
25147
|
{ id: "kiro", label: "Kiro CLI", aliases: ["kiro-cli"], command: "kiro-cli", commandAliases: ["kiro"], versionArguments: ["--version"], promptStdin: "omit", restrictedPermission: true },
|
|
25083
25148
|
{ id: "omp", label: "OMP", command: "omp", versionArguments: ["--version"] },
|
|
25084
|
-
// Chinese coding CLIs that serve ACP themselves (acp/acp-launch-specs.ts). Only
|
|
25085
|
-
// the main command is detected: launches use it, never an alias.
|
|
25086
|
-
{ id: "qwen", label: "Qwen Code", aliases: ["qwen-code"], command: "qwen", versionArguments: ["--version"], installHint: "npm i -g @qwen-code/qwen-code" },
|
|
25087
|
-
{ id: "kimi", label: "Kimi Code", aliases: ["kimi-code"], command: "kimi", versionArguments: ["--version"] },
|
|
25088
|
-
{ id: "qoder", label: "Qoder CLI", command: "qodercli", versionArguments: ["--version"] },
|
|
25089
|
-
{ id: "qoder-cn", label: "Qoder CN CLI", aliases: ["qodercn"], command: "qoderclicn", versionArguments: ["--version"], installHint: "npm i -g @qodercn-ai/qoderclicn" },
|
|
25090
|
-
{ id: "codebuddy", label: "CodeBuddy Code", aliases: ["codebuddy-code"], command: "codebuddy", versionArguments: ["--version"], installHint: "npm i -g @tencent-ai/codebuddy-code" },
|
|
25091
|
-
// TRAE CN's own name: `trae-cli` is also installed by the unrelated bytedance/trae-agent.
|
|
25092
|
-
{ id: "trae", label: "TRAE CLI", command: "traecli", versionArguments: ["--version"] },
|
|
25093
|
-
{ id: "mimo", label: "MiMo Code", aliases: ["mimo-code"], command: "mimo", versionArguments: ["--version"] },
|
|
25094
|
-
{ id: "dsh", label: "DeepSeek Harness", aliases: ["deepseek", "deepseek-harness"], command: "dsh", versionArguments: ["--version"] },
|
|
25095
25149
|
{ id: "cursor", label: "Cursor Agent", command: "cursor-agent", commandAliases: ["cursor"] },
|
|
25096
25150
|
{ id: "copilot", label: "GitHub Copilot CLI", command: "copilot" },
|
|
25097
25151
|
{ id: "aider", label: "Aider", command: "aider" },
|
|
@@ -25131,18 +25185,18 @@ function detectedCliVersion(id) {
|
|
|
25131
25185
|
// src/providers/provider.ts
|
|
25132
25186
|
import { realpathSync } from "node:fs";
|
|
25133
25187
|
import { homedir as homedir3 } from "node:os";
|
|
25134
|
-
import { delimiter as delimiter4, dirname as
|
|
25188
|
+
import { delimiter as delimiter4, dirname as dirname4 } from "node:path";
|
|
25135
25189
|
|
|
25136
25190
|
// src/shared/node-cli-command-resolution.ts
|
|
25137
|
-
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
25191
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
|
|
25138
25192
|
import { homedir as homedir2 } from "node:os";
|
|
25139
|
-
import { dirname as
|
|
25193
|
+
import { dirname as dirname3, join as join6 } from "node:path";
|
|
25140
25194
|
function adapterOf(options) {
|
|
25141
25195
|
return platformFor(options.platform ?? process.platform);
|
|
25142
25196
|
}
|
|
25143
25197
|
function splitPath(platform2, pathEnv) {
|
|
25144
25198
|
if (!pathEnv) return [];
|
|
25145
|
-
return pathEnv.split(platform2.id === "win32" ? ";" : ":").map((entry) => entry.trim()).filter(Boolean);
|
|
25199
|
+
return pathEnv.split(platform2.id === "win32" ? ";" : ":").map((entry) => entry.trim().replace(/^"(.*)"$/, "$1")).filter(Boolean);
|
|
25146
25200
|
}
|
|
25147
25201
|
function parseVersionSegment(raw) {
|
|
25148
25202
|
return raw.replace(/^v/i, "").split(".").map((segment) => Number.parseInt(segment, 10)).map((segment) => Number.isFinite(segment) ? segment : 0);
|
|
@@ -25176,12 +25230,12 @@ function getBaseVersionManagerDirectories(platform2, homePath) {
|
|
|
25176
25230
|
function getNvmVersionDirectories(homePath) {
|
|
25177
25231
|
const nvmVersionsDir = join6(homePath, ".nvm", "versions", "node");
|
|
25178
25232
|
if (!existsSync3(nvmVersionsDir)) return [];
|
|
25179
|
-
return
|
|
25233
|
+
return readdirSync2(nvmVersionsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort(compareVersionDesc).map((entry) => join6(nvmVersionsDir, entry, "bin"));
|
|
25180
25234
|
}
|
|
25181
25235
|
function getVersionManagerDirectories(platform2, homePath, executableNames) {
|
|
25182
25236
|
const directories = getBaseVersionManagerDirectories(platform2, homePath);
|
|
25183
25237
|
const firstNvmMatch = findFirstExecutable(platform2, getNvmVersionDirectories(homePath), executableNames);
|
|
25184
|
-
if (firstNvmMatch) directories.unshift(
|
|
25238
|
+
if (firstNvmMatch) directories.unshift(dirname3(firstNvmMatch));
|
|
25185
25239
|
return directories;
|
|
25186
25240
|
}
|
|
25187
25241
|
function resolveCliCommand(commandName, options = {}) {
|
|
@@ -25189,6 +25243,7 @@ function resolveCliCommand(commandName, options = {}) {
|
|
|
25189
25243
|
}
|
|
25190
25244
|
function findCliCommand(commandName, options = {}) {
|
|
25191
25245
|
const platform2 = adapterOf(options);
|
|
25246
|
+
if (/[\\/]/.test(commandName)) return platform2.isRunnableFile(commandName) ? commandName : null;
|
|
25192
25247
|
const executableNames = platform2.executableNames(commandName);
|
|
25193
25248
|
const pathEnv = options.pathEnv ?? process.env.PATH ?? process.env.Path ?? null;
|
|
25194
25249
|
const pathCandidate = findFirstExecutable(platform2, splitPath(platform2, pathEnv), executableNames);
|
|
@@ -25255,9 +25310,9 @@ function toolCallRows(name, path) {
|
|
|
25255
25310
|
function providerEnvironment() {
|
|
25256
25311
|
const env = currentPlatform.normalizeEnvironment(process.env);
|
|
25257
25312
|
const commandPaths = [
|
|
25258
|
-
|
|
25259
|
-
...getVersionManagerBinPaths(),
|
|
25313
|
+
dirname4(process.execPath),
|
|
25260
25314
|
env.PATH,
|
|
25315
|
+
...getVersionManagerBinPaths(),
|
|
25261
25316
|
...currentPlatform.fallbackBinDirectories(homedir3())
|
|
25262
25317
|
].filter((value) => Boolean(value));
|
|
25263
25318
|
env.PATH = [...new Set(commandPaths)].join(delimiter4);
|
|
@@ -25325,7 +25380,7 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
25325
25380
|
import { statSync as statSync3 } from "node:fs";
|
|
25326
25381
|
import { chmod as chmod3, mkdir as mkdir3, readFile as readFile2, rename as rename3, stat, writeFile as writeFile3 } from "node:fs/promises";
|
|
25327
25382
|
import { homedir as homedir4 } from "node:os";
|
|
25328
|
-
import { dirname as
|
|
25383
|
+
import { dirname as dirname5, isAbsolute, join as join7, resolve as resolve2 } from "node:path";
|
|
25329
25384
|
var codexHome = () => process.env.CODEX_HOME?.trim() || join7(homedir4(), ".codex");
|
|
25330
25385
|
var BUNDLED_TIMEOUT_MS = 1e4;
|
|
25331
25386
|
function configuredCatalogPath(config2, home = codexHome()) {
|
|
@@ -25434,7 +25489,7 @@ async function rebuild() {
|
|
|
25434
25489
|
return;
|
|
25435
25490
|
}
|
|
25436
25491
|
const path = overlayPath();
|
|
25437
|
-
await mkdir3(
|
|
25492
|
+
await mkdir3(dirname5(path), { recursive: true, mode: 448 });
|
|
25438
25493
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
25439
25494
|
await writeFile3(temporary, JSON.stringify(filled), { mode: 384 });
|
|
25440
25495
|
await rename3(temporary, path);
|
|
@@ -25968,10 +26023,6 @@ var MODEL_SOURCES = {
|
|
|
25968
26023
|
}
|
|
25969
26024
|
};
|
|
25970
26025
|
|
|
25971
|
-
// src/acp/acp-dialects/acp-dialect.ts
|
|
25972
|
-
var GENERIC_ACP_DIALECT = {};
|
|
25973
|
-
var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
25974
|
-
|
|
25975
26026
|
// src/acp/acp-dialects/gemini-dialect.ts
|
|
25976
26027
|
var GEMINI_FAILURE_RULES = [
|
|
25977
26028
|
{ kind: "sessionMissing", pattern: /session[^\n]{0,60}(?:not found|does not exist)|no session found|invalid session/i },
|
|
@@ -25979,6 +26030,9 @@ var GEMINI_FAILURE_RULES = [
|
|
|
25979
26030
|
];
|
|
25980
26031
|
var GEMINI_ACP_DIALECT = { failureRules: GEMINI_FAILURE_RULES };
|
|
25981
26032
|
|
|
26033
|
+
// src/acp/acp-dialects/acp-dialect.ts
|
|
26034
|
+
var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
26035
|
+
|
|
25982
26036
|
// src/acp/acp-dialects/grok-dialect.ts
|
|
25983
26037
|
function modelEfforts(model) {
|
|
25984
26038
|
const meta3 = record2(model._meta);
|
|
@@ -26489,7 +26543,7 @@ import { spawn as spawn6 } from "node:child_process";
|
|
|
26489
26543
|
import { createHash } from "node:crypto";
|
|
26490
26544
|
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
|
|
26491
26545
|
import { copyFile, mkdir as mkdir4, rename as rename4, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
|
|
26492
|
-
import { dirname as
|
|
26546
|
+
import { dirname as dirname6, join as join11, resolve as resolve4 } from "node:path";
|
|
26493
26547
|
import { fileURLToPath } from "node:url";
|
|
26494
26548
|
var AcpRuntimeUnavailable = class extends Error {
|
|
26495
26549
|
constructor(message) {
|
|
@@ -26499,7 +26553,7 @@ var AcpRuntimeUnavailable = class extends Error {
|
|
|
26499
26553
|
};
|
|
26500
26554
|
var NPM_INSTALL_TIMEOUT_MS = 10 * 6e4;
|
|
26501
26555
|
function packageRoot() {
|
|
26502
|
-
let directory =
|
|
26556
|
+
let directory = dirname6(fileURLToPath(import.meta.url));
|
|
26503
26557
|
while (true) {
|
|
26504
26558
|
const path = resolve4(directory, "package.json");
|
|
26505
26559
|
if (existsSync4(path)) {
|
|
@@ -26508,7 +26562,7 @@ function packageRoot() {
|
|
|
26508
26562
|
} catch {
|
|
26509
26563
|
}
|
|
26510
26564
|
}
|
|
26511
|
-
const parent =
|
|
26565
|
+
const parent = dirname6(directory);
|
|
26512
26566
|
if (parent === directory) return void 0;
|
|
26513
26567
|
directory = parent;
|
|
26514
26568
|
}
|
|
@@ -26536,7 +26590,7 @@ var installs = /* @__PURE__ */ new Map();
|
|
|
26536
26590
|
function ensureClaudeRuntime(dataDir2) {
|
|
26537
26591
|
const entry = vendoredAdapter("claude");
|
|
26538
26592
|
if (!entry) return Promise.reject(new AcpRuntimeUnavailable("\u8FD9\u4E2A\u7248\u672C\u7684\u8BBE\u5907\u4EE3\u7406\u6CA1\u6709\u9644\u5E26 Claude ACP \u9002\u914D\u5668"));
|
|
26539
|
-
const manifestPath = join11(
|
|
26593
|
+
const manifestPath = join11(dirname6(entry), "runtime.json");
|
|
26540
26594
|
let manifest;
|
|
26541
26595
|
try {
|
|
26542
26596
|
manifest = JSON.parse(readFileSync4(manifestPath, "utf8"));
|
|
@@ -26659,32 +26713,6 @@ var OMP_LAUNCH_SPEC = {
|
|
|
26659
26713
|
// Its CLI listing includes disabled models, and it cannot delete sessions: list in a disposable session folder.
|
|
26660
26714
|
modelDiscovery: { kind: "session", sessionFolderArgs: (folder) => ["--session-dir", folder] }
|
|
26661
26715
|
};
|
|
26662
|
-
function plainAcpRow(agent, args, rest = {}) {
|
|
26663
|
-
return { agent, headless: "acp", args: () => [...args], dialect: GENERIC_ACP_DIALECT, modelDiscovery: { kind: "session" }, ...rest };
|
|
26664
|
-
}
|
|
26665
|
-
var QWEN_LAUNCH_SPEC = {
|
|
26666
|
-
agent: "qwen",
|
|
26667
|
-
headless: "acp",
|
|
26668
|
-
args: ({ access }) => ["--acp", "--approval-mode", access === "bypassPermissions" ? "yolo" : "default"],
|
|
26669
|
-
dialect: GEMINI_ACP_DIALECT,
|
|
26670
|
-
modelDiscovery: { kind: "session" }
|
|
26671
|
-
};
|
|
26672
|
-
var KIMI_LAUNCH_SPEC = plainAcpRow("kimi", ["acp"], {
|
|
26673
|
-
dialect: { failureRules: [{ kind: "notSignedIn", pattern: /LLM not set|send "?\/login/i }] }
|
|
26674
|
-
});
|
|
26675
|
-
var QODER_LAUNCH_SPEC = plainAcpRow("qoder", ["--acp"]);
|
|
26676
|
-
var QODER_CN_LAUNCH_SPEC = plainAcpRow("qoder-cn", ["--acp"]);
|
|
26677
|
-
var CODEBUDDY_LAUNCH_SPEC = plainAcpRow("codebuddy", ["--acp"]);
|
|
26678
|
-
var TRAE_LAUNCH_SPEC = plainAcpRow("trae", ["acp", "serve"]);
|
|
26679
|
-
var MIMO_LAUNCH_SPEC = plainAcpRow("mimo", ["acp"], {
|
|
26680
|
-
env: { MIMOCODE_CLIENT: "acp", MIMOCODE_ENABLE_QUESTION_TOOL: "false" },
|
|
26681
|
-
dialect: OPENCODE_ACP_DIALECT
|
|
26682
|
-
});
|
|
26683
|
-
var DSH_LAUNCH_SPEC = plainAcpRow("dsh", ["--profile", "acp"], {
|
|
26684
|
-
// Sessions open without a key; the first prompt then fails naming DEEPSEEK_API_KEY.
|
|
26685
|
-
dialect: { failureRules: [{ kind: "notSignedIn", pattern: /no API key for provider route/i }] },
|
|
26686
|
-
modelDiscovery: { kind: "unavailable", reason: "DeepSeek Harness \u7684 ACP \u4E0D\u80FD\u5220\u9664\u4F1A\u8BDD\uFF0C\u4E0D\u8BFB\u53D6\u6A21\u578B\u5217\u8868" }
|
|
26687
|
-
});
|
|
26688
26716
|
function installedCli(spec) {
|
|
26689
26717
|
const override = process.env[spec.overrideEnv]?.trim();
|
|
26690
26718
|
const found = override || findCliCommand(cliCommand(spec), { pathEnv: providerEnvironment().PATH ?? null });
|
|
@@ -26756,14 +26784,6 @@ var ACP_LAUNCH_SPECS = [
|
|
|
26756
26784
|
GROK_LAUNCH_SPEC,
|
|
26757
26785
|
OPENCODE_LAUNCH_SPEC,
|
|
26758
26786
|
OMP_LAUNCH_SPEC,
|
|
26759
|
-
QWEN_LAUNCH_SPEC,
|
|
26760
|
-
KIMI_LAUNCH_SPEC,
|
|
26761
|
-
QODER_LAUNCH_SPEC,
|
|
26762
|
-
QODER_CN_LAUNCH_SPEC,
|
|
26763
|
-
CODEBUDDY_LAUNCH_SPEC,
|
|
26764
|
-
TRAE_LAUNCH_SPEC,
|
|
26765
|
-
MIMO_LAUNCH_SPEC,
|
|
26766
|
-
DSH_LAUNCH_SPEC,
|
|
26767
26787
|
CLAUDE_LAUNCH_SPEC,
|
|
26768
26788
|
CODEX_LAUNCH_SPEC
|
|
26769
26789
|
];
|
|
@@ -27428,7 +27448,7 @@ async function readSessionModels(row, clientVersion = "1") {
|
|
|
27428
27448
|
stderr: () => void 0
|
|
27429
27449
|
}, clientVersion);
|
|
27430
27450
|
try {
|
|
27431
|
-
if (!connection.deleteSession && !folderArgs.length) throw new Error(`${cli.label} \u4E0D\u80FD\u5220\u9664\u4F1A\u8BDD\uFF0C\
|
|
27451
|
+
if (!connection.deleteSession && !folderArgs.length) throw new Error(`${cli.label} \u4E0D\u80FD\u5220\u9664\u4F1A\u8BDD\uFF0C\u53EA\u80FD\u5728\u804A\u5929\u4E2D\u8BFB\u53D6\u6A21\u578B\u5217\u8868`);
|
|
27432
27452
|
const state = await connection.newSession(folder);
|
|
27433
27453
|
if (connection.deleteSession) await connection.removeSession(state.sessionId).catch(() => void 0);
|
|
27434
27454
|
const listed = sessionModels(state, row.dialect);
|
|
@@ -28046,7 +28066,7 @@ function isWriterConflict(message) {
|
|
|
28046
28066
|
}
|
|
28047
28067
|
|
|
28048
28068
|
// src/providers/cli/claude.ts
|
|
28049
|
-
import { readdirSync as
|
|
28069
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync5 } from "node:fs";
|
|
28050
28070
|
import { homedir as homedir8 } from "node:os";
|
|
28051
28071
|
import { join as join14 } from "node:path";
|
|
28052
28072
|
var CLAUDE = requireCliSpec("claude");
|
|
@@ -28063,13 +28083,13 @@ function claudeTranscriptPath(sessionId) {
|
|
|
28063
28083
|
for (const root2 of claudeProjectRoots()) {
|
|
28064
28084
|
let projects;
|
|
28065
28085
|
try {
|
|
28066
|
-
projects =
|
|
28086
|
+
projects = readdirSync3(root2);
|
|
28067
28087
|
} catch {
|
|
28068
28088
|
continue;
|
|
28069
28089
|
}
|
|
28070
28090
|
for (const project of projects) {
|
|
28071
28091
|
try {
|
|
28072
|
-
if (
|
|
28092
|
+
if (readdirSync3(join14(root2, project)).includes(file2)) return join14(root2, project, file2);
|
|
28073
28093
|
} catch {
|
|
28074
28094
|
}
|
|
28075
28095
|
}
|
|
@@ -29198,7 +29218,7 @@ function resolveDetectedProviderCommands(foundCommands, commands = DETECTION_COM
|
|
|
29198
29218
|
function probeVersion(path, args) {
|
|
29199
29219
|
if (args.length === 0) return Promise.resolve({});
|
|
29200
29220
|
return new Promise((resolve10) => {
|
|
29201
|
-
const launch = directLaunch2(path, args);
|
|
29221
|
+
const launch = directLaunch2(path, args, process.env.TOC_OCRA_NODE_PATH || process.execPath);
|
|
29202
29222
|
const child = spawn9(launch.executable, launch.args, { stdio: ["ignore", "pipe", "pipe"], shell: false, windowsHide: true });
|
|
29203
29223
|
let stdout = "";
|
|
29204
29224
|
let stderr = "";
|
|
@@ -29247,13 +29267,15 @@ var CliDetectionService = class {
|
|
|
29247
29267
|
const foundCommands = new Set(commands.filter((command) => resolved.get(command)?.found));
|
|
29248
29268
|
const detected = resolveDetectedProviderCommands(foundCommands, DETECTION_COMMANDS);
|
|
29249
29269
|
const providers2 = await Promise.all(CLI_CATALOG.map(async (config2) => {
|
|
29250
|
-
const
|
|
29251
|
-
const
|
|
29270
|
+
const override = process.env[config2.overrideEnv]?.trim();
|
|
29271
|
+
const unsupported = config2.detectUnsupportedRuntimes?.includes(process.platform) ?? false;
|
|
29272
|
+
const requiredPresent = (config2.detectRequiredCommands ?? []).every((command) => foundCommands.has(command));
|
|
29273
|
+
const matchedDetectionCommand = unsupported || !requiredPresent ? void 0 : override ? config2.detectCmd : detected.get(config2.id);
|
|
29274
|
+
const result = matchedDetectionCommand ? override ? resolveCliCommandDetailed(override) : resolved.get(matchedDetectionCommand) : void 0;
|
|
29252
29275
|
const executablePath = result?.found ? result.path : void 0;
|
|
29253
29276
|
const installed = Boolean(executablePath);
|
|
29254
|
-
const unsupported = config2.detectUnsupportedRuntimes?.includes(process.platform) ?? false;
|
|
29255
29277
|
const diagnostic = executablePath ? await probeVersion(executablePath, config2.versionArguments ?? []) : {};
|
|
29256
|
-
const detail = installed ? diagnostic.detail : unsupported ? "unsupported runtime" :
|
|
29278
|
+
const detail = installed ? diagnostic.detail : unsupported ? "unsupported runtime" : !requiredPresent ? "command or required command not found" : override && !result?.found ? `${config2.overrideEnv} \u6307\u5411\u7684\u7A0B\u5E8F\u4E0D\u5B58\u5728\uFF1A${override}` : "command not found";
|
|
29257
29279
|
return {
|
|
29258
29280
|
id: config2.id,
|
|
29259
29281
|
installed,
|
|
@@ -32481,7 +32503,7 @@ async function runCliSmoke(options = {}) {
|
|
|
32481
32503
|
|
|
32482
32504
|
// src/runtime/run-service.ts
|
|
32483
32505
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
|
|
32484
|
-
import { dirname as
|
|
32506
|
+
import { dirname as dirname10, resolve as resolve8 } from "node:path";
|
|
32485
32507
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32486
32508
|
|
|
32487
32509
|
// src/health/server.ts
|
|
@@ -32731,7 +32753,7 @@ import {
|
|
|
32731
32753
|
unlinkSync,
|
|
32732
32754
|
writeFileSync as writeFileSync2
|
|
32733
32755
|
} from "node:fs";
|
|
32734
|
-
import { dirname as
|
|
32756
|
+
import { dirname as dirname7 } from "node:path";
|
|
32735
32757
|
var DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
|
|
32736
32758
|
var DEFAULT_MAX_ROTATED_FILES = 2;
|
|
32737
32759
|
var PRIVATE_FILE_MODE = 384;
|
|
@@ -32755,7 +32777,7 @@ function createDiagnosticLogger(filePath, options = {}) {
|
|
|
32755
32777
|
let disabled = false;
|
|
32756
32778
|
let currentBytes = 0;
|
|
32757
32779
|
try {
|
|
32758
|
-
mkdirSync3(
|
|
32780
|
+
mkdirSync3(dirname7(filePath), { recursive: true });
|
|
32759
32781
|
pruneExpired();
|
|
32760
32782
|
currentBytes = existsSync5(filePath) ? statSync4(filePath).size : 0;
|
|
32761
32783
|
} catch {
|
|
@@ -33130,7 +33152,7 @@ async function controlTbSwitch(payload) {
|
|
|
33130
33152
|
|
|
33131
33153
|
// src/runs/orphan-registry.ts
|
|
33132
33154
|
import { mkdir as mkdir8, readFile as readFile9, rename as rename7, writeFile as writeFile8 } from "node:fs/promises";
|
|
33133
|
-
import { basename as basename3, dirname as
|
|
33155
|
+
import { basename as basename3, dirname as dirname8 } from "node:path";
|
|
33134
33156
|
var OrphanRegistry = class {
|
|
33135
33157
|
constructor(file2) {
|
|
33136
33158
|
this.file = file2;
|
|
@@ -33148,7 +33170,7 @@ var OrphanRegistry = class {
|
|
|
33148
33170
|
persist() {
|
|
33149
33171
|
const snapshot = JSON.stringify([...this.records.values()]);
|
|
33150
33172
|
this.writing = this.writing.then(async () => {
|
|
33151
|
-
await mkdir8(
|
|
33173
|
+
await mkdir8(dirname8(this.file), { recursive: true, mode: 448 });
|
|
33152
33174
|
const temporary = `${this.file}.${process.pid}.tmp`;
|
|
33153
33175
|
await writeFile8(temporary, snapshot, { mode: 384 });
|
|
33154
33176
|
await rename7(temporary, this.file);
|
|
@@ -33312,7 +33334,7 @@ var GatewayClient = class {
|
|
|
33312
33334
|
// src/workspace/directory-browser.ts
|
|
33313
33335
|
import { readdir as readdir3, realpath as realpath4, stat as stat7 } from "node:fs/promises";
|
|
33314
33336
|
import { homedir as homedir11 } from "node:os";
|
|
33315
|
-
import { dirname as
|
|
33337
|
+
import { dirname as dirname9, parse as parse3, resolve as resolve6 } from "node:path";
|
|
33316
33338
|
var MAX_ENTRIES = 1e3;
|
|
33317
33339
|
async function listDirectory(requested, allowedRoots) {
|
|
33318
33340
|
const raw = requested.trim().replace(/^~(?=$|[\\/])/, homedir11()) || homedir11();
|
|
@@ -33332,7 +33354,7 @@ async function listDirectory(requested, allowedRoots) {
|
|
|
33332
33354
|
if (entry.isDirectory()) directories.push(item);
|
|
33333
33355
|
else if (entry.isFile()) files.push(item);
|
|
33334
33356
|
}
|
|
33335
|
-
const parent =
|
|
33357
|
+
const parent = dirname9(directory);
|
|
33336
33358
|
const places = [{ label: "\u4E3B\u76EE\u5F55", path: homedir11() }];
|
|
33337
33359
|
for (const root2 of allowedRoots) if (root2 !== homedir11()) places.push({ label: "\u5141\u8BB8\u7684\u76EE\u5F55", path: root2 });
|
|
33338
33360
|
places.push({ label: "\u6839\u76EE\u5F55", path: process.platform === "win32" ? parse3(directory).root : "/" });
|
|
@@ -34495,7 +34517,9 @@ var AgentService = class {
|
|
|
34495
34517
|
await this.stop();
|
|
34496
34518
|
throw error62;
|
|
34497
34519
|
}
|
|
34498
|
-
} else process.stdout.write(
|
|
34520
|
+
} else process.stdout.write(`\u672C\u673A\u5C1A\u672A\u7ED1\u5B9A\u670D\u52A1\u5668\uFF0C\u8BF7\u5728\u300C\u8BBE\u5907\u4EE3\u7406\u300D\u63D2\u4EF6\u4E2D\u5B8C\u6210\u7ED1\u5B9A\uFF0C\u6216\u8FD0\u884C toc-ocra setup --server <\u670D\u52A1\u5668\u5730\u5740>
|
|
34521
|
+
\u5F53\u524D\u914D\u7F6E\uFF1A${this.config.configPath}
|
|
34522
|
+
`);
|
|
34499
34523
|
}
|
|
34500
34524
|
stop() {
|
|
34501
34525
|
return this.stopPromise ??= (async () => {
|
|
@@ -34565,7 +34589,9 @@ var AgentService = class {
|
|
|
34565
34589
|
id: provider.id,
|
|
34566
34590
|
installed: provider.installed,
|
|
34567
34591
|
runnable: provider.available,
|
|
34568
|
-
version: provider.version ?? ""
|
|
34592
|
+
version: provider.version ?? "",
|
|
34593
|
+
path: provider.resolvedPath ?? "",
|
|
34594
|
+
detail: provider.detail ?? ""
|
|
34569
34595
|
}))
|
|
34570
34596
|
};
|
|
34571
34597
|
}
|
|
@@ -34636,7 +34662,7 @@ function errorMessage3(error62) {
|
|
|
34636
34662
|
// src/runtime/run-service.ts
|
|
34637
34663
|
var PACKAGE_NAME = "toc-ocra";
|
|
34638
34664
|
function agentPackageRoot() {
|
|
34639
|
-
let directory =
|
|
34665
|
+
let directory = dirname10(fileURLToPath2(import.meta.url));
|
|
34640
34666
|
while (true) {
|
|
34641
34667
|
const packagePath = resolve8(directory, "package.json");
|
|
34642
34668
|
if (existsSync6(packagePath)) {
|
|
@@ -34646,7 +34672,7 @@ function agentPackageRoot() {
|
|
|
34646
34672
|
} catch {
|
|
34647
34673
|
}
|
|
34648
34674
|
}
|
|
34649
|
-
const parent =
|
|
34675
|
+
const parent = dirname10(directory);
|
|
34650
34676
|
if (parent === directory) return void 0;
|
|
34651
34677
|
directory = parent;
|
|
34652
34678
|
}
|
|
@@ -34799,23 +34825,22 @@ async function enroll(args) {
|
|
|
34799
34825
|
async function setup(args) {
|
|
34800
34826
|
const server = option(args, "--server");
|
|
34801
34827
|
if (!server) throw new Error("\u7528\u6CD5\uFF1Atoc-ocra setup --server <\u540E\u7AEF\u5730\u5740> [--code <\u914D\u5BF9\u7801>]\uFF08\u4E0D\u5E26 --code \u65F6\u626B\u7801\u6216\u8F93\u5165\u8FDE\u63A5\u7801\u914D\u5BF9\uFF09");
|
|
34802
|
-
const configPath = option(args, "--config");
|
|
34803
34828
|
const result = await pairDevice(args, server);
|
|
34804
34829
|
process.stdout.write(`\u914D\u5BF9\u6210\u529F\uFF1A\u8BBE\u5907\u300C${result.deviceName}\u300D\uFF08${result.deviceId}\uFF09
|
|
34805
34830
|
\u540E\u7AEF\uFF1A${result.serverUrl}
|
|
34806
34831
|
\u6B63\u5728\u5B89\u88C5\u540E\u53F0\u670D\u52A1\u2026
|
|
34807
34832
|
`);
|
|
34808
|
-
if (!manageService("install",
|
|
34833
|
+
if (!manageService("install", ["--config", result.configPath])) {
|
|
34809
34834
|
process.stderr.write("\u540E\u53F0\u670D\u52A1\u5B89\u88C5\u5931\u8D25\uFF0C\u53EF\u4EE5\u5148\u8FD0\u884C toc-ocra run \u4E34\u65F6\u542F\u52A8\n");
|
|
34810
34835
|
return;
|
|
34811
34836
|
}
|
|
34812
|
-
process.stdout.write("\u5B8C\u6210\uFF1A\
|
|
34837
|
+
process.stdout.write("\u5B8C\u6210\uFF1A\u540E\u53F0\u670D\u52A1\u5DF2\u542F\u52A8\u5E76\u786E\u8BA4\u7ED1\u5B9A\uFF0C\u5F00\u673A\u81EA\u52A8\u542F\u52A8\u3002\u56DE\u5230 Echo \u9875\u9762\u53EF\u67E5\u770B\u5728\u7EBF\u72B6\u6001\u3002\n");
|
|
34813
34838
|
if (process.platform === "linux") {
|
|
34814
34839
|
process.stdout.write('\u63D0\u793A\uFF1A\u5982\u9700\u5728\u9000\u51FA\u767B\u5F55\u540E\u7EE7\u7EED\u8FD0\u884C\uFF0C\u8BF7\u6267\u884C\u4E00\u6B21 loginctl enable-linger "$USER"\n');
|
|
34815
34840
|
}
|
|
34816
34841
|
}
|
|
34817
34842
|
function manageService(action, args) {
|
|
34818
|
-
const script = resolve9(
|
|
34843
|
+
const script = resolve9(dirname11(fileURLToPath3(import.meta.url)), "../../scripts/service.mjs");
|
|
34819
34844
|
if (!existsSync7(script)) throw new Error(`service manager is missing: ${script}`);
|
|
34820
34845
|
const result = spawnSync(process.execPath, [script, action, ...args], { stdio: "inherit", shell: false });
|
|
34821
34846
|
if (result.error) throw result.error;
|