原因:任务标准结果中的 Base64、Data URI 和 Buffer 会进入 PostgreSQL JSON,导致 TOAST 与备份体积快速增长。 影响:新增统一 JSON 持久化关口;upload_none 将二进制原子写入本地结果目录,数据库仅保存带 SHA-256 的有界占位符;任务详情、同步响应、异步查询和兼容协议按需校验恢复。补充 24 小时清理、容量上限、历史小批量治理命令及管理端说明。 风险:本地结果超过 TTL、丢失或损坏时分别返回明确的 410/500;空间不足时返回 503 且不重试上游。未自动执行历史治理。 验证:三种真实图片模型同步/异步与幂等重放通过;Go vet/全量测试、前端 111 测试、lint/typecheck/build、OpenAPI、迁移安全、govulncheck、依赖审计、手工发布测试及 Linux amd64 构建通过。
90 lines
4.3 KiB
Bash
90 lines
4.3 KiB
Bash
APP_ENV=development
|
|
HTTP_ADDR=:8088
|
|
|
|
# Reuse the same PostgreSQL 18 instance as Agent memory, but use an independent
|
|
# database. When running from the host, use the externally reachable host/port.
|
|
AI_GATEWAY_DATABASE_NAME=easyai_ai_gateway
|
|
AI_GATEWAY_DATABASE_URL=postgresql://easyai:easyai2025@localhost:5432/easyai_ai_gateway?sslmode=disable
|
|
|
|
# When running inside the EasyAI docker network, use the container DNS name:
|
|
# AI_GATEWAY_DATABASE_URL=postgresql://easyai:easyai2025@easyai-pgvector:5432/easyai_ai_gateway?schema=public
|
|
#
|
|
# If AI_GATEWAY_DATABASE_URL is omitted, the service can derive host/user/pass
|
|
# from MEMORY_DATABASE_URL but will still replace the database with
|
|
# AI_GATEWAY_DATABASE_NAME.
|
|
# MEMORY_DATABASE_URL=postgresql://easyai:easyai2025@easyai-pgvector:5432/easyai_memory?schema=public
|
|
|
|
# Keep this aligned with easyai-server-main CONFIG_JWT_SECRET in the first migration phase.
|
|
CONFIG_JWT_SECRET=this is a very secret secret
|
|
|
|
# Identity mode:
|
|
# - standalone: Gateway owns users, groups, login/API keys, wallet, recharge, and local billing.
|
|
# - server-main: server-main owns users/API keys/billing; Gateway stores synced users/groups for policy execution.
|
|
# - hybrid: both sources are accepted and separated by gateway_users.source.
|
|
IDENTITY_MODE=hybrid
|
|
|
|
# Billing engine rollout mode:
|
|
# - observe: keep legacy billing decisions and compare effective-pricing-v2 in logs.
|
|
# - enforce: require v2 pricing, reserve the candidate maximum, then settle asynchronously.
|
|
# - hold: reject new production generation before any upstream request; existing settlements continue.
|
|
BILLING_ENGINE_MODE=observe
|
|
|
|
# River 执行 worker 会按平台模型和活跃用户组中更严格的 concurrent 总量每 5 秒重算。
|
|
# hard limit 是单进程安全边界;平台模型/用户组 concurrency lease 才是业务并发真值。
|
|
AI_GATEWAY_ASYNC_WORKER_HARD_LIMIT=2048
|
|
AI_GATEWAY_ASYNC_WORKER_REFRESH_INTERVAL_SECONDS=5
|
|
|
|
# Unified identity business settings are managed in System Settings > Unified
|
|
# Identity. Deployment only supplies the SecretStore and infrastructure timing.
|
|
AI_GATEWAY_PUBLIC_BASE_URL=http://localhost:8088
|
|
IDENTITY_SECRET_STORE=file
|
|
IDENTITY_SECRET_DIR=.local-secrets/identity
|
|
# Kubernetes uses one pre-provisioned empty Secret and narrowly scoped RBAC.
|
|
# IDENTITY_SECRET_STORE=kubernetes
|
|
# IDENTITY_KUBERNETES_NAMESPACE=easyai
|
|
# IDENTITY_KUBERNETES_SECRET_NAME=easyai-gateway-identity
|
|
# IDENTITY_KUBERNETES_API_SERVER=https://kubernetes.default.svc
|
|
IDENTITY_SECURITY_EVENTS_HEARTBEAT_INTERVAL_SECONDS=60
|
|
IDENTITY_SECURITY_EVENTS_STALE_AFTER_SECONDS=180
|
|
IDENTITY_SECURITY_EVENTS_CLOCK_SKEW_SECONDS=60
|
|
AI_GATEWAY_WEB_BASE_URL=http://localhost:5178
|
|
AI_GATEWAY_WEB_BASE_PATH=/
|
|
AI_GATEWAY_GO_BUILD_IMAGE=golang:1.26.3-alpine
|
|
AI_GATEWAY_API_RUNTIME_IMAGE=alpine:3.22
|
|
AI_GATEWAY_NODE_BUILD_IMAGE=node:22-alpine
|
|
AI_GATEWAY_WEB_RUNTIME_IMAGE=nginx:1.27-alpine
|
|
|
|
# Opt-in, billable China Kling V1 integration tests. Keep real AK/SK only in
|
|
# .env.local (gitignored); never commit them.
|
|
KELING_LIVE_TEST=0
|
|
KELING_TEST_BASE_URL=https://api-beijing.klingai.com/v1
|
|
KELING_TEST_ACCESS_KEY=
|
|
KELING_TEST_SECRET_KEY=
|
|
|
|
# Used when the gateway delegates OpenAPI sk-* validation, user/group sync, file upload, and settlement callbacks.
|
|
SERVER_MAIN_BASE_URL=http://localhost:3000
|
|
SERVER_MAIN_INTERNAL_TOKEN=change-me
|
|
SERVER_MAIN_INTERNAL_KEY=gateway
|
|
SERVER_MAIN_INTERNAL_SECRET=change-me
|
|
|
|
# Gateway writes progress events locally, then calls this server-main endpoint.
|
|
# server-main receives the callback and pushes it through the existing WebSocket gateway.
|
|
TASK_PROGRESS_CALLBACK_ENABLED=true
|
|
TASK_PROGRESS_CALLBACK_URL=http://localhost:3000/internal/platform/task-progress-callbacks
|
|
TASK_PROGRESS_CALLBACK_TIMEOUT_MS=5000
|
|
TASK_PROGRESS_CALLBACK_MAX_ATTEMPTS=10
|
|
# First deploy with cleanup disabled; enable only after compatibility and
|
|
# asynchronous-resume verification has passed.
|
|
AI_GATEWAY_TASK_CLEANUP_ENABLED=false
|
|
AI_GATEWAY_TASK_RETENTION_DAYS=30
|
|
AI_GATEWAY_TASK_ANALYSIS_RETENTION_DAYS=7
|
|
AI_GATEWAY_TASK_CLEANUP_INTERVAL_SECONDS=300
|
|
AI_GATEWAY_TASK_CLEANUP_BATCH_SIZE=1000
|
|
AI_GATEWAY_LOCAL_RESULT_TTL_HOURS=24
|
|
AI_GATEWAY_LOCAL_RESULT_MIN_FREE_BYTES=10737418240
|
|
AI_GATEWAY_LOCAL_RESULT_MAX_BYTES=268435456
|
|
AI_GATEWAY_LOCAL_RESULT_MAX_TASK_BYTES=536870912
|
|
|
|
CORS_ALLOWED_ORIGIN=http://localhost:5178,http://127.0.0.1:5178
|
|
VITE_GATEWAY_API_BASE_URL=http://localhost:8088
|