Streamline agent setup

This commit is contained in:
hwhung
2026-04-27 11:55:31 +08:00
parent af74853254
commit 3782902257
5 changed files with 28 additions and 64 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"server": { "server": {
"host": "127.0.0.1", "host": "0.0.0.0",
"port": 8080 "port": 8080
}, },
"proxy": { "proxy": {
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "@workspace/api-server", "name": "random-proxy",
"version": "0.0.0", "version": "0.0.0",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
+2
View File
@@ -0,0 +1,2 @@
packages:
- "."
+23 -61
View File
@@ -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 ## Run Exactly
1. Install dependencies:
```bash ```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 ```bash
cp config.example.json config.json cp config.example.json config.json
``` ```
Replace provider values when internal endpoints are available: Then fill only these values:
```json ```json
{ {
"server": {
"host": "127.0.0.1",
"port": 8080
},
"proxy": {
"apiKey": "dev-proxy-key"
},
"providers": { "providers": {
"openai": { "openai": {
"apiKey": "internal-openai-token", "apiKey": "internal-openai-token",
@@ -38,49 +38,13 @@ Replace provider values when internal endpoints are available:
"apiKey": "internal-anthropic-token", "apiKey": "internal-anthropic-token",
"baseURL": "https://your-internal-anthropic-endpoint" "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`. 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`.
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
```
## Routes ## 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 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.<name>.apiKey` and `providers.<name>.baseURL`.
## Production
```bash ```bash
curl -s http://localhost:8080/v1/chat/completions \ pnpm build
-H "Authorization: Bearer dev-proxy-key" \ pnpm start
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.2","messages":[{"role":"user","content":"hello"}]}'
``` ```
Expected result without provider config: `503` with a message asking for `providers.<name>.apiKey` and `providers.<name>.baseURL`.
+1 -1
View File
@@ -26,7 +26,7 @@ export interface AppConfig {
const DEFAULT_CONFIG: AppConfig = { const DEFAULT_CONFIG: AppConfig = {
server: { server: {
host: "127.0.0.1", host: "0.0.0.0",
port: 8080, port: 8080,
}, },
proxy: { proxy: {