veryfront 0.1.320 → 0.1.322

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 (37) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/extensions/ext-jwt/src/index.d.ts +39 -0
  3. package/esm/extensions/ext-jwt/src/index.d.ts.map +1 -0
  4. package/esm/extensions/ext-jwt/src/index.js +103 -0
  5. package/esm/extensions/ext-openai/src/openai-provider.d.ts +29 -0
  6. package/esm/extensions/ext-openai/src/openai-provider.d.ts.map +1 -0
  7. package/esm/extensions/ext-openai/src/openai-provider.js +1095 -0
  8. package/esm/extensions/ext-tailwind/src/index.d.ts +9 -0
  9. package/esm/extensions/ext-tailwind/src/index.d.ts.map +1 -0
  10. package/esm/extensions/ext-tailwind/src/index.js +69 -0
  11. package/esm/src/embedding/veryfront-cloud/provider.d.ts.map +1 -1
  12. package/esm/src/embedding/veryfront-cloud/provider.js +6 -1
  13. package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
  14. package/esm/src/html/styles-builder/tailwind-compiler-cache.js +30 -2
  15. package/esm/src/provider/shared/index.d.ts +16 -0
  16. package/esm/src/provider/shared/index.d.ts.map +1 -0
  17. package/esm/src/provider/shared/index.js +18 -0
  18. package/esm/src/provider/veryfront-cloud/openai.d.ts +10 -0
  19. package/esm/src/provider/veryfront-cloud/openai.d.ts.map +1 -0
  20. package/esm/src/provider/veryfront-cloud/openai.js +18 -0
  21. package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
  22. package/esm/src/provider/veryfront-cloud/provider.js +6 -1
  23. package/esm/src/proxy/main.js +3 -0
  24. package/esm/src/utils/version-constant.d.ts +1 -1
  25. package/esm/src/utils/version-constant.js +1 -1
  26. package/package.json +3 -1
  27. package/src/deno.js +1 -1
  28. package/src/extensions/ext-jwt/src/index.ts +173 -0
  29. package/src/extensions/ext-openai/src/openai-provider.ts +1481 -0
  30. package/src/extensions/ext-tailwind/src/index.ts +80 -0
  31. package/src/src/embedding/veryfront-cloud/provider.ts +6 -3
  32. package/src/src/html/styles-builder/tailwind-compiler-cache.ts +36 -2
  33. package/src/src/provider/shared/index.ts +62 -0
  34. package/src/src/provider/veryfront-cloud/openai.ts +34 -0
  35. package/src/src/provider/veryfront-cloud/provider.ts +6 -3
  36. package/src/src/proxy/main.ts +4 -0
  37. package/src/src/utils/version-constant.ts +1 -1
