fix(cli): improve ui arg passthrough
This commit is contained in:
@@ -98,13 +98,7 @@ describe("gateway SIGTERM", () => {
|
|||||||
child.stdout?.on("data", (d) => out.push(String(d)));
|
child.stdout?.on("data", (d) => out.push(String(d)));
|
||||||
child.stderr?.on("data", (d) => err.push(String(d)));
|
child.stderr?.on("data", (d) => err.push(String(d)));
|
||||||
|
|
||||||
await waitForPortOpen(
|
await waitForPortOpen(proc, out, err, port, 20_000);
|
||||||
proc,
|
|
||||||
out,
|
|
||||||
err,
|
|
||||||
port,
|
|
||||||
20_000,
|
|
||||||
);
|
|
||||||
|
|
||||||
proc.kill("SIGTERM");
|
proc.kill("SIGTERM");
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import {
|
|||||||
browserTabs,
|
browserTabs,
|
||||||
resolveBrowserControlUrl,
|
resolveBrowserControlUrl,
|
||||||
} from "../browser/client.js";
|
} from "../browser/client.js";
|
||||||
import { runClawdisMac } from "../infra/clawdis-mac.js";
|
|
||||||
import { agentCommand } from "../commands/agent.js";
|
import { agentCommand } from "../commands/agent.js";
|
||||||
import { healthCommand } from "../commands/health.js";
|
import { healthCommand } from "../commands/health.js";
|
||||||
import { sendCommand } from "../commands/send.js";
|
import { sendCommand } from "../commands/send.js";
|
||||||
import { sessionsCommand } from "../commands/sessions.js";
|
import { sessionsCommand } from "../commands/sessions.js";
|
||||||
import { statusCommand } from "../commands/status.js";
|
import { statusCommand } from "../commands/status.js";
|
||||||
import { danger, info, setVerbose } from "../globals.js";
|
import { danger, info, setVerbose } from "../globals.js";
|
||||||
|
import { runClawdisMac } from "../infra/clawdis-mac.js";
|
||||||
import { loginWeb, logoutWeb } from "../provider-web.js";
|
import { loginWeb, logoutWeb } from "../provider-web.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
import { defaultRuntime } from "../runtime.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
@@ -230,9 +230,8 @@ Examples:
|
|||||||
.description("macOS UI automation via Clawdis.app (PeekabooBridge)")
|
.description("macOS UI automation via Clawdis.app (PeekabooBridge)")
|
||||||
.option("--json", "Output JSON (passthrough from clawdis-mac)", false)
|
.option("--json", "Output JSON (passthrough from clawdis-mac)", false)
|
||||||
.allowUnknownOption(true)
|
.allowUnknownOption(true)
|
||||||
.passThroughOptions()
|
|
||||||
.argument(
|
.argument(
|
||||||
"<uiArgs...>",
|
"[uiArgs...]",
|
||||||
"Args passed through to: clawdis-mac ui <command> ...",
|
"Args passed through to: clawdis-mac ui <command> ...",
|
||||||
)
|
)
|
||||||
.addHelpText(
|
.addHelpText(
|
||||||
@@ -247,9 +246,15 @@ Examples:
|
|||||||
clawdis ui --json see --bundle-id com.apple.Safari
|
clawdis ui --json see --bundle-id com.apple.Safari
|
||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
.action(async (uiArgs: string[], opts) => {
|
.action(async (_unused: string[], opts, cmd) => {
|
||||||
try {
|
try {
|
||||||
const res = await runClawdisMac(["ui", ...uiArgs], {
|
const raw = (cmd.parent?.rawArgs ?? []).map((a: unknown) => String(a));
|
||||||
|
const idx = raw.indexOf("ui");
|
||||||
|
const tail = idx >= 0 ? raw.slice(idx + 1) : [];
|
||||||
|
const forwarded =
|
||||||
|
tail.length > 0 && tail[0] === "--json" ? tail.slice(1) : tail;
|
||||||
|
|
||||||
|
const res = await runClawdisMac(["ui", ...forwarded], {
|
||||||
json: Boolean(opts.json),
|
json: Boolean(opts.json),
|
||||||
timeoutMs: 45_000,
|
timeoutMs: 45_000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,4 +63,3 @@ export async function runClawdisMac(
|
|||||||
const res = await runCommandWithTimeout(argv, opts?.timeoutMs ?? 30_000);
|
const res = await runCommandWithTimeout(argv, opts?.timeoutMs ?? 30_000);
|
||||||
return { stdout: res.stdout, stderr: res.stderr, code: res.code };
|
return { stdout: res.stdout, stderr: res.stderr, code: res.code };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user