AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。 含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@aigateway/api-client",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": "./src/index.ts"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
export interface HealthResponse {
|
||||
status: 'ok'
|
||||
version: string
|
||||
}
|
||||
|
||||
export interface ReadinessComponent {
|
||||
status: 'ok' | 'unavailable' | 'not_configured'
|
||||
required: boolean
|
||||
latency_ms: number
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ReadinessResponse {
|
||||
ready: boolean
|
||||
status: 'ok' | 'degraded' | 'unavailable'
|
||||
components: Record<string, ReadinessComponent>
|
||||
}
|
||||
|
||||
export class GatewaySystemClient {
|
||||
constructor(private readonly baseURL = '') {}
|
||||
|
||||
health(signal?: AbortSignal): Promise<HealthResponse> {
|
||||
return this.get<HealthResponse>('/healthz', signal)
|
||||
}
|
||||
|
||||
readiness(signal?: AbortSignal): Promise<ReadinessResponse> {
|
||||
return this.get<ReadinessResponse>('/readyz', signal)
|
||||
}
|
||||
|
||||
private async get<T>(path: string, signal?: AbortSignal): Promise<T> {
|
||||
const response = await fetch(`${this.baseURL}${path}`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
signal
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw new Error(`gateway request failed: ${response.status}`)
|
||||
}
|
||||
return (await response.json()) as T
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user