@llumiverse/common 1.2.0 → 1.4.0-dev.20260629.090753Z

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.
Files changed (184) hide show
  1. package/lib/capability/anthropic.d.ts +3 -0
  2. package/lib/capability/anthropic.d.ts.map +1 -0
  3. package/lib/capability/anthropic.js +92 -0
  4. package/lib/capability/anthropic.js.map +1 -0
  5. package/lib/{types/capability → capability}/azure_foundry.d.ts +1 -1
  6. package/lib/capability/azure_foundry.d.ts.map +1 -0
  7. package/lib/capability/azure_foundry.js +394 -0
  8. package/lib/capability/azure_foundry.js.map +1 -0
  9. package/lib/{types/capability → capability}/bedrock.d.ts +1 -1
  10. package/lib/capability/bedrock.d.ts.map +1 -0
  11. package/lib/capability/bedrock.js +300 -0
  12. package/lib/capability/bedrock.js.map +1 -0
  13. package/lib/{types/capability → capability}/openai.d.ts +1 -1
  14. package/lib/capability/openai.d.ts.map +1 -0
  15. package/lib/capability/openai.js +179 -0
  16. package/lib/capability/openai.js.map +1 -0
  17. package/lib/{types/capability → capability}/vertexai.d.ts +1 -1
  18. package/lib/capability/vertexai.d.ts.map +1 -0
  19. package/lib/capability/vertexai.js +137 -0
  20. package/lib/capability/vertexai.js.map +1 -0
  21. package/lib/{types/capability.d.ts → capability.d.ts} +1 -1
  22. package/lib/capability.d.ts.map +1 -0
  23. package/lib/{esm/capability.js → capability.js} +21 -15
  24. package/lib/capability.js.map +1 -0
  25. package/lib/index.d.ts +14 -0
  26. package/lib/index.d.ts.map +1 -0
  27. package/lib/index.js +14 -0
  28. package/lib/index.js.map +1 -0
  29. package/lib/options/anthropic.d.ts +16 -0
  30. package/lib/options/anthropic.d.ts.map +1 -0
  31. package/lib/options/anthropic.js +34 -0
  32. package/lib/options/anthropic.js.map +1 -0
  33. package/lib/{types/options → options}/azure_foundry.d.ts +14 -14
  34. package/lib/options/azure_foundry.d.ts.map +1 -0
  35. package/lib/{esm/options → options}/azure_foundry.js +126 -126
  36. package/lib/options/azure_foundry.js.map +1 -0
  37. package/lib/options/bedrock.d.ts +61 -0
  38. package/lib/options/bedrock.d.ts.map +1 -0
  39. package/lib/options/bedrock.js +489 -0
  40. package/lib/options/bedrock.js.map +1 -0
  41. package/lib/options/context-windows.d.ts.map +1 -0
  42. package/lib/options/context-windows.js.map +1 -0
  43. package/lib/options/embedding.d.ts +38 -0
  44. package/lib/options/embedding.d.ts.map +1 -0
  45. package/lib/options/embedding.js +77 -0
  46. package/lib/options/embedding.js.map +1 -0
  47. package/lib/{types/options → options}/fallback.d.ts +2 -2
  48. package/lib/options/fallback.d.ts.map +1 -0
  49. package/lib/options/fallback.js +65 -0
  50. package/lib/options/fallback.js.map +1 -0
  51. package/lib/{types/options → options}/groq.d.ts +2 -2
  52. package/lib/options/groq.d.ts.map +1 -0
  53. package/lib/options/groq.js +54 -0
  54. package/lib/options/groq.js.map +1 -0
  55. package/lib/options/openai.d.ts +40 -0
  56. package/lib/options/openai.d.ts.map +1 -0
  57. package/lib/options/openai.js +284 -0
  58. package/lib/options/openai.js.map +1 -0
  59. package/lib/{types/options → options}/shared-parsing.d.ts +1 -1
  60. package/lib/options/shared-parsing.d.ts.map +1 -0
  61. package/lib/{esm/options → options}/shared-parsing.js +14 -17
  62. package/lib/options/shared-parsing.js.map +1 -0
  63. package/lib/options/version-parsing.d.ts.map +1 -0
  64. package/lib/{esm/options → options}/version-parsing.js +15 -15
  65. package/lib/options/version-parsing.js.map +1 -0
  66. package/lib/{types/options → options}/vertexai.d.ts +18 -15
  67. package/lib/options/vertexai.d.ts.map +1 -0
  68. package/lib/options/vertexai.js +606 -0
  69. package/lib/options/vertexai.js.map +1 -0
  70. package/lib/{types/options.d.ts → options.d.ts} +1 -1
  71. package/lib/options.d.ts.map +1 -0
  72. package/lib/{esm/options.js → options.js} +10 -7
  73. package/lib/options.js.map +1 -0
  74. package/lib/{types/types.d.ts → types.d.ts} +161 -42
  75. package/lib/types.d.ts.map +1 -0
  76. package/lib/{esm/types.js → types.js} +28 -22
  77. package/lib/types.js.map +1 -0
  78. package/package.json +12 -34
  79. package/src/LlumiverseError.test.ts +18 -72
  80. package/src/capability/anthropic.ts +99 -0
  81. package/src/capability/azure_foundry.ts +303 -65
  82. package/src/capability/bedrock.ts +201 -56
  83. package/src/capability/openai.ts +135 -41
  84. package/src/capability/vertexai.ts +105 -35
  85. package/src/capability.ts +21 -16
  86. package/src/index.ts +13 -11
  87. package/src/options/anthropic.ts +59 -0
  88. package/src/options/azure_foundry.ts +157 -143
  89. package/src/options/bedrock.ts +266 -187
  90. package/src/options/context-windows.ts +2 -2
  91. package/src/options/embedding.ts +92 -0
  92. package/src/options/fallback.ts +50 -17
  93. package/src/options/groq.ts +48 -21
  94. package/src/options/openai.ts +231 -183
  95. package/src/options/shared-parsing.ts +16 -21
  96. package/src/options/version-parsing.ts +17 -17
  97. package/src/options/vertexai.ts +385 -288
  98. package/src/options.ts +11 -8
  99. package/src/types.ts +284 -160
  100. package/lib/cjs/capability/azure_foundry.js +0 -160
  101. package/lib/cjs/capability/azure_foundry.js.map +0 -1
  102. package/lib/cjs/capability/bedrock.js +0 -158
  103. package/lib/cjs/capability/bedrock.js.map +0 -1
  104. package/lib/cjs/capability/openai.js +0 -98
  105. package/lib/cjs/capability/openai.js.map +0 -1
  106. package/lib/cjs/capability/vertexai.js +0 -80
  107. package/lib/cjs/capability/vertexai.js.map +0 -1
  108. package/lib/cjs/capability.js +0 -109
  109. package/lib/cjs/capability.js.map +0 -1
  110. package/lib/cjs/index.js +0 -27
  111. package/lib/cjs/index.js.map +0 -1
  112. package/lib/cjs/options/azure_foundry.js +0 -423
  113. package/lib/cjs/options/azure_foundry.js.map +0 -1
  114. package/lib/cjs/options/bedrock.js +0 -427
  115. package/lib/cjs/options/bedrock.js.map +0 -1
  116. package/lib/cjs/options/context-windows.js +0 -138
  117. package/lib/cjs/options/context-windows.js.map +0 -1
  118. package/lib/cjs/options/fallback.js +0 -35
  119. package/lib/cjs/options/fallback.js.map +0 -1
  120. package/lib/cjs/options/groq.js +0 -37
  121. package/lib/cjs/options/groq.js.map +0 -1
  122. package/lib/cjs/options/openai.js +0 -246
  123. package/lib/cjs/options/openai.js.map +0 -1
  124. package/lib/cjs/options/shared-parsing.js +0 -144
  125. package/lib/cjs/options/shared-parsing.js.map +0 -1
  126. package/lib/cjs/options/version-parsing.js +0 -326
  127. package/lib/cjs/options/version-parsing.js.map +0 -1
  128. package/lib/cjs/options/vertexai.js +0 -525
  129. package/lib/cjs/options/vertexai.js.map +0 -1
  130. package/lib/cjs/options.js +0 -30
  131. package/lib/cjs/options.js.map +0 -1
  132. package/lib/cjs/package.json +0 -3
  133. package/lib/cjs/types.js +0 -299
  134. package/lib/cjs/types.js.map +0 -1
  135. package/lib/esm/capability/azure_foundry.js +0 -157
  136. package/lib/esm/capability/azure_foundry.js.map +0 -1
  137. package/lib/esm/capability/bedrock.js +0 -155
  138. package/lib/esm/capability/bedrock.js.map +0 -1
  139. package/lib/esm/capability/openai.js +0 -95
  140. package/lib/esm/capability/openai.js.map +0 -1
  141. package/lib/esm/capability/vertexai.js +0 -77
  142. package/lib/esm/capability/vertexai.js.map +0 -1
  143. package/lib/esm/capability.js.map +0 -1
  144. package/lib/esm/index.js +0 -11
  145. package/lib/esm/index.js.map +0 -1
  146. package/lib/esm/options/azure_foundry.js.map +0 -1
  147. package/lib/esm/options/bedrock.js +0 -423
  148. package/lib/esm/options/bedrock.js.map +0 -1
  149. package/lib/esm/options/context-windows.js.map +0 -1
  150. package/lib/esm/options/fallback.js +0 -32
  151. package/lib/esm/options/fallback.js.map +0 -1
  152. package/lib/esm/options/groq.js +0 -34
  153. package/lib/esm/options/groq.js.map +0 -1
  154. package/lib/esm/options/openai.js +0 -243
  155. package/lib/esm/options/openai.js.map +0 -1
  156. package/lib/esm/options/shared-parsing.js.map +0 -1
  157. package/lib/esm/options/version-parsing.js.map +0 -1
  158. package/lib/esm/options/vertexai.js +0 -519
  159. package/lib/esm/options/vertexai.js.map +0 -1
  160. package/lib/esm/options.js.map +0 -1
  161. package/lib/esm/types.js.map +0 -1
  162. package/lib/types/capability/azure_foundry.d.ts.map +0 -1
  163. package/lib/types/capability/bedrock.d.ts.map +0 -1
  164. package/lib/types/capability/openai.d.ts.map +0 -1
  165. package/lib/types/capability/vertexai.d.ts.map +0 -1
  166. package/lib/types/capability.d.ts.map +0 -1
  167. package/lib/types/index.d.ts +0 -11
  168. package/lib/types/index.d.ts.map +0 -1
  169. package/lib/types/options/azure_foundry.d.ts.map +0 -1
  170. package/lib/types/options/bedrock.d.ts +0 -54
  171. package/lib/types/options/bedrock.d.ts.map +0 -1
  172. package/lib/types/options/context-windows.d.ts.map +0 -1
  173. package/lib/types/options/fallback.d.ts.map +0 -1
  174. package/lib/types/options/groq.d.ts.map +0 -1
  175. package/lib/types/options/openai.d.ts +0 -37
  176. package/lib/types/options/openai.d.ts.map +0 -1
  177. package/lib/types/options/shared-parsing.d.ts.map +0 -1
  178. package/lib/types/options/version-parsing.d.ts.map +0 -1
  179. package/lib/types/options/vertexai.d.ts.map +0 -1
  180. package/lib/types/options.d.ts.map +0 -1
  181. package/lib/types/types.d.ts.map +0 -1
  182. /package/lib/{types/options → options}/context-windows.d.ts +0 -0
  183. /package/lib/{esm/options → options}/context-windows.js +0 -0
  184. /package/lib/{types/options → options}/version-parsing.d.ts +0 -0
