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
|
@@ -5,12 +5,12 @@ import { formatAsyncQuestionAnswer, hasTrustedFullAccessContext, parseAsyncUserQ
|
|
|
5
5
|
import { requestDangerousCommandPermissionResult } from '../core/permission/approval-gateway.js';
|
|
6
6
|
import { permissionFailureResult } from '../core/permission/permission-result.js';
|
|
7
7
|
import { checkReadonly, checkDangerousCommand, evaluateToolPreflight } from '../core/permission/tool-policy.js';
|
|
8
|
-
import { isShellToolName } from '../core/permission/tool-canonical.js';
|
|
8
|
+
import { isShellToolName, normalizeFileMutation } from '../core/permission/tool-canonical.js';
|
|
9
9
|
import { normalizeExecutionPermissionMode, normalizePermissionMode, resolvePhaseOneExecutionSandbox } from '../core/permission/mode.js';
|
|
10
10
|
import { assertWindowsCodexFilesystemRuleBudget, buildCodexProtectedFilesystemRules, compactCodexLinuxFilesystemRules, getExistingRelationAttachmentDirs, isSameOrDescendant, resolveProtectedCandidate, } from '../core/permission/protected-paths.js';
|
|
11
11
|
import { CODEX_THREAD_ACTIVE_WRITER, CodexAppServerClient, } from './codex/app-server-client.js';
|
|
12
12
|
import { getSandboxInitializationFailureCounters, isNestedSandboxInitializationFailure, recordSandboxInitializationFailure, SANDBOX_INITIALIZATION_FAILED, } from '../core/permission/sandbox-runtime.js';
|
|
13
|
-
import { resolveOpenaiConfig, resolveCodexCliPath, resolveCodexPowerShellShimPath, } from './baseagent.js';
|
|
13
|
+
import { resolveOpenaiConfig, resolveRuntimeBaseagentModelSelection, resolveCodexCliPath, resolveCodexPowerShellShimPath, } from './baseagent.js';
|
|
14
14
|
import { logger } from '../utils/logger.js';
|
|
15
15
|
import { resolveProviderService } from '../config/providers.js';
|
|
16
16
|
import { catalogHash } from '../core/model/catalog-service.js';
|
|
@@ -21,12 +21,13 @@ import { findModelSpec, getGatewayPricing as getSharedGatewayPricing } from '../
|
|
|
21
21
|
import { renderActionAsText } from '../core/interaction-router.js';
|
|
22
22
|
import { buildEnvelope, isInteractionSendAccepted, sendInteractionPayload } from '../core/message/message-utils.js';
|
|
23
23
|
import { resolveCodexCapabilityThreadConfigForProject } from '../core/capability/capability-manager.js';
|
|
24
|
+
import { resolveEffective } from '../config/config-manager.js';
|
|
24
25
|
import { AGENT_DELEGATION_TOKEN_ENV, CODEX_SESSION_TOKEN_ENV, hashDelegatedCommandArgv, hashDelegatedCommandSpec, parseDelegatedExecutionSpec, } from '../core/auth/agent-delegation.js';
|
|
25
26
|
import { sanitizeShellExecutionEnvironment } from '../core/permission/shell-environment.js';
|
|
26
|
-
import { classifyEvolcoreShellCommand, literalShellParseRemedy, containsLiteralManagedTmpDirOutsideSendContent, containsUnresolvedManagedTmpDirReference, hasCodexCmdCarrierEcIntent, hasPowerShellCredentialAssignment, normalizeEvolcoreCommandArgv, parseLiteralShellArgv, resolveCodexShellCarrierArgv,
|
|
27
|
+
import { classifyEvolcoreShellCommand, canonicalizeEvolcoreCommandArgv, literalShellParseRemedy, containsLiteralManagedTmpDirOutsideSendContent, containsUnresolvedManagedTmpDirReference, hasCodexCmdCarrierEcIntent, hasPowerShellCredentialAssignment, normalizeEvolcoreCommandArgv, parseLiteralShellArgv, resolveCodexShellCarrierArgv, resolveCanonicalEvolcoreToolInput, serializeCanonicalEvolcoreExecutionSpec, } from '../core/permission/ec-command-parser.js';
|
|
27
28
|
import { compareVersions } from '../utils/npm-ops.js';
|
|
28
29
|
import { agentCodexTokenPath, getPackageRoot, resolvePaths, resolveRoot } from '../paths.js';
|
|
29
|
-
import { MAIN_CLI_BIN } from '../product.js';
|
|
30
|
+
import { CODEX_HOOK_TOKEN_ENV, MAIN_CLI_BIN } from '../product.js';
|
|
30
31
|
import { ensureSessionRuntimeDir, getManagedTaskTempDir } from '../cli/task-context.js';
|
|
31
32
|
import { buildTranscriptTurns } from '../core/session/session-transcript.js';
|
|
32
33
|
import { CodexSessionFileAdapter } from '../core/session/adapters/codex-session-file-adapter.js';
|
|
@@ -34,7 +35,7 @@ import { execFileSync } from 'child_process';
|
|
|
34
35
|
import { probeCli, probeCliSync } from '../utils/cross-platform.js';
|
|
35
36
|
import { createHash, randomBytes } from 'crypto';
|
|
36
37
|
import { buildModelRequestHeaders } from './request-identity.js';
|
|
37
|
-
import { normalizeToolErrorClassification, normalizeToolErrorCode, normalizeToolErrorDetailCode, } from '../core/permission/tool-error-code.js';
|
|
38
|
+
import { extractStructuredToolErrorMarker, normalizeToolErrorClassification, normalizeToolErrorCode, normalizeToolErrorDetailCode, } from '../core/permission/tool-error-code.js';
|
|
38
39
|
import fs from 'fs';
|
|
39
40
|
import { assertOwnershipAuthorization } from '../core/ownership/owner-resolver.js';
|
|
40
41
|
import path from 'path';
|
|
@@ -391,8 +392,36 @@ export function getCodexAppServerAvailability() {
|
|
|
391
392
|
export function isCodexAppServerAvailable() {
|
|
392
393
|
return getCodexAppServerAvailability().available;
|
|
393
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* 启动期可用性探测结果缓存。
|
|
397
|
+
*
|
|
398
|
+
* 每次探测是一次完整的 Codex CLI 启动(Windows 上 0.3-0.45s)。启动时每个 codex
|
|
399
|
+
* agent 都会调一次(21 个 agent 就是 21 次进程启动),并行创建 runner 后会同时抢
|
|
400
|
+
* CPU,反而更慢。这里缓存整个探测的 Promise:并发调用共享同一轮探测,失败结果也
|
|
401
|
+
* 缓存,避免热加载反复重试。
|
|
402
|
+
*
|
|
403
|
+
* 用 TTL 而不是永久缓存:用户可能在 daemon 运行期间升级 Codex CLI,过期的失败结论
|
|
404
|
+
* 不应永久黏住。
|
|
405
|
+
*/
|
|
406
|
+
const CODEX_AVAILABILITY_CACHE_TTL_MS = 60_000;
|
|
407
|
+
let codexAvailabilityCache = null;
|
|
408
|
+
/** 让测试与显式刷新(例如安装 Codex 后)能清掉缓存。 */
|
|
409
|
+
export function invalidateCodexAppServerAvailabilityCache() {
|
|
410
|
+
codexAvailabilityCache = null;
|
|
411
|
+
}
|
|
394
412
|
/** Daemon startup/hot reload use asynchronous probes; sync CLI callers share the cache. */
|
|
395
413
|
export async function getCodexAppServerAvailabilityAsync() {
|
|
414
|
+
const now = Date.now();
|
|
415
|
+
if (codexAvailabilityCache && now - codexAvailabilityCache.at < CODEX_AVAILABILITY_CACHE_TTL_MS) {
|
|
416
|
+
return codexAvailabilityCache.promise;
|
|
417
|
+
}
|
|
418
|
+
const promise = probeCodexAppServerAvailabilityAsync();
|
|
419
|
+
codexAvailabilityCache = { at: now, promise };
|
|
420
|
+
// 失败的 Promise 同样要能被后续调用复用,但不能产生未处理拒绝。
|
|
421
|
+
promise.catch(() => { });
|
|
422
|
+
return promise;
|
|
423
|
+
}
|
|
424
|
+
async function probeCodexAppServerAvailabilityAsync() {
|
|
396
425
|
const cliPath = resolveCodexCliPath();
|
|
397
426
|
const options = {
|
|
398
427
|
timeouts: [CODEX_CLI_PROBE_TIMEOUT_MS, CODEX_CLI_PROBE_RETRY_TIMEOUT_MS],
|
|
@@ -482,16 +511,20 @@ export class CodexRunner {
|
|
|
482
511
|
/** Fallback authorization lifecycle ids for app-server requests without an RPC id. */
|
|
483
512
|
approvalLifecycleIds = new WeakMap();
|
|
484
513
|
resolvedConfig;
|
|
514
|
+
modelConfig;
|
|
485
515
|
codexVersion;
|
|
486
516
|
pendingInterruptTtlMs = 30_000;
|
|
487
517
|
/** Fallback for direct runner callers that do not inject SessionManager. */
|
|
488
518
|
codexSessionFileAdapter = new CodexSessionFileAdapter();
|
|
489
|
-
/** threadId →
|
|
519
|
+
/** threadId → CLI session credential, issued by this runner's agent only. */
|
|
490
520
|
threadCredentials = new Map();
|
|
521
|
+
/** Hook processes inherit the app-server environment, not thread shell settings. */
|
|
522
|
+
managedHookToken = randomBytes(32).toString('hex');
|
|
491
523
|
/** @deprecated Compatibility alias for direct runner integrations. */
|
|
492
524
|
threadDelegationCarriers = this.threadCredentials;
|
|
493
525
|
asyncQuestionItems = new Set();
|
|
494
526
|
constructor(config, callbacks, runtime) {
|
|
527
|
+
this.modelConfig = config.agents?.codex ?? {};
|
|
495
528
|
// Compatibility for legacy direct callers that still pass the removed
|
|
496
529
|
// internal fields in a synthetic config. AgentLoader uses runtime binding.
|
|
497
530
|
const legacy = config.agents?.codex;
|
|
@@ -554,6 +587,7 @@ export class CodexRunner {
|
|
|
554
587
|
approvalsReviewer: 'user',
|
|
555
588
|
protectEvolcoreFilesystem: !fullAccess,
|
|
556
589
|
selfAid: this.resolvedConfig.agentAid,
|
|
590
|
+
env: { [CODEX_HOOK_TOKEN_ENV]: this.managedHookToken },
|
|
557
591
|
// A completed turn is explicitly unsubscribed below. This is only an
|
|
558
592
|
// optimization on newer Codex versions; old versions retain the thread
|
|
559
593
|
// until the cross-client archive fallback runs.
|
|
@@ -870,12 +904,12 @@ export class CodexRunner {
|
|
|
870
904
|
const command = typeof toolInput.command === 'string' ? toolInput.command : '';
|
|
871
905
|
return classifyEvolcoreShellCommand(command).kind !== 'none';
|
|
872
906
|
}
|
|
873
|
-
armApprovedDelegationCommand(sessionId, argv, approvalId, specHash, executionSpec) {
|
|
907
|
+
armApprovedDelegationCommand(sessionId, argv, approvalId, specHash, executionSpec, credentialToken) {
|
|
874
908
|
const threadId = this.activeSessions.get(sessionId) ?? this.provisionalSessions.get(sessionId);
|
|
875
|
-
const sessionToken = threadId ? this.ensureThreadCredentialLoaded(threadId) : undefined;
|
|
909
|
+
const sessionToken = credentialToken ?? (threadId ? this.ensureThreadCredentialLoaded(threadId) : undefined);
|
|
876
910
|
const commandHash = executionSpec
|
|
877
911
|
? hashDelegatedCommandArgv(executionSpec.argv, executionSpec)
|
|
878
|
-
: hashDelegatedCommandArgv(argv);
|
|
912
|
+
: hashDelegatedCommandArgv(canonicalizeEvolcoreCommandArgv(argv));
|
|
879
913
|
const arm = this.permissionContexts.get(sessionId)?.armApprovedDelegationCommand;
|
|
880
914
|
if (!sessionToken || !commandHash || !arm)
|
|
881
915
|
return false;
|
|
@@ -889,6 +923,32 @@ export class CodexRunner {
|
|
|
889
923
|
return false;
|
|
890
924
|
}
|
|
891
925
|
}
|
|
926
|
+
/**
|
|
927
|
+
* Bind a literal managed EC command to the current Codex tool call.
|
|
928
|
+
*
|
|
929
|
+
* Non-fullaccess Codex threads carry a thread credential instead of the
|
|
930
|
+
* task delegation token. The daemon therefore requires a one-shot command
|
|
931
|
+
* approval even when PreToolUse already allowed the command. Keep this
|
|
932
|
+
* binding at the canonical EC argv boundary so every subcommand and option
|
|
933
|
+
* is covered without maintaining a command allowlist here.
|
|
934
|
+
*
|
|
935
|
+
* Returns undefined for non-EC input and false for an EC command that could
|
|
936
|
+
* not be safely bound.
|
|
937
|
+
*/
|
|
938
|
+
armManagedEcCommand(sessionId, toolInput, callId, sessionToken, managedTempDir) {
|
|
939
|
+
if (!sessionToken)
|
|
940
|
+
return undefined;
|
|
941
|
+
const canonical = this.resolveCanonicalEcApproval(toolInput, managedTempDir, sessionToken);
|
|
942
|
+
if (canonical.parseFailure)
|
|
943
|
+
return false;
|
|
944
|
+
if (!canonical.argv)
|
|
945
|
+
return this.isManagedEvolcoreCommandIntent(toolInput) ? false : undefined;
|
|
946
|
+
if (canonical.executionSpec || !callId)
|
|
947
|
+
return false;
|
|
948
|
+
if (canonical.credentialToken && canonical.credentialToken !== sessionToken)
|
|
949
|
+
return false;
|
|
950
|
+
return this.armApprovedDelegationCommand(sessionId, canonical.argv, callId, undefined, undefined, sessionToken);
|
|
951
|
+
}
|
|
892
952
|
parseSafeOutputCommand(command) {
|
|
893
953
|
const argv = typeof command === 'string' ? parseLiteralShellArgv(command) : [...command];
|
|
894
954
|
if (!argv || argv.length !== 3 || argv[0] !== process.execPath)
|
|
@@ -1065,12 +1125,20 @@ export class CodexRunner {
|
|
|
1065
1125
|
return Object.keys(merged).length > 0 ? merged : null;
|
|
1066
1126
|
}
|
|
1067
1127
|
async resolveCapabilityThreadConfig(projectPath) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1128
|
+
// 每次调用按当前 effective 配置解析;构造期快照会让 capability/baseagentSkills 改动要等 runner 重建才生效。
|
|
1129
|
+
let agentConfig = this.resolvedConfig.agentConfig;
|
|
1130
|
+
if (this.resolvedConfig.agentAid) {
|
|
1131
|
+
try {
|
|
1132
|
+
agentConfig = resolveEffective({ self: this.resolvedConfig.agentAid }, { cache: true });
|
|
1133
|
+
}
|
|
1134
|
+
catch { }
|
|
1073
1135
|
}
|
|
1136
|
+
// 拿不到配置时按 baseagentSkills 缺省值(关闭)处理。
|
|
1137
|
+
const fallbackConfig = {
|
|
1138
|
+
skills: { include_instructions: false, bundled: { enabled: false }, config: [{ name: 'eclink', enabled: false }] },
|
|
1139
|
+
};
|
|
1140
|
+
if (!agentConfig)
|
|
1141
|
+
return fallbackConfig;
|
|
1074
1142
|
try {
|
|
1075
1143
|
const resolved = await resolveCodexCapabilityThreadConfigForProject(agentConfig, projectPath, 'codex');
|
|
1076
1144
|
const skills = this.configRecord(resolved.skills);
|
|
@@ -1086,15 +1154,11 @@ export class CodexRunner {
|
|
|
1086
1154
|
...(skills ?? {}),
|
|
1087
1155
|
config: [...configured, { name: 'eclink', enabled: false }],
|
|
1088
1156
|
},
|
|
1089
|
-
}) ??
|
|
1090
|
-
skills: { config: [{ name: 'eclink', enabled: false }] },
|
|
1091
|
-
};
|
|
1157
|
+
}) ?? fallbackConfig;
|
|
1092
1158
|
}
|
|
1093
1159
|
catch (error) {
|
|
1094
1160
|
logger.warn(`[CodexRunner] Failed to resolve Codex capability thread config: ${error}`);
|
|
1095
|
-
return
|
|
1096
|
-
skills: { config: [{ name: 'eclink', enabled: false }] },
|
|
1097
|
-
};
|
|
1161
|
+
return fallbackConfig;
|
|
1098
1162
|
}
|
|
1099
1163
|
}
|
|
1100
1164
|
configRecord(value) {
|
|
@@ -1575,15 +1639,30 @@ export class CodexRunner {
|
|
|
1575
1639
|
/**
|
|
1576
1640
|
* Decide whether the managed hook may proceed with a tool call.
|
|
1577
1641
|
*
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
1583
|
-
* - sessionToken absent → unmanaged process; not this runner's concern
|
|
1584
|
-
* (applicable=false; the IPC layer allows such calls outright).
|
|
1642
|
+
* The process Hook credential selects its owning runner; the active thread
|
|
1643
|
+
* binding then supplies the CLI session credential inside the daemon.
|
|
1644
|
+
* Legacy callers may still supply a thread credential directly. Unknown or
|
|
1645
|
+
* untracked managed calls never receive an allow. Unmanaged calls carry
|
|
1646
|
+
* neither credential and are handled before runner dispatch.
|
|
1585
1647
|
*/
|
|
1586
|
-
async evaluatePreToolUse(threadId, toolName, toolInput, signal, callId, sessionToken) {
|
|
1648
|
+
async evaluatePreToolUse(threadId, toolName, toolInput, signal, callId, sessionToken, hookToken) {
|
|
1649
|
+
if (hookToken) {
|
|
1650
|
+
// Shared daemon dispatch tries each runner. Only the process that
|
|
1651
|
+
// issued this Hook credential may resolve its thread credential.
|
|
1652
|
+
if (hookToken !== this.managedHookToken)
|
|
1653
|
+
return { ok: false, applicable: false };
|
|
1654
|
+
const boundSession = this.findSessionKeyByThread(threadId);
|
|
1655
|
+
if (!this.isThreadOwnedBySession(boundSession, threadId)) {
|
|
1656
|
+
return { ok: false, applicable: true, decision: 'deny',
|
|
1657
|
+
reason: 'EvolCore-managed Codex thread is not tracked by an active session' };
|
|
1658
|
+
}
|
|
1659
|
+
const threadCredential = this.ensureThreadCredentialLoaded(threadId);
|
|
1660
|
+
if (!threadCredential || (sessionToken && sessionToken !== threadCredential)) {
|
|
1661
|
+
return { ok: false, applicable: true, decision: 'deny',
|
|
1662
|
+
reason: 'Codex session credential was not recognized' };
|
|
1663
|
+
}
|
|
1664
|
+
sessionToken = threadCredential;
|
|
1665
|
+
}
|
|
1587
1666
|
if (typeof sessionToken === 'string' && sessionToken) {
|
|
1588
1667
|
if (!this.validateThreadCredential(threadId, sessionToken)) {
|
|
1589
1668
|
return {
|
|
@@ -1607,7 +1686,7 @@ export class CodexRunner {
|
|
|
1607
1686
|
return { ok: true, applicable: true, decision: 'deny', reason: error instanceof Error ? error.message : String(error) };
|
|
1608
1687
|
}
|
|
1609
1688
|
const isShellTool = isShellToolName(toolName); // canonical normalisation via tool-canonical.ts
|
|
1610
|
-
const recordPreToolUseDenial = async (policyCode, reason) => {
|
|
1689
|
+
const recordPreToolUseDenial = async (policyCode, reason, details) => {
|
|
1611
1690
|
const summary = summarizeToolInputForAudit(toolName, normalizedInput).slice(0, 512);
|
|
1612
1691
|
auditToolPreflightDenial({
|
|
1613
1692
|
toolName,
|
|
@@ -1625,7 +1704,22 @@ export class CodexRunner {
|
|
|
1625
1704
|
callId,
|
|
1626
1705
|
correlationId: callId,
|
|
1627
1706
|
taskId: context?.taskId,
|
|
1707
|
+
matchedPath: details?.matchedPath,
|
|
1628
1708
|
});
|
|
1709
|
+
try {
|
|
1710
|
+
context?.recordPreflightDenial?.({
|
|
1711
|
+
toolName,
|
|
1712
|
+
toolInput: normalizedInput,
|
|
1713
|
+
reason,
|
|
1714
|
+
policyCode,
|
|
1715
|
+
...(details?.errorDetailCode ? { errorDetailCode: details.errorDetailCode } : {}),
|
|
1716
|
+
...(details?.matchedPath ? { matchedPath: details.matchedPath } : {}),
|
|
1717
|
+
...(callId ? { callId, correlationId: callId } : {}),
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
catch (error) {
|
|
1721
|
+
logger.warn('[CodexRunner] failed to project managed-hook denial: session=' + sessionKey + ' tool=' + toolName + ' error=' + (error instanceof Error ? error.message : String(error)));
|
|
1722
|
+
}
|
|
1629
1723
|
try {
|
|
1630
1724
|
await context?.recordExecutionAnomaly?.({
|
|
1631
1725
|
code: 'operation_blocked',
|
|
@@ -1677,8 +1771,19 @@ export class CodexRunner {
|
|
|
1677
1771
|
// 系统会话:模块判定即最终结论,不进入 preflight / 角色 / permissionMode 分支
|
|
1678
1772
|
if (context.systemSessionCheck) {
|
|
1679
1773
|
const decision = context.systemSessionCheck(isShellTool ? 'Bash' : toolName, normalizedInput);
|
|
1680
|
-
if (decision.allow)
|
|
1774
|
+
if (decision.allow) {
|
|
1775
|
+
const trustedFullAccess = (this.chatModes.get(sessionKey) ?? this.currentMode) === 'fullaccess'
|
|
1776
|
+
&& this.isTrustedFullAccessSession(sessionKey);
|
|
1777
|
+
if (decision.ecCommand && !trustedFullAccess) {
|
|
1778
|
+
const armed = this.armManagedEcCommand(sessionKey, normalizedInput, callId, sessionToken, context.managedTempDir ?? this.getManagedTempDir(sessionKey));
|
|
1779
|
+
if (armed !== true) {
|
|
1780
|
+
const reason = 'EC command approval failed to arm delegation';
|
|
1781
|
+
await recordPreToolUseDenial('delegation_not_armed', reason);
|
|
1782
|
+
return { ok: true, applicable: true, decision: 'deny', reason };
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1681
1785
|
return { ok: true, applicable: true, decision: 'allow' };
|
|
1786
|
+
}
|
|
1682
1787
|
await recordPreToolUseDenial(decision.code, decision.reason);
|
|
1683
1788
|
return { ok: true, applicable: true, decision: 'deny', reason: decision.reason };
|
|
1684
1789
|
}
|
|
@@ -1709,7 +1814,10 @@ export class CodexRunner {
|
|
|
1709
1814
|
});
|
|
1710
1815
|
if (preflight.behavior === 'deny') {
|
|
1711
1816
|
const reason = preflight.message ?? 'tool preflight denied';
|
|
1712
|
-
await recordPreToolUseDenial(preflight.policyCode ?? 'tool_preflight_denied', reason
|
|
1817
|
+
await recordPreToolUseDenial(preflight.policyCode ?? 'tool_preflight_denied', reason, {
|
|
1818
|
+
errorDetailCode: preflight.errorDetailCode,
|
|
1819
|
+
matchedPath: preflight.matchedPath,
|
|
1820
|
+
});
|
|
1713
1821
|
return { ok: true, applicable: true, decision: 'deny', reason };
|
|
1714
1822
|
}
|
|
1715
1823
|
const updatedInput = preflight.behavior === 'allow' && preflight.input !== normalizedInput
|
|
@@ -1746,12 +1854,27 @@ export class CodexRunner {
|
|
|
1746
1854
|
this.registeredSafeOutputCalls.delete(key);
|
|
1747
1855
|
return false;
|
|
1748
1856
|
};
|
|
1857
|
+
const bindManagedEcCommand = async () => {
|
|
1858
|
+
// A rewritten safe-output command is already bound to its full
|
|
1859
|
+
// execution spec above. Do not create a second approval for the raw
|
|
1860
|
+
// source command, which is not what the child process will execute.
|
|
1861
|
+
if (safeExecutionSpec || !isShellTool)
|
|
1862
|
+
return true;
|
|
1863
|
+
const armed = this.armManagedEcCommand(sessionKey, normalizedInput, callId, sessionToken, context.managedTempDir ?? this.getManagedTempDir(sessionKey));
|
|
1864
|
+
if (armed !== false)
|
|
1865
|
+
return true;
|
|
1866
|
+
await recordPreToolUseDenial('delegation_not_armed', 'EC command approval failed to arm delegation');
|
|
1867
|
+
return false;
|
|
1868
|
+
};
|
|
1749
1869
|
// A tracked interactive thread still needs an authenticated, explicit
|
|
1750
1870
|
// allow so the managed hook can fail closed when no runner matches.
|
|
1751
1871
|
if (!context.preToolUsePolicyHook) {
|
|
1752
1872
|
if (!await bindSafeExecutionSpec()) {
|
|
1753
1873
|
return { ok: true, applicable: true, decision: 'deny', reason: '安全 EC 输出命令无法绑定到当前工具调用' };
|
|
1754
1874
|
}
|
|
1875
|
+
if (!await bindManagedEcCommand()) {
|
|
1876
|
+
return { ok: true, applicable: true, decision: 'deny', reason: 'EC command approval failed to arm delegation' };
|
|
1877
|
+
}
|
|
1755
1878
|
return {
|
|
1756
1879
|
ok: true, applicable: true, decision: 'allow',
|
|
1757
1880
|
...(updatedInput ? { updatedInput } : {}),
|
|
@@ -1773,6 +1896,9 @@ export class CodexRunner {
|
|
|
1773
1896
|
if (!await bindSafeExecutionSpec()) {
|
|
1774
1897
|
return { ok: true, applicable: true, decision: 'deny', reason: '安全 EC 输出命令无法绑定到当前工具调用' };
|
|
1775
1898
|
}
|
|
1899
|
+
if (!await bindManagedEcCommand()) {
|
|
1900
|
+
return { ok: true, applicable: true, decision: 'deny', reason: 'EC command approval failed to arm delegation' };
|
|
1901
|
+
}
|
|
1776
1902
|
return {
|
|
1777
1903
|
ok: true, applicable: true, decision: 'allow',
|
|
1778
1904
|
...(updatedInput ? { updatedInput } : {}),
|
|
@@ -2032,6 +2158,13 @@ export class CodexRunner {
|
|
|
2032
2158
|
error.code = 'TOPIC_TURN_LEASE_REQUIRED';
|
|
2033
2159
|
throw error;
|
|
2034
2160
|
}
|
|
2161
|
+
if (!this.model && !modelOverride?.model) {
|
|
2162
|
+
const selection = await resolveRuntimeBaseagentModelSelection('codex', {
|
|
2163
|
+
...this.modelConfig,
|
|
2164
|
+
...(modelOverride?.provider ? { provider: modelOverride.provider } : {}),
|
|
2165
|
+
});
|
|
2166
|
+
this.setModel(selection.model);
|
|
2167
|
+
}
|
|
2035
2168
|
const topicAgentSessionId = topicBinding ? modelOverride?.backend?.agentSessionId ?? null : undefined;
|
|
2036
2169
|
const knownThreadId = topicBinding
|
|
2037
2170
|
? this.cachedThreadForTopic(sessionId, topicAgentSessionId)
|
|
@@ -4512,9 +4645,28 @@ export class CodexRunner {
|
|
|
4512
4645
|
// 系统会话:审批路径同样只看模块判定(FileChange / PermissionGrant 一律被模块拒绝)
|
|
4513
4646
|
if (permissionContext?.systemSessionCheck) {
|
|
4514
4647
|
const decision = permissionContext.systemSessionCheck(toolName, toolInput);
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4648
|
+
if (decision.allow)
|
|
4649
|
+
return 'allow';
|
|
4650
|
+
const summary = summarizeToolInputForAudit(toolName, toolInput).slice(0, 512);
|
|
4651
|
+
auditToolPreflightDenial({
|
|
4652
|
+
toolName,
|
|
4653
|
+
policyCode: decision.code,
|
|
4654
|
+
reason: decision.reason,
|
|
4655
|
+
summary,
|
|
4656
|
+
sessionId: sessionKey,
|
|
4657
|
+
agentAid: permissionContext.selfAid,
|
|
4658
|
+
agentName: permissionContext.agentName,
|
|
4659
|
+
permissionMode: normalizeExecutionPermissionMode(this.chatModes.get(sessionKey) ?? this.currentMode),
|
|
4660
|
+
channel: permissionContext.channel,
|
|
4661
|
+
actorId: permissionContext.userId,
|
|
4662
|
+
role: permissionContext.role,
|
|
4663
|
+
selfAid: permissionContext.selfAid,
|
|
4664
|
+
requestId: typeof requestId === 'string' || typeof requestId === 'number' ? String(requestId) : undefined,
|
|
4665
|
+
callId,
|
|
4666
|
+
correlationId: callId,
|
|
4667
|
+
taskId: permissionContext.taskId,
|
|
4668
|
+
});
|
|
4669
|
+
return { decision: 'deny', decisionSource: 'policy', policyCode: decision.code, reason: decision.reason };
|
|
4518
4670
|
}
|
|
4519
4671
|
const permissionPrompt = permissionContext?.sendPrompt ?? this.sendPromptFn;
|
|
4520
4672
|
const hasFilesystemPermissions = (toolName === 'Bash' || toolName === 'PermissionGrant')
|
|
@@ -4523,17 +4675,20 @@ export class CodexRunner {
|
|
|
4523
4675
|
&& this.hasNetworkPermissionRequest(toolInput);
|
|
4524
4676
|
const hasUnknownPermissions = (toolName === 'Bash' || toolName === 'PermissionGrant')
|
|
4525
4677
|
&& this.hasUnknownPermissionRequest(toolInput);
|
|
4526
|
-
const
|
|
4527
|
-
|
|
4528
|
-
:
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4678
|
+
const sessionToken = this.sessionTokenForSession(sessionKey);
|
|
4679
|
+
const fileMutation = normalizeFileMutation(toolName, toolInput, {
|
|
4680
|
+
verifyShellExecutable: process.platform === 'win32',
|
|
4681
|
+
managedTempDir: permissionContext?.managedTempDir ?? this.getManagedTempDir(sessionKey),
|
|
4682
|
+
...(sessionToken ? { expectedCredentialToken: sessionToken } : {}),
|
|
4683
|
+
});
|
|
4684
|
+
const fileChanges = fileMutation.kind === 'file-mutation' ? fileMutation.fileChanges : undefined;
|
|
4685
|
+
const fileChangeInput = fileChanges
|
|
4686
|
+
? { ...toolInput, fileChanges }
|
|
4532
4687
|
: toolInput;
|
|
4533
4688
|
const hasPermissionExpansion = hasFilesystemPermissions || hasNetworkPermissions || hasUnknownPermissions;
|
|
4534
4689
|
const hasFileChangeExpansion = toolName === 'FileChange'
|
|
4535
|
-
? this.fileChangeRequiresExpansion(
|
|
4536
|
-
: !!
|
|
4690
|
+
? this.fileChangeRequiresExpansion(fileChangeInput, workspacePath, sessionKey)
|
|
4691
|
+
: !!fileChanges && this.fileChangeRequiresExpansion(fileChangeInput, workspacePath, sessionKey);
|
|
4537
4692
|
// per-session 权限模式(runQuery 写入);缺省回落实例级 currentMode(兼容无 runQuery 上下文的调用)
|
|
4538
4693
|
const rawMode = this.chatModes.get(sessionKey) ?? this.currentMode;
|
|
4539
4694
|
const mode = normalizeExecutionPermissionMode(rawMode);
|
|
@@ -4620,15 +4775,14 @@ export class CodexRunner {
|
|
|
4620
4775
|
if (preflight.behavior === 'allow')
|
|
4621
4776
|
return 'allow';
|
|
4622
4777
|
const checkedInput = preflight.input;
|
|
4623
|
-
const policyInput =
|
|
4624
|
-
? { ...checkedInput, fileChanges
|
|
4778
|
+
const policyInput = fileChanges
|
|
4779
|
+
? { ...checkedInput, fileChanges }
|
|
4625
4780
|
: checkedInput;
|
|
4626
|
-
const policyToolName =
|
|
4781
|
+
const policyToolName = fileChanges ? 'FileChange' : toolName;
|
|
4627
4782
|
if (toolName === 'FileChange') {
|
|
4628
4783
|
const hasGrantRoot = typeof checkedInput.grantRoot === 'string'
|
|
4629
4784
|
&& checkedInput.grantRoot.length > 0;
|
|
4630
|
-
const hasConcreteChanges =
|
|
4631
|
-
.some(change => typeof change?.path === 'string' && change.path.length > 0);
|
|
4785
|
+
const hasConcreteChanges = !!fileChanges?.length;
|
|
4632
4786
|
if (!hasGrantRoot && !hasConcreteChanges)
|
|
4633
4787
|
return {
|
|
4634
4788
|
decision: 'deny', decisionSource: 'infrastructure', policyCode: 'approval_file_changes_missing',
|
|
@@ -5704,7 +5858,15 @@ export class CodexRunner {
|
|
|
5704
5858
|
const isError = exitCode !== undefined
|
|
5705
5859
|
? exitCode !== 0
|
|
5706
5860
|
: item.status === 'failed' || item.status === 'declined';
|
|
5707
|
-
const rawOutput = item.aggregatedOutput ?? '';
|
|
5861
|
+
const rawOutput = item.aggregatedOutput ?? item.output ?? '';
|
|
5862
|
+
const commandInput = Array.isArray(item.command)
|
|
5863
|
+
? { commandArgv: item.command }
|
|
5864
|
+
: { command: typeof item.command === 'string' ? item.command : '' };
|
|
5865
|
+
const canonicalCommand = this.resolveCanonicalEcApproval(commandInput, this.getManagedTempDir(state.sessionId));
|
|
5866
|
+
const isManagedLogsCommand = canonicalCommand.argv?.[0] === 'ec' && canonicalCommand.argv?.[1] === 'logs';
|
|
5867
|
+
const structuredMarker = isManagedLogsCommand
|
|
5868
|
+
? extractStructuredToolErrorMarker(outputTextForManagedHook(rawOutput))
|
|
5869
|
+
: undefined;
|
|
5708
5870
|
const commandStr = Array.isArray(item.command)
|
|
5709
5871
|
? item.command.join(' ')
|
|
5710
5872
|
: typeof item.command === 'string' ? item.command : '';
|
|
@@ -5721,16 +5883,27 @@ export class CodexRunner {
|
|
|
5721
5883
|
yield {
|
|
5722
5884
|
type: 'tool_result',
|
|
5723
5885
|
name: 'Shell',
|
|
5724
|
-
result: rawOutput + applyPatchHint,
|
|
5886
|
+
result: (structuredMarker?.output ?? rawOutput) + applyPatchHint,
|
|
5725
5887
|
...(item.aggregatedOutput != null ? { outputKind: 'combined' } : {}),
|
|
5726
|
-
...(blockedFields ?? {
|
|
5888
|
+
...(blockedFields ?? (structuredMarker ? {
|
|
5889
|
+
isError: true,
|
|
5890
|
+
error: structuredMarker.error.reason,
|
|
5891
|
+
errorCode: structuredMarker.error.errorCode,
|
|
5892
|
+
...(structuredMarker.error.errorDetailCode ? { errorDetailCode: structuredMarker.error.errorDetailCode } : {}),
|
|
5893
|
+
decision: 'deny',
|
|
5894
|
+
decisionSource: structuredMarker.error.decisionSource,
|
|
5895
|
+
...(structuredMarker.error.policyCode ? { policyCode: structuredMarker.error.policyCode } : {}),
|
|
5896
|
+
reason: structuredMarker.error.reason,
|
|
5897
|
+
executed: false,
|
|
5898
|
+
executionState: 'blocked',
|
|
5899
|
+
} : {
|
|
5727
5900
|
isError,
|
|
5728
5901
|
...codexItemErrorFields(item),
|
|
5729
5902
|
...(itemErrorText ? { error: itemErrorText } : {}),
|
|
5730
5903
|
executed: true,
|
|
5731
5904
|
executionState: isError ? 'failed' : 'completed',
|
|
5732
5905
|
...(exitCode !== undefined ? { exitCode } : {}),
|
|
5733
|
-
}),
|
|
5906
|
+
})),
|
|
5734
5907
|
...(blockedFields ? {} : exitCode !== undefined ? { exitCode } : {}),
|
|
5735
5908
|
callId: item.id,
|
|
5736
5909
|
durationMs: typeof item.durationMs === 'number' ? item.durationMs : undefined,
|
|
@@ -6100,9 +6273,9 @@ export class CodexRunner {
|
|
|
6100
6273
|
}
|
|
6101
6274
|
buildEvolcoreShellEnvironmentConfig(sessionId, sessionToken, taskDelegationToken) {
|
|
6102
6275
|
const managedTempDir = ensureSessionRuntimeDir(sessionId);
|
|
6103
|
-
//
|
|
6104
|
-
//
|
|
6105
|
-
//
|
|
6276
|
+
// CLI children carry a per-thread credential. Hooks receive their separate
|
|
6277
|
+
// process credential through getAppServerClient(), since Codex does not
|
|
6278
|
+
// apply these thread shell settings to the Hook process environment.
|
|
6106
6279
|
return {
|
|
6107
6280
|
shell_environment_policy: {
|
|
6108
6281
|
set: {
|
|
@@ -6134,7 +6307,8 @@ export class CodexRunner {
|
|
|
6134
6307
|
: undefined;
|
|
6135
6308
|
for (const name of Object.keys(safeSet)) {
|
|
6136
6309
|
const normalized = name.toUpperCase();
|
|
6137
|
-
if (normalized === AGENT_DELEGATION_TOKEN_ENV || normalized === CODEX_SESSION_TOKEN_ENV
|
|
6310
|
+
if (normalized === AGENT_DELEGATION_TOKEN_ENV || normalized === CODEX_SESSION_TOKEN_ENV
|
|
6311
|
+
|| normalized === CODEX_HOOK_TOKEN_ENV) {
|
|
6138
6312
|
delete safeSet[name];
|
|
6139
6313
|
}
|
|
6140
6314
|
}
|
|
@@ -6152,9 +6326,11 @@ export class CodexRunner {
|
|
|
6152
6326
|
return normalized !== AGENT_DELEGATION_TOKEN_ENV
|
|
6153
6327
|
&& normalized !== CODEX_SESSION_TOKEN_ENV;
|
|
6154
6328
|
});
|
|
6155
|
-
const exclude =
|
|
6156
|
-
|
|
6157
|
-
|
|
6329
|
+
const exclude = [...new Set([
|
|
6330
|
+
...filteredExclude,
|
|
6331
|
+
CODEX_HOOK_TOKEN_ENV,
|
|
6332
|
+
...(carriesTaskDelegation ? [] : [AGENT_DELEGATION_TOKEN_ENV]),
|
|
6333
|
+
])];
|
|
6158
6334
|
return {
|
|
6159
6335
|
...config,
|
|
6160
6336
|
shell_environment_policy: {
|
|
@@ -6232,10 +6408,11 @@ export class CodexAgentPlugin {
|
|
|
6232
6408
|
throw new Error(availability.reason || 'Missing codex CLI with app-server');
|
|
6233
6409
|
}
|
|
6234
6410
|
const override = agent.config.baseagents?.codex;
|
|
6411
|
+
const selection = await resolveRuntimeBaseagentModelSelection('codex', override);
|
|
6235
6412
|
const merged = {
|
|
6236
6413
|
agents: {
|
|
6237
6414
|
codex: {
|
|
6238
|
-
...(override || {}),
|
|
6415
|
+
...(override || {}), model: selection.model,
|
|
6239
6416
|
},
|
|
6240
6417
|
},
|
|
6241
6418
|
};
|