{"_id":"2schema","_rev":"5-c8e251bde0f7515f4b14052874837519","name":"2schema","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.2":{"name":"2schema","version":"1.0.2","keywords":["agent","tool","json","schema","openapi"],"author":{"name":"Hung-Han Chen"},"license":"MIT","_id":"2schema@1.0.2","maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"homepage":"https://github.com/chenhunghan/2schema#readme","bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"dist":{"shasum":"faca6f37c9a0cab7978eefa60f27652078144403","tarball":"https://registry.npmjs.org/2schema/-/2schema-1.0.2.tgz","fileCount":47,"integrity":"sha512-vLp48aXvIhkPj45sl8/aMB83ZJkfi7/gxQ3BD7L63qxjvCMPqr91iof2JLt7w/pbaVGc6hk510hOjBZhvD7kOg==","signatures":[{"sig":"MEUCIQCb+wCrEka8CUQRQ+GbE+yXZ/Jpf9n8A/d0jEokkbKbOwIgFFvqAmyC+BBVroeUebsio319vGpIK+v9jzOcrTxJlHE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53189},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"91ea9ba6d43b1967a9096214d3c301a84e9bc30d","scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"chenhunghan","email":"chenhungh@gmail.com"},"repository":{"url":"git+https://github.com/chenhunghan/2schema.git","type":"git"},"_npmVersion":"10.8.2","description":"enhance tooling for AI agents","directories":{},"_nodeVersion":"20.18.3","dependencies":{"typescript":"^5.8.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.8"},"_npmOperationalInternal":{"tmp":"tmp/2schema_1.0.2_1742133271701_0.9396563647695384","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"2schema","version":"1.0.3","keywords":["agent","tool","json","schema","openapi"],"author":{"name":"Hung-Han Chen"},"license":"MIT","_id":"2schema@1.0.3","maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"homepage":"https://github.com/chenhunghan/2schema#readme","bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"dist":{"shasum":"3177e39227f95335108698fe97e42d16f420e8c1","tarball":"https://registry.npmjs.org/2schema/-/2schema-1.0.3.tgz","fileCount":47,"integrity":"sha512-MP7himlv2gAAR3SC5fqDES0iREJKsD1VtJ5acO4CCa2O2THrVkvUNE1y7jP1hUhvjCRxCbkyJiOVKxclxkXYWQ==","signatures":[{"sig":"MEUCIEyEk1hlhI3CQ68JyKvM8MdjTFLi2QdynJqZgLQxuW9EAiEApLMbqq9d1+sghLiNbO5JlSUwx2gUfCz1l9PxfzZnTm8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52748},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8e508b8b761a8c80353efa11bde10456ec22019a","scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"chenhunghan","email":"chenhungh@gmail.com"},"repository":{"url":"git+https://github.com/chenhunghan/2schema.git","type":"git"},"_npmVersion":"10.8.2","description":"enhance tooling for AI agents","directories":{},"_nodeVersion":"20.18.3","dependencies":{"typescript":"^5.8.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.8"},"_npmOperationalInternal":{"tmp":"tmp/2schema_1.0.3_1742134423951_0.5864571549294","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"2schema","version":"1.1.0","keywords":["agent","tool","json","schema","openapi"],"author":{"name":"Hung-Han Chen"},"license":"MIT","_id":"2schema@1.1.0","maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"homepage":"https://github.com/chenhunghan/2schema#readme","bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"dist":{"shasum":"461f9b76bb4599fbbccd3a8945579a108d5b2c04","tarball":"https://registry.npmjs.org/2schema/-/2schema-1.1.0.tgz","fileCount":28,"integrity":"sha512-43WBQ4il67RAvbyYtNJ437A31/eGb0eSaLbHJ3uSvIMmf+Va/JiVU+pDS7l4z3M4EW9pOCPknJgxRLuBlvOHog==","signatures":[{"sig":"MEYCIQD0ngjiptkcUz/QIG1nX0a693ju5oY+gYP3hN45knQHIQIhAO2GlbIj1VFEohH7G202mNJMc7Bw2M20zjkf1CpnRucN","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52681},"main":"index.js","types":"index.d.ts","gitHead":"ca3484d6a67f33afea47d0c7a812b96008c8f911","scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"chenhunghan","email":"chenhungh@gmail.com"},"repository":{"url":"git+https://github.com/chenhunghan/2schema.git","type":"git"},"_npmVersion":"10.8.2","description":"enhance tooling for AI agents","directories":{},"_nodeVersion":"20.18.3","dependencies":{"typescript":"^5.8.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.8"},"_npmOperationalInternal":{"tmp":"tmp/2schema_1.1.0_1742135693636_0.589037921548488","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"2schema","version":"1.1.2","keywords":["agent","tool","json","schema","openapi"],"author":{"name":"Hung-Han Chen"},"license":"MIT","_id":"2schema@1.1.2","maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"homepage":"https://github.com/chenhunghan/2schema#readme","bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"dist":{"shasum":"e4fb2045889e6bdd4addac1c38abd457d197e83f","tarball":"https://registry.npmjs.org/2schema/-/2schema-1.1.2.tgz","fileCount":50,"integrity":"sha512-znGGtIHXxMS7d6bl7UwNyAviGo/RAOF6g+CPHZ3Id6JOMsS4vRbGWNvOnrMHk9Y8VIsgbJ3Wvz9rN83JWUASOw==","signatures":[{"sig":"MEYCIQDCoUGHRm9lGlgYursMtX1/o0men0JYm/zFvQPSDIT9OgIhANL3XRix4C6PlSGenGXrlEERW5KQrCg4atdwf10mHjP9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":113352},"main":"index.js","types":"index.d.ts","gitHead":"e1606374de359c75530f20bc571d0c4b936dca41","scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"chenhunghan","email":"chenhungh@gmail.com"},"repository":{"url":"git+https://github.com/chenhunghan/2schema.git","type":"git"},"_npmVersion":"10.8.2","description":"enhance tooling for AI agents","directories":{},"_nodeVersion":"20.18.3","dependencies":{"typescript":"^5.8.2"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.8"},"_npmOperationalInternal":{"tmp":"tmp/2schema_1.1.2_1742136853104_0.9219136276579014","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"2schema","version":"1.1.3","description":"enhance tooling for AI agents","main":"index.js","types":"index.d.ts","scripts":{"test":"vitest","build":"tsc"},"repository":{"type":"git","url":"git+https://github.com/chenhunghan/2schema.git"},"keywords":["agent","tool","json","schema","openapi"],"author":{"name":"Hung-Han Chen"},"license":"MIT","bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"homepage":"https://github.com/chenhunghan/2schema#readme","dependencies":{"typescript":"^5.8.2"},"devDependencies":{"vitest":"^3.0.8"},"_id":"2schema@1.1.3","gitHead":"810852801bb7d98a3abe56b2184821825f55b828","_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-kxblbk8oA7ygi8TlsqIo+boo8CLm8hag6XXOaRpszWcCfoM/Ct7sDQPkWs9TQFxlXNv4+JPcxWAr3GLsVPnSRQ==","shasum":"ec68f5ccdcf4a089f2f220ee1795f2cda796dfda","tarball":"https://registry.npmjs.org/2schema/-/2schema-1.1.3.tgz","fileCount":50,"unpackedSize":113592,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBYkrALoYqjb7QLP6gGKpC/goY9oefxKKTvgIWRhvgb9AiBkkprKPXoXreo+rsK8dHuzhrPXJa/dv9IjLepWyDFCQg=="}]},"_npmUser":{"name":"chenhunghan","email":"chenhungh@gmail.com"},"directories":{},"maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/2schema_1.1.3_1742137423038_0.4350176160643826"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-16T13:54:31.699Z","modified":"2025-03-16T15:03:43.403Z","1.0.2":"2025-03-16T13:54:31.935Z","1.0.3":"2025-03-16T14:13:44.184Z","1.1.0":"2025-03-16T14:34:53.899Z","1.1.2":"2025-03-16T14:54:13.297Z","1.1.3":"2025-03-16T15:03:43.213Z"},"bugs":{"url":"https://github.com/chenhunghan/2schema/issues"},"author":{"name":"Hung-Han Chen"},"license":"MIT","homepage":"https://github.com/chenhunghan/2schema#readme","keywords":["agent","tool","json","schema","openapi"],"repository":{"type":"git","url":"git+https://github.com/chenhunghan/2schema.git"},"description":"enhance tooling for AI agents","maintainers":[{"name":"chenhunghan","email":"chenhungh@gmail.com"}],"readme":"# 2schema\n\nAutomatically generate schemas from LLM function calling.\n\nInstead of writing schemas by hand 🥱\n\n```ts\nimport { OpenAI } from \"openai\";\n\nconst openai = new OpenAI();\n\nconst tools = [{\n    \"type\": \"function\",\n    \"function\": {\n        \"name\": \"getWeather\",\n        \"description\": \"Get current temperature for a given location.\",\n        \"parameters\": {\n            \"type\": \"object\",\n            \"properties\": {\n                // life is too short for schema\n            },\n        },\n    }\n}];\n\nfunction getWeather(args: { location: string }) {\n    return //...\n}\n\nconst completion = await openai.chat.completions.create({\n    model: \"gpt-5\",\n    messages: [{ role: \"user\", content: \"What is the weather like in Paris today?\" }],\n    tools,\n});\n```\n\nLet the compiler works for you\n\n```ts\nimport { fn } from \"2schema\";\n\nconst openai = new OpenAI();\n\nclass Tools {\n  @fn\n  static async getWeather(args: { location: string }) {\n    return; // ...\n  }\n}\n\n// will generate the schema for you\nconst tools = [Tools.getWeather.toJSONSchema()];\n\nconst completion = await openai.chat.completions.create({\n  model: \"gpt-5\",\n  messages: [\n    { role: \"user\", content: \"What is the weather like in Paris today?\" },\n  ],\n  tools,\n});\n```\n","readmeFilename":"README.md"}