openvibers/openvibe.sdk Commits
0.70.0: openvibe-sdk/search: the Search Fabric (fabric(), query() with scopes, providers(), types) (#97)
Changes
@@@ -3,6 +3,26 @@All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minorrelease may change an API and says so here.++## 0.70.0 (2026-10-28)++++- **`openvibe-sdk/search`: the Search Fabric** (Contracts 0.225.0 `search.fabric.query`; plan 2026-10-28 §4.5). One++ query over several scopes, routed the cheapest way that answers.++ - **`search.fabric(text, { scopes, freshness, depth, answer, limit, cursor, owner, type, lang, site })`** returns++ `search.fabric-result@1`:++ - `results`: each has a scope and a kind (a document in the index, or a web page with its provider, URL and++ dates);++ - `groups`, `citations`, and `route.explain` (what each step did and what it cost).++ - **Scopes:**++ - `network` and `mine` (the person's own; a service passes `actingSubject`);++ - `web`: OpenVibe's open index first, then DeepSeek for a signed-in caller or a service, then Wikipedia,++ cached;++ - `news`, `images`, `video`, `products`, `people`, `places` and `code`.++ - `search.query(text, { scopes })` is the same call; without `scopes`, `query()` is the index search as before.++ - `search.providers()` lists the web ladder's `search.provider-offer@1` items.++ - Reads use GET, so the client may retry them.++ - Types: `FabricOptions`, `FabricAnswer`, `FabricResult`, `FabricExplainStep`, `ProviderOffer`; `fabricOf()` builds++ the query string.++## 0.69.0 (2026-10-28)- **`openvibe-sdk/tools`: domain history** (OpenVibe.Tools' `/api/v1/domains`, 2026-10-28). What the WHOIS and RDAP@@@ -2,14 +2,14 @@> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.69.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.++**Status:** alpha, v0.70.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.**If a capability is not in the SDK, it is not public.** Apps call services through `openvibe-sdk` and never build internal routes themselves. A route with no SDK wrapper is internal, even when you can reach it, and it can change without notice. To make a capability public, first define it in OpenVibe.Contracts, then wrap it here.```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.69.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.70.0```It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from Contracts v0.86.0, a devDependency the tests check them against).@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.69.0",++ "version": "0.70.0","plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30","deployed": false,"deployment": "none: a package released as git tags; services and apps pin a tag",@@@ -1,4 +1,4 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.69.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.70.0, MIT). Do not edit.// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces// (auth, registry, modules, realtime, media, community, bot, search, themes, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */@@@ -43,7 +43,7 @@ const { paginate, offsetPager } = __load(7);const semver = __load(6);/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.69.0';++const SDK_VERSION = '0.70.0';module.exports = {createClient,@@@ -1989,6 +1989,15 @@ function (module, exports) {* const { suggestions } = await search.suggest('japan');* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see*++ * The Search Fabric (Contracts 0.225.0, search.fabric.query; also the MCP tool openvibe.search): one query over++ * several scopes, routed the cheapest way that answers.++ * const r = await search.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'standard' });++ * // r: { results (each with scope, kind document|page, url, provider for the web), groups, citations,++ * // route: { explain, cost_usd }, next_cursor } — query(text, { scopes }) is the same call++ * const { providers } = await search.providers(); // the web ladder's offers (price, availability, today's use)++ * Anonymous callers get the index, the open index and cached web answers; a person or a service also reaches the++ * paid providers within OpenVibe's daily caps; `mine` needs a person (actingSubject for a service).++ ** Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may@@@ -2001,6 +2010,17 @@ const { isOpenVibeError } = __load(3);const { isActingSubjectId } = __load(5);const enc = encodeURIComponent;++const FABRIC_KEYS = ['freshness', 'depth', 'limit', 'cursor', 'owner', 'type', 'lang', 'site'];++++/** The query string of GET /api/v1/query (search.fabric-request@1, GET form: scopes comma-separated). */++function fabricOf(text, o = {}) {++ const q = { q: String(text == null ? '' : text) };++ const scopes = Array.isArray(o.scopes) ? o.scopes : o.scopes ? String(o.scopes).split(',') : ['network'];++ q.scopes = scopes.map((x) => String(x).trim()).filter(Boolean).join(',');++ for (const k of FABRIC_KEYS) if (o[k] !== undefined && o[k] !== null && o[k] !== '') q[k] = o[k];++ if (o.answer) q.answer = 'true';++ return q;++}const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;function queryOf(text, o = {}) {@@@ -2041,9 +2061,15 @@ function createSearchClient(client, defaults = {}) {}const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });++ /** The Search Fabric: GET, so the core client may retry it safely. */++ const fabric = (text, o = {}) => call({ path: pathWith('/api/v1/query', fabricOf(text, o)) }, o);return {-- /** { results, next_cursor, facets? } — one page. */-- query: (text, o = {}) => call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o),++ /** { results, next_cursor, facets? } — one page. With `scopes`, the Search Fabric (fabric()). */++ query: (text, o = {}) => (o.scopes ? fabric(text, o) : call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o)),++ /** search.fabric-result@1 — one query over network, mine, web and the vertical scopes. */++ fabric,++ /** { providers: search.provider-offer@1[] } — the web ladder's providers. */++ providers: (o = {}) => call({ path: '/api/v1/query/providers' }, o),/** Every result, page after page (cursor), until Search has no more or `max` is reached. */async *iterate(text, o = {}) {let cursor = o.cursor || null;@@@ -2062,7 +2088,7 @@ function createSearchClient(client, defaults = {}) {};}--module.exports = { createSearchClient, queryOf };++module.exports = { createSearchClient, queryOf, fabricOf };},// ── 17: src/themes.js ───────────────────────────────────────────────function (module, exports) {@@@ -235,6 +235,7 @@"search": {"object": ["createSearchClient",++ "fabricOf","queryOf"]},@@@ -634,6 +635,7 @@},"openvibe-sdk/search": {"createSearchClient": "function",++ "fabricOf": "function","queryOf": "function"},"openvibe-sdk/service": {@@@ -2,6 +2,6 @@import cjs from '../src/search.js';export const {-- createSearchClient, queryOf,++ createSearchClient, queryOf, fabricOf,} = cjs;export default cjs;@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.69.0",++ "version": "0.70.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.69.0",++ "version": "0.70.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -14,7 +14,7 @@"devDependencies": {"@electric-sql/pglite": "^0.5.8","iovalkey": "^0.4.0",-- "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",++ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0","pg": "^8.23.0"},"engines": {@@@ -198,9 +198,9 @@"license": "MIT"},"node_modules/openvibe-contracts": {-- "version": "0.222.0",-- "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",-- "integrity": "sha512-wdUQCilq9glRMwfxEswbIj3l0QQqKDXZAi2+CR5Mlh34rZjI1Q+7GlAoR0UtNwZAgtLwXhPxFyJ/aPk8lcDG1Q==",++ "version": "0.225.0",++ "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0",++ "integrity": "sha512-msLaRYa2Byyabnf/+L3aRPwkx8MI3zWbofFhwupq+RyBCdgbA4gLlkPsJu9nK/1UTCWdNdSTfWXW5pZY1/1zbQ==","dev": true,"license": "AGPL-3.0-only","dependencies": {@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.69.0",++ "version": "0.70.0","description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.","main": "index.js","types": "types/index.d.ts",@@@ -444,7 +444,7 @@"devDependencies": {"@electric-sql/pglite": "^0.5.8","iovalkey": "^0.4.0",-- "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",++ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0","pg": "^8.23.0"},"peerDependencies": {@@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');const semver = require('./semver');/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.69.0';++const SDK_VERSION = '0.70.0';module.exports = {createClient,@@@ -8,6 +8,15 @@* const { suggestions } = await search.suggest('japan');* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see*++ * The Search Fabric (Contracts 0.225.0, search.fabric.query; also the MCP tool openvibe.search): one query over++ * several scopes, routed the cheapest way that answers.++ * const r = await search.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'standard' });++ * // r: { results (each with scope, kind document|page, url, provider for the web), groups, citations,++ * // route: { explain, cost_usd }, next_cursor } — query(text, { scopes }) is the same call++ * const { providers } = await search.providers(); // the web ladder's offers (price, availability, today's use)++ * Anonymous callers get the index, the open index and cached web answers; a person or a service also reaches the++ * paid providers within OpenVibe's daily caps; `mine` needs a person (actingSubject for a service).++ ** Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may@@@ -20,6 +29,17 @@ const { isOpenVibeError } = require('./core/errors');const { isActingSubjectId } = require('./core/ids');const enc = encodeURIComponent;++const FABRIC_KEYS = ['freshness', 'depth', 'limit', 'cursor', 'owner', 'type', 'lang', 'site'];++++/** The query string of GET /api/v1/query (search.fabric-request@1, GET form: scopes comma-separated). */++function fabricOf(text, o = {}) {++ const q = { q: String(text == null ? '' : text) };++ const scopes = Array.isArray(o.scopes) ? o.scopes : o.scopes ? String(o.scopes).split(',') : ['network'];++ q.scopes = scopes.map((x) => String(x).trim()).filter(Boolean).join(',');++ for (const k of FABRIC_KEYS) if (o[k] !== undefined && o[k] !== null && o[k] !== '') q[k] = o[k];++ if (o.answer) q.answer = 'true';++ return q;++}const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;function queryOf(text, o = {}) {@@@ -60,9 +80,15 @@ function createSearchClient(client, defaults = {}) {}const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });++ /** The Search Fabric: GET, so the core client may retry it safely. */++ const fabric = (text, o = {}) => call({ path: pathWith('/api/v1/query', fabricOf(text, o)) }, o);return {-- /** { results, next_cursor, facets? } — one page. */-- query: (text, o = {}) => call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o),++ /** { results, next_cursor, facets? } — one page. With `scopes`, the Search Fabric (fabric()). */++ query: (text, o = {}) => (o.scopes ? fabric(text, o) : call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o)),++ /** search.fabric-result@1 — one query over network, mine, web and the vertical scopes. */++ fabric,++ /** { providers: search.provider-offer@1[] } — the web ladder's providers. */++ providers: (o = {}) => call({ path: '/api/v1/query/providers' }, o),/** Every result, page after page (cursor), until Search has no more or `max` is reached. */async *iterate(text, o = {}) {let cursor = o.cursor || null;@@@ -81,4 +107,4 @@ function createSearchClient(client, defaults = {}) {};}--module.exports = { createSearchClient, queryOf };++module.exports = { createSearchClient, queryOf, fabricOf };@@@ -3,7 +3,7 @@const assert = require('node:assert/strict');const { stubServer, send, run } = require('./helpers');const { createClient } = require('../src/core');--const { createSearchClient, queryOf } = require('../src/search');++const { createSearchClient, queryOf, fabricOf } = require('../src/search');const USR = 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ';@@@ -15,6 +15,8 @@ async function search() {if (!cursor) return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '1' }, { owner: 'live', type: 'vod', id: '2' }], next_cursor: 'c2' });return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '3' }], next_cursor: null });}++ if (u.pathname === '/api/v1/query') return send(res, 200, { results: [{ scope: 'web', kind: 'page', title: 'A', url: 'https://example.org/a', provider: 'wikipedia' }], groups: { web: 1 }, answer: null, citations: [], route: { explain: [{ scope: 'web', step: 'wikipedia', ok: true, count: 1 }], cost_usd: 0 }, next_cursor: null });++ if (u.pathname === '/api/v1/query/providers') return send(res, 200, { providers: [{ provider: 'deepseek', scopes: ['web'], price_usd_per_call: 0.00075, available: true, checked_at: '2026-10-28T12:00:00Z' }] });if (u.pathname === '/api/v1/suggest') return send(res, 200, { suggestions: [{ owner: 'live', type: 'channel', id: '327', title: 'JapaneseOldGuy' }] });if (u.pathname.startsWith('/api/v1/documents/live/channel/404')) return send(res, 404, { type: 'about:blank', code: 'search.not_found', status: 404 });if (u.pathname.startsWith('/api/v1/documents/')) return send(res, 200, { owner: 'live', type: 'channel', id: '327' });@@@ -23,6 +25,26 @@ async function search() {}run([++ ['fabric: scopes go to GET /api/v1/query; query() with scopes is the same call; providers', async () => {++ const srv = await search();++ const s = createSearchClient(createClient({ baseUrls: { search: srv.url } }));++ const r = await s.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'deep', site: 'example.org', limit: 5, answer: true });++ assert.equal(r.results[0].provider, 'wikipedia');++ assert.equal(r.route.cost_usd, 0);++ const u = new URL(srv.requests[0].url, 'http://x');++ assert.equal(srv.requests[0].method, 'GET', 'a read: the client may retry it');++ assert.deepEqual([u.pathname, u.searchParams.get('q'), u.searchParams.get('scopes'), u.searchParams.get('freshness'), u.searchParams.get('depth'), u.searchParams.get('site'), u.searchParams.get('limit'), u.searchParams.get('answer')],++ ['/api/v1/query', 'surf maps', 'network,web', 'month', 'deep', 'example.org', '5', 'true']);++ await s.query('x', { scopes: 'web' });++ assert.equal(new URL(srv.requests[1].url, 'http://x').pathname, '/api/v1/query', 'query() with scopes is the fabric');++ await s.query('x', { owner: 'live' });++ assert.equal(new URL(srv.requests[2].url, 'http://x').pathname, '/api/v1/search', 'without scopes, the index search as before');++ assert.equal(new URL(srv.requests[3] ? srv.requests[3].url : 'http://x/none', 'http://x').pathname, '/none');++ const p = await s.providers();++ assert.equal(p.providers[0].provider, 'deepseek');++ assert.deepEqual(fabricOf('q'), { q: 'q', scopes: 'network' }, 'network by default');++ await srv.close();++ }],['query sends owner, type, facet filters and facet keys', async () => {const srv = await search();const s = createSearchClient(createClient({ baseUrls: { search: srv.url } }));@@@ -21,11 +21,53 @@ export interface SearchOptions {signal?: AbortSignal;}export interface SearchPage { results: SearchDocument[]; next_cursor: string | null; facets?: Record<string, Array<{ value: string; count: number }>>; }++export type FabricScope = 'network' | 'mine' | 'web' | 'news' | 'images' | 'video' | 'products' | 'people' | 'places' | 'code';++export interface FabricOptions {++ scopes?: FabricScope[] | string;++ freshness?: 'any' | 'day' | 'week' | 'month' | 'year';++ depth?: 'quick' | 'standard' | 'deep';++ answer?: boolean;++ limit?: number; cursor?: string | null;++ owner?: string; type?: string; lang?: string;++ /** web: results from this host only. */++ site?: string;++ actingSubject?: string;++ signal?: AbortSignal;++}++export interface FabricResult {++ scope: FabricScope; kind: 'document' | 'page'; title: string; url: string;++ snippet?: string | null; site?: string | null; image?: string | null;++ published_at?: string | null; retrieved_at?: string | null;++ /** page: who found it (open_index, deepseek, wikipedia, …). */++ provider?: string | null;++ owner?: string | null; type?: string | null; id?: string | null; score?: number | null;++}++export interface FabricExplainStep { scope: FabricScope; step: string; ok: boolean; count?: number; ms?: number; cached?: boolean; cost_usd?: number; skipped?: string | null; }++/** search.fabric-result@1 */++export interface FabricAnswer {++ results: FabricResult[];++ groups: Partial<Record<FabricScope, number>>;++ answer?: { text: string; citations: number[]; label: 'Written by AI from these sources' } | null;++ citations?: Array<{ n: number; url: string; title: string; provider?: string | null; retrieved_at?: string | null }>;++ route: { explain: FabricExplainStep[]; cost_usd: number };++ next_cursor: string | null;++}++/** search.provider-offer@1 */++export interface ProviderOffer {++ provider: string; name?: string; scopes: FabricScope[]; price_usd_per_call: number; independent_index?: boolean;++ available: boolean; reason?: string | null; daily_cap?: number | null; used_today?: number | null;++ latency_ms_p50?: number | null; answered_rate?: number | null; terms_url?: string | null; checked_at: string;++}export interface SearchClient {query(text: string, opts?: SearchOptions): Promise<SearchPage>;++ /** With scopes: the Search Fabric. */++ query(text: string, opts: FabricOptions & { scopes: FabricScope[] | string }): Promise<FabricAnswer>;++ fabric(text: string, opts?: FabricOptions): Promise<FabricAnswer>;++ providers(opts?: Pick<FabricOptions, 'signal'>): Promise<{ providers: ProviderOffer[] }>;iterate(text: string, opts?: SearchOptions & { max?: number }): AsyncGenerator<SearchDocument, void, unknown>;suggest(text: string, opts?: Pick<SearchOptions, 'owner' | 'type' | 'limit' | 'actingSubject' | 'signal'>): Promise<{ suggestions: Array<{ owner: string; type: string; id: string; title: string; canonical_url?: string }> }>;document(owner: string, type: string, id: string, opts?: Pick<SearchOptions, 'actingSubject' | 'signal'>): Promise<SearchDocument | null>;}export function createSearchClient(client: OpenVibeClient, defaults?: { baseUrl?: string; actingSubject?: string }): SearchClient;export function queryOf(text: string, opts?: SearchOptions): Record<string, string | string[] | number>;++export function fabricOf(text: string, opts?: FabricOptions): Record<string, string | number>;
@@ -3,6 +3,26 @@
@@ -3,6 +3,26 @@
All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minor
All notable changes to `openvibe-sdk`. The package follows semver; while it is `0.x`, a minor
release may change an API and says so here.
release may change an API and says so here.
+## 0.70.0 (2026-10-28)
+
+- **`openvibe-sdk/search`: the Search Fabric** (Contracts 0.225.0 `search.fabric.query`; plan 2026-10-28 §4.5). One
+ query over several scopes, routed the cheapest way that answers.
+ - **`search.fabric(text, { scopes, freshness, depth, answer, limit, cursor, owner, type, lang, site })`** returns
+ `search.fabric-result@1`:
+ - `results`: each has a scope and a kind (a document in the index, or a web page with its provider, URL and
+ dates);
+ - `groups`, `citations`, and `route.explain` (what each step did and what it cost).
+ - **Scopes:**
+ - `network` and `mine` (the person's own; a service passes `actingSubject`);
+ - `web`: OpenVibe's open index first, then DeepSeek for a signed-in caller or a service, then Wikipedia,
+ cached;
+ - `news`, `images`, `video`, `products`, `people`, `places` and `code`.
+ - `search.query(text, { scopes })` is the same call; without `scopes`, `query()` is the index search as before.
+ - `search.providers()` lists the web ladder's `search.provider-offer@1` items.
+ - Reads use GET, so the client may retry them.
+ - Types: `FabricOptions`, `FabricAnswer`, `FabricResult`, `FabricExplainStep`, `ProviderOffer`; `fabricOf()` builds
+ the query string.
+
## 0.69.0 (2026-10-28)
## 0.69.0 (2026-10-28)
- **`openvibe-sdk/tools`: domain history** (OpenVibe.Tools' `/api/v1/domains`, 2026-10-28). What the WHOIS and RDAP
- **`openvibe-sdk/tools`: domain history** (OpenVibe.Tools' `/api/v1/domains`, 2026-10-28). What the WHOIS and RDAP
@@ -2,14 +2,14 @@
@@ -2,14 +2,14 @@
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.69.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
+**Status:** alpha, v0.70.0 (roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat and AI clients from WS-F task 4; per-actor limits from WS-R task 4). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
**If a capability is not in the SDK, it is not public.** Apps call services through `openvibe-sdk` and never build internal routes themselves. A route with no SDK wrapper is internal, even when you can reach it, and it can change without notice. To make a capability public, first define it in OpenVibe.Contracts, then wrap it here.
**If a capability is not in the SDK, it is not public.** Apps call services through `openvibe-sdk` and never build internal routes themselves. A route with no SDK wrapper is internal, even when you can reach it, and it can change without notice. To make a capability public, first define it in OpenVibe.Contracts, then wrap it here.
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.69.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.70.0
```
```
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from Contracts v0.86.0, a devDependency the tests check them against).
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from Contracts v0.86.0, a devDependency the tests check them against).
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.69.0",
+ "version": "0.70.0",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30",
"deployed": false,
"deployed": false,
"deployment": "none: a package released as git tags; services and apps pin a tag",
"deployment": "none: a package released as git tags; services and apps pin a tag",
@@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.69.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.70.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, registry, modules, realtime, media, community, bot, search, themes, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
// (auth, registry, modules, realtime, media, community, bot, search, themes, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
/* eslint-disable */
@@ -43,7 +43,7 @@ const { paginate, offsetPager } = __load(7);
@@ -43,7 +43,7 @@ const { paginate, offsetPager } = __load(7);
const semver = __load(6);
const semver = __load(6);
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.69.0';
+const SDK_VERSION = '0.70.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -1989,6 +1989,15 @@ function (module, exports) {
@@ -1989,6 +1989,15 @@ function (module, exports) {
* const { suggestions } = await search.suggest('japan');
* const { suggestions } = await search.suggest('japan');
* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see
* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see
*
*
+ * The Search Fabric (Contracts 0.225.0, search.fabric.query; also the MCP tool openvibe.search): one query over
+ * several scopes, routed the cheapest way that answers.
+ * const r = await search.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'standard' });
+ * // r: { results (each with scope, kind document|page, url, provider for the web), groups, citations,
+ * // route: { explain, cost_usd }, next_cursor } — query(text, { scopes }) is the same call
+ * const { providers } = await search.providers(); // the web ladder's offers (price, availability, today's use)
+ * Anonymous callers get the index, the open index and cached web answers; a person or a service also reaches the
+ * paid providers within OpenVibe's daily caps; `mine` needs a person (actingSubject for a service).
+ *
* Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable
* Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable
* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also
* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also
* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may
* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may
@@ -2001,6 +2010,17 @@ const { isOpenVibeError } = __load(3);
@@ -2001,6 +2010,17 @@ const { isOpenVibeError } = __load(3);
const { isActingSubjectId } = __load(5);
const { isActingSubjectId } = __load(5);
const enc = encodeURIComponent;
const enc = encodeURIComponent;
+const FABRIC_KEYS = ['freshness', 'depth', 'limit', 'cursor', 'owner', 'type', 'lang', 'site'];
+
+/** The query string of GET /api/v1/query (search.fabric-request@1, GET form: scopes comma-separated). */
+function fabricOf(text, o = {}) {
+ const q = { q: String(text == null ? '' : text) };
+ const scopes = Array.isArray(o.scopes) ? o.scopes : o.scopes ? String(o.scopes).split(',') : ['network'];
+ q.scopes = scopes.map((x) => String(x).trim()).filter(Boolean).join(',');
+ for (const k of FABRIC_KEYS) if (o[k] !== undefined && o[k] !== null && o[k] !== '') q[k] = o[k];
+ if (o.answer) q.answer = 'true';
+ return q;
+}
const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;
const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;
function queryOf(text, o = {}) {
function queryOf(text, o = {}) {
@@ -2041,9 +2061,15 @@ function createSearchClient(client, defaults = {}) {
@@ -2041,9 +2061,15 @@ function createSearchClient(client, defaults = {}) {
}
}
const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });
const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });
+ /** The Search Fabric: GET, so the core client may retry it safely. */
+ const fabric = (text, o = {}) => call({ path: pathWith('/api/v1/query', fabricOf(text, o)) }, o);
return {
return {
- /** { results, next_cursor, facets? } — one page. */
- query: (text, o = {}) => call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o),
+ /** { results, next_cursor, facets? } — one page. With `scopes`, the Search Fabric (fabric()). */
+ query: (text, o = {}) => (o.scopes ? fabric(text, o) : call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o)),
+ /** search.fabric-result@1 — one query over network, mine, web and the vertical scopes. */
+ fabric,
+ /** { providers: search.provider-offer@1[] } — the web ladder's providers. */
+ providers: (o = {}) => call({ path: '/api/v1/query/providers' }, o),
/** Every result, page after page (cursor), until Search has no more or `max` is reached. */
/** Every result, page after page (cursor), until Search has no more or `max` is reached. */
async *iterate(text, o = {}) {
async *iterate(text, o = {}) {
let cursor = o.cursor || null;
let cursor = o.cursor || null;
@@ -2062,7 +2088,7 @@ function createSearchClient(client, defaults = {}) {
@@ -2062,7 +2088,7 @@ function createSearchClient(client, defaults = {}) {
};
};
}
}
-module.exports = { createSearchClient, queryOf };
+module.exports = { createSearchClient, queryOf, fabricOf };
},
},
// ── 17: src/themes.js ───────────────────────────────────────────────
// ── 17: src/themes.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
@@ -235,6 +235,7 @@
@@ -235,6 +235,7 @@
"search": {
"search": {
"object": [
"object": [
"createSearchClient",
"createSearchClient",
+ "fabricOf",
"queryOf"
"queryOf"
]
]
},
},
@@ -634,6 +635,7 @@
@@ -634,6 +635,7 @@
},
},
"openvibe-sdk/search": {
"openvibe-sdk/search": {
"createSearchClient": "function",
"createSearchClient": "function",
+ "fabricOf": "function",
"queryOf": "function"
"queryOf": "function"
},
},
"openvibe-sdk/service": {
"openvibe-sdk/service": {
@@ -2,6 +2,6 @@
@@ -2,6 +2,6 @@
import cjs from '../src/search.js';
import cjs from '../src/search.js';
export const {
export const {
- createSearchClient, queryOf,
+ createSearchClient, queryOf, fabricOf,
} = cjs;
} = cjs;
export default cjs;
export default cjs;
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.69.0",
+ "version": "0.70.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.69.0",
+ "version": "0.70.0",
"license": "MIT",
"license": "MIT",
"bin": {
"bin": {
"openvibe-download": "bin/openvibe-download.js"
"openvibe-download": "bin/openvibe-download.js"
@@ -14,7 +14,7 @@
@@ -14,7 +14,7 @@
"devDependencies": {
"devDependencies": {
"@electric-sql/pglite": "^0.5.8",
"@electric-sql/pglite": "^0.5.8",
"iovalkey": "^0.4.0",
"iovalkey": "^0.4.0",
- "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",
+ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0",
"pg": "^8.23.0"
"pg": "^8.23.0"
},
},
"engines": {
"engines": {
@@ -198,9 +198,9 @@
@@ -198,9 +198,9 @@
"license": "MIT"
"license": "MIT"
},
},
"node_modules/openvibe-contracts": {
"node_modules/openvibe-contracts": {
- "version": "0.222.0",
- "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",
- "integrity": "sha512-wdUQCilq9glRMwfxEswbIj3l0QQqKDXZAi2+CR5Mlh34rZjI1Q+7GlAoR0UtNwZAgtLwXhPxFyJ/aPk8lcDG1Q==",
+ "version": "0.225.0",
+ "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0",
+ "integrity": "sha512-msLaRYa2Byyabnf/+L3aRPwkx8MI3zWbofFhwupq+RyBCdgbA4gLlkPsJu9nK/1UTCWdNdSTfWXW5pZY1/1zbQ==",
"dev": true,
"dev": true,
"license": "AGPL-3.0-only",
"license": "AGPL-3.0-only",
"dependencies": {
"dependencies": {
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.69.0",
+ "version": "0.70.0",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"main": "index.js",
"main": "index.js",
"types": "types/index.d.ts",
"types": "types/index.d.ts",
@@ -444,7 +444,7 @@
@@ -444,7 +444,7 @@
"devDependencies": {
"devDependencies": {
"@electric-sql/pglite": "^0.5.8",
"@electric-sql/pglite": "^0.5.8",
"iovalkey": "^0.4.0",
"iovalkey": "^0.4.0",
- "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.222.0",
+ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.225.0",
"pg": "^8.23.0"
"pg": "^8.23.0"
},
},
"peerDependencies": {
"peerDependencies": {
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
const semver = require('./semver');
const semver = require('./semver');
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.69.0';
+const SDK_VERSION = '0.70.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -8,6 +8,15 @@
@@ -8,6 +8,15 @@
* const { suggestions } = await search.suggest('japan');
* const { suggestions } = await search.suggest('japan');
* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see
* const doc = await search.document('live', 'channel', '327'); // null when missing or not yours to see
*
*
+ * The Search Fabric (Contracts 0.225.0, search.fabric.query; also the MCP tool openvibe.search): one query over
+ * several scopes, routed the cheapest way that answers.
+ * const r = await search.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'standard' });
+ * // r: { results (each with scope, kind document|page, url, provider for the web), groups, citations,
+ * // route: { explain, cost_usd }, next_cursor } — query(text, { scopes }) is the same call
+ * const { providers } = await search.providers(); // the web ladder's offers (price, availability, today's use)
+ * Anonymous callers get the index, the open index and cached web answers; a person or a service also reaches the
+ * paid providers within OpenVibe's daily caps; `mine` needs a person (actingSubject for a service).
+ *
* Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable
* Who sees what is decided by Search for every hit: anonymous callers get public, published, indexable
* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also
* documents only; a signed-in person (Bearer user JWT, or the ov_token cookie with credentials) also
* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may
* gets restricted documents whose ACL names them; a first-party service with search.query.delegate may
@@ -20,6 +29,17 @@ const { isOpenVibeError } = require('./core/errors');
@@ -20,6 +29,17 @@ const { isOpenVibeError } = require('./core/errors');
const { isActingSubjectId } = require('./core/ids');
const { isActingSubjectId } = require('./core/ids');
const enc = encodeURIComponent;
const enc = encodeURIComponent;
+const FABRIC_KEYS = ['freshness', 'depth', 'limit', 'cursor', 'owner', 'type', 'lang', 'site'];
+
+/** The query string of GET /api/v1/query (search.fabric-request@1, GET form: scopes comma-separated). */
+function fabricOf(text, o = {}) {
+ const q = { q: String(text == null ? '' : text) };
+ const scopes = Array.isArray(o.scopes) ? o.scopes : o.scopes ? String(o.scopes).split(',') : ['network'];
+ q.scopes = scopes.map((x) => String(x).trim()).filter(Boolean).join(',');
+ for (const k of FABRIC_KEYS) if (o[k] !== undefined && o[k] !== null && o[k] !== '') q[k] = o[k];
+ if (o.answer) q.answer = 'true';
+ return q;
+}
const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;
const FACET_KEY = /^[a-z][a-z0-9_]{0,39}$/;
function queryOf(text, o = {}) {
function queryOf(text, o = {}) {
@@ -60,9 +80,15 @@ function createSearchClient(client, defaults = {}) {
@@ -60,9 +80,15 @@ function createSearchClient(client, defaults = {}) {
}
}
const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });
const orNull = (p) => p.catch((err) => { if (isOpenVibeError(err) && err.status === 404) return null; throw err; });
+ /** The Search Fabric: GET, so the core client may retry it safely. */
+ const fabric = (text, o = {}) => call({ path: pathWith('/api/v1/query', fabricOf(text, o)) }, o);
return {
return {
- /** { results, next_cursor, facets? } — one page. */
- query: (text, o = {}) => call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o),
+ /** { results, next_cursor, facets? } — one page. With `scopes`, the Search Fabric (fabric()). */
+ query: (text, o = {}) => (o.scopes ? fabric(text, o) : call({ path: pathWith('/api/v1/search', queryOf(text, o)) }, o)),
+ /** search.fabric-result@1 — one query over network, mine, web and the vertical scopes. */
+ fabric,
+ /** { providers: search.provider-offer@1[] } — the web ladder's providers. */
+ providers: (o = {}) => call({ path: '/api/v1/query/providers' }, o),
/** Every result, page after page (cursor), until Search has no more or `max` is reached. */
/** Every result, page after page (cursor), until Search has no more or `max` is reached. */
async *iterate(text, o = {}) {
async *iterate(text, o = {}) {
let cursor = o.cursor || null;
let cursor = o.cursor || null;
@@ -81,4 +107,4 @@ function createSearchClient(client, defaults = {}) {
@@ -81,4 +107,4 @@ function createSearchClient(client, defaults = {}) {
};
};
}
}
-module.exports = { createSearchClient, queryOf };
+module.exports = { createSearchClient, queryOf, fabricOf };
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
const assert = require('node:assert/strict');
const assert = require('node:assert/strict');
const { stubServer, send, run } = require('./helpers');
const { stubServer, send, run } = require('./helpers');
const { createClient } = require('../src/core');
const { createClient } = require('../src/core');
-const { createSearchClient, queryOf } = require('../src/search');
+const { createSearchClient, queryOf, fabricOf } = require('../src/search');
const USR = 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ';
const USR = 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ';
@@ -15,6 +15,8 @@ async function search() {
@@ -15,6 +15,8 @@ async function search() {
if (!cursor) return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '1' }, { owner: 'live', type: 'vod', id: '2' }], next_cursor: 'c2' });
if (!cursor) return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '1' }, { owner: 'live', type: 'vod', id: '2' }], next_cursor: 'c2' });
return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '3' }], next_cursor: null });
return send(res, 200, { results: [{ owner: 'live', type: 'vod', id: '3' }], next_cursor: null });
}
}
+ if (u.pathname === '/api/v1/query') return send(res, 200, { results: [{ scope: 'web', kind: 'page', title: 'A', url: 'https://example.org/a', provider: 'wikipedia' }], groups: { web: 1 }, answer: null, citations: [], route: { explain: [{ scope: 'web', step: 'wikipedia', ok: true, count: 1 }], cost_usd: 0 }, next_cursor: null });
+ if (u.pathname === '/api/v1/query/providers') return send(res, 200, { providers: [{ provider: 'deepseek', scopes: ['web'], price_usd_per_call: 0.00075, available: true, checked_at: '2026-10-28T12:00:00Z' }] });
if (u.pathname === '/api/v1/suggest') return send(res, 200, { suggestions: [{ owner: 'live', type: 'channel', id: '327', title: 'JapaneseOldGuy' }] });
if (u.pathname === '/api/v1/suggest') return send(res, 200, { suggestions: [{ owner: 'live', type: 'channel', id: '327', title: 'JapaneseOldGuy' }] });
if (u.pathname.startsWith('/api/v1/documents/live/channel/404')) return send(res, 404, { type: 'about:blank', code: 'search.not_found', status: 404 });
if (u.pathname.startsWith('/api/v1/documents/live/channel/404')) return send(res, 404, { type: 'about:blank', code: 'search.not_found', status: 404 });
if (u.pathname.startsWith('/api/v1/documents/')) return send(res, 200, { owner: 'live', type: 'channel', id: '327' });
if (u.pathname.startsWith('/api/v1/documents/')) return send(res, 200, { owner: 'live', type: 'channel', id: '327' });
@@ -23,6 +25,26 @@ async function search() {
@@ -23,6 +25,26 @@ async function search() {
}
}
run([
run([
+ ['fabric: scopes go to GET /api/v1/query; query() with scopes is the same call; providers', async () => {
+ const srv = await search();
+ const s = createSearchClient(createClient({ baseUrls: { search: srv.url } }));
+ const r = await s.fabric('surf maps', { scopes: ['network', 'web'], freshness: 'month', depth: 'deep', site: 'example.org', limit: 5, answer: true });
+ assert.equal(r.results[0].provider, 'wikipedia');
+ assert.equal(r.route.cost_usd, 0);
+ const u = new URL(srv.requests[0].url, 'http://x');
+ assert.equal(srv.requests[0].method, 'GET', 'a read: the client may retry it');
+ assert.deepEqual([u.pathname, u.searchParams.get('q'), u.searchParams.get('scopes'), u.searchParams.get('freshness'), u.searchParams.get('depth'), u.searchParams.get('site'), u.searchParams.get('limit'), u.searchParams.get('answer')],
+ ['/api/v1/query', 'surf maps', 'network,web', 'month', 'deep', 'example.org', '5', 'true']);
+ await s.query('x', { scopes: 'web' });
+ assert.equal(new URL(srv.requests[1].url, 'http://x').pathname, '/api/v1/query', 'query() with scopes is the fabric');
+ await s.query('x', { owner: 'live' });
+ assert.equal(new URL(srv.requests[2].url, 'http://x').pathname, '/api/v1/search', 'without scopes, the index search as before');
+ assert.equal(new URL(srv.requests[3] ? srv.requests[3].url : 'http://x/none', 'http://x').pathname, '/none');
+ const p = await s.providers();
+ assert.equal(p.providers[0].provider, 'deepseek');
+ assert.deepEqual(fabricOf('q'), { q: 'q', scopes: 'network' }, 'network by default');
+ await srv.close();
+ }],
['query sends owner, type, facet filters and facet keys', async () => {
['query sends owner, type, facet filters and facet keys', async () => {
const srv = await search();
const srv = await search();
const s = createSearchClient(createClient({ baseUrls: { search: srv.url } }));
const s = createSearchClient(createClient({ baseUrls: { search: srv.url } }));
@@ -21,11 +21,53 @@ export interface SearchOptions {
@@ -21,11 +21,53 @@ export interface SearchOptions {
signal?: AbortSignal;
signal?: AbortSignal;
}
}
export interface SearchPage { results: SearchDocument[]; next_cursor: string | null; facets?: Record<string, Array<{ value: string; count: number }>>; }
export interface SearchPage { results: SearchDocument[]; next_cursor: string | null; facets?: Record<string, Array<{ value: string; count: number }>>; }
+export type FabricScope = 'network' | 'mine' | 'web' | 'news' | 'images' | 'video' | 'products' | 'people' | 'places' | 'code';
+export interface FabricOptions {
+ scopes?: FabricScope[] | string;
+ freshness?: 'any' | 'day' | 'week' | 'month' | 'year';
+ depth?: 'quick' | 'standard' | 'deep';
+ answer?: boolean;
+ limit?: number; cursor?: string | null;
+ owner?: string; type?: string; lang?: string;
+ /** web: results from this host only. */
+ site?: string;
+ actingSubject?: string;
+ signal?: AbortSignal;
+}
+export interface FabricResult {
+ scope: FabricScope; kind: 'document' | 'page'; title: string; url: string;
+ snippet?: string | null; site?: string | null; image?: string | null;
+ published_at?: string | null; retrieved_at?: string | null;
+ /** page: who found it (open_index, deepseek, wikipedia, …). */
+ provider?: string | null;
+ owner?: string | null; type?: string | null; id?: string | null; score?: number | null;
+}
+export interface FabricExplainStep { scope: FabricScope; step: string; ok: boolean; count?: number; ms?: number; cached?: boolean; cost_usd?: number; skipped?: string | null; }
+/** search.fabric-result@1 */
+export interface FabricAnswer {
+ results: FabricResult[];
+ groups: Partial<Record<FabricScope, number>>;
+ answer?: { text: string; citations: number[]; label: 'Written by AI from these sources' } | null;
+ citations?: Array<{ n: number; url: string; title: string; provider?: string | null; retrieved_at?: string | null }>;
+ route: { explain: FabricExplainStep[]; cost_usd: number };
+ next_cursor: string | null;
+}
+/** search.provider-offer@1 */
+export interface ProviderOffer {
+ provider: string; name?: string; scopes: FabricScope[]; price_usd_per_call: number; independent_index?: boolean;
+ available: boolean; reason?: string | null; daily_cap?: number | null; used_today?: number | null;
+ latency_ms_p50?: number | null; answered_rate?: number | null; terms_url?: string | null; checked_at: string;
+}
export interface SearchClient {
export interface SearchClient {
query(text: string, opts?: SearchOptions): Promise<SearchPage>;
query(text: string, opts?: SearchOptions): Promise<SearchPage>;
+ /** With scopes: the Search Fabric. */
+ query(text: string, opts: FabricOptions & { scopes: FabricScope[] | string }): Promise<FabricAnswer>;
+ fabric(text: string, opts?: FabricOptions): Promise<FabricAnswer>;
+ providers(opts?: Pick<FabricOptions, 'signal'>): Promise<{ providers: ProviderOffer[] }>;
iterate(text: string, opts?: SearchOptions & { max?: number }): AsyncGenerator<SearchDocument, void, unknown>;
iterate(text: string, opts?: SearchOptions & { max?: number }): AsyncGenerator<SearchDocument, void, unknown>;
suggest(text: string, opts?: Pick<SearchOptions, 'owner' | 'type' | 'limit' | 'actingSubject' | 'signal'>): Promise<{ suggestions: Array<{ owner: string; type: string; id: string; title: string; canonical_url?: string }> }>;
suggest(text: string, opts?: Pick<SearchOptions, 'owner' | 'type' | 'limit' | 'actingSubject' | 'signal'>): Promise<{ suggestions: Array<{ owner: string; type: string; id: string; title: string; canonical_url?: string }> }>;
document(owner: string, type: string, id: string, opts?: Pick<SearchOptions, 'actingSubject' | 'signal'>): Promise<SearchDocument | null>;
document(owner: string, type: string, id: string, opts?: Pick<SearchOptions, 'actingSubject' | 'signal'>): Promise<SearchDocument | null>;
}
}
export function createSearchClient(client: OpenVibeClient, defaults?: { baseUrl?: string; actingSubject?: string }): SearchClient;
export function createSearchClient(client: OpenVibeClient, defaults?: { baseUrl?: string; actingSubject?: string }): SearchClient;
export function queryOf(text: string, opts?: SearchOptions): Record<string, string | string[] | number>;
export function queryOf(text: string, opts?: SearchOptions): Record<string, string | string[] | number>;
+export function fabricOf(text: string, opts?: FabricOptions): Record<string, string | number>;