tool-schema 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/util.ts","../src/targets/openai.ts","../src/targets/anthropic.ts","../src/targets/gemini.ts","../src/targets/mcp.ts","../src/transform.ts"],"sourcesContent":["export { toToolSchema, toTool, lintToolSchema } from './transform.js';\nexport type {\n JSONSchema,\n Target,\n Warning,\n WarningCode,\n TransformResult,\n ToolSchemaOptions,\n ToolDefinition,\n ToolResult,\n LintResult,\n McpAnnotations,\n} from './types.js';\n","import type { JSONSchema, Warning, WarningCode } from './types.js';\n\n/** Collects warnings and tracks whether the conversion lost information. */\nexport class Warnings {\n readonly list: Warning[] = [];\n lossy = false;\n\n add(path: string, code: WarningCode, message: string, lossy = true): void {\n this.list.push({ path, code, message });\n if (lossy) this.lossy = true;\n }\n}\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** A deep, structurally faithful clone. Uses the platform `structuredClone`. */\nexport function clone<T>(value: T): T {\n return structuredClone(value);\n}\n\n/** Returns the schema's declared types as an array (empty when untyped). */\nexport function typesOf(schema: JSONSchema): string[] {\n if (typeof schema.type === 'string') return [schema.type];\n if (Array.isArray(schema.type)) return schema.type.filter((t) => typeof t === 'string');\n return [];\n}\n\n/**\n * Heuristic: does this node describe an object? True when `type` is `object`\n * (or a union containing it) or when it is untyped but carries object keywords.\n */\nexport function isObjectSchema(schema: JSONSchema): boolean {\n const types = typesOf(schema);\n if (types.includes('object')) return true;\n if (types.length > 0) return false;\n return isPlainObject(schema.properties) || schema.additionalProperties !== undefined;\n}\n\n/**\n * Makes a schema accept `null`. Adds `null` to a string/array `type`, appends a\n * `{ type: 'null' }` branch to an `anyOf`, otherwise wraps the node in an\n * `anyOf` with a null branch. Used by OpenAI strict mode where every property\n * must be `required`, so optional fields are expressed as nullable instead.\n */\nexport function makeNullable(schema: JSONSchema): JSONSchema {\n if (typeof schema.type === 'string') {\n if (schema.type === 'null') return schema;\n return { ...schema, type: [schema.type, 'null'] };\n }\n if (Array.isArray(schema.type)) {\n if (schema.type.includes('null')) return schema;\n return { ...schema, type: [...schema.type, 'null'] };\n }\n if (Array.isArray(schema.anyOf)) {\n if (schema.anyOf.some((b) => typesOf(b).includes('null'))) return schema;\n return { ...schema, anyOf: [...schema.anyOf, { type: 'null' }] };\n }\n return { anyOf: [schema, { type: 'null' }] };\n}\n\n/**\n * Resolves local `$ref` pointers (`#/$defs/...` or `#/definitions/...`) by\n * inlining them. Non local refs are left untouched. Recursive refs are replaced\n * with an empty schema and reported, since target dialects that need inlining\n * (Gemini route A) cannot express recursion.\n */\nexport function dereference(root: JSONSchema, warnings: Warnings): JSONSchema {\n const defs: Record<string, JSONSchema> = {\n ...(isPlainObject(root.definitions) ? (root.definitions as Record<string, JSONSchema>) : {}),\n ...(isPlainObject(root.$defs) ? (root.$defs as Record<string, JSONSchema>) : {}),\n };\n\n const resolve = (ref: string): JSONSchema | undefined => {\n const m = /^#\\/(?:\\$defs|definitions)\\/(.+)$/.exec(ref);\n if (!m) return undefined;\n const key = decodeURIComponent(m[1].replace(/~1/g, '/').replace(/~0/g, '~'));\n return defs[key];\n };\n\n const walk = (node: JSONSchema, path: string, seen: Set<string>): JSONSchema => {\n if (!isPlainObject(node)) return node;\n if (typeof node.$ref === 'string') {\n const ref = node.$ref;\n const target = resolve(ref);\n if (!target) return node; // leave external / unknown refs in place\n if (seen.has(ref)) {\n warnings.add(path, 'recursive-ref', `Recursive $ref '${ref}' cannot be inlined; replaced with an open schema.`);\n return {};\n }\n const { $ref: _drop, ...rest } = node;\n void _drop;\n warnings.add(path, 'inlined-ref', `Inlined $ref '${ref}'.`, false);\n const merged = { ...clone(target), ...rest };\n return walk(merged, path, new Set([...seen, ref]));\n }\n return mapChildren(node, path, (child, childPath) => walk(child, childPath, seen));\n };\n\n const out = walk(clone(root), '#', new Set());\n delete out.$defs;\n delete out.definitions;\n return out;\n}\n\n/**\n * Applies `fn` to every direct sub schema of `node`, returning a new node. Walks\n * the standard applicator keywords. Leaf keywords are copied as is.\n */\nexport function mapChildren(\n node: JSONSchema,\n path: string,\n fn: (child: JSONSchema, childPath: string) => JSONSchema,\n): JSONSchema {\n const out: JSONSchema = { ...node };\n\n if (isPlainObject(out.properties)) {\n const props: Record<string, JSONSchema> = {};\n for (const [k, v] of Object.entries(out.properties as Record<string, JSONSchema>)) {\n props[k] = fn(v, `${path}/properties/${k}`);\n }\n out.properties = props;\n }\n\n if (Array.isArray(out.items)) {\n out.items = out.items.map((it, i) => fn(it, `${path}/items/${i}`));\n } else if (isPlainObject(out.items)) {\n out.items = fn(out.items as JSONSchema, `${path}/items`);\n }\n\n if (isPlainObject(out.additionalProperties)) {\n out.additionalProperties = fn(out.additionalProperties as JSONSchema, `${path}/additionalProperties`);\n }\n\n for (const key of ['anyOf', 'oneOf', 'allOf'] as const) {\n const arr = out[key];\n if (Array.isArray(arr)) {\n out[key] = arr.map((b, i) => fn(b, `${path}/${key}/${i}`));\n }\n }\n\n if (isPlainObject(out.not)) out.not = fn(out.not as JSONSchema, `${path}/not`);\n for (const key of ['if', 'then', 'else'] as const) {\n if (isPlainObject(out[key])) out[key] = fn(out[key] as JSONSchema, `${path}/${key}`);\n }\n\n if (isPlainObject(out.patternProperties)) {\n const pp: Record<string, JSONSchema> = {};\n for (const [k, v] of Object.entries(out.patternProperties as Record<string, JSONSchema>)) {\n pp[k] = fn(v, `${path}/patternProperties/${k}`);\n }\n out.patternProperties = pp;\n }\n\n for (const key of ['$defs', 'definitions', 'dependentSchemas'] as const) {\n const map = out[key];\n if (isPlainObject(map)) {\n const next: Record<string, JSONSchema> = {};\n for (const [k, v] of Object.entries(map as Record<string, JSONSchema>)) {\n next[k] = fn(v as JSONSchema, `${path}/${key}/${k}`);\n }\n out[key] = next;\n }\n }\n\n return out;\n}\n\n/** Ensures the root is an object schema, reporting when it was not. */\nexport function ensureObjectRoot(schema: JSONSchema, warnings: Warnings, target: string): JSONSchema {\n if (isObjectSchema(schema)) {\n if (typesOf(schema).length === 0) return { type: 'object', ...schema };\n return schema;\n }\n warnings.add(\n '#',\n 'root-not-object',\n `${target} requires the root schema to be an object; wrapped the schema under a 'value' property.`,\n );\n return {\n type: 'object',\n properties: { value: schema },\n required: ['value'],\n };\n}\n","import type { JSONSchema, TransformResult } from '../types.js';\nimport {\n Warnings,\n clone,\n isObjectSchema,\n isPlainObject,\n makeNullable,\n mapChildren,\n ensureObjectRoot,\n} from '../util.js';\n\n/** Formats OpenAI Structured Outputs accepts. Others are dropped in strict mode. */\nconst FORMAT_WHITELIST = new Set([\n 'date-time',\n 'time',\n 'date',\n 'duration',\n 'email',\n 'hostname',\n 'ipv4',\n 'ipv6',\n 'uuid',\n]);\n\n/** Keywords OpenAI strict mode rejects outright. */\nconst UNSUPPORTED = [\n 'not',\n 'if',\n 'then',\n 'else',\n 'dependentRequired',\n 'dependentSchemas',\n 'patternProperties',\n 'unevaluatedProperties',\n] as const;\n\nconst MAX_PROPERTIES = 5000;\nconst MAX_DEPTH = 10;\nconst MAX_ENUM_VALUES = 1000;\n\n/** OpenAI non strict: tool parameters should be an object, otherwise pass through. */\nexport function toOpenAI(input: JSONSchema): TransformResult {\n const warnings = new Warnings();\n const schema = ensureObjectRoot(clone(input), warnings, 'OpenAI');\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n\n/**\n * OpenAI Structured Outputs / `strict: true`. Enforces: every object has\n * `additionalProperties: false`; every property is `required` (optional ones\n * become nullable); unsupported keywords are stripped; `allOf` is merged; only\n * whitelisted `format` values survive. `$defs` / `$ref` and `anyOf` are kept.\n */\nexport function toOpenAIStrict(input: JSONSchema): TransformResult {\n const warnings = new Warnings();\n\n const transform = (node: JSONSchema, path: string): JSONSchema => {\n if (!isPlainObject(node)) return node;\n let s: JSONSchema = { ...node };\n\n if (Array.isArray(s.allOf)) {\n s = mergeAllOf(s, path, warnings);\n }\n\n for (const kw of UNSUPPORTED) {\n if (kw in s) {\n delete s[kw];\n warnings.add(path, 'stripped-keyword', `'${kw}' is not supported in OpenAI strict mode; removed.`);\n }\n }\n\n if (typeof s.format === 'string' && !FORMAT_WHITELIST.has(s.format)) {\n warnings.add(\n `${path}/format`,\n 'unsupported-format',\n `format '${s.format}' is not in OpenAI's whitelist; removed.`,\n );\n delete s.format;\n }\n\n // Recurse into all sub schemas first (anyOf branches, items, $defs, ...).\n s = mapChildren(s, path, transform);\n\n if (isObjectSchema(s) && isPlainObject(s.properties)) {\n const props = s.properties as Record<string, JSONSchema>;\n const originalRequired = new Set(Array.isArray(s.required) ? s.required : []);\n const nextProps: Record<string, JSONSchema> = {};\n for (const key of Object.keys(props)) {\n let child = props[key];\n if (!originalRequired.has(key)) {\n child = makeNullable(child);\n warnings.add(\n `${path}/properties/${key}`,\n 'forced-required',\n `Optional property '${key}' was made required and nullable for OpenAI strict mode.`,\n );\n }\n nextProps[key] = child;\n }\n s.properties = nextProps;\n s.required = Object.keys(nextProps);\n if (s.additionalProperties !== false) {\n warnings.add(\n path,\n 'forced-additional-properties',\n \"Set 'additionalProperties: false' as required by strict mode.\",\n false,\n );\n }\n s.additionalProperties = false;\n } else if (isObjectSchema(s)) {\n // Object without declared properties: strict mode still forbids extra keys.\n if (s.additionalProperties !== false) {\n warnings.add(\n path,\n 'forced-additional-properties',\n \"Set 'additionalProperties: false' on a property-less object.\",\n false,\n );\n }\n s.additionalProperties = false;\n }\n\n return s;\n };\n\n const schema = ensureObjectRoot(transform(clone(input), '#'), warnings, 'OpenAI strict mode');\n checkLimits(schema, warnings);\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n\n/** Shallow merges `allOf` object subschemas into the parent, then drops `allOf`. */\nfunction mergeAllOf(node: JSONSchema, path: string, warnings: Warnings): JSONSchema {\n const parts = node.allOf as JSONSchema[];\n const { allOf: _drop, ...base } = node;\n void _drop;\n const merged: JSONSchema = { ...base };\n const props: Record<string, JSONSchema> = isPlainObject(merged.properties)\n ? { ...(merged.properties as Record<string, JSONSchema>) }\n : {};\n const required = new Set<string>(Array.isArray(merged.required) ? merged.required : []);\n\n for (const part of parts) {\n if (!isPlainObject(part)) continue;\n if (isPlainObject(part.properties)) {\n Object.assign(props, part.properties);\n }\n if (Array.isArray(part.required)) {\n for (const r of part.required) required.add(r);\n }\n if (part.type && !merged.type) merged.type = part.type;\n }\n\n if (Object.keys(props).length > 0) merged.properties = props;\n if (required.size > 0) merged.required = [...required];\n if (!merged.type && (merged.properties || isObjectSchema(merged))) merged.type = 'object';\n warnings.add(path, 'merged-allof', \"Merged 'allOf' subschemas into the parent (unsupported in strict mode).\");\n return merged;\n}\n\nfunction checkLimits(schema: JSONSchema, warnings: Warnings): void {\n let propertyCount = 0;\n let maxDepth = 0;\n\n const visit = (node: JSONSchema, depth: number): void => {\n if (!isPlainObject(node)) return;\n maxDepth = Math.max(maxDepth, depth);\n if (isPlainObject(node.properties)) {\n const keys = Object.keys(node.properties as Record<string, JSONSchema>);\n propertyCount += keys.length;\n }\n if (Array.isArray(node.enum) && node.enum.length > MAX_ENUM_VALUES) {\n warnings.add(\n '#',\n 'limit-exceeded',\n `An enum has ${node.enum.length} values; OpenAI allows at most ${MAX_ENUM_VALUES}.`,\n false,\n );\n }\n const children = collectChildren(node);\n for (const c of children) visit(c, depth + 1);\n };\n\n visit(schema, 0);\n if (propertyCount > MAX_PROPERTIES) {\n warnings.add(\n '#',\n 'limit-exceeded',\n `Schema has ${propertyCount} object properties; OpenAI allows at most ${MAX_PROPERTIES}.`,\n false,\n );\n }\n if (maxDepth > MAX_DEPTH) {\n warnings.add(\n '#',\n 'limit-exceeded',\n `Schema nests ${maxDepth} levels deep; OpenAI allows at most ${MAX_DEPTH}.`,\n false,\n );\n }\n}\n\nfunction collectChildren(node: JSONSchema): JSONSchema[] {\n const out: JSONSchema[] = [];\n if (isPlainObject(node.properties)) out.push(...Object.values(node.properties as Record<string, JSONSchema>));\n if (Array.isArray(node.items)) out.push(...node.items);\n else if (isPlainObject(node.items)) out.push(node.items as JSONSchema);\n for (const key of ['anyOf', 'oneOf', 'allOf'] as const) {\n const arr = node[key];\n if (Array.isArray(arr)) out.push(...arr);\n }\n if (isPlainObject(node.$defs)) out.push(...Object.values(node.$defs as Record<string, JSONSchema>));\n return out.filter(isPlainObject) as JSONSchema[];\n}\n","import type { JSONSchema, TransformResult } from '../types.js';\nimport { Warnings, clone, ensureObjectRoot } from '../util.js';\n\n/**\n * Anthropic tool use. The API is permissive: it accepts standard JSON Schema for\n * `input_schema` (anyOf, oneOf, allOf, $ref, format, pattern, ...). The only hard\n * requirement is that the root is an object, so that is all we enforce.\n */\nexport function toAnthropic(input: JSONSchema): TransformResult {\n const warnings = new Warnings();\n const schema = ensureObjectRoot(clone(input), warnings, 'Anthropic');\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n","import type { JSONSchema, TransformResult } from '../types.js';\nimport { Warnings, clone, dereference, ensureObjectRoot, isPlainObject, mapChildren, typesOf } from '../util.js';\n\n/**\n * Keywords absent from Gemini's `Schema` proto (route A). Sending them either\n * errors or is silently ignored, so they are stripped.\n */\nconst STRIP = [\n '$schema',\n '$id',\n '$anchor',\n '$ref',\n 'oneOf',\n 'allOf',\n 'not',\n 'if',\n 'then',\n 'else',\n 'additionalProperties',\n 'patternProperties',\n 'unevaluatedProperties',\n 'const',\n 'dependentRequired',\n 'dependentSchemas',\n 'multipleOf',\n 'exclusiveMinimum',\n 'exclusiveMaximum',\n 'uniqueItems',\n 'contentEncoding',\n 'contentMediaType',\n '$defs',\n 'definitions',\n] as const;\n\nconst TYPE_UPPER: Record<string, string> = {\n string: 'STRING',\n number: 'NUMBER',\n integer: 'INTEGER',\n boolean: 'BOOLEAN',\n array: 'ARRAY',\n object: 'OBJECT',\n null: 'NULL',\n};\n\ninterface GeminiOptions {\n uppercaseTypes?: boolean;\n}\n\n/**\n * Gemini function calling, route A (`parameters` as an OpenAPI 3.0 subset).\n * Inlines `$ref`, strips unsupported keywords, converts nullable unions to\n * `nullable: true`, collapses `anyOf` null branches, and coerces enum values to\n * strings. Use the `gemini-jsonschema` target for the richer\n * `parametersJsonSchema` route.\n */\nexport function toGemini(input: JSONSchema, options: GeminiOptions = {}): TransformResult {\n const warnings = new Warnings();\n const dereferenced = dereference(clone(input), warnings);\n\n const transform = (node: JSONSchema, path: string): JSONSchema => {\n if (!isPlainObject(node)) return node;\n let s: JSONSchema = { ...node };\n\n for (const kw of STRIP) {\n if (kw in s) {\n delete s[kw];\n warnings.add(path, 'stripped-keyword', `'${kw}' is not supported by Gemini (route A); removed.`);\n }\n }\n\n s = collapseNullableUnion(s, path, warnings);\n s = mapChildren(s, path, transform);\n s = collapseAnyOf(s, path, warnings);\n coerceEnum(s, path, warnings);\n return s;\n };\n\n let schema = ensureObjectRoot(transform(dereferenced, '#'), warnings, 'Gemini');\n if (options.uppercaseTypes) schema = uppercaseTypes(schema);\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n\n/** Final pass: rewrite JSON Schema type names to Gemini's upper case enum. */\nfunction uppercaseTypes(node: JSONSchema): JSONSchema {\n if (!isPlainObject(node)) return node;\n const out: JSONSchema = { ...node };\n if (typeof out.type === 'string') {\n out.type = TYPE_UPPER[out.type] ?? out.type;\n } else if (Array.isArray(out.type)) {\n out.type = out.type.map((t) => TYPE_UPPER[t] ?? t);\n }\n return mapChildren(out, '#', (child) => uppercaseTypes(child));\n}\n\n/** Gemini route B (`parametersJsonSchema`): richer JSON Schema, object root only. */\nexport function toGeminiJsonSchema(input: JSONSchema): TransformResult {\n const warnings = new Warnings();\n const schema = ensureObjectRoot(clone(input), warnings, 'Gemini (parametersJsonSchema)');\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n\n/** Converts `type: ['string', 'null']` into `type: 'string', nullable: true`. */\nfunction collapseNullableUnion(node: JSONSchema, path: string, warnings: Warnings): JSONSchema {\n if (!Array.isArray(node.type)) return node;\n const nonNull = node.type.filter((t) => t !== 'null');\n const hadNull = node.type.includes('null');\n const out: JSONSchema = { ...node };\n if (nonNull.length === 0) {\n out.type = 'string';\n } else {\n out.type = nonNull[0];\n if (nonNull.length > 1) {\n warnings.add(\n path,\n 'union-types',\n `Gemini cannot express a union of types [${nonNull.join(', ')}]; kept '${nonNull[0]}'.`,\n );\n }\n }\n if (hadNull) {\n out.nullable = true;\n warnings.add(path, 'collapsed-nullable', \"Converted nullable type union into 'nullable: true'.\", false);\n }\n return out;\n}\n\n/** Removes `{ type: 'null' }` branches from `anyOf`, mapping them to `nullable`. */\nfunction collapseAnyOf(node: JSONSchema, path: string, warnings: Warnings): JSONSchema {\n if (!Array.isArray(node.anyOf)) return node;\n const branches = node.anyOf as JSONSchema[];\n const nonNull = branches.filter((b) => !(typesOf(b).length === 1 && typesOf(b)[0] === 'null'));\n const hadNull = nonNull.length !== branches.length;\n const out: JSONSchema = { ...node };\n\n if (hadNull) {\n out.nullable = true;\n warnings.add(path, 'collapsed-nullable', \"Converted an anyOf null branch into 'nullable: true'.\", false);\n }\n\n if (nonNull.length === 0) {\n delete out.anyOf;\n if (!out.type) out.type = 'string';\n } else if (nonNull.length === 1) {\n // Flatten a single remaining branch into the parent.\n delete out.anyOf;\n const branch = nonNull[0];\n for (const [k, v] of Object.entries(branch)) {\n if (k === 'description' && out.description) continue;\n out[k] = v;\n }\n } else {\n out.anyOf = nonNull;\n }\n return out;\n}\n\n/** Gemini enum values must be strings. Coerces and reports when they were not. */\nfunction coerceEnum(node: JSONSchema, path: string, warnings: Warnings): void {\n if (!Array.isArray(node.enum)) return;\n const allStrings = node.enum.every((v) => typeof v === 'string');\n if (!allStrings) {\n node.enum = node.enum.map((v) => String(v));\n warnings.add(`${path}/enum`, 'enum-coerced', 'Gemini enum values must be strings; coerced non string values.');\n }\n if (!node.type) node.type = 'string';\n}\n","import type { JSONSchema, TransformResult } from '../types.js';\nimport { Warnings, clone, ensureObjectRoot } from '../util.js';\n\n/**\n * MCP (Model Context Protocol) tools. The most permissive target: `inputSchema`\n * is standard JSON Schema and the spec only requires the root to be an object.\n * All keywords are preserved.\n */\nexport function toMcp(input: JSONSchema): TransformResult {\n const warnings = new Warnings();\n const schema = ensureObjectRoot(clone(input), warnings, 'MCP');\n return { schema, warnings: warnings.list, lossy: warnings.lossy };\n}\n","import type {\n JSONSchema,\n LintResult,\n Target,\n ToolDefinition,\n ToolResult,\n ToolSchemaOptions,\n TransformResult,\n Warning,\n} from './types.js';\nimport { toOpenAI, toOpenAIStrict } from './targets/openai.js';\nimport { toAnthropic } from './targets/anthropic.js';\nimport { toGemini, toGeminiJsonSchema } from './targets/gemini.js';\nimport { toMcp } from './targets/mcp.js';\n\nconst EMPTY_OBJECT_SCHEMA: JSONSchema = { type: 'object', properties: {} };\n\n/**\n * Convert any JSON Schema into a schema that is valid for a provider's tool /\n * function calling parameters.\n *\n * @example\n * const { schema, warnings } = toToolSchema(mySchema, { target: 'openai-strict' });\n */\nexport function toToolSchema(schema: JSONSchema, options: ToolSchemaOptions = {}): TransformResult {\n const target = options.target ?? 'openai';\n switch (target) {\n case 'openai':\n return toOpenAI(schema);\n case 'openai-strict':\n return toOpenAIStrict(schema);\n case 'anthropic':\n return toAnthropic(schema);\n case 'gemini':\n return toGemini(schema, { uppercaseTypes: options.geminiUppercaseTypes });\n case 'gemini-jsonschema':\n return toGeminiJsonSchema(schema);\n case 'mcp':\n return toMcp(schema);\n default:\n throw new Error(`Unknown target: ${String(target satisfies never)}`);\n }\n}\n\n/**\n * Build a complete, provider shaped tool / function declaration: the right\n * wrapper keys (`function`, `input_schema`, `parameters`, `inputSchema`), the\n * converted parameter schema, and provider specific extras such as `strict` or\n * MCP `annotations`.\n */\nexport function toTool(def: ToolDefinition, options: ToolSchemaOptions = {}): ToolResult {\n const target = options.target ?? 'openai';\n const result = toToolSchema(def.schema ?? EMPTY_OBJECT_SCHEMA, options);\n const warnings: Warning[] = [...result.warnings];\n validateName(def.name, target, warnings);\n\n const tool = buildTool(def, result.schema, target, options);\n return { tool, warnings, lossy: result.lossy };\n}\n\n/**\n * Report what would change to make `schema` valid for a target, without\n * applying it. `ok` is true when the schema is already conformant.\n */\nexport function lintToolSchema(schema: JSONSchema, options: ToolSchemaOptions = {}): LintResult {\n const { warnings } = toToolSchema(schema, options);\n return { ok: warnings.length === 0, issues: warnings };\n}\n\nfunction buildTool(\n def: ToolDefinition,\n schema: JSONSchema,\n target: Target,\n options: ToolSchemaOptions,\n): Record<string, unknown> {\n const { name, description } = def;\n\n switch (target) {\n case 'openai':\n case 'openai-strict': {\n const strict = target === 'openai-strict';\n if (options.openaiResponses) {\n return {\n type: 'function',\n name,\n ...(description ? { description } : {}),\n parameters: schema,\n ...(strict ? { strict: true } : {}),\n };\n }\n return {\n type: 'function',\n function: {\n name,\n ...(description ? { description } : {}),\n parameters: schema,\n ...(strict ? { strict: true } : {}),\n },\n };\n }\n case 'anthropic':\n return {\n name,\n ...(description ? { description } : {}),\n input_schema: schema,\n ...(options.anthropicStrict ? { strict: true } : {}),\n };\n case 'gemini':\n return {\n name,\n ...(description ? { description } : {}),\n parameters: schema,\n };\n case 'gemini-jsonschema':\n return {\n name,\n ...(description ? { description } : {}),\n parametersJsonSchema: schema,\n };\n case 'mcp':\n return {\n name,\n ...(description ? { description } : {}),\n inputSchema: schema,\n ...(def.annotations ? { annotations: def.annotations } : {}),\n };\n default:\n throw new Error(`Unknown target: ${String(target satisfies never)}`);\n }\n}\n\nconst NAME_RULES: Record<Target, { pattern: RegExp; label: string }> = {\n openai: { pattern: /^[a-zA-Z0-9_-]{1,64}$/, label: 'OpenAI (letters, digits, _ and -, max 64)' },\n 'openai-strict': { pattern: /^[a-zA-Z0-9_-]{1,64}$/, label: 'OpenAI (letters, digits, _ and -, max 64)' },\n anthropic: { pattern: /^[a-zA-Z0-9_-]{1,64}$/, label: 'Anthropic (letters, digits, _ and -, max 64)' },\n gemini: { pattern: /^[a-zA-Z0-9_:.-]{1,128}$/, label: 'Gemini (letters, digits, _ : . -, max 128)' },\n 'gemini-jsonschema': { pattern: /^[a-zA-Z0-9_:.-]{1,128}$/, label: 'Gemini (letters, digits, _ : . -, max 128)' },\n mcp: { pattern: /^[a-zA-Z0-9_-]{1,128}$/, label: 'MCP (letters, digits, _ and -)' },\n};\n\nfunction validateName(name: string, target: Target, warnings: Warning[]): void {\n const rule = NAME_RULES[target];\n if (!rule.pattern.test(name)) {\n warnings.push({\n path: '#/name',\n code: 'invalid-name',\n message: `Tool name '${name}' does not match the ${rule.label} naming rule.`,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,WAAN,MAAe;AAAA,EACX,OAAkB,CAAC;AAAA,EAC5B,QAAQ;AAAA,EAER,IAAI,MAAc,MAAmB,SAAiB,QAAQ,MAAY;AACxE,SAAK,KAAK,KAAK,EAAE,MAAM,MAAM,QAAQ,CAAC;AACtC,QAAI,MAAO,MAAK,QAAQ;AAAA,EAC1B;AACF;AAEO,SAAS,cAAc,OAAkD;AAC9E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAGO,SAAS,MAAS,OAAa;AACpC,SAAO,gBAAgB,KAAK;AAC9B;AAGO,SAAS,QAAQ,QAA8B;AACpD,MAAI,OAAO,OAAO,SAAS,SAAU,QAAO,CAAC,OAAO,IAAI;AACxD,MAAI,MAAM,QAAQ,OAAO,IAAI,EAAG,QAAO,OAAO,KAAK,OAAO,CAAC,MAAM,OAAO,MAAM,QAAQ;AACtF,SAAO,CAAC;AACV;AAMO,SAAS,eAAe,QAA6B;AAC1D,QAAM,QAAQ,QAAQ,MAAM;AAC5B,MAAI,MAAM,SAAS,QAAQ,EAAG,QAAO;AACrC,MAAI,MAAM,SAAS,EAAG,QAAO;AAC7B,SAAO,cAAc,OAAO,UAAU,KAAK,OAAO,yBAAyB;AAC7E;AAQO,SAAS,aAAa,QAAgC;AAC3D,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yBAAyB,OAAO,4CAA4C;AAAA,EACxG,WAAW,EAAE,SAAS,yBAAyB,OAAO,+CAA+C;AAAA,EACrG,QAAQ,EAAE,SAAS,4BAA4B,OAAO,6CAA6C;AAAA,EACnG,qBAAqB,EAAE,SAAS,4BAA4B,OAAO,6CAA6C;AAAA,EAChH,KAAK,EAAE,SAAS,0BAA0B,OAAO,iCAAiC;AACpF;AAEA,SAAS,aAAa,MAAc,QAAgB,UAA2B;AAC7E,QAAM,OAAO,WAAW,MAAM;AAC9B,MAAI,CAAC,KAAK,QAAQ,KAAK,IAAI,GAAG;AAC5B,aAAS,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,cAAc,IAAI,wBAAwB,KAAK,KAAK;AAAA,IAC/D,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * A JSON Schema object. Intentionally loose: tool-schema accepts schemas from
3
+ * many sources (hand written, OpenAPI, `z.toJSONSchema()`, codegen) so the input
4
+ * type stays permissive. The public result types below are strict.
5
+ */
6
+ interface JSONSchema {
7
+ type?: string | string[];
8
+ properties?: Record<string, JSONSchema>;
9
+ required?: string[];
10
+ items?: JSONSchema | JSONSchema[];
11
+ additionalProperties?: boolean | JSONSchema;
12
+ enum?: unknown[];
13
+ const?: unknown;
14
+ anyOf?: JSONSchema[];
15
+ oneOf?: JSONSchema[];
16
+ allOf?: JSONSchema[];
17
+ not?: JSONSchema;
18
+ $ref?: string;
19
+ $defs?: Record<string, JSONSchema>;
20
+ definitions?: Record<string, JSONSchema>;
21
+ description?: string;
22
+ title?: string;
23
+ format?: string;
24
+ pattern?: string;
25
+ default?: unknown;
26
+ nullable?: boolean;
27
+ propertyOrdering?: string[];
28
+ [key: string]: unknown;
29
+ }
30
+ /** A provider target for tool / function calling. */
31
+ type Target = 'openai' | 'openai-strict' | 'anthropic' | 'gemini' | 'gemini-jsonschema' | 'mcp';
32
+ /** A non fatal adjustment made while converting a schema to a target. */
33
+ interface Warning {
34
+ /** JSON Pointer style path to the node where the change happened. */
35
+ path: string;
36
+ /** Stable machine readable code (e.g. `stripped-keyword`). */
37
+ code: WarningCode;
38
+ /** Human readable explanation. */
39
+ message: string;
40
+ }
41
+ type WarningCode = 'stripped-keyword' | 'unsupported-format' | 'forced-required' | 'forced-additional-properties' | 'root-not-object' | 'merged-allof' | 'inlined-ref' | 'recursive-ref' | 'collapsed-nullable' | 'union-types' | 'enum-coerced' | 'invalid-name' | 'limit-exceeded';
42
+ /** Result of converting a schema for a target. */
43
+ interface TransformResult {
44
+ /** The provider valid schema. */
45
+ schema: JSONSchema;
46
+ /** Every adjustment made during conversion. Empty means the input was already valid. */
47
+ warnings: Warning[];
48
+ /** True when conversion dropped information (a keyword or constraint was removed). */
49
+ lossy: boolean;
50
+ }
51
+ /** Options accepted by {@link toToolSchema} and {@link toTool}. */
52
+ interface ToolSchemaOptions {
53
+ /** Provider target. Defaults to `'openai'`. */
54
+ target?: Target;
55
+ /**
56
+ * For the `gemini` target, emit upper case OpenAPI type names (`STRING`,
57
+ * `OBJECT`, ...) as required by the raw REST `Schema` proto. Most official
58
+ * SDKs accept lower case and normalize, so this defaults to `false`.
59
+ */
60
+ geminiUppercaseTypes?: boolean;
61
+ /**
62
+ * For OpenAI targets, emit the flattened Responses API tool shape
63
+ * (`{ type, name, description, parameters, strict }`) instead of the nested
64
+ * Chat Completions shape (`{ type, function: { ... } }`). Defaults to `false`.
65
+ */
66
+ openaiResponses?: boolean;
67
+ /** For the `anthropic` target, add `strict: true` to the tool definition. */
68
+ anthropicStrict?: boolean;
69
+ }
70
+ /** MCP tool behavioural hints. See the Model Context Protocol spec. */
71
+ interface McpAnnotations {
72
+ title?: string;
73
+ readOnlyHint?: boolean;
74
+ destructiveHint?: boolean;
75
+ idempotentHint?: boolean;
76
+ openWorldHint?: boolean;
77
+ }
78
+ /** Input to {@link toTool}. */
79
+ interface ToolDefinition {
80
+ /** Tool / function name. */
81
+ name: string;
82
+ /** What the tool does. Strongly recommended: models use it to choose tools. */
83
+ description?: string;
84
+ /** The parameters / input schema. Defaults to an empty object schema. */
85
+ schema?: JSONSchema;
86
+ /** MCP only: behavioural hints surfaced to clients. */
87
+ annotations?: McpAnnotations;
88
+ }
89
+ /** Result of {@link toTool}: a provider shaped tool plus conversion metadata. */
90
+ interface ToolResult {
91
+ /** The provider shaped tool / function declaration. */
92
+ tool: Record<string, unknown>;
93
+ warnings: Warning[];
94
+ lossy: boolean;
95
+ }
96
+ /** Result of {@link lintToolSchema}. */
97
+ interface LintResult {
98
+ /** True when the schema was already valid for the target with no changes. */
99
+ ok: boolean;
100
+ /** The changes that would be required to make it valid. */
101
+ issues: Warning[];
102
+ }
103
+
104
+ /**
105
+ * Convert any JSON Schema into a schema that is valid for a provider's tool /
106
+ * function calling parameters.
107
+ *
108
+ * @example
109
+ * const { schema, warnings } = toToolSchema(mySchema, { target: 'openai-strict' });
110
+ */
111
+ declare function toToolSchema(schema: JSONSchema, options?: ToolSchemaOptions): TransformResult;
112
+ /**
113
+ * Build a complete, provider shaped tool / function declaration: the right
114
+ * wrapper keys (`function`, `input_schema`, `parameters`, `inputSchema`), the
115
+ * converted parameter schema, and provider specific extras such as `strict` or
116
+ * MCP `annotations`.
117
+ */
118
+ declare function toTool(def: ToolDefinition, options?: ToolSchemaOptions): ToolResult;
119
+ /**
120
+ * Report what would change to make `schema` valid for a target, without
121
+ * applying it. `ok` is true when the schema is already conformant.
122
+ */
123
+ declare function lintToolSchema(schema: JSONSchema, options?: ToolSchemaOptions): LintResult;
124
+
125
+ export { type JSONSchema, type LintResult, type McpAnnotations, type Target, type ToolDefinition, type ToolResult, type ToolSchemaOptions, type TransformResult, type Warning, type WarningCode, lintToolSchema, toTool, toToolSchema };
@@ -0,0 +1,125 @@
1
+ /**
2
+ * A JSON Schema object. Intentionally loose: tool-schema accepts schemas from
3
+ * many sources (hand written, OpenAPI, `z.toJSONSchema()`, codegen) so the input
4
+ * type stays permissive. The public result types below are strict.
5
+ */
6
+ interface JSONSchema {
7
+ type?: string | string[];
8
+ properties?: Record<string, JSONSchema>;
9
+ required?: string[];
10
+ items?: JSONSchema | JSONSchema[];
11
+ additionalProperties?: boolean | JSONSchema;
12
+ enum?: unknown[];
13
+ const?: unknown;
14
+ anyOf?: JSONSchema[];
15
+ oneOf?: JSONSchema[];
16
+ allOf?: JSONSchema[];
17
+ not?: JSONSchema;
18
+ $ref?: string;
19
+ $defs?: Record<string, JSONSchema>;
20
+ definitions?: Record<string, JSONSchema>;
21
+ description?: string;
22
+ title?: string;
23
+ format?: string;
24
+ pattern?: string;
25
+ default?: unknown;
26
+ nullable?: boolean;
27
+ propertyOrdering?: string[];
28
+ [key: string]: unknown;
29
+ }
30
+ /** A provider target for tool / function calling. */
31
+ type Target = 'openai' | 'openai-strict' | 'anthropic' | 'gemini' | 'gemini-jsonschema' | 'mcp';
32
+ /** A non fatal adjustment made while converting a schema to a target. */
33
+ interface Warning {
34
+ /** JSON Pointer style path to the node where the change happened. */
35
+ path: string;
36
+ /** Stable machine readable code (e.g. `stripped-keyword`). */
37
+ code: WarningCode;
38
+ /** Human readable explanation. */
39
+ message: string;
40
+ }
41
+ type WarningCode = 'stripped-keyword' | 'unsupported-format' | 'forced-required' | 'forced-additional-properties' | 'root-not-object' | 'merged-allof' | 'inlined-ref' | 'recursive-ref' | 'collapsed-nullable' | 'union-types' | 'enum-coerced' | 'invalid-name' | 'limit-exceeded';
42
+ /** Result of converting a schema for a target. */
43
+ interface TransformResult {
44
+ /** The provider valid schema. */
45
+ schema: JSONSchema;
46
+ /** Every adjustment made during conversion. Empty means the input was already valid. */
47
+ warnings: Warning[];
48
+ /** True when conversion dropped information (a keyword or constraint was removed). */
49
+ lossy: boolean;
50
+ }
51
+ /** Options accepted by {@link toToolSchema} and {@link toTool}. */
52
+ interface ToolSchemaOptions {
53
+ /** Provider target. Defaults to `'openai'`. */
54
+ target?: Target;
55
+ /**
56
+ * For the `gemini` target, emit upper case OpenAPI type names (`STRING`,
57
+ * `OBJECT`, ...) as required by the raw REST `Schema` proto. Most official
58
+ * SDKs accept lower case and normalize, so this defaults to `false`.
59
+ */
60
+ geminiUppercaseTypes?: boolean;
61
+ /**
62
+ * For OpenAI targets, emit the flattened Responses API tool shape
63
+ * (`{ type, name, description, parameters, strict }`) instead of the nested
64
+ * Chat Completions shape (`{ type, function: { ... } }`). Defaults to `false`.
65
+ */
66
+ openaiResponses?: boolean;
67
+ /** For the `anthropic` target, add `strict: true` to the tool definition. */
68
+ anthropicStrict?: boolean;
69
+ }
70
+ /** MCP tool behavioural hints. See the Model Context Protocol spec. */
71
+ interface McpAnnotations {
72
+ title?: string;
73
+ readOnlyHint?: boolean;
74
+ destructiveHint?: boolean;
75
+ idempotentHint?: boolean;
76
+ openWorldHint?: boolean;
77
+ }
78
+ /** Input to {@link toTool}. */
79
+ interface ToolDefinition {
80
+ /** Tool / function name. */
81
+ name: string;
82
+ /** What the tool does. Strongly recommended: models use it to choose tools. */
83
+ description?: string;
84
+ /** The parameters / input schema. Defaults to an empty object schema. */
85
+ schema?: JSONSchema;
86
+ /** MCP only: behavioural hints surfaced to clients. */
87
+ annotations?: McpAnnotations;
88
+ }
89
+ /** Result of {@link toTool}: a provider shaped tool plus conversion metadata. */
90
+ interface ToolResult {
91
+ /** The provider shaped tool / function declaration. */
92
+ tool: Record<string, unknown>;
93
+ warnings: Warning[];
94
+ lossy: boolean;
95
+ }
96
+ /** Result of {@link lintToolSchema}. */
97
+ interface LintResult {
98
+ /** True when the schema was already valid for the target with no changes. */
99
+ ok: boolean;
100
+ /** The changes that would be required to make it valid. */
101
+ issues: Warning[];
102
+ }
103
+
104
+ /**
105
+ * Convert any JSON Schema into a schema that is valid for a provider's tool /
106
+ * function calling parameters.
107
+ *
108
+ * @example
109
+ * const { schema, warnings } = toToolSchema(mySchema, { target: 'openai-strict' });
110
+ */
111
+ declare function toToolSchema(schema: JSONSchema, options?: ToolSchemaOptions): TransformResult;
112
+ /**
113
+ * Build a complete, provider shaped tool / function declaration: the right
114
+ * wrapper keys (`function`, `input_schema`, `parameters`, `inputSchema`), the
115
+ * converted parameter schema, and provider specific extras such as `strict` or
116
+ * MCP `annotations`.
117
+ */
118
+ declare function toTool(def: ToolDefinition, options?: ToolSchemaOptions): ToolResult;
119
+ /**
120
+ * Report what would change to make `schema` valid for a target, without
121
+ * applying it. `ok` is true when the schema is already conformant.
122
+ */
123
+ declare function lintToolSchema(schema: JSONSchema, options?: ToolSchemaOptions): LintResult;
124
+
125
+ export { type JSONSchema, type LintResult, type McpAnnotations, type Target, type ToolDefinition, type ToolResult, type ToolSchemaOptions, type TransformResult, type Warning, type WarningCode, lintToolSchema, toTool, toToolSchema };
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import {
2
+ lintToolSchema,
3
+ toTool,
4
+ toToolSchema
5
+ } from "./chunk-OI5FY7ML.js";
6
+ export {
7
+ lintToolSchema,
8
+ toTool,
9
+ toToolSchema
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "tool-schema",
3
+ "version": "0.1.0",
4
+ "description": "Convert any JSON Schema into a valid tool / function calling schema for OpenAI, Anthropic, Gemini and MCP. Zero dependencies.",
5
+ "keywords": [
6
+ "openai",
7
+ "anthropic",
8
+ "claude",
9
+ "gemini",
10
+ "mcp",
11
+ "model-context-protocol",
12
+ "function-calling",
13
+ "tool-use",
14
+ "tool-calling",
15
+ "json-schema",
16
+ "structured-outputs",
17
+ "llm",
18
+ "ai",
19
+ "agents",
20
+ "zod"
21
+ ],
22
+ "license": "MIT",
23
+ "author": "Sebastian Legarraga",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/slegarraga/tool-schema.git"
27
+ },
28
+ "homepage": "https://github.com/slegarraga/tool-schema#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/slegarraga/tool-schema/issues"
31
+ },
32
+ "type": "module",
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "require": "./dist/index.cjs"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
44
+ "bin": {
45
+ "tool-schema": "./dist/cli.js"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "README.md",
50
+ "LICENSE",
51
+ "CHANGELOG.md"
52
+ ],
53
+ "engines": {
54
+ "node": ">=18"
55
+ },
56
+ "sideEffects": false,
57
+ "scripts": {
58
+ "build": "tsup",
59
+ "typecheck": "tsc --noEmit",
60
+ "test": "vitest run",
61
+ "test:watch": "vitest",
62
+ "lint": "eslint .",
63
+ "format": "prettier --write .",
64
+ "format:check": "prettier --check .",
65
+ "prepublishOnly": "npm run build",
66
+ "prepare": "npm run build"
67
+ },
68
+ "devDependencies": {
69
+ "@eslint/js": "^9.17.0",
70
+ "@types/node": "^22.10.2",
71
+ "eslint": "^9.17.0",
72
+ "prettier": "^3.4.2",
73
+ "tsup": "^8.3.5",
74
+ "typescript": "^5.7.2",
75
+ "typescript-eslint": "^8.18.1",
76
+ "vitest": "^2.1.8"
77
+ }
78
+ }