{"_id":"@agentic-utilities/agent-response-schema","_rev":"3-0cb7705a7703abbadbe542c32536eaf6","name":"@agentic-utilities/agent-response-schema","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.1":{"name":"@agentic-utilities/agent-response-schema","version":"0.1.1","keywords":["ai","llm","json","validation","repair","schema","openai","anthropic"],"author":{"name":"Agentic Utilities"},"license":"MIT","_id":"@agentic-utilities/agent-response-schema@0.1.1","maintainers":[{"name":"aitesthq","email":"hello@cijaytechnologies.org"}],"dist":{"shasum":"59420f6a199aadbf6b2213782cbab6669f62240a","tarball":"https://registry.npmjs.org/@agentic-utilities/agent-response-schema/-/agent-response-schema-0.1.1.tgz","fileCount":5,"integrity":"sha512-OmfeqxtD/1Tnwa84t+ovxSU4oTxnzlK+C5tUYuO6dM6IKoRMUjQXACasSnQhnUUr0NhtKf0kTBaVz4yNmTCE1A==","signatures":[{"sig":"MEUCIQDGA1OFqFtWGeHNv7ZIVeNAYzLMUNqlsI3VTNngTLkLgAIgBJGffxwmHloh7INmHH4w6+RMouB0Ek2gAxsBEmcy2oc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17989},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"b5204310fcefc860dee62c5a657c92a055bacdcd","scripts":{"test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","prepare":"npm run build && npm run test","test:watch":"vitest"},"_npmUser":{"name":"aitesthq","email":"hello@cijaytechnologies.org"},"_npmVersion":"10.9.4","description":"A Zod-like schema validation and repair library for Agentic frameworks","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"packageManager":"npm@11.0.0","devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","typescript":"^5.6.0","@types/node":"^20.0.0","@vitest/coverage-v8":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/agent-response-schema_0.1.1_1787576065037_0.6361295878224305","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@agentic-utilities/agent-response-schema","version":"0.1.2","keywords":["ai","llm","json","validation","repair","schema","openai","anthropic"],"author":{"name":"Agentic Utilities"},"license":"MIT","_id":"@agentic-utilities/agent-response-schema@0.1.2","maintainers":[{"name":"aitesthq","email":"hello@cijaytechnologies.org"}],"dist":{"shasum":"398b04893a5db62d860af27af06636acbe7fd989","tarball":"https://registry.npmjs.org/@agentic-utilities/agent-response-schema/-/agent-response-schema-0.1.2.tgz","fileCount":5,"integrity":"sha512-rFfxBTkL3DuJJg/l7Y4oSSm4IQ0KluehDMhkYrOv3afETxdjg9msFuRckI7wI3/hOj6XtcZNyK4HjDElzsPg/Q==","signatures":[{"sig":"MEUCIQCxtlt3L8k9I/pXjWnduBm/AUTsIcQPcTSKX7hYLz8iiAIgWp9sRV/NV/XOt7F5iBJCBiZZzPAn6l0oXZX4Dr9hOho=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19141},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"614c4e9dbeea1319979ea40dfaefbe69c9e28bfb","scripts":{"test":"vitest run","build":"tsup src/index.ts --format esm --dts --clean","prepare":"npm run build && npm run test","test:watch":"vitest"},"_npmUser":{"name":"aitesthq","email":"hello@cijaytechnologies.org"},"_npmVersion":"10.8.2","description":"A Zod-like schema validation and repair library for Agentic frameworks","directories":{},"_nodeVersion":"18.20.8","_hasShrinkwrap":false,"packageManager":"npm@11.0.0","devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","typescript":"^5.6.0","@types/node":"^20.0.0","@vitest/coverage-v8":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/agent-response-schema_0.1.2_1787595438692_0.0379165750748689","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@agentic-utilities/agent-response-schema","version":"0.1.3","description":"A Zod-like schema validation and repair library for Agentic frameworks","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"packageManager":"npm@11.0.0","scripts":{"build":"tsup src/index.ts --format esm --dts --clean","test":"vitest run","test:watch":"vitest","prepare":"npm run build && npm run test"},"devDependencies":{"@types/node":"^20.0.0","tsup":"^8.0.0","typescript":"^5.6.0","vitest":"^2.0.0","@vitest/coverage-v8":"^2.0.0"},"engines":{"node":">=18.0.0"},"keywords":["ai","llm","json","validation","repair","schema","openai","anthropic"],"author":{"name":"Agentic Utilities"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/agentic-utilities/agent-response-schema.git"},"bugs":{"url":"https://github.com/agentic-utilities/agent-response-schema/issues"},"homepage":"https://github.com/agentic-utilities/agent-response-schema#readme","publishConfig":{"access":"public"},"funding":{"type":"individual","url":"https://buymeacoffee.com/cijaytechnh"},"_id":"@agentic-utilities/agent-response-schema@0.1.3","gitHead":"4519b569580190355207baa9f60d7a62ad43e173","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-WNQKulOncrp3dIU8ePauTvrD6ImLFI6rZXxGIuP357QCI204fg0kT7JzTqplQZ+QVmOaxCF6iVI7lyM1/xT3eQ==","shasum":"ac67faa72dff8cc9b785395464daec024e0bd9e0","tarball":"https://registry.npmjs.org/@agentic-utilities/agent-response-schema/-/agent-response-schema-0.1.3.tgz","fileCount":5,"unpackedSize":19587,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD1RBtZZbcu6chR0q04yzbjlzFkn1rHlSb9rxaMbs7qpAIhAKvuIRSN8zu2d/dygl09FiG3ulFRHR0Je7BKhjQXRtKn"}]},"_npmUser":{"name":"aitesthq","email":"hello@cijaytechnologies.org"},"directories":{},"maintainers":[{"name":"aitesthq","email":"hello@cijaytechnologies.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agent-response-schema_0.1.3_1787606496464_0.8281503275713498"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-24T12:54:24.865Z","modified":"2026-08-24T21:21:36.847Z","0.1.1":"2026-08-24T12:54:25.184Z","0.1.2":"2026-08-24T18:17:18.828Z","0.1.3":"2026-08-24T21:21:36.665Z"},"author":{"name":"Agentic Utilities"},"license":"MIT","keywords":["ai","llm","json","validation","repair","schema","openai","anthropic"],"description":"A Zod-like schema validation and repair library for Agentic frameworks","maintainers":[{"name":"aitesthq","email":"hello@cijaytechnologies.org"}],"readme":"# @agentic-utilities/agent-response-schema\n\n[![npm version](https://img.shields.io/npm/v/@agentic-utilities/agent-response-schema.svg)](https://www.npmjs.com/package/@agentic-utilities/agent-response-schema)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA lightweight, Zod-like schema validation and repair library designed specifically for Agentic AI frameworks. \n\nLLMs frequently hallucinate JSON formatting, miss trailing commas, drop brackets, or output types as strings instead of numbers. While standard validation libraries like Zod will outright reject these responses, this library acts as a robust middle-layer—coercing and repairing messy AI output back into strict TypeScript types so your agents can keep running.\n\n## Features\n\n- **Robust Type Coercion**: Automatically converts `\"42\"` to `42` and `\"true\"` to `true` when the schema demands it.\n- **Syntax Repair**: Gracefully handles missing trailing commas, unclosed brackets, and stray conversational text.\n- **Zod-Like API**: Familiar, chainable validation syntax (e.g., `z.string().min(2)`).\n\n## Installation\n\n```bash\nnpm install @agentic-utilities/agent-response-schema\n```\n\n## Basic Usage\n\n```typescript\nimport { validateWithRepair, z } from \"@agentic-utilities/agent-response-schema\";\n\nconst schema = z.object({\n  id: z.string().uuid(),\n  age: z.number(),\n  isActive: z.boolean()\n});\n\n// A messy LLM response with conversational text, bad JSON syntax, and stringified numbers/booleans\nconst rawAIResponse = `\nHere is the extracted data:\n\\`\\`\\`json\n{\n  \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n  \"age\": \"28\",\n  \"isActive\": \"TRUE\"\n\\`\\`\\`\n`;\n\nconst result = validateWithRepair(schema, rawAIResponse, {\n  extractFromText: true,\n  fixMissingBrackets: true,\n  coerceTypes: true\n});\n\nif (result.success) {\n  console.log(result.data); \n  // Output: { id: \"123e...\", age: 28, isActive: true }\n} else {\n  console.error(\"Failed to parse and repair AI response:\", result.errors);\n}\n```\n\n## Repair Options\n\nThe `validateWithRepair` function takes an optional configuration object to tailor the repair strategies to your LLM's behavior:\n\n| Option | Type | Default | Description |\n| :--- | :--- | :--- | :--- |\n| `extractFromText` | `boolean` | `true` | Attempts to extract JSON blocks (like ` ```json ... ``` `) from conversational LLM output. |\n| `fixMissingBrackets` | `boolean` | `true` | Automatically balances and injects missing `[` or `{` brackets at the start or end of the string. |\n| `coerceTypes` | `boolean` | `true` | Safely casts primitive strings (e.g. `\"10\"`, `\"false\"`) into their proper types if the schema requires a `number` or `boolean`. |\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md","homepage":"https://github.com/agentic-utilities/agent-response-schema#readme","repository":{"type":"git","url":"git+https://github.com/agentic-utilities/agent-response-schema.git"},"bugs":{"url":"https://github.com/agentic-utilities/agent-response-schema/issues"}}