evolcore 0.0.41-test.2 → 0.0.42-test.0
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 +38 -2
- package/bin/codex-managed-hook.mjs +9 -5
- package/dist/agents/baseagent.js +156 -16
- package/dist/agents/claude-runner.js +10 -3
- package/dist/agents/codex/catalog.js +8 -4
- package/dist/agents/codex-runner.js +236 -59
- package/dist/agents/ecagent-runner.js +82 -13
- package/dist/aun/aid/agentmd.js +106 -27
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +65 -13
- package/dist/aun/aid/identity.js +70 -4
- package/dist/aun/aid/index.js +2 -2
- package/dist/aun/service-proxy.js +25 -1
- package/dist/channels/aun.js +242 -209
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +1 -1
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +1 -1
- package/dist/channels/wecom.js +1 -1
- package/dist/cli/agent-command.js +183 -3
- package/dist/cli/agent-create.js +92 -86
- package/dist/cli/agent.js +136 -1
- package/dist/cli/aun-commands.js +137 -35
- package/dist/cli/bench.js +8 -2
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +235 -51
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/directory.js +170 -0
- package/dist/cli/index.js +40 -30
- package/dist/cli/init-channel.js +4 -4
- package/dist/cli/init.js +47 -32
- package/dist/cli/managed-command-guard.js +4 -1
- package/dist/cli/model.js +27 -18
- package/dist/cli/pa-workspace-command.js +191 -0
- package/dist/cli/{contact.js → peer.js} +19 -25
- package/dist/cli/restart-monitor.js +11 -4
- package/dist/cli/thread-command.js +47 -18
- package/dist/cli/version.js +18 -18
- package/dist/config/access-policy.js +29 -12
- package/dist/config/boot-log.js +65 -10
- package/dist/config/builtin-roles.js +2 -4
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +28 -20
- package/dist/config/{contact-bind-code.js → peer-bind-code.js} +6 -6
- package/dist/config/{contact-book-store.js → peer-book-store.js} +75 -75
- package/dist/config/{contact-book-v2-startup.js → peer-book-v2-startup.js} +2 -2
- package/dist/config/{contact-book.js → peer-book.js} +47 -47
- package/dist/config/peer-operation-service.js +132 -0
- package/dist/config/{contact-request-service.js → peer-request-service.js} +90 -90
- package/dist/config/peer-role-resolver.js +3 -3
- package/dist/config/providers-config.js +17 -8
- package/dist/config/providers.js +1 -1
- package/dist/config/schema-migration.js +336 -39
- package/dist/core/agent-application-service.js +8 -2
- package/dist/core/agent-create-status.js +4 -5
- package/dist/core/agent-ipc-registration.js +5 -4
- package/dist/core/agent-runtime.js +30 -17
- package/dist/core/auth/operation-authorizer.js +0 -24
- package/dist/core/auth/operation-catalog.js +4 -20
- package/dist/core/baseagent-loader.js +27 -3
- package/dist/core/bootstrap-service.js +5 -22
- package/dist/core/capability/capability-manager.js +52 -35
- package/dist/core/channel-loader.js +43 -2
- package/dist/core/channel-runtime.js +2 -2
- package/dist/core/command/agent-control.js +54 -18
- package/dist/core/command/command-handler.js +92 -72
- package/dist/core/command/connect-menu.js +35 -42
- package/dist/core/command/daemon-diagnostics.js +41 -5
- package/dist/core/command/data-root-error.js +10 -0
- package/dist/core/command/data-root-resolver.js +53 -13
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +163 -65
- package/dist/core/command/menu-protocol.js +52 -0
- package/dist/core/command/pa-workspace-calendar.js +223 -0
- package/dist/core/command/pa-workspace-store.js +459 -0
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +57 -41
- package/dist/core/daemon-lifecycle.js +90 -31
- package/dist/core/evolagent.js +6 -10
- package/dist/core/handoff/runtime.js +11 -4
- package/dist/core/host-snapshot.js +208 -0
- package/dist/core/initialization/service.js +152 -20
- package/dist/core/ipc-registration.js +33 -4
- package/dist/core/memory/batch-meta.js +27 -0
- package/dist/core/memory/consolidation-ops-records.js +44 -1
- package/dist/core/memory/consolidation.js +169 -27
- package/dist/core/message/aun-ipc-sender.js +2 -8
- package/dist/core/message/im-renderer.js +56 -3
- package/dist/core/message/message-admission.js +121 -124
- package/dist/core/message/message-bridge.js +38 -54
- package/dist/core/message/message-queue.js +7 -0
- package/dist/core/message/outbound.js +34 -9
- package/dist/core/message/response-engine.js +154 -73
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +2 -2
- package/dist/core/model/model-catalog.js +5 -4
- package/dist/core/model/model-diagnostics.js +6 -5
- package/dist/core/model/model-fallback.js +3 -6
- package/dist/core/model/model-permission.js +1 -1
- package/dist/core/ownership/owner-resolver.js +9 -9
- package/dist/core/permission/approval-gateway.js +1 -1
- package/dist/core/permission/ec-command-parser.js +2 -2
- package/dist/core/permission/tool-canonical.js +96 -46
- package/dist/core/permission/tool-error-code.js +41 -0
- package/dist/core/permission/tool-policy.js +71 -47
- package/dist/core/role/runtime-policy.js +1 -1
- package/dist/core/session/session-idle-monitor.js +10 -0
- package/dist/core/session/session-manager.js +2 -4
- package/dist/core/session/session-title.js +36 -8
- package/dist/core/system-session/memory.js +2 -7
- package/dist/core/thread/command-parser.js +6 -2
- package/dist/core/thread/ipc-operation.js +51 -36
- package/dist/core/thread/thread-operation.js +29 -61
- package/dist/core/thread/thread-service.js +57 -13
- package/dist/directory/canonical-digest.js +54 -0
- package/dist/directory/owner-directory-admission.js +114 -43
- package/dist/directory/owner-directory-agentmd-sync.js +89 -0
- package/dist/directory/owner-directory-cache.js +847 -459
- package/dist/directory/owner-directory-markdown.js +272 -0
- package/dist/directory/owner-directory-query-operation.js +195 -0
- package/dist/directory/owner-directory-remark-operation.js +147 -0
- package/dist/directory/owner-directory-remarks.js +145 -0
- package/dist/directory/owner-directory-scope.js +55 -0
- package/dist/directory/owner-directory-search.js +148 -0
- package/dist/directory/owner-directory-store.js +227 -0
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/message-context-service.js +13 -9
- package/dist/index.js +195 -37
- package/dist/ipc.js +86 -22
- package/dist/paths.js +11 -8
- package/dist/product.js +2 -0
- package/dist/proxy/manager.js +13 -2
- package/dist/proxy/service-supervisor.js +8 -1
- package/dist/trigger/history.js +23 -0
- package/dist/trigger/scheduler.js +3 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/cross-platform.js +35 -0
- package/dist/utils/ecweb-supervisor.js +42 -0
- package/dist/utils/error-utils.js +2 -1
- package/dist/utils/evolcore-version.js +19 -0
- package/dist/utils/host-info.js +242 -5
- package/dist/utils/instance-registry.js +28 -6
- package/dist/utils/logger.js +59 -14
- package/dist/utils/machine-info.js +46 -0
- package/dist/utils/process-introspect.js +166 -2
- package/dist/utils/startup-trace.js +245 -0
- package/ecagent/dist/agent-loop.js +27 -13
- package/ecagent/dist/harness/agent-harness.js +3 -3
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +72 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +17 -27
- package/kits/docs/evolcore/agent.md +4 -1
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +16 -5
- package/kits/docs/evolcore/ctl.md +9 -0
- package/kits/docs/evolcore/ec-capabilities.md +19 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +79 -5
- package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -1
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +13 -4
- package/kits/docs/evolcore/msg.md +1 -1
- package/kits/docs/evolcore/pa-workspace.md +51 -0
- package/kits/docs/evolcore/peer.md +73 -0
- package/kits/docs/evolcore/thread-chain.md +4 -1
- package/kits/eck_manifest.json +21 -0
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/agent-config.schema.16.json +6 -0
- package/kits/schemas/agent-config.schema.17.json +897 -0
- package/kits/schemas/daemon.schema.9.json +8 -1
- package/kits/skills/ec-agent-create/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +45 -27
- package/kits/skills/ec-service-proxy/SKILL.md +7 -2
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +4 -5
- package/kits/skills/thread-ops/SKILL.md +11 -11
- package/kits/templates/bootstrap-welcome.md +3 -15
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +24 -23
- package/kits/templates/system-fragments/commands.md +12 -5
- package/kits/templates/system-fragments/thread.md +18 -3
- package/package.json +6 -4
- package/dist/config/contact-operation-service.js +0 -235
- package/dist/directory/owner-directory-authorization.js +0 -309
- package/kits/docs/evolcore/contact.md +0 -78
- /package/dist/config/{contact-alias.js → peer-alias.js} +0 -0
|
@@ -12,6 +12,8 @@ const MIGRATION_KIND = {
|
|
|
12
12
|
'provider-service-type-v1': 'provider-service-type',
|
|
13
13
|
'relation-config-v11-v1': 'agent-only-model',
|
|
14
14
|
'legacy-model-selection-v1': 'agent-only-model',
|
|
15
|
+
'access-policy-v17-v1': 'agent-only-model',
|
|
16
|
+
'peer-file-v1': 'agent-only-model',
|
|
15
17
|
};
|
|
16
18
|
const SUPPORTED_BASEAGENTS = new Set(['claude', 'codex', 'gemini', 'ecagent']);
|
|
17
19
|
const BASEAGENT_ALIASES = new Map([
|
|
@@ -33,7 +35,44 @@ function isRecord(value) {
|
|
|
33
35
|
function hasOwn(value, field) {
|
|
34
36
|
return Object.prototype.hasOwnProperty.call(value, field);
|
|
35
37
|
}
|
|
38
|
+
let startupReadCache = null;
|
|
39
|
+
/**
|
|
40
|
+
* 在这个作用域内共享配置读取结果。
|
|
41
|
+
*
|
|
42
|
+
* 只能包住「只读规划」阶段:一旦有迁移落盘,缓存里的内容就过期了。
|
|
43
|
+
* 每次启动在三份迁移之间开一次,结束后自动失效。
|
|
44
|
+
*/
|
|
45
|
+
export async function withMigrationReadCache(run) {
|
|
46
|
+
const previous = startupReadCache;
|
|
47
|
+
startupReadCache = new Map();
|
|
48
|
+
try {
|
|
49
|
+
return await run();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
startupReadCache = previous;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 丢弃当前作用域里已缓存的内容。
|
|
57
|
+
*
|
|
58
|
+
* 多个迁移改的是同一批文件(例如 agentOnly 会剔掉 relation 里的 model 字段,
|
|
59
|
+
* relationVersion 又会重写同一个文件)。一旦前一个迁移真的落盘,后一个迁移必须
|
|
60
|
+
* 重新读盘,否则它会基于旧文本整文件覆盖,把前一个的改动回滚掉。
|
|
61
|
+
* 调用方在「该迁移确实产生了改动」时调用本函数。
|
|
62
|
+
*/
|
|
63
|
+
export function invalidateMigrationReadCache() {
|
|
64
|
+
startupReadCache?.clear();
|
|
65
|
+
}
|
|
36
66
|
function readJson(file) {
|
|
67
|
+
if (startupReadCache) {
|
|
68
|
+
const cached = startupReadCache.get(file);
|
|
69
|
+
if (cached)
|
|
70
|
+
return cached;
|
|
71
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
72
|
+
const entry = { value: JSON.parse(text), text };
|
|
73
|
+
startupReadCache.set(file, entry);
|
|
74
|
+
return entry;
|
|
75
|
+
}
|
|
37
76
|
const text = fs.readFileSync(file, 'utf8');
|
|
38
77
|
return { value: JSON.parse(text), text };
|
|
39
78
|
}
|
|
@@ -825,7 +864,6 @@ function planAgentOnlyModelMigration(home) {
|
|
|
825
864
|
filesChanged: 0,
|
|
826
865
|
relationFilesChanged: 0,
|
|
827
866
|
defaultsFieldsRemoved: 0,
|
|
828
|
-
defaultsBaseagentsAdded: 0,
|
|
829
867
|
ownerModelsPromoted: 0,
|
|
830
868
|
ownerEffortsPromoted: 0,
|
|
831
869
|
legacyModelsRestored: 0,
|
|
@@ -865,7 +903,6 @@ function planAgentOnlyModelMigration(home) {
|
|
|
865
903
|
const inheritedBlocks = baseagentSource(defaultsRaw) ?? {};
|
|
866
904
|
const agentEntries = fs.readdirSync(agentsRoot, { withFileTypes: true })
|
|
867
905
|
.sort((left, right) => left.name.localeCompare(right.name));
|
|
868
|
-
const declaredBaseagents = new Set();
|
|
869
906
|
for (const entry of agentEntries) {
|
|
870
907
|
if (!entry.isDirectory() || !validAid(entry.name))
|
|
871
908
|
continue;
|
|
@@ -877,13 +914,6 @@ function planAgentOnlyModelMigration(home) {
|
|
|
877
914
|
const agent = parsed.value;
|
|
878
915
|
if (isRecord(agent)) {
|
|
879
916
|
const active = canonicalBaseagent(agent.active_baseagent);
|
|
880
|
-
if (active)
|
|
881
|
-
declaredBaseagents.add(active);
|
|
882
|
-
for (const name of baseagentNames(agent)) {
|
|
883
|
-
const canonical = canonicalBaseagent(name);
|
|
884
|
-
if (canonical)
|
|
885
|
-
declaredBaseagents.add(canonical);
|
|
886
|
-
}
|
|
887
917
|
const selected = active || canonicalBaseagent(defaultsRaw.active_baseagent);
|
|
888
918
|
if (selected) {
|
|
889
919
|
const ownerSelections = ownerRelationSelections(path.join(agentsRoot, entry.name, 'relations'), firstOwnerAid(agent), selected);
|
|
@@ -948,38 +978,15 @@ function planAgentOnlyModelMigration(home) {
|
|
|
948
978
|
summary.relationFilesChanged += 1;
|
|
949
979
|
}
|
|
950
980
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}
|
|
958
|
-
const value = defaults ? { ...defaults } : { $schema_version: 5 };
|
|
959
|
-
if (value.baseagents !== undefined && !isRecord(value.baseagents)) {
|
|
960
|
-
throw new Error(`${defaultsFile}: baseagents must be an object`);
|
|
961
|
-
}
|
|
962
|
-
const blocks = { ...(isRecord(value.baseagents) ? value.baseagents : {}) };
|
|
963
|
-
for (const name of [...declaredBaseagents].sort()) {
|
|
964
|
-
if (hasOwn(blocks, name))
|
|
965
|
-
continue;
|
|
966
|
-
blocks[name] = {};
|
|
967
|
-
summary.defaultsBaseagentsAdded += 1;
|
|
968
|
-
}
|
|
969
|
-
if (summary.defaultsBaseagentsAdded > 0) {
|
|
970
|
-
value.baseagents = blocks;
|
|
971
|
-
if (pendingDefaults)
|
|
972
|
-
pendingDefaults.after = jsonText(value);
|
|
973
|
-
else {
|
|
974
|
-
changes.push({ file: defaultsFile, kind: 'agent-only-model', before: original?.text ?? null, after: jsonText(value) });
|
|
975
|
-
details.push({ file: path.relative(home, defaultsFile), removed: [] });
|
|
976
|
-
summary.filesChanged += 1;
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}
|
|
981
|
+
// 这里曾经会把所有 Agent 声明过的后端名并集补进 defaults.baseagents。
|
|
982
|
+
// 那个做法是错的:defaults 会被每个 Agent 合并,因此只要有一个 Agent 用了
|
|
983
|
+
// codex,空 block {codex:{}} 就会出现在**所有** Agent 的 effective config 里,
|
|
984
|
+
// 让 codex 插件对所有 Agent isEnabled 通过(只要机器上有全局 codex 凭据),
|
|
985
|
+
// 于是多出一整套永远不用的 runner。后端可用性本来就只看各 Agent 自己的配置,
|
|
986
|
+
// 不需要在 defaults 里"注册"名称。
|
|
980
987
|
return { home, changes, summary, details };
|
|
981
988
|
}
|
|
982
|
-
/** Remove relation model parameters
|
|
989
|
+
/** Remove relation model parameters from agent and relation configs. */
|
|
983
990
|
export function runAgentOnlyModelSchemaMigration(options = {}) {
|
|
984
991
|
const id = 'agent-only-model-v1';
|
|
985
992
|
const home = path.resolve(options.home || resolvePaths().root);
|
|
@@ -1535,3 +1542,293 @@ export async function ensureRelationConfigVersionMigrationOnStartup() {
|
|
|
1535
1542
|
throw new ConfigError('RELATION_CONFIG_VERSION_MIGRATION_FAILED', `Automatic relation-config version migration failed: ${detail}`, { cause: error });
|
|
1536
1543
|
}
|
|
1537
1544
|
}
|
|
1545
|
+
// ── Agent 消息准入重写:v16 → v17 ────────────────────────────────────────────
|
|
1546
|
+
const ACCESS_POLICY_TARGET_VERSION = 17;
|
|
1547
|
+
/**
|
|
1548
|
+
* 旧三态 `policyMode` + 两个名录开关 → 新三档开关。
|
|
1549
|
+
*
|
|
1550
|
+
* - `owners` → 三档全关,等价于"只收 Owner 与个人助理"。
|
|
1551
|
+
* - `open` → 打开陌生人档;内部档保持开启。
|
|
1552
|
+
* - `contacts`→ 旧语义是"Owner + 本地联系人簿的 active 联系人"。三档里没有对应位置,
|
|
1553
|
+
* 因此把该 Agent 本地联系人簿里的 active 条目提升进 `allowedAids`,
|
|
1554
|
+
* 避免升级后突然丢联系人;其余按最严格处理(三档全关)。
|
|
1555
|
+
* - 两个名录开关合并到 `allowInternalContacts`:都为显式 false 时才收紧内部档。
|
|
1556
|
+
*
|
|
1557
|
+
* `allowExternalContacts` 同名保留,语义从"普通外部发送者"收敛为"名录里的外部条目"。
|
|
1558
|
+
*/
|
|
1559
|
+
function rewriteAccessPolicy(access, legacyContacts) {
|
|
1560
|
+
const removed = [];
|
|
1561
|
+
const migrated = [];
|
|
1562
|
+
const promoted = [];
|
|
1563
|
+
if (!hasOwn(access, 'policyMode') && !hasOwn(access, 'allowOwnerDirectoryContacts')
|
|
1564
|
+
&& !hasOwn(access, 'allowOwnerAgentDirectory')) {
|
|
1565
|
+
return { value: access, removed, migrated, promoted };
|
|
1566
|
+
}
|
|
1567
|
+
const mode = typeof access.policyMode === 'string' ? access.policyMode : undefined;
|
|
1568
|
+
const ownerContacts = access.allowOwnerDirectoryContacts;
|
|
1569
|
+
const ownerAgents = access.allowOwnerAgentDirectory;
|
|
1570
|
+
const externalExplicit = typeof access.allowExternalContacts === 'boolean'
|
|
1571
|
+
? access.allowExternalContacts : undefined;
|
|
1572
|
+
const value = { ...access };
|
|
1573
|
+
let internal = true;
|
|
1574
|
+
let external = externalExplicit ?? false;
|
|
1575
|
+
let stranger = false;
|
|
1576
|
+
if (mode === 'open') {
|
|
1577
|
+
internal = true;
|
|
1578
|
+
stranger = true;
|
|
1579
|
+
}
|
|
1580
|
+
else if (mode === 'contacts') {
|
|
1581
|
+
// 目标达成方式是旧联系人提升进白名单,三档本身保持最严格。
|
|
1582
|
+
internal = true;
|
|
1583
|
+
}
|
|
1584
|
+
else if (mode === 'owners') {
|
|
1585
|
+
internal = false;
|
|
1586
|
+
external = false;
|
|
1587
|
+
}
|
|
1588
|
+
if (ownerContacts === false && ownerAgents === false)
|
|
1589
|
+
internal = false;
|
|
1590
|
+
if (mode !== undefined) {
|
|
1591
|
+
migrated.push(`policyMode=${mode}`);
|
|
1592
|
+
}
|
|
1593
|
+
for (const field of ['policyMode', 'allowOwnerDirectoryContacts', 'allowOwnerAgentDirectory']) {
|
|
1594
|
+
if (!hasOwn(value, field))
|
|
1595
|
+
continue;
|
|
1596
|
+
delete value[field];
|
|
1597
|
+
removed.push(field);
|
|
1598
|
+
}
|
|
1599
|
+
if (mode === 'contacts' && isRecord(legacyContacts)) {
|
|
1600
|
+
const contacts = legacyContacts.contacts;
|
|
1601
|
+
if (isRecord(contacts)) {
|
|
1602
|
+
for (const [primaryId, rawEntry] of Object.entries(contacts)) {
|
|
1603
|
+
if (!isRecord(rawEntry))
|
|
1604
|
+
continue;
|
|
1605
|
+
const status = rawEntry.status;
|
|
1606
|
+
if (status !== undefined && status !== 'active')
|
|
1607
|
+
continue;
|
|
1608
|
+
if (promoted.includes(primaryId))
|
|
1609
|
+
continue;
|
|
1610
|
+
promoted.push(primaryId);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
const existingAllowed = Array.isArray(value.allowedAids)
|
|
1615
|
+
? value.allowedAids.filter((item) => typeof item === 'string') : [];
|
|
1616
|
+
value.allowedAids = Array.from(new Set([...existingAllowed, ...promoted]));
|
|
1617
|
+
value.allowInternalContacts = internal;
|
|
1618
|
+
value.allowExternalContacts = external;
|
|
1619
|
+
value.allowStrangerContacts = stranger;
|
|
1620
|
+
if (typeof value.$schema_version === 'number' && value.$schema_version < ACCESS_POLICY_TARGET_VERSION) {
|
|
1621
|
+
value.$schema_version = ACCESS_POLICY_TARGET_VERSION;
|
|
1622
|
+
}
|
|
1623
|
+
return { value, removed, migrated, promoted };
|
|
1624
|
+
}
|
|
1625
|
+
function planAccessPolicyMigration(home) {
|
|
1626
|
+
const changes = [];
|
|
1627
|
+
const details = [];
|
|
1628
|
+
const summary = {
|
|
1629
|
+
configsScanned: 0, filesChanged: 0, modesConverted: 0, promotedContacts: 0, fieldsRemoved: 0,
|
|
1630
|
+
};
|
|
1631
|
+
const agentsRoot = path.join(home, 'agents');
|
|
1632
|
+
if (!fs.existsSync(agentsRoot))
|
|
1633
|
+
return { home, changes, summary, details };
|
|
1634
|
+
for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
1635
|
+
if (!entry.isDirectory() || !validAid(entry.name))
|
|
1636
|
+
continue;
|
|
1637
|
+
const agentRoot = path.join(agentsRoot, entry.name);
|
|
1638
|
+
const file = path.join(agentRoot, 'config.json');
|
|
1639
|
+
if (!fs.existsSync(file))
|
|
1640
|
+
continue;
|
|
1641
|
+
summary.configsScanned += 1;
|
|
1642
|
+
let parsed;
|
|
1643
|
+
try {
|
|
1644
|
+
parsed = readJson(file);
|
|
1645
|
+
}
|
|
1646
|
+
catch {
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
if (!isRecord(parsed.value))
|
|
1650
|
+
continue;
|
|
1651
|
+
const nowVersion = parsed.value.$schema_version;
|
|
1652
|
+
if (typeof nowVersion === 'number' && nowVersion > ACCESS_POLICY_TARGET_VERSION)
|
|
1653
|
+
continue;
|
|
1654
|
+
const access = isRecord(parsed.value.access) ? parsed.value.access : undefined;
|
|
1655
|
+
if (!access) {
|
|
1656
|
+
// 没写过 access:只补版本号,读取层会套用 v17 默认值。
|
|
1657
|
+
if (nowVersion === ACCESS_POLICY_TARGET_VERSION)
|
|
1658
|
+
continue;
|
|
1659
|
+
const next = { ...parsed.value, $schema_version: ACCESS_POLICY_TARGET_VERSION };
|
|
1660
|
+
const nextText = jsonText(next);
|
|
1661
|
+
if (nextText === parsed.text)
|
|
1662
|
+
continue;
|
|
1663
|
+
changes.push({ file, kind: 'agent-only-model', before: parsed.text, after: nextText });
|
|
1664
|
+
details.push({ file: path.relative(home, file), removed: [], migrated: [`$schema_version→${ACCESS_POLICY_TARGET_VERSION}`] });
|
|
1665
|
+
summary.filesChanged += 1;
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
// 改名迁移可能已经跑过,两个文件名都认。
|
|
1669
|
+
const peersFile = path.join(agentRoot, 'peers.json');
|
|
1670
|
+
const contactsFile = fs.existsSync(peersFile) ? peersFile : path.join(agentRoot, 'contact.json');
|
|
1671
|
+
let legacyContacts;
|
|
1672
|
+
if (fs.existsSync(contactsFile)) {
|
|
1673
|
+
try {
|
|
1674
|
+
legacyContacts = readJson(contactsFile).value;
|
|
1675
|
+
}
|
|
1676
|
+
catch {
|
|
1677
|
+
legacyContacts = undefined;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
const result = rewriteAccessPolicy(access, legacyContacts);
|
|
1681
|
+
const nextAgent = { ...parsed.value, access: result.value, $schema_version: ACCESS_POLICY_TARGET_VERSION };
|
|
1682
|
+
const nextText = jsonText(nextAgent);
|
|
1683
|
+
if (nextText === parsed.text)
|
|
1684
|
+
continue;
|
|
1685
|
+
const migrated = [...result.migrated];
|
|
1686
|
+
if (result.promoted.length)
|
|
1687
|
+
migrated.push(`allowedAids+=${result.promoted.join(',')}`);
|
|
1688
|
+
changes.push({ file, kind: 'agent-only-model', before: parsed.text, after: nextText });
|
|
1689
|
+
details.push({ file: path.relative(home, file), removed: result.removed, migrated });
|
|
1690
|
+
summary.filesChanged += 1;
|
|
1691
|
+
summary.fieldsRemoved += result.removed.length;
|
|
1692
|
+
if (result.migrated.length > 0)
|
|
1693
|
+
summary.modesConverted += 1;
|
|
1694
|
+
summary.promotedContacts += result.promoted.length;
|
|
1695
|
+
}
|
|
1696
|
+
return { home, changes, summary, details };
|
|
1697
|
+
}
|
|
1698
|
+
/** Plan or apply the Agent access-policy rewrite (v16 → v17). */
|
|
1699
|
+
export function runAccessPolicySchemaMigration(options = {}) {
|
|
1700
|
+
const id = 'access-policy-v17-v1';
|
|
1701
|
+
const home = path.resolve(options.home || resolvePaths().root);
|
|
1702
|
+
const release = acquireLock(home, id);
|
|
1703
|
+
try {
|
|
1704
|
+
assertDaemonStopped(home);
|
|
1705
|
+
recoverJournal(home, id);
|
|
1706
|
+
const plan = planAccessPolicyMigration(home);
|
|
1707
|
+
const backup = options.apply ? applyMigration(plan, id) : null;
|
|
1708
|
+
return {
|
|
1709
|
+
ok: true,
|
|
1710
|
+
mode: options.apply ? 'applied' : 'dry-run',
|
|
1711
|
+
home,
|
|
1712
|
+
changedFiles: plan.changes.length,
|
|
1713
|
+
backup,
|
|
1714
|
+
summary: plan.summary,
|
|
1715
|
+
details: plan.details,
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
finally {
|
|
1719
|
+
release();
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
/** Apply the access-policy rewrite before daemon registration. */
|
|
1723
|
+
export async function ensureAccessPolicyMigrationOnStartup() {
|
|
1724
|
+
const home = resolvePaths().root;
|
|
1725
|
+
try {
|
|
1726
|
+
const result = runAccessPolicySchemaMigration({ home, apply: true });
|
|
1727
|
+
if (result.changedFiles === 0)
|
|
1728
|
+
return null;
|
|
1729
|
+
return {
|
|
1730
|
+
mode: 'applied',
|
|
1731
|
+
changedFiles: result.changedFiles,
|
|
1732
|
+
backup: result.backup,
|
|
1733
|
+
summary: result.summary,
|
|
1734
|
+
details: result.details,
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
catch (error) {
|
|
1738
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1739
|
+
throw new ConfigError('ACCESS_POLICY_MIGRATION_FAILED', `Automatic access policy migration failed: ${detail}`, { cause: error });
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* `contact.json` 只承载本 Agent 的身份映射、displayName 与本地拉黑,和 Owner 名录副本
|
|
1744
|
+
* `contacts.json` 名字太近。v17 起改称 `peers.json`,这里把既有文件搬过去。
|
|
1745
|
+
*
|
|
1746
|
+
* 只做搬移,不改内容;目标已存在时保留目标、把旧文件留在原地由 Owner 复核,
|
|
1747
|
+
* 避免覆盖一份可能更完整的新文件。
|
|
1748
|
+
*/
|
|
1749
|
+
function planPeerFileRename(home) {
|
|
1750
|
+
const changes = [];
|
|
1751
|
+
const details = [];
|
|
1752
|
+
const legacyFiles = [];
|
|
1753
|
+
const summary = { configsScanned: 0, filesChanged: 0 };
|
|
1754
|
+
const agentsRoot = path.join(home, 'agents');
|
|
1755
|
+
if (!fs.existsSync(agentsRoot))
|
|
1756
|
+
return { home, changes, summary, details };
|
|
1757
|
+
for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
1758
|
+
if (!entry.isDirectory() || !validAid(entry.name))
|
|
1759
|
+
continue;
|
|
1760
|
+
const agentRoot = path.join(agentsRoot, entry.name);
|
|
1761
|
+
if (!fs.existsSync(path.join(agentRoot, 'config.json')))
|
|
1762
|
+
continue;
|
|
1763
|
+
summary.configsScanned += 1;
|
|
1764
|
+
const legacy = path.join(agentRoot, 'contact.json');
|
|
1765
|
+
if (!fs.existsSync(legacy))
|
|
1766
|
+
continue;
|
|
1767
|
+
const target = path.join(agentRoot, 'peers.json');
|
|
1768
|
+
if (fs.existsSync(target)) {
|
|
1769
|
+
details.push({ file: path.relative(home, legacy), removed: [], migrated: ['skipped: peers.json already exists'] });
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
const text = fs.readFileSync(legacy, 'utf8');
|
|
1773
|
+
changes.push({ file: target, kind: 'agent-only-model', before: null, after: text });
|
|
1774
|
+
legacyFiles.push(legacy);
|
|
1775
|
+
details.push({ file: path.relative(home, legacy), removed: ['contact.json'], migrated: ['→peers.json'] });
|
|
1776
|
+
summary.filesChanged += 1;
|
|
1777
|
+
}
|
|
1778
|
+
return { home, changes, summary, details, legacyFiles };
|
|
1779
|
+
}
|
|
1780
|
+
export function runPeerFileRenameMigration(options = {}) {
|
|
1781
|
+
const id = 'peer-file-v1';
|
|
1782
|
+
const home = path.resolve(options.home || resolvePaths().root);
|
|
1783
|
+
const release = acquireLock(home, id);
|
|
1784
|
+
try {
|
|
1785
|
+
assertDaemonStopped(home);
|
|
1786
|
+
recoverJournal(home, id);
|
|
1787
|
+
const plan = planPeerFileRename(home);
|
|
1788
|
+
const legacyFiles = plan.legacyFiles ?? [];
|
|
1789
|
+
const backup = options.apply ? applyMigration(plan, id) : null;
|
|
1790
|
+
let changedFiles = plan.changes.length;
|
|
1791
|
+
if (options.apply) {
|
|
1792
|
+
for (const legacy of legacyFiles) {
|
|
1793
|
+
try {
|
|
1794
|
+
fs.rmSync(legacy, { force: true });
|
|
1795
|
+
changedFiles += 1;
|
|
1796
|
+
}
|
|
1797
|
+
catch {
|
|
1798
|
+
// 删除失败不影响新文件可用,旧文件留待 Owner 手工清理。
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return {
|
|
1803
|
+
ok: true,
|
|
1804
|
+
mode: options.apply ? 'applied' : 'dry-run',
|
|
1805
|
+
home,
|
|
1806
|
+
changedFiles,
|
|
1807
|
+
backup,
|
|
1808
|
+
summary: plan.summary,
|
|
1809
|
+
details: plan.details,
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
finally {
|
|
1813
|
+
release();
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
export async function ensurePeerFileRenameOnStartup() {
|
|
1817
|
+
const home = resolvePaths().root;
|
|
1818
|
+
try {
|
|
1819
|
+
const result = runPeerFileRenameMigration({ home, apply: true });
|
|
1820
|
+
if (result.changedFiles === 0)
|
|
1821
|
+
return null;
|
|
1822
|
+
return {
|
|
1823
|
+
mode: 'applied',
|
|
1824
|
+
changedFiles: result.changedFiles,
|
|
1825
|
+
backup: result.backup,
|
|
1826
|
+
summary: result.summary,
|
|
1827
|
+
details: result.details,
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
catch (error) {
|
|
1831
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1832
|
+
throw new ConfigError('PEER_FILE_RENAME_MIGRATION_FAILED', `Automatic peer file rename migration failed: ${detail}`, { cause: error });
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
@@ -3,12 +3,13 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { agentMdPath, resolvePaths, } from '../paths.js';
|
|
5
5
|
import { loadAgent, saveAgent, } from '../config-store.js';
|
|
6
|
-
import { ConfigTarget, assertAgentAidAvailable, assertAgentModelConfigured, ensureFile as cfgEnsure, initConfigManager, notifyConfigWrite, read as cfgRead, write as cfgWrite, } from '../config/config-manager.js';
|
|
6
|
+
import { ConfigTarget, assertAgentAidAvailable, assertAgentModelConfigured, ensureFile as cfgEnsure, initConfigManager, notifyConfigWrite, read as cfgRead, resolveEffective, write as cfgWrite, } from '../config/config-manager.js';
|
|
7
7
|
import { executeResolvedConfigCommand, } from '../config/config-operation-service.js';
|
|
8
8
|
import { resolveConfigCommand } from '../config/resolved-config-op.js';
|
|
9
9
|
import { AgentReloadBusyError } from './agent-reload-coordinator.js';
|
|
10
10
|
import { logger } from '../utils/logger.js';
|
|
11
11
|
import { initializationCreateProgress, initializationOwnership, removeAgentFiles } from './agent-create-status.js';
|
|
12
|
+
import { resolveRuntimeBaseagentModelSelection } from '../agents/baseagent.js';
|
|
12
13
|
function toPosix(value) {
|
|
13
14
|
if (!value)
|
|
14
15
|
return null;
|
|
@@ -281,8 +282,13 @@ export class AgentApplicationService {
|
|
|
281
282
|
await this.initialization?.cancel(aid);
|
|
282
283
|
const previousEnabled = config.enabled;
|
|
283
284
|
try {
|
|
284
|
-
if (enabled)
|
|
285
|
+
if (enabled) {
|
|
286
|
+
const effective = resolveEffective({ self: aid }, { cache: false });
|
|
287
|
+
const backend = effective.active_baseagent;
|
|
288
|
+
if (backend)
|
|
289
|
+
await resolveRuntimeBaseagentModelSelection(backend, effective.baseagents?.[backend]);
|
|
285
290
|
assertAgentModelConfigured(aid);
|
|
291
|
+
}
|
|
286
292
|
config.enabled = enabled;
|
|
287
293
|
saveAgent(config);
|
|
288
294
|
}
|
|
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { creationOwnershipBinding } from './ownership/owner-resolver.js';
|
|
6
|
-
import {
|
|
6
|
+
import { removeAgentCreationClaim, updateAgentCreationClaim } from './agent-creation-claim.js';
|
|
7
7
|
import { resolvePaths } from '../paths.js';
|
|
8
8
|
import { removeRegisteredFile } from './file-integrity/store.js';
|
|
9
9
|
const FILE = 'create-status.json';
|
|
@@ -120,10 +120,9 @@ export async function removeAgentFiles(aid, purge) {
|
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
122
|
removeCreateStatus(agentDir);
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
await removeAgentCreationClaim(aid, claim.creationId);
|
|
123
|
+
// Initialization receipts are retained for diagnostics, but the shared
|
|
124
|
+
// admission claim is transient and must never reserve a deleted AID.
|
|
125
|
+
await removeAgentCreationClaim(aid);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
const PHASES = {
|
|
@@ -148,12 +148,13 @@ export function registerAgentOperationExecutor({ ipcServer, sessionManager, agen
|
|
|
148
148
|
baseagent: agent.baseagent ?? null,
|
|
149
149
|
model: agent.model ?? null,
|
|
150
150
|
lastActivity: agent.lastActivity ?? null,
|
|
151
|
-
...(agent.mode === 'one_shot' ? {
|
|
152
|
-
mode: agent.mode,
|
|
151
|
+
...(agent.mode === 'one_shot' || agent.initialization?.code === 'INITIALIZE_STATE_INVALID' ? {
|
|
152
|
+
...(agent.mode === 'one_shot' ? { mode: agent.mode } : {}),
|
|
153
153
|
lifecycle: agent.lifecycle,
|
|
154
154
|
initialization: agent.initialization,
|
|
155
|
-
createProgress: agent.createProgress,
|
|
156
|
-
ownership: agent.ownership,
|
|
155
|
+
...(agent.createProgress ? { createProgress: agent.createProgress } : {}),
|
|
156
|
+
...(agent.ownership ? { ownership: agent.ownership } : {}),
|
|
157
|
+
...(agent.usable !== undefined ? { usable: agent.usable } : {}),
|
|
157
158
|
} : {}),
|
|
158
159
|
};
|
|
159
160
|
}) : [];
|
|
@@ -248,13 +248,11 @@ export function createAgentInitializationRuntime({ agentRegistry, agentMap, chan
|
|
|
248
248
|
&& instance.channel.getAidState?.()?.status === 'connected');
|
|
249
249
|
return new AgentInitializationService({
|
|
250
250
|
ownershipBeforePublication: true,
|
|
251
|
-
register: async (aid,
|
|
251
|
+
register: async (aid, ownerAid, mode) => {
|
|
252
252
|
assertAgentAidAvailable(aid);
|
|
253
|
-
const {
|
|
253
|
+
const { aidCreateIdentityOnly } = await import('../aun/aid/identity.js');
|
|
254
254
|
const { assertAgentIdentityReusable } = await import('../aun/aid/agentmd.js');
|
|
255
|
-
const created =
|
|
256
|
-
? await aidCreateIdentityOnly(aid)
|
|
257
|
-
: await aidCreate(aid, { type: 'agent' });
|
|
255
|
+
const created = await aidCreateIdentityOnly(aid, { type: 'agent' });
|
|
258
256
|
try {
|
|
259
257
|
if (created.alreadyExisted)
|
|
260
258
|
await assertAgentIdentityReusable(aid, { store: created.store });
|
|
@@ -269,14 +267,17 @@ export function createAgentInitializationRuntime({ agentRegistry, agentMap, chan
|
|
|
269
267
|
}
|
|
270
268
|
},
|
|
271
269
|
bindOwner: async (aid, ownerAid) => {
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
// Initialization happens before the new Agent is hot-loaded. Use a
|
|
271
|
+
// short-lived client for both modes; the long-lived resolver requires a
|
|
272
|
+
// connected subject and therefore cannot bind a freshly registered AID.
|
|
273
|
+
// Keep the exact SDK task returned by this invocation so the service can
|
|
274
|
+
// persist its operation ID beside the creation receipt.
|
|
275
|
+
return bindInitializationOwner(aid, ownerAid);
|
|
278
276
|
},
|
|
279
277
|
ownerBindActive: (aid, ownerAid) => {
|
|
278
|
+
const record = readInitialization(aid);
|
|
279
|
+
if (record?.plan.ownerAid === ownerAid && record.ownerBindSubmitted === true)
|
|
280
|
+
return true;
|
|
280
281
|
const task = ownerResolver.snapshot(aid).task;
|
|
281
282
|
return task?.operation === 'bind' && task.owner_aid === ownerAid
|
|
282
283
|
&& (task.status === 'pending' || task.status === 'completed');
|
|
@@ -510,24 +511,29 @@ export function createAgentRuntimeOperations({ agentRegistry, agentLoader, sessi
|
|
|
510
511
|
};
|
|
511
512
|
return { hotLoad, resync };
|
|
512
513
|
}
|
|
513
|
-
// fastaun 0.5.
|
|
514
|
+
// fastaun 0.5.29 start()/capture() only read and verify documents. All writes
|
|
514
515
|
// and notifications occur in execute(), which converts transport failures to
|
|
515
516
|
// an error task with its original operation_id. Only this audited artifact
|
|
516
517
|
// therefore proves that a raw ECONNRESET rejection preceded submission.
|
|
517
518
|
// A different SDK version or workflow must fall back to unknown until its
|
|
518
519
|
// boundary is reviewed, even when another version reuses this workflow file.
|
|
519
|
-
const
|
|
520
|
-
|
|
520
|
+
const AUDITED_WORKFLOW_SHA256 = {
|
|
521
|
+
'0.5.28': 'cd736d1fcce0812013ba7d7c2148f86c8f3d3d2d39e451e52a0f9cc2a4d4fb51',
|
|
522
|
+
'0.5.29': '24ac11a456607019dbbf5e7d247f4632520d7bd70bf0e49d4efa36d2898e7648',
|
|
523
|
+
};
|
|
521
524
|
export function initializationBindPreflightFailure(error) {
|
|
522
525
|
if (!(error instanceof Error) || error.code !== 'ECONNRESET')
|
|
523
526
|
return false;
|
|
524
527
|
try {
|
|
525
528
|
const entry = import.meta.resolve('@agentunion/fastaun');
|
|
526
529
|
const manifest = JSON.parse(readFileSync(new URL('../package.json', entry), 'utf8'));
|
|
527
|
-
|
|
530
|
+
const expectedHash = typeof manifest.version === 'string'
|
|
531
|
+
? AUDITED_WORKFLOW_SHA256[manifest.version]
|
|
532
|
+
: undefined;
|
|
533
|
+
if (!expectedHash)
|
|
528
534
|
return false;
|
|
529
535
|
const workflow = new URL('ownership-workflow.js', entry);
|
|
530
|
-
return createHash('sha256').update(readFileSync(workflow)).digest('hex') ===
|
|
536
|
+
return createHash('sha256').update(readFileSync(workflow)).digest('hex') === expectedHash;
|
|
531
537
|
}
|
|
532
538
|
catch {
|
|
533
539
|
return false;
|
|
@@ -590,11 +596,18 @@ export async function bindInitializationOwner(aid, ownerAid) {
|
|
|
590
596
|
}
|
|
591
597
|
});
|
|
592
598
|
}
|
|
599
|
+
/** Ordinary creation is retryable; reuse a matching relation without rebinding. */
|
|
600
|
+
export async function bindAgentCreationOwner(aid, ownerAid) {
|
|
601
|
+
return withInitializationClient(aid, async (client) => {
|
|
602
|
+
const { aidEnsureOwnerBinding } = await import('../aun/aid/identity.js');
|
|
603
|
+
return aidEnsureOwnerBinding(client, aid, ownerAid);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
593
606
|
/** Each bootstrap observation has a new SDK client and no cached consensus. */
|
|
594
607
|
export async function checkBootstrapInitializationOwner(aid, ownerAid) {
|
|
595
608
|
try {
|
|
596
609
|
return await withInitializationClient(aid, async (client) => {
|
|
597
|
-
const view = await client.checkOwnershipConsensus(aid);
|
|
610
|
+
const view = await client.checkOwnershipConsensus(aid, true);
|
|
598
611
|
const checkedAt = Date.now();
|
|
599
612
|
const details = {
|
|
600
613
|
...(['consensus', 'released', 'unbound', 'single_sided', 'invalid', 'unavailable', 'not_applicable'].includes(view.status)
|
|
@@ -388,30 +388,6 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
// Agent self-service contact add deliberately reuses the same low-trust
|
|
392
|
-
// relation boundary as ec.msg.send. Older per-Agent role files may still
|
|
393
|
-
// contain the historical contact.* deny without an explicit contact.add
|
|
394
|
-
// entry; preserve their safe current-peer/private-only send capability while
|
|
395
|
-
// allowing this new request workflow. An explicit contact.add rule wins.
|
|
396
|
-
if (operation === 'contact.add'
|
|
397
|
-
&& !Object.prototype.hasOwnProperty.call(roleDef.commandPermissions || {}, 'contact.add')) {
|
|
398
|
-
const sendPermission = roleDef.commandPermissions?.['ec.msg.send'];
|
|
399
|
-
if (sendPermission?.allow) {
|
|
400
|
-
matchResult = {
|
|
401
|
-
permission: {
|
|
402
|
-
...sendPermission,
|
|
403
|
-
scopes: ['relation'],
|
|
404
|
-
constraints: {
|
|
405
|
-
...(sendPermission.constraints ?? {}),
|
|
406
|
-
ownPeerOnly: true,
|
|
407
|
-
privateOnly: true,
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
matchedRule: 'ec.msg.send',
|
|
411
|
-
rank: 1000,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
391
|
if (!matchResult) {
|
|
416
392
|
return denyDecision(ctx, 'NO_PERMISSION', `Role ${role} has no permission for ${operation}`, operation, intent.scope, opMeta.dangerous);
|
|
417
393
|
}
|
|
@@ -649,35 +649,19 @@ const OPERATIONS = [
|
|
|
649
649
|
sources: ['menu', 'ecweb', 'control'],
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
|
-
id: '
|
|
652
|
+
id: 'peer.read',
|
|
653
653
|
category: 'read',
|
|
654
654
|
dangerous: false,
|
|
655
655
|
defaultScopes: ['agent'],
|
|
656
|
-
description: 'Read Agent
|
|
656
|
+
description: 'Read the Agent peer registry and locally blocked peers',
|
|
657
657
|
sources: ['agent-tool'],
|
|
658
658
|
},
|
|
659
659
|
{
|
|
660
|
-
id: '
|
|
661
|
-
category: 'write-agent',
|
|
662
|
-
dangerous: false,
|
|
663
|
-
defaultScopes: ['relation'],
|
|
664
|
-
description: 'Request adding the current private relation as an Agent contact',
|
|
665
|
-
sources: ['agent-tool'],
|
|
666
|
-
},
|
|
667
|
-
{
|
|
668
|
-
id: 'contact.block',
|
|
669
|
-
category: 'write-agent',
|
|
670
|
-
dangerous: false,
|
|
671
|
-
defaultScopes: ['agent'],
|
|
672
|
-
description: 'Block or unblock a canonical contact across bound private channels',
|
|
673
|
-
sources: ['agent-tool'],
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
id: 'contact.review',
|
|
660
|
+
id: 'peer.block',
|
|
677
661
|
category: 'write-agent',
|
|
678
662
|
dangerous: false,
|
|
679
663
|
defaultScopes: ['agent'],
|
|
680
|
-
description: '
|
|
664
|
+
description: 'Block or unblock a canonical peer on this Agent',
|
|
681
665
|
sources: ['agent-tool'],
|
|
682
666
|
},
|
|
683
667
|
{
|