soulfire.client.SoulFire¶
- class soulfire.client.SoulFire(base_url: str, *, token: soulfire._auth.TokenProvider | None = None, timeout_ms: int | None = None, interceptors: collections.abc.Iterable[ClientInterceptor] = (), required_capabilities: collections.abc.Iterable[str] = (), required_plugins: collections.abc.Iterable[soulfire.connection.RequiredPlugin] = ())[source]¶
A scoped client for a SoulFire server and its bot instances.
Use
connect()for an existing server,install()for a managed local server, orcreate_bot()for a ready bot in one operation. Direct construction creates RPC clients without a handshake or scope cleanup.SDK operations return lazy
Effectvalues. Compose them withyield frominside an Effect workflow, then run the workflow withrun_async. Keep all client and bot work insidescoped. The scope closes transports and any local server that this client manages.See also
- bot_service¶
- bot_live¶
- bot_tasks¶
- pathfinder_service¶
- chat_service¶
- inventory_service¶
- recipe_service¶
- registry_service¶
- world_service¶
- protocol_service¶
- client_service¶
- command_service¶
- download_service¶
- logs_service¶
- metrics_service¶
- plugin_stats_service¶
- script_service¶
- server_service¶
- user_service¶
- instance_service¶
- instance_live¶
- login_service¶
- mc_auth_service¶
- classmethod connect(base_url: str, *, token: soulfire._auth.TokenProvider | None = None, timeout_ms: int | None = None, interceptors: collections.abc.Iterable[ClientInterceptor] = (), required_capabilities: collections.abc.Iterable[str] = (), required_plugins: collections.abc.Iterable[soulfire.connection.RequiredPlugin] = ()) effect_py.Effect[SoulFire, soulfire.errors.SoulFireOperationError, effect_py.Scope][source]¶
Connect to an existing server and check SDK compatibility.
The handshake checks the API version, required capabilities, and required plugin versions. The scope closes the client’s transports on exit. It does not stop the remote SoulFire server.
- Parameters:
base_url – SoulFire gRPC-Web URL, including
http://orhttps://. This is separate from the Minecraft server address.token – Bearer token or token provider. Omit it for a public server.
timeout_ms – Default RPC timeout in milliseconds.
Noneuses the transport default. This is separate from bot readiness timeouts.interceptors – Additional ConnectRPC interceptors.
required_capabilities – Capability identifiers the server must support.
required_plugins – Plugin identifiers and version constraints to check.
- Returns:
An Effect that produces a client after the handshake. Requires
Scope.
Notes
Transport, authentication, and compatibility errors use the Effect error channel. Use
unauthenticated()when login must precede the handshake.
- classmethod unauthenticated(base_url: str, *, token: soulfire._auth.TokenProvider | None = None, timeout_ms: int | None = None, interceptors: collections.abc.Iterable[ClientInterceptor] = (), required_capabilities: collections.abc.Iterable[str] = (), required_plugins: collections.abc.Iterable[soulfire.connection.RequiredPlugin] = ()) effect_py.Effect[SoulFire, soulfire.errors.SoulFireOperationError, effect_py.Scope][source]¶
Create a scoped client without an SDK handshake.
Use this client for the login flow on a server that requires authentication. After login, negotiate compatibility before reading server metadata. The scope closes all transports. This method accepts the same connection options as
connect().- Returns:
An Effect that produces a client. Requires
Scope.
- classmethod install(*, directory: str | os.PathLike[str] | None = None, version: str | None = None, java_args: collections.abc.Iterable[str] = (), port: int | None = None, startup_timeout: float = 120.0, on_log: collections.abc.Callable[[str], None] | None = None, timeout_ms: int | None = None, interceptors: collections.abc.Iterable[ClientInterceptor] = ()) effect_py.Effect[SoulFire, soulfire.errors.SoulFireOperationError, effect_py.Scope][source]¶
Download and start a local SoulFire server owned by the scope.
The installer downloads Java and SoulFire when needed, starts the process, then connects with its local token and completes the SDK handshake. The scope closes the client and stops the managed process on exit. Downloaded files and server data remain available for later runs.
- Parameters:
directory – Installation and data directory. Defaults to
.soulfirein the current working directory.version – Release tag to install.
Noneselects the latest release.java_args – Extra JVM arguments before the SoulFire JAR.
port – Local gRPC-Web port.
Noneselects an available port.startup_timeout – Maximum startup wait in seconds. Defaults to 120.
on_log – Callback for server log lines.
timeout_ms – Default RPC timeout in milliseconds after startup.
interceptors – Additional ConnectRPC interceptors.
- Returns:
An Effect that produces a connected client. Requires
Scope.
Notes
Installation failures use
SoulFireInstallErrorin the Effect error channel. Startup timeout and RPC timeout control different stages.
- set_token(token: soulfire._auth.TokenProvider | None) None[source]¶
Replace the bearer token or token provider for subsequent RPC calls.
This synchronous change does not perform a handshake or restart open streams.
- classmethod create_bot(*, server: str, username: str, auth: Literal['offline', 'microsoft'] = 'offline', instance_name: str | None = None, name: str | None = None, ready_timeout: float = 30.0, on_device_code: collections.abc.Callable[[soulfire.mc_auth_pb2.DeviceCode], effect_py.Effect[None, soulfire.errors.SoulFireOperationError]] | None = None, installation: ManagedInstallOptions | None = None) effect_py.Effect[soulfire.bot.SoulFireBot, soulfire.errors.SoulFireOperationError, effect_py.Scope][source]¶
Install SoulFire and create or reuse a ready bot by name.
The instance name defaults to the Minecraft server address. The bot name and offline username default to
username. Repeated calls reuse named resources. Conflicting account or server configuration fails explicitly. The scope owns the managed process, observation, and bot startup.- Parameters:
server – Minecraft address, such as
localhost:25565.username – Minecraft username for a new offline account.
auth –
"offline"by default."microsoft"enables device-code login when no matching account exists.instance_name – Stable instance name. Defaults to the trimmed address.
name – Stable bot name within the instance. Defaults to
username.ready_timeout – Positive, finite readiness deadline in seconds. Defaults to 30. The bot must receive an initial player snapshot.
on_device_code – Effect callback for the first Microsoft login code. Without a callback, the SDK prints the sign-in URL and code.
installation – Local server options accepted by
install().
- Returns:
An Effect that produces a ready, observed bot. Requires
Scope.
See also
SoulFireInstance.get_or_create_bot()for several bots on one client.
- property server: soulfire.connection.ServerMetadata¶
- property identity: soulfire.sdk_pb2.SdkIdentity¶
- property capabilities: soulfire.connection.CapabilitySet¶
- property limits: types.MappingProxyType[str, int]¶
- property plugins: soulfire.plugins.PluginCatalog¶
- property admin: soulfire.admin.SoulFireAdmin¶
- property local_server_logs: tuple[str, ...]¶
- property is_local_server_running: bool¶
- restart_local_server() effect_py.Effect[None, soulfire.errors.SoulFireOperationError][source]¶
- stop_local_server() effect_py.Effect[None, soulfire.errors.SoulFireOperationError][source]¶
- service[ClientT](client_type: collections.abc.Callable[..., ClientT]) ClientT[source]¶
- instance(instance_id: str) SoulFireInstance[source]¶
Create an instance handle without a network request.
- Parameters:
instance_id – Existing instance UUID, not its friendly name.
- Returns:
A handle whose operations use this client’s transports. Creating the handle does not check that the instance exists or that access is allowed.
See also
get_or_create_instance()to provision an instance by name.
- instances(*, headers: dict[str, str] | None = None, timeout_ms: int | None = None) effect_py.Effect[list[soulfire.instance_pb2.InstanceListResponse.Instance], soulfire.errors.SoulFireOperationError][source]¶
- create_instance(friendly_name: str, *, headers: dict[str, str] | None = None, timeout_ms: int | None = None) effect_py.Effect[SoulFireInstance, soulfire.errors.SoulFireOperationError][source]¶
- get_or_create_instance(name: str, *, server: str | None = None, timeout_ms: int | None = None) effect_py.Effect[SoulFireInstance, soulfire.errors.SoulFireOperationError][source]¶
Find or create an instance by name for the authenticated user.
- Parameters:
name – Stable instance name used for provisioning.
server – Minecraft address to configure. A conflicting address fails.
timeout_ms – RPC timeout in milliseconds.
- Returns:
An Effect that produces an instance handle. Requires the negotiated
instance.provisioning.v1capability.
Notes
Reuse the returned instance to provision several bots. This operation does not start bots or delete the instance when a scope closes.
- begin_login(email: str, *, headers: dict[str, str] | None = None, timeout_ms: int | None = None) effect_py.Effect[soulfire.login_pb2.NextAuthFlowResponse, soulfire.errors.SoulFireOperationError][source]¶
- complete_login(auth_flow_token: str, code: str, *, headers: dict[str, str] | None = None, timeout_ms: int | None = None) effect_py.Effect[soulfire.login_pb2.NextAuthFlowResponse, soulfire.errors.SoulFireOperationError][source]¶
- close() effect_py.Effect[None][source]¶
Close client transports and stop its managed local server, if any.
The connection scope calls this operation automatically. Prefer scope cleanup so active workflows finish before their transports close. This operation leaves downloaded files and persistent server data in place.
- negotiate() effect_py.Effect[None, soulfire.errors.SoulFireOperationError][source]¶