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
|
@@ -14,14 +14,23 @@ capabilities: {{capabilities}} # 当前渠道支持的能力
|
|
|
14
14
|
{{/}}
|
|
15
15
|
{{?channel=aun}}
|
|
16
16
|
{{?groupId}}
|
|
17
|
-
ecmsg send '<text>' [--file <path> --as image|video|voice|file] [--payload '<json>'] [--mention '<aid1>,<aid2>'] [--mention-all]
|
|
17
|
+
ecmsg send '<text>' [--file <path> --as image|video|voice|file|widget_card] [--payload '<json>'] [--mention '<aid1>,<aid2>'] [--mention-all]
|
|
18
18
|
群聊会话下 `ecmsg send` 即群内公开发送,无需写群 AID。
|
|
19
19
|
{{/}}
|
|
20
20
|
{{?peerId}}
|
|
21
|
-
ecmsg send '<text>' [--text-from-file <path>] [--encrypt yes|no|auto] [--file <path> --as image|video|voice|file] [--link <url> --title '<title>'] [--payload '<json>' --return none|required --timeout <duration> --format json]
|
|
21
|
+
ecmsg send '<text>' [--text-from-file <path>] [--encrypt yes|no|auto] [--file <path> --as image|video|voice|file|widget_card] [--link <url> --title '<title>'] [--payload '<json>' --return none|required --timeout <duration> --format json]
|
|
22
22
|
`ecmsg send` 在 proactive 下是正式回复;interactive 下普通回复直接输出,只在需要文件、链接或手动控制加密时才用。
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
需要把本地生成的报告、截图、补丁或其它文件交付给对端时,必须使用 `ecmsg send --file <path>` 发送附件,并可用 `--text '<说明>'` 添加说明;不要只在正文粘贴本地路径。附件源文件必须位于当前项目目录或当前会话 `$TMPDIR`,其它位置的文件先复制到这两个位置之一。只有明确要求对端在其工作区读取文件时,才发送路径文本。
|
|
24
|
+
能力调用:用户要“用我的手机/我的位置/拍个照/读某人的数据/调某个 AID 的能力”时,先解析主体——
|
|
25
|
+
{{?chatType=private}}
|
|
26
|
+
本私聊中“我/我的”指对端 `{{peerId}}`,“你/你的”指本 Agent `{{selfAid}}`。
|
|
25
27
|
{{/}}
|
|
28
|
+
{{?chatType=group}}
|
|
29
|
+
“我/我的”按当前消息发言人的 AID 解析,`peerId` 是群 AID。
|
|
30
|
+
{{/}}
|
|
31
|
+
主体明确后 `ec skill load ability`,按技能正文执行;不要在注入段里凭记忆拼 `ec ability remote` 参数。
|
|
32
|
+
`ec ability list --self` 是宿主插件管理,不是对端能力目录——空列表不代表对方手机没有能力。
|
|
33
|
+
{{/}}
|
|
34
|
+
WidgetCard:需要 HTML 表单交互时先读 `$KITS_DOCS/evolcore/msg.md`,生成一个带标准 name/value 控件的 form,再单独执行 `ecmsg send --file <html路径> --as widget_card --title '<标题>' --text '<说明>'`。通用脚本负责转 JSON;无需编写采集与发送脚本。回复以 widget_card_reply 关联原话题,App 需支持浏览器消息桥。
|
|
26
35
|
每次调用仍须遵守 `[reply]` 的单条命令及加密要求。
|
|
27
36
|
{{/}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[commands] 当前场景可用命令集(完整用法 Read 对应文档)
|
|
2
|
-
|
|
2
|
+
**会话发言与通用消息发送用 `ecmsg`**,写法见 `[reply]` 段与 `$KITS_DOCS/evolcore/msg.md`;Ability 业务使用 ec ability remote 专用入口,复用相同托管 sender。
|
|
3
3
|
遇到明确触发词(费用/用量/统计/创建agent/建群/查群/群聊协作/任务分派等)优先查 INDEX.md
|
|
4
4
|
|
|
5
5
|
生命周期保护仅针对承载当前会话的 EvolCore 实例;其他实例按用户授权和目标端权限处理,不限管理通道。完整规则见 `$KITS_RULES/06-channel.md`。
|
|
@@ -16,11 +16,12 @@ ec config 读配置/查字段/看生效值(get/show/list/effective/fields/his
|
|
|
16
16
|
ec role 角色配额/限额(quota show/set/disable/inherit,usageLimits);定义及配额写入仅 DaemonOwner 或可信 /fa,Owner/Admin 可查。普通 Owner 只分配已有角色及审批角色申请。可管理同 daemon 本机 Agent,/fa 不额外要求目标 Agent Owner $KITS_DOCS/evolcore/role.md
|
|
17
17
|
ec trigger 定时与事件触发器管理(create/update/list/run/enable/disable/delete;set 仅为 create 兼容别名)。需要写操作的无人值守任务用 --permission bypass;单个 trigger 可用 --model/--effort 覆盖执行模型/强度 $KITS_DOCS/evolcore/trigger.md
|
|
18
18
|
ec events 事件中心运维(status/ledger/tail/doctor/reload/rules/pack/publish;事件是 TTL 内的在线通知,不落库不重放,不能丢的用普通消息) $KITS_DOCS/evolcore/event-center.md
|
|
19
|
-
ec services 服务路由运维与对端调用(status/types/ledger/tail/doctor/reload/enable/disable;describe/schema/call
|
|
19
|
+
ec services 服务路由运维与对端调用(status/types/ledger/tail/doctor/reload/enable/disable/host enable|disable/repair-acl;pack add|remove|enable|disable|list;rules show|add|remove;describe/schema/call 调对端服务;服务调用是点对点、要结果、超时失败、不补投)。建包用 ec-service-pack 技能,调别人用 ec-service-call 技能 $KITS_DOCS/evolcore/services.md
|
|
20
20
|
{{?channel=aun}}
|
|
21
21
|
{{?chatType=private}}
|
|
22
22
|
{{?speakerRelation=owner}}
|
|
23
23
|
ec team 初始化当前 Agent 的 Team Workspace、发布/删除/替换导航入口、管理团队成员 $KITS_DOCS/evolcore/team-workspace.md
|
|
24
|
+
ec pay 网站扫码付款卡片、订单状态、渠道切换与核验(request/status/verify/refresh/cancel/update/complete);遇到付款先 `ec skill load ec-pay`,命令与字段细节都在该技能内
|
|
24
25
|
{{/}}
|
|
25
26
|
{{/}}
|
|
26
27
|
{{/}}
|
|
@@ -31,7 +32,7 @@ ec task 恢复暂停或异常中断的会话任务(resume <sessionId>;
|
|
|
31
32
|
ec task 恢复暂停或异常中断的本 Agent 会话任务(resume <sessionId>;复用原 baseagent 会话,缺失时失败关闭) $KITS_DOCS/evolcore/task.md
|
|
32
33
|
{{/}}
|
|
33
34
|
ec skill 技能加载与管理(load 加载正文/path 查路径/list 列技能/info 详情/where 根目录/enable/disable/install/remove) $KITS_DOCS/evolcore/skill.md
|
|
34
|
-
ec ability
|
|
35
|
+
ec ability 远端 remote list/discover/info/devices/call/result,自动校验、加密定向调用与结果核验;先 ec skill load ability。list --self、invoke 等仍是宿主插件管理与本地实例调用。命令与协议说明都在该技能内(SKILL.md 与 references/cli.md)
|
|
35
36
|
ec aid 身份/证书/名片/换头像(avatar --file/--url)/探测对端 $KITS_DOCS/evolcore/aid.md
|
|
36
37
|
ec directory 联系人名录(list 列举+--filter 关键词过滤+分页/info 按名字或 AID 看详情/refresh 重算注入/blocked 拉黑总览/block、unblock 本地拉黑/request 发加好友申请);备注直接读写 directory/remarks/<AID>.md 再 refresh $KITS_DOCS/evolcore/directory.md
|
|
37
38
|
ec fs AUN 文件系统统一入口(ls/stat/cat/cp/mv/rm/mkdir/ln/chmod/setfacl/getfacl/token/find/df/mount/approve/reject/umount;个人/群空间同一入口;没有 ec group fs) $KITS_DOCS/evolcore/fs.md
|
|
@@ -75,6 +75,7 @@ proactive:普通输出作为思考过程展示,不作为正式回复、不
|
|
|
75
75
|
|
|
76
76
|
发送约束:
|
|
77
77
|
- 只能使用当前会话的 delegated sender,经 daemon IPC 发送;保留托管环境,不另建 SDK 连接。不为绕过限制改写身份、对端或 thread 路由。
|
|
78
|
+
- Ability 业务走 `ec ability remote`,不是聊天回复入口;命令与授权细节见 `ability` 技能,不在本段重复。
|
|
78
79
|
- 调用发送命令时,每次 shell 调用只能执行一条完整的 `ecmsg` 命令。不要拼接探测、管道、重定向、子 shell 或其它命令;不要读取外部 coding-agent skill 寻找发送方式。
|
|
79
80
|
- 正文用单引号包住;正文里含单引号时用 `$'…'` 转义,含 `$` 反引号时注意 Shell 展开。
|
|
80
81
|
- 以退出码和发送回执判断成败;被拒绝时说明具体原因,不通过改目标、改身份或绕开托管通道重试。
|
|
@@ -39,7 +39,7 @@ readonly: true — 禁止写入项目目录及临时目录;如需生成文件
|
|
|
39
39
|
{{/}}
|
|
40
40
|
# 决定响应后:
|
|
41
41
|
# 命令速查:
|
|
42
|
-
# 每次工具调用只执行一条完整的命令;禁止 command -v。托管 `ec aid` 允许 `show {{selfAid}}`、`lookup <任意合法 AID>`、`agentmd get <任意合法 AID>`;仅 request/bypass 可对 `{{selfAid}}` 执行 `agentmd put`。可选后缀仅限 --format json;禁止 &&、||、;、子 shell、bash -lc/sh -c
|
|
42
|
+
# 每次工具调用只执行一条完整的命令;禁止 command -v。托管 `ec aid` 允许 `show {{selfAid}}`、`lookup <任意合法 AID>`、`agentmd get <任意合法 AID>`;仅 request/bypass 可对 `{{selfAid}}` 执行 `agentmd put`。可选后缀仅限 --format json;禁止 &&、||、;、子 shell、bash -lc/sh -c 或其它脚本与其串联。先用命令自身的过滤和分页参数收窄输出。Bash 的受控过滤管道只支持 head/tail/grep/wc/sort/cut/uniq/tr 读取 stdin 的限定参数,不接受文件操作数;不要在 ec 后接 python/python3/node/jq。仍需处理较大查询结果时,可用 `> $TMPDIR/<新文件>` 存盘,再在独立工具调用中读取;发送命令仍遵守 [reply] 的独立执行规则。PowerShell/cmd 下不支持上述管道或重定向。
|
|
43
43
|
# 审批拒绝时原样报告并停止;必须收到包含 message_id/status 的成功回执后才能声称已发送。
|
|
44
44
|
# 正式回复统一用 ecmsg send '<text>';指定话题加 --thread,指定对端加 --to。
|
|
45
45
|
# 本端恒为当前会话本端,无需指定;文件/链接/跨话题/完整选项见 $KITS_DOCS/evolcore/msg.md
|
|
@@ -1,156 +1,54 @@
|
|
|
1
1
|
[thread] 话题系统(ec thread)
|
|
2
|
-
触发词:话题/thread/summary/摘要/ec thread/话题名/工作报告
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
话题摘要是**话题级**进展快照:这条任务线做了什么、结果如何,供下次激活时恢复。
|
|
5
4
|
对端的长期事实(偏好、角色、背景)不写这里,写记忆(见 `[memory]` 段)。
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
`aun#…` 形态的 peerKey 也会被归一成裸 AID 接受。空列表会说明成因(对端无往来 / 被过滤条件挡掉 /
|
|
9
|
-
索引缺失),标识形态非法则直接报错退出。
|
|
6
|
+
## 何时必须写摘要
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# 2. 列出某 agent 有话题记录的所有对端
|
|
18
|
-
ec thread peers
|
|
19
|
-
|
|
20
|
-
# 3. 列出与某对端的所有话题(默认10条/页,含消息统计和摘要)
|
|
21
|
-
ec thread list <peer>
|
|
22
|
-
|
|
23
|
-
# 4. 翻页(页脚自动给出完整翻页命令,含真实 peer)
|
|
24
|
-
ec thread list <peer> --page 2 --limit 10 --sort recent
|
|
25
|
-
|
|
26
|
-
# 5. 查看某话题的历史消息
|
|
27
|
-
ec thread history <peer>/<threadId> --limit 20
|
|
28
|
-
|
|
29
|
-
# 6. 查看话题摘要(写摘要见下文「话题摘要维护」)
|
|
30
|
-
ec thread summary show <peer>/<threadId>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
> 本端身份由运行时注入,托管会话一律不写 `--self`;`--self` 只用于宿主终端(见下方改名示例)。
|
|
34
|
-
|
|
35
|
-
## 跨话题发送(联系当前对端以外的对象)
|
|
36
|
-
|
|
37
|
-
一个话题只有本端与对端两端。当前话题能直接回复的只有本话题的对端;要联系**其他**对象,必须换到与该对象的话题上发送:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# 1. 选中目标话题(没有就新建)
|
|
41
|
-
ec thread list <对方AID>
|
|
42
|
-
ec thread create <对方AID> --name '问题跟踪' # 返回 threadId
|
|
43
|
-
|
|
44
|
-
# 2. 带上话题发送;本端/对端由话题推断
|
|
45
|
-
ecmsg send '<text>' --thread <threadId> --check-every 5m
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
- 目标与会话不一致即为跨话题,`ecmsg` 会自动建复查;缺省 20m,要改周期才写 `--check-every`
|
|
49
|
-
- `--thread` 只接受 `thread-…` 与 `main:<aidA>:<aidB>` 两种形态,形态不对报 `INVALID_THREAD_REF`;话题必须已存在于本端索引,否则报 `TOPIC_NOT_FOUND`。群的主话题同样写成 `main:<本端AID>:<群AID>`,在群子话题里回群主话题必须写它(`--to <群AID>` 只会留在当前子话题)
|
|
50
|
-
- 跨话题需要从 AUN 会话发起;其它渠道的会话只能回复本会话对端
|
|
51
|
-
- 发送成功后本端写入 thread-inbox:目标话题下次被唤醒时注入一次来源话题上下文,然后删除
|
|
52
|
-
- `--to <对方AID>` 首次建立主会话时也保存来源话题。向 Owner 汇报优先写 `--thread <来源话题>`;只写 `--to <Owner AID>` 时,框架仅在有唯一有效的 Owner 委托来源时自动回到原话题,默认不另建复查。要明确发到 Owner 主话题,请写 `--thread main:<本端AID>:<Owner AID>`。
|
|
53
|
-
- `--check-every` 会创建周期复查 Trigger(每次发送各新建一个,名称 `check-<目标>-from-<来源>-<唯一后缀>`),
|
|
54
|
-
需显式 `ec trigger delete <trigger_id>` 结束(不要用 `cancel`,那只是 disable,会留下挂起的死 Trigger);定位用返回的 `trigger_id`(`trig_…`),**不是名称**
|
|
55
|
-
|
|
56
|
-
## 话题名称维护
|
|
57
|
-
|
|
58
|
-
**何时更新名称**(主动触发,不等对端问):
|
|
59
|
-
|
|
60
|
-
| 情况 | 操作 |
|
|
61
|
-
|------|------|
|
|
62
|
-
| 名称是"话题会话"、"你好"等无意义短语 | 立即改名 |
|
|
63
|
-
| 话题方向已明确,名称仍未反映内容 | 改名 |
|
|
64
|
-
| 话题完成,名称与成果不符 | 改名 |
|
|
65
|
-
|
|
66
|
-
**命名规范**:
|
|
67
|
-
- 不超过 20 字,用动词短语描述核心动作
|
|
68
|
-
- 好的示例:`skill 索引热更新 bug 修复`、`manifest 注入与 CLAUDE.md 冗余问题`
|
|
69
|
-
- 避免:日期、轮次序号、"话题会话"等占位词
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
ec thread rename current '<新名称>' # 托管会话
|
|
73
|
-
ec thread rename <peer>/<threadId> '<新名称>' --self <selfAid> # 宿主终端
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## 话题摘要维护
|
|
8
|
+
| 时机 | 操作 |
|
|
9
|
+
|---|---|
|
|
10
|
+
| 用户说"总结一下""总结话题""更新摘要" | 写摘要 |
|
|
11
|
+
| 一个明确的阶段或任务完成 | 写入/更新摘要 |
|
|
12
|
+
| 即将跨话题路由(去问另一个 agent)之前 | 写入当前状态 |
|
|
13
|
+
| 独立话题改为 `closed` 之前 | 写入最终成果 |
|
|
77
14
|
|
|
78
|
-
|
|
15
|
+
`ec thread list` 里显示"未总结"就是行动信号。不要每条消息后都更新,只在阶段完成时。
|
|
79
16
|
|
|
80
|
-
|
|
17
|
+
## 写摘要(两条路径)
|
|
81
18
|
|
|
82
|
-
|
|
83
|
-
`summary set` 自动把游标推进到当时话题最新一条。
|
|
19
|
+
**当前话题里总结**(对话就在上下文,增量即本轮对话,不用读历史):
|
|
84
20
|
|
|
85
21
|
```bash
|
|
86
|
-
#
|
|
87
|
-
ec thread summary
|
|
88
|
-
ec thread summary set current '<摘要内容>' --name '<新标题>' # 2. 写摘要 + 标题(--name 必填)
|
|
89
|
-
# 游标自动推进;不想改名就传 --name -
|
|
90
|
-
|
|
91
|
-
# 情形 B:从别的话题/别处总结(必须读增量)
|
|
92
|
-
ec thread summary show <peer>/<threadId> # 1. 拿 coveredThroughTs
|
|
93
|
-
ec thread history <peer>/<threadId> --after <coveredThroughTs> --limit 50 # 2. 读增量
|
|
94
|
-
ec thread history <peer>/<threadId> --before <最早ts-1> --limit 50 # 3. 增量多则往回翻页
|
|
95
|
-
ec thread summary set <peer>/<threadId> '<摘要内容>' --name '<新标题>' # 4. 读完再写(游标自动推进)
|
|
22
|
+
ec thread summary show current # 看上次摘要 + coveredThroughTs
|
|
23
|
+
ec thread summary set current '<摘要>' --name '<新标题>' # 写摘要 + 改名,游标自动推进
|
|
96
24
|
```
|
|
97
25
|
|
|
98
|
-
|
|
99
|
-
没读完就写,游标越过未读消息,它们下次不会再返回。
|
|
26
|
+
`--name` 必填;保留原标题传 `--name -`。
|
|
100
27
|
|
|
101
|
-
|
|
102
|
-
|
|
28
|
+
**从别的话题或别处总结**:`summary show` 拿 `coveredThroughTs` → `ec thread history <peer>/<threadId> --after <ts> --limit 50`
|
|
29
|
+
读增量 → **读完再写**。`summary set` 把游标设为当时最新一条,没读完就写会让未读消息下次不再返回。
|
|
103
30
|
|
|
104
|
-
|
|
105
|
-
此时从最新往回翻到你认为已覆盖的开头再写。
|
|
31
|
+
摘要 100 字以内,写给自己下次看,不是给对端展示。格式:`[谁]做了[什么],结果是[什么],遗留[什么]`。
|
|
106
32
|
|
|
107
|
-
|
|
33
|
+
## 话题命名
|
|
108
34
|
|
|
109
|
-
|
|
110
|
-
|------|------|
|
|
111
|
-
| 用户明确说"总结一下" | 按上面的情形 A / B 序列执行 |
|
|
112
|
-
| 一个明确的阶段或任务完成 | 写入/更新摘要 |
|
|
113
|
-
| 即将跨话题路由(去问另一个 agent)之前 | 写入当前状态 |
|
|
114
|
-
| 话题状态改为 `closed` 之前 | 写入最终成果摘要 |
|
|
115
|
-
| 被唤醒时发现摘要显示"未总结" | 回顾历史后补写 |
|
|
116
|
-
|
|
117
|
-
**摘要规范**:
|
|
118
|
-
- 100 字以内,写给自己下次看,不是给对端展示
|
|
119
|
-
- 格式:`[谁]做了[什么],结果是[什么],遗留[什么]`
|
|
120
|
-
- 示例:`leiliang 要求把 skill 开关从默认开改为默认关。tl3 完成 switch-resolver.ts 修改并验证,107 个开关记录对应,daemon 已重启。`
|
|
121
|
-
- summary 是本端私有的(keyed by 本地 sessionId),只写"我下次该知道什么",不写给对端的话
|
|
35
|
+
名称是"话题会话""你好"这类无意义短语、或方向已明确但名称未反映内容时,主动改名:
|
|
122
36
|
|
|
123
37
|
```bash
|
|
124
|
-
ec thread
|
|
125
|
-
ec thread summary log current # 查看摘要历史
|
|
38
|
+
ec thread rename current '<新名称>' # 20 字内,动词短语;避免日期、轮次、占位词
|
|
126
39
|
```
|
|
127
40
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
**不要**:每条消息后都更新摘要(只在阶段完成时);把摘要写成会议纪要;因为对端没问就不更新。
|
|
131
|
-
|
|
132
|
-
## 话题状态管理
|
|
133
|
-
|
|
134
|
-
业务状态只适用于独立话题(`thread-...`)。主话题是关系的默认会话,没有业务状态,不能执行
|
|
135
|
-
`ec thread status`,也不能通过把 `current` 当作独立话题来绕过这一限制。
|
|
41
|
+
## 状态管理
|
|
136
42
|
|
|
137
|
-
`current`
|
|
43
|
+
`current` 可能指向独立话题,也可能指向主话题,先确认:
|
|
138
44
|
|
|
139
45
|
```bash
|
|
140
46
|
ec thread show current --format json
|
|
141
47
|
```
|
|
142
48
|
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
跨话题更新状态时,使用 `ec thread list <peer>` 返回的独立 `thread-...` id,不要使用主话题 id。
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
ec thread status <threadId> closed # 讨论结束(收到新消息会自动回退 active)
|
|
151
|
-
ec thread status <threadId> archived # 归档:不再响应消息,仅在用户明确要求时使用
|
|
152
|
-
# 状态值:active | closed | archived
|
|
153
|
-
```
|
|
49
|
+
- 返回 `thread-...`:可用 `ec thread status current closed`(讨论结束)/ `archived`(归档)。
|
|
50
|
+
- 返回 `main:...`(主话题):**没有业务状态**,不能执行 status;完成信息写进 summary 即可。
|
|
51
|
+
- `active | closed | archived`;收到新消息会自动回退 active。
|
|
52
|
+
- 不要自行归档,`archived` 仅在用户明确要求或前端操作时设置。进展写 summary,不用状态表达任务进度。
|
|
154
53
|
|
|
155
|
-
|
|
156
|
-
**不要自行归档**:`archived` 只在用户明确要求或前端操作时设置。话题的进展写在 summary 里,不要用状态表达任务进度。
|
|
54
|
+
跨话题发送、话题链、处理收到的委托、翻页查历史等完整规程见 `ec skill load thread-ops`。
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
chatType: {{chatType}} # private|group
|
|
3
3
|
EVOLCORE_HOME: {{EVOLCORE_HOME}} # 用户数据根目录(agents/sessions/logs)
|
|
4
4
|
PACKAGE_ROOT: {{PACKAGE_ROOT}} # evolcore 安装目录(kits/rules/docs)
|
|
5
|
+
{{?AGENT_DIR}}
|
|
6
|
+
AGENT_DIR: {{AGENT_DIR}} # 当前 agent 数据根目录;历史里的 $AGENT_DIR/attachments/... 就是这里的绝对路径
|
|
7
|
+
{{/}}
|
|
8
|
+
{{?RELATIONS_DIR}}
|
|
9
|
+
RELATIONS_DIR: {{RELATIONS_DIR}} # 当前 agent 关系数据目录;历史里的 $RELATIONS_DIR/... 就是这里的绝对路径
|
|
10
|
+
{{/}}
|
|
5
11
|
{{?evolcoreMode=dev}}
|
|
6
12
|
evolcoreMode: dev # evolcore 以源码仓库运行,$PACKAGE_ROOT/src 下的代码可直接查看和修改
|
|
7
13
|
{{/}}
|
|
@@ -14,6 +20,16 @@ venueUid: {{venueUid}}
|
|
|
14
20
|
{{?mentionMode}}
|
|
15
21
|
mentionMode: {{mentionMode}} # 群 @ 处理模式:mention-only(被@才响应) / disabled(所有消息都响应) / auto(按上下文判断)
|
|
16
22
|
{{/}}
|
|
23
|
+
{{?chatType=private}}
|
|
24
|
+
{{?privateMentionMode=mention-only}}
|
|
25
|
+
privateMentionMode: mention-only # 私聊提及模式(Owner 设置):未被 @ 的私聊消息只记录、不进本回合
|
|
26
|
+
|
|
27
|
+
当前处于私聊提及模式:只有被 @ 的消息会进入本回合,未被 @ 的消息只记入本地历史。
|
|
28
|
+
需要回顾此前对话时,用 `ec msg history <self-aid> <peer-aid> --session all` 读取本地历史
|
|
29
|
+
(最新 50 条,不推进收件箱游标),不要凭印象补全上下文。
|
|
30
|
+
必须带 `--session all`:未被 @ 的消息没有进入任何会话,默认的 `--session latest` 读不到它们。
|
|
31
|
+
{{/}}
|
|
32
|
+
{{/}}
|
|
17
33
|
{{?clientType}}
|
|
18
34
|
clientType: {{clientType}} # 客户端类型:desktop / web / mobile
|
|
19
35
|
{{/}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evolcore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "AI Agent gateway connecting Claude, Codex, Gemini, and the bundled ecagent runner to messaging channels with multi-project session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
"kits/",
|
|
31
31
|
"!kits/runtime/ability-runner-v2.mjs",
|
|
32
32
|
"!kits/.kits-version",
|
|
33
|
-
"!kits/skills/ec-group/TASK.md",
|
|
34
|
-
"!kits/skills/ec-group/WORKLOG.md",
|
|
35
33
|
"*.md",
|
|
36
34
|
"!AGENTS.md",
|
|
37
35
|
"!CLAUDE.md",
|
|
@@ -66,7 +64,7 @@
|
|
|
66
64
|
"prepublishOnly": "npm test"
|
|
67
65
|
},
|
|
68
66
|
"dependencies": {
|
|
69
|
-
"@agentunion/fastaun": "0.5.
|
|
67
|
+
"@agentunion/fastaun": "0.5.38",
|
|
70
68
|
"@anthropic-ai/claude-agent-sdk": "0.3.300",
|
|
71
69
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
72
70
|
"ajv": "^8.20.0",
|
|
@@ -74,9 +72,10 @@
|
|
|
74
72
|
"chokidar": "^5.0.0",
|
|
75
73
|
"cron-parser": "^5.5.0",
|
|
76
74
|
"dotenv": "^17.4.2",
|
|
77
|
-
"ec-web": "0.0.
|
|
75
|
+
"ec-web": "0.0.50",
|
|
78
76
|
"ignore": "7.0.5",
|
|
79
77
|
"image-type": "^6.0.0",
|
|
78
|
+
"jsqr": "^1.4.0",
|
|
80
79
|
"partial-json": "0.1.7",
|
|
81
80
|
"qrcode-terminal": "^0.12.0",
|
|
82
81
|
"semver": "^7.8.5",
|
|
@@ -9,7 +9,8 @@ import { loadEvolcore } from './shared/evolcore.mjs';
|
|
|
9
9
|
import { validateAgainstSchema, buildAgentTriggers, resolveProviderRefs } from './shared/plan.mjs';
|
|
10
10
|
import { excludedResource as excluded, isPortableEventPackFile, isPortableEventPackResource, readEventPacks, validateEventPack } from './shared/template-package.mjs';
|
|
11
11
|
import { normalizeTeam } from './shared/template-contract.mjs';
|
|
12
|
-
import { renderValue as renderTemplateValue, renderResource, bindTemplateProviders, teamMemberVariables, planMemberConfig, resolveMemberParameters } from './shared/template-runtime.mjs';
|
|
12
|
+
import { renderValue as renderTemplateValue, renderResource, bindTemplateProviders, teamMemberVariables, planMemberConfig, resolveMemberParameters, mergeMemberDefaults } from './shared/template-runtime.mjs';
|
|
13
|
+
import { DEFAULT_ACCESS_POLICY } from '../../dist/config/access-policy.js';
|
|
13
14
|
|
|
14
15
|
export async function inspectAgent(options) {
|
|
15
16
|
const config = options.effectiveConfig ?? readJson(path.join(options.agentDir, 'config.json'));
|
|
@@ -28,7 +29,8 @@ export async function inspectAgent(options) {
|
|
|
28
29
|
baseagents: BASEAGENTS.filter(name => config.baseagents?.[name]).map(name => ({ name, currentModel: config.baseagents[name].model ?? null,
|
|
29
30
|
currentEffort: config.baseagents[name].effort ?? null, provider: config.baseagents[name].provider ?? null })),
|
|
30
31
|
triggers, events: readEventPacks(path.join(options.agentDir, 'events')).map(pack => ({ id: pack.id, name: pack.definition.name, enabled: pack.definition.enabled !== false })), skills: options.skills ?? [],
|
|
31
|
-
project: { path: project, files:
|
|
32
|
+
project: { path: project, files: options.listProjectFiles !== false && fs.existsSync(project)
|
|
33
|
+
? fs.readdirSync(project).filter(f => !excluded(f)).sort() : [] } };
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export async function inspectPackage(options) {
|
|
@@ -57,7 +59,7 @@ export async function inspectPackage(options) {
|
|
|
57
59
|
assert(bytes.length === entry.size && sha256(bytes) === entry.sha256, 'INTEGRITY_FAILED', 'Manifest checksum mismatch: ' + entry.path);
|
|
58
60
|
}
|
|
59
61
|
assert(walkFiles(root).length === files.length + 2, 'INTEGRITY_FAILED', 'Unexpected package entries');
|
|
60
|
-
const { tpl, errors } = loadTemplate(templateDir);
|
|
62
|
+
const { tpl, errors } = loadTemplate(templateDir, { contextMemberKeys: Object.keys(options.contextMembers ?? {}) });
|
|
61
63
|
assert(!errors.length, 'INVALID_ARGUMENT', errors.join('; '));
|
|
62
64
|
const contract = normalizeTeam(tpl.team, { packageInfo: pkg });
|
|
63
65
|
assert(!contract.errors.length, 'INTEGRITY_FAILED', contract.errors.join('; '));
|
|
@@ -65,38 +67,42 @@ export async function inspectPackage(options) {
|
|
|
65
67
|
'INVALID_ARGUMENT', 'Matching template metadata and unique member keys required');
|
|
66
68
|
const schemaErrors = validateAgainstSchema(tpl.team, tpl.schema);
|
|
67
69
|
assert(!schemaErrors.length, 'INVALID_ARGUMENT', schemaErrors.join('; '));
|
|
70
|
+
const allKeys = tpl.actualKeys;
|
|
68
71
|
// Check the complete package before selecting member resources. No member may hide unsupported files.
|
|
69
72
|
for (const file of files) assert(file === 'team.json' || file === 'team.schema.json'
|
|
70
|
-
|| file.startsWith('.evolcore/skills/') ||
|
|
73
|
+
|| file.startsWith('.evolcore/skills/') || allKeys.some(key => file.startsWith('workspace/' + key + '/')
|
|
71
74
|
|| file.startsWith('agents/' + key + '/personal/soul/') && file.endsWith('.md') && !file.endsWith('/00-GUIDE.md')
|
|
72
75
|
|| file === 'agents/' + key + '/personal/welcome.md' || file.startsWith('agents/' + key + '/triggers/')
|
|
73
76
|
|| file.startsWith('agents/' + key + '/') && isPortableEventPackFile(file.slice(('agents/' + key + '/').length))),
|
|
74
77
|
'INVALID_ARGUMENT', 'Unsupported template resource: ' + file);
|
|
78
|
+
assert(!options.sourceMemberKey || allKeys.includes(options.sourceMemberKey), 'INTEGRITY_FAILED', 'Original source member is absent');
|
|
79
|
+
const keys = options.sourceMemberKey ? [options.sourceMemberKey] : allKeys;
|
|
75
80
|
const platforms = tpl.team.host.platform;
|
|
76
81
|
if (platforms !== undefined) assert(Array.isArray(platforms) && platforms.length
|
|
77
82
|
&& platforms.every(p => ['linux', 'darwin', 'win32'].includes(p)) && platforms.includes(process.platform),
|
|
78
83
|
'INCOMPATIBLE', 'Template host.platform must support this host');
|
|
79
84
|
if (!options.targets) {
|
|
80
|
-
assert(
|
|
81
|
-
return inspectMember(options, { pkg, tpl, templateDir, files, key:
|
|
85
|
+
assert(keys.length === 1, 'INVALID_ARGUMENT', 'Provide targets mapping for every template member');
|
|
86
|
+
return inspectMember(options, { pkg, tpl, templateDir, files, key: keys[0] });
|
|
82
87
|
}
|
|
83
|
-
assert(isRecord(options.targets) &&
|
|
84
|
-
&&
|
|
85
|
-
const contexts =
|
|
88
|
+
assert(isRecord(options.targets) && keys.length === Object.keys(options.targets).length
|
|
89
|
+
&& keys.every(key => Object.hasOwn(options.targets, key)), 'INVALID_ARGUMENT', 'Map every template member exactly once');
|
|
90
|
+
const contexts = keys.map(key => options.targets[key]);
|
|
86
91
|
assert(contexts.every(c => isRecord(c) && typeof c.targetAid === 'string' && c.home === contexts[0].home)
|
|
87
92
|
&& new Set(contexts.map(c => c.targetAid)).size === contexts.length,
|
|
88
93
|
'INVALID_ARGUMENT', 'Members must map to distinct Agents on the same host');
|
|
89
|
-
assert(Object.keys(options.members ?? {}).every(key =>
|
|
94
|
+
assert(Object.keys(options.members ?? {}).every(key => keys.includes(key)), 'INVALID_ARGUMENT', 'Unknown member selection');
|
|
90
95
|
const writes = new Map(); const members = []; const plans = [];
|
|
91
|
-
const memberVars = teamMemberVariables(Object.fromEntries(
|
|
92
|
-
{ aid: options.targets[key].targetAid, projectPath: options.targets[key].projectPath ?? options.targets[key].targetConfig?.projects?.defaultPath }])),
|
|
96
|
+
const memberVars = teamMemberVariables({ ...options.contextMembers, ...Object.fromEntries(keys.map(key => [key,
|
|
97
|
+
{ aid: options.targets[key].targetAid, projectPath: options.targets[key].projectPath ?? options.targets[key].targetConfig?.projects?.defaultPath }])) },
|
|
93
98
|
contexts[0].ownerAid, contexts[0].hostAid);
|
|
94
|
-
for (const key of
|
|
99
|
+
for (const key of keys) {
|
|
95
100
|
const selection = options.members?.[key] ?? {};
|
|
96
101
|
const out = inside(options.out ?? path.dirname(root), 'members/' + key);
|
|
97
102
|
const data = await inspectMember({ ...options.targets[key], out, packageRoot: options.packageRoot, digest: options.digest,
|
|
98
|
-
pullId: options.pullId, planMode: options.planMode,
|
|
99
|
-
|
|
103
|
+
pullId: options.pullId, planMode: options.planMode, singleMember: !!options.sourceMemberKey, affectedAids: options.affectedAids,
|
|
104
|
+
memberVars: memberVars[key], selections: selection.providers ?? {}, externalAids: selection.externalAids ?? {} },
|
|
105
|
+
{ pkg, tpl, templateDir, key, memberDefaults: options.memberDefaults?.[key], files: files.filter(f => !f.startsWith('agents/') && !f.startsWith('workspace/')
|
|
100
106
|
|| f.startsWith('agents/' + key + '/') || f.startsWith('workspace/' + key + '/')) });
|
|
101
107
|
const plan = readJson(data.planFile);
|
|
102
108
|
for (const write of plan.writes) {
|
|
@@ -107,7 +113,8 @@ export async function inspectPackage(options) {
|
|
|
107
113
|
const { planFile: _planFile, ...preview } = data;
|
|
108
114
|
members.push({ key, targetAid: plan.targetAid, ...preview });
|
|
109
115
|
plans.push({ key, targetAid: plan.targetAid, projectPath: plan.projectPath, profile: plan.profile,
|
|
110
|
-
originalProfile: plan.originalProfile, profileVersion: plan.profileVersion, providers: plan.providers
|
|
116
|
+
originalProfile: plan.originalProfile, profileVersion: plan.profileVersion, providers: plan.providers,
|
|
117
|
+
managedConfig: plan.managedConfig, managedSkills: plan.managedSkills });
|
|
111
118
|
}
|
|
112
119
|
const planFile = path.join(options.out ?? path.dirname(root), 'plan.json');
|
|
113
120
|
atomicBytes(planFile, jsonBytes({ version: 1, home: contexts[0].home, templateDir,
|
|
@@ -116,7 +123,7 @@ export async function inspectPackage(options) {
|
|
|
116
123
|
members, externalAids: pkg.externalAids ?? [], planFile };
|
|
117
124
|
}
|
|
118
125
|
|
|
119
|
-
async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
126
|
+
async function inspectMember(options, { pkg, tpl, templateDir, files, key, memberDefaults }) {
|
|
120
127
|
const root = path.dirname(templateDir);
|
|
121
128
|
const targets = options.targetConfig;
|
|
122
129
|
assert(targets?.aid === options.targetAid, 'INVALID_ARGUMENT', 'Target configuration required');
|
|
@@ -124,7 +131,7 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
124
131
|
assert(typeof project === 'string' && path.isAbsolute(project), 'INVALID_ARGUMENT', 'Target default project required');
|
|
125
132
|
const vars = options.memberVars ?? teamMemberVariables({ [key]: { aid: options.targetAid, projectPath: project } }, options.ownerAid, options.hostAid)[key];
|
|
126
133
|
const renderValue = value => renderTemplateValue(value, vars, options.externalAids ?? {});
|
|
127
|
-
const originalMember = tpl.team.agents.find(member => member.key === key);
|
|
134
|
+
const originalMember = mergeMemberDefaults(memberDefaults ?? {}, tpl.team.agents.find(member => member.key === key));
|
|
128
135
|
const parameters = resolveMemberParameters(originalMember);
|
|
129
136
|
const spec = { ...renderValue(originalMember), ...parameters };
|
|
130
137
|
if (isRecord(spec.config)) for (const field of ['version', 'update']) delete spec.config[field];
|
|
@@ -135,7 +142,7 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
135
142
|
|| file.startsWith('agents/' + key + '/') && isPortableEventPackFile(file.slice(('agents/' + key + '/').length)),
|
|
136
143
|
'INVALID_ARGUMENT', 'Unsupported template resource: ' + file);
|
|
137
144
|
assert(isRecord(spec.config) && !MANAGED_AGENT_FIELDS.some(f => f in spec.config)
|
|
138
|
-
&& Object.keys(spec.config).every(f => ['chatmode', 'memory', 'active_baseagent', 'baseagents', 'version', 'update'].includes(f)),
|
|
145
|
+
&& Object.keys(spec.config).every(f => ['chatmode', 'memory', 'access', 'active_baseagent', 'baseagents', 'version', 'update'].includes(f)),
|
|
139
146
|
'INVALID_ARGUMENT', 'Unsupported template configuration');
|
|
140
147
|
const packageRoot = options.packageRoot ?? path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
141
148
|
const temp = process.env.TMPDIR;
|
|
@@ -151,7 +158,7 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
151
158
|
&& (semver.satisfies(ec.version, pkg.compat.evolcore, { includePrerelease: true })
|
|
152
159
|
|| !pkg.compat.templateFeatures?.length && semver.satisfies(ec.version.replace(/-test\.\d+$/, ''), pkg.compat.evolcore, { includePrerelease: true }))
|
|
153
160
|
&& (pkg.compat.templateFeatures === undefined || Array.isArray(pkg.compat.templateFeatures)
|
|
154
|
-
&& pkg.compat.templateFeatures.every(feature => ['member-references-v1', 'event-packs-v1'].includes(feature))),
|
|
161
|
+
&& pkg.compat.templateFeatures.every(feature => ['member-references-v1', 'event-packs-v1', 'optional-members-v1'].includes(feature))),
|
|
155
162
|
'INCOMPATIBLE', 'Platform or EvolCore version is incompatible', { incompatible: ['platform/version'] });
|
|
156
163
|
const selections = options.selections ?? {};
|
|
157
164
|
for (const [name, block] of Object.entries(spec.config.baseagents ?? {})) {
|
|
@@ -166,6 +173,9 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
166
173
|
assert(resolved.baseagents?.[resolved.active_baseagent], 'INVALID_ARGUMENT', 'Default baseagent must be selected');
|
|
167
174
|
assert(Object.keys(selections).every(name => resolved.baseagents?.[name]), 'INVALID_ARGUMENT', 'Unknown baseagent selection');
|
|
168
175
|
const config = mergeObjects(targets, resolveProviderRefs(resolved));
|
|
176
|
+
if (config.access !== undefined) {
|
|
177
|
+
config.access.requestLimit = { ...DEFAULT_ACCESS_POLICY.requestLimit, ...config.access.requestLimit };
|
|
178
|
+
}
|
|
169
179
|
for (const field of ['version', 'update']) if (Object.hasOwn(parameters, field)) {
|
|
170
180
|
config[field] = structuredClone(parameters[field]);
|
|
171
181
|
}
|
|
@@ -184,7 +194,8 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
184
194
|
soul: { add: [], overwrite: [] }, triggers: { add: [], overwrite: [] }, events: { add: [], overwrite: [] }, skills: [], files: { add: 0, overwrite: 0 },
|
|
185
195
|
project: { path: project, changeDefault: false }, config: Object.keys(resolved) };
|
|
186
196
|
const skillMapping = {};
|
|
187
|
-
const localNames = [...new Set(files.filter(f => f.startsWith('.evolcore/skills/')).map(f => f.split('/')[2]))]
|
|
197
|
+
const localNames = [...new Set(files.filter(f => f.startsWith('.evolcore/skills/')).map(f => f.split('/')[2]))]
|
|
198
|
+
.filter(name => !options.singleMember || Object.hasOwn(spec.skills ?? {}, name));
|
|
188
199
|
for (const name of localNames) {
|
|
189
200
|
const source = inside(path.join(templateDir, '.evolcore', 'skills'), name);
|
|
190
201
|
const hash = createHash('sha256');
|
|
@@ -194,7 +205,8 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
194
205
|
const original = inside(path.join(options.home, 'skills'), name);
|
|
195
206
|
if (fs.existsSync(original) && templateDigest(original) !== desiredDigest) destName += '--' + pkg.id;
|
|
196
207
|
const dest = inside(path.join(options.home, 'skills'), destName);
|
|
197
|
-
if (fs.existsSync(dest)) assert(templateDigest(dest) === desiredDigest, '
|
|
208
|
+
if (fs.existsSync(dest)) assert(templateDigest(dest) === desiredDigest, options.singleMember ? 'SHARED_RESOURCE_CONFLICT' : 'CONFLICT',
|
|
209
|
+
'Skill name conflicts: ' + destName, options.singleMember ? { path: dest, affectedAids: options.affectedAids ?? [] } : undefined);
|
|
198
210
|
skillMapping[name] = destName;
|
|
199
211
|
preview.skills.push({ name, installAs: destName });
|
|
200
212
|
for (const p of walkFiles(source)) add(inside(dest, p), render(fs.readFileSync(inside(source, p)), p),
|
|
@@ -203,7 +215,7 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
203
215
|
const switchesFile = path.join(agentDir, 'skills', '.switches.json');
|
|
204
216
|
const switches = fs.existsSync(switchesFile) ? readJson(switchesFile) : {};
|
|
205
217
|
for (const [name, value] of Object.entries(spec.skills ?? {})) switches[skillMapping[name] ?? name] = { enabled: value.enabled === true };
|
|
206
|
-
add(switchesFile, jsonBytes(switches));
|
|
218
|
+
if (Object.keys(spec.skills ?? {}).length) add(switchesFile, jsonBytes(switches));
|
|
207
219
|
const eventPacks = readEventPacks(path.join(templateDir, 'agents', key, 'events'), { template: true });
|
|
208
220
|
for (const pack of eventPacks) {
|
|
209
221
|
const dir = inside(path.join(agentDir, 'events'), pack.id);
|
|
@@ -272,6 +284,8 @@ async function inspectMember(options, { pkg, tpl, templateDir, files, key }) {
|
|
|
272
284
|
}
|
|
273
285
|
const plan = { version: 1, targetAid: options.targetAid, home: options.home, projectPath: project,
|
|
274
286
|
templateDir, templateDigest: templateDigest(templateDir), package: pkg, writes,
|
|
287
|
+
managedConfig: { ...resolveProviderRefs(resolved), ...parameters },
|
|
288
|
+
managedSkills: Object.fromEntries(Object.entries(spec.skills ?? {}).map(([name, value]) => [skillMapping[name] ?? name, { enabled: value.enabled === true }])),
|
|
275
289
|
profile: spec.profile,
|
|
276
290
|
originalProfile: options.profile, profileVersion: options.profileVersion, providers: refs };
|
|
277
291
|
const planFile = path.join(options.out ?? path.dirname(root), 'plan.json');
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { assert, snapshot, equalSnapshot, readJson, jsonBytes, atomicBytes, regularPath } from './shared/common.mjs';
|
|
3
|
+
import { assert, snapshot, equalSnapshot, readJson, jsonBytes, atomicBytes, regularPath, sha256 } from './shared/common.mjs';
|
|
4
4
|
import { templateDigest } from './shared/template.mjs';
|
|
5
5
|
|
|
6
6
|
export function verifyPlan(plan) {
|
|
7
7
|
assert(templateDigest(plan.templateDir) === plan.templateDigest, 'CONFLICT', 'Cached template changed');
|
|
8
|
+
for (const [file, expected] of Object.entries(plan.observed ?? {})) {
|
|
9
|
+
assert(equalSnapshot(snapshot(file), expected), 'CONFLICT', 'Observed target changed: ' + file);
|
|
10
|
+
}
|
|
8
11
|
for (const write of plan.writes) assert(equalSnapshot(snapshot(write.path), write.expected), 'CONFLICT', 'Target changed: ' + write.path);
|
|
9
12
|
}
|
|
10
13
|
|
|
@@ -12,6 +15,13 @@ export function restore(backupDir) {
|
|
|
12
15
|
const file = path.join(backupDir, 'journal.json');
|
|
13
16
|
const journal = readJson(file);
|
|
14
17
|
assert(journal.version === 1 && Array.isArray(journal.entries), 'INSTALL_BROKEN', 'Invalid restore journal');
|
|
18
|
+
for (const entry of journal.entries) {
|
|
19
|
+
if (!Object.hasOwn(entry, 'desired')) continue; // Legacy journals retain their original recovery behavior.
|
|
20
|
+
const current = snapshot(entry.path);
|
|
21
|
+
const original = entry.existed ? { sha256: sha256(fs.readFileSync(path.join(backupDir, entry.backup))), mode: entry.mode } : null;
|
|
22
|
+
assert(equalSnapshot(current, original) || equalSnapshot(current, entry.desired),
|
|
23
|
+
'INSTALL_BROKEN', 'Independent change prevents safe restore: ' + entry.path);
|
|
24
|
+
}
|
|
15
25
|
for (const entry of [...journal.entries].reverse()) {
|
|
16
26
|
regularPath(entry.path);
|
|
17
27
|
if (entry.existed) atomicBytes(entry.path, fs.readFileSync(path.join(backupDir, entry.backup)), entry.mode);
|
|
@@ -27,6 +37,13 @@ export function restore(backupDir) {
|
|
|
27
37
|
export async function overlay(options) {
|
|
28
38
|
if (options.operation === 'restore') return restore(options.backupDir);
|
|
29
39
|
const plan = options.plan ?? readJson(options.planFile);
|
|
40
|
+
if (options.operation === 'verify-applied') {
|
|
41
|
+
for (const write of plan.writes) {
|
|
42
|
+
const expected = write.remove ? null : { sha256: sha256(Buffer.from(write.content, 'base64')), mode: write.mode };
|
|
43
|
+
assert(equalSnapshot(snapshot(write.path), expected), 'INTEGRITY_FAILED', 'Applied resource differs: ' + write.path);
|
|
44
|
+
}
|
|
45
|
+
return { verified: true };
|
|
46
|
+
}
|
|
30
47
|
verifyPlan(plan);
|
|
31
48
|
if (options.operation === 'verify') return { valid: true };
|
|
32
49
|
const backupDir = options.backupDir;
|
|
@@ -42,7 +59,8 @@ export async function overlay(options) {
|
|
|
42
59
|
for (const [i, write] of plan.writes.entries()) {
|
|
43
60
|
regularPath(write.path);
|
|
44
61
|
const existing = snapshot(write.path);
|
|
45
|
-
const entry = { path: write.path, existed: existing !== null, mode: existing?.mode ?? write.mode, backup: i + '.bin'
|
|
62
|
+
const entry = { path: write.path, existed: existing !== null, mode: existing?.mode ?? write.mode, backup: i + '.bin',
|
|
63
|
+
desired: write.remove ? null : { sha256: sha256(Buffer.from(write.content, 'base64')), mode: write.mode } };
|
|
46
64
|
if (existing) atomicBytes(path.join(backupDir, entry.backup), fs.readFileSync(write.path), 0o600);
|
|
47
65
|
journal.entries.push(entry);
|
|
48
66
|
let dir = path.dirname(write.path); const missing = [];
|
|
@@ -12,7 +12,7 @@ const parentPid = process.ppid;
|
|
|
12
12
|
|
|
13
13
|
export const LIMITS = { file: 20 * 1024 * 1024, total: 200 * 1024 * 1024, entries: 20000 };
|
|
14
14
|
export const BASEAGENTS = ['claude', 'codex', 'gemini', 'ecagent'];
|
|
15
|
-
export const CONFIG_FIELDS = ['chatmode', 'memory'];
|
|
15
|
+
export const CONFIG_FIELDS = ['chatmode', 'memory', 'access'];
|
|
16
16
|
export const PROFILE_FIELDS = ['name', 'description', 'avatar', 'tags', 'exttype'];
|
|
17
17
|
|
|
18
18
|
export function assert(value, code, message, data) {
|
|
@@ -48,14 +48,20 @@ export function regularPath(target) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export function walkFiles(root, exclude = () => false, { maxTotalBytes = LIMITS.total, onOversizedFile } = {}) {
|
|
51
|
+
export function walkFiles(root, exclude = () => false, { maxTotalBytes = LIMITS.total, onOversizedFile, onMissingFile } = {}) {
|
|
52
52
|
if (!fs.existsSync(root)) return [];
|
|
53
53
|
regularPath(root);
|
|
54
54
|
const files = [];
|
|
55
55
|
let total = 0;
|
|
56
56
|
let count = 0;
|
|
57
57
|
const visit = (dir) => {
|
|
58
|
-
|
|
58
|
+
let entries;
|
|
59
|
+
try { regularPath(dir); entries = fs.readdirSync(dir, { withFileTypes: true }); }
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (!onMissingFile || !['ENOENT', 'ENOTDIR'].includes(error.code)) throw error;
|
|
62
|
+
onMissingFile(posix(path.relative(root, dir))); return;
|
|
63
|
+
}
|
|
64
|
+
for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
59
65
|
const file = path.join(dir, e.name);
|
|
60
66
|
if (exclude(posix(path.relative(root, file)))) continue;
|
|
61
67
|
assert(!e.isSymbolicLink() && (e.isFile() || e.isDirectory()), 'INVALID_ARGUMENT', 'Only regular files/directories: ' + file);
|
|
@@ -63,7 +69,13 @@ export function walkFiles(root, exclude = () => false, { maxTotalBytes = LIMITS.
|
|
|
63
69
|
if (e.isDirectory()) visit(file);
|
|
64
70
|
else {
|
|
65
71
|
count++;
|
|
66
|
-
|
|
72
|
+
let stat;
|
|
73
|
+
try { stat = fs.lstatSync(file); }
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (!onMissingFile || !['ENOENT', 'ENOTDIR'].includes(error.code)) throw error;
|
|
76
|
+
onMissingFile(posix(path.relative(root, file))); continue;
|
|
77
|
+
}
|
|
78
|
+
assert(stat.isFile(), 'INVALID_ARGUMENT', 'Only regular files: ' + file);
|
|
67
79
|
if (stat.size > LIMITS.file && onOversizedFile) {
|
|
68
80
|
onOversizedFile({ path: posix(path.relative(root, file)), size: stat.size, limit: LIMITS.file });
|
|
69
81
|
continue;
|