@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.
- package/README.md +750 -0
- package/dist/__tests__/anthropic.test.d.ts +2 -0
- package/dist/__tests__/anthropic.test.d.ts.map +1 -0
- package/dist/__tests__/anthropic.test.js +183 -0
- package/dist/__tests__/anthropic.test.js.map +1 -0
- package/dist/__tests__/gemini.test.d.ts +2 -0
- package/dist/__tests__/gemini.test.d.ts.map +1 -0
- package/dist/__tests__/gemini.test.js +177 -0
- package/dist/__tests__/gemini.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +2 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +513 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/__tests__/normalizer.test.d.ts +2 -0
- package/dist/__tests__/normalizer.test.d.ts.map +1 -0
- package/dist/__tests__/normalizer.test.js +349 -0
- package/dist/__tests__/normalizer.test.js.map +1 -0
- package/dist/__tests__/openai.test.d.ts +2 -0
- package/dist/__tests__/openai.test.d.ts.map +1 -0
- package/dist/__tests__/openai.test.js +473 -0
- package/dist/__tests__/openai.test.js.map +1 -0
- package/dist/__tests__/providers.test.d.ts +2 -0
- package/dist/__tests__/providers.test.d.ts.map +1 -0
- package/dist/__tests__/providers.test.js +187 -0
- package/dist/__tests__/providers.test.js.map +1 -0
- package/dist/__tests__/tool.test.d.ts +2 -0
- package/dist/__tests__/tool.test.d.ts.map +1 -0
- package/dist/__tests__/tool.test.js +212 -0
- package/dist/__tests__/tool.test.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/dist/normalizer.d.ts +24 -0
- package/dist/normalizer.d.ts.map +1 -0
- package/dist/normalizer.js +263 -0
- package/dist/normalizer.js.map +1 -0
- package/dist/providers/anthropic.d.ts +7 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +109 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/cohere.d.ts +8 -0
- package/dist/providers/cohere.d.ts.map +1 -0
- package/dist/providers/cohere.js +63 -0
- package/dist/providers/cohere.js.map +1 -0
- package/dist/providers/gemini.d.ts +10 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +160 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +51 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/mcp.d.ts +8 -0
- package/dist/providers/mcp.d.ts.map +1 -0
- package/dist/providers/mcp.js +18 -0
- package/dist/providers/mcp.js.map +1 -0
- package/dist/providers/ollama.d.ts +8 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +63 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +10 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +309 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/tool.d.ts +19 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +120 -0
- package/dist/tool.js.map +1 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToGemini = convertToGemini;
|
|
4
|
+
exports.wrapGeminiResponseFormat = wrapGeminiResponseFormat;
|
|
5
|
+
const normalizer_1 = require("../normalizer");
|
|
6
|
+
/**
|
|
7
|
+
* Keywords that Gemini does not support.
|
|
8
|
+
*/
|
|
9
|
+
const UNSUPPORTED_KEYWORDS = ['default', 'examples', '$comment'];
|
|
10
|
+
/**
|
|
11
|
+
* Convert a JSON Schema to Google Gemini's format.
|
|
12
|
+
*/
|
|
13
|
+
function convertToGemini(schema, options) {
|
|
14
|
+
const transformations = [];
|
|
15
|
+
const warnings = [];
|
|
16
|
+
let result = (0, normalizer_1.deepClone)(schema);
|
|
17
|
+
// Remove unsupported keywords
|
|
18
|
+
result = removeKeywords(result, '$', transformations, warnings, options);
|
|
19
|
+
// Simplify composition (limited oneOf/allOf support)
|
|
20
|
+
result = simplifyComposition(result, '$', transformations, warnings);
|
|
21
|
+
return { schema: result, transformations, warnings };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Wrap a converted schema in Gemini's response format envelope.
|
|
25
|
+
*/
|
|
26
|
+
function wrapGeminiResponseFormat(schema) {
|
|
27
|
+
return {
|
|
28
|
+
generationConfig: {
|
|
29
|
+
responseMimeType: 'application/json',
|
|
30
|
+
responseSchema: schema,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function removeKeywords(node, path, transformations, warnings, options) {
|
|
35
|
+
const result = { ...node };
|
|
36
|
+
const promote = options?.promoteConstraintsToDescription ?? false;
|
|
37
|
+
for (const keyword of UNSUPPORTED_KEYWORDS) {
|
|
38
|
+
if (keyword in result) {
|
|
39
|
+
const value = result[keyword];
|
|
40
|
+
if (promote && keyword !== '$comment' && keyword !== 'examples') {
|
|
41
|
+
const constraint = `${keyword}: ${JSON.stringify(value)}`;
|
|
42
|
+
result.description = result.description
|
|
43
|
+
? `${result.description} (${constraint})`
|
|
44
|
+
: `(${constraint})`;
|
|
45
|
+
}
|
|
46
|
+
delete result[keyword];
|
|
47
|
+
transformations.push({
|
|
48
|
+
type: 'KEYWORD_REMOVED',
|
|
49
|
+
path,
|
|
50
|
+
message: `Removed unsupported keyword "${keyword}"`,
|
|
51
|
+
lossy: keyword !== '$comment',
|
|
52
|
+
});
|
|
53
|
+
if (keyword !== '$comment') {
|
|
54
|
+
warnings.push(`Removed "${keyword}" at ${path} — Gemini does not support this keyword`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (result.properties) {
|
|
59
|
+
const newProps = {};
|
|
60
|
+
for (const [key, prop] of Object.entries(result.properties)) {
|
|
61
|
+
newProps[key] = removeKeywords(prop, `${path}.properties.${key}`, transformations, warnings, options);
|
|
62
|
+
}
|
|
63
|
+
result.properties = newProps;
|
|
64
|
+
}
|
|
65
|
+
if (result.items && !Array.isArray(result.items)) {
|
|
66
|
+
result.items = removeKeywords(result.items, `${path}.items`, transformations, warnings, options);
|
|
67
|
+
}
|
|
68
|
+
if (result.anyOf) {
|
|
69
|
+
result.anyOf = result.anyOf.map((s, i) => removeKeywords(s, `${path}.anyOf[${i}]`, transformations, warnings, options));
|
|
70
|
+
}
|
|
71
|
+
if (result.oneOf) {
|
|
72
|
+
result.oneOf = result.oneOf.map((s, i) => removeKeywords(s, `${path}.oneOf[${i}]`, transformations, warnings, options));
|
|
73
|
+
}
|
|
74
|
+
if (result.allOf) {
|
|
75
|
+
result.allOf = result.allOf.map((s, i) => removeKeywords(s, `${path}.allOf[${i}]`, transformations, warnings, options));
|
|
76
|
+
}
|
|
77
|
+
if (result.$defs) {
|
|
78
|
+
const newDefs = {};
|
|
79
|
+
for (const [key, def] of Object.entries(result.$defs)) {
|
|
80
|
+
newDefs[key] = removeKeywords(def, `${path}.$defs.${key}`, transformations, warnings, options);
|
|
81
|
+
}
|
|
82
|
+
result.$defs = newDefs;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function simplifyComposition(node, path, transformations, warnings) {
|
|
87
|
+
let result = { ...node };
|
|
88
|
+
// Merge allOf
|
|
89
|
+
if (result.allOf && result.allOf.length > 0) {
|
|
90
|
+
let merged = {};
|
|
91
|
+
for (const sub of result.allOf) {
|
|
92
|
+
merged = mergeSchemas(merged, sub);
|
|
93
|
+
}
|
|
94
|
+
const { allOf: _, ...rest } = result;
|
|
95
|
+
result = { ...rest, ...merged };
|
|
96
|
+
transformations.push({
|
|
97
|
+
type: 'COMPOSITION_SIMPLIFIED',
|
|
98
|
+
path,
|
|
99
|
+
message: 'Merged allOf schemas',
|
|
100
|
+
lossy: false,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Remove not
|
|
104
|
+
if (result.not) {
|
|
105
|
+
delete result.not;
|
|
106
|
+
transformations.push({
|
|
107
|
+
type: 'COMPOSITION_SIMPLIFIED',
|
|
108
|
+
path,
|
|
109
|
+
message: 'Removed "not" keyword',
|
|
110
|
+
lossy: true,
|
|
111
|
+
});
|
|
112
|
+
warnings.push(`Removed "not" at ${path} — Gemini has limited "not" support`);
|
|
113
|
+
}
|
|
114
|
+
// Recurse
|
|
115
|
+
if (result.properties) {
|
|
116
|
+
const newProps = {};
|
|
117
|
+
for (const [key, prop] of Object.entries(result.properties)) {
|
|
118
|
+
newProps[key] = simplifyComposition(prop, `${path}.properties.${key}`, transformations, warnings);
|
|
119
|
+
}
|
|
120
|
+
result.properties = newProps;
|
|
121
|
+
}
|
|
122
|
+
if (result.items && !Array.isArray(result.items)) {
|
|
123
|
+
result.items = simplifyComposition(result.items, `${path}.items`, transformations, warnings);
|
|
124
|
+
}
|
|
125
|
+
if (result.anyOf) {
|
|
126
|
+
result.anyOf = result.anyOf.map((s, i) => simplifyComposition(s, `${path}.anyOf[${i}]`, transformations, warnings));
|
|
127
|
+
}
|
|
128
|
+
if (result.oneOf) {
|
|
129
|
+
result.oneOf = result.oneOf.map((s, i) => simplifyComposition(s, `${path}.oneOf[${i}]`, transformations, warnings));
|
|
130
|
+
}
|
|
131
|
+
if (result.$defs) {
|
|
132
|
+
const newDefs = {};
|
|
133
|
+
for (const [key, def] of Object.entries(result.$defs)) {
|
|
134
|
+
newDefs[key] = simplifyComposition(def, `${path}.$defs.${key}`, transformations, warnings);
|
|
135
|
+
}
|
|
136
|
+
result.$defs = newDefs;
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function mergeSchemas(a, b) {
|
|
141
|
+
const result = { ...a };
|
|
142
|
+
if (b.type)
|
|
143
|
+
result.type = b.type;
|
|
144
|
+
if (b.description)
|
|
145
|
+
result.description = b.description;
|
|
146
|
+
if (b.properties) {
|
|
147
|
+
result.properties = { ...(result.properties || {}), ...b.properties };
|
|
148
|
+
}
|
|
149
|
+
if (b.required) {
|
|
150
|
+
const reqSet = new Set([...(result.required || []), ...b.required]);
|
|
151
|
+
result.required = Array.from(reqSet);
|
|
152
|
+
}
|
|
153
|
+
for (const key of Object.keys(b)) {
|
|
154
|
+
if (!(key in result)) {
|
|
155
|
+
result[key] = b[key];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/providers/gemini.ts"],"names":[],"mappings":";;AAWA,0CAYC;AAKD,4DAOC;AAlCD,8CAA0C;AAE1C;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAEjE;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAkB,EAAE,OAAwB;IAC1E,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,MAAM,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;IAE/B,8BAA8B;IAC9B,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEzE,qDAAqD;IACrD,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IAErE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;GAEG;AAC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E,CAAC;QACf,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpE,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;YACpB,MAAkC,CAAC,GAAG,CAAC,GAAI,CAA6B,CAAC,GAAG,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSONSchema, Provider, ConvertOptions, ProviderSchema } from '../types';
|
|
2
|
+
export type ProviderConverter = (schema: JSONSchema, options?: ConvertOptions) => ProviderSchema;
|
|
3
|
+
/**
|
|
4
|
+
* Get the converter function for a provider.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getConverter(provider: Provider): ProviderConverter;
|
|
7
|
+
/**
|
|
8
|
+
* List all supported provider names.
|
|
9
|
+
*/
|
|
10
|
+
export declare function supportedProviders(): Provider[];
|
|
11
|
+
export { convertToOpenAI, wrapOpenAIResponseFormat } from './openai';
|
|
12
|
+
export { convertToAnthropic } from './anthropic';
|
|
13
|
+
export { convertToGemini, wrapGeminiResponseFormat } from './gemini';
|
|
14
|
+
export { convertToCohere } from './cohere';
|
|
15
|
+
export { convertToMCP } from './mcp';
|
|
16
|
+
export { convertToOllama } from './ollama';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQrF,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,cAAc,CAAC;AAYjG;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,iBAAiB,CAMlE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,QAAQ,EAAE,CAE/C;AAED,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToOllama = exports.convertToMCP = exports.convertToCohere = exports.wrapGeminiResponseFormat = exports.convertToGemini = exports.convertToAnthropic = exports.wrapOpenAIResponseFormat = exports.convertToOpenAI = void 0;
|
|
4
|
+
exports.getConverter = getConverter;
|
|
5
|
+
exports.supportedProviders = supportedProviders;
|
|
6
|
+
const openai_1 = require("./openai");
|
|
7
|
+
const anthropic_1 = require("./anthropic");
|
|
8
|
+
const gemini_1 = require("./gemini");
|
|
9
|
+
const cohere_1 = require("./cohere");
|
|
10
|
+
const mcp_1 = require("./mcp");
|
|
11
|
+
const ollama_1 = require("./ollama");
|
|
12
|
+
const converters = {
|
|
13
|
+
openai: openai_1.convertToOpenAI,
|
|
14
|
+
anthropic: anthropic_1.convertToAnthropic,
|
|
15
|
+
gemini: gemini_1.convertToGemini,
|
|
16
|
+
cohere: cohere_1.convertToCohere,
|
|
17
|
+
mcp: mcp_1.convertToMCP,
|
|
18
|
+
'vercel-ai': mcp_1.convertToMCP, // Vercel AI uses standard JSON Schema like MCP
|
|
19
|
+
ollama: ollama_1.convertToOllama,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Get the converter function for a provider.
|
|
23
|
+
*/
|
|
24
|
+
function getConverter(provider) {
|
|
25
|
+
const converter = converters[provider];
|
|
26
|
+
if (!converter) {
|
|
27
|
+
throw new Error(`Unsupported provider: "${provider}". Supported providers: ${Object.keys(converters).join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
return converter;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List all supported provider names.
|
|
33
|
+
*/
|
|
34
|
+
function supportedProviders() {
|
|
35
|
+
return Object.keys(converters);
|
|
36
|
+
}
|
|
37
|
+
var openai_2 = require("./openai");
|
|
38
|
+
Object.defineProperty(exports, "convertToOpenAI", { enumerable: true, get: function () { return openai_2.convertToOpenAI; } });
|
|
39
|
+
Object.defineProperty(exports, "wrapOpenAIResponseFormat", { enumerable: true, get: function () { return openai_2.wrapOpenAIResponseFormat; } });
|
|
40
|
+
var anthropic_2 = require("./anthropic");
|
|
41
|
+
Object.defineProperty(exports, "convertToAnthropic", { enumerable: true, get: function () { return anthropic_2.convertToAnthropic; } });
|
|
42
|
+
var gemini_2 = require("./gemini");
|
|
43
|
+
Object.defineProperty(exports, "convertToGemini", { enumerable: true, get: function () { return gemini_2.convertToGemini; } });
|
|
44
|
+
Object.defineProperty(exports, "wrapGeminiResponseFormat", { enumerable: true, get: function () { return gemini_2.wrapGeminiResponseFormat; } });
|
|
45
|
+
var cohere_2 = require("./cohere");
|
|
46
|
+
Object.defineProperty(exports, "convertToCohere", { enumerable: true, get: function () { return cohere_2.convertToCohere; } });
|
|
47
|
+
var mcp_2 = require("./mcp");
|
|
48
|
+
Object.defineProperty(exports, "convertToMCP", { enumerable: true, get: function () { return mcp_2.convertToMCP; } });
|
|
49
|
+
var ollama_2 = require("./ollama");
|
|
50
|
+
Object.defineProperty(exports, "convertToOllama", { enumerable: true, get: function () { return ollama_2.convertToOllama; } });
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;AAuBA,oCAMC;AAKD,gDAEC;AAnCD,qCAA2C;AAC3C,2CAAiD;AACjD,qCAA2C;AAC3C,qCAA2C;AAC3C,+BAAqC;AACrC,qCAA2C;AAI3C,MAAM,UAAU,GAAsC;IACpD,MAAM,EAAE,wBAAe;IACvB,SAAS,EAAE,8BAAkB;IAC7B,MAAM,EAAE,wBAAe;IACvB,MAAM,EAAE,wBAAe;IACvB,GAAG,EAAE,kBAAY;IACjB,WAAW,EAAE,kBAAY,EAAE,+CAA+C;IAC1E,MAAM,EAAE,wBAAe;CACxB,CAAC;AAEF;;GAEG;AACH,SAAgB,YAAY,CAAC,QAAkB;IAC7C,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,2BAA2B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAe,CAAC;AAC/C,CAAC;AAED,mCAAqE;AAA5D,yGAAA,eAAe,OAAA;AAAE,kHAAA,wBAAwB,OAAA;AAClD,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA;AAC3B,mCAAqE;AAA5D,yGAAA,eAAe,OAAA;AAAE,kHAAA,wBAAwB,OAAA;AAClD,mCAA2C;AAAlC,yGAAA,eAAe,OAAA;AACxB,6BAAqC;AAA5B,mGAAA,YAAY,OAAA;AACrB,mCAA2C;AAAlC,yGAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSONSchema, ConvertOptions, ProviderSchema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a JSON Schema to MCP format.
|
|
4
|
+
* MCP supports full JSON Schema with minimal restrictions.
|
|
5
|
+
* Only $comment is removed per spec (actually MCP keeps everything; we keep it too).
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertToMCP(schema: JSONSchema, options?: ConvertOptions): ProviderSchema;
|
|
8
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/providers/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAwB,MAAM,UAAU,CAAC;AAGjG;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CASzF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToMCP = convertToMCP;
|
|
4
|
+
const normalizer_1 = require("../normalizer");
|
|
5
|
+
/**
|
|
6
|
+
* Convert a JSON Schema to MCP format.
|
|
7
|
+
* MCP supports full JSON Schema with minimal restrictions.
|
|
8
|
+
* Only $comment is removed per spec (actually MCP keeps everything; we keep it too).
|
|
9
|
+
*/
|
|
10
|
+
function convertToMCP(schema, options) {
|
|
11
|
+
const transformations = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const result = (0, normalizer_1.deepClone)(schema);
|
|
14
|
+
// MCP supports full JSON Schema — no keywords removed
|
|
15
|
+
// Per the spec keyword table, MCP keeps everything including $comment
|
|
16
|
+
return { schema: result, transformations, warnings };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/providers/mcp.ts"],"names":[],"mappings":";;AAQA,oCASC;AAhBD,8CAA0C;AAE1C;;;;GAIG;AACH,SAAgB,YAAY,CAAC,MAAkB,EAAE,OAAwB;IACvE,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;IAEjC,sDAAsD;IACtD,sEAAsE;IAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSONSchema, ConvertOptions, ProviderSchema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a JSON Schema to Ollama's format.
|
|
4
|
+
* Ollama passes JSON Schema directly in the `format` field.
|
|
5
|
+
* $ref is inlined for maximum compatibility (support varies by version).
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertToOllama(schema: JSONSchema, options?: ConvertOptions): ProviderSchema;
|
|
8
|
+
//# sourceMappingURL=ollama.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/providers/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAwB,MAAM,UAAU,CAAC;AAQjG;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAS5F"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToOllama = convertToOllama;
|
|
4
|
+
const normalizer_1 = require("../normalizer");
|
|
5
|
+
/**
|
|
6
|
+
* Keywords that Ollama does not support well.
|
|
7
|
+
*/
|
|
8
|
+
const UNSUPPORTED_KEYWORDS = ['examples', '$comment'];
|
|
9
|
+
/**
|
|
10
|
+
* Convert a JSON Schema to Ollama's format.
|
|
11
|
+
* Ollama passes JSON Schema directly in the `format` field.
|
|
12
|
+
* $ref is inlined for maximum compatibility (support varies by version).
|
|
13
|
+
*/
|
|
14
|
+
function convertToOllama(schema, options) {
|
|
15
|
+
const transformations = [];
|
|
16
|
+
const warnings = [];
|
|
17
|
+
let result = (0, normalizer_1.deepClone)(schema);
|
|
18
|
+
// Remove unsupported keywords
|
|
19
|
+
result = removeKeywords(result, '$', transformations);
|
|
20
|
+
return { schema: result, transformations, warnings };
|
|
21
|
+
}
|
|
22
|
+
function removeKeywords(node, path, transformations) {
|
|
23
|
+
const result = { ...node };
|
|
24
|
+
for (const keyword of UNSUPPORTED_KEYWORDS) {
|
|
25
|
+
if (keyword in result) {
|
|
26
|
+
delete result[keyword];
|
|
27
|
+
transformations.push({
|
|
28
|
+
type: 'KEYWORD_REMOVED',
|
|
29
|
+
path,
|
|
30
|
+
message: `Removed unsupported keyword "${keyword}"`,
|
|
31
|
+
lossy: keyword !== '$comment',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (result.properties) {
|
|
36
|
+
const newProps = {};
|
|
37
|
+
for (const [key, prop] of Object.entries(result.properties)) {
|
|
38
|
+
newProps[key] = removeKeywords(prop, `${path}.properties.${key}`, transformations);
|
|
39
|
+
}
|
|
40
|
+
result.properties = newProps;
|
|
41
|
+
}
|
|
42
|
+
if (result.items && !Array.isArray(result.items)) {
|
|
43
|
+
result.items = removeKeywords(result.items, `${path}.items`, transformations);
|
|
44
|
+
}
|
|
45
|
+
if (result.anyOf) {
|
|
46
|
+
result.anyOf = result.anyOf.map((s, i) => removeKeywords(s, `${path}.anyOf[${i}]`, transformations));
|
|
47
|
+
}
|
|
48
|
+
if (result.oneOf) {
|
|
49
|
+
result.oneOf = result.oneOf.map((s, i) => removeKeywords(s, `${path}.oneOf[${i}]`, transformations));
|
|
50
|
+
}
|
|
51
|
+
if (result.allOf) {
|
|
52
|
+
result.allOf = result.allOf.map((s, i) => removeKeywords(s, `${path}.allOf[${i}]`, transformations));
|
|
53
|
+
}
|
|
54
|
+
if (result.$defs) {
|
|
55
|
+
const newDefs = {};
|
|
56
|
+
for (const [key, def] of Object.entries(result.$defs)) {
|
|
57
|
+
newDefs[key] = removeKeywords(def, `${path}.$defs.${key}`, transformations);
|
|
58
|
+
}
|
|
59
|
+
result.$defs = newDefs;
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=ollama.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/providers/ollama.ts"],"names":[],"mappings":";;AAaA,0CASC;AArBD,8CAA0C;AAE1C;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEtD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,MAAkB,EAAE,OAAwB;IAC1E,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,MAAM,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;IAE/B,8BAA8B;IAC9B,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC;IAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,cAAc,CACrB,IAAgB,EAChB,IAAY,EACZ,eAAuC;IAEvC,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;I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,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACvC,cAAc,CAAC,CAAC,EAAE,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACvC,cAAc,CAAC,CAAC,EAAE,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,OAAO,GAA+B,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,IAAI,UAAU,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSONSchema, ConvertOptions, ProviderSchema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a JSON Schema to OpenAI's structured output format.
|
|
4
|
+
*/
|
|
5
|
+
export declare function convertToOpenAI(schema: JSONSchema, options?: ConvertOptions): ProviderSchema;
|
|
6
|
+
/**
|
|
7
|
+
* Wrap a converted schema in OpenAI's response_format envelope.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrapOpenAIResponseFormat(schema: JSONSchema, name: string, strict?: boolean): Record<string, unknown>;
|
|
10
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAwB,MAAM,UAAU,CAAC;AAYjG;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAqB5F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,OAAc,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB"}
|