@ken-jo/agent-connector 0.4.6 → 0.4.8

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.
Files changed (187) hide show
  1. package/dist/{action-EV63GAPY.js → action-RWPRIZIC.js} +10 -10
  2. package/dist/{amazon-q-COAL3764.js → amazon-q-5LJOB5L3.js} +6 -18
  3. package/dist/amazon-q-5LJOB5L3.js.map +1 -0
  4. package/dist/{amp-XJQ4TDAU.js → amp-PU4LFSY6.js} +16 -48
  5. package/dist/amp-PU4LFSY6.js.map +1 -0
  6. package/dist/{antigravity-AMKKKHS4.js → antigravity-DWW35HZO.js} +6 -5
  7. package/dist/{antigravity-cli-XERXEH5W.js → antigravity-cli-VTQ6DNWL.js} +6 -5
  8. package/dist/{antigravity-cli-XERXEH5W.js.map → antigravity-cli-VTQ6DNWL.js.map} +1 -1
  9. package/dist/{chunk-F5RX62T7.js → chunk-7QRUZAUG.js} +2 -2
  10. package/dist/{chunk-G5CQHVQG.js → chunk-7TVBFRVI.js} +12 -15
  11. package/dist/chunk-7TVBFRVI.js.map +1 -0
  12. package/dist/{chunk-QC5A3TFQ.js → chunk-A2T4Q7RM.js} +18 -18
  13. package/dist/{chunk-2X4EH2D7.js → chunk-CDVOBKSG.js} +4 -4
  14. package/dist/{chunk-RQPKL62M.js → chunk-CENEXP7K.js} +9 -38
  15. package/dist/chunk-CENEXP7K.js.map +1 -0
  16. package/dist/chunk-FBJQGRET.js +38 -0
  17. package/dist/chunk-FBJQGRET.js.map +1 -0
  18. package/dist/{chunk-WZA4CSGJ.js → chunk-H53QZQJI.js} +15 -2
  19. package/dist/chunk-H53QZQJI.js.map +1 -0
  20. package/dist/{chunk-DCK5FADX.js → chunk-HOE2MN36.js} +2 -2
  21. package/dist/{chunk-7L6ITC4T.js → chunk-IEGR4TP3.js} +22 -6
  22. package/dist/chunk-IEGR4TP3.js.map +1 -0
  23. package/dist/{chunk-CPLK7GTE.js → chunk-KG6T3YNJ.js} +353 -36
  24. package/dist/chunk-KG6T3YNJ.js.map +1 -0
  25. package/dist/{chunk-MZF2YCXX.js → chunk-MOW2RKHX.js} +2 -2
  26. package/dist/{chunk-EXLS7BSI.js → chunk-NLFPH4S2.js} +10 -2
  27. package/dist/chunk-NLFPH4S2.js.map +1 -0
  28. package/dist/{chunk-EROJDXMW.js → chunk-NYR55UT7.js} +2 -2
  29. package/dist/{chunk-SRVAA2VN.js → chunk-OZ5EXXQV.js} +2 -2
  30. package/dist/{chunk-I5MLE6S7.js → chunk-TO57WYBB.js} +15 -1
  31. package/dist/chunk-TO57WYBB.js.map +1 -0
  32. package/dist/chunk-UM5S7DKK.js +33 -0
  33. package/dist/chunk-UM5S7DKK.js.map +1 -0
  34. package/dist/{chunk-5G4EPJ4Y.js → chunk-VRKTVCYJ.js} +7 -7
  35. package/dist/{chunk-QOGMDOUX.js → chunk-WI6YSXOC.js} +3 -3
  36. package/dist/{chunk-BMD7ANKF.js → chunk-XQUUNAGC.js} +36 -36
  37. package/dist/{chunk-LQRAPXS4.js → chunk-YS2NYJ6R.js} +15 -49
  38. package/dist/chunk-YS2NYJ6R.js.map +1 -0
  39. package/dist/{chunk-H67V7DEL.js → chunk-YYISBXOM.js} +7 -7
  40. package/dist/{claude-code-T2LPFNC3.js → claude-code-64X6RR2S.js} +46 -133
  41. package/dist/claude-code-64X6RR2S.js.map +1 -0
  42. package/dist/cli/sdk.js +4 -4
  43. package/dist/cli.js +1 -1
  44. package/dist/{cline-WRYMNS7Z.js → cline-T7ZDJYZQ.js} +15 -47
  45. package/dist/cline-T7ZDJYZQ.js.map +1 -0
  46. package/dist/{codebuff-PODYPOOP.js → codebuff-PPPY3SJV.js} +9 -40
  47. package/dist/codebuff-PPPY3SJV.js.map +1 -0
  48. package/dist/{codex-O4G7D7KK.js → codex-EEVN43C2.js} +115 -172
  49. package/dist/codex-EEVN43C2.js.map +1 -0
  50. package/dist/{continue-K43SUHLQ.js → continue-VLLZO4PM.js} +12 -33
  51. package/dist/continue-VLLZO4PM.js.map +1 -0
  52. package/dist/{copilot-cli-Q3SSPT4V.js → copilot-cli-A7G5WB4N.js} +17 -64
  53. package/dist/copilot-cli-A7G5WB4N.js.map +1 -0
  54. package/dist/{crush-MBEH2R3I.js → crush-AH24GDDB.js} +17 -42
  55. package/dist/crush-AH24GDDB.js.map +1 -0
  56. package/dist/{cursor-TMBXDYR4.js → cursor-GJBSMXI6.js} +61 -183
  57. package/dist/cursor-GJBSMXI6.js.map +1 -0
  58. package/dist/{detect-AHJIUMBO.js → detect-YDCZNV4W.js} +4 -4
  59. package/dist/{doctor-G5MLCPAB.js → doctor-DGC7P3P7.js} +13 -12
  60. package/dist/{doctor-G5MLCPAB.js.map → doctor-DGC7P3P7.js.map} +1 -1
  61. package/dist/{droid-JC2NT6S4.js → droid-RBWCFKL3.js} +63 -144
  62. package/dist/droid-RBWCFKL3.js.map +1 -0
  63. package/dist/{gemini-cli-ILR7M5X3.js → gemini-cli-CFPFEJEA.js} +20 -63
  64. package/dist/gemini-cli-CFPFEJEA.js.map +1 -0
  65. package/dist/{goose-SFO5BBGW.js → goose-UBJVQFUE.js} +107 -183
  66. package/dist/goose-UBJVQFUE.js.map +1 -0
  67. package/dist/{hermes-3N7WN4WS.js → hermes-6FXGXLNL.js} +41 -83
  68. package/dist/hermes-6FXGXLNL.js.map +1 -0
  69. package/dist/{hook-76JBKTUX.js → hook-CDGSCASQ.js} +10 -10
  70. package/dist/index.js +2 -2
  71. package/dist/{install-R7252QFH.js → install-2D3UKEME.js} +13 -12
  72. package/dist/{install-R7252QFH.js.map → install-2D3UKEME.js.map} +1 -1
  73. package/dist/{jetbrains-copilot-NRZHI5PC.js → jetbrains-copilot-K26KMA3U.js} +12 -37
  74. package/dist/jetbrains-copilot-K26KMA3U.js.map +1 -0
  75. package/dist/{kilo-IX4T3OHJ.js → kilo-BKZJ26RM.js} +26 -90
  76. package/dist/kilo-BKZJ26RM.js.map +1 -0
  77. package/dist/{kilo-cli-2AYCXBQD.js → kilo-cli-6UVWCXQD.js} +17 -48
  78. package/dist/kilo-cli-6UVWCXQD.js.map +1 -0
  79. package/dist/{kimi-2YFK2GBA.js → kimi-QALYPSRR.js} +20 -31
  80. package/dist/kimi-QALYPSRR.js.map +1 -0
  81. package/dist/{kiro-YL6AWUYG.js → kiro-J5J42I5Z.js} +12 -31
  82. package/dist/kiro-J5J42I5Z.js.map +1 -0
  83. package/dist/{leaderboard-V6VWA5ZV.js → leaderboard-VZQXNWTX.js} +2 -2
  84. package/dist/{mimo-code-FTMGSKMQ.js → mimo-code-BEE622P2.js} +22 -87
  85. package/dist/mimo-code-BEE622P2.js.map +1 -0
  86. package/dist/{mux-5XZFB44C.js → mux-5HTNKK4K.js} +10 -54
  87. package/dist/mux-5HTNKK4K.js.map +1 -0
  88. package/dist/{nemoclaw-CQYXZVQN.js → nemoclaw-DNFIZFDF.js} +5 -5
  89. package/dist/{omp-2QMEY6HD.js → omp-I3UTRBNP.js} +16 -48
  90. package/dist/omp-I3UTRBNP.js.map +1 -0
  91. package/dist/{openclaw-UZC437RW.js → openclaw-QE2LMWIF.js} +5 -5
  92. package/dist/{opencode-L4BGFP25.js → opencode-ZFSUYJXI.js} +22 -88
  93. package/dist/opencode-ZFSUYJXI.js.map +1 -0
  94. package/dist/{package-DNLQTPNN.js → package-BSCCMW4E.js} +8 -8
  95. package/dist/{pi-PVVPVWKG.js → pi-H2KBBDDJ.js} +4 -4
  96. package/dist/{qwen-code-G4CXKUHR.js → qwen-code-5LE34FNE.js} +63 -152
  97. package/dist/qwen-code-5LE34FNE.js.map +1 -0
  98. package/dist/{roo-code-67TYJIQR.js → roo-code-XH4GCYIS.js} +15 -52
  99. package/dist/roo-code-XH4GCYIS.js.map +1 -0
  100. package/dist/runtime/index.js +8 -8
  101. package/dist/sdk/index.js +3 -3
  102. package/dist/sdk/test.js +5 -5
  103. package/dist/{serve-EOVWYBGZ.js → serve-MQNGPY2H.js} +10 -10
  104. package/dist/{status-VTD6XXLW.js → status-MRHVRDFY.js} +8 -7
  105. package/dist/{status-VTD6XXLW.js.map → status-MRHVRDFY.js.map} +1 -1
  106. package/dist/{statusline-3ET5YPQ5.js → statusline-IYWA75TR.js} +9 -9
  107. package/dist/{telemetry-QCTMKDBQ.js → telemetry-IONIOMLC.js} +5 -5
  108. package/dist/{trae-7CZZGOGI.js → trae-RVNRSV7X.js} +10 -39
  109. package/dist/trae-RVNRSV7X.js.map +1 -0
  110. package/dist/{uninstall-FL3SH2DT.js → uninstall-ESLSVCLE.js} +13 -12
  111. package/dist/{uninstall-FL3SH2DT.js.map → uninstall-ESLSVCLE.js.map} +1 -1
  112. package/dist/{upgrade-SLFG2FCT.js → upgrade-VICY5T64.js} +13 -12
  113. package/dist/{upgrade-SLFG2FCT.js.map → upgrade-VICY5T64.js.map} +1 -1
  114. package/dist/{usage-IRBLVUZM.js → usage-TCUWV2YZ.js} +2 -2
  115. package/dist/{usage-event-VFF77WYY.js → usage-event-CBZZP37Q.js} +9 -9
  116. package/dist/{vscode-copilot-MF2CDNMT.js → vscode-copilot-B2QBBHJW.js} +17 -65
  117. package/dist/vscode-copilot-B2QBBHJW.js.map +1 -0
  118. package/dist/{warp-VKG55TAT.js → warp-5R54ST3N.js} +7 -19
  119. package/dist/warp-5R54ST3N.js.map +1 -0
  120. package/dist/{windsurf-FU5G4SHF.js → windsurf-L32UEOLY.js} +6 -18
  121. package/dist/windsurf-L32UEOLY.js.map +1 -0
  122. package/dist/{zed-SFUHL3GS.js → zed-FDJHJZKD.js} +11 -21
  123. package/dist/zed-FDJHJZKD.js.map +1 -0
  124. package/package.json +1 -1
  125. package/dist/amazon-q-COAL3764.js.map +0 -1
  126. package/dist/amp-XJQ4TDAU.js.map +0 -1
  127. package/dist/chunk-7L6ITC4T.js.map +0 -1
  128. package/dist/chunk-CPLK7GTE.js.map +0 -1
  129. package/dist/chunk-EXLS7BSI.js.map +0 -1
  130. package/dist/chunk-G5CQHVQG.js.map +0 -1
  131. package/dist/chunk-I5MLE6S7.js.map +0 -1
  132. package/dist/chunk-LQRAPXS4.js.map +0 -1
  133. package/dist/chunk-RQPKL62M.js.map +0 -1
  134. package/dist/chunk-WZA4CSGJ.js.map +0 -1
  135. package/dist/claude-code-T2LPFNC3.js.map +0 -1
  136. package/dist/cline-WRYMNS7Z.js.map +0 -1
  137. package/dist/codebuff-PODYPOOP.js.map +0 -1
  138. package/dist/codex-O4G7D7KK.js.map +0 -1
  139. package/dist/continue-K43SUHLQ.js.map +0 -1
  140. package/dist/copilot-cli-Q3SSPT4V.js.map +0 -1
  141. package/dist/crush-MBEH2R3I.js.map +0 -1
  142. package/dist/cursor-TMBXDYR4.js.map +0 -1
  143. package/dist/droid-JC2NT6S4.js.map +0 -1
  144. package/dist/gemini-cli-ILR7M5X3.js.map +0 -1
  145. package/dist/goose-SFO5BBGW.js.map +0 -1
  146. package/dist/hermes-3N7WN4WS.js.map +0 -1
  147. package/dist/jetbrains-copilot-NRZHI5PC.js.map +0 -1
  148. package/dist/kilo-IX4T3OHJ.js.map +0 -1
  149. package/dist/kilo-cli-2AYCXBQD.js.map +0 -1
  150. package/dist/kimi-2YFK2GBA.js.map +0 -1
  151. package/dist/kiro-YL6AWUYG.js.map +0 -1
  152. package/dist/mimo-code-FTMGSKMQ.js.map +0 -1
  153. package/dist/mux-5XZFB44C.js.map +0 -1
  154. package/dist/omp-2QMEY6HD.js.map +0 -1
  155. package/dist/opencode-L4BGFP25.js.map +0 -1
  156. package/dist/qwen-code-G4CXKUHR.js.map +0 -1
  157. package/dist/roo-code-67TYJIQR.js.map +0 -1
  158. package/dist/trae-7CZZGOGI.js.map +0 -1
  159. package/dist/vscode-copilot-MF2CDNMT.js.map +0 -1
  160. package/dist/warp-VKG55TAT.js.map +0 -1
  161. package/dist/windsurf-FU5G4SHF.js.map +0 -1
  162. package/dist/zed-SFUHL3GS.js.map +0 -1
  163. /package/dist/{action-EV63GAPY.js.map → action-RWPRIZIC.js.map} +0 -0
  164. /package/dist/{antigravity-AMKKKHS4.js.map → antigravity-DWW35HZO.js.map} +0 -0
  165. /package/dist/{chunk-F5RX62T7.js.map → chunk-7QRUZAUG.js.map} +0 -0
  166. /package/dist/{chunk-QC5A3TFQ.js.map → chunk-A2T4Q7RM.js.map} +0 -0
  167. /package/dist/{chunk-2X4EH2D7.js.map → chunk-CDVOBKSG.js.map} +0 -0
  168. /package/dist/{chunk-DCK5FADX.js.map → chunk-HOE2MN36.js.map} +0 -0
  169. /package/dist/{chunk-MZF2YCXX.js.map → chunk-MOW2RKHX.js.map} +0 -0
  170. /package/dist/{chunk-EROJDXMW.js.map → chunk-NYR55UT7.js.map} +0 -0
  171. /package/dist/{chunk-SRVAA2VN.js.map → chunk-OZ5EXXQV.js.map} +0 -0
  172. /package/dist/{chunk-5G4EPJ4Y.js.map → chunk-VRKTVCYJ.js.map} +0 -0
  173. /package/dist/{chunk-QOGMDOUX.js.map → chunk-WI6YSXOC.js.map} +0 -0
  174. /package/dist/{chunk-BMD7ANKF.js.map → chunk-XQUUNAGC.js.map} +0 -0
  175. /package/dist/{chunk-H67V7DEL.js.map → chunk-YYISBXOM.js.map} +0 -0
  176. /package/dist/{detect-AHJIUMBO.js.map → detect-YDCZNV4W.js.map} +0 -0
  177. /package/dist/{hook-76JBKTUX.js.map → hook-CDGSCASQ.js.map} +0 -0
  178. /package/dist/{leaderboard-V6VWA5ZV.js.map → leaderboard-VZQXNWTX.js.map} +0 -0
  179. /package/dist/{nemoclaw-CQYXZVQN.js.map → nemoclaw-DNFIZFDF.js.map} +0 -0
  180. /package/dist/{openclaw-UZC437RW.js.map → openclaw-QE2LMWIF.js.map} +0 -0
  181. /package/dist/{package-DNLQTPNN.js.map → package-BSCCMW4E.js.map} +0 -0
  182. /package/dist/{pi-PVVPVWKG.js.map → pi-H2KBBDDJ.js.map} +0 -0
  183. /package/dist/{serve-EOVWYBGZ.js.map → serve-MQNGPY2H.js.map} +0 -0
  184. /package/dist/{statusline-3ET5YPQ5.js.map → statusline-IYWA75TR.js.map} +0 -0
  185. /package/dist/{telemetry-QCTMKDBQ.js.map → telemetry-IONIOMLC.js.map} +0 -0
  186. /package/dist/{usage-IRBLVUZM.js.map → usage-TCUWV2YZ.js.map} +0 -0
  187. /package/dist/{usage-event-VFF77WYY.js.map → usage-event-CBZZP37Q.js.map} +0 -0
