{"_id":"@drzl/generator-ai","_rev":"2-52cf543f98a166043e4fd3efcc4d50a1","name":"@drzl/generator-ai","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@drzl/generator-ai","version":"0.1.0","keywords":["drizzle","drizzle-orm","ai","vercel-ai-sdk","tools","codegen","standard-schema"],"license":"Apache-2.0","_id":"@drzl/generator-ai@0.1.0","maintainers":[{"name":"omar-dulaimi","email":"o.m.dulaimi@gmail.com"}],"dist":{"shasum":"5f87f604deccd4e365f13863b0a108afcc443f9f","tarball":"https://registry.npmjs.org/@drzl/generator-ai/-/generator-ai-0.1.0.tgz","fileCount":7,"integrity":"sha512-evibL6ngIMew77Eo9Nmk47mrBldyMd4hmN6hCBc8lAVQuMaL+mDYiCdiPkVwwQsXceN+VrdBoCUGxk8C8R/kew==","signatures":[{"sig":"MEUCIAr89h0Z2kwylkCM6GDUQDo7tYCtNro79fSCD4Dbt1nrAiEA+EBrMz5gDSkEsCvU0BxX8eyX3LvtJRvldsH0pukT+80=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61778},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.17.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"funding":{"url":"https://github.com/sponsors/omar-dulaimi","type":"github"},"private":false,"scripts":{"lint":"eslint . --ext .ts","test":"vitest run --testTimeout=20000","build":"tsup src/index.ts --dts --format esm,cjs --external prettier --clean"},"_npmUser":{"name":"omar-dulaimi","email":"o.m.dulaimi@gmail.com"},"repository":{"url":"https://github.com/use-drzl/drzl","type":"git","directory":"packages/generator-ai"},"description":"Generate AI SDK tools from a Drizzle schema, one module per table, so a language model is told each column's real bounds before it writes a row rather than after the database refuses one.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","dependencies":{"@drzl/analyzer":"^1.21.5","@drzl/validation-core":"^3.22.6"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"ai":"^7.0.0","zod":"^4.4.3","tsup":"^8.5.1","arktype":"^2.1.29","valibot":"^1.1.0","typescript":"^5.9.3","@ai-sdk/provider-utils":"^5.0.26","@valibot/to-json-schema":"^1.4.0"},"_npmOperationalInternal":{"tmp":"tmp/generator-ai_0.1.0_1786450012797_0.34819275414249984","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@drzl/generator-ai","version":"0.1.1","private":false,"license":"Apache-2.0","description":"Generate AI SDK tools from a Drizzle schema, one module per table, so a language model is told each column's real bounds before it writes a row rather than after the database refuses one.","keywords":["drizzle","drizzle-orm","ai","vercel-ai-sdk","tools","codegen","standard-schema"],"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"sideEffects":false,"dependencies":{"@drzl/analyzer":"^1.22.0","@drzl/validation-core":"^3.23.0"},"devDependencies":{"@ai-sdk/provider-utils":"^5.0.26","@valibot/to-json-schema":"^1.4.0","ai":"^7.0.0","arktype":"^2.1.29","tsup":"^8.5.1","typescript":"^5.9.3","valibot":"^1.1.0","zod":"^4.4.3"},"engines":{"node":">=18.17.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/","provenance":true},"repository":{"type":"git","url":"https://github.com/use-drzl/drzl","directory":"packages/generator-ai"},"funding":{"type":"github","url":"https://github.com/sponsors/omar-dulaimi"},"scripts":{"build":"tsup src/index.ts --dts --format esm,cjs --external prettier --clean","lint":"eslint . --ext .ts","test":"vitest run --testTimeout=20000"},"_nodeVersion":"24.18.0","_id":"@drzl/generator-ai@0.1.1","dist":{"integrity":"sha512-8XLzdAi+rzNgZM/QOQdIhwVvqc1AQMmkdSbZg+kN2wfzhihS0mvs1CfrATf5XfsmVPlM8M4AqZvRaKJP0FoTJw==","shasum":"842644640fe34f0e062b889a2800c956d2663831","tarball":"https://registry.npmjs.org/@drzl/generator-ai/-/generator-ai-0.1.1.tgz","fileCount":7,"unpackedSize":61793,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@drzl%2fgenerator-ai@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDSHhB4l75w9E+ULDGF+G+nT3n9fsh+9roW4Cq4wfyteAIgX7OuA3Q/7IkPw7NOMTILcvPQnnGTM4DuXBYfTEASX6s="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f4c4d4a4-dbd7-457e-b5be-ff00bee53c29"}},"directories":{},"maintainers":[{"name":"omar-dulaimi","email":"o.m.dulaimi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/generator-ai_0.1.1_1786697004412_0.8554685526234704"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-11T12:06:52.588Z","modified":"2026-08-14T08:43:24.926Z","0.1.0":"2026-08-11T12:06:52.985Z","0.1.1":"2026-08-14T08:43:24.562Z"},"license":"Apache-2.0","keywords":["drizzle","drizzle-orm","ai","vercel-ai-sdk","tools","codegen","standard-schema"],"repository":{"type":"git","url":"https://github.com/use-drzl/drzl","directory":"packages/generator-ai"},"description":"Generate AI SDK tools from a Drizzle schema, one module per table, so a language model is told each column's real bounds before it writes a row rather than after the database refuses one.","maintainers":[{"name":"omar-dulaimi","email":"o.m.dulaimi@gmail.com"}],"readme":"# @drzl/generator-ai\n\nGenerate [Vercel AI SDK](https://ai-sdk.dev) tools from a Drizzle schema: five tools per table, with\nthe table's `CHECK` constraints reaching the model as bounds on the arguments it is allowed to send.\n\n## The reason this exists\n\nA tool hands a model a JSON Schema and the model writes arguments against it. Derive that schema\nfrom the column types alone and the model learns that `age` is an integer and nothing else: it\nguesses, the write reaches the database, and the database refuses it. Pointed at DRZL's own schemas\nthe same tool advertises `{ \"type\": \"integer\", \"minimum\": 18, \"maximum\": 120 }` and the invalid call\nnever happens.\n\n## One measurement changed what this emits\n\n`tool()` accepts any Standard Schema, and the SDK's adapter decides whether a validation passed with\n`'value' in result`. A valibot failure result is `{ value, typed, issues }`: it carries a `value` key\neven when it failed. So every valibot validation failure is reported to the AI SDK as a **success**\nand the invalid input reaches `execute`.\n\nMeasured on 2026-08-11 against `ai` 7.0.59 and `@ai-sdk/provider-utils` 5.0.26, with a schema\ndemanding `age >= 18`: zod and arktype refuse `{ age: 7 }` through the SDK, valibot accepts it.\nTheir failure results carry no `value` key and valibot's does.\n\nA generated valibot tool handed over as a Standard Schema would validate nothing at all, silently.\nSo valibot tools are emitted through `jsonSchema(document, { validate })` with the parse spelled\nout; zod and arktype are passed through, because they work.\n\n## Install\n\n```bash\nnpm install -D @drzl/generator-ai\nnpm install ai\n```\n\n```ts\n// drzl.config.ts\nexport default {\n  schema: './src/db/schema.ts',\n  generators: [\n    { kind: 'zod', path: 'src/validators/zod' },\n    {\n      kind: 'ai',\n      path: 'src/ai/tools',\n      validation: { useShared: true, importPath: 'src/validators/zod' },\n    },\n  ],\n};\n```\n\n`useShared` is what carries the constraints. Valibot needs `@valibot/to-json-schema` as well, for\nthe adapter above.\n\n## Using them\n\n```ts\nimport { generateText } from 'ai';\nimport { allTools } from './ai/tools';\n\nawait generateText({ model, tools: allTools, prompt: 'Add a user called Omar who is 30.' });\n```\n\n`allTools` is one flat object, which is what `generateText` and `streamText` take. Each table also\nexports its own set.\n\nFull documentation: https://use-drzl.github.io/drzl/generators/ai\n\n## Licence\n\nApache-2.0. Generated output is yours under your own project's licence.\n","readmeFilename":""}