Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(codex): 屏蔽重复的 Sky Computer Use 能力 (#1693)
Dash94404a0a0b7a
diff --git a/apps/desktop/src/main/maker-host/__tests__/capabilityRouting.test.ts b/apps/desktop/src/main/maker-host/__tests__/capabilityRouting.test.tsnew file mode 100644index 0000000000..0f52a2ad87--- /dev/null+++ b/apps/desktop/src/main/maker-host/__tests__/capabilityRouting.test.ts@@ -0,0 +1,50 @@+import { describe, expect, it } from 'vitest';+import type { CapabilityRoutingPolicy } from '@cindy/maker-core';++import { buildDesktopCapabilityRoutingPolicy } from '../capability-routing.js';++function computerUseRoutes(policy: CapabilityRoutingPolicy) {+ return policy.overrides.filter((route) => route.capabilityId === 'computer-use');+}++describe('desktop Computer Use capability routing', () => {+ it('keeps only the node_repl compatibility restriction before Cindy Computer Use is applied', () => {+ const routes = computerUseRoutes(+ buildDesktopCapabilityRoutingPolicy({+ cindyComputerAvailable: false,+ }),+ );++ expect(routes).toEqual([+ expect.objectContaining({+ source: expect.objectContaining({+ surface: 'skill',+ id: 'computer-use:computer-use',+ containerId: 'computer-use@openai-bundled',+ }),+ invocation: 'disabled',+ }),+ ]);+ });++ it('disables the downstream plugin only after cindy_computer is applied', () => {+ const routes = computerUseRoutes(+ buildDesktopCapabilityRoutingPolicy({+ cindyComputerAvailable: true,+ }),+ );++ expect(routes).toHaveLength(2);+ expect(routes[1]).toMatchObject({+ source: {+ surface: 'plugin',+ id: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ replacement: {+ kind: 'cindy-host',+ id: 'cindy_computer',+ },+ });+ });+});diff --git a/apps/desktop/src/main/maker-host/capability-routing.ts b/apps/desktop/src/main/maker-host/capability-routing.tsindex 293e06f181..0c7be27fc7 100644--- a/apps/desktop/src/main/maker-host/capability-routing.ts+++ b/apps/desktop/src/main/maker-host/capability-routing.ts@@ -1,4 +1,23 @@-import type { CapabilityRoutingPolicy } from '@cindy/maker-core';+import type {+ CapabilityRouteOverride,+ CapabilityRoutingPolicy,+} from '@cindy/maker-core';++const CODEX_COMPUTER_USE_REPLACEMENT_ROUTE = {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ replacement: {+ kind: 'cindy-host',+ id: 'cindy_computer',+ },+ reason: 'Cindy owns desktop-control enablement, permissions, and execution.',+} as const satisfies CapabilityRouteOverride;/*** Product-level arbitration for capability sources that collide inside Cindy.@@ -95,20 +114,41 @@ export const DESKTOP_CAPABILITY_ROUTING_POLICY = {},reason: 'The downstream Feishu account must not be used without an explicit source choice.',},+ // The bundled Skill requires node_repl, which Cindy's Codex host does not+ // expose. Keep this compatibility restriction independent from whether the+ // user enabled Cindy's own Computer Use replacement.{capabilityId: 'computer-use',source: {kind: 'harness-plugin',harness: 'codex',- surface: 'plugin',- id: 'computer-use@openai-bundled',+ surface: 'skill',+ id: 'computer-use:computer-use',+ artifactId: 'computer-use',+ containerId: 'computer-use@openai-bundled',},invocation: 'disabled',- replacement: {- kind: 'cindy-host',- id: 'cindy_computer',- },- reason: 'Cindy owns desktop-control enablement, permissions, and execution.',+ reason: 'The bundled Skill requires node_repl, which is unavailable in Cindy.',},],} as const satisfies CapabilityRoutingPolicy;++/**+ * Freeze the routing policy for one Codex session.+ *+ * Disabling the downstream plugin is replacement arbitration, so it only+ * applies after the current Codex environment actually exposes cindy_computer.+ * The base policy still hides the incompatible node_repl Skill when the Cindy+ * replacement is unavailable, without changing the plugin-wide setting.+ */+export function buildDesktopCapabilityRoutingPolicy(opts: {+ cindyComputerAvailable: boolean;+}): CapabilityRoutingPolicy {+ if (!opts.cindyComputerAvailable) return DESKTOP_CAPABILITY_ROUTING_POLICY;+ return {+ overrides: [+ ...DESKTOP_CAPABILITY_ROUTING_POLICY.overrides,+ CODEX_COMPUTER_USE_REPLACEMENT_ROUTE,+ ],+ };+}diff --git a/apps/desktop/src/main/maker-host/index.ts b/apps/desktop/src/main/maker-host/index.tsindex 2b3fcf909f..f5e942ca18 100644--- a/apps/desktop/src/main/maker-host/index.ts+++ b/apps/desktop/src/main/maker-host/index.ts@@ -144,6 +144,7 @@ import {import { cleanupComputerDriverSession } from '../mcp-integrations/computer.js';import { createPluginRegistry, resetPluginRegistry } from './plugins/index.js';import {+ getActiveCodexBridgeServerNames,getCodexExtraSpawnConfig,registerCodexMcpThreadContext,setCodexEnvironmentShutdownHook,@@ -185,7 +186,10 @@ import {} from './mcp-tool-approval-policy.js';import { mapCodexAppServerModelsToCatalog } from './codex-model-discovery.js';import { prepareSharedProjectSkillLinks } from './shared-global-skills.js';-import { DESKTOP_CAPABILITY_ROUTING_POLICY } from './capability-routing.js';+import {+ buildDesktopCapabilityRoutingPolicy,+ DESKTOP_CAPABILITY_ROUTING_POLICY,+} from './capability-routing.js';export { withRehydrateCloseSuppressed };type RemoteCcQuery = Awaited<@@ -980,7 +984,15 @@ export function getMaker(): Maker {// codex 子进程没法消费 in-process JS instance, prepareCodexExtraSpawnConfig// 起 streamable-HTTP bridge 把 instance 通过 -c 'mcp_servers...=...' 注入。mcpProviders: codexMcpProviders,- capabilityRouting: DESKTOP_CAPABILITY_ROUTING_POLICY,+ // Evaluate after app-server startup prepared (or reused) the MCP bridge.+ // The bridge snapshot is the applied capability surface; the preference+ // alone can be ahead of it while a busy Codex turn defers refresh.+ get capabilityRouting() {+ return buildDesktopCapabilityRoutingPolicy({+ cindyComputerAvailable:+ getActiveCodexBridgeServerNames()?.includes('cindy_computer') === true,+ });+ },makerMemory: makerMemoryManager,// 通讯录 prompt 段有效状态(codex 版): 在 claude 的判定链之上再与「实际应用// 到 running app-server 的 spawn 快照」对齐 —— 开关切换后失效失败(busy,diff --git a/packages/maker-core/src/agents/codex/capability-routing.test.ts b/packages/maker-core/src/agents/codex/capability-routing.test.tsindex 56a6e554a6..e384f1cfb3 100644--- a/packages/maker-core/src/agents/codex/capability-routing.test.ts+++ b/packages/maker-core/src/agents/codex/capability-routing.test.ts@@ -1,7 +1,70 @@import { describe, expect, it } from 'vitest';import type { CapabilityRoutingPolicy } from '../../types/capability-routing.js';-import { buildCodexCapabilityConfigOverrides } from './capability-routing.js';+import {+ buildCodexCapabilityConfigOverrides,+ buildCodexCapabilitySkillConfigOverrides,+ buildCodexSessionCapabilityRoutingPolicy,+ requiresCodexCapabilitySkillDiscovery,+} from './capability-routing.js';++describe('buildCodexSessionCapabilityRoutingPolicy', () => {+ const compatibilityRoute = {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'skill',+ id: 'computer-use:computer-use',+ artifactId: 'computer-use',+ containerId: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ } as const;+ const localReplacementRoute = {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ replacement: { kind: 'cindy-host', id: 'cindy_computer' },+ } as const;+ const pluginReplacementRoute = {+ capabilityId: 'example',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: 'example@personal',+ },+ invocation: 'disabled',+ replacement: { kind: 'cindy-plugin', id: 'example' },+ } as const;+ const policy = {+ overrides: [+ compatibilityRoute,+ localReplacementRoute,+ pluginReplacementRoute,+ ],+ } as const satisfies CapabilityRoutingPolicy;++ it('preserves local-host replacement arbitration for local Codex', () => {+ expect(buildCodexSessionCapabilityRoutingPolicy(policy, {+ cindyHostReplacementsAvailable: true,+ })).toBe(policy);+ });++ it('removes only unavailable Cindy-host replacements for remote Codex', () => {+ expect(buildCodexSessionCapabilityRoutingPolicy(policy, {+ cindyHostReplacementsAvailable: false,+ })).toEqual({+ overrides: [compatibilityRoute, pluginReplacementRoute],+ });+ });+});describe('buildCodexCapabilityConfigOverrides', () => {it('disables the selected Codex plugin with a per-thread config override', () => {@@ -178,3 +241,224 @@ describe('buildCodexCapabilityConfigOverrides', () => {).toThrowError(/source\.containerId is required/);});});++describe('buildCodexCapabilitySkillConfigOverrides', () => {+ const disabledPluginPolicy = {+ overrides: [+ {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ },+ ],+ } as const satisfies CapabilityRoutingPolicy;++ const disabledSkillPolicy = {+ overrides: [+ {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'skill',+ id: 'computer-use:computer-use',+ artifactId: 'computer-use',+ containerId: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ },+ ],+ } as const satisfies CapabilityRoutingPolicy;++ it('disables matching plugin Skills and preserves existing disabled Skills', () => {+ expect(requiresCodexCapabilitySkillDiscovery(disabledPluginPolicy)).toBe(true);+ expect(buildCodexCapabilitySkillConfigOverrides(disabledPluginPolicy, [+ {+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: true,+ },+ {+ path: '/Users/dash/.codex/skills/already-disabled/SKILL.md',+ enabled: false,+ },+ {+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/browser/1.0.0/skills/browser/SKILL.md',+ enabled: true,+ },+ ])).toEqual({+ 'skills.config': [+ {+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: false,+ },+ {+ path: '/Users/dash/.codex/skills/already-disabled/SKILL.md',+ enabled: false,+ },+ ],+ });+ });++ it('matches remote Windows plugin cache paths without disabling namesakes', () => {+ expect(buildCodexCapabilitySkillConfigOverrides(disabledPluginPolicy, [+ {+ path: 'C:\\Users\\dash\\.codex\\plugins\\cache\\openai-bundled\\computer-use\\1.0.0\\skills\\computer-use\\SKILL.md',+ enabled: true,+ },+ {+ path: 'C:\\Users\\dash\\.codex\\skills\\computer-use\\SKILL.md',+ enabled: true,+ },+ ])).toEqual({+ 'skills.config': [{+ path: 'C:\\Users\\dash\\.codex\\plugins\\cache\\openai-bundled\\computer-use\\1.0.0\\skills\\computer-use\\SKILL.md',+ enabled: false,+ }],+ });+ });++ it('matches bundled marketplace snapshots without disabling namesakes', () => {+ const macSnapshotPath =+ '/Users/dash/.codex/.tmp/bundled-marketplaces/openai-bundled/plugins/computer-use/skills/computer-use/SKILL.md';+ const windowsSnapshotPath =+ 'C:\\Users\\dash\\.codex\\.tmp\\bundled-marketplaces\\openai-bundled.staging-123\\plugins\\computer-use\\skills\\computer-use\\SKILL.md';+ expect(buildCodexCapabilitySkillConfigOverrides(disabledSkillPolicy, [+ { path: macSnapshotPath, enabled: true },+ { path: windowsSnapshotPath, enabled: true },+ {+ path: '/Users/dash/.codex/skills/computer-use/SKILL.md',+ enabled: true,+ },+ ])).toEqual({+ 'skills.config': [+ { path: macSnapshotPath, enabled: false },+ { path: windowsSnapshotPath, enabled: false },+ ],+ });+ });++ it('disables only the selected incompatible Skill without disabling its plugin', () => {+ expect(requiresCodexCapabilitySkillDiscovery(disabledSkillPolicy)).toBe(true);+ expect(buildCodexCapabilityConfigOverrides(disabledSkillPolicy)).toEqual({});+ expect(buildCodexCapabilitySkillConfigOverrides(disabledSkillPolicy, [+ {+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: true,+ },+ {+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/setup/SKILL.md',+ enabled: true,+ },+ {+ path: '/Users/dash/.codex/skills/computer-use/SKILL.md',+ enabled: true,+ },+ ])).toEqual({+ 'skills.config': [{+ path: '/Users/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: false,+ }],+ });+ });++ it('does not replace the base skills config when the plugin contributes no Skills', () => {+ expect(buildCodexCapabilitySkillConfigOverrides(disabledPluginPolicy, [{+ path: '/Users/dash/.codex/skills/already-disabled/SKILL.md',+ enabled: false,+ }])).toEqual({});+ });++ it('fails closed when a disabled plugin id has no marketplace provenance', () => {+ const invalidPolicy = {+ overrides: [{+ capabilityId: 'example',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: 'plugin-without-marketplace',+ },+ invocation: 'disabled',+ }],+ } as const satisfies CapabilityRoutingPolicy;++ expect(() => buildCodexCapabilitySkillConfigOverrides(invalidPolicy, []))+ .toThrowError(/expected plugin id in <name>@<marketplace> form/);+ });++ it('identifies a missing plugin source id in the error', () => {+ const invalidPolicy = {+ overrides: [{+ capabilityId: 'example',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'plugin',+ id: '',+ },+ invocation: 'disabled',+ }],+ } as const satisfies CapabilityRoutingPolicy;++ expect(() => buildCodexCapabilitySkillConfigOverrides(invalidPolicy, []))+ .toThrowError(/source\.id is required/);+ });++ it('fails closed when a disabled Skill lacks precise plugin provenance', () => {+ const noContainer = {+ overrides: [{+ capabilityId: 'example',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'skill',+ id: 'example:skill',+ artifactId: 'skill',+ },+ invocation: 'disabled',+ }],+ } as const satisfies CapabilityRoutingPolicy;+ const noArtifact = {+ overrides: [{+ capabilityId: 'example',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'skill',+ id: 'example:skill',+ containerId: 'example@marketplace',+ },+ invocation: 'disabled',+ }],+ } as const satisfies CapabilityRoutingPolicy;++ expect(() => buildCodexCapabilitySkillConfigOverrides(noContainer, []))+ .toThrowError(/source\.containerId is required/);+ expect(() => buildCodexCapabilitySkillConfigOverrides(noArtifact, []))+ .toThrowError(/source\.artifactId is required/);+ });++ it('skips discovery for unrelated routing policies', () => {+ const unrelatedPolicy = {+ overrides: [{+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'claude-code',+ surface: 'plugin',+ id: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ }],+ } as const satisfies CapabilityRoutingPolicy;++ expect(requiresCodexCapabilitySkillDiscovery(unrelatedPolicy)).toBe(false);+ expect(buildCodexCapabilitySkillConfigOverrides(unrelatedPolicy, []))+ .toEqual({});+ });+});diff --git a/packages/maker-core/src/agents/codex/capability-routing.ts b/packages/maker-core/src/agents/codex/capability-routing.tsindex 8036ab85ef..6505c761a8 100644--- a/packages/maker-core/src/agents/codex/capability-routing.ts+++ b/packages/maker-core/src/agents/codex/capability-routing.ts@@ -5,6 +5,22 @@ import type {const CODEX_HARNESS_ID = 'codex';+interface CodexSkillState {+ path: string;+ enabled: boolean;+}++interface CodexPluginCacheIdentity {+ pluginName: string;+ marketplace: string;+}++interface CodexSkillDisableTarget {+ plugin: CodexPluginCacheIdentity;+ /** Undefined means every Skill contributed by the plugin. */+ skillArtifactId?: string;+}+export interface CodexCapabilityRoutingOptions {/*** Whether the host prepared a provenance-preserving plugin overlay for this@@ -18,6 +34,11 @@ export interface CodexCapabilityRoutingOptions {isolatedPluginOverlays?: boolean;}+export interface CodexSessionCapabilityRoutingOptions {+ /** Whether this Codex host can invoke replacements served by Cindy itself. */+ cindyHostReplacementsAvailable: boolean;+}+/*** Codex thread config accepts flattened TOML paths. Plugin config names contain* `@`, so they must be rendered as quoted dotted-key segments.@@ -35,6 +56,160 @@ function isCodexHarnessPluginDirective();}+function isDisabledCodexSkillSourceDirective(+ directive: CapabilityRouteOverride,+): boolean {+ return (+ isCodexHarnessPluginDirective(directive) &&+ (directive.source.surface === 'plugin' ||+ directive.source.surface === 'skill') &&+ directive.invocation === 'disabled'+ );+}++function parseCodexPluginCacheIdentity(+ pluginId: string,+): CodexPluginCacheIdentity | null {+ const separator = pluginId.lastIndexOf('@');+ if (separator <= 0 || separator === pluginId.length - 1) return null;+ return {+ pluginName: pluginId.slice(0, separator),+ marketplace: pluginId.slice(separator + 1),+ };+}++function isSkillFromPluginDistribution(+ skillPath: string,+ target: CodexSkillDisableTarget,+): boolean {+ const segments = skillPath.replace(/\\/g, '/').split('/');+ for (let index = 0; index < segments.length; index += 1) {+ if (+ index + 6 < segments.length &&+ segments[index] === 'plugins' &&+ segments[index + 1] === 'cache' &&+ segments[index + 2] === target.plugin.marketplace &&+ segments[index + 3] === target.plugin.pluginName &&+ segments[index + 4] !== '' &&+ segments[index + 5] === 'skills' &&+ (target.skillArtifactId === undefined ||+ segments[index + 6] === target.skillArtifactId)+ ) {+ return true;+ }+ const bundledMarketplace = segments[index + 1];+ if (+ index + 5 < segments.length &&+ segments[index] === 'bundled-marketplaces' &&+ (bundledMarketplace === target.plugin.marketplace ||+ bundledMarketplace?.startsWith(+ `${target.plugin.marketplace}.staging-`,+ )) &&+ segments[index + 2] === 'plugins' &&+ segments[index + 3] === target.plugin.pluginName &&+ segments[index + 4] === 'skills' &&+ (target.skillArtifactId === undefined ||+ segments[index + 5] === target.skillArtifactId)+ ) {+ return true;+ }+ }+ return false;+}++/**+ * Remove replacement-arbitration routes that the selected Codex host cannot+ * satisfy. Compatibility-only restrictions without a replacement remain in+ * force, so remote sessions still hide Skills that depend on unavailable APIs.+ */+export function buildCodexSessionCapabilityRoutingPolicy(+ policy: CapabilityRoutingPolicy | undefined,+ opts: CodexSessionCapabilityRoutingOptions,+): CapabilityRoutingPolicy | undefined {+ if (opts.cindyHostReplacementsAvailable || !policy) return policy;+ const overrides = policy.overrides.filter(+ (directive) => directive.replacement?.kind !== 'cindy-host',+ );+ return overrides.length === policy.overrides.length ? policy : { overrides };+}++/** Whether a session must inspect Codex's effective Skill catalog before start. */+export function requiresCodexCapabilitySkillDiscovery(+ policy: CapabilityRoutingPolicy | undefined,+): boolean {+ return policy?.overrides.some(isDisabledCodexSkillSourceDirective) ?? false;+}++/**+ * Hide a selected plugin Skill, or every Skill from a disabled plugin.+ *+ * Codex 0.145 keeps plugin Skills enabled in the model-facing catalog even+ * when the plugin-wide `enabled` override is false. `skills.config` is the+ * supported per-Skill control. Cindy also uses the same narrow control when a+ * specific downstream Skill depends on a host interface that is unavailable.+ * Derive paths from app-server's own catalog rather than guessing local or+ * remote homes. Existing disabled Skills in this cwd are carried forward+ * because the per-thread array may replace the base array.+ */+export function buildCodexCapabilitySkillConfigOverrides(+ policy: CapabilityRoutingPolicy | undefined,+ skills: readonly CodexSkillState[],+): Record<string, unknown> {+ 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 } : {}),+ });+ }+ if (targets.length === 0) return {};++ const routedSkillPaths = skills+ .filter((skill) =>+ targets.some((target) =>+ isSkillFromPluginDistribution(skill.path, target),+ ),+ )+ .map((skill) => skill.path);+ if (routedSkillPaths.length === 0) return {};++ const disabledPaths = new Set([+ ...skills.filter((skill) => !skill.enabled).map((skill) => skill.path),+ ...routedSkillPaths,+ ]);+ return {+ 'skills.config': [...disabledPaths]+ .sort()+ .map((skillPath) => ({ path: skillPath, enabled: false })),+ };+}+/*** Convert host policy into per-thread Codex config overrides.*diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex 77f541f8ef..f1e2ff5755 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -353,6 +353,12 @@ function installFakeHost(cwd: '/repo',};}+ if (method === Method.SkillsList) {+ const { cwds = ['/repo'] } = params as { cwds?: string[] };+ return {+ data: cwds.map((cwd) => ({ cwd, skills: [], errors: [] })),+ };+ }if (method === Method.ThreadFork) {return {thread: { id: 'fork-thread-id' },@@ -554,6 +560,18 @@ describe('CodexAgent capability routing', () => {id: 'xd-feishu',},},+ {+ capabilityId: 'computer-use',+ source: {+ kind: 'harness-plugin',+ harness: 'codex',+ surface: 'skill',+ id: 'computer-use:computer-use',+ artifactId: 'computer-use',+ containerId: 'computer-use@openai-bundled',+ },+ invocation: 'disabled',+ },{capabilityId: 'computer-use',source: {@@ -572,8 +590,34 @@ describe('CodexAgent capability routing', () => {} as const;it('applies host-owned plugin policy to new and resumed Codex 0.145 threads', async () => {+ const listComputerUseSkill = (method: string, params: unknown) => {+ if (method !== Method.SkillsList) return undefined;+ const { cwds = ['/repo'] } = params as { cwds?: string[] };+ return {+ data: cwds.map((cwd) => ({+ cwd,+ skills: [+ {+ name: 'computer-use:computer-use',+ description: 'Control local Mac apps',+ path: '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ scope: 'user',+ enabled: true,+ },+ {+ name: 'disabled-user-skill',+ description: 'Already disabled by the user',+ path: '/home/dash/.codex/skills/disabled-user-skill/SKILL.md',+ scope: 'user',+ enabled: false,+ },+ ],+ errors: [],+ })),+ };+ };const startAgent = new CodexAgent(createDeps({}, { capabilityRouting }));- const startHost = installFakeHost(startAgent, undefined, {+ const startHost = installFakeHost(startAgent, listComputerUseSkill, {userAgent: 'mock-codex/0.145.0',});const startHandle = await startAgent.startSession({@@ -589,10 +633,25 @@ describe('CodexAgent capability routing', () => {'plugins."feishu-delegate@personal".mcp_servers."feishu-delegate".enabled': false,'plugins."feishu-delegate@personal".mcp_servers."cindy-routed-feishu-delegate".default_tools_approval_mode':'prompt',+ 'skills.config': [+ {+ path: '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: false,+ },+ {+ path: '/home/dash/.codex/skills/disabled-user-skill/SKILL.md',+ enabled: false,+ },+ ],});+ expect(startHost.request).toHaveBeenCalledWith(Method.SkillsList, {+ cwds: ['/repo'],+ forceReload: false,+ perCwdExtraUserRoots: null,+ }, { timeoutMs: 60_000 });const resumeAgent = new CodexAgent(createDeps({}, { capabilityRouting }));- const resumeHost = installFakeHost(resumeAgent, undefined, {+ const resumeHost = installFakeHost(resumeAgent, listComputerUseSkill, {userAgent: 'mock-codex/0.145.0',});const resumeHandle = await resumeAgent.startSession({@@ -609,12 +668,109 @@ describe('CodexAgent capability routing', () => {'plugins."feishu-delegate@personal".mcp_servers."feishu-delegate".enabled': false,'plugins."feishu-delegate@personal".mcp_servers."cindy-routed-feishu-delegate".default_tools_approval_mode':'prompt',+ 'skills.config': [+ {+ path: '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: false,+ },+ {+ path: '/home/dash/.codex/skills/disabled-user-skill/SKILL.md',+ enabled: false,+ },+ ],});await startHandle.close();await resumeHandle.close();});+ it('keeps the plugin enabled when Cindy Computer Use is unavailable but hides its incompatible Skill', async () => {+ const compatibilityOnlyRouting = {+ overrides: [capabilityRouting.overrides[1]],+ } as const;+ const agent = new CodexAgent(createDeps({}, {+ capabilityRouting: compatibilityOnlyRouting,+ }));+ const host = installFakeHost(agent, (method, params) => {+ if (method !== Method.SkillsList) return undefined;+ const { cwds = ['/repo'] } = params as { cwds?: string[] };+ return {+ data: cwds.map((cwd) => ({+ cwd,+ skills: [{+ name: 'computer-use:computer-use',+ description: 'Control local Mac apps',+ path: '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ scope: 'user',+ enabled: true,+ }],+ errors: [],+ })),+ };+ }, {+ userAgent: 'mock-codex/0.145.0',+ });++ const handle = await agent.startSession({+ sessionId: 'session-capability-routing-compatibility-only',+ model: 'gpt-5.4',+ workingDir: '/repo',+ });+ const params = host.request.mock.calls.find(+ ([method]) => method === Method.ThreadStart,+ )?.[1] as { config?: Record<string, unknown> };++ expect(params.config).toMatchObject({+ 'skills.config': [{+ path: '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md',+ enabled: false,+ }],+ });+ expect(params.config).not.toHaveProperty(+ 'plugins."computer-use@openai-bundled".enabled',+ );++ await handle.close();+ });++ it('disables a restricted Skill path even when catalog parsing reports it as an error', async () => {+ const compatibilityOnlyRouting = {+ overrides: [capabilityRouting.overrides[1]],+ } as const;+ const agent = new CodexAgent(createDeps({}, {+ capabilityRouting: compatibilityOnlyRouting,+ }));+ const brokenSkillPath =+ '/home/dash/.codex/plugins/cache/openai-bundled/computer-use/1.0.0/skills/computer-use/SKILL.md';+ const host = installFakeHost(agent, (method, params) => {+ if (method !== Method.SkillsList) return undefined;+ const { cwds = ['/repo'] } = params as { cwds?: string[] };+ return {+ data: cwds.map((cwd) => ({+ cwd,+ skills: [],+ errors: [{ path: brokenSkillPath, message: 'invalid metadata' }],+ })),+ };+ }, {+ userAgent: 'mock-codex/0.145.0',+ });++ const handle = await agent.startSession({+ sessionId: 'session-capability-routing-broken-skill',+ model: 'gpt-5.4',+ workingDir: '/repo',+ });+ const params = host.request.mock.calls.find(+ ([method]) => method === Method.ThreadStart,+ )?.[1] as { config?: Record<string, unknown> };++ expect(params.config).toMatchObject({+ 'skills.config': [{ path: brokenSkillPath, enabled: false }],+ });+ await handle.close();+ });+it('fails closed for older Codex daemons that cannot apply plugin overrides', async () => {const agent = new CodexAgent(createDeps({}, { capabilityRouting }));installFakeHost(agent, undefined, {@@ -630,9 +786,25 @@ describe('CodexAgent capability routing', () => {).rejects.toThrow('requires Codex app-server 0.145.0 or newer');});- it('disables an explicit-only plugin on remote Codex where the local overlay is unavailable', async () => {+ it('keeps remote Computer Use available without a local host replacement', async () => {const agent = new CodexAgent(createDeps({}, { capabilityRouting }));- const host = installFakeHost(agent, undefined, {+ const host = installFakeHost(agent, (method, params) => {+ if (method !== Method.SkillsList) return undefined;+ const { cwds = ['/repo'] } = params as { cwds?: string[] };+ return {+ data: cwds.map((cwd) => ({+ cwd,+ skills: [{+ name: 'computer-use:computer-use',+ description: 'Control remote desktop apps',+ path: 'C:\\Users\\dash\\.codex\\plugins\\cache\\openai-bundled\\computer-use\\1.0.0\\skills\\computer-use\\SKILL.md',+ scope: 'user',+ enabled: true,+ }],+ errors: [],+ })),+ };+ }, {userAgent: 'mock-codex/0.145.0',});const handle = await agent.startSession({@@ -647,15 +819,41 @@ describe('CodexAgent capability routing', () => {expect(params.config).toMatchObject({'plugins."feishu-delegate@personal".enabled': false,- 'plugins."computer-use@openai-bundled".enabled': false,+ 'skills.config': [{+ path: 'C:\\Users\\dash\\.codex\\plugins\\cache\\openai-bundled\\computer-use\\1.0.0\\skills\\computer-use\\SKILL.md',+ enabled: false,+ }],});expect(params.config).not.toHaveProperty('plugins."feishu-delegate@personal".mcp_servers."cindy-routed-feishu-delegate".default_tools_approval_mode',);+ expect(params.config).not.toHaveProperty(+ 'plugins."computer-use@openai-bundled".enabled',+ );await handle.close();});+ it('fails closed when restricted Skill discovery is unavailable', async () => {+ const agent = new CodexAgent(createDeps({}, { capabilityRouting }));+ installFakeHost(agent, (method) => {+ if (method === Method.SkillsList) {+ throw new Error('skills/list unavailable');+ }+ return undefined;+ }, {+ userAgent: 'mock-codex/0.145.0',+ });++ await expect(agent.startSession({+ sessionId: 'session-capability-routing-skill-discovery-failure',+ model: 'gpt-5.4',+ workingDir: '/repo',+ })).rejects.toThrow(+ 'Cannot start Codex safely because Cindy could not inspect restricted Codex Skills: skills/list unavailable',+ );+ });+it('declines an explicit-only downstream MCP unless the user chose that source', async () => {const makeAgent = () =>new CodexAgent(diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex d423bab253..f197c6c912 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -98,7 +98,12 @@ import {parseOverloadError,} from '../shared/overload-error.js';import { buildCodexEnv } from './env-builder.js';-import { buildCodexCapabilityConfigOverrides } from './capability-routing.js';+import {+ buildCodexCapabilityConfigOverrides,+ buildCodexCapabilitySkillConfigOverrides,+ buildCodexSessionCapabilityRoutingPolicy,+ requiresCodexCapabilitySkillDiscovery,+} from './capability-routing.js';import { scanCodexCustomizations } from './customization-scanner.js';import { commandExecutionDisplayInput } from './command-display.js';import {@@ -1364,11 +1369,23 @@ export class CodexAgent extends BaseAgent {forceReload: boolean,): Promise<{ skills: SkillMetadata[]; errors: Array<{ path?: string; message: string }> }> {const { host } = await this.getUtilityHost();- const response = await host.request<SkillsListResponse>(Method.SkillsList, {+ return await this.listSkillsForHost(host, workingDir, forceReload);+ }++ private async listSkillsForHost(+ host: AppServerHost,+ workingDir: string,+ forceReload: boolean,+ timeoutMs?: number,+ ): Promise<{ skills: SkillMetadata[]; errors: Array<{ path?: string; message: string }> }> {+ const params = {cwds: [workingDir],forceReload,perCwdExtraUserRoots: null,- });+ };+ const response = timeoutMs == null+ ? await host.request<SkillsListResponse>(Method.SkillsList, params)+ : await host.request<SkillsListResponse>(Method.SkillsList, params, { timeoutMs });const entry = response.data.find((item) => item.cwd === workingDir) ?? response.data[0];return {skills: entry?.skills ?? [],@@ -2944,8 +2961,16 @@ export class CodexAgent extends BaseAgent {: credentialMode ?? this.hostEffectiveCredentialModes.get(currentHostKey);const approvalsReviewerProtocolSupported =supportsCodexApprovalsReviewerProtocol(initResp.userAgent);- const capabilityRoutingPolicy = this.deps.capabilityRouting;- const capabilityRoutingConfig = buildCodexCapabilityConfigOverrides(+ const capabilityRoutingPolicy = buildCodexSessionCapabilityRoutingPolicy(+ this.deps.capabilityRouting,+ {+ // Remote Codex does not receive the local Cindy MCP bridge. Keep+ // compatibility restrictions, but do not disable a remote capability+ // in favor of a replacement that only exists on the local host.+ cindyHostReplacementsAvailable: !opts.remoteHostId,+ },+ );+ let capabilityRoutingConfig = buildCodexCapabilityConfigOverrides(capabilityRoutingPolicy,{// Remote Codex uses its own isolated CODEX_HOME. Cindy currently@@ -2954,6 +2979,35 @@ export class CodexAgent extends BaseAgent {isolatedPluginOverlays: !opts.remoteHostId,},);+ if (requiresCodexCapabilitySkillDiscovery(capabilityRoutingPolicy)) {+ try {+ assertCurrentHost('capability Skill discovery');+ const { skills, errors } = await this.listSkillsForHost(+ host,+ opts.workingDir,+ false,+ CRITICAL_THREAD_RPC_TIMEOUT_MS,+ );+ assertCurrentHost('capability Skill discovery');+ capabilityRoutingConfig = {+ ...capabilityRoutingConfig,+ ...buildCodexCapabilitySkillConfigOverrides(capabilityRoutingPolicy, [+ ...skills,+ // A malformed restricted Skill may be absent from `skills` while+ // its concrete SKILL.md path is still reported here. Disable that+ // path too instead of failing open on a catalog parse error.+ ...errors.flatMap((error) =>+ error.path ? [{ path: error.path, enabled: true }] : [],+ ),+ ]),+ };+ } catch (error) {+ releaseHostBindingLeaseIfNeeded();+ throw new Error(+ `Cannot start Codex safely because Cindy could not inspect restricted Codex Skills: ${error instanceof Error ? error.message : String(error)}`,+ );+ }+ }const capabilityRoutingProtocolSupported =supportsCodexCapabilityRoutingProtocol(initResp.userAgent);if (@@ -5138,7 +5192,7 @@ export class CodexAgent extends BaseAgent {}const capabilityRoute = findCapabilityRouteOverride(- this.deps.capabilityRouting,+ capabilityRoutingPolicy,{harness: 'codex',surface: 'mcp',