@@ -1,19 +1,29 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ codexConfigHome
4
+ } from "./chunk-UM5S7DKK.js";
2
5
  import {
3
6
  writeTomlString
4
7
  } from "./chunk-OPXAP3AC.js";
8
+ import {
9
+ normalizeSessionSource
10
+ } from "./chunk-H53QZQJI.js";
5
11
  import {
6
12
  resolveEnvRefsDeep
7
13
  } from "./chunk-DBQMX75U.js";
8
14
  import {
9
- BaseAdapter
10
- } from "./chunk-CPLK7GTE.js";
11
- import "./chunk-7L6ITC4T.js";
15
+ BaseAdapter,
16
+ removeFromObjectMap,
17
+ upsertInObjectMap
18
+ } from "./chunk-KG6T3YNJ.js";
19
+ import {
20
+ renderCommandMd,
21
+ renderSkillMd
22
+ } from "./chunk-IEGR4TP3.js";
12
23
  import {
13
24
  buildHomeBinHookCommand,
14
- buildServeWrapperCommand,
15
- shouldWrapForTelemetry
16
- } from "./chunk-I5MLE6S7.js";
25
+ buildWrappedStdio
26
+ } from "./chunk-TO57WYBB.js";
17
27
  import "./chunk-N6HH7K6P.js";
