Skip to content

Class: PageToolDirectory

Defined in: packages/aiui-claude-channel/src/page-tools.ts:173

The channel's live registry of page-declared tools and the connections that back them. One instance per channel process; shared by the /tools websocket (which feeds it) and the MCP tools (which read and drive it).

Constructors

Constructor

new PageToolDirectory(options?): PageToolDirectory

Defined in: packages/aiui-claude-channel/src/page-tools.ts:192

Parameters

options?

PageToolDirectoryOptions = {}

Returns

PageToolDirectory

Methods

addConnection()

addConnection(send): string

Defined in: packages/aiui-claude-channel/src/page-tools.ts:200

Register a freshly connected page socket; returns its server-assigned id.

Parameters

send

PageToolSend

Returns

string


call()

call(request): Promise<unknown>

Defined in: packages/aiui-claude-channel/src/page-tools.ts:502

Route a call to the one page registration that matches. clientId/ns narrow the search; either may be omitted when the match is already unique. Among several matches, a single one on the browser's active tab wins (MCP-B's routing rule: active tab first, else any tab holding the tool). Rejects on remaining ambiguity (listing the candidates), when nothing matches, on timeout, or if the page disconnects before answering.

Parameters

request

PageToolCall

Returns

Promise<unknown>


handleClientMessage()

handleClientMessage(clientId, raw): void

Defined in: packages/aiui-claude-channel/src/page-tools.ts:233

Dispatch one parsed client message (a register, a result, or an activation). Validates loosely — a malformed message is ignored rather than fatal, since the transport is a cooperative same-host client.

Parameters

clientId

string

raw

unknown

Returns

void


list()

list(): PageToolRegistration[]

Defined in: packages/aiui-claude-channel/src/page-tools.ts:447

Every current registration, across all connections — active-tab entries first (stable within each group): the agent reads the list top-down and the tab the user is looking at is the likeliest routing target. When two connections carry the SAME namespace, the losers are marked shadowed (the honest rendering of a duplicate — call routing prefers the winner).

Returns

PageToolRegistration[]


onChange()

onChange(listener): () => void

Defined in: packages/aiui-claude-channel/src/page-tools.ts:257

Subscribe to the debounced change signal. Fires once per quiet period after the TOOL SET changes: a registration under a new hash, or a namespace lost to socket close. Same-hash re-registrations (HMR churn), reconnects that restore an identical set within the debounce window, and ACTIVATION flips (tab switches — deliberately unobservable here; see signature) never fire — the signature gate below is the same dedupe-by-content-hash discipline registration logging uses. Returns an unsubscribe function.

Parameters

listener

() => void

Returns

() => void


removeConnection()

removeConnection(clientId): void

Defined in: packages/aiui-claude-channel/src/page-tools.ts:215

Drop a connection: forget its namespaces and reject any in-flight calls. Called when the socket closes.

Parameters

clientId

string

Returns

void


summary()

summary(): PageToolSummary

Defined in: packages/aiui-claude-channel/src/page-tools.ts:470

Cheap counts for a /health or /debug summary.

Returns

PageToolSummary