@devvibex/aiflow 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -26
- package/package.json +1 -1
- package/src/index.d.ts +2 -36
- package/src/index.js +48 -1147
package/README.md
CHANGED
|
@@ -83,7 +83,6 @@ console.log(emb.data[0].embedding.length);
|
|
|
83
83
|
| `timeout` | `number` | `60000` | Per-request timeout (ms). |
|
|
84
84
|
| `maxRetries` | `number` | `2` | Retries on 429 / 5xx / network errors. |
|
|
85
85
|
| `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch (Node <18, testing). |
|
|
86
|
-
| `backgroundNotice` | `boolean` | `true` | `false` turns off the [background notice](#the-background-notice--1170) for the whole page. |
|
|
87
86
|
|
|
88
87
|
When you don't pass a `defaultModel`, the SDK calls `GET /config` on the
|
|
89
88
|
first `chat` / `chatStream` / `generateImage` / `embed` and caches the
|
|
@@ -210,7 +209,7 @@ finished, or when it does (also after a page change or a reload):
|
|
|
210
209
|
```js
|
|
211
210
|
useEffect(() => {
|
|
212
211
|
const job = aiflow.jobs.attach('poster');
|
|
213
|
-
if (!job || job.status === 'failed') return; // an
|
|
212
|
+
if (!job || job.status === 'failed') return; // an earlier failure: start fresh
|
|
214
213
|
if (job.status === 'processing') setLoading(true);
|
|
215
214
|
job.done
|
|
216
215
|
.then((res) => setImages(res.images))
|
|
@@ -222,29 +221,8 @@ const res = await aiflow.generateImage({ prompt, tag: 'poster' });
|
|
|
222
221
|
```
|
|
223
222
|
|
|
224
223
|
Without a tag, `jobs.attach()` picks the newest job started from the current
|
|
225
|
-
page.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
### The background notice (≥ 1.17.0)
|
|
229
|
-
|
|
230
|
-
When the user leaves the page that started a generation (or reloads it), the
|
|
231
|
-
SDK shows a small panel in the corner: *"Generating your video… It keeps going
|
|
232
|
-
in the background."* When the job finishes, the panel shows the result — image
|
|
233
|
-
thumbnails, an audio or video player, or the start of the answer — with
|
|
234
|
-
**Open page**, **Download** / **Copy** and a close button. A page that picks the
|
|
235
|
-
job up itself (`jobs.attach(…).done`, `waitForJob`, `resumeChatStream`) takes
|
|
236
|
-
over and the panel hides it. It speaks English, Korean, Vietnamese, Japanese and
|
|
237
|
-
Chinese (from `<html lang>`, then the browser), follows the system light/dark
|
|
238
|
-
setting, and never appears in a client constructed with `appSecret` or outside
|
|
239
|
-
a browser.
|
|
240
|
-
|
|
241
|
-
```js
|
|
242
|
-
// Move it, force a language, or turn it off for the whole page:
|
|
243
|
-
AIFlowClient.configureBackgroundNotice({ position: 'bottom-right', locale: 'ko' });
|
|
244
|
-
AIFlowClient.configureBackgroundNotice({ enabled: false });
|
|
245
|
-
// also: new AIFlowClient({ ..., backgroundNotice: false })
|
|
246
|
-
// or: window.__AIFLOW_BACKGROUND_NOTICE__ = false
|
|
247
|
-
```
|
|
224
|
+
page. A job still running joins the wait already open on the page, so it is
|
|
225
|
+
not polled twice.
|
|
248
226
|
|
|
249
227
|
### Job methods
|
|
250
228
|
|
|
@@ -255,7 +233,7 @@ AIFlowClient.configureBackgroundNotice({ enabled: false });
|
|
|
255
233
|
| `resumeChatStream(jobId, { from?, signal? })` | Re-attach to a streamed chat answer: chunks from character `from` (the length already shown; `0` replays all of it), then live until done. |
|
|
256
234
|
| `getJob(jobId, { waitMs? })` | One job now: `{ jobId, kind, status, tag?, prompt?, result?, error?, errorStatus?, errorCode? }`. |
|
|
257
235
|
| `listJobs({ active?, limit? })` | The signed-in end user's own jobs on this module, from any device (needs `setEndUser(id, token)`; anonymous → `[]`). No results — read one with `waitForJob`. |
|
|
258
|
-
| `jobs.latest(tag?)` / `jobs.list({ tag? })` / `jobs.forget(idOrTag)` | Jobs started from **this browser**, kept a day in localStorage: `{ jobId, kind, tag, status, result?, error?, page
|
|
236
|
+
| `jobs.latest(tag?)` / `jobs.list({ tag? })` / `jobs.forget(idOrTag)` | Jobs started from **this browser**, kept a day in localStorage: `{ jobId, kind, tag, status, result?, error?, page? }`. Works without login. |
|
|
259
237
|
|
|
260
238
|
A job whose server restarted mid-way fails with `code: 'interrupted'` (status
|
|
261
239
|
503) and is not charged — credits are deducted only on success. `chat`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvibex/aiflow",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "First-party LLM gateway SDK for apps generated on the VibeX platform — chat, streaming, image, video (including stateful multi-turn video extension with Gemini Omni), music (Lyria), sound effects (ElevenLabs), embeddings and real-time speech translation (Gemini Live) without shipping any third-party API key.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
package/src/index.d.ts
CHANGED
|
@@ -104,18 +104,6 @@ export interface RememberedJob {
|
|
|
104
104
|
error?: string;
|
|
105
105
|
/** The page that started it: path, plus the `#/…` route of a hash router (≥ 1.17.0). */
|
|
106
106
|
page?: string;
|
|
107
|
-
/** Prompt (or last user message), shortened — what the background notice shows. */
|
|
108
|
-
label?: string;
|
|
109
|
-
/** Background-notice bookkeeping (≥ 1.17.0). */
|
|
110
|
-
bg?: 1;
|
|
111
|
-
/** The user left its page while it ran. */
|
|
112
|
-
orphaned?: boolean;
|
|
113
|
-
/** It finished where a page showed it. */
|
|
114
|
-
delivered?: boolean;
|
|
115
|
-
/** The user closed its card in the notice. */
|
|
116
|
-
dismissed?: boolean;
|
|
117
|
-
/** Replaced by a re-run, or no longer readable — never shown. */
|
|
118
|
-
hidden?: boolean;
|
|
119
107
|
createdAt: number;
|
|
120
108
|
updatedAt: number;
|
|
121
109
|
}
|
|
@@ -132,8 +120,7 @@ export interface AttachedJob<T = any> {
|
|
|
132
120
|
/**
|
|
133
121
|
* Resolves with what the starting call resolved with — at once when it
|
|
134
122
|
* already finished, else when it does (also after a page change or a
|
|
135
|
-
* reload). Rejects with an AIFlowError when it failed.
|
|
136
|
-
* background notice that this page shows the job.
|
|
123
|
+
* reload). Rejects with an AIFlowError when it failed.
|
|
137
124
|
*/
|
|
138
125
|
readonly done: Promise<T>;
|
|
139
126
|
}
|
|
@@ -147,22 +134,11 @@ export interface JobsNamespace {
|
|
|
147
134
|
forget(jobIdOrTag: string): void;
|
|
148
135
|
/**
|
|
149
136
|
* Pick a job up again on mount: the newest one with `tag` (with no tag,
|
|
150
|
-
* the newest one started from the current page), or null.
|
|
151
|
-
* shows it, so the background notice hides it.
|
|
137
|
+
* the newest one started from the current page), or null.
|
|
152
138
|
*/
|
|
153
139
|
attach<T = any>(tag?: string): AttachedJob<T> | null;
|
|
154
140
|
}
|
|
155
141
|
|
|
156
|
-
/** Page-wide settings for the background notice. */
|
|
157
|
-
export interface BackgroundNoticeOptions {
|
|
158
|
-
/** Default true in browsers. Also off when `window.__AIFLOW_BACKGROUND_NOTICE__ === false`. */
|
|
159
|
-
enabled?: boolean;
|
|
160
|
-
/** Default `'bottom-left'`. */
|
|
161
|
-
position?: 'bottom-left' | 'bottom-right';
|
|
162
|
-
/** `'en' | 'ko' | 'vi' | 'ja' | 'zh'`; default from `<html lang>`, then the browser. */
|
|
163
|
-
locale?: string | null;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
142
|
export type ChatRole = 'system' | 'user' | 'assistant';
|
|
167
143
|
|
|
168
144
|
// ─── Multimodal content blocks ───────────────────────────────────────────────
|
|
@@ -1050,8 +1026,6 @@ export interface AIFlowClientOptions {
|
|
|
1050
1026
|
timeout?: number;
|
|
1051
1027
|
maxRetries?: number;
|
|
1052
1028
|
fetch?: typeof fetch;
|
|
1053
|
-
/** `false` turns off the background notice for the whole page. */
|
|
1054
|
-
backgroundNotice?: boolean;
|
|
1055
1029
|
}
|
|
1056
1030
|
|
|
1057
1031
|
export interface AiflowConfig {
|
|
@@ -1214,13 +1188,6 @@ export class AIFlowClient {
|
|
|
1214
1188
|
|
|
1215
1189
|
constructor(options: AIFlowClientOptions);
|
|
1216
1190
|
|
|
1217
|
-
/**
|
|
1218
|
-
* Configure the background notice for the whole page — the small panel
|
|
1219
|
-
* that tells a user who left a page mid-generation that it keeps going,
|
|
1220
|
-
* then shows the result with a way back to the page.
|
|
1221
|
-
*/
|
|
1222
|
-
static configureBackgroundNotice(options: BackgroundNoticeOptions): void;
|
|
1223
|
-
|
|
1224
1191
|
/**
|
|
1225
1192
|
* Set (or clear with `null`) the current end user. Call after your app
|
|
1226
1193
|
* authenticates a user, passing the user's id AND their access token (from
|
|
@@ -1376,7 +1343,6 @@ export class AIFlowClient {
|
|
|
1376
1343
|
* that started it resolves with. Works after a reload or on another page.
|
|
1377
1344
|
* Aborting `signal` / hitting `timeout` (default 30 min) stops only the
|
|
1378
1345
|
* waiting. Throws an AIFlowError (`status`, `code`) when the job failed.
|
|
1379
|
-
* The page now shows the job, so the background notice hides it.
|
|
1380
1346
|
*/
|
|
1381
1347
|
waitForJob<T = any>(
|
|
1382
1348
|
jobId: string,
|