18
28
  import {
19
29
  ensureDir
@@ -138,16 +148,11 @@ var CodexAdapter = class extends BaseAdapter {
138
148
  }
139
149
  ];
140
150
  }
141
- /** `$CODEX_HOME` || `~/.codex` for user scope. */
151
+ /** `$CODEX_HOME` (tilde-expanded, then resolved) || `~/.codex` for user
152
+ * scope. Shared with marketplace detection via `codexConfigHome` so the
153
+ * config writer and the install probe never target different dirs. */
142
154
  userConfigDir() {
143
- const env = process.env.CODEX_HOME;
144
- if (env && env.trim() !== "") {
145
- if (env.startsWith("~")) {
146
- return join(homedir(), env.replace(/^~[/\\]?/, ""));
147
- }
148
- return env;
149
- }
150
- return join(homedir(), ".codex");
155
+ return codexConfigHome();
151
156
  }
152
157
  // ── TOML config IO (override JSON helpers — config.toml is TOML) ─────────
153
158
  readToml(path) {
@@ -163,6 +168,17 @@ var CodexAdapter = class extends BaseAdapter {
163
168
  ensureDir(dirname(path));
164
169
  writeFileSync(path, TOML.stringify(data), "utf8");
165
170
  }
171
+ /** An ObjectMapCodec over config.toml for the core/object-map engine.
172
+ * `isPresentButUnparseable` is `() => false`: readToml fail-softs to {} and the
173
+ * server path has historically coerced/overwritten rather than warn-skip on an
174
+ * unparseable file — preserved here for byte-identical behavior. */
175
+ tomlObjectMapCodec() {
176
+ return {
177
+ parse: (path) => this.readToml(path),
178
+ serialize: (path, data, dryRun) => this.writeToml(path, data, dryRun),
179
+ isPresentButUnparseable: () => false
180
+ };
181
+ }
166
182
  // ── Install server (config.toml → [mcp_servers.<id>]) ───────────────────
167
183
  installServer(ctx) {
168
184
  const { connector, dryRun } = ctx;
@@ -184,102 +200,90 @@ var CodexAdapter = class extends BaseAdapter {
184
200
  ];
185
201
  }
186
202
  const entry = this.renderMcpEntry(ctx, server);
187
- const cfg = this.readToml(path);
188
- const bucket = this.tomlBucket(cfg, "mcp_servers");
189
- const before = JSON.stringify(bucket[connector.id]);
190
- const after = JSON.stringify(entry);
191
- let action;
192
- if (before === void 0) action = "create";
193
- else if (before === after) action = "skip";
194
- else action = "update";
195
- if (action !== "skip") {
196
- bucket[connector.id] = entry;
197
- this.writeToml(path, cfg, dryRun);
198
- }
199
- return [{ platform: this.id, action, path, detail: `mcp_servers.${connector.id}` }];
203
+ return [
204
+ upsertInObjectMap({
205
+ codec: this.tomlObjectMapCodec(),
206
+ rootKey: "mcp_servers",
207
+ policy: "coerce",
208
+ platform: this.id,
209
+ configPath: path,
210
+ entryId: connector.id,
211
+ entry,
212
+ dryRun
213
+ })
214
+ ];
200
215
  }
