veryfront 0.1.486 → 0.1.488
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/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts +164 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/mod.js +212 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts +19 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/parse.js +69 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts +17 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/dotenv/0.225.6/stringify.js +45 -0
- package/esm/src/agent/hosted-agent-service-env-files.d.ts +10 -0
- package/esm/src/agent/hosted-agent-service-env-files.d.ts.map +1 -0
- package/esm/src/agent/hosted-agent-service-env-files.js +33 -0
- package/esm/src/agent/index.d.ts +2 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -0
- package/esm/src/agent/veryfront-cloud-runtime-system-messages.d.ts +13 -0
- package/esm/src/agent/veryfront-cloud-runtime-system-messages.d.ts.map +1 -0
- package/esm/src/agent/veryfront-cloud-runtime-system-messages.js +40 -0
- package/esm/src/platform/compat/std/dotenv.d.ts +18 -0
- package/esm/src/platform/compat/std/dotenv.d.ts.map +1 -0
- package/esm/src/platform/compat/std/dotenv.js +70 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/deps/jsr.io/@std/dotenv/0.225.6/mod.ts +251 -0
- package/src/deps/jsr.io/@std/dotenv/0.225.6/parse.ts +110 -0
- package/src/deps/jsr.io/@std/dotenv/0.225.6/stringify.ts +48 -0
- package/src/src/agent/hosted-agent-service-env-files.ts +55 -0
- package/src/src/agent/index.ts +10 -0
- package/src/src/agent/veryfront-cloud-runtime-system-messages.ts +65 -0
- package/src/src/platform/compat/std/dotenv.ts +87 -0
- 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,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
|
+
}
|
package/src/src/agent/index.ts
CHANGED
|
@@ -186,6 +186,11 @@ export {
|
|
|
186
186
|
runtimeAgentThinkingConfigSchema,
|
|
187
187
|
} from "./runtime-agent-definition.js";
|
|
188
188
|
|
|
189
|
+
export {
|
|
190
|
+
createVeryfrontCloudRuntimeSystemMessages,
|
|
191
|
+
type CreateVeryfrontCloudRuntimeSystemMessagesInput,
|
|
192
|
+
} from "./veryfront-cloud-runtime-system-messages.js";
|
|
193
|
+
|
|
189
194
|
export {
|
|
190
195
|
applyAgentProjectContextChange,
|
|
191
196
|
getConfirmedProjectContextSwitchId,
|
|
@@ -279,6 +284,11 @@ export {
|
|
|
279
284
|
hostedAgentServiceConfigSchema,
|
|
280
285
|
parseHostedAgentServiceConfig,
|
|
281
286
|
} from "./hosted-agent-service-config.js";
|
|
287
|
+
export {
|
|
288
|
+
type HostedAgentServiceEnvFileLoadOptions,
|
|
289
|
+
type HostedAgentServiceEnvFileLoadResult,
|
|
290
|
+
loadHostedAgentServiceEnvFiles,
|
|
291
|
+
} from "./hosted-agent-service-env-files.js";
|
|
282
292
|
export {
|
|
283
293
|
type AgentServiceBootstrapExit,
|
|
284
294
|
type AgentServiceTraceContext,
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ChatSystemMessage } from "../chat/types.js";
|
|
2
|
+
import {
|
|
3
|
+
createRuntimeAgentSystemMessages,
|
|
4
|
+
type RuntimeAgentMarkdownDefinition,
|
|
5
|
+
} from "./runtime-agent-definition.js";
|
|
6
|
+
import { createRuntimePromptBlock } from "./runtime-prompt-block.js";
|
|
7
|
+
import type { RuntimeSkillDefinition } from "./runtime-skill-metadata.js";
|
|
8
|
+
|
|
9
|
+
export type CreateVeryfrontCloudRuntimeSystemMessagesInput = {
|
|
10
|
+
agent: RuntimeAgentMarkdownDefinition;
|
|
11
|
+
instructions?: string;
|
|
12
|
+
skills?: readonly RuntimeSkillDefinition[];
|
|
13
|
+
projectId?: string | null;
|
|
14
|
+
branchId?: string | null;
|
|
15
|
+
environmentContext?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function createProjectInstructionsBlock(instructions: string): string {
|
|
19
|
+
return createRuntimePromptBlock({
|
|
20
|
+
name: "project_instructions",
|
|
21
|
+
content: `CRITICAL: You MUST follow these project-specific guidelines:\n\n${instructions}`,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createProjectContextBlock(input: { projectId: string; branchId?: string | null }): string {
|
|
26
|
+
const branchLine = input.branchId
|
|
27
|
+
? `branch_id: "${input.branchId}"`
|
|
28
|
+
: "branch_id: main (no branch_id needed for file operations)";
|
|
29
|
+
|
|
30
|
+
return createRuntimePromptBlock({
|
|
31
|
+
name: "project_context",
|
|
32
|
+
content: `project_reference: "${input.projectId}"
|
|
33
|
+
${branchLine}
|
|
34
|
+
|
|
35
|
+
Use the exact project_reference above for project/platform tools unless a tool result explicitly confirms a different active project.
|
|
36
|
+
|
|
37
|
+
CRITICAL: Do NOT guess or invent project references. If a tool requires project_reference, use the value above.`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createVeryfrontCloudRuntimeSystemMessages(
|
|
42
|
+
input: CreateVeryfrontCloudRuntimeSystemMessagesInput,
|
|
43
|
+
): ChatSystemMessage[] {
|
|
44
|
+
const runtimeBlocks: string[] = [];
|
|
45
|
+
|
|
46
|
+
if (input.instructions) {
|
|
47
|
+
runtimeBlocks.push(createProjectInstructionsBlock(input.instructions));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (input.projectId) {
|
|
51
|
+
runtimeBlocks.push(
|
|
52
|
+
createProjectContextBlock({
|
|
53
|
+
projectId: input.projectId,
|
|
54
|
+
branchId: input.branchId,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return createRuntimeAgentSystemMessages({
|
|
60
|
+
agent: input.agent,
|
|
61
|
+
runtimeBlocks,
|
|
62
|
+
skills: input.skills,
|
|
63
|
+
environmentContext: input.environmentContext,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -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
|
+
}
|