@causalorlabs/niyati-core
v0.3.3
Published
JavaScript/WebAssembly SDK for Niyati, the hosted engine for reachability, fragility, and decision intelligence
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/:
causalor_wasm_bg.wasmcausalor_wasm.jscausalor_wasm.d.ts
Browser Usage
<script type="module">
import init, { CausalorSession } from "./pkg/causalor_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 CausalorSession(
schema,
"your_api_key_here",
"https://api.causalorlabs.com"
);
const remoteResult = JSON.parse(await session.evaluate(null));
const localResult = JSON.parse(session.simulate_local(null));
</script>API Surface
new CausalorSession(schemaJson, apiKey?, baseUrl?)await session.evaluate(budget?)session.simulate_local(budget?)session.update_schema(schemaJson)await simulate(schemaJson, budget?, apiKey?)simulate_local(schemaJson, budget?)
Runtime Notes
- Remote calls include
X-Causalor-Versionmatching the crate version. - 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.
