veryfront 0.1.485 → 0.1.487

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 (34) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts +164 -0
  3. package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.js +212 -0
  5. package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts +19 -0
  6. package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.js +69 -0
  8. package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts +17 -0
  9. package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.js +45 -0
  11. package/esm/src/agent/hosted-agent-service-config.d.ts +44 -0
  12. package/esm/src/agent/hosted-agent-service-config.d.ts.map +1 -0
  13. package/esm/src/agent/hosted-agent-service-config.js +35 -0
  14. package/esm/src/agent/hosted-agent-service-env-files.d.ts +10 -0
  15. package/esm/src/agent/hosted-agent-service-env-files.d.ts.map +1 -0
  16. package/esm/src/agent/hosted-agent-service-env-files.js +33 -0
  17. package/esm/src/agent/index.d.ts +2 -0
  18. package/esm/src/agent/index.d.ts.map +1 -1
  19. package/esm/src/agent/index.js +2 -0
  20. package/esm/src/platform/compat/std/dotenv.d.ts +18 -0
  21. package/esm/src/platform/compat/std/dotenv.d.ts.map +1 -0
  22. package/esm/src/platform/compat/std/dotenv.js +70 -0
  23. package/esm/src/utils/version-constant.d.ts +1 -1
  24. package/esm/src/utils/version-constant.js +1 -1
  25. package/package.json +1 -1
  26. package/src/deno.js +1 -1
  27. package/src/deps/jsr.io/@std/dotenv/0.225.6/mod.ts +251 -0
  28. package/src/deps/jsr.io/@std/dotenv/0.225.6/parse.ts +110 -0
  29. package/src/deps/jsr.io/@std/dotenv/0.225.6/stringify.ts +48 -0
  30. package/src/src/agent/hosted-agent-service-config.ts +45 -0
  31. package/src/src/agent/hosted-agent-service-env-files.ts +55 -0
  32. package/src/src/agent/index.ts +11 -0
  33. package/src/src/platform/compat/std/dotenv.ts +87 -0
  34. package/src/src/utils/version-constant.ts +1 -1
