evolcore 0.0.47 → 0.0.48
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 +56 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +139 -39
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +31 -16
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +81 -24
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +7 -1
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +2 -8
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/role.js +61 -17
- package/dist/cli/stats.js +3 -3
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-manager.js +2 -6
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +59 -8
- package/dist/config/providers-management.js +467 -49
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +3 -0
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +28 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/command-handler.js +81 -85
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +61 -149
- package/dist/core/command/menu-protocol.js +7 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +7 -7
- package/dist/core/evolagent-registry.js +14 -1
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +2 -1
- package/dist/core/message/aun-ipc-sender.js +165 -55
- package/dist/core/message/im-renderer.js +1 -1
- package/dist/core/message/message-bridge.js +51 -334
- package/dist/core/message/message-log.js +5 -0
- package/dist/core/message/message-queue.js +22 -0
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +429 -116
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/relation/peer-identity.js +23 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +12 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/directory/owner-directory-admission.js +1 -1
- package/dist/directory/owner-directory-cache.js +45 -28
- package/dist/directory/owner-directory-markdown.js +13 -1
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/eck/message-renderer.js +84 -24
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +4 -2
- package/dist/event-center/registry.js +13 -2
- package/dist/event-center/runtime.js +103 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +92 -59
- package/dist/ipc.js +13 -2
- package/dist/outputs/events.js +62 -0
- package/dist/outputs/protocol.js +102 -0
- package/dist/outputs/service.js +279 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +89 -4
- package/dist/services/ipc-operation.js +4 -15
- package/dist/services/pack-manager.js +12 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +9 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -2
- package/kits/docs/evolcore/config.md +12 -0
- package/kits/docs/evolcore/directory.md +22 -3
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +123 -3
- package/kits/docs/evolcore/role.md +80 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +10 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +221 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +3 -3
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +6 -5
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +4 -1
- package/scripts/agent-template/shared/common.mjs +2 -3
- package/scripts/agent-template/shared/template-contract.mjs +2 -1
- package/scripts/agent-template/shared/template-package.mjs +9 -2
- package/scripts/agent-template/shared/template-runtime.mjs +20 -5
- package/scripts/agent-template/team-pack.mjs +6 -3
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
package/dist/channels/aun.js
CHANGED
|
@@ -28,7 +28,7 @@ import { createSendFileMarkerPattern } from '../core/message/file-markers.js';
|
|
|
28
28
|
import { chatDirPath } from '../core/session/session-fs-store.js';
|
|
29
29
|
import { readSessionLoopConfig, resolveSessionLoopTarget } from '../core/session/session-idle-monitor.js';
|
|
30
30
|
import { resolveRuntimePermissionMode, sessionFullAccessStatus } from '../core/role/runtime-policy.js';
|
|
31
|
-
import {
|
|
31
|
+
import { readTopicStatus } from '../core/session/session-mapper.js';
|
|
32
32
|
import { appendHintAddDetailed, appendHintRemoveDetailed, appendHintPromoteDetailed, parseInjectRequest, peekHints, withHintTargetLock } from '../core/message/pending-hints.js';
|
|
33
33
|
import { appendAidLifecycle } from '../aun/aid/identity.js';
|
|
34
34
|
import { getAidStore, loadClient, SLOT } from '../aun/aid/store.js';
|
|
@@ -955,7 +955,7 @@ export class AUNChannel {
|
|
|
955
955
|
ownerDirectoryRetryAttempts = 0;
|
|
956
956
|
ownerDirectoryResolvedSignature;
|
|
957
957
|
store = null;
|
|
958
|
-
/**
|
|
958
|
+
/** 服务路由实例(懒建;缺少 services-config.json 时默认开启,内置查询无需装包)。 */
|
|
959
959
|
serviceRouter = null;
|
|
960
960
|
/**
|
|
961
961
|
* 本 agent 的工程目录,由插件从 `ChannelBuildContext.defaultProjectPath` 注入。
|
|
@@ -998,7 +998,8 @@ export class AUNChannel {
|
|
|
998
998
|
// 自动从 data 推断顶层字段(self_aid / peer_aid / group_id / task_id / chatmode),
|
|
999
999
|
// 便于 jq 过滤:`jq 'select(.task_id == "task-xxx")'`
|
|
1000
1000
|
const inbound = data && typeof data === 'object' ? data : {};
|
|
1001
|
-
const isolateTrace = dir === 'IN' && event === 'message.received'
|
|
1001
|
+
const isolateTrace = dir === 'IN' && event === 'message.received'
|
|
1002
|
+
&& (!this.config.pureIdentity || inbound.payload?.type === 'action_card_reply');
|
|
1002
1003
|
const safeData = isolateTrace ? {
|
|
1003
1004
|
message_id: inbound.message_id, seq: inbound.seq,
|
|
1004
1005
|
envelope: { from: inbound.envelope?.from, to: inbound.envelope?.to, encrypted: inbound.envelope?.encrypted },
|
|
@@ -1320,7 +1321,7 @@ export class AUNChannel {
|
|
|
1320
1321
|
logger.info(`${this.logPrefix()} ActionInteraction audit: behavior=${behavior ?? 'reply'} `
|
|
1321
1322
|
+ `cardId=${cardMessageId} interactionId=${interactionId} result=${result} textLength=${textLength}`);
|
|
1322
1323
|
}
|
|
1323
|
-
extractTextPayload(payload, channelId, senderAid, delivery) {
|
|
1324
|
+
extractTextPayload(payload, channelId, senderAid, delivery, encrypted) {
|
|
1324
1325
|
if (typeof payload === 'string')
|
|
1325
1326
|
return payload;
|
|
1326
1327
|
if (payload && typeof payload === 'object') {
|
|
@@ -1331,6 +1332,11 @@ export class AUNChannel {
|
|
|
1331
1332
|
const cardMsgId = typeof obj.ref_message_id === 'string' ? obj.ref_message_id
|
|
1332
1333
|
: typeof obj.card_message_id === 'string' ? obj.card_message_id : '';
|
|
1333
1334
|
const cardInfo = cardMsgId ? this.cardMessageIdMap.get(cardMsgId) : undefined;
|
|
1335
|
+
if (cardInfo?.sensitive && (encrypted !== true || delivery?.chatType !== 'private'
|
|
1336
|
+
|| !senderAid || senderAid !== cardInfo.initiatorAid || channelId !== cardInfo.channelId)) {
|
|
1337
|
+
this.notifyCardActionFailure(channelId, '凭据仅接受卡片发起者通过加密私聊提交', senderAid, channelId === cardInfo.channelId ? cardInfo.replyContext?.threadId : undefined, delivery);
|
|
1338
|
+
return '';
|
|
1339
|
+
}
|
|
1334
1340
|
const cardDelivery = cardInfo?.delivery ?? delivery;
|
|
1335
1341
|
const savedTopic = this.ownedCardTopics.get(cardMsgId);
|
|
1336
1342
|
// Keep the topic after the actionable mapping expires, including for
|
|
@@ -1463,6 +1469,7 @@ export class AUNChannel {
|
|
|
1463
1469
|
...(isComposeReply ? { custom_text: text } : {}),
|
|
1464
1470
|
},
|
|
1465
1471
|
operatorId: cardClickerAid || undefined,
|
|
1472
|
+
...(cardInfo.sensitive ? { encrypted: encrypted === true } : {}),
|
|
1466
1473
|
};
|
|
1467
1474
|
const settle = (accepted) => {
|
|
1468
1475
|
this.interactionActionsInFlight.delete(cardMsgId);
|
|
@@ -2036,6 +2043,26 @@ export class AUNChannel {
|
|
|
2036
2043
|
invalidateAgentDisplayName(aid);
|
|
2037
2044
|
PeerIdentityCache.invalidate('aun', aid, path.join(resolvePaths().agentsDir, this.config.aid));
|
|
2038
2045
|
}
|
|
2046
|
+
/**
|
|
2047
|
+
* 入站发件人展示名:Owner 备注名 > 名片名 > AID 短名。
|
|
2048
|
+
*
|
|
2049
|
+
* 备注名来自 Owner 名录快照(App 里给联系人改的备注),比名片更贴近 Owner
|
|
2050
|
+
* 平时的称呼;名录取不到该条目时才回落到名片名。名录读取是本地快照、
|
|
2051
|
+
* 有文件戳缓存,不产生网络请求。
|
|
2052
|
+
*/
|
|
2053
|
+
inboundDisplayName(fromAid, cardName, shortAid) {
|
|
2054
|
+
let directoryName;
|
|
2055
|
+
try {
|
|
2056
|
+
const entry = this.ownerDirectoryCache?.cache.readSnapshot('contacts')?.entries
|
|
2057
|
+
.find(item => item.aid === fromAid);
|
|
2058
|
+
const remark = entry?.remark?.trim();
|
|
2059
|
+
if (remark)
|
|
2060
|
+
return remark;
|
|
2061
|
+
directoryName = entry?.name?.trim() || undefined;
|
|
2062
|
+
}
|
|
2063
|
+
catch { /* 名录不可用不影响消息处理 */ }
|
|
2064
|
+
return cardName?.trim() || directoryName || shortAid || fromAid;
|
|
2065
|
+
}
|
|
2039
2066
|
/**
|
|
2040
2067
|
* 每条进入消息队列的消息都走这里。分两段,代价完全不同:
|
|
2041
2068
|
*
|
|
@@ -2199,7 +2226,7 @@ export class AUNChannel {
|
|
|
2199
2226
|
logger.warn(`${this.logPrefix()} owner.directory.grant: initial pull failed (pending kept): ${error instanceof Error ? error.message : String(error)}`);
|
|
2200
2227
|
}
|
|
2201
2228
|
}
|
|
2202
|
-
buildGroupReplyContext(threadId, senderAid, encrypted, messageId, chatmode, topicName, groupId,
|
|
2229
|
+
buildGroupReplyContext(threadId, senderAid, encrypted, messageId, chatmode, topicName, groupId, topicStatus) {
|
|
2203
2230
|
if (!groupId)
|
|
2204
2231
|
throw new Error('buildGroupReplyContext requires groupId');
|
|
2205
2232
|
const replyContext = {
|
|
@@ -2217,13 +2244,11 @@ export class AUNChannel {
|
|
|
2217
2244
|
replyContext.metadata = {};
|
|
2218
2245
|
replyContext.metadata.topicName = topicName;
|
|
2219
2246
|
}
|
|
2220
|
-
if (label && threadId)
|
|
2221
|
-
replyContext.metadata.label = label;
|
|
2222
2247
|
if (topicStatus && threadId)
|
|
2223
2248
|
replyContext.metadata.topicStatus = topicStatus;
|
|
2224
2249
|
return replyContext;
|
|
2225
2250
|
}
|
|
2226
|
-
buildPrivateReplyContext(threadId, senderAid, encrypted, messageId, chatmode, topicName, refMessageId,
|
|
2251
|
+
buildPrivateReplyContext(threadId, senderAid, encrypted, messageId, chatmode, topicName, refMessageId, topicStatus) {
|
|
2227
2252
|
const replyContext = {
|
|
2228
2253
|
metadata: { encrypted, chatmode, refMessageId },
|
|
2229
2254
|
delivery: { chatType: 'private' },
|
|
@@ -2235,8 +2260,6 @@ export class AUNChannel {
|
|
|
2235
2260
|
replyContext.replyToMessageId = messageId;
|
|
2236
2261
|
if (topicName && threadId)
|
|
2237
2262
|
replyContext.metadata.topicName = topicName;
|
|
2238
|
-
if (label && threadId)
|
|
2239
|
-
replyContext.metadata.label = label;
|
|
2240
2263
|
if (topicStatus && threadId)
|
|
2241
2264
|
replyContext.metadata.topicStatus = topicStatus;
|
|
2242
2265
|
return replyContext;
|
|
@@ -3373,7 +3396,7 @@ export class AUNChannel {
|
|
|
3373
3396
|
if (type === 'text' && typeof value?.text === 'string' && /^\s*\/bind(?:\s|$)/i.test(value.text))
|
|
3374
3397
|
return false;
|
|
3375
3398
|
// An already isolated source never becomes an ordinary message after approval.
|
|
3376
|
-
await ownerResolver.refresh(selfAid, { maxAgeMs:
|
|
3399
|
+
await ownerResolver.refresh(selfAid, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true, source: 'contact.inbound' });
|
|
3377
3400
|
await this.getOwnerDirectoryRuntime();
|
|
3378
3401
|
await this.settleOwnerDirectoryBeforeTurn();
|
|
3379
3402
|
const decision = evaluateAppContactAdmission(selfAid, fromAid);
|
|
@@ -3582,6 +3605,18 @@ export class AUNChannel {
|
|
|
3582
3605
|
return;
|
|
3583
3606
|
const protectedHeaders = verifiedProtectedHeaders(msg, env);
|
|
3584
3607
|
const payload = msg.payload ?? '';
|
|
3608
|
+
// Credential answers must be consumed before contact/request persistence,
|
|
3609
|
+
// observer forwarding or generic message logging. Card binding is server-owned.
|
|
3610
|
+
if (payload && typeof payload === 'object' && payload.type === 'action_card_reply') {
|
|
3611
|
+
const ref = payload.ref_message_id ?? payload.card_message_id;
|
|
3612
|
+
const card = typeof ref === 'string' ? this.cardMessageIdMap.get(ref) : undefined;
|
|
3613
|
+
if (!card || card.sensitive) {
|
|
3614
|
+
if (appOwned && !this.claimInboundMessage('private', messageId, seq))
|
|
3615
|
+
return;
|
|
3616
|
+
this.extractTextPayload(payload, fromAid, fromAid, { chatType: 'private' }, !!env.encrypted);
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3585
3620
|
// friend.invite.v1(App 主动加好友)不依赖 app-v1 灰度:按 Owner 准入策略已放行的申请人
|
|
3586
3621
|
// 由本 Agent 直接回 accepted 并发欢迎语;其余转交 Owner。不进 Agent、不转 observer。
|
|
3587
3622
|
if (!this.config.pureIdentity && isFriendInvitePayload(payload)) {
|
|
@@ -3651,7 +3686,7 @@ export class AUNChannel {
|
|
|
3651
3686
|
? payload._evolcore_causation_ref
|
|
3652
3687
|
: undefined;
|
|
3653
3688
|
const logDescriptor = classifyAunPayloadForLog(payload);
|
|
3654
|
-
const text = this.extractTextPayload(payload, fromAid, fromAid, { chatType: 'private' });
|
|
3689
|
+
const text = this.extractTextPayload(payload, fromAid, fromAid, { chatType: 'private' }, !!env.encrypted);
|
|
3655
3690
|
const threadId = typeof payload === 'object' && payload !== null ? payload.thread_id : undefined;
|
|
3656
3691
|
const refMessageId = typeof payload === 'object' && payload !== null && typeof payload.ref_message_id === 'string'
|
|
3657
3692
|
? payload.ref_message_id
|
|
@@ -3684,7 +3719,8 @@ export class AUNChannel {
|
|
|
3684
3719
|
// forwardInbound 内部排除 self-echo 与 from-owner。
|
|
3685
3720
|
// 显式排除 observer.inject:它是 owner 对本 agent 的控制消息,不应镜像给观察者
|
|
3686
3721
|
// (即便日后 from-owner 排除规则调整,也不会泄漏)。
|
|
3687
|
-
if (!contactControl &&
|
|
3722
|
+
if (!contactControl && inboundType !== 'action_card_reply'
|
|
3723
|
+
&& (typeof inboundType !== 'string' || !inboundType.startsWith('observer.inject'))) {
|
|
3688
3724
|
void this.forwardInbound(msg);
|
|
3689
3725
|
}
|
|
3690
3726
|
if (inboundType === 'observer.inject.status' || inboundType === 'observer.inject.ack') {
|
|
@@ -3721,7 +3757,7 @@ export class AUNChannel {
|
|
|
3721
3757
|
const peerIdentity = await PeerIdentityCache.resolve('aun', fromAid, selfAgentDir, this.store, false, this.config.keystorePath || resolveRoot());
|
|
3722
3758
|
await prepareSameOwnerProof(this.config.aid, fromAid);
|
|
3723
3759
|
const shortAid = this.getShortAid(fromAid);
|
|
3724
|
-
const displayName = peerIdentity.name
|
|
3760
|
+
const displayName = this.inboundDisplayName(fromAid, peerIdentity.name, shortAid);
|
|
3725
3761
|
// 详细 dispatch 决策日志:记录消息为何被路由到 agent
|
|
3726
3762
|
const p2pPayloadType = (payload && typeof payload === 'object' && typeof payload.type === 'string')
|
|
3727
3763
|
? payload.type
|
|
@@ -3826,7 +3862,7 @@ export class AUNChannel {
|
|
|
3826
3862
|
appendAidEvent({ ts: Date.now(), iso: new Date().toISOString(), event: 'message_in', aid: this.config.aid, from: fromAid, msgId: messageId, kind: 'text', len: finalText.length });
|
|
3827
3863
|
const isSystemP2P = p2pPayloadType === 'event';
|
|
3828
3864
|
this.aidStatsCollector?.recordInbound(this.config.aid, fromAid, Buffer.byteLength(finalText, 'utf-8'), finalText, isSystemP2P, msgEncrypted, msgChatmode, isSystemP2P ? 'notify' : 'send');
|
|
3829
|
-
const replyContext = this.buildPrivateReplyContext(threadId, fromAid, msgEncrypted, messageId, msgChatmode, topicName, refMessageId,
|
|
3865
|
+
const replyContext = this.buildPrivateReplyContext(threadId, fromAid, msgEncrypted, messageId, msgChatmode, topicName, refMessageId, readTopicStatus(payload));
|
|
3830
3866
|
this.dispatchMessage({
|
|
3831
3867
|
channelId: chatId,
|
|
3832
3868
|
userId: fromAid,
|
|
@@ -3874,6 +3910,14 @@ export class AUNChannel {
|
|
|
3874
3910
|
const groupId = env.group_id ?? '';
|
|
3875
3911
|
const senderAid = env.from ?? '';
|
|
3876
3912
|
const payload = msg.payload ?? '';
|
|
3913
|
+
if (payload && typeof payload === 'object' && payload.type === 'action_card_reply') {
|
|
3914
|
+
const ref = payload.ref_message_id ?? payload.card_message_id;
|
|
3915
|
+
const card = typeof ref === 'string' ? this.cardMessageIdMap.get(ref) : undefined;
|
|
3916
|
+
if (!card || card.sensitive) {
|
|
3917
|
+
this.extractTextPayload(payload, groupId, senderAid, { chatType: 'group', groupId }, !!env.encrypted);
|
|
3918
|
+
return;
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3877
3921
|
const responseRecord = getAunRequestRegistry().resolveIncoming({
|
|
3878
3922
|
selfAid: this._aid || this.config.aid,
|
|
3879
3923
|
fromAid: senderAid,
|
|
@@ -3903,7 +3947,7 @@ export class AUNChannel {
|
|
|
3903
3947
|
return;
|
|
3904
3948
|
const payloadMentionAids = mentionEntryAids(payloadMentionEntries);
|
|
3905
3949
|
const logDescriptor = classifyAunPayloadForLog(payload);
|
|
3906
|
-
const text = this.extractTextPayload(payload, groupId, senderAid, { chatType: 'group', groupId });
|
|
3950
|
+
const text = this.extractTextPayload(payload, groupId, senderAid, { chatType: 'group', groupId }, !!env.encrypted);
|
|
3907
3951
|
const threadId = typeof payload === 'object' && payload !== null ? payload.thread_id : undefined;
|
|
3908
3952
|
const topicName = (typeof payload === 'object' && payload !== null)
|
|
3909
3953
|
? this.sanitizeTopicName(payload.topicName)
|
|
@@ -3915,8 +3959,10 @@ export class AUNChannel {
|
|
|
3915
3959
|
}
|
|
3916
3960
|
// Observer forward (inbound):群聊消息在所有过滤之前转发原始明文 payload。
|
|
3917
3961
|
// forwardInbound 内部排除 self-echo 与 from-owner。
|
|
3918
|
-
|
|
3919
|
-
|
|
3962
|
+
if (inboundType !== 'action_card_reply') {
|
|
3963
|
+
void this.forwardInbound(msg);
|
|
3964
|
+
logger.debug(`${this.logPrefix()}[DIAG-GRP] full_msg=${JSON.stringify(msg).substring(0, 500)}`);
|
|
3965
|
+
}
|
|
3920
3966
|
if (!groupId || !senderAid) {
|
|
3921
3967
|
logger.debug(`${this.logPrefix()} Group dropped: missing groupId or senderAid (mid=${messageId})`);
|
|
3922
3968
|
return;
|
|
@@ -3944,7 +3990,7 @@ export class AUNChannel {
|
|
|
3944
3990
|
const msgChatmodeFast = (payload && typeof payload === 'object') ? payload.chatmode : undefined;
|
|
3945
3991
|
const peerInfo = this.peerInfoCached(senderAid);
|
|
3946
3992
|
const shortAid = this.getShortAid(senderAid);
|
|
3947
|
-
const displayName = peerInfo?.name
|
|
3993
|
+
const displayName = this.inboundDisplayName(senderAid, peerInfo?.name, shortAid);
|
|
3948
3994
|
const createdAt = data.created_at;
|
|
3949
3995
|
if (!peerInfo)
|
|
3950
3996
|
this.prefetchPeerInfo(senderAid);
|
|
@@ -3957,7 +4003,7 @@ export class AUNChannel {
|
|
|
3957
4003
|
peerName: displayName,
|
|
3958
4004
|
peerType: peerInfo?.type || 'unknown',
|
|
3959
4005
|
seq,
|
|
3960
|
-
replyContext: this.buildGroupReplyContext(threadId, senderAid, msgEncryptedFast, messageId, msgChatmodeFast, topicName, groupId,
|
|
4006
|
+
replyContext: this.buildGroupReplyContext(threadId, senderAid, msgEncryptedFast, messageId, msgChatmodeFast, topicName, groupId, readTopicStatus(payload)),
|
|
3961
4007
|
createdAt,
|
|
3962
4008
|
});
|
|
3963
4009
|
return;
|
|
@@ -4035,7 +4081,7 @@ export class AUNChannel {
|
|
|
4035
4081
|
extra: `from=${senderAid} mid=${messageId} chat=group self=${this._aid || 'unknown'} conn_uptime=${this.connectedAt ? Math.round((echoReceiveTs - this.connectedAt) / 1000) + 's' : 'unknown'}${echoInboundLegLabel(echoCreatedAt, receivedAt)}`,
|
|
4036
4082
|
})}`;
|
|
4037
4083
|
const msgChatmodeEcho = (payload && typeof payload === 'object') ? payload.chatmode : undefined;
|
|
4038
|
-
const groupProbeContext = this.buildGroupReplyContext(threadId, senderAid, msgEncrypted, messageId, msgChatmodeEcho, topicName, groupId,
|
|
4084
|
+
const groupProbeContext = this.buildGroupReplyContext(threadId, senderAid, msgEncrypted, messageId, msgChatmodeEcho, topicName, groupId, readTopicStatus(payload));
|
|
4039
4085
|
this.registerProbe(messageId, echoKindGroup ?? 'ask', echoText, groupId, groupProbeContext, echoReceiveTs);
|
|
4040
4086
|
// 继续走正常 Agent 流程(下面的代码会 dispatch)
|
|
4041
4087
|
}
|
|
@@ -4092,7 +4138,7 @@ export class AUNChannel {
|
|
|
4092
4138
|
const selfAgentDir = path.join(resolvePaths().agentsDir, this.config.aid);
|
|
4093
4139
|
const peerIdentity = await PeerIdentityCache.resolve('aun', senderAid, selfAgentDir, this.store, false, this.config.keystorePath || resolveRoot());
|
|
4094
4140
|
const shortAid = this.getShortAid(senderAid);
|
|
4095
|
-
const displayName = peerIdentity.name
|
|
4141
|
+
const displayName = this.inboundDisplayName(senderAid, peerIdentity.name, shortAid);
|
|
4096
4142
|
// 详细 dispatch 决策日志:记录消息为何被路由到 agent
|
|
4097
4143
|
const payloadType = (payload && typeof payload === 'object') ? payload.type ?? '' : '';
|
|
4098
4144
|
const textMentionSelf = this._aid ? this.hasExplicitMention(text, this._aid) : false;
|
|
@@ -4126,7 +4172,7 @@ export class AUNChannel {
|
|
|
4126
4172
|
const senderGroupRole = memberRoles?.get(String(senderAid).toLowerCase());
|
|
4127
4173
|
const myGroupRole = memberRoles?.get(String(this._aid || '').toLowerCase());
|
|
4128
4174
|
const groupRoles = memberRoles ? Object.fromEntries(memberRoles) : undefined;
|
|
4129
|
-
//
|
|
4175
|
+
// 「关系角色」:发言人本人的关系 → 联系人 → visitor。
|
|
4130
4176
|
const speakerRelation = resolveSenderRelationRole({
|
|
4131
4177
|
selfAid: this.config.aid,
|
|
4132
4178
|
channelKey: `aun#${this.config.aid}#main`,
|
|
@@ -4163,7 +4209,7 @@ export class AUNChannel {
|
|
|
4163
4209
|
isMentioned: isOwnHandoff || mentionedSelf || mentionedAll,
|
|
4164
4210
|
source: isOwnHandoff ? 'handoff' : undefined,
|
|
4165
4211
|
encrypted: msgEncrypted,
|
|
4166
|
-
replyContext: this.buildGroupReplyContext(threadId, senderAid, msgEncrypted, messageId, msgChatmode, topicName, groupId,
|
|
4212
|
+
replyContext: this.buildGroupReplyContext(threadId, senderAid, msgEncrypted, messageId, msgChatmode, topicName, groupId, readTopicStatus(payload)),
|
|
4167
4213
|
mentionMode: serverMentionMode,
|
|
4168
4214
|
images: inboundImages.length > 0 ? inboundImages : undefined,
|
|
4169
4215
|
msgType: logDescriptor.msgType,
|
|
@@ -5764,6 +5810,7 @@ export class AUNChannel {
|
|
|
5764
5810
|
this.registerCardPostSend(messageId, {
|
|
5765
5811
|
type: 'register_interaction_card', requestId: interaction.id,
|
|
5766
5812
|
isCommandCard: false, initiatorAid: interaction.initiatorId,
|
|
5813
|
+
sensitive: interaction.sensitive,
|
|
5767
5814
|
expiresAt: interaction.expiresAt, delivery,
|
|
5768
5815
|
}, channelId, delivery, envelope.replyContext);
|
|
5769
5816
|
}
|
|
@@ -5827,6 +5874,7 @@ export class AUNChannel {
|
|
|
5827
5874
|
channelId,
|
|
5828
5875
|
delivery: delivery ?? action.delivery,
|
|
5829
5876
|
replyContext: callbackContext,
|
|
5877
|
+
sensitive: action.sensitive,
|
|
5830
5878
|
});
|
|
5831
5879
|
this.ownedCardMsgIds.add(messageId);
|
|
5832
5880
|
if (typeof replyContext?.threadId === 'string') {
|
|
@@ -7605,6 +7653,8 @@ export class AUNChannel {
|
|
|
7605
7653
|
Object.assign(finalPayload, this.withCurrentTopicName(channelId, finalPayload));
|
|
7606
7654
|
}
|
|
7607
7655
|
const isMenuPayload = typeof finalPayload.type === 'string' && finalPayload.type.startsWith('menu.');
|
|
7656
|
+
const isOutputServicePayload = delivery.chatType === 'private' && !!delivery.service
|
|
7657
|
+
&& /^services\.outputs\.(snapshot|list|detail|changes)\.result$/.test(finalPayload.type ?? '');
|
|
7608
7658
|
finalPayload = await this.withSessionState(channelId, finalPayload, context);
|
|
7609
7659
|
const params = { payload: finalPayload, encrypt };
|
|
7610
7660
|
if (!isGroup && ['menu.response', 'menu.event'].includes(finalPayload.type))
|
|
@@ -7617,6 +7667,10 @@ export class AUNChannel {
|
|
|
7617
7667
|
}
|
|
7618
7668
|
if (encrypt)
|
|
7619
7669
|
params.protected_headers = aunProtectedHeaders(context);
|
|
7670
|
+
if (isOutputServicePayload) {
|
|
7671
|
+
params.message_class = 'control';
|
|
7672
|
+
params.protected_headers = { ...(params.protected_headers ?? {}), message_class: 'control' };
|
|
7673
|
+
}
|
|
7620
7674
|
try {
|
|
7621
7675
|
if (isGroup) {
|
|
7622
7676
|
params.group_id = delivery.groupId;
|
|
@@ -8932,6 +8986,7 @@ export class AUNChannelPlugin {
|
|
|
8932
8986
|
const aunCard = withAunAttention({
|
|
8933
8987
|
type: 'action_card',
|
|
8934
8988
|
title: action.title,
|
|
8989
|
+
...(req.sensitive ? { sensitive: true } : {}),
|
|
8935
8990
|
...(req.blocking === true ? { blocking: true } : {}),
|
|
8936
8991
|
...(action.recommendedOption ? { recommended_option: action.recommendedOption } : {}),
|
|
8937
8992
|
actions: action.buttons.map(btn => ({
|
|
@@ -8945,6 +9000,7 @@ export class AUNChannelPlugin {
|
|
|
8945
9000
|
if (action.allowCustomInput) {
|
|
8946
9001
|
aunCard.actions.push({
|
|
8947
9002
|
label: '✏️ 手动输入', style: 'default', behavior: 'compose',
|
|
9003
|
+
...(req.sensitive ? { sensitive: true } : {}),
|
|
8948
9004
|
...(cardExpiresAt !== undefined ? { compose_timeout_ms: Math.max(0, cardExpiresAt - Date.now()) } : {}),
|
|
8949
9005
|
});
|
|
8950
9006
|
}
|
|
@@ -8972,6 +9028,7 @@ export class AUNChannelPlugin {
|
|
|
8972
9028
|
type: 'register_interaction_card',
|
|
8973
9029
|
requestId: req.id,
|
|
8974
9030
|
isCommandCard: false,
|
|
9031
|
+
sensitive: req.sensitive,
|
|
8975
9032
|
initiatorAid: req.initiatorId,
|
|
8976
9033
|
delivery: replyCtx?.delivery,
|
|
8977
9034
|
expiresAt: cardExpiresAt,
|
package/dist/channels/daemon.js
CHANGED
|
@@ -2,8 +2,7 @@ import { appendExpireEntry, recordNextLaunchCleanup, cleanupPreviousByKind, runE
|
|
|
2
2
|
import { ExecutionTimeoutError } from '../utils/error-utils.js';
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import { normalizeExecutionMode } from '../trigger/validation.js';
|
|
5
|
-
import {
|
|
6
|
-
import { prepareSameOwnerProof } from '../core/relation/same-owner-proof.js';
|
|
5
|
+
import { bindTriggerExecutionIdentity, currentTriggerExecutionIdentity } from '../trigger/authorization.js';
|
|
7
6
|
import { assertSystemSessionLaunchable } from '../core/system-session/registry.js';
|
|
8
7
|
import { sessionTopicThreadId } from '../core/thread/topic-id.js';
|
|
9
8
|
const DEFAULT_WATCHDOG_MS = 11 * 60 * 1000;
|
|
@@ -147,16 +146,21 @@ export class DaemonChannel {
|
|
|
147
146
|
}
|
|
148
147
|
if (ctx.signal?.aborted)
|
|
149
148
|
onAbort();
|
|
150
|
-
|
|
151
|
-
await
|
|
149
|
+
try {
|
|
150
|
+
await bindTriggerExecutionIdentity(message, ctx.trigger, ctx.executionIdentity);
|
|
152
151
|
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
this.fail(pendingId, 'authorization_denied', error instanceof Error ? error.message : String(error));
|
|
154
|
+
return promise;
|
|
155
|
+
}
|
|
156
|
+
const executionIdentity = await currentTriggerExecutionIdentity(message, ctx.trigger.agentAid);
|
|
153
157
|
if (!slot?.terminalClaim) {
|
|
154
158
|
void this.messageQueue.enqueue(ctx.session.id, message, ctx.projectPath, {
|
|
155
159
|
interruptible: false,
|
|
156
160
|
agentName: ctx.trigger.agentAid,
|
|
157
161
|
sessionKeyField: ctx.session.sessionKey,
|
|
158
162
|
selfAID: ctx.trigger.agentAid,
|
|
159
|
-
role:
|
|
163
|
+
role: executionIdentity?.role,
|
|
160
164
|
signal: ctx.signal,
|
|
161
165
|
}).catch((err) => {
|
|
162
166
|
if (ctx.signal?.aborted)
|
|
@@ -357,26 +361,6 @@ export class DaemonChannel {
|
|
|
357
361
|
slot.acc.seenToolCallIds.add(callId);
|
|
358
362
|
slot.acc.toolCallCount += 1;
|
|
359
363
|
}
|
|
360
|
-
triggerOriginRole(trigger) {
|
|
361
|
-
const origin = trigger.origin;
|
|
362
|
-
if (!origin?.peerId)
|
|
363
|
-
return undefined;
|
|
364
|
-
if (origin.channelKey === 'daemon')
|
|
365
|
-
return 'owner';
|
|
366
|
-
const channelType = origin.channelType
|
|
367
|
-
?? (origin.channelKey ? channelTypeFromKey(origin.channelKey) : undefined);
|
|
368
|
-
if (!channelType)
|
|
369
|
-
return undefined;
|
|
370
|
-
const chatType = origin.delivery?.chatType ?? 'private';
|
|
371
|
-
return resolvePeerRoleDetail({
|
|
372
|
-
selfAid: trigger.agentAid,
|
|
373
|
-
channelKey: origin.channelKey,
|
|
374
|
-
channelType,
|
|
375
|
-
chatType,
|
|
376
|
-
actorId: origin.peerId,
|
|
377
|
-
conversationId: chatType === 'group' ? origin.channelId : origin.peerId,
|
|
378
|
-
}).effectiveRole ?? undefined;
|
|
379
|
-
}
|
|
380
364
|
finish(runId, status, metadata) {
|
|
381
365
|
const slot = this.pending.get(runId);
|
|
382
366
|
if (!slot || !this.claimTerminal(slot, status, metadata))
|
package/dist/cli/aun-commands.js
CHANGED
|
@@ -1527,6 +1527,9 @@ export function buildThreadCheckTrigger(input) {
|
|
|
1527
1527
|
// labels 只收字符串(validation.ts 校验);scheduler 读取时用 Number() 还原。
|
|
1528
1528
|
...(input.firstSentAt ? { firstSentAt: String(input.firstSentAt) } : {}),
|
|
1529
1529
|
...(input.originThreadName ? { originThreadName: input.originThreadName } : {}),
|
|
1530
|
+
...(input.originPeerName && input.originPeerName !== input.originPeer
|
|
1531
|
+
? { originPeerName: input.originPeerName } : {}),
|
|
1532
|
+
...(input.originPeerType ? { originPeerType: input.originPeerType } : {}),
|
|
1530
1533
|
...(input.targetThreadName ? { targetThreadName: input.targetThreadName } : {}),
|
|
1531
1534
|
},
|
|
1532
1535
|
...(input.origin ? { origin: input.origin } : {}),
|
|
@@ -1596,16 +1599,22 @@ export function buildCrossThreadReviewPrompt(input) {
|
|
|
1596
1599
|
/**
|
|
1597
1600
|
* 解析并校验 `--check-every`。返回 `{ durationMs }` 或错误。
|
|
1598
1601
|
* 私聊与群聊两条跨话题发送路径共用,保证错误码一致。
|
|
1602
|
+
*
|
|
1603
|
+
* `--check-every none` = 跨话题发送但**不建复查 Trigger**(收尾场景:结果带回原话题)。
|
|
1604
|
+
* 此时仍写 thread-inbox —— 「我发过这条」是事实,与「要不要定时唤醒我」是两件事。
|
|
1605
|
+
* 不传 `--check-every` 仍然报错:逼调用方显式区分「发起」和「无需跟进」。
|
|
1599
1606
|
*/
|
|
1600
1607
|
function parseCheckEveryArgs(checkEveryRaw, hasCheckEvery) {
|
|
1601
1608
|
if (!hasCheckEvery) {
|
|
1602
|
-
return { code: 'CHECK_EVERY_REQUIRED', error: '跨话题发送必须指定 --check-every
|
|
1609
|
+
return { code: 'CHECK_EVERY_REQUIRED', error: '跨话题发送必须指定 --check-every <时长|none>(如 5m / 30m / 2h / none)' };
|
|
1603
1610
|
}
|
|
1604
1611
|
if (checkEveryRaw === undefined)
|
|
1605
1612
|
return { durationMs: 5 * 60 * 1000 };
|
|
1613
|
+
if (checkEveryRaw.trim().toLowerCase() === 'none')
|
|
1614
|
+
return { durationMs: undefined };
|
|
1606
1615
|
const parsed = parseDuration(checkEveryRaw);
|
|
1607
1616
|
if (parsed === null) {
|
|
1608
|
-
return { code: 'INVALID_DURATION', error: `--check-every 时长格式无效: ${checkEveryRaw}(示例: 5m / 30m / 2h / 1d)` };
|
|
1617
|
+
return { code: 'INVALID_DURATION', error: `--check-every 时长格式无效: ${checkEveryRaw}(示例: 5m / 30m / 2h / 1d / none)` };
|
|
1609
1618
|
}
|
|
1610
1619
|
return { durationMs: parsed };
|
|
1611
1620
|
}
|
|
@@ -1644,6 +1653,15 @@ async function applyCrossThreadSendEffects(input) {
|
|
|
1644
1653
|
let originPeerName = originPeer;
|
|
1645
1654
|
let targetThreadName = input.targetThreadId;
|
|
1646
1655
|
let targetPeerName = input.targetChannelId;
|
|
1656
|
+
// 来源话题对端的主体类型:只有运行时上下文知道(话题索引不存 type)。
|
|
1657
|
+
// 伪对端(trigger: / bg:)不是主体,不能把 'system' 写进信封。
|
|
1658
|
+
const originPeerType = (() => {
|
|
1659
|
+
const type = String(runtime?.peerType ?? '').trim();
|
|
1660
|
+
const peerId = String(runtime?.peerId ?? '');
|
|
1661
|
+
if (!type || peerId.startsWith('trigger:') || peerId.startsWith('bg:'))
|
|
1662
|
+
return undefined;
|
|
1663
|
+
return type;
|
|
1664
|
+
})();
|
|
1647
1665
|
try {
|
|
1648
1666
|
const { ThreadService } = await import('../core/thread/index.js');
|
|
1649
1667
|
const originEntry = isTopicThreadId(originThreadId)
|
|
@@ -1691,49 +1709,54 @@ async function applyCrossThreadSendEffects(input) {
|
|
|
1691
1709
|
extra: input.triggerPromptExtra,
|
|
1692
1710
|
});
|
|
1693
1711
|
let createdTriggerId;
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1712
|
+
// `--check-every none`:跳过 Trigger,只保留 inbox(「我发过」是事实,定时唤醒是可选项)。
|
|
1713
|
+
if (input.durationMs !== undefined) {
|
|
1714
|
+
try {
|
|
1715
|
+
const { formatChannelKey } = await import('../core/channel-loader.js');
|
|
1716
|
+
const triggerDef = buildThreadCheckTrigger({
|
|
1717
|
+
agentAid: input.selfAid,
|
|
1718
|
+
id: triggerId,
|
|
1719
|
+
name: triggerName,
|
|
1720
|
+
prompt,
|
|
1721
|
+
everyMs: input.durationMs,
|
|
1722
|
+
checkEvery: input.checkEveryLabel,
|
|
1723
|
+
channelKey: formatChannelKey({ type: 'aun', selfAID: input.selfAid, name: 'main' }),
|
|
1724
|
+
targetChannelId: input.targetChannelId,
|
|
1725
|
+
targetThreadId: input.targetThreadId,
|
|
1726
|
+
originThreadId,
|
|
1727
|
+
originPeer,
|
|
1728
|
+
feedbackChatType: input.feedbackChatType,
|
|
1729
|
+
originalText: input.contentSummary,
|
|
1730
|
+
firstSentAt: input.timestamp,
|
|
1731
|
+
originThreadName,
|
|
1732
|
+
originPeerName,
|
|
1733
|
+
originPeerType,
|
|
1734
|
+
targetThreadName,
|
|
1735
|
+
});
|
|
1736
|
+
const { response: triggerRes, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
1737
|
+
type: 'trigger.create',
|
|
1738
|
+
definition: triggerDef,
|
|
1739
|
+
files: [],
|
|
1740
|
+
enable: true,
|
|
1741
|
+
// daemon 侧 authenticatedTriggerActor 先看 actorSessionId:缺了它会回落到
|
|
1742
|
+
// controlToken 分支(CLI 从不读 control.token),必然抛
|
|
1743
|
+
// "valid local control token is required"。与 trigger-command.ts 的组装保持一致。
|
|
1744
|
+
actorSessionId: originSessionId,
|
|
1745
|
+
delegationToken: readDelegationCredential(),
|
|
1746
|
+
}, 30_000);
|
|
1747
|
+
if (!triggerRes?.ok) {
|
|
1748
|
+
process.stderr.write(`⚠ Trigger 创建失败: ${triggerRes?.error ?? daemonUnavailableMessage(transportError, 'unknown')}(inbox 仍会写入)\n`);
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
// 以 daemon 落盘的结果为准(definition 已带 id,正常应与预设值相同;
|
|
1752
|
+
// 若 daemon 因任何原因改写了 id,回填真值而不是本地预设值)。
|
|
1753
|
+
createdTriggerId = triggerRes.trigger?.id ?? triggerId;
|
|
1754
|
+
}
|
|
1727
1755
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
// 若 daemon 因任何原因改写了 id,回填真值而不是本地预设值)。
|
|
1731
|
-
createdTriggerId = triggerRes.trigger?.id ?? triggerId;
|
|
1756
|
+
catch (e) {
|
|
1757
|
+
process.stderr.write(`⚠ Trigger 创建异常: ${e?.message ?? e}(inbox 仍会写入)\n`);
|
|
1732
1758
|
}
|
|
1733
1759
|
}
|
|
1734
|
-
catch (e) {
|
|
1735
|
-
process.stderr.write(`⚠ Trigger 创建异常: ${e?.message ?? e}(inbox 仍会写入)\n`);
|
|
1736
|
-
}
|
|
1737
1760
|
const { ThreadService } = await import('../core/thread/index.js');
|
|
1738
1761
|
ThreadService.appendInbox(input.selfAid, {
|
|
1739
1762
|
messageId: input.messageId,
|
|
@@ -1741,6 +1764,10 @@ async function applyCrossThreadSendEffects(input) {
|
|
|
1741
1764
|
timestamp: input.timestamp,
|
|
1742
1765
|
originThreadId,
|
|
1743
1766
|
originPeer,
|
|
1767
|
+
// 显示名随条目落盘:渲染时不必再查话题索引,也保住了改名前的历史值。
|
|
1768
|
+
...(originPeerName && originPeerName !== originPeer ? { originPeerName } : {}),
|
|
1769
|
+
// 主体类型同样落盘:渲染层不能猜,旧条目缺失时退回 unknown。
|
|
1770
|
+
...(originPeerType ? { originPeerType } : {}),
|
|
1744
1771
|
originSessionId,
|
|
1745
1772
|
targetSessionId: input.targetSessionId,
|
|
1746
1773
|
...(createdTriggerId ? { triggerId: createdTriggerId } : {}),
|
|
@@ -1797,7 +1824,7 @@ Options:
|
|
|
1797
1824
|
--channel-name <name> 历史渠道实例名(非 AUN 渠道必须匹配 Agent 配置)
|
|
1798
1825
|
--channel-key <key> 非 AUN 已落盘渠道的完整实例键(与 --peer-id 成对)
|
|
1799
1826
|
--peer-id <id> 非 AUN 渠道的原生对端 ID(与 --channel-key 成对)
|
|
1800
|
-
--check-every <duration> 跨话题发送后自动创建**跨话题复查**(如 5m/30m/2h
|
|
1827
|
+
--check-every <duration|none> 跨话题发送后自动创建**跨话题复查**(如 5m/30m/2h),跨话题时**必填**;none = 不建复查
|
|
1801
1828
|
每 duration 向**目标话题**投递一条【跨话题复查】通知(不新建会话),
|
|
1802
1829
|
由目标话题侧的 agent 在自己的上下文里决定结束/调整周期/继续
|
|
1803
1830
|
Trigger 名:check-<目标threadId>-from-<来源threadId>-<唯一后缀>
|
|
@@ -2368,7 +2395,8 @@ Options:
|
|
|
2368
2395
|
: body.mode === 'file' ? `[file] ${body.filePath}`
|
|
2369
2396
|
: '[payload]',
|
|
2370
2397
|
timestamp: result.timestamp ?? Date.now(),
|
|
2371
|
-
|
|
2398
|
+
// undefined 原样透传(= --check-every none),不要兜底成 5m。
|
|
2399
|
+
durationMs: checkEveryDurationMs,
|
|
2372
2400
|
checkEveryLabel: checkEveryRaw || '5m',
|
|
2373
2401
|
triggerPromptExtra,
|
|
2374
2402
|
});
|
|
@@ -2634,7 +2662,7 @@ Options:
|
|
|
2634
2662
|
--encrypt 强制端到端加密(未指定时使用 daemon 默认值;仅 send)
|
|
2635
2663
|
--no-encrypt 强制明文发送(优先于 --encrypt;仅 send)
|
|
2636
2664
|
--thread <id> 指定话题 ID(仅 send;话题必须存在于本端索引)
|
|
2637
|
-
--check-every
|
|
2665
|
+
--check-every <时长|none> 跨话题发送(带 --thread)时**必填**,创建跨话题复查(如 5m/30m/2h);none = 不建复查
|
|
2638
2666
|
到期向**目标话题**投递【跨话题复查】通知,不新建会话
|
|
2639
2667
|
无值时默认 5m;Trigger 名:check-<目标threadId>-from-<来源threadId>-<唯一后缀>
|
|
2640
2668
|
结束/调整用返回的 trigger_id(trig_…),show/update/delete 只认 id
|
|
@@ -3035,7 +3063,8 @@ g- 是名称的一部分,会完整保留;默认命名格式为 g-10000 至 g
|
|
|
3035
3063
|
: body.mode === 'file' ? `[file] ${body.filePath}`
|
|
3036
3064
|
: '[payload]',
|
|
3037
3065
|
timestamp: r.timestamp ?? Date.now(),
|
|
3038
|
-
|
|
3066
|
+
// undefined 原样透传(= --check-every none),不要兜底成 5m。
|
|
3067
|
+
durationMs: groupCheckEveryMs,
|
|
3039
3068
|
checkEveryLabel: groupCheckEveryRaw || '5m',
|
|
3040
3069
|
triggerPromptExtra: groupTriggerPromptExtra,
|
|
3041
3070
|
});
|
|
@@ -3728,11 +3757,17 @@ export function resolveManagedSendArgv(argv, routing) {
|
|
|
3728
3757
|
let checkEveryMs;
|
|
3729
3758
|
if (thread) {
|
|
3730
3759
|
if (checkEvery === undefined)
|
|
3731
|
-
throw new Error('Cross-thread sends require --check-every');
|
|
3732
|
-
|
|
3733
|
-
if (
|
|
3734
|
-
|
|
3735
|
-
|
|
3760
|
+
throw new Error('Cross-thread sends require --check-every (or "none")');
|
|
3761
|
+
// `none` = 跨话题发送但不建复查 Trigger;checkEveryMs 保持 undefined,下游据此跳过建 Trigger。
|
|
3762
|
+
if (checkEvery.trim().toLowerCase() === 'none') {
|
|
3763
|
+
checkEveryMs = undefined;
|
|
3764
|
+
}
|
|
3765
|
+
else {
|
|
3766
|
+
const parsedCheckEveryMs = parseDuration(checkEvery);
|
|
3767
|
+
if (parsedCheckEveryMs === null)
|
|
3768
|
+
throw new Error('Invalid --check-every duration');
|
|
3769
|
+
checkEveryMs = parsedCheckEveryMs;
|
|
3770
|
+
}
|
|
3736
3771
|
}
|
|
3737
3772
|
if (scope === 'msg' && (mentions.length || booleans.has('--mention-all')))
|
|
3738
3773
|
throw new Error('Mentions require a group send');
|