evolcore 0.0.43-test.6 → 0.0.43-test.7
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 +48 -0
- package/bin/ecmsg.js +171 -54
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +234 -21
- package/dist/cli/agent-create.js +2 -2
- package/dist/cli/daemon-commands.js +6 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/restart-monitor.js +45 -47
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +6 -1
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +104 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +4 -3
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +53 -11
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +338 -0
- package/dist/core/command/menu-catalog.js +8 -0
- package/dist/core/command/menu-handler.js +198 -84
- package/dist/core/command/menu-protocol.js +60 -11
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +8 -5
- package/dist/core/daemon-lifecycle.js +132 -73
- package/dist/core/handoff/runtime.js +3 -3
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +46 -7
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +147 -17
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/response-engine.js +157 -54
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +43 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/permission/ec-command-parser.js +3 -2
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +2 -3
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +114 -0
- package/dist/event-center/bus-gate.js +136 -0
- package/dist/event-center/bus-host.js +290 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +100 -0
- package/dist/event-center/client-factory.js +50 -0
- package/dist/event-center/daemon.js +45 -0
- package/dist/event-center/directory-source.js +53 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +63 -0
- package/dist/event-center/ipc-operation.js +308 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +202 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +238 -0
- package/dist/event-center/runtime.js +641 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +35 -0
- package/dist/event-center/validation.js +413 -0
- package/dist/index.js +285 -99
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +458 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +204 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +95 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +7 -14
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -0
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +207 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +3 -2
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +15 -3
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +277 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +0 -5
- package/kits/templates/system-fragments/thread.md +10 -8
- package/package.json +3 -5
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { initializationBlocksTasks } from '../../cli/agent-create.js';
|
|
2
|
-
import { assertOwnershipAuthorization, getDaemonOwners, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
2
|
+
import { assertOwnershipAuthorization, getDaemonOwners, refreshOwnershipForAuthorization, resolveContextOwner, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import os from 'os';
|
|
@@ -46,9 +46,13 @@ import { buildEnvelope, isInteractionSendAccepted, isNoopText, replyContextFromS
|
|
|
46
46
|
import { chatModeForScene, isSystemOrServicePeer, resolveChatMode } from './peer-mode.js';
|
|
47
47
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
48
48
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
49
|
-
import { isValidAid } from '../../aun/aid/identity.js';
|
|
50
49
|
// Re-export 工具函数(向后兼容,让其他模块可以从 response-engine 导入)
|
|
51
50
|
export { buildEnvelope, sendInteractionPayload } from './message-utils.js';
|
|
51
|
+
/**
|
|
52
|
+
* 上一次告警过的 owner 来源不一致组合(self:protocol:directory)。
|
|
53
|
+
* 一致性的检查每轮都做,但日志只在组合变化时报一次,避免每个 turn 刷屏。
|
|
54
|
+
*/
|
|
55
|
+
let lastReportedOwnerSourceMismatch;
|
|
52
56
|
import { constrainResolvedModelForRole, isModelAllowedForRoleBaseagent } from '../model/model-permission.js';
|
|
53
57
|
import { eligibleFallbackModels } from '../model/model-fallback.js';
|
|
54
58
|
import { isRecoverableProtocolFailure, RetryScheduler } from './retry-scheduler.js';
|
|
@@ -1294,6 +1298,18 @@ function stripContextLimitErrorLines(text) {
|
|
|
1294
1298
|
.filter(line => !isStandaloneContextLimitErrorLine(line))
|
|
1295
1299
|
.join('\n');
|
|
1296
1300
|
}
|
|
1301
|
+
const GATEWAY_EMPTY_MESSAGE_PLACEHOLDER = '[System: Empty message content sanitised to satisfy protocol]';
|
|
1302
|
+
function isGatewayEmptyMessagePlaceholder(text) {
|
|
1303
|
+
return text.trim() === GATEWAY_EMPTY_MESSAGE_PLACEHOLDER;
|
|
1304
|
+
}
|
|
1305
|
+
export function filterGatewayEmptyMessageEvent(event) {
|
|
1306
|
+
if (event.type === 'text' && isGatewayEmptyMessagePlaceholder(event.text))
|
|
1307
|
+
return undefined;
|
|
1308
|
+
if (event.type === 'complete' && typeof event.result === 'string' && isGatewayEmptyMessagePlaceholder(event.result)) {
|
|
1309
|
+
return { ...event, result: '' };
|
|
1310
|
+
}
|
|
1311
|
+
return event;
|
|
1312
|
+
}
|
|
1297
1313
|
const SHELL_CONTROL_RE = /[;&|`]|[$][(]|\r|\n/;
|
|
1298
1314
|
function isCtlQueueReadCommand(toolName, input) {
|
|
1299
1315
|
if (toolName !== 'Bash' && toolName !== 'Shell')
|
|
@@ -1411,6 +1427,8 @@ export class ResponseEngine {
|
|
|
1411
1427
|
triggerTerminalMessages = new WeakSet();
|
|
1412
1428
|
fullAccessTerminalMessages = new WeakSet();
|
|
1413
1429
|
agentDelegationRegistry;
|
|
1430
|
+
/** 能力清单查询;未注入时两个变量恒为 false(无包 = 无该段)。 */
|
|
1431
|
+
capabilityIndexes;
|
|
1414
1432
|
turnCoordinator;
|
|
1415
1433
|
/** 响应模式协调器(插件化机制中枢)。内置模式在构造时注册。 */
|
|
1416
1434
|
responseCoordinator;
|
|
@@ -1473,6 +1491,31 @@ export class ResponseEngine {
|
|
|
1473
1491
|
}
|
|
1474
1492
|
throw new BaseagentRunnerUnavailableError('<unknown>', requestedBaseagent || '<missing>', []);
|
|
1475
1493
|
}
|
|
1494
|
+
async ensureAgent(channel, baseagent, selfAID) {
|
|
1495
|
+
const aid = channel === 'daemon' && selfAID === this.daemonTriggerOwnerAid
|
|
1496
|
+
? this.primaryRunnerKey.slice(0, this.primaryRunnerKey.lastIndexOf('::'))
|
|
1497
|
+
: selfAID || this.agentRegistry?.resolveByChannel(channel)?.aid;
|
|
1498
|
+
if (aid)
|
|
1499
|
+
await this.runnerReadiness?.(aid, baseagent);
|
|
1500
|
+
return this.getAgent(channel, baseagent, selfAID);
|
|
1501
|
+
}
|
|
1502
|
+
runnerWaiters = new Map();
|
|
1503
|
+
/** An interrupt releases the task even if a shared backend load is still queued. */
|
|
1504
|
+
async ensureSessionAgent(session, channel, selfAID) {
|
|
1505
|
+
const waiters = this.runnerWaiters.get(session.id) ?? new Set();
|
|
1506
|
+
this.runnerWaiters.set(session.id, waiters);
|
|
1507
|
+
let cancel;
|
|
1508
|
+
const interrupted = new Promise(resolve => { cancel = () => resolve(undefined); });
|
|
1509
|
+
waiters.add(cancel);
|
|
1510
|
+
try {
|
|
1511
|
+
return await Promise.race([this.ensureAgent(channel, session.baseagent, selfAID), interrupted]);
|
|
1512
|
+
}
|
|
1513
|
+
finally {
|
|
1514
|
+
waiters.delete(cancel);
|
|
1515
|
+
if (!waiters.size)
|
|
1516
|
+
this.runnerWaiters.delete(session.id);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1476
1519
|
getTextInferenceProvider(channel, baseagent, selfAID) {
|
|
1477
1520
|
if (!baseagent)
|
|
1478
1521
|
return undefined;
|
|
@@ -1524,7 +1567,6 @@ export class ResponseEngine {
|
|
|
1524
1567
|
? (session.metadata?.groupId || channelId)
|
|
1525
1568
|
: (session.metadata?.peerId || channelId);
|
|
1526
1569
|
const peerKey = channelType && peerKeyId ? formatPeerKey(channelType, peerKeyId) : undefined;
|
|
1527
|
-
const agent = this.agentRegistry?.resolveByChannel(channelKey);
|
|
1528
1570
|
return resolveChatMode({
|
|
1529
1571
|
self: self || undefined,
|
|
1530
1572
|
peerKey,
|
|
@@ -1532,8 +1574,6 @@ export class ResponseEngine {
|
|
|
1532
1574
|
chatType: session.chatType,
|
|
1533
1575
|
peerType,
|
|
1534
1576
|
channelType,
|
|
1535
|
-
lifecycle: agent ? resolveAgentLifecycle(agent.config) : undefined,
|
|
1536
|
-
sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main',
|
|
1537
1577
|
});
|
|
1538
1578
|
}
|
|
1539
1579
|
catch {
|
|
@@ -1561,7 +1601,7 @@ export class ResponseEngine {
|
|
|
1561
1601
|
this.commandHandler = commandHandler;
|
|
1562
1602
|
this.turnCoordinator = new SessionTurnCoordinator(sessionManager);
|
|
1563
1603
|
sessionManager.setCapsuleTranscriptReader?.(async (session) => {
|
|
1564
|
-
const runner = this.
|
|
1604
|
+
const runner = await this.ensureAgent(session.channel, session.baseagent, session.selfAID);
|
|
1565
1605
|
return await runner.getSessionMessages?.(session.agentSessionId, session.projectPath) ?? [];
|
|
1566
1606
|
});
|
|
1567
1607
|
if (agentRunnerOrMap instanceof Map) {
|
|
@@ -1680,12 +1720,21 @@ export class ResponseEngine {
|
|
|
1680
1720
|
for (const { adapter } of this.channels.values())
|
|
1681
1721
|
this.restoreAsyncQuestions(adapter);
|
|
1682
1722
|
}
|
|
1723
|
+
/**
|
|
1724
|
+
* 注入能力清单查询(ECK 的 hasServicePacks / hasEventPacks)。
|
|
1725
|
+
*
|
|
1726
|
+
* 必须只读内存状态、不做 IO:渲染是热路径(每条入站消息一次),
|
|
1727
|
+
* 扫目录会让延迟不可控。两个运行时在启动/热重载时已把包集合挂在内存里。
|
|
1728
|
+
*/
|
|
1729
|
+
setCapabilityIndexes(provider) {
|
|
1730
|
+
this.capabilityIndexes = provider;
|
|
1731
|
+
}
|
|
1683
1732
|
setMessageQueue(queue) {
|
|
1684
1733
|
this.messageQueue = queue;
|
|
1685
1734
|
this.taskRecoveryService = new TaskRecoveryService({
|
|
1686
1735
|
sessions: this.sessionManager,
|
|
1687
1736
|
queue,
|
|
1688
|
-
getRunner: (session) => this.
|
|
1737
|
+
getRunner: (session) => this.ensureAgent(session.metadata?.channelKey || session.channel, session.baseagent, session.selfAID),
|
|
1689
1738
|
resumePause: (sessionId) => this.resumeSession(sessionId),
|
|
1690
1739
|
hasChannel: (session) => !!this.resolveChannelInfo(session.metadata?.channelKey || session.channel),
|
|
1691
1740
|
});
|
|
@@ -1940,7 +1989,7 @@ export class ResponseEngine {
|
|
|
1940
1989
|
})).allow;
|
|
1941
1990
|
}
|
|
1942
1991
|
async submitAsyncQuestionAnswer(record, session, answer) {
|
|
1943
|
-
const runner = this.
|
|
1992
|
+
const runner = await this.ensureAgent(record.origin.channel, 'codex', record.selfAid);
|
|
1944
1993
|
if (!runner.steerAsyncQuestionAnswer)
|
|
1945
1994
|
throw new Error('Codex async input is unavailable');
|
|
1946
1995
|
if (await runner.steerAsyncQuestionAnswer(session.id, answer) === 'accepted')
|
|
@@ -1986,8 +2035,15 @@ export class ResponseEngine {
|
|
|
1986
2035
|
|| active.interactions.some(item => !item.settlement)
|
|
1987
2036
|
|| this.isPauseRequested(sessionId) || this.retryDelayWaiters.has(sessionId))
|
|
1988
2037
|
return { state: 'live', ...identity };
|
|
1989
|
-
|
|
1990
|
-
|
|
2038
|
+
let runner;
|
|
2039
|
+
try {
|
|
2040
|
+
runner = this.getAgent(session.metadata?.channelKey || session.channel, session.baseagent, selfAid);
|
|
2041
|
+
}
|
|
2042
|
+
catch (error) {
|
|
2043
|
+
if (!(error instanceof BaseagentRunnerUnavailableError))
|
|
2044
|
+
throw error;
|
|
2045
|
+
}
|
|
2046
|
+
const owned = runner?.hasActiveOperation?.(sessionId, active.taskId) ?? runner?.hasActiveStream(sessionId) ?? false;
|
|
1991
2047
|
return { state: owned ? 'live' : 'missing', ...identity,
|
|
1992
2048
|
hasTerminalOwner: this.activeTimeoutHandlers.has(sessionId) };
|
|
1993
2049
|
}
|
|
@@ -2049,9 +2105,18 @@ export class ResponseEngine {
|
|
|
2049
2105
|
this.interruptedSessions.set(sessionId, effectiveReason);
|
|
2050
2106
|
this.messageQueue?.markActiveTerminal?.(sessionId, effectiveReason);
|
|
2051
2107
|
const channelKey = session.metadata?.channelKey || session.channel;
|
|
2052
|
-
|
|
2108
|
+
// An interrupted task may still be waiting for on-demand initialization.
|
|
2109
|
+
// Commit its terminal state without starting a backend just to stop it.
|
|
2110
|
+
let agent;
|
|
2111
|
+
try {
|
|
2112
|
+
agent = this.getAgent(channelKey, session.baseagent, session.selfAID);
|
|
2113
|
+
}
|
|
2114
|
+
catch (error) {
|
|
2115
|
+
if (!(error instanceof BaseagentRunnerUnavailableError))
|
|
2116
|
+
throw error;
|
|
2117
|
+
}
|
|
2053
2118
|
const cancelledQueuedTurn = interruptedTurn?.active
|
|
2054
|
-
? agent
|
|
2119
|
+
? agent?.cancelQueuedTurn?.(sessionId, {
|
|
2055
2120
|
taskId: interruptedTurn.active.taskId,
|
|
2056
2121
|
generation: interruptedTurn.active.generation,
|
|
2057
2122
|
}) ?? false
|
|
@@ -2063,6 +2128,9 @@ export class ResponseEngine {
|
|
|
2063
2128
|
const taskId = (await this.turnCoordinator.completeInterrupt(session, effectiveReason, recoverable))
|
|
2064
2129
|
?? interruptedTaskId
|
|
2065
2130
|
?? taskSpan?.taskId;
|
|
2131
|
+
// Release first-use waits only after the interrupt is durable.
|
|
2132
|
+
for (const cancel of this.runnerWaiters?.get(sessionId) ?? [])
|
|
2133
|
+
cancel();
|
|
2066
2134
|
if (taskId) {
|
|
2067
2135
|
const taskCausation = taskSpan?.causation ?? runtimeContext?.causation;
|
|
2068
2136
|
if (taskCausation && effectiveReason === 'daemon_restart') {
|
|
@@ -2100,7 +2168,7 @@ export class ResponseEngine {
|
|
|
2100
2168
|
sessionId: session.id,
|
|
2101
2169
|
channel: channelInfo.adapter.channelName,
|
|
2102
2170
|
channelId: session.channelId,
|
|
2103
|
-
agentName: agent.
|
|
2171
|
+
agentName: agent?.name ?? session.baseagent,
|
|
2104
2172
|
chatmode: this.resolveEffectiveChatmodeForSession(session, channelKey, session.channelId),
|
|
2105
2173
|
replyContext: {
|
|
2106
2174
|
...replyContextFromSession(session),
|
|
@@ -2118,7 +2186,7 @@ export class ResponseEngine {
|
|
|
2118
2186
|
})();
|
|
2119
2187
|
const runnerInterrupt = (cancelledQueuedTurn || !interruptTarget
|
|
2120
2188
|
? Promise.resolve()
|
|
2121
|
-
: agent
|
|
2189
|
+
: agent?.interrupt(sessionId, interruptTarget) ?? Promise.resolve()).catch(error => {
|
|
2122
2190
|
logger.debug(`[ResponseEngine] interrupt barrier runner failure: session=${sessionId} error=${error instanceof Error ? error.message : String(error)}`);
|
|
2123
2191
|
if (strict)
|
|
2124
2192
|
throw error;
|
|
@@ -3165,9 +3233,12 @@ export class ResponseEngine {
|
|
|
3165
3233
|
const runnerSelfAid = this.agentRegistry?.resolveByChannel(channelKey)?.aid
|
|
3166
3234
|
|| session.selfAID
|
|
3167
3235
|
|| message.selfAID;
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3236
|
+
const loaded = await this.ensureSessionAgent(session, channelKey, runnerSelfAid);
|
|
3237
|
+
if (!loaded) {
|
|
3238
|
+
this.publishTriggerExecutionSkipped(message, 'interrupted_before_runner_ready');
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
agent = loaded;
|
|
3171
3242
|
}
|
|
3172
3243
|
catch (error) {
|
|
3173
3244
|
if (error instanceof BaseagentRunnerUnavailableError) {
|
|
@@ -3570,9 +3641,12 @@ export class ResponseEngine {
|
|
|
3570
3641
|
let agent;
|
|
3571
3642
|
let turnLease;
|
|
3572
3643
|
try {
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3644
|
+
const loaded = await this.ensureSessionAgent(session, channelKey, runnerSelfAid);
|
|
3645
|
+
if (!loaded) {
|
|
3646
|
+
this.publishTriggerExecutionSkipped(message, 'interrupted_before_runner_ready');
|
|
3647
|
+
return;
|
|
3648
|
+
}
|
|
3649
|
+
agent = loaded;
|
|
3576
3650
|
}
|
|
3577
3651
|
catch (error) {
|
|
3578
3652
|
if (error instanceof BaseagentRunnerUnavailableError) {
|
|
@@ -3748,13 +3822,6 @@ export class ResponseEngine {
|
|
|
3748
3822
|
// trigger override 绝对优先;否则由 Coordinator 解析(responseMode 标量 > 注册表首选)。
|
|
3749
3823
|
const systemOrServicePeer = isSystemOrServicePeer(peerType);
|
|
3750
3824
|
const triggerChatModeOverride = systemOrServicePeer ? undefined : message.triggerMeta?.chatModeOverride;
|
|
3751
|
-
const previousTurn = this.turnCoordinator.current(session);
|
|
3752
|
-
const recoveryChatMode = (message.taskRecovery || message.restartResume?.submitted)
|
|
3753
|
-
? (previousTurn.active ?? previousTurn.lastTerminal)?.recoveryContext?.chatmode
|
|
3754
|
-
: undefined;
|
|
3755
|
-
// Preserve PA's explicit-reply contract across recovery. The existing
|
|
3756
|
-
// interactive/proactive recovery and override rules remain authoritative.
|
|
3757
|
-
const taskChatModeOverride = recoveryChatMode === 'paactive' ? recoveryChatMode : triggerChatModeOverride;
|
|
3758
3825
|
// chatmode 是顶层字典(agent 级与关系级同名,已由 ConfigManager 逐键合并)。
|
|
3759
3826
|
// 实际生效值由对端类型选键(private/nothuman/group),出厂默认走 schema。
|
|
3760
3827
|
const chatModeFallback = resolveChatMode({
|
|
@@ -3764,8 +3831,6 @@ export class ResponseEngine {
|
|
|
3764
3831
|
chatType,
|
|
3765
3832
|
peerType,
|
|
3766
3833
|
channelType: currentChannelType,
|
|
3767
|
-
lifecycle,
|
|
3768
|
-
sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main',
|
|
3769
3834
|
});
|
|
3770
3835
|
// Resolve overrides before binding a flow so hooks, context and envelope
|
|
3771
3836
|
// all use the same scene-checked mode for this task.
|
|
@@ -3773,13 +3838,13 @@ export class ResponseEngine {
|
|
|
3773
3838
|
? 'proactive'
|
|
3774
3839
|
: systemOrServicePeer
|
|
3775
3840
|
? 'interactive'
|
|
3776
|
-
:
|
|
3777
|
-
? chatModeForScene(
|
|
3841
|
+
: triggerChatModeOverride
|
|
3842
|
+
? chatModeForScene(triggerChatModeOverride, { channelType: currentChannelType, chatType, peerType, role: peerRole })
|
|
3778
3843
|
: chatModeFallback;
|
|
3779
3844
|
const responseModeAgentDir = selfAid ? resolveAgentDir(selfAid) : undefined;
|
|
3780
3845
|
// mentionMode:顶层通用参数(先读出备用,投递/入队策略后续接入)
|
|
3781
3846
|
const mentionMode = effectiveAgentConfig?.mentionMode ?? 'disabled';
|
|
3782
|
-
const resolvedMode =
|
|
3847
|
+
const resolvedMode = triggerChatModeOverride
|
|
3783
3848
|
|| systemOrServicePeer || !responseModeAgentDir
|
|
3784
3849
|
? null
|
|
3785
3850
|
: this.responseCoordinator.resolveMode(effectiveAgentConfig?.responseMode, // 标量:关系级>agent级>注册表首选
|
|
@@ -3814,6 +3879,24 @@ export class ResponseEngine {
|
|
|
3814
3879
|
// chatMode 由 resolveChatModeForPeer 按配置层级解析(步骤 1/4)。
|
|
3815
3880
|
const chatmode = effectiveChatMode;
|
|
3816
3881
|
const isProactive = effectiveChatMode === 'proactive';
|
|
3882
|
+
// Use the same PA identity fact for transport and ECK. Snapshot once per
|
|
3883
|
+
// task so an identity refresh cannot switch protocols halfway through it.
|
|
3884
|
+
const directoryIdentity = selfAid
|
|
3885
|
+
? readOwnerDirectoryIdentity(path.join(resolveRoot(), 'agents', selfAid, 'directory'))
|
|
3886
|
+
: EMPTY_IDENTITY;
|
|
3887
|
+
const contextOwner = resolveContextOwner(selfAid, directoryIdentity.owner?.aid);
|
|
3888
|
+
const activityTransport = isProactive
|
|
3889
|
+
&& currentChannelType === 'aun'
|
|
3890
|
+
&& chatType === 'private'
|
|
3891
|
+
&& peerType === 'human'
|
|
3892
|
+
&& peerRole === 'owner'
|
|
3893
|
+
&& lifecycle === 'active'
|
|
3894
|
+
&& (session.sessionType ?? session.metadata?.sessionType ?? 'main') === 'main'
|
|
3895
|
+
&& directoryIdentity.personalAssistant?.aid === selfAid
|
|
3896
|
+
&& !!contextOwner.ownerAid
|
|
3897
|
+
&& contextOwner.ownerAid === message.channelId
|
|
3898
|
+
&& directoryIdentity.owner?.aid === contextOwner.ownerAid
|
|
3899
|
+
? 'message' : undefined;
|
|
3817
3900
|
const legacyMiddleOutputMode = () => {
|
|
3818
3901
|
const mode = policy.middleOutputMode?.(chatType, identityRole, peerType);
|
|
3819
3902
|
if (isShowActivitiesMode(mode))
|
|
@@ -3910,6 +3993,7 @@ export class ResponseEngine {
|
|
|
3910
3993
|
channelId: message.channelId,
|
|
3911
3994
|
agentName: agentNameForStats,
|
|
3912
3995
|
chatmode: effectiveChatMode,
|
|
3996
|
+
activityTransport,
|
|
3913
3997
|
replyContext: taskReplyContext(),
|
|
3914
3998
|
causation: taskCausation,
|
|
3915
3999
|
});
|
|
@@ -4244,7 +4328,6 @@ export class ResponseEngine {
|
|
|
4244
4328
|
? aunMessageTranscriptUuid(sourceMessageId)
|
|
4245
4329
|
: undefined;
|
|
4246
4330
|
turnLease = await this.turnCoordinator.begin(session, taskId, inputId, configActorId ? {
|
|
4247
|
-
...(effectiveChatMode === 'paactive' ? { chatmode: effectiveChatMode } : {}),
|
|
4248
4331
|
peerId: configActorId,
|
|
4249
4332
|
approvalInteractionPolicy,
|
|
4250
4333
|
encrypted: message.encrypted ?? message.replyContext?.metadata?.encrypted,
|
|
@@ -5291,14 +5374,21 @@ export class ResponseEngine {
|
|
|
5291
5374
|
const memoryMode = session.metadata?.memoryMode;
|
|
5292
5375
|
// Kit renderer: 组装上下文
|
|
5293
5376
|
const pkgRoot = getPackageRoot();
|
|
5294
|
-
// 名录身份(Owner / 个人助理)来自渲染产物旁的小文件,只读一次、只取四个字段:
|
|
5295
|
-
// 每轮都要算,不能去解析 contacts.json。读不出时是空身份,下面的 isPersonalAssistant
|
|
5296
|
-
// / isOwner 随之双双为 false——宁可不注入 PA 段,也不能让非 PA 拿到 PA 的行为约束。
|
|
5297
|
-
const directoryIdentity = selfAid
|
|
5298
|
-
? readOwnerDirectoryIdentity(path.join(resolveRoot(), 'agents', selfAid, 'directory'))
|
|
5299
|
-
: EMPTY_IDENTITY;
|
|
5300
5377
|
const personalAssistantAid = directoryIdentity.personalAssistant?.aid;
|
|
5301
5378
|
const identityOwnerAid = directoryIdentity.owner?.aid;
|
|
5379
|
+
// Owner 只有一个来源:归属协议共识,与记忆写入/整理(ipc.ts 的 memory.create /
|
|
5380
|
+
// memory.consolidate)走同一个解析。名录快照里的 owner 是网络缓存,可能滞后于
|
|
5381
|
+
// 协议绑定变更;若拿它拼 owner-memory 路径,就会写进一处、读的时候去另一处找。
|
|
5382
|
+
// 快照身份在这里只与协议 owner 交叉核对,不一致时按组合变化告警一次。
|
|
5383
|
+
const protocolOwnerAid = contextOwner.ownerAid;
|
|
5384
|
+
if (contextOwner.mismatch) {
|
|
5385
|
+
const mismatchKey = `${selfAid}:${contextOwner.mismatch.protocolOwnerAid}:${contextOwner.mismatch.directoryOwnerAid}`;
|
|
5386
|
+
if (mismatchKey !== lastReportedOwnerSourceMismatch) {
|
|
5387
|
+
lastReportedOwnerSourceMismatch = mismatchKey;
|
|
5388
|
+
logger.warn(`[ResponseEngine] owner 来源不一致 self=${selfAid} protocol=${contextOwner.mismatch.protocolOwnerAid} directory=${contextOwner.mismatch.directoryOwnerAid};`
|
|
5389
|
+
+ '上下文注入与记忆写入一律按归属协议取 owner,请检查名录快照是否过期');
|
|
5390
|
+
}
|
|
5391
|
+
}
|
|
5302
5392
|
const kitCtx = {
|
|
5303
5393
|
vars: {
|
|
5304
5394
|
EVOLCORE_HOME: resolveRoot(),
|
|
@@ -5326,22 +5416,18 @@ export class ResponseEngine {
|
|
|
5326
5416
|
RELATIONS_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid, 'relations') : undefined,
|
|
5327
5417
|
VENUES_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid, 'venues') : undefined,
|
|
5328
5418
|
selfAid: selfAid || undefined,
|
|
5329
|
-
//
|
|
5330
|
-
//
|
|
5331
|
-
ownerAid:
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
if (!raw)
|
|
5336
|
-
return undefined;
|
|
5337
|
-
return isValidAid(raw) ? raw : undefined;
|
|
5338
|
-
})(),
|
|
5339
|
-
ownerName: directoryIdentity.owner?.name || undefined,
|
|
5419
|
+
// 与记忆写入/整理同源:owner-memory 段注入的路径必须和写入落盘的路径一致。
|
|
5420
|
+
// 名录快照不再是 owner 的来源,只在确认是同一个人时提供展示用名字。
|
|
5421
|
+
ownerAid: protocolOwnerAid,
|
|
5422
|
+
ownerName: protocolOwnerAid && protocolOwnerAid === identityOwnerAid
|
|
5423
|
+
? directoryIdentity.owner?.name || undefined
|
|
5424
|
+
: undefined,
|
|
5340
5425
|
personalAssistantAid,
|
|
5341
5426
|
personalAssistantName: directoryIdentity.personalAssistant?.name || undefined,
|
|
5342
5427
|
// 两个角色布尔**即时比较**,不从文件读:落盘的布尔会过期,也挡不住手改文件伪造。
|
|
5428
|
+
// isOwner 与 ownerAid 同源(归属协议),避免名录快照滞后时把自封 Owner 的角色注入进去。
|
|
5343
5429
|
isPersonalAssistant: !!personalAssistantAid && personalAssistantAid === selfAid,
|
|
5344
|
-
isOwner: !!
|
|
5430
|
+
isOwner: !!protocolOwnerAid && protocolOwnerAid === selfAid,
|
|
5345
5431
|
// 准入现状压成一句话:只列能联系谁,说不通的档位直接不提。
|
|
5346
5432
|
// 只说"能",不说"谁关的"——默认关与显式关在结果上没区别。
|
|
5347
5433
|
...(() => {
|
|
@@ -5372,6 +5458,17 @@ export class ResponseEngine {
|
|
|
5372
5458
|
lifecycle,
|
|
5373
5459
|
isBootstrapping,
|
|
5374
5460
|
hasPersona: !!persona,
|
|
5461
|
+
// 能力清单:没有包时恒 false,manifest 对应 section 整段不注入。
|
|
5462
|
+
...(() => {
|
|
5463
|
+
if (!selfAid || !this.capabilityIndexes)
|
|
5464
|
+
return { hasServicePacks: false, hasEventPacks: false };
|
|
5465
|
+
try {
|
|
5466
|
+
return this.capabilityIndexes(selfAid);
|
|
5467
|
+
}
|
|
5468
|
+
catch {
|
|
5469
|
+
return { hasServicePacks: false, hasEventPacks: false };
|
|
5470
|
+
}
|
|
5471
|
+
})(),
|
|
5375
5472
|
peerId: peerIdRaw || undefined,
|
|
5376
5473
|
// 与任务上下文同源:系统会话取目标关系,否则 peer-profile / relation 索引会按 bg: 伪对端注入
|
|
5377
5474
|
peerKey: systemSessionContext?.peerKey ?? peerKey,
|
|
@@ -5420,7 +5517,7 @@ export class ResponseEngine {
|
|
|
5420
5517
|
sessionKey: session.sessionKey,
|
|
5421
5518
|
chatMode: effectiveChatMode,
|
|
5422
5519
|
// Message templates receive the same derived reply fact as system templates.
|
|
5423
|
-
activePush:
|
|
5520
|
+
activePush: isProactive,
|
|
5424
5521
|
isTriggerTask: causationPath.length > 0 || message.source === 'trigger',
|
|
5425
5522
|
readonly: effectivePermissionMode === 'readonly',
|
|
5426
5523
|
baseAgent: normalizedBaseagent.canonical,
|
|
@@ -5436,7 +5533,7 @@ export class ResponseEngine {
|
|
|
5436
5533
|
},
|
|
5437
5534
|
sessionId: session.id,
|
|
5438
5535
|
};
|
|
5439
|
-
if (
|
|
5536
|
+
if (isProactive) {
|
|
5440
5537
|
Object.assign(kitCtx.vars, {
|
|
5441
5538
|
// Proactive policy variables are scoped to proactive tasks only.
|
|
5442
5539
|
proactivePreTool1stMsgChk: proactive?.preTool1stMsgChk ?? false,
|
|
@@ -7168,7 +7265,9 @@ export class ResponseEngine {
|
|
|
7168
7265
|
await adapter.send(withEnvelopeReplyContext(envelope, sendOpts), errorPayload);
|
|
7169
7266
|
}
|
|
7170
7267
|
// Proactive 可观测:catch 块的基础设施错误也透传为 thought,保证按 task_id 聚合完整
|
|
7171
|
-
if (isProactive
|
|
7268
|
+
if (isProactive
|
|
7269
|
+
&& adapter.capabilities?.thought
|
|
7270
|
+
&& middleOutputMode === 'all') {
|
|
7172
7271
|
await adapter.send(withEnvelopeReplyContext(envelope, sendOpts), {
|
|
7173
7272
|
kind: 'activity.batch',
|
|
7174
7273
|
items: [{
|
|
@@ -7647,6 +7746,10 @@ export class ResponseEngine {
|
|
|
7647
7746
|
if (event.type === 'complete') {
|
|
7648
7747
|
event = normalizeCompleteAgentEvent(event);
|
|
7649
7748
|
}
|
|
7749
|
+
const filteredEvent = filterGatewayEmptyMessageEvent(event);
|
|
7750
|
+
if (!filteredEvent)
|
|
7751
|
+
continue;
|
|
7752
|
+
event = filteredEvent;
|
|
7650
7753
|
if (event.type === 'tool_result' && isToolResultFailure(event)) {
|
|
7651
7754
|
const classification = normalizeToolErrorClassification(event);
|
|
7652
7755
|
event = {
|
|
@@ -29,10 +29,13 @@ export const GATEWAY_ROUTE_VALUE_FLAGS = [
|
|
|
29
29
|
];
|
|
30
30
|
/** 只有网关认识、`ec msg send` 不认识的选项。 */
|
|
31
31
|
export const GATEWAY_ONLY_VALUE_FLAGS = ['--to', '--from'];
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
/**
|
|
33
|
+
* 网关的别名映射。
|
|
34
|
+
*
|
|
35
|
+
* 曾把 `--self` 映射到 `--from`。现在 `ecmsg send` 只用 `--from` 表达本端,
|
|
36
|
+
* 不再接受 `--self`(其它命令的 `--self` 不过这个网关,不受影响)。
|
|
37
|
+
*/
|
|
38
|
+
export const GATEWAY_FLAG_ALIASES = {};
|
|
36
39
|
/** 下游允许的选项总数,用于漂移自检。 */
|
|
37
40
|
export const MANAGED_SEND_KNOWN_FLAGS = [
|
|
38
41
|
...MANAGED_SEND_VALUE_FLAGS,
|
|
@@ -176,6 +176,11 @@ export function resolveSendRoute(input, session, deps = {}) {
|
|
|
176
176
|
if (!targetId) {
|
|
177
177
|
return fail('INVALID_ARGUMENT', '--to 不能为空', '省略 --to 表示发给当前会话对端');
|
|
178
178
|
}
|
|
179
|
+
// `--to <本端AID>` 只在给出 `--thread` 时有意义:话题是投递落点的唯一依据。
|
|
180
|
+
// 不带话题时它会走下面「跨对端」的分支,拼出 `main:<self>:<self>` 这种自反主话题。
|
|
181
|
+
if (normalizeTopicAid(targetId).toLowerCase() === self.toLowerCase()) {
|
|
182
|
+
return fail('INVALID_ARGUMENT', '--to 是本端自己时必须同时指定 --thread(话题决定投递落点)', `投给自己请写:--thread <话题id> --to ${self}`);
|
|
183
|
+
}
|
|
179
184
|
const resolvedPeer = deps.resolveTarget?.(targetId) ?? {
|
|
180
185
|
channelType: session.channelType,
|
|
181
186
|
peerKind: session.chatType,
|
|
@@ -209,7 +214,8 @@ export function resolveSendRoute(input, session, deps = {}) {
|
|
|
209
214
|
threadId = currentThread;
|
|
210
215
|
source = { peer: 'session', thread: 'session' };
|
|
211
216
|
}
|
|
212
|
-
// 3. --thread 与 --to
|
|
217
|
+
// 3. --thread 与 --to 同时给出:对端一致 → peer;本端自己 → self;其它 → 冲突
|
|
218
|
+
let recipient = 'peer';
|
|
213
219
|
if (input.thread !== undefined && input.to !== undefined) {
|
|
214
220
|
const targetId = String(input.to ?? '').trim();
|
|
215
221
|
const explicitPeer = deps.resolveTarget?.(targetId) ?? {
|
|
@@ -217,10 +223,23 @@ export function resolveSendRoute(input, session, deps = {}) {
|
|
|
217
223
|
peerKind: session.chatType,
|
|
218
224
|
id: targetId,
|
|
219
225
|
};
|
|
220
|
-
if (
|
|
221
|
-
|
|
226
|
+
if (sameRoutePeer(explicitPeer, peer, deps)) {
|
|
227
|
+
recipient = 'peer';
|
|
228
|
+
}
|
|
229
|
+
else if (normalizeTopicAid(targetId).toLowerCase() === self.toLowerCase()) {
|
|
230
|
+
// 话题内投给自己:话题仍属于 (self, peer),只是收件人是本端。
|
|
231
|
+
recipient = 'self';
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return fail('TOPIC_CONFLICT', `--thread 指向 ${peer.id},--to 指向 ${explicitPeer.id},两者冲突`, '--to 只能是话题对端或本端自己;一次发送只能有一个目标');
|
|
222
235
|
}
|
|
223
236
|
}
|
|
237
|
+
// 自发只适用于私聊话题:群投递的位置参数恒为群 AID,`--to 本端` 会被当成
|
|
238
|
+
// 发群消息,收件人与回执对不上,还会把本应给自己的内容发进群。
|
|
239
|
+
if (recipient === 'self' && peer.peerKind === 'group') {
|
|
240
|
+
return fail('INVALID_ARGUMENT', '群话题不支持发给自己', '群消息的收件人恒为群;自发只用于私聊话题(--thread <私聊话题> --to <本端AID>)');
|
|
241
|
+
}
|
|
242
|
+
const recipientId = recipient === 'self' ? self : peer.id;
|
|
224
243
|
// 4. 跨话题判定
|
|
225
244
|
const crossTopic = !sameRoutePeer(peer, currentPeer, deps) || threadId !== currentThread;
|
|
226
245
|
// 5. 复查周期
|
|
@@ -260,13 +279,25 @@ export function resolveSendRoute(input, session, deps = {}) {
|
|
|
260
279
|
if (peer.channelType !== 'aun' && encrypt === 'yes') {
|
|
261
280
|
return fail('ENCRYPT_UNSUPPORTED', `目标对端 ${peer.id} 不在 AUN 网络上(channel=${peer.channelType}),无法端到端加密`, '去掉 --encrypt 或改用 --encrypt no');
|
|
262
281
|
}
|
|
282
|
+
// auto 的取值:
|
|
283
|
+
// - 自发(recipient='self'):跟随话题 T 上一条消息的加密态(D4)。自发不是
|
|
284
|
+
// 被对端触发的,`inboundEncrypted` 描述的是当前会话而非话题 T,不能拿来用。
|
|
285
|
+
// - 其余:本轮被入站消息触发就沿用该消息,否则明文。
|
|
286
|
+
let lastTopicEncrypted;
|
|
287
|
+
if (recipient === 'self' && encrypt === 'auto') {
|
|
288
|
+
lastTopicEncrypted = deps.resolveLastTopicEncrypt?.(threadId);
|
|
289
|
+
}
|
|
263
290
|
const encryptResolved = encrypt === 'auto' && peer.channelType === 'aun'
|
|
264
|
-
?
|
|
291
|
+
? recipient === 'self'
|
|
292
|
+
? lastTopicEncrypted === true
|
|
293
|
+
: (input.inboundTriggered === true ? input.inboundEncrypted === true : false)
|
|
265
294
|
: encrypt === 'yes';
|
|
266
295
|
return {
|
|
267
296
|
ok: true,
|
|
268
297
|
self,
|
|
269
298
|
peer,
|
|
299
|
+
recipient,
|
|
300
|
+
recipientId,
|
|
270
301
|
threadId,
|
|
271
302
|
crossTopic,
|
|
272
303
|
firstContact,
|
|
@@ -308,13 +339,20 @@ function sourceLabel(source, field) {
|
|
|
308
339
|
*
|
|
309
340
|
* 格式:`from=<self> to=<id>(<来源>) thread=<threadId>(<来源>) chatType=<kind>`
|
|
310
341
|
* 推断补全的值标来源,全部为归一化后的实际生效值,不是输入原文。
|
|
342
|
+
*
|
|
343
|
+
* 自发(`recipient === 'self'`)时 `to` 回显本端 AID 并附 `recipient=self`,
|
|
344
|
+
* 让调用方一眼看出这不是发给对端的。话题仍按对端所属话题回显。
|
|
311
345
|
*/
|
|
312
346
|
export function formatRouteReceipt(route) {
|
|
313
347
|
const threadLabel = route.threadId ? route.threadId : 'main';
|
|
348
|
+
const target = route.recipient === 'self'
|
|
349
|
+
? `to=${route.recipientId}(自发)`
|
|
350
|
+
: `to=${route.peer.id}(${sourceLabel(route.source, 'peer')})`;
|
|
314
351
|
return [
|
|
315
352
|
`from=${route.self}`,
|
|
316
|
-
|
|
353
|
+
target,
|
|
317
354
|
`thread=${threadLabel}(${sourceLabel(route.source, 'thread')})`,
|
|
318
355
|
`chatType=${route.peer.peerKind}`,
|
|
356
|
+
...(route.recipient === 'self' ? ['recipient=self'] : []),
|
|
319
357
|
].join(' ');
|
|
320
358
|
}
|
|
@@ -1697,6 +1697,13 @@ export const getProtocolOwners = (subjectAid) => ownerResolver.protocolOwners(su
|
|
|
1697
1697
|
export const getOwners = (subjectAid) => ownerResolver.owners(subjectAid);
|
|
1698
1698
|
export const getConfiguredOwners = (subjectAid) => ownerResolver.configuredOwnerList(subjectAid);
|
|
1699
1699
|
export const getDaemonOwners = () => ownerResolver.daemonOwners();
|
|
1700
|
+
export function resolveContextOwner(selfAid, directoryOwnerAid) {
|
|
1701
|
+
const ownerAid = selfAid ? getProtocolOwner(selfAid) : undefined;
|
|
1702
|
+
if (ownerAid && directoryOwnerAid && ownerAid !== directoryOwnerAid) {
|
|
1703
|
+
return { ownerAid, mismatch: { protocolOwnerAid: ownerAid, directoryOwnerAid } };
|
|
1704
|
+
}
|
|
1705
|
+
return { ownerAid };
|
|
1706
|
+
}
|
|
1700
1707
|
export async function refreshOwnershipForAuthorization(subjectAid, options = {}) {
|
|
1701
1708
|
const daemonAid = ownerResolver.getDaemonAid();
|
|
1702
1709
|
const ownershipSubjectAid = daemonAid && subjectAid === `${daemonAid}#daemon` ? daemonAid : subjectAid;
|
|
@@ -386,11 +386,11 @@ const APPLY_PATCH_EXECUTABLE_BASENAMES = new Set([
|
|
|
386
386
|
'apply_patch.ps1',
|
|
387
387
|
]);
|
|
388
388
|
const EVOLCORE_SUBCOMMANDS = new Set([
|
|
389
|
-
'ability', 'agent', 'aid', 'bench', 'config', 'peer', 'ctl', 'data', 'diag', 'diagnose',
|
|
389
|
+
'ability', 'agent', 'aid', 'bench', 'config', 'events', 'peer', 'ctl', 'data', 'diag', 'diagnose',
|
|
390
390
|
'fs', 'gateway', 'group', 'init', 'link-rules', 'logs', 'menu-client',
|
|
391
391
|
'mode', 'model', 'msg', 'mv', 'net', 'queue', 'response', 'restart',
|
|
392
392
|
'restart-monitor', 'rpc', 'start', 'stats', 'status', 'stop', 'storage', 'task',
|
|
393
|
-
'trigger', 'proxy', 'version', 'watch', 'session', '
|
|
393
|
+
'trigger', 'proxy', 'version', 'watch', 'session', 'team', 'upgrade', 'update',
|
|
394
394
|
]);
|
|
395
395
|
// Development/install entrypoints that are part of this repository's CLI.
|
|
396
396
|
// Only these exact relative paths are canonicalized; arbitrary Node scripts
|
|
@@ -3388,6 +3388,7 @@ export function containsLiteralManagedTmpDirOutsideSendContent(argv) {
|
|
|
3388
3388
|
const READ_ONLY_SUBCOMMANDS = new Set([
|
|
3389
3389
|
'thread.list', 'thread.show', 'thread.history', 'thread.peers',
|
|
3390
3390
|
'thread.summary', 'msg.history', 'msg.online', 'trigger.list', 'trigger.show',
|
|
3391
|
+
'events.status', 'events.ledger', 'events.tail', 'events.doctor', 'events.allowlist:show',
|
|
3391
3392
|
'directory.list', 'directory.info', 'aid.show', 'aid.list', 'aid.lookup',
|
|
3392
3393
|
'peer.list', 'help', 'status',
|
|
3393
3394
|
]);
|
|
@@ -49,6 +49,8 @@ const L_CLASS_RELATIVE_PATTERNS = [
|
|
|
49
49
|
/^backups\/config(?:\/|$)/,
|
|
50
50
|
/^agents\/[^/]+\/triggers(?:\/|$)/,
|
|
51
51
|
/^agents\/[^/]+\/roles(?:\/|$)/,
|
|
52
|
+
/^agents\/[^/]+\/events(?:\/|$)/,
|
|
53
|
+
/^agents\/[^/]+\/services(?:\/|$)/,
|
|
52
54
|
];
|
|
53
55
|
const L_CLASS_REFERENCE_PATTERNS = [
|
|
54
56
|
/(?:^|[^A-Za-z0-9_.-])daemon\.json(?=$|[^A-Za-z0-9_.-])/,
|
|
@@ -56,6 +58,8 @@ const L_CLASS_REFERENCE_PATTERNS = [
|
|
|
56
58
|
/(?:^|[^A-Za-z0-9_.-])backups[\\/]config(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
57
59
|
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]triggers(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
58
60
|
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]roles(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
61
|
+
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]events(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
62
|
+
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]services(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
59
63
|
];
|
|
60
64
|
function normalizeForComparison(value) {
|
|
61
65
|
const resolved = path.resolve(value);
|
|
@@ -438,6 +442,10 @@ export function getLClassWritePatterns(root = resolveRoot()) {
|
|
|
438
442
|
return [
|
|
439
443
|
path.join(absoluteRoot, 'agents', '*', 'triggers'),
|
|
440
444
|
path.join(absoluteRoot, 'agents', '*', 'triggers') + '/**',
|
|
445
|
+
path.join(absoluteRoot, 'agents', '*', 'events'),
|
|
446
|
+
path.join(absoluteRoot, 'agents', '*', 'events') + '/**',
|
|
447
|
+
path.join(absoluteRoot, 'agents', '*', 'services'),
|
|
448
|
+
path.join(absoluteRoot, 'agents', '*', 'services') + '/**',
|
|
441
449
|
path.join(absoluteRoot, 'agents', '*', 'roles') + '/**',
|
|
442
450
|
];
|
|
443
451
|
}
|
|
@@ -606,7 +614,7 @@ export function getExistingLClassReadOnlyTargets(root = resolveRoot(), options =
|
|
|
606
614
|
}
|
|
607
615
|
const ownRoot = path.join(agentsDir, selfAid);
|
|
608
616
|
for (const relative of [
|
|
609
|
-
'config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers',
|
|
617
|
+
'config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services',
|
|
610
618
|
])
|
|
611
619
|
addExistingTarget(targets, path.join(ownRoot, relative));
|
|
612
620
|
try {
|
|
@@ -625,6 +633,8 @@ export function getExistingLClassReadOnlyTargets(root = resolveRoot(), options =
|
|
|
625
633
|
if (!entry.isDirectory())
|
|
626
634
|
continue;
|
|
627
635
|
addExistingTarget(targets, path.join(agentsDir, entry.name, 'triggers'));
|
|
636
|
+
addExistingTarget(targets, path.join(agentsDir, entry.name, 'events'));
|
|
637
|
+
addExistingTarget(targets, path.join(agentsDir, entry.name, 'services'));
|
|
628
638
|
addExistingTarget(targets, path.join(agentsDir, entry.name, 'roles'));
|
|
629
639
|
}
|
|
630
640
|
}
|
|
@@ -1017,7 +1027,7 @@ export function lClassGrantIncludesProtectedPath(value, options = {}) {
|
|
|
1017
1027
|
// relations/<peer> 本身时才覆盖它,更深的路径(如 relations/<peer>/memory/…)不会。
|
|
1018
1028
|
if (segments[2] === 'relations')
|
|
1019
1029
|
return segments.length <= 4;
|
|
1020
|
-
return ['config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers']
|
|
1030
|
+
return ['config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services']
|
|
1021
1031
|
.includes(segments[2]);
|
|
1022
1032
|
}
|
|
1023
1033
|
return false;
|