201
216
  uninstallServer(ctx) {
202
217
  const { connector, dryRun } = ctx;
203
218
  const path = this.getServerConfigPath(ctx);
204
- const cfg = this.readToml(path);
205
- const bucket = cfg["mcp_servers"];
206
- if (!existsSync(path) || typeof bucket !== "object" || bucket === null || !(connector.id in bucket)) {
207
- return [
208
- {
209
- platform: this.id,
210
- action: "skip",
211
- path,
212
- detail: `mcp_servers.${connector.id} absent`
213
- }
214
- ];
215
- }
216
- delete bucket[connector.id];
217
- this.writeToml(path, cfg, dryRun);
218
- return [{ platform: this.id, action: "remove", path, detail: `mcp_servers.${connector.id}` }];
219
+ return [
220
+ removeFromObjectMap({
221
+ codec: this.tomlObjectMapCodec(),
222
+ rootKey: "mcp_servers",
223
+ policy: "coerce",
224
+ platform: this.id,
225
+ configPath: path,
226
+ entryId: connector.id,
227
+ dryRun
228
+ })
229
+ ];
219
230
  }
220
231
  // ── Install hooks (hooks.json) ──────────────────────────────────────────
221
232
  installHooks(ctx) {
222
- const { dryRun } = ctx;
223
233
  const path = this.getHookConfigPath(ctx);
224
234
  const events = this.effectiveHookEvents(ctx);
225
235
  const dropped = this.warnSkipHookEvents(ctx);
226
236
  if (events.length === 0 && dropped.length === 0) {
227
237
  return [{ platform: this.id, action: "skip", path, detail: "no hooks declared" }];
228
238
  }
229
- const file = this.readHooksFile(path);
230
- const hooks = file.hooks ??= {};
231
- const changes = [];
232
- for (const event of dropped) {
233
- changes.push({
234
- platform: this.id,
235
- action: "warn",
236
- path,
237
- detail: `${event} has no Codex hook equivalent \u2014 skipped`
238
- });
239
- }
240
- for (const event of events) {
241
- const desired = this.renderHookEntry(ctx, event);
242
- const list = Array.isArray(hooks[event]) ? hooks[event] : hooks[event] = [];
243
- const idx = list.findIndex((e) => this.isOurEntry(ctx, event, e));
244
- if (idx < 0) {
245
- list.push(desired);
246
- changes.push({ platform: this.id, action: "create", path, detail: `hooks.${event}` });
247
- } else if (JSON.stringify(list[idx]) !== JSON.stringify(desired)) {
248
- list[idx] = desired;
249
- changes.push({ platform: this.id, action: "update", path, detail: `hooks.${event}` });
250
- } else {
251
- changes.push({ platform: this.id, action: "skip", path, detail: `hooks.${event}` });
252
- }
253
- }
254
- if (changes.some((c) => c.action === "create" || c.action === "update")) {
255
- this.writeJson(path, file, dryRun);
256
- }
257
- return changes;
239
+ const pending = [
240
+ ...dropped.map((event) => ({ event, matcher: "" })),
241
+ ...events.map((event) => ({ event, matcher: "" }))
242
+ ];
243
+ return this.upsertHookEntries(ctx, path, pending, this.hookDescriptor(ctx));
258
244
  }
