@ken-jo/agent-connector 0.3.1 → 0.4.1

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 (189) hide show
  1. package/README.md +180 -16
  2. package/dist/action-WT7GVRCC.js +55 -0
  3. package/dist/action-WT7GVRCC.js.map +1 -0
  4. package/dist/amazon-q-COAL3764.js +276 -0
  5. package/dist/amazon-q-COAL3764.js.map +1 -0
  6. package/dist/{amp-YGV66GJT.js → amp-4U33CU7E.js} +81 -5
  7. package/dist/amp-4U33CU7E.js.map +1 -0
  8. package/dist/{antigravity-7IBYFO6P.js → antigravity-AMKKKHS4.js} +4 -4
  9. package/dist/{antigravity-cli-JEOUP2VN.js → antigravity-cli-XERXEH5W.js} +4 -4
  10. package/dist/{chunk-3JCRUROU.js → chunk-24IDL5RW.js} +13 -4
  11. package/dist/chunk-24IDL5RW.js.map +1 -0
  12. package/dist/chunk-2AVLX7GH.js +351 -0
  13. package/dist/chunk-2AVLX7GH.js.map +1 -0
  14. package/dist/{chunk-GSGDG2BV.js → chunk-4ENJK5S2.js} +106 -176
  15. package/dist/chunk-4ENJK5S2.js.map +1 -0
  16. package/dist/{chunk-ZAM4M7LI.js → chunk-5OWS5CMA.js} +136 -296
  17. package/dist/chunk-5OWS5CMA.js.map +1 -0
  18. package/dist/{chunk-PD4VFEBY.js → chunk-CPLK7GTE.js} +79 -5
  19. package/dist/chunk-CPLK7GTE.js.map +1 -0
  20. package/dist/chunk-DCKFYWGM.js +237 -0
  21. package/dist/chunk-DCKFYWGM.js.map +1 -0
  22. package/dist/chunk-EGCBZ2DC.js +83 -0
  23. package/dist/chunk-EGCBZ2DC.js.map +1 -0
  24. package/dist/chunk-F5RX62T7.js +21 -0
  25. package/dist/chunk-F5RX62T7.js.map +1 -0
  26. package/dist/chunk-FAHIMJRU.js +177 -0
  27. package/dist/chunk-FAHIMJRU.js.map +1 -0
  28. package/dist/{chunk-MEH7GC7R.js → chunk-I5MLE6S7.js} +33 -3
  29. package/dist/chunk-I5MLE6S7.js.map +1 -0
  30. package/dist/{chunk-KVAAFYRR.js → chunk-KHO5WNTP.js} +2 -18
  31. package/dist/chunk-KHO5WNTP.js.map +1 -0
  32. package/dist/{chunk-KQSNDFBN.js → chunk-LQRAPXS4.js} +3 -3
  33. package/dist/{chunk-3RBLIHPZ.js → chunk-O5TWCIJN.js} +27 -17
  34. package/dist/chunk-O5TWCIJN.js.map +1 -0
  35. package/dist/{chunk-WNREHWKL.js → chunk-QREL7LZJ.js} +5 -4
  36. package/dist/chunk-QREL7LZJ.js.map +1 -0
  37. package/dist/{chunk-KMAKDD3Z.js → chunk-RIMVWCZY.js} +37 -12
  38. package/dist/chunk-RIMVWCZY.js.map +1 -0
  39. package/dist/{openclaw-UZ5BMCGQ.js → chunk-URHQMFB3.js} +210 -41
  40. package/dist/chunk-URHQMFB3.js.map +1 -0
  41. package/dist/chunk-WZA4CSGJ.js +28 -0
  42. package/dist/chunk-WZA4CSGJ.js.map +1 -0
  43. package/dist/chunk-XJ4S47CT.js +44 -0
  44. package/dist/chunk-XJ4S47CT.js.map +1 -0
  45. package/dist/{claude-code-4275HQU4.js → claude-code-W4PUFZL5.js} +194 -52
  46. package/dist/claude-code-W4PUFZL5.js.map +1 -0
  47. package/dist/cli/sdk.js +5 -3
  48. package/dist/cli/sdk.js.map +1 -1
  49. package/dist/cli.js +1 -1
  50. package/dist/cline-WRYMNS7Z.js +442 -0
  51. package/dist/cline-WRYMNS7Z.js.map +1 -0
  52. package/dist/{codebuff-LE3KBZGM.js → codebuff-DH5Y7GAT.js} +106 -5
  53. package/dist/codebuff-DH5Y7GAT.js.map +1 -0
  54. package/dist/{codex-4BY2ZJIW.js → codex-DDHIV767.js} +43 -11
  55. package/dist/codex-DDHIV767.js.map +1 -0
  56. package/dist/continue-K43SUHLQ.js +790 -0
  57. package/dist/continue-K43SUHLQ.js.map +1 -0
  58. package/dist/{copilot-cli-IPISKO3V.js → copilot-cli-Q3SSPT4V.js} +70 -12
  59. package/dist/copilot-cli-Q3SSPT4V.js.map +1 -0
  60. package/dist/{crush-X3E25EQG.js → crush-MBEH2R3I.js} +130 -6
  61. package/dist/crush-MBEH2R3I.js.map +1 -0
  62. package/dist/{cursor-UH3W622V.js → cursor-TMBXDYR4.js} +119 -16
  63. package/dist/cursor-TMBXDYR4.js.map +1 -0
  64. package/dist/{detect-U3E7NVNW.js → detect-KG5FG3EV.js} +5 -3
  65. package/dist/{detect-U3E7NVNW.js.map → detect-KG5FG3EV.js.map} +1 -1
  66. package/dist/{doctor-DZTWED4O.js → doctor-FLZF34Y3.js} +226 -96
  67. package/dist/doctor-FLZF34Y3.js.map +1 -0
  68. package/dist/{droid-T5VBRXZF.js → droid-JC2NT6S4.js} +298 -10
  69. package/dist/droid-JC2NT6S4.js.map +1 -0
  70. package/dist/{gemini-cli-ZSUK55UA.js → gemini-cli-ILR7M5X3.js} +62 -10
  71. package/dist/gemini-cli-ILR7M5X3.js.map +1 -0
  72. package/dist/{goose-M3RR3CZG.js → goose-SFO5BBGW.js} +112 -10
  73. package/dist/goose-SFO5BBGW.js.map +1 -0
  74. package/dist/{hermes-CUNKIAR5.js → hermes-3N7WN4WS.js} +329 -15
  75. package/dist/hermes-3N7WN4WS.js.map +1 -0
  76. package/dist/{hook-EVY7LOUQ.js → hook-XR3Z45FB.js} +16 -10
  77. package/dist/hook-XR3Z45FB.js.map +1 -0
  78. package/dist/index.d.ts +71 -3
  79. package/dist/index.js +23 -3
  80. package/dist/{install-OWAS5UIE.js → install-BSR62UHJ.js} +12 -9
  81. package/dist/{install-OWAS5UIE.js.map → install-BSR62UHJ.js.map} +1 -1
  82. package/dist/introspect-Nw8hTReX.d.ts +53 -0
  83. package/dist/{jetbrains-copilot-C3HDGGML.js → jetbrains-copilot-NRZHI5PC.js} +85 -18
  84. package/dist/jetbrains-copilot-NRZHI5PC.js.map +1 -0
  85. package/dist/{kilo-PKAJCWPX.js → kilo-5NWOXVSD.js} +16 -16
  86. package/dist/kilo-5NWOXVSD.js.map +1 -0
  87. package/dist/{kilo-cli-QWUVXG2O.js → kilo-cli-UZ7R5UOP.js} +3 -3
  88. package/dist/{kimi-EVD7YKXS.js → kimi-2YFK2GBA.js} +87 -25
  89. package/dist/kimi-2YFK2GBA.js.map +1 -0
  90. package/dist/{kiro-UQRY6EIO.js → kiro-YL6AWUYG.js} +3 -3
  91. package/dist/{leaderboard-CSWHI4UY.js → leaderboard-MJG24O35.js} +2 -2
  92. package/dist/mimo-code-FTMGSKMQ.js +790 -0
  93. package/dist/mimo-code-FTMGSKMQ.js.map +1 -0
  94. package/dist/{mux-5CI5FP2W.js → mux-5XZFB44C.js} +156 -6
  95. package/dist/mux-5XZFB44C.js.map +1 -0
  96. package/dist/nemoclaw-W5KEJ3WX.js +58 -0
  97. package/dist/nemoclaw-W5KEJ3WX.js.map +1 -0
  98. package/dist/{omp-AXA7XY22.js → omp-2QMEY6HD.js} +138 -18
  99. package/dist/omp-2QMEY6HD.js.map +1 -0
  100. package/dist/openclaw-EXJEFNZI.js +18 -0
  101. package/dist/openclaw-EXJEFNZI.js.map +1 -0
  102. package/dist/{opencode-NZBRLJN3.js → opencode-WNXYJR4X.js} +84 -27
  103. package/dist/opencode-WNXYJR4X.js.map +1 -0
  104. package/dist/{package-WFOS4QVU.js → package-ACZXJHWB.js} +8 -6
  105. package/dist/{package-WFOS4QVU.js.map → package-ACZXJHWB.js.map} +1 -1
  106. package/dist/{pi-WMTUX6ES.js → pi-PVVPVWKG.js} +3 -2
  107. package/dist/{pi-WMTUX6ES.js.map → pi-PVVPVWKG.js.map} +1 -1
  108. package/dist/{qwen-code-MRRIUQ3P.js → qwen-code-G4CXKUHR.js} +426 -10
  109. package/dist/qwen-code-G4CXKUHR.js.map +1 -0
  110. package/dist/{roo-code-NI5UU6JB.js → roo-code-67TYJIQR.js} +137 -4
  111. package/dist/roo-code-67TYJIQR.js.map +1 -0
  112. package/dist/runtime/index.d.ts +96 -2
  113. package/dist/runtime/index.js +19 -10
  114. package/dist/sdk/index.d.ts +52 -0
  115. package/dist/sdk/index.js +82 -0
  116. package/dist/sdk/index.js.map +1 -0
  117. package/dist/sdk/test.d.ts +74 -0
  118. package/dist/sdk/test.js +292 -0
  119. package/dist/sdk/test.js.map +1 -0
  120. package/dist/{serve-3C2VFPAY.js → serve-GER7URPR.js} +13 -9
  121. package/dist/{serve-3C2VFPAY.js.map → serve-GER7URPR.js.map} +1 -1
  122. package/dist/{status-MKQYX5MW.js → status-LAJE3BM5.js} +10 -7
  123. package/dist/{status-MKQYX5MW.js.map → status-LAJE3BM5.js.map} +1 -1
  124. package/dist/statusline-L376ZPZU.js +60 -0
  125. package/dist/statusline-L376ZPZU.js.map +1 -0
  126. package/dist/{telemetry-3DN6XGYB.js → telemetry-B3DX3PWU.js} +6 -4
  127. package/dist/{telemetry-3DN6XGYB.js.map → telemetry-B3DX3PWU.js.map} +1 -1
  128. package/dist/{trae-CQC72RHH.js → trae-7CZZGOGI.js} +99 -5
  129. package/dist/trae-7CZZGOGI.js.map +1 -0
  130. package/dist/{types-CNigfEuR.d.ts → types-CRVrFWeU.d.ts} +322 -18
  131. package/dist/{uninstall-WG6PFWF3.js → uninstall-ZYTW7YMZ.js} +12 -9
  132. package/dist/{uninstall-WG6PFWF3.js.map → uninstall-ZYTW7YMZ.js.map} +1 -1
  133. package/dist/{upgrade-32NC2RKI.js → upgrade-4LUEEOZW.js} +12 -9
  134. package/dist/{upgrade-32NC2RKI.js.map → upgrade-4LUEEOZW.js.map} +1 -1
  135. package/dist/{usage-CJOM2WQM.js → usage-ZFBVQF3H.js} +2 -2
  136. package/dist/{usage-event-472X3DOY.js → usage-event-GZ32AGEB.js} +12 -8
  137. package/dist/{usage-event-472X3DOY.js.map → usage-event-GZ32AGEB.js.map} +1 -1
  138. package/dist/{vscode-copilot-4RVRTCKV.js → vscode-copilot-MF2CDNMT.js} +23 -10
  139. package/dist/vscode-copilot-MF2CDNMT.js.map +1 -0
  140. package/dist/{warp-X6MB67NT.js → warp-VKG55TAT.js} +55 -4
  141. package/dist/warp-VKG55TAT.js.map +1 -0
  142. package/dist/windsurf-FU5G4SHF.js +443 -0
  143. package/dist/windsurf-FU5G4SHF.js.map +1 -0
  144. package/dist/{zed-NTCYW4V2.js → zed-SFUHL3GS.js} +3 -3
  145. package/package.json +10 -2
  146. package/dist/amp-YGV66GJT.js.map +0 -1
  147. package/dist/chunk-3JCRUROU.js.map +0 -1
  148. package/dist/chunk-3RBLIHPZ.js.map +0 -1
  149. package/dist/chunk-GSGDG2BV.js.map +0 -1
  150. package/dist/chunk-KMAKDD3Z.js.map +0 -1
  151. package/dist/chunk-KVAAFYRR.js.map +0 -1
  152. package/dist/chunk-MEH7GC7R.js.map +0 -1
  153. package/dist/chunk-NJU275US.js +0 -238
  154. package/dist/chunk-NJU275US.js.map +0 -1
  155. package/dist/chunk-PD4VFEBY.js.map +0 -1
  156. package/dist/chunk-WNREHWKL.js.map +0 -1
  157. package/dist/chunk-ZAM4M7LI.js.map +0 -1
  158. package/dist/claude-code-4275HQU4.js.map +0 -1
  159. package/dist/codebuff-LE3KBZGM.js.map +0 -1
  160. package/dist/codex-4BY2ZJIW.js.map +0 -1
  161. package/dist/copilot-cli-IPISKO3V.js.map +0 -1
  162. package/dist/crush-X3E25EQG.js.map +0 -1
  163. package/dist/cursor-UH3W622V.js.map +0 -1
  164. package/dist/doctor-DZTWED4O.js.map +0 -1
  165. package/dist/droid-T5VBRXZF.js.map +0 -1
  166. package/dist/gemini-cli-ZSUK55UA.js.map +0 -1
  167. package/dist/goose-M3RR3CZG.js.map +0 -1
  168. package/dist/hermes-CUNKIAR5.js.map +0 -1
  169. package/dist/hook-EVY7LOUQ.js.map +0 -1
  170. package/dist/jetbrains-copilot-C3HDGGML.js.map +0 -1
  171. package/dist/kilo-PKAJCWPX.js.map +0 -1
  172. package/dist/kimi-EVD7YKXS.js.map +0 -1
  173. package/dist/mux-5CI5FP2W.js.map +0 -1
  174. package/dist/omp-AXA7XY22.js.map +0 -1
  175. package/dist/openclaw-UZ5BMCGQ.js.map +0 -1
  176. package/dist/opencode-NZBRLJN3.js.map +0 -1
  177. package/dist/qwen-code-MRRIUQ3P.js.map +0 -1
  178. package/dist/roo-code-NI5UU6JB.js.map +0 -1
  179. package/dist/trae-CQC72RHH.js.map +0 -1
  180. package/dist/vscode-copilot-4RVRTCKV.js.map +0 -1
  181. package/dist/warp-X6MB67NT.js.map +0 -1
  182. /package/dist/{antigravity-7IBYFO6P.js.map → antigravity-AMKKKHS4.js.map} +0 -0
  183. /package/dist/{antigravity-cli-JEOUP2VN.js.map → antigravity-cli-XERXEH5W.js.map} +0 -0
  184. /package/dist/{chunk-KQSNDFBN.js.map → chunk-LQRAPXS4.js.map} +0 -0
  185. /package/dist/{kilo-cli-QWUVXG2O.js.map → kilo-cli-UZ7R5UOP.js.map} +0 -0
  186. /package/dist/{kiro-UQRY6EIO.js.map → kiro-YL6AWUYG.js.map} +0 -0
  187. /package/dist/{leaderboard-CSWHI4UY.js.map → leaderboard-MJG24O35.js.map} +0 -0
  188. /package/dist/{usage-CJOM2WQM.js.map → usage-ZFBVQF3H.js.map} +0 -0
  189. /package/dist/{zed-NTCYW4V2.js.map → zed-SFUHL3GS.js.map} +0 -0
