evolcore 0.0.28 → 0.0.29
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/CHANGELOG.md +12 -0
- package/bin/ec-safe-output.js +270 -54
- package/dist/agents/baseagent-availability.js +37 -1
- package/dist/agents/baseagent.js +19 -9
- package/dist/agents/claude-runner.js +171 -13
- package/dist/agents/codex/app-server-client.js +6 -2
- package/dist/agents/codex/diagnostics.js +4 -3
- package/dist/agents/codex-runner.js +396 -95
- package/dist/agents/gemini-runner.js +35 -17
- package/dist/aun/group/history.js +130 -90
- package/dist/aun/group/operations.js +1 -3
- package/dist/aun/menu/transport.js +5 -3
- package/dist/aun/msg/managed-operation.js +70 -0
- package/dist/aun/msg/p2p.js +1 -3
- package/dist/aun/msg/upload.js +2 -2
- package/dist/aun/outbox.js +1 -37
- package/dist/channels/aun.js +249 -89
- package/dist/channels/daemon.js +18 -1
- package/dist/channels/feishu.js +1 -2
- package/dist/cli/agent-command.js +23 -3
- package/dist/cli/agent-create.js +68 -2
- package/dist/cli/agent.js +12 -2
- package/dist/cli/aun-commands.js +87 -13
- package/dist/cli/cli-argv.js +26 -0
- package/dist/cli/daemon-commands.js +40 -10
- package/dist/cli/data-command.js +4 -4
- package/dist/cli/handoff-command.js +2 -0
- package/dist/cli/index.js +18 -1
- package/dist/cli/managed-command-guard.js +10 -0
- package/dist/cli/memory-command.js +441 -0
- package/dist/cli/restart-monitor.js +62 -6
- package/dist/cli/skill-command.js +41 -0
- package/dist/cli/task-context.js +2 -23
- package/dist/cli/trigger-command.js +9 -1
- package/dist/cli/watch-msg-diag.js +209 -0
- package/dist/config/config-field-policy.js +52 -3
- package/dist/config/config-manager.js +17 -4
- package/dist/config/contact-book-store.js +2 -2
- package/dist/config/mention-mode.js +7 -2
- package/dist/config/merge.js +28 -9
- package/dist/config/resolved-config-op.js +1 -1
- package/dist/config/runtime-env.js +137 -0
- package/dist/config/schema-registry.js +11 -1
- package/dist/config-store.js +10 -10
- package/dist/core/audit/event-key.js +3 -1
- package/dist/core/audit/log-integrity.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +13 -6
- package/dist/core/auth/authorization-audit.js +54 -19
- package/dist/core/auth/operation-authorizer.js +17 -0
- package/dist/core/auth/operation-catalog.js +9 -0
- package/dist/core/causation/context.js +5 -1
- package/dist/core/command/agent-control.js +1 -2
- package/dist/core/command/command-handler.js +51 -23
- package/dist/core/command/memory-slash.js +270 -0
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +315 -60
- package/dist/core/command/menu-protocol.js +42 -4
- package/dist/core/command/slash-gate.js +10 -10
- package/dist/core/command/slash-handler.js +206 -64
- package/dist/core/data-migration.js +282 -505
- package/dist/core/event-catalog.js +26 -0
- package/dist/core/evolagent-registry.js +6 -0
- package/dist/core/evolagent.js +0 -10
- package/dist/core/handoff/store.js +1 -20
- package/dist/core/inference/text-inference.js +57 -1
- package/dist/core/memory/consolidation-context.js +505 -0
- package/dist/core/memory/consolidation-ops-records.js +124 -0
- package/dist/core/memory/consolidation-trigger.js +394 -0
- package/dist/core/memory/index-manager.js +308 -0
- package/dist/core/memory/launch-consolidation.js +395 -0
- package/dist/core/memory/memory-admin.js +234 -0
- package/dist/core/memory/memory-document.js +100 -0
- package/dist/core/memory/memory-session-policy.js +41 -0
- package/dist/core/memory/memory-signature.js +257 -0
- package/dist/core/memory/memory-writer.js +432 -0
- package/dist/core/memory/staleness.js +117 -0
- package/dist/core/message/auto-mention-gate.js +454 -0
- package/dist/core/message/im-renderer.js +69 -16
- package/dist/core/message/message-bridge.js +287 -21
- package/dist/core/message/message-log.js +1 -0
- package/dist/core/message/message-queue.js +114 -27
- package/dist/core/message/pending-hints.js +329 -161
- package/dist/core/message/response-engine.js +567 -80
- package/dist/core/permission/ec-command-parser.js +1029 -80
- package/dist/core/permission/protected-paths.js +376 -126
- package/dist/core/permission/sandbox-runtime.js +40 -12
- package/dist/core/permission/tool-error-code.js +96 -13
- package/dist/core/permission/tool-policy.js +276 -23
- package/dist/core/role/runtime-policy.js +3 -7
- package/dist/core/session/{runner-task-history.js → runner-event-summary.js} +1 -1
- package/dist/core/session/session-fs-store.js +0 -76
- package/dist/core/session/session-idle-monitor.js +355 -0
- package/dist/core/session/session-manager.js +478 -17
- package/dist/core/session/session-mapper.js +33 -16
- package/dist/core/session/session-renew.js +217 -155
- package/dist/core/session/{session-turns.js → session-transcript.js} +35 -6
- package/dist/core/skill/global-watcher.js +282 -0
- package/dist/core/skill/index-generator.js +84 -0
- package/dist/core/skill/startup.js +73 -0
- package/dist/core/skill/switch-resolver.js +115 -0
- package/dist/core/task/task-activity-store.js +219 -0
- package/dist/eck/kit-renderer.js +30 -3
- package/dist/eck/manifest-engine.js +26 -4
- package/dist/index.js +708 -18
- package/dist/ipc.js +564 -2
- package/dist/paths.js +30 -9
- package/dist/response-system/engines/v1/proactive-flow.js +116 -15
- package/dist/response-system/modes/single-session/index.js +3 -0
- package/dist/trigger/feedback.js +1 -0
- package/dist/trigger/manager.js +0 -10
- package/dist/trigger/scheduler.js +11 -0
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/avatar-upload.js +59 -18
- package/dist/utils/error-dict.json +6 -3
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/logger.js +32 -10
- package/dist/utils/media-cache.js +84 -0
- package/dist/utils/msg-diag.js +97 -0
- package/dist/utils/welcome.js +37 -8
- package/kits/docs/AUTHORING.md +314 -0
- package/kits/docs/GUIDE.md +2 -0
- package/kits/docs/INDEX.md +2 -0
- package/kits/docs/aun/CHEATSHEET.md +4 -0
- package/kits/docs/aun/SDK.md +60 -0
- package/kits/docs/context-assembly.md +10 -6
- package/kits/docs/evolcore/INDEX.md +17 -3
- package/kits/docs/evolcore/agent-create.md +24 -0
- package/kits/docs/evolcore/agent.md +5 -2
- package/kits/docs/evolcore/config.md +1 -1
- package/kits/docs/evolcore/ec-capabilities.md +364 -0
- package/kits/docs/evolcore/group.md +34 -18
- package/kits/docs/evolcore/memory-architecture.md +78 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +133 -0
- package/kits/docs/evolcore/memory-consolidation.md +263 -0
- package/kits/docs/evolcore/memory-tags.md +63 -0
- package/kits/docs/evolcore/memory.md +110 -0
- package/kits/docs/evolcore/menu-client.md +27 -11
- package/kits/{schemas → docs/evolcore}/menu-exec-schema-commands.md +12 -6
- package/kits/docs/evolcore/menu-protocol.md +213 -0
- package/kits/docs/evolcore/msg.md +2 -0
- package/kits/docs/evolcore/trigger.md +7 -5
- package/kits/docs/path-registry.md +6 -8
- package/kits/docs/prompt-loading-architecture.md +5 -3
- package/kits/docs/venues/group.md +5 -4
- package/kits/eck_manifest.json +294 -88
- package/kits/eck_manifest.memory.json +257 -0
- package/kits/rules/03-identity.md +8 -8
- package/kits/rules/05-venue.md +4 -2
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +276 -47
- package/kits/schemas/agent-config.schema.12.json +38 -2
- package/kits/schemas/agent-config.schema.13.json +591 -0
- package/kits/schemas/daemon.schema.6.json +9 -9
- package/kits/schemas/defaults.schema.5.json +29 -0
- package/kits/schemas/relation-config.schema.8.json +14 -1
- package/kits/schemas/relation-config.schema.9.json +129 -0
- package/kits/schemas/role-config.schema.1.json +3 -3
- package/kits/skills/.switches.json +3 -0
- package/kits/skills/ec-skill/SKILL.md +217 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +128 -0
- package/kits/skills/ec-skill/scripts/deps.mjs +107 -0
- package/kits/skills/ec-skill/scripts/frontmatter.mjs +104 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +629 -0
- package/kits/skills/ec-skill/scripts/template/SKILL.md.tmpl +30 -0
- package/kits/templates/decision/auto-mention.md +25 -0
- package/kits/templates/decision/session-renew.md +22 -0
- package/kits/templates/memory-consolidation/forget.md +104 -0
- package/kits/templates/memory-consolidation/generalize.md +76 -0
- package/kits/templates/memory-consolidation/notes.md +133 -0
- package/kits/templates/memory-consolidation/profile.md +58 -0
- package/kits/templates/memory-consolidation/promote.md +72 -0
- package/kits/templates/memory-consolidation/workflow.md +75 -0
- package/kits/templates/system-fragments/bootstrap.md +14 -5
- package/kits/templates/system-fragments/commands.md +1 -0
- package/kits/templates/system-fragments/group-history.md +6 -0
- package/kits/templates/system-fragments/identity.md +0 -3
- package/kits/templates/system-fragments/memory.md +79 -0
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +4 -6
- package/dist/trigger/legacy-session-history.js +0 -19
- package/kits/templates/system-fragments/group-unread-history.md +0 -7
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 依赖自举:按需把第三方包装进 $EVOLCORE_HOME/skills/.deps/
|
|
3
|
+
*
|
|
4
|
+
* 为什么装在 .deps 而不是技能目录里:
|
|
5
|
+
* - 本机级技能目录是用户自己的,塞 node_modules 会污染
|
|
6
|
+
* - 内置级在 kits/skills/,随包发布,全局安装时可能是只读的
|
|
7
|
+
*
|
|
8
|
+
* 装一次之后离线可用:每次都先查 .deps,命中就直接用,不碰网络。
|
|
9
|
+
* 版本锁死(不用 ^),避免上游升级带来兼容性问题。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import os from 'node:os';
|
|
15
|
+
import { createRequire } from 'node:module';
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
|
|
18
|
+
/** 锁定的依赖版本。新增依赖时在此登记。 */
|
|
19
|
+
export const LOCKED_DEPS = {
|
|
20
|
+
'adm-zip': '0.6.1',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** $EVOLCORE_HOME 的解析规则与主程序 paths.ts 保持一致 */
|
|
24
|
+
export function evolcoreHome() {
|
|
25
|
+
if (process.env.EVOLCORE_HOME) return process.env.EVOLCORE_HOME;
|
|
26
|
+
return path.join(os.homedir(), '.evolcore');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 依赖目录 */
|
|
30
|
+
export function depsDir() {
|
|
31
|
+
return path.join(evolcoreHome(), 'skills', '.deps');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 确保某个依赖可用,返回其模块入口的绝对路径。
|
|
36
|
+
* 已存在直接返回;缺失则 npm install(锁版本)。
|
|
37
|
+
*/
|
|
38
|
+
export function ensureDep(name) {
|
|
39
|
+
const version = LOCKED_DEPS[name];
|
|
40
|
+
if (!version) throw new Error(`未登记的依赖: ${name}(请在 LOCKED_DEPS 中登记并锁定版本)`);
|
|
41
|
+
|
|
42
|
+
const pkgDir = path.join(depsDir(), 'node_modules', name);
|
|
43
|
+
if (!fs.existsSync(pkgDir)) {
|
|
44
|
+
installDep(name, version);
|
|
45
|
+
}
|
|
46
|
+
return pkgDir;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 用 CommonJS require 加载依赖(兼容 CJS 包) */
|
|
50
|
+
export function loadDep(name) {
|
|
51
|
+
const pkgDir = ensureDep(name);
|
|
52
|
+
const require = createRequire(path.join(pkgDir, 'noop.js'));
|
|
53
|
+
return require(pkgDir);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function installDep(name, version) {
|
|
57
|
+
const dir = depsDir();
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
|
|
60
|
+
// 极简并发保护:mkdir 是原子的,抢到锁目录的进程执行安装,其余等待
|
|
61
|
+
const lockDir = path.join(dir, '.install-lock');
|
|
62
|
+
const deadline = Date.now() + 120_000;
|
|
63
|
+
let acquired = false;
|
|
64
|
+
|
|
65
|
+
while (Date.now() < deadline) {
|
|
66
|
+
try {
|
|
67
|
+
fs.mkdirSync(lockDir);
|
|
68
|
+
acquired = true;
|
|
69
|
+
break;
|
|
70
|
+
} catch (e) {
|
|
71
|
+
if (e.code !== 'EEXIST') throw e;
|
|
72
|
+
// 别人正在装:等它装完
|
|
73
|
+
const target = path.join(dir, 'node_modules', name);
|
|
74
|
+
if (fs.existsSync(target)) return;
|
|
75
|
+
sleepSync(300);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!acquired) {
|
|
80
|
+
throw new Error(`等待依赖安装超时(${name})。若另一进程正在安装,请稍后重试。`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// 抢到锁后再查一次(可能别人已装好)
|
|
85
|
+
if (fs.existsSync(path.join(dir, 'node_modules', name))) return;
|
|
86
|
+
|
|
87
|
+
process.stderr.write(`[ec-skill] 首次使用,正在安装依赖 ${name}@${version} ...\n`);
|
|
88
|
+
execFileSync('npm', ['install', '--prefix', dir, '--no-save', '--no-audit', '--no-fund', `${name}@${version}`], {
|
|
89
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
90
|
+
shell: process.platform === 'win32', // Windows 上 npm 是 .cmd,需要 shell
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
const detail = e.stderr ? e.stderr.toString() : (e.message || String(e));
|
|
94
|
+
throw new Error(
|
|
95
|
+
`安装依赖 ${name}@${version} 失败:${detail}\n` +
|
|
96
|
+
`提示:首次安装需要联网。若处于离线环境,改用「给目录」的方式安装技能(不需要解压依赖)。`
|
|
97
|
+
);
|
|
98
|
+
} finally {
|
|
99
|
+
try { fs.rmdirSync(lockDir); } catch {}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** 同步 sleep(脚本场景下避免引入异步复杂度) */
|
|
104
|
+
function sleepSync(ms) {
|
|
105
|
+
const sab = new SharedArrayBuffer(4);
|
|
106
|
+
Atomics.wait(new Int32Array(sab), 0, 0, ms);
|
|
107
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SKILL.md frontmatter 的最小解析器。
|
|
3
|
+
*
|
|
4
|
+
* 为什么不用 yaml 包:本机级技能在 $EVOLCORE_HOME/skills/(包外面),
|
|
5
|
+
* 按相对路径解析不到包的 node_modules,脚本必须零外部依赖。
|
|
6
|
+
*
|
|
7
|
+
* 只解析规范里定义、且技能作者实际会用的形态:
|
|
8
|
+
* 简单键值 name: foo
|
|
9
|
+
* 引号标量 name: "foo" / name: 'foo'
|
|
10
|
+
* 折叠块 description: >- (后续缩进行拼成一行)
|
|
11
|
+
* 字面块 description: | (保留换行)
|
|
12
|
+
* 行内数组 allowed-tools: [Read, Grep]
|
|
13
|
+
* 逗号串 allowed-tools: Read, Grep
|
|
14
|
+
* 不追求完整 YAML 语义——复杂结构(嵌套对象/锚点)超出技能规范范围。
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
|
|
20
|
+
/** 取出 frontmatter 文本块;没有则返回 null */
|
|
21
|
+
export function extractFrontmatter(text) {
|
|
22
|
+
const m = text.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
23
|
+
return m ? m[1] : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** 解析 frontmatter 文本为普通对象 */
|
|
27
|
+
export function parseFrontmatter(fmText) {
|
|
28
|
+
const out = {};
|
|
29
|
+
const lines = fmText.split(/\r?\n/);
|
|
30
|
+
let i = 0;
|
|
31
|
+
|
|
32
|
+
while (i < lines.length) {
|
|
33
|
+
const line = lines[i];
|
|
34
|
+
// 跳过空行与注释
|
|
35
|
+
if (!line.trim() || line.trimStart().startsWith('#')) { i++; continue; }
|
|
36
|
+
// 缩进行属于上一个键,已在块处理里消费
|
|
37
|
+
if (/^\s/.test(line)) { i++; continue; }
|
|
38
|
+
|
|
39
|
+
const m = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
|
|
40
|
+
if (!m) { i++; continue; }
|
|
41
|
+
|
|
42
|
+
const key = m[1];
|
|
43
|
+
let value = m[2];
|
|
44
|
+
i++;
|
|
45
|
+
|
|
46
|
+
// 块标量:>- | > | 等
|
|
47
|
+
if (/^[|>][-+]?\d*$/.test(value.trim())) {
|
|
48
|
+
const folded = value.trim().startsWith('>');
|
|
49
|
+
const blockLines = [];
|
|
50
|
+
while (i < lines.length && (/^\s/.test(lines[i]) || lines[i].trim() === '')) {
|
|
51
|
+
blockLines.push(lines[i]);
|
|
52
|
+
i++;
|
|
53
|
+
}
|
|
54
|
+
// 去掉公共缩进
|
|
55
|
+
const indents = blockLines.filter(l => l.trim()).map(l => l.match(/^\s*/)[0].length);
|
|
56
|
+
const indent = indents.length ? Math.min(...indents) : 0;
|
|
57
|
+
const stripped = blockLines.map(l => l.slice(indent));
|
|
58
|
+
// 去掉首尾空行
|
|
59
|
+
while (stripped.length && !stripped[0].trim()) stripped.shift();
|
|
60
|
+
while (stripped.length && !stripped[stripped.length - 1].trim()) stripped.pop();
|
|
61
|
+
|
|
62
|
+
out[key] = folded
|
|
63
|
+
? stripped.map(l => l.trim()).filter(Boolean).join(' ')
|
|
64
|
+
: stripped.join('\n');
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
out[key] = parseScalar(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function parseScalar(raw) {
|
|
75
|
+
const v = raw.trim();
|
|
76
|
+
if (v === '') return '';
|
|
77
|
+
if (v === 'true') return true;
|
|
78
|
+
if (v === 'false') return false;
|
|
79
|
+
if (v === 'null' || v === '~') return null;
|
|
80
|
+
// 引号
|
|
81
|
+
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
|
|
82
|
+
return v.slice(1, -1);
|
|
83
|
+
}
|
|
84
|
+
// 行内数组
|
|
85
|
+
if (v.startsWith('[') && v.endsWith(']')) {
|
|
86
|
+
return v.slice(1, -1).split(',').map(s => s.trim().replace(/^["']|["']$/g, '')).filter(Boolean);
|
|
87
|
+
}
|
|
88
|
+
// 逗号串(allowed-tools 允许这种写法)
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** 读取一个技能目录的 frontmatter;失败返回 {__error} */
|
|
93
|
+
export function readSkillFrontmatter(skillDir) {
|
|
94
|
+
const file = path.join(skillDir, 'SKILL.md');
|
|
95
|
+
if (!fs.existsSync(file)) return null;
|
|
96
|
+
const text = fs.readFileSync(file, 'utf-8');
|
|
97
|
+
const fm = extractFrontmatter(text);
|
|
98
|
+
if (fm === null) return null;
|
|
99
|
+
try {
|
|
100
|
+
return parseFrontmatter(fm);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return { __error: e instanceof Error ? e.message : String(e) };
|
|
103
|
+
}
|
|
104
|
+
}
|