@chatpanel/sdk 0.22.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.
package/README.md CHANGED
@@ -46,6 +46,18 @@ const { token } = await cp.pair(codeTheUserTyped);
46
46
  Reads on the `/v1` data plane work without a token; the gateway allows `http://localhost`
47
47
  origins and anything in its `allowedOrigins`.
48
48
 
49
+ ### From a partner server (ChatPanel Link)
50
+
51
+ A server the user paired by hand (`chatpanel-gateway link pair --partner <name>`) reaches their
52
+ gateway with the Link client as the `fetch` — the base URL stays loopback:
53
+
54
+ ```ts
55
+ import { createLinkFetch } from '@chatpanel/events/link-fetch.js';
56
+ const cp = new ChatPanel({ baseUrl: 'http://127.0.0.1:4320', fetch: await createLinkFetch({ pairing: code, store }) });
57
+ ```
58
+
59
+ Scopes, routes and the security model: the repository README, "Remote access for partner servers".
60
+
49
61
  ### Errors
50
62
 
51
63
  Every failure is a `ChatPanelError` with `status`, `type` and `operation`:
@@ -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";
@@ -972,6 +1182,86 @@ export declare const OPERATIONS: {
972
1182
  readonly pathParams: readonly [];
973
1183
  readonly queryParams: readonly [];
974
1184
  };
1185
+ readonly "link.status": {
1186
+ readonly id: "link.status";
1187
+ readonly method: "GET";
1188
+ readonly path: "/v1/link";
1189
+ readonly auth: "token";
1190
+ readonly since: "0.60.0";
1191
+ readonly stream: null;
1192
+ readonly pathParams: readonly [];
1193
+ readonly queryParams: readonly [];
1194
+ };
1195
+ readonly "link.pair": {
1196
+ readonly id: "link.pair";
1197
+ readonly method: "POST";
1198
+ readonly path: "/v1/link/pair";
1199
+ readonly auth: "token";
1200
+ readonly since: "0.60.0";
1201
+ readonly stream: null;
1202
+ readonly pathParams: readonly [];
1203
+ readonly queryParams: readonly [];
1204
+ };
1205
+ readonly "link.route": {
1206
+ readonly id: "link.route";
1207
+ readonly method: "POST";
1208
+ readonly path: "/v1/link/route";
1209
+ readonly auth: "token";
1210
+ readonly since: "0.65.0";
1211
+ readonly stream: null;
1212
+ readonly pathParams: readonly [];
1213
+ readonly queryParams: readonly [];
1214
+ };
1215
+ readonly "link.removeDevice": {
1216
+ readonly id: "link.removeDevice";
1217
+ readonly method: "DELETE";
1218
+ readonly path: "/v1/link/devices/{deviceId}";
1219
+ readonly auth: "token";
1220
+ readonly since: "0.60.0";
1221
+ readonly stream: null;
1222
+ readonly pathParams: readonly ["deviceId"];
1223
+ readonly queryParams: readonly [];
1224
+ };
1225
+ readonly "link.approvals": {
1226
+ readonly id: "link.approvals";
1227
+ readonly method: "GET";
1228
+ readonly path: "/v1/link/approvals";
1229
+ readonly auth: "token";
1230
+ readonly since: "0.91.0";
1231
+ readonly stream: null;
1232
+ readonly pathParams: readonly [];
1233
+ readonly queryParams: readonly [];
1234
+ };
1235
+ readonly "link.approvalsStream": {
1236
+ readonly id: "link.approvalsStream";
1237
+ readonly method: "GET";
1238
+ readonly path: "/v1/link/approvals/stream";
1239
+ readonly auth: "token";
1240
+ readonly since: "0.91.0";
1241
+ readonly stream: "sse";
1242
+ readonly pathParams: readonly [];
1243
+ readonly queryParams: readonly [];
1244
+ };
1245
+ readonly "link.answerApproval": {
1246
+ readonly id: "link.answerApproval";
1247
+ readonly method: "POST";
1248
+ readonly path: "/v1/link/approvals/{approvalId}";
1249
+ readonly auth: "token";
1250
+ readonly since: "0.91.0";
1251
+ readonly stream: null;
1252
+ readonly pathParams: readonly ["approvalId"];
1253
+ readonly queryParams: readonly [];
1254
+ };
1255
+ readonly "link.listFiles": {
1256
+ readonly id: "link.listFiles";
1257
+ readonly method: "GET";
1258
+ readonly path: "/v1/link/files";
1259
+ readonly auth: "token";
1260
+ readonly since: "0.92.0";
1261
+ readonly stream: null;
1262
+ readonly pathParams: readonly [];
1263
+ readonly queryParams: readonly [];
1264
+ };
975
1265
  };
