mirror of
https://github.com/moeru-ai/airi.git
synced 2026-11-29 10:56:17 +00:00
## Summary This PR addresses the `@proj-airi/component-calling` item in #3180. - Replace four explicit `any` types with `unknown` or schema-derived types. - Combine both component-props parsing paths in `loadComponentProps`. - Validate model-generated props with the registered component's Valibot schema before assigning them. - Keep the Valibot runtime schema separate from the JSON Schema sent to the model. ## Behavior and boundaries Invalid JSON, unknown component names, and props that fail schema validation do not reach the widget. Validated schema output is assigned, so schema transformations apply. The page completes its loading flow after the response. | Boundary | Protection | Evidence | | --- | --- | --- | | Model-generated widget props | Parse and validate before assignment | Tests cover valid props, additional props, invalid JSON, invalid values, and transformed output | | Component prop types | Derive output types from the registered schema | Workspace typecheck passes | ## Follow-up `parseComponentProps` throws when validation fails. The page catches the error and logs it, but still renders an empty widget. Improve this error state in a follow-up. ## Visual changes The same mock response sends `temperature: 29` as a number. The component schema expects a string. | Before | After | | --- | --- | |  |  | | `main`, 1440 × 900 | `component-calling`, 1440 × 900 | ## Verification - `pnpm -F @proj-airi/component-calling typecheck` — passed. - `pnpm -F @proj-airi/component-calling exec vitest run src/plugins/plugin-component-calling/index.test.ts` — 6 tests passed. - Targeted ESLint on the three changed TypeScript and Vue files — passed. - `pnpm lint` — 0 errors and 691 warnings. - `git diff --check` — passed. The app build was not run. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| index.html | ||
| netlify.toml | ||
| package.json | ||
| tsconfig.json | ||
| uno.config.ts | ||
| vite.config.ts | ||