Skip to content

Computer use for the Pi coding agent — Windows apps, browsers and desktops through native UI trees, screenshots and real input.

fix: use placeholder machine names in examples and tests

alexshpunt-clanker[bot]35797f0c14f3
diff --git a/src/computer-resources.ts b/src/computer-resources.ts
index 9e78bf6..2835ffa 100644
--- a/src/computer-resources.ts
+++ b/src/computer-resources.ts
@@ -333,7 +333,7 @@ export class ComputerResources {
private readonly starting = new Map<string, Promise<OpenedMachine>>();
/** Sandbox launches and machine starts still in progress; a cancelled one finishes its own cleanup before it settles. */
private readonly opening = new Set<Promise<unknown>>();
- /** Short aliases of this run's long addresses (computer:zinpc/w3qk). */
+ /** Short aliases of this run's long addresses (computer:<machine>/w3qk). */
private readonly shorts = new ShortAddresses();
/** Window names the agent gave, with the window's title when it was named. */
private readonly names = new Map<string, { window_ref: string; title: string }>();
@@ -394,7 +394,7 @@ export class ComputerResources {
details: { status: "delivered", mode: this.getMode(), window_ref: ref } };
}
/**
- * Parse an address the agent sent: a long one, a short alias issued in this run (computer:zinpc/w3qk, with the
+ * Parse an address the agent sent: a long one, a short alias issued in this run (computer:<machine>/w3qk, with the
* observation options of the long form), or a window name (computer:game). Stale aliases and names refuse.
*/
address(source: string): ComputerAddress {
@@ -420,7 +420,7 @@ export class ComputerResources {
if (!NAME.test(segments[1])) throw new ComputerRequestError("A viewport name is 1-32 lowercase letters, digits, - or _ and starts with a letter.");
return requireComputerAddress(viewportSource(this.names.get(segments[0])!.window_ref, segments[1]));
}
- // A short window address, or a viewport of one: computer:zinpc/w3qk or computer:zinpc/w3qk/pano.
+ // A short window address, or a viewport of one: computer:<machine>/w3qk or computer:<machine>/w3qk/pano.
if ((segments.length === 2 || segments.length === 3) && !ADDRESS_KINDS.has(segments[0]) && SHORT_REFERENCE.test(segments[1])) {
let long: string;
try { long = this.shorts.resolve(segments[0], segments[1]); }
@@ -979,7 +979,7 @@ export class ComputerResources {
*/
async view(address: ComputerAddress, cwd: string, given: Partial<PixelBox>, signal?: AbortSignal): Promise<ComputerResult> {
if (address.kind !== "viewport")
- throw new ComputerRequestError("computer_view needs a viewport address: computer:<window name>/<viewport name> such as computer:game/pano, or a window address with the viewport name after it such as computer:zinpc/w3qk/pano.");
+ throw new ComputerRequestError("computer_view needs a viewport address: computer:<window name>/<viewport name> such as computer:game/pano, or a window address with the viewport name after it such as computer:<machine>/w3qk/pano.");
const existing = this.viewports.get(viewportSource(address.ref, address.name));
if (existing) this.viewport(address);
const place = this.place(address);
@@ -1066,7 +1066,7 @@ export class ComputerResources {
*/
async input(address: ComputerAddress, cwd: string, plan: InputPlan, signal?: AbortSignal): Promise<ComputerResult> {
if (address.kind !== "window" && address.kind !== "viewport")
- throw new ComputerRequestError("Give the window address from Search, Read or a name, such as computer:zinpc/w3qk or computer:game, or a viewport address such as computer:game/pano.");
+ throw new ComputerRequestError("Give the window address from Search, Read or a name, such as computer:<machine>/w3qk or computer:game, or a viewport address such as computer:game/pano.");
// In a viewport, points are pixels of the viewport's image and its pixels show what the action changed.
const viewport = address.kind === "viewport" ? this.viewport(address) : undefined;
if (viewport && plan.space !== undefined) throw new ComputerRequestError("space does not apply in a viewport: its points are pixels of the viewport's image.");
diff --git a/src/computer-tools.ts b/src/computer-tools.ts
index b62f22c..7c2e536 100644
--- a/src/computer-tools.ts
+++ b/src/computer-tools.ts
@@ -73,7 +73,7 @@ export function openCommand(address: ComputerAddress, params: Static<typeof open
}
const windowParameters = Type.Object({
- window: Type.String({ description: "Window address from {search}, {read} or a name, such as computer:zinpc/w3qk or computer:game." }),
+ window: Type.String({ description: "Window address from {search}, {read} or a name, such as computer:<machine>/w3qk or computer:game." }),
action: StringEnum(["move", "resize", "maximize", "minimize", "focus", "restore", "name"] as const,
{ description: "focus activates a visible window; restore brings a minimized window back and activates it; name gives the window a short address computer:<as>." }),
as: Type.Optional(Type.String({ description: "name: 1-32 lowercase letters, digits, - or _, starting with a letter, such as game. It resolves until the window closes." })),
@@ -95,7 +95,7 @@ export function windowCommand(params: Static<typeof windowParameters>): Record<s
}
const viewParameters = Type.Object({
- viewport: Type.String({ description: "Viewport address: a window's name or address with the viewport's name after it, such as computer:game/pano or computer:zinpc/w3qk/pano. The name is 1-32 lowercase letters, digits, - or _, starting with a letter. A new name makes the viewport and needs x, y, width and height; for an existing one, give only what changes." }),
+ viewport: Type.String({ description: "Viewport address: a window's name or address with the viewport's name after it, such as computer:game/pano or computer:<machine>/w3qk/pano. The name is 1-32 lowercase letters, digits, - or _, starting with a letter. A new name makes the viewport and needs x, y, width and height; for an existing one, give only what changes." }),
x: Type.Optional(Type.Integer({ minimum: 0, description: "Left edge in pixels of the window's latest image." })),
y: Type.Optional(Type.Integer({ minimum: 0, description: "Top edge in pixels of the window's latest image." })),
width: Type.Optional(Type.Integer({ minimum: 1, description: "Width in pixels of the window's latest image." })),
diff --git a/src/session.ts b/src/session.ts
index 83dfab9..badf449 100644
--- a/src/session.ts
+++ b/src/session.ts
@@ -210,7 +210,7 @@ const appName = (name: string) => name.trim().toLowerCase().replace(/^windows\s+
/** File name of a Win32 launch path without directory and extension; packaged shell:appsFolder paths have none. */
const executableName = (path: string) => /^shell:/i.test(path) ? "" : appName(path.split(/[\\/]/).pop() ?? "");
-/** Watch captures in flight at once. A third measured no faster on ZinPC: part of each driver call is serial. */
+/** Watch captures in flight at once. A third measured no faster: part of each driver call is serial. */
const WATCH_CONCURRENCY = 2;
/** A watch frame the driver cropped to its viewport: the image is the viewport, at most `cap` on its long edge. */
function nativeCropFrame(state: Record<string, unknown>, images: SequenceFrame["image"][], requested: PixelBox, cap: number, base: ObservationSource) {
diff --git a/test/computer-renderers.test.ts b/test/computer-renderers.test.ts
index 2e6c86c..6ca487d 100644
--- a/test/computer-renderers.test.ts
+++ b/test/computer-renderers.test.ts
@@ -4,7 +4,7 @@ import { computerActionRenderer, computerReadRenderer, typedRenderers } from "..
// Plain theme: styling is not the contract, the words and the layout are.
const theme = { fg: (_: unknown, text: string) => text, bold: (text: string) => text, underline: (text: string) => text };
-const describe = (source: string) => source.includes("w1") ? { machine: "zinpc", title: "Untitled - Notepad" } : undefined;
+const describe = (source: string) => source.includes("w1") ? { machine: "remote", title: "Untitled - Notepad" } : undefined;
const ctx = (isError = false) => ({ isError, args: {}, lastComponent: undefined });
const action = (data: Record<string, unknown>, isError = false) => ({ content: [{ type: "text", text: "PRIVATE_AGENT_TEXT" }], isError,
details: { metadata: { semanticAction: { kind: "computer-action", ...data } } } });
@@ -13,16 +13,16 @@ const result = (tool: string, data: Record<string, unknown>, options: { expanded
draw(typedRenderers(tool, describe).renderResult(action(data, isError) as never, { expanded: false, isPartial: false, ...options }, theme as never, ctx(isError) as never), width);
test("a delivered action says where it ran and what changed in the UI, not the receipt text", () => {
- const lines = result("computer_click", { ok: true, effect: "applied", status: "delivered", machine: "zinpc", script: { window: "computer:zinpc/w1ab" },
+ const lines = result("computer_click", { ok: true, effect: "applied", status: "delivered", machine: "remote", script: { window: "computer:remote/w1ab" },
successor: { diff: { kind: "ui", changed: ["1:a Edit value=1"], added: [], removed: [], counts: { changed: 1, added: 0, removed: 0 }, waited_ms: 180 } } });
- expect(lines[0]).toBe("✓ delivered · zinpc");
+ expect(lines[0]).toBe("✓ delivered · remote");
expect(lines.join("\n")).toMatch(/1 changed.*180 ms/);
expect(lines.join("\n")).toContain("~ 1:a Edit value=1");
expect(lines.join("\n")).not.toContain("PRIVATE_AGENT_TEXT");
});
test("an action that changed nothing says so in a note", () => {
- const lines = result("computer_click", { ok: true, status: "delivered", machine: "zinpc",
+ const lines = result("computer_click", { ok: true, status: "delivered", machine: "remote",
successor: { diff: { kind: "ui", changed: [], added: [], removed: [], counts: { changed: 0, added: 0, removed: 0 }, waited_ms: 300 } } });
// The fixture's wait time is the one fact worth checking; the sentence around it is wording.
expect(lines).toHaveLength(2);
@@ -30,8 +30,8 @@ test("an action that changed nothing says so in a note", () => {
});
test("unknown warns that the action may have happened; refused and failed give their one-line reason", () => {
- const unknown = result("computer_type", { ok: false, effect: "unknown", status: "unknown", machine: "zinpc", script: { reason: "Driver returned unknown for type_text. Observe again." } }, {}, 200);
- expect(unknown[0]).toBe("? unknown · zinpc");
+ const unknown = result("computer_type", { ok: false, effect: "unknown", status: "unknown", machine: "remote", script: { reason: "Driver returned unknown for type_text. Observe again." } }, {}, 200);
+ expect(unknown[0]).toBe("? unknown · remote");
// The reason from the receipt, then one caution line that the action may have happened.
expect(unknown).toHaveLength(3);
expect(unknown[1]).toContain("Driver returned unknown for type_text");
@@ -45,9 +45,9 @@ test("unknown warns that the action may have happened; refused and failed give t
});
test("a resize that Windows settled within the allowed difference shows the measured size", () => {
- const lines = result("computer_window", { ok: true, status: "delivered", machine: "zinpc", state: { operation: "resize", mutation_attempted: true, postcondition_confirmed: true,
+ const lines = result("computer_window", { ok: true, status: "delivered", machine: "remote", state: { operation: "resize", mutation_attempted: true, postcondition_confirmed: true,
requested_bounds: { width: 600, height: 450 }, observed: { bounds: { width: 601, height: 450 } } } });
- expect(lines[0]).toBe("✓ delivered · zinpc · resize · 601×450");
+ expect(lines[0]).toBe("✓ delivered · remote · resize · 601×450");
expect(lines).toHaveLength(2);
expect(lines[1]).toContain("601×450");
expect(lines[1]).toContain("600×450");
@@ -59,12 +59,12 @@ test("while a call runs the card shows only the running state", () => {
test("headings name the window by title, show literal input only by length, and drop options before clipping the target", () => {
const heading = (args: Record<string, unknown>, width = 100) => draw(typedRenderers("computer_type", describe).renderCall(args, theme as never, { ...ctx(), expanded: false } as never), width);
- expect(heading({ window: "computer:zinpc/w1ab", target: "2:a", text: "PRIVATE_TYPED_TEXT", submit: true })[0]).toBe("computer_type “Untitled - Notepad” · 2:a · 18 chars · + Enter");
- const narrow = heading({ window: "computer:zinpc/w1ab", target: "2:a", text: "x", submit: true }, 40)[0];
+ expect(heading({ window: "computer:remote/w1ab", target: "2:a", text: "PRIVATE_TYPED_TEXT", submit: true })[0]).toBe("computer_type “Untitled - Notepad” · 2:a · 18 chars · + Enter");
+ const narrow = heading({ window: "computer:remote/w1ab", target: "2:a", text: "x", submit: true }, 40)[0];
expect(visibleWidth(narrow)).toBeLessThanOrEqual(40);
expect(narrow).toContain("computer_type “Untitled - Notepad”");
- const expanded = draw(typedRenderers("computer_type", describe).renderCall({ window: "computer:zinpc/w1ab", text: "PRIVATE_TYPED_TEXT", delay_ms: 0 }, theme as never, { ...ctx(), expanded: true } as never), 100).join("\n");
- expect(expanded).toContain("window=computer:zinpc/w1ab");
+ const expanded = draw(typedRenderers("computer_type", describe).renderCall({ window: "computer:remote/w1ab", text: "PRIVATE_TYPED_TEXT", delay_ms: 0 }, theme as never, { ...ctx(), expanded: true } as never), 100).join("\n");
+ expect(expanded).toContain("window=computer:remote/w1ab");
expect(expanded).toContain("delay_ms=0");
expect(expanded).not.toContain("PRIVATE_TYPED_TEXT");
});
@@ -79,10 +79,10 @@ test("app text is data: control sequences never reach the terminal and every lin
test("a Read shows the listing or UI structure as rows, bounded, with the rest behind expand", () => {
const elements = Array.from({ length: 9 }, (_, i) => ({ hint: `1:${"abcdefghi"[i]}`, role: "Button", name: `Button ${i}`, value: "PRIVATE_FIELD_VALUE", enabled: true }));
const read = (expanded: boolean) => draw(computerReadRenderer(describe)({ content: [{ type: "text", text: "PRIVATE_AGENT_TEXT" }], details: { source: "computer:window/x", resolvedBy: "computer",
- computer: { status: "observed", machine: "zinpc", window_ref: "w1", agent_image: { output: { width: 500, height: 350 } }, ui: { collected: 9, truncated: false, elements } } } } as never,
+ computer: { status: "observed", machine: "remote", window_ref: "w1", agent_image: { output: { width: 500, height: 350 } }, ui: { collected: 9, truncated: false, elements } } } } as never,
{ expanded, isPartial: false }, theme as never, ctx() as never), 100);
const compact = read(false);
- expect(compact[0]).toContain("✓ observed · zinpc");
+ expect(compact[0]).toContain("✓ observed · remote");
expect(compact[0]).toContain("image 500×350 · UI 9 elements");
expect(compact).toHaveLength(1 + 6 + 1);
expect(compact.at(-1)).toContain("3");
@@ -99,7 +99,7 @@ test("write, insert and delete renderers select only computer addresses and sema
expect(renderer.matches({ details: { metadata: { semanticAction: { kind: "computer-action" } } } }, "result")).toBe(true);
for (const value of [undefined, { details: {} }, { details: { metadata: { semanticAction: { kind: "file-action" } } } }]) expect(renderer.matches(value, "result")).toBe(false);
}
- const lines = draw(computerActionRenderer("write", describe).renderCall({ path: "computer:zinpc/o1ab", content: "PRIVATE_TYPED_TEXT" }, theme as never, { ...ctx(), expanded: false } as never));
- expect(lines[0]).toBe("write observation o1ab · zinpc");
+ const lines = draw(computerActionRenderer("write", describe).renderCall({ path: "computer:remote/o1ab", content: "PRIVATE_TYPED_TEXT" }, theme as never, { ...ctx(), expanded: false } as never));
+ expect(lines[0]).toBe("write observation o1ab · remote");
expect(lines.join("\n")).not.toContain("PRIVATE_TYPED_TEXT");
});
diff --git a/test/live/dpi-scaling.live.ts b/test/live/dpi-scaling.live.ts
index d96af35..ce1b2f6 100644
--- a/test/live/dpi-scaling.live.ts
+++ b/test/live/dpi-scaling.live.ts
@@ -4,7 +4,7 @@ import { connectLive, nativeForm, openWindow, text, WINDOWS_POWERSHELL_PATH as P
// LPT-907: on a display scaled above 100%, Windows paints a DPI-unaware window at 96 DPI and stretches it on screen.
// Its overview must show that stretched window, so UI bounds, OCR boxes and pixel input agree with the image.
-// Run it on a machine scaled above 100% (ZinPC: 150%).
+// Run it on a machine scaled above 100%, for example 150%.
const live = await connectLive();
const pids: number[] = [];
afterAll(async () => { for (const pid of pids) await live.kill(pid); await live.close(); });