259
245
  uninstallHooks(ctx) {
260
- const path = this.getHookConfigPath(ctx);
261
- const file = this.readJson(path);
262
- const hooks = file?.hooks;
263
- if (!file || !hooks) {
264
- return [{ platform: this.id, action: "skip", path, detail: "no hooks.json" }];
265
- }
266
- const changes = [];
267
- let mutated = false;
268
- for (const event of CODEX_HOOK_EVENTS) {
269
- const list = hooks[event];
270
- if (!Array.isArray(list)) continue;
271
- const kept = list.filter((e) => !this.isOurEntry(ctx, event, e));
272
- if (kept.length === list.length) continue;
273
- mutated = true;
274
- if (kept.length > 0) hooks[event] = kept;
275
- else delete hooks[event];
276
- changes.push({ platform: this.id, action: "remove", path, detail: `hooks.${event}` });
277
- }
278
- if (mutated) this.writeJson(path, file, ctx.dryRun);
279
- if (changes.length === 0) {
280
- return [{ platform: this.id, action: "skip", path, detail: "no agent-connector hooks present" }];
281
- }
282
- return changes;
246
+ return this.removeHookEntries(ctx, this.getHookConfigPath(ctx), this.hookDescriptor(ctx));
247
+ }
248
+ /**
249
+ * Codex hook-merge policy for the shared object-map engine. EVENT-SPECIFIC by
250
+ * construction: every observable (coerce root + bucket, the path-normalized
251
+ * per-event ownership find, the event-derived matcher with `hooks`-then-
252
+ * `matcher` key order, the BARE `hooks.<event>` skip/remove details with NO
253
+ * count, the warn wording, and the absent/no-match skips) is carried here so
254
+ * the engine reproduces the prior in-adapter loop byte-for-byte.
255
+ */
256
+ hookDescriptor(ctx) {
257
+ return {
258
+ // Codex's server path coerces a malformed root; the hook path matches it.
259
+ malformedPolicy: "coerce",
260
+ // Supported event identity; a WARN_SKIP event (PostToolUseFailure, which
261
+ // is the only thing `dropped` ever contains) → undefined → warn.
262
+ mapEvent: (e) => CODEX_HOOK_EVENTS.includes(e) ? e : void 0,
263
+ unmappedWarnDetail: (e) => `${e} has no Codex hook equivalent \u2014 skipped`,
264
+ renderEntry: (event, _matcher, command) => {
265
+ const entry = { hooks: [{ type: "command", command }] };
266
+ entry.matcher = event === "PreToolUse" || event === "PermissionRequest" ? PRE_TOOL_USE_MATCHER : "";
267
+ return entry;
268
+ },
269
+ // Idempotency find for the CANONICAL event the engine built `command` from —
270
+ // path-normalized, exact-command, the body of isOurEntry's command check.
271
+ entryOwnsCommand: (entry, command) => Array.isArray(entry.hooks) && entry.hooks.some(
272
+ (h) => (h.command ?? "").replace(/\\/g, "/") === command.replace(/\\/g, "/")
273
+ ),
274
+ // FLAT whole-entry removal, EVENT-SPECIFIC: isOurEntry rebuilds our command
275
+ // from the event key being stripped, so a SubagentStop entry is never matched
276
+ // while iterating the PreToolUse bucket.
277
+ ownsEntryForRemove: (c, event) => (entry) => this.isOurEntry(c, event, entry),
278
+ skipDetail: (e) => `hooks.${e}`,
279
+ removeDetail: (e, _n) => `hooks.${e}`,
280
+ absentDetail: "no hooks.json",
281
+ noMatchDetail: "no agent-connector hooks present",
282
+ // Uninstall scans EXACTLY codex's fixed event set (not Object.keys), so a
283
+ // home-bin command hand-placed under a foreign event key is left untouched —
284
+ // byte-identical to the prior `for (const event of CODEX_HOOK_EVENTS)` loop.
285
+ removeEventKeys: CODEX_HOOK_EVENTS
286
+ };
283
287
  }
