@causalorlabs/niyati-core
v0.3.17
Published
JavaScript/WebAssembly SDK for Niyati, the hosted engine for reachability, fragility, and decision intelligence
Downloads
56
Maintainers
Readme
@causalorlabs/niyati-core
WebAssembly bindings for running Niyati in the browser or from a bundler-based web app.
Niyati is a hosted decision engine for answering:
- what futures are still reachable
- how quickly optionality is collapsing
- which constraints are driving collapse
- when a system is nearing a point of no return
Typical use cases:
- startup runway and survival planning
- game decision validation and scoring
- market elimination and scenario analysis
- strategy tooling where local UX needs to stay fast but cloud execution remains the source of truth
Install
Published package flow:
npm install @causalorlabs/niyati-coreLocal development flow:
npm install
cargo install wasm-pack
wasm-pack build --target bundler --out-dir pkgBuild
npm install
wasm-pack build --target bundler --out-dir pkgOutput artifacts in pkg/:
niyati_wasm_bg.wasmniyati_wasm.jsniyati_wasm.d.ts
Browser Usage
<script type="module">
import init, { NiyatiSession } from "./pkg/niyati_wasm.js";
await init();
const schema = JSON.stringify({
version: "1.0.0",
metadata: { name: "WASM Demo" },
time: { type: "discrete", horizon: 4 },
resources: {
money: { initial: 1000, min: 0, max: 10000 }
},
variables: {
x: { type: "float", initial: 0, min: 0, max: 10, discretization: 1 }
},
actions: [
{
name: "increment",
cost: { money: 10 },
effects: { x: { op: "add", value: 1 } },
preconditions: []
}
],
transitions: [],
constraints: [],
goal: {
type: "threshold",
conditions: [{ variable: "x", operator: "gte", value: 3 }]
}
});
const session = new NiyatiSession(
schema,
"your_api_key_here",
"https://api.causalorlabs.com"
);
const remoteResult = JSON.parse(await session.evaluate(null, "full"));
const localResult = JSON.parse(session.simulate_local(null));
</script>API Surface
new NiyatiSession(schemaJson, apiKey?, baseUrl?)await session.evaluate(budget?, capability?)(capability:fullorlite, defaultfull)session.simulate_local(budget?)await session.solve_reachability(payloadJson)await session.solve_fragility(payloadJson)await session.solve_trajectory(payloadJson)await session.solve_multiagent(payloadJson)await session.solve_competition(payloadJson)await session.solve_pareto(payloadJson)session.update_schema(schemaJson)await simulate(schemaJson, budget?, apiKey?, capability?)simulate_local(schemaJson, budget?)
Runtime Notes
- Remote calls include
X-Niyati-Versionmatching the live hosted API contract. POST /v1/simulatecan be used anonymously, but/v1/solve/*requires a valid API key.- Legacy class alias
CausalorSessionremains available during migration. - Browser requests use a
3.5sabort timeout. - Local execution is capped to
<= 5variables and horizon<= 12. - The production hosted API is expected at
https://api.causalorlabs.com.
