@runfusion/fusion 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/bin.js +27921 -21003
  2. package/dist/client/assets/AgentDetailView-BwJaLqZh.css +1 -0
  3. package/dist/client/assets/AgentDetailView-ZbHEbYRT.js +18 -0
  4. package/dist/client/assets/AgentsView-B3jYk8Kt.js +29 -0
  5. package/dist/client/assets/{AgentsView-DSGQWObq.css → AgentsView-CV3vm7Qk.css} +1 -1
  6. package/dist/client/assets/ChatView-DhPkiEGs.js +1 -0
  7. package/dist/client/assets/ChatView-DwJAd5G1.css +1 -0
  8. package/dist/client/assets/{DevServerView-C9lzHrcT.js → DevServerView-DyGDEiBP.js} +1 -1
  9. package/dist/client/assets/{DirectoryPicker-aVdFaV37.js → DirectoryPicker-D5UIeIl6.js} +1 -1
  10. package/dist/client/assets/{DocumentsView-DIpg3NSP.js → DocumentsView-DNHu1T8K.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-BrhyOdeE.css → DocumentsView-gv4zG3aT.css} +1 -1
  12. package/dist/client/assets/EvalsView-CUNJ1TLc.css +1 -0
  13. package/dist/client/assets/EvalsView-CpRobtDi.js +1 -0
  14. package/dist/client/assets/{agentSkills-DDHJnrkn.css → ExperimentalAgentOnboardingModal-B-APN_lM.css} +1 -1
  15. package/dist/client/assets/ExperimentalAgentOnboardingModal-DOY_oZi7.js +499 -0
  16. package/dist/client/assets/InsightsView-B0J4mhzV.css +1 -0
  17. package/dist/client/assets/InsightsView-vp0RE8Mg.js +11 -0
  18. package/dist/client/assets/MemoryView-PSc5lGJt.js +2 -0
  19. package/dist/client/assets/MemoryView-zaXewZzi.css +1 -0
  20. package/dist/client/assets/NodesView-DMj6HGeC.js +14 -0
  21. package/dist/client/assets/NodesView-DT4pXowv.css +1 -0
  22. package/dist/client/assets/{PiExtensionsManager-Buopv-jb.js → PiExtensionsManager-DL_QcN56.js} +2 -2
  23. package/dist/client/assets/PluginManager-BtYKm8IT.js +1 -0
  24. package/dist/client/assets/PluginManager-DtRQXia5.css +1 -0
  25. package/dist/client/assets/{ResearchView-_BHXUv2j.js → ResearchView-BhWqfdV0.js} +1 -1
  26. package/dist/client/assets/SettingsModal-BAgB4_AR.js +31 -0
  27. package/dist/client/assets/SettingsModal-CUCyaAyE.js +1 -0
  28. package/dist/client/assets/SettingsModal-DzsLquBu.css +1 -0
  29. package/dist/client/assets/SetupWizardModal-BKscasuh.js +1 -0
  30. package/dist/client/assets/{SkillsView-hDpTBdFT.js → SkillsView-BdELqTy7.js} +1 -1
  31. package/dist/client/assets/TodoView-Cx9cVhq7.css +1 -0
  32. package/dist/client/assets/TodoView-DFNGBDNV.js +6 -0
  33. package/dist/client/assets/{folder-open-usZkXdq2.js → folder-open-k1xmUMyr.js} +1 -1
  34. package/dist/client/assets/index-Qq2JOOWx.css +1 -0
  35. package/dist/client/assets/index-TFYXEVpn.js +692 -0
  36. package/dist/client/assets/projectDetection-G3XuxD2X.js +1 -0
  37. package/dist/client/assets/{star-BAT_ObKE.js → star-ne32r3Y4.js} +1 -1
  38. package/dist/client/assets/{upload-BC2YKNEV.js → upload-MS-2Gx53.js} +1 -1
  39. package/dist/client/assets/{users-Dkd4rtrN.js → users-C519GSjH.js} +1 -1
  40. package/dist/client/index.html +12 -20
  41. package/dist/client/theme-data.css +106 -0
  42. package/dist/client/version.json +1 -1
  43. package/dist/droid-cli/package.json +1 -1
  44. package/dist/extension.js +15395 -9935
  45. package/dist/pi-claude-cli/package.json +1 -1
  46. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +216 -0
  47. package/dist/plugins/fusion-plugin-cursor-runtime/manifest.json +6 -0
  48. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +11 -0
  49. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +30 -0
  50. package/dist/plugins/fusion-plugin-dependency-graph/manifest.json +1 -1
  51. package/dist/plugins/fusion-plugin-dependency-graph/package.json +3 -26
  52. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +136684 -0
  53. package/dist/plugins/fusion-plugin-droid-runtime/manifest.json +13 -0
  54. package/dist/plugins/fusion-plugin-droid-runtime/mcp-schema-server.cjs +49 -0
  55. package/dist/plugins/fusion-plugin-droid-runtime/package.json +11 -0
  56. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +68 -71
  57. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  58. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +137 -53
  59. package/dist/plugins/fusion-plugin-openclaw-runtime/mcp-schema-server.cjs +59 -0
  60. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  61. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +155 -109
  62. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  63. package/dist/plugins/fusion-plugin-reports/manifest.json +33 -0
  64. package/dist/plugins/fusion-plugin-reports/package.json +26 -0
  65. package/dist/plugins/fusion-plugin-reports/src/__tests__/manifest.test.ts +51 -0
  66. package/dist/plugins/fusion-plugin-reports/src/__tests__/review-panel.test.ts +166 -0
  67. package/dist/plugins/fusion-plugin-reports/src/__tests__/settings.test.ts +157 -0
  68. package/dist/plugins/fusion-plugin-reports/src/index.ts +87 -0
  69. package/dist/plugins/fusion-plugin-reports/src/report-schema.ts +38 -0
  70. package/dist/plugins/fusion-plugin-reports/src/review-panel.ts +294 -0
  71. package/dist/plugins/fusion-plugin-reports/src/review-types.ts +75 -0
  72. package/dist/plugins/fusion-plugin-reports/src/settings.ts +105 -0
  73. package/dist/plugins/fusion-plugin-reports/src/store/__tests__/report-schema.test.ts +66 -0
  74. package/dist/plugins/fusion-plugin-reports/src/store/__tests__/report-store.test.ts +177 -0
  75. package/dist/plugins/fusion-plugin-reports/src/store/report-store.ts +341 -0
  76. package/dist/plugins/fusion-plugin-reports/src/store/report-types.ts +77 -0
  77. package/dist/plugins/fusion-plugin-roadmap/manifest.json +16 -0
  78. package/dist/plugins/fusion-plugin-roadmap/package.json +48 -0
  79. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/api-client.test.ts +101 -0
  80. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/index.test.ts +92 -0
  81. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/roadmap-routes.test.ts +48 -0
  82. package/dist/plugins/fusion-plugin-roadmap/src/__tests__/roadmap-suggestions.test.ts +31 -0
  83. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/RoadmapsView.css +1299 -0
  84. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/RoadmapsView.tsx +2559 -0
  85. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/__tests__/RoadmapsView.test.tsx +1144 -0
  86. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/__tests__/useRoadmaps.test.ts +1756 -0
  87. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/api.ts +70 -0
  88. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/test-setup.ts +7 -0
  89. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/types.ts +1 -0
  90. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useConfirm.ts +8 -0
  91. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useRoadmaps.ts +1188 -0
  92. package/dist/plugins/fusion-plugin-roadmap/src/dashboard/useViewportMode.ts +20 -0
  93. package/dist/plugins/fusion-plugin-roadmap/src/dashboard-view.tsx +6 -0
  94. package/dist/plugins/fusion-plugin-roadmap/src/index.ts +74 -0
  95. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-routes.ts +1 -0
  96. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-schema.ts +41 -0
  97. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-suggestions.d.ts +15 -0
  98. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-suggestions.ts +15 -0
  99. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.d.ts +283 -0
  100. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.d.ts.map +1 -0
  101. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.js +21 -0
  102. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.js.map +1 -0
  103. package/dist/plugins/fusion-plugin-roadmap/src/roadmap-types.ts +310 -0
  104. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.d.ts +5 -0
  105. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.d.ts.map +1 -0
  106. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.js +361 -0
  107. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.js.map +1 -0
  108. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-routes.ts +408 -0
  109. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.d.ts +68 -0
  110. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.d.ts.map +1 -0
  111. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.js +300 -0
  112. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.js.map +1 -0
  113. package/dist/plugins/fusion-plugin-roadmap/src/routes/roadmap-suggestions.ts +381 -0
  114. package/dist/plugins/fusion-plugin-roadmap/src/server/index.d.ts +3 -0
  115. package/dist/plugins/fusion-plugin-roadmap/src/server/index.ts +1 -0
  116. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-handoff.test.ts +445 -0
  117. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-ordering.test.ts +334 -0
  118. package/dist/plugins/fusion-plugin-roadmap/src/store/__tests__/roadmap-store.test.ts +1318 -0
  119. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-handoff.ts +163 -0
  120. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.d.ts +37 -0
  121. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.d.ts.map +1 -0
  122. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.js +188 -0
  123. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.js.map +1 -0
  124. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-ordering.ts +311 -0
  125. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.d.ts +299 -0
  126. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.d.ts.map +1 -0
  127. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.js +765 -0
  128. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.js.map +1 -0
  129. package/dist/plugins/fusion-plugin-roadmap/src/store/roadmap-store.ts +1001 -0
  130. package/dist/plugins/fusion-plugin-whatsapp-chat/manifest.json +8 -0
  131. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +34 -0
  132. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/auth-state.test.ts +99 -0
  133. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/connection.test.ts +145 -0
  134. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/index.test.ts +216 -0
  135. package/dist/plugins/fusion-plugin-whatsapp-chat/src/__tests__/reply.test.ts +52 -0
  136. package/dist/plugins/fusion-plugin-whatsapp-chat/src/auth-state.ts +89 -0
  137. package/dist/plugins/fusion-plugin-whatsapp-chat/src/connection.ts +253 -0
  138. package/dist/plugins/fusion-plugin-whatsapp-chat/src/index.ts +262 -0
  139. package/dist/plugins/fusion-plugin-whatsapp-chat/src/qrcode.d.ts +1 -0
  140. package/dist/plugins/fusion-plugin-whatsapp-chat/src/reply.ts +37 -0
  141. package/package.json +2 -2
  142. package/skill/fusion/SKILL.md +2 -2
  143. package/skill/fusion/references/engine-tools.md +3 -0
  144. package/skill/fusion/references/extension-tools.md +39 -0
  145. package/skill/fusion/references/fusion-capabilities.md +3 -0
  146. package/dist/client/assets/AgentDetailView-C1XceMgi.js +0 -18
  147. package/dist/client/assets/AgentDetailView-CeO_1MK7.css +0 -1
  148. package/dist/client/assets/AgentsView-Deh125ss.js +0 -527
  149. package/dist/client/assets/ChatView-7D_RQDqT.js +0 -1
  150. package/dist/client/assets/InsightsView-AWo5o_81.css +0 -1
  151. package/dist/client/assets/InsightsView-jKjEFAx_.js +0 -11
  152. package/dist/client/assets/MemoryView-DiajLXby.css +0 -1
  153. package/dist/client/assets/MemoryView-nXlTqebk.js +0 -2
  154. package/dist/client/assets/NodesView-Di2SvOhg.js +0 -14
  155. package/dist/client/assets/NodesView-fXqDk9ur.css +0 -1
  156. package/dist/client/assets/PluginManager-B9-NbQ8f.js +0 -1
  157. package/dist/client/assets/PluginManager-C1DbPaar.css +0 -1
  158. package/dist/client/assets/RoadmapsView-DHWjUoc8.js +0 -6
  159. package/dist/client/assets/RoadmapsView-DdGlfuu-.css +0 -1
  160. package/dist/client/assets/SettingsModal-C89Ikhfm.js +0 -1
  161. package/dist/client/assets/SettingsModal-DHitIpsa.css +0 -1
  162. package/dist/client/assets/SettingsModal-DR_yirvK.js +0 -31
  163. package/dist/client/assets/SetupWizardModal-BtDMY9pa.js +0 -1
  164. package/dist/client/assets/agentSkills-B-w5wFHh.js +0 -1
  165. package/dist/client/assets/index-Bc6ZdGMz.css +0 -1
  166. package/dist/client/assets/index-D__RMku8.js +0 -694
  167. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraphView.css +0 -141
  168. package/dist/plugins/fusion-plugin-dependency-graph/src/DependencyGraphView.tsx +0 -428
  169. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/DependencyGraphView.test.tsx +0 -261
  170. package/dist/plugins/fusion-plugin-dependency-graph/src/__tests__/storage.test.ts +0 -41
  171. package/dist/plugins/fusion-plugin-dependency-graph/src/index.ts +0 -25
  172. package/dist/plugins/fusion-plugin-dependency-graph/src/storage.ts +0 -22
