mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
feat(codex): support explicit local model catalog configuration (#2266)
* fix(codex): reuse local model catalogs by default * fix(codex): verify catalog provenance and native schema before reuse * fix(codex): keep refresh credentials out of discovery homes * refactor(codex): reduce catalog support to explicit configuration * fix(codex): invalidate selected catalogs and resolve shim names
This commit is contained in:
@@ -4,6 +4,7 @@ import { readFile } from 'node:fs/promises';
|
||||
import { join, resolve } from 'node:path';
|
||||
import type { CodexModelsResponse, CodexModelSummary } from '@hapi/protocol/apiTypes';
|
||||
import { CodexAppServerClient } from '@/codex/codexAppServerClient';
|
||||
import { resolveModelCatalogArgs } from '@/codex/utils/modelCatalog';
|
||||
import { resolveCodexHome } from '@/codex/utils/codexHome';
|
||||
import { getErrorMessage } from './rpcResponses';
|
||||
|
||||
@@ -114,7 +115,10 @@ async function catalogFingerprint(): Promise<string> {
|
||||
const rootConfig = config?.toString('utf8').split(/^\s*\[/m, 1)[0] ?? '';
|
||||
const rawPath = rootConfig.match(/^\s*model_catalog_json\s*=\s*("(?:[^"\\]|\\.)*"|'[^']*')/m)?.[1];
|
||||
let catalogPath: string | undefined;
|
||||
if (rawPath) {
|
||||
const override = resolveModelCatalogArgs();
|
||||
if (override.length) {
|
||||
catalogPath = JSON.parse(override[1].slice('model_catalog_json='.length)) as string;
|
||||
} else if (rawPath) {
|
||||
catalogPath = rawPath.startsWith('"') ? JSON.parse(rawPath) as string : rawPath.slice(1, -1);
|
||||
}
|
||||
const catalog = catalogPath ? await readOptionalFile(resolve(home, catalogPath)) : null;
|
||||
|
||||
Reference in New Issue
Block a user