@@ -1,46 +1,112 @@
1
- import { ModelModalities } from "../types.js";
1
+ import type { ModelModalities } from '../types.js';
2
2
 
3
3
  // Record of Vertex AI model capabilities keyed by model ID (last path segment, lowercased)
4
- const RECORD_MODEL_CAPABILITIES: Record<string, { input: ModelModalities; output: ModelModalities; tool_support?: boolean }> = {
5
- "gemini-2.0-flash-lite-001": { input: { text: true, image: true, video: true, audio: true, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: false },
4
+ const RECORD_MODEL_CAPABILITIES: Record<
5
+ string,
6
+ { input: ModelModalities; output: ModelModalities; tool_support?: boolean }
7
+ > = {
8
+ 'gemini-2.0-flash-lite-001': {
9
+ input: { text: true, image: true, video: true, audio: true, embed: false },
10
+ output: { text: true, image: false, video: false, audio: false, embed: false },
11
+ tool_support: false,
12
+ },
6
13
  };
7
14
 
8
15
  // Populate RECORD_FAMILY_CAPABILITIES as a const record (lowest common denominator for each family)
9
- const RECORD_FAMILY_CAPABILITIES: Record<string, { input: ModelModalities; output: ModelModalities; tool_support?: boolean }> = {
10
- "gemini": { input: { text: true, image: true, video: true, audio: true, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: true },
11
- "gemini-2.5-flash-image": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: true, video: false, audio: false, embed: false }, tool_support: false },
12
- "gemini-3.0-pro-image": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: true, video: false, audio: false, embed: false }, tool_support: false },
13
- "gemini-3.0-flash-image": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: true, video: false, audio: false, embed: false }, tool_support: false },
14
- 'imagen': { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: false, image: true, video: false, audio: false, embed: false }, tool_support: false },
15
- "imagen-3.0": { input: { text: true, image: false, video: false, audio: false, embed: false }, output: { text: false, image: true, video: false, audio: false, embed: false }, tool_support: false },
16
- "imagen-3.0-capability": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: false, image: true, video: false, audio: false, embed: false }, tool_support: false },
17
- "imagen-4.0": { input: { text: true, image: false, video: false, audio: false, embed: false }, output: { text: false, image: true, video: false, audio: false, embed: false }, tool_support: false },
18
- "imagen-4.0-capability": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: false, image: true, video: false, audio: false, embed: false }, tool_support: false },
19
- "claude": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: true },
20
- "llama": { input: { text: true, image: false, video: false, audio: false, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: true },
21
- "llama-2": { input: { text: true, image: false, video: false, audio: false, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: false },
22
- "llama-3.2": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: true },
23
- "llama-4": { input: { text: true, image: true, video: false, audio: false, embed: false }, output: { text: true, image: false, video: false, audio: false, embed: false }, tool_support: true },
16
+ const RECORD_FAMILY_CAPABILITIES: Record<
17
+ string,
18
+ { input: ModelModalities; output: ModelModalities; tool_support?: boolean }
19
+ > = {
20
+ gemini: {
21
+ input: { text: true, image: true, video: true, audio: true, embed: false },
22
+ output: { text: true, image: false, video: false, audio: false, embed: false },
23
+ tool_support: true,
24
+ },
25
+ 'gemini-2.5-flash-image': {
26
+ input: { text: true, image: true, video: false, audio: false, embed: false },
27
+ output: { text: true, image: true, video: false, audio: false, embed: false },
28
+ tool_support: false,
29
+ },
30
+ 'gemini-3.0-pro-image': {
31
+ input: { text: true, image: true, video: false, audio: false, embed: false },
32
+ output: { text: true, image: true, video: false, audio: false, embed: false },
33
+ tool_support: false,
34
+ },
35
+ 'gemini-3.0-flash-image': {
36
+ input: { text: true, image: true, video: false, audio: false, embed: false },
37
+ output: { text: true, image: true, video: false, audio: false, embed: false },
38
+ tool_support: false,
39
+ },
40
+ imagen: {
41
+ input: { text: true, image: true, video: false, audio: false, embed: false },
42
+ output: { text: false, image: true, video: false, audio: false, embed: false },
43
+ tool_support: false,
44
+ },
45
+ 'imagen-3.0': {
46
+ input: { text: true, image: false, video: false, audio: false, embed: false },
47
+ output: { text: false, image: true, video: false, audio: false, embed: false },
48
+ tool_support: false,
49
+ },
50
+ 'imagen-3.0-capability': {
51
+ input: { text: true, image: true, video: false, audio: false, embed: false },
52
+ output: { text: false, image: true, video: false, audio: false, embed: false },
53
+ tool_support: false,
54
+ },
55
+ 'imagen-4.0': {
56
+ input: { text: true, image: false, video: false, audio: false, embed: false },
57
+ output: { text: false, image: true, video: false, audio: false, embed: false },
58
+ tool_support: false,
59
+ },
60
+ 'imagen-4.0-capability': {
61
+ input: { text: true, image: true, video: false, audio: false, embed: false },
62
+ output: { text: false, image: true, video: false, audio: false, embed: false },
63
+ tool_support: false,
64
+ },
65
+ claude: {
66
+ input: { text: true, image: true, video: false, audio: false, embed: false },
67
+ output: { text: true, image: false, video: false, audio: false, embed: false },
68
+ tool_support: true,
69
+ },
70
+ llama: {
71
+ input: { text: true, image: false, video: false, audio: false, embed: false },
72
+ output: { text: true, image: false, video: false, audio: false, embed: false },
73
+ tool_support: true,
74
+ },
75
+ 'llama-2': {
76
+ input: { text: true, image: false, video: false, audio: false, embed: false },
77
+ output: { text: true, image: false, video: false, audio: false, embed: false },
78
+ tool_support: false,
79
+ },
80
+ 'llama-3.2': {
81
+ input: { text: true, image: true, video: false, audio: false, embed: false },
82
+ output: { text: true, image: false, video: false, audio: false, embed: false },
83
+ tool_support: true,
84
+ },
85
+ 'llama-4': {
86
+ input: { text: true, image: true, video: false, audio: false, embed: false },
87
+ output: { text: true, image: false, video: false, audio: false, embed: false },
88
+ tool_support: true,
89
+ },
24
90
  };
25
91
 
26
92
  // Fallback pattern lists for inferring modalities and tool support
27
- const IMAGE_INPUT_MODELS = ["image"];
28
- const VIDEO_INPUT_MODELS = ["video"];
29
- const AUDIO_INPUT_MODELS = ["audio"];
30
- const TEXT_INPUT_MODELS = ["text"];
31
- const IMAGE_OUTPUT_MODELS = ["image"];
32
- const VIDEO_OUTPUT_MODELS = ["video"];
33
- const AUDIO_OUTPUT_MODELS = ["audio"];
34
- const TEXT_OUTPUT_MODELS = ["text"];
35
- const EMBEDDING_OUTPUT_MODELS = ["embed"];
36
- const TOOL_SUPPORT_MODELS = ["tool", "sonnet", "opus", "gemini", "claude"];
93
+ const IMAGE_INPUT_MODELS = ['image'];
94
+ const VIDEO_INPUT_MODELS = ['video'];
95
+ const AUDIO_INPUT_MODELS = ['audio'];
96
+ const TEXT_INPUT_MODELS = ['text'];
97
+ const IMAGE_OUTPUT_MODELS = ['image'];
98
+ const VIDEO_OUTPUT_MODELS = ['video'];
99
+ const AUDIO_OUTPUT_MODELS = ['audio'];
100
+ const TEXT_OUTPUT_MODELS = ['text'];
101
+ const EMBEDDING_OUTPUT_MODELS = ['embed'];
102
+ const TOOL_SUPPORT_MODELS = ['tool', 'sonnet', 'opus', 'gemini', 'claude'];
37
103
 
38
104
  function modelMatches(modelName: string, patterns: string[]): boolean {
39
- return patterns.some(pattern => modelName.includes(pattern));
105
+ return patterns.some((pattern) => modelName.includes(pattern));
40
106
  }
41
107
 
42
108
  function normalizeVertexAIModelName(modelName: string): string {
43
- const segments = modelName.toLowerCase().split("/");
109
+ const segments = modelName.toLowerCase().split('/');
44
110
  return segments[segments.length - 1];
45
111
  }
46
112
 
@@ -48,11 +114,15 @@ function normalizeVertexAIModelName(modelName: string): string {
48
114
  * Get the full ModelCapabilities for a Vertex AI model.
49
115
  * Checks RECORD_MODEL_CAPABILITIES first, then falls back to pattern-based inference.
50
116
  */
51
- export function getModelCapabilitiesVertexAI(model: string): { input: ModelModalities; output: ModelModalities; tool_support?: boolean } {
117
+ export function getModelCapabilitiesVertexAI(model: string): {
118
+ input: ModelModalities;
119
+ output: ModelModalities;
120
+ tool_support?: boolean;
121
+ } {
52
122
  const normalized = normalizeVertexAIModelName(model);
53
123
  const record = RECORD_MODEL_CAPABILITIES[normalized];
54
124
  if (record) return record;
55
- let bestFamilyKey = undefined;
125
+ let bestFamilyKey: string | undefined;
56
126
  let bestFamilyLength = 0;
57
127
  for (const key of Object.keys(RECORD_FAMILY_CAPABILITIES)) {
58
128
  if (normalized.startsWith(key) && key.length > bestFamilyLength) {
@@ -68,15 +138,15 @@ export function getModelCapabilitiesVertexAI(model: string): { input: ModelModal
68
138
  image: modelMatches(normalized, IMAGE_INPUT_MODELS) || undefined,
69
139
  video: modelMatches(normalized, VIDEO_INPUT_MODELS) || undefined,
70
140
  audio: modelMatches(normalized, AUDIO_INPUT_MODELS) || undefined,
71
- embed: false
141
+ embed: false,
72
142
  };
73
143
  const output: ModelModalities = {
74
144
  text: modelMatches(normalized, TEXT_OUTPUT_MODELS) || undefined,
75
145
  image: modelMatches(normalized, IMAGE_OUTPUT_MODELS) || undefined,
76
146
  video: modelMatches(normalized, VIDEO_OUTPUT_MODELS) || undefined,
77
147
  audio: modelMatches(normalized, AUDIO_OUTPUT_MODELS) || undefined,
78
- embed: modelMatches(normalized, EMBEDDING_OUTPUT_MODELS) || undefined
148
+ embed: modelMatches(normalized, EMBEDDING_OUTPUT_MODELS) || undefined,
79
149
  };
80
150
  const tool_support = modelMatches(normalized, TOOL_SUPPORT_MODELS) || undefined;
81
151
  return { input, output, tool_support };
82
- }
152
+ }
package/src/capability.ts CHANGED
@@ -1,15 +1,16 @@
1
- import { getModelCapabilitiesAzureFoundry } from "./capability/azure_foundry.js";
2
- import { getModelCapabilitiesBedrock } from "./capability/bedrock.js";
3
- import { getModelCapabilitiesOpenAI } from "./capability/openai.js";
4
- import { getModelCapabilitiesVertexAI } from "./capability/vertexai.js";
5
- import { ModelCapabilities, ModelModalities, Providers } from "./types.js";
1
+ import { getModelCapabilitiesAnthropic } from './capability/anthropic.js';
2
+ import { getModelCapabilitiesAzureFoundry } from './capability/azure_foundry.js';
3
+ import { getModelCapabilitiesBedrock } from './capability/bedrock.js';
4
+ import { getModelCapabilitiesOpenAI } from './capability/openai.js';
5
+ import { getModelCapabilitiesVertexAI } from './capability/vertexai.js';
6
+ import { type ModelCapabilities, type ModelModalities, Providers } from './types.js';
6
7
 
7
8
  export function getModelCapabilities(model: string, provider?: string | Providers): ModelCapabilities {
8
9
  //Check for locations/<location>/ prefix and remove it
9
- if (model.startsWith("locations/")) {
10
- const parts = model.split("/");
10
+ if (model.startsWith('locations/')) {
11
+ const parts = model.split('/');
11
12
  if (parts.length >= 3) {
12
- model = parts.slice(2).join("/");
13
+ model = parts.slice(2).join('/');
13
14
  }
14
15
  }
15
16
  const capabilities = _getModelCapabilities(model, provider);
@@ -25,6 +26,8 @@ export function getModelCapabilities(model: string, provider?: string | Provider
25
26
 
26
27
  function _getModelCapabilities(model: string, provider?: string | Providers): ModelCapabilities {
27
28
  switch (provider?.toLowerCase()) {
29
+ case Providers.anthropic:
30
+ return getModelCapabilitiesAnthropic(model);
28
31
  case Providers.vertexai:
29
32
  return getModelCapabilitiesVertexAI(model);
30
33
  case Providers.openai:
@@ -44,26 +47,28 @@ function _getModelCapabilities(model: string, provider?: string | Providers): Mo
44
47
  case Providers.xai:
45
48
  // xAI (Grok) models support tool use and are text-based
46
49
  return {
47
- input: { text: true, image: model.includes("vision") },
50
+ input: { text: true, image: model.includes('vision') },
48
51
  output: { text: true },
49
52
  tool_support: true,
50
53
  tool_support_streaming: false, // Conservative - may work but not tested
51
54
  };
52
55
  default:
53
56
  // Guess the provider based on the model name
54
- if (model.startsWith("gpt")) {
57
+ if (model.startsWith('gpt')) {
55
58
  return getModelCapabilitiesOpenAI(model);
56
- } else if (model.startsWith("grok")) {
59
+ } else if (model.startsWith('claude')) {
60
+ return getModelCapabilitiesAnthropic(model);
61
+ } else if (model.startsWith('grok')) {
57
62
  // xAI Grok models
58
63
  return {
59
- input: { text: true, image: model.includes("vision") },
64
+ input: { text: true, image: model.includes('vision') },
60
65
  output: { text: true },
61
66
  tool_support: true,
62
67
  tool_support_streaming: false,
63
68
  };
64
- } else if (model.startsWith("publishers/")) {
69
+ } else if (model.startsWith('publishers/')) {
65
70
  return getModelCapabilitiesVertexAI(model);
66
- } else if (model.startsWith("arn:aws")) {
71
+ } else if (model.startsWith('arn:aws')) {
67
72
  return getModelCapabilitiesBedrock(model);
68
73
  }
69
74
  // Fallback to a generic model with no capabilities
@@ -85,7 +90,7 @@ function getModelCapabilitiesOpenAICompatible(model: string): ModelCapabilities
85
90
  return caps;
86
91
  }
87
92
  const normalized = model.toLowerCase();
88
- const isNonToolModel = NO_TOOL_SUPPORT_PATTERNS.some(p => normalized.includes(p));
93
+ const isNonToolModel = NO_TOOL_SUPPORT_PATTERNS.some((p) => normalized.includes(p));
89
94
  return {
90
95
  input: { text: true },
91
96
  output: { text: true },
@@ -103,4 +108,4 @@ export function modelModalitiesToArray(modalities: ModelModalities): string[] {
103
108
  return Object.entries(modalities)
104
109
  .filter(([_, isSupported]) => isSupported)
105
110
  .map(([modality]) => modality);
106
- }
111
+ }
package/src/index.ts CHANGED
@@ -1,11 +1,13 @@
1
- export * from "./types.js";
2
- export * from "./capability.js";
3
- export * from "./options.js";
4
-
5
- export * from "./options/bedrock.js";
6
- export * from "./options/fallback.js";
7
- export * from "./options/groq.js";
8
- export * from "./options/openai.js";
9
- export * from "./options/vertexai.js";
10
- export * from "./options/context-windows.js";
11
- export * from "./options/version-parsing.js";
1
+ export * from './capability.js';
2
+ export * from './options/anthropic.js';
3
+ export * from './options/bedrock.js';
4
+ export * from './options/context-windows.js';
5
+ export * from './options/embedding.js';
6
+ export * from './options/fallback.js';
7
+ export * from './options/groq.js';
8
+ export * from './options/openai.js';
9
+ export * from './options/shared-parsing.js';
10
+ export * from './options/version-parsing.js';
11
+ export * from './options/vertexai.js';
12
+ export * from './options.js';
13
+ export * from './types.js';
@@ -0,0 +1,59 @@
1
+ import { type ModelOptions, type ModelOptionsInfo, OptionType, SharedOptions } from '../types.js';
2
+ import { textOptionsFallback } from './fallback.js';
3
+ import {
4
+ buildClaudeCacheOptions,
5
+ buildClaudeCacheTtlOptions,
6
+ buildClaudeEffortOptions,
7
+ buildClaudeIncludeThoughtsOption,
8
+ buildClaudeThinkingBudgetOption,
9
+ getClaudeMaxTokensLimit,
10
+ } from './shared-parsing.js';
11
+ import { hasSamplingParameterRestriction } from './version-parsing.js';
12
+
13
+ export interface AnthropicClaudeOptions {
14
+ _option_id: 'anthropic-claude';
15
+ max_tokens?: number;
16
+ temperature?: number;
17
+ top_p?: number;
18
+ top_k?: number;
19
+ stop_sequence?: string[];
20
+ effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
21
+ thinking_budget_tokens?: number;
22
+ include_thoughts?: boolean;
23
+ cache_enabled?: boolean;
24
+ cache_ttl?: '5m' | '1h';
25
+ }
26
+
27
+ export function getAnthropicOptions(model: string, option?: ModelOptions): ModelOptionsInfo {
28
+ const max_tokens_limit = getClaudeMaxTokensLimit(model);
29
+ const excludeOptions = ['max_tokens', 'presence_penalty', 'frequency_penalty'];
30
+ let commonOptions = textOptionsFallback.options.filter((o) => !excludeOptions.includes(o.name));
31
+
32
+ const hasSamplingRestriction = hasSamplingParameterRestriction(model);
33
+ if (hasSamplingRestriction) {
34
+ commonOptions = commonOptions.filter(
35
+ (o) => o.name !== SharedOptions.temperature && o.name !== SharedOptions.top_p && o.name !== 'top_k',
36
+ );
37
+ }
38
+
39
+ return {
40
+ _option_id: 'anthropic-claude',
41
+ options: [
42
+ {
43
+ name: SharedOptions.max_tokens,
44
+ type: OptionType.numeric,
45
+ min: 1,
46
+ max: max_tokens_limit,
47
+ integer: true,
48
+ step: 200,
49
+ description: 'The maximum number of tokens to generate',
50
+ },
51
+ ...commonOptions,
52
+ ...buildClaudeEffortOptions(model),
53
+ ...buildClaudeThinkingBudgetOption(model),
54
+ ...buildClaudeIncludeThoughtsOption(model),
55
+ ...buildClaudeCacheOptions(),
56
+ ...buildClaudeCacheTtlOptions((option as unknown as AnthropicClaudeOptions)?.cache_enabled),
57
+ ],
58
+ };
59
+ }