evolcore 0.0.49 → 0.0.50
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 +64 -1
- package/bin/ecmsg.js +9 -4
- package/dist/ability/caller/authorization.js +21 -0
- package/dist/ability/caller/command.js +164 -0
- package/dist/ability/caller/contract.js +102 -0
- package/dist/ability/caller/daemon.js +158 -0
- package/dist/ability/caller/service.js +380 -0
- package/dist/ability/command-contract.js +5 -0
- package/dist/ability/daemon.js +5 -1
- package/dist/ability/interop-v1.js +10 -3
- package/dist/ability/management.js +1 -0
- package/dist/agent-template/jobs.js +173 -1
- package/dist/agent-template/runtime.js +280 -6
- package/dist/agent-template/service.js +1159 -40
- package/dist/agent-template/types.js +2 -1
- package/dist/agents/baseagent-availability.js +27 -3
- package/dist/agents/baseagent-capability-adapter.js +102 -0
- package/dist/agents/baseagent-plugin-descriptor.js +274 -0
- package/dist/agents/baseagent-plugin-loader.js +145 -0
- package/dist/agents/baseagent.js +68 -2
- package/dist/agents/claude-gateway/agent-registration.js +389 -0
- package/dist/agents/claude-gateway/binding.js +96 -0
- package/dist/agents/claude-gateway/inbox.js +138 -0
- package/dist/agents/claude-gateway/index.js +125 -0
- package/dist/agents/claude-gateway/listing.js +330 -0
- package/dist/agents/claude-gateway/router.js +328 -0
- package/dist/agents/claude-gateway/sessions.js +128 -0
- package/dist/agents/claude-gateway/terminal.js +250 -0
- package/dist/agents/claude-gateway/transcript.js +272 -0
- package/dist/agents/claude-gateway/types.js +14 -0
- package/dist/agents/claude-runner.js +6 -10
- package/dist/agents/codex-runner.js +4 -1
- package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
- package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
- package/dist/agents/gemini/index.js +51 -0
- package/dist/aun/aid/control-aid.js +52 -32
- package/dist/aun/group/invite-service.js +6 -36
- package/dist/aun/group/operations.js +6 -0
- package/dist/aun/msg/mention-schema.js +1 -1
- package/dist/aun/msg/p2p.js +29 -1
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +537 -189
- package/dist/cli/ability-command.js +42 -0
- package/dist/cli/agent-command.js +20 -1
- package/dist/cli/agent-create.js +78 -18
- package/dist/cli/agent-template.js +5 -3
- package/dist/cli/agent.js +91 -0
- package/dist/cli/aun-commands.js +92 -34
- package/dist/cli/bench.js +5 -2
- package/dist/cli/config.js +22 -6
- package/dist/cli/daemon-commands.js +245 -101
- package/dist/cli/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +23 -4
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +1 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/services-command.js +11 -9
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +17 -8
- package/dist/config/config-manager.js +86 -46
- package/dist/config/config-operation-service.js +22 -1
- package/dist/config/gateway-config.js +9 -8
- package/dist/config/owner-config.js +0 -16
- package/dist/config/peer-role-resolver.js +1 -7
- package/dist/config/providers-config.js +99 -16
- package/dist/config/providers-management.js +35 -19
- package/dist/config/resolved-config-op.js +1 -42
- package/dist/config/schema-migration.js +78 -5
- package/dist/config/schema-registry.js +52 -7
- package/dist/config-store.js +1309 -17
- package/dist/core/agent-application-service.js +220 -1
- package/dist/core/agent-ipc-registration.js +19 -2
- package/dist/core/agent-reload-coordinator.js +5 -0
- package/dist/core/agent-runtime.js +198 -54
- package/dist/core/auth/agent-delegation.js +14 -0
- package/dist/core/auth/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +50 -7
- package/dist/core/baseagent-loader.js +30 -3
- package/dist/core/capability/capability-manager.js +16 -7
- package/dist/core/channel-runtime.js +4 -2
- package/dist/core/command/agent-control.js +20 -2
- package/dist/core/command/agent-template-menu.js +4 -3
- package/dist/core/command/cli-intent-parser.js +15 -0
- package/dist/core/command/menu-catalog.js +20 -4
- package/dist/core/command/menu-file-path.js +70 -0
- package/dist/core/command/menu-handler.js +91 -72
- package/dist/core/command/menu-protocol.js +5 -0
- package/dist/core/command/menu-query-batch.js +2 -2
- package/dist/core/command/private-mention-menu.js +71 -0
- package/dist/core/command/slash-handler.js +17 -26
- package/dist/core/command/team-workspace-bootstrap.js +2 -1
- package/dist/core/command/topic-slash.js +7 -1
- package/dist/core/daemon-bootstrap.js +0 -4
- package/dist/core/daemon-control.js +2 -1
- package/dist/core/daemon-lifecycle.js +13 -5
- package/dist/core/evolagent-registry.js +12 -7
- package/dist/core/handoff/runtime.js +1 -1
- package/dist/core/host-snapshot.js +8 -3
- package/dist/core/initialization/service.js +3 -0
- package/dist/core/interaction-router.js +130 -0
- package/dist/core/ipc-registration.js +4 -0
- package/dist/core/memory/consolidation-context.js +2 -1
- package/dist/core/memory/consolidation.js +35 -64
- package/dist/core/message/aun-ipc-sender.js +98 -21
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/message-bridge.js +105 -6
- package/dist/core/message/message-log.js +8 -0
- package/dist/core/message/message-queue.js +5 -3
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +23 -8
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +4 -0
- package/dist/core/permission/ec-command-parser.js +182 -58
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +9 -2
- package/dist/core/permission/tool-policy.js +21 -9
- package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
- package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
- package/dist/core/session/session-manager.js +47 -10
- package/dist/core/session/session-mapper.js +16 -0
- package/dist/core/skill/index-generator.js +2 -3
- package/dist/core/skill/switch-resolver.js +3 -0
- package/dist/core/thread/command-parser.js +4 -1
- package/dist/core/thread/ipc-operation.js +4 -2
- package/dist/core/thread/thread-operation.js +25 -10
- package/dist/core/thread/thread-service.js +294 -55
- package/dist/core/thread/topic-id.js +52 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/eck/kit-renderer.js +2 -1
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/index.js +116 -41
- package/dist/ipc.js +58 -2
- package/dist/paths.js +48 -1
- package/dist/pay/command.js +38 -0
- package/dist/pay/protocol.js +136 -0
- package/dist/pay/runtime.js +188 -0
- package/dist/pay/service.js +384 -0
- package/dist/pay/store.js +81 -0
- package/dist/response-system/engines/v1/proactive-flow.js +29 -2
- package/dist/services/dispatcher.js +23 -5
- package/dist/services/host/main.js +388 -0
- package/dist/services/host/protocol.js +118 -0
- package/dist/services/host/resident.js +310 -0
- package/dist/services/host-client.js +386 -0
- package/dist/services/host-deploy.js +180 -0
- package/dist/services/host-launch.js +117 -0
- package/dist/services/host-recycle.js +203 -0
- package/dist/services/host-runtime.js +802 -0
- package/dist/services/idempotency.js +44 -86
- package/dist/services/index-generator.js +4 -3
- package/dist/services/index.js +176 -18
- package/dist/services/ipc-operation.js +204 -44
- package/dist/services/script-runner.js +515 -83
- package/dist/services/validation.js +109 -4
- package/dist/trigger/application-service.js +6 -4
- package/dist/trigger/local-files.js +19 -9
- package/dist/trigger/scheduler.js +22 -12
- package/dist/trigger/script-sandbox.js +51 -20
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +73 -0
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- package/dist/utils/restart-safety.js +14 -1
- package/dist/utils/system-memory.js +113 -25
- package/dist/utils/systemd-lifecycle.js +154 -0
- package/dist/utils/windows-shell-trust.js +7 -3
- package/kits/docs/INDEX.md +3 -2
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/evolcore/INDEX.md +7 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +20 -3
- package/kits/docs/evolcore/config.md +1 -1
- package/kits/docs/evolcore/group.md +2 -1
- package/kits/docs/evolcore/memory-tags.md +2 -0
- package/kits/docs/evolcore/menu-client.md +3 -3
- package/kits/docs/evolcore/menu-protocol.md +7 -0
- package/kits/docs/evolcore/model.md +3 -0
- package/kits/docs/evolcore/msg.md +68 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +21 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -0
- package/kits/rules/01-overview.md +11 -32
- package/kits/rules/02-navigation.md +7 -0
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +38 -5
- package/kits/schemas/agent-config.schema.21.json +974 -0
- package/kits/schemas/agent-config.schema.22.json +977 -0
- package/kits/schemas/agent-config.schema.23.json +958 -0
- package/kits/schemas/daemon.schema.10.json +373 -0
- package/kits/schemas/daemon.schema.9.json +12 -0
- package/kits/schemas/defaults.schema.7.json +472 -0
- package/kits/schemas/providers.schema.3.json +18 -2
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/skills/.switches.json +13 -1
- package/kits/skills/ability/SKILL.md +229 -34
- package/kits/skills/ability/STRUCTURE.md +333 -0
- package/kits/skills/ability/references/cli.md +208 -0
- package/kits/skills/ability/references/development.md +107 -37
- package/kits/skills/ability/references/management.md +106 -46
- package/kits/skills/ability/references/runtime-protocol.md +65 -63
- package/kits/skills/agent-output-cards/SKILL.md +12 -5
- package/kits/skills/ec-group/SKILL.md +8 -6
- package/kits/skills/ec-group/TASK.md +186 -0
- package/kits/skills/ec-group/WORKLOG.md +180 -0
- package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
- package/kits/skills/ec-pay/SKILL.md +101 -0
- package/kits/skills/ec-pay/references/pay-cli.md +110 -0
- package/kits/skills/ec-provider/SKILL.md +1 -1
- package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
- package/kits/skills/ec-service-call/SKILL.md +135 -0
- package/kits/skills/ec-service-pack/SKILL.md +277 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/workflow.md +46 -0
- package/kits/templates/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +4 -3
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +27 -129
- package/kits/templates/system-fragments/venue.md +16 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +37 -23
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +16 -4
- package/scripts/agent-template/shared/team-schema.json +20 -4
- package/scripts/agent-template/shared/template-contract.mjs +53 -13
- package/scripts/agent-template/shared/template-package.mjs +90 -26
- package/scripts/agent-template/shared/template-runtime.mjs +111 -1
- package/scripts/agent-template/shared/template.mjs +65 -7
- package/scripts/agent-template/team-pack.mjs +89 -33
- package/scripts/agent-template/team-preview.mjs +249 -5
- package/kits/docs/aun/ABILITY_CALLING.md +0 -280
- package/kits/docs/evolcore/ability.md +0 -185
- package/kits/skills/ability/references/calling.md +0 -56
- package/kits/skills/ability/references/contract-checklist.md +0 -37
- package/kits/skills/ability/references/recovery.md +0 -27
- /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
|
@@ -16,6 +16,7 @@ const HELP_TEXT = `
|
|
|
16
16
|
show <ref> 查看单个话题的元数据
|
|
17
17
|
history <ref> 读取话题历史消息
|
|
18
18
|
create <peer> --name 新建话题(对端类型按关系证据自动识别,--group/--private 可覆盖)
|
|
19
|
+
对端不能是本端自己;跨话题自派请先用真实对端建话题
|
|
19
20
|
rename <ref> <名称> 修改话题名称(仅本端)
|
|
20
21
|
status <ref> <状态> 更新话题状态(active|closed|archived)
|
|
21
22
|
delete <ref> 删除话题(session 文件移入 _trash)
|
|
@@ -26,6 +27,7 @@ const HELP_TEXT = `
|
|
|
26
27
|
rebuild-index 重建话题索引(丢失/损坏时使用)
|
|
27
28
|
rebuild-index --check 检查索引健康状态(只报告不写盘,区分严重/轻微)
|
|
28
29
|
check-index 同 rebuild-index --check
|
|
30
|
+
reconcile-status 对账索引与会话文件的状态漂移(默认只报告,--write 写回)
|
|
29
31
|
|
|
30
32
|
典型工作流:
|
|
31
33
|
1. ec thread peers # 查看有话题记录的所有对端
|
|
@@ -43,6 +45,10 @@ list 选项:
|
|
|
43
45
|
--page <n> 页码
|
|
44
46
|
--limit <n> 每页条数
|
|
45
47
|
|
|
48
|
+
reconcile-status 选项:
|
|
49
|
+
--write 按版本判定写回索引(仅「会话文件较新」的条目)
|
|
50
|
+
--agent <aid> 指定 Agent(宿主终端)
|
|
51
|
+
|
|
46
52
|
history 选项:
|
|
47
53
|
--limit <n> 消息条数上限(默认 50)
|
|
48
54
|
--before <time> 截止时间
|
|
@@ -178,6 +184,21 @@ function printItem(item, opts) {
|
|
|
178
184
|
return;
|
|
179
185
|
}
|
|
180
186
|
const obj = item;
|
|
187
|
+
// CreateThreadResult — 必须在 ThreadIndexEntry 之前检查:两者都含 threadId + sessionId,
|
|
188
|
+
// 而创建结果没有 lastActiveAt/nameUpdatedAt 这类索引字段。顺序写反会让创建成功
|
|
189
|
+
// 时走成条目渲染,peerUnverified 提示永远不出现。
|
|
190
|
+
if ('createdAt' in obj && 'sessionId' in obj && !('lastActiveAt' in obj)) {
|
|
191
|
+
console.log(`✓ 话题创建成功: ${obj.threadId}`);
|
|
192
|
+
console.log(` 名称: ${obj.name}`);
|
|
193
|
+
console.log(` 对端: ${obj.peer}`);
|
|
194
|
+
// 本地名片缓存缺失不影响创建(建话题不发消息,离线也必须可建),
|
|
195
|
+
// 但要让用户知道"这个对端本端还没见过",并给出补充路径。
|
|
196
|
+
if (obj.peerUnverified === true) {
|
|
197
|
+
console.warn(`⚠ 对端 ${obj.peer} 本地无名片缓存,消息可能无法投递`);
|
|
198
|
+
console.warn(` 先执行 ec aid agentmd get ${obj.peer} 拉取名片,再重试发送`);
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
181
202
|
// ThreadHistoryResult — 必须在 ThreadIndexEntry 之前检查,两者都含 threadId
|
|
182
203
|
if ('messages' in obj && Array.isArray(obj.messages)) {
|
|
183
204
|
const result = obj;
|
|
@@ -232,13 +253,6 @@ function printItem(item, opts) {
|
|
|
232
253
|
console.log(`[${obj.time}] ${dir} ${obj.from}: ${String(obj.content).slice(0, 120)}`);
|
|
233
254
|
return;
|
|
234
255
|
}
|
|
235
|
-
// CreateThreadResult
|
|
236
|
-
if ('createdAt' in obj && 'sessionId' in obj) {
|
|
237
|
-
console.log(`✓ 话题创建成功: ${obj.threadId}`);
|
|
238
|
-
console.log(` 名称: ${obj.name}`);
|
|
239
|
-
console.log(` 对端: ${obj.peer}`);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
256
|
// RenameThreadResult
|
|
243
257
|
if ('changed' in obj) {
|
|
244
258
|
console.log(obj.changed ? `✓ 改名成功: ${obj.name}` : '✓ 名称未变更');
|
|
@@ -546,11 +560,12 @@ export async function runThreadCommand(args) {
|
|
|
546
560
|
}
|
|
547
561
|
const r = resp.result;
|
|
548
562
|
if (dryRun) {
|
|
549
|
-
//
|
|
563
|
+
// 三个计数都可能缺省(接口只回传有问题的维度),缺省按 0 处理,
|
|
550
564
|
// 否则健康状态也会落进「建议 rebuild」分支。
|
|
551
565
|
const missing = r.missing ?? 0;
|
|
552
566
|
const stale = r.stale ?? 0;
|
|
553
|
-
|
|
567
|
+
const selfPeer = r.selfPeer ?? 0;
|
|
568
|
+
if (missing === 0 && stale === 0 && selfPeer === 0) {
|
|
554
569
|
console.log(`✓ 索引健康:共 ${r.rebuilt ?? r.total} 条话题,session 文件完整`);
|
|
555
570
|
}
|
|
556
571
|
else {
|
|
@@ -560,7 +575,14 @@ export async function runThreadCommand(args) {
|
|
|
560
575
|
if (stale > 0) {
|
|
561
576
|
console.warn(`⚠ [轻微] ${stale} 条话题属性与 session 文件最后一行不一致(写盘时序),rebuild-index 可修复`);
|
|
562
577
|
}
|
|
563
|
-
|
|
578
|
+
if (selfPeer > 0) {
|
|
579
|
+
console.warn(`⚠ [严重] ${selfPeer} 条话题的对端是本端自己——结构残缺,rebuild 修不好,需逐条删除:`);
|
|
580
|
+
for (const id of (r.selfPeerIds ?? [])) {
|
|
581
|
+
console.warn(` ec thread delete ${aid}/${id}`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (missing > 0 || stale > 0)
|
|
585
|
+
console.warn(` 建议执行 ec thread rebuild-index 修复`);
|
|
564
586
|
if (jsonFormat)
|
|
565
587
|
console.log(JSON.stringify(r, null, 2));
|
|
566
588
|
}
|
|
@@ -572,6 +594,42 @@ export async function runThreadCommand(args) {
|
|
|
572
594
|
console.warn(`⚠ ${resp.indexWarning}`);
|
|
573
595
|
break;
|
|
574
596
|
}
|
|
597
|
+
case 'reconcile-status': {
|
|
598
|
+
const aid = argValue(args, '--agent') ?? selfAid;
|
|
599
|
+
const apply = hasFlag(args, '--write');
|
|
600
|
+
const resp = await sendOp({ op: 'reconcile-status', selfAid: aid, apply });
|
|
601
|
+
if (!resp.ok) {
|
|
602
|
+
console.error(`✗ ${resp.error}`);
|
|
603
|
+
process.exitCode = 1;
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const r = resp.result;
|
|
607
|
+
const drift = Array.isArray(r?.drift) ? r.drift : [];
|
|
608
|
+
if (jsonFormat) {
|
|
609
|
+
console.log(JSON.stringify(r, null, 2));
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
if (drift.length === 0) {
|
|
613
|
+
console.log(`✓ 索引与会话文件状态一致,无需对账`);
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
// 逐条列出冲突与判定:只有明确「文件较新」的才可自动修,
|
|
617
|
+
// ambiguous 表示两侧都没有版本号,必须人工确认。
|
|
618
|
+
for (const d of drift) {
|
|
619
|
+
const reason = d.winner === 'file' ? '以会话文件为准'
|
|
620
|
+
: d.winner === 'index' ? '以索引为准' : '无版本依据,需人工确认';
|
|
621
|
+
console.log(`${d.threadId} 索引=${d.indexStatus} 文件=${d.fileStatus} ${reason}`);
|
|
622
|
+
if (d.kind === 'name' || d.kind === 'both')
|
|
623
|
+
console.log(` 名称也有差异,本命令只处理状态`);
|
|
624
|
+
}
|
|
625
|
+
if (apply) {
|
|
626
|
+
console.log(`\n✓ 已按判定写回 ${r.applied ?? 0} 条;其余需人工确认`);
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
console.log(`\n共 ${drift.length} 条可对账;加 --write 按判定写回(仅「文件较新」的条目)`);
|
|
630
|
+
}
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
575
633
|
case 'check-index': {
|
|
576
634
|
const aid = argValue(args, '--agent') ?? selfAid;
|
|
577
635
|
const resp = await sendOp({ op: 'check-index', selfAid: aid });
|
|
@@ -583,7 +641,8 @@ export async function runThreadCommand(args) {
|
|
|
583
641
|
const r = resp.result;
|
|
584
642
|
const missing = r.missing ?? 0;
|
|
585
643
|
const stale = r.stale ?? 0;
|
|
586
|
-
|
|
644
|
+
const selfPeer = r.selfPeer ?? 0;
|
|
645
|
+
if (missing === 0 && stale === 0 && selfPeer === 0) {
|
|
587
646
|
console.log(`✓ 索引健康:共 ${r.total} 条话题,session 文件完整`);
|
|
588
647
|
}
|
|
589
648
|
else {
|
|
@@ -593,7 +652,14 @@ export async function runThreadCommand(args) {
|
|
|
593
652
|
if (stale > 0) {
|
|
594
653
|
console.warn(`⚠ [轻微] ${stale} 条话题属性与 session 文件最后一行不一致(写盘时序),rebuild-index 可修复`);
|
|
595
654
|
}
|
|
596
|
-
|
|
655
|
+
if (selfPeer > 0) {
|
|
656
|
+
console.warn(`⚠ [严重] ${selfPeer} 条话题的对端是本端自己——结构残缺,rebuild 修不好,需逐条删除:`);
|
|
657
|
+
for (const id of (r.selfPeerIds ?? [])) {
|
|
658
|
+
console.warn(` ec thread delete ${aid}/${id}`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (missing > 0 || stale > 0)
|
|
662
|
+
console.warn(` 建议执行 ec thread rebuild-index 修复`);
|
|
597
663
|
if (jsonFormat)
|
|
598
664
|
console.log(JSON.stringify(r, null, 2));
|
|
599
665
|
}
|
|
@@ -14,10 +14,13 @@ export class AccessPolicyError extends Error {
|
|
|
14
14
|
* 缺失 `access` 时按"只收内部联系人"执行:同 Owner 名录成员可进,外部与陌生人不进。
|
|
15
15
|
*
|
|
16
16
|
* `allowAllContacts` 是压过三档的总开关,默认关。
|
|
17
|
+
*
|
|
18
|
+
* `allowExternalContacts` **不在这里**:它没有 schema 默认值,因为"未配置"要由个人助理
|
|
19
|
+
* 身份判定接管(PA 默认接收外部联系人)。补 `false` 会把"未配置"永久写成"显式关闭",
|
|
20
|
+
* 见 docs/config/11-default-value-levels.md。
|
|
17
21
|
*/
|
|
18
22
|
export const DEFAULT_ACCESS_POLICY = Object.freeze({
|
|
19
23
|
allowInternalContacts: true,
|
|
20
|
-
allowExternalContacts: false,
|
|
21
24
|
allowAllContacts: false,
|
|
22
25
|
allowedAids: Object.freeze([]),
|
|
23
26
|
deniedAids: Object.freeze([]),
|
|
@@ -111,13 +114,23 @@ function assertAccessPolicyWrite(input, agent, policy) {
|
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
function clonePolicy(policy) {
|
|
117
|
+
// requestLimit 的每个子字段单独回落:配置里只写了 maxTimes 时 coolDown 仍是数,
|
|
118
|
+
// 浅展开会留下 undefined,频控窗口算成 NaN。
|
|
119
|
+
const maxTimes = policy.requestLimit?.maxTimes ?? DEFAULT_ACCESS_POLICY.requestLimit.maxTimes;
|
|
120
|
+
const coolDown = policy.requestLimit?.coolDown ?? DEFAULT_ACCESS_POLICY.requestLimit.coolDown;
|
|
114
121
|
return {
|
|
122
|
+
...(policy.contactAdmission !== undefined ? { contactAdmission: policy.contactAdmission } : {}),
|
|
115
123
|
allowInternalContacts: policy.allowInternalContacts ?? true,
|
|
116
|
-
|
|
124
|
+
// allowExternalContacts 没有 schema 默认值:未配置就保持缺席,由个人助理身份判定接管。
|
|
125
|
+
// 这里不补 false —— 补了就和 `ec config get access` 的读数不一致,
|
|
126
|
+
// 也会让"未配置"这一信息在 view=access 里丢失。
|
|
127
|
+
...(policy.allowExternalContacts !== undefined
|
|
128
|
+
? { allowExternalContacts: policy.allowExternalContacts }
|
|
129
|
+
: {}),
|
|
117
130
|
allowAllContacts: policy.allowAllContacts ?? false,
|
|
118
131
|
allowedAids: [...(policy.allowedAids ?? [])],
|
|
119
132
|
deniedAids: [...(policy.deniedAids ?? [])],
|
|
120
|
-
requestLimit: {
|
|
133
|
+
requestLimit: { maxTimes, coolDown },
|
|
121
134
|
};
|
|
122
135
|
}
|
|
123
136
|
function accessPolicyRevision(policy) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { isSupportedBaseagent } from '../agents/baseagent.js';
|
|
1
2
|
import { SYSTEM_SESSION_TYPES } from '../core/system-session/types.js';
|
|
2
3
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
3
4
|
const BEHAVIOR_TOP_FIELDS = new Set([
|
|
4
5
|
'active_baseagent',
|
|
5
6
|
'chatmode',
|
|
6
7
|
'mentionMode',
|
|
8
|
+
'privateMentionMode',
|
|
7
9
|
'autoMentionQuietWindowMs',
|
|
8
10
|
'groupSlashRequireMentions',
|
|
9
11
|
'responseMode',
|
|
@@ -33,21 +35,20 @@ export function isAgentOnlyModelField(fieldPath) {
|
|
|
33
35
|
const parts = fieldPath.split('.');
|
|
34
36
|
return parts.length === 3
|
|
35
37
|
&& parts[0] === 'baseagents'
|
|
36
|
-
&&
|
|
38
|
+
&& isSupportedBaseagent(parts[1])
|
|
37
39
|
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning' || parts[2] === 'fallback');
|
|
38
40
|
}
|
|
39
41
|
/** Baseagent selection is Agent-owned as well. */
|
|
40
42
|
export function isAgentOnlyBaseagentField(fieldPath) {
|
|
41
43
|
return fieldPath === 'active_baseagent' || fieldPath === 'baseagents' || isAgentOnlyModelField(fieldPath);
|
|
42
44
|
}
|
|
43
|
-
const SUPPORTED_BASEAGENTS = new Set(['claude', 'codex', 'gemini', 'ecagent']);
|
|
44
45
|
/** Public behavior fields for a runner this version does not implement. */
|
|
45
46
|
export function isUnsupportedBaseagentConfigField(fieldPath) {
|
|
46
47
|
const parts = fieldPath.split('.');
|
|
47
48
|
return parts.length === 3
|
|
48
49
|
&& parts[0] === 'baseagents'
|
|
49
50
|
&& /^[a-z][a-z0-9_-]*$/.test(parts[1])
|
|
50
|
-
&& !
|
|
51
|
+
&& !isSupportedBaseagent(parts[1])
|
|
51
52
|
&& BASEAGENT_BEHAVIOR_FIELDS.has(parts[2]);
|
|
52
53
|
}
|
|
53
54
|
const SENSITIVE_TOP_FIELDS = new Set([
|
|
@@ -57,8 +58,6 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
57
58
|
'lifecycle',
|
|
58
59
|
'initialized',
|
|
59
60
|
'initialization',
|
|
60
|
-
'owner',
|
|
61
|
-
'owners',
|
|
62
61
|
'access',
|
|
63
62
|
'fullaccess',
|
|
64
63
|
'sessionFullAccess',
|
|
@@ -73,7 +72,7 @@ const SENSITIVE_TOP_FIELDS = new Set([
|
|
|
73
72
|
'role',
|
|
74
73
|
'extra_backup',
|
|
75
74
|
]);
|
|
76
|
-
const CRITICAL_AGENT_FIELDS = new Set(['
|
|
75
|
+
const CRITICAL_AGENT_FIELDS = new Set(['admins', 'roles', 'access']);
|
|
77
76
|
const EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
78
77
|
function scalar(rolePermissionKey, valueKind, access = 'role-overridable') {
|
|
79
78
|
return { class: 'safe-scalar', access, rolePermissionKey, valueKind };
|
|
@@ -114,12 +113,14 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
114
113
|
if (parts.length < 3)
|
|
115
114
|
return { class: 'sensitive' };
|
|
116
115
|
const [, baseagent, leaf] = parts;
|
|
117
|
-
if (!
|
|
116
|
+
if (!isSupportedBaseagent(baseagent))
|
|
118
117
|
return { class: 'unknown' };
|
|
119
118
|
const normalizedLeaf = leaf === 'reasoning' ? 'effort' : leaf;
|
|
120
119
|
const permissionKey = `baseagents.${baseagent}.${normalizedLeaf}`;
|
|
121
120
|
if (leaf === 'provider' && parts.length === 3)
|
|
122
121
|
return scalar(permissionKey, 'string', 'owner-only');
|
|
122
|
+
if (leaf === 'enabled' && parts.length === 3)
|
|
123
|
+
return scalar(permissionKey, 'boolean', 'owner-only');
|
|
123
124
|
if (leaf === 'model' && parts.length === 3)
|
|
124
125
|
return scalar(permissionKey, 'string');
|
|
125
126
|
if ((leaf === 'effort' || leaf === 'reasoning') && parts.length === 3)
|
|
@@ -141,6 +142,8 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
141
142
|
return scalar(field, 'nonnegative-number');
|
|
142
143
|
if (field === 'mentionMode')
|
|
143
144
|
return scalar(field, 'mention-mode');
|
|
145
|
+
if (field === 'privateMentionMode')
|
|
146
|
+
return scalar(field, 'private-mention-mode', 'owner-only');
|
|
144
147
|
if (field === 'autoMentionQuietWindowMs')
|
|
145
148
|
return scalar(field, 'nonnegative-number');
|
|
146
149
|
if (field === 'groupSlashRequireMentions')
|
|
@@ -157,6 +160,8 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
157
160
|
return scalar('restartRecovery.enabled', 'boolean');
|
|
158
161
|
if (field === 'skills.watch')
|
|
159
162
|
return scalar('skills.watch', 'boolean');
|
|
163
|
+
if (field === 'ccAgent.enabled')
|
|
164
|
+
return scalar('ccAgent.enabled', 'boolean');
|
|
160
165
|
// 仅 agent-config 声明该字段,relation/defaults 由 schema 路由拒绝。
|
|
161
166
|
if (field === 'baseagentSkills')
|
|
162
167
|
return scalar(field, 'boolean', 'owner-only');
|
|
@@ -361,7 +366,7 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
361
366
|
case 'string':
|
|
362
367
|
return raw ? { ok: true, value: raw } : { ok: false, reason: `Config field ${fieldPath} cannot be empty` };
|
|
363
368
|
case 'baseagent':
|
|
364
|
-
return
|
|
369
|
+
return isSupportedBaseagent(raw)
|
|
365
370
|
? { ok: true, value: raw }
|
|
366
371
|
: { ok: false, reason: `Config field ${fieldPath} must name a supported baseagent` };
|
|
367
372
|
case 'boolean':
|
|
@@ -413,6 +418,10 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
413
418
|
return raw === 'disabled' || raw === 'mention-only' || raw === 'auto'
|
|
414
419
|
? { ok: true, value: raw }
|
|
415
420
|
: { ok: false, reason: `Config field ${fieldPath} must be disabled, mention-only, or auto` };
|
|
421
|
+
case 'private-mention-mode':
|
|
422
|
+
return raw === 'disabled' || raw === 'mention-only'
|
|
423
|
+
? { ok: true, value: raw }
|
|
424
|
+
: { ok: false, reason: `Config field ${fieldPath} must be disabled or mention-only` };
|
|
416
425
|
case 'show-activities':
|
|
417
426
|
return raw === 'all' || raw === 'text' || raw === 'none'
|
|
418
427
|
? { ok: true, value: raw }
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* 详见 docs/config/01-overview.md
|
|
12
12
|
*/
|
|
13
13
|
import fs from 'fs';
|
|
14
|
+
import { validateBaseagentPluginConfigs } from '../agents/baseagent-plugin-descriptor.js';
|
|
14
15
|
import path from 'path';
|
|
15
16
|
import { ensureManagedLockParent, resolveManagedLockPath } from '../core/runtime-lock.js';
|
|
16
17
|
import crypto from 'crypto';
|
|
@@ -22,7 +23,7 @@ import { isValidAid } from '../aun/aid/validation.js';
|
|
|
22
23
|
import { normalizeAidDomain } from '../aun/aid/domain.js';
|
|
23
24
|
import { ensureRelationSharedDirectory } from '../core/relation/shared-data.js';
|
|
24
25
|
import { parseContactAlias } from './peer-alias.js';
|
|
25
|
-
import { loadSchema, listSchemaVersions, currentVersion, isSchemaName, } from './schema-registry.js';
|
|
26
|
+
import { loadSchema, listSchemaVersions, currentVersion, isSchemaName, schemaDefaultsLayer, } from './schema-registry.js';
|
|
26
27
|
import { mergeLayers } from './merge.js';
|
|
27
28
|
import { normalizeAgentLifecycle } from './lifecycle.js';
|
|
28
29
|
import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-field-policy.js';
|
|
@@ -34,9 +35,9 @@ import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
|
34
35
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
35
36
|
import { assertProviderSelectionWrite, resolveProviderModelSettings, validateProvidersFile } from './providers-config.js';
|
|
36
37
|
import { resolveProviderSelectionModel } from '../core/model/model-catalog.js';
|
|
37
|
-
import { assertOwnerConfigRecord,
|
|
38
|
+
import { assertOwnerConfigRecord, normalizeOwnerConfigTree, withOwnerListCompatibility } from './owner-config.js';
|
|
38
39
|
import { getOwners, getPrimaryOwner, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
39
|
-
import { resolveBaseagentModelSelection } from '../agents/baseagent.js';
|
|
40
|
+
import { isSupportedBaseagent, resolveBaseagentModelSelection } from '../agents/baseagent.js';
|
|
40
41
|
import { assertProjectPathReference } from '../utils/project-path.js';
|
|
41
42
|
// AUN gateway discovery belongs to fastaun. Keep the retired gatewayUrl
|
|
42
43
|
// compatibility handling beside the rest of the configuration read/write
|
|
@@ -1033,9 +1034,6 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1033
1034
|
const before = readTextOrNull(file);
|
|
1034
1035
|
const after = `${JSON.stringify(normalized, null, 2)}\n`;
|
|
1035
1036
|
commitAgentConfigTransactionSync(syncAid, [{ file, before, after }]);
|
|
1036
|
-
if (target === ConfigTarget.Agent) {
|
|
1037
|
-
ownerResolver.setAgentConfiguredOwners(syncAid, configuredOwnerList(normalized));
|
|
1038
|
-
}
|
|
1039
1037
|
finishConfigWrite(target, sel, file);
|
|
1040
1038
|
return;
|
|
1041
1039
|
}
|
|
@@ -1048,12 +1046,6 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1048
1046
|
fs.chmodSync(protectedFile, 0o600);
|
|
1049
1047
|
}
|
|
1050
1048
|
}
|
|
1051
|
-
if (target === ConfigTarget.Agent && sel?.self) {
|
|
1052
|
-
ownerResolver.setAgentConfiguredOwners(sel.self, configuredOwnerList(normalized));
|
|
1053
|
-
}
|
|
1054
|
-
if (target === ConfigTarget.Process && typeof normalized?.aid === 'string') {
|
|
1055
|
-
ownerResolver.setConfiguredOwners(normalized.aid, configuredOwnerList(normalized));
|
|
1056
|
-
}
|
|
1057
1049
|
finishConfigWrite(target, sel, file);
|
|
1058
1050
|
}
|
|
1059
1051
|
/**
|
|
@@ -1083,25 +1075,6 @@ export function mutateConfig(target, sel, mutate) {
|
|
|
1083
1075
|
release();
|
|
1084
1076
|
}
|
|
1085
1077
|
}
|
|
1086
|
-
/** Retire both local compatibility fields after freshly confirmed protocol ownership. */
|
|
1087
|
-
export function clearConfiguredOwnerAfterConsensus(subjectAid, ownerAid) {
|
|
1088
|
-
const normalizedOwnerAid = ownerAid.trim();
|
|
1089
|
-
if (!isValidAid(normalizedOwnerAid) || subjectAid === ownerResolver.getDaemonAid())
|
|
1090
|
-
return false;
|
|
1091
|
-
const isConfirmed = () => {
|
|
1092
|
-
const state = ownerResolver.snapshot(subjectAid);
|
|
1093
|
-
return ownerResolver.owner(subjectAid) === normalizedOwnerAid && state.authorizationStatus === 'verified'
|
|
1094
|
-
&& state.consensus?.lock === 'locked' && state.consensus.sub_aid === subjectAid && !state.refreshFailure;
|
|
1095
|
-
};
|
|
1096
|
-
if (!isConfirmed())
|
|
1097
|
-
return false;
|
|
1098
|
-
return mutateConfig(ConfigTarget.Agent, { self: subjectAid }, config => {
|
|
1099
|
-
if (!isConfirmed())
|
|
1100
|
-
return;
|
|
1101
|
-
delete config.owner;
|
|
1102
|
-
delete config.owners;
|
|
1103
|
-
}).changed;
|
|
1104
|
-
}
|
|
1105
1078
|
function cloneConfigValue(value) {
|
|
1106
1079
|
return JSON.parse(JSON.stringify(value));
|
|
1107
1080
|
}
|
|
@@ -1263,6 +1236,7 @@ function ensureSchemaVersion(value, version) {
|
|
|
1263
1236
|
function validateOrThrow(schema, value, target) {
|
|
1264
1237
|
const ok = schema.validate(value);
|
|
1265
1238
|
const scopeErrors = [
|
|
1239
|
+
...validatePluginConfigForTarget(target, value),
|
|
1266
1240
|
...validateProcessOnlyFields(target, value),
|
|
1267
1241
|
...validateProcessAidDomain(target, value),
|
|
1268
1242
|
...validateProcessServiceNames(target, value),
|
|
@@ -1408,6 +1382,7 @@ export function validateConfig(target, value) {
|
|
|
1408
1382
|
}
|
|
1409
1383
|
const ok = schema.validate(normalized);
|
|
1410
1384
|
const errors = [
|
|
1385
|
+
...validatePluginConfigForTarget(target, normalized),
|
|
1411
1386
|
...validateProcessOnlyFields(target, normalized),
|
|
1412
1387
|
...validateProcessAidDomain(target, normalized),
|
|
1413
1388
|
...validateProcessServiceNames(target, normalized),
|
|
@@ -1534,9 +1509,15 @@ export function resolveAgentConfig(sel, opts = {}) {
|
|
|
1534
1509
|
const fields = loadSchema('agent-config').fields;
|
|
1535
1510
|
const agentConfig = sel.self ? read(ConfigTarget.Agent, sel, opts) : null;
|
|
1536
1511
|
const relationConfig = (sel.self && sel.peerKey) ? read(ConfigTarget.Relation, sel, opts) : null;
|
|
1512
|
+
// 每一层的 schema 默认值先于该层自己的配置文件进入覆盖链:某层文件没写参数时,
|
|
1513
|
+
// 该层仍以 schema default 出值。默认值挂在哪一层是设计决策,规则见
|
|
1514
|
+
// docs/config/11-default-value-levels.md。
|
|
1537
1515
|
const layers = [
|
|
1516
|
+
schemaDefaultsLayer('defaults'),
|
|
1538
1517
|
stripDefaultsLegacyModelFields(stripStaticOwnerField(normalizeDefaultsBehaviorCompat(read(ConfigTarget.Defaults, undefined, opts)))),
|
|
1518
|
+
schemaDefaultsLayer('agent-config'),
|
|
1539
1519
|
agentConfig,
|
|
1520
|
+
schemaDefaultsLayer('relation-config'),
|
|
1540
1521
|
stripRelationRoleData(stripStaticOwnerField(relationConfig)),
|
|
1541
1522
|
];
|
|
1542
1523
|
const merged = mergeLayers(layers, fields);
|
|
@@ -1613,8 +1594,35 @@ function stripDefaultsLegacyModelFields(config) {
|
|
|
1613
1594
|
if (!config)
|
|
1614
1595
|
return config;
|
|
1615
1596
|
const { models: _models, decision_model: _decisionModel, ...rest } = config;
|
|
1597
|
+
if (rest.baseagents && typeof rest.baseagents === 'object' && !Array.isArray(rest.baseagents)) {
|
|
1598
|
+
const blocks = {};
|
|
1599
|
+
for (const [name, raw] of Object.entries(rest.baseagents)) {
|
|
1600
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
1601
|
+
blocks[name] = raw;
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
const { enabled: _enabled, ...block } = raw;
|
|
1605
|
+
if (Object.keys(block).length || !Object.hasOwn(raw, 'enabled'))
|
|
1606
|
+
blocks[name] = block;
|
|
1607
|
+
}
|
|
1608
|
+
rest.baseagents = blocks;
|
|
1609
|
+
}
|
|
1616
1610
|
return rest;
|
|
1617
1611
|
}
|
|
1612
|
+
function validatePluginConfigForTarget(target, value) {
|
|
1613
|
+
if (target !== ConfigTarget.Agent && target !== ConfigTarget.Defaults)
|
|
1614
|
+
return [];
|
|
1615
|
+
const config = value;
|
|
1616
|
+
const errors = validateBaseagentPluginConfigs(config?.baseagents, target === ConfigTarget.Defaults);
|
|
1617
|
+
for (const name of Object.keys(config?.baseagents ?? {})) {
|
|
1618
|
+
if (!isSupportedBaseagent(name))
|
|
1619
|
+
errors.push(`/baseagents/${name}: plugin is not installed or discovered`);
|
|
1620
|
+
}
|
|
1621
|
+
if (config?.active_baseagent !== undefined && !isSupportedBaseagent(config.active_baseagent)) {
|
|
1622
|
+
errors.push('/active_baseagent: plugin is not installed or discovered');
|
|
1623
|
+
}
|
|
1624
|
+
return errors;
|
|
1625
|
+
}
|
|
1618
1626
|
function stripRelationRoleData(config) {
|
|
1619
1627
|
if (!config || (!Object.prototype.hasOwnProperty.call(config, 'role')
|
|
1620
1628
|
&& !Object.prototype.hasOwnProperty.call(config, 'roles')
|
|
@@ -1654,9 +1662,10 @@ function stripRelationRoleData(config) {
|
|
|
1654
1662
|
* 合并视图:只合并物理覆盖链 defaults → agent/config → relation/config。
|
|
1655
1663
|
*/
|
|
1656
1664
|
export function resolveEffective(sel, opts = {}) {
|
|
1665
|
+
// 默认值已经作为各层的值参与合并(见 resolveAgentConfig),这里不再补任何
|
|
1666
|
+
// 硬编码兜底:任何字段为 undefined 都表示"整条链都没配、且 schema 也没给默认值",
|
|
1667
|
+
// 那就是未配置。规则见 docs/config/11-default-value-levels.md。
|
|
1657
1668
|
const config = resolveAgentConfig(sel, opts);
|
|
1658
|
-
const observableDefault = loadSchema('agent-config').fields.get('observable')?.default;
|
|
1659
|
-
const autoMentionQuietWindowMsDefault = loadSchema('agent-config').fields.get('autoMentionQuietWindowMs')?.default;
|
|
1660
1669
|
const effective = {
|
|
1661
1670
|
$schema_version: config.$schema_version ?? currentVersion('agent-config'),
|
|
1662
1671
|
aid: config.aid ?? sel.self ?? '',
|
|
@@ -1669,32 +1678,28 @@ export function resolveEffective(sel, opts = {}) {
|
|
|
1669
1678
|
owner: getPrimaryOwner(sel.self ?? config.aid ?? ''),
|
|
1670
1679
|
owners: getOwners(sel.self ?? config.aid ?? ''),
|
|
1671
1680
|
fullaccess: config.fullaccess,
|
|
1681
|
+
// access 是 Agent 级唯一来源,合并链上不会出现其它层的值;这里只做键序归一,
|
|
1682
|
+
// 保证 `ec config get access` 与 `connect view=access` 输出逐字节一致。
|
|
1683
|
+
access: normalizeAccessPolicy(config.access),
|
|
1672
1684
|
aun: config.aun,
|
|
1673
1685
|
channels: config.channels ?? [],
|
|
1674
1686
|
projects: config.projects,
|
|
1675
1687
|
capabilities: config.capabilities,
|
|
1676
|
-
ability:
|
|
1677
|
-
...config.ability,
|
|
1678
|
-
codeApproval: {
|
|
1679
|
-
...config.ability?.codeApproval,
|
|
1680
|
-
enabled: config.ability?.codeApproval?.enabled ?? true,
|
|
1681
|
-
},
|
|
1682
|
-
},
|
|
1688
|
+
ability: config.ability,
|
|
1683
1689
|
baseagentSkills: config.baseagentSkills,
|
|
1684
1690
|
readonlySourceDiagnostics: config.readonlySourceDiagnostics,
|
|
1685
|
-
|
|
1686
|
-
// factory default here so omitted observable fields are enabled at runtime.
|
|
1687
|
-
observable: config.observable ?? (typeof observableDefault === 'boolean' ? observableDefault : true),
|
|
1691
|
+
observable: config.observable,
|
|
1688
1692
|
extra_backup: config.extra_backup,
|
|
1689
1693
|
// Runtime configuration parameters
|
|
1690
1694
|
active_baseagent: config.active_baseagent,
|
|
1691
1695
|
baseagents: config.baseagents,
|
|
1692
1696
|
Services: config.Services,
|
|
1693
1697
|
chatmode: config.chatmode,
|
|
1698
|
+
// 群聊 @ 策略刻意不带默认值:未配置时要让服务端的 mention_mode 生效。
|
|
1694
1699
|
mentionMode: config.mentionMode,
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
groupSlashRequireMentions: config.groupSlashRequireMentions
|
|
1700
|
+
privateMentionMode: config.privateMentionMode,
|
|
1701
|
+
autoMentionQuietWindowMs: config.autoMentionQuietWindowMs,
|
|
1702
|
+
groupSlashRequireMentions: config.groupSlashRequireMentions,
|
|
1698
1703
|
responseMode: config.responseMode,
|
|
1699
1704
|
responseModeParams: config.responseModeParams,
|
|
1700
1705
|
flush_delay: config.flush_delay,
|
|
@@ -1720,6 +1725,35 @@ export function assertAgentModelConfigured(self, baseagent) {
|
|
|
1720
1725
|
throw new ConfigError('MODEL_NOT_CONFIGURED', `Configure baseagents.${backend}.model before enabling or selecting this backend`);
|
|
1721
1726
|
}
|
|
1722
1727
|
}
|
|
1728
|
+
/**
|
|
1729
|
+
* 按固定字段顺序重排准入策略,并裁掉未配置的键。
|
|
1730
|
+
*
|
|
1731
|
+
* 值本身全部来自合并链(defaults → agent 的 schema 默认值层 + 配置文件),这里
|
|
1732
|
+
* **不补任何默认值**:`allowExternalContacts` / `contactAdmission` 没有默认值,
|
|
1733
|
+
* 未配置就必须是未配置(个人助理按身份判定的逻辑依赖这一点)。只做两件事:
|
|
1734
|
+
* 固定键序(`ec config get access` 与 `connect view=access` 必须逐字节一致),
|
|
1735
|
+
* 以及 array 字段拷贝一份,避免调用方改写污染配置缓存。
|
|
1736
|
+
*/
|
|
1737
|
+
function normalizeAccessPolicy(policy) {
|
|
1738
|
+
if (!policy)
|
|
1739
|
+
return policy;
|
|
1740
|
+
return {
|
|
1741
|
+
...(policy.contactAdmission !== undefined ? { contactAdmission: policy.contactAdmission } : {}),
|
|
1742
|
+
...(policy.allowInternalContacts !== undefined ? { allowInternalContacts: policy.allowInternalContacts } : {}),
|
|
1743
|
+
// allowExternalContacts 没有 schema 默认值:未配置时保持缺席,由个人助理身份判定接管。
|
|
1744
|
+
...(policy.allowExternalContacts !== undefined ? { allowExternalContacts: policy.allowExternalContacts } : {}),
|
|
1745
|
+
...(policy.allowAllContacts !== undefined ? { allowAllContacts: policy.allowAllContacts } : {}),
|
|
1746
|
+
...(policy.allowedAids !== undefined ? { allowedAids: [...policy.allowedAids] } : {}),
|
|
1747
|
+
...(policy.deniedAids !== undefined ? { deniedAids: [...policy.deniedAids] } : {}),
|
|
1748
|
+
// requestLimit 的两个子字段在 agent-config schema 里有默认值,合并后必然齐全;
|
|
1749
|
+
// 兜底值只防 schema 被误删时算出 NaN 频控窗口(不 import DEFAULT_ACCESS_POLICY,
|
|
1750
|
+
// 那会造成 access-policy ↔ config-manager 的循环依赖)。
|
|
1751
|
+
requestLimit: {
|
|
1752
|
+
maxTimes: policy.requestLimit?.maxTimes ?? 600,
|
|
1753
|
+
coolDown: policy.requestLimit?.coolDown ?? 3600,
|
|
1754
|
+
},
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1723
1757
|
function normalizeEffectiveCompatibility(effective) {
|
|
1724
1758
|
normalizeShowActivitiesCompat(effective);
|
|
1725
1759
|
const behavior = {};
|
|
@@ -1737,6 +1771,7 @@ const EFFECTIVE_BEHAVIOR_FIELDS = [
|
|
|
1737
1771
|
'baseagents',
|
|
1738
1772
|
'chatmode',
|
|
1739
1773
|
'mentionMode',
|
|
1774
|
+
'privateMentionMode',
|
|
1740
1775
|
'autoMentionQuietWindowMs',
|
|
1741
1776
|
'groupSlashRequireMentions',
|
|
1742
1777
|
'flush_delay',
|
|
@@ -1764,6 +1799,11 @@ export function routeFieldPath(fieldPath, scope) {
|
|
|
1764
1799
|
if (scope === 'relation' && isAgentOnlyBaseagentField(fieldPath)) {
|
|
1765
1800
|
throw new ConfigError('SCOPE_MISMATCH', `${fieldPath} is Agent-scoped and cannot be configured per relation`);
|
|
1766
1801
|
}
|
|
1802
|
+
// privateMentionMode 只存在于 agent-config:私聊提及模式是 Agent 的身份级开关,
|
|
1803
|
+
// 不按对端区分。显式拒绝,避免落成一条永远读不到的孤儿配置。
|
|
1804
|
+
if (scope === 'relation' && topField === 'privateMentionMode') {
|
|
1805
|
+
throw new ConfigError('SCOPE_MISMATCH', `${fieldPath} is Agent-scoped and cannot be configured per relation`);
|
|
1806
|
+
}
|
|
1767
1807
|
if (topField === 'sessionLoop') {
|
|
1768
1808
|
throw new ConfigError('SESSION_LOOP_MANAGED', 'sessionLoop is managed through the dedicated /loop or session Menu entry');
|
|
1769
1809
|
}
|
|
@@ -381,13 +381,20 @@ function executeGet(op, options) {
|
|
|
381
381
|
? diagnoseRelationLayer(op, withSource.source?.target === ConfigTarget.Relation)
|
|
382
382
|
: undefined;
|
|
383
383
|
if (withSource.source) {
|
|
384
|
+
// 顶层对象存在、叶子缺失(例如 access 写了 allowAllContacts 但没写
|
|
385
|
+
// requestLimit.coolDown):值按 schema default 回落,来源仍报告存储层,
|
|
386
|
+
// 让调用方知道"这块配过一部分"。
|
|
387
|
+
const value = withSource.value !== undefined
|
|
388
|
+
? withSource.value
|
|
389
|
+
: fieldSchemaDefault(op.route?.schema ?? 'agent-config', op.field);
|
|
384
390
|
return {
|
|
385
391
|
ok: true,
|
|
386
392
|
subcommand: 'get',
|
|
387
393
|
field: op.field,
|
|
388
|
-
value:
|
|
394
|
+
value: value ?? null,
|
|
389
395
|
scope: op.configScope,
|
|
390
396
|
source: withSource.source,
|
|
397
|
+
...(withSource.value === undefined && value !== undefined ? { schemaDefault: true } : {}),
|
|
391
398
|
...(note ? { note } : {}),
|
|
392
399
|
};
|
|
393
400
|
}
|
|
@@ -398,6 +405,20 @@ function executeGet(op, options) {
|
|
|
398
405
|
if (withSource.value !== undefined && !op.route) {
|
|
399
406
|
return { ok: true, subcommand: 'get', field: op.field, value: withSource.value, scope: op.configScope };
|
|
400
407
|
}
|
|
408
|
+
// 有 route 但没有任何存储层配置过:值来自 schema 默认值层(它作为该层的值参与了
|
|
409
|
+
// 合并,见 docs/config/11-default-value-levels.md)。必须标 schemaDefault,
|
|
410
|
+
// 否则文本输出会误报成一次普通取值。
|
|
411
|
+
if (withSource.value !== undefined && op.route) {
|
|
412
|
+
return {
|
|
413
|
+
ok: true,
|
|
414
|
+
subcommand: 'get',
|
|
415
|
+
field: op.field,
|
|
416
|
+
value: withSource.value,
|
|
417
|
+
scope: op.configScope,
|
|
418
|
+
schemaDefault: true,
|
|
419
|
+
...(note ? { note } : {}),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
401
422
|
return getWithSchemaDefault(op, null, note);
|
|
402
423
|
}
|
|
403
424
|
/**
|