@chatpanel/sdk 0.18.0 → 0.22.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.
@@ -272,6 +272,16 @@ export declare const OPERATIONS: {
272
272
  readonly pathParams: readonly [];
273
273
  readonly queryParams: readonly [];
274
274
  };
275
+ readonly "threads.send": {
276
+ readonly id: "threads.send";
277
+ readonly method: "POST";
278
+ readonly path: "/v1/threads/send";
279
+ readonly auth: "token";
280
+ readonly since: "0.69.0";
281
+ readonly stream: null;
282
+ readonly pathParams: readonly [];
283
+ readonly queryParams: readonly [];
284
+ };
275
285
  readonly "memory.forget": {
276
286
  readonly id: "memory.forget";
277
287
  readonly method: "POST";
@@ -642,6 +652,16 @@ export declare const OPERATIONS: {
642
652
  readonly pathParams: readonly [];
643
653
  readonly queryParams: readonly [];
644
654
  };
655
+ readonly "runtime.plan": {
656
+ readonly id: "runtime.plan";
657
+ readonly method: "GET";
658
+ readonly path: "/v1/runtime/plan";
659
+ readonly auth: "open";
660
+ readonly since: "0.74.0";
661
+ readonly stream: null;
662
+ readonly pathParams: readonly [];
663
+ readonly queryParams: readonly ["service", "model", "ctx", "need_mb"];
664
+ };
645
665
  readonly "runtime.engine": {
646
666
  readonly id: "runtime.engine";
647
667
  readonly method: "POST";
@@ -1106,6 +1126,29 @@ export declare class MemoryApi {
1106
1126
  removes?: Array<string>;
1107
1127
  }, opts?: RequestOptions): Promise<T.MemorySyncResponse>;
1108
1128
  }
1129
+ /** The person's chats, asked by one another — any chat's own model answers in it. */
1130
+ export declare class ThreadsApi {
1131
+ private readonly rt;
1132
+ constructor(rt: Runtime);
1133
+ /** Ask one of the person's chats and get its answer; the exchange is added to that chat. The chat's own model or coding agent answers, in that chat (its agent session is resumed), and the question — framed with who asked — and the answer are appended to it. A caller acting for an agent should ask the person first; `dryRun` returns the chat's title and model for that question without running anything. — Requires the gateway token. Gateway 0.69.0+. */
1134
+ send(body: {
1135
+ /** The chat to ask — a record id, chat:… */
1136
+ to: string;
1137
+ message: string;
1138
+ /** The chat asking, so the other one says who asked. */
1139
+ from?: {
1140
+ id?: string;
1141
+ title?: string;
1142
+ };
1143
+ /** Only which chat and model — nothing is run. */
1144
+ dryRun?: boolean;
1145
+ }, opts?: RequestOptions): Promise<{
1146
+ ok: boolean;
1147
+ title: string;
1148
+ model: string;
1149
+ reply?: string;
1150
+ }>;
1151
+ }
1109
1152
  /** The settings every client shares. */
