Skip to content

Protocol

Defined in: src/protocol.ts:25

Fluent builder for defining RPC methods. Register unary, producer, and exchange methods, then pass to VgiRpcServer.

new Protocol(name, options?): Protocol;

Defined in: src/protocol.ts:40

ParameterType
namestring
options?{ protocolVersion?: string; }
options.protocolVersion?string

Protocol

readonly name: string;

Defined in: src/protocol.ts:27

Service / protocol name, exposed to clients via introspection.


readonly protocolVersion: string;

Defined in: src/protocol.ts:35

Application protocol surface version. When non-empty, the server enforces exact major+minor match (patch ignored) against every request’s vgi_rpc.protocol_version metadata; clients bound to this Protocol emit the value on every request. Format: canonical semver MAJOR.MINOR.PATCH. Mirrors Python’s Protocol.protocol_version ClassVar.


readonly protocolVersionParts: readonly [number, number, number] | null;

Defined in: src/protocol.ts:37

Parsed semver tuple; null when protocolVersion is unset.

exchange<S>(name, config): this;

Defined in: src/protocol.ts:130

Register an exchange (bidirectional-streaming) method. The generic S is inferred from the init return type and threaded to exchange.

Type Parameter
S
ParameterType
namestring
config{ defaults?: Record<string, any>; doc?: string; exchange: ExchangeFn<S>; headerInit?: HeaderInit; headerSchema?: SchemaLike; init: ExchangeInit<S>; inputSchema: SchemaLike; onCancel?: OnCancelFn<S>; outputSchema: SchemaLike; params: SchemaLike; paramTypes?: Record<string, string>; }
config.defaults?Record<string, any>
config.doc?string
config.exchangeExchangeFn<S>
config.headerInit?HeaderInit
config.headerSchema?SchemaLike
config.initExchangeInit<S>
config.inputSchemaSchemaLike
config.onCancel?OnCancelFn<S>
config.outputSchemaSchemaLike
config.paramsSchemaLike
config.paramTypes?Record<string, string>

this


getMethods(): Map<string, MethodDefinition>;

Defined in: src/protocol.ts:168

Snapshot of the registered methods, keyed by method name. Returns a copy, so mutating it does not affect the protocol.

Map<string, MethodDefinition>


producer<S>(name, config): this;

Defined in: src/protocol.ts:91

Register a producer (server-streaming) method. The generic S is inferred from the init return type and threaded to produce.

Type Parameter
S
ParameterType
namestring
config{ defaults?: Record<string, any>; doc?: string; headerInit?: HeaderInit; headerSchema?: SchemaLike; init: ProducerInit<S>; onCancel?: OnCancelFn<S>; outputSchema: SchemaLike; params: SchemaLike; paramTypes?: Record<string, string>; produce: ProducerFn<S>; }
config.defaults?Record<string, any>
config.doc?string
config.headerInit?HeaderInit
config.headerSchema?SchemaLike
config.initProducerInit<S>
config.onCancel?OnCancelFn<S>
config.outputSchemaSchemaLike
config.paramsSchemaLike
config.paramTypes?Record<string, string>
config.produceProducerFn<S>

this


unary(name, config): this;

Defined in: src/protocol.ts:62

Register a unary (request-response) method.

ParameterTypeDescription
namestringMethod name exposed to clients
config{ defaults?: Record<string, any>; doc?: string; handler: UnaryHandler; params: SchemaLike; paramTypes?: Record<string, string>; result: SchemaLike; }-
config.defaults?Record<string, any>Optional default parameter values
config.doc?stringOptional documentation string
config.handlerUnaryHandlerAsync function receiving params and returning result values
config.paramsSchemaLikeParameter schema (SchemaLike)
config.paramTypes?Record<string, string>Optional parameter type hints (inferred from params if omitted)
config.resultSchemaLikeResult schema (SchemaLike)

this