Skip to content

EntityHandle

Handle returned by ctx.spawn() and ctx.observe(). Provides access to a child or observed entity's stream and status.

Source: @durable-streams/darix-runtime

ts
interface EntityHandle {
  entityUrl: string
  type?: string
  db: EntityStreamDB
  events: ChangeEvent[]
  run: Promise<void>
  text(): Promise<string[]>
  send(msg: unknown): void
  status(): ChildStatus | undefined
}

Members

MemberTypeDescription
entityUrlstringURL path of the entity (e.g. "/chat/my-child").
typestring | undefinedEntity type name, if known.
dbEntityStreamDBThe entity's TanStack DB instance for querying its collections.
eventsChangeEvent[]All change events received from this entity's stream.
runPromise<void>Promise that resolves when the entity's current run completes. Useful with await.
text()Promise<string[]>Returns all text outputs from the entity's stream.
send(msg)voidSend a message to this entity.
status()ChildStatus | undefinedCurrent status of the entity, or undefined if unknown.

ChildStatus

ts
type ChildStatus = ChildStatusEntry
ts
interface ChildStatusEntry {
  key: string
  entity_url: string
  entity_type: string
  status: "spawning" | "running" | "idle" | "stopped"
}

Status values:

StatusDescription
spawningEntity creation is in progress.
runningHandler is currently executing.
idleHandler has completed; entity is waiting for the next wake.
stoppedEntity has been stopped or deleted.