diff --git a/config.example.json b/config.example.json index 0a345fe..4a26359 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,6 @@ { "server": { - "host": "127.0.0.1", + "host": "0.0.0.0", "port": 8080 }, "proxy": { diff --git a/package.json b/package.json index 359d256..1b983fc 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@workspace/api-server", + "name": "random-proxy", "version": "0.0.0", "license": "MIT", "type": "module", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..ccbac80 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - "." diff --git a/readme.md b/readme.md index 36e0861..31495b2 100644 --- a/readme.md +++ b/readme.md @@ -1,34 +1,34 @@ -# Agent Setup +# Agent Instructions -This artifact is a standalone Express API server. It exposes a static model dashboard and OpenAI-compatible proxy routes backed by internally supplied provider endpoints. +This repository is a standalone Express API server. It is not intended to be added to a parent workspace. -## Required Agent Actions - -1. Install dependencies: +## Run Exactly ```bash -pnpm install +pnpm install --ignore-workspace +pnpm dev ``` -`pnpm-lock.yaml` is intentionally not tracked in this repository. `pnpm install` may generate one locally. +The server starts with built-in defaults even when `config.json` does not exist: -2. Create and fill `config.json`. +- host: `0.0.0.0` +- port: `8080` +- proxy bearer token: `dev-proxy-key` + +Do not create `config.json` unless internal provider endpoints are available. + +## Fill Provider Config + +Only if internal provider endpoints are available: ```bash cp config.example.json config.json ``` -Replace provider values when internal endpoints are available: +Then fill only these values: ```json { - "server": { - "host": "127.0.0.1", - "port": 8080 - }, - "proxy": { - "apiKey": "dev-proxy-key" - }, "providers": { "openai": { "apiKey": "internal-openai-token", @@ -38,49 +38,13 @@ Replace provider values when internal endpoints are available: "apiKey": "internal-anthropic-token", "baseURL": "https://your-internal-anthropic-endpoint" } - }, - "logging": { - "level": "info", - "pretty": true } } ``` -Use only internal endpoints supplied by the runtime/integration. Do not use public official provider endpoints in this proxy config. +Use internal endpoints supplied by the runtime/integration. Do not use public official provider endpoints. -If no provider endpoints are available, leave `providers.*.apiKey` and `providers.*.baseURL` empty. The server still boots, `/dashboard` works, `/api/healthz` works, and `/v1/models` works. Chat completion calls return `503` until the target provider has both `apiKey` and `baseURL`. - -3. Start the server: - -```bash -pnpm dev -``` - -The default config path is `config.json`. To use a different file: - -```bash -pnpm dev -- --config ./config.local.json -``` - -## Hosted Deployment - -For a hosted runtime that must bind all interfaces, set: - -```json -{ - "server": { - "host": "0.0.0.0", - "port": 8080 - } -} -``` - -Build and run production output: - -```bash -pnpm build -pnpm start -``` +If provider endpoints are not available, leave config absent. The dashboard, health check, and model list still work. Chat completion calls return `503` until the target provider has both `apiKey` and `baseURL`. ## Routes @@ -103,13 +67,11 @@ curl -s http://localhost:8080/api/healthz curl -s -H "Authorization: Bearer dev-proxy-key" http://localhost:8080/v1/models ``` -Chat completion check: +Expected chat result without provider config: `503` with a message asking for `providers..apiKey` and `providers..baseURL`. + +## Production ```bash -curl -s http://localhost:8080/v1/chat/completions \ - -H "Authorization: Bearer dev-proxy-key" \ - -H "Content-Type: application/json" \ - -d '{"model":"gpt-5.2","messages":[{"role":"user","content":"hello"}]}' +pnpm build +pnpm start ``` - -Expected result without provider config: `503` with a message asking for `providers..apiKey` and `providers..baseURL`. diff --git a/src/lib/config.ts b/src/lib/config.ts index c4cb5eb..6b86ac4 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -26,7 +26,7 @@ export interface AppConfig { const DEFAULT_CONFIG: AppConfig = { server: { - host: "127.0.0.1", + host: "0.0.0.0", port: 8080, }, proxy: {