ScriptedAgent class final
An agent of the world that answers mentions with the run of its script.
A message of a person that mentions agentId in a channel the agent sees gets
trigger_state received and a queued run in the same step; a message of the triggering
person in the thread of an active run is a follow-up (followups/<message id> with state
queued). Then the steps run one after another, each after AgentScript.pause. A run
that ends early (cancelRun) stops its script. Nothing is random.
Example:
final agent = ScriptedAgent(world, agentId: robin, script: AgentScript.followUpRun(
world.nextId(), world.stamp()));
agent.attach();
Constructors
- ScriptedAgent(FakeWorld world, {required String agentId, required AgentScript script, bool anchors = false})
-
Creates the agent; it acts after attach. With
anchorsevery run gets its live box anchor (kind = run, 09 5.4) right after it is queued, as the server writes it in the same transaction; tests of tickets before M4-21 run without.
Properties
- agentId → String
-
The agent principal.
final
- anchors → bool
-
Whether runs get their anchor message.
final
-
cards
→ Map<
String, List< String> > -
The cards this agent posted, by run ID (message IDs in order).
final
-
done
→ Future<
void> -
Completes when the script of the newest run ended.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
runIds
→ List<
String> -
The runs this agent started, by ID.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- script → AgentScript
-
What every run does.
final
- world → FakeWorld
-
The world.
final
Methods
-
attach(
) → void - Starts listening to created messages.
-
detach(
) → void - Stops listening.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerCommand(
String name, {String description = '', List< JsonMap> options = const [], bool control = false, FakeAutocomplete? suggest}) → String -
Registers the command
nameof this agent on the instance (09 10.2) with option suggestions fromsuggest(09 10.5); returns its ID. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited