@broberg/ai-sdk 0.25.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1353,7 +1353,9 @@ declare const transcribeInputSchema: z.ZodObject<{
1353
1353
  /** Bias toward brand/jargon terms (Azure phraseList, F029.3); others ignore it. */
1354
1354
  phrases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1355
1355
  /** Opt-in timestamps (F036) — a single granularity or an array. Omit → the
1356
- * current { text, usage } shape, unchanged. Pass ["word","segment"] for both. */
1356
+ * current { text, usage } shape, unchanged. Pass ["word","segment"] for both.
1357
+ * Supported by Whisper (openai) + Azure fast-transcription (F036.1); other
1358
+ * adapters (Voxtral/mistral) ignore it and return text only. */
1357
1359
  timestamps: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["word", "segment"]>, z.ZodArray<z.ZodEnum<["word", "segment"]>, "many">]>>;
1358
1360
  }, "strip", z.ZodTypeAny, {
1359
1361
  audio: string | Uint8Array<ArrayBuffer>;
@@ -2043,8 +2045,8 @@ declare const falStubAdapter: ProviderAdapter;
2043
2045
  * wires the live adapters. */
2044
2046
  declare const stubProviders: Record<string, ProviderAdapter>;
2045
2047
 
2046
- declare const VERSION: "0.25.0";
2047
- declare const SDK_TAG: "@broberg/ai-sdk@0.25.0";
2048
+ declare const VERSION: "0.25.1";
2049
+ declare const SDK_TAG: "@broberg/ai-sdk@0.25.1";
2048
2050
 
2049
2051
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2050
2052
  * per-call override.
package/dist/index.js CHANGED
@@ -1534,7 +1534,26 @@ function azureAdapter(config = {}) {
1534
1534
  outputTokens: 0
1535
1535
  });
1536
1536
  usage.costUsd = minutes * (config.sttPricePerMin ?? AZURE_STT_PRICE_PER_MIN);
1537
- return { text, usage };
1537
+ const result = { text, usage };
1538
+ if (req.timestamps && req.timestamps.length > 0 && data.phrases) {
1539
+ const toSec = (ms) => (ms ?? 0) / 1e3;
1540
+ if (req.timestamps.includes("word")) {
1541
+ const words = data.phrases.flatMap((p) => p.words ?? []);
1542
+ if (words.length > 0) {
1543
+ result.words = words.map((w) => ({
1544
+ word: w.text ?? "",
1545
+ start: toSec(w.offsetMilliseconds),
1546
+ end: toSec((w.offsetMilliseconds ?? 0) + (w.durationMilliseconds ?? 0))
1547
+ }));
1548
+ }
1549
+ }
1550
+ result.segments = data.phrases.map((p) => ({
1551
+ text: p.text ?? "",
1552
+ start: toSec(p.offsetMilliseconds),
1553
+ end: toSec((p.offsetMilliseconds ?? 0) + (p.durationMilliseconds ?? 0))
1554
+ }));
1555
+ }
1556
+ return result;
1538
1557
  }
1539
1558
  return { name: "azure", tts, transcribe };
1540
1559
  }
@@ -2538,7 +2557,9 @@ var transcribeInputSchema = z.object({
2538
2557
  /** Bias toward brand/jargon terms (Azure phraseList, F029.3); others ignore it. */
2539
2558
  phrases: z.array(z.string()).optional(),
2540
2559
  /** Opt-in timestamps (F036) — a single granularity or an array. Omit → the
2541
- * current { text, usage } shape, unchanged. Pass ["word","segment"] for both. */
2560
+ * current { text, usage } shape, unchanged. Pass ["word","segment"] for both.
2561
+ * Supported by Whisper (openai) + Azure fast-transcription (F036.1); other
2562
+ * adapters (Voxtral/mistral) ignore it and return text only. */
2542
2563
  timestamps: z.union([z.enum(["word", "segment"]), z.array(z.enum(["word", "segment"]))]).optional(),
2543
2564
  ...callOptions
2544
2565
  });
@@ -2586,8 +2607,8 @@ var aiConfigSchema = z.object({
2586
2607
  });
2587
2608
 
2588
2609
  // src/version.ts
2589
- var VERSION = "0.25.0";
2590
- var SDK_TAG = "@broberg/ai-sdk@0.25.0";
2610
+ var VERSION = "0.25.1";
2611
+ var SDK_TAG = "@broberg/ai-sdk@0.25.1";
2591
2612
 
2592
2613
  // src/cost/sinks/upmetrics.ts
2593
2614
  function upmetricsSink(config) {