跳至主要内容

JavaScript SDK — zeq

A zero-dependency vanilla-JS client. Drops into any browser or Node ≥ 18 runtime. Same wire format as the TypeScript, Python, Rust, Go, and HTTP SDKs — every receipt round-trips identically across them all.

Install

npm install zeq
# or
pnpm add zeq
# or
yarn add zeq

First call — public, no key

import { pulse } from "zeq";

const p = await pulse();
console.log(`Zeqond ${p.zeqond} · phase ${p.phase.toFixed(3)} · R(t) ${p.R_t}`);

pulse() hits GET /api/zeq/pulse — no authentication, no rate limit beyond the public quota. Use it for live cadence on dashboards, status pages, or as the first heartbeat in an observer agent.

Authed call — zeq.compute()

import { ZeqClient } from "zeq";

const zeq = new ZeqClient({ apiKey: process.env.ZEQ_KEY });

const r = await zeq.compute({
operators: ["KO42", "QM5", "GR40"],
domain: "cross",
inputs: { t: 0 },
});

console.log(r.value, r.unit, "± " + r.uncertainty);
console.log(r.zeqProof); // tamper-evident proof
console.log(r.compliance.standards_aligned); // 13-standard envelope

Every compute() returns a ZeqState (the math), a ZeqProof (the tamper-evident receipt), and a ZeqCompliance v1 envelope. The same call from Python, Rust, Go, or curl produces a byte-identical proof.

What you get back

FieldShapeUse
value / unit / uncertaintynumericthe closed-form answer
zeqProofsha256feed to /api/zeq/prove/verify to re-prove
zeqStateobjectdomain, masterEquation, operator sequence
compliancezeq.compliance.v1per-call regulatory envelope
meta.zeqondbigintthe canonical Zeqond the row landed at

Master-equation solve + register dump — zeq.solve() / zeq.multibody()

zeq.compute() runs the textbook-dispatch path. For the master-equation runtime (full trajectory + register dump + functional energy E = P_φ · Z), use the dedicated client methods.

import { ZeqClient } from "zeq";

const zeq = new ZeqClient({ apiKey: process.env.ZEQ_KEY });

// Single-body
const r = await zeq.solve({
prompt: "feather drop",
mass: 1e-4,
location: "earth",
medium: "air",
koSettings: { KO42: 1.0 },
});
console.log("registerDump: ", r.registerDump);
console.log("functionalEnergy:", r.functionalEnergy, "= P_φ·Z");

// Strict autotune
const tuned = await zeq.solveStrict({
prompt: "free-fall calibration",
mass: 1.0,
koSettings: { NM19: 1.0, NM24: 0.3 },
tMax: 0.4, dt: 0.001,
maxIterations: 40,
referenceMode: "free-fall",
});
console.log(tuned.tuneStatus, tuned.tuneIterations);

// Multi-body
const mb = await zeq.multibody({
prompt: "sun-earth-moon",
bodies: [
{ mass: 1.989e30, location: "sun", object: "sun" },
{ mass: 5.972e24, location: "earth", object: "earth" },
{ mass: 7.342e22, location: "moon", object: "moon" },
],
koSettings: { KO42: 1.0, NM21: 0.5, GR35: 0.3 },
});
for (const body of mb.bodies)
console.log(body.object, body.registerDump);
for (const pair of mb.interactions)
console.log(`(${pair.bodyA},${pair.bodyB})`, "F_avg =", pair.F_avg);

All three methods are server-only — they require an API key. See /api/framework/ for the full request/response schema and every optional field (useOperatorModules, coreOnly, referenceMode, pairwiseCoupling, …).

Compose with

Source