AgentContext
in package
FinalYes
Identifies which agent a command runs as, and with which NHA action token.
A null $token means "use whatever token is configured on the
NHA client" — i.e. the bot's own default agent. A non-null token is
an explicit per-Discord-user credential and is sent verbatim on
POST /intent, so the same handler can act as the bot or as the caller
without any other code path changing.
Build one through ActorTrait::actor() rather than by hand.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- bot() : self
- Context for the bot's own default agent (its ambient token is used).
- user() : self
- Context for a Discord user's linked agent, carrying that user's token.
Properties
$agentId read-only
public
int
$agentId
$label read-only
public
string
$label
= 'the agent'
$token read-only
public
string|null
$token
= null
Methods
__construct()
public
__construct(int $agentId[, string|null $token = null ][, string $label = 'the agent' ]) : mixed
Parameters
- $agentId : int
-
The acting agent's id.
- $token : string|null = null
-
The agent's NHA token, or null to use the bot's ambient token.
- $label : string = 'the agent'
-
Short human label ("you", "the bot", "agent #12") for confirmations.
bot()
Context for the bot's own default agent (its ambient token is used).
public
static bot(int $agentId) : self
Parameters
- $agentId : int
Return values
selfuser()
Context for a Discord user's linked agent, carrying that user's token.
public
static user(int $agentId, string $token) : self
Parameters
- $agentId : int
- $token : string