openvibers/openvibe.sdk Commits

0.127.0: AI tasks, choices and admin defaults in the AI client (#168)

OP OpenVibers committed 4 days ago · 22b466119b · 10 files, +67 −18

* AI tasks and choices in the AI client

ov.ai.tasks() lists the task catalogue, ov.ai.choices.get/set reads and saves a
person's choice for a task, ov.ai.run(task, input, {choice}) starts a run from a
task, and ov.ai.admin.defaults() reads or writes the owner's per-task defaults.
runs.create() also carries `task` and `choice`.

Version 0.124.0.

* 0.124.0 in SDK_VERSION, the lockfile, the bundle and the README

The version test reads all of them, and they still said 0.123.0.

* Merge main; 0.127.0: AI tasks and choices in the AI client

Main released 0.126.0 (the Pics client) while this branch was open. The AI tasks
and choices land as 0.127.0 on top of it, with SDK_VERSION, the lockfile, the
bundle and the README naming the same release.

* Pin openvibe-contracts 0.374.0 and name 0.127.0 in STATUS.json

The resources name helpers need contracts' resources (0.374.0), and the pin was
0.372.0, so the resources test was red on main. STATUS.json still said 0.126.0.

* Set AI choices SDK release to 0.128.0

* Retry CI after incomplete GitHub workflow scheduling

* Restart CI after GitHub Actions outage

* Retry SDK CI trigger after Actions recovery

* Merge SDK 0.127.0 and keep AI choices at 0.128.0

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex 5d0a8f2..a23121c 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,9 @@
# Changelog
++## 0.128.0 (2026-11-09)
++
++- ov.ai: tasks(), choices.get/set, run(task, input, {choice}) and admin.defaults(); runs.create accepts `task` and `choice`
++
## 0.127.0 — 2026-11-09
- `openvibe-sdk/git` (`ov.git`): repositories, trees, blobs, commits, branches, tags, releases, contributors,
ddiff --git a/README.md b/README.md
iindex a3c4805..d356e23 100644
---- a/README.md
++++ b/README.md
@@@ -10,7 +10,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
> Supported browser and server clients for the OpenVibe platform.
--**Status:** alpha, v0.127.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.128.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.
@@@ -19,7 +19,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
After v0.97.1 is tagged:
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.127.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.128.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 3de9020..6624ae4 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.127.0",
++ "version": "0.128.0",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), \u00a73.2; roadmap \u00a730",
"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 3313dd6..9fdfb94 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.127.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.128.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, mediaUpload, ui, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
@@@ -56,7 +56,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.127.0';
++const SDK_VERSION = '0.128.0';
module.exports = {
createClient,
@@@ -5019,6 +5019,8 @@ function createAiClient(client, defaults = {}) {
/** workflow key (e.g. 'wiki.generate_page'), its input; o: { wait (ms), version, idempotencyKey, target, attribution, onBehalfOf, latency, deadlineHours, options } */
create(workflow, input = {}, o = {}) {
const body = { workflow, input };
++ if (o.choice !== undefined) body.choice = o.choice;
++ if (o.task !== undefined) body.task = o.task;
if (o.version != null) body.version = o.version;
if (o.target !== undefined) body.target = o.target;
if (o.attribution !== undefined) body.attribution = o.attribution;
@@@ -5059,6 +5061,17 @@ function createAiClient(client, defaults = {}) {
},
};
++ const tasks = (o = {}) => call({ path: '/api/v1/tasks' }, o);
++ const choices = {
++ get: (task, o = {}) => call({ path: '/api/v1/choices', query: { task } }, o),
++ set: (task, choice, o = {}) => call({ method: 'PUT', path: `/api/v1/me/choices/${enc(task)}`, json: choice, idempotencyKey: false }, o),
++ };
++ const run = (task, input = {}, o = {}) => {
++ const body = { task, input, ...(o.choice ? { choice: o.choice } : {}), ...(o.onBehalfOf ? { on_behalf_of: o.onBehalfOf } : {}), ...(runOptions(o) ? { options: runOptions(o) } : {}) };
++ return call({ method: 'POST', path: '/api/v1/runs', query: waitQuery(o), json: body, ...writeOpts(o) }, o);
++ };
++ const admin = { defaults: (value, o = {}) => call({ path: '/api/v1/admin/task-defaults', ...(value === undefined ? {} : { method: 'PUT', json: value, idempotencyKey: false }) }, o) };
++
const batches = {
/** The prompts of a batch (a string, or { prompt, model }); o: { model, deadlineHours, idempotencyKey } → { batch } */
create(items, o = {}) {
@@@ -5081,7 +5094,7 @@ function createAiClient(client, defaults = {}) {
cancel: (id, o = {}) => call({ method: 'POST', path: `/api/v1/batches/${enc(id)}/cancel`, idempotencyKey: false }, o),
};
-- const api = { runs, batches, TERMINAL, CLASSES };
++ const api = { tasks, choices, run, admin, runs, batches, TERMINAL, CLASSES };
// Direct operations: a run of workflow ai.<op> with the input as the body, waited for by AI.
for (const op of OPS) {
api[op] = (input = {}, o = {}) => call({ method: 'POST', path: `/api/v1/${op}`, query: waitQuery(o),
ddiff --git a/package-lock.json b/package-lock.json
iindex 623ebaf..2eca6b6 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.127.0",
++ "version": "0.128.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.127.0",
++ "version": "0.128.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.372.0",
++ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.375.0",
"pg": "^8.23.0"
},
"engines": {
@@@ -198,9 +198,9 @@
"license": "MIT"
},
"node_modules/openvibe-contracts": {
-- "version": "0.372.0",
-- "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.372.0",
-- "integrity": "sha512-HnfBnkhfMXYNbW4NnpTAMqZc0uV9d4XvwA20VaZXZFbBTPZiClYfoZ0/TWWWh24BFANx9TSzC+4jE0WDHKuNhA==",
++ "version": "0.375.0",
++ "resolved": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.375.0",
++ "integrity": "sha512-+HI3XAkqkDW1ANR0SyGSXAYTko/z0SsDB9uIdswQCiYixoS/9M3RYGqPOFr+VevvZH9CG9hXvW0Tp3ecc0qaXw==",
"dev": true,
"license": "AGPL-3.0-only",
"dependencies": {
ddiff --git a/package.json b/package.json
iindex 2c61af0..86f169b 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.127.0",
++ "version": "0.128.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",
@@@ -624,7 +624,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.372.0",
++ "openvibe-contracts": "https://codeload.github.com/OpenVibers/OpenVibe.Contracts/tar.gz/refs/tags/v0.375.0",
"pg": "^8.23.0"
},
"peerDependencies": {
ddiff --git a/src/ai.js b/src/ai.js
iindex f9251f7..82b212f 100644
---- a/src/ai.js
++++ b/src/ai.js
@@@ -54,6 +54,8 @@ function createAiClient(client, defaults = {}) {
/** workflow key (e.g. 'wiki.generate_page'), its input; o: { wait (ms), version, idempotencyKey, target, attribution, onBehalfOf, latency, deadlineHours, options } */
create(workflow, input = {}, o = {}) {
const body = { workflow, input };
++ if (o.choice !== undefined) body.choice = o.choice;
++ if (o.task !== undefined) body.task = o.task;
if (o.version != null) body.version = o.version;
if (o.target !== undefined) body.target = o.target;
if (o.attribution !== undefined) body.attribution = o.attribution;
@@@ -94,6 +96,17 @@ function createAiClient(client, defaults = {}) {
},
};
++ const tasks = (o = {}) => call({ path: '/api/v1/tasks' }, o);
++ const choices = {
++ get: (task, o = {}) => call({ path: '/api/v1/choices', query: { task } }, o),
++ set: (task, choice, o = {}) => call({ method: 'PUT', path: `/api/v1/me/choices/${enc(task)}`, json: choice, idempotencyKey: false }, o),
++ };
++ const run = (task, input = {}, o = {}) => {
++ const body = { task, input, ...(o.choice ? { choice: o.choice } : {}), ...(o.onBehalfOf ? { on_behalf_of: o.onBehalfOf } : {}), ...(runOptions(o) ? { options: runOptions(o) } : {}) };
++ return call({ method: 'POST', path: '/api/v1/runs', query: waitQuery(o), json: body, ...writeOpts(o) }, o);
++ };
++ const admin = { defaults: (value, o = {}) => call({ path: '/api/v1/admin/task-defaults', ...(value === undefined ? {} : { method: 'PUT', json: value, idempotencyKey: false }) }, o) };
++
const batches = {
/** The prompts of a batch (a string, or { prompt, model }); o: { model, deadlineHours, idempotencyKey } → { batch } */
create(items, o = {}) {
@@@ -116,7 +129,7 @@ function createAiClient(client, defaults = {}) {
cancel: (id, o = {}) => call({ method: 'POST', path: `/api/v1/batches/${enc(id)}/cancel`, idempotencyKey: false }, o),
};
-- const api = { runs, batches, TERMINAL, CLASSES };
++ const api = { tasks, choices, run, admin, runs, batches, TERMINAL, CLASSES };
// Direct operations: a run of workflow ai.<op> with the input as the body, waited for by AI.
for (const op of OPS) {
api[op] = (input = {}, o = {}) => call({ method: 'POST', path: `/api/v1/${op}`, query: waitQuery(o),
ddiff --git a/src/core/index.js b/src/core/index.js
iindex f88cf67..259b512 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.127.0';
++const SDK_VERSION = '0.128.0';
module.exports = {
createClient,
ddiff --git a/test/ai-choices.test.js b/test/ai-choices.test.js
nnew file mode 100644
iindex 0000000..761640f
---- /dev/null
++++ b/test/ai-choices.test.js
@@@ -0,0 +1,16 @@
++'use strict';
++const assert=require('node:assert/strict');
++const {createAiClient}=require('../src/ai');
++const calls=[];const ai=createAiClient({json:async r=>{calls.push(r);return {ok:true};}});
++(async()=>{
++ const choice={model:'anthropic/claude-opus-5-5',source:'openvibe'};
++ await ai.tasks();await ai.choices.get('design.icon');await ai.choices.set('design.icon',choice);
++ await ai.run('design.icon',{prompt:'A tree'},{choice,wait:1000});
++ await ai.runs.create('ai.generate',{prompt:'A tree'},{choice});
++ await ai.admin.defaults();await ai.admin.defaults({defaults:[]});
++ assert.equal(calls[0].path,'/api/v1/tasks');assert.deepEqual(calls[1].query,{task:'design.icon'});
++ assert.equal(calls[2].method,'PUT');assert.deepEqual(calls[2].json,choice);
++ assert.deepEqual(calls[3].json,{task:'design.icon',input:{prompt:'A tree'},choice});
++ assert.deepEqual(calls[4].json.choice,choice);assert.equal(calls[5].path,'/api/v1/admin/task-defaults');assert.equal(calls[6].method,'PUT');
++ console.log('AI choices: seven client operations preserve their wire shape');
++})().catch(e=>{console.error(e);process.exitCode=1;});
ddiff --git a/types/ai.d.ts b/types/ai.d.ts
iindex 857aa19..c0f08c4 100644
---- a/types/ai.d.ts
++++ b/types/ai.d.ts
@@@ -5,7 +5,10 @@ export interface AiRun { id: string; status: 'queued' | 'running' | 'succeeded'
export type LatencyClass = 'interactive' | 'background' | 'batch';
/** The tier a run was priced on: the one the provider served (standard, flex, batch) or the one the router chose (offpeak, local). */
export type ServiceTier = 'standard' | 'flex' | 'batch' | 'offpeak' | 'local';
--export interface RunOptions { wait?: number; version?: number; idempotencyKey?: string; target?: unknown; attribution?: unknown; onBehalfOf?: unknown; /** The class the caller asks for. A slower class than the workflow allows is honoured; a faster one is clamped by the service. */ latency?: LatencyClass; /** For a batch run: how long the answer may take, in hours (1 to 72). */ deadlineHours?: number; options?: Record<string, unknown>; signal?: AbortSignal; }
++export interface AiChoice { model: string; source: "openvibe" | "keys" | "machines"; machine?: string; }
++export interface AiTask { name: string; kind: "text" | "code" | "vision" | "image" | "search"; sentence: string; default: AiChoice; workflow?: string; service?: string; }
++export interface AiTaskDefaults { signed_out: AiChoice; signed_in: AiChoice; fallbacks: AiChoice[]; image_model: AiChoice | null; search_engines: Array<{ engine: string; enabled: boolean }>; max_cost_usd: number | null; }
++export interface RunOptions { choice?: AiChoice; task?: string; wait?: number; version?: number; idempotencyKey?: string; target?: unknown; attribution?: unknown; onBehalfOf?: unknown; /** The class the caller asks for. A slower class than the workflow allows is honoured; a faster one is clamped by the service. */ latency?: LatencyClass; /** For a batch run: how long the answer may take, in hours (1 to 72). */ deadlineHours?: number; options?: Record<string, unknown>; signal?: AbortSignal; }
export interface RunResponse { run: AiRun; replayed?: boolean }
export interface AiRuns {
create(workflow: string, input?: Record<string, unknown>, opts?: RunOptions): Promise<RunResponse>;
@@@ -48,7 +51,7 @@ export interface AiBatches {
cancel(id: string, opts?: { signal?: AbortSignal }): Promise<{ batch: AiBatch }>;
}
type Op = (input?: Record<string, unknown>, opts?: Omit<RunOptions, 'version' | 'onBehalfOf'>) => Promise<RunResponse>;
--export interface AiClient { runs: AiRuns; batches: AiBatches; TERMINAL: Set<string>; CLASSES: string[]; chat: Op; generate: Op; summarize: Op; classify: Op; extract: Op; enrich: Op; embed: Op; }
++export interface AiClient { tasks(opts?: {signal?: AbortSignal}): Promise<{tasks: AiTask[]}>; run(task: string, input?: Record<string, unknown>, opts?: RunOptions): Promise<RunResponse>; choices: { get(task: string, opts?: {signal?: AbortSignal}): Promise<{task: AiTask; choice: AiChoice; why: string; options: Record<string, unknown[]>}>; set(task: string, choice: AiChoice, opts?: {signal?: AbortSignal}): Promise<{choice: AiChoice}> }; admin: { defaults(value?: {defaults: Array<{task: string; value: AiTaskDefaults}>}, opts?: {signal?: AbortSignal}): Promise<{tasks?: AiTask[]; defaults: Record<string, AiTaskDefaults>}> }; runs: AiRuns; batches: AiBatches; TERMINAL: Set<string>; CLASSES: string[]; chat: Op; generate: Op; summarize: Op; classify: Op; extract: Op; enrich: Op; embed: Op; }
export function createAiClient(client: OpenVibeClient, defaults?: { baseUrl?: string }): AiClient;
export const TERMINAL: Set<string>;
export const OPS: string[];