Files
JohnRiceMLandClaude Opus 4.6 be523cee72 feat: v0.8.0 — configurable gateway port, Agent Optimizer redesign, markdown code blocks
- Add OPENCLAW_GATEWAY_PORT env var support (default 18789) — auto-detected
  from openclaw.json during setup, all API routes use gatewayBaseUrl() helper
- Redesign AI Cost Analysis as "Agent Optimizer" with action chips, structured
  prompts for Max plan users, and follow-up suggestions
- Fix renderMarkdown to handle fenced code blocks (extract before escape,
  reinsert after rules)
- Rewrite buildCostAnalysisPrompt: throughput-focused, structured response
  format, 350 word cap
- Fix efficiency score using effective input (input + cache tokens)
- Unified OptimizationCard with UUID resolution and responsive layout
- Update all docs and in-app help to mention configurable port
- Remove auto-scroll from cost analysis chat
- Change insight button from "Fix" to "How to fix"

Closes #9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:25:07 -05:00

25 lines
799 B
TypeScript

/**
* Safely retrieve a required environment variable at runtime.
* Call inside functions (not at module top level) so imports don't crash during build/test.
*/
export function requireEnv(name: string): string {
const value = process.env[name]
if (!value) {
throw new Error(
`Missing required environment variable: ${name}. ` +
`See .env.example for configuration.`
)
}
return value
}
/** OpenClaw gateway port — reads OPENCLAW_GATEWAY_PORT, defaults to 18789. */
export function gatewayPort(): number {
return parseInt(process.env.OPENCLAW_GATEWAY_PORT || '18789', 10)
}
/** OpenClaw gateway base URL for the OpenAI-compatible API (e.g. http://localhost:18789/v1). */
export function gatewayBaseUrl(): string {
return `http://localhost:${gatewayPort()}/v1`
}