addAgent method
- required String handle,
- required String displayName,
- String billingMode = 'organization',
- String? credentialHolderId,
- String? reportedBillingMode,
- List<
String> ? billingModesSupported = const ['organization', 'personal'], - String adapterKind = 'hermes',
- String state = 'online',
- String keyType = 'api_key',
Adds an agent person (through addPerson, kind agent) and its FakeAgent with the
given configured and reported values, as if its first heartbeat had just arrived; returns
the FakeAgent.
credentialHolderId is stored as given, so a test can build a world that already breaks
I1 (10 5.4) and repair it through the API.
Implementation
FakeAgent addAgent({
required String handle,
required String displayName,
String billingMode = 'organization',
String? credentialHolderId,
String? reportedBillingMode,
List<String>? billingModesSupported = const ['organization', 'personal'],
String adapterKind = 'hermes',
String state = 'online',
String keyType = 'api_key',
}) {
final p = addPerson(
handle: handle,
displayName: displayName,
kind: 'agent',
);
final a = FakeAgent(
id: p.id,
billingMode: billingMode,
credentialHolderId: credentialHolderId,
reportedBillingMode: reportedBillingMode,
billingModesSupported: billingModesSupported == null
? null
: List.of(billingModesSupported),
adapterKind: adapterKind,
state: state,
keyType: keyType,
)..lastHeartbeatAt = stamp();
a.mismatchAtHeartbeat =
reportedBillingMode != null && reportedBillingMode != billingMode;
agents[a.id] = a;
return a;
}