284
288
  // ── Health checks (default doctor renders these) ────────────────────────
285
289
  getHealthChecks(ctx) {
@@ -364,7 +368,11 @@ var CodexAdapter = class extends BaseAdapter {
364
368
  return [{ platform: this.id, action: "skip", detail: "connector declares no commands" }];
365
369
  }
366
370
  return connector.commands.map(
367
- (cmd) => this.writeContentFile(this.commandPath(cmd.name), this.renderCommand(cmd), ctx.dryRun)
371
+ (cmd) => this.writeContentFile(
372
+ this.commandPath(cmd.name),
373
+ renderCommandMd(cmd, { includeToolsAndModel: false }),
374
+ ctx.dryRun
375
+ )
368
376
  );
369
377
  }
370
378
  uninstallCommands(ctx) {
@@ -379,14 +387,6 @@ var CodexAdapter = class extends BaseAdapter {
379
387
  (cmd) => this.removeContentFile(this.commandPath(cmd.name), ctx.dryRun)
380
388
  );
381
389
  }
382
- /** Render a command to md+frontmatter (description, argument-hint). */
383
- renderCommand(cmd) {
384
- const frontmatter = {};
385
- if (cmd.description !== void 0) frontmatter.description = cmd.description;
386
- if (cmd.argumentHint !== void 0) frontmatter["argument-hint"] = cmd.argumentHint;
387
- if (cmd.extra) Object.assign(frontmatter, cmd.extra);
388
- return this.renderFrontmatterMd(frontmatter, cmd.prompt);
389
- }
390
390
  // ── Skills ───────────────────────────────────────────────────────────────