@@ -1,11 +1,12 @@
1
- // ../plugin-sdk/dist/index.js
1
+ // ../plugin-sdk/src/index.ts
2
2
  function definePlugin(plugin2) {
3
3
  return plugin2;
4
4
  }
5
5
 
6
- // ../../plugins/fusion-plugin-openclaw-runtime/dist/pi-module.js
6
+ // ../../plugins/fusion-plugin-openclaw-runtime/src/pi-module.ts
7
7
  import { spawn } from "node:child_process";
8
8
  import { randomUUID } from "node:crypto";
9
+ import { readFile } from "node:fs/promises";
9
10
  var DEFAULT_BINARY = "openclaw";
10
11
  var DEFAULT_AGENT_ID = "main";
11
12
  var DEFAULT_THINKING = "off";
@@ -16,20 +17,16 @@ function asString(v) {
16
17
  return typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
17
18
  }
18
19
  function asNumber(v) {
19
- if (typeof v === "number" && Number.isFinite(v))
20
- return v;
20
+ if (typeof v === "number" && Number.isFinite(v)) return v;
21
21
  const s = asString(v);
22
- if (s === void 0)
23
- return void 0;
22
+ if (s === void 0) return void 0;
24
23
  const n = Number(s);
25
24
  return Number.isFinite(n) ? n : void 0;
26
25
  }
