{"_id":"@4djs/ai-widgets","_rev":"2-678f5f85134a155f70f465fd13b8f2de","name":"@4djs/ai-widgets","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@4djs/ai-widgets","version":"0.1.0","_id":"@4djs/ai-widgets@0.1.0","maintainers":[{"name":"idrissi","email":"med.idrissi@outlook.com"}],"dist":{"shasum":"b554a4656a4760b819b0bbcba1776310d00a79f7","tarball":"https://registry.npmjs.org/@4djs/ai-widgets/-/ai-widgets-0.1.0.tgz","fileCount":35,"integrity":"sha512-vjdKU4S6XZlkLfI1ho/7DT2iAezxmY9UOL1v7YjMgwalyNXUc0PC8mFEua8fwdCeru6hXnU7yK1d6OcJ3rphNw==","signatures":[{"sig":"MEYCIQD7jAJWlY7CvKdIPbU/BcUKS9X0dCoq9sQiOBEQnQFsCAIhAIYL7OYiYG+PCxmmf4uDOZjlp0vwcvVPBr+S+xm+Tngy","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":114826},"type":"module","exports":{".":"./src/index.ts","./styles.css":"./src/styles.css"},"gitHead":"12b30c75ad417e913daadde3496fa75d97ebced4","private":false,"scripts":{"lint":"biome lint .","test":"bun test","build":"bun build ./src/index.ts --outdir ./dist --target bun","typecheck":"tsc --noEmit"},"_npmUser":{"name":"idrissi","email":"med.idrissi@outlook.com"},"_npmVersion":"11.13.0","description":"Built-in assistant widgets for Data Explorer. Widgets are **render-only**: they receive a data envelope and paint UI. They never fetch from the datastore.","directories":{},"_nodeVersion":"23.11.1","_hasShrinkwrap":false,"devDependencies":{"react":"^19.1.0","react-dom":"^19.1.0","typescript":"catalog:","@types/react":"^19.1.2","@types/react-dom":"^19.1.2","@4d/typescript-config":"workspace:*"},"_npmOperationalInternal":{"tmp":"tmp/ai-widgets_0.1.0_1784644703231_0.3998144576978957","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@4djs/ai-widgets","version":"0.1.1","private":false,"type":"module","exports":{".":"./src/index.ts","./styles.css":"./src/styles.css"},"scripts":{"lint":"biome lint .","typecheck":"tsc --noEmit","build":"bun build ./src/index.ts --outdir ./dist --target bun","test":"bun test"},"devDependencies":{"@4d/typescript-config":"workspace:*","@types/react":"^19.1.2","@types/react-dom":"^19.1.2","react":"^19.1.0","react-dom":"^19.1.0","typescript":"catalog:"},"gitHead":"93fdbcef0fa37b4c712e55b130c65bd78322ac23","_id":"@4djs/ai-widgets@0.1.1","description":"Built-in assistant widgets for Data Explorer. Widgets are **render-only**: they receive a data envelope and paint UI. They never fetch from the datastore.","_nodeVersion":"23.11.1","_npmVersion":"11.13.0","dist":{"integrity":"sha512-s+7f0/r2EJKTvN3MTZO8S0jFwx3d8wquEEpCGXVK/IrYQ3fOJVtSDI9pHDxKtREe3OTXbKG4vaYT4avoy9E5jQ==","shasum":"f205b80b30c2ffc484f54818ef6f9cae8115ce47","tarball":"https://registry.npmjs.org/@4djs/ai-widgets/-/ai-widgets-0.1.1.tgz","fileCount":35,"unpackedSize":114826,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIA3GjzCTo6M2rmtJbQeHMncF82ipDVq9m1U3y0lSE5u9AiAB0siwJyk0CYAr70h1Q2Ia5JQMEnzpOPPPTLUoVzMvWg=="}]},"_npmUser":{"name":"idrissi","email":"med.idrissi@outlook.com"},"directories":{},"maintainers":[{"name":"idrissi","email":"med.idrissi@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-widgets_0.1.1_1784647741490_0.04524289477886989"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-21T14:38:23.056Z","modified":"2026-07-21T15:29:01.784Z","0.1.0":"2026-07-21T14:38:23.387Z","0.1.1":"2026-07-21T15:29:01.621Z"},"description":"Built-in assistant widgets for Data Explorer. Widgets are **render-only**: they receive a data envelope and paint UI. They never fetch from the datastore.","maintainers":[{"name":"idrissi","email":"med.idrissi@outlook.com"}],"readme":"# @4djs/ai-widgets\n\nBuilt-in assistant widgets for Data Explorer. Widgets are **render-only**: they receive a data envelope and paint UI. They never fetch from the datastore.\n\nHosts (e.g. Data Explorer) gather data with `@datastore/query`, shape an envelope, then call `@widgets/render`. Results render inline via `WidgetRenderer`.\n\n## Usage\n\n```ts\nimport {\n  WidgetRenderer,\n  listBuiltinWidgets,\n  listWidgetAiGuidance,\n  getWidgetRenderPropsFromResult,\n  buildWidgetRenderInputSchema,\n  buildWidgetRenderToolDescription,\n  parseWidgetRenderArgs,\n} from \"@4djs/ai-widgets\";\nimport \"@4djs/ai-widgets/styles.css\";\n```\n\n### Render a tool result\n\n```tsx\nconst props = getWidgetRenderPropsFromResult(step.result);\nif (props) {\n  return <WidgetRenderer {...props} mode={props.mode ?? \"light\"} />;\n}\n```\n\n### Host tool (data in)\n\nCompose the tool description and JSON Schema from the registry so per-widget AI instructions stay next to each component (not in the app system prompt):\n\n```ts\nconst opts = { disabledWidgetTypes };\nconst schema = buildWidgetRenderInputSchema(opts);\nconst description = buildWidgetRenderToolDescription(opts);\nconst parsed = parseWidgetRenderArgs(args, opts);\nif (!parsed.ok) return toolResultErr(parsed.error);\nreturn toolResultOk({\n  widget: { title: parsed.value.title, data: parsed.value.data },\n});\n```\n\nEach widget definition can declare:\n\n```ts\n{\n  type: \"pie\",\n  label: \"Pie Chart\",\n  description: \"Part-to-whole slices\", // human UI\n  example: { type: \"pie\", values: [{ label: \"A\", value: 3 }] },\n  ai: {\n    summary: \"Part-to-whole distribution as a pie\",\n    dataShape: '{ \"type\": \"pie\", \"values\": [{ \"label\", \"value\" }] }',\n    aliases: 'Also accepts series/data as [{ \"key\", \"value\" }]',\n  },\n  Render: …\n}\n```\n\nExample tool args:\n\n```json\n{\n  \"title\": \"Cars by category\",\n  \"data\": {\n    \"type\": \"pie\",\n    \"values\": [\n      { \"label\": \"SUV\", \"value\": 12 },\n      { \"label\": \"Sedan\", \"value\": 8 }\n    ]\n  }\n}\n```\n\n## Built-in types\n\nKPI, line, area, bar, pie, donut, scatter, heatmap, table, gauge, progress, funnel, map, timeline, filter.\n\n## Scripts\n\n```sh\nbun run typecheck\nbun run test\nbun run lint\n```\n\n## Profile enablement\n\nData Explorer stores `disabledWidgetTypes` per profile. The Widgets settings panel toggles types and refreshes the `@widgets/render` schema so disabled types are omitted from the model tool enum.\n","readmeFilename":"README.md"}