poe-code 3.0.125 → 3.0.127

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/dist/index.js CHANGED
@@ -2757,6 +2757,17 @@ function toTomlInlineTable(values) {
2757
2757
  function serializeJsonMcpArgs(servers) {
2758
2758
  return ["--mcp-config", JSON.stringify({ mcpServers: toJsonMcpServers(servers) })];
2759
2759
  }
2760
+ function serializeOpenCodeMcpEnv(servers) {
2761
+ const mcp = {};
2762
+ for (const [name, server] of Object.entries(servers)) {
2763
+ const entry = { type: "local", command: [server.command, ...server.args ?? []] };
2764
+ if (server.env && Object.keys(server.env).length > 0) {
2765
+ entry.environment = server.env;
2766
+ }
2767
+ mcp[name] = entry;
2768
+ }
2769
+ return { OPENCODE_CONFIG_CONTENT: JSON.stringify({ mcp }) };
2770
+ }
2760
2771
  function serializeCodexMcpArgs(servers) {
2761
2772
  const args = [];
2762
2773
  for (const [name, server] of Object.entries(servers)) {
@@ -2854,6 +2865,7 @@ var openCodeSpawnConfig;
2854
2865
  var init_opencode2 = __esm({
2855
2866
  "packages/agent-spawn/src/configs/opencode.ts"() {
2856
2867
  "use strict";
2868
+ init_mcp();
2857
2869
  openCodeSpawnConfig = {
2858
2870
  kind: "cli",
2859
2871
  agentId: "opencode",
@@ -2877,7 +2889,8 @@ var init_opencode2 = __esm({
2877
2889
  defaultArgs: [],
2878
2890
  promptFlag: "--prompt"
2879
2891
  },
2880
- resumeCommand: (threadId, cwd) => [cwd, "--session", threadId]
2892
+ resumeCommand: (threadId, cwd) => [cwd, "--session", threadId],
2893
+ mcpEnv: serializeOpenCodeMcpEnv
2881
2894
  };
2882
2895
  }
2883
2896
  });
@@ -2927,12 +2940,12 @@ function getSpawnConfig(input) {
2927
2940
  }
2928
2941
  function supportsMcpAtSpawn(input) {
2929
2942
  const config = getSpawnConfig(input);
2930
- return !!config && config.kind === "cli" && typeof config.mcpArgs === "function";
2943
+ return !!config && config.kind === "cli" && (typeof config.mcpArgs === "function" || typeof config.mcpEnv === "function");
2931
2944
  }
2932
2945
  function listMcpSupportedAgents() {
2933
2946
  const supported = [];
2934
2947
  for (const config of allSpawnConfigs) {
2935
- if (config.kind !== "cli" || typeof config.mcpArgs !== "function") {
2948
+ if (config.kind !== "cli" || typeof config.mcpArgs !== "function" && typeof config.mcpEnv !== "function") {
2936
2949
  continue;
2937
2950
  }
2938
2951
  supported.push(config.agentId);
@@ -2994,11 +3007,20 @@ function getMcpArgs(config, servers) {
2994
3007
  if (!hasMcpServers(servers)) {
2995
3008
  return [];
2996
3009
  }
2997
- if (!config.mcpArgs) {
3010
+ if (!config.mcpArgs && !config.mcpEnv) {
2998
3011
  throw new Error(formatUnsupportedMcpSpawnMessage(config.agentId));
2999
3012
  }
3013
+ if (!config.mcpArgs) {
3014
+ return [];
3015
+ }
3000
3016
  return config.mcpArgs(servers);
3001
3017
  }
3018
+ function getMcpEnv(config, servers) {
3019
+ if (!hasMcpServers(servers) || !config.mcpEnv) {
3020
+ return {};
3021
+ }
3022
+ return config.mcpEnv(servers);
3023
+ }
3002
3024
  function formatUnsupportedMcpSpawnMessage(agentId) {
3003
3025
  const supported = listMcpSupportedAgents();
3004
3026
  const supportedText = supported.length > 0 ? supported.join(", ") : "(none)";
@@ -4549,6 +4571,7 @@ function spawnStreaming(options) {
4549
4571
  throw new Error(`Agent "${agentId}" has no binaryName.`);
4550
4572
  }
4551
4573
  const mcpArgs = getMcpArgs(spawnConfig, options.mcpServers);
4574
+ const mcpEnvVars = getMcpEnv(spawnConfig, options.mcpServers);
4552
4575
  const args = [];
4553
4576
  if (spawnConfig.mcpArgsBeforeCommand) {
4554
4577
  args.push(...mcpArgs);
@@ -4577,7 +4600,8 @@ function spawnStreaming(options) {
4577
4600
  }
4578
4601
  const child = spawnChildProcess3(binaryName, args, {
4579
4602
  cwd: options.cwd,
4580
- stdio: ["pipe", "pipe", "pipe"]
4603
+ stdio: ["pipe", "pipe", "pipe"],
4604
+ env: Object.keys(mcpEnvVars).length > 0 ? { ...process.env, ...mcpEnvVars } : void 0
4581
4605
  });
4582
4606
  let aborted = false;
4583
4607
  const onAbort = () => {
@@ -4939,6 +4963,7 @@ var init_src6 = __esm({
4939
4963
  "use strict";
4940
4964
  init_run_command();
4941
4965
  init_configs();
4966
+ init_mcp();
4942
4967
  init_spawn();
4943
4968
  init_spawn();
4944
4969
  init_spawn_interactive();
@@ -7171,6 +7196,35 @@ function parseTaskStatus(value, availableSteps, taskId) {
7171
7196
  }
7172
7197
  return statusMap;
7173
7198
  }
7199
+ function parseMcpConfig(value) {
7200
+ if (!isRecord3(value)) {
7201
+ throw new Error('Invalid plan YAML: "mcp" must be an object.');
7202
+ }
7203
+ const result = {};
7204
+ for (const [name, entry] of Object.entries(value)) {
7205
+ if (!isRecord3(entry)) {
7206
+ throw new Error(`Invalid plan YAML: mcp["${name}"] must be an object.`);
7207
+ }
7208
+ if (typeof entry.command !== "string" || entry.command.length === 0) {
7209
+ throw new Error(`Invalid plan YAML: mcp["${name}"].command must be a non-empty string.`);
7210
+ }
7211
+ const server = { command: entry.command };
7212
+ if (entry.args !== void 0) {
7213
+ if (!Array.isArray(entry.args) || !entry.args.every((a) => typeof a === "string")) {
7214
+ throw new Error(`Invalid plan YAML: mcp["${name}"].args must be an array of strings.`);
7215
+ }
7216
+ server.args = entry.args;
7217
+ }
7218
+ if (entry.env !== void 0) {
7219
+ if (!isRecord3(entry.env) || !Object.values(entry.env).every((v) => typeof v === "string")) {
7220
+ throw new Error(`Invalid plan YAML: mcp["${name}"].env must be a string record.`);
7221
+ }
7222
+ server.env = entry.env;
7223
+ }
7224
+ result[name] = server;
7225
+ }
7226
+ return result;
7227
+ }
7174
7228
  function parsePlan(yamlContent, options = {}) {
7175
7229
  let document;
7176
7230
  try {
@@ -7203,7 +7257,9 @@ function parsePlan(yamlContent, options = {}) {
7203
7257
  status: parseTaskStatus(value.status, options.availableSteps, id)
7204
7258
  };
7205
7259
  });
7206
- return { tasks };
7260
+ const mcpValue = document.mcp;
7261
+ const mcp = mcpValue !== void 0 ? parseMcpConfig(mcpValue) : void 0;
7262
+ return { tasks, ...mcp !== void 0 ? { mcp } : {} };
7207
7263
  }
7208
7264
  var init_parser = __esm({
7209
7265
  "packages/pipeline/src/plan/parser.ts"() {
@@ -7759,6 +7815,7 @@ async function runPipeline(options) {
7759
7815
  cwd: options.cwd,
7760
7816
  logDir: options.logDir,
7761
7817
  ...model ? { model } : {},
7818
+ ...plan.mcp ? { mcpServers: plan.mcp } : {},
7762
7819
  ...options.signal ? { signal: options.signal } : {}
7763
7820
  });
7764
7821
  } catch (error) {
@@ -7872,7 +7929,8 @@ async function runPipeline2(options) {
7872
7929
  cwd: input.cwd,
7873
7930
  logDir: input.logDir,
7874
7931
  model: input.model,
7875
- mode: input.mode
7932
+ mode: input.mode,
7933
+ ...input.mcpServers ? { mcpServers: input.mcpServers } : {}
7876
7934
  });
7877
7935
  await renderAcpStream(events);
7878
7936
  return await result;
@@ -24010,7 +24068,7 @@ var init_package = __esm({
24010
24068
  "package.json"() {
24011
24069
  package_default = {
24012
24070
  name: "poe-code",
24013
- version: "3.0.125",
24071
+ version: "3.0.127",
24014
24072
  description: "CLI tool to configure Poe API for developer workflows.",
24015
24073
  type: "module",
24016
24074
  main: "./dist/index.js",