@broberg/ai-sdk 0.25.1 → 0.26.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/dist/index.d.ts CHANGED
@@ -1697,7 +1697,10 @@ declare const aiConfigSchema: z.ZodObject<{
1697
1697
  transport: "http" | "subprocess";
1698
1698
  }>>>;
1699
1699
  providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<ProviderAdapter, z.ZodTypeDef, ProviderAdapter>>>;
1700
- costSink: z.ZodOptional<z.ZodType<CostSink, z.ZodTypeDef, CostSink>>;
1700
+ /** Omit → cost-tracking auto-wires from the upmetrics env (F034). Pass `null`
1701
+ * to opt OUT explicitly — for a consumer that already reports its own costs
1702
+ * and would otherwise be counted twice (F034.3). An object is used as-is. */
1703
+ costSink: z.ZodOptional<z.ZodNullable<z.ZodType<CostSink, z.ZodTypeDef, CostSink>>>;
1701
1704
  budget: z.ZodOptional<z.ZodObject<{
1702
1705
  perCallUsd: z.ZodOptional<z.ZodNumber>;
1703
1706
  rollingUsd: z.ZodOptional<z.ZodNumber>;
@@ -1725,7 +1728,7 @@ declare const aiConfigSchema: z.ZodObject<{
1725
1728
  transport: "http" | "subprocess";
1726
1729
  }>> | undefined;
1727
1730
  providers?: Record<string, ProviderAdapter> | undefined;
1728
- costSink?: CostSink | undefined;
1731
+ costSink?: CostSink | null | undefined;
1729
1732
  budget?: {
1730
1733
  perCallUsd?: number | undefined;
1731
1734
  rollingUsd?: number | undefined;
@@ -1741,7 +1744,7 @@ declare const aiConfigSchema: z.ZodObject<{
1741
1744
  transport: "http" | "subprocess";
1742
1745
  }>> | undefined;
1743
1746
  providers?: Record<string, ProviderAdapter> | undefined;
1744
- costSink?: CostSink | undefined;
1747
+ costSink?: CostSink | null | undefined;
1745
1748
  budget?: {
1746
1749
  perCallUsd?: number | undefined;
1747
1750
  rollingUsd?: number | undefined;
@@ -2045,8 +2048,8 @@ declare const falStubAdapter: ProviderAdapter;
2045
2048
  * wires the live adapters. */
2046
2049
  declare const stubProviders: Record<string, ProviderAdapter>;
2047
2050
 
2048
- declare const VERSION: "0.25.1";
2049
- declare const SDK_TAG: "@broberg/ai-sdk@0.25.1";
2051
+ declare const VERSION: "0.26.0";
2052
+ declare const SDK_TAG: "@broberg/ai-sdk@0.26.0";
2050
2053
 
2051
2054
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
2052
2055
  * per-call override.
package/dist/index.js CHANGED
@@ -2601,14 +2601,17 @@ var aiConfigSchema = z.object({
2601
2601
  // Functions can't be deeply validated — z.custom asserts the TS type and
2602
2602
  // passes the value through untouched.
2603
2603
  providers: z.record(z.string(), z.custom()).optional(),
2604
- costSink: z.custom().optional(),
2604
+ /** Omit → cost-tracking auto-wires from the upmetrics env (F034). Pass `null`
2605
+ * to opt OUT explicitly — for a consumer that already reports its own costs
2606
+ * and would otherwise be counted twice (F034.3). An object is used as-is. */
2607
+ costSink: z.custom().nullable().optional(),
2605
2608
  budget: budgetSchema.optional(),
2606
2609
  availability: availabilitySchema.optional()
2607
2610
  });
2608
2611
 
2609
2612
  // src/version.ts
2610
- var VERSION = "0.25.1";
2611
- var SDK_TAG = "@broberg/ai-sdk@0.25.1";
2613
+ var VERSION = "0.26.0";
2614
+ var SDK_TAG = "@broberg/ai-sdk@0.26.0";
2612
2615
 
2613
2616
  // src/cost/sinks/upmetrics.ts
2614
2617
  function upmetricsSink(config) {
@@ -2728,7 +2731,7 @@ function defaultCostSink() {
2728
2731
  function createAI(config = {}) {
2729
2732
  const cfg = aiConfigSchema.parse(config);
2730
2733
  const providers = cfg.providers ?? defaultProviders;
2731
- const costSink = cfg.costSink ?? defaultCostSink();
2734
+ const costSink = cfg.costSink === void 0 ? defaultCostSink() : cfg.costSink ?? void 0;
2732
2735
  const budget = cfg.budget ? new BudgetGuard(cfg.budget) : void 0;
2733
2736
  const estTokens = (s) => Math.ceil(s.length / 4);
2734
2737
  async function preflight(spec, estInTokens, estOutTokens) {