constructor
new Agent<Called by the runtime on every activation — never construct an agent yourself. Re-arms the task scheduler to the earliest pending task (insideE,State>(ctx,env):Agent<E,State>
ctx.blockConcurrencyWhile), so persistent timers resume after a crash or
restart. A subclass constructor must call super(ctx, env) first.
Parameters
Returns
Agent<E, State>
Overrides
StatefulActor<E>.constructor
ctx
The actor’s identity + storage + concurrency primitives. Inherited fromprotectedreadonlyctx:ActorContext
StatefulActor.ctx
env
The bindings environment for this actor’s worker scope. Inherited fromprotectedreadonlyenv:E
StatefulActor.env
fetch()
fetch(Optional HTTP-style entry._req):Promise<Response>
stub.fetch(req) from a caller routes here.
Subclasses override; the base default returns 404.
Request and Response are the standard Fetch API globals (Node 18+
exposes both natively).
Parameters
Returns
Promise<Response>
Inherited from
StatefulActor.fetch
webSocket()
Take ownership of an accepted WebSocket connection.optionalwebSocket(ws,req):void|Promise<void>
ws is the live socket; req is the handshake request, whose headers
carry whatever the front door attached (auth, identity). Declaring this
method is what opts the actor into holding sockets; ctx.broadcast /
ctx.count / ctx.sockets then operate on the sockets it holds.
Parameters
Returns
void | Promise<void>
Inherited from
StatefulActor.webSocket
onConnect()
Hook: a client connection is established. Override to authorize, seed, or close the connection. The default implementation does nothing. ParametersprotectedonConnect(_conn):Promise<void>
Returns
Promise<void>
alarm()
alarm(Reserved: the SDK claims the actor’s alarm slot to drive the task scheduler. When the alarm fires, this drains every due task, dispatches each to the method it names (or `onTask`), and re-arms the alarm to the next deadline. Do not override_info):Promise<void>
alarm() in an Agent
subclass — doing so breaks queue / schedule / every. If you need
timed work, schedule a task instead.
Parameters
Returns
Promise<void>
Overrides
StatefulActor.alarm