managarten/apps/api/package.json
Till JS c2a75bb8e1 feat(shared-types): add Zod schemas for AI structured outputs
Introduces packages/shared-types/src/ai-schemas.ts as the single source
of truth for the wire format between mana-api and the unified Mana app.

Two schemas:
  - MealAnalysisSchema (foods, totalNutrition, description, confidence,
    warnings, suggestions) — consumed by nutriphi /analysis/photo and
    /analysis/text routes
  - PlantIdentificationSchema (scientificName, commonNames, confidence,
    health/watering/light advice, generalTips) — consumed by planta
    /analysis/identify

Both schemas include .describe() annotations on every field. The Vercel
AI SDK passes these through to the model as part of the structured-output
prompt, which materially improves accuracy on Gemini Vision (the model
sees both the field name AND the German-language hint about what to put
there).

Schemas use plain .optional() rather than .nullable() because
generateObject() guides the model with strict schema adherence — it
won't emit JSON null for missing fields, just omit them.

Deps wired up:
  - apps/api: + ai@6, + @ai-sdk/openai-compatible@2, + @mana/shared-types
  - apps/mana/apps/web: + zod (for z.infer of the shared schemas)
  - packages/shared-types: + zod (for the schema definitions themselves)

All three on zod ^3.23 to stay in lockstep with the existing
apps/api zod usage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 16:59:28 +02:00

35 lines
891 B
JSON

{
"name": "@mana/api",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "bun --hot run src/index.ts",
"build": "bun build src/index.ts --outdir dist --target bun",
"start": "bun run dist/index.js",
"type-check": "tsc --noEmit",
"db:generate": "drizzle-kit generate",
"db:push": "drizzle-kit push"
},
"dependencies": {
"@ai-sdk/openai-compatible": "^2.0.41",
"@mana/media-client": "workspace:*",
"@mana/shared-hono": "workspace:*",
"@mana/shared-storage": "workspace:*",
"@mana/shared-types": "workspace:^",
"@mozilla/readability": "^0.5.0",
"ai": "^6.0.154",
"drizzle-orm": "^0.38.0",
"hono": "^4.7.0",
"jsdom": "^25.0.0",
"postgres": "^3.4.0",
"rrule": "^2.8.1",
"zod": "^3.23.0"
},
"devDependencies": {
"@types/bun": "latest",
"@types/jsdom": "^21.1.0",
"drizzle-kit": "^0.30.0",
"typescript": "^5.8.0"
}
}