OfflineContext: {
    [toStringTag]: string;
    ReadOnly: Readonly<{
        [context]: Function;
        [toStringTag]: string;
        activity: undefined | Activity;
        offline: true;
        trace?: Action;
        transaction: Transaction;
        agentFor<const T>(endpoint: Endpoint<T>): Instance<T>;
        authorizedFor(desiredAccessLevel: AccessLevel): desiredAccessLevel is View;
    }>;
    act<T>(purpose: string, activity: undefined | NodeActivity, actor: ((context: ActionContext) => MaybePromise<T>), options?: OfflineContext.Options): MaybePromise<T>;
} = ...

OfflineContext.act gives you access to the Agent API outside of user interaction.

You can also use OfflineContext.ReadOnly for read-only Agent access.

Type declaration

  • [toStringTag]: string
  • ReadOnly: Readonly<{
        [context]: Function;
        [toStringTag]: string;
        activity: undefined | Activity;
        offline: true;
        trace?: Action;
        transaction: Transaction;
        agentFor<const T>(endpoint: Endpoint<T>): Instance<T>;
        authorizedFor(desiredAccessLevel: AccessLevel): desiredAccessLevel is View;
    }>

    Normally you need to use OfflineContext.act to work with behaviors, and you can only interact with the behaviors in the actor function. This ActionContext allows you to create offline agents that remain functional for the lifespan of the node.

    Write operations will throw an error with this context.

  • act:function