poe-code 3.0.454 → 4.0.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.
@@ -3859,11 +3859,11 @@ function mergeLayers(layers) {
3859
3859
  }
3860
3860
  return mergeObjectLayers(layers, []);
3861
3861
  }
3862
- function mergeObjectLayers(layers, path47) {
3862
+ function mergeObjectLayers(layers, path48) {
3863
3863
  const data = {};
3864
3864
  const sources = {};
3865
3865
  for (const key of collectKeys(layers)) {
3866
- const resolved = resolveKey(layers, key, path47);
3866
+ const resolved = resolveKey(layers, key, path48);
3867
3867
  if (resolved === void 0) {
3868
3868
  continue;
3869
3869
  }
@@ -3883,7 +3883,7 @@ function collectKeys(layers) {
3883
3883
  }
3884
3884
  return [...keys];
3885
3885
  }
3886
- function resolveKey(layers, key, path47) {
3886
+ function resolveKey(layers, key, path48) {
3887
3887
  let winningSource;
3888
3888
  let winningValue;
3889
3889
  const objectLayers = [];
@@ -3916,9 +3916,9 @@ function resolveKey(layers, key, path47) {
3916
3916
  if (winningValue === null) {
3917
3917
  return void 0;
3918
3918
  }
3919
- const fullPath = buildPath(path47, key);
3919
+ const fullPath = buildPath(path48, key);
3920
3920
  if (isPlainObject(winningValue)) {
3921
- const merged = mergeObjectLayers(objectLayers, [...path47, key]);
3921
+ const merged = mergeObjectLayers(objectLayers, [...path48, key]);
3922
3922
  return {
3923
3923
  value: merged.data,
3924
3924
  sources: {
@@ -3946,8 +3946,8 @@ function isWinningCandidate(key, value) {
3946
3946
  function getOwnEntry2(record, key) {
3947
3947
  return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : void 0;
3948
3948
  }
3949
- function buildPath(path47, key) {
3950
- return [...path47, key].map(escapePathSegment).join(".");
3949
+ function buildPath(path48, key) {
3950
+ return [...path48, key].map(escapePathSegment).join(".");
3951
3951
  }
3952
3952
  function escapePathSegment(segment) {
3953
3953
  return segment.replaceAll("\\", "\\\\").replaceAll(".", "\\.");
@@ -5850,22 +5850,22 @@ function prune2(obj, shape) {
5850
5850
  }
5851
5851
  return { changed, result };
5852
5852
  }
5853
- function modifyAtPath(content, path47, value) {
5853
+ function modifyAtPath(content, path48, value) {
5854
5854
  const indent = detectIndent(content);
5855
5855
  const formattingOptions = {
5856
5856
  tabSize: indent === " " ? 1 : indent.length,
5857
5857
  insertSpaces: indent !== " ",
5858
5858
  eol: "\n"
5859
5859
  };
5860
- const edits = jsonc.modify(content, path47, value, { formattingOptions });
5860
+ const edits = jsonc.modify(content, path48, value, { formattingOptions });
5861
5861
  let result = jsonc.applyEdits(content, edits);
5862
5862
  if (!result.endsWith("\n")) {
5863
5863
  result += "\n";
5864
5864
  }
5865
5865
  return result;
5866
5866
  }
5867
- function removeAtPath(content, path47) {
5868
- return modifyAtPath(content, path47, void 0);
5867
+ function removeAtPath(content, path48) {
5868
+ return modifyAtPath(content, path48, void 0);
5869
5869
  }
5870
5870
  function serializeUpdate(content, current, next) {
5871
5871
  let result = content || "{}";
@@ -5875,15 +5875,15 @@ function serializeUpdate(content, current, next) {
5875
5875
  }
5876
5876
  return result;
5877
5877
  }
5878
- function applyObjectUpdate(content, path47, current, next) {
5878
+ function applyObjectUpdate(content, path48, current, next) {
5879
5879
  let result = content;
5880
5880
  for (const key of Object.keys(current)) {
5881
5881
  if (!hasConfigEntry(next, key)) {
5882
- result = removeAtPath(result, [...path47, key]);
5882
+ result = removeAtPath(result, [...path48, key]);
5883
5883
  }
5884
5884
  }
5885
5885
  for (const [key, nextValue] of Object.entries(next)) {
5886
- const nextPath = [...path47, key];
5886
+ const nextPath = [...path48, key];
5887
5887
  const hasCurrent = hasConfigEntry(current, key);
5888
5888
  const currentValue = hasCurrent ? current[key] : void 0;
5889
5889
  if (hasCurrent && isConfigObject(currentValue) && isConfigObject(nextValue)) {
@@ -6083,16 +6083,16 @@ function getConfigFormat(pathOrFormat) {
6083
6083
  }
6084
6084
  return formatRegistry[formatName];
6085
6085
  }
6086
- function detectFormat2(path47) {
6087
- const ext = getExtension(path47);
6086
+ function detectFormat2(path48) {
6087
+ const ext = getExtension(path48);
6088
6088
  return extensionMap[ext];
6089
6089
  }
6090
- function getExtension(path47) {
6091
- const lastDot = path47.lastIndexOf(".");
6090
+ function getExtension(path48) {
6091
+ const lastDot = path48.lastIndexOf(".");
6092
6092
  if (lastDot === -1) {
6093
6093
  return "";
6094
6094
  }
6095
- return path47.slice(lastDot).toLowerCase();
6095
+ return path48.slice(lastDot).toLowerCase();
6096
6096
  }
6097
6097
 
6098
6098
  // packages/config-mutations/src/execution/path-utils.ts
@@ -7309,7 +7309,7 @@ function mergeScope(scope, baseScope, overrideScope) {
7309
7309
  }
7310
7310
  return merged;
7311
7311
  }
7312
- function mergeRuntimeScope(baseScope, overrideScope, path47 = []) {
7312
+ function mergeRuntimeScope(baseScope, overrideScope, path48 = []) {
7313
7313
  const merged = {};
7314
7314
  const keys = /* @__PURE__ */ new Set([...Object.keys(baseScope), ...Object.keys(overrideScope)]);
7315
7315
  for (const key of keys) {
@@ -7322,7 +7322,7 @@ function mergeRuntimeScope(baseScope, overrideScope, path47 = []) {
7322
7322
  continue;
7323
7323
  }
7324
7324
  if (isRecord5(baseValue) && isRecord5(overrideValue)) {
7325
- setOwnEntry(merged, key, mergeRuntimeScope(baseValue, overrideValue, [...path47, key]));
7325
+ setOwnEntry(merged, key, mergeRuntimeScope(baseValue, overrideValue, [...path48, key]));
7326
7326
  continue;
7327
7327
  }
7328
7328
  setOwnEntry(merged, key, overrideValue);
@@ -12052,21 +12052,21 @@ async function* adaptClaude(lines) {
12052
12052
  if (blockType !== "tool_result") continue;
12053
12053
  const kind = toolKindsById.get(item.tool_use_id);
12054
12054
  toolKindsById.delete(item.tool_use_id);
12055
- let path47;
12055
+ let path48;
12056
12056
  if (typeof item.content === "string") {
12057
- path47 = item.content;
12057
+ path48 = item.content;
12058
12058
  } else {
12059
12059
  try {
12060
- path47 = JSON.stringify(item.content);
12060
+ path48 = JSON.stringify(item.content);
12061
12061
  } catch {
12062
- path47 = String(item.content);
12062
+ path48 = String(item.content);
12063
12063
  }
12064
12064
  }
12065
12065
  yield {
12066
12066
  event: "tool_complete",
12067
12067
  id: item.tool_use_id,
12068
12068
  kind,
12069
- path: path47
12069
+ path: path48
12070
12070
  };
12071
12071
  }
12072
12072
  }
@@ -12162,10 +12162,10 @@ async function* adaptCodex(lines) {
12162
12162
  const kindFromStart = toolKindById.get(item.id);
12163
12163
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
12164
12164
  const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
12165
- const path47 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
12165
+ const path48 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
12166
12166
  toolTitleById.delete(item.id);
12167
12167
  toolKindById.delete(item.id);
12168
- yield { event: "tool_complete", id: item.id, kind, path: path47 };
12168
+ yield { event: "tool_complete", id: item.id, kind, path: path48 };
12169
12169
  }
12170
12170
  }
12171
12171
  }
@@ -12514,14 +12514,14 @@ function toolInfo(event) {
12514
12514
  const [toolName = "tool", rawTool = {}] = Object.entries(toolCall)[0] ?? [];
12515
12515
  const tool = asObject2(rawTool) ?? {};
12516
12516
  const args = asObject2(tool.args) ?? asObject2(tool.arguments) ?? tool;
12517
- const path47 = typeof args.path === "string" ? args.path : "";
12517
+ const path48 = typeof args.path === "string" ? args.path : "";
12518
12518
  const kinds = {
12519
12519
  editToolCall: "edit",
12520
12520
  readToolCall: "read",
12521
12521
  shellToolCall: "exec",
12522
12522
  bashToolCall: "exec"
12523
12523
  };
12524
- return { kind: kinds[toolName] ?? "other", title: path47 || toolName, path: path47 };
12524
+ return { kind: kinds[toolName] ?? "other", title: path48 || toolName, path: path48 };
12525
12525
  }
12526
12526
  async function* adaptCursor(lines) {
12527
12527
  for await (const rawLine of lines) {
@@ -13735,6 +13735,107 @@ function createInstallRunner(definition) {
13735
13735
  };
13736
13736
  }
13737
13737
 
13738
+ // src/cli/isolated-env.ts
13739
+ import path47 from "node:path";
13740
+ async function resolveIsolatedEnvDetails(env, isolated, providerName, activeProvider) {
13741
+ if (!providerName) {
13742
+ throw new Error("resolveIsolatedEnvDetails requires providerName.");
13743
+ }
13744
+ const baseDir = resolveIsolatedBaseDir(env, providerName);
13745
+ const requiresConfig = isolated.requiresConfig !== false;
13746
+ if (requiresConfig && !isolated.configProbe) {
13747
+ throw new Error(
13748
+ `resolveIsolatedEnvDetails requires configProbe when requiresConfig is true (provider "${providerName}").`
13749
+ );
13750
+ }
13751
+ return {
13752
+ agentBinary: isolated.agentBinary,
13753
+ env: await resolveIsolatedEnvVars(env, baseDir, isolated.env, activeProvider),
13754
+ configProbePath: isolated.configProbe ? resolveIsolatedEnvPath(env, baseDir, isolated.configProbe) : void 0
13755
+ };
13756
+ }
13757
+ function resolveIsolatedBaseDir(env, providerName) {
13758
+ return env.resolveHomePath(".poe-code", providerName);
13759
+ }
13760
+ async function resolveIsolatedEnvVars(env, baseDir, vars, activeProvider) {
13761
+ const out = /* @__PURE__ */ Object.create(null);
13762
+ for (const [key, value] of Object.entries(vars)) {
13763
+ out[key] = await resolveIsolatedEnvValue(env, baseDir, value, activeProvider);
13764
+ }
13765
+ return out;
13766
+ }
13767
+ async function resolveIsolatedEnvValue(env, baseDir, value, activeProvider) {
13768
+ if (typeof value === "string") {
13769
+ return expandHomeShortcut(env, value);
13770
+ }
13771
+ if (isEnvVarReference(value)) {
13772
+ const resolved = env.getVariable(value.name);
13773
+ if (typeof resolved !== "string" || resolved.trim().length === 0) {
13774
+ throw new Error(
13775
+ `Missing required environment variable "${value.name}" for isolated wrapper.`
13776
+ );
13777
+ }
13778
+ return resolved;
13779
+ }
13780
+ if (isProviderCredentialReference(value)) {
13781
+ if (!activeProvider) {
13782
+ throw new Error('Cannot resolve "providerCredential": no active provider on context.');
13783
+ }
13784
+ return `${value.prefix ?? ""}${activeProvider.credential}`;
13785
+ }
13786
+ if (isProviderBaseUrlReference(value)) {
13787
+ if (!activeProvider) {
13788
+ throw new Error('Cannot resolve "providerBaseUrl": no active provider on context.');
13789
+ }
13790
+ return activeProvider.baseUrl;
13791
+ }
13792
+ if (isAgentBaseUrlReference(value)) {
13793
+ if (!activeProvider) {
13794
+ throw new Error('Cannot resolve "agentBaseUrl": no active provider on context.');
13795
+ }
13796
+ return activeProvider.agentBaseUrl;
13797
+ }
13798
+ if (value.kind === "isolatedDir" || value.kind === "isolatedFile") {
13799
+ return resolveIsolatedEnvPath(env, baseDir, value);
13800
+ }
13801
+ throw new Error("Unsupported isolated environment value.");
13802
+ }
13803
+ function resolveIsolatedEnvPath(env, baseDir, value) {
13804
+ switch (value.kind) {
13805
+ case "isolatedDir":
13806
+ return value.relativePath ? path47.join(baseDir, value.relativePath) : baseDir;
13807
+ case "isolatedFile":
13808
+ return path47.join(baseDir, value.relativePath);
13809
+ }
13810
+ }
13811
+ function isEnvVarReference(value) {
13812
+ return typeof value === "object" && value.kind === "envVar";
13813
+ }
13814
+ function isProviderCredentialReference(value) {
13815
+ return typeof value === "object" && value.kind === "providerCredential";
13816
+ }
13817
+ function isProviderBaseUrlReference(value) {
13818
+ return typeof value === "object" && value.kind === "providerBaseUrl";
13819
+ }
13820
+ function isAgentBaseUrlReference(value) {
13821
+ return typeof value === "object" && value.kind === "agentBaseUrl";
13822
+ }
13823
+ function expandHomeShortcut(env, input) {
13824
+ if (!input.startsWith("~")) {
13825
+ return input;
13826
+ }
13827
+ if (input === "~") {
13828
+ return env.homeDir;
13829
+ }
13830
+ if (input.startsWith("~/") || input.startsWith(`~${path47.sep}`)) {
13831
+ return path47.join(env.homeDir, input.slice(2));
13832
+ }
13833
+ if (input.startsWith("~./") || input.startsWith(`~.${path47.sep}`)) {
13834
+ return path47.join(env.homeDir, `.${input.slice(3)}`);
13835
+ }
13836
+ return input;
13837
+ }
13838
+
13738
13839
  // src/providers/opencode.ts
13739
13840
  function providerModel(model) {
13740
13841
  const value = model ?? DEFAULT_FRONTIER_MODEL;
@@ -13784,6 +13885,17 @@ async function ensureHealthWorkspace(context) {
13784
13885
  }
13785
13886
  return dir;
13786
13887
  }
13888
+ var openCodeIsolatedEnv = {
13889
+ agentBinary: openCodeAgent.binaryName,
13890
+ configProbe: {
13891
+ kind: "isolatedFile",
13892
+ relativePath: ".config/opencode/config.json"
13893
+ },
13894
+ env: {
13895
+ XDG_CONFIG_HOME: { kind: "isolatedDir", relativePath: ".config" },
13896
+ XDG_DATA_HOME: { kind: "isolatedDir", relativePath: ".local/share" }
13897
+ }
13898
+ };
13787
13899
  var openCodeService = createProvider({
13788
13900
  ...openCodeAgent,
13789
13901
  configurationLabel: "OpenCode CLI",
@@ -13799,17 +13911,7 @@ var openCodeService = createProvider({
13799
13911
  }))
13800
13912
  }
13801
13913
  },
13802
- isolatedEnv: {
13803
- agentBinary: openCodeAgent.binaryName,
13804
- configProbe: {
13805
- kind: "isolatedFile",
13806
- relativePath: ".config/opencode/config.json"
13807
- },
13808
- env: {
13809
- XDG_CONFIG_HOME: { kind: "isolatedDir", relativePath: ".config" },
13810
- XDG_DATA_HOME: { kind: "isolatedDir", relativePath: ".local/share" }
13811
- }
13812
- },
13914
+ isolatedEnv: openCodeIsolatedEnv,
13813
13915
  manifest: {
13814
13916
  configure: [
13815
13917
  fileMutation.ensureDirectory({ path: "~/.config/opencode" }),
@@ -13897,7 +13999,7 @@ var openCodeService = createProvider({
13897
13999
  })
13898
14000
  );
13899
14001
  },
13900
- spawn(context, options) {
14002
+ async spawn(context, options) {
13901
14003
  const opts = options ?? {};
13902
14004
  const args = [
13903
14005
  ...getModelArgs(opts.model),
@@ -13905,12 +14007,22 @@ var openCodeService = createProvider({
13905
14007
  opts.prompt,
13906
14008
  ...opts.args ?? []
13907
14009
  ];
13908
- if (!opts.cwd && !opts.mcpServers) {
13909
- return context.command.runCommand("poe-code", ["wrap", "opencode", ...args]);
13910
- }
13911
- return context.command.runCommand("poe-code", ["wrap", "opencode", ...args], {
14010
+ const activeProvider = context.activeProvider;
14011
+ const details = await resolveIsolatedEnvDetails(
14012
+ context.env,
14013
+ openCodeIsolatedEnv,
14014
+ openCodeAgent.id,
14015
+ activeProvider
14016
+ );
14017
+ const mcpEnv = opts.mcpServers ? serializeOpenCodeMcpEnv(opts.mcpServers) : void 0;
14018
+ return context.command.runCommand("opencode", args, {
13912
14019
  cwd: opts.cwd,
13913
- env: opts.mcpServers ? serializeOpenCodeMcpEnv(opts.mcpServers) : void 0
14020
+ env: {
14021
+ ...activeProvider?.extraEnv ?? {},
14022
+ ...details?.env ?? {},
14023
+ ...mcpEnv ?? {},
14024
+ ...opts.env ?? {}
14025
+ }
13914
14026
  });
13915
14027
  }
13916
14028
  });