Skip to content

Commit b959a8f

Browse files
Document and tighten environment defaults
1 parent 195c992 commit b959a8f

5 files changed

Lines changed: 90 additions & 16 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
AWS_SECRET_ACCESS_KEY: minio123
4040
AWS_REGION: us-east-1
4141
ports:
42-
- "3030:3000"
42+
- "4318:3000"
4343

4444
volumes:
4545
minio-data:

packages/core/src/config.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ export function configFromEnv(
4949
environment.storeType;
5050
const dbPath = overrides.dbPath ?? join(environment.envDir, "cache.duckdb");
5151
const projectId = env("AGENTPOND_PROJECT_ID") ?? "default-project";
52-
const publicKey =
53-
env("LANGFUSE_PUBLIC_KEY") ?? env("AGENTPOND_PUBLIC_KEY") ?? "pk-agentpond";
54-
const secretKey =
55-
env("LANGFUSE_SECRET_KEY") ?? env("AGENTPOND_SECRET_KEY") ?? "sk-agentpond";
52+
const publicKey = env("LANGFUSE_PUBLIC_KEY") ?? "pk-agentpond";
53+
const secretKey = env("LANGFUSE_SECRET_KEY") ?? "sk-agentpond";
5654

5755
return {
5856
projectId,
@@ -68,13 +66,15 @@ export function configFromEnv(
6866
),
6967
endpoint:
7068
overrides.s3Endpoint ??
71-
env("AGENTPOND_S3_ENDPOINT") ??
72-
env("S3_ENDPOINT"),
69+
nonEmpty(env("AGENTPOND_S3_ENDPOINT")) ??
70+
nonEmpty(env("S3_ENDPOINT")),
7371
region: env("AWS_REGION") ?? env("AGENTPOND_S3_REGION") ?? "us-east-1",
7472
accessKeyId:
75-
env("AWS_ACCESS_KEY_ID") ?? env("AGENTPOND_S3_ACCESS_KEY_ID"),
73+
nonEmpty(env("AWS_ACCESS_KEY_ID")) ??
74+
nonEmpty(env("AGENTPOND_S3_ACCESS_KEY_ID")),
7675
secretAccessKey:
77-
env("AWS_SECRET_ACCESS_KEY") ?? env("AGENTPOND_S3_SECRET_ACCESS_KEY"),
76+
nonEmpty(env("AWS_SECRET_ACCESS_KEY")) ??
77+
nonEmpty(env("AGENTPOND_S3_SECRET_ACCESS_KEY")),
7878
forcePathStyle:
7979
(env("AGENTPOND_S3_FORCE_PATH_STYLE") ?? "true") !== "false",
8080
},
@@ -102,6 +102,10 @@ function envValue(
102102
return (name) => process.env[name] ?? fileEnv[name];
103103
}
104104

105+
function nonEmpty(value: string | undefined): string | undefined {
106+
return value === undefined || value === "" ? undefined : value;
107+
}
108+
105109
function storeTypeFromValue(
106110
value: string | undefined,
107111
): AgentPondStoreType | undefined {

packages/core/src/environment.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,40 @@ function normalizeEnvironmentName(name: string): string {
132132
}
133133

134134
function defaultEnvironmentFile(name: string): string {
135+
const isDev = name === "dev";
136+
if (isDev) return "";
135137
const lines = [
138+
"# Project id used to share the same object store across different projects.",
136139
"AGENTPOND_PROJECT_ID=default-project",
140+
"",
141+
"# Langfuse-compatible base URL used by SDKs.",
142+
"LANGFUSE_BASE_URL=http://localhost:4318",
143+
"",
144+
"# Langfuse-compatible public key accepted by the ingestion server.",
137145
"LANGFUSE_PUBLIC_KEY=pk-agentpond",
146+
"# Langfuse-compatible secret key accepted by the ingestion server.",
138147
"LANGFUSE_SECRET_KEY=sk-agentpond",
139148
"",
140149
];
141-
if (name !== "dev") lines.unshift("AGENTPOND_STORE=s3");
150+
lines.unshift(
151+
"# Storage backend for this environment. S3-backed environments sync from object storage.",
152+
"AGENTPOND_STORE=s3",
153+
"",
154+
"# S3 bucket containing AgentPond ingestion objects.",
155+
"AGENTPOND_S3_BUCKET=agentpond",
156+
"# Optional key prefix inside the S3 bucket.",
157+
"AGENTPOND_S3_PREFIX=",
158+
"# Local MinIO endpoint from docker-compose.yml. Leave empty for Amazon S3.",
159+
"AGENTPOND_S3_ENDPOINT=http://localhost:9000",
160+
"# AWS/S3 region used by the object-store client.",
161+
"AGENTPOND_S3_REGION=us-east-1",
162+
"# Local MinIO access key from docker-compose.yml. Leave empty to use the AWS SDK credential chain.",
163+
"AGENTPOND_S3_ACCESS_KEY_ID=minio",
164+
"# Local MinIO secret key from docker-compose.yml. Leave empty to use the AWS SDK credential chain.",
165+
"AGENTPOND_S3_SECRET_ACCESS_KEY=minio123",
166+
"# Use true for MinIO. Use false for Amazon S3 virtual-hosted buckets.",
167+
"AGENTPOND_S3_FORCE_PATH_STYLE=true",
168+
"",
169+
);
142170
return lines.join("\n");
143171
}

tests/cli.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,12 @@ test("CLI scores create writes directly to the dev DuckDB", async () => {
630630
});
631631

632632
test("CLI dev env prints shell exports for SDK configuration", async () => {
633+
const cwd = process.cwd();
634+
const root = mkdtempSync(join(tmpdir(), "agentpond-cli-dev-env-"));
633635
const originalExitCode = process.exitCode;
634636
process.exitCode = undefined;
635637
try {
638+
process.chdir(root);
636639
const output = await captureStdout(() =>
637640
main(["node", "agentpond", "dev", "env"]),
638641
);
@@ -648,14 +651,18 @@ test("CLI dev env prints shell exports for SDK configuration", async () => {
648651
].join("\n"),
649652
);
650653
} finally {
654+
process.chdir(cwd);
651655
process.exitCode = originalExitCode;
652656
}
653657
});
654658

655659
test("CLI dev env honors custom host and port", async () => {
660+
const cwd = process.cwd();
661+
const root = mkdtempSync(join(tmpdir(), "agentpond-cli-dev-env-override-"));
656662
const originalExitCode = process.exitCode;
657663
process.exitCode = undefined;
658664
try {
665+
process.chdir(root);
659666
const output = await captureStdout(() =>
660667
main([
661668
"node",
@@ -671,7 +678,9 @@ test("CLI dev env honors custom host and port", async () => {
671678

672679
assert.equal(process.exitCode, undefined);
673680
assert.match(output, /export LANGFUSE_BASE_URL=http:\/\/0\.0\.0\.0:9999/);
681+
assert.match(output, /export LANGFUSE_PUBLIC_KEY=pk-agentpond-dev/);
674682
} finally {
683+
process.chdir(cwd);
675684
process.exitCode = originalExitCode;
676685
}
677686
});

tests/config.test.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,54 @@ test("config keeps explicit path override precedence", () => {
4444
);
4545
});
4646

47-
test("dev environment file does not include a store override", () => {
47+
test("generated environment files document defaults and S3 settings", () => {
4848
const originalCwd = process.cwd();
4949
const cwd = mkdtempSync(join(tmpdir(), "agentpond-config-"));
5050
try {
5151
process.chdir(cwd);
5252
const dev = initAgentPondEnvironment("dev");
5353
const production = initAgentPondEnvironment("production");
54+
const devFile = readFileSync(dev.envFilePath, "utf8");
55+
const productionFile = readFileSync(production.envFilePath, "utf8");
5456

55-
assert.doesNotMatch(
56-
readFileSync(dev.envFilePath, "utf8"),
57-
/AGENTPOND_STORE=/,
57+
assert.equal(devFile, "");
58+
assert.doesNotMatch(devFile, /AGENTPOND_PROJECT_ID=/);
59+
assert.doesNotMatch(devFile, /AGENTPOND_STORE=/);
60+
assert.doesNotMatch(devFile, /AGENTPOND_S3_BUCKET=/);
61+
assert.doesNotMatch(devFile, /LANGFUSE_BASE_URL=/);
62+
assert.doesNotMatch(devFile, /LANGFUSE_PUBLIC_KEY=/);
63+
assert.doesNotMatch(devFile, /LANGFUSE_SECRET_KEY=/);
64+
65+
assert.match(productionFile, /# Storage backend/);
66+
assert.match(productionFile, /LANGFUSE_BASE_URL=http:\/\/localhost:4318/);
67+
assert.match(productionFile, /AGENTPOND_STORE=s3/);
68+
assert.match(productionFile, /# S3 bucket/);
69+
assert.match(productionFile, /AGENTPOND_S3_BUCKET=agentpond/);
70+
assert.match(productionFile, /AGENTPOND_S3_PREFIX=/);
71+
assert.match(
72+
productionFile,
73+
/Local MinIO endpoint from docker-compose\.yml/,
5874
);
5975
assert.match(
60-
readFileSync(production.envFilePath, "utf8"),
61-
/AGENTPOND_STORE=s3/,
76+
productionFile,
77+
/AGENTPOND_S3_ENDPOINT=http:\/\/localhost:9000/,
78+
);
79+
assert.match(productionFile, /AGENTPOND_S3_REGION=us-east-1/);
80+
assert.match(productionFile, /AGENTPOND_S3_ACCESS_KEY_ID=minio/);
81+
assert.match(productionFile, /AGENTPOND_S3_SECRET_ACCESS_KEY=minio123/);
82+
assert.match(productionFile, /Use true for MinIO/);
83+
assert.match(productionFile, /AGENTPOND_S3_FORCE_PATH_STYLE=true/);
84+
assert.equal(
85+
configFromEnv({ envName: "production" }).s3.endpoint,
86+
"http://localhost:9000",
87+
);
88+
assert.equal(
89+
configFromEnv({ envName: "production" }).s3.accessKeyId,
90+
"minio",
91+
);
92+
assert.equal(
93+
configFromEnv({ envName: "production" }).s3.secretAccessKey,
94+
"minio123",
6295
);
6396
} finally {
6497
process.chdir(originalCwd);

0 commit comments

Comments
 (0)