UNPKG

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.

35 lines (34 loc) 1.99 kB
/** * # sdk/facade — `createSdk(transport)`: the ONE typed client over a transport CHOICE (kestrel-djm.5) * * The transport-agnostic seam. `createSdk` wires a low-level {@link Transport} (LOCAL or HTTP) into the * {@link KestrelSdk} facade — the caller writes the flow ONCE and runs it either way. The facade is a thin, * protocol-uniform delegator: it forwards every verb to the transport verbatim (no re-encoding, no * face-local state) and adds ONLY the cross-cutting experimental-evidence fields (`transportKind` / * `version` / `transportVersion`, djm.5 AC5). Because it holds no logic of its own, LOCAL and HTTP are * behaviourally indistinguishable THROUGH the facade — exactly what the transport-parity test pins. * * LIGHT: the only value import is the zero-dependency protocol version constant, so this module (and any * remote-only consumer that imports it via `remote.ts`) carries no local runtime weight. */ import { PROTOCOL_VERSION } from "../protocol/index.js"; /** The SDK contract version — protocol-anchored so it moves in lockstep with the wire it speaks. */ export const SDK_VERSION = `kestrel.sdk/${PROTOCOL_VERSION}`; /** * Build the ONE typed client over a chosen {@link Transport}. Pass `localTransport()` (in-process djm.4 * controller) or `remoteTransport({ baseUrl, fetch })` (109 HTTP client); the returned {@link KestrelSdk} * is identical either way and returns the SAME djm.2 protocol objects. */ export function createSdk(transport) { return { transportKind: transport.kind, version: SDK_VERSION, transportVersion: transport.version, catalog: () => transport.catalog(), validate: (document) => transport.validate(document), openSession: (subject, document) => transport.openSession(subject, document), grade: (request) => transport.grade(request), artifact: (ref) => transport.artifact(ref), resumeOperation: (ref) => transport.resumeOperation(ref), }; }