1110
1153
  export declare class PrefsApi {
1111
1154
  private readonly rt;
@@ -1387,6 +1430,13 @@ export declare class RuntimeApi {
1387
1430
  constructor(rt: Runtime);
1388
1431
  /** The runtime — the process sandbox, what is running now, the container engine, the services. One document for Settings › Runtime. `sandbox` is the bridge's own (`/health.sandbox`: enabled, mode `open` | `allowlist` | `none`, the runtime found, the reason when none, the global `extras`, whether a process can get a session of its own, and `refused` — the last hosts any process was refused, names only). `processes` lists every local MCP server running for the user with its sandbox record and the hosts it was refused, and the warm agent processes. `engines` says which container engine exists (`podman` first, `docker`) and whether it can run a container now; when none does, `install` carries the command for this platform — shown to the person, never run by the gateway. `services` is the catalogue: `searxng` with its state (`no-engine` | `engine-stopped` | `absent` | `stopped` | `running`), its loopback URL and whether it answers. — Gateway 0.19.0+. */
1389
1432
  status(opts?: RequestOptions): Promise<T.RuntimeDocument>;
1433
+ /** Will this local model run now? Weights + the KV cache for the context + 10% headroom, against what is free. Checked against what Heatwatch (an optional macOS tool on `127.0.0.1:7878`) says is reclaimable NOW, with the apps to close when it is short — or, without Heatwatch, against the machine's total memory, and `source` says which (`heatwatch` | `total-memory`). The KV cache is counted from the model's `config.json` when it is in the gateway's model cache (`contextCounted` says whether it was). A model the catalogue does not list needs `need_mb`. A native service's start makes the same check and refuses a model that does not fit what is free, unless the start says `force: true`. `runtime.heatwatch: false` stops the gateway asking Heatwatch. — Gateway 0.74.0+. */
1434
+ plan(query?: {
1435
+ service?: string;
1436
+ model?: string;
1437
+ ctx?: number;
1438
+ need_mb?: number;
1439
+ }, opts?: RequestOptions): Promise<T.RuntimePlan>;
1390
1440
  /** Start the container engine (Podman — creates and starts its machine where one is needed). `{ action: 'start' }`. Podman on macOS and Windows runs containers in a machine: made on first start (`podman machine init`), then started. Linux Podman is rootless and needs nothing. Docker is not started by the gateway — the response says so. — Requires the gateway token. Gateway 0.19.0+. */
1391
1441
  engine(name: string, body: {
1392
1442
  action?: "start";
@@ -1396,15 +1446,17 @@ export declare class RuntimeApi {
1396
1446
  action?: "start" | "stop" | "model";
1397
1447
  /** With `action: model` — a catalogue id or a Hugging Face owner/name. */
1398
1448
  model?: string;
1449
+ /** With `action: start` (gateway 0.74+) — start a native model past the live-memory check (`GET /v1/runtime/plan`). */
1450
+ force?: boolean;
1399
1451
  }, opts?: RequestOptions): Promise<T.RuntimeActionResult>;
1400
1452
  }
1401
1453
  /** Web retrieval — search through the provider the user chose, and a page as LLM-ready Markdown, cited where it landed, with its sections (docs/web-retrieval.md). */
1402
1454
  export declare class RetrievalApi {
1403
1455
  private readonly rt;
1404
1456
  constructor(rt: Runtime);
1405
- /** 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+. */
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. 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+. */
1406
1458
  search(body: T.WebSearchRequest, opts?: RequestOptions): Promise<T.WebSearchResponse>;
1407
- /** 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+. */
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. 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+. */
1408
1460
  searchAlias(q: string, query?: {
1409
1461
  read?: number;
1410
1462
  }, opts?: RequestOptions): Promise<{
@@ -1416,7 +1468,12 @@ export declare class RetrievalApi {
1416
1468
  description: string;
1417
1469
  content: string;
1418
1470
  publishedTime?: string;
1471
+ /** The engine that produced it, as on `WebSearchResult.engine`. Since gateway 0.79.0. */
1472
+ engine?: string;
1473
+ /** The kind of door it came through, as on `WebSearchResult.via`. Since gateway 0.79.0. */
1474
+ via?: string;
1419
1475
  }>;
1476
+ trail?: T.SearchTrail;
1420
1477
  }>;
1421
1478
  /** 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+. */
1422
1479
  extract(body: T.ExtractRequest, opts?: RequestOptions): Promise<T.ExtractResponse>;
@@ -1555,6 +1612,7 @@ export declare function buildApi(rt: Runtime): {
1555
1612
  history: HistoryApi;
1556
1613
  events: EventsApi;
1557
1614
  memory: MemoryApi;
1615
+ threads: ThreadsApi;
1558
1616
  prefs: PrefsApi;
1559
1617
  teams: TeamsApi;
1560
1618
  projects: ProjectsApi;
@@ -27,6 +27,7 @@ export const OPERATIONS = {
27
27
  "memory.list": { id: "memory.list", method: "GET", path: "/v1/memory/list", auth: "open", since: null, stream: null, pathParams: [], queryParams: [] },
28
28
  "memory.recall": { id: "memory.recall", method: "POST", path: "/v1/memory/recall", auth: "open", since: null, stream: null, pathParams: [], queryParams: [] },
29
29
  "memory.remember": { id: "memory.remember", method: "POST", path: "/v1/memory/remember", auth: "token", since: null, stream: null, pathParams: [], queryParams: [] },
30
+ "threads.send": { id: "threads.send", method: "POST", path: "/v1/threads/send", auth: "token", since: "0.69.0", stream: null, pathParams: [], queryParams: [] },
30
31
  "memory.forget": { id: "memory.forget", method: "POST", path: "/v1/memory/forget", auth: "token", since: null, stream: null, pathParams: [], queryParams: [] },
31
32
  "memory.sync": { id: "memory.sync", method: "POST", path: "/v1/memory/sync", auth: "token", since: null, stream: null, pathParams: [], queryParams: [] },
32
33
  "prefs.get": { id: "prefs.get", method: "GET", path: "/v1/prefs", auth: "open", since: "0.6.77", stream: null, pathParams: [], queryParams: ["section", "stamps"] },
@@ -64,6 +65,7 @@ export const OPERATIONS = {
64
65
  "agents.rate": { id: "agents.rate", method: "POST", path: "/v1/agents/{agentId}/scorecard", auth: "open", since: "0.6.87", stream: null, pathParams: ["agentId"], queryParams: [] },
65
66
  "capabilities.list": { id: "capabilities.list", method: "GET", path: "/v1/capabilities", auth: "open", since: "0.13.0", stream: null, pathParams: [], queryParams: [] },
66
67
  "runtime.status": { id: "runtime.status", method: "GET", path: "/v1/runtime", auth: "open", since: "0.19.0", stream: null, pathParams: [], queryParams: [] },
68
+ "runtime.plan": { id: "runtime.plan", method: "GET", path: "/v1/runtime/plan", auth: "open", since: "0.74.0", stream: null, pathParams: [], queryParams: ["service", "model", "ctx", "need_mb"] },
67
69
  "runtime.engine": { id: "runtime.engine", method: "POST", path: "/v1/runtime/engines/{name}", auth: "token", since: "0.19.0", stream: null, pathParams: ["name"], queryParams: [] },
68
70
  "runtime.service": { id: "runtime.service", method: "POST", path: "/v1/runtime/services/{id}", auth: "token", since: "0.19.0", stream: null, pathParams: ["id"], queryParams: [] },
69
71
  "capabilities.detect": { id: "capabilities.detect", method: "POST", path: "/v1/detect", auth: "open", since: "0.13.0", stream: null, pathParams: [], queryParams: [] },
@@ -251,6 +253,15 @@ export class MemoryApi {
251
253
  return this.rt.request(OPERATIONS["memory.sync"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
252
254
  }
253
255
  }
256
+ /** The person's chats, asked by one another — any chat's own model answers in it. */
257
+ export class ThreadsApi {
258
+ rt;
259
+ constructor(rt) { this.rt = rt; }
260
+ /** Ask one of the person's chats and get its answer; the exchange is added to that chat. The chat's own model or coding agent answers, in that chat (its agent session is resumed), and the question — framed with who asked — and the answer are appended to it. A caller acting for an agent should ask the person first; `dryRun` returns the chat's title and model for that question without running anything. — Requires the gateway token. Gateway 0.69.0+. */
261
+ send(body, opts) {
262
+ return this.rt.request(OPERATIONS["threads.send"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
263
+ }
264
+ }
254
265
  /** The settings every client shares. */
255
266
  export class PrefsApi {
256
267
  rt;
@@ -448,6 +459,10 @@ export class RuntimeApi {
448
459
  status(opts) {
449
460
  return this.rt.request(OPERATIONS["runtime.status"], { path: {}, query: undefined, headers: opts?.headers, body: undefined, opts });
450
461
  }
462
+ /** Will this local model run now? Weights + the KV cache for the context + 10% headroom, against what is free. Checked against what Heatwatch (an optional macOS tool on `127.0.0.1:7878`) says is reclaimable NOW, with the apps to close when it is short — or, without Heatwatch, against the machine's total memory, and `source` says which (`heatwatch` | `total-memory`). The KV cache is counted from the model's `config.json` when it is in the gateway's model cache (`contextCounted` says whether it was). A model the catalogue does not list needs `need_mb`. A native service's start makes the same check and refuses a model that does not fit what is free, unless the start says `force: true`. `runtime.heatwatch: false` stops the gateway asking Heatwatch. — Gateway 0.74.0+. */
463
+ plan(query, opts) {
464
+ return this.rt.request(OPERATIONS["runtime.plan"], { path: {}, query: query, headers: opts?.headers, body: undefined, opts });
465
+ }
451
466
  /** Start the container engine (Podman — creates and starts its machine where one is needed). `{ action: 'start' }`. Podman on macOS and Windows runs containers in a machine: made on first start (`podman machine init`), then started. Linux Podman is rootless and needs nothing. Docker is not started by the gateway — the response says so. — Requires the gateway token. Gateway 0.19.0+. */
452
467
  engine(name, body, opts) {
453
468
  return this.rt.request(OPERATIONS["runtime.engine"], { path: { name }, query: undefined, headers: opts?.headers, body: body, opts });
@@ -461,11 +476,11 @@ export class RuntimeApi {
461
476
  export class RetrievalApi {
462
477
  rt;
463
478
  constructor(rt) { this.rt = rt; }
464
- /** 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+. */
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. 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+. */
465
480
  search(body, opts) {
466
481
  return this.rt.request(OPERATIONS["retrieval.search"], { path: {}, query: undefined, headers: opts?.headers, body: body, opts });
467
482
  }
468
- /** 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+. */
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. 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+. */
469
484
  searchAlias(q, query, opts) {
470
485
  return this.rt.request(OPERATIONS["retrieval.searchAlias"], { path: { q }, query: query, headers: opts?.headers, body: undefined, opts });
471
486
  }
@@ -585,6 +600,7 @@ export function buildApi(rt) {
585
600
  history: new HistoryApi(rt),
586
601
  events: new EventsApi(rt),
587
602
  memory: new MemoryApi(rt),
603
+ threads: new ThreadsApi(rt),
588
604
  prefs: new PrefsApi(rt),
589
605
  teams: new TeamsApi(rt),
590
606
  projects: new ProjectsApi(rt),
@@ -173,6 +173,35 @@ export interface RuntimeActionResult {
173
173
  restarted?: boolean;
174
174
  /** A model pick that fits but is tight for the engine's memory. */
175
175
  note?: string;
176
+ plan?: RuntimePlan;
177
+ }
178
+ /** Whether a local model fits in memory (gateway 0.74+) — `GET /v1/runtime/plan`, and on a start the live-memory check refused. */
179
+ export interface RuntimePlan {
180
+ ok: boolean;
181
+ service?: string;
182
+ model?: string;
183
+ /** Weights + KV cache + 10% headroom. */
184
+ needMB?: number;
185
+ weightsMB?: number;
186
+ /** The KV cache for the context; null when the model's config.json is not on disk. */
187
+ kvMB?: number;
188
+ context?: number;
189
+ contextCounted?: boolean;
190
+ source?: "heatwatch" | "total-memory";
191
+ fits?: boolean;
192
+ /** Heatwatch's answer; null without it. */
193
+ live?: {
194
+ fits?: boolean;
195
+ needMB?: number;
196
+ availableMB?: number;
197
+ shortfallMB?: number;
198
+ fitsGPULimit?: boolean;
199
+ gpuWiredLimitMB?: number;
200
+ /** The apps to close to make room. */
201
+ close?: Array<string>;
202
+ };
203
+ /** One sentence for the person. */
204
+ advice?: string;
176
205
  }
177
206
  export interface CapabilitiesDocument {
178
207
  capabilities: Array<Capability>;
@@ -222,6 +251,8 @@ export interface DetectRequest {
222
251
  labels?: Array<string>;
223
252
  /** Refused before running if the provider's record predicts it cannot be met. */
224
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;
225
256
  }
226
257
  export interface DetectedEntity {
227
258
  value: string;
@@ -326,8 +357,10 @@ export interface WebSearchResult {
326
357
  url: string;
327
358
  title: string;
328
359
  snippet: string;
329
- /** 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. */
330
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;
331
364
  /** SearXNG: every engine that returned it. */
332
365
  engines?: Array<string>;
333
366
  /** SearXNG's fused score. */
@@ -351,6 +384,36 @@ export interface WebSearchResponse {
351
384
  query?: string;
352
385
  provider: string;
353
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;
354
417
  }
355
418
  /** Either `name` + `data` (open a document) or `hash` + `page` (read one page of an open document). */
356
419
  export interface ExtractRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/sdk",
3
- "version": "0.18.0",
3
+ "version": "0.22.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",