veryfront 0.1.73 → 0.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/esm/cli/commands/knowledge/command-help.d.ts.map +1 -1
  2. package/esm/cli/commands/knowledge/command-help.js +3 -1
  3. package/esm/cli/commands/knowledge/command.d.ts +32 -5
  4. package/esm/cli/commands/knowledge/command.d.ts.map +1 -1
  5. package/esm/cli/commands/knowledge/command.js +87 -21
  6. package/esm/cli/commands/knowledge/parser-source.d.ts.map +1 -1
  7. package/esm/cli/commands/knowledge/parser-source.js +110 -5
  8. package/esm/deno.js +1 -1
  9. package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts +2 -0
  10. package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
  11. package/esm/src/server/handlers/request/ssr/ssr.handler.js +6 -2
  12. package/esm/src/server/runtime-handler/adapter-factory.d.ts +3 -0
  13. package/esm/src/server/runtime-handler/adapter-factory.d.ts.map +1 -1
  14. package/esm/src/server/runtime-handler/adapter-factory.js +6 -5
  15. package/esm/src/server/runtime-handler/index.d.ts +33 -0
  16. package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
  17. package/esm/src/server/runtime-handler/index.js +103 -37
  18. package/esm/src/server/runtime-handler/local-project-discovery.d.ts +32 -4
  19. package/esm/src/server/runtime-handler/local-project-discovery.d.ts.map +1 -1
  20. package/esm/src/server/runtime-handler/local-project-discovery.js +46 -16
  21. package/esm/src/server/services/rendering/ssr.service.d.ts +19 -1
  22. package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
  23. package/esm/src/server/services/rendering/ssr.service.js +9 -1
  24. package/esm/src/server/shared/renderer/adapter.d.ts +25 -0
  25. package/esm/src/server/shared/renderer/adapter.d.ts.map +1 -1
  26. package/esm/src/server/shared/renderer/adapter.js +83 -10
  27. package/esm/src/server/shared/renderer/index.d.ts +1 -1
  28. package/esm/src/server/shared/renderer/index.d.ts.map +1 -1
  29. package/esm/src/server/shared/renderer/index.js +1 -1
  30. package/package.json +1 -1
  31. package/src/cli/commands/knowledge/command-help.ts +3 -1
  32. package/src/cli/commands/knowledge/command.ts +104 -21
  33. package/src/cli/commands/knowledge/parser-source.ts +110 -5
  34. package/src/deno.js +1 -1
  35. package/src/src/server/handlers/request/ssr/ssr.handler.ts +11 -2
  36. package/src/src/server/runtime-handler/adapter-factory.ts +13 -5
  37. package/src/src/server/runtime-handler/index.ts +132 -39
  38. package/src/src/server/runtime-handler/local-project-discovery.ts +51 -17
  39. package/src/src/server/services/rendering/ssr.service.ts +34 -3
  40. package/src/src/server/shared/renderer/adapter.ts +107 -8
  41. package/src/src/server/shared/renderer/index.ts +7 -1
@@ -1 +1 @@
1
- {"version":3,"file":"command-help.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command-help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,aAAa,EAAE,WAqC3B,CAAC"}
1
+ {"version":3,"file":"command-help.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command-help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,aAAa,EAAE,WAuC3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export const knowledgeHelp = {
2
2
  name: "knowledge",
3
3
  description: "Ingest documents into the project knowledge base",
4
- usage: "veryfront knowledge ingest <source> [options]",
4
+ usage: "veryfront knowledge ingest <source...> [options]",
5
5
  options: [
6
6
  {
7
7
  flag: "--project, -p <slug>",
@@ -26,6 +26,7 @@ export const knowledgeHelp = {
26
26
  ],
27
27
  examples: [
28
28
  "veryfront knowledge ingest uploads/contracts/q1.pdf --json",
29
+ "veryfront knowledge ingest uploads/contracts/a.pdf uploads/contracts/b.pdf uploads/contracts/c.pdf --json",
29
30
  "veryfront knowledge ingest /workspace/uploads/q1.pdf --json",
30
31
  "veryfront knowledge ingest --path uploads/ --all --json",
31
32
  ],
@@ -34,5 +35,6 @@ export const knowledgeHelp = {
34
35
  "`uploads/...` means a remote project upload; use `./uploads/...` or `/workspace/uploads/...` to force a local file",
35
36
  "`ingest` orchestrates upload resolution, parsing, and project file writes",
36
37
  "Requires python3; non-text formats also require the supported parser packages unless you run inside the Veryfront sandbox",
38
+ "The Veryfront sandbox image includes `kreuzberg`, and knowledge ingest falls back to the built-in parser when `kreuzberg` is unavailable or extraction fails",
37
39
  ],
38
40
  };
@@ -41,10 +41,10 @@ type DownloadResult = {
41
41
  localPath: string;
42
42
  bytes?: number;
43
43
  };
44
- declare const KnowledgeIngestArgsSchema: z.ZodObject<{
44
+ declare const KnowledgeIngestArgsSchema: z.ZodEffects<z.ZodObject<{
45
45
  projectSlug: z.ZodOptional<z.ZodString>;
46
46
  projectDir: z.ZodOptional<z.ZodString>;
47
- source: z.ZodOptional<z.ZodString>;
47
+ sources: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
48
48
  path: z.ZodOptional<z.ZodString>;
49
49
  all: z.ZodDefault<z.ZodBoolean>;
50
50
  recursive: z.ZodDefault<z.ZodBoolean>;
@@ -58,6 +58,7 @@ declare const KnowledgeIngestArgsSchema: z.ZodObject<{
58
58
  json: boolean;
59
59
  recursive: boolean;
60
60
  all: boolean;
61
+ sources: string[];
61
62
  quiet: boolean;
62
63
  knowledgePath: string;
63
64
  path?: string | undefined;
@@ -66,7 +67,6 @@ declare const KnowledgeIngestArgsSchema: z.ZodObject<{
66
67
  outputDir?: string | undefined;
67
68
  projectDir?: string | undefined;
68
69
  slug?: string | undefined;
69
- source?: string | undefined;
70
70
  }, {
71
71
  path?: string | undefined;
72
72
  projectSlug?: string | undefined;
@@ -77,7 +77,33 @@ declare const KnowledgeIngestArgsSchema: z.ZodObject<{
77
77
  projectDir?: string | undefined;
78
78
  slug?: string | undefined;
79
79
  all?: boolean | undefined;
80
- source?: string | undefined;
80
+ sources?: string[] | undefined;
81
+ quiet?: boolean | undefined;
82
+ knowledgePath?: string | undefined;
83
+ }>, {
84
+ json: boolean;
85
+ recursive: boolean;
86
+ all: boolean;
87
+ sources: string[];
88
+ quiet: boolean;
89
+ knowledgePath: string;
90
+ path?: string | undefined;
91
+ projectSlug?: string | undefined;
92
+ description?: string | undefined;
93
+ outputDir?: string | undefined;
94
+ projectDir?: string | undefined;
95
+ slug?: string | undefined;
96
+ }, {
97
+ path?: string | undefined;
98
+ projectSlug?: string | undefined;
99
+ description?: string | undefined;
100
+ outputDir?: string | undefined;
101
+ json?: boolean | undefined;
102
+ recursive?: boolean | undefined;
103
+ projectDir?: string | undefined;
104
+ slug?: string | undefined;
105
+ all?: boolean | undefined;
106
+ sources?: string[] | undefined;
81
107
  quiet?: boolean | undefined;
82
108
  knowledgePath?: string | undefined;
83
109
  }>;
@@ -102,8 +128,9 @@ export declare function runKnowledgeParser(input: {
102
128
  description?: string;
103
129
  slug?: string;
104
130
  sourceReference?: string;
131
+ env?: Record<string, string>;
105
132
  }): Promise<KnowledgeParserResult>;
106
- export declare function collectKnowledgeSources(options: Pick<KnowledgeIngestOptions, "source" | "path" | "all" | "recursive">, deps: {
133
+ export declare function collectKnowledgeSources(options: Pick<KnowledgeIngestOptions, "sources" | "path" | "all" | "recursive">, deps: {
107
134
  client: ApiClient;
108
135
  projectSlug: string;
109
136
  downloadUploads: (uploadPaths: string[]) => Promise<DownloadResult[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,KAAK,SAAS,EAA0C,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAqBxD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,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,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CACvE,GACA,OAAO,CAAC,eAAe,EAAE,CAAC,CA0G5B;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,eAAe,EAAE,EAC1B,OAAO,EAAE,sBAAsB,EAC/B,IAAI,EAAE;IACJ,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,kBAAkB,CAAC;IACrC,mBAAmB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3F,GACA,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAkCtC;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwEtE"}
@@ -26,7 +26,7 @@ const SUPPORTED_EXTENSIONS = new Set([
26
26
  const KnowledgeIngestArgsSchema = z.object({
27
27
  projectSlug: z.string().optional(),
28
28
  projectDir: z.string().optional(),
29
- source: z.string().optional(),
29
+ sources: z.array(z.string()).default([]),
30
30
  path: z.string().optional(),
31
31
  all: z.boolean().default(false),
32
32
  recursive: z.boolean().default(false),
@@ -36,6 +36,39 @@ const KnowledgeIngestArgsSchema = z.object({
36
36
  slug: z.string().optional(),
37
37
  json: z.boolean().default(false),
38
38
  quiet: z.boolean().default(false),
39
+ }).superRefine((value, ctx) => {
40
+ const hasExplicitSources = value.sources.length > 0;
41
+ const hasPath = typeof value.path === "string" && value.path.length > 0;
42
+ if (hasExplicitSources && (hasPath || value.all)) {
43
+ ctx.addIssue({
44
+ code: z.ZodIssueCode.custom,
45
+ message: "Use either explicit source paths or --path with --all, not both.",
46
+ });
47
+ }
48
+ if (!hasExplicitSources && !hasPath && !value.all) {
49
+ ctx.addIssue({
50
+ code: z.ZodIssueCode.custom,
51
+ message: "Provide one or more source paths or use --path with --all.",
52
+ });
53
+ }
54
+ if (hasPath && !value.all) {
55
+ ctx.addIssue({
56
+ code: z.ZodIssueCode.custom,
57
+ message: "--path requires --all.",
58
+ });
59
+ }
60
+ if (!hasPath && value.all) {
61
+ ctx.addIssue({
62
+ code: z.ZodIssueCode.custom,
63
+ message: "--all requires --path.",
64
+ });
65
+ }
66
+ if (value.slug && value.sources.length !== 1) {
67
+ ctx.addIssue({
68
+ code: z.ZodIssueCode.custom,
69
+ message: "--slug can only be used with a single explicit source.",
70
+ });
71
+ }
39
72
  });
40
73
  function getStringArg(args, ...keys) {
41
74
  for (const key of keys) {
@@ -56,7 +89,7 @@ function showKnowledgeUsage() {
56
89
  Veryfront Knowledge
57
90
 
58
91
  Usage:
59
- veryfront knowledge ingest <source> [options]
92
+ veryfront knowledge ingest <source...> [options]
60
93
  veryfront knowledge ingest --path <prefix-or-dir> --all [options]
61
94
 
62
95
  Subcommands:
@@ -67,7 +100,7 @@ export function parseKnowledgeIngestArgs(args) {
67
100
  return KnowledgeIngestArgsSchema.safeParse({
68
101
  projectSlug: getStringArg(args, "project", "p", "project-slug"),
69
102
  projectDir: getStringArg(args, "project-dir", "dir", "d"),
70
- source: typeof args._[2] === "string" ? args._[2] : undefined,
103
+ sources: args._.slice(2).filter((value) => typeof value === "string"),
71
104
  path: getStringArg(args, "path"),
72
105
  all: getBooleanArg(args, "all"),
73
106
  recursive: getBooleanArg(args, "recursive"),
@@ -218,6 +251,7 @@ export async function runKnowledgeParser(input) {
218
251
  try {
219
252
  result = await new dntShim.Deno.Command("python3", {
220
253
  args: [scriptPath, "--input-json", inputJsonPath, "--output-json", outputJsonPath],
254
+ ...(input.env ? { env: input.env } : {}),
221
255
  stdout: "piped",
222
256
  stderr: "piped",
223
257
  }).output();
@@ -241,27 +275,56 @@ export async function runKnowledgeParser(input) {
241
275
  }
242
276
  export async function collectKnowledgeSources(options, deps) {
243
277
  const fs = createFileSystem();
244
- if (options.source) {
245
- if (!isProjectUploadReference(options.source) && await fs.exists(options.source)) {
246
- const localFiles = await collectLocalFiles(options.source, options.recursive);
247
- if (!localFiles.length)
248
- throw new Error(`No supported files found at ${options.source}`);
249
- return localFiles.map((localPath) => ({ kind: "local", input: options.source, localPath }));
278
+ if (options.sources.length > 0) {
279
+ const explicitSources = [];
280
+ const uploadTargets = [];
281
+ for (const input of options.sources) {
282
+ if (!isProjectUploadReference(input) && await fs.exists(input)) {
283
+ const localFiles = await collectLocalFiles(input, options.recursive);
284
+ if (!localFiles.length)
285
+ throw new Error(`No supported files found at ${input}`);
286
+ explicitSources.push({
287
+ kind: "local",
288
+ sources: localFiles.map((localPath) => ({ kind: "local", input, localPath })),
289
+ });
290
+ continue;
291
+ }
292
+ if (isLikelyLocalPath(input)) {
293
+ throw new Error(`Local file not found: ${input}`);
294
+ }
295
+ const uploadPath = normalizeProjectUploadPath(input);
296
+ explicitSources.push({ kind: "upload", input, uploadPath });
297
+ uploadTargets.push(uploadPath);
250
298
  }
251
- if (isLikelyLocalPath(options.source)) {
252
- throw new Error(`Local file not found: ${options.source}`);
299
+ const downloads = uploadTargets.length > 0 ? await deps.downloadUploads(uploadTargets) : [];
300
+ const downloadsByPath = new Map();
301
+ for (const download of downloads) {
302
+ const existing = downloadsByPath.get(download.uploadPath) ?? [];
303
+ existing.push(download);
304
+ downloadsByPath.set(download.uploadPath, existing);
253
305
  }
254
- const uploadPath = normalizeProjectUploadPath(options.source);
255
- const downloads = await deps.downloadUploads([uploadPath]);
256
- return downloads.map((download) => ({
257
- kind: "upload",
258
- input: options.source,
259
- uploadPath: download.uploadPath,
260
- localPath: download.localPath,
261
- }));
306
+ const resolvedSources = [];
307
+ for (const source of explicitSources) {
308
+ if (source.kind === "local") {
309
+ resolvedSources.push(...source.sources);
310
+ continue;
311
+ }
312
+ const matchingDownloads = downloadsByPath.get(source.uploadPath);
313
+ const download = matchingDownloads?.shift();
314
+ if (!download) {
315
+ throw new Error(`Upload not found: ${formatKnowledgeUploadSource(source.uploadPath)}`);
316
+ }
317
+ resolvedSources.push({
318
+ kind: "upload",
319
+ input: source.input,
320
+ uploadPath: download.uploadPath,
321
+ localPath: download.localPath,
322
+ });
323
+ }
324
+ return resolvedSources;
262
325
  }
263
326
  if (!options.path || !options.all) {
264
- throw new Error("Provide a source path or use --path with --all.");
327
+ throw new Error("Provide one or more source paths or use --path with --all.");
265
328
  }
266
329
  if (!isProjectUploadReference(options.path) && await fs.exists(options.path)) {
267
330
  const localFiles = await collectLocalFiles(options.path, options.recursive);
@@ -298,7 +361,10 @@ export async function collectKnowledgeSources(options, deps) {
298
361
  }));
299
362
  }
300
363
  export async function ingestResolvedSources(sources, options, deps) {
301
- const slugs = options.slug && sources.length === 1 ? [options.slug] : ensureUniqueSlugs(sources);
364
+ if (options.slug && sources.length !== 1) {
365
+ throw new Error("--slug can only be used with a single explicit source.");
366
+ }
367
+ const slugs = options.slug ? [options.slug] : ensureUniqueSlugs(sources);
302
368
  const results = [];
303
369
  for (const [index, source] of sources.entries()) {
304
370
  const parser = await deps.runParser({
@@ -1 +1 @@
1
- {"version":3,"file":"parser-source.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/parser-source.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,QA8ZvC,CAAC"}
1
+ {"version":3,"file":"parser-source.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/parser-source.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,QAugBvC,CAAC"}
@@ -3,6 +3,7 @@ import argparse
3
3
  import csv
4
4
  import json
5
5
  import re
6
+ import subprocess
6
7
  from datetime import date
7
8
  from pathlib import Path
8
9
  from typing import Any, Optional
@@ -71,6 +72,107 @@ def build_frontmatter(source: str, source_type: str, description: str) -> str:
71
72
  ])
72
73
 
73
74
 
75
+ def metadata_int(metadata: dict[str, Any], *keys: str) -> Optional[int]:
76
+ for key in keys:
77
+ value = metadata.get(key)
78
+ if isinstance(value, int) and not isinstance(value, bool):
79
+ return value
80
+ return None
81
+
82
+
83
+ def metadata_string_list(metadata: dict[str, Any], *keys: str) -> Optional[list[str]]:
84
+ for key in keys:
85
+ value = metadata.get(key)
86
+ if isinstance(value, list) and all(isinstance(item, str) for item in value):
87
+ return value
88
+ return None
89
+
90
+
91
+ def build_kreuzberg_stats(source_type: str, content: str, metadata: dict[str, Any]):
92
+ stats: dict[str, Any] = {
93
+ "characters": len(content),
94
+ "lines": len(content.splitlines()) if content else 0,
95
+ "engine": "kreuzberg",
96
+ }
97
+
98
+ if isinstance(metadata.get("mime_type"), str):
99
+ stats["mime_type"] = metadata["mime_type"]
100
+
101
+ if source_type == "pdf":
102
+ stats["pages"] = metadata_int(metadata, "page_count") or 0
103
+ stats["tables"] = metadata_int(metadata, "table_count") or 0
104
+ elif source_type in {"xlsx", "xls"}:
105
+ stats["sheets"] = metadata_int(metadata, "sheet_count") or 0
106
+ stats["rows"] = metadata_int(metadata, "row_count") or 0
107
+ stats["sheet_names"] = metadata_string_list(metadata, "sheet_names") or []
108
+ elif source_type == "docx":
109
+ stats["paragraphs"] = metadata_int(metadata, "paragraph_count") or 0
110
+ stats["tables"] = metadata_int(metadata, "table_count") or 0
111
+ elif source_type == "pptx":
112
+ stats["slides"] = metadata_int(metadata, "slide_count", "page_count") or 0
113
+ stats["tables"] = metadata_int(metadata, "table_count") or 0
114
+ elif source_type == "html":
115
+ stats["tables"] = metadata_int(metadata, "table_count") or 0
116
+
117
+ return stats
118
+
119
+
120
+ def parse_with_kreuzberg(path: str, source_type: str):
121
+ warnings: list[str] = []
122
+ completed = subprocess.run(
123
+ [
124
+ "kreuzberg",
125
+ "extract",
126
+ path,
127
+ "--format",
128
+ "json",
129
+ "--output-format",
130
+ "markdown",
131
+ ],
132
+ capture_output=True,
133
+ text=True,
134
+ check=False,
135
+ )
136
+
137
+ if completed.returncode != 0:
138
+ detail = completed.stderr.strip() or completed.stdout.strip() or f"exit code {completed.returncode}"
139
+ raise RuntimeError(f"kreuzberg extract failed: {detail}")
140
+
141
+ try:
142
+ payload = json.loads(completed.stdout)
143
+ except json.JSONDecodeError as error:
144
+ raise RuntimeError(f"kreuzberg extract returned invalid JSON: {error}") from error
145
+
146
+ content = payload.get("content", "")
147
+ if not isinstance(content, str):
148
+ raise RuntimeError("kreuzberg extract did not return string content")
149
+
150
+ metadata = payload.get("metadata") if isinstance(payload.get("metadata"), dict) else {}
151
+ normalized_content = clean_text(content)
152
+ stats = build_kreuzberg_stats(source_type, normalized_content, metadata)
153
+
154
+ return normalized_content or "_No extractable text found in document._", stats, warnings
155
+
156
+
157
+ def prefer_kreuzberg(source_type: str, fallback_parser):
158
+ def parser(path: str):
159
+ try:
160
+ return parse_with_kreuzberg(path, source_type)
161
+ except FileNotFoundError as error:
162
+ if getattr(error, "filename", "") == "kreuzberg":
163
+ return fallback_parser(path)
164
+ raise
165
+ except RuntimeError as error:
166
+ content, stats, warnings = fallback_parser(path)
167
+ warnings.append(
168
+ "kreuzberg extraction failed; fell back to the built-in parser: "
169
+ + str(error)
170
+ )
171
+ return content, stats, warnings
172
+
173
+ return parser
174
+
175
+
74
176
  def parse_csv_like(path: str, delimiter: str = ","):
75
177
  warnings: list[str] = []
76
178
  with open(path, newline="", encoding="utf-8-sig") as file:
@@ -305,18 +407,19 @@ def parse_json(path: str):
305
407
  def select_parser(path: Path):
306
408
  ext = path.suffix.lower()
307
409
  if ext == ".pdf":
308
- return "pdf", parse_pdf
410
+ return "pdf", prefer_kreuzberg("pdf", parse_pdf)
309
411
  if ext in {".csv", ".tsv"}:
310
412
  delimiter = "\t" if ext == ".tsv" else ","
311
413
  return ext.lstrip("."), lambda file_path: parse_csv_like(file_path, delimiter)
312
414
  if ext in {".xlsx", ".xls"}:
313
- return ext.lstrip("."), parse_excel
415
+ source_type = ext.lstrip(".")
416
+ return source_type, prefer_kreuzberg(source_type, parse_excel)
314
417
  if ext == ".docx":
315
- return "docx", parse_docx
418
+ return "docx", prefer_kreuzberg("docx", parse_docx)
316
419
  if ext == ".pptx":
317
- return "pptx", parse_pptx
420
+ return "pptx", prefer_kreuzberg("pptx", parse_pptx)
318
421
  if ext in {".html", ".htm"}:
319
- return "html", parse_html
422
+ return "html", prefer_kreuzberg("html", parse_html)
320
423
  if ext in {".txt", ".md", ".mdx"}:
321
424
  return ext.lstrip("."), parse_text
322
425
  if ext == ".json":
@@ -325,6 +428,8 @@ def select_parser(path: Path):
325
428
 
326
429
 
327
430
  def build_summary(source_type: str, stats: dict[str, Any]) -> str:
431
+ if stats.get("engine") == "kreuzberg":
432
+ return f"Converted {source_type.upper()} to markdown ({stats.get('characters', 0)} chars)."
328
433
  if source_type in {"csv", "tsv"}:
329
434
  return f"Parsed {stats.get('rows', 0)} rows across {stats.get('columns', 0)} columns."
330
435
  if source_type in {"xlsx", "xls"}:
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -9,6 +9,7 @@
9
9
  import * as dntShim from "../../../../../_dnt.shims.js";
10
10
  import { BaseHandler } from "../../response/base.js";
11
11
  import type { HandlerContext, HandlerMetadata, HandlerResult } from "../../types.js";
12
+ import { type SSRServiceLike } from "../../../services/rendering/ssr.service.js";
12
13
  /**
13
14
  * Determine if request should serve production (released) content.
14
15
  * Uses resolvedEnvironment (from domain lookup) with fallback to requestContext.mode.
@@ -29,6 +30,7 @@ export declare function isProductionMode(ctx: HandlerContext, _url?: URL): boole
29
30
  export declare class SSRHandler extends BaseHandler {
30
31
  metadata: HandlerMetadata;
31
32
  private ssrService;
33
+ constructor(ssrService?: SSRServiceLike);
32
34
  handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult>;
33
35
  private setupContextAndRender;
34
36
  private handleWithContext;
@@ -1 +1 @@
1
- {"version":3,"file":"ssr.handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/ssr/ssr.handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;AAiBxB;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAKzE;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,EAAE,eAAe,CAIvB;IAEF,OAAO,CAAC,UAAU,CAAoB;IAEtC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA8BzE,OAAO,CAAC,qBAAqB;IAgE7B,OAAO,CAAC,iBAAiB;YAuDX,cAAc;YA6Bd,sBAAsB;YAgBtB,aAAa;CAU5B"}
1
+ {"version":3,"file":"ssr.handler.d.ts","sourceRoot":"","sources":["../../../../../../src/src/server/handlers/request/ssr/ssr.handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAEf,aAAa,EACd,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,4CAA4C,CAAC;AAMpD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAKzE;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,EAAE,eAAe,CAIvB;IAEF,OAAO,CAAC,UAAU,CAAiB;gBAEvB,UAAU,CAAC,EAAE,cAAc;IAKvC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA8BzE,OAAO,CAAC,qBAAqB;IAgE7B,OAAO,CAAC,iBAAiB;YAuDX,cAAc;YA6Bd,sBAAsB;YAgBtB,aAAa;CAU5B"}
@@ -9,7 +9,7 @@ import { serverLogger } from "../../../../utils/index.js";
9
9
  import { endRequest, startRequest } from "../../../../utils/index.js";
10
10
  import { tryNotFoundFallback } from "./not-found-fallback.js";
11
11
  import { tryErrorPageFallback } from "./error-page-fallback.js";
12
- import { SSRService } from "../../../services/rendering/ssr.service.js";
12
+ import { SSRService, } from "../../../services/rendering/ssr.service.js";
13
13
  import { ErrorPages } from "../../../utils/error-html.js";
14
14
  import { buildSSRResponse } from "./ssr-response-builder.js";
15
15
  const logger = serverLogger.component("ssr");
@@ -41,7 +41,11 @@ export class SSRHandler extends BaseHandler {
41
41
  priority: PRIORITY_LOW,
42
42
  patterns: [{ pattern: /^(?!\/_).*/, method: ["GET", "HEAD"] }],
43
43
  };
44
- ssrService = new SSRService();
44
+ ssrService;
45
+ constructor(ssrService) {
46
+ super();
47
+ this.ssrService = ssrService ?? new SSRService();
48
+ }
45
49
  handle(req, ctx) {
46
50
  const url = new URL(req.url);
47
51
  const pathname = url.pathname;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { RuntimeAdapter } from "../../platform/adapters/base.js";
10
10
  import type { VeryfrontConfig } from "../../config/index.js";
11
+ import { type ProjectDiscoveryCache } from "./local-project-discovery.js";
11
12
  import type { ParsedDomain } from "../utils/domain-parser.js";
12
13
  interface AdapterResolutionResult {
13
14
  /** The effective project directory to use */
@@ -46,6 +47,8 @@ interface AdapterResolutionOptions {
46
47
  headerProjectPath: string | undefined;
47
48
  /** Whether running in proxy mode */
48
49
  isProxyMode: boolean;
50
+ /** Optional injectable cache (defaults to module-level singleton) */
51
+ cache?: ProjectDiscoveryCache;
49
52
  }
50
53
  /**
51
54
  * Resolve the effective adapter and config for a request.
@@ -1 +1 @@
1
- {"version":3,"file":"adapter-factory.d.ts","sourceRoot":"","sources":["../../../../src/src/server/runtime-handler/adapter-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,uBAAuB;IAC/B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,EAAE,cAAc,CAAC;IACxB,kCAAkC;IAClC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,yDAAyD;IACzD,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,UAAU,wBAAwB;IAChC,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,6BAA6B;IAC7B,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,mBAAmB;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,iBAAiB;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,kBAAkB;IAClB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,iBAAiB;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,uCAAuC;IACvC,QAAQ,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAC/C,kBAAkB;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,yCAAyC;IACzC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,yBAAyB;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,+BAA+B;IAC/B,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,oCAAoC;IACpC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAmHlC"}
1
+ {"version":3,"file":"adapter-factory.d.ts","sourceRoot":"","sources":["../../../../src/src/server/runtime-handler/adapter-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,UAAU,uBAAuB;IAC/B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,OAAO,EAAE,cAAc,CAAC;IACxB,kCAAkC;IAClC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,yDAAyD;IACzD,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,UAAU,wBAAwB;IAChC,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,6BAA6B;IAC7B,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,mBAAmB;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,iBAAiB;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,kBAAkB;IAClB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,iBAAiB;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,uCAAuC;IACvC,QAAQ,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAC/C,kBAAkB;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,yCAAyC;IACzC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,yBAAyB;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,+BAA+B;IAC/B,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,oCAAoC;IACpC,WAAW,EAAE,OAAO,CAAC;IACrB,qEAAqE;IACrE,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAqHlC"}
@@ -12,7 +12,7 @@ import { runtime } from "../../platform/adapters/detect.js";
12
12
  import { isExtendedFSAdapter } from "../../platform/adapters/fs/wrapper.js";
13
13
  import { getConfig } from "../../config/loader.js";
14
14
  import { timeAsync } from "./request-lifecycle.js";
15
- import { findLocalProjectPath, localAdapterCache } from "./local-project-discovery.js";
15
+ import { defaultDiscoveryCache, findLocalProjectPath, } from "./local-project-discovery.js";
16
16
  const baseLogger = getBaseLogger("SERVER");
17
17
  const logger = baseLogger.component("adapter-factory");
18
18
  /**
@@ -22,6 +22,7 @@ const logger = baseLogger.component("adapter-factory");
22
22
  * For proxy mode: Uses VeryFront API adapter with project context.
23
23
  */
24
24
  export async function resolveAdapter(opts) {
25
+ const cache = opts.cache ?? defaultDiscoveryCache;
25
26
  let effectiveProjectDir = opts.projectDir;
26
27
  let effectiveAdapter = opts.adapter;
27
28
  let effectiveConfig = opts.config;
@@ -31,7 +32,7 @@ export async function resolveAdapter(opts) {
31
32
  const trustedHeaderProjectPath = opts.isProxyMode ? opts.headerProjectPath : undefined;
32
33
  const shouldCheckLocalPath = opts.projectSlug && (!opts.isProxyMode || trustedHeaderProjectPath);
33
34
  const localProjectPath = shouldCheckLocalPath
34
- ? await findLocalProjectPath(opts.projectSlug, opts.adapter, trustedHeaderProjectPath)
35
+ ? await findLocalProjectPath(opts.projectSlug, opts.adapter, trustedHeaderProjectPath, cache)
35
36
  : undefined;
36
37
  const isLocalProject = !!localProjectPath;
37
38
  if (isLocalProject && localProjectPath) {
@@ -41,15 +42,15 @@ export async function resolveAdapter(opts) {
41
42
  projectDir: effectiveProjectDir,
42
43
  });
43
44
  // Get or create local adapter
44
- if (!localAdapterCache.has(effectiveProjectDir)) {
45
+ if (!cache.adapters.has(effectiveProjectDir)) {
45
46
  const baseAdapter = await runtime.get();
46
- localAdapterCache.set(effectiveProjectDir, baseAdapter);
47
+ cache.adapters.set(effectiveProjectDir, baseAdapter);
47
48
  logger.debug("Created local adapter for project", {
48
49
  projectSlug: opts.projectSlug,
49
50
  projectDir: effectiveProjectDir,
50
51
  });
51
52
  }
52
- effectiveAdapter = localAdapterCache.get(effectiveProjectDir);
53
+ effectiveAdapter = cache.adapters.get(effectiveProjectDir);
53
54
  // Load project-specific config
54
55
  try {
55
56
  effectiveConfig = await timeAsync("config:load-project", () => getConfig(effectiveProjectDir, effectiveAdapter));
@@ -9,7 +9,40 @@
9
9
  import * as dntShim from "../../../_dnt.shims.js";
10
10
  import type { RuntimeAdapter } from "../../platform/adapters/base.js";
11
11
  import type { VeryfrontConfig } from "../../config/index.js";
12
+ import { RouteRegistry } from "../../routing/registry/index.js";
13
+ import type { Handler } from "../../types/index.js";
14
+ import { ApiHandlerWrapper } from "../handlers/request/api/index.js";
12
15
  export { parseProxyEnvironment, type ProxyEnvironment } from "./proxy-environment.js";
16
+ /** Handler names in registration order. */
17
+ export declare const HANDLER_NAMES: readonly ["AuthHandler", "CsrfHandler", "HMRHandler", "CorsHandler", "HealthHandler", "MetricsHandler", "MemoryDebugHandler", "ClientLogHandler", "DevEndpointsHandler", "StylesCSSHandler", "DebugContextHandler", "OpenAPIHandler", "OpenAPIDocsHandler", "InternalAgentsListHandler", "AgentStreamHandler", "AgentRunResumeHandler", "AgentRunCancelHandler", "ChannelInvokeHandler", "DevDashboardHandler", "ProjectsHandler", "StudioBridgeModulesHandler", "CSSHandler", "DevFileHandler", "SnippetHandler", "StaticHandler", "LibModulesHandler", "RSCHandler", "ModuleHandler", "ApiHandlerWrapper", "MarkdownPreviewHandler", "SSRHandler", "NotFoundHandler"];
18
+ /** Union of all registered handler names. */
19
+ export type HandlerName = (typeof HANDLER_NAMES)[number];
20
+ /**
21
+ * Dependencies for handler registry creation.
22
+ * All fields are optional — when omitted, the real handler implementation is used.
23
+ * This allows tests to inject mock handlers for specific slots.
24
+ */
25
+ export interface HandlerDependencies {
26
+ /** Override any handler by its typed name. */
27
+ overrides?: Partial<Record<HandlerName, Handler>>;
28
+ /** When true, log handler registration details. */
29
+ debug?: boolean;
30
+ }
31
+ /**
32
+ * Creates a RouteRegistry populated with the standard handler chain.
33
+ *
34
+ * Handlers are instantiated lazily — overridden slots skip construction
35
+ * of the default handler entirely.
36
+ *
37
+ * @param projectDir - Root project directory
38
+ * @param adapter - Runtime adapter for environment access
39
+ * @param deps - Optional dependency overrides for testing
40
+ * @returns Object containing the registry and the api handler (for initialization)
41
+ */
42
+ export declare function createHandlerRegistry(projectDir: string, adapter: RuntimeAdapter, deps?: HandlerDependencies): {
43
+ registry: RouteRegistry;
44
+ apiHandler: ApiHandlerWrapper;
45
+ };
13
46
  export interface RuntimeHandlerOptions {
14
47
  projectDir: string;
15
48
  /** When true, expose additional debug logging. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/server/runtime-handler/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAQlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM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