Durable tasks
Start, observe, cancel, and reconnect to long-running SoulFire bot work.
Это руководство доступно только на английском.
A durable task runs on the SoulFire server. A detached task can continue after the SDK disconnects while its SoulFire server and bot remain available. Managed installation closes the local SoulFire server at scope exit. Scoped bot connection also stops bots started by that scope. Use an existing SoulFire server and a bot kept running when work must survive your application. Use a durable task for progress updates, cancellation, or shared bot control.
World tasks
Inventory tasks
Combat tasks
Survival tasks
Start a task and keep its handle
const task = yield* bot.tasks.autoEat(
["minecraft:bread"],
{ maximumMeals: 1 },
);
const result = yield* task.result();A task handle exposes its stable ID and latest snapshot. Use it to refresh, watch revisions, wait for completion, decode the typed result, or cancel the task.
Attach ownership to a stream
The run* methods (run_* in Python) start a task and stream every update.
By default they use the CANCEL_WITH_CALL disconnect policy: the task belongs to
your call and stops when you stop reading the stream.
yield* bot.tasks.runAutoRespawn({
maximumRespawns: 1,
}).pipe(Stream.runDrain);from effect_py import fn, sync
@fn("consume stream")
def consume(event):
yield from sync(lambda: print(event.task.status, event.task.progress))
yield from bot.tasks.run_auto_respawn(maximum_respawns=1).run_for_each(consume)Use a task handle from a normal start method, such as autoEat, when the work
must continue after your program exits.
Observe progress
const task = yield* bot.tasks.attackEntity(target);
yield* task.events().pipe(
Stream.runForEach((event) =>
Effect.logInfo(event.task?.progress?.message ?? "Working")
),
);Progress includes a message, current count, optional total, and optional fraction. Terminal snapshots include a typed result or structured failure.
Cancel explicitly
yield* task.cancel("Target changed");Cancellation is idempotent for a terminal task.
Choose conflict and reconnect policy
Tasks declare resources such as movement, rotation, hands, inventory, containers, chat, and automation. Independent work can run together. Conflicts can reject, queue, replace, or suspend lower-priority tasks.
Reconnect policy controls what happens when the Minecraft connection changes:
- Fail the task because connection-scoped references are no longer valid.
- Pause and resume after reconnect.
- Continue when the task can safely reacquire state.
Entity references carry a connection epoch because Minecraft network entity IDs can be reused after reconnect.
Reattach to a detached task
Store task.id after you start a task. A later SDK process can call
bot.tasks.get(taskId, resultSchema) in TypeScript or
bot.tasks.get(task_id, result_type) in Python, then resume watching its
revisions.
Use an idempotency key when retrying task creation after an uncertain network failure. SoulFire returns the existing task when the owner, bot, key, and input match.
Последнее обновление:
Полезна ли эта страница?
