kestrel.markets
Version:
A typed, token-efficient language + runtime for agentic trading: agents author bounded plans, the runtime fires them at the tick. CLI + typed library + MCP server.
57 lines • 4.31 kB
TypeScript
/**
* # sdk/local — the LOCAL transport: the in-process djm.4 controller + djm.8 catalog + engine projection
*
* The HEAVY transport (kestrel-djm.5). `localTransport()` binds, IN-PROCESS: the djm.8 public Session
* catalog (catalog discovery + subject resolution), the engine parser (validation), the djm.4 incremental
* controller (the real Session progression — Bus → Blotter → graded bus), and a deterministic projection of
* the rich engine {@link EngineBlotter} into the djm.2 PROTOCOL {@link Blotter} + portable {@link GradeResult}
* this SDK returns. It NEVER forks Session progression — a {@link LocalSession} is a thin wrapper over the
* djm.4 {@link SessionController}; finalize projects, registers, and seals.
*
* ── DESIGN FORK LOGGED (hard rules forbid .beads writes) — the engine→protocol Blotter PROJECTION ──
* djm.2's {@link Blotter} is the GENERIC public view ("generic instruments only"); the engine Blotter is the
* rich internal record (per-order lifecycle, fill support, settle-mark provenance). The MINIMAL, HONEST,
* DETERMINISTIC projection this SDK adopts ({@link toProtocolBlotter}): carry the deterministic Session
* identity and the settlement (realized floor + asset + settle time, all fully determined by the graded
* bus), and leave the generic `orders`/`fills`/`positions` arrays EMPTY — the engine `OrderRecord` lacks a
* contract expiry and generic per-order ISO timestamps, and the protocol option {@link import("../protocol/index.ts").Instrument}
* REQUIRES an expiry, so fabricating one would violate the never-fabricate non-negotiable (AGENTS.md). The
* full per-order detail stays on the rich engine Blotter (the LOCAL path exposes it); the managed backend's
* own richer server-side projection is out of djm.5's scope. Both transports agree BY CONSTRUCTION: the HTTP
* transport replays this SAME projection's output (baked from a LOCAL run — see scripts/sdk/bake-catalog-records.ts).
*
* This is the DEFAULT, heaviest surface — it pulls the engine aggregate; a remote-only consumer imports
* `remote.ts` (light) instead (the djm.3 light/heavy seam, pinned by tests/package.boundary.test.ts).
*/
import type { Blotter as EngineBlotter } from "../blotter/index.ts";
export { toProtocolBlotter } from "../blotter/protocol-view.ts";
import { type GradeResult } from "../protocol/index.ts";
import type { SessionId } from "../protocol/session.ts";
import type { Transport } from "./types.ts";
/** A typed, fail-closed refusal from the LOCAL transport (agents match on `code`, not prose). Never a
* `RangeError` / silent load — an unknown subject/artifact is a stated, typed protocol refusal. */
export declare class SdkLocalError extends Error {
readonly name = "SdkLocalError";
readonly code: string;
constructor(code: string, message: string);
}
/** The conformance root of a run = the graded-bus sha256 (`SimRunId`), a pure function of the graded bus. */
export declare function conformanceRootOf(b: EngineBlotter): string;
/**
* Derive the portable {@link GradeResult} for a finalized run — the SAME OSS {@link grade} Judge an outsider
* runs, applied to the projected protocol Blotter (kestrel-h314 D4: `grade` REPLACES the old bespoke
* `gradeOf`). Both metric families come out of the certified evidence carried on the wire; grading one
* Blotter yields a GradeResult whose `subjectSessionId` is that session's id. Deterministic; both transports
* agree by construction.
*/
export declare function gradeOf(sessionId: SessionId, b: EngineBlotter): GradeResult;
/** The content-addressed artifact handles a finalized Session delivers: the graded-bus root + the Blotter
* artifact id (the Blotter's `sessionId` IS its artifact id). Deterministic; identical on both transports. */
export declare function artifactsOf(sessionId: SessionId, conformanceRoot: string): readonly string[];
/**
* Build the LOCAL transport — the in-process djm.4 controller + djm.8 catalog + engine projection. The
* caller wraps it with `createSdk(localTransport())`. It never gates (the free in-process path invents no
* 402); an unknown subject / artifact / operation is a typed {@link SdkLocalError} (fail-closed).
*/
export declare function localTransport(): Transport;
//# sourceMappingURL=local.d.ts.map