27
26
  function asBool(v) {
28
- if (typeof v === "boolean")
29
- return v;
27
+ if (typeof v === "boolean") return v;
30
28
  const s = asString(v);
31
- if (s === void 0)
32
- return void 0;
29
+ if (s === void 0) return void 0;
33
30
  return s === "1" || s.toLowerCase() === "true";
34
31
  }
35
32
  function stripAnsi(text) {
@@ -46,12 +43,15 @@ function resolveCliConfig(settings) {
46
43
  useGateway: asBool(settings?.useGateway) ?? asBool(process.env.OPENCLAW_USE_GATEWAY) ?? false
47
44
  };
48
45
  }
49
- function buildOpenClawArgs(config, sessionId, message) {
50
- const args = ["--no-color", "agent"];
51
- if (!config.useGateway)
52
- args.push("--local");
46
+ function buildOpenClawArgs(config, session, message) {
47
+ const args = ["--no-color"];
48
+ if (session.mcpProfile) {
49
+ args.push("--profile", session.mcpProfile);
50
+ }
51
+ args.push("agent");
52
+ if (!config.useGateway) args.push("--local");
53
53
  args.push("--json");
54
- args.push("--session-id", sessionId);
54
+ args.push("--session-id", session.sessionId);
55
55
  args.push("--message", message);
56
56
  args.push("--agent", config.agentId);
57
57
  if (config.model) {
@@ -63,8 +63,7 @@ function buildOpenClawArgs(config, sessionId, message) {
63
63
  }
64
64
  function extractStderrError(stderr, stdout) {
65
65
  const tryExtract = (raw) => {
66
- if (!raw)
67
- return void 0;
66
+ if (!raw) return void 0;
68
67
  const lines = stripAnsi(raw).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
69
68
  return lines.length > 0 ? lines[lines.length - 1] : void 0;
70
69
  };
@@ -78,11 +77,33 @@ function createCliSession(opts) {
78
77
  messages: [{ role: "developer", content: opts.systemPrompt }],
79
78
  lastModelDescription: `openclaw/${opts.agentId ?? DEFAULT_AGENT_ID}`,
80
79
  lastUsage: void 0,
81
- callbacks: opts.callbacks
80
+ callbacks: opts.callbacks,
81
+ mcpProfile: opts.mcpProfile,
82
+ mcpConfigPath: opts.mcpConfigPath
82
83
  };
83
84
  }
85
+ async function configureOpenClawMcpServer(opts) {
86
+ const serverValue = await readFile(opts.serverConfigPath, "utf-8");
87
+ await new Promise((resolve, reject) => {
88
+ const child = spawn(opts.binaryPath, ["--no-color", "--profile", opts.profile, "mcp", "set", opts.serverName, serverValue], {
89
+ stdio: ["ignore", "pipe", "pipe"]
90
+ });
91
+ let stderr = "";
92
+ child.stderr?.on("data", (chunk) => {
93
+ stderr += chunk.toString("utf-8");
94
+ });
95
+ child.on("error", (err) => reject(new Error(`openclaw: failed to configure MCP server \u2014 ${err.message}`)));
96
+ child.on("close", (code) => {
97
+ if (code === 0) {
98
+ resolve();
99
+ return;
100
+ }
101
+ reject(new Error(`openclaw: mcp set failed (${String(code)}): ${extractStderrError(stderr)}`));
102
+ });
103
+ });
104
+ }
84
105
  async function promptCli(session, message, config, callbacks, signal) {
85
- const args = buildOpenClawArgs(config, session.sessionId, message);
106
+ const args = buildOpenClawArgs(config, session, message);
86
107
  const cb = { ...session.callbacks, ...callbacks };
87
108
  cb.onToolStart?.("openclaw.agent", { sessionId: session.sessionId });
88
109
  return new Promise((resolve, reject) => {
@@ -91,18 +112,20 @@ async function promptCli(session, message, config, callbacks, signal) {
91
112
  stdio: ["ignore", "pipe", "pipe"]
92
113
  });
93
114
  const hardKill = setTimeout(() => {
94
- if (settled)
95
- return;
115
+ if (settled) return;
96
116
  settled = true;
97
117
  try {
98
118
  child.kill("SIGKILL");
99
119
  } catch {
100
120
  }
101
- reject(new Error(`openclaw: process timed out after ${config.cliTimeoutMs}ms`));
121
+ reject(
122
+ new Error(
123
+ `openclaw: process timed out after ${config.cliTimeoutMs}ms`
124
+ )
125
+ );
102
126
  }, config.cliTimeoutMs);
103
127
  const onAbort = () => {
104
- if (settled)
105
- return;
128
+ if (settled) return;
106
129
  try {
107
130
  child.kill("SIGTERM");
108
131
  } catch {
@@ -124,17 +147,19 @@ async function promptCli(session, message, config, callbacks, signal) {
124
147
  stderr += chunk.toString("utf-8");
125
148
  });
126
149
  child.on("error", (err) => {
127
- if (settled)
128
- return;
150
+ if (settled) return;
129
151
  settled = true;
130
152
  clearTimeout(hardKill);
131
153
  signal?.removeEventListener("abort", onAbort);
132
154
  const isNotFound = err.code === "ENOENT";
133
- reject(new Error(isNotFound ? `openclaw: binary not found at "${config.binaryPath}". Install OpenClaw (npm i -g openclaw) or set binaryPath/OPENCLAW_BIN.` : `openclaw: spawn error \u2014 ${err.message}`));
155
+ reject(
156
+ new Error(
157
+ isNotFound ? `openclaw: binary not found at "${config.binaryPath}". Install OpenClaw (npm i -g openclaw) or set binaryPath/OPENCLAW_BIN.` : `openclaw: spawn error \u2014 ${err.message}`
158
+ )
159
+ );
134
160
  });
135
161
  child.on("close", (code) => {
136
- if (settled)
137
- return;
162
+ if (settled) return;
138
163
  settled = true;
139
164
  clearTimeout(hardKill);
140
165
  signal?.removeEventListener("abort", onAbort);
@@ -155,29 +180,30 @@ async function promptCli(session, message, config, callbacks, signal) {
155
180
  const reasoningText = payloads.filter((p) => p.isReasoning).map((p) => p.text ?? "").filter((t) => t.length > 0).join("\n");
156
181
  const errorText = payloads.filter((p) => p.isError).map((p) => p.text ?? "").filter((t) => t.length > 0);
157
182
  const finalText = visibleText || parsed.meta?.finalAssistantVisibleText || "";
158
- if (finalText)
159
- cb.onText?.(finalText);
160
- if (reasoningText)
161
- cb.onThinking?.(reasoningText);
183
+ if (finalText) cb.onText?.(finalText);
184
+ if (reasoningText) cb.onThinking?.(reasoningText);
162
185
  session.messages.push({ role: "user", content: message });
163
186
  if (finalText) {
164
187
  session.messages.push({ role: "assistant", content: finalText });
165
188
  }
166
189
  const agentMeta = parsed.meta?.agentMeta;
167
- if (agentMeta?.usage)
168
- session.lastUsage = agentMeta.usage;
190
+ if (agentMeta?.usage) session.lastUsage = agentMeta.usage;
169
191
  if (agentMeta?.provider && agentMeta.model) {
170
192
  session.lastModelDescription = `openclaw/${session.agentId}/${agentMeta.provider}/${agentMeta.model}`;
171
193
  }
172
194
  const metaError = parsed.meta?.error;
173
195
  const isError = !!metaError;
174
- cb.onToolEnd?.("openclaw.agent", isError, {
175
- usage: agentMeta?.usage,
176
- provider: agentMeta?.provider,
177
- model: agentMeta?.model,
178
- ...metaError ? { error: metaError } : {},
179
- ...errorText.length > 0 ? { toolErrors: errorText } : {}
180
- });
196
+ cb.onToolEnd?.(
197
+ "openclaw.agent",
198
+ isError,
199
+ {
200
+ usage: agentMeta?.usage,
201
+ provider: agentMeta?.provider,
202
+ model: agentMeta?.model,
203
+ ...metaError ? { error: metaError } : {},
204
+ ...errorText.length > 0 ? { toolErrors: errorText } : {}
205
+ }
206
+ );
181
207
  resolve();
182
208
  });
183
209
  });
@@ -186,7 +212,43 @@ function describeCliModel(session) {
186
212
  return session.lastModelDescription || `openclaw/${session.agentId}`;
187
213
  }
188
214
 
189
- // ../../plugins/fusion-plugin-openclaw-runtime/dist/runtime-adapter.js
215
+ // ../../plugins/fusion-plugin-openclaw-runtime/src/mcp-config.ts
216
+ import { writeFileSync } from "node:fs";
217
+ import { tmpdir } from "node:os";
218
+ import { join } from "node:path";
219
+ import { fileURLToPath } from "node:url";
220
+ import { dirname } from "node:path";
221
+ var BUILT_IN_TOOL_NAMES = /* @__PURE__ */ new Set(["read", "write", "edit", "bash", "grep", "find"]);
222
+ function toolsToMcpToolDefs(tools) {
223
+ if (!Array.isArray(tools)) return [];
224
+ return tools.filter((tool) => tool && typeof tool.name === "string" && !BUILT_IN_TOOL_NAMES.has(tool.name)).map((tool) => ({
225
+ name: tool.name,
226
+ description: typeof tool.description === "string" ? tool.description : "",
227
+ inputSchema: tool.parameters ?? { type: "object", properties: {} }
228
+ }));
229
+ }
230
+ function writeOpenClawMcpBridgeFiles(toolDefs, cacheKey) {
231
+ const suffix = cacheKey ? `${process.pid}-${cacheKey}` : `${process.pid}`;
232
+ const schemaPath = join(tmpdir(), `openclaw-runtime-mcp-schemas-${suffix}.json`);
233
+ writeFileSync(schemaPath, JSON.stringify(toolDefs));
234
+ const __filename = fileURLToPath(import.meta.url);
235
+ const __dirname = dirname(__filename);
236
+ const serverPath = join(__dirname, "mcp-schema-server.cjs");
237
+ const serverConfig = {
238
+ command: "node",
239
+ args: [serverPath, schemaPath]
240
+ };
241
+ const serverConfigPath = join(tmpdir(), `openclaw-runtime-mcp-server-${suffix}.json`);
242
+ writeFileSync(serverConfigPath, JSON.stringify(serverConfig));
243
+ return {
244
+ schemaPath,
245
+ serverConfigPath,
246
+ serverName: "fusion-custom-tools"
247
+ };
248
+ }
249
+
250
+ // ../../plugins/fusion-plugin-openclaw-runtime/src/runtime-adapter.ts
251
+ import { randomUUID as randomUUID2 } from "node:crypto";
190
252
  var OpenClawRuntimeAdapter = class {
191
253
  id = "openclaw";
192
254
  name = "OpenClaw Runtime";
@@ -195,9 +257,29 @@ var OpenClawRuntimeAdapter = class {
195
257
  this.config = resolveCliConfig(settings);
196
258
  }
197
259
  async createSession(options) {
260
+ const contextTools = [
261
+ ...Array.isArray(options.tools) ? options.tools : [],
262
+ ...Array.isArray(options.customTools) ? options.customTools : []
263
+ ];
264
+ const toolDefs = toolsToMcpToolDefs(contextTools);
265
+ let mcpProfile;
266
+ let mcpConfigPath;
267
+ if (toolDefs.length > 0) {
268
+ const bridge = writeOpenClawMcpBridgeFiles(toolDefs, randomUUID2());
269
+ mcpProfile = `fusion-${randomUUID2()}`;
270
+ mcpConfigPath = bridge.serverConfigPath;
271
+ await configureOpenClawMcpServer({
272
+ binaryPath: this.config.binaryPath,
273
+ profile: mcpProfile,
274
+ serverName: bridge.serverName,
275
+ serverConfigPath: bridge.serverConfigPath
276
+ });
277
+ }
198
278
  const session = createCliSession({
199
279
  systemPrompt: options.systemPrompt,
200
280
  agentId: this.config.agentId,
281
+ mcpProfile,
282
+ mcpConfigPath,
201
283
  callbacks: {
202
284
  onText: options.onText,
203
285
  onThinking: options.onThinking,
@@ -218,7 +300,7 @@ var OpenClawRuntimeAdapter = class {
218
300
  }
219
301
  };
220
302
 
221
- // ../../plugins/fusion-plugin-openclaw-runtime/dist/probe.js
303
+ // ../../plugins/fusion-plugin-openclaw-runtime/src/probe.ts
222
304
  import { spawn as spawn2 } from "node:child_process";
223
305
  var DEFAULT_PROBE_TIMEOUT_MS = 2e3;
224
306
  async function probeOpenClawBinary(opts = {}) {
@@ -235,8 +317,7 @@ async function probeOpenClawBinary(opts = {}) {
235
317
  stdio: ["ignore", "pipe", "pipe"]
236
318
  });
237
319
  const timer = setTimeout(() => {
238
- if (settled)
239
- return;
320
+ if (settled) return;
240
321
  settled = true;
241
322
  try {
242
323
  child.kill("SIGKILL");
@@ -257,8 +338,7 @@ async function probeOpenClawBinary(opts = {}) {
257
338
  stderr += chunk.toString("utf-8");
258
339
  });
259
340
  child.on("error", (err) => {
260
- if (settled)
261
- return;
341
+ if (settled) return;
262
342
  settled = true;
263
343
  clearTimeout(timer);
264
344
  const isNotFound = err.code === "ENOENT";
@@ -269,8 +349,7 @@ async function probeOpenClawBinary(opts = {}) {
269
349
  });
270
350
  });
271
351
  child.on("close", (code) => {
272
- if (settled)
273
- return;
352
+ if (settled) return;
274
353
  settled = true;
275
354
  clearTimeout(timer);
276
355
  if (code === 0) {
@@ -309,7 +388,7 @@ async function tryResolveBinaryPath(binary) {
309
388
  });
310
389
  }
311
390
 
312
- // ../../plugins/fusion-plugin-openclaw-runtime/dist/index.js
391
+ // ../../plugins/fusion-plugin-openclaw-runtime/src/index.ts
313
392
  var OPENCLAW_RUNTIME_ID = "openclaw";
314
393
  var OPENCLAW_RUNTIME_VERSION = "0.2.0";
315
394
  var openclawRuntimeMetadata = {
@@ -336,7 +415,9 @@ var plugin = definePlugin({
336
415
  onLoad: async (ctx) => {
337
416
  const config = resolveCliConfig(ctx.settings);
338
417
  const probe = await probeOpenClawBinary({ binaryPath: config.binaryPath });
339
- ctx.logger.info(probe.available ? `OpenClaw Runtime Plugin loaded \u2014 binary=${config.binaryPath}${probe.version ? ` (${probe.version})` : ""}` : `OpenClaw Runtime Plugin loaded but binary not detected: ${probe.reason ?? "unknown"}`);
418
+ ctx.logger.info(
419
+ probe.available ? `OpenClaw Runtime Plugin loaded \u2014 binary=${config.binaryPath}${probe.version ? ` (${probe.version})` : ""}` : `OpenClaw Runtime Plugin loaded but binary not detected: ${probe.reason ?? "unknown"}`
420
+ );
340
421
  ctx.emitEvent("openclaw-runtime:loaded", {
341
422
  runtimeId: OPENCLAW_RUNTIME_ID,
342
423
  version: OPENCLAW_RUNTIME_VERSION,
@@ -357,6 +438,7 @@ export {
357
438
  OPENCLAW_RUNTIME_ID,
358
439
  OpenClawRuntimeAdapter,
359
440
  buildOpenClawArgs,
441
+ configureOpenClawMcpServer,
360
442
  createCliSession,
361
443
  index_default as default,
362
444
  describeCliModel,
@@ -365,5 +447,7 @@ export {
365
447
  openclawRuntimeMetadata,
366
448
  probeOpenClawBinary,
367
449
  promptCli,
368
- resolveCliConfig
450
+ resolveCliConfig,
451
+ toolsToMcpToolDefs,
452
+ writeOpenClawMcpBridgeFiles
369
453
  };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const readline = require("readline");
5
+
6
+ const schemaPath = process.argv[2];
7
+ if (!schemaPath) process.exit(1);
8
+
9
+ let tools = [];
10
+ try {
11
+ tools = JSON.parse(fs.readFileSync(schemaPath, "utf-8"));
12
+ } catch {
13
+ process.exit(1);
14
+ }
15
+
16
+ const rl = readline.createInterface({ input: process.stdin });
17
+ rl.on("line", (line) => {
18
+ let msg;
19
+ try {
20
+ msg = JSON.parse(line);
21
+ } catch {
22
+ return;
23
+ }
24
+
25
+ if (msg.method === "initialize") {
26
+ process.stdout.write(
27
+ JSON.stringify({
28
+ jsonrpc: "2.0",
29
+ id: msg.id,
30
+ result: {
31
+ protocolVersion: "2024-11-05",
32
+ capabilities: { tools: {} },
33
+ serverInfo: { name: "fusion-custom-tools", version: "1.0.0" },
34
+ },
35
+ }) + "\n",
36
+ );
37
+ return;
38
+ }
39
+
40
+ if (msg.method === "tools/list") {
41
+ process.stdout.write(
42
+ JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: { tools } }) + "\n",
43
+ );
44
+ return;
45
+ }
46
+
47
+ if (msg.method === "tools/call") {
48
+ process.stdout.write(
49
+ JSON.stringify({
50
+ jsonrpc: "2.0",
51
+ id: msg.id,
52
+ result: {
53
+ content: [{ type: "text", text: "Tool execution is handled by Fusion runtime." }],
54
+ isError: true,
55
+ },
56
+ }) + "\n",
57
+ );
58
+ }
59
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/openclaw-runtime",
3
- "version": "0.2.31",
3
+ "version": "0.2.33",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {