AutoplayLoop
in package
FinalYes
The autonomous LLM play loop: while `isAutoplayEnabled()`, every `$interval` seconds ask {@see AutoPlayer::step()} for the default agent's next move and queue it, posting the play-by-play ("thinking dialogue") to `$brainChannelId`.
Overlapping runs are skipped (an LLM reply is slower than the interval), a single bad turn never takes the loop down, and a persistent fault (brain host unreachable, API down) is logged once then at most once every 5 minutes.
Tags
Table of Contents
Properties
- $autoPlayer : AutoPlayer
- $brainChannelId : string|null
- $busy : bool
- $interval : float
- $lastWarn : array{msg: string, at: int}
- $nha : NHA
- $state : StateStore
Methods
- __construct() : mixed
- start() : void
- warn() : void
- Log a warning, de-duping an identical message to at most once per 5 minutes.
Properties
$autoPlayer read-only
private
AutoPlayer
$autoPlayer
$brainChannelId read-only
private
string|null
$brainChannelId
$busy
private
bool
$busy
= false
$interval read-only
private
float
$interval
$lastWarn
private
array{msg: string, at: int}
$lastWarn
= ['msg' => '', 'at' => 0]
$nha read-only
private
NHA
$nha
$state read-only
private
StateStore
$state
Methods
__construct()
public
__construct(NHA $nha, StateStore $state, AutoPlayer $autoPlayer, string|null $brainChannelId, float $interval) : mixed
Parameters
- $nha : NHA
- $state : StateStore
- $autoPlayer : AutoPlayer
- $brainChannelId : string|null
- $interval : float
start()
public
start() : void
warn()
Log a warning, de-duping an identical message to at most once per 5 minutes.
private
warn(string $msg) : void
Parameters
- $msg : string