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.

feat(actions): add page.findSearch to report how a site can be searched

Shahriar83985cf3a46e
diff --git a/lib/actions/page/find-search.ts b/lib/actions/page/find-search.ts
new file mode 100644
index 0000000..5c0514a
--- /dev/null
+++ b/lib/actions/page/find-search.ts
@@ -0,0 +1,44 @@
+import { z } from 'zod';
+import { defineAction } from '../core';
+import { describeElement } from './dom';
+import {
+ bestSearchField,
+ describeField,
+ openSearchLink,
+ searchFields,
+ searchLinks,
+ searchTemplate,
+ searchToggles,
+} from './search';
+
+export const findSearch = defineAction({
+ name: 'page.findSearch',
+ description:
+ 'Report how this site can be searched from where you are: the search boxes on the page — including one hidden behind a header toggle — the buttons that reveal them, links to a search page, and the URL template a search would land on, with {query} where the words go. ' +
+ 'Read-only: it never types and never navigates. Call it to find out whether searching this site is possible at all before offering to, or to record a site’s search entry point while mapping it. ' +
+ 'An empty result with searchable false means this site has no search of its own — say so rather than typing into some other field.',
+ input: z.object({
+ maxPerKind: z
+ .number()
+ .int()
+ .positive()
+ .max(20)
+ .default(5)
+ .describe('Cap on search boxes, toggles and links listed per kind, most likely first'),
+ }),
+ execute({ maxPerKind }) {
+ const fields = searchFields();
+ const template = searchTemplate(bestSearchField(fields));
+ return {
+ url: location.href,
+ searchable: fields.length > 0 || !!template,
+ ...(template ?? {}),
+ fields: fields.slice(0, maxPerKind).map(describeField),
+ toggles: searchToggles(fields).slice(0, maxPerKind).map(describeElement),
+ links: searchLinks()
+ .slice(0, maxPerKind)
+ .map((link) => ({ ...describeElement(link), href: link.href })),
+ openSearch: openSearchLink(),
+ };
+ },
+});
diff --git a/lib/actions/registry.ts b/lib/actions/registry.ts
index 079f098..9b5c9b2 100644
--- a/lib/actions/registry.ts
+++ b/lib/actions/registry.ts
@@ -12,6 +12,7 @@ import { extractText } from './page/extract-text';
import { fillInput } from './page/fill-input';
import { findCaptcha } from './page/find-captcha';
import { findProgress } from './page/find-progress';
+import { findSearch } from './page/find-search';
import { focusInput } from './page/focus-input';
import { getPageInfo } from './page/get-page-info';
import { highlightElement } from './page/highlight-element';
@@ -58,6 +59,7 @@ export const actions: ReadonlyMap<string, AnyAction> = new Map(
submitForm,
waitForElement,
findProgress,
+ findSearch,
readTheme,
auditContrast,
applyTheme,