blazen-wasm-sdk
v0.1.111
Published
Blazen SDK for TypeScript/JavaScript via WebAssembly
Downloads
562
Readme
@blazen/sdk
TypeScript/JavaScript SDK for Blazen via WebAssembly. Run the full Blazen workflow engine, LLM completion, agent loop, and pipeline directly in the browser, Node.js, Deno, or Cloudflare Workers -- no native dependencies required.
Installation
npm install @blazen/sdkQuick start
import init, { CompletionModel, ChatMessage } from "@blazen/sdk";
await init(); // load the WASM module
const model = CompletionModel.openrouter("or-key");
const response = await model.complete([ChatMessage.user("Hello!")]);
console.log(response.content);Workflows
import init, { Workflow } from "@blazen/sdk";
await init();
const workflow = new Workflow("greeter");
workflow.addStep("parse", ["StartEvent"], async (event) => {
return { type: "GreetEvent", name: event.name ?? "World" };
});
workflow.addStep("greet", ["GreetEvent"], async (event) => {
return {
type: "StopEvent",
result: { greeting: `Hello, ${event.name}!` },
};
});
const result = await workflow.run({ name: "Zach" });
console.log(result.data);Supported platforms
- Browsers (Chrome, Firefox, Safari, Edge)
- Node.js (v16+)
- Deno
- Cloudflare Workers / edge runtimes
- Any environment with WebAssembly support
Build from source
Requires wasm-pack:
# Bundler target (default -- works with Vite, webpack, etc.)
wasm-pack build --target bundler --release
# Web target (standalone ES module)
wasm-pack build --target web --release
# Node.js target (CommonJS)
wasm-pack build --target nodejs --releaseOutput is written to the pkg/ directory.
Docs
Full documentation at blazen.dev/docs/getting-started/introduction.
License
AGPL-3.0-or-later
