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
|
@@ -147,8 +147,12 @@ export class DelegationDiagnostics {
|
|
|
147
147
|
return 'session_mismatch';
|
|
148
148
|
if (credential.kind === 'task')
|
|
149
149
|
return this.taskCause(credential);
|
|
150
|
-
const
|
|
151
|
-
const
|
|
150
|
+
const candidate = commandHash ? this.find('approval', tokenHash, sessionId, commandHash) : undefined;
|
|
151
|
+
const approval = candidate?.taskId === credential.taskId
|
|
152
|
+
&& candidate?.activeTokenHash === credential.activeTokenHash
|
|
153
|
+
&& candidate?.runtimeEpoch === credential.runtimeEpoch
|
|
154
|
+
? candidate : undefined;
|
|
155
|
+
const activeTokenHash = credential.activeTokenHash;
|
|
152
156
|
const task = activeTokenHash
|
|
153
157
|
? this.find('task', activeTokenHash, sessionId)
|
|
154
158
|
: undefined;
|
|
@@ -522,7 +522,9 @@ function authorizeCatalogPolicy(ctx, meta) {
|
|
|
522
522
|
if (!policy)
|
|
523
523
|
return undefined;
|
|
524
524
|
if (policy.authority === 'daemon-owner') {
|
|
525
|
-
|
|
525
|
+
const delegatedRead = policy.allowDelegatedRead === true && ctx.source === 'agent-tool'
|
|
526
|
+
&& meta.category === 'read' && !meta.dangerous;
|
|
527
|
+
return scope === policy.scope && policy.channel === 'control' && (ctx.fromControlChannel || delegatedRead)
|
|
526
528
|
&& hasDaemonOwnerRole(ctx) && ctx.processRole !== 'daemon-service'
|
|
527
529
|
? allow('daemon-owner', 'catalog-daemon-owner')
|
|
528
530
|
: deny('This operation requires DaemonOwner process control');
|
|
@@ -144,14 +144,16 @@ const QUEUE_OPERATIONS = [['read', 'Read the current Agent message queue'], ['cl
|
|
|
144
144
|
*
|
|
145
145
|
* 参照设计文档 docs/command-execution-role-permission-design.md 第 5 节
|
|
146
146
|
*/
|
|
147
|
-
const PROVIDER_OPERATIONS = ['list', 'show', 'create', 'import', 'update', 'delete'].map(action => ({
|
|
147
|
+
const PROVIDER_OPERATIONS = ['list', 'show', 'create', 'import', 'update', 'delete', 'sync'].map(action => ({
|
|
148
148
|
id: 'provider.' + action,
|
|
149
149
|
category: action === 'list' || action === 'show' ? 'read' : 'process',
|
|
150
150
|
dangerous: action !== 'list' && action !== 'show',
|
|
151
151
|
defaultScopes: ['process'],
|
|
152
152
|
description: 'Manage the daemon Provider registry: ' + action,
|
|
153
|
-
sources:
|
|
154
|
-
|
|
153
|
+
sources: action === 'sync' ? ['control']
|
|
154
|
+
: action === 'list' || action === 'show' ? ['menu', 'control', 'ecweb', 'agent-tool'] : ['menu', 'control', 'ecweb'],
|
|
155
|
+
authorizationPolicy: { authority: 'daemon-owner', scope: 'process', channel: 'control',
|
|
156
|
+
allowDelegatedRead: action === 'list' || action === 'show' },
|
|
155
157
|
}));
|
|
156
158
|
const OPERATIONS = [
|
|
157
159
|
...['read', 'result-read', 'install', 'configure', 'enable', 'disable', 'invoke', 'publish', 'upgrade', 'rollback', 'uninstall', 'grant', 'retire'].map(action => ({
|
|
@@ -1264,7 +1266,7 @@ const OPERATIONS = [
|
|
|
1264
1266
|
{
|
|
1265
1267
|
id: 'ec.aid.bind', category: 'write-agent', dangerous: true, defaultScopes: ['agent'],
|
|
1266
1268
|
minimumPermissionMode: 'request',
|
|
1267
|
-
description: 'Request or decide a protocol Owner binding
|
|
1269
|
+
description: 'Request or decide a protocol Owner binding, or reset its local automatic-invitation rejection', sources: ['agent-tool', 'menu.cli'],
|
|
1268
1270
|
},
|
|
1269
1271
|
{
|
|
1270
1272
|
id: 'ec.aid.transfer', category: 'write-agent', dangerous: true, defaultScopes: ['agent'],
|
|
@@ -256,7 +256,8 @@ function parseAidCommand(argv, source, defaultSelfAid) {
|
|
|
256
256
|
...(subjectAid ? { self: subjectAid } : {}),
|
|
257
257
|
...(command.subjectAid ? { subjectAid: command.subjectAid } : {}),
|
|
258
258
|
...(command.action === 'status' && command.refresh ? { refresh: true } : {}),
|
|
259
|
-
...(command.action === 'bind' ? { ownerAid: command.ownerAid } : {}),
|
|
259
|
+
...(command.action === 'bind' || command.action === 'reset-rejection' ? { ownerAid: command.ownerAid } : {}),
|
|
260
|
+
...(command.action === 'reset-rejection' ? { action: command.action } : {}),
|
|
260
261
|
...(command.action === 'transfer' ? { subAid: command.subAid, newOwnerAid: command.newOwnerAid } : {}),
|
|
261
262
|
...(command.action === 'accept' || command.action === 'reject'
|
|
262
263
|
? { decision: command.action, operationId: command.operationId } : {}),
|
|
@@ -8,7 +8,7 @@ import { renderCommandCardAsText } from '../interaction-router.js';
|
|
|
8
8
|
import { buildEnvelope, deliveryTargetFromSession, isInteractionSendAccepted, replyContextFromSession, sendInteractionPayload } from '../message/message-utils.js';
|
|
9
9
|
import { sessionTopicThreadId } from '../thread/topic-id.js';
|
|
10
10
|
import { resolvePaths, getPackageRoot, resolveRoot } from '../../paths.js';
|
|
11
|
-
import { loadDaemonConfig } from '../../config-store.js';
|
|
11
|
+
import { loadAgent, loadDaemonConfig } from '../../config-store.js';
|
|
12
12
|
import { parseOwnershipCommand, executeOwnershipCommand, ownershipFailure } from '../../aun/aid/ownership-operation.js';
|
|
13
13
|
import { ownerResolver, refreshOwnershipForAuthorization } from '../ownership/owner-resolver.js';
|
|
14
14
|
import { logger } from '../../utils/logger.js';
|
|
@@ -356,15 +356,17 @@ export class CommandHandler {
|
|
|
356
356
|
getTriggerSchedulerForAgent(agentAid) {
|
|
357
357
|
return this.triggerSchedulerResolver?.(agentAid) ?? (this.triggerSchedulerFallbackAid === agentAid ? this.triggerSchedulerFallback : undefined);
|
|
358
358
|
}
|
|
359
|
-
assertSessionLoopTrigger(session) {
|
|
359
|
+
assertSessionLoopTrigger(session, once = false) {
|
|
360
360
|
const daemonAid = this.getDaemonTriggerOwnerAid();
|
|
361
361
|
const schedulers = new Set([
|
|
362
362
|
this.getTriggerSchedulerForAgent(session.selfAID ?? ''),
|
|
363
363
|
daemonAid ? this.getTriggerSchedulerForAgent(daemonAid) : undefined,
|
|
364
364
|
]);
|
|
365
365
|
const triggers = [...schedulers].flatMap(scheduler => scheduler?.list({ all: true }) ?? [])
|
|
366
|
-
.filter(definition =>
|
|
367
|
-
|
|
366
|
+
.filter(definition => once
|
|
367
|
+
? definition.id === '__session-idle-check' && isDaemonEventSessionTrigger(definition)
|
|
368
|
+
: definition.id === '__session-idle-check'
|
|
369
|
+
|| (definition.source.type === 'event' && definition.source.eventPattern === 'session:idle'));
|
|
368
370
|
if (triggers.length === 0) {
|
|
369
371
|
throw sessionLoopError('LOOP_TRIGGER_NOT_FOUND', '未找到 session:idle Trigger,无法开启 loop');
|
|
370
372
|
}
|
|
@@ -2060,7 +2062,9 @@ export class CommandHandler {
|
|
|
2060
2062
|
const command = parseOwnershipCommand(argv);
|
|
2061
2063
|
const targetAid = command.subjectAid ?? grant.selfAid;
|
|
2062
2064
|
const fullAccess = hasTrustedFullAccessDelegation(grant);
|
|
2063
|
-
|
|
2065
|
+
if (command.action !== 'reset-rejection' || !loadAgent(targetAid)) {
|
|
2066
|
+
ownerResolver.assertLocalSubject(targetAid);
|
|
2067
|
+
}
|
|
2064
2068
|
if (command.action === 'status') {
|
|
2065
2069
|
return { ok: true, state: await executeOwnershipCommand(command, grant.selfAid) };
|
|
2066
2070
|
}
|
|
@@ -2096,7 +2100,8 @@ export class CommandHandler {
|
|
|
2096
2100
|
args: {
|
|
2097
2101
|
self: targetAid,
|
|
2098
2102
|
targetAgentAid: targetAid,
|
|
2099
|
-
...(command.action === 'bind' ? { ownerAid: command.ownerAid } : {}),
|
|
2103
|
+
...(command.action === 'bind' || command.action === 'reset-rejection' ? { ownerAid: command.ownerAid } : {}),
|
|
2104
|
+
...(command.action === 'reset-rejection' ? { action: command.action } : {}),
|
|
2100
2105
|
...(command.action === 'transfer' ? { subAid: command.subAid, newOwnerAid: command.newOwnerAid } : {}),
|
|
2101
2106
|
...(command.action === 'accept' || command.action === 'reject'
|
|
2102
2107
|
? { decision: command.action, operationId: command.operationId } : {}),
|
|
@@ -241,8 +241,10 @@ export function isAunMenuTokenRequired() {
|
|
|
241
241
|
}
|
|
242
242
|
export function evolMenuResponseTransportMetadata(sdkVersion, volatileCapability) {
|
|
243
243
|
return {
|
|
244
|
-
//
|
|
245
|
-
|
|
244
|
+
// Menu/control responses are consumed through the SDK classified-control
|
|
245
|
+
// path, which requires an authenticated E2EE envelope to recover the
|
|
246
|
+
// sender from AAD. Do not inherit a plaintext/default transport choice.
|
|
247
|
+
encrypted: true,
|
|
246
248
|
protectedHeaders: {
|
|
247
249
|
ec_version: readInstalledEvolcoreVersion(),
|
|
248
250
|
...(typeof sdkVersion === 'string' && sdkVersion.trim() ? { sdk_version: sdkVersion.trim() } : {}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createProvider, parseProviderImport, readProvidersSnapshot, updateProvider } from '../../config/providers-management.js';
|
|
2
2
|
import { parseProviderObject, providerFailure } from '../../config/provider-ipc-service.js';
|
|
3
|
+
import { resolveProviderId } from '../../config/providers-config.js';
|
|
3
4
|
import { validateProviderMenuRequest } from '../../config/provider-menu-request.js';
|
|
4
5
|
import { authorizeFreshOperation } from '../auth/auth-gateway.js';
|
|
5
6
|
export async function executeProviderMenu(request, subject, source) {
|
|
@@ -28,8 +29,9 @@ export async function executeProviderMenu(request, subject, source) {
|
|
|
28
29
|
const snapshot = readProvidersSnapshot();
|
|
29
30
|
if (operation === 'list')
|
|
30
31
|
return { data: snapshot };
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const providerId = resolveProviderId(args.providerId, snapshot);
|
|
33
|
+
const provider = snapshot.providers[providerId];
|
|
34
|
+
return provider ? { data: { providerId, provider, revision: snapshot.revision } }
|
|
33
35
|
: { error: 'Provider not found', code: 'NOT_FOUND' };
|
|
34
36
|
}
|
|
35
37
|
if (operation === 'create' || operation === 'import') {
|
|
@@ -5,7 +5,7 @@ import { ConfigTarget, read, resolveEffectiveWithSources, write } from '../../co
|
|
|
5
5
|
import { getBuiltinRolesConfig, getRoleDefinition, isValidUserRoleName, readRolesConfig, } from '../../config/roles.js';
|
|
6
6
|
import { BUILTIN_USER_ROLES, MANAGEMENT_ROLES, expectedRoleRank, isManagementRole } from '../../config/builtin-roles.js';
|
|
7
7
|
import { checkRoleAccess, isStaticAgentOwner, resolvePeerRoleDetail } from '../../config/peer-role-resolver.js';
|
|
8
|
-
import {
|
|
8
|
+
import { prepareSameOwnerProof } from '../relation/same-owner-proof.js';
|
|
9
9
|
import { relationFieldWriteOperation, resolveRoleFieldPermission, } from '../../config/config-field-policy.js';
|
|
10
10
|
import { evaluateRoleOperationCapability } from '../auth/operation-authorizer.js';
|
|
11
11
|
import { listOperations } from '../auth/operation-catalog.js';
|
|
@@ -824,7 +824,7 @@ async function targetSnapshot(context, args, policyRevision) {
|
|
|
824
824
|
? normalized
|
|
825
825
|
: await validateTargetExists(context, normalized, { allowAuthenticatedPrivateActor: true });
|
|
826
826
|
if (target.kind === 'private')
|
|
827
|
-
await
|
|
827
|
+
await prepareSameOwnerProof(self, target.peerAid);
|
|
828
828
|
const relation = readRelation(target.peerKey, self);
|
|
829
829
|
const roleView = targetRoleView(self, target, relation?.config ?? null);
|
|
830
830
|
const override = target.kind === 'private'
|
|
@@ -25,7 +25,7 @@ import { authorizationNextStep, formatAuthorizationDenial } from '../auth/author
|
|
|
25
25
|
import { resolvePermissionMode, writeAgentModelConfig } from '../model/config-scope.js';
|
|
26
26
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
27
27
|
import { writeChatmodeConfig } from './chatmode-config.js';
|
|
28
|
-
import {
|
|
28
|
+
import { prepareSameOwnerProof } from '../relation/same-owner-proof.js';
|
|
29
29
|
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
30
30
|
import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
31
31
|
import { modelMatches, getCatalog, assertCatalogSelectable, resolveCatalogModel, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
@@ -41,7 +41,7 @@ import { launchMonitorAndConfirm, resolveMonitorLaunch, cleanupMonitorStage, isP
|
|
|
41
41
|
import { scanInstances } from '../../utils/instance-registry.js';
|
|
42
42
|
import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, parseFullAccessCommand, probeSessionActivity, } from './slash-gate.js';
|
|
43
43
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
44
|
-
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
44
|
+
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_PROMPT_LENGTH, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
45
45
|
const allEfforts = CONFIGURABLE_EFFORTS;
|
|
46
46
|
const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
|
|
47
47
|
function formatSessionPolicyStatus(name, scope, enabled, updated = false) {
|
|
@@ -424,7 +424,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
424
424
|
includeDaemon: /^\/(?:restart|upgrade|update|reload|pair|fa|fullaccess|diag)(?:\s|$)/i.test(normalizedContent),
|
|
425
425
|
});
|
|
426
426
|
if (this.resolveChannelType(channel) === 'aun' && narrowedChatType === 'private') {
|
|
427
|
-
await
|
|
427
|
+
await prepareSameOwnerProof(selfAID ?? this.agentRegistry?.resolveByChannel(channel)?.aid ?? this.resolveSelfAID(channel), userId);
|
|
428
428
|
}
|
|
429
429
|
const identityConversationId = narrowedChatType === 'group' ? channelId : userId;
|
|
430
430
|
const resolvedIdentity = overrideIdentity ?? this.sessionManager.resolveIdentity(channel, userId, narrowedChatType, identityConversationId);
|
|
@@ -580,12 +580,21 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
580
580
|
const isCmd = isRecognizedSlashCommand(normalizedContent);
|
|
581
581
|
if (!isCmd)
|
|
582
582
|
return undefined;
|
|
583
|
-
if (
|
|
583
|
+
if (/^\/loop(?:\s|$)/.test(normalizedContent)) {
|
|
584
584
|
const rawArgs = normalizedContent.slice('/loop'.length).trim();
|
|
585
585
|
const parts = rawArgs ? rawArgs.split(/\s+/) : [];
|
|
586
|
-
|
|
586
|
+
const controlCommand = rawArgs === '' || rawArgs === 'on' || rawArgs === 'off'
|
|
587
|
+
|| /^(?:on|off)\s/.test(rawArgs);
|
|
588
|
+
if (controlCommand && (parts.length > 2 || (parts.length > 0 && !['on', 'off'].includes(parts[0])))) {
|
|
587
589
|
return { kind: 'command.error', text: `❌ 用法: /loop | /loop on [${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS}] | /loop off` };
|
|
588
590
|
}
|
|
591
|
+
const oncePrompt = controlCommand ? undefined : rawArgs;
|
|
592
|
+
if (oncePrompt && source === 'card-trigger') {
|
|
593
|
+
return { kind: 'command.error', text: '❌ /loop <提示词> 只能由用户直接发送' };
|
|
594
|
+
}
|
|
595
|
+
if (oncePrompt && oncePrompt.length > MAX_SESSION_LOOP_PROMPT_LENGTH) {
|
|
596
|
+
return { kind: 'command.error', text: `❌ /loop 提示词不能超过 ${MAX_SESSION_LOOP_PROMPT_LENGTH} 个字符` };
|
|
597
|
+
}
|
|
589
598
|
const route = {
|
|
590
599
|
channel,
|
|
591
600
|
channelId,
|
|
@@ -603,7 +612,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
603
612
|
const message = error instanceof Error ? error.message : String(error);
|
|
604
613
|
return { kind: 'command.error', text: `❌ ${message}${code ? ` (${code})` : ''}` };
|
|
605
614
|
}
|
|
606
|
-
const operation = parts.length === 0 ? 'session.loop.current' : 'session.loop.update';
|
|
615
|
+
const operation = !oncePrompt && parts.length === 0 ? 'session.loop.current' : 'session.loop.update';
|
|
607
616
|
const denied = await authorizeIntent({
|
|
608
617
|
intent: { operation, scope: 'relation', source: 'slash', args: { sessionId: target.session.id, peer: target.peerKey, value: parts[0] } },
|
|
609
618
|
identity,
|
|
@@ -621,10 +630,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
621
630
|
try {
|
|
622
631
|
const current = await refreshSessionLoopTarget(this.sessionManager, route, target);
|
|
623
632
|
const payload = sessionLoopPayload(current);
|
|
633
|
+
const once = payload.once;
|
|
624
634
|
return {
|
|
625
635
|
kind: 'system.notice',
|
|
626
636
|
text: formatSessionPolicyStatus('idle 触发', current.level, payload.value === true)
|
|
627
|
-
+ (payload.value ? `(${payload.idleSeconds} 秒)` : '')
|
|
637
|
+
+ (payload.value ? `(${payload.idleSeconds} 秒)` : '')
|
|
638
|
+
+ (once ? `;单次:待执行(${once.idleSeconds} 秒);提示词:${once.promptPreview}` : ';单次:无'),
|
|
628
639
|
subtype: 'session.loop.current',
|
|
629
640
|
};
|
|
630
641
|
}
|
|
@@ -638,6 +649,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
638
649
|
return { kind: 'command.error', text: '❌ /loop off 不接受秒数' };
|
|
639
650
|
next = { enabled: false };
|
|
640
651
|
}
|
|
652
|
+
else if (oncePrompt) {
|
|
653
|
+
next = { enabled: true, idleSeconds: DEFAULT_SESSION_LOOP_SECONDS };
|
|
654
|
+
}
|
|
641
655
|
else {
|
|
642
656
|
const seconds = parts.length === 2
|
|
643
657
|
? /^[1-9]\d*$/.test(parts[1]) ? validateIdleSeconds(Number(parts[1])) : undefined
|
|
@@ -648,16 +662,33 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
648
662
|
}
|
|
649
663
|
try {
|
|
650
664
|
const latest = await refreshSessionLoopTarget(this.sessionManager, route, target);
|
|
665
|
+
if (oncePrompt) {
|
|
666
|
+
this.assertSessionLoopTrigger(latest.session, true);
|
|
667
|
+
this.sessionManager.updateSessionLoopOnce(latest.session.id, {
|
|
668
|
+
idleSeconds: DEFAULT_SESSION_LOOP_SECONDS,
|
|
669
|
+
prompt: oncePrompt,
|
|
670
|
+
}, { peerId: authSubject.principalId ?? userId,
|
|
671
|
+
encrypted: replyContext?.metadata?.encrypted ?? this.sessionManager.getSessionEncrypt(latest.session.id) });
|
|
672
|
+
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
673
|
+
return null;
|
|
674
|
+
return {
|
|
675
|
+
kind: 'system.notice',
|
|
676
|
+
text: `✅ 单次 idle 触发(${latest.level})已安排;闲置时长:${DEFAULT_SESSION_LOOP_SECONDS} 秒;提示词:${oncePrompt.replace(/\s+/g, ' ').slice(0, 120)}`,
|
|
677
|
+
subtype: 'session.loop.once.updated',
|
|
678
|
+
};
|
|
679
|
+
}
|
|
651
680
|
if (next.enabled)
|
|
652
681
|
this.assertSessionLoopTrigger(latest.session);
|
|
653
682
|
const updated = writeSessionLoopConfig(this.sessionManager, latest, next);
|
|
683
|
+
if (!next.enabled)
|
|
684
|
+
this.sessionManager.consumeSessionLoopOnce(updated.session.id);
|
|
654
685
|
const payload = sessionLoopPayload(updated);
|
|
655
686
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
656
687
|
return null;
|
|
657
688
|
return {
|
|
658
689
|
kind: 'system.notice',
|
|
659
690
|
text: formatSessionPolicyStatus('idle 触发', updated.level, payload.value === true, true)
|
|
660
|
-
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ''),
|
|
691
|
+
+ (payload.value ? `(${payload.idleSeconds} 秒)` : ';已取消待执行的单次触发'),
|
|
661
692
|
subtype: 'session.loop.updated',
|
|
662
693
|
};
|
|
663
694
|
}
|
|
@@ -865,7 +896,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
865
896
|
' /baseagent - 查看 Agent 后端',
|
|
866
897
|
' /perm - 查看权限模式',
|
|
867
898
|
' /mention - 查看群聊 @ 处理模式',
|
|
868
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
899
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
869
900
|
' /ask <选项> - 回答待处理问题',
|
|
870
901
|
' /pause - 在下一次工具调用前暂停任务',
|
|
871
902
|
' /resume - 继续已暂停的任务',
|
|
@@ -912,7 +943,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
912
943
|
'',
|
|
913
944
|
'💬 聊天设置:',
|
|
914
945
|
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`] : []),
|
|
915
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
946
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
916
947
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '或切换' : ''}群聊 @ 处理模式`] : []),
|
|
917
948
|
] : []),
|
|
918
949
|
...(canReadPermission || canAnswerPermission ? [
|
|
@@ -957,7 +988,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
957
988
|
'💬 聊天设置:',
|
|
958
989
|
` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`,
|
|
959
990
|
] : []),
|
|
960
|
-
...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
991
|
+
...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
961
992
|
...(canReadPermission || canAnswerPermission ? [
|
|
962
993
|
'',
|
|
963
994
|
'🔐 权限管理:',
|
|
@@ -1005,7 +1036,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1005
1036
|
' /activity [all|text|none] - 查看/控制中间输出显示模式',
|
|
1006
1037
|
...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ` [${chatmodeChoices}]` : ''} - 查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`] : []),
|
|
1007
1038
|
...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`] : []),
|
|
1008
|
-
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
1039
|
+
...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off|<提示词>]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
|
|
1009
1040
|
'',
|
|
1010
1041
|
'🧠 上下文:',
|
|
1011
1042
|
' /memory - 记忆概览与维护',
|
|
@@ -1088,8 +1119,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1088
1119
|
const canUpdateLoop = canAccessSlashOperation('session.loop.update', 'relation');
|
|
1089
1120
|
const loopHelp = canReadLoop || canUpdateLoop ? [{
|
|
1090
1121
|
command: '/loop',
|
|
1091
|
-
...(canUpdateLoop ? { args: '[on [seconds]|off]' } : {}),
|
|
1092
|
-
description: '
|
|
1122
|
+
...(canUpdateLoop ? { args: '[on [seconds]|off|<提示词>]' } : {}),
|
|
1123
|
+
description: '查看或设置闲置触发;自定义提示词闲置 300 秒后单次执行',
|
|
1093
1124
|
category: '聊天设置',
|
|
1094
1125
|
roles: [identity.role],
|
|
1095
1126
|
}] : [];
|
|
@@ -4036,7 +4067,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4036
4067
|
}
|
|
4037
4068
|
return { kind: 'command.error', text: '❌ 当前话题会话不存在或归属已变化' };
|
|
4038
4069
|
}
|
|
4039
|
-
return
|
|
4070
|
+
return outcome.value.startsWith('❌')
|
|
4071
|
+
? { kind: 'command.result', text: outcome.value }
|
|
4072
|
+
: { kind: 'system.notice', text: outcome.value, subtype: 'session.rewound' };
|
|
4040
4073
|
}
|
|
4041
4074
|
const rewindBaseagent = session.baseagent;
|
|
4042
4075
|
if (!rewindBaseagent) {
|
|
@@ -4050,7 +4083,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
4050
4083
|
return { kind: 'command.error', text: `❌ 当前 Agent (${rewindAgent.name}) 不支持 /rewind` };
|
|
4051
4084
|
}
|
|
4052
4085
|
await interruptPausedSessionBeforeReplacement(session);
|
|
4053
|
-
|
|
4086
|
+
const rewindResult = await this.handleRewind(session, rewindAgent, turnNum, mode);
|
|
4087
|
+
return rewindResult.startsWith('❌')
|
|
4088
|
+
? { kind: 'command.result', text: rewindResult }
|
|
4089
|
+
: { kind: 'system.notice', text: rewindResult, subtype: 'session.rewound' };
|
|
4054
4090
|
}
|
|
4055
4091
|
// /repair 命令:检查并修复会话文件
|
|
4056
4092
|
if (normalizedContent === '/repair') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatChannelKey } from '../channel-loader.js';
|
|
1
|
+
import { formatChannelKey, tryParseChannelKey } from '../channel-loader.js';
|
|
2
2
|
import { classifyAunPayloadForLog } from '../message/message-log.js';
|
|
3
3
|
import { HandoffDispatcher } from './dispatcher.js';
|
|
4
4
|
import { KeyedFairMutex } from './mutex.js';
|
|
@@ -75,7 +75,13 @@ export class HandoffRuntime {
|
|
|
75
75
|
throwIfAborted(input.signal);
|
|
76
76
|
if (!origin || origin.selfAID !== input.selfAid)
|
|
77
77
|
throw new Error('origin session not found');
|
|
78
|
-
|
|
78
|
+
// 目标渠道:缺省 AUN 主渠(历史行为);跨会话投递给其它渠道的会话时,
|
|
79
|
+
// 由调用方显式传入该会话真实的 channelKey / channelType。
|
|
80
|
+
const targetChannelKey = input.targetChannelKey
|
|
81
|
+
?? formatChannelKey({ type: 'aun', selfAID: input.selfAid, name: 'main' });
|
|
82
|
+
const targetChannelType = input.targetChannelType
|
|
83
|
+
?? tryParseChannelKey(targetChannelKey)?.type
|
|
84
|
+
?? 'aun';
|
|
79
85
|
if (!input.targetChatType) {
|
|
80
86
|
throw Object.assign(new Error('AUN handoff requires an explicit target chat type'), {
|
|
81
87
|
code: 'AUN_OUTBOUND_ROUTE_REQUIRED',
|
|
@@ -86,7 +92,7 @@ export class HandoffRuntime {
|
|
|
86
92
|
channelKey: targetChannelKey,
|
|
87
93
|
peerId: input.to,
|
|
88
94
|
...(targetChatType === 'group' ? { groupId: input.to } : {}),
|
|
89
|
-
}, undefined, input.to, targetChatType, origin.baseagent, input.selfAid,
|
|
95
|
+
}, undefined, input.to, targetChatType, origin.baseagent, input.selfAid, targetChannelType, targetChatType === 'group' ? 'group' : 'agent');
|
|
90
96
|
throwIfAborted(input.signal);
|
|
91
97
|
if (target.id === origin.id) {
|
|
92
98
|
if (input.handoffContext !== undefined)
|
|
@@ -11,6 +11,7 @@ import { isValidAid } from '../../aun/aid/validation.js';
|
|
|
11
11
|
import { listBaseagentImportSources, providerFromBaseagent } from '../../config/providers-import.js';
|
|
12
12
|
import { importOrMergeBaseagentProvider, readProvidersSnapshot } from '../../config/providers-management.js';
|
|
13
13
|
import { providerServiceTypesForBaseagent } from '../../config/providers.js';
|
|
14
|
+
import { resolveProviderId } from '../../config/providers-config.js';
|
|
14
15
|
import { readInstalledEvolcoreVersion } from '../../utils/evolcore-version.js';
|
|
15
16
|
import { agentProjectRootFromDefaults, defaultProjectsRoot } from '../../utils/project-path.js';
|
|
16
17
|
import { resolveControlAidDomain } from '../../aun/aid/control-aid.js';
|
|
@@ -170,9 +171,9 @@ export class EcwebInitializationService {
|
|
|
170
171
|
config.baseagents = record(config.baseagents) ? config.baseagents : {};
|
|
171
172
|
for (const id of available) {
|
|
172
173
|
const previous = record(config.baseagents[id]) ? config.baseagents[id] : {};
|
|
173
|
-
const previousProvider = typeof previous.provider === 'string' ? previous.provider : '';
|
|
174
|
+
const previousProvider = typeof previous.provider === 'string' ? resolveProviderId(previous.provider, providers) : '';
|
|
174
175
|
const provider = id === 'ecagent' ? ecagentProvider
|
|
175
|
-
: state.providerIds?.[id]
|
|
176
|
+
: (state.providerIds?.[id] ? resolveProviderId(state.providerIds[id], providers) : undefined)
|
|
176
177
|
|| (providerSupportsBaseagent(providers.providers[previousProvider], id) ? previousProvider : undefined)
|
|
177
178
|
|| firstProvider(id);
|
|
178
179
|
if (provider && providerSupportsBaseagent(providers.providers[provider], id))
|
|
@@ -199,7 +200,7 @@ export class EcwebInitializationService {
|
|
|
199
200
|
const defaultsComplete = configured.every(item => {
|
|
200
201
|
const selected = defaults[item.id];
|
|
201
202
|
return !!selected?.provider
|
|
202
|
-
&& providerSupportsBaseagent(providers.providers[selected.provider], item.id)
|
|
203
|
+
&& providerSupportsBaseagent(providers.providers[resolveProviderId(selected.provider, providers)], item.id)
|
|
203
204
|
&& (item.id !== 'ecagent' || !!selected.model?.trim());
|
|
204
205
|
});
|
|
205
206
|
const active = inventory.baseagents.find(item => item.id === inventory.active && item.detected);
|
|
@@ -16,6 +16,8 @@ import { sameGroupAid } from '../../aun/group/identity.js';
|
|
|
16
16
|
import { resolveThreadRouteTarget } from '../thread/thread-route.js';
|
|
17
17
|
import { isTopicThreadId, parseMainTopicId, safeFormatMainTopicId, sessionLocalTopicId } from '../thread/topic-id.js';
|
|
18
18
|
import { ThreadService } from '../thread/thread-service.js';
|
|
19
|
+
import { buildEnvelope } from './message-utils.js';
|
|
20
|
+
import { sessionTopicThreadId } from '../thread/topic-id.js';
|
|
19
21
|
import { getAunRequestRegistry, requestDiagnostics, requestTtlSeconds } from './aun-request-registry.js';
|
|
20
22
|
import { parseJsonObjectArgument } from '../permission/ec-command-parser.js';
|
|
21
23
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
@@ -36,9 +38,18 @@ export function createAunHandoffSender(sessionManager, channelInstances, getOutb
|
|
|
36
38
|
const targetSession = await sessionManager.getSessionById(handoff.target_session_id);
|
|
37
39
|
if (!targetSession)
|
|
38
40
|
return { ok: false, error: 'target session not found' };
|
|
39
|
-
|
|
41
|
+
// 目标会话可能属于任意渠道。先按该会话自己的 channelKey/渠道实例匹配,
|
|
42
|
+
// 只有拿到 AUN 渠道实例时才走 AUN 专用发送路径;其它渠道走通用 adapter。
|
|
43
|
+
const instance = channelInstances.find(candidate => (candidate.adapter.channelKey === targetSession.metadata?.channelKey
|
|
40
44
|
|| candidate.adapter.channelName === targetSession.channel
|
|
41
|
-
||
|
|
45
|
+
|| (candidate.channelType === 'aun'
|
|
46
|
+
&& tryParseChannelKey(candidate.adapter.channelKey)?.selfAID === targetSession.selfAID)));
|
|
47
|
+
if (!instance) {
|
|
48
|
+
return { ok: false, error: `channel not found for session ${targetSession.id}` };
|
|
49
|
+
}
|
|
50
|
+
if (instance.channelType !== 'aun') {
|
|
51
|
+
return sendViaSessionAdapter(handoff, targetSession, instance, getOutboundDebug);
|
|
52
|
+
}
|
|
42
53
|
const channel = instance?.channel;
|
|
43
54
|
if (!channel) {
|
|
44
55
|
return { ok: false, error: `AUN channel not found for ${targetSession.selfAID || '<unknown>'}` };
|
|
@@ -87,6 +98,57 @@ export function createAunHandoffSender(sessionManager, channelInstances, getOutb
|
|
|
87
98
|
return { ok: result.ok, message_id: result.message_id, error: result.error };
|
|
88
99
|
};
|
|
89
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* 跨会话投递到**非 AUN 渠道**的目标会话。
|
|
103
|
+
*
|
|
104
|
+
* 与 AUN 路径的区别只在投递方式:非 AUN 渠道没有 `sendDaemonMsg`,统一走
|
|
105
|
+
* adapter 的通用 `send(envelope, payload)`。目标会话已由 `createOutbound`
|
|
106
|
+
* 建好(`channelKey` / `channelId` / `threadId` 都来自该会话),这里只负责
|
|
107
|
+
* 把正文投出去。
|
|
108
|
+
*
|
|
109
|
+
* 边界:只支持文本正文。文件/链接/payload 的跨渠道投递尚未验证,明确报错
|
|
110
|
+
* 而不是静默丢弃。
|
|
111
|
+
*/
|
|
112
|
+
async function sendViaSessionAdapter(handoff, targetSession, instance, getOutboundDebug) {
|
|
113
|
+
const payload = handoff.request.payload;
|
|
114
|
+
const text = typeof payload?.text === 'string' ? payload.text : '';
|
|
115
|
+
if (!text.trim()) {
|
|
116
|
+
return { ok: false, error: 'cross-channel handoff currently supports text payloads only' };
|
|
117
|
+
}
|
|
118
|
+
const threadId = sessionTopicThreadId(targetSession);
|
|
119
|
+
// 投递目标以**目标会话自身**为准,不依赖 request.delivery(那是 AUN 路由字段)。
|
|
120
|
+
const delivery = targetSession.chatType === 'group'
|
|
121
|
+
? { chatType: 'group', groupId: targetSession.metadata?.groupId ?? targetSession.channelId }
|
|
122
|
+
: { chatType: 'private' };
|
|
123
|
+
const envelope = buildEnvelope({
|
|
124
|
+
taskId: `handoff:${handoff.handoff_id}`,
|
|
125
|
+
channel: instance.adapter.channelKey,
|
|
126
|
+
channelId: targetSession.channelId,
|
|
127
|
+
agentName: targetSession.selfAID,
|
|
128
|
+
causation: handoff.causation,
|
|
129
|
+
replyContext: {
|
|
130
|
+
delivery,
|
|
131
|
+
...(threadId ? { threadId } : {}),
|
|
132
|
+
...(typeof handoff.request.encrypt === 'boolean'
|
|
133
|
+
? { metadata: { encrypted: handoff.request.encrypt } }
|
|
134
|
+
: {}),
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
const receipt = await instance.adapter.send(envelope, { kind: 'result.text', text, isFinal: true });
|
|
139
|
+
if (receipt && typeof receipt === 'object' && 'status' in receipt) {
|
|
140
|
+
const status = receipt.status;
|
|
141
|
+
if (status === 'failed') {
|
|
142
|
+
return { ok: false, error: String(receipt.error ?? 'send failed') };
|
|
143
|
+
}
|
|
144
|
+
return { ok: true, message_id: receipt.messageId };
|
|
145
|
+
}
|
|
146
|
+
return { ok: true };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
90
152
|
async function applyManagedCrossThreadSendEffects(input) {
|
|
91
153
|
const originSessionId = input.grant.sessionId;
|
|
92
154
|
const originPeer = parsePeerKey(input.grant.peerKey).channelId;
|
|
@@ -134,7 +196,11 @@ async function applyManagedCrossThreadSendEffects(input) {
|
|
|
134
196
|
prompt,
|
|
135
197
|
everyMs: input.durationMs,
|
|
136
198
|
checkEvery: input.checkEveryLabel,
|
|
137
|
-
|
|
199
|
+
// 目标话题所属渠道:从话题索引取,取不到时按 AUN 主渠兜底(历史行为)。
|
|
200
|
+
// 硬写 AUN 会让飞书等渠道的目标话题把 Trigger 的 feedback.target 指向错渠道。
|
|
201
|
+
channelKey: targetEntry?.channelType
|
|
202
|
+
? formatChannelKey({ type: targetEntry.channelType, selfAID: input.selfAid, name: 'main' })
|
|
203
|
+
: formatChannelKey({ type: 'aun', selfAID: input.selfAid, name: 'main' }),
|
|
138
204
|
targetChannelId: input.targetChannelId,
|
|
139
205
|
targetThreadId: input.targetThreadId,
|
|
140
206
|
originThreadId,
|
|
@@ -545,6 +611,18 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
|
|
|
545
611
|
encrypt,
|
|
546
612
|
thread: params.thread,
|
|
547
613
|
targetChatType: params.scope === 'group' ? 'group' : 'private',
|
|
614
|
+
// 目标会话可能属于别的渠道(如飞书话题):带上它自己的 channelKey,
|
|
615
|
+
// 否则会按 AUN 主渠建会话,投递到错误的渠道。
|
|
616
|
+
...(threadRoute?.channelType
|
|
617
|
+
? {
|
|
618
|
+
targetChannelType: threadRoute.channelType,
|
|
619
|
+
targetChannelKey: formatChannelKey({
|
|
620
|
+
type: threadRoute.channelType,
|
|
621
|
+
selfAID: params.aid,
|
|
622
|
+
name: 'main',
|
|
623
|
+
}),
|
|
624
|
+
}
|
|
625
|
+
: {}),
|
|
548
626
|
explicitReturnPolicy: params.returnPolicy,
|
|
549
627
|
handoffContext: params.handoffContext,
|
|
550
628
|
// 跨话题发送的目标侧上下文由话题链(thread-inbox)负责注入;
|
|
@@ -4,6 +4,7 @@ import { isValidAid } from '../../aun/aid/validation.js';
|
|
|
4
4
|
import { readOwnerDirectoryMembership } from '../../directory/owner-directory-admission.js';
|
|
5
5
|
import { resolveAunPeerKind } from '../relation/peer-identity.js';
|
|
6
6
|
import { evaluateAppContactAdmission } from './contact-admission.js';
|
|
7
|
+
import { ownerResolver, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
7
8
|
/**
|
|
8
9
|
* AUN 出站私聊固定使用 app-v1,与入站保持相同的绑定和联系人判定。
|
|
9
10
|
* 群聊的准入单位是群,出站到群不做发言人判定。
|
|
@@ -21,6 +22,7 @@ export async function evaluateOutboundContactAdmission(input) {
|
|
|
21
22
|
return { allow: true, status: 'group' };
|
|
22
23
|
let decision;
|
|
23
24
|
try {
|
|
25
|
+
await ownerResolver.refresh(selfAid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
|
|
24
26
|
decision = evaluateAppContactAdmission(selfAid, targetAid);
|
|
25
27
|
}
|
|
26
28
|
catch (error) {
|