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.
- package/esm/deno.js +1 -1
- package/esm/extensions/ext-jwt/src/index.d.ts +39 -0
- package/esm/extensions/ext-jwt/src/index.d.ts.map +1 -0
- package/esm/extensions/ext-jwt/src/index.js +103 -0
- package/esm/extensions/ext-openai/src/openai-provider.d.ts +29 -0
- package/esm/extensions/ext-openai/src/openai-provider.d.ts.map +1 -0
- package/esm/extensions/ext-openai/src/openai-provider.js +1095 -0
- package/esm/extensions/ext-tailwind/src/index.d.ts +9 -0
- package/esm/extensions/ext-tailwind/src/index.d.ts.map +1 -0
- package/esm/extensions/ext-tailwind/src/index.js +69 -0
- package/esm/src/embedding/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/embedding/veryfront-cloud/provider.js +6 -1
- package/esm/src/html/styles-builder/tailwind-compiler-cache.d.ts.map +1 -1
- package/esm/src/html/styles-builder/tailwind-compiler-cache.js +30 -2
- package/esm/src/provider/shared/index.d.ts +16 -0
- package/esm/src/provider/shared/index.d.ts.map +1 -0
- package/esm/src/provider/shared/index.js +18 -0
- package/esm/src/provider/veryfront-cloud/openai.d.ts +10 -0
- package/esm/src/provider/veryfront-cloud/openai.d.ts.map +1 -0
- package/esm/src/provider/veryfront-cloud/openai.js +18 -0
- package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/provider.js +6 -1
- package/esm/src/proxy/main.js +3 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +3 -1
- package/src/deno.js +1 -1
- package/src/extensions/ext-jwt/src/index.ts +173 -0
- package/src/extensions/ext-openai/src/openai-provider.ts +1481 -0
- package/src/extensions/ext-tailwind/src/index.ts +80 -0
- package/src/src/embedding/veryfront-cloud/provider.ts +6 -3
- package/src/src/html/styles-builder/tailwind-compiler-cache.ts +36 -2
- package/src/src/provider/shared/index.ts +62 -0
- package/src/src/provider/veryfront-cloud/openai.ts +34 -0
- package/src/src/provider/veryfront-cloud/provider.ts +6 -3
- package/src/src/proxy/main.ts +4 -0
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
2
|
+
import type { CSSCompileOptions, CSSCompiler, CSSProcessor } from "../../../src/extensions/interfaces/index.js";
|
|
3
|
+
declare class TailwindCSSProcessor implements CSSProcessor {
|
|
4
|
+
compile(stylesheet: string, options: CSSCompileOptions): Promise<CSSCompiler>;
|
|
5
|
+
}
|
|
6
|
+
declare const extTailwind: ExtensionFactory;
|
|
7
|
+
export default extTailwind;
|
|
8
|
+
export { TailwindCSSProcessor };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-tailwind/src/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAgBhH,cAAM,oBAAqB,YAAW,YAAY;IAC1C,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;CAgBpF;AAED,QAAA,MAAM,WAAW,EAAE,gBAoBlB,CAAC;AAEF,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import { compile } from "tailwindcss";
|
|
20
|
+
import plugin from "tailwindcss/plugin";
|
|
21
|
+
import defaultTheme from "tailwindcss/defaultTheme";
|
|
22
|
+
import colors from "tailwindcss/colors";
|
|
23
|
+
function installTailwindPluginShims() {
|
|
24
|
+
const g = dntShim.dntGlobalThis;
|
|
25
|
+
g.__tailwindPluginShim = { default: plugin, __esModule: true };
|
|
26
|
+
g.__tailwindDefaultThemeShim = { default: defaultTheme, __esModule: true };
|
|
27
|
+
g.__tailwindColorsShim = { default: colors, __esModule: true };
|
|
28
|
+
}
|
|
29
|
+
class TailwindCSSProcessor {
|
|
30
|
+
async compile(stylesheet, options) {
|
|
31
|
+
const native = await compile(stylesheet, {
|
|
32
|
+
base: options.base,
|
|
33
|
+
loadStylesheet: options.loadStylesheet,
|
|
34
|
+
loadModule: async (id) => {
|
|
35
|
+
const loaded = await options.loadModule(id);
|
|
36
|
+
// deno-lint-ignore no-explicit-any -- loaded plugin modules are opaque to the contract
|
|
37
|
+
return { module: loaded.module, base: loaded.base, path: loaded.path };
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
build(candidates) {
|
|
42
|
+
return native.build(candidates);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const extTailwind = () => {
|
|
48
|
+
const impl = new TailwindCSSProcessor();
|
|
49
|
+
return {
|
|
50
|
+
name: "ext-tailwind",
|
|
51
|
+
version: "0.1.0",
|
|
52
|
+
capabilities: [
|
|
53
|
+
{ type: "contract", name: "CSSProcessor" },
|
|
54
|
+
{ type: "net", hosts: ["esm.sh"] },
|
|
55
|
+
],
|
|
56
|
+
setup(ctx) {
|
|
57
|
+
installTailwindPluginShims();
|
|
58
|
+
ctx.provide("CSSProcessor", impl);
|
|
59
|
+
ctx.logger.info("[ext-tailwind] CSSProcessor registered");
|
|
60
|
+
},
|
|
61
|
+
teardown() {
|
|
62
|
+
// Shims stay installed — removing them could break in-flight plugin
|
|
63
|
+
// loads. The globalThis pollution is intentional and scoped to keys
|
|
64
|
+
// with `__tailwind` prefix.
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export default extTailwind;
|
|
69
|
+
export { TailwindCSSProcessor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/embedding/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/embedding/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAShE,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CA6BpF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createError, toError } from "../../errors/veryfront-error.js";
|
|
2
2
|
import { createGoogleEmbeddingRuntime } from "../../provider/runtime-loader.js";
|
|
3
3
|
import { createVeryfrontCloudFetch, getVeryfrontCloudGatewayBaseUrl, parseVeryfrontCloudModelId, requireVeryfrontCloudBootstrap, } from "../../provider/veryfront-cloud/shared.js";
|
|
4
|
+
import { createVeryfrontCloudOpenAIEmbeddingModel } from "../../provider/veryfront-cloud/openai.js";
|
|
4
5
|
export function createVeryfrontCloudEmbeddingModel(modelId) {
|
|
5
6
|
const { provider, modelId: upstreamModelId } = parseVeryfrontCloudModelId(modelId, "embedding");
|
|
6
7
|
const { apiBaseUrl, apiToken } = requireVeryfrontCloudBootstrap();
|
|
@@ -8,7 +9,11 @@ export function createVeryfrontCloudEmbeddingModel(modelId) {
|
|
|
8
9
|
const fetch = createVeryfrontCloudFetch(apiToken);
|
|
9
10
|
switch (provider) {
|
|
10
11
|
case "openai":
|
|
11
|
-
|
|
12
|
+
return createVeryfrontCloudOpenAIEmbeddingModel(upstreamModelId, {
|
|
13
|
+
apiToken,
|
|
14
|
+
baseURL,
|
|
15
|
+
fetch,
|
|
16
|
+
});
|
|
12
17
|
case "google":
|
|
13
18
|
return createGoogleEmbeddingRuntime({
|
|
14
19
|
apiKey: apiToken,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind-compiler-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/tailwind-compiler-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"tailwind-compiler-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/tailwind-compiler-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,sCAAsC,CAAC;AA0GtF,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAgEtB;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1E,CAQA;AAED,wBAAgB,gBAAgB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAalD"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module html/styles-builder/tailwind-compiler-cache
|
|
15
15
|
*/
|
|
16
|
-
import { tryResolve as tryResolveContract } from "../../extensions/contracts.js";
|
|
16
|
+
import { register as registerContract, tryResolve as tryResolveContract, } from "../../extensions/contracts.js";
|
|
17
17
|
import { serverLogger } from "../../utils/index.js";
|
|
18
18
|
import { DEPENDENCY_MISSING, NETWORK_ERROR } from "../../errors/index.js";
|
|
19
19
|
import { getTailwindCSSUrl } from "../../utils/constants/cdn.js";
|
|
@@ -51,6 +51,34 @@ async function getTailwindBaseCSS() {
|
|
|
51
51
|
}
|
|
52
52
|
return tailwindBaseCSS;
|
|
53
53
|
}
|
|
54
|
+
async function resolveCSSProcessor() {
|
|
55
|
+
const registeredProcessor = tryResolveContract("CSSProcessor");
|
|
56
|
+
if (registeredProcessor)
|
|
57
|
+
return registeredProcessor;
|
|
58
|
+
try {
|
|
59
|
+
const { default: createTailwindExtension } = await import("../../../extensions/ext-tailwind/src/index.js");
|
|
60
|
+
const extension = createTailwindExtension();
|
|
61
|
+
await extension.setup?.({
|
|
62
|
+
config: {},
|
|
63
|
+
logger,
|
|
64
|
+
provide: (name, impl) => registerContract(name, impl),
|
|
65
|
+
get: () => undefined,
|
|
66
|
+
require: (name) => {
|
|
67
|
+
const contract = tryResolveContract(name);
|
|
68
|
+
if (contract === undefined) {
|
|
69
|
+
throw new Error(`Missing required extension contract: ${name}`);
|
|
70
|
+
}
|
|
71
|
+
return contract;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
logger.warn("Failed to register built-in CSSProcessor extension", {
|
|
77
|
+
error: error instanceof Error ? error.message : String(error),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return tryResolveContract("CSSProcessor");
|
|
81
|
+
}
|
|
54
82
|
function evictOldestCompiler() {
|
|
55
83
|
if (compilerCache.size < MAX_CACHED_COMPILERS)
|
|
56
84
|
return;
|
|
@@ -79,7 +107,7 @@ export async function getCompiler(stylesheet, projectSlug) {
|
|
|
79
107
|
return cached.compiler;
|
|
80
108
|
}
|
|
81
109
|
logger.debug("Creating new compiler", { hash, projectSlug });
|
|
82
|
-
const processor =
|
|
110
|
+
const processor = await resolveCSSProcessor();
|
|
83
111
|
if (!processor) {
|
|
84
112
|
logger.warn("No CSSProcessor extension registered — CSS output will be empty. Install it with: deno add @veryfront/ext-tailwind");
|
|
85
113
|
const noopCompiler = { build: () => "" };
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export { getAnthropicMessagesUrl, getGoogleEmbeddingUrl, getGoogleGenerateContentUrl, getGoogleStreamGenerateContentUrl, getOpenAIChatCompletionsUrl, getOpenAIEmbeddingUrl, getOpenAIResponsesUrl, } from "../runtime-loader/provider-endpoints.js";
|
|
12
|
+
export { createAnthropicRequestInit, createGoogleRequestInit, createOpenAIRequestInit, } from "../runtime-loader/provider-request-init.js";
|
|
13
|
+
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions, } from "../runtime-loader/tool-input-status.js";
|
|
14
|
+
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, } from "../runtime-loader.js";
|
|
15
|
+
export type { OpenAICompatibleChatMessage, OpenAICompatibleChatRequest, RuntimePromptMessage, } from "../runtime-loader.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,iCAAiC,EACjC,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
// URL builders
|
|
12
|
+
export { getAnthropicMessagesUrl, getGoogleEmbeddingUrl, getGoogleGenerateContentUrl, getGoogleStreamGenerateContentUrl, getOpenAIChatCompletionsUrl, getOpenAIEmbeddingUrl, getOpenAIResponsesUrl, } from "../runtime-loader/provider-endpoints.js";
|
|
13
|
+
// Request init builders
|
|
14
|
+
export { createAnthropicRequestInit, createGoogleRequestInit, createOpenAIRequestInit, } from "../runtime-loader/provider-request-init.js";
|
|
15
|
+
// Tool-input status transitions
|
|
16
|
+
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions, } from "../runtime-loader/tool-input-status.js";
|
|
17
|
+
// Retry / error / HTTP plumbing (currently in runtime-loader.ts).
|
|
18
|
+
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, } from "../runtime-loader.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EmbeddingRuntime, ModelRuntime } from "../types.js";
|
|
2
|
+
interface VeryfrontCloudOpenAIConfig {
|
|
3
|
+
apiToken: string;
|
|
4
|
+
baseURL: string;
|
|
5
|
+
fetch: typeof globalThis.fetch;
|
|
6
|
+
}
|
|
7
|
+
export declare function createVeryfrontCloudOpenAIModel(modelId: string, config: VeryfrontCloudOpenAIConfig): ModelRuntime;
|
|
8
|
+
export declare function createVeryfrontCloudOpenAIEmbeddingModel(modelId: string, config: VeryfrontCloudOpenAIConfig): EmbeddingRuntime;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/veryfront-cloud/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKlE,UAAU,0BAA0B;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAChC;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,0BAA0B,GACjC,YAAY,CAOd;AAED,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,0BAA0B,GACjC,gBAAgB,CAOlB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OpenAIProvider } from "../../../extensions/ext-openai/src/openai-provider.js";
|
|
2
|
+
const openAIProvider = new OpenAIProvider();
|
|
3
|
+
export function createVeryfrontCloudOpenAIModel(modelId, config) {
|
|
4
|
+
return openAIProvider.createModel(modelId, {
|
|
5
|
+
credential: config.apiToken,
|
|
6
|
+
baseURL: config.baseURL,
|
|
7
|
+
name: "veryfront-cloud",
|
|
8
|
+
fetch: config.fetch,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function createVeryfrontCloudOpenAIEmbeddingModel(modelId, config) {
|
|
12
|
+
return openAIProvider.createEmbedding(modelId, {
|
|
13
|
+
credential: config.apiToken,
|
|
14
|
+
baseURL: config.baseURL,
|
|
15
|
+
name: "veryfront-cloud",
|
|
16
|
+
fetch: config.fetch,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAShD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAmEvE"}
|
|
@@ -3,6 +3,7 @@ import { createAnthropicModelRuntime, createGoogleModelRuntime } from "../runtim
|
|
|
3
3
|
import { tryResolve } from "../../extensions/contracts.js";
|
|
4
4
|
import { AIProviderRegistryName } from "../../extensions/interfaces/index.js";
|
|
5
5
|
import { createVeryfrontCloudFetch, getVeryfrontCloudGatewayBaseUrl, parseVeryfrontCloudModelId, requireVeryfrontCloudBootstrap, } from "./shared.js";
|
|
6
|
+
import { createVeryfrontCloudOpenAIModel } from "./openai.js";
|
|
6
7
|
export function createVeryfrontCloudModel(modelId) {
|
|
7
8
|
const { provider, modelId: upstreamModelId } = parseVeryfrontCloudModelId(modelId, "language");
|
|
8
9
|
const { apiBaseUrl, apiToken, projectSlug } = requireVeryfrontCloudBootstrap();
|
|
@@ -50,7 +51,11 @@ export function createVeryfrontCloudModel(modelId) {
|
|
|
50
51
|
fetch,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
return createVeryfrontCloudOpenAIModel(upstreamModelId, {
|
|
55
|
+
apiToken,
|
|
56
|
+
baseURL,
|
|
57
|
+
fetch,
|
|
58
|
+
});
|
|
54
59
|
}
|
|
55
60
|
default: {
|
|
56
61
|
const _exhaustive = provider;
|
package/esm/src/proxy/main.js
CHANGED
|
@@ -23,6 +23,8 @@ import * as dntShim from "../../_dnt.shims.js";
|
|
|
23
23
|
import { createProxyHandler, INTERNAL_PROXY_HEADERS } from "./handler.js";
|
|
24
24
|
import { createCacheFromEnv } from "./cache/index.js";
|
|
25
25
|
import { isRetryableConnectionError } from "./retry.js";
|
|
26
|
+
import { register } from "../extensions/contracts.js";
|
|
27
|
+
import { createAuthProvider } from "../../extensions/ext-jwt/src/index.js";
|
|
26
28
|
import { endSpan, extractContext, initializeOTLPWithApis, injectContext, ProxySpanNames, shutdownOTLP, startServerSpan, withContext, withSpan, } from "./tracing.js";
|
|
27
29
|
import { proxyLogger, runWithProxyRequestContext } from "./logger.js";
|
|
28
30
|
import { getProxyFailureLogLevel } from "./log-noise.js";
|
|
@@ -80,6 +82,7 @@ const DEFAULT_SERVER_RETRY_COUNT = 1;
|
|
|
80
82
|
const DEFAULT_SERVER_RETRY_DELAY_MS = 100;
|
|
81
83
|
const VERYFRONT_SERVER_RETRY_COUNT = parseInt(getEnv("VERYFRONT_SERVER_RETRY_COUNT") || String(DEFAULT_SERVER_RETRY_COUNT));
|
|
82
84
|
const VERYFRONT_SERVER_RETRY_DELAY_MS = parseInt(getEnv("VERYFRONT_SERVER_RETRY_DELAY_MS") || String(DEFAULT_SERVER_RETRY_DELAY_MS));
|
|
85
|
+
register("AuthProvider", createAuthProvider({}));
|
|
83
86
|
// Initialize cache and proxy handler
|
|
84
87
|
const cache = await createCacheFromEnv();
|
|
85
88
|
const proxyHandler = createProxyHandler({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.322";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.322",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -225,6 +225,7 @@
|
|
|
225
225
|
"esbuild": "0.27.4",
|
|
226
226
|
"github-slugger": "2.0.0",
|
|
227
227
|
"gray-matter": "4.0.3",
|
|
228
|
+
"jose": "5.9.6",
|
|
228
229
|
"mdast-util-to-string": "4.0.0",
|
|
229
230
|
"react": "19.2.4",
|
|
230
231
|
"react-dom": "19.2.4",
|
|
@@ -239,6 +240,7 @@
|
|
|
239
240
|
"remark-parse": "11.0.0",
|
|
240
241
|
"remark-rehype": "11.1.2",
|
|
241
242
|
"tailwind-merge": "3.5.0",
|
|
243
|
+
"tailwindcss": "4.2.2",
|
|
242
244
|
"unified": "11.0.5",
|
|
243
245
|
"unist-util-visit": "5.1.0",
|
|
244
246
|
"vfile": "6.0.3",
|
package/src/deno.js
CHANGED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-jwt — AuthProvider implementation backed by `jose`.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `AuthProvider` contract: sign / verify (HS256 by default),
|
|
5
|
+
* verify-with-remote-JWKS, and decode-header.
|
|
6
|
+
*
|
|
7
|
+
* @module extensions/ext-jwt
|
|
8
|
+
*/
|
|
9
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
createRemoteJWKSet,
|
|
14
|
+
decodeProtectedHeader,
|
|
15
|
+
type JWTPayload,
|
|
16
|
+
jwtVerify,
|
|
17
|
+
type KeyLike,
|
|
18
|
+
SignJWT,
|
|
19
|
+
} from "jose";
|
|
20
|
+
|
|
21
|
+
import type { ExtensionFactory } from "../../../src/extensions/index.js";
|
|
22
|
+
import type {
|
|
23
|
+
AuthProvider,
|
|
24
|
+
SignOptions,
|
|
25
|
+
TokenHeader,
|
|
26
|
+
TokenPayload,
|
|
27
|
+
VerifyOptions,
|
|
28
|
+
} from "../../../src/extensions/interfaces/index.js";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Signature used by jose's verify step to resolve a key for a given header.
|
|
32
|
+
*
|
|
33
|
+
* Matches the shape returned by `createRemoteJWKSet` / `createLocalJWKSet`
|
|
34
|
+
* and lets tests inject an in-memory key set without reaching the network.
|
|
35
|
+
*/
|
|
36
|
+
export type JwksResolver = Parameters<typeof jwtVerify>[1] & object;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Factory for building a JWKS resolver from a URL.
|
|
40
|
+
*
|
|
41
|
+
* The default uses `createRemoteJWKSet`; tests can inject a stub that returns
|
|
42
|
+
* a local resolver bound to an in-memory key set.
|
|
43
|
+
*/
|
|
44
|
+
export type JwksResolverFactory = (jwksUrl: string) => JwksResolver;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional configuration for the ext-jwt factory.
|
|
48
|
+
*
|
|
49
|
+
* - `secret`: HMAC secret for `sign`/`verify`. Falls back to the `JWT_SECRET`
|
|
50
|
+
* environment variable. Without one, `sign`/`verify` throw.
|
|
51
|
+
* - `jwksResolverFactory`: test seam that overrides JWKS resolution.
|
|
52
|
+
*/
|
|
53
|
+
export interface ExtJwtConfig {
|
|
54
|
+
secret?: string | Uint8Array;
|
|
55
|
+
jwksResolverFactory?: JwksResolverFactory;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function defaultJwksResolverFactory(jwksUrl: string): JwksResolver {
|
|
59
|
+
return createRemoteJWKSet(new URL(jwksUrl)) as unknown as JwksResolver;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function toUint8Array(secret: string | Uint8Array): Uint8Array {
|
|
63
|
+
return typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getSecret(configSecret?: string | Uint8Array): Uint8Array {
|
|
67
|
+
if (configSecret !== undefined) return toUint8Array(configSecret);
|
|
68
|
+
const env = typeof dntShim.Deno !== "undefined" ? dntShim.Deno.env.get("JWT_SECRET") : undefined;
|
|
69
|
+
if (!env) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
"ext-jwt: no HMAC secret configured. Pass `secret` to the extension " +
|
|
72
|
+
"factory or set the JWT_SECRET environment variable.",
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return new TextEncoder().encode(env);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createAuthProvider(config: ExtJwtConfig): AuthProvider {
|
|
79
|
+
const jwksResolverFactory = config.jwksResolverFactory ??
|
|
80
|
+
defaultJwksResolverFactory;
|
|
81
|
+
|
|
82
|
+
// Cache one resolver per JWKS URL; `createRemoteJWKSet` maintains its own
|
|
83
|
+
// internal key cache with cooldown/rotation semantics, so reusing the
|
|
84
|
+
// same resolver is required for the cache to be effective.
|
|
85
|
+
const jwksResolvers = new Map<string, JwksResolver>();
|
|
86
|
+
|
|
87
|
+
function getJwksResolver(jwksUrl: string): JwksResolver {
|
|
88
|
+
const existing = jwksResolvers.get(jwksUrl);
|
|
89
|
+
if (existing) return existing;
|
|
90
|
+
const created = jwksResolverFactory(jwksUrl);
|
|
91
|
+
jwksResolvers.set(jwksUrl, created);
|
|
92
|
+
return created;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
async sign(payload: TokenPayload, options?: SignOptions): Promise<string> {
|
|
97
|
+
const secret = getSecret(config.secret);
|
|
98
|
+
const algorithm = options?.algorithm ?? "HS256";
|
|
99
|
+
const { sub, ...rest } = payload;
|
|
100
|
+
const builder = new SignJWT(rest as JWTPayload)
|
|
101
|
+
.setProtectedHeader({ alg: algorithm })
|
|
102
|
+
.setSubject(sub);
|
|
103
|
+
if (options?.expiresIn !== undefined) {
|
|
104
|
+
// jose's setExpirationTime accepts `string | number | Date`.
|
|
105
|
+
builder.setExpirationTime(
|
|
106
|
+
options.expiresIn as string | number,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return await builder.sign(secret);
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
async verify(
|
|
113
|
+
token: string,
|
|
114
|
+
options?: VerifyOptions,
|
|
115
|
+
): Promise<TokenPayload> {
|
|
116
|
+
const secret = getSecret(config.secret);
|
|
117
|
+
const algorithms = options?.algorithms ?? ["HS256"];
|
|
118
|
+
const { payload } = await jwtVerify(token, secret, { algorithms });
|
|
119
|
+
return payload as TokenPayload;
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
async verifyWithJwks(
|
|
123
|
+
token: string,
|
|
124
|
+
jwksUrl: string,
|
|
125
|
+
options?: VerifyOptions,
|
|
126
|
+
): Promise<TokenPayload> {
|
|
127
|
+
const resolver = getJwksResolver(jwksUrl);
|
|
128
|
+
const { algorithms, ...rest } = options ?? {};
|
|
129
|
+
const verifyOpts: Record<string, unknown> = { ...rest };
|
|
130
|
+
if (algorithms) verifyOpts.algorithms = algorithms;
|
|
131
|
+
const { payload } = await jwtVerify(
|
|
132
|
+
token,
|
|
133
|
+
resolver as unknown as KeyLike,
|
|
134
|
+
verifyOpts,
|
|
135
|
+
);
|
|
136
|
+
return payload as TokenPayload;
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
decode(token: string): TokenHeader | undefined {
|
|
140
|
+
try {
|
|
141
|
+
return decodeProtectedHeader(token) as TokenHeader;
|
|
142
|
+
} catch {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Default export — the ext-jwt extension factory.
|
|
151
|
+
*
|
|
152
|
+
* Produces an extension that registers an `AuthProvider` contract
|
|
153
|
+
* implementation backed by `jose`.
|
|
154
|
+
*/
|
|
155
|
+
const extJwt: ExtensionFactory = (config?: unknown) => {
|
|
156
|
+
const cfg = (config ?? {}) as ExtJwtConfig;
|
|
157
|
+
const provider = createAuthProvider(cfg);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
name: "ext-jwt",
|
|
161
|
+
version: "0.1.0",
|
|
162
|
+
capabilities: [
|
|
163
|
+
{ type: "contract", name: "AuthProvider" },
|
|
164
|
+
{ type: "network", host: "*" },
|
|
165
|
+
],
|
|
166
|
+
provides: {
|
|
167
|
+
AuthProvider: provider,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default extJwt;
|
|
173
|
+
export { createAuthProvider };
|