veryfront 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +500 -223
- package/dist/ai/index.js.map +4 -4
- package/dist/ai/react.js +1 -3
- package/dist/ai/react.js.map +2 -2
- package/dist/cli.js +1204 -3049
- package/dist/components.js +395 -260
- package/dist/components.js.map +4 -4
- package/dist/config.js +289 -10
- package/dist/config.js.map +4 -4
- package/dist/data.js +105 -12
- package/dist/data.js.map +3 -3
- package/dist/index.js +398 -258
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -1672,60 +1672,18 @@ var SERVER_ACTION_DEFAULT_TTL_SEC = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;
|
|
|
1672
1672
|
var ONE_DAY_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
1673
1673
|
var LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;
|
|
1674
1674
|
|
|
1675
|
-
// src/core/utils/constants/cdn.ts
|
|
1676
|
-
var ESM_CDN_BASE = "https://esm.sh";
|
|
1677
|
-
var REACT_VERSION_18_3 = "18.3.1";
|
|
1678
|
-
var REACT_DEFAULT_VERSION = REACT_VERSION_18_3;
|
|
1679
|
-
function getReactCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1680
|
-
return `${ESM_CDN_BASE}/react@${version}`;
|
|
1681
|
-
}
|
|
1682
|
-
function getReactDOMCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1683
|
-
return `${ESM_CDN_BASE}/react-dom@${version}`;
|
|
1684
|
-
}
|
|
1685
|
-
function getReactDOMClientCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1686
|
-
return `${ESM_CDN_BASE}/react-dom@${version}/client`;
|
|
1687
|
-
}
|
|
1688
|
-
function getReactDOMServerCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1689
|
-
return `${ESM_CDN_BASE}/react-dom@${version}/server`;
|
|
1690
|
-
}
|
|
1691
|
-
function getReactJSXRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1692
|
-
return `${ESM_CDN_BASE}/react@${version}/jsx-runtime`;
|
|
1693
|
-
}
|
|
1694
|
-
function getReactJSXDevRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1695
|
-
return `${ESM_CDN_BASE}/react@${version}/jsx-dev-runtime`;
|
|
1696
|
-
}
|
|
1697
|
-
function getReactImportMap(version = REACT_DEFAULT_VERSION) {
|
|
1698
|
-
return {
|
|
1699
|
-
react: getReactCDNUrl(version),
|
|
1700
|
-
"react-dom": getReactDOMCDNUrl(version),
|
|
1701
|
-
"react-dom/client": getReactDOMClientCDNUrl(version),
|
|
1702
|
-
"react-dom/server": getReactDOMServerCDNUrl(version),
|
|
1703
|
-
"react/jsx-runtime": getReactJSXRuntimeCDNUrl(version),
|
|
1704
|
-
"react/jsx-dev-runtime": getReactJSXDevRuntimeCDNUrl(version)
|
|
1705
|
-
};
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
// src/core/utils/constants/http.ts
|
|
1709
|
-
var KB_IN_BYTES = 1024;
|
|
1710
|
-
var PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;
|
|
1711
|
-
|
|
1712
|
-
// src/core/utils/constants/hmr.ts
|
|
1713
|
-
var HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;
|
|
1714
|
-
|
|
1715
|
-
// src/core/utils/constants/network.ts
|
|
1716
|
-
var BYTES_PER_MB = 1024 * 1024;
|
|
1717
|
-
|
|
1718
1675
|
// deno.json
|
|
1719
1676
|
var deno_default = {
|
|
1720
1677
|
name: "veryfront",
|
|
1721
|
-
version: "0.0.
|
|
1678
|
+
version: "0.0.36",
|
|
1722
1679
|
exclude: [
|
|
1723
1680
|
"npm/",
|
|
1724
1681
|
"dist/",
|
|
1725
1682
|
"coverage/",
|
|
1726
1683
|
"scripts/",
|
|
1727
1684
|
"examples/",
|
|
1728
|
-
"tests/"
|
|
1685
|
+
"tests/",
|
|
1686
|
+
"src/cli/templates/files/"
|
|
1729
1687
|
],
|
|
1730
1688
|
exports: {
|
|
1731
1689
|
".": "./src/index.ts",
|
|
@@ -1735,6 +1693,7 @@ var deno_default = {
|
|
|
1735
1693
|
"./components": "./src/react/components/index.ts",
|
|
1736
1694
|
"./data": "./src/data/index.ts",
|
|
1737
1695
|
"./config": "./src/core/config/index.ts",
|
|
1696
|
+
"./platform": "./src/platform/index.ts",
|
|
1738
1697
|
"./ai": "./src/ai/index.ts",
|
|
1739
1698
|
"./ai/client": "./src/ai/client.ts",
|
|
1740
1699
|
"./ai/react": "./src/ai/react/index.ts",
|
|
@@ -1914,6 +1873,140 @@ var deno_default = {
|
|
|
1914
1873
|
// src/core/utils/version.ts
|
|
1915
1874
|
var VERSION = getEnv("VERYFRONT_VERSION") || (typeof deno_default.version === "string" ? deno_default.version : "0.0.0");
|
|
1916
1875
|
|
|
1876
|
+
// src/core/utils/constants/cdn.ts
|
|
1877
|
+
var ESM_CDN_BASE = "https://esm.sh";
|
|
1878
|
+
var REACT_VERSION_18_3 = "18.3.1";
|
|
1879
|
+
var REACT_DEFAULT_VERSION = REACT_VERSION_18_3;
|
|
1880
|
+
function getReactCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1881
|
+
return `${ESM_CDN_BASE}/react@${version}`;
|
|
1882
|
+
}
|
|
1883
|
+
function getReactDOMCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1884
|
+
return `${ESM_CDN_BASE}/react-dom@${version}`;
|
|
1885
|
+
}
|
|
1886
|
+
function getReactDOMClientCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1887
|
+
return `${ESM_CDN_BASE}/react-dom@${version}/client`;
|
|
1888
|
+
}
|
|
1889
|
+
function getReactDOMServerCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1890
|
+
return `${ESM_CDN_BASE}/react-dom@${version}/server`;
|
|
1891
|
+
}
|
|
1892
|
+
function getReactJSXRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1893
|
+
return `${ESM_CDN_BASE}/react@${version}/jsx-runtime`;
|
|
1894
|
+
}
|
|
1895
|
+
function getReactJSXDevRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
|
|
1896
|
+
return `${ESM_CDN_BASE}/react@${version}/jsx-dev-runtime`;
|
|
1897
|
+
}
|
|
1898
|
+
function getReactImportMap(version = REACT_DEFAULT_VERSION) {
|
|
1899
|
+
return {
|
|
1900
|
+
react: getReactCDNUrl(version),
|
|
1901
|
+
"react-dom": getReactDOMCDNUrl(version),
|
|
1902
|
+
"react-dom/client": getReactDOMClientCDNUrl(version),
|
|
1903
|
+
"react-dom/server": getReactDOMServerCDNUrl(version),
|
|
1904
|
+
"react/jsx-runtime": getReactJSXRuntimeCDNUrl(version),
|
|
1905
|
+
"react/jsx-dev-runtime": getReactJSXDevRuntimeCDNUrl(version)
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
// src/core/utils/constants/http.ts
|
|
1910
|
+
var KB_IN_BYTES = 1024;
|
|
1911
|
+
var PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;
|
|
1912
|
+
|
|
1913
|
+
// src/core/utils/constants/hmr.ts
|
|
1914
|
+
var HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;
|
|
1915
|
+
|
|
1916
|
+
// src/core/utils/constants/network.ts
|
|
1917
|
+
var BYTES_PER_MB = 1024 * 1024;
|
|
1918
|
+
|
|
1919
|
+
// src/core/utils/constants/server.ts
|
|
1920
|
+
var INTERNAL_PREFIX = "/_veryfront";
|
|
1921
|
+
var INTERNAL_PATH_PREFIXES = {
|
|
1922
|
+
/** React Server Components endpoints */
|
|
1923
|
+
RSC: `${INTERNAL_PREFIX}/rsc/`,
|
|
1924
|
+
/** File system access endpoints (base64 encoded paths) */
|
|
1925
|
+
FS: `${INTERNAL_PREFIX}/fs/`,
|
|
1926
|
+
/** Virtual module system */
|
|
1927
|
+
MODULES: `${INTERNAL_PREFIX}/modules/`,
|
|
1928
|
+
/** Generated page modules */
|
|
1929
|
+
PAGES: `${INTERNAL_PREFIX}/pages/`,
|
|
1930
|
+
/** Data JSON endpoints */
|
|
1931
|
+
DATA: `${INTERNAL_PREFIX}/data/`,
|
|
1932
|
+
/** Library modules (AI SDK, etc.) */
|
|
1933
|
+
LIB: `${INTERNAL_PREFIX}/lib/`,
|
|
1934
|
+
/** Chunk assets */
|
|
1935
|
+
CHUNKS: `${INTERNAL_PREFIX}/chunks/`,
|
|
1936
|
+
/** Client component modules */
|
|
1937
|
+
CLIENT: `${INTERNAL_PREFIX}/client/`
|
|
1938
|
+
};
|
|
1939
|
+
var INTERNAL_ENDPOINTS = {
|
|
1940
|
+
// Development endpoints
|
|
1941
|
+
HMR_RUNTIME: `${INTERNAL_PREFIX}/hmr-runtime.js`,
|
|
1942
|
+
HMR: `${INTERNAL_PREFIX}/hmr.js`,
|
|
1943
|
+
HYDRATE: `${INTERNAL_PREFIX}/hydrate.js`,
|
|
1944
|
+
ERROR_OVERLAY: `${INTERNAL_PREFIX}/error-overlay.js`,
|
|
1945
|
+
DEV_LOADER: `${INTERNAL_PREFIX}/dev-loader.js`,
|
|
1946
|
+
CLIENT_LOG: `${INTERNAL_PREFIX}/log`,
|
|
1947
|
+
// Production endpoints
|
|
1948
|
+
CLIENT_JS: `${INTERNAL_PREFIX}/client.js`,
|
|
1949
|
+
ROUTER_JS: `${INTERNAL_PREFIX}/router.js`,
|
|
1950
|
+
PREFETCH_JS: `${INTERNAL_PREFIX}/prefetch.js`,
|
|
1951
|
+
MANIFEST_JSON: `${INTERNAL_PREFIX}/manifest.json`,
|
|
1952
|
+
APP_JS: `${INTERNAL_PREFIX}/app.js`,
|
|
1953
|
+
// RSC endpoints
|
|
1954
|
+
RSC_CLIENT: `${INTERNAL_PREFIX}/rsc/client.js`,
|
|
1955
|
+
RSC_MANIFEST: `${INTERNAL_PREFIX}/rsc/manifest`,
|
|
1956
|
+
RSC_STREAM: `${INTERNAL_PREFIX}/rsc/stream`,
|
|
1957
|
+
RSC_PAYLOAD: `${INTERNAL_PREFIX}/rsc/payload`,
|
|
1958
|
+
RSC_RENDER: `${INTERNAL_PREFIX}/rsc/render`,
|
|
1959
|
+
RSC_PAGE: `${INTERNAL_PREFIX}/rsc/page`,
|
|
1960
|
+
RSC_MODULE: `${INTERNAL_PREFIX}/rsc/module`,
|
|
1961
|
+
RSC_DOM: `${INTERNAL_PREFIX}/rsc/dom.js`,
|
|
1962
|
+
RSC_HYDRATOR: `${INTERNAL_PREFIX}/rsc/hydrator.js`,
|
|
1963
|
+
RSC_HYDRATE_CLIENT: `${INTERNAL_PREFIX}/rsc/hydrate-client.js`,
|
|
1964
|
+
// Library module endpoints
|
|
1965
|
+
LIB_AI_REACT: `${INTERNAL_PREFIX}/lib/ai/react.js`,
|
|
1966
|
+
LIB_AI_COMPONENTS: `${INTERNAL_PREFIX}/lib/ai/components.js`,
|
|
1967
|
+
LIB_AI_PRIMITIVES: `${INTERNAL_PREFIX}/lib/ai/primitives.js`
|
|
1968
|
+
};
|
|
1969
|
+
var BUILD_DIRS = {
|
|
1970
|
+
/** Main build output directory */
|
|
1971
|
+
ROOT: "_veryfront",
|
|
1972
|
+
/** Chunks directory */
|
|
1973
|
+
CHUNKS: "_veryfront/chunks",
|
|
1974
|
+
/** Data directory */
|
|
1975
|
+
DATA: "_veryfront/data",
|
|
1976
|
+
/** Assets directory */
|
|
1977
|
+
ASSETS: "_veryfront/assets"
|
|
1978
|
+
};
|
|
1979
|
+
var PROJECT_DIRS = {
|
|
1980
|
+
/** Base veryfront internal directory */
|
|
1981
|
+
ROOT: ".veryfront",
|
|
1982
|
+
/** Cache directory for build artifacts, transforms, etc. */
|
|
1983
|
+
CACHE: ".veryfront/cache",
|
|
1984
|
+
/** KV store directory */
|
|
1985
|
+
KV: ".veryfront/kv",
|
|
1986
|
+
/** Log files directory */
|
|
1987
|
+
LOGS: ".veryfront/logs",
|
|
1988
|
+
/** Temporary files directory */
|
|
1989
|
+
TMP: ".veryfront/tmp"
|
|
1990
|
+
};
|
|
1991
|
+
var DEFAULT_CACHE_DIR = PROJECT_DIRS.CACHE;
|
|
1992
|
+
var DEV_SERVER_ENDPOINTS = {
|
|
1993
|
+
HMR_RUNTIME: INTERNAL_ENDPOINTS.HMR_RUNTIME,
|
|
1994
|
+
ERROR_OVERLAY: INTERNAL_ENDPOINTS.ERROR_OVERLAY
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
// src/core/utils/paths.ts
|
|
1998
|
+
var VERYFRONT_PATHS = {
|
|
1999
|
+
INTERNAL_PREFIX,
|
|
2000
|
+
BUILD_DIR: BUILD_DIRS.ROOT,
|
|
2001
|
+
CHUNKS_DIR: BUILD_DIRS.CHUNKS,
|
|
2002
|
+
DATA_DIR: BUILD_DIRS.DATA,
|
|
2003
|
+
ASSETS_DIR: BUILD_DIRS.ASSETS,
|
|
2004
|
+
HMR_RUNTIME: INTERNAL_ENDPOINTS.HMR_RUNTIME,
|
|
2005
|
+
CLIENT_JS: INTERNAL_ENDPOINTS.CLIENT_JS,
|
|
2006
|
+
ROUTER_JS: INTERNAL_ENDPOINTS.ROUTER_JS,
|
|
2007
|
+
ERROR_OVERLAY: INTERNAL_ENDPOINTS.ERROR_OVERLAY
|
|
2008
|
+
};
|
|
2009
|
+
|
|
1917
2010
|
// src/core/utils/bundle-manifest.ts
|
|
1918
2011
|
var InMemoryBundleManifestStore = class {
|
|
1919
2012
|
constructor() {
|
|
@@ -3638,7 +3731,7 @@ var DEFAULT_CONFIG2 = {
|
|
|
3638
3731
|
}
|
|
3639
3732
|
},
|
|
3640
3733
|
cache: {
|
|
3641
|
-
dir:
|
|
3734
|
+
dir: DEFAULT_CACHE_DIR,
|
|
3642
3735
|
render: {
|
|
3643
3736
|
type: "memory",
|
|
3644
3737
|
ttl: void 0,
|
|
@@ -3957,7 +4050,362 @@ function createMockAdapter() {
|
|
|
3957
4050
|
};
|
|
3958
4051
|
}
|
|
3959
4052
|
|
|
4053
|
+
// src/platform/compat/fs.ts
|
|
4054
|
+
var NodeFileSystem = class {
|
|
4055
|
+
constructor() {
|
|
4056
|
+
this.fs = null;
|
|
4057
|
+
this.os = null;
|
|
4058
|
+
this.path = null;
|
|
4059
|
+
this.initialized = false;
|
|
4060
|
+
}
|
|
4061
|
+
async ensureInitialized() {
|
|
4062
|
+
if (this.initialized)
|
|
4063
|
+
return;
|
|
4064
|
+
if (!isNode) {
|
|
4065
|
+
throw toError(createError({
|
|
4066
|
+
type: "not_supported",
|
|
4067
|
+
message: "Node.js fs modules not available",
|
|
4068
|
+
feature: "Node.js"
|
|
4069
|
+
}));
|
|
4070
|
+
}
|
|
4071
|
+
const [fsModule, osModule, pathModule] = await Promise.all([
|
|
4072
|
+
import("node:fs/promises"),
|
|
4073
|
+
import("node:os"),
|
|
4074
|
+
import("node:path")
|
|
4075
|
+
]);
|
|
4076
|
+
this.fs = fsModule;
|
|
4077
|
+
this.os = osModule;
|
|
4078
|
+
this.path = pathModule;
|
|
4079
|
+
this.initialized = true;
|
|
4080
|
+
}
|
|
4081
|
+
async readTextFile(path) {
|
|
4082
|
+
await this.ensureInitialized();
|
|
4083
|
+
return await this.fs.readFile(path, { encoding: "utf8" });
|
|
4084
|
+
}
|
|
4085
|
+
async readFile(path) {
|
|
4086
|
+
await this.ensureInitialized();
|
|
4087
|
+
return await this.fs.readFile(path);
|
|
4088
|
+
}
|
|
4089
|
+
async writeTextFile(path, data) {
|
|
4090
|
+
await this.ensureInitialized();
|
|
4091
|
+
await this.fs.writeFile(path, data, { encoding: "utf8" });
|
|
4092
|
+
}
|
|
4093
|
+
async writeFile(path, data) {
|
|
4094
|
+
await this.ensureInitialized();
|
|
4095
|
+
await this.fs.writeFile(path, data);
|
|
4096
|
+
}
|
|
4097
|
+
async exists(path) {
|
|
4098
|
+
await this.ensureInitialized();
|
|
4099
|
+
try {
|
|
4100
|
+
await this.fs.access(path);
|
|
4101
|
+
return true;
|
|
4102
|
+
} catch (error) {
|
|
4103
|
+
if (error.code === "ENOENT") {
|
|
4104
|
+
return false;
|
|
4105
|
+
}
|
|
4106
|
+
throw error;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
async stat(path) {
|
|
4110
|
+
await this.ensureInitialized();
|
|
4111
|
+
const stat = await this.fs.stat(path);
|
|
4112
|
+
return {
|
|
4113
|
+
isFile: stat.isFile(),
|
|
4114
|
+
isDirectory: stat.isDirectory(),
|
|
4115
|
+
isSymlink: stat.isSymbolicLink(),
|
|
4116
|
+
size: stat.size,
|
|
4117
|
+
mtime: stat.mtime
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4120
|
+
async mkdir(path, options) {
|
|
4121
|
+
await this.ensureInitialized();
|
|
4122
|
+
await this.fs.mkdir(path, { recursive: options?.recursive ?? false });
|
|
4123
|
+
}
|
|
4124
|
+
async *readDir(path) {
|
|
4125
|
+
await this.ensureInitialized();
|
|
4126
|
+
const entries = await this.fs.readdir(path, { withFileTypes: true });
|
|
4127
|
+
for (const entry of entries) {
|
|
4128
|
+
yield {
|
|
4129
|
+
name: entry.name,
|
|
4130
|
+
isFile: entry.isFile(),
|
|
4131
|
+
isDirectory: entry.isDirectory()
|
|
4132
|
+
};
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
async remove(path, options) {
|
|
4136
|
+
await this.ensureInitialized();
|
|
4137
|
+
await this.fs.rm(path, {
|
|
4138
|
+
recursive: options?.recursive ?? false,
|
|
4139
|
+
force: options?.recursive ?? false
|
|
4140
|
+
});
|
|
4141
|
+
}
|
|
4142
|
+
async makeTempDir(options) {
|
|
4143
|
+
await this.ensureInitialized();
|
|
4144
|
+
const tempDir = this.path.join(
|
|
4145
|
+
this.os.tmpdir(),
|
|
4146
|
+
`${options?.prefix ?? "tmp-"}${Math.random().toString(36).substring(2, 8)}`
|
|
4147
|
+
);
|
|
4148
|
+
await this.fs.mkdir(tempDir, { recursive: true });
|
|
4149
|
+
return tempDir;
|
|
4150
|
+
}
|
|
4151
|
+
};
|
|
4152
|
+
var DenoFileSystem = class {
|
|
4153
|
+
async readTextFile(path) {
|
|
4154
|
+
return await Deno.readTextFile(path);
|
|
4155
|
+
}
|
|
4156
|
+
async readFile(path) {
|
|
4157
|
+
return await Deno.readFile(path);
|
|
4158
|
+
}
|
|
4159
|
+
async writeTextFile(path, data) {
|
|
4160
|
+
await Deno.writeTextFile(path, data);
|
|
4161
|
+
}
|
|
4162
|
+
async writeFile(path, data) {
|
|
4163
|
+
await Deno.writeFile(path, data);
|
|
4164
|
+
}
|
|
4165
|
+
async exists(path) {
|
|
4166
|
+
try {
|
|
4167
|
+
await Deno.stat(path);
|
|
4168
|
+
return true;
|
|
4169
|
+
} catch (error) {
|
|
4170
|
+
if (error instanceof Deno.errors.NotFound) {
|
|
4171
|
+
return false;
|
|
4172
|
+
}
|
|
4173
|
+
throw error;
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
async stat(path) {
|
|
4177
|
+
const stat = await Deno.stat(path);
|
|
4178
|
+
return {
|
|
4179
|
+
isFile: stat.isFile,
|
|
4180
|
+
isDirectory: stat.isDirectory,
|
|
4181
|
+
isSymlink: stat.isSymlink,
|
|
4182
|
+
size: stat.size,
|
|
4183
|
+
mtime: stat.mtime
|
|
4184
|
+
};
|
|
4185
|
+
}
|
|
4186
|
+
async mkdir(path, options) {
|
|
4187
|
+
await Deno.mkdir(path, { recursive: options?.recursive ?? false });
|
|
4188
|
+
}
|
|
4189
|
+
async *readDir(path) {
|
|
4190
|
+
for await (const entry of Deno.readDir(path)) {
|
|
4191
|
+
yield {
|
|
4192
|
+
name: entry.name,
|
|
4193
|
+
isFile: entry.isFile,
|
|
4194
|
+
isDirectory: entry.isDirectory
|
|
4195
|
+
};
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
async remove(path, options) {
|
|
4199
|
+
await Deno.remove(path, { recursive: options?.recursive ?? false });
|
|
4200
|
+
}
|
|
4201
|
+
async makeTempDir(options) {
|
|
4202
|
+
return await Deno.makeTempDir({ prefix: options?.prefix });
|
|
4203
|
+
}
|
|
4204
|
+
};
|
|
4205
|
+
function createFileSystem() {
|
|
4206
|
+
if (isDeno) {
|
|
4207
|
+
return new DenoFileSystem();
|
|
4208
|
+
} else {
|
|
4209
|
+
return new NodeFileSystem();
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
|
|
4213
|
+
// src/platform/compat/path-helper.ts
|
|
4214
|
+
import nodePath from "node:path";
|
|
4215
|
+
var pathMod = null;
|
|
4216
|
+
if (typeof Deno === "undefined") {
|
|
4217
|
+
pathMod = nodePath;
|
|
4218
|
+
} else {
|
|
4219
|
+
import("node:path").then((mod) => {
|
|
4220
|
+
pathMod = mod;
|
|
4221
|
+
});
|
|
4222
|
+
}
|
|
4223
|
+
function getPathMod() {
|
|
4224
|
+
if (pathMod)
|
|
4225
|
+
return pathMod;
|
|
4226
|
+
return nodePath;
|
|
4227
|
+
}
|
|
4228
|
+
var dirname = (path) => getPathMod().dirname(path);
|
|
4229
|
+
var join2 = (...paths) => getPathMod().join(...paths);
|
|
4230
|
+
var sep = nodePath.sep;
|
|
4231
|
+
|
|
3960
4232
|
// src/ai/utils/discovery.ts
|
|
4233
|
+
var transpileCache = /* @__PURE__ */ new Map();
|
|
4234
|
+
async function importModule(file, context) {
|
|
4235
|
+
const cacheKey = file;
|
|
4236
|
+
if (transpileCache.has(cacheKey)) {
|
|
4237
|
+
return transpileCache.get(cacheKey);
|
|
4238
|
+
}
|
|
4239
|
+
const fs2 = createFileSystem();
|
|
4240
|
+
const filePath = file.replace("file://", "");
|
|
4241
|
+
let source;
|
|
4242
|
+
try {
|
|
4243
|
+
source = await fs2.readTextFile(filePath);
|
|
4244
|
+
} catch (error) {
|
|
4245
|
+
throw new Error(`Failed to read file ${filePath}: ${error}`);
|
|
4246
|
+
}
|
|
4247
|
+
const isTsx = filePath.endsWith(".tsx");
|
|
4248
|
+
const isJsx = filePath.endsWith(".jsx");
|
|
4249
|
+
const loader = isTsx ? "tsx" : isJsx ? "jsx" : filePath.endsWith(".ts") ? "ts" : "js";
|
|
4250
|
+
const { build } = await import("esbuild");
|
|
4251
|
+
const result = await build({
|
|
4252
|
+
bundle: true,
|
|
4253
|
+
write: false,
|
|
4254
|
+
format: "esm",
|
|
4255
|
+
platform: "neutral",
|
|
4256
|
+
target: "es2022",
|
|
4257
|
+
jsx: "automatic",
|
|
4258
|
+
jsxImportSource: "react",
|
|
4259
|
+
resolveExtensions: [".ts", ".tsx", ".js", ".jsx", ".mjs"],
|
|
4260
|
+
external: [
|
|
4261
|
+
"ai",
|
|
4262
|
+
"ai/*",
|
|
4263
|
+
"@ai-sdk/*",
|
|
4264
|
+
"zod",
|
|
4265
|
+
"node:*",
|
|
4266
|
+
"veryfront",
|
|
4267
|
+
"veryfront/*",
|
|
4268
|
+
"@opentelemetry/*",
|
|
4269
|
+
"path"
|
|
4270
|
+
],
|
|
4271
|
+
stdin: {
|
|
4272
|
+
contents: source,
|
|
4273
|
+
loader,
|
|
4274
|
+
resolveDir: dirname(filePath),
|
|
4275
|
+
sourcefile: filePath
|
|
4276
|
+
}
|
|
4277
|
+
});
|
|
4278
|
+
if (result.errors && result.errors.length > 0) {
|
|
4279
|
+
const first = result.errors[0]?.text || "unknown error";
|
|
4280
|
+
throw new Error(`Failed to transpile ${filePath}: ${first}`);
|
|
4281
|
+
}
|
|
4282
|
+
const js = result.outputFiles?.[0]?.text ?? "export {}";
|
|
4283
|
+
const tempDir = await fs2.makeTempDir({ prefix: "vf-discovery-" });
|
|
4284
|
+
const tempFile = join2(tempDir, "module.mjs");
|
|
4285
|
+
let transformedCode;
|
|
4286
|
+
if (isDeno) {
|
|
4287
|
+
transformedCode = rewriteForDeno(js);
|
|
4288
|
+
} else {
|
|
4289
|
+
transformedCode = await rewriteDiscoveryImports(js, context.baseDir || ".", fs2);
|
|
4290
|
+
}
|
|
4291
|
+
await fs2.writeTextFile(tempFile, transformedCode);
|
|
4292
|
+
try {
|
|
4293
|
+
const module = await import(`file://${tempFile}?v=${Date.now()}`);
|
|
4294
|
+
transpileCache.set(cacheKey, module);
|
|
4295
|
+
return module;
|
|
4296
|
+
} finally {
|
|
4297
|
+
await fs2.remove(tempDir, { recursive: true });
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
function rewriteForDeno(code) {
|
|
4301
|
+
let transformed = code;
|
|
4302
|
+
const npmPackages = [
|
|
4303
|
+
{ pattern: /from\s+["']ai["']/g, replacement: 'from "npm:ai"' },
|
|
4304
|
+
{ pattern: /from\s+["']ai\/([^"']+)["']/g, replacement: 'from "npm:ai/$1"' },
|
|
4305
|
+
{ pattern: /from\s+["']@ai-sdk\/([^"']+)["']/g, replacement: 'from "npm:@ai-sdk/$1"' },
|
|
4306
|
+
{ pattern: /from\s+["']zod["']/g, replacement: 'from "npm:zod"' },
|
|
4307
|
+
{ pattern: /import\s*\(\s*["']ai["']\s*\)/g, replacement: 'import("npm:ai")' },
|
|
4308
|
+
{ pattern: /import\s*\(\s*["']zod["']\s*\)/g, replacement: 'import("npm:zod")' }
|
|
4309
|
+
];
|
|
4310
|
+
for (const { pattern, replacement } of npmPackages) {
|
|
4311
|
+
transformed = transformed.replace(pattern, replacement);
|
|
4312
|
+
}
|
|
4313
|
+
return transformed;
|
|
4314
|
+
}
|
|
4315
|
+
async function rewriteDiscoveryImports(code, projectDir, fs2) {
|
|
4316
|
+
let transformed = code;
|
|
4317
|
+
try {
|
|
4318
|
+
const { pathToFileURL } = await import("node:url");
|
|
4319
|
+
const resolvePackageToFileUrl = async (packageName) => {
|
|
4320
|
+
const packagePath = join2(projectDir, "node_modules", packageName);
|
|
4321
|
+
const packageJsonPath = join2(packagePath, "package.json");
|
|
4322
|
+
try {
|
|
4323
|
+
const pkgJson = JSON.parse(await fs2.readTextFile(packageJsonPath));
|
|
4324
|
+
let entryPoint;
|
|
4325
|
+
if (pkgJson.exports) {
|
|
4326
|
+
const dotExport = pkgJson.exports["."];
|
|
4327
|
+
if (typeof dotExport === "string") {
|
|
4328
|
+
entryPoint = dotExport;
|
|
4329
|
+
} else if (dotExport?.import) {
|
|
4330
|
+
entryPoint = dotExport.import;
|
|
4331
|
+
} else if (dotExport?.default) {
|
|
4332
|
+
entryPoint = dotExport.default;
|
|
4333
|
+
}
|
|
4334
|
+
}
|
|
4335
|
+
if (!entryPoint) {
|
|
4336
|
+
entryPoint = pkgJson.module || pkgJson.main || "index.js";
|
|
4337
|
+
}
|
|
4338
|
+
if (!entryPoint) {
|
|
4339
|
+
return null;
|
|
4340
|
+
}
|
|
4341
|
+
const resolvedPath = join2(packagePath, entryPoint);
|
|
4342
|
+
return pathToFileURL(resolvedPath).href;
|
|
4343
|
+
} catch {
|
|
4344
|
+
return null;
|
|
4345
|
+
}
|
|
4346
|
+
};
|
|
4347
|
+
const externalPackagesToResolve = [
|
|
4348
|
+
"zod",
|
|
4349
|
+
"ai",
|
|
4350
|
+
"@ai-sdk/anthropic",
|
|
4351
|
+
"@ai-sdk/openai",
|
|
4352
|
+
"@ai-sdk/google",
|
|
4353
|
+
"@ai-sdk/mistral",
|
|
4354
|
+
"@ai-sdk/provider",
|
|
4355
|
+
"@ai-sdk/provider-utils"
|
|
4356
|
+
];
|
|
4357
|
+
for (const pkg of externalPackagesToResolve) {
|
|
4358
|
+
const escapedPkg = pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4359
|
+
const staticImportRegex = new RegExp(`from\\s+["']${escapedPkg}["']`, "g");
|
|
4360
|
+
if (staticImportRegex.test(transformed)) {
|
|
4361
|
+
const resolvedUrl = await resolvePackageToFileUrl(pkg);
|
|
4362
|
+
if (resolvedUrl) {
|
|
4363
|
+
transformed = transformed.replace(staticImportRegex, `from "${resolvedUrl}"`);
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
const dynamicImportRegex = new RegExp(`import\\s*\\(\\s*["']${escapedPkg}["']\\s*\\)`, "g");
|
|
4367
|
+
if (dynamicImportRegex.test(transformed)) {
|
|
4368
|
+
const resolvedUrl = await resolvePackageToFileUrl(pkg);
|
|
4369
|
+
if (resolvedUrl) {
|
|
4370
|
+
transformed = transformed.replace(dynamicImportRegex, `import("${resolvedUrl}")`);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
const vfPackagePath = join2(projectDir, "node_modules", "veryfront");
|
|
4375
|
+
const vfPackageJsonPath = join2(vfPackagePath, "package.json");
|
|
4376
|
+
let exportsMap = {};
|
|
4377
|
+
try {
|
|
4378
|
+
const pkgJson = JSON.parse(await fs2.readTextFile(vfPackageJsonPath));
|
|
4379
|
+
exportsMap = pkgJson.exports || {};
|
|
4380
|
+
} catch {
|
|
4381
|
+
}
|
|
4382
|
+
transformed = transformed.replace(
|
|
4383
|
+
/from\s+["'](veryfront\/[^"']+)["']/g,
|
|
4384
|
+
(_match, fullSpecifier) => {
|
|
4385
|
+
const subpath = "./" + fullSpecifier.replace("veryfront/", "");
|
|
4386
|
+
const exportEntry = exportsMap[subpath];
|
|
4387
|
+
if (exportEntry?.import) {
|
|
4388
|
+
const resolvedPath = join2(vfPackagePath, exportEntry.import);
|
|
4389
|
+
return `from "${pathToFileURL(resolvedPath).href}"`;
|
|
4390
|
+
}
|
|
4391
|
+
return _match;
|
|
4392
|
+
}
|
|
4393
|
+
);
|
|
4394
|
+
transformed = transformed.replace(
|
|
4395
|
+
/from\s+["']veryfront["']/g,
|
|
4396
|
+
() => {
|
|
4397
|
+
const exportEntry = exportsMap["."];
|
|
4398
|
+
if (exportEntry?.import) {
|
|
4399
|
+
const resolvedPath = join2(vfPackagePath, exportEntry.import);
|
|
4400
|
+
return `from "${pathToFileURL(resolvedPath).href}"`;
|
|
4401
|
+
}
|
|
4402
|
+
return 'from "veryfront"';
|
|
4403
|
+
}
|
|
4404
|
+
);
|
|
4405
|
+
} catch {
|
|
4406
|
+
}
|
|
4407
|
+
return transformed;
|
|
4408
|
+
}
|
|
3961
4409
|
async function discoverAll(config) {
|
|
3962
4410
|
let aiDir = config.aiDir;
|
|
3963
4411
|
const baseDir = config.baseDir;
|
|
@@ -3972,7 +4420,8 @@ async function discoverAll(config) {
|
|
|
3972
4420
|
}
|
|
3973
4421
|
const context = {
|
|
3974
4422
|
platform: detectPlatform(),
|
|
3975
|
-
fsAdapter: config.fsAdapter
|
|
4423
|
+
fsAdapter: config.fsAdapter,
|
|
4424
|
+
baseDir
|
|
3976
4425
|
};
|
|
3977
4426
|
const result = {
|
|
3978
4427
|
tools: /* @__PURE__ */ new Map(),
|
|
@@ -4006,7 +4455,7 @@ async function discoverTools(dir, result, context, verbose) {
|
|
|
4006
4455
|
}
|
|
4007
4456
|
for (const file of files) {
|
|
4008
4457
|
try {
|
|
4009
|
-
const module = await
|
|
4458
|
+
const module = await importModule(file, context);
|
|
4010
4459
|
const tool2 = module.default;
|
|
4011
4460
|
if (!tool2 || typeof tool2.execute !== "function") {
|
|
4012
4461
|
if (verbose) {
|
|
@@ -4039,7 +4488,7 @@ async function discoverAgents(dir, result, context, verbose) {
|
|
|
4039
4488
|
}
|
|
4040
4489
|
for (const file of files) {
|
|
4041
4490
|
try {
|
|
4042
|
-
const module = await
|
|
4491
|
+
const module = await importModule(file, context);
|
|
4043
4492
|
const agent2 = module.default;
|
|
4044
4493
|
if (!agent2 || typeof agent2.generate !== "function") {
|
|
4045
4494
|
if (verbose) {
|
|
@@ -4072,7 +4521,7 @@ async function discoverResources(dir, result, context, verbose) {
|
|
|
4072
4521
|
}
|
|
4073
4522
|
for (const file of files) {
|
|
4074
4523
|
try {
|
|
4075
|
-
const module = await
|
|
4524
|
+
const module = await importModule(file, context);
|
|
4076
4525
|
const resource2 = module.default;
|
|
4077
4526
|
if (!resource2 || typeof resource2.load !== "function") {
|
|
4078
4527
|
if (verbose) {
|
|
@@ -4106,7 +4555,7 @@ async function discoverPrompts(dir, result, context, verbose) {
|
|
|
4106
4555
|
}
|
|
4107
4556
|
for (const file of files) {
|
|
4108
4557
|
try {
|
|
4109
|
-
const module = await
|
|
4558
|
+
const module = await importModule(file, context);
|
|
4110
4559
|
const promptInstance = module.default;
|
|
4111
4560
|
if (!promptInstance || typeof promptInstance.getContent !== "function") {
|
|
4112
4561
|
if (verbose) {
|
|
@@ -4259,166 +4708,6 @@ function toAISDKTools(tools) {
|
|
|
4259
4708
|
return aiTools;
|
|
4260
4709
|
}
|
|
4261
4710
|
|
|
4262
|
-
// src/platform/compat/fs.ts
|
|
4263
|
-
var NodeFileSystem = class {
|
|
4264
|
-
constructor() {
|
|
4265
|
-
this.fs = null;
|
|
4266
|
-
this.os = null;
|
|
4267
|
-
this.path = null;
|
|
4268
|
-
this.initialized = false;
|
|
4269
|
-
}
|
|
4270
|
-
async ensureInitialized() {
|
|
4271
|
-
if (this.initialized)
|
|
4272
|
-
return;
|
|
4273
|
-
if (!isNode) {
|
|
4274
|
-
throw toError(createError({
|
|
4275
|
-
type: "not_supported",
|
|
4276
|
-
message: "Node.js fs modules not available",
|
|
4277
|
-
feature: "Node.js"
|
|
4278
|
-
}));
|
|
4279
|
-
}
|
|
4280
|
-
const [fsModule, osModule, pathModule] = await Promise.all([
|
|
4281
|
-
import("node:fs/promises"),
|
|
4282
|
-
import("node:os"),
|
|
4283
|
-
import("node:path")
|
|
4284
|
-
]);
|
|
4285
|
-
this.fs = fsModule;
|
|
4286
|
-
this.os = osModule;
|
|
4287
|
-
this.path = pathModule;
|
|
4288
|
-
this.initialized = true;
|
|
4289
|
-
}
|
|
4290
|
-
async readTextFile(path) {
|
|
4291
|
-
await this.ensureInitialized();
|
|
4292
|
-
return await this.fs.readFile(path, { encoding: "utf8" });
|
|
4293
|
-
}
|
|
4294
|
-
async readFile(path) {
|
|
4295
|
-
await this.ensureInitialized();
|
|
4296
|
-
return await this.fs.readFile(path);
|
|
4297
|
-
}
|
|
4298
|
-
async writeTextFile(path, data) {
|
|
4299
|
-
await this.ensureInitialized();
|
|
4300
|
-
await this.fs.writeFile(path, data, { encoding: "utf8" });
|
|
4301
|
-
}
|
|
4302
|
-
async writeFile(path, data) {
|
|
4303
|
-
await this.ensureInitialized();
|
|
4304
|
-
await this.fs.writeFile(path, data);
|
|
4305
|
-
}
|
|
4306
|
-
async exists(path) {
|
|
4307
|
-
await this.ensureInitialized();
|
|
4308
|
-
try {
|
|
4309
|
-
await this.fs.access(path);
|
|
4310
|
-
return true;
|
|
4311
|
-
} catch (error) {
|
|
4312
|
-
if (error.code === "ENOENT") {
|
|
4313
|
-
return false;
|
|
4314
|
-
}
|
|
4315
|
-
throw error;
|
|
4316
|
-
}
|
|
4317
|
-
}
|
|
4318
|
-
async stat(path) {
|
|
4319
|
-
await this.ensureInitialized();
|
|
4320
|
-
const stat = await this.fs.stat(path);
|
|
4321
|
-
return {
|
|
4322
|
-
isFile: stat.isFile(),
|
|
4323
|
-
isDirectory: stat.isDirectory(),
|
|
4324
|
-
isSymlink: stat.isSymbolicLink(),
|
|
4325
|
-
size: stat.size,
|
|
4326
|
-
mtime: stat.mtime
|
|
4327
|
-
};
|
|
4328
|
-
}
|
|
4329
|
-
async mkdir(path, options) {
|
|
4330
|
-
await this.ensureInitialized();
|
|
4331
|
-
await this.fs.mkdir(path, { recursive: options?.recursive ?? false });
|
|
4332
|
-
}
|
|
4333
|
-
async *readDir(path) {
|
|
4334
|
-
await this.ensureInitialized();
|
|
4335
|
-
const entries = await this.fs.readdir(path, { withFileTypes: true });
|
|
4336
|
-
for (const entry of entries) {
|
|
4337
|
-
yield {
|
|
4338
|
-
name: entry.name,
|
|
4339
|
-
isFile: entry.isFile(),
|
|
4340
|
-
isDirectory: entry.isDirectory()
|
|
4341
|
-
};
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
async remove(path, options) {
|
|
4345
|
-
await this.ensureInitialized();
|
|
4346
|
-
await this.fs.rm(path, {
|
|
4347
|
-
recursive: options?.recursive ?? false,
|
|
4348
|
-
force: options?.recursive ?? false
|
|
4349
|
-
});
|
|
4350
|
-
}
|
|
4351
|
-
async makeTempDir(options) {
|
|
4352
|
-
await this.ensureInitialized();
|
|
4353
|
-
const tempDir = this.path.join(
|
|
4354
|
-
this.os.tmpdir(),
|
|
4355
|
-
`${options?.prefix ?? "tmp-"}${Math.random().toString(36).substring(2, 8)}`
|
|
4356
|
-
);
|
|
4357
|
-
await this.fs.mkdir(tempDir, { recursive: true });
|
|
4358
|
-
return tempDir;
|
|
4359
|
-
}
|
|
4360
|
-
};
|
|
4361
|
-
var DenoFileSystem = class {
|
|
4362
|
-
async readTextFile(path) {
|
|
4363
|
-
return await Deno.readTextFile(path);
|
|
4364
|
-
}
|
|
4365
|
-
async readFile(path) {
|
|
4366
|
-
return await Deno.readFile(path);
|
|
4367
|
-
}
|
|
4368
|
-
async writeTextFile(path, data) {
|
|
4369
|
-
await Deno.writeTextFile(path, data);
|
|
4370
|
-
}
|
|
4371
|
-
async writeFile(path, data) {
|
|
4372
|
-
await Deno.writeFile(path, data);
|
|
4373
|
-
}
|
|
4374
|
-
async exists(path) {
|
|
4375
|
-
try {
|
|
4376
|
-
await Deno.stat(path);
|
|
4377
|
-
return true;
|
|
4378
|
-
} catch (error) {
|
|
4379
|
-
if (error instanceof Deno.errors.NotFound) {
|
|
4380
|
-
return false;
|
|
4381
|
-
}
|
|
4382
|
-
throw error;
|
|
4383
|
-
}
|
|
4384
|
-
}
|
|
4385
|
-
async stat(path) {
|
|
4386
|
-
const stat = await Deno.stat(path);
|
|
4387
|
-
return {
|
|
4388
|
-
isFile: stat.isFile,
|
|
4389
|
-
isDirectory: stat.isDirectory,
|
|
4390
|
-
isSymlink: stat.isSymlink,
|
|
4391
|
-
size: stat.size,
|
|
4392
|
-
mtime: stat.mtime
|
|
4393
|
-
};
|
|
4394
|
-
}
|
|
4395
|
-
async mkdir(path, options) {
|
|
4396
|
-
await Deno.mkdir(path, { recursive: options?.recursive ?? false });
|
|
4397
|
-
}
|
|
4398
|
-
async *readDir(path) {
|
|
4399
|
-
for await (const entry of Deno.readDir(path)) {
|
|
4400
|
-
yield {
|
|
4401
|
-
name: entry.name,
|
|
4402
|
-
isFile: entry.isFile,
|
|
4403
|
-
isDirectory: entry.isDirectory
|
|
4404
|
-
};
|
|
4405
|
-
}
|
|
4406
|
-
}
|
|
4407
|
-
async remove(path, options) {
|
|
4408
|
-
await Deno.remove(path, { recursive: options?.recursive ?? false });
|
|
4409
|
-
}
|
|
4410
|
-
async makeTempDir(options) {
|
|
4411
|
-
return await Deno.makeTempDir({ prefix: options?.prefix });
|
|
4412
|
-
}
|
|
4413
|
-
};
|
|
4414
|
-
function createFileSystem() {
|
|
4415
|
-
if (isDeno) {
|
|
4416
|
-
return new DenoFileSystem();
|
|
4417
|
-
} else {
|
|
4418
|
-
return new NodeFileSystem();
|
|
4419
|
-
}
|
|
4420
|
-
}
|
|
4421
|
-
|
|
4422
4711
|
// src/ai/utils/setup.ts
|
|
4423
4712
|
var fs = createFileSystem();
|
|
4424
4713
|
async function setupAI(options = {}) {
|
|
@@ -5820,18 +6109,6 @@ function waitForApproval(id, options = {}) {
|
|
|
5820
6109
|
};
|
|
5821
6110
|
}
|
|
5822
6111
|
|
|
5823
|
-
// src/platform/compat/path-helper.ts
|
|
5824
|
-
import nodePath from "node:path";
|
|
5825
|
-
var pathMod = null;
|
|
5826
|
-
if (typeof Deno === "undefined") {
|
|
5827
|
-
pathMod = nodePath;
|
|
5828
|
-
} else {
|
|
5829
|
-
import("node:path").then((mod) => {
|
|
5830
|
-
pathMod = mod;
|
|
5831
|
-
});
|
|
5832
|
-
}
|
|
5833
|
-
var sep = nodePath.sep;
|
|
5834
|
-
|
|
5835
6112
|
// src/ai/workflow/backends/types.ts
|
|
5836
6113
|
function hasLockSupport(backend) {
|
|
5837
6114
|
return typeof backend.acquireLock === "function" && typeof backend.releaseLock === "function";
|