@ken-jo/agent-connector 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +6 -0
  3. package/README.md +348 -0
  4. package/dist/amp-QSFH2V7Y.js +217 -0
  5. package/dist/amp-QSFH2V7Y.js.map +1 -0
  6. package/dist/amp-TULUPXXL.js +237 -0
  7. package/dist/amp-TULUPXXL.js.map +1 -0
  8. package/dist/antigravity-CX2YLSY7.js +17 -0
  9. package/dist/antigravity-CX2YLSY7.js.map +1 -0
  10. package/dist/antigravity-STHZWMP3.js +171 -0
  11. package/dist/antigravity-STHZWMP3.js.map +1 -0
  12. package/dist/antigravity-cli-P6HADOAO.js +121 -0
  13. package/dist/antigravity-cli-P6HADOAO.js.map +1 -0
  14. package/dist/antigravity-cli-YQDFVV4U.js +86 -0
  15. package/dist/antigravity-cli-YQDFVV4U.js.map +1 -0
  16. package/dist/chunk-54EMKTTX.js +191 -0
  17. package/dist/chunk-54EMKTTX.js.map +1 -0
  18. package/dist/chunk-7L6ITC4T.js +54 -0
  19. package/dist/chunk-7L6ITC4T.js.map +1 -0
  20. package/dist/chunk-7MSDGHJW.js +316 -0
  21. package/dist/chunk-7MSDGHJW.js.map +1 -0
  22. package/dist/chunk-BCHWFTV4.js +196 -0
  23. package/dist/chunk-BCHWFTV4.js.map +1 -0
  24. package/dist/chunk-DBQMX75U.js +36 -0
  25. package/dist/chunk-DBQMX75U.js.map +1 -0
  26. package/dist/chunk-EXLS7BSI.js +29 -0
  27. package/dist/chunk-EXLS7BSI.js.map +1 -0
  28. package/dist/chunk-JNM3TPLX.js +593 -0
  29. package/dist/chunk-JNM3TPLX.js.map +1 -0
  30. package/dist/chunk-JWNT5KW7.js +197 -0
  31. package/dist/chunk-JWNT5KW7.js.map +1 -0
  32. package/dist/chunk-KHO5WNTP.js +30 -0
  33. package/dist/chunk-KHO5WNTP.js.map +1 -0
  34. package/dist/chunk-LTT56GI3.js +155 -0
  35. package/dist/chunk-LTT56GI3.js.map +1 -0
  36. package/dist/chunk-MEH7GC7R.js +111 -0
  37. package/dist/chunk-MEH7GC7R.js.map +1 -0
  38. package/dist/chunk-MQPNU2CY.js +64 -0
  39. package/dist/chunk-MQPNU2CY.js.map +1 -0
  40. package/dist/chunk-OPXAP3AC.js +12 -0
  41. package/dist/chunk-OPXAP3AC.js.map +1 -0
  42. package/dist/chunk-RK6VBLXP.js +50 -0
  43. package/dist/chunk-RK6VBLXP.js.map +1 -0
  44. package/dist/chunk-TIIP3RG2.js +420 -0
  45. package/dist/chunk-TIIP3RG2.js.map +1 -0
  46. package/dist/chunk-TRKWUNO4.js +702 -0
  47. package/dist/chunk-TRKWUNO4.js.map +1 -0
  48. package/dist/chunk-TRQKHP7D.js +93 -0
  49. package/dist/chunk-TRQKHP7D.js.map +1 -0
  50. package/dist/chunk-WCETQWWK.js +59 -0
  51. package/dist/chunk-WCETQWWK.js.map +1 -0
  52. package/dist/chunk-WV63X7IK.js +357 -0
  53. package/dist/chunk-WV63X7IK.js.map +1 -0
  54. package/dist/chunk-XD7MY6HB.js +343 -0
  55. package/dist/chunk-XD7MY6HB.js.map +1 -0
  56. package/dist/chunk-XNAM7F35.js +276 -0
  57. package/dist/chunk-XNAM7F35.js.map +1 -0
  58. package/dist/chunk-XUCWLJY5.js +238 -0
  59. package/dist/chunk-XUCWLJY5.js.map +1 -0
  60. package/dist/chunk-YNZU6PAV.js +800 -0
  61. package/dist/chunk-YNZU6PAV.js.map +1 -0
  62. package/dist/chunk-YT43MUSJ.js +146 -0
  63. package/dist/chunk-YT43MUSJ.js.map +1 -0
  64. package/dist/claude-code-HKDV7T32.js +637 -0
  65. package/dist/claude-code-HKDV7T32.js.map +1 -0
  66. package/dist/claude-code-W74MNTAC.js +652 -0
  67. package/dist/claude-code-W74MNTAC.js.map +1 -0
  68. package/dist/cli/sdk.d.ts +54 -0
  69. package/dist/cli/sdk.js +82 -0
  70. package/dist/cli/sdk.js.map +1 -0
  71. package/dist/cli.d.ts +2 -0
  72. package/dist/cli.js +15 -0
  73. package/dist/cli.js.map +1 -0
  74. package/dist/codebuff-3PMZJJHP.js +307 -0
  75. package/dist/codebuff-3PMZJJHP.js.map +1 -0
  76. package/dist/codebuff-QX57FJDN.js +220 -0
  77. package/dist/codebuff-QX57FJDN.js.map +1 -0
  78. package/dist/codex-JFQTS6LU.js +593 -0
  79. package/dist/codex-JFQTS6LU.js.map +1 -0
  80. package/dist/codex-Q3ATRRX3.js +364 -0
  81. package/dist/codex-Q3ATRRX3.js.map +1 -0
  82. package/dist/copilot-cli-MTCGHZ2T.js +622 -0
  83. package/dist/copilot-cli-MTCGHZ2T.js.map +1 -0
  84. package/dist/copilot-cli-SJGIXVSD.js +369 -0
  85. package/dist/copilot-cli-SJGIXVSD.js.map +1 -0
  86. package/dist/crush-I7PK3FGI.js +360 -0
  87. package/dist/crush-I7PK3FGI.js.map +1 -0
  88. package/dist/crush-LN5QFFR2.js +183 -0
  89. package/dist/crush-LN5QFFR2.js.map +1 -0
  90. package/dist/cursor-4TMXKJOZ.js +603 -0
  91. package/dist/cursor-4TMXKJOZ.js.map +1 -0
  92. package/dist/cursor-QZ6MTO74.js +194 -0
  93. package/dist/cursor-QZ6MTO74.js.map +1 -0
  94. package/dist/detect-WIAGVYS4.js +68 -0
  95. package/dist/detect-WIAGVYS4.js.map +1 -0
  96. package/dist/doctor-EZW2K4NI.js +372 -0
  97. package/dist/doctor-EZW2K4NI.js.map +1 -0
  98. package/dist/droid-KN6VRMMT.js +424 -0
  99. package/dist/droid-KN6VRMMT.js.map +1 -0
  100. package/dist/droid-W5WF5XEX.js +224 -0
  101. package/dist/droid-W5WF5XEX.js.map +1 -0
  102. package/dist/gemini-cli-CIRW37TU.js +369 -0
  103. package/dist/gemini-cli-CIRW37TU.js.map +1 -0
  104. package/dist/gemini-cli-Y35FFK4M.js +705 -0
  105. package/dist/gemini-cli-Y35FFK4M.js.map +1 -0
  106. package/dist/goose-A3M5GODH.js +212 -0
  107. package/dist/goose-A3M5GODH.js.map +1 -0
  108. package/dist/goose-ZTGTSUFJ.js +480 -0
  109. package/dist/goose-ZTGTSUFJ.js.map +1 -0
  110. package/dist/hermes-H2KV44GK.js +470 -0
  111. package/dist/hermes-H2KV44GK.js.map +1 -0
  112. package/dist/hermes-ZYLMOFLZ.js +196 -0
  113. package/dist/hermes-ZYLMOFLZ.js.map +1 -0
  114. package/dist/hook-YVDILAMZ.js +75 -0
  115. package/dist/hook-YVDILAMZ.js.map +1 -0
  116. package/dist/index.d.ts +22 -0
  117. package/dist/index.js +10 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/install-HQRYZOQ2.js +60 -0
  120. package/dist/install-HQRYZOQ2.js.map +1 -0
  121. package/dist/jetbrains-copilot-HWA3DMH7.js +633 -0
  122. package/dist/jetbrains-copilot-HWA3DMH7.js.map +1 -0
  123. package/dist/kilo-NSWAVP6P.js +235 -0
  124. package/dist/kilo-NSWAVP6P.js.map +1 -0
  125. package/dist/kilo-QXJRCSLT.js +384 -0
  126. package/dist/kilo-QXJRCSLT.js.map +1 -0
  127. package/dist/kilo-cli-EAQTHXUW.js +587 -0
  128. package/dist/kilo-cli-EAQTHXUW.js.map +1 -0
  129. package/dist/kilo-cli-EVBKUODA.js +160 -0
  130. package/dist/kilo-cli-EVBKUODA.js.map +1 -0
  131. package/dist/kimi-EI3UM3ZV.js +155 -0
  132. package/dist/kimi-EI3UM3ZV.js.map +1 -0
  133. package/dist/kimi-GQ7VXNYT.js +423 -0
  134. package/dist/kimi-GQ7VXNYT.js.map +1 -0
  135. package/dist/kiro-UCLSLBW2.js +217 -0
  136. package/dist/kiro-UCLSLBW2.js.map +1 -0
  137. package/dist/kiro-VQTT6LO2.js +451 -0
  138. package/dist/kiro-VQTT6LO2.js.map +1 -0
  139. package/dist/leaderboard-K6ON3SWW.js +137 -0
  140. package/dist/leaderboard-K6ON3SWW.js.map +1 -0
  141. package/dist/mux-T2TV4CIQ.js +211 -0
  142. package/dist/mux-T2TV4CIQ.js.map +1 -0
  143. package/dist/mux-ZMLVAXOO.js +96 -0
  144. package/dist/mux-ZMLVAXOO.js.map +1 -0
  145. package/dist/omp-PB4VDKS6.js +586 -0
  146. package/dist/omp-PB4VDKS6.js.map +1 -0
  147. package/dist/openclaw-ETN2M63O.js +751 -0
  148. package/dist/openclaw-ETN2M63O.js.map +1 -0
  149. package/dist/openclaw-IYA7ASL6.js +150 -0
  150. package/dist/openclaw-IYA7ASL6.js.map +1 -0
  151. package/dist/opencode-FZ33JKUZ.js +734 -0
  152. package/dist/opencode-FZ33JKUZ.js.map +1 -0
  153. package/dist/opencode-HWT3RSMN.js +216 -0
  154. package/dist/opencode-HWT3RSMN.js.map +1 -0
  155. package/dist/package-DLOVE2E4.js +1132 -0
  156. package/dist/package-DLOVE2E4.js.map +1 -0
  157. package/dist/pi-CIU2QHT4.js +208 -0
  158. package/dist/pi-CIU2QHT4.js.map +1 -0
  159. package/dist/pi-UFX2OYFV.js +139 -0
  160. package/dist/pi-UFX2OYFV.js.map +1 -0
  161. package/dist/qwen-code-5POCNU6P.js +573 -0
  162. package/dist/qwen-code-5POCNU6P.js.map +1 -0
  163. package/dist/qwen-code-W7NUCDEN.js +134 -0
  164. package/dist/qwen-code-W7NUCDEN.js.map +1 -0
  165. package/dist/roo-code-IOIUXRDE.js +242 -0
  166. package/dist/roo-code-IOIUXRDE.js.map +1 -0
  167. package/dist/roo-code-ZLKH4A7N.js +229 -0
  168. package/dist/roo-code-ZLKH4A7N.js.map +1 -0
  169. package/dist/runtime/index.d.ts +157 -0
  170. package/dist/runtime/index.js +20 -0
  171. package/dist/runtime/index.js.map +1 -0
  172. package/dist/serve-HVWWY4B6.js +65 -0
  173. package/dist/serve-HVWWY4B6.js.map +1 -0
  174. package/dist/status-FE7TECZD.js +128 -0
  175. package/dist/status-FE7TECZD.js.map +1 -0
  176. package/dist/synthetic-UKR6SMGS.js +178 -0
  177. package/dist/synthetic-UKR6SMGS.js.map +1 -0
  178. package/dist/telemetry-36GESKQQ.js +349 -0
  179. package/dist/telemetry-36GESKQQ.js.map +1 -0
  180. package/dist/trae-JSNDZFKL.js +204 -0
  181. package/dist/trae-JSNDZFKL.js.map +1 -0
  182. package/dist/trae-PA26DPBW.js +157 -0
  183. package/dist/trae-PA26DPBW.js.map +1 -0
  184. package/dist/types-CYUB1OTr.d.ts +427 -0
  185. package/dist/uninstall-IGCKNOSF.js +72 -0
  186. package/dist/uninstall-IGCKNOSF.js.map +1 -0
  187. package/dist/upgrade-JV2VK242.js +104 -0
  188. package/dist/upgrade-JV2VK242.js.map +1 -0
  189. package/dist/usage-6ER6EMEY.js +324 -0
  190. package/dist/usage-6ER6EMEY.js.map +1 -0
  191. package/dist/usage-event-JKBI6XCF.js +48 -0
  192. package/dist/usage-event-JKBI6XCF.js.map +1 -0
  193. package/dist/vscode-copilot-CK3NO54M.js +715 -0
  194. package/dist/vscode-copilot-CK3NO54M.js.map +1 -0
  195. package/dist/warp-JNQA7PBU.js +126 -0
  196. package/dist/warp-JNQA7PBU.js.map +1 -0
  197. package/dist/warp-QNVDXOG4.js +199 -0
  198. package/dist/warp-QNVDXOG4.js.map +1 -0
  199. package/dist/zed-NNNX5MNT.js +272 -0
  200. package/dist/zed-NNNX5MNT.js.map +1 -0
  201. package/dist/zed-VRJKWYUR.js +209 -0
  202. package/dist/zed-VRJKWYUR.js.map +1 -0
  203. package/package.json +79 -0
