@silupanda/schema-bridge 0.2.2

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 (74) hide show
  1. package/README.md +750 -0
  2. package/dist/__tests__/anthropic.test.d.ts +2 -0
  3. package/dist/__tests__/anthropic.test.d.ts.map +1 -0
  4. package/dist/__tests__/anthropic.test.js +183 -0
  5. package/dist/__tests__/anthropic.test.js.map +1 -0
  6. package/dist/__tests__/gemini.test.d.ts +2 -0
  7. package/dist/__tests__/gemini.test.d.ts.map +1 -0
  8. package/dist/__tests__/gemini.test.js +177 -0
  9. package/dist/__tests__/gemini.test.js.map +1 -0
  10. package/dist/__tests__/integration.test.d.ts +2 -0
  11. package/dist/__tests__/integration.test.d.ts.map +1 -0
  12. package/dist/__tests__/integration.test.js +513 -0
  13. package/dist/__tests__/integration.test.js.map +1 -0
  14. package/dist/__tests__/normalizer.test.d.ts +2 -0
  15. package/dist/__tests__/normalizer.test.d.ts.map +1 -0
  16. package/dist/__tests__/normalizer.test.js +349 -0
  17. package/dist/__tests__/normalizer.test.js.map +1 -0
  18. package/dist/__tests__/openai.test.d.ts +2 -0
  19. package/dist/__tests__/openai.test.d.ts.map +1 -0
  20. package/dist/__tests__/openai.test.js +473 -0
  21. package/dist/__tests__/openai.test.js.map +1 -0
  22. package/dist/__tests__/providers.test.d.ts +2 -0
  23. package/dist/__tests__/providers.test.d.ts.map +1 -0
  24. package/dist/__tests__/providers.test.js +187 -0
  25. package/dist/__tests__/providers.test.js.map +1 -0
  26. package/dist/__tests__/tool.test.d.ts +2 -0
  27. package/dist/__tests__/tool.test.d.ts.map +1 -0
  28. package/dist/__tests__/tool.test.js +212 -0
  29. package/dist/__tests__/tool.test.js.map +1 -0
  30. package/dist/index.d.ts +45 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +81 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/normalizer.d.ts +24 -0
  35. package/dist/normalizer.d.ts.map +1 -0
  36. package/dist/normalizer.js +263 -0
  37. package/dist/normalizer.js.map +1 -0
  38. package/dist/providers/anthropic.d.ts +7 -0
  39. package/dist/providers/anthropic.d.ts.map +1 -0
  40. package/dist/providers/anthropic.js +109 -0
  41. package/dist/providers/anthropic.js.map +1 -0
  42. package/dist/providers/cohere.d.ts +8 -0
  43. package/dist/providers/cohere.d.ts.map +1 -0
  44. package/dist/providers/cohere.js +63 -0
  45. package/dist/providers/cohere.js.map +1 -0
  46. package/dist/providers/gemini.d.ts +10 -0
  47. package/dist/providers/gemini.d.ts.map +1 -0
  48. package/dist/providers/gemini.js +160 -0
  49. package/dist/providers/gemini.js.map +1 -0
  50. package/dist/providers/index.d.ts +17 -0
  51. package/dist/providers/index.d.ts.map +1 -0
  52. package/dist/providers/index.js +51 -0
  53. package/dist/providers/index.js.map +1 -0
  54. package/dist/providers/mcp.d.ts +8 -0
  55. package/dist/providers/mcp.d.ts.map +1 -0
  56. package/dist/providers/mcp.js +18 -0
  57. package/dist/providers/mcp.js.map +1 -0
  58. package/dist/providers/ollama.d.ts +8 -0
  59. package/dist/providers/ollama.d.ts.map +1 -0
  60. package/dist/providers/ollama.js +63 -0
  61. package/dist/providers/ollama.js.map +1 -0
  62. package/dist/providers/openai.d.ts +10 -0
  63. package/dist/providers/openai.d.ts.map +1 -0
  64. package/dist/providers/openai.js +309 -0
  65. package/dist/providers/openai.js.map +1 -0
  66. package/dist/tool.d.ts +19 -0
  67. package/dist/tool.d.ts.map +1 -0
  68. package/dist/tool.js +120 -0
  69. package/dist/tool.js.map +1 -0
  70. package/dist/types.d.ts +143 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +3 -0
  73. package/dist/types.js.map +1 -0
  74. package/package.json +32 -0
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const index_1 = require("../index");
5
+ const ALL_PROVIDERS = ['openai', 'anthropic', 'gemini', 'cohere', 'mcp', 'ollama', 'vercel-ai'];
6
+ const simpleSchema = {
7
+ type: 'object',
8
+ properties: {
9
+ name: { type: 'string', description: 'User name' },
10
+ age: { type: 'number', description: 'User age' },
11
+ },
12
+ required: ['name', 'age'],
13
+ };
14
+ const schemaWithConstraints = {
15
+ type: 'object',
16
+ properties: {
17
+ name: { type: 'string', minLength: 1, maxLength: 100 },
18
+ age: { type: 'number', minimum: 0, maximum: 150 },
19
+ email: { type: 'string', format: 'email', pattern: '^[^@]+@[^@]+$' },
20
+ tags: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 10 },
21
+ },
22
+ required: ['name', 'age'],
23
+ };
24
+ const schemaWithRefs = {
25
+ type: 'object',
26
+ properties: {
27
+ address: { $ref: '#/$defs/Address' },
28
+ },
29
+ required: ['address'],
30
+ $defs: {
31
+ Address: {
32
+ type: 'object',
33
+ properties: {
34
+ street: { type: 'string' },
35
+ city: { type: 'string' },
36
+ },
37
+ required: ['street', 'city'],
38
+ },
39
+ },
40
+ };
41
+ (0, vitest_1.describe)('convert - all providers', () => {
42
+ for (const provider of ALL_PROVIDERS) {
43
+ (0, vitest_1.describe)(provider, () => {
44
+ (0, vitest_1.it)('converts a simple schema successfully', () => {
45
+ const result = (0, index_1.convert)(simpleSchema, provider);
46
+ (0, vitest_1.expect)(result).toBeDefined();
47
+ (0, vitest_1.expect)(result.schema).toBeDefined();
48
+ (0, vitest_1.expect)(result.transformations).toBeDefined();
49
+ (0, vitest_1.expect)(result.warnings).toBeDefined();
50
+ });
51
+ (0, vitest_1.it)('returns a valid schema structure', () => {
52
+ const result = (0, index_1.convert)(simpleSchema, provider);
53
+ (0, vitest_1.expect)(result.schema.type).toBe('object');
54
+ (0, vitest_1.expect)(result.schema.properties).toBeDefined();
55
+ });
56
+ (0, vitest_1.it)('handles schema with constraints', () => {
57
+ const result = (0, index_1.convert)(schemaWithConstraints, provider);
58
+ (0, vitest_1.expect)(result).toBeDefined();
59
+ (0, vitest_1.expect)(result.schema).toBeDefined();
60
+ });
61
+ (0, vitest_1.it)('handles schema with $ref', () => {
62
+ const result = (0, index_1.convert)(schemaWithRefs, provider);
63
+ (0, vitest_1.expect)(result).toBeDefined();
64
+ (0, vitest_1.expect)(result.schema).toBeDefined();
65
+ });
66
+ (0, vitest_1.it)('handles empty object schema', () => {
67
+ const result = (0, index_1.convert)({ type: 'object', properties: {} }, provider);
68
+ (0, vitest_1.expect)(result.schema).toBeDefined();
69
+ });
70
+ });
71
+ }
72
+ });
73
+ (0, vitest_1.describe)('provider-specific constraint handling', () => {
74
+ (0, vitest_1.it)('OpenAI removes constraints', () => {
75
+ const result = (0, index_1.convert)(schemaWithConstraints, 'openai');
76
+ (0, vitest_1.expect)(result.schema.properties.age.minimum).toBeUndefined();
77
+ (0, vitest_1.expect)(result.schema.properties.age.maximum).toBeUndefined();
78
+ (0, vitest_1.expect)(result.schema.properties.name.minLength).toBeUndefined();
79
+ (0, vitest_1.expect)(result.schema.properties.email.format).toBeUndefined();
80
+ });
81
+ (0, vitest_1.it)('Anthropic preserves constraints', () => {
82
+ const result = (0, index_1.convert)(schemaWithConstraints, 'anthropic');
83
+ (0, vitest_1.expect)(result.schema.properties.age.minimum).toBe(0);
84
+ (0, vitest_1.expect)(result.schema.properties.age.maximum).toBe(150);
85
+ (0, vitest_1.expect)(result.schema.properties.name.minLength).toBe(1);
86
+ (0, vitest_1.expect)(result.schema.properties.email.format).toBe('email');
87
+ });
88
+ (0, vitest_1.it)('Gemini removes default but preserves constraints', () => {
89
+ const schemaWithDefault = {
90
+ type: 'object',
91
+ properties: {
92
+ mode: { type: 'string', default: 'auto', minimum: 5 },
93
+ },
94
+ required: ['mode'],
95
+ };
96
+ const result = (0, index_1.convert)(schemaWithDefault, 'gemini');
97
+ (0, vitest_1.expect)(result.schema.properties.mode.default).toBeUndefined();
98
+ });
99
+ (0, vitest_1.it)('MCP preserves everything', () => {
100
+ const result = (0, index_1.convert)(schemaWithConstraints, 'mcp');
101
+ (0, vitest_1.expect)(result.schema.properties.age.minimum).toBe(0);
102
+ (0, vitest_1.expect)(result.schema.properties.age.maximum).toBe(150);
103
+ (0, vitest_1.expect)(result.schema.properties.name.minLength).toBe(1);
104
+ (0, vitest_1.expect)(result.schema.properties.email.format).toBe('email');
105
+ (0, vitest_1.expect)(result.schema.properties.tags.minItems).toBe(1);
106
+ });
107
+ (0, vitest_1.it)('Cohere preserves most constraints', () => {
108
+ const result = (0, index_1.convert)(schemaWithConstraints, 'cohere');
109
+ (0, vitest_1.expect)(result.schema.properties.age.minimum).toBe(0);
110
+ (0, vitest_1.expect)(result.schema.properties.age.maximum).toBe(150);
111
+ });
112
+ (0, vitest_1.it)('Ollama removes examples but preserves constraints', () => {
113
+ const schemaWithExamples = {
114
+ type: 'object',
115
+ properties: {
116
+ name: { type: 'string', examples: ['Alice'], minimum: 0 },
117
+ },
118
+ required: ['name'],
119
+ };
120
+ const result = (0, index_1.convert)(schemaWithExamples, 'ollama');
121
+ (0, vitest_1.expect)(result.schema.properties.name.examples).toBeUndefined();
122
+ });
123
+ });
124
+ (0, vitest_1.describe)('provider-specific $ref handling', () => {
125
+ (0, vitest_1.it)('OpenAI preserves $ref for recursive schemas', () => {
126
+ const recursiveSchema = {
127
+ type: 'object',
128
+ properties: {
129
+ child: { $ref: '#/$defs/Node' },
130
+ },
131
+ $defs: {
132
+ Node: {
133
+ type: 'object',
134
+ properties: {
135
+ value: { type: 'string' },
136
+ child: { $ref: '#/$defs/Node' },
137
+ },
138
+ },
139
+ },
140
+ };
141
+ const result = (0, index_1.convert)(recursiveSchema, 'openai');
142
+ // For recursive schemas with preserveRefs, $defs should be kept
143
+ (0, vitest_1.expect)(result.schema).toBeDefined();
144
+ });
145
+ (0, vitest_1.it)('Cohere inlines $ref for non-recursive schemas', () => {
146
+ const result = (0, index_1.convert)(schemaWithRefs, 'cohere');
147
+ // Refs should be inlined
148
+ (0, vitest_1.expect)(result.schema.properties.address.properties).toBeDefined();
149
+ });
150
+ (0, vitest_1.it)('Ollama inlines $ref for non-recursive schemas', () => {
151
+ const result = (0, index_1.convert)(schemaWithRefs, 'ollama');
152
+ (0, vitest_1.expect)(result.schema.properties.address.properties).toBeDefined();
153
+ });
154
+ });
155
+ (0, vitest_1.describe)('supported providers', () => {
156
+ (0, vitest_1.it)('returns all supported provider names', () => {
157
+ const providers = (0, index_1.supported)();
158
+ (0, vitest_1.expect)(providers).toContain('openai');
159
+ (0, vitest_1.expect)(providers).toContain('anthropic');
160
+ (0, vitest_1.expect)(providers).toContain('gemini');
161
+ (0, vitest_1.expect)(providers).toContain('cohere');
162
+ (0, vitest_1.expect)(providers).toContain('mcp');
163
+ (0, vitest_1.expect)(providers).toContain('ollama');
164
+ (0, vitest_1.expect)(providers).toContain('vercel-ai');
165
+ });
166
+ (0, vitest_1.it)('throws for unsupported provider', () => {
167
+ (0, vitest_1.expect)(() => (0, index_1.convert)(simpleSchema, 'unknown')).toThrow('Unsupported provider');
168
+ });
169
+ });
170
+ (0, vitest_1.describe)('round-trip consistency', () => {
171
+ (0, vitest_1.it)('schema structure is preserved across conversion', () => {
172
+ for (const provider of ALL_PROVIDERS) {
173
+ const result = (0, index_1.convert)(simpleSchema, provider);
174
+ // All providers should preserve the basic structure
175
+ (0, vitest_1.expect)(result.schema.properties.name).toBeDefined();
176
+ (0, vitest_1.expect)(result.schema.properties.age).toBeDefined();
177
+ }
178
+ });
179
+ (0, vitest_1.it)('descriptions are preserved across all providers', () => {
180
+ for (const provider of ALL_PROVIDERS) {
181
+ const result = (0, index_1.convert)(simpleSchema, provider);
182
+ (0, vitest_1.expect)(result.schema.properties.name.description).toBe('User name');
183
+ (0, vitest_1.expect)(result.schema.properties.age.description).toBe('User age');
184
+ }
185
+ });
186
+ });
187
+ //# sourceMappingURL=providers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.test.js","sourceRoot":"","sources":["../../src/__tests__/providers.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,oCAA8C;AAG9C,MAA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AC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,WAAE,EAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,IAAA,eAAO,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC/C,oDAAoD;YACpD,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,CAAC,UAAW,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YACrD,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,CAAC,UAAW,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,IAAA,eAAO,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC/C,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,CAAC,UAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACrE,IAAA,eAAM,EAAC,MAAM,CAAC,MAAM,CAAC,UAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/tool.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const tool_1 = require("../tool");
5
+ const index_1 = require("../index");
6
+ const weatherSchema = {
7
+ type: 'object',
8
+ properties: {
9
+ location: { type: 'string', description: 'City and state' },
10
+ units: { type: 'string', enum: ['fahrenheit', 'celsius'] },
11
+ },
12
+ required: ['location'],
13
+ };
14
+ const weatherTool = {
15
+ name: 'get_weather',
16
+ description: 'Get current weather for a location',
17
+ schema: weatherSchema,
18
+ };
19
+ (0, vitest_1.describe)('createTool', () => {
20
+ (0, vitest_1.describe)('tool name validation', () => {
21
+ (0, vitest_1.it)('accepts valid alphanumeric names', () => {
22
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: 'get_weather' }, 'openai')).not.toThrow();
23
+ });
24
+ (0, vitest_1.it)('accepts names with hyphens', () => {
25
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: 'get-weather' }, 'openai')).not.toThrow();
26
+ });
27
+ (0, vitest_1.it)('accepts names with underscores', () => {
28
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: 'get_weather_v2' }, 'openai')).not.toThrow();
29
+ });
30
+ (0, vitest_1.it)('rejects names with spaces', () => {
31
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: 'get weather' }, 'openai')).toThrow(TypeError);
32
+ });
33
+ (0, vitest_1.it)('rejects names with special characters', () => {
34
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: 'get@weather' }, 'openai')).toThrow(TypeError);
35
+ });
36
+ (0, vitest_1.it)('rejects empty names', () => {
37
+ (0, vitest_1.expect)(() => (0, tool_1.createTool)({ ...weatherTool, name: '' }, 'openai')).toThrow(TypeError);
38
+ });
39
+ });
40
+ (0, vitest_1.describe)('OpenAI tool format', () => {
41
+ (0, vitest_1.it)('produces correct envelope', () => {
42
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'openai');
43
+ const openaiTool = tool;
44
+ (0, vitest_1.expect)(openaiTool.type).toBe('function');
45
+ (0, vitest_1.expect)(openaiTool.function.name).toBe('get_weather');
46
+ (0, vitest_1.expect)(openaiTool.function.description).toBe('Get current weather for a location');
47
+ (0, vitest_1.expect)(openaiTool.function.parameters).toBeDefined();
48
+ (0, vitest_1.expect)(openaiTool.function.strict).toBe(true);
49
+ });
50
+ (0, vitest_1.it)('sets strict: false when option specified', () => {
51
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'openai', { strict: false });
52
+ const openaiTool = tool;
53
+ (0, vitest_1.expect)(openaiTool.function.strict).toBe(false);
54
+ });
55
+ (0, vitest_1.it)('injects additionalProperties: false in parameters', () => {
56
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'openai');
57
+ const openaiTool = tool;
58
+ (0, vitest_1.expect)(openaiTool.function.parameters.additionalProperties).toBe(false);
59
+ });
60
+ (0, vitest_1.it)('expands required and makes optional fields nullable', () => {
61
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'openai');
62
+ const openaiTool = tool;
63
+ (0, vitest_1.expect)(openaiTool.function.parameters.required).toContain('location');
64
+ (0, vitest_1.expect)(openaiTool.function.parameters.required).toContain('units');
65
+ });
66
+ });
67
+ (0, vitest_1.describe)('Anthropic tool format', () => {
68
+ (0, vitest_1.it)('produces correct envelope', () => {
69
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'anthropic');
70
+ const anthropicTool = tool;
71
+ (0, vitest_1.expect)(anthropicTool.name).toBe('get_weather');
72
+ (0, vitest_1.expect)(anthropicTool.description).toBe('Get current weather for a location');
73
+ (0, vitest_1.expect)(anthropicTool.input_schema).toBeDefined();
74
+ (0, vitest_1.expect)(anthropicTool.input_schema.type).toBe('object');
75
+ });
76
+ (0, vitest_1.it)('uses input_schema key (not parameters)', () => {
77
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'anthropic');
78
+ const anthropicTool = tool;
79
+ (0, vitest_1.expect)(anthropicTool.input_schema).toBeDefined();
80
+ (0, vitest_1.expect)(anthropicTool.parameters).toBeUndefined();
81
+ });
82
+ (0, vitest_1.it)('preserves optional fields as optional', () => {
83
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'anthropic');
84
+ const anthropicTool = tool;
85
+ (0, vitest_1.expect)(anthropicTool.input_schema.required).toEqual(['location']);
86
+ });
87
+ });
88
+ (0, vitest_1.describe)('Gemini tool format', () => {
89
+ (0, vitest_1.it)('produces correct envelope', () => {
90
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'gemini');
91
+ const geminiTool = tool;
92
+ (0, vitest_1.expect)(geminiTool.name).toBe('get_weather');
93
+ (0, vitest_1.expect)(geminiTool.description).toBe('Get current weather for a location');
94
+ (0, vitest_1.expect)(geminiTool.parameters).toBeDefined();
95
+ });
96
+ });
97
+ (0, vitest_1.describe)('Cohere tool format', () => {
98
+ (0, vitest_1.it)('produces correct envelope', () => {
99
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'cohere');
100
+ const cohereTool = tool;
101
+ (0, vitest_1.expect)(cohereTool.type).toBe('function');
102
+ (0, vitest_1.expect)(cohereTool.function.name).toBe('get_weather');
103
+ (0, vitest_1.expect)(cohereTool.function.description).toBe('Get current weather for a location');
104
+ (0, vitest_1.expect)(cohereTool.function.parameters).toBeDefined();
105
+ });
106
+ });
107
+ (0, vitest_1.describe)('MCP tool format', () => {
108
+ (0, vitest_1.it)('produces correct envelope with camelCase inputSchema', () => {
109
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'mcp');
110
+ const mcpTool = tool;
111
+ (0, vitest_1.expect)(mcpTool.name).toBe('get_weather');
112
+ (0, vitest_1.expect)(mcpTool.description).toBe('Get current weather for a location');
113
+ (0, vitest_1.expect)(mcpTool.inputSchema).toBeDefined();
114
+ (0, vitest_1.expect)(mcpTool.input_schema).toBeUndefined();
115
+ });
116
+ (0, vitest_1.it)('includes outputSchema when provided', () => {
117
+ const toolWithOutput = {
118
+ ...weatherTool,
119
+ outputSchema: {
120
+ type: 'object',
121
+ properties: {
122
+ temperature: { type: 'number' },
123
+ },
124
+ required: ['temperature'],
125
+ },
126
+ };
127
+ const { tool } = (0, tool_1.createTool)(toolWithOutput, 'mcp');
128
+ const mcpTool = tool;
129
+ (0, vitest_1.expect)(mcpTool.outputSchema).toBeDefined();
130
+ (0, vitest_1.expect)(mcpTool.outputSchema.type).toBe('object');
131
+ });
132
+ (0, vitest_1.it)('does not include outputSchema for non-MCP providers', () => {
133
+ const toolWithOutput = {
134
+ ...weatherTool,
135
+ outputSchema: {
136
+ type: 'object',
137
+ properties: {
138
+ temperature: { type: 'number' },
139
+ },
140
+ },
141
+ };
142
+ const { tool } = (0, tool_1.createTool)(toolWithOutput, 'openai');
143
+ (0, vitest_1.expect)(tool.outputSchema).toBeUndefined();
144
+ });
145
+ });
146
+ (0, vitest_1.describe)('Ollama tool format', () => {
147
+ (0, vitest_1.it)('produces correct envelope', () => {
148
+ const { tool } = (0, tool_1.createTool)(weatherTool, 'ollama');
149
+ const ollamaTool = tool;
150
+ (0, vitest_1.expect)(ollamaTool.name).toBe('get_weather');
151
+ (0, vitest_1.expect)(ollamaTool.description).toBe('Get current weather for a location');
152
+ (0, vitest_1.expect)(ollamaTool.format).toBeDefined();
153
+ });
154
+ });
155
+ (0, vitest_1.it)('returns transformations and warnings', () => {
156
+ const { transformations, warnings } = (0, tool_1.createTool)(weatherTool, 'openai');
157
+ (0, vitest_1.expect)(Array.isArray(transformations)).toBe(true);
158
+ (0, vitest_1.expect)(Array.isArray(warnings)).toBe(true);
159
+ });
160
+ });
161
+ (0, vitest_1.describe)('createTools', () => {
162
+ const tools = [
163
+ weatherTool,
164
+ {
165
+ name: 'search',
166
+ description: 'Search the web',
167
+ schema: {
168
+ type: 'object',
169
+ properties: {
170
+ query: { type: 'string' },
171
+ },
172
+ required: ['query'],
173
+ },
174
+ },
175
+ ];
176
+ (0, vitest_1.it)('converts multiple tools', () => {
177
+ const result = (0, tool_1.createTools)(tools, 'openai');
178
+ (0, vitest_1.expect)(result.tools.length).toBe(2);
179
+ (0, vitest_1.expect)(result.transformations.length).toBe(2);
180
+ (0, vitest_1.expect)(result.warnings.length).toBe(2);
181
+ });
182
+ (0, vitest_1.it)('handles empty array', () => {
183
+ const result = (0, tool_1.createTools)([], 'openai');
184
+ (0, vitest_1.expect)(result.tools.length).toBe(0);
185
+ });
186
+ (0, vitest_1.it)('wraps Gemini tools in functionDeclarations', () => {
187
+ const result = (0, tool_1.createTools)(tools, 'gemini');
188
+ (0, vitest_1.expect)(result.tools.length).toBe(1); // Single object wrapping all declarations
189
+ const wrapper = result.tools[0];
190
+ (0, vitest_1.expect)(wrapper.functionDeclarations).toBeDefined();
191
+ (0, vitest_1.expect)(wrapper.functionDeclarations.length).toBe(2);
192
+ });
193
+ (0, vitest_1.it)('each tool gets independent transformation records', () => {
194
+ const result = (0, tool_1.createTools)(tools, 'openai');
195
+ (0, vitest_1.expect)(result.transformations[0]).not.toBe(result.transformations[1]);
196
+ });
197
+ });
198
+ (0, vitest_1.describe)('convertTool (re-exported from index)', () => {
199
+ (0, vitest_1.it)('works the same as createTool', () => {
200
+ const result = (0, index_1.convertTool)(weatherTool, 'openai');
201
+ (0, vitest_1.expect)(result.tool).toBeDefined();
202
+ (0, vitest_1.expect)(result.transformations).toBeDefined();
203
+ (0, vitest_1.expect)(result.warnings).toBeDefined();
204
+ });
205
+ });
206
+ (0, vitest_1.describe)('convertTools (re-exported from index)', () => {
207
+ (0, vitest_1.it)('works the same as createTools', () => {
208
+ const result = (0, index_1.convertTools)([weatherTool], 'anthropic');
209
+ (0, vitest_1.expect)(result.tools.length).toBe(1);
210
+ });
211
+ });
212
+ //# sourceMappingURL=tool.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.test.js","sourceRoot":"","sources":["../../src/__tests__/tool.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,kCAAkD;AAClD,oCAAqD;AAGrD,MAAM,aAAa,GAAe;IAChC,IAAI,EAAE,Q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BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAC,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;QACxD,IAAA,eAAM,EAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { JSONSchema, Provider, ConvertOptions, ProviderSchema, ToolDefinitionInput, ToolDefinition, TransformationRecord } from './types';
2
+ /**
3
+ * Convert a JSON Schema to a provider-specific structured output format.
4
+ *
5
+ * @param schema - A JSON Schema object
6
+ * @param provider - Target provider name
7
+ * @param options - Conversion options
8
+ * @returns The converted schema with transformation records and warnings
9
+ */
10
+ export declare function convert(schema: JSONSchema, provider: Provider, options?: ConvertOptions): ProviderSchema;
11
+ /**
12
+ * Convert a tool definition to a provider-specific format.
13
+ *
14
+ * @param tool - Tool definition with name, description, and schema
15
+ * @param provider - Target provider name
16
+ * @param options - Conversion options
17
+ * @returns Provider-specific tool definition with transformation records
18
+ */
19
+ export declare function convertTool(tool: ToolDefinitionInput, provider: Provider, options?: ConvertOptions): {
20
+ tool: ToolDefinition;
21
+ transformations: TransformationRecord[];
22
+ warnings: string[];
23
+ };
24
+ /**
25
+ * Convert multiple tool definitions to a provider-specific format.
26
+ *
27
+ * @param tools - Array of tool definitions
28
+ * @param provider - Target provider name
29
+ * @param options - Conversion options
30
+ * @returns Provider-specific tool definitions with transformation records
31
+ */
32
+ export declare function convertTools(tools: ToolDefinitionInput[], provider: Provider, options?: ConvertOptions): {
33
+ tools: ToolDefinition[];
34
+ transformations: TransformationRecord[][];
35
+ warnings: string[][];
36
+ };
37
+ /**
38
+ * List all supported provider names.
39
+ */
40
+ export declare function supported(): Provider[];
41
+ export type { JSONSchema, Provider, ConvertOptions, ProviderSchema, ToolDefinitionInput, ToolDefinition, OpenAIToolDefinition, AnthropicToolDefinition, GeminiToolDefinition, CohereToolDefinition, MCPToolDefinition, OllamaToolDefinition, GenericToolDefinition, TransformationRecord, TransformationType, } from './types';
42
+ export { normalize, resolveRefs } from './normalizer';
43
+ export { convertToOpenAI, wrapOpenAIResponseFormat, convertToAnthropic, convertToGemini, wrapGeminiResponseFormat, convertToCohere, convertToMCP, convertToOllama, } from './providers';
44
+ export { createTool, createTools } from './tool';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAKjB;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,CAoBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,eAAe,EAAE,oBAAoB,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAEvF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,mBAAmB,EAAE,EAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,cAAc,GACvB;IAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,eAAe,EAAE,oBAAoB,EAAE,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAE9F;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,QAAQ,EAAE,CAEtC;AAGD,YAAY,EACV,UAAU,EACV,QAAQ,EACR,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTools = exports.createTool = exports.convertToOllama = exports.convertToMCP = exports.convertToCohere = exports.wrapGeminiResponseFormat = exports.convertToGemini = exports.convertToAnthropic = exports.wrapOpenAIResponseFormat = exports.convertToOpenAI = exports.resolveRefs = exports.normalize = void 0;
4
+ exports.convert = convert;
5
+ exports.convertTool = convertTool;
6
+ exports.convertTools = convertTools;
7
+ exports.supported = supported;
8
+ const normalizer_1 = require("./normalizer");
9
+ const providers_1 = require("./providers");
10
+ const tool_1 = require("./tool");
11
+ /**
12
+ * Convert a JSON Schema to a provider-specific structured output format.
13
+ *
14
+ * @param schema - A JSON Schema object
15
+ * @param provider - Target provider name
16
+ * @param options - Conversion options
17
+ * @returns The converted schema with transformation records and warnings
18
+ */
19
+ function convert(schema, provider, options) {
20
+ const converter = (0, providers_1.getConverter)(provider);
21
+ // Normalize the schema
22
+ let normalized = (0, normalizer_1.normalize)(schema);
23
+ // Resolve $ref references
24
+ const preserveRefs = provider === 'openai' || provider === 'anthropic' || provider === 'mcp' || provider === 'gemini';
25
+ const { schema: resolved, transformations: refTransforms } = (0, normalizer_1.resolveRefs)(normalized, {
26
+ maxRecursionDepth: options?.maxRecursionDepth,
27
+ preserveRefs,
28
+ });
29
+ // Apply provider-specific conversion
30
+ const result = converter(resolved, options);
31
+ // Merge ref transformations
32
+ result.transformations = [...refTransforms, ...result.transformations];
33
+ return result;
34
+ }
35
+ /**
36
+ * Convert a tool definition to a provider-specific format.
37
+ *
38
+ * @param tool - Tool definition with name, description, and schema
39
+ * @param provider - Target provider name
40
+ * @param options - Conversion options
41
+ * @returns Provider-specific tool definition with transformation records
42
+ */
43
+ function convertTool(tool, provider, options) {
44
+ return (0, tool_1.createTool)(tool, provider, options);
45
+ }
46
+ /**
47
+ * Convert multiple tool definitions to a provider-specific format.
48
+ *
49
+ * @param tools - Array of tool definitions
50
+ * @param provider - Target provider name
51
+ * @param options - Conversion options
52
+ * @returns Provider-specific tool definitions with transformation records
53
+ */
54
+ function convertTools(tools, provider, options) {
55
+ return (0, tool_1.createTools)(tools, provider, options);
56
+ }
57
+ /**
58
+ * List all supported provider names.
59
+ */
60
+ function supported() {
61
+ return (0, providers_1.supportedProviders)();
62
+ }
63
+ // Re-export normalizer
64
+ var normalizer_2 = require("./normalizer");
65
+ Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return normalizer_2.normalize; } });
66
+ Object.defineProperty(exports, "resolveRefs", { enumerable: true, get: function () { return normalizer_2.resolveRefs; } });
67
+ // Re-export provider-specific converters for advanced use
68
+ var providers_2 = require("./providers");
69
+ Object.defineProperty(exports, "convertToOpenAI", { enumerable: true, get: function () { return providers_2.convertToOpenAI; } });
70
+ Object.defineProperty(exports, "wrapOpenAIResponseFormat", { enumerable: true, get: function () { return providers_2.wrapOpenAIResponseFormat; } });
71
+ Object.defineProperty(exports, "convertToAnthropic", { enumerable: true, get: function () { return providers_2.convertToAnthropic; } });
72
+ Object.defineProperty(exports, "convertToGemini", { enumerable: true, get: function () { return providers_2.convertToGemini; } });
73
+ Object.defineProperty(exports, "wrapGeminiResponseFormat", { enumerable: true, get: function () { return providers_2.wrapGeminiResponseFormat; } });
74
+ Object.defineProperty(exports, "convertToCohere", { enumerable: true, get: function () { return providers_2.convertToCohere; } });
75
+ Object.defineProperty(exports, "convertToMCP", { enumerable: true, get: function () { return providers_2.convertToMCP; } });
76
+ Object.defineProperty(exports, "convertToOllama", { enumerable: true, get: function () { return providers_2.convertToOllama; } });
77
+ // Re-export tool builders
78
+ var tool_2 = require("./tool");
79
+ Object.defineProperty(exports, "createTool", { enumerable: true, get: function () { return tool_2.createTool; } });
80
+ Object.defineProperty(exports, "createTools", { enumerable: true, get: function () { return tool_2.createTools; } });
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAqBA,0BAwBC;AAUD,kCAMC;AAUD,oCAMC;AAKD,8BAEC;AA3ED,6CAAsD;AACtD,2CAA+D;AAC/D,iCAAiD;AAEjD;;;;;;;GAOG;AACH,SAAgB,OAAO,CACrB,MAAkB,EAClB,QAAkB,EAClB,OAAwB;IAExB,MAAM,SAAS,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAC;IAEzC,uBAAuB;IACvB,IAAI,UAAU,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;IAEnC,0BAA0B;IAC1B,MAAM,YAAY,GAAG,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,CAAC;IACtH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,wBAAW,EAAC,UAAU,EAAE;QACnF,iBAAiB,EAAE,OAAO,EAAE,iBAAiB;QAC7C,YAAY;KACb,CAAC,CAAC;IAEH,qCAAqC;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE5C,4BAA4B;IAC5B,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CACzB,IAAyB,EACzB,QAAkB,EAClB,OAAwB;IAExB,OAAO,IAAA,iBAAU,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,KAA4B,EAC5B,QAAkB,EAClB,OAAwB;IAExB,OAAO,IAAA,kBAAW,EAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,IAAA,8BAAkB,GAAE,CAAC;AAC9B,CAAC;AAqBD,uBAAuB;AACvB,2CAAsD;AAA7C,uGAAA,SAAS,OAAA;AAAE,yGAAA,WAAW,OAAA;AAE/B,0DAA0D;AAC1D,yCASqB;AARnB,4GAAA,eAAe,OAAA;AACf,qHAAA,wBAAwB,OAAA;AACxB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,qHAAA,wBAAwB,OAAA;AACxB,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,0BAA0B;AAC1B,+BAAiD;AAAxC,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA"}
@@ -0,0 +1,24 @@
1
+ import type { JSONSchema, TransformationRecord } from './types';
2
+ /**
3
+ * Deep clone a JSON Schema object.
4
+ */
5
+ export declare function deepClone<T>(obj: T): T;
6
+ /**
7
+ * Normalize a JSON Schema to a canonical form (draft-2020-12 style).
8
+ * - Converts `definitions` to `$defs`
9
+ * - Handles array-form `items` to `prefixItems`
10
+ * - Strips `$schema` property
11
+ */
12
+ export declare function normalize(schema: JSONSchema): JSONSchema;
13
+ /**
14
+ * Resolve all $ref references by inlining them.
15
+ * Returns the resolved schema and a list of transformation records.
16
+ */
17
+ export declare function resolveRefs(schema: JSONSchema, options?: {
18
+ maxRecursionDepth?: number;
19
+ preserveRefs?: boolean;
20
+ }): {
21
+ schema: JSONSchema;
22
+ transformations: TransformationRecord[];
23
+ };
24
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../src/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAQtC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAGxD;AAgED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,eAAe,EAAE,oBAAoB,EAAE,CAAA;CAAE,CAkBjE"}