@openrouter/ai-sdk-provider 1.5.2 → 1.5.4

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.mts CHANGED
@@ -2,8 +2,6 @@ import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, La
2
2
  export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
3
3
  import * as models from '@openrouter/sdk/models';
4
4
  import { z } from 'zod/v4';
5
- import { EncodeOptions, DecodeOptions, JsonValue } from '@toon-format/toon';
6
- export { DecodeOptions, EncodeOptions, JsonValue } from '@toon-format/toon';
7
5
 
8
6
  type OpenRouterChatModelId = string;
9
7
  type OpenRouterChatSettings = {
@@ -551,84 +549,4 @@ declare class OpenRouter {
551
549
  embedding(modelId: OpenRouterEmbeddingModelId, settings?: OpenRouterEmbeddingSettings): OpenRouterEmbeddingModel;
552
550
  }
553
551
 
554
- /**
555
- * TOON (Token-Oriented Object Notation) helper utilities for token-efficient
556
- * data encoding in LLM prompts.
557
- *
558
- * TOON achieves ~40% token reduction vs JSON for tabular data while maintaining
559
- * high LLM comprehension accuracy.
560
- *
561
- * @see https://toonformat.dev
562
- * @see https://github.com/toon-format/toon
563
- *
564
- * @example
565
- * ```ts
566
- * import { encodeToon, decodeToon } from '@openrouter/ai-sdk-provider';
567
- *
568
- * // Encode data to TOON format
569
- * const toon = await encodeToon([
570
- * { id: 1, name: 'Alice', score: 95 },
571
- * { id: 2, name: 'Bob', score: 87 },
572
- * ]);
573
- * // Result: [2]{id,name,score}: 1,Alice,95 2,Bob,87
574
- *
575
- * // Decode TOON back to JSON
576
- * const data = await decodeToon(toon);
577
- * ```
578
- */
579
-
580
- type ToonEncodeOptions = EncodeOptions;
581
- type ToonDecodeOptions = DecodeOptions;
582
- /**
583
- * Encodes a JavaScript value into TOON format string.
584
- *
585
- * TOON is particularly efficient for uniform arrays of objects (tabular data),
586
- * achieving CSV-like compactness while preserving explicit structure.
587
- *
588
- * @param value - Any JavaScript value (objects, arrays, primitives)
589
- * @param options - Optional encoding configuration
590
- * @returns Promise resolving to TOON formatted string
591
- *
592
- * @example
593
- * ```ts
594
- * // Simple object
595
- * await encodeToon({ name: 'Alice', age: 30 });
596
- * // name: Alice
597
- * // age: 30
598
- *
599
- * // Tabular array (most efficient)
600
- * await encodeToon([
601
- * { id: 1, name: 'Alice' },
602
- * { id: 2, name: 'Bob' },
603
- * ]);
604
- * // [2]{id,name}: 1,Alice 2,Bob
605
- *
606
- * // With options
607
- * await encodeToon(data, { indent: 4, keyFolding: 'safe' });
608
- * ```
609
- */
610
- declare function encodeToon(value: unknown, options?: ToonEncodeOptions): Promise<string>;
611
- /**
612
- * Decodes a TOON format string into a JavaScript value.
613
- *
614
- * @param input - TOON formatted string
615
- * @param options - Optional decoding configuration
616
- * @returns Promise resolving to parsed JavaScript value
617
- *
618
- * @example
619
- * ```ts
620
- * // Decode simple object
621
- * await decodeToon('name: Alice\nage: 30');
622
- * // { name: 'Alice', age: 30 }
623
- *
624
- * // Decode tabular array
625
- * await decodeToon('[2]{id,name}: 1,Alice 2,Bob');
626
- * // [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
627
- *
628
- * // With options
629
- * await decodeToon(toonString, { strict: false, expandPaths: 'safe' });
630
- * ```
631
- */
632
- declare function decodeToon(input: string, options?: ToonDecodeOptions): Promise<JsonValue>;
633
-
634
- export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, type ToonDecodeOptions, type ToonEncodeOptions, createOpenRouter, decodeToon, encodeToon, openrouter };
552
+ export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, createOpenRouter, openrouter };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,6 @@ import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, La
2
2
  export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
3
3
  import * as models from '@openrouter/sdk/models';
4
4
  import { z } from 'zod/v4';
5
- import { EncodeOptions, DecodeOptions, JsonValue } from '@toon-format/toon';
6
- export { DecodeOptions, EncodeOptions, JsonValue } from '@toon-format/toon';
7
5
 
8
6
  type OpenRouterChatModelId = string;