@@ -5,14 +5,11 @@ import {
5
5
  import {
6
6
  BaseAdapter,
7
7
  parseJsonc
8
- } from "./chunk-PD4VFEBY.js";
9
- import "./chunk-7L6ITC4T.js";
8
+ } from "./chunk-CPLK7GTE.js";
10
9
  import {
11
10
  buildServeWrapperCommand,
12
11
  shouldWrapForTelemetry
13
- } from "./chunk-MEH7GC7R.js";
14
- import "./chunk-N6HH7K6P.js";
15
- import "./chunk-TRQKHP7D.js";
12
+ } from "./chunk-I5MLE6S7.js";
16
13
 
17
14
  // src/adapters/openclaw/index.ts
18
15
  import {
@@ -48,6 +45,9 @@ var EVENT_TO_OPENCLAW = {
48
45
  };
49
46
  var OpenClawAdapter = class extends BaseAdapter {
50
47
  id = HOST;
48
+ // Declared as `string` (not the literal "OpenClaw") so a fork adapter can
49
+ // override it — NemoClaw extends this class (precedent: AntigravityAdapter,
50
+ // whose name is likewise typed `string` for AntigravityCliAdapter).
51
51
  name = "OpenClaw";
52
52
  paradigm = "ts-plugin";
53
53
  capabilities = {
@@ -81,8 +81,22 @@ var OpenClawAdapter = class extends BaseAdapter {
81
81
  canModifyOutput: false,
82
82
  // injected via before_prompt_build at prompt assembly.
83
83
  canInjectSessionContext: true,
84
- // OpenClaw's MCP sidecar registration is stdio-only in practice.
85
- transports: ["stdio"]
84
+ // stdio sidecars + remote servers. OpenClaw's validator accepts a remote
85
+ // transport of "sse" | "streamable-http" (AC "http" → "streamable-http");
86
+ // verified against OpenClaw 2026.6.1 + docs.openclaw.ai/gateway/configuration-reference.
87
+ transports: ["stdio", "sse", "http"],
88
+ // Content surface: OpenClaw follows the AgentSkills spec (dir-per-skill
89
+ // SKILL.md with {name, description} frontmatter + body). User scope →
90
+ // ~/.openclaw/skills (the `openclaw skills install --global` target);
91
+ // project scope → the resolved <workspace>/skills (the highest-priority
92
+ // documented skill root, the same workspace the memory surface anchors to).
93
+ supportsSkills: true,
94
+ // Action surface: each declared action becomes a user-invokable slash
95
+ // command registered INSIDE the generated plugin module (api.registerCommand),
96
+ // shelling out to the home-bin action verb with the install target baked as
97
+ // the host token (this.id), so a fork like NemoClaw emits `action nemoclaw`.
98
+ // supportsActions -> the installActions/uninstallActions overrides below.
99
+ supportsActions: true
86
100
  };
87
101
  // ── Tolerant JSON5/JSONC read (override base strict JSON.parse) ──────────
88
102
  /**
@@ -118,23 +132,32 @@ var OpenClawAdapter = class extends BaseAdapter {
118
132
  memoryTargets(ctx) {
119
133
  if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);
120
134
  if (ctx.scope !== "project" && ctx.scope !== "user") return [];
121
- const configPath = resolveOpenClawConfigPath();
122
- const cfg = this.readJson(configPath);
123
- const declared = cfg?.agents?.defaults?.workspace;
124
- const workspace = typeof declared === "string" && declared.trim() !== "" ? declared.startsWith("~") ? resolve(homedir(), declared.replace(/^~[/\\]?/, "")) : resolve(declared) : join(dirname(configPath), "workspace");
125
135
  return [
126
136
  {
127
- path: join(workspace, "AGENTS.md"),
137
+ path: join(this.resolveWorkspace(), "AGENTS.md"),
128
138
  reason: "openclaw agent-workspace AGENTS.md (workspace-scoped operating instructions, not the project repo \u2014 both scopes map here)"
129
139
  }
130
140
  ];
131
141
  }
142
+ /**
143
+ * Resolve OpenClaw's AGENT WORKSPACE — `agents.defaults.workspace` in
144
+ * openclaw.json when set, else `<stateDir>/workspace` (default
145
+ * ~/.openclaw/workspace). The same root the memory surface and the
146
+ * project-scope skills surface both anchor to, so they never diverge.
147
+ */
148
+ resolveWorkspace() {
149
+ const configPath = resolveOpenClawConfigPath();
150
+ const cfg = this.readJson(configPath);
151
+ const declared = cfg?.agents?.defaults?.workspace;
152
+ return typeof declared === "string" && declared.trim() !== "" ? declared.startsWith("~") ? resolve(homedir(), declared.replace(/^~[/\\]?/, "")) : resolve(declared) : join(dirname(configPath), "workspace");
153
+ }
132
154
  // ── Detection ──────────────────────────────────────────────────────────
133
155
  detectInstalled(projectDir) {
134
156
  const userConfig = resolveOpenClawConfigPath();
135
157
  const userDir = join(homedir(), ".openclaw");
136
158
  const projectConfig = join(projectDir, "openclaw.json");
137
- const userInstalled = existsSync(userConfig) || existsSync(userDir);
159
+ const deferToNemoClaw = existsSync(join(homedir(), ".nemoclaw"));
160
+ const userInstalled = !deferToNemoClaw && (existsSync(userConfig) || existsSync(userDir));
138
161
  const projInstalled = existsSync(projectConfig);
139
162
  const installed = userInstalled || projInstalled;
140
163
  const scope = projInstalled && !userInstalled ? "project" : "user";
@@ -198,7 +221,7 @@ var OpenClawAdapter = class extends BaseAdapter {
198
221
  }
199
222
  /** Resolve the per-platform server override into an effective ServerDef. */
200
223
  effectiveServer(ctx) {
201
- const override = ctx.connector.platforms[HOST]?.server;
224
+ const override = ctx.connector.platforms[this.id]?.server;
202
225
  if (override === false) return void 0;
203
226
  const base = ctx.connector.server;
204
227
  if (!base) return void 0;
@@ -210,7 +233,7 @@ var OpenClawAdapter = class extends BaseAdapter {
210
233
  * stdio → { command, args?, env? } (NO transport key — a stdio sidecar is
211
234
  * inferred from `command`; OpenClaw's validator rejects
212
235
  * transport:"stdio" and only accepts "sse"/"streamable-http")
213
- * remote → { url, transport: "sse"|"http", headers? }
236
+ * remote → { url, transport: "sse"|"streamable-http", headers? }
214
237
  *
215
238
  * OpenClaw documents no native ${env:VAR} token, so refs resolve to literals.
216
239
  */
@@ -240,7 +263,7 @@ var OpenClawAdapter = class extends BaseAdapter {
240
263
  if (server.enabled === false) entry2.enabled = false;
241
264
  return entry2;
242
265
  }
243
- const transport = server.transport === "http" ? "http" : "sse";
266
+ const transport = server.transport === "http" ? "streamable-http" : "sse";
244
267
  const entry = {
245
268
  url: resolveEnvRefsDeep(server.url ?? ""),
246
269
  transport
@@ -325,17 +348,71 @@ var OpenClawAdapter = class extends BaseAdapter {
325
348
  // ── Hook install / uninstall (ts-plugin + DUAL REGISTRATION) ────────────
326
349
  installHooks(ctx) {
327
350
  const pluginPath = this.getHookConfigPath(ctx);
328
- const configPath = this.getServerConfigPath(ctx);
329
- if (ctx.connector.platforms[HOST]?.hooks === false) {
351
+ if (ctx.connector.platforms[this.id]?.hooks === false) {
330
352
  return [
331
- { platform: this.id, action: "skip", path: pluginPath, detail: "hooks disabled for openclaw" }
353
+ { platform: this.id, action: "skip", path: pluginPath, detail: `hooks disabled for ${this.id}` }
332
354
  ];
333
355
  }
334
356
  if (ctx.connector.hookEvents.length === 0) {
335
357
  return [
336
- { platform: this.id, action: "skip", path: pluginPath, detail: "connector declares no hooks" }
358
+ {
359
+ platform: this.id,
360
+ action: "skip",
361
+ path: pluginPath,
362
+ detail: this.actionTriggers(ctx).length > 0 ? "no hooks (plugin written for actions)" : "connector declares no hooks"
363
+ }
337
364
  ];
338
365
  }
366
+ return this.ensurePlugin(ctx, `openclaw plugin module (${this.hookDetail(ctx)})`);
367
+ }
368
+ // ── Action install / uninstall (slash commands in the shared plugin) ────
369
+ /**
370
+ * Each declared action becomes an `api.registerCommand(...)` inside the SAME
371
+ * synthesized plugin module (see buildPluginSource). So installActions ensures
372
+ * that shared module is on disk AND dual-registered: when hooks already wrote
373
+ * the identical bytes the content-compare yields "skip" (no double material
374
+ * write), and an actions-only connector gets the plugin written + registered
375
+ * here. Honors platforms.<id>.actions === false and the empty-actions skip.
376
+ */
377
+ installActions(ctx) {
378
+ const pluginPath = this.getHookConfigPath(ctx);
379
+ if (ctx.connector.platforms[this.id]?.actions === false) {
380
+ return [
381
+ { platform: this.id, action: "skip", path: pluginPath, detail: `actions disabled for ${this.id}` }
382
+ ];
383
+ }
384
+ if (this.actionTriggers(ctx).length === 0) {
385
+ return [
386
+ { platform: this.id, action: "skip", path: pluginPath, detail: "connector declares no actions" }
387
+ ];
388
+ }
389
+ return this.ensurePlugin(ctx, "openclaw plugin module (action commands)");
390
+ }
391
+ /**
392
+ * Actions live INSIDE the shared plugin module, which uninstallHooks removes
393
+ * (file + manifest + dual-registration entry) unconditionally — it runs last
394
+ * in the teardown pass. Removing the plugin here too would race uninstallHooks,
395
+ * so this is a single informational skip.
396
+ */
397
+ uninstallActions(ctx) {
398
+ return [
399
+ {
400
+ platform: this.id,
401
+ action: "skip",
402
+ path: this.getHookConfigPath(ctx),
403
+ detail: "action commands are embedded in the plugin module; removed by uninstallHooks"
404
+ }
405
+ ];
406
+ }
407
+ /**
408
+ * Synthesize + content-compare-write the plugin module(s) AND upsert the dual-
409
+ * registration entry. Shared by installHooks and installActions: the generator
410
+ * is a pure function of ctx, so whichever surface runs second sees byte-
411
+ * identical files (and an already-present entry) and reports "skip" — no double
412
+ * material write. `moduleDetail` flavors the module ChangeRecord per surface.
413
+ */
414
+ ensurePlugin(ctx, moduleDetail) {
415
+ const configPath = this.getServerConfigPath(ctx);
339
416
  const changes = [];
340
417
  for (const file of this.synthesizePlugin(ctx)) {
341
418
  const before = existsSync(file.path) ? this.safeRead(file.path) : void 0;
@@ -352,7 +429,7 @@ var OpenClawAdapter = class extends BaseAdapter {
352
429
  platform: this.id,
353
430
  action,
354
431
  path: file.path,
355
- detail: `openclaw plugin module (${this.hookDetail(ctx)})`
432
+ detail: moduleDetail
356
433
  });
357
434
  }
358
435
  changes.push(this.upsertPluginEntry(configPath, ctx, this.pluginDir(ctx)));
@@ -504,6 +581,96 @@ var OpenClawAdapter = class extends BaseAdapter {
504
581
  loadObj[PLUGINS_LOAD_PATHS_KEY] = paths;
505
582
  return paths;
506
583
  }
584
+ // ── Content surface: skills (dir-per-skill SKILL.md) ────────────────────
585
+ // CONTENT-ONLY: pure native-file writers, mirroring codex/claude-code
586
+ // installSkills + renderSkill. No runtime dispatch, no home-bin pointer, no
587
+ // telemetry wrap. Each write is idempotent (byte-identical → skip) via
588
+ // writeContentFile and reversible via removeContentFile + removeDirIfEmpty
589
+ // (never rm -rf a shared dir). Honors platforms["openclaw"].skills === false.
590
+ //
591
+ // Native locations (AgentSkills spec — dir-per-skill SKILL.md + resources):
592
+ // user → ~/.openclaw/skills/<name>/SKILL.md (`openclaw skills install
593
+ // --global` targets this dir)
594
+ // project → <workspace>/skills/<name>/SKILL.md (the highest-priority
595
+ // documented skill root; <workspace> is the SAME root the memory
596
+ // surface resolves, so both content surfaces stay consistent).
597
+ /**
598
+ * Per-skill directory for ctx.scope:
599
+ * user → ~/.openclaw/skills/<name> (`--global` install target)
600
+ * project → <workspace>/skills/<name> (resolved agent workspace —
601
+ * consistent with this adapter's memoryTargets resolution).
602
+ */
603
+ skillDir(ctx, name) {
604
+ const base = ctx.scope === "project" ? join(this.resolveWorkspace(), "skills") : join(dirname(resolveOpenClawConfigPath()), "skills");
605
+ return join(base, name);
606
+ }
607
+ installSkills(ctx) {
608
+ const { connector } = ctx;
609
+ if (connector.platforms[this.id]?.skills === false) {
610
+ return [{ platform: this.id, action: "skip", detail: `skills disabled for ${this.id}` }];
611
+ }
612
+ if (connector.skills.length === 0) {
613
+ return [{ platform: this.id, action: "skip", detail: "connector declares no skills" }];
614
+ }
615
+ const changes = [];
616
+ for (const skill of connector.skills) {
617
+ const dir = this.skillDir(ctx, skill.name);
618
+ changes.push(
619
+ this.writeContentFile(join(dir, "SKILL.md"), this.renderSkill(skill), ctx.dryRun)
620
+ );
621
+ for (const [rel, contents] of Object.entries(skill.resources ?? {})) {
622
+ const target = this.resolveWithin(dir, rel);
623
+ if (target === null) {
624
+ changes.push({
625
+ platform: this.id,
626
+ action: "warn",
627
+ detail: `skill resource "${rel}" escapes the skill dir; skipped`
628
+ });
629
+ continue;
630
+ }
631
+ changes.push(this.writeContentFile(target, contents, ctx.dryRun));
632
+ }
633
+ }
634
+ return changes;
635
+ }
636
+ uninstallSkills(ctx) {
637
+ const { connector } = ctx;
638
+ if (connector.skills.length === 0) {
639
+ return [{ platform: this.id, action: "skip", detail: "connector declares no skills" }];
640
+ }
641
+ const changes = [];
642
+ for (const skill of connector.skills) {
643
+ const dir = this.skillDir(ctx, skill.name);
644
+ changes.push(this.removeContentFile(join(dir, "SKILL.md"), ctx.dryRun));
645
+ for (const rel of Object.keys(skill.resources ?? {})) {
646
+ const target = this.resolveWithin(dir, rel);
647
+ if (target === null) continue;
648
+ changes.push(this.removeContentFile(target, ctx.dryRun));
649
+ }
650
+ changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));
651
+ }
652
+ return changes;
653
+ }
654
+ /**
655
+ * Render a skill's SKILL.md: frontmatter (name, description + optional model,
656
+ * allowed-tools, disable-model-invocation) + body. UNIFORM with codex /
657
+ * claude-code — only the parent dir differs (single-line frontmatter keys;
658
+ * OpenClaw follows the AgentSkills spec).
659
+ */
660
+ renderSkill(skill) {
661
+ const frontmatter = {
662
+ name: skill.name,
663
+ description: skill.description
664
+ };
665
+ if (skill.model !== void 0) frontmatter.model = skill.model;
666
+ const allow = skill.tools?.allow;
667
+ if (allow && allow.length > 0) frontmatter["allowed-tools"] = allow.join(", ");
668
+ if (skill.disableModelInvocation !== void 0) {
669
+ frontmatter["disable-model-invocation"] = skill.disableModelInvocation;
670
+ }
671
+ if (skill.extra) Object.assign(frontmatter, skill.extra);
672
+ return this.renderFrontmatterMd(frontmatter, skill.body);
673
+ }
507
674
  // ── ts-plugin synthesis ────────────────────────────────────────────────
508
675
  /**
509
676
  * Build ONE self-contained ESM plugin module for OpenClaw.
@@ -547,7 +714,8 @@ var OpenClawAdapter = class extends BaseAdapter {
547
714
  const homeBin = JSON.stringify(ctx.homeBinPath);
548
715
  const connectorId = JSON.stringify(ctx.connector.id);
549
716
  const connectorName = JSON.stringify(ctx.connector.displayName || ctx.connector.id);
550
- const events = ctx.connector.hookEvents.filter(
717
+ const canonicalOff = ctx.connector.platforms[this.id]?.hooks === false;
718
+ const events = canonicalOff ? [] : ctx.connector.hookEvents.filter(
551
719
  (e) => EVENT_TO_OPENCLAW[e] !== void 0
552
720
  );
553
721
  const has = (e) => events.includes(e);
@@ -562,21 +730,7 @@ var OpenClawAdapter = class extends BaseAdapter {
562
730
  */
563
731
  import { execFileSync, execSync } from "node:child_process";
564
732
 
565
- const HOME_BIN = ` + homeBin + ";\nconst CONNECTOR_ID = " + connectorId + `;
566
-
567
- /**
568
- * Invoke the universal hook entrypoint for one canonical event.
569
- * @param {string} event canonical event name
570
- * (PreToolUse|PostToolUse|SessionStart|SubagentStart|SubagentStop)
571
- * @param {object} payload OpenClaw-shaped payload posted on stdin
572
- * @returns {object|null} normalized HookResponse, or null on any failure
573
- */
574
- function bridge(event, payload) {
575
- try {
576
- // On Windows HOME_BIN is the agent-connector.cmd launcher: Node cannot
577
- // execFile a batch file, and shell+args is deprecated (DEP0190), so run
578
- // one quoted command line via a shell. POSIX keeps the direct execFile.
579
- const args = ["hook", "openclaw", event, "--connector", CONNECTOR_ID];
733
+ const HOME_BIN = ` + homeBin + ";\nconst CONNECTOR_ID = " + connectorId + ';\n\n/**\n * Invoke the universal hook entrypoint for one canonical event.\n * @param {string} event canonical event name\n * (PreToolUse|PostToolUse|SessionStart|SubagentStart|SubagentStop)\n * @param {object} payload OpenClaw-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\n // one quoted command line via a shell. POSIX keeps the direct execFile.\n const args = ["hook", ' + JSON.stringify(this.id) + `, event, "--connector", CONNECTOR_ID];
580
734
  const opts = { input: JSON.stringify(payload), encoding: "utf8" };
581
735
  const stdout =
582
736
  process.platform === "win32"
@@ -646,6 +800,20 @@ let contextInjected = false;
646
800
  '\n // SessionStart \u2192 session_start records the real session id and fetches\n // the additionalContext to inject; before_prompt_build performs the\n // injection (the verified context-injection point upstream).\n on("session_start", async (event) => {\n const e = event || {};\n SESSION_ID = e.sessionId || e.sessionKey || SESSION_ID;\n const res = bridge("SessionStart", {\n sessionId: SESSION_ID,\n source: e.resumedFrom ? "resume" : "startup",\n projectDir: PROJECT_DIR,\n });\n contextInjected = false;\n pendingContext =\n res && typeof res.additionalContext === "string" && res.additionalContext\n ? res.additionalContext\n : null;\n return undefined;\n });\n\n // Inject the session-start context once, at prompt-build time.\n on("before_prompt_build", () => {\n if (contextInjected || !pendingContext) return undefined;\n contextInjected = true;\n return { appendSystemContext: pendingContext };\n });\n'
647
801
  );
648
802
  }
803
+ for (const action of this.actionTriggers(ctx)) {
804
+ const id = JSON.stringify(action.id);
805
+ const description = JSON.stringify(action.description);
806
+ reg.push(
807
+ "\n // Action /" + action.id + " -> run the home-bin action verb directly.\n api.registerCommand({\n name: " + id + ",\n description: " + description + ',\n handler: async (_ctx) => {\n try {\n const args = ["action", ' + JSON.stringify(this.id) + ", " + id + `, "--connector", CONNECTOR_ID];
808
+ const out =
809
+ process.platform === "win32"
810
+ ? execSync([HOME_BIN, ...args].map((a) => '"' + a + '"').join(" "), { encoding: "utf8" })
811
+ : execFileSync(HOME_BIN, args, { encoding: "utf8" });
812
+ return { text: (out || "").trim() };
813
+ } catch (e) {
814
+ return { text: "action " + ` + id + ' + " failed: " + (e && e.message ? e.message : "error") };\n }\n },\n });\n'
815
+ );
816
+ }
649
817
  reg.push(" },\n");
650
818
  const definition = "const plugin = {\n id: CONNECTOR_ID,\n name: " + connectorName + ',\n configSchema: {\n type: "object",\n properties: {\n enabled: {\n type: "boolean",\n default: true,\n description: "Enable or disable the " + CONNECTOR_ID + " plugin.",\n },\n },\n additionalProperties: false,\n },\n' + reg.join("") + "};\n\nexport default plugin;\n";
651
819
  return header + definition;
@@ -659,7 +827,7 @@ let contextInjected = false;
659
827
  parseEvent(event, raw) {
660
828
  const input = raw ?? {};
661
829
  const base = {
662
- hostPlatform: HOST,
830
+ hostPlatform: this.id,
663
831
  connectorId: "",
664
832
  sessionId: typeof input.sessionId === "string" ? input.sessionId : "",
665
833
  raw,
@@ -729,7 +897,7 @@ let contextInjected = false;
729
897
  const pluginPath = this.getHookConfigPath(ctx);
730
898
  const pluginDir = this.pluginDir(ctx);
731
899
  const id = ctx.connector.id;
732
- const hasHooks = ctx.connector.hookEvents.length > 0;
900
+ const hasHooks = ctx.connector.hookEvents.length > 0 || this.actionTriggers(ctx).length > 0;
733
901
  const hasServer = Boolean(ctx.connector.server);
734
902
  return [
735
903
  {
@@ -840,9 +1008,10 @@ function isNonEmptyString(value) {
840
1008
  }
841
1009
  var adapter = new OpenClawAdapter();
842
1010
  var openclaw_default = adapter;
1011
+
843
1012
  export {
844
1013
  OpenClawAdapter,
845
1014
  adapter,
846
- openclaw_default as default
1015
+ openclaw_default
847
1016
  };
848
- //# sourceMappingURL=openclaw-UZ5BMCGQ.js.map
1017
+ //# sourceMappingURL=chunk-URHQMFB3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/openclaw/index.ts"],"sourcesContent":["/**\n * adapters/openclaw — OpenClaw (Gateway) platform adapter for agent-connector.\n *\n * OpenClaw is a **ts-plugin** host, but with a twist no other ts-plugin host\n * has: a plugin only delivers its MCP tools to the agent when it is registered\n * in TWO places at once (DUAL REGISTRATION):\n *\n * (a) plugins.entries.<id> = { enabled: true } + plugins.load.paths: [dir]\n * — so the gateway DISCOVERS and LOADS the plugin\n * module (runs register(api), wiring the hooks).\n * NOTE: the entry is { enabled } only — a per-entry\n * `module` field is rejected by `openclaw config\n * validate`, so discovery goes through the\n * plugins.load.paths dir scan instead; and\n * (b) mcp.servers.<id> — nested under a top-level \"mcp\" object, so the\n * plugin's MCP tools SURFACE to the agent.\n *\n * If only (a) is present, the plugin loads but ZERO tools reach the agent.\n * If only (b) is present, the tools are declared but the hook bridge never\n * loads. context-mode's own adapter proved this empirically against OpenClaw\n * 2026.4.22 (src/adapters/openclaw/index.ts checkPluginRegistration: \"in\n * plugins.entries but missing from mcp.servers — plugin loads but no ctx_*\n * tools reach the agent\"). So getHealthChecks() FAILS when the two are\n * inconsistent (entries XOR mcp.servers).\n *\n * Why we BRIDGE instead of importing handlers (mirrors the OpenCode adapter):\n * context-mode could load ITS OWN plugin in-process because the handler code\n * shipped with the package. agent-connector cannot: the connector's hook\n * handlers are arbitrary developer code we must not import into the gateway's\n * runtime (wrong cwd, wrong deps, version skew). So installHooks synthesizes a\n * tiny, fully self-contained ESM plugin module — { id, name, configSchema,\n * register(api) } — that imports NOTHING from agent-connector and, on each\n * hook firing, shells out to the ONE stable home binary's universal entrypoint\n * <homeBin> hook openclaw <event> --connector <id>\n * feeding the event payload on stdin and JSON.parsing the normalized\n * HookResponse back from stdout. Fail-open: any bridge error → no-op. The same\n * universal json-stdio dispatcher every other host uses thus serves OpenClaw.\n *\n * Plugin module shape (grounded in context-mode build/adapters/openclaw/plugin.js):\n * export default { id, name, configSchema, register(api) }\n * register(api) wires typed lifecycle hooks via api.on(event, handler):\n * before_tool_call → block (return { block, blockReason }) / rewrite args\n * (mutate event.params in place); deny+ask both block.\n * after_tool_call → observe (capture result/output).\n * session_start → record the real session id.\n * before_prompt_build → inject SessionStart additionalContext via\n * { appendSystemContext } (the verified context-injection\n * point; session_start itself returns no context payload).\n * subagent_spawned / subagent_ended → observe the subagent lifecycle\n * (SubagentStart / SubagentStop; observe-only — no\n * decision or context payload).\n * api.on() is the correct API for typed lifecycle hooks; api.registerHook() is\n * for generic command hooks. We register defensively (api.on present check).\n *\n * Config file (JSON5 / JSONC — PARSE TOLERANTLY):\n * user scope → resolveOpenClawConfigPath():\n * $OPENCLAW_CONFIG_PATH\n * else $OPENCLAW_STATE_DIR/openclaw.json\n * else ~/.openclaw/openclaw.json\n * (mirrors context-mode openclawConfigPath — the file the\n * gateway actually loads, NOT process.cwd()).\n * project scope → <projectDir>/openclaw.json (also supported).\n * openclaw.json may contain comments + trailing commas (JSON5), so we NEVER\n * use strict JSON.parse — readJson is overridden to strip comments/commas\n * first via the shared core/jsonc parseJsonc. writes are strict JSON\n * (idempotent, comment-free).\n *\n * Plugin module location (project | user):\n * user → <stateDir>/extensions/<id>/index.mjs (stateDir = dir of openclaw.json)\n * project → <projectDir>/.openclaw/extensions/<id>/index.mjs\n * Beside index.mjs we also emit an openclaw.plugin.json manifest. The plugin's\n * DIRECTORY (not the file) is added to plugins.load.paths so the gateway scans\n * it and loads the module; the plugins.entries.<id> = { enabled: true } half\n * then activates it. (There is no per-entry \"module\" field — validate rejects it.)\n *\n * The gateway hot-reloads its config on SIGUSR1 — no action needed here; the\n * next reload (or restart) picks up our entries/servers/module.\n *\n * Capabilities (per OpenClaw hook API):\n * preToolUse / postToolUse / sessionStart / subagentStart / subagentStop\n * true; transports [\"stdio\"].\n * before_tool_call mutates event.params → canModifyArgs true.\n * after_tool_call cannot rewrite the tool result → canModifyOutput false.\n * before_prompt_build injects context → canInjectSessionContext true.\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, resolve } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type {\n Adapter,\n GeneratedPluginFile,\n HookReply,\n InstallContext,\n MemoryTarget,\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 PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n SkillDef,\n SubagentStartEvent,\n SubagentStopEvent,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { parseJsonc } from \"../../core/jsonc.js\";\nimport {\n buildServeWrapperCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"openclaw\";\n\n/**\n * MCP servers live nested under the top-level \"mcp\" object: mcp.servers.<id>\n * (NOT a top-level \"mcpServers\" key). plugins.entries.<id> is the second half of\n * the dual registration.\n */\nconst MCP_ROOT_KEY = \"mcp\";\nconst MCP_SERVERS_KEY = \"servers\";\nconst PLUGINS_KEY = \"plugins\";\nconst PLUGINS_ENTRIES_KEY = \"entries\";\n/**\n * The gateway discovers a synthesized plugin module by scanning the directories\n * listed in plugins.load.paths — it does NOT take a per-entry `module` field\n * (that fails `openclaw config validate`). We add the plugin's own dir here.\n */\nconst PLUGINS_LOAD_KEY = \"load\";\nconst PLUGINS_LOAD_PATHS_KEY = \"paths\";\n/** Manifest the gateway reads inside a plugins.load.paths directory. */\nconst PLUGIN_MANIFEST_FILE = \"openclaw.plugin.json\";\n\n/**\n * Canonical → OpenClaw event name map. A connector hook event is only emitted by\n * the generated plugin when it appears here AND is declared by the connector.\n *\n * SessionStart maps to OpenClaw's session_start (to learn the real session id)\n * plus before_prompt_build (the verified context-injection point — session_start\n * itself returns no context payload upstream).\n */\nconst EVENT_TO_OPENCLAW: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"before_tool_call\",\n PostToolUse: \"after_tool_call\",\n SessionStart: \"session_start\",\n // Subagent lifecycle: OpenClaw observes launch + completion (no decision\n // control on either). PermissionRequest is deliberately ABSENT — OpenClaw's\n // permission gate is the requireApproval RETURN VALUE of before_tool_call,\n // not an observable event; PostToolUseFailure is ABSENT too (a failure\n // arrives merged into after_tool_call, already surfaced as PostToolUse\n // isError). Unmapped declared events are reported as \"unsupported here\".\n SubagentStart: \"subagent_spawned\",\n SubagentStop: \"subagent_ended\",\n};\n\n/** Raw payload the generated plugin posts to the universal hook entrypoint. */\ninterface OpenClawBridgePayload {\n toolName?: string;\n toolInput?: Record<string, unknown>;\n toolOutput?: string;\n isError?: boolean;\n sessionId?: string;\n source?: string;\n projectDir?: string;\n // subagent_spawned / subagent_ended (the generated plugin normalizes the\n // host's field-name variants before posting; empty strings are omitted).\n agentId?: string;\n agentType?: string;\n lastAssistantMessage?: string;\n}\n\n/**\n * Native MCP server entry shapes OpenClaw accepts under mcp.servers.<id>.\n *\n * A stdio sidecar carries NO `transport` field: OpenClaw's config validator\n * only accepts `transport: \"sse\" | \"streamable-http\"` for remote servers and\n * REJECTS `transport: \"stdio\"` (verified against OpenClaw 2026.6.1). A stdio\n * server is INFERRED from the presence of `command`, so we must never write a\n * transport key here.\n */\ninterface OpenClawStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n enabled?: boolean;\n}\ninterface OpenClawRemoteServer {\n url: string;\n transport: \"sse\" | \"streamable-http\";\n headers?: Record<string, string>;\n enabled?: boolean;\n}\n\n/**\n * plugins.entries.<id> reference shape.\n *\n * `openclaw config validate` REJECTS a `module` field here (it is not part of\n * the entry schema), so the entry is `{ enabled: true }` ONLY. Discovery of the\n * synthesized module is wired separately via `plugins.load.paths` (the dir that\n * holds the module + its openclaw.plugin.json manifest).\n */\ninterface OpenClawPluginEntry {\n enabled: boolean;\n}\n\nexport class OpenClawAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n // Declared as `string` (not the literal \"OpenClaw\") so a fork adapter can\n // override it — NemoClaw extends this class (precedent: AntigravityAdapter,\n // whose name is likewise typed `string` for AntigravityCliAdapter).\n readonly name: string = \"OpenClaw\";\n readonly paradigm: HookParadigm = \"ts-plugin\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block. OpenClaw's AGENTS.md\n // lives in the AGENT WORKSPACE (default ~/.openclaw/workspace), NOT the\n // user's repo — memoryTargets below maps BOTH scopes there (R2:\n // platforms force scopes; personal-assistant semantics, no project file).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n // OpenClaw compaction is owned by a context engine, not wired through the\n // universal bridge here.\n preCompact: false,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n // Newer events: OpenClaw observes the full subagent lifecycle via\n // subagent_spawned / subagent_ended (observe-only — no decision control,\n // so a SubagentStop \"deny\" cannot keep the subagent running here).\n // permissionRequest / postToolUseFailure stay unset: the permission gate\n // is a RETURN VALUE of before_tool_call (not an event) and tool failures\n // arrive merged into after_tool_call. Install reports the standard\n // \"unsupported here\" for unmapped declared events.\n subagentStart: true,\n subagentStop: true,\n // before_tool_call mutates event.params in place → input rewrite supported.\n canModifyArgs: true,\n // after_tool_call observes but cannot rewrite the tool result upstream.\n canModifyOutput: false,\n // injected via before_prompt_build at prompt assembly.\n canInjectSessionContext: true,\n // stdio sidecars + remote servers. OpenClaw's validator accepts a remote\n // transport of \"sse\" | \"streamable-http\" (AC \"http\" → \"streamable-http\");\n // verified against OpenClaw 2026.6.1 + docs.openclaw.ai/gateway/configuration-reference.\n transports: [\"stdio\", \"sse\", \"http\"],\n // Content surface: OpenClaw follows the AgentSkills spec (dir-per-skill\n // SKILL.md with {name, description} frontmatter + body). User scope →\n // ~/.openclaw/skills (the `openclaw skills install --global` target);\n // project scope → the resolved <workspace>/skills (the highest-priority\n // documented skill root, the same workspace the memory surface anchors to).\n supportsSkills: true,\n // Action surface: each declared action becomes a user-invokable slash\n // command registered INSIDE the generated plugin module (api.registerCommand),\n // shelling out to the home-bin action verb with the install target baked as\n // the host token (this.id), so a fork like NemoClaw emits `action nemoclaw`.\n // supportsActions -> the installActions/uninstallActions overrides below.\n supportsActions: true,\n };\n\n // ── Tolerant JSON5/JSONC read (override base strict JSON.parse) ──────────\n\n /**\n * openclaw.json is officially JSON5 (comments + trailing commas allowed). A\n * strict JSON.parse false-fails a perfectly valid commented file, so we strip\n * comments and trailing commas before parsing. Writes remain strict JSON\n * (writeJson in BaseAdapter), which is itself valid JSON5 — so round-trips\n * stay safe and idempotent.\n */\n protected override readJson<T = Record<string, unknown>>(path: string): T | null {\n if (!existsSync(path)) return null;\n let raw: string;\n try {\n raw = readFileSync(path, \"utf8\");\n } catch {\n return null;\n }\n try {\n // Shared, string-aware JSONC stripper (the local stripJsonish whose\n // trailing-comma regex corrupted in-string \",]\"/\",}\"-like values is gone).\n return parseJsonc<T>(raw);\n } catch {\n return null;\n }\n }\n\n // ── Memory surface: agent-workspace AGENTS.md (both scopes) ─────────────\n /**\n * OpenClaw loads AGENTS.md (operating instructions) from its AGENT WORKSPACE\n * every session — `agents.defaults.workspace` in openclaw.json when set,\n * else `<stateDir>/workspace` (default ~/.openclaw/workspace). That file is\n * personal-assistant state, NOT a repo file, so a \"project scope\" write does\n * not apply: BOTH scopes map to the workspace (R2: platforms force scopes),\n * with the reason string flagging the semantics.\n */\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") return [];\n return [\n {\n path: join(this.resolveWorkspace(), \"AGENTS.md\"),\n reason:\n \"openclaw agent-workspace AGENTS.md (workspace-scoped operating instructions, \" +\n \"not the project repo — both scopes map here)\",\n },\n ];\n }\n\n /**\n * Resolve OpenClaw's AGENT WORKSPACE — `agents.defaults.workspace` in\n * openclaw.json when set, else `<stateDir>/workspace` (default\n * ~/.openclaw/workspace). The same root the memory surface and the\n * project-scope skills surface both anchor to, so they never diverge.\n */\n private resolveWorkspace(): string {\n const configPath = resolveOpenClawConfigPath();\n const cfg = this.readJson<{ agents?: { defaults?: { workspace?: unknown } } }>(configPath);\n const declared = cfg?.agents?.defaults?.workspace;\n return typeof declared === \"string\" && declared.trim() !== \"\"\n ? declared.startsWith(\"~\")\n ? resolve(homedir(), declared.replace(/^~[/\\\\]?/, \"\"))\n : resolve(declared)\n : join(dirname(configPath), \"workspace\");\n }\n\n // ── Detection ──────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userConfig = resolveOpenClawConfigPath();\n const userDir = join(homedir(), \".openclaw\");\n const projectConfig = join(projectDir, \"openclaw.json\");\n\n // Fork-before-parent at DETECTION: NemoClaw DRIVES ~/.openclaw/openclaw.json,\n // so on a NemoClaw box (its ~/.nemoclaw/ marker present) the user-scope\n // OpenClaw config is nemoclaw-OWNED — defer so the planner does not double-\n // target the shared file as two platforms (an `uninstall openclaw` would\n // otherwise strip the connector's entries out from under nemoclaw). The\n // NemoClaw adapter overrides detectInstalled, so it is unaffected by this.\n const deferToNemoClaw = existsSync(join(homedir(), \".nemoclaw\"));\n const userInstalled =\n !deferToNemoClaw && (existsSync(userConfig) || existsSync(userDir));\n const projInstalled = existsSync(projectConfig);\n const installed = userInstalled || projInstalled;\n\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 OpenClaw config at ${projectConfig}`\n : `found OpenClaw config at ${configPath}`\n : `no OpenClaw config at ${userConfig} or ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ───────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? ctx.projectDir\n : dirname(resolveOpenClawConfigPath());\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \"openclaw.json\")\n : resolveOpenClawConfigPath();\n }\n\n /**\n * For ts-plugin hosts the \"hook config path\" is the generated plugin FILE.\n * OpenClaw additionally needs the plugins.entries reference written into\n * openclaw.json (handled in installHooks); this is the module on disk.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.pluginDir(ctx), this.pluginFileName());\n }\n\n /** Extensions directory the synthesized plugin module is written into. */\n private pluginDir(ctx: InstallContext): string {\n const base =\n ctx.scope === \"project\"\n ? join(ctx.projectDir, \".openclaw\")\n : dirname(resolveOpenClawConfigPath());\n return join(base, \"extensions\", ctx.connector.id);\n }\n\n /** Plugin module file name (ESM so the gateway loads it without a loader). */\n private pluginFileName(): string {\n return \"index.mjs\";\n }\n\n // ── MCP server install / uninstall (mcp.servers.<id>) ───────────────────\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 openclaw\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n const entry = this.renderServerEntry(ctx, server);\n return [this.upsertNestedServer(serverPath, ctx.connector.id, entry, ctx.dryRun)];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [this.removeNestedServer(serverPath, ctx.connector.id, ctx.dryRun)];\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[this.id]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override && typeof override === \"object\" ? { ...base, ...override } : base;\n }\n\n /**\n * Render a normalized ServerDef into OpenClaw's native mcp.servers.<id> entry.\n *\n * stdio → { command, args?, env? } (NO transport key — a stdio sidecar is\n * inferred from `command`; OpenClaw's validator rejects\n * transport:\"stdio\" and only accepts \"sse\"/\"streamable-http\")\n * remote → { url, transport: \"sse\"|\"streamable-http\", headers? }\n *\n * OpenClaw documents no native ${env:VAR} token, so refs resolve to literals.\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): OpenClawStdioServer | OpenClawRemoteServer {\n if (server.transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n 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 // NO `transport` key: OpenClaw infers a stdio sidecar from `command` and\n // its validator rejects transport:\"stdio\" (only \"sse\"/\"streamable-http\").\n const entry: OpenClawStdioServer = {\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 if (server.enabled === false) entry.enabled = false;\n return entry;\n }\n\n // sse / http → OpenClaw registers a remote URL sidecar. AC's canonical\n // \"http\" (streamable HTTP) maps to OpenClaw's literal \"streamable-http\" — its\n // validator rejects a bare \"http\" transport value.\n const transport: \"sse\" | \"streamable-http\" =\n server.transport === \"http\" ? \"streamable-http\" : \"sse\";\n const entry: OpenClawRemoteServer = {\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n transport,\n };\n if (server.headers && Object.keys(server.headers).length > 0) {\n entry.headers = resolveEnvRefsDeep({ ...server.headers });\n }\n if (server.enabled === false) entry.enabled = false;\n return entry;\n }\n\n /** Resolve every ${env:VAR} in env values to literals (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 /** Upsert config.mcp.servers.<id> idempotently. */\n private upsertNestedServer(\n path: string,\n id: string,\n entry: unknown,\n dryRun: boolean,\n ): ChangeRecord {\n // OVERWRITE GUARD: never blank a present-but-unparseable openclaw.json.\n if (this.isPresentButUnparseable(path)) {\n return {\n platform: this.id,\n action: \"warn\",\n path,\n detail: `existing ${path} is not parseable; left untouched (back it up / fix it, then re-run)`,\n };\n }\n const cfg = this.readJson<Record<string, unknown>>(path) ?? {};\n const servers = this.nestedServersBucket(cfg);\n const before = JSON.stringify(servers[id]);\n const after = JSON.stringify(entry);\n let action: ChangeRecord[\"action\"];\n if (before === undefined) action = \"create\";\n else if (before === after) action = \"skip\";\n else action = \"update\";\n if (action !== \"skip\") {\n servers[id] = entry;\n this.writeJson(path, cfg, dryRun);\n }\n return {\n platform: this.id,\n action,\n path,\n detail: `${MCP_ROOT_KEY}.${MCP_SERVERS_KEY}.${id}`,\n };\n }\n\n /** Remove config.mcp.servers.<id>. */\n private removeNestedServer(path: string, id: string, dryRun: boolean): ChangeRecord {\n const cfg = this.readJson<Record<string, unknown>>(path);\n const mcp = cfg?.[MCP_ROOT_KEY];\n const servers =\n mcp && typeof mcp === \"object\" && !Array.isArray(mcp)\n ? ((mcp as Record<string, unknown>)[MCP_SERVERS_KEY] as\n | Record<string, unknown>\n | undefined)\n : undefined;\n if (!cfg || !servers || !(id in servers)) {\n return {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `${MCP_ROOT_KEY}.${MCP_SERVERS_KEY}.${id} absent`,\n };\n }\n delete servers[id];\n this.writeJson(path, cfg, dryRun);\n return {\n platform: this.id,\n action: \"remove\",\n path,\n detail: `${MCP_ROOT_KEY}.${MCP_SERVERS_KEY}.${id}`,\n };\n }\n\n /** Get-or-create config.mcp.servers as a mutable object. */\n private nestedServersBucket(cfg: Record<string, unknown>): Record<string, unknown> {\n let mcp = cfg[MCP_ROOT_KEY];\n if (!mcp || typeof mcp !== \"object\" || Array.isArray(mcp)) {\n mcp = {};\n cfg[MCP_ROOT_KEY] = mcp;\n }\n const mcpObj = mcp as Record<string, unknown>;\n let servers = mcpObj[MCP_SERVERS_KEY];\n if (!servers || typeof servers !== \"object\" || Array.isArray(servers)) {\n servers = {};\n mcpObj[MCP_SERVERS_KEY] = servers;\n }\n return servers as Record<string, unknown>;\n }\n\n // ── Hook install / uninstall (ts-plugin + DUAL REGISTRATION) ────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n\n if (ctx.connector.platforms[this.id]?.hooks === false) {\n return [\n { platform: this.id, action: \"skip\", path: pluginPath, detail: `hooks disabled for ${this.id}` },\n ];\n }\n // Empty-events gate: the plugin module is SHARED with the action surface, so\n // a connector with actions-but-no-hooks still needs it written + registered —\n // but that is installActions' job (it calls ensurePlugin too). installHooks\n // only writes when there ARE hooks; its skip detail stays honest about why.\n if (ctx.connector.hookEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: pluginPath,\n detail:\n this.actionTriggers(ctx).length > 0\n ? \"no hooks (plugin written for actions)\"\n : \"connector declares no hooks\",\n },\n ];\n }\n\n return this.ensurePlugin(ctx, `openclaw plugin module (${this.hookDetail(ctx)})`);\n }\n\n // ── Action install / uninstall (slash commands in the shared plugin) ────\n\n /**\n * Each declared action becomes an `api.registerCommand(...)` inside the SAME\n * synthesized plugin module (see buildPluginSource). So installActions ensures\n * that shared module is on disk AND dual-registered: when hooks already wrote\n * the identical bytes the content-compare yields \"skip\" (no double material\n * write), and an actions-only connector gets the plugin written + registered\n * here. Honors platforms.<id>.actions === false and the empty-actions skip.\n */\n override installActions(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n if (ctx.connector.platforms[this.id]?.actions === false) {\n return [\n { platform: this.id, action: \"skip\", path: pluginPath, detail: `actions disabled for ${this.id}` },\n ];\n }\n if (this.actionTriggers(ctx).length === 0) {\n return [\n { platform: this.id, action: \"skip\", path: pluginPath, detail: \"connector declares no actions\" },\n ];\n }\n return this.ensurePlugin(ctx, \"openclaw plugin module (action commands)\");\n }\n\n /**\n * Actions live INSIDE the shared plugin module, which uninstallHooks removes\n * (file + manifest + dual-registration entry) unconditionally — it runs last\n * in the teardown pass. Removing the plugin here too would race uninstallHooks,\n * so this is a single informational skip.\n */\n override uninstallActions(ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: this.getHookConfigPath(ctx),\n detail: \"action commands are embedded in the plugin module; removed by uninstallHooks\",\n },\n ];\n }\n\n /**\n * Synthesize + content-compare-write the plugin module(s) AND upsert the dual-\n * registration entry. Shared by installHooks and installActions: the generator\n * is a pure function of ctx, so whichever surface runs second sees byte-\n * identical files (and an already-present entry) and reports \"skip\" — no double\n * material write. `moduleDetail` flavors the module ChangeRecord per surface.\n */\n private ensurePlugin(ctx: InstallContext, moduleDetail: string): ChangeRecord[] {\n const configPath = this.getServerConfigPath(ctx);\n const changes: ChangeRecord[] = [];\n\n // 1. Write the synthesized plugin module(s).\n for (const file of this.synthesizePlugin(ctx)) {\n const before = existsSync(file.path) ? this.safeRead(file.path) : 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 changes.push({\n platform: this.id,\n action,\n path: file.path,\n detail: moduleDetail,\n });\n }\n\n // 2. DUAL REGISTRATION half (a): enable plugins.entries.<id> AND add the\n // plugin DIR to plugins.load.paths so the gateway discovers + loads the\n // module. (half (b), mcp.servers.<id>, is written by installServer — both\n // are required for tools to reach the agent.)\n changes.push(this.upsertPluginEntry(configPath, ctx, this.pluginDir(ctx)));\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_OPENCLAW are mapped/wired; any declared\n * event with no OpenClaw mapping (e.g. UserPromptSubmit) is reported separately\n * as \"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_OPENCLAW[e] !== undefined);\n const unsupported = declared.filter((e) => EVENT_TO_OPENCLAW[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 pluginPath = this.getHookConfigPath(ctx);\n const configPath = this.getServerConfigPath(ctx);\n const changes: ChangeRecord[] = [];\n\n // 1. Remove the plugins.entries.<id> reference AND drop the plugin dir from\n // plugins.load.paths.\n changes.push(\n this.removePluginEntry(configPath, ctx.connector.id, this.pluginDir(ctx), ctx.dryRun),\n );\n\n // 2. Remove the plugin module + its manifest on disk.\n const manifestPath = join(this.pluginDir(ctx), PLUGIN_MANIFEST_FILE);\n for (const [path, label] of [\n [pluginPath, \"openclaw plugin module\"],\n [manifestPath, \"openclaw plugin manifest\"],\n ] as const) {\n if (existsSync(path)) {\n if (!ctx.dryRun) rmSync(path, { force: true });\n changes.push({ platform: this.id, action: \"remove\", path, detail: label });\n } else {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: `no ${label} present`,\n });\n }\n }\n\n // 3. Drop the now-empty plugin dir (only if WE own its full contents).\n changes.push(this.removeDirIfEmpty(this.pluginDir(ctx), ctx.dryRun));\n\n return changes;\n }\n\n /**\n * Upsert plugins.entries.<id> = { enabled: true } AND add `pluginDir` to\n * plugins.load.paths idempotently.\n *\n * `openclaw config validate` rejects a per-entry `module` field, so the entry\n * carries ONLY `{ enabled: true }`. The gateway discovers the synthesized\n * module by scanning the directories in plugins.load.paths (the dir holding\n * index.mjs + openclaw.plugin.json), so the dir is added there.\n */\n private upsertPluginEntry(\n configPath: string,\n ctx: InstallContext,\n pluginDir: string,\n ): ChangeRecord {\n // OVERWRITE GUARD: never blank a present-but-unparseable openclaw.json.\n if (this.isPresentButUnparseable(configPath)) {\n return {\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`,\n };\n }\n const cfg = this.readJson<Record<string, unknown>>(configPath) ?? {};\n const entries = this.pluginEntriesBucket(cfg);\n const id = ctx.connector.id;\n const desired: OpenClawPluginEntry = { enabled: true };\n const entryBefore = JSON.stringify(entries[id]);\n const entryAfter = JSON.stringify(desired);\n\n // plugins.load.paths: add the plugin dir if absent.\n const loadPaths = this.pluginLoadPathsBucket(cfg);\n const pathPresent = loadPaths.includes(pluginDir);\n\n const entryChanged = entryBefore !== entryAfter;\n const pathChanged = !pathPresent;\n let action: ChangeRecord[\"action\"];\n if (entryBefore === undefined) action = \"create\";\n else if (!entryChanged && !pathChanged) action = \"skip\";\n else action = \"update\";\n\n if (action !== \"skip\") {\n entries[id] = desired;\n if (!pathPresent) loadPaths.push(pluginDir);\n this.writeJson(configPath, cfg, ctx.dryRun);\n }\n return {\n platform: this.id,\n action,\n path: configPath,\n detail: `${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}.${id} + ${PLUGINS_KEY}.${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY}`,\n };\n }\n\n /** Remove plugins.entries.<id> AND drop `pluginDir` from plugins.load.paths. */\n private removePluginEntry(\n configPath: string,\n id: string,\n pluginDir: string,\n dryRun: boolean,\n ): ChangeRecord {\n const cfg = this.readJson<Record<string, unknown>>(configPath);\n const plugins = cfg?.[PLUGINS_KEY];\n const pluginsObj =\n plugins && typeof plugins === \"object\" && !Array.isArray(plugins)\n ? (plugins as Record<string, unknown>)\n : undefined;\n const entries = pluginsObj?.[PLUGINS_ENTRIES_KEY] as\n | Record<string, unknown>\n | undefined;\n const load = pluginsObj?.[PLUGINS_LOAD_KEY] as Record<string, unknown> | undefined;\n const loadPaths =\n load && Array.isArray(load[PLUGINS_LOAD_PATHS_KEY])\n ? (load[PLUGINS_LOAD_PATHS_KEY] as unknown[])\n : undefined;\n\n const entryPresent = Boolean(entries && id in entries);\n const pathIdx = loadPaths ? loadPaths.indexOf(pluginDir) : -1;\n\n if (!cfg || (!entryPresent && pathIdx < 0)) {\n return {\n platform: this.id,\n action: \"skip\",\n path: configPath,\n detail: `${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}.${id} absent`,\n };\n }\n if (entryPresent && entries) delete entries[id];\n if (loadPaths && pathIdx >= 0) loadPaths.splice(pathIdx, 1);\n this.writeJson(configPath, cfg, dryRun);\n return {\n platform: this.id,\n action: \"remove\",\n path: configPath,\n detail: `${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}.${id} + ${PLUGINS_KEY}.${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY}`,\n };\n }\n\n /** Get-or-create config.plugins.entries as a mutable object. */\n private pluginEntriesBucket(cfg: Record<string, unknown>): Record<string, unknown> {\n let plugins = cfg[PLUGINS_KEY];\n if (!plugins || typeof plugins !== \"object\" || Array.isArray(plugins)) {\n plugins = {};\n cfg[PLUGINS_KEY] = plugins;\n }\n const pluginsObj = plugins as Record<string, unknown>;\n let entries = pluginsObj[PLUGINS_ENTRIES_KEY];\n if (!entries || typeof entries !== \"object\" || Array.isArray(entries)) {\n entries = {};\n pluginsObj[PLUGINS_ENTRIES_KEY] = entries;\n }\n return entries as Record<string, unknown>;\n }\n\n /** Get-or-create config.plugins.load.paths as a mutable string array. */\n private pluginLoadPathsBucket(cfg: Record<string, unknown>): string[] {\n let plugins = cfg[PLUGINS_KEY];\n if (!plugins || typeof plugins !== \"object\" || Array.isArray(plugins)) {\n plugins = {};\n cfg[PLUGINS_KEY] = plugins;\n }\n const pluginsObj = plugins as Record<string, unknown>;\n let load = pluginsObj[PLUGINS_LOAD_KEY];\n if (!load || typeof load !== \"object\" || Array.isArray(load)) {\n load = {};\n pluginsObj[PLUGINS_LOAD_KEY] = load;\n }\n const loadObj = load as Record<string, unknown>;\n const existing = loadObj[PLUGINS_LOAD_PATHS_KEY];\n // Normalize to a fresh string[] (drop any non-string a user may have placed\n // here) and write it back so the caller mutates the live array.\n const paths = Array.isArray(existing)\n ? existing.filter((p): p is string => typeof p === \"string\")\n : [];\n loadObj[PLUGINS_LOAD_PATHS_KEY] = paths;\n return paths;\n }\n\n // ── Content surface: skills (dir-per-skill SKILL.md) ────────────────────\n // CONTENT-ONLY: pure native-file writers, mirroring codex/claude-code\n // installSkills + renderSkill. No runtime dispatch, no home-bin pointer, no\n // telemetry wrap. Each write is idempotent (byte-identical → skip) via\n // writeContentFile and reversible via removeContentFile + removeDirIfEmpty\n // (never rm -rf a shared dir). Honors platforms[\"openclaw\"].skills === false.\n //\n // Native locations (AgentSkills spec — dir-per-skill SKILL.md + resources):\n // user → ~/.openclaw/skills/<name>/SKILL.md (`openclaw skills install\n // --global` targets this dir)\n // project → <workspace>/skills/<name>/SKILL.md (the highest-priority\n // documented skill root; <workspace> is the SAME root the memory\n // surface resolves, so both content surfaces stay consistent).\n\n /**\n * Per-skill directory for ctx.scope:\n * user → ~/.openclaw/skills/<name> (`--global` install target)\n * project → <workspace>/skills/<name> (resolved agent workspace —\n * consistent with this adapter's memoryTargets resolution).\n */\n private skillDir(ctx: InstallContext, name: string): string {\n const base =\n ctx.scope === \"project\"\n ? join(this.resolveWorkspace(), \"skills\")\n : join(dirname(resolveOpenClawConfigPath()), \"skills\");\n return join(base, name);\n }\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 ${this.id}` }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /**\n * Render a skill's SKILL.md: frontmatter (name, description + optional model,\n * allowed-tools, disable-model-invocation) + body. UNIFORM with codex /\n * claude-code — only the parent dir differs (single-line frontmatter keys;\n * OpenClaw follows the AgentSkills spec).\n */\n private renderSkill(skill: SkillDef): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.model !== undefined) frontmatter.model = skill.model;\n const allow = skill.tools?.allow;\n if (allow && allow.length > 0) frontmatter[\"allowed-tools\"] = allow.join(\", \");\n if (skill.disableModelInvocation !== undefined) {\n frontmatter[\"disable-model-invocation\"] = skill.disableModelInvocation;\n }\n if (skill.extra) Object.assign(frontmatter, skill.extra);\n return this.renderFrontmatterMd(frontmatter, skill.body);\n }\n\n // ── ts-plugin synthesis ────────────────────────────────────────────────\n\n /**\n * Build ONE self-contained ESM plugin module for OpenClaw.\n *\n * The module imports nothing from agent-connector. It embeds two constants\n * (the absolute home-bin path and the connector id) and a `bridge()` helper\n * that shells out to the universal hook entrypoint via execFileSync, feeding\n * the OpenClaw event payload on stdin and JSON.parsing the normalized\n * HookResponse back from stdout (fail-open: any error → null). Its default\n * export is the OpenClaw plugin definition { id, name, configSchema,\n * register(api) }; register wires api.on(...) handlers for the events this\n * connector actually declares.\n */\n synthesizePlugin(ctx: InstallContext): GeneratedPluginFile[] {\n const path = this.getHookConfigPath(ctx);\n const contents = this.buildPluginSource(ctx);\n // The gateway scans plugins.load.paths dirs for a manifest, so emit an\n // openclaw.plugin.json beside index.mjs pointing at the module entry.\n const manifestPath = join(this.pluginDir(ctx), PLUGIN_MANIFEST_FILE);\n const manifest = this.buildPluginManifest(ctx);\n return [\n { path, contents, executable: false },\n { path: manifestPath, contents: manifest, executable: false },\n ];\n }\n\n /**\n * Build the openclaw.plugin.json manifest the gateway reads inside a\n * plugins.load.paths directory. It names the plugin and points at the ESM\n * module entry (index.mjs) so the loader knows what to import.\n */\n private buildPluginManifest(ctx: InstallContext): string {\n const manifest = {\n id: ctx.connector.id,\n name: ctx.connector.displayName || ctx.connector.id,\n main: this.pluginFileName(),\n enabled: true,\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 const connectorName = JSON.stringify(ctx.connector.displayName || ctx.connector.id);\n\n // `platforms[host].hooks === false` disables the CANONICAL events. The\n // plugin module may still be synthesized for ACTIONS (installActions writes\n // it independently of hooks), so the canonical handler set collapses to []\n // here rather than letting a live before_tool_call/after_tool_call gate leak\n // into a hooks-disabled plugin. Mirrors omp/opencode. Uses this.id so the\n // NemoClaw fork checks platforms.nemoclaw.hooks.\n const canonicalOff = ctx.connector.platforms[this.id]?.hooks === false;\n const events = canonicalOff\n ? []\n : ctx.connector.hookEvents.filter(\n (e): e is HookEventName => EVENT_TO_OPENCLAW[e] !== undefined,\n );\n const has = (e: HookEventName) => events.includes(e);\n\n const header =\n \"/**\\n\" +\n \" * AUTO-GENERATED by agent-connector — DO NOT EDIT.\\n\" +\n \" *\\n\" +\n \" * Self-contained OpenClaw plugin bridge for connector \" +\n ctx.connector.id +\n \".\\n\" +\n \" * It imports nothing from agent-connector: every hook invocation shells out\\n\" +\n \" * to the stable home binary's universal entrypoint and JSON-parses the\\n\" +\n \" * normalized response. Fail-open: any bridge error degrades to a no-op.\\n\" +\n \" *\\n\" +\n \" * Registered via DUAL REGISTRATION in openclaw.json: plugins.entries.<id>\\n\" +\n \" * (loads this module) + mcp.servers.<id> (surfaces the MCP tools). The\\n\" +\n \" * gateway hot-reloads its config on SIGUSR1.\\n\" +\n \" */\\n\" +\n 'import { execFileSync, execSync } from \"node:child_process\";\\n\\n' +\n \"const HOME_BIN = \" +\n homeBin +\n \";\\n\" +\n \"const CONNECTOR_ID = \" +\n connectorId +\n \";\\n\\n\" +\n \"/**\\n\" +\n \" * Invoke the universal hook entrypoint for one canonical event.\\n\" +\n \" * @param {string} event canonical event name\\n\" +\n \" * (PreToolUse|PostToolUse|SessionStart|SubagentStart|SubagentStop)\\n\" +\n \" * @param {object} payload OpenClaw-shaped payload posted on stdin\\n\" +\n \" * @returns {object|null} normalized HookResponse, or null on any failure\\n\" +\n \" */\\n\" +\n \"function bridge(event, payload) {\\n\" +\n \" try {\\n\" +\n \" // On Windows HOME_BIN is the agent-connector.cmd launcher: Node cannot\\n\" +\n \" // execFile a batch file, and shell+args is deprecated (DEP0190), so run\\n\" +\n \" // one quoted command line via a shell. POSIX keeps the direct execFile.\\n\" +\n ' const args = [\"hook\", ' + JSON.stringify(this.id) + ', event, \"--connector\", CONNECTOR_ID];\\n' +\n ' const opts = { input: JSON.stringify(payload), encoding: \"utf8\" };\\n' +\n \" const stdout =\\n\" +\n ' process.platform === \"win32\"\\n' +\n \" ? execSync([HOME_BIN, ...args].map((a) => '\\\"' + a + '\\\"').join(\\\" \\\"), opts)\\n\" +\n \" : execFileSync(HOME_BIN, args, opts);\\n\" +\n ' const text = (stdout || \"\").trim();\\n' +\n ' if (text === \"\") return { decision: \"allow\" };\\n' +\n \" return JSON.parse(text);\\n\" +\n \" } catch {\\n\" +\n \" // Fail-open — never wedge a tool call on a bridge error.\\n\" +\n \" return null;\\n\" +\n \" }\\n\" +\n \"}\\n\\n\" +\n \"// Module-scoped context the prompt-build hook injects at session start.\\n\" +\n \"// before_prompt_build is the verified injection point (session_start itself\\n\" +\n \"// returns no context payload). The flag prevents double-injection.\\n\" +\n \"let PROJECT_DIR = process.cwd();\\n\" +\n \"let SESSION_ID = \\\"\\\";\\n\" +\n \"let pendingContext = null;\\n\" +\n \"let contextInjected = false;\\n\\n\";\n\n // register(api) body — wire only the handlers this connector declares.\n const reg: string[] = [];\n\n reg.push(\n \" register(api) {\\n\" +\n \" PROJECT_DIR = process.cwd();\\n\" +\n \" const on = (event, handler) => {\\n\" +\n ' if (typeof api?.on === \"function\") {\\n' +\n \" try { api.on(event, handler); return; } catch { /* fall through */ }\\n\" +\n \" }\\n\" +\n ' if (typeof api?.registerHook === \"function\") {\\n' +\n \" try {\\n\" +\n ' api.registerHook(event, handler, { name: CONNECTOR_ID + \":\" + event, description: \"agent-connector bridge\" });\\n' +\n \" } catch { /* best effort */ }\\n\" +\n \" }\\n\" +\n \" };\\n\",\n );\n\n if (has(\"PreToolUse\")) {\n reg.push(\n \"\\n\" +\n \" // PreToolUse → before_tool_call: block (return { block, blockReason })\\n\" +\n \" // for deny/ask; rewrite args by mutating event.params in place for modify.\\n\" +\n ' on(\"before_tool_call\", async (event) => {\\n' +\n \" const e = event || {};\\n\" +\n \" const toolInput = e.params || {};\\n\" +\n \" const res = bridge(\\\"PreToolUse\\\", {\\n\" +\n ' toolName: e.toolName || \"\",\\n' +\n \" toolInput,\\n\" +\n \" sessionId: SESSION_ID,\\n\" +\n \" projectDir: PROJECT_DIR,\\n\" +\n \" });\\n\" +\n \" if (!res) return undefined;\\n\" +\n \" // OpenClaw has no separate ask gate — deny and ask both block (safe).\\n\" +\n ' if (res.decision === \"deny\" || res.decision === \"ask\") {\\n' +\n ' return { block: true, blockReason: res.reason || (\"Blocked by \" + CONNECTOR_ID) };\\n' +\n \" }\\n\" +\n ' if (res.decision === \"modify\" && res.updatedInput && typeof toolInput === \"object\") {\\n' +\n \" Object.assign(toolInput, res.updatedInput);\\n\" +\n \" }\\n\" +\n \" return undefined;\\n\" +\n \" });\\n\",\n );\n }\n\n if (has(\"PostToolUse\")) {\n reg.push(\n \"\\n\" +\n \" // PostToolUse → after_tool_call: observe the completed tool call.\\n\" +\n \" // OpenClaw exposes the result (v2+) or output (older builds); it cannot\\n\" +\n \" // rewrite the tool result, so updatedOutput is intentionally dropped.\\n\" +\n ' on(\"after_tool_call\", async (event) => {\\n' +\n \" const e = event || {};\\n\" +\n \" const rawResult = e.result !== undefined ? e.result : e.output;\\n\" +\n \" const toolOutput =\\n\" +\n ' typeof rawResult === \"string\"\\n' +\n \" ? rawResult\\n\" +\n \" : rawResult != null\\n\" +\n \" ? JSON.stringify(rawResult)\\n\" +\n \" : undefined;\\n\" +\n \" bridge(\\\"PostToolUse\\\", {\\n\" +\n ' toolName: e.toolName || \"\",\\n' +\n \" toolInput: e.params || {},\\n\" +\n \" toolOutput,\\n\" +\n \" isError: Boolean(e.error || e.isError),\\n\" +\n \" sessionId: SESSION_ID,\\n\" +\n \" projectDir: PROJECT_DIR,\\n\" +\n \" });\\n\" +\n \" return undefined;\\n\" +\n \" });\\n\",\n );\n }\n\n if (has(\"SubagentStart\")) {\n reg.push(\n \"\\n\" +\n \" // SubagentStart → subagent_spawned: observe-only (OpenClaw exposes no\\n\" +\n \" // decision or context-injection payload for subagent launches). Field\\n\" +\n \" // names vary across builds, so the common variants are normalized;\\n\" +\n \" // empty values are omitted so the dispatcher never matcher-filters on\\n\" +\n ' // an empty agent type (fail-open).\\n' +\n ' on(\"subagent_spawned\", async (event) => {\\n' +\n \" const e = event || {};\\n\" +\n \" bridge(\\\"SubagentStart\\\", {\\n\" +\n \" agentId: e.agentId || e.subagentId || undefined,\\n\" +\n \" agentType: e.agentType || e.subagentType || e.agent || undefined,\\n\" +\n \" sessionId: SESSION_ID,\\n\" +\n \" projectDir: PROJECT_DIR,\\n\" +\n \" });\\n\" +\n \" return undefined;\\n\" +\n \" });\\n\",\n );\n }\n\n if (has(\"SubagentStop\")) {\n reg.push(\n \"\\n\" +\n \" // SubagentStop → subagent_ended: observe-only completion. A normalized\\n\" +\n \" // 'deny' cannot keep the subagent running on OpenClaw, so the bridge\\n\" +\n \" // reply is intentionally ignored.\\n\" +\n ' on(\"subagent_ended\", async (event) => {\\n' +\n \" const e = event || {};\\n\" +\n \" const rawResult = e.result !== undefined ? e.result : e.output;\\n\" +\n \" bridge(\\\"SubagentStop\\\", {\\n\" +\n \" agentId: e.agentId || e.subagentId || undefined,\\n\" +\n \" agentType: e.agentType || e.subagentType || e.agent || undefined,\\n\" +\n \" lastAssistantMessage:\\n\" +\n ' typeof rawResult === \"string\" && rawResult !== \"\" ? rawResult : undefined,\\n' +\n \" sessionId: SESSION_ID,\\n\" +\n \" projectDir: PROJECT_DIR,\\n\" +\n \" });\\n\" +\n \" return undefined;\\n\" +\n \" });\\n\",\n );\n }\n\n if (has(\"SessionStart\")) {\n reg.push(\n \"\\n\" +\n \" // SessionStart → session_start records the real session id and fetches\\n\" +\n \" // the additionalContext to inject; before_prompt_build performs the\\n\" +\n \" // injection (the verified context-injection point upstream).\\n\" +\n ' on(\"session_start\", async (event) => {\\n' +\n \" const e = event || {};\\n\" +\n \" SESSION_ID = e.sessionId || e.sessionKey || SESSION_ID;\\n\" +\n \" const res = bridge(\\\"SessionStart\\\", {\\n\" +\n \" sessionId: SESSION_ID,\\n\" +\n ' source: e.resumedFrom ? \"resume\" : \"startup\",\\n' +\n \" projectDir: PROJECT_DIR,\\n\" +\n \" });\\n\" +\n \" contextInjected = false;\\n\" +\n \" pendingContext =\\n\" +\n ' res && typeof res.additionalContext === \"string\" && res.additionalContext\\n' +\n \" ? res.additionalContext\\n\" +\n \" : null;\\n\" +\n \" return undefined;\\n\" +\n \" });\\n\" +\n \"\\n\" +\n \" // Inject the session-start context once, at prompt-build time.\\n\" +\n ' on(\"before_prompt_build\", () => {\\n' +\n \" if (contextInjected || !pendingContext) return undefined;\\n\" +\n \" contextInjected = true;\\n\" +\n \" return { appendSystemContext: pendingContext };\\n\" +\n \" });\\n\",\n );\n }\n\n // Action surface: one api.registerCommand per declared action, registered in\n // the SAME register(api) body. The command shells out to the home-bin\n // `action <host>` verb with the host token baked as this.id (so a NemoClaw\n // fork emits `action nemoclaw`, NOT openclaw — exactly like the hook bridge\n // above). The win32 branch reuses the hook bridge's quoted-shell form (a .cmd\n // launcher throws EINVAL via execFileSync). Both id AND description are\n // JSON.stringify'd — descriptions are free-form connector text, so a raw \" /\n // backtick would break the generated module.\n for (const action of this.actionTriggers(ctx)) {\n const id = JSON.stringify(action.id);\n const description = JSON.stringify(action.description);\n reg.push(\n \"\\n\" +\n \" // Action /\" + action.id + \" -> run the home-bin action verb directly.\\n\" +\n \" api.registerCommand({\\n\" +\n \" name: \" + id + \",\\n\" +\n \" description: \" + description + \",\\n\" +\n \" handler: async (_ctx) => {\\n\" +\n \" try {\\n\" +\n ' const args = [\"action\", ' + JSON.stringify(this.id) + \", \" + id + ', \"--connector\", CONNECTOR_ID];\\n' +\n \" const out =\\n\" +\n ' process.platform === \"win32\"\\n' +\n \" ? execSync([HOME_BIN, ...args].map((a) => '\\\"' + a + '\\\"').join(\\\" \\\"), { encoding: \\\"utf8\\\" })\\n\" +\n ' : execFileSync(HOME_BIN, args, { encoding: \"utf8\" });\\n' +\n ' return { text: (out || \"\").trim() };\\n' +\n \" } catch (e) {\\n\" +\n \" return { text: \\\"action \\\" + \" + id + \" + \\\" failed: \\\" + (e && e.message ? e.message : \\\"error\\\") };\\n\" +\n \" }\\n\" +\n \" },\\n\" +\n \" });\\n\",\n );\n }\n\n reg.push(\" },\\n\");\n\n const definition =\n \"const plugin = {\\n\" +\n \" id: CONNECTOR_ID,\\n\" +\n \" name: \" +\n connectorName +\n \",\\n\" +\n \" configSchema: {\\n\" +\n ' type: \"object\",\\n' +\n \" properties: {\\n\" +\n \" enabled: {\\n\" +\n ' type: \"boolean\",\\n' +\n \" default: true,\\n\" +\n ' description: \"Enable or disable the \" + CONNECTOR_ID + \" plugin.\",\\n' +\n \" },\\n\" +\n \" },\\n\" +\n \" additionalProperties: false,\\n\" +\n \" },\\n\" +\n reg.join(\"\") +\n \"};\\n\\n\" +\n \"export default plugin;\\n\";\n\n return header + definition;\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, source?, projectDir }\n * so this maps straight through.\n */\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as OpenClawBridgePayload;\n const base = {\n hostPlatform: this.id,\n connectorId: \"\",\n sessionId: typeof input.sessionId === \"string\" ? input.sessionId : \"\",\n raw,\n ...(typeof input.projectDir === \"string\" ? { projectDir: input.projectDir } : {}),\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\" ? { toolOutput: input.toolOutput } : {}),\n ...(typeof input.isError === \"boolean\" ? { isError: input.isError } : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const source: SessionStartEvent[\"source\"] =\n input.source === \"resume\"\n ? \"resume\"\n : input.source === \"compact\"\n ? \"compact\"\n : input.source === \"clear\"\n ? \"clear\"\n : \"startup\";\n const ev: SessionStartEvent = { ...base, source };\n return ev;\n }\n case \"SubagentStart\": {\n // Empty strings are dropped so the runtime matcher never filters a\n // real spawn on an unknown agent type (fail-open, per the dispatcher).\n const ev: SubagentStartEvent = {\n ...base,\n ...(isNonEmptyString(input.agentId) ? { agentId: input.agentId } : {}),\n ...(isNonEmptyString(input.agentType)\n ? { agentType: input.agentType }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n const ev: SubagentStopEvent = {\n ...base,\n ...(isNonEmptyString(input.agentId) ? { agentId: input.agentId } : {}),\n ...(isNonEmptyString(input.agentType)\n ? { agentType: input.agentType }\n : {}),\n ...(isNonEmptyString(input.lastAssistantMessage)\n ? { lastAssistantMessage: input.lastAssistantMessage }\n : {}),\n };\n return ev;\n }\n default:\n // Other canonical events are not surfaced by OpenClaw; 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 reads\n * decision / updatedInput / additionalContext.\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 configPath = this.getServerConfigPath(ctx);\n const pluginPath = this.getHookConfigPath(ctx);\n const pluginDir = this.pluginDir(ctx);\n const id = ctx.connector.id;\n // Actions are health-equivalent to hooks: both write the SAME plugin module\n // and the SAME dual-registration entry, so an actions-only connector must\n // still assert the plugin/extension is present + loaded.\n const hasHooks =\n ctx.connector.hookEvents.length > 0 || this.actionTriggers(ctx).length > 0;\n const hasServer = Boolean(ctx.connector.server);\n\n return [\n {\n name: `${this.name}: openclaw.json present`,\n check: () =>\n existsSync(configPath)\n ? { status: \"OK\", detail: configPath }\n : { status: \"FAIL\", detail: `not found: ${configPath}` },\n },\n {\n // HARDEST PART — dual registration must be CONSISTENT. The plugin only\n // delivers tools when it is LOADED (plugins.entries.<id> enabled AND its\n // dir in plugins.load.paths) AND in mcp.servers. A config with one half\n // but not the other is a tool-less (or never-loaded) install, so FAIL on\n // loaded XOR mcp.servers. (We assert plugins.load.paths — NOT a per-entry\n // `module` field, which openclaw config validate rejects.)\n name: `${this.name}: dual registration (plugins.entries+load.paths + mcp.servers.${id})`,\n check: () => {\n // Only assert what the connector declares: a catalog-only connector\n // (no MCP server, no hooks) never writes either half of the dual\n // registration, so absence — even of the config file — is healthy.\n if (!hasServer && !hasHooks) {\n return { status: \"OK\", detail: \"no MCP server or hooks declared\" };\n }\n const cfg = this.readJson<Record<string, unknown>>(configPath);\n if (!cfg) return { status: \"FAIL\", detail: `cannot read ${configPath}` };\n\n const inEntries = this.hasPluginEntry(cfg, id) && this.hasLoadPath(cfg, pluginDir);\n const inMcp = this.hasMcpServer(cfg, id);\n\n // A hooks-only connector (no MCP server declared) does not need the\n // mcp.servers half — the load half alone is correct and complete.\n if (!hasServer) {\n return inEntries || !hasHooks\n ? { status: \"OK\", detail: \"hooks-only connector (no MCP server)\" }\n : {\n status: \"FAIL\",\n detail: `${id} not enabled in ${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY} + ${PLUGINS_KEY}.${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY} (plugin will not load)`,\n };\n }\n\n if (inEntries && inMcp) {\n return {\n status: \"OK\",\n detail: `${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}.${id}+${PLUGINS_KEY}.${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY} + ${MCP_ROOT_KEY}.${MCP_SERVERS_KEY}.${id}`,\n };\n }\n if (inEntries && !inMcp) {\n return {\n status: \"FAIL\",\n detail: `loaded (${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}+${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY}) but missing from ${MCP_ROOT_KEY}.${MCP_SERVERS_KEY} — plugin loads but no tools reach the agent`,\n };\n }\n if (!inEntries && inMcp) {\n return {\n status: \"FAIL\",\n detail: `in ${MCP_ROOT_KEY}.${MCP_SERVERS_KEY} but not loaded (missing ${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY} or ${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY}) — tools declared but plugin never loads`,\n };\n }\n return {\n status: \"FAIL\",\n detail: `not loaded (${PLUGINS_KEY}.${PLUGINS_ENTRIES_KEY}+${PLUGINS_LOAD_KEY}.${PLUGINS_LOAD_PATHS_KEY}) and not in ${MCP_ROOT_KEY}.${MCP_SERVERS_KEY}`,\n };\n },\n },\n {\n name: `${this.name}: plugin module present`,\n check: () => {\n if (!hasHooks) return { status: \"OK\", detail: \"no hooks declared\" };\n return existsSync(pluginPath)\n ? { status: \"OK\", detail: pluginPath }\n : { status: \"FAIL\", detail: `not found: ${pluginPath}` };\n },\n },\n ];\n }\n\n /** True when config.plugins.entries.<id> exists (and is not disabled). */\n private hasPluginEntry(cfg: Record<string, unknown>, id: string): boolean {\n const plugins = cfg[PLUGINS_KEY];\n if (!plugins || typeof plugins !== \"object\" || Array.isArray(plugins)) return false;\n const entries = (plugins as Record<string, unknown>)[PLUGINS_ENTRIES_KEY];\n if (!entries || typeof entries !== \"object\" || Array.isArray(entries)) return false;\n const entry = (entries as Record<string, unknown>)[id];\n if (entry === undefined) return false;\n // An explicit { enabled: false } means the gateway will not load it.\n return !(\n entry &&\n typeof entry === \"object\" &&\n (entry as Record<string, unknown>).enabled === false\n );\n }\n\n /** True when config.plugins.load.paths includes `pluginDir`. */\n private hasLoadPath(cfg: Record<string, unknown>, pluginDir: string): boolean {\n const plugins = cfg[PLUGINS_KEY];\n if (!plugins || typeof plugins !== \"object\" || Array.isArray(plugins)) return false;\n const load = (plugins as Record<string, unknown>)[PLUGINS_LOAD_KEY];\n if (!load || typeof load !== \"object\" || Array.isArray(load)) return false;\n const paths = (load as Record<string, unknown>)[PLUGINS_LOAD_PATHS_KEY];\n return Array.isArray(paths) && paths.includes(pluginDir);\n }\n\n /** True when config.mcp.servers.<id> exists. */\n private hasMcpServer(cfg: Record<string, unknown>, id: string): boolean {\n const mcp = cfg[MCP_ROOT_KEY];\n if (!mcp || typeof mcp !== \"object\" || Array.isArray(mcp)) return false;\n const servers = (mcp as Record<string, unknown>)[MCP_SERVERS_KEY];\n if (!servers || typeof servers !== \"object\" || Array.isArray(servers)) return false;\n return id in (servers as Record<string, unknown>);\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/**\n * Resolve the openclaw.json the gateway actually loads (mirrors context-mode's\n * openclawConfigPath): $OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,\n * else ~/.openclaw/openclaw.json. The gateway never loads a CWD/project-local\n * openclaw.json for user scope, so this is the canonical user-scope path.\n */\nfunction resolveOpenClawConfigPath(env: NodeJS.ProcessEnv = process.env): string {\n if (env.OPENCLAW_CONFIG_PATH) return resolve(env.OPENCLAW_CONFIG_PATH);\n const stateDir = env.OPENCLAW_STATE_DIR\n ? resolve(env.OPENCLAW_STATE_DIR)\n : resolve(homedir(), \".openclaw\");\n return resolve(stateDir, \"openclaw.json\");\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\n/** Narrow to a non-empty string (the bridge omits empties, but stay defensive). */\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nexport const adapter = new OpenClawAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;AAsFA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,SAAS,MAAM,eAAe;AAmCvC,IAAM,OAAmB;AAOzB,IAAM,eAAe;AACrB,IAAM,kBAAkB;AACxB,IAAM,cAAc;AACpB,IAAM,sBAAsB;AAM5B,IAAM,mBAAmB;AACzB,IAAM,yBAAyB;AAE/B,IAAM,uBAAuB;AAU7B,IAAM,oBAA4D;AAAA,EAChE,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,eAAe;AAAA,EACf,cAAc;AAChB;AAoDO,IAAM,kBAAN,cAA8B,YAA+B;AAAA,EACzD,KAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,OAAe;AAAA,EACf,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5C,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,aAAa;AAAA;AAAA;AAAA,IAGb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQd,eAAe;AAAA,IACf,cAAc;AAAA;AAAA,IAEd,eAAe;AAAA;AAAA,IAEf,iBAAiB;AAAA;AAAA,IAEjB,yBAAyB;AAAA;AAAA;AAAA;AAAA,IAIzB,YAAY,CAAC,SAAS,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMnC,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMhB,iBAAiB;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA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