evolcore 0.0.43-test.2 → 0.0.43-test.3
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 +8 -1
- package/dist/agents/ecagent-runner.js +13 -6
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/channels/aun.js +79 -48
- package/dist/channels/daemon.js +4 -0
- package/dist/cli/agent-create.js +3 -5
- package/dist/cli/aun-commands.js +17 -19
- package/dist/cli/directory.js +101 -56
- package/dist/cli/index.js +1 -1
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/config/access-policy.js +0 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +5 -0
- package/dist/config/config-manager.js +25 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +26 -2
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +17 -0
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/command-handler.js +39 -3
- package/dist/core/command/menu-catalog.js +13 -0
- package/dist/core/command/menu-handler.js +59 -9
- package/dist/core/command/menu-protocol.js +8 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +48 -21
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent.js +5 -4
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/message/aun-ipc-sender.js +30 -24
- package/dist/core/message/contact-admission.js +1 -19
- package/dist/core/message/im-renderer.js +64 -28
- package/dist/core/message/message-admission.js +15 -65
- package/dist/core/message/message-bridge.js +18 -5
- package/dist/core/message/message-utils.js +9 -0
- package/dist/core/message/peer-mode.js +16 -8
- package/dist/core/message/response-engine.js +56 -35
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +24 -10
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +4 -3
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/owner-directory-admission.js +0 -3
- package/dist/directory/owner-directory-cache.js +197 -15
- package/dist/directory/owner-directory-markdown.js +44 -21
- package/dist/directory/owner-directory-policy.js +1 -1
- package/dist/directory/owner-directory-query-operation.js +219 -97
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +76 -23
- package/dist/directory/owner-directory-store.js +5 -38
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +6 -3
- package/dist/eck/message-renderer.js +2 -5
- package/dist/ecweb/message-context-service.js +4 -0
- package/dist/index.js +11 -0
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/scheduler.js +8 -3
- package/dist/utils/error-utils.js +7 -5
- package/ecagent/README.md +18 -0
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +2 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +7 -3
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/schemas/_meta.json +16 -3
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/templates/soul/00-GUIDE.md +20 -42
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/directory-contacts.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -17
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +2 -2
- package/dist/eck/paactive-context.js +0 -45
- package/dist/response-system/engines/v1/paactive-flow.js +0 -18
- package/kits/eck_manifest.paactive.json +0 -528
- package/kits/eck_message_manifest.paactive.json +0 -233
- package/kits/templates/message-fragments/paactive/item.md +0 -3
- package/kits/templates/system-fragments/paactive/channel.md +0 -25
- package/kits/templates/system-fragments/paactive/reply.md +0 -25
- package/kits/templates/system-fragments/paactive/session.md +0 -32
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
import { agentConfig } from '../paths.js';
|
|
4
|
+
import { isValidAid } from '../aun/aid/validation.js';
|
|
5
|
+
import { FRIEND_INVITE_TTL_MS } from '../core/message/contact-admission.js';
|
|
6
|
+
import { DirectoryQueryError } from './owner-directory-query-operation.js';
|
|
7
|
+
/** Submit the App-owned invitation protocol without mutating the directory or access policy. */
|
|
8
|
+
export function resolveDirectoryRequestCommand(argv) {
|
|
9
|
+
if (argv[0] !== 'request')
|
|
10
|
+
throw new DirectoryQueryError('INVALID_ACTION', 'directory request is required');
|
|
11
|
+
const values = new Map();
|
|
12
|
+
const positionals = [];
|
|
13
|
+
for (let index = 1; index < argv.length; index++) {
|
|
14
|
+
const token = argv[index];
|
|
15
|
+
if (!token.startsWith('-')) {
|
|
16
|
+
positionals.push(token);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (!['--self', '--note', '--format'].includes(token)) {
|
|
20
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', `未知 request 参数: ${token}`);
|
|
21
|
+
}
|
|
22
|
+
const value = argv[++index];
|
|
23
|
+
if (values.has(token) || !value?.trim() || value.startsWith('--')) {
|
|
24
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', `${token} 必须提供非空值,且不能重复`);
|
|
25
|
+
}
|
|
26
|
+
values.set(token, value.trim());
|
|
27
|
+
}
|
|
28
|
+
const selfAid = values.get('--self') ?? process.env.EVOLCORE_SELF_AID?.trim();
|
|
29
|
+
if (!selfAid || !isValidAid(selfAid)) {
|
|
30
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '--self <agent-aid> 必须是有效的本端 Agent AID');
|
|
31
|
+
}
|
|
32
|
+
if (positionals.length !== 1 || !isValidAid(positionals[0])) {
|
|
33
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '用法: ec directory request <target-aid> --self <agent-aid> [--note <申请说明>]');
|
|
34
|
+
}
|
|
35
|
+
if (positionals[0] === selfAid) {
|
|
36
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '不能向本 Agent 自己发送好友申请');
|
|
37
|
+
}
|
|
38
|
+
const format = values.get('--format');
|
|
39
|
+
if (format !== undefined && format !== 'json' && format !== 'text') {
|
|
40
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '--format 仅支持 text|json');
|
|
41
|
+
}
|
|
42
|
+
const note = values.get('--note');
|
|
43
|
+
if (note?.includes('\0')) {
|
|
44
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '申请说明不能包含 NUL');
|
|
45
|
+
}
|
|
46
|
+
return { action: 'request', selfAid, targetAid: positionals[0], ...(note ? { note } : {}) };
|
|
47
|
+
}
|
|
48
|
+
export async function executeDirectoryRequestCommand(command, send) {
|
|
49
|
+
if (!fs.existsSync(agentConfig(command.selfAid))) {
|
|
50
|
+
return { ok: false, code: 'AGENT_NOT_FOUND', error: `Agent 不存在: ${command.selfAid}` };
|
|
51
|
+
}
|
|
52
|
+
const createdAt = Date.now();
|
|
53
|
+
const payload = {
|
|
54
|
+
type: 'friend.invite.v1',
|
|
55
|
+
schema_version: 1,
|
|
56
|
+
invite_id: `friend-invite-${crypto.randomUUID()}`,
|
|
57
|
+
applicant_aid: command.selfAid,
|
|
58
|
+
target_aid: command.targetAid,
|
|
59
|
+
created_at_ms: createdAt,
|
|
60
|
+
expires_at_ms: createdAt + FRIEND_INVITE_TTL_MS,
|
|
61
|
+
introduction: command.note ?? '你好,我想添加你为联系人。',
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const result = await send({ from: command.selfAid, to: command.targetAid, payload, encrypt: true });
|
|
65
|
+
if (!result.ok || !result.message_id) {
|
|
66
|
+
return { ok: false, code: String(result.code ?? 'FRIEND_INVITE_FAILED'),
|
|
67
|
+
error: `向目标 ${command.targetAid} 发送加好友申请失败:${result.error ?? '未获得消息发送回执'}` };
|
|
68
|
+
}
|
|
69
|
+
return { ok: true, action: 'request', selfAid: command.selfAid, targetAid: command.targetAid,
|
|
70
|
+
status: 'sent', message_id: result.message_id };
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return { ok: false, code: 'FRIEND_INVITE_FAILED',
|
|
74
|
+
error: `向目标 ${command.targetAid} 发送加好友申请失败:${error instanceof Error ? error.message : String(error)}` };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -40,6 +40,27 @@ export function isMessagingType(type) {
|
|
|
40
40
|
export function ownerRefAid(snapshot, fallbackOwnerAid) {
|
|
41
41
|
return snapshot?.owner?.aid ?? fallbackOwnerAid;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 归属是否经过双边核验。
|
|
45
|
+
*
|
|
46
|
+
* 协议里 `ownership_status` 只有 `owned` / `unknown`:`owned` 表示 Owner 侧已经
|
|
47
|
+
* 通过 Ownership 共识确认了这条与自己的绑定关系,`unknown`(以及缺字段)都表示
|
|
48
|
+
* **没能确认**。内外判定和注入都只认 `owned`——否则一个 Agent 只要在名录里
|
|
49
|
+
* 把 `owner_aid` 写成我们的 Owner,就能拿到内部联系人的默认放行。
|
|
50
|
+
*/
|
|
51
|
+
export function isOwnershipVerified(entry) {
|
|
52
|
+
return (entry.ownership_status ?? '').trim().toLowerCase() === 'owned';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 这条主体要不要过双边归属门禁。
|
|
56
|
+
*
|
|
57
|
+
* 只对 `type=agent` 生效:会自称“我是某某的 Agent”并据此索取内部待遇的是 Agent,
|
|
58
|
+
* 双边核验要拦的也是它。人类联系人由 Owner 在名录里直接维护,`owner_aid` 本身
|
|
59
|
+
* 就是 Owner 的明确指派;其余非消息类型(host/device/service…)不参与消息准入。
|
|
60
|
+
*/
|
|
61
|
+
function requiresOwnershipVerification(entry) {
|
|
62
|
+
return (entry.type ?? '').trim().toLowerCase() === 'agent';
|
|
63
|
+
}
|
|
43
64
|
/** 条目的 Owner AID;缺失返回 undefined。 */
|
|
44
65
|
export function entryOwnerAid(entry) {
|
|
45
66
|
const value = entry.ownerAid?.trim();
|
|
@@ -64,11 +85,21 @@ export function classifyEntry(entry, ownerRef) {
|
|
|
64
85
|
const owner = entryOwnerAid(entry);
|
|
65
86
|
if (owner === undefined)
|
|
66
87
|
return type === 'agent' ? 'unbound_agent' : 'external_human';
|
|
67
|
-
if (owner === ownerRef)
|
|
68
|
-
|
|
88
|
+
if (owner === ownerRef) {
|
|
89
|
+
const verified = !requiresOwnershipVerification(entry) || isOwnershipVerified(entry);
|
|
90
|
+
return verified ? 'internal' : 'unverified';
|
|
91
|
+
}
|
|
69
92
|
return type === 'agent' ? 'external_agent' : 'external_human';
|
|
70
93
|
}
|
|
71
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* 条目是否属于本 Owner(内部联系人)。
|
|
96
|
+
*
|
|
97
|
+
* agent 类型必须同时满足 `owner_aid` 匹配与双边核验;只看 `owner_aid` 会让一条
|
|
98
|
+
* 自称归属、实际未核验的 Agent 拿到内部联系人的默认放行。人类与其他非消息类型
|
|
99
|
+
* 以 `owner_aid` 为准(见 `requiresOwnershipVerification`)。
|
|
100
|
+
*/
|
|
72
101
|
export function isInternalEntry(entry, ownerRef) {
|
|
73
|
-
|
|
102
|
+
if (entryOwnerAid(entry) !== ownerRef)
|
|
103
|
+
return false;
|
|
104
|
+
return !requiresOwnershipVerification(entry) || isOwnershipVerified(entry);
|
|
74
105
|
}
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* 中文没有词边界,一律按子串匹配,不做分词。查询串按空白切成 token,
|
|
9
9
|
* **所有 token 都要命中**(AND),总分是每个 token 最佳命中字段的分数之和。
|
|
10
10
|
*/
|
|
11
|
-
import { isInternalEntry, ownerRefAid } from './owner-directory-scope.js';
|
|
11
|
+
import { isInternalEntry, isOwnershipVerified, ownerRefAid, } from './owner-directory-scope.js';
|
|
12
|
+
import { normalizeDirectoryText, stripTrailingParenthetical, } from './owner-directory-text.js';
|
|
12
13
|
const DEFAULT_LIMIT = 5;
|
|
13
14
|
const MAX_LIMIT = 50;
|
|
14
15
|
/** 各命中方式的权重。分数用于排序,不承诺对外稳定,调用方只看相对顺序。 */
|
|
@@ -94,25 +95,31 @@ export function searchDirectory(snapshot, ownerAid, remarks, options) {
|
|
|
94
95
|
return hits.slice(0, limit);
|
|
95
96
|
}
|
|
96
97
|
function scoreToken(token, entry, remark, localNote) {
|
|
97
|
-
const aid = entry.aid
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
98
|
+
const aid = normalizeDirectoryText(entry.aid);
|
|
99
|
+
const rawName = normalizeDirectoryText(entry.name);
|
|
100
|
+
// 名字比较忽略结尾括号称呼:`李文江(研发)` 与 `李文江` 是同一个人。
|
|
101
|
+
const name = normalizeDirectoryText(stripTrailingParenthetical(rawName));
|
|
102
|
+
const exttype = normalizeDirectoryText(entry.exttype ?? '');
|
|
103
|
+
const type = normalizeDirectoryText(entry.type ?? '');
|
|
104
|
+
const baseagent = normalizeDirectoryText(entry.baseagent ?? '');
|
|
102
105
|
if (aid === token)
|
|
103
106
|
return { score: WEIGHT.exactAid, field: 'aid' };
|
|
104
|
-
if (name === token)
|
|
107
|
+
if (name === token || rawName === token)
|
|
105
108
|
return { score: WEIGHT.exactName, field: 'name' };
|
|
106
109
|
if (aid.startsWith(token) || name.startsWith(token))
|
|
107
110
|
return { score: WEIGHT.prefix, field: 'prefix' };
|
|
108
111
|
// 任何叫法精确命中都算:名录名、Owner 写的备注名、自己记的每一个称呼。
|
|
109
|
-
const localAliases = remark?.aliases ?? (remark?.remark ? [remark.remark] : [])
|
|
110
|
-
|
|
112
|
+
const localAliases = (remark?.aliases ?? (remark?.remark ? [remark.remark] : []))
|
|
113
|
+
.map(alias => normalizeDirectoryText(alias));
|
|
114
|
+
if (localAliases.some(alias => alias === token || normalizeDirectoryText(stripTrailingParenthetical(alias)) === token)) {
|
|
111
115
|
return { score: WEIGHT.exactRemark, field: 'remark' };
|
|
112
116
|
}
|
|
113
|
-
|
|
117
|
+
const ownerRemark = normalizeDirectoryText(entry.remark ?? '');
|
|
118
|
+
if (ownerRemark && (ownerRemark === token || normalizeDirectoryText(stripTrailingParenthetical(ownerRemark)) === token)) {
|
|
114
119
|
return { score: WEIGHT.exactRemark, field: 'ownerRemark' };
|
|
115
|
-
|
|
120
|
+
}
|
|
121
|
+
// AID 的域段先于普通包含判定:`list --filter agentid.cn` 是"列出这个域",
|
|
122
|
+
// 不是"名字里有这段字"。
|
|
116
123
|
const domain = aid.slice(aid.indexOf('.') + 1);
|
|
117
124
|
if (domain.includes(token))
|
|
118
125
|
return { score: WEIGHT.domainContains, field: 'domain' };
|
|
@@ -120,23 +127,63 @@ function scoreToken(token, entry, remark, localNote) {
|
|
|
120
127
|
return { score: WEIGHT.contains, field: 'name' };
|
|
121
128
|
if (exttype === token || baseagent === token)
|
|
122
129
|
return { score: WEIGHT.exactExttype, field: 'exttype' };
|
|
123
|
-
if (entry.description && entry.description
|
|
130
|
+
if (entry.description && normalizeDirectoryText(entry.description).includes(token)) {
|
|
124
131
|
return { score: WEIGHT.descriptionContains, field: 'description' };
|
|
125
132
|
}
|
|
126
133
|
// 本地备注正文与远端描述并列参与:它是 PA 自己记的"什么事该找他",是找人的主要线索之一。
|
|
127
|
-
if (localNote && localNote
|
|
134
|
+
if (localNote && normalizeDirectoryText(localNote).includes(token)) {
|
|
128
135
|
return { score: WEIGHT.descriptionContains, field: 'localNote' };
|
|
129
136
|
}
|
|
130
|
-
if (localAliases.some(alias => alias.
|
|
137
|
+
if (localAliases.some(alias => alias.includes(token))) {
|
|
131
138
|
return { score: WEIGHT.descriptionContains, field: 'remark' };
|
|
132
139
|
}
|
|
133
|
-
if (
|
|
140
|
+
if (ownerRemark.includes(token)) {
|
|
134
141
|
return { score: WEIGHT.descriptionContains, field: 'ownerRemark' };
|
|
135
142
|
}
|
|
136
143
|
if (type === token)
|
|
137
144
|
return { score: WEIGHT.exactType, field: 'type' };
|
|
138
145
|
return { score: 0, field: '' };
|
|
139
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* `list` 的过滤:组间 AND、组内 OR。
|
|
149
|
+
*
|
|
150
|
+
* 与 `ec skill list --filter` 同一套语义(逗号分隔为 OR,多个 `--filter` 之间
|
|
151
|
+
* 为 AND),区别只是匹配字段:技能匹配名称+描述,名录还匹配 AID、备注、exttype。
|
|
152
|
+
* 组为空表示不过滤。
|
|
153
|
+
*/
|
|
154
|
+
export function filterDirectory(snapshot, ownerAid, remarks, options = {}) {
|
|
155
|
+
if (!snapshot)
|
|
156
|
+
return [];
|
|
157
|
+
const ownerRef = ownerRefAid(snapshot, ownerAid);
|
|
158
|
+
const groups = (options.filters ?? [])
|
|
159
|
+
.map(group => group.map(keyword => normalizeDirectoryText(keyword)).filter(Boolean))
|
|
160
|
+
.filter(group => group.length > 0);
|
|
161
|
+
const scope = options.scope ?? 'all';
|
|
162
|
+
const typeFilter = normalizeDirectoryText(options.type ?? '');
|
|
163
|
+
const ownerFilter = normalizeDirectoryText(options.ownerAid ?? '');
|
|
164
|
+
return snapshot.entries
|
|
165
|
+
.filter(entry => {
|
|
166
|
+
const internal = isInternalEntry(entry, ownerRef);
|
|
167
|
+
if (scope === 'internal' && !internal)
|
|
168
|
+
return false;
|
|
169
|
+
if (scope === 'external' && internal)
|
|
170
|
+
return false;
|
|
171
|
+
if (typeFilter && normalizeDirectoryText(entry.type ?? '') !== typeFilter)
|
|
172
|
+
return false;
|
|
173
|
+
if (ownerFilter) {
|
|
174
|
+
const entryOwner = normalizeDirectoryText(entry.ownerAid ?? '');
|
|
175
|
+
if (ownerFilter === 'unbound' ? entryOwner !== '' : entryOwner !== ownerFilter)
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (groups.length === 0)
|
|
179
|
+
return true;
|
|
180
|
+
const remark = remarks?.get(entry.aid);
|
|
181
|
+
return groups.every(group => group.some(keyword => scoreToken(keyword, entry, remark, remark?.body).score > 0));
|
|
182
|
+
})
|
|
183
|
+
.sort((a, b) => Number(isInternalEntry(b, ownerRef)) - Number(isInternalEntry(a, ownerRef))
|
|
184
|
+
|| normalizeDirectoryText(a.name).localeCompare(normalizeDirectoryText(b.name))
|
|
185
|
+
|| a.aid.localeCompare(b.aid));
|
|
186
|
+
}
|
|
140
187
|
/**
|
|
141
188
|
* 单个条目的完整记录,用于 `show`。描述与备注不截断。
|
|
142
189
|
*
|
|
@@ -144,7 +191,12 @@ function scoreToken(token, entry, remark, localNote) {
|
|
|
144
191
|
* 受不同开关约束,白名单与黑名单又各自优先,算一次再套给所有条目必然错。
|
|
145
192
|
* 传布尔时按原样使用(老调用方与单测)。
|
|
146
193
|
*/
|
|
147
|
-
export function describeEntry(entry, ownerRef, remark, contactable
|
|
194
|
+
export function describeEntry(entry, ownerRef, remark, contactable,
|
|
195
|
+
/**
|
|
196
|
+
* `includeLocalRemark` 只在详情(`info`)里打开。`list` 是检索结果,
|
|
197
|
+
* 本地备注正文可能很长,按口径不展示——要看正文用 `ec directory info <AID>`。
|
|
198
|
+
*/
|
|
199
|
+
options = {}) {
|
|
148
200
|
const internal = isInternalEntry(entry, ownerRef);
|
|
149
201
|
const contactableValue = typeof contactable === 'function' ? contactable(entry) : contactable;
|
|
150
202
|
return {
|
|
@@ -153,13 +205,18 @@ export function describeEntry(entry, ownerRef, remark, contactable) {
|
|
|
153
205
|
type: entry.type ?? null,
|
|
154
206
|
exttype: entry.exttype ?? null,
|
|
155
207
|
baseagent: entry.baseagent ?? null,
|
|
208
|
+
// Owner 绑定关系与核验状态要单独给出:list 的用途就是让调用方看清
|
|
209
|
+
// "这条到底归谁、这个归属是不是经过双边确认的"。
|
|
210
|
+
ownerAid: entry.ownerAid ?? null,
|
|
211
|
+
ownershipStatus: entry.ownership_status ?? null,
|
|
212
|
+
ownershipVerified: isOwnershipVerified(entry),
|
|
213
|
+
ownershipCheckedAt: entry.ownership_checked_at_ms ?? null,
|
|
156
214
|
// 远端字段与本地备注并列返回,不互相覆盖:调用方要判断"对方本来是什么样"
|
|
157
215
|
// 和"我记了什么"是两件事。要在渲染里二选一由调用方决定。
|
|
158
216
|
remark: remark?.remark ?? entry.remark ?? null,
|
|
159
217
|
aliases: remark?.aliases ?? null,
|
|
160
218
|
description: entry.description ?? null,
|
|
161
|
-
localRemark: remark?.body ?? null,
|
|
162
|
-
ownershipStatus: entry.ownership_status ?? null,
|
|
219
|
+
...(options.includeLocalRemark !== false ? { localRemark: remark?.body ?? null } : {}),
|
|
163
220
|
agentMdSignedAt: entry.agent_md_signed_at ?? null,
|
|
164
221
|
internal,
|
|
165
222
|
contactable: contactableValue,
|
|
@@ -167,11 +224,7 @@ export function describeEntry(entry, ownerRef, remark, contactable) {
|
|
|
167
224
|
};
|
|
168
225
|
}
|
|
169
226
|
function tokenize(query) {
|
|
170
|
-
return
|
|
171
|
-
.toLowerCase()
|
|
172
|
-
.split(/\s+/)
|
|
173
|
-
.map(token => token.trim())
|
|
174
|
-
.filter(Boolean);
|
|
227
|
+
return normalizeDirectoryText(query).split(/\s+/).filter(Boolean);
|
|
175
228
|
}
|
|
176
229
|
function clampLimit(limit) {
|
|
177
230
|
if (!Number.isSafeInteger(limit) || limit <= 0)
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { atomicWriteJson } from '../utils/atomic-write.js';
|
|
4
4
|
import { logger } from '../utils/logger.js';
|
|
5
|
-
import {
|
|
5
|
+
import { changedEntryFields } from './owner-directory-cache.js';
|
|
6
6
|
import { OWNER_DIRECTORY_SCOPES } from './owner-directory-scope.js';
|
|
7
7
|
// ── content_digest helpers ────────────────────────────────────────────────────
|
|
8
8
|
const CONTENT_DIGEST_RE = /^[a-f0-9]{64}$/;
|
|
@@ -112,7 +112,7 @@ export function diffSnapshots(scope, next, prev, nextMeta, prevMeta) {
|
|
|
112
112
|
else {
|
|
113
113
|
// 运行期自检:只有真正存在差异字段才记 `entry_changed`。
|
|
114
114
|
// 上游若换一种序列化(缺失 / "" / null 互换),这里不会再刷出噪音行。
|
|
115
|
-
const fields =
|
|
115
|
+
const fields = changedEntryFields(old, entry);
|
|
116
116
|
if (fields.length === 0)
|
|
117
117
|
continue;
|
|
118
118
|
lines.push({ at: now, scope, type: 'entry_changed', aid, contentDigest, prevContentDigest: prevDigest, from: old, to: entry, fields });
|
|
@@ -148,42 +148,6 @@ export function diffSnapshots(scope, next, prev, nextMeta, prevMeta) {
|
|
|
148
148
|
}
|
|
149
149
|
return lines;
|
|
150
150
|
}
|
|
151
|
-
/**
|
|
152
|
-
* 条目内容的可变字段。这是"什么算变了"的唯一定义:`entry_changed` 的判定、
|
|
153
|
-
* 变更行里的 `fields` 都从这里出,不另写一份。
|
|
154
|
-
*
|
|
155
|
-
* `ownership_checked_at_ms` 不在其中——它是探测时间而不是内容。
|
|
156
|
-
* `ownerAid` 也不在:上游对它的有无本身在抖,纳进来只会制造噪音;内外归属变化
|
|
157
|
-
* 会体现在 `ownership_status` 上。
|
|
158
|
-
*/
|
|
159
|
-
const CONTENT_FIELDS = [
|
|
160
|
-
'name', 'remark', 'description', 'type', 'exttype', 'baseagent', 'ownership_status',
|
|
161
|
-
];
|
|
162
|
-
/**
|
|
163
|
-
* 条目内容相对旧值的差异字段。空数组 = 没有实际变化。
|
|
164
|
-
*
|
|
165
|
-
* 缺失与空串视为等价:normalizeEntry 已经把恒存在的字符串字段收敛成恒 `''`,
|
|
166
|
-
* 但本地快照可能来自更早的版本(字段缺失),这里再兜一层。这同时是运行期自检——
|
|
167
|
-
* 无论上游把可选字段写成 `""`、`null` 还是不写,只要业务值相同就不会进日志。
|
|
168
|
-
*/
|
|
169
|
-
function changedFields(a, b) {
|
|
170
|
-
const changed = [];
|
|
171
|
-
for (const key of CONTENT_FIELDS) {
|
|
172
|
-
if (text(a[key]) !== text(b[key]))
|
|
173
|
-
changed.push(key);
|
|
174
|
-
}
|
|
175
|
-
if (a.agent_md_signed_at !== b.agent_md_signed_at)
|
|
176
|
-
changed.push('agent_md_signed_at');
|
|
177
|
-
// 未知字段(`extra`)单独比:它是 key→值 的映射,按规范化指纹比较,
|
|
178
|
-
// 字段顺序不同不算变化。远端新增一个字段却没有任何 `CONTENT_FIELDS` 变化时,
|
|
179
|
-
// 变更日志里只会有这一条线索,不能漏。
|
|
180
|
-
if (extraFingerprint(a.extra) !== extraFingerprint(b.extra))
|
|
181
|
-
changed.push('extra');
|
|
182
|
-
return changed;
|
|
183
|
-
}
|
|
184
|
-
function text(value) {
|
|
185
|
-
return value ?? '';
|
|
186
|
-
}
|
|
187
151
|
/**
|
|
188
152
|
* 身份块(`owner` / `personal_assistant`)是否变化。
|
|
189
153
|
*
|
|
@@ -191,6 +155,9 @@ function text(value) {
|
|
|
191
155
|
* 否则"换了 owner 或 personal assistant"这件事在变更日志里完全不可见。
|
|
192
156
|
* 两侧都缺失时不算变更(老快照没有身份块是常态,不是事件)。
|
|
193
157
|
*/
|
|
158
|
+
function text(value) {
|
|
159
|
+
return value ?? '';
|
|
160
|
+
}
|
|
194
161
|
function identityChanged(a, b) {
|
|
195
162
|
if (!a && !b)
|
|
196
163
|
return false;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 名录里的名字/关键词归一。
|
|
3
|
+
*
|
|
4
|
+
* `list`、`info`(旧 `find` / `show`)必须用同一套比较规则,否则同一个名字在
|
|
5
|
+
* 不同命令里的命中结果会不一致:
|
|
6
|
+
*
|
|
7
|
+
* - NFKC:全角字母/数字/空格 → 半角;
|
|
8
|
+
* - 去掉零宽字符:从聊天窗口复制名字时经常带进来;
|
|
9
|
+
* - 空白折叠为单个空格;
|
|
10
|
+
* - 大小写不敏感(AID 和英文名都不该区分大小写)。
|
|
11
|
+
*/
|
|
12
|
+
/** 归一后的比较基串。 */
|
|
13
|
+
export function normalizeDirectoryText(value) {
|
|
14
|
+
return String(value ?? '')
|
|
15
|
+
.normalize('NFKC')
|
|
16
|
+
.replace(/[\u200B-\u200D\uFEFF]/g, '')
|
|
17
|
+
.replace(/\s+/g, ' ')
|
|
18
|
+
.trim()
|
|
19
|
+
.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
/** 去掉名字结尾括号里的称呼:`李文江(研发)` → `李文江`。 */
|
|
22
|
+
export function stripTrailingParenthetical(value) {
|
|
23
|
+
return value.replace(/\s*[((][^()()]*[))]\s*$/, '').trim();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 两个名字是否算同一个人:
|
|
27
|
+
* - 归一后完全相等;
|
|
28
|
+
* - 忽略结尾括号里的称呼;
|
|
29
|
+
* - 忽略名字内部的空格。
|
|
30
|
+
*/
|
|
31
|
+
export function sameDirectoryName(candidate, wanted) {
|
|
32
|
+
const right = normalizeDirectoryText(wanted);
|
|
33
|
+
if (!right)
|
|
34
|
+
return false;
|
|
35
|
+
const left = normalizeDirectoryText(candidate);
|
|
36
|
+
if (left === right)
|
|
37
|
+
return true;
|
|
38
|
+
const leftBase = normalizeDirectoryText(stripTrailingParenthetical(left));
|
|
39
|
+
const rightBase = normalizeDirectoryText(stripTrailingParenthetical(right));
|
|
40
|
+
return leftBase === rightBase
|
|
41
|
+
|| leftBase.replace(/ /g, '') === rightBase.replace(/ /g, '');
|
|
42
|
+
}
|
|
43
|
+
/** 编辑距离,用于“可能打错字/叫法接近”的提示。 */
|
|
44
|
+
export function editDistance(left, right) {
|
|
45
|
+
if (left === right)
|
|
46
|
+
return 0;
|
|
47
|
+
if (!left.length)
|
|
48
|
+
return right.length;
|
|
49
|
+
if (!right.length)
|
|
50
|
+
return left.length;
|
|
51
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
52
|
+
for (let row = 1; row <= left.length; row++) {
|
|
53
|
+
const current = [row];
|
|
54
|
+
for (let column = 1; column <= right.length; column++) {
|
|
55
|
+
current[column] = Math.min(previous[column] + 1, current[column - 1] + 1, previous[column - 1] + (left[row - 1] === right[column - 1] ? 0 : 1));
|
|
56
|
+
}
|
|
57
|
+
previous = current;
|
|
58
|
+
}
|
|
59
|
+
return previous[right.length];
|
|
60
|
+
}
|
package/dist/eck/kit-renderer.js
CHANGED
|
@@ -81,9 +81,11 @@ export function renderKitSections(ctx, manifestFile = DEFAULT_MANIFEST_FILE) {
|
|
|
81
81
|
// by agent configuration normalization while leaving explicit invalid
|
|
82
82
|
// values untouched for fail-closed manifest conditions.
|
|
83
83
|
const resolvedLifecycle = resolveAgentLifecycle({ lifecycle: ctx.vars.lifecycle });
|
|
84
|
-
const vars =
|
|
85
|
-
|
|
86
|
-
: {
|
|
84
|
+
const vars = {
|
|
85
|
+
...ctx.vars,
|
|
86
|
+
...(resolvedLifecycle === null ? {} : { lifecycle: resolvedLifecycle }),
|
|
87
|
+
activePush: ctx.vars.chatMode === 'proactive' || ctx.vars.chatMode === 'paactive',
|
|
88
|
+
};
|
|
87
89
|
const renderCtx = { ...ctx, vars };
|
|
88
90
|
const pathMappings = buildPathMappings(vars);
|
|
89
91
|
const sessionCache = getSessionCache(ctx.sessionId);
|
|
@@ -279,6 +281,7 @@ const PARAM_DESCRIPTIONS = {
|
|
|
279
281
|
osInfo: '操作系统及版本(如 Windows 11 Pro (win32 10.0.26200))',
|
|
280
282
|
threadId: '话题 ID(多话题路由时)',
|
|
281
283
|
chatMode: '会话模式(interactive=同步交互 / proactive=主动推送 / paactive=PA activity)',
|
|
284
|
+
activePush: '是否通过托管发送命令发送正式回复(true/false)',
|
|
282
285
|
isTriggerTask: '当前任务是否来源于 Trigger(true/false)',
|
|
283
286
|
proactivePreTool1stMsgChk: 'proactive 前置工具首消息检查(true/false)',
|
|
284
287
|
proactiveToolUseReminder: 'proactive 工具调用提醒(true/false)',
|
|
@@ -11,7 +11,6 @@ import { randomUUID } from 'crypto';
|
|
|
11
11
|
import { isEckSnapshotsEnabled } from '../config-store.js';
|
|
12
12
|
import { eckDebugDir } from '../paths.js';
|
|
13
13
|
import { logger } from '../utils/logger.js';
|
|
14
|
-
import { paactiveMessageManifest } from './paactive-context.js';
|
|
15
14
|
import { loadManifest, evaluateWhen, renderTemplate, loadSectionFiles, defaultModeNames, } from './manifest-engine.js';
|
|
16
15
|
const MESSAGE_MANIFEST_FILE = 'eck_message_manifest.json';
|
|
17
16
|
// ── time formatting (per IANA timezone) ──
|
|
@@ -36,8 +35,7 @@ export function formatLocalTime(epochMs, timeZone) {
|
|
|
36
35
|
}
|
|
37
36
|
// ── single item render ──
|
|
38
37
|
function renderOneItem(item, sessionVars, sessionCache, contentSentinel) {
|
|
39
|
-
const sections = loadManifest(
|
|
40
|
-
? paactiveMessageManifest(sessionVars) : MESSAGE_MANIFEST_FILE);
|
|
38
|
+
const sections = loadManifest(MESSAGE_MANIFEST_FILE);
|
|
41
39
|
// 各 modeType 当前激活的 modeName:agent config.render(经 sessionVars.renderModes 透传)
|
|
42
40
|
// 覆盖 manifest 里标 isDefault 的缺省。详见 docs/observer-insert-design.md 第二部分。
|
|
43
41
|
const defaults = defaultModeNames(sections);
|
|
@@ -277,8 +275,7 @@ export function renderMessageBody(items, sessionVars, sessionId) {
|
|
|
277
275
|
* 逐条结果 renderedParts 已是最终文本,作为字面量填入 wrapper 的 {{@loop}},不二次解析。
|
|
278
276
|
*/
|
|
279
277
|
function wrapBatch(renderedParts, sessionVars, sessionCache) {
|
|
280
|
-
const sections = loadManifest(
|
|
281
|
-
? paactiveMessageManifest(sessionVars) : MESSAGE_MANIFEST_FILE);
|
|
278
|
+
const sections = loadManifest(MESSAGE_MANIFEST_FILE);
|
|
282
279
|
const loopSection = sections.find(s => s.loop && s.enabled !== false && evaluateWhen(s.when, sessionVars));
|
|
283
280
|
if (!loopSection || !loopSection.loop || !loopSection.file)
|
|
284
281
|
return null;
|
|
@@ -6,6 +6,7 @@ import { resolveAgentLifecycle } from '../config/lifecycle.js';
|
|
|
6
6
|
import { resolveChatMode } from '../core/message/peer-mode.js';
|
|
7
7
|
import { resolvePermissionMode } from '../core/model/config-scope.js';
|
|
8
8
|
import { formatPeerKey } from '../core/relation/peer-identity.js';
|
|
9
|
+
import { preparePaTeamQualification } from '../core/relation/pa-team.js';
|
|
9
10
|
const REQUEST_FIELDS = new Set([
|
|
10
11
|
'selfAid', 'channelType', 'channelKey', 'chatType', 'actorId',
|
|
11
12
|
'conversationId', 'peerType', 'sessionId', 'displayQueries',
|
|
@@ -84,6 +85,9 @@ export function createEcwebMessageContextProvider(sessionManager, resolveRuntime
|
|
|
84
85
|
throw new MessageContextRequestError('sessionId must be an EvolCore session identifier');
|
|
85
86
|
}
|
|
86
87
|
const peerKey = formatPeerKey(identity.channelType, conversationId);
|
|
88
|
+
if (identity.channelType === 'aun' && chatType === 'private') {
|
|
89
|
+
await preparePaTeamQualification(identity.selfAid, identity.actorId);
|
|
90
|
+
}
|
|
87
91
|
const detail = resolvePeerRoleDetail({ ...identity, chatType, conversationId, peerType });
|
|
88
92
|
const role = detail.effectiveRole || 'none';
|
|
89
93
|
const candidate = sessionId ? await sessionManager.getSessionById(sessionId) : undefined;
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ import { createDelegationAuthorizer } from './core/auth/delegation-authorization
|
|
|
47
47
|
import { registerProxyIpcExecutor } from './proxy/ipc-service.js';
|
|
48
48
|
import { ownerResolver, getDaemonOwners, getPrimaryOwner } from './core/ownership/owner-resolver.js';
|
|
49
49
|
import { cleanupStartupHandoffs, recoverStartupHandoffs, releaseRestoredQueue, resumePendingSessions, createDaemonShutdown, daemonConversationTotalExecutionMs, daemonConversationWatchdogMs, daemonIdleTimeoutMs, } from './core/daemon-lifecycle.js';
|
|
50
|
+
import { createLifecycleNoticeService } from './core/lifecycle-notice.js';
|
|
50
51
|
import { BootstrapService, createBootstrapCompletionHandler, createBootstrapOwnerBoundHandler } from './core/bootstrap-service.js';
|
|
51
52
|
import { MessageCache } from './core/message/message-cache.js';
|
|
52
53
|
import { createAunHandoffSender } from './core/message/aun-ipc-sender.js';
|
|
@@ -763,6 +764,11 @@ async function main() {
|
|
|
763
764
|
// handoff 启动恢复是否还在收集 hint。与"队列是否已放行"是两件事:
|
|
764
765
|
// 队列有超时兜底会提前放行,而恢复可能还在等渠道。
|
|
765
766
|
let startupRecoveryPending = true;
|
|
767
|
+
// AUN 上下线系统提示(volatile)。系统行为,无配置开关。
|
|
768
|
+
const lifecycleNotices = createLifecycleNoticeService({
|
|
769
|
+
channelInstances,
|
|
770
|
+
resolveAgent: (channelKey, channelName) => agentRegistry.resolveByChannel(channelKey) ?? agentRegistry.resolveByChannel(channelName),
|
|
771
|
+
});
|
|
766
772
|
const { markChannelConnected, unregisterRuntimeChannel, queuePendingObserverHints } = createChannelConnectionRuntime({
|
|
767
773
|
...channelRuntimeDependencies,
|
|
768
774
|
channelInstances,
|
|
@@ -770,6 +776,7 @@ async function main() {
|
|
|
770
776
|
bootstrapService,
|
|
771
777
|
ensureTriggerSchedulerStarted,
|
|
772
778
|
sendOnlineNoticeForChannel,
|
|
779
|
+
sendLifecycleNoticeForChannel: instance => lifecycleNotices.online(instance),
|
|
773
780
|
trySendPendingRestartNotice,
|
|
774
781
|
sessionsDir: paths.sessionsDir,
|
|
775
782
|
startupObserverRecoveries,
|
|
@@ -1230,6 +1237,10 @@ async function main() {
|
|
|
1230
1237
|
// 显式触发更可控。
|
|
1231
1238
|
shutdown = createDaemonShutdown({
|
|
1232
1239
|
disposePluginResources: () => daemonPluginLifecycle.dispose(),
|
|
1240
|
+
lifecycleNotices: {
|
|
1241
|
+
beginShutdown: () => lifecycleNotices.beginShutdown(),
|
|
1242
|
+
sendOffline: signal => lifecycleNotices.sendOffline(signal),
|
|
1243
|
+
},
|
|
1233
1244
|
ipcServer,
|
|
1234
1245
|
readySignalPath,
|
|
1235
1246
|
bindService,
|
package/dist/paths.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
|
-
import { DAEMON_CONFIG_FILENAME, DEFAULT_RUNTIME_HOME_DIRNAME, INSTANCE_SOCKET_FILENAME, RUNTIME_HOME_ENV, WINDOWS_PIPE_PREFIX, } from './product.js';
|
|
5
|
+
import { DAEMON_CONFIG_FILENAME, DEFAULT_RUNTIME_HOME_DIRNAME, INSTANCE_SOCKET_FILENAME, RUNTIME_HOME_ENV, TEST_TMPDIR_ENV, WINDOWS_PIPE_PREFIX, } from './product.js';
|
|
6
6
|
import { migrateLegacyAgentJsonlLogs } from './core/audit/log-integrity.js';
|
|
7
7
|
const isWindows = process.platform === 'win32';
|
|
8
8
|
let _root = null;
|
|
@@ -12,7 +12,9 @@ export function resolveRoot() {
|
|
|
12
12
|
// than falling back to the developer's live runtime directory.
|
|
13
13
|
if (process.env.EVOLCORE_TEST === '1') {
|
|
14
14
|
const testRoot = process.env[RUNTIME_HOME_ENV] || process.env.EVOLCORE_TEST_ROOT;
|
|
15
|
-
|
|
15
|
+
// Managed children narrow TMPDIR to their session directory. The test
|
|
16
|
+
// harness retains the original boundary across that deliberate change.
|
|
17
|
+
const tempDir = process.env[TEST_TMPDIR_ENV] || process.env.TMPDIR;
|
|
16
18
|
if (!testRoot || !path.isAbsolute(testRoot) || !tempDir || !path.isAbsolute(tempDir)) {
|
|
17
19
|
throw new Error('Test runtime requires an absolute isolated root inside TMPDIR');
|
|
18
20
|
}
|
package/dist/product.js
CHANGED
|
@@ -16,6 +16,7 @@ export const MIN_ECWEB_VERSION = '0.0.8';
|
|
|
16
16
|
export const DAEMON_CONFIG_FILENAME = 'daemon.json';
|
|
17
17
|
export const DAEMON_SCHEMA_NAME = 'daemon';
|
|
18
18
|
export const RUNTIME_HOME_ENV = 'EVOLCORE_HOME';
|
|
19
|
+
export const TEST_TMPDIR_ENV = 'EVOLCORE_TEST_TMPDIR';
|
|
19
20
|
export const TARGET_PACKAGE_ROOT_ENV = 'EVOLCORE_TARGET_PACKAGE_ROOT';
|
|
20
21
|
export const SESSION_ID_ENV = 'EVOLCORE_SESSION_ID';
|
|
21
22
|
export const SELF_AID_ENV = 'EVOLCORE_SELF_AID';
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* V1 引擎 —— 单会话处理行为的载体。
|
|
3
3
|
*
|
|
4
|
-
* 对外只暴露 flowForChatMode:按 chatMode
|
|
4
|
+
* 对外只暴露 flowForChatMode:按 chatMode 取对应执行流(interactive / proactive)。
|
|
5
5
|
* chatMode 分流收拢于此,模式层(modes/single-session)与调用方不再散布分支。
|
|
6
6
|
*/
|
|
7
7
|
import { interactiveFlow } from './interactive-flow.js';
|
|
8
8
|
import { proactiveFlow } from './proactive-flow.js';
|
|
9
|
-
import { paactiveFlow } from './paactive-flow.js';
|
|
10
9
|
const FLOWS = {
|
|
11
10
|
interactive: interactiveFlow,
|
|
12
11
|
proactive: proactiveFlow,
|
|
13
|
-
paactive:
|
|
12
|
+
paactive: interactiveFlow,
|
|
14
13
|
};
|
|
15
14
|
/** 按 chatMode 取处理流。 */
|
|
16
15
|
export function flowForChatMode(chatMode) {
|
|
@@ -21,4 +20,3 @@ export function flowForChatMode(chatMode) {
|
|
|
21
20
|
}
|
|
22
21
|
export { interactiveFlow } from './interactive-flow.js';
|
|
23
22
|
export { proactiveFlow } from './proactive-flow.js';
|
|
24
|
-
export { paactiveFlow } from './paactive-flow.js';
|
|
@@ -16,7 +16,7 @@ import { isChatMode } from '../../../core/message/peer-mode.js';
|
|
|
16
16
|
* 单会话响应模式(architecture.md §4.1)—— 合并原 interactive / proactive。
|
|
17
17
|
*
|
|
18
18
|
* 本层是薄包装:不含处理行为,全部钩子委托 V1 引擎的 flow。chatMode 决定用哪个
|
|
19
|
-
* flow(interactive / proactive
|
|
19
|
+
* flow(interactive / proactive;paactive 复用 interactive),取值来自 modeConfig.chatMode(宿主按配置层级
|
|
20
20
|
* 解析后注入,见 implementation-plan.md §三;无 auto 值)。
|
|
21
21
|
*/
|
|
22
22
|
export class SingleSessionMode {
|
|
@@ -2,8 +2,9 @@ import crypto from 'crypto';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { CronExpressionParser } from 'cron-parser';
|
|
4
4
|
import { logger } from '../utils/logger.js';
|
|
5
|
+
import { isNoopText } from '../core/message/message-utils.js';
|
|
5
6
|
import { matchTriggerEvent, TriggerEventSource } from './event-source.js';
|
|
6
|
-
import { definitionRevision, executionTimeoutMs,
|
|
7
|
+
import { definitionRevision, executionTimeoutMs, parseDurationMs, previewText, renderTemplate, resolveScriptPath, sha256, validateConcurrencyCombination, } from './validation.js';
|
|
7
8
|
import { TargetSessionLockRegistry } from './session-lock.js';
|
|
8
9
|
import { enterTrigger, formatTriggerPath } from '../core/causation/context.js';
|
|
9
10
|
import { createRootCausation } from '../core/causation/context.js';
|
|
@@ -1042,9 +1043,11 @@ export class TriggerRuntimeScheduler {
|
|
|
1042
1043
|
},
|
|
1043
1044
|
});
|
|
1044
1045
|
const sentinel = definition.execution.noopSentinel ?? '[[NOOP]]';
|
|
1046
|
+
const isNoop = daemonReply.outcome === 'success' && isNoopText(daemonReply.text, sentinel);
|
|
1045
1047
|
const reply = {
|
|
1046
1048
|
...daemonReply,
|
|
1047
|
-
outcome:
|
|
1049
|
+
outcome: isNoop ? 'noop' : daemonReply.outcome,
|
|
1050
|
+
text: isNoop ? '' : daemonReply.text,
|
|
1048
1051
|
};
|
|
1049
1052
|
return {
|
|
1050
1053
|
branch: branchFromReply(reply),
|
|
@@ -1443,9 +1446,11 @@ export class TriggerRuntimeScheduler {
|
|
|
1443
1446
|
},
|
|
1444
1447
|
});
|
|
1445
1448
|
const sentinel = definition.execution.noopSentinel ?? '[[NOOP]]';
|
|
1449
|
+
const isNoop = daemonReply.outcome === 'success' && isNoopText(daemonReply.text, sentinel);
|
|
1446
1450
|
const reply = {
|
|
1447
1451
|
...daemonReply,
|
|
1448
|
-
outcome:
|
|
1452
|
+
outcome: isNoop ? 'noop' : daemonReply.outcome,
|
|
1453
|
+
text: isNoop ? '' : daemonReply.text,
|
|
1449
1454
|
};
|
|
1450
1455
|
return {
|
|
1451
1456
|
branch: branchFromReply(reply),
|