@chatpanel/sdk 0.24.0 → 0.27.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.
@@ -202,6 +202,16 @@ export declare const OPERATIONS: {
202
202
  readonly pathParams: readonly [];
203
203
  readonly queryParams: readonly [];
204
204
  };
205
+ readonly "events.delete": {
206
+ readonly id: "events.delete";
207
+ readonly method: "DELETE";
208
+ readonly path: "/v1/events";
209
+ readonly auth: "token";
210
+ readonly since: "0.105.0";
211
+ readonly stream: null;
212
+ readonly pathParams: readonly [];
213
+ readonly queryParams: readonly ["host", "all", "force"];
214
+ };
205
215
  readonly "events.cursor": {
206
216
  readonly id: "events.cursor";
207
217
  readonly method: "GET";
@@ -732,6 +742,26 @@ export declare const OPERATIONS: {
732
742
  readonly pathParams: readonly ["q"];
733
743
  readonly queryParams: readonly ["read"];
734
744
  };
745
+ readonly "capabilities.embed": {
746
+ readonly id: "capabilities.embed";
747
+ readonly method: "POST";
748
+ readonly path: "/v1/embeddings";
749
+ readonly auth: "open";
750
+ readonly since: "0.101.0";
751
+ readonly stream: null;
752
+ readonly pathParams: readonly [];
753
+ readonly queryParams: readonly [];
754
+ };
755
+ readonly "retrieval.extractContext": {
756
+ readonly id: "retrieval.extractContext";
757
+ readonly method: "POST";
758
+ readonly path: "/v1/extract/context";
759
+ readonly auth: "open";
760
+ readonly since: "0.102.0";
761
+ readonly stream: null;
762
+ readonly pathParams: readonly [];
763
+ readonly queryParams: readonly [];
764
+ };
735
765
  readonly "retrieval.extract": {
736
766
  readonly id: "retrieval.extract";
737
767
  readonly method: "POST";
@@ -742,6 +772,196 @@ export declare const OPERATIONS: {
742
772
  readonly pathParams: readonly [];
743
773
  readonly queryParams: readonly [];
744
774
  };
775
+ readonly "knowledge.list": {
776
+ readonly id: "knowledge.list";
777
+ readonly method: "GET";
778
+ readonly path: "/v1/kb";
779
+ readonly auth: "open";
780
+ readonly since: "0.101.0";
781
+ readonly stream: null;
782
+ readonly pathParams: readonly [];
783
+ readonly queryParams: readonly [];
784
+ };
785
+ readonly "knowledge.create": {
786
+ readonly id: "knowledge.create";
787
+ readonly method: "POST";
788
+ readonly path: "/v1/kb";
789
+ readonly auth: "open";
790
+ readonly since: "0.101.0";
791
+ readonly stream: null;
792
+ readonly pathParams: readonly [];
793
+ readonly queryParams: readonly [];
794
+ };
795
+ readonly "knowledge.status": {
796
+ readonly id: "knowledge.status";
797
+ readonly method: "GET";
798
+ readonly path: "/v1/kb/{id}";
799
+ readonly auth: "open";
800
+ readonly since: "0.101.0";
801
+ readonly stream: null;
802
+ readonly pathParams: readonly ["id"];
803
+ readonly queryParams: readonly [];
804
+ };
805
+ readonly "knowledge.delete": {
806
+ readonly id: "knowledge.delete";
807
+ readonly method: "DELETE";
808
+ readonly path: "/v1/kb/{id}";
809
+ readonly auth: "token";
810
+ readonly since: "0.101.0";
811
+ readonly stream: null;
812
+ readonly pathParams: readonly ["id"];
813
+ readonly queryParams: readonly [];
814
+ };
815
+ readonly "knowledge.documents": {
816
+ readonly id: "knowledge.documents";
817
+ readonly method: "GET";
818
+ readonly path: "/v1/kb/{id}/documents";
819
+ readonly auth: "open";
820
+ readonly since: "0.101.0";
821
+ readonly stream: null;
822
+ readonly pathParams: readonly ["id"];
823
+ readonly queryParams: readonly [];
824
+ };
825
+ readonly "knowledge.add": {
826
+ readonly id: "knowledge.add";
827
+ readonly method: "POST";
828
+ readonly path: "/v1/kb/{id}/documents";
829
+ readonly auth: "open";
830
+ readonly since: "0.101.0";
831
+ readonly stream: null;
832
+ readonly pathParams: readonly ["id"];
833
+ readonly queryParams: readonly [];
834
+ };
835
+ readonly "knowledge.page": {
836
+ readonly id: "knowledge.page";
837
+ readonly method: "GET";
838
+ readonly path: "/v1/kb/{id}/documents/{doc}";
839
+ readonly auth: "open";
840
+ readonly since: "0.101.0";
841
+ readonly stream: null;
842
+ readonly pathParams: readonly ["id", "doc"];
843
+ readonly queryParams: readonly ["page"];
844
+ };
845
+ readonly "knowledge.removeDocument": {
846
+ readonly id: "knowledge.removeDocument";
847
+ readonly method: "DELETE";
848
+ readonly path: "/v1/kb/{id}/documents/{doc}";
849
+ readonly auth: "token";
850
+ readonly since: "0.101.0";
851
+ readonly stream: null;
852
+ readonly pathParams: readonly ["id", "doc"];
853
+ readonly queryParams: readonly [];
854
+ };
855
+ readonly "knowledge.passage": {
856
+ readonly id: "knowledge.passage";
857
+ readonly method: "GET";
858
+ readonly path: "/v1/kb/{id}/passages/{passage}";
859
+ readonly auth: "open";
860
+ readonly since: "0.101.0";
861
+ readonly stream: null;
862
+ readonly pathParams: readonly ["id", "passage"];
863
+ readonly queryParams: readonly [];
864
+ };
865
+ readonly "knowledge.outline": {
866
+ readonly id: "knowledge.outline";
867
+ readonly method: "GET";
868
+ readonly path: "/v1/kb/{id}/outline";
869
+ readonly auth: "open";
870
+ readonly since: "0.101.0";
871
+ readonly stream: null;
872
+ readonly pathParams: readonly ["id"];
873
+ readonly queryParams: readonly ["doc"];
874
+ };
875
+ readonly "knowledge.search": {
876
+ readonly id: "knowledge.search";
877
+ readonly method: "POST";
878
+ readonly path: "/v1/kb/{id}/search";
879
+ readonly auth: "open";
880
+ readonly since: "0.101.0";
881
+ readonly stream: null;
882
+ readonly pathParams: readonly ["id"];
883
+ readonly queryParams: readonly [];
884
+ };
885
+ readonly "knowledge.research": {
886
+ readonly id: "knowledge.research";
887
+ readonly method: "POST";
888
+ readonly path: "/v1/kb/{id}/research";
889
+ readonly auth: "open";
890
+ readonly since: "0.101.0";
891
+ readonly stream: null;
892
+ readonly pathParams: readonly ["id"];
893
+ readonly queryParams: readonly [];
894
+ };
895
+ readonly "knowledge.graph": {
896
+ readonly id: "knowledge.graph";
897
+ readonly method: "POST";
898
+ readonly path: "/v1/kb/{id}/graph";
899
+ readonly auth: "open";
900
+ readonly since: "0.101.0";
901
+ readonly stream: null;
902
+ readonly pathParams: readonly ["id"];
903
+ readonly queryParams: readonly [];
904
+ };
905
+ readonly "knowledge.notes": {
906
+ readonly id: "knowledge.notes";
907
+ readonly method: "GET";
908
+ readonly path: "/v1/kb/{id}/notes";
909
+ readonly auth: "open";
910
+ readonly since: "0.101.0";
911
+ readonly stream: null;
912
+ readonly pathParams: readonly ["id"];
913
+ readonly queryParams: readonly [];
914
+ };
915
+ readonly "knowledge.note": {
916
+ readonly id: "knowledge.note";
917
+ readonly method: "POST";
918
+ readonly path: "/v1/kb/{id}/notes";
919
+ readonly auth: "open";
920
+ readonly since: "0.101.0";
921
+ readonly stream: null;
922
+ readonly pathParams: readonly ["id"];
923
+ readonly queryParams: readonly [];
924
+ };
925
+ readonly "knowledge.noteStatus": {
926
+ readonly id: "knowledge.noteStatus";
927
+ readonly method: "POST";
928
+ readonly path: "/v1/kb/{id}/notes/{note}";
929
+ readonly auth: "token";
930
+ readonly since: "0.101.0";
931
+ readonly stream: null;
932
+ readonly pathParams: readonly ["id", "note"];
933
+ readonly queryParams: readonly [];
934
+ };
935
+ readonly "knowledge.access": {
936
+ readonly id: "knowledge.access";
937
+ readonly method: "GET";
938
+ readonly path: "/v1/kb/{id}/access";
939
+ readonly auth: "open";
940
+ readonly since: "0.101.1";
941
+ readonly stream: null;
942
+ readonly pathParams: readonly ["id"];
943
+ readonly queryParams: readonly [];
944
+ };
945
+ readonly "knowledge.setAccess": {
946
+ readonly id: "knowledge.setAccess";
947
+ readonly method: "POST";
948
+ readonly path: "/v1/kb/{id}/access";
949
+ readonly auth: "token";
950
+ readonly since: "0.101.1";
951
+ readonly stream: null;
952
+ readonly pathParams: readonly ["id"];
953
+ readonly queryParams: readonly [];
954
+ };
955
+ readonly "knowledge.embed": {
956
+ readonly id: "knowledge.embed";
957
+ readonly method: "POST";
958
+ readonly path: "/v1/kb/{id}/embed";
959
+ readonly auth: "open";
960
+ readonly since: "0.101.0";
961
+ readonly stream: null;
962
+ readonly pathParams: readonly ["id"];
963
+ readonly queryParams: readonly [];
964
+ };
745
965
  readonly "retrieval.read": {
746
966
  readonly id: "retrieval.read";
747
967
  readonly method: "POST";
@@ -1173,6 +1393,12 @@ export declare class EventsApi {
1173
1393
  }, opts?: RequestOptions): Promise<T.EventsPage>;
1174
1394
  /** 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+. */
1175
1395
  push(body: T.PushEventsRequest, opts?: RequestOptions): Promise<T.PushEventsResponse>;
1396
+ /** Delete one host's slice of the merged log, or the whole log — only with `force=1`. A client's "Clear activity" reaching the copy held here. Name exactly one of `host` or `all=1`. Without `force=1` nothing is deleted: the answer is 409 `confirm_required` with `wouldDelete`, so leaving the flag off (or sending `force=0`) is a dry run, never a delete. The host's cursor entry goes with its events, so its next push starts afresh. A tailing stream gets a `deleted` frame. Idempotent: a host with nothing left deletes 0. — Requires the gateway token. Gateway 0.105.0+. */
1397
+ delete(query?: {
1398
+ host?: string;
1399
+ all?: "1" | "true" | "yes";
1400
+ force?: "1" | "true" | "yes";
1401
+ }, opts?: RequestOptions): Promise<T.EventsDeleted>;
1176
1402
  /** The gateway's highest `seq` per host — what a client asks for before it pushes. — Requires the gateway token. Gateway 0.24.0+. */
1177
1403
  cursor(opts?: RequestOptions): Promise<T.EventsCursor>;
1178
1404
  /** 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+. */
@@ -1503,6 +1729,8 @@ export declare class CapabilitiesApi {
1503
1729
  rerank(body: T.RerankRequest, opts?: RequestOptions): Promise<T.RerankResponse>;
1504
1730
  /** 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+. */
1505
1731
  decide(body: T.DecideRequest, opts?: RequestOptions): Promise<T.DecideResponse>;
1732
+ /** One unit vector per input — OpenAI-shaped embeddings, in the gateway's own process by default. The `embed` capability (docs/capability-endpoints.md C4), served since 0.101.0 by the in-process embedder (`Xenova/multilingual-e5-small` by default, 384 dimensions, q8 on the ONNX runtime; `Xenova/all-MiniLM-L6-v2` as the lighter English-only pick) — or by the server `capabilities.embed` names, through its adapter. `input` is a string or up to 256 strings; `kind` says whether they are queries or passages (E5 prefixes each). The vectors are unit length, so cosine is a dot product. 503 `provider_warming` while the model downloads (the first call starts it; a caller is never held), 404 `no_provider` when it is turned off (`capabilities.embed.provider = none`), `budgetMs` refused from the record like every capability. The knowledge base (`/v1/kb`) uses this for its vector lane; it works on words and the graph until the model is on disk. — Gateway 0.101.0+. */
1733
+ embed(body: T.EmbedRequest, opts?: RequestOptions): Promise<T.EmbedResponse>;
1506
1734
  }
1507
1735
  /** 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). */
1508
1736
  export declare class RuntimeApi {
@@ -1555,6 +1783,8 @@ export declare class RetrievalApi {
1555
1783
  }>;
1556
1784
  trail?: T.SearchTrail;
1557
1785
  }>;
1786
+ /** The attached document(s) read FOR a question — one cited block to put before the question, as ChatPanel's own clients do. The turn pipeline's document stage as an API. Every ChatPanel client reads a file the person attached BEFORE a small model answers: whole when it fits the window's share of characters, else the pages that carry the question's words, each page cited, as one `prefetch` block placed before the question (a small model reads context first). A harness built on this SDK gets the same block here: send the question and the documents (the bytes, base64, or the `hash` of one `/v1/extract` already opened), and put `attachment.text` in the user message ahead of the question. `window` (tokens) sizes the share — a 4k on-device model gets a few thousand characters, a large window far more — or `budgetChars` sets it outright. `how` says whether the whole document went or pages were picked; `read` lists each document's pages, `skipped` the ones that could not be opened. A document with no text layer is named as a scan inside the block rather than guessed from. Parsed in the same worker as `/v1/extract`, on this machine; nothing leaves it. — Gateway 0.102.0+. */
1787
+ extractContext(body: T.ExtractContextRequest, opts?: RequestOptions): Promise<T.ExtractContextResponse>;
1558
1788
  /** 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+. */
1559
1789
  extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
1560
1790
  /** 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+. */
@@ -1571,6 +1801,53 @@ export declare class RetrievalApi {
1571
1801
  data: T.ReadResponse;
1572
1802
  }>;
1573
1803
  }
1804
+ /** Knowledge bases — the user's documents (PDFs, office files, folders, pages) indexed on this machine and searched by words, meaning and graph; researched by the harness loop; annotated over time (docs/knowledge-base.md). */
1805
+ export declare class KnowledgeApi {
1806
+ private readonly rt;
1807
+ constructor(rt: Runtime);
1808
+ /** The knowledge bases on this machine. Each base with its id, name, document count, vector count and model. Loads no passages. — Gateway 0.101.0+. */
1809
+ list(opts?: RequestOptions): Promise<T.KbList>;
1810
+ /** Create a knowledge base (or return the one with that id). A base is a folder under `~/.chatpanel/kb/<id>/` (manifest, passages, notes, vectors, a Markdown report) — a projection over the documents added to it, rebuildable from them. `embed: off` keeps it on words and the graph only. 201 when created, 200 with `existed` when the id was already there. — Gateway 0.101.0+. */
1811
+ create(body: T.KbCreateRequest, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1812
+ /** What a base holds — its documents, passages, notes, vectors, entities and connections. — Gateway 0.101.0+. */
1813
+ status(id: string, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1814
+ /** Delete a base and its folder. — Requires the gateway token. Gateway 0.101.0+. */
1815
+ delete(id: string, opts?: RequestOptions): Promise<T.KbOkResponse>;
1816
+ /** The documents in a base. — Gateway 0.101.0+. */
1817
+ documents(id: string, opts?: RequestOptions): Promise<T.KbDocuments>;
1818
+ /** Add a document — bytes, a path on this machine, a URL, or text — and index it. One of four sources: `name` + `data` (the file, base64, up to 64 MB — a PDF, DOCX, XLSX, PPTX, ODF, Markdown or text, parsed in the extract worker); `path` (a file or folder on this machine, walked with the same refusals the `files` tool applies — credential stores withheld and named, `node_modules` and hidden folders skipped, documents up to 64 MB; TOKEN-GATED: a path is a read on the machine, so it is 403 to a caller without the token or the extension origin); `url` (a public page through the `read` capability); `text`. The same bytes added again REPLACE the document. Passages are chunked by the document's own headings with page citations, indexed by words and in the graph, and embedded when the embedder's model is on disk (`embedded` says how many); the report is rewritten. — Gateway 0.101.0+. */
1819
+ add(id: string, body: T.KbAddRequest, opts?: RequestOptions): Promise<T.KbAddResponse>;
1820
+ /** One page of a document, from the index. — Gateway 0.101.0+. */
1821
+ page(id: string, doc: string, query?: {
1822
+ page?: number;
1823
+ }, opts?: RequestOptions): Promise<T.KbPage>;
1824
+ /** Remove a document, its passages and vectors (notes keep their text and lose the cite). — Requires the gateway token. Gateway 0.101.0+. */
1825
+ removeDocument(id: string, doc: string, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1826
+ /** One passage by id, with its citation. — Gateway 0.101.0+. */
1827
+ passage(id: string, passage: string, opts?: RequestOptions): Promise<T.KbPassage>;
1828
+ /** The table of contents a document's headings imply — every section once, with where it starts. — Gateway 0.101.0+. */
1829
+ outline(id: string, query?: {
1830
+ doc?: string;
1831
+ }, opts?: RequestOptions): Promise<T.KbOutline>;
1832
+ /** The passages that answer a question — words, meaning and graph fused, a reranker on top, each with its citation. The words in up to four query shapes (BM25), the meaning when the base has vectors (the query embedded by the same model), the graph's one-hop expansion of the best hits (a passage sharing a name or a section with a hit, and `via` says which), and the notes as their own lane — fused by Reciprocal Rank Fusion with the graph at half weight, then the gateway's reranker fused in (never substituted). Each result carries `lanes` (which found it), `scores` (each lane's own, comparable within one query) and `cite` as the model is told to write it (`[report.pdf p.12]`). `docs` scopes to documents; `queries` adds the caller's own phrasings. — Gateway 0.101.0+. */
1833
+ search(id: string, body: T.KbSearchRequest, opts?: RequestOptions): Promise<T.KbSearchResponse>;
1834
+ /** The bounded loop over a base — framed, searched, read, checked once, asked when ambiguous — as one cited block for a model. The harness's loop (events kb-research.js), not a model's tool calls: a whole-document ask ("what is this about") reads the outline and the opening of each section; a focused one searches, reads the best passages grouped by document in page order, and — with `model` (TOKEN-GATED: the check runs on this gateway's own chat route) — asks that model once whether what was read answers it, then searches once more for what it says is missing. When the hits split evenly across documents and the question names none, the answer is `ask` (which document?) instead of a guess; call again with `answer` to go on, or `ask: false` to never pause. `attachment` is the block a client attaches before the question (`kind: prefetch`), `null` when nothing matched beyond the plain statement. — Gateway 0.101.0+. */
1835
+ research(id: string, body: T.KbResearchRequest, opts?: RequestOptions): Promise<T.KbResearchResponse>;
1836
+ /** What connects to a node — its neighbours up to `hops` away — or the path between two. — Gateway 0.101.0+. */
1837
+ graph(id: string, body: T.KbGraphRequest, opts?: RequestOptions): Promise<T.KbGraphResponse>;
1838
+ /** The notes filed into a base. — Gateway 0.101.0+. */
1839
+ notes(id: string, opts?: RequestOptions): Promise<T.KbNotes>;
1840
+ /** File a note — a fact, a summary, a correction — cited to passages; proposed until accepted. How a base improves over time. A note is indexed and searched as its own lane and shown with its status; `status: accepted` is honoured only from a caller with the token (the person, or a client acting for them) — any other caller's note is filed as `proposed`. Unknown cites are dropped. — Gateway 0.101.0+. */
1841
+ note(id: string, body: T.KbNoteRequest, opts?: RequestOptions): Promise<T.KbNoteResponse>;
1842
+ /** Accept a proposed note, withdraw it to proposed, or remove it. — Requires the gateway token. Gateway 0.101.0+. */
1843
+ noteStatus(id: string, note: string, body: T.KbNoteStatusRequest, opts?: RequestOptions): Promise<T.KbNoteResponse>;
1844
+ /** Who may use a base — every agent, or the ones named. — Gateway 0.101.1+. */
1845
+ access(id: string, opts?: RequestOptions): Promise<T.KbAccessResponse>;
1846
+ /** Grant a base to every agent or to the ones named — the owner's act. Grants (docs/knowledge-base.md §3, "knowledge is granted like skills"): a caller with the token or the extension's origin is the owner and reaches every base; any other caller names itself (`X-ChatPanel-Agent: claude`, or `?agent=`) — the gateway's own MCP server sends the connected client's name — and reaches the bases whose `access.agents` is `all` (the default) or names it. `GET /v1/kb` lists only those; a base not granted reads as 404 to that caller. — Requires the gateway token. Gateway 0.101.1+. */
1847
+ setAccess(id: string, body: T.KbAccessRequest, opts?: RequestOptions): Promise<T.KbAccessResponse>;
1848
+ /** Embed every passage that has no vector yet, and say where the embedder stands. — Gateway 0.101.0+. */
1849
+ embed(id: string, body: Record<string, never>, opts?: RequestOptions): Promise<T.KbEmbedResponse>;
1850
+ }
1574
1851
  /** The model ledger — every engine's card. */
1575
1852
  export declare class EnginesApi {
1576
1853
  private readonly rt;
@@ -1732,6 +2009,7 @@ export declare function buildApi(rt: Runtime): {
1732
2009
  capabilities: CapabilitiesApi;
1733
2010
  runtime: RuntimeApi;
1734
2011
  retrieval: RetrievalApi;
2012
+ knowledge: KnowledgeApi;
1735
2013
  engines: EnginesApi;
1736
2014
  skills: SkillsApi;
1737
2015
  a2a: A2aApi;
@@ -20,6 +20,7 @@ export const OPERATIONS = {
20
20
  "history.stream": { id: "history.stream", method: "GET", path: "/v1/history/stream", auth: "open", since: "0.11.0", stream: "sse", pathParams: [], queryParams: [] },
21
21
  "events.since": { id: "events.since", method: "GET", path: "/v1/events", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: ["cursor", "limit", "host"] },
22
22
  "events.push": { id: "events.push", method: "POST", path: "/v1/events", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: [] },
23
+ "events.delete": { id: "events.delete", method: "DELETE", path: "/v1/events", auth: "token", since: "0.105.0", stream: null, pathParams: [], queryParams: ["host", "all", "force"] },
23
24
  "events.cursor": { id: "events.cursor", method: "GET", path: "/v1/events/cursor", auth: "token", since: "0.24.0", stream: null, pathParams: [], queryParams: [] },
24
25
  "events.stats": { id: "events.stats", method: "GET", path: "/v1/events/stats", auth: "token", since: "0.25.1", stream: null, pathParams: [], queryParams: [] },
25
26
  "events.stream": { id: "events.stream", method: "GET", path: "/v1/events/stream", auth: "token", since: "0.24.0", stream: "sse", pathParams: [], queryParams: ["cursor"] },
@@ -73,7 +74,28 @@ export const OPERATIONS = {
73
74
  "capabilities.decide": { id: "capabilities.decide", method: "POST", path: "/v1/decide", auth: "open", since: "0.20.0", stream: null, pathParams: [], queryParams: [] },
74
75
  "retrieval.search": { id: "retrieval.search", method: "POST", path: "/v1/search", auth: "open", since: "0.15.0", stream: null, pathParams: [], queryParams: [] },
75
76
  "retrieval.searchAlias": { id: "retrieval.searchAlias", method: "GET", path: "/v1/search/{q}", auth: "open", since: "0.15.0", stream: null, pathParams: ["q"], queryParams: ["read"] },
77
+ "capabilities.embed": { id: "capabilities.embed", method: "POST", path: "/v1/embeddings", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
78
+ "retrieval.extractContext": { id: "retrieval.extractContext", method: "POST", path: "/v1/extract/context", auth: "open", since: "0.102.0", stream: null, pathParams: [], queryParams: [] },
76
79
  "retrieval.extract": { id: "retrieval.extract", method: "POST", path: "/v1/extract", auth: "open", since: "0.16.0", stream: null, pathParams: [], queryParams: [] },
80
+ "knowledge.list": { id: "knowledge.list", method: "GET", path: "/v1/kb", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
81
+ "knowledge.create": { id: "knowledge.create", method: "POST", path: "/v1/kb", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
82
+ "knowledge.status": { id: "knowledge.status", method: "GET", path: "/v1/kb/{id}", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
83
+ "knowledge.delete": { id: "knowledge.delete", method: "DELETE", path: "/v1/kb/{id}", auth: "token", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
84
+ "knowledge.documents": { id: "knowledge.documents", method: "GET", path: "/v1/kb/{id}/documents", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
85
+ "knowledge.add": { id: "knowledge.add", method: "POST", path: "/v1/kb/{id}/documents", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
86
+ "knowledge.page": { id: "knowledge.page", method: "GET", path: "/v1/kb/{id}/documents/{doc}", auth: "open", since: "0.101.0", stream: null, pathParams: ["id", "doc"], queryParams: ["page"] },
87
+ "knowledge.removeDocument": { id: "knowledge.removeDocument", method: "DELETE", path: "/v1/kb/{id}/documents/{doc}", auth: "token", since: "0.101.0", stream: null, pathParams: ["id", "doc"], queryParams: [] },
88
+ "knowledge.passage": { id: "knowledge.passage", method: "GET", path: "/v1/kb/{id}/passages/{passage}", auth: "open", since: "0.101.0", stream: null, pathParams: ["id", "passage"], queryParams: [] },
89
+ "knowledge.outline": { id: "knowledge.outline", method: "GET", path: "/v1/kb/{id}/outline", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: ["doc"] },
90
+ "knowledge.search": { id: "knowledge.search", method: "POST", path: "/v1/kb/{id}/search", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
91
+ "knowledge.research": { id: "knowledge.research", method: "POST", path: "/v1/kb/{id}/research", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
92
+ "knowledge.graph": { id: "knowledge.graph", method: "POST", path: "/v1/kb/{id}/graph", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
93
+ "knowledge.notes": { id: "knowledge.notes", method: "GET", path: "/v1/kb/{id}/notes", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
94
+ "knowledge.note": { id: "knowledge.note", method: "POST", path: "/v1/kb/{id}/notes", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
95
+ "knowledge.noteStatus": { id: "knowledge.noteStatus", method: "POST", path: "/v1/kb/{id}/notes/{note}", auth: "token", since: "0.101.0", stream: null, pathParams: ["id", "note"], queryParams: [] },
96
+ "knowledge.access": { id: "knowledge.access", method: "GET", path: "/v1/kb/{id}/access", auth: "open", since: "0.101.1", stream: null, pathParams: ["id"], queryParams: [] },
97
+ "knowledge.setAccess": { id: "knowledge.setAccess", method: "POST", path: "/v1/kb/{id}/access", auth: "token", since: "0.101.1", stream: null, pathParams: ["id"], queryParams: [] },
98
+ "knowledge.embed": { id: "knowledge.embed", method: "POST", path: "/v1/kb/{id}/embed", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
77
99
  "retrieval.read": { id: "retrieval.read", method: "POST", path: "/v1/read", auth: "open", since: "0.14.0", stream: null, pathParams: [], queryParams: [] },
78
100
  "retrieval.readAlias": { id: "retrieval.readAlias", method: "GET", path: "/v1/read/{url}", auth: "open", since: "0.14.0", stream: null, pathParams: ["url"], queryParams: [] },
79
101
  "engines.list": { id: "engines.list", method: "GET", path: "/v1/engines", auth: "open", since: "0.6.89", stream: null, pathParams: [], queryParams: ["minCalls"] },
@@ -223,6 +245,10 @@ export class EventsApi {
223
245
  push(body, opts) {
224
246
  return this.rt.request(OPERATIONS["events.push"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
225
247
  }
248
+ /** Delete one host's slice of the merged log, or the whole log — only with `force=1`. A client's "Clear activity" reaching the copy held here. Name exactly one of `host` or `all=1`. Without `force=1` nothing is deleted: the answer is 409 `confirm_required` with `wouldDelete`, so leaving the flag off (or sending `force=0`) is a dry run, never a delete. The host's cursor entry goes with its events, so its next push starts afresh. A tailing stream gets a `deleted` frame. Idempotent: a host with nothing left deletes 0. — Requires the gateway token. Gateway 0.105.0+. */
249
+ delete(query, opts) {
250
+ return this.rt.request(OPERATIONS["events.delete"], { path: {}, query: query, headers: opts?.headers, body: undefined, opts });
251
+ }
226
252
  /** The gateway's highest `seq` per host — what a client asks for before it pushes. — Requires the gateway token. Gateway 0.24.0+. */
227
253
  cursor(opts) {
228
254
  return this.rt.request(OPERATIONS["events.cursor"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
@@ -458,6 +484,10 @@ export class CapabilitiesApi {
458
484
  decide(body, opts) {
459
485
  return this.rt.request(OPERATIONS["capabilities.decide"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
460
486
  }
487
+ /** One unit vector per input — OpenAI-shaped embeddings, in the gateway's own process by default. The `embed` capability (docs/capability-endpoints.md C4), served since 0.101.0 by the in-process embedder (`Xenova/multilingual-e5-small` by default, 384 dimensions, q8 on the ONNX runtime; `Xenova/all-MiniLM-L6-v2` as the lighter English-only pick) — or by the server `capabilities.embed` names, through its adapter. `input` is a string or up to 256 strings; `kind` says whether they are queries or passages (E5 prefixes each). The vectors are unit length, so cosine is a dot product. 503 `provider_warming` while the model downloads (the first call starts it; a caller is never held), 404 `no_provider` when it is turned off (`capabilities.embed.provider = none`), `budgetMs` refused from the record like every capability. The knowledge base (`/v1/kb`) uses this for its vector lane; it works on words and the graph until the model is on disk. — Gateway 0.101.0+. */
488
+ embed(body, opts) {
489
+ return this.rt.request(OPERATIONS["capabilities.embed"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
490
+ }
461
491
  }
462
492
  /** 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). */
463
493
  export class RuntimeApi {
@@ -492,6 +522,10 @@ export class RetrievalApi {
492
522
  searchAlias(q, query, opts) {
493
523
  return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
494
524
  }
525
+ /** The attached document(s) read FOR a question — one cited block to put before the question, as ChatPanel's own clients do. The turn pipeline's document stage as an API. Every ChatPanel client reads a file the person attached BEFORE a small model answers: whole when it fits the window's share of characters, else the pages that carry the question's words, each page cited, as one `prefetch` block placed before the question (a small model reads context first). A harness built on this SDK gets the same block here: send the question and the documents (the bytes, base64, or the `hash` of one `/v1/extract` already opened), and put `attachment.text` in the user message ahead of the question. `window` (tokens) sizes the share — a 4k on-device model gets a few thousand characters, a large window far more — or `budgetChars` sets it outright. `how` says whether the whole document went or pages were picked; `read` lists each document's pages, `skipped` the ones that could not be opened. A document with no text layer is named as a scan inside the block rather than guessed from. Parsed in the same worker as `/v1/extract`, on this machine; nothing leaves it. — Gateway 0.102.0+. */
526
+ extractContext(body, opts) {
527
+ return this.rt.request(OPERATIONS["retrieval.extractContext"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
528
+ }
495
529
  /** 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+. */
496
530
  extract(body, opts) {
497
531
  return this.rt.request(OPERATIONS["retrieval.extract"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
@@ -505,6 +539,87 @@ export class RetrievalApi {
505
539
  return this.rt.request(OPERATIONS["retrieval.readAlias"], { path: { url }, query: undefined, headers: opts?.headers, body: undefined, opts });
506
540
  }
507
541
  }
542
+ /** Knowledge bases — the user's documents (PDFs, office files, folders, pages) indexed on this machine and searched by words, meaning and graph; researched by the harness loop; annotated over time (docs/knowledge-base.md). */
543
+ export class KnowledgeApi {
544
+ rt;
545
+ constructor(rt) { this.rt = rt; }
546
+ /** The knowledge bases on this machine. Each base with its id, name, document count, vector count and model. Loads no passages. — Gateway 0.101.0+. */
547
+ list(opts) {
548
+ return this.rt.request(OPERATIONS["knowledge.list"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
549
+ }
550
+ /** Create a knowledge base (or return the one with that id). A base is a folder under `~/.chatpanel/kb/<id>/` (manifest, passages, notes, vectors, a Markdown report) — a projection over the documents added to it, rebuildable from them. `embed: off` keeps it on words and the graph only. 201 when created, 200 with `existed` when the id was already there. — Gateway 0.101.0+. */
551
+ create(body, opts) {
552
+ return this.rt.request(OPERATIONS["knowledge.create"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
553
+ }
554
+ /** What a base holds — its documents, passages, notes, vectors, entities and connections. — Gateway 0.101.0+. */
555
+ status(id, opts) {
556
+ return this.rt.request(OPERATIONS["knowledge.status"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
557
+ }
558
+ /** Delete a base and its folder. — Requires the gateway token. Gateway 0.101.0+. */
559
+ delete(id, opts) {
560
+ return this.rt.request(OPERATIONS["knowledge.delete"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
561
+ }
562
+ /** The documents in a base. — Gateway 0.101.0+. */
563
+ documents(id, opts) {
564
+ return this.rt.request(OPERATIONS["knowledge.documents"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
565
+ }
566
+ /** Add a document — bytes, a path on this machine, a URL, or text — and index it. One of four sources: `name` + `data` (the file, base64, up to 64 MB — a PDF, DOCX, XLSX, PPTX, ODF, Markdown or text, parsed in the extract worker); `path` (a file or folder on this machine, walked with the same refusals the `files` tool applies — credential stores withheld and named, `node_modules` and hidden folders skipped, documents up to 64 MB; TOKEN-GATED: a path is a read on the machine, so it is 403 to a caller without the token or the extension origin); `url` (a public page through the `read` capability); `text`. The same bytes added again REPLACE the document. Passages are chunked by the document's own headings with page citations, indexed by words and in the graph, and embedded when the embedder's model is on disk (`embedded` says how many); the report is rewritten. — Gateway 0.101.0+. */
567
+ add(id, body, opts) {
568
+ return this.rt.request(OPERATIONS["knowledge.add"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
569
+ }
570
+ /** One page of a document, from the index. — Gateway 0.101.0+. */
571
+ page(id, doc, query, opts) {
572
+ return this.rt.request(OPERATIONS["knowledge.page"], { path: { id, doc }, query: query, headers: opts?.headers, body: undefined, opts });
573
+ }
574
+ /** Remove a document, its passages and vectors (notes keep their text and lose the cite). — Requires the gateway token. Gateway 0.101.0+. */
575
+ removeDocument(id, doc, opts) {
576
+ return this.rt.request(OPERATIONS["knowledge.removeDocument"], { path: { id, doc }, query: undefined, headers: opts?.headers, body: undefined, opts });
577
+ }
578
+ /** One passage by id, with its citation. — Gateway 0.101.0+. */
579
+ passage(id, passage, opts) {
580
+ return this.rt.request(OPERATIONS["knowledge.passage"], { path: { id, passage }, query: undefined, headers: opts?.headers, body: undefined, opts });
581
+ }
582
+ /** The table of contents a document's headings imply — every section once, with where it starts. — Gateway 0.101.0+. */
583
+ outline(id, query, opts) {
584
+ return this.rt.request(OPERATIONS["knowledge.outline"], { path: { id }, query: query, headers: opts?.headers, body: undefined, opts });
585
+ }
586
+ /** The passages that answer a question — words, meaning and graph fused, a reranker on top, each with its citation. The words in up to four query shapes (BM25), the meaning when the base has vectors (the query embedded by the same model), the graph's one-hop expansion of the best hits (a passage sharing a name or a section with a hit, and `via` says which), and the notes as their own lane — fused by Reciprocal Rank Fusion with the graph at half weight, then the gateway's reranker fused in (never substituted). Each result carries `lanes` (which found it), `scores` (each lane's own, comparable within one query) and `cite` as the model is told to write it (`[report.pdf p.12]`). `docs` scopes to documents; `queries` adds the caller's own phrasings. — Gateway 0.101.0+. */
587
+ search(id, body, opts) {
588
+ return this.rt.request(OPERATIONS["knowledge.search"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
589
+ }
590
+ /** The bounded loop over a base — framed, searched, read, checked once, asked when ambiguous — as one cited block for a model. The harness's loop (events kb-research.js), not a model's tool calls: a whole-document ask ("what is this about") reads the outline and the opening of each section; a focused one searches, reads the best passages grouped by document in page order, and — with `model` (TOKEN-GATED: the check runs on this gateway's own chat route) — asks that model once whether what was read answers it, then searches once more for what it says is missing. When the hits split evenly across documents and the question names none, the answer is `ask` (which document?) instead of a guess; call again with `answer` to go on, or `ask: false` to never pause. `attachment` is the block a client attaches before the question (`kind: prefetch`), `null` when nothing matched beyond the plain statement. — Gateway 0.101.0+. */
591
+ research(id, body, opts) {
592
+ return this.rt.request(OPERATIONS["knowledge.research"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
593
+ }
594
+ /** What connects to a node — its neighbours up to `hops` away — or the path between two. — Gateway 0.101.0+. */
595
+ graph(id, body, opts) {
596
+ return this.rt.request(OPERATIONS["knowledge.graph"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
597
+ }
598
+ /** The notes filed into a base. — Gateway 0.101.0+. */
599
+ notes(id, opts) {
600
+ return this.rt.request(OPERATIONS["knowledge.notes"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
601
+ }
602
+ /** File a note — a fact, a summary, a correction — cited to passages; proposed until accepted. How a base improves over time. A note is indexed and searched as its own lane and shown with its status; `status: accepted` is honoured only from a caller with the token (the person, or a client acting for them) — any other caller's note is filed as `proposed`. Unknown cites are dropped. — Gateway 0.101.0+. */
603
+ note(id, body, opts) {
604
+ return this.rt.request(OPERATIONS["knowledge.note"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
605
+ }
606
+ /** Accept a proposed note, withdraw it to proposed, or remove it. — Requires the gateway token. Gateway 0.101.0+. */
607
+ noteStatus(id, note, body, opts) {
608
+ return this.rt.request(OPERATIONS["knowledge.noteStatus"], { path: { id, note }, query: undefined, headers: opts?.headers, body: body, opts });
609
+ }
610
+ /** Who may use a base — every agent, or the ones named. — Gateway 0.101.1+. */
611
+ access(id, opts) {
612
+ return this.rt.request(OPERATIONS["knowledge.access"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
613
+ }
614
+ /** Grant a base to every agent or to the ones named — the owner's act. Grants (docs/knowledge-base.md §3, "knowledge is granted like skills"): a caller with the token or the extension's origin is the owner and reaches every base; any other caller names itself (`X-ChatPanel-Agent: claude`, or `?agent=`) — the gateway's own MCP server sends the connected client's name — and reaches the bases whose `access.agents` is `all` (the default) or names it. `GET /v1/kb` lists only those; a base not granted reads as 404 to that caller. — Requires the gateway token. Gateway 0.101.1+. */
615
+ setAccess(id, body, opts) {
616
+ return this.rt.request(OPERATIONS["knowledge.setAccess"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
617
+ }
618
+ /** Embed every passage that has no vector yet, and say where the embedder stands. — Gateway 0.101.0+. */
619
+ embed(id, body, opts) {
620
+ return this.rt.request(OPERATIONS["knowledge.embed"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
621
+ }
622
+ }
508
623
  /** The model ledger — every engine's card. */
509
624
  export class EnginesApi {
510
625
  rt;
@@ -653,6 +768,7 @@ export function buildApi(rt) {
653
768
  capabilities: new CapabilitiesApi(rt),
654
769
  runtime: new RuntimeApi(rt),
655
770
  retrieval: new RetrievalApi(rt),
771
+ knowledge: new KnowledgeApi(rt),
656
772
  engines: new EnginesApi(rt),
657
773
  skills: new SkillsApi(rt),
658
774
  a2a: new A2aApi(rt),
@@ -448,6 +448,417 @@ export interface ExtractResponse {
448
448
  provider: string;
449
449
  ms: number;
450
450
  }
451
+ export interface ExtractContextRequest {
452
+ /** The question the documents are read for — its content words pick the pages of a long document. */
453
+ question: string;
454
+ /** Each document as its bytes (`name` + `data`, optionally `type`) or as the `hash` `/v1/extract` returned for one already open (optionally `name`, the title the block shows). */
455
+ documents: Array<{
456
+ name?: string;
457
+ type?: string;
458
+ data?: string;
459
+ hash?: string;
460
+ }>;
461
+ /** The answering model's window in tokens — sizes the share the documents may take. Absent: a small window's share. */
462
+ window?: number;
463
+ /** The share outright, in characters; overrides `window`. */
464
+ budgetChars?: number;
465
+ }
466
+ export interface ExtractContextResponse {
467
+ /** The block to put BEFORE the question; null when nothing could be read. */
468
+ attachment: {
469
+ kind?: "prefetch";
470
+ prefetch?: "document";
471
+ title?: string;
472
+ /** Per document: a one-sentence head naming it and its pages (a sentence, not a tag — an on-device model judges the prompt's language before reading it), then `--- page n ---` and that page's text. */
473
+ text?: string;
474
+ chars?: number;
475
+ cites?: Array<{
476
+ title?: string;
477
+ page?: number;
478
+ }>;
479
+ docs?: Array<{
480
+ id?: string;
481
+ title?: string;
482
+ of?: number;
483
+ pages?: Array<number>;
484
+ how?: "whole" | "pages";
485
+ }>;
486
+ };
487
+ read: Array<{
488
+ id?: string;
489
+ title?: string;
490
+ /** The document's page count. */
491
+ of?: number;
492
+ /** The pages in the block. */
493
+ pages?: Array<number>;
494
+ how?: "whole" | "pages";
495
+ /** The document's hash — reuse it on the next call. */
496
+ hash?: string;
497
+ }>;
498
+ skipped: Array<{
499
+ id?: string;
500
+ title?: string;
501
+ why?: string;
502
+ }>;
503
+ how: "whole" | "pages" | "none";
504
+ budgetChars: number;
505
+ /** `chatpanel-extract`. */
506
+ provider: string;
507
+ ms: number;
508
+ }
509
+ export interface EmbedRequest {
510
+ /** A string, or 1–256 strings. */
511
+ input: string | Array<string>;
512
+ /** The model `GET /v1/capabilities` lists for `embed`; 404 otherwise. */
513
+ model?: string;
514
+ /** What the texts are — a model with instruction prefixes (E5) prefixes each accordingly. */
515
+ kind?: "query" | "passage";
516
+ budgetMs?: number;
517
+ }
518
+ export interface EmbedResponse {
519
+ object: "list";
520
+ data: Array<{
521
+ object: "embedding";
522
+ index: number;
523
+ /** Unit length. */
524
+ embedding: Array<number>;
525
+ }>;
526
+ model: string;
527
+ usage?: {
528
+ prompt_tokens?: number;
529
+ total_tokens?: number;
530
+ };
531
+ ms: number;
532
+ }
533
+ export interface KbAccess {
534
+ /** `all`, or the agent names (lower-case) that may use the base — the owner always may. */
535
+ agents: "all" | Array<string>;
536
+ }
537
+ export interface KbAccessRequest {
538
+ /** `all`, or the agent names to grant. */
539
+ agents: "all" | Array<string>;
540
+ }
541
+ export interface KbAccessResponse {
542
+ access: KbAccess;
543
+ }
544
+ export interface KbOkResponse {
545
+ ok: boolean;
546
+ }
547
+ export interface KbList {
548
+ kbs: Array<{
549
+ id: string;
550
+ name: string;
551
+ docs: number;
552
+ updatedAt?: number;
553
+ vectors?: number;
554
+ model?: string;
555
+ access?: KbAccess;
556
+ }>;
557
+ }
558
+ export interface KbCreateRequest {
559
+ /** Chosen by the caller; made up when absent. */
560
+ id?: string;
561
+ name?: string;
562
+ /** `off`: words and graph only, no vectors. */
563
+ embed?: "auto" | "off";
564
+ }
565
+ export interface KbDocument {
566
+ id: string;
567
+ title: string;
568
+ pages: number;
569
+ /** Passages. */
570
+ chunks: number;
571
+ type?: string;
572
+ source?: {
573
+ kind?: "file" | "url" | "bytes" | "text";
574
+ path?: string;
575
+ url?: string;
576
+ name?: string;
577
+ };
578
+ addedAt?: number;
579
+ }
580
+ export interface KbStatus {
581
+ id: string;
582
+ name: string;
583
+ v?: number;
584
+ createdAt?: number;
585
+ updatedAt?: number;
586
+ docs: number;
587
+ chunks: number;
588
+ notes: number;
589
+ /** Notes awaiting acceptance. */
590
+ proposed?: number;
591
+ vectors: number;
592
+ /** The embedding model the vectors came from. */
593
+ model?: string;
594
+ dims?: number;
595
+ embed?: "auto" | "off";
596
+ entities: number;
597
+ edges: number;
598
+ /** The tightest provenance of its documents (`internal`, `web`, or empty). */
599
+ reach?: string;
600
+ access?: KbAccess;
601
+ documents: Array<KbDocument>;
602
+ /** On disk. */
603
+ bytes?: number;
604
+ /** The folder on disk — to a caller with the token only. */
605
+ dir?: string;
606
+ }
607
+ export interface KbStatusResponse {
608
+ kb: KbStatus;
609
+ existed?: boolean;
610
+ ok?: boolean;
611
+ }
612
+ export interface KbDocuments {
613
+ documents: Array<KbDocument>;
614
+ }
615
+ /** One source: `name` + `data`, or `path`, or `url`, or `text`. */
616
+ export interface KbAddRequest {
617
+ /** The file name (with `data`); the title for `text` when none is given. */
618
+ name?: string;
619
+ /** A type hint (`pdf`, `docx`); the bytes decide. */
620
+ type?: string;
621
+ /** The whole file, base64, at most 64 MB decoded. */
622
+ data?: string;
623
+ /** A file or folder on this machine (token-gated). */
624
+ path?: string;
625
+ /** With a folder: walk subfolders. */
626
+ recursive?: boolean;
627
+ /** With a folder: only these extensions (`*.pdf`, `.md`). */
628
+ include?: Array<string>;
629
+ /** A public http(s) page, read as Markdown. */
630
+ url?: string;
631
+ /** Plain text or Markdown, up to 4 M characters. */
632
+ text?: string;
633
+ title?: string;
634
+ /** Provenance to record on the document (`internal` narrows a turn that uses it). */
635
+ reach?: string;
636
+ }
637
+ export interface KbAddResponse {
638
+ added: Array<{
639
+ id: string;
640
+ title: string;
641
+ pages: number;
642
+ chunks: number;
643
+ replaced?: boolean;
644
+ /** A PDF with no text layer: indexed empty. */
645
+ scanned?: boolean;
646
+ /** Relative to the folder given. */
647
+ path?: string;
648
+ }>;
649
+ skipped: Array<{
650
+ path?: string;
651
+ url?: string;
652
+ why?: string;
653
+ }>;
654
+ /** Passages given a vector in this call. */
655
+ embedded?: number;
656
+ kb: KbStatus;
657
+ ms?: number;
658
+ }
659
+ export interface KbPassage {
660
+ /** `<doc>#<n>`, or `note:<id>`. */
661
+ id: string;
662
+ doc?: string;
663
+ title?: string;
664
+ kind?: "text" | "note";
665
+ page?: number;
666
+ pageEnd?: number;
667
+ /** The heading path, ` › `-joined. */
668
+ section?: string;
669
+ text: string;
670
+ chars?: number;
671
+ /** The fused rank score (RRF) — only its order means anything. */
672
+ score?: number;
673
+ /** Each lane's own score (`text`, `vector`, `rerank`), comparable within one query. */
674
+ scores?: {
675
+ [key: string]: number;
676
+ };
677
+ rerank?: number;
678
+ lanes?: Array<"text" | "vector" | "graph" | "notes" | "rerank">;
679
+ /** For a graph hit: the node(s) it was reached through. */
680
+ via?: Array<string>;
681
+ /** As the model is told to write it: `[report.pdf p.12]`. */
682
+ cite?: string;
683
+ /** A note's. */
684
+ status?: "proposed" | "accepted";
685
+ /** A note's passage ids. */
686
+ cites?: Array<string>;
687
+ }
688
+ export interface KbSearchRequest {
689
+ query: string;
690
+ limit?: number;
691
+ /** Graph expansion of the best hits; 0 = off. */
692
+ hops?: number;
693
+ /** Only these documents. */
694
+ docs?: Array<string>;
695
+ /** The caller's own phrasings, searched too. */
696
+ queries?: Array<string>;
697
+ /** `false`: skip the reranker. */
698
+ rerank?: boolean;
699
+ budgetMs?: number;
700
+ }
701
+ export interface KbSearchResponse {
702
+ results: Array<KbPassage>;
703
+ /** How many candidates each lane found. */
704
+ lanes: {
705
+ text?: number;
706
+ vector?: number;
707
+ graph?: number;
708
+ notes?: number;
709
+ };
710
+ /** The query shapes searched. */
711
+ queries: Array<string>;
712
+ ms: number;
713
+ }
714
+ export interface KbResearchRequest {
715
+ question: string;
716
+ /** The person's answer to a previous `ask` (a document title, or `all`). */
717
+ answer?: string;
718
+ /** `false`: never pause; search every document. */
719
+ ask?: boolean;
720
+ /** A model (from `GET /v1/models`) for the evidence check; token-gated. */
721
+ model?: string;
722
+ /** The previous response's `frame`, for a follow-up. */
723
+ previous?: {
724
+ [key: string]: unknown;
725
+ };
726
+ /** Only these documents. */
727
+ docs?: Array<string>;
728
+ }
729
+ export interface KbResearchResponse {
730
+ /** The block for the model (`kind: prefetch`, `prefetch: kb`), or null. */
731
+ attachment?: {
732
+ id?: string;
733
+ kind?: string;
734
+ prefetch?: string;
735
+ title?: string;
736
+ text?: string;
737
+ chars?: number;
738
+ cites?: Array<{
739
+ [key: string]: unknown;
740
+ }>;
741
+ };
742
+ /** What was read, grouped by document in page order (or the outline for a whole-document ask). */
743
+ read: Array<{
744
+ [key: string]: unknown;
745
+ }>;
746
+ hits: Array<{
747
+ id?: string;
748
+ doc?: string;
749
+ title?: string;
750
+ page?: number;
751
+ section?: string;
752
+ cite?: string;
753
+ lanes?: Array<string>;
754
+ via?: Array<string>;
755
+ }>;
756
+ queries: Array<string>;
757
+ /** The check's answer when a model was given. */
758
+ verdict?: "yes" | "partly" | "no" | null;
759
+ rounds: number;
760
+ /** The question for the person, when the hits split evenly across documents. */
761
+ ask?: {
762
+ question?: string;
763
+ options?: Array<string>;
764
+ kind?: string;
765
+ step?: string;
766
+ };
767
+ /** How it was searched, in words. */
768
+ how?: string;
769
+ frame?: {
770
+ whole?: boolean;
771
+ docs?: Array<string>;
772
+ };
773
+ ms: number;
774
+ }
775
+ export interface KbGraphRequest {
776
+ /** An entity, section or topic by name (or a node id). */
777
+ node: string;
778
+ /** A second node: the path from `node` to it. */
779
+ to?: string;
780
+ hops?: number;
781
+ kinds?: Array<"doc" | "section" | "entity" | "topic" | "note" | "chunk">;
782
+ limit?: number;
783
+ }
784
+ export interface KbGraphResponse {
785
+ node: {
786
+ id?: string;
787
+ kind?: string;
788
+ label?: string;
789
+ };
790
+ neighbours: Array<{
791
+ id?: string;
792
+ kind?: string;
793
+ label?: string;
794
+ weight?: number;
795
+ via?: Array<{
796
+ [key: string]: unknown;
797
+ }>;
798
+ }>;
799
+ to?: string;
800
+ path?: Array<{
801
+ id?: string;
802
+ label?: string;
803
+ kind?: string;
804
+ }>;
805
+ message?: string;
806
+ }
807
+ export interface KbPage {
808
+ doc: string;
809
+ title?: string;
810
+ page: number;
811
+ pages: number;
812
+ text: string;
813
+ }
814
+ export interface KbOutline {
815
+ outline: Array<{
816
+ doc?: string;
817
+ section?: string;
818
+ level?: number;
819
+ page?: number;
820
+ chunks?: number;
821
+ chars?: number;
822
+ /** The first passage id of the section. */
823
+ first?: string;
824
+ }>;
825
+ }
826
+ export interface KbNote {
827
+ id: string;
828
+ text: string;
829
+ cites?: Array<string>;
830
+ by?: string;
831
+ status: "proposed" | "accepted";
832
+ at: number;
833
+ }
834
+ export interface KbNotes {
835
+ notes: Array<KbNote>;
836
+ }
837
+ export interface KbNoteRequest {
838
+ text: string;
839
+ cites?: Array<string>;
840
+ /** `accepted` is honoured from a caller with the token only. */
841
+ status?: "proposed" | "accepted";
842
+ by?: string;
843
+ }
844
+ export interface KbNoteResponse {
845
+ note: KbNote;
846
+ removed?: boolean;
847
+ }
848
+ export interface KbNoteStatusRequest {
849
+ status: "proposed" | "accepted" | "removed";
850
+ }
851
+ export interface KbEmbedResponse {
852
+ embedded: number;
853
+ vectors: number;
854
+ model?: string;
855
+ dims?: number;
856
+ /** `ready`, `idle`, `loading`, `downloading`, `down`, `off`. */
857
+ state: string;
858
+ progress?: {
859
+ [key: string]: unknown;
860
+ };
861
+ }
451
862
  export interface ReadRequest {
452
863
  /** Absolute http(s) URL of a public page. */
453
864
  url: string;
@@ -718,6 +1129,26 @@ export interface EventsCursor {
718
1129
  cursor: EventsCursorMap;
719
1130
  count?: number;
720
1131
  }
1132
+ export interface EventsDeleted {
1133
+ ok: boolean;
1134
+ /** How many events went. */
1135
+ deleted: number;
1136
+ host?: string;
1137
+ all?: boolean;
1138
+ cursor: EventsCursorMap;
1139
+ }
1140
+ export interface EventsDeleteDryRun {
1141
+ ok: false;
1142
+ /** What `force=1` would delete. */
1143
+ wouldDelete: number;
1144
+ host?: string;
1145
+ all?: boolean;
1146
+ error: {
1147
+ message: string;
1148
+ type: "confirm_required";
1149
+ code?: "confirm_required";
1150
+ };
1151
+ }
721
1152
  export interface EventsPage {
722
1153
  ok: boolean;
723
1154
  events: Array<CloudEvent>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.27.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",