evolcore 0.0.41 → 0.0.42-test.0
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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,42 @@
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## 0.0.42-test.0 (2026-11-01)
|
|
9
|
+
|
|
10
|
+
### 主机诊断与运维
|
|
11
|
+
|
|
12
|
+
- 新增启动甘特图,记录 CLI 与 daemon 各阶段耗时,并在 EC Web 系统页展示最近启动记录。
|
|
13
|
+
- 新增 `ec agent host <aid>` 与 `/system` 主机视图,统一展示 daemon、队列、主机、磁盘、组件版本和运行时信息。
|
|
14
|
+
- 主机静态信息改为启动后异步探测,动态信息按查询现算;磁盘、虚拟化和 CPU 采样不再阻塞 daemon 启动。
|
|
15
|
+
- 修复 ESM 下 `ec version`、Windows `.cmd` 运行时探测和队列运行中 Agent 统计。
|
|
16
|
+
|
|
17
|
+
### Personal Assistant 与工作区
|
|
18
|
+
|
|
19
|
+
- 新增 PA 看板、工作区初始化与导航,展示 Owner、PA 和 Agent 团队拓扑、在岗状态、派活/汇报计数及沟通流。
|
|
20
|
+
- 新增工作区日历能力与日历菜单投影,支持个人助手读取和汇总日程信息。
|
|
21
|
+
- 完善 PA 独立创建 Agent 入口、Provider 默认配置持久化及初始化失败重试。
|
|
22
|
+
|
|
23
|
+
### Agent、模型与 Provider
|
|
24
|
+
|
|
25
|
+
- 完善 Provider 驱动的默认模型解析,按连接目录为 ecagent/Codex 选择可用模型,并过滤未验证、隐藏和禁用项。
|
|
26
|
+
- 统一 Agent 启用、对话运行、模型诊断、CLI 查询和上下文压缩使用有效模型与推理强度。
|
|
27
|
+
- 初始化流程继承已保存的 Provider、服务类型、模型和默认配置,补充创建前配置校验。
|
|
28
|
+
- AUN SDK 最低兼容版本提升至 `0.5.29`。
|
|
29
|
+
|
|
30
|
+
### Owner 名录、身份与安全
|
|
31
|
+
|
|
32
|
+
- 将联系人模型统一为 Peer,按 Owner 名录归属实施三档准入,并加固名录注入和共享缓存同步。
|
|
33
|
+
- 支持仅注册 AID 的 identity-only 流程,保护 Agent 名片中的 Ownership 声明与关系版本。
|
|
34
|
+
- 收紧控制 AID、Owner 绑定、Bootstrap 名片发布和非 human AID Owner 声明校验。
|
|
35
|
+
- 统一 apply_patch 文件目标归一化,修复移动文件解析、补丁误触发 L 级拒绝和 Codex 审批目标不一致。
|
|
36
|
+
|
|
37
|
+
### ServiceProxy、AUN 与 EC Web
|
|
38
|
+
|
|
39
|
+
- 完善 ServiceProxy 服务访问、端口传递、生命周期守护和 AUN 错误原因处理,避免错误诊断重复展示。
|
|
40
|
+
- 改进响应引擎、ecagent 中断状态、H 类拒绝和终态回复;补充 Daemon Owner 查询认证与 fullaccess 判定。
|
|
41
|
+
- EC Web 初始化支持默认配置持久化和失败重试;新增 PA 看板与启动诊断数据视图。
|
|
42
|
+
- 与 EvolCore `0.0.42-test.0` 同步发布。
|
|
43
|
+
|
|
8
44
|
## 0.0.41 (2026-10-31)
|
|
9
45
|
|
|
10
46
|
### Agent 创建、初始化与身份
|
|
@@ -131,10 +131,10 @@ function queryDaemon(socketPath, payload) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// The Windows managed requirements are machine-wide, so unmanaged Codex
|
|
134
|
-
// processes also reach this hook. EvolCore-
|
|
135
|
-
// credential
|
|
136
|
-
//
|
|
137
|
-
// allowed outright and never contact the daemon — EvolCore being stopped must
|
|
134
|
+
// processes also reach this hook. EvolCore app-server processes carry a Hook
|
|
135
|
+
// credential in their process environment. Thread shell environment settings
|
|
136
|
+
// do not reach Hooks. Keep accepting a per-thread credential for older hosts.
|
|
137
|
+
// Unmanaged calls are allowed outright and never contact the daemon — EvolCore being stopped must
|
|
138
138
|
// not break a standalone Codex. Credentialed calls always require an explicit
|
|
139
139
|
// daemon allow: a credential without its daemon is an orphaned managed thread
|
|
140
140
|
// and fails closed.
|
|
@@ -177,8 +177,11 @@ async function main() {
|
|
|
177
177
|
&& process.env.EVOLCORE_CODEX_SESSION_TOKEN
|
|
178
178
|
? process.env.EVOLCORE_CODEX_SESSION_TOKEN
|
|
179
179
|
: undefined;
|
|
180
|
+
// Standalone copy: keep this name in sync with CODEX_HOOK_TOKEN_ENV in src/product.ts.
|
|
181
|
+
const hookToken = process.env.EVOLCORE_CODEX_HOOK_TOKEN || undefined;
|
|
182
|
+
diagnostic('credential', { sessionCredentialPresent: !!sessionToken, hookCredentialPresent: !!hookToken });
|
|
180
183
|
|
|
181
|
-
if (!sessionToken) {
|
|
184
|
+
if (!sessionToken && !hookToken) {
|
|
182
185
|
// Unmanaged process: nothing to enforce, and no reason to pay the daemon
|
|
183
186
|
// round-trip (or its outage) for a call we would allow anyway.
|
|
184
187
|
return;
|
|
@@ -194,6 +197,7 @@ async function main() {
|
|
|
194
197
|
toolName: input.tool_name,
|
|
195
198
|
toolInput: input.tool_input ?? null,
|
|
196
199
|
sessionToken,
|
|
200
|
+
hookToken,
|
|
197
201
|
...(typeof (input.tool_use_id ?? input.toolUseId ?? input.item_id ?? input.itemId) === 'string'
|
|
198
202
|
? { callId: input.tool_use_id ?? input.toolUseId ?? input.item_id ?? input.itemId }
|
|
199
203
|
: {}),
|
package/dist/agents/baseagent.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import os from 'os';
|
|
15
|
+
import { createHash } from 'node:crypto';
|
|
15
16
|
import { buildCliLaunchCommand, commandExists, isWindows, resolvePowerShellShimPath, resolveProbePath, } from '../utils/cross-platform.js';
|
|
16
17
|
import { execFileSync } from 'child_process';
|
|
17
18
|
import { parse as parseToml } from 'smol-toml';
|
|
@@ -77,6 +78,44 @@ export function isSupportedBaseagent(input) {
|
|
|
77
78
|
const key = String(input || '').trim().toLowerCase();
|
|
78
79
|
return SUPPORTED_BASEAGENTS.has(key);
|
|
79
80
|
}
|
|
81
|
+
// Runtime prefill only: never write discovered defaults into Agent/defaults files.
|
|
82
|
+
// Connection and model overrides are part of the key, so a changed Provider cannot
|
|
83
|
+
// reuse a selection made for another endpoint, credential or enabled-model set.
|
|
84
|
+
const discoveredDefaultModels = new Map();
|
|
85
|
+
const discoveringDefaultModels = new Map();
|
|
86
|
+
export function clearRuntimeBaseagentModelDefaults() {
|
|
87
|
+
discoveredDefaultModels.clear();
|
|
88
|
+
}
|
|
89
|
+
function defaultModelConnectionKey(baseagent, configured) {
|
|
90
|
+
const providerId = configured?.provider;
|
|
91
|
+
const provider = providerId !== undefined ? resolveProviderServiceForBaseagent(providerId, baseagent) : undefined;
|
|
92
|
+
const settings = baseagent === 'codex' && !provider ? loadCodexSettings() : undefined;
|
|
93
|
+
const connection = provider ?? {
|
|
94
|
+
apiKey: configured?.apiKey,
|
|
95
|
+
baseUrl: configured?.baseUrl,
|
|
96
|
+
headers: configured?.headers,
|
|
97
|
+
queryParams: configured?.queryParams,
|
|
98
|
+
settings,
|
|
99
|
+
codexHome: process.env.CODEX_HOME || path.join(os.homedir(), '.codex'),
|
|
100
|
+
openaiApiKey: process.env.OPENAI_API_KEY,
|
|
101
|
+
codexApiKey: process.env.CODEX_API_KEY,
|
|
102
|
+
openaiBaseUrl: process.env.OPENAI_BASE_URL,
|
|
103
|
+
};
|
|
104
|
+
return createHash('sha256').update(JSON.stringify({ baseagent, connection })).digest('hex');
|
|
105
|
+
}
|
|
106
|
+
function discoveredDefaultModel(baseagent, configured) {
|
|
107
|
+
if (baseagent !== 'codex' && baseagent !== 'ecagent')
|
|
108
|
+
return undefined;
|
|
109
|
+
return discoveredDefaultModels.get(defaultModelConnectionKey(baseagent, configured));
|
|
110
|
+
}
|
|
111
|
+
function defaultModelUnavailable(baseagent) {
|
|
112
|
+
const message = baseagent === 'ecagent'
|
|
113
|
+
? 'ecagent 未配置模型,当前 Provider 目录中没有可用的 deepseek[*]flash;请配置 baseagents.ecagent.model'
|
|
114
|
+
: 'Codex 未配置模型,app-server 目录中没有可用的 gpt[*]terra;请配置 baseagents.codex.model 或 config.toml.model';
|
|
115
|
+
return Object.assign(new Error(message), {
|
|
116
|
+
code: baseagent === 'ecagent' ? 'ECAGENT_MODEL_UNAVAILABLE' : 'CODEX_MODEL_UNAVAILABLE',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
80
119
|
function readLegacyJson(file) {
|
|
81
120
|
try {
|
|
82
121
|
if (!fs.existsSync(file))
|
|
@@ -90,12 +129,7 @@ function readLegacyJson(file) {
|
|
|
90
129
|
return undefined;
|
|
91
130
|
}
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
* Read a pre-agent-config runner selection for the one-time schema migration.
|
|
95
|
-
* Mirror the runner's historical file/default model fallback without loading
|
|
96
|
-
* credentials, resolving providers, connecting, or changing runtime selection.
|
|
97
|
-
*/
|
|
98
|
-
export function resolveLegacyBaseagentModelSelection(baseagent, options = {}) {
|
|
132
|
+
function resolveLocalBaseagentModelSelection(baseagent, options = {}) {
|
|
99
133
|
const canonical = normalizeBaseagent(baseagent).canonical;
|
|
100
134
|
const home = options.home ? path.resolve(options.home) : os.homedir();
|
|
101
135
|
if (canonical === 'claude') {
|
|
@@ -103,7 +137,11 @@ export function resolveLegacyBaseagentModelSelection(baseagent, options = {}) {
|
|
|
103
137
|
const settings = readLegacyJson(file);
|
|
104
138
|
const model = nonEmptyString(settings?.model);
|
|
105
139
|
const effort = nonEmptyString(settings?.effortLevel);
|
|
106
|
-
return {
|
|
140
|
+
return {
|
|
141
|
+
model: model ?? DEFAULT_CLAUDE_MODEL,
|
|
142
|
+
...(model ? { modelPath: file } : {}),
|
|
143
|
+
...(effort ? { effort, effortPath: file } : {}),
|
|
144
|
+
};
|
|
107
145
|
}
|
|
108
146
|
if (canonical === 'codex') {
|
|
109
147
|
const codexHome = options.codexHome
|
|
@@ -118,20 +156,118 @@ export function resolveLegacyBaseagentModelSelection(baseagent, options = {}) {
|
|
|
118
156
|
: undefined;
|
|
119
157
|
const model = nonEmptyString(parsed?.model);
|
|
120
158
|
const effort = nonEmptyString(parsed?.model_reasoning_effort);
|
|
121
|
-
return {
|
|
159
|
+
return {
|
|
160
|
+
model: model ?? DEFAULT_CODEX_MODEL,
|
|
161
|
+
...(model ? { modelPath: file } : {}),
|
|
162
|
+
...(effort ? { effort, effortPath: file } : {}),
|
|
163
|
+
};
|
|
122
164
|
}
|
|
123
165
|
catch {
|
|
124
|
-
return { model:
|
|
166
|
+
return { model: DEFAULT_CODEX_MODEL };
|
|
125
167
|
}
|
|
126
168
|
}
|
|
127
169
|
if (canonical === 'gemini') {
|
|
128
|
-
return { model:
|
|
170
|
+
return { model: DEFAULT_GEMINI_MODEL };
|
|
129
171
|
}
|
|
130
172
|
if (canonical === 'ecagent') {
|
|
131
|
-
return { model: DEFAULT_ECAGENT_MODEL
|
|
173
|
+
return { model: DEFAULT_ECAGENT_MODEL };
|
|
132
174
|
}
|
|
133
175
|
return undefined;
|
|
134
176
|
}
|
|
177
|
+
/** Read the historical runner selection for the one-time schema migration. */
|
|
178
|
+
export function resolveLegacyBaseagentModelSelection(baseagent, options = {}) {
|
|
179
|
+
const local = resolveLocalBaseagentModelSelection(baseagent, options);
|
|
180
|
+
if (!local)
|
|
181
|
+
return undefined;
|
|
182
|
+
return {
|
|
183
|
+
model: local.model,
|
|
184
|
+
...(local.effort ? { effort: local.effort } : {}),
|
|
185
|
+
source: local.modelPath ?? local.effortPath ?? 'runner-default',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Resolve runtime model/effort without persisting fallback values. */
|
|
189
|
+
export function resolveBaseagentModelSelection(baseagent, configured, options = {}) {
|
|
190
|
+
const local = resolveLocalBaseagentModelSelection(baseagent, options);
|
|
191
|
+
if (!local)
|
|
192
|
+
return undefined;
|
|
193
|
+
const configuredModel = nonEmptyString(configured?.model);
|
|
194
|
+
const configuredEffort = nonEmptyString(configured?.effort)
|
|
195
|
+
?? (normalizeBaseagent(baseagent).canonical === 'codex' ? nonEmptyString(configured?.reasoning) : undefined);
|
|
196
|
+
const effort = configuredEffort ?? local.effort;
|
|
197
|
+
const canonical = normalizeBaseagent(baseagent).canonical;
|
|
198
|
+
// Historical constants remain confined to migration. Runtime defaults for
|
|
199
|
+
// these backends must come from the current connection's actual catalog.
|
|
200
|
+
const model = configuredModel ?? (canonical === 'ecagent' || (canonical === 'codex' && !local.modelPath)
|
|
201
|
+
? discoveredDefaultModel(canonical, configured)
|
|
202
|
+
: local.model);
|
|
203
|
+
if (!model)
|
|
204
|
+
return undefined;
|
|
205
|
+
return {
|
|
206
|
+
model,
|
|
207
|
+
...(effort ? { effort } : {}),
|
|
208
|
+
modelSource: configuredModel ? 'configured' : local.modelPath ? 'cli' : 'runner',
|
|
209
|
+
...(configuredEffort
|
|
210
|
+
? { effortSource: 'configured' }
|
|
211
|
+
: local.effort ? { effortSource: 'cli' } : {}),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** Resolve missing runtime defaults once per connection, sharing concurrent discovery. */
|
|
215
|
+
export async function resolveRuntimeBaseagentModelSelection(baseagent, configured) {
|
|
216
|
+
const selection = resolveBaseagentModelSelection(baseagent, configured);
|
|
217
|
+
if (selection)
|
|
218
|
+
return selection;
|
|
219
|
+
const canonical = normalizeBaseagent(baseagent).canonical;
|
|
220
|
+
if (canonical !== 'ecagent' && canonical !== 'codex')
|
|
221
|
+
return undefined;
|
|
222
|
+
const key = defaultModelConnectionKey(canonical, configured);
|
|
223
|
+
let pending = discoveringDefaultModels.get(key);
|
|
224
|
+
if (!pending) {
|
|
225
|
+
pending = (async () => {
|
|
226
|
+
try {
|
|
227
|
+
let model;
|
|
228
|
+
if (canonical === 'ecagent') {
|
|
229
|
+
if (!configured?.provider)
|
|
230
|
+
throw defaultModelUnavailable(canonical);
|
|
231
|
+
resolveEcagentConfig({ agents: { ecagent: configured } }, configured);
|
|
232
|
+
const { getProviderCatalog, assertCatalogSelectable } = await import('../core/model/model-catalog.js');
|
|
233
|
+
const catalog = await getProviderCatalog(configured.provider, undefined, false, false, 'ecagent');
|
|
234
|
+
assertCatalogSelectable(catalog);
|
|
235
|
+
model = catalog.models.find(item => item.verification === 'listed' && /deepseek.*flash/iu.test(item.id))?.id;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
const connection = resolveOpenaiConfig({ agents: { codex: configured } }, configured);
|
|
239
|
+
const { codexNativeCatalog } = await import('./codex/catalog.js');
|
|
240
|
+
const models = await codexNativeCatalog({ ...connection, scope: '<runtime-default>', baseagent: 'codex' }, {
|
|
241
|
+
allowCliFallback: false,
|
|
242
|
+
});
|
|
243
|
+
const overrides = connection.providerId
|
|
244
|
+
? resolveProviderServiceForBaseagent(connection.providerId, 'codex').modelOverrides : {};
|
|
245
|
+
model = models?.find(item => item.verification === 'listed' && /^gpt.*terra/iu.test(item.id)
|
|
246
|
+
&& overrides[item.id]?.enabled !== false && item.supportsTools !== false)?.id;
|
|
247
|
+
}
|
|
248
|
+
if (!model)
|
|
249
|
+
throw defaultModelUnavailable(canonical);
|
|
250
|
+
if (discoveredDefaultModels.size >= 128) {
|
|
251
|
+
discoveredDefaultModels.delete(discoveredDefaultModels.keys().next().value);
|
|
252
|
+
}
|
|
253
|
+
discoveredDefaultModels.set(key, model);
|
|
254
|
+
return model;
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
// Provider/app-server payloads can contain credentials or physical paths.
|
|
258
|
+
throw defaultModelUnavailable(canonical);
|
|
259
|
+
}
|
|
260
|
+
})().finally(() => discoveringDefaultModels.delete(key));
|
|
261
|
+
discoveringDefaultModels.set(key, pending);
|
|
262
|
+
}
|
|
263
|
+
await pending;
|
|
264
|
+
const resolved = resolveBaseagentModelSelection(canonical, configured);
|
|
265
|
+
// A Provider may have changed while its catalog was in flight. Do not apply
|
|
266
|
+
// that older connection's model to the new configuration.
|
|
267
|
+
if (!resolved)
|
|
268
|
+
throw defaultModelUnavailable(canonical);
|
|
269
|
+
return resolved;
|
|
270
|
+
}
|
|
135
271
|
function directInferencePair(apiKey, baseUrl) {
|
|
136
272
|
const normalizedApiKey = directInferenceValue(apiKey);
|
|
137
273
|
const normalizedBaseUrl = directInferenceValue(baseUrl);
|
|
@@ -411,8 +547,9 @@ export function resolveOpenaiConfig(config, override, runtime) {
|
|
|
411
547
|
providerId,
|
|
412
548
|
headers: provider.headers,
|
|
413
549
|
queryParams: provider.queryParams,
|
|
414
|
-
model: override?.model || config.agents?.codex?.model || codexSettings.model
|
|
415
|
-
|
|
550
|
+
model: override?.model || config.agents?.codex?.model || codexSettings.model
|
|
551
|
+
|| discoveredDefaultModel('codex', { ...config.agents?.codex, ...override }) || '',
|
|
552
|
+
effort: override?.effort || override?.reasoning || config.agents?.codex?.effort || codexSettings.effort || undefined,
|
|
416
553
|
enableRequestUserInput: override?.enableRequestUserInput ?? config.agents?.codex?.enableRequestUserInput ?? true,
|
|
417
554
|
agentAid: runtime?.agentAid,
|
|
418
555
|
agentConfig: runtime?.agentConfig,
|
|
@@ -455,11 +592,12 @@ export function resolveOpenaiConfig(config, override, runtime) {
|
|
|
455
592
|
const model = override?.model
|
|
456
593
|
|| config.agents?.codex?.model
|
|
457
594
|
|| codexSettings.model
|
|
458
|
-
||
|
|
595
|
+
|| discoveredDefaultModel('codex', { ...config.agents?.codex, ...override }) || '';
|
|
459
596
|
const effort = override?.effort
|
|
460
597
|
|| override?.reasoning
|
|
461
598
|
|| config.agents?.codex?.effort
|
|
462
599
|
|| config.agents?.codex?.reasoning
|
|
600
|
+
|| codexSettings.effort
|
|
463
601
|
|| undefined;
|
|
464
602
|
const enableRequestUserInput = override?.enableRequestUserInput
|
|
465
603
|
?? config.agents?.codex?.enableRequestUserInput
|
|
@@ -527,7 +665,8 @@ export function resolveEcagentConfig(config, override) {
|
|
|
527
665
|
baseUrl: provider.baseUrl,
|
|
528
666
|
headers: provider.headers,
|
|
529
667
|
queryParams: provider.queryParams,
|
|
530
|
-
model: override?.model || configured?.model
|
|
668
|
+
model: override?.model || configured?.model
|
|
669
|
+
|| discoveredDefaultModel('ecagent', { ...configured, ...override }) || '',
|
|
531
670
|
effort: override?.effort ?? configured?.effort,
|
|
532
671
|
timeoutMs: numberOr(override?.timeoutMs ?? configured?.timeoutMs, DEFAULT_ECAGENT_TIMEOUT_MS),
|
|
533
672
|
maxRetries: numberOr(override?.maxRetries ?? configured?.maxRetries, DEFAULT_ECAGENT_MAX_RETRIES),
|
|
@@ -550,7 +689,8 @@ export function resolveEcagentConfig(config, override) {
|
|
|
550
689
|
const baseUrl = (override?.baseUrl && !override.baseUrl.includes('placeholder') ? override.baseUrl : undefined)
|
|
551
690
|
|| process.env.ECAGENT_BASE_URL
|
|
552
691
|
|| DEFAULT_ECAGENT_BASE_URL;
|
|
553
|
-
const model = override?.model || configured?.model
|
|
692
|
+
const model = override?.model || configured?.model
|
|
693
|
+
|| discoveredDefaultModel('ecagent', { ...configured, ...override }) || '';
|
|
554
694
|
const headers = normalizeStringMap(override?.headers, 'headers');
|
|
555
695
|
const queryParams = normalizeStringMap(override?.queryParams, 'queryParams');
|
|
556
696
|
const effort = override?.effort ?? configured?.effort;
|
|
@@ -112,6 +112,8 @@ export function summarizeClaudeQueryOptions(options, context) {
|
|
|
112
112
|
denyWriteCount: sandbox?.filesystem?.denyWrite?.length ?? null,
|
|
113
113
|
},
|
|
114
114
|
settingSources: options.settingSources?.slice() ?? [],
|
|
115
|
+
disallowedTools: options.disallowedTools?.slice() ?? [],
|
|
116
|
+
skills: Array.isArray(options.skills) ? { count: options.skills.length } : options.skills ?? null,
|
|
115
117
|
promptAppend: { length: append.length, sha256: sha256(append) },
|
|
116
118
|
queryOptionNames: Object.keys(options).sort(),
|
|
117
119
|
nativeDebugOptionsEnabled: options.debug === true || !!options.debugFile,
|
|
@@ -1908,14 +1910,19 @@ export class AgentRunner {
|
|
|
1908
1910
|
}));
|
|
1909
1911
|
}
|
|
1910
1912
|
else if (u && !isSyntheticError) {
|
|
1911
|
-
//
|
|
1912
|
-
|
|
1913
|
+
// 降级:无逐次数据,写一条累计行。u 是整轮聚合用量,不是单次请求的
|
|
1914
|
+
// 上下文占用,派生 contextUsage 会得到远超模型窗口的数字,因此这里
|
|
1915
|
+
// 只保留 tokenUsage 供计费用的,不写 contextUsage。
|
|
1916
|
+
modelCalls = [{ call_index: 0, model: callModel_, tokenUsage: u, degraded: true }];
|
|
1913
1917
|
}
|
|
1914
1918
|
// `event.usage` is aggregate query usage when the SDK made multiple
|
|
1915
1919
|
// model calls. The top-level context field must describe a single
|
|
1916
1920
|
// current request. For normal results aggregate usage remains available
|
|
1917
1921
|
// in tokenUsage; synthetic errors use their own terminal usage instead.
|
|
1918
|
-
|
|
1922
|
+
// 降级行只有整轮聚合用量,回落到 modelCalls/aggregate 都会把累计值当成
|
|
1923
|
+
// 当前上下文,因此这种情况只认真实的逐次调用记录。
|
|
1924
|
+
const hasDegradedModelCalls = modelCalls?.some(mc => mc.degraded) ?? false;
|
|
1925
|
+
const contextUsage = isSyntheticError || hasDegradedModelCalls
|
|
1919
1926
|
? lastModelCall?.contextUsage
|
|
1920
1927
|
: lastModelCall?.contextUsage
|
|
1921
1928
|
?? modelCalls?.at(-1)?.contextUsage
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { CodexAppServerClient } from './app-server-client.js';
|
|
3
3
|
import { resolveCodexLaunchCommand } from '../baseagent.js';
|
|
4
|
-
import { parseModelList } from '../../core/model/catalog-service.js';
|
|
4
|
+
import { catalogHash, parseModelList } from '../../core/model/catalog-service.js';
|
|
5
5
|
async function cliModels() {
|
|
6
6
|
const launch = resolveCodexLaunchCommand(['debug', 'models']);
|
|
7
7
|
if (!launch)
|
|
@@ -30,11 +30,13 @@ async function cliModels() {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
/** A catalog-only client uses the same transport configuration as inference. */
|
|
33
|
-
export async function codexNativeCatalog(context) {
|
|
33
|
+
export async function codexNativeCatalog(context, options = {}) {
|
|
34
34
|
if (context.baseagent !== 'codex')
|
|
35
35
|
return null;
|
|
36
36
|
const client = new CodexAppServerClient({
|
|
37
|
-
apiKey: context.apiKey ?? '', authType: context.authType, baseUrl: context.baseUrl,
|
|
37
|
+
apiKey: context.apiKey ?? '', authType: context.authType, baseUrl: context.baseUrl,
|
|
38
|
+
provider: context.providerId ? `evolcore_registry_${catalogHash(context.providerId).slice(0, 20)}` : context.provider,
|
|
39
|
+
isolatedProvider: context.providerId !== undefined,
|
|
38
40
|
headers: context.headers, queryParams: context.queryParams,
|
|
39
41
|
});
|
|
40
42
|
let timer;
|
|
@@ -51,7 +53,7 @@ export async function codexNativeCatalog(context) {
|
|
|
51
53
|
throw new Error('Model catalog timeout');
|
|
52
54
|
if (!Array.isArray(page.data))
|
|
53
55
|
throw new Error('Invalid native model list');
|
|
54
|
-
models.push(...parseModelList(page.data.filter(m => !m.hidden)));
|
|
56
|
+
models.push(...parseModelList(page.data.filter(m => !m.hidden && m.enabled !== false)));
|
|
55
57
|
cursor = page.nextCursor || undefined;
|
|
56
58
|
if (cursor && (seen.has(cursor) || seen.size >= 100))
|
|
57
59
|
throw new Error('Invalid native model pagination');
|
|
@@ -64,6 +66,8 @@ export async function codexNativeCatalog(context) {
|
|
|
64
66
|
]);
|
|
65
67
|
}
|
|
66
68
|
catch {
|
|
69
|
+
if (options.allowCliFallback === false)
|
|
70
|
+
return null;
|
|
67
71
|
// The host CLI catalog has no guarantee of matching this Agent connection.
|
|
68
72
|
// It is useful metadata/suggestions and always remains unverified.
|
|
69
73
|
return await cliModels();
|