aea.context.base
This module contains the agent context class.
AgentContext Objects
Provide read access to relevant objects of the agent for the skills.
__init__
| __init__(identity: Identity, connection_status: MultiplexerStatus, outbox: OutBox, decision_maker_message_queue: Queue, decision_maker_handler_context: SimpleNamespace, task_manager: TaskManager, default_ledger_id: str, currency_denominations: Dict[str, str], default_connection: Optional[PublicId], default_routing: Dict[PublicId, PublicId], search_service_address: Address, decision_maker_address: Address, data_dir: str, storage_callable: Callable[[], Optional[Storage]] = lambda: None, send_to_skill: Optional[Callable] = None, **kwargs: Any) -> None
Initialize an agent context.
Arguments:
identity: the identity objectconnection_status: the connection status of the multiplexeroutbox: the outboxdecision_maker_message_queue: the (in) queue of the decision makerdecision_maker_handler_context: the decision maker's name spacetask_manager: the task managerdefault_ledger_id: the default ledger idcurrency_denominations: mapping from ledger ids to currency denominationsdefault_connection: the default connectiondefault_routing: the default routingsearch_service_address: the address of the search servicedecision_maker_address: the address of the decision makerdata_dir: directory where to put local files.storage_callable: function that returns optional storage attached to agent.send_to_skill: callable for sending envelopes to skills.kwargs: keyword arguments to be attached in the agent context namespace.
send_to_skill
| send_to_skill(message_or_envelope: Union[Message, Envelope], context: Optional[EnvelopeContext] = None) -> None
Send message or envelope to another skill.
If message passed it will be wrapped into envelope with optional envelope context.
Arguments:
message_or_envelope: envelope to send to another skill.context: the optional envelope context
storage
Return storage instance if enabled in AEA.
data_dir
Return assets directory.
shared_state
Get the shared state dictionary.
The shared state is the only object which skills can use to exchange state directly. It is accessible (read and write) from all skills.
Returns:
dictionary of the shared state.
identity
Get the identity.
agent_name
Get agent name.
addresses
Get addresses.
public_keys
Get public keys.
address
Get the default address.
public_key
Get the default public key.
connection_status
Get connection status of the multiplexer.
outbox
Get outbox.
decision_maker_message_queue
Get decision maker queue.
decision_maker_handler_context
Get the decision maker handler context.
task_manager
Get the task manager.
search_service_address
Get the address of the search service.
decision_maker_address
Get the address of the decision maker.
default_ledger_id
Get the default ledger id.
currency_denominations
Get a dictionary mapping ledger ids to currency denominations.
default_connection
Get the default connection.
default_routing
Get the default routing.
namespace
Get the agent context namespace.