c7a75d069d
* feat(ai): job-shaped AI service with OpenAI-compatible backend, extraction-first; stop extracting every inbox document twice Sovereign plan WS1 PR1 (#1406 Tier 2, extraction-first, aligned with the AI surface audit). lib/ai grows a job-shaped service (generateText / generateStructured / extractFromDocument; no streaming members yet, see plan rule R3): - services/anthropic-family delegates to the existing createAiClient() and sends the exact request literals the inbox extractor sent before (request-shape tests deep-equal them), so hosted Bedrock stays byte-identical. - services/openai-compatible talks to any chat-completions endpoint (BYO Swedish provider) via Vercel AI SDK 6.x, exact-pinned and guarded: images as parts, PDFs rasterized with poppler (AI_PDF_MODE) or sent natively, AI_VISION / AI_STRICT_JSON declared, honest skips (ai_no_vision, pdf_rasterizer_missing) instead of fake failures. - config.ts: AI_PROVIDER/AI_BASE_URL/AI_API_KEY/AI_MODEL and per-tier AI_*_MODEL with the legacy BEDROCK_* names kept as the same overrides; getAiStatus() is the single source of truth for "is AI wired up". - provider.ts: openai-compatible in the auto-detect chain (after Bedrock and the direct API); createAiClient() refuses it loudly. Document extraction moves onto the service and gets the audit's fixes: - Inbox documents were extracted TWICE (pipeline A ran inside uploadDocument() before the inbox row existed, so its dedupe branch never fired; 3 707 + 1 666 calls / 30 d). The inbox now declares extractionOwner on the upload, the extension yields, and the inbox mirrors its single outcome onto document_attachments from every writer (sync, deferred, attach, retry, MCP). - Every "no extraction will ever happen" outcome is stamped (skipped:no_ai_entitlement / ai_unconfigured / system_generated / ...); the status route maps the quiet ones to 'disabled' on the first poll instead of a 30 s client timeout. Prod showed 309 of the 327 never-extracted uploads were the paywall working silently. - Self-generated documents (our own invoice PDFs, payout files) are no longer OCR'd. - Agent invoke answers 503 ai_unconfigured when the deployment has no assistant backend, distinct from the paywall. Guard: new direct-ai-client antipattern check (shrink-only allowlist of the pre-abstraction SDK callers) plus exact pins for @anthropic-ai/sdk, ai and @ai-sdk/openai-compatible. Verified: 15 958 unit tests green, guards, lint ratchet, typecheck, and a live smoke against hosted Bedrock through the new service (ping, streamed tool turn, thinking+cache, PDF extraction). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat(ai): make AI_API_KEY optional for OpenAI-compatible endpoints (keyless local model servers) A local model server (llama.cpp's server, Ollama /v1, LM Studio, vLLM) usually has no auth. Before, the OpenAI-compatible backend required both AI_BASE_URL and AI_API_KEY to count as configured, so running Accounted on a local model meant setting a meaningless placeholder key. - resolveAiProvider / hasAiCredentials: a base URL alone is now enough. - services/openai-compatible: only send Authorization: Bearer when AI_API_KEY is set, so a keyless server is never handed an empty bearer; a hosted provider that needs a key still sets it. - Docs (SELF-HOSTING Option 3: local-model example, key marked optional), DECISIONS. Verified: with no AI_API_KEY, just AI_BASE_URL + AI_MODEL, getAiStatus() reports configured=true / provider=openai-compatible (live). lib/ai suite 71 green; tsc, guards, lint clean. Bedrock/Anthropic logic unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
113 lines
3.8 KiB
JSON
113 lines
3.8 KiB
JSON
{
|
|
"name": "erp-base",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"license": "AGPL-3.0-or-later",
|
|
"scripts": {
|
|
"setup:extensions": "npx tsx scripts/generate-extension-registry.ts",
|
|
"skills:generate": "npx tsx scripts/generate-skill-bodies.ts",
|
|
"skills:check": "npx tsx scripts/generate-skill-bodies.ts --check",
|
|
"apiskill:generate": "npx tsx --conditions react-server scripts/api-skill/generate.ts",
|
|
"apiskill:check": "npx tsx --conditions react-server scripts/api-skill/generate.ts --check",
|
|
"crontabs:generate": "npx tsx scripts/generate-crontabs.ts",
|
|
"taxonomy:generate": "npx tsx scripts/generate-taxonomy-registry.ts",
|
|
"taxonomy:check": "npx tsx scripts/generate-taxonomy-registry.ts --check",
|
|
"validate:ixbrl": "node scripts/validate-ixbrl.mjs",
|
|
"predev": "npm run setup:extensions && node scripts/inject-public-branding.mjs",
|
|
"dev": "next dev",
|
|
"prebuild": "npm run setup:extensions && node scripts/inject-public-branding.mjs",
|
|
"build": "next build",
|
|
"start": "next start",
|
|
"lint": "eslint",
|
|
"check:guards": "node scripts/checks/no-new-antipatterns.mjs",
|
|
"validate:packs": "npx tsx scripts/validate-packs.ts",
|
|
"validate:registry": "npx tsx scripts/validate-registry.ts",
|
|
"check:lint": "node scripts/checks/no-new-lint-errors.mjs",
|
|
"test": "vitest run --project unit",
|
|
"test:pg": "vitest run --project pg-real"
|
|
},
|
|
"dependencies": {
|
|
"@ai-sdk/openai-compatible": "2.0.69",
|
|
"@anthropic-ai/bedrock-sdk": "0.29.1",
|
|
"@anthropic-ai/sdk": "0.95.0",
|
|
"@hookform/resolvers": "^5.4.0",
|
|
"@radix-ui/react-checkbox": "^1.3.7",
|
|
"@radix-ui/react-dialog": "^1.1.19",
|
|
"@radix-ui/react-dropdown-menu": "^2.1.20",
|
|
"@radix-ui/react-label": "^2.1.11",
|
|
"@radix-ui/react-progress": "^1.1.12",
|
|
"@radix-ui/react-select": "^2.3.3",
|
|
"@radix-ui/react-slot": "^1.2.4",
|
|
"@radix-ui/react-switch": "^1.3.3",
|
|
"@radix-ui/react-tabs": "^1.1.17",
|
|
"@radix-ui/react-toast": "^1.2.19",
|
|
"@radix-ui/react-tooltip": "^1.2.12",
|
|
"@react-pdf/renderer": "^4.5.1",
|
|
"@supabase/ssr": "^0.12.1",
|
|
"@supabase/supabase-js": "^2.110.1",
|
|
"@tailwindcss/typography": "^0.5.20",
|
|
"@types/qrcode": "^1.5.6",
|
|
"@upstash/ratelimit": "^2.0.8",
|
|
"@upstash/redis": "^1.38.0",
|
|
"@use-gesture/react": "^10.3.1",
|
|
"@vercel/speed-insights": "^2.0.0",
|
|
"ai": "6.0.259",
|
|
"class-variance-authority": "^0.7.1",
|
|
"clsx": "^2.1.1",
|
|
"date-fns": "^4.4.0",
|
|
"framer-motion": "^12.42.2",
|
|
"fuse.js": "^7.4.2",
|
|
"ics": "^3.12.0",
|
|
"js-yaml": "4.3.1",
|
|
"jszip": "^3.10.1",
|
|
"lucide-react": "^1.24.0",
|
|
"mailparser": "^3.9.14",
|
|
"next": "16.3.1",
|
|
"next-intl": "^4.13.2",
|
|
"next-themes": "^0.4.6",
|
|
"pdf-lib": "^1.17.1",
|
|
"posthog-js": "^1.407.3",
|
|
"posthog-node": "^5.46.1",
|
|
"qrcode": "^1.5.4",
|
|
"react": "19.2.7",
|
|
"react-dom": "19.2.7",
|
|
"react-hook-form": "^7.80.0",
|
|
"react-markdown": "^10.1.0",
|
|
"recharts": "^3.9.1",
|
|
"remark-gfm": "^4.0.1",
|
|
"resend": "^6.17.2",
|
|
"server-only": "^0.0.1",
|
|
"sharp": "^0.35.3",
|
|
"stripe": "^22.3.1",
|
|
"svix": "^1.85.0",
|
|
"swr": "^2.4.2",
|
|
"tailwind-merge": "^3.6.0",
|
|
"web-push": "^3.6.7",
|
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
"zod": "^4.4.3"
|
|
},
|
|
"devDependencies": {
|
|
"@tailwindcss/postcss": "^4",
|
|
"@types/js-yaml": "4.0.9",
|
|
"@types/mailparser": "^3.4.6",
|
|
"@types/node": "^20",
|
|
"@types/pg": "^8.20.0",
|
|
"@types/react": "^19",
|
|
"@types/react-dom": "^19",
|
|
"@types/sharp": "^0.32.0",
|
|
"@types/web-push": "^3.6.4",
|
|
"dotenv": "^17.4.2",
|
|
"eslint": "^9",
|
|
"eslint-config-next": "16.3.1",
|
|
"pg": "^8.22.0",
|
|
"tailwindcss": "^4",
|
|
"typescript": "^5",
|
|
"vitest": "^4.1.9"
|
|
},
|
|
"overrides": {
|
|
"ws": "^8.21.0",
|
|
"sharp": "^0.35.3",
|
|
"postcss": "^8.5.18"
|
|
}
|
|
}
|