mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-15 05:02:07 +00:00
xubuntu
This commit is contained in:
parent
81b0a2f47a
commit
3919bbf708
2 changed files with 44 additions and 0 deletions
|
|
@ -188,6 +188,7 @@ export interface BrowserToolOptions {
|
||||||
stateDir?: string;
|
stateDir?: string;
|
||||||
agentDir?: string;
|
agentDir?: string;
|
||||||
headed?: boolean;
|
headed?: boolean;
|
||||||
|
windowClass?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BrowserCommandContext {
|
interface BrowserCommandContext {
|
||||||
|
|
@ -287,6 +288,15 @@ function shouldLaunchHeaded(options?: BrowserToolOptions): boolean {
|
||||||
return isTruthyEnv(process.env.COMPANION_AGENT_BROWSER_HEADED);
|
return isTruthyEnv(process.env.COMPANION_AGENT_BROWSER_HEADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBrowserWindowClass(
|
||||||
|
options?: BrowserToolOptions,
|
||||||
|
): string | undefined {
|
||||||
|
const rawValue =
|
||||||
|
options?.windowClass ?? process.env.COMPANION_BROWSER_WINDOW_CLASS;
|
||||||
|
const windowClass = rawValue?.trim();
|
||||||
|
return windowClass ? windowClass : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function createBrowserCommandContext(
|
function createBrowserCommandContext(
|
||||||
profilePath: string,
|
profilePath: string,
|
||||||
stateDir: string,
|
stateDir: string,
|
||||||
|
|
@ -356,6 +366,10 @@ function buildBrowserCommand(
|
||||||
if (shouldLaunchHeaded(options)) {
|
if (shouldLaunchHeaded(options)) {
|
||||||
baseArgs.push("--headed");
|
baseArgs.push("--headed");
|
||||||
}
|
}
|
||||||
|
const windowClass = getBrowserWindowClass(options);
|
||||||
|
if (windowClass) {
|
||||||
|
baseArgs.push("--args", `--class=${windowClass}`);
|
||||||
|
}
|
||||||
|
|
||||||
switch (input.action) {
|
switch (input.action) {
|
||||||
case "open": {
|
case "open": {
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,36 @@ describe("browser tool", () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("passes a custom browser window class through to agent-browser", async () => {
|
||||||
|
const cwd = createTempDir("coding-agent-browser-window-class-");
|
||||||
|
const profileDir = join(cwd, "profile");
|
||||||
|
const stateDir = join(cwd, "states");
|
||||||
|
const { calls, operations } = createMockBrowserOperations();
|
||||||
|
|
||||||
|
const browserTool = createBrowserTool(cwd, {
|
||||||
|
operations,
|
||||||
|
profileDir,
|
||||||
|
stateDir,
|
||||||
|
headed: true,
|
||||||
|
windowClass: "CompanionBrowser",
|
||||||
|
});
|
||||||
|
|
||||||
|
await browserTool.execute("browser-open-window-class", {
|
||||||
|
action: "open",
|
||||||
|
url: "https://example.com",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(calls[0]?.args).toEqual([
|
||||||
|
"--profile",
|
||||||
|
profileDir,
|
||||||
|
"--headed",
|
||||||
|
"--args",
|
||||||
|
"--class=CompanionBrowser",
|
||||||
|
"open",
|
||||||
|
"https://example.com",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("uses interactive snapshots by default and returns snapshot text", async () => {
|
it("uses interactive snapshots by default and returns snapshot text", async () => {
|
||||||
const cwd = createTempDir("coding-agent-browser-snapshot-");
|
const cwd = createTempDir("coding-agent-browser-snapshot-");
|
||||||
const profileDir = join(cwd, "profile");
|
const profileDir = join(cwd, "profile");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue