veryfront 0.1.283 → 0.1.285

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 (112) hide show
  1. package/esm/deno.d.ts +0 -8
  2. package/esm/deno.js +8 -11
  3. package/esm/src/agent/agent-service.d.ts +28 -6
  4. package/esm/src/agent/agent-service.d.ts.map +1 -1
  5. package/esm/src/agent/agent-service.js +23 -1
  6. package/esm/src/agent/index.d.ts +1 -1
  7. package/esm/src/agent/index.d.ts.map +1 -1
  8. package/esm/src/embedding/resolve.d.ts.map +1 -1
  9. package/esm/src/embedding/resolve.js +15 -2
  10. package/esm/src/embedding/veryfront-cloud/provider.d.ts.map +1 -1
  11. package/esm/src/embedding/veryfront-cloud/provider.js +2 -7
  12. package/esm/src/extensions/contracts.js +3 -1
  13. package/esm/src/extensions/interfaces/ai-provider.d.ts +50 -0
  14. package/esm/src/extensions/interfaces/ai-provider.d.ts.map +1 -0
  15. package/esm/src/extensions/interfaces/ai-provider.js +13 -0
  16. package/esm/src/extensions/interfaces/code-parser.d.ts +11 -0
  17. package/esm/src/extensions/interfaces/code-parser.d.ts.map +1 -1
  18. package/esm/src/extensions/interfaces/css-processor.d.ts +41 -22
  19. package/esm/src/extensions/interfaces/css-processor.d.ts.map +1 -1
  20. package/esm/src/extensions/interfaces/css-processor.js +10 -1
  21. package/esm/src/extensions/interfaces/index.d.ts +5 -4
  22. package/esm/src/extensions/interfaces/index.d.ts.map +1 -1
  23. package/esm/src/extensions/interfaces/index.js +1 -0
  24. package/esm/src/extensions/interfaces/schema-validator.d.ts +84 -5
  25. package/esm/src/extensions/interfaces/schema-validator.d.ts.map +1 -1
  26. package/esm/src/extensions/interfaces/schema-validator.js +5 -0
  27. package/esm/src/extensions/loader.d.ts +7 -0
  28. package/esm/src/extensions/loader.d.ts.map +1 -1
  29. package/esm/src/extensions/loader.js +12 -0
  30. package/esm/src/extensions/orchestrate.d.ts +2 -0
  31. package/esm/src/extensions/orchestrate.d.ts.map +1 -1
  32. package/esm/src/extensions/orchestrate.js +3 -0
  33. package/esm/src/extensions/recommendations.d.ts.map +1 -1
  34. package/esm/src/extensions/recommendations.js +4 -1
  35. package/esm/src/extensions/registries/ai-provider-registry.d.ts +11 -0
  36. package/esm/src/extensions/registries/ai-provider-registry.d.ts.map +1 -0
  37. package/esm/src/extensions/registries/ai-provider-registry.js +40 -0
  38. package/esm/src/html/styles-builder/plugin-loader.d.ts.map +1 -1
  39. package/esm/src/html/styles-builder/plugin-loader.js +4 -16
  40. package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts +8 -2
  41. package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
  42. package/esm/src/html/styles-builder/tailwind-compiler-cache.js +20 -3
  43. package/esm/src/provider/model-registry.d.ts.map +1 -1
  44. package/esm/src/provider/model-registry.js +33 -6
  45. package/esm/src/provider/runtime-loader/provider-embedding-responses.d.ts +1 -0
  46. package/esm/src/provider/runtime-loader/provider-embedding-responses.d.ts.map +1 -1
  47. package/esm/src/provider/runtime-loader/provider-embedding-responses.js +1 -1
  48. package/esm/src/provider/runtime-loader/provider-http.d.ts +9 -0
  49. package/esm/src/provider/runtime-loader/provider-http.d.ts.map +1 -1
  50. package/esm/src/provider/runtime-loader/provider-http.js +2 -2
  51. package/esm/src/provider/runtime-loader.d.ts +120 -9
  52. package/esm/src/provider/runtime-loader.d.ts.map +1 -1
  53. package/esm/src/provider/runtime-loader.js +13 -943
  54. package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
  55. package/esm/src/provider/veryfront-cloud/provider.js +30 -15
  56. package/esm/src/sandbox/index.d.ts +1 -1
  57. package/esm/src/sandbox/index.d.ts.map +1 -1
  58. package/esm/src/sandbox/index.js +1 -1
  59. package/esm/src/sandbox/lazy-sandbox.d.ts +3 -0
  60. package/esm/src/sandbox/lazy-sandbox.d.ts.map +1 -1
  61. package/esm/src/sandbox/lazy-sandbox.js +22 -1
  62. package/esm/src/schemas/define.d.ts +31 -0
  63. package/esm/src/schemas/define.d.ts.map +1 -0
  64. package/esm/src/schemas/define.js +42 -0
  65. package/esm/src/schemas/index.d.ts +7 -2
  66. package/esm/src/schemas/index.d.ts.map +1 -1
  67. package/esm/src/schemas/index.js +10 -2
  68. package/esm/src/schemas/zod-adapter.d.ts +25 -0
  69. package/esm/src/schemas/zod-adapter.d.ts.map +1 -0
  70. package/esm/src/schemas/zod-adapter.js +120 -0
  71. package/esm/src/server/bootstrap.d.ts.map +1 -1
  72. package/esm/src/server/bootstrap.js +5 -0
  73. package/esm/src/transforms/plugins/babel-node-positions.d.ts +6 -7
  74. package/esm/src/transforms/plugins/babel-node-positions.d.ts.map +1 -1
  75. package/esm/src/transforms/plugins/babel-node-positions.js +10 -123
  76. package/esm/src/utils/version-constant.d.ts +1 -1
  77. package/esm/src/utils/version-constant.js +1 -1
  78. package/package.json +1 -6
  79. package/src/deno.js +8 -11
  80. package/src/src/agent/agent-service.ts +91 -7
  81. package/src/src/agent/index.ts +4 -0
  82. package/src/src/embedding/resolve.ts +18 -7
  83. package/src/src/embedding/veryfront-cloud/provider.ts +4 -10
  84. package/src/src/extensions/contracts.ts +3 -3
  85. package/src/src/extensions/interfaces/ai-provider.ts +54 -0
  86. package/src/src/extensions/interfaces/code-parser.ts +12 -0
  87. package/src/src/extensions/interfaces/css-processor.ts +43 -22
  88. package/src/src/extensions/interfaces/index.ts +15 -11
  89. package/src/src/extensions/interfaces/schema-validator.ts +112 -5
  90. package/src/src/extensions/loader.ts +14 -0
  91. package/src/src/extensions/orchestrate.ts +5 -0
  92. package/src/src/extensions/recommendations.ts +4 -1
  93. package/src/src/extensions/registries/ai-provider-registry.ts +53 -0
  94. package/src/src/html/styles-builder/plugin-loader.ts +4 -16
  95. package/src/src/html/styles-builder/tailwind-compiler-cache.ts +27 -6
  96. package/src/src/provider/model-registry.ts +34 -15
  97. package/src/src/provider/runtime-loader/provider-embedding-responses.ts +1 -1
  98. package/src/src/provider/runtime-loader/provider-http.ts +2 -2
  99. package/src/src/provider/runtime-loader.ts +41 -1189
  100. package/src/src/provider/veryfront-cloud/provider.ts +35 -19
  101. package/src/src/sandbox/index.ts +5 -1
  102. package/src/src/sandbox/lazy-sandbox.ts +25 -1
  103. package/src/src/schemas/define.ts +48 -0
  104. package/src/src/schemas/index.ts +13 -2
  105. package/src/src/schemas/zod-adapter.ts +180 -0
  106. package/src/src/server/bootstrap.ts +5 -0
  107. package/src/src/transforms/plugins/babel-node-positions.ts +11 -173
  108. package/src/src/utils/version-constant.ts +1 -1
  109. package/esm/src/extensions/interfaces/ai-model-provider.d.ts +0 -94
  110. package/esm/src/extensions/interfaces/ai-model-provider.d.ts.map +0 -1
  111. package/esm/src/extensions/interfaces/ai-model-provider.js +0 -8
  112. package/src/src/extensions/interfaces/ai-model-provider.ts +0 -100
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.283";
3
+ export const VERSION = "0.1.285";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.283",
3
+ "version": "0.1.285",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
@@ -188,10 +188,6 @@
188
188
  }
