veryfront 0.1.74 → 0.1.75

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 (86) hide show
  1. package/esm/cli/commands/knowledge/command.d.ts +2 -0
  2. package/esm/cli/commands/knowledge/command.d.ts.map +1 -1
  3. package/esm/cli/commands/knowledge/command.js +64 -1
  4. package/esm/deno.d.ts +2 -0
  5. package/esm/deno.js +3 -1
  6. package/esm/src/data/data-fetcher.d.ts +11 -1
  7. package/esm/src/data/data-fetcher.d.ts.map +1 -1
  8. package/esm/src/data/data-fetcher.js +5 -2
  9. package/esm/src/data/index.d.ts +1 -1
  10. package/esm/src/data/index.d.ts.map +1 -1
  11. package/esm/src/data/server-data-fetcher.d.ts +14 -1
  12. package/esm/src/data/server-data-fetcher.d.ts.map +1 -1
  13. package/esm/src/data/server-data-fetcher.js +49 -3
  14. package/esm/src/rendering/orchestrator/lifecycle.d.ts +4 -0
  15. package/esm/src/rendering/orchestrator/lifecycle.d.ts.map +1 -1
  16. package/esm/src/rendering/orchestrator/lifecycle.js +8 -0
  17. package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
  18. package/esm/src/rendering/orchestrator/pipeline.js +6 -1
  19. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts +26 -1
  20. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
  21. package/esm/src/rendering/orchestrator/ssr-orchestrator.js +77 -1
  22. package/esm/src/routing/api/handler.d.ts.map +1 -1
  23. package/esm/src/routing/api/handler.js +6 -2
  24. package/esm/src/routing/api/route-executor.d.ts +8 -2
  25. package/esm/src/routing/api/route-executor.d.ts.map +1 -1
  26. package/esm/src/routing/api/route-executor.js +131 -3
  27. package/esm/src/security/deno-permissions.d.ts +6 -0
  28. package/esm/src/security/deno-permissions.d.ts.map +1 -1
  29. package/esm/src/security/deno-permissions.js +10 -0
  30. package/esm/src/security/sandbox/project-worker.d.ts +61 -0
  31. package/esm/src/security/sandbox/project-worker.d.ts.map +1 -0
  32. package/esm/src/security/sandbox/project-worker.js +318 -0
  33. package/esm/src/security/sandbox/worker-permissions.d.ts +30 -0
  34. package/esm/src/security/sandbox/worker-permissions.d.ts.map +1 -0
  35. package/esm/src/security/sandbox/worker-permissions.js +60 -0
  36. package/esm/src/security/sandbox/worker-pool.d.ts +87 -0
  37. package/esm/src/security/sandbox/worker-pool.d.ts.map +1 -0
  38. package/esm/src/security/sandbox/worker-pool.js +356 -0
  39. package/esm/src/security/sandbox/worker-types.d.ts +165 -0
  40. package/esm/src/security/sandbox/worker-types.d.ts.map +1 -0
  41. package/esm/src/security/sandbox/worker-types.js +17 -0
  42. package/esm/src/server/project-env/storage.d.ts +6 -0
  43. package/esm/src/server/project-env/storage.d.ts.map +1 -1
  44. package/esm/src/server/project-env/storage.js +8 -0
  45. package/esm/src/server/runtime-handler/project-isolation.d.ts +5 -0
  46. package/esm/src/server/runtime-handler/project-isolation.d.ts.map +1 -1
  47. package/esm/src/server/runtime-handler/project-isolation.js +44 -0
  48. package/esm/src/server/shared/renderer/memory/pressure.d.ts +7 -0
  49. package/esm/src/server/shared/renderer/memory/pressure.d.ts.map +1 -1
  50. package/esm/src/server/shared/renderer/memory/pressure.js +7 -0
  51. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.d.ts +4 -4
  52. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.d.ts.map +1 -1
  53. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.js +15 -15
  54. package/esm/src/utils/index.d.ts +10 -1
  55. package/esm/src/utils/index.d.ts.map +1 -1
  56. package/esm/src/utils/index.js +9 -1
  57. package/esm/src/utils/logger/index.d.ts +1 -1
  58. package/esm/src/utils/logger/index.d.ts.map +1 -1
  59. package/esm/src/utils/logger/index.js +1 -1
  60. package/esm/src/utils/logger/logger.d.ts +14 -0
  61. package/esm/src/utils/logger/logger.d.ts.map +1 -1
  62. package/esm/src/utils/logger/logger.js +17 -0
  63. package/esm/src/workflow/claude-code/tool.d.ts +5 -5
  64. package/package.json +4 -1
  65. package/src/cli/commands/knowledge/command.ts +76 -1
  66. package/src/deno.js +3 -1
  67. package/src/src/data/data-fetcher.ts +18 -2
  68. package/src/src/data/index.ts +1 -1
  69. package/src/src/data/server-data-fetcher.ts +78 -3
  70. package/src/src/rendering/orchestrator/lifecycle.ts +11 -0
  71. package/src/src/rendering/orchestrator/pipeline.ts +7 -2
  72. package/src/src/rendering/orchestrator/ssr-orchestrator.ts +119 -0
  73. package/src/src/routing/api/handler.ts +16 -3
  74. package/src/src/routing/api/route-executor.ts +222 -1
  75. package/src/src/security/deno-permissions.ts +11 -0
  76. package/src/src/security/sandbox/project-worker.ts +416 -0
  77. package/src/src/security/sandbox/worker-permissions.ts +74 -0
  78. package/src/src/security/sandbox/worker-pool.ts +451 -0
  79. package/src/src/security/sandbox/worker-types.ts +209 -0
  80. package/src/src/server/project-env/storage.ts +9 -0
  81. package/src/src/server/runtime-handler/project-isolation.ts +53 -0
  82. package/src/src/server/shared/renderer/memory/pressure.ts +8 -0
  83. package/src/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.ts +18 -12
  84. package/src/src/utils/index.ts +11 -0
  85. package/src/src/utils/logger/index.ts +1 -0
  86. package/src/src/utils/logger/logger.ts +34 -0
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type ApiClient } from "../../shared/config.js";
3
3
  import type { ParsedArgs } from "../../shared/types.js";
