evolcore 0.0.43-test.6 → 0.0.43-test.8
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 +95 -0
- package/bin/ecmsg.js +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/eck/message-renderer.js +2 -0
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,101 @@
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## 0.0.43-test.8 (2026-11-10)
|
|
9
|
+
|
|
10
|
+
### 身份、Owner 与联系人
|
|
11
|
+
|
|
12
|
+
- Agent 常驻设定改用 personal/soul/ 分册,迁移旧 persona.md;显示名跟随签名名片刷新,支持关闭首次欢迎消息。
|
|
13
|
+
- 新增 App 联系人准入与同 Owner 内部联系人默认角色,完善黑名单、临时授权、名录范围和出站联系申请;敏感操作重新核验协议归属。
|
|
14
|
+
- 名录查询统一为 ec directory list/info,准入与查询使用本地快照,废弃本地授权凭据;明确撤权持久化,阻止共享缓存恢复已撤权快照。
|
|
15
|
+
- 上下文与记忆写入统一使用协议确认的 Owner;普通 Agent 绑定和转让要求目标为验签通过的 human,自动绑定仅限初始化阶段;修复 SDK 0.5.34 下绑定提交前连接中断的识别。
|
|
16
|
+
|
|
17
|
+
### 对话、模型与自动化
|
|
18
|
+
|
|
19
|
+
- 移除 paactive 对话模式,仅保留 interactive/proactive,启动时自动迁移已知配置中的旧模式;个人助理与本人 Owner 的 AUN 私聊按已核验身份使用可靠 activity 投递。
|
|
20
|
+
- 统一模型容量解析,按当前 Provider 计算压缩阈值,更新模型与价格数据;修正压缩后用量,增加手动压缩进度通知。
|
|
21
|
+
- ecagent 支持只读访问入站附件并校验真实路径;非法工具参数转为可恢复错误,摘要失败不再自动重试。
|
|
22
|
+
- Trigger 跟随 Agent 当前基座,支持静默结果和自定义闲置提示;完善取消与子进程清理,输入已提交但结果不明时避免重复提交。
|
|
23
|
+
|
|
24
|
+
### 消息、服务与事件
|
|
25
|
+
|
|
26
|
+
- 新增 ecmsg 统一发送入口,统一话题路由、复查和加密选项,支持非 AUN 既有会话;跨话题自派必须指定其他话题,并向该话题对端展示派发副本。
|
|
27
|
+
- AUN Menu 使用独立 control 消息流并强制加密响应;完善自动最终回复的结构化投递、话题摘要批量读取及空列表诊断。
|
|
28
|
+
- 新增 ec services 服务路由,支持准入、限流、幂等、脚本执行和结构化应答;新增 ec events 事件中心,提供 TTL 内在线通知、订阅及白名单管理。
|
|
29
|
+
- 服务包与事件包统一使用 pack.json,支持受控安装、卸载、日志归档和跨 Agent 管理授权;事件中心复用 AUN 渠道连接,完善订阅、重连和消费诊断。
|
|
30
|
+
- 完善 Fullaccess 委托核验、授权审计及跨 Shell 参数解析,允许直接执行 ecmsg 入口,过滤空消息占位输出。
|
|
31
|
+
|
|
32
|
+
### 能力插件、团队与模板
|
|
33
|
+
|
|
34
|
+
- 新增按 Agent 或主机 AID 管理的能力插件平台,支持开发、构建、安装、授权、发布、升级及回滚;能力发现和管理技能合并为 ability。
|
|
35
|
+
- 完善多运行时、设备路由、请求关联、契约校验和重放保护,资源代理支持批量存储与工作区读取。
|
|
36
|
+
- 新增 ec team 团队工作区及成员、导航管理,使用稳定入口 ID 增量更新;每个 Agent 使用独立产物目录,迁移旧工作区文件与导航引用。
|
|
37
|
+
- 新增 Agent 模板检查、打包、分享及安装,支持将多成员模板映射到已有 Agent,逐成员选择 Provider、统一渲染资源占位符,并在失败时整包回滚。
|
|
38
|
+
- 支持导出不含主机凭据的便携模板包、校验后导入新目录,以及通过主机控制通道推送模板任务进度;兼容旧版团队模板字段布局并校验格式版本。
|
|
39
|
+
|
|
40
|
+
### Provider、启动与运行管理
|
|
41
|
+
|
|
42
|
+
- Provider 使用域名稳定 ID,支持本机配置导入、引用迁移、接口风格保存和冲突诊断;EC Web 初始化导入冲突改用对话框处理。
|
|
43
|
+
- 修复 Codex 切换 Provider 后原会话续接,保留线程与历史;Runner 按需加载,合并首次并发加载,协调配置重载、中断与停机。
|
|
44
|
+
- 启动恢复按 Agent 和任务优先级调度,Handoff 后台恢复,会话空闲计时按近期与历史分批恢复;复用目录扫描并让出 I/O,减少就绪等待。
|
|
45
|
+
- EC Web 启动甘特图展示 Observer 提示、空闲计时及 Handoff 后台恢复阶段;修复初始化重试时项目路径尾分隔符误判。
|
|
46
|
+
- 完善受管服务与 EC Web 的实例身份、健康检查和优雅退出,以及异步进程探测、重启监控、并行停机和 Windows 安装诊断;移除内置 PA 看板导航入口。
|
|
47
|
+
|
|
48
|
+
### 依赖与兼容性
|
|
49
|
+
|
|
50
|
+
- Node.js 要求 >=22.16.0,AUN SDK 最低兼容版本提升至 0.5.34,配套 ec-web@0.0.43-test.8。
|
|
51
|
+
- Agent、Relation、Role Schema 分别为 v20、v12、v2;内部联系人默认角色使用 internalContact,已知 Schema 中的旧 paactive 模式自动迁移为 proactive。
|
|
52
|
+
- 服务与事件配置采用 services-config.json、events-config.json,旧配置与包清单在兼容流程中迁移至新名称。
|
|
53
|
+
- Invoke 保留为未完成功能,本次按要求不执行相关测试,不作为可用功能验收。
|
|
54
|
+
|
|
55
|
+
## 0.0.43-test.7 (2026-11-09)
|
|
56
|
+
|
|
57
|
+
### 身份、Owner 与联系人
|
|
58
|
+
|
|
59
|
+
- Agent 常驻设定改用 personal/soul/ 分册,迁移旧 persona.md;显示名跟随签名名片刷新,支持关闭首次欢迎消息。
|
|
60
|
+
- 新增 App 联系人准入与同 Owner 内部联系人默认角色,完善黑名单、临时授权、名录范围和出站联系申请;敏感操作重新核验协议归属。
|
|
61
|
+
- 名录查询统一为 ec directory list/info,准入与查询使用本地快照,废弃本地授权凭据;明确撤权持久化,阻止共享缓存恢复已撤权快照,并允许缺少快照时刷新。
|
|
62
|
+
- 上下文与记忆写入统一使用协议确认的 Owner;普通 Agent 绑定和转让要求目标为验签通过的 human,自动绑定仅限初始化阶段,active Agent 跳过旧配置邀约。
|
|
63
|
+
|
|
64
|
+
### 对话、模型与自动化
|
|
65
|
+
|
|
66
|
+
- 移除 paactive 对话模式,仅保留 interactive/proactive。个人助理与本人 Owner 的 AUN 私聊按已核验身份自动使用可靠 activity 投递;正式回复仍通过 ecmsg 发送,超限 activity 不降级为普通文本。
|
|
67
|
+
- 统一模型容量解析,按当前 Provider 计算压缩阈值,更新模型与价格数据;修正压缩后用量,增加手动压缩进度通知。
|
|
68
|
+
- ecagent 支持只读访问入站附件并校验真实路径;非法工具参数转为可恢复错误,摘要失败不再自动重试。
|
|
69
|
+
- Trigger 跟随 Agent 当前基座,支持静默结果和自定义闲置提示;完善取消与子进程清理,输入已提交但结果不明时避免重复提交。
|
|
70
|
+
|
|
71
|
+
### 消息、服务与事件
|
|
72
|
+
|
|
73
|
+
- 新增 ecmsg 统一发送入口,统一话题路由、复查和加密选项,支持非 AUN 既有会话及话题内投递给本端自己,回执显示实际目标。
|
|
74
|
+
- AUN Menu 使用独立 control 消息流并强制加密响应;异步分批读取话题摘要,完善响应重试、Codex 话题派生和批量查询的逐项结果。
|
|
75
|
+
- 新增 ec services 服务路由,支持 services.* 请求、服务包匹配、准入、限流、幂等、脚本执行和结构化应答;服务结果与普通模型消息分别处理。
|
|
76
|
+
- 新增 ec events 事件中心,支持事件注册、发布、订阅、白名单及事件包脚本处理;事件为 TTL 内在线通知,不提供持久历史或业务应答。
|
|
77
|
+
- 服务包与事件包支持运行时校验、台账、沙箱执行及状态诊断,索引按配置注入上下文。
|
|
78
|
+
- 完善 Fullaccess 委托核验、授权审计及跨 Shell 参数解析,停止观察通道转发 thought.put 返回结果,过滤空消息占位输出。
|
|
79
|
+
|
|
80
|
+
### 能力插件与团队工作区
|
|
81
|
+
|
|
82
|
+
- 新增按 Agent 或主机 AID 管理的能力插件平台,支持开发、构建、安装、授权、发布、升级及回滚;能力发现和管理技能合并为 ability。
|
|
83
|
+
- 完善多运行时、设备路由、请求关联、契约校验和重放保护,资源代理支持批量存储与工作区读取。
|
|
84
|
+
- 新增 ec team 团队工作区及成员、导航管理,使用稳定入口 ID 增量更新;支持 Owner 私聊 Menu 管理和并发版本校验。
|
|
85
|
+
- 每个 Agent 使用独立产物目录,迁移旧工作区文件与导航引用;保留路径、符号链接和既有目标的冲突保护,任务图片保存为不可变资源。
|
|
86
|
+
|
|
87
|
+
### Provider、启动与运行管理
|
|
88
|
+
|
|
89
|
+
- Provider 使用域名稳定 ID,支持本机配置导入、引用迁移、接口风格保存和冲突诊断;冲突时保留原配置,环境变量地址需声明有效域名。
|
|
90
|
+
- 修复 Codex 切换 Provider 后原会话续接:备份并同步线程元数据和索引,保留原线程及历史;冲突或无法释放旧运行时时停止恢复。
|
|
91
|
+
- Runner 按需加载,启动仅预载恢复任务需要的主用后端;合并首次并发加载,协调配置重载、中断与停机,状态查询不触发加载。
|
|
92
|
+
- 启动按 Agent 完成恢复分类后逐步放行渠道,前台连接优先;构建身份诊断和 CLI 版本探测后台执行,区分控制面、任务就绪及后台审计。
|
|
93
|
+
- 完善受管服务与 EC Web 的实例身份、健康检查、恢复计数和优雅退出;服务清理继承的任务授权环境,状态区分进程存活与端点健康。
|
|
94
|
+
- 完善异步进程探测、重启监控、并行停机和 Windows 安装、自启动诊断;统一上下线通知开关,下线通知完成准入后再释放 Owner 共识。
|
|
95
|
+
- 移除 EC Web 内置 PA 看板导航入口,看板服务需单独部署。
|
|
96
|
+
|
|
97
|
+
### 依赖与兼容性
|
|
98
|
+
|
|
99
|
+
- Node.js 要求 >=22.16.0,AUN SDK 最低兼容版本为 0.5.33,配套 ec-web@0.0.43-test.7。
|
|
100
|
+
- Agent Schema 升至 v20,Relation、Role Schema 为 v12、v2;内部联系人默认角色使用 internalContact,旧 paactive 配置需改为 interactive 或 proactive。
|
|
101
|
+
- Invoke 保留为未完成功能,本次按要求不执行相关测试,不作为可用功能验收。
|
|
102
|
+
|
|
8
103
|
## 0.0.43-test.6 (2026-11-08)
|
|
9
104
|
|
|
10
105
|
### 身份、Owner 与联系人
|
package/bin/ecmsg.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* 职责边界(第一期):
|
|
8
8
|
* - 只做**路由**:解析目标三元组、判跨话题、决定复查与加密,然后分派给
|
|
9
9
|
* 现有的内部发送通道。
|
|
10
|
-
* -
|
|
11
|
-
* 全部保持原状可用。
|
|
10
|
+
* - 不改写任何内部通道的实现,旧命令全部保持原状可用。
|
|
12
11
|
*
|
|
13
12
|
* 为什么必须有这一层:
|
|
14
13
|
* 模型面对三种写法时必须先判断"用哪种",判断错就失败。网关把判断收敛为一
|
|
@@ -25,6 +24,7 @@
|
|
|
25
24
|
* 参数解析与下游 argv 构造在 `dist/cli/ecmsg-gateway.js`(纯函数,可单测)。
|
|
26
25
|
*/
|
|
27
26
|
import net from 'node:net';
|
|
27
|
+
import fs from 'node:fs';
|
|
28
28
|
import path from 'node:path';
|
|
29
29
|
import crypto from 'node:crypto';
|
|
30
30
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
@@ -47,7 +47,8 @@ const HELP = `用法: ecmsg send '<正文>' [选项]
|
|
|
47
47
|
(省略) 回复当前会话的对端/群
|
|
48
48
|
--thread <话题id> 发到指定话题;只接受 thread-… 或 main:<aidA>:<aidB>
|
|
49
49
|
--to <对端ID> 发到指定对端(群 AID 或对方 AID,按本地关系判定类型)
|
|
50
|
-
--from <本端AID>
|
|
50
|
+
--from <本端AID> 托管会话可省略(恒等于会话本端);非托管必填
|
|
51
|
+
--to <本端AID> 跨话题自派(self-dispatch):必须配合 --thread,换话题给自己派活
|
|
51
52
|
|
|
52
53
|
复查:
|
|
53
54
|
跨话题(对端或话题与会话不同)自动创建复查 Trigger,默认 20m;
|
|
@@ -185,21 +186,25 @@ async function loadDist(relative) {
|
|
|
185
186
|
* 第 3 条同时覆盖"首次联系一个人":这时关系记录还不存在,按私聊发出,
|
|
186
187
|
* 会话随首条消息建立。
|
|
187
188
|
*/
|
|
188
|
-
async function resolveTargetPeerKind(runtime, targetId) {
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
async function resolveTargetPeerKind(runtime, targetId, selfAidOverride) {
|
|
190
|
+
// 非托管没有会话上下文:渠道恒为 aun,当前对端未知,只按关系证据判类型。
|
|
191
|
+
const currentKind = !runtime ? 'private' : (runtime.chatType === 'group' ? 'group' : 'private');
|
|
192
|
+
const selfAid = selfAidOverride ?? runtime?.selfAid;
|
|
193
|
+
if (runtime && runtime.channel !== 'aun') return currentKind;
|
|
191
194
|
|
|
192
195
|
const normalize = value => String(value ?? '').trim().replace(/^@/, '').toLowerCase();
|
|
193
|
-
const currentPeerId = currentPeerIdOf(runtime);
|
|
194
|
-
if (normalize(targetId) === normalize(currentPeerId)) return currentKind;
|
|
196
|
+
const currentPeerId = runtime ? currentPeerIdOf(runtime) : '';
|
|
197
|
+
if (currentPeerId && normalize(targetId) === normalize(currentPeerId)) return currentKind;
|
|
198
|
+
// 目标是本端自己:类型就是当前会话类型,不必拉自己的 agent.md / 网关。
|
|
199
|
+
if (selfAid && normalize(targetId) === normalize(selfAid)) return currentKind;
|
|
195
200
|
|
|
196
201
|
const peerIdentity = await loadDist('core/relation/peer-identity.js');
|
|
197
202
|
try {
|
|
198
|
-
const local = peerIdentity?.readAunPeerKind?.(
|
|
203
|
+
const local = peerIdentity?.readAunPeerKind?.(selfAid, targetId)?.kind;
|
|
199
204
|
if (local === 'private' || local === 'group') return local;
|
|
200
205
|
} catch { /* 本地证据不可用不算错误,继续往下判 */ }
|
|
201
206
|
try {
|
|
202
|
-
const remote = await peerIdentity?.resolveAunPeerKind?.(
|
|
207
|
+
const remote = await peerIdentity?.resolveAunPeerKind?.(selfAid, targetId);
|
|
203
208
|
if (remote?.kind === 'private' || remote?.kind === 'group') return remote.kind;
|
|
204
209
|
} catch { /* 网络不可用时不阻塞发送,按私聊兜底 */ }
|
|
205
210
|
return 'private';
|
|
@@ -271,6 +276,11 @@ async function main() {
|
|
|
271
276
|
{ hint: sub === 'history' ? '查看历史请用 ec msg history' : '用 --help 查看发送用法' });
|
|
272
277
|
}
|
|
273
278
|
|
|
279
|
+
// 与 aid/msg/group 等命令一致:先关掉 SDK 的 [aun_core] 日志,
|
|
280
|
+
// 否则解析对端类型时的 debug 行会糊住真正的回执/错误。
|
|
281
|
+
const aidModule = await loadDist('aun/aid/index.js');
|
|
282
|
+
aidModule?.suppressSdkLogs?.();
|
|
283
|
+
|
|
274
284
|
const routing = await loadDist('core/message/send-routing.js');
|
|
275
285
|
const gateway = await loadDist('cli/ecmsg-gateway.js');
|
|
276
286
|
if (!routing || !gateway) fail(BUILD_HINT, 'BUILD_REQUIRED');
|
|
@@ -285,18 +295,32 @@ async function main() {
|
|
|
285
295
|
const sessionId = process.env[ENV_SESSION_ID]?.trim();
|
|
286
296
|
const delegationToken = process.env[ENV_DELEGATION_TOKEN]?.trim()
|
|
287
297
|
|| process.env[ENV_CODEX_SESSION_TOKEN]?.trim();
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
298
|
+
// 非托管(宿主终端):没有会话运行时,本端由 `--from` 显式给出,话题由 `--thread` 给出,
|
|
299
|
+
// 对端与 chatType 从话题索引反查。这条路径走本机 controlToken,不走委托链。
|
|
300
|
+
const nonManaged = !sessionId;
|
|
301
|
+
if (nonManaged && !delegationToken) {
|
|
302
|
+
if (!routeOpts.from || !String(routeOpts.from).trim()) {
|
|
303
|
+
fail('非托管使用需要 --from <本端AID> 指定发送方', 'FROM_REQUIRED',
|
|
304
|
+
{ hint: 'ecmsg send \'<正文>\' --from <本端AID> --thread <话题id> --to <对端或本端AID>' });
|
|
305
|
+
}
|
|
306
|
+
if (!routeOpts.thread || !String(routeOpts.thread).trim()) {
|
|
307
|
+
fail('非托管使用需要 --thread <话题id> 定位会话', 'THREAD_REQUIRED',
|
|
308
|
+
{ hint: "ecmsg send '<正文>' --from <本端AID> --thread <话题id> --to <对端或本端AID>" });
|
|
309
|
+
}
|
|
310
|
+
if (passthrough.length > 0) {
|
|
311
|
+
fail(`非托管发送目前只支持纯文本,不支持的选项:${passthrough.join(' ')}`, 'UNSUPPORTED_OPTION');
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (sessionId && !delegationToken) {
|
|
315
|
+
fail('ecmsg 需要会话委托凭证(缺少 EVOLCORE_DELEGATION_TOKEN)。', 'DELEGATION_REQUIRED');
|
|
291
316
|
}
|
|
292
|
-
if (!delegationToken) fail('ecmsg 需要会话委托凭证(缺少 EVOLCORE_DELEGATION_TOKEN)。', 'DELEGATION_REQUIRED');
|
|
293
317
|
|
|
294
318
|
const runtime = (() => {
|
|
295
319
|
const raw = process.env[ENV_TASK_RUNTIME_CONTEXT];
|
|
296
320
|
if (!raw) return undefined;
|
|
297
321
|
try { return JSON.parse(raw); } catch { return undefined; }
|
|
298
322
|
})();
|
|
299
|
-
if (!runtime?.selfAid || !runtime?.channel || !runtime?.chatType) {
|
|
323
|
+
if (!nonManaged && (!runtime?.selfAid || !runtime?.channel || !runtime?.chatType)) {
|
|
300
324
|
fail('运行时上下文不完整(缺少 selfAid/channel/chatType),无法确定本端与对端',
|
|
301
325
|
'CONTEXT_INCOMPLETE');
|
|
302
326
|
}
|
|
@@ -310,12 +334,29 @@ async function main() {
|
|
|
310
334
|
// 其余情况零 IO。
|
|
311
335
|
const deps = {};
|
|
312
336
|
|
|
337
|
+
// 本端 AID:托管取运行时,非托管取 `--from`。
|
|
338
|
+
const selfAid = nonManaged ? String(routeOpts.from).trim().replace(/^@/, '') : runtime.selfAid;
|
|
339
|
+
|
|
340
|
+
// 群 AID 归一:`g-18127` 这类裸 base 必须在判定目标之前展开成完整 AID,
|
|
341
|
+
// 否则既判不出它是群,也拼不出主话题。展开逻辑见 `ecmsg-gateway.ts` 的
|
|
342
|
+
// `expandGroupBase`(纯函数,有单测)。
|
|
343
|
+
let groupIdentity;
|
|
344
|
+
const resolveGroupId = async id => {
|
|
345
|
+
groupIdentity ??= await loadDist('aun/group/identity.js');
|
|
346
|
+
return gateway.expandGroupBase(selfAid, id, groupIdentity?.normalizeGroupAid);
|
|
347
|
+
};
|
|
348
|
+
|
|
313
349
|
// --to 的目标类型:下游按它选 msg send / group send,必须解析而不是沿用
|
|
314
350
|
// 当前会话的类型——否则"在私聊会话里给群发"会走成私聊,"在群会话里给个人发"
|
|
315
351
|
// 会走成群消息。
|
|
352
|
+
//
|
|
353
|
+
// 群 AID 的 base 简写(`g-18127`)必须先展开成完整 AID,再做类型判定与路由:
|
|
354
|
+
// 否则它既不像群也拼不出主话题,`--to g-18127` 会直接 TOPIC_REQUIRED。
|
|
316
355
|
if (routeOpts.to !== undefined && String(routeOpts.to).trim()) {
|
|
317
|
-
|
|
318
|
-
|
|
356
|
+
// 归一后写回 routeOpts:下游 argv 与回执都必须用展开后的完整 AID。
|
|
357
|
+
routeOpts.to = await resolveGroupId(String(routeOpts.to).trim());
|
|
358
|
+
const peerKind = await resolveTargetPeerKind(runtime, routeOpts.to, selfAid);
|
|
359
|
+
deps.resolveTarget = id => ({ channelType: runtime?.channel ?? 'aun', peerKind, id });
|
|
319
360
|
}
|
|
320
361
|
// `--thread main:<a>:<b>` 的对端类型:主话题 id 里只有两个 AID,群的主话题同样写成
|
|
321
362
|
// main:<self>:<群AID>。类型按关系证据解析(与 --to 同一套),再同步注入给纯函数;
|
|
@@ -324,15 +365,17 @@ async function main() {
|
|
|
324
365
|
const topicIds = await loadDist('core/thread/topic-id.js');
|
|
325
366
|
const threadValue = routeOpts.thread.trim();
|
|
326
367
|
const mainPeer = topicIds?.isMainTopicId?.(threadValue)
|
|
327
|
-
? topicIds.mainTopicPeer(threadValue,
|
|
368
|
+
? topicIds.mainTopicPeer(threadValue, selfAid)
|
|
328
369
|
: undefined;
|
|
329
370
|
if (mainPeer) {
|
|
330
|
-
const mainPeerKind = await resolveTargetPeerKind(runtime, mainPeer);
|
|
371
|
+
const mainPeerKind = await resolveTargetPeerKind(runtime, mainPeer, selfAid);
|
|
331
372
|
deps.resolvePeerKind = () => mainPeerKind;
|
|
332
373
|
}
|
|
333
374
|
}
|
|
334
375
|
const needsThreadModule = gateway.needsThreadIndexLookup(routeOpts.thread)
|
|
335
376
|
|| routeOpts.to !== undefined;
|
|
377
|
+
// 话题条目:非托管下它就是「当前会话」的全部来源(对端 / chatType / channelType)。
|
|
378
|
+
let threadEntry;
|
|
336
379
|
if (needsThreadModule) {
|
|
337
380
|
const threadModule = await loadDist('core/thread/thread-service.js');
|
|
338
381
|
if (!threadModule && gateway.needsThreadIndexLookup(routeOpts.thread)) {
|
|
@@ -341,15 +384,16 @@ async function main() {
|
|
|
341
384
|
if (threadModule) {
|
|
342
385
|
let entry;
|
|
343
386
|
try {
|
|
344
|
-
entry = threadModule.ThreadService.findThreadById(
|
|
387
|
+
entry = threadModule.ThreadService.findThreadById(selfAid, routeOpts.thread);
|
|
345
388
|
} catch {
|
|
346
389
|
entry = undefined;
|
|
347
390
|
}
|
|
391
|
+
threadEntry = entry;
|
|
348
392
|
deps.resolveThread = threadId => {
|
|
349
393
|
if (!entry || entry.threadId !== threadId) return undefined;
|
|
350
394
|
return {
|
|
351
395
|
threadId: entry.threadId,
|
|
352
|
-
selfAid
|
|
396
|
+
selfAid,
|
|
353
397
|
peer: {
|
|
354
398
|
channelType: entry.channelType ?? 'aun',
|
|
355
399
|
peerKind: entry.peerKind,
|
|
@@ -361,14 +405,55 @@ async function main() {
|
|
|
361
405
|
// 判定权仍归下游。
|
|
362
406
|
deps.mainSessionExists = peer => {
|
|
363
407
|
try {
|
|
364
|
-
return !!threadModule.ThreadService.findMainSessionEntry(
|
|
408
|
+
return !!threadModule.ThreadService.findMainSessionEntry(selfAid, peer.id);
|
|
365
409
|
} catch {
|
|
366
410
|
return true;
|
|
367
411
|
}
|
|
368
412
|
};
|
|
413
|
+
|
|
414
|
+
// 自发(`--to <本端AID>`)的 `--encrypt auto` 跟随话题上一条消息的加密态。
|
|
415
|
+
// 只读该话题所在 chatDir 的 messages.jsonl 末条,读不到/异常一律按明文。
|
|
416
|
+
const sessionFs = await loadDist('core/session/session-fs-store.js');
|
|
417
|
+
const paths = await loadDist('paths.js');
|
|
418
|
+
deps.resolveLastTopicEncrypt = threadId => {
|
|
419
|
+
if (!entry || entry.threadId !== threadId || !sessionFs?.readAllJsonlLines || !paths?.agentDir) {
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const agentsRoot = path.dirname(paths.agentDir(selfAid));
|
|
424
|
+
const chatDir = sessionFs.chatDirPath(agentsRoot, entry.channelType ?? 'aun', entry.peer, selfAid);
|
|
425
|
+
const lines = sessionFs.readAllJsonlLines(path.join(chatDir, 'messages.jsonl'));
|
|
426
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
427
|
+
const line = lines[index];
|
|
428
|
+
if (!line || line.threadId !== threadId) continue;
|
|
429
|
+
return line.encrypt === true;
|
|
430
|
+
}
|
|
431
|
+
return undefined;
|
|
432
|
+
} catch {
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
};
|
|
369
436
|
}
|
|
370
437
|
}
|
|
371
438
|
|
|
439
|
+
// 非托管:没有会话上下文,本端来自 --from,对端/类型来自话题索引条目。
|
|
440
|
+
// chatType 按条目判(群话题 = group),peerId 用条目里的对端。
|
|
441
|
+
const sessionContext = nonManaged
|
|
442
|
+
? {
|
|
443
|
+
selfAid,
|
|
444
|
+
channelType: threadEntry?.channelType ?? 'aun',
|
|
445
|
+
chatType: threadEntry?.peerKind === 'group' ? 'group' : 'private',
|
|
446
|
+
peerId: threadEntry?.peer ?? '',
|
|
447
|
+
threadId: routing.isThreadTopicId(routeOpts.thread) ? routeOpts.thread : undefined,
|
|
448
|
+
}
|
|
449
|
+
: {
|
|
450
|
+
selfAid: runtime.selfAid,
|
|
451
|
+
channelType: runtime.channel,
|
|
452
|
+
chatType: runtime.chatType === 'group' ? 'group' : 'private',
|
|
453
|
+
peerId: currentPeerIdOf(runtime),
|
|
454
|
+
threadId: routing.isThreadTopicId(runtime.threadId) ? runtime.threadId : undefined,
|
|
455
|
+
};
|
|
456
|
+
|
|
372
457
|
const outcome = routing.resolveSendRoute(
|
|
373
458
|
{
|
|
374
459
|
thread: routeOpts.thread,
|
|
@@ -379,62 +464,80 @@ async function main() {
|
|
|
379
464
|
noEncrypt: routeOpts.noEncrypt === true,
|
|
380
465
|
// auto 的判据:本轮是否带着入站消息的加密态。有该状态说明是回复对端消息,
|
|
381
466
|
// 沿用它的加密方式;没有(如 trigger 唤醒发起)则明文。
|
|
382
|
-
inboundTriggered: runtime
|
|
383
|
-
inboundEncrypted: runtime
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
selfAid: runtime.selfAid,
|
|
387
|
-
channelType: runtime.channel,
|
|
388
|
-
chatType: runtime.chatType === 'group' ? 'group' : 'private',
|
|
389
|
-
peerId: currentPeerIdOf(runtime),
|
|
390
|
-
threadId: routing.isThreadTopicId(runtime.threadId) ? runtime.threadId : undefined,
|
|
467
|
+
inboundTriggered: runtime?.inboundEncrypted !== undefined,
|
|
468
|
+
inboundEncrypted: runtime?.inboundEncrypted === true,
|
|
391
469
|
},
|
|
470
|
+
sessionContext,
|
|
392
471
|
deps,
|
|
393
472
|
);
|
|
394
473
|
|
|
395
474
|
if (!outcome.ok) fail(outcome.message, outcome.code, outcome.hint ? { hint: outcome.hint } : {});
|
|
396
475
|
|
|
397
476
|
// ── 分派 ──
|
|
398
|
-
const dispatch = gateway.decideDispatch(outcome, text, passthrough,
|
|
477
|
+
const dispatch = gateway.decideDispatch(outcome, text, passthrough, sessionContext.channelType);
|
|
399
478
|
if (dispatch.kind === 'reject') {
|
|
400
479
|
fail(dispatch.message, dispatch.code, dispatch.hint ? { hint: dispatch.hint } : {});
|
|
401
480
|
}
|
|
402
481
|
if (dispatch.kind === 'session') {
|
|
482
|
+
if (nonManaged) {
|
|
483
|
+
fail('非托管没有会话级发送通道,请用 --thread 指定话题', 'SESSION_CHANNEL_UNAVAILABLE');
|
|
484
|
+
}
|
|
403
485
|
await dispatchSessionChannel(outcome, text, runtime, sessionId, delegationToken, routing, argv);
|
|
404
486
|
return;
|
|
405
487
|
}
|
|
406
488
|
|
|
407
489
|
const daemonArgv = dispatch.argv;
|
|
408
490
|
|
|
409
|
-
// 委托哈希必须覆盖**实际下发的 argv**:daemon 在 `aun-msg-send` 带 argv 时按
|
|
410
|
-
// `['ec', ...cmd.argv]` 重算并比对(ipc.ts 的 DELEGATED_ARGV_ENDPOINTS 闸门)。
|
|
411
|
-
// 网关下发的 argv 与调用方写的简化式不同(补了 from/to 与加密二态),
|
|
412
|
-
// 拿简化式算哈希必然 command_hash_mismatch。
|
|
413
|
-
if (readDelegatedExecutionSpec([MAIN_CLI_BIN, ...daemonArgv], process.env)) {
|
|
414
|
-
// 被安全输出 helper 包过的调用带执行规格,daemon 侧无对应字段可比对,这里无法绑定。
|
|
415
|
-
fail('ecmsg 不支持在安全输出包装内调用', 'UNSUPPORTED_WRAPPER');
|
|
416
|
-
}
|
|
417
|
-
const delegationCommandHash = hashDelegatedCommandArgv([MAIN_CLI_BIN, ...daemonArgv]);
|
|
418
|
-
|
|
419
491
|
let socketPath;
|
|
492
|
+
let paths;
|
|
420
493
|
try {
|
|
421
|
-
|
|
494
|
+
paths = await loadDist('paths.js');
|
|
422
495
|
socketPath = paths.resolvePaths().socket;
|
|
423
496
|
} catch {
|
|
424
497
|
fail(BUILD_HINT, 'BUILD_REQUIRED');
|
|
425
498
|
}
|
|
426
499
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
:
|
|
437
|
-
|
|
500
|
+
// 非托管:不走 argv(argv 路径必须带委托哈希),改用显式参数 + controlToken。
|
|
501
|
+
// 只有自发(--to 本端)允许走这条,其它目标仍须委托链,由 daemon 侧判定。
|
|
502
|
+
let request;
|
|
503
|
+
if (nonManaged) {
|
|
504
|
+
let controlToken;
|
|
505
|
+
try { controlToken = fs.readFileSync(paths.resolvePaths().controlToken, 'utf8').trim(); } catch { /* 交给 daemon 报错 */ }
|
|
506
|
+
const body = text.join(' ').trim();
|
|
507
|
+
request = {
|
|
508
|
+
type: 'aun-msg-send',
|
|
509
|
+
aid: outcome.self,
|
|
510
|
+
to: outcome.recipientId,
|
|
511
|
+
scope: 'msg',
|
|
512
|
+
thread: outcome.threadId || undefined,
|
|
513
|
+
payload: { type: 'text', text: body },
|
|
514
|
+
encrypt: outcome.encryptResolved,
|
|
515
|
+
controlToken,
|
|
516
|
+
};
|
|
517
|
+
} else {
|
|
518
|
+
// 委托哈希必须覆盖**实际下发的 argv**:daemon 在 `aun-msg-send` 带 argv 时按
|
|
519
|
+
// `['ec', ...cmd.argv]` 重算并比对(ipc.ts 的 DELEGATED_ARGV_ENDPOINTS 闸门)。
|
|
520
|
+
// 网关下发的 argv 与调用方写的简化式不同(补了 from/to 与加密二态),
|
|
521
|
+
// 拿简化式算哈希必然 command_hash_mismatch。
|
|
522
|
+
if (readDelegatedExecutionSpec([MAIN_CLI_BIN, ...daemonArgv], process.env)) {
|
|
523
|
+
// 被安全输出 helper 包过的调用带执行规格,daemon 侧无对应字段可比对,这里无法绑定。
|
|
524
|
+
fail('ecmsg 不支持在安全输出包装内调用', 'UNSUPPORTED_WRAPPER');
|
|
525
|
+
}
|
|
526
|
+
const delegationCommandHash = hashDelegatedCommandArgv([MAIN_CLI_BIN, ...daemonArgv]);
|
|
527
|
+
request = {
|
|
528
|
+
type: 'aun-msg-send',
|
|
529
|
+
argv: daemonArgv,
|
|
530
|
+
delegationToken,
|
|
531
|
+
...(delegationCommandHash ? { delegationCommandHash } : {}),
|
|
532
|
+
originSessionId: sessionId,
|
|
533
|
+
...(runtime.messageId ? { originMessageId: runtime.messageId } : {}),
|
|
534
|
+
...(process.env.EVOLCORE_DAEMON_RUNTIME_EPOCH
|
|
535
|
+
? { daemonRuntimeEpoch: process.env.EVOLCORE_DAEMON_RUNTIME_EPOCH }
|
|
536
|
+
: {}),
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const result = await queryDaemonOnce(socketPath, request);
|
|
438
541
|
|
|
439
542
|
if (!result) fail('无法连接 EvolCore daemon(AUN_DAEMON_UNAVAILABLE)', 'DAEMON_UNAVAILABLE');
|
|
440
543
|
if (!result.ok) {
|
|
@@ -458,12 +561,16 @@ async function main() {
|
|
|
458
561
|
*/
|
|
459
562
|
function renderReceipt(route, result, routing, gateway) {
|
|
460
563
|
const routeLine = routing.formatRouteReceipt(route);
|
|
564
|
+
// 自发(self-address):收件人是本端,`peer` 只是话题归属方,不能当 `to` 回显。
|
|
565
|
+
const selfAddressed = route.recipient === 'self';
|
|
461
566
|
|
|
462
567
|
if (jsonOutput) {
|
|
463
568
|
process.stdout.write(`${JSON.stringify({
|
|
464
569
|
ok: true,
|
|
465
570
|
from: route.self,
|
|
466
|
-
to: route.peer.id,
|
|
571
|
+
to: selfAddressed ? route.recipientId : route.peer.id,
|
|
572
|
+
recipient: route.recipient,
|
|
573
|
+
...(selfAddressed ? { topicPeer: route.peer.id } : {}),
|
|
467
574
|
thread: route.threadId,
|
|
468
575
|
chatType: route.peer.peerKind,
|
|
469
576
|
crossTopic: route.crossTopic,
|
|
@@ -475,8 +582,14 @@ function renderReceipt(route, result, routing, gateway) {
|
|
|
475
582
|
encryptResolved: route.encryptResolved,
|
|
476
583
|
message_id: result.message_id,
|
|
477
584
|
seq: result.seq,
|
|
478
|
-
status
|
|
479
|
-
|
|
585
|
+
// status 是「本地已受理」的稳定口径;传输层的原始状态单独放在 aun_status,
|
|
586
|
+
// 它随消息类型在 sent/delivered/accepted 之间变化,不适合当判据。
|
|
587
|
+
status: 'accepted',
|
|
588
|
+
...(result.status !== undefined ? { aun_status: result.status } : {}),
|
|
589
|
+
...(selfAddressed || result.self_session_id !== undefined || result.self_delivery_error !== undefined ? {
|
|
590
|
+
self_session_id: result.self_session_id,
|
|
591
|
+
self_delivery_error: result.self_delivery_error,
|
|
592
|
+
} : { trigger_id: result.trigger_id }),
|
|
480
593
|
})}\n`);
|
|
481
594
|
return;
|
|
482
595
|
}
|
|
@@ -490,10 +603,27 @@ function renderReceipt(route, result, routing, gateway) {
|
|
|
490
603
|
}
|
|
491
604
|
|
|
492
605
|
const seq = result.seq ?? result.message?.seq ?? '-';
|
|
606
|
+
// 稳定口径:status 恒为 accepted(本地已受理);传输层原始状态放 aun_status。
|
|
607
|
+
const aunStatus = result.status !== undefined ? ` aun_status=${result.status}` : '';
|
|
493
608
|
process.stdout.write(
|
|
494
|
-
`✓ 已发送 ${routeLine} message_id=${result.message_id ?? '-'} seq=${seq} status
|
|
609
|
+
`✓ 已发送 ${routeLine} message_id=${result.message_id ?? '-'} seq=${seq} status=accepted${aunStatus}\n`,
|
|
495
610
|
);
|
|
496
611
|
|
|
612
|
+
// 只要 daemon 报了本地投递失败就必须说出来:会话内回复会被路由成「发给会话对端」,
|
|
613
|
+
// 目标恰好是本端时 recipient 是 peer 而不是 self,只看 route 会把这个失败吞掉。
|
|
614
|
+
if (selfAddressed || result.self_delivery_error !== undefined || result.self_session_id !== undefined) {
|
|
615
|
+
// 自发不建复查(D13),也不该按跨话题的口径提示「已建复查」。
|
|
616
|
+
if (result.self_delivery_error) {
|
|
617
|
+
process.stderr.write(`⚠ 本地投递未完成: ${result.self_delivery_error}\n`);
|
|
618
|
+
process.stderr.write(' AUN 消息已发出(其它设备可见),但本机队列没拿到这条任务。\n');
|
|
619
|
+
} else if (result.self_session_id) {
|
|
620
|
+
process.stdout.write(`✓ 已投给本端队列 session=${result.self_session_id}\n`);
|
|
621
|
+
} else if (selfAddressed) {
|
|
622
|
+
process.stderr.write('⚠ 未返回本地投递结果(self_session_id 缺失)\n');
|
|
623
|
+
}
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
|
|
497
627
|
if (route.firstContact) {
|
|
498
628
|
process.stdout.write('· 首次联系:目标会话随本条建立,本次不建复查\n');
|
|
499
629
|
} else if (route.crossTopic) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
import { atomicWriteJson } from '../core/session/session-fs-store.js';
|
|
5
|
+
import { templateError } from './types.js';
|
|
6
|
+
function stable(value) {
|
|
7
|
+
return JSON.stringify(value, (_key, v) => v && typeof v === 'object' && !Array.isArray(v)
|
|
8
|
+
? Object.fromEntries(Object.keys(v).sort().map(k => [k, v[k]])) : v);
|
|
9
|
+
}
|
|
10
|
+
export function templateFingerprint(value) { return createHash('sha256').update(stable(value)).digest('hex'); }
|
|
11
|
+
export class TemplateJobs {
|
|
12
|
+
root;
|
|
13
|
+
constructor(root) {
|
|
14
|
+
this.root = root;
|
|
15
|
+
fs.mkdirSync(root, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
file(id) {
|
|
18
|
+
if (!/^job_[a-f0-9-]{36}$/.test(id))
|
|
19
|
+
throw templateError('INVALID_ARGUMENT', 'Invalid jobId');
|
|
20
|
+
return path.join(this.root, id + '.json');
|
|
21
|
+
}
|
|
22
|
+
list() {
|
|
23
|
+
return fs.readdirSync(this.root).filter(f => /^job_[a-f0-9-]{36}\.json$/.test(f)).map(f => {
|
|
24
|
+
const value = JSON.parse(fs.readFileSync(path.join(this.root, f), 'utf8'));
|
|
25
|
+
if (!value.jobId || !value.event)
|
|
26
|
+
throw templateError('INSTALL_BROKEN', 'Invalid persisted template job');
|
|
27
|
+
return value;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
save(job) { atomicWriteJson(this.file(job.jobId), job); }
|
|
31
|
+
get(actor, query) {
|
|
32
|
+
const job = query.jobId ? this.list().find(j => j.jobId === query.jobId && j.actor === actor)
|
|
33
|
+
: this.list().find(j => j.requestId === query.requestId && j.actor === actor);
|
|
34
|
+
if (!job || job.event.status !== 'running' && job.updatedAt < Date.now() - 86400_000) {
|
|
35
|
+
throw templateError('NOT_FOUND', 'Template task not found or expired');
|
|
36
|
+
}
|
|
37
|
+
return job;
|
|
38
|
+
}
|
|
39
|
+
accept(actor, aid, requestId, action, args, phase, aids) {
|
|
40
|
+
const fingerprint = templateFingerprint({ action, args });
|
|
41
|
+
const jobs = this.list();
|
|
42
|
+
const original = jobs.find(j => j.actor === actor && (j.requestId === requestId
|
|
43
|
+
|| action === 'deploy' && j.action === action && j.args.pullId === args.pullId
|
|
44
|
+
|| action === 'push' && j.action === action && j.args.buildId === args.buildId && j.event.status === 'running'));
|
|
45
|
+
if (original) {
|
|
46
|
+
if (original.fingerprint !== fingerprint)
|
|
47
|
+
throw templateError('CONFLICT', 'Request or pullId already has different parameters');
|
|
48
|
+
return { job: original, reused: true };
|
|
49
|
+
}
|
|
50
|
+
const jobId = 'job_' + randomUUID();
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
const job = { jobId, actor, aid, ...(aids ? { aids } : {}), action, args, requestId, fingerprint, createdAt: now, updatedAt: now,
|
|
53
|
+
event: { type: 'menu.event', event: 'template.progress', requestId, jobId, seq: 1, phase, status: 'running', message: 'Task accepted' } };
|
|
54
|
+
this.save(job);
|
|
55
|
+
return { job, reused: false };
|
|
56
|
+
}
|
|
57
|
+
update(job, patch) {
|
|
58
|
+
job.updatedAt = Date.now();
|
|
59
|
+
job.event = { ...job.event, ...patch, seq: job.event.seq + 1 };
|
|
60
|
+
this.save(job);
|
|
61
|
+
}
|
|
62
|
+
}
|