@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,4 +1,4 @@
1
- import { LlumiverseErrorContext, LlumiverseError } from '@llumiverse/common';
1
+ import { LlumiverseError, type LlumiverseErrorContext } from '@llumiverse/common';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
4
  describe('LlumiverseError', () => {
@@ -17,7 +17,7 @@ describe('LlumiverseError', () => {
17
17
  mockContext,
18
18
  originalError,
19
19
  429,
20
- 'RateLimitError'
20
+ 'RateLimitError',
21
21
  );
22
22
 
23
23
  expect(error).toBeInstanceOf(Error);
@@ -34,24 +34,13 @@ describe('LlumiverseError', () => {
34
34
  const originalError = new Error('Original error');
35
35
  const originalStack = originalError.stack;
36
36
 
37
- const error = new LlumiverseError(
38
- 'Wrapped error',
39
- true,
40
- mockContext,
41
- originalError,
42
- 500
43
- );
37
+ const error = new LlumiverseError('Wrapped error', true, mockContext, originalError, 500);
44
38
 
45
39
  expect(error.stack).toBe(originalStack);
46
40
  });
47
41
 
48
42
  it('should handle undefined code', () => {
49
- const error = new LlumiverseError(
50
- 'Test error',
51
- true,
52
- mockContext,
53
- new Error('Unknown error')
54
- );
43
+ const error = new LlumiverseError('Test error', true, mockContext, new Error('Unknown error'));
55
44
 
56
45
  expect(error.code).toBeUndefined();
57
46
  expect(error.name).toBe('LlumiverseError'); // Default name
@@ -64,7 +53,7 @@ describe('LlumiverseError', () => {
64
53
  mockContext,
65
54
  new Error('Unauthorized'),
66
55
  401,
67
- 'AuthenticationError'
56
+ 'AuthenticationError',
68
57
  );
69
58
 
70
59
  expect(error.retryable).toBe(false);
@@ -75,14 +64,7 @@ describe('LlumiverseError', () => {
75
64
  describe('toJSON', () => {
76
65
  it('should serialize to JSON', () => {
77
66
  const originalError = new Error('Original error');
78
- const error = new LlumiverseError(
79
- 'Test error',
80
- true,
81
- mockContext,
82
- originalError,
83
- 429,
84
- 'RateLimitError'
85
- );
67
+ const error = new LlumiverseError('Test error', true, mockContext, originalError, 429, 'RateLimitError');
86
68
 
87
69
  const json = error.toJSON();
88
70
 
@@ -96,13 +78,7 @@ describe('LlumiverseError', () => {
96
78
  });
97
79
 
98
80
  it('should handle non-Error original error', () => {
99
- const error = new LlumiverseError(
100
- 'Test error',
101
- true,
102
- mockContext,
103
- 'string error',
104
- 500
105
- );
81
+ const error = new LlumiverseError('Test error', true, mockContext, 'string error', 500);
106
82
 
107
83
  const json = error.toJSON();
108
84
  expect(json.originalErrorMessage).toBe('string error');
@@ -111,13 +87,7 @@ describe('LlumiverseError', () => {
111
87
 
112
88
  describe('isLlumiverseError', () => {
113
89
  it('should return true for LlumiverseError instances', () => {
114
- const error = new LlumiverseError(
115
- 'Test error',
116
- true,
117
- mockContext,
118
- new Error('Original'),
119
- 500
120
- );
90
+ const error = new LlumiverseError('Test error', true, mockContext, new Error('Original'), 500);
121
91
 
122
92
  expect(LlumiverseError.isLlumiverseError(error)).toBe(true);
123
93
  });
@@ -143,7 +113,7 @@ describe('LlumiverseError', () => {
143
113
  true,
144
114
  { ...mockContext, operation: 'execute' as const },
145
115
  new Error('Too many requests'),
146
- 429
116
+ 429,
147
117
  );
148
118
 
149
119
  expect(error.retryable).toBe(true);
@@ -156,7 +126,7 @@ describe('LlumiverseError', () => {
156
126
  true,
157
127
  { ...mockContext, operation: 'stream' as const },
158
128
  new Error('Server error'),
159
- 500
129
+ 500,
160
130
  );
161
131
 
162
132
  expect(error.retryable).toBe(true);
@@ -164,52 +134,28 @@ describe('LlumiverseError', () => {
164
134
  });
165
135
 
166
136
  it('should handle authentication errors', () => {
167
- const error = new LlumiverseError(
168
- 'Invalid API key',
169
- false,
170
- mockContext,
171
- new Error('Unauthorized'),
172
- 401
173
- );
137
+ const error = new LlumiverseError('Invalid API key', false, mockContext, new Error('Unauthorized'), 401);
174
138
 
175
139
  expect(error.retryable).toBe(false);
176
140
  expect(error.code).toBe(401);
177
141
  });
178
142
 
179
143
  it('should handle validation errors', () => {
180
- const error = new LlumiverseError(
181
- 'Invalid request',
182
- false,
183
- mockContext,
184
- new Error('Bad request'),
185
- 400
186
- );
144
+ const error = new LlumiverseError('Invalid request', false, mockContext, new Error('Bad request'), 400);
187
145
 
188
146
  expect(error.retryable).toBe(false);
189
147
  expect(error.code).toBe(400);
190
148
  });
191
149
 
192
150
  it('should handle timeout errors', () => {
193
- const error = new LlumiverseError(
194
- 'Request timeout',
195
- true,
196
- mockContext,
197
- new Error('Timeout'),
198
- 408
199
- );
151
+ const error = new LlumiverseError('Request timeout', true, mockContext, new Error('Timeout'), 408);
200
152
 
201
153
  expect(error.retryable).toBe(true);
202
154
  expect(error.code).toBe(408);
203
155
  });
204
156
 
205
157
  it('should handle service overloaded errors', () => {
206
- const error = new LlumiverseError(
207
- 'Service overloaded',
208
- true,
209
- mockContext,
210
- new Error('Overloaded'),
211
- 529
212
- );
158
+ const error = new LlumiverseError('Service overloaded', true, mockContext, new Error('Overloaded'), 529);
213
159
 
214
160
  expect(error.retryable).toBe(true);
215
161
  expect(error.code).toBe(529);
@@ -223,7 +169,7 @@ describe('LlumiverseError', () => {
223
169
  true,
224
170
  { ...mockContext, provider: 'openai' },
225
171
  new Error('Test'),
226
- 500
172
+ 500,
227
173
  );
228
174
 
229
175
  expect(error.context.provider).toBe('openai');
@@ -235,7 +181,7 @@ describe('LlumiverseError', () => {
235
181
  true,
236
182
  { ...mockContext, model: 'gpt-4' },
237
183
  new Error('Test'),
238
- 500
184
+ 500,
239
185
  );
240
186
 
241
187
  expect(error.context.model).toBe('gpt-4');
@@ -247,7 +193,7 @@ describe('LlumiverseError', () => {
247
193
  true,
248
194
  { ...mockContext, operation: 'execute' as const },
249
195
  new Error('Test'),
250
- 500
196
+ 500,
251
197
  );
252
198
 
253
199
  const streamError = new LlumiverseError(
@@ -255,7 +201,7 @@ describe('LlumiverseError', () => {
255
201
  true,
256
202
  { ...mockContext, operation: 'stream' as const },
257
203
  new Error('Test'),
258
- 500
204
+ 500,
259
205
  );
260
206
 
261
207
  expect(executeError.context.operation).toBe('execute');
@@ -0,0 +1,99 @@
1
+ import type { ModelCapabilities } from '../types.js';
2
+
3
+ // Explicit model exceptions
4
+ const RECORD_MODEL_CAPABILITIES: Record<string, ModelCapabilities> = {
5
+ // claude-3-5-haiku: no image input
6
+ 'claude-3-5-haiku-20241022': {
7
+ input: { text: true, image: false, video: false, audio: false, embed: false },
8
+ output: { text: true, image: false, video: false, audio: false, embed: false },
9
+ tool_support: true,
10
+ tool_support_streaming: true,
11
+ },
12
+ };
13
+
14
+ // Family-level capabilities (longest prefix match)
15
+ const RECORD_FAMILY_CAPABILITIES: Record<string, ModelCapabilities> = {
16
+ 'claude-3-5-haiku': {
17
+ input: { text: true, image: false, video: false, audio: false, embed: false },
18
+ output: { text: true, image: false, video: false, audio: false, embed: false },
19
+ tool_support: true,
20
+ tool_support_streaming: true,
21
+ },
22
+ 'claude-3-haiku': {
23
+ input: { text: true, image: true, video: false, audio: false, embed: false },
24
+ output: { text: true, image: false, video: false, audio: false, embed: false },
25
+ tool_support: true,
26
+ tool_support_streaming: true,
27
+ },
28
+ 'claude-3-sonnet': {
29
+ input: { text: true, image: true, video: false, audio: false, embed: false },
30
+ output: { text: true, image: false, video: false, audio: false, embed: false },
31
+ tool_support: true,
32
+ tool_support_streaming: true,
33
+ },
34
+ 'claude-3-opus': {
35
+ input: { text: true, image: true, video: false, audio: false, embed: false },
36
+ output: { text: true, image: false, video: false, audio: false, embed: false },
37
+ tool_support: true,
38
+ tool_support_streaming: true,
39
+ },
40
+ 'claude-3-5': {
41
+ input: { text: true, image: true, video: false, audio: false, embed: false },
42
+ output: { text: true, image: false, video: false, audio: false, embed: false },
43
+ tool_support: true,
44
+ tool_support_streaming: true,
45
+ },
46
+ 'claude-3-7': {
47
+ input: { text: true, image: true, video: false, audio: false, embed: false },
48
+ output: { text: true, image: false, video: false, audio: false, embed: false },
49
+ tool_support: true,
50
+ tool_support_streaming: true,
51
+ },
52
+ 'claude-3': {
53
+ input: { text: true, image: true, video: false, audio: false, embed: false },
54
+ output: { text: true, image: false, video: false, audio: false, embed: false },
55
+ tool_support: true,
56
+ tool_support_streaming: true,
57
+ },
58
+ 'claude-4': {
59
+ input: { text: true, image: true, video: false, audio: false, embed: false },
60
+ output: { text: true, image: false, video: false, audio: false, embed: false },
61
+ tool_support: true,
62
+ tool_support_streaming: true,
63
+ },
64
+ 'claude-': {
65
+ input: { text: true, image: true, video: false, audio: false, embed: false },
66
+ output: { text: true, image: false, video: false, audio: false, embed: false },
67
+ tool_support: true,
68
+ tool_support_streaming: true,
69
+ },
70
+ };
71
+
72
+ const DEFAULT_CLAUDE_CAPABILITIES: ModelCapabilities = {
73
+ input: { text: true, image: true, video: false, audio: false, embed: false },
74
+ output: { text: true, image: false, video: false, audio: false, embed: false },
75
+ tool_support: true,
76
+ tool_support_streaming: true,
77
+ };
78
+
79
+ export function getModelCapabilitiesAnthropic(model: string): ModelCapabilities {
80
+ const lower = model.toLowerCase();
81
+
82
+ // Exact match first
83
+ if (lower in RECORD_MODEL_CAPABILITIES) {
84
+ return RECORD_MODEL_CAPABILITIES[lower];
85
+ }
86
+
87
+ // Longest prefix family match
88
+ let bestKey: string | undefined;
89
+ for (const key of Object.keys(RECORD_FAMILY_CAPABILITIES)) {
90
+ if (lower.startsWith(key) && (!bestKey || key.length > bestKey.length)) {
91
+ bestKey = key;
92
+ }
93
+ }
94
+ if (bestKey) {
95
+ return RECORD_FAMILY_CAPABILITIES[bestKey];
96
+ }
97
+
98
+ return DEFAULT_CLAUDE_CAPABILITIES;
99
+ }