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.

48 lines 3.71 kB
/** * # sdk/remote — the HTTP transport: the 109 client over the 5rb wire (kestrel-djm.5) * * The LIGHT transport. `remoteTransport({ baseUrl, fetch })` binds the kestrel-109 {@link KestrelClient} * (mint / validate / sim / grade over the 5rb wire dialect) and re-exposes it under the ONE typed SDK * contract. Catalog discovery / validation / grade delegate to the client verbatim; an incremental Session * is a CLIENT-SIDE REPLAY of the server-computed, catalog-pinned transcript the `POST /sim` stream carries * (the wire deliberately omits an `advance` — a face is a pure encoder over the controller, never a forked * progression). Because the server ran the SAME engine the LOCAL transport runs, the replayed pentad chain / * Blotter / grade / root are BYTE-IDENTICAL to the LOCAL run (the djm.5 headline). * * FAIL-CLOSED, PROTOCOL-UNIFORM: a 402/Offer is DATA on {@link Gated} (surfaced, never thrown / redirected); * an unknown subject is a typed {@link KestrelClientError} (the 109 client's non-2xx throw); an off-contract * SSE event is the 109 client's `SSE_PROTOCOL_VIOLATION` (fail-closed, never laundered into a face state); * a replay turn that diverges from the recorded script is a typed djm.4 {@link SessionResponse} refusal. * * DEPENDENCY BOUNDARY (djm.3 / djm.5): the ONLY value import is the 109 client (+ its re-exported wire * types) and this SDK's light core (`facade.ts` / `types.ts`). Every djm.2/djm.4 shape is a TYPE-ONLY import * (erased). NO local runtime — no djm.4 controller, no simulate/sim driver, no engine tree, no djm.8 loader * — reaches this graph. Pinned by tests/package.boundary.test.ts. * * ── DESIGN FORK LOGGED (hard rules forbid .beads writes) — the HTTP Session is a server-run REPLAY ── * A catalog Session's SUBJECT is a FIXED, server-pinned script (arm-once/pass-forever). The HTTP transport * runs it server-side ONCE at `openSession` (`POST /sim` resolves the catalog dataset to its pre-computed * record) and REPLAYS the record verb-by-verb: `start`/`advance` deliver the recorded Frames and return the * recorded pentad-chained {@link import("../protocol/session.ts").TurnEntry}s verbatim (never re-sealed — the * server's entries ARE the truth), verifying each caller turn against the recorded script (a divergent turn * is a typed `turn-conflict` refusal — fail-closed). This mirrors "HTTP is canonical; the SDK is a lossless * projection" (djm.5 design). The minimal shape consistent with djm.4's Delivery/SessionResponse. */ import type { FetchLike, TrialCapability } from "../client/index.ts"; import type { Transport } from "./types.ts"; export { createSdk, SDK_VERSION } from "./facade.ts"; export type { KestrelSdk, KestrelSession, SessionRef, SdkFinalized, GradeRequest, ArtifactResult, OperationRef, OperationResumption, Transport, Gated, GradeOutcome, ValidateOutcome, } from "./types.ts"; /** Options for {@link remoteTransport}: the managed API base + an optional `fetch` override (tests / a * custom agent) + an optional pre-seeded trial capability. Mirrors the 109 client's `ClientOptions`. */ export interface RemoteTransportOptions { readonly baseUrl: string; readonly fetch?: FetchLike; readonly capability?: TrialCapability; } /** * Build the HTTP transport over the managed API. Wrap it with `createSdk(remoteTransport({ baseUrl, fetch }))`. * Delegates catalog / validate / grade to the 109 client; runs + replays a catalog Session's server-computed * transcript for the incremental surface. Fail-closed and protocol-uniform throughout. */ export declare function remoteTransport(options: RemoteTransportOptions): Transport; //# sourceMappingURL=remote.d.ts.map