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
|
@@ -136,11 +136,22 @@ export function resolveChatModeForPeer(params) {
|
|
|
136
136
|
* invalidateKitCache——schema 换了新的,出厂默认表却永久停在进程启动那一刻。
|
|
137
137
|
*/
|
|
138
138
|
export function chatmodeFactoryDefaults() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
// 默认值挂在 chatmode 的三个子字段上(不接受 chatmode 对象级 default:
|
|
140
|
+
// 对象级默认值会让"整块未配置"变成"整块已配置",见
|
|
141
|
+
// docs/config/11-default-value-levels.md)。
|
|
142
|
+
const children = loadSchema('agent-config').fields.get('chatmode')?.children;
|
|
143
|
+
const field = (name) => {
|
|
144
|
+
const value = children?.get(name)?.default;
|
|
145
|
+
return value === 'interactive' || value === 'proactive' ? value : undefined;
|
|
146
|
+
};
|
|
147
|
+
const privateMode = field('private');
|
|
148
|
+
const nothumanMode = field('nothuman');
|
|
149
|
+
// group 场景只有 proactive 一个合法值,schema 枚举已把这一点固定住。
|
|
150
|
+
const groupMode = field('group') === 'proactive' ? 'proactive' : undefined;
|
|
151
|
+
if (!privateMode || !groupMode || !nothumanMode) {
|
|
152
|
+
throw new Error('[peer-mode] agent-config schema 缺少 chatmode 出厂默认值(chatmode.{private,group,nothuman}.default)');
|
|
142
153
|
}
|
|
143
|
-
return {
|
|
154
|
+
return { private: privateMode, group: groupMode, nothuman: nothumanMode };
|
|
144
155
|
}
|
|
145
156
|
export function chatmodeFieldForPeer(chatType, peerType) {
|
|
146
157
|
const kind = normalizePeerType(peerType);
|
|
@@ -4064,7 +4064,8 @@ export class ResponseEngine {
|
|
|
4064
4064
|
// ─── 响应模式解析(插件化机制中枢)───
|
|
4065
4065
|
// trigger override 绝对优先;否则由 Coordinator 解析(responseMode 标量 > 注册表首选)。
|
|
4066
4066
|
const systemOrServicePeer = isSystemOrServicePeer(peerType);
|
|
4067
|
-
const triggerChatModeOverride = systemOrServicePeer
|
|
4067
|
+
const triggerChatModeOverride = systemOrServicePeer && message.source !== 'trigger'
|
|
4068
|
+
? undefined : message.triggerMeta?.chatModeOverride;
|
|
4068
4069
|
// chatmode 是顶层字典(agent 级与关系级同名,已由 ConfigManager 逐键合并)。
|
|
4069
4070
|
// 实际生效值由对端类型选键(private/nothuman/group),出厂默认走 schema。
|
|
4070
4071
|
const chatModeFallback = resolveChatMode({
|
|
@@ -4077,13 +4078,25 @@ export class ResponseEngine {
|
|
|
4077
4078
|
});
|
|
4078
4079
|
// Resolve overrides before binding a flow so hooks, context and envelope
|
|
4079
4080
|
// all use the same scene-checked mode for this task.
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4081
|
+
// Trigger 轮次的 chatMode 一律沿用会话自身,不按唤醒源的 peerType 判定。
|
|
4082
|
+
// message.peerType 在这里表达的是「谁把我叫醒」(trigger 恒为 system),与
|
|
4083
|
+
// 「这个会话在跟谁说话」正交;拿它走下面的 systemOrServicePeer 分支,会把
|
|
4084
|
+
// agent 对端的会话压成 interactive。真系统会话(记忆整理、daemon 内部)由
|
|
4085
|
+
// systemSession 标记排除,保持原行为。
|
|
4086
|
+
const sessionChatModeSource = message.source === 'trigger'
|
|
4087
|
+
&& !readSystemSessionMarker(session.metadata)
|
|
4088
|
+
? this.resolveEffectiveChatmodeForSession(session, channelKey, message.channelId)
|
|
4089
|
+
: undefined;
|
|
4090
|
+
const effectiveChatMode = triggerChatModeOverride && sessionChatModeSource
|
|
4091
|
+
? chatModeForScene(triggerChatModeOverride, { channelType: currentChannelType, chatType,
|
|
4092
|
+
peerType: session.metadata?.peerType, role: peerRole })
|
|
4093
|
+
: sessionChatModeSource ?? (chatType === 'group'
|
|
4094
|
+
? 'proactive'
|
|
4095
|
+
: systemOrServicePeer
|
|
4096
|
+
? 'interactive'
|
|
4097
|
+
: triggerChatModeOverride
|
|
4098
|
+
? chatModeForScene(triggerChatModeOverride, { channelType: currentChannelType, chatType, peerType, role: peerRole })
|
|
4099
|
+
: chatModeFallback);
|
|
4087
4100
|
const responseModeAgentDir = selfAid ? resolveAgentDir(selfAid) : undefined;
|
|
4088
4101
|
// mentionMode:顶层通用参数(先读出备用,投递/入队策略后续接入)
|
|
4089
4102
|
const mentionMode = effectiveAgentConfig?.mentionMode ?? 'disabled';
|
|
@@ -5846,6 +5859,8 @@ export class ResponseEngine {
|
|
|
5846
5859
|
?? session.metadata?.mentionMode
|
|
5847
5860
|
?? message.mentionMode
|
|
5848
5861
|
?? undefined,
|
|
5862
|
+
// 私聊 @ 策略只从 Agent 级取:没有服务器下发值,也没有关系级覆盖。
|
|
5863
|
+
privateMentionMode: effectiveAgentConfig?.privateMentionMode ?? 'disabled',
|
|
5849
5864
|
groupHistoryAvailable: canUseGroupHistory('ec.group.history'),
|
|
5850
5865
|
clientType: message.clientType || undefined,
|
|
5851
5866
|
permissionMode: effectivePermissionMode,
|
|
@@ -16,13 +16,46 @@ export const MANAGED_SEND_VALUE_FLAGS = [
|
|
|
16
16
|
];
|
|
17
17
|
/** 布尔选项。 */
|
|
18
18
|
export const MANAGED_SEND_BOOLEAN_FLAGS = [
|
|
19
|
-
'--
|
|
19
|
+
'--mention-all',
|
|
20
20
|
];
|
|
21
|
+
/**
|
|
22
|
+
* 三态取值的选项:必须带 `yes|no|auto` 之一,裸写即参数错误。
|
|
23
|
+
*
|
|
24
|
+
* 为什么单独一类:`--encrypt` 曾同时被当成布尔(`ec msg send`)和取值
|
|
25
|
+
* (`ecmsg` 网关)两种东西,于是文档示例 `--encrypt yes` 在托管发送里把
|
|
26
|
+
* `yes` 读成正文,和 `--payload-file` 撞成正文冲突、被判违规直到熔断。
|
|
27
|
+
* 现在三处解析共用这一张表,且只有三态、没有"裸写等价某值"这回事。
|
|
28
|
+
*
|
|
29
|
+
* 不带 `--encrypt` 整个参数时才是默认值 `auto`。
|
|
30
|
+
*/
|
|
31
|
+
export const MANAGED_SEND_TRISTATE_FLAGS = [
|
|
32
|
+
'--encrypt',
|
|
33
|
+
];
|
|
34
|
+
/** `--encrypt` 的合法取值。 */
|
|
35
|
+
export const ENCRYPT_MODES = ['yes', 'no', 'auto'];
|
|
36
|
+
/**
|
|
37
|
+
* 把 `--encrypt` 的取值归一成下游的二态布尔。
|
|
38
|
+
*
|
|
39
|
+
* `auto` 无法在本地判定(要看本轮是否被对端消息触发、以及那条消息的加密态),
|
|
40
|
+
* 因此返回 undefined,交给路由层按 `auto` 语义解析。本函数只接受三态之一,
|
|
41
|
+
* 裸写(undefined)属于参数错误,由调用方在解析阶段拒绝。
|
|
42
|
+
*/
|
|
43
|
+
export function resolveEncryptFlagValue(value) {
|
|
44
|
+
if (value === 'yes')
|
|
45
|
+
return true;
|
|
46
|
+
if (value === 'no')
|
|
47
|
+
return false;
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
/** `--encrypt` 取值是否合法(供各解析点给出统一报错)。 */
|
|
51
|
+
export function isValidEncryptMode(value) {
|
|
52
|
+
return value !== undefined && ENCRYPT_MODES.includes(value);
|
|
53
|
+
}
|
|
21
54
|
/**
|
|
22
55
|
* 网关自己消费、不向下游透传的选项。
|
|
23
56
|
*
|
|
24
|
-
*
|
|
25
|
-
* `--encrypt
|
|
57
|
+
* `--encrypt` 在网关侧就是三态取值参数,解析后向下游下发二态。
|
|
58
|
+
* `--no-encrypt` 已移除:等价写法是 `--encrypt no`。
|
|
26
59
|
*/
|
|
27
60
|
export const GATEWAY_ROUTE_VALUE_FLAGS = [
|
|
28
61
|
'--thread', '--to', '--from', '--check-every', '--encrypt', '--format',
|
|
@@ -40,4 +73,5 @@ export const GATEWAY_FLAG_ALIASES = {};
|
|
|
40
73
|
export const MANAGED_SEND_KNOWN_FLAGS = [
|
|
41
74
|
...MANAGED_SEND_VALUE_FLAGS,
|
|
42
75
|
...MANAGED_SEND_BOOLEAN_FLAGS,
|
|
76
|
+
...MANAGED_SEND_TRISTATE_FLAGS,
|
|
43
77
|
];
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* I5 跨话题必有复查周期(缺省补默认);同话题永不建复查
|
|
19
19
|
* I6 加密默认 auto;只有目标对端是 AUN 时才能加密
|
|
20
20
|
*/
|
|
21
|
-
import { canonicalizeMainTopicId, formatMainTopicId, isExternalTopicThreadId, isMainTopicId, mainTopicPeer, normalizeTopicAid, } from '../thread/topic-id.js';
|
|
21
|
+
import { canonicalizeMainTopicId, formatMainTopicId, isExternalTopicThreadId, isMainTopicId, isSelfTopicPeer, mainTopicPeer, normalizeTopicAid, } from '../thread/topic-id.js';
|
|
22
22
|
// ── 常量 ────────────────────────────────────────────────────────────────
|
|
23
23
|
/** 跨话题缺省复查周期(plan 假设 A1)。改这里即可调整全局节奏。 */
|
|
24
24
|
export const DEFAULT_CROSS_TOPIC_CHECK_EVERY = '20m';
|
|
@@ -98,6 +98,10 @@ function resolveThreadOption(raw, self, deps) {
|
|
|
98
98
|
if (!peerId) {
|
|
99
99
|
return fail('IDENTITY_MISMATCH', `主话题 ${value} 不属于当前本端 ${self}——主话题 id 由本端与对端共同构成`);
|
|
100
100
|
}
|
|
101
|
+
// `main:<本端>:<本端>` 这类自反主话题同样是残缺结构,不能当正常话题投递。
|
|
102
|
+
if (isSelfTopicPeer(peerId, self)) {
|
|
103
|
+
return fail('SELF_PEER_NOT_ALLOWED', `话题对端不能是本端自己(${peerId})`, `跨话题自派请写 --thread <真实对端的话题id> --to ${self}`);
|
|
104
|
+
}
|
|
101
105
|
const threadId = canonicalizeMainTopicId(value) ?? value;
|
|
102
106
|
// 主话题 id 里只有两个 AID,没有类型信息:群的主话题同样写成 main:<self>:<群AID>。
|
|
103
107
|
// 类型由调用方按关系证据注入;没有注入时才按私聊,保持旧行为。
|
|
@@ -112,6 +116,11 @@ function resolveThreadOption(raw, self, deps) {
|
|
|
112
116
|
if (normalizeTopicAid(info.selfAid) !== normalizeTopicAid(self)) {
|
|
113
117
|
return fail('IDENTITY_MISMATCH', `话题 ${value} 的本端是 ${info.selfAid},不是当前会话本端 ${self}`);
|
|
114
118
|
}
|
|
119
|
+
// 历史残题(对端 = 本端)在索引里仍然存在,这里兜住:既有的残缺话题不再能继续发消息。
|
|
120
|
+
// 创建侧的拦截只管新话题,已经建出来的只能靠这一层和 `ec thread delete` 清理。
|
|
121
|
+
if (isSelfTopicPeer(info.peer.id, self)) {
|
|
122
|
+
return fail('SELF_PEER_NOT_ALLOWED', `话题 ${value} 的对端是本端自己(${info.peer.id}),该话题结构残缺,无法投递`, `请用 ec thread delete ${info.peer.id}/${value} 清理后,改以真实对端建话题`);
|
|
123
|
+
}
|
|
115
124
|
return { peer: info.peer, threadId: value };
|
|
116
125
|
}
|
|
117
126
|
return fail('INVALID_THREAD_REF', `--thread 只接受 thread-… 或 main:<aidA>:<aidB>,收到 "${value}"`, '裸对端 AID 不是话题 id;要指定对端请用 --to');
|
|
@@ -265,12 +274,7 @@ export function resolveSendRoute(input, session, deps = {}) {
|
|
|
265
274
|
}
|
|
266
275
|
// 6. 加密
|
|
267
276
|
let encrypt = 'auto';
|
|
268
|
-
if (input.
|
|
269
|
-
return fail('INVALID_ARGUMENT', '--no-encrypt 与 --encrypt 互斥');
|
|
270
|
-
}
|
|
271
|
-
if (input.noEncrypt === true)
|
|
272
|
-
encrypt = 'no';
|
|
273
|
-
else if (input.encrypt !== undefined) {
|
|
277
|
+
if (input.encrypt !== undefined) {
|
|
274
278
|
if (!['yes', 'no', 'auto'].includes(input.encrypt)) {
|
|
275
279
|
return fail('INVALID_ARGUMENT', `--encrypt 只接受 yes|no|auto,收到 ${input.encrypt}`);
|
|
276
280
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* owns refreshes and snapshots. Runners in the daemon use that same instance.
|
|
4
4
|
*/
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import { clearRuntimeBaseagentModelDefaults } from '../../agents/baseagent.js';
|
|
6
|
+
import { listSupportedBaseagents, clearRuntimeBaseagentModelDefaults } from '../../agents/baseagent.js';
|
|
7
7
|
import { buildModelRequestHeaders } from '../../agents/request-identity.js';
|
|
8
8
|
import { activeBaseagent } from './config-scope.js';
|
|
9
9
|
import { resolveEffective } from '../../config/config-manager.js';
|
|
@@ -80,10 +80,10 @@ const service = new ModelCatalogService({
|
|
|
80
80
|
legacyAliasFile: () => resolvePaths().claudeModelCache,
|
|
81
81
|
native: async (context) => (await import('../../agents/codex/catalog.js')).codexNativeCatalog(context),
|
|
82
82
|
});
|
|
83
|
-
const
|
|
83
|
+
const hostBaseagents = () => listSupportedBaseagents();
|
|
84
84
|
function resolveProviderCatalogBaseagent(serviceType, requested) {
|
|
85
85
|
const baseagent = requested ?? (['claude', 'codex', 'gemini'].includes(serviceType) ? serviceType : '');
|
|
86
|
-
if (baseagent && (!
|
|
86
|
+
if (baseagent && (!hostBaseagents().includes(baseagent)
|
|
87
87
|
|| !providerServiceTypesForBaseagent(baseagent).includes(serviceType))) {
|
|
88
88
|
throw new Error(`Baseagent ${baseagent} is incompatible with provider service ${serviceType}`);
|
|
89
89
|
}
|
|
@@ -170,8 +170,8 @@ export function resolveCatalogContext(self, ba) {
|
|
|
170
170
|
}
|
|
171
171
|
/** Query the catalog for a host-level default connection, without Agent scope. */
|
|
172
172
|
export async function getBaseagentCatalog(baseagent, options = {}) {
|
|
173
|
-
if (!
|
|
174
|
-
throw Object.assign(new Error(`Invalid baseagent: ${baseagent}. Valid: ${
|
|
173
|
+
if (!hostBaseagents().includes(baseagent)) {
|
|
174
|
+
throw Object.assign(new Error(`Invalid baseagent: ${baseagent}. Valid: ${hostBaseagents().join(', ')}`), { code: 'INVALID_ARGUMENT' });
|
|
175
175
|
}
|
|
176
176
|
const normalized = baseagent;
|
|
177
177
|
const snapshot = await getCatalog(undefined, normalized, options.refresh === true);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createHash, randomUUID } from 'crypto';
|
|
4
|
-
import { agentMdPath, agentOwnerBindingRejectionPath, ownershipCachePath
|
|
4
|
+
import { agentMdPath, agentOwnerBindingRejectionPath, ownershipCachePath } from '../../paths.js';
|
|
5
5
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
6
|
-
import { atomicReadJson } from '../../utils/atomic-write.js';
|
|
7
|
-
import { configuredOwnerList as readConfiguredOwnerList } from '../../config/owner-config.js';
|
|
8
6
|
import { logger, logOwnershipEvent, ownershipErrorCode } from '../../utils/logger.js';
|
|
9
7
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
10
8
|
import { registerContent, verifyFile } from '../file-integrity/store.js';
|
|
@@ -65,9 +63,6 @@ export class OwnerResolver {
|
|
|
65
63
|
subjects = new Map();
|
|
66
64
|
authorizationChecks = new Map();
|
|
67
65
|
daemonAid;
|
|
68
|
-
/** Compatibility binding targets loaded from config; never an Owner authorization source. */
|
|
69
|
-
configuredOwners = new Map();
|
|
70
|
-
configuredOwnerFileRevision = new Map();
|
|
71
66
|
listeners = new Set();
|
|
72
67
|
updateListeners = new Set();
|
|
73
68
|
cacheFile;
|
|
@@ -196,6 +191,9 @@ export class OwnerResolver {
|
|
|
196
191
|
}
|
|
197
192
|
subject.view = { ...JSON.parse(JSON.stringify(cached)), connected: subject.view.connected };
|
|
198
193
|
this.rememberVerifiedRelation(subject);
|
|
194
|
+
// Restoring a restart snapshot changes readiness just like a network result.
|
|
195
|
+
// Cache hits must wake observers even when no consensus query runs.
|
|
196
|
+
this.notifyUpdate(subjectAid);
|
|
199
197
|
}
|
|
200
198
|
persistCache(subject, invalidate = false) {
|
|
201
199
|
// The daemon is the sole production writer. Short-lived CLI processes may read, never replace its snapshot.
|
|
@@ -250,47 +248,12 @@ export class OwnerResolver {
|
|
|
250
248
|
logger.warn(`[ownership] Cache write failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
|
-
setConfiguredOwners(subjectAid, owners) {
|
|
254
|
-
this.assertAid(subjectAid);
|
|
255
|
-
const normalized = [...new Set(owners
|
|
256
|
-
.map(owner => String(owner || '').trim())
|
|
257
|
-
.filter(owner => isValidAid(owner) && owner !== subjectAid))];
|
|
258
|
-
const previous = this.configuredOwners.get(subjectAid) ?? [];
|
|
259
|
-
if (JSON.stringify(previous) === JSON.stringify(normalized))
|
|
260
|
-
return;
|
|
261
|
-
if (normalized.length > 0)
|
|
262
|
-
this.configuredOwners.set(subjectAid, normalized);
|
|
263
|
-
else
|
|
264
|
-
this.configuredOwners.delete(subjectAid);
|
|
265
|
-
const subject = this.subjects.get(subjectAid);
|
|
266
|
-
// Retiring compatibility targets must not invalidate the freshly verified protocol Owner.
|
|
267
|
-
const removesConfirmedTargets = normalized.length === 0 && subject?.view.consensusStatus === 'consensus'
|
|
268
|
-
&& this.isCacheFresh(subject, OWNERSHIP_AUTHORIZATION_MAX_AGE_MS);
|
|
269
|
-
if (subject && !removesConfirmedTargets) {
|
|
270
|
-
this.invalidate(subject, 'Configured Owners changed; fresh consensus is required', true);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
setAgentConfiguredOwners(subjectAid, owners) {
|
|
274
|
-
this.assertAid(subjectAid);
|
|
275
|
-
if (subjectAid === this.daemonAid)
|
|
276
|
-
return;
|
|
277
|
-
this.setConfiguredOwners(subjectAid, owners);
|
|
278
|
-
}
|
|
279
|
-
configuredOwnerList(subjectAid) {
|
|
280
|
-
if (!subjectAid)
|
|
281
|
-
return [];
|
|
282
|
-
this.refreshConfiguredOwnersFromDisk(subjectAid);
|
|
283
|
-
return [...(this.configuredOwners.get(subjectAid) ?? [])];
|
|
284
|
-
}
|
|
285
251
|
isOwner(subjectAid, ownerAid) {
|
|
286
252
|
if (!subjectAid || !ownerAid)
|
|
287
253
|
return false;
|
|
288
254
|
if (subjectAid === ownerAid && this.owner(subjectAid) === subjectAid)
|
|
289
255
|
return true;
|
|
290
|
-
|
|
291
|
-
return true;
|
|
292
|
-
return !this.hasObservedProtocolConsensus(subjectAid)
|
|
293
|
-
&& this.configuredOwnerList(subjectAid).includes(ownerAid);
|
|
256
|
+
return this.protocolOwners(subjectAid).includes(ownerAid);
|
|
294
257
|
}
|
|
295
258
|
assertLocalSubject(subjectAid) {
|
|
296
259
|
this.assertAid(subjectAid);
|
|
@@ -477,7 +440,11 @@ export class OwnerResolver {
|
|
|
477
440
|
const protocol = this.protocolOwners(subjectAid);
|
|
478
441
|
if (protocol.length > 0 || this.hasObservedProtocolConsensus(subjectAid))
|
|
479
442
|
return protocol;
|
|
480
|
-
|
|
443
|
+
// Ownership is granted by the ownership protocol only. A configured value
|
|
444
|
+
// is a binding target and never an authorization source — not for Agents,
|
|
445
|
+
// and not for the daemon's own control identity. Until consensus exists the
|
|
446
|
+
// daemon has no Owner and its control surface stays closed.
|
|
447
|
+
return [];
|
|
481
448
|
}
|
|
482
449
|
protocolOwners(subjectAid) {
|
|
483
450
|
const owner = this.owner(subjectAid);
|
|
@@ -496,6 +463,7 @@ export class OwnerResolver {
|
|
|
496
463
|
primaryOwner(subjectAid) {
|
|
497
464
|
return this.owners(subjectAid)[0];
|
|
498
465
|
}
|
|
466
|
+
/** Owners already established by protocol evidence. Configured values never qualify. */
|
|
499
467
|
knownOwners(subjectAid) {
|
|
500
468
|
if (!subjectAid)
|
|
501
469
|
return [];
|
|
@@ -505,9 +473,7 @@ export class OwnerResolver {
|
|
|
505
473
|
const relation = this.subjects.get(subjectAid)?.view.relation;
|
|
506
474
|
if (relation?.consensusStatus === 'consensus' && relation.ownerAid)
|
|
507
475
|
return [relation.ownerAid];
|
|
508
|
-
|
|
509
|
-
return [];
|
|
510
|
-
return this.configuredOwnerList(subjectAid);
|
|
476
|
+
return [];
|
|
511
477
|
}
|
|
512
478
|
knownOwner(subjectAid) {
|
|
513
479
|
return this.knownOwners(subjectAid)[0];
|
|
@@ -515,16 +481,12 @@ export class OwnerResolver {
|
|
|
515
481
|
daemonOwners() {
|
|
516
482
|
return this.owners(this.daemonAid);
|
|
517
483
|
}
|
|
518
|
-
configuredRevision(subjectAid) {
|
|
519
|
-
return JSON.stringify(this.configuredOwnerList(subjectAid));
|
|
520
|
-
}
|
|
521
484
|
revision(subjectAid) {
|
|
522
485
|
const view = this.subjects.get(subjectAid)?.view;
|
|
523
486
|
return JSON.stringify([
|
|
524
487
|
view?.revision ?? 0,
|
|
525
488
|
this.owner(subjectAid),
|
|
526
489
|
view?.consensusStatus ?? 'unavailable',
|
|
527
|
-
this.configuredOwnerList(subjectAid),
|
|
528
490
|
]);
|
|
529
491
|
}
|
|
530
492
|
snapshot(subjectAid) {
|
|
@@ -545,7 +507,6 @@ export class OwnerResolver {
|
|
|
545
507
|
async refresh(subjectAid, options = {}) {
|
|
546
508
|
const subject = this.subject(subjectAid);
|
|
547
509
|
this.restoreCache(subjectAid, subject);
|
|
548
|
-
this.refreshConfiguredOwnersFromDisk(subjectAid);
|
|
549
510
|
const inFlight = subject.refreshing?.epoch === subject.epoch ? subject.refreshing : undefined;
|
|
550
511
|
const refreshing = inFlight?.promise;
|
|
551
512
|
const initialEpoch = subject.epoch;
|
|
@@ -567,14 +528,12 @@ export class OwnerResolver {
|
|
|
567
528
|
.filter(frame => !/\/core\/ownership\/owner-resolver\.[cm]?[jt]s:/.test(frame))
|
|
568
529
|
.map(frame => frame.match(/\/((?:src|dist)\/[a-zA-Z0-9_./-]+\.[cm]?[jt]s:\d+:\d+)/)?.[1])
|
|
569
530
|
.find(frame => !!frame);
|
|
570
|
-
const configuredOwners = this.configuredOwnerList(subjectAid);
|
|
571
531
|
const diagnostic = inFlight?.diagnostic ?? {
|
|
572
532
|
startedAt: performance.now(), source: options.source ?? 'direct', caller,
|
|
573
533
|
attemptId, processId: process.pid, connected: subject.view.connected,
|
|
574
534
|
sdkReady: subject.client?.isReady === true,
|
|
575
535
|
force: !!options.force, maxAgeMs, timeoutMs: this.options.timeoutMs ?? 8_000,
|
|
576
536
|
firstObservation: !subject.view.consensus, previousConsensusStatus: subject.view.consensusStatus,
|
|
577
|
-
configuredOwnerAid: configuredOwners[0], configuredOwnerCount: configuredOwners.length,
|
|
578
537
|
};
|
|
579
538
|
const promise = refreshing ?? this.refreshSubject(subjectAid, subject, attemptId, attemptedAt, diagnostic, options);
|
|
580
539
|
subject.refreshing = { epoch: subject.epoch, attemptId, attemptedAt, diagnostic, promise };
|
|
@@ -1207,8 +1166,6 @@ export class OwnerResolver {
|
|
|
1207
1166
|
for (const subjectAid of this.subjects.keys())
|
|
1208
1167
|
this.detachClient(subjectAid);
|
|
1209
1168
|
this.subjects.clear();
|
|
1210
|
-
this.configuredOwners.clear();
|
|
1211
|
-
this.configuredOwnerFileRevision.clear();
|
|
1212
1169
|
this.authorizationChecks.clear();
|
|
1213
1170
|
this.cacheEntries.clear();
|
|
1214
1171
|
this.cacheFile = undefined;
|
|
@@ -1758,8 +1715,6 @@ export class OwnerResolver {
|
|
|
1758
1715
|
const rootScope = this.options.cachePath?.() ?? ownershipCachePath();
|
|
1759
1716
|
if (this.rootScope && this.rootScope !== rootScope) {
|
|
1760
1717
|
this.subjects.clear();
|
|
1761
|
-
this.configuredOwners.clear();
|
|
1762
|
-
this.configuredOwnerFileRevision.clear();
|
|
1763
1718
|
this.authorizationChecks.clear();
|
|
1764
1719
|
}
|
|
1765
1720
|
this.rootScope = rootScope;
|
|
@@ -1838,34 +1793,6 @@ export class OwnerResolver {
|
|
|
1838
1793
|
now() {
|
|
1839
1794
|
return this.options.now?.() ?? Date.now();
|
|
1840
1795
|
}
|
|
1841
|
-
refreshConfiguredOwnersFromDisk(subjectAid) {
|
|
1842
|
-
const file = subjectAid === this.daemonAid
|
|
1843
|
-
? resolvePaths().daemonConfig
|
|
1844
|
-
: path.join(resolvePaths().agentsDir, subjectAid, 'config.json');
|
|
1845
|
-
let revision = 'missing';
|
|
1846
|
-
try {
|
|
1847
|
-
const stat = fs.statSync(file);
|
|
1848
|
-
revision = `${stat.size}:${stat.mtimeMs}`;
|
|
1849
|
-
}
|
|
1850
|
-
catch { }
|
|
1851
|
-
if (this.configuredOwnerFileRevision.get(subjectAid) === revision)
|
|
1852
|
-
return;
|
|
1853
|
-
const hadFileRevision = this.configuredOwnerFileRevision.has(subjectAid);
|
|
1854
|
-
this.configuredOwnerFileRevision.set(subjectAid, revision);
|
|
1855
|
-
if (revision === 'missing') {
|
|
1856
|
-
if (hadFileRevision)
|
|
1857
|
-
this.setConfiguredOwners(subjectAid, []);
|
|
1858
|
-
return;
|
|
1859
|
-
}
|
|
1860
|
-
try {
|
|
1861
|
-
const raw = atomicReadJson(file);
|
|
1862
|
-
this.setConfiguredOwners(subjectAid, readConfiguredOwnerList(raw));
|
|
1863
|
-
}
|
|
1864
|
-
catch {
|
|
1865
|
-
// The regular config loader reports malformed files; keep this optional
|
|
1866
|
-
// compatibility read fail-closed without interrupting ownership checks.
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
1796
|
assertAid(aid) {
|
|
1870
1797
|
if (!isValidAid(aid) || aid.trim() !== aid)
|
|
1871
1798
|
throw new OwnershipError('INVALID_AID', `Invalid AID: ${aid}`);
|
|
@@ -1988,7 +1915,6 @@ export const getProtocolOwner = (subjectAid) => ownerResolver.owner(subjectAid);
|
|
|
1988
1915
|
export const getPrimaryOwner = (subjectAid) => ownerResolver.primaryOwner(subjectAid);
|
|
1989
1916
|
export const getProtocolOwners = (subjectAid) => ownerResolver.protocolOwners(subjectAid);
|
|
1990
1917
|
export const getOwners = (subjectAid) => ownerResolver.owners(subjectAid);
|
|
1991
|
-
export const getConfiguredOwners = (subjectAid) => ownerResolver.configuredOwnerList(subjectAid);
|
|
1992
1918
|
export const getDaemonOwners = () => ownerResolver.daemonOwners();
|
|
1993
1919
|
export function resolveContextOwner(selfAid, directoryOwnerAid) {
|
|
1994
1920
|
const ownerAid = selfAid ? getProtocolOwner(selfAid) : undefined;
|
package/dist/core/pack-auth.js
CHANGED
|
@@ -209,6 +209,10 @@ const PACK_OPERATIONS = {
|
|
|
209
209
|
// AID 级总闸:整机是否对外提供本 AID 的服务。
|
|
210
210
|
enable: 'switch',
|
|
211
211
|
disable: 'switch',
|
|
212
|
+
// 宿主模式总闸。与 enable/disable 同档:它虽然不改"接不接活",但决定脚本以
|
|
213
|
+
// 什么隔离形态执行(常驻进程跨调用共享内存),属于整机执行面决策,不是包级配置。
|
|
214
|
+
'host:enable': 'switch',
|
|
215
|
+
'host:disable': 'switch',
|
|
212
216
|
'pack:list': 'view',
|
|
213
217
|
'pack:add': 'manage',
|
|
214
218
|
'pack:remove': 'manage',
|