The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Add containerized server deployment with external configuration.
debajyoti-truefoundryd67e8e1d7510
diff --git a/.dockerignore b/.dockerignorenew file mode 100644index 000000000..1a2af2e4c--- /dev/null+++ b/.dockerignore@@ -0,0 +1,17 @@+**/node_modules+**/dist+**/coverage+**/.turbo+**/*.tsbuildinfo+.git+.github+.husky+.eslintcache+.pnpm-store+**/*.log+**/.DS_Store+**/.env+packages/server/registry+Dockerfile+docker-compose.yml+.dockerignorediff --git a/.gitignore b/.gitignoreindex 6df4e9d02..98fd4cefb 100644--- a/.gitignore+++ b/.gitignore@@ -4,7 +4,7 @@ dist/.DS_Store*.log.env-packages/server/src/config/.env+packages/server/registry/coverage/.turbo/*.tsbuildinfodiff --git a/README.md b/README.mdindex 73222ee8c..e841d439e 100644--- a/README.md+++ b/README.md@@ -16,6 +16,29 @@ pnpm testpnpm typecheck```+## Run the server++Create the local environment and registry files from the tracked examples:++```bash+cp packages/server/src/.env.example packages/server/src/.env+cp -R packages/server/registry-example packages/server/registry+```++Fill in `MODEL_API_KEY` in `packages/server/src/.env`, then start the server:++```bash+pnpm dev:server+```++To build and run it with Docker instead:++```bash+docker compose up --build+```++The local `.env` file and `packages/server/registry/` directory are ignored by Git. Docker Compose requires the environment file and mounts the registry read-only into the container.+## Library imports```tsdiff --git a/docker-compose.yml b/docker-compose.ymlnew file mode 100644index 000000000..f2a8fdec1--- /dev/null+++ b/docker-compose.yml@@ -0,0 +1,21 @@+services:+ server:+ build:+ context: .+ dockerfile: packages/server/Dockerfile+ image: truefoundry-server:latest+ ports:+ - '${PORT:-8790}:8790'+ environment:+ # PORT the server listens on inside the container (defaults to 8790).+ PORT: 8790+ # Environment variables (MODEL_API_KEY, etc.) are read from this file.+ # Copy packages/server/src/.env.example to packages/server/src/.env and fill it in.+ env_file:+ - path: packages/server/src/.env+ required: true+ # The YAML registry (models.yaml, mcp.yaml, skills.yaml) is not baked into+ # the image. Copy registry-example to registry before starting the service.+ volumes:+ - ./packages/server/registry:/app/packages/server/registry:ro+ restart: unless-stoppeddiff --git a/packages/server/Dockerfile b/packages/server/Dockerfilenew file mode 100644index 000000000..9622adf44--- /dev/null+++ b/packages/server/Dockerfile@@ -0,0 +1,64 @@+# syntax=docker/dockerfile:1+#+# Multi-stage build for @truefoundry/server.+#+# The build context must be the repository root (this is a pnpm workspace and+# the server depends on the workspace package @truefoundry/utils). See the+# docker-compose.yml / build command at the repo root.++FROM node:24-slim AS base+ENV PNPM_HOME=/pnpm+ENV PATH="$PNPM_HOME:$PATH"+RUN corepack enable+WORKDIR /app++# ---------------------------------------------------------------------------+# builder: install all deps (incl. dev) and build utils + server.+# ---------------------------------------------------------------------------+FROM base AS builder+COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc tsconfig.base.json ./+COPY packages/harness/package.json packages/harness/package.json+COPY packages/server/package.json packages/server/package.json+RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile+COPY packages/harness packages/harness+COPY packages/server packages/server+RUN pnpm build++# ---------------------------------------------------------------------------+# prod-deps: resolve only production dependencies (no dev tooling).+# ---------------------------------------------------------------------------+FROM base AS prod-deps+COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./+COPY packages/harness/package.json packages/harness/package.json+COPY packages/server/package.json packages/server/package.json+RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod++# ---------------------------------------------------------------------------+# runner: minimal image with prod node_modules + built artifacts.+# ---------------------------------------------------------------------------+FROM base AS runner+ENV NODE_ENV=production++# Production dependency tree (pnpm workspace symlinks preserved).+COPY --from=prod-deps /app/node_modules ./node_modules+COPY --from=prod-deps /app/packages/harness/node_modules ./packages/harness/node_modules+COPY --from=prod-deps /app/packages/server/node_modules ./packages/server/node_modules++# Built workspace dependency (@truefoundry/utils).+COPY --from=builder /app/packages/harness/package.json ./packages/harness/package.json+COPY --from=builder /app/packages/harness/dist ./packages/harness/dist++# Built server.+COPY --from=builder /app/packages/server/package.json ./packages/server/package.json+COPY --from=builder /app/packages/server/dist ./packages/server/dist++WORKDIR /app/packages/server++# The YAML registry (models.yaml, mcp.yaml, skills.yaml) is read at runtime from+# ./registry and is provided via a volume mount rather than baked into the image.+RUN mkdir -p registry+VOLUME ["/app/packages/server/registry"]++EXPOSE 8790++CMD ["node", "dist/main.js"]diff --git a/packages/server/package.json b/packages/server/package.jsonindex c7ea29823..2912982b4 100644--- a/packages/server/package.json+++ b/packages/server/package.json@@ -8,7 +8,7 @@"type": "module","scripts": {"build": "tsup",- "dev": "tsx --env-file=src/config/.env src/main.ts",+ "dev": "tsx --env-file=src/.env src/main.ts","typecheck": "tsc --noEmit","start": "node dist/main.js"},diff --git a/packages/server/src/config/mcp.yaml b/packages/server/registry-example/mcp.yamlsimilarity index 100%rename from packages/server/src/config/mcp.yamlrename to packages/server/registry-example/mcp.yamldiff --git a/packages/server/src/config/models.yaml b/packages/server/registry-example/models.yamlsimilarity index 100%rename from packages/server/src/config/models.yamlrename to packages/server/registry-example/models.yamldiff --git a/packages/server/src/config/skills.yaml b/packages/server/registry-example/skills.yamlsimilarity index 100%rename from packages/server/src/config/skills.yamlrename to packages/server/registry-example/skills.yamldiff --git a/packages/server/src/config/.env.example b/packages/server/src/.env.examplesimilarity index 99%rename from packages/server/src/config/.env.examplerename to packages/server/src/.env.exampleindex 6df7a6c70..f9c44d191 100644--- a/packages/server/src/config/.env.example+++ b/packages/server/src/.env.example@@ -8,7 +8,7 @@# HTTP port the server listens on. Optional, defaults to 8790.PORT=8790-# Note: models.yaml, mcp.yaml and skills.yaml are always read from ./config+# Note: models.yaml, mcp.yaml and skills.yaml are always read from ./registry# (relative to the working directory). The model API base URL is the# base_url field in models.yaml; only its API key lives here.diff --git a/packages/server/src/config/config.ts b/packages/server/src/config.tssimilarity index 98%rename from packages/server/src/config/config.tsrename to packages/server/src/config.tsindex 802856874..e8f5d5196 100644--- a/packages/server/src/config/config.ts+++ b/packages/server/src/config.ts@@ -12,8 +12,8 @@ import path from 'node:path';// CONFIG FILES// ============================================================================-/** Directory containing the YAML config files: `./config` relative to the working directory. */-export const CONFIG_DIR = path.resolve('config');+/** Directory containing the YAML config files: `./registry` relative to the working directory. */+export const CONFIG_DIR = path.resolve('registry');/** YAML files the stores load from CONFIG_DIR at startup. */export const CONFIG_FILES = {diff --git a/packages/server/src/main.ts b/packages/server/src/main.tsindex b9aa39e2c..f2b9afee7 100644--- a/packages/server/src/main.ts+++ b/packages/server/src/main.ts@@ -18,7 +18,7 @@ try {{ createServerSandboxFactory },] = await Promise.all([import('./app'),- import('./config/config'),+ import('./config'),import('./store/ModelStore'),import('./store/McpStore'),import('./store/SkillStore'),diff --git a/packages/server/src/runtime/sandboxFactory.ts b/packages/server/src/runtime/sandboxFactory.tsindex 38a570ec1..ac2b900c8 100644--- a/packages/server/src/runtime/sandboxFactory.ts+++ b/packages/server/src/runtime/sandboxFactory.ts@@ -16,7 +16,7 @@ import { dirname, join } from 'node:path';import type { Logger } from 'winston';import { ZodError } from 'zod';import { TENANT_NAME } from '../apis/sessions';-import configuration from '../config/config';+import configuration from '../config';// Python helpers ship with @truefoundry/utils under dist/sandbox-scripts.const require = createRequire(import.meta.url);diff --git a/packages/server/src/store/McpStore.ts b/packages/server/src/store/McpStore.tsindex df9a8ef1b..d97a4a188 100644--- a/packages/server/src/store/McpStore.ts+++ b/packages/server/src/store/McpStore.ts@@ -3,7 +3,7 @@* MCP_HEADERS / MCP_{NAME}_HEADERS env vars and are never exposed in list* output.*/-import configuration, { CONFIG_FILES, normalizeEnvName } from '../config/config';+import configuration, { CONFIG_FILES, normalizeEnvName } from '../config';import { loadYamlFile } from './loadYaml';import { McpFileSchema, type McpServerEntry } from './schemas';diff --git a/packages/server/src/store/ModelStore.ts b/packages/server/src/store/ModelStore.tsindex 72658729c..7bd1f9aa5 100644--- a/packages/server/src/store/ModelStore.ts+++ b/packages/server/src/store/ModelStore.ts@@ -5,7 +5,7 @@* MODEL_HEADERS / MODEL_{NAME}_HEADERS add extra headers. Credentials are* never exposed in list output.*/-import configuration, { CONFIG_FILES, normalizeEnvName } from '../config/config';+import configuration, { CONFIG_FILES, normalizeEnvName } from '../config';import { loadYamlFile } from './loadYaml';import { ModelsFileSchema, type ModelEntry } from './schemas';diff --git a/packages/server/src/store/SkillStore.ts b/packages/server/src/store/SkillStore.tsindex 52a0d1039..1fdc7fd1e 100644--- a/packages/server/src/store/SkillStore.ts+++ b/packages/server/src/store/SkillStore.ts@@ -1,7 +1,7 @@/*** Catalog of agent skills from skills.yaml (git-based skills).*/-import { CONFIG_FILES } from '../config/config';+import { CONFIG_FILES } from '../config';import { loadYamlFile } from './loadYaml';import { SkillsFileSchema, type SkillEntry } from './schemas';diff --git a/packages/server/src/store/loadYaml.ts b/packages/server/src/store/loadYaml.tsindex c26432a0e..f1b5128e3 100644--- a/packages/server/src/store/loadYaml.ts+++ b/packages/server/src/store/loadYaml.ts@@ -7,7 +7,7 @@ import fs from 'node:fs';import path from 'node:path';import { parse } from 'yaml';import type { z } from 'zod';-import { CONFIG_DIR } from '../config/config';+import { CONFIG_DIR } from '../config';export function loadYamlFile<T>(fileName: string, schema: z.ZodType<T>): T {const filePath = path.join(CONFIG_DIR, fileName);diff --git a/packages/server/src/store/schemas.ts b/packages/server/src/store/schemas.tsindex da85c13aa..3b1a0a8bc 100644--- a/packages/server/src/store/schemas.ts+++ b/packages/server/src/store/schemas.ts@@ -4,7 +4,7 @@* the server fail at startup.*/import { z } from 'zod';-import { normalizeEnvName } from '../config/config';+import { normalizeEnvName } from '../config';/** Adds a validation issue if two entries share a name. */function uniqueNames(entries: { name: string }[], ctx: z.RefinementCtx): void {