189
189
  },
190
190
  "dependencies": {
191
- "@babel/generator": "7.29.1",
192
- "@babel/parser": "7.29.2",
193
- "@babel/traverse": "7.29.0",
194
- "@babel/types": "7.29.0",
195
191
  "@mdx-js/mdx": "3.1.1",
196
192
  "@types/hast": "3.0.3",
197
193
  "@types/mdast": "4.0.3",
@@ -215,7 +211,6 @@
215
211
  "remark-parse": "11.0.0",
216
212
  "remark-rehype": "11.1.2",
217
213
  "tailwind-merge": "3.5.0",
218
- "tailwindcss": "4.2.2",
219
214
  "unified": "11.0.5",
220
215
  "unist-util-visit": "5.1.0",
221
216
  "vfile": "6.0.3",
package/src/deno.js CHANGED
@@ -1,12 +1,17 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.283",
3
+ "version": "0.1.285",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
7
- "./extensions/ext-redis",
7
+ "./extensions/ext-anthropic",
8
+ "./extensions/ext-babel",
9
+ "./extensions/ext-jwt",
10
+ "./extensions/ext-node-compat",
11
+ "./extensions/ext-openai",
8
12
  "./extensions/ext-opentelemetry",
9
- "./extensions/ext-node-compat"
13
+ "./extensions/ext-redis",
14
+ "./extensions/ext-tailwind"
10
15
  ],
