evolcore 0.0.41-test.1 → 0.0.41-test.2
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 +49 -36
- package/dist/agents/baseagent.js +68 -6
- package/dist/agents/codex-runner.js +62 -43
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/p2p.js +3 -8
- package/dist/aun/service-proxy.js +17 -0
- package/dist/channels/aun.js +321 -34
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +44 -16
- package/dist/cli/daemon-commands.js +1 -0
- package/dist/cli/index.js +24 -1
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +13 -1
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/boot-log.js +3 -2
- package/dist/config/config-field-policy.js +12 -7
- package/dist/config/config-manager.js +138 -6
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +2 -1
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +8 -1
- package/dist/config/schema-migration.js +322 -8
- package/dist/config-store.js +10 -1
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +193 -23
- package/dist/core/auth/agent-delegation.js +4 -2
- package/dist/core/auth/auth-gateway.js +66 -1
- package/dist/core/auth/authorization-audit.js +41 -5
- package/dist/core/auth/delegation-authorization.js +2 -1
- package/dist/core/auth/operation-authorizer.js +28 -6
- package/dist/core/auth/operation-catalog.js +14 -1
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +257 -14
- package/dist/core/command/cli-intent-parser.js +6 -2
- package/dist/core/command/command-handler.js +64 -55
- package/dist/core/command/memory-slash.js +1 -1
- package/dist/core/command/menu-catalog.js +5 -0
- package/dist/core/command/menu-handler.js +64 -18
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/slash-handler.js +2 -1
- package/dist/core/daemon-control.js +18 -13
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +3 -1
- package/dist/core/evolagent.js +8 -6
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +34 -22
- package/dist/core/memory/consolidation-ops-records.js +95 -0
- package/dist/core/memory/consolidation-trigger.js +19 -2
- package/dist/core/memory/consolidation.js +19 -8
- package/dist/core/memory/memory-admin.js +1 -1
- package/dist/core/memory/relation-sweep.js +11 -6
- package/dist/core/message/aun-ipc-sender.js +73 -67
- package/dist/core/message/im-renderer.js +18 -0
- package/dist/core/message/message-bridge.js +35 -3
- package/dist/core/message/response-engine.js +32 -28
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +5 -7
- package/dist/core/ownership/owner-resolver.js +755 -143
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +32 -4
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/tool-policy.js +7 -43
- package/dist/core/system-session/memory.js +37 -7
- package/dist/directory/owner-directory-cache.js +2 -2
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/index.js +17 -5
- package/dist/ipc.js +85 -25
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +6 -7
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/error-utils.js +24 -0
- package/dist/utils/logger.js +68 -1
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +11 -1
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +2 -2
- package/kits/schemas/agent-config.schema.16.json +3 -3
- package/kits/schemas/relation-config.schema.11.json +17 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/ec-trigger/SKILL.md +5 -13
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +3 -3
- package/dist/core/memory/forget-log.js +0 -96
- package/dist/core/message/create-status.js +0 -96
package/CHANGELOG.md
CHANGED
|
@@ -5,54 +5,67 @@
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
-
## 0.0.41 (2026-10-
|
|
8
|
+
## 0.0.41-test.2 (2026-10-31)
|
|
9
9
|
|
|
10
|
-
###
|
|
10
|
+
### Agent 创建、初始化与身份
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- 修正 EC Web 角色定义选项展示,清理失效的 Provider 服务类型配置字段。
|
|
12
|
+
- 完善 App 一步创建、初始化进度、Owner 绑定、失败恢复和取消流程,补充 creationId、operationId、请求主体及绑定关系诊断。
|
|
13
|
+
- 修复初始化状态损坏、目标配置变化和已激活 Agent 重绑时的错误归因,保留可恢复与不可恢复状态边界。
|
|
14
|
+
- 支持初始化阶段头像上传、Provider 导入、Agent 名片校验和配置冲突检查。
|
|
15
|
+
- 合并创建状态、初始化进度、初始化 Owner 投影和删除清理逻辑,修复 npm 包运行时缺失模块的问题。
|
|
17
16
|
|
|
18
|
-
###
|
|
17
|
+
### Ownership、Owner 目录与权限
|
|
19
18
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
19
|
+
- 将 Ownership 2.1 核验收口到实际依赖 Owner 权限的操作,增加结构化刷新来源、失败代码和暂态诊断。
|
|
20
|
+
- 保留已验证关系,阻止已激活 Agent 按遗留配置自动重绑;Owner 不匹配时撤销授权并要求重新核验。
|
|
21
|
+
- 新增 Owner Agent 名录授权、缓存、快照同步、过期处理、拒绝持久化和连接代次保护。
|
|
22
|
+
- Owner 目录刷新增加强制新鲜度校验、退避重试和私聊/群聊准入边界。
|
|
23
|
+
- 补充角色提升申请与审批服务、角色命令和权限结果诊断。
|
|
25
24
|
|
|
26
|
-
###
|
|
25
|
+
### AUN 消息、Bootstrap 与命令安全
|
|
27
26
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
27
|
+
- 修复 Bootstrap 欢迎消息在历史群路由上的恢复逻辑,统一修复为 Owner 私聊并避免重复投递。
|
|
28
|
+
- 完善 AUN 出站消息路由、加密默认值、设备目标和话题元数据处理。
|
|
29
|
+
- 扩展受管命令解析对 thread summary 文本和 `$TMPDIR` 字面量的识别,保留不安全展开的 fail-closed 行为。
|
|
30
|
+
- 改进命令授权、跨会话权限、工具输入和策略拒绝诊断,保留原始错误归因。
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### 会话、任务、Trigger 与记忆
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- 收紧共识校验范围,只在实际依赖 Owner 权限的操作中要求 Owner 共识。
|
|
34
|
+
- 完善 session capsule、renew、任务恢复、Trigger 重试和权限诊断,补充请求关联审计元数据。
|
|
35
|
+
- Trigger 列表改为带最近刷新时间的手动刷新模式。
|
|
36
|
+
- 合并记忆遗忘审计与整理操作记录,保留遗忘原因、范围和结果。
|
|
37
|
+
- 完善费用、用量、网关价格和历史调用成本聚合。
|
|
39
38
|
|
|
40
|
-
###
|
|
39
|
+
### Provider、ServiceProxy 与运行时兼容
|
|
41
40
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
- 完善受管任务会话身份、控制面操作和 Fullaccess 权限模式的审计关联。
|
|
47
|
-
- 修复重启确认超时后无法继续执行的问题,并显示当前对话中待查看的后台结果。
|
|
41
|
+
- 新增 Provider CLI、Provider Menu 和 ServiceProxy 管理能力,完善配置并发校验、引用删除保护和服务生命周期。
|
|
42
|
+
- 增加 personal-assistant 技能及其工作区、数据流、渲染配置和自动化脚本。
|
|
43
|
+
- 更新 Agent、daemon、relation schema 和运行时文档。
|
|
44
|
+
- AUN SDK 最低兼容版本提升至 `0.5.28`;EC Web 协议同步至 1.4;Node.js 要求为 `>=22.16.0`。
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
## 0.0.41 (2026-10-30)
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
- 统一
|
|
54
|
-
-
|
|
55
|
-
-
|
|
48
|
+
### Ownership、权限与 Agent 初始化
|
|
49
|
+
|
|
50
|
+
- 统一 Ownership 2.1 协议共识与 Owner 角色判定;绑定关系建立后不再回退到配置中的兼容 Owner。
|
|
51
|
+
- 收紧 Ownership IPC 的委派与本地控制认证边界,支持状态查询强制刷新,并记录脱敏的 Ownership 业务事件。
|
|
52
|
+
- 完善 Agent 创建、Owner 绑定、初始化恢复和身份冲突诊断,保留未绑定 Agent 的兼容绑定目标。
|
|
53
|
+
- 启用 Agent 前校验模型配置;模型或推理强度仅从 Agent/defaults 配置读取,缺失时返回明确错误。
|
|
54
|
+
- 完善旧关系模型配置迁移,清理关系级模型字段并补齐缺失的 Agent Base Agent 配置。
|
|
55
|
+
|
|
56
|
+
### Provider 与菜单控制
|
|
57
|
+
|
|
58
|
+
- 新增 Provider CLI 和 Provider Menu 进程级管理,支持配置创建、更新、删除、JSON 导入和并发校验。
|
|
59
|
+
- 删除被 Provider 引用时提供保护,强化 Provider IPC、Menu 权限边界和错误码映射。
|
|
60
|
+
- 统一 Trigger 详情查询语义,并补充 Provider 管理文档。
|
|
61
|
+
- 升级 AUN SDK 至 `0.5.28`。
|
|
62
|
+
|
|
63
|
+
### AUN 消息与配置
|
|
64
|
+
|
|
65
|
+
- 修复 AUN payload 的话题路由一致性。
|
|
66
|
+
- 增强 Agent、AUN 命令和初始化参数的校验与提示。
|
|
67
|
+
- 完善模型目录和默认模型选择,避免配置读取失败时静默使用隐式 runner 默认值。
|
|
68
|
+
- 更新 AID、联系人和群关系文档,明确 Ownership 2.1 共识与兼容绑定目标的权限边界。
|
|
56
69
|
|
|
57
70
|
## 0.0.41 (2026-10-27)
|
|
58
71
|
|
package/dist/agents/baseagent.js
CHANGED
|
@@ -66,6 +66,9 @@ const BASEAGENT_ALIASES = {
|
|
|
66
66
|
'ec-agent': { canonical: 'ecagent', displayName: 'ecagent' },
|
|
67
67
|
};
|
|
68
68
|
const SUPPORTED_BASEAGENTS = new Set(['claude', 'codex', 'gemini', 'ecagent']);
|
|
69
|
+
export const DEFAULT_CLAUDE_MODEL = 'sonnet';
|
|
70
|
+
export const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
|
|
71
|
+
export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-flash';
|
|
69
72
|
export function normalizeBaseagent(input) {
|
|
70
73
|
const key = String(input || '').trim().toLowerCase().replace(/_/g, '-');
|
|
71
74
|
return BASEAGENT_ALIASES[key] || { canonical: 'unknown', displayName: input ? String(input) : 'Unknown' };
|
|
@@ -74,6 +77,61 @@ export function isSupportedBaseagent(input) {
|
|
|
74
77
|
const key = String(input || '').trim().toLowerCase();
|
|
75
78
|
return SUPPORTED_BASEAGENTS.has(key);
|
|
76
79
|
}
|
|
80
|
+
function readLegacyJson(file) {
|
|
81
|
+
try {
|
|
82
|
+
if (!fs.existsSync(file))
|
|
83
|
+
return undefined;
|
|
84
|
+
const value = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
85
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
86
|
+
? value
|
|
87
|
+
: undefined;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
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 = {}) {
|
|
99
|
+
const canonical = normalizeBaseagent(baseagent).canonical;
|
|
100
|
+
const home = options.home ? path.resolve(options.home) : os.homedir();
|
|
101
|
+
if (canonical === 'claude') {
|
|
102
|
+
const file = path.join(home, '.claude', 'settings.json');
|
|
103
|
+
const settings = readLegacyJson(file);
|
|
104
|
+
const model = nonEmptyString(settings?.model);
|
|
105
|
+
const effort = nonEmptyString(settings?.effortLevel);
|
|
106
|
+
return { model: model ?? 'sonnet', ...(effort ? { effort } : {}), source: model || effort ? file : 'runner-default' };
|
|
107
|
+
}
|
|
108
|
+
if (canonical === 'codex') {
|
|
109
|
+
const codexHome = options.codexHome
|
|
110
|
+
? path.resolve(options.codexHome)
|
|
111
|
+
: process.env.CODEX_HOME?.trim()
|
|
112
|
+
? path.resolve(process.env.CODEX_HOME)
|
|
113
|
+
: path.join(home, '.codex');
|
|
114
|
+
const file = path.join(codexHome, 'config.toml');
|
|
115
|
+
try {
|
|
116
|
+
const parsed = fs.existsSync(file)
|
|
117
|
+
? recordValue(parseToml(fs.readFileSync(file, 'utf8')))
|
|
118
|
+
: undefined;
|
|
119
|
+
const model = nonEmptyString(parsed?.model);
|
|
120
|
+
const effort = nonEmptyString(parsed?.model_reasoning_effort);
|
|
121
|
+
return { model: model ?? 'gpt-5.2-codex', ...(effort ? { effort } : {}), source: model || effort ? file : 'runner-default' };
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return { model: 'gpt-5.2-codex', source: 'runner-default' };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (canonical === 'gemini') {
|
|
128
|
+
return { model: 'gemini-2.5-flash', source: 'runner-default' };
|
|
129
|
+
}
|
|
130
|
+
if (canonical === 'ecagent') {
|
|
131
|
+
return { model: DEFAULT_ECAGENT_MODEL, source: 'runner-default' };
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
77
135
|
function directInferencePair(apiKey, baseUrl) {
|
|
78
136
|
const normalizedApiKey = directInferenceValue(apiKey);
|
|
79
137
|
const normalizedBaseUrl = directInferenceValue(baseUrl);
|
|
@@ -181,7 +239,7 @@ export function resolveAnthropicConfig(config, override, runtime) {
|
|
|
181
239
|
providerId,
|
|
182
240
|
headers: provider.headers,
|
|
183
241
|
queryParams: provider.queryParams,
|
|
184
|
-
model: override?.model || config.agents?.claude?.model || settings.model ||
|
|
242
|
+
model: override?.model || config.agents?.claude?.model || settings.model || DEFAULT_CLAUDE_MODEL,
|
|
185
243
|
effort: override?.effort || config.agents?.claude?.effort || settings.effortLevel || undefined,
|
|
186
244
|
pathToClaudeCodeExecutable: override?.pathToClaudeCodeExecutable || config.agents?.claude?.pathToClaudeCodeExecutable,
|
|
187
245
|
};
|
|
@@ -210,7 +268,7 @@ export function resolveAnthropicConfig(config, override, runtime) {
|
|
|
210
268
|
const model = override?.model
|
|
211
269
|
|| config.agents?.claude?.model
|
|
212
270
|
|| settings.model
|
|
213
|
-
||
|
|
271
|
+
|| DEFAULT_CLAUDE_MODEL;
|
|
214
272
|
const effort = override?.effort
|
|
215
273
|
|| config.agents?.claude?.effort
|
|
216
274
|
|| settings.effortLevel
|
|
@@ -244,6 +302,7 @@ export function loadCodexSettings() {
|
|
|
244
302
|
// A corrupt auth.json must not prevent the provider config from loading.
|
|
245
303
|
}
|
|
246
304
|
let model;
|
|
305
|
+
let effort;
|
|
247
306
|
let baseUrl;
|
|
248
307
|
let provider;
|
|
249
308
|
let bearerToken;
|
|
@@ -252,6 +311,7 @@ export function loadCodexSettings() {
|
|
|
252
311
|
if (fs.existsSync(configPath)) {
|
|
253
312
|
const parsed = recordValue(parseToml(fs.readFileSync(configPath, 'utf-8')));
|
|
254
313
|
model = nonEmptyString(parsed?.model);
|
|
314
|
+
effort = nonEmptyString(parsed?.model_reasoning_effort);
|
|
255
315
|
provider = nonEmptyString(parsed?.model_provider);
|
|
256
316
|
const providers = recordValue(parsed?.model_providers);
|
|
257
317
|
const selectedProvider = provider ? recordValue(providers?.[provider]) : undefined;
|
|
@@ -272,6 +332,7 @@ export function loadCodexSettings() {
|
|
|
272
332
|
authSource: 'config.toml',
|
|
273
333
|
baseUrl,
|
|
274
334
|
model,
|
|
335
|
+
effort,
|
|
275
336
|
provider,
|
|
276
337
|
requiresOpenaiAuth,
|
|
277
338
|
};
|
|
@@ -283,11 +344,12 @@ export function loadCodexSettings() {
|
|
|
283
344
|
authSource: 'auth.json',
|
|
284
345
|
baseUrl,
|
|
285
346
|
model,
|
|
347
|
+
effort,
|
|
286
348
|
provider,
|
|
287
349
|
requiresOpenaiAuth,
|
|
288
350
|
};
|
|
289
351
|
}
|
|
290
|
-
return { baseUrl, model, provider, requiresOpenaiAuth };
|
|
352
|
+
return { baseUrl, model, effort, provider, requiresOpenaiAuth };
|
|
291
353
|
}
|
|
292
354
|
/**
|
|
293
355
|
* Resolve a complete credential/endpoint pair for direct OpenAI HTTP calls.
|
|
@@ -349,7 +411,7 @@ export function resolveOpenaiConfig(config, override, runtime) {
|
|
|
349
411
|
providerId,
|
|
350
412
|
headers: provider.headers,
|
|
351
413
|
queryParams: provider.queryParams,
|
|
352
|
-
model: override?.model || config.agents?.codex?.model || codexSettings.model ||
|
|
414
|
+
model: override?.model || config.agents?.codex?.model || codexSettings.model || DEFAULT_CODEX_MODEL,
|
|
353
415
|
effort: override?.effort || override?.reasoning || config.agents?.codex?.effort || undefined,
|
|
354
416
|
enableRequestUserInput: override?.enableRequestUserInput ?? config.agents?.codex?.enableRequestUserInput ?? true,
|
|
355
417
|
agentAid: runtime?.agentAid,
|
|
@@ -393,7 +455,7 @@ export function resolveOpenaiConfig(config, override, runtime) {
|
|
|
393
455
|
const model = override?.model
|
|
394
456
|
|| config.agents?.codex?.model
|
|
395
457
|
|| codexSettings.model
|
|
396
|
-
||
|
|
458
|
+
|| DEFAULT_CODEX_MODEL;
|
|
397
459
|
const effort = override?.effort
|
|
398
460
|
|| override?.reasoning
|
|
399
461
|
|| config.agents?.codex?.effort
|
|
@@ -424,7 +486,7 @@ export function resolveGoogleConfig(config, override) {
|
|
|
424
486
|
if (!cliPath) {
|
|
425
487
|
cliPath = commandExists('gemini') ? 'gemini' : '';
|
|
426
488
|
}
|
|
427
|
-
const model = override?.model || googleCfg?.model ||
|
|
489
|
+
const model = override?.model || googleCfg?.model || DEFAULT_GEMINI_MODEL;
|
|
428
490
|
const providerId = override?.provider ?? googleCfg?.provider;
|
|
429
491
|
if (providerId !== undefined) {
|
|
430
492
|
const provider = resolveProviderService(providerId, 'gemini');
|
|
@@ -2,7 +2,8 @@ import { getRunnerCatalog, catalogEfforts, assertCatalogSelectable } from '../co
|
|
|
2
2
|
// Codex/OpenAI API 不认识 Claude Code SDK 的窗口后缀,必须传入基础模型 ID。
|
|
3
3
|
import { parseModelId, stripContextWindowSuffix } from '../core/model/context-window-suffix.js';
|
|
4
4
|
import { formatAsyncQuestionAnswer, hasTrustedFullAccessContext, parseAsyncUserQuestions, unsettledInterruptError, withInterruptDeadline } from './runner-types.js';
|
|
5
|
-
import {
|
|
5
|
+
import { requestDangerousCommandPermissionResult } from '../core/permission/approval-gateway.js';
|
|
6
|
+
import { permissionFailureResult } from '../core/permission/permission-result.js';
|
|
6
7
|
import { checkReadonly, checkDangerousCommand, evaluateToolPreflight } from '../core/permission/tool-policy.js';
|
|
7
8
|
import { isShellToolName } from '../core/permission/tool-canonical.js';
|
|
8
9
|
import { normalizeExecutionPermissionMode, normalizePermissionMode, resolvePhaseOneExecutionSandbox } from '../core/permission/mode.js';
|
|
@@ -22,7 +23,7 @@ import { buildEnvelope, isInteractionSendAccepted, sendInteractionPayload } from
|
|
|
22
23
|
import { resolveCodexCapabilityThreadConfigForProject } from '../core/capability/capability-manager.js';
|
|
23
24
|
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, hashDelegatedCommandArgv, hashDelegatedCommandSpec, parseDelegatedExecutionSpec, } from '../core/auth/agent-delegation.js';
|
|
24
25
|
import { sanitizeShellExecutionEnvironment } from '../core/permission/shell-environment.js';
|
|
25
|
-
import { classifyEvolcoreShellCommand, containsLiteralManagedTmpDirOutsideSendContent, containsUnresolvedManagedTmpDirReference, hasCodexCmdCarrierEcIntent, hasPowerShellCredentialAssignment, normalizeEvolcoreCommandArgv, parseLiteralShellArgv, resolveCodexShellCarrierArgv, parseShellApplyPatchInvocation, resolveCanonicalEvolcoreToolInput, serializeCanonicalEvolcoreExecutionSpec, } from '../core/permission/ec-command-parser.js';
|
|
26
|
+
import { classifyEvolcoreShellCommand, literalShellParseRemedy, containsLiteralManagedTmpDirOutsideSendContent, containsUnresolvedManagedTmpDirReference, hasCodexCmdCarrierEcIntent, hasPowerShellCredentialAssignment, normalizeEvolcoreCommandArgv, parseLiteralShellArgv, resolveCodexShellCarrierArgv, parseShellApplyPatchInvocation, resolveCanonicalEvolcoreToolInput, serializeCanonicalEvolcoreExecutionSpec, } from '../core/permission/ec-command-parser.js';
|
|
26
27
|
import { compareVersions } from '../utils/npm-ops.js';
|
|
27
28
|
import { agentCodexTokenPath, getPackageRoot, resolvePaths, resolveRoot } from '../paths.js';
|
|
28
29
|
import { MAIN_CLI_BIN } from '../product.js';
|
|
@@ -124,6 +125,8 @@ function fallbackErrorCodeForToolDenial(decisionSource, policyCode) {
|
|
|
124
125
|
return 'POLICY_DENIED';
|
|
125
126
|
if (decisionSource === 'approval')
|
|
126
127
|
return 'USER_DENIED';
|
|
128
|
+
if (policyCode === 'approval_expired' || policyCode === 'approval_timeout')
|
|
129
|
+
return 'APPROVAL_TIMEOUT';
|
|
127
130
|
if (policyCode && /delegation|carrier/i.test(policyCode))
|
|
128
131
|
return 'DELEGATION_FAILED';
|
|
129
132
|
if (policyCode && /argument|canonical|quote|shell/i.test(policyCode))
|
|
@@ -3770,9 +3773,7 @@ export class CodexRunner {
|
|
|
3770
3773
|
}
|
|
3771
3774
|
return await denyInfrastructure('ec_command_not_canonical', canonicalEcApproval?.parseFailure
|
|
3772
3775
|
? `EC command approval denied because canonical argv parsing failed (${canonicalEcApproval.parseFailure.issue})`
|
|
3773
|
-
+ (canonicalEcApproval.parseFailure
|
|
3774
|
-
? '. PowerShell treats U+2018/U+2019/U+201A/U+201B as quote delimiters too. An EC inline text argument must be ASCII single-quoted; replace any character inside it that looks like a quote with U+02BC or U+FF07, or write the text to the session TMPDIR and pass it with --text-from-file.'
|
|
3775
|
-
: '')
|
|
3776
|
+
+ `。${literalShellParseRemedy(canonicalEcApproval.parseFailure) ?? ''}`
|
|
3776
3777
|
: 'EC command approval denied because no canonical argv could be derived', canonicalEcApproval?.parseFailure?.issue === 'invalid-quote' ? 'INVALID_QUOTE' : undefined);
|
|
3777
3778
|
}
|
|
3778
3779
|
try {
|
|
@@ -3807,25 +3808,31 @@ export class CodexRunner {
|
|
|
3807
3808
|
}
|
|
3808
3809
|
const response = this.toAppServerApprovalResponse(request.method, decision, toolInput, unattended);
|
|
3809
3810
|
const decisionSource = resolutionMeta?.decisionSource
|
|
3810
|
-
?? (sessionMode === 'auto' || sessionMode === 'readonly' ? 'policy' : '
|
|
3811
|
+
?? (sessionMode === 'auto' || sessionMode === 'readonly' ? 'policy' : 'infrastructure');
|
|
3811
3812
|
const policyCode = resolutionMeta?.policyCode
|
|
3812
|
-
?? (decisionSource === 'policy' ? 'permission_mode_denied' : undefined);
|
|
3813
|
-
const
|
|
3813
|
+
?? (decisionSource === 'policy' ? 'permission_mode_denied' : decision === 'deny' ? 'approval_failure_unknown' : undefined);
|
|
3814
|
+
const errorDetailCode = resolutionMeta?.errorDetailCode
|
|
3815
|
+
?? (decision === 'deny' && policyCode === 'approval_failure_unknown' ? 'APPROVAL_FAILURE_UNKNOWN' : undefined);
|
|
3816
|
+
const denialReason = resolutionMeta?.reason || (decisionSource === 'policy'
|
|
3814
3817
|
? `permission mode ${sessionMode} denied approval`
|
|
3815
|
-
: '
|
|
3818
|
+
: '审批失败,具体原因未知;操作未执行。');
|
|
3816
3819
|
if (decision === 'deny') {
|
|
3817
3820
|
this.rememberToolDenial(request, params, {
|
|
3818
3821
|
decision: 'deny',
|
|
3819
3822
|
decisionSource,
|
|
3820
3823
|
...(policyCode ? { policyCode } : {}),
|
|
3821
|
-
...(
|
|
3824
|
+
...(errorDetailCode ? { errorDetailCode } : {}),
|
|
3825
|
+
approvalRequestId: resolutionMeta?.requestId,
|
|
3826
|
+
approverOperatorId: resolutionMeta?.approverOperatorId,
|
|
3827
|
+
approverChannelKey: resolutionMeta?.approverChannelKey,
|
|
3828
|
+
approverPrincipalId: resolutionMeta?.approverPrincipalId,
|
|
3822
3829
|
reason: denialReason,
|
|
3823
3830
|
});
|
|
3824
3831
|
setImmediate(() => this.steerPolicyReason(sessionKey, policyCode, denialReason));
|
|
3825
3832
|
}
|
|
3826
3833
|
this.logAppServerApprovalAudit(request, sessionKey, toolName, decision === 'deny' ? 'deny' : 'allow', decision === 'deny' ? decisionSource : 'approval', decision === 'deny' ? policyCode : undefined, decision === 'deny'
|
|
3827
3834
|
? denialReason
|
|
3828
|
-
: 'approval accepted');
|
|
3835
|
+
: 'approval accepted', undefined, { ...resolutionMeta, errorDetailCode });
|
|
3829
3836
|
logger.info(`[CodexRunner] app-server approval response id=${request.id} method=${request.method} decision=${decision} response=${JSON.stringify(response)}`);
|
|
3830
3837
|
return response;
|
|
3831
3838
|
}
|
|
@@ -3835,7 +3842,14 @@ export class CodexRunner {
|
|
|
3835
3842
|
throw error;
|
|
3836
3843
|
}
|
|
3837
3844
|
}
|
|
3838
|
-
logAppServerApprovalAudit(request, sessionKey, toolName, decision, decisionSource, policyCode, reason, parseFailure) {
|
|
3845
|
+
logAppServerApprovalAudit(request, sessionKey, toolName, decision, decisionSource, policyCode, reason, parseFailure, resolution) {
|
|
3846
|
+
const approvalMetadata = {
|
|
3847
|
+
approvalRequestId: resolution?.requestId,
|
|
3848
|
+
errorDetailCode: resolution?.errorDetailCode,
|
|
3849
|
+
approverOperatorId: resolution?.approverOperatorId,
|
|
3850
|
+
approverChannelKey: resolution?.approverChannelKey,
|
|
3851
|
+
approverPrincipalId: resolution?.approverPrincipalId,
|
|
3852
|
+
};
|
|
3839
3853
|
const context = this.permissionContexts.get(sessionKey);
|
|
3840
3854
|
const params = (request.params || {});
|
|
3841
3855
|
const rawCallId = params.itemId ?? params.item_id ?? params.callId ?? params.call_id;
|
|
@@ -3851,6 +3865,7 @@ export class CodexRunner {
|
|
|
3851
3865
|
? params.cwd
|
|
3852
3866
|
: undefined;
|
|
3853
3867
|
auditCodexApprovalDecision({
|
|
3868
|
+
...approvalMetadata,
|
|
3854
3869
|
requestId: request.id !== undefined ? String(request.id) : undefined,
|
|
3855
3870
|
callId,
|
|
3856
3871
|
correlationId: callId,
|
|
@@ -3879,6 +3894,7 @@ export class CodexRunner {
|
|
|
3879
3894
|
?? `codex-approval-${crypto.randomUUID()}`;
|
|
3880
3895
|
auditPermissionLifecycle({
|
|
3881
3896
|
phase: 'response',
|
|
3897
|
+
...approvalMetadata,
|
|
3882
3898
|
requestId: lifecycleRequestId,
|
|
3883
3899
|
callId,
|
|
3884
3900
|
correlationId: callId,
|
|
@@ -3898,6 +3914,7 @@ export class CodexRunner {
|
|
|
3898
3914
|
});
|
|
3899
3915
|
auditPermissionLifecycle({
|
|
3900
3916
|
phase: 'final',
|
|
3917
|
+
...approvalMetadata,
|
|
3901
3918
|
requestId: lifecycleRequestId,
|
|
3902
3919
|
callId,
|
|
3903
3920
|
correlationId: callId,
|
|
@@ -3916,6 +3933,7 @@ export class CodexRunner {
|
|
|
3916
3933
|
approvalMethod: request.method,
|
|
3917
3934
|
});
|
|
3918
3935
|
logger.info(`[CodexRunner] app-server approval audit ${JSON.stringify({
|
|
3936
|
+
...approvalMetadata,
|
|
3919
3937
|
requestId: request.id !== undefined ? String(request.id) : undefined,
|
|
3920
3938
|
...(callId ? { callId, correlationId: callId } : {}),
|
|
3921
3939
|
method: request.method,
|
|
@@ -4484,11 +4502,12 @@ export class CodexRunner {
|
|
|
4484
4502
|
}
|
|
4485
4503
|
async resolvePermissionDecision(sessionKey, toolName, toolInput, summary, reason, workspacePath = process.cwd(), operationCwd = workspacePath, requestId, callId) {
|
|
4486
4504
|
const permissionContext = this.permissionContexts.get(sessionKey);
|
|
4505
|
+
const resolutionRequestId = requestId !== undefined ? String(requestId) : `codex-approval-${crypto.randomUUID()}`;
|
|
4487
4506
|
try {
|
|
4488
4507
|
await assertOwnershipAuthorization(permissionContext);
|
|
4489
4508
|
}
|
|
4490
4509
|
catch {
|
|
4491
|
-
return '
|
|
4510
|
+
return permissionFailureResult(resolutionRequestId, 'ownership_authorization_failed');
|
|
4492
4511
|
}
|
|
4493
4512
|
// 系统会话:审批路径同样只看模块判定(FileChange / PermissionGrant 一律被模块拒绝)
|
|
4494
4513
|
if (permissionContext?.systemSessionCheck) {
|
|
@@ -4520,7 +4539,7 @@ export class CodexRunner {
|
|
|
4520
4539
|
const mode = normalizeExecutionPermissionMode(rawMode);
|
|
4521
4540
|
if (rawMode === 'fullaccess') {
|
|
4522
4541
|
if (!this.isTrustedFullAccessSession(sessionKey)) {
|
|
4523
|
-
return 'deny';
|
|
4542
|
+
return { decision: 'deny', decisionSource: 'policy', policyCode: 'fullaccess_untrusted', reason: '当前会话未通过完整访问授权校验。' };
|
|
4524
4543
|
}
|
|
4525
4544
|
return 'allow';
|
|
4526
4545
|
}
|
|
@@ -4565,6 +4584,7 @@ export class CodexRunner {
|
|
|
4565
4584
|
catch (error) {
|
|
4566
4585
|
logger.warn(`[CodexRunner] failed to record blocked operation: session=${sessionKey} tool=${toolName} code=${policyCode} error=${error instanceof Error ? error.message : String(error)}`);
|
|
4567
4586
|
}
|
|
4587
|
+
return { decision: 'deny', decisionSource: 'policy', requestId: resolutionRequestId, policyCode, reason: denialReason };
|
|
4568
4588
|
};
|
|
4569
4589
|
const preflight = evaluateToolPreflight(toolName, toolInput, {
|
|
4570
4590
|
sessionId: sessionKey,
|
|
@@ -4610,23 +4630,31 @@ export class CodexRunner {
|
|
|
4610
4630
|
const hasConcreteChanges = this.normalizeFileChanges(checkedInput.fileChanges)
|
|
4611
4631
|
.some(change => typeof change?.path === 'string' && change.path.length > 0);
|
|
4612
4632
|
if (!hasGrantRoot && !hasConcreteChanges)
|
|
4613
|
-
return
|
|
4633
|
+
return {
|
|
4634
|
+
decision: 'deny', decisionSource: 'infrastructure', policyCode: 'approval_file_changes_missing',
|
|
4635
|
+
errorDetailCode: 'FILE_CHANGE_INPUT_MISSING', reason: '无法审批文件编辑:审批请求缺少目标文件信息;操作未执行。',
|
|
4636
|
+
};
|
|
4614
4637
|
}
|
|
4615
4638
|
if (toolName === 'Bash' && !hasPermissionExpansion) {
|
|
4616
4639
|
const command = typeof checkedInput.command === 'string'
|
|
4617
4640
|
? checkedInput.command.trim()
|
|
4618
4641
|
: '';
|
|
4619
4642
|
if (!command)
|
|
4620
|
-
return
|
|
4643
|
+
return {
|
|
4644
|
+
decision: 'deny', decisionSource: 'infrastructure', policyCode: 'approval_command_missing',
|
|
4645
|
+
errorDetailCode: 'COMMAND_INPUT_MISSING', reason: '无法审批命令:审批请求缺少命令信息;操作未执行。',
|
|
4646
|
+
};
|
|
4621
4647
|
}
|
|
4622
4648
|
if (toolName === 'PermissionGrant' && !hasPermissionExpansion)
|
|
4623
|
-
return
|
|
4649
|
+
return {
|
|
4650
|
+
decision: 'deny', decisionSource: 'infrastructure', policyCode: 'approval_permissions_missing',
|
|
4651
|
+
errorDetailCode: 'PERMISSION_INPUT_MISSING', reason: '无法审批权限申请:请求缺少可识别的权限范围;操作未执行。',
|
|
4652
|
+
};
|
|
4624
4653
|
const grantScope = `codex:${this.permissionProfileName(sessionKey)}:${mode}`;
|
|
4625
4654
|
if (mode === 'readonly') {
|
|
4626
4655
|
const readonly = this.checkCodexReadonly(policyToolName, policyInput, operationCwd, sessionKey);
|
|
4627
4656
|
if (readonly.behavior === 'deny') {
|
|
4628
|
-
|
|
4629
|
-
return 'deny';
|
|
4657
|
+
return recordBlockedOperation(readonly.policyCode ?? 'readonly_mode', policyInput, readonly.message);
|
|
4630
4658
|
}
|
|
4631
4659
|
return 'allow';
|
|
4632
4660
|
}
|
|
@@ -4636,49 +4664,36 @@ export class CodexRunner {
|
|
|
4636
4664
|
// auto 模式下检查危险命令,危险命令自动拒绝
|
|
4637
4665
|
if (mode === 'auto') {
|
|
4638
4666
|
if (hasFileChangeExpansion || hasFilesystemPermissions || hasUnknownPermissions) {
|
|
4639
|
-
|
|
4640
|
-
return 'deny';
|
|
4667
|
+
return recordBlockedOperation('auto_permission_expansion', policyInput, 'auto 权限模式不允许扩大文件系统权限;操作未执行。');
|
|
4641
4668
|
}
|
|
4642
4669
|
if (toolName === 'PermissionGrant' && !hasNetworkPermissions) {
|
|
4643
|
-
|
|
4644
|
-
return 'deny';
|
|
4670
|
+
return recordBlockedOperation('auto_permission_expansion', checkedInput, 'auto 权限模式不允许此权限扩展;操作未执行。');
|
|
4645
4671
|
}
|
|
4646
4672
|
const dangerous = checkDangerousCommand(toolName, checkedInput);
|
|
4647
4673
|
if (dangerous.isDangerous) {
|
|
4648
|
-
|
|
4649
|
-
return 'deny';
|
|
4674
|
+
return recordBlockedOperation('auto_dangerous_command', checkedInput, 'auto 权限模式不允许执行此危险操作;操作未执行。');
|
|
4650
4675
|
}
|
|
4651
4676
|
return 'allow';
|
|
4652
4677
|
}
|
|
4653
4678
|
const requiresSandboxExpansionApproval = hasFileChangeExpansion
|
|
4654
4679
|
|| hasFilesystemPermissions
|
|
4655
4680
|
|| hasUnknownPermissions;
|
|
4656
|
-
const resolveRuntimeApproval = (decision) => {
|
|
4657
|
-
if (decision === 'deny' && permissionContext?.approvalInteractionPolicy === 'deny') {
|
|
4658
|
-
return {
|
|
4659
|
-
decision: 'deny',
|
|
4660
|
-
decisionSource: 'policy',
|
|
4661
|
-
policyCode: 'permission_mode_denied',
|
|
4662
|
-
reason: 'permission mode denied runtime approval',
|
|
4663
|
-
};
|
|
4664
|
-
}
|
|
4665
|
-
return decision;
|
|
4666
|
-
};
|
|
4667
4681
|
if (requiresSandboxExpansionApproval) {
|
|
4682
|
+
if (permissionContext?.approvalInteractionPolicy === 'deny') {
|
|
4683
|
+
return permissionFailureResult(resolutionRequestId, 'permission_mode_denied', {}, 'permission_mode_denied');
|
|
4684
|
+
}
|
|
4668
4685
|
if (!this.permissionGateway || !permissionPrompt) {
|
|
4669
|
-
return
|
|
4670
|
-
? resolveRuntimeApproval('deny')
|
|
4671
|
-
: 'deny';
|
|
4686
|
+
return permissionFailureResult(resolutionRequestId, !this.permissionGateway ? 'approval_gateway_unavailable' : 'approval_prompt_unavailable', {}, 'approval_channel_unavailable');
|
|
4672
4687
|
}
|
|
4673
4688
|
if (policyToolName === 'FileChange') {
|
|
4674
|
-
return
|
|
4689
|
+
return this.permissionGateway.requestPermissionResult(sessionKey, policyToolName, policyInput, permissionPrompt, { ...permissionContext, permissionMode: mode }, summary, reason || 'Codex 请求扩大当前命令或 turn 的文件系统权限', grantScope, undefined, { fileChangeCwd: workspacePath });
|
|
4675
4690
|
}
|
|
4676
|
-
return
|
|
4691
|
+
return this.permissionGateway.requestPermissionResult(sessionKey, toolName, checkedInput, permissionPrompt, { ...permissionContext, permissionMode: mode }, summary, reason || 'Codex 请求扩大当前命令或 turn 的文件系统权限', grantScope, undefined, toolName === 'PermissionGrant' ? { filesystemCwd: operationCwd, workspacePath } : undefined);
|
|
4677
4692
|
}
|
|
4678
4693
|
if (mode === 'request' || mode === 'bypass') {
|
|
4679
|
-
const dangerous = await
|
|
4694
|
+
const dangerous = await requestDangerousCommandPermissionResult(this.permissionGateway, sessionKey, toolName, checkedInput, permissionPrompt, this.permissionContexts.get(sessionKey), grantScope, mode);
|
|
4680
4695
|
if (dangerous.matched)
|
|
4681
|
-
return
|
|
4696
|
+
return dangerous.result;
|
|
4682
4697
|
return 'allow';
|
|
4683
4698
|
}
|
|
4684
4699
|
// Network is already part of every profile, so a defensive
|
|
@@ -5598,6 +5613,10 @@ export class CodexRunner {
|
|
|
5598
5613
|
policyCode: denial.policyCode,
|
|
5599
5614
|
reason: denial.reason,
|
|
5600
5615
|
requestId: denial.requestId,
|
|
5616
|
+
approvalRequestId: denial.approvalRequestId,
|
|
5617
|
+
approverOperatorId: denial.approverOperatorId,
|
|
5618
|
+
approverChannelKey: denial.approverChannelKey,
|
|
5619
|
+
approverPrincipalId: denial.approverPrincipalId,
|
|
5601
5620
|
executed: false,
|
|
5602
5621
|
executionState: 'blocked',
|
|
5603
5622
|
}
|