evolcore 0.0.43-test.4 → 0.0.43-test.6
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 +93 -0
- package/bin/ecmsg.js +437 -91
- package/dist/agents/baseagent-availability.js +19 -4
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +14 -3
- package/dist/agents/codex-runner.js +18 -23
- 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/aun/group/invite-service.js +3 -2
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +99 -23
- package/dist/channels/daemon.js +2 -2
- package/dist/cli/agent-create.js +19 -7
- package/dist/cli/aid-bind-command.js +3 -0
- package/dist/cli/aun-commands.js +19 -4
- package/dist/cli/code-stats.js +451 -213
- package/dist/cli/ctl-command.js +1 -3
- package/dist/cli/daemon-commands.js +42 -4
- package/dist/cli/directory.js +3 -1
- package/dist/cli/ecmsg-gateway.js +206 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/init.js +120 -13
- package/dist/cli/provider-command.js +82 -5
- package/dist/cli/restart-monitor.js +35 -24
- package/dist/cli/stats.js +8 -1
- package/dist/cli/task-context.js +41 -1
- package/dist/cli/watch-logs.js +6 -4
- package/dist/config/boot-log.js +16 -3
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-manager.js +5 -14
- package/dist/config/daemon-services.js +1 -0
- package/dist/config/peer-role-resolver.js +6 -6
- package/dist/config/provider-identity-migration.js +277 -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 +155 -0
- package/dist/config/providers-config.js +45 -4
- package/dist/config/providers-management.js +242 -76
- package/dist/config/providers.js +4 -1
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +143 -86
- package/dist/config/snapshot.js +70 -41
- package/dist/core/agent-runtime.js +48 -9
- 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/baseagent-loader.js +114 -11
- package/dist/core/channel-loader.js +36 -13
- package/dist/core/channel-runtime.js +112 -42
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +16 -11
- package/dist/core/command/menu-handler.js +8 -3
- package/dist/core/command/menu-protocol.js +80 -7
- package/dist/core/command/provider-menu.js +4 -2
- package/dist/core/command/role-menu.js +29 -17
- package/dist/core/command/slash-handler.js +52 -16
- package/dist/core/daemon-control.js +42 -15
- package/dist/core/daemon-lifecycle.js +411 -67
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +139 -45
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +7 -6
- package/dist/core/ipc-registration.js +5 -4
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/message/aun-ipc-sender.js +83 -5
- package/dist/core/message/message-admission.js +2 -0
- package/dist/core/message/message-bridge.js +53 -4
- package/dist/core/message/message-queue.js +46 -4
- package/dist/core/message/pending-hints.js +4 -10
- package/dist/core/message/response-engine.js +33 -25
- package/dist/core/message/send-options.js +40 -0
- package/dist/core/message/send-routing.js +320 -0
- package/dist/core/ownership/owner-resolver.js +112 -8
- package/dist/core/permission/ec-command-parser.js +159 -16
- 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/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-fs-store.js +164 -3
- package/dist/core/session/session-idle-monitor.js +103 -17
- package/dist/core/session/session-manager.js +105 -18
- package/dist/core/thread/thread-route.js +5 -2
- package/dist/directory/owner-directory-admission.js +26 -1
- package/dist/directory/owner-directory-cache.js +739 -109
- package/dist/directory/owner-directory-markdown.js +146 -36
- package/dist/directory/owner-directory-query-operation.js +6 -3
- 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 +26 -15
- package/dist/ecweb/runtime/supervisor.js +120 -51
- package/dist/index.js +551 -250
- package/dist/paths.js +2 -1
- package/dist/proxy/manager.js +40 -17
- package/dist/proxy/service-supervisor.js +67 -33
- package/dist/response-system/engines/v1/proactive-flow.js +4 -0
- package/dist/trigger/application-service.js +4 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/event-source.js +4 -0
- package/dist/trigger/feedback.js +26 -2
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +81 -8
- 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 +188 -12
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +64 -1
- package/dist/utils/public-suffix.js +5811 -0
- package/dist/utils/startup-trace.js +160 -19
- package/dist/utils/windows-autostart.js +41 -7
- package/ecagent/dist/harness/env/nodejs.js +46 -2
- package/kits/docs/aun/ABILITY_CALLING.md +6 -6
- 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 +5 -3
- package/kits/docs/evolcore/agent.md +2 -2
- package/kits/docs/evolcore/aid.md +8 -2
- package/kits/docs/evolcore/ctl.md +15 -5
- package/kits/docs/evolcore/directory.md +48 -15
- package/kits/docs/evolcore/group.md +8 -8
- package/kits/docs/evolcore/memory-consolidation.md +1 -1
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +32 -3
- package/kits/docs/evolcore/msg.md +38 -30
- package/kits/docs/evolcore/provider.md +57 -5
- package/kits/docs/evolcore/response.md +2 -2
- 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 +44 -32
- package/kits/eck_manifest.memory.json +18 -18
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/01-overview.md +1 -1
- package/kits/rules/06-channel.md +7 -8
- package/kits/schemas/_meta.json +7 -1
- package/kits/schemas/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/providers.schema.2.json +74 -0
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- package/kits/skills/aid-ability/SKILL.md +7 -7
- package/kits/skills/ec-agent-create/SKILL.md +1 -0
- package/kits/skills/ec-group/SKILL.md +8 -5
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +3 -10
- package/kits/skills/ec-trigger/SKILL.md +9 -9
- package/kits/skills/ec-trigger/references/examples.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/system-fragments/channel.md +5 -5
- package/kits/templates/system-fragments/commands.md +7 -6
- 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 +48 -28
- package/kits/templates/system-fragments/session.md +3 -10
- package/kits/templates/system-fragments/thread.md +5 -5
- package/package.json +4 -4
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';
|
|
@@ -407,6 +407,7 @@ const AUN_PERMANENT_STRING_CODES = new Set([
|
|
|
407
407
|
const AUN_RETRYABLE_STRING_CODES = new Set([
|
|
408
408
|
'network_error', 'connection_error', 'timeout', 'timed_out', 'rate_limited',
|
|
409
409
|
'too_many_requests', 'temporarily_unavailable', 'server_error', 'aun_not_connected',
|
|
410
|
+
'contact_directory_unavailable', 'contact_ownership_unavailable',
|
|
410
411
|
]);
|
|
411
412
|
function errorRecord(value) {
|
|
412
413
|
return value && typeof value === 'object' && !Array.isArray(value)
|
|
@@ -498,6 +499,8 @@ export function classifyAunSendFailure(value, fallback = 'AUN send failed') {
|
|
|
498
499
|
const retryByName = /(?:timeout|connection|rate.?limit|temporar(?:y|ily)|unavailable|network|socket)/i.test(details.name ?? '');
|
|
499
500
|
const relayTargetMissing = text.includes('relay_target_not_found') || text.includes('relay target not found');
|
|
500
501
|
const rpcHandlerTimeout = numericCode === -32004 && /rpc handler timeout/i.test(text);
|
|
502
|
+
const gatewayWarming = numericCode === -32020
|
|
503
|
+
&& details.message === 'Gateway is warming; retry via another gateway';
|
|
501
504
|
// -32013 is otherwise permanent, but "client signature cert unavailable" is
|
|
502
505
|
// the gateway failing to resolve the signer's certificate while the local
|
|
503
506
|
// cert is valid and auth succeeded. It clears server-side, so keep the
|
|
@@ -550,6 +553,7 @@ export function classifyAunSendFailure(value, fallback = 'AUN send failed') {
|
|
|
550
553
|
else if (AUN_RETRYABLE_ERROR_CODES.has(numericCode ?? Number.NaN)
|
|
551
554
|
|| transientHttpStatus
|
|
552
555
|
|| rpcHandlerTimeout
|
|
556
|
+
|| gatewayWarming
|
|
553
557
|
|| signatureCertUnavailable
|
|
554
558
|
|| AUN_RETRYABLE_STRING_CODES.has(stringCode)
|
|
555
559
|
|| retryByName
|
|
@@ -908,7 +912,9 @@ export class AUNChannel {
|
|
|
908
912
|
if (!beforeSend) {
|
|
909
913
|
const blocked = this.appContactOutboundBlock(params.to, { chatType: 'private' }, payload, params);
|
|
910
914
|
if (blocked) {
|
|
911
|
-
throw Object.assign(new Error(blocked.error), {
|
|
915
|
+
throw Object.assign(new Error(blocked.error), {
|
|
916
|
+
code: blocked.code, retryable: blocked.status === 'retry',
|
|
917
|
+
});
|
|
912
918
|
}
|
|
913
919
|
}
|
|
914
920
|
}
|
|
@@ -1641,6 +1647,15 @@ export class AUNChannel {
|
|
|
1641
1647
|
logger.warn(`${this.logPrefix()} topic.renamed failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1642
1648
|
});
|
|
1643
1649
|
}
|
|
1650
|
+
/** Quiesce callbacks before the shared resolver is detached, while offline sends still work. */
|
|
1651
|
+
prepareShutdown() {
|
|
1652
|
+
this.intentionalDisconnect = true;
|
|
1653
|
+
this.configuredOwnerBindEpoch++;
|
|
1654
|
+
this.stopOwnerDirectoryRefresh();
|
|
1655
|
+
if (this.reconnectTimer)
|
|
1656
|
+
clearTimeout(this.reconnectTimer);
|
|
1657
|
+
this.reconnectTimer = null;
|
|
1658
|
+
}
|
|
1644
1659
|
stopOwnerDirectoryRefresh() {
|
|
1645
1660
|
this.ownerDirectoryWatch?.stop();
|
|
1646
1661
|
this.ownerDirectoryWatch = undefined;
|
|
@@ -1756,13 +1771,15 @@ export class AUNChannel {
|
|
|
1756
1771
|
const selfAid = this.config.aid.replace(/^@/, '');
|
|
1757
1772
|
const client = this.client;
|
|
1758
1773
|
logger.debug(`${this.logPrefix()} getOwnerDirectoryRuntime called: selfAid=${selfAid}, connected=${this.connected}, pureIdentity=${!!this.config.pureIdentity}`);
|
|
1759
|
-
if (!client || !this.connected || this.config.pureIdentity) {
|
|
1774
|
+
if (!client || !this.connected || this.intentionalDisconnect || this.config.pureIdentity) {
|
|
1760
1775
|
logger.debug(`${this.logPrefix()} getOwnerDirectoryRuntime early return: client=${!!client}, connected=${this.connected}, pureIdentity=${!!this.config.pureIdentity}`);
|
|
1761
1776
|
return;
|
|
1762
1777
|
}
|
|
1763
1778
|
// Let Core and the SDK reuse valid consensus; explicit authorization/bind operations
|
|
1764
1779
|
// own their fresh checks. Material changes invalidate the SDK cache themselves.
|
|
1765
1780
|
const ownership = await ownerResolver.refresh(selfAid, { allowTransient: true, source: 'directory.runtime' });
|
|
1781
|
+
if (this.intentionalDisconnect || this.client !== client || !this.connected)
|
|
1782
|
+
return;
|
|
1766
1783
|
const ownerAid = ownerResolver.owner(selfAid);
|
|
1767
1784
|
logger.info(`${this.logPrefix()} ownerResolver result: selfAid=${selfAid}, ownerAid=${ownerAid || 'undefined'}`);
|
|
1768
1785
|
if (ownership.refreshFailure) {
|
|
@@ -1919,13 +1936,16 @@ export class AUNChannel {
|
|
|
1919
1936
|
// ACK 只回传通知自带的 operation_id;旧版通知不带它,也不等 ACK,不能自造一个回过去。
|
|
1920
1937
|
const operationId = typeof record.data.operation_id === 'string' && record.data.operation_id.trim()
|
|
1921
1938
|
? record.data.operation_id : undefined;
|
|
1939
|
+
// `published.<scope>.updated_at_ms`:远端这一版自己声明的修改时间。
|
|
1940
|
+
// 协调者用它丢弃乱序到达的旧通知,并判断已经拉到的东西够不够新。
|
|
1941
|
+
const published = parseNotificationPublished(record.data);
|
|
1922
1942
|
try {
|
|
1923
1943
|
const runtime = await this.getOwnerDirectoryRuntime();
|
|
1924
1944
|
if (!runtime)
|
|
1925
1945
|
return;
|
|
1926
1946
|
// 记标记。真正的网络拉取在 ACK 之后发起(见方法末尾):先拉会把网络耗时
|
|
1927
1947
|
// 压进 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);
|
|
1948
|
+
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
1949
|
// 重试状态只在发通知的那台设备内存里;拿不到它的设备 ID 就不回,
|
|
1930
1950
|
// 广播给 Owner 全部设备既清不掉重试,又会被其它设备当成会话消息展示。
|
|
1931
1951
|
if (operationId && senderDeviceId) {
|
|
@@ -2312,10 +2332,27 @@ export class AUNChannel {
|
|
|
2312
2332
|
setAidStatsCollector(collector) {
|
|
2313
2333
|
this.aidStatsCollector = collector;
|
|
2314
2334
|
}
|
|
2335
|
+
transportListeners = new Set();
|
|
2336
|
+
onTransportState(listener) {
|
|
2337
|
+
this.transportListeners.add(listener);
|
|
2338
|
+
return () => { this.transportListeners.delete(listener); };
|
|
2339
|
+
}
|
|
2315
2340
|
setAidStatus(status, extra) {
|
|
2341
|
+
const wasReady = this.aidState.status === 'connected';
|
|
2316
2342
|
this.aidState.status = status;
|
|
2317
2343
|
if (extra)
|
|
2318
2344
|
Object.assign(this.aidState, extra);
|
|
2345
|
+
const ready = status === 'connected';
|
|
2346
|
+
if (ready !== wasReady) {
|
|
2347
|
+
for (const listener of this.transportListeners) {
|
|
2348
|
+
try {
|
|
2349
|
+
listener(ready);
|
|
2350
|
+
}
|
|
2351
|
+
catch (error) {
|
|
2352
|
+
logger.warn(`${this.logPrefix()} transport listener failed: ${error}`);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2319
2356
|
}
|
|
2320
2357
|
async connect() {
|
|
2321
2358
|
this.intentionalDisconnect = false;
|
|
@@ -2352,7 +2389,7 @@ export class AUNChannel {
|
|
|
2352
2389
|
this.observerGroupMemberFetches.clear();
|
|
2353
2390
|
// Clean up existing client if any
|
|
2354
2391
|
if (this.client) {
|
|
2355
|
-
|
|
2392
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
2356
2393
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
2357
2394
|
this.trace('OUT', 'client.close', { reason: 'initClient' });
|
|
2358
2395
|
try {
|
|
@@ -2394,7 +2431,7 @@ export class AUNChannel {
|
|
|
2394
2431
|
const localConfig = loadAgent(aidName);
|
|
2395
2432
|
ownerResolver.setAgentConfiguredOwners(aidName, configuredOwnerList(localConfig));
|
|
2396
2433
|
ownerResolver.attachClient(aidName, client);
|
|
2397
|
-
|
|
2434
|
+
registerSameOwnerClient(aidName, client, store);
|
|
2398
2435
|
try {
|
|
2399
2436
|
await this.config.onClientReady?.(client);
|
|
2400
2437
|
}
|
|
@@ -3402,7 +3439,7 @@ export class AUNChannel {
|
|
|
3402
3439
|
// 解析对端身份(30天缓存)
|
|
3403
3440
|
const selfAgentDir = path.join(resolvePaths().agentsDir, this.config.aid);
|
|
3404
3441
|
const peerIdentity = await PeerIdentityCache.resolve('aun', fromAid, selfAgentDir, this.store, false, this.config.keystorePath || resolveRoot());
|
|
3405
|
-
await
|
|
3442
|
+
await prepareSameOwnerProof(this.config.aid, fromAid);
|
|
3406
3443
|
const shortAid = this.getShortAid(fromAid);
|
|
3407
3444
|
const displayName = peerIdentity.name || shortAid;
|
|
3408
3445
|
// 详细 dispatch 决策日志:记录消息为何被路由到 agent
|
|
@@ -4599,6 +4636,7 @@ export class AUNChannel {
|
|
|
4599
4636
|
if (!config)
|
|
4600
4637
|
return undefined;
|
|
4601
4638
|
const lifecycle = resolveAgentLifecycle(config);
|
|
4639
|
+
// Legacy Owner hints are initialization inputs; active Agents need no automatic bind reconciliation.
|
|
4602
4640
|
if (lifecycle === null || lifecycle === 'active')
|
|
4603
4641
|
return undefined;
|
|
4604
4642
|
return firstConfiguredOwner(config);
|
|
@@ -4666,6 +4704,8 @@ export class AUNChannel {
|
|
|
4666
4704
|
return;
|
|
4667
4705
|
// Claim before awaiting submission: an error or lost receipt must not cause automatic resends.
|
|
4668
4706
|
AUNChannel.configuredOwnerBindAttempts.add(attemptKey);
|
|
4707
|
+
logger.info(`${this.logPrefix()} Submitting configured Owner binding invitation: `
|
|
4708
|
+
+ `subject=${subjectAid} owner=${ownerAid} consensus=${current.consensusStatus}`);
|
|
4669
4709
|
await ownerResolver.bind(subjectAid, ownerAid, () => this.isCurrentConfiguredOwnerBind(client, epoch) && this.configuredOwnerAid() === ownerAid
|
|
4670
4710
|
&& !ownerResolver.hasRejectedOwnerBinding(subjectAid, ownerAid));
|
|
4671
4711
|
}
|
|
@@ -4744,7 +4784,7 @@ export class AUNChannel {
|
|
|
4744
4784
|
}
|
|
4745
4785
|
// Force close SDK client,中断它内部的重连循环
|
|
4746
4786
|
if (this.client) {
|
|
4747
|
-
|
|
4787
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4748
4788
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4749
4789
|
this.trace('OUT', 'client.close', { reason: `takeover_${reason}` });
|
|
4750
4790
|
this.client.close().catch(() => { });
|
|
@@ -4771,7 +4811,7 @@ export class AUNChannel {
|
|
|
4771
4811
|
logger.debug(`${this.logPrefix()} TS-layer reconnect (${reason}) succeeded but generation stale, closing stale client`);
|
|
4772
4812
|
this.stopOwnerDirectoryRefresh();
|
|
4773
4813
|
if (this.client) {
|
|
4774
|
-
|
|
4814
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
4775
4815
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
4776
4816
|
this.client.close().catch(() => { });
|
|
4777
4817
|
this.client = null;
|
|
@@ -5294,11 +5334,41 @@ export class AUNChannel {
|
|
|
5294
5334
|
if (decision.allow)
|
|
5295
5335
|
return undefined;
|
|
5296
5336
|
return { status: decision.reason === 'unavailable' ? 'retry' : 'permanent',
|
|
5297
|
-
code: '
|
|
5337
|
+
code: decision.reason === 'unavailable' ? 'CONTACT_DIRECTORY_UNAVAILABLE' : 'CONTACT_DENIED',
|
|
5338
|
+
error: `联系人准入未通过:${decision.reason}` };
|
|
5339
|
+
}
|
|
5340
|
+
async prepareAppContactOutbound(channelId, delivery, payload, params) {
|
|
5341
|
+
if (delivery.chatType === 'private' && !this.config.pureIdentity
|
|
5342
|
+
&& !this.hasContactControlPermit(channelId, payload, params)
|
|
5343
|
+
&& !this.acceptsVerifiedOwnership(channelId, payload, params)) {
|
|
5344
|
+
await ownerResolver.refresh(this.config.aid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5345
|
+
}
|
|
5346
|
+
return this.appContactOutboundBlock(channelId, delivery, payload, params);
|
|
5347
|
+
}
|
|
5348
|
+
/**
|
|
5349
|
+
* A caller that already holds the consensus may skip the refresh round-trip.
|
|
5350
|
+
*
|
|
5351
|
+
* Only lifecycle notices qualify, and only toward their own Owner. Shutdown is
|
|
5352
|
+
* the reason this exists: the offline notice runs while the daemon is tearing
|
|
5353
|
+
* down, so a network refresh would outlive the AUN connection it needs.
|
|
5354
|
+
* Admission itself is unchanged — the block below still demands a live
|
|
5355
|
+
* consensus in the resolver cache, so this skips the check of the cache's
|
|
5356
|
+
* freshness, never the requirement that a consensus exists.
|
|
5357
|
+
*/
|
|
5358
|
+
acceptsVerifiedOwnership(channelId, payload, params) {
|
|
5359
|
+
if (params?.ownershipVerified !== true)
|
|
5360
|
+
return false;
|
|
5361
|
+
const notice = payload;
|
|
5362
|
+
if (!notice || notice.type !== 'notice'
|
|
5363
|
+
|| (notice.subtype !== 'agent.online' && notice.subtype !== 'agent.offline'))
|
|
5364
|
+
return false;
|
|
5365
|
+
// Even if the flag ever leaked, it cannot widen admission: the target must be
|
|
5366
|
+
// the Owner the live consensus names, which admission allows unconditionally.
|
|
5367
|
+
return currentContactBinding(this.config.aid)?.owner_aid === channelId;
|
|
5298
5368
|
}
|
|
5299
5369
|
async sendAunPayload(channelId, payload, context, label) {
|
|
5300
5370
|
const delivery = this.requireDelivery(channelId, context);
|
|
5301
|
-
const blocked = this.
|
|
5371
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, payload);
|
|
5302
5372
|
if (blocked)
|
|
5303
5373
|
return { ok: false, ...blocked };
|
|
5304
5374
|
let normalizedPayload;
|
|
@@ -5809,6 +5879,7 @@ export class AUNChannel {
|
|
|
5809
5879
|
/** An unadmitted outbound text becomes an Owner request, never a send to the peer. */
|
|
5810
5880
|
async requestOutboundContact(args) {
|
|
5811
5881
|
const selfAid = this.config.aid;
|
|
5882
|
+
await ownerResolver.refresh(selfAid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
5812
5883
|
const binding = currentContactBinding(selfAid);
|
|
5813
5884
|
if (!binding) {
|
|
5814
5885
|
return { ok: false, code: 'CONTACT_DIRECTORY_UNAVAILABLE', error: '本端 Owner 关系不可用,未发送申请或原消息' };
|
|
@@ -5891,7 +5962,7 @@ export class AUNChannel {
|
|
|
5891
5962
|
code: 'INVALID_REQUEST_TTL',
|
|
5892
5963
|
};
|
|
5893
5964
|
}
|
|
5894
|
-
const contactBlock = this.
|
|
5965
|
+
const contactBlock = await this.prepareAppContactOutbound(args.to, { chatType: 'private' }, finalPayload, { encrypt: args.encrypt, rawPayload: preserveRawPayload, ownershipVerified: args.ownershipVerified === true });
|
|
5895
5966
|
if (contactBlock)
|
|
5896
5967
|
return { ok: false, code: contactBlock.code, error: contactBlock.error };
|
|
5897
5968
|
if (preserveRawPayload && jsonUtf8Size(finalPayload) > AUN_MAX_PAYLOAD_SIZE) {
|
|
@@ -5911,7 +5982,7 @@ export class AUNChannel {
|
|
|
5911
5982
|
let peerRole = null;
|
|
5912
5983
|
try {
|
|
5913
5984
|
const { resolvePeerRoleDetail } = await import('../config/peer-role-resolver.js');
|
|
5914
|
-
await
|
|
5985
|
+
await prepareSameOwnerProof(this.config.aid, args.to);
|
|
5915
5986
|
peerRole = resolvePeerRoleDetail({
|
|
5916
5987
|
selfAid: this.config.aid,
|
|
5917
5988
|
channelKey: `aun#${this.config.aid}#main`,
|
|
@@ -6039,6 +6110,7 @@ export class AUNChannel {
|
|
|
6039
6110
|
// Preserve the notice verbatim: no session state, topic name or mentions.
|
|
6040
6111
|
rawPayload: true,
|
|
6041
6112
|
ttl,
|
|
6113
|
+
ownershipVerified: args.ownershipVerified,
|
|
6042
6114
|
});
|
|
6043
6115
|
}
|
|
6044
6116
|
/** Public contracts use this AID's existing authenticated storage connection. */
|
|
@@ -6232,7 +6304,7 @@ export class AUNChannel {
|
|
|
6232
6304
|
const delivery = this.requirePersistedDelivery(channelId, entry.delivery);
|
|
6233
6305
|
const context = this.withDelivery(entry.context, delivery);
|
|
6234
6306
|
if (!entry.deliveryReceipt) {
|
|
6235
|
-
const blocked = this.
|
|
6307
|
+
const blocked = await this.prepareAppContactOutbound(channelId, delivery, { type: 'text', text: entry.text });
|
|
6236
6308
|
if (blocked)
|
|
6237
6309
|
return blocked;
|
|
6238
6310
|
}
|
|
@@ -7019,7 +7091,7 @@ export class AUNChannel {
|
|
|
7019
7091
|
}
|
|
7020
7092
|
async deliverImageEntry(entry) {
|
|
7021
7093
|
if (!entry.deliveryReceipt) {
|
|
7022
|
-
const blocked = this.
|
|
7094
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'image' });
|
|
7023
7095
|
if (blocked)
|
|
7024
7096
|
return blocked;
|
|
7025
7097
|
}
|
|
@@ -7070,7 +7142,7 @@ export class AUNChannel {
|
|
|
7070
7142
|
}
|
|
7071
7143
|
async deliverFileEntry(entry) {
|
|
7072
7144
|
if (!entry.deliveryReceipt) {
|
|
7073
|
-
const blocked = this.
|
|
7145
|
+
const blocked = await this.prepareAppContactOutbound(entry.channelId, this.requirePersistedDelivery(entry.channelId, entry.delivery), { type: 'file' });
|
|
7074
7146
|
if (blocked)
|
|
7075
7147
|
return blocked;
|
|
7076
7148
|
}
|
|
@@ -7451,8 +7523,8 @@ export class AUNChannel {
|
|
|
7451
7523
|
async sendCustomPayload(channelId, payload, context) {
|
|
7452
7524
|
// Validate the route even when disconnected; callers must never be able
|
|
7453
7525
|
// to bypass the fail-closed AUN routing contract. This compatibility API
|
|
7454
|
-
// is
|
|
7455
|
-
//
|
|
7526
|
+
// is best-effort while offline except for Menu responses, whose callers
|
|
7527
|
+
// must receive the failure to retry or report the delivery outcome.
|
|
7456
7528
|
const delivery = this.requireDelivery(channelId, context);
|
|
7457
7529
|
context = this.withDelivery(context, delivery);
|
|
7458
7530
|
// SDK 0.3.0 E2EE requires payload to be an object
|
|
@@ -7472,6 +7544,11 @@ export class AUNChannel {
|
|
|
7472
7544
|
return;
|
|
7473
7545
|
}
|
|
7474
7546
|
if (!this.connected || !this.client) {
|
|
7547
|
+
if (payloadObj.type === 'menu.response') {
|
|
7548
|
+
throw Object.assign(new Error('AUN channel is not connected'), {
|
|
7549
|
+
name: 'AUNSendError', code: 'AUN_NOT_CONNECTED', retryable: true,
|
|
7550
|
+
});
|
|
7551
|
+
}
|
|
7475
7552
|
logger.debug(`${this.logPrefix()} Custom payload skipped while disconnected: channel=${channelId}`);
|
|
7476
7553
|
return;
|
|
7477
7554
|
}
|
|
@@ -7484,10 +7561,9 @@ export class AUNChannel {
|
|
|
7484
7561
|
* 传入预算时到点就往下走,不再等 SDK。
|
|
7485
7562
|
*/
|
|
7486
7563
|
async disconnect(clientCloseBudgetMs) {
|
|
7487
|
-
this.
|
|
7488
|
-
this.configuredOwnerBindEpoch++;
|
|
7564
|
+
this.prepareShutdown();
|
|
7489
7565
|
if (this.client) {
|
|
7490
|
-
|
|
7566
|
+
unregisterSameOwnerClient(this.config.aid, this.client);
|
|
7491
7567
|
ownerResolver.detachClient(this.config.aid, this.client);
|
|
7492
7568
|
}
|
|
7493
7569
|
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,8 +24,9 @@ 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
|
+
import { initializationRuntimePlan } from '../config/providers-config.js';
|
|
29
30
|
/** Select the creation lifecycle independently of --non-interactive. */
|
|
30
31
|
export function resolveAgentCreateMode(args) {
|
|
31
32
|
if (args.includes('--initialize') && args.includes('--bootstrap')) {
|
|
@@ -970,6 +971,12 @@ export function readInitialization(aid) {
|
|
|
970
971
|
if (fingerprint !== record.fingerprint)
|
|
971
972
|
throw new InitializationStateError('fingerprint_mismatch');
|
|
972
973
|
}
|
|
974
|
+
try {
|
|
975
|
+
initializationRuntimePlan(record);
|
|
976
|
+
}
|
|
977
|
+
catch {
|
|
978
|
+
throw new InitializationStateError('invalid_record');
|
|
979
|
+
}
|
|
973
980
|
return record;
|
|
974
981
|
}
|
|
975
982
|
export function saveInitialization(record) {
|
|
@@ -1251,13 +1258,15 @@ export class AgentInitializationService {
|
|
|
1251
1258
|
usable: complete && this.deps.usable(aid), initialization: summary,
|
|
1252
1259
|
};
|
|
1253
1260
|
}
|
|
1254
|
-
start(plan, actor, dryRun = false) {
|
|
1261
|
+
start(plan, actor, dryRun = false, providerMigration) {
|
|
1255
1262
|
if (this.deps.authorize && !this.deps.authorize(actor))
|
|
1256
1263
|
failure('NOT_ALLOWED');
|
|
1257
|
-
validateInitializationPlan(plan);
|
|
1258
1264
|
plan = JSON.parse(JSON.stringify(plan));
|
|
1259
|
-
|
|
1265
|
+
assertAgentAidAvailable(plan.aid);
|
|
1260
1266
|
const existing = readInitialization(plan.aid);
|
|
1267
|
+
if (!existing)
|
|
1268
|
+
validateInitializationPlan(initializationRuntimePlan({ plan, providerMigration }));
|
|
1269
|
+
const fingerprint = initializationFingerprint(plan);
|
|
1261
1270
|
if (existing) {
|
|
1262
1271
|
if (recordMode(existing) !== 'supplied' || existing.actor !== actor || existing.fingerprint !== fingerprint)
|
|
1263
1272
|
failure('INITIALIZE_PLAN_CONFLICT');
|
|
@@ -1276,6 +1285,7 @@ export class AgentInitializationService {
|
|
|
1276
1285
|
}
|
|
1277
1286
|
const r = {
|
|
1278
1287
|
version: 1, operationId: `init-${randomBytes(12).toString('hex')}`, actor, plan, fingerprint,
|
|
1288
|
+
...(providerMigration ? { providerMigration } : {}),
|
|
1279
1289
|
status: 'in_progress', phase: 'planned', startedAt: Date.now(), updatedAt: Date.now(),
|
|
1280
1290
|
};
|
|
1281
1291
|
const claim = claimAgentCreation({
|
|
@@ -1434,7 +1444,7 @@ export class AgentInitializationService {
|
|
|
1434
1444
|
if (r.status === 'cancelled')
|
|
1435
1445
|
failure('INITIALIZE_CANCELLED');
|
|
1436
1446
|
if (r.status !== 'complete' && !this.running.has(aid)) {
|
|
1437
|
-
validateInitializationPlan(r
|
|
1447
|
+
validateInitializationPlan(initializationRuntimePlan(r));
|
|
1438
1448
|
r.status = 'in_progress';
|
|
1439
1449
|
if (r.bindAttempt?.state === 'unknown') {
|
|
1440
1450
|
// A prior local diagnostic (for example TARGET_CHANGED after a
|
|
@@ -1594,7 +1604,9 @@ export class AgentInitializationService {
|
|
|
1594
1604
|
}
|
|
1595
1605
|
// Omitted fields use the existing defaults/migration selection, just as
|
|
1596
1606
|
// they do on initial creation. Only explicit plan overrides are frozen.
|
|
1597
|
-
if (config && r.plan.provider !== undefined
|
|
1607
|
+
if (config && r.plan.provider !== undefined
|
|
1608
|
+
&& (typeof baseagentConfig?.provider !== 'string'
|
|
1609
|
+
|| resolveProviderId(baseagentConfig.provider) !== resolveProviderId(initializationRuntimePlan(r).provider)))
|
|
1598
1610
|
failure('INITIALIZE_TARGET_CHANGED');
|
|
1599
1611
|
if (config && r.plan.chatmode !== undefined
|
|
1600
1612
|
&& ['private', 'group', 'nothuman'].some(scope => config.chatmode?.[scope] !== r.plan.chatmode?.[scope])) {
|
|
@@ -1747,7 +1759,7 @@ export class AgentInitializationService {
|
|
|
1747
1759
|
return true;
|
|
1748
1760
|
}
|
|
1749
1761
|
async run(r) {
|
|
1750
|
-
const p = r
|
|
1762
|
+
const p = initializationRuntimePlan(r);
|
|
1751
1763
|
// Resume from the durable checkpoint. In particular, never call aidCreate
|
|
1752
1764
|
// again after the bind/activation stages have created the local config.
|
|
1753
1765
|
if (!r.configSaved) {
|
|
@@ -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 格式
|
|
@@ -1768,9 +1770,10 @@ Commands:
|
|
|
1768
1770
|
online <from> <target-aid> [<target-aid>...] 查询在线状态
|
|
1769
1771
|
history <from> [<target-aid>|selector] [筛选选项] 查询本地消息历史
|
|
1770
1772
|
|
|
1771
|
-
托管会话简化语法(EVOLCORE_SESSION_ID
|
|
1773
|
+
托管会话简化语法(EVOLCORE_SESSION_ID 已设时;正式回复请用 ecmsg send):
|
|
1772
1774
|
send <text> --thread <id> from/to 从运行时上下文与话题索引自动推断
|
|
1773
1775
|
send <text> 发送到当前会话对端
|
|
1776
|
+
ecmsg send '<text>' [--thread <id>|--to <对端ID>] 统一入口,跨话题自动建复查
|
|
1774
1777
|
|
|
1775
1778
|
Options:
|
|
1776
1779
|
--text-from-file <path> 从文件读取文本(UTF-8),用于超长消息或避免 Shell 转义
|
|
@@ -2582,6 +2585,7 @@ visitor 不开放历史;群权限仍由托管会话校验。`);
|
|
|
2582
2585
|
send <from> <group-id> <text> 发送群文本
|
|
2583
2586
|
send <from> <group-id> --file <path> [--as <type>] 发送群文件
|
|
2584
2587
|
send <from> <group-id> --payload <json> 发送自定义 payload
|
|
2588
|
+
(托管会话发消息统一用 ecmsg send '<text>' --to <群ID>,见 ecmsg --help)
|
|
2585
2589
|
pull <from> <group-id> [--after-seq N] [--limit N] --app <name> 拉取群消息(必须使用独立 slot)
|
|
2586
2590
|
ack <from> <group-id> <seq> [--app <name>] 确认已读
|
|
2587
2591
|
history <from> <group-id> [options] 查询本地群消息历史(只读)
|
|
@@ -3633,14 +3637,20 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3633
3637
|
const booleans = new Set();
|
|
3634
3638
|
const text = [];
|
|
3635
3639
|
const mentions = [];
|
|
3636
|
-
const valueFlags = new Set(
|
|
3637
|
-
const booleanFlags = new Set(
|
|
3640
|
+
const valueFlags = new Set(MANAGED_SEND_VALUE_FLAGS);
|
|
3641
|
+
const booleanFlags = new Set(MANAGED_SEND_BOOLEAN_FLAGS);
|
|
3638
3642
|
for (let index = bodyStart; index < argv.length; index++) {
|
|
3639
3643
|
const flag = argv[index];
|
|
3640
3644
|
if (flag === '--') {
|
|
3641
3645
|
text.push(...argv.slice(index + 1));
|
|
3642
3646
|
break;
|
|
3643
3647
|
}
|
|
3648
|
+
// `--to` / `--from` 是网关选项,托管发送用位置参数表达 from/to。它们不在
|
|
3649
|
+
// 取值表里,落到下面就会进 text —— 正文会变成「--to x.agentid.cn 你好」,
|
|
3650
|
+
// 消息照常送达,于是没人发现发错了。这里明确拒绝,让调用方改写法。
|
|
3651
|
+
if (flag === '--to' || flag === '--from') {
|
|
3652
|
+
throw new Error(`${flag} is not supported by managed send; use positional from/to, or \`ecmsg send --to <aid>\``);
|
|
3653
|
+
}
|
|
3644
3654
|
if (flag === '--app' || flag === '--aun-path')
|
|
3645
3655
|
throw new Error(`${flag} is not allowed for managed sends`);
|
|
3646
3656
|
if (booleanFlags.has(flag))
|
|
@@ -3704,7 +3714,12 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3704
3714
|
const to = scope === 'group'
|
|
3705
3715
|
? normalizeGroupAid(argv[3], aid.slice(aid.indexOf('.') + 1))
|
|
3706
3716
|
: hasTo ? argv[3] : inferredTarget;
|
|
3707
|
-
if (!to
|
|
3717
|
+
if (!to)
|
|
3718
|
+
throw new Error('Invalid send target');
|
|
3719
|
+
// 目标形态:普通发送必须是合法 AID。但 `--thread` 指向的目标会话可能属于
|
|
3720
|
+
// 其它渠道(如飞书),那条会话的 `peer` 是原生 ID(`ou_…`),不是 AID。
|
|
3721
|
+
// 此时由话题索引保证目标正确,不再按 AID 校验。
|
|
3722
|
+
if (!thread && !validSendAid(to))
|
|
3708
3723
|
throw new Error('Invalid send target');
|
|
3709
3724
|
const checkEvery = values.get('--check-every');
|
|
3710
3725
|
const triggerPromptExtra = values.get('--trigger-prompt');
|