The DOSFI SDK. Everything you need.
A unified SDK for JavaScript, Python, and Rust — covering task submission, distributed state, node management, and the full mesh-native app lifecycle against the published DOSFI ABI.
npm install @meshinfer/sdkimport { DOSFI } from "@meshinfer/sdk";
const mesh = await DOSFI.connect({
token: process.env.DOSFI_TOKEN,
region: "us-east", // optional — defaults to nearest
privacyTier: "tier-2", // default tier for all tasks
});
console.log(mesh.nodeCount); // active nodes in routing poolBuild apps, not just tasks.
The DOSFI app model lets you compose multi-step workflows, declare state and routing constraints, describe a UI, and deploy as a fully managed mesh-native application — without managing infrastructure.
Define Your Workflow
A mesh-native app is modeled as a directed acyclic graph (DAG) of tasks. Each node in the DAG maps to a DOSFI task. You declare dependencies; the scheduler resolves execution order.
const app = mesh.workflow({
name: "image-classifier",
steps: [
{ id: "preprocess", task: "transform", input: "raw_image" },
{ id: "classify", task: "inference", input: "preprocess.output",
model: "meshinfer/resnet-50", tier: "tier-2" },
{ id: "postprocess",task: "transform", input: "classify.output" },
],
});Declare State & Routing
Specify which state your app reads and writes, and apply routing constraints. DOSFI handles replication, consistency, and tier enforcement automatically.
app.state({
config: { key: "classifier/config", tier: "tier-1", consistency: "strong" },
results: { key: "classifier/results", tier: "tier-0", consistency: "eventual" },
});
app.routing({
geoRestrict: ["US", "EU"], // only route to nodes in these regions
minTrustScore: 85, // only high-trust nodes
});Build Your UI Schema
Optionally describe a UI schema. DOSFI Studio renders it as a visual interface, and the mesh-native runtime hosts it against the app's live task graph.
app.ui({
input: { type: "image-upload", label: "Upload image" },
output: { type: "label-list", label: "Classification results" },
status: { type: "task-progress", steps: ["preprocess","classify","postprocess"] },
});Deploy
Deploy your app definition to the mesh. DOSFI registers the workflow, allocates routing capacity, and returns a public endpoint and event stream URL.
const deployment = await app.deploy({ env: "production" });
console.log(deployment.endpoint); // https://mesh.dosfi.ai/apps/image-classifier
console.log(deployment.streamUrl); // wss://events.dosfi.ai/apps/image-classifierDirect REST access to every surface.
All SDK methods map to documented REST endpoints. Base URL: https://api.dosfi.ai. Authenticate via Bearer token in the Authorization header.
/v1/tasksSubmit a workload to the mesh. Returns a task ID and initial status./v1/tasks/:idGet the current status, shard progress, and metadata for a task./v1/tasks/:id/streamOpen a server-sent event stream to receive shard results in real time./v1/tasks/:idCancel an in-progress task. In-flight shards are drained gracefully./v1/nodesList nodes in the routing pool with readiness scores and tier eligibility./v1/nodes/:idGet detailed readiness, thermals, and trust data for a specific node./v1/nodes/:id/revokeRevoke a node's identity and remove it from the routing pool./v1/routesEvaluate a routing policy against the current mesh topology (dry-run)./v1/state/:keyRead a distributed state value. Respects privacy tier and consistency level./v1/state/:keyWrite a distributed state value with tier and consistency options.