11
16
  "exclude": [
12
17
  "npm/",
@@ -265,14 +270,6 @@ export default {
265
270
  "unist": "npm:@types/unist@3.0.2",
266
271
  "unified": "npm:unified@11.0.5",
267
272
  "vfile": "npm:vfile@6.0.3",
268
- "tailwindcss": "https://esm.sh/tailwindcss@4.2.2",
269
- "tailwindcss/plugin": "https://esm.sh/tailwindcss@4.2.2/plugin",
270
- "tailwindcss/defaultTheme": "https://esm.sh/tailwindcss@4.2.2/defaultTheme",
271
- "tailwindcss/colors": "https://esm.sh/tailwindcss@4.2.2/colors",
272
- "@babel/parser": "npm:@babel/parser@7.29.2",
273
- "@babel/traverse": "npm:@babel/traverse@7.29.0",
274
- "@babel/generator": "npm:@babel/generator@7.29.1",
275
- "@babel/types": "npm:@babel/types@7.29.0",
276
273
  "class-variance-authority": "npm:class-variance-authority@0.7.1",
277
274
  "tailwind-merge": "npm:tailwind-merge@3.5.0"
278
275
  },
@@ -26,21 +26,70 @@ export interface AgentServiceServerConfig {
26
26
  cors?: boolean;
27
27
  }
28
28
 
29
- /**
30
- * Phase-0 contract draft for the future framework-owned hosted agent service.
31
- */
32
- export interface AgentContract<
29
+ export type AgentRegistry = Record<string, Agent>;
30
+
31
+ export interface AgentServiceContractBase<
33
32
  TStartInput = void,
34
33
  TRun = unknown,
35
34
  TEvent = unknown,
36
35
  TTerminalState = unknown,
37
36
  > {
38
37
  serviceName: string;
39
- agent: Agent;
40
38
  server?: AgentServiceServerConfig;
41
39
  durableRunSink?: DurableRunSink<TStartInput, TRun, TEvent, TTerminalState>;
42
40
  }
43
41
 
42
+ /**
43
+ * Multi-agent hosted-service contract. Framework services route to
44
+ * `defaultAgentId` unless the host chooses another registered agent.
45
+ */
46
+ export interface AgentServiceRegistryContract<
47
+ TStartInput = void,
48
+ TRun = unknown,
49
+ TEvent = unknown,
50
+ TTerminalState = unknown,
51
+ > extends AgentServiceContractBase<TStartInput, TRun, TEvent, TTerminalState> {
52
+ agents: AgentRegistry;
53
+ defaultAgentId: string;
54
+ }
55
+
56
+ /**
57
+ * Single-agent convenience accepted by `defineAgentService()`. Implementations
58
+ * must normalize this shape into the same registry path used by multi-agent
59
+ * services so framework users are not boxed into one-agent-per-process.
60
+ */
61
+ export interface AgentServiceSingleAgentContract<
62
+ TStartInput = void,
63
+ TRun = unknown,
64
+ TEvent = unknown,
65
+ TTerminalState = unknown,
66
+ > extends AgentServiceContractBase<TStartInput, TRun, TEvent, TTerminalState> {
67
+ agent: Agent;
68
+ defaultAgentId?: string;
69
+ }
70
+
71
+ /**
72
+ * Phase-0 contract draft for the future framework-owned hosted agent service.
73
+ */
74
+ export type AgentContract<
75
+ TStartInput = void,
76
+ TRun = unknown,
77
+ TEvent = unknown,
78
+ TTerminalState = unknown,
79
+ > =
80
+ | AgentServiceRegistryContract<TStartInput, TRun, TEvent, TTerminalState>
81
+ | AgentServiceSingleAgentContract<TStartInput, TRun, TEvent, TTerminalState>;
82
+
83
+ export interface NormalizedAgentServiceContract<
84
+ TStartInput = void,
85
+ TRun = unknown,
86
+ TEvent = unknown,
87
+ TTerminalState = unknown,
88
+ > extends AgentServiceContractBase<TStartInput, TRun, TEvent, TTerminalState> {
89
+ agents: AgentRegistry;
90
+ defaultAgentId: string;
91
+ }
92
+
44
93
  /**
45
94
  * Type-preserving service definition reserved ahead of the runtime
46
95
  * implementation landing in a later migration phase.
@@ -51,12 +100,47 @@ export interface AgentServiceDefinition<
51
100
  TEvent = unknown,
52
101
  TTerminalState = unknown,
53
102
  > {
54
- contract: AgentContract<TStartInput, TRun, TEvent, TTerminalState>;
103
+ contract: NormalizedAgentServiceContract<TStartInput, TRun, TEvent, TTerminalState>;
55
104
  }
56
105
 
57
106
  const DEFINE_AGENT_SERVICE_STUB_ERROR =
58
107
  "defineAgentService() is a Phase 0 stub. The framework contract is reserved, but the hosted runtime implementation has not landed yet.";
59
108
 
109
+ function getSingleAgentDefaultId(contract: {
110
+ agent: Agent;
111
+ defaultAgentId?: string;
112
+ }): string {
113
+ return contract.defaultAgentId ?? contract.agent.id ?? "default";
114
+ }
115
+
116
+ function normalizeAgentServiceContract<
117
+ TStartInput = void,
118
+ TRun = unknown,
119
+ TEvent = unknown,
120
+ TTerminalState = unknown,
121
+ >(
122
+ contract: AgentContract<TStartInput, TRun, TEvent, TTerminalState>,
123
+ ): NormalizedAgentServiceContract<TStartInput, TRun, TEvent, TTerminalState> {
124
+ if ("agents" in contract) {
125
+ return {
126
+ serviceName: contract.serviceName,
127
+ agents: contract.agents,
128
+ defaultAgentId: contract.defaultAgentId,
129
+ server: contract.server,
130
+ durableRunSink: contract.durableRunSink,
131
+ };
132
+ }
133
+
134
+ const defaultAgentId = getSingleAgentDefaultId(contract);
135
+ return {
136
+ serviceName: contract.serviceName,
137
+ agents: { [defaultAgentId]: contract.agent },
138
+ defaultAgentId,
139
+ server: contract.server,
140
+ durableRunSink: contract.durableRunSink,
141
+ };
142
+ }
143
+
60
144
  /**
61
145
  * Reserve the public hosted agent-service signature before the runtime
62
146
  * implementation lands.
@@ -69,6 +153,6 @@ export function defineAgentService<
69
153
  >(
70
154
  contract: AgentContract<TStartInput, TRun, TEvent, TTerminalState>,
71
155
  ): AgentServiceDefinition<TStartInput, TRun, TEvent, TTerminalState> {
72
- void contract;
156
+ void normalizeAgentServiceContract(contract);
73
157
  throw new Error(DEFINE_AGENT_SERVICE_STUB_ERROR);
74
158
  }
@@ -143,10 +143,14 @@ export {
143
143
  export { agent } from "./factory.js";
144
144
  export {
145
145
  type AgentContract,
146
+ type AgentRegistry,
146
147
  type AgentServiceDefinition,
148
+ type AgentServiceRegistryContract,
147
149
  type AgentServiceServerConfig,
150
+ type AgentServiceSingleAgentContract,
148
151
  defineAgentService,
149
152
  type DurableRunSink,
153
+ type NormalizedAgentServiceContract,
150
154
  } from "./agent-service.js";
151
155
  export {
152
156
  type AgUiRuntimeHandlerConfig,
@@ -1,11 +1,11 @@
1
1
  import { createError, toError } from "../errors/veryfront-error.js";
2
2
  import { getGoogleGenAIEnvConfig, getOpenAIEnvConfig } from "../config/env.js";
3
3
  import { createLocalEmbeddingModel } from "../provider/local/embedding-runtime-adapter.js";
4
- import {
5
- createGoogleEmbeddingRuntime,
6
- createOpenAIEmbeddingRuntime,
7
- } from "../provider/runtime-loader.js";
4
+ import { createGoogleEmbeddingRuntime } from "../provider/runtime-loader.js";
8
5
  import type { EmbeddingRuntime } from "../provider/types.js";
6
+ import { tryResolve } from "../extensions/contracts.js";
7
+ import type { AIProviderRegistry } from "../extensions/interfaces/index.js";
8
+ import { AIProviderRegistryName } from "../extensions/interfaces/index.js";
9
9
  import { createVeryfrontCloudEmbeddingModel } from "./veryfront-cloud/provider.js";
10
10
 
11
11
  type EmbeddingProviderFactory = (modelId: string) => EmbeddingRuntime;
@@ -44,9 +44,20 @@ function autoInitializeFromEnv(): void {
44
44
  }),
45
45
  );
46
46
  }
47
- return createOpenAIEmbeddingRuntime(
48
- { apiKey: config.apiKey, baseURL: config.baseURL },
49
- id,
47
+ const registry = tryResolve<AIProviderRegistry>(AIProviderRegistryName);
48
+ const provider = registry?.get("openai");
49
+ if (provider?.createEmbedding) {
50
+ return provider.createEmbedding(id, {
51
+ credential: config.apiKey,
52
+ baseURL: config.baseURL,
53
+ });
54
+ }
55
+ throw toError(
56
+ createError({
57
+ type: "config",
58
+ message:
59
+ "OpenAI provider not installed. Add @veryfront/ext-openai to use openai/* embedding models.",
60
+ }),
50
61
  );
51
62
  });
52
63
  }
@@ -1,8 +1,5 @@
1
1
  import { createError, toError } from "../../errors/veryfront-error.js";
2
- import {
3
- createGoogleEmbeddingRuntime,
4
- createOpenAIEmbeddingRuntime,
5
- } from "../../provider/runtime-loader.js";
2
+ import { createGoogleEmbeddingRuntime } from "../../provider/runtime-loader.js";
6
3
  import type { EmbeddingRuntime } from "../../provider/types.js";
7
4
  import {
8
5
  createVeryfrontCloudFetch,
@@ -19,12 +16,9 @@ export function createVeryfrontCloudEmbeddingModel(modelId: string): EmbeddingRu
19
16
 
20
17
  switch (provider) {
21
18
  case "openai":
22
- return createOpenAIEmbeddingRuntime({
23
- apiKey: apiToken,
24
- baseURL,
25
- name: "veryfront-cloud",
26
- fetch,
27
- }, upstreamModelId);
19
+ throw new Error(
20
+ "OpenAI provider not installed. Add @veryfront/ext-openai to use openai embedding models via veryfront-cloud.",
21
+ );
28
22
 
29
23
  case "google":
30
24
  return createGoogleEmbeddingRuntime({
@@ -14,9 +14,9 @@ export function resolve<T>(name: string): T {
14
14
  if (impl === undefined) {
15
15
  const recommendation = getRecommendation(name);
16
16
  throw MISSING_EXTENSION_ERROR.create({
17
- message: `Missing extension for contract "${name}"${
18
- recommendation ? `. Recommended: ${recommendation}` : ""
19
- }`,
17
+ message: recommendation
18
+ ? `Missing extension for contract "${name}". Install it with: deno add ${recommendation}`
19
+ : `Missing extension for contract "${name}"`,
20
20
  detail: recommendation ? `Install it with: deno add ${recommendation}` : undefined,
21
21
  });
22
22
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Contract interface for LLM provider extensions.
3
+ *
4
+ * A single `AIProviderRegistry` impl lives in the contract registry under
5
+ * {@link AIProviderRegistryName}. Each provider extension resolves the
6
+ * registry in its `setup()` and calls `registry.register(provider)`.
7
+ * Core consumers (model-registry, veryfront-cloud) resolve the registry
8
+ * and dispatch on provider id parsed from `"provider/model"` strings.
9
+ *
10
+ * @module extensions/interfaces/ai-provider
11
+ */
12
+
13
+ import type { EmbeddingRuntime, ModelRuntime } from "../../provider/types.js";
14
+
15
+ /** Config passed to any provider's create* method. */
16
+ export interface AIProviderConfig {
17
+ /** API credential — maps to OpenAI `apiKey`, Anthropic `authToken`, Google `apiKey` internally. */
18
+ credential: string;
19
+ /** Override the provider's base URL (e.g. Azure OpenAI, self-hosted gateway). */
20
+ baseURL?: string;
21
+ /** Override fetch (veryfront-cloud uses this to inject project auth headers). */
22
+ fetch?: typeof fetch;
23
+ /** Display name shown in errors + telemetry. Defaults to provider id. */
24
+ name?: string;
25
+ /** Provider-specific extras. */
26
+ [key: string]: unknown;
27
+ }
28
+
29
+ /**
30
+ * An LLM provider implementation. Extensions register one of these with the
31
+ * {@link AIProviderRegistry} during setup(). `createModel` is required;
32
+ * `createEmbedding` and `createResponses` are optional and absent on
33
+ * providers that don't support them.
34
+ */
35
+ export interface AIProvider {
36
+ /** Stable id used in model strings: "openai" / "anthropic" / "google". */
37
+ readonly id: string;
38
+ createModel(modelId: string, config: AIProviderConfig): ModelRuntime;
39
+ createEmbedding?(modelId: string, config: AIProviderConfig): EmbeddingRuntime;
40
+ createResponses?(modelId: string, config: AIProviderConfig): ModelRuntime;
41
+ }
42
+
43
+ /** Registry contract. Single impl created at bootstrap. */
44
+ export interface AIProviderRegistry {
45
+ register(provider: AIProvider): void;
46
+ unregister(id: string): void;
47
+ get(id: string): AIProvider | undefined;
48
+ require(id: string): AIProvider;
49
+ list(): AIProvider[];
50
+ has(id: string): boolean;
51
+ }
52
+
53
+ /** Contract name used for `resolve()` / `provide()`. */
54
+ export const AIProviderRegistryName = "AIProviderRegistry" as const;
@@ -74,6 +74,12 @@ export interface GenerateResult {
74
74
  * Implementations parse source code into ASTs, traverse/transform
75
75
  * nodes, and generate code back from modified trees.
76
76
  */
77
+ /** Options for {@link CodeParser.injectJsxNodePositions}. */
78
+ export interface InjectJsxNodePositionsOptions {
79
+ /** Source file path — emitted into `data-node-file` attributes. */
80
+ filePath: string;
81
+ }
82
+
77
83
  export interface CodeParser {
78
84
  /** Parse source code into an abstract syntax tree. */
79
85
  parse(options: ParseOptions): Promise<ASTNode>;
@@ -81,4 +87,10 @@ export interface CodeParser {
81
87
  traverse(ast: ASTNode, visitor: TraverseVisitor): void;
82
88
  /** Generate source code from an AST. */
83
89
  generate(ast: ASTNode, options?: GenerateOptions): Promise<GenerateResult>;
90
+ /**
91
+ * Inject `data-node-*` attributes into every JSX element in the source,
92
+ * enabling Studio Navigator to map rendered elements back to their
93
+ * source positions. Parsing failures return the input unchanged.
94
+ */
95
+ injectJsxNodePositions(source: string, options: InjectJsxNodePositionsOptions): string;
84
96
  }
@@ -1,40 +1,61 @@
1
1
  /**
2
- * Contract interface for CSS processing engines.
2
+ * Contract interface for CSS processing engines (Tailwind-style compile
3
+ * pipelines).
3
4
  *
4
5
  * Default implementation: `@veryfront/ext-tailwind`
5
6
  *
7
+ * The contract mirrors the Tailwind v4 `compile()` surface: a stateful
8
+ * compiler is constructed once per stylesheet and emits CSS output for the
9
+ * set of class-name candidates discovered at render time. Core scans the
10
+ * rendered HTML for candidates and calls `CSSCompiler.build(candidates)`
11
+ * on each request; the compiler accumulates state across calls, so per-
12
+ * project isolation is the caller's responsibility (see
13
+ * `tailwind-compiler-cache.ts`).
14
+ *
6
15
  * @module extensions/interfaces/css-processor
7
16
  */
8
17
 
9
- /** Options passed to {@link CSSProcessor.process}. */
10
- export interface CSSProcessOptions {
11
- /** Raw CSS or utility-class input. */
18
+ /** A loaded stylesheet body with the base path used to resolve relative imports. */
19
+ export interface CSSStylesheetSource {
12
20
  content: string;
13
- /** Paths to source files used for scanning class usage. */
14
- sources?: string[];
15
- /** Enable minification of the output. */
16
- minify?: boolean;
17
- /** Extra implementation-specific options. */
18
- [key: string]: unknown;
21
+ base: string;
22
+ path: string;
23
+ }
24
+
25
+ /** A loaded module (Tailwind plugin). `module` is the plugin's default export. */
26
+ export interface CSSModuleSource {
27
+ module: unknown;
28
+ base: string;
29
+ path: string;
30
+ }
31
+
32
+ /** Options passed to {@link CSSProcessor.compile}. */
33
+ export interface CSSCompileOptions {
34
+ /** Base path used to resolve relative `@import` specifiers. */
35
+ base: string;
36
+ /** Resolver invoked when the compiler encounters an `@import` it doesn't recognize. */
37
+ loadStylesheet(id: string): Promise<CSSStylesheetSource>;
38
+ /** Resolver invoked for `@plugin` directives. */
39
+ loadModule(id: string): Promise<CSSModuleSource>;
19
40
  }
20
41
 
21
- /** Result returned from {@link CSSProcessor.process}. */
22
- export interface CSSProcessResult {
23
- /** Processed CSS output. */
24
- css: string;
25
- /** Source map, if generated. */
26
- map?: string;
42
+ /** Stateful compiler returned by {@link CSSProcessor.compile}. */
43
+ export interface CSSCompiler {
44
+ /**
45
+ * Emit CSS for the supplied list of class-name candidates. Stateful — the
46
+ * compiler accumulates candidates across calls for the lifetime of the
47
+ * underlying compile session.
48
+ */
49
+ build(candidates: string[]): string;
27
50
  }
28
51
 
29
52
  /**
30
53
  * CSSProcessor contract interface.
31
54
  *
32
- * Implementations compile utility classes or raw CSS into optimized
33
- * stylesheets ready for the browser.
55
+ * Implementations wire a utility-class compiler (Tailwind, UnoCSS, etc.) so
56
+ * core's styles-builder can emit per-request CSS without importing the
57
+ * underlying engine directly.
34
58
  */
35
59
  export interface CSSProcessor {
36
- /** Process CSS input and return the compiled result. */
37
- process(options: CSSProcessOptions): Promise<CSSProcessResult>;
38
- /** Merge class names using the processor's conflict-resolution strategy. */
39
- mergeClasses?(...classes: string[]): string;
60
+ compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler>;
40
61
  }
@@ -27,7 +27,13 @@ export type { CacheStore } from "./cache-store.js";
27
27
  export type { TokenCacheEntry, TokenCacheStats, TokenCacheStore } from "./token-cache-store.js";
28
28
 
29
29
  // CSS processor
30
- export type { CSSProcessOptions, CSSProcessor, CSSProcessResult } from "./css-processor.js";
30
+ export type {
31
+ CSSCompileOptions,
32
+ CSSCompiler,
33
+ CSSModuleSource,
34
+ CSSProcessor,
35
+ CSSStylesheetSource,
36
+ } from "./css-processor.js";
31
37
 
32
38
  // Content transformer
33
39
  export type {
@@ -51,16 +57,9 @@ export type {
51
57
  // Tracing exporter
52
58
  export type { SpanData, TracerProvider, TracingExporter } from "./tracing-exporter.js";
53
59
 
54
- // AI model provider
55
- export type {
56
- AIModelProvider,
57
- ChatMessage,
58
- CompletionOptions,
59
- CompletionResult,
60
- ContentPart,
61
- StreamChunk,
62
- ToolDefinition,
63
- } from "./ai-model-provider.js";
60
+ // AI provider (registry + per-provider contract)
61
+ export type { AIProvider, AIProviderConfig, AIProviderRegistry } from "./ai-provider.js";
62
+ export { AIProviderRegistryName } from "./ai-provider.js";
64
63
 
65
64
  // Embedding provider
66
65
  export type { EmbeddingOptions, EmbeddingProvider, EmbeddingResult } from "./embedding-provider.js";
@@ -71,6 +70,7 @@ export type {
71
70
  CodeParser,
72
71
  GenerateOptions,
73
72
  GenerateResult,
73
+ InjectJsxNodePositionsOptions,
74
74
  NodePath,
75
75
  ParseOptions,
76
76
  TraverseVisitor,
@@ -78,8 +78,12 @@ export type {
78
78
 
79
79
  // Schema validator
80
80
  export type {
81
+ InferSchema,
82
+ InferShape,
81
83
  Schema,
84
+ SchemaFactory,
82
85
  SchemaValidator,
86
+ SchemaValidatorCoerce,
83
87
  ValidationFailure,
84
88
  ValidationIssue,
85
89
  ValidationResult,
@@ -3,15 +3,68 @@
3
3
  *
4
4
  * Default implementation: `@veryfront/ext-zod`
5
5
  *
6
+ * The interface exposes a small DSL (inspired by zod) that lets core modules
7
+ * declare validation schemas without importing zod directly. Schemas are
8
+ * constructed lazily via `defineSchema()` so that an extension-provided
9
+ * implementation can be registered before any schema is materialized.
10
+ *
6
11
  * @module extensions/interfaces/schema-validator
7
12
  */
8
13
 
9
- /** An opaque schema definition that validates and infers type `T`. */
14
+ /**
15
+ * An opaque schema definition that validates and infers type `T`.
16
+ *
17
+ * Implementations may use this as a nominal wrapper around a native validator
18
+ * (e.g. a zod schema). Core code only calls the methods defined here.
19
+ */
10
20
  export interface Schema<T = unknown> {
11
- /** Brand field for nominal typing -- not used at runtime. */
21
+ /** Brand field for nominal typing not used at runtime. */
12
22
  readonly _output: T;
23
+
24
+ // Refinement / modifier chainables
25
+ optional(): Schema<T | undefined>;
26
+ nullable(): Schema<T | null>;
27
+ nullish(): Schema<T | null | undefined>;
28
+ default(value: T | (() => T)): Schema<T>;
29
+ describe(description: string): Schema<T>;
30
+ refine(check: (value: T) => boolean, message?: string | { message?: string }): Schema<T>;
31
+ transform<U>(fn: (value: T) => U): Schema<U>;
32
+
33
+ // Object-level chainables (no-op / type-preserving on non-object schemas;
34
+ // implementations should only call these on object schemas).
35
+ strict(): Schema<T>;
36
+ passthrough(): Schema<T>;
37
+ partial(): Schema<Partial<T>>;
38
+ extend<U extends Record<string, Schema<unknown>>>(
39
+ shape: U,
40
+ ): Schema<T & { [K in keyof U]: InferSchema<U[K]> }>;
41
+ merge<U>(other: Schema<U>): Schema<T & U>;
42
+
43
+ // String-level chainables
44
+ min(value: number, message?: string): Schema<T>;
45
+ max(value: number, message?: string): Schema<T>;
46
+ int(message?: string): Schema<T>;
47
+ positive(message?: string): Schema<T>;
48
+ nonnegative(message?: string): Schema<T>;
49
+ regex(pattern: RegExp, message?: string): Schema<T>;
50
+ email(message?: string): Schema<T>;
51
+ url(message?: string): Schema<T>;
52
+ uuid(message?: string): Schema<T>;
53
+ datetime(message?: string): Schema<T>;
54
+
55
+ // Validation
56
+ parse(data: unknown): T;
57
+ safeParse(data: unknown): ValidationResult<T>;
13
58
  }
14
59
 
60
+ /** Extracts the inferred output type `T` from a `Schema<T>`. */
61
+ export type InferSchema<S> = S extends Schema<infer T> ? T : never;
62
+
63
+ /** Maps a raw object shape to its inferred object type. */
64
+ export type InferShape<S extends Record<string, Schema<unknown>>> = {
65
+ [K in keyof S]: InferSchema<S[K]>;
66
+ };
67
+
15
68
  /** A single validation issue with location context. */
16
69
  export interface ValidationIssue {
17
70
  /** Dot-path to the offending field (e.g. `"user.email"`). */
@@ -34,18 +87,72 @@ export interface ValidationFailure {
34
87
  success: false;
35
88
  /** List of issues found during validation. */
36
89
  issues: ValidationIssue[];
90
+ /** Native error thrown by the underlying validator (if any). */
91
+ error?: unknown;
37
92
  }
38
93
 
39
94
  /** Discriminated union of validation outcomes. */
40
95
  export type ValidationResult<T> = ValidationSuccess<T> | ValidationFailure;
41
96
 
97
+ /**
98
+ * Namespace for `coerce.*` constructors — accepts input in any form and
99
+ * coerces to the target type before validation.
100
+ */
101
+ export interface SchemaValidatorCoerce {
102
+ string(): Schema<string>;
103
+ number(): Schema<number>;
104
+ boolean(): Schema<boolean>;
105
+ date(): Schema<Date>;
106
+ }
107
+
42
108
  /**
43
109
  * SchemaValidator contract interface.
44
110
  *
45
- * Implementations validate unknown input against a typed schema and
46
- * return a discriminated success/failure result.
111
+ * Exposes a zod-inspired DSL. The `object(shape)`, `array(schema)`, etc.
112
+ * constructors produce opaque `Schema<T>` instances that can be further
113
+ * refined via chainables and finally validated with `.parse` / `.safeParse`.
47
114
  */
48
115
  export interface SchemaValidator {
49
- /** Validate `data` against the given schema. */
116
+ // Primitive constructors
117
+ string(): Schema<string>;
118
+ number(): Schema<number>;
119
+ boolean(): Schema<boolean>;
120
+ date(): Schema<Date>;
121
+ null(): Schema<null>;
122
+ unknown(): Schema<unknown>;
123
+ // deno-lint-ignore no-explicit-any -- `any` constructor intentionally mirrors zod
124
+ any(): Schema<any>;
125
+
126
+ // Composite constructors
127
+ object<S extends Record<string, Schema<unknown>>>(shape: S): Schema<InferShape<S>>;
128
+ array<T>(element: Schema<T>): Schema<T[]>;
129
+ record<K extends string | number | symbol, V>(
130
+ keys: Schema<K>,
131
+ values: Schema<V>,
132
+ ): Schema<Record<K, V>>;
133
+ union<T extends readonly [Schema<unknown>, ...Schema<unknown>[]]>(
134
+ schemas: T,
135
+ ): Schema<InferSchema<T[number]>>;
136
+ discriminatedUnion<
137
+ K extends string,
138
+ T extends readonly [Schema<unknown>, ...Schema<unknown>[]],
139
+ >(
140
+ discriminator: K,
141
+ schemas: T,
142
+ ): Schema<InferSchema<T[number]>>;
143
+ literal<T extends string | number | boolean | null>(value: T): Schema<T>;
144
+ enum<T extends readonly [string, ...string[]]>(values: T): Schema<T[number]>;
145
+
146
+ /** Coercing constructors — accept any input and coerce to the target. */
147
+ coerce: SchemaValidatorCoerce;
148
+
149
+ /**
150
+ * Convenience that runs validation on an already-constructed schema.
151
+ * Equivalent to `schema.safeParse(data)`; kept for ergonomic parity with
152
+ * earlier revisions of this contract.
153
+ */
50
154
  validate<T>(schema: Schema<T>, data: unknown): ValidationResult<T>;
51
155
  }
156
+
157
+ /** Factory type accepted by `defineSchema`. */
158
+ export type SchemaFactory<T> = (v: SchemaValidator) => Schema<T>;