9
7
  type OpenRouterChatSettings = {
@@ -551,84 +549,4 @@ declare class OpenRouter {
551
549
  embedding(modelId: OpenRouterEmbeddingModelId, settings?: OpenRouterEmbeddingSettings): OpenRouterEmbeddingModel;
552
550
  }
553
551
 
554
- /**
555
- * TOON (Token-Oriented Object Notation) helper utilities for token-efficient
556
- * data encoding in LLM prompts.
557
- *
558
- * TOON achieves ~40% token reduction vs JSON for tabular data while maintaining
559
- * high LLM comprehension accuracy.
560
- *
561
- * @see https://toonformat.dev
562
- * @see https://github.com/toon-format/toon
563
- *
564
- * @example
565
- * ```ts
566
- * import { encodeToon, decodeToon } from '@openrouter/ai-sdk-provider';
567
- *
568
- * // Encode data to TOON format
569
- * const toon = await encodeToon([
570
- * { id: 1, name: 'Alice', score: 95 },
571
- * { id: 2, name: 'Bob', score: 87 },
572
- * ]);
573
- * // Result: [2]{id,name,score}: 1,Alice,95 2,Bob,87
574
- *
575
- * // Decode TOON back to JSON
576
- * const data = await decodeToon(toon);
577
- * ```
578
- */
579
-
580
- type ToonEncodeOptions = EncodeOptions;
581
- type ToonDecodeOptions = DecodeOptions;
582
- /**
583
- * Encodes a JavaScript value into TOON format string.
584
- *
585
- * TOON is particularly efficient for uniform arrays of objects (tabular data),
586
- * achieving CSV-like compactness while preserving explicit structure.
587
- *
588
- * @param value - Any JavaScript value (objects, arrays, primitives)
589
- * @param options - Optional encoding configuration
590
- * @returns Promise resolving to TOON formatted string
591
- *
592
- * @example
593
- * ```ts
594
- * // Simple object
595
- * await encodeToon({ name: 'Alice', age: 30 });
596
- * // name: Alice
597
- * // age: 30
598
- *
599
- * // Tabular array (most efficient)
600
- * await encodeToon([
601
- * { id: 1, name: 'Alice' },
602
- * { id: 2, name: 'Bob' },
603
- * ]);
604
- * // [2]{id,name}: 1,Alice 2,Bob
605
- *
606
- * // With options
607
- * await encodeToon(data, { indent: 4, keyFolding: 'safe' });
608
- * ```
609
- */
610
- declare function encodeToon(value: unknown, options?: ToonEncodeOptions): Promise<string>;
611
- /**
612
- * Decodes a TOON format string into a JavaScript value.
613
- *
614
- * @param input - TOON formatted string
615
- * @param options - Optional decoding configuration
616
- * @returns Promise resolving to parsed JavaScript value
617
- *
618
- * @example
619
- * ```ts
620
- * // Decode simple object
621
- * await decodeToon('name: Alice\nage: 30');
622
- * // { name: 'Alice', age: 30 }
623
- *
624
- * // Decode tabular array
625
- * await decodeToon('[2]{id,name}: 1,Alice 2,Bob');
626
- * // [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
627
- *
628
- * // With options
629
- * await decodeToon(toonString, { strict: false, expandPaths: 'safe' });
630
- * ```
631
- */
632
- declare function decodeToon(input: string, options?: ToonDecodeOptions): Promise<JsonValue>;
633
-
634
- export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, type ToonDecodeOptions, type ToonEncodeOptions, createOpenRouter, decodeToon, encodeToon, openrouter };
552
+ export { OpenRouter, type OpenRouterChatSettings, type OpenRouterCompletionSettings, type OpenRouterEmbeddingModelId, type OpenRouterEmbeddingSettings, type OpenRouterProvider, type OpenRouterProviderOptions, type OpenRouterProviderSettings, type OpenRouterSharedSettings, type OpenRouterUsageAccounting, createOpenRouter, openrouter };
package/dist/index.js CHANGED
@@ -49,8 +49,6 @@ var index_exports = {};
49
49
  __export(index_exports, {
50
50
  OpenRouter: () => OpenRouter,
51
51
  createOpenRouter: () => createOpenRouter,
52
- decodeToon: () => decodeToon,
53
- encodeToon: () => encodeToon,
54
52
  openrouter: () => openrouter
55
53
  });
56
54
  module.exports = __toCommonJS(index_exports);
@@ -1025,10 +1023,10 @@ var FileAnnotationSchema = import_v43.z.object({
1025
1023
  import_v43.z.object({
1026
1024
  type: import_v43.z.string(),
1027
1025
  text: import_v43.z.string().optional()
1028
- }).passthrough()
1026
+ }).catchall(import_v43.z.any())
1029
1027
  ).optional()
