veryfront 0.1.283 → 0.1.284
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/esm/deno.d.ts +0 -8
- package/esm/deno.js +8 -11
- package/esm/src/agent/agent-service.d.ts +28 -6
- package/esm/src/agent/agent-service.d.ts.map +1 -1
- package/esm/src/agent/agent-service.js +23 -1
- package/esm/src/agent/index.d.ts +1 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/embedding/resolve.d.ts.map +1 -1
- package/esm/src/embedding/resolve.js +15 -2
- package/esm/src/embedding/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/embedding/veryfront-cloud/provider.js +2 -7
- package/esm/src/extensions/contracts.js +3 -1
- package/esm/src/extensions/interfaces/ai-provider.d.ts +50 -0
- package/esm/src/extensions/interfaces/ai-provider.d.ts.map +1 -0
- package/esm/src/extensions/interfaces/ai-provider.js +13 -0
- package/esm/src/extensions/interfaces/code-parser.d.ts +11 -0
- package/esm/src/extensions/interfaces/code-parser.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/css-processor.d.ts +41 -22
- package/esm/src/extensions/interfaces/css-processor.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/css-processor.js +10 -1
- package/esm/src/extensions/interfaces/index.d.ts +5 -4
- package/esm/src/extensions/interfaces/index.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/index.js +1 -0
- package/esm/src/extensions/interfaces/schema-validator.d.ts +84 -5
- package/esm/src/extensions/interfaces/schema-validator.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/schema-validator.js +5 -0
- package/esm/src/extensions/loader.d.ts +7 -0
- package/esm/src/extensions/loader.d.ts.map +1 -1
- package/esm/src/extensions/loader.js +12 -0
- package/esm/src/extensions/orchestrate.d.ts +2 -0
- package/esm/src/extensions/orchestrate.d.ts.map +1 -1
- package/esm/src/extensions/orchestrate.js +3 -0
- package/esm/src/extensions/recommendations.d.ts.map +1 -1
- package/esm/src/extensions/recommendations.js +4 -1
- package/esm/src/extensions/registries/ai-provider-registry.d.ts +11 -0
- package/esm/src/extensions/registries/ai-provider-registry.d.ts.map +1 -0
- package/esm/src/extensions/registries/ai-provider-registry.js +40 -0
- package/esm/src/html/styles-builder/plugin-loader.d.ts.map +1 -1
- package/esm/src/html/styles-builder/plugin-loader.js +4 -16
- package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts +8 -2
- package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
- package/esm/src/html/styles-builder/tailwind-compiler-cache.js +20 -3
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +33 -6
- package/esm/src/provider/runtime-loader/provider-embedding-responses.d.ts +1 -0
- package/esm/src/provider/runtime-loader/provider-embedding-responses.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader/provider-embedding-responses.js +1 -1
- package/esm/src/provider/runtime-loader/provider-http.d.ts +9 -0
- package/esm/src/provider/runtime-loader/provider-http.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader/provider-http.js +2 -2
- package/esm/src/provider/runtime-loader.d.ts +120 -9
- package/esm/src/provider/runtime-loader.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader.js +13 -943
- package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/provider.js +30 -15
- package/esm/src/schemas/define.d.ts +31 -0
- package/esm/src/schemas/define.d.ts.map +1 -0
- package/esm/src/schemas/define.js +42 -0
- package/esm/src/schemas/index.d.ts +7 -2
- package/esm/src/schemas/index.d.ts.map +1 -1
- package/esm/src/schemas/index.js +10 -2
- package/esm/src/schemas/zod-adapter.d.ts +25 -0
- package/esm/src/schemas/zod-adapter.d.ts.map +1 -0
- package/esm/src/schemas/zod-adapter.js +120 -0
- package/esm/src/server/bootstrap.d.ts.map +1 -1
- package/esm/src/server/bootstrap.js +5 -0
- package/esm/src/transforms/plugins/babel-node-positions.d.ts +6 -7
- package/esm/src/transforms/plugins/babel-node-positions.d.ts.map +1 -1
- package/esm/src/transforms/plugins/babel-node-positions.js +10 -123
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -6
- package/src/deno.js +8 -11
- package/src/src/agent/agent-service.ts +91 -7
- package/src/src/agent/index.ts +4 -0
- package/src/src/embedding/resolve.ts +18 -7
- package/src/src/embedding/veryfront-cloud/provider.ts +4 -10
- package/src/src/extensions/contracts.ts +3 -3
- package/src/src/extensions/interfaces/ai-provider.ts +54 -0
- package/src/src/extensions/interfaces/code-parser.ts +12 -0
- package/src/src/extensions/interfaces/css-processor.ts +43 -22
- package/src/src/extensions/interfaces/index.ts +15 -11
- package/src/src/extensions/interfaces/schema-validator.ts +112 -5
- package/src/src/extensions/loader.ts +14 -0
- package/src/src/extensions/orchestrate.ts +5 -0
- package/src/src/extensions/recommendations.ts +4 -1
- package/src/src/extensions/registries/ai-provider-registry.ts +53 -0
- package/src/src/html/styles-builder/plugin-loader.ts +4 -16
- package/src/src/html/styles-builder/tailwind-compiler-cache.ts +27 -6
- package/src/src/provider/model-registry.ts +34 -15
- package/src/src/provider/runtime-loader/provider-embedding-responses.ts +1 -1
- package/src/src/provider/runtime-loader/provider-http.ts +2 -2
- package/src/src/provider/runtime-loader.ts +41 -1189
- package/src/src/provider/veryfront-cloud/provider.ts +35 -19
- package/src/src/schemas/define.ts +48 -0
- package/src/src/schemas/index.ts +13 -2
- package/src/src/schemas/zod-adapter.ts +180 -0
- package/src/src/server/bootstrap.ts +5 -0
- package/src/src/transforms/plugins/babel-node-positions.ts +11 -173
- package/src/src/utils/version-constant.ts +1 -1
- package/esm/src/extensions/interfaces/ai-model-provider.d.ts +0 -94
- package/esm/src/extensions/interfaces/ai-model-provider.d.ts.map +0 -1
- package/esm/src/extensions/interfaces/ai-model-provider.js +0 -8
- package/src/src/extensions/interfaces/ai-model-provider.ts +0 -100
|
@@ -26,21 +26,70 @@ export interface AgentServiceServerConfig {
|
|
|
26
26
|
cors?: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
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:
|
|
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
|
}
|
package/src/src/agent/index.ts
CHANGED
|
@@ -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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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:
|
|
18
|
-
|
|
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
|
-
/**
|
|
10
|
-
export interface
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
/**
|
|
22
|
-
export interface
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
33
|
-
*
|
|
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
|
-
|
|
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 {
|
|
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
|
|
55
|
-
export type {
|
|
56
|
-
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
*
|
|
46
|
-
*
|
|
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
|
-
|
|
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>;
|
|
@@ -17,6 +17,16 @@ import type { Extension, ExtensionContext, ExtensionLogger, ResolvedExtension }
|
|
|
17
17
|
export class ExtensionLoader {
|
|
18
18
|
private logger: ExtensionLogger;
|
|
19
19
|
private setupOrder: ResolvedExtension[] = [];
|
|
20
|
+
private primed: Record<string, unknown> = {};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Register contracts that will be re-applied after each `setupAll()`
|
|
24
|
+
* teardown pass. Used by `orchestrateExtensions()` to seed infrastructure
|
|
25
|
+
* (e.g. `AIProviderRegistry`) before per-extension `setup()` runs.
|
|
26
|
+
*/
|
|
27
|
+
primeContracts(contracts: Record<string, unknown>): void {
|
|
28
|
+
this.primed = { ...this.primed, ...contracts };
|
|
29
|
+
}
|
|
20
30
|
|
|
21
31
|
constructor(logger: ExtensionLogger) {
|
|
22
32
|
this.logger = logger;
|
|
@@ -154,6 +164,10 @@ export class ExtensionLoader {
|
|
|
154
164
|
// registry even when nothing is loaded yet.
|
|
155
165
|
await this.teardownAll();
|
|
156
166
|
|
|
167
|
+
for (const [name, impl] of Object.entries(this.primed)) {
|
|
168
|
+
register(name, impl);
|
|
169
|
+
}
|
|
170
|
+
|
|
157
171
|
// Check for contract conflicts before loading
|
|
158
172
|
const conflicts = detectConflicts(extensions);
|
|
159
173
|
if (conflicts.length > 0) {
|
|
@@ -30,6 +30,8 @@ export interface OrchestrateOptions {
|
|
|
30
30
|
projectDir: string;
|
|
31
31
|
config: { extensions?: ExtensionConfigEntry[] };
|
|
32
32
|
logger: ExtensionLogger;
|
|
33
|
+
/** Contracts to seed into the registry after teardown, before setup(). */
|
|
34
|
+
primeContracts?: Record<string, unknown>;
|
|
33
35
|
/** @internal Override discovery functions in tests. */
|
|
34
36
|
discovery?: {
|
|
35
37
|
discoverPackageExtensions: typeof defaultDiscovery.discoverPackageExtensions;
|
|
@@ -167,6 +169,9 @@ export async function orchestrateExtensions(
|
|
|
167
169
|
);
|
|
168
170
|
|
|
169
171
|
const loader = new ExtensionLoader(logger);
|
|
172
|
+
if (options.primeContracts) {
|
|
173
|
+
loader.primeContracts(options.primeContracts);
|
|
174
|
+
}
|
|
170
175
|
await loader.setupAll(merged, config as Record<string, unknown>);
|
|
171
176
|
return loader;
|
|
172
177
|
}
|
|
@@ -13,7 +13,10 @@ const recommendations = new Map<string, string>([
|
|
|
13
13
|
["DatabaseClient", "@veryfront/ext-postgres"],
|
|
14
14
|
["AuthProvider", "@veryfront/ext-jwt"],
|
|
15
15
|
["TracingExporter", "@veryfront/ext-opentelemetry"],
|
|
16
|
-
["
|
|
16
|
+
["AIProviderRegistry", "@veryfront/ext-openai"],
|
|
17
|
+
["AIProvider:openai", "@veryfront/ext-openai"],
|
|
18
|
+
["AIProvider:anthropic", "@veryfront/ext-anthropic"],
|
|
19
|
+
["AIProvider:google", "@veryfront/ext-google"],
|
|
17
20
|
["EmbeddingProvider", "@veryfront/ext-embeddings"],
|
|
18
21
|
["CodeParser", "@veryfront/ext-babel"],
|
|
19
22
|
["SchemaValidator", "@veryfront/ext-zod"],
|