feat(workbench): live LiteLLM gateway adapter + explicit project grants
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 6s
masterplan-lock / check (push) Successful in 6s
CI (SIAX Cloud) / security (push) Successful in 14s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 19s
CI (SIAX Cloud) / security (pull_request) Successful in 21s
Security Scan (SIAX Cloud) / security (push) Successful in 25s
CI (SIAX Cloud) / integration (pull_request) Successful in 29s
CI (SIAX Cloud) / quality (pull_request) Successful in 51s
CI (SIAX Cloud) / quality (push) Successful in 1m29s

- createInf0Gateway prefers the live OpenAI-compatible LiteLLM gateway and
  falls back to the native INF0 surface; admission stays local and fail-closed.
- Project authorization: OpenFGA when configured, otherwise a validated
  server-owned OPT_PROJECT_GRANTS list (deny by default).
- Tests for the gateway adapter, the factory and grants.
This commit is contained in:
2026-11-02 14:50:50 +01:00
parent b3239487b7
commit e3c4bc28c3
8 changed files with 525 additions and 12 deletions
+43
View File
@@ -0,0 +1,43 @@
/**
* Resolve the live INF0 inference path.
*
* Preference order:
* 1. INF0_GATEWAY_LITELLM_KEY + INF0_GATEWAY_URL (live LiteLLM, used today)
* 2. INF0_URL + INF0_API_TOKEN (native `/v1/inf0/*` surface, contract-only)
*
* Returns `undefined` when neither is configured, so the caller can fail
* closed with an explicit "not configured" response.
*/
import { Inf0GatewayClient } from './inf0-gateway-client';
import { LiteLlmGatewayClient } from './litellm-gateway-client';
import { isTrustedHttpsUrl } from './runtime-config';
export interface Inf0Gateway {
complete(input: Parameters<Inf0GatewayClient['complete']>[0]): ReturnType<Inf0GatewayClient['complete']>;
}
export function createInf0Gateway(env: NodeJS.ProcessEnv = process.env): Inf0Gateway | undefined {
const litellmKey = env.INF0_GATEWAY_LITELLM_KEY?.trim();
const litellmUrl = env.INF0_GATEWAY_URL?.trim() || 'https://ai-gateway.siax.io/v1';
if (litellmKey && isTrustedHttpsUrl(litellmUrl)) {
try {
return new LiteLlmGatewayClient({
baseUrl: litellmUrl,
apiKey: litellmKey,
providerKind: env.INF0_GATEWAY_PROVIDER_KIND === 'local' ? 'local' : 'external',
});
} catch {
return undefined;
}
}
const baseUrl = env.INF0_URL ?? env.INF0_API_URL;
const token = env.INF0_API_TOKEN ?? env.INF0_SERVICE_TOKEN;
if (isTrustedHttpsUrl(baseUrl) && token?.trim()) {
try {
return new Inf0GatewayClient({ baseUrl, serviceToken: token.trim() });
} catch {
return undefined;
}
}
return undefined;
}