@@ -0,0 +1,48 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Stringify an object into a valid `.env` file format.
6
+ *
7
+ * @example Usage
8
+ * ```ts
9
+ * import { stringify } from "@std/dotenv/stringify";
10
+ * import { assertEquals } from "@std/assert";
11
+ *
12
+ * const object = { GREETING: "hello world" };
13
+ * assertEquals(stringify(object), "GREETING='hello world'");
14
+ * ```
15
+ *
16
+ * @param object object to be stringified
17
+ * @returns string of object
18
+ */
19
+ export function stringify(object: Record<string, string>): string {
20
+ const lines: string[] = [];
21
+ for (const [key, value] of Object.entries(object)) {
22
+ let quote;
23
+
24
+ let escapedValue = value ?? "";
25
+ if (key.startsWith("#")) {
26
+ // deno-lint-ignore no-console
27
+ console.warn(
28
+ `key starts with a '#' indicates a comment and is ignored: '${key}'`,
29
+ );
30
+ continue;
31
+ } else if (escapedValue.includes("\n") || escapedValue.includes("'")) {
32
+ // escape inner new lines
33
+ escapedValue = escapedValue.replaceAll("\n", "\\n");
34
+ quote = `"`;
35
+ } else if (escapedValue.match(/\W/)) {
36
+ quote = "'";
37
+ }
38
+
39
+ if (quote) {
40
+ // escape inner quotes
41
+ escapedValue = escapedValue.replaceAll(quote, `\\${quote}`);
42
+ escapedValue = `${quote}${escapedValue}${quote}`;
43
+ }
44
+ const line = `${key}=${escapedValue}`;
45
+ lines.push(line);
46
+ }
47
+ return lines.join("\n");
48
+ }
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+
3
+ function parseBooleanFlag(value: string): boolean {
4
+ return value === "true";
5
+ }
6
+
7
+ function splitAllowedOrigins(value: string): string[] {
8
+ return value.split(",").map((origin) => origin.trim());
9
+ }
10
+
11
+ const booleanFlagSchema = z.string().default("false").transform(parseBooleanFlag);
12
+
13
+ export const hostedAgentServiceConfigSchema = z.object({
14
+ VERYFRONT_API_URL: z.string().url().default("https://api.veryfront.com"),
15
+ NODE_ENV: z.enum(["development", "test", "production"]).default("development"),
16
+ PORT: z.coerce.number().default(3001),
17
+ OAUTH_PUBLIC_KEY: z.string().optional(),
18
+ VERYFRONT_STUDIO_MCP_URL: z.string().default(""),
19
+ VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT: booleanFlagSchema,
20
+ VERYFRONT_ENABLE_DURABLE_TASK: booleanFlagSchema,
21
+ ALLOWED_ORIGINS: z.string().default("http://localhost:3000,http://veryfront.me:3000"),
22
+ OTEL_ENABLED: booleanFlagSchema,
23
+ OTEL_EXPORTER_OTLP_ENDPOINT: z.string().optional(),
24
+ }).transform((env) => ({
25
+ VERYFRONT_API_URL: env.VERYFRONT_API_URL,
26
+ VERYFRONT_MCP_URL: `${env.VERYFRONT_API_URL}/mcp`,
27
+ VERYFRONT_STUDIO_MCP_URL: env.VERYFRONT_STUDIO_MCP_URL,
28
+ VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT: env.VERYFRONT_ENABLE_DURABLE_INVOKE_AGENT,
29
+ VERYFRONT_ENABLE_DURABLE_TASK: env.VERYFRONT_ENABLE_DURABLE_TASK,
30
+ NODE_ENV: env.NODE_ENV,
31
+ PORT: env.PORT,
32
+ OAUTH_PUBLIC_KEY: env.OAUTH_PUBLIC_KEY,
33
+ ALLOWED_ORIGINS: splitAllowedOrigins(env.ALLOWED_ORIGINS),
34
+ OTEL_ENABLED: env.OTEL_ENABLED,
35
+ OTEL_EXPORTER_OTLP_ENDPOINT: env.OTEL_EXPORTER_OTLP_ENDPOINT,
36
+ }));
37
+
38
+ export type HostedAgentServiceConfig = z.infer<typeof hostedAgentServiceConfigSchema>;
39
+ export type HostedAgentServiceConfigInput = z.input<typeof hostedAgentServiceConfigSchema>;
40
+
41
+ export function parseHostedAgentServiceConfig(
42
+ input: HostedAgentServiceConfigInput,
43
+ ): HostedAgentServiceConfig {
44
+ return hostedAgentServiceConfigSchema.parse(input);
45
+ }
@@ -0,0 +1,55 @@
1
+ import { cwd as getCwd, env as getProcessEnv, setEnv } from "../platform/compat/process.js";
2
+ import { load as loadDotenv } from "../platform/compat/std/dotenv.js";
3
+
4
+ const DEFAULT_HOSTED_AGENT_SERVICE_ENV_FILES = [".env", ".env.local"] as const;
5
+
6
+ export type HostedAgentServiceEnvFileLoadResult = {
7
+ loadedFiles: string[];
8
+ loadedVariables: number;
9
+ };
10
+
11
+ export type HostedAgentServiceEnvFileLoadOptions = {
12
+ cwd?: string;
13
+ files?: readonly string[];
14
+ };
15
+
16
+ function joinEnvPath(cwd: string, file: string): string {
17
+ if (file.startsWith("/") || file.startsWith("./") || file.startsWith("../")) {
18
+ return file;
19
+ }
20
+
21
+ return `${cwd.replace(/\/$/, "")}/${file}`;
22
+ }
23
+
24
+ export async function loadHostedAgentServiceEnvFiles(
25
+ options: HostedAgentServiceEnvFileLoadOptions = {},
26
+ ): Promise<HostedAgentServiceEnvFileLoadResult> {
27
+ const cwd = options.cwd ?? getCwd();
28
+ const files = options.files ?? DEFAULT_HOSTED_AGENT_SERVICE_ENV_FILES;
29
+ const protectedKeys = new Set(Object.keys(getProcessEnv()));
30
+ const loadedFiles: string[] = [];
31
+ let loadedVariables = 0;
32
+
33
+ for (const file of files) {
34
+ const envPath = joinEnvPath(cwd, file);
35
+ const parsed = await loadDotenv({ envPath, allowEmptyValues: true });
36
+ const entries = Object.entries(parsed);
37
+
38
+ if (entries.length === 0) {
39
+ continue;
40
+ }
41
+
42
+ loadedFiles.push(envPath);
43
+
44
+ for (const [key, value] of entries) {
45
+ if (protectedKeys.has(key)) {
46
+ continue;
47
+ }
48
+
49
+ setEnv(key, value);
50
+ loadedVariables++;
51
+ }
52
+ }
53
+
54
+ return { loadedFiles, loadedVariables };
55
+ }
@@ -273,6 +273,17 @@ export {
273
273
  type StartNodeHostedAgentServiceOptions,
274
274
  type StartNodeHostedAgentServiceResult,
275
275
  } from "./hosted-agent-service-runtime.js";
