select_page
Choose a page to set as the active context for subsequent operations. Specify page ID and optionally bring the page to the foreground.
Instructions
Select a page as a context for future tool calls.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageId | Yes | The ID of the page to select. Call list_pages to get available pages. | |
| bringToFront | No | Whether to focus the page and bring it to the top. |
Implementation Reference
- src/daemon/rewrite.ts:24-24 (registration)Tool name constant definition for 'select_page' used throughout the system.
const SELECT_PAGE_TOOL = 'select_page'; - src/daemon/rewrite.ts:127-147 (handler)Core rewrite logic for select_page tool: validates pageId ownership, returns markSelectPageId so the daemon updates per-context page selection.
// select_page: track selection per-ctx; forward with pageId so upstream doesn't // clobber its global selection for others. if (toolName === SELECT_PAGE_TOOL) { const requested = params.pageId as number | undefined; if (requested == null) { return { params, shortCircuitError: {code: -32602, message: 'pageId required'}, }; } if (!ctx.owns(requested)) { return { params, shortCircuitError: { code: -32602, message: `pageId ${requested} not owned by this context`, }, }; } return {params, markSelectPageId: requested}; } - src/daemon/rewrite.ts:83-85 (schema)The markSelectPageId field in RewriteResult interface; after a successful select_page response, the daemon sets ctx.selectedPageId from this value.
/** If true, after a successful response, treat as select_page for ctx. */ markSelectPageId?: number; } - src/daemon/daemon.ts:381-383 (helper)Post-call handler in daemon.ts: after upstream responds to select_page, updates the context's selectedPageId using rewrite.markSelectPageId.
} else if (name === 'select_page' && rewrite.markSelectPageId != null) { ctx.selectedPageId = rewrite.markSelectPageId; } - test/harness/FakeUpstream.ts:194-201 (helper)Test harness implementation of the select_page tool handler used in tests.
if (name === 'select_page') { const id = Number(toolArgs.pageId); if (!pages.has(id)) { return {error: {code: -32602, message: `no page ${id}`}}; } setSelected(id); return {result: {content: [{type: 'text', text: pagesListText()}]}}; }