Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

perf(actions): drop the dialect URL and the implied safe-integer bounds from every tool schema

Shahriar0c13c8db6e65
diff --git a/src/lib/actions/registry.test.ts b/src/lib/actions/registry.test.ts
new file mode 100644
index 0000000..0077b4b
--- /dev/null
+++ b/src/lib/actions/registry.test.ts
@@ -0,0 +1,22 @@
+import { describe, expect, test } from 'vitest';
+import { describeActions } from './registry';
+
+const schemaOf = (name: string) =>
+ describeActions().find((action) => action.name === name)!.inputSchema as {
+ properties: Record<string, { properties?: Record<string, Record<string, unknown>> } & Record<string, unknown>>;
+ };
+
+describe('the described schemas', () => {
+ test('none carries the JSON Schema dialect URL', () => {
+ expect(JSON.stringify(describeActions())).not.toContain('$schema');
+ });
+
+ test('none carries the safe-integer bounds zod implies for an integer', () => {
+ expect(JSON.stringify(describeActions())).not.toContain(String(Number.MAX_SAFE_INTEGER));
+ });
+
+ test('a bound the action declared itself is kept', () => {
+ expect(schemaOf('page.clickElement').properties.target.properties!.nth).toMatchObject({ type: 'integer', minimum: 0 });
+ expect(schemaOf('page.dragElement').properties.steps).toMatchObject({ minimum: 2, maximum: 60 });
+ });
+});
diff --git a/src/lib/actions/registry.ts b/src/lib/actions/registry.ts
index 17b796d..ed3b3e3 100644
--- a/src/lib/actions/registry.ts
+++ b/src/lib/actions/registry.ts
@@ -117,6 +117,24 @@ export function describeActions(): ToolDescriptor[] {
return [...actions.values()].map(({ name, description, input }) => ({
name,
description,
- inputSchema: z.toJSONSchema(input, { io: 'input' }),
+ inputSchema: tidy(z.toJSONSchema(input, { io: 'input' })),
}));
}
+
+const UNBOUNDED = new Set([Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER]);
+
+/**
+ * Every tool's schema is re-sent to the model on every turn, so what zod emits for its
+ * own sake — the dialect URL, and the safe-integer bounds `.int()` implies — is cut.
+ */
+function tidy(schema: unknown): unknown {
+ if (Array.isArray(schema)) return schema.map(tidy);
+ if (!schema || typeof schema !== 'object') return schema;
+ return Object.fromEntries(
+ Object.entries(schema)
+ .filter(([key, value]) => key !== '$schema' && !(isBound(key) && UNBOUNDED.has(value as number)))
+ .map(([key, value]) => [key, tidy(value)]),
+ );
+}
+
+const isBound = (key: string) => key === 'minimum' || key === 'maximum';