@testchimp/cli 0.1.72 → 0.1.73
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/chimphands/run.js +20 -0
- package/package.json +1 -1
package/dist/chimphands/run.js
CHANGED
|
@@ -2682,11 +2682,31 @@ function startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, han
|
|
|
2682
2682
|
}
|
|
2683
2683
|
};
|
|
2684
2684
|
try {
|
|
2685
|
+
// Prefer JSON for workspace-scoped APIs — OpenCode SPA fallback is text/html.
|
|
2686
|
+
if (opencodeProxyNeedsDirectory(pathPart) && !headers.Accept && !headers.accept) {
|
|
2687
|
+
headers.Accept = "application/json";
|
|
2688
|
+
}
|
|
2685
2689
|
const upstream = await fetch(target, init);
|
|
2686
2690
|
const respHeaders = {};
|
|
2687
2691
|
upstream.headers.forEach((v, k) => {
|
|
2688
2692
|
respHeaders[k] = v;
|
|
2689
2693
|
});
|
|
2694
|
+
const contentType = String(respHeaders["content-type"] || respHeaders["Content-Type"] || "").toLowerCase();
|
|
2695
|
+
// Root-cause: never tunnel OpenCode SPA HTML as a successful VCS/API response.
|
|
2696
|
+
if (opencodeProxyNeedsDirectory(pathPart) &&
|
|
2697
|
+
contentType.includes("text/html")) {
|
|
2698
|
+
const msg = `OpenCode returned HTML SPA shell for ${pathPart} ` +
|
|
2699
|
+
"(expected JSON API; check directory routing / API path)";
|
|
2700
|
+
console.error(`ChimpHands ${msg}`);
|
|
2701
|
+
send({
|
|
2702
|
+
type: "http_response",
|
|
2703
|
+
requestId,
|
|
2704
|
+
status: 502,
|
|
2705
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
2706
|
+
bodyBase64: Buffer.from(msg, "utf8").toString("base64"),
|
|
2707
|
+
});
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2690
2710
|
send({
|
|
2691
2711
|
type: "http_response_start",
|
|
2692
2712
|
requestId,
|
package/package.json
CHANGED