@chatpanel/sdk 0.1.0 → 0.10.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.
- package/dist/api.generated.d.ts +280 -1
- package/dist/api.generated.js +121 -1
- package/dist/types.generated.d.ts +446 -0
- package/package.json +27 -6
package/dist/api.generated.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/api.generated.js
CHANGED
|
@@ -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
|
}
|
|
@@ -130,6 +130,312 @@ export interface ChatCompletionChunk {
|
|
|
130
130
|
usage?: AnyObject;
|
|
131
131
|
[key: string]: unknown;
|
|
132
132
|
}
|
|
133
|
+
/** The runtime — Settings › Runtime's one document (docs/sandboxing.md S1). */
|
|
134
|
+
export interface RuntimeDocument {
|
|
135
|
+
/** the bridge's /health.sandbox: enabled, mode, runtime, reason?, extras, ownSessions, refused[] (names only), provisioned? (Windows) */
|
|
136
|
+
sandbox?: AnyObject;
|
|
137
|
+
processes?: {
|
|
138
|
+
/** 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) */
|
|
139
|
+
all?: Array<AnyObject>;
|
|
140
|
+
/** id, command (basename), pid, since, sandbox (the record), refused[] — never argv or env */
|
|
141
|
+
localMcp?: Array<AnyObject>;
|
|
142
|
+
warm?: AnyObject;
|
|
143
|
+
};
|
|
144
|
+
/** every container the engine has, running or not: name, image, state, status, ports[], ours (a chatpanel- name), engine (0.19.1) */
|
|
145
|
+
containers?: Array<AnyObject>;
|
|
146
|
+
/** { id, engine, host, at } newest first */
|
|
147
|
+
refused?: Array<AnyObject>;
|
|
148
|
+
bridge?: {
|
|
149
|
+
ok?: boolean;
|
|
150
|
+
version?: string;
|
|
151
|
+
};
|
|
152
|
+
/** podman/docker: { installed, version?, running?, machine? }; preferred; install? { command, url, note } */
|
|
153
|
+
engines?: AnyObject;
|
|
154
|
+
/** 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+). */
|
|
155
|
+
services?: AnyObject;
|
|
156
|
+
}
|
|
157
|
+
export interface RuntimeActionResult {
|
|
158
|
+
ok: boolean;
|
|
159
|
+
error?: string;
|
|
160
|
+
already?: boolean;
|
|
161
|
+
url?: string;
|
|
162
|
+
answering?: boolean;
|
|
163
|
+
install?: AnyObject;
|
|
164
|
+
/** The capabilities the service now stands behind (gateway 0.20+). */
|
|
165
|
+
provides?: Array<string>;
|
|
166
|
+
/** The model the container runs, on a start or a model pick (gateway 0.22+). */
|
|
167
|
+
model?: string;
|
|
168
|
+
/** A model pick re-created a running container. */
|
|
169
|
+
restarted?: boolean;
|
|
170
|
+
/** A model pick that fits but is tight for the engine's memory. */
|
|
171
|
+
note?: string;
|
|
172
|
+
}
|
|
173
|
+
export interface CapabilitiesDocument {
|
|
174
|
+
capabilities: Array<Capability>;
|
|
175
|
+
server: {
|
|
176
|
+
name: string;
|
|
177
|
+
version: string;
|
|
178
|
+
/** Where this provider's egress audit is served. */
|
|
179
|
+
audit?: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export interface Capability {
|
|
183
|
+
id: "detect" | "decide" | "rerank" | "embed" | "stt" | "tts" | "search" | "read";
|
|
184
|
+
/** The standard route for this capability on this provider. */
|
|
185
|
+
route: string;
|
|
186
|
+
/** Model capabilities (detect, decide, rerank, embed, stt, tts): the models offered. Required for those. */
|
|
187
|
+
models?: Array<string>;
|
|
188
|
+
/** Provider capabilities (search, read): the providers offered — a SearXNG, a SERP scraper, an extractor. Required for those. */
|
|
189
|
+
providers?: Array<string>;
|
|
190
|
+
/** One of `models`, or of `providers`. */
|
|
191
|
+
default?: string;
|
|
192
|
+
/** detect: the loaded model's label vocabulary, BIOES prefixes stripped. Empty until a model is loaded. */
|
|
193
|
+
labels?: Array<string>;
|
|
194
|
+
/** detect: the tokenizer's limit; null when effectively unbounded. */
|
|
195
|
+
maxTokens?: number | null;
|
|
196
|
+
requirements?: AnyObject;
|
|
197
|
+
stats?: CapabilityStats;
|
|
198
|
+
/** state (off | loading | downloading | ready | error | external), name, dtype, error… */
|
|
199
|
+
runtime?: AnyObject;
|
|
200
|
+
/** stt: the session route for live dictation. */
|
|
201
|
+
streaming?: string;
|
|
202
|
+
/** tts: the voices route. */
|
|
203
|
+
voices?: string;
|
|
204
|
+
}
|
|
205
|
+
export interface CapabilityStats {
|
|
206
|
+
calls: number;
|
|
207
|
+
p50Ms?: number;
|
|
208
|
+
p95Ms?: number;
|
|
209
|
+
maxMs?: number;
|
|
210
|
+
lastMs?: number;
|
|
211
|
+
charsPerSec?: number | null;
|
|
212
|
+
}
|
|
213
|
+
export interface DetectRequest {
|
|
214
|
+
text: string;
|
|
215
|
+
/** A model this provider lists; 404 otherwise. */
|
|
216
|
+
model?: string;
|
|
217
|
+
/** Keep only these of the model's labels. */
|
|
218
|
+
labels?: Array<string>;
|
|
219
|
+
/** Refused before running if the provider's record predicts it cannot be met. */
|
|
220
|
+
budgetMs?: number;
|
|
221
|
+
}
|
|
222
|
+
export interface DetectedEntity {
|
|
223
|
+
value: string;
|
|
224
|
+
/** The model's own label. */
|
|
225
|
+
type: string;
|
|
226
|
+
/** Character offset into the request text. */
|
|
227
|
+
start: number;
|
|
228
|
+
end: number;
|
|
229
|
+
score: number;
|
|
230
|
+
}
|
|
231
|
+
export interface DetectResponse {
|
|
232
|
+
entities: Array<DetectedEntity>;
|
|
233
|
+
model: string;
|
|
234
|
+
ms: number;
|
|
235
|
+
runtime?: AnyObject;
|
|
236
|
+
}
|
|
237
|
+
export interface RerankRequest {
|
|
238
|
+
query: string;
|
|
239
|
+
documents: Array<string>;
|
|
240
|
+
/** Return only the best this many. */
|
|
241
|
+
top_n?: number;
|
|
242
|
+
/** The model this provider serves; 404 otherwise. */
|
|
243
|
+
model?: string;
|
|
244
|
+
/** Refused before dialling if the gateway's record predicts it cannot be met. */
|
|
245
|
+
budgetMs?: number;
|
|
246
|
+
}
|
|
247
|
+
export interface RerankResult {
|
|
248
|
+
/** Into the request's documents. */
|
|
249
|
+
index: number;
|
|
250
|
+
relevance_score: number;
|
|
251
|
+
}
|
|
252
|
+
export interface RerankResponse {
|
|
253
|
+
/** Distinct indexes, best first; at most top_n. */
|
|
254
|
+
results: Array<RerankResult>;
|
|
255
|
+
model: string;
|
|
256
|
+
ms: number;
|
|
257
|
+
}
|
|
258
|
+
export interface DecideOption {
|
|
259
|
+
value: string;
|
|
260
|
+
/** What the option means — travels to the model as its criterion. */
|
|
261
|
+
describe?: string;
|
|
262
|
+
}
|
|
263
|
+
export interface DecideQuestion {
|
|
264
|
+
type: "choice" | "score" | "noul";
|
|
265
|
+
instructions: string;
|
|
266
|
+
/** choice: the values to pick from; score: the rubric, in order. A noul has none. */
|
|
267
|
+
options?: Array<string | DecideOption>;
|
|
268
|
+
}
|
|
269
|
+
export interface DecideRequest {
|
|
270
|
+
/** The text judged. */
|
|
271
|
+
state: string;
|
|
272
|
+
/** Keyed by identifier ([A-Za-z_][A-Za-z0-9_]*). */
|
|
273
|
+
questions: {
|
|
274
|
+
[key: string]: DecideQuestion;
|
|
275
|
+
};
|
|
276
|
+
/** The model this provider serves; 404 otherwise. */
|
|
277
|
+
model?: string;
|
|
278
|
+
budgetMs?: number;
|
|
279
|
+
}
|
|
280
|
+
export interface DecideAnswerOption {
|
|
281
|
+
/** A string (choice, score rubric entry) or a boolean (noul). */
|
|
282
|
+
value: unknown;
|
|
283
|
+
p: number;
|
|
284
|
+
}
|
|
285
|
+
export interface DecideAnswer {
|
|
286
|
+
/** choice: the option picked; score: a number on the rubric; noul: a boolean. */
|
|
287
|
+
value: unknown;
|
|
288
|
+
/** The probability of `value` — read it as one only when the response says `calibrated`. */
|
|
289
|
+
p: number;
|
|
290
|
+
/** The whole distribution. */
|
|
291
|
+
options: Array<DecideAnswerOption>;
|
|
292
|
+
/** The provider's own confidence, when it reports one. */
|
|
293
|
+
confidence?: number;
|
|
294
|
+
}
|
|
295
|
+
export interface DecideResponse {
|
|
296
|
+
/** One per question asked, under the same key. */
|
|
297
|
+
answers: {
|
|
298
|
+
[key: string]: DecideAnswer;
|
|
299
|
+
};
|
|
300
|
+
model: string;
|
|
301
|
+
ms: number;
|
|
302
|
+
/** Whether `p` is a calibrated probability. false for a zero-shot NLI concentration. */
|
|
303
|
+
calibrated?: boolean;
|
|
304
|
+
}
|
|
305
|
+
export interface WebSearchRequest {
|
|
306
|
+
q: string;
|
|
307
|
+
limit?: number;
|
|
308
|
+
/** en or en-US; honoured by SearXNG. */
|
|
309
|
+
lang?: string;
|
|
310
|
+
/** A hostname — the site: operator. */
|
|
311
|
+
site?: string;
|
|
312
|
+
/** Honoured by SearXNG (time_range); week maps to month. */
|
|
313
|
+
freshness?: "day" | "week" | "month" | "year";
|
|
314
|
+
/** Read the top N results in this request. */
|
|
315
|
+
read?: number;
|
|
316
|
+
/** One of the providers `GET /v1/capabilities` lists for `search`; 404 otherwise. */
|
|
317
|
+
provider?: string;
|
|
318
|
+
budgetMs?: number;
|
|
319
|
+
}
|
|
320
|
+
export interface WebSearchResult {
|
|
321
|
+
rank: number;
|
|
322
|
+
url: string;
|
|
323
|
+
title: string;
|
|
324
|
+
snippet: string;
|
|
325
|
+
/** The engine that produced it (SearXNG: the first of `engines`; serp: the results page asked). */
|
|
326
|
+
engine?: string;
|
|
327
|
+
/** SearXNG: every engine that returned it. */
|
|
328
|
+
engines?: Array<string>;
|
|
329
|
+
/** SearXNG's fused score. */
|
|
330
|
+
score?: number;
|
|
331
|
+
publishedDate?: string;
|
|
332
|
+
/** Present for the top `read` results. */
|
|
333
|
+
read?: ReadResponse;
|
|
334
|
+
}
|
|
335
|
+
export interface WebSearchResponse {
|
|
336
|
+
results: Array<WebSearchResult>;
|
|
337
|
+
/** SearXNG's direct answers, when it had any. */
|
|
338
|
+
answers?: Array<string>;
|
|
339
|
+
suggestions?: Array<string>;
|
|
340
|
+
/** What was actually asked. */
|
|
341
|
+
engines?: Array<string>;
|
|
342
|
+
/** SearXNG engines that did not answer. */
|
|
343
|
+
unresponsive?: Array<string>;
|
|
344
|
+
/** Layer-1 redaction removed something from the query. */
|
|
345
|
+
redacted?: boolean;
|
|
346
|
+
/** The query as sent, when `redacted`. */
|
|
347
|
+
query?: string;
|
|
348
|
+
provider: string;
|
|
349
|
+
ms: number;
|
|
350
|
+
}
|
|
351
|
+
/** Either `name` + `data` (open a document) or `hash` + `page` (read one page of an open document). */
|
|
352
|
+
export interface ExtractRequest {
|
|
353
|
+
/** The file name — its extension helps tell office formats apart. */
|
|
354
|
+
name?: string;
|
|
355
|
+
/** The client's guess at the type (e.g. `pdf`, `docx`); the bytes decide. */
|
|
356
|
+
type?: string;
|
|
357
|
+
/** The whole file, base64. At most 64 MB decoded. */
|
|
358
|
+
data?: string;
|
|
359
|
+
/** The `hash` an open call returned. */
|
|
360
|
+
hash?: string;
|
|
361
|
+
/** The page to read, 1-based. */
|
|
362
|
+
page?: number;
|
|
363
|
+
/** Refused before parsing if the worker's record predicts it cannot be met. */
|
|
364
|
+
budgetMs?: number;
|
|
365
|
+
}
|
|
366
|
+
export interface ExtractResponse {
|
|
367
|
+
/** SHA-256 of the bytes — the document's identity for page calls. */
|
|
368
|
+
hash: string;
|
|
369
|
+
/** What the bytes are: pdf, docx, xlsx, pptx, odt, ods, odp, md, txt, csv, html. */
|
|
370
|
+
type: string;
|
|
371
|
+
pages: number;
|
|
372
|
+
/** The document's own title, when it declares one; else empty. */
|
|
373
|
+
title?: string;
|
|
374
|
+
/** A PDF with no text layer: its pages are empty and need OCR, which this does not do. */
|
|
375
|
+
scanned?: boolean;
|
|
376
|
+
/** Present on a page call. */
|
|
377
|
+
page?: number;
|
|
378
|
+
/** The page's text, on a page call. May be empty. */
|
|
379
|
+
text?: string;
|
|
380
|
+
/** `chatpanel-extract`. */
|
|
381
|
+
provider: string;
|
|
382
|
+
ms: number;
|
|
383
|
+
}
|
|
384
|
+
export interface ReadRequest {
|
|
385
|
+
/** Absolute http(s) URL of a public page. */
|
|
386
|
+
url: string;
|
|
387
|
+
format?: "markdown" | "text";
|
|
388
|
+
/** Cut at a section boundary near this length; `truncated` says so. */
|
|
389
|
+
maxChars?: number;
|
|
390
|
+
/** A search snippet to stand in for the content when the page cannot be read. */
|
|
391
|
+
snippet?: string;
|
|
392
|
+
/** One of the providers `GET /v1/capabilities` lists for `read`; 404 otherwise. */
|
|
393
|
+
provider?: string;
|
|
394
|
+
/** Refused before fetching if the provider's record predicts it cannot be met. */
|
|
395
|
+
budgetMs?: number;
|
|
396
|
+
}
|
|
397
|
+
export interface ReadSection {
|
|
398
|
+
/** The page's own heading id when it has one, else a slug — cite as `url#id`. */
|
|
399
|
+
id: string;
|
|
400
|
+
heading: string;
|
|
401
|
+
level: number;
|
|
402
|
+
/** Character offset of the heading line into the content. */
|
|
403
|
+
offset: number;
|
|
404
|
+
}
|
|
405
|
+
export interface ReadRestriction {
|
|
406
|
+
/** `robots` and `tdm` come only from a hosted (crawler) provider; on the user's machine the reader is a user agent. */
|
|
407
|
+
reason: "login" | "paywall" | "rate_limited" | "robots" | "tdm";
|
|
408
|
+
detail?: string;
|
|
409
|
+
}
|
|
410
|
+
export interface ReadResponse {
|
|
411
|
+
/** Where to CITE the page: the same-origin canonical, else where the fetch landed. Fragments dropped. */
|
|
412
|
+
url: string;
|
|
413
|
+
/** The URL that was asked for. */
|
|
414
|
+
requested?: string;
|
|
415
|
+
title: string;
|
|
416
|
+
author?: string;
|
|
417
|
+
/** As the page declared it (ISO date or datetime when it gave one). */
|
|
418
|
+
published?: string;
|
|
419
|
+
/** The hostname of `url`. */
|
|
420
|
+
site?: string;
|
|
421
|
+
lang?: string;
|
|
422
|
+
format: "markdown" | "text";
|
|
423
|
+
/** The content, when `format` is markdown. */
|
|
424
|
+
markdown?: string;
|
|
425
|
+
/** The content, when `format` is text. */
|
|
426
|
+
text?: string;
|
|
427
|
+
/** Length of the content field. */
|
|
428
|
+
chars: number;
|
|
429
|
+
truncated: boolean;
|
|
430
|
+
sections: Array<ReadSection>;
|
|
431
|
+
/** When the page was fetched (the cached copy's time on a cache hit). */
|
|
432
|
+
fetched?: string;
|
|
433
|
+
cached?: boolean;
|
|
434
|
+
provider: string;
|
|
435
|
+
ms: number;
|
|
436
|
+
/** Set when the page was not read as the article; the content is then the request's `snippet`. */
|
|
437
|
+
restricted?: ReadRestriction | null;
|
|
438
|
+
}
|
|
133
439
|
export interface RedactionPreview {
|
|
134
440
|
/** What the model would receive. */
|
|
135
441
|
text: string;
|
|
@@ -219,6 +525,97 @@ export interface RecordsPage {
|
|
|
219
525
|
newest?: number;
|
|
220
526
|
[key: string]: unknown;
|
|
221
527
|
}
|
|
528
|
+
/** 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. */
|
|
529
|
+
export interface CloudEvent {
|
|
530
|
+
specversion: "1.0";
|
|
531
|
+
id: string;
|
|
532
|
+
/** `urn:chatpanel:host:<host>` */
|
|
533
|
+
source: string;
|
|
534
|
+
/** `net.chatpanel.<family>.<kind>` */
|
|
535
|
+
type: string;
|
|
536
|
+
time: string;
|
|
537
|
+
datacontenttype?: string;
|
|
538
|
+
seq: number;
|
|
539
|
+
host: string;
|
|
540
|
+
causes?: string;
|
|
541
|
+
chatpanelv: number;
|
|
542
|
+
data?: AnyObject;
|
|
543
|
+
[key: string]: unknown;
|
|
544
|
+
}
|
|
545
|
+
/** `{ host: seq }` — the highest seq held per host. */
|
|
546
|
+
export interface EventsCursorMap {
|
|
547
|
+
[key: string]: number;
|
|
548
|
+
}
|
|
549
|
+
export interface PushEventsRequest {
|
|
550
|
+
events: Array<CloudEvent>;
|
|
551
|
+
}
|
|
552
|
+
export interface PushEventsResponse {
|
|
553
|
+
ok: boolean;
|
|
554
|
+
appended: number;
|
|
555
|
+
/** Events already held — a retry's share. */
|
|
556
|
+
duplicates: number;
|
|
557
|
+
rejected: Array<{
|
|
558
|
+
id?: string | null;
|
|
559
|
+
/** `CLOUDEVENT` (envelope), `SEQ` (moved backwards), or event.js's `SHAPE` / `TYPE` / `PAYLOAD` / `VERSION`. */
|
|
560
|
+
code: string;
|
|
561
|
+
message: string;
|
|
562
|
+
}>;
|
|
563
|
+
cursor: EventsCursorMap;
|
|
564
|
+
}
|
|
565
|
+
export interface EventsCursor {
|
|
566
|
+
ok: boolean;
|
|
567
|
+
cursor: EventsCursorMap;
|
|
568
|
+
count?: number;
|
|
569
|
+
}
|
|
570
|
+
export interface EventsPage {
|
|
571
|
+
ok: boolean;
|
|
572
|
+
events: Array<CloudEvent>;
|
|
573
|
+
/** Pass back as `cursor` for the next page. */
|
|
574
|
+
cursor: EventsCursorMap;
|
|
575
|
+
more: boolean;
|
|
576
|
+
}
|
|
577
|
+
export interface EventsStats {
|
|
578
|
+
ok: boolean;
|
|
579
|
+
stats: {
|
|
580
|
+
events?: number;
|
|
581
|
+
bytes?: number;
|
|
582
|
+
avgBytes?: number;
|
|
583
|
+
span?: {
|
|
584
|
+
[key: string]: unknown;
|
|
585
|
+
};
|
|
586
|
+
perDay?: {
|
|
587
|
+
[key: string]: unknown;
|
|
588
|
+
};
|
|
589
|
+
hosts?: {
|
|
590
|
+
[key: string]: unknown;
|
|
591
|
+
};
|
|
592
|
+
types?: {
|
|
593
|
+
[key: string]: number;
|
|
594
|
+
};
|
|
595
|
+
turns?: {
|
|
596
|
+
[key: string]: unknown;
|
|
597
|
+
};
|
|
598
|
+
/** `total`, `distinct`, `dedupHitRate` (percent). */
|
|
599
|
+
refs?: {
|
|
600
|
+
[key: string]: unknown;
|
|
601
|
+
};
|
|
602
|
+
toolCalls?: {
|
|
603
|
+
[key: string]: unknown;
|
|
604
|
+
};
|
|
605
|
+
[key: string]: unknown;
|
|
606
|
+
};
|
|
607
|
+
/** `eventsPerYear`, `bytesPerYear`, `daysToCap` at the observed rate; null before there is a span. */
|
|
608
|
+
year?: {
|
|
609
|
+
[key: string]: unknown;
|
|
610
|
+
} | null;
|
|
611
|
+
}
|
|
612
|
+
export interface EventsStreamEvent {
|
|
613
|
+
/** The SSE event name. */
|
|
614
|
+
event: "hello" | "cloudevent";
|
|
615
|
+
cursor?: EventsCursorMap;
|
|
616
|
+
count?: number;
|
|
617
|
+
version?: string;
|
|
618
|
+
}
|
|
222
619
|
export interface PutRecordsRequest {
|
|
223
620
|
/** Who is pushing — recorded on every record. */
|
|
224
621
|
host?: string;
|
|
@@ -390,3 +787,52 @@ export interface Skill {
|
|
|
390
787
|
prompt?: string;
|
|
391
788
|
[key: string]: unknown;
|
|
392
789
|
}
|
|
790
|
+
export interface Transcription {
|
|
791
|
+
text: string;
|
|
792
|
+
/** verbose_json only */
|
|
793
|
+
task?: "transcribe";
|
|
794
|
+
/** verbose_json only */
|
|
795
|
+
language?: string;
|
|
796
|
+
/** Seconds of audio; verbose_json only. */
|
|
797
|
+
duration?: number;
|
|
798
|
+
/** Who transcribed; verbose_json only. */
|
|
799
|
+
provider?: "embedded" | "remote" | "container";
|
|
800
|
+
took_ms?: number;
|
|
801
|
+
/** verbose_json only. */
|
|
802
|
+
segments?: Array<{
|
|
803
|
+
id: number;
|
|
804
|
+
start: number;
|
|
805
|
+
end: number;
|
|
806
|
+
text: string;
|
|
807
|
+
/** With diarize=true. */
|
|
808
|
+
speaker?: string;
|
|
809
|
+
}>;
|
|
810
|
+
}
|
|
811
|
+
export interface FusionList {
|
|
812
|
+
kinds: {
|
|
813
|
+
[key: string]: {
|
|
814
|
+
id?: string;
|
|
815
|
+
label?: string;
|
|
816
|
+
gain?: "recall" | "speed" | "reliability";
|
|
817
|
+
what?: string;
|
|
818
|
+
for?: Array<string>;
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
fusions: Array<{
|
|
822
|
+
id: string;
|
|
823
|
+
kind: "union" | "draft" | "fallback";
|
|
824
|
+
capability: string;
|
|
825
|
+
label?: string;
|
|
826
|
+
members: Array<string | {
|
|
827
|
+
id: string;
|
|
828
|
+
role?: "target" | "draft";
|
|
829
|
+
}>;
|
|
830
|
+
/** Read from the gateway’s state, not composed. */
|
|
831
|
+
derived?: boolean;
|
|
832
|
+
/** For a derived one: ner, or the runtime service. */
|
|
833
|
+
source?: string;
|
|
834
|
+
running?: boolean;
|
|
835
|
+
/** The fusion in a sentence. */
|
|
836
|
+
describe?: string;
|
|
837
|
+
}>;
|
|
838
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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
|
-
".": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
10
13
|
},
|
|
11
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
12
19
|
"sideEffects": false,
|
|
13
|
-
"engines": {
|
|
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": [
|
|
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": {
|
|
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
|
}
|