4
+ import { type Logger } from "../../../src/utils/index.js";
4
5
  export interface KnowledgeParserResult {
5
6
  success: true;
6
7
  source_path: string;
@@ -143,6 +144,7 @@ export declare function ingestResolvedSources(sources: KnowledgeSource[], option
143
144
  uploadKnowledgeFile: (remotePath: string, localPath: string) => Promise<{
144
145
  path: string;
145
146
  }>;
147
+ eventLogger?: Logger | null;
146
148
  }): Promise<KnowledgeIngestFileResult[]>;
147
149
  export declare function knowledgeCommand(args: ParsedArgs): Promise<void>;
148
150
  export {};
@@ -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,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,KAAK,eAAe,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,U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 @@
1
1
  import * as dntShim from "../../../_dnt.shims.js";
2
2
  import { z } from "zod";
3
- import { createFileSystem } from "../../../src/platform/index.js";
3
+ import { createFileSystem, getEnv } from "../../../src/platform/index.js";
4
4
  import { basename, extname, join, normalize, relative } from "../../../src/platform/compat/path/index.js";
5
5
  import { withSpan } from "../../../src/observability/tracing/otlp-setup.js";
6
6
  import { cliLogger } from "../../utils/index.js";
@@ -8,6 +8,7 @@ import { createApiClient, resolveConfigWithAuth } from "../../shared/config.js";
8
8
  import { downloadUploadToFile, listAllUploads } from "../uploads/command.js";
9
9
  import { putRemoteFileFromLocal } from "../files/command.js";
10
10
  import { knowledgeIngestPythonSource } from "./parser-source.js";
11
+ import { createJobUserLogger, serverLogger } from "../../../src/utils/index.js";
11
12
  const SUPPORTED_EXTENSIONS = new Set([
12
13
  ".pdf",
13
14
  ".csv",
@@ -23,6 +24,7 @@ const SUPPORTED_EXTENSIONS = new Set([
23
24
  ".md",
24
25
  ".mdx",
25
26
  ]);
27
+ const knowledgeJobLogger = serverLogger.component("knowledge-ingest");
26
28
  const KnowledgeIngestArgsSchema = z.object({
27
29
  projectSlug: z.string().optional(),
28
30
  projectDir: z.string().optional(),
@@ -84,6 +86,23 @@ function getBooleanArg(args, ...keys) {
84
86
  function printJson(value) {
85
87
  console.log(JSON.stringify(value, null, 2));
86
88
  }
89
+ function createKnowledgeIngestEventLogger() {
90
+ const projectId = getEnv("TENANT_PROJECT_ID");
91
+ const jobId = getEnv("JOB_ID");
92
+ if (!projectId || !jobId) {
93
+ return null;
94
+ }
95
+ return createJobUserLogger(knowledgeJobLogger, {
96
+ projectId,
97
+ jobId,
98
+ batchId: getEnv("JOB_BATCH_ID") ?? undefined,
99
+ jobTarget: getEnv("JOB_TARGET") ?? undefined,
100
+ task: "knowledge-ingest",
101
+ });
102
+ }
103
+ function buildKnowledgeSourceName(source) {
104
+ return basename(source.kind === "upload" ? source.uploadPath : source.localPath);
105
+ }
87
106
  function showKnowledgeUsage() {
88
107
  console.log(`
89
108
  Veryfront Knowledge
@@ -367,6 +386,12 @@ export async function ingestResolvedSources(sources, options, deps) {
367
386
  const slugs = options.slug ? [options.slug] : ensureUniqueSlugs(sources);
368
387
  const results = [];
369
388
  for (const [index, source] of sources.entries()) {
389
+ deps.eventLogger?.info("Processing knowledge source", {
390
+ phase: "file_processing",
391
+ progress_current: index + 1,
392
+ progress_total: sources.length,
393
+ source_name: buildKnowledgeSourceName(source),
394
+ });
370
395
  const parser = await deps.runParser({
371
396
  filePath: source.localPath,
372
397
  outputDir: deps.outputDir,
@@ -376,6 +401,23 @@ export async function ingestResolvedSources(sources, options, deps) {
376
401
  });
377
402
  const remotePath = deriveKnowledgeRemotePath(parser.sandbox_output_path, deps.outputDir, options.knowledgePath);
378
403
  const uploaded = await deps.uploadKnowledgeFile(remotePath, parser.sandbox_output_path);
404
+ deps.eventLogger?.info("Knowledge source ingested", {
405
+ phase: "file_completed",
406
+ progress_current: index + 1,
407
+ progress_total: sources.length,
408
+ source_name: buildKnowledgeSourceName(source),
409
+ remote_path: uploaded.path,
410
+ warning_count: parser.warnings.length,
411
+ });
412
+ if (parser.warnings.length > 0) {
413
+ deps.eventLogger?.warn("Knowledge source emitted warnings", {
414
+ phase: "file_warning",
415
+ progress_current: index + 1,
416
+ progress_total: sources.length,
417
+ source_name: buildKnowledgeSourceName(source),
418
+ warning_count: parser.warnings.length,
419
+ });
420
+ }
379
421
  results.push(createKnowledgeIngestResult({
380
422
  source: buildSourceReference(source),
381
423
  localSourcePath: source.localPath,
@@ -407,19 +449,34 @@ export async function knowledgeCommand(args) {
407
449
  const outputDir = options.outputDir ?? await defaultOutputRoot();
408
450
  const shouldCleanupOutputDir = options.outputDir === undefined;
409
451
  const downloadOutputDir = resolveKnowledgeDownloadOutputDir(outputDir);
452
+ const eventLogger = createKnowledgeIngestEventLogger();
410
453
  try {
454
+ eventLogger?.info("Starting knowledge ingest", {
455
+ phase: "started",
456
+ mode: options.path ? "path_prefix" : "explicit_sources",
457
+ });
411
458
  const sources = await collectKnowledgeSources(options, {
412
459
  client,
413
460
  projectSlug: config.projectSlug,
414
461
  downloadUploads: (uploadPaths) => Promise.all(uploadPaths.map((uploadPath) => downloadUploadToFile(client, config.projectSlug, uploadPath, downloadOutputDir))),
415
462
  });
463
+ eventLogger?.info("Resolved knowledge sources", {
464
+ phase: "sources_resolved",
465
+ progress_total: sources.length,
466
+ });
416
467
  const results = await ingestResolvedSources(sources, options, {
417
468
  client,
418
469
  projectSlug: config.projectSlug,
419
470
  outputDir,
420
471
  runParser: runKnowledgeParser,
472
+ eventLogger,
421
473
  uploadKnowledgeFile: (remotePath, localPath) => putRemoteFileFromLocal(client, config.projectSlug, remotePath, localPath),
422
474
  });
475
+ eventLogger?.info("Completed knowledge ingest", {
476
+ phase: "completed",
477
+ progress_current: results.length,
478
+ progress_total: results.length,
479
+ });
423
480
  if (options.json) {
424
481
  printJson(results);
425
482
  return;
@@ -431,6 +488,12 @@ export async function knowledgeCommand(args) {
431
488
  }
432
489
  }
433
490
  }
491
+ catch (error) {
492
+ eventLogger?.error("Knowledge ingest failed", {
493
+ phase: "failed",
494
+ });
495
+ throw error;
496
+ }
434
497
  finally {
435
498
  if (shouldCleanupOutputDir) {
436
499
  await Promise.all([
package/esm/deno.d.ts CHANGED
@@ -24,6 +24,7 @@ declare namespace _default {
24
24
  "./resource": string;
25
25
  "./mcp": string;
26
26
  "./middleware": string;
27
+ "./utils": string;
27
28
  "./oauth": string;
28
29
  "./provider": string;
29
30
  "./fs": string;
@@ -61,6 +62,7 @@ declare namespace _default {
61
62
  "veryfront/workflow/claude-code": string;
62
63
  "veryfront/workflow/claude-code/react": string;
63
64
  "veryfront/workflow/discovery": string;
65
+ "veryfront/utils": string;
64
66
  "veryfront/utils/box": string;
65
67
  "veryfront/utils/case-utils": string;
66
68
  "veryfront/utils/constants/server": string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -34,6 +34,7 @@ export default {
34
34
  "./resource": "./src/resource/index.ts",
35
35
  "./mcp": "./src/mcp/index.ts",
36
36
  "./middleware": "./src/middleware/index.ts",
37
+ "./utils": "./src/utils/index.ts",
37
38
  "./oauth": "./src/oauth/index.ts",
38
39
  "./provider": "./src/provider/index.ts",
39
40
  "./fs": "./src/fs/index.ts",
@@ -71,6 +72,7 @@ export default {
71
72
  "veryfront/workflow/claude-code": "./src/workflow/claude-code/index.ts",
72
73
  "veryfront/workflow/claude-code/react": "./src/workflow/claude-code/react/index.ts",
73
74
  "veryfront/workflow/discovery": "./src/workflow/discovery/index.ts",
75
+ "veryfront/utils": "./src/utils/index.ts",
74
76
  "veryfront/utils/box": "./src/utils/box.ts",
75
77
  "veryfront/utils/case-utils": "./src/utils/case-utils.ts",
76
78
  "veryfront/utils/constants/server": "./src/utils/constants/server.ts",
@@ -1,11 +1,21 @@
1
1
  import type { DataContext, DataResult, PageWithData, StaticPathsResult } from "./types.js";
2
+ /**
3
+ * Options for isolated data fetching. Passed through to ServerDataFetcher
4
+ * when worker isolation is enabled.
5
+ */
6
+ export interface FetchDataOptions {
7
+ /** Absolute path to the module containing getServerData */
8
+ modulePath?: string;
9
+ /** Project directory for worker scoping */
10
+ projectDir?: string;
11
+ }
2
12
  export declare class DataFetcher {
3
13
  private cacheManager;
4
14
  private serverFetcher;
5
15
  private staticFetcher;
6
16
  private pathsFetcher;
7
17
  constructor(_adapter?: unknown);
8
- fetchData(pageModule: PageWithData, context: DataContext, mode?: "development" | "production"): Promise<DataResult>;
18
+ fetchData(pageModule: PageWithData, context: DataContext, mode?: "development" | "production", options?: FetchDataOptions): Promise<DataResult>;
9
19
  getStaticPaths(pageModule: PageWithData): Promise<StaticPathsResult | null>;
10
20
  clearCache(pattern?: string): void;
11
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/data-fetcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3F,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,YAAY,CAAqB;gBAE7B,QAAQ,CAAC,EAAE,OAAO;IAO9B,SAAS,CACP,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,WAAW,EACpB,IAAI,GAAE,aAAa,GAAG,YAA4B,GACjD,OAAO,CAAC,UAAU,CAAC;IA0BtB,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAI3E,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CAQnC"}
1
+ {"version":3,"file":"data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/data-fetcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,aAAa,CAAoB;IACzC,OAAO,CAAC,YAAY,CAAqB;gBAE7B,QAAQ,CAAC,EAAE,OAAO;IAO9B,SAAS,CACP,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,WAAW,EACpB,IAAI,GAAE,aAAa,GAAG,YAA4B,EAClD,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,UAAU,CAAC;IA8BtB,cAAc,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAI3E,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CAQnC"}
@@ -15,7 +15,7 @@ export class DataFetcher {
15
15
  this.staticFetcher = new StaticDataFetcher(this.cacheManager);
16
16
  this.pathsFetcher = new StaticPathsFetcher();
17
17
  }
18
- fetchData(pageModule, context, mode = "development") {
18
+ fetchData(pageModule, context, mode = "development", options) {
19
19
  const preferServerData = mode === "development" || !pageModule.getStaticData;
20
20
  const useServer = preferServerData && !!pageModule.getServerData;
21
21
  const useStatic = !useServer && !!pageModule.getStaticData;
@@ -24,9 +24,12 @@ export class DataFetcher {
24
24
  : useStatic
25
25
  ? "static"
26
26
  : "none";
27
+ const isolationOptions = options
28
+ ? { modulePath: options.modulePath, projectDir: options.projectDir }
29
+ : undefined;
27
30
  return withSpan(SpanNames.DATA_FETCH, () => {
28
31
  if (useServer)
29
- return this.serverFetcher.fetch(pageModule, context);
32
+ return this.serverFetcher.fetch(pageModule, context, isolationOptions);
30
33
  if (useStatic)
31
34
  return this.staticFetcher.fetch(pageModule, context);
32
35
  return Promise.resolve({ props: {} });
@@ -5,6 +5,6 @@
5
5
  * @module data
6
6
  */
7
7
  export type { CacheEntry, DataContext, DataResult, InferGetServerDataProps, PageWithData, StaticPathsResult, } from "./types.js";
8
- export { DataFetcher } from "./data-fetcher.js";
8
+ export { DataFetcher, type FetchDataOptions } from "./data-fetcher.js";
9
9
  export { notFound, redirect } from "./helpers.js";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/data/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/data/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"}
@@ -1,6 +1,19 @@
1
1
  import type { DataContext, DataResult, PageWithData } from "./types.js";
2
+ /**
3
+ * Options for isolated data fetching through Worker pool.
4
+ */
5
+ export interface ServerDataFetchOptions {
6
+ /** Absolute path to the module containing getServerData */
7
+ modulePath?: string;
8
+ /** Project directory for worker scoping */
9
+ projectDir?: string;
10
+ }
2
11
  export declare class ServerDataFetcher {
3
- fetch(pageModule: PageWithData, context: DataContext): Promise<DataResult>;
12
+ fetch(pageModule: PageWithData, context: DataContext, options?: ServerDataFetchOptions): Promise<DataResult>;
13
+ /**
14
+ * Execute getServerData in a per-project Worker.
15
+ */
16
+ private fetchIsolated;
4
17
  /**
5
18
  * Log errors unconditionally. Production errors should always be logged.
6
19
  * @see plans/architecture-audit/010-error-handling.md
@@ -1 +1 @@
1
- {"version":3,"file":"server-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/server-data-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAOxE,qBAAa,iBAAiB;IAC5B,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAkE1E;;;OAGG;IACH,OAAO,CAAC,QAAQ;CAGjB"}
1
+ {"version":3,"file":"server-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/server-data-fetcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AASxE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,iBAAiB;IAC5B,KAAK,CACH,UAAU,EAAE,YAAY,EACxB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,UAAU,CAAC;IA8EtB;;OAEG;YACW,aAAa;IA2C3B;;;OAGG;IACH,OAAO,CAAC,QAAQ;CAGjB"}
@@ -1,10 +1,12 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
1
2
  import { serverLogger } from "../utils/index.js";
2
3
  import { DATA_FETCH_TIMEOUT_MS } from "../config/defaults.js";
3
4
  import { TimeoutError, withTimeoutThrow } from "../rendering/utils/stream-utils.js";
4
5
  import { withSpan } from "../observability/tracing/otlp-setup.js";
5
6
  import { CircuitBreakerOpen, getCircuitBreaker } from "../utils/circuit-breaker.js";
7
+ import { getWorkerPool, isDataIsolationEnabled } from "../security/sandbox/worker-pool.js";
6
8
  export class ServerDataFetcher {
7
- fetch(pageModule, context) {
9
+ fetch(pageModule, context, options) {
8
10
  if (typeof pageModule.getServerData !== "function") {
9
11
  return Promise.resolve({ props: {} });
10
12
  }
@@ -15,10 +17,16 @@ export class ServerDataFetcher {
15
17
  resetTimeoutMs: 30_000,
16
18
  successThreshold: 2,
17
19
  });
20
+ // Choose isolated or direct execution
21
+ const useIsolation = isDataIsolationEnabled() &&
22
+ !!options?.modulePath &&
23
+ !!options?.projectDir;
18
24
  return withSpan("data.fetch_server", async () => {
19
25
  const start = performance.now();
20
26
  try {
21
- const result = await circuitBreaker.execute(() => withTimeoutThrow(Promise.resolve(pageModule.getServerData(context)), DATA_FETCH_TIMEOUT_MS, `getServerData for ${pathname}`));
27
+ const result = await circuitBreaker.execute(() => withTimeoutThrow(useIsolation
28
+ ? this.fetchIsolated(options.modulePath, options.projectDir, context)
29
+ : Promise.resolve(pageModule.getServerData(context)), DATA_FETCH_TIMEOUT_MS, `getServerData for ${pathname}`));
22
30
  if (result.redirect)
23
31
  return { redirect: result.redirect };
24
32
  if (result.notFound)
@@ -43,7 +51,11 @@ export class ServerDataFetcher {
43
51
  });
44
52
  throw error;
45
53
  }
46
- this.logError("DATA_FETCH_ERROR getServerData failed", error, { pathname, durationMs });
54
+ this.logError("DATA_FETCH_ERROR getServerData failed", error, {
55
+ pathname,
56
+ durationMs,
57
+ isolated: useIsolation,
58
+ });
47
59
  throw error;
48
60
  }
49
61
  }, {
@@ -51,8 +63,42 @@ export class ServerDataFetcher {
51
63
  "data.pathname": pathname,
52
64
  "data.timeout_ms": DATA_FETCH_TIMEOUT_MS,
53
65
  "data.project_id": projectId,
66
+ "data.isolated": useIsolation,
54
67
  });
55
68
  }
69
+ /**
70
+ * Execute getServerData in a per-project Worker.
71
+ */
72
+ async fetchIsolated(modulePath, projectDir, context) {
73
+ const pool = getWorkerPool();
74
+ const body = context.request?.body ? new Uint8Array(await context.request.arrayBuffer()) : null;
75
+ const workerResponse = await pool.execute(projectDir, [projectDir], {
76
+ type: "fetch-data",
77
+ id: dntShim.crypto.randomUUID(),
78
+ modulePath,
79
+ context: {
80
+ params: context.params,
81
+ query: context.query?.toString() ?? "",
82
+ request: {
83
+ url: context.request?.url ?? context.url?.toString() ?? "http://localhost",
84
+ method: context.request?.method ?? "GET",
85
+ headers: context.request ? [...context.request.headers.entries()] : [],
86
+ body,
87
+ },
88
+ url: context.url?.toString() ?? "http://localhost",
89
+ },
90
+ });
91
+ if (workerResponse.type === "error") {
92
+ const err = new Error(workerResponse.error.message);
93
+ err.name = workerResponse.error.name;
94
+ throw err;
95
+ }
96
+ if (workerResponse.type === "data-result") {
97
+ return workerResponse.result;
98
+ }
99
+ // Unexpected response type — shouldn't happen but be defensive
100
+ throw new Error(`Unexpected worker response type: ${workerResponse.type}`);
101
+ }
56
102
  /**
57
103
  * Log errors unconditionally. Production errors should always be logged.
58
104
  * @see plans/architecture-audit/010-error-handling.md
@@ -8,6 +8,7 @@ import { PageResolver } from "../page-resolution/index.js";
8
8
  import { ElementValidator } from "../element-validator/index.js";
9
9
  import { SSRRenderer } from "../ssr-renderer.js";
10
10
  import type { ConfigurationManager } from "./config.js";
11
+ import type { RuntimeAdapter } from "../../platform/adapters/base.js";
11
12
  import type { MdxBundle } from "../../types/index.js";
12
13
  import { CompilerService } from "./compiler-service.js";
13
14
  export interface LifecycleOptions {
@@ -18,6 +19,8 @@ export interface LifecycleOptions {
18
19
  projectId?: string;
19
20
  /** Content source identifier for cache isolation (branch or release) */
20
21
  contentSourceId?: string;
22
+ /** Injectable factory for testing — bypasses real service construction */
23
+ servicesFactory?: (adapter: RuntimeAdapter) => RendererServices;
21
24
  }
22
25
  export interface RendererServices {
23
26
  componentRegistry: ComponentRegistry;
@@ -40,6 +43,7 @@ export declare class RendererLifecycle {
40
43
  private contentSourceId?;
41
44
  private services?;
42
45
  private adapter;
46
+ private servicesFactory?;
43
47
  constructor(options: LifecycleOptions);
44
48
  initialize(): Promise<RendererServices>;
45
49
  updateCompileMDX(compileMDX: (content: string, frontmatter?: Record<string, unknown>, filePath?: string) => Promise<MdxBundle>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/lifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE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AAC,gBAAgB,CAAC;IAqJ7C,gBAAgB,CACd,UAAU,EAAE,CACV,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,KACd,OAAO,CAAC,SAAS,CAAC,GACtB,IAAI;IAcP,WAAW,IAAI,gBAAgB;IAazB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3C,cAAc,IAAI,IAAI;IAWtB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
@@ -26,12 +26,14 @@ export class RendererLifecycle {
26
26
  contentSourceId;
27
27
  services;
28
28
  adapter;
29
+ servicesFactory;
29
30
  constructor(options) {
30
31
  this.configManager = options.configManager;
31
32
  this.port = options.port;
32
33
  this.moduleServerUrl = options.moduleServerUrl;
33
34
  this.projectId = options.projectId;
34
35
  this.contentSourceId = options.contentSourceId;
36
+ this.servicesFactory = options.servicesFactory;
35
37
  }
36
38
  async initialize() {
37
39
  logger.debug("Initializing renderer services", {
@@ -43,6 +45,12 @@ export class RendererLifecycle {
43
45
  const { runtime } = await import("../../platform/adapters/detect.js");
44
46
  this.adapter = await runtime.get();
45
47
  }
48
+ // Allow tests to bypass the full service graph construction
49
+ if (this.servicesFactory) {
50
+ this.services = this.servicesFactory(this.adapter);
51
+ logger.debug("Renderer services initialized via injected factory");
52
+ return this.services;
53
+ }
46
54
  const projectDir = this.configManager.getProjectDir();
47
55
  const mode = this.configManager.getMode();
48
56
  const debugMode = this.configManager.isDebugMode();
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,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,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,qBAAqB,EAAE,sBAAsB,CAAC;CAC1E;AAQD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,MAAM,EAAE,oBAAoB;IAaxC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,sBAAsB;YAIhB,0BAA0B;IAaxC;;;;;;;;;OASG;YACW,qBAAqB;IAyDnC;;;OAGG;YACW,mBAAmB;IA0H3B,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA8P9E,+EAA+E;IACzE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA6LvF;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;CAetB"}
@@ -183,8 +183,13 @@ export class RenderPipeline {
183
183
  }
184
184
  const dataResults = await withSpan(SpanNames.RENDER_FETCH_DATA, () => withTimeoutThrow(Promise.all(dataJobs.map(async (job) => {
185
185
  try {
186
+ const jobPath = job.path;
187
+ const fetchOptions = {
188
+ modulePath: jobPath,
189
+ projectDir: this.config.projectDir,
190
+ };
186
191
  const result = await this.dataFetcher
187
- .fetchData(job.mod, dataContext, this.config.mode);
192
+ .fetchData(job.mod, dataContext, this.config.mode, fetchOptions);
188
193
  return { ...job, result, error: null };
189
194
  }
190
195
  catch (error) {
@@ -15,10 +15,35 @@ export interface SSRRenderingResult {
15
15
  finalStream: ReadableStream | null;
16
16
  ssrHash: string;
17
17
  }
18
+ /**
19
+ * Options for isolated SSR rendering through the Worker pool.
20
+ * When provided and SSR isolation is enabled, the rendering happens
21
+ * in a per-project Worker instead of the main process.
22
+ */
23
+ export interface SSRIsolationOptions {
24
+ /** Temp file path for the page component module */
25
+ pageModulePath: string;
26
+ /** Ordered layout module temp paths (innermost → outermost) */
27
+ layoutModulePaths: string[];
28
+ /** Page component props */
29
+ pageProps: Record<string, unknown>;
30
+ /** Layout props (one entry per layout, matching layoutModulePaths order) */
31
+ layoutProps: Record<string, unknown>[];
32
+ /** Project directory for worker scoping */
33
+ projectDir: string;
34
+ }
18
35
  export declare class SSROrchestrator {
19
36
  private config;
20
37
  constructor(config: SSROrchestratorConfig);
21
- performSSRRendering(pageElement: React.ReactElement, generationContext: Omit<HTMLGenerationContext, "html" | "ssrHash">, options?: RenderOptions): Promise<SSRRenderingResult>;
38
+ performSSRRendering(pageElement: React.ReactElement, generationContext: Omit<HTMLGenerationContext, "html" | "ssrHash">, options?: RenderOptions, isolationOptions?: SSRIsolationOptions): Promise<SSRRenderingResult>;
39
+ /**
40
+ * Perform SSR rendering in an isolated per-project Worker.
41
+ *
42
+ * The Worker imports user modules from their temp file paths,
43
+ * constructs the React element tree, and renders to HTML.
44
+ * For streaming, the Worker sends chunks via postMessage.
45
+ */
46
+ private performIsolatedSSR;
22
47
  private createStream;
23
48
  }
24
49
  //# sourceMappingURL=ssr-orchestrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-orchestrator.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/ssr-orchestrator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK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M,WAAW,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAOhD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACvC,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;CACpB;AAUD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAwB;gBAE1B,MAAM,EAAE,qBAAqB;IAInC,mBAAmB,CACvB,WAAW,EAAE,KAAK,CAAC,YAAY,EAC/B,iBAAiB,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC,EAClE,OAAO,CAAC,EAAE,aAAa,EACvB,gBAAgB,CAAC,EAAE,mBAAmB,GACrC,OAAO,CAAC,kBAAkB,CAAC;IAiG9B;;;;;;OAMG;YACW,kBAAkB;IAiFhC,OAAO,CAAC,YAAY;CAerB"}
@@ -5,6 +5,7 @@ import { withSpan } from "../../observability/tracing/otlp-setup.js";
5
5
  import { SpanNames } from "../../observability/tracing/span-names.js";
6
6
  import { computeHash } from "../utils/index.js";
7
7
  import { runWithHeadCollector } from "../../react/head-collector.js";
8
+ import { getWorkerPool, isSSRIsolationEnabled } from "../../security/sandbox/worker-pool.js";
8
9
  const logger = rendererLogger.component("ssr-orchestrator");
9
10
  function getElementTypeName(el) {
10
11
  if (!el?.type)
@@ -19,7 +20,14 @@ export class SSROrchestrator {
19
20
  constructor(config) {
20
21
  this.config = config;
21
22
  }
22
- async performSSRRendering(pageElement, generationContext, options) {
23
+ async performSSRRendering(pageElement, generationContext, options, isolationOptions) {
24
+ // Isolated SSR path: render in per-project Worker
25
+ if (isSSRIsolationEnabled() &&
26
+ isolationOptions?.pageModulePath &&
27
+ isolationOptions?.projectDir) {
28
+ return this.performIsolatedSSR(generationContext, options, isolationOptions);
29
+ }
30
+ // Default path: render in main process
23
31
  logger.debug("performSSRRendering called", {
24
32
  elementType: getElementTypeName(pageElement),
25
33
  hasChildren: !!pageElement.props?.children,
@@ -77,6 +85,74 @@ export class SSROrchestrator {
77
85
  ssrHash,
78
86
  };
79
87
  }
88
+ /**
89
+ * Perform SSR rendering in an isolated per-project Worker.
90
+ *
91
+ * The Worker imports user modules from their temp file paths,
92
+ * constructs the React element tree, and renders to HTML.
93
+ * For streaming, the Worker sends chunks via postMessage.
94
+ */
95
+ async performIsolatedSSR(generationContext, options, isolation) {
96
+ const wantsStream = options?.delivery === "stream";
97
+ const pool = getWorkerPool();
98
+ const requestId = dntShim.crypto.randomUUID();
99
+ return withSpan("ssr.isolated_render", async () => {
100
+ const worker = pool.getOrCreateWorker(isolation.projectDir, [isolation.projectDir]);
101
+ if (wantsStream) {
102
+ // Streaming mode: get a ReadableStream of chunks from the Worker
103
+ const stream = worker.executeStream({
104
+ type: "render-ssr",
105
+ id: requestId,
106
+ pageModulePath: isolation.pageModulePath,
107
+ layoutModulePaths: isolation.layoutModulePaths,
108
+ pageProps: isolation.pageProps,
109
+ layoutProps: isolation.layoutProps,
110
+ delivery: "stream",
111
+ });
112
+ const ssrHash = `stream-isolated-${Date.now()}`;
113
+ // Generate HTML stream using the framework's HTML generator
114
+ const finalStream = await this.config.htmlGenerator.generateHTMLStream(stream, {
115
+ ...generationContext,
116
+ ssrHash,
117
+ options: { ...generationContext.options, ...options },
118
+ collectedHead: undefined,
119
+ });
120
+ return { fullHtml: "", finalStream, ssrHash };
121
+ }
122
+ // String mode: render to HTML in Worker, get result back
123
+ const workerResponse = await worker.execute({
124
+ type: "render-ssr",
125
+ id: requestId,
126
+ pageModulePath: isolation.pageModulePath,
127
+ layoutModulePaths: isolation.layoutModulePaths,
128
+ pageProps: isolation.pageProps,
129
+ layoutProps: isolation.layoutProps,
130
+ delivery: "string",
131
+ });
132
+ if (workerResponse.type === "error") {
133
+ const err = new Error(workerResponse.error.message);
134
+ err.name = workerResponse.error.name;
135
+ throw err;
136
+ }
137
+ if (workerResponse.type !== "ssr-result") {
138
+ throw new Error(`Unexpected worker response type: ${workerResponse.type}`);
139
+ }
140
+ const html = workerResponse.html;
141
+ const ssrHash = await computeHash(html);
142
+ const fullHtml = await this.config.htmlGenerator.generateFullHTML({
143
+ ...generationContext,
144
+ html,
145
+ ssrHash,
146
+ options: { ...generationContext.options, ...options },
147
+ collectedHead: undefined,
148
+ });
149
+ return { fullHtml, finalStream: null, ssrHash };
150
+ }, {
151
+ "ssr.isolated": true,
152
+ "ssr.wants_stream": wantsStream,
153
+ "ssr.project_dir": isolation.projectDir,
154
+ });
155
+ }
80
156
  createStream(html) {
81
157
  try {
82
158
  return new dntShim.Response(html).body ?? null;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/src/routing/api/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMlD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;A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