openvibers/openvibe.sdk Commits
Add AI credentials SDK client (#143)
Changes
@@@ -1,5 +1,12 @@# Changelog++## 0.103.0 (2026-11-08)++++- Add `openvibe-sdk/credentials`: `createCredentialsClient` for a person's own provider credentials on OpenVibe.AI:++ `list()` (metadata only: kind, provider, label, created, last used, expired), `add()` for an API key or a browser++ session cookie, `remove()`, and `balance()` (that credential's fixed read-only balance readers: Anthropic Console++ prepaid credits and current spend, OpenAI credit grants). A secret never comes back from any call.++## 0.102.0 (2026-11-08)- Add `openvibe-sdk/trust`: `createTrustClient({ networkUrl, getToken })` with `.me()` (the caller's own signals, a@@@ -2,7 +2,7 @@> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.102.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.103.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.102.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.103.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).@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.102.0",++ "version": "0.103.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",@@@ -24,6 +24,7 @@ module.exports = {redact: require('./src/redact'),chat: require('./src/chat'),ai: require('./src/ai'),++ credentials: require('./src/credentials'),jobs: require('./src/jobs'),tools: require('./src/tools'),projects: require('./src/projects'),@@@ -1,6 +1,6 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.102.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.103.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, community, bot, search, bench, meme, vision, themes, redact, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.++// (auth, locker, registry, trust, modules, realtime, media, community, 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 */const __defs = [// ── 0: browser.js ──────────────────────────────────────────────────@@@ -31,10 +31,11 @@ module.exports = {redact: __load(33),chat: __load(34),ai: __load(35),-- jobs: __load(36),-- tools: __load(38),-- projects: __load(39),-- geo: __load(40),++ credentials: __load(36),++ jobs: __load(37),++ tools: __load(39),++ projects: __load(40),++ geo: __load(41),};},// ── 1: src/core/index.js ───────────────────────────────────────────@@@ -49,7 +50,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.102.0';++const SDK_VERSION = '0.103.0';module.exports = {createClient,@@@ -4773,7 +4774,25 @@ function createAiClient(client, defaults = {}) {module.exports = { createAiClient, TERMINAL, OPS, CLASSES };},--// ── 36: src/jobs.js ─────────────────────────────────────────────────++// ── 36: src/credentials.js ──────────────────────────────────────────++function (module, exports) {++'use strict';++++/** The current person's AI credentials and provider balance readers (metadata only on list). */++function createCredentialsClient(client, defaults = {}) {++ const { baseUrl } = defaults;++ const call = (opts, o = {}) => client.json({ service: 'ai', baseUrl, audience: 'openvibe.ai', ...opts, signal: o.signal });++ return {++ list: (o = {}) => call({ method: 'GET', path: '/api/v1/me/credentials' }, o),++ add: (credential, o = {}) => call({ method: 'POST', path: '/api/v1/me/credentials', body: credential }, o),++ remove: (id, o = {}) => call({ method: 'DELETE', path: `/api/v1/me/credentials/${encodeURIComponent(id)}` }, o),++ balance: (id, o = {}) => call({ method: 'GET', path: `/api/v1/me/credentials/${encodeURIComponent(id)}/balance` }, o),++ };++}++++module.exports = { createCredentialsClient };++},++// ── 37: src/jobs.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4811,7 +4830,7 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { appendFiles } = __load(37);++const { appendFiles } = __load(38);const { parseSSE } = __load(23);const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);@@@ -4975,7 +4994,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'openmodule.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };},--// ── 37: src/core/form.js ────────────────────────────────────────────++// ── 38: src/core/form.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5009,7 +5028,7 @@ function appendFiles(form, list, where) {module.exports = { isBlob, isUpload, appendFiles };},--// ── 38: src/tools.js ────────────────────────────────────────────────++// ── 39: src/tools.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5043,8 +5062,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { isUpload, appendFiles } = __load(37);--const { createJobsClient } = __load(36);++const { isUpload, appendFiles } = __load(38);++const { createJobsClient } = __load(37);const enc = encodeURIComponent;const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;@@@ -5294,7 +5313,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'opemodule.exports = { createToolsClient, ToolRunError, isToolRunError };},--// ── 39: src/projects.js ─────────────────────────────────────────────++// ── 40: src/projects.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5410,7 +5429,7 @@ function createProjectsClient(client, { baseUrl } = {}) {module.exports = { createProjectsClient };},--// ── 40: src/geo.js ──────────────────────────────────────────────────++// ── 41: src/geo.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5491,7 +5510,7 @@ export const {satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,locker, registry, trust, modules, realtime, media,community, bot, search, bench, meme, vision,-- themes, redact, chat, ai, jobs, tools,-- projects, geo,++ themes, redact, chat, ai, credentials, jobs,++ tools, projects, geo,} = sdk;export default sdk;@@@ -110,6 +110,11 @@]},"createClient": "function",++ "credentials": {++ "object": [++ "createCredentialsClient"++ ]++ },"deals": {"object": ["createDealsClient"@@@ -599,6 +604,9 @@"openvibe-sdk/coupons": {"createCouponsClient": "function"},++ "openvibe-sdk/credentials": {++ "createCredentialsClient": "function"++ },"openvibe-sdk/db": {"DbError": "class","ISOLATION": {nnew file mode 100644@@@ -0,0 +1,17 @@++# AI credentials++++Use `createCredentialsClient` from `openvibe-sdk/credentials` with a person-authenticated core client to list metadata, add or remove a credential, and run its balance readers. `list()` never returns secret values.++++```js++const credentials = createCredentialsClient(client, { baseUrl: 'https://ai.openvibe.network' });++const { credentials: stored } = await credentials.list();++const { credential } = await credentials.add({++ kind: 'session_cookie', provider: 'openai', cookie: process.env.OPENAI_SESSION,++ label: 'OpenAI browser session',++});++const result = await credentials.balance(credential.id);++```++++Session cookies are encrypted at rest. They can perform actions available to the signed-in browser account while valid. OpenVibe uses them only for fixed, read-only provider readers: Anthropic Console prepaid credits and current spend at `console.anthropic.com`, and OpenAI credit grants at `api.openai.com/dashboard/billing/credit_grants`. Redirects are refused. Signing out of the provider ends the session. Anthropic credentials require the organization ID as `org_id`.++++The API is `GET`, `POST`, and `DELETE /api/v1/me/credentials`, plus `GET /api/v1/me/credentials/:id/balance`.nnew file mode 100644@@@ -0,0 +1,5 @@++// Generated by scripts/esm.js from src/credentials.js. Do not edit.++import cjs from '../src/credentials.js';++++export const { createCredentialsClient } = cjs;++export default cjs;@@@ -8,11 +8,11 @@ export const {locker, auth, registry, identity, trust, modules,events, realtime, media, community, bot, search,bench, meme, vision, themes, redact, chat,-- chatApps, ai, jobs, tools, projects, resources,-- vip, quest, live, inventory, tips, blog,-- reviews, wiki, coupons, deals, trade, space,-- host, news, food, actor, run, video,-- work, zone, play, download, openre, geo,-- usage, commerce, telemetry,++ chatApps, ai, credentials, jobs, tools, projects,++ resources, vip, quest, live, inventory, tips,++ blog, reviews, wiki, coupons, deals, trade,++ space, host, news, food, actor, run,++ video, work, zone, play, download, openre,++ geo, usage, commerce, telemetry,} = cjs;export default cjs;@@@ -29,6 +29,7 @@ module.exports = {chat: require('./src/chat'),chatApps: require('./src/chat-apps'),ai: require('./src/ai'),++ credentials: require('./src/credentials'),jobs: require('./src/jobs'),tools: require('./src/tools'),projects: require('./src/projects'),@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.102.0",++ "version": "0.103.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.102.0",++ "version": "0.103.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.102.0",++ "version": "0.103.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",@@@ -256,6 +256,12 @@"import": "./esm/ai.mjs","default": "./src/ai.js"},++ "./credentials": {++ "types": "./types/credentials.d.ts",++ "browser": "./src/credentials.js",++ "import": "./esm/credentials.mjs",++ "default": "./src/credentials.js"++ },"./jobs": {"types": "./types/jobs.d.ts","import": "./esm/jobs.mjs",@@@ -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.102.0';++const SDK_VERSION = '0.103.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,15 @@++'use strict';++++/** The current person's AI credentials and provider balance readers (metadata only on list). */++function createCredentialsClient(client, defaults = {}) {++ const { baseUrl } = defaults;++ const call = (opts, o = {}) => client.json({ service: 'ai', baseUrl, audience: 'openvibe.ai', ...opts, signal: o.signal });++ return {++ list: (o = {}) => call({ method: 'GET', path: '/api/v1/me/credentials' }, o),++ add: (credential, o = {}) => call({ method: 'POST', path: '/api/v1/me/credentials', body: credential }, o),++ remove: (id, o = {}) => call({ method: 'DELETE', path: `/api/v1/me/credentials/${encodeURIComponent(id)}` }, o),++ balance: (id, o = {}) => call({ method: 'GET', path: `/api/v1/me/credentials/${encodeURIComponent(id)}/balance` }, o),++ };++}++++module.exports = { createCredentialsClient };nnew file mode 100644@@@ -0,0 +1,16 @@++'use strict';++const t = require('node:test');++const assert = require('node:assert/strict');++const { createCredentialsClient } = require('../src/credentials');++++t.test('credentials client uses person-scoped metadata and balance endpoints', async () => {++ const calls = [];++ const client = { json: async (request) => { calls.push(request); return { credentials: [] }; } };++ const api = createCredentialsClient(client, { baseUrl: 'https://ai.example' });++ await api.list(); await api.add({ provider: 'openai', cookie: 'private' }); await api.balance('id/one'); await api.remove('id/one');++ assert.deepEqual(calls.map((x) => [x.method, x.path]), [++ ['GET', '/api/v1/me/credentials'], ['POST', '/api/v1/me/credentials'],++ ['GET', '/api/v1/me/credentials/id%2Fone/balance'], ['DELETE', '/api/v1/me/credentials/id%2Fone'],++ ]);++ assert.ok(calls.every((x) => x.audience === 'openvibe.ai' && x.baseUrl === 'https://ai.example'));++});@@@ -72,7 +72,7 @@ run([})().catch((err) => { console.error(err); process.exit(1); });`;const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));-- assert.equal(subpaths.length, 90); // Adds the browser-safe trust client.++ assert.equal(subpaths.length, 91); // Adds the browser-safe trust client (0.102.0) and the AI credentials client.assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');} finally {fs.rmSync(tmp, { recursive: true, force: true });@@@ -14,6 +14,7 @@ import * as themes from './themes';import * as redact from './redact';import * as chat from './chat';import * as ai from './ai';++import * as credentials from './credentials';import * as jobs from './jobs';import * as tools from './tools';import * as projects from './projects';@@@ -38,6 +39,7 @@ export * as themes from './themes';export * as redact from './redact';export * as chat from './chat';export * as ai from './ai';++export * as credentials from './credentials';export * as jobs from './jobs';export * as tools from './tools';export * as projects from './projects';@@@ -47,6 +49,6 @@ export * as trust from './trust';declare const sdk: typeof core & {auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;-- media: typeof media; community: typeof community; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; redact: typeof redact; chat: typeof chat; ai: typeof ai; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;++ media: typeof media; community: typeof community; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;};export default sdk;nnew file mode 100644@@@ -0,0 +1,27 @@++export interface CredentialMetadata {++ id: string;++ kind: 'api_key' | 'admin_key' | 'session_cookie';++ provider: string;++ label?: string;++ created?: string;++ last_used?: string | null;++ expires?: string | null;++ expired?: boolean;++}++export interface SessionCookieInput {++ kind?: 'session_cookie';++ provider: 'anthropic' | 'openai';++ cookie: string;++ label?: string;++ expires_at?: string;++ /** Anthropic organization identifier; not a secret. */++ org_id?: string;++}++export interface ApiKeyInput { kind?: 'api_key'; provider: string; key: string; label?: string; base_url?: string; }++export interface CredentialsClient {++ list(options?: { signal?: AbortSignal }): Promise<{ credentials: CredentialMetadata[] }>;++ add(credential: SessionCookieInput | ApiKeyInput, options?: { signal?: AbortSignal }): Promise<{ credential: CredentialMetadata }>;++ remove(id: string, options?: { signal?: AbortSignal }): Promise<void>;++ balance(id: string, options?: { signal?: AbortSignal }): Promise<{ balance: { credential: CredentialMetadata; source: string; at: string; values: Record<string, unknown> } }>;++}++export function createCredentialsClient(client: unknown, defaults?: { baseUrl?: string }): CredentialsClient;@@@ -17,6 +17,7 @@ export * as redact from './redact';export * as chat from './chat';export * as chatApps from './chat-apps';export * as ai from './ai';++export * as credentials from './credentials';export * as jobs from './jobs';export * as tools from './tools';export * as projects from './projects';
@@ -1,5 +1,12 @@
@@ -1,5 +1,12 @@
# Changelog
# Changelog
+## 0.103.0 (2026-11-08)
+
+- Add `openvibe-sdk/credentials`: `createCredentialsClient` for a person's own provider credentials on OpenVibe.AI:
+ `list()` (metadata only: kind, provider, label, created, last used, expired), `add()` for an API key or a browser
+ session cookie, `remove()`, and `balance()` (that credential's fixed read-only balance readers: Anthropic Console
+ prepaid credits and current spend, OpenAI credit grants). A secret never comes back from any call.
+
## 0.102.0 (2026-11-08)
## 0.102.0 (2026-11-08)
- Add `openvibe-sdk/trust`: `createTrustClient({ networkUrl, getToken })` with `.me()` (the caller's own signals, a
- Add `openvibe-sdk/trust`: `createTrustClient({ networkUrl, getToken })` with `.me()` (the caller's own signals, a
@@ -2,7 +2,7 @@
@@ -2,7 +2,7 @@
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.102.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.103.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.
**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.
@@ -11,7 +11,7 @@
@@ -11,7 +11,7 @@
After v0.97.1 is tagged:
After v0.97.1 is tagged:
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.102.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.103.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).
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).
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.102.0",
+ "version": "0.103.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",
@@ -24,6 +24,7 @@ module.exports = {
@@ -24,6 +24,7 @@ module.exports = {
redact: require('./src/redact'),
redact: require('./src/redact'),
chat: require('./src/chat'),
chat: require('./src/chat'),
ai: require('./src/ai'),
ai: require('./src/ai'),
+ credentials: require('./src/credentials'),
jobs: require('./src/jobs'),
jobs: require('./src/jobs'),
tools: require('./src/tools'),
tools: require('./src/tools'),
projects: require('./src/projects'),
projects: require('./src/projects'),
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.102.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.103.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, locker, registry, trust, modules, realtime, media, community, bot, search, bench, meme, vision, themes, redact, chat, ai, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
+// (auth, locker, registry, trust, modules, realtime, media, community, 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 */
/* eslint-disable */
const __defs = [
const __defs = [
// ── 0: browser.js ──────────────────────────────────────────────────
// ── 0: browser.js ──────────────────────────────────────────────────
@@ -31,10 +31,11 @@ module.exports = {
@@ -31,10 +31,11 @@ module.exports = {
redact: __load(33),
redact: __load(33),
chat: __load(34),
chat: __load(34),
ai: __load(35),
ai: __load(35),
- jobs: __load(36),
- tools: __load(38),
- projects: __load(39),
- geo: __load(40),
+ credentials: __load(36),
+ jobs: __load(37),
+ tools: __load(39),
+ projects: __load(40),
+ geo: __load(41),
};
};
},
},
// ── 1: src/core/index.js ───────────────────────────────────────────
// ── 1: src/core/index.js ───────────────────────────────────────────
@@ -49,7 +50,7 @@ const { paginate, offsetPager } = __load(7);
@@ -49,7 +50,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.102.0';
+const SDK_VERSION = '0.103.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -4773,7 +4774,25 @@ function createAiClient(client, defaults = {}) {
@@ -4773,7 +4774,25 @@ function createAiClient(client, defaults = {}) {
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
},
},
-// ── 36: src/jobs.js ─────────────────────────────────────────────────
+// ── 36: src/credentials.js ──────────────────────────────────────────
+function (module, exports) {
+'use strict';
+
+/** The current person's AI credentials and provider balance readers (metadata only on list). */
+function createCredentialsClient(client, defaults = {}) {
+ const { baseUrl } = defaults;
+ const call = (opts, o = {}) => client.json({ service: 'ai', baseUrl, audience: 'openvibe.ai', ...opts, signal: o.signal });
+ return {
+ list: (o = {}) => call({ method: 'GET', path: '/api/v1/me/credentials' }, o),
+ add: (credential, o = {}) => call({ method: 'POST', path: '/api/v1/me/credentials', body: credential }, o),
+ remove: (id, o = {}) => call({ method: 'DELETE', path: `/api/v1/me/credentials/${encodeURIComponent(id)}` }, o),
+ balance: (id, o = {}) => call({ method: 'GET', path: `/api/v1/me/credentials/${encodeURIComponent(id)}/balance` }, o),
+ };
+}
+
+module.exports = { createCredentialsClient };
+},
+// ── 37: src/jobs.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4811,7 +4830,7 @@ function (module, exports) {
@@ -4811,7 +4830,7 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { appendFiles } = __load(37);
+const { appendFiles } = __load(38);
const { parseSSE } = __load(23);
const { parseSSE } = __load(23);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
@@ -4975,7 +4994,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
@@ -4975,7 +4994,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
},
},
-// ── 37: src/core/form.js ────────────────────────────────────────────
+// ── 38: src/core/form.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5009,7 +5028,7 @@ function appendFiles(form, list, where) {
@@ -5009,7 +5028,7 @@ function appendFiles(form, list, where) {
module.exports = { isBlob, isUpload, appendFiles };
module.exports = { isBlob, isUpload, appendFiles };
},
},
-// ── 38: src/tools.js ────────────────────────────────────────────────
+// ── 39: src/tools.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5043,8 +5062,8 @@ function (module, exports) {
@@ -5043,8 +5062,8 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { isUpload, appendFiles } = __load(37);
-const { createJobsClient } = __load(36);
+const { isUpload, appendFiles } = __load(38);
+const { createJobsClient } = __load(37);
const enc = encodeURIComponent;
const enc = encodeURIComponent;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
@@ -5294,7 +5313,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
@@ -5294,7 +5313,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
module.exports = { createToolsClient, ToolRunError, isToolRunError };
module.exports = { createToolsClient, ToolRunError, isToolRunError };
},
},
-// ── 39: src/projects.js ─────────────────────────────────────────────
+// ── 40: src/projects.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5410,7 +5429,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
@@ -5410,7 +5429,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
module.exports = { createProjectsClient };
module.exports = { createProjectsClient };
},
},
-// ── 40: src/geo.js ──────────────────────────────────────────────────
+// ── 41: src/geo.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5491,7 +5510,7 @@ export const {
@@ -5491,7 +5510,7 @@ export const {
satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,
satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,
locker, registry, trust, modules, realtime, media,
locker, registry, trust, modules, realtime, media,
community, bot, search, bench, meme, vision,
community, bot, search, bench, meme, vision,
- themes, redact, chat, ai, jobs, tools,
- projects, geo,
+ themes, redact, chat, ai, credentials, jobs,
+ tools, projects, geo,
} = sdk;
} = sdk;
export default sdk;
export default sdk;
@@ -110,6 +110,11 @@
@@ -110,6 +110,11 @@
]
]
},
},
"createClient": "function",
"createClient": "function",
+ "credentials": {
+ "object": [
+ "createCredentialsClient"
+ ]
+ },
"deals": {
"deals": {
"object": [
"object": [
"createDealsClient"
"createDealsClient"
@@ -599,6 +604,9 @@
@@ -599,6 +604,9 @@
"openvibe-sdk/coupons": {
"openvibe-sdk/coupons": {
"createCouponsClient": "function"
"createCouponsClient": "function"
},
},
+ "openvibe-sdk/credentials": {
+ "createCredentialsClient": "function"
+ },
"openvibe-sdk/db": {
"openvibe-sdk/db": {
"DbError": "class",
"DbError": "class",
"ISOLATION": {
"ISOLATION": {
new file mode 100644
new file mode 100644
@@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
+# AI credentials
+
+Use `createCredentialsClient` from `openvibe-sdk/credentials` with a person-authenticated core client to list metadata, add or remove a credential, and run its balance readers. `list()` never returns secret values.
+
+```js
+const credentials = createCredentialsClient(client, { baseUrl: 'https://ai.openvibe.network' });
+const { credentials: stored } = await credentials.list();
+const { credential } = await credentials.add({
+ kind: 'session_cookie', provider: 'openai', cookie: process.env.OPENAI_SESSION,
+ label: 'OpenAI browser session',
+});
+const result = await credentials.balance(credential.id);
+```
+
+Session cookies are encrypted at rest. They can perform actions available to the signed-in browser account while valid. OpenVibe uses them only for fixed, read-only provider readers: Anthropic Console prepaid credits and current spend at `console.anthropic.com`, and OpenAI credit grants at `api.openai.com/dashboard/billing/credit_grants`. Redirects are refused. Signing out of the provider ends the session. Anthropic credentials require the organization ID as `org_id`.
+
+The API is `GET`, `POST`, and `DELETE /api/v1/me/credentials`, plus `GET /api/v1/me/credentials/:id/balance`.
new file mode 100644
new file mode 100644
@@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
+// Generated by scripts/esm.js from src/credentials.js. Do not edit.
+import cjs from '../src/credentials.js';
+
+export const { createCredentialsClient } = cjs;
+export default cjs;
@@ -8,11 +8,11 @@ export const {
@@ -8,11 +8,11 @@ export const {
locker, auth, registry, identity, trust, modules,
locker, auth, registry, identity, trust, modules,
events, realtime, media, community, bot, search,
events, realtime, media, community, bot, search,
bench, meme, vision, themes, redact, chat,
bench, meme, vision, themes, redact, chat,
- chatApps, ai, jobs, tools, projects, resources,
- vip, quest, live, inventory, tips, blog,
- reviews, wiki, coupons, deals, trade, space,
- host, news, food, actor, run, video,
- work, zone, play, download, openre, geo,
- usage, commerce, telemetry,
+ chatApps, ai, credentials, jobs, tools, projects,
+ resources, vip, quest, live, inventory, tips,
+ blog, reviews, wiki, coupons, deals, trade,
+ space, host, news, food, actor, run,
+ video, work, zone, play, download, openre,
+ geo, usage, commerce, telemetry,
} = cjs;
} = cjs;
export default cjs;
export default cjs;
@@ -29,6 +29,7 @@ module.exports = {
@@ -29,6 +29,7 @@ module.exports = {
chat: require('./src/chat'),
chat: require('./src/chat'),
chatApps: require('./src/chat-apps'),
chatApps: require('./src/chat-apps'),
ai: require('./src/ai'),
ai: require('./src/ai'),
+ credentials: require('./src/credentials'),
jobs: require('./src/jobs'),
jobs: require('./src/jobs'),
tools: require('./src/tools'),
tools: require('./src/tools'),
projects: require('./src/projects'),
projects: require('./src/projects'),
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.102.0",
+ "version": "0.103.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.102.0",
+ "version": "0.103.0",
"license": "MIT",
"license": "MIT",
"bin": {
"bin": {
"openvibe-download": "bin/openvibe-download.js"
"openvibe-download": "bin/openvibe-download.js"
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.102.0",
+ "version": "0.103.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",
@@ -256,6 +256,12 @@
@@ -256,6 +256,12 @@
"import": "./esm/ai.mjs",
"import": "./esm/ai.mjs",
"default": "./src/ai.js"
"default": "./src/ai.js"
},
},
+ "./credentials": {
+ "types": "./types/credentials.d.ts",
+ "browser": "./src/credentials.js",
+ "import": "./esm/credentials.mjs",
+ "default": "./src/credentials.js"
+ },
"./jobs": {
"./jobs": {
"types": "./types/jobs.d.ts",
"types": "./types/jobs.d.ts",
"import": "./esm/jobs.mjs",
"import": "./esm/jobs.mjs",
@@ -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.102.0';
+const SDK_VERSION = '0.103.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
+'use strict';
+
+/** The current person's AI credentials and provider balance readers (metadata only on list). */
+function createCredentialsClient(client, defaults = {}) {
+ const { baseUrl } = defaults;
+ const call = (opts, o = {}) => client.json({ service: 'ai', baseUrl, audience: 'openvibe.ai', ...opts, signal: o.signal });
+ return {
+ list: (o = {}) => call({ method: 'GET', path: '/api/v1/me/credentials' }, o),
+ add: (credential, o = {}) => call({ method: 'POST', path: '/api/v1/me/credentials', body: credential }, o),
+ remove: (id, o = {}) => call({ method: 'DELETE', path: `/api/v1/me/credentials/${encodeURIComponent(id)}` }, o),
+ balance: (id, o = {}) => call({ method: 'GET', path: `/api/v1/me/credentials/${encodeURIComponent(id)}/balance` }, o),
+ };
+}
+
+module.exports = { createCredentialsClient };
new file mode 100644
new file mode 100644
@@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
+'use strict';
+const t = require('node:test');
+const assert = require('node:assert/strict');
+const { createCredentialsClient } = require('../src/credentials');
+
+t.test('credentials client uses person-scoped metadata and balance endpoints', async () => {
+ const calls = [];
+ const client = { json: async (request) => { calls.push(request); return { credentials: [] }; } };
+ const api = createCredentialsClient(client, { baseUrl: 'https://ai.example' });
+ await api.list(); await api.add({ provider: 'openai', cookie: 'private' }); await api.balance('id/one'); await api.remove('id/one');
+ assert.deepEqual(calls.map((x) => [x.method, x.path]), [
+ ['GET', '/api/v1/me/credentials'], ['POST', '/api/v1/me/credentials'],
+ ['GET', '/api/v1/me/credentials/id%2Fone/balance'], ['DELETE', '/api/v1/me/credentials/id%2Fone'],
+ ]);
+ assert.ok(calls.every((x) => x.audience === 'openvibe.ai' && x.baseUrl === 'https://ai.example'));
+});
@@ -72,7 +72,7 @@ run([
@@ -72,7 +72,7 @@ run([
})().catch((err) => { console.error(err); process.exit(1); });`;
})().catch((err) => { console.error(err); process.exit(1); });`;
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
- assert.equal(subpaths.length, 90); // Adds the browser-safe trust client.
+ assert.equal(subpaths.length, 91); // Adds the browser-safe trust client (0.102.0) and the AI credentials client.
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
} finally {
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
fs.rmSync(tmp, { recursive: true, force: true });
@@ -14,6 +14,7 @@ import * as themes from './themes';
@@ -14,6 +14,7 @@ import * as themes from './themes';
import * as redact from './redact';
import * as redact from './redact';
import * as chat from './chat';
import * as chat from './chat';
import * as ai from './ai';
import * as ai from './ai';
+import * as credentials from './credentials';
import * as jobs from './jobs';
import * as jobs from './jobs';
import * as tools from './tools';
import * as tools from './tools';
import * as projects from './projects';
import * as projects from './projects';
@@ -38,6 +39,7 @@ export * as themes from './themes';
@@ -38,6 +39,7 @@ export * as themes from './themes';
export * as redact from './redact';
export * as redact from './redact';
export * as chat from './chat';
export * as chat from './chat';
export * as ai from './ai';
export * as ai from './ai';
+export * as credentials from './credentials';
export * as jobs from './jobs';
export * as jobs from './jobs';
export * as tools from './tools';
export * as tools from './tools';
export * as projects from './projects';
export * as projects from './projects';
@@ -47,6 +49,6 @@ export * as trust from './trust';
@@ -47,6 +49,6 @@ export * as trust from './trust';
declare const sdk: typeof core & {
declare const sdk: typeof core & {
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
- media: typeof media; community: typeof community; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; redact: typeof redact; chat: typeof chat; ai: typeof ai; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;
+ media: typeof media; community: typeof community; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;
};
};
export default sdk;
export default sdk;
new file mode 100644
new file mode 100644
@@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
+export interface CredentialMetadata {
+ id: string;
+ kind: 'api_key' | 'admin_key' | 'session_cookie';
+ provider: string;
+ label?: string;
+ created?: string;
+ last_used?: string | null;
+ expires?: string | null;
+ expired?: boolean;
+}
+export interface SessionCookieInput {
+ kind?: 'session_cookie';
+ provider: 'anthropic' | 'openai';
+ cookie: string;
+ label?: string;
+ expires_at?: string;
+ /** Anthropic organization identifier; not a secret. */
+ org_id?: string;
+}
+export interface ApiKeyInput { kind?: 'api_key'; provider: string; key: string; label?: string; base_url?: string; }
+export interface CredentialsClient {
+ list(options?: { signal?: AbortSignal }): Promise<{ credentials: CredentialMetadata[] }>;
+ add(credential: SessionCookieInput | ApiKeyInput, options?: { signal?: AbortSignal }): Promise<{ credential: CredentialMetadata }>;
+ remove(id: string, options?: { signal?: AbortSignal }): Promise<void>;
+ balance(id: string, options?: { signal?: AbortSignal }): Promise<{ balance: { credential: CredentialMetadata; source: string; at: string; values: Record<string, unknown> } }>;
+}
+export function createCredentialsClient(client: unknown, defaults?: { baseUrl?: string }): CredentialsClient;
@@ -17,6 +17,7 @@ export * as redact from './redact';
@@ -17,6 +17,7 @@ export * as redact from './redact';
export * as chat from './chat';
export * as chat from './chat';
export * as chatApps from './chat-apps';
export * as chatApps from './chat-apps';
export * as ai from './ai';
export * as ai from './ai';
+export * as credentials from './credentials';
export * as jobs from './jobs';
export * as jobs from './jobs';
export * as tools from './tools';
export * as tools from './tools';
export * as projects from './projects';
export * as projects from './projects';