@chatpanel/sdk 0.1.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -172,6 +172,56 @@ export declare const OPERATIONS: {
172
172
  readonly pathParams: readonly [];
173
173
  readonly queryParams: readonly [];
174
174
  };
175
+ readonly "events.since": {
176
+ readonly id: "events.since";
177
+ readonly method: "GET";
178
+ readonly path: "/v1/events";
179
+ readonly auth: "token";
180
+ readonly since: "0.24.0";
181
+ readonly stream: null;
182
+ readonly pathParams: readonly [];
183
+ readonly queryParams: readonly ["cursor", "limit", "host"];
184
+ };
185
+ readonly "events.push": {
186
+ readonly id: "events.push";
187
+ readonly method: "POST";
188
+ readonly path: "/v1/events";
189
+ readonly auth: "token";
190
+ readonly since: "0.24.0";
191
+ readonly stream: null;
192
+ readonly pathParams: readonly [];
193
+ readonly queryParams: readonly [];
194
+ };
195
+ readonly "events.cursor": {
196
+ readonly id: "events.cursor";
197
+ readonly method: "GET";
198
+ readonly path: "/v1/events/cursor";
199
+ readonly auth: "token";
200
+ readonly since: "0.24.0";
201
+ readonly stream: null;
202
+ readonly pathParams: readonly [];
203
+ readonly queryParams: readonly [];
204
+ };
205
+ readonly "events.stats": {
206
+ readonly id: "events.stats";
207
+ readonly method: "GET";
208
+ readonly path: "/v1/events/stats";
209
+ readonly auth: "token";
210
+ readonly since: "0.25.1";
211
+ readonly stream: null;
212
+ readonly pathParams: readonly [];
213
+ readonly queryParams: readonly [];
214
+ };
215
+ readonly "events.stream": {
216
+ readonly id: "events.stream";
217
+ readonly method: "GET";
218
+ readonly path: "/v1/events/stream";
219
+ readonly auth: "token";
220
+ readonly since: "0.24.0";
221
+ readonly stream: "sse";
222
+ readonly pathParams: readonly [];
223
+ readonly queryParams: readonly ["cursor"];
224
+ };
175
225
  readonly "history.ingest": {
176
226
  readonly id: "history.ingest";
177
227
  readonly method: "POST";
@@ -552,6 +602,126 @@ export declare const OPERATIONS: {
552
602
  readonly pathParams: readonly ["agentId"];
553
603
  readonly queryParams: readonly [];
554
604
  };
605
+ readonly "capabilities.list": {
606
+ readonly id: "capabilities.list";
607
+ readonly method: "GET";
608
+ readonly path: "/v1/capabilities";
609
+ readonly auth: "open";
610
+ readonly since: "0.13.0";
611
+ readonly stream: null;
612
+ readonly pathParams: readonly [];
613
+ readonly queryParams: readonly [];
614
+ };
615
+ readonly "runtime.status": {
616
+ readonly id: "runtime.status";
617
+ readonly method: "GET";
618
+ readonly path: "/v1/runtime";
619
+ readonly auth: "open";
620
+ readonly since: "0.19.0";
621
+ readonly stream: null;
622
+ readonly pathParams: readonly [];
623
+ readonly queryParams: readonly [];
624
+ };
625
+ readonly "runtime.engine": {
626
+ readonly id: "runtime.engine";
627
+ readonly method: "POST";
628
+ readonly path: "/v1/runtime/engines/{name}";
629
+ readonly auth: "token";
630
+ readonly since: "0.19.0";
631
+ readonly stream: null;
632
+ readonly pathParams: readonly ["name"];
633
+ readonly queryParams: readonly [];
634
+ };
635
+ readonly "runtime.service": {
636
+ readonly id: "runtime.service";
637
+ readonly method: "POST";
638
+ readonly path: "/v1/runtime/services/{id}";
639
+ readonly auth: "token";
640
+ readonly since: "0.19.0";
641
+ readonly stream: null;
642
+ readonly pathParams: readonly ["id"];
643
+ readonly queryParams: readonly [];
644
+ };
645
+ readonly "capabilities.detect": {
646
+ readonly id: "capabilities.detect";
647
+ readonly method: "POST";
648
+ readonly path: "/v1/detect";
649
+ readonly auth: "open";
650
+ readonly since: "0.13.0";
651
+ readonly stream: null;
652
+ readonly pathParams: readonly [];
653
+ readonly queryParams: readonly [];
654
+ };
655
+ readonly "capabilities.rerank": {
656
+ readonly id: "capabilities.rerank";
657
+ readonly method: "POST";
658
+ readonly path: "/v1/rerank";
659
+ readonly auth: "open";
660
+ readonly since: "0.20.0";
661
+ readonly stream: null;
662
+ readonly pathParams: readonly [];
663
+ readonly queryParams: readonly [];
664
+ };
665
+ readonly "capabilities.decide": {
666
+ readonly id: "capabilities.decide";
667
+ readonly method: "POST";
668
+ readonly path: "/v1/decide";
669
+ readonly auth: "open";
670
+ readonly since: "0.20.0";
671
+ readonly stream: null;
672
+ readonly pathParams: readonly [];
673
+ readonly queryParams: readonly [];
674
+ };
675
+ readonly "retrieval.search": {
676
+ readonly id: "retrieval.search";
677
+ readonly method: "POST";
678
+ readonly path: "/v1/search";
679
+ readonly auth: "open";
680
+ readonly since: "0.15.0";
681
+ readonly stream: null;
682
+ readonly pathParams: readonly [];
683
+ readonly queryParams: readonly [];
684
+ };
685
+ readonly "retrieval.searchAlias": {
686
+ readonly id: "retrieval.searchAlias";
687
+ readonly method: "GET";
688
+ readonly path: "/v1/search/{q}";
689
+ readonly auth: "open";
690
+ readonly since: "0.15.0";
691
+ readonly stream: null;
692
+ readonly pathParams: readonly ["q"];
693
+ readonly queryParams: readonly ["read"];
694
+ };
695
+ readonly "retrieval.extract": {
696
+ readonly id: "retrieval.extract";
697
+ readonly method: "POST";
698
+ readonly path: "/v1/extract";
699
+ readonly auth: "open";
700
+ readonly since: "0.16.0";
701
+ readonly stream: null;
702
+ readonly pathParams: readonly [];
703
+ readonly queryParams: readonly [];
704
+ };
705
+ readonly "retrieval.read": {
706
+ readonly id: "retrieval.read";
707
+ readonly method: "POST";
708
+ readonly path: "/v1/read";
709
+ readonly auth: "open";
710
+ readonly since: "0.14.0";
711
+ readonly stream: null;
712
+ readonly pathParams: readonly [];
713
+ readonly queryParams: readonly [];
714
+ };
715
+ readonly "retrieval.readAlias": {
716
+ readonly id: "retrieval.readAlias";
717
+ readonly method: "GET";
718
+ readonly path: "/v1/read/{url}";
719
+ readonly auth: "open";
720
+ readonly since: "0.14.0";
721
+ readonly stream: null;
722
+ readonly pathParams: readonly ["url"];
723
+ readonly queryParams: readonly [];
724
+ };
555
725
  readonly "engines.list": {
556
726
  readonly id: "engines.list";
557
727
  readonly method: "GET";
@@ -602,6 +772,16 @@ export declare const OPERATIONS: {
602
772
  readonly pathParams: readonly ["skillId"];
603
773
  readonly queryParams: readonly ["workdir"];
604
774
  };
775
+ readonly "fusions.list": {
776
+ readonly id: "fusions.list";
777
+ readonly method: "GET";
778
+ readonly path: "/v1/fusions";
779
+ readonly auth: "open";
780
+ readonly since: "0.33.0";
781
+ readonly stream: null;
782
+ readonly pathParams: readonly [];
783
+ readonly queryParams: readonly [];
784
+ };
605
785
  };
606
786
  export type OperationId = keyof typeof OPERATIONS;
607
787
  /** Liveness, identity and pairing. */
@@ -633,7 +813,7 @@ export declare class ModelsApi {
633
813
  export declare class ChatApi {
634
814
  private readonly rt;
635
815
  constructor(rt: Runtime);
636
- /** One chat turn through the gateway (OpenAI-compatible). Redacted on the way out, restored on the way back, routed by `model`. With `stream: true` the response is `text/event-stream` of OpenAI chunk objects ending in `data: [DONE]`. Send `tools` so a redacted turn can still act: the gateway relays a tool call back with real arguments and redacts the result. `X-ChatPanel-Redaction: off` is honoured only from a token-bearing caller (0.6.69+) and is recorded in the trace. **Two lanes.** An API destination (a cloud or local model endpoint) is a proxy hop and is open to any local caller. An AGENT destination (`codex`, `claude`, `opencode`, … — `provider_type: agent` in `GET /v1/models`) spawns a process on this machine, so the caller must hold the gateway token (0.9.0+): without it the gateway answers **401** `{ type: 'auth', code: 'agent_lane_token_required' }`. The SDKs surface that as `ForbiddenError` with `status` 401. */
816
+ /** One chat turn through the gateway (OpenAI-compatible). Redacted on the way out, restored on the way back, routed by `model`. With `stream: true` the response is `text/event-stream` of OpenAI chunk objects ending in `data: [DONE]`. Send `tools` so a redacted turn can still act: the gateway relays a tool call back with real arguments and redacts the result. `X-ChatPanel-Redaction: off` is honoured only from a token-bearing caller (0.6.69+) and is recorded in the trace. **Permission prompts (gateway 0.25.0+).** List a function tool named `permission_prompt` to say your client can answer an agent's "may I run this?" — the gateway strips it from what the agent sees and lets the agent ask instead of denying headlessly. The question arrives as a `tool_calls` stop on that tool, its arguments `{ tool, input, description, path, rules }`; answer with a `tool` message whose content is the JSON `{ "behavior": "allow" | "deny", "scope": "once" | "chat", "message"?: string }`. Anything else is a deny. **Two lanes.** An API destination (a cloud or local model endpoint) is a proxy hop and is open to any local caller. An AGENT destination (`codex`, `claude`, `opencode`, … — `provider_type: agent` in `GET /v1/models`) spawns a process on this machine, so the caller must hold the gateway token (0.9.0+): without it the gateway answers **401** `{ type: 'auth', code: 'agent_lane_token_required' }`. The SDKs surface that as `ForbiddenError` with `status` 401. */
637
817
  completions(body: T.ChatCompletionRequest, opts?: RequestOptions & {
638
818
  headers?: {
639
819
  "X-ChatPanel-Redaction"?: "off";
@@ -707,6 +887,27 @@ export declare class HistoryApi {
707
887
  size: number;
708
888
  }>;
709
889
  }
890
+ /** The durable event log, merged across every client and served as one CloudEvents 1.0 stream — metadata only (refs and counts, never content), ordered by `(host, seq)` and `causes`, never by clock (docs/event-stream-sync.md E1). */
891
+ export declare class EventsApi {
892
+ private readonly rt;
893
+ constructor(rt: Runtime);
894
+ /** The merged log above a cursor — host by host in `seq` order, as CloudEvents, paged. — Requires the gateway token. Gateway 0.24.0+. */
895
+ since(query?: {
896
+ cursor?: string;
897
+ limit?: number;
898
+ host?: string;
899
+ }, opts?: RequestOptions): Promise<T.EventsPage>;
900
+ /** Push a batch of this client's durable log as CloudEvents; each event is appended once, each refusal is named. Idempotent on event id, so a retry is free. A `seq` that moves backwards for a host under a new id is a corrupt writer and is refused by itself; the rest of the batch lands. Push what lies above your entry in `cursor` (the gateway's highest `seq` per host) and stop re-sending what `rejected` names. At most 2000 events per batch. A gateway without SQLite answers 501. — Requires the gateway token. Gateway 0.24.0+. */
901
+ push(body: T.PushEventsRequest, opts?: RequestOptions): Promise<T.PushEventsResponse>;
902
+ /** The gateway's highest `seq` per host — what a client asks for before it pushes. — Requires the gateway token. Gateway 0.24.0+. */
903
+ cursor(opts?: RequestOptions): Promise<T.EventsCursor>;
904
+ /** What the merged log measures — bytes and events per turn, per surface, per host and per day; the dedup hit-rate; tool calls; a year projected against the cap. — Requires the gateway token. Gateway 0.25.1+. */
905
+ stats(opts?: RequestOptions): Promise<T.EventsStats>;
906
+ /** Tail the merged log — `hello` once, then a `cloudevent` frame per appended event; with `cursor`, the backlog above it first. — Requires the gateway token. Gateway 0.24.0+. */
907
+ stream(query?: {
908
+ cursor?: string;
909
+ }, opts?: RequestOptions): AsyncIterable<SseFrame<T.EventsStreamEvent>>;
910
+ }
710
911
  /** Durable facts about the user, carried into every turn on every client. */
711
912
  export declare class MemoryApi {
712
913
  private readonly rt;
@@ -956,6 +1157,72 @@ export declare class AgentsApi {
956
1157
  refs?: T.AnyObject;
957
1158
  }, opts?: RequestOptions): Promise<T.AnyObject>;
958
1159
  }
1160
+ /** The small non-generative models this gateway provides — discovery, and one standard signature per capability (docs/capability-endpoints.md). */
1161
+ export declare class CapabilitiesApi {
1162
+ private readonly rt;
1163
+ constructor(rt: Runtime);
1164
+ /** What this provider can do — which capabilities, models, measured cost and runtime state. The discovery document a client chooses a provider from: one entry per capability (`detect`, `stt`, `tts` today; `decide`, `rerank`, `embed` as they land), each at its standard route, with the models it can serve, the loaded model's own label vocabulary (`detect`), the measured latency record, and the runtime's state. Never loads a model. — Gateway 0.13.0+. */
1165
+ list(opts?: RequestOptions): Promise<T.CapabilitiesDocument>;
1166
+ /** Find entities in text — the model's own labels, with offsets and scores. The standard `detect` signature over the in-process entity detector. Labels are the model's own (`private_person`, `PER`, `GIVENNAME`…) — the client maps them; the vocabulary is listed by `GET /v1/capabilities`. `budgetMs` is refused (503 `over_budget`) from the provider's own latency record before the model runs, never missed. An engine that is still loading answers 503 `detector_unready`; an empty `entities` on 200 means the model found nothing. Raw text reaches the model here and nowhere else — this route is loopback-only like the rest of the gateway. — Gateway 0.13.0+. */
1167
+ detect(body: T.DetectRequest, opts?: RequestOptions): Promise<T.DetectResponse>;
1168
+ /** Order documents by relevance to a query — a cross-encoder, no language model. The Cohere / Jina rerank shape, served BY PROXY: the gateway forwards to the reranker it is pointed at — the `reranker` container started under Settings › Runtime (Text Embeddings Inference with `BAAI/bge-reranker-v2-m3`, loopback-only), or the server `capabilities.rerank` names — through the adapter that speaks its wire, and validates the answer against the contract before it leaves (a wrong shape is 502 `bad_shape`, never a bad order). `budgetMs` is refused (503 `over_budget`) from the gateway's own latency record before dialling. 404 `no_provider` until a provider is configured; 503 `provider_unavailable` when it does not answer. `GET /v1/capabilities` lists it only while configured. — Gateway 0.20.0+. */
1169
+ rerank(body: T.RerankRequest, opts?: RequestOptions): Promise<T.RerankResponse>;
1170
+ /** Typed decisions over a text — a choice, a score or a yes/no, each with a probability. ChatPanel's `decide` signature (docs/capability-endpoints.md §4.2): `state` is the text judged, `questions` are keyed by identifier — a `choice` picks one of its `options`, a `score` places the state on `options` read as an ordered rubric, a `noul` is yes/no. Served BY PROXY through the adapter the config names: the `opendecision` container started under Settings › Runtime (TypeSafe's `/v1/systemone` shape, loopback-only), or a server `capabilities.decide` names (a Jev endpoint with a token, another gateway). `calibrated` in the response says whether `p` may be read as a probability — an NLI concentration (OpenDecision) is not one. Errors as `/v1/rerank`. — Gateway 0.20.0+. */
1171
+ decide(body: T.DecideRequest, opts?: RequestOptions): Promise<T.DecideResponse>;
1172
+ }
1173
+ /** What runs processes for the user and how — the process sandbox (through the bridge), the container engine on this machine, and the services the gateway runs for the user (docs/sandboxing.md S1). */
1174
+ export declare class RuntimeApi {
1175
+ private readonly rt;
1176
+ constructor(rt: Runtime);
1177
+ /** The runtime — the process sandbox, what is running now, the container engine, the services. One document for Settings › Runtime. `sandbox` is the bridge's own (`/health.sandbox`: enabled, mode `open` | `allowlist` | `none`, the runtime found, the reason when none, the global `extras`, whether a process can get a session of its own, and `refused` — the last hosts any process was refused, names only). `processes` lists every local MCP server running for the user with its sandbox record and the hosts it was refused, and the warm agent processes. `engines` says which container engine exists (`podman` first, `docker`) and whether it can run a container now; when none does, `install` carries the command for this platform — shown to the person, never run by the gateway. `services` is the catalogue: `searxng` with its state (`no-engine` | `engine-stopped` | `absent` | `stopped` | `running`), its loopback URL and whether it answers. — Gateway 0.19.0+. */
1178
+ status(opts?: RequestOptions): Promise<T.RuntimeDocument>;
1179
+ /** Start the container engine (Podman — creates and starts its machine where one is needed). `{ action: 'start' }`. Podman on macOS and Windows runs containers in a machine: made on first start (`podman machine init`), then started. Linux Podman is rootless and needs nothing. Docker is not started by the gateway — the response says so. — Requires the gateway token. Gateway 0.19.0+. */
1180
+ engine(name: string, body: {
1181
+ action?: "start";
1182
+ }, opts?: RequestOptions): Promise<T.RuntimeActionResult>;
1183
+ /** Start or stop a catalogue service, or pick a capability container's model — each runs loopback-only and the gateway points at it. `{ action: 'start' | 'stop' }`. `start` brings the engine up if it is not, runs the service's container from its kit (SearXNG: `127.0.0.1:8888`, JSON on, the limiter off, a random secret, capabilities dropped; `reranker` on 8889 and `opendecision` on 8890 with the shared model cache mounted, gateway 0.20+) — the first start pulls the image — waits for it to answer, and sets the config that points the gateway at it (`search.searxng.url`; `capabilities.rerank` / `capabilities.decide`, so `/v1/rerank` and `/v1/decide` are served and listed). `stop` stops the container and clears what it set. `{ action: 'model', model }` (gateway 0.22+) picks the model a capability container runs — an id from its catalogue (`GET /v1/runtime` `services.<id>.models`) or a Hugging Face `owner/name` — gated by the container ENGINE's memory (a model it cannot hold is refused with the command that raises the ceiling); the container is re-created with the pick and restarted when it ran. — Requires the gateway token. Gateway 0.19.0+. */
1184
+ service(id: string, body: {
1185
+ action?: "start" | "stop" | "model";
1186
+ /** With `action: model` — a catalogue id or a Hugging Face owner/name. */
1187
+ model?: string;
1188
+ }, opts?: RequestOptions): Promise<T.RuntimeActionResult>;
1189
+ }
1190
+ /** Web retrieval — search through the provider the user chose, and a page as LLM-ready Markdown, cited where it landed, with its sections (docs/web-retrieval.md). */
1191
+ export declare class RetrievalApi {
1192
+ private readonly rt;
1193
+ constructor(rt: Runtime);
1194
+ /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. — Gateway 0.15.0+. */
1195
+ search(body: T.WebSearchRequest, opts?: RequestOptions): Promise<T.WebSearchResponse>;
1196
+ /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. — Gateway 0.15.0+. */
1197
+ searchAlias(q: string, query?: {
1198
+ read?: number;
1199
+ }, opts?: RequestOptions): Promise<{
1200
+ code: number;
1201
+ status: number;
1202
+ data: Array<{
1203
+ url: string;
1204
+ title: string;
1205
+ description: string;
1206
+ content: string;
1207
+ publishedTime?: string;
1208
+ }>;
1209
+ }>;
1210
+ /** A document's pages from its bytes — a PDF, a Word file, a sheet, a deck — parsed once, paged by hash. The `extract` capability (docs/capability-endpoints.md): the third leg beside `search` and `read`. Two calls on one route. With `name` and `data` (the file, base64), the document is parsed in a worker process on this machine — no network, the vault unreadable — and the answer is its identity (`hash`, SHA-256 of the bytes), its `type` as read from the bytes, its `title` when it has one and how many `pages` it has; the text stays on the server. With `hash` and `page`, one page's text comes back; the bytes crossed once. A page is the format's own unit (a PDF page, a slide, a sheet) or, for a document with none (DOCX, Markdown, text), a run of ~6,000 characters cut at a heading. Readers: PDF (pdf.js, the text layer — a scanned document is `scanned: true` with empty pages, never OCR'd), DOCX (Markdown), XLSX/ODS (rows of cells), PPTX/ODP (a slide per page, speaker notes appended), ODT, Markdown, text, CSV, HTML. A hash the worker no longer holds (it is dropped when idle) is a 404 `unknown_document`: send the bytes again. `budgetMs` is refused (503 `over_budget`) from the worker's own record. — Gateway 0.16.0+. */
1211
+ extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
1212
+ /** Read one public page as LLM-ready Markdown, cited where it landed, with its sections. The `read` capability (docs/web-retrieval.md §4.2). The page is fetched from this machine as the user's agent — public web only (the shared SSRF guard, re-checked where a redirect lands), a browser User-Agent, no cookies — and turned into Markdown that keeps headings, lists, tables, code and links. `url` in the answer is where the page should be CITED: the same-origin canonical when it declares one, else where the fetch landed; `sections` are the page's own heading ids with their offset into the content so a citation can point at `url#section`. A page that could not be read as the article — a login wall, a paywall, a 429 — is a 200 with `restricted.reason` and the caller's `snippet` standing in for the content, never the wall rendered as prose. `maxChars` cuts at a section boundary. A read is served from this process's page cache when fresh (`cached: true`), revalidated with its ETag when stale. `budgetMs` is refused (503 `over_budget`) from the provider's own record, never missed. Providers are listed by `GET /v1/capabilities`: `defuddle` (in-process), `text` (the DOM-less fallback), `remote` (an `r.jina.ai`-shaped reader configured under `read.remote`). — Gateway 0.14.0+. */
1213
+ read(body: T.ReadRequest, opts?: RequestOptions): Promise<T.ReadResponse>;
1214
+ /** The r.jina.ai-shaped alias — `GET /v1/read/https://…` — for clients that already speak it. Same read as `POST /v1/read`, addressed the way the shipped ChatPanel extension's *reader service* slot (and anything else built for `r.jina.ai`) already addresses a reader: the page URL appended to the base, as is or percent-encoded, with its own query string kept. Answers `text/plain` with `Title:` / `URL Source:` / `Published Time:` header lines, a blank line and `Markdown Content:`; under `Accept: application/json` the §4.2 document wrapped as `{ code, status, data }`. `X-Return-Format: text` selects the text form. A Bearer token is accepted and ignored. — Gateway 0.14.0+. */
1215
+ readAlias(url: string, opts?: RequestOptions & {
1216
+ headers?: {
1217
+ "Accept"?: string;
1218
+ "X-Return-Format"?: "markdown" | "text";
1219
+ };
1220
+ }): Promise<{
1221
+ code: number;
1222
+ status: number;
1223
+ data: T.ReadResponse;
1224
+ }>;
1225
+ }
959
1226
  /** The model ledger — every engine's card. */
960
1227
  export declare class EnginesApi {
961
1228
  private readonly rt;
@@ -992,6 +1259,13 @@ export declare class SkillsApi {
992
1259
  skill: T.Skill | null;
993
1260
  }>;
994
1261
  }
1262
+ /** Several models as one — union, draft + target, fallback. */
1263
+ export declare class FusionsApi {
1264
+ private readonly rt;
1265
+ constructor(rt: Runtime);
1266
+ /** Several models as one — the fusions this gateway has. Derived from state (the entity detector's union once a companion is ready, an engine drafting with a second model) and composed by the user (`POST /config { fusions }`, a chat fallback in order). A chat turn names a fallback as `model: "fusion:<id>"` and is routed to the first member that is up; `x-chatpanel-fusion` on the response says which. — Gateway 0.33.0+. */
1267
+ list(opts?: RequestOptions): Promise<T.FusionList>;
1268
+ }
995
1269
  /** The namespaces a client exposes, built on one runtime. */
996
1270
  export declare function buildApi(rt: Runtime): {
997
1271
  gateway: GatewayApi;
@@ -999,11 +1273,16 @@ export declare function buildApi(rt: Runtime): {
999
1273
  chat: ChatApi;
1000
1274
  redaction: RedactionApi;
1001
1275
  history: HistoryApi;
1276
+ events: EventsApi;
1002
1277
  memory: MemoryApi;
1003
1278
  prefs: PrefsApi;
1004
1279
  teams: TeamsApi;
1005
1280
  projects: ProjectsApi;
1006
1281
  agents: AgentsApi;
1282
+ capabilities: CapabilitiesApi;
1283
+ runtime: RuntimeApi;
1284
+ retrieval: RetrievalApi;
1007
1285
  engines: EnginesApi;
1008
1286
  skills: SkillsApi;
1287
+ fusions: FusionsApi;
1009
1288
  };
@@ -17,6 +17,11 @@ export const OPERATIONS = {
17
17
  "history.records": { id: "history.records", method: "GET", path: "/v1/history/records", auth: "open", since: "0.10.0", stream: null, pathParams: [], queryParams: ["since", "cursor", "limit", "kind"] },
18
18
  "history.putRecords": { id: "history.putRecords", method: "PUT", path: "/v1/history/records", auth: "token", since: "0.10.0", stream: null, pathParams: [], queryParams: [] },
19
19
  "history.stream": { id: "history.stream", method: "GET", path: "/v1/history/stream", auth: "open", since: "0.11.0", stream: "sse", pathParams: [], queryParams: [] },
20
+ "events.since": { id: "events.since", method: "GET", path: "/v1/events", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: ["cursor", "limit", "host"] },
21
+ "events.push": { id: "events.push", method: "POST", path: "/v1/events", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: [] },
22
+ "events.cursor": { id: "events.cursor", method: "GET", path: "/v1/events/cursor", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: [] },
23
+ "events.stats": { id: "events.stats", method: "GET", path: "/v1/events/stats", auth: "token", since: "0.25.1", stream: null, pathParams: [], queryParams: [] },
24
+ "events.stream": { id: "events.stream", method: "GET", path: "/v1/events/stream", auth: "token", since: "0.24.0", stream: "sse", pathParams: [], queryParams: ["cursor"] },
20
25
  "history.ingest": { id: "history.ingest", method: "POST", path: "/v1/history/ingest", auth: "token", since: null, stream: null, pathParams: [], queryParams: [] },
21
26
  "memory.list": { id: "memory.list", method: "GET", path: "/v1/memory/list", auth: "open", since: null, stream: null, pathParams: [], queryParams: [] },
22
27
  "memory.recall": { id: "memory.recall", method: "POST", path: "/v1/memory/recall", auth: "open", since: null, stream: null, pathParams: [], queryParams: [] },
@@ -55,11 +60,24 @@ export const OPERATIONS = {
55
60
  "agents.scorecards": { id: "agents.scorecards", method: "GET", path: "/v1/agents/scorecards", auth: "open", since: "0.6.87", stream: null, pathParams: [], queryParams: [] },
56
61
  "agents.scorecard": { id: "agents.scorecard", method: "GET", path: "/v1/agents/{agentId}/scorecard", auth: "open", since: "0.6.87", stream: null, pathParams: ["agentId"], queryParams: [] },
57
62
  "agents.rate": { id: "agents.rate", method: "POST", path: "/v1/agents/{agentId}/scorecard", auth: "open", since: "0.6.87", stream: null, pathParams: ["agentId"], queryParams: [] },
63
+ "capabilities.list": { id: "capabilities.list", method: "GET", path: "/v1/capabilities", auth: "open", since: "0.13.0", stream: null, pathParams: [], queryParams: [] },
64
+ "runtime.status": { id: "runtime.status", method: "GET", path: "/v1/runtime", auth: "open", since: "0.19.0", stream: null, pathParams: [], queryParams: [] },
65
+ "runtime.engine": { id: "runtime.engine", method: "POST", path: "/v1/runtime/engines/{name}", auth: "token", since: "0.19.0", stream: null, pathParams: ["name"], queryParams: [] },
66
+ "runtime.service": { id: "runtime.service", method: "POST", path: "/v1/runtime/services/{id}", auth: "token", since: "0.19.0", stream: null, pathParams: ["id"], queryParams: [] },
67
+ "capabilities.detect": { id: "capabilities.detect", method: "POST", path: "/v1/detect", auth: "open", since: "0.13.0", stream: null, pathParams: [], queryParams: [] },
68
+ "capabilities.rerank": { id: "capabilities.rerank", method: "POST", path: "/v1/rerank", auth: "open", since: "0.20.0", stream: null, pathParams: [], queryParams: [] },
69
+ "capabilities.decide": { id: "capabilities.decide", method: "POST", path: "/v1/decide", auth: "open", since: "0.20.0", stream: null, pathParams: [], queryParams: [] },
70
+ "retrieval.search": { id: "retrieval.search", method: "POST", path: "/v1/search", auth: "open", since: "0.15.0", stream: null, pathParams: [], queryParams: [] },
71
+ "retrieval.searchAlias": { id: "retrieval.searchAlias", method: "GET", path: "/v1/search/{q}", auth: "open", since: "0.15.0", stream: null, pathParams: ["q"], queryParams: ["read"] },
72
+ "retrieval.extract": { id: "retrieval.extract", method: "POST", path: "/v1/extract", auth: "open", since: "0.16.0", stream: null, pathParams: [], queryParams: [] },
73
+ "retrieval.read": { id: "retrieval.read", method: "POST", path: "/v1/read", auth: "open", since: "0.14.0", stream: null, pathParams: [], queryParams: [] },
74
+ "retrieval.readAlias": { id: "retrieval.readAlias", method: "GET", path: "/v1/read/{url}", auth: "open", since: "0.14.0", stream: null, pathParams: ["url"], queryParams: [] },
58
75
  "engines.list": { id: "engines.list", method: "GET", path: "/v1/engines", auth: "open", since: "0.6.89", stream: null, pathParams: [], queryParams: ["minCalls"] },
59
76
  "engines.card": { id: "engines.card", method: "GET", path: "/v1/engines/{engineKey}/card", auth: "open", since: "0.6.89", stream: null, pathParams: ["engineKey"], queryParams: ["entries", "minCalls"] },
60
77
  "engines.appendEntry": { id: "engines.appendEntry", method: "POST", path: "/v1/engines/{engineKey}/entries", auth: "open", since: "0.6.89", stream: null, pathParams: ["engineKey"], queryParams: [] },
61
78
  "skills.list": { id: "skills.list", method: "GET", path: "/skills", auth: "open", since: "0.6.64", stream: null, pathParams: [], queryParams: ["workdir"] },
62
79
  "skills.get": { id: "skills.get", method: "GET", path: "/skills/{skillId}", auth: "open", since: "0.6.67", stream: null, pathParams: ["skillId"], queryParams: ["workdir"] },
80
+ "fusions.list": { id: "fusions.list", method: "GET", path: "/v1/fusions", auth: "open", since: "0.33.0", stream: null, pathParams: [], queryParams: [] },
63
81
  };
64
82
  /** Liveness, identity and pairing. */
65
83
  export class GatewayApi {
@@ -99,7 +117,7 @@ export class ModelsApi {
99
117
  export class ChatApi {
100
118
  rt;
101
119
  constructor(rt) { this.rt = rt; }
102
- /** One chat turn through the gateway (OpenAI-compatible). Redacted on the way out, restored on the way back, routed by `model`. With `stream: true` the response is `text/event-stream` of OpenAI chunk objects ending in `data: [DONE]`. Send `tools` so a redacted turn can still act: the gateway relays a tool call back with real arguments and redacts the result. `X-ChatPanel-Redaction: off` is honoured only from a token-bearing caller (0.6.69+) and is recorded in the trace. **Two lanes.** An API destination (a cloud or local model endpoint) is a proxy hop and is open to any local caller. An AGENT destination (`codex`, `claude`, `opencode`, … — `provider_type: agent` in `GET /v1/models`) spawns a process on this machine, so the caller must hold the gateway token (0.9.0+): without it the gateway answers **401** `{ type: 'auth', code: 'agent_lane_token_required' }`. The SDKs surface that as `ForbiddenError` with `status` 401. */
120
+ /** One chat turn through the gateway (OpenAI-compatible). Redacted on the way out, restored on the way back, routed by `model`. With `stream: true` the response is `text/event-stream` of OpenAI chunk objects ending in `data: [DONE]`. Send `tools` so a redacted turn can still act: the gateway relays a tool call back with real arguments and redacts the result. `X-ChatPanel-Redaction: off` is honoured only from a token-bearing caller (0.6.69+) and is recorded in the trace. **Permission prompts (gateway 0.25.0+).** List a function tool named `permission_prompt` to say your client can answer an agent's "may I run this?" — the gateway strips it from what the agent sees and lets the agent ask instead of denying headlessly. The question arrives as a `tool_calls` stop on that tool, its arguments `{ tool, input, description, path, rules }`; answer with a `tool` message whose content is the JSON `{ "behavior": "allow" | "deny", "scope": "once" | "chat", "message"?: string }`. Anything else is a deny. **Two lanes.** An API destination (a cloud or local model endpoint) is a proxy hop and is open to any local caller. An AGENT destination (`codex`, `claude`, `opencode`, … — `provider_type: agent` in `GET /v1/models`) spawns a process on this machine, so the caller must hold the gateway token (0.9.0+): without it the gateway answers **401** `{ type: 'auth', code: 'agent_lane_token_required' }`. The SDKs surface that as `ForbiddenError` with `status` 401. */
103
121
  completions(body, opts) {
104
122
  return this.rt.request(OPERATIONS["chat.completions"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
105
123
  }
@@ -162,6 +180,31 @@ export class HistoryApi {
162
180
  return this.rt.request(OPERATIONS["history.ingest"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
163
181
  }
164
182
  }
183
+ /** The durable event log, merged across every client and served as one CloudEvents 1.0 stream — metadata only (refs and counts, never content), ordered by `(host, seq)` and `causes`, never by clock (docs/event-stream-sync.md E1). */
184
+ export class EventsApi {
185
+ rt;
186
+ constructor(rt) { this.rt = rt; }
187
+ /** The merged log above a cursor — host by host in `seq` order, as CloudEvents, paged. — Requires the gateway token. Gateway 0.24.0+. */
188
+ since(query, opts) {
189
+ return this.rt.request(OPERATIONS["events.since"], { path: {}, query: query, headers: opts?.headers, body: undefined, opts });
190
+ }
191
+ /** Push a batch of this client's durable log as CloudEvents; each event is appended once, each refusal is named. Idempotent on event id, so a retry is free. A `seq` that moves backwards for a host under a new id is a corrupt writer and is refused by itself; the rest of the batch lands. Push what lies above your entry in `cursor` (the gateway's highest `seq` per host) and stop re-sending what `rejected` names. At most 2000 events per batch. A gateway without SQLite answers 501. — Requires the gateway token. Gateway 0.24.0+. */
192
+ push(body, opts) {
193
+ return this.rt.request(OPERATIONS["events.push"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
194
+ }
195
+ /** The gateway's highest `seq` per host — what a client asks for before it pushes. — Requires the gateway token. Gateway 0.24.0+. */
196
+ cursor(opts) {
197
+ return this.rt.request(OPERATIONS["events.cursor"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
198
+ }
199
+ /** What the merged log measures — bytes and events per turn, per surface, per host and per day; the dedup hit-rate; tool calls; a year projected against the cap. — Requires the gateway token. Gateway 0.25.1+. */
200
+ stats(opts) {
201
+ return this.rt.request(OPERATIONS["events.stats"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
202
+ }
203
+ /** Tail the merged log — `hello` once, then a `cloudevent` frame per appended event; with `cursor`, the backlog above it first. — Requires the gateway token. Gateway 0.24.0+. */
204
+ stream(query, opts) {
205
+ return this.rt.stream(OPERATIONS["events.stream"], { path: {}, query: query, headers: opts?.headers, opts });
206
+ }
207
+ }
165
208
  /** Durable facts about the user, carried into every turn on every client. */
166
209
  export class MemoryApi {
167
210
  rt;
@@ -335,6 +378,69 @@ export class AgentsApi {
335
378
  return this.rt.request(OPERATIONS["agents.rate"], { path: { agentId }, query: undefined, headers: opts?.headers, body: body, opts });
336
379
  }
337
380
  }
381
+ /** The small non-generative models this gateway provides — discovery, and one standard signature per capability (docs/capability-endpoints.md). */
382
+ export class CapabilitiesApi {
383
+ rt;
384
+ constructor(rt) { this.rt = rt; }
385
+ /** What this provider can do — which capabilities, models, measured cost and runtime state. The discovery document a client chooses a provider from: one entry per capability (`detect`, `stt`, `tts` today; `decide`, `rerank`, `embed` as they land), each at its standard route, with the models it can serve, the loaded model's own label vocabulary (`detect`), the measured latency record, and the runtime's state. Never loads a model. — Gateway 0.13.0+. */
386
+ list(opts) {
387
+ return this.rt.request(OPERATIONS["capabilities.list"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
388
+ }
389
+ /** Find entities in text — the model's own labels, with offsets and scores. The standard `detect` signature over the in-process entity detector. Labels are the model's own (`private_person`, `PER`, `GIVENNAME`…) — the client maps them; the vocabulary is listed by `GET /v1/capabilities`. `budgetMs` is refused (503 `over_budget`) from the provider's own latency record before the model runs, never missed. An engine that is still loading answers 503 `detector_unready`; an empty `entities` on 200 means the model found nothing. Raw text reaches the model here and nowhere else — this route is loopback-only like the rest of the gateway. — Gateway 0.13.0+. */
390
+ detect(body, opts) {
391
+ return this.rt.request(OPERATIONS["capabilities.detect"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
392
+ }
393
+ /** Order documents by relevance to a query — a cross-encoder, no language model. The Cohere / Jina rerank shape, served BY PROXY: the gateway forwards to the reranker it is pointed at — the `reranker` container started under Settings › Runtime (Text Embeddings Inference with `BAAI/bge-reranker-v2-m3`, loopback-only), or the server `capabilities.rerank` names — through the adapter that speaks its wire, and validates the answer against the contract before it leaves (a wrong shape is 502 `bad_shape`, never a bad order). `budgetMs` is refused (503 `over_budget`) from the gateway's own latency record before dialling. 404 `no_provider` until a provider is configured; 503 `provider_unavailable` when it does not answer. `GET /v1/capabilities` lists it only while configured. — Gateway 0.20.0+. */
394
+ rerank(body, opts) {
395
+ return this.rt.request(OPERATIONS["capabilities.rerank"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
396
+ }
397
+ /** Typed decisions over a text — a choice, a score or a yes/no, each with a probability. ChatPanel's `decide` signature (docs/capability-endpoints.md §4.2): `state` is the text judged, `questions` are keyed by identifier — a `choice` picks one of its `options`, a `score` places the state on `options` read as an ordered rubric, a `noul` is yes/no. Served BY PROXY through the adapter the config names: the `opendecision` container started under Settings › Runtime (TypeSafe's `/v1/systemone` shape, loopback-only), or a server `capabilities.decide` names (a Jev endpoint with a token, another gateway). `calibrated` in the response says whether `p` may be read as a probability — an NLI concentration (OpenDecision) is not one. Errors as `/v1/rerank`. — Gateway 0.20.0+. */
398
+ decide(body, opts) {
399
+ return this.rt.request(OPERATIONS["capabilities.decide"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
400
+ }
401
+ }
402
+ /** What runs processes for the user and how — the process sandbox (through the bridge), the container engine on this machine, and the services the gateway runs for the user (docs/sandboxing.md S1). */
403
+ export class RuntimeApi {
404
+ rt;
405
+ constructor(rt) { this.rt = rt; }
406
+ /** The runtime — the process sandbox, what is running now, the container engine, the services. One document for Settings › Runtime. `sandbox` is the bridge's own (`/health.sandbox`: enabled, mode `open` | `allowlist` | `none`, the runtime found, the reason when none, the global `extras`, whether a process can get a session of its own, and `refused` — the last hosts any process was refused, names only). `processes` lists every local MCP server running for the user with its sandbox record and the hosts it was refused, and the warm agent processes. `engines` says which container engine exists (`podman` first, `docker`) and whether it can run a container now; when none does, `install` carries the command for this platform — shown to the person, never run by the gateway. `services` is the catalogue: `searxng` with its state (`no-engine` | `engine-stopped` | `absent` | `stopped` | `running`), its loopback URL and whether it answers. — Gateway 0.19.0+. */
407
+ status(opts) {
408
+ return this.rt.request(OPERATIONS["runtime.status"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
409
+ }
410
+ /** Start the container engine (Podman — creates and starts its machine where one is needed). `{ action: 'start' }`. Podman on macOS and Windows runs containers in a machine: made on first start (`podman machine init`), then started. Linux Podman is rootless and needs nothing. Docker is not started by the gateway — the response says so. — Requires the gateway token. Gateway 0.19.0+. */
411
+ engine(name, body, opts) {
412
+ return this.rt.request(OPERATIONS["runtime.engine"], { path: { name }, query: undefined, headers: opts?.headers, body: body, opts });
413
+ }
414
+ /** Start or stop a catalogue service, or pick a capability container's model — each runs loopback-only and the gateway points at it. `{ action: 'start' | 'stop' }`. `start` brings the engine up if it is not, runs the service's container from its kit (SearXNG: `127.0.0.1:8888`, JSON on, the limiter off, a random secret, capabilities dropped; `reranker` on 8889 and `opendecision` on 8890 with the shared model cache mounted, gateway 0.20+) — the first start pulls the image — waits for it to answer, and sets the config that points the gateway at it (`search.searxng.url`; `capabilities.rerank` / `capabilities.decide`, so `/v1/rerank` and `/v1/decide` are served and listed). `stop` stops the container and clears what it set. `{ action: 'model', model }` (gateway 0.22+) picks the model a capability container runs — an id from its catalogue (`GET /v1/runtime` `services.<id>.models`) or a Hugging Face `owner/name` — gated by the container ENGINE's memory (a model it cannot hold is refused with the command that raises the ceiling); the container is re-created with the pick and restarted when it ran. — Requires the gateway token. Gateway 0.19.0+. */
415
+ service(id, body, opts) {
416
+ return this.rt.request(OPERATIONS["runtime.service"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
417
+ }
418
+ }
419
+ /** Web retrieval — search through the provider the user chose, and a page as LLM-ready Markdown, cited where it landed, with its sections (docs/web-retrieval.md). */
420
+ export class RetrievalApi {
421
+ rt;
422
+ constructor(rt) { this.rt = rt; }
423
+ /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. — Gateway 0.15.0+. */
424
+ search(body, opts) {
425
+ return this.rt.request(OPERATIONS["retrieval.search"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
426
+ }
427
+ /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. — Gateway 0.15.0+. */
428
+ searchAlias(q, query, opts) {
429
+ return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
430
+ }
431
+ /** A document's pages from its bytes — a PDF, a Word file, a sheet, a deck — parsed once, paged by hash. The `extract` capability (docs/capability-endpoints.md): the third leg beside `search` and `read`. Two calls on one route. With `name` and `data` (the file, base64), the document is parsed in a worker process on this machine — no network, the vault unreadable — and the answer is its identity (`hash`, SHA-256 of the bytes), its `type` as read from the bytes, its `title` when it has one and how many `pages` it has; the text stays on the server. With `hash` and `page`, one page's text comes back; the bytes crossed once. A page is the format's own unit (a PDF page, a slide, a sheet) or, for a document with none (DOCX, Markdown, text), a run of ~6,000 characters cut at a heading. Readers: PDF (pdf.js, the text layer — a scanned document is `scanned: true` with empty pages, never OCR'd), DOCX (Markdown), XLSX/ODS (rows of cells), PPTX/ODP (a slide per page, speaker notes appended), ODT, Markdown, text, CSV, HTML. A hash the worker no longer holds (it is dropped when idle) is a 404 `unknown_document`: send the bytes again. `budgetMs` is refused (503 `over_budget`) from the worker's own record. — Gateway 0.16.0+. */
432
+ extract(body, opts) {
433
+ return this.rt.request(OPERATIONS["retrieval.extract"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
434
+ }
435
+ /** Read one public page as LLM-ready Markdown, cited where it landed, with its sections. The `read` capability (docs/web-retrieval.md §4.2). The page is fetched from this machine as the user's agent — public web only (the shared SSRF guard, re-checked where a redirect lands), a browser User-Agent, no cookies — and turned into Markdown that keeps headings, lists, tables, code and links. `url` in the answer is where the page should be CITED: the same-origin canonical when it declares one, else where the fetch landed; `sections` are the page's own heading ids with their offset into the content so a citation can point at `url#section`. A page that could not be read as the article — a login wall, a paywall, a 429 — is a 200 with `restricted.reason` and the caller's `snippet` standing in for the content, never the wall rendered as prose. `maxChars` cuts at a section boundary. A read is served from this process's page cache when fresh (`cached: true`), revalidated with its ETag when stale. `budgetMs` is refused (503 `over_budget`) from the provider's own record, never missed. Providers are listed by `GET /v1/capabilities`: `defuddle` (in-process), `text` (the DOM-less fallback), `remote` (an `r.jina.ai`-shaped reader configured under `read.remote`). — Gateway 0.14.0+. */
436
+ read(body, opts) {
437
+ return this.rt.request(OPERATIONS["retrieval.read"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
438
+ }
439
+ /** The r.jina.ai-shaped alias — `GET /v1/read/https://…` — for clients that already speak it. Same read as `POST /v1/read`, addressed the way the shipped ChatPanel extension's *reader service* slot (and anything else built for `r.jina.ai`) already addresses a reader: the page URL appended to the base, as is or percent-encoded, with its own query string kept. Answers `text/plain` with `Title:` / `URL Source:` / `Published Time:` header lines, a blank line and `Markdown Content:`; under `Accept: application/json` the §4.2 document wrapped as `{ code, status, data }`. `X-Return-Format: text` selects the text form. A Bearer token is accepted and ignored. — Gateway 0.14.0+. */
440
+ readAlias(url, opts) {
441
+ return this.rt.request(OPERATIONS["retrieval.readAlias"], { path: { url }, query: undefined, headers: opts?.headers, body: undefined, opts });
442
+ }
443
+ }
338
444
  /** The model ledger — every engine's card. */
339
445
  export class EnginesApi {
340
446
  rt;
@@ -365,6 +471,15 @@ export class SkillsApi {
365
471
  return this.rt.request(OPERATIONS["skills.get"], { path: { skillId }, query: query, headers: opts?.headers, body: undefined, opts });
366
472
  }
367
473
  }
474
+ /** Several models as one — union, draft + target, fallback. */
475
+ export class FusionsApi {
476
+ rt;
477
+ constructor(rt) { this.rt = rt; }
478
+ /** Several models as one — the fusions this gateway has. Derived from state (the entity detector's union once a companion is ready, an engine drafting with a second model) and composed by the user (`POST /config { fusions }`, a chat fallback in order). A chat turn names a fallback as `model: "fusion:<id>"` and is routed to the first member that is up; `x-chatpanel-fusion` on the response says which. — Gateway 0.33.0+. */
479
+ list(opts) {
480
+ return this.rt.request(OPERATIONS["fusions.list"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
481
+ }
482
+ }
368
483
  /** The namespaces a client exposes, built on one runtime. */
369
484
  export function buildApi(rt) {
370
485
  return {
@@ -373,12 +488,17 @@ export function buildApi(rt) {
373
488
  chat: new ChatApi(rt),
374
489
  redaction: new RedactionApi(rt),
375
490
  history: new HistoryApi(rt),
491
+ events: new EventsApi(rt),
376
492
  memory: new MemoryApi(rt),
377
493
  prefs: new PrefsApi(rt),
378
494
  teams: new TeamsApi(rt),
379
495
  projects: new ProjectsApi(rt),
380
496
  agents: new AgentsApi(rt),
497
+ capabilities: new CapabilitiesApi(rt),
498
+ runtime: new RuntimeApi(rt),
499
+ retrieval: new RetrievalApi(rt),
381
500
  engines: new EnginesApi(rt),
382
501
  skills: new SkillsApi(rt),
502
+ fusions: new FusionsApi(rt),
383
503
  };
384
504
  }
@@ -69,6 +69,8 @@ export interface Model {
69
69
  reason?: string;
70
70
  /** False when the agent cannot take per-turn tools. */
71
71
  tools?: boolean;
72
+ /** 0.40.0+ — where the model runs, which is what a privacy ceiling reads: `device` on this machine, `trusted` on the private network, `any` a cloud. For a coding agent it is where its MODEL is (Codex → OpenAI is `any`; OpenCode over Ollama is `device`), never where the CLI process runs. Every row is served on the gateway's loopback address, so the address says nothing — read this field. */
73
+ reach?: "device" | "trusted" | "any";
72
74
  [key: string]: unknown;
73
75
  }
74
76
  export interface ModelList {
@@ -130,6 +132,312 @@ export interface ChatCompletionChunk {
130
132
  usage?: AnyObject;
131
133
  [key: string]: unknown;
132
134
  }
135
+ /** The runtime — Settings › Runtime's one document (docs/sandboxing.md S1). */
136
+ export interface RuntimeDocument {
137
+ /** the bridge's /health.sandbox: enabled, mode, runtime, reason?, extras, ownSessions, refused[] (names only), provisioned? (Windows) */
138
+ sandbox?: AnyObject;
139
+ processes?: {
140
+ /** every process running for the user — the bridge's (kind agent | warm | mcp | probe) and the gateway's own workers (kind worker): id, kind, engine, command (basename), label, pid, since, sandbox (the record), refused[] — never argv or env (0.19.1) */
141
+ all?: Array<AnyObject>;
142
+ /** id, command (basename), pid, since, sandbox (the record), refused[] — never argv or env */
143
+ localMcp?: Array<AnyObject>;
144
+ warm?: AnyObject;
145
+ };
146
+ /** every container the engine has, running or not: name, image, state, status, ports[], ours (a chatpanel- name), engine (0.19.1) */
147
+ containers?: Array<AnyObject>;
148
+ /** { id, engine, host, at } newest first */
149
+ refused?: Array<AnyObject>;
150
+ bridge?: {
151
+ ok?: boolean;
152
+ version?: string;
153
+ };
154
+ /** podman/docker: { installed, version?, running?, machine? }; preferred; install? { command, url, note } */
155
+ engines?: AnyObject;
156
+ /** Per catalogue service (searxng · reranker · opendecision): { id, label, image, container, port, blurb, provides, engine, state, url, configured, answering } — a capability container also { model, default, models: [{ id, label, lang, tier, approxMB, ramMB, licence, recommended, installed, note, unavailable?, ramNote? }], machine: { engineRamMB } } (gateway 0.22+). */
157
+ services?: AnyObject;
158
+ }
159
+ export interface RuntimeActionResult {
160
+ ok: boolean;
161
+ error?: string;
162
+ already?: boolean;
163
+ url?: string;
164
+ answering?: boolean;
165
+ install?: AnyObject;
166
+ /** The capabilities the service now stands behind (gateway 0.20+). */
167
+ provides?: Array<string>;
168
+ /** The model the container runs, on a start or a model pick (gateway 0.22+). */
169
+ model?: string;
170
+ /** A model pick re-created a running container. */
171
+ restarted?: boolean;
172
+ /** A model pick that fits but is tight for the engine's memory. */
173
+ note?: string;
174
+ }
175
+ export interface CapabilitiesDocument {
176
+ capabilities: Array<Capability>;
177
+ server: {
178
+ name: string;
179
+ version: string;
180
+ /** Where this provider's egress audit is served. */
181
+ audit?: string;
182
+ };
183
+ }
184
+ export interface Capability {
185
+ id: "detect" | "decide" | "rerank" | "embed" | "stt" | "tts" | "search" | "read";
186
+ /** The standard route for this capability on this provider. */
187
+ route: string;
188
+ /** Model capabilities (detect, decide, rerank, embed, stt, tts): the models offered. Required for those. */
189
+ models?: Array<string>;
190
+ /** Provider capabilities (search, read): the providers offered — a SearXNG, a SERP scraper, an extractor. Required for those. */
191
+ providers?: Array<string>;
192
+ /** One of `models`, or of `providers`. */
193
+ default?: string;
194
+ /** detect: the loaded model's label vocabulary, BIOES prefixes stripped. Empty until a model is loaded. */
195
+ labels?: Array<string>;
196
+ /** detect: the tokenizer's limit; null when effectively unbounded. */
197
+ maxTokens?: number | null;
198
+ requirements?: AnyObject;
199
+ stats?: CapabilityStats;
200
+ /** state (off | loading | downloading | ready | error | external), name, dtype, error… */
201
+ runtime?: AnyObject;
202
+ /** stt: the session route for live dictation. */
203
+ streaming?: string;
204
+ /** tts: the voices route. */
205
+ voices?: string;
206
+ }
207
+ export interface CapabilityStats {
208
+ calls: number;
209
+ p50Ms?: number;
210
+ p95Ms?: number;
211
+ maxMs?: number;
212
+ lastMs?: number;
213
+ charsPerSec?: number | null;
214
+ }
215
+ export interface DetectRequest {
216
+ text: string;
217
+ /** A model this provider lists; 404 otherwise. */
218
+ model?: string;
219
+ /** Keep only these of the model's labels. */
220
+ labels?: Array<string>;
221
+ /** Refused before running if the provider's record predicts it cannot be met. */
222
+ budgetMs?: number;
223
+ }
224
+ export interface DetectedEntity {
225
+ value: string;
226
+ /** The model's own label. */
227
+ type: string;
228
+ /** Character offset into the request text. */
229
+ start: number;
230
+ end: number;
231
+ score: number;
232
+ }
233
+ export interface DetectResponse {
234
+ entities: Array<DetectedEntity>;
235
+ model: string;
236
+ ms: number;
237
+ runtime?: AnyObject;
238
+ }
239
+ export interface RerankRequest {
240
+ query: string;
241
+ documents: Array<string>;
242
+ /** Return only the best this many. */
243
+ top_n?: number;
244
+ /** The model this provider serves; 404 otherwise. */
245
+ model?: string;
246
+ /** Refused before dialling if the gateway's record predicts it cannot be met. */
247
+ budgetMs?: number;
248
+ }
249
+ export interface RerankResult {
250
+ /** Into the request's documents. */
251
+ index: number;
252
+ relevance_score: number;
253
+ }
254
+ export interface RerankResponse {
255
+ /** Distinct indexes, best first; at most top_n. */
256
+ results: Array<RerankResult>;
257
+ model: string;
258
+ ms: number;
259
+ }
260
+ export interface DecideOption {
261
+ value: string;
262
+ /** What the option means — travels to the model as its criterion. */
263
+ describe?: string;
264
+ }
265
+ export interface DecideQuestion {
266
+ type: "choice" | "score" | "noul";
267
+ instructions: string;
268
+ /** choice: the values to pick from; score: the rubric, in order. A noul has none. */
269
+ options?: Array<string | DecideOption>;
270
+ }
271
+ export interface DecideRequest {
272
+ /** The text judged. */
273
+ state: string;
274
+ /** Keyed by identifier ([A-Za-z_][A-Za-z0-9_]*). */
275
+ questions: {
276
+ [key: string]: DecideQuestion;
277
+ };
278
+ /** The model this provider serves; 404 otherwise. */
279
+ model?: string;
280
+ budgetMs?: number;
281
+ }
282
+ export interface DecideAnswerOption {
283
+ /** A string (choice, score rubric entry) or a boolean (noul). */
284
+ value: unknown;
285
+ p: number;
286
+ }
287
+ export interface DecideAnswer {
288
+ /** choice: the option picked; score: a number on the rubric; noul: a boolean. */
289
+ value: unknown;
290
+ /** The probability of `value` — read it as one only when the response says `calibrated`. */
291
+ p: number;
292
+ /** The whole distribution. */
293
+ options: Array<DecideAnswerOption>;
294
+ /** The provider's own confidence, when it reports one. */
295
+ confidence?: number;
296
+ }
297
+ export interface DecideResponse {
298
+ /** One per question asked, under the same key. */
299
+ answers: {
300
+ [key: string]: DecideAnswer;
301
+ };
302
+ model: string;
303
+ ms: number;
304
+ /** Whether `p` is a calibrated probability. false for a zero-shot NLI concentration. */
305
+ calibrated?: boolean;
306
+ }
307
+ export interface WebSearchRequest {
308
+ q: string;
309
+ limit?: number;
310
+ /** en or en-US; honoured by SearXNG. */
311
+ lang?: string;
312
+ /** A hostname — the site: operator. */
313
+ site?: string;
314
+ /** Honoured by SearXNG (time_range); week maps to month. */
315
+ freshness?: "day" | "week" | "month" | "year";
316
+ /** Read the top N results in this request. */
317
+ read?: number;
318
+ /** One of the providers `GET /v1/capabilities` lists for `search`; 404 otherwise. */
319
+ provider?: string;
320
+ budgetMs?: number;
321
+ }
322
+ export interface WebSearchResult {
323
+ rank: number;
324
+ url: string;
325
+ title: string;
326
+ snippet: string;
327
+ /** The engine that produced it (SearXNG: the first of `engines`; serp: the results page asked). */
328
+ engine?: string;
329
+ /** SearXNG: every engine that returned it. */
330
+ engines?: Array<string>;
331
+ /** SearXNG's fused score. */
332
+ score?: number;
333
+ publishedDate?: string;
334
+ /** Present for the top `read` results. */
335
+ read?: ReadResponse;
336
+ }
337
+ export interface WebSearchResponse {
338
+ results: Array<WebSearchResult>;
339
+ /** SearXNG's direct answers, when it had any. */
340
+ answers?: Array<string>;
341
+ suggestions?: Array<string>;
342
+ /** What was actually asked. */
343
+ engines?: Array<string>;
344
+ /** SearXNG engines that did not answer. */
345
+ unresponsive?: Array<string>;
346
+ /** Layer-1 redaction removed something from the query. */
347
+ redacted?: boolean;
348
+ /** The query as sent, when `redacted`. */
349
+ query?: string;
350
+ provider: string;
351
+ ms: number;
352
+ }
353
+ /** Either `name` + `data` (open a document) or `hash` + `page` (read one page of an open document). */
354
+ export interface ExtractRequest {
355
+ /** The file name — its extension helps tell office formats apart. */
356
+ name?: string;
357
+ /** The client's guess at the type (e.g. `pdf`, `docx`); the bytes decide. */
358
+ type?: string;
359
+ /** The whole file, base64. At most 64 MB decoded. */
360
+ data?: string;
361
+ /** The `hash` an open call returned. */
362
+ hash?: string;
363
+ /** The page to read, 1-based. */
364
+ page?: number;
365
+ /** Refused before parsing if the worker's record predicts it cannot be met. */
366
+ budgetMs?: number;
367
+ }
368
+ export interface ExtractResponse {
369
+ /** SHA-256 of the bytes — the document's identity for page calls. */
370
+ hash: string;
371
+ /** What the bytes are: pdf, docx, xlsx, pptx, odt, ods, odp, md, txt, csv, html. */
372
+ type: string;
373
+ pages: number;
374
+ /** The document's own title, when it declares one; else empty. */
375
+ title?: string;
376
+ /** A PDF with no text layer: its pages are empty and need OCR, which this does not do. */
377
+ scanned?: boolean;
378
+ /** Present on a page call. */
379
+ page?: number;
380
+ /** The page's text, on a page call. May be empty. */
381
+ text?: string;
382
+ /** `chatpanel-extract`. */
383
+ provider: string;
384
+ ms: number;
385
+ }
386
+ export interface ReadRequest {
387
+ /** Absolute http(s) URL of a public page. */
388
+ url: string;
389
+ format?: "markdown" | "text";
390
+ /** Cut at a section boundary near this length; `truncated` says so. */
391
+ maxChars?: number;
392
+ /** A search snippet to stand in for the content when the page cannot be read. */
393
+ snippet?: string;
394
+ /** One of the providers `GET /v1/capabilities` lists for `read`; 404 otherwise. */
395
+ provider?: string;
396
+ /** Refused before fetching if the provider's record predicts it cannot be met. */
397
+ budgetMs?: number;
398
+ }
399
+ export interface ReadSection {
400
+ /** The page's own heading id when it has one, else a slug — cite as `url#id`. */
401
+ id: string;
402
+ heading: string;
403
+ level: number;
404
+ /** Character offset of the heading line into the content. */
405
+ offset: number;
406
+ }
407
+ export interface ReadRestriction {
408
+ /** `robots` and `tdm` come only from a hosted (crawler) provider; on the user's machine the reader is a user agent. */
409
+ reason: "login" | "paywall" | "rate_limited" | "robots" | "tdm";
410
+ detail?: string;
411
+ }
412
+ export interface ReadResponse {
413
+ /** Where to CITE the page: the same-origin canonical, else where the fetch landed. Fragments dropped. */
414
+ url: string;
415
+ /** The URL that was asked for. */
416
+ requested?: string;
417
+ title: string;
418
+ author?: string;
419
+ /** As the page declared it (ISO date or datetime when it gave one). */
420
+ published?: string;
421
+ /** The hostname of `url`. */
422
+ site?: string;
423
+ lang?: string;
424
+ format: "markdown" | "text";
425
+ /** The content, when `format` is markdown. */
426
+ markdown?: string;
427
+ /** The content, when `format` is text. */
428
+ text?: string;
429
+ /** Length of the content field. */
430
+ chars: number;
431
+ truncated: boolean;
432
+ sections: Array<ReadSection>;
433
+ /** When the page was fetched (the cached copy's time on a cache hit). */
434
+ fetched?: string;
435
+ cached?: boolean;
436
+ provider: string;
437
+ ms: number;
438
+ /** Set when the page was not read as the article; the content is then the request's `snippet`. */
439
+ restricted?: ReadRestriction | null;
440
+ }
133
441
  export interface RedactionPreview {
134
442
  /** What the model would receive. */
135
443
  text: string;
@@ -219,6 +527,97 @@ export interface RecordsPage {
219
527
  newest?: number;
220
528
  [key: string]: unknown;
221
529
  }
530
+ /** One durable event in the CloudEvents 1.0 envelope. `seq`, `host`, `chatpanelv` are ChatPanel's extension attributes (the per-host order, the producer, the log schema version); `causes` is the comma-joined ids this event follows; `data` is the payload — refs and counts, never content. */
531
+ export interface CloudEvent {
532
+ specversion: "1.0";
533
+ id: string;
534
+ /** `urn:chatpanel:host:<host>` */
535
+ source: string;
536
+ /** `net.chatpanel.<family>.<kind>` */
537
+ type: string;
538
+ time: string;
539
+ datacontenttype?: string;
540
+ seq: number;
541
+ host: string;
542
+ causes?: string;
543
+ chatpanelv: number;
544
+ data?: AnyObject;
545
+ [key: string]: unknown;
546
+ }
547
+ /** `{ host: seq }` — the highest seq held per host. */
548
+ export interface EventsCursorMap {
549
+ [key: string]: number;
550
+ }
551
+ export interface PushEventsRequest {
552
+ events: Array<CloudEvent>;
553
+ }
554
+ export interface PushEventsResponse {
555
+ ok: boolean;
556
+ appended: number;
557
+ /** Events already held — a retry's share. */
558
+ duplicates: number;
559
+ rejected: Array<{
560
+ id?: string | null;
561
+ /** `CLOUDEVENT` (envelope), `SEQ` (moved backwards), or event.js's `SHAPE` / `TYPE` / `PAYLOAD` / `VERSION`. */
562
+ code: string;
563
+ message: string;
564
+ }>;
565
+ cursor: EventsCursorMap;
566
+ }
567
+ export interface EventsCursor {
568
+ ok: boolean;
569
+ cursor: EventsCursorMap;
570
+ count?: number;
571
+ }
572
+ export interface EventsPage {
573
+ ok: boolean;
574
+ events: Array<CloudEvent>;
575
+ /** Pass back as `cursor` for the next page. */
576
+ cursor: EventsCursorMap;
577
+ more: boolean;
578
+ }
579
+ export interface EventsStats {
580
+ ok: boolean;
581
+ stats: {
582
+ events?: number;
583
+ bytes?: number;
584
+ avgBytes?: number;
585
+ span?: {
586
+ [key: string]: unknown;
587
+ };
588
+ perDay?: {
589
+ [key: string]: unknown;
590
+ };
591
+ hosts?: {
592
+ [key: string]: unknown;
593
+ };
594
+ types?: {
595
+ [key: string]: number;
596
+ };
597
+ turns?: {
598
+ [key: string]: unknown;
599
+ };
600
+ /** `total`, `distinct`, `dedupHitRate` (percent). */
601
+ refs?: {
602
+ [key: string]: unknown;
603
+ };
604
+ toolCalls?: {
605
+ [key: string]: unknown;
606
+ };
607
+ [key: string]: unknown;
608
+ };
609
+ /** `eventsPerYear`, `bytesPerYear`, `daysToCap` at the observed rate; null before there is a span. */
610
+ year?: {
611
+ [key: string]: unknown;
612
+ } | null;
613
+ }
614
+ export interface EventsStreamEvent {
615
+ /** The SSE event name. */
616
+ event: "hello" | "cloudevent";
617
+ cursor?: EventsCursorMap;
618
+ count?: number;
619
+ version?: string;
620
+ }
222
621
  export interface PutRecordsRequest {
223
622
  /** Who is pushing — recorded on every record. */
224
623
  host?: string;
@@ -390,3 +789,52 @@ export interface Skill {
390
789
  prompt?: string;
391
790
  [key: string]: unknown;
392
791
  }
792
+ export interface Transcription {
793
+ text: string;
794
+ /** verbose_json only */
795
+ task?: "transcribe";
796
+ /** verbose_json only */
797
+ language?: string;
798
+ /** Seconds of audio; verbose_json only. */
799
+ duration?: number;
800
+ /** Who transcribed; verbose_json only. */
801
+ provider?: "embedded" | "remote" | "container";
802
+ took_ms?: number;
803
+ /** verbose_json only. */
804
+ segments?: Array<{
805
+ id: number;
806
+ start: number;
807
+ end: number;
808
+ text: string;
809
+ /** With diarize=true. */
810
+ speaker?: string;
811
+ }>;
812
+ }
813
+ export interface FusionList {
814
+ kinds: {
815
+ [key: string]: {
816
+ id?: string;
817
+ label?: string;
818
+ gain?: "recall" | "speed" | "reliability";
819
+ what?: string;
820
+ for?: Array<string>;
821
+ };
822
+ };
823
+ fusions: Array<{
824
+ id: string;
825
+ kind: "union" | "draft" | "fallback";
826
+ capability: string;
827
+ label?: string;
828
+ members: Array<string | {
829
+ id: string;
830
+ role?: "target" | "draft";
831
+ }>;
832
+ /** Read from the gateway’s state, not composed. */
833
+ derived?: boolean;
834
+ /** For a derived one: ner, or the runtime service. */
835
+ source?: string;
836
+ running?: boolean;
837
+ /** The fusion in a sentence. */
838
+ describe?: string;
839
+ }>;
840
+ }
package/package.json CHANGED
@@ -1,16 +1,25 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.11.0",
4
4
  "description": "Typed client for the local ChatPanel gateway — chat through the privacy proxy, search the user's history, read and write memory, follow team runs. Zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
- ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
10
13
  },
11
- "files": ["dist", "README.md", "LICENSE"],
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
12
19
  "sideEffects": false,
13
- "engines": { "node": ">=20" },
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
14
23
  "scripts": {
15
24
  "build": "tsc -p tsconfig.json",
16
25
  "test": "npm run build && node --test tests/*.test.mjs",
@@ -19,8 +28,20 @@
19
28
  "devDependencies": {
20
29
  "typescript": "^5.9.0"
21
30
  },
22
- "keywords": ["chatpanel", "sdk", "client", "gateway", "privacy", "llm", "agents"],
31
+ "keywords": [
32
+ "chatpanel",
33
+ "sdk",
34
+ "client",
35
+ "gateway",
36
+ "privacy",
37
+ "llm",
38
+ "agents"
39
+ ],
23
40
  "license": "Apache-2.0",
24
- "repository": { "type": "git", "url": "git+https://github.com/chatpanel/chatpanel-sdk.git", "directory": "sdk/typescript" },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/chatpanel/chatpanel-sdk.git",
44
+ "directory": "sdk/typescript"
45
+ },
25
46
  "homepage": "https://chatpanel.net"
26
47
  }