Migrate AI runtime to SDK and hardcode Zhipu coding endpoint

This commit is contained in:
2026-02-28 13:59:00 -05:00
parent abae5e7486
commit b9f3b7f9d0
14 changed files with 453 additions and 243 deletions

View File

@@ -1,6 +1,6 @@
# Fiscal Clone 3.0
Turbopack-first rebuild of a fiscal.ai-style terminal with OpenClaw integration.
Turbopack-first rebuild of a fiscal.ai-style terminal with Vercel AI SDK integration.
## Stack
@@ -14,7 +14,7 @@ Turbopack-first rebuild of a fiscal.ai-style terminal with OpenClaw integration.
- Eden Treaty for type-safe frontend API calls
- Workflow DevKit Local World for background task execution
- SQLite-backed domain storage (watchlist, holdings, filings, tasks, insights)
- OpenClaw/ZeroClaw analysis via OpenAI-compatible chat endpoint
- Vercel AI SDK (`ai`) + Zhipu community provider (`zhipu-ai-provider`) for analysis tasks (hardcoded to `https://api.z.ai/api/coding/paas/v4`)
## Run locally
@@ -44,10 +44,8 @@ cp .env.example .env
docker compose up --build -d
```
For local Docker, host port mapping comes from `docker-compose.override.yml` (default `http://localhost:3000` via `APP_PORT`, and `http://localhost:4000` for OpenClaw via `OPENCLAW_PORT`).
OpenClaw is included as a Compose service (`openclaw`) and is built by default from `OPENCLAW_BUILD_CONTEXT` (set to `Francy51/coolify_ZeroClaw` in `.env.example`).
If that Gitea repo is private, set `OPENCLAW_BUILD_CONTEXT` with embedded credentials (`https://<username>:<token>@.../coolify_ZeroClaw.git`) or point `OPENCLAW_IMAGE` to a prebuilt image you can pull.
The app container defaults to `OPENCLAW_BASE_URL=http://openclaw:4000` unless you explicitly set a different `OPENCLAW_BASE_URL`.
For local Docker, host port mapping comes from `docker-compose.override.yml` (default `http://localhost:3000` via `APP_PORT`).
The app calls Zhipu directly via AI SDK and always targets the Coding API endpoint (`https://api.z.ai/api/coding/paas/v4`), so no extra AI gateway container is required.
On container startup, the app applies Drizzle migrations automatically before launching Next.js.
The app stores SQLite data in Docker volume `fiscal_sqlite_data` (mounted to `/app/data`) and workflow local data in `fiscal_workflow_data` (mounted to `/app/.workflow-data`).
@@ -88,19 +86,10 @@ BETTER_AUTH_SECRET=replace-with-a-long-random-secret
BETTER_AUTH_BASE_URL=https://fiscal.b11studio.xyz
BETTER_AUTH_TRUSTED_ORIGINS=https://fiscal.b11studio.xyz
OPENCLAW_BASE_URL=
OPENCLAW_API_KEY=
OPENCLAW_MODEL=zeroclaw
OPENCLAW_AUTH_MODE=none
OPENCLAW_PORT=4000
OPENCLAW_IMAGE=coolify-zeroclaw:local
OPENCLAW_BUILD_CONTEXT=https://gitea-hs848cs8kgs840o8c8s8cwkk.b11studio.xyz/Francy51/coolify_ZeroClaw.git
OPENCLAW_DOCKERFILE=Dockerfile
# for OPENCLAW_AUTH_MODE=basic
# OPENCLAW_BASIC_AUTH_USERNAME=your_nginx_user
# OPENCLAW_BASIC_AUTH_PASSWORD=your_nginx_password
# optional: forward API key in a custom header when using basic/none auth
# OPENCLAW_API_KEY_HEADER=X-OpenClaw-API-Key
ZHIPU_API_KEY=
ZHIPU_MODEL=glm-4.7-flashx
# optional generation tuning
AI_TEMPERATURE=0.2
SEC_USER_AGENT=Fiscal Clone <support@fiscal.local>
WORKFLOW_TARGET_WORLD=local
@@ -108,19 +97,27 @@ WORKFLOW_LOCAL_DATA_DIR=.workflow-data
WORKFLOW_LOCAL_QUEUE_CONCURRENCY=100
```
If OpenClaw is unset or invalidly configured, the app uses local fallback analysis so task workflows still run.
If `ZHIPU_API_KEY` is unset, the app uses local fallback analysis so task workflows still run.
`ZHIPU_BASE_URL` is deprecated and ignored; runtime always uses `https://api.z.ai/api/coding/paas/v4`.
For OpenClaw behind Nginx Basic Auth, use:
## Migration from OPENCLAW_* to ZHIPU_*
```env
OPENCLAW_BASE_URL=https://your-nginx-host
OPENCLAW_AUTH_MODE=basic
OPENCLAW_BASIC_AUTH_USERNAME=your_nginx_user
OPENCLAW_BASIC_AUTH_PASSWORD=your_nginx_password
# optional if upstream still needs an API key in a non-Authorization header
OPENCLAW_API_KEY=your_key
OPENCLAW_API_KEY_HEADER=X-OpenClaw-API-Key
```
This repository now uses direct provider calls through AI SDK. The legacy gateway container path is removed.
The AI runtime endpoint is fixed to `https://api.z.ai/api/coding/paas/v4`.
| Legacy variable | Replacement |
| --- | --- |
| `OPENCLAW_API_KEY` | `ZHIPU_API_KEY` |
| `OPENCLAW_MODEL` | `ZHIPU_MODEL` |
| `OPENCLAW_BASE_URL` | Removed (runtime endpoint is hardcoded to `https://api.z.ai/api/coding/paas/v4`) |
| `OPENCLAW_AUTH_MODE` | Removed (not needed with direct provider calls) |
| `OPENCLAW_BASIC_AUTH_USERNAME` | Removed |
| `OPENCLAW_BASIC_AUTH_PASSWORD` | Removed |
| `OPENCLAW_API_KEY_HEADER` | Removed |
| `OPENCLAW_PORT` | Removed (no gateway service) |
| `OPENCLAW_IMAGE` | Removed |
| `OPENCLAW_BUILD_CONTEXT` | Removed |
| `OPENCLAW_DOCKERFILE` | Removed |
## API surface