openvibers/openvibe.sdk Commits

Expose popular and trending tool discovery in the SDK (#163)

OP OpenVibers committed 4 days ago · f8207563a7 · 11 files, +95 −11

* Expose popular and trending tool discovery in the SDK

* Merge remote-tracking branch 'origin/main' into tools-discovery-sdk-1109

* Merge remote-tracking branch 'origin/main' into tools-discovery-sdk-1109

* Merge main

* 0.115.0

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex 90a1db2..596d042 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,9 @@
# Changelog
++## 0.115.0 (2026-11-09)
++
++- Tools discovery: ov.tools.popular() and ov.tools.trending()
++
## 0.114.0 (2026-11-09)
- Dock v2: Vibe conversations (ov.chat.vibe.conversations) and Actor skill runs (ov.actor.skills.run)
ddiff --git a/README.md b/README.md
iindex 9d49f6b..927100f 100644
---- a/README.md
++++ b/README.md
@@@ -2,7 +2,7 @@
> Supported browser and server clients for the OpenVibe platform.
--**Status:** alpha, v0.114.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). 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.115.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). 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.
@@@ -11,7 +11,7 @@
After v0.97.1 is tagged:
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.114.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.115.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 the temporary Contracts sharing branch, a devDependency the tests check them against).
ddiff --git a/STATUS.json b/STATUS.json
iindex 17e6022..012a7d3 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.114.0",
++ "version": "0.115.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",
ddiff --git a/browser/openvibe-sdk.mjs b/browser/openvibe-sdk.mjs
iindex 387c0b0..a3144d7 100644
---- a/browser/openvibe-sdk.mjs
++++ b/browser/openvibe-sdk.mjs
@@@ -1,4 +1,4 @@
--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.114.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.115.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
@@@ -52,7 +52,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.114.0';
++const SDK_VERSION = '0.115.0';
module.exports = {
createClient,
@@@ -5450,7 +5450,17 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
async lists({ limit, signal } = {}) { return read('/api/v1/domains', { limit }, signal); },
};
-- return { list, get, schema, run, jobs, domains };
++ /** Public successful-run rankings, cached by Tools for one minute. */
++ async function trending({ window = 'week', limit = 12, signal } = {}) {
++ if (!['hour', 'week'].includes(window)) throw new TypeError('tools.trending: window must be hour or week');
++ if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new TypeError('tools.trending: limit must be 1–50');
++ return read('/api/v1/tools/trending', { window, limit }, signal);
++ }
++ async function popular({ limit = 12, signal } = {}) {
++ if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new TypeError('tools.popular: limit must be 1–50');
++ return read('/api/v1/tools/popular', { limit }, signal);
++ }
++ return { list, get, schema, run, jobs, domains, trending, popular };
}
module.exports = { createToolsClient, ToolRunError, isToolRunError };
ddiff --git a/docs/tools-discovery.md b/docs/tools-discovery.md
nnew file mode 100644
iindex 0000000..789a12a
---- /dev/null
++++ b/docs/tools-discovery.md
@@@ -0,0 +1,14 @@
++# Tool discovery
++
++```js
++const rising = await ov.tools.trending({ window: 'hour', limit: 12 });
++const popular = await ov.tools.popular({ limit: 12 });
++```
++
++`trending()` defaults to `window: 'week'`. Limits are integers from 1 to 50; both methods accept an AbortSignal. Registry reads are anonymous by default, just like `tools.list()`.
++
++Both return `{ metric: 'successful_api_runs', window, updated_at, uses_today, tools, count }`. Each tool has `id`, `name`, `description`, `family`, `icon`, `url` and `uses`. Trending entries also have `previous_uses` and `increase`; only rising tools appear, ordered by absolute increase, use count and ID. Empty lists mean no recorded activity, while unavailable data rejects the request.
++
++Counts cover successful inline API requests (including cache hits but excluding idempotent replays) and successful file jobs with tool IDs. They exclude page opens, browser-only edits and failures. The current UTC hour is partial; week means the last 168 hourly buckets compared with the preceding 168. The server refreshes totals every minute. No historical use is fabricated before the counter migration.
++
++Requires the Tools gateway discovery API deployment. SDK releases follow the normal merge/tag process; this addition needs no new browser bundle entrypoint.
ddiff --git a/package-lock.json b/package-lock.json
iindex 6c748e4..40faf2d 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.114.0",
++ "version": "0.115.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.114.0",
++ "version": "0.115.0",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex d00dfb0..71b5c02 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.114.0",
++ "version": "0.115.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",
ddiff --git a/src/core/index.js b/src/core/index.js
iindex 6e2ecff..b30e2b8 100644
---- a/src/core/index.js
++++ b/src/core/index.js
@@@ -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.114.0';
++const SDK_VERSION = '0.115.0';
module.exports = {
createClient,
ddiff --git a/src/tools.js b/src/tools.js
iindex 32edad4..042bf5e 100644
---- a/src/tools.js
++++ b/src/tools.js
@@@ -276,7 +276,17 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
async lists({ limit, signal } = {}) { return read('/api/v1/domains', { limit }, signal); },
};
-- return { list, get, schema, run, jobs, domains };
++ /** Public successful-run rankings, cached by Tools for one minute. */
++ async function trending({ window = 'week', limit = 12, signal } = {}) {
++ if (!['hour', 'week'].includes(window)) throw new TypeError('tools.trending: window must be hour or week');
++ if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new TypeError('tools.trending: limit must be 1–50');
++ return read('/api/v1/tools/trending', { window, limit }, signal);
++ }
++ async function popular({ limit = 12, signal } = {}) {
++ if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new TypeError('tools.popular: limit must be 1–50');
++ return read('/api/v1/tools/popular', { limit }, signal);
++ }
++ return { list, get, schema, run, jobs, domains, trending, popular };
}
module.exports = { createToolsClient, ToolRunError, isToolRunError };
ddiff --git a/test/tools-discovery.test.js b/test/tools-discovery.test.js
nnew file mode 100644
iindex 0000000..dd96ffa
---- /dev/null
++++ b/test/tools-discovery.test.js
@@@ -0,0 +1,22 @@
++'use strict';
++const assert = require('node:assert/strict');
++const { createToolsClient } = require('../src/tools');
++(async () => {
++ const calls = [];
++ const result = { metric: 'successful_api_runs', window: 'hour', updated_at: '2026-11-09T10:00:00Z', uses_today: 3, tools: [], count: 0 };
++ const tools = createToolsClient({ request: async opts => { calls.push(opts); return { data: result }; } }, { baseUrl: 'https://openvibe.tools' });
++ const signal = new AbortController().signal;
++ assert.equal(await tools.trending({ window: 'hour', limit: 4, signal }), result);
++ assert.equal(calls[0].path, '/api/v1/tools/trending');
++ assert.deepEqual(calls[0].query, { window: 'hour', limit: 4 });
++ assert.equal(calls[0].auth, false);
++ assert.equal(calls[0].signal, signal);
++ await tools.popular();
++ assert.equal(calls[1].path, '/api/v1/tools/popular');
++ assert.deepEqual(calls[1].query, { limit: 12 });
++ await assert.rejects(tools.trending({ window: 'day' }), TypeError);
++ await assert.rejects(tools.popular({ limit: 51 }), TypeError);
++ const broken = createToolsClient({ request: async () => { throw new Error('unavailable'); } });
++ await assert.rejects(broken.trending(), /unavailable/);
++ console.log('tools discovery: all checks passed');
++})().catch(e => { console.error(e); process.exit(1); });
ddiff --git a/types/tools.d.ts b/types/tools.d.ts
iindex 9c9a83c..a7ede90 100644
---- a/types/tools.d.ts
++++ b/types/tools.d.ts
@@@ -93,7 +93,31 @@ export declare class ToolRunError extends OpenVibeError {
}
export declare function isToolRunError(err: unknown): err is ToolRunError;
++export interface ToolRankingItem {
++ id: string;
++ name: string;
++ description: string;
++ family: string;
++ icon: string;
++ url: string;
++ uses: number;
++ /** Trending only: use count in the preceding comparison window. */
++ previous_uses?: number;
++ increase?: number;
++}
++export interface ToolRanking {
++ metric: 'successful_api_runs';
++ window: 'hour' | 'week';
++ updated_at: string;
++ uses_today: number;
++ tools: ToolRankingItem[];
++ count: number;
++}
export interface ToolsClient {
++ /** Rising successful API use versus the preceding UTC hour or seven-day window. */
++ trending(opts?: { window?: 'hour' | 'week'; limit?: number; signal?: AbortSignal }): Promise<ToolRanking>;
++ /** Most successful API uses in the last seven days. */
++ popular(opts?: { limit?: number; signal?: AbortSignal }): Promise<ToolRanking>;
/** GET /api/v1/tools: tools.tool-list@1, schemas as { $ref }. */
list(query?: ToolListQuery): Promise<ToolList>;
/** GET /api/v1/tools/:id: the descriptor with its schemas embedded, or null. */