openvibers/openvibe.sdk Commits

BA3: the batches say what cancelling does (#135)

OP OpenVibers committed 5 days ago · d1162f28a7 · 9 files, +36 −12

ai.batches.cancel touches only the prompts that never had a run; a prompt that already has a run goes on and settles on its own path, and nobody is told it was not charged.

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex 75bf848..5717d09 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,14 @@
# Changelog
++## 0.98.1 (2026-11-07)
++
++- `ai.batches.cancel` says what cancelling does: only the prompts that never had a run are cancelled, and
++ nothing is charged for them. A prompt that already has a run (the provider is working on it) goes on and
++ settles on its own path: it keeps its status, the answer says so, and nobody is told it was not charged.
++ The batch itself is cancelled only when nothing is left in flight. The same note is on `AiBatchItem.reason`.
++ No runtime change.
++
++
## 0.98.0 (2026-11-07)
- `ai.runs.create` (and the direct operations) may ask for the class the caller may wait in:
ddiff --git a/README.md b/README.md
iindex aeafd2e..47c1d81 100644
---- a/README.md
++++ b/README.md
@@@ -2,7 +2,7 @@
> Supported browser and server clients for the OpenVibe platform.
--**Status:** alpha, v0.98.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.98.1 (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.98.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.98.1
```
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 92296d3..3a18aa4 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.98.0",
++ "version": "0.98.1",
"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 7330566..963a88c 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.98.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.98.1, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, locker, registry, 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.
/* eslint-disable */
@@@ -48,7 +48,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.98.0';
++const SDK_VERSION = '0.98.1';
module.exports = {
createClient,
@@@ -4692,7 +4692,13 @@ function createAiClient(client, defaults = {}) {
list: (query = {}, o = {}) => call({ path: '/api/v1/batches', query }, o),
/** One batch with its items → { batch } (null when there is no such batch) */
get: (id, o = {}) => orNull(call({ path: `/api/v1/batches/${enc(id)}` }, o)),
-- /** Cancel a batch: the items that had not run are cancelled and nothing is charged for them → { batch } */
++ /**
++ * Cancel a batch → { batch }
++ *
++ * Only the prompts that never had a run are cancelled, and nothing is charged for them. A prompt
++ * that already has a run (the provider is working on it) goes on and settles on its own path: it
++ * keeps its status, the answer says so, and nobody is told it was not charged.
++ */
cancel: (id, o = {}) => call({ method: 'POST', path: `/api/v1/batches/${enc(id)}/cancel`, idempotencyKey: false }, o),
};
ddiff --git a/package-lock.json b/package-lock.json
iindex 587a76d..a568d44 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.98.0",
++ "version": "0.98.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.98.0",
++ "version": "0.98.1",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex 5efd634..d647e4b 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.98.0",
++ "version": "0.98.1",
"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 ba6c5ff..f9251f7 100644
---- a/src/ai.js
++++ b/src/ai.js
@@@ -106,7 +106,13 @@ function createAiClient(client, defaults = {}) {
list: (query = {}, o = {}) => call({ path: '/api/v1/batches', query }, o),
/** One batch with its items → { batch } (null when there is no such batch) */
get: (id, o = {}) => orNull(call({ path: `/api/v1/batches/${enc(id)}` }, o)),
-- /** Cancel a batch: the items that had not run are cancelled and nothing is charged for them → { batch } */
++ /**
++ * Cancel a batch → { batch }
++ *
++ * Only the prompts that never had a run are cancelled, and nothing is charged for them. A prompt
++ * that already has a run (the provider is working on it) goes on and settles on its own path: it
++ * keeps its status, the answer says so, and nobody is told it was not charged.
++ */
cancel: (id, o = {}) => call({ method: 'POST', path: `/api/v1/batches/${enc(id)}/cancel`, idempotencyKey: false }, o),
};
ddiff --git a/src/core/index.js b/src/core/index.js
iindex 1f233e6..dab6cf0 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.98.0';
++const SDK_VERSION = '0.98.1';
module.exports = {
createClient,
ddiff --git a/types/ai.d.ts b/types/ai.d.ts
iindex e970fc8..857aa19 100644
---- a/types/ai.d.ts
++++ b/types/ai.d.ts
@@@ -22,7 +22,9 @@ export interface AiBatchItem {
idx: number;
status: 'queued' | 'waiting' | 'running' | 'succeeded' | 'failed' | 'expired' | 'cancelled' | string;
model?: string | null; run_id?: string | null; answer?: string | null;
-- error_code?: string | null; error_detail?: string | null; reason?: string | null; capacity?: string | null;
++ error_code?: string | null; error_detail?: string | null;
++ /** The plain note about the prompt: it expired (it was not charged), it was cancelled before it ran (it was not charged), or it was already sent to the provider (it finishes and is charged). */
++ reason?: string | null; capacity?: string | null;
route_provider?: string | null; route_model?: string | null;
cost_nano_usd?: string | null; absorbed_nano_usd?: string | null; charged_nano_usd?: string | null;
deadline_at?: string; created_at?: string; updated_at?: string;
@@@ -42,6 +44,7 @@ export interface AiBatches {
create(items: Array<string | { prompt: string; model?: string }>, opts?: { model?: string; deadlineHours?: number; idempotencyKey?: string; signal?: AbortSignal }): Promise<{ batch: AiBatch }>;
list(query?: Record<string, string | number>, opts?: { signal?: AbortSignal }): Promise<{ batches: AiBatch[]; [field: string]: unknown }>;
get(id: string, opts?: { signal?: AbortSignal }): Promise<{ batch: AiBatch } | null>;
++ /** Cancels a batch: only the prompts that never had a run are cancelled, and nothing is charged for them; a prompt that already has a run goes on and settles on its own path. */
cancel(id: string, opts?: { signal?: AbortSignal }): Promise<{ batch: AiBatch }>;
}
type Op = (input?: Record<string, unknown>, opts?: Omit<RunOptions, 'version' | 'onBehalfOf'>) => Promise<RunResponse>;