evolcore 0.0.41 → 0.0.42
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 +36 -0
- package/bin/codex-managed-hook.mjs +9 -5
- package/dist/agents/baseagent.js +156 -16
- package/dist/agents/claude-runner.js +10 -3
- package/dist/agents/codex/catalog.js +8 -4
- package/dist/agents/codex-runner.js +236 -59
- package/dist/agents/ecagent-runner.js +82 -13
- package/dist/aun/aid/agentmd.js +106 -27
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +65 -13
- package/dist/aun/aid/identity.js +70 -4
- package/dist/aun/aid/index.js +2 -2
- package/dist/aun/service-proxy.js +25 -1
- package/dist/channels/aun.js +242 -209
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +1 -1
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +1 -1
- package/dist/channels/wecom.js +1 -1
- package/dist/cli/agent-command.js +183 -3
- package/dist/cli/agent-create.js +92 -86
- package/dist/cli/agent.js +136 -1
- package/dist/cli/aun-commands.js +137 -35
- package/dist/cli/bench.js +8 -2
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +235 -51
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/directory.js +170 -0
- package/dist/cli/index.js +40 -30
- package/dist/cli/init-channel.js +4 -4
- package/dist/cli/init.js +47 -32
- package/dist/cli/managed-command-guard.js +4 -1
- package/dist/cli/model.js +27 -18
- package/dist/cli/pa-workspace-command.js +191 -0
- package/dist/cli/{contact.js → peer.js} +19 -25
- package/dist/cli/restart-monitor.js +11 -4
- package/dist/cli/thread-command.js +47 -18
- package/dist/cli/version.js +18 -18
- package/dist/config/access-policy.js +29 -12
- package/dist/config/boot-log.js +65 -10
- package/dist/config/builtin-roles.js +2 -4
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +28 -20
- package/dist/config/{contact-bind-code.js → peer-bind-code.js} +6 -6
- package/dist/config/{contact-book-store.js → peer-book-store.js} +75 -75
- package/dist/config/{contact-book-v2-startup.js → peer-book-v2-startup.js} +2 -2
- package/dist/config/{contact-book.js → peer-book.js} +47 -47
- package/dist/config/peer-operation-service.js +132 -0
- package/dist/config/{contact-request-service.js → peer-request-service.js} +90 -90
- package/dist/config/peer-role-resolver.js +3 -3
- package/dist/config/providers-config.js +17 -8
- package/dist/config/providers.js +1 -1
- package/dist/config/schema-migration.js +336 -39
- package/dist/core/agent-application-service.js +8 -2
- package/dist/core/agent-create-status.js +4 -5
- package/dist/core/agent-ipc-registration.js +5 -4
- package/dist/core/agent-runtime.js +30 -17
- package/dist/core/auth/operation-authorizer.js +0 -24
- package/dist/core/auth/operation-catalog.js +4 -20
- package/dist/core/baseagent-loader.js +27 -3
- package/dist/core/bootstrap-service.js +5 -22
- package/dist/core/capability/capability-manager.js +52 -35
- package/dist/core/channel-loader.js +43 -2
- package/dist/core/channel-runtime.js +2 -2
- package/dist/core/command/agent-control.js +54 -18
- package/dist/core/command/command-handler.js +92 -72
- package/dist/core/command/connect-menu.js +35 -42
- package/dist/core/command/daemon-diagnostics.js +41 -5
- package/dist/core/command/data-root-error.js +10 -0
- package/dist/core/command/data-root-resolver.js +53 -13
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +163 -65
- package/dist/core/command/menu-protocol.js +52 -0
- package/dist/core/command/pa-workspace-calendar.js +223 -0
- package/dist/core/command/pa-workspace-store.js +459 -0
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +57 -41
- package/dist/core/daemon-lifecycle.js +90 -31
- package/dist/core/evolagent.js +6 -10
- package/dist/core/handoff/runtime.js +11 -4
- package/dist/core/host-snapshot.js +208 -0
- package/dist/core/initialization/service.js +152 -20
- package/dist/core/ipc-registration.js +33 -4
- package/dist/core/memory/batch-meta.js +27 -0
- package/dist/core/memory/consolidation-ops-records.js +44 -1
- package/dist/core/memory/consolidation.js +169 -27
- package/dist/core/message/aun-ipc-sender.js +2 -8
- package/dist/core/message/im-renderer.js +56 -3
- package/dist/core/message/message-admission.js +121 -124
- package/dist/core/message/message-bridge.js +38 -54
- package/dist/core/message/message-queue.js +7 -0
- package/dist/core/message/outbound.js +34 -9
- package/dist/core/message/response-engine.js +154 -73
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +2 -2
- package/dist/core/model/model-catalog.js +5 -4
- package/dist/core/model/model-diagnostics.js +6 -5
- package/dist/core/model/model-fallback.js +3 -6
- package/dist/core/model/model-permission.js +1 -1
- package/dist/core/ownership/owner-resolver.js +9 -9
- package/dist/core/permission/approval-gateway.js +1 -1
- package/dist/core/permission/ec-command-parser.js +2 -2
- package/dist/core/permission/tool-canonical.js +96 -46
- package/dist/core/permission/tool-error-code.js +41 -0
- package/dist/core/permission/tool-policy.js +71 -47
- package/dist/core/role/runtime-policy.js +1 -1
- package/dist/core/session/session-idle-monitor.js +10 -0
- package/dist/core/session/session-manager.js +2 -4
- package/dist/core/session/session-title.js +36 -8
- package/dist/core/system-session/memory.js +2 -7
- package/dist/core/thread/command-parser.js +6 -2
- package/dist/core/thread/ipc-operation.js +51 -36
- package/dist/core/thread/thread-operation.js +29 -61
- package/dist/core/thread/thread-service.js +57 -13
- package/dist/directory/canonical-digest.js +54 -0
- package/dist/directory/owner-directory-admission.js +114 -43
- package/dist/directory/owner-directory-agentmd-sync.js +89 -0
- package/dist/directory/owner-directory-cache.js +847 -459
- package/dist/directory/owner-directory-markdown.js +272 -0
- package/dist/directory/owner-directory-query-operation.js +195 -0
- package/dist/directory/owner-directory-remark-operation.js +147 -0
- package/dist/directory/owner-directory-remarks.js +145 -0
- package/dist/directory/owner-directory-scope.js +55 -0
- package/dist/directory/owner-directory-search.js +148 -0
- package/dist/directory/owner-directory-store.js +227 -0
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/message-context-service.js +13 -9
- package/dist/index.js +195 -37
- package/dist/ipc.js +86 -22
- package/dist/paths.js +11 -8
- package/dist/product.js +2 -0
- package/dist/proxy/manager.js +13 -2
- package/dist/proxy/service-supervisor.js +8 -1
- package/dist/trigger/history.js +23 -0
- package/dist/trigger/scheduler.js +3 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/cross-platform.js +35 -0
- package/dist/utils/ecweb-supervisor.js +42 -0
- package/dist/utils/error-utils.js +2 -1
- package/dist/utils/evolcore-version.js +19 -0
- package/dist/utils/host-info.js +242 -5
- package/dist/utils/instance-registry.js +28 -6
- package/dist/utils/logger.js +59 -14
- package/dist/utils/machine-info.js +46 -0
- package/dist/utils/process-introspect.js +166 -2
- package/dist/utils/startup-trace.js +245 -0
- package/ecagent/dist/agent-loop.js +27 -13
- package/ecagent/dist/harness/agent-harness.js +3 -3
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +72 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +17 -27
- package/kits/docs/evolcore/agent.md +4 -1
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +16 -5
- package/kits/docs/evolcore/ctl.md +9 -0
- package/kits/docs/evolcore/ec-capabilities.md +19 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +79 -5
- package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -1
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +13 -4
- package/kits/docs/evolcore/msg.md +1 -1
- package/kits/docs/evolcore/pa-workspace.md +51 -0
- package/kits/docs/evolcore/peer.md +73 -0
- package/kits/docs/evolcore/thread-chain.md +4 -1
- package/kits/eck_manifest.json +21 -0
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/agent-config.schema.16.json +6 -0
- package/kits/schemas/agent-config.schema.17.json +897 -0
- package/kits/schemas/daemon.schema.9.json +8 -1
- package/kits/skills/ec-agent-create/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +45 -27
- package/kits/skills/ec-service-proxy/SKILL.md +7 -2
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +4 -5
- package/kits/skills/thread-ops/SKILL.md +11 -11
- package/kits/templates/bootstrap-welcome.md +3 -15
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +24 -23
- package/kits/templates/system-fragments/commands.md +12 -5
- package/kits/templates/system-fragments/thread.md +18 -3
- package/package.json +6 -4
- package/dist/config/contact-operation-service.js +0 -235
- package/dist/directory/owner-directory-authorization.js +0 -309
- package/kits/docs/evolcore/contact.md +0 -78
- /package/dist/config/{contact-alias.js → peer-alias.js} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isDeliveryTargetForChannel } from './message-utils.js';
|
|
2
|
-
import { readEvolcoreRuntimeFlavor, readEvolcoreStartedAtIso, readInstalledEvolcoreVersion, tagErrorTextWithEvolcoreVersion, } from '../../utils/evolcore-version.js';
|
|
2
|
+
import { readEvolcoreRuntimeFlavor, readEvolcoreStartedAtIso, readInstalledEvolcoreVersion, errorTextContainsRaw, tagErrorTextWithEvolcoreVersion, } from '../../utils/evolcore-version.js';
|
|
3
3
|
import { getErrorRawText } from '../../utils/error-utils.js';
|
|
4
|
+
import { logPreview } from '../../utils/logger.js';
|
|
4
5
|
function appendRawErrorText(text, raw) {
|
|
5
|
-
if (!raw || text
|
|
6
|
+
if (!raw || errorTextContainsRaw(text, raw))
|
|
6
7
|
return text;
|
|
7
8
|
return `${text}\n原因:${raw}`;
|
|
8
9
|
}
|
|
@@ -70,21 +71,45 @@ export function summarizeOutboundPayload(payload) {
|
|
|
70
71
|
if (!payload)
|
|
71
72
|
return { kind: 'unknown' };
|
|
72
73
|
const summary = { kind: payload.kind };
|
|
74
|
+
const addTextPreview = (value) => {
|
|
75
|
+
if (typeof value !== 'string')
|
|
76
|
+
return;
|
|
77
|
+
summary.textPreview = logPreview(value);
|
|
78
|
+
// Keep the historical field usable for consumers while bounding its value.
|
|
79
|
+
summary.text = summary.textPreview;
|
|
80
|
+
summary.textBytes = Buffer.byteLength(value, 'utf8');
|
|
81
|
+
};
|
|
82
|
+
const addMetadata = (value) => {
|
|
83
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
84
|
+
return;
|
|
85
|
+
const metadata = { ...value };
|
|
86
|
+
if (typeof metadata.message === 'string')
|
|
87
|
+
metadata.message = logPreview(metadata.message);
|
|
88
|
+
if (typeof metadata.raw === 'string') {
|
|
89
|
+
metadata.rawPreview = logPreview(metadata.raw);
|
|
90
|
+
delete metadata.raw;
|
|
91
|
+
}
|
|
92
|
+
if (typeof metadata.text === 'string')
|
|
93
|
+
metadata.text = logPreview(metadata.text);
|
|
94
|
+
summary.metadata = metadata;
|
|
95
|
+
};
|
|
73
96
|
switch (payload.kind) {
|
|
74
97
|
case 'activity.batch':
|
|
75
98
|
summary.itemCount = payload.items?.length ?? 0;
|
|
76
|
-
summary.
|
|
99
|
+
summary.itemKinds = Array.isArray(payload.items)
|
|
100
|
+
? payload.items.slice(0, 32).map((item) => item?.kind).filter((kind) => typeof kind === 'string')
|
|
101
|
+
: [];
|
|
77
102
|
break;
|
|
78
103
|
case 'result.text':
|
|
79
104
|
summary.isFinal = payload.isFinal;
|
|
80
|
-
|
|
105
|
+
addTextPreview(payload.text);
|
|
81
106
|
break;
|
|
82
107
|
case 'command.result':
|
|
83
108
|
case 'command.error':
|
|
84
109
|
case 'result.error':
|
|
85
|
-
|
|
110
|
+
addTextPreview(payload.text);
|
|
86
111
|
if (payload.raw !== undefined)
|
|
87
|
-
summary.
|
|
112
|
+
summary.rawPreview = logPreview(payload.raw);
|
|
88
113
|
break;
|
|
89
114
|
case 'result.file':
|
|
90
115
|
summary.filePath = payload.filePath;
|
|
@@ -92,9 +117,9 @@ export function summarizeOutboundPayload(payload) {
|
|
|
92
117
|
case 'system.notice':
|
|
93
118
|
case 'system.error':
|
|
94
119
|
summary.subtype = payload.subtype;
|
|
95
|
-
|
|
120
|
+
addTextPreview(payload.text);
|
|
96
121
|
if (payload.raw !== undefined)
|
|
97
|
-
summary.
|
|
122
|
+
summary.rawPreview = logPreview(payload.raw);
|
|
98
123
|
break;
|
|
99
124
|
case 'interaction':
|
|
100
125
|
summary.interactionId = payload.interaction?.id;
|
|
@@ -109,7 +134,7 @@ export function summarizeOutboundPayload(payload) {
|
|
|
109
134
|
case 'status.interrupted':
|
|
110
135
|
case 'status.error':
|
|
111
136
|
case 'status.timeout':
|
|
112
|
-
|
|
137
|
+
addMetadata(payload.metadata);
|
|
113
138
|
break;
|
|
114
139
|
}
|
|
115
140
|
return summary;
|
|
@@ -17,6 +17,7 @@ import { IMRenderer } from './im-renderer.js';
|
|
|
17
17
|
import { projectSubtaskStarted, projectSubtaskTerminal } from './subtask-tool-projection.js';
|
|
18
18
|
import { TaskActivityStore } from '../task/task-activity-store.js';
|
|
19
19
|
import { createSendFileMarkerPattern } from './file-markers.js';
|
|
20
|
+
import { hasOwnerDirectoryMarkdown } from '../../directory/owner-directory-markdown.js';
|
|
20
21
|
import { createDecisionInferenceProvider, createTextInferenceProvider } from '../inference/text-inference.js';
|
|
21
22
|
import { StreamIdleMonitor } from './stream-idle-monitor.js';
|
|
22
23
|
import { logger } from '../../utils/logger.js';
|
|
@@ -34,7 +35,7 @@ import { syncGroupRulesContext } from '../../eck/group-rules-sync.js';
|
|
|
34
35
|
import { claimHints, commitHintClaim, releaseHintClaim, peekHints, hintsToSubMessages, composeHintFallback, OBSERVER_HINT_FAILURE_MESSAGES, } from './pending-hints.js';
|
|
35
36
|
import { createRootCausation, deriveCausation, normalizeCausation } from '../causation/context.js';
|
|
36
37
|
import { recordCausationLink, recordCausationSpan } from '../causation/audit.js';
|
|
37
|
-
import { normalizeBaseagent } from '../../agents/baseagent.js';
|
|
38
|
+
import { normalizeBaseagent, resolveBaseagentModelSelection, resolveRuntimeBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
38
39
|
import { renderActionAsText } from '../interaction-router.js';
|
|
39
40
|
import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
|
|
40
41
|
import { buildEnvelope, isInteractionSendAccepted, replyContextFromSession, sendInteractionPayload, withEnvelopeReplyContext } from './message-utils.js';
|
|
@@ -1107,6 +1108,19 @@ function isNonErrorInterruptReason(reason) {
|
|
|
1107
1108
|
function isExpectedTerminalInterrupt(reason) {
|
|
1108
1109
|
return isAbortTerminalReason(reason);
|
|
1109
1110
|
}
|
|
1111
|
+
export function isExpectedStreamInterrupt(terminalReason, interruptReason) {
|
|
1112
|
+
return isExpectedTerminalInterrupt(terminalReason) || isNonErrorInterruptReason(interruptReason);
|
|
1113
|
+
}
|
|
1114
|
+
export async function projectTerminalReply(projection) {
|
|
1115
|
+
if (!projection.isCurrent() || projection.isInterrupted() || projection.isNoop)
|
|
1116
|
+
return false;
|
|
1117
|
+
if (projection.isError) {
|
|
1118
|
+
return projection.text || projection.diagnosticText ? projection.sendError() : false;
|
|
1119
|
+
}
|
|
1120
|
+
if (projection.text && projection.needsTextProjection)
|
|
1121
|
+
await projection.addText(projection.text);
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1110
1124
|
function formatRetryableErrorFinalMessage(error, retries) {
|
|
1111
1125
|
const reason = getErrorRawText(error) || 'API 暂时不可用';
|
|
1112
1126
|
return `❌ API 暂时不可用,已自动重试 ${retries} 次仍失败,任务已停止。\n原因:${reason}`;
|
|
@@ -1673,6 +1687,37 @@ export class ResponseEngine {
|
|
|
1673
1687
|
observerHintFailed;
|
|
1674
1688
|
observerHintFailureReported = new WeakMap();
|
|
1675
1689
|
scheduledObserverHints = new Set();
|
|
1690
|
+
/**
|
|
1691
|
+
* 自动回填会话名之后的同步钩子:更新话题索引并向对端发 `topic.renamed`。
|
|
1692
|
+
* 由 daemon 组装时注入(`index.ts`),测试/嵌入路径不注入即退回纯本地改名。
|
|
1693
|
+
*/
|
|
1694
|
+
sessionTitleSyncer;
|
|
1695
|
+
setSessionTitleSyncer(fn) {
|
|
1696
|
+
this.sessionTitleSyncer = fn;
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* 自动回填会话名称。
|
|
1700
|
+
*
|
|
1701
|
+
* 同步器存在时由它统一改写(索引 + 落盘 + 发通知);它返回 false 表示
|
|
1702
|
+
* “没有可同步的话题目标”,退回只改本地会话名。同步器抛错同样退回本地改名——
|
|
1703
|
+
* 自动命名失败不能把一个已完成的 turn 变成错误。
|
|
1704
|
+
*/
|
|
1705
|
+
async autoFillSessionTitle(session, title) {
|
|
1706
|
+
if (this.sessionTitleSyncer) {
|
|
1707
|
+
try {
|
|
1708
|
+
const handled = await this.sessionTitleSyncer(session, title);
|
|
1709
|
+
if (handled !== false) {
|
|
1710
|
+
logger.info(`[ResponseEngine] Auto-filled session name: ${title}`);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
catch (error) {
|
|
1715
|
+
logger.debug(`[ResponseEngine] Auto-fill sync failed, falling back to local rename: ${error instanceof Error ? error.message : String(error)}`);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
await this.sessionManager.renameSession(session.id, title);
|
|
1719
|
+
logger.info(`[ResponseEngine] Auto-filled session name: ${title}`);
|
|
1720
|
+
}
|
|
1676
1721
|
setObserverHintConsumed(fn) {
|
|
1677
1722
|
this.observerHintConsumed = fn;
|
|
1678
1723
|
}
|
|
@@ -3732,7 +3777,7 @@ export class ResponseEngine {
|
|
|
3732
3777
|
: configuredMiddleOutputMode;
|
|
3733
3778
|
outputState.middleOutputMode = middleOutputMode;
|
|
3734
3779
|
// 诊断日志:记录 inbound message_id 和生成的 task_id 的对应关系
|
|
3735
|
-
logger.info(`[ResponseEngine]
|
|
3780
|
+
logger.info(`[ResponseEngine] task.started: inboundMsgId=${message.messageId ?? 'none'} taskId=${taskId} sessionId=${session.id} chatmode=${chatmode} mode=${resolvedMode?.mode.id ?? 'override/fallback'}`);
|
|
3736
3781
|
{
|
|
3737
3782
|
import('../../utils/msg-diag.js').then(m => m.diagLog('task_created', { aid: session.selfAID ?? '', msgId: message.messageId ?? '', taskId, text: message.content ?? '' })).catch(() => { });
|
|
3738
3783
|
}
|
|
@@ -4051,7 +4096,7 @@ export class ResponseEngine {
|
|
|
4051
4096
|
return;
|
|
4052
4097
|
}
|
|
4053
4098
|
}
|
|
4054
|
-
// ──
|
|
4099
|
+
// ── 模型按 Agent → defaults → 本机 CLI 配置 → runner 默认值解析 ──
|
|
4055
4100
|
{
|
|
4056
4101
|
if (effectiveAgentConfigError) {
|
|
4057
4102
|
this.touchAgentActivity(channelKey);
|
|
@@ -4068,8 +4113,26 @@ export class ResponseEngine {
|
|
|
4068
4113
|
return;
|
|
4069
4114
|
}
|
|
4070
4115
|
const modelBaseagent = normalizeBaseagent(agent.name).canonical;
|
|
4071
|
-
const
|
|
4116
|
+
const configuredBaseagent = modelBaseagent === 'unknown'
|
|
4117
|
+
? undefined : effectiveAgentConfig?.baseagents?.[modelBaseagent];
|
|
4072
4118
|
const triggerModel = message.triggerMeta?.modelOverride;
|
|
4119
|
+
let agentModel;
|
|
4120
|
+
let modelFailure;
|
|
4121
|
+
try {
|
|
4122
|
+
agentModel = typeof triggerModel === 'string' && triggerModel.trim()
|
|
4123
|
+
? triggerModel
|
|
4124
|
+
: (await resolveRuntimeBaseagentModelSelection(modelBaseagent, configuredBaseagent))?.model;
|
|
4125
|
+
}
|
|
4126
|
+
catch (error) {
|
|
4127
|
+
const code = error?.code;
|
|
4128
|
+
modelFailure = isHostChinese()
|
|
4129
|
+
? error instanceof Error ? error.message : '模型目录不可用'
|
|
4130
|
+
: code === 'CODEX_MODEL_UNAVAILABLE'
|
|
4131
|
+
? 'No configured Codex model or available gpt[*]terra in the app-server catalog. Set baseagents.codex.model or config.toml.model.'
|
|
4132
|
+
: code === 'ECAGENT_MODEL_UNAVAILABLE'
|
|
4133
|
+
? 'No configured ecagent model or available deepseek[*]flash in the selected Provider catalog. Set baseagents.ecagent.model.'
|
|
4134
|
+
: undefined;
|
|
4135
|
+
}
|
|
4073
4136
|
const hasModel = (typeof agentModel === 'string' && agentModel.trim().length > 0)
|
|
4074
4137
|
|| (typeof triggerModel === 'string' && triggerModel.trim().length > 0);
|
|
4075
4138
|
if (modelBaseagent !== 'unknown' && !hasModel) {
|
|
@@ -4078,8 +4141,8 @@ export class ResponseEngine {
|
|
|
4078
4141
|
adapter.send(envelope, {
|
|
4079
4142
|
kind: 'system.error',
|
|
4080
4143
|
text: isHostChinese()
|
|
4081
|
-
? `⚠️
|
|
4082
|
-
: `⚠️ This Agent has no model configured (baseagents.${modelBaseagent}.model) and cannot reply. An Agent owner/admin must set one with /model
|
|
4144
|
+
? `⚠️ ${modelFailure ?? `当前 Agent 未配置模型(baseagents.${modelBaseagent}.model),无法回复。请 Agent 的 owner/admin 使用 /model 设置模型。`}`
|
|
4145
|
+
: `⚠️ ${modelFailure ?? `This Agent has no model configured (baseagents.${modelBaseagent}.model) and cannot reply. An Agent owner/admin must set one with /model.`}`,
|
|
4083
4146
|
subtype: 'model_not_configured',
|
|
4084
4147
|
recoverable: false,
|
|
4085
4148
|
}).catch(() => { });
|
|
@@ -4101,7 +4164,7 @@ export class ResponseEngine {
|
|
|
4101
4164
|
const peerId = message.peerId ?? session.metadata?.peerId ?? message.channelId;
|
|
4102
4165
|
const peerShort = peerId ? peerId.split('.')[0].split(':')[0] : '?';
|
|
4103
4166
|
const peerLabel = peerName && peerName !== peerShort ? `${peerShort}(${peerName})` : peerShort;
|
|
4104
|
-
logger.
|
|
4167
|
+
logger.debug(`[ResponseEngine] session=${session.id} task=${taskId} peer=${peerLabel} chatType=${session.chatType} chatMode=${effectiveChatMode} baseagent=${session.baseagent} msgChatType=${message.chatType ?? 'n/a'}`);
|
|
4105
4168
|
// Establish the durable turn before exposing any processing state. This
|
|
4106
4169
|
// lets an immediate /stop or replacement message close the same task and
|
|
4107
4170
|
// prevents a BusinessTrip reaction from becoming orphaned during setup.
|
|
@@ -4506,6 +4569,11 @@ export class ResponseEngine {
|
|
|
4506
4569
|
approvalInteractionPolicy,
|
|
4507
4570
|
permissionMode: effectivePermissionMode,
|
|
4508
4571
|
recordExecutionAnomaly,
|
|
4572
|
+
recordPreflightDenial: activity => {
|
|
4573
|
+
if (turnLease && !this.turnCoordinator.isCurrent(turnLease))
|
|
4574
|
+
return;
|
|
4575
|
+
renderer.addPreflightDenial(activity);
|
|
4576
|
+
},
|
|
4509
4577
|
pauseController: taskPauseController,
|
|
4510
4578
|
preToolUsePolicyHook: purePreToolUsePolicyHook,
|
|
4511
4579
|
onProactiveCircuitBreak: requestProactiveCircuitBreak,
|
|
@@ -4670,7 +4738,7 @@ export class ResponseEngine {
|
|
|
4670
4738
|
if (message.replyContext?.metadata?.encrypted != null) {
|
|
4671
4739
|
this.sessionManager.setSessionEncrypt(session.id, !!(message.replyContext.metadata.encrypted));
|
|
4672
4740
|
}
|
|
4673
|
-
logger.
|
|
4741
|
+
logger.debug(`[ResponseEngine] session ${session.id} marked as processing task=${taskId}`);
|
|
4674
4742
|
// 检查是否因新消息自动中断 — 包装 prompt 让 Agent 知道上下文
|
|
4675
4743
|
const prevInterruptReason = this.interruptedSessions.get(session.id);
|
|
4676
4744
|
this.interruptedSessions.delete(session.id);
|
|
@@ -4804,7 +4872,7 @@ export class ResponseEngine {
|
|
|
4804
4872
|
fullAccessMessagePromptContext = fullAccessAuthorization
|
|
4805
4873
|
? FULL_ACCESS_MESSAGE_PROMPT_CONTEXT
|
|
4806
4874
|
: undefined;
|
|
4807
|
-
//
|
|
4875
|
+
// 模型/强度按配置、CLI 和 runner 默认值解析后,经角色约束传入 runQuery。
|
|
4808
4876
|
// 不缓存、不绑会话——改 Agent 级后该 Agent 所有会话的下条消息即时生效;
|
|
4809
4877
|
// 多对端并发各自独立解析、各自传参,无共享状态可被污染。
|
|
4810
4878
|
let effectiveModel;
|
|
@@ -4820,10 +4888,18 @@ export class ResponseEngine {
|
|
|
4820
4888
|
const selector = { self: selfAid || undefined, peerKey };
|
|
4821
4889
|
const modelResolution = resolveEffectiveFieldWithSource(`baseagents.${normalizedBaseagent.canonical}.model`, selector, { cache: true });
|
|
4822
4890
|
const effortResolution = resolveEffectiveFieldWithSource(`baseagents.${normalizedBaseagent.canonical}.effort`, selector, { cache: true });
|
|
4891
|
+
const fallbackSelection = resolveBaseagentModelSelection(normalizedBaseagent.canonical, {
|
|
4892
|
+
...(normalizedBaseagent.canonical === 'unknown'
|
|
4893
|
+
? undefined : effectiveAgentConfig?.baseagents?.[normalizedBaseagent.canonical]),
|
|
4894
|
+
model: modelResolution.value,
|
|
4895
|
+
effort: effortResolution.value,
|
|
4896
|
+
});
|
|
4897
|
+
const resolvedModel = fallbackSelection?.model ?? modelResolution.value;
|
|
4898
|
+
const resolvedEffort = fallbackSelection?.effort ?? effortResolution.value;
|
|
4823
4899
|
const modelDecision = constrainResolvedModelForRole({
|
|
4824
4900
|
role: peerRole,
|
|
4825
4901
|
baseagent: normalizedBaseagent.canonical,
|
|
4826
|
-
model:
|
|
4902
|
+
model: resolvedModel,
|
|
4827
4903
|
resolveModelId: typeof agent.resolveModelId === 'function'
|
|
4828
4904
|
? agent.resolveModelId.bind(agent)
|
|
4829
4905
|
: undefined,
|
|
@@ -4835,22 +4911,24 @@ export class ResponseEngine {
|
|
|
4835
4911
|
selfAid: selfAid || undefined,
|
|
4836
4912
|
role: peerRole,
|
|
4837
4913
|
field: effortField,
|
|
4838
|
-
configuredValue:
|
|
4914
|
+
configuredValue: resolvedEffort,
|
|
4839
4915
|
});
|
|
4840
4916
|
const effectiveEffortValue = effortDecision.effectiveValue;
|
|
4841
4917
|
const effort = effectiveEffortValue === 'auto' ? undefined : effectiveEffortValue;
|
|
4842
4918
|
effectiveModelSource = modelDecision.constrained
|
|
4843
4919
|
? 'role'
|
|
4844
|
-
:
|
|
4920
|
+
: fallbackSelection?.modelSource === 'configured' && modelResolution.source
|
|
4921
|
+
? `${modelResolution.source.target}:${modelResolution.source.file}`
|
|
4922
|
+
: fallbackSelection?.modelSource;
|
|
4845
4923
|
effectiveEffortSource = effortDecision.decidedBy === 'role'
|
|
4846
4924
|
? 'role'
|
|
4847
|
-
: effortResolution.source
|
|
4925
|
+
: fallbackSelection?.effortSource === 'configured' && effortResolution.source
|
|
4848
4926
|
? `${effortResolution.source.target}:${effortResolution.source.file}`
|
|
4849
|
-
:
|
|
4850
|
-
if (model
|
|
4927
|
+
: fallbackSelection?.effortSource;
|
|
4928
|
+
if (model) {
|
|
4851
4929
|
evolcoreModelOverride = {
|
|
4852
4930
|
model,
|
|
4853
|
-
effort,
|
|
4931
|
+
...(effort ? { effort } : { effortMode: 'model_default' }),
|
|
4854
4932
|
};
|
|
4855
4933
|
effectiveModel = model;
|
|
4856
4934
|
}
|
|
@@ -4894,10 +4972,14 @@ export class ResponseEngine {
|
|
|
4894
4972
|
});
|
|
4895
4973
|
const triggerEffort = triggerEffortDecision.effectiveValue;
|
|
4896
4974
|
const effectiveTriggerEffort = triggerEffort === 'auto' ? undefined : triggerEffort;
|
|
4897
|
-
if (effectiveTriggerEffort)
|
|
4975
|
+
if (effectiveTriggerEffort) {
|
|
4898
4976
|
constrainedOverride.effort = effectiveTriggerEffort;
|
|
4899
|
-
|
|
4977
|
+
delete constrainedOverride.effortMode;
|
|
4978
|
+
}
|
|
4979
|
+
else {
|
|
4900
4980
|
delete constrainedOverride.effort;
|
|
4981
|
+
constrainedOverride.effortMode = 'model_default';
|
|
4982
|
+
}
|
|
4901
4983
|
effectiveEffort = triggerEffort;
|
|
4902
4984
|
effectiveEffortSource = triggerEffortDecision.decidedBy === 'role' ? 'role' : 'trigger';
|
|
4903
4985
|
}
|
|
@@ -5107,6 +5189,11 @@ export class ResponseEngine {
|
|
|
5107
5189
|
// AGENT_DIR 是 manifest 的合法别名(buildPathMappings 有注册),
|
|
5108
5190
|
// 缺了它引用 $AGENT_DIR 的段(如技能索引)会整段静默丢弃。
|
|
5109
5191
|
AGENT_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid) : undefined,
|
|
5192
|
+
// 名录注入判据:只看 directory.md 是否存在且非空。不在这里解析快照——
|
|
5193
|
+
// 这个变量每轮渲染都要算,一次 stat 的代价必须保持在这个量级。
|
|
5194
|
+
hasOwnerDirectory: selfAid
|
|
5195
|
+
? hasOwnerDirectoryMarkdown(path.join(resolveRoot(), 'agents', selfAid, 'directory'))
|
|
5196
|
+
: false,
|
|
5110
5197
|
PERSONAL_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid, 'personal') : undefined,
|
|
5111
5198
|
RELATIONS_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid, 'relations') : undefined,
|
|
5112
5199
|
VENUES_DIR: selfAid ? path.join(resolveRoot(), 'agents', selfAid, 'venues') : undefined,
|
|
@@ -5530,7 +5617,7 @@ export class ResponseEngine {
|
|
|
5530
5617
|
const shouldTimeoutRetryAttempt = retryScheduler.shouldTimeoutAttempt() && apiRetryTimeoutMs !== undefined;
|
|
5531
5618
|
let attemptTimeout;
|
|
5532
5619
|
try {
|
|
5533
|
-
logger.
|
|
5620
|
+
logger.debug(`[ResponseEngine] agent.runQuery start: agent=${agent.name} session=${session.id} task=${taskId} attempt=${runAttempt} apiRetries=${retryScheduler.apiRetryAttemptsMade} agentSessionId=${runAgentSessionId ?? 'none'} topicBinding=${isTopicSession(session) ? 'authoritative' : 'legacy'}`);
|
|
5534
5621
|
import('../../utils/msg-diag.js').then(m => m.diagLog('task_start', { aid: session.selfAID ?? '', msgId: message.messageId ?? '', taskId, sessionId: runAgentSessionId ?? undefined, text: message.content ?? '' })).catch(() => { });
|
|
5535
5622
|
await this.assertCurrentExecutionAuthorization(permissionContext, agent);
|
|
5536
5623
|
if (fullAccessAuthorization) {
|
|
@@ -6138,60 +6225,46 @@ export class ResponseEngine {
|
|
|
6138
6225
|
await this.publishTriggerExecutionInterrupted(message, adapter, envelope, 'stale_turn', taskCausation);
|
|
6139
6226
|
return;
|
|
6140
6227
|
}
|
|
6141
|
-
const terminalInterrupt =
|
|
6228
|
+
const terminalInterrupt = isExpectedStreamInterrupt(streamResult.terminalReason, this.interruptedSessions.get(session.id));
|
|
6142
6229
|
const streamRecoverable = !permissionTerminalFailure
|
|
6143
6230
|
&& !isExpectedTerminalInterrupt(streamResult.terminalReason)
|
|
6144
6231
|
&& isRetryableError(new Error(getStreamErrorText(streamResult)));
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
? (streamResult.syntheticDiagnosticText || getStreamErrorMessage(streamResult, false))
|
|
6159
|
-
: visibleFinalReplyText;
|
|
6160
|
-
if (streamResult.isError) {
|
|
6161
|
-
// 用原始诊断文本(含错误码)判断可重试性,不用已过 stripContextLimitErrorLines 的展示文本
|
|
6232
|
+
sentErrorAsSystemError = await projectTerminalReply({
|
|
6233
|
+
isCurrent: () => !turnLease || this.turnCoordinator.canPublish(turnLease),
|
|
6234
|
+
isInterrupted: () => terminalInterrupt || isNonErrorInterruptReason(this.interruptedSessions.get(session.id)),
|
|
6235
|
+
isNoop: isTriggerNoop,
|
|
6236
|
+
isError: streamResult.isError,
|
|
6237
|
+
text: visibleFinalReplyText,
|
|
6238
|
+
diagnosticText: streamResult.syntheticDiagnosticText,
|
|
6239
|
+
needsTextProjection: shouldSuppress() || !streamResult.hasProjectedCurrentReplyText,
|
|
6240
|
+
addText: async (text) => { await renderer.addText(text, undefined, undefined, streamResult.assistantUuid); },
|
|
6241
|
+
sendError: async () => {
|
|
6242
|
+
if (this.isTrustedDaemonTrigger(message))
|
|
6243
|
+
return false;
|
|
6244
|
+
const errorText = streamResult.syntheticDiagnosticText || getStreamErrorMessage(streamResult, false);
|
|
6162
6245
|
const subtype = normalizeCoreErrorSubtype(new Error(streamRawErrorText || getStreamErrorText(streamResult)), streamResult.subtype, streamResult.terminalReason);
|
|
6163
6246
|
const reason = normalizeCoreErrorReason(streamResult.terminalReason);
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
...(reason ? { reason } : {}),
|
|
6176
|
-
recoverable: streamRecoverable,
|
|
6177
|
-
}).catch(() => { });
|
|
6178
|
-
sentErrorAsSystemError = true;
|
|
6179
|
-
}
|
|
6180
|
-
}
|
|
6181
|
-
else if (visibleFinalReplyText && (shouldSuppress() || !streamResult.hasProjectedCurrentReplyText)) {
|
|
6182
|
-
await renderer.addText(visibleFinalReplyText, undefined, undefined, streamResult.assistantUuid);
|
|
6183
|
-
}
|
|
6184
|
-
}
|
|
6247
|
+
await adapter.send(envelope, {
|
|
6248
|
+
kind: 'system.error',
|
|
6249
|
+
text: errorText,
|
|
6250
|
+
...(subtype === ErrorType.POLICY_REJECTED ? {} : streamRawErrorText ? { raw: streamRawErrorText } : {}),
|
|
6251
|
+
subtype,
|
|
6252
|
+
...(reason ? { reason } : {}),
|
|
6253
|
+
recoverable: streamRecoverable,
|
|
6254
|
+
}).catch(() => { });
|
|
6255
|
+
return true;
|
|
6256
|
+
},
|
|
6257
|
+
});
|
|
6185
6258
|
// 先清理流和处理中状态(保证即使 flush 卡住,session 也不会永久处于"处理中")
|
|
6186
6259
|
agent.cleanupStream(streamKey, turnLease ? { taskId: turnLease.taskId, generation: turnLease.generation } : undefined);
|
|
6187
|
-
logger.
|
|
6260
|
+
logger.debug(`[ResponseEngine] agent.cleanupStream ok: session=${session.id} task=${taskId}`);
|
|
6188
6261
|
this.sessionManager.clearProcessingIfTask(session.id, taskId);
|
|
6189
6262
|
if (this.activeTaskRuntimeContexts.get(session.id)?.taskId === taskId) {
|
|
6190
6263
|
this.activeTaskRuntimeContexts.delete(session.id);
|
|
6191
6264
|
this.activeRunnerModels.delete(session.id); // F1修复
|
|
6192
6265
|
}
|
|
6193
6266
|
this.agentDelegationRegistry?.revokeTask(session.id, taskId, terminalInterrupt ? 'interrupted' : streamResult.isError ? 'failed' : 'completed');
|
|
6194
|
-
logger.info(`[ResponseEngine] session
|
|
6267
|
+
logger.info(`[ResponseEngine] task.finished: session=${session.id} task=${taskId} outcome=${terminalInterrupt ? 'interrupted' : streamResult.isError ? 'error' : 'completed'}`);
|
|
6195
6268
|
import('../../utils/msg-diag.js').then(m => m.diagLog('task_done', { aid: session.selfAID ?? '', msgId: message.messageId ?? '', taskId, text: message.content ?? '' })).catch(() => { });
|
|
6196
6269
|
// 降级模型回复末尾追加标记(代码层硬注入,不依赖模型输出)
|
|
6197
6270
|
if (usedFallback) {
|
|
@@ -6208,8 +6281,8 @@ export class ResponseEngine {
|
|
|
6208
6281
|
}
|
|
6209
6282
|
// 被用户中断(新消息打断)时跳过 flush — 新 task 已接管渠道,旧 task 的 flush 无意义且可能卡住
|
|
6210
6283
|
const preFlushInterrupt = this.interruptedSessions.get(session.id);
|
|
6211
|
-
if (isNonErrorInterruptReason(preFlushInterrupt)) {
|
|
6212
|
-
logger.info(`[ResponseEngine] Skipping flush for interrupted task=${taskId} reason=${preFlushInterrupt}`);
|
|
6284
|
+
if (terminalInterrupt || isNonErrorInterruptReason(preFlushInterrupt)) {
|
|
6285
|
+
logger.info(`[ResponseEngine] Skipping flush for interrupted task=${taskId} reason=${preFlushInterrupt ?? streamResult.terminalReason}`);
|
|
6213
6286
|
}
|
|
6214
6287
|
else {
|
|
6215
6288
|
// Flush 剩余内容(文件标记已在 flush 时自动移除)
|
|
@@ -6279,8 +6352,7 @@ export class ResponseEngine {
|
|
|
6279
6352
|
// 用户主动打断(新消息//stop/撤回)会让 SDK 流在工具调用中途被掐断,
|
|
6280
6353
|
// 末尾 result message 形状异常并被标记为 error(含 SDK 内部 ede_diagnostic 串)。
|
|
6281
6354
|
// 这不是真正的失败,不应把诊断串暴露给用户,也不计入错误统计。
|
|
6282
|
-
const isExpectedInterrupt =
|
|
6283
|
-
|| isExpectedTerminalInterrupt(streamResult.terminalReason);
|
|
6355
|
+
const isExpectedInterrupt = isExpectedStreamInterrupt(streamResult.terminalReason, interruptReason);
|
|
6284
6356
|
taskActivityStatus = isExpectedInterrupt ? 'interrupted' : 'error';
|
|
6285
6357
|
if (!isExpectedInterrupt && !permissionTerminalFailure) {
|
|
6286
6358
|
const terminalMetadata = {
|
|
@@ -6655,7 +6727,7 @@ export class ResponseEngine {
|
|
|
6655
6727
|
const leaseWasCurrent = !!turnLease && this.turnCoordinator.isCurrent(turnLease);
|
|
6656
6728
|
// 清理流和处理中状态(异常时也要清除)
|
|
6657
6729
|
agent.cleanupStream(streamKey, turnLease ? { taskId: turnLease.taskId, generation: turnLease.generation } : undefined);
|
|
6658
|
-
logger.
|
|
6730
|
+
logger.debug(`[ResponseEngine] agent.cleanupStream ok (on error): session=${session.id} task=${taskId}`);
|
|
6659
6731
|
try {
|
|
6660
6732
|
this.sessionManager.clearProcessingIfTask(session.id, taskId);
|
|
6661
6733
|
if (this.activeTaskRuntimeContexts.get(session.id)?.taskId === taskId) {
|
|
@@ -6663,7 +6735,7 @@ export class ResponseEngine {
|
|
|
6663
6735
|
this.activeRunnerModels.delete(session.id); // F1修复
|
|
6664
6736
|
}
|
|
6665
6737
|
this.agentDelegationRegistry?.revokeTask(session.id, taskId, this.interruptedSessions.has(session.id) ? 'interrupted' : 'failed');
|
|
6666
|
-
logger.info(`[ResponseEngine] session
|
|
6738
|
+
logger.info(`[ResponseEngine] task.finished: session=${session.id} task=${taskId} outcome=${this.interruptedSessions.has(session.id) ? 'interrupted' : 'error'}`);
|
|
6667
6739
|
}
|
|
6668
6740
|
catch { }
|
|
6669
6741
|
// 注意:不在此处清除 interruptedSessions,由下一条消息的 prompt 包装逻辑消费
|
|
@@ -7072,10 +7144,11 @@ export class ResponseEngine {
|
|
|
7072
7144
|
const shouldClose = !writerDb;
|
|
7073
7145
|
try {
|
|
7074
7146
|
const row = db.prepare(`SELECT model, input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens,
|
|
7075
|
-
context_tokens
|
|
7147
|
+
context_tokens, max_tokens
|
|
7076
7148
|
FROM model_calls
|
|
7077
7149
|
WHERE session_id = ?
|
|
7078
7150
|
AND agent_session_id = ?
|
|
7151
|
+
AND COALESCE(degraded, 0) = 0
|
|
7079
7152
|
ORDER BY ts DESC, call_index DESC
|
|
7080
7153
|
LIMIT 1`).get(sessionId, agentSessionId);
|
|
7081
7154
|
if (!row)
|
|
@@ -7096,6 +7169,15 @@ export class ResponseEngine {
|
|
|
7096
7169
|
}
|
|
7097
7170
|
if (totalTokens <= 0)
|
|
7098
7171
|
return undefined;
|
|
7172
|
+
// 单次请求的上下文不可能超过模型窗口。超过(留 5% 余量容纳输出侧计数)
|
|
7173
|
+
// 说明这行记的不是单次上下文,而是整轮累计用量——历史行里出现过
|
|
7174
|
+
// cache_read 被累加成 119 万的记录,它会让自动压缩在每个任务开始时
|
|
7175
|
+
// 重复触发。这类行一律不参与压缩判断。
|
|
7176
|
+
const maxTokens = row.max_tokens ?? 0;
|
|
7177
|
+
if (maxTokens > 0 && totalTokens > maxTokens * 1.05) {
|
|
7178
|
+
logger.warn(`[ResponseEngine] Ignoring implausible context_tokens: session=${sessionId} totalTokens=${totalTokens} maxTokens=${maxTokens}`);
|
|
7179
|
+
return undefined;
|
|
7180
|
+
}
|
|
7099
7181
|
// EvolCore 的自动压缩阈值固定为 650k,与模型上下文窗口无关:
|
|
7100
7182
|
// 大窗口模型(1M)到 650k 由 EvolCore 压缩;小窗口模型(200k/128k)
|
|
7101
7183
|
// 到不了该阈值,交给 base agent 自身的压缩机制处理。
|
|
@@ -7883,6 +7965,7 @@ export class ResponseEngine {
|
|
|
7883
7965
|
executionState: event.executionState ?? (event.decision === 'deny'
|
|
7884
7966
|
? 'blocked'
|
|
7885
7967
|
: event.isError ? 'failed' : 'completed'),
|
|
7968
|
+
...(event.cancelled ? { cancelled: true, abortSource: event.abortSource } : {}),
|
|
7886
7969
|
timestamp: Date.now(),
|
|
7887
7970
|
causation,
|
|
7888
7971
|
});
|
|
@@ -7997,10 +8080,9 @@ export class ResponseEngine {
|
|
|
7997
8080
|
if (event.type === 'complete') {
|
|
7998
8081
|
const isAbort = isExpectedTerminalInterrupt(event.terminalReason);
|
|
7999
8082
|
logger.info(`[ResponseEngine] ${isAbort ? 'task interrupted' : 'complete event'}: queryFinal=${event.queryFinal !== false} isError=${event.isError} terminalReason=${event.terminalReason ?? 'none'} subtype=${event.subtype ?? 'none'} hasReceivedText=${hasReceivedText}`);
|
|
8000
|
-
//
|
|
8083
|
+
// 自动回填会话名称(索引 + 对端同步由 sessionTitleSyncer 统一处理)
|
|
8001
8084
|
if (event.sessionTitle && shouldAutoFillSessionTitle(session.name, sessionTopicThreadId(session))) {
|
|
8002
|
-
await this.
|
|
8003
|
-
logger.info(`[ResponseEngine] Auto-filled session name: ${event.sessionTitle}`);
|
|
8085
|
+
await this.autoFillSessionTitle(session, event.sessionTitle);
|
|
8004
8086
|
}
|
|
8005
8087
|
// 记录完成状态 + 最后一轮回复文本(后续 complete 覆盖前序)
|
|
8006
8088
|
completeResult = { isError: !!event.isError, subtype: event.subtype, errors: event.errors, terminalReason: event.terminalReason, lastReplyText, fullText: event.result || '', hasReceivedText, numTurns: event.numTurns, ttftMs: event.ttftMs, model: event.model, tokenUsage: event.tokenUsage, contextUsage: event.contextUsage, lastModelCall: event.lastModelCall, modelCalls: event.modelCalls, syntheticDiagnosticText };
|
|
@@ -8048,10 +8130,9 @@ export class ResponseEngine {
|
|
|
8048
8130
|
if (event.type !== 'complete') {
|
|
8049
8131
|
continue;
|
|
8050
8132
|
}
|
|
8051
|
-
//
|
|
8133
|
+
// 自动回填会话名称(索引 + 对端同步由 sessionTitleSyncer 统一处理)
|
|
8052
8134
|
if (event.sessionTitle && shouldAutoFillSessionTitle(session.name, sessionTopicThreadId(session))) {
|
|
8053
|
-
await this.
|
|
8054
|
-
logger.info(`[ResponseEngine] Auto-filled session name: ${event.sessionTitle}`);
|
|
8135
|
+
await this.autoFillSessionTitle(session, event.sessionTitle);
|
|
8055
8136
|
}
|
|
8056
8137
|
// 记录完成状态
|
|
8057
8138
|
completeResult = { isError: !!event.isError, subtype: event.subtype, errors: event.errors, terminalReason: event.terminalReason, lastReplyText, fullText: event.result || '', hasReceivedText, syntheticDiagnosticText, numTurns: event.numTurns, ttftMs: event.ttftMs, model: event.model, tokenUsage: event.tokenUsage, contextUsage: event.contextUsage, lastModelCall: event.lastModelCall };
|
|
@@ -103,7 +103,7 @@ export function parseModelList(json, _url) {
|
|
|
103
103
|
return [...out.values()];
|
|
104
104
|
}
|
|
105
105
|
const BUILTIN_IDS = {
|
|
106
|
-
codex: ['gpt-
|
|
106
|
+
codex: ['gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-6-sol', 'gpt-6-astra', 'gpt-5.6-terra', 'gpt-5.6-sol'],
|
|
107
107
|
claude: ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-5-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'claude-fable-5', 'claude-fable-5-1', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'glm-5.3', 'glm-5.3-flash', 'glm-5.3-flashx', 'glm-5.2'],
|
|
108
108
|
ecagent: ['claude-sonnet-4-6'],
|
|
109
109
|
gemini: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* model/effort 只在 Agent 级配置:
|
|
9
9
|
* agent agents/<self>/config.json → baseagents.<ba>.{model,effort}
|
|
10
10
|
* 角色 角色策略 → 只约束 Agent 级模型(白名单/固定模型),不提供模型
|
|
11
|
-
*
|
|
11
|
+
* 关系级不承载模型参数;Agent/defaults 未设置时回落本机 CLI 配置和 runner 默认值。
|
|
12
12
|
*
|
|
13
13
|
* 改 Agent 级后,该 Agent 所有会话的下一条消息即时生效(运行时每条消息解析,不缓存)。
|
|
14
14
|
*
|
|
@@ -100,7 +100,7 @@ export function writeAgentModelConfig(self, ba, patch) {
|
|
|
100
100
|
ensureFile(target, { self });
|
|
101
101
|
write(target, cur, { self });
|
|
102
102
|
}
|
|
103
|
-
/** 清除 Agent 级 model+effort
|
|
103
|
+
/** 清除 Agent 级 model+effort,回落到较低优先级的配置。 */
|
|
104
104
|
export function clearAgentModelConfig(self, ba) {
|
|
105
105
|
writeAgentModelConfig(self, ba, { model: null, effort: null });
|
|
106
106
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* owns refreshes and snapshots. Runners in the daemon use that same instance.
|
|
4
4
|
*/
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import { clearRuntimeBaseagentModelDefaults } from '../../agents/baseagent.js';
|
|
6
7
|
import { activeBaseagent } from './config-scope.js';
|
|
7
8
|
import { resolveEffective } from '../../config/config-manager.js';
|
|
8
9
|
import { readRuntimeEnvironmentVariable } from '../../config/runtime-env.js';
|
|
@@ -11,7 +12,7 @@ import net from 'node:net';
|
|
|
11
12
|
import fs from 'node:fs';
|
|
12
13
|
import { getWindowsInstanceSocketPathCandidates, resolvePaths } from '../../paths.js';
|
|
13
14
|
import { ModelCatalogService, adaptCatalogModels, adaptServiceCatalogModels, catalogEfforts, catalogHash, resolveCatalogModel } from './catalog-service.js';
|
|
14
|
-
import { providerIsConfigured,
|
|
15
|
+
import { providerIsConfigured, providerServiceTypesForBaseagent, resolveProviderService, resolveProviderServiceForBaseagent } from '../../config/providers.js';
|
|
15
16
|
export * from './catalog-service.js';
|
|
16
17
|
let daemonOwner = false;
|
|
17
18
|
export function setModelCatalogDaemonOwner(value) { daemonOwner = value; }
|
|
@@ -94,7 +95,7 @@ function adaptProviderCatalogModels(models, provider, baseagent) {
|
|
|
94
95
|
export async function getProviderCatalog(providerId, serviceType, refresh = false, management = false, requestedBaseagent) {
|
|
95
96
|
const selected = requestedBaseagent
|
|
96
97
|
? resolveProviderServiceForBaseagent(providerId, requestedBaseagent, serviceType)
|
|
97
|
-
: resolveProviderService(providerId, serviceType);
|
|
98
|
+
: resolveProviderService(providerId, serviceType ?? '');
|
|
98
99
|
const effectiveServiceType = selected.serviceType;
|
|
99
100
|
const baseagent = resolveProviderCatalogBaseagent(effectiveServiceType, requestedBaseagent);
|
|
100
101
|
const present = (snapshot) => {
|
|
@@ -184,7 +185,7 @@ export function getRunnerCatalog(baseagent, self, connection) {
|
|
|
184
185
|
if (self)
|
|
185
186
|
return getCatalog(self, baseagent);
|
|
186
187
|
if (connection.providerId !== undefined) {
|
|
187
|
-
return getProviderCatalog(connection.providerId, connection.providerServiceType
|
|
188
|
+
return getProviderCatalog(connection.providerId, connection.providerServiceType, false, false, baseagent);
|
|
188
189
|
}
|
|
189
190
|
const context = { ...connection, scope: '<defaults>', baseagent };
|
|
190
191
|
return service.get(context).then(snapshot => applyProviderModelOverrides(snapshot, context.modelOverrides));
|
|
@@ -199,7 +200,7 @@ export async function getModelEfforts(model, self, ba) {
|
|
|
199
200
|
const baseagent = ba || activeBaseagent(self);
|
|
200
201
|
return catalogEfforts(await getCatalog(self, baseagent), model, baseagent);
|
|
201
202
|
}
|
|
202
|
-
export function clearModelCatalogCache() { service.clear(); }
|
|
203
|
+
export function clearModelCatalogCache() { service.clear(); clearRuntimeBaseagentModelDefaults(); }
|
|
203
204
|
export function applyProviderModelOverrides(snapshot, overrides) {
|
|
204
205
|
if (!overrides || Object.keys(overrides).length === 0)
|
|
205
206
|
return snapshot;
|