Skip to content

toolmark-monorepo / @toolmark/core/protocol / validateMessage

Function: validateMessage() ​

validateMessage(value, direction): Result

Defined in: packages/core/src/protocol/validate.ts:139

Validates a bridge protocol v1 message (hand-written, dependency-free; agrees with protocolSchemas). Top-level messages and ToolResults are strict; manifest entries and hints accept unknown properties; input and result.data are unconstrained.

Parameters ​

value ​

unknown

The parsed message.

direction ​

"toPage" | "toAgent"

toPage for agent→page messages, toAgent for page→agent messages.

Returns ​

Result

The typed message, or a reason (with unsupportedProtocol and the message id when the protocol version is not 1).