1030
- }).passthrough()
1031
- });
1028
+ }).catchall(import_v43.z.any())
1029
+ }).catchall(import_v43.z.any());
1032
1030
  var OpenRouterProviderMetadataSchema = import_v43.z.object({
1033
1031
  provider: import_v43.z.string(),
1034
1032
  reasoning_details: import_v43.z.array(ReasoningDetailUnionSchema).optional(),
@@ -1037,18 +1035,18 @@ var OpenRouterProviderMetadataSchema = import_v43.z.object({
1037
1035
  promptTokens: import_v43.z.number(),
1038
1036
  promptTokensDetails: import_v43.z.object({
1039
1037
  cachedTokens: import_v43.z.number()
1040
- }).passthrough().optional(),
1038
+ }).catchall(import_v43.z.any()).optional(),
1041
1039
  completionTokens: import_v43.z.number(),
1042
1040
  completionTokensDetails: import_v43.z.object({
1043
1041
  reasoningTokens: import_v43.z.number()
1044
- }).passthrough().optional(),
1042
+ }).catchall(import_v43.z.any()).optional(),
1045
1043
  totalTokens: import_v43.z.number(),
1046
1044
  cost: import_v43.z.number().optional(),
1047
1045
  costDetails: import_v43.z.object({
1048
1046
  upstreamInferenceCost: import_v43.z.number()
1049
- }).passthrough().optional()
1050
- }).passthrough()
1051
- }).passthrough();
1047
+ }).catchall(import_v43.z.any()).optional()
1048
+ }).catchall(import_v43.z.any())
1049
+ }).catchall(import_v43.z.any());
1052
1050
  var OpenRouterProviderOptionsSchema = import_v43.z.object({
1053
1051
  openrouter: import_v43.z.object({
1054
1052
  reasoning_details: import_v43.z.array(ReasoningDetailUnionSchema).optional(),
@@ -1966,6 +1964,7 @@ var OpenRouterChatLanguageModel = class {
1966
1964
  };
1967
1965
  const openrouterUsage = {};
1968
1966
  const accumulatedReasoningDetails = [];
1967
+ const accumulatedFileAnnotations = [];
1969
1968
  let textStarted = false;
1970
1969
  let reasoningStarted = false;
1971
1970
  let textId;
@@ -2144,6 +2143,13 @@ var OpenRouterChatLanguageModel = class {
2144
2143
  }
2145
2144
  }
2146
2145
  });
2146
+ } else if (annotation.type === "file") {
2147
+ const file = annotation.file;
2148
+ if (file && typeof file === "object" && "hash" in file && "name" in file) {
2149
+ accumulatedFileAnnotations.push(
2150
+ annotation
2151
+ );
2152
+ }
2147
2153
  }
2148
2154
  }
2149
2155
  }
@@ -2319,6 +2325,9 @@ var OpenRouterChatLanguageModel = class {
2319
2325
  if (accumulatedReasoningDetails.length > 0) {
2320
2326
  openrouterMetadata.reasoning_details = accumulatedReasoningDetails;
2321
2327
  }
2328
+ if (accumulatedFileAnnotations.length > 0) {
2329
+ openrouterMetadata.annotations = accumulatedFileAnnotations;
2330
+ }
2322
2331
  controller.enqueue({
2323
2332
  type: "finish",
2324
2333
  finishReason,
@@ -2870,7 +2879,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
2870
2879
  }
2871
2880
 
2872
2881
  // src/version.ts
2873
- var VERSION = false ? "0.0.0-test" : "1.5.2";
2882
+ var VERSION = false ? "0.0.0-test" : "1.5.4";
2874
2883
 
2875
2884
  // src/provider.ts
2876
2885
  function createOpenRouter(options = {}) {
@@ -2938,31 +2947,10 @@ var openrouter = createOpenRouter({
2938
2947
  compatibility: "strict"
2939
2948
  // strict for OpenRouter API
2940
2949
  });
2941
-
2942
- // src/toon/index.ts
2943
- async function getToonModule() {
2944
- try {
2945
- return await import("@toon-format/toon");
2946
- } catch (e) {
2947
- throw new Error(
2948
- "The @toon-format/toon package is required for TOON encoding/decoding. Install it with: npm install @toon-format/toon"
2949
- );
2950
- }
2951
- }
2952
- async function encodeToon(value, options) {
2953
- const toon = await getToonModule();
2954
- return toon.encode(value, options);
2955
- }
2956
- async function decodeToon(input, options) {
2957
- const toon = await getToonModule();
2958
- return toon.decode(input, options);
2959
- }
2960
2950
  // Annotate the CommonJS export names for ESM import in node:
2961
2951
  0 && (module.exports = {
2962
2952
  OpenRouter,
2963
2953
  createOpenRouter,
2964
- decodeToon,
2965
- encodeToon,
2966
2954
  openrouter
2967
2955
  });
2968
2956
  //# sourceMappingURL=index.js.map