evolcore 0.0.43-test.0 → 0.0.43-test.2
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 +31 -2
- package/README.md +22 -0
- package/dist/agents/claude-runner.js +26 -2
- package/dist/agents/codex/app-server-client.js +12 -0
- package/dist/agents/codex-runner.js +49 -8
- package/dist/agents/ecagent-runner.js +26 -9
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +3 -0
- package/dist/channels/aun.js +484 -43
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/dingtalk.js +83 -31
- package/dist/channels/feishu.js +29 -13
- package/dist/channels/qqbot.js +32 -11
- package/dist/channels/wechat.js +13 -3
- package/dist/channels/wecom.js +67 -27
- package/dist/cli/agent-command.js +3 -86
- package/dist/cli/agent-create.js +22 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +1 -0
- package/dist/cli/config.js +1 -1
- package/dist/cli/daemon-commands.js +47 -2
- package/dist/cli/data-command.js +9 -1
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/diag.js +1 -1
- package/dist/cli/directory.js +77 -64
- package/dist/cli/getmeta-command.js +1 -1
- package/dist/cli/index.js +79 -22
- package/dist/cli/init.js +1 -23
- package/dist/cli/link-rules.js +1 -1
- package/dist/cli/managed-command-guard.js +0 -1
- package/dist/cli/pa-workspace-command.js +36 -2
- package/dist/cli/peer.js +1 -1
- package/dist/cli/restart-monitor.js +17 -3
- package/dist/cli/role.js +1 -1
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +2 -2
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/access-policy.js +1 -0
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +7 -0
- package/dist/config/role-schema.js +4 -3
- package/dist/config/role-service.js +3 -3
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/agent-runtime.js +2 -1
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +0 -11
- package/dist/core/auth/operation-catalog.js +0 -18
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +17 -46
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +3 -2
- package/dist/core/command/menu-handler.js +51 -8
- package/dist/core/command/menu-protocol.js +20 -0
- package/dist/core/command/slash-handler.js +101 -40
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +5 -8
- package/dist/core/handoff/argv-parse.js +115 -0
- package/dist/core/handoff/ipc-registration.js +1 -1
- package/dist/core/ipc-registration.js +19 -2
- package/dist/core/memory/consolidation.js +8 -1
- package/dist/core/memory/relation-sweep.js +20 -8
- package/dist/core/message/aun-ipc-sender.js +28 -1
- package/dist/core/message/contact-admission.js +548 -0
- package/dist/core/message/im-renderer.js +69 -10
- package/dist/core/message/message-admission.js +28 -3
- package/dist/core/message/message-bridge.js +46 -5
- package/dist/core/message/message-utils.js +0 -5
- package/dist/core/message/peer-mode.js +44 -10
- package/dist/core/message/response-engine.js +268 -69
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/permission/ec-command-parser.js +1 -28
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/role/runtime-policy.js +14 -2
- package/dist/core/session/session-manager.js +9 -1
- package/dist/core/soul.js +66 -0
- package/dist/core/system-session/memory.js +2 -2
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +128 -29
- package/dist/directory/owner-directory-cache.js +364 -50
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +120 -47
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +219 -32
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-search.js +50 -18
- package/dist/directory/owner-directory-store.js +150 -30
- package/dist/eck/kit-renderer.js +12 -5
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/eck/message-renderer.js +5 -2
- package/dist/eck/paactive-context.js +45 -0
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +24 -16
- package/dist/index.js +9 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +26 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +4 -1
- package/dist/response-system/engines/v1/paactive-flow.js +18 -0
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +3 -5
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +5 -2
- package/dist/utils/logger.js +13 -4
- package/dist/utils/npm-ops.js +2 -2
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/dist/agent-loop.js +43 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +1 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +137 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +57 -4
- package/kits/eck_manifest.memory.json +67 -3
- package/kits/eck_manifest.paactive.json +528 -0
- package/kits/eck_message_manifest.paactive.json +233 -0
- package/kits/rules/01-overview.md +2 -2
- package/kits/rules/03-identity.md +10 -9
- package/kits/rules/05-venue.md +2 -4
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +31 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +109 -53
- package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
- package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
- package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
- package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
- package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
- package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
- package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
- package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
- package/kits/templates/message-fragments/paactive/item.md +3 -0
- package/kits/templates/soul/00-GUIDE.md +61 -0
- package/kits/templates/soul/01-identity.md +5 -0
- package/kits/templates/soul/02-persona.md +11 -0
- package/kits/templates/soul/03-duties.md +5 -0
- package/kits/templates/soul/04-working-style.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +7 -7
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +9 -0
- package/kits/templates/system-fragments/memory.md +1 -1
- package/kits/templates/system-fragments/paactive/channel.md +25 -0
- package/kits/templates/system-fragments/paactive/reply.md +25 -0
- package/kits/templates/system-fragments/paactive/session.md +32 -0
- package/kits/templates/system-fragments/personal-assistant.md +65 -0
- package/package.json +4 -3
- package/dist/cli/handoff-command.js +0 -353
- package/dist/directory/owner-directory-remark-operation.js +0 -147
- package/kits/docs/evolcore/self-summary.md +0 -29
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { atomicWriteJson } from '../utils/atomic-write.js';
|
|
4
4
|
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { extraFingerprint } from './owner-directory-cache.js';
|
|
5
6
|
import { OWNER_DIRECTORY_SCOPES } from './owner-directory-scope.js';
|
|
6
7
|
// ── content_digest helpers ────────────────────────────────────────────────────
|
|
7
8
|
const CONTENT_DIGEST_RE = /^[a-f0-9]{64}$/;
|
|
@@ -45,10 +46,9 @@ function archiveFileName(scope, now) {
|
|
|
45
46
|
function changesDir(directory) {
|
|
46
47
|
return path.join(directory, 'changes');
|
|
47
48
|
}
|
|
48
|
-
function changesFile(directory,
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
return path.join(changesDir(directory), `${y}-${m}.jsonl`);
|
|
49
|
+
function changesFile(directory, year, month) {
|
|
50
|
+
const m = String(month).padStart(2, '0');
|
|
51
|
+
return path.join(changesDir(directory), `${year}-${m}.jsonl`);
|
|
52
52
|
}
|
|
53
53
|
function changesIndexFile(directory) {
|
|
54
54
|
return path.join(changesDir(directory), 'index.json');
|
|
@@ -84,7 +84,7 @@ function entryChangeKind(entry) {
|
|
|
84
84
|
/**
|
|
85
85
|
* 比较新旧两份快照,生成变更行列表。
|
|
86
86
|
* 无旧快照时写一行 baseline(不展开差集)。
|
|
87
|
-
* owner / personal_assistant
|
|
87
|
+
* owner / personal_assistant 身份块的变化单独产出 `identity_changed` 行。
|
|
88
88
|
*/
|
|
89
89
|
export function diffSnapshots(scope, next, prev, nextMeta, prevMeta) {
|
|
90
90
|
const now = next.fetchedAt;
|
|
@@ -109,8 +109,13 @@ export function diffSnapshots(scope, next, prev, nextMeta, prevMeta) {
|
|
|
109
109
|
lines.push({ at: now, scope, type: 'host_added', aid, contentDigest, prevContentDigest: prevDigest, from: null, to: entry });
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
else
|
|
113
|
-
|
|
112
|
+
else {
|
|
113
|
+
// 运行期自检:只有真正存在差异字段才记 `entry_changed`。
|
|
114
|
+
// 上游若换一种序列化(缺失 / "" / null 互换),这里不会再刷出噪音行。
|
|
115
|
+
const fields = changedFields(old, entry);
|
|
116
|
+
if (fields.length === 0)
|
|
117
|
+
continue;
|
|
118
|
+
lines.push({ at: now, scope, type: 'entry_changed', aid, contentDigest, prevContentDigest: prevDigest, from: old, to: entry, fields });
|
|
114
119
|
const wasHost = isHost(old), nowHost = isHost(entry);
|
|
115
120
|
if (!wasHost && nowHost)
|
|
116
121
|
lines.push({ at: now, scope, type: 'host_added', aid, contentDigest, prevContentDigest: prevDigest, from: old, to: entry });
|
|
@@ -127,21 +132,73 @@ export function diffSnapshots(scope, next, prev, nextMeta, prevMeta) {
|
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
134
|
}
|
|
135
|
+
// 身份块(owner / personal_assistant)不属于 entries,但它的 agent_md_signed_at 决定
|
|
136
|
+
// agent.md 是否需要重拉。不单独记行的话,"换了 owner / personal assistant"这件事
|
|
137
|
+
// 在变更日志里完全不可见。
|
|
138
|
+
for (const slot of ['owner', 'personalAssistant']) {
|
|
139
|
+
const before = prevMeta?.[slot], after = nextMeta?.[slot];
|
|
140
|
+
if (!identityChanged(before, after))
|
|
141
|
+
continue;
|
|
142
|
+
lines.push({
|
|
143
|
+
at: now, scope, type: 'identity_changed', identity: slot,
|
|
144
|
+
aid: after?.aid ?? before?.aid ?? '',
|
|
145
|
+
contentDigest, prevContentDigest: prevDigest,
|
|
146
|
+
from: before ?? null, to: after ?? null,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
130
149
|
return lines;
|
|
131
150
|
}
|
|
132
151
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
152
|
+
* 条目内容的可变字段。这是"什么算变了"的唯一定义:`entry_changed` 的判定、
|
|
153
|
+
* 变更行里的 `fields` 都从这里出,不另写一份。
|
|
154
|
+
*
|
|
155
|
+
* `ownership_checked_at_ms` 不在其中——它是探测时间而不是内容。
|
|
156
|
+
* `ownerAid` 也不在:上游对它的有无本身在抖,纳进来只会制造噪音;内外归属变化
|
|
157
|
+
* 会体现在 `ownership_status` 上。
|
|
158
|
+
*/
|
|
159
|
+
const CONTENT_FIELDS = [
|
|
160
|
+
'name', 'remark', 'description', 'type', 'exttype', 'baseagent', 'ownership_status',
|
|
161
|
+
];
|
|
162
|
+
/**
|
|
163
|
+
* 条目内容相对旧值的差异字段。空数组 = 没有实际变化。
|
|
164
|
+
*
|
|
165
|
+
* 缺失与空串视为等价:normalizeEntry 已经把恒存在的字符串字段收敛成恒 `''`,
|
|
166
|
+
* 但本地快照可能来自更早的版本(字段缺失),这里再兜一层。这同时是运行期自检——
|
|
167
|
+
* 无论上游把可选字段写成 `""`、`null` 还是不写,只要业务值相同就不会进日志。
|
|
135
168
|
*/
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
169
|
+
function changedFields(a, b) {
|
|
170
|
+
const changed = [];
|
|
171
|
+
for (const key of CONTENT_FIELDS) {
|
|
172
|
+
if (text(a[key]) !== text(b[key]))
|
|
173
|
+
changed.push(key);
|
|
174
|
+
}
|
|
175
|
+
if (a.agent_md_signed_at !== b.agent_md_signed_at)
|
|
176
|
+
changed.push('agent_md_signed_at');
|
|
177
|
+
// 未知字段(`extra`)单独比:它是 key→值 的映射,按规范化指纹比较,
|
|
178
|
+
// 字段顺序不同不算变化。远端新增一个字段却没有任何 `CONTENT_FIELDS` 变化时,
|
|
179
|
+
// 变更日志里只会有这一条线索,不能漏。
|
|
180
|
+
if (extraFingerprint(a.extra) !== extraFingerprint(b.extra))
|
|
181
|
+
changed.push('extra');
|
|
182
|
+
return changed;
|
|
183
|
+
}
|
|
184
|
+
function text(value) {
|
|
185
|
+
return value ?? '';
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 身份块(`owner` / `personal_assistant`)是否变化。
|
|
189
|
+
*
|
|
190
|
+
* 身份块的 `agent_md_signed_at` 决定 agent.md 是否需要重新拉取,改了就值得记一行,
|
|
191
|
+
* 否则"换了 owner 或 personal assistant"这件事在变更日志里完全不可见。
|
|
192
|
+
* 两侧都缺失时不算变更(老快照没有身份块是常态,不是事件)。
|
|
193
|
+
*/
|
|
194
|
+
function identityChanged(a, b) {
|
|
195
|
+
if (!a && !b)
|
|
196
|
+
return false;
|
|
197
|
+
if (!a || !b)
|
|
198
|
+
return true;
|
|
199
|
+
return a.aid !== b.aid
|
|
200
|
+
|| text(a.name) !== text(b.name)
|
|
201
|
+
|| (a.agent_md_signed_at ?? 0) !== (b.agent_md_signed_at ?? 0);
|
|
145
202
|
}
|
|
146
203
|
/**
|
|
147
204
|
* 收集需要刷新 agent.md 的 AID:
|
|
@@ -162,6 +219,12 @@ export function collectAgentMdRefreshAids(lines, nextMeta, prevMeta, nextSnapsho
|
|
|
162
219
|
continue;
|
|
163
220
|
if (!line.aid)
|
|
164
221
|
continue;
|
|
222
|
+
if (line.type === 'identity_changed') {
|
|
223
|
+
// 身份块的刷新对象不是 name 字段,而是 aid 本身。
|
|
224
|
+
if (line.to?.aid)
|
|
225
|
+
aids.add(line.to.aid);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
165
228
|
const isAdd = line.type === 'agent_added' || line.type === 'contact_added';
|
|
166
229
|
const signedAtChanged = line.from?.agent_md_signed_at !== line.to?.agent_md_signed_at;
|
|
167
230
|
if (isAdd || signedAtChanged)
|
|
@@ -185,23 +248,81 @@ export function collectAgentMdRefreshAids(lines, nextMeta, prevMeta, nextSnapsho
|
|
|
185
248
|
}
|
|
186
249
|
/**
|
|
187
250
|
* 将变更行追加到 changes/<YYYY-MM>.jsonl,并更新 index.json。
|
|
188
|
-
*
|
|
251
|
+
*
|
|
252
|
+
* 无变更时跳过。**失败会抛出**:调用方必须在覆盖本地快照之前调用它,
|
|
253
|
+
* 这样写日志失败时整次同步失败、下次重试,而不是"快照前进了、日志缺一块"。
|
|
254
|
+
* 吞掉异常会让这条链永久缺环,事后无法从日志补回。
|
|
189
255
|
*/
|
|
190
256
|
export function appendChanges(directory, lines, now = new Date()) {
|
|
191
257
|
if (lines.length === 0)
|
|
192
258
|
return;
|
|
259
|
+
const cDir = changesDir(directory);
|
|
260
|
+
fs.mkdirSync(cDir, { recursive: true, mode: 0o700 });
|
|
261
|
+
const jsonl = lines.map(l => JSON.stringify(l)).join('\n') + '\n';
|
|
262
|
+
// 月份由变更行自己的 `at` 决定,不由写盘那一刻的墙钟决定。
|
|
263
|
+
// 服务端时间与本机时间不一致、或月末跨零点时,否则会出现"写着 10 月的记录躺在
|
|
264
|
+
// 11 月文件里"这种按文件找、按时间戳找都对不上的孤儿行。
|
|
265
|
+
const { year, month } = changesMonth(lines);
|
|
266
|
+
const target = changesFile(directory, year, month);
|
|
267
|
+
if (alreadyAppended(target, lines)) {
|
|
268
|
+
logger.debug(`[OwnerDirectoryStore] ${path.basename(target)} already ends with this batch; skipping duplicate append`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
fs.appendFileSync(target, jsonl, 'utf-8');
|
|
272
|
+
updateChangesIndex(directory, lines, year, month);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 这一批是否已经写过了。
|
|
276
|
+
*
|
|
277
|
+
* 调用方先写日志、后覆盖快照,所以"日志写成功但快照没写成"会触发重试;
|
|
278
|
+
* 重试时 diff 结果与上一批完全相同,这里比对末尾那行的 digest 对就能识别,
|
|
279
|
+
* 避免同一批变更落两份。
|
|
280
|
+
*
|
|
281
|
+
* 判据:最后一行与这一批的首行共享 `contentDigest` + `prevContentDigest`。
|
|
282
|
+
* 一整批共用同一个 digest 对(见 diffSnapshots),所以只比首行就够。
|
|
283
|
+
* 文件里最后一行解析失败时按"没写过"处理——宁可重复,不能漏记。
|
|
284
|
+
*/
|
|
285
|
+
function alreadyAppended(file, lines) {
|
|
286
|
+
if (lines.length === 0)
|
|
287
|
+
return false;
|
|
288
|
+
let tail;
|
|
193
289
|
try {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
290
|
+
const size = fs.statSync(file).size;
|
|
291
|
+
if (size === 0)
|
|
292
|
+
return false;
|
|
293
|
+
// 只需最后一行:连同换行符读尾部 8KB,足够覆盖单行(条目字段有截断上限)。
|
|
294
|
+
const length = Math.min(size, 8192);
|
|
295
|
+
const fd = fs.openSync(file, 'r');
|
|
296
|
+
try {
|
|
297
|
+
const buffer = Buffer.alloc(length);
|
|
298
|
+
fs.readSync(fd, buffer, 0, length, size - length);
|
|
299
|
+
tail = buffer.toString('utf-8');
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
fs.closeSync(fd);
|
|
303
|
+
}
|
|
199
304
|
}
|
|
200
|
-
catch
|
|
201
|
-
|
|
305
|
+
catch {
|
|
306
|
+
return false;
|
|
202
307
|
}
|
|
308
|
+
const lastLine = tail.split('\n').filter(line => line.trim()).pop();
|
|
309
|
+
if (!lastLine)
|
|
310
|
+
return false;
|
|
311
|
+
try {
|
|
312
|
+
const last = JSON.parse(lastLine);
|
|
313
|
+
return last.contentDigest === lines[0].contentDigest
|
|
314
|
+
&& last.prevContentDigest === lines[0].prevContentDigest;
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function changesMonth(lines) {
|
|
321
|
+
// `at` 是该行所属快照的 fetchedAt;同一批共用一个 `at`,取最早的即可。
|
|
322
|
+
const stamp = new Date(lines[0].at);
|
|
323
|
+
return { year: stamp.getUTCFullYear(), month: stamp.getUTCMonth() + 1 };
|
|
203
324
|
}
|
|
204
|
-
function updateChangesIndex(directory, lines,
|
|
325
|
+
function updateChangesIndex(directory, lines, year, month) {
|
|
205
326
|
const indexPath = changesIndexFile(directory);
|
|
206
327
|
let index = [];
|
|
207
328
|
try {
|
|
@@ -210,8 +331,7 @@ function updateChangesIndex(directory, lines, now) {
|
|
|
210
331
|
index = raw;
|
|
211
332
|
}
|
|
212
333
|
catch { /* fresh */ }
|
|
213
|
-
const
|
|
214
|
-
const existing = index.find(e => e.year === y && e.month === m);
|
|
334
|
+
const existing = index.find(e => e.year === year && e.month === month);
|
|
215
335
|
const ats = lines.map(l => l.at);
|
|
216
336
|
const minAt = Math.min(...ats), maxAt = Math.max(...ats);
|
|
217
337
|
if (existing) {
|
|
@@ -220,7 +340,7 @@ function updateChangesIndex(directory, lines, now) {
|
|
|
220
340
|
existing.lastAt = Math.max(existing.lastAt, maxAt);
|
|
221
341
|
}
|
|
222
342
|
else {
|
|
223
|
-
index.push({ year
|
|
343
|
+
index.push({ year, month, count: lines.length, firstAt: minAt, lastAt: maxAt });
|
|
224
344
|
index.sort((a, b) => a.year !== b.year ? a.year - b.year : a.month - b.month);
|
|
225
345
|
}
|
|
226
346
|
atomicWriteJson(indexPath, index);
|
package/dist/eck/kit-renderer.js
CHANGED
|
@@ -174,8 +174,9 @@ export function renderKitSections(ctx, manifestFile = DEFAULT_MANIFEST_FILE) {
|
|
|
174
174
|
diag.injected = true;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
//
|
|
178
|
-
|
|
177
|
+
// 单目录段超限:注入截断说明行。单文件截断的说明已随该文件内容一起追加,
|
|
178
|
+
// 这里只在确实有文件被丢弃时补一行,避免出现「0 个文件未加载」的空话。
|
|
179
|
+
if (diag.dirOverflow && diag.dirOverflow.droppedFiles > 0) {
|
|
179
180
|
const ov = diag.dirOverflow;
|
|
180
181
|
const displayPath = shortenPath(diag.resolvedPath ?? rawPath, pathMappings);
|
|
181
182
|
const note = `[注意] 目录 ${displayPath} 未完整加载:${ov.droppedFiles} 个文件未加载` +
|
|
@@ -235,9 +236,15 @@ const PARAM_DESCRIPTIONS = {
|
|
|
235
236
|
selfName: '当前 agent 的显示名',
|
|
236
237
|
lifecycle: '当前 agent 生命周期(created/ownerpending/bootstrapping/active)',
|
|
237
238
|
isBootstrapping: '当前 agent 是否处于 bootstrap 首次设定阶段',
|
|
238
|
-
hasPersona: '
|
|
239
|
-
hasWorkingMemory: '是否有 working memory',
|
|
239
|
+
hasPersona: '是否有自我定义内容(soul/ 下除指南外有非空文件)',
|
|
240
240
|
hasOwnerDirectory: '是否有 Owner 名录注入文件($AGENT_DIR/directory/directory.md)',
|
|
241
|
+
ownerAid: 'Owner 的 AID(名录快照为准,未落地时退回静态配置)',
|
|
242
|
+
ownerName: 'Owner 的显示名(名录快照)',
|
|
243
|
+
personalAssistantAid: '个人助理的 AID(名录快照;没有个人助理时为空)',
|
|
244
|
+
personalAssistantName: '个人助理的显示名(名录快照)',
|
|
245
|
+
isPersonalAssistant: '当前 agent 是否就是 Owner 的个人助理(即时比较,读不到身份时为 false)',
|
|
246
|
+
isOwner: '当前 agent 是否就是名录里的 Owner(即时比较;Owner 通常是人,一般恒为 false)',
|
|
247
|
+
contactsState: '准入现状一句话:内部联系人/外部联系人/名录外的人分别可不可联系',
|
|
241
248
|
peerId: '对端在该渠道的原生 ID',
|
|
242
249
|
peerKey: '对端跨渠道唯一标识(channel#urlEncode(peerId))',
|
|
243
250
|
peerName: '对端显示名',
|
|
@@ -271,7 +278,7 @@ const PARAM_DESCRIPTIONS = {
|
|
|
271
278
|
weekday: '当前本地星期几(按 timezone+locale)',
|
|
272
279
|
osInfo: '操作系统及版本(如 Windows 11 Pro (win32 10.0.26200))',
|
|
273
280
|
threadId: '话题 ID(多话题路由时)',
|
|
274
|
-
chatMode: '会话模式(interactive=同步交互 / proactive
|
|
281
|
+
chatMode: '会话模式(interactive=同步交互 / proactive=主动推送 / paactive=PA activity)',
|
|
275
282
|
isTriggerTask: '当前任务是否来源于 Trigger(true/false)',
|
|
276
283
|
proactivePreTool1stMsgChk: 'proactive 前置工具首消息检查(true/false)',
|
|
277
284
|
proactiveToolUseReminder: 'proactive 工具调用提醒(true/false)',
|
|
@@ -12,6 +12,8 @@ import { readVerifiedText, isShippedPath } from '../core/file-integrity/read.js'
|
|
|
12
12
|
export const DIR_MAX_FILES = 20;
|
|
13
13
|
/** 单目录段默认最多总字节(40KB) */
|
|
14
14
|
export const DIR_MAX_BYTES = 40 * 1024;
|
|
15
|
+
/** 单目录段里单个文件的默认上限(8KB);超过截断,避免单个失控文件吃光整段乃至全局额度 */
|
|
16
|
+
export const DIR_MAX_FILE_BYTES = 8 * 1024;
|
|
15
17
|
/** 整个清单默认最多文件数 */
|
|
16
18
|
export const TOTAL_MAX_FILES = 50;
|
|
17
19
|
/** 整个清单默认最多总字节(100KB) */
|
|
@@ -407,9 +409,14 @@ export function loadSectionFiles(section, vars, sessionCache, overflowOut) {
|
|
|
407
409
|
const resolved = resolvePath(section.path, vars);
|
|
408
410
|
if (!resolved)
|
|
409
411
|
return [];
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
412
|
+
const limits = {
|
|
413
|
+
maxFiles: section.maxFiles ?? DIR_MAX_FILES,
|
|
414
|
+
maxBytes: section.maxBytes ?? DIR_MAX_BYTES,
|
|
415
|
+
maxFileBytes: section.maxFileBytes ?? DIR_MAX_FILE_BYTES,
|
|
416
|
+
skipUnchangedTemplate: section.skipUnchangedTemplate,
|
|
417
|
+
unchangedTemplateKeep: section.unchangedTemplateKeep,
|
|
418
|
+
};
|
|
419
|
+
const { files, overflow } = readDirectoryFiles(resolved, section.pattern, limits, vars);
|
|
413
420
|
if (overflow && overflowOut)
|
|
414
421
|
overflowOut.value = overflow;
|
|
415
422
|
return files.map(([name, content]) => [path.join(resolved, name), content]);
|
|
@@ -425,10 +432,18 @@ function loadFileSection(filePath, vars, sessionCache) {
|
|
|
425
432
|
return content === null ? null : [resolved, content];
|
|
426
433
|
}
|
|
427
434
|
/**
|
|
428
|
-
*
|
|
435
|
+
* 读取目录下匹配文件,受三层限额约束:
|
|
436
|
+
* - maxFiles:文件数上限,超出的文件不加载;
|
|
437
|
+
* - maxBytes:本段总字节上限,超出的文件不加载;
|
|
438
|
+
* - maxFileBytes:单文件上限,超出的**截断**(不丢弃,其余文件照常加载)。
|
|
439
|
+
*
|
|
440
|
+
* 单文件限额存在的意义:没有它时「至少保留 1 个文件」的规则会让一个超大文件直接吃光
|
|
441
|
+
* 本段额度(甚至全局总闸),把后面所有段挤掉。截断只损失一个文件末尾,不影响其它段。
|
|
442
|
+
*
|
|
429
443
|
* 返回已加载文件 + 溢出信息(超限时)。按 fileCache 缓存目录列表与文件内容。
|
|
430
444
|
*/
|
|
431
|
-
function readDirectoryFiles(dirPath, pattern,
|
|
445
|
+
function readDirectoryFiles(dirPath, pattern, limits, vars) {
|
|
446
|
+
const { maxFiles, maxBytes, maxFileBytes, skipUnchangedTemplate, unchangedTemplateKeep } = limits;
|
|
432
447
|
const glob = pattern || '*.md';
|
|
433
448
|
const cacheOptions = sectionCacheOptions(dirPath, vars);
|
|
434
449
|
const readNames = () => {
|
|
@@ -447,6 +462,7 @@ function readDirectoryFiles(dirPath, pattern, maxFiles, maxBytes, vars) {
|
|
|
447
462
|
const out = [];
|
|
448
463
|
let usedBytes = 0;
|
|
449
464
|
let overflow;
|
|
465
|
+
const truncated = [];
|
|
450
466
|
for (let i = 0; i < names.length; i++) {
|
|
451
467
|
const f = names[i];
|
|
452
468
|
// 文件数限额
|
|
@@ -455,9 +471,20 @@ function readDirectoryFiles(dirPath, pattern, maxFiles, maxBytes, vars) {
|
|
|
455
471
|
break;
|
|
456
472
|
}
|
|
457
473
|
const fp = path.join(dirPath, f);
|
|
458
|
-
|
|
474
|
+
let content = loadKitsDoc(fp, vars);
|
|
459
475
|
if (content === null)
|
|
460
476
|
continue;
|
|
477
|
+
// 仍是未改动的骨架:占位说明不算内容,跳过(不计入文件数与字节)。
|
|
478
|
+
if (skipUnchangedTemplate
|
|
479
|
+
&& !unchangedTemplateKeep?.includes(f)
|
|
480
|
+
&& matchesTemplate(content, f, skipUnchangedTemplate))
|
|
481
|
+
continue;
|
|
482
|
+
// 单文件限额:截断而不是丢弃,避免一个失控文件挤掉整段。
|
|
483
|
+
const originalBytes = Buffer.byteLength(content, 'utf-8');
|
|
484
|
+
if (originalBytes > maxFileBytes) {
|
|
485
|
+
content = `${truncateUtf8(content, maxFileBytes)}\n\n[注意] 本文件超过单文件上限 ${formatKb(maxFileBytes)},已截断(原 ${formatKb(originalBytes)})。`;
|
|
486
|
+
truncated.push({ name: f, originalBytes, limit: maxFileBytes });
|
|
487
|
+
}
|
|
461
488
|
// 字节限额(至少加载一个文件,避免单个超大文件导致空目录)
|
|
462
489
|
const size = Buffer.byteLength(content, 'utf-8');
|
|
463
490
|
if (out.length > 0 && usedBytes + size > maxBytes) {
|
|
@@ -467,8 +494,30 @@ function readDirectoryFiles(dirPath, pattern, maxFiles, maxBytes, vars) {
|
|
|
467
494
|
usedBytes += size;
|
|
468
495
|
out.push([f, content]);
|
|
469
496
|
}
|
|
497
|
+
if (truncated.length > 0) {
|
|
498
|
+
overflow = { ...(overflow ?? { droppedFiles: 0, reason: 'bytes', limit: maxBytes }), truncated };
|
|
499
|
+
}
|
|
470
500
|
return { files: out, overflow };
|
|
471
501
|
}
|
|
502
|
+
/** 按字节上限截断文本,并回退到 UTF-8 字符边界,避免切出半个汉字。 */
|
|
503
|
+
function truncateUtf8(text, maxBytes) {
|
|
504
|
+
const buf = Buffer.from(text, 'utf-8');
|
|
505
|
+
let end = maxBytes;
|
|
506
|
+
// 0b10xxxxxx 是 UTF-8 续字节;落在续字节上说明切在字符中间,往前退。
|
|
507
|
+
while (end > 0 && (buf[end] & 0xc0) === 0x80)
|
|
508
|
+
end -= 1;
|
|
509
|
+
return buf.subarray(0, end).toString('utf-8');
|
|
510
|
+
}
|
|
511
|
+
function formatKb(bytes) {
|
|
512
|
+
return bytes >= 1024 ? `${Math.round(bytes / 1024)}KB` : `${bytes}B`;
|
|
513
|
+
}
|
|
514
|
+
/** 内容是否仍与 `kits/templates/<templateDir>/<同名文件>` 完全一致(未改动的骨架)。 */
|
|
515
|
+
function matchesTemplate(content, name, templateDir) {
|
|
516
|
+
const template = loadKitsDoc(path.join(kitsDir(), 'templates', templateDir, name), {});
|
|
517
|
+
if (template === null)
|
|
518
|
+
return false;
|
|
519
|
+
return content.trim() === template.trim();
|
|
520
|
+
}
|
|
472
521
|
function matchGlob(filename, pattern) {
|
|
473
522
|
const regex = pattern
|
|
474
523
|
.replace(/\./g, '\\.')
|
|
@@ -11,6 +11,7 @@ import { randomUUID } from 'crypto';
|
|
|
11
11
|
import { isEckSnapshotsEnabled } from '../config-store.js';
|
|
12
12
|
import { eckDebugDir } from '../paths.js';
|
|
13
13
|
import { logger } from '../utils/logger.js';
|
|
14
|
+
import { paactiveMessageManifest } from './paactive-context.js';
|
|
14
15
|
import { loadManifest, evaluateWhen, renderTemplate, loadSectionFiles, defaultModeNames, } from './manifest-engine.js';
|
|
15
16
|
const MESSAGE_MANIFEST_FILE = 'eck_message_manifest.json';
|
|
16
17
|
// ── time formatting (per IANA timezone) ──
|
|
@@ -35,7 +36,8 @@ export function formatLocalTime(epochMs, timeZone) {
|
|
|
35
36
|
}
|
|
36
37
|
// ── single item render ──
|
|
37
38
|
function renderOneItem(item, sessionVars, sessionCache, contentSentinel) {
|
|
38
|
-
const sections = loadManifest(
|
|
39
|
+
const sections = loadManifest(sessionVars.chatMode === 'paactive'
|
|
40
|
+
? paactiveMessageManifest(sessionVars) : MESSAGE_MANIFEST_FILE);
|
|
39
41
|
// 各 modeType 当前激活的 modeName:agent config.render(经 sessionVars.renderModes 透传)
|
|
40
42
|
// 覆盖 manifest 里标 isDefault 的缺省。详见 docs/observer-insert-design.md 第二部分。
|
|
41
43
|
const defaults = defaultModeNames(sections);
|
|
@@ -275,7 +277,8 @@ export function renderMessageBody(items, sessionVars, sessionId) {
|
|
|
275
277
|
* 逐条结果 renderedParts 已是最终文本,作为字面量填入 wrapper 的 {{@loop}},不二次解析。
|
|
276
278
|
*/
|
|
277
279
|
function wrapBatch(renderedParts, sessionVars, sessionCache) {
|
|
278
|
-
const sections = loadManifest(
|
|
280
|
+
const sections = loadManifest(sessionVars.chatMode === 'paactive'
|
|
281
|
+
? paactiveMessageManifest(sessionVars) : MESSAGE_MANIFEST_FILE);
|
|
279
282
|
const loopSection = sections.find(s => s.loop && s.enabled !== false && evaluateWhen(s.when, sessionVars));
|
|
280
283
|
if (!loopSection || !loopSection.loop || !loopSection.file)
|
|
281
284
|
return null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { evaluateWhen, loadManifest, loadSectionFiles } from './manifest-engine.js';
|
|
2
|
+
export const PAACTIVE_SYSTEM_MANIFEST = 'eck_manifest.paactive.json';
|
|
3
|
+
export const PAACTIVE_MESSAGE_MANIFEST = 'eck_message_manifest.paactive.json';
|
|
4
|
+
/** Assemble PA context from shared, authenticated task facts, not proactive state. */
|
|
5
|
+
export function buildPaactiveSystemVars(facts) {
|
|
6
|
+
if (facts.channel !== 'aun' || facts.chatType !== 'private'
|
|
7
|
+
|| (facts.lifecycle !== undefined && facts.lifecycle !== 'active')
|
|
8
|
+
|| (facts.sessionType !== undefined && facts.sessionType !== 'main')
|
|
9
|
+
|| facts.peerType !== 'human'
|
|
10
|
+
|| (facts.peerRole !== 'owner' && facts.peerRole !== 'admin')
|
|
11
|
+
|| facts.chatMode !== 'paactive') {
|
|
12
|
+
throw new Error('paactive requires an active AUN human owner/admin private main session');
|
|
13
|
+
}
|
|
14
|
+
if (Object.keys(facts).some(key => key.startsWith('proactive'))) {
|
|
15
|
+
throw new Error('paactive context must not contain proactive policy variables');
|
|
16
|
+
}
|
|
17
|
+
return { ...facts, lifecycle: 'active', chatMode: 'paactive' };
|
|
18
|
+
}
|
|
19
|
+
/** Message and batch rendering use the same immutable mode facts as system rendering. */
|
|
20
|
+
export function buildPaactiveMessageVars(facts) {
|
|
21
|
+
// PA's packaged message modes are independent of the shared interactive
|
|
22
|
+
// render configuration; unsupported legacy mode names must not erase input.
|
|
23
|
+
return { ...buildPaactiveSystemVars(facts), renderModes: undefined };
|
|
24
|
+
}
|
|
25
|
+
export function paactiveSystemManifest(vars) {
|
|
26
|
+
const context = buildPaactiveSystemVars(vars);
|
|
27
|
+
const sections = loadManifest(PAACTIVE_SYSTEM_MANIFEST);
|
|
28
|
+
for (const id of ['reply-contract', 'channel-layer', 'session']) {
|
|
29
|
+
const section = sections.find(item => item.id === id && item.enabled !== false);
|
|
30
|
+
if (!section || !evaluateWhen(section.when, context)
|
|
31
|
+
|| !loadSectionFiles(section, context, new Map()).some(([, body]) => body.trim())) {
|
|
32
|
+
throw new Error(`paactive system manifest is missing required section: ${id}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return PAACTIVE_SYSTEM_MANIFEST;
|
|
36
|
+
}
|
|
37
|
+
export function paactiveMessageManifest(vars) {
|
|
38
|
+
const context = buildPaactiveMessageVars(vars);
|
|
39
|
+
const section = loadManifest(PAACTIVE_MESSAGE_MANIFEST)
|
|
40
|
+
.find(item => item.id === 'msg-private-default' && item.enabled !== false);
|
|
41
|
+
if (!section || !loadSectionFiles(section, context, new Map()).some(([, body]) => body.trim())) {
|
|
42
|
+
throw new Error('paactive message manifest is missing required private template');
|
|
43
|
+
}
|
|
44
|
+
return PAACTIVE_MESSAGE_MANIFEST;
|
|
45
|
+
}
|
|
@@ -322,7 +322,7 @@ function assertServices(value) {
|
|
|
322
322
|
value.forEach((service, index) => {
|
|
323
323
|
if (!isRecord(service))
|
|
324
324
|
throw makeError(`services[${index}] must be an object`, 'INVALID_SETTINGS_VALUE');
|
|
325
|
-
const allowedKeys = new Set(['name', 'enabled', 'port', 'proxy']);
|
|
325
|
+
const allowedKeys = new Set(['name', 'enabled', 'port', 'runtime', 'health', 'proxy']);
|
|
326
326
|
if (Object.keys(service).some(key => !allowedKeys.has(key)))
|
|
327
327
|
throw makeError(`services[${index}] contains an unsupported field`, 'INVALID_SETTINGS_VALUE');
|
|
328
328
|
const name = assertString(service.name, `services[${index}].name`, { max: 64 });
|
|
@@ -509,7 +509,7 @@ function validateDefaultsValue(fieldPath, value) {
|
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
511
|
if (fieldPath === 'config.chatMode') {
|
|
512
|
-
if (!['interactive', 'proactive'].includes(String(value)))
|
|
512
|
+
if (!['interactive', 'proactive', 'paactive'].includes(String(value)))
|
|
513
513
|
throw makeError(`${fieldPath} is invalid`, 'INVALID_SETTINGS_VALUE');
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
2
2
|
import { resolvePeerDisplayLabel } from '../config/peer-book.js';
|
|
3
3
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
4
|
+
import { ConfigTarget, read } from '../config/config-manager.js';
|
|
5
|
+
import { resolveAgentLifecycle } from '../config/lifecycle.js';
|
|
4
6
|
import { resolveChatMode } from '../core/message/peer-mode.js';
|
|
5
7
|
import { resolvePermissionMode } from '../core/model/config-scope.js';
|
|
6
8
|
import { formatPeerKey } from '../core/relation/peer-identity.js';
|
|
@@ -84,29 +86,35 @@ export function createEcwebMessageContextProvider(sessionManager, resolveRuntime
|
|
|
84
86
|
const peerKey = formatPeerKey(identity.channelType, conversationId);
|
|
85
87
|
const detail = resolvePeerRoleDetail({ ...identity, chatType, conversationId, peerType });
|
|
86
88
|
const role = detail.effectiveRole || 'none';
|
|
89
|
+
const candidate = sessionId ? await sessionManager.getSessionById(sessionId) : undefined;
|
|
90
|
+
const scopedSession = candidate?.selfAID === identity.selfAid
|
|
91
|
+
&& candidate.channelType === identity.channelType
|
|
92
|
+
&& candidate.channelId === conversationId
|
|
93
|
+
? candidate : undefined;
|
|
87
94
|
const result = {
|
|
88
95
|
role,
|
|
89
96
|
roleSource: detail.source,
|
|
90
97
|
permissionMode: resolvePermissionMode({ self: identity.selfAid, peerKey, role }),
|
|
91
|
-
chatMode: resolveChatMode({
|
|
98
|
+
chatMode: resolveChatMode({
|
|
99
|
+
self: identity.selfAid, peerKey, role, chatType, peerType,
|
|
100
|
+
channelType: identity.channelType,
|
|
101
|
+
lifecycle: resolveAgentLifecycle(read(ConfigTarget.Agent, { self: identity.selfAid }) ?? {}),
|
|
102
|
+
sessionType: scopedSession?.sessionType ?? scopedSession?.metadata?.sessionType ?? 'main',
|
|
103
|
+
}),
|
|
92
104
|
...(peerLabels ? { peerLabels } : {}),
|
|
93
105
|
};
|
|
94
|
-
if (
|
|
95
|
-
const session =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const fileInfo = sessionManager.getSessionFileInfo(session.projectPath, session.agentSessionId, session.baseagent, session.selfAID);
|
|
105
|
-
if (Number.isFinite(fileInfo.turns) && fileInfo.turns > 0)
|
|
106
|
-
result.turns = fileInfo.turns;
|
|
107
|
-
}
|
|
108
|
-
catch { }
|
|
106
|
+
if (scopedSession) {
|
|
107
|
+
const session = scopedSession;
|
|
108
|
+
const status = resolveRuntimeStatus?.(session);
|
|
109
|
+
if (status)
|
|
110
|
+
result.status = status;
|
|
111
|
+
if (session.agentSessionId && session.projectPath && session.baseagent) {
|
|
112
|
+
try {
|
|
113
|
+
const fileInfo = sessionManager.getSessionFileInfo(session.projectPath, session.agentSessionId, session.baseagent, session.selfAID);
|
|
114
|
+
if (Number.isFinite(fileInfo.turns) && fileInfo.turns > 0)
|
|
115
|
+
result.turns = fileInfo.turns;
|
|
109
116
|
}
|
|
117
|
+
catch { }
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
return result;
|
package/dist/index.js
CHANGED
|
@@ -366,7 +366,7 @@ async function main() {
|
|
|
366
366
|
// 渠道插件系统
|
|
367
367
|
trace.mark('daemon.channelCreate');
|
|
368
368
|
const channelLoader = new ChannelLoader(daemonCfg.debug, daemonCfg.aun?.defaultEncrypt);
|
|
369
|
-
registerBuiltinChannelPlugins(channelLoader);
|
|
369
|
+
await registerBuiltinChannelPlugins(channelLoader);
|
|
370
370
|
// Create channel instances: 每个 self-agent 各自的 channels
|
|
371
371
|
const evolagentInstances = [];
|
|
372
372
|
for (const agent of agentRegistry.runnableAgents()) {
|
|
@@ -688,10 +688,10 @@ async function main() {
|
|
|
688
688
|
return !!inst && inst.channel.getStatus?.().connected === true;
|
|
689
689
|
};
|
|
690
690
|
const contactBindIpcExecutor = (channelType) => {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
691
|
+
return {
|
|
692
|
+
register: (request) => channelLoader.contactBindRegistry.registerPending(channelType, request),
|
|
693
|
+
isChannelReady: isContactBindChannelReady,
|
|
694
|
+
};
|
|
695
695
|
};
|
|
696
696
|
cmdHandler.setAgentStorageClientResolver(createAgentStorageClientResolver(channelInstances));
|
|
697
697
|
const msgBridge = new MessageBridge(defaultProjectPath, sessionManager, processor, messageQueue, cmdHandler, eventBus, primaryAgent?.config.debounce, processLevelOwners);
|
|
@@ -841,6 +841,10 @@ async function main() {
|
|
|
841
841
|
trace.mark('daemon.ipcCreate');
|
|
842
842
|
const ipcServer = new IpcServer(resolvePaths().socket, createIpcStatusProvider({
|
|
843
843
|
channelInstances,
|
|
844
|
+
getChannelRuntimeSnapshot: () => channelLoader.getSnapshot(agentRegistry.list().flatMap(info => {
|
|
845
|
+
const agent = agentRegistry.get(info.aid);
|
|
846
|
+
return agent ? [agent] : [];
|
|
847
|
+
})),
|
|
844
848
|
statsCollector,
|
|
845
849
|
agentRegistry,
|
|
846
850
|
messageQueue,
|
package/dist/ipc.js
CHANGED
|
@@ -1174,7 +1174,7 @@ export class IpcServer {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
if (cmd.argv !== undefined && ['handoff-status', 'handoff-list', 'handoff-trace'].includes(cmd.type)) {
|
|
1176
1176
|
try {
|
|
1177
|
-
const { parseList, parseTrace } = await import('./
|
|
1177
|
+
const { parseList, parseTrace } = await import('./core/handoff/argv-parse.js');
|
|
1178
1178
|
if (!Array.isArray(cmd.argv) || cmd.argv[0] !== 'handoff' || `handoff-${cmd.argv[1]}` !== cmd.type) {
|
|
1179
1179
|
return { ok: false, code: 'INVALID_REQUEST', error: 'Handoff endpoint does not match argv' };
|
|
1180
1180
|
}
|
package/dist/paths.js
CHANGED
|
@@ -7,6 +7,22 @@ import { migrateLegacyAgentJsonlLogs } from './core/audit/log-integrity.js';
|
|
|
7
7
|
const isWindows = process.platform === 'win32';
|
|
8
8
|
let _root = null;
|
|
9
9
|
export function resolveRoot() {
|
|
10
|
+
// Tests may clear their per-case home while asynchronous callbacks are
|
|
11
|
+
// still running. Keep those callbacks in the suite's temporary root rather
|
|
12
|
+
// than falling back to the developer's live runtime directory.
|
|
13
|
+
if (process.env.EVOLCORE_TEST === '1') {
|
|
14
|
+
const testRoot = process.env[RUNTIME_HOME_ENV] || process.env.EVOLCORE_TEST_ROOT;
|
|
15
|
+
const tempDir = process.env.TMPDIR;
|
|
16
|
+
if (!testRoot || !path.isAbsolute(testRoot) || !tempDir || !path.isAbsolute(tempDir)) {
|
|
17
|
+
throw new Error('Test runtime requires an absolute isolated root inside TMPDIR');
|
|
18
|
+
}
|
|
19
|
+
const relative = path.relative(path.resolve(tempDir), path.resolve(testRoot));
|
|
20
|
+
if (!relative || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
21
|
+
throw new Error('Test runtime root must stay inside TMPDIR');
|
|
22
|
+
}
|
|
23
|
+
_root = testRoot;
|
|
24
|
+
return _root;
|
|
25
|
+
}
|
|
10
26
|
if (_root)
|
|
11
27
|
return _root;
|
|
12
28
|
if (process.env[RUNTIME_HOME_ENV]) {
|
|
@@ -105,6 +121,16 @@ export function agentPeerAuditPath(aid) {
|
|
|
105
121
|
export function agentPersonalDir(aid) {
|
|
106
122
|
return path.join(agentDir(aid), 'personal');
|
|
107
123
|
}
|
|
124
|
+
/** 常驻自我定义目录:其中每个非空 .md 都会注入 system prompt。 */
|
|
125
|
+
export function agentSoulDir(aid) {
|
|
126
|
+
return path.join(agentPersonalDir(aid), 'soul');
|
|
127
|
+
}
|
|
128
|
+
/** soul 目录的机制指南文件名;注入时排除(它不是人格内容)。 */
|
|
129
|
+
export const SOUL_GUIDE_FILE = '00-GUIDE.md';
|
|
130
|
+
/** soul 目录里承载「我是谁」的分册。 */
|
|
131
|
+
export const SOUL_IDENTITY_FILE = '01-identity.md';
|
|
132
|
+
/** soul 目录里承载「性格与表达」的分册;创建时给的 persona 正文与旧版合集都落到这里。 */
|
|
133
|
+
export const SOUL_PERSONA_FILE = '02-persona.md';
|
|
108
134
|
/** Agent-owned Bootstrap completion welcome template. */
|
|
109
135
|
export function agentWelcomePath(aid) {
|
|
110
136
|
return path.join(agentPersonalDir(aid), 'welcome.md');
|