evolcore 0.0.45 → 0.0.46
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 +75 -0
- package/bin/ecmsg.js +33 -23
- package/dist/ability/application-service.js +1 -2
- package/dist/ability/package.js +28 -0
- package/dist/agent-template/jobs.js +158 -36
- package/dist/agent-template/runtime.js +401 -34
- package/dist/agent-template/service.js +764 -369
- package/dist/agent-template/tool-runner.js +35 -17
- package/dist/agent-template/types.js +7 -4
- package/dist/agents/baseagent.js +10 -9
- package/dist/agents/claude-runner.js +13 -5
- package/dist/agents/codex/app-server-client.js +2 -4
- package/dist/agents/codex/diagnostics.js +18 -1
- package/dist/agents/codex-runner.js +3 -1
- package/dist/agents/ecagent-runner.js +3 -1
- package/dist/agents/gemini-runner.js +2 -1
- package/dist/aun/menu/client.js +142 -182
- package/dist/aun/rpc/client.js +33 -17
- package/dist/aun/service-proxy.js +6 -23
- package/dist/channels/aun.js +656 -112
- package/dist/cli/agent-create.js +37 -10
- package/dist/cli/agent-template.js +105 -84
- package/dist/cli/agent.js +31 -18
- package/dist/cli/daemon-commands.js +15 -17
- package/dist/cli/daemon-lifecycle-client.js +40 -18
- package/dist/cli/directory.js +12 -4
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/events-command.js +2 -1
- package/dist/cli/init.js +50 -20
- package/dist/cli/integrity-command.js +2 -0
- package/dist/cli/managed-command-guard.js +20 -1
- package/dist/cli/menu-client.js +7 -5
- package/dist/cli/restart-monitor.js +33 -20
- package/dist/cli/services-command.js +28 -5
- package/dist/config/config-field-policy.js +24 -0
- package/dist/config/config-manager.js +20 -2
- package/dist/config/peer-book-store.js +152 -120
- package/dist/config/peer-role-resolver.js +24 -4
- package/dist/config/provider-identity-migration.js +1 -1
- package/dist/config/provider-identity.js +10 -4
- package/dist/config/provider-ipc-service.js +10 -2
- package/dist/config/provider-local-sync.js +2 -2
- package/dist/config/providers-config.js +95 -10
- package/dist/config/providers-import.js +4 -6
- package/dist/config/providers.js +14 -3
- package/dist/config/role-store.js +1 -1
- package/dist/config-store.js +9 -1
- package/dist/core/agent-application-service.js +56 -29
- package/dist/core/agent-create-status.js +3 -1
- package/dist/core/agent-creation-claim.js +1 -0
- package/dist/core/agent-ipc-registration.js +2 -2
- package/dist/core/agent-reload-coordinator.js +38 -1
- package/dist/core/agent-runtime.js +85 -38
- package/dist/core/auth/agent-delegation.js +5 -0
- package/dist/core/auth/operation-authorizer.js +1 -1
- package/dist/core/auth/operation-catalog.js +3 -3
- package/dist/core/bootstrap-service.js +3 -0
- package/dist/core/capability/capability-manager.js +3 -1
- package/dist/core/channel-loader.js +29 -3
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-control.js +6 -5
- package/dist/core/command/agent-template-menu.js +32 -97
- package/dist/core/command/eventcenter-menu.js +61 -13
- package/dist/core/command/menu-catalog.js +11 -4
- package/dist/core/command/menu-handler.js +35 -8
- package/dist/core/command/menu-protocol.js +8 -16
- package/dist/core/command/skill-slash.js +6 -2
- package/dist/core/command/team-workspace-bootstrap.js +1 -2
- package/dist/core/command/team-workspace-management-store.js +83 -0
- package/dist/core/command/team-workspace-management.js +1 -2
- package/dist/core/command/team-workspace-team.js +26 -3
- package/dist/core/daemon-control.js +3 -4
- package/dist/core/daemon-lifecycle.js +146 -110
- package/dist/core/evolagent-registry.js +42 -0
- package/dist/core/evolagent.js +2 -1
- package/dist/core/file-integrity/read.js +9 -16
- package/dist/core/file-integrity/store.js +94 -34
- package/dist/core/handoff/dispatcher.js +33 -7
- package/dist/core/handoff/runtime.js +8 -0
- package/dist/core/inference/text-inference.js +12 -2
- package/dist/core/invoke/invoke-service.js +24 -3
- package/dist/core/ipc-registration.js +3 -0
- package/dist/core/message/aun-ipc-sender.js +109 -7
- package/dist/core/message/contact-admission.js +6 -2
- package/dist/core/message/message-bridge.js +13 -0
- package/dist/core/message/message-queue.js +131 -30
- package/dist/core/message/pending-hints.js +8 -0
- package/dist/core/message/response-engine.js +48 -2
- package/dist/core/message/send-routing.js +3 -12
- package/dist/core/model/catalog-service.js +13 -0
- package/dist/core/model/model-catalog.js +57 -18
- package/dist/core/pack-auth.js +163 -31
- package/dist/core/pack-install.js +42 -1
- package/dist/{services/ledger.js → core/pack-ledger.js} +17 -6
- package/dist/core/permission/ec-command-parser.js +3 -1
- package/dist/core/permission/shell-environment.js +23 -0
- package/dist/core/rate-window.js +6 -1
- package/dist/core/session/session-idle-monitor.js +0 -1
- package/dist/core/session/session-manager.js +14 -0
- package/dist/core/session/session-title.js +26 -6
- package/dist/core/skill/index-generator.js +3 -4
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/core/thread/topic-id.js +8 -0
- package/dist/directory/owner-directory-admission.js +17 -0
- package/dist/directory/owner-directory-cache.js +3 -1
- package/dist/directory/owner-directory-markdown.js +145 -23
- package/dist/directory/owner-directory-policy.js +23 -0
- package/dist/directory/owner-directory-query-operation.js +20 -6
- package/dist/directory/owner-directory-search.js +47 -0
- package/dist/eck/message-renderer.js +171 -32
- package/dist/ecweb/basic-settings-service.js +7 -3
- package/dist/ecweb/providers-service.js +17 -10
- package/dist/ecweb/runtime/lifecycle.js +1 -1
- package/dist/ecweb/runtime/supervisor.js +77 -35
- package/dist/event-center/admission-materializer.js +1 -1
- package/dist/event-center/bus-gate.js +48 -4
- package/dist/event-center/bus-host.js +3 -3
- package/dist/event-center/center-config.js +57 -28
- package/dist/event-center/dispatcher.js +8 -0
- package/dist/event-center/event-log.js +69 -27
- package/dist/event-center/index-generator.js +6 -1
- package/dist/event-center/ipc-operation.js +66 -25
- package/dist/event-center/pack-loader.js +12 -55
- package/dist/event-center/pack-manager.js +5 -3
- package/dist/event-center/registry.js +48 -52
- package/dist/event-center/runtime.js +219 -81
- package/dist/event-center/script-runner.js +18 -7
- package/dist/event-center/types.js +9 -1
- package/dist/event-center/validation.js +33 -4
- package/dist/index.js +96 -42
- package/dist/ipc.js +33 -7
- package/dist/product.js +1 -0
- package/dist/proxy/manager.js +52 -11
- package/dist/proxy/service-supervisor.js +265 -67
- package/dist/services/dispatcher.js +26 -3
- package/dist/services/idempotency.js +128 -0
- package/dist/services/identity.js +3 -27
- package/dist/services/index-generator.js +5 -1
- package/dist/services/index.js +244 -45
- package/dist/services/ipc-operation.js +164 -20
- package/dist/services/pack-manager.js +37 -9
- package/dist/services/router.js +100 -31
- package/dist/services/script-runner.js +15 -4
- package/dist/services/service-payload.js +50 -2
- package/dist/services/validation.js +107 -3
- package/dist/trigger/scheduler.js +14 -4
- package/dist/trigger/script-sandbox.js +39 -2
- package/dist/utils/cross-platform.js +35 -11
- package/dist/utils/error-utils.js +13 -1
- package/dist/utils/instance-registry.js +33 -35
- package/dist/utils/process-introspect.js +35 -20
- package/dist/utils/project-path.js +47 -3
- package/dist/utils/windows-shell-trust.js +174 -68
- package/kits/docs/context-assembly.md +3 -3
- package/kits/docs/evolcore/agent.md +28 -10
- package/kits/docs/evolcore/config.md +22 -0
- package/kits/docs/evolcore/directory.md +46 -12
- package/kits/docs/evolcore/event-center.md +6 -6
- package/kits/docs/evolcore/group-collaboration.md +1 -1
- package/kits/docs/evolcore/menu-client.md +7 -5
- package/kits/docs/evolcore/menu-protocol.md +5 -3
- package/kits/docs/evolcore/msg.md +10 -3
- package/kits/docs/evolcore/provider.md +7 -3
- package/kits/docs/evolcore/services.md +145 -12
- package/kits/docs/evolcore/thread-chain.md +17 -9
- package/kits/docs/prompt-loading-architecture.md +4 -4
- package/kits/eck_message_manifest.json +46 -3
- package/kits/rules/04-relation.md +10 -2
- package/kits/rules/06-channel.md +2 -1
- package/kits/schemas/providers.schema.2.json +1 -0
- package/kits/skills/ec-group/SKILL.md +4 -0
- package/kits/skills/ec-skill/scripts/cli.mjs +1 -1
- package/kits/skills/ec-skill/scripts/skill.mjs +13 -2
- package/kits/skills/thread-ops/SKILL.md +8 -5
- package/kits/templates/message-fragments/group-batch-item.md +3 -0
- package/kits/templates/message-fragments/group-batch.md +1 -0
- package/kits/templates/message-fragments/item-group.md +4 -0
- package/kits/templates/message-fragments/item-private.md +4 -0
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/system-fragments/commands.md +5 -5
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +11 -7
- package/package.json +3 -2
- package/scripts/agent-template/index.mjs +9 -4
- package/scripts/agent-template/inspect.mjs +16 -9
- package/scripts/agent-template/shared/plan.mjs +3 -33
- package/scripts/agent-template/shared/template-contract.mjs +186 -3
- package/scripts/agent-template/shared/template-package.mjs +119 -10
- package/scripts/agent-template/shared/template-runtime.mjs +49 -6
- package/scripts/agent-template/shared/template.mjs +5 -5
- package/scripts/agent-template/team-pack.mjs +245 -0
- package/scripts/agent-template/team-preview.mjs +111 -0
- package/scripts/aid-batch/identity-batch.mjs +143 -0
- package/dist/ability/versions.js +0 -32
- package/dist/aun/model-headers.js +0 -17
- package/dist/channels/builtin-plugins.js +0 -19
- package/dist/core/command/team-workspace-initializer.js +0 -2
- package/dist/core/command/team-workspace-job-store.js +0 -88
- package/dist/core/command/team-workspace-management-service.js +0 -2
- package/dist/core/contact-bind-registry.js +0 -27
- package/dist/event-center/ledger.js +0 -52
- package/dist/services/reply.js +0 -55
- package/kits/templates/message-fragments/item.md +0 -3
- package/scripts/agent-template/pack.mjs +0 -169
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* 事件与服务包的长期生命周期台账;消息正文仍由各自的按日消息日志记录。
|
|
3
|
+
* 领域 action/字段分别约束,追加与读取共用一个实现。
|
|
4
4
|
*/
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
|
|
7
|
+
class PackLedger {
|
|
8
8
|
filePath;
|
|
9
9
|
constructor(filePath) {
|
|
10
10
|
this.filePath = filePath;
|
|
@@ -18,7 +18,7 @@ export class ServiceLedger {
|
|
|
18
18
|
fs.appendFileSync(this.filePath, `${JSON.stringify(full)}\n`, 'utf8');
|
|
19
19
|
}
|
|
20
20
|
catch {
|
|
21
|
-
//
|
|
21
|
+
// 台账写失败不致命:运行继续,由台账查询入口诊断磁盘。
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
/** 读最后 N 行(CLI tail 用)。 */
|
|
@@ -43,10 +43,21 @@ export class ServiceLedger {
|
|
|
43
43
|
return out;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export class Ledger extends PackLedger {
|
|
47
|
+
}
|
|
48
|
+
export class ServiceLedger extends PackLedger {
|
|
49
|
+
}
|
|
50
|
+
export function eventPackLedger(pack) {
|
|
51
|
+
return new Ledger(pack.paths.ledger);
|
|
52
|
+
}
|
|
53
|
+
export function servicePackLedger(pack) {
|
|
47
54
|
return new ServiceLedger(pack.paths.ledger);
|
|
48
55
|
}
|
|
49
|
-
/**
|
|
56
|
+
/** 事件中心级台账。 */
|
|
57
|
+
export function centerLedger(eventsDir) {
|
|
58
|
+
return new Ledger(path.join(eventsDir, '.center-ledger.jsonl'));
|
|
59
|
+
}
|
|
60
|
+
/** 服务路由级台账。 */
|
|
50
61
|
export function routerLedger(servicesDir) {
|
|
51
62
|
return new ServiceLedger(path.join(servicesDir, '.router-ledger.jsonl'));
|
|
52
63
|
}
|
|
@@ -3748,7 +3748,9 @@ export function isThreadRoutedEvolcoreSendCommand(toolName, input, selfAid, reso
|
|
|
3748
3748
|
else {
|
|
3749
3749
|
return false;
|
|
3750
3750
|
}
|
|
3751
|
-
|
|
3751
|
+
// 跨话题发送同样属于「向对端表达意图」,--file/--text-from-file 必须与正文同等对待;
|
|
3752
|
+
// 这里漏传 allowAttachment 会让所有带附件的 --thread 发送被误判成"没有发送内容"。
|
|
3753
|
+
if (!hasExecutableProactiveSendPayload(normalized, scope, 5, { allowAttachment: true }))
|
|
3752
3754
|
return false;
|
|
3753
3755
|
return resolveThread(scope, threadId, target);
|
|
3754
3756
|
}
|
|
@@ -36,6 +36,29 @@ export function isShellCodeInjectionEnvironmentName(name) {
|
|
|
36
36
|
|| name.startsWith('LD_')
|
|
37
37
|
|| name.startsWith('DYLD_');
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* 凭据类环境变量名:脚本不该继承的任何东西。
|
|
41
|
+
*
|
|
42
|
+
* 命名约定而非白名单——`GITHUB_TOKEN`、`AWS_SECRET_ACCESS_KEY`、`NPM_TOKEN`
|
|
43
|
+
* 这类名字不认识就是漏。宁可误杀一个业务变量(脚本自己传参即可),也不要让
|
|
44
|
+
* 一个第三方 token 悄悄进到没有隔离的脚本里。
|
|
45
|
+
*
|
|
46
|
+
* 与 `isShellCodeInjectionEnvironmentName` 分开:那个防的是命令注入,这个防的是
|
|
47
|
+
* 凭据泄漏,两者失效后果不同,调用点也不同。
|
|
48
|
+
*/
|
|
49
|
+
export function isCredentialEnvironmentName(name) {
|
|
50
|
+
const normalized = name.toUpperCase();
|
|
51
|
+
return CREDENTIAL_ENV_SUFFIXES.some(suffix => normalized.endsWith(suffix))
|
|
52
|
+
|| CREDENTIAL_ENV_PREFIXES.some(prefix => normalized.startsWith(prefix))
|
|
53
|
+
|| normalized.includes('PASSWORD')
|
|
54
|
+
|| normalized.includes('PASSWD');
|
|
55
|
+
}
|
|
56
|
+
const CREDENTIAL_ENV_SUFFIXES = [
|
|
57
|
+
'_API_KEY', '_APIKEY', '_TOKEN', '_SECRET', '_SECRET_KEY', '_CREDENTIAL', '_CREDENTIALS',
|
|
58
|
+
'_ACCESS_KEY', '_PRIVATE_KEY', '_AUTH_TOKEN',
|
|
59
|
+
];
|
|
60
|
+
/** 云厂商/包管理器的固定前缀:这些名字的后半段五花八门,按前缀更稳。 */
|
|
61
|
+
const CREDENTIAL_ENV_PREFIXES = ['AWS_', 'GCP_', 'AZURE_', 'NPM_', 'GITHUB_', 'GH_', 'DOCKER_', 'SLACK_'];
|
|
39
62
|
export function sanitizeShellExecutionEnvironment(input, options = {}) {
|
|
40
63
|
const sanitized = { ...input };
|
|
41
64
|
for (const name of Object.keys(sanitized)) {
|
package/dist/core/rate-window.js
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 事件侧与服务侧共用同一份算法:两侧都是「按来源 AID 限制调用频率」,
|
|
5
5
|
* 差别只在额度来源(services-config.json 的 rateLimit vs events-config.json 的 rateLimit)。
|
|
6
|
-
*
|
|
6
|
+
* 抽出来是为了避免两套实现各自漂移——限流行为不一致比没有限流更难排查。
|
|
7
|
+
*
|
|
8
|
+
* **这是固定窗口,不是滑动窗口。** 每分钟(每小时)从第一次调用起算一格,到点整体清零。
|
|
9
|
+
* 后果是边界处最多放行到 2 倍额度:59 秒用完 60 次,60 秒满血又 60 次。
|
|
10
|
+
* 对"保护订阅方脚本不被失控的发布方打爆"这个目的够用——它防的是持续过载,
|
|
11
|
+
* 不是精确配额。真要严格,得换成令牌桶或滑动日志,代价是每 key 存一条时间序列。
|
|
7
12
|
*/
|
|
8
13
|
const MINUTE_MS = 60_000;
|
|
9
14
|
const HOUR_MS = 3_600_000;
|
|
@@ -257,7 +257,6 @@ export class SessionIdleMonitor {
|
|
|
257
257
|
this.options.eventBus.subscribe('session:created', this.onSessionCreated);
|
|
258
258
|
this.options.eventBus.subscribe('session:loop-changed', this.onSessionLoopChanged);
|
|
259
259
|
}
|
|
260
|
-
/** Subscribe first; restore cold history only after normal task Ready. */
|
|
261
260
|
activate(options = {}) {
|
|
262
261
|
if (this.active)
|
|
263
262
|
return Promise.resolve();
|
|
@@ -1028,6 +1028,20 @@ export class SessionManager {
|
|
|
1028
1028
|
this.sessionFileIndex.set(sessionId, found);
|
|
1029
1029
|
return found;
|
|
1030
1030
|
}
|
|
1031
|
+
/** Prime a known recovery route without enumerating unrelated historical Sessions. */
|
|
1032
|
+
registerSessionRoute(sessionId, route) {
|
|
1033
|
+
if (!/^meta_[A-Za-z0-9_-]+$/.test(sessionId))
|
|
1034
|
+
return;
|
|
1035
|
+
const parsed = tryParseChannelKey(route.channel);
|
|
1036
|
+
const aid = route.selfAID || parsed?.selfAID;
|
|
1037
|
+
const type = route.channelType || parsed?.type;
|
|
1038
|
+
if (!aid || !type || !route.channelId)
|
|
1039
|
+
return;
|
|
1040
|
+
const chatDir = chatDirPath(this.sessionsDir, type, route.channelId, aid, route.channel);
|
|
1041
|
+
const isThread = isTopicThreadId(route.threadId);
|
|
1042
|
+
this.rememberSessionFile(sessionId, { chatDir, isThread,
|
|
1043
|
+
metaPath: path.join(chatDir, ...(isThread ? ['_threads'] : []), `${sessionId}.jsonl`) });
|
|
1044
|
+
}
|
|
1031
1045
|
rebuildSessionFileIndex() {
|
|
1032
1046
|
this.sessionFileIndex.clear();
|
|
1033
1047
|
this.knownChatDirs = scanChatDirs(this.sessionsDir).map(entry => entry.dirPath);
|
|
@@ -4,10 +4,17 @@ const SYSTEM_PROMPT_MARKERS = [
|
|
|
4
4
|
'<system-reminder>',
|
|
5
5
|
'EvolCore Context Kit documents are shown below.',
|
|
6
6
|
];
|
|
7
|
-
// EvolCore
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
const MESSAGE_ROUTE_PREFIX_RE = /^‹[
|
|
7
|
+
// EvolCore 消息渲染器给每条入站消息加的信封前缀(kits/templates/message-fragments/)。
|
|
8
|
+
// 形态:`‹YYYY-MM-DD HH:mm:ss 偏移 … ›`(完整信封)或 `‹提醒:跨话题委托 … ›`(委托提醒)。
|
|
9
|
+
// `[^›]*` 保证只吞到第一个 `›`,真人不可能手打这种全角前缀。
|
|
10
|
+
const MESSAGE_ROUTE_PREFIX_RE = /^‹(?:\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|提醒:)[^\n›]*›\s*/;
|
|
11
|
+
// 兼容已发布版本的历史私聊/群聊路由信封。
|
|
12
|
+
const LEGACY_MESSAGE_ROUTE_PREFIX_RE = /^‹[^›]*·\s*from:[^›]*→[^›]*self:[^›]*›\s*/;
|
|
13
|
+
// 群聊批次头:`[2026-11-09 21:04 · 群聊] 群:… · self:… · chat:…`。
|
|
14
|
+
// 批次消息第一行是它(而不是 `‹…›`),只认信封前缀会漏判。
|
|
15
|
+
const GROUP_BATCH_HEADER_RE = /^\[[^\]\n]*·\s*群聊\][^\n]*(?:\n|$)/;
|
|
16
|
+
// 批次逐行信封:`‹21:04:29 · from:… · mid:…›`
|
|
17
|
+
const BATCH_ITEM_PREFIX_RE = /^‹\d{2}:\d{2}:\d{2}[^\n›]*›\s*/;
|
|
11
18
|
/**
|
|
12
19
|
* 判断文本是否以 EvolCore 路由前缀开头,即该会话是 EvolCore 自身驱动 base agent 产生的
|
|
13
20
|
* (不是用户在终端直接发起的 CLI 会话)。用于 `/s cli` 列表把"自己的会话"排除在导入候选之外,
|
|
@@ -16,7 +23,9 @@ const MESSAGE_ROUTE_PREFIX_RE = /^‹[^›]*·\s*from:[^›]*→[^›]*self:[^
|
|
|
16
23
|
export function isEvolcoreRoutedMessage(text) {
|
|
17
24
|
if (typeof text !== 'string')
|
|
18
25
|
return false;
|
|
19
|
-
|
|
26
|
+
const trimmed = text.trimStart();
|
|
27
|
+
return MESSAGE_ROUTE_PREFIX_RE.test(trimmed) || LEGACY_MESSAGE_ROUTE_PREFIX_RE.test(trimmed)
|
|
28
|
+
|| GROUP_BATCH_HEADER_RE.test(trimmed);
|
|
20
29
|
}
|
|
21
30
|
const SHARED_SYNTHETIC_CLI_PROMPT_PREFIXES = [
|
|
22
31
|
'Use Bash exactly once to run:',
|
|
@@ -158,7 +167,18 @@ export function sanitizeSessionTitle(title) {
|
|
|
158
167
|
cleanTitle = cleanTitle.slice(0, markerIndex);
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
|
-
cleanTitle = cleanTitle.trim()
|
|
170
|
+
cleanTitle = cleanTitle.trim()
|
|
171
|
+
.replace(GROUP_BATCH_HEADER_RE, '')
|
|
172
|
+
.replace(MESSAGE_ROUTE_PREFIX_RE, '')
|
|
173
|
+
.replace(LEGACY_MESSAGE_ROUTE_PREFIX_RE, '');
|
|
174
|
+
// 群聊批次逐行信封:`‹HH:mm:ss · from:…›`;连续多条时逐行剥掉。
|
|
175
|
+
for (let i = 0; i < 20; i++) {
|
|
176
|
+
const next = cleanTitle.trimStart().replace(BATCH_ITEM_PREFIX_RE, '');
|
|
177
|
+
if (next === cleanTitle)
|
|
178
|
+
break;
|
|
179
|
+
cleanTitle = next;
|
|
180
|
+
}
|
|
181
|
+
cleanTitle = cleanTitle.replace(/\s+/g, ' ').trim();
|
|
162
182
|
if (!cleanTitle)
|
|
163
183
|
return undefined;
|
|
164
184
|
if (/^\.+$/.test(cleanTitle))
|
|
@@ -67,12 +67,11 @@ function generateOneIndex(indexDir, filename, skills, label, skillRoot) {
|
|
|
67
67
|
* 直接按目录读,不走 discoverSkillDirectories——后者按父目录扫描再按 name 匹配,
|
|
68
68
|
* 同名技能(本机覆盖内置)会读到另一份的 description。
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* 内置技能是随包发布的内容:安装模式下按当前包版本校验,升级自动切换基线;
|
|
71
|
+
* 同版本带外改动会恢复,恢复不了则返回空描述,与 ECK 文档同一套策略。开发模式下不校验,
|
|
72
72
|
* agent 随手改技能可以立刻生效。
|
|
73
73
|
*
|
|
74
|
-
*
|
|
75
|
-
* 那条路径不经过本函数,目前不受台账保护(等单独的 SKILL.md 加载工具接手)。
|
|
74
|
+
* 技能正文的 ec skill load 与 /skill load 也走相同的版本基线校验。
|
|
76
75
|
*/
|
|
77
76
|
export function readSkillDescription(skillDir) {
|
|
78
77
|
const file = path.join(skillDir, 'SKILL.md');
|
|
@@ -8,7 +8,6 @@ import { sanitizeSessionTitle, sessionTitleLength, SESSION_TITLE_MAX_LEN, SESSIO
|
|
|
8
8
|
import { isMainSessionThreadId, isTopicThreadId, mainTopicPeer, safeFormatMainTopicId, sessionTopicThreadId } from './topic-id.js';
|
|
9
9
|
import { PeerIdentityCache } from '../relation/peer-identity.js';
|
|
10
10
|
import { ThreadContextStorage } from './thread-context-storage.js';
|
|
11
|
-
const THREAD_ID_RE = /^thread-[0-9]+-[0-9a-f]{4}-[0-9a-f]{4}$/;
|
|
12
11
|
const RESERVED_THREAD_IDS = new Set(['current', 'main', 'all']);
|
|
13
12
|
/**
|
|
14
13
|
* 话题名长度校验:自动生成与手动改名共用 `session-title.ts` 的两个常量。
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
* 对端凭空建出一个叫 `main:…` 的话题。它只用于本端寻址、持久化与展示。
|
|
17
17
|
*/
|
|
18
18
|
export const MAIN_TOPIC_PREFIX = 'main:';
|
|
19
|
+
// CLI 创建时间戳形式,客户端可创建 UUID 形式;原值参与索引与双端寻址,不改写大小写。
|
|
20
|
+
const TIMESTAMP_TOPIC_ID_RE = /^thread-[0-9]+-[0-9a-f]{4}-[0-9a-f]{4}$/;
|
|
21
|
+
const UUID_TOPIC_ID_RE = /^thread-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
22
|
+
/** 外部发送引用的格式校验;是否存在及属于谁,仍须查询本端话题索引。 */
|
|
23
|
+
export function isExternalTopicThreadId(value) {
|
|
24
|
+
return typeof value === 'string' && value === value.trim() && value.startsWith('thread-')
|
|
25
|
+
&& (TIMESTAMP_TOPIC_ID_RE.test(value) || UUID_TOPIC_ID_RE.test(value));
|
|
26
|
+
}
|
|
19
27
|
/**
|
|
20
28
|
* AID 段:不含 `:` 与 `/`,至少两级域名。
|
|
21
29
|
*
|
|
@@ -292,3 +292,20 @@ function logDirectoryAdmissionUnavailable(selfAid, targetAid, reason, ownerAid,
|
|
|
292
292
|
logger.warn(`[OwnerDirectoryAdmission] unavailable self=${selfAid} target=${targetAid}`
|
|
293
293
|
+ ` owner=${ownerAid ?? '<unresolved>'} reason=${reason}${errorCode ? ` error=${errorCode}` : ''}`);
|
|
294
294
|
}
|
|
295
|
+
/** 发送方是否在 Owner 名录(联系人)里。名录不可用或未接入时按"不是联系人"处理。 */
|
|
296
|
+
export function isOwnerDirectoryContact(selfAid, aid) {
|
|
297
|
+
if (!selfAid || !aid)
|
|
298
|
+
return false;
|
|
299
|
+
try {
|
|
300
|
+
const membership = readOwnerDirectoryMembership(selfAid, aid);
|
|
301
|
+
if (!membership || membership.category === 'not_found' || membership.category === 'unavailable') {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
if (membership.blocked === true || membership.scopeExcluded === true)
|
|
305
|
+
return false;
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -10,7 +10,7 @@ import { resolveRoot } from '../paths.js';
|
|
|
10
10
|
import { contactAdmissionDirectory } from './contact-admission-paths.js';
|
|
11
11
|
import { OWNER_DIRECTORY_MARKDOWN_FILE, renderOwnerDirectoryMarkdown } from './owner-directory-markdown.js';
|
|
12
12
|
import { OWNER_DIRECTORY_IDENTITY_FILE, buildOwnerDirectoryIdentity } from './owner-directory-identity.js';
|
|
13
|
-
import { resolveOwnerDirectoryRenderPolicy } from './owner-directory-policy.js';
|
|
13
|
+
import { resolveMyAgentTeam, resolveOwnerDirectoryRenderPolicy } from './owner-directory-policy.js';
|
|
14
14
|
import { directoryContentDigest } from './canonical-digest.js';
|
|
15
15
|
import { readAllRemarks, OWNER_DIRECTORY_REMARKS_DIR } from './owner-directory-remarks.js';
|
|
16
16
|
import { archiveSnapshot, appendChanges, diffSnapshots, collectAgentMdRefreshAids, isValidContentDigest, } from './owner-directory-store.js';
|
|
@@ -1944,6 +1944,8 @@ export class OwnerDirectoryCache {
|
|
|
1944
1944
|
snapshot,
|
|
1945
1945
|
remarks: this.remarksSnapshot(),
|
|
1946
1946
|
policy: resolveOwnerDirectoryRenderPolicy(this.options.selfAid, snapshot),
|
|
1947
|
+
// `config.team` 每轮现读:Owner 在 App 里改完团队成员,下一次重算就生效。
|
|
1948
|
+
team: resolveMyAgentTeam(this.options.selfAid),
|
|
1947
1949
|
});
|
|
1948
1950
|
if (!markdown) {
|
|
1949
1951
|
if (!this.directoryGone()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { splitAliases } from './owner-directory-remarks.js';
|
|
4
|
-
import { classifyEntry, isInPaTeam, ownerRefAid, } from './owner-directory-scope.js';
|
|
4
|
+
import { classifyEntry, entryOwnerAid, isInPaTeam, ownerRefAid, } from './owner-directory-scope.js';
|
|
5
5
|
/** ECK 载入的名录文件,与名录快照同目录。 */
|
|
6
6
|
export const OWNER_DIRECTORY_MARKDOWN_FILE = 'directory.md';
|
|
7
7
|
/**
|
|
@@ -13,6 +13,18 @@ export const OWNER_DIRECTORY_MARKDOWN_MAX_BYTES = 32 * 1024;
|
|
|
13
13
|
const NAME_MAX = 32;
|
|
14
14
|
const DESCRIPTION_MAX = 100;
|
|
15
15
|
const TYPE_MAX = 24;
|
|
16
|
+
/**
|
|
17
|
+
* My Agent Team 的渲染上限。
|
|
18
|
+
*
|
|
19
|
+
* 超过这个数的成员**整条不渲染**(连名字也不留),只在组提示里报总数。
|
|
20
|
+
* 与 PA Team 的 100 人降级策略不同:那份清单是服务端下发的,本端无权删,
|
|
21
|
+
* 只能降级保全名字;`config.team` 是本 Agent 自己的名单,超限时少露几个人
|
|
22
|
+
* 比把 32KB 预算吃干、挤掉 PA Team 更划算。
|
|
23
|
+
*/
|
|
24
|
+
export const MY_AGENT_TEAM_LIMIT = 50;
|
|
25
|
+
/** 团队里在名录中找不到,或找到了但没有 owner 归属时的状态列文案。 */
|
|
26
|
+
const TEAM_MISSING_LABEL = '不在联系人中';
|
|
27
|
+
const TEAM_UNBOUND_LABEL = '未绑定 Owner';
|
|
16
28
|
/**
|
|
17
29
|
* 归一化开关入参。
|
|
18
30
|
*
|
|
@@ -44,25 +56,26 @@ export function hasOwnerDirectoryMarkdown(directory) {
|
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* 分组与形态(形态决定占多少预算):
|
|
59
|
+
* 计算 `config.team` 里哪些成员会进 `directory.md`。
|
|
50
60
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* - 外部三组(外部 Agent、外部人类、加入的群):`brief` 形态,受外部开关控制。
|
|
56
|
-
* - 白名单联系人:`allowedAids` 命中的外部条目,独立成组,不受外部开关影响;
|
|
57
|
-
* 用 `full` 形态(Owner 显式放行过,需要完整记录)。
|
|
58
|
-
* - 归属未核实:自称归本 Owner 但 `ownership_status !== owned`、没有 `owner_aid`、
|
|
59
|
-
* 或 `type` 不在协议 8 种之内的条目。资料不可信,只注入名字(`brief`),
|
|
60
|
-
* 详情用 `ec directory list` 现查;不参与内部联系人的默认放行。
|
|
61
|
-
*
|
|
62
|
-
* 行形态只有 `full` / `brief` 两种,提示文案由 `groupHint` 按形态统一追加。
|
|
63
|
-
*
|
|
64
|
-
* 输出不含时间戳:内容不变就逐字节相同,调用方据此跳过写盘。
|
|
61
|
+
* 渲染和 `ec directory list --scope my-agent-team` 必须用**同一份**结果:
|
|
62
|
+
* 命令是给 agent 查"我注入内容里有哪些团队成员"的,比注入多列出几个人就等于
|
|
63
|
+
* 说谎。所以这里把筛除规则(空值 → 固定身份块 → 黑名单 → 50 人上限)收在一处,
|
|
64
|
+
* 两边都调它。
|
|
65
65
|
*/
|
|
66
|
+
export function resolveMyAgentTeamAids(team, snapshot, selfAid, ownerAid) {
|
|
67
|
+
const reserved = new Set([ownerAid, selfAid]);
|
|
68
|
+
if (snapshot?.owner?.aid)
|
|
69
|
+
reserved.add(snapshot.owner.aid);
|
|
70
|
+
if (snapshot?.personalAssistant?.aid)
|
|
71
|
+
reserved.add(snapshot.personalAssistant.aid);
|
|
72
|
+
const blocked = new Set(snapshot?.blockedAids ?? []);
|
|
73
|
+
const total = [...new Set((team ?? [])
|
|
74
|
+
.map(aid => String(aid).trim())
|
|
75
|
+
.filter(aid => aid !== '' && !reserved.has(aid) && !blocked.has(aid)))];
|
|
76
|
+
const visible = total.slice(0, MY_AGENT_TEAM_LIMIT);
|
|
77
|
+
return { visible, total: total.length, dropped: total.length - visible.length };
|
|
78
|
+
}
|
|
66
79
|
export function renderOwnerDirectoryMarkdown(input) {
|
|
67
80
|
const { selfAid, ownerAid, snapshot, remarks } = input;
|
|
68
81
|
if (!snapshot)
|
|
@@ -83,6 +96,13 @@ export function renderOwnerDirectoryMarkdown(input) {
|
|
|
83
96
|
// 把拉黑对象并列进去等于诱导模型去联系一个明确被拒绝的人。名单本身用
|
|
84
97
|
// `ec directory blocked` 查,注入不需要承担这个用途。
|
|
85
98
|
const blocked = new Set(snapshot.blockedAids ?? []);
|
|
99
|
+
// My Agent Team:本 Agent 自己的名单(`config.team`)。与 PA Team 是两份
|
|
100
|
+
// 独立来源——这份是"我要用谁",那份是"Owner/PA 发下来的团队",两者重叠时
|
|
101
|
+
// 以这份为准。
|
|
102
|
+
const teamSelection = resolveMyAgentTeamAids(input.team, snapshot, selfAid, ownerAid);
|
|
103
|
+
const teamVisible = teamSelection.visible;
|
|
104
|
+
const teamSet = new Set(teamVisible);
|
|
105
|
+
const teamEntryByAid = new Map(snapshot.entries.map(entry => [entry.aid, entry]));
|
|
86
106
|
// PA Team 优先于分类:服务端下发的团队成员列表
|
|
87
107
|
const paContextAids = snapshot.openPaContext ?? [];
|
|
88
108
|
const paTeam = [];
|
|
@@ -97,6 +117,10 @@ export function renderOwnerDirectoryMarkdown(input) {
|
|
|
97
117
|
continue;
|
|
98
118
|
if (blocked.has(entry.aid))
|
|
99
119
|
continue;
|
|
120
|
+
// My Agent Team 优先于 PA Team:这份名单是本 Agent 自己的,PA Team 里
|
|
121
|
+
// 不再重复渲染,改为在 PA Team 组里列名并说明"上面已有完整记录"。
|
|
122
|
+
if (teamSet.has(entry.aid))
|
|
123
|
+
continue;
|
|
100
124
|
// PA Team 判据优先:在列表里且 ownership_status=owned
|
|
101
125
|
if (isInPaTeam(entry, paContextAids)) {
|
|
102
126
|
paTeam.push(entry);
|
|
@@ -130,7 +154,7 @@ export function renderOwnerDirectoryMarkdown(input) {
|
|
|
130
154
|
' 名字做归一化精确匹配(全半角、空格、结尾称呼不影响),没命中再按包含匹配并标出"可能不是同一个人";',
|
|
131
155
|
' 多条命中会全部列出,要精确就用 AID。',
|
|
132
156
|
'- `ec directory list`:列举和过滤。`--filter \'a,b\'` 组内 OR、多个 `--filter` 之间 AND,',
|
|
133
|
-
' `--type agent`、`--scope internal|external|pa-team|all`、`--owner <aid|unbound>` 按维度筛,',
|
|
157
|
+
' `--type agent`、`--scope internal|external|pa-team|my-agent-team|all`、`--owner <aid|unbound>` 按维度筛,',
|
|
134
158
|
' `--limit` / `--page` 翻页(默认每页 20)。',
|
|
135
159
|
'- `ec directory refresh`:立即同步一次,然后重算本文件。怀疑名录过期时用。',
|
|
136
160
|
'- `ec directory blocked`:查被拉黑的主体。名录里不渲染黑名单,要判断某人能不能联系就查这个。',
|
|
@@ -149,8 +173,21 @@ export function renderOwnerDirectoryMarkdown(input) {
|
|
|
149
173
|
const paTeamFull = paTeam.slice(0, PA_TEAM_LIMIT);
|
|
150
174
|
const paTeamOverflow = paTeam.slice(PA_TEAM_LIMIT);
|
|
151
175
|
const blocks = [
|
|
176
|
+
// My Agent Team:本 Agent 自己的团队成员,full 形态。排在 PA Team 之前:
|
|
177
|
+
// 它比 PA Team 更窄、更贴合当下的工作,而且不受外部开关控制——Owner 在
|
|
178
|
+
// App 里亲手加进来的人,不该因为一个准入开关就从注入内容里消失。
|
|
179
|
+
groupBlockMyAgentTeam(teamVisible, teamSelection.total, teamEntryByAid, remarks),
|
|
152
180
|
// PA Team:个人助理团队成员,full 形态
|
|
153
|
-
groupBlockPaTeam('PA Team', paTeamFull, paTeamOverflow, remarks, '个人助理团队成员,可直接调用或私聊'
|
|
181
|
+
groupBlockPaTeam('PA Team', paTeamFull, paTeamOverflow, remarks, '个人助理团队成员,可直接调用或私聊',
|
|
182
|
+
// 与 My Agent Team 重叠的人:上面已给完整记录,这里只列名,避免模型
|
|
183
|
+
// 以为 PA 下发的名单漏了人。这些人已被循环里的 `continue` 排除在
|
|
184
|
+
// `paTeam` 之外,所以从两份名单本身算交集,而不是从渲染结果里找。
|
|
185
|
+
// 用 `teamVisible`(注入里真出现的那批):被 50 人上限截掉的成员在
|
|
186
|
+
// 上面并没有完整记录,这里必须照常列名,否则两边都看不到他。
|
|
187
|
+
teamVisible
|
|
188
|
+
.filter(aid => paContextAids.includes(aid))
|
|
189
|
+
.map(aid => teamEntryByAid.get(aid))
|
|
190
|
+
.filter((entry) => entry !== undefined && isInPaTeam(entry, paContextAids))),
|
|
154
191
|
// 内部联系人(PA Team 之外):name 形态带 AID
|
|
155
192
|
groupBlock('内部联系人', internal, remarks, 'name_with_aid', 'PA Team 之外、仍归你名下的联系人', internalNote),
|
|
156
193
|
];
|
|
@@ -228,9 +265,23 @@ function groupHint(description, form, note, contactable = true) {
|
|
|
228
265
|
* 超出 100 人时,前 100 人用 full 形态,超出部分降级为 name 形态(无 AID、无描述),
|
|
229
266
|
* 追加在提示行之后。
|
|
230
267
|
*/
|
|
231
|
-
function groupBlockPaTeam(title, fullEntries, overflowEntries, remarks, description
|
|
232
|
-
|
|
268
|
+
function groupBlockPaTeam(title, fullEntries, overflowEntries, remarks, description,
|
|
269
|
+
/**
|
|
270
|
+
* 同时属于 My Agent Team 的成员。它们不参与本组渲染——完整记录已在上面
|
|
271
|
+
* 那组给过——只在提示里点名,让「PA 下发的名单」保持完整,否则 Owner
|
|
272
|
+
* 和 PA 对照时会以为名单漏了人。点名放在提示开头,读者一眼能看到全貌,
|
|
273
|
+
* 不必翻到组尾;下面的清单只列本组独有的人,不重复。
|
|
274
|
+
*/
|
|
275
|
+
overlapEntries = []) {
|
|
276
|
+
// 计数含重叠成员:他们确实属于 PA Team,标题要反映真实人数,提示里说明
|
|
277
|
+
// 完整记录在上面的分组。标题少报会让人以为 PA 下发的名单本身缩水了。
|
|
278
|
+
const total = fullEntries.length + overflowEntries.length + overlapEntries.length;
|
|
233
279
|
let hint = groupHint(description, 'full');
|
|
280
|
+
if (overlapEntries.length > 0) {
|
|
281
|
+
const names = overlapEntries.map(entry => label(entry)).join('、');
|
|
282
|
+
hint = `${overlapEntries.length} 人同时在 My Agent Team 里,完整记录见上面的分组,`
|
|
283
|
+
+ `此处不重复:${names}。${hint}`;
|
|
284
|
+
}
|
|
234
285
|
if (overflowEntries.length > 0) {
|
|
235
286
|
hint += ` PA Team 当前加载 ${fullEntries.length} 人,其余 ${overflowEntries.length} 人仅列名。`;
|
|
236
287
|
}
|
|
@@ -241,7 +292,78 @@ function groupBlockPaTeam(title, fullEntries, overflowEntries, remarks, descript
|
|
|
241
292
|
hint,
|
|
242
293
|
total,
|
|
243
294
|
full: [...fullLines, ...overflowLines],
|
|
244
|
-
compact: [
|
|
295
|
+
compact: [
|
|
296
|
+
...fullLines.map((_, i) => compactRow(fullEntries[i], remarks?.get(fullEntries[i].aid))),
|
|
297
|
+
...overflowLines,
|
|
298
|
+
],
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* My Agent Team 分组。
|
|
303
|
+
*
|
|
304
|
+
* 与其它分组的本质区别:它的成员来源是 `config.team` 这份**独立名单**,
|
|
305
|
+
* 不是名录的子集。所以渲染要按名单遍历,而不是按 `entries` 过滤——
|
|
306
|
+
* 名单里有、名录里没有的人也必须出现,否则"配了但没用"这件事就看不见了。
|
|
307
|
+
*
|
|
308
|
+
* 三种行:
|
|
309
|
+
* - 名录里有且带 `ownerAid` → `full`(这是正常情况);
|
|
310
|
+
* - 名录里有但没 `ownerAid` → 只列 AID + 状态,资料不可信;
|
|
311
|
+
* - 名录里没有 → 只列 AID + 状态。加成员时已经拦过一遍,这里是脏数据的
|
|
312
|
+
* 兜底:Persona 改过、名录同步滞后、Owner 撤了联系人都会留下这种残留。
|
|
313
|
+
*
|
|
314
|
+
* 超过 `MY_AGENT_TEAM_LIMIT` 的部分**整条不渲染**,只在提示里报数:这是本
|
|
315
|
+
* Agent 自己的名单,少露几个人比挤掉别的分组划算。
|
|
316
|
+
*/
|
|
317
|
+
function groupBlockMyAgentTeam(
|
|
318
|
+
/** 已经过筛除与截断的成员;`resolveMyAgentTeamAids` 的 `visible`。 */
|
|
319
|
+
visible,
|
|
320
|
+
/** 截断前的条数,只用来在提示里报"共 N 人"。 */
|
|
321
|
+
totalCount, entryByAid, remarks) {
|
|
322
|
+
const dropped = totalCount - visible.length;
|
|
323
|
+
const fullLines = [];
|
|
324
|
+
const compactLines = [];
|
|
325
|
+
let missing = 0;
|
|
326
|
+
let unbound = 0;
|
|
327
|
+
for (const aid of visible) {
|
|
328
|
+
const entry = entryByAid.get(aid);
|
|
329
|
+
if (!entry) {
|
|
330
|
+
missing++;
|
|
331
|
+
fullLines.push(`- ${aid} | ${TEAM_MISSING_LABEL}`);
|
|
332
|
+
compactLines.push(`- ${aid} | ${TEAM_MISSING_LABEL}`);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (entryOwnerAid(entry) === undefined) {
|
|
336
|
+
unbound++;
|
|
337
|
+
fullLines.push(`- ${aid} | ${TEAM_UNBOUND_LABEL}`);
|
|
338
|
+
compactLines.push(`- ${aid} | ${TEAM_UNBOUND_LABEL}`);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
fullLines.push(fullRow(entry, remarks?.get(aid)));
|
|
342
|
+
compactLines.push(compactRow(entry, remarks?.get(aid)));
|
|
343
|
+
}
|
|
344
|
+
// 提示要能解释每一类异常行,否则模型只能靠猜。顺序固定:语义 → 异常 → 上限。
|
|
345
|
+
let hint = groupHint('你自己的团队成员,可直接调用或私聊', 'full');
|
|
346
|
+
if (missing > 0 || unbound > 0) {
|
|
347
|
+
const parts = [];
|
|
348
|
+
if (unbound > 0)
|
|
349
|
+
parts.push(`${unbound} 人未绑定 Owner`);
|
|
350
|
+
if (missing > 0)
|
|
351
|
+
parts.push(`${missing} 人不在联系人名录中`);
|
|
352
|
+
hint += ` 其中 ${parts.join('、')}——这些条目只有 AID 可用,`
|
|
353
|
+
+ '联系前先用 `ec directory info <AID>` 确认,或让 Owner 在 App 里重新添加。';
|
|
354
|
+
}
|
|
355
|
+
if (dropped > 0) {
|
|
356
|
+
// 只报"截掉了几人",不猜他们去了哪个组:那属于渲染细节,写进提示反而
|
|
357
|
+
// 会让模型去对照分组,而它真正需要知道的是"这个列表不完整"。
|
|
358
|
+
hint += ` 当前 My Agent Team 共 ${totalCount} 人,本组只列前 ${MY_AGENT_TEAM_LIMIT} 人,`
|
|
359
|
+
+ `已截掉 ${dropped} 人。`;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
title: 'My Agent Team',
|
|
363
|
+
hint,
|
|
364
|
+
total: visible.length,
|
|
365
|
+
full: fullLines,
|
|
366
|
+
compact: compactLines,
|
|
245
367
|
};
|
|
246
368
|
}
|
|
247
369
|
function groupBlock(title, entries, remarks, form,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readAccessPolicy, readExplicitAllowExternalContacts } from '../config/access-policy.js';
|
|
2
|
+
import { ConfigTarget, read } from '../config/config-manager.js';
|
|
2
3
|
/**
|
|
3
4
|
* 名录「开关语义」的唯一来源。
|
|
4
5
|
*
|
|
@@ -39,6 +40,28 @@ personalAssistantAid) {
|
|
|
39
40
|
return { internalContacts: true, externalContacts: isAssistant, strangerContacts: false };
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 本 Agent 自己的团队名单(`config.team`),由 Owner 在 Evol App 的 Team
|
|
45
|
+
* Workspace 里维护,走 Menu protocol 写进 AgentConfig。
|
|
46
|
+
*
|
|
47
|
+
* 读失败返回空数组而不是抛错:名录渲染是每轮都要跑的派生产物,一份读不出的
|
|
48
|
+
* 配置不该让整份 `directory.md` 生成失败——少一个分组远好过让 agent 没有名录。
|
|
49
|
+
* 干净非法值(空串)也在这里过滤,渲染侧不必再防一遍。
|
|
50
|
+
*/
|
|
51
|
+
export function resolveMyAgentTeam(selfAid) {
|
|
52
|
+
try {
|
|
53
|
+
const config = read(ConfigTarget.Agent, { self: selfAid }, { cache: true });
|
|
54
|
+
const team = config?.team;
|
|
55
|
+
if (!Array.isArray(team))
|
|
56
|
+
return [];
|
|
57
|
+
return [...new Set(team.filter((aid) => typeof aid === 'string')
|
|
58
|
+
.map(aid => aid.trim())
|
|
59
|
+
.filter(aid => aid !== ''))];
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
/** 这个 agent 是否是 Owner 名录里的个人助理。快照缺失、AID 为空都返回 false。 */
|
|
43
66
|
export function isPersonalAssistantSnapshot(selfAid, snapshot) {
|
|
44
67
|
const aid = snapshot?.personalAssistant?.aid;
|
|
@@ -23,7 +23,8 @@ import { editDistance, normalizeDirectoryText, sameDirectoryName, stripTrailingP
|
|
|
23
23
|
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
24
24
|
import { snapshotOwnerAid, refreshOwnerDirectory, syncOwnerDirectoryForLookup } from './owner-directory-admission.js';
|
|
25
25
|
import { getPeerSnapshot } from '../config/peer-book.js';
|
|
26
|
-
import { resolveEntryContactable } from './owner-directory-policy.js';
|
|
26
|
+
import { resolveEntryContactable, resolveMyAgentTeam } from './owner-directory-policy.js';
|
|
27
|
+
import { resolveMyAgentTeamAids } from './owner-directory-markdown.js';
|
|
27
28
|
/** `info` 按名字命中时的默认上限。 */
|
|
28
29
|
const INFO_NAME_MATCH_LIMIT = 20;
|
|
29
30
|
/** `list` 的分页默认值与上限;与 `ec skill list` 的默认 20 条一致。 */
|
|
@@ -168,11 +169,18 @@ export async function executeDirectoryQueryCommand(command) {
|
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
171
|
// list:过滤后分页。过滤条件为空时就是全量列举。
|
|
171
|
-
|
|
172
|
+
const remarks = readAllRemarks(directory);
|
|
173
|
+
// `--scope my-agent-team` 的成员来源:与名录是两份独立名单,必须显式传进去。
|
|
174
|
+
// 用渲染器同一份筛除+截断结果:这条命令是给 agent 查"我的注入内容里有哪些
|
|
175
|
+
// 团队成员"的,比注入多列出被 50 人上限截掉的部分就等于说谎。
|
|
176
|
+
const teamSelection = resolveMyAgentTeamAids(resolveMyAgentTeam(command.selfAid), snapshot, command.selfAid, ownerAid);
|
|
177
|
+
const teamAids = teamSelection.visible;
|
|
178
|
+
let filtered = filterDirectory(snapshot, ownerAid, remarks, {
|
|
172
179
|
...(command.filters ? { filters: command.filters } : {}),
|
|
173
180
|
...(command.type ? { type: command.type } : {}),
|
|
174
181
|
...(command.scope ? { scope: command.scope } : {}),
|
|
175
182
|
...(command.ownerAid ? { ownerAid: command.ownerAid } : {}),
|
|
183
|
+
...(command.scope === 'my-agent-team' ? { teamAids } : {}),
|
|
176
184
|
});
|
|
177
185
|
let synced = false;
|
|
178
186
|
if (filtered.length === 0 && command.filters?.length) {
|
|
@@ -181,11 +189,12 @@ export async function executeDirectoryQueryCommand(command) {
|
|
|
181
189
|
const refreshed = withIdentityEntries(cache.readSnapshot(scope));
|
|
182
190
|
if (refreshed) {
|
|
183
191
|
snapshot = refreshed;
|
|
184
|
-
filtered = filterDirectory(snapshot, ownerAid,
|
|
192
|
+
filtered = filterDirectory(snapshot, ownerAid, remarks, {
|
|
185
193
|
...(command.filters ? { filters: command.filters } : {}),
|
|
186
194
|
...(command.type ? { type: command.type } : {}),
|
|
187
195
|
...(command.scope ? { scope: command.scope } : {}),
|
|
188
196
|
...(command.ownerAid ? { ownerAid: command.ownerAid } : {}),
|
|
197
|
+
...(command.scope === 'my-agent-team' ? { teamAids } : {}),
|
|
189
198
|
});
|
|
190
199
|
}
|
|
191
200
|
}
|
|
@@ -194,7 +203,6 @@ export async function executeDirectoryQueryCommand(command) {
|
|
|
194
203
|
const total = filtered.length;
|
|
195
204
|
const start = (page - 1) * limit;
|
|
196
205
|
const ownerRef = ownerRefAid(snapshot, ownerAid);
|
|
197
|
-
const remarks = readAllRemarks(directory);
|
|
198
206
|
const entries = filtered.slice(start, start + limit)
|
|
199
207
|
// 检索结果不带本地备注正文:要看正文用 `ec directory info <AID>`。
|
|
200
208
|
.map(entry => describeEntry(entry, ownerRef, remarks.get(entry.aid), contactable, {
|
|
@@ -202,6 +210,11 @@ export async function executeDirectoryQueryCommand(command) {
|
|
|
202
210
|
}));
|
|
203
211
|
return {
|
|
204
212
|
ok: true, action: 'list', entries, page, limit, total, hasMore: start + entries.length < total,
|
|
213
|
+
// `--scope my-agent-team` 被 50 人上限截断时把真实条数一并给出:注入里只
|
|
214
|
+
// 有前 50 人,调用方不该以为名单只有这么长。其它 scope 不带这两个字段。
|
|
215
|
+
...(command.scope === 'my-agent-team' && teamSelection.dropped > 0
|
|
216
|
+
? { myAgentTeamTotal: teamSelection.total, myAgentTeamDropped: teamSelection.dropped }
|
|
217
|
+
: {}),
|
|
205
218
|
};
|
|
206
219
|
}
|
|
207
220
|
/**
|
|
@@ -463,9 +476,10 @@ function takePositional(args) {
|
|
|
463
476
|
function parseScope(value) {
|
|
464
477
|
if (value === undefined)
|
|
465
478
|
return undefined;
|
|
466
|
-
if (value === 'internal' || value === 'external' || value === 'pa-team'
|
|
479
|
+
if (value === 'internal' || value === 'external' || value === 'pa-team'
|
|
480
|
+
|| value === 'my-agent-team' || value === 'all')
|
|
467
481
|
return value;
|
|
468
|
-
throw new DirectoryQueryError('INVALID_ARGUMENT', '--scope must be internal, external, pa-team or all');
|
|
482
|
+
throw new DirectoryQueryError('INVALID_ARGUMENT', '--scope must be internal, external, pa-team, my-agent-team or all');
|
|
469
483
|
}
|
|
470
484
|
/**
|
|
471
485
|
* `--owner <aid|unbound>`:按条目归属过滤。
|