Skip to content

Commit b4b731f

Browse files
chore(headless): bump openwrk to 0.1.8 (anomalyco#379)
1 parent 599930b commit b4b731f

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎packages/headless/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openwrk",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"description": "Headless OpenWork host orchestrator for OpenCode + OpenWork server + Owpenbot",
55
"type": "module",
66
"bin": {

‎packages/headless/src/cli.ts‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,10 @@ async function startOwpenbot(options: {
950950
}) {
951951
const args = ["start", options.workspace];
952952
if (options.opencodeUrl) {
953-
args.push("--opencode-url", options.opencodeUrl);
953+
const supports = await owpenbotSupportsOpencodeUrl(options.bin);
954+
if (supports) {
955+
args.push("--opencode-url", options.opencodeUrl);
956+
}
954957
}
955958

956959
const resolved = resolveBinCommand(options.bin);
@@ -959,6 +962,8 @@ async function startOwpenbot(options: {
959962
stdio: ["ignore", "pipe", "pipe"],
960963
env: {
961964
...process.env,
965+
...(options.opencodeUrl ? { OPENCODE_URL: options.opencodeUrl } : {}),
966+
OPENCODE_DIRECTORY: options.workspace,
962967
...(options.opencodeUsername ? { OPENCODE_SERVER_USERNAME: options.opencodeUsername } : {}),
963968
...(options.opencodePassword ? { OPENCODE_SERVER_PASSWORD: options.opencodePassword } : {}),
964969
},
@@ -970,6 +975,40 @@ async function startOwpenbot(options: {
970975
return child;
971976
}
972977

978+
async function owpenbotSupportsOpencodeUrl(bin: string): Promise<boolean> {
979+
const resolved = resolveBinCommand(bin);
980+
return new Promise((resolve) => {
981+
const child = spawn(resolved.command, [...resolved.prefixArgs, "--help"], {
982+
stdio: ["ignore", "pipe", "pipe"],
983+
});
984+
let output = "";
985+
const timeout = setTimeout(() => {
986+
try {
987+
child.kill("SIGKILL");
988+
} catch {
989+
// ignore
990+
}
991+
resolve(output.includes("--opencode-url"));
992+
}, 1500);
993+
994+
const onChunk = (chunk: unknown) => {
995+
output += String(chunk ?? "");
996+
};
997+
998+
child.stdout?.on("data", onChunk);
999+
child.stderr?.on("data", onChunk);
1000+
1001+
child.on("exit", () => {
1002+
clearTimeout(timeout);
1003+
resolve(output.includes("--opencode-url"));
1004+
});
1005+
child.on("error", () => {
1006+
clearTimeout(timeout);
1007+
resolve(false);
1008+
});
1009+
});
1010+
}
1011+
9731012
async function verifyOwpenbotVersion(binary: ResolvedBinary): Promise<string | undefined> {
9741013
const actual = await readCliVersion(binary.bin);
9751014
assertVersionMatch("owpenbot", binary.expectedVersion, actual, binary.bin);

0 commit comments

Comments
 (0)