totalum-sdk 1.9.0 → 1.10.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.
@@ -1,4 +1,4 @@
1
- import { _ as _ZodNumber, z as $ZodNumberInternals } from './errors.d-WcXvShIX.js';
1
+ import { _ as _ZodNumber, z as $ZodNumberInternals } from './errors.d-BBRayxHv.js';
2
2
 
3
3
  interface ZodCoercedNumber<T = unknown> extends _ZodNumber<$ZodNumberInternals<T>> {
4
4
  }
@@ -3133,6 +3133,10 @@ interface TotalumClientOptions {
3133
3133
  /** Sent as `x-totalum-env` on every call (the database it targets, and dev vs live usage); default `TOTALUM_ENV`, else `live`. */
3134
3134
  env?: 'dev' | 'live';
3135
3135
  }
3136
+ /** What a call was charged, in Totalum credits: the only usage Totalum shows (never a vendor, units or a cost). */
3137
+ interface Usage {
3138
+ credits: number;
3139
+ }
3136
3140
 
3137
3141
  /** Every code a `TotalumError` can carry: SDK-API's frozen codes plus the client-side ones (plan 05 §7.2). */
3138
3142
  type TotalumErrorCode = ErrorCode | SdkClientErrorCode;
@@ -3158,4 +3162,4 @@ declare class TotalumError extends Error {
3158
3162
  declare function isTotalumError(e: unknown): e is TotalumError;
3159
3163
 
3160
3164
  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 };
3161
- 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 };
3165
+ export type { $loose as $, SdkClientErrorCode as S, TotalumClientOptions as T, Usage as U, _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, w as ZodNullable, u as ZodISODateTime, y as ZodEmail, r as ZodLiteral, g as ZodUnknown } from './errors.d-WcXvShIX.js';
2
- import { Z as ZodCoercedNumber } from './coerce.d-Cli9TkUD.js';
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-BBRayxHv.js';
2
+ import { Z as ZodCoercedNumber } from './coerce.d-3Xj4xYuy.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<{
@@ -141,9 +141,6 @@ declare const WebScrapeOutput: ZodObject<{
141
141
  contentUrl: ZodOptional<ZodURL>;
142
142
  usage: ZodObject<{
143
143
  credits: ZodNumber;
144
- vendor: ZodOptional<ZodString>;
145
- units: ZodOptional<ZodNumber>;
146
- vendorCostUsd: ZodOptional<ZodNumber>;
147
144
  }, $strip>;
148
145
  }, $strip>;
149
146
  type WebScrapeOutput = output<typeof WebScrapeOutput>;
@@ -459,9 +456,6 @@ declare const TranscribeOutput: ZodObject<{
459
456
  }, $strip>>>;
460
457
  usage: ZodObject<{
461
458
  credits: ZodNumber;
462
- vendor: ZodOptional<ZodString>;
463
- units: ZodOptional<ZodNumber>;
464
- vendorCostUsd: ZodOptional<ZodNumber>;
465
459
  }, $strip>;
466
460
  }, $strip>;
467
461
  type TranscribeOutput = output<typeof TranscribeOutput>;
@@ -489,9 +483,6 @@ declare const StoredMedia: ZodObject<{
489
483
  url: ZodURL;
490
484
  usage: ZodObject<{
491
485
  credits: ZodNumber;
492
- vendor: ZodOptional<ZodString>;
493
- units: ZodOptional<ZodNumber>;
494
- vendorCostUsd: ZodOptional<ZodNumber>;
495
486
  }, $strip>;
496
487
  }, $strip>;
497
488
  type StoredMedia = output<typeof StoredMedia>;
@@ -1,5 +1,5 @@
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-WcXvShIX.js';
2
- import { Z as ZodCoercedNumber } from './coerce.d-Cli9TkUD.js';
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-BBRayxHv.js';
2
+ import { Z as ZodCoercedNumber } from './coerce.d-3Xj4xYuy.js';
3
3
 
4
4
  declare const SiteMetric: ZodEnum<{
5
5
  bytes: "bytes";
@@ -1,9 +1,8 @@
1
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-WcXvShIX.js';
3
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
4
- import { I as IntegrationUsage } from '../_types/billing.d-Bl2JQGMY.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, U as Usage } from '../_types/errors.d-BBRayxHv.js';
3
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
4
  import { SpeakInput, StoredMedia, TranscribeInput } from '../index.js';
6
- import '../_types/coerce.d-Cli9TkUD.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
7
6
 
8
7
  /**
9
8
  * Named model presets (A10.13): SDK-API resolves each to an OpenRouter slug from the CEO-editable `ai_model_aliases`
@@ -60,9 +59,6 @@ declare const AiEmbedOutput: ZodObject<{
60
59
  embeddings: ZodArray<ZodArray<ZodNumber>>;
61
60
  usage: ZodObject<{
62
61
  credits: ZodNumber;
63
- vendor: ZodOptional<ZodString>;
64
- units: ZodOptional<ZodNumber>;
65
- vendorCostUsd: ZodOptional<ZodNumber>;
66
62
  }, $strip>;
67
63
  }, $strip>;
68
64
  type AiEmbedOutput = output<typeof AiEmbedOutput>;
@@ -118,9 +114,6 @@ declare const AiImageOutput: ZodObject<{
118
114
  }, $strip>>;
119
115
  usage: ZodObject<{
120
116
  credits: ZodNumber;
121
- vendor: ZodOptional<ZodString>;
122
- units: ZodOptional<ZodNumber>;
123
- vendorCostUsd: ZodOptional<ZodNumber>;
124
117
  }, $strip>;
125
118
  fileName: ZodOptional<ZodString>;
126
119
  imageUrl: ZodOptional<ZodURL>;
@@ -164,9 +157,6 @@ declare const AiVideoJob: ZodObject<{
164
157
  }, $strip>>;
165
158
  usage: ZodOptional<ZodObject<{
166
159
  credits: ZodNumber;
167
- vendor: ZodOptional<ZodString>;
168
- units: ZodOptional<ZodNumber>;
169
- vendorCostUsd: ZodOptional<ZodNumber>;
170
160
  }, $strip>>;
171
161
  error: ZodOptional<ZodObject<{
172
162
  code: ZodString;
@@ -185,9 +175,6 @@ declare const AiTextOutput: ZodObject<{
185
175
  text: ZodString;
186
176
  usage: ZodObject<{
187
177
  credits: ZodNumber;
188
- vendor: ZodOptional<ZodString>;
189
- units: ZodOptional<ZodNumber>;
190
- vendorCostUsd: ZodOptional<ZodNumber>;
191
178
  }, $strip>;
192
179
  }, $strip>;
193
180
  type AiTextOutput = output<typeof AiTextOutput>;
@@ -218,7 +205,7 @@ declare const AiModelsOutput: ZodObject<{
218
205
  type AiModelsOutput = output<typeof AiModelsOutput>;
219
206
 
220
207
  interface TotalumAiOptions extends TotalumClientOptions {
221
- /** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
208
+ /** The OpenAI-compatible AI gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
222
209
  aiBaseUrl?: string;
223
210
  }
224
211
  /** What a call was charged, in Totalum credits — the only usage Totalum shows (no tokens, no vendor cost). */
@@ -228,8 +215,6 @@ interface ChatUsage {
228
215
  inputTokens: number;
229
216
  /** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
230
217
  outputTokens: number;
231
- /** @deprecated Since 1.1.0: always 0 — Totalum shows only `credits`. */
232
- costUsd: number;
233
218
  }
234
219
  interface ToolCall {
235
220
  id: string;
@@ -258,7 +243,7 @@ interface ChatStream {
258
243
  /**
259
244
  * `totalum.ai` (plan 05 §6.1, plan 04 §5.1) over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
260
245
  * `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
261
- * of its family, resolved by Totalum) or a pinned OpenRouter id; every call returned with the Totalum credits it was
246
+ * of its family, resolved by Totalum) or a pinned model id; every call returned with the Totalum credits it was
262
247
  * charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` (A5.27) — the
263
248
  * agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
264
249
  */
@@ -278,7 +263,7 @@ declare function totalumAi(options?: TotalumAiOptions): {
278
263
  healing?: boolean;
279
264
  }) => Promise<{
280
265
  object: unknown;
281
- usage: IntegrationUsage;
266
+ usage: Usage;
282
267
  }>;
283
268
  /** Sugar over `generateObject`: one of `options`, chosen by the model. */
284
269
  classify(req: {
@@ -294,9 +279,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
294
279
  embeddings: number[][];
295
280
  usage: {
296
281
  credits: number;
297
- vendor?: string | undefined;
298
- units?: number | undefined;
299
- vendorCostUsd?: number | undefined;
300
282
  };
301
283
  }>;
302
284
  image: {
@@ -311,9 +293,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
311
293
  }[];
312
294
  usage: {
313
295
  credits: number;
314
- vendor?: string | undefined;
315
- units?: number | undefined;
316
- vendorCostUsd?: number | undefined;
317
296
  };
318
297
  fileName?: string | undefined;
319
298
  imageUrl?: string | undefined;
@@ -329,9 +308,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
329
308
  }[];
330
309
  usage: {
331
310
  credits: number;
332
- vendor?: string | undefined;
333
- units?: number | undefined;
334
- vendorCostUsd?: number | undefined;
335
311
  };
336
312
  fileName?: string | undefined;
337
313
  imageUrl?: string | undefined;
@@ -355,9 +331,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
355
331
  } | undefined;
356
332
  usage?: {
357
333
  credits: number;
358
- vendor?: string | undefined;
359
- units?: number | undefined;
360
- vendorCostUsd?: number | undefined;
361
334
  } | undefined;
362
335
  error?: {
363
336
  code: string;
@@ -380,9 +353,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
380
353
  text: string;
381
354
  usage: {
382
355
  credits: number;
383
- vendor?: string | undefined;
384
- units?: number | undefined;
385
- vendorCostUsd?: number | undefined;
386
356
  };
387
357
  }>;
388
358
  };
