evolcore 0.0.41 → 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 +36 -0
- 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
package/dist/cli/version.js
CHANGED
|
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'url';
|
|
|
7
7
|
import { MAIN_PACKAGE_NAME, PRODUCT_DISPLAY_NAME, WEB_PACKAGE_NAME } from '../product.js';
|
|
8
8
|
import { getArgValue, wantsHelp } from './help.js';
|
|
9
9
|
import { resolveGlobalPkg } from '../utils/npm-ops.js';
|
|
10
|
+
import { readVersionInfo } from '../utils/machine-info.js';
|
|
10
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
12
|
const PACKAGE_ROOT = path.resolve(__dirname, '../..');
|
|
12
13
|
const RESET = '\x1b[0m';
|
|
@@ -51,33 +52,32 @@ export function handleVersion(args) {
|
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
const isJson = getArgValue(args, '--format') === 'json' || args.includes('--json');
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const versions = readVersionInfo();
|
|
56
|
+
// 获取构建时间戳
|
|
56
57
|
const mainEntry = path.join(PACKAGE_ROOT, 'dist', 'cli', 'index.js');
|
|
57
58
|
const mainTs = getFileModTime(mainEntry);
|
|
58
|
-
// EC Web may be in the repository (dev mode) or nested under the globally
|
|
59
|
-
// installed EvolCore package. Use the shared resolver so both layouts report
|
|
60
|
-
// the actual installed package instead of `?`.
|
|
61
59
|
const ecwebInstalled = resolveGlobalPkg(WEB_PACKAGE_NAME);
|
|
62
60
|
const ecwebDir = ecwebInstalled ? path.dirname(ecwebInstalled.path) : path.join(PACKAGE_ROOT, 'ecweb');
|
|
63
|
-
const ecwebPkg = readPkgJson(ecwebDir);
|
|
64
61
|
const ecwebEntry = path.join(ecwebDir, 'dist', 'index.js');
|
|
65
62
|
const ecwebTs = getFileModTime(ecwebEntry);
|
|
66
63
|
const ecwebStaticTs = getFileModTime(path.join(ecwebDir, 'dist', 'static', 'index.html'));
|
|
67
|
-
// 关键依赖
|
|
68
|
-
const deps = [
|
|
69
|
-
'@agentunion/fastaun',
|
|
70
|
-
'ws',
|
|
71
|
-
];
|
|
72
64
|
const components = [
|
|
73
|
-
{ name: MAIN_PACKAGE_NAME, version:
|
|
74
|
-
{ name: WEB_PACKAGE_NAME, version:
|
|
65
|
+
{ name: MAIN_PACKAGE_NAME, version: versions.evolcore || '?', built: mainTs || undefined, note: 'main package' },
|
|
66
|
+
{ name: WEB_PACKAGE_NAME, version: versions.ecweb || '?', built: ecwebTs || undefined, note: `static: ${ecwebStaticTs || '?'}` },
|
|
75
67
|
];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
// 添加 fastaun(从归口模块已获取)
|
|
69
|
+
if (versions.fastaun) {
|
|
70
|
+
const fastaunInfo = findInstalledVersion('@agentunion/fastaun');
|
|
71
|
+
components.push({
|
|
72
|
+
name: '@agentunion/fastaun',
|
|
73
|
+
version: versions.fastaun,
|
|
74
|
+
built: fastaunInfo?.buildTs || undefined
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// 其他依赖(ws)
|
|
78
|
+
const wsInfo = findInstalledVersion('ws');
|
|
79
|
+
if (wsInfo) {
|
|
80
|
+
components.push({ name: wsInfo.name, version: wsInfo.version, built: wsInfo.buildTs || undefined });
|
|
81
81
|
}
|
|
82
82
|
// Node.js 版本
|
|
83
83
|
components.push({ name: 'node', version: process.version, note: process.platform + '/' + process.arch });
|
|
@@ -10,21 +10,42 @@ export class AccessPolicyError extends Error {
|
|
|
10
10
|
this.name = 'AccessPolicyError';
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* 缺失 `access` 时按"只收内部联系人"执行:同 Owner 名录成员可进,外部与陌生人不进。
|
|
15
|
+
*/
|
|
13
16
|
export const DEFAULT_ACCESS_POLICY = Object.freeze({
|
|
14
|
-
|
|
15
|
-
allowOwnerDirectoryContacts: true,
|
|
16
|
-
allowOwnerAgentDirectory: true,
|
|
17
|
+
allowInternalContacts: true,
|
|
17
18
|
allowExternalContacts: false,
|
|
19
|
+
allowStrangerContacts: false,
|
|
20
|
+
allowedAids: Object.freeze([]),
|
|
21
|
+
deniedAids: Object.freeze([]),
|
|
18
22
|
requestLimit: Object.freeze({ maxTimes: 600, coolDown: 60 * 60 }),
|
|
19
23
|
});
|
|
20
24
|
export function listAgentOwners(selfAid) {
|
|
21
25
|
const agent = read(ConfigTarget.Agent, { self: selfAid }, { cache: true });
|
|
22
26
|
return validAgentOwnerIds(agent);
|
|
23
27
|
}
|
|
24
|
-
/** Missing AgentConfig.access
|
|
28
|
+
/** Missing AgentConfig.access falls back to DEFAULT_ACCESS_POLICY. */
|
|
25
29
|
export function readAccessPolicy(selfAid) {
|
|
26
30
|
return readAccessPolicySnapshot(selfAid).policy;
|
|
27
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* 只读配置里**显式写过**的 `allowExternalContacts`;没写返回 undefined。
|
|
34
|
+
*
|
|
35
|
+
* 读 `readAccessPolicy` 拿不到这个区别——它已经把缺省值补成 `false` 了。而外部联系
|
|
36
|
+
* 默认值对个人助理是 `true`(Personal Assistant 需要联系 Owner 之外的人),
|
|
37
|
+
* 所以调用方必须能区分"没写"和"写了 false"。
|
|
38
|
+
*/
|
|
39
|
+
export function readExplicitAllowExternalContacts(selfAid) {
|
|
40
|
+
try {
|
|
41
|
+
const agent = read(ConfigTarget.Agent, { self: selfAid }, { cache: true });
|
|
42
|
+
const value = agent?.access?.allowExternalContacts;
|
|
43
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
28
49
|
export function readAccessPolicySnapshot(selfAid) {
|
|
29
50
|
const agent = read(ConfigTarget.Agent, { self: selfAid }, { cache: true });
|
|
30
51
|
return accessPolicySnapshotFromAgent(selfAid, agent);
|
|
@@ -83,21 +104,17 @@ function accessPolicySnapshotFromAgent(selfAid, agent) {
|
|
|
83
104
|
function assertAccessPolicyWrite(input, agent, policy) {
|
|
84
105
|
const owners = validAgentOwnerIds({ aid: input.selfAid });
|
|
85
106
|
const normalizedActorAid = String(input.actorAid || '').trim();
|
|
86
|
-
|
|
87
|
-
if (!isOwner) {
|
|
107
|
+
if (!owners.includes(normalizedActorAid)) {
|
|
88
108
|
throw new AccessPolicyError('access_policy_owner_required', 'Only an Agent Owner can change access policy');
|
|
89
109
|
}
|
|
90
|
-
if (policy.policyMode !== 'open' && owners.length === 0) {
|
|
91
|
-
throw new AccessPolicyError('restricted_mode_without_owner', `Agent ${input.selfAid} cannot use ${policy.policyMode} without an Owner`);
|
|
92
|
-
}
|
|
93
110
|
}
|
|
94
111
|
function clonePolicy(policy) {
|
|
95
112
|
return {
|
|
96
|
-
|
|
97
|
-
allowOwnerDirectoryContacts: policy.allowOwnerDirectoryContacts ?? true,
|
|
98
|
-
allowOwnerAgentDirectory: policy.allowOwnerAgentDirectory ?? true,
|
|
113
|
+
allowInternalContacts: policy.allowInternalContacts ?? true,
|
|
99
114
|
allowExternalContacts: policy.allowExternalContacts ?? false,
|
|
115
|
+
allowStrangerContacts: policy.allowStrangerContacts ?? false,
|
|
100
116
|
allowedAids: [...(policy.allowedAids ?? [])],
|
|
117
|
+
deniedAids: [...(policy.deniedAids ?? [])],
|
|
101
118
|
requestLimit: { ...policy.requestLimit },
|
|
102
119
|
};
|
|
103
120
|
}
|
package/dist/config/boot-log.js
CHANGED
|
@@ -15,36 +15,66 @@ import { logger } from '../utils/logger.js';
|
|
|
15
15
|
import { autoMigrateIfNeeded } from '../config-store.js';
|
|
16
16
|
import { ConfigTarget, initConfigManager, notifyConfigWrite } from './config-manager.js';
|
|
17
17
|
import { ensureRoleConfigV4OnStartup, ensureRoleConfigV5OnStartup } from './role-migration-startup.js';
|
|
18
|
-
import { ensureAgentModelProviderMigrationOnStartup, ensureAgentOnlyModelMigrationOnStartup, ensureAuxiliaryModelMigrationOnStartup, ensureProviderServiceTypeMigrationOnStartup, ensureRelationConfigVersionMigrationOnStartup } from './schema-migration.js';
|
|
19
|
-
import { ensureContactBookV2OnStartup } from './
|
|
20
|
-
import {
|
|
18
|
+
import { ensureAccessPolicyMigrationOnStartup, ensureAgentModelProviderMigrationOnStartup, ensureAgentOnlyModelMigrationOnStartup, ensureAuxiliaryModelMigrationOnStartup, ensurePeerFileRenameOnStartup, ensureProviderServiceTypeMigrationOnStartup, ensureRelationConfigVersionMigrationOnStartup, invalidateMigrationReadCache, withMigrationReadCache, } from './schema-migration.js';
|
|
19
|
+
import { ensureContactBookV2OnStartup } from './peer-book-v2-startup.js';
|
|
20
|
+
import { synchronizeAllManagementPeersSync } from './peer-book-store.js';
|
|
21
21
|
import { readInstalledEvolcoreVersion, readFastaunVersion } from '../utils/evolcore-version.js';
|
|
22
22
|
import { readCurrent, readWVersion, writeWVersion, materializeVersion, listAllVersions, diffVersions, snapshot, isConfigSnapshotsEnabled, ensureStartupConfigSnapshot, incrementSuccessCount, retentionCleanup, writeSnapshotConfigFile, removeSnapshotConfigFile, } from './snapshot.js';
|
|
23
23
|
const MAX_LINES = 300;
|
|
24
24
|
const KEEP_MIN = 150;
|
|
25
25
|
const FALLBACK_MAX_TRIES = 20;
|
|
26
26
|
const FALLBACK_MAX_MS = 120_000;
|
|
27
|
-
export async function prepareStartupConfig(recoverRoleMutations) {
|
|
27
|
+
export async function prepareStartupConfig(recoverRoleMutations, onStep) {
|
|
28
|
+
// 这一整段曾经只占一个埋点(1.2s),看不出是哪一步重。分步上报后
|
|
29
|
+
// 才能判断该优化扫描次数还是该加水印快路径。
|
|
30
|
+
const step = (name) => onStep?.(name);
|
|
28
31
|
recoverRoleMutations();
|
|
32
|
+
step('recoverRoleMutations');
|
|
29
33
|
autoMigrateIfNeeded();
|
|
30
|
-
|
|
34
|
+
// 前三个迁移扫的是同一批配置(relations/ 下有上千个文件),共享一次读取。
|
|
35
|
+
// 之后 roleV4/V5、contactBook 走的是不同的读取路径,各自的开销不受影响。
|
|
36
|
+
// 缓存作用域只覆盖规划阶段:每个迁移都是先 plan 再独立写盘,写盘之后的内容
|
|
37
|
+
// 由后续迁移自己重新读。
|
|
38
|
+
step('auxiliaryModel');
|
|
39
|
+
// 任一迁移真的落盘后立刻丢弃缓存:这三个迁移改的是同一批 relation 配置,
|
|
40
|
+
// 后一个迁移若沿用写盘前的旧文本做整文件覆盖,会把前一个的改动回滚掉。
|
|
41
|
+
const { auxiliaryModelMigration, agentOnlyModelMigration, relationVersionMigration } = await withMigrationReadCache(async () => {
|
|
42
|
+
const auxiliary = await ensureAuxiliaryModelMigrationOnStartup();
|
|
43
|
+
if (auxiliary)
|
|
44
|
+
invalidateMigrationReadCache();
|
|
45
|
+
const agentOnly = await ensureAgentOnlyModelMigrationOnStartup();
|
|
46
|
+
if (agentOnly)
|
|
47
|
+
invalidateMigrationReadCache();
|
|
48
|
+
const relationVersion = await ensureRelationConfigVersionMigrationOnStartup();
|
|
49
|
+
if (relationVersion)
|
|
50
|
+
invalidateMigrationReadCache();
|
|
51
|
+
return {
|
|
52
|
+
auxiliaryModelMigration: auxiliary,
|
|
53
|
+
agentOnlyModelMigration: agentOnly,
|
|
54
|
+
relationVersionMigration: relationVersion,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
31
57
|
if (auxiliaryModelMigration) {
|
|
32
58
|
const message = `✓ Session Renew auxiliary model migration applied automatically: ${auxiliaryModelMigration.changedFiles} file(s)`
|
|
33
59
|
+ (auxiliaryModelMigration.backup ? `; backup: ${auxiliaryModelMigration.backup}` : '');
|
|
34
60
|
logger.info(message);
|
|
35
61
|
console.error(message);
|
|
36
62
|
}
|
|
37
|
-
const agentOnlyModelMigration = await ensureAgentOnlyModelMigrationOnStartup();
|
|
38
63
|
if (agentOnlyModelMigration) {
|
|
39
|
-
const message = `✓ Agent model migration applied automatically: normalized ${agentOnlyModelMigration.changedFiles} file(s)
|
|
64
|
+
const message = `✓ Agent model migration applied automatically: normalized ${agentOnlyModelMigration.changedFiles} file(s)`
|
|
40
65
|
+ (agentOnlyModelMigration.backup ? `; backup: ${agentOnlyModelMigration.backup}` : '');
|
|
41
66
|
logger.info(message);
|
|
42
67
|
console.error(message);
|
|
43
68
|
for (const detail of agentOnlyModelMigration.details) {
|
|
44
69
|
const actions = [...(detail.migrated ?? []), ...detail.removed];
|
|
45
|
-
|
|
70
|
+
// 不再有"只在 defaults 里注册后端名"这种无字段变化的条目;
|
|
71
|
+
// 没有动作的 detail 直接跳过,别打出会误导人的文案。
|
|
72
|
+
if (actions.length === 0)
|
|
73
|
+
continue;
|
|
74
|
+
logger.info(`[config] ${detail.file}: ${actions.join(', ')}`);
|
|
46
75
|
}
|
|
47
76
|
}
|
|
77
|
+
step('modelProvider');
|
|
48
78
|
const modelProviderMigration = await ensureAgentModelProviderMigrationOnStartup();
|
|
49
79
|
if (modelProviderMigration) {
|
|
50
80
|
const message = `✓ Agent model provider migration applied automatically: gateway information moved into providers.json, ${modelProviderMigration.changedFiles} file(s) updated`
|
|
@@ -55,6 +85,28 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
55
85
|
logger.info(`[config] ${detail.file}${detail.removed.length ? `: removed ${detail.removed.join(', ')}` : ''}`);
|
|
56
86
|
}
|
|
57
87
|
}
|
|
88
|
+
step('accessPolicy');
|
|
89
|
+
const accessPolicyMigration = await ensureAccessPolicyMigrationOnStartup();
|
|
90
|
+
if (accessPolicyMigration) {
|
|
91
|
+
const message = `✓ Agent access policy migration applied automatically: ${accessPolicyMigration.changedFiles} file(s)`
|
|
92
|
+
+ (accessPolicyMigration.backup ? `; backup: ${accessPolicyMigration.backup}` : '');
|
|
93
|
+
logger.info(message);
|
|
94
|
+
console.error(message);
|
|
95
|
+
for (const detail of accessPolicyMigration.details) {
|
|
96
|
+
const actions = [...(detail.migrated ?? []), ...detail.removed];
|
|
97
|
+
logger.info(`[config] ${detail.file}: ${actions.length ? actions.join(', ') : 'schema restamped'}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// 必须在准入迁移之后:准入迁移要读 contact.json 才能提升旧联系人。
|
|
101
|
+
step('peerFileRename');
|
|
102
|
+
const peerFileRename = await ensurePeerFileRenameOnStartup();
|
|
103
|
+
if (peerFileRename) {
|
|
104
|
+
const message = `✓ Agent peer file rename applied automatically: ${peerFileRename.changedFiles} file(s)`
|
|
105
|
+
+ (peerFileRename.backup ? `; backup: ${peerFileRename.backup}` : '');
|
|
106
|
+
logger.info(message);
|
|
107
|
+
console.error(message);
|
|
108
|
+
}
|
|
109
|
+
step('providerServiceType');
|
|
58
110
|
const providerServiceTypeMigration = await ensureProviderServiceTypeMigrationOnStartup();
|
|
59
111
|
if (providerServiceTypeMigration) {
|
|
60
112
|
const message = `✓ Agent provider service type migration applied automatically: removed from ${providerServiceTypeMigration.changedFiles} config file(s)`
|
|
@@ -65,13 +117,13 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
65
117
|
logger.info(`[config] ${detail.file}: removed ${detail.removed.join(', ')}`);
|
|
66
118
|
}
|
|
67
119
|
}
|
|
68
|
-
const relationVersionMigration = await ensureRelationConfigVersionMigrationOnStartup();
|
|
69
120
|
if (relationVersionMigration) {
|
|
70
121
|
const message = `✓ Relation config version migration applied automatically: ${relationVersionMigration.changedFiles} file(s) restamped`
|
|
71
122
|
+ (relationVersionMigration.backup ? `; backup: ${relationVersionMigration.backup}` : '');
|
|
72
123
|
logger.info(message);
|
|
73
124
|
console.error(message);
|
|
74
125
|
}
|
|
126
|
+
step('roleV4');
|
|
75
127
|
const migration = await ensureRoleConfigV4OnStartup();
|
|
76
128
|
if (migration) {
|
|
77
129
|
const message = `✓ Role config v4 migration applied automatically: ${migration.changedFiles} file(s)`
|
|
@@ -79,6 +131,7 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
79
131
|
logger.info(message);
|
|
80
132
|
console.error(message);
|
|
81
133
|
}
|
|
134
|
+
step('roleV5');
|
|
82
135
|
const domainMigration = await ensureRoleConfigV5OnStartup();
|
|
83
136
|
if (domainMigration) {
|
|
84
137
|
const message = `✓ Standalone role config migration applied automatically: ${domainMigration.changedFiles} file(s)`
|
|
@@ -86,6 +139,7 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
86
139
|
logger.info(message);
|
|
87
140
|
console.error(message);
|
|
88
141
|
}
|
|
142
|
+
step('contactBook');
|
|
89
143
|
const contactMigration = await ensureContactBookV2OnStartup();
|
|
90
144
|
if (contactMigration) {
|
|
91
145
|
const message = `✓ Contact book v2 migration applied automatically: ${contactMigration.changedFiles} file(s)`
|
|
@@ -93,7 +147,8 @@ export async function prepareStartupConfig(recoverRoleMutations) {
|
|
|
93
147
|
logger.info(message);
|
|
94
148
|
console.error(message);
|
|
95
149
|
}
|
|
96
|
-
|
|
150
|
+
step('syncContacts');
|
|
151
|
+
const synchronizedContacts = synchronizeAllManagementPeersSync();
|
|
97
152
|
if (synchronizedContacts > 0) {
|
|
98
153
|
const message = `✓ Contact management identities synchronized: ${synchronizedContacts} agent(s)`;
|
|
99
154
|
logger.info(message);
|
|
@@ -31,10 +31,8 @@ export function getBuiltinRolesConfig() {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getManagementCommandPermissions(role) {
|
|
33
33
|
return {
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'contact.block': { allow: true, scopes: ['agent'], constraints: { requireAgentAdmin: true } },
|
|
37
|
-
'contact.review': { allow: true, scopes: ['agent'], constraints: { requireAgentAdmin: true } },
|
|
34
|
+
'peer.read': { allow: true, scopes: ['agent'] },
|
|
35
|
+
'peer.block': { allow: true, scopes: ['agent'], constraints: { requireAgentAdmin: true } },
|
|
38
36
|
'connect.write': { allow: true, scopes: ['agent'], constraints: { requireAgentAdmin: true } },
|
|
39
37
|
'connect.access.write': { allow: true, scopes: ['agent'], constraints: { requireAgentOwner: true } },
|
|
40
38
|
'role.assign': { allow: true, scopes: ['agent'] },
|
|
@@ -143,6 +143,9 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
143
143
|
return scalar('restartRecovery.enabled', 'boolean');
|
|
144
144
|
if (field === 'skills.watch')
|
|
145
145
|
return scalar('skills.watch', 'boolean');
|
|
146
|
+
// 仅 agent-config 声明该字段,relation/defaults 由 schema 路由拒绝。
|
|
147
|
+
if (field === 'baseagentSkills')
|
|
148
|
+
return scalar(field, 'boolean', 'owner-only');
|
|
146
149
|
if (top === 'chatmode') {
|
|
147
150
|
if (parts.length === 1)
|
|
148
151
|
return readonlyObject('chatmode');
|
|
@@ -14,26 +14,27 @@ import fs from 'fs';
|
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { ensureManagedLockParent, resolveManagedLockPath } from '../core/runtime-lock.js';
|
|
16
16
|
import crypto from 'crypto';
|
|
17
|
-
import { resolvePaths, agentConfig as agentConfigPath,
|
|
17
|
+
import { resolvePaths, agentConfig as agentConfigPath, agentPeerConfig, agentRelationConfig, agentRolesIndex, agentRoleConfig, } from '../paths.js';
|
|
18
18
|
import { atomicReadJson, atomicWriteJson } from '../utils/atomic-write.js';
|
|
19
19
|
import { fileCache } from '../core/daemon-file-cache.js';
|
|
20
20
|
import { registerFile } from '../core/file-integrity/store.js';
|
|
21
21
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
22
22
|
import { normalizeAidDomain } from '../aun/aid/domain.js';
|
|
23
23
|
import { ensureRelationSharedDirectory } from '../core/relation/shared-data.js';
|
|
24
|
-
import { parseContactAlias } from './
|
|
24
|
+
import { parseContactAlias } from './peer-alias.js';
|
|
25
25
|
import { loadSchema, listSchemaVersions, currentVersion, isSchemaName, } from './schema-registry.js';
|
|
26
26
|
import { mergeLayers } from './merge.js';
|
|
27
27
|
import { normalizeAgentLifecycle } from './lifecycle.js';
|
|
28
28
|
import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-field-policy.js';
|
|
29
29
|
import { clearRoleStoreCache, isRoleName } from './role-store.js';
|
|
30
30
|
import { writeRoleDefinition, writeRoleRegistry } from './role-service.js';
|
|
31
|
-
import {
|
|
31
|
+
import { mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
32
32
|
import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
33
33
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
34
34
|
import { assertProviderSelectionWrite, resolveProviderModelOverrides, validateProvidersFile } from './providers-config.js';
|
|
35
35
|
import { assertOwnerConfigRecord, configuredOwnerList, normalizeOwnerConfigTree, withOwnerListCompatibility } from './owner-config.js';
|
|
36
36
|
import { getOwners, getPrimaryOwner, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
37
|
+
import { resolveBaseagentModelSelection } from '../agents/baseagent.js';
|
|
37
38
|
// AUN gateway discovery belongs to fastaun. Keep the retired gatewayUrl
|
|
38
39
|
// compatibility handling beside the rest of the configuration read/write
|
|
39
40
|
// policy so all config callers share one implementation.
|
|
@@ -147,7 +148,7 @@ export var ConfigTarget;
|
|
|
147
148
|
ConfigTarget["Defaults"] = "defaults";
|
|
148
149
|
ConfigTarget["Agent"] = "agent";
|
|
149
150
|
ConfigTarget["Relation"] = "relation";
|
|
150
|
-
ConfigTarget["
|
|
151
|
+
ConfigTarget["Peer"] = "peer";
|
|
151
152
|
ConfigTarget["RoleRegistry"] = "role-registry";
|
|
152
153
|
ConfigTarget["Role"] = "role";
|
|
153
154
|
})(ConfigTarget || (ConfigTarget = {}));
|
|
@@ -165,7 +166,7 @@ const TARGET_SCHEMA = {
|
|
|
165
166
|
[ConfigTarget.Defaults]: 'defaults',
|
|
166
167
|
[ConfigTarget.Agent]: 'agent-config',
|
|
167
168
|
[ConfigTarget.Relation]: 'relation-config',
|
|
168
|
-
[ConfigTarget.
|
|
169
|
+
[ConfigTarget.Peer]: 'contact-book',
|
|
169
170
|
[ConfigTarget.RoleRegistry]: 'role-registry',
|
|
170
171
|
[ConfigTarget.Role]: 'role-config',
|
|
171
172
|
};
|
|
@@ -371,6 +372,8 @@ export function assertContactBookV2Ready() {
|
|
|
371
372
|
.filter(version => version >= minimumVersion)
|
|
372
373
|
.map(version => loadSchema(name, version)));
|
|
373
374
|
const agentSchemas = supportedSchemas('agent-config', contactMigrationAgentSchemaMax);
|
|
375
|
+
/** 当前 Agent 配置版本:介于迁移上限与它之间的版本都由别处校验,本门禁放行。 */
|
|
376
|
+
const agentConfigCurrentVersion = currentVersion('agent-config');
|
|
374
377
|
const contactSchemas = supportedSchemas('contact-book', 2);
|
|
375
378
|
const relationSchemas = supportedSchemas('relation-config', 5);
|
|
376
379
|
const inspect = (file, schemas, skipNewerAgentSchema = false) => {
|
|
@@ -387,9 +390,13 @@ export function assertContactBookV2Ready() {
|
|
|
387
390
|
const schemaVersion = value?.$schema_version;
|
|
388
391
|
if (skipNewerAgentSchema && typeof schemaVersion === 'number'
|
|
389
392
|
&& schemaVersion > contactMigrationAgentSchemaMax
|
|
390
|
-
&&
|
|
391
|
-
// Contact book v2 only migrates Agent schemas through v6; later Agent
|
|
393
|
+
&& schemaVersion <= agentConfigCurrentVersion) {
|
|
394
|
+
// Contact book v2 only migrates Agent schemas through v6; any later Agent
|
|
392
395
|
// config is left untouched by that migration and validated elsewhere.
|
|
396
|
+
//
|
|
397
|
+
// 判据只看版本号区间,不要求该版本的 schema 文件还在:已发布过的版本可能
|
|
398
|
+
// 被后续提交删除(v15 就是),文件缺失不代表配置非法。超过当前版本号的
|
|
399
|
+
// 仍然拒绝——那是本程序不认识的未来格式。
|
|
393
400
|
return;
|
|
394
401
|
}
|
|
395
402
|
if (!candidates.some(schema => schema.validate(value))) {
|
|
@@ -471,7 +478,7 @@ function inspectContactBookDomain(contactFile, agentFile, issues) {
|
|
|
471
478
|
.filter(Boolean));
|
|
472
479
|
const aliases = new Map();
|
|
473
480
|
for (const [primaryId, entry] of Object.entries(contact?.contacts ?? {})) {
|
|
474
|
-
const identity =
|
|
481
|
+
const identity = resolvePeerAidKind(String(agent?.aid ?? ''), primaryId);
|
|
475
482
|
if (identity.kind === 'group' || ['conflict', 'invalid', 'unavailable'].includes(identity.reason)) {
|
|
476
483
|
issues.push({ file: contactFile, detail: identity.kind === 'group'
|
|
477
484
|
? `group contact ${primaryId} is not supported`
|
|
@@ -610,9 +617,9 @@ function targetPath(target, sel) {
|
|
|
610
617
|
case ConfigTarget.Relation:
|
|
611
618
|
requirePeer(sel, target);
|
|
612
619
|
return agentRelationConfig(sel.self, sel.peerKey);
|
|
613
|
-
case ConfigTarget.
|
|
620
|
+
case ConfigTarget.Peer:
|
|
614
621
|
requireSelf(sel, target);
|
|
615
|
-
return
|
|
622
|
+
return agentPeerConfig(sel.self);
|
|
616
623
|
case ConfigTarget.RoleRegistry:
|
|
617
624
|
requireSelf(sel, target);
|
|
618
625
|
return agentRolesIndex(sel.self);
|
|
@@ -720,7 +727,7 @@ function groupFor(target, sel) {
|
|
|
720
727
|
if (target === ConfigTarget.Relation) {
|
|
721
728
|
return 'relation-prefs';
|
|
722
729
|
}
|
|
723
|
-
if (sel?.self && target === ConfigTarget.
|
|
730
|
+
if (sel?.self && target === ConfigTarget.Peer) {
|
|
724
731
|
return `contact:${sel.self}`;
|
|
725
732
|
}
|
|
726
733
|
if (sel?.self && (target === ConfigTarget.RoleRegistry || target === ConfigTarget.Role)) {
|
|
@@ -929,7 +936,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
929
936
|
const requestedVersion = value && typeof value === 'object'
|
|
930
937
|
? Number(value.$schema_version)
|
|
931
938
|
: NaN;
|
|
932
|
-
const schema = target === ConfigTarget.
|
|
939
|
+
const schema = target === ConfigTarget.Peer && requestedVersion === 2
|
|
933
940
|
? loadSchema('contact-book', 2)
|
|
934
941
|
: loadSchema(TARGET_SCHEMA[target]);
|
|
935
942
|
const retiredGatewayPaths = legacyAunGatewayConfigPaths(value);
|
|
@@ -964,7 +971,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
964
971
|
: target === ConfigTarget.Agent ? read(ConfigTarget.Defaults, undefined, { cache: false }) ?? {}
|
|
965
972
|
: resolveAgentConfig({ self: sel?.self }, { cache: false });
|
|
966
973
|
try {
|
|
967
|
-
assertProviderSelectionWrite(normalized, previous, inherited, (providerId, serviceType) => resolveProviderModelOverrides(providerId, serviceType, read(ConfigTarget.Providers) ?? { providers: {} }));
|
|
974
|
+
assertProviderSelectionWrite(normalized, previous, inherited, (providerId, serviceType, baseagent) => resolveProviderModelOverrides(providerId, serviceType, read(ConfigTarget.Providers) ?? { providers: {} }, baseagent));
|
|
968
975
|
}
|
|
969
976
|
catch (error) {
|
|
970
977
|
throw new ConfigError('VALIDATION_ERROR', error instanceof Error ? error.message : String(error));
|
|
@@ -982,9 +989,9 @@ export function write(target, value, sel, opts = {}) {
|
|
|
982
989
|
throw new ConfigError(issue.code, issue.message);
|
|
983
990
|
}
|
|
984
991
|
}
|
|
985
|
-
if (target === ConfigTarget.
|
|
992
|
+
if (target === ConfigTarget.Peer && sel?.self) {
|
|
986
993
|
const contact = { ...normalized, $schema_version: currentVersion('contact-book') };
|
|
987
|
-
|
|
994
|
+
mutatePeerBookTransactionSync({
|
|
988
995
|
selfAid: sel.self,
|
|
989
996
|
actor: 'contact-config-write',
|
|
990
997
|
mutation: { type: 'replace', contact },
|
|
@@ -998,7 +1005,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
998
1005
|
}
|
|
999
1006
|
const before = readTextOrNull(file);
|
|
1000
1007
|
const after = `${JSON.stringify(normalized, null, 2)}\n`;
|
|
1001
|
-
|
|
1008
|
+
mutatePeerBookTransactionSync({
|
|
1002
1009
|
selfAid: syncAid,
|
|
1003
1010
|
actor: target === ConfigTarget.Agent ? 'agent-management-role-sync' : 'relation-management-role-sync',
|
|
1004
1011
|
mutation: { type: 'sync-management-roles' },
|
|
@@ -1034,7 +1041,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1034
1041
|
* unrelated fields from another process writing the same config document.
|
|
1035
1042
|
*/
|
|
1036
1043
|
export function mutateConfig(target, sel, mutate) {
|
|
1037
|
-
if (target === ConfigTarget.RoleRegistry || target === ConfigTarget.Role || target === ConfigTarget.
|
|
1044
|
+
if (target === ConfigTarget.RoleRegistry || target === ConfigTarget.Role || target === ConfigTarget.Peer) {
|
|
1038
1045
|
throw new ConfigError('MUTATION_UNSUPPORTED', `mutateConfig does not support ${target}`);
|
|
1039
1046
|
}
|
|
1040
1047
|
const file = targetPath(target, sel);
|
|
@@ -1350,7 +1357,7 @@ export function validateConfig(target, value) {
|
|
|
1350
1357
|
const requestedVersion = value && typeof value === 'object'
|
|
1351
1358
|
? Number(value.$schema_version)
|
|
1352
1359
|
: NaN;
|
|
1353
|
-
const schema = target === ConfigTarget.
|
|
1360
|
+
const schema = target === ConfigTarget.Peer && requestedVersion === 2
|
|
1354
1361
|
? loadSchema('contact-book', 2)
|
|
1355
1362
|
: loadSchema(TARGET_SCHEMA[target]);
|
|
1356
1363
|
const withVer = ensureSchemaVersion(value, schema.version);
|
|
@@ -1619,6 +1626,7 @@ export function resolveEffective(sel, opts = {}) {
|
|
|
1619
1626
|
channels: config.channels ?? [],
|
|
1620
1627
|
projects: config.projects,
|
|
1621
1628
|
capabilities: config.capabilities,
|
|
1629
|
+
baseagentSkills: config.baseagentSkills,
|
|
1622
1630
|
readonlySourceDiagnostics: config.readonlySourceDiagnostics,
|
|
1623
1631
|
// Schema defaults are not applied by AJV during reads; apply the current
|
|
1624
1632
|
// factory default here so omitted observable fields are enabled at runtime.
|
|
@@ -1653,8 +1661,8 @@ export function assertAgentModelConfigured(self, baseagent) {
|
|
|
1653
1661
|
const backend = baseagent ?? config.active_baseagent;
|
|
1654
1662
|
if (!backend)
|
|
1655
1663
|
throw new ConfigError('BASEAGENT_REQUIRED', 'Configure active_baseagent before enabling this Agent');
|
|
1656
|
-
const
|
|
1657
|
-
if (
|
|
1664
|
+
const selection = resolveBaseagentModelSelection(backend, config.baseagents?.[backend]);
|
|
1665
|
+
if (!selection?.model) {
|
|
1658
1666
|
throw new ConfigError('MODEL_NOT_CONFIGURED', `Configure baseagents.${backend}.model before enabling or selecting this backend`);
|
|
1659
1667
|
}
|
|
1660
1668
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomInt } from 'crypto';
|
|
2
2
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
3
|
-
import {
|
|
4
|
-
import { formatContactAlias, normalizeContactChannelKey } from './
|
|
5
|
-
import {
|
|
3
|
+
import { isAcceptedPeer, resolvePeerView } from './peer-book.js';
|
|
4
|
+
import { formatContactAlias, normalizeContactChannelKey } from './peer-alias.js';
|
|
5
|
+
import { mutatePeerBookSync } from './peer-book-store.js';
|
|
6
6
|
export const CONTACT_BIND_CODE_TTL_MS = 10 * 60 * 1000;
|
|
7
7
|
export const CONTACT_BIND_MAX_FAILED_ATTEMPTS = 5;
|
|
8
8
|
export const CONTACT_BIND_MAX_PENDING_PER_CHANNEL = 100;
|
|
@@ -34,8 +34,8 @@ export class ContactBindCodeRegistry {
|
|
|
34
34
|
return { ok: false, error: `invalid channelName: ${req.channelName}` };
|
|
35
35
|
if (!isValidAid(primaryId))
|
|
36
36
|
return { ok: false, error: `invalid primaryId: ${req.primaryId}` };
|
|
37
|
-
const contact =
|
|
38
|
-
if (!contact.isOwner && !
|
|
37
|
+
const contact = resolvePeerView(selfAid, primaryId);
|
|
38
|
+
if (!contact.isOwner && !isAcceptedPeer(selfAid, primaryId)) {
|
|
39
39
|
return { ok: false, error: `only an active contact or Agent owner can bind an identity: ${primaryId}` };
|
|
40
40
|
}
|
|
41
41
|
if (requestedCode && !/^\d{6}$/.test(requestedCode))
|
|
@@ -143,7 +143,7 @@ export class ContactBindCodeRegistry {
|
|
|
143
143
|
this.removePending(pendingKey);
|
|
144
144
|
try {
|
|
145
145
|
const alias = formatContactAlias(matchingItem.channelName, actorId);
|
|
146
|
-
|
|
146
|
+
mutatePeerBookSync({
|
|
147
147
|
selfAid: matchingItem.selfAid,
|
|
148
148
|
actor: actorId,
|
|
149
149
|
mutation: { type: 'bind-alias-eligible', primaryId: matchingItem.primaryId, alias },
|