veryfront 0.0.35 → 0.0.37

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 (77) hide show
  1. package/dist/ai/index.js +365 -179
  2. package/dist/ai/index.js.map +4 -4
  3. package/dist/ai/react.js +1 -3
  4. package/dist/ai/react.js.map +2 -2
  5. package/dist/cli.js +359 -2304
  6. package/dist/components.js +4 -2
  7. package/dist/components.js.map +2 -2
  8. package/dist/config.js +4 -2
  9. package/dist/config.js.map +2 -2
  10. package/dist/data.js +4 -2
  11. package/dist/data.js.map +2 -2
  12. package/dist/index.js +7 -2
  13. package/dist/index.js.map +2 -2
  14. package/dist/templates/ai/ai/agents/assistant.ts +20 -0
  15. package/dist/templates/ai/ai/prompts/assistant.ts +14 -0
  16. package/dist/templates/ai/ai/tools/get-weather.ts +29 -0
  17. package/dist/templates/ai/app/api/chat/route.ts +37 -0
  18. package/dist/templates/ai/app/layout.tsx +18 -0
  19. package/dist/templates/ai/app/page.tsx +28 -0
  20. package/dist/templates/ai/tsconfig.json +18 -0
  21. package/dist/templates/ai/veryfront.config.ts +9 -0
  22. package/dist/templates/app/_env.example +16 -0
  23. package/dist/templates/app/app/api/auth/login/route.ts +53 -0
  24. package/dist/templates/app/app/api/auth/logout/route.ts +27 -0
  25. package/dist/templates/app/app/api/auth/me/route.ts +34 -0
  26. package/dist/templates/app/app/api/auth/register/route.ts +42 -0
  27. package/dist/templates/app/app/api/stats/route.ts +21 -0
  28. package/dist/templates/app/app/api/users/route.ts +42 -0
  29. package/dist/templates/app/app/dashboard/page.tsx +29 -0
  30. package/dist/templates/app/app/layout.tsx +45 -0
  31. package/dist/templates/app/app/login/page.tsx +222 -0
  32. package/dist/templates/app/app/page.tsx +15 -0
  33. package/dist/templates/app/components/AuthProvider.tsx +51 -0
  34. package/dist/templates/app/components/DashboardLayout.tsx +142 -0
  35. package/dist/templates/app/components/FeatureGrid.tsx +98 -0
  36. package/dist/templates/app/components/Header.tsx +58 -0
  37. package/dist/templates/app/components/HeroSection.tsx +49 -0
  38. package/dist/templates/app/components/RecentActivity.tsx +98 -0
  39. package/dist/templates/app/components/StatsGrid.tsx +126 -0
  40. package/dist/templates/app/components/Toaster.tsx +113 -0
  41. package/dist/templates/app/lib/auth-client.ts +38 -0
  42. package/dist/templates/app/lib/auth.ts +49 -0
  43. package/dist/templates/app/lib/stats.ts +34 -0
  44. package/dist/templates/app/lib/users.ts +86 -0
  45. package/dist/templates/app/middleware/auth.ts +34 -0
  46. package/dist/templates/app/public/robots.txt +4 -0
  47. package/dist/templates/app/veryfront.config.js +74 -0
  48. package/dist/templates/blog/app/about/page.mdx +14 -0
  49. package/dist/templates/blog/app/archive/page.tsx +42 -0
  50. package/dist/templates/blog/app/blog/[slug]/page.tsx +47 -0
  51. package/dist/templates/blog/app/layout.tsx +54 -0
  52. package/dist/templates/blog/app/page.tsx +13 -0
  53. package/dist/templates/blog/components/BlogPostList.tsx +53 -0
  54. package/dist/templates/blog/components/MDXContent.tsx +26 -0
  55. package/dist/templates/blog/content/posts/hello-world.mdx +29 -0
  56. package/dist/templates/blog/content/posts/markdown-showcase.mdx +105 -0
  57. package/dist/templates/blog/lib/posts.ts +76 -0
  58. package/dist/templates/blog/lib/utils.ts +14 -0
  59. package/dist/templates/blog/public/robots.txt +4 -0
  60. package/dist/templates/blog/styles/globals.css +21 -0
  61. package/dist/templates/blog/veryfront.config.js +39 -0
  62. package/dist/templates/docs/app/docs/api/page.mdx +102 -0
  63. package/dist/templates/docs/app/docs/core-concepts/page.mdx +82 -0
  64. package/dist/templates/docs/app/docs/getting-started/page.mdx +67 -0
  65. package/dist/templates/docs/app/layout.tsx +41 -0
  66. package/dist/templates/docs/app/page.mdx +51 -0
  67. package/dist/templates/docs/components/CodeBlock.tsx +44 -0
  68. package/dist/templates/docs/components/Header.tsx +49 -0
  69. package/dist/templates/docs/components/Sidebar.tsx +68 -0
  70. package/dist/templates/docs/public/robots.txt +4 -0
  71. package/dist/templates/docs/styles/globals.css +48 -0
  72. package/dist/templates/docs/veryfront.config.js +47 -0
  73. package/dist/templates/minimal/app/about/page.mdx +18 -0
  74. package/dist/templates/minimal/app/layout.tsx +20 -0
  75. package/dist/templates/minimal/app/page.tsx +26 -0
  76. package/dist/templates/minimal/veryfront.config.js +29 -0
  77. package/package.json +1 -1
