evolcore 0.0.45 → 0.0.47
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 +113 -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 +22 -6
- package/dist/agents/codex/app-server-client.js +34 -27
- 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/group/fs-download.js +1 -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 +675 -120
- package/dist/channels/daemon.js +1 -1
- 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 +42 -56
- package/dist/cli/daemon-lifecycle-client.js +55 -19
- 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-channel.js +2 -2
- package/dist/cli/init.js +57 -21
- 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 +135 -46
- package/dist/cli/services-command.js +28 -5
- package/dist/cli/task-context.js +83 -15
- package/dist/cli/upgrade-command.js +4 -2
- package/dist/config/config-field-policy.js +24 -0
- package/dist/config/config-manager.js +49 -19
- package/dist/config/peer-book-store.js +167 -127
- package/dist/config/peer-role-resolver.js +24 -4
- package/dist/config/provider-identity-migration.js +158 -6
- 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/schema-migration.js +123 -16
- package/dist/config/schema-registry.js +6 -2
- 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 +91 -43
- package/dist/core/auth/agent-delegation.js +13 -3
- package/dist/core/auth/delegation-diagnostics.js +56 -15
- package/dist/core/auth/operation-authorizer.js +2 -2
- 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 +39 -12
- package/dist/core/command/menu-protocol.js +8 -16
- package/dist/core/command/skill-slash.js +6 -2
- package/dist/core/command/slash-handler.js +4 -6
- 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-bootstrap.js +11 -9
- package/dist/core/daemon-control.js +4 -7
- package/dist/core/daemon-lifecycle.js +189 -143
- package/dist/core/evolagent-registry.js +50 -2
- 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/host-snapshot.js +9 -4
- package/dist/core/inference/text-inference.js +12 -2
- package/dist/core/initialization/service.js +22 -4
- package/dist/core/invoke/invoke-service.js +24 -3
- package/dist/core/ipc-registration.js +7 -3
- package/dist/core/memory/consolidation.js +6 -6
- 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/ownership/owner-resolver.js +27 -10
- 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/relation/peer-identity.js +5 -1
- package/dist/core/relation/same-owner-proof.js +2 -1
- package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
- package/dist/core/session/session-file-health.js +36 -7
- 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/task/task-image-resources.js +1 -1
- 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 +65 -16
- package/dist/ecweb/runtime/supervisor.js +79 -50
- 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 +132 -75
- package/dist/ipc.js +35 -8
- 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 +18 -4
- package/dist/trigger/script-sandbox.js +39 -2
- package/dist/trigger/state.js +7 -0
- package/dist/utils/aid-bind.js +155 -18
- package/dist/utils/atomic-write.js +3 -3
- package/dist/utils/cross-platform.js +59 -16
- package/dist/utils/error-utils.js +26 -1
- package/dist/utils/instance-registry.js +94 -35
- package/dist/utils/process-introspect.js +187 -27
- package/dist/utils/project-path.js +47 -3
- package/dist/utils/upgrade-jobs.js +4 -4
- 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/aid.md +3 -1
- 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 +17 -5
- 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,7 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import sharp from 'sharp';
|
|
5
4
|
import { agentDataDir } from '../../paths.js';
|
|
6
5
|
import { checkProtectedPathAccess, isSameOrDescendant } from '../permission/protected-paths.js';
|
|
7
6
|
export const TASK_IMAGE_CHUNK_BYTES = 192 * 1024;
|
|
@@ -65,6 +64,7 @@ export class TaskImageResources {
|
|
|
65
64
|
finally {
|
|
66
65
|
await handle.close();
|
|
67
66
|
}
|
|
67
|
+
const { default: sharp } = await import('sharp');
|
|
68
68
|
const metadata = await sharp(bytes, { limitInputPixels: 40_000_000 }).metadata();
|
|
69
69
|
const mimeType = IMAGE_MIMES[metadata.format ?? ''];
|
|
70
70
|
if (!mimeType || !metadata.width || !metadata.height)
|
|
@@ -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>`:按条目归属过滤。
|
|
@@ -45,6 +45,8 @@ export function searchDirectory(snapshot, ownerAid, remarks, options) {
|
|
|
45
45
|
continue;
|
|
46
46
|
if (scope === 'pa-team' && !isInPaTeam(entry, snapshot.openPaContext ?? []))
|
|
47
47
|
continue;
|
|
48
|
+
if (scope === 'my-agent-team' && !(options.teamAids ?? []).includes(entry.aid))
|
|
49
|
+
continue;
|
|
48
50
|
if (typeFilter && (entry.type ?? '').toLowerCase() !== typeFilter)
|
|
49
51
|
continue;
|
|
50
52
|
if (ownerFilter) {
|
|
@@ -163,6 +165,11 @@ export function filterDirectory(snapshot, ownerAid, remarks, options = {}) {
|
|
|
163
165
|
const scope = options.scope ?? 'all';
|
|
164
166
|
const typeFilter = normalizeDirectoryText(options.type ?? '');
|
|
165
167
|
const ownerFilter = normalizeDirectoryText(options.ownerAid ?? '');
|
|
168
|
+
if (scope === 'my-agent-team') {
|
|
169
|
+
return filterMyAgentTeam(snapshot, options.teamAids ?? [], {
|
|
170
|
+
groups, typeFilter, ownerFilter, remarks,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
166
173
|
return snapshot.entries
|
|
167
174
|
.filter(entry => {
|
|
168
175
|
const internal = isInternalEntry(entry, ownerRef);
|
|
@@ -188,6 +195,46 @@ export function filterDirectory(snapshot, ownerAid, remarks, options = {}) {
|
|
|
188
195
|
|| normalizeDirectoryText(a.name).localeCompare(normalizeDirectoryText(b.name))
|
|
189
196
|
|| a.aid.localeCompare(b.aid));
|
|
190
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* `--scope my-agent-team`:以 `config.team` 为基准,左连名录条目。
|
|
200
|
+
*
|
|
201
|
+
* 不能复用上面的 `entries.filter(...)`:那份名单里的 AID 可能根本不在名录中
|
|
202
|
+
* (成员被移出联系人、名录尚未同步、名单残留),而 `filter` 只会漏掉它们。
|
|
203
|
+
* 漏掉恰恰是这个 scope 最该回答的问题——"我配了他,为什么用不了"。
|
|
204
|
+
* 所以名录里找不到的成员补一条只有 AID 的占位条目,`ownerAid` 天然为空,
|
|
205
|
+
* 调用方据此判它不可用。
|
|
206
|
+
*
|
|
207
|
+
* 顺序照名单本身,不做内部优先排序:这里回答的是"我的团队有谁",
|
|
208
|
+
* 名单顺序就是 Owner 看到的顺序。
|
|
209
|
+
*/
|
|
210
|
+
function filterMyAgentTeam(snapshot, teamAids, filters) {
|
|
211
|
+
const remarks = filters.remarks;
|
|
212
|
+
const byAid = new Map(snapshot.entries.map(entry => [entry.aid, entry]));
|
|
213
|
+
const seen = new Set();
|
|
214
|
+
const out = [];
|
|
215
|
+
for (const raw of teamAids) {
|
|
216
|
+
const aid = raw.trim();
|
|
217
|
+
if (!aid || seen.has(aid))
|
|
218
|
+
continue;
|
|
219
|
+
seen.add(aid);
|
|
220
|
+
const entry = byAid.get(aid) ?? { aid, name: aid };
|
|
221
|
+
if (filters.typeFilter && normalizeDirectoryText(entry.type ?? '') !== filters.typeFilter)
|
|
222
|
+
continue;
|
|
223
|
+
const entryOwner = normalizeDirectoryText(entry.ownerAid ?? '');
|
|
224
|
+
if (filters.ownerFilter) {
|
|
225
|
+
if (filters.ownerFilter === 'unbound' ? entryOwner !== '' : entryOwner !== filters.ownerFilter)
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (filters.groups.length > 0) {
|
|
229
|
+
const remark = remarks?.get(aid);
|
|
230
|
+
const hit = filters.groups.every(group => group.some(keyword => scoreToken(keyword, entry, remark, remark?.body).score > 0));
|
|
231
|
+
if (!hit)
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
out.push(entry);
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
191
238
|
/**
|
|
192
239
|
* 单个条目的完整记录,用于 `show`。描述与备注不截断。
|
|
193
240
|
*
|