@@ -0,0 +1,586 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveEnvRefsDeep
4
+ } from "./chunk-DBQMX75U.js";
5
+ import {
6
+ BaseAdapter
7
+ } from "./chunk-TIIP3RG2.js";
8
+ import "./chunk-7L6ITC4T.js";
9
+ import {
10
+ buildServeWrapperCommand,
11
+ shouldWrapForTelemetry
12
+ } from "./chunk-MEH7GC7R.js";
13
+ import "./chunk-TRQKHP7D.js";
14
+
15
+ // src/adapters/omp/index.ts
16
+ import {
17
+ chmodSync,
18
+ existsSync,
19
+ mkdirSync,
20
+ readFileSync,
21
+ rmSync,
22
+ writeFileSync
23
+ } from "fs";
24
+ import { homedir } from "os";
25
+ import { dirname, join } from "path";
26
+ var HOST = "omp";
27
+ var MCP_ROOT_KEY = "mcpServers";
28
+ var EVENT_TO_OMP = {
29
+ PreToolUse: "tool_call",
30
+ PostToolUse: "tool_result",
31
+ SessionStart: "session_start",
32
+ PreCompact: "session_before_compact"
33
+ };
34
+ var OMPAdapter = class extends BaseAdapter {
35
+ id = HOST;
36
+ name = "Oh My Pi (OMP)";
37
+ paradigm = "ts-plugin";
38
+ capabilities = {
39
+ preToolUse: true,
40
+ postToolUse: true,
41
+ // session_before_compact is wired as an observe-only PreCompact surface.
42
+ preCompact: true,
43
+ sessionStart: true,
44
+ sessionEnd: false,
45
+ userPromptSubmit: false,
46
+ stop: false,
47
+ notification: false,
48
+ // OMP tool_call gates via { block, reason } only — it does not hand the
49
+ // handler a mutable args object, so input rewrite is unsupported.
50
+ canModifyArgs: false,
51
+ // No tool_result output-rewrite surface upstream.
52
+ canModifyOutput: false,
53
+ // No session_start context-injection surface upstream.
54
+ canInjectSessionContext: false,
55
+ // OMP registers stdio and remote (http) MCP servers.
56
+ transports: ["stdio", "http"]
57
+ };
58
+ // ── Native paths ───────────────────────────────────────────────────────
59
+ /**
60
+ * Resolve the OMP agent dir, honoring the PI_CODING_AGENT_DIR override (the
61
+ * only OMP runtime dir env), else ~/.omp/agent. This is the user-scope root.
62
+ */
63
+ agentDir() {
64
+ const override = process.env.PI_CODING_AGENT_DIR;
65
+ return override && override !== "" ? override : join(homedir(), ".omp", "agent");
66
+ }
67
+ getConfigDir(ctx) {
68
+ return ctx.scope === "project" ? join(ctx.projectDir, ".omp") : this.agentDir();
69
+ }
70
+ /** Native MCP file: <agentDir>/mcp.json (user) or <projectDir>/.omp/mcp.json. */
71
+ getServerConfigPath(ctx) {
72
+ return join(this.getConfigDir(ctx), "mcp.json");
73
+ }
74
+ /**
75
+ * For this ts-plugin host the "hook config path" is the generated extension
76
+ * entrypoint module (index.js). OMP loads the extension package by reading its
77
+ * package.json manifest, so the package.json is written alongside (see
78
+ * synthesizePlugin); this returns the entry module the manifest points at.
79
+ */
80
+ getHookConfigPath(ctx) {
81
+ return join(this.extensionDir(ctx), "index.js");
82
+ }
83
+ /** Extension package directory OMP loads the plugin from, per scope. */
84
+ extensionDir(ctx) {
85
+ const base = ctx.scope === "project" ? join(ctx.projectDir, ".omp") : this.agentDir();
86
+ return join(base, "extensions", ctx.connector.id);
87
+ }
88
+ // ── Detection ──────────────────────────────────────────────────────────
89
+ detectInstalled(projectDir) {
90
+ const userAgentDir = this.agentDir();
91
+ const userConfig = join(userAgentDir, "mcp.json");
92
+ const projectConfig = join(projectDir, ".omp", "mcp.json");
93
+ const userInstalled = existsSync(userAgentDir) || existsSync(userConfig);
94
+ const projInstalled = existsSync(join(projectDir, ".omp")) || existsSync(projectConfig);
95
+ const installed = userInstalled || projInstalled;
96
+ const scope = projInstalled && !userInstalled ? "project" : "user";
97
+ const configPath = scope === "project" ? projectConfig : userConfig;
98
+ return {
99
+ id: this.id,
100
+ name: this.name,
101
+ installed,
102
+ paradigm: this.paradigm,
103
+ capabilities: this.capabilities,
104
+ configPath,
105
+ scope,
106
+ reason: installed ? scope === "project" ? `found project OMP dir at ${join(projectDir, ".omp")}` : `found OMP agent dir at ${userAgentDir}` : `no OMP agent dir at ${userAgentDir}`,
107
+ confidence: installed ? "high" : "low"
108
+ };
109
+ }
110
+ // ── MCP server install / uninstall (native mcp.json) ────────────────────
111
+ installServer(ctx) {
112
+ const server = this.effectiveServer(ctx);
113
+ const serverPath = this.getServerConfigPath(ctx);
114
+ if (!server) {
115
+ return [
116
+ {
117
+ platform: this.id,
118
+ action: "skip",
119
+ path: serverPath,
120
+ detail: ctx.connector.server ? "server registration disabled for omp" : "connector declares no MCP server"
121
+ }
122
+ ];
123
+ }
124
+ const entry = this.renderServerEntry(ctx, server);
125
+ return [
126
+ this.upsertServerInJson(
127
+ serverPath,
128
+ MCP_ROOT_KEY,
129
+ ctx.connector.id,
130
+ entry,
131
+ ctx.dryRun
132
+ )
133
+ ];
134
+ }
135
+ uninstallServer(ctx) {
136
+ const serverPath = this.getServerConfigPath(ctx);
137
+ return [
138
+ this.removeServerFromJson(
139
+ serverPath,
140
+ MCP_ROOT_KEY,
141
+ ctx.connector.id,
142
+ ctx.dryRun
143
+ )
144
+ ];
145
+ }
146
+ /** Resolve the per-platform server override into an effective ServerDef. */
147
+ effectiveServer(ctx) {
148
+ const override = ctx.connector.platforms[HOST]?.server;
149
+ if (override === false) return void 0;
150
+ const base = ctx.connector.server;
151
+ if (!base) return void 0;
152
+ return override && typeof override === "object" ? { ...base, ...override } : base;
153
+ }
154
+ /**
155
+ * Render a normalized ServerDef into OMP's native "mcpServers" entry.
156
+ *
157
+ * stdio → { command, args, env } (portable field names)
158
+ * remote → { url, headers? }
159
+ *
160
+ * Telemetry wrapping routes the real command through
161
+ * `<homeBin> serve --connector <id> -- <command> <args...>`. OMP has no native
162
+ * env interpolation token, so every ${env:VAR} ref resolves to a literal.
163
+ */
164
+ renderServerEntry(ctx, server) {
165
+ const transport = server.transport;
166
+ if (transport === "stdio") {
167
+ let command = server.command ?? "";
168
+ let args = [...server.args ?? []];
169
+ if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
170
+ const wrapped = buildServeWrapperCommand(
171
+ ctx.homeBinPath,
172
+ ctx.connector.id,
173
+ command,
174
+ args,
175
+ ctx.scope,
176
+ this.id
177
+ );
178
+ command = wrapped.command;
179
+ args = wrapped.args;
180
+ }
181
+ const entry2 = {
182
+ command: resolveEnvRefsDeep(command)
183
+ };
184
+ const resolvedArgs = resolveEnvRefsDeep(args).filter((s) => s !== "");
185
+ if (resolvedArgs.length > 0) entry2.args = resolvedArgs;
186
+ const env = this.renderEnv(server.env);
187
+ if (env) entry2.env = env;
188
+ return entry2;
189
+ }
190
+ const entry = {
191
+ url: resolveEnvRefsDeep(server.url ?? "")
192
+ };
193
+ const headers = this.renderEnv(server.headers);
194
+ if (headers) entry.headers = headers;
195
+ return entry;
196
+ }
197
+ /** Resolve every ${env:VAR} ref to a literal (OMP has no native token). */
198
+ renderEnv(env) {
199
+ if (!env || Object.keys(env).length === 0) return void 0;
200
+ return resolveEnvRefsDeep({ ...env });
201
+ }
202
+ // ── Hook install / uninstall (ts-plugin extension package) ──────────────
203
+ installHooks(ctx) {
204
+ const entryPath = this.getHookConfigPath(ctx);
205
+ if (ctx.connector.platforms[HOST]?.hooks === false) {
206
+ return [
207
+ {
208
+ platform: this.id,
209
+ action: "skip",
210
+ path: entryPath,
211
+ detail: "hooks disabled for omp"
212
+ }
213
+ ];
214
+ }
215
+ if (ctx.connector.hookEvents.length === 0) {
216
+ return [
217
+ {
218
+ platform: this.id,
219
+ action: "skip",
220
+ path: entryPath,
221
+ detail: "connector declares no hooks"
222
+ }
223
+ ];
224
+ }
225
+ const files = this.synthesizePlugin(ctx);
226
+ const changes = [];
227
+ for (const file of files) {
228
+ const before = existsSync(file.path) ? this.safeRead(file.path) : void 0;
229
+ let action;
230
+ if (before === void 0) action = "create";
231
+ else if (before === file.contents) action = "skip";
232
+ else action = "update";
233
+ if (action !== "skip" && !ctx.dryRun) {
234
+ ensureDir(dirname(file.path));
235
+ writeFileSync(file.path, file.contents, "utf8");
236
+ chmodSync(file.path, file.executable ? 493 : 420);
237
+ }
238
+ changes.push({
239
+ platform: this.id,
240
+ action,
241
+ path: file.path,
242
+ detail: file.path.endsWith("package.json") ? "omp extension manifest" : `omp plugin module (${this.hookDetail(ctx)})`
243
+ });
244
+ }
245
+ return changes;
246
+ }
247
+ /**
248
+ * Human-facing summary of which declared events the synthesized module ACTUALLY
249
+ * wires. Only events present in EVENT_TO_OMP are mapped/wired; any declared
250
+ * event with no OMP mapping (e.g. UserPromptSubmit) is reported separately as
251
+ * "unsupported here" so the detail never overstates coverage.
252
+ */
253
+ hookDetail(ctx) {
254
+ const declared = ctx.connector.hookEvents;
255
+ const mapped = declared.filter((e) => EVENT_TO_OMP[e] !== void 0);
256
+ const unsupported = declared.filter((e) => EVENT_TO_OMP[e] === void 0);
257
+ const base = mapped.join(",");
258
+ return unsupported.length > 0 ? `${base}; unsupported here: ${unsupported.join(",")}` : base;
259
+ }
260
+ uninstallHooks(ctx) {
261
+ const entryPath = this.getHookConfigPath(ctx);
262
+ const manifestPath = join(this.extensionDir(ctx), "package.json");
263
+ const present = [entryPath, manifestPath].filter((p) => existsSync(p));
264
+ if (present.length === 0) {
265
+ return [
266
+ {
267
+ platform: this.id,
268
+ action: "skip",
269
+ path: entryPath,
270
+ detail: "no omp extension present"
271
+ }
272
+ ];
273
+ }
274
+ const changes = [];
275
+ for (const p of present) {
276
+ if (!ctx.dryRun) rmSync(p, { force: true });
277
+ changes.push({
278
+ platform: this.id,
279
+ action: "remove",
280
+ path: p,
281
+ detail: p.endsWith("package.json") ? "omp extension manifest" : "omp plugin module"
282
+ });
283
+ }
284
+ return changes;
285
+ }
286
+ // ── ts-plugin synthesis ────────────────────────────────────────────────
287
+ /**
288
+ * Build the OMP extension package: TWO files.
289
+ *
290
+ * 1. package.json — the manifest OMP's loader reads. It carries the `omp`
291
+ * field (`pluginPkg.omp || pluginPkg.pi`) whose `extensions` array points
292
+ * at the entry module, plus `type:"module"` and `main:"index.js"`.
293
+ * 2. index.js — a self-contained ESM plugin that imports nothing from
294
+ * agent-connector. Its default export is the OMP HookFactory `(pi)=>void`;
295
+ * each declared event registers a `pi.on(...)` handler that bridges to the
296
+ * home binary via execFileSync (fail-open) and applies the normalized
297
+ * response.
298
+ */
299
+ synthesizePlugin(ctx) {
300
+ const dir = this.extensionDir(ctx);
301
+ return [
302
+ {
303
+ path: join(dir, "package.json"),
304
+ contents: this.buildManifest(ctx),
305
+ executable: false
306
+ },
307
+ {
308
+ path: join(dir, "index.js"),
309
+ contents: this.buildPluginSource(ctx),
310
+ executable: false
311
+ }
312
+ ];
313
+ }
314
+ /** The extension package.json manifest OMP's plugin loader reads. */
315
+ buildManifest(ctx) {
316
+ const manifest = {
317
+ name: ctx.connector.id,
318
+ version: ctx.connector.version || "0.0.0",
319
+ description: `${ctx.connector.displayName} OMP extension (generated by agent-connector)`,
320
+ type: "module",
321
+ main: "index.js",
322
+ // pluginPkg.omp || pluginPkg.pi → manifest. extensions points at the entry.
323
+ omp: {
324
+ extensions: ["./index.js"]
325
+ }
326
+ };
327
+ return `${JSON.stringify(manifest, null, 2)}
328
+ `;
329
+ }
330
+ /** Compose the generated plugin source with plain string concatenation. */
331
+ buildPluginSource(ctx) {
332
+ const homeBin = JSON.stringify(ctx.homeBinPath);
333
+ const connectorId = JSON.stringify(ctx.connector.id);
334
+ const events = ctx.connector.hookEvents.filter(
335
+ (e) => EVENT_TO_OMP[e] !== void 0
336
+ );
337
+ const has = (e) => events.includes(e);
338
+ const header = `/**
339
+ * AUTO-GENERATED by agent-connector \u2014 DO NOT EDIT.
340
+ *
341
+ * Self-contained Oh My Pi (OMP) plugin extension for connector ${ctx.connector.id}.
342
+ * It imports nothing from agent-connector: every hook invocation shells out to
343
+ * the stable home binary's universal entrypoint and JSON-parses the normalized
344
+ * response. Fail-open: any bridge error degrades to a no-op (never wedges OMP).
345
+ *
346
+ * OMP loads this module via the sibling package.json "omp" manifest field; the
347
+ * default export is the HookFactory (pi) => void called once at load time.
348
+ */
349
+ import { execFileSync, execSync } from "node:child_process";
350
+
351
+ const HOME_BIN = ${homeBin};
352
+ const CONNECTOR_ID = ${connectorId};
353
+
354
+ /**
355
+ * Invoke the universal hook entrypoint for one event.
356
+ * @param {string} event canonical event name
357
+ * @param {object} payload OMP-shaped payload posted on stdin
358
+ * @returns {object|null} normalized HookResponse, or null on any failure
359
+ */
360
+ function bridge(event, payload) {
361
+ try {
362
+ // On Windows HOME_BIN is the agent-connector.cmd launcher: Node cannot
363
+ // execFile a batch file, and shell+args is deprecated (DEP0190), so run one
364
+ // quoted command line via a shell. POSIX keeps the direct execFile (no shell).
365
+ const args = ["hook", "omp", event, "--connector", CONNECTOR_ID];
366
+ const opts = { input: JSON.stringify(payload), encoding: "utf8" };
367
+ const stdout =
368
+ process.platform === "win32"
369
+ ? execSync([HOME_BIN, ...args].map((a) => '"' + a + '"').join(" "), opts)
370
+ : execFileSync(HOME_BIN, args, opts);
371
+ const text = (stdout || "").trim();
372
+ if (text === "") return { decision: "allow" };
373
+ return JSON.parse(text);
374
+ } catch {
375
+ // Fail-open \u2014 never break an OMP tool call / lifecycle event.
376
+ return null;
377
+ }
378
+ }
379
+
380
+ // OMP exposes the project dir via PI_PROJECT_DIR (PI_*-prefixed only); fall
381
+ // through to cwd. The plugin process is long-lived, so resolve once at load.
382
+ const PROJECT_DIR = process.env.PI_PROJECT_DIR || process.cwd();
383
+
384
+ // Derive a stable session id from OMP's session manager when available
385
+ // (ctx.sessionManager.getSessionFile()), else a wall-clock token. The id is
386
+ // rebound on each session_start so multi-session reuse stays attributed.
387
+ let SESSION_ID = "";
388
+ function deriveSessionId(ctx) {
389
+ try {
390
+ const f = ctx && ctx.sessionManager && typeof ctx.sessionManager.getSessionFile === "function"
391
+ ? ctx.sessionManager.getSessionFile()
392
+ : "";
393
+ if (f && typeof f === "string") return f;
394
+ } catch {
395
+ // best effort
396
+ }
397
+ return "omp-" + Date.now();
398
+ }
399
+ `;
400
+ const handlers = [];
401
+ if (has("SessionStart")) {
402
+ handlers.push(` // SessionStart \u2192 rebind the session id and notify the connector.
403
+ pi.on("session_start", (_event, ctx) => {
404
+ SESSION_ID = deriveSessionId(ctx);
405
+ bridge("SessionStart", { sessionId: SESSION_ID, projectDir: PROJECT_DIR });
406
+ return undefined;
407
+ });`);
408
+ }
409
+ if (has("PreToolUse")) {
410
+ handlers.push(` // PreToolUse \u2192 block via { block, reason }. OMP tool_call cannot mutate
411
+ // args, so "ask" degrades to a block (the safe direction); "modify" degrades
412
+ // to ALLOW (no-block), matching opencode/claude-code \u2014 only deny/ask block.
413
+ pi.on("tool_call", (event) => {
414
+ const payload = {
415
+ toolName: (event && event.toolName) || "",
416
+ toolInput: (event && event.input) || {},
417
+ sessionId: SESSION_ID,
418
+ projectDir: PROJECT_DIR,
419
+ };
420
+ const res = bridge("PreToolUse", payload);
421
+ if (!res) return undefined;
422
+ if (res.decision === "deny" || res.decision === "ask") {
423
+ return { block: true, reason: res.reason || "Blocked by ${ctx.connector.id}" };
424
+ }
425
+ return undefined;
426
+ });`);
427
+ }
428
+ if (has("PostToolUse")) {
429
+ handlers.push(` // PostToolUse \u2192 observe tool results (no output-rewrite surface upstream).
430
+ pi.on("tool_result", (event) => {
431
+ const content = (event && Array.isArray(event.content)) ? event.content : [];
432
+ const toolOutput = content
433
+ .filter((c) => c && c.type === "text" && typeof c.text === "string")
434
+ .map((c) => c.text)
435
+ .join("\\n");
436
+ const payload = {
437
+ toolName: (event && event.toolName) || "",
438
+ toolInput: (event && event.input) || {},
439
+ toolOutput,
440
+ isError: !!(event && event.isError),
441
+ sessionId: SESSION_ID,
442
+ projectDir: PROJECT_DIR,
443
+ };
444
+ bridge("PostToolUse", payload);
445
+ return undefined;
446
+ });`);
447
+ }
448
+ if (has("PreCompact")) {
449
+ handlers.push(` // PreCompact \u2192 notify before OMP compacts the context window.
450
+ pi.on("session_before_compact", () => {
451
+ bridge("PreCompact", { sessionId: SESSION_ID, projectDir: PROJECT_DIR });
452
+ return undefined;
453
+ });`);
454
+ }
455
+ const factory = `
456
+ export default function plugin(pi) {
457
+ ${handlers.join("\n\n")}
458
+ }
459
+ `;
460
+ return header + factory;
461
+ }
462
+ // ── Runtime: parse OUR bridge payload → normalized event ───────────────
463
+ /**
464
+ * `raw` is the payload OUR generated plugin posts (NOT a host-native shape):
465
+ * { toolName?, toolInput?, toolOutput?, isError?, sessionId?, projectDir? }
466
+ * so this maps straight through.
467
+ */
468
+ parseEvent(event, raw) {
469
+ const input = raw ?? {};
470
+ const base = {
471
+ hostPlatform: HOST,
472
+ connectorId: "",
473
+ sessionId: typeof input.sessionId === "string" ? input.sessionId : "",
474
+ raw,
475
+ ...typeof input.projectDir === "string" ? { projectDir: input.projectDir } : {}
476
+ };
477
+ switch (event) {
478
+ case "PreToolUse": {
479
+ const ev = {
480
+ ...base,
481
+ toolName: input.toolName ?? "",
482
+ toolInput: input.toolInput ?? {}
483
+ };
484
+ return ev;
485
+ }
486
+ case "PostToolUse": {
487
+ const ev = {
488
+ ...base,
489
+ toolName: input.toolName ?? "",
490
+ toolInput: input.toolInput ?? {},
491
+ ...typeof input.toolOutput === "string" ? { toolOutput: input.toolOutput } : {},
492
+ ...typeof input.isError === "boolean" ? { isError: input.isError } : {}
493
+ };
494
+ return ev;
495
+ }
496
+ case "PreCompact": {
497
+ const ev = { ...base };
498
+ return ev;
499
+ }
500
+ case "SessionStart": {
501
+ const ev = { ...base, source: "startup" };
502
+ return ev;
503
+ }
504
+ default:
505
+ return { ...base, source: "startup" };
506
+ }
507
+ }
508
+ // ── Runtime: normalized response → reply the generated bridge parses ───
509
+ /**
510
+ * Unlike json-stdio hosts (whose reply is the host's NATIVE control payload),
511
+ * OUR generated bridge consumes this stdout directly. So the reply body is the
512
+ * NORMALIZED HookResponse itself — the bridge JSON.parses it and maps decision
513
+ * → OMP's { block, reason } for tool_call (and ignores it otherwise).
514
+ */
515
+ formatReply(_event, response) {
516
+ return {
517
+ exitCode: 0,
518
+ stdout: JSON.stringify(response ?? { decision: "allow" })
519
+ };
520
+ }
521
+ // ── Diagnostics ────────────────────────────────────────────────────────
522
+ getHealthChecks(ctx) {
523
+ const serverPath = this.getServerConfigPath(ctx);
524
+ const entryPath = this.getHookConfigPath(ctx);
525
+ const manifestPath = join(this.extensionDir(ctx), "package.json");
526
+ const connectorId = ctx.connector.id;
527
+ const hasHooks = ctx.connector.hookEvents.length > 0;
528
+ return [
529
+ {
530
+ name: `${this.name}: mcp.json present`,
531
+ check: () => existsSync(serverPath) ? { status: "OK", detail: serverPath } : { status: "FAIL", detail: `not found: ${serverPath}` }
532
+ },
533
+ {
534
+ name: `${this.name}: ${MCP_ROOT_KEY}.${connectorId} registered`,
535
+ check: () => {
536
+ if (!ctx.connector.server) {
537
+ return { status: "OK", detail: "no MCP server declared" };
538
+ }
539
+ const cfg = this.readJson(
540
+ serverPath
541
+ );
542
+ const bucket = cfg?.[MCP_ROOT_KEY];
543
+ if (!cfg || !bucket) {
544
+ return {
545
+ status: "FAIL",
546
+ detail: `no ${MCP_ROOT_KEY} in ${serverPath}`
547
+ };
548
+ }
549
+ return connectorId in bucket ? { status: "OK", detail: `${MCP_ROOT_KEY}.${connectorId} present` } : {
550
+ status: "FAIL",
551
+ detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${serverPath}`
552
+ };
553
+ }
554
+ },
555
+ {
556
+ name: `${this.name}: extension package present`,
557
+ check: () => {
558
+ if (!hasHooks) return { status: "OK", detail: "no hooks declared" };
559
+ if (!existsSync(manifestPath)) {
560
+ return { status: "FAIL", detail: `not found: ${manifestPath}` };
561
+ }
562
+ return existsSync(entryPath) ? { status: "OK", detail: entryPath } : { status: "FAIL", detail: `not found: ${entryPath}` };
563
+ }
564
+ }
565
+ ];
566
+ }
567
+ /** Read a file, returning undefined on any error (idempotency compare). */
568
+ safeRead(path) {
569
+ try {
570
+ return readFileSync(path, "utf8");
571
+ } catch {
572
+ return void 0;
573
+ }
574
+ }
575
+ };
576
+ function ensureDir(dir) {
577
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
578
+ }
579
+ var adapter = new OMPAdapter();
580
+ var omp_default = adapter;
581
+ export {
582
+ OMPAdapter,
583
+ adapter,
584
+ omp_default as default
585
+ };
586
+ //# sourceMappingURL=omp-PB4VDKS6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/omp/index.ts"],"sourcesContent":["/**\n * adapters/omp — Oh My Pi (OMP) platform adapter for agent-connector.\n *\n * OMP is a ts-plugin host with NATIVE MCP. The two surfaces are split:\n *\n * • MCP (native, real file) — OMP reads a real `mcp.json`:\n * user scope → <agentDir>/mcp.json (agentDir = ~/.omp/agent)\n * project scope → <projectDir>/.omp/mcp.json\n * JSON, root key \"mcpServers\", stdio entry { command, args, env } — the\n * portable field names. Verified against can1357/oh-my-pi\n * (packages/utils/src/dirs.ts getMCPConfigPath + docs/mcp-config.md). OMP\n * documents no native ${env:VAR} token, so env refs resolve to literals at\n * install time (resolveEnvRefsDeep).\n *\n * • Hooks (ts-plugin, in-process) — OMP loads EXTENSION PACKAGES. Its plugin\n * loader reads a package whose package.json carries an `omp` (or `pi`)\n * manifest field; the manifest's `extensions` array points at the plugin\n * module, whose DEFAULT export is a HookFactory `(pi) => void` that calls\n * `pi.on(event, handler)` (upstream loader.ts:75\n * `pluginPkg.omp || pluginPkg.pi`; hook factory types.ts:809). context-mode\n * proved this by dropping an extension under\n * `<agentDir>/extensions/<name>/{package.json,index.js}` whose index.js\n * default-exports the OMP plugin factory (src/setup.ts applyPlatformInstall\n * \"omp\"; src/adapters/omp/plugin.ts).\n *\n * Why we SYNTHESIZE instead of importing context-mode's plugin:\n * context-mode could load its own plugin module in-process because the handler\n * code shipped with the package. agent-connector cannot — the connector's hook\n * handlers are arbitrary developer code we must not import into OMP's runtime\n * (wrong cwd, wrong deps, version skew, the cache-heal bug class). So, exactly\n * like the OpenCode adapter, we generate a tiny self-contained ESM extension\n * that imports NOTHING from agent-connector: each `pi.on(...)` handler shells\n * out to the ONE stable home binary's universal entrypoint\n * (`<homeBin> hook omp <event> --connector <id>`) over child_process, feeds it\n * the OMP-shaped payload as JSON on stdin, and JSON.parses the normalized\n * HookResponse back from stdout. Fail-open: any bridge error → no-op. One\n * entrypoint, every paradigm.\n *\n * Event mapping (only events the connector declares are subscribed):\n * PreToolUse → pi.on(\"tool_call\", …) block via { block:true, reason }\n * (OMP tool_call cannot mutate args → canModifyArgs:false)\n * PostToolUse → pi.on(\"tool_result\", …) observe-only (no output rewrite hook)\n * SessionStart → pi.on(\"session_start\", …) (no context-injection surface)\n * PreCompact → pi.on(\"session_before_compact\", …) observe-only\n *\n * Distinct storage root from Pi: OMP lives under ~/.omp (NOT ~/.pi); the\n * PI_CODING_AGENT_DIR env var (the only OMP runtime dir override — OMP mirrors\n * any .env `OMP_*` keys to `PI_*` before process.env is read) takes precedence.\n */\n\nimport {\n chmodSync,\n existsSync,\n mkdirSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type {\n Adapter,\n GeneratedPluginFile,\n HookReply,\n InstallContext,\n NormalizedEvent,\n} from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreCompactEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildServeWrapperCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"omp\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * Canonical → OMP event name map. A connector hook event is only subscribed by\n * the generated plugin when it appears here AND is declared by the connector.\n * Names verified against the proven context-mode OMP plugin (pi.on targets).\n */\nconst EVENT_TO_OMP: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"tool_call\",\n PostToolUse: \"tool_result\",\n SessionStart: \"session_start\",\n PreCompact: \"session_before_compact\",\n};\n\n/** Raw payload the generated plugin posts to the universal hook entrypoint. */\ninterface OmpBridgePayload {\n toolName?: string;\n toolInput?: Record<string, unknown>;\n toolOutput?: string;\n isError?: boolean;\n sessionId?: string;\n projectDir?: string;\n}\n\n/** Native MCP server entry shapes OMP accepts under \"mcpServers\". */\ninterface OmpStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface OmpRemoteServer {\n url: string;\n headers?: Record<string, string>;\n}\n\nexport class OMPAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Oh My Pi (OMP)\";\n readonly paradigm: HookParadigm = \"ts-plugin\";\n\n readonly capabilities: PlatformCapabilities = {\n preToolUse: true,\n postToolUse: true,\n // session_before_compact is wired as an observe-only PreCompact surface.\n preCompact: true,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n // OMP tool_call gates via { block, reason } only — it does not hand the\n // handler a mutable args object, so input rewrite is unsupported.\n canModifyArgs: false,\n // No tool_result output-rewrite surface upstream.\n canModifyOutput: false,\n // No session_start context-injection surface upstream.\n canInjectSessionContext: false,\n // OMP registers stdio and remote (http) MCP servers.\n transports: [\"stdio\", \"http\"],\n };\n\n // ── Native paths ───────────────────────────────────────────────────────\n\n /**\n * Resolve the OMP agent dir, honoring the PI_CODING_AGENT_DIR override (the\n * only OMP runtime dir env), else ~/.omp/agent. This is the user-scope root.\n */\n private agentDir(): string {\n const override = process.env.PI_CODING_AGENT_DIR;\n return override && override !== \"\"\n ? override\n : join(homedir(), \".omp\", \"agent\");\n }\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".omp\")\n : this.agentDir();\n }\n\n /** Native MCP file: <agentDir>/mcp.json (user) or <projectDir>/.omp/mcp.json. */\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * For this ts-plugin host the \"hook config path\" is the generated extension\n * entrypoint module (index.js). OMP loads the extension package by reading its\n * package.json manifest, so the package.json is written alongside (see\n * synthesizePlugin); this returns the entry module the manifest points at.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.extensionDir(ctx), \"index.js\");\n }\n\n /** Extension package directory OMP loads the plugin from, per scope. */\n private extensionDir(ctx: InstallContext): string {\n const base =\n ctx.scope === \"project\"\n ? join(ctx.projectDir, \".omp\")\n : this.agentDir();\n return join(base, \"extensions\", ctx.connector.id);\n }\n\n // ── Detection ──────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userAgentDir = this.agentDir();\n const userConfig = join(userAgentDir, \"mcp.json\");\n const projectConfig = join(projectDir, \".omp\", \"mcp.json\");\n\n const userInstalled = existsSync(userAgentDir) || existsSync(userConfig);\n const projInstalled =\n existsSync(join(projectDir, \".omp\")) || existsSync(projectConfig);\n const installed = userInstalled || projInstalled;\n\n // Report the marker that actually matched.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectConfig : userConfig;\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 ? scope === \"project\"\n ? `found project OMP dir at ${join(projectDir, \".omp\")}`\n : `found OMP agent dir at ${userAgentDir}`\n : `no OMP agent dir at ${userAgentDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── MCP server install / uninstall (native mcp.json) ────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const server = this.effectiveServer(ctx);\n const serverPath = this.getServerConfigPath(ctx);\n\n if (!server) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: serverPath,\n detail: ctx.connector.server\n ? \"server registration disabled for omp\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n const entry = this.renderServerEntry(ctx, server);\n return [\n this.upsertServerInJson(\n serverPath,\n MCP_ROOT_KEY,\n ctx.connector.id,\n entry,\n ctx.dryRun,\n ),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(\n serverPath,\n MCP_ROOT_KEY,\n ctx.connector.id,\n ctx.dryRun,\n ),\n ];\n }\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[HOST]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override && typeof override === \"object\"\n ? { ...base, ...override }\n : base;\n }\n\n /**\n * Render a normalized ServerDef into OMP's native \"mcpServers\" entry.\n *\n * stdio → { command, args, env } (portable field names)\n * remote → { url, headers? }\n *\n * Telemetry wrapping routes the real command through\n * `<homeBin> serve --connector <id> -- <command> <args...>`. OMP has no native\n * env interpolation token, so every ${env:VAR} ref resolves to a literal.\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): OmpStdioServer | OmpRemoteServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n const entry: OmpStdioServer = {\n command: resolveEnvRefsDeep(command),\n };\n const resolvedArgs = resolveEnvRefsDeep(args).filter((s) => s !== \"\");\n if (resolvedArgs.length > 0) entry.args = resolvedArgs;\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // remote (http / sse / ws) — OMP registers a URL.\n const entry: OmpRemoteServer = {\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /** Resolve every ${env:VAR} ref to a literal (OMP has no native token). */\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 resolveEnvRefsDeep({ ...env });\n }\n\n // ── Hook install / uninstall (ts-plugin extension package) ──────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const entryPath = this.getHookConfigPath(ctx);\n\n if (ctx.connector.platforms[HOST]?.hooks === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: entryPath,\n detail: \"hooks disabled for omp\",\n },\n ];\n }\n if (ctx.connector.hookEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: entryPath,\n detail: \"connector declares no hooks\",\n },\n ];\n }\n\n const files = this.synthesizePlugin(ctx);\n const changes: ChangeRecord[] = [];\n\n for (const file of files) {\n const before = existsSync(file.path)\n ? this.safeRead(file.path)\n : undefined;\n let action: ChangeRecord[\"action\"];\n if (before === undefined) action = \"create\";\n else if (before === file.contents) action = \"skip\";\n else action = \"update\";\n\n if (action !== \"skip\" && !ctx.dryRun) {\n ensureDir(dirname(file.path));\n writeFileSync(file.path, file.contents, \"utf8\");\n chmodSync(file.path, file.executable ? 0o755 : 0o644);\n }\n\n changes.push({\n platform: this.id,\n action,\n path: file.path,\n detail: file.path.endsWith(\"package.json\")\n ? \"omp extension manifest\"\n : `omp plugin module (${this.hookDetail(ctx)})`,\n });\n }\n\n return changes;\n }\n\n /**\n * Human-facing summary of which declared events the synthesized module ACTUALLY\n * wires. Only events present in EVENT_TO_OMP are mapped/wired; any declared\n * event with no OMP mapping (e.g. UserPromptSubmit) is reported separately as\n * \"unsupported here\" so the detail never overstates coverage.\n */\n private hookDetail(ctx: InstallContext): string {\n const declared = ctx.connector.hookEvents;\n const mapped = declared.filter((e) => EVENT_TO_OMP[e] !== undefined);\n const unsupported = declared.filter((e) => EVENT_TO_OMP[e] === undefined);\n const base = mapped.join(\",\");\n return unsupported.length > 0\n ? `${base}; unsupported here: ${unsupported.join(\",\")}`\n : base;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const entryPath = this.getHookConfigPath(ctx);\n const manifestPath = join(this.extensionDir(ctx), \"package.json\");\n const present = [entryPath, manifestPath].filter((p) => existsSync(p));\n\n if (present.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: entryPath,\n detail: \"no omp extension present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n for (const p of present) {\n if (!ctx.dryRun) rmSync(p, { force: true });\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: p,\n detail: p.endsWith(\"package.json\")\n ? \"omp extension manifest\"\n : \"omp plugin module\",\n });\n }\n return changes;\n }\n\n // ── ts-plugin synthesis ────────────────────────────────────────────────\n\n /**\n * Build the OMP extension package: TWO files.\n *\n * 1. package.json — the manifest OMP's loader reads. It carries the `omp`\n * field (`pluginPkg.omp || pluginPkg.pi`) whose `extensions` array points\n * at the entry module, plus `type:\"module\"` and `main:\"index.js\"`.\n * 2. index.js — a self-contained ESM plugin that imports nothing from\n * agent-connector. Its default export is the OMP HookFactory `(pi)=>void`;\n * each declared event registers a `pi.on(...)` handler that bridges to the\n * home binary via execFileSync (fail-open) and applies the normalized\n * response.\n */\n synthesizePlugin(ctx: InstallContext): GeneratedPluginFile[] {\n const dir = this.extensionDir(ctx);\n return [\n {\n path: join(dir, \"package.json\"),\n contents: this.buildManifest(ctx),\n executable: false,\n },\n {\n path: join(dir, \"index.js\"),\n contents: this.buildPluginSource(ctx),\n executable: false,\n },\n ];\n }\n\n /** The extension package.json manifest OMP's plugin loader reads. */\n private buildManifest(ctx: InstallContext): string {\n const manifest = {\n name: ctx.connector.id,\n version: ctx.connector.version || \"0.0.0\",\n description: `${ctx.connector.displayName} OMP extension (generated by agent-connector)`,\n type: \"module\",\n main: \"index.js\",\n // pluginPkg.omp || pluginPkg.pi → manifest. extensions points at the entry.\n omp: {\n extensions: [\"./index.js\"],\n },\n };\n return `${JSON.stringify(manifest, null, 2)}\\n`;\n }\n\n /** Compose the generated plugin source with plain string concatenation. */\n private buildPluginSource(ctx: InstallContext): string {\n const homeBin = JSON.stringify(ctx.homeBinPath);\n const connectorId = JSON.stringify(ctx.connector.id);\n\n const events = ctx.connector.hookEvents.filter(\n (e): e is HookEventName => EVENT_TO_OMP[e] !== undefined,\n );\n const has = (e: HookEventName) => events.includes(e);\n\n const header = `/**\n * AUTO-GENERATED by agent-connector — DO NOT EDIT.\n *\n * Self-contained Oh My Pi (OMP) plugin extension for connector ${ctx.connector.id}.\n * It imports nothing from agent-connector: every hook invocation shells out to\n * the stable home binary's universal entrypoint and JSON-parses the normalized\n * response. Fail-open: any bridge error degrades to a no-op (never wedges OMP).\n *\n * OMP loads this module via the sibling package.json \"omp\" manifest field; the\n * default export is the HookFactory (pi) => void called once at load time.\n */\nimport { execFileSync, execSync } from \"node:child_process\";\n\nconst HOME_BIN = ${homeBin};\nconst CONNECTOR_ID = ${connectorId};\n\n/**\n * Invoke the universal hook entrypoint for one event.\n * @param {string} event canonical event name\n * @param {object} payload OMP-shaped payload posted on stdin\n * @returns {object|null} normalized HookResponse, or null on any failure\n */\nfunction bridge(event, payload) {\n try {\n // On Windows HOME_BIN is the agent-connector.cmd launcher: Node cannot\n // execFile a batch file, and shell+args is deprecated (DEP0190), so run one\n // quoted command line via a shell. POSIX keeps the direct execFile (no shell).\n const args = [\"hook\", \"omp\", event, \"--connector\", CONNECTOR_ID];\n const opts = { input: JSON.stringify(payload), encoding: \"utf8\" };\n const stdout =\n process.platform === \"win32\"\n ? execSync([HOME_BIN, ...args].map((a) => '\"' + a + '\"').join(\" \"), opts)\n : execFileSync(HOME_BIN, args, opts);\n const text = (stdout || \"\").trim();\n if (text === \"\") return { decision: \"allow\" };\n return JSON.parse(text);\n } catch {\n // Fail-open — never break an OMP tool call / lifecycle event.\n return null;\n }\n}\n\n// OMP exposes the project dir via PI_PROJECT_DIR (PI_*-prefixed only); fall\n// through to cwd. The plugin process is long-lived, so resolve once at load.\nconst PROJECT_DIR = process.env.PI_PROJECT_DIR || process.cwd();\n\n// Derive a stable session id from OMP's session manager when available\n// (ctx.sessionManager.getSessionFile()), else a wall-clock token. The id is\n// rebound on each session_start so multi-session reuse stays attributed.\nlet SESSION_ID = \"\";\nfunction deriveSessionId(ctx) {\n try {\n const f = ctx && ctx.sessionManager && typeof ctx.sessionManager.getSessionFile === \"function\"\n ? ctx.sessionManager.getSessionFile()\n : \"\";\n if (f && typeof f === \"string\") return f;\n } catch {\n // best effort\n }\n return \"omp-\" + Date.now();\n}\n`;\n\n const handlers: string[] = [];\n\n if (has(\"SessionStart\")) {\n handlers.push(` // SessionStart → rebind the session id and notify the connector.\n pi.on(\"session_start\", (_event, ctx) => {\n SESSION_ID = deriveSessionId(ctx);\n bridge(\"SessionStart\", { sessionId: SESSION_ID, projectDir: PROJECT_DIR });\n return undefined;\n });`);\n }\n\n if (has(\"PreToolUse\")) {\n handlers.push(` // PreToolUse → block via { block, reason }. OMP tool_call cannot mutate\n // args, so \"ask\" degrades to a block (the safe direction); \"modify\" degrades\n // to ALLOW (no-block), matching opencode/claude-code — only deny/ask block.\n pi.on(\"tool_call\", (event) => {\n const payload = {\n toolName: (event && event.toolName) || \"\",\n toolInput: (event && event.input) || {},\n sessionId: SESSION_ID,\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"PreToolUse\", payload);\n if (!res) return undefined;\n if (res.decision === \"deny\" || res.decision === \"ask\") {\n return { block: true, reason: res.reason || \"Blocked by ${ctx.connector.id}\" };\n }\n return undefined;\n });`);\n }\n\n if (has(\"PostToolUse\")) {\n handlers.push(` // PostToolUse → observe tool results (no output-rewrite surface upstream).\n pi.on(\"tool_result\", (event) => {\n const content = (event && Array.isArray(event.content)) ? event.content : [];\n const toolOutput = content\n .filter((c) => c && c.type === \"text\" && typeof c.text === \"string\")\n .map((c) => c.text)\n .join(\"\\\\n\");\n const payload = {\n toolName: (event && event.toolName) || \"\",\n toolInput: (event && event.input) || {},\n toolOutput,\n isError: !!(event && event.isError),\n sessionId: SESSION_ID,\n projectDir: PROJECT_DIR,\n };\n bridge(\"PostToolUse\", payload);\n return undefined;\n });`);\n }\n\n if (has(\"PreCompact\")) {\n handlers.push(` // PreCompact → notify before OMP compacts the context window.\n pi.on(\"session_before_compact\", () => {\n bridge(\"PreCompact\", { sessionId: SESSION_ID, projectDir: PROJECT_DIR });\n return undefined;\n });`);\n }\n\n const factory = `\nexport default function plugin(pi) {\n${handlers.join(\"\\n\\n\")}\n}\n`;\n\n return header + factory;\n }\n\n // ── Runtime: parse OUR bridge payload → normalized event ───────────────\n\n /**\n * `raw` is the payload OUR generated plugin posts (NOT a host-native shape):\n * { toolName?, toolInput?, toolOutput?, isError?, sessionId?, projectDir? }\n * so this maps straight through.\n */\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as OmpBridgePayload;\n const base = {\n hostPlatform: HOST,\n connectorId: \"\",\n sessionId: typeof input.sessionId === \"string\" ? input.sessionId : \"\",\n raw,\n ...(typeof input.projectDir === \"string\"\n ? { projectDir: input.projectDir }\n : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n ...(typeof input.toolOutput === \"string\"\n ? { toolOutput: input.toolOutput }\n : {}),\n ...(typeof input.isError === \"boolean\"\n ? { isError: input.isError }\n : {}),\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = { ...base };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = { ...base, source: \"startup\" };\n return ev;\n }\n default:\n // Other canonical events are not surfaced by OMP; treat as a\n // session-start-shaped no-op so the dispatcher fails open gracefully.\n return { ...base, source: \"startup\" } satisfies SessionStartEvent;\n }\n }\n\n // ── Runtime: normalized response → reply the generated bridge parses ───\n\n /**\n * Unlike json-stdio hosts (whose reply is the host's NATIVE control payload),\n * OUR generated bridge consumes this stdout directly. So the reply body is the\n * NORMALIZED HookResponse itself — the bridge JSON.parses it and maps decision\n * → OMP's { block, reason } for tool_call (and ignores it otherwise).\n */\n formatReply(_event: HookEventName, response: HookResponse): HookReply {\n return {\n exitCode: 0,\n stdout: JSON.stringify(response ?? { decision: \"allow\" }),\n };\n }\n\n // ── Diagnostics ────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const serverPath = this.getServerConfigPath(ctx);\n const entryPath = this.getHookConfigPath(ctx);\n const manifestPath = join(this.extensionDir(ctx), \"package.json\");\n const connectorId = ctx.connector.id;\n const hasHooks = ctx.connector.hookEvents.length > 0;\n\n return [\n {\n name: `${this.name}: mcp.json present`,\n check: () =>\n existsSync(serverPath)\n ? { status: \"OK\", detail: serverPath }\n : { status: \"FAIL\", detail: `not found: ${serverPath}` },\n },\n {\n name: `${this.name}: ${MCP_ROOT_KEY}.${connectorId} registered`,\n check: () => {\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> }>(\n serverPath,\n );\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return {\n status: \"FAIL\",\n detail: `no ${MCP_ROOT_KEY} in ${serverPath}`,\n };\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 ${serverPath}`,\n };\n },\n },\n {\n name: `${this.name}: extension package present`,\n check: () => {\n if (!hasHooks) return { status: \"OK\", detail: \"no hooks declared\" };\n if (!existsSync(manifestPath)) {\n return { status: \"FAIL\", detail: `not found: ${manifestPath}` };\n }\n return existsSync(entryPath)\n ? { status: \"OK\", detail: entryPath }\n : { status: \"FAIL\", detail: `not found: ${entryPath}` };\n },\n },\n ];\n }\n\n /** Read a file, returning undefined on any error (idempotency compare). */\n private safeRead(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n }\n}\n\n/** Create a directory (recursive) if it does not already exist. */\nfunction ensureDir(dir: string): void {\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n}\n\nexport const adapter = new OMPAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;AAkDA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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