@@ -0,0 +1,80 @@
1
+ /**
2
+ * ext-tailwind — CSSProcessor implementation backed by Tailwind CSS v4.
3
+ *
4
+ * Provides the `CSSProcessor` contract:
5
+ * - `compile(stylesheet, options)` — delegates to tailwindcss `compile()`
6
+ * and returns a compiler whose `build(candidates)` emits CSS for the
7
+ * class-name candidates discovered at render time.
8
+ *
9
+ * The extension also installs three `globalThis` shims on setup so that
10
+ * Tailwind plugin bundles loaded at runtime from esm.sh can bind their
11
+ * `tailwindcss/plugin`, `tailwindcss/defaultTheme`, and `tailwindcss/colors`
12
+ * imports to the same tailwindcss copy this extension ships. Core's
13
+ * `plugin-loader.ts` rewrites plugin bundle code to reference these shims
14
+ * by name; without the shims installed, dynamic plugin loading fails.
15
+ *
16
+ * @module extensions/ext-tailwind
17
+ */
18
+ import * as dntShim from "../../../_dnt.shims.js";
19
+
20
+
21
+ import type { ExtensionFactory } from "../../../src/extensions/index.js";
22
+ import type { CSSCompileOptions, CSSCompiler, CSSProcessor } from "../../../src/extensions/interfaces/index.js";
23
+
24
+ import { compile } from "tailwindcss";
25
+ import plugin from "tailwindcss/plugin";
26
+ import defaultTheme from "tailwindcss/defaultTheme";
27
+ import colors from "tailwindcss/colors";
28
+
29
+ type ShimGlobal = Record<string, unknown>;
30
+
31
+ function installTailwindPluginShims(): void {
32
+ const g = dntShim.dntGlobalThis as ShimGlobal;
33
+ g.__tailwindPluginShim = { default: plugin, __esModule: true };
34
+ g.__tailwindDefaultThemeShim = { default: defaultTheme, __esModule: true };
35
+ g.__tailwindColorsShim = { default: colors, __esModule: true };
36
+ }
37
+
38
+ class TailwindCSSProcessor implements CSSProcessor {
39
+ async compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler> {
40
+ const native = await compile(stylesheet, {
41
+ base: options.base,
42
+ loadStylesheet: options.loadStylesheet,
43
+ loadModule: async (id: string) => {
44
+ const loaded = await options.loadModule(id);
45
+ // deno-lint-ignore no-explicit-any -- loaded plugin modules are opaque to the contract
46
+ return { module: loaded.module as any, base: loaded.base, path: loaded.path };
47
+ },
48
+ });
49
+ return {
50
+ build(candidates: string[]): string {
51
+ return native.build(candidates);
52
+ },
53
+ };
54
+ }
55
+ }
56
+
57
+ const extTailwind: ExtensionFactory = () => {
58
+ const impl = new TailwindCSSProcessor();
59
+ return {
60
+ name: "ext-tailwind",
61
+ version: "0.1.0",
62
+ capabilities: [
63
+ { type: "contract", name: "CSSProcessor" },
64
+ { type: "net", hosts: ["esm.sh"] },
65
+ ],
66
+ setup(ctx) {
67
+ installTailwindPluginShims();
68
+ ctx.provide("CSSProcessor", impl);
69
+ ctx.logger.info("[ext-tailwind] CSSProcessor registered");
70
+ },
71
+ teardown() {
72
+ // Shims stay installed — removing them could break in-flight plugin
73
+ // loads. The globalThis pollution is intentional and scoped to keys
74
+ // with `__tailwind` prefix.
75
+ },
76
+ };
77
+ };
78
+
79
+ export default extTailwind;
80
+ export { TailwindCSSProcessor };
@@ -7,6 +7,7 @@ import {
7
7
  parseVeryfrontCloudModelId,
8
8
  requireVeryfrontCloudBootstrap,
9
9
  } from "../../provider/veryfront-cloud/shared.js";
10
+ import { createVeryfrontCloudOpenAIEmbeddingModel } from "../../provider/veryfront-cloud/openai.js";
10
11
 