package/dist/ai/index.js CHANGED
@@ -1675,14 +1675,15 @@ var LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;
1675
1675
  // deno.json
1676
1676
  var deno_default = {
1677
1677
  name: "veryfront",
1678
- version: "0.0.35",
1678
+ version: "0.0.37",
1679
1679
  exclude: [
1680
1680
  "npm/",
1681
1681
  "dist/",
1682
1682
  "coverage/",
1683
1683
  "scripts/",
1684
1684
  "examples/",
1685
- "tests/"
1685
+ "tests/",
1686
+ "src/cli/templates/files/"
1686
1687
  ],
1687
1688
  exports: {
1688
1689
  ".": "./src/index.ts",
@@ -1692,6 +1693,7 @@ var deno_default = {
1692
1693
  "./components": "./src/react/components/index.ts",
1693
1694
  "./data": "./src/data/index.ts",
1694
1695
  "./config": "./src/core/config/index.ts",
1696
+ "./platform": "./src/platform/index.ts",
1695
1697
  "./ai": "./src/ai/index.ts",
1696
1698
  "./ai/client": "./src/ai/client.ts",
1697
1699
  "./ai/react": "./src/ai/react/index.ts",
@@ -4048,7 +4050,362 @@ function createMockAdapter() {
4048
4050
  };
4049
4051
  }
4050
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
+
4051
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
+ }
4052
4409
  async function discoverAll(config) {
4053
4410
  let aiDir = config.aiDir;
4054
4411
  const baseDir = config.baseDir;
@@ -4063,7 +4420,8 @@ async function discoverAll(config) {
4063
4420
  }
4064
4421
  const context = {
4065
4422
  platform: detectPlatform(),
4066
- fsAdapter: config.fsAdapter
4423
+ fsAdapter: config.fsAdapter,
4424
+ baseDir
4067
4425
  };
4068
4426
  const result = {
4069
4427
  tools: /* @__PURE__ */ new Map(),
@@ -4097,7 +4455,7 @@ async function discoverTools(dir, result, context, verbose) {
4097
4455
  }
4098
4456
  for (const file of files) {
4099
4457
  try {
4100
- const module = await import(file);
4458
+ const module = await importModule(file, context);
4101
4459
  const tool2 = module.default;
4102
4460
  if (!tool2 || typeof tool2.execute !== "function") {
4103
4461
  if (verbose) {
@@ -4130,7 +4488,7 @@ async function discoverAgents(dir, result, context, verbose) {
4130
4488
  }
4131
4489
  for (const file of files) {
4132
4490
  try {
4133
- const module = await import(file);
4491
+ const module = await importModule(file, context);
4134
4492
  const agent2 = module.default;
4135
4493
  if (!agent2 || typeof agent2.generate !== "function") {
4136
4494
  if (verbose) {
@@ -4163,7 +4521,7 @@ async function discoverResources(dir, result, context, verbose) {
4163
4521
  }
4164
4522
  for (const file of files) {
4165
4523
  try {
4166
- const module = await import(file);
4524
+ const module = await importModule(file, context);
4167
4525
  const resource2 = module.default;
4168
4526
  if (!resource2 || typeof resource2.load !== "function") {
4169
4527
  if (verbose) {
@@ -4197,7 +4555,7 @@ async function discoverPrompts(dir, result, context, verbose) {
4197
4555
  }
4198
4556
  for (const file of files) {
4199
4557
  try {
4200
- const module = await import(file);
4558
+ const module = await importModule(file, context);
4201
4559
  const promptInstance = module.default;
4202
4560
  if (!promptInstance || typeof promptInstance.getContent !== "function") {
4203
4561
  if (verbose) {
@@ -4350,166 +4708,6 @@ function toAISDKTools(tools) {
4350
4708
  return aiTools;
4351
4709
  }
4352
4710
 
4353
- // src/platform/compat/fs.ts
4354
- var NodeFileSystem = class {
4355
- constructor() {
4356
- this.fs = null;
4357
- this.os = null;
4358
- this.path = null;
4359
- this.initialized = false;
4360
- }
4361
- async ensureInitialized() {
4362
- if (this.initialized)
4363
- return;
4364
- if (!isNode) {
4365
- throw toError(createError({
4366
- type: "not_supported",
4367
- message: "Node.js fs modules not available",
4368
- feature: "Node.js"
4369
- }));
4370
- }
4371
- const [fsModule, osModule, pathModule] = await Promise.all([
4372
- import("node:fs/promises"),
4373
- import("node:os"),
4374
- import("node:path")
4375
- ]);
4376
- this.fs = fsModule;
4377
- this.os = osModule;
4378
- this.path = pathModule;
4379
- this.initialized = true;
4380
- }
4381
- async readTextFile(path) {
4382
- await this.ensureInitialized();
4383
- return await this.fs.readFile(path, { encoding: "utf8" });
4384
- }
4385
- async readFile(path) {
4386
- await this.ensureInitialized();
4387
- return await this.fs.readFile(path);
4388
- }
4389
- async writeTextFile(path, data) {
4390
- await this.ensureInitialized();
4391
- await this.fs.writeFile(path, data, { encoding: "utf8" });
4392
- }
4393
- async writeFile(path, data) {
4394
- await this.ensureInitialized();
4395
- await this.fs.writeFile(path, data);
4396
- }
4397
- async exists(path) {
4398
- await this.ensureInitialized();
4399
- try {
4400
- await this.fs.access(path);
4401
- return true;
4402
- } catch (error) {
4403
- if (error.code === "ENOENT") {
4404
- return false;
4405
- }
4406
- throw error;
4407
- }
4408
- }
4409
- async stat(path) {
4410
- await this.ensureInitialized();
4411
- const stat = await this.fs.stat(path);
4412
- return {
4413
- isFile: stat.isFile(),
4414
- isDirectory: stat.isDirectory(),
4415
- isSymlink: stat.isSymbolicLink(),
4416
- size: stat.size,
4417
- mtime: stat.mtime
4418
- };
4419
- }
4420
- async mkdir(path, options) {
4421
- await this.ensureInitialized();
4422
- await this.fs.mkdir(path, { recursive: options?.recursive ?? false });
4423
- }
4424
- async *readDir(path) {
4425
- await this.ensureInitialized();
4426
- const entries = await this.fs.readdir(path, { withFileTypes: true });
4427
- for (const entry of entries) {
4428
- yield {
4429
- name: entry.name,
4430
- isFile: entry.isFile(),
4431
- isDirectory: entry.isDirectory()
4432
- };
4433
- }
4434
- }
4435
- async remove(path, options) {
4436
- await this.ensureInitialized();
4437
- await this.fs.rm(path, {
4438
- recursive: options?.recursive ?? false,
4439
- force: options?.recursive ?? false
4440
- });
4441
- }
4442
- async makeTempDir(options) {
4443
- await this.ensureInitialized();
4444
- const tempDir = this.path.join(
4445
- this.os.tmpdir(),
4446
- `${options?.prefix ?? "tmp-"}${Math.random().toString(36).substring(2, 8)}`
4447
- );
4448
- await this.fs.mkdir(tempDir, { recursive: true });
4449
- return tempDir;
4450
- }
4451
- };
4452
- var DenoFileSystem = class {
4453
- async readTextFile(path) {
4454
- return await Deno.readTextFile(path);
4455
- }
4456
- async readFile(path) {
4457
- return await Deno.readFile(path);
4458
- }
4459
- async writeTextFile(path, data) {
4460
- await Deno.writeTextFile(path, data);
4461
- }
4462
- async writeFile(path, data) {
4463
- await Deno.writeFile(path, data);
4464
- }
4465
- async exists(path) {
4466
- try {
4467
- await Deno.stat(path);
4468
- return true;
4469
- } catch (error) {
4470
- if (error instanceof Deno.errors.NotFound) {
4471
- return false;
4472
- }
4473
- throw error;
4474
- }
4475
- }
4476
- async stat(path) {
4477
- const stat = await Deno.stat(path);
4478
- return {
4479
- isFile: stat.isFile,
4480
- isDirectory: stat.isDirectory,
4481
- isSymlink: stat.isSymlink,
4482
- size: stat.size,
4483
- mtime: stat.mtime
4484
- };
4485
- }
4486
- async mkdir(path, options) {
4487
- await Deno.mkdir(path, { recursive: options?.recursive ?? false });
4488
- }
4489
- async *readDir(path) {
4490
- for await (const entry of Deno.readDir(path)) {
4491
- yield {
4492
- name: entry.name,
4493
- isFile: entry.isFile,
4494
- isDirectory: entry.isDirectory
4495
- };
4496
- }
4497
- }
4498
- async remove(path, options) {
4499
- await Deno.remove(path, { recursive: options?.recursive ?? false });
4500
- }
4501
- async makeTempDir(options) {
4502
- return await Deno.makeTempDir({ prefix: options?.prefix });
4503
- }
4504
- };
4505
- function createFileSystem() {
4506
- if (isDeno) {
4507
- return new DenoFileSystem();
4508
- } else {
4509
- return new NodeFileSystem();
4510
- }
4511
- }
4512
-
4513
4711
  // src/ai/utils/setup.ts
4514
4712
  var fs = createFileSystem();
4515
4713
  async function setupAI(options = {}) {
@@ -5911,18 +6109,6 @@ function waitForApproval(id, options = {}) {
5911
6109
  };
5912
6110
  }
5913
6111
 
5914
- // src/platform/compat/path-helper.ts
5915
- import nodePath from "node:path";
5916
- var pathMod = null;
5917
- if (typeof Deno === "undefined") {
5918
- pathMod = nodePath;
5919
- } else {
5920
- import("node:path").then((mod) => {
5921
- pathMod = mod;
5922
- });
5923
- }
5924
- var sep = nodePath.sep;
5925
-
5926
6112
  // src/ai/workflow/backends/types.ts
5927
6113
  function hasLockSupport(backend) {
5928
6114
  return typeof backend.acquireLock === "function" && typeof backend.releaseLock === "function";