@@ -401,9 +371,6 @@ declare function totalumAi(options?: TotalumAiOptions): {
401
371
  durationSec: number;
402
372
  usage: {
403
373
  credits: number;
404
- vendor?: string | undefined;
405
- units?: number | undefined;
406
- vendorCostUsd?: number | undefined;
407
374
  };
408
375
  language?: string | undefined;
409
376
  segments?: {
@@ -432,7 +399,7 @@ declare function totalumAi(options?: TotalumAiOptions): {
432
399
  denylist?: string[] | undefined;
433
400
  }>;
434
401
  };
435
- /** The exact OpenRouter API for any OpenRouter/OpenAI client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
402
+ /** The OpenAI-compatible API for any OpenAI-compatible client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
436
403
  gatewayConfig: () => {
437
404
  baseURL: string;
438
405
  apiKey: string;
package/dist/ai/index.js CHANGED
@@ -11,7 +11,7 @@ const resultOf = (c) => ({
11
11
  text: c.choices?.[0]?.message?.content ?? '',
12
12
  toolCalls: c.choices?.[0]?.message?.tool_calls ?? [],
13
13
  finishReason: c.choices?.[0]?.finish_reason ?? null,
14
- usage: { credits: c.usage?.credits ?? 0, inputTokens: 0, outputTokens: 0, costUsd: 0 },
14
+ usage: { credits: c.usage?.credits ?? 0, inputTokens: 0, outputTokens: 0 },
15
15
  raw: c,
16
16
  });
17
17
  /** SSE `data:` payloads of a stream, in order (`[DONE]` ends it). */
@@ -85,7 +85,7 @@ function chatStream(body) {
85
85
  /**
86
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
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
88
+ * of its family, resolved by Totalum) or a pinned model id; every call returned with the Totalum credits it was
89
89
  * charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` (A5.27) — the
90
90
  * agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
91
91
  */
@@ -94,7 +94,7 @@ export function totalumAi(options = {}) {
94
94
  const raw = rawClient(options);
95
95
  const speech = totalumSpeech(options);
96
96
  /**
97
- * A chat completion; `model` is a preset (`fast`, `smart` — the default — or `reasoning`) or a pinned OpenRouter id.
97
+ * A chat completion; `model` is a preset (`fast`, `smart` — the default — or `reasoning`) or a pinned model id.
98
98
  *
99
99
  * @example
100
100
  * const { text } = await ai.chat({ model: 'fast', messages: [{ role: 'user', content: 'Hi' }] });
@@ -176,7 +176,7 @@ export function totalumAi(options = {}) {
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
- /** The exact OpenRouter API for any OpenRouter/OpenAI client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
179
+ /** The OpenAI-compatible API for any OpenAI-compatible client (A6.19): `new OpenAI(ai.gatewayConfig())`. Server-side only. */
180
180
  gatewayConfig: () => ({
181
181
  baseURL: options.aiBaseUrl ?? readEnv('TOTALUM_AI_BASE_URL') ?? 'https://ai.totalum.app/api/v1',
182
182
  apiKey: projectKey(options),
@@ -1,7 +1,7 @@
1
- import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-CS92EKY-.js';
2
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
3
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
4
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { b as SiteMetric, a as SiteDimension, S as SiteAnalyticsOutput } from '../_types/ops.d-D_3lqkJ2.js';
2
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
3
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
4
+ import '../_types/coerce.d-3Xj4xYuy.js';
5
5
 
6
6
  interface SiteAnalyticsQuery {
7
7
  /** ISO; default the last 7 days. */
@@ -1,5 +1,5 @@
1
- import { Z as ZodObject, e as ZodArray, j as ZodBoolean, c as ZodOptional, g as ZodUnknown, f as ZodEnum, d as ZodString, m as $strip, l as ZodInt, o as output, $ as $loose, s as ZodType, t as $ZodTypeInternals, h as ZodRecord, p as ZodURL, u as ZodISODateTime, k as ZodNumber, r as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
2
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
1
+ import { Z as ZodObject, e as ZodArray, j as ZodBoolean, c as ZodOptional, g as ZodUnknown, f as ZodEnum, d as ZodString, m as $strip, l as ZodInt, o as output, $ as $loose, s as ZodType, t as $ZodTypeInternals, h as ZodRecord, p as ZodURL, u as ZodISODateTime, k as ZodNumber, r as ZodLiteral, T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
3
 
4
4
  declare const BrowserCommandName: ZodEnum<{
5
5
  type: "type";
@@ -1,8 +1,8 @@
1
- import { d as CronJobInput, c as CronJob, e as CronJobPatch } from '../_types/integrations.d-WM81VvEj.js';
2
- export { f as CronRun, g as CronRunsPage } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { d as CronJobInput, c as CronJob, e as CronJobPatch } from '../_types/integrations.d-Hj3BqI02.js';
2
+ export { f as CronRun, g as CronRunsPage } from '../_types/integrations.d-Hj3BqI02.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /**
8
8
  * `totalum.cron` (plan 05 §6.9) over SDK-API `/v1/cron/*` (scope `cron`): HTTP jobs against the project's own host,
@@ -1,6 +1,6 @@
1
- import { S as SdkClientErrorCode, a as TotalumError, b as TotalumErrorCode, E as ErrorBody } from '../_types/errors.d-WcXvShIX.js';
1
+ import { S as SdkClientErrorCode, a as TotalumError, b as TotalumErrorCode, E as ErrorBody } from '../_types/errors.d-BBRayxHv.js';
2
2
  import { TotalumClientOptions } from '../ai/index.js';
3
- export { i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
3
+ export { i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
4
4
 
5
5
  /**
6
6
  * Cloudflare's `D1Database` surface, re-declared structurally so an app needs no Cloudflare types to compile
@@ -1,8 +1,8 @@
1
- import { E as EmailSendInput, k as EmailView } from '../_types/integrations.d-WM81VvEj.js';
2
- export { j as EmailSendOutput } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
+ import { E as EmailSendInput, k as EmailView } from '../_types/integrations.d-Hj3BqI02.js';
4
+ export { j as EmailSendOutput } from '../_types/integrations.d-Hj3BqI02.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /**
8
8
  * `totalum.email` (plan 05 §6.4) over SDK-API `/v1/email/*` (scope `email`): HTML sent byte for byte, charged
@@ -15,18 +15,14 @@ declare function totalumEmail(options?: TotalumClientOptions): {
15
15
  * @example
16
16
  * await email.send({ to: 'ana@example.com', subject: 'Welcome', html: '<p>Hi Ana</p>' });
17
17
  */
18
- send: (msg: EmailSendInput) => Promise<{
18
+ send: (msg: EmailSendInput) => Promise<Omit<{
19
19
  success: true;
20
20
  message: "Email sent successfully";
21
21
  messageId: string;
22
22
  id: string;
23
23
  status: "queued" | "sent";
24
- } & {
25
- usage: {
26
- vendor?: string | undefined;
27
- units?: number | undefined;
28
- credits: number;
29
- };
24
+ }, "usage"> & {
25
+ usage: Usage;
30
26
  }>;
31
27
  /** `null` when the e-mail is not this project's. */
32
28
  get: (id: string) => Promise<EmailView | null>;
@@ -1,8 +1,8 @@
1
- import { F as FileDescriptor, l as FileUploadUrlInput, n as FilesListQuery } from '../_types/integrations.d-WM81VvEj.js';
2
- export { m as FileUploadUrlOutput, o as FilesPage } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { F as FileDescriptor, l as FileUploadUrlInput, n as FilesListQuery } from '../_types/integrations.d-Hj3BqI02.js';
2
+ export { m as FileUploadUrlOutput, o as FilesPage } from '../_types/integrations.d-Hj3BqI02.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  interface TotalumFilesOptions extends TotalumClientOptions {
8
8
  /** The public files host; default `TOTALUM_FILES_URL`, else `https://files.totalum-project.com` (A10.1). */
package/dist/http.js CHANGED
@@ -115,8 +115,9 @@ export function query(params) {
115
115
  q.set(k, Array.isArray(v) ? v.join(',') : String(v));
116
116
  return q.size ? `?${q.toString()}` : '';
117
117
  }
118
- /** `data` + `usage {credits, vendor?, units?}` from `metadata` (plan 11 §0.8: every integration result shows its price). */
119
- export const withUsage = ({ data, metadata }) => ({
120
- ...data,
121
- usage: { credits: metadata?.credits ?? 0, ...metadata?.usage },
122
- });
118
+ /** `data` + `usage {credits}` from `metadata` (plan 11 §0.8: every integration result shows its price, in credits only). */
119
+ export const withUsage = ({ data, metadata, }) => {
120
+ const rest = { ...data };
121
+ delete rest.usage;
122
+ return { ...rest, usage: { credits: metadata?.credits ?? 0 } };
123
+ };
package/dist/index.d.ts CHANGED
@@ -29,13 +29,12 @@ export { TotalumVectors, VectorFilter, VectorMatch, VectorMetadata, VectorRecord
29
29
  import { totalumWeb } from './web/index.js';
30
30
  export { TotalumWeb } from './web/index.js';
31
31
  import { totalumWebhooks } from './webhooks/index.js';
32
- export { TotalumWebhookError, TotalumWebhooks, verifyWebhook } from './webhooks/index.js';
32
+ export { TotalumWebhookError, TotalumWebhooks, WebhookConfig, WebhookEvent, WebhookSecretOutput, verifyWebhook } from './webhooks/index.js';
33
33
  export { D1Database, D1DatabaseSession, D1ExecResult, D1PreparedStatement, D1Result, READ_YOUR_WRITES_COOKIE, TotalumD1ClientCode, TotalumD1Error, TotalumD1ErrorCode, TotalumD1Options, isTotalumD1Error, totalumD1, withTotalumSession } from './d1/index.js';
34
- export { T as TotalumClientOptions, a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from './_types/errors.d-WcXvShIX.js';
35
- export { C as CheckoutInput, a as CheckoutOutput, b as CheckoutSession, c as CronJob, d as CronJobInput, e as CronJobPatch, f as CronRun, g as CronRunsPage, h as CustomerPortalLinkInput, i as CustomerPortalLinkOutput, E as EmailSendInput, j as EmailSendOutput, k as EmailView, F as FileDescriptor, l as FileUploadUrlInput, m as FileUploadUrlOutput, n as FilesListQuery, o as FilesPage, J as JobCreated, O as OnboardingLinkInput, p as OnboardingLinkOutput, P as PaymentsStatus, q as PdfFromHtmlInput, r as PdfFromUrlInput, s as PdfOutput, R as RefundInput, t as RefundOutput, S as ScanDocumentInput, u as ScanOcrInput, v as ScanOcrOutput, w as ScreenshotInput, x as ScreenshotOutput, y as SeoIndexNowKey, z as SeoNotifyOutput, A as SpeakInput, B as StoredMedia, D as Subscription, G as SubscriptionUpdateInput, T as TranscribeInput, H as TranscribeOutput, W as WebJob, I as WebScrapeOutput, K as WebSearchOutput } from './_types/integrations.d-WM81VvEj.js';
36
- export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-CS92EKY-.js';
37
- export { W as WebhookConfig, a as WebhookEvent, b as WebhookSecretOutput } from './_types/billing.d-Bl2JQGMY.js';
38
- import './_types/coerce.d-Cli9TkUD.js';
34
+ export { T as TotalumClientOptions, a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from './_types/errors.d-BBRayxHv.js';
35
+ export { C as CheckoutInput, a as CheckoutOutput, b as CheckoutSession, c as CronJob, d as CronJobInput, e as CronJobPatch, f as CronRun, g as CronRunsPage, h as CustomerPortalLinkInput, i as CustomerPortalLinkOutput, E as EmailSendInput, j as EmailSendOutput, k as EmailView, F as FileDescriptor, l as FileUploadUrlInput, m as FileUploadUrlOutput, n as FilesListQuery, o as FilesPage, J as JobCreated, O as OnboardingLinkInput, p as OnboardingLinkOutput, P as PaymentsStatus, q as PdfFromHtmlInput, r as PdfFromUrlInput, s as PdfOutput, R as RefundInput, t as RefundOutput, S as ScanDocumentInput, u as ScanOcrInput, v as ScanOcrOutput, w as ScreenshotInput, x as ScreenshotOutput, y as SeoIndexNowKey, z as SeoNotifyOutput, A as SpeakInput, B as StoredMedia, D as Subscription, G as SubscriptionUpdateInput, T as TranscribeInput, H as TranscribeOutput, W as WebJob, I as WebScrapeOutput, K as WebSearchOutput } from './_types/integrations.d-Hj3BqI02.js';
36
+ export { L as LogsPage, S as SiteAnalyticsOutput, a as SiteDimension, b as SiteMetric } from './_types/ops.d-D_3lqkJ2.js';
37
+ import './_types/coerce.d-3Xj4xYuy.js';
39
38
 
40
39
  /** The options of `createTotalum()`: every namespace's options in one object (each falls back to its env var). */
41
40
  type TotalumOptions = TotalumAiOptions & TotalumFilesOptions;
@@ -1,8 +1,8 @@
1
- import { c as LogsQueryInput } from '../_types/ops.d-CS92EKY-.js';
2
- export { L as LogsPage } from '../_types/ops.d-CS92EKY-.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { c as LogsQueryInput } from '../_types/ops.d-D_3lqkJ2.js';
2
+ export { L as LogsPage } from '../_types/ops.d-D_3lqkJ2.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /** A `logs.query` filter: the window (default the last hour), level, substring, status class, path, request id, env. */
8
8
  type LogsQuery = Omit<LogsQueryInput, 'caller' | 'runId'>;
@@ -1,8 +1,8 @@
1
- import { O as OnboardingLinkInput, C as CheckoutInput, h as CustomerPortalLinkInput, G as SubscriptionUpdateInput, R as RefundInput } from '../_types/integrations.d-WM81VvEj.js';
2
- export { a as CheckoutOutput, b as CheckoutSession, i as CustomerPortalLinkOutput, p as OnboardingLinkOutput, P as PaymentsStatus, t as RefundOutput, D as Subscription } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { O as OnboardingLinkInput, C as CheckoutInput, h as CustomerPortalLinkInput, G as SubscriptionUpdateInput, R as RefundInput } from '../_types/integrations.d-Hj3BqI02.js';
2
+ export { a as CheckoutOutput, b as CheckoutSession, i as CustomerPortalLinkOutput, p as OnboardingLinkOutput, P as PaymentsStatus, t as RefundOutput, D as Subscription } from '../_types/integrations.d-Hj3BqI02.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /**
8
8
  * `totalum.payments` (plan 05, plan 11 §9.5) over SDK-API `/v1/payments/*` with a project key (scope `payments`): Stripe
@@ -1,8 +1,8 @@
1
- import { q as PdfFromHtmlInput, r as PdfFromUrlInput } from '../_types/integrations.d-WM81VvEj.js';
2
- export { s as PdfOutput } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
+ import { q as PdfFromHtmlInput, r as PdfFromUrlInput } from '../_types/integrations.d-Hj3BqI02.js';
4
+ export { s as PdfOutput } from '../_types/integrations.d-Hj3BqI02.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /** `totalum.pdf` (plan 04 §5.5) over `/v1/pdf/*` (scope `files:write`): a new file in the project's storage each time. */
8
8
  declare function totalumPdf(options?: TotalumClientOptions): {
@@ -12,28 +12,20 @@ declare function totalumPdf(options?: TotalumClientOptions): {
12
12
  * @example
13
13
  * const { url } = await pdf.fromHtml({ html: '<h1>Invoice 12</h1>', name: 'invoice-12' });
14
14
  */
15
- fromHtml: (input: PdfFromHtmlInput) => Promise<{
15
+ fromHtml: (input: PdfFromHtmlInput) => Promise<Omit<{
16
16
  url: string;
17
17
  fileName: string;
18
18
  key: string;
19
- } & {
20
- usage: {
21
- vendor?: string | undefined;
22
- units?: number | undefined;
23
- credits: number;
24
- };
19
+ }, "usage"> & {
20
+ usage: Usage;
25
21
  }>;
26
22
  /** A PDF of a web page, stored as a project file. */
27
- fromUrl: (input: PdfFromUrlInput) => Promise<{
23
+ fromUrl: (input: PdfFromUrlInput) => Promise<Omit<{
28
24
  url: string;
29
25
  fileName: string;
30
26
  key: string;
31
- } & {
32
- usage: {
33
- vendor?: string | undefined;
34
- units?: number | undefined;
35
- credits: number;
36
- };
27
+ }, "usage"> & {
28
+ usage: Usage;
37
29
  }>;
38
30
  };
39
31
  type TotalumPdf = ReturnType<typeof totalumPdf>;
@@ -1,5 +1,5 @@
1
- import { Z as ZodObject, c as ZodOptional, d as ZodString, g as ZodUnknown, m as $strip, o as output, u as ZodISODateTime, l as ZodInt, h as ZodRecord, j as ZodBoolean, T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
2
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
1
+ import { Z as ZodObject, c as ZodOptional, d as ZodString, g as ZodUnknown, m as $strip, o as output, u as ZodISODateTime, l as ZodInt, h as ZodRecord, j as ZodBoolean, T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
3
 
4
4
  /** `POST /v1/realtime/tickets` (scope `realtime`). `ttl` is the join window in seconds, not the session length. */
5
5
  declare const RealtimeTicketInput: ZodObject<{
@@ -1,8 +1,8 @@
1
- import { S as ScanDocumentInput, u as ScanOcrInput } from '../_types/integrations.d-WM81VvEj.js';
2
- export { v as ScanOcrOutput } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { S as ScanDocumentInput, u as ScanOcrInput } from '../_types/integrations.d-Hj3BqI02.js';
2
+ export { v as ScanOcrOutput } from '../_types/integrations.d-Hj3BqI02.js';
3
+ import { U as Usage, T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /**
8
8
  * The v1 scan result: the extracted fields (one set per page with `processEveryPdfPageAsDifferentScan`), the v1
@@ -17,18 +17,14 @@ interface ScanDocumentResult {
17
17
  provider: string;
18
18
  credits: number;
19
19
  };
20
- usage: {
21
- credits: number;
22
- vendor?: string | undefined;
23
- units?: number | undefined;
24
- };
20
+ usage: Usage;
25
21
  }
26
22
  /** `totalum.scan` (plan 05 §6.7) over `/v1/scan/*` (scope `scan`): a vision model through Totalum's AI gateway. */
27
23
  declare function totalumScan(options?: TotalumClientOptions): {
28
24
  /** Extracts the fields described by `properties` from a document or image (one set per page on request). */
29
25
  document: (input: ScanDocumentInput) => Promise<ScanDocumentResult>;
30
26
  /** The text of a document or image, per page as Markdown. */
31
- ocr: (input: ScanOcrInput) => Promise<{
27
+ ocr: (input: ScanOcrInput) => Promise<Omit<{
32
28
  text: string;
33
29
  pages: {
34
30
  markdown: string;
@@ -40,12 +36,8 @@ declare function totalumScan(options?: TotalumClientOptions): {
40
36
  }[] | undefined;
41
37
  }[];
42
38
  fullDetails?: unknown;
43
- } & {
44
- usage: {
45
- vendor?: string | undefined;
46
- units?: number | undefined;
47
- credits: number;
48
- };
39
+ }, "usage"> & {
40
+ usage: Usage;
49
41
  }>;
50
42
  };
51
43
  type TotalumScan = ReturnType<typeof totalumScan>;
@@ -1,7 +1,7 @@
1
- export { y as SeoIndexNowKey, z as SeoNotifyOutput } from '../_types/integrations.d-WM81VvEj.js';
2
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
3
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
4
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ export { y as SeoIndexNowKey, z as SeoNotifyOutput } from '../_types/integrations.d-Hj3BqI02.js';
2
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
3
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
4
+ import '../_types/coerce.d-3Xj4xYuy.js';
5
5
 
6
6
  /** `totalum.seo` (plan 05 §6.10) over SDK-API `/v1/seo/*` (scope `seo`): IndexNow for verified custom domains, free. */
7
7
  declare function totalumSeo(options?: TotalumClientOptions): {
@@ -1,8 +1,8 @@
1
- import { T as TranscribeInput, A as SpeakInput, B as StoredMedia } from '../_types/integrations.d-WM81VvEj.js';
2
- export { H as TranscribeOutput } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { T as TranscribeInput, A as SpeakInput, B as StoredMedia } from '../_types/integrations.d-Hj3BqI02.js';
2
+ export { H as TranscribeOutput } from '../_types/integrations.d-Hj3BqI02.js';
3
+ import { T as TotalumClientOptions } from '../_types/errors.d-BBRayxHv.js';
4
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /** The audio bytes of `synthesize` without `store`, and what the call cost (`usage.credits`, the call's hold). */
8
8
  interface SpeechAudio {
@@ -25,9 +25,6 @@ declare function totalumSpeech(options?: TotalumClientOptions): {
25
25
  durationSec: number;
26
26
  usage: {
27
27
  credits: number;
28
- vendor?: string | undefined;
29
- units?: number | undefined;
30
- vendorCostUsd?: number | undefined;
31
28
  };
32
29
  language?: string | undefined;
33
30
  segments?: {
@@ -1,5 +1,5 @@
1
- import { Z as ZodObject, d as ZodString, c as ZodOptional, e as ZodArray, k as ZodNumber, f as ZodEnum, h as ZodRecord, n as ZodUnion, j as ZodBoolean, m as $strip, o as output, l as ZodInt, q as $partial, x as $strict, T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
2
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
1
+ import { Z as ZodObject, d as ZodString, c as ZodOptional, e as ZodArray, k as ZodNumber, f as ZodEnum, h as ZodRecord, n as ZodUnion, j as ZodBoolean, m as $strip, o as output, l as ZodInt, q as $partial, x as $strict, T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
3
 
4
4
  /** `text` = the `embed` preset's space; `image` = the `embed-image` preset's text+image space. */
5
5
  declare const VectorSpace: ZodEnum<{
@@ -108,31 +108,20 @@ declare function totalumVectors(options?: TotalumClientOptions): {
108
108
  * The answer (and `count()`) means stored; `query` and `get` see the write later — often seconds, sometimes 10+
109
109
  * minutes (the index applies writes asynchronously). Never wait or poll for a write to become searchable.
110
110
  */
111
- upsert: (vectors: VectorUpsertItem[]) => Promise<Omit<{
111
+ upsert: (vectors: VectorUpsertItem[]) => Promise<Omit<Omit<{
112
112
  upserted: number;
113
113
  count: number;
114
114
  usage: {
115
115
  credits: number;
116
- vendor?: string | undefined;
117
- units?: number | undefined;
118
- vendorCostUsd?: number | undefined;
119
- };
120
- }, "usage"> & {
121
- usage: {
122
- vendor?: string | undefined;
123
- units?: number | undefined;
124
- credits: number;
125
116
  };
117
+ }, "usage">, "usage"> & {
118
+ usage: Usage;
126
119
  }>;
127
120
  /** The `topK` (≤ 50, default 5) closest vectors to `text`, `values` or `image`, with their metadata. */
128
- query: (input: VectorsQueryInput) => Promise<{
121
+ query: (input: VectorsQueryInput) => Promise<Omit<{
129
122
  matches: VectorMatch[];
130
- } & {
131
- usage: {
132
- vendor?: string | undefined;
133
- units?: number | undefined;
134
- credits: number;
135
- };
123
+ }, "usage"> & {
124
+ usage: Usage;
136
125
  }>;
137
126
  /** The stored vectors (values and metadata) of up to 100 ids; unknown and just-written ids are left out. */
138
127
  get: (ids: string[]) => Promise<{
@@ -142,21 +131,14 @@ declare function totalumVectors(options?: TotalumClientOptions): {
142
131
  metadata?: Record<string, string | number | boolean | string[]> | undefined;
143
132
  }[]>;
144
133
  /** Deletes up to 1,000 ids; answers how many existed and how many are left. */
145
- delete: (ids: string[]) => Promise<Omit<{
134
+ delete: (ids: string[]) => Promise<Omit<Omit<{
146
135
  deleted: number;
147
136
  count: number;
148
137
  usage: {
149
138
  credits: number;
150
- vendor?: string | undefined;
151
- units?: number | undefined;
152
- vendorCostUsd?: number | undefined;
153
- };
154
- }, "usage"> & {
155
- usage: {
156
- vendor?: string | undefined;
157
- units?: number | undefined;
158
- credits: number;
159
139
  };
140
+ }, "usage">, "usage"> & {
141
+ usage: Usage;
160
142
  }>;
161
143
  /** How many vectors this environment stores (free). */
162
144
  count: () => Promise<{
@@ -1,8 +1,8 @@
1
- import { L as WebScrapeInput, M as WebSearchInput, N as WebMapInput, Q as WebCrawlInput, w as ScreenshotInput } from '../_types/integrations.d-WM81VvEj.js';
2
- export { J as JobCreated, x as ScreenshotOutput, W as WebJob, I as WebScrapeOutput, K as WebSearchOutput } from '../_types/integrations.d-WM81VvEj.js';
3
- import { T as TotalumClientOptions } from '../_types/errors.d-WcXvShIX.js';
4
- export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
5
- import '../_types/coerce.d-Cli9TkUD.js';
1
+ import { T as TotalumClientOptions, U as Usage } from '../_types/errors.d-BBRayxHv.js';
2
+ export { a as TotalumError, b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
+ import { L as WebScrapeInput, M as WebSearchInput, N as WebMapInput, Q as WebCrawlInput, w as ScreenshotInput } from '../_types/integrations.d-Hj3BqI02.js';
4
+ export { J as JobCreated, x as ScreenshotOutput, W as WebJob, I as WebScrapeOutput, K as WebSearchOutput } from '../_types/integrations.d-Hj3BqI02.js';
5
+ import '../_types/coerce.d-3Xj4xYuy.js';
6
6
 
7
7
  /**
8
8
  * `totalum.web` (plan 05 §6.2) over SDK-API `/v1/web/*` (scope `web`): scrape, search, map, crawl and screenshots,
@@ -26,9 +26,6 @@ declare function totalumWeb(options?: TotalumClientOptions): {
26
26
  };
27
27
  usage: {
28
28
  credits: number;
29
- vendor?: string | undefined;
30
- units?: number | undefined;
31
- vendorCostUsd?: number | undefined;
32
29
  };
33
30
  markdown?: string | undefined;
34
31
  html?: string | undefined;
@@ -40,7 +37,7 @@ declare function totalumWeb(options?: TotalumClientOptions): {
40
37
  contentUrl?: string | undefined;
41
38
  }>;
42
39
  /** A web search; with `scrapeOptions` each result also carries its page content. */
43
- search: (query: string, opts?: Omit<WebSearchInput, "query">) => Promise<{
40
+ search: (query: string, opts?: Omit<WebSearchInput, "query">) => Promise<Omit<{
44
41
  web: {
45
42
  title: string;
46
43
  url: string;
@@ -72,22 +69,14 @@ declare function totalumWeb(options?: TotalumClientOptions): {
72
69
  summary?: string | undefined;
73
70
  contentUrl?: string | undefined;
74
71
  }[] | undefined;
75
- } & {
76
- usage: {
77
- vendor?: string | undefined;
78
- units?: number | undefined;
79
- credits: number;
80
- };
72
+ }, "usage"> & {
73
+ usage: Usage;
81
74
  }>;
82
75
  /** The URLs of a site (sitemap and links), without fetching the pages. */
83
- map: (url: string, opts?: Omit<WebMapInput, "url">) => Promise<{
76
+ map: (url: string, opts?: Omit<WebMapInput, "url">) => Promise<Omit<{
84
77
  links: string[];
85
- } & {
86
- usage: {
87
- vendor?: string | undefined;
88
- units?: number | undefined;
89
- credits: number;
90
- };
78
+ }, "usage"> & {
79
+ usage: Usage;
91
80
  }>;
92
81
  /** `202 {jobId}`: poll `crawlStatus` until the job leaves `running`; that read settles its charge. */
93
82
  crawl: (url: string, opts?: Omit<WebCrawlInput, "url">) => Promise<{
@@ -151,17 +140,13 @@ declare function totalumWeb(options?: TotalumClientOptions): {
151
140
  resultUrl?: string | undefined;
152
141
  }>;
153
142
  /** A screenshot of a `url` or of inline `html`, stored as a project file (`key`, `url`). */
154
- screenshot: (input: ScreenshotInput) => Promise<{
143
+ screenshot: (input: ScreenshotInput) => Promise<Omit<{
155
144
  key: string;
156
145
  url: string;
157
146
  format: "png" | "jpeg" | "webp";
158
147
  base64?: string | undefined;
159
- } & {
160
- usage: {
161
- vendor?: string | undefined;
162
- units?: number | undefined;
163
- credits: number;
164
- };
148
+ }, "usage"> & {
149
+ usage: Usage;
165
150
  }>;
166
151
  };
167
152
  type TotalumWeb = ReturnType<typeof totalumWeb>;
@@ -1,7 +1,32 @@
1
- import { a as WebhookEvent } from '../_types/billing.d-Bl2JQGMY.js';
2
- export { W as WebhookConfig, b as WebhookSecretOutput } from '../_types/billing.d-Bl2JQGMY.js';
3
- import { T as TotalumClientOptions, a as TotalumError } from '../_types/errors.d-WcXvShIX.js';
4
- export { b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-WcXvShIX.js';
1
+ import { Z as ZodObject, d as ZodString, u as ZodISODateTime, f as ZodEnum, c as ZodOptional, j as ZodBoolean, h as ZodRecord, g as ZodUnknown, m as $strip, o as output, w as ZodNullable, p as ZodURL, T as TotalumClientOptions, a as TotalumError } from '../_types/errors.d-BBRayxHv.js';
2
+ export { b as TotalumErrorCode, i as isTotalumError } from '../_types/errors.d-BBRayxHv.js';
3
+
4
+ /** The delivery body: `{id, type, createdAt, projectId, env, livemode?, data}`, idempotent by `id`. */
5
+ declare const WebhookEvent: ZodObject<{
6
+ id: ZodString;
7
+ type: ZodString;
8
+ createdAt: ZodISODateTime;
9
+ projectId: ZodString;
10
+ env: ZodEnum<{
11
+ dev: "dev";
12
+ live: "live";
13
+ }>;
14
+ livemode: ZodOptional<ZodBoolean>;
15
+ data: ZodRecord<ZodString, ZodUnknown>;
16
+ }, $strip>;
17
+ type WebhookEvent = output<typeof WebhookEvent>;
18
+ /** `GET|PUT /v1/webhooks`: the secret itself is shown only by `POST /v1/webhooks/rotate-secret`. */
19
+ declare const WebhookConfig: ZodObject<{
20
+ url: ZodNullable<ZodURL>;
21
+ enabled: ZodBoolean;
22
+ secretPrefix: ZodNullable<ZodString>;
23
+ }, $strip>;
24
+ type WebhookConfig = output<typeof WebhookConfig>;
25
+ /** `POST /v1/webhooks/rotate-secret`: a new signing secret, revealed once (`whsec_` + 64 hex). */
26
+ declare const WebhookSecretOutput: ZodObject<{
27
+ secret: ZodString;
28
+ }, $strip>;
29
+ type WebhookSecretOutput = output<typeof WebhookSecretOutput>;
5
30
 
6
31
  /** A webhook refusal (plan 05 §7.2): the codes never travel, the app answers 400. */
7
32
  declare class TotalumWebhookError extends TotalumError {
@@ -45,5 +70,5 @@ declare function totalumWebhooks(options?: TotalumClientOptions): {
45
70
  };
46
71
  type TotalumWebhooks = ReturnType<typeof totalumWebhooks>;
47
72
 
48
- export { TotalumClientOptions, TotalumError, TotalumWebhookError, WebhookEvent, totalumWebhooks, verifyWebhook };
73
+ export { TotalumClientOptions, TotalumError, TotalumWebhookError, WebhookConfig, WebhookEvent, WebhookSecretOutput, totalumWebhooks, verifyWebhook };
49
74
  export type { TotalumWebhooks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "totalum-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.10.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
@@ -21,7 +21,7 @@ same environment at call time, never at import; an option of the same name wins:
21
21
  | `TOTALUM_SDK_API_URL` | `apiUrl` | Default `https://sdk-api.totalum.app`. |
22
22
  | `TOTALUM_ENV` | `env` | `dev` or `live` (default), sent as `x-totalum-env`: the database `totalum-sdk/d1` targets over HTTPS, and dev vs live usage. |
23
23
  | `TOTALUM_FILES_URL` | `filesUrl` | The public files host of `files.url()`. |
24
- | `TOTALUM_AI_BASE_URL` | `aiBaseUrl` | The exact-OpenRouter gateway `ai.gatewayConfig()` returns. |
24
+ | `TOTALUM_AI_BASE_URL` | `aiBaseUrl` | The OpenAI-compatible AI gateway `ai.gatewayConfig()` returns. |
25
25
  | `TOTALUM_APP_KEY` | `key` | Set by Totalum in the sandbox only: the deployed app's own key, used before `TOTALUM_PROJECT_KEY` by every namespace but the database, so the agent's checks have the app's permissions. |
26
26
  | `TOTALUM_WEBHOOK_SECRET` | argument | The secret `webhooks.verify` checks `Totalum-Signature` with. Totalum sets it on the preview, the published site and the sandbox, and a rotation reaches them at once: never set it yourself. |
27
27
 
@@ -367,7 +367,7 @@ billed in credits — every result carries `usage.credits`.
367
367
  #### `web.scrape`
368
368
 
369
369
  ```ts
370
- web.scrape(url: string, opts?: Omit<{ url: string; formats?: ('screenshot' | 'markdown' | 'html' | 'rawHtml' | 'links' | 'json' | 'summary')[] | undefined; onlyMainContent?: boolean | undefined; waitFor?: number | undefined; timeout?: number | undefined; proxy?: 'basic' | 'stealth' | 'auto' | undefined; location?: { country?: string | undefined; languages?: string[] | undefined; } | undefined; actions?: Record<string, unknown>[] | undefined; schema?: Record<string, unknown> | undefined; prompt?: string | undefined; cacheMaxAgeMs?: number | undefined; }, 'url'>): Promise<{ url: string; statusCode: number; metadata: { sourceURL: string; title?: string | undefined; description?: string | undefined; language?: string | undefined; }; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; markdown?: string | undefined; html?: string | undefined; rawHtml?: string | undefined; links?: string[] | undefined; screenshotUrl?: string | undefined; json?: unknown; summary?: string | undefined; contentUrl?: string | undefined; }>
370
+ web.scrape(url: string, opts?: Omit<{ url: string; formats?: ('screenshot' | 'markdown' | 'html' | 'rawHtml' | 'links' | 'json' | 'summary')[] | undefined; onlyMainContent?: boolean | undefined; waitFor?: number | undefined; timeout?: number | undefined; proxy?: 'basic' | 'stealth' | 'auto' | undefined; location?: { country?: string | undefined; languages?: string[] | undefined; } | undefined; actions?: Record<string, unknown>[] | undefined; schema?: Record<string, unknown> | undefined; prompt?: string | undefined; cacheMaxAgeMs?: number | undefined; }, 'url'>): Promise<{ url: string; statusCode: number; metadata: { sourceURL: string; title?: string | undefined; description?: string | undefined; language?: string | undefined; }; usage: { credits: number; }; markdown?: string | undefined; html?: string | undefined; rawHtml?: string | undefined; links?: string[] | undefined; screenshotUrl?: string | undefined; json?: unknown; summary?: string | undefined; contentUrl?: string | undefined; }>
371
371
  ```
372
372
 
373
373
  One page as `markdown`, `html`, `links`, ….
@@ -379,7 +379,7 @@ const { markdown } = await web.scrape('https://example.com', { formats: ['markdo
379
379
  #### `web.search`
380
380
 
381
381
  ```ts
382
- web.search(query: string, opts?: Omit<{ query: string; limit?: number | undefined; sources?: ('web' | 'news' | 'images')[] | undefined; location?: { country?: string | undefined; city?: string | undefined; } | undefined; timeRange?: 'day' | 'month' | 'week' | 'year' | undefined; scrapeOptions?: { formats?: ('screenshot' | 'markdown' | 'html' | 'rawHtml' | 'links' | 'json' | 'summary')[] | undefined; onlyMainContent?: boolean | undefined; waitFor?: number | undefined; timeout?: number | undefined; proxy?: 'basic' | 'stealth' | 'auto' | undefined; location?: { country?: string | undefined; languages?: string[] | undefined; } | undefined; actions?: Record<string, unknown>[] | undefined; schema?: Record<string, unknown> | undefined; prompt?: string | undefined; cacheMaxAgeMs?: number | undefined; } | undefined; }, 'query'>): Promise<{ web: { title: string; url: string; position: number; snippet?: string | undefined; }[]; news?: { title: string; url: string; position: number; snippet?: string | undefined; }[] | undefined; images?: Record<string, unknown>[] | undefined; scraped?: { url: string; statusCode: number; metadata: { sourceURL: string; title?: string | undefined; description?: string | undefined; language?: string | undefined; }; markdown?: string | undefined; html?: string | undefined; rawHtml?: string | undefined; links?: string[] | undefined; screenshotUrl?: string | undefined; json?: unknown; summary?: string | undefined; contentUrl?: string | undefined; }[] | undefined; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
382
+ web.search(query: string, opts?: Omit<{ query: string; limit?: number | undefined; sources?: ('web' | 'news' | 'images')[] | undefined; location?: { country?: string | undefined; city?: string | undefined; } | undefined; timeRange?: 'day' | 'month' | 'week' | 'year' | undefined; scrapeOptions?: { formats?: ('screenshot' | 'markdown' | 'html' | 'rawHtml' | 'links' | 'json' | 'summary')[] | undefined; onlyMainContent?: boolean | undefined; waitFor?: number | undefined; timeout?: number | undefined; proxy?: 'basic' | 'stealth' | 'auto' | undefined; location?: { country?: string | undefined; languages?: string[] | undefined; } | undefined; actions?: Record<string, unknown>[] | undefined; schema?: Record<string, unknown> | undefined; prompt?: string | undefined; cacheMaxAgeMs?: number | undefined; } | undefined; }, 'query'>): Promise<Omit<{ web: { title: string; url: string; position: number; snippet?: string | undefined; }[]; news?: { title: string; url: string; position: number; snippet?: string | undefined; }[] | undefined; images?: Record<string, unknown>[] | undefined; scraped?: { url: string; statusCode: number; metadata: { sourceURL: string; title?: string | undefined; description?: string | undefined; language?: string | undefined; }; markdown?: string | undefined; html?: string | undefined; rawHtml?: string | undefined; links?: string[] | undefined; screenshotUrl?: string | undefined; json?: unknown; summary?: string | undefined; contentUrl?: string | undefined; }[] | undefined; }, 'usage'> & { usage: Usage; }>
383
383
  ```
384
384
 
385
385
  A web search; with `scrapeOptions` each result also carries its page content.
@@ -387,7 +387,7 @@ A web search; with `scrapeOptions` each result also carries its page content.
387
387
  #### `web.map`
388
388
 
389
389
  ```ts
390
- web.map(url: string, opts?: Omit<{ url: string; search?: string | undefined; limit?: number | undefined; }, 'url'>): Promise<{ links: string[]; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
390
+ web.map(url: string, opts?: Omit<{ url: string; search?: string | undefined; limit?: number | undefined; }, 'url'>): Promise<Omit<{ links: string[]; }, 'usage'> & { usage: Usage; }>
391
391
  ```
392
392
 
393
393
  The URLs of a site (sitemap and links), without fetching the pages.
@@ -419,7 +419,7 @@ Stops a running crawl; pages already crawled are charged.
419
419
  #### `web.screenshot`
420
420
 
421
421
  ```ts
422
- web.screenshot(input: { url?: string | undefined; html?: string | undefined; fullPage?: boolean | undefined; viewport?: { width: number; height: number; } | undefined; format?: 'png' | 'jpeg' | 'webp' | undefined; waitForSelector?: string | undefined; inline?: boolean | undefined; }): Promise<{ key: string; url: string; format: 'png' | 'jpeg' | 'webp'; base64?: string | undefined; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
422
+ web.screenshot(input: { url?: string | undefined; html?: string | undefined; fullPage?: boolean | undefined; viewport?: { width: number; height: number; } | undefined; format?: 'png' | 'jpeg' | 'webp' | undefined; waitForSelector?: string | undefined; inline?: boolean | undefined; }): Promise<Omit<{ key: string; url: string; format: 'png' | 'jpeg' | 'webp'; base64?: string | undefined; }, 'usage'> & { usage: Usage; }>
423
423
  ```
424
424
 
425
425
  A screenshot of a `url` or of inline `html`, stored as a project file (`key`, `url`).
@@ -437,7 +437,7 @@ totalumPdf(options?: TotalumClientOptions)
437
437
  #### `pdf.fromHtml`
438
438
 
439
439
  ```ts
440
- pdf.fromHtml(input: { name: string; html?: string | undefined; base64HtmlString?: string | undefined; options?: { format?: string | undefined; landscape?: boolean | undefined; margin?: Record<string, string> | undefined; printBackground?: boolean | undefined; headerTemplate?: string | undefined; footerTemplate?: string | undefined; displayHeaderFooter?: boolean | undefined; } | undefined; waitForSelector?: string | undefined; }): Promise<{ url: string; fileName: string; key: string; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
440
+ pdf.fromHtml(input: { name: string; html?: string | undefined; base64HtmlString?: string | undefined; options?: { format?: string | undefined; landscape?: boolean | undefined; margin?: Record<string, string> | undefined; printBackground?: boolean | undefined; headerTemplate?: string | undefined; footerTemplate?: string | undefined; displayHeaderFooter?: boolean | undefined; } | undefined; waitForSelector?: string | undefined; }): Promise<Omit<{ url: string; fileName: string; key: string; }, 'usage'> & { usage: Usage; }>
441
441
  ```
442
442
 
443
443
  A PDF rendered from HTML, stored as a project file (`key`, `url`).
@@ -449,7 +449,7 @@ const { url } = await pdf.fromHtml({ html: '<h1>Invoice 12</h1>', name: 'invoice
449
449
  #### `pdf.fromUrl`
450
450
 
451
451
  ```ts
452
- pdf.fromUrl(input: { url: string; name: string; options?: { format?: string | undefined; landscape?: boolean | undefined; margin?: Record<string, string> | undefined; printBackground?: boolean | undefined; headerTemplate?: string | undefined; footerTemplate?: string | undefined; displayHeaderFooter?: boolean | undefined; } | undefined; cookies?: Record<string, unknown>[] | undefined; headers?: Record<string, string> | undefined; }): Promise<{ url: string; fileName: string; key: string; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
452
+ pdf.fromUrl(input: { url: string; name: string; options?: { format?: string | undefined; landscape?: boolean | undefined; margin?: Record<string, string> | undefined; printBackground?: boolean | undefined; headerTemplate?: string | undefined; footerTemplate?: string | undefined; displayHeaderFooter?: boolean | undefined; } | undefined; cookies?: Record<string, unknown>[] | undefined; headers?: Record<string, string> | undefined; }): Promise<Omit<{ url: string; fileName: string; key: string; }, 'usage'> & { usage: Usage; }>
453
453
  ```
454
454
 
455
455
  A PDF of a web page, stored as a project file.
@@ -475,7 +475,7 @@ Extracts the fields described by `properties` from a document or image (one set
475
475
  #### `scan.ocr`
476
476
 
477
477
  ```ts
478
- scan.ocr(input: { pages?: number[] | undefined; fileName?: string | undefined; key?: string | undefined; url?: string | undefined; }): Promise<{ text: string; pages: { markdown: string; width: number; height: number; words?: { text: string; bbox: number[]; }[] | undefined; }[]; fullDetails?: unknown; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
478
+ scan.ocr(input: { pages?: number[] | undefined; fileName?: string | undefined; key?: string | undefined; url?: string | undefined; }): Promise<Omit<{ text: string; pages: { markdown: string; width: number; height: number; words?: { text: string; bbox: number[]; }[] | undefined; }[]; fullDetails?: unknown; }, 'usage'> & { usage: Usage; }>
479
479
  ```
480
480
 
481
481
  The text of a document or image, per page as Markdown.
@@ -498,7 +498,7 @@ metadata keys `source`, `type`, `tag`, `group` (strings) and `page` (number).
498
498
  #### `vectors.upsert`
499
499
 
500
500
  ```ts
501
- vectors.upsert(vectors: { id: string; values?: number[] | undefined; text?: string | undefined; image?: string | undefined; space?: 'text' | 'image' | undefined; metadata?: Record<string, string | number | boolean | string[]> | undefined; }[]): Promise<Omit<{ upserted: number; count: number; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }, 'usage'> & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
501
+ vectors.upsert(vectors: { id: string; values?: number[] | undefined; text?: string | undefined; image?: string | undefined; space?: 'text' | 'image' | undefined; metadata?: Record<string, string | number | boolean | string[]> | undefined; }[]): Promise<Omit<Omit<{ upserted: number; count: number; usage: { credits: number; }; }, 'usage'>, 'usage'> & { usage: Usage; }>
502
502
  ```
503
503
 
504
504
  Inserts or replaces up to 100 vectors (≤ 8 images) from `values`, `text` or `image`, with optional metadata.
@@ -508,7 +508,7 @@ minutes (the index applies writes asynchronously). Never wait or poll for a writ
508
508
  #### `vectors.query`
509
509
 
510
510
  ```ts
511
- vectors.query(input: { text?: string | undefined; values?: number[] | undefined; image?: string | undefined; space?: 'text' | 'image' | undefined; topK?: number | undefined; filter?: Partial<Record<'type' | 'source' | 'page' | 'tag' | 'group', string | number | boolean | { $eq?: string | number | boolean | undefined; $ne?: string | number | boolean | undefined; $in?: (string | number | boolean)[] | undefined; $nin?: (string | number | boolean)[] | undefined; $lt?: string | number | undefined; $lte?: string | number | undefined; $gt?: string | number | undefined; $gte?: string | number | undefined; }>> | undefined; includeValues?: boolean | undefined; }): Promise<{ matches: { id: string; score: number; space: 'text' | 'image'; metadata?: Record<string, string | number | boolean | string[]> | undefined; values?: number[] | undefined; }[]; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
511
+ vectors.query(input: { text?: string | undefined; values?: number[] | undefined; image?: string | undefined; space?: 'text' | 'image' | undefined; topK?: number | undefined; filter?: Partial<Record<'type' | 'source' | 'page' | 'tag' | 'group', string | number | boolean | { $eq?: string | number | boolean | undefined; $ne?: string | number | boolean | undefined; $in?: (string | number | boolean)[] | undefined; $nin?: (string | number | boolean)[] | undefined; $lt?: string | number | undefined; $lte?: string | number | undefined; $gt?: string | number | undefined; $gte?: string | number | undefined; }>> | undefined; includeValues?: boolean | undefined; }): Promise<Omit<{ matches: { id: string; score: number; space: 'text' | 'image'; metadata?: Record<string, string | number | boolean | string[]> | undefined; values?: number[] | undefined; }[]; }, 'usage'> & { usage: Usage; }>
512
512
  ```
513
513
 
514
514
  The `topK` (≤ 50, default 5) closest vectors to `text`, `values` or `image`, with their metadata.
@@ -524,7 +524,7 @@ The stored vectors (values and metadata) of up to 100 ids; unknown and just-writ
524
524
  #### `vectors.delete`
525
525
 
526
526
  ```ts
527
- vectors.delete(ids: string[]): Promise<Omit<{ deleted: number; count: number; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }, 'usage'> & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
527
+ vectors.delete(ids: string[]): Promise<Omit<Omit<{ deleted: number; count: number; usage: { credits: number; }; }, 'usage'>, 'usage'> & { usage: Usage; }>
528
528
  ```
529
529
 
530
530
  Deletes up to 1,000 ids; answers how many existed and how many are left.
@@ -550,7 +550,7 @@ totalumSpeech(options?: TotalumClientOptions)
550
550
  #### `speech.transcribe`
551
551
 
552
552
  ```ts
553
- speech.transcribe(input: { audioBase64?: string | undefined; filename?: string | undefined; url?: string | undefined; language?: string | undefined; model?: 'fast' | 'accurate' | undefined; diarize?: boolean | undefined; timestamps?: 'word' | 'segment' | undefined; keyterms?: string[] | undefined; }): Promise<{ text: string; durationSec: number; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; language?: string | undefined; segments?: { start: number; end: number; text: string; }[] | undefined; words?: { word: string; start: number; end: number; }[] | undefined; }>
553
+ speech.transcribe(input: { audioBase64?: string | undefined; filename?: string | undefined; url?: string | undefined; language?: string | undefined; model?: 'fast' | 'accurate' | undefined; diarize?: boolean | undefined; timestamps?: 'word' | 'segment' | undefined; keyterms?: string[] | undefined; }): Promise<{ text: string; durationSec: number; usage: { credits: number; }; language?: string | undefined; segments?: { start: number; end: number; text: string; }[] | undefined; words?: { word: string; start: number; end: number; }[] | undefined; }>
554
554
  ```
555
555
 
556
556
  Speech to text from `audioBase64` (+ `filename` with its extension) or a `url` — a public one, or a file this
@@ -559,8 +559,8 @@ project stored; optional language, word timestamps and speakers.
559
559
  #### `speech.synthesize`
560
560
 
561
561
  ```ts
562
- speech.synthesize(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; } & { store: true; }): Promise<{ key: string; url: string; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }>
563
- speech.synthesize(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; }): Promise<{ key: string; url: string; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; } | SpeechAudio>
562
+ speech.synthesize(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; } & { store: true; }): Promise<{ key: string; url: string; usage: { credits: number; }; }>
563
+ speech.synthesize(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; }): Promise<{ key: string; url: string; usage: { credits: number; }; } | SpeechAudio>
564
564
  ```
565
565
 
566
566
  The stored file `{key, url, usage}` with `store: true`; else the audio bytes `{audio, contentType, usage}`.
@@ -575,7 +575,7 @@ totalumAi(options?: TotalumAiOptions)
575
575
 
576
576
  `totalum.ai` over SDK-API `/v1/ai/*` (scope `ai`): a `model` is a preset (`fast`,
577
577
  `smart`, `reasoning`, `vision`, `image`, `image-edit`, `video`, `tts`, `stt`, `embed` — each follows the newest model
578
- of its family, resolved by Totalum) or a pinned OpenRouter id; every call returned with the Totalum credits it was
578
+ of its family, resolved by Totalum) or a pinned model id; every call returned with the Totalum credits it was
579
579
  charged (`usage.credits`, never tokens or a vendor cost). No `ai.agent()` — the
580
580
  agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gatewayConfig()`.
581
581
 
@@ -585,7 +585,7 @@ agent loop is the template's `src/agents/` on the Vercel AI SDK, pointed at `gat
585
585
  ai.chat(req: Omit<{ messages: { [x: string]: unknown; role: 'user' | 'system' | 'assistant' | 'tool' | 'developer'; content: unknown; }[]; model?: string | undefined; tools?: Record<string, unknown>[] | undefined; toolChoice?: unknown; parallelToolCalls?: boolean | undefined; responseFormat?: Record<string, unknown> | undefined; temperature?: number | undefined; maxTokens?: number | undefined; reasoning?: { effort: string; } | undefined; serverTools?: ('web_search' | 'image_generation' | 'web_fetch' | 'datetime')[] | undefined; maxToolCalls?: number | undefined; stream?: boolean | undefined; cache?: { ttlSec: number; } | undefined; zdr?: boolean | undefined; fastMode?: boolean | undefined; user?: string | undefined; }, 'stream'>): Promise<ChatResult>
586
586
  ```
587
587
 
588
- A chat completion; `model` is a preset (`fast`, `smart` — the default — or `reasoning`) or a pinned OpenRouter id.
588
+ A chat completion; `model` is a preset (`fast`, `smart` — the default — or `reasoning`) or a pinned model id.
589
589
 
590
590
  ```ts
591
591
  const { text } = await ai.chat({ model: 'fast', messages: [{ role: 'user', content: 'Hi' }] });
@@ -603,7 +603,7 @@ The same request streamed: `raw` is the OpenAI-format SSE (return it from a rout
603
603
  #### `ai.generateObject`
604
604
 
605
605
  ```ts
606
- ai.generateObject(req: { schema: Record<string, unknown>; prompt?: string | undefined; messages?: { [x: string]: unknown; role: 'user' | 'system' | 'assistant' | 'tool' | 'developer'; content: unknown; }[] | undefined; model?: string | undefined; healing?: boolean | undefined; }): Promise<{ object: unknown; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }>
606
+ ai.generateObject(req: { schema: Record<string, unknown>; prompt?: string | undefined; messages?: { [x: string]: unknown; role: 'user' | 'system' | 'assistant' | 'tool' | 'developer'; content: unknown; }[] | undefined; model?: string | undefined; healing?: boolean | undefined; }): Promise<{ object: unknown; usage: Usage; }>
607
607
  ```
608
608
 
609
609
  A JSON object matching `schema` (JSON Schema).
@@ -619,7 +619,7 @@ Sugar over `generateObject`: one of `options`, chosen by the model.
619
619
  #### `ai.embed`
620
620
 
621
621
  ```ts
622
- ai.embed(req: { input: string | string[]; model?: string | undefined; }): Promise<{ embeddings: number[][]; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }>
622
+ ai.embed(req: { input: string | string[]; model?: string | undefined; }): Promise<{ embeddings: number[][]; usage: { credits: number; }; }>
623
623
  ```
624
624
 
625
625
  Embedding vectors for one or more texts.
@@ -627,7 +627,7 @@ Embedding vectors for one or more texts.
627
627
  #### `ai.image.generate`
628
628
 
629
629
  ```ts
630
- ai.image.generate(req: { prompt: string; model?: string | undefined; aspectRatio?: string | undefined; resolution?: '1K' | '2K' | '4K' | '512' | undefined; quality?: string | undefined; outputFormat?: 'png' | 'jpeg' | 'webp' | undefined; background?: string | undefined; n?: number | undefined; references?: string[] | undefined; fileName?: string | undefined; store?: boolean | undefined; }): Promise<{ images: { key: string; url: string; mediaType: string; width?: number | undefined; height?: number | undefined; }[]; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; fileName?: string | undefined; imageUrl?: string | undefined; }>
630
+ ai.image.generate(req: { prompt: string; model?: string | undefined; aspectRatio?: string | undefined; resolution?: '1K' | '2K' | '4K' | '512' | undefined; quality?: string | undefined; outputFormat?: 'png' | 'jpeg' | 'webp' | undefined; background?: string | undefined; n?: number | undefined; references?: string[] | undefined; fileName?: string | undefined; store?: boolean | undefined; }): Promise<{ images: { key: string; url: string; mediaType: string; width?: number | undefined; height?: number | undefined; }[]; usage: { credits: number; }; fileName?: string | undefined; imageUrl?: string | undefined; }>
631
631
  ```
632
632
 
633
633
  Images from a prompt; `store: true` keeps them as project files.
@@ -635,7 +635,7 @@ Images from a prompt; `store: true` keeps them as project files.
635
635
  #### `ai.image.edit`
636
636
 
637
637
  ```ts
638
- ai.image.edit(req: { prompt: string; images: string[]; mask?: string | undefined; fileName?: string | undefined; size?: string | undefined; quality?: string | undefined; outputFormat?: 'png' | 'jpeg' | 'webp' | undefined; background?: string | undefined; inputFidelity?: string | undefined; }): Promise<{ images: { key: string; url: string; mediaType: string; width?: number | undefined; height?: number | undefined; }[]; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; fileName?: string | undefined; imageUrl?: string | undefined; }>
638
+ ai.image.edit(req: { prompt: string; images: string[]; mask?: string | undefined; fileName?: string | undefined; size?: string | undefined; quality?: string | undefined; outputFormat?: 'png' | 'jpeg' | 'webp' | undefined; background?: string | undefined; inputFidelity?: string | undefined; }): Promise<{ images: { key: string; url: string; mediaType: string; width?: number | undefined; height?: number | undefined; }[]; usage: { credits: number; }; fileName?: string | undefined; imageUrl?: string | undefined; }>
639
639
  ```
640
640
 
641
641
  An image edited by a prompt.
@@ -651,7 +651,7 @@ ai.video.generate(req: { prompt: string; durationSec: number; model?: string | u
651
651
  #### `ai.video.get`
652
652
 
653
653
  ```ts
654
- ai.video.get(jobId: string): Promise<{ jobId: string; status: 'expired' | 'completed' | 'queued' | 'running' | 'failed' | 'cancelled'; 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; }>
654
+ ai.video.get(jobId: string): Promise<{ jobId: string; status: 'expired' | 'completed' | 'queued' | 'running' | 'failed' | 'cancelled'; progress?: number | undefined; video?: { key: string; url: string; } | undefined; usage?: { credits: number; } | undefined; error?: { code: string; message: string; } | undefined; }>
655
655
  ```
656
656
 
657
657
  The video job: `status`, and the stored clip once completed.
@@ -659,7 +659,7 @@ The video job: `status`, and the stored clip once completed.
659
659
  #### `ai.video.wait`
660
660
 
661
661
  ```ts
662
- ai.video.wait(jobId: string, opts?: { intervalMs?: number | undefined; timeoutMs?: number | undefined; }): Promise<{ jobId: string; status: 'expired' | 'completed' | 'queued' | 'running' | 'failed' | 'cancelled'; 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; }>
662
+ ai.video.wait(jobId: string, opts?: { intervalMs?: number | undefined; timeoutMs?: number | undefined; }): Promise<{ jobId: string; status: 'expired' | 'completed' | 'queued' | 'running' | 'failed' | 'cancelled'; progress?: number | undefined; video?: { key: string; url: string; } | undefined; usage?: { credits: number; } | undefined; error?: { code: string; message: string; } | undefined; }>
663
663
  ```
664
664
 
665
665
  ⚠ NODE-ONLY: polls `get(jobId)` until the job leaves `queued`/`running` (default every 5 s, at most 45 min —
@@ -669,7 +669,7 @@ In a Worker it throws `NODE_ONLY` — store the `jobId` and read `get(jobId)` la
669
669
  #### `ai.vision.describe`
670
670
 
671
671
  ```ts
672
- ai.vision.describe(req: { image: string; prompt?: string | undefined; model?: string | undefined; }): Promise<{ text: string; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }>
672
+ ai.vision.describe(req: { image: string; prompt?: string | undefined; model?: string | undefined; }): Promise<{ text: string; usage: { credits: number; }; }>
673
673
  ```
674
674
 
675
675
  A text description of an image (URL, data URL or project file key).
@@ -677,8 +677,8 @@ A text description of an image (URL, data URL or project file key).
677
677
  #### `ai.speech.speak`
678
678
 
679
679
  ```ts
680
- ai.speech.speak(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; } & { store: true; }): Promise<{ key: string; url: string; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; }>
681
- ai.speech.speak(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; }): Promise<{ key: string; url: string; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; } | SpeechAudio>
680
+ ai.speech.speak(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; } & { store: true; }): Promise<{ key: string; url: string; usage: { credits: number; }; }>
681
+ ai.speech.speak(input: { text: string; voice?: string | undefined; language?: string | undefined; model?: 'standard' | 'premium' | undefined; format?: 'mp3' | 'wav' | 'opus' | undefined; speed?: number | undefined; store?: boolean | undefined; }): Promise<{ key: string; url: string; usage: { credits: number; }; } | SpeechAudio>
682
682
  ```
683
683
 
684
684
  **Deprecated.** Since 1.0.0: use `totalum.speech.synthesize` (the same call).
@@ -686,7 +686,7 @@ ai.speech.speak(input: { text: string; voice?: string | undefined; language?: st
686
686
  #### `ai.speech.transcribe`
687
687
 
688
688
  ```ts
689
- ai.speech.transcribe(input: { audioBase64?: string | undefined; filename?: string | undefined; url?: string | undefined; language?: string | undefined; model?: 'fast' | 'accurate' | undefined; diarize?: boolean | undefined; timestamps?: 'word' | 'segment' | undefined; keyterms?: string[] | undefined; }): Promise<{ text: string; durationSec: number; usage: { credits: number; vendor?: string | undefined; units?: number | undefined; vendorCostUsd?: number | undefined; }; language?: string | undefined; segments?: { start: number; end: number; text: string; }[] | undefined; words?: { word: string; start: number; end: number; }[] | undefined; }>
689
+ ai.speech.transcribe(input: { audioBase64?: string | undefined; filename?: string | undefined; url?: string | undefined; language?: string | undefined; model?: 'fast' | 'accurate' | undefined; diarize?: boolean | undefined; timestamps?: 'word' | 'segment' | undefined; keyterms?: string[] | undefined; }): Promise<{ text: string; durationSec: number; usage: { credits: number; }; language?: string | undefined; segments?: { start: number; end: number; text: string; }[] | undefined; words?: { word: string; start: number; end: number; }[] | undefined; }>
690
690
  ```
691
691
 
692
692
  **Deprecated.** Since 1.0.0: use `totalum.speech.transcribe` (the same call).
@@ -705,7 +705,7 @@ Each preset's current model and the models a project may call, with their prices
705
705
  ai.gatewayConfig(): { baseURL: string; apiKey: string; }
706
706
  ```
707
707
 
708
- The exact OpenRouter API for any OpenRouter/OpenAI client: `new OpenAI(ai.gatewayConfig())`. Server-side only.
708
+ The OpenAI-compatible API for any OpenAI-compatible client: `new OpenAI(ai.gatewayConfig())`. Server-side only.
709
709
 
710
710
  ## `totalum-sdk/email`
711
711
 
@@ -721,7 +721,7 @@ per recipient. On dev only allow-listed recipients are accepted (`DEV_RECIPIENT_
721
721
  #### `email.send`
722
722
 
723
723
  ```ts
724
- email.send(msg: { to: string | string[]; subject: string; html?: string | undefined; text?: string | undefined; from?: { name?: string | undefined; localPart?: string | undefined; domain?: string | undefined; } | undefined; replyTo?: string | string[] | undefined; cc?: string | string[] | undefined; bcc?: string | string[] | undefined; headers?: Record<string, string> | undefined; attachments?: { filename: string; url?: string | undefined; content?: string | undefined; contentType?: string | undefined; }[] | undefined; tags?: { name: string; value: string; }[] | undefined; scheduledAt?: string | undefined; idempotencyKey?: string | undefined; bulk?: boolean | undefined; }): Promise<{ success: true; message: 'Email sent successfully'; messageId: string; id: string; status: 'queued' | 'sent'; } & { usage: { vendor?: string | undefined; units?: number | undefined; credits: number; }; }>
724
+ email.send(msg: { to: string | string[]; subject: string; html?: string | undefined; text?: string | undefined; from?: { name?: string | undefined; localPart?: string | undefined; domain?: string | undefined; } | undefined; replyTo?: string | string[] | undefined; cc?: string | string[] | undefined; bcc?: string | string[] | undefined; headers?: Record<string, string> | undefined; attachments?: { filename: string; url?: string | undefined; content?: string | undefined; contentType?: string | undefined; }[] | undefined; tags?: { name: string; value: string; }[] | undefined; scheduledAt?: string | undefined; idempotencyKey?: string | undefined; bulk?: boolean | undefined; }): Promise<Omit<{ success: true; message: 'Email sent successfully'; messageId: string; id: string; status: 'queued' | 'sent'; }, 'usage'> & { usage: Usage; }>
725
725
  ```
726
726
 
727
727
  Sends one e-mail (HTML byte for byte); charged per recipient (`usage.credits`).
@@ -1127,7 +1127,7 @@ type RealtimeChannelOptions = {
1127
1127
  type ScanDocumentResult = {
1128
1128
  data: Record<string, unknown> | Record<string, unknown>[];
1129
1129
  metadata: { usageUnits: number; exactUsageUnits: number; pages: number; provider: string; credits: number; };
1130
- usage: { credits: number; vendor?: string | undefined; units?: number | undefined; };
1130
+ usage: Usage;
1131
1131
  }
1132
1132
  ```
1133
1133
 
@@ -1167,7 +1167,7 @@ type SpeechAudio = {
1167
1167
 
1168
1168
  ```ts
1169
1169
  type TotalumAiOptions = {
1170
- /** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
1170
+ /** The OpenAI-compatible AI gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
1171
1171
  aiBaseUrl?: string;
1172
1172
  /** Project key `tlm_pk_…`; default `TOTALUM_PROJECT_KEY`. Server-side only. */
1173
1173
  key?: string;
@@ -1231,7 +1231,7 @@ type TotalumFilesOptions = {
1231
1231
 
1232
1232
  ```ts
1233
1233
  type TotalumOptions = {
1234
- /** The exact-OpenRouter gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
1234
+ /** The OpenAI-compatible AI gateway `gatewayConfig()` returns; default `TOTALUM_AI_BASE_URL`, else `https://ai.totalum.app/api/v1`. */
1235
1235
  aiBaseUrl?: string;
1236
1236
  /** Project key `tlm_pk_…`; default `TOTALUM_PROJECT_KEY`. Server-side only. */
1237
1237
  key?: string;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.9.0",
2
+ "version": "1.10.0",
3
3
  "methods": [
4
4
  {
5
5
  "call": "totalum.files.upload(input, { name?, contentType?, private?, folder? })",
@@ -128,11 +128,11 @@
128
128
  },
129
129
  {
130
130
  "call": "totalum.pdf.fromHtml({ name, html?, base64HtmlString?, options?, waitForSelector? })",
131
- "returns": "{ url, fileName, key, usage }"
131
+ "returns": "{ key, fileName, url, usage }"
132
132
  },
133
133
  {
134
134
  "call": "totalum.pdf.fromUrl({ url, name, options?, cookies?, headers? })",
135
- "returns": "{ url, fileName, key, usage }"
135
+ "returns": "{ key, fileName, url, usage }"
136
136
  },
137
137
  {
138
138
  "call": "totalum.scan.document({ properties, options?, fileName?, key?, url? })",
@@ -140,7 +140,7 @@
140
140
  },
141
141
  {
142
142
  "call": "totalum.scan.ocr({ pages?, fileName?, key?, url? })",
143
- "returns": "{ text, pages, fullDetails?, usage }"
143
+ "returns": "{ pages, text, fullDetails?, usage }"
144
144
  },
145
145
  {
146
146
  "call": "totalum.vectors.upsert(vectors)",
@@ -243,7 +243,7 @@
243
243
  },
244
244
  {
245
245
  "call": "totalum.email.send({ to, subject, html?, text?, from?, replyTo?, cc?, bcc?, headers?, attachments?, tags?, scheduledAt?, idempotencyKey?, bulk? })",
246
- "returns": "{ success, message, messageId, id, status: 'queued' | 'sent', usage }"
246
+ "returns": "{ id, status: 'queued' | 'sent', message, success, messageId, usage }"
247
247
  },
248
248
  {
249
249
  "call": "totalum.email.get(id)",
@@ -1,42 +0,0 @@
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-WcXvShIX.js';
2
-
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
- */
8
- declare const IntegrationUsage: ZodObject<{
9
- credits: ZodNumber;
10
- vendor: ZodOptional<ZodString>;
11
- units: ZodOptional<ZodNumber>;
12
- vendorCostUsd: ZodOptional<ZodNumber>;
13
- }, $strip>;
14
- type IntegrationUsage = output<typeof IntegrationUsage>;
15
- /** The delivery body: `{id, type, createdAt, projectId, env, livemode?, data}`, idempotent by `id`. */
16
- declare const WebhookEvent: ZodObject<{
17
- id: ZodString;
18
- type: ZodString;
19
- createdAt: ZodISODateTime;
20
- projectId: ZodString;
21
- env: ZodEnum<{
22
- dev: "dev";
23
- live: "live";
24
- }>;
25
- livemode: ZodOptional<ZodBoolean>;
26
- data: ZodRecord<ZodString, ZodUnknown>;
27
- }, $strip>;
28
- type WebhookEvent = output<typeof WebhookEvent>;
29
- /** `GET|PUT /v1/webhooks`: the secret itself is shown only by `POST /v1/webhooks/rotate-secret`. */
30
- declare const WebhookConfig: ZodObject<{
31
- url: ZodNullable<ZodURL>;
32
- enabled: ZodBoolean;
33
- secretPrefix: ZodNullable<ZodString>;
34
- }, $strip>;
35
- type WebhookConfig = output<typeof WebhookConfig>;
36
- /** `POST /v1/webhooks/rotate-secret`: a new signing secret, revealed once (`whsec_` + 64 hex). */
37
- declare const WebhookSecretOutput: ZodObject<{
38
- secret: ZodString;
39
- }, $strip>;
40
- type WebhookSecretOutput = output<typeof WebhookSecretOutput>;
41
-
42
- export { IntegrationUsage as I, WebhookConfig as W, WebhookEvent as a, WebhookSecretOutput as b };