391
391
  installSkills(ctx) {
392
392
  const { connector } = ctx;
@@ -399,7 +399,7 @@ var CodexAdapter = class extends BaseAdapter {
399
399
  const changes = [];
400
400
  for (const skill of connector.skills) {
401
401
  const dir = this.skillDir(ctx, skill.name);
402
- const rendered = this.renderSkill(skill);
402
+ const rendered = renderSkillMd(skill);
403
403
  changes.push(this.writeContentFile(join(dir, "SKILL.md"), rendered, ctx.dryRun));
404
404
  for (const [rel, contents] of Object.entries(skill.resources ?? {})) {
405
405
  const target = this.resolveWithin(dir, rel);
@@ -458,25 +458,6 @@ var CodexAdapter = class extends BaseAdapter {
458
458
  }
459
459
  return changes;
460
460
  }
461
- /**
462
- * Render a skill's SKILL.md: frontmatter (name, description + optional model,
463
- * allowed-tools, disable-model-invocation) + body. UNIFORM with every other
464
- * skill-supporting platform — only the parent dir differs.
465
- */
466
- renderSkill(skill) {
467
- const frontmatter = {
468
- name: skill.name,
469
- description: skill.description
470
- };
471
- if (skill.model !== void 0) frontmatter.model = skill.model;
472
- const allow = skill.tools?.allow;
473
- if (allow && allow.length > 0) frontmatter["allowed-tools"] = allow.join(", ");
474
- if (skill.disableModelInvocation !== void 0) {
475
- frontmatter["disable-model-invocation"] = skill.disableModelInvocation;
476
- }
477
- if (skill.extra) Object.assign(frontmatter, skill.extra);
478
- return this.renderFrontmatterMd(frontmatter, skill.body);
479
- }
480
461
  // ── Subagents (TOML) ─────────────────────────────────────────────────────
481
462
  installSubagents(ctx) {
482
463
  const { connector } = ctx;
@@ -540,7 +521,7 @@ var CodexAdapter = class extends BaseAdapter {
540
521
  isError: input.is_error ?? false
541
522
  };
542
523
  case "SessionStart":
543
- return { ...base, source: this.normalizeSource(input.source) };
524
+ return { ...base, source: normalizeSessionSource(input.source) };
544
525
  case "SessionEnd":
545
526
  return { ...base, reason: input.message };
546
527
  case "UserPromptSubmit":
@@ -707,11 +688,7 @@ var CodexAdapter = class extends BaseAdapter {
707
688
  }
708
689
  let command = server.command;
709
690
  let args = [...server.args ?? []];
710
- if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
711
- const wrapped = buildServeWrapperCommand(ctx.homeBinPath, ctx.connector.id, command, args, ctx.scope, this.id);
712
- command = wrapped.command;
713
- args = wrapped.args;
714
- }
691
+ ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));
715
692
  command = resolveEnvRefsDeep(command);
716
693
  args = resolveEnvRefsDeep(args);
717
694
  const entry = { command };
@@ -725,52 +702,18 @@ var CodexAdapter = class extends BaseAdapter {
725
702
  }
726
703
  return entry;
727
704
  }
728
- /** Render one hooks.json entry pointing at the stable home binary. */
729
- renderHookEntry(ctx, event) {
730
- const command = buildHomeBinHookCommand(
731
- ctx.homeBinPath,
732
- "codex",
733
- event,
734
- ctx.connector.id
735
- );
736
- const entry = { hooks: [{ type: "command", command }] };
737
- if (event === "PreToolUse" || event === "PermissionRequest") {
738
- entry.matcher = PRE_TOOL_USE_MATCHER;
739
- } else entry.matcher = "";
740
- return entry;
741
- }
742
- /** Does this hooks.json entry belong to this connector (by home-bin command)? */
705
+ /**
706
+ * Does this hooks.json entry belong to this connector for `event`? EVENT-
707
+ * SPECIFIC + path-normalized exact-command match. The engine binds this per
708
+ * event in the uninstall (whole-entry FLAT removal) and the install idempotency
709
+ * find reuses its command body via the descriptor's entryOwnsCommand.
710
+ */
743
711
  isOurEntry(ctx, event, entry) {
744
712
  if (!entry || typeof entry !== "object" || !Array.isArray(entry.hooks)) return false;
745
713
  const ours = buildHomeBinHookCommand(ctx.homeBinPath, "codex", event, ctx.connector.id);
746
714
  const needle = ours.replace(/\\/g, "/");
747
715
  return entry.hooks.some((h) => (h.command ?? "").replace(/\\/g, "/") === needle);
748
716
  }
749
- readHooksFile(path) {
750
- return this.readJson(path) ?? {};
751
- }
752
- /** Get-or-create a nested table inside a parsed TOML object. */
753
- tomlBucket(cfg, key) {
754
- const existing = cfg[key];
755
- if (existing && typeof existing === "object" && !Array.isArray(existing)) {
756
- return existing;
757
- }
758
- const fresh = {};
759
- cfg[key] = fresh;
760
- return fresh;
761
- }
762
- normalizeSource(raw) {
763
- switch (raw) {
764
- case "compact":
765
- return "compact";
766
- case "resume":
767
- return "resume";
768
- case "clear":
769
- return "clear";
770
- default:
771
- return "startup";
772
- }
773
- }
774
717
  };
775
718
  var adapter = new CodexAdapter();
776
719
  var codex_default = adapter;
@@ -779,4 +722,4 @@ export {
779
722
  adapter,
780
723
  codex_default as default
781
724
  };
