@chatpanel/sdk 0.20.0 → 0.24.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`:
@@ -972,6 +972,86 @@ export declare const OPERATIONS: {
972
972
  readonly pathParams: readonly [];
973
973
  readonly queryParams: readonly [];
974
974
  };
975
+ readonly "link.status": {
976
+ readonly id: "link.status";
977
+ readonly method: "GET";
978
+ readonly path: "/v1/link";
979
+ readonly auth: "token";
980
+ readonly since: "0.60.0";
981
+ readonly stream: null;
982
+ readonly pathParams: readonly [];
983
+ readonly queryParams: readonly [];
984
+ };
985
+ readonly "link.pair": {
986
+ readonly id: "link.pair";
987
+ readonly method: "POST";
988
+ readonly path: "/v1/link/pair";
989
+ readonly auth: "token";
990
+ readonly since: "0.60.0";
991
+ readonly stream: null;
992
+ readonly pathParams: readonly [];
993
+ readonly queryParams: readonly [];
994
+ };
995
+ readonly "link.route": {
996
+ readonly id: "link.route";
997
+ readonly method: "POST";
998
+ readonly path: "/v1/link/route";
999
+ readonly auth: "token";
1000
+ readonly since: "0.65.0";
1001
+ readonly stream: null;
1002
+ readonly pathParams: readonly [];
1003
+ readonly queryParams: readonly [];
1004
+ };
1005
+ readonly "link.removeDevice": {
1006
+ readonly id: "link.removeDevice";
1007
+ readonly method: "DELETE";
1008
+ readonly path: "/v1/link/devices/{deviceId}";
1009
+ readonly auth: "token";
1010
+ readonly since: "0.60.0";
1011
+ readonly stream: null;
1012
+ readonly pathParams: readonly ["deviceId"];
1013
+ readonly queryParams: readonly [];
1014
+ };
1015
+ readonly "link.approvals": {
1016
+ readonly id: "link.approvals";
1017
+ readonly method: "GET";
1018
+ readonly path: "/v1/link/approvals";
1019
+ readonly auth: "token";
1020
+ readonly since: "0.91.0";
1021
+ readonly stream: null;
1022
+ readonly pathParams: readonly [];
1023
+ readonly queryParams: readonly [];
1024
+ };
1025
+ readonly "link.approvalsStream": {
1026
+ readonly id: "link.approvalsStream";
1027
+ readonly method: "GET";
1028
+ readonly path: "/v1/link/approvals/stream";
1029
+ readonly auth: "token";
1030
+ readonly since: "0.91.0";
1031
+ readonly stream: "sse";
1032
+ readonly pathParams: readonly [];
1033
+ readonly queryParams: readonly [];
1034
+ };
1035
+ readonly "link.answerApproval": {
1036
+ readonly id: "link.answerApproval";
1037
+ readonly method: "POST";
1038
+ readonly path: "/v1/link/approvals/{approvalId}";
1039
+ readonly auth: "token";
1040
+ readonly since: "0.91.0";
1041
+ readonly stream: null;
1042
+ readonly pathParams: readonly ["approvalId"];
1043
+ readonly queryParams: readonly [];
1044
+ };
1045
+ readonly "link.listFiles": {
1046
+ readonly id: "link.listFiles";
1047
+ readonly method: "GET";
1048
+ readonly path: "/v1/link/files";
1049
+ readonly auth: "token";
1050
+ readonly since: "0.92.0";
1051
+ readonly stream: null;
1052
+ readonly pathParams: readonly [];
1053
+ readonly queryParams: readonly [];
1054
+ };
975
1055
  };
976
1056
  export type OperationId = keyof typeof OPERATIONS;
977
1057
  /** Liveness, identity and pairing. */
@@ -1454,9 +1534,9 @@ export declare class RuntimeApi {
1454
1534
  export declare class RetrievalApi {
1455
1535
  private readonly rt;
1456
1536
  constructor(rt: Runtime);
1457
- /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. — Gateway 0.15.0+. */
1537
+ /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. Since gateway 0.78.0 `serp` asks one built-in engine per search (DuckDuckGo, Startpage, Bing) plus any search API the person added in the gateway's settings (Exa, Brave, Tavily, Serper, SerpApi, Google Programmable Search, Jina, Mwmbl, or one they describe — keyed ones first); an engine that refuses rests for a while. Since gateway 0.79.0 every result is tagged with its `engine` and `via` (the kind of door it came through), and `trail` says what each provider and engine asked did and, when nothing came back, why — `nothing` (they answered, found nothing) reads differently from `blocked`, `resting` or `offline`. Both are optional: an older gateway sends neither. — Gateway 0.15.0+. */
1458
1538
  search(body: T.WebSearchRequest, opts?: RequestOptions): Promise<T.WebSearchResponse>;
1459
- /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. — Gateway 0.15.0+. */
1539
+ /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. Since gateway 0.79.0 each item may carry `engine` and `via`, and the top level `trail`, exactly as `POST /v1/search` does (a Jina reader ignores them). — Gateway 0.15.0+. */
1460
1540
  searchAlias(q: string, query?: {
1461
1541
  read?: number;
1462
1542
  }, opts?: RequestOptions): Promise<{
@@ -1468,7 +1548,12 @@ export declare class RetrievalApi {
1468
1548
  description: string;
1469
1549
  content: string;
1470
1550
  publishedTime?: string;
1551
+ /** The engine that produced it, as on `WebSearchResult.engine`. Since gateway 0.79.0. */
1552
+ engine?: string;
1553
+ /** The kind of door it came through, as on `WebSearchResult.via`. Since gateway 0.79.0. */
1554
+ via?: string;
1471
1555
  }>;
1556
+ trail?: T.SearchTrail;
1472
1557
  }>;
1473
1558
  /** 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+. */
1474
1559
  extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
@@ -1598,6 +1683,38 @@ export declare class BrowserApi {
1598
1683
  ok: boolean;
1599
1684
  }>;
1600
1685
  }
1686
+ /** 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. */
1687
+ export declare class LinkApi {
1688
+ private readonly rt;
1689
+ constructor(rt: Runtime);
1690
+ /** 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+. */
1691
+ status(opts?: RequestOptions): Promise<T.LinkStatus>;
1692
+ /** 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+. */
1693
+ pair(body: T.LinkPairRequest, opts?: RequestOptions): Promise<T.LinkPairResult>;
1694
+ /** 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+. */
1695
+ route(body: T.LinkRouteRequest, opts?: RequestOptions): Promise<T.LinkStatus>;
1696
+ /** Remove a paired device now — its relay room, its key and its open connection. — Requires the gateway token. Gateway 0.60.0+. */
1697
+ removeDevice(deviceId: string, opts?: RequestOptions): Promise<{
1698
+ ok: boolean;
1699
+ }>;
1700
+ /** 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+. */
1701
+ approvals(opts?: RequestOptions): Promise<{
1702
+ pending: Array<T.LinkApproval>;
1703
+ }>;
1704
+ /** 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+. */
1705
+ approvalsStream(opts?: RequestOptions): AsyncIterable<SseFrame<unknown>>;
1706
+ /** 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+. */
1707
+ answerApproval(approvalId: string, body: {
1708
+ decision: "allow" | "allow_action" | "allow_all" | "deny";
1709
+ }, opts?: RequestOptions): Promise<{
1710
+ ok: boolean;
1711
+ }>;
1712
+ /** 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+. */
1713
+ listFiles(opts?: RequestOptions): Promise<{
1714
+ folder?: string;
1715
+ files: Array<T.LinkPartnerFile>;
1716
+ }>;
1717
+ }
1601
1718
  /** The namespaces a client exposes, built on one runtime. */
1602
1719
  export declare function buildApi(rt: Runtime): {
1603
1720
  gateway: GatewayApi;
@@ -1620,4 +1737,5 @@ export declare function buildApi(rt: Runtime): {
1620
1737
  a2a: A2aApi;
1621
1738
  fusions: FusionsApi;
1622
1739
  browser: BrowserApi;
1740
+ link: LinkApi;
1623
1741
  };
@@ -97,6 +97,14 @@ export const OPERATIONS = {
97
97
  "browser.stream": { id: "browser.stream", method: "GET", path: "/v1/browser/stream", auth: "token", since: "0.59.0", stream: "sse", pathParams: [], queryParams: [] },
98
98
  "browser.announce": { id: "browser.announce", method: "POST", path: "/v1/browser/announce", auth: "token", since: "0.59.0", stream: null, pathParams: [], queryParams: [] },
99
99
  "browser.result": { id: "browser.result", method: "POST", path: "/v1/browser/result", auth: "token", since: "0.59.0", stream: null, pathParams: [], queryParams: [] },
100
+ "link.status": { id: "link.status", method: "GET", path: "/v1/link", auth: "token", since: "0.60.0", stream: null, pathParams: [], queryParams: [] },
101
+ "link.pair": { id: "link.pair", method: "POST", path: "/v1/link/pair", auth: "token", since: "0.60.0", stream: null, pathParams: [], queryParams: [] },
102
+ "link.route": { id: "link.route", method: "POST", path: "/v1/link/route", auth: "token", since: "0.65.0", stream: null, pathParams: [], queryParams: [] },
103
+ "link.removeDevice": { id: "link.removeDevice", method: "DELETE", path: "/v1/link/devices/{deviceId}", auth: "token", since: "0.60.0", stream: null, pathParams: ["deviceId"], queryParams: [] },
104
+ "link.approvals": { id: "link.approvals", method: "GET", path: "/v1/link/approvals", auth: "token", since: "0.91.0", stream: null, pathParams: [], queryParams: [] },
105
+ "link.approvalsStream": { id: "link.approvalsStream", method: "GET", path: "/v1/link/approvals/stream", auth: "token", since: "0.91.0", stream: "sse", pathParams: [], queryParams: [] },
106
+ "link.answerApproval": { id: "link.answerApproval", method: "POST", path: "/v1/link/approvals/{approvalId}", auth: "token", since: "0.91.0", stream: null, pathParams: ["approvalId"], queryParams: [] },
107
+ "link.listFiles": { id: "link.listFiles", method: "GET", path: "/v1/link/files", auth: "token", since: "0.92.0", stream: null, pathParams: [], queryParams: [] },
100
108
  };
101
109
  /** Liveness, identity and pairing. */
102
110
  export class GatewayApi {
@@ -476,11 +484,11 @@ export class RuntimeApi {
476
484
  export class RetrievalApi {
477
485
  rt;
478
486
  constructor(rt) { this.rt = rt; }
479
- /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. — Gateway 0.15.0+. */
487
+ /** Search the web through the provider this gateway is configured with; optionally read the top results in the same request. The `search` capability (docs/web-retrieval.md §4.1). Providers are listed by `GET /v1/capabilities`: `serp` (a results page fetched and read with the shared rules — no install, the default) and `searxng` (the user's own metasearch, preferred the moment it answers). `read: N` reads the top N results in parallel in this request, each carrying a §4.2 document under `read` — one round-trip instead of 1 + N; a page that will not be read keeps its snippet with `read.restricted.reason`. The query goes through layer-1 redaction (emails, cards, keys, dictionary terms — never the name detector) before it leaves; what was replaced is dropped and `redacted: true` says so; a query with nothing left is 400 `unsafe_query`. `freshness` and `lang` are honoured by SearXNG; `site` by both. `budgetMs` covers the search and its reads and is refused (503 `over_budget`) from the provider's record. `engines` names what was actually asked, so an empty list can be told from a blocked one. Since gateway 0.78.0 `serp` asks one built-in engine per search (DuckDuckGo, Startpage, Bing) plus any search API the person added in the gateway's settings (Exa, Brave, Tavily, Serper, SerpApi, Google Programmable Search, Jina, Mwmbl, or one they describe — keyed ones first); an engine that refuses rests for a while. Since gateway 0.79.0 every result is tagged with its `engine` and `via` (the kind of door it came through), and `trail` says what each provider and engine asked did and, when nothing came back, why — `nothing` (they answered, found nothing) reads differently from `blocked`, `resting` or `offline`. Both are optional: an older gateway sends neither. — Gateway 0.15.0+. */
480
488
  search(body, opts) {
481
489
  return this.rt.request(OPERATIONS["retrieval.search"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
482
490
  }
483
- /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. — Gateway 0.15.0+. */
491
+ /** The s.jina.ai-shaped alias — `GET /v1/search/<query>` — the top results WITH their content. Same search as `POST /v1/search` with `read: 5` (`?read=N`, 0–10, changes it), answered in the shape the shipped ChatPanel extension's *Web search API* engine already reads: `{ code, status, data: [{ url, title, description, content, publishedTime? }] }` where `content` is the page's Markdown when it was read and the snippet otherwise — nothing needs fetching on the client. A Bearer token is accepted and ignored. Since gateway 0.79.0 each item may carry `engine` and `via`, and the top level `trail`, exactly as `POST /v1/search` does (a Jina reader ignores them). — Gateway 0.15.0+. */
484
492
  searchAlias(q, query, opts) {
485
493
  return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
486
494
  }
@@ -590,6 +598,43 @@ export class BrowserApi {
590
598
  return this.rt.request(OPERATIONS["browser.result"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
591
599
  }
592
600
  }
601
+ /** 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. */
602
+ export class LinkApi {
603
+ rt;
604
+ constructor(rt) { this.rt = rt; }
605
+ /** 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+. */
606
+ status(opts) {
607
+ return this.rt.request(OPERATIONS["link.status"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
608
+ }
609
+ /** 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+. */
610
+ pair(body, opts) {
611
+ return this.rt.request(OPERATIONS["link.pair"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
612
+ }
613
+ /** 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+. */
614
+ route(body, opts) {
615
+ return this.rt.request(OPERATIONS["link.route"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
616
+ }
617
+ /** Remove a paired device now — its relay room, its key and its open connection. — Requires the gateway token. Gateway 0.60.0+. */
618
+ removeDevice(deviceId, opts) {
619
+ return this.rt.request(OPERATIONS["link.removeDevice"], { path: { deviceId }, query: undefined, headers: opts?.headers, body: undefined, opts });
620
+ }
621
+ /** 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+. */
622
+ approvals(opts) {
623
+ return this.rt.request(OPERATIONS["link.approvals"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
624
+ }
625
+ /** 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+. */
626
+ approvalsStream(opts) {
627
+ return this.rt.stream(OPERATIONS["link.approvalsStream"], { path: {}, query: undefined, headers: opts?.headers, opts });
628
+ }
629
+ /** 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+. */
630
+ answerApproval(approvalId, body, opts) {
631
+ return this.rt.request(OPERATIONS["link.answerApproval"], { path: { approvalId }, query: undefined, headers: opts?.headers, body: body, opts });
632
+ }
633
+ /** 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+. */
634
+ listFiles(opts) {
635
+ return this.rt.request(OPERATIONS["link.listFiles"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
636
+ }
637
+ }
593
638
  /** The namespaces a client exposes, built on one runtime. */
594
639
  export function buildApi(rt) {
595
640
  return {
@@ -613,5 +658,6 @@ export function buildApi(rt) {
613
658
  a2a: new A2aApi(rt),
614
659
  fusions: new FusionsApi(rt),
615
660
  browser: new BrowserApi(rt),
661
+ link: new LinkApi(rt),
616
662
  };
617
663
  }
@@ -251,6 +251,8 @@ export interface DetectRequest {
251
251
  labels?: Array<string>;
252
252
  /** Refused before running if the provider's record predicts it cannot be met. */
253
253
  budgetMs?: number;
254
+ /** Return every span the provider finds, second-guessing none (redaction strictness 'strict'). A provider that does not filter ignores it. Since gateway 0.76.0. */
255
+ strict?: boolean;
254
256
  }
255
257
  export interface DetectedEntity {
256
258
  value: string;
@@ -355,8 +357,10 @@ export interface WebSearchResult {
355
357
  url: string;
356
358
  title: string;
357
359
  snippet: string;
358
- /** The engine that produced it (SearXNG: the first of `engines`; serp: the results page asked). */
360
+ /** The engine that produced it (SearXNG: the first of `engines`; serp: the engine asked — `duckduckgo`, `startpage`, `bing`, or `api:<id>` for a search API such as `api:exa`). Since gateway 0.79.0 every result carries it; the provider id when nothing finer is known. */
359
361
  engine?: string;
362
+ /** The kind of door it came through: `gateway` · `searxng` · `api` (a search API) · `page` (a results page read) · `browser` (the person's own browser). A client meeting a value it does not know shows it as it is. Since gateway 0.79.0. */
363
+ via?: string;
360
364
  /** SearXNG: every engine that returned it. */
361
365
  engines?: Array<string>;
362
366
  /** SearXNG's fused score. */
@@ -380,6 +384,36 @@ export interface WebSearchResponse {
380
384
  query?: string;
381
385
  provider: string;
382
386
  ms: number;
387
+ trail?: SearchTrail;
388
+ }
389
+ /** What the search did — each provider and engine asked, what it did, which are resting — and how it ended. Optional on every response that carries it; an older gateway sends none. Since gateway 0.79.0. */
390
+ export interface SearchTrail {
391
+ /** How it ended: `answered` (results came back) · `nothing` (engines answered, none had anything) · `blocked` (every engine asked refused or timed out) · `resting` (nothing was asked: every engine is resting after earlier refusals) · `offline` (every engine failed at the network) · `no-engines`. A client meeting a value it does not know treats it as no results. */
392
+ status: string;
393
+ /** In the order asked: the provider tried first (`searxng`, or each engine and API `serp` asked), then the other provider when the first came back empty. */
394
+ asked: Array<SearchTrailAsk>;
395
+ /** Engines resting after refusing earlier, and until when. */
396
+ resting: Array<SearchTrailResting>;
397
+ }
398
+ export interface SearchTrailAsk {
399
+ /** The engine or provider asked — `searxng`, `serp`, `duckduckgo`, `startpage`, `bing`, `api:<id>`. */
400
+ id: string;
401
+ /** `answered` · `empty` (answered, found nothing) · `refused` (a refusing status, a timeout or no answer at all). */
402
+ outcome: string;
403
+ /** How many results it returned. */
404
+ found?: number;
405
+ /** The HTTP status of a refusal (429, 403, …), when there was one. */
406
+ status?: number;
407
+ /** It did not answer within its share of the budget. */
408
+ timedOut?: boolean;
409
+ /** It failed at the network — no status at all. */
410
+ network?: boolean;
411
+ }
412
+ export interface SearchTrailResting {
413
+ /** The resting engine. */
414
+ id: string;
415
+ /** When it may be asked again, ms since epoch. */
416
+ until: number;
383
417
  }
384
418
  /** Either `name` + `data` (open a document) or `hash` + `page` (read one page of an open document). */
385
419
  export interface ExtractRequest {
@@ -1109,6 +1143,135 @@ export interface BrowserInfo {
1109
1143
  kind: "chrome" | "edge" | "firefox" | "brave" | "opera" | "chromium" | "other";
1110
1144
  version?: string;
1111
1145
  }
1146
+ export interface LinkPairRequest {
1147
+ /** Absent is a phone. */
1148
+ kind?: "phone" | "partner";
1149
+ /** A phone pairing — what the phone calls this computer. */
1150
+ name?: string;
1151
+ partner?: {
1152
+ /** What the owner calls the partner. */
1153
+ name: string;
1154
+ };
1155
+ /** 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. */
1156
+ scopes?: Array<"models" | "chat" | "agents" | "files"> | string;
1157
+ /** The partner's one path. Absent is the gateway's own route. */
1158
+ route?: "link" | "relay" | "tailscale" | "cloudflare";
1159
+ /** The https relay for `route relay`. */
1160
+ relay?: string;
1161
+ /** 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. */
1162
+ folder?: string;
1163
+ /** The owner saw the preview and said yes. Without it nothing is issued. */
1164
+ confirm?: boolean;
1165
+ }
1166
+ export interface LinkPartnerPreview {
1167
+ partner: string;
1168
+ scopes: Array<string>;
1169
+ agents: boolean;
1170
+ route: string;
1171
+ /** The one host the partner's server will connect to. */
1172
+ host: string;
1173
+ /** Where its agents will work (with agents). */
1174
+ folder?: string;
1175
+ /** The confirmation as the owner reads it. */
1176
+ lines: Array<string>;
1177
+ }
1178
+ export interface LinkPairResult {
1179
+ /** A phone's QR text. */
1180
+ uri?: string;
1181
+ /** The QR as SVG. */
1182
+ svg?: string;
1183
+ /** Epoch ms when the code stops working. */
1184
+ expiresAt?: number;
1185
+ /** The device id it pairs. */
1186
+ room?: string;
1187
+ /** Partner pairings — false is a preview only. */
1188
+ confirmed?: boolean;
1189
+ preview?: LinkPartnerPreview;
1190
+ /** A partner's one-time `cplink1.` code — give it to the partner through a channel you trust. */
1191
+ code?: string;
1192
+ kind?: string;
1193
+ partner?: {
1194
+ name?: string;
1195
+ };
1196
+ scopes?: Array<string>;
1197
+ route?: string;
1198
+ host?: string;
1199
+ }
1200
+ export interface LinkRouteRequest {
1201
+ route: "link" | "relay" | "tailscale" | "cloudflare";
1202
+ /** The relay (relay) or this computer's tunnel address (tailscale */
1203
+ url?: string;
1204
+ /** A tunnel route keeps ChatPanel Link as the phones' fallback unless false. */
1205
+ fallback?: boolean;
1206
+ }
1207
+ export interface LinkApproval {
1208
+ id: string;
1209
+ /** The partner whose agent asks. */
1210
+ partner: string;
1211
+ device?: string;
1212
+ /** The partner's conversation (`partner.<device>.<thread>`), or the turn's own. */
1213
+ conversation?: string;
1214
+ /** Who asks and what kind of action — "Atlas’s agent asks — run a command?" */
1215
+ title: string;
1216
+ /** The command */
1217
+ body: string;
1218
+ tool?: string;
1219
+ createdAt: number;
1220
+ /** When it becomes a no. */
1221
+ expiresAt: number;
1222
+ }
1223
+ export interface LinkPartnerFile {
1224
+ /** Relative to the partner's folder. */
1225
+ path: string;
1226
+ size: number;
1227
+ modifiedAt?: number;
1228
+ }
1229
+ export interface LinkDevice {
1230
+ id: string;
1231
+ kind?: "phone" | "partner";
1232
+ name: string;
1233
+ pairedAt?: number | null;
1234
+ lastSeen?: number | null;
1235
+ online?: boolean;
1236
+ /** tunnel or relay, while online. */
1237
+ via?: string | null;
1238
+ partner?: {
1239
+ name?: string;
1240
+ };
1241
+ scopes?: Array<string>;
1242
+ /** A partner's route */
1243
+ route?: string | null;
1244
+ host?: string;
1245
+ /** A tunnel partner whose door shut when the gateway's route moved — pair it again to move it. */
1246
+ routeClosed?: boolean;
1247
+ /** Where a partner's agents work (0.90.0+, with agents). */
1248
+ folder?: string;
1249
+ staleRelay?: string;
1250
+ tunnelNeedsRelink?: boolean;
1251
+ }
1252
+ export interface LinkStatus {
1253
+ enabled: boolean;
1254
+ route?: string;
1255
+ relay?: string | null;
1256
+ tunnel?: string | null;
1257
+ problem?: string;
1258
+ routes?: Array<{
1259
+ [key: string]: unknown;
1260
+ }>;
1261
+ setup?: {
1262
+ [key: string]: unknown;
1263
+ };
1264
+ devices: Array<LinkDevice>;
1265
+ /** A phone code waiting to be scanned. */
1266
+ pairing?: {
1267
+ [key: string]: unknown;
1268
+ } | null;
1269
+ /** A partner code waiting to be used. */
1270
+ partnerPairing?: {
1271
+ [key: string]: unknown;
1272
+ } | null;
1273
+ agentSessions?: boolean;
1274
+ }
1112
1275
  export interface BrowserStatus {
1113
1276
  connected: boolean;
1114
1277
  /** Calls waiting on the browser. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.20.0",
3
+ "version": "0.24.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",