@rpc() are
callable by connected clients, and rpcSurface() reports what a class
exposes. Both are standalone functions imported from @telnyx/edge-runtime,
not Agent members.
These functions are the server half of the remote-call story. @rpc() marks what may
be called; AgentSocketServer
enforces the opt-in on the wire (an undecorated method answers method_private); and
on the far end, AgentClient’s stub is
how callers reach what you exposed — agent.stub.humanReply("…") dispatches to the
@rpc()-decorated humanReply on your class.
rpc()
rpc(Mark a method (or a function-valued class field) as remote-callable. Only decorated members dispatch over the agent socket; reserved lifecycle hooks (options?): {(value,context):void; <V>(value,context): (initial) =>V; }
constructor/alarm/fetch/webSocket) and _-prefixed names
remain non-dispatchable even if decorated, and an undecorated override of a
decorated base method is not dispatchable.
The optional metadata is introspectable via rpcSurface, so a caller
can discover what an agent exposes remotely.
Parameters
Returns
{(
value, context): void; <V>(value, context): (initial) => V; }
Example
rpcSurface()
rpcSurface(The effective remote surface of a constructed agent instance: method name → theinstance):ReadonlyMap<string,RpcOptions>
RpcOptions it was decorated with, for exactly the names a remote
call frame could dispatch. Names the dispatcher would reject are excluded
even if decorated: reserved hooks, _-prefixed names, and names whose
resolved callable is not the decorated function (e.g. an undecorated
subclass override).
Returns a fresh snapshot on every call — mutating it has no effect on
dispatch.
Parameters
Returns
ReadonlyMap<string, RpcOptions>
RpcOptions
Metadata attached to a remote-callable method via@rpc().
Properties
description?
Human-readable summary of what the method does.readonlyoptionaldescription?:string