An Agent offers interaction with a single endpoint. This is the operational interface to endpoints. It is separate from the Endpoint because the agent is context-aware and may be bound to a specific fabric.

An endpoint agent manages one or more Behavior instances that implement a discrete subset of the agent's functionality.

Each endpoint agent has an associated Agent.Type that defines each Behavior.Type the endpoint supports.

Agent.Type is a permanent feature of an endpoint but agent instances themselves are transitory and there is no guarantee they will exist beyond the lifecycle of a single transaction.

Constructors

Accessors

  • get owner(): undefined | Agent
  • Access an Agent for this agent's owner.

    Returns undefined | Agent

Methods

  • Parameters

    Returns void

  • Trigger initialization of a supported Behavior.Type.

    Functionally identical to load but has no return value and errors are logged rathjer than thrown.

    Parameters

    Returns void

  • Obtain a Behavior supported by this agent. Throws an error if the Behavior.Type isn't supported or is still initializing.

    You may also access behaviors using normal property access, e.g. agent.descriptor is the same as agent.get(DescriptorBehavior).

    Property access is available in TypeScript when the set of behaviors is defined statically.

    Type Parameters

    Parameters

    • type: T

    Returns InstanceType<T>

  • Test to see if a Behavior.Type is supported by this agent.

    Type Parameters

    • BehaviorT extends Type

    Parameters

    Returns this is InstanceType<BehaviorT>

  • Determine whether a behavior is loaded (does not validate class, only by ID).

    Parameters

    Returns boolean

  • Obtain a behavior supported by this agent. Throws an error if the Behavior.Type isn't supported. Waits if the behavior is not yet initialized.

    Type Parameters

    Parameters

    • type: T

    Returns MaybePromise<InstanceType<T>>

  • Add support for a Behavior.Type.

    Type Parameters

    Parameters

    Returns void

  • Returns string