@jsm-mit/rabbit-standalone-package
v0.1.1
Published
Wrapper TypeScript package for rabbit-rust: a queue of tasks in channels.
Readme
@jsm-mit/rabbit-standalone-package
The TypeScript wrapper of rabbit (../core in rabbit-standalone) — a
queue of tasks in channels. The only sanctioned way for a service or a front to talk to
rabbit. Successor of @jsm-mit/rabbit-motoko-package.
import { TasksActor, RabbitTaskWorker } from "@jsm-mit/rabbit-standalone-package";
const tasks = new TasksActor(RABBIT_ID, identity);
const id = await tasks.addTaskAsyncUnsafe({ channel: "video", commonId: "job-1", payload: "…" });
// A worker: every call on a task names its channel.
const worker = new RabbitTaskWorker("video", 5000, new TasksActor(RABBIT_ID, workerIdentity));
worker.tasks$.subscribe(async (task) => {
await tasks.completeTaskAsyncUnsafe({ channel: task.channel, id: task.id, message: "done" });
});
worker.run();Web fronts import from @jsm-mit/rabbit-standalone-package/browser (no RabbitTaskWorker, no
pigeon).
Works with @icp-sdk/core 5.2+ and 6 (peer ^5.2.0 || ^6.0.0): the suite passed on both
(2026-10-09) — the octopus services are still on 5.2. RabbitTaskWorker takes
@jsm-mit/pigeon-package 0.11 or 0.12 (same two report methods).
Errors
Every …AsyncUnsafe method resolves with the value or throws one of three:
CanisterError— rabbit refused;cause.errorKeyisNotAuthorized,NotFound,AlreadyExists,InvalidDataorExpired(a claim of an overdue task: the task is now marked expired),cause.errorMessagethe text.CallRefusedAtInspectionStage— refused before it ran (anonymous caller, a role's method called without the role, a too big argument).CriticalCanisterError— no connection, or a trap;cause.rawError.
A call refused because rabbit is being upgraded (IC0508/IC0509) is repeated for about a minute first.
Changes from rabbit-motoko-package
claimTask,completeTaskandgetTasktake the channel (ready for sharding).- Admin lists:
findTasksAsyncUnsafe(filters, newest first, pages bynextBeforeId, texts cut to 200 characters) replacesgetTasks,getTasksLast24h,getTasksByCommonId. ForcedUpdateis nowExpired; nologsin errors;getLogs,clearLogs,setLoggingEnabledare gone —getStatusAsyncUnsafehas events, cycles and memory.- New:
getRoleAsyncUnsafe,closeChannelForSignupAsyncUnsafe,setRetentionDaysAsyncUnsafe; channels carry member and task counts. ActorOptions.hostfor a local replica.
Scripts
| Script | What |
|---|---|
| npm run typecheck | the package and its tests |
| npm run test-suite-local, test-smoke-local | against a fresh rabbit on the local replica (no cycles) — the only tests; rabbit is never tested on short-living |
| npm run sync-declarations | after a change of ../core/rabbit-rust.did |
| npm run publish-public | smoke + candid check on the local replica, stamp, publish (human-run) |
