@testchimp/cli 0.1.62 → 0.1.63
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.d.ts +2 -0
- package/dist/chimphands/run.js +26 -1
- package/package.json +1 -1
package/dist/chimphands/run.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ type RunOptions = {
|
|
|
19
19
|
runtimeId?: string;
|
|
20
20
|
};
|
|
21
21
|
export declare function runChimphands(opts: RunOptions): Promise<void>;
|
|
22
|
+
/** OpenCode workspace-scoped APIs require directory routing (header + query). */
|
|
23
|
+
export declare function appendOpencodeDirectoryRouting(path: string, query: string | undefined, headers: Record<string, string>, directory: string): string;
|
|
22
24
|
/** Runtime-aware entry: register + attach to local OpenCode server (Phase 1+). */
|
|
23
25
|
export declare function serveChimphands(opts: RunOptions & {
|
|
24
26
|
attachUrl: string;
|
package/dist/chimphands/run.js
CHANGED
|
@@ -2122,9 +2122,32 @@ async function commitAndPushDirtyWorktree(message) {
|
|
|
2122
2122
|
console.error(`ChimpHands commit-before-idle failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
2123
2123
|
}
|
|
2124
2124
|
}
|
|
2125
|
+
function opencodeProxyNeedsDirectory(path) {
|
|
2126
|
+
const p = path.startsWith("/") ? path : `/${path}`;
|
|
2127
|
+
return (p.startsWith("/vcs") ||
|
|
2128
|
+
p.startsWith("/file") ||
|
|
2129
|
+
p.startsWith("/path") ||
|
|
2130
|
+
p.startsWith("/session") ||
|
|
2131
|
+
p.startsWith("/instance") ||
|
|
2132
|
+
p.startsWith("/event") ||
|
|
2133
|
+
p.startsWith("/global/event"));
|
|
2134
|
+
}
|
|
2135
|
+
/** OpenCode workspace-scoped APIs require directory routing (header + query). */
|
|
2136
|
+
export function appendOpencodeDirectoryRouting(path, query, headers, directory) {
|
|
2137
|
+
if (!opencodeProxyNeedsDirectory(path)) {
|
|
2138
|
+
return query || "";
|
|
2139
|
+
}
|
|
2140
|
+
headers["x-opencode-directory"] = directory;
|
|
2141
|
+
if (query?.includes("directory=")) {
|
|
2142
|
+
return query;
|
|
2143
|
+
}
|
|
2144
|
+
const dirParam = `directory=${encodeURIComponent(directory)}`;
|
|
2145
|
+
return query ? `${query}&${dirParam}` : dirParam;
|
|
2146
|
+
}
|
|
2125
2147
|
function startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, handlers) {
|
|
2126
2148
|
let stopped = false;
|
|
2127
2149
|
const base = attachUrl.replace(/\/$/, "");
|
|
2150
|
+
const workDirectory = process.cwd();
|
|
2128
2151
|
let ws = null;
|
|
2129
2152
|
let reconnectTimer = null;
|
|
2130
2153
|
let backoffMs = 1000;
|
|
@@ -2140,8 +2163,10 @@ function startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, han
|
|
|
2140
2163
|
if (!req.requestId || socket.readyState !== 1)
|
|
2141
2164
|
return;
|
|
2142
2165
|
const requestId = req.requestId;
|
|
2143
|
-
const
|
|
2166
|
+
const pathPart = req.path || "/";
|
|
2144
2167
|
const headers = { ...(req.headers || {}) };
|
|
2168
|
+
const query = appendOpencodeDirectoryRouting(pathPart, req.query, headers, workDirectory);
|
|
2169
|
+
const target = base + pathPart + (query ? `?${query}` : "");
|
|
2145
2170
|
const init = { method: req.method || "GET", headers };
|
|
2146
2171
|
if (req.bodyBase64) {
|
|
2147
2172
|
init.body = Buffer.from(req.bodyBase64, "base64");
|
package/package.json
CHANGED