Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
refactor(agent): Codex 路由检查与参数生成共用同一套判据
Dash4d70acb2423a
diff --git a/apps/desktop/src/main/maker-host/codex-global-plugins.ts b/apps/desktop/src/main/maker-host/codex-global-plugins.tsindex 72c635e206..3f96302e10 100644--- a/apps/desktop/src/main/maker-host/codex-global-plugins.ts+++ b/apps/desktop/src/main/maker-host/codex-global-plugins.ts@@ -4,7 +4,10 @@ import { promises as fsp } from 'node:fs';import { createHash, randomUUID } from 'node:crypto';import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';import yaml from 'js-yaml';-import type { CapabilityRoutingPolicy } from '@cindy/maker-core';+import {+ isCodexExplicitOnlyOverlayRoute,+ type CapabilityRoutingPolicy,+} from '@cindy/maker-core';import {ensureDirectoryLink,@@ -127,13 +130,7 @@ function codexCapabilityOverlays(if (!policy) return [];const overlays: CodexPluginOverlay[] = [];for (const directive of policy.overrides) {- if (- directive.invocation !== 'explicit-only' ||- directive.source.harness !== 'codex' ||- directive.source.kind !== 'harness-plugin'- ) {- continue;- }+ if (!isCodexExplicitOnlyOverlayRoute(directive)) continue;const pluginKey = directive.source.containerId;if (!pluginKey) continue;const marketplace = marketplaceOfPluginKey(pluginKey);@@ -151,11 +148,7 @@ function codexCapabilityOverlays(});continue;}- if (- directive.source.surface === 'mcp' &&- directive.source.artifactId &&- directive.source.artifactId !== directive.source.id- ) {+ if (directive.source.surface === 'mcp' && directive.source.artifactId) {overlays.push({...base,kind: 'mcp',diff --git a/packages/maker-core/src/agents/claude-code/capability-routing.ts b/packages/maker-core/src/agents/claude-code/capability-routing.tsindex b4cf41808b..cbc51c09a9 100644--- a/packages/maker-core/src/agents/claude-code/capability-routing.ts+++ b/packages/maker-core/src/agents/claude-code/capability-routing.ts@@ -74,8 +74,12 @@ function isClaudeSkillDirective(directive: CapabilityRouteOverride): boolean {/*** Translate host routing policy into Claude Code's native per-skill listing* controls. `user-invocable-only` removes a skill from implicit model context- * while preserving exact `/name` invocation. User and project skills are never- * overridden here, even if a host policy accidentally names one.+ * while preserving exact `/name` invocation.+ *+ * Claude matches `skillOverrides` by name only and cannot tell a harness Skill+ * from a user or project Skill of the same name. Host policy therefore names+ * only harness-specific Skills (namespaced plugin Skills or vendor-specific+ * built-in names), never generic names such as `design`.*/export function buildClaudeSkillOverrides(policy: CapabilityRoutingPolicy | undefined,diff --git a/packages/maker-core/src/agents/codex/capability-routing.ts b/packages/maker-core/src/agents/codex/capability-routing.tsindex 0934439f64..de9fe45758 100644--- a/packages/maker-core/src/agents/codex/capability-routing.ts+++ b/packages/maker-core/src/agents/codex/capability-routing.ts@@ -217,34 +217,86 @@ function hasCodexPluginIdentity(pluginId: string | undefined): boolean {}/**- * Whether Codex enforces a host route: through thread config and Skill config- * here, or through the desktop's provenance-preserving plugin overlay for- * explicit-only sources. Keep this in step with those builders; a route that- * fails it would be ignored or rejected at session start.+ * The Skill catalog target hidden by a disabled Codex plugin or Skill route.+ * Throws when the route lacks the plugin identity Codex needs to find it.+ */+function codexSkillDisableTarget(+ directive: CapabilityRouteOverride,+): CodexSkillDisableTarget {+ const pluginId = directive.source.surface === 'plugin'+ ? directive.source.id+ : directive.source.containerId;+ if (!pluginId) {+ const requiredField = directive.source.surface === 'plugin'+ ? 'source.id'+ : 'source.containerId';+ throw new Error(+ `Cannot disable Codex Skill ${directive.source.id}: ${requiredField} is required`,+ );+ }+ const plugin = parseCodexPluginCacheIdentity(pluginId);+ if (!plugin) {+ throw new Error(+ `Cannot enforce disabled Codex Skill routing for ${directive.source.id}: expected plugin id in <name>@<marketplace> form`,+ );+ }+ const skillArtifactId = directive.source.surface === 'skill'+ ? directive.source.artifactId+ : undefined;+ if (directive.source.surface === 'skill' && !skillArtifactId) {+ throw new Error(+ `Cannot disable Codex Skill ${directive.source.id}: source.artifactId is required`,+ );+ }+ return {+ plugin,+ ...(skillArtifactId ? { skillArtifactId } : {}),+ };+}++/**+ * Whether the desktop's provenance-preserving plugin overlay narrows this+ * explicit-only route locally. The overlay builder selects routes through this+ * same predicate.+ */+export function isCodexExplicitOnlyOverlayRoute(+ directive: CapabilityRouteOverride,+): boolean {+ if (+ !isCodexHarnessPluginDirective(directive) ||+ directive.invocation !== 'explicit-only' ||+ !hasCodexPluginIdentity(directive.source.containerId)+ ) {+ return false;+ }+ const { surface, id, artifactId } = directive.source;+ return surface === 'skill' ||+ (surface === 'mcp' && !!artifactId && artifactId !== id);+}++/**+ * Whether Codex enforces a host route. Built from the same helpers the Skill+ * config builder and the desktop overlay use, so the route support check+ * cannot drift from what a session actually applies.*/export function isCodexCapabilityRouteEnforced(directive: CapabilityRouteOverride,): boolean {- if (!isCodexHarnessPluginDirective(directive)) return false;- const { surface, id, containerId, artifactId } = directive.source;- if (directive.invocation === 'disabled') {- switch (surface) {- case 'plugin':- return hasCodexPluginIdentity(id);- case 'skill':- return hasCodexPluginIdentity(containerId) && !!artifactId;- case 'mcp':- return true;- default:- return false;+ if (isDisabledCodexSkillSourceDirective(directive)) {+ try {+ codexSkillDisableTarget(directive);+ return true;+ } catch {+ return false;}}- if (directive.invocation === 'explicit-only') {- if (!hasCodexPluginIdentity(containerId)) return false;- if (surface === 'skill') return true;- if (surface === 'mcp') return !!artifactId && artifactId !== id;+ if (+ isCodexHarnessPluginDirective(directive) &&+ directive.invocation === 'disabled'+ ) {+ return directive.source.surface === 'mcp';}- return false;+ return isCodexExplicitOnlyOverlayRoute(directive);}/**@@ -288,35 +340,7 @@ export function buildCodexCapabilitySkillConfigOverrides(const targets: CodexSkillDisableTarget[] = [];for (const directive of policy?.overrides ?? []) {if (!isDisabledCodexSkillSourceDirective(directive)) continue;- const pluginId = directive.source.surface === 'plugin'- ? directive.source.id- : directive.source.containerId;- if (!pluginId) {- const requiredField = directive.source.surface === 'plugin'- ? 'source.id'- : 'source.containerId';- throw new Error(- `Cannot disable Codex Skill ${directive.source.id}: ${requiredField} is required`,- );- }- const plugin = parseCodexPluginCacheIdentity(pluginId);- if (!plugin) {- throw new Error(- `Cannot enforce disabled Codex Skill routing for ${directive.source.id}: expected plugin id in <name>@<marketplace> form`,- );- }- const skillArtifactId = directive.source.surface === 'skill'- ? directive.source.artifactId- : undefined;- if (directive.source.surface === 'skill' && !skillArtifactId) {- throw new Error(- `Cannot disable Codex Skill ${directive.source.id}: source.artifactId is required`,- );- }- targets.push({- plugin,- ...(skillArtifactId ? { skillArtifactId } : {}),- });+ targets.push(codexSkillDisableTarget(directive));}if (targets.length === 0) return {};diff --git a/packages/maker-core/src/agents/index.ts b/packages/maker-core/src/agents/index.tsindex 1616e25713..bedd5ebace 100644--- a/packages/maker-core/src/agents/index.ts+++ b/packages/maker-core/src/agents/index.ts@@ -13,6 +13,7 @@ export type {} from './claude-code/subagent-model-access.js';export { CodexAgent } from './codex/index.js';export { findUnenforcedCapabilityRoutes } from './capability-route-support.js';+export { isCodexExplicitOnlyOverlayRoute } from './codex/capability-routing.js';export { isCodexHistoryRecoveryRequired } from './codex/history-recovery.js';export {CODEX_HISTORY_OVERSIZED_REASON,