@ken-jo/agent-connector 0.4.67 → 0.4.79
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/README.md +43 -6
- package/dist/{action-RUM6GP23.js → action-OHGFVKMC.js} +14 -14
- package/dist/{amazon-q-KXVJFT7Q.js → amazon-q-B52EY2SV.js} +6 -6
- package/dist/{amp-WAPHJYTK.js → amp-UXABVUKC.js} +10 -6
- package/dist/amp-UXABVUKC.js.map +1 -0
- package/dist/antigravity-RZHN53VB.js +18 -0
- package/dist/{antigravity-cli-OH27IFH5.js → antigravity-cli-KODEKUTM.js} +7 -7
- package/dist/{chunk-D6ZJS4ND.js → chunk-4FWETID5.js} +2 -2
- package/dist/{chunk-3Y23ZYYF.js → chunk-4HVQ7IUM.js} +4 -4
- package/dist/{chunk-IU42THN7.js → chunk-4NSU3KWX.js} +2 -2
- package/dist/{chunk-7CZKXXBD.js → chunk-56R2ER7K.js} +2 -2
- package/dist/{chunk-RQCBBLTA.js → chunk-7NXEHZAK.js} +3 -3
- package/dist/{chunk-P5KA5NVR.js → chunk-AMK2K6XZ.js} +49 -3
- package/dist/chunk-AMK2K6XZ.js.map +1 -0
- package/dist/{chunk-TZ5KGCE2.js → chunk-AY3RGRTT.js} +2 -2
- package/dist/{chunk-DBQMX75U.js → chunk-BEFVJ2OE.js} +28 -2
- package/dist/chunk-BEFVJ2OE.js.map +1 -0
- package/dist/{chunk-TO57WYBB.js → chunk-HORHRHNG.js} +9 -3
- package/dist/chunk-HORHRHNG.js.map +1 -0
- package/dist/{chunk-2HCJV6UO.js → chunk-IXOQDZWC.js} +9 -2
- package/dist/chunk-IXOQDZWC.js.map +1 -0
- package/dist/{chunk-CSRBMJLU.js → chunk-LKAVD4HP.js} +20 -10
- package/dist/chunk-LKAVD4HP.js.map +1 -0
- package/dist/{chunk-7QRUZAUG.js → chunk-LN76OGNR.js} +2 -2
- package/dist/{chunk-ZSMGHEB5.js → chunk-NBUEL74R.js} +8 -4
- package/dist/chunk-NBUEL74R.js.map +1 -0
- package/dist/{chunk-UVBAH263.js → chunk-PZHB5TVA.js} +5 -5
- package/dist/{chunk-AXAHW2KU.js → chunk-QKLJU4JX.js} +2 -2
- package/dist/{chunk-GCRRX4MO.js → chunk-S4E6QQEM.js} +2 -2
- package/dist/{chunk-F5COBB5F.js → chunk-UBB7T54N.js} +4 -4
- package/dist/{chunk-ZEFUDBTY.js → chunk-UYZ53KWS.js} +6 -6
- package/dist/{chunk-IZ4XQ23W.js → chunk-VD4EG6SG.js} +57 -11
- package/dist/chunk-VD4EG6SG.js.map +1 -0
- package/dist/{chunk-NXR4HM5N.js → chunk-VKRGQLY4.js} +19 -19
- package/dist/{chunk-NXR4HM5N.js.map → chunk-VKRGQLY4.js.map} +1 -1
- package/dist/{chunk-RHML2NOB.js → chunk-VVFDU4IX.js} +5 -5
- package/dist/chunk-VVFDU4IX.js.map +1 -0
- package/dist/{chunk-LS65GL2P.js → chunk-X457NOFE.js} +36 -36
- package/dist/chunk-YJP3KGLM.js +386 -0
- package/dist/chunk-YJP3KGLM.js.map +1 -0
- package/dist/{chunk-ALVXORZM.js → chunk-YYNXIUR2.js} +2 -2
- package/dist/{chunk-E45SUUD7.js → chunk-ZXX5DVSE.js} +5 -5
- package/dist/{claude-code-WLN43K7I.js → claude-code-T6ZRCMA7.js} +14 -10
- package/dist/claude-code-T6ZRCMA7.js.map +1 -0
- package/dist/cli/sdk.js +7 -7
- package/dist/cli.js +1 -1
- package/dist/{cline-PEGTGVQD.js → cline-NNMVCECA.js} +6 -6
- package/dist/{codebuff-UG6LVSOM.js → codebuff-RJIDSEU3.js} +10 -6
- package/dist/codebuff-RJIDSEU3.js.map +1 -0
- package/dist/{codex-4LVDQXCD.js → codex-RHKQKNNG.js} +19 -26
- package/dist/codex-RHKQKNNG.js.map +1 -0
- package/dist/{continue-DYV5V55Y.js → continue-MNM7YVJY.js} +7 -7
- package/dist/{copilot-cli-NVFXFLUF.js → copilot-cli-SMTX5F65.js} +68 -25
- package/dist/copilot-cli-SMTX5F65.js.map +1 -0
- package/dist/{crush-PP4HYZLT.js → crush-NYDBHIJE.js} +23 -13
- package/dist/crush-NYDBHIJE.js.map +1 -0
- package/dist/{cursor-XMXOZKAP.js → cursor-AOELDNZU.js} +7 -7
- package/dist/{detect-IZOWP5AA.js → detect-ALAKE54S.js} +4 -4
- package/dist/{doctor-5IVUQ2YH.js → doctor-UNF7FCF4.js} +101 -19
- package/dist/doctor-UNF7FCF4.js.map +1 -0
- package/dist/{droid-ETNOUIPJ.js → droid-PTCH2K7Y.js} +6 -6
- package/dist/{gemini-cli-P7XJXWVH.js → gemini-cli-QGLN2UMS.js} +6 -6
- package/dist/{goose-UZVA6MQC.js → goose-DQ6GSZ5O.js} +7 -7
- package/dist/{hermes-IC6R4CII.js → hermes-E47IG63A.js} +7 -7
- package/dist/{hook-7IUPIHCZ.js → hook-GM2IDA3C.js} +14 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/{install-EP6GPQ65.js → install-7O4XWH7T.js} +17 -17
- package/dist/{introspect-BFcXpfUp.d.ts → introspect-5o5ick0_.d.ts} +9 -4
- package/dist/{jetbrains-copilot-MZO2RQGJ.js → jetbrains-copilot-4IOT3I2Y.js} +5 -5
- package/dist/{kilo-CCB34CQQ.js → kilo-TAHOPT2Q.js} +6 -6
- package/dist/{kilo-cli-EOMN3WC7.js → kilo-cli-X4NPJWGX.js} +6 -6
- package/dist/{kimi-GUSJME55.js → kimi-Z7L2LEEI.js} +6 -6
- package/dist/{kiro-6OHZ5RGV.js → kiro-YZ4TTZGD.js} +6 -6
- package/dist/{leaderboard-6I2E5XZK.js → leaderboard-DVW4WYJ6.js} +5 -5
- package/dist/{mimo-code-ZPJJ6IIW.js → mimo-code-G2CBZ4M6.js} +6 -6
- package/dist/{mux-AFTVMGGM.js → mux-JNM3F2NW.js} +6 -6
- package/dist/{nemoclaw-D5EN4G2Q.js → nemoclaw-SHA4IUML.js} +7 -7
- package/dist/{omp-GKI2PZ7G.js → omp-OOVUNXME.js} +6 -6
- package/dist/openclaw-BD56E5MV.js +17 -0
- package/dist/{opencode-M34E6PI7.js → opencode-W2RK4M7G.js} +6 -6
- package/dist/{package-BWLV24OO.js → package-H5V3AZHR.js} +13 -13
- package/dist/{pi-HVG6ZWFE.js → pi-I7BLL4EI.js} +5 -5
- package/dist/{qwen-code-OWLM3I5P.js → qwen-code-JG7AF442.js} +7 -7
- package/dist/{roo-code-RFKKTNNI.js → roo-code-L5F7S6QH.js} +6 -6
- package/dist/runtime/index.d.ts +12 -1
- package/dist/runtime/index.js +12 -12
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.js +6 -6
- package/dist/sdk/test.d.ts +33 -3
- package/dist/sdk/test.js +14 -284
- package/dist/sdk/test.js.map +1 -1
- package/dist/{serve-CM4HZPMP.js → serve-WMO2TUW3.js} +24 -17
- package/dist/serve-WMO2TUW3.js.map +1 -0
- package/dist/{status-BPB4VLQX.js → status-WRLBTBRE.js} +10 -10
- package/dist/{statusline-HIKR2I4Q.js → statusline-EUD4DMIP.js} +13 -13
- package/dist/{telemetry-SBVUJYNE.js → telemetry-U3LGMR3D.js} +10 -10
- package/dist/{trae-FVHQALK3.js → trae-Z7CQ2A2Q.js} +6 -6
- package/dist/{types-ChUrvw0j.d.ts → types-D6RWGXm1.d.ts} +13 -0
- package/dist/{uninstall-MO3RGGVE.js → uninstall-TWPUEJEC.js} +17 -17
- package/dist/{upgrade-6XIGSPGY.js → upgrade-EM6Y7QLH.js} +17 -17
- package/dist/{usage-IBN36ZVW.js → usage-3HQDTXGY.js} +2 -2
- package/dist/{usage-event-4RJP37K6.js → usage-event-DWIGKO7V.js} +13 -13
- package/dist/{vscode-copilot-6FLDRTKV.js → vscode-copilot-LU5NC4ZS.js} +10 -6
- package/dist/vscode-copilot-LU5NC4ZS.js.map +1 -0
- package/dist/{warp-7CC52UJV.js → warp-4PPG5LOM.js} +6 -6
- package/dist/{windsurf-6ZLQMBQW.js → windsurf-3T3RVXKM.js} +6 -6
- package/dist/{zed-FULJMNBV.js → zed-LLOAUXSA.js} +6 -6
- package/package.json +1 -1
- package/dist/amp-WAPHJYTK.js.map +0 -1
- package/dist/antigravity-GF3RU42A.js +0 -18
- package/dist/chunk-2HCJV6UO.js.map +0 -1
- package/dist/chunk-CSRBMJLU.js.map +0 -1
- package/dist/chunk-DBQMX75U.js.map +0 -1
- package/dist/chunk-IZ4XQ23W.js.map +0 -1
- package/dist/chunk-P5KA5NVR.js.map +0 -1
- package/dist/chunk-RHML2NOB.js.map +0 -1
- package/dist/chunk-TO57WYBB.js.map +0 -1
- package/dist/chunk-ZSMGHEB5.js.map +0 -1
- package/dist/claude-code-WLN43K7I.js.map +0 -1
- package/dist/codebuff-UG6LVSOM.js.map +0 -1
- package/dist/codex-4LVDQXCD.js.map +0 -1
- package/dist/copilot-cli-NVFXFLUF.js.map +0 -1
- package/dist/crush-PP4HYZLT.js.map +0 -1
- package/dist/doctor-5IVUQ2YH.js.map +0 -1
- package/dist/openclaw-A76PCNBV.js +0 -17
- package/dist/serve-CM4HZPMP.js.map +0 -1
- package/dist/vscode-copilot-6FLDRTKV.js.map +0 -1
- /package/dist/{action-RUM6GP23.js.map → action-OHGFVKMC.js.map} +0 -0
- /package/dist/{amazon-q-KXVJFT7Q.js.map → amazon-q-B52EY2SV.js.map} +0 -0
- /package/dist/{antigravity-GF3RU42A.js.map → antigravity-RZHN53VB.js.map} +0 -0
- /package/dist/{antigravity-cli-OH27IFH5.js.map → antigravity-cli-KODEKUTM.js.map} +0 -0
- /package/dist/{chunk-D6ZJS4ND.js.map → chunk-4FWETID5.js.map} +0 -0
- /package/dist/{chunk-3Y23ZYYF.js.map → chunk-4HVQ7IUM.js.map} +0 -0
- /package/dist/{chunk-IU42THN7.js.map → chunk-4NSU3KWX.js.map} +0 -0
- /package/dist/{chunk-7CZKXXBD.js.map → chunk-56R2ER7K.js.map} +0 -0
- /package/dist/{chunk-RQCBBLTA.js.map → chunk-7NXEHZAK.js.map} +0 -0
- /package/dist/{chunk-TZ5KGCE2.js.map → chunk-AY3RGRTT.js.map} +0 -0
- /package/dist/{chunk-7QRUZAUG.js.map → chunk-LN76OGNR.js.map} +0 -0
- /package/dist/{chunk-UVBAH263.js.map → chunk-PZHB5TVA.js.map} +0 -0
- /package/dist/{chunk-AXAHW2KU.js.map → chunk-QKLJU4JX.js.map} +0 -0
- /package/dist/{chunk-GCRRX4MO.js.map → chunk-S4E6QQEM.js.map} +0 -0
- /package/dist/{chunk-F5COBB5F.js.map → chunk-UBB7T54N.js.map} +0 -0
- /package/dist/{chunk-ZEFUDBTY.js.map → chunk-UYZ53KWS.js.map} +0 -0
- /package/dist/{chunk-LS65GL2P.js.map → chunk-X457NOFE.js.map} +0 -0
- /package/dist/{chunk-ALVXORZM.js.map → chunk-YYNXIUR2.js.map} +0 -0
- /package/dist/{chunk-E45SUUD7.js.map → chunk-ZXX5DVSE.js.map} +0 -0
- /package/dist/{cline-PEGTGVQD.js.map → cline-NNMVCECA.js.map} +0 -0
- /package/dist/{continue-DYV5V55Y.js.map → continue-MNM7YVJY.js.map} +0 -0
- /package/dist/{cursor-XMXOZKAP.js.map → cursor-AOELDNZU.js.map} +0 -0
- /package/dist/{detect-IZOWP5AA.js.map → detect-ALAKE54S.js.map} +0 -0
- /package/dist/{droid-ETNOUIPJ.js.map → droid-PTCH2K7Y.js.map} +0 -0
- /package/dist/{gemini-cli-P7XJXWVH.js.map → gemini-cli-QGLN2UMS.js.map} +0 -0
- /package/dist/{goose-UZVA6MQC.js.map → goose-DQ6GSZ5O.js.map} +0 -0
- /package/dist/{hermes-IC6R4CII.js.map → hermes-E47IG63A.js.map} +0 -0
- /package/dist/{hook-7IUPIHCZ.js.map → hook-GM2IDA3C.js.map} +0 -0
- /package/dist/{install-EP6GPQ65.js.map → install-7O4XWH7T.js.map} +0 -0
- /package/dist/{jetbrains-copilot-MZO2RQGJ.js.map → jetbrains-copilot-4IOT3I2Y.js.map} +0 -0
- /package/dist/{kilo-CCB34CQQ.js.map → kilo-TAHOPT2Q.js.map} +0 -0
- /package/dist/{kilo-cli-EOMN3WC7.js.map → kilo-cli-X4NPJWGX.js.map} +0 -0
- /package/dist/{kimi-GUSJME55.js.map → kimi-Z7L2LEEI.js.map} +0 -0
- /package/dist/{kiro-6OHZ5RGV.js.map → kiro-YZ4TTZGD.js.map} +0 -0
- /package/dist/{leaderboard-6I2E5XZK.js.map → leaderboard-DVW4WYJ6.js.map} +0 -0
- /package/dist/{mimo-code-ZPJJ6IIW.js.map → mimo-code-G2CBZ4M6.js.map} +0 -0
- /package/dist/{mux-AFTVMGGM.js.map → mux-JNM3F2NW.js.map} +0 -0
- /package/dist/{nemoclaw-D5EN4G2Q.js.map → nemoclaw-SHA4IUML.js.map} +0 -0
- /package/dist/{omp-GKI2PZ7G.js.map → omp-OOVUNXME.js.map} +0 -0
- /package/dist/{openclaw-A76PCNBV.js.map → openclaw-BD56E5MV.js.map} +0 -0
- /package/dist/{opencode-M34E6PI7.js.map → opencode-W2RK4M7G.js.map} +0 -0
- /package/dist/{package-BWLV24OO.js.map → package-H5V3AZHR.js.map} +0 -0
- /package/dist/{pi-HVG6ZWFE.js.map → pi-I7BLL4EI.js.map} +0 -0
- /package/dist/{qwen-code-OWLM3I5P.js.map → qwen-code-JG7AF442.js.map} +0 -0
- /package/dist/{roo-code-RFKKTNNI.js.map → roo-code-L5F7S6QH.js.map} +0 -0
- /package/dist/{status-BPB4VLQX.js.map → status-WRLBTBRE.js.map} +0 -0
- /package/dist/{statusline-HIKR2I4Q.js.map → statusline-EUD4DMIP.js.map} +0 -0
- /package/dist/{telemetry-SBVUJYNE.js.map → telemetry-U3LGMR3D.js.map} +0 -0
- /package/dist/{trae-FVHQALK3.js.map → trae-Z7CQ2A2Q.js.map} +0 -0
- /package/dist/{uninstall-MO3RGGVE.js.map → uninstall-TWPUEJEC.js.map} +0 -0
- /package/dist/{upgrade-6XIGSPGY.js.map → upgrade-EM6Y7QLH.js.map} +0 -0
- /package/dist/{usage-IBN36ZVW.js.map → usage-3HQDTXGY.js.map} +0 -0
- /package/dist/{usage-event-4RJP37K6.js.map → usage-event-DWIGKO7V.js.map} +0 -0
- /package/dist/{warp-7CC52UJV.js.map → warp-4PPG5LOM.js.map} +0 -0
- /package/dist/{windsurf-6ZLQMBQW.js.map → windsurf-3T3RVXKM.js.map} +0 -0
- /package/dist/{zed-FULJMNBV.js.map → zed-LLOAUXSA.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/codebuff/index.ts"],"sourcesContent":["/**\n * adapters/codebuff — Codebuff platform adapter for agent-connector.\n *\n * Codebuff is an **mcp-only** host: it exposes no lifecycle hook system, and MCP\n * is its extensibility mechanism. This adapter therefore installs only the MCP\n * server and reports hooks as unavailable (mirrors the Warp reference path that\n * validates the `mcp-only` paradigm end-to-end).\n *\n * MCP config (SPEC):\n * - project scope (preferred) → <projectDir>/.agents/mcp.json\n * - user scope → ~/.agents/mcp.json\n * Both are JSON, root key \"mcpServers\". There is no separate hook file — the\n * hook \"config path\" is the same mcp.json so the generic doctor/backup behave\n * sensibly.\n *\n * A stdio server entry is the standard `{ type:\"stdio\", command, args, env }`\n * shape. Codebuff supports native `$VAR` interpolation, so `${env:VAR}` refs are\n * rewritten to Codebuff's native `$VAR` token (rewriteEnvRefs) rather than being\n * resolved to literals — secrets are never baked into the config file.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, InstallContext } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SubagentDef,\n Transport,\n} from \"../../core/types.js\";\nimport { rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"codebuff\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * Render `${env:VAR}`/`${env:VAR:-default}` into Codebuff's native `$VAR` token.\n *\n * When the portable ref carried a default (`${env:VAR:-fallback}`), Codebuff's\n * native `$VAR` token cannot express it — so a bare native token would silently\n * DROP the default. Instead, resolve the default at install time: emit the live\n * value when VAR is set and non-empty, else the literal fallback. The native\n * token is only emitted when there is no default to preserve.\n */\nconst toNativeRef = (name: string, def?: string): string => {\n if (def !== undefined) {\n const v = process.env[name];\n return v != null && v !== \"\" ? v : def;\n }\n return `$${name}`;\n};\n\n/** Recursively rewrite every `${env:VAR}` ref in a JSON-ish value to `$VAR`. */\nfunction rewriteEnvRefsDeep<T>(value: T): T {\n if (typeof value === \"string\") {\n return rewriteEnvRefs(value, toNativeRef) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) => rewriteEnvRefsDeep(v)) as unknown as T;\n }\n if (value && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) out[k] = rewriteEnvRefsDeep(v);\n return out as T;\n }\n return value;\n}\n\n/**\n * Render one AgentDefinition field as a ` key: value,` line for the emitted\n * `.agents/<id>.ts` module. The value is serialized with JSON.stringify (correct\n * string/array/object escaping); a known-identifier key is emitted unquoted, and\n * anything else (only reachable via `extra`) is quoted. Multi-line JSON (arrays /\n * nested objects) is reindented so it sits under the 2-space object body.\n */\nfunction renderAgentField(key: string, value: unknown): string {\n const k = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n const json = JSON.stringify(value, null, 2);\n const v = json.includes(\"\\n\") ? json.replace(/\\n/g, \"\\n \") : json;\n return ` ${k}: ${v},`;\n}\n\n/**\n * Native MCP server entry shapes Codebuff accepts under `mcpServers`.\n * A stdio entry is tagged with `type:\"stdio\"`; remote transports carry a `url`.\n */\ninterface CodebuffStdioServer {\n type: \"stdio\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface CodebuffHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\nexport class CodebuffAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Codebuff\";\n readonly paradigm: HookParadigm = \"mcp-only\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // Codebuff has no lifecycle hook system — every hook capability is false.\n preToolUse: false,\n postToolUse: false,\n preCompact: false,\n sessionStart: false,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: false,\n // Codebuff registers stdio and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"http\"],\n // Server env/url use Codebuff's NATIVE ${env:VAR} interpolation\n // (rewriteEnvRefs) — the token survives into the config, never a baked\n // literal — so the installer's unset-env-ref bake warn does not apply here.\n nativeServerEnvInterpolation: true,\n // Content surfaces: Codebuff reads AgentSkills from\n // <configDir>/skills/<name>/SKILL.md (configDir is .agents, so the path is\n // .agents/skills/<name>/SKILL.md). Verified against codebuff source\n // sdk/src/skills/load-skills.ts — the frontmatter `name` MUST equal the dir\n // name. Commands have no native Codebuff surface. Subagents ARE natively\n // supported — executable .agents/*.ts AgentDefinition modules (codebuff docs:\n // \"Create a new TypeScript file in .agents/\") — and are now WIRED:\n // installSubagents emits one `.agents/<id>.ts` AgentDefinition module per\n // declared subagent (PROJECT scope; see renderSubagent), each\n // default-exporting the AgentDefinition object WITHOUT the type-only\n // `agent-definition` import (erased at runtime; emitting it would only couple\n // the module to a generated types file that may not exist).\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".agents\");\n const userMcp = join(userDir, \"mcp.json\");\n const projDir = join(projectDir, \".agents\");\n const projMcp = join(projDir, \"mcp.json\");\n\n const userInstalled = existsSync(userDir) || existsSync(userMcp);\n const projInstalled = existsSync(projDir) || existsSync(projMcp);\n const installed = userInstalled || projInstalled;\n // Project is the preferred scope; fall back to user when only that matched.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projMcp : userMcp;\n\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? `found Codebuff config (${scope})`\n : `no .agents config dir at ${userDir} or ${projDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".agents\")\n : join(homedir(), \".agents\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Codebuff has no hook file — hooks are not a thing here. The hook \"config\n * path\" is the same mcp.json so the generic doctor/backup behave sensibly.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for codebuff\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Codebuff's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CodebuffStdioServer | CodebuffHttpServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Codebuff supports native `$VAR` interpolation, so rewrite every\n // ${env:VAR} ref to `$VAR` rather than baking literals into the config.\n const entry: CodebuffStdioServer = {\n type: \"stdio\",\n command: rewriteEnvRefsDeep(command),\n };\n if (args.length > 0) entry.args = rewriteEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport) — Codebuff registers a URL.\n const entry: CodebuffHttpServer = {\n type: \"http\",\n url: rewriteEnvRefsDeep(server.url ?? \"\"),\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Codebuff supports native `$VAR` interpolation, so\n * rewrite `${env:VAR}` references to `$VAR` rather than resolving to literals.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n return rewriteEnvRefsDeep({ ...env });\n }\n\n // ── Content surfaces: skills ──────────────────────────────────────────────\n // CONTENT-ONLY: pure native-file writers. No runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Each method is idempotent (byte-identical →\n // skip) via writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"codebuff\"].skills === false to skip. Both user and project scope\n // are supported (configDir resolves per scope).\n //\n // Native location:\n // skill → <configDir>/skills/<name>/SKILL.md (+ resources)\n // configDir is .agents, so .agents/skills/<name>/SKILL.md. Verified\n // against codebuff source sdk/src/skills/load-skills.ts — the\n // frontmatter `name` MUST equal the dir name.\n\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"skills\", name);\n }\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for codebuff\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), renderSkillMd(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Content surfaces: subagents ───────────────────────────────────────────\n // CONTENT-ONLY: pure native-file writers (no runtime dispatch, no home-bin\n // pointer, no telemetry wrap). Idempotent via writeContentFile, reversible via\n // removeContentFile. Honors platforms[\"codebuff\"].subagents === false.\n //\n // Native location: codebuff agents are executable TypeScript modules in the\n // PROJECT .agents/ dir — <projectDir>/.agents/<id>.ts (codebuff docs:\n // \"Create a new TypeScript file in .agents/\"). No user-scope agents dir is\n // documented, so user scope warn-skips (the warp/amp project-scoped precedent).\n\n /** Native subagent module path: <configDir>/<name>.ts (= .agents/<name>.ts). */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), `${name}.ts`);\n }\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for codebuff\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n // codebuff agents live in the PROJECT .agents/ dir; no user-scope agents dir\n // is documented, so user scope warn-skips (mirrors warp/amp project-scoped).\n if (ctx.scope !== \"project\") {\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n \"codebuff subagents are project-scoped only (.agents/*.ts; no documented \" +\n `user-scope agents dir); ${connector.subagents.length} skipped`,\n },\n ];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n this.renderSubagent(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n if (ctx.scope !== \"project\") {\n return [\n { platform: this.id, action: \"skip\", detail: \"codebuff subagents are project-scoped only\" },\n ];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent into a Codebuff `.agents/<id>.ts` AgentDefinition module:\n *\n * const definition = {\n * id: \"<name>\",\n * ...\n * };\n *\n * export default definition;\n *\n * Emitted WITHOUT the `import { AgentDefinition } from './types/agent-definition'`\n * line the docs show: that import is TYPE-ONLY (erased at runtime), so omitting\n * it avoids coupling the module to a generated types file that may not exist —\n * a bare object literal + default export is a complete, valid AgentDefinition.\n *\n * Field mapping (ONLY fields AC's SubagentDef can populate; nothing fabricated):\n * id ← name (already kebab-case → a valid codebuff id)\n * displayName ← name\n * spawnerPrompt ← description (the delegation hint)\n * model ← model (OMITTED when the connector declares none)\n * toolNames ← tools.allow (OMITTED when none declared)\n * instructionsPrompt ← prompt (the system prompt / instructions body)\n * SubagentDef.readonly is NOT mapped: Codebuff expresses tool access through the\n * `toolNames` allowlist and documents no read-only permission flag, and AC has no\n * verified read-only tool taxonomy to synthesize one — so a readonly hint is\n * carried only if the author restricts `tools.allow` themselves (or via `extra`).\n * `extra` is merged LAST as the documented escape hatch — the only way to reach\n * codebuff AgentDefinition fields AC does not model (version, outputMode,\n * spawnableAgents, inputSchema, …); its values come from the connector author,\n * never invented here.\n */\n private renderSubagent(agent: SubagentDef): string {\n const def: Record<string, unknown> = {\n id: agent.name,\n displayName: agent.name,\n spawnerPrompt: agent.description,\n };\n if (agent.model !== undefined) def.model = agent.model;\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) def.toolNames = [...allow];\n def.instructionsPrompt = agent.prompt;\n if (agent.extra) Object.assign(def, agent.extra);\n\n const body = Object.entries(def)\n .map(([k, v]) => renderAgentField(k, v))\n .join(\"\\n\");\n return `const definition = {\\n${body}\\n};\\n\\nexport default definition;\\n`;\n }\n\n // ── Hooks (unavailable — Codebuff is mcp-only) ────────────────────────────\n\n installHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Codebuff is mcp-only)\",\n },\n ];\n }\n\n uninstallHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Codebuff is mcp-only)\",\n },\n ];\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: mcpPath }\n : { status: \"FAIL\", detail: `not found: ${mcpPath}` },\n },\n {\n name: `${this.name}: server entry registered`,\n check: () => {\n // Only assert what the connector declares: a server-less connector\n // never writes a server entry, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(mcpPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY} in ${mcpPath}` };\n }\n return connectorId in bucket\n ? { status: \"OK\", detail: `${MCP_ROOT_KEY}.${connectorId} present` }\n : {\n status: \"FAIL\",\n detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${mcpPath}`,\n };\n },\n },\n ];\n\n // Content-surface checks: assert presence only for the skills this connector\n // declares (a skill-less connector writes none, so absence is healthy).\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n // Subagent checks: codebuff agents are PROJECT-scoped .agents/*.ts modules,\n // so assert presence only at project scope (user scope warn-skips install).\n if (ctx.scope === \"project\") {\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n }\n return checks;\n }\n}\n\nexport const adapter = new CodebuffAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAqBrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAWrB,IAAM,cAAc,CAAC,MAAc,QAAyB;AAC1D,MAAI,QAAQ,QAAW;AACrB,UAAM,IAAI,QAAQ,IAAI,IAAI;AAC1B,WAAO,KAAK,QAAQ,MAAM,KAAK,IAAI;AAAA,EACrC;AACA,SAAO,IAAI,IAAI;AACjB;AAGA,SAAS,mBAAsB,OAAa;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,eAAe,OAAO,WAAW;AAAA,EAC1C;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,MAAM,mBAAmB,CAAC,CAAC;AAAA,EAC/C;AACA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,MAA+B,CAAC;AACtC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,CAAC,IAAI,mBAAmB,CAAC;AACzE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AASA,SAAS,iBAAiB,KAAa,OAAwB;AAC7D,QAAM,IAAI,6BAA6B,KAAK,GAAG,IAAI,MAAM,KAAK,UAAU,GAAG;AAC3E,QAAM,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAC1C,QAAM,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,OAAO,MAAM,IAAI;AAC9D,SAAO,KAAK,CAAC,KAAK,CAAC;AACrB;AAkBO,IAAM,kBAAN,cAA8B,YAA+B;AAAA,EACzD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I,EAAE,QAAQ,QAAQ,QAAQ,cAAc,CAAC,GAAG;AAAA,QAC9F,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU,IAAI,gBAAgB;AAC3C,IAAO,mBAAQ;","names":["entry"]}
|
|
@@ -10,22 +10,22 @@ import {
|
|
|
10
10
|
} from "./chunk-H53QZQJI.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveEnvRefsDeep
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BEFVJ2OE.js";
|
|
14
14
|
import {
|
|
15
15
|
BaseAdapter,
|
|
16
16
|
removeFromObjectMap,
|
|
17
17
|
renderCommandMd,
|
|
18
18
|
renderSkillMd,
|
|
19
19
|
upsertInObjectMap
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VVFDU4IX.js";
|
|
21
21
|
import {
|
|
22
22
|
buildHomeBinHookCommand,
|
|
23
23
|
buildWrappedStdio
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-HORHRHNG.js";
|
|
25
|
+
import "./chunk-YYNXIUR2.js";
|
|
26
26
|
import {
|
|
27
27
|
ensureDir
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-IXOQDZWC.js";
|
|
29
29
|
|
|
30
30
|
// src/adapters/codex/index.ts
|
|
31
31
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -251,14 +251,15 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
251
251
|
// ── Install hooks (hooks.json) ──────────────────────────────────────────
|
|
252
252
|
installHooks(ctx) {
|
|
253
253
|
const path = this.getHookConfigPath(ctx);
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
254
|
+
const hooksOff = ctx.connector.platforms[this.id]?.hooks === false;
|
|
255
|
+
const declared = hooksOff ? [] : ctx.connector.hookEvents;
|
|
256
|
+
if (declared.length === 0) {
|
|
257
257
|
return [{ platform: this.id, action: "skip", path, detail: "no hooks declared" }];
|
|
258
258
|
}
|
|
259
|
+
const supported = (e) => CODEX_HOOK_EVENTS.includes(e);
|
|
259
260
|
const pending = [
|
|
260
|
-
...
|
|
261
|
-
...
|
|
261
|
+
...declared.filter((e) => !supported(e)).map((event) => ({ event, matcher: "" })),
|
|
262
|
+
...declared.filter(supported).map((event) => ({ event, matcher: "" }))
|
|
262
263
|
];
|
|
263
264
|
return this.upsertHookEntries(ctx, path, pending, this.hookDescriptor(ctx));
|
|
264
265
|
}
|
|
@@ -273,14 +274,18 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
273
274
|
* count, the warn wording, and the absent/no-match skips) is carried here so
|
|
274
275
|
* the engine reproduces the prior in-adapter loop byte-for-byte.
|
|
275
276
|
*/
|
|
276
|
-
hookDescriptor(
|
|
277
|
+
hookDescriptor(_ctx) {
|
|
277
278
|
return {
|
|
278
279
|
// Codex's server path coerces a malformed root; the hook path matches it.
|
|
279
280
|
malformedPolicy: "coerce",
|
|
280
|
-
// Supported event → identity;
|
|
281
|
-
//
|
|
281
|
+
// Supported event → identity; any other canonical event → undefined → the
|
|
282
|
+
// engine reports it (never silent), at the severity unmappedAction picks.
|
|
282
283
|
mapEvent: (e) => CODEX_HOOK_EVENTS.includes(e) ? e : void 0,
|
|
283
284
|
unmappedWarnDetail: (e) => `${e} has no Codex hook equivalent \u2014 skipped`,
|
|
285
|
+
// E1 newer events (PostToolUseFailure) keep the established `warn` (exit-1);
|
|
286
|
+
// the legacy SessionEnd / Notification — silently dropped before this fix —
|
|
287
|
+
// become a VISIBLE `skip` so the install exit code is unchanged for them.
|
|
288
|
+
unmappedAction: (e) => WARN_SKIP_EVENTS.has(e) ? "warn" : "skip",
|
|
284
289
|
renderEntry: (event, _matcher, command) => {
|
|
285
290
|
const entry = { hooks: [{ type: "command", command }] };
|
|
286
291
|
entry.matcher = event === "PreToolUse" || event === "PermissionRequest" ? PRE_TOOL_USE_MATCHER : "";
|
|
@@ -695,18 +700,6 @@ var CodexAdapter = class extends BaseAdapter {
|
|
|
695
700
|
if (!base) return void 0;
|
|
696
701
|
return override ? { ...base, ...override } : base;
|
|
697
702
|
}
|
|
698
|
-
/** Which canonical hook events to register for Codex, honoring overrides. */
|
|
699
|
-
effectiveHookEvents(ctx) {
|
|
700
|
-
const override = ctx.connector.platforms[this.id]?.hooks;
|
|
701
|
-
if (override === false) return [];
|
|
702
|
-
return CODEX_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));
|
|
703
|
-
}
|
|
704
|
-
/** Declared events Codex has no analog for — install reports a warn-skip. */
|
|
705
|
-
warnSkipHookEvents(ctx) {
|
|
706
|
-
const override = ctx.connector.platforms[this.id]?.hooks;
|
|
707
|
-
if (override === false) return [];
|
|
708
|
-
return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));
|
|
709
|
-
}
|
|
710
703
|
/**
|
|
711
704
|
* Render the `[mcp_servers.<id>]` table. TOML has NO interpolation, so every
|
|
712
705
|
* `${env:VAR}` is resolved to a literal at install time. The env table is a
|
|
@@ -763,4 +756,4 @@ export {
|
|
|
763
756
|
adapter,
|
|
764
757
|
codex_default as default
|
|
765
758
|
};
|
|
766
|
-
//# sourceMappingURL=codex-
|
|
759
|
+
//# sourceMappingURL=codex-RHKQKNNG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/codex/index.ts"],"sourcesContent":["/**\n * adapters/codex — Codex CLI platform adapter for agent-connector.\n *\n * Codex CLI hook paradigm is \"json-stdio\": the host pipes a JSON payload to a\n * command on stdin and reads JSON/exit-code back — the same wire protocol as\n * Claude Code (PascalCase fields, `hookSpecificOutput` reply wrapper).\n *\n * Two native config files live under the Codex config dir\n * (`$CODEX_HOME` || `~/.codex`, mirrored to `<projectDir>/.codex` for project\n * scope):\n * - config.toml → `[mcp_servers.<id>]` MCP registration (TOML, NO native\n * interpolation, so env-refs are resolved to literals at install time).\n * - hooks.json → Claude-compatible hook registration ({ matcher, hooks }).\n *\n * Grounded in context-mode's proven Codex adapter (configs/codex/{config.toml,\n * hooks.json}, src/adapters/codex/*) — exact TOML MCP shape + hook JSON schema.\n *\n * Codex capabilities (upstream, verified against openai/codex source at the\n * stable release tags noted):\n * - PreToolUse `updatedInput` rewrite IS honored (PR #20527, commit d08906a9,\n * stable since codex 0.131.0; applied in the shell/mcp/apply_patch tool\n * handlers, confirmed present through 0.141.0) — hence canModifyArgs is now\n * TRUE. Codex's output_parser.rs requires the rewrite to be paired with\n * `permissionDecision:\"allow\"` (an allow WITHOUT updatedInput, and an\n * updatedInput WITHOUT allow, are both rejected as invalid), so \"modify\"\n * emits the allow+updatedInput envelope together. The still-open tracking\n * issue openai/codex#18491 is now scoped to a NARROWER gap — read_file/grep\n * have no PreToolUse handler yet — not to updatedInput itself, which works\n * for every tool that fires PreToolUse (shell/Bash, apply_patch, MCP).\n * - PostToolUse `updatedMCPToolOutput` is still explicitly rejected as\n * \"unsupported\" by output_parser.rs (no output-rewrite field on\n * PostToolUseOutput at 0.141.0) — hence canModifyOutput stays FALSE.\n *\n * E1 extension events (verified against developers.openai.com/codex/hooks):\n * - PermissionRequest — native, decision-capable via the nested\n * hookSpecificOutput.decision{behavior:\"allow\"|\"deny\", message?} envelope.\n * Codex docs: updatedInput / updatedPermissions / interrupt FAIL CLOSED on\n * this event, so they are never emitted here.\n * - SubagentStart — native; hookSpecificOutput.additionalContext is injected\n * as developer context for the subagent (not blockable).\n * - SubagentStop — native; the documented continuation shape is the TOP-LEVEL\n * {\"decision\":\"block\",\"reason\"} (Stop semantics: keeps the subagent going).\n * - PostToolUseFailure — NO Codex analog (PostToolUse only); declared hooks\n * for it warn-skip at install and the capability flag stays unset.\n * - PostCompact — native (Codex's hook system fires both PreCompact and\n * PostCompact); observe-only, normalizing the `trigger` (manual|auto)\n * exactly like PreCompact, with a passthrough formatReply.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport TOML from \"@iarna/toml\";\n\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SkillDef,\n SubagentDef,\n} from \"../../core/types.js\";\nimport { ensureDir } from \"../../core/paths.js\";\nimport { codexConfigHome } from \"../../core/host-paths.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n removeFromObjectMap,\n upsertInObjectMap,\n type ObjectMapCodec,\n} from \"../../core/object-map.js\";\nimport { writeTomlString } from \"../../core/toml.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderCommandMd, renderSkillMd } from \"../claude-code/render.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\nimport { BaseAdapter, type HookMergeDescriptor } from \"../base.js\";\nimport type {\n HookReply,\n InstallContext,\n MemoryTarget,\n NormalizedEvent,\n} from \"../spi.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native shapes\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Raw Codex hook payload (PascalCase event, snake_case fields — Claude-style). */\ninterface CodexHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n // PostToolUse only. The host serializes this as serde_json::Value (any JSON):\n // a BARE STRING for shell/apply_patch (e.g. json!(\"shell output\")) but an\n // OBJECT for MCP/structured tools (the serialized CallToolResult, e.g.\n // json!({content,structuredContent,isError})) — NOT always a string. Typed\n // `unknown` so PostToolUse coerces it for the string-typed toolOutput.\n // Primary source: openai/codex codex-rs/hooks/src/schema.rs PostToolUseCommandInput\n // `tool_response: Value` + core/src/tools/handlers/{mcp.rs object, shell_tests.rs string}.\n tool_response?: unknown;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n source?: string;\n prompt?: string;\n // NO is_error: Codex's PostToolUseCommandInput struct (#[serde(deny_unknown_fields)])\n // never serializes a top-level is_error — the error signal for MCP tools lives\n // INSIDE tool_response as the CallToolResult `isError`. The field was removed;\n // see derivePostToolUseIsError below. (openai/codex codex-rs/hooks/src/schema.rs:317-337)\n stop_hook_active?: boolean;\n trigger?: string;\n message?: string;\n // PostToolUseFailure-style failure field. Codex has NO failure event today;\n // parsed defensively only (the Claude-compatible wire would carry it).\n error?: string;\n // SubagentStart / SubagentStop (agent_type is the matcher subject).\n agent_id?: string;\n agent_type?: string;\n // SubagentStop only — the subagent's own transcript + final message.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n}\n\n/** One hook entry inside hooks.json (Claude-compatible). */\ninterface CodexHookEntry {\n matcher?: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** Rendered `[mcp_servers.<id>]` table — string env table, no interpolation. */\ninterface CodexMcpEntry {\n // stdio transport\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n // streamable HTTP transport (remote): codex infers the transport from `url`\n // (no explicit transport key). Verified against codex-cli 0.139.0.\n url?: string;\n bearer_token_env_var?: string;\n http_headers?: Record<string, string>;\n}\n\n/**\n * Codex hook events agent-connector registers, in the canonical → native order.\n * Codex uses the same PascalCase event names as Claude Code; the home-binary\n * hook command receives the lowercased event token.\n */\nconst CODEX_HOOK_EVENTS = [\n \"SessionStart\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"UserPromptSubmit\",\n \"Stop\",\n \"PermissionRequest\",\n \"SubagentStart\",\n \"SubagentStop\",\n \"PostCompact\",\n] as const;\n\ntype CodexHookEventName = (typeof CODEX_HOOK_EVENTS)[number];\n\n/**\n * Newer E1 canonical events with NO Codex analog: Codex ships PostToolUse only —\n * there is no failure event on the live hooks page. Declared hooks for these\n * warn-skip (action `warn`, exit-1) — the established convention. The legacy\n * SessionEnd / Notification, which Codex also cannot fire, are reported as a\n * VISIBLE `skip` instead (exit-0 preserving) — see the hook descriptor's\n * `unmappedAction`. Nothing Codex cannot fire is ever silently dropped.\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set([\"PostToolUseFailure\"]);\n\n/**\n * PreToolUse matcher — canonical Codex tool names + bare MCP tool names +\n * external MCP catch-all literal. Charset-clean ([A-Za-z0-9_|] only) so Codex's\n * Rust `regex` exact-matcher short-circuits (no look-around, which Codex\n * rejects at boot). Copied from context-mode's proven matcher.\n */\nconst PRE_TOOL_USE_MATCHER =\n \"local_shell|shell|shell_command|exec_command|Bash|Shell|apply_patch|Edit|Write|grep_files|mcp__\";\n\n/**\n * Coerce Codex's PostToolUse `tool_response` (serde_json::Value — bare string\n * for shell/apply_patch, OBJECT for MCP/structured tools) to a string for the\n * string-typed `toolOutput`. A string passes through verbatim; everything else\n * (object/array/number/bool) is JSON-stringified; undefined/null → undefined\n * (leave `toolOutput` unset).\n *\n * Source: openai/codex codex-rs/hooks/src/schema.rs PostToolUseCommandInput\n * `tool_response: Value`; core/src/tools/handlers/shell_tests.rs emits\n * `json!(\"shell output\")` (string), mcp.rs emits `json!({...})` (object).\n */\nfunction coerceToolResponse(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Derive PostToolUse `isError`. Codex's PostToolUseCommandInput\n * (`#[serde(deny_unknown_fields)]`) has NO top-level is_error field, so the only\n * machine-readable error signal is the MCP CallToolResult `isError` nested in\n * the `tool_response` object (serialized camelCase by rmcp). For shell/\n * apply_patch tool_response is a bare string carrying no boolean, so we report\n * false. Returns false when no such signal exists (never invents one).\n *\n * Source: openai/codex codex-rs/hooks/src/schema.rs:317-337 (no is_error field);\n * codex-rs/core/src/tools/handlers/mcp.rs (tool_response = serialized\n * CallToolResult → `isError` when the MCP call failed).\n */\nfunction derivePostToolUseIsError(toolResponse: unknown): boolean {\n if (toolResponse !== null && typeof toolResponse === \"object\") {\n const flag = (toolResponse as Record<string, unknown>).isError;\n if (typeof flag === \"boolean\") return flag;\n }\n return false;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Adapter\n// ─────────────────────────────────────────────────────────────────────────\n\nexport class CodexAdapter extends BaseAdapter {\n readonly id: PlatformId = \"codex\";\n readonly name = \"Codex CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block. memoryTargets below probes\n // AGENTS.override.md first (it shadows AGENTS.md per directory on codex).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // E1 events: PermissionRequest (decision-capable) + SubagentStart/Stop are\n // Codex-native. postToolUseFailure stays unset — Codex has no failure event,\n // so a declared hook for it warn-skips at install.\n permissionRequest: true,\n subagentStart: true,\n subagentStop: true,\n // PostCompact: Codex's hook system fires both PreCompact and PostCompact\n // (developers.openai.com/codex/hooks). Observational only — the reply\n // contract mirrors PreCompact (cannot block/modify a completed compaction).\n postCompact: true,\n // PreToolUse updatedInput rewrite is honored upstream (paired with\n // permissionDecision:\"allow\"); PostToolUse output rewrite is not (see header).\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Codex implements all three.\n // command → ~/.codex/prompts/<name>.md (md+frontmatter, USER SCOPE ONLY)\n // skill → project: .codex/skills/<name>/SKILL.md · user: ~/.agents/skills/<name>/SKILL.md\n // subagent → <codexDir>/agents/<name>.toml (TOML)\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ──────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = this.userConfigDir();\n const projDir = join(projectDir, \".codex\");\n const userCfg = join(userDir, \"config.toml\");\n const projCfg = join(projDir, \"config.toml\");\n\n const userInstalled = existsSync(userDir) || existsSync(userCfg);\n const projInstalled = existsSync(projDir) || existsSync(projCfg);\n const installed = userInstalled || projInstalled;\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projCfg : userCfg;\n\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? `Found Codex config dir (${scope})`\n : `No .codex config dir at ${userDir} or ${projDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ───────────────────────────────────────────────────────\n\n override getConfigDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") return join(ctx.projectDir, \".codex\");\n return this.userConfigDir();\n }\n\n override getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"config.toml\");\n }\n\n override getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"hooks.json\");\n }\n\n // ── Memory surface: AGENTS.override.md probe + 32 KiB doc-cap budget ─────\n // Codex reads AGENTS.override.md > AGENTS.md per directory (one file per\n // directory), so when the override file exists OUR block must live there or\n // it is never loaded. Combined project docs are capped at 32 KiB\n // (`project_doc_max_bytes`), hence the ~28 KiB per-file budget warn.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n // An explicit path override keeps the base resolution (escape hatch wins).\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") return [];\n const budgetBytes = 28 * 1024;\n const dir = ctx.scope === \"project\" ? ctx.projectDir : this.userConfigDir();\n const overrideMd = join(dir, \"AGENTS.override.md\");\n if (existsSync(overrideMd)) {\n return [\n {\n path: overrideMd,\n reason: \"AGENTS.override.md shadows AGENTS.md on codex (one doc per directory)\",\n budgetBytes,\n },\n ];\n }\n return [\n {\n path: join(dir, \"AGENTS.md\"),\n reason:\n ctx.scope === \"project\"\n ? \"AGENTS.md standard (project root; codex is the format's originator)\"\n : \"codex global guidance ($CODEX_HOME/AGENTS.md)\",\n budgetBytes,\n },\n ];\n }\n\n /** `$CODEX_HOME` (tilde-expanded, then resolved) || `~/.codex` for user\n * scope. Shared with marketplace detection via `codexConfigHome` so the\n * config writer and the install probe never target different dirs. */\n private userConfigDir(): string {\n return codexConfigHome();\n }\n\n // ── TOML config IO (override JSON helpers — config.toml is TOML) ─────────\n\n private readToml(path: string): Record<string, unknown> {\n if (!existsSync(path)) return {};\n try {\n return TOML.parse(readFileSync(path, \"utf8\")) as Record<string, unknown>;\n } catch {\n return {};\n }\n }\n\n private writeToml(path: string, data: Record<string, unknown>, dryRun: boolean): void {\n if (dryRun) return;\n ensureDir(dirname(path));\n // @iarna/toml's stringify type wants its JsonMap; our object is structurally compatible.\n writeFileSync(path, TOML.stringify(data as never), \"utf8\");\n }\n\n /** An ObjectMapCodec over config.toml for the core/object-map engine.\n * `isPresentButUnparseable` is `() => false`: readToml fail-softs to {} and the\n * server path has historically coerced/overwritten rather than warn-skip on an\n * unparseable file — preserved here for byte-identical behavior. */\n private tomlObjectMapCodec(): ObjectMapCodec {\n return {\n parse: (path) => this.readToml(path),\n serialize: (path, data, dryRun) => this.writeToml(path, data, dryRun),\n isPresentButUnparseable: () => false,\n };\n }\n\n // ── Install server (config.toml → [mcp_servers.<id>]) ───────────────────\n\n override installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const server = this.effectiveServer(ctx);\n const path = this.getServerConfigPath(ctx);\n\n if (!server) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no server declared\" }];\n }\n const isStdio = server.transport === \"stdio\" && !!server.command;\n const isHttp = server.transport === \"http\" && !!server.url;\n if (!isStdio && !isHttp) {\n // Codex config.toml [mcp_servers] supports stdio (command) + streamable\n // HTTP (url). Other remote transports (sse/ws) have no codex analog.\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `transport \"${server.transport}\" not registrable in config.toml (stdio + streamable-http only)`,\n },\n ];\n }\n\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const entry = this.renderMcpEntry(ctx, server);\n\n return [\n upsertInObjectMap({\n codec: this.tomlObjectMapCodec(),\n rootKey: \"mcp_servers\",\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n entry,\n dryRun,\n }),\n ];\n }\n\n override uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getServerConfigPath(ctx);\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n return [\n removeFromObjectMap({\n codec: this.tomlObjectMapCodec(),\n rootKey: \"mcp_servers\",\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n dryRun,\n }),\n ];\n }\n\n // ── Install hooks (hooks.json) ──────────────────────────────────────────\n\n override installHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const hooksOff = ctx.connector.platforms[this.id]?.hooks === false;\n const declared = hooksOff ? [] : ctx.connector.hookEvents;\n\n if (declared.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n // HOST-ORDERED pending: the unsupported events (mapEvent → undefined →\n // warn/skip via the descriptor) FIRST, then the supported events in\n // CODEX_HOOK_EVENTS order. EVERY declared event is enqueued — an event with\n // no Codex analog is reported VISIBLY (warn for the E1 newer events, a `skip`\n // for the legacy SessionEnd/Notification whose drop predates the convention),\n // never silently dropped. matcher is \"\" for every item; renderEntry derives\n // the real matcher from the event (PreToolUse/PermissionRequest).\n const supported = (e: HookEventName) =>\n (CODEX_HOOK_EVENTS as readonly string[]).includes(e);\n const pending = [\n ...declared.filter((e) => !supported(e)).map((event) => ({ event: event as string, matcher: \"\" })),\n ...declared.filter(supported).map((event) => ({ event: event as string, matcher: \"\" })),\n ];\n return this.upsertHookEntries(ctx, path, pending, this.hookDescriptor(ctx));\n }\n\n override uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n return this.removeHookEntries(ctx, this.getHookConfigPath(ctx), this.hookDescriptor(ctx));\n }\n\n /**\n * Codex hook-merge policy for the shared object-map engine. EVENT-SPECIFIC by\n * construction: every observable (coerce root + bucket, the path-normalized\n * per-event ownership find, the event-derived matcher with `hooks`-then-\n * `matcher` key order, the BARE `hooks.<event>` skip/remove details with NO\n * count, the warn wording, and the absent/no-match skips) is carried here so\n * the engine reproduces the prior in-adapter loop byte-for-byte.\n */\n private hookDescriptor(_ctx: InstallContext): HookMergeDescriptor<CodexHookEntry> {\n return {\n // Codex's server path coerces a malformed root; the hook path matches it.\n malformedPolicy: \"coerce\",\n // Supported event → identity; any other canonical event → undefined → the\n // engine reports it (never silent), at the severity unmappedAction picks.\n mapEvent: (e) =>\n (CODEX_HOOK_EVENTS as readonly string[]).includes(e) ? e : undefined,\n unmappedWarnDetail: (e) => `${e} has no Codex hook equivalent — skipped`,\n // E1 newer events (PostToolUseFailure) keep the established `warn` (exit-1);\n // the legacy SessionEnd / Notification — silently dropped before this fix —\n // become a VISIBLE `skip` so the install exit code is unchanged for them.\n unmappedAction: (e) =>\n WARN_SKIP_EVENTS.has(e as HookEventName) ? \"warn\" : \"skip\",\n renderEntry: (event, _matcher, command) => {\n const entry: CodexHookEntry = { hooks: [{ type: \"command\", command }] };\n // KEY ORDER: hooks THEN matcher. Matcher is EVENT-derived, not from the\n // connector's declared matcher: PermissionRequest matches tool names like\n // PreToolUse (charset-clean), everything else registers \"\" (all).\n entry.matcher =\n event === \"PreToolUse\" || event === \"PermissionRequest\" ? PRE_TOOL_USE_MATCHER : \"\";\n return entry;\n },\n // Idempotency find for the CANONICAL event the engine built `command` from —\n // path-normalized, exact-command, the body of isOurEntry's command check.\n entryOwnsCommand: (entry, command) =>\n Array.isArray(entry.hooks) &&\n entry.hooks.some(\n (h) => (h.command ?? \"\").replace(/\\\\/g, \"/\") === command.replace(/\\\\/g, \"/\"),\n ),\n // FLAT whole-entry removal, EVENT-SPECIFIC: isOurEntry rebuilds our command\n // from the event key being stripped, so a SubagentStop entry is never matched\n // while iterating the PreToolUse bucket.\n ownsEntryForRemove: (c, event) => (entry) =>\n this.isOurEntry(c, event as CodexHookEventName, entry),\n skipDetail: (e) => `hooks.${e}`,\n removeDetail: (e, _n) => `hooks.${e}`,\n absentDetail: \"no hooks.json\",\n noMatchDetail: \"no agent-connector hooks present\",\n // Uninstall scans EXACTLY codex's fixed event set (not Object.keys), so a\n // home-bin command hand-placed under a foreign event key is left untouched —\n // byte-identical to the prior `for (const event of CODEX_HOOK_EVENTS)` loop.\n removeEventKeys: CODEX_HOOK_EVENTS,\n };\n }\n\n // ── Health checks (default doctor renders these) ────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const path = this.getServerConfigPath(ctx);\n const id = ctx.connector.id;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: config.toml exists`,\n check: () =>\n existsSync(path)\n ? { status: \"OK\", detail: path }\n : { status: \"FAIL\", detail: `not found: ${path}` },\n },\n {\n name: `${this.name}: mcp_servers.${id} registered`,\n check: () => {\n // Only assert what the connector declares (same rule as the\n // content-surface checks below): a server-less connector — e.g. a\n // catalog-only bundle of agents/skills/commands — never writes an\n // [mcp_servers.<id>] table, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readToml(path);\n const bucket = cfg[\"mcp_servers\"];\n const present =\n typeof bucket === \"object\" &&\n bucket !== null &&\n id in (bucket as Record<string, unknown>);\n return present\n ? { status: \"OK\", detail: `mcp_servers.${id}` }\n : { status: \"FAIL\", detail: `mcp_servers.${id} not found in ${path}` };\n },\n },\n ];\n\n // Content-surface checks: assert presence only for surfaces this connector\n // declares. Codex commands are user-scope only, so a project-scope install\n // won't have written them — only check command files in user scope.\n if (ctx.scope !== \"project\") {\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Content surfaces: commands / skills / subagents ──────────────────────\n // CONTENT-ONLY: pure native-file writers. No runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Each method is idempotent (byte-identical →\n // skip) via writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"codex\"] per-surface false to skip.\n //\n // Native locations:\n // command → ~/.codex/prompts/<name>.md md+frontmatter(description,argument-hint)\n // USER SCOPE ONLY — project scope yields a single \"warn\".\n // skill → project: <projectDir>/.codex/skills/<name>/SKILL.md (+ resources)\n // user: ~/.agents/skills/<name>/SKILL.md (~/.codex/skills is deprecated)\n // subagent → <codexDir>/agents/<name>.toml TOML via writeTomlString\n\n /** Command files always live under the USER codex dir: ~/.codex/prompts. */\n private commandPath(name: string): string {\n return join(this.userConfigDir(), \"prompts\", `${name}.md`);\n }\n private skillDir(ctx: InstallContext, name: string): string {\n // Project scope: <projectDir>/.codex/skills/<name> — the Project config-layer\n // skills root (codex-rs/core-skills/src/loader.rs, ConfigLayerSource::Project),\n // NOT deprecated. User scope: $HOME/.agents/skills/<name> — codex's CURRENT\n // user skills root. The older $CODEX_HOME/skills (~/.codex/skills) is still\n // read but the loader labels it a \"Deprecated user skills location, kept for\n // backward compatibility\". .agents is anchored to the OS home (home_dir), NOT\n // $CODEX_HOME — so use homedir() here, never userConfigDir() (which honors\n // CODEX_HOME).\n if (ctx.scope === \"project\") return join(this.getConfigDir(ctx), \"skills\", name);\n return join(homedir(), \".agents\", \"skills\", name);\n }\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"agents\", `${name}.toml`);\n }\n\n // ── Commands (USER SCOPE ONLY) ───────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for codex\" }];\n }\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(\n this.commandPath(cmd.name),\n renderCommandMd(cmd, { includeToolsAndModel: false }),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(cmd.name), ctx.dryRun),\n );\n }\n\n // ── Skills ───────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for codex\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n const rendered = renderSkillMd(skill);\n changes.push(this.writeContentFile(join(dir, \"SKILL.md\"), rendered, ctx.dryRun));\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n // Migrate away an AC-owned copy at the deprecated user skills root so the\n // skill is not double-registered after the move to ~/.agents/skills.\n changes.push(...this.migrateDeprecatedUserSkill(ctx, skill, rendered));\n }\n return changes;\n }\n\n /**\n * One-time, opt-out-safe migration: prior AC versions wrote user-scope skills\n * to the now-deprecated $CODEX_HOME/skills/<name> root, which codex STILL reads\n * (kept for backward compatibility). Once we write the same skill to the current\n * ~/.agents/skills root, codex would register it TWICE (same frontmatter name,\n * two User-scope roots). If a SKILL.md exists at the deprecated path AND is\n * byte-identical to what we render — i.e. AC-owned, not hand-authored — remove\n * it (and its now-empty dir). The content-equality guard guarantees we never\n * delete a skill a user placed there by hand. No-op for project scope (where\n * .codex/skills is the valid, non-deprecated Project config-layer path) and when\n * a custom CODEX_HOME would make the deprecated path coincide with the new one.\n */\n private migrateDeprecatedUserSkill(\n ctx: InstallContext,\n skill: SkillDef,\n rendered: string,\n ): ChangeRecord[] {\n if (ctx.scope === \"project\") return [];\n const deprecated = join(this.userConfigDir(), \"skills\", skill.name, \"SKILL.md\");\n // Never touch the file we just wrote (pathological CODEX_HOME === ~/.agents).\n if (deprecated === join(this.skillDir(ctx, skill.name), \"SKILL.md\")) return [];\n if (!existsSync(deprecated)) return [];\n if (readFileSync(deprecated, \"utf8\") !== rendered) return []; // hand-authored — leave it\n return [\n this.removeContentFile(deprecated, ctx.dryRun),\n this.removeDirIfEmpty(dirname(deprecated), ctx.dryRun),\n ];\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Subagents (TOML) ─────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for codex\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(this.subagentPath(ctx, agent.name), this.renderSubagent(agent), ctx.dryRun),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent to a Codex agent TOML file:\n * { name, description, developer_instructions: prompt, model }.\n * model is omitted when undefined so Codex applies its default.\n */\n private renderSubagent(agent: SubagentDef): string {\n const table: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n developer_instructions: agent.prompt,\n };\n if (agent.model !== undefined) table.model = agent.model;\n if (agent.extra) Object.assign(table, agent.extra);\n return writeTomlString(table);\n }\n\n // ── Runtime dispatch ────────────────────────────────────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CodexHookInput;\n const base = {\n hostPlatform: this.id,\n connectorId: \"\",\n sessionId: input.session_id ?? `pid-${process.ppid}`,\n projectDir: input.cwd ?? process.env.CODEX_PROJECT_DIR ?? process.cwd(),\n raw,\n };\n\n switch (event) {\n case \"PreToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n // tool_response is a bare string for shell/apply_patch but an OBJECT\n // for MCP tools — coerce non-strings to JSON so the string-typed\n // toolOutput never receives a raw object.\n toolOutput: coerceToolResponse(input.tool_response),\n // Codex never serializes a top-level is_error (deny_unknown_fields);\n // the true error signal is the CallToolResult.isError nested inside\n // tool_response for MCP tools. Derive it from there.\n isError: derivePostToolUseIsError(input.tool_response),\n };\n case \"SessionStart\":\n return { ...base, source: normalizeSessionSource(input.source) };\n case \"SessionEnd\":\n return { ...base, reason: input.message };\n case \"UserPromptSubmit\":\n return { ...base, prompt: input.prompt ?? \"\" };\n case \"PreCompact\":\n return { ...base, trigger: input.trigger === \"manual\" ? \"manual\" : \"auto\" };\n case \"PostCompact\":\n // Post-compaction sibling of PreCompact — same `trigger` normalization\n // (manual|auto), observe-only. Codex's PostCompact payload mirrors\n // PreCompact's; everything else rides on `raw`.\n return { ...base, trigger: input.trigger === \"manual\" ? \"manual\" : \"auto\" };\n case \"Stop\":\n return { ...base, stopHookActive: input.stop_hook_active ?? false };\n case \"Notification\":\n return { ...base, message: input.message ?? \"\" };\n case \"PermissionRequest\":\n // Codex documents tool_name/tool_input (+tool_input.description); it has\n // no permission_suggestions field, so the normalized optional stays unset.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUseFailure\":\n // No Codex analog — never fired natively. Parsed defensively (Claude-\n // compatible wire) so a manual `hook codex PostToolUseFailure` invocation\n // still normalizes instead of throwing.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: input.error ?? \"\",\n };\n case \"SubagentStart\":\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\n };\n case \"SubagentStop\":\n // agent_id/agent_type stay optional — never depend on hosts populating\n // them on stop (the Claude-family SDK quirk).\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n }\n }\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n // Codex (like Claude Code) reads a `hookSpecificOutput` JSON wrapper from\n // stdout; exit code 0 = allow. Fields the host cannot honor are dropped.\n\n // PermissionRequest uses Codex's nested decision{behavior} envelope and is\n // the ONE event where an EXPLICIT \"allow\" is an ACTIVE grant (suppresses the\n // approval prompt). ask/context/void → NO decision output: fall through to\n // the normal approval flow (the prompt IS the ask). Codex docs: updatedInput\n // / updatedPermissions / interrupt FAIL CLOSED on this event, so \"modify\"\n // also falls through — emitting a bare allow would grant the ORIGINAL input\n // the handler wanted rewritten.\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n }),\n };\n }\n if (response.decision === \"allow\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: { behavior: \"allow\" },\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // SubagentStart is observe/context-only on Codex (continue:false is parsed\n // but does not stop the subagent): \"context\" injects additionalContext as\n // developer context for the SUBAGENT, and a \"deny\" DEGRADES to the same\n // shape carrying the reason.\n if (event === \"SubagentStart\") {\n const context =\n response.decision === \"context\"\n ? response.additionalContext\n : response.decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"SubagentStart\",\n additionalContext: context,\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n if (response.decision === \"deny\") {\n // PreToolUse deny is honored; other events fail-open to allow.\n if (event === \"PreToolUse\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n }),\n };\n }\n // SubagentStop deny = Stop semantics: the documented continuation shape is\n // the TOP-LEVEL {\"decision\":\"block\",\"reason\"} (keeps the subagent going\n // with `reason` as its next instruction).\n if (event === \"SubagentStop\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // modify → rewrite PreToolUse tool input. Codex applies `updatedInput`\n // (PR #20527, stable since 0.131.0) but its output_parser.rs only accepts it\n // when paired with permissionDecision:\"allow\" — emitting updatedInput alone\n // (the Claude Code shape) is rejected as \"updatedInput without\n // permissionDecision:allow\", and an allow alone is rejected too, so the pair\n // is emitted together. Other events fail open (no updatedInput surface).\n if (response.decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"allow\",\n updatedInput: response.updatedInput,\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // Context injection: honored on SessionStart, PostToolUse, and PreToolUse\n // (additionalContext — PreToolUse support shipped via PR #20692, stable since\n // codex 0.130.0; injected independent of any permission decision).\n // (SubagentStop accepts only the common output fields — no additionalContext.)\n if (\n response.additionalContext &&\n (event === \"SessionStart\" || event === \"PostToolUse\" || event === \"PreToolUse\")\n ) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: event,\n additionalContext: response.additionalContext,\n },\n }),\n };\n }\n\n // \"allow\" / unsupported-on-Codex (ask) → passthrough.\n return { exitCode: 0 };\n }\n\n // ── Internal helpers ────────────────────────────────────────────────────\n\n /** Resolve the per-platform server override into an effective ServerDef. */\n private effectiveServer(ctx: InstallContext): ServerDef | undefined {\n const override = ctx.connector.platforms[this.id]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override ? { ...base, ...override } : base;\n }\n\n /**\n * Render the `[mcp_servers.<id>]` table. TOML has NO interpolation, so every\n * `${env:VAR}` is resolved to a literal at install time. The env table is a\n * plain string→string map. Honors the telemetry serve-wrapper.\n */\n private renderMcpEntry(ctx: InstallContext, server: ServerDef): CodexMcpEntry {\n // Streamable HTTP server: codex infers the transport from `url` (no explicit\n // transport key). VERIFIED against codex-cli 0.139.0 — `codex mcp add <id>\n // --url <U> --bearer-token-env-var <E>` writes:\n // [mcp_servers.<id>]\n // url = \"…\"\n // bearer_token_env_var = \"…\" (only with bearerEnv auth)\n // Telemetry serve-wrapping is stdio-only (remote cannot be intercepted).\n // installServer's guard only lets stdio+command or http+url reach here, so\n // this branch is exactly the streamable-HTTP case (lock-step with the guard).\n if (server.transport === \"http\") {\n const remote: CodexMcpEntry = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n if (server.auth?.type === \"bearerEnv\" && server.auth.bearerEnvVar) {\n remote.bearer_token_env_var = server.auth.bearerEnvVar;\n }\n if (server.headers && Object.keys(server.headers).length > 0) {\n const headers: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.headers))) {\n headers[k] = String(v);\n }\n remote.http_headers = headers;\n }\n return remote;\n }\n let command = server.command as string;\n let args = [...(server.args ?? [])];\n\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Resolve env-refs to literals (TOML cannot interpolate).\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: CodexMcpEntry = { command };\n if (args.length > 0) entry.args = args;\n\n if (server.env && Object.keys(server.env).length > 0) {\n const env: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.env))) {\n env[k] = String(v);\n }\n entry.env = env;\n }\n return entry;\n }\n\n /**\n * Does this hooks.json entry belong to this connector for `event`? EVENT-\n * SPECIFIC + path-normalized exact-command match. The engine binds this per\n * event in the uninstall (whole-entry FLAT removal) and the install idempotency\n * find reuses its command body via the descriptor's entryOwnsCommand.\n */\n private isOurEntry(ctx: InstallContext, event: CodexHookEventName, entry: CodexHookEntry): boolean {\n if (!entry || typeof entry !== \"object\" || !Array.isArray(entry.hooks)) return false;\n const ours = buildHomeBinHookCommand(ctx.homeBinPath, \"codex\", event, ctx.connector.id);\n const needle = ours.replace(/\\\\/g, \"/\");\n return entry.hooks.some((h) => (h.command ?? \"\").replace(/\\\\/g, \"/\") === needle);\n }\n}\n\nexport const adapter = new CodexAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAE9B,OAAO,UAAU;AAqGjB,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAYA,IAAM,mBAA+C,oBAAI,IAAI,CAAC,oBAAoB,CAAC;AAQnF,IAAM,uBACJ;AAaF,SAAS,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AI,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,KAAK,EAAG,QAAO;AAC/E,UAAM,OAAO,wBAAwB,IAAI,aAAa,SAAS,OAAO,IAAI,UAAU,EAAE;AACtF,UAAM,SAAS,KAAK,QAAQ,OAAO,GAAG;AACtC,WAAO,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,WAAW,IAAI,QAAQ,OAAO,GAAG,MAAM,MAAM;AAAA,EACjF;AACF;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
readYaml,
|
|
4
4
|
writeYaml
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4NSU3KWX.js";
|
|
6
6
|
import {
|
|
7
7
|
extractSessionId,
|
|
8
8
|
normalizeSessionSource,
|
|
@@ -10,17 +10,17 @@ import {
|
|
|
10
10
|
} from "./chunk-H53QZQJI.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveEnvRefsDeep
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BEFVJ2OE.js";
|
|
14
14
|
import {
|
|
15
15
|
BaseAdapter
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-VVFDU4IX.js";
|
|
17
17
|
import {
|
|
18
18
|
buildHomeBinHookCommand,
|
|
19
19
|
buildWrappedStdio,
|
|
20
20
|
isHomeBinHookCommand
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-HORHRHNG.js";
|
|
22
|
+
import "./chunk-YYNXIUR2.js";
|
|
23
|
+
import "./chunk-IXOQDZWC.js";
|
|
24
24
|
|
|
25
25
|
// src/adapters/continue/index.ts
|
|
26
26
|
import { existsSync, statSync } from "fs";
|
|
@@ -769,4 +769,4 @@ export {
|
|
|
769
769
|
adapter,
|
|
770
770
|
continue_default as default
|
|
771
771
|
};
|
|
772
|
-
//# sourceMappingURL=continue-
|
|
772
|
+
//# sourceMappingURL=continue-MNM7YVJY.js.map
|
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
} from "./chunk-H53QZQJI.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveEnvRefsDeep
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BEFVJ2OE.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseAdapter,
|
|
10
10
|
renderSkillMd,
|
|
11
11
|
renderSubagentMd
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VVFDU4IX.js";
|
|
13
13
|
import {
|
|
14
14
|
buildHomeBinHookCommand,
|
|
15
15
|
buildWrappedStdio,
|
|
16
16
|
isHomeBinHookCommand
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-HORHRHNG.js";
|
|
18
|
+
import "./chunk-YYNXIUR2.js";
|
|
19
|
+
import "./chunk-IXOQDZWC.js";
|
|
20
20
|
|
|
21
21
|
// src/adapters/copilot-cli/index.ts
|
|
22
22
|
import { existsSync } from "fs";
|
|
@@ -84,11 +84,17 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
84
84
|
permissionRequest: false,
|
|
85
85
|
postToolUseFailure: false,
|
|
86
86
|
subagentStart: false,
|
|
87
|
-
// PreToolUse is fail-closed and can rewrite tool input (
|
|
88
|
-
// PostToolUse hook cannot rewrite
|
|
87
|
+
// PreToolUse is fail-closed and can rewrite tool input (the host reads a
|
|
88
|
+
// flat top-level `modifiedArgs`); a PostToolUse hook cannot rewrite
|
|
89
|
+
// already-emitted tool output.
|
|
89
90
|
canModifyArgs: true,
|
|
90
91
|
canModifyOutput: false,
|
|
91
|
-
|
|
92
|
+
// DEMOTED to false (fail-safe): the installed CLI 1.0.63 bundle has NO
|
|
93
|
+
// additionalContext mechanism — the token appears zero times in app.js, so a
|
|
94
|
+
// context-injection reply (SessionStart/PreCompact/etc.) is a silent no-op.
|
|
95
|
+
// Claiming the capability would advertise an injection path the host never
|
|
96
|
+
// honors; re-promote once a verified bundle ships an additionalContext reader.
|
|
97
|
+
canInjectSessionContext: false,
|
|
92
98
|
// Copilot CLI's mcp-config.json `type` accepts stdio (written "local"),
|
|
93
99
|
// http (Streamable HTTP), and sse (legacy) — per GitHub's add-mcp-servers docs.
|
|
94
100
|
transports: ["stdio", "http", "sse"],
|
|
@@ -580,17 +586,17 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
580
586
|
case "PreToolUse": {
|
|
581
587
|
const ev = {
|
|
582
588
|
...base,
|
|
583
|
-
toolName: input
|
|
584
|
-
toolInput: input
|
|
589
|
+
toolName: toolNameOf(input),
|
|
590
|
+
toolInput: toolInputOf(input)
|
|
585
591
|
};
|
|
586
592
|
return ev;
|
|
587
593
|
}
|
|
588
594
|
case "PostToolUse": {
|
|
589
|
-
const toolOutput = input.tool_result?.text_result_for_llm;
|
|
595
|
+
const toolOutput = input.toolResult?.textResultForLlm ?? input.tool_result?.text_result_for_llm;
|
|
590
596
|
const ev = {
|
|
591
597
|
...base,
|
|
592
|
-
toolName: input
|
|
593
|
-
toolInput: input
|
|
598
|
+
toolName: toolNameOf(input),
|
|
599
|
+
toolInput: toolInputOf(input),
|
|
594
600
|
...typeof toolOutput === "string" ? { toolOutput } : {}
|
|
595
601
|
};
|
|
596
602
|
return ev;
|
|
@@ -644,16 +650,16 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
644
650
|
case "PermissionRequest": {
|
|
645
651
|
const ev = {
|
|
646
652
|
...base,
|
|
647
|
-
toolName: input
|
|
648
|
-
toolInput: input
|
|
653
|
+
toolName: toolNameOf(input),
|
|
654
|
+
toolInput: toolInputOf(input)
|
|
649
655
|
};
|
|
650
656
|
return ev;
|
|
651
657
|
}
|
|
652
658
|
case "PostToolUseFailure": {
|
|
653
659
|
const ev = {
|
|
654
660
|
...base,
|
|
655
|
-
toolName: input
|
|
656
|
-
toolInput: input
|
|
661
|
+
toolName: toolNameOf(input),
|
|
662
|
+
toolInput: toolInputOf(input),
|
|
657
663
|
error: typeof input.error === "string" ? input.error : ""
|
|
658
664
|
};
|
|
659
665
|
return ev;
|
|
@@ -717,6 +723,24 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
717
723
|
}
|
|
718
724
|
return { exitCode: 0 };
|
|
719
725
|
}
|
|
726
|
+
if (event === "PreToolUse") {
|
|
727
|
+
if (decision === "deny") {
|
|
728
|
+
return this.stdout({
|
|
729
|
+
permissionDecision: "deny",
|
|
730
|
+
permissionDecisionReason: response.reason ?? "Blocked by hook"
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (decision === "ask") {
|
|
734
|
+
return this.stdout({
|
|
735
|
+
permissionDecision: "ask",
|
|
736
|
+
permissionDecisionReason: response.reason ?? "Confirmation required by hook"
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
if (decision === "modify" && response.updatedInput) {
|
|
740
|
+
return this.stdout({ modifiedArgs: response.updatedInput });
|
|
741
|
+
}
|
|
742
|
+
return { exitCode: 0 };
|
|
743
|
+
}
|
|
720
744
|
if (decision === "deny") {
|
|
721
745
|
if (event === "SubagentStop") {
|
|
722
746
|
return this.stdout({
|
|
@@ -741,13 +765,6 @@ var CopilotCliAdapter = class extends BaseAdapter {
|
|
|
741
765
|
}
|
|
742
766
|
});
|
|
743
767
|
}
|
|
744
|
-
if (decision === "modify") {
|
|
745
|
-
if (event === "PreToolUse" && response.updatedInput) {
|
|
746
|
-
return this.stdout({
|
|
747
|
-
hookSpecificOutput: { hookEventName, updatedInput: response.updatedInput }
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
768
|
if (decision === "context" && response.additionalContext) {
|
|
752
769
|
return this.stdout({
|
|
753
770
|
hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext }
|
|
@@ -764,11 +781,37 @@ function extractSessionId(input) {
|
|
|
764
781
|
const m = input.transcript_path.match(/([a-f0-9-]{36})\.jsonl$/);
|
|
765
782
|
if (m && m[1]) return m[1];
|
|
766
783
|
}
|
|
784
|
+
if (typeof input.sessionId === "string" && input.sessionId !== "") {
|
|
785
|
+
return input.sessionId;
|
|
786
|
+
}
|
|
767
787
|
if (typeof input.session_id === "string" && input.session_id !== "") {
|
|
768
788
|
return input.session_id;
|
|
769
789
|
}
|
|
770
790
|
return "";
|
|
771
791
|
}
|
|
792
|
+
function toolNameOf(input) {
|
|
793
|
+
if (typeof input.toolName === "string") return input.toolName;
|
|
794
|
+
if (typeof input.tool_name === "string") return input.tool_name;
|
|
795
|
+
return "";
|
|
796
|
+
}
|
|
797
|
+
function toolInputOf(input) {
|
|
798
|
+
const raw = input.toolArgs;
|
|
799
|
+
if (typeof raw === "string") {
|
|
800
|
+
try {
|
|
801
|
+
const parsed = JSON.parse(raw);
|
|
802
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
803
|
+
return parsed;
|
|
804
|
+
}
|
|
805
|
+
} catch {
|
|
806
|
+
}
|
|
807
|
+
} else if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
808
|
+
return raw;
|
|
809
|
+
}
|
|
810
|
+
if (input.tool_input && typeof input.tool_input === "object") {
|
|
811
|
+
return input.tool_input;
|
|
812
|
+
}
|
|
813
|
+
return {};
|
|
814
|
+
}
|
|
772
815
|
var adapter = new CopilotCliAdapter();
|
|
773
816
|
var copilot_cli_default = adapter;
|
|
774
817
|
export {
|
|
@@ -776,4 +819,4 @@ export {
|
|
|
776
819
|
adapter,
|
|
777
820
|
copilot_cli_default as default
|
|
778
821
|
};
|
|
779
|
-
//# sourceMappingURL=copilot-cli-
|
|
822
|
+
//# sourceMappingURL=copilot-cli-SMTX5F65.js.map
|