openvibers/openvibe.sdk Commits

SDK 0.150.0: typed file-capable AI turns (#225)

OP OpenVibers committed 2 days ago · 96fa089bba · 10 files, +40 −17

* SDK 0.149.0: typed file-capable AI turns

* Type image task owner controls in SDK

* Sync SDK release metadata and browser bundle

* Merge SDK main and prepare file turns for 0.150.0

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex a7edc18..0f59730 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,10 @@
# Changelog
++## 0.150.0 — 2026-11-11
++
++- Add `ai.turn(input, options)` for file-capable `ai.complete` runs. Its typed `output_file` option stores a text, Markdown, CSV or JSON answer in Media and returns private `ai.file` artifact references; existing `ai.files.read()` reads a returned object.
++- Type the image task's owner daily cap and guest find switch in `AiTaskDefaults`.
++
## 0.149.0 — 2026-11-11
- Extend the existing `codes` client with `modelPlans.get/put/presets()` and `tasks.create({ plan | preset })`, typed for `codes.model-plan@1` on Contracts 0.406.0.
ddiff --git a/README.md b/README.md
iindex a6e74a7..e6df453 100644
---- a/README.md
++++ b/README.md
@@@ -8,12 +8,12 @@
**Install and test:** `npm ci && npm test` (Node 20 or newer)
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.149.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.150.0
```
> Supported browser and server clients for the OpenVibe platform.
--**Status:** alpha, v0.149.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.150.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.
@@@ -22,7 +22,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.149.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.150.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 4974e4a..fee62b8 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.149.0",
++ "version": "0.150.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 46dd6d8..399c1e2 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.149.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.150.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, levels, modules, realtime, media, composer, cam, mediaUpload, ui, community, homeFeed, feed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, agents, tools, projects, geo, history, userCard, player, agentSheet). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
@@@ -64,7 +64,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.149.0';
++const SDK_VERSION = '0.150.0';
module.exports = {
createClient,
@@@ -5549,6 +5549,8 @@ function createAiClient(client, defaults = {}) {
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);
};
++ /** A typed file-capable turn through the ai.complete workflow; output_file stores the answer in Media. */
++ const turn = (input, o = {}) => runs.create('ai.complete', input, o);
const admin = { defaults: (value, o = {}) => call({ path: '/api/v1/admin/task-defaults', ...(value === undefined ? {} : { method: 'PUT', json: value, idempotencyKey: false }) }, o) };
const batches = {
@@@ -5617,7 +5619,7 @@ function createAiClient(client, defaults = {}) {
};
const metrics = __load(46).createMetricsClient(call);
-- const api = { tasks, creations, choices, run, admin, runs, batches, files, metrics, TERMINAL, CLASSES };
++ const api = { tasks, creations, choices, run, turn, admin, runs, batches, files, metrics, 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 4c3560a..56f0b10 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.149.0",
++ "version": "0.150.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.149.0",
++ "version": "0.150.0",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex 04006b4..cac5b11 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.149.0",
++ "version": "0.150.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/ai.js b/src/ai.js
iindex bb8e228..dd15924 100644
---- a/src/ai.js
++++ b/src/ai.js
@@@ -107,6 +107,8 @@ function createAiClient(client, defaults = {}) {
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);
};
++ /** A typed file-capable turn through the ai.complete workflow; output_file stores the answer in Media. */
++ const turn = (input, o = {}) => runs.create('ai.complete', input, o);
const admin = { defaults: (value, o = {}) => call({ path: '/api/v1/admin/task-defaults', ...(value === undefined ? {} : { method: 'PUT', json: value, idempotencyKey: false }) }, o) };
const batches = {
@@@ -175,7 +177,7 @@ function createAiClient(client, defaults = {}) {
};
const metrics = require('./ai-metrics').createMetricsClient(call);
-- const api = { tasks, creations, choices, run, admin, runs, batches, files, metrics, TERMINAL, CLASSES };
++ const api = { tasks, creations, choices, run, turn, admin, runs, batches, files, metrics, 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 8fa3bdd..f7a8ad9 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.149.0';
++const SDK_VERSION = '0.150.0';
module.exports = {
createClient,
ddiff --git a/test/ai.test.js b/test/ai.test.js
iindex e678ce2..68ae4d4 100644
---- a/test/ai.test.js
++++ b/test/ai.test.js
@@@ -48,6 +48,18 @@ run([
assert.equal(srv.requests[0].headers.authorization, undefined, 'public: no token is sent');
await srv.close();
}],
++ ['turn sends Media file references and the requested output file through ai.complete', async () => {
++ const srv = await aiStub();
++ const ai = createAiClient(createClient({ baseUrls: { ai: srv.url }, token: 't' }));
++ await ai.turn({ messages: [{ role: 'user', content: 'Summarize this file' }], files: [{ id: 'med_example' }],
++ output_file: { name: 'answer.md', media_type: 'text/markdown' } },
++ { wait: 1000, onBehalfOf: { type: 'user', id: 'usr_example' } });
++ assert.deepEqual(JSON.parse(String(srv.requests[0].body)), {
++ workflow: 'ai.complete', input: { messages: [{ role: 'user', content: 'Summarize this file' }], files: [{ id: 'med_example' }],
++ output_file: { name: 'answer.md', media_type: 'text/markdown' } }, on_behalf_of: { type: 'user', id: 'usr_example' },
++ });
++ await srv.close();
++ }],
['a create without a key is not retried; direct ops post the input as the body', async () => {
const srv = await aiStub();
const ai = createAiClient(createClient({ baseUrls: { ai: srv.url }, token: 't', retries: 2 }));
ddiff --git a/types/ai.d.ts b/types/ai.d.ts
iindex 7df7ec5..de52dd6 100644
---- a/types/ai.d.ts
++++ b/types/ai.d.ts
@@@ -4,9 +4,11 @@ import type { OpenVibeClient } from './core';
export interface AiRun { id: string; status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | string; workflow?: { key: string; version: number }; output?: unknown; error?: unknown; latency_class?: LatencyClass; service_tier?: ServiceTier | null; latency_clamped?: { asked: LatencyClass; used: LatencyClass } | null; [field: string]: unknown; }
export interface AiFile { id: string; name: string; media_type: string; size: number; storage: { provider: 'media'; key: string }; access: { readers: string[] }; read: { method: 'text' | 'pages' | 'image' | 'audio_transcript' | 'not_readable'; content?: string; pages?: string[]; reason?: string }; role?: 'input' | 'artifact'; }
--export interface AiTurnMessage { role: 'user' | 'assistant'; content: string; files?: AiFile[]; }
--export interface AiTurnRequest { messages: AiTurnMessage[]; files?: AiFile[]; }
--export interface AiTurnResult { content: string; artifacts: AiFile[]; }
++export interface AiTurnMessage { role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; content: string | null; files?: AiFile[]; }
++export interface AiOutputFile { name: string; media_type: 'text/plain' | 'text/markdown' | 'text/csv' | 'application/json'; }
++export interface AiTurnRequest { messages: AiTurnMessage[]; files?: Array<AiFile | Pick<AiFile, 'id'>>; output_file?: AiOutputFile; model?: string; max_tokens?: number; }
++export interface AiTurnResult { content?: string; choices?: Array<{ index: number; message: { role: 'assistant'; content: string | null; artifacts?: AiFile[] }; finish_reason?: string | null }>; artifacts?: AiFile[]; model?: string | null; }
++export interface AiTurnResponse { run: AiRun & { output?: AiTurnResult }; replayed?: boolean; }
export interface AiFiles { attach(data: Blob | ArrayBuffer | ArrayBufferView | string, opts?: { filename?: string; mediaType?: string; subject?: string; signal?: AbortSignal; [option: string]: unknown }): Promise<AiFile>; list(opts?: Record<string, unknown>): Promise<{ files: AiFile[]; [field: string]: unknown }>; read(id: string, opts?: { ttl?: number; signal?: AbortSignal }): Promise<{ file: unknown; bytes: Uint8Array }>; remove(id: string): Promise<boolean>; }
/** How long the caller may wait: interactive (as soon as the provider can), background (minutes, priced on the cheapest tier that can wait), batch (hours, answered through the provider's own batch API). */
export type LatencyClass = 'interactive' | 'background' | 'batch';
@@@ -14,7 +16,7 @@ export type LatencyClass = 'interactive' | 'background' | 'batch';
export type ServiceTier = 'standard' | 'flex' | 'batch' | 'offpeak' | 'local';
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 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; daily_cap?: number | null; guest_find?: boolean; effort?: 'low' | 'medium' | 'high' | 'max'; }
/** One thing AI can make, as GET /api/v1/creations lists it (ai.creation@1). */
export interface AiCreation {
id: string;
@@@ -72,7 +74,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 { metrics: AiMetrics; tasks(opts?: {signal?: AbortSignal}): Promise<{tasks: AiTask[]}>; creations(opts?: {signal?: AbortSignal}): Promise<AiCreationList>; 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; files: AiFiles; TERMINAL: Set<string>; CLASSES: string[]; chat: Op; generate: Op; summarize: Op; classify: Op; extract: Op; enrich: Op; embed: Op; }
++export interface AiClient { metrics: AiMetrics; tasks(opts?: {signal?: AbortSignal}): Promise<{tasks: AiTask[]}>; creations(opts?: {signal?: AbortSignal}): Promise<AiCreationList>; run(task: string, input?: Record<string, unknown>, opts?: RunOptions): Promise<RunResponse>; turn(input: AiTurnRequest, opts?: RunOptions): Promise<AiTurnResponse>; 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; files: AiFiles; 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; media?: Record<string, unknown> & { app: string; subject?: string }; objectsClient?: { upload: Function; list: Function; signedUrl: Function; get: Function; delete: Function }; fetch?: typeof fetch }): AiClient;
export const TERMINAL: Set<string>;
export const OPS: string[];