@khalilgharbaoui/opencode-claude-code-plugin 0.4.2 → 0.4.3

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
@@ -577,6 +577,17 @@ function dotOpencodeDirs(cwd, worktree) {
577
577
  if (envDir && dirExists(envDir)) push(envDir);
578
578
  return dirs;
579
579
  }
580
+ function substituteEnvPlaceholders(source) {
581
+ const out = {};
582
+ for (const [k, v] of Object.entries(source)) {
583
+ if (typeof v !== "string") continue;
584
+ out[k] = v.replace(/\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
585
+ const resolved = process.env[name];
586
+ return typeof resolved === "string" ? resolved : "";
587
+ });
588
+ }
589
+ return out;
590
+ }
580
591
  function translateServer(name, spec) {
581
592
  if (spec.enabled === false) return null;
582
593
  const type = spec.type;
@@ -592,7 +603,9 @@ function translateServer(name, spec) {
592
603
  };
593
604
  if (cmd.length > 1) out.args = cmd.slice(1).map((s) => String(s));
594
605
  if (spec.environment && typeof spec.environment === "object") {
595
- out.env = spec.environment;
606
+ out.env = substituteEnvPlaceholders(
607
+ spec.environment
608
+ );
596
609
  }
597
610
  return out;
598
611
  }
@@ -606,7 +619,9 @@ function translateServer(name, spec) {
606
619
  url: spec.url
607
620
  };
608
621
  if (spec.headers && typeof spec.headers === "object") {
609
- out.headers = spec.headers;
622
+ out.headers = substituteEnvPlaceholders(
623
+ spec.headers
624
+ );
610
625
  }
611
626
  return out;
612
627
  }
@@ -2857,6 +2872,33 @@ ${plan}
2857
2872
  });
2858
2873
  turnCompleted = true;
2859
2874
  endTextBlock();
2875
+ if (drainBuffer.length > 0) {
2876
+ log.info(
2877
+ "draining pending proxy calls at turn-result boundary",
2878
+ {
2879
+ sessionKey: sk,
2880
+ count: drainBuffer.length
2881
+ }
2882
+ );
2883
+ drainNow();
2884
+ return;
2885
+ }
2886
+ const orphanPending = getPendingProxyCalls(sk);
2887
+ if (orphanPending.length > 0) {
2888
+ log.warn(
2889
+ "rejecting orphan pending proxy calls at turn-result boundary",
2890
+ {
2891
+ sessionKey: sk,
2892
+ count: orphanPending.length
2893
+ }
2894
+ );
2895
+ rejectAllPendingProxyCallsForSession(
2896
+ sk,
2897
+ new Error(
2898
+ "Claude CLI emitted result with pending proxy calls not in drain buffer"
2899
+ )
2900
+ );
2901
+ }
2860
2902
  for (const [idx, reasoningId] of reasoningIds) {
2861
2903
  if (reasoningStarted.get(idx)) {
2862
2904
  controller.enqueue({