976
1266
  export type OperationId = keyof typeof OPERATIONS;
977
1267
  /** Liveness, identity and pairing. */
@@ -1423,6 +1713,8 @@ export declare class CapabilitiesApi {
1423
1713
  rerank(body: T.RerankRequest, opts?: RequestOptions): Promise<T.RerankResponse>;
1424
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+. */
1425
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>;
1426
1718
  }
1427
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). */
1428
1720
  export declare class RuntimeApi {
@@ -1475,6 +1767,8 @@ export declare class RetrievalApi {
1475
1767
  }>;
1476
1768
  trail?: T.SearchTrail;
1477
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>;
1478
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+. */
1479
1773
  extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
1480
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+. */
@@ -1491,6 +1785,53 @@ export declare class RetrievalApi {
1491
1785
  data: T.ReadResponse;
1492
1786
  }>;
1493
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
+ }
1494
1835
  /** The model ledger — every engine's card. */
1495
1836
  export declare class EnginesApi {
1496
1837
  private readonly rt;
@@ -1603,6 +1944,38 @@ export declare class BrowserApi {
1603
1944
  ok: boolean;
1604
1945
  }>;
1605
1946
  }
1947
+ /** ChatPanel Link — the person's phones and the partner servers they chose reach this gateway end-to-end encrypted (Noise) through a relay or the person's own tunnel, with no port open. Pairing, listing and removing devices is the owner's, at their own computer — token only, and never over Link itself. */
1948
+ export declare class LinkApi {
1949
+ private readonly rt;
1950
+ constructor(rt: Runtime);
1951
+ /** The Link route and every paired device — phones and partner servers — with what each may reach. No keys, tokens or secrets. A partner device (gateway 0.89.0+) carries `kind: partner`, its `partner.name`, `scopes`, the `route` it was paired on and the `host` it connects to; a phone carries `kind: phone` and follows the gateway's route. Changing the route never moves a partner: one whose tunnel door shut with the route says `routeClosed`. — Requires the gateway token. Gateway 0.60.0+. */
1952
+ status(opts?: RequestOptions): Promise<T.LinkStatus>;
1953
+ /** Start a pairing — a phone's QR, or (with `kind partner`) a partner server's one-time code, shown and confirmed first. **A phone** (no `kind`, or `kind: phone`): a room on the route's relay and the QR the phone scans; the answer carries `uri`, `svg`, `expiresAt`, `room`. **A partner server** (`kind: partner`, gateway 0.89.0+): nothing is issued without the owner's yes. Without `confirm: true` the answer is `{ confirmed: false, preview }` — what the partner will be able to do (scopes, agents yes/no), the route and the one host its server will connect to — and nothing is created. With `confirm: true` the answer adds the `code` (`cplink1.…`, one use, 10 minutes), `room`, `route` and `host`. The route is the gateway's own unless `route` names another; a tunnel route reaches the tunnel door with no relay at all, and ChatPanel's hosted relay is used only for `link`. Refused with 403 from a device on Link: a paired device never pairs another. — Requires the gateway token. Gateway 0.60.0+. */
1954
+ pair(body: T.LinkPairRequest, opts?: RequestOptions): Promise<T.LinkPairResult>;
1955
+ /** How devices reach this computer — ChatPanel Link, the person's own relay, Tailscale or Cloudflare Tunnel. Checked, saved in the gateway's config and applied without a restart. Phones follow it; partner devices keep the route they were paired on, and the answer lists which is on which. — Requires the gateway token. Gateway 0.65.0+. */
1956
+ route(body: T.LinkRouteRequest, opts?: RequestOptions): Promise<T.LinkStatus>;
1957
+ /** Remove a paired device now — its relay room, its key and its open connection. — Requires the gateway token. Gateway 0.60.0+. */
1958
+ removeDevice(deviceId: string, opts?: RequestOptions): Promise<{
1959
+ ok: boolean;
1960
+ }>;
1961
+ /** What partners' agents are waiting on the owner for — each request a partner's coding agent made that the owner's settings do not already allow. A partner granted `agents` (gateway 0.90.0+) runs them as the owner's own turn does, and never answers their permission prompts: the request waits here for the OWNER (0.91.0+). Nothing that arrives over Link may list or answer these — 403 for a partner and a phone alike. In memory only. — Requires the gateway token. Gateway 0.91.0+. */
1962
+ approvals(opts?: RequestOptions): Promise<{
1963
+ pending: Array<T.LinkApproval>;
1964
+ }>;
1965
+ /** The waiting requests as they change — one `approvals` event with the whole list on each change, and at connect. — Requires the gateway token. Gateway 0.91.0+. */
1966
+ approvalsStream(opts?: RequestOptions): AsyncIterable<SseFrame<unknown>>;
1967
+ /** The owner's answer — once, this action for the rest of the conversation, everything in it, or no. No answer within the agent's own wait (10 minutes) is a no; revoking the partner denies what it waits on. — Requires the gateway token. Gateway 0.91.0+. */
1968
+ answerApproval(approvalId: string, body: {
1969
+ decision: "allow" | "allow_action" | "allow_all" | "deny";
1970
+ }, opts?: RequestOptions): Promise<{
1971
+ ok: boolean;
1972
+ }>;
1973
+ /** A partner's own folder, from its side — every file it may hold there, with size and last change. Called BY A PARTNER over Link (`createLinkFetch`), granted `files` (0.92.0+; needs `agents`). The folder is the one the owner chose at pairing, where its agents work; a partner may hold its data (`data/`), skills (`.claude/skills/`, `.agents/skills/`), subagents (`.claude/agents/*.md`) and instructions (`CLAUDE.md`, `AGENTS.md`) — never what configures the agent. `GET /v1/link/files/data` lists one root. — Requires the gateway token. Gateway 0.92.0+. */
1974
+ listFiles(opts?: RequestOptions): Promise<{
1975
+ folder?: string;
1976
+ files: Array<T.LinkPartnerFile>;
1977
+ }>;
1978
+ }
1606
1979
  /** The namespaces a client exposes, built on one runtime. */
