@openagents-org/agent-launcher 0.2.226 → 0.2.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-launcher",
3
- "version": "0.2.226",
3
+ "version": "0.2.227",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -27,6 +27,9 @@ const { buildOpenCodeSkillMd, buildOpenCodeSystemPrompt, workspaceSkillName } =
27
27
  const { whichBinary, whereBinary, getEnhancedEnv } = require('../paths');
28
28
  const { isPostinstallStub, isPostinstallStubOutput } = require('../postinstall-stub');
29
29
 
30
+ // The launcher's own CLI, whose `mcp-server` command serves the workspace tools.
31
+ const WORKSPACE_MCP_BIN = path.resolve(__dirname, '..', '..', 'bin', 'agent-connector.js');
32
+
30
33
  const IS_WINDOWS = process.platform === 'win32';
31
34
 
32
35
  // Max time an `opencode run` may stay completely silent. This is deliberately
@@ -252,8 +255,40 @@ class OpenCodeAdapter extends BaseAdapter {
252
255
  touch();
253
256
  return { touch, cancel, timeoutMs };
254
257
  }
255
- _spawnEnv() {
256
- return { ...(this.agentEnv || process.env) };
258
+ _spawnEnv(channel) {
259
+ const env = { ...(this.agentEnv || process.env) };
260
+ if (!this._wiresWorkspaceMcp()) return env;
261
+ // Give OpenCode the workspace tools (publish, todos, browser, ...) through
262
+ // our MCP server, as the Claude adapter does. Merged into any inline config
263
+ // the host already passes; the token travels in the child's environment only.
264
+ let cfg = {};
265
+ try { cfg = JSON.parse(env.OPENCODE_CONFIG_CONTENT || '{}') || {}; } catch { return env; }
266
+ if (typeof cfg !== 'object' || Array.isArray(cfg)) return env;
267
+ const args = [WORKSPACE_MCP_BIN, 'mcp-server',
268
+ '--workspace-id', this.workspaceId, '--channel-name', channel || this.channelName || 'general',
269
+ '--agent-name', this.agentName, '--endpoint', this.endpoint];
270
+ const disabled = this.disabledModules || new Set();
271
+ if (disabled.has('files')) args.push('--disable-files');
272
+ if (disabled.has('browser')) args.push('--disable-browser');
273
+ if (disabled.has('knowledge')) args.push('--disable-knowledge');
274
+ const requester = channel && this.requesterEmailFor ? this.requesterEmailFor(channel) : null;
275
+ cfg.mcp = { ...(cfg.mcp || {}), openagents: { type: 'local', enabled: true,
276
+ command: [process.execPath, ...args],
277
+ environment: { OA_WORKSPACE_TOKEN: this.token, ...(requester ? { OPENAGENTS_REQUESTER_EMAIL: requester } : {}) } } };
278
+ env.OPENCODE_CONFIG_CONTENT = JSON.stringify(cfg);
279
+ return env;
280
+ }
281
+
282
+ /**
283
+ * Only plain OpenCode reads OPENCODE_CONFIG_CONTENT; the forks built on this
284
+ * adapter (CodeArts, MiMo Code) replace _spawnEnv and keep the curl skill.
285
+ */
286
+ _wiresWorkspaceMcp() {
287
+ // An OpenCode across the Windows/WSL boundary could not start our node.
288
+ const bin = String(this._opencodeBinary || '');
289
+ if (bin.startsWith('wsl:') || (!IS_WINDOWS && /\.(exe|cmd|bat)$/i.test(bin))) return false;
290
+ return this._spawnEnv === OpenCodeAdapter.prototype._spawnEnv
291
+ && Boolean(this.token && this.workspaceId) && fs.existsSync(WORKSPACE_MCP_BIN);
257
292
  }
258
293
 
259
294
  /**
@@ -366,6 +401,7 @@ class OpenCodeAdapter extends BaseAdapter {
366
401
  mode: this._mode,
367
402
  model: this.modelLabel(),
368
403
  disabledModules: this.disabledModules,
404
+ workspaceMcp: this._wiresWorkspaceMcp(),
369
405
  ...this.pinnedPromptOpts(channelName),
370
406
  });
371
407
  }
@@ -978,15 +978,24 @@ function buildOpenclawSkillMd({ endpoint, workspaceId, token, agentName, channel
978
978
  * `glossary` opts in to knowledge pinning exactly as in
979
979
  * buildOpenclawSystemPrompt.
980
980
  */
981
- function buildOpenCodeSystemPrompt({ agentName, workspaceId, channelName, endpoint, token, mode = 'execute', disabledModules, browserEnabled = false, glossary = null, isWindows = process.platform === 'win32', model = null }) {
982
- const identity = buildWorkspaceIdentity(agentName, workspaceId, channelName, mode, 'skills', model);
981
+ function buildOpenCodeSystemPrompt({ agentName, workspaceId, channelName, endpoint, token, mode = 'execute', disabledModules, browserEnabled = false, glossary = null, isWindows = process.platform === 'win32', model = null, workspaceMcp = false }) {
982
+ // With the workspace MCP server wired in (see OpenCodeAdapter._spawnEnv) the
983
+ // agent gets real workspace_* tools, as Claude does; the curl skill stays on
984
+ // disk as a fallback. Without it, curl through OpenCode's shell tool, `bash`.
985
+ const toolMode = workspaceMcp ? 'mcp' : 'skills';
986
+ const skillName = workspaceSkillName(agentName);
987
+ const identity = buildWorkspaceIdentity(agentName, workspaceId, channelName, mode, toolMode, model);
983
988
  const directive = buildBrowserDirective(browserEnabled);
984
- const collab = buildCollaborationPrompt('skills', workspaceSkillName(agentName));
989
+ const collab = buildCollaborationPrompt(toolMode, skillName);
985
990
  const modePrompt = buildModePrompt(mode) + buildWindowsShellHint(isWindows);
986
- const pinned = buildPinnedSections({ toolMode: 'skills', mode, glossary })
991
+ const pinned = buildPinnedSections({ toolMode, mode, glossary })
987
992
  .map((s) => '\n' + s).join('');
988
- const api = buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channelName, disabledModules, mode });
989
- return identity + directive + '\n' + collab + '\n' + modePrompt + pinned + '\n' + api + '\n' + buildGuardrails();
993
+ const tools = workspaceMcp
994
+ ? buildClaudeMcpToolBlock() +
995
+ 'Use workspace_publish_project to share HTML pages or reports, workspace_write_file for other files, and the workspace_browser_* tools for the shared browser.\n' +
996
+ `If a workspace tool is missing or fails, the ${skillName} skill documents the same operations as bash + curl.\n`
997
+ : buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channelName, disabledModules, mode, execTool: 'bash' });
998
+ return identity + directive + '\n' + collab + '\n' + modePrompt + pinned + '\n' + tools + '\n' + buildGuardrails();
990
999
  }
991
1000
 
992
1001
  /**
@@ -1005,7 +1014,7 @@ function buildPiSystemPrompt({ agentName, workspaceId, channelName, endpoint, to
1005
1014
  const directive = buildBrowserDirective(browserEnabled);
1006
1015
  const collab = buildCollaborationPrompt('skills', workspaceSkillName(agentName));
1007
1016
  const modePrompt = buildModePrompt(mode);
1008
- const api = buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channelName, disabledModules, mode });
1017
+ const api = buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channelName, disabledModules, mode, execTool: 'bash' });
1009
1018
  return identity + directive + '\n' + collab + '\n' + modePrompt + '\n' + api + '\n' + buildGuardrails();
1010
1019
  }
1011
1020
 
@@ -1149,6 +1158,7 @@ function buildOpenCodeSkillMd({ endpoint, workspaceId, token, agentName, channel
1149
1158
  channelName: channelName || 'general',
1150
1159
  disabledModules,
1151
1160
  mode: 'execute',
1161
+ execTool: 'bash',
1152
1162
  });
1153
1163
 
1154
1164
  const frontmatter =