11
12
  export function createVeryfrontCloudEmbeddingModel(modelId: string): EmbeddingRuntime {
12
13
  const { provider, modelId: upstreamModelId } = parseVeryfrontCloudModelId(modelId, "embedding");
@@ -16,9 +17,11 @@ export function createVeryfrontCloudEmbeddingModel(modelId: string): EmbeddingRu
16
17
 
17
18
  switch (provider) {
18
19
  case "openai":
19
- throw new Error(
20
- "OpenAI provider not installed. Add @veryfront/ext-openai to use openai embedding models via veryfront-cloud.",
21
- );
20
+ return createVeryfrontCloudOpenAIEmbeddingModel(upstreamModelId, {
21
+ apiToken,
22
+ baseURL,
23
+ fetch,
24
+ });
22
25
 
23
26
  case "google":
24
27
  return createGoogleEmbeddingRuntime({
@@ -14,7 +14,10 @@
14
14
  * @module html/styles-builder/tailwind-compiler-cache
15
15
  */
16
16
 
17
- import { tryResolve as tryResolveContract } from "../../extensions/contracts.js";
17
+ import {
18
+ register as registerContract,
19
+ tryResolve as tryResolveContract,
20
+ } from "../../extensions/contracts.js";
18
21
  import type { CSSCompiler, CSSProcessor } from "../../extensions/interfaces/index.js";
19
22
  import { serverLogger } from "../../utils/index.js";
20
23
  import { DEPENDENCY_MISSING, NETWORK_ERROR } from "../../errors/index.js";
@@ -71,6 +74,37 @@ async function getTailwindBaseCSS(): Promise<string> {
71
74
  return tailwindBaseCSS;
72
75
  }
73
76
 
77
+ async function resolveCSSProcessor(): Promise<CSSProcessor | undefined> {
78
+ const registeredProcessor = tryResolveContract<CSSProcessor>("CSSProcessor");
79
+ if (registeredProcessor) return registeredProcessor;
80
+
81
+ try {
82
+ const { default: createTailwindExtension } = await import(
83
+ "../../../extensions/ext-tailwind/src/index.js"
84
+ );
85
+ const extension = createTailwindExtension();
86
+ await extension.setup?.({
87
+ config: {},
88
+ logger,
89
+ provide: (name: string, impl: unknown) => registerContract(name, impl),
90
+ get: () => undefined,
91
+ require: <T>(name: string): T => {
92
+ const contract = tryResolveContract<T>(name);
93
+ if (contract === undefined) {
94
+ throw new Error(`Missing required extension contract: ${name}`);
95
+ }
96
+ return contract;
97
+ },
98
+ });
99
+ } catch (error) {
100
+ logger.warn("Failed to register built-in CSSProcessor extension", {
101
+ error: error instanceof Error ? error.message : String(error),
102
+ });
103
+ }
104
+
105
+ return tryResolveContract<CSSProcessor>("CSSProcessor");
106
+ }
107
+
74
108
  function evictOldestCompiler(): void {
75
109
  if (compilerCache.size < MAX_CACHED_COMPILERS) return;
76
110
 
@@ -108,7 +142,7 @@ export async function getCompiler(
108
142
 
109
143
  logger.debug("Creating new compiler", { hash, projectSlug });
110
144
 
111
- const processor = tryResolveContract<CSSProcessor>("CSSProcessor");
145
+ const processor = await resolveCSSProcessor();
112
146
  if (!processor) {
113
147
  logger.warn(
114
148
  "No CSSProcessor extension registered — CSS output will be empty. Install it with: deno add @veryfront/ext-tailwind",
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Shared plumbing consumed by the `@veryfront/ext-*` provider extensions.
3
+ *
4
+ * This barrel is the stable public surface: implementations currently live
5
+ * in `runtime-loader.ts` and `runtime-loader/` subdirectory. Future PRs
6
+ * (post ext-anthropic / ext-google extraction) may move the implementations
7
+ * into this directory; extensions keep importing from here unchanged.
8
+ *
9
+ * @module provider/shared
10
+ */
11
+
12
+ // URL builders
13
+ export {
14
+ getAnthropicMessagesUrl,
15
+ getGoogleEmbeddingUrl,
16
+ getGoogleGenerateContentUrl,
17
+ getGoogleStreamGenerateContentUrl,
18
+ getOpenAIChatCompletionsUrl,
19
+ getOpenAIEmbeddingUrl,
20
+ getOpenAIResponsesUrl,
21
+ } from "../runtime-loader/provider-endpoints.js";
22
+
23
+ // Request init builders
24
+ export {
25
+ createAnthropicRequestInit,
26
+ createGoogleRequestInit,
27
+ createOpenAIRequestInit,
28
+ } from "../runtime-loader/provider-request-init.js";
29
+
30
+ // Tool-input status transitions
31
+ export {
32
+ TOOL_INPUT_PENDING_THRESHOLD_MS,
33
+ withToolInputStatusTransitions,
34
+ } from "../runtime-loader/tool-input-status.js";
35
+
36
+ // Retry / error / HTTP plumbing (currently in runtime-loader.ts).
37
+ export {
38
+ buildProviderError,
39
+ createWarningCollector,
40
+ isNumberArray,
41
+ mergeUsage,
42
+ parseRetryAfterMs,
43
+ ProviderError,
44
+ ProviderOverloadedError,
45
+ ProviderQuotaError,
46
+ ProviderRateLimitError,
47
+ ProviderRequestError,
48
+ readProviderOptions,
49
+ readRecord,
50
+ readTextParts,
51
+ requestJson,
52
+ requestStream,
53
+ stringifyJsonValue,
54
+ toOpenAICompatibleMessages,
55
+ toOpenAICompatibleTools,
56
+ } from "../runtime-loader.js";
57
+
58
+ export type {
59
+ OpenAICompatibleChatMessage,
60
+ OpenAICompatibleChatRequest,
61
+ RuntimePromptMessage,
62
+ } from "../runtime-loader.js";
@@ -0,0 +1,34 @@
1
+ import type { EmbeddingRuntime, ModelRuntime } from "../types.js";
2
+ import { OpenAIProvider } from "../../../extensions/ext-openai/src/openai-provider.js";
3
+
4
+ const openAIProvider = new OpenAIProvider();
5
+
6
+ interface VeryfrontCloudOpenAIConfig {
7
+ apiToken: string;
8
+ baseURL: string;
9
+ fetch: typeof globalThis.fetch;
10
+ }
11
+
12
+ export function createVeryfrontCloudOpenAIModel(
13
+ modelId: string,
14
+ config: VeryfrontCloudOpenAIConfig,
15
+ ): ModelRuntime {
16
+ return openAIProvider.createModel(modelId, {
17
+ credential: config.apiToken,
18
+ baseURL: config.baseURL,
19
+ name: "veryfront-cloud",
20
+ fetch: config.fetch,
21
+ });
22
+ }
23
+
24
+ export function createVeryfrontCloudOpenAIEmbeddingModel(
25
+ modelId: string,
26
+ config: VeryfrontCloudOpenAIConfig,
27
+ ): EmbeddingRuntime {
28
+ return openAIProvider.createEmbedding(modelId, {
29
+ credential: config.apiToken,
30
+ baseURL: config.baseURL,
31
+ name: "veryfront-cloud",
32
+ fetch: config.fetch,
33
+ });
34
+ }
@@ -10,6 +10,7 @@ import {
10
10
  parseVeryfrontCloudModelId,
11
11
  requireVeryfrontCloudBootstrap,
12
12
  } from "./shared.js";
13
+ import { createVeryfrontCloudOpenAIModel } from "./openai.js";
13
14
 
14
15
  export function createVeryfrontCloudModel(modelId: string): ModelRuntime {
15
16
  const { provider, modelId: upstreamModelId } = parseVeryfrontCloudModelId(modelId, "language");
@@ -61,9 +62,11 @@ export function createVeryfrontCloudModel(modelId: string): ModelRuntime {
61
62
  fetch,
62
63
  });
63
64
  }
64
- throw new Error(
65
- "OpenAI provider not installed. Add @veryfront/ext-openai to use openai/moonshotai models via veryfront-cloud.",
66
- );
65
+ return createVeryfrontCloudOpenAIModel(upstreamModelId, {
66
+ apiToken,
67
+ baseURL,
68
+ fetch,
69
+ });
67
70
  }
68
71
 
69
72
  default: {
@@ -25,6 +25,8 @@ import * as dntShim from "../../_dnt.shims.js";
25
25
  import { createProxyHandler, INTERNAL_PROXY_HEADERS, type ProxyConfig } from "./handler.js";
26
26
  import { createCacheFromEnv } from "./cache/index.js";
27
27
  import { isRetryableConnectionError } from "./retry.js";
28
+ import { register } from "../extensions/contracts.js";
29
+ import { createAuthProvider } from "../../extensions/ext-jwt/src/index.js";
28
30
  import {
29
31
  endSpan,
30
32
  extractContext,
@@ -112,6 +114,8 @@ const VERYFRONT_SERVER_RETRY_DELAY_MS = parseInt(
112
114
  getEnv("VERYFRONT_SERVER_RETRY_DELAY_MS") || String(DEFAULT_SERVER_RETRY_DELAY_MS),
113
115
  );
114
116
 
117
+ register("AuthProvider", createAuthProvider({}));
118
+
115
119
  // Initialize cache and proxy handler
116
120
  const cache = await createCacheFromEnv();
117
121
  const proxyHandler = createProxyHandler({
@@ -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.320";
3
+ export const VERSION = "0.1.322";