totalum-sdk 0.1.0-dev.9 → 1.1.0
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/CHANGELOG.md +74 -0
- package/dist/_types/{billing.d-BbSZh1wY.d.ts → billing.d-DWcflg9y.d.ts} +6 -2
- package/dist/_types/{coerce.d-C0KIW76L.d.ts → coerce.d-BXj_o-j6.d.ts} +1 -1
- package/dist/_types/{errors.d-Cu3q_E_r.d.ts → errors.d-Dtt-BIwJ.d.ts} +26 -2
- package/dist/_types/{integrations.d-BNGV70e3.d.ts → integrations.d-DjOeFaYn.d.ts} +2 -2
- package/dist/_types/{ops.d-C9375KIG.d.ts → ops.d-BKBWL6Qf.d.ts} +2 -2
- package/dist/ai/index.d.ts +49 -28
- package/dist/ai/index.js +21 -21
- package/dist/analytics/index.d.ts +4 -4
- package/dist/browser/index.d.ts +60 -5
- package/dist/browser/index.js +22 -5
- package/dist/cron/index.d.ts +5 -5
- package/dist/cron/index.js +2 -10
- package/dist/d1/index.d.ts +6 -4
- package/dist/d1/lazy.js +21 -3
- package/dist/d1/session.js +83 -15
- package/dist/deprecate.js +16 -0
- package/dist/email/index.d.ts +12 -6
- package/dist/email/index.js +4 -3
- package/dist/files/index.d.ts +11 -9
- package/dist/files/index.js +10 -5
- package/dist/index.d.ts +11 -8
- package/dist/index.js +3 -0
- package/dist/logs/index.d.ts +5 -5
- package/dist/payments/index.d.ts +5 -5
- package/dist/pdf/index.d.ts +5 -5
- package/dist/realtime/index.d.ts +2 -2
- package/dist/scan/index.d.ts +14 -6
- package/dist/scan/index.js +5 -1
- package/dist/seo/index.d.ts +4 -4
- package/dist/speech/index.d.ts +26 -13
- package/dist/speech/index.js +24 -12
- package/dist/vectors/index.d.ts +167 -0
- package/dist/vectors/index.js +28 -0
- package/dist/web/index.d.ts +6 -6
- package/dist/web/index.js +1 -1
- package/dist/webhooks/index.d.ts +4 -4
- package/package.json +13 -3
- package/totalum-sdk.md +122 -25
- package/totalum-sdk.signatures.json +313 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
`totalum-sdk` follows [semantic versioning](https://semver.org) from `1.0.0`. The public API is what
|
|
4
|
+
`api/totalum-sdk.api.md` lists (generated from the published `.d.ts`; CI fails when it changes without being
|
|
5
|
+
regenerated), plus the request each call sends to SDK-API (`compat/requests/*.json`).
|
|
6
|
+
|
|
7
|
+
## Versioning and deprecation policy
|
|
8
|
+
|
|
9
|
+
- **Patch** (`1.0.x`): fixes that change no public type and no request shape.
|
|
10
|
+
- **Minor** (`1.x.0`): additions only — a new namespace, method, option or result field. An app written against
|
|
11
|
+
`1.a` compiles and runs unchanged on every later `1.b`.
|
|
12
|
+
- **Major** (`x.0.0`): the only place a public name is removed or changed incompatibly.
|
|
13
|
+
- **Deprecation:** a name that is replaced keeps working, as an alias of the new one, for **at least one major
|
|
14
|
+
version** — deprecated in `1.x`, removed no earlier than `2.0.0`. It carries a `@deprecated` JSDoc tag (editors
|
|
15
|
+
strike it through; `@typescript-eslint/no-deprecated` flags it), is marked **Deprecated** in `totalum-sdk.md`, and
|
|
16
|
+
logs one `console.warn` per process (per isolate in a Worker) naming its replacement the first time it is used.
|
|
17
|
+
- **Server side:** SDK-API keeps accepting every request shape any `1.x` release — and every `0.1.0-dev.N` prerelease
|
|
18
|
+
apps were built on — has sent (its `test/sdk-compat.test.ts` replays them). A new major may stop sending a shape;
|
|
19
|
+
SDK-API keeps accepting it while any supported release sends it.
|
|
20
|
+
- **Dist-tags:** `next` is the newest release; `latest` moves only by a decision at launch. `dev` holds the old
|
|
21
|
+
`0.1.0-dev.N` prereleases.
|
|
22
|
+
|
|
23
|
+
## 1.1.0 — 2026-09-28
|
|
24
|
+
|
|
25
|
+
### Changed (compatible)
|
|
26
|
+
|
|
27
|
+
- **`ai.video.wait()` waits up to 45 min by default** (was 10 min, which gave up on a 15 s 1080p clip that took
|
|
28
|
+
~11 min; the longest allowed clip, 30 s, takes ~22 min). `timeoutMs` still overrides it.
|
|
29
|
+
- **AI usage reports only Totalum credits:** `usage.credits` is the whole charge.
|
|
30
|
+
|
|
31
|
+
### Deprecated (removed no earlier than 2.0.0)
|
|
32
|
+
|
|
33
|
+
| Deprecated | Use instead |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `ai.chat(...)` → `.usage.inputTokens`, `.usage.outputTokens`, `.usage.costUsd` (always 0: Totalum shows no tokens or vendor cost, 2026-09-28) | `.usage.credits` |
|
|
36
|
+
|
|
37
|
+
## 1.0.0 — 2026-09-28
|
|
38
|
+
|
|
39
|
+
The first stable release: the `0.1.0-dev.14` surface, reviewed for consistency and frozen. Nothing was removed; every
|
|
40
|
+
renamed name still works as a deprecated alias. An app built on any `0.1.0-dev.N` compiles and runs on `1.0.0`
|
|
41
|
+
(`compat/fixtures/app-dev.ts`).
|
|
42
|
+
|
|
43
|
+
### Changed (compatible)
|
|
44
|
+
|
|
45
|
+
- **Every paid call reports its cost as `usage.credits`.** Added `usage` to `email.send()`, `scan.document()` and
|
|
46
|
+
`speech.synthesize()` without `store` (the audio bytes); the other paid calls already had it.
|
|
47
|
+
- **Every subpath exports the same error and option types:** `TotalumError`, `isTotalumError`, `TotalumErrorCode`
|
|
48
|
+
and `TotalumClientOptions` from each of `totalum-sdk/<namespace>` (some lacked `TotalumErrorCode` or
|
|
49
|
+
`TotalumClientOptions`).
|
|
50
|
+
- `files.presign(keys, { expiresInSeconds })` — the same option name as `files.getSignedUrl()`; the request sent is
|
|
51
|
+
unchanged.
|
|
52
|
+
- `cron.runs()` and `browser.sessions.list()` build their query string with the shared helper: an unset filter is
|
|
53
|
+
no longer sent as the text `undefined`, and an empty filter sends no `?`.
|
|
54
|
+
|
|
55
|
+
### Deprecated (removed no earlier than 2.0.0)
|
|
56
|
+
|
|
57
|
+
| Deprecated | Use instead |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `files.getDownloadUrl(key, opts)` | `files.getSignedUrl(key, opts)` (the same call) |
|
|
60
|
+
| `files.presign(keys, { ttl })` | `files.presign(keys, { expiresInSeconds })` |
|
|
61
|
+
| `ai.speech.speak(input)` | `speech.synthesize(input)` (`totalum.speech`) |
|
|
62
|
+
| `ai.speech.transcribe(input)` | `speech.transcribe(input)` (`totalum.speech`) |
|
|
63
|
+
| `speech.synthesize(...)` → `.credits` | `.usage.credits` |
|
|
64
|
+
| type `TotalumD1ErrorCode` | `TotalumErrorCode` (the same type) |
|
|
65
|
+
|
|
66
|
+
### Added
|
|
67
|
+
|
|
68
|
+
- `CHANGELOG.md` and this deprecation policy; `api/totalum-sdk.api.md`, the public API report (`pnpm api`,
|
|
69
|
+
`pnpm api:check`); `totalum-sdk.signatures.json`, one compact row per method, which the template renders its
|
|
70
|
+
recipe tables from; the compatibility suite (`pnpm compat`).
|
|
71
|
+
|
|
72
|
+
## 0.1.0-dev.2 … 0.1.0-dev.14
|
|
73
|
+
|
|
74
|
+
Prereleases under the `dev` dist-tag, built wave by wave (the git history has each one).
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Z as ZodObject, k as ZodNumber, c as ZodOptional, d as ZodString, m as $strip, o as output,
|
|
1
|
+
import { Z as ZodObject, k as ZodNumber, c as ZodOptional, d as ZodString, m as $strip, o as output, u as ZodISODateTime, f as ZodEnum, j as ZodBoolean, h as ZodRecord, g as ZodUnknown, w as ZodNullable, p as ZodURL } from './errors.d-Dtt-BIwJ.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* `usage` on every integration result (plan 11 §0.8): the Totalum credits the call was charged, 4 decimals — never
|
|
5
|
+
* the vendor, its units or its cost (Francesc 2026-09-28). The optional fields stay for totalum-sdk 1.x type
|
|
6
|
+
* compatibility and are never sent.
|
|
7
|
+
*/
|
|
4
8
|
declare const IntegrationUsage: ZodObject<{
|
|
5
9
|
credits: ZodNumber;
|
|
6
10
|
vendor: ZodOptional<ZodString>;
|
|
@@ -2335,6 +2335,7 @@ declare const ErrorCode: ZodEnum<{
|
|
|
2335
2335
|
PLAN_REQUIRED: "PLAN_REQUIRED";
|
|
2336
2336
|
FEATURE_LIMIT_REACHED: "FEATURE_LIMIT_REACHED";
|
|
2337
2337
|
FEATURE_DISABLED: "FEATURE_DISABLED";
|
|
2338
|
+
VECTORS_LIMIT_REACHED: "VECTORS_LIMIT_REACHED";
|
|
2338
2339
|
AGENT_ALREADY_RUNNING: "AGENT_ALREADY_RUNNING";
|
|
2339
2340
|
IMPORT_IN_PROGRESS: "IMPORT_IN_PROGRESS";
|
|
2340
2341
|
TOO_MANY_RUN_REQUESTS: "TOO_MANY_RUN_REQUESTS";
|
|
@@ -2445,6 +2446,7 @@ declare const ErrorCode: ZodEnum<{
|
|
|
2445
2446
|
RELEASE_ROLLOUT_ACTIVE: "RELEASE_ROLLOUT_ACTIVE";
|
|
2446
2447
|
RELEASE_GUARD_PAUSED: "RELEASE_GUARD_PAUSED";
|
|
2447
2448
|
RELEASE_BUILD_UNAVAILABLE: "RELEASE_BUILD_UNAVAILABLE";
|
|
2449
|
+
RELEASE_BELOW_MIN_SAFE_VERSION: "RELEASE_BELOW_MIN_SAFE_VERSION";
|
|
2448
2450
|
VISUAL_EDIT_PREVIEW_DEPLOYING: "VISUAL_EDIT_PREVIEW_DEPLOYING";
|
|
2449
2451
|
VISUAL_EDIT_NOT_PATCHABLE: "VISUAL_EDIT_NOT_PATCHABLE";
|
|
2450
2452
|
VISUAL_EDIT_BASE_MISMATCH: "VISUAL_EDIT_BASE_MISMATCH";
|
|
@@ -2490,6 +2492,16 @@ declare const ErrorCode: ZodEnum<{
|
|
|
2490
2492
|
MOBILE_ARTIFACT_INVALID: "MOBILE_ARTIFACT_INVALID";
|
|
2491
2493
|
SIGNING_FINGERPRINT_MISMATCH: "SIGNING_FINGERPRINT_MISMATCH";
|
|
2492
2494
|
AM_RESTARTED: "AM_RESTARTED";
|
|
2495
|
+
MOBILE_BUILD_NOT_SIGNED: "MOBILE_BUILD_NOT_SIGNED";
|
|
2496
|
+
STORE_NOT_CONFIGURED: "STORE_NOT_CONFIGURED";
|
|
2497
|
+
STORE_CREDENTIALS_INVALID: "STORE_CREDENTIALS_INVALID";
|
|
2498
|
+
STORE_APP_NOT_FOUND: "STORE_APP_NOT_FOUND";
|
|
2499
|
+
STORE_UPLOAD_RUNNING: "STORE_UPLOAD_RUNNING";
|
|
2500
|
+
STORE_UPLOAD_LIMIT_REACHED: "STORE_UPLOAD_LIMIT_REACHED";
|
|
2501
|
+
STORE_UPLOAD_NOT_FOUND: "STORE_UPLOAD_NOT_FOUND";
|
|
2502
|
+
STORE_UPLOAD_FAILED: "STORE_UPLOAD_FAILED";
|
|
2503
|
+
PLAY_FIRST_UPLOAD_MANUAL: "PLAY_FIRST_UPLOAD_MANUAL";
|
|
2504
|
+
STORE_PROCESSING_TIMEOUT: "STORE_PROCESSING_TIMEOUT";
|
|
2493
2505
|
LIMIT_ABOVE_PLAN_CEILING: "LIMIT_ABOVE_PLAN_CEILING";
|
|
2494
2506
|
UNKNOWN_FEATURE: "UNKNOWN_FEATURE";
|
|
2495
2507
|
INVALID_LIMIT: "INVALID_LIMIT";
|
|
@@ -2716,6 +2728,7 @@ declare const ErrorBody: ZodObject<{
|
|
|
2716
2728
|
PLAN_REQUIRED: "PLAN_REQUIRED";
|
|
2717
2729
|
FEATURE_LIMIT_REACHED: "FEATURE_LIMIT_REACHED";
|
|
2718
2730
|
FEATURE_DISABLED: "FEATURE_DISABLED";
|
|
2731
|
+
VECTORS_LIMIT_REACHED: "VECTORS_LIMIT_REACHED";
|
|
2719
2732
|
AGENT_ALREADY_RUNNING: "AGENT_ALREADY_RUNNING";
|
|
2720
2733
|
IMPORT_IN_PROGRESS: "IMPORT_IN_PROGRESS";
|
|
2721
2734
|
TOO_MANY_RUN_REQUESTS: "TOO_MANY_RUN_REQUESTS";
|
|
@@ -2826,6 +2839,7 @@ declare const ErrorBody: ZodObject<{
|
|
|
2826
2839
|
RELEASE_ROLLOUT_ACTIVE: "RELEASE_ROLLOUT_ACTIVE";
|
|
2827
2840
|
RELEASE_GUARD_PAUSED: "RELEASE_GUARD_PAUSED";
|
|
2828
2841
|
RELEASE_BUILD_UNAVAILABLE: "RELEASE_BUILD_UNAVAILABLE";
|
|
2842
|
+
RELEASE_BELOW_MIN_SAFE_VERSION: "RELEASE_BELOW_MIN_SAFE_VERSION";
|
|
2829
2843
|
VISUAL_EDIT_PREVIEW_DEPLOYING: "VISUAL_EDIT_PREVIEW_DEPLOYING";
|
|
2830
2844
|
VISUAL_EDIT_NOT_PATCHABLE: "VISUAL_EDIT_NOT_PATCHABLE";
|
|
2831
2845
|
VISUAL_EDIT_BASE_MISMATCH: "VISUAL_EDIT_BASE_MISMATCH";
|
|
@@ -2871,6 +2885,16 @@ declare const ErrorBody: ZodObject<{
|
|
|
2871
2885
|
MOBILE_ARTIFACT_INVALID: "MOBILE_ARTIFACT_INVALID";
|
|
2872
2886
|
SIGNING_FINGERPRINT_MISMATCH: "SIGNING_FINGERPRINT_MISMATCH";
|
|
2873
2887
|
AM_RESTARTED: "AM_RESTARTED";
|
|
2888
|
+
MOBILE_BUILD_NOT_SIGNED: "MOBILE_BUILD_NOT_SIGNED";
|
|
2889
|
+
STORE_NOT_CONFIGURED: "STORE_NOT_CONFIGURED";
|
|
2890
|
+
STORE_CREDENTIALS_INVALID: "STORE_CREDENTIALS_INVALID";
|
|
2891
|
+
STORE_APP_NOT_FOUND: "STORE_APP_NOT_FOUND";
|
|
2892
|
+
STORE_UPLOAD_RUNNING: "STORE_UPLOAD_RUNNING";
|
|
2893
|
+
STORE_UPLOAD_LIMIT_REACHED: "STORE_UPLOAD_LIMIT_REACHED";
|
|
2894
|
+
STORE_UPLOAD_NOT_FOUND: "STORE_UPLOAD_NOT_FOUND";
|
|
2895
|
+
STORE_UPLOAD_FAILED: "STORE_UPLOAD_FAILED";
|
|
2896
|
+
PLAY_FIRST_UPLOAD_MANUAL: "PLAY_FIRST_UPLOAD_MANUAL";
|
|
2897
|
+
STORE_PROCESSING_TIMEOUT: "STORE_PROCESSING_TIMEOUT";
|
|
2874
2898
|
LIMIT_ABOVE_PLAN_CEILING: "LIMIT_ABOVE_PLAN_CEILING";
|
|
2875
2899
|
UNKNOWN_FEATURE: "UNKNOWN_FEATURE";
|
|
2876
2900
|
INVALID_LIMIT: "INVALID_LIMIT";
|
|
@@ -3089,5 +3113,5 @@ declare class TotalumError extends Error {
|
|
|
3089
3113
|
}
|
|
3090
3114
|
declare function isTotalumError(e: unknown): e is TotalumError;
|
|
3091
3115
|
|
|
3092
|
-
export { ErrorBody as E, ZodObject as Z, TotalumError as a, ZodOptional as c, ZodString as d, ZodArray as e, ZodEnum as f, ZodUnknown as g, ZodRecord as h, isTotalumError as i, ZodBoolean as j, ZodNumber as k, ZodUnion as n, ZodURL as p, ZodLiteral as
|
|
3093
|
-
export type { $loose as $, SdkClientErrorCode as S, TotalumClientOptions as T, _ZodNumber as _, TotalumErrorCode as b, ZodInt as l, $strip as m, output as o, $ZodTypeInternals as
|
|
3116
|
+
export { ErrorBody as E, ZodObject as Z, TotalumError as a, ZodOptional as c, ZodString as d, ZodArray as e, ZodEnum as f, ZodUnknown as g, ZodRecord as h, isTotalumError as i, ZodBoolean as j, ZodNumber as k, ZodUnion as n, ZodURL as p, ZodLiteral as r, ZodType as s, ZodISODateTime as u, ZodNullable as w, ZodEmail as y };
|
|
3117
|
+
export type { $loose as $, SdkClientErrorCode as S, TotalumClientOptions as T, _ZodNumber as _, TotalumErrorCode as b, ZodInt as l, $strip as m, output as o, $partial as q, $ZodTypeInternals as t, $catchall as v, $strict as x, $ZodNumberInternals as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, d as ZodString, c as ZodOptional, f as ZodEnum, k as ZodNumber, j as ZodBoolean, m as $strip, o as output, p as ZodURL, e as ZodArray, n as ZodUnion, l as ZodInt, h as ZodRecord,
|
|
2
|
-
import { Z as ZodCoercedNumber } from './coerce.d-
|
|
1
|
+
import { Z as ZodObject, d as ZodString, c as ZodOptional, f as ZodEnum, k as ZodNumber, j as ZodBoolean, m as $strip, o as output, p as ZodURL, e as ZodArray, n as ZodUnion, l as ZodInt, h as ZodRecord, w as ZodNullable, u as ZodISODateTime, y as ZodEmail, r as ZodLiteral, g as ZodUnknown } from './errors.d-Dtt-BIwJ.js';
|
|
2
|
+
import { Z as ZodCoercedNumber } from './coerce.d-BXj_o-j6.js';
|
|
3
3
|
|
|
4
4
|
/** `202` of every async integration call; `estimatedCredits` = the reserved estimate (settled to the real cost). */
|
|
5
5
|
declare const JobCreated: ZodObject<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Z as ZodObject, c as ZodOptional, e as ZodArray,
|
|
2
|
-
import { Z as ZodCoercedNumber } from './coerce.d-
|
|
1
|
+
import { Z as ZodObject, c as ZodOptional, e as ZodArray, u as ZodISODateTime, v as $catchall, k as ZodNumber, d as ZodString, f as ZodEnum, m as $strip, r as ZodLiteral, j as ZodBoolean, o as output, w as ZodNullable, l as ZodInt } from './errors.d-Dtt-BIwJ.js';
|
|
2
|
+
import { Z as ZodCoercedNumber } from './coerce.d-BXj_o-j6.js';
|
|
3
3
|
|
|
4
4
|
declare const SiteMetric: ZodEnum<{
|
|
5
5
|
bytes: "bytes";
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SpeechAudio } from '../speech/index.js';
|
|
2
|
+
import { Z as ZodObject, c as ZodOptional, d as ZodString, e as ZodArray, f as ZodEnum, g as ZodUnknown, $ as $loose, h as ZodRecord, j as ZodBoolean, k as ZodNumber, l as ZodInt, m as $strip, o as output, n as ZodUnion, p as ZodURL, q as $partial, r as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
3
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
4
|
+
import { I as IntegrationUsage } from '../_types/billing.d-DWcflg9y.js';
|
|
4
5
|
import { SpeakInput, StoredMedia, TranscribeInput } from '../index.js';
|
|
5
|
-
import '../_types/coerce.d-
|
|
6
|
+
import '../_types/coerce.d-BXj_o-j6.js';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Named model presets (A10.13): SDK-API resolves each to an OpenRouter slug from the CEO-editable `ai_model_aliases`
|
|
10
|
+
* table, refreshed from OpenRouter's catalogue to the newest non-deprecated model of the preset's family. A `model`
|
|
11
|
+
* field takes a preset or a pinned OpenRouter slug; a `:free` slug is never sent (20 req/min, shared by every tenant).
|
|
12
|
+
*/
|
|
13
|
+
declare const AI_PRESETS: readonly ["fast", "smart", "reasoning", "vision", "image", "image-edit", "video", "tts", "stt", "embed", "embed-image"];
|
|
14
|
+
type AiPresetName = (typeof AI_PRESETS)[number];
|
|
7
15
|
/** `POST /v1/ai/chat` (integration `ai_text`); `stream:true` answers SSE ending with `AiStreamCreditsChunk`. */
|
|
8
16
|
declare const AiChatInput: ZodObject<{
|
|
9
17
|
model: ZodOptional<ZodString>;
|
|
@@ -184,13 +192,21 @@ declare const AiTextOutput: ZodObject<{
|
|
|
184
192
|
}, $strip>;
|
|
185
193
|
}, $strip>;
|
|
186
194
|
type AiTextOutput = output<typeof AiTextOutput>;
|
|
187
|
-
/** `GET /v1/ai/models` (cached 1 h). */
|
|
195
|
+
/** `GET /v1/ai/models` (cached 1 h): each preset's current slug, and the catalogue the plan may call. */
|
|
188
196
|
declare const AiModelsOutput: ZodObject<{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
presets: ZodRecord<ZodEnum<{
|
|
198
|
+
fast: "fast";
|
|
199
|
+
smart: "smart";
|
|
200
|
+
reasoning: "reasoning";
|
|
201
|
+
vision: "vision";
|
|
202
|
+
image: "image";
|
|
203
|
+
"image-edit": "image-edit";
|
|
204
|
+
video: "video";
|
|
205
|
+
tts: "tts";
|
|
206
|
+
stt: "stt";
|
|
207
|
+
embed: "embed";
|
|
208
|
+
"embed-image": "embed-image";
|
|
209
|
+
}> & $partial, ZodString>;
|
|
194
210
|
models: ZodArray<ZodObject<{
|
|
195
211
|
slug: ZodString;
|
|
196
212
|
name: ZodString;
|
|
@@ -206,11 +222,15 @@ interface TotalumAiOptions extends TotalumClientOptions {
|
|
|
206
222
|
/** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
|
|
207
223
|
aiBaseUrl?: string;
|
|
208
224
|
}
|
|
225
|
+
/** What a call was charged, in Totalum credits — the only usage Totalum shows (no tokens, no vendor cost). */
|
|
209
226
|
interface ChatUsage {
|
|
227
|
+
credits: number;
|
|
228
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
210
229
|
inputTokens: number;
|
|
230
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
211
231
|
outputTokens: number;
|
|
232
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
212
233
|
costUsd: number;
|
|
213
|
-
credits: number;
|
|
214
234
|
}
|
|
215
235
|
interface ToolCall {
|
|
216
236
|
id: string;
|
|
@@ -237,8 +257,10 @@ interface ChatStream {
|
|
|
237
257
|
result(): Promise<ChatResult>;
|
|
238
258
|
}
|
|
239
259
|
/**
|
|
240
|
-
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`):
|
|
241
|
-
*
|
|
260
|
+
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
261
|
+
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
262
|
+
* of its family, resolved by Totalum) or a pinned OpenRouter id; every call returned with the Totalum credits it was
|
|
263
|
+
* charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` (A5.27) — the
|
|
242
264
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
243
265
|
*/
|
|
244
266
|
declare function totalumAi(options?: TotalumAiOptions): {
|
|
@@ -344,7 +366,8 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
344
366
|
} | undefined;
|
|
345
367
|
}>;
|
|
346
368
|
/**
|
|
347
|
-
* ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most
|
|
369
|
+
* ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most 45 min —
|
|
370
|
+
* the longest clip, 30 s at 1080p, renders in about 22 min).
|
|
348
371
|
* In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
349
372
|
*/
|
|
350
373
|
wait(jobId: string, opts?: {
|
|
@@ -364,14 +387,16 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
364
387
|
};
|
|
365
388
|
}>;
|
|
366
389
|
};
|
|
390
|
+
/** @deprecated Since 1.0.0: use `totalum.speech` (the same calls). */
|
|
367
391
|
speech: {
|
|
368
|
-
/**
|
|
369
|
-
speak:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
392
|
+
/** @deprecated Since 1.0.0: use `totalum.speech.synthesize` (the same call). */
|
|
393
|
+
speak: {
|
|
394
|
+
(input: SpeakInput & {
|
|
395
|
+
store: true;
|
|
396
|
+
}): Promise<StoredMedia>;
|
|
397
|
+
(input: SpeakInput): Promise<StoredMedia | SpeechAudio>;
|
|
398
|
+
};
|
|
399
|
+
/** @deprecated Since 1.0.0: use `totalum.speech.transcribe` (the same call). */
|
|
375
400
|
transcribe: (input: TranscribeInput) => Promise<{
|
|
376
401
|
text: string;
|
|
377
402
|
durationSec: number;
|
|
@@ -395,13 +420,9 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
395
420
|
}>;
|
|
396
421
|
};
|
|
397
422
|
models: {
|
|
398
|
-
/**
|
|
423
|
+
/** Each preset's current model and the models a project may call, with their prices. */
|
|
399
424
|
list: () => Promise<{
|
|
400
|
-
|
|
401
|
-
cheap: string;
|
|
402
|
-
normal: string;
|
|
403
|
-
best: string;
|
|
404
|
-
};
|
|
425
|
+
presets: Partial<Record<"fast" | "reasoning" | "video" | "image" | "smart" | "vision" | "image-edit" | "tts" | "stt" | "embed" | "embed-image", string>>;
|
|
405
426
|
models: {
|
|
406
427
|
slug: string;
|
|
407
428
|
name: string;
|
|
@@ -421,4 +442,4 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
421
442
|
type TotalumAi = ReturnType<typeof totalumAi>;
|
|
422
443
|
|
|
423
444
|
export { AiChatInput, AiEmbedInput, AiEmbedOutput, AiImageEditInput, AiImageInput, AiImageOutput, AiModelsOutput, AiTextOutput, AiVideoCreated, AiVideoInput, AiVideoJob, AiVisionDescribeInput, TotalumClientOptions, totalumAi };
|
|
424
|
-
export type { ChatResult, ChatStream, ChatUsage, TotalumAi, TotalumAiOptions };
|
|
445
|
+
export type { AiPresetName, ChatResult, ChatStream, ChatUsage, TotalumAi, TotalumAiOptions };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { alias } from '../deprecate.js';
|
|
1
2
|
import { assertNode, TotalumError } from '../errors.js';
|
|
2
3
|
import { jsonClient, projectKey, rawClient, readEnv } from '../http.js';
|
|
3
4
|
import { totalumSpeech } from '../speech/index.js';
|
|
5
|
+
/** `video.wait()`'s default bound: a 15 s 1080p clip took ~11 min on dev, so the longest (30 s) takes ~22 min; doubled for queueing. */
|
|
6
|
+
const VIDEO_WAIT_MS = 45 * 60_000;
|
|
4
7
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
5
8
|
const resultOf = (c) => ({
|
|
6
9
|
id: c.id ?? '',
|
|
@@ -8,12 +11,7 @@ const resultOf = (c) => ({
|
|
|
8
11
|
text: c.choices?.[0]?.message?.content ?? '',
|
|
9
12
|
toolCalls: c.choices?.[0]?.message?.tool_calls ?? [],
|
|
10
13
|
finishReason: c.choices?.[0]?.finish_reason ?? null,
|
|
11
|
-
usage: {
|
|
12
|
-
inputTokens: c.usage?.prompt_tokens ?? 0,
|
|
13
|
-
outputTokens: c.usage?.completion_tokens ?? 0,
|
|
14
|
-
costUsd: c.usage?.costUsd ?? 0,
|
|
15
|
-
credits: c.usage?.credits ?? 0,
|
|
16
|
-
},
|
|
14
|
+
usage: { credits: c.usage?.credits ?? 0, inputTokens: 0, outputTokens: 0, costUsd: 0 },
|
|
17
15
|
raw: c,
|
|
18
16
|
});
|
|
19
17
|
/** SSE `data:` payloads of a stream, in order (`[DONE]` ends it). */
|
|
@@ -55,8 +53,6 @@ function chatStream(body) {
|
|
|
55
53
|
acc.id = chunk.id;
|
|
56
54
|
if (!acc.model && chunk.model)
|
|
57
55
|
acc.model = chunk.model;
|
|
58
|
-
if (chunk.usage)
|
|
59
|
-
acc.usage = chunk.usage;
|
|
60
56
|
const choice = chunk.choices?.[0];
|
|
61
57
|
if (choice?.finish_reason && acc.choices?.[0])
|
|
62
58
|
acc.choices[0].finish_reason = choice.finish_reason;
|
|
@@ -69,7 +65,7 @@ function chatStream(body) {
|
|
|
69
65
|
})();
|
|
70
66
|
const drain = async () => {
|
|
71
67
|
while (!(await source.next()).done) {
|
|
72
|
-
/* read to the end: the
|
|
68
|
+
/* read to the end: the credits chunk comes last */
|
|
73
69
|
}
|
|
74
70
|
};
|
|
75
71
|
return {
|
|
@@ -82,13 +78,15 @@ function chatStream(body) {
|
|
|
82
78
|
...acc,
|
|
83
79
|
choices: [{ message: { content: acc.text }, finish_reason: acc.choices?.[0]?.finish_reason ?? null }],
|
|
84
80
|
});
|
|
85
|
-
return { ...r, usage: { ...r.usage,
|
|
81
|
+
return { ...r, usage: { ...r.usage, credits } };
|
|
86
82
|
},
|
|
87
83
|
};
|
|
88
84
|
}
|
|
89
85
|
/**
|
|
90
|
-
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`):
|
|
91
|
-
*
|
|
86
|
+
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
87
|
+
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
88
|
+
* of its family, resolved by Totalum) or a pinned OpenRouter id; every call returned with the Totalum credits it was
|
|
89
|
+
* charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` (A5.27) — the
|
|
92
90
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
93
91
|
*/
|
|
94
92
|
export function totalumAi(options = {}) {
|
|
@@ -96,10 +94,10 @@ export function totalumAi(options = {}) {
|
|
|
96
94
|
const raw = rawClient(options);
|
|
97
95
|
const speech = totalumSpeech(options);
|
|
98
96
|
/**
|
|
99
|
-
* A chat completion; `model` is
|
|
97
|
+
* A chat completion; `model` is a preset (`fast`, `smart` — the default — or `reasoning`) or a pinned OpenRouter id.
|
|
100
98
|
*
|
|
101
99
|
* @example
|
|
102
|
-
* const { text } = await ai.chat({ model: '
|
|
100
|
+
* const { text } = await ai.chat({ model: 'fast', messages: [{ role: 'user', content: 'Hi' }] });
|
|
103
101
|
*/
|
|
104
102
|
const chat = Object.assign(async (req) => resultOf(await call('POST', '/v1/ai/chat', { ...req, stream: false })), {
|
|
105
103
|
/**
|
|
@@ -148,12 +146,13 @@ export function totalumAi(options = {}) {
|
|
|
148
146
|
/** The video job: `status`, and the stored clip once completed. */
|
|
149
147
|
get: videoJob,
|
|
150
148
|
/**
|
|
151
|
-
* ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most
|
|
149
|
+
* ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most 45 min —
|
|
150
|
+
* the longest clip, 30 s at 1080p, renders in about 22 min).
|
|
152
151
|
* In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
153
152
|
*/
|
|
154
153
|
async wait(jobId, opts = {}) {
|
|
155
154
|
assertNode('totalum.ai.video.wait()', 'Start the job with ai.video.generate(), store the jobId, and read ai.video.get(jobId) when the page is refreshed.', 'https://totalum.app/docs/sdk/ai#node-only');
|
|
156
|
-
const until = Date.now() + (opts.timeoutMs ??
|
|
155
|
+
const until = Date.now() + (opts.timeoutMs ?? VIDEO_WAIT_MS);
|
|
157
156
|
for (;;) {
|
|
158
157
|
const job = await videoJob(jobId);
|
|
159
158
|
if ((job.status !== 'queued' && job.status !== 'running') || Date.now() > until)
|
|
@@ -166,14 +165,15 @@ export function totalumAi(options = {}) {
|
|
|
166
165
|
/** A text description of an image (URL, data URL or project file key). */
|
|
167
166
|
describe: (req) => call('POST', '/v1/ai/vision/describe', req),
|
|
168
167
|
},
|
|
168
|
+
/** @deprecated Since 1.0.0: use `totalum.speech` (the same calls). */
|
|
169
169
|
speech: {
|
|
170
|
-
/**
|
|
171
|
-
speak: speech.synthesize,
|
|
172
|
-
/**
|
|
173
|
-
transcribe: speech.transcribe,
|
|
170
|
+
/** @deprecated Since 1.0.0: use `totalum.speech.synthesize` (the same call). */
|
|
171
|
+
speak: alias(speech.synthesize, 'ai.speech.speak()', 'totalum.speech.synthesize()'),
|
|
172
|
+
/** @deprecated Since 1.0.0: use `totalum.speech.transcribe` (the same call). */
|
|
173
|
+
transcribe: alias(speech.transcribe, 'ai.speech.transcribe()', 'totalum.speech.transcribe()'),
|
|
174
174
|
},
|
|
175
175
|
models: {
|
|
176
|
-
/**
|
|
176
|
+
/** Each preset's current model and the models a project may call, with their prices. */
|
|
177
177
|
list: () => call('GET', '/v1/ai/models'),
|
|
178
178
|
},
|
|
179
179
|
/** The exact OpenRouter API for any OpenRouter/OpenAI client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-
|
|
2
|
-
import { T as TotalumClientOptions } from '../_types/errors.d-
|
|
3
|
-
export { a as TotalumError, i as isTotalumError } from '../_types/errors.d-
|
|
4
|
-
import '../_types/coerce.d-
|
|
1
|
+
import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-BKBWL6Qf.js';
|
|
2
|
+
import { T as TotalumClientOptions } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
3
|
+
export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
4
|
+
import '../_types/coerce.d-BXj_o-j6.js';
|
|
5
5
|
|
|
6
6
|
interface SiteAnalyticsQuery {
|
|
7
7
|
/** ISO; default the last 7 days. */
|