lsh

SDK ยท preview

@logishell/sdk

A thin, typed fetch client for the LogiShell block registry and orchestrator HTTP APIs. No runtime dependencies beyond the block schema types.

Status. The package is not on npm yet. This page documents the API as it is in the repository today; the install line below starts working with the first public release.

Install

npm install @logishell/sdk

Create a client

import { createClient } from '@logishell/sdk';

const client = createClient({
  registryUrl: 'http://localhost:8080',
  orchestratorUrl: 'http://localhost:8081',
  token: process.env.LOGISHELL_TOKEN, // optional, sent as Bearer
});
OptionMeaning
registryUrlBase URL of the block registry service.
orchestratorUrlBase URL of the orchestrator service.
tokenOptional. Sent as Authorization: Bearer <token>.
fetchOptional. Your own fetch for tests, proxies or edge runtimes.

Registry

// blocks
const created = await client.blocks.create(def);
const one = await client.blocks.get(created.id);
const all = await client.blocks.list();
await client.blocks.update(created.id, def);
await client.blocks.remove(created.id);

// a block's graph and its cost
const graph = await client.graph.resolve(created.id);
const estimate = await client.cost.evaluate(graph);
console.log(estimate.total, estimate.currency);

Orchestrator

// tasks
const task = await client.tasks.enqueue({ blockId: created.id });
const next = await client.tasks.next();
await client.tasks.postResult(task.id, { ok: true });

// review gate
await client.review.approve(task.id, 'alice');
await client.review.reject(task.id, 'out of budget', 'bob');
const reviews = await client.review.list();

Errors

Any response outside 2xx throws an HttpError carrying status and the raw response body.

import { HttpError } from '@logishell/sdk';

try {
  await client.blocks.get('missing');
} catch (err) {
  if (err instanceof HttpError) console.error(err.status, err.body);
}

Back to lsh.dev