evolcore 0.0.40 → 0.0.41-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -1
- package/bin/codex-managed-hook.mjs +11 -0
- package/bin/ec-safe-output.js +11 -1
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +20 -43
- package/dist/agents/claude-runner.js +197 -197
- package/dist/agents/codex-runner.js +535 -259
- package/dist/agents/ecagent-runner.js +31 -12
- package/dist/agents/gemini-runner.js +27 -7
- package/dist/agents/runner-types.js +11 -3
- package/dist/aun/ability-device-routing.js +26 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -13
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/msg/managed-operation.js +72 -11
- package/dist/aun/msg/p2p.js +32 -7
- package/dist/aun/service-proxy.js +36 -12
- package/dist/aun/storage/download.js +30 -0
- package/dist/aun/storage/index.js +14 -6
- package/dist/channels/aun.js +367 -24
- package/dist/channels/daemon.js +39 -5
- package/dist/cli/agent-command.js +2 -0
- package/dist/cli/agent-create.js +98 -19
- package/dist/cli/agent.js +10 -3
- package/dist/cli/aun-commands.js +85 -41
- package/dist/cli/daemon-commands.js +678 -688
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +48 -4
- package/dist/cli/managed-command-guard.js +4 -0
- package/dist/cli/model.js +40 -40
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +17 -0
- package/dist/cli/role.js +85 -0
- package/dist/cli/session-command.js +128 -13
- package/dist/cli/stats.js +60 -4
- package/dist/cli/trigger-command.js +2 -2
- package/dist/config/access-policy.js +8 -1
- package/dist/config/boot-log.js +38 -1
- package/dist/config/config-field-policy.js +5 -32
- package/dist/config/config-manager.js +46 -39
- package/dist/config/config-operation-service.js +8 -11
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +89 -595
- package/dist/config/peer-role-resolver.js +15 -11
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/resolved-config-op.js +3 -0
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +686 -25
- package/dist/config-store.js +79 -3
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +3 -1
- package/dist/core/agent-application-service.js +11 -1
- package/dist/core/agent-ipc-registration.js +4 -0
- package/dist/core/agent-runtime.js +1 -1
- package/dist/core/auth/agent-delegation.js +82 -6
- package/dist/core/auth/auth-gateway.js +1 -1
- package/dist/core/auth/authorization-audit.js +37 -9
- package/dist/core/auth/delegation-authorization.js +3 -1
- package/dist/core/auth/operation-authorizer.js +15 -0
- package/dist/core/auth/operation-catalog.js +39 -6
- package/dist/core/command/agent-control.js +94 -19
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +105 -145
- package/dist/core/command/connect-menu.js +31 -2
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +6 -6
- package/dist/core/command/menu-handler.js +87 -163
- package/dist/core/command/menu-protocol.js +9 -2
- package/dist/core/command/role-menu.js +148 -30
- package/dist/core/command/slash-gate.js +13 -10
- package/dist/core/command/slash-handler.js +157 -352
- package/dist/core/daemon-control.js +8 -14
- package/dist/core/event-catalog.js +15 -0
- package/dist/core/evolagent-registry.js +4 -4
- package/dist/core/evolagent.js +2 -2
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/ipc-registration.js +24 -3
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +1 -1
- package/dist/core/memory/consolidation-trigger.js +190 -190
- package/dist/core/memory/consolidation.js +316 -29
- package/dist/core/memory/forget-log.js +96 -0
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +44 -39
- package/dist/core/message/aun-ipc-sender.js +34 -7
- package/dist/core/message/aun-request-registry.js +97 -3
- package/dist/core/message/im-renderer.js +11 -4
- package/dist/core/message/message-admission.js +97 -8
- package/dist/core/message/message-bridge.js +71 -24
- package/dist/core/message/message-log.js +55 -0
- package/dist/core/message/message-queue.js +5 -5
- package/dist/core/message/response-engine.js +387 -144
- package/dist/core/model/catalog-service.js +4 -2
- package/dist/core/model/config-scope.js +24 -64
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +37 -47
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +25 -23
- package/dist/core/permission/ec-command-parser.js +138 -5
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +42 -10
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +197 -0
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +168 -14
- package/dist/core/session/session-mapper.js +2 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +6 -1
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +79 -17
- package/dist/ipc.js +189 -17
- package/dist/paths.js +4 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +485 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +15 -0
- package/dist/stats/index.js +2 -2
- package/dist/stats/price-resolver.js +304 -5
- package/dist/stats/query.js +82 -3
- package/dist/stats/writer.js +38 -5
- package/dist/trigger/feedback.js +18 -7
- package/dist/trigger/manager.js +20 -3
- package/dist/trigger/parser.js +6 -3
- package/dist/trigger/patch.js +1 -1
- package/dist/trigger/system-definitions.js +43 -7
- package/dist/trigger/validation.js +13 -5
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +16 -2
- package/dist/utils/logger.js +24 -5
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +5 -3
- package/dist/utils/upgrade-jobs.js +45 -5
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/ABILITY_CALLING.md +20 -2
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +2 -1
- package/kits/docs/evolcore/agent-create.md +3 -2
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/config.md +18 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/event.md +1 -0
- package/kits/docs/evolcore/fs.md +16 -0
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +36 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +21 -8
- package/kits/docs/evolcore/session.md +14 -0
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +23 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +260 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +3 -7
- package/kits/skills/aid-ability/SKILL.md +35 -6
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-trigger/SKILL.md +13 -5
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/session-capsule/recovery.md +5 -0
- package/kits/templates/session-capsule/renew.md +5 -0
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/bootstrap.md +6 -6
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/memory.md +4 -4
- package/package.json +7 -3
- package/dist/stats/billing.js +0 -215
|
@@ -38,8 +38,14 @@
|
|
|
38
38
|
**统一入口 `launchConsolidation()`**:所有触发路径——关系整理链、手动调用、定时检查、上下文压缩、renew / `/new`——都收口到这一个函数。它负责整理的完整生命周期:启动前把 `pending/` 加锁移入 `processing/`,序列化上下文文件,**直接创建整理会话**,会话结束后通过 `onConsolidationComplete` 处理收尾(归位、checkpoint、定稿索引、反馈)。
|
|
39
39
|
|
|
40
40
|
**整理一律以关系为单位**,一个会话只处理一个关系。触发方:
|
|
41
|
-
-
|
|
42
|
-
-
|
|
41
|
+
- **关系整理链**(主路径,内容驱动):每个关系一个计时器,对该关系依次跑 notes → generalize → promote(仅 owner 关系),每步收尾后再判定下一步。
|
|
42
|
+
- 空闲到期:最后一次活动后 `idleHours`(默认 1 小时)没有新活动。只跑候选攒够 `minBatchItems`(默认 3)条的步骤,不够的推迟。
|
|
43
|
+
- 兜底到期:最早一次未整理的活动满 `maxUnconsolidatedHours`(默认 8 小时),持续聊天也会到期。有 1 条候选就跑。
|
|
44
|
+
- 候选:notes 数 pending 里的 note,generalize 数本关系 `to-generalize`,promote 数本关系 **与 agent 层**的 `to-promote`。
|
|
45
|
+
- 活动:真实入站(含群里未被 @ 的消息;owner 插话不算)、往该关系写 note、群链按发言人写入该关系。
|
|
46
|
+
- 触发来源 `relation-idle`,**不反馈**。
|
|
47
|
+
- **定时检查**(时间驱动):evolcore trigger 的 `script` 模式每小时执行,逐关系检查画像到期(profile:还没有画像且已有记忆,或画像生成后有新建记忆且画像满 `profileRegenDays`;距上次尝试不满 `profileRegenDays` 不再拉起)和关系层超期记忆(forget),外加 agent 层、owner 层的 forget。agent 层有 `to-promote` 时也在这里按 owner 关系兜底拉起 promote(标签不是 generalize 打的,或泛化收尾时还没有 owner 关系目录)。一个会话只处理一个关系或一层,同样的整理已在排队或在跑时跳过。
|
|
48
|
+
- **泛化收尾跨层触发**:generalize 会话成功收尾时,若 agent 层有 `to-promote`,立即按 owner 关系拉起 promote(排在本 agent 的串行队列里,槽位一空就跑)。本次 generalize 若就是 owner 关系整理链的一步则跳过——链的下一步就是 promote。agent 级记忆不挂任何关系,关系整理链等不到它的空闲,这是它的主路径;agent 层标签不攒批,有 1 条就跑。触发来源 `relation-idle`,不反馈。
|
|
43
49
|
- **手动 / compact / renew / `/new`**:直接对当前关系调用 `launchConsolidation()`。
|
|
44
50
|
|
|
45
51
|
**并发与排队**:同一 agent 同时只能有一个整理会话在跑;全局最多 5 个 agent 并发。超出的请求排队,前一个结束后自动启动下一个。
|
|
@@ -52,7 +58,7 @@
|
|
|
52
58
|
|---|---|---|---|---|
|
|
53
59
|
| `notes` | 当前关系的 `pending/` + 会话历史 | relation 正式记忆 | 值不值得长期留下 | 否 |
|
|
54
60
|
| `generalize` | 关系级里带 `to-generalize` 的记忆 | agent 正式记忆 | **普遍性**:换成别的对端也成立 | 否 |
|
|
55
|
-
| `promote` |
|
|
61
|
+
| `promote` | 关系级与 agent 层带 `to-promote` 的记忆 | owner 正式记忆 | **权威性**:owner 定下、对所有 agent 有效 | **是** |
|
|
56
62
|
| `profile` | 该关系索引里的全部记忆 | 一条带 `profile` 标签的 relation 记忆 | 归纳对端这个主体 | 否 |
|
|
57
63
|
| `forget` | mtime 超过 `forgetAfterDays` 的记忆 | 无新结论,只做续期 / 合并 / 归档 | 这条还成立吗 | 否 |
|
|
58
64
|
|
|
@@ -79,6 +85,7 @@ ec memory create --scope <relation|agent|owner> --slug <slug> --desc '一句话
|
|
|
79
85
|
- **目标 slug 已存在且未在 `--replaces` 里列出 → 拒绝**,报错回传已有文件路径。这是防止漏用 `--replaces` 导致静默覆盖的闸门。
|
|
80
86
|
- **正文上限 10KB**,超出报 `MEMORY_TOO_LARGE`。这不是技术限制,而是记忆的性质决定的:一条记忆应当是**一句话能说清的结论**。内容确实那么多时,拆成多条分别 `create`,或把细节留在归档文件里、记忆只记结论。
|
|
81
87
|
- `--reason` 写进批次目录的 `ops.jsonl` 操作流水,不进记忆正文。结论属于记忆,判断依据属于过程记录。
|
|
88
|
+
- forget 模式下 `update` / `archive` / `create --replaces` 必须带 `--reason`(≤80 字,针对这一条记忆),`update` 只能 `--touch`,`archive` 一次一条;理由另记入遗忘日志(见第八节)。
|
|
82
89
|
|
|
83
90
|
### 跨层路径
|
|
84
91
|
|
|
@@ -140,7 +147,8 @@ daemon 按整理会话的模式校验 `--scope`:
|
|
|
140
147
|
**其他写入限制**:
|
|
141
148
|
|
|
142
149
|
- **整理一律以关系为单位:带前缀的路径里 peerKey 必须是本次会话所属关系**,所有模式都一样。整理会话的可读根只含当前关系的 `consolidated/`,允许写别的关系等于对读不到的目录做归档,绕过 grants 边界。没有所属关系的会话(owner 层 / agent 层 forget)不接受带前缀的路径。
|
|
143
|
-
-
|
|
150
|
+
- 保留前缀 `agent/` 指本 agent 的 `personal/memory/consolidated/`(`agent/consolidated/x.md`)。它不是关系名,不受"必须是所属关系"限制;promote 从 agent 层取候选时用它寻址。
|
|
151
|
+
- 唯一的例外是群聊 notes 的 `--peer`:按发言人把记忆写进发言人自己的关系。被写入的关系在群的整理链结束后各记一次活动,按它自己的空闲 / 兜底计时整理。
|
|
144
152
|
- `profile` 标签的记忆,一个关系只能有一条。重新生成必须用 `--replaces` 指定旧的那条。
|
|
145
153
|
- `to-promote` 只能打在对端是 owner 的关系上。群聊关系额外检查发言人身份,owner 本人说的话可以打。
|
|
146
154
|
- 全局总开关是 `memory.enableRelation`。它关闭时,五种模式和手动调用全部拒绝。
|
|
@@ -156,7 +164,7 @@ daemon 按整理会话的模式校验 `--scope`:
|
|
|
156
164
|
**`notes` 模式**的输入是:
|
|
157
165
|
|
|
158
166
|
- `pending/` 里的全部 note
|
|
159
|
-
- 会话历史(整理会话带了该关系的路由时生成话题快照:`compress` / `session-new` / `manual`,以及关系整理链 `relation-idle
|
|
167
|
+
- 会话历史(整理会话带了该关系的路由时生成话题快照:`compress` / `session-new` / `manual`,以及关系整理链 `relation-idle`、定时检查拉起的关系级 profile / forget;该关系没有入站记录、拿不到路由时没有会话历史,只能凭 note 本身判断)
|
|
160
168
|
- 现有的 `MEMORY.md` 索引(查重用)
|
|
161
169
|
|
|
162
170
|
**`launchConsolidation()` 在拉起整理会话之前会把 `pending/` 整体 rename 到 `processing/`**,相当于加锁声明认领。整理过程中主会话新写的 note 落在 `pending/`,不会被这次整理误伤,也不会被误删。
|
|
@@ -186,7 +194,11 @@ daemon 按整理会话的模式校验 `--scope`:
|
|
|
186
194
|
- 往 `ops.jsonl` 追加一行 `summary`(created / updated / archived / errors 计数)。
|
|
187
195
|
- 导出整理会话历史到 `history.jsonl`。
|
|
188
196
|
|
|
189
|
-
|
|
197
|
+
整理会话里的 `create` / `update` / `archive` 只写文件、追加 `ops.jsonl`,**不重建索引**。收尾时按 `ops.jsonl` 里出现过的层逐层 `rebuildIndex`(`collectAffectedScopes`),失败回撤之后也重建一次,把索引对齐到磁盘现状。只有 `ec memory demote` 会在写完后即时重建源层与目标层。
|
|
198
|
+
|
|
199
|
+
**失败 / 中断的回撤**:按 `ops.jsonl` 倒序撤掉成功的写操作(create 删文件并还原被归档的旧文件;archive 从 `archive/` 移回;update 恢复 tags、`updatedAt`、mtime),每一步都过完整性台账。撤掉的如果是遗忘日志里记过的操作,同一份日志会补一行「撤销…」(来源 `rollback:<批次目录名>`)。
|
|
200
|
+
|
|
201
|
+
> daemon 中途退出时收尾不会执行,这批日志就没有对应的「撤销」行。下一轮遗忘看到同一批记忆时照常按内容重新判断,日志只如实记录发生过什么,不做自动对账。
|
|
190
202
|
|
|
191
203
|
上一批的 `processing/` 还在时(会话未结束,或 daemon 中途重启丢了收尾),新一轮 notes 整理不迁移 `pending/`,避免两批混在一起。
|
|
192
204
|
|
|
@@ -234,9 +246,21 @@ daemon 按整理会话的模式校验 `--scope`:
|
|
|
234
246
|
├── processing/ # 整理中快照
|
|
235
247
|
├── consolidated/ # 正式记忆(已登记完整性台账),文件名即 <slug>.md
|
|
236
248
|
└── archive/
|
|
237
|
-
|
|
249
|
+
├── consolidated/ # 归档的正式记忆
|
|
250
|
+
├── notes/ # 整理完成的 pending 原件
|
|
251
|
+
└── FORGET-LOG.md # 遗忘日志(审计记录,不是记忆,不进索引)
|
|
238
252
|
```
|
|
239
253
|
|
|
254
|
+
**遗忘日志** `archive/FORGET-LOG.md`:遗忘机制每动一条记忆,就在该记忆所在层追加一行,记时间、动作、记忆、理由、来源。只追加,不随整理批次目录清理。
|
|
255
|
+
|
|
256
|
+
| 动作 | 何时写 | 来源列 |
|
|
257
|
+
|---|---|---|
|
|
258
|
+
| `续期` / `归档` / `合并归档→<新slug>` | forget 会话的 `update --touch` / `archive` / `create --replaces` | 批次目录名 |
|
|
259
|
+
| `撤销续期` / `撤销归档` / `撤销合并` | forget 会话失败,回撤上面的操作 | `rollback:<批次目录名>` |
|
|
260
|
+
| `手动归档` / `恢复` | `/memory archive` / `/memory restore` | `slash:<发起人 AID>` |
|
|
261
|
+
|
|
262
|
+
其他模式 `--replaces` 产生的归档、长期记忆的推迟审查都不写。整理会话读不到这份日志,每次审查按记忆内容重新判断。
|
|
263
|
+
|
|
240
264
|
**索引**:每个作用域一份,上限 `memory.indexMaxBytes`(默认 5KB)。重建时**逐份过完整性台账**:被带外修改的先恢复到最后登记的版本再进索引,被改动且无法恢复的跳过、不移动文件。筛选顺序:
|
|
241
265
|
|
|
242
266
|
1. `important`、`urgent`、`profile` 必进,**永不淘汰**
|
|
@@ -254,7 +278,7 @@ daemon 按整理会话的模式校验 `--scope`:
|
|
|
254
278
|
|
|
255
279
|
没进索引的文件仍留在磁盘上,可以搜到;只有 `archive` 才让它下线。
|
|
256
280
|
|
|
257
|
-
**整理批次**:`$EVOLCORE_HOME/memory/consolidation-batches/`,每次整理建一个批次目录,命名为 `YYYYMMDDTHHmmss-<selfAid>-<mode>/`,目录内含 `context.md`(任务书)、`ops.jsonl`(操作流水)、`threads
|
|
281
|
+
**整理批次**:`$EVOLCORE_HOME/memory/consolidation-batches/`,每次整理建一个批次目录,命名为 `YYYYMMDDTHHmmss-<selfAid>-<mode>/`,目录内含 `context.md`(任务书)、`ops.jsonl`(操作流水)、`threads/`(话题快照)。每次拉起整理时程序只保留最新的 10 个批次目录(所有 agent、所有模式共用这 10 个名额),更早的整个删掉。遗忘日志不在批次目录里,不受清理影响。详细结构见 `memory-consolidation-batches.md`。
|
|
258
282
|
|
|
259
283
|
---
|
|
260
284
|
|
|
@@ -73,7 +73,7 @@ ec memory consolidate [--mode <notes|generalize|promote|profile|forget>]
|
|
|
73
73
|
| `generalize` | 关系级 → agent 级 | 对端说「不管跟谁聊你都要记得这个」 |
|
|
74
74
|
| `promote` | 关系级 → owner 级 | owner 说「让我所有 Agent 都记住这个」 |
|
|
75
75
|
| `profile` | 生成/重建当前对端画像 | owner 说「重新生成一下画像」 |
|
|
76
|
-
| `forget` | 评估超期记忆续期或归档 |
|
|
76
|
+
| `forget` | 评估超期记忆续期或归档 | 一般不手动:关系层、agent 层、owner 层都由定时检查发起 |
|
|
77
77
|
|
|
78
78
|
**命令是异步的**:`launchConsolidation()` 在拿到整理会话的 base agent 会话 ID 后命令即退出,不等整理会话完成。输出示例:
|
|
79
79
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
> 状态:[done]
|
|
2
|
+
> 创建:2026-10-27
|
|
3
|
+
|
|
1
4
|
# Menu Protocol 规范
|
|
2
5
|
|
|
3
6
|
Menu Protocol 是 EvolCore 在 AUN `message.send` 之上建立的**应用层协议**,与 AUN SDK 本身无关。任何能发送 AUN 消息的客户端,只要按照本文约定的 payload 格式发送,都可以与 EvolCore daemon 交互。对应实现:`src/core/command/menu-protocol.ts`、`src/aun/menu/`。
|
|
@@ -119,6 +122,10 @@ Menu Protocol 是 EvolCore 在 AUN `message.send` 之上建立的**应用层协
|
|
|
119
122
|
}
|
|
120
123
|
```
|
|
121
124
|
|
|
125
|
+
`/model` 与 `/effort` 的更新只写当前 Agent 的 Agent 级配置(`baseagents.<baseagent>.model` / `effort`),
|
|
126
|
+
只有当前 Agent 的 owner / admin 可以执行;`args.scope` 被忽略,没有关系级模型。关系菜单不再提供模型与推理强度项,
|
|
127
|
+
对应设置项为 Agent 菜单的 `model.agent` / `effort.agent`。查询返回 Agent 级配置经角色约束后的值;Agent 级未配置时 `model` 为 `null`。
|
|
128
|
+
|
|
122
129
|
`name="session"` 且 `args.resource="loop"` 时,`value` 必须是 JSON boolean:
|
|
123
130
|
`true` 开启当前可信主话题或话题的一次闲置触发,`false` 关闭;开启时可在
|
|
124
131
|
`args.idleSeconds` 指定 30–86400 的整数,省略时使用 300 秒。目标由当前关系和可信
|
|
@@ -166,6 +173,35 @@ Menu Protocol 是 EvolCore 在 AUN `message.send` 之上建立的**应用层协
|
|
|
166
173
|
| `cli` | `exec` | — | 执行任意 `ec` CLI 命令(`args.argv` 是完整 argv 数组) |
|
|
167
174
|
| `file` | `search` | `file.search` | 当前项目内递归搜索文件,仅目标 Agent AID 入口 |
|
|
168
175
|
|
|
176
|
+
### Agent 初始化
|
|
177
|
+
|
|
178
|
+
主机 Agent 初始化通过 `menu.action`、`name="agent"`、`action="initialize"` 调用。参数可平铺在
|
|
179
|
+
`args` 中,也可放入 `args.plan`;`aid` 必须与计划中的 AID 一致。`project` 可省略或为空,Core 会按普通
|
|
180
|
+
Agent 创建规则解析主机默认项目;显式项目路径优先。可选的 `model` 必须存在于主机当前 baseagent 的可见模型
|
|
181
|
+
目录;指定非 `auto` 的 `effort` 时必须同时指定 `model`,且强度必须在当前模型目录支持的范围内。
|
|
182
|
+
`effort="auto"` 不写入强度覆盖。远程调用沿用现有控制面权限校验。
|
|
183
|
+
|
|
184
|
+
失败后用同一 action 和 `{ aid, resume: true }` 恢复已保存计划。恢复不接受新计划字段,只使用原操作主体、AID
|
|
185
|
+
和持久化计划;其他主体无法接管。
|
|
186
|
+
|
|
187
|
+
相同请求重复调用只返回原操作状态,不自动恢复;省略项目路径时会复用原计划路径,避免生成另一个目录。
|
|
188
|
+
计划变化返回 `INITIALIZE_PLAN_CONFLICT`,恢复主体不匹配返回 `INITIALIZE_OWNER_MISMATCH`;模型不可见或
|
|
189
|
+
effort 不受支持返回 `INVALID_ARGUMENT`,目录查询或网关鉴权失败返回 `MODEL_UNAVAILABLE`。
|
|
190
|
+
|
|
191
|
+
初始化状态通过 `menu.query`、`name="agent"`、`args.aid` 查询。响应包含:
|
|
192
|
+
|
|
193
|
+
- `initialization.status`、`initialization.phase`、`initialization.complete`、`initialization.code`、`initialization.error`
|
|
194
|
+
- 顶层 `lifecycle`
|
|
195
|
+
- 顶层 `usable`,表示已完成、active 且当前运行时可用;它独立于生命周期,断开连接时可为 `false`
|
|
196
|
+
|
|
197
|
+
`initialization.status` 为 `in_progress` / `failed` / `complete` / `cancelled`;没有错误时 `code` 和 `error`
|
|
198
|
+
固定为 `null`。初始化记录损坏时仍返回 `status="failed"`、`phase="unknown"`、
|
|
199
|
+
`code="INITIALIZE_STATE_INVALID"`、`complete=false` 和 `retryable=false`。
|
|
200
|
+
|
|
201
|
+
客户端只在 `initialization.complete == true` 且 `lifecycle == "active"` 时认定初始化成功。`usable` 用于显示当前
|
|
202
|
+
运行可用性,不改变初始化完成判定。主机 process Menu Catalog 通过 `menu.list` 的 `view="catalog"` 和
|
|
203
|
+
`context.kind="process"` 返回 `agent.initialize` action 声明,供客户端发现入口;实际调用仍使用 `menu.action`。
|
|
204
|
+
|
|
169
205
|
### 项目文件搜索:`file/search`
|
|
170
206
|
|
|
171
207
|
搜索请求必须发送到当前目标 Agent AID,不支持 Host/control 或 `rootId` 数据根。项目由当前可信话题会话解析,
|
|
@@ -1,54 +1,57 @@
|
|
|
1
1
|
# ec model - 模型管理命令集
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
查看或设置 agent 使用的模型与推理强度。模型参数只在 Agent 级配置:`agents/<aid>/config.json` 的 `baseagents.<baseagent>.model` / `effort`。关系级配置和 `agents/defaults.json` 都不承载模型参数;Agent 级未设置模型时,该 Agent 没有模型可用,收到消息会回复“未配置模型”提示,不回落任何默认模型。
|
|
4
|
+
|
|
5
|
+
`ec model` 修改 Agent 级持久化配置,对该 Agent 所有会话的下一条消息生效。
|
|
4
6
|
|
|
5
7
|
## 命令
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
#
|
|
10
|
+
# 列出可用模型并显示当前 Agent 级模型
|
|
9
11
|
ec model list [--self <aid>] [--peer <peer>] [--role <role>]
|
|
10
12
|
|
|
11
|
-
#
|
|
13
|
+
# 显示 Agent 级模型(经角色约束)、推理强度和配置来源
|
|
12
14
|
ec model current [--self <aid>] [--peer <peer>] [--role <role>]
|
|
13
15
|
|
|
14
16
|
# 查看单个模型详情
|
|
15
17
|
ec model info <model-id> [--self <aid>]
|
|
16
18
|
|
|
17
|
-
#
|
|
18
|
-
ec model use <model-id> --self <aid> [--
|
|
19
|
+
# 设置 Agent 级模型,可同时设置推理强度
|
|
20
|
+
ec model use <model-id> --self <aid> [--effort <level>]
|
|
19
21
|
|
|
20
|
-
#
|
|
21
|
-
ec model effort <level> --self <aid>
|
|
22
|
+
# 设置 Agent 级推理强度:low | medium | high | xhigh | max | auto
|
|
23
|
+
ec model effort <level> --self <aid>
|
|
22
24
|
|
|
23
|
-
#
|
|
24
|
-
ec model reset --self <aid>
|
|
25
|
+
# 清除 Agent 级模型和推理强度;清除后该 Agent 无模型可用
|
|
26
|
+
ec model reset --self <aid>
|
|
25
27
|
|
|
26
|
-
#
|
|
28
|
+
# 诊断网关连通性、模型目录和 Agent 级模型可用性
|
|
27
29
|
ec model check [--self <aid>]
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
## 作用域
|
|
31
33
|
|
|
32
|
-
| 参数 |
|
|
33
|
-
|
|
34
|
-
| 无 | 只读 catalog
|
|
35
|
-
| `--self <aid>` |
|
|
36
|
-
| `--self <aid> --role <role>` |
|
|
37
|
-
| `--self <aid> --peer <peer>` |
|
|
34
|
+
| 参数 | 用途 | 配置位置 |
|
|
35
|
+
|------|------|----------|
|
|
36
|
+
| 无 | 只读 catalog | 不允许写入 |
|
|
37
|
+
| `--self <aid>` | Agent 级读写 | `agents/<aid>/config.json` |
|
|
38
|
+
| `--self <aid> --role <role>` | 按角色策略预览有效模型 | 只读;角色策略由角色策略编辑器管理 |
|
|
39
|
+
| `--self <aid> --peer <peer>` | 按该对端的关系角色预览有效模型 | 只读;`use` / `effort` / `reset` 带 `--peer` 直接拒绝(`MODEL_AGENT_ONLY`) |
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
角色策略只约束 Agent 级模型(模型白名单、固定模型),不提供模型:Agent 级未设置模型时,角色策略不会补出一个模型。`--peer` 使用 `channelType#channelId`;裸 AID 按 `aun#<aid>` 处理。
|
|
40
42
|
|
|
41
|
-
在 EvolCore 托管会话中,所有 `ec model` 子命令都通过 daemon 的 `ec ctl` 路径作用于已认证的当前会话,不能指定 `--self`、`--peer` 或 `--role
|
|
43
|
+
在 EvolCore 托管会话中,所有 `ec model` 子命令都通过 daemon 的 `ec ctl` 路径作用于已认证的当前会话,不能指定 `--self`、`--peer` 或 `--role`;上表的显式参数只用于宿主终端。需要读取或修改持久化模型配置时,使用 `ec config`,由 daemon 按实际角色和目标范围鉴权。本机终端不具备隐式当前会话语义。
|
|
42
44
|
|
|
43
45
|
帮助查询不选择目标或执行操作,`ec model list --self <aid> --help` 等形式仍可查看帮助。
|
|
44
46
|
|
|
45
47
|
## 输出与权限
|
|
46
48
|
|
|
47
49
|
- 所有子命令支持 `--format json`。
|
|
48
|
-
-
|
|
50
|
+
- 从聊天菜单、slash 命令或 agent 工具调用时,命令会在执行前经过 operation 鉴权。
|
|
51
|
+
- `use`、`effort`、`reset` 只能写 Agent 级,且只有当前 Agent 的 owner / admin(或 DaemonOwner)可以执行;这是代码级上限,角色文件授予 `model.*` 也不能让其他角色写入。member、visitor 只能查看。
|
|
49
52
|
- 本地终端直接运行时不伪造远端角色。显式传入 `--role` 可检查该角色的模型可见性和有效模型。
|
|
50
53
|
- `use`、`effort`、`reset` 不直接修改角色策略;传入 role 写作用域会返回 `ROLE_POLICY_MANAGED`。
|
|
51
|
-
- `check` 会连接已配置的模型网关并发送最小探测请求;未配置自定义网关时跳过 API 探测。
|
|
54
|
+
- `check` 会连接已配置的模型网关并发送最小探测请求;未配置自定义网关时跳过 API 探测。Agent 级未配置模型时,“配置模型”一步标记为失败。
|
|
52
55
|
|
|
53
56
|
## 模型参数与执行窗口
|
|
54
57
|
|
|
@@ -37,6 +37,9 @@ ec msg send <from> <to> --link <url> [--title '<title>'] [--description '<desc>'
|
|
|
37
37
|
# 自定义 payload(JSON)
|
|
38
38
|
ec msg send <from> <to> --payload '<json>'
|
|
39
39
|
|
|
40
|
+
# 从 UTF-8 文件读取自定义 payload(避免 Windows Shell 破坏 JSON 引号)
|
|
41
|
+
ec msg send <from> <to> --payload-file <path>
|
|
42
|
+
|
|
40
43
|
# 发送自定义 payload 并等待关联结果
|
|
41
44
|
ec msg send <from> <to> --payload '<json>' --return required --timeout 60s --format json
|
|
42
45
|
|
|
@@ -44,7 +47,8 @@ ec msg send <from> <to> --payload '<json>' --return required --timeout 60s --for
|
|
|
44
47
|
ec msg send <from> <to> --payload '<json>' --return none
|
|
45
48
|
```
|
|
46
49
|
|
|
47
|
-
`--payload` 优先按 JSON 对象解析;为兼容 Windows 命令包装器,也接受“一层 JSON 字符串包裹 JSON
|
|
50
|
+
`--payload` 优先按 JSON 对象解析;为兼容 Windows 命令包装器,也接受“一层 JSON 字符串包裹 JSON 对象”的形式。`--payload-file` 按 UTF-8 读取文件并执行同样的 JSON 对象校验;两个选项互斥。该选项用于私聊 `msg send`,不能同时提供位置文本。
|
|
51
|
+
Windows 或包含复杂 JSON 时优先使用 `--payload-file`。临时文件先通过文件工具写入当前会话的 `$TMPDIR`,内容保持原始 JSON,不添加 Shell 转义;发送命令单独执行。托管发送由 daemon 授权后读取文件,校验项目/当前会话临时目录边界和设备路由。PowerShell 路径使用 `"$env:TMPDIR/obs_payload.json"`,Git Bash 使用 `"$TMPDIR/obs_payload.json"`;路径变量不用于 `--payload` 正文。
|
|
48
52
|
最多额外解包一层,最终值必须是 JSON 对象;数组、普通字符串、数字、布尔值和 `null` 均会被拒绝。
|
|
49
53
|
在当前 Windows PowerShell 托管环境中,调用 `ec.cmd` 时使用单引号包裹 JSON,并在 JSON 内每个
|
|
50
54
|
双引号前加一个反斜杠,例如 `--payload '{\"type\":\"query\"}'`。反斜杠只用于命令行参数传递,
|
|
@@ -63,25 +67,28 @@ ec msg send <from> <to> --payload '<json>' --return none
|
|
|
63
67
|
- `--transcript <text>` — 语音转写(仅 `--as voice`)
|
|
64
68
|
- `--return none|required` — 是否建立通用请求/响应关联;`required` 会等待结果,默认不要求结果
|
|
65
69
|
- `--timeout <duration>` — `--return required` 的本地等待时间及 AUN volatile TTL,如 `30s`、`60s`、`2m`;未指定时默认 60 秒,最大 3600 秒
|
|
70
|
+
- `--device-id <id>` — 将私聊消息定向到指定 Provider 设备;业务 Ability `role=call` 必须使用从该 Provider 能力索引或 `protocol/discover` 结果中取得的设备 ID
|
|
66
71
|
- `--format json` — 输出结构化发送回执和响应
|
|
67
72
|
|
|
73
|
+
业务 Ability 调用必须指定能力发布设备,避免 Provider 的多台登录设备同时处理同一调用。设备 ID 是
|
|
74
|
+
`message.send` 的传输路由参数,不属于 Ability payload;不要猜测它,也不要把它写入 JSON。
|
|
75
|
+
`protocol/discover` 用于发现设备,可以不带 `--device-id`;之后从匹配能力的 `devices` 字段中选择目标设备。
|
|
76
|
+
缺少目标设备的业务调用会以 `ABILITY_DEVICE_REQUIRED` 在发送前失败。`--device-id` 只适用于私聊发送。
|
|
77
|
+
|
|
68
78
|
未指定 `--content-type` 时,附件 MIME 由 SDK 按实际字节识别、后缀回退,附件描述沿用上传后的类型。
|
|
69
79
|
`--as` 控制消息展示类型,与 MIME 独立。
|
|
70
80
|
|
|
71
81
|
托管会话中的附件源文件必须位于当前项目目录或当前会话 `$TMPDIR` 内;符号链接、硬链接、路径穿越和受保护路径会被拒绝。
|
|
72
82
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
ec contact add <target-aid> --self <self-aid>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
该命令在托管会话中会创建/更新联系人申请并给 Owner 发送审核卡片;`blocked` 目标必须先执行:
|
|
83
|
+
托管会话主动执行 `ec msg send` 时,系统会先校验目标关系权限,再将无条目、`pending` 或
|
|
84
|
+
`declined` 的私聊目标加入本 Agent 联系人簿并设为 `active`,然后继续发送。`blocked` 目标仍会拒绝发送,必须先执行:
|
|
80
85
|
|
|
81
86
|
```bash
|
|
82
87
|
ec contact unblock <target-aid> --self <self-aid>
|
|
83
88
|
```
|
|
84
89
|
|
|
90
|
+
`ec group send` 走群关系权限,不使用私聊联系人准入;群 AID 不写入 Contact Book。
|
|
91
|
+
|
|
85
92
|
非托管环境的 `ec msg send` 是独立 AUN CLI 发送,不读取或要求 `agents/<aid>/config.json`,因此不会触发这套 Agent 联系人准入判断。
|
|
86
93
|
|
|
87
94
|
在 EvolCore 会话内,发送会经过当前 session 的 self/peer/role 鉴权。`visitor` 或 `member` 默认只允许回复当前对端;要联系当前对端以外的对象,必须通过话题路由:先 `ec thread list <对方AID>` 选话题(没有就 `ec thread create`),再用 `ec msg send '<text>' --thread <threadId> --check-every <时长>` 发送;from/to 由话题推断,无需手写。不带 `--thread` 直接改目标会被拒绝。`--check-every` 到期后,系统会向**目标话题**投递一条【跨话题复查】通知(不新建会话),由目标话题侧的 agent 在自己的上下文里决定结束、调整周期或继续。完整话题路由操作序列见 `[thread]` 段。没有成功 JSON 回执(含 `message_id`/`status`)不得声称已发送。
|
|
@@ -119,6 +126,12 @@ Ability payload 已有 `call_id` 时,EvolCore 使用它作为通用 transport
|
|
|
119
126
|
ec msg request get <self-aid> <request-id> --format json
|
|
120
127
|
```
|
|
121
128
|
|
|
129
|
+
发送结果的 `request_diagnostics` 给出目标设备、传输状态、是否收到业务 ACK 和未完成原因。查询记录中对应字段为 `targetDeviceId`、`responseDeviceId`、`ackMessageId`、`lastIgnoredResponse`、`ignoredResponseCount`(尚未发生的事件字段可以缺省)。`response_device_mismatch` 表示回包来自其他设备;`response_device_id_missing` 表示回包缺少认证设备来源,均不会被当成目标设备的执行结果。`provider_ack_without_final_result` 表示仅收到业务受理 ACK,`no_final_response_before_deadline` 表示等待窗口内没有最终回包;后者不能单独证明设备离线或确认窗未弹出。
|
|
130
|
+
|
|
131
|
+
`--return required` 在 daemon 内通过入站事件唤醒等待,不需要同时反复执行 `request get`。超时后先查一次诊断;确需继续只读跟进时逐步拉长查询间隔(例如 5、15、30、60 秒),设置次数上限,信息不变则停止本轮查询并报告未确认状态。不要以重发申请代替状态查询。
|
|
132
|
+
|
|
133
|
+
`ec_command_not_canonical` 是命令执行前的审批解析拒绝。保持一次工具调用内只有一条完整的 `ec` 命令,避免命令替换、管道或与文件写入拼接;复杂 JSON 改走 `--payload-file`。不要因此修改身份或绕过托管授权。
|
|
134
|
+
|
|
122
135
|
查询必须由原始托管会话提供有效的 sessionId 和 delegationToken,且本端、关系、来源话题与请求登记上下文一致;跨话题目标仍须通过既有目标授权。知道 request ID 不代表有权查询,独立终端及缺少来源授权的旧记录不返回请求详情。查询是只读操作,不会重新发送消息,可以稍后重复查询。`--return none` 不建立请求记录,
|
|
123
136
|
不能使用此命令查询其结果。发送命令在顶层返回 `request_id` / `request_state` / `response`;
|
|
124
137
|
查询命令返回 `{ ok, request }`,状态和响应分别位于 `request.state` / `request.responsePayload`。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# ec session
|
|
2
|
+
|
|
3
|
+
`ec session` 查询本机 EC 会话快照与底层会话恢复胶囊。托管任务通过当前任务凭据限制到本 Agent;owner/admin 可查看该 Agent,会话角色只能查看当前关系。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
ec session find <sessionId>
|
|
7
|
+
ec session source <sessionId>
|
|
8
|
+
ec session capsule list <sessionId>
|
|
9
|
+
ec session capsule show <capsuleId>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`source` 返回直接来源 EC Session ID;根会话没有来源。`capsule list` 查看 `session-renew`、`topic-renew`、`backend-recovery` 的生命周期与底层 ID,`show` 额外输出交接摘要正文。胶囊状态由 `created`、`bound`、`consumed` 追加记录推导,不维护独立状态字段。
|
|
13
|
+
|
|
14
|
+
上述命令支持 `--format json`。`messages.jsonl` 里首条被新 backend 接收的普通输入包含 `capsuleId`,可用它查询对应摘要;`/renew` 命令本身不关联该胶囊。
|
|
@@ -3,9 +3,13 @@ import os from 'os';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
6
7
|
import Ajv from 'ajv';
|
|
7
8
|
|
|
8
9
|
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const requireCore = createRequire(import.meta.url);
|
|
11
|
+
// Use the same pure policy as the daemon. Published packages always include dist.
|
|
12
|
+
const { resolveAunTargetKind, verifiedPeerType } = requireCore('../../dist/aun/group/identity.js');
|
|
9
13
|
const SCHEMA_DIR = path.resolve(SCRIPT_DIR, '..', 'schemas');
|
|
10
14
|
const AGENT_LOCK_NAME = '.contact-book-mutation.lock';
|
|
11
15
|
const RECEIPT_NAME = 'contact-book-v2-relation-role-authority.json';
|
|
@@ -44,14 +48,6 @@ function isValidAid(name) {
|
|
|
44
48
|
return labels.length >= 3 && labels.every(label => /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(label));
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
function isExplicitGroupId(value) {
|
|
48
|
-
const id = String(value || '').trim();
|
|
49
|
-
return (id.startsWith('group.') && id.includes('/'))
|
|
50
|
-
|| /^\d+\.[a-z0-9.-]+$/i.test(id)
|
|
51
|
-
|| /^grp_[a-z0-9_-]+$/i.test(id)
|
|
52
|
-
|| /^g-[a-z0-9_-]+(?:[.@][a-z0-9.-]+)?$/i.test(id);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
function readJson(file) {
|
|
56
52
|
const text = fs.readFileSync(file, 'utf8');
|
|
57
53
|
return { value: JSON.parse(text), text };
|
|
@@ -395,18 +391,37 @@ function planAgentMigration(home, aid, validators, changes, summary, backupRoles
|
|
|
395
391
|
if (!isRecord(rawContacts)) throw new Error(`${contactFile}: contacts must be an object`);
|
|
396
392
|
const contacts = {};
|
|
397
393
|
const aliasOwners = new Map();
|
|
394
|
+
const resolvePeerKind = (peerAid, subjectType) => {
|
|
395
|
+
const peerKey = canonicalPeerKey('aun', peerAid);
|
|
396
|
+
const identityFile = path.join(relationsDir, peerKey, 'peer-identity.json');
|
|
397
|
+
const identity = fs.existsSync(identityFile) ? readJson(identityFile).value : undefined;
|
|
398
|
+
return resolveAunTargetKind({
|
|
399
|
+
targetKind: relations.get(peerKey)?.value.targetKind,
|
|
400
|
+
routeKind: subjectType === 'group' ? 'group' : subjectType === 'principal' ? 'private' : undefined,
|
|
401
|
+
verifiedType: verifiedPeerType(peerAid, identity),
|
|
402
|
+
});
|
|
403
|
+
};
|
|
398
404
|
|
|
399
405
|
for (const [primaryId, rawEntry] of Object.entries(rawContacts)) {
|
|
400
406
|
if (!isValidAid(primaryId)) throw new Error(`${contactFile}: invalid contact primary AID ${JSON.stringify(primaryId)}`);
|
|
401
407
|
if (!isRecord(rawEntry)) throw new Error(`${contactFile}: contact ${primaryId} must be an object`);
|
|
402
408
|
const unknown = Object.keys(rawEntry).filter(key => !CONTACT_KEYS.has(key));
|
|
403
409
|
if (unknown.length) throw new Error(`${contactFile}: contact ${primaryId} has unsupported fields ${unknown.join(', ')}`);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
throw new Error(`${contactFile}: contact ${primaryId} has invalid subjectType ${JSON.stringify(subjectType)}`);
|
|
410
|
+
if (rawEntry.subjectType !== undefined && rawEntry.subjectType !== 'principal' && rawEntry.subjectType !== 'group') {
|
|
411
|
+
throw new Error(`${contactFile}: contact ${primaryId} has invalid subjectType ${JSON.stringify(rawEntry.subjectType)}`);
|
|
407
412
|
}
|
|
413
|
+
const kind = resolvePeerKind(primaryId, rawEntry.subjectType);
|
|
414
|
+
if (kind.reason !== 'missing' && kind.kind === 'unknown') {
|
|
415
|
+
throw new Error(`${contactFile}: contact ${primaryId} type is unknown (${kind.reason}); explicit type evidence is required`);
|
|
416
|
+
}
|
|
417
|
+
if (kind.kind === 'unknown' && rawEntry.role !== undefined) {
|
|
418
|
+
throw new Error(`${contactFile}: contact ${primaryId} has a role but its type is unknown; explicit type evidence is required`);
|
|
419
|
+
}
|
|
420
|
+
const subjectType = kind.kind === 'group' ? 'group' : kind.kind === 'private' ? 'principal' : undefined;
|
|
421
|
+
if (kind.kind === 'private') ensureRelation('aun', primaryId, 'private');
|
|
408
422
|
const contactRole = roleValue(rawEntry.role, roleIds, contactFile, `contact ${primaryId} role`);
|
|
409
423
|
if (contactRole) {
|
|
424
|
+
if (!subjectType) throw new Error(`${contactFile}: contact ${primaryId} role has no type evidence`);
|
|
410
425
|
const targetKind = subjectType === 'group' ? 'group' : 'private';
|
|
411
426
|
const relation = ensureRelation('aun', primaryId, targetKind);
|
|
412
427
|
if (relation.value.role === undefined) {
|
|
@@ -467,6 +482,10 @@ function planAgentMigration(home, aid, validators, changes, summary, backupRoles
|
|
|
467
482
|
const admin = String(rawAdmin || '').trim();
|
|
468
483
|
if (!isValidAid(admin)) throw new Error(`${agentFile}: invalid admin AID ${JSON.stringify(rawAdmin)}`);
|
|
469
484
|
if (owners.has(admin)) continue;
|
|
485
|
+
const kind = resolvePeerKind(admin);
|
|
486
|
+
if (kind.kind !== 'private') {
|
|
487
|
+
throw new Error(`${agentFile}: admin ${admin} requires private type evidence (${kind.reason}); roles do not establish peer type`);
|
|
488
|
+
}
|
|
470
489
|
const relation = ensureRelation('aun', admin, 'private');
|
|
471
490
|
if (relation.value.role !== 'admin') summary.adminsMigrated += 1;
|
|
472
491
|
relation.value.role = 'admin';
|
package/kits/schemas/_meta.json
CHANGED
|
@@ -4,16 +4,31 @@
|
|
|
4
4
|
"currentVersion": 1
|
|
5
5
|
},
|
|
6
6
|
"daemon": {
|
|
7
|
-
"currentVersion":
|
|
7
|
+
"currentVersion": 9
|
|
8
8
|
},
|
|
9
9
|
"defaults": {
|
|
10
|
-
"currentVersion": 5
|
|
10
|
+
"currentVersion": 5,
|
|
11
|
+
"history": []
|
|
11
12
|
},
|
|
12
13
|
"agent-config": {
|
|
13
|
-
"currentVersion":
|
|
14
|
+
"currentVersion": 16,
|
|
15
|
+
"history": [
|
|
16
|
+
{
|
|
17
|
+
"version": 16,
|
|
18
|
+
"date": "2026-10-27",
|
|
19
|
+
"description": "合并 v15 模型与 Provider 配置调整,并增加 Owner 通讯录和 Owner Agent 名录的入站联系开关;旧配置直接迁移到 v16"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
14
22
|
},
|
|
15
23
|
"relation-config": {
|
|
16
|
-
"currentVersion":
|
|
24
|
+
"currentVersion": 11,
|
|
25
|
+
"history": [
|
|
26
|
+
{
|
|
27
|
+
"version": 11,
|
|
28
|
+
"date": "2026-10-27",
|
|
29
|
+
"description": "删除 baseagents/active_baseagent/model/models;关系级不承载模型参数;新增 sessionFullAccess,跨 EC session 保留主会话 /fa 开关"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
17
32
|
},
|
|
18
33
|
"contact-book": {
|
|
19
34
|
"currentVersion": 3
|
|
@@ -29,12 +44,24 @@
|
|
|
29
44
|
}
|
|
30
45
|
},
|
|
31
46
|
"history": [
|
|
47
|
+
{
|
|
48
|
+
"schema": "agent-config",
|
|
49
|
+
"version": 16,
|
|
50
|
+
"date": "2026-10-27",
|
|
51
|
+
"description": "合并 v15 模型与 Provider 配置调整,增加 Owner 名录入站联系开关;旧配置直接迁移到 v16,保留既有 access 配置"
|
|
52
|
+
},
|
|
32
53
|
{
|
|
33
54
|
"schema": "providers",
|
|
34
55
|
"version": 1,
|
|
35
56
|
"date": "2026-10-20",
|
|
36
57
|
"description": "global providers managed by ConfigManager"
|
|
37
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"schema": "daemon",
|
|
61
|
+
"version": 9,
|
|
62
|
+
"date": "2026-10-29",
|
|
63
|
+
"description": "add managed service runtime and health monitoring configuration for ServiceProxy"
|
|
64
|
+
},
|
|
38
65
|
{
|
|
39
66
|
"schema": "daemon",
|
|
40
67
|
"version": 8,
|
|
@@ -298,6 +325,12 @@
|
|
|
298
325
|
"version": 10,
|
|
299
326
|
"date": "2026-10-03",
|
|
300
327
|
"description": "[已撤销] add relation-level memory.verifySignature gate (AND-merged with agent level)"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"schema": "relation-config",
|
|
331
|
+
"version": 11,
|
|
332
|
+
"date": "2026-10-27",
|
|
333
|
+
"description": "remove relation-level model parameters (baseagents/active_baseagent/model/models); models are Agent-level only; persist main-session fullaccess controls independently of EC session replacement"
|
|
301
334
|
}
|
|
302
335
|
]
|
|
303
336
|
}
|
|
@@ -147,6 +147,21 @@
|
|
|
147
147
|
],
|
|
148
148
|
"description": "私聊和群聊准入策略:开放、仅联系人或仅 Owner。"
|
|
149
149
|
},
|
|
150
|
+
"allowExternalContacts": {
|
|
151
|
+
"type": "boolean",
|
|
152
|
+
"default": true,
|
|
153
|
+
"description": "是否允许非 Owner 按 policyMode 联系 Agent;关闭时仅 Owner 和 allowedAids 可进入普通会话。仅 Owner 可修改。"
|
|
154
|
+
},
|
|
155
|
+
"allowedAids": {
|
|
156
|
+
"type": "array",
|
|
157
|
+
"items": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?){2,}$"
|
|
160
|
+
},
|
|
161
|
+
"uniqueItems": true,
|
|
162
|
+
"default": [],
|
|
163
|
+
"description": "仅 Owner 可维护的指定 AID 准入名单;可绕过非 Owner 开关和 policyMode,但不绕过私聊黑名单,不授予角色权限。"
|
|
164
|
+
},
|
|
150
165
|
"requestLimit": {
|
|
151
166
|
"type": "object",
|
|
152
167
|
"additionalProperties": false,
|
|
@@ -603,11 +618,16 @@
|
|
|
603
618
|
},
|
|
604
619
|
"idleHours": {
|
|
605
620
|
"type": "number",
|
|
606
|
-
"description": "
|
|
621
|
+
"description": "关系空闲时长(小时):一个关系最后一次活动(入站、写 note)后这么久没有新活动,触发该关系的整理链,只跑候选攒够 minBatchItems 的步骤。默认 1。"
|
|
607
622
|
},
|
|
608
623
|
"maxUnconsolidatedHours": {
|
|
609
624
|
"type": "number",
|
|
610
|
-
"description": "
|
|
625
|
+
"description": "关系兜底整理时长(小时):一个关系最早一次未整理的活动满这么久,即使仍在聊也触发整理链,有 1 条候选就跑。默认 8。"
|
|
626
|
+
},
|
|
627
|
+
"minBatchItems": {
|
|
628
|
+
"type": "number",
|
|
629
|
+
"minimum": 1,
|
|
630
|
+
"description": "空闲到期时一步至少攒够多少条候选才跑(note 条数 / to-generalize 条数 / to-promote 条数),不够的留给兜底。默认 3。"
|
|
611
631
|
},
|
|
612
632
|
"checkIntervalHours": {
|
|
613
633
|
"type": "number",
|
|
@@ -615,7 +635,7 @@
|
|
|
615
635
|
},
|
|
616
636
|
"backlogHours": {
|
|
617
637
|
"type": "number",
|
|
618
|
-
"description": "pending
|
|
638
|
+
"description": "已废弃,不再生效(pending 由关系空闲 / 兜底计时覆盖)。保留只为旧配置文件仍能通过校验。"
|
|
619
639
|
},
|
|
620
640
|
"indexMaxBytes": {
|
|
621
641
|
"type": "number",
|