The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Add SWAGGER_ENABLED config to control Swagger docs mounting (#873)
Chirag Jain7b43c06f209e
diff --git a/packages/trueforge/.env.example b/packages/trueforge/.env.exampleindex 431ae5823..8e587073a 100644--- a/packages/trueforge/.env.example+++ b/packages/trueforge/.env.example@@ -19,6 +19,9 @@ PORT=8790## HTTP bind address. Optional, defaults to localhost. Production Docker images set 0.0.0.0.# HOST=0.0.0.0+## Enable Swagger UI at /api/v1/docs. Optional, defaults to true.+# SWAGGER_ENABLED=true+## Optional override for the model catalog YAML (GET /catalog/model-providers).## When unset, the catalog inlined at build time (catalog/model-catalog.yaml) is used.# MODEL_CATALOG_PATH=/path/to/model-catalog.yamldiff --git a/packages/trueforge/src/app.ts b/packages/trueforge/src/app.tsindex d893e2f46..e3a0c67c7 100644--- a/packages/trueforge/src/app.ts+++ b/packages/trueforge/src/app.ts@@ -481,17 +481,19 @@ export function createServerApp<TTransaction>(deps: ServerDeps<TTransaction>) {);const uiBasePath = getPublicUiBasePath();- const openApiSpecPath = `${uiBasePath}api/v1/openapi.json`;- const openApiServerUrl = uiBasePath === '/' ? undefined : uiBasePath.replace(/\/$/, '');- app.get('/api/v1/docs', swaggerUI({ url: openApiSpecPath }));- app.get('/api/v1/openapi.json', c =>- c.json(- buildOpenApiDocument(app, {- authEnabled,- ...(openApiServerUrl === undefined ? {} : { serverUrl: openApiServerUrl }),- }),- ),- );+ if (configuration.SWAGGER_ENABLED) {+ const openApiSpecPath = `${uiBasePath}api/v1/openapi.json`;+ const openApiServerUrl = uiBasePath === '/' ? undefined : uiBasePath.replace(/\/$/, '');+ app.get('/api/v1/docs', swaggerUI({ url: openApiSpecPath }));+ app.get('/api/v1/openapi.json', c =>+ c.json(+ buildOpenApiDocument(app, {+ authEnabled,+ ...(openApiServerUrl === undefined ? {} : { serverUrl: openApiServerUrl }),+ }),+ ),+ );+ }app.notFound(routeNotFound);diff --git a/packages/trueforge/src/config.ts b/packages/trueforge/src/config.tsindex 40d08c035..fc99cf0ba 100644--- a/packages/trueforge/src/config.ts+++ b/packages/trueforge/src/config.ts@@ -686,6 +686,8 @@ export interface SharedServerConfiguration {HOST: string;/** Peering identity embedded in the turn ids this process mints; `local` in standalone mode. */EXECUTOR_ID: string;+ /** Enable Swagger UI at `/api/v1/docs`. Env: `SWAGGER_ENABLED`. Default true. */+ SWAGGER_ENABLED: boolean;/*** Optional override for the model catalog YAML (discovery presets for* GET /catalogs/model-providers). When unset, the catalog inlined at build@@ -1032,6 +1034,7 @@ const shared: SharedServerConfiguration = {PORT: port,HOST: host,EXECUTOR_ID: standalone ? LOCAL_EXECUTOR_ID : randomAlphanumeric(6),+ SWAGGER_ENABLED: parseBoolean({ envKey: 'SWAGGER_ENABLED', raw: getEnv('SWAGGER_ENABLED'), defaultValue: true }),MODEL_CATALOG_PATH: resolveOptionalPathEnv('MODEL_CATALOG_PATH'),MCP_CATALOG_PATH: resolveOptionalPathEnv('MCP_CATALOG_PATH'),SKILL_CATALOG_PATH: resolveOptionalPathEnv('SKILL_CATALOG_PATH'),