@agent-dock/cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/claude-acp.mjs +60 -0
- package/dist/agents/codex-acp.mjs +38 -0
- package/dist/assets/SVG-SPINNERS-LICENSE.txt +23 -0
- package/dist/assets/agentdock-bouncing-ball.webp +0 -0
- package/dist/cli.js +21916 -0
- package/dist/cli.js.map +7 -0
- package/dist/vendor/lark-sdk.cjs +91930 -0
- package/dist/vendor/native/better-sqlite3.json +15 -0
- package/dist/vendor/native/linux-x64/better_sqlite3.node +0 -0
- package/package.json +64 -4
- package/public/agent-dock.svg +12 -0
- package/public/agent-icons/README.md +15 -0
- package/public/agent-icons/claudecode.svg +1 -0
- package/public/agent-icons/codex.svg +1 -0
- package/public/agent-icons/copilot.svg +1 -0
- package/public/agent-icons/cursor.svg +1 -0
- package/public/agent-icons/deepseek.svg +1 -0
- package/public/agent-icons/droid.svg +8 -0
- package/public/agent-icons/fast-agent.svg +6 -0
- package/public/agent-icons/gemini.svg +1 -0
- package/public/agent-icons/grok.svg +1 -0
- package/public/agent-icons/iflow.png +0 -0
- package/public/agent-icons/kilocode.svg +1 -0
- package/public/agent-icons/kimi.svg +1 -0
- package/public/agent-icons/kiro.svg +1 -0
- package/public/agent-icons/mcode.svg +1 -0
- package/public/agent-icons/mux.svg +18 -0
- package/public/agent-icons/openclaw.svg +1 -0
- package/public/agent-icons/opencode.svg +1 -0
- package/public/agent-icons/pi.svg +1 -0
- package/public/agent-icons/poolside.svg +1 -0
- package/public/agent-icons/qoder.svg +1 -0
- package/public/agent-icons/qwen.svg +1 -0
- package/public/agent-icons/trae.svg +1 -0
- package/public/agent-icons/zeroclaw.svg +1 -0
- package/public/assets/ImageLightbox-DDAwu-Ky.js +1 -0
- package/public/assets/ImageLightbox-DUblxfbA.css +1 -0
- package/public/assets/PromptEditor-CkEM_6zj.js +29 -0
- package/public/assets/index-BhkwJfLD.css +32 -0
- package/public/assets/index-DCRx7Io2.js +755 -0
- package/public/assets/syntax-highlighter-fRlPMgFb.js +22 -0
- package/public/index.html +4 -0
- package/scripts/check-native-compat.mjs +84 -0
- package/scripts/fix-node-pty.mjs +10 -0
- package/README.md +0 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { access, readFile } from 'node:fs/promises';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { delimiter, join } from 'node:path';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { parseEnv } from 'node:util';
|
|
8
|
+
|
|
9
|
+
async function settingsEnvironment(file) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(await readFile(file, 'utf8'));
|
|
12
|
+
if (!parsed?.env || typeof parsed.env !== 'object' || Array.isArray(parsed.env)) return {};
|
|
13
|
+
return Object.fromEntries(Object.entries(parsed.env).filter((entry) => typeof entry[1] === 'string'));
|
|
14
|
+
} catch { return {}; }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function fileEnvironment(file) {
|
|
18
|
+
try { return parseEnv(await readFile(file, 'utf8')); }
|
|
19
|
+
catch { return {}; }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function findClaudeExecutable(pathValue) {
|
|
23
|
+
if (process.env.CLAUDE_CODE_EXECUTABLE) return process.env.CLAUDE_CODE_EXECUTABLE;
|
|
24
|
+
const names = process.platform === 'win32' ? ['claude.exe', 'claude.cmd', 'claude.bat'] : ['claude'];
|
|
25
|
+
for (const directory of String(pathValue ?? '').split(delimiter).filter(Boolean)) {
|
|
26
|
+
for (const name of names) {
|
|
27
|
+
const candidate = join(directory, name);
|
|
28
|
+
try { await access(candidate, constants.X_OK); return candidate; }
|
|
29
|
+
catch {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
|
|
35
|
+
const settingsEnv = Object.assign(
|
|
36
|
+
{},
|
|
37
|
+
await settingsEnvironment(join(configDir, 'settings.json')),
|
|
38
|
+
await fileEnvironment(join(process.cwd(), '.env')),
|
|
39
|
+
await fileEnvironment(join(process.cwd(), '.env.local')),
|
|
40
|
+
await settingsEnvironment(join(process.cwd(), '.claude', 'settings.json')),
|
|
41
|
+
await settingsEnvironment(join(process.cwd(), '.claude', 'settings.local.json'))
|
|
42
|
+
);
|
|
43
|
+
const env = { ...settingsEnv, ...process.env };
|
|
44
|
+
const installedClaude = await findClaudeExecutable(env.PATH);
|
|
45
|
+
if (installedClaude) env.CLAUDE_CODE_EXECUTABLE = installedClaude;
|
|
46
|
+
const bundledClaudeAcp = fileURLToPath(import.meta.resolve('@agentclientprotocol/claude-agent-acp/dist/index.js'));
|
|
47
|
+
const command = process.env.AGENTDOCK_CLAUDE_ACP_COMMAND || process.execPath;
|
|
48
|
+
const args = process.env.AGENTDOCK_CLAUDE_ACP_ARGS_JSON
|
|
49
|
+
? JSON.parse(process.env.AGENTDOCK_CLAUDE_ACP_ARGS_JSON)
|
|
50
|
+
: [bundledClaudeAcp];
|
|
51
|
+
const child = spawn(command, args, { cwd: process.cwd(), env, stdio: 'inherit' });
|
|
52
|
+
|
|
53
|
+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => { if (!child.killed) child.kill(signal); });
|
|
54
|
+
child.once('error', error => { process.stderr.write(`${error.message}\n`); process.exitCode = 1; });
|
|
55
|
+
child.once('exit', (code, signal) => {
|
|
56
|
+
if (signal && process.platform !== 'win32') {
|
|
57
|
+
process.removeAllListeners(signal);
|
|
58
|
+
process.kill(process.pid, signal);
|
|
59
|
+
} else process.exit(code ?? 1);
|
|
60
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
|
|
5
|
+
import { access, stat } from 'node:fs/promises';
|
|
6
|
+
import { constants } from 'node:fs';
|
|
7
|
+
import { delimiter, resolve } from 'node:path';
|
|
8
|
+
|
|
9
|
+
async function localCodexPath() {
|
|
10
|
+
if (process.env.CODEX_PATH) return process.env.CODEX_PATH;
|
|
11
|
+
for (const directory of (process.env.PATH ?? '').split(delimiter).filter(Boolean)) {
|
|
12
|
+
for (const name of process.platform === 'win32' ? ['codex.exe', 'codex.cmd', 'codex.bat'] : ['codex']) {
|
|
13
|
+
const candidate = resolve(directory, name);
|
|
14
|
+
try { if (!(await stat(candidate)).isFile()) continue; await access(candidate, constants.X_OK); return candidate; } catch {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
throw new Error('未找到本机 Codex,请将 Codex CLI 加入 PATH 或设置 CODEX_PATH。');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Only the launcher environment receives CODEX_PATH; persisted session keys
|
|
21
|
+
// remain snake_case. Discovery and sessions use this same local executable.
|
|
22
|
+
process.env.CODEX_PATH = await localCodexPath();
|
|
23
|
+
if (process.argv[2] === '--version') {
|
|
24
|
+
const result = spawnSync(process.env.CODEX_PATH, ['--version'], { stdio: 'inherit', timeout: 1000, shell: process.platform === 'win32' });
|
|
25
|
+
process.exit(result.status ?? 1);
|
|
26
|
+
}
|
|
27
|
+
// Import in this process without an intermediary npx or shell process.
|
|
28
|
+
// Session-specific selection overrides only model; retain provider routing and
|
|
29
|
+
// credentials from CODEX_CONFIG / CODEX_HOME without modifying shared files.
|
|
30
|
+
if (process.env.agentdock_codex_model) {
|
|
31
|
+
let config;
|
|
32
|
+
try { config = JSON.parse(process.env.CODEX_CONFIG || '{}'); }
|
|
33
|
+
catch { throw new Error('Codex CODEX_CONFIG 必须是有效的 JSON 对象。'); }
|
|
34
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) throw new Error('Codex CODEX_CONFIG 必须是有效的 JSON 对象。');
|
|
35
|
+
process.env.CODEX_CONFIG = JSON.stringify({ ...config, model: process.env.agentdock_codex_model });
|
|
36
|
+
}
|
|
37
|
+
const adapter = createRequire(import.meta.url).resolve('@agentclientprotocol/codex-acp');
|
|
38
|
+
await import(pathToFileURL(adapter).href);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Utkarsh Verma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Source: https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/bouncing-ball.svg
|
|
Binary file
|