Compare commits
29 Commits
22bd329ee3
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c4f9cf1b04 | |||
| 012224d40c | |||
| f48b6665bc | |||
| 4ef4925fb6 | |||
| d7a2d520b6 | |||
| 63a5db2a86 | |||
| c927ac8282 | |||
| 563804439e | |||
| 0175ea028a | |||
| 591e716063 | |||
| 933b848076 | |||
| f075cddc4e | |||
| f947c69062 | |||
| 41be842d9f | |||
| 369628345f | |||
| 8747b5bfac | |||
| e61ad2a81a | |||
| 425cd053e5 | |||
| 657f81d4e0 | |||
| da856261f3 | |||
| 5463862d32 | |||
| 934ab43ccc | |||
| c5eca5bdb9 | |||
| 9a19c87251 | |||
| 554ab93df2 | |||
| 878cd1eb3c | |||
| 424b691fef | |||
| 0078ee7e58 | |||
| bee5dc1e01 |
@@ -4,3 +4,4 @@ node_modules/
|
|||||||
config.json
|
config.json
|
||||||
config.local.json
|
config.local.json
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
|
proxy-artifact/
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
run = "PORT=${PORT:-3000} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} pnpm prod"
|
||||||
|
onBoot = "pnpm install --ignore-workspace"
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"server": {
|
|
||||||
"host": "0.0.0.0",
|
|
||||||
"port": 8080
|
|
||||||
},
|
|
||||||
"proxy": {
|
|
||||||
"apiKey": "replace-this-token"
|
|
||||||
},
|
|
||||||
"providers": {
|
|
||||||
"openai": {
|
|
||||||
"apiKey": "internal-openai-token",
|
|
||||||
"baseURL": "https://your-internal-openai-endpoint/v1"
|
|
||||||
},
|
|
||||||
"anthropic": {
|
|
||||||
"apiKey": "internal-anthropic-token",
|
|
||||||
"baseURL": "https://your-internal-anthropic-endpoint"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"logging": {
|
|
||||||
"level": "info",
|
|
||||||
"pretty": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "random-proxy",
|
"name": "random-proxy-simple",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "pnpm@10.33.2",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx src/index.ts",
|
"dev": "tsx src/index.ts",
|
||||||
"build": "tsc --noEmit && node build.mjs",
|
"build": "tsc --noEmit && node build.mjs",
|
||||||
|
"build:fast": "node build.mjs",
|
||||||
|
"prod": "node build.mjs && node --enable-source-maps dist/index.mjs",
|
||||||
"start": "node --enable-source-maps dist/index.mjs",
|
"start": "node --enable-source-maps dist/index.mjs",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,64 +1,85 @@
|
|||||||
# Agent Runbook
|
# Agent Runbook
|
||||||
|
|
||||||
Run this repository as a standalone app. Do not add it to a parent workspace. Do not move it into `artifacts/`. Do not edit source files for setup.
|
This app is already prepared for one-shot deployment. Follow these commands exactly unless one fails.
|
||||||
|
|
||||||
## Setup
|
Do not add this repo to a parent workspace. Do not move it into `artifacts/`. Do not edit source files. Do not edit `package.json`. Do not create `config.json` or a `/tmp` config file for deployment. Do not inspect or free unrelated ports.
|
||||||
|
|
||||||
|
## Replit
|
||||||
|
|
||||||
|
The repo includes `.replit`, so after import the Run button starts the app with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PORT=${PORT:-3000} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} pnpm prod
|
||||||
|
```
|
||||||
|
|
||||||
|
The `.replit` `onBoot` command installs dependencies with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install --ignore-workspace
|
||||||
|
```
|
||||||
|
|
||||||
|
For publishing from a workspace that clones this repo into `./random-proxy-simple`, configure the
|
||||||
|
workspace root `.replit` `[deployment]` block to build and run `random-proxy-simple` directly, then
|
||||||
|
create a shell web artifact so the publish UI has a web target.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
Run from this repository root:
|
Run from this repository root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm install --ignore-workspace
|
pnpm install --ignore-workspace
|
||||||
pnpm dev
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If plain `pnpm` is unavailable, use `corepack pnpm` for the same commands. Do not edit `package.json`.
|
Use the available `pnpm`. This repo intentionally has no `packageManager` pin.
|
||||||
|
|
||||||
The app runs without `config.json`:
|
## Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PORT=${PORT:-3000} PROXY_API_KEY=${PROXY_API_KEY:-dev-proxy-key} pnpm prod
|
||||||
|
```
|
||||||
|
|
||||||
|
When Replit AI Integrations are provisioned, the app reads these variables automatically:
|
||||||
|
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_API_KEY`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_API_KEY`
|
||||||
|
|
||||||
|
Provider CLI flags are still supported for manual overrides, but mass deployments should use env vars:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm start -- \
|
||||||
|
--openai-base-url "<ai-integrations-openai-base-url>" \
|
||||||
|
--openai-api-key "<ai-integrations-openai-api-key>" \
|
||||||
|
--anthropic-base-url "<ai-integrations-anthropic-base-url>" \
|
||||||
|
--anthropic-api-key "<ai-integrations-anthropic-api-key>"
|
||||||
|
```
|
||||||
|
|
||||||
|
Use Replit AI Integrations endpoints only. Never use public official provider endpoints. Do not print provider tokens.
|
||||||
|
|
||||||
|
## Defaults
|
||||||
|
|
||||||
- host: `0.0.0.0`
|
- host: `0.0.0.0`
|
||||||
- port: `8080`
|
- port: `3000`
|
||||||
- bearer token: `dev-proxy-key`
|
- bearer token: `dev-proxy-key`
|
||||||
|
|
||||||
## Optional Provider Config
|
These can be overridden with CLI flags or environment variables:
|
||||||
|
|
||||||
Do not create `config.json` unless internal provider endpoints/tokens are available.
|
- `--host` or `HOST`
|
||||||
|
- `--port` or `PORT`
|
||||||
|
- `--proxy-api-key` or `PROXY_API_KEY`
|
||||||
|
|
||||||
If they are available, create `config.json` in one write with this shape:
|
For mass deployments, pass the generated proxy token through `PROXY_API_KEY`. Replit AI
|
||||||
|
Integration provider values are read from the `AI_INTEGRATIONS_*` environment variables.
|
||||||
```json
|
|
||||||
{
|
|
||||||
"server": {
|
|
||||||
"host": "0.0.0.0",
|
|
||||||
"port": 8080
|
|
||||||
},
|
|
||||||
"proxy": {
|
|
||||||
"apiKey": "dev-proxy-key"
|
|
||||||
},
|
|
||||||
"providers": {
|
|
||||||
"openai": {
|
|
||||||
"apiKey": "",
|
|
||||||
"baseURL": ""
|
|
||||||
},
|
|
||||||
"anthropic": {
|
|
||||||
"apiKey": "",
|
|
||||||
"baseURL": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"logging": {
|
|
||||||
"level": "info",
|
|
||||||
"pretty": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Fill only `providers.openai.apiKey`, `providers.openai.baseURL`, `providers.anthropic.apiKey`, and `providers.anthropic.baseURL`. Use internal endpoints only. Never use public official provider endpoints.
|
|
||||||
|
|
||||||
## Verify
|
## Verify
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -s http://localhost:8080/api/healthz
|
curl -s http://localhost:3000/api/healthz
|
||||||
curl -s http://localhost:8080/dashboard | head
|
curl -s http://localhost:3000/dashboard | head
|
||||||
curl -s -H "Authorization: Bearer dev-proxy-key" http://localhost:8080/v1/models
|
curl -s -H "Authorization: Bearer ${PROXY_API_KEY:-dev-proxy-key}" http://localhost:3000/v1/models
|
||||||
```
|
```
|
||||||
|
|
||||||
Expected without provider config: dashboard, health, and model list work; chat completions return `503`.
|
Expected without provider flags: dashboard, health, and model list work; chat completions return `503`.
|
||||||
|
|
||||||
|
Report only the local URL and verification results.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Standalone TypeScript API server with file-based configuration.
|
Standalone TypeScript API server with Replit run and deployment configuration.
|
||||||
|
|
||||||
## Stack
|
## Stack
|
||||||
|
|
||||||
@@ -11,20 +11,46 @@ Standalone TypeScript API server with file-based configuration.
|
|||||||
- **TypeScript version**: 5.9
|
- **TypeScript version**: 5.9
|
||||||
- **API framework**: Express 5
|
- **API framework**: Express 5
|
||||||
- **Build**: esbuild
|
- **Build**: esbuild
|
||||||
- **Config**: `config.json` by default, or `--config ./path.json`
|
|
||||||
|
|
||||||
## Provider Endpoints
|
## Provider Endpoints
|
||||||
|
|
||||||
Do not configure this proxy with public official provider endpoints. Agents should populate `providers.openai.baseURL` and `providers.anthropic.baseURL` with the internal endpoints supplied by their runtime/integration, along with the matching internal tokens.
|
Use Replit AI Integrations endpoints. The app reads these environment variables automatically:
|
||||||
|
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_API_KEY`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_API_KEY`
|
||||||
|
|
||||||
|
CLI flags are still available for manual overrides:
|
||||||
|
|
||||||
|
- `--openai-base-url`
|
||||||
|
- `--openai-api-key`
|
||||||
|
- `--anthropic-base-url`
|
||||||
|
- `--anthropic-api-key`
|
||||||
|
|
||||||
|
Never use public official provider endpoints.
|
||||||
|
|
||||||
## Key Commands
|
## Key Commands
|
||||||
|
|
||||||
- `pnpm dev` — run API server locally
|
- `pnpm install --ignore-workspace` — install dependencies without joining a parent workspace
|
||||||
- `pnpm dev -- --config ./config.local.json` — run with a custom config file
|
- `pnpm prod` — build and run API server locally on port `3000`
|
||||||
- `pnpm run typecheck` — typecheck the server
|
- `pnpm run typecheck` — typecheck the server
|
||||||
- `pnpm run build` — typecheck and build `dist/index.mjs`
|
- `pnpm run build` — typecheck and build `dist/index.mjs`
|
||||||
|
- `pnpm run build:fast` — build `dist/index.mjs` without typechecking
|
||||||
- `pnpm start` — run the built server
|
- `pnpm start` — run the built server
|
||||||
|
|
||||||
|
## Replit Configuration
|
||||||
|
|
||||||
|
- `.replit` `run` uses `pnpm prod`
|
||||||
|
- `.replit` `onBoot` uses `pnpm install --ignore-workspace`
|
||||||
|
- publishing from a parent workspace should configure root `.replit` deployment and create a shell web artifact
|
||||||
|
|
||||||
|
## Server Overrides
|
||||||
|
|
||||||
|
- `--host` or `HOST`
|
||||||
|
- `--port` or `PORT`
|
||||||
|
- `--proxy-api-key` or `PROXY_API_KEY`
|
||||||
|
|
||||||
## Routes
|
## Routes
|
||||||
|
|
||||||
- `/` and `/dashboard` — static model dashboard
|
- `/` and `/dashboard` — static model dashboard
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
Clone and run https://git.komnenos.me/springfw/random-proxy-simple in ./random-proxy-simple.
|
||||||
|
|
||||||
|
Goal: get the app running once on port 3000 with OpenAI and Anthropic Replit AI Integrations wired.
|
||||||
|
|
||||||
|
Bearer token for this deployment: DEPLOYMENT_GENERATED_PROXY_TOKEN
|
||||||
|
|
||||||
|
Important: wire OpenAI and Anthropic via the ai-integrations-openai and
|
||||||
|
ai-integrations-anthropic skills. Call setupReplitAIIntegrations directly. Do not call
|
||||||
|
searchIntegrations. OpenAI and Anthropic are Replit AI Integrations that provide
|
||||||
|
AI_INTEGRATIONS_* variables; they are not OAuth connectors.
|
||||||
|
|
||||||
|
Do not:
|
||||||
|
- add it to a parent workspace
|
||||||
|
- move it into artifacts/
|
||||||
|
- modify source files
|
||||||
|
- edit package.json
|
||||||
|
- create config.json or /tmp config files
|
||||||
|
- inspect/free unrelated ports
|
||||||
|
- use nohup/setsid/background shell tricks
|
||||||
|
- call searchIntegrations
|
||||||
|
- search the Replit integrations catalog
|
||||||
|
- create provider API secrets manually
|
||||||
|
- use public OpenAI or Anthropic endpoints
|
||||||
|
- invent, rotate, print, store, or replace the bearer token
|
||||||
|
- run a foreground server command directly in the shell
|
||||||
|
- run verification commands
|
||||||
|
- run chat-completion smoke tests unless asked
|
||||||
|
|
||||||
|
Publishability requirement: do not configure production deployment through the artifact system.
|
||||||
|
Configure the workspace root .replit [deployment] section to build and run the cloned proxy
|
||||||
|
directly.
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
|
||||||
|
1. Clone into ./random-proxy-simple.
|
||||||
|
|
||||||
|
2. Wire OpenAI and Anthropic via the ai-integrations-openai and ai-integrations-anthropic
|
||||||
|
skills:
|
||||||
|
- call setupReplitAIIntegrations directly
|
||||||
|
- do not call searchIntegrations
|
||||||
|
|
||||||
|
3. From ./random-proxy-simple, run:
|
||||||
|
pnpm install --ignore-workspace
|
||||||
|
|
||||||
|
4. Create the smallest persistent workflow named "Random Proxy Simple" with this exact run command:
|
||||||
|
|
||||||
|
cd random-proxy-simple && PORT=3000 PROXY_API_KEY=DEPLOYMENT_GENERATED_PROXY_TOKEN pnpm prod
|
||||||
|
|
||||||
|
5. Start/restart that workflow once.
|
||||||
|
|
||||||
|
6. create a shell web artifact to allow publishing.
|
||||||
|
|
||||||
|
7. Do not run health, dashboard, model-list, or chat-completion verification commands.
|
||||||
|
|
||||||
|
Report only:
|
||||||
|
- local URL
|
||||||
|
- whether setupReplitAIIntegrations wired OpenAI and Anthropic
|
||||||
|
- that no verification commands were run
|
||||||
+55
-81
@@ -1,6 +1,3 @@
|
|||||||
import { existsSync, readFileSync } from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
export interface ProviderConfig {
|
export interface ProviderConfig {
|
||||||
baseURL?: string;
|
baseURL?: string;
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
@@ -27,7 +24,7 @@ export interface AppConfig {
|
|||||||
const DEFAULT_CONFIG: AppConfig = {
|
const DEFAULT_CONFIG: AppConfig = {
|
||||||
server: {
|
server: {
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
port: 8080,
|
port: 3000,
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
apiKey: "dev-proxy-key",
|
apiKey: "dev-proxy-key",
|
||||||
@@ -42,95 +39,72 @@ const DEFAULT_CONFIG: AppConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
function argValue(name: string): string | undefined {
|
||||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
const longName = `--${name}`;
|
||||||
}
|
const index = process.argv.findIndex((arg) => arg === longName);
|
||||||
|
if (index >= 0) {
|
||||||
function stringValue(value: unknown): string | undefined {
|
const value = process.argv[index + 1];
|
||||||
return typeof value === "string" && value.length > 0 ? value : undefined;
|
return value && !value.startsWith("--") ? value : undefined;
|
||||||
}
|
|
||||||
|
|
||||||
function booleanValue(value: unknown): boolean | undefined {
|
|
||||||
return typeof value === "boolean" ? value : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function numberValue(value: unknown): number | undefined {
|
|
||||||
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function providerConfig(value: unknown): ProviderConfig {
|
|
||||||
if (!isRecord(value)) return {};
|
|
||||||
return {
|
|
||||||
...(stringValue(value["baseURL"]) ? { baseURL: stringValue(value["baseURL"]) } : {}),
|
|
||||||
...(stringValue(value["apiKey"]) ? { apiKey: stringValue(value["apiKey"]) } : {}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeConfig(raw: unknown): AppConfig {
|
|
||||||
if (!isRecord(raw)) return DEFAULT_CONFIG;
|
|
||||||
|
|
||||||
const server = isRecord(raw["server"]) ? raw["server"] : {};
|
|
||||||
const proxy = isRecord(raw["proxy"]) ? raw["proxy"] : {};
|
|
||||||
const providers = isRecord(raw["providers"]) ? raw["providers"] : {};
|
|
||||||
const logging = isRecord(raw["logging"]) ? raw["logging"] : {};
|
|
||||||
|
|
||||||
const port = numberValue(server["port"]) ?? DEFAULT_CONFIG.server.port;
|
|
||||||
if (!Number.isInteger(port) || port <= 0) {
|
|
||||||
throw new Error(`Invalid config value "server.port": ${port}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inlineArg = process.argv.find((arg) => arg.startsWith(`${longName}=`));
|
||||||
|
return inlineArg ? inlineArg.slice(longName.length + 1) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function argFlag(name: string): boolean {
|
||||||
|
return process.argv.includes(`--${name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function envValue(name: string): string | undefined {
|
||||||
|
const value = process.env[name];
|
||||||
|
return value && value.length > 0 ? value : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyArgOverrides(base: AppConfig): AppConfig {
|
||||||
|
const rawPort = argValue("port") ?? envValue("PORT");
|
||||||
|
const port = rawPort === undefined ? base.server.port : Number(rawPort);
|
||||||
|
if (!Number.isInteger(port) || port <= 0) {
|
||||||
|
throw new Error(`Invalid port value: ${rawPort}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const host = argValue("host") ?? envValue("HOST") ?? base.server.host;
|
||||||
|
const proxyApiKey = argValue("proxy-api-key") ?? envValue("PROXY_API_KEY") ?? base.proxy.apiKey;
|
||||||
|
const openaiBaseURL = argValue("openai-base-url") ?? envValue("AI_INTEGRATIONS_OPENAI_BASE_URL");
|
||||||
|
const openaiApiKey = argValue("openai-api-key") ?? envValue("AI_INTEGRATIONS_OPENAI_API_KEY");
|
||||||
|
const anthropicBaseURL =
|
||||||
|
argValue("anthropic-base-url") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_BASE_URL");
|
||||||
|
const anthropicApiKey =
|
||||||
|
argValue("anthropic-api-key") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_API_KEY");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
server: {
|
server: {
|
||||||
host: stringValue(server["host"]) ?? DEFAULT_CONFIG.server.host,
|
host,
|
||||||
port,
|
port,
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
apiKey: stringValue(proxy["apiKey"]) ?? DEFAULT_CONFIG.proxy.apiKey,
|
apiKey: proxyApiKey,
|
||||||
},
|
},
|
||||||
providers: {
|
providers: {
|
||||||
openai: providerConfig(providers["openai"]),
|
openai: {
|
||||||
anthropic: providerConfig(providers["anthropic"]),
|
...base.providers.openai,
|
||||||
|
...(openaiBaseURL ? { baseURL: openaiBaseURL } : {}),
|
||||||
|
...(openaiApiKey ? { apiKey: openaiApiKey } : {}),
|
||||||
|
},
|
||||||
|
anthropic: {
|
||||||
|
...base.providers.anthropic,
|
||||||
|
...(anthropicBaseURL ? { baseURL: anthropicBaseURL } : {}),
|
||||||
|
...(anthropicApiKey ? { apiKey: anthropicApiKey } : {}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
logging: {
|
logging: {
|
||||||
level: stringValue(logging["level"]) ?? DEFAULT_CONFIG.logging.level,
|
level: argValue("log-level") ?? base.logging.level,
|
||||||
pretty: booleanValue(logging["pretty"]) ?? DEFAULT_CONFIG.logging.pretty,
|
pretty: argFlag("pretty-logs")
|
||||||
|
? true
|
||||||
|
: argFlag("no-pretty-logs")
|
||||||
|
? false
|
||||||
|
: base.logging.pretty,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function configPathFromArgv(): string {
|
export const config = applyArgOverrides(DEFAULT_CONFIG);
|
||||||
const configArgIndex = process.argv.findIndex((arg) => arg === "--config");
|
|
||||||
if (configArgIndex >= 0) {
|
|
||||||
const value = process.argv[configArgIndex + 1];
|
|
||||||
if (!value) {
|
|
||||||
throw new Error("Missing value after --config");
|
|
||||||
}
|
|
||||||
return path.resolve(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
const inlineArg = process.argv.find((arg) => arg.startsWith("--config="));
|
|
||||||
if (inlineArg) {
|
|
||||||
return path.resolve(inlineArg.slice("--config=".length));
|
|
||||||
}
|
|
||||||
|
|
||||||
return path.resolve("config.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadConfig(): AppConfig {
|
|
||||||
const filePath = configPathFromArgv();
|
|
||||||
if (!existsSync(filePath)) {
|
|
||||||
return DEFAULT_CONFIG;
|
|
||||||
}
|
|
||||||
|
|
||||||
let parsed: unknown;
|
|
||||||
try {
|
|
||||||
parsed = JSON.parse(readFileSync(filePath, "utf8"));
|
|
||||||
} catch (err) {
|
|
||||||
const message = err instanceof Error ? err.message : String(err);
|
|
||||||
throw new Error(`Could not read config file ${filePath}: ${message}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergeConfig(parsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const config = loadConfig();
|
|
||||||
|
|||||||
+1
-1
@@ -494,7 +494,7 @@ function errorMessage(err: unknown): string {
|
|||||||
function providerNotConfigured(res: Response, provider: "openai" | "anthropic"): void {
|
function providerNotConfigured(res: Response, provider: "openai" | "anthropic"): void {
|
||||||
res.status(503).json({
|
res.status(503).json({
|
||||||
error: {
|
error: {
|
||||||
message: `${provider} provider is not configured. Add providers.${provider}.apiKey and providers.${provider}.baseURL to config.json. Use the internal endpoint supplied by your runtime or agent, not the public provider endpoint.`,
|
message: `${provider} provider is not configured. Pass the matching Replit AI Integrations CLI flags, not public provider endpoints.`,
|
||||||
type: "server_error",
|
type: "server_error",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user