ec-web 0.0.20 → 0.0.22
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/ipc-client.js +7 -1
- package/dist/paths.js +18 -1
- package/dist/server.js +159 -28
- package/dist/sources/aid.js +69 -49
- package/dist/sources/baseagent-detector.js +60 -6
- package/dist/sources/basic-settings.js +818 -0
- package/dist/sources/gateway.js +5 -4
- package/dist/sources/monitor.js +22 -5
- package/dist/sources/msg.js +4 -96
- package/dist/sources/relation-roles.js +216 -207
- package/dist/sources/role-definitions.js +162 -331
- package/dist/sources/session-codex.js +207 -84
- package/dist/sources/system.js +10 -9
- package/dist/sources/triggers.js +82 -13
- package/dist/sources/types.js +20 -1
- package/dist/static/app.js +175 -15
- package/dist/static/basic-settings.js +1576 -0
- package/dist/static/index.html +43 -1
- package/dist/static/style.css +586 -2
- package/ecweb-wrapper.cjs +5 -1
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Base agent 环境检测 —
|
|
2
|
+
* Base agent 环境检测 — 检测本机可用的 Claude、Codex、Gemini 和内置 EC Agent。
|
|
3
3
|
*
|
|
4
4
|
* 检测条件:
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* 命令行工具优先按 PATH 检测;同时保留会话目录检测,兼容 CLI 不在当前 shell
|
|
6
|
+
* PATH 但已经在本机初始化过的情况。ecagent 随 EvolCore 一起提供,始终作为可选
|
|
7
|
+
* 基座展示,实际凭据和网关配置由配置校验负责。
|
|
7
8
|
*/
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
import path from 'path';
|
|
10
11
|
import os from 'os';
|
|
11
12
|
import { createRequire } from 'module';
|
|
13
|
+
import { spawnSync } from 'child_process';
|
|
12
14
|
const requireFromHere = createRequire(import.meta.url);
|
|
13
15
|
let _cached = null;
|
|
14
16
|
/**
|
|
@@ -45,6 +47,40 @@ function checkClaudeProjects() {
|
|
|
45
47
|
const claudeProjects = path.join(os.homedir(), '.claude', 'projects');
|
|
46
48
|
return fs.existsSync(claudeProjects);
|
|
47
49
|
}
|
|
50
|
+
function commandExists(command) {
|
|
51
|
+
try {
|
|
52
|
+
const result = process.platform === 'win32'
|
|
53
|
+
? spawnSync('where', [command], { stdio: 'ignore', windowsHide: true })
|
|
54
|
+
: spawnSync('sh', ['-lc', `command -v ${JSON.stringify(command)}`], { stdio: 'ignore' });
|
|
55
|
+
return result.status === 0;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function checkGeminiHome() {
|
|
62
|
+
return fs.existsSync(path.join(os.homedir(), '.gemini'));
|
|
63
|
+
}
|
|
64
|
+
function detectSources(id) {
|
|
65
|
+
if (id === 'ecagent')
|
|
66
|
+
return ['内置'];
|
|
67
|
+
const sources = [];
|
|
68
|
+
if (commandExists(id))
|
|
69
|
+
sources.push('PATH');
|
|
70
|
+
if (id === 'claude' && checkClaudeProjects())
|
|
71
|
+
sources.push('~/.claude/projects');
|
|
72
|
+
if (id === 'codex') {
|
|
73
|
+
if (checkCodexSessions())
|
|
74
|
+
sources.push('~/.codex/sessions');
|
|
75
|
+
if (checkCodexStateDb())
|
|
76
|
+
sources.push('~/.codex/state_*.sqlite');
|
|
77
|
+
if (checkSqliteAvailable())
|
|
78
|
+
sources.push('node:sqlite');
|
|
79
|
+
}
|
|
80
|
+
if (id === 'gemini' && checkGeminiHome())
|
|
81
|
+
sources.push('~/.gemini');
|
|
82
|
+
return sources;
|
|
83
|
+
}
|
|
48
84
|
/**
|
|
49
85
|
* 检测 Codex sessions 目录是否存在
|
|
50
86
|
*/
|
|
@@ -59,11 +95,29 @@ function checkCodexSessions() {
|
|
|
59
95
|
export function detectBaseAgents() {
|
|
60
96
|
if (_cached)
|
|
61
97
|
return _cached;
|
|
62
|
-
const claude =
|
|
63
|
-
const codex =
|
|
64
|
-
|
|
98
|
+
const claude = detectSources('claude').length > 0;
|
|
99
|
+
const codex = detectSources('codex').length > 0;
|
|
100
|
+
const gemini = detectSources('gemini').length > 0;
|
|
101
|
+
const ecagent = true;
|
|
102
|
+
_cached = { claude, codex, gemini, ecagent };
|
|
65
103
|
return _cached;
|
|
66
104
|
}
|
|
105
|
+
/** Return display-oriented detection details for the Basic Settings API. */
|
|
106
|
+
export function detectBaseAgentDetails(defaults = {}) {
|
|
107
|
+
const configured = isRecord(defaults?.baseagents) ? defaults.baseagents : {};
|
|
108
|
+
return ['claude', 'codex', 'gemini', 'ecagent'].map(id => {
|
|
109
|
+
const detectionSource = detectSources(id);
|
|
110
|
+
return {
|
|
111
|
+
id,
|
|
112
|
+
detected: id === 'ecagent' || detectionSource.length > 0,
|
|
113
|
+
configured: Object.prototype.hasOwnProperty.call(configured, id),
|
|
114
|
+
detectionSource,
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function isRecord(value) {
|
|
119
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
120
|
+
}
|
|
67
121
|
/**
|
|
68
122
|
* 重置缓存(测试用)
|
|
69
123
|
*/
|