evolcore 0.0.43-test.1 → 0.0.43-test.3
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 -1
- 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 +39 -15
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +7 -2
- package/dist/channels/aun.js +522 -50
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/daemon.js +4 -0
- 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 +20 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +18 -19
- 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 +149 -91
- 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 +3 -2
- 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/task-context.js +3 -1
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -2
- package/dist/config/config-manager.js +32 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +29 -4
- package/dist/config/role-service.js +12 -7
- package/dist/config/role-store.js +30 -8
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +17 -11
- package/dist/core/auth/operation-catalog.js +5 -13
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +47 -40
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +16 -2
- package/dist/core/command/menu-handler.js +107 -14
- package/dist/core/command/menu-protocol.js +28 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +139 -51
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +10 -12
- 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/lifecycle-notice.js +185 -0
- 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 +35 -2
- package/dist/core/message/contact-admission.js +530 -0
- package/dist/core/message/im-renderer.js +111 -16
- package/dist/core/message/message-admission.js +29 -54
- package/dist/core/message/message-bridge.js +62 -8
- package/dist/core/message/message-utils.js +9 -5
- package/dist/core/message/peer-mode.js +55 -13
- package/dist/core/message/response-engine.js +298 -78
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +25 -38
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +18 -5
- 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/core/thread/thread-service.js +6 -4
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +125 -29
- package/dist/directory/owner-directory-cache.js +554 -58
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +154 -58
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +399 -90
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +118 -33
- package/dist/directory/owner-directory-store.js +117 -30
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +18 -8
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +28 -16
- package/dist/index.js +20 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +29 -1
- package/dist/product.js +1 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +2 -1
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +7 -4
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +12 -7
- 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/README.md +18 -0
- package/ecagent/dist/agent-loop.js +43 -1
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +227 -0
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +64 -7
- package/kits/eck_manifest.memory.json +93 -4
- 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 +44 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- 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/soul/00-GUIDE.md +39 -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/channel.md +2 -2
- 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/personal-assistant.md +50 -0
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +3 -2
- 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
package/dist/cli/index.js
CHANGED
|
@@ -18,15 +18,16 @@ import { isInitCancelledError, printInitCancelHint } from './init-cancel.js';
|
|
|
18
18
|
import { assertManagedTopLevelCommandAllowed, ManagedCommandNotAllowedError } from './managed-command-guard.js';
|
|
19
19
|
import { resolveDebugContext, stripAsSessionArgs } from './debug-mode.js';
|
|
20
20
|
const MAIN_HELP = `用法: ec <command> [选项]
|
|
21
|
+
ec 显示本帮助(等同 ec --help / ec -h)
|
|
21
22
|
|
|
22
23
|
服务:
|
|
23
24
|
init 初始化默认配置、owner、控制 AID 与 EC Web
|
|
24
|
-
start
|
|
25
|
+
start 启动服务(不指定命令时不再自动启动)
|
|
25
26
|
stop 停止服务
|
|
26
27
|
restart 重启服务并检查更新
|
|
27
|
-
upgrade 检查 EvolCore、EC Web 和 FASTAUN
|
|
28
|
-
update
|
|
29
|
-
status
|
|
28
|
+
upgrade 检查 EvolCore、EC Web 和 FASTAUN 是否有更新(只查询,不安装)
|
|
29
|
+
update 受理或复用唯一更新任务并异步执行(update status 查询进度)
|
|
30
|
+
status 查看运行状态(含 --format json 结构化快照)
|
|
30
31
|
logs 持续查看 daemon 日志
|
|
31
32
|
watch 打开日志、AID、消息或 EC Web 监控
|
|
32
33
|
|
|
@@ -36,10 +37,11 @@ Agent 与会话:
|
|
|
36
37
|
queue 查询或操作 agent 消息队列
|
|
37
38
|
session 按 ec 会话 id 查询本地 session 存档(含 agentSessionId)
|
|
38
39
|
getmeta 按会话 id / threadId / agentSessionId 查询会话元数据
|
|
40
|
+
thread 话题链:对端话题的列表、历史、摘要与索引维护
|
|
41
|
+
memory 记忆:写 note、整理正式记忆、触发整理会话
|
|
39
42
|
task 恢复暂停或异常中断的会话任务
|
|
40
43
|
trigger 管理定时与事件触发器
|
|
41
44
|
proxy 查询和管理 daemon 服务代理
|
|
42
|
-
handoff 查询和完成跨会话回流
|
|
43
45
|
pa-workspace 绑定 PA 工作区并维护入口导航
|
|
44
46
|
model 查看或设置模型与推理强度
|
|
45
47
|
response 查看或设置响应模式
|
|
@@ -53,7 +55,9 @@ AUN:
|
|
|
53
55
|
rpc 调用底层 AUN RPC
|
|
54
56
|
menu-client 向远程 daemon 发送标准 Menu 请求
|
|
55
57
|
diag 邀请远程诊断 Agent,或 stop 撤销诊断授权
|
|
56
|
-
|
|
58
|
+
peer 联系人黑名单与已登记对端查询
|
|
59
|
+
directory 名录查询与发起加好友申请
|
|
60
|
+
role 关系角色提升申请与审批
|
|
57
61
|
net AUN 网络链路诊断
|
|
58
62
|
|
|
59
63
|
配置与诊断:
|
|
@@ -61,12 +65,14 @@ AUN:
|
|
|
61
65
|
provider 管理 daemon 级 Provider 注册表与 JSON 导入
|
|
62
66
|
ability 按 AID 管理能力插件、运行、发布和作业
|
|
63
67
|
stats Token 用量与费用统计
|
|
68
|
+
skill EC 技能管理:加载、安装、启停与索引刷新
|
|
64
69
|
diagnose 检查启动环境
|
|
65
70
|
version 显示组件版本
|
|
66
71
|
mv 迁移项目目录和会话路径
|
|
67
72
|
|
|
68
73
|
维护命令:
|
|
69
|
-
data migrate
|
|
74
|
+
data 数据迁移(data migrate,显式维护窗口)
|
|
75
|
+
integrity 文件完整性台账:check / seal / query / list
|
|
70
76
|
mode 切换开发源码与 npm 包运行模式
|
|
71
77
|
restart-monitor 运行 daemon 重启监控器
|
|
72
78
|
bench AUN 消息性能基准测试
|
|
@@ -94,20 +100,64 @@ function printLifecycleHelp(command) {
|
|
|
94
100
|
};
|
|
95
101
|
console.log(help[command]);
|
|
96
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* 拒绝命令不认识的参数。
|
|
105
|
+
*
|
|
106
|
+
* `ec stop --hel` 这类打错字的输入此前会被静默忽略并照常执行——对 stop/restart
|
|
107
|
+
* 这种破坏性命令意味着「以为在查帮助,实际把服务停了」。这里按白名单收口:
|
|
108
|
+
* boolean 选项只允许出现一次,取值选项必须紧跟一个值。
|
|
109
|
+
*/
|
|
110
|
+
function readFlagValue(args, flag) {
|
|
111
|
+
const eqPrefix = `${flag}=`;
|
|
112
|
+
const inline = args.find(token => token.startsWith(eqPrefix));
|
|
113
|
+
if (inline !== undefined)
|
|
114
|
+
return inline.slice(eqPrefix.length);
|
|
115
|
+
return getArgValue(args, flag);
|
|
116
|
+
}
|
|
117
|
+
function rejectUnknownFlags(cmd, args, booleanFlags, valueFlags = []) {
|
|
118
|
+
const booleans = new Set(booleanFlags);
|
|
119
|
+
const values = new Set(valueFlags);
|
|
120
|
+
for (let index = 0; index < args.length; index++) {
|
|
121
|
+
const token = args[index];
|
|
122
|
+
if (!token.startsWith('-')) {
|
|
123
|
+
console.error(`❌ ${cmd} 不接受位置参数: ${token}`);
|
|
124
|
+
console.error(`用法: ec ${cmd} [选项],运行 ec ${cmd} --help 查看完整参数`);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const eq = token.indexOf('=');
|
|
128
|
+
const name = eq >= 0 ? token.slice(0, eq) : token;
|
|
129
|
+
if (booleans.has(name)) {
|
|
130
|
+
if (eq >= 0) {
|
|
131
|
+
console.error(`❌ ${name} 不接受取值`);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (values.has(name)) {
|
|
137
|
+
if (eq >= 0)
|
|
138
|
+
continue;
|
|
139
|
+
const value = args[index + 1];
|
|
140
|
+
if (value === undefined || value.startsWith('-')) {
|
|
141
|
+
console.error(`❌ ${name} 需要一个值`);
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
index++;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
console.error(`❌ 未知参数: ${token}`);
|
|
148
|
+
console.error(`用法: ec ${cmd} [选项],运行 ec ${cmd} --help 查看完整参数`);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
97
153
|
// Suppress Node.js ExperimentalWarning (e.g. SQLite) from cluttering CLI output
|
|
98
154
|
process.removeAllListeners('warning');
|
|
99
155
|
process.on('warning', (w) => { if (w.name === 'ExperimentalWarning')
|
|
100
156
|
return; process.stderr.write((w.stack ?? String(w)) + '\n'); });
|
|
101
157
|
export async function main(args) {
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
if (args.length === 0 && process.env.EVOLCORE_SESSION_ID) {
|
|
106
|
-
console.log(MAIN_HELP);
|
|
107
|
-
process.exitCode = 1;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const cmd = args[0] || 'start';
|
|
158
|
+
// 裸跑 `ec` 一律等于 `ec --help` / `ec -h`:只打印帮助,不启动 daemon。
|
|
159
|
+
// 启动服务必须显式 `ec start`,托管与非托管环境行为一致。
|
|
160
|
+
const cmd = args[0] || 'help';
|
|
111
161
|
// 调试路径:--as-session <sessionId> 注入托管会话身份,必须在白名单检查之前
|
|
112
162
|
await resolveDebugContext(args);
|
|
113
163
|
// 注入完成后剥除 --as-session <sessionId> 两个参数,避免子命令把它们当作未知参数
|
|
@@ -255,7 +305,11 @@ export async function main(args) {
|
|
|
255
305
|
break;
|
|
256
306
|
}
|
|
257
307
|
{
|
|
258
|
-
|
|
308
|
+
if (!rejectUnknownFlags('start', strippedArgs.slice(1), ['--foreground', '--diagnose', '-d', '--debug'], ['--as-mode'])) {
|
|
309
|
+
process.exitCode = 1;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
const asModeRaw = readFlagValue(strippedArgs, '--as-mode');
|
|
259
313
|
if (asModeRaw !== undefined && asModeRaw !== 'dev' && asModeRaw !== 'install') {
|
|
260
314
|
console.error(`❌ --as-mode 只接受 dev 或 install,收到: ${asModeRaw}`);
|
|
261
315
|
process.exitCode = 1;
|
|
@@ -274,6 +328,10 @@ export async function main(args) {
|
|
|
274
328
|
printLifecycleHelp('stop');
|
|
275
329
|
break;
|
|
276
330
|
}
|
|
331
|
+
if (!rejectUnknownFlags('stop', strippedArgs.slice(1), [])) {
|
|
332
|
+
process.exitCode = 1;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
277
335
|
await cmdStop();
|
|
278
336
|
break;
|
|
279
337
|
case 'restart':
|
|
@@ -281,6 +339,10 @@ export async function main(args) {
|
|
|
281
339
|
printLifecycleHelp('restart');
|
|
282
340
|
break;
|
|
283
341
|
}
|
|
342
|
+
if (!rejectUnknownFlags('restart', strippedArgs.slice(1), ['--clear', '--diagnose', '-d'])) {
|
|
343
|
+
process.exitCode = 1;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
284
346
|
await cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
|
|
285
347
|
break;
|
|
286
348
|
case 'upgrade':
|
|
@@ -507,11 +569,6 @@ export async function main(args) {
|
|
|
507
569
|
await (await import('./aun-commands.js')).cmdMsg(strippedArgs.slice(1));
|
|
508
570
|
break;
|
|
509
571
|
}
|
|
510
|
-
case 'handoff': {
|
|
511
|
-
const { cmdHandoff } = await import('./handoff-command.js');
|
|
512
|
-
await cmdHandoff(strippedArgs.slice(1));
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
572
|
case 'thread': {
|
|
516
573
|
const { runThreadCommand } = await import('./thread-command.js');
|
|
517
574
|
await runThreadCommand(strippedArgs.slice(1));
|
package/dist/cli/init.js
CHANGED
|
@@ -5,7 +5,7 @@ import readline from 'readline';
|
|
|
5
5
|
import { resolvePaths, ensureDataDirs } from '../paths.js';
|
|
6
6
|
import { commandExists } from '../utils/cross-platform.js';
|
|
7
7
|
import { scanInstances } from '../utils/instance-registry.js';
|
|
8
|
-
import { saveDefaultsSafe,
|
|
8
|
+
import { saveDefaultsSafe, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
|
|
9
9
|
import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
|
|
10
10
|
import { ensureControlAgentMd, generateControlAid, resolveControlAidDomain, submitControlAidRegistration, } from '../aun/aid/control-aid.js';
|
|
11
11
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
@@ -500,12 +500,6 @@ export async function cmdInit(options) {
|
|
|
500
500
|
}
|
|
501
501
|
/** 补全控制 AID + owner(可单独调用,不走 baseagent 向导)。 */
|
|
502
502
|
export async function initTail(options = {}) {
|
|
503
|
-
// 提示创建 agent(两分支汇合后执行一次)
|
|
504
|
-
const { agents } = loadAllAgents();
|
|
505
|
-
if (agents.length === 0) {
|
|
506
|
-
console.log('\n提示:尚无 agent,运行以下命令创建:');
|
|
507
|
-
console.log(' ec agent new <aid>.example.com');
|
|
508
|
-
}
|
|
509
503
|
// 控制 AID:daemon 进程身份。缺失则生成并写回 daemon.json(幂等:已存在则跳过)。
|
|
510
504
|
const daemonConfig = loadDaemonConfig();
|
|
511
505
|
let controlAidReady = !!daemonConfig.aid;
|
|
@@ -619,10 +613,6 @@ export async function initTail(options = {}) {
|
|
|
619
613
|
}
|
|
620
614
|
console.log(`✓ 已配置进程级管理者: ${ownerAid}`);
|
|
621
615
|
}
|
|
622
|
-
if (daemonConfigForOwners.aid) {
|
|
623
|
-
console.log('\n协议 Owner 绑定:启动后运行 ec aid bind <ownerAid>。');
|
|
624
|
-
console.log('使用 ec aid bind status 查看绑定状态。');
|
|
625
|
-
}
|
|
626
616
|
return true;
|
|
627
617
|
}
|
|
628
618
|
async function handleEcwebPrompt() {
|
|
@@ -661,19 +651,7 @@ export async function initTail(options = {}) {
|
|
|
661
651
|
console.log('\n✓ EvolCore 初始化完成');
|
|
662
652
|
const finalCfg = loadDaemonConfig();
|
|
663
653
|
console.log(` 控制 AID: ${finalCfg.aid || '(未配置)'}`);
|
|
664
|
-
console.log(' 协议 Owner: 启动后使用 ec aid bind status 核验');
|
|
665
654
|
console.log(` ECWeb 自启动: ${ecwebService(finalCfg.services)?.enabled ? '已启用' : '已禁用'}`);
|
|
666
|
-
const { agents: finalAgents } = loadAllAgents();
|
|
667
|
-
if (finalAgents.length === 0) {
|
|
668
|
-
console.log('\n📌 下一步:创建 agent');
|
|
669
|
-
console.log(' ec agent new <your-aid>.example.com');
|
|
670
|
-
console.log(' ec init feishu # 绑定飞书');
|
|
671
|
-
console.log(' ec start # 启动服务');
|
|
672
|
-
}
|
|
673
|
-
else {
|
|
674
|
-
console.log(`\n✓ 已有 ${finalAgents.length} 个 agent,可直接运行:`);
|
|
675
|
-
console.log(' ec start');
|
|
676
|
-
}
|
|
677
655
|
return controlAidReady;
|
|
678
656
|
}
|
|
679
657
|
/**
|
package/dist/cli/link-rules.js
CHANGED
|
@@ -79,7 +79,7 @@ function cleanEmptyParents(dir) {
|
|
|
79
79
|
}
|
|
80
80
|
// ── 子命令 ──
|
|
81
81
|
function showHelp() {
|
|
82
|
-
console.log(
|
|
82
|
+
console.log(`用法: ec link-rules <subcommand> [baseagent] [--dir <path>]
|
|
83
83
|
|
|
84
84
|
Subcommands:
|
|
85
85
|
connect Connect ECK rules to a project directory (default: cwd)
|
|
@@ -15,7 +15,6 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
15
15
|
'group',
|
|
16
16
|
// Managed log reads are routed through a bounded, daemon-authorized IPC query.
|
|
17
17
|
'logs',
|
|
18
|
-
'handoff',
|
|
19
18
|
// `memory` only works inside a managed task: both subcommands require
|
|
20
19
|
// EVOLCORE_SESSION_ID and authorize through their daemon IPC entrypoints.
|
|
21
20
|
'memory',
|
|
@@ -9,6 +9,7 @@ const USAGE = `用法: ec pa-workspace init --workspace <绝对路径> [--force]
|
|
|
9
9
|
ec pa-workspace navigation show
|
|
10
10
|
ec pa-workspace navigation update --expected-revision <n> --entries-json <json>
|
|
11
11
|
|
|
12
|
+
所有子命令都只输出 JSON,--format json / --json 可省略。
|
|
12
13
|
仅限当前 Agent 的 AUN owner 私聊托管会话。`;
|
|
13
14
|
const MAX_SKILL_OUTPUT_CHARS = 2 * 1024 * 1024;
|
|
14
15
|
export class PaWorkspaceCommandError extends Error {
|
|
@@ -101,6 +102,38 @@ function value(args, flag) {
|
|
|
101
102
|
const index = args.indexOf(flag);
|
|
102
103
|
return index >= 0 ? args[index + 1] : undefined;
|
|
103
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* 摘掉输出格式参数。
|
|
107
|
+
*
|
|
108
|
+
* 本命令**只输出 JSON**,所以 `--format json` 和 `--json` 都不改变行为。
|
|
109
|
+
* 但别的命令(`ec thread`、`ec agent welcome show` …)都接受这两个参数,
|
|
110
|
+
* 调用方很容易顺手写上;直接报 INVALID_ARGUMENT 只会让人以为是用法错误。
|
|
111
|
+
* 这里统一接受,真正的非法值(如 `--format text`)才报错并说清原因。
|
|
112
|
+
*/
|
|
113
|
+
function normalizeFormatArgs(args) {
|
|
114
|
+
const out = [];
|
|
115
|
+
for (let index = 0; index < args.length; index++) {
|
|
116
|
+
const argument = args[index];
|
|
117
|
+
if (argument === '--json')
|
|
118
|
+
continue;
|
|
119
|
+
if (argument === '--format') {
|
|
120
|
+
const format = args[++index];
|
|
121
|
+
if (format !== 'json') {
|
|
122
|
+
throw new PaWorkspaceCommandError('INVALID_ARGUMENT', `ec pa-workspace 只输出 JSON,--format 只能取 json(收到 ${format ?? '空'})`);
|
|
123
|
+
}
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (argument.startsWith('--format=')) {
|
|
127
|
+
const format = argument.slice('--format='.length);
|
|
128
|
+
if (format !== 'json') {
|
|
129
|
+
throw new PaWorkspaceCommandError('INVALID_ARGUMENT', `ec pa-workspace 只输出 JSON,--format 只能取 json(收到 ${format || '空'})`);
|
|
130
|
+
}
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
out.push(argument);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
104
137
|
function assertOwnerPrivateRuntime(context) {
|
|
105
138
|
if (context.channel !== 'aun' || context.chatType !== 'private' || context.peerRole !== 'owner'
|
|
106
139
|
|| !context.selfAid || !context.peerId) {
|
|
@@ -110,12 +143,13 @@ function assertOwnerPrivateRuntime(context) {
|
|
|
110
143
|
function output(value) {
|
|
111
144
|
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
112
145
|
}
|
|
113
|
-
export async function cmdPaWorkspace(
|
|
114
|
-
if (
|
|
146
|
+
export async function cmdPaWorkspace(rawArgs) {
|
|
147
|
+
if (rawArgs.length === 0 || rawArgs.includes('--help') || rawArgs.includes('-h')) {
|
|
115
148
|
console.log(USAGE);
|
|
116
149
|
return;
|
|
117
150
|
}
|
|
118
151
|
try {
|
|
152
|
+
const args = normalizeFormatArgs(rawArgs);
|
|
119
153
|
const context = await authorizeLocalCommand(['pa-workspace', ...args]);
|
|
120
154
|
assertOwnerPrivateRuntime(context);
|
|
121
155
|
if (args[0] === 'init') {
|
package/dist/cli/peer.js
CHANGED
|
@@ -70,7 +70,7 @@ function fail(message, code = 'INVALID_ARGUMENT', data) {
|
|
|
70
70
|
throw error;
|
|
71
71
|
}
|
|
72
72
|
function printHelp() {
|
|
73
|
-
console.log(
|
|
73
|
+
console.log(`用法:
|
|
74
74
|
ec peer block <primaryId> --self <agent-aid>
|
|
75
75
|
ec peer unblock <primaryId> --self <agent-aid>
|
|
76
76
|
ec peer list --blocked [--self <agent-aid>]
|
|
@@ -83,7 +83,8 @@ Options:
|
|
|
83
83
|
--format json 输出 JSON
|
|
84
84
|
--help, -h 显示帮助
|
|
85
85
|
|
|
86
|
-
添加联系人、审批联系人申请由
|
|
86
|
+
添加联系人、审批联系人申请由 Evol App 名录流程处理。
|
|
87
|
+
发起 app-v1 加好友申请:ec directory request <target-aid> --self <agent-aid> [--note <申请介绍>]。`);
|
|
87
88
|
}
|
|
88
89
|
function withDefaultSelf(args) {
|
|
89
90
|
if (args.includes('--self'))
|
|
@@ -17,7 +17,7 @@ import { readRestartRequest, updateRestartRequest, removeRestartRequest, shouldS
|
|
|
17
17
|
import { rotateStdoutLog } from '../utils/log-writer.js';
|
|
18
18
|
import { applyDataMigration, finalizeDataMigration, planDataMigration, verifyDataMigration, } from '../core/data-migration.js';
|
|
19
19
|
import { DAEMON_SHUTDOWN_TIMEOUT_MS, requestDaemonShutdown, stopCodexAppServerOrphans } from './daemon-commands.js';
|
|
20
|
-
import { getProcessStartTime, startTimeMatches } from '../utils/process-introspect.js';
|
|
20
|
+
import { getProcessStartTime, invalidateProcessSnapshot, startTimeMatches } from '../utils/process-introspect.js';
|
|
21
21
|
import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode } from '../config/daemon-services.js';
|
|
22
22
|
import { probeEcwebRestartReadiness, stopEcwebForRestart } from '../ecweb/runtime/lifecycle.js';
|
|
23
23
|
import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
@@ -398,9 +398,23 @@ export async function cmdRestartMonitor() {
|
|
|
398
398
|
// Preserve CLI restart's final ownership guards and optional orphan cleanup
|
|
399
399
|
// here, after election/shutdown, so no launcher stops a daemon before a
|
|
400
400
|
// watchdog has successfully loaded.
|
|
401
|
+
// Shutdown changed the process table. A cached pre-shutdown snapshot can
|
|
402
|
+
// otherwise classify the exited daemon as an unregistered runtime process.
|
|
403
|
+
invalidateProcessSnapshot();
|
|
401
404
|
const remaining = findOrphanProcesses();
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
const remainingMains = scanInstances().mains.filter(item => item.alive);
|
|
406
|
+
const remainingRuntime = remaining.filter(belongsToRuntime);
|
|
407
|
+
if (remainingMains.length || remainingRuntime.length) {
|
|
408
|
+
const pids = [...new Set([
|
|
409
|
+
...remainingMains.map(item => item.record.pid),
|
|
410
|
+
...remainingRuntime.map(item => item.pid),
|
|
411
|
+
])].join(', ');
|
|
412
|
+
const reason = `Restart aborted: a runtime process appeared or survived shutdown (PID: ${pids})`;
|
|
413
|
+
log(reason);
|
|
414
|
+
if (upgradeJob)
|
|
415
|
+
updateUpgradeJob(upgradeJob.jobId, {
|
|
416
|
+
lifecycle: { status: 'failed', reason, at: new Date().toISOString() },
|
|
417
|
+
});
|
|
404
418
|
cleanupPendingFile(pendingFile, log, hasCorrelatedRequest ? requestId : undefined);
|
|
405
419
|
process.exit(1);
|
|
406
420
|
}
|
package/dist/cli/role.js
CHANGED
|
@@ -65,7 +65,7 @@ function fail(message, code = 'INVALID_ARGUMENT', data) {
|
|
|
65
65
|
throw error;
|
|
66
66
|
}
|
|
67
67
|
function printHelp() {
|
|
68
|
-
console.log(
|
|
68
|
+
console.log(`用法:
|
|
69
69
|
ec role request <peer-aid> --role <role-id> [--reason '<text>'] [--self <agent-aid>]
|
|
70
70
|
ec role list [--status pending|approved|rejected|expired] [--self <agent-aid>]
|
|
71
71
|
ec role approve <request-id> [--reason '<text>'] [--self <agent-aid>]
|
|
@@ -5,7 +5,7 @@ import { authorizeLocalCommand } from './task-context.js';
|
|
|
5
5
|
import { findSessionCapsule, materializeSessionCapsules } from '../core/session/session-capsule.js';
|
|
6
6
|
import { scanChatDirs, readLastJsonlLine, } from '../core/session/session-fs-store.js';
|
|
7
7
|
const HELP_TEXT = `
|
|
8
|
-
ec session <command> [options]
|
|
8
|
+
用法: ec session <command> [options]
|
|
9
9
|
|
|
10
10
|
本地会话文件查询(读取 $EVOLCORE_HOME/agents/ 下的存档;托管任务先经 daemon 鉴权)。
|
|
11
11
|
|
package/dist/cli/stats.js
CHANGED
|
@@ -7,9 +7,9 @@ import { authorizeLocalCommand } from './task-context.js';
|
|
|
7
7
|
import { queryAggregated, querySessionTurns, queryContextBreakdown, queryTopPeers, queryTopModels, queryMessageAggregated, queryPeerList, querySummary, queryPeerDaily, queryTaskModelCalls, querySessionModelCalls, queryTaskSummary } from '../stats/query.js';
|
|
8
8
|
import { getBudgetStatus } from '../stats/budget.js';
|
|
9
9
|
import { normalizeUsage } from '../stats/normalizer.js';
|
|
10
|
-
const HELP =
|
|
10
|
+
const HELP = `用法: ec stats [options]
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
ec stats — Token 用量与费用统计
|
|
13
13
|
|
|
14
14
|
时间范围:
|
|
15
15
|
(无参数) 今日概览
|
package/dist/cli/task-context.js
CHANGED
|
@@ -7,6 +7,7 @@ import os from 'node:os';
|
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { readDelegationCredential } from '../core/auth/agent-delegation.js';
|
|
9
9
|
import { resolveRoot } from '../paths.js';
|
|
10
|
+
import { TEST_TMPDIR_ENV } from '../product.js';
|
|
10
11
|
export const TASK_RUNTIME_CONTEXT_ENV = 'EVOLCORE_TASK_RUNTIME_CONTEXT';
|
|
11
12
|
export const SESSION_RUNTIME_DIR_ENV = 'EVOLCORE_SESSION_RUNTIME_DIR';
|
|
12
13
|
export const DAEMON_RUNTIME_EPOCH_ENV = 'EVOLCORE_DAEMON_RUNTIME_EPOCH';
|
|
@@ -189,7 +190,8 @@ function canonicalHome() {
|
|
|
189
190
|
return process.platform === 'win32' ? canonical.toLowerCase() : canonical;
|
|
190
191
|
}
|
|
191
192
|
function systemTempRoot() {
|
|
192
|
-
const testRoot = process.env.EVOLCORE_TEST === '1'
|
|
193
|
+
const testRoot = process.env.EVOLCORE_TEST === '1'
|
|
194
|
+
&& (process.env.TMPDIR || process.env[TEST_TMPDIR_ENV])?.trim();
|
|
193
195
|
const candidate = testRoot && path.isAbsolute(testRoot)
|
|
194
196
|
? testRoot
|
|
195
197
|
: process.platform === 'win32'
|
|
@@ -8,7 +8,7 @@ import { readTaskRuntimeContextFromEnv } from './task-context.js';
|
|
|
8
8
|
const TOPIC_STATUSES = ['pending', 'in_progress', 'completed', 'archived'];
|
|
9
9
|
const SORT_ORDERS = ['recent', 'created'];
|
|
10
10
|
const HELP_TEXT = `
|
|
11
|
-
ec thread <command> [options]
|
|
11
|
+
用法: ec thread <command> [options]
|
|
12
12
|
|
|
13
13
|
命令:
|
|
14
14
|
peers 列出有话题记录的所有对端(先用这个选对端)
|
package/dist/cli/watch-msg.js
CHANGED
|
@@ -302,7 +302,7 @@ function renderMessagesPanel(state, width, height) {
|
|
|
302
302
|
const isGroup = m.chatType === 'group';
|
|
303
303
|
const chatTag = isGroup ? `${MAGENTA}[群聊]${RST}` : '';
|
|
304
304
|
const encLabel = m.encrypt ? '密文' : '明文';
|
|
305
|
-
const modeLabel = m.chatmode === 'proactive' ? '自主' : '响应';
|
|
305
|
+
const modeLabel = m.chatmode === 'paactive' ? 'PA' : m.chatmode === 'proactive' ? '自主' : '响应';
|
|
306
306
|
const metaTags = (m.encrypt != null || m.chatmode) ? `${MAGENTA}[${encLabel}|${modeLabel}]${RST}` : '';
|
|
307
307
|
// observer 插话:醒目标记,与对端真实消息区分
|
|
308
308
|
const injectTag = m.source === 'owner-inject' ? `${YELLOW}[插话]${RST}` : '';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { kitsRoleTemplatesDir } from '../paths.js';
|
|
3
3
|
import { createErrorCapturingReader, fileCache } from '../core/daemon-file-cache.js';
|
|
4
|
-
import { normalizeRoleEffortCompat, validateRoleConfig } from './role-schema.js';
|
|
4
|
+
import { normalizeRoleEffortCompat, normalizeRoleGroupChatmodeCompat, validateRoleConfig } from './role-schema.js';
|
|
5
5
|
import { expectedRoleRank } from './role-ranks.js';
|
|
6
6
|
export const BUILTIN_ROLE_IDS = ['owner', 'admin', 'member', 'visitor'];
|
|
7
7
|
export function validateBuiltinRoleTemplateDefinition(roleId, raw) {
|
|
8
|
-
const normalizedRaw = normalizeRoleEffortCompat(raw);
|
|
8
|
+
const normalizedRaw = normalizeRoleGroupChatmodeCompat(normalizeRoleEffortCompat(raw));
|
|
9
9
|
const issues = validateRoleConfig(normalizedRaw);
|
|
10
10
|
if (issues.length) {
|
|
11
11
|
return {
|
|
@@ -4,6 +4,7 @@ export { expectedRoleRank, ROLE_RANKS } from './role-ranks.js';
|
|
|
4
4
|
export const BUILTIN_USER_ROLES = ['member', 'visitor'];
|
|
5
5
|
export const MANAGEMENT_ROLES = ['owner', 'admin'];
|
|
6
6
|
export const DAEMON_OWNER_ROLE = 'daemon-owner';
|
|
7
|
+
export const DEFAULT_PA_TEAM_ROLE = 'member';
|
|
7
8
|
export function isManagementRole(role) {
|
|
8
9
|
return role === 'owner' || role === 'admin';
|
|
9
10
|
}
|
|
@@ -17,7 +18,7 @@ export function isReservedRoleName(role) {
|
|
|
17
18
|
export function getBuiltinRolesConfig() {
|
|
18
19
|
return {
|
|
19
20
|
$schema_version: 1,
|
|
20
|
-
defaultRoles: { private: null, group: null },
|
|
21
|
+
defaultRoles: { private: null, group: null, paTeam: DEFAULT_PA_TEAM_ROLE },
|
|
21
22
|
roles: Object.fromEntries(BUILTIN_USER_ROLES.flatMap(roleId => {
|
|
22
23
|
const definition = readBuiltinRoleTemplate(roleId).definition;
|
|
23
24
|
return definition ? [[roleId, definition]] : [];
|
|
@@ -321,9 +321,14 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
321
321
|
? { ok: true, value: raw }
|
|
322
322
|
: { ok: false, reason: `Config field ${fieldPath} must be one of ${[...EFFORTS].join(', ')}; use unset for auto` };
|
|
323
323
|
case 'chatmode':
|
|
324
|
-
|
|
324
|
+
if (fieldPath.trim() === 'chatmode.group') {
|
|
325
|
+
return raw === 'proactive'
|
|
326
|
+
? { ok: true, value: raw }
|
|
327
|
+
: { ok: false, reason: 'Config field chatmode.group is fixed to proactive' };
|
|
328
|
+
}
|
|
329
|
+
return raw === 'interactive' || raw === 'proactive' || raw === 'paactive'
|
|
325
330
|
? { ok: true, value: raw }
|
|
326
|
-
: { ok: false, reason: `Config field ${fieldPath} must be interactive or
|
|
331
|
+
: { ok: false, reason: `Config field ${fieldPath} must be interactive, proactive, or paactive` };
|
|
327
332
|
case 'mention-mode':
|
|
328
333
|
return raw === 'disabled' || raw === 'mention-only' || raw === 'auto'
|
|
329
334
|
? { ok: true, value: raw }
|
|
@@ -28,6 +28,7 @@ import { normalizeAgentLifecycle } from './lifecycle.js';
|
|
|
28
28
|
import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-field-policy.js';
|
|
29
29
|
import { clearRoleStoreCache, isRoleName } from './role-store.js';
|
|
30
30
|
import { writeRoleDefinition, writeRoleRegistry } from './role-service.js';
|
|
31
|
+
import { normalizeRoleEffortCompat, normalizeRoleGroupChatmodeCompat } from './role-schema.js';
|
|
31
32
|
import { mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
32
33
|
import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
33
34
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
@@ -661,10 +662,12 @@ export function read(target, sel, opts = {}) {
|
|
|
661
662
|
const normalized = target === ConfigTarget.Process
|
|
662
663
|
? normalizeProcessConfigCompat(normalizeDaemonServices(migrated))
|
|
663
664
|
: target === ConfigTarget.Agent
|
|
664
|
-
? normalizeAgentConfigForRead(migrated, sel?.self)
|
|
665
|
+
? normalizeGroupChatmodeCompat(normalizeAgentConfigForRead(migrated, sel?.self))
|
|
665
666
|
: target === ConfigTarget.Relation
|
|
666
|
-
? foldLegacyProactiveBlock(migrated)
|
|
667
|
-
:
|
|
667
|
+
? normalizeGroupChatmodeCompat(foldLegacyProactiveBlock(migrated))
|
|
668
|
+
: target === ConfigTarget.Role
|
|
669
|
+
? normalizeRoleGroupChatmodeCompat(normalizeRoleEffortCompat(migrated))
|
|
670
|
+
: migrated;
|
|
668
671
|
// Agent read compatibility may move the legacy top-level `agents` block to
|
|
669
672
|
// `baseagents`, so canonicalize effort after that structural migration.
|
|
670
673
|
// config.json 不做 ${VAR} 展开:网关凭证与端点只在 providers.json,那里有独立展开实现。
|
|
@@ -879,6 +882,11 @@ function normalizeRelationConfigForWrite(value) {
|
|
|
879
882
|
normalizeShowActivitiesCompat(mutable);
|
|
880
883
|
return mutable;
|
|
881
884
|
}
|
|
885
|
+
function normalizeGroupChatmodeCompat(value) {
|
|
886
|
+
if (value?.chatmode?.group !== 'interactive')
|
|
887
|
+
return value;
|
|
888
|
+
return { ...value, chatmode: { ...value.chatmode, group: 'proactive' } };
|
|
889
|
+
}
|
|
882
890
|
function normalizeShowActivitiesCompat(value) {
|
|
883
891
|
if (value.show_activities === true)
|
|
884
892
|
value.show_activities = 'all';
|
|
@@ -965,6 +973,10 @@ export function write(target, value, sel, opts = {}) {
|
|
|
965
973
|
// 1. Schema 校验
|
|
966
974
|
if (!opts.skipValidate) {
|
|
967
975
|
validateOrThrow(schema, normalized, target);
|
|
976
|
+
if (target === ConfigTarget.Relation && normalized.chatmode?.private === 'paactive'
|
|
977
|
+
&& (!sel?.peerKey?.startsWith('aun#') || normalized.targetKind !== 'private')) {
|
|
978
|
+
throw new ConfigError('SCHEMA_INVALID', 'paactive only supports AUN private relations');
|
|
979
|
+
}
|
|
968
980
|
if (target === ConfigTarget.Defaults || target === ConfigTarget.Agent || target === ConfigTarget.Relation) {
|
|
969
981
|
const previous = atomicReadJson(file) ?? {};
|
|
970
982
|
const inherited = target === ConfigTarget.Defaults ? {}
|
|
@@ -1425,6 +1437,13 @@ export function validateConfigFile(target, sel) {
|
|
|
1425
1437
|
catch (error) {
|
|
1426
1438
|
return { exists: true, errors: [error instanceof Error ? error.message : String(error)] };
|
|
1427
1439
|
}
|
|
1440
|
+
if ((target === ConfigTarget.Agent || target === ConfigTarget.Relation)
|
|
1441
|
+
&& sanitized && typeof sanitized === 'object') {
|
|
1442
|
+
sanitized = normalizeGroupChatmodeCompat(sanitized);
|
|
1443
|
+
}
|
|
1444
|
+
if (target === ConfigTarget.Role) {
|
|
1445
|
+
sanitized = normalizeRoleGroupChatmodeCompat(normalizeRoleEffortCompat(sanitized));
|
|
1446
|
+
}
|
|
1428
1447
|
return { exists: true, errors: validateConfig(target, sanitized) };
|
|
1429
1448
|
}
|
|
1430
1449
|
function fileCacheAvailable() {
|
|
@@ -1530,18 +1549,21 @@ function mergeBaseagentBlocks(layers) {
|
|
|
1530
1549
|
* the normal agent/relation merge chain without leaking the compatibility
|
|
1531
1550
|
* container itself into EffectiveAgentConfig.
|
|
1532
1551
|
*
|
|
1533
|
-
* Explicit canonical fields (if a future schema adds them) always win.
|
|
1534
|
-
*
|
|
1535
|
-
* compatibility field predates the per-category `chatmode` dictionary.
|
|
1552
|
+
* Explicit canonical fields (if a future schema adds them) always win.
|
|
1553
|
+
* Legacy default modes apply to private chats; group delivery is always proactive.
|
|
1536
1554
|
*/
|
|
1537
1555
|
export function normalizeDefaultsBehaviorCompat(defaults) {
|
|
1538
|
-
if (!defaults || !defaults.config || typeof defaults.config !== 'object' || Array.isArray(defaults.config))
|
|
1539
|
-
return defaults;
|
|
1556
|
+
if (!defaults || !defaults.config || typeof defaults.config !== 'object' || Array.isArray(defaults.config)) {
|
|
1557
|
+
return defaults ? normalizeGroupChatmodeCompat(defaults) : defaults;
|
|
1558
|
+
}
|
|
1540
1559
|
const { config, ...rest } = defaults;
|
|
1541
1560
|
const normalized = { ...rest };
|
|
1542
1561
|
const chatMode = config.chatMode;
|
|
1543
1562
|
if (!normalized.chatmode && (chatMode === 'interactive' || chatMode === 'proactive')) {
|
|
1544
|
-
normalized.chatmode = { private: chatMode, group:
|
|
1563
|
+
normalized.chatmode = { private: chatMode, group: 'proactive', nothuman: chatMode };
|
|
1564
|
+
}
|
|
1565
|
+
else if (!normalized.chatmode && chatMode === 'paactive') {
|
|
1566
|
+
normalized.chatmode = { private: 'paactive', group: 'proactive', nothuman: 'proactive' };
|
|
1545
1567
|
}
|
|
1546
1568
|
if (normalized.mentionMode === undefined && (config.mentionMode === 'disabled' || config.mentionMode === 'mention-only' || config.mentionMode === 'auto')) {
|
|
1547
1569
|
normalized.mentionMode = config.mentionMode;
|
|
@@ -1549,7 +1571,7 @@ export function normalizeDefaultsBehaviorCompat(defaults) {
|
|
|
1549
1571
|
if (normalized.show_activities === undefined && ['all', 'text', 'none'].includes(config.show_activities)) {
|
|
1550
1572
|
normalized.show_activities = config.show_activities;
|
|
1551
1573
|
}
|
|
1552
|
-
return normalized;
|
|
1574
|
+
return normalizeGroupChatmodeCompat(normalized);
|
|
1553
1575
|
}
|
|
1554
1576
|
function stripStaticOwnerField(config) {
|
|
1555
1577
|
if (!config)
|
|
@@ -13,6 +13,8 @@ import { configuredOwnerList } from './owner-config.js';
|
|
|
13
13
|
import { tryParseChannelKey } from '../core/channel-loader.js';
|
|
14
14
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
15
15
|
import { getOwners, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
16
|
+
import { paTeamQualification, paTeamRevision, requiresPaTeamVerification } from '../core/relation/pa-team.js';
|
|
17
|
+
import { readRoleStore } from './role-store.js';
|
|
16
18
|
export function isAuthenticated(userId) {
|
|
17
19
|
return isValidAid(String(userId || '').trim());
|
|
18
20
|
}
|
|
@@ -58,7 +60,8 @@ export function getFirstStaticAgentOwner(aid) {
|
|
|
58
60
|
}
|
|
59
61
|
/** Revision for security-sensitive owner/contact/relation authorization inputs. */
|
|
60
62
|
export function authorizationConfigRevision(aid) {
|
|
61
|
-
const fingerprints = [ownerResolver.revision(aid),
|
|
63
|
+
const fingerprints = [ownerResolver.revision(aid), paTeamRevision(aid),
|
|
64
|
+
JSON.stringify(readRoleStore(aid)), fileRevision(agentConfig(aid)), fileRevision(agentPeerConfig(aid))];
|
|
62
65
|
const relations = agentRelationsDir(aid);
|
|
63
66
|
try {
|
|
64
67
|
for (const entry of fs.readdirSync(relations, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
@@ -101,6 +104,25 @@ export function resolvePeerRoleDetail(ctx) {
|
|
|
101
104
|
candidates.push({ role: 'owner', source: 'agent-owner', sourcePriority: 100 });
|
|
102
105
|
}
|
|
103
106
|
const actorRole = resolveActorDirectRole(ctx.selfAid, actor, channelType, operatorId);
|
|
107
|
+
if (channelType === 'aun' && ctx.chatType === 'private' && hasTrustedPrincipal(actor)
|
|
108
|
+
&& (paTeamQualification(ctx.selfAid, actor.principalId) === 'matched'
|
|
109
|
+
|| requiresPaTeamVerification(ctx.selfAid, actor.principalId))) {
|
|
110
|
+
const ownerCandidate = candidates.find(candidate => candidate.role === 'owner');
|
|
111
|
+
if (ownerCandidate)
|
|
112
|
+
return resultFor('owner', 'agent-owner', actor, ctx.selfAid);
|
|
113
|
+
const relation = read(ConfigTarget.Relation, { self: ctx.selfAid, peerKey: formatPeerKey('aun', actor.principalId) }, { cache: true });
|
|
114
|
+
if (relation?.role !== undefined && relation.role !== null) {
|
|
115
|
+
return resultFor(actorRole, 'relation-actor', actor, ctx.selfAid);
|
|
116
|
+
}
|
|
117
|
+
if (paTeamQualification(ctx.selfAid, actor.principalId) !== 'matched') {
|
|
118
|
+
return resultFor(null, 'none', actor, ctx.selfAid);
|
|
119
|
+
}
|
|
120
|
+
const store = readRoleStore(ctx.selfAid);
|
|
121
|
+
const valid = !store.diagnostics.some(diagnostic => diagnostic.code === 'INVALID_ROLE_REGISTRY'
|
|
122
|
+
|| diagnostic.code === 'MISSING_ROLE_REGISTRY');
|
|
123
|
+
const role = valid ? normalizeDefaultRole(store.registry.defaultRoles.paTeam ?? 'member', ctx.selfAid) : null;
|
|
124
|
+
return resultFor(role, 'pa-team-default', actor, ctx.selfAid);
|
|
125
|
+
}
|
|
104
126
|
if (ctx.chatType === 'private') {
|
|
105
127
|
if (actorRole)
|
|
106
128
|
candidates.push({ role: actorRole, source: 'relation-actor', sourcePriority: 80 });
|