evolcore 0.0.43-test.4 → 0.0.43-test.5
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 +46 -0
- package/bin/ecmsg.js +354 -91
- package/dist/agents/codex-runner.js +12 -17
- package/dist/aun/aid/agentmd.js +25 -0
- package/dist/aun/aid/control-aid.js +15 -0
- package/dist/aun/aid/identity.js +8 -0
- package/dist/aun/aid/ownership-operation.js +12 -3
- package/dist/channels/aun.js +30 -17
- package/dist/channels/daemon.js +2 -2
- package/dist/cli/agent-create.js +4 -2
- package/dist/cli/aid-bind-command.js +3 -0
- package/dist/cli/aun-commands.js +10 -3
- package/dist/cli/code-stats.js +451 -213
- package/dist/cli/ctl-command.js +1 -3
- package/dist/cli/daemon-commands.js +12 -3
- package/dist/cli/directory.js +3 -1
- package/dist/cli/ecmsg-gateway.js +204 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/init.js +45 -13
- package/dist/cli/provider-command.js +82 -5
- package/dist/cli/restart-monitor.js +11 -19
- package/dist/cli/stats.js +8 -1
- package/dist/cli/task-context.js +3 -0
- package/dist/config/boot-log.js +12 -1
- package/dist/config/config-manager.js +4 -13
- package/dist/config/daemon-services.js +1 -0
- package/dist/config/peer-role-resolver.js +5 -5
- package/dist/config/provider-identity-migration.js +202 -0
- package/dist/config/provider-identity.js +37 -0
- package/dist/config/provider-ipc-service.js +40 -3
- package/dist/config/provider-local-sync.js +153 -0
- package/dist/config/providers-config.js +32 -4
- package/dist/config/providers-management.js +144 -68
- package/dist/config/providers.js +4 -1
- package/dist/config/schema-migration.js +67 -3
- package/dist/core/agent-runtime.js +4 -2
- package/dist/core/auth/auth-gateway.js +5 -3
- package/dist/core/auth/delegation-diagnostics.js +6 -2
- package/dist/core/auth/operation-authorizer.js +3 -1
- package/dist/core/auth/operation-catalog.js +6 -4
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +11 -6
- package/dist/core/command/menu-protocol.js +4 -2
- package/dist/core/command/provider-menu.js +4 -2
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-handler.js +52 -16
- package/dist/core/handoff/runtime.js +9 -3
- package/dist/core/initialization/service.js +4 -3
- package/dist/core/message/aun-ipc-sender.js +81 -3
- package/dist/core/message/message-admission.js +2 -0
- package/dist/core/message/response-engine.js +23 -23
- package/dist/core/message/send-options.js +40 -0
- package/dist/core/message/send-routing.js +310 -0
- package/dist/core/ownership/owner-resolver.js +111 -8
- package/dist/core/permission/ec-command-parser.js +148 -15
- package/dist/core/permission/readonly-shell-query.js +66 -7
- package/dist/core/permission/tool-error-code.js +13 -1
- package/dist/core/permission/tool-policy.js +74 -20
- package/dist/core/relation/same-owner-proof.js +131 -0
- package/dist/core/session/session-idle-monitor.js +94 -16
- package/dist/core/session/session-manager.js +69 -16
- package/dist/core/thread/thread-route.js +5 -2
- package/dist/directory/owner-directory-cache.js +686 -97
- package/dist/directory/owner-directory-markdown.js +146 -36
- package/dist/directory/owner-directory-query-operation.js +2 -2
- package/dist/directory/owner-directory-scope.js +12 -0
- package/dist/directory/owner-directory-search.js +5 -1
- package/dist/directory/owner-directory-store.js +28 -0
- package/dist/ecweb/basic-settings-service.js +15 -1
- package/dist/ecweb/message-context-service.js +2 -2
- package/dist/ecweb/providers-service.js +3 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -9
- package/dist/ecweb/runtime/supervisor.js +76 -24
- package/dist/index.js +4 -0
- package/dist/paths.js +2 -1
- package/dist/proxy/manager.js +2 -0
- package/dist/proxy/service-supervisor.js +2 -2
- package/dist/response-system/engines/v1/proactive-flow.js +4 -0
- package/dist/trigger/application-service.js +1 -0
- package/dist/trigger/event-source.js +4 -0
- package/dist/trigger/feedback.js +26 -2
- package/dist/trigger/scheduler.js +3 -3
- package/dist/trigger/system-definitions.js +2 -2
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/autostart.js +2 -2
- package/dist/utils/cross-platform.js +36 -8
- package/dist/utils/public-suffix.js +5811 -0
- package/dist/utils/windows-autostart.js +41 -7
- package/ecagent/dist/harness/env/nodejs.js +46 -2
- package/kits/docs/aun/ABILITY_CALLING.md +3 -3
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/channels/feishu.md +2 -2
- package/kits/docs/context-assembly.md +20 -4
- package/kits/docs/evolcore/INDEX.md +2 -1
- package/kits/docs/evolcore/agent.md +2 -2
- package/kits/docs/evolcore/aid.md +8 -2
- package/kits/docs/evolcore/ctl.md +13 -4
- package/kits/docs/evolcore/directory.md +48 -15
- package/kits/docs/evolcore/group.md +6 -6
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +32 -3
- package/kits/docs/evolcore/msg.md +28 -27
- package/kits/docs/evolcore/provider.md +39 -5
- package/kits/docs/evolcore/response.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +11 -13
- package/kits/docs/evolcore/tool-authorization.md +17 -0
- package/kits/docs/evolcore/trigger.md +2 -2
- package/kits/docs/identity/ROLE_DETAIL.md +1 -1
- package/kits/docs/prompt-loading-architecture.md +30 -20
- package/kits/eck_manifest.auxiliary.json +5 -5
- package/kits/eck_manifest.json +28 -28
- package/kits/eck_manifest.memory.json +18 -18
- package/kits/rules/01-overview.md +1 -1
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +7 -1
- package/kits/schemas/providers.schema.2.json +74 -0
- package/kits/schemas/role-registry.schema.1.json +1 -1
- package/kits/skills/ec-agent-create/SKILL.md +1 -0
- package/kits/skills/ec-service-proxy/SKILL.md +3 -10
- package/kits/skills/ec-trigger/SKILL.md +5 -5
- package/kits/skills/ec-trigger/references/examples.md +1 -1
- package/kits/templates/system-fragments/channel.md +5 -5
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +10 -3
- package/kits/templates/system-fragments/personal-assistant.md +22 -3
- package/kits/templates/system-fragments/reply.md +47 -28
- package/kits/templates/system-fragments/session.md +2 -9
- package/kits/templates/system-fragments/thread.md +5 -5
- package/package.json +2 -3
package/dist/aun/aid/agentmd.js
CHANGED
|
@@ -705,6 +705,31 @@ export async function agentmdGet(aid, opts) {
|
|
|
705
705
|
catch { /* ignore */ }
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
|
+
/** Ordinary Agent ownership targets require a freshly verified human card. */
|
|
709
|
+
export async function assertHumanAgentOwner(ownerAid, opts = {}) {
|
|
710
|
+
let card;
|
|
711
|
+
try {
|
|
712
|
+
card = await agentmdGet(ownerAid, { ...opts, withVerification: true, remoteOnly: true });
|
|
713
|
+
}
|
|
714
|
+
catch (cause) {
|
|
715
|
+
throw Object.assign(new Error(`Cannot verify the Owner identity for ${ownerAid}`), {
|
|
716
|
+
code: 'OWNER_IDENTITY_UNAVAILABLE', cause,
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
const frontmatter = card.content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
|
|
720
|
+
const document = parseDocument(frontmatter ?? '');
|
|
721
|
+
const fields = document.errors.length === 0 ? document.toJS() : undefined;
|
|
722
|
+
if (card.verification.status !== 'verified' || document.errors.length > 0
|
|
723
|
+
|| !fields || typeof fields !== 'object' || Array.isArray(fields) || fields.aid !== ownerAid
|
|
724
|
+
|| typeof fields.type !== 'string' || !fields.type.trim()) {
|
|
725
|
+
throw Object.assign(new Error(`Cannot verify the Owner identity for ${ownerAid}`), {
|
|
726
|
+
code: 'OWNER_IDENTITY_UNAVAILABLE',
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
if (fields.type !== 'human') {
|
|
730
|
+
throw Object.assign(new Error('An Agent Owner must have type human'), { code: 'INVALID_OWNER' });
|
|
731
|
+
}
|
|
732
|
+
}
|
|
708
733
|
/** Check an existing identity before Agent creation can overwrite its signed card. */
|
|
709
734
|
export async function assertAgentIdentityReusable(aid, opts = {}) {
|
|
710
735
|
let card;
|
|
@@ -14,6 +14,21 @@ import { agentmdPutInitializationProfile, buildInitialAgentMd, invalidateAgentDi
|
|
|
14
14
|
import { logger, logOwnershipEvent } from '../../utils/logger.js';
|
|
15
15
|
const MAX_ATTEMPTS = 5;
|
|
16
16
|
export { DEFAULT_AID_DOMAIN } from './domain.js';
|
|
17
|
+
export function hasLocalControlIdentity(aid, root = resolvePaths().root) {
|
|
18
|
+
if (!isValidAid(aid))
|
|
19
|
+
return false;
|
|
20
|
+
return [['private', 'key.json'], ['public', 'cert.pem']].every(parts => {
|
|
21
|
+
try {
|
|
22
|
+
return fs.statSync(path.join(root, 'AIDs', aid, ...parts)).isFile();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function missingControlIdentityMessage(aid) {
|
|
30
|
+
return `控制 AID ${aid} 的本地证书或私钥缺失。重装 npm 包不能恢复身份;请从可信备份恢复该 AID 的证书和私钥,或明确选择卸载菜单的“完全清除”后重新安装(会删除所有 AIDs、配置与数据)。未自动重新生成 AID。`;
|
|
31
|
+
}
|
|
17
32
|
/** Human-facing platform label used in the control AID's agent.md name. */
|
|
18
33
|
export function controlHostPlatformLabel(platform = process.platform) {
|
|
19
34
|
switch (String(platform).trim().toLowerCase()) {
|
package/dist/aun/aid/identity.js
CHANGED
|
@@ -252,6 +252,10 @@ export async function aidEnsureOwnerBinding(client, aid, ownerAid) {
|
|
|
252
252
|
code: current.code || 'OWNER_BIND_STATE_UNAVAILABLE',
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
+
if (client.getType() === 'agent') {
|
|
256
|
+
const { assertHumanAgentOwner } = await import('./agentmd.js');
|
|
257
|
+
await assertHumanAgentOwner(owner);
|
|
258
|
+
}
|
|
255
259
|
const binding = await client.bindOwneraid(owner);
|
|
256
260
|
if (binding.status === 'error' || binding.status === 'rejected' || binding.status === 'stopped') {
|
|
257
261
|
throw Object.assign(new Error(binding.reason || `Owner binding ${binding.status}`), {
|
|
@@ -336,6 +340,10 @@ export async function aidCreate(aid, opts) {
|
|
|
336
340
|
// 新注册流程:AIDStore.register → downloadCaRoot → load → authenticate
|
|
337
341
|
const store = await getAidStore({ slotId: SLOT.cli, aunPath });
|
|
338
342
|
try {
|
|
343
|
+
if ((opts?.type ?? 'agent') === 'agent' && opts?.owner?.trim()) {
|
|
344
|
+
const { assertHumanAgentOwner } = await import('./agentmd.js');
|
|
345
|
+
await assertHumanAgentOwner(opts.owner.trim(), { aunPath, store });
|
|
346
|
+
}
|
|
339
347
|
const regResult = await store.register(aid, {
|
|
340
348
|
type: opts?.type ?? 'agent',
|
|
341
349
|
...(opts?.owner?.trim() ? { owner: opts.owner.trim() } : {}),
|
|
@@ -17,13 +17,17 @@ export function parseOwnershipCommand(argv) {
|
|
|
17
17
|
if (!args[0] || !args[1] || !['bind', 'transfer'].includes(args[0])) {
|
|
18
18
|
throw new OwnershipError('INVALID_ARGUMENT', `Use ${MAIN_CLI_BIN} aid bind <ownerAid>, transfer <subAid> <newOwnerAid>, status, accept, or reject`);
|
|
19
19
|
}
|
|
20
|
-
const action = args[0] === '
|
|
21
|
-
: [
|
|
20
|
+
const action = args[0] === 'bind' && args[1] === 'reject' && args[2] === '--reset' ? 'reset-rejection'
|
|
21
|
+
: args[0] === 'transfer' ? 'transfer'
|
|
22
|
+
: ['status', 'accept', 'reject'].includes(args[1]) ? args[1] : 'bind';
|
|
22
23
|
if (action === 'bind' && !isValidAid(args[1]))
|
|
23
24
|
throw new OwnershipError('INVALID_AID', 'A valid owner AID is required');
|
|
24
25
|
if (action === 'transfer' && (!isValidAid(args[1]) || !isValidAid(args[2] ?? ''))) {
|
|
25
26
|
throw new OwnershipError('INVALID_AID', 'Valid sub and new owner AIDs are required');
|
|
26
27
|
}
|
|
28
|
+
if (action === 'reset-rejection' && !isValidAid(args[3] ?? '')) {
|
|
29
|
+
throw new OwnershipError('INVALID_AID', 'A valid owner AID is required to reset a rejection');
|
|
30
|
+
}
|
|
27
31
|
if ((action === 'accept' || action === 'reject') && !OWNERSHIP_OPERATION_ID.test(args[2] ?? '')) {
|
|
28
32
|
throw new OwnershipError('INVALID_OPERATION', 'A valid ownership operation ID is required');
|
|
29
33
|
}
|
|
@@ -31,7 +35,7 @@ export function parseOwnershipCommand(argv) {
|
|
|
31
35
|
let reason;
|
|
32
36
|
let refresh = false;
|
|
33
37
|
let formatSeen = false;
|
|
34
|
-
const positionalEnd = action === 'bind' || action === 'status' ? 2 : 3;
|
|
38
|
+
const positionalEnd = action === 'reset-rejection' ? 4 : action === 'bind' || action === 'status' ? 2 : 3;
|
|
35
39
|
for (let index = positionalEnd; index < args.length;) {
|
|
36
40
|
const flag = args[index];
|
|
37
41
|
if (flag === '--refresh' && action === 'status' && !refresh) {
|
|
@@ -57,6 +61,8 @@ export function parseOwnershipCommand(argv) {
|
|
|
57
61
|
}
|
|
58
62
|
if (action === 'status')
|
|
59
63
|
return { action, subjectAid, ...(refresh ? { refresh } : {}) };
|
|
64
|
+
if (action === 'reset-rejection')
|
|
65
|
+
return { action, subjectAid, ownerAid: args[3] };
|
|
60
66
|
if (action === 'transfer')
|
|
61
67
|
return { action, subAid: args[1], newOwnerAid: args[2], subjectAid };
|
|
62
68
|
if (action === 'accept')
|
|
@@ -72,6 +78,9 @@ export async function executeOwnershipCommand(command, defaultSubjectAid) {
|
|
|
72
78
|
if (command.action === 'status') {
|
|
73
79
|
return ownerResolver.status(subjectAid, { force: command.refresh === true });
|
|
74
80
|
}
|
|
81
|
+
if (command.action === 'reset-rejection') {
|
|
82
|
+
return ownerResolver.resetRejectedOwnerBinding(subjectAid, command.ownerAid);
|
|
83
|
+
}
|
|
75
84
|
if (command.action === 'accept' || command.action === 'reject') {
|
|
76
85
|
return ownerResolver.decide(subjectAid, command.operationId, command.action, command.action === 'reject' ? command.reason : undefined);
|
|
77
86
|
}
|
package/dist/channels/aun.js
CHANGED
|
@@ -4,11 +4,11 @@ import { buildContactRequest, contactIntroductionText, consumeContactIntroductio
|
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
6
6
|
import fs from 'fs';
|
|
7
|
-
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
7
|
+
import { ownerResolver, OWNERSHIP_CACHE_MAX_AGE_MS } from '../core/ownership/owner-resolver.js';
|
|
8
8
|
import { OWNER_DIRECTORY_APPLY_WAIT_MS, OwnerDirectoryCache, parseOwnerDirectoryGrantAbilityResponse } from '../directory/owner-directory-cache.js';
|
|
9
9
|
import { registerOwnerDirectoryAdmission } from '../directory/owner-directory-admission.js';
|
|
10
10
|
import { OwnerDirectoryAgentMdSync } from '../directory/owner-directory-agentmd-sync.js';
|
|
11
|
-
import { parseNotificationSnapshots } from '../directory/owner-directory-store.js';
|
|
11
|
+
import { parseNotificationSnapshots, parseNotificationPublished } from '../directory/owner-directory-store.js';
|
|
12
12
|
import { OWNER_DIRECTORY_SCOPES } from '../directory/owner-directory-cache.js';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import os from 'os';
|
|
@@ -44,7 +44,7 @@ import * as outbox from '../aun/outbox.js';
|
|
|
44
44
|
import { aunProtectedHeaders } from '../aun/model-headers.js';
|
|
45
45
|
import { formatSize } from '../utils/media-cache.js';
|
|
46
46
|
import { formatPeerKey, PeerIdentityCache } from '../core/relation/peer-identity.js';
|
|
47
|
-
import {
|
|
47
|
+
import { prepareSameOwnerProof, registerSameOwnerClient, unregisterSameOwnerClient } from '../core/relation/same-owner-proof.js';
|
|
48
48
|
import { isHClassPath } from '../core/permission/protected-paths.js';
|
|
49
49
|
import { consumeAunCausation, registerAunCausation } from '../core/causation/aun-association.js';
|
|
50
50
|
import { deriveCausation, normalizeCausation } from '../core/causation/context.js';
|
|
@@ -1919,13 +1919,16 @@ export class AUNChannel {
|
|
|
1919
1919
|
// ACK 只回传通知自带的 operation_id;旧版通知不带它,也不等 ACK,不能自造一个回过去。
|
|
1920
1920
|
const operationId = typeof record.data.operation_id === 'string' && record.data.operation_id.trim()
|
|
1921
1921
|
? record.data.operation_id : undefined;
|
|
1922
|
+
// `published.<scope>.updated_at_ms`:远端这一版自己声明的修改时间。
|
|
1923
|
+
// 协调者用它丢弃乱序到达的旧通知,并判断已经拉到的东西够不够新。
|
|
1924
|
+
const published = parseNotificationPublished(record.data);
|
|
1922
1925
|
try {
|
|
1923
1926
|
const runtime = await this.getOwnerDirectoryRuntime();
|
|
1924
1927
|
if (!runtime)
|
|
1925
1928
|
return;
|
|
1926
1929
|
// 记标记。真正的网络拉取在 ACK 之后发起(见方法末尾):先拉会把网络耗时
|
|
1927
1930
|
// 压进 App 侧的重试窗口,App 可能因此在拿到 ACK 前再发一次通知。
|
|
1928
|
-
await runtime.cache.handleOwnerChangedEvent(senderAid, Object.keys(digests).length > 0 ? Object.fromEntries(Object.entries(digests).map(([k, v]) => [k, v?.content_digest ?? ''])) : undefined);
|
|
1931
|
+
await runtime.cache.handleOwnerChangedEvent(senderAid, Object.keys(digests).length > 0 ? Object.fromEntries(Object.entries(digests).map(([k, v]) => [k, v?.content_digest ?? ''])) : undefined, published);
|
|
1929
1932
|
// 重试状态只在发通知的那台设备内存里;拿不到它的设备 ID 就不回,
|
|
1930
1933
|
// 广播给 Owner 全部设备既清不掉重试,又会被其它设备当成会话消息展示。
|
|
1931
1934
|
if (operationId && senderDeviceId) {
|
|
@@ -2352,7 +2355,7 @@ export class AUNChannel {
|
|
|
2352
2355
|
this.observerGroupMemberFetches.clear();
|
|
2353
2356
|
// Clean up existing client if any
|
|
2354
2357
|
if (this.client) {
|
|
2355
|
-
|
|
2358
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
2356
2359
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
2357
2360
|
this.trace('OUT', 'client.close', { reason: 'initClient' });
|
|
2358
2361
|
try {
|
|
@@ -2394,7 +2397,7 @@ export class AUNChannel {
|
|
|
2394
2397
|
const localConfig = loadAgent(aidName);
|
|
2395
2398
|
ownerResolver.setAgentConfiguredOwners(aidName, configuredOwnerList(localConfig));
|
|
2396
2399
|
ownerResolver.attachClient(aidName, client);
|
|
2397
|
-
|
|
2400
|
+
registerSameOwnerClient(aidName, client, store);
|
|
2398
2401
|
try {
|
|
2399
2402
|
await this.config.onClientReady?.(client);
|
|
2400
2403
|
}
|
|
@@ -3402,7 +3405,7 @@ export class AUNChannel {
|
|
|
3402
3405
|
// 解析对端身份(30天缓存)
|
|
3403
3406
|
const selfAgentDir = path.join(resolvePaths().agentsDir, this.config.aid);
|
|
3404
3407
|
const peerIdentity = await PeerIdentityCache.resolve('aun', fromAid, selfAgentDir, this.store, false, this.config.keystorePath || resolveRoot());
|
|
3405
|
-
await
|
|
3408
|
+
await prepareSameOwnerProof(this.config.aid, fromAid);
|
|
3406
3409
|
const shortAid = this.getShortAid(fromAid);
|
|
3407
3410
|
const displayName = peerIdentity.name || shortAid;
|
|
3408
3411
|
// 详细 dispatch 决策日志:记录消息为何被路由到 agent
|
|
@@ -4599,7 +4602,7 @@ export class AUNChannel {
|
|
|
4599
4602
|
if (!config)
|
|
4600
4603
|
return undefined;
|
|
4601
4604
|
const lifecycle = resolveAgentLifecycle(config);
|
|
4602
|
-
if (lifecycle === null
|
|
4605
|
+
if (lifecycle === null)
|
|
4603
4606
|
return undefined;
|
|
4604
4607
|
return firstConfiguredOwner(config);
|
|
4605
4608
|
}
|
|
@@ -4666,6 +4669,8 @@ export class AUNChannel {
|
|
|
4666
4669
|
return;
|
|
4667
4670
|
// Claim before awaiting submission: an error or lost receipt must not cause automatic resends.
|
|
4668
4671
|
AUNChannel.configuredOwnerBindAttempts.add(attemptKey);
|
|
4672
|
+
logger.info(`${this.logPrefix()} Submitting configured Owner binding invitation: `
|
|
4673
|
+
+ `subject=${subjectAid} owner=${ownerAid} consensus=${current.consensusStatus}`);
|
|
4669
4674
|
await ownerResolver.bind(subjectAid, ownerAid, () => this.isCurrentConfiguredOwnerBind(client, epoch) && this.configuredOwnerAid() === ownerAid
|
|
4670
4675
|
&& !ownerResolver.hasRejectedOwnerBinding(subjectAid, ownerAid));
|
|
4671
4676
|
}
|
|
@@ -4744,7 +4749,7 @@ export class AUNChannel {
|
|
|
4744
4749
|
}
|
|
4745
4750
|
// Force close SDK client,中断它内部的重连循环
|
|
4746
4751
|
if (this.client) {
|
|
4747
|
-
|
|
4752
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4748
4753
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4749
4754
|
this.trace('OUT', 'client.close', { reason: `takeover_${reason}` });
|
|
4750
4755
|
this.client.close().catch(() => { });
|
|
@@ -4771,7 +4776,7 @@ export class AUNChannel {
|
|
|
4771
4776
|
logger.debug(`${this.logPrefix()} TS-layer reconnect (${reason}) succeeded but generation stale, closing stale client`);
|
|
4772
4777
|
this.stopOwnerDirectoryRefresh();
|
|
4773
4778
|
if (this.client) {
|
|
4774
|
-
|
|
4779
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4775
4780
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4776
4781
|
this.client.close().catch(() => { });
|
|
4777
4782
|
this.client = null;
|
|
@@ -5296,9 +5301,16 @@ export class AUNChannel {
|
|
|
5296
5301
|
return { status: decision.reason === 'unavailable' ? 'retry' : 'permanent',
|
|
5297
5302
|
code: 'CONTACT_DENIED', error: `联系人准入未通过:${decision.reason}` };
|
|
5298
5303
|
}
|
|
5304
|
+
async prepareAppContactOutbound(channelId, delivery, payload, params) {
|
|
5305
|
+
if (delivery.chatType === 'private' && !this.config.pureIdentity
|
|
5306
|
+
&& !this.hasContactControlPermit(channelId, payload, params)) {
|
|
5307
|
+
await ownerResolver.refresh(this.config.aid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5308
|
+
}
|
|
5309
|
+
return this.appContactOutboundBlock(channelId, delivery, payload, params);
|
|
5310
|
+
}
|
|
5299
5311
|
async sendAunPayload(channelId, payload, context, label) {
|
|
5300
5312
|
const delivery = this.requireDelivery(channelId, context);
|
|
5301
|
-
const blocked = this.
|
|
5313
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, payload);
|
|
5302
5314
|
if (blocked)
|
|
5303
5315
|
return { ok: false, ...blocked };
|
|
5304
5316
|
let normalizedPayload;
|
|
@@ -5809,6 +5821,7 @@ export class AUNChannel {
|
|
|
5809
5821
|
/** An unadmitted outbound text becomes an Owner request, never a send to the peer. */
|
|
5810
5822
|
async requestOutboundContact(args) {
|
|
5811
5823
|
const selfAid = this.config.aid;
|
|
5824
|
+
await ownerResolver.refresh(selfAid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5812
5825
|
const binding = currentContactBinding(selfAid);
|
|
5813
5826
|
if (!binding) {
|
|
5814
5827
|
return { ok: false, code: 'CONTACT_DIRECTORY_UNAVAILABLE', error: '本端 Owner 关系不可用,未发送申请或原消息' };
|
|
@@ -5891,7 +5904,7 @@ export class AUNChannel {
|
|
|
5891
5904
|
code: 'INVALID_REQUEST_TTL',
|
|
5892
5905
|
};
|
|
5893
5906
|
}
|
|
5894
|
-
const contactBlock = this.
|
|
5907
|
+
const contactBlock = await this.prepareAppContactOutbound(args.to, { chatType: 'private' }, finalPayload, { encrypt: args.encrypt, rawPayload: preserveRawPayload });
|
|
5895
5908
|
if (contactBlock)
|
|
5896
5909
|
return { ok: false, code: contactBlock.code, error: contactBlock.error };
|
|
5897
5910
|
if (preserveRawPayload && jsonUtf8Size(finalPayload) > AUN_MAX_PAYLOAD_SIZE) {
|
|
@@ -5911,7 +5924,7 @@ export class AUNChannel {
|
|
|
5911
5924
|
let peerRole = null;
|
|
5912
5925
|
try {
|
|
5913
5926
|
const { resolvePeerRoleDetail } = await import('../config/peer-role-resolver.js');
|
|
5914
|
-
await
|
|
5927
|
+
await prepareSameOwnerProof(this.config.aid, args.to);
|
|
5915
5928
|
peerRole = resolvePeerRoleDetail({
|
|
5916
5929
|
selfAid: this.config.aid,
|
|
5917
5930
|
channelKey: `aun#${this.config.aid}#main`,
|
|
@@ -6232,7 +6245,7 @@ export class AUNChannel {
|
|
|
6232
6245
|
const delivery = this.requirePersistedDelivery(channelId, entry.delivery);
|
|
6233
6246
|
const context = this.withDelivery(entry.context, delivery);
|
|
6234
6247
|
if (!entry.deliveryReceipt) {
|
|
6235
|
-
const blocked = this.
|
|
6248
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, { type: 'text', text: entry.text });
|
|
6236
6249
|
if (blocked)
|
|
6237
6250
|
return blocked;
|
|
6238
6251
|
}
|
|
@@ -7019,7 +7032,7 @@ export class AUNChannel {
|
|
|
7019
7032
|
}
|
|
7020
7033
|
async deliverImageEntry(entry) {
|
|
7021
7034
|
if (!entry.deliveryReceipt) {
|
|
7022
|
-
const blocked = this.
|
|
7035
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'image' });
|
|
7023
7036
|
if (blocked)
|
|
7024
7037
|
return blocked;
|
|
7025
7038
|
}
|
|
@@ -7070,7 +7083,7 @@ export class AUNChannel {
|
|
|
7070
7083
|
}
|
|
7071
7084
|
async deliverFileEntry(entry) {
|
|
7072
7085
|
if (!entry.deliveryReceipt) {
|
|
7073
|
-
const blocked = this.
|
|
7086
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'file' });
|
|
7074
7087
|
if (blocked)
|
|
7075
7088
|
return blocked;
|
|
7076
7089
|
}
|
|
@@ -7487,7 +7500,7 @@ export class AUNChannel {
|
|
|
7487
7500
|
this.stopOwnerDirectoryRefresh();
|
|
7488
7501
|
this.configuredOwnerBindEpoch++;
|
|
7489
7502
|
if (this.client) {
|
|
7490
|
-
|
|
7503
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
7491
7504
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
7492
7505
|
}
|
|
7493
7506
|
this.managedMenuClient.close();
|
package/dist/channels/daemon.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ExecutionTimeoutError } from '../utils/error-utils.js';
|
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { normalizeExecutionMode } from '../trigger/validation.js';
|
|
5
5
|
import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
|
|
6
|
-
import {
|
|
6
|
+
import { prepareSameOwnerProof } from '../core/relation/same-owner-proof.js';
|
|
7
7
|
import { assertSystemSessionLaunchable } from '../core/system-session/registry.js';
|
|
8
8
|
import { sessionTopicThreadId } from '../core/thread/topic-id.js';
|
|
9
9
|
const DEFAULT_WATCHDOG_MS = 11 * 60 * 1000;
|
|
@@ -148,7 +148,7 @@ export class DaemonChannel {
|
|
|
148
148
|
if (ctx.signal?.aborted)
|
|
149
149
|
onAbort();
|
|
150
150
|
if (message.triggerMeta?.originChannelType === 'aun' && message.triggerMeta.originChatType !== 'group') {
|
|
151
|
-
await
|
|
151
|
+
await prepareSameOwnerProof(ctx.trigger.agentAid, message.triggerMeta.originPeerId);
|
|
152
152
|
}
|
|
153
153
|
if (!slot?.terminalClaim) {
|
|
154
154
|
void this.messageQueue.enqueue(ctx.session.id, message, ctx.projectPath, {
|
package/dist/cli/agent-create.js
CHANGED
|
@@ -24,7 +24,7 @@ import { readTaskRuntimeContextFromEnv } from './task-context.js';
|
|
|
24
24
|
import { logger } from '../utils/logger.js';
|
|
25
25
|
import { creationOwnershipBinding } from '../core/ownership/owner-resolver.js';
|
|
26
26
|
import { getCatalog, getProviderCatalog, resolveCatalogModel, catalogEfforts, assertCatalogSelectable } from '../core/model/model-catalog.js';
|
|
27
|
-
import { resolveProviderServiceForBaseagent } from '../config/providers.js';
|
|
27
|
+
import { resolveProviderId, resolveProviderServiceForBaseagent } from '../config/providers.js';
|
|
28
28
|
import { claimAgentCreation, claimAgentCreationAsync, readAgentCreationClaim, updateAgentCreationClaim } from '../core/agent-creation-claim.js';
|
|
29
29
|
/** Select the creation lifecycle independently of --non-interactive. */
|
|
30
30
|
export function resolveAgentCreateMode(args) {
|
|
@@ -1594,7 +1594,9 @@ export class AgentInitializationService {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
// Omitted fields use the existing defaults/migration selection, just as
|
|
1596
1596
|
// they do on initial creation. Only explicit plan overrides are frozen.
|
|
1597
|
-
if (config && r.plan.provider !== undefined
|
|
1597
|
+
if (config && r.plan.provider !== undefined
|
|
1598
|
+
&& (typeof baseagentConfig?.provider !== 'string'
|
|
1599
|
+
|| resolveProviderId(baseagentConfig.provider) !== resolveProviderId(r.plan.provider)))
|
|
1598
1600
|
failure('INITIALIZE_TARGET_CHANGED');
|
|
1599
1601
|
if (config && r.plan.chatmode !== undefined
|
|
1600
1602
|
&& ['private', 'group', 'nothuman'].some(scope => config.chatmode?.[scope] !== r.plan.chatmode?.[scope])) {
|
|
@@ -11,6 +11,7 @@ export async function cmdAidBind(args) {
|
|
|
11
11
|
`${MAIN_CLI_BIN} aid bind status [--refresh] [--subject <subjectAid>] [--format json]`,
|
|
12
12
|
`${MAIN_CLI_BIN} aid bind accept <operationId> [--subject <subjectAid>] [--format json]`,
|
|
13
13
|
`${MAIN_CLI_BIN} aid bind reject <operationId> [--reason <text>] [--subject <subjectAid>] [--format json]`,
|
|
14
|
+
`${MAIN_CLI_BIN} aid bind reject --reset <ownerAid> [--subject <subjectAid>] [--format json]`,
|
|
14
15
|
'宿主 CLI 可显式加 --local-control 选择本地控制,并持有本地控制凭据;TTY 不授予权限。',
|
|
15
16
|
'同一 OS 用户可读取控制凭据,fullaccess 与宿主共用该信任边界。',
|
|
16
17
|
].join('\n'));
|
|
@@ -60,6 +61,8 @@ export async function cmdAidBind(args) {
|
|
|
60
61
|
console.log(`最近已确认关系(历史快照): ${state.relation.consensusStatus} (owner=${state.relation.ownerAid ?? '-'}, version=${state.relation.relationVersion})`);
|
|
61
62
|
}
|
|
62
63
|
console.log(`运行态同步: ${state.synchronization.status}`);
|
|
64
|
+
if (state.rejectionReset)
|
|
65
|
+
console.log(`自动邀约拒绝记录: ${state.rejectionReset.ownerAid} (${state.rejectionReset.cleared ? '已清除' : '不存在'});未提交绑定邀约`);
|
|
63
66
|
if (state.task)
|
|
64
67
|
console.log(`SDK 动作记录(不代表绑定结论): ${state.task.operation_id} (${state.task.status}/${state.task.step})`);
|
|
65
68
|
if (state.decisionTask)
|
package/dist/cli/aun-commands.js
CHANGED
|
@@ -6,6 +6,7 @@ import { normalizeGroupAid } from '../aun/group/index.js';
|
|
|
6
6
|
import { getArgValue, isHelpFlag, wantsHelp } from './help.js';
|
|
7
7
|
import { daemonUnavailableMessage, queryDaemon } from './help.js';
|
|
8
8
|
import { isValidAid as validSendAid } from '../aun/aid/validation.js';
|
|
9
|
+
import { MANAGED_SEND_BOOLEAN_FLAGS, MANAGED_SEND_VALUE_FLAGS } from '../core/message/send-options.js';
|
|
9
10
|
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, readDelegationCredential, } from '../core/auth/agent-delegation.js';
|
|
10
11
|
import { MAIN_CLI_BIN, SELF_AID_ENV, SESSION_ID_ENV } from '../product.js';
|
|
11
12
|
import { isTrustedFullAccessRuntimeContext, readBestTaskRuntimeContext, readVerifiedTaskRuntimeContext, RUNTIME_LOCK_DIR_ENV, SESSION_RUNTIME_DIR_ENV, TASK_RUNTIME_CONTEXT_ENV, } from './task-context.js';
|
|
@@ -508,6 +509,7 @@ Commands:
|
|
|
508
509
|
bind status [--refresh] [--subject <subjectAid>] 核验协议 Owner、任务和同步状态(--refresh 强制重新查询)
|
|
509
510
|
bind accept <operationId> [--subject <subjectAid>] 接受绑定邀约
|
|
510
511
|
bind reject <operationId> [--reason <text>] [--subject <subjectAid>] 拒绝绑定邀约
|
|
512
|
+
bind reject --reset <ownerAid> [--subject <subjectAid>] 清除自动邀约拒绝记录(不发送邀约)
|
|
511
513
|
|
|
512
514
|
Options:
|
|
513
515
|
--format json 输出 JSON 格式
|
|
@@ -3633,8 +3635,8 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3633
3635
|
const booleans = new Set();
|
|
3634
3636
|
const text = [];
|
|
3635
3637
|
const mentions = [];
|
|
3636
|
-
const valueFlags = new Set(
|
|
3637
|
-
const booleanFlags = new Set(
|
|
3638
|
+
const valueFlags = new Set(MANAGED_SEND_VALUE_FLAGS);
|
|
3639
|
+
const booleanFlags = new Set(MANAGED_SEND_BOOLEAN_FLAGS);
|
|
3638
3640
|
for (let index = bodyStart; index < argv.length; index++) {
|
|
3639
3641
|
const flag = argv[index];
|
|
3640
3642
|
if (flag === '--') {
|
|
@@ -3704,7 +3706,12 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3704
3706
|
const to = scope === 'group'
|
|
3705
3707
|
? normalizeGroupAid(argv[3], aid.slice(aid.indexOf('.') + 1))
|
|
3706
3708
|
: hasTo ? argv[3] : inferredTarget;
|
|
3707
|
-
if (!to
|
|
3709
|
+
if (!to)
|
|
3710
|
+
throw new Error('Invalid send target');
|
|
3711
|
+
// 目标形态:普通发送必须是合法 AID。但 `--thread` 指向的目标会话可能属于
|
|
3712
|
+
// 其它渠道(如飞书),那条会话的 `peer` 是原生 ID(`ou_…`),不是 AID。
|
|
3713
|
+
// 此时由话题索引保证目标正确,不再按 AID 校验。
|
|
3714
|
+
if (!thread && !validSendAid(to))
|
|
3708
3715
|
throw new Error('Invalid send target');
|
|
3709
3716
|
const checkEvery = values.get('--check-every');
|
|
3710
3717
|
const triggerPromptExtra = values.get('--trigger-prompt');
|