The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(ego-browser): name the invalid argument type in keyboard.paste errors
Zhuowei Wangfcb7b72ddea6
diff --git a/package/ego-browser/src/clipboard.ts b/package/ego-browser/src/clipboard.tsindex d7eab3d..ce08092 100644--- a/package/ego-browser/src/clipboard.ts+++ b/package/ego-browser/src/clipboard.ts@@ -307,11 +307,17 @@ async function startClipboardHost(};}+function describeClipboardArgument(value: unknown): string {+ if (value === null) return "null";+ if (Array.isArray(value)) return "an array";+ return typeof value;+}+function validateClipboardInput(input: ClipboardInput): ClipboardInput {if (typeof input === "string") return input;if (!input || typeof input !== "object" || Array.isArray(input)) {throw new TypeError(- "page.keyboard.paste requires a string or { text, html? }",+ `page.keyboard.paste requires a string or { text, html? }, received ${describeClipboardArgument(input)}`,);}const keys = Object.keys(input);diff --git a/package/ego-browser/src/driver/page-keyboard.ts b/package/ego-browser/src/driver/page-keyboard.tsindex d63271d..62ae5ae 100644--- a/package/ego-browser/src/driver/page-keyboard.ts+++ b/package/ego-browser/src/driver/page-keyboard.ts@@ -235,13 +235,19 @@ export class PageKeyboardController {}}+function describeClipboardArgument(value: unknown): string {+ if (value === null) return "null";+ if (Array.isArray(value)) return "an array";+ return typeof value;+}+function assertClipboardContent(content: unknown,): asserts content is PageClipboardContent {if (typeof content === "string") return;if (!content || typeof content !== "object" || Array.isArray(content)) {throw new TypeError(- "page.keyboard.paste requires a string or { text, html? }",+ `page.keyboard.paste requires a string or { text, html? }, received ${describeClipboardArgument(content)}`,);}const value = content as Record<string, unknown>;diff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjsindex 3646caf..a4d6ed0 100644--- a/package/ego-browser/src/page-model.test.mjs+++ b/package/ego-browser/src/page-model.test.mjs@@ -4025,6 +4025,31 @@ test("Page keyboard paste forwards plain-text and HTML clipboard representations});});+test("Page keyboard paste names the invalid argument type", async () => {+ await withFixture(async (fixture) => {+ const task = taskForRound(fixture, "round-a", { platform: "win32" });+ const page = await openTestPage(task, "https://example.test/table");++ for (const [value, received] of [+ [undefined, "undefined"],+ [null, "null"],+ [["A", "B"], "an array"],+ [42, "number"],+ ]) {+ await assert.rejects(+ () => page.keyboard.paste(value),+ new RegExp(+ `requires a string or \\{ text, html\\? \\}, received ${received}$`,+ ),+ );+ }+ assert.equal(+ fixture.calls.some((call) => call[0] === "clipboard"),+ false,+ );+ });+});+test("Page keyboard paste still restores the clipboard when input fails", async () => {await withFixture(async (fixture) => {let restored = false;