totalum-sdk 1.0.0 → 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 +14 -0
- package/dist/_types/{billing.d-BcRcDH4Y.d.ts → billing.d-DWcflg9y.d.ts} +5 -1
- package/dist/ai/index.d.ts +10 -5
- package/dist/ai/index.js +10 -14
- package/dist/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts +2 -2
- package/package.json +1 -1
- package/totalum-sdk.md +4 -3
- package/totalum-sdk.signatures.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -20,6 +20,20 @@ regenerated), plus the request each call sends to SDK-API (`compat/requests/*.js
|
|
|
20
20
|
- **Dist-tags:** `next` is the newest release; `latest` moves only by a decision at launch. `dev` holds the old
|
|
21
21
|
`0.1.0-dev.N` prereleases.
|
|
22
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
|
+
|
|
23
37
|
## 1.0.0 — 2026-09-28
|
|
24
38
|
|
|
25
39
|
The first stable release: the `0.1.0-dev.14` surface, reviewed for consistency and frozen. Nothing was removed; every
|
|
@@ -1,6 +1,10 @@
|
|
|
1
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>;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpeechAudio } from '../speech/index.js';
|
|
2
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
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-
|
|
4
|
+
import { I as IntegrationUsage } from '../_types/billing.d-DWcflg9y.js';
|
|
5
5
|
import { SpeakInput, StoredMedia, TranscribeInput } from '../index.js';
|
|
6
6
|
import '../_types/coerce.d-BXj_o-j6.js';
|
|
7
7
|
|
|
@@ -222,11 +222,15 @@ interface TotalumAiOptions extends TotalumClientOptions {
|
|
|
222
222
|
/** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
|
|
223
223
|
aiBaseUrl?: string;
|
|
224
224
|
}
|
|
225
|
+
/** What a call was charged, in Totalum credits — the only usage Totalum shows (no tokens, no vendor cost). */
|
|
225
226
|
interface ChatUsage {
|
|
227
|
+
credits: number;
|
|
228
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
226
229
|
inputTokens: number;
|
|
230
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
227
231
|
outputTokens: number;
|
|
232
|
+
/** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
|
|
228
233
|
costUsd: number;
|
|
229
|
-
credits: number;
|
|
230
234
|
}
|
|
231
235
|
interface ToolCall {
|
|
232
236
|
id: string;
|
|
@@ -255,8 +259,8 @@ interface ChatStream {
|
|
|
255
259
|
/**
|
|
256
260
|
* `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
257
261
|
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
258
|
-
* of its family, resolved by Totalum) or a pinned OpenRouter id; every call
|
|
259
|
-
*
|
|
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
|
|
260
264
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
261
265
|
*/
|
|
262
266
|
declare function totalumAi(options?: TotalumAiOptions): {
|
|
@@ -362,7 +366,8 @@ declare function totalumAi(options?: TotalumAiOptions): {
|
|
|
362
366
|
} | undefined;
|
|
363
367
|
}>;
|
|
364
368
|
/**
|
|
365
|
-
* ⚠ 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).
|
|
366
371
|
* In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
367
372
|
*/
|
|
368
373
|
wait(jobId: string, opts?: {
|
package/dist/ai/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { alias } from '../deprecate.js';
|
|
|
2
2
|
import { assertNode, TotalumError } from '../errors.js';
|
|
3
3
|
import { jsonClient, projectKey, rawClient, readEnv } from '../http.js';
|
|
4
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;
|
|
5
7
|
export { TotalumError, isTotalumError } from '../errors.js';
|
|
6
8
|
const resultOf = (c) => ({
|
|
7
9
|
id: c.id ?? '',
|
|
@@ -9,12 +11,7 @@ const resultOf = (c) => ({
|
|
|
9
11
|
text: c.choices?.[0]?.message?.content ?? '',
|
|
10
12
|
toolCalls: c.choices?.[0]?.message?.tool_calls ?? [],
|
|
11
13
|
finishReason: c.choices?.[0]?.finish_reason ?? null,
|
|
12
|
-
usage: {
|
|
13
|
-
inputTokens: c.usage?.prompt_tokens ?? 0,
|
|
14
|
-
outputTokens: c.usage?.completion_tokens ?? 0,
|
|
15
|
-
costUsd: c.usage?.costUsd ?? 0,
|
|
16
|
-
credits: c.usage?.credits ?? 0,
|
|
17
|
-
},
|
|
14
|
+
usage: { credits: c.usage?.credits ?? 0, inputTokens: 0, outputTokens: 0, costUsd: 0 },
|
|
18
15
|
raw: c,
|
|
19
16
|
});
|
|
20
17
|
/** SSE `data:` payloads of a stream, in order (`[DONE]` ends it). */
|
|
@@ -56,8 +53,6 @@ function chatStream(body) {
|
|
|
56
53
|
acc.id = chunk.id;
|
|
57
54
|
if (!acc.model && chunk.model)
|
|
58
55
|
acc.model = chunk.model;
|
|
59
|
-
if (chunk.usage)
|
|
60
|
-
acc.usage = chunk.usage;
|
|
61
56
|
const choice = chunk.choices?.[0];
|
|
62
57
|
if (choice?.finish_reason && acc.choices?.[0])
|
|
63
58
|
acc.choices[0].finish_reason = choice.finish_reason;
|
|
@@ -70,7 +65,7 @@ function chatStream(body) {
|
|
|
70
65
|
})();
|
|
71
66
|
const drain = async () => {
|
|
72
67
|
while (!(await source.next()).done) {
|
|
73
|
-
/* read to the end: the
|
|
68
|
+
/* read to the end: the credits chunk comes last */
|
|
74
69
|
}
|
|
75
70
|
};
|
|
76
71
|
return {
|
|
@@ -83,15 +78,15 @@ function chatStream(body) {
|
|
|
83
78
|
...acc,
|
|
84
79
|
choices: [{ message: { content: acc.text }, finish_reason: acc.choices?.[0]?.finish_reason ?? null }],
|
|
85
80
|
});
|
|
86
|
-
return { ...r, usage: { ...r.usage,
|
|
81
|
+
return { ...r, usage: { ...r.usage, credits } };
|
|
87
82
|
},
|
|
88
83
|
};
|
|
89
84
|
}
|
|
90
85
|
/**
|
|
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`,
|
|
92
87
|
* `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
93
|
-
* of its family, resolved by Totalum) or a pinned OpenRouter id; every call
|
|
94
|
-
*
|
|
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
|
|
95
90
|
* agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
96
91
|
*/
|
|
97
92
|
export function totalumAi(options = {}) {
|
|
@@ -151,12 +146,13 @@ export function totalumAi(options = {}) {
|
|
|
151
146
|
/** The video job: `status`, and the stored clip once completed. */
|
|
152
147
|
get: videoJob,
|
|
153
148
|
/**
|
|
154
|
-
* ⚠ 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).
|
|
155
151
|
* In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
156
152
|
*/
|
|
157
153
|
async wait(jobId, opts = {}) {
|
|
158
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');
|
|
159
|
-
const until = Date.now() + (opts.timeoutMs ??
|
|
155
|
+
const until = Date.now() + (opts.timeoutMs ?? VIDEO_WAIT_MS);
|
|
160
156
|
for (;;) {
|
|
161
157
|
const job = await videoJob(jobId);
|
|
162
158
|
if ((job.status !== 'queued' && job.status !== 'running') || Date.now() > until)
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { D1Database, D1DatabaseSession, D1ExecResult, D1PreparedStatement, D1Res
|
|
|
34
34
|
export { T as TotalumClientOptions, a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from './_types/errors.d-Dtt-BIwJ.js';
|
|
35
35
|
export { C as CheckoutInput, a as CheckoutOutput, b as CronJob, c as CronJobInput, d as CronJobPatch, e as CronRun, f as CronRunsPage, g as CustomerPortalLinkInput, h as CustomerPortalLinkOutput, E as EmailSendInput, i as EmailSendOutput, j as EmailView, F as FileDescriptor, k as FileUploadUrlInput, l as FileUploadUrlOutput, m as FilesListQuery, n as FilesPage, J as JobCreated, O as OnboardingLinkInput, o as OnboardingLinkOutput, P as PaymentsStatus, p as PdfFromHtmlInput, q as PdfFromUrlInput, r as PdfOutput, S as ScanDocumentInput, s as ScanOcrInput, t as ScanOcrOutput, u as ScreenshotInput, v as ScreenshotOutput, w as SeoIndexNowKey, x as SeoNotifyOutput, y as SpeakInput, z as StoredMedia, T as TranscribeInput, A as TranscribeOutput, W as WebJob, B as WebScrapeOutput, D as WebSearchOutput } from './_types/integrations.d-DjOeFaYn.js';
|
|
36
36
|
export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-BKBWL6Qf.js';
|
|
37
|
-
export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-
|
|
37
|
+
export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-DWcflg9y.js';
|
|
38
38
|
import './_types/coerce.d-BXj_o-j6.js';
|
|
39
39
|
|
|
40
40
|
/** The options of `createTotalum()`: every namespace's options in one object (each falls back to its env var). */
|
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as WebhookEvent } from '../_types/billing.d-
|
|
2
|
-
export { W as WebhookConfig, b as WebhookSecretOutput } from '../_types/billing.d-
|
|
1
|
+
import { a as WebhookEvent } from '../_types/billing.d-DWcflg9y.js';
|
|
2
|
+
export { W as WebhookConfig, b as WebhookSecretOutput } from '../_types/billing.d-DWcflg9y.js';
|
|
3
3
|
import { T as TotalumClientOptions, a as TotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
4
4
|
export { b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-Dtt-BIwJ.js';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "totalum-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The SDK generated Totalum apps import: every integration namespace over SDK-API (totalum-sdk, or one subpath each: /files, /ai, /web, \u2026) and totalum-sdk/d1, the D1 driver",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
package/totalum-sdk.md
CHANGED
|
@@ -511,8 +511,8 @@ totalumAi(options?: TotalumAiOptions)
|
|
|
511
511
|
|
|
512
512
|
`totalum.ai` over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
|
|
513
513
|
`smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
|
|
514
|
-
of its family, resolved by Totalum) or a pinned OpenRouter id; every call
|
|
515
|
-
|
|
514
|
+
of its family, resolved by Totalum) or a pinned OpenRouter id; every call returned with the Totalum credits it was
|
|
515
|
+
charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` — the
|
|
516
516
|
agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
|
|
517
517
|
|
|
518
518
|
#### `ai.chat`
|
|
@@ -598,7 +598,8 @@ The video job: `status`, and the stored clip once completed.
|
|
|
598
598
|
ai.video.wait(jobId: string, opts?: { intervalMs?: number | undefined; timeoutMs?: number | undefined; }): Promise<{ jobId: string; status: 'completed' | 'queued' | 'running' | 'failed' | 'cancelled' | 'expired'; progress?: number | undefined; video?: { key: string; url: string; } | undefined; usage?: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; } | undefined; error?: { code: string; message: string; } | undefined; }>
|
|
599
599
|
```
|
|
600
600
|
|
|
601
|
-
⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most
|
|
601
|
+
⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most 45 min —
|
|
602
|
+
the longest clip, 30 s at 1080p, renders in about 22 min).
|
|
602
603
|
In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` later instead.
|
|
603
604
|
|
|
604
605
|
#### `ai.vision.describe`
|