evolcore 0.0.42 → 0.0.43-test.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/CHANGELOG.md +35 -0
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/agent-runtime.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +5 -3
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* lock.mjs —— 锁定工作区(单向操作,锁上就解不开)
|
|
4
|
+
*
|
|
5
|
+
* 用法:
|
|
6
|
+
* node "<技能目录>/scripts/lock.mjs" --workspace "<路径>" [--reason "<说明>"] [--yes] [--json]
|
|
7
|
+
* node "<技能目录>/scripts/lock.mjs" --workspace "<路径>" --show [--json]
|
|
8
|
+
*
|
|
9
|
+
* **锁定是单向的**。这不是疏忽,是设计:
|
|
10
|
+
* · 锁定的语义是"这份数据已经定稿,别再让任何自动化碰它"
|
|
11
|
+
* · 留一个 unlock,就等于留了一个能被误触发的后门,
|
|
12
|
+
* 锁本身也就失去了意义
|
|
13
|
+
* · 真要用它,只能由人手动删掉 .assistant/LOCK 文件——
|
|
14
|
+
* 这一步必须绕过本工具,是刻意的摩擦
|
|
15
|
+
*
|
|
16
|
+
* 锁定后:
|
|
17
|
+
* · clean.mjs 拒绝清理(无绕过开关)
|
|
18
|
+
* · 建议:锁定前先把数据备份到别处,锁上就取不回来了
|
|
19
|
+
*
|
|
20
|
+
* 为什么单独一个文件而不是写进 state.json:
|
|
21
|
+
* state.json 是"运行时状态",会被 init/migrate 重写;
|
|
22
|
+
* 锁必须独立存在,且任何一个脚本都不该有"顺手改它"的路径。
|
|
23
|
+
*
|
|
24
|
+
* 退出码:0 成功 / 10 已锁定(幂等)/ 20 失败 / 30 拒绝(不是工作区)
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
|
27
|
+
import { join, resolve } from 'node:path';
|
|
28
|
+
import { createHash } from 'node:crypto';
|
|
29
|
+
import { nowLocal } from './lib/time.mjs';
|
|
30
|
+
|
|
31
|
+
const LOCK_REL = join('.assistant', 'LOCK');
|
|
32
|
+
|
|
33
|
+
function parseArgs(argv) {
|
|
34
|
+
const out = { json: false, yes: false, show: false };
|
|
35
|
+
for (let i = 2; i < argv.length; i++) {
|
|
36
|
+
const a = argv[i];
|
|
37
|
+
if (a === '--workspace' || a === '-w') out.workspace = argv[++i];
|
|
38
|
+
else if (a === '--reason') out.reason = argv[++i];
|
|
39
|
+
else if (a === '--show') out.show = true;
|
|
40
|
+
else if (a === '--yes' || a === '-y') out.yes = true;
|
|
41
|
+
else if (a === '--json') out.json = true;
|
|
42
|
+
else if (a === '--help' || a === '-h') out.help = true;
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const args = parseArgs(process.argv);
|
|
48
|
+
if (args.help || !args.workspace) {
|
|
49
|
+
console.log(`用法:node lock.mjs --workspace <路径> [选项]
|
|
50
|
+
|
|
51
|
+
--reason <说明> 记录锁定原因
|
|
52
|
+
--yes 确认锁定(锁定不可逆,不加只预览)
|
|
53
|
+
--show 查看当前锁定状态
|
|
54
|
+
--json 机器可读输出
|
|
55
|
+
|
|
56
|
+
锁定是单向的,没有 unlock。
|
|
57
|
+
要解除只能由人手动删除 .assistant/LOCK 文件。`);
|
|
58
|
+
process.exit(args.help ? 0 : 30);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const workspace = resolve(args.workspace);
|
|
62
|
+
const lockPath = join(workspace, LOCK_REL);
|
|
63
|
+
|
|
64
|
+
function readLock() {
|
|
65
|
+
if (!existsSync(lockPath)) return null;
|
|
66
|
+
try { return JSON.parse(readFileSync(lockPath, 'utf8')); }
|
|
67
|
+
catch { return { lockedAt: '(无法解析)', corrupted: true }; }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ── --show ─────────────────────────────────────────────────────
|
|
71
|
+
if (args.show) {
|
|
72
|
+
const lock = readLock();
|
|
73
|
+
if (args.json) {
|
|
74
|
+
console.log(JSON.stringify({ ok: true, workspace, locked: !!lock, lock }, null, 2));
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
if (!lock) {
|
|
78
|
+
console.log(`🔓 未锁定:${workspace}`);
|
|
79
|
+
} else {
|
|
80
|
+
console.log(`🔒 已锁定:${workspace}`);
|
|
81
|
+
if (lock.lockedAt) console.log(` 锁定时间:${lock.lockedAt}`);
|
|
82
|
+
if (lock.reason) console.log(` 原因:${lock.reason}`);
|
|
83
|
+
if (lock.treeHash) console.log(` 目录指纹:${lock.treeHash.slice(0, 16)}…`);
|
|
84
|
+
console.log('');
|
|
85
|
+
console.log(' 解除方式:由人手动删除 ' + lockPath);
|
|
86
|
+
}
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ── 前置:必须是工作区 ──────────────────────────────────────────
|
|
91
|
+
const looksLikeWorkspace =
|
|
92
|
+
existsSync(join(workspace, '.assistant', 'state.json')) ||
|
|
93
|
+
(existsSync(join(workspace, 'capture')) && existsSync(join(workspace, 'output')));
|
|
94
|
+
|
|
95
|
+
if (!looksLikeWorkspace) {
|
|
96
|
+
const entries = existsSync(workspace) ? readdirSync(workspace).slice(0, 10) : [];
|
|
97
|
+
if (args.json) {
|
|
98
|
+
console.log(JSON.stringify({
|
|
99
|
+
ok: false, code: 'NOT_A_WORKSPACE', workspace, entries,
|
|
100
|
+
hint: '不是个人助理工作区,不锁定',
|
|
101
|
+
}, null, 2));
|
|
102
|
+
} else {
|
|
103
|
+
console.error(`❌ 拒绝锁定:这个目录不像个人助理工作区
|
|
104
|
+
路径:${workspace}
|
|
105
|
+
现有内容:${entries.length ? entries.join('、') : '(不存在或为空)'}`);
|
|
106
|
+
}
|
|
107
|
+
process.exit(30);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── 已锁定:幂等 ───────────────────────────────────────────────
|
|
111
|
+
const existing = readLock();
|
|
112
|
+
if (existing) {
|
|
113
|
+
if (args.json) {
|
|
114
|
+
console.log(JSON.stringify({ ok: true, alreadyLocked: true, workspace, lock: existing }, null, 2));
|
|
115
|
+
} else {
|
|
116
|
+
console.log(`🔒 已经锁定,无需重复操作:${workspace}`);
|
|
117
|
+
if (existing.lockedAt) console.log(` 锁定时间:${existing.lockedAt}`);
|
|
118
|
+
}
|
|
119
|
+
process.exit(10);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ── 目录指纹(锁定时的快照依据,便于日后核对是否被改动) ────────
|
|
123
|
+
function treeHash(dir) {
|
|
124
|
+
const h = createHash('sha256');
|
|
125
|
+
const walk = (d, prefix) => {
|
|
126
|
+
let entries;
|
|
127
|
+
try { entries = readdirSync(d, { withFileTypes: true }); } catch { return; }
|
|
128
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
129
|
+
for (const e of entries) {
|
|
130
|
+
if (e.name === 'LOCK') continue; // 锁文件自身不算进指纹
|
|
131
|
+
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
132
|
+
if (e.isDirectory()) { h.update(`D:${rel}\n`); walk(join(d, e.name), rel); }
|
|
133
|
+
else h.update(`F:${rel}\n`);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
walk(dir, '');
|
|
137
|
+
return h.digest('hex');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ── 预览 ───────────────────────────────────────────────────────
|
|
141
|
+
if (!args.yes) {
|
|
142
|
+
if (args.json) {
|
|
143
|
+
console.log(JSON.stringify({
|
|
144
|
+
ok: true, dryRun: true, workspace,
|
|
145
|
+
willWrite: lockPath,
|
|
146
|
+
reason: args.reason || null,
|
|
147
|
+
hint: '加 --yes 确认锁定。锁定后无法通过工具解除。',
|
|
148
|
+
}, null, 2));
|
|
149
|
+
process.exit(0);
|
|
150
|
+
}
|
|
151
|
+
console.log(`[预览] 将锁定:${workspace}`);
|
|
152
|
+
if (args.reason) console.log(` 原因:${args.reason}`);
|
|
153
|
+
console.log(` 写入:${lockPath}`);
|
|
154
|
+
console.log('');
|
|
155
|
+
console.log('⚠️ 锁定后无法通过任何工具解除,clean.mjs 会拒绝清理。');
|
|
156
|
+
console.log(' 确认无误后加 --yes 执行。');
|
|
157
|
+
process.exit(0);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ── 执行 ───────────────────────────────────────────────────────
|
|
161
|
+
const lock = {
|
|
162
|
+
lockedAt: nowLocal(),
|
|
163
|
+
reason: args.reason || '',
|
|
164
|
+
treeHash: treeHash(workspace),
|
|
165
|
+
note: '单向锁定。解除只能由人手动删除本文件。',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
mkdirSync(join(workspace, '.assistant'), { recursive: true });
|
|
170
|
+
writeFileSync(lockPath, JSON.stringify(lock, null, 2), 'utf8');
|
|
171
|
+
} catch (e) {
|
|
172
|
+
if (args.json) {
|
|
173
|
+
console.log(JSON.stringify({ ok: false, workspace, error: String(e.message) }, null, 2));
|
|
174
|
+
} else {
|
|
175
|
+
console.error(`❌ 锁定失败:${e.message}`);
|
|
176
|
+
}
|
|
177
|
+
process.exit(20);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (args.json) {
|
|
181
|
+
console.log(JSON.stringify({ ok: true, locked: true, workspace, lock }, null, 2));
|
|
182
|
+
process.exit(0);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
console.log(`🔒 已锁定:${workspace}`);
|
|
186
|
+
if (lock.reason) console.log(` 原因:${lock.reason}`);
|
|
187
|
+
console.log(` 目录指纹:${lock.treeHash.slice(0, 16)}…`);
|
|
188
|
+
console.log('');
|
|
189
|
+
console.log('✅ 锁定完成。此操作不可逆——工具层面没有解锁路径。');
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* 4. 顺序执行:从当前版本逐级升到目标版本,不跳级
|
|
13
13
|
* 5. EXTRA 不清理:用户自建目录一律保留
|
|
14
14
|
*
|
|
15
|
-
* 退出码:0
|
|
15
|
+
* 退出码:0 成功(含"无需迁移")/ 20 部分失败 / 30 前置条件不满足
|
|
16
16
|
*/
|
|
17
17
|
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
|
|
18
|
+
// 锁定检查见下方;LOCK 文件独立存在,任何脚本都不写它。
|
|
18
19
|
import { join, resolve, dirname } from 'node:path';
|
|
19
20
|
import {
|
|
20
21
|
SKILL_DIR, loadSchema, listVersions, latestVersion,
|
|
@@ -46,6 +47,26 @@ const target = latestVersion();
|
|
|
46
47
|
const from = readWorkspaceVersion(workspace);
|
|
47
48
|
const capabilities = readCapabilities(workspace);
|
|
48
49
|
|
|
50
|
+
// ── 锁定检查(迁移会改结构,属于"碰",一律拒绝) ────────────────
|
|
51
|
+
const LOCK_PATH = join(workspace, '.assistant', 'LOCK');
|
|
52
|
+
if (existsSync(LOCK_PATH)) {
|
|
53
|
+
let info = null;
|
|
54
|
+
try { info = JSON.parse(readFileSync(LOCK_PATH, 'utf8')); } catch { /* 损坏也照样拦 */ }
|
|
55
|
+
const when = info?.lockedAt ? `\n 锁定时间:${info.lockedAt}` : '';
|
|
56
|
+
const why = info?.reason ? `\n 锁定原因:${info.reason}` : '';
|
|
57
|
+
|
|
58
|
+
if (args.json) {
|
|
59
|
+
console.log(JSON.stringify({ ok: false, code: 'WORKSPACE_LOCKED', workspace, lock: info }, null, 2));
|
|
60
|
+
} else {
|
|
61
|
+
console.error(`🔒 拒绝迁移:工作区已锁定${when}${why}
|
|
62
|
+
|
|
63
|
+
路径:${workspace}
|
|
64
|
+
|
|
65
|
+
解除只能由人手动删除 ${LOCK_PATH}`);
|
|
66
|
+
}
|
|
67
|
+
process.exit(30);
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
const report = {
|
|
50
71
|
workspace,
|
|
51
72
|
from: from || 'uninitialized',
|
|
@@ -57,6 +78,19 @@ const report = {
|
|
|
57
78
|
errors: [],
|
|
58
79
|
};
|
|
59
80
|
|
|
81
|
+
// ── 无迁移可做:先判定,别写快照 ────────────────────────────────
|
|
82
|
+
// 快照是"改动前"的可回滚依据;没有改动就不该留快照,否则每次空跑都堆一份垃圾。
|
|
83
|
+
const versions = listVersions().filter(v => v > from);
|
|
84
|
+
if (!versions.length && from >= target) {
|
|
85
|
+
if (args.json) {
|
|
86
|
+
console.log(JSON.stringify({ ...report, ok: true, noop: true }, null, 2));
|
|
87
|
+
} else {
|
|
88
|
+
console.log(`✅ 已是 v${target},无需迁移`);
|
|
89
|
+
}
|
|
90
|
+
// 无需迁移是成功,不是失败——非 0 会让 && 链和 CI 误判
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
|
|
60
94
|
// ── 快照(可回滚依据) ──────────────────────────────────────────
|
|
61
95
|
if (!args.dryRun && from > 0) {
|
|
62
96
|
const logDir = join(workspace, '.assistant', 'logs');
|
|
@@ -69,15 +103,6 @@ if (!args.dryRun && from > 0) {
|
|
|
69
103
|
}
|
|
70
104
|
|
|
71
105
|
// ── 逐级迁移 ────────────────────────────────────────────────────
|
|
72
|
-
const versions = listVersions().filter(v => v > from);
|
|
73
|
-
if (!versions.length && from >= target) {
|
|
74
|
-
if (args.json) {
|
|
75
|
-
console.log(JSON.stringify({ ...report, ok: true, noop: true }, null, 2));
|
|
76
|
-
} else {
|
|
77
|
-
console.log(`✅ 已是 v${target},无需迁移`);
|
|
78
|
-
}
|
|
79
|
-
process.exit(10);
|
|
80
|
-
}
|
|
81
106
|
|
|
82
107
|
// 每级迁移:这里各版本共用一个通用落地器(建目录 + 补生成物)。
|
|
83
108
|
// 将来若某版本需要改结构(移动/重命名),在该版本分支里加专用步骤。
|
|
@@ -151,7 +151,8 @@ const rel = p => p.replace(workspace, '').replace(/^[\\/]/, '');
|
|
|
151
151
|
|
|
152
152
|
if (args.json) {
|
|
153
153
|
console.log(JSON.stringify({
|
|
154
|
-
|
|
154
|
+
// 有警告仍然是"通过";只有 errors 才算不通过
|
|
155
|
+
ok: exitCode !== 20,
|
|
155
156
|
workspace,
|
|
156
157
|
structure: { version: current, target, missing: d.missing.length, extra: d.extra.length },
|
|
157
158
|
manifest: { files: manifestCount, objects: checkedObjects, broken: manifestBroken },
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
persona.md 的完整模板(备份+重建用)。
|
|
3
|
+
|
|
4
|
+
用法:
|
|
5
|
+
1. 把现有 persona.md 整份复制为 persona.before-personal-assistant.md(已存在则不覆盖)
|
|
6
|
+
2. 用本模板渲染出一份全新的 persona.md 写回去
|
|
7
|
+
3. 备份里有要保留的信息,从备份抄进新文件
|
|
8
|
+
|
|
9
|
+
替换占位符:{{workspace}} 工作区绝对路径 {{owner}} 主人显示名
|
|
10
|
+
{{skillDir}} 技能目录绝对路径 {{triggers}} 已装触发器清单
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## 数据位置
|
|
14
|
+
|
|
15
|
+
个人助理工作区:`{{workspace}}`
|
|
16
|
+
|
|
17
|
+
这是主人 {{owner}} 的长期档案,纯文本,不依赖任何软件,换掉 EvolCore 也能用编辑器打开。
|
|
18
|
+
**新会话开场,只要话题涉及归档、回顾、报告、任务、找人找事,先读它的 `INDEX.md` 建立底数。**
|
|
19
|
+
|
|
20
|
+
### 里面有什么
|
|
21
|
+
|
|
22
|
+
| 目录 | 内容 | 性质 |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `capture/` | 原料:对话、笔记、链接、文件、现场、会议 | 只增不改 |
|
|
25
|
+
| `output/reports/` | 日报 / 周报 / 月报 / 季报 / 年报 | 可归档 |
|
|
26
|
+
| `output/tasks/` | 任务唯一事实源(`QUEUE.md` `today.md` `short.md` `long.md`) | 完成后归档 |
|
|
27
|
+
| `output/knowledge/memory/` | **持久记忆**:`facts/` `rules/` `entities/` `episodes/` | 永不归档 |
|
|
28
|
+
| `output/knowledge/profile/` | 主人、他人、组织画像 | 永不归档 |
|
|
29
|
+
| `output/knowledge/topics/` | 主题梳理 | 永不归档 |
|
|
30
|
+
| `INDEX.md` | 全部记录的入口 | 每日重建 |
|
|
31
|
+
|
|
32
|
+
### 持久记忆是什么
|
|
33
|
+
|
|
34
|
+
`output/knowledge/memory/` 是**长期保管**用的档案,和运行时记忆各管一段,不要混用。
|
|
35
|
+
|
|
36
|
+
它的关键机制是**改主意不改老条目**——写一条新的,把旧的标 `superseded`,旧版本永久保留。
|
|
37
|
+
所以"九月我以为 A,十月改成了 B,当时出了什么事"这种问题,答案只在工作区里。
|
|
38
|
+
|
|
39
|
+
### 什么时候该进来读
|
|
40
|
+
|
|
41
|
+
不必等主人点名。命中以下任一情形,**先读再动手**,不要凭上下文猜:
|
|
42
|
+
|
|
43
|
+
1. 主人说「记一下」「归档」「存起来」→ 落 `capture/`,原文照录不润色
|
|
44
|
+
2. 主人问「以前说过什么」「上次那个」「查一下」→ 先搜工作区,再回答
|
|
45
|
+
3. 主人要日报 / 周报 / 月报 → 读对应周期的 `capture/` 原料再写,每条结论带 `source:`
|
|
46
|
+
4. 涉及任务、待办、跟进 → 读 `output/tasks/`
|
|
47
|
+
5. 涉及某个人、某个组织 → 读 `output/knowledge/profile/`
|
|
48
|
+
6. 归不了类的原料 → 先丢 `capture/_inbox/`,绝不因为"不确定放哪"而拒收
|
|
49
|
+
|
|
50
|
+
### 操作方式
|
|
51
|
+
|
|
52
|
+
- 操作细节走技能:`ec skill load personal-assistant`
|
|
53
|
+
- 脚本一律用绝对路径,技能目录:`{{skillDir}}`
|
|
54
|
+
- 已装触发器,**不要重复创建**:{{triggers}}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"source": { "type": "cron", "expression": "50 23 * * *", "timezone": "Asia/Shanghai" },
|
|
9
9
|
"execution": {
|
|
10
10
|
"type": "trigger_session",
|
|
11
|
-
"prompt": "加载 personal-assistant 技能,执行「每日落地」:运行 node \"<技能目录>/scripts/ingest.mjs\" --workspace \"{{workspace}}\" --date today。若落地正常且无需报告,只输出 [[NOOP]];如发现缺失或失败,用一句话说明缺什么。",
|
|
11
|
+
"prompt": "加载 personal-assistant 技能,执行「每日落地」:运行 node \"<技能目录>/scripts/ingest.mjs\" --workspace \"{{workspace}}\" --self {{agent_aid}} --date today。若落地正常且无需报告,只输出 [[NOOP]];如发现缺失或失败,用一句话说明缺什么。",
|
|
12
12
|
"thread": "per_run",
|
|
13
13
|
"permissionMode": "bypass",
|
|
14
14
|
"onError": "fail",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
| 来源 | 位置 | 说明 |
|
|
12
12
|
|---|---|---|
|
|
13
|
-
| note | 上下文文件里的 `
|
|
13
|
+
| note | 上下文文件里的 `processingDir` | 整理开始时已从 `pending/` 认领到 `processing/` 的本批临时记忆:可能重复、可能矛盾、可能有错 |
|
|
14
14
|
| 会话历史 | 上下文文件里的 `threads/` 快照目录 | 上下文文件列出了「话题快照文件」时可用,**应当读取**(`manual` / `compress` / `session-new` 以及多数 `relation-idle`);没列出时(没有入站记录的关系,如只被群链按发言人写入过的关系)只能凭 note 本身判断 |
|
|
15
15
|
| 已有记忆 | 目标作用域的 `MEMORY.md` 索引 | 查重 |
|
|
16
16
|
|
|
@@ -20,7 +20,8 @@ group-send 用于群内公开发送:proactive 下是正式回复;interactive
|
|
|
20
20
|
{{?peerId}}
|
|
21
21
|
ec msg send {{selfAid}} {{peerId}} '<text>' [--text-from-file <path>] [--encrypt|--no-encrypt] [--file <path> --as image|video|voice|file] [--link <url> --title '<title>'] [--payload '<json>' --return none|required --timeout <duration> --format json]
|
|
22
22
|
msg-send 用于私聊发送:proactive 下是正式回复;interactive 下普通回复直接输出,需要文件、链接或手动控制加密时使用此命令。群聊仅在确需私下联系本条消息发送者且已获授权时使用,公开回复使用 group-send。
|
|
23
|
-
当用户想获取、读取、查询或汇总属于某个主体的数据时,无论主体通过“我/你”、姓名、关系称谓还是 AID 指代,都先依据当前关系层、明确 AID 或可靠身份/联系人信息确认主体是谁并解析到准确 AID;姓名不明或有歧义时才询问。必要时加载 `ec-identity` 解析姓名。随后加载内置技能 `aid-ability`,检查该主体 AID 是否发布了匹配的数据能力;数据类型和来源不设限。若数据由关联设备或服务提供,只能依据能力索引或可信身份信息确认对应 Provider AID
|
|
23
|
+
当用户想获取、读取、查询或汇总属于某个主体的数据时,无论主体通过“我/你”、姓名、关系称谓还是 AID 指代,都先依据当前关系层、明确 AID 或可靠身份/联系人信息确认主体是谁并解析到准确 AID;姓名不明或有歧义时才询问。必要时加载 `ec-identity` 解析姓名。随后加载内置技能 `aid-ability`,检查该主体 AID 是否发布了匹配的数据能力;数据类型和来源不设限。若数据由关联设备或服务提供,只能依据能力索引或可信身份信息确认对应 Provider AID,不得猜测。
|
|
24
|
+
用户要求发现或调用其他 AID 的能力时使用 `aid-ability`。用户要求给当前 Agent/主机添加、开发、安装、启用、发布、下架、升级或诊断本端插件时使用 `ec-ability`。仅出现 `ability` 等术语不足以判定要调用远端能力;按用户要做的事分流。若用户只询问远端调用流程/可行性或明确要求不要执行,只说明身份解析、能力发现与调用步骤,不读取索引、不调用能力。实际调用时不要猜测能力路径或参数:读取目标 AID 的能力索引,必要时执行在线发现,再按结构化契约构造原始 JSON。需要结果时使用 `ec msg send --return required`;它会按 `--timeout`(默认 60s,最大 3600s)使用 AUN volatile 非持久消息。等待超时后用 `ec msg request get` 查询,不要自动重发。`message_id` 只表示传输 ACK,不表示能力执行完成。
|
|
24
25
|
{{/}}
|
|
25
26
|
每次调用仍须遵守 `[reply]` 的单条命令及加密要求。
|
|
26
27
|
{{/}}
|
|
@@ -24,6 +24,7 @@ ec task 恢复暂停或异常中断的会话任务(resume <sessionId>;
|
|
|
24
24
|
ec task 恢复暂停或异常中断的本 Agent 会话任务(resume <sessionId>;复用原 baseagent 会话,缺失时失败关闭) $KITS_DOCS/evolcore/task.md
|
|
25
25
|
{{/}}
|
|
26
26
|
ec skill 技能加载与管理(load 加载正文/path 查路径/list 列技能/info 详情/where 根目录/enable/disable/install/remove) $KITS_DOCS/evolcore/skill.md
|
|
27
|
+
ec ability 按 AID 管理和开发能力插件(context/--self、dev 构建打包、发布下架、状态诊断与作业等待;写操作仍按目标授权) $KITS_DOCS/evolcore/ability.md
|
|
27
28
|
ec aid 身份/证书/名片/换头像(avatar --file/--url)/探测对端 $KITS_DOCS/evolcore/aid.md
|
|
28
29
|
ec fs AUN 文件系统统一入口(ls/stat/cat/cp/mv/rm/mkdir/ln/chmod/setfacl/getfacl/token/find/df/mount/approve/reject/umount;个人/群空间同一入口;没有 ec group fs) $KITS_DOCS/evolcore/fs.md
|
|
29
30
|
ec storage 文件上传/下载/配额(底层调试入口,日常优先 ec fs) $KITS_DOCS/evolcore/storage.md
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evolcore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43-test.1",
|
|
4
4
|
"description": "AI Agent gateway connecting Claude, Codex, Gemini, and the bundled ecagent runner to messaging channels with multi-project session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,18 +60,20 @@
|
|
|
60
60
|
"prepublishOnly": "npm test"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@agentunion/fastaun": "0.5.
|
|
63
|
+
"@agentunion/fastaun": "0.5.30",
|
|
64
64
|
"@anthropic-ai/claude-agent-sdk": "0.3.300",
|
|
65
65
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
66
66
|
"ajv": "^8.20.0",
|
|
67
|
+
"canonicalize": "^2.1.0",
|
|
67
68
|
"chokidar": "^5.0.0",
|
|
68
69
|
"cron-parser": "^5.5.0",
|
|
69
70
|
"dotenv": "^17.4.2",
|
|
70
|
-
"ec-web": "0.0.
|
|
71
|
+
"ec-web": "0.0.43-test.0",
|
|
71
72
|
"ignore": "7.0.5",
|
|
72
73
|
"image-type": "^6.0.0",
|
|
73
74
|
"partial-json": "0.1.7",
|
|
74
75
|
"qrcode-terminal": "^0.12.0",
|
|
76
|
+
"semver": "^7.8.5",
|
|
75
77
|
"sharp": "0.35.5",
|
|
76
78
|
"smol-toml": "1.8.0",
|
|
77
79
|
"typebox": "1.1.38",
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 版本与 runtime 元信息的归口读取。
|
|
3
|
-
*
|
|
4
|
-
* 这里全部是同步廉价读取:只读 package.json,不起子进程、不打 npm。
|
|
5
|
-
* ecweb 已装版本要跑 `npm root -g`(约 350ms),由 daemon 在启动后异步解析一次,
|
|
6
|
-
* 通过 HostSnapshot 下发;CLI 不再自己算。
|
|
7
|
-
*/
|
|
8
|
-
import fs from 'node:fs';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { getPackageRoot } from '../paths.js';
|
|
11
|
-
import { WEB_PACKAGE_NAME } from '../product.js';
|
|
12
|
-
function readJsonVersion(filePath) {
|
|
13
|
-
try {
|
|
14
|
-
const pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
15
|
-
return typeof pkg.version === 'string' && pkg.version ? pkg.version : null;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* ecweb 版本按"正在跑的那份"取值:开发仓的 ecweb/ 优先于 node_modules 里的旧副本。
|
|
23
|
-
* 不跑 npm;全局安装布局下 ecweb 在 globalRoot/ecweb,那份由 daemon 异步补齐。
|
|
24
|
-
*/
|
|
25
|
-
export function readLocalEcwebVersion() {
|
|
26
|
-
const pkgRoot = getPackageRoot();
|
|
27
|
-
return readJsonVersion(path.join(pkgRoot, 'ecweb', 'package.json'))
|
|
28
|
-
?? readJsonVersion(path.join(pkgRoot, 'node_modules', ...WEB_PACKAGE_NAME.split('/'), 'package.json'));
|
|
29
|
-
}
|
|
30
|
-
export function readVersionInfo(options = {}) {
|
|
31
|
-
const pkgRoot = getPackageRoot();
|
|
32
|
-
return {
|
|
33
|
-
evolcore: readJsonVersion(path.join(pkgRoot, 'package.json')),
|
|
34
|
-
fastaun: readJsonVersion(path.join(pkgRoot, 'node_modules', '@agentunion', 'fastaun', 'package.json')),
|
|
35
|
-
ecweb: options.ecweb !== undefined ? options.ecweb : readLocalEcwebVersion(),
|
|
36
|
-
node: process.version,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function readRuntimeInfo(runMode) {
|
|
40
|
-
const packagePath = getPackageRoot();
|
|
41
|
-
return {
|
|
42
|
-
packagePath,
|
|
43
|
-
installationType: packagePath.includes('node_modules') ? 'npm-global' : 'development-link',
|
|
44
|
-
runMode: runMode ?? null,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { parentPort } from 'node:worker_threads';
|
|
2
|
-
import { performance } from 'node:perf_hooks';
|
|
3
|
-
import { readProcessMetrics } from './process-tree-stats.js';
|
|
4
|
-
const port = parentPort;
|
|
5
|
-
if (!port)
|
|
6
|
-
throw new Error('process-tree worker requires a parent port');
|
|
7
|
-
port.on('message', (message) => {
|
|
8
|
-
if (message?.type !== 'sample')
|
|
9
|
-
return;
|
|
10
|
-
const startedAt = performance.now();
|
|
11
|
-
try {
|
|
12
|
-
const metrics = readProcessMetrics();
|
|
13
|
-
if (metrics.length === 0)
|
|
14
|
-
throw new Error('process enumeration returned no metrics');
|
|
15
|
-
const response = {
|
|
16
|
-
type: 'sample',
|
|
17
|
-
requestId: message.requestId,
|
|
18
|
-
metrics,
|
|
19
|
-
durationMs: Math.round((performance.now() - startedAt) * 10) / 10,
|
|
20
|
-
};
|
|
21
|
-
port.postMessage(response);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
port.postMessage({
|
|
25
|
-
type: 'sample-error',
|
|
26
|
-
requestId: message.requestId,
|
|
27
|
-
error: error instanceof Error ? error.message : String(error),
|
|
28
|
-
durationMs: Math.round((performance.now() - startedAt) * 10) / 10,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { TextDecoder } from 'util';
|
|
2
|
-
/** Decode output from Windows native commands regardless of the active code page. */
|
|
3
|
-
export function decodeWindowsOutput(value) {
|
|
4
|
-
if (!value)
|
|
5
|
-
return '';
|
|
6
|
-
const bytes = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
7
|
-
if (bytes.length === 0)
|
|
8
|
-
return '';
|
|
9
|
-
if (bytes.length >= 2 && bytes[0] === 0xff && bytes[1] === 0xfe) {
|
|
10
|
-
return bytes.subarray(2).toString('utf16le').replace(/^\uFEFF/, '');
|
|
11
|
-
}
|
|
12
|
-
if (bytes.length >= 2 && bytes[0] === 0xfe && bytes[1] === 0xff) {
|
|
13
|
-
const swapped = Buffer.allocUnsafe(bytes.length - 2);
|
|
14
|
-
for (let i = 2; i + 1 < bytes.length; i += 2) {
|
|
15
|
-
swapped[i - 2] = bytes[i + 1];
|
|
16
|
-
swapped[i - 1] = bytes[i];
|
|
17
|
-
}
|
|
18
|
-
return swapped.toString('utf16le').replace(/^\uFEFF/, '');
|
|
19
|
-
}
|
|
20
|
-
// Windows PowerShell 5.1 can emit UTF-16 without a BOM when stdout is
|
|
21
|
-
// redirected. NUL bytes are not expected in command text, so use them as
|
|
22
|
-
// the signal for this representation before trying code-page decoding.
|
|
23
|
-
const utf8Loose = bytes.toString('utf8');
|
|
24
|
-
if (utf8Loose.includes('\u0000')) {
|
|
25
|
-
const utf16 = bytes.toString('utf16le').replace(/^\uFEFF/, '');
|
|
26
|
-
if (!utf16.includes('\u0000'))
|
|
27
|
-
return utf16;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
return new TextDecoder('utf-8', { fatal: true }).decode(bytes).replace(/^\uFEFF/, '');
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
// schtasks.exe uses the active Windows/OEM code page for redirected output.
|
|
34
|
-
return new TextDecoder('gb18030').decode(bytes).replace(/^\uFEFF/, '');
|
|
35
|
-
}
|
|
36
|
-
}
|