276
+ export {
277
+ type HostedAgentServiceConfig,
278
+ type HostedAgentServiceConfigInput,
279
+ hostedAgentServiceConfigSchema,
280
+ parseHostedAgentServiceConfig,
281
+ } from "./hosted-agent-service-config.js";
282
+ export {
283
+ type HostedAgentServiceEnvFileLoadOptions,
284
+ type HostedAgentServiceEnvFileLoadResult,
285
+ loadHostedAgentServiceEnvFiles,
286
+ } from "./hosted-agent-service-env-files.js";
276
287
  export {
277
288
  type AgentServiceBootstrapExit,
278
289
  type AgentServiceTraceContext,
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Portable @std/dotenv shim for Node.js and Bun.
3
+ *
4
+ * In Deno: Uses @std/dotenv
5
+ * In Node.js/Bun: Provides a minimal .env file loader
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import { isDeno } from "../runtime.js";
11
+
12
+ interface LoadOptions {
13
+ envPath?: string;
14
+ export?: boolean;
15
+ examplePath?: string | null;
16
+ allowEmptyValues?: boolean;
17
+ defaultsPath?: string | null;
18
+ }
19
+
20
+ function parseEnvFile(content: string, allowEmptyValues: boolean): Record<string, string> {
21
+ const result: Record<string, string> = {};
22
+
23
+ for (const line of content.split("\n")) {
24
+ const trimmed = line.trim();
25
+ if (!trimmed || trimmed.startsWith("#")) continue;
26
+
27
+ const eqIndex = trimmed.indexOf("=");
28
+ if (eqIndex === -1) continue;
29
+
30
+ const key = trimmed.slice(0, eqIndex).trim();
31
+ if (!key) continue;
32
+
33
+ let value = trimmed.slice(eqIndex + 1).trim();
34
+ if (!value && !allowEmptyValues) continue;
35
+
36
+ const firstChar = value[0];
37
+ if ((firstChar === `"` || firstChar === `'`) && value.endsWith(firstChar)) {
38
+ value = value.slice(1, -1);
39
+ }
40
+
41
+ if (value.includes("\\")) {
42
+ value = value
43
+ .replace(/\\n/g, "\n")
44
+ .replace(/\\r/g, "\r")
45
+ .replace(/\\t/g, "\t")
46
+ .replace(/\\\\/g, "\\");
47
+ }
48
+
49
+ result[key] = value;
50
+ }
51
+
52
+ return result;
53
+ }
54
+
55
+ async function nodeLoad(options: LoadOptions = {}): Promise<Record<string, string>> {
56
+ const { readFile } = await import("node:fs/promises");
57
+ const { resolve: pathResolve, join } = await import("node:path");
58
+ const { cwd } = await import("node:process");
59
+
60
+ const envPath = options.envPath ?? join(cwd(), ".env");
61
+ const shouldExport = options.export ?? false;
62
+
63
+ try {
64
+ const content = await readFile(pathResolve(envPath), "utf-8");
65
+ const parsed = parseEnvFile(content, options.allowEmptyValues ?? false);
66
+
67
+ if (shouldExport) {
68
+ for (const [key, value] of Object.entries(parsed)) {
69
+ if (process.env[key] === undefined) process.env[key] = value;
70
+ }
71
+ }
72
+
73
+ return parsed;
74
+ } catch (error) {
75
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return {};
76
+ throw error;
77
+ }
78
+ }
79
+
80
+ export let load: (options?: LoadOptions) => Promise<Record<string, string>>;
81
+
82
+ if (isDeno) {
83
+ const stdDotenv = await import("../../../../deps/jsr.io/@std/dotenv/0.225.6/mod.js");
84
+ load = stdDotenv.load;
85
+ } else {
86
+ load = nodeLoad;
87
+ }
@@ -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.485";
3
+ export const VERSION = "0.1.487";