782
- //# sourceMappingURL=codex-O4G7D7KK.js.map
725
+ //# sourceMappingURL=codex-EEVN43C2.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 * Known Codex limitations (upstream): PreToolUse deny works but updatedInput is\n * not yet honored (openai/codex#18491); PostToolUse updatedMCPToolOutput is\n * parsed-but-unsupported — hence canModifyArgs / canModifyOutput are 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 tool_response?: string;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n source?: string;\n prompt?: string;\n is_error?: boolean;\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 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 at install so the degradation is reported, never silent. (The\n * legacy SessionEnd / Notification silent filter predates this convention and\n * is deliberately left untouched.)\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// 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 canModifyArgs: false,\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 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 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 events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n\n if (events.length === 0 && dropped.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n // HOST-ORDERED pending: warn-skip events (mapEvent → undefined → warn) FIRST,\n // then the supported events in CODEX_HOOK_EVENTS order. Events neither\n // supported nor in WARN_SKIP_EVENTS are never enqueued → silently dropped, as\n // before. matcher is \"\" for every item; renderEntry derives the real matcher\n // from the event (PreToolUse/PermissionRequest), never from this field.\n const pending = [\n ...dropped.map((event) => ({ event: event as string, matcher: \"\" })),\n ...events.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; a WARN_SKIP event (PostToolUseFailure, which\n // is the only thing `dropped` ever contains) → undefined → warn.\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 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 toolOutput: input.tool_response,\n isError: input.is_error ?? false,\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 // Context injection: honored on SessionStart and PostToolUse (additionalContext).\n // (SubagentStop accepts only the common output fields — no additionalContext.)\n if (response.additionalContext && (event === \"SessionStart\" || event === \"PostToolUse\")) {\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 (modify, 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 /** Which canonical hook events to register for Codex, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): CodexHookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return CODEX_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Codex has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAE9B,OAAO,UAAU;AA2FjB,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAWA,IAAM,mBAA+C,oBAAI,IAAI,CAAC,oBAAoB,CAAC;AAQnF,IAAM,uBACJ;AAMK,IAAM,eAAN,cAA2B,YAAY;AAAA,EACnC,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA,I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G,CAAC,KAAK,OAAO,QAAQ,mBAAmB,OAAO,GAAG,CAAC,GAAG;AACnE,YAAI,CAAC,IAAI,OAAO,CAAC;AAAA,MACnB;AACA,YAAM,MAAM;AAAA,IACd;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,WAAW,KAAqB,OAA2B,OAAgC;AACjG,QAAI,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,24 +2,24 @@
2
2
  import {
3
3
  readYaml,
4
4
  writeYaml
5
- } from "./chunk-EXLS7BSI.js";
5
+ } from "./chunk-NLFPH4S2.js";
6
6
  import {
7
7
  extractSessionId,
8
+ normalizeSessionSource,
8
9
  toolResponseToString
9
- } from "./chunk-WZA4CSGJ.js";
10
+ } from "./chunk-H53QZQJI.js";
10
11
  import {
11
12
  resolveEnvRefsDeep
12
13
  } from "./chunk-DBQMX75U.js";
13
14
  import {
14
15
  BaseAdapter
15
- } from "./chunk-CPLK7GTE.js";
16
- import "./chunk-7L6ITC4T.js";
16
+ } from "./chunk-KG6T3YNJ.js";
17
+ import "./chunk-IEGR4TP3.js";
17
18
  import {
18
19
  buildHomeBinHookCommand,
19
- buildServeWrapperCommand,
20
- isHomeBinHookCommand,
21
- shouldWrapForTelemetry
22
- } from "./chunk-I5MLE6S7.js";
20
+ buildWrappedStdio,
21
+ isHomeBinHookCommand
22
+ } from "./chunk-TO57WYBB.js";
23
23
  import "./chunk-N6HH7K6P.js";
24
24
  import "./chunk-TRQKHP7D.js";
25
25
 
@@ -298,18 +298,7 @@ var ContinueAdapter = class extends BaseAdapter {
298
298
  if (transport === "stdio") {
299
299
  let command = server.command ?? "";
300
300
  let args = [...server.args ?? []];
301
- if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
302
- const wrapped = buildServeWrapperCommand(
303
- ctx.homeBinPath,
304
- ctx.connector.id,
305
- command,
306
- args,
307
- ctx.scope,
308
- this.id
309
- );
310
- command = wrapped.command;
311
- args = wrapped.args;
312
- }
301
+ ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));
313
302
  command = resolveEnvRefsDeep(command);
314
303
  args = resolveEnvRefsDeep(args);
315
304
  const entry = {
@@ -371,6 +360,8 @@ var ContinueAdapter = class extends BaseAdapter {
371
360
  }
372
361
  const hookPath = this.getHookConfigPath(ctx);
373
362
  const file = this.readJson(hookPath) ?? {};
363
+ const __skip = this.malformedHookRootSkip(hookPath, file.hooks);
364
+ if (__skip) return [__skip];
374
365
  const hooks = file.hooks ??= {};
375
366
  const changes = [];
376
367
  let mutated = false;
@@ -768,18 +759,6 @@ var ContinueAdapter = class extends BaseAdapter {
768
759
  return override && typeof override === "object" ? { ...base, ...override } : base;
769
760
  }
770
761
  };
771
- function normalizeSessionSource(source) {
772
- switch (source) {
773
- case "compact":
774
- return "compact";
775
- case "resume":
776
- return "resume";
777
- case "clear":
778
- return "clear";
779
- default:
780
- return "startup";
781
- }
782
- }
783
762
  var adapter = new ContinueAdapter();
784
763
  var continue_default = adapter;
785
764
  export {
@@ -787,4 +766,4 @@ export {
787
766
  adapter,
788
767
  continue_default as default
789
768
  };
790
- //# sourceMappingURL=continue-K43SUHLQ.js.map
769
+ //# sourceMappingURL=continue-VLLZO4PM.js.map