1607
1980
  export declare function buildApi(rt: Runtime): {
1608
1981
  gateway: GatewayApi;
@@ -1620,9 +1993,11 @@ export declare function buildApi(rt: Runtime): {
1620
1993
  capabilities: CapabilitiesApi;
1621
1994
  runtime: RuntimeApi;
1622
1995
  retrieval: RetrievalApi;
1996
+ knowledge: KnowledgeApi;
1623
1997
  engines: EnginesApi;
1624
1998
  skills: SkillsApi;
1625
1999
  a2a: A2aApi;
1626
2000
  fusions: FusionsApi;
1627
2001
  browser: BrowserApi;
2002
+ link: LinkApi;
1628
2003
  };
@@ -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"] },
@@ -97,6 +118,14 @@ export const OPERATIONS = {
97
118
  "browser.stream": { id: "browser.stream", method: "GET", path: "/v1/browser/stream", auth: "token", since: "0.59.0", stream: "sse", pathParams: [], queryParams: [] },
98
119
  "browser.announce": { id: "browser.announce", method: "POST", path: "/v1/browser/announce", auth: "token", since: "0.59.0", stream: null, pathParams: [], queryParams: [] },
99
120
  "browser.result": { id: "browser.result", method: "POST", path: "/v1/browser/result", auth: "token", since: "0.59.0", stream: null, pathParams: [], queryParams: [] },
121
+ "link.status": { id: "link.status", method: "GET", path: "/v1/link", auth: "token", since: "0.60.0", stream: null, pathParams: [], queryParams: [] },
122
+ "link.pair": { id: "link.pair", method: "POST", path: "/v1/link/pair", auth: "token", since: "0.60.0", stream: null, pathParams: [], queryParams: [] },
123
+ "link.route": { id: "link.route", method: "POST", path: "/v1/link/route", auth: "token", since: "0.65.0", stream: null, pathParams: [], queryParams: [] },
124
+ "link.removeDevice": { id: "link.removeDevice", method: "DELETE", path: "/v1/link/devices/{deviceId}", auth: "token", since: "0.60.0", stream: null, pathParams: ["deviceId"], queryParams: [] },
125
+ "link.approvals": { id: "link.approvals", method: "GET", path: "/v1/link/approvals", auth: "token", since: "0.91.0", stream: null, pathParams: [], queryParams: [] },
126
+ "link.approvalsStream": { id: "link.approvalsStream", method: "GET", path: "/v1/link/approvals/stream", auth: "token", since: "0.91.0", stream: "sse", pathParams: [], queryParams: [] },
127
+ "link.answerApproval": { id: "link.answerApproval", method: "POST", path: "/v1/link/approvals/{approvalId}", auth: "token", since: "0.91.0", stream: null, pathParams: ["approvalId"], queryParams: [] },
128
+ "link.listFiles": { id: "link.listFiles", method: "GET", path: "/v1/link/files", auth: "token", since: "0.92.0", stream: null, pathParams: [], queryParams: [] },
100
129
  };
101
130
  /** Liveness, identity and pairing. */
102
131
  export class GatewayApi {
@@ -450,6 +479,10 @@ export class CapabilitiesApi {
450
479
  decide(body, opts) {
451
480
  return this.rt.request(OPERATIONS["capabilities.decide"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
452
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
+ }
453
486
  }
454
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). */
455
488
  export class RuntimeApi {
@@ -484,6 +517,10 @@ export class RetrievalApi {
484
517
  searchAlias(q, query, opts) {
485
518
  return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
486
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
+ }
487
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+. */
488
525
  extract(body, opts) {
489
526
  return this.rt.request(OPERATIONS["retrieval.extract"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
@@ -497,6 +534,87 @@ export class RetrievalApi {
497
534
  return this.rt.request(OPERATIONS["retrieval.readAlias"], { path: { url }, query: undefined, headers: opts?.headers, body: undefined, opts });
498
535
  }
499
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
+ }
500
618
  /** The model ledger — every engine's card. */
501
619
  export class EnginesApi {
502
620
  rt;
@@ -590,6 +708,43 @@ export class BrowserApi {
590
708
  return this.rt.request(OPERATIONS["browser.result"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
591
709
  }
592
710
  }
711
+ /** ChatPanel Link — the person's phones and the partner servers they chose reach this gateway end-to-end encrypted (Noise) through a relay or the person's own tunnel, with no port open. Pairing, listing and removing devices is the owner's, at their own computer — token only, and never over Link itself. */
712
+ export class LinkApi {
713
+ rt;
714
+ constructor(rt) { this.rt = rt; }
715
+ /** The Link route and every paired device — phones and partner servers — with what each may reach. No keys, tokens or secrets. A partner device (gateway 0.89.0+) carries `kind: partner`, its `partner.name`, `scopes`, the `route` it was paired on and the `host` it connects to; a phone carries `kind: phone` and follows the gateway's route. Changing the route never moves a partner: one whose tunnel door shut with the route says `routeClosed`. — Requires the gateway token. Gateway 0.60.0+. */
716
+ status(opts) {
717
+ return this.rt.request(OPERATIONS["link.status"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
718
+ }
719
+ /** Start a pairing — a phone's QR, or (with `kind partner`) a partner server's one-time code, shown and confirmed first. **A phone** (no `kind`, or `kind: phone`): a room on the route's relay and the QR the phone scans; the answer carries `uri`, `svg`, `expiresAt`, `room`. **A partner server** (`kind: partner`, gateway 0.89.0+): nothing is issued without the owner's yes. Without `confirm: true` the answer is `{ confirmed: false, preview }` — what the partner will be able to do (scopes, agents yes/no), the route and the one host its server will connect to — and nothing is created. With `confirm: true` the answer adds the `code` (`cplink1.…`, one use, 10 minutes), `room`, `route` and `host`. The route is the gateway's own unless `route` names another; a tunnel route reaches the tunnel door with no relay at all, and ChatPanel's hosted relay is used only for `link`. Refused with 403 from a device on Link: a paired device never pairs another. — Requires the gateway token. Gateway 0.60.0+. */
720
+ pair(body, opts) {
721
+ return this.rt.request(OPERATIONS["link.pair"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
722
+ }
723
+ /** How devices reach this computer — ChatPanel Link, the person's own relay, Tailscale or Cloudflare Tunnel. Checked, saved in the gateway's config and applied without a restart. Phones follow it; partner devices keep the route they were paired on, and the answer lists which is on which. — Requires the gateway token. Gateway 0.65.0+. */
724
+ route(body, opts) {
725
+ return this.rt.request(OPERATIONS["link.route"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
726
+ }
727
+ /** Remove a paired device now — its relay room, its key and its open connection. — Requires the gateway token. Gateway 0.60.0+. */
728
+ removeDevice(deviceId, opts) {
729
+ return this.rt.request(OPERATIONS["link.removeDevice"], { path: { deviceId }, query: undefined, headers: opts?.headers, body: undefined, opts });
730
+ }
731
+ /** What partners' agents are waiting on the owner for — each request a partner's coding agent made that the owner's settings do not already allow. A partner granted `agents` (gateway 0.90.0+) runs them as the owner's own turn does, and never answers their permission prompts: the request waits here for the OWNER (0.91.0+). Nothing that arrives over Link may list or answer these — 403 for a partner and a phone alike. In memory only. — Requires the gateway token. Gateway 0.91.0+. */
732
+ approvals(opts) {
733
+ return this.rt.request(OPERATIONS["link.approvals"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
734
+ }
735
+ /** The waiting requests as they change — one `approvals` event with the whole list on each change, and at connect. — Requires the gateway token. Gateway 0.91.0+. */
736
+ approvalsStream(opts) {
737
+ return this.rt.stream(OPERATIONS["link.approvalsStream"], { path: {}, query: undefined, headers: opts?.headers, opts });
738
+ }
739
+ /** The owner's answer — once, this action for the rest of the conversation, everything in it, or no. No answer within the agent's own wait (10 minutes) is a no; revoking the partner denies what it waits on. — Requires the gateway token. Gateway 0.91.0+. */
740
+ answerApproval(approvalId, body, opts) {
741
+ return this.rt.request(OPERATIONS["link.answerApproval"], { path: { approvalId }, query: undefined, headers: opts?.headers, body: body, opts });
742
+ }
743
+ /** A partner's own folder, from its side — every file it may hold there, with size and last change. Called BY A PARTNER over Link (`createLinkFetch`), granted `files` (0.92.0+; needs `agents`). The folder is the one the owner chose at pairing, where its agents work; a partner may hold its data (`data/`), skills (`.claude/skills/`, `.agents/skills/`), subagents (`.claude/agents/*.md`) and instructions (`CLAUDE.md`, `AGENTS.md`) — never what configures the agent. `GET /v1/link/files/data` lists one root. — Requires the gateway token. Gateway 0.92.0+. */
744
+ listFiles(opts) {
745
+ return this.rt.request(OPERATIONS["link.listFiles"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
746
+ }
747
+ }
593
748
  /** The namespaces a client exposes, built on one runtime. */
594
749
  export function buildApi(rt) {
595
750
  return {
@@ -608,10 +763,12 @@ export function buildApi(rt) {
608
763
  capabilities: new CapabilitiesApi(rt),
609
764
  runtime: new RuntimeApi(rt),
610
765
  retrieval: new RetrievalApi(rt),
766
+ knowledge: new KnowledgeApi(rt),
611
767
  engines: new EnginesApi(rt),
612
768
  skills: new SkillsApi(rt),
613
769
  a2a: new A2aApi(rt),
614
770
  fusions: new FusionsApi(rt),
615
771
  browser: new BrowserApi(rt),
772
+ link: new LinkApi(rt),
616
773
  };
617
774
  }
@@ -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;
@@ -1143,6 +1554,135 @@ export interface BrowserInfo {
1143
1554
  kind: "chrome" | "edge" | "firefox" | "brave" | "opera" | "chromium" | "other";
1144
1555
  version?: string;
1145
1556
  }
1557
+ export interface LinkPairRequest {
1558
+ /** Absent is a phone. */
1559
+ kind?: "phone" | "partner";
1560
+ /** A phone pairing — what the phone calls this computer. */
1561
+ name?: string;
1562
+ partner?: {
1563
+ /** What the owner calls the partner. */
1564
+ name: string;
1565
+ };
1566
+ /** What the partner may reach: `models` (GET /v1/models), `chat` (POST /v1/chat/completions and /v1/messages to API models), `agents` (also the coding agents, as the owner's own turn runs them — the Coding Agents settings, the sandbox and the org policy decide what they may do, in the partner's own folder, and the owner answers their approval prompts; needs chat; 0.90.0+), `files` (its data, skills, subagents and instructions in that folder — /v1/link/files; needs agents; 0.92.0+). An array or a comma list; absent is models and chat. */
1567
+ scopes?: Array<"models" | "chat" | "agents" | "files"> | string;
1568
+ /** The partner's one path. Absent is the gateway's own route. */
1569
+ route?: "link" | "relay" | "tailscale" | "cloudflare";
1570
+ /** The https relay for `route relay`. */
1571
+ relay?: string;
1572
+ /** Where the partner's agents work (with `agents`, 0.90.0+): an absolute path or ~/…; absent is ~/.chatpanel/partners/<name>. Never the disk or the home folder. */
1573
+ folder?: string;
1574
+ /** The owner saw the preview and said yes. Without it nothing is issued. */
1575
+ confirm?: boolean;
1576
+ }
1577
+ export interface LinkPartnerPreview {
1578
+ partner: string;
1579
+ scopes: Array<string>;
1580
+ agents: boolean;
1581
+ route: string;
1582
+ /** The one host the partner's server will connect to. */
1583
+ host: string;
1584
+ /** Where its agents will work (with agents). */
1585
+ folder?: string;
1586
+ /** The confirmation as the owner reads it. */
1587
+ lines: Array<string>;
1588
+ }
1589
+ export interface LinkPairResult {
1590
+ /** A phone's QR text. */
1591
+ uri?: string;
1592
+ /** The QR as SVG. */
1593
+ svg?: string;
1594
+ /** Epoch ms when the code stops working. */
1595
+ expiresAt?: number;
1596
+ /** The device id it pairs. */
1597
+ room?: string;
1598
+ /** Partner pairings — false is a preview only. */
1599
+ confirmed?: boolean;
1600
+ preview?: LinkPartnerPreview;
1601
+ /** A partner's one-time `cplink1.` code — give it to the partner through a channel you trust. */
1602
+ code?: string;
1603
+ kind?: string;
1604
+ partner?: {
1605
+ name?: string;
1606
+ };
1607
+ scopes?: Array<string>;
1608
+ route?: string;
1609
+ host?: string;
1610
+ }
1611
+ export interface LinkRouteRequest {
1612
+ route: "link" | "relay" | "tailscale" | "cloudflare";
1613
+ /** The relay (relay) or this computer's tunnel address (tailscale */
1614
+ url?: string;
1615
+ /** A tunnel route keeps ChatPanel Link as the phones' fallback unless false. */
1616
+ fallback?: boolean;
1617
+ }
1618
+ export interface LinkApproval {
1619
+ id: string;
1620
+ /** The partner whose agent asks. */
1621
+ partner: string;
1622
+ device?: string;
1623
+ /** The partner's conversation (`partner.<device>.<thread>`), or the turn's own. */
1624
+ conversation?: string;
1625
+ /** Who asks and what kind of action — "Atlas’s agent asks — run a command?" */
1626
+ title: string;
1627
+ /** The command */
1628
+ body: string;
1629
+ tool?: string;
1630
+ createdAt: number;
1631
+ /** When it becomes a no. */
1632
+ expiresAt: number;
1633
+ }
1634
+ export interface LinkPartnerFile {
1635
+ /** Relative to the partner's folder. */
1636
+ path: string;
1637
+ size: number;
1638
+ modifiedAt?: number;
1639
+ }
1640
+ export interface LinkDevice {
1641
+ id: string;
1642
+ kind?: "phone" | "partner";
1643
+ name: string;
1644
+ pairedAt?: number | null;
1645
+ lastSeen?: number | null;
1646
+ online?: boolean;
1647
+ /** tunnel or relay, while online. */
1648
+ via?: string | null;
1649
+ partner?: {
1650
+ name?: string;
1651
+ };
1652
+ scopes?: Array<string>;
1653
+ /** A partner's route */
1654
+ route?: string | null;
1655
+ host?: string;
1656
+ /** A tunnel partner whose door shut when the gateway's route moved — pair it again to move it. */
1657
+ routeClosed?: boolean;
1658
+ /** Where a partner's agents work (0.90.0+, with agents). */
1659
+ folder?: string;
1660
+ staleRelay?: string;
1661
+ tunnelNeedsRelink?: boolean;
1662
+ }
1663
+ export interface LinkStatus {
1664
+ enabled: boolean;
1665
+ route?: string;
1666
+ relay?: string | null;
1667
+ tunnel?: string | null;
1668
+ problem?: string;
1669
+ routes?: Array<{
1670
+ [key: string]: unknown;
1671
+ }>;
1672
+ setup?: {
1673
+ [key: string]: unknown;
1674
+ };
1675
+ devices: Array<LinkDevice>;
1676
+ /** A phone code waiting to be scanned. */
1677
+ pairing?: {
1678
+ [key: string]: unknown;
1679
+ } | null;
1680
+ /** A partner code waiting to be used. */
1681
+ partnerPairing?: {
1682
+ [key: string]: unknown;
1683
+ } | null;
1684
+ agentSessions?: boolean;
1685
+ }
1146
1686
  export interface BrowserStatus {
1147
1687
  connected: boolean;
1148
1688
  /** Calls waiting on the browser. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.22.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",