Files
Stirling-PDF/frontend/vite.config.ts
T
ReeceandClaude Opus 4.7 b32a3cf271 Merge origin/main into AI-Form-Fill
Resolution favours main for all conflicts (new orchestrator shape with
artifacts/file_names/conversation_history/resume_with, WorkflowOutcome
enum, RAG, ledger agent, deleted engine/config/.env.example).

Re-wires our three form-fill agents (FormAnalyserAgent, FormFillerAgent,
DocumentExtractorAgent) into the new app layout:
- contracts/__init__.py: adds form-fill exports to __all__
- api/dependencies.py: adds get_form_analyser_agent / get_form_filler_agent / get_document_extractor_agent
- api/app.py: instantiates the three agents in lifespan and registers form_fill_router
- api/routes/__init__.py: exports form_fill_router
- tests/test_stirling_api.py: imports and registers form-fill stubs
- tests/test_stirling_contracts.py: adds back KnowledgeUpdateResponse discriminator test

Form fill remains accessible via its own endpoints (/api/v1/form/ai/analyse,
/fill-batch, /extract). Not wired as an orchestrator delegate — following
main's pattern where orchestrator only routes pdf_edit/pdf_question/user_spec
/math_auditor.

Follow-ups still needed:
- Thread conversation_history into form-fill agent prompts
- Align form-fill response outcomes with WorkflowOutcome enum
- Decide whether engine should return ToolOperationStep plans (main's
  new pattern per #6116) or keep returning fill values directly

All 127 engine tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 13:13:12 +01:00

141 lines
4.4 KiB
TypeScript

import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from "vite-tsconfig-paths";
import { viteStaticCopy } from "vite-plugin-static-copy";
const VALID_MODES = [
"core",
"proprietary",
"saas",
"desktop",
"prototypes",
] as const;
type BuildMode = (typeof VALID_MODES)[number];
const TSCONFIG_MAP: Record<BuildMode, string> = {
core: "./tsconfig.core.vite.json",
proprietary: "./tsconfig.proprietary.vite.json",
saas: "./tsconfig.saas.vite.json",
desktop: "./tsconfig.desktop.vite.json",
prototypes: "./tsconfig.prototypes.vite.json",
};
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the
// `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), "");
// Resolve the effective build mode.
// Explicit --mode flags take precedence; otherwise default to proprietary
// unless DISABLE_ADDITIONAL_FEATURES=true, in which case default to core.
const effectiveMode: BuildMode = (VALID_MODES as readonly string[]).includes(
mode,
)
? (mode as BuildMode)
: process.env.DISABLE_ADDITIONAL_FEATURES === "true"
? "core"
: "proprietary";
const tsconfigProject = TSCONFIG_MAP[effectiveMode];
const backendTarget = `http://localhost:${env.VITE_BACKEND_PORT || '8080'}`;
const aiEngineTarget = `http://localhost:${env.VITE_AI_ENGINE_PORT || '5001'}`;
return {
plugins: [
react(),
tsconfigPaths({
projects: [tsconfigProject],
}),
viteStaticCopy({
targets: [
{
//provides static pdfium so embedpdf can run without cdn
src: "node_modules/@embedpdf/pdfium/dist/pdfium.wasm",
dest: "pdfium",
},
{
// Copy jscanify vendor files to dist
src: "public/vendor/jscanify/*",
dest: "vendor/jscanify",
},
{
// pdfjs-dist CMap data for CJK / non-latin glyph mapping — required
// when rendering PDFs inside workers where the default DOM fetch paths
// aren't available.
src: "node_modules/pdfjs-dist/cmaps/*",
dest: "pdfjs/cmaps",
},
{
// pdfjs-dist standard font data (Helvetica/Times/etc.) — needed so
// workers can substitute non-embedded base 14 fonts without DOM access.
src: "node_modules/pdfjs-dist/standard_fonts/*",
dest: "pdfjs/standard_fonts",
},
],
}),
],
server: {
host: true,
// make sure this port matches the devUrl port in tauri.conf.json file
port: 5173,
// Tauri expects a fixed port, fail if that port is not available
strictPort: true,
watch: {
// tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
// Only use proxy in web mode - Tauri handles backend connections directly
proxy:
effectiveMode === "desktop"
? undefined
: {
"/api": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/oauth2": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/saml2": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/login/oauth2": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/login/saml2": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/swagger-ui": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
"/v1/api-docs": {
target: "http://localhost:8080",
changeOrigin: true,
secure: false,
xfwd: true,
},
},
},
base: env.RUN_SUBPATH ? `/${env.RUN_SUBPATH}` : "./",
};
});