@chatpanel/sdk 0.24.0 → 0.26.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.
@@ -732,6 +732,26 @@ export declare const OPERATIONS: {
732
732
  readonly pathParams: readonly ["q"];
733
733
  readonly queryParams: readonly ["read"];
734
734
  };
735
+ readonly "capabilities.embed": {
736
+ readonly id: "capabilities.embed";
737
+ readonly method: "POST";
738
+ readonly path: "/v1/embeddings";
739
+ readonly auth: "open";
740
+ readonly since: "0.101.0";
741
+ readonly stream: null;
742
+ readonly pathParams: readonly [];
743
+ readonly queryParams: readonly [];
744
+ };
745
+ readonly "retrieval.extractContext": {
746
+ readonly id: "retrieval.extractContext";
747
+ readonly method: "POST";
748
+ readonly path: "/v1/extract/context";
749
+ readonly auth: "open";
750
+ readonly since: "0.102.0";
751
+ readonly stream: null;
752
+ readonly pathParams: readonly [];
753
+ readonly queryParams: readonly [];
754
+ };
735
755
  readonly "retrieval.extract": {
736
756
  readonly id: "retrieval.extract";
737
757
  readonly method: "POST";
@@ -742,6 +762,196 @@ export declare const OPERATIONS: {
742
762
  readonly pathParams: readonly [];
743
763
  readonly queryParams: readonly [];
744
764
  };
765
+ readonly "knowledge.list": {
766
+ readonly id: "knowledge.list";
767
+ readonly method: "GET";
768
+ readonly path: "/v1/kb";
769
+ readonly auth: "open";
770
+ readonly since: "0.101.0";
771
+ readonly stream: null;
772
+ readonly pathParams: readonly [];
773
+ readonly queryParams: readonly [];
774
+ };
775
+ readonly "knowledge.create": {
776
+ readonly id: "knowledge.create";
777
+ readonly method: "POST";
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.status": {
786
+ readonly id: "knowledge.status";
787
+ readonly method: "GET";
788
+ readonly path: "/v1/kb/{id}";
789
+ readonly auth: "open";
790
+ readonly since: "0.101.0";
791
+ readonly stream: null;
792
+ readonly pathParams: readonly ["id"];
793
+ readonly queryParams: readonly [];
794
+ };
795
+ readonly "knowledge.delete": {
796
+ readonly id: "knowledge.delete";
797
+ readonly method: "DELETE";
798
+ readonly path: "/v1/kb/{id}";
799
+ readonly auth: "token";
800
+ readonly since: "0.101.0";
801
+ readonly stream: null;
802
+ readonly pathParams: readonly ["id"];
803
+ readonly queryParams: readonly [];
804
+ };
805
+ readonly "knowledge.documents": {
806
+ readonly id: "knowledge.documents";
807
+ readonly method: "GET";
808
+ readonly path: "/v1/kb/{id}/documents";
809
+ readonly auth: "open";
810
+ readonly since: "0.101.0";
811
+ readonly stream: null;
812
+ readonly pathParams: readonly ["id"];
813
+ readonly queryParams: readonly [];
814
+ };
815
+ readonly "knowledge.add": {
816
+ readonly id: "knowledge.add";
817
+ readonly method: "POST";
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.page": {
826
+ readonly id: "knowledge.page";
827
+ readonly method: "GET";
828
+ readonly path: "/v1/kb/{id}/documents/{doc}";
829
+ readonly auth: "open";
830
+ readonly since: "0.101.0";
831
+ readonly stream: null;
832
+ readonly pathParams: readonly ["id", "doc"];
833
+ readonly queryParams: readonly ["page"];
834
+ };
835
+ readonly "knowledge.removeDocument": {
836
+ readonly id: "knowledge.removeDocument";
837
+ readonly method: "DELETE";
838
+ readonly path: "/v1/kb/{id}/documents/{doc}";
839
+ readonly auth: "token";
840
+ readonly since: "0.101.0";
841
+ readonly stream: null;
842
+ readonly pathParams: readonly ["id", "doc"];
843
+ readonly queryParams: readonly [];
844
+ };
845
+ readonly "knowledge.passage": {
846
+ readonly id: "knowledge.passage";
847
+ readonly method: "GET";
848
+ readonly path: "/v1/kb/{id}/passages/{passage}";
849
+ readonly auth: "open";
850
+ readonly since: "0.101.0";
851
+ readonly stream: null;
852
+ readonly pathParams: readonly ["id", "passage"];
853
+ readonly queryParams: readonly [];
854
+ };
855
+ readonly "knowledge.outline": {
856
+ readonly id: "knowledge.outline";
857
+ readonly method: "GET";
858
+ readonly path: "/v1/kb/{id}/outline";
859
+ readonly auth: "open";
860
+ readonly since: "0.101.0";
861
+ readonly stream: null;
862
+ readonly pathParams: readonly ["id"];
863
+ readonly queryParams: readonly ["doc"];
864
+ };
865
+ readonly "knowledge.search": {
866
+ readonly id: "knowledge.search";
867
+ readonly method: "POST";
868
+ readonly path: "/v1/kb/{id}/search";
869
+ readonly auth: "open";
870
+ readonly since: "0.101.0";
871
+ readonly stream: null;
872
+ readonly pathParams: readonly ["id"];
873
+ readonly queryParams: readonly [];
874
+ };
875
+ readonly "knowledge.research": {
876
+ readonly id: "knowledge.research";
877
+ readonly method: "POST";
878
+ readonly path: "/v1/kb/{id}/research";
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.graph": {
886
+ readonly id: "knowledge.graph";
887
+ readonly method: "POST";
888
+ readonly path: "/v1/kb/{id}/graph";
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.notes": {
896
+ readonly id: "knowledge.notes";
897
+ readonly method: "GET";
898
+ readonly path: "/v1/kb/{id}/notes";
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.note": {
906
+ readonly id: "knowledge.note";
907
+ readonly method: "POST";
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.noteStatus": {
916
+ readonly id: "knowledge.noteStatus";
917
+ readonly method: "POST";
918
+ readonly path: "/v1/kb/{id}/notes/{note}";
919
+ readonly auth: "token";
920
+ readonly since: "0.101.0";
921
+ readonly stream: null;
922
+ readonly pathParams: readonly ["id", "note"];
923
+ readonly queryParams: readonly [];
924
+ };
925
+ readonly "knowledge.access": {
926
+ readonly id: "knowledge.access";
927
+ readonly method: "GET";
928
+ readonly path: "/v1/kb/{id}/access";
929
+ readonly auth: "open";
930
+ readonly since: "0.101.1";
931
+ readonly stream: null;
932
+ readonly pathParams: readonly ["id"];
933
+ readonly queryParams: readonly [];
934
+ };
935
+ readonly "knowledge.setAccess": {
936
+ readonly id: "knowledge.setAccess";
937
+ readonly method: "POST";
938
+ readonly path: "/v1/kb/{id}/access";
939
+ readonly auth: "token";
940
+ readonly since: "0.101.1";
941
+ readonly stream: null;
942
+ readonly pathParams: readonly ["id"];
943
+ readonly queryParams: readonly [];
944
+ };
945
+ readonly "knowledge.embed": {
946
+ readonly id: "knowledge.embed";
947
+ readonly method: "POST";
948
+ readonly path: "/v1/kb/{id}/embed";
949
+ readonly auth: "open";
950
+ readonly since: "0.101.0";
951
+ readonly stream: null;
952
+ readonly pathParams: readonly ["id"];
953
+ readonly queryParams: readonly [];
954
+ };
745
955
  readonly "retrieval.read": {
746
956
  readonly id: "retrieval.read";
747
957
  readonly method: "POST";
@@ -1503,6 +1713,8 @@ export declare class CapabilitiesApi {
1503
1713
  rerank(body: T.RerankRequest, opts?: RequestOptions): Promise<T.RerankResponse>;
1504
1714
  /** 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
1715
  decide(body: T.DecideRequest, opts?: RequestOptions): Promise<T.DecideResponse>;
1716
+ /** 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+. */
1717
+ embed(body: T.EmbedRequest, opts?: RequestOptions): Promise<T.EmbedResponse>;
1506
1718
  }
1507
1719
  /** 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
1720
  export declare class RuntimeApi {
@@ -1555,6 +1767,8 @@ export declare class RetrievalApi {
1555
1767
  }>;
1556
1768
  trail?: T.SearchTrail;
1557
1769
  }>;
1770
+ /** 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+. */
1771
+ extractContext(body: T.ExtractContextRequest, opts?: RequestOptions): Promise<T.ExtractContextResponse>;
1558
1772
  /** 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
1773
  extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
1560
1774
  /** 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 +1785,53 @@ export declare class RetrievalApi {
1571
1785
  data: T.ReadResponse;
1572
1786
  }>;
1573
1787
  }
1788
+ /** 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). */
1789
+ export declare class KnowledgeApi {
1790
+ private readonly rt;
1791
+ constructor(rt: Runtime);
1792
+ /** 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+. */
1793
+ list(opts?: RequestOptions): Promise<T.KbList>;
1794
+ /** 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+. */
1795
+ create(body: T.KbCreateRequest, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1796
+ /** What a base holds — its documents, passages, notes, vectors, entities and connections. — Gateway 0.101.0+. */
1797
+ status(id: string, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1798
+ /** Delete a base and its folder. — Requires the gateway token. Gateway 0.101.0+. */
1799
+ delete(id: string, opts?: RequestOptions): Promise<T.KbOkResponse>;
1800
+ /** The documents in a base. — Gateway 0.101.0+. */
1801
+ documents(id: string, opts?: RequestOptions): Promise<T.KbDocuments>;
1802
+ /** 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+. */
1803
+ add(id: string, body: T.KbAddRequest, opts?: RequestOptions): Promise<T.KbAddResponse>;
1804
+ /** One page of a document, from the index. — Gateway 0.101.0+. */
1805
+ page(id: string, doc: string, query?: {
1806
+ page?: number;
1807
+ }, opts?: RequestOptions): Promise<T.KbPage>;
1808
+ /** Remove a document, its passages and vectors (notes keep their text and lose the cite). — Requires the gateway token. Gateway 0.101.0+. */
1809
+ removeDocument(id: string, doc: string, opts?: RequestOptions): Promise<T.KbStatusResponse>;
1810
+ /** One passage by id, with its citation. — Gateway 0.101.0+. */
1811
+ passage(id: string, passage: string, opts?: RequestOptions): Promise<T.KbPassage>;
1812
+ /** The table of contents a document's headings imply — every section once, with where it starts. — Gateway 0.101.0+. */
1813
+ outline(id: string, query?: {
1814
+ doc?: string;
1815
+ }, opts?: RequestOptions): Promise<T.KbOutline>;
1816
+ /** 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+. */
1817
+ search(id: string, body: T.KbSearchRequest, opts?: RequestOptions): Promise<T.KbSearchResponse>;
1818
+ /** 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+. */
1819
+ research(id: string, body: T.KbResearchRequest, opts?: RequestOptions): Promise<T.KbResearchResponse>;
1820
+ /** What connects to a node — its neighbours up to `hops` away — or the path between two. — Gateway 0.101.0+. */
1821
+ graph(id: string, body: T.KbGraphRequest, opts?: RequestOptions): Promise<T.KbGraphResponse>;
1822
+ /** The notes filed into a base. — Gateway 0.101.0+. */
1823
+ notes(id: string, opts?: RequestOptions): Promise<T.KbNotes>;
1824
+ /** 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+. */
1825
+ note(id: string, body: T.KbNoteRequest, opts?: RequestOptions): Promise<T.KbNoteResponse>;
1826
+ /** Accept a proposed note, withdraw it to proposed, or remove it. — Requires the gateway token. Gateway 0.101.0+. */
1827
+ noteStatus(id: string, note: string, body: T.KbNoteStatusRequest, opts?: RequestOptions): Promise<T.KbNoteResponse>;
1828
+ /** Who may use a base — every agent, or the ones named. — Gateway 0.101.1+. */
1829
+ access(id: string, opts?: RequestOptions): Promise<T.KbAccessResponse>;
1830
+ /** 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+. */
1831
+ setAccess(id: string, body: T.KbAccessRequest, opts?: RequestOptions): Promise<T.KbAccessResponse>;
1832
+ /** Embed every passage that has no vector yet, and say where the embedder stands. — Gateway 0.101.0+. */
1833
+ embed(id: string, body: Record<string, never>, opts?: RequestOptions): Promise<T.KbEmbedResponse>;
1834
+ }
1574
1835
  /** The model ledger — every engine's card. */
1575
1836
  export declare class EnginesApi {
1576
1837
  private readonly rt;
@@ -1732,6 +1993,7 @@ export declare function buildApi(rt: Runtime): {
1732
1993
  capabilities: CapabilitiesApi;
1733
1994
  runtime: RuntimeApi;
1734
1995
  retrieval: RetrievalApi;
1996
+ knowledge: KnowledgeApi;
1735
1997
  engines: EnginesApi;
1736
1998
  skills: SkillsApi;
1737
1999
  a2a: A2aApi;
@@ -73,7 +73,28 @@ export const OPERATIONS = {
73
73
  "capabilities.decide": { id: "capabilities.decide", method: "POST", path: "/v1/decide", auth: "open", since: "0.20.0", stream: null, pathParams: [], queryParams: [] },
74
74
  "retrieval.search": { id: "retrieval.search", method: "POST", path: "/v1/search", auth: "open", since: "0.15.0", stream: null, pathParams: [], queryParams: [] },
75
75
  "retrieval.searchAlias": { id: "retrieval.searchAlias", method: "GET", path: "/v1/search/{q}", auth: "open", since: "0.15.0", stream: null, pathParams: ["q"], queryParams: ["read"] },
76
+ "capabilities.embed": { id: "capabilities.embed", method: "POST", path: "/v1/embeddings", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
77
+ "retrieval.extractContext": { id: "retrieval.extractContext", method: "POST", path: "/v1/extract/context", auth: "open", since: "0.102.0", stream: null, pathParams: [], queryParams: [] },
76
78
  "retrieval.extract": { id: "retrieval.extract", method: "POST", path: "/v1/extract", auth: "open", since: "0.16.0", stream: null, pathParams: [], queryParams: [] },
79
+ "knowledge.list": { id: "knowledge.list", method: "GET", path: "/v1/kb", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
80
+ "knowledge.create": { id: "knowledge.create", method: "POST", path: "/v1/kb", auth: "open", since: "0.101.0", stream: null, pathParams: [], queryParams: [] },
81
+ "knowledge.status": { id: "knowledge.status", method: "GET", path: "/v1/kb/{id}", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
82
+ "knowledge.delete": { id: "knowledge.delete", method: "DELETE", path: "/v1/kb/{id}", auth: "token", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
83
+ "knowledge.documents": { id: "knowledge.documents", method: "GET", path: "/v1/kb/{id}/documents", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
84
+ "knowledge.add": { id: "knowledge.add", method: "POST", path: "/v1/kb/{id}/documents", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
85
+ "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"] },
86
+ "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: [] },
87
+ "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: [] },
88
+ "knowledge.outline": { id: "knowledge.outline", method: "GET", path: "/v1/kb/{id}/outline", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: ["doc"] },
89
+ "knowledge.search": { id: "knowledge.search", method: "POST", path: "/v1/kb/{id}/search", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
90
+ "knowledge.research": { id: "knowledge.research", method: "POST", path: "/v1/kb/{id}/research", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
91
+ "knowledge.graph": { id: "knowledge.graph", method: "POST", path: "/v1/kb/{id}/graph", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
92
+ "knowledge.notes": { id: "knowledge.notes", method: "GET", path: "/v1/kb/{id}/notes", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
93
+ "knowledge.note": { id: "knowledge.note", method: "POST", path: "/v1/kb/{id}/notes", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
94
+ "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: [] },
95
+ "knowledge.access": { id: "knowledge.access", method: "GET", path: "/v1/kb/{id}/access", auth: "open", since: "0.101.1", stream: null, pathParams: ["id"], queryParams: [] },
96
+ "knowledge.setAccess": { id: "knowledge.setAccess", method: "POST", path: "/v1/kb/{id}/access", auth: "token", since: "0.101.1", stream: null, pathParams: ["id"], queryParams: [] },
97
+ "knowledge.embed": { id: "knowledge.embed", method: "POST", path: "/v1/kb/{id}/embed", auth: "open", since: "0.101.0", stream: null, pathParams: ["id"], queryParams: [] },
77
98
  "retrieval.read": { id: "retrieval.read", method: "POST", path: "/v1/read", auth: "open", since: "0.14.0", stream: null, pathParams: [], queryParams: [] },
78
99
  "retrieval.readAlias": { id: "retrieval.readAlias", method: "GET", path: "/v1/read/{url}", auth: "open", since: "0.14.0", stream: null, pathParams: ["url"], queryParams: [] },
79
100
  "engines.list": { id: "engines.list", method: "GET", path: "/v1/engines", auth: "open", since: "0.6.89", stream: null, pathParams: [], queryParams: ["minCalls"] },
@@ -458,6 +479,10 @@ export class CapabilitiesApi {
458
479
  decide(body, opts) {
459
480
  return this.rt.request(OPERATIONS["capabilities.decide"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
460
481
  }
482
+ /** 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+. */
483
+ embed(body, opts) {
484
+ return this.rt.request(OPERATIONS["capabilities.embed"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
485
+ }
461
486
  }
462
487
  /** 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
488
  export class RuntimeApi {
@@ -492,6 +517,10 @@ export class RetrievalApi {
492
517
  searchAlias(q, query, opts) {
493
518
  return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
494
519
  }
520
+ /** 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+. */
521
+ extractContext(body, opts) {
522
+ return this.rt.request(OPERATIONS["retrieval.extractContext"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
523
+ }
495
524
  /** 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
525
  extract(body, opts) {
497
526
  return this.rt.request(OPERATIONS["retrieval.extract"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
@@ -505,6 +534,87 @@ export class RetrievalApi {
505
534
  return this.rt.request(OPERATIONS["retrieval.readAlias"], { path: { url }, query: undefined, headers: opts?.headers, body: undefined, opts });
506
535
  }
507
536
  }
537
+ /** 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). */
538
+ export class KnowledgeApi {
539
+ rt;
540
+ constructor(rt) { this.rt = rt; }
541
+ /** 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+. */
542
+ list(opts) {
543
+ return this.rt.request(OPERATIONS["knowledge.list"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
544
+ }
545
+ /** 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+. */
546
+ create(body, opts) {
547
+ return this.rt.request(OPERATIONS["knowledge.create"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
548
+ }
549
+ /** What a base holds — its documents, passages, notes, vectors, entities and connections. — Gateway 0.101.0+. */
550
+ status(id, opts) {
551
+ return this.rt.request(OPERATIONS["knowledge.status"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
552
+ }
553
+ /** Delete a base and its folder. — Requires the gateway token. Gateway 0.101.0+. */
554
+ delete(id, opts) {
555
+ return this.rt.request(OPERATIONS["knowledge.delete"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
556
+ }
557
+ /** The documents in a base. — Gateway 0.101.0+. */
558
+ documents(id, opts) {
559
+ return this.rt.request(OPERATIONS["knowledge.documents"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
560
+ }
561
+ /** 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+. */
562
+ add(id, body, opts) {
563
+ return this.rt.request(OPERATIONS["knowledge.add"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
564
+ }
565
+ /** One page of a document, from the index. — Gateway 0.101.0+. */
566
+ page(id, doc, query, opts) {
567
+ return this.rt.request(OPERATIONS["knowledge.page"], { path: { id, doc }, query: query, headers: opts?.headers, body: undefined, opts });
568
+ }
569
+ /** Remove a document, its passages and vectors (notes keep their text and lose the cite). — Requires the gateway token. Gateway 0.101.0+. */
570
+ removeDocument(id, doc, opts) {
571
+ return this.rt.request(OPERATIONS["knowledge.removeDocument"], { path: { id, doc }, query: undefined, headers: opts?.headers, body: undefined, opts });
572
+ }
573
+ /** One passage by id, with its citation. — Gateway 0.101.0+. */
574
+ passage(id, passage, opts) {
575
+ return this.rt.request(OPERATIONS["knowledge.passage"], { path: { id, passage }, query: undefined, headers: opts?.headers, body: undefined, opts });
576
+ }
577
+ /** The table of contents a document's headings imply — every section once, with where it starts. — Gateway 0.101.0+. */
578
+ outline(id, query, opts) {
579
+ return this.rt.request(OPERATIONS["knowledge.outline"], { path: { id }, query: query, headers: opts?.headers, body: undefined, opts });
580
+ }
581
+ /** 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+. */
582
+ search(id, body, opts) {
583
+ return this.rt.request(OPERATIONS["knowledge.search"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
584
+ }
585
+ /** 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+. */
586
+ research(id, body, opts) {
587
+ return this.rt.request(OPERATIONS["knowledge.research"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
588
+ }
589
+ /** What connects to a node — its neighbours up to `hops` away — or the path between two. — Gateway 0.101.0+. */
590
+ graph(id, body, opts) {
591
+ return this.rt.request(OPERATIONS["knowledge.graph"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
592
+ }
593
+ /** The notes filed into a base. — Gateway 0.101.0+. */
594
+ notes(id, opts) {
595
+ return this.rt.request(OPERATIONS["knowledge.notes"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
596
+ }
597
+ /** 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+. */
598
+ note(id, body, opts) {
599
+ return this.rt.request(OPERATIONS["knowledge.note"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
600
+ }
601
+ /** Accept a proposed note, withdraw it to proposed, or remove it. — Requires the gateway token. Gateway 0.101.0+. */
602
+ noteStatus(id, note, body, opts) {
603
+ return this.rt.request(OPERATIONS["knowledge.noteStatus"], { path: { id, note }, query: undefined, headers: opts?.headers, body: body, opts });
604
+ }
605
+ /** Who may use a base — every agent, or the ones named. — Gateway 0.101.1+. */
606
+ access(id, opts) {
607
+ return this.rt.request(OPERATIONS["knowledge.access"], { path: { id }, query: undefined, headers: opts?.headers, body: undefined, opts });
608
+ }
609
+ /** 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+. */
610
+ setAccess(id, body, opts) {
611
+ return this.rt.request(OPERATIONS["knowledge.setAccess"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
612
+ }
613
+ /** Embed every passage that has no vector yet, and say where the embedder stands. — Gateway 0.101.0+. */
614
+ embed(id, body, opts) {
615
+ return this.rt.request(OPERATIONS["knowledge.embed"], { path: { id }, query: undefined, headers: opts?.headers, body: body, opts });
616
+ }
617
+ }
508
618
  /** The model ledger — every engine's card. */
509
619
  export class EnginesApi {
510
620
  rt;
@@ -653,6 +763,7 @@ export function buildApi(rt) {
653
763
  capabilities: new CapabilitiesApi(rt),
654
764
  runtime: new RuntimeApi(rt),
655
765
  retrieval: new RetrievalApi(rt),
766
+ knowledge: new KnowledgeApi(rt),
656
767
  engines: new EnginesApi(rt),
657
768
  skills: new SkillsApi(rt),
658
769
  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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.26.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",