veryfront 0.0.12 → 0.0.14

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.
package/dist/ai/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/ai/providers/openai.ts
2
- import { z } from "zod";
2
+ import { z as z2 } from "zod";
3
3
 
4
4
  // src/core/errors/veryfront-error.ts
5
5
  function createError(error) {
@@ -135,6 +135,23 @@ var agentLogger = createLogger("AGENT");
135
135
  var logger = createLogger("VERYFRONT");
136
136
 
137
137
  // src/ai/providers/base.ts
138
+ import { z } from "zod";
139
+ var OpenAIStreamChunkSchema = z.object({
140
+ choices: z.array(z.object({
141
+ delta: z.object({
142
+ content: z.string().optional().nullable(),
143
+ tool_calls: z.array(z.object({
144
+ index: z.number().optional(),
145
+ id: z.string().optional(),
146
+ function: z.object({
147
+ name: z.string().optional(),
148
+ arguments: z.string().optional()
149
+ }).optional()
150
+ })).optional()
151
+ }),
152
+ finish_reason: z.string().nullable()
153
+ })).min(1)
154
+ });
138
155
  var BaseProvider = class {
139
156
  constructor(config) {
140
157
  this.config = config;
@@ -238,8 +255,12 @@ var BaseProvider = class {
238
255
  continue;
239
256
  }
240
257
  try {
241
- const parsed = JSON.parse(data);
242
- const choice = parsed.choices?.[0];
258
+ const raw = JSON.parse(data);
259
+ const result = OpenAIStreamChunkSchema.safeParse(raw);
260
+ if (!result.success) {
261
+ continue;
262
+ }
263
+ const choice = result.data.choices[0];
243
264
  if (!choice)
244
265
  continue;
245
266
  const delta = choice.delta;
@@ -324,25 +345,25 @@ var BaseProvider = class {
324
345
  };
325
346
 
326
347
  // src/ai/providers/openai.ts
327
- var OpenAIToolCallSchema = z.object({
328
- id: z.string(),
329
- function: z.object({
330
- name: z.string(),
331
- arguments: z.string()
348
+ var OpenAIToolCallSchema = z2.object({
349
+ id: z2.string(),
350
+ function: z2.object({
351
+ name: z2.string(),
352
+ arguments: z2.string()
332
353
  })
333
354
  });
334
- var OpenAIResponseSchema = z.object({
335
- choices: z.array(z.object({
336
- message: z.object({
337
- content: z.string().nullable().optional(),
338
- tool_calls: z.array(OpenAIToolCallSchema).optional()
355
+ var OpenAIResponseSchema = z2.object({
356
+ choices: z2.array(z2.object({
357
+ message: z2.object({
358
+ content: z2.string().nullable().optional(),
359
+ tool_calls: z2.array(OpenAIToolCallSchema).optional()
339
360
  }),
340
- finish_reason: z.string()
361
+ finish_reason: z2.string()
341
362
  })).min(1),
342
- usage: z.object({
343
- prompt_tokens: z.number().optional(),
344
- completion_tokens: z.number().optional(),
345
- total_tokens: z.number().optional()
363
+ usage: z2.object({
364
+ prompt_tokens: z2.number().optional(),
365
+ completion_tokens: z2.number().optional(),
366
+ total_tokens: z2.number().optional()
346
367
  }).optional()
347
368
  });
348
369
  var OpenAIProvider = class extends BaseProvider {
@@ -727,26 +748,26 @@ var AnthropicProvider = class extends BaseProvider {
727
748
  };
728
749
 
729
750
  // src/ai/providers/google.ts
730
- import { z as z2 } from "zod";
731
- var GoogleToolCallSchema = z2.object({
732
- id: z2.string(),
733
- function: z2.object({
734
- name: z2.string(),
735
- arguments: z2.union([z2.string(), z2.record(z2.unknown())])
751
+ import { z as z3 } from "zod";
752
+ var GoogleToolCallSchema = z3.object({
753
+ id: z3.string(),
754
+ function: z3.object({
755
+ name: z3.string(),
756
+ arguments: z3.union([z3.string(), z3.record(z3.unknown())])
736
757
  })
737
758
  });
738
- var GoogleResponseSchema = z2.object({
739
- choices: z2.array(z2.object({
740
- message: z2.object({
741
- content: z2.string().nullable().optional(),
742
- tool_calls: z2.array(GoogleToolCallSchema).optional()
759
+ var GoogleResponseSchema = z3.object({
760
+ choices: z3.array(z3.object({
761
+ message: z3.object({
762
+ content: z3.string().nullable().optional(),
763
+ tool_calls: z3.array(GoogleToolCallSchema).optional()
743
764
  }),
744
- finish_reason: z2.string()
765
+ finish_reason: z3.string()
745
766
  })).min(1),
746
- usage: z2.object({
747
- prompt_tokens: z2.number().optional(),
748
- completion_tokens: z2.number().optional(),
749
- total_tokens: z2.number().optional()
767
+ usage: z3.object({
768
+ prompt_tokens: z3.number().optional(),
769
+ completion_tokens: z3.number().optional(),
770
+ total_tokens: z3.number().optional()
750
771
  }).optional()
751
772
  });
752
773
  var GoogleProvider = class extends BaseProvider {
@@ -1688,7 +1709,7 @@ var BYTES_PER_MB = 1024 * 1024;
1688
1709
  // deno.json
1689
1710
  var deno_default = {
1690
1711
  name: "veryfront",
1691
- version: "0.0.12",
1712
+ version: "0.0.14",
1692
1713
  nodeModulesDir: "auto",
1693
1714
  workspace: [
1694
1715
  "./examples/async-worker-redis",
@@ -2280,6 +2301,45 @@ async function withSpan(name, fn, options = {}) {
2280
2301
  }
2281
2302
 
2282
2303
  // src/ai/agent/runtime.ts
2304
+ import { z as z4 } from "zod";
2305
+ var AgentStreamEventSchema = z4.discriminatedUnion("type", [
2306
+ z4.object({
2307
+ type: z4.literal("content"),
2308
+ content: z4.string()
2309
+ }),
2310
+ z4.object({
2311
+ type: z4.literal("tool_call_start"),
2312
+ toolCall: z4.object({
2313
+ id: z4.string(),
2314
+ name: z4.string()
2315
+ })
2316
+ }),
2317
+ z4.object({
2318
+ type: z4.literal("tool_call_delta"),
2319
+ id: z4.string(),
2320
+ arguments: z4.string()
2321
+ }),
2322
+ z4.object({
2323
+ type: z4.literal("tool_call_complete"),
2324
+ toolCall: z4.object({
2325
+ id: z4.string(),
2326
+ name: z4.string(),
2327
+ arguments: z4.string()
2328
+ })
2329
+ }),
2330
+ z4.object({
2331
+ type: z4.literal("finish"),
2332
+ finishReason: z4.string().nullable()
2333
+ }),
2334
+ z4.object({
2335
+ type: z4.literal("usage"),
2336
+ usage: z4.object({
2337
+ promptTokens: z4.number().optional(),
2338
+ completionTokens: z4.number().optional(),
2339
+ totalTokens: z4.number().optional()
2340
+ })
2341
+ })
2342
+ ]);
2283
2343
  var DEFAULT_MAX_TOKENS = 4096;
2284
2344
  var DEFAULT_TEMPERATURE = 0.7;
2285
2345
  var AgentRuntime = class {
@@ -2561,6 +2621,42 @@ var AgentRuntime = class {
2561
2621
  let accumulatedText = "";
2562
2622
  let finishReason = null;
2563
2623
  const streamToolCalls = /* @__PURE__ */ new Map();
2624
+ const parseStreamToolArgs = (rawArgs) => {
2625
+ try {
2626
+ const parsed = typeof rawArgs === "string" ? JSON.parse(rawArgs) : rawArgs;
2627
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
2628
+ return { args: parsed };
2629
+ }
2630
+ return { args: {}, error: "Tool call arguments must be a JSON object" };
2631
+ } catch (error) {
2632
+ return {
2633
+ args: {},
2634
+ error: error instanceof Error ? error.message : String(error)
2635
+ };
2636
+ }
2637
+ };
2638
+ const recordToolError = async (toolCall, errorStr) => {
2639
+ toolCall.status = "error";
2640
+ toolCall.error = errorStr;
2641
+ toolCalls.push(toolCall);
2642
+ const errorData = JSON.stringify({
2643
+ type: "error",
2644
+ error: errorStr
2645
+ });
2646
+ controller.enqueue(encoder.encode(`data: ${errorData}
2647
+
2648
+ `));
2649
+ const errorMessage = {
2650
+ id: `tool_error_${toolCall.id}`,
2651
+ role: "tool",
2652
+ content: `Error: ${errorStr}`,
2653
+ toolCallId: toolCall.id,
2654
+ toolCall,
2655
+ timestamp: Date.now()
2656
+ };
2657
+ currentMessages.push(errorMessage);
2658
+ await this.memory.add(errorMessage);
2659
+ };
2564
2660
  const handleEvent = (event) => {
2565
2661
  switch (event.type) {
2566
2662
  case "content": {
@@ -2624,17 +2720,26 @@ var AgentRuntime = class {
2624
2720
  const lines = segments.filter((line) => line.trim());
2625
2721
  for (const line of lines) {
2626
2722
  try {
2627
- const event = JSON.parse(line);
2628
- handleEvent(event);
2629
- } catch {
2723
+ const rawEvent = JSON.parse(line);
2724
+ const parseResult = AgentStreamEventSchema.safeParse(rawEvent);
2725
+ if (parseResult.success) {
2726
+ handleEvent(parseResult.data);
2727
+ } else {
2728
+ serverLogger.warn("[AGENT] Invalid stream event received:", parseResult.error);
2729
+ }
2730
+ } catch (e) {
2731
+ serverLogger.warn("[AGENT] Failed to parse stream line:", e);
2630
2732
  continue;
2631
2733
  }
2632
2734
  }
2633
2735
  }
2634
2736
  if (partial.trim()) {
2635
2737
  try {
2636
- const event = JSON.parse(partial);
2637
- handleEvent(event);
2738
+ const rawEvent = JSON.parse(partial);
2739
+ const parseResult = AgentStreamEventSchema.safeParse(rawEvent);
2740
+ if (parseResult.success) {
2741
+ handleEvent(parseResult.data);
2742
+ }
2638
2743
  } catch {
2639
2744
  }
2640
2745
  }
@@ -2645,23 +2750,41 @@ var AgentRuntime = class {
2645
2750
  timestamp: Date.now()
2646
2751
  };
2647
2752
  if (streamToolCalls.size > 0) {
2648
- assistantMessage.toolCalls = Array.from(streamToolCalls.values()).map((tc) => ({
2649
- id: tc.id,
2650
- name: tc.name,
2651
- arguments: JSON.parse(tc.arguments)
2652
- }));
2753
+ assistantMessage.toolCalls = Array.from(streamToolCalls.values()).map((tc) => {
2754
+ const { args, error } = parseStreamToolArgs(tc.arguments);
2755
+ if (error) {
2756
+ serverLogger.warn("[AGENT] Failed to parse streamed tool arguments", {
2757
+ toolCallId: tc.id,
2758
+ error
2759
+ });
2760
+ }
2761
+ return {
2762
+ id: tc.id,
2763
+ name: tc.name,
2764
+ arguments: args
2765
+ };
2766
+ });
2653
2767
  }
2654
2768
  currentMessages.push(assistantMessage);
2655
2769
  await this.memory.add(assistantMessage);
2656
2770
  if (finishReason === "tool_calls" && streamToolCalls.size > 0) {
2657
2771
  this.status = "tool_execution";
2658
2772
  for (const tc of streamToolCalls.values()) {
2773
+ const { args, error: argError } = parseStreamToolArgs(tc.arguments);
2659
2774
  const toolCall = {
2660
2775
  id: tc.id,
2661
2776
  name: tc.name,
2662
- args: JSON.parse(tc.arguments),
2777
+ args,
2663
2778
  status: "pending"
2664
2779
  };
2780
+ if (argError) {
2781
+ serverLogger.warn("[AGENT] Invalid streamed tool arguments", {
2782
+ toolCallId: tc.id,
2783
+ error: argError
2784
+ });
2785
+ await recordToolError(toolCall, `Invalid tool arguments: ${argError}`);
2786
+ continue;
2787
+ }
2665
2788
  try {
2666
2789
  toolCall.status = "executing";
2667
2790
  const startTime = Date.now();
@@ -2708,26 +2831,8 @@ var AgentRuntime = class {
2708
2831
  currentMessages.push(toolResultMessage);
2709
2832
  await this.memory.add(toolResultMessage);
2710
2833
  } catch (error) {
2711
- toolCall.status = "error";
2712
- toolCall.error = error instanceof Error ? error.message : String(error);
2713
- toolCalls.push(toolCall);
2714
- const errorData = JSON.stringify({
2715
- type: "error",
2716
- error: toolCall.error
2717
- });
2718
- controller.enqueue(encoder.encode(`data: ${errorData}
2719
-
2720
- `));
2721
- const errorMessage = {
2722
- id: `tool_error_${tc.id}`,
2723
- role: "tool",
2724
- content: `Error: ${toolCall.error}`,
2725
- toolCallId: tc.id,
2726
- toolCall,
2727
- timestamp: Date.now()
2728
- };
2729
- currentMessages.push(errorMessage);
2730
- await this.memory.add(errorMessage);
2834
+ const errorStr = error instanceof Error ? error.message : String(error);
2835
+ await recordToolError(toolCall, errorStr);
2731
2836
  }
2732
2837
  }
2733
2838
  this.status = "thinking";
@@ -3178,13 +3283,13 @@ function generateAgentId() {
3178
3283
  }
3179
3284
 
3180
3285
  // src/ai/agent/composition.ts
3181
- import { z as z3 } from "zod";
3286
+ import { z as z5 } from "zod";
3182
3287
  function agentAsTool(agent2, description) {
3183
3288
  return {
3184
3289
  id: `agent_${agent2.id}`,
3185
3290
  description,
3186
- inputSchema: z3.object({
3187
- input: z3.string().describe("Input for the agent")
3291
+ inputSchema: z5.object({
3292
+ input: z5.string().describe("Input for the agent")
3188
3293
  }),
3189
3294
  async execute({ input }) {
3190
3295
  const response = await agent2.generate({ input });
@@ -3264,125 +3369,138 @@ function getAgentsAsTools(descriptions) {
3264
3369
  }
3265
3370
 
3266
3371
  // src/core/config/schema.ts
3267
- import { z as z4 } from "zod";
3268
- var corsSchema = z4.union([z4.boolean(), z4.object({ origin: z4.string().optional() }).strict()]);
3269
- var veryfrontConfigSchema = z4.object({
3270
- title: z4.string().optional(),
3271
- description: z4.string().optional(),
3272
- experimental: z4.object({
3273
- esmLayouts: z4.boolean().optional(),
3274
- precompileMDX: z4.boolean().optional()
3372
+ import { z as z6 } from "zod";
3373
+ var corsSchema = z6.union([z6.boolean(), z6.object({ origin: z6.string().optional() }).strict()]);
3374
+ var veryfrontConfigSchema = z6.object({
3375
+ title: z6.string().optional(),
3376
+ description: z6.string().optional(),
3377
+ experimental: z6.object({
3378
+ esmLayouts: z6.boolean().optional(),
3379
+ precompileMDX: z6.boolean().optional()
3275
3380
  }).partial().optional(),
3276
- router: z4.enum(["app", "pages"]).optional(),
3277
- defaultLayout: z4.string().optional(),
3278
- theme: z4.object({ colors: z4.record(z4.string()).optional() }).partial().optional(),
3279
- build: z4.object({
3280
- outDir: z4.string().optional(),
3281
- trailingSlash: z4.boolean().optional(),
3282
- esbuild: z4.object({
3283
- wasmURL: z4.string().url().optional(),
3284
- worker: z4.boolean().optional()
3381
+ router: z6.enum(["app", "pages"]).optional(),
3382
+ defaultLayout: z6.string().optional(),
3383
+ theme: z6.object({ colors: z6.record(z6.string()).optional() }).partial().optional(),
3384
+ build: z6.object({
3385
+ outDir: z6.string().optional(),
3386
+ trailingSlash: z6.boolean().optional(),
3387
+ esbuild: z6.object({
3388
+ wasmURL: z6.string().url().optional(),
3389
+ worker: z6.boolean().optional()
3285
3390
  }).partial().optional()
3286
3391
  }).partial().optional(),
3287
- cache: z4.object({
3288
- dir: z4.string().optional(),
3289
- bundleManifest: z4.object({
3290
- type: z4.enum(["redis", "kv", "memory"]).optional(),
3291
- redisUrl: z4.string().optional(),
3292
- keyPrefix: z4.string().optional(),
3293
- ttl: z4.number().int().positive().optional(),
3294
- enabled: z4.boolean().optional()
3392
+ cache: z6.object({
3393
+ dir: z6.string().optional(),
3394
+ bundleManifest: z6.object({
3395
+ type: z6.enum(["redis", "kv", "memory"]).optional(),
3396
+ redisUrl: z6.string().optional(),
3397
+ keyPrefix: z6.string().optional(),
3398
+ ttl: z6.number().int().positive().optional(),
3399
+ enabled: z6.boolean().optional()
3295
3400
  }).partial().optional()
3296
3401
  }).partial().optional(),
3297
- dev: z4.object({
3298
- port: z4.number().int().positive().optional(),
3299
- host: z4.string().optional(),
3300
- open: z4.boolean().optional(),
3301
- hmr: z4.boolean().optional(),
3302
- components: z4.array(z4.string()).optional()
3402
+ dev: z6.object({
3403
+ port: z6.number().int().positive().optional(),
3404
+ host: z6.string().optional(),
3405
+ open: z6.boolean().optional(),
3406
+ hmr: z6.boolean().optional(),
3407
+ components: z6.array(z6.string()).optional()
3303
3408
  }).partial().optional(),
3304
- resolve: z4.object({
3305
- importMap: z4.object({
3306
- imports: z4.record(z4.string()).optional(),
3307
- scopes: z4.record(z4.record(z4.string())).optional()
3409
+ resolve: z6.object({
3410
+ importMap: z6.object({
3411
+ imports: z6.record(z6.string()).optional(),
3412
+ scopes: z6.record(z6.record(z6.string())).optional()
3308
3413
  }).partial().optional()
3309
3414
  }).partial().optional(),
3310
- security: z4.object({
3311
- csp: z4.record(z4.array(z4.string())).optional(),
3312
- remoteHosts: z4.array(z4.string().url()).optional(),
3415
+ security: z6.object({
3416
+ csp: z6.record(z6.array(z6.string())).optional(),
3417
+ remoteHosts: z6.array(z6.string().url()).optional(),
3313
3418
  cors: corsSchema.optional(),
3314
- coop: z4.enum(["same-origin", "same-origin-allow-popups", "unsafe-none"]).optional(),
3315
- corp: z4.enum(["same-origin", "same-site", "cross-origin"]).optional(),
3316
- coep: z4.enum(["require-corp", "unsafe-none"]).optional()
3419
+ coop: z6.enum(["same-origin", "same-origin-allow-popups", "unsafe-none"]).optional(),
3420
+ corp: z6.enum(["same-origin", "same-site", "cross-origin"]).optional(),
3421
+ coep: z6.enum(["require-corp", "unsafe-none"]).optional()
3317
3422
  }).partial().optional(),
3318
- middleware: z4.object({
3319
- custom: z4.array(z4.function()).optional()
3423
+ middleware: z6.object({
3424
+ custom: z6.array(z6.function()).optional()
3320
3425
  }).partial().optional(),
3321
- theming: z4.object({
3322
- brandName: z4.string().optional(),
3323
- logoHtml: z4.string().optional()
3426
+ theming: z6.object({
3427
+ brandName: z6.string().optional(),
3428
+ logoHtml: z6.string().optional()
3324
3429
  }).partial().optional(),
3325
- assetPipeline: z4.object({
3326
- images: z4.object({
3327
- enabled: z4.boolean().optional(),
3328
- formats: z4.array(z4.enum(["webp", "avif", "jpeg", "png"])).optional(),
3329
- sizes: z4.array(z4.number().int().positive()).optional(),
3330
- quality: z4.number().int().min(1).max(100).optional(),
3331
- inputDir: z4.string().optional(),
3332
- outputDir: z4.string().optional(),
3333
- preserveOriginal: z4.boolean().optional()
3430
+ assetPipeline: z6.object({
3431
+ images: z6.object({
3432
+ enabled: z6.boolean().optional(),
3433
+ formats: z6.array(z6.enum(["webp", "avif", "jpeg", "png"])).optional(),
3434
+ sizes: z6.array(z6.number().int().positive()).optional(),
3435
+ quality: z6.number().int().min(1).max(100).optional(),
3436
+ inputDir: z6.string().optional(),
3437
+ outputDir: z6.string().optional(),
3438
+ preserveOriginal: z6.boolean().optional()
3334
3439
  }).partial().optional(),
3335
- css: z4.object({
3336
- enabled: z4.boolean().optional(),
3337
- minify: z4.boolean().optional(),
3338
- autoprefixer: z4.boolean().optional(),
3339
- purge: z4.boolean().optional(),
3340
- criticalCSS: z4.boolean().optional(),
3341
- inputDir: z4.string().optional(),
3342
- outputDir: z4.string().optional(),
3343
- browsers: z4.array(z4.string()).optional(),
3344
- purgeContent: z4.array(z4.string()).optional(),
3345
- sourceMap: z4.boolean().optional()
3440
+ css: z6.object({
3441
+ enabled: z6.boolean().optional(),
3442
+ minify: z6.boolean().optional(),
3443
+ autoprefixer: z6.boolean().optional(),
3444
+ purge: z6.boolean().optional(),
3445
+ criticalCSS: z6.boolean().optional(),
3446
+ inputDir: z6.string().optional(),
3447
+ outputDir: z6.string().optional(),
3448
+ browsers: z6.array(z6.string()).optional(),
3449
+ purgeContent: z6.array(z6.string()).optional(),
3450
+ sourceMap: z6.boolean().optional()
3346
3451
  }).partial().optional()
3347
3452
  }).partial().optional(),
3348
- observability: z4.object({
3349
- tracing: z4.object({
3350
- enabled: z4.boolean().optional(),
3351
- exporter: z4.enum(["jaeger", "zipkin", "otlp", "console"]).optional(),
3352
- endpoint: z4.string().optional(),
3353
- serviceName: z4.string().optional(),
3354
- sampleRate: z4.number().min(0).max(1).optional()
3453
+ observability: z6.object({
3454
+ tracing: z6.object({
3455
+ enabled: z6.boolean().optional(),
3456
+ exporter: z6.enum(["jaeger", "zipkin", "otlp", "console"]).optional(),
3457
+ endpoint: z6.string().optional(),
3458
+ serviceName: z6.string().optional(),
3459
+ sampleRate: z6.number().min(0).max(1).optional()
3355
3460
  }).partial().optional(),
3356
- metrics: z4.object({
3357
- enabled: z4.boolean().optional(),
3358
- exporter: z4.enum(["prometheus", "otlp", "console"]).optional(),
3359
- endpoint: z4.string().optional(),
3360
- prefix: z4.string().optional(),
3361
- collectInterval: z4.number().int().positive().optional()
3461
+ metrics: z6.object({
3462
+ enabled: z6.boolean().optional(),
3463
+ exporter: z6.enum(["prometheus", "otlp", "console"]).optional(),
3464
+ endpoint: z6.string().optional(),
3465
+ prefix: z6.string().optional(),
3466
+ collectInterval: z6.number().int().positive().optional()
3362
3467
  }).partial().optional()
3363
3468
  }).partial().optional(),
3364
- fs: z4.object({
3365
- type: z4.enum(["local", "veryfront-api", "memory"]).optional(),
3366
- local: z4.object({
3367
- baseDir: z4.string().optional()
3469
+ fs: z6.object({
3470
+ type: z6.enum(["local", "veryfront-api", "memory"]).optional(),
3471
+ local: z6.object({
3472
+ baseDir: z6.string().optional()
3368
3473
  }).partial().optional(),
3369
- veryfront: z4.object({
3370
- apiBaseUrl: z4.string().url(),
3371
- apiToken: z4.string(),
3372
- projectSlug: z4.string(),
3373
- cache: z4.object({
3374
- enabled: z4.boolean().optional(),
3375
- ttl: z4.number().int().positive().optional(),
3376
- maxSize: z4.number().int().positive().optional()
3474
+ veryfront: z6.object({
3475
+ apiBaseUrl: z6.string().url(),
3476
+ apiToken: z6.string(),
3477
+ projectSlug: z6.string(),
3478
+ cache: z6.object({
3479
+ enabled: z6.boolean().optional(),
3480
+ ttl: z6.number().int().positive().optional(),
3481
+ maxSize: z6.number().int().positive().optional()
3377
3482
  }).partial().optional(),
3378
- retry: z4.object({
3379
- maxRetries: z4.number().int().min(0).optional(),
3380
- initialDelay: z4.number().int().positive().optional(),
3381
- maxDelay: z4.number().int().positive().optional()
3483
+ retry: z6.object({
3484
+ maxRetries: z6.number().int().min(0).optional(),
3485
+ initialDelay: z6.number().int().positive().optional(),
3486
+ maxDelay: z6.number().int().positive().optional()
3382
3487
  }).partial().optional()
3383
3488
  }).partial().optional(),
3384
- memory: z4.object({
3385
- files: z4.record(z4.union([z4.string(), z4.instanceof(Uint8Array)])).optional()
3489
+ memory: z6.object({
3490
+ files: z6.record(z6.union([z6.string(), z6.instanceof(Uint8Array)])).optional()
3491
+ }).partial().optional()
3492
+ }).partial().optional(),
3493
+ client: z6.object({
3494
+ moduleResolution: z6.enum(["cdn", "self-hosted", "bundled"]).optional(),
3495
+ cdn: z6.object({
3496
+ provider: z6.enum(["esm.sh", "unpkg", "jsdelivr"]).optional(),
3497
+ versions: z6.union([
3498
+ z6.literal("auto"),
3499
+ z6.object({
3500
+ react: z6.string().optional(),
3501
+ veryfront: z6.string().optional()
3502
+ })
3503
+ ]).optional()
3386
3504
  }).partial().optional()
3387
3505
  }).partial().optional()
3388
3506
  }).partial();
@@ -3428,7 +3546,8 @@ function findUnknownTopLevelKeys(input) {
3428
3546
  "theming",
3429
3547
  "assetPipeline",
3430
3548
  "observability",
3431
- "fs"
3549
+ "fs",
3550
+ "client"
3432
3551
  ]);
3433
3552
  return Object.keys(input).filter((k) => !known.has(k));
3434
3553
  }
@@ -3477,6 +3596,13 @@ var DEFAULT_CONFIG2 = {
3477
3596
  },
3478
3597
  resolve: {
3479
3598
  importMap: getDefaultImportMapForConfig()
3599
+ },
3600
+ client: {
3601
+ moduleResolution: "cdn",
3602
+ cdn: {
3603
+ provider: "esm.sh",
3604
+ versions: "auto"
3605
+ }
3480
3606
  }
3481
3607
  };
3482
3608
  var configCacheByProject = /* @__PURE__ */ new Map();
@@ -3529,6 +3655,14 @@ function mergeConfigs(userConfig) {
3529
3655
  resolve: {
3530
3656
  ...DEFAULT_CONFIG2.resolve,
3531
3657
  ...userConfig.resolve
3658
+ },
3659
+ client: {
3660
+ ...DEFAULT_CONFIG2.client,
3661
+ ...userConfig.client,
3662
+ cdn: {
3663
+ ...DEFAULT_CONFIG2.client?.cdn,
3664
+ ...userConfig.client?.cdn
3665
+ }
3532
3666
  }
3533
3667
  };
3534
3668
  if (merged.resolve) {