SDK / DEVELOPER_REFERENCE

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.

SDK / INSTALLInstallation
bash
npm install @meshinfer/sdk
SDK / QUICKSTARTCore API Examples
js
import { 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 pool
APP_MODEL / WORKFLOWMesh-Native App Model

Build 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.

01

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.

js
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" },
  ],
});
02

Declare State & Routing

Specify which state your app reads and writes, and apply routing constraints. DOSFI handles replication, consistency, and tier enforcement automatically.

js
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
});
03

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.

js
app.ui({
  input:  { type: "image-upload", label: "Upload image" },
  output: { type: "label-list",   label: "Classification results" },
  status: { type: "task-progress", steps: ["preprocess","classify","postprocess"] },
});
04

Deploy

Deploy your app definition to the mesh. DOSFI registers the workflow, allocates routing capacity, and returns a public endpoint and event stream URL.

js
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-classifier
API / REST_REFERENCEREST API Reference

Direct 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.

POST/v1/tasksSubmit a workload to the mesh. Returns a task ID and initial status.
GET/v1/tasks/:idGet the current status, shard progress, and metadata for a task.
GET/v1/tasks/:id/streamOpen a server-sent event stream to receive shard results in real time.
DELETE/v1/tasks/:idCancel an in-progress task. In-flight shards are drained gracefully.
GET/v1/nodesList nodes in the routing pool with readiness scores and tier eligibility.
GET/v1/nodes/:idGet detailed readiness, thermals, and trust data for a specific node.
POST/v1/nodes/:id/revokeRevoke a node's identity and remove it from the routing pool.
POST/v1/routesEvaluate a routing policy against the current mesh topology (dry-run).
GET/v1/state/:keyRead a distributed state value. Respects privacy tier and consistency level.
PUT/v1/state/:keyWrite a distributed state value with tier and consistency options.
SDK / BEST_PRACTICESError Handling & Best Practices