Skip to content

Commit 3637b65

Browse files
refactor(provider-core): expose model metadata through a ModelCatalog port
Antigravity, Claude, and Codex read the server's ModelManifest service directly, so they could not leave apps/server. The manifest itself (bundle, remote refresh, disk cache, compatibility policies) stays with the server; providers now see only their own catalog entry through @t3tools/provider-core/server/ModelCatalog: - current(driverKind) / bundled(driverKind): the driver's catalog from the manifest in memory or the bundle. Never fetches. - refreshInBackground: the TTL-gated remote refresh drivers start from provider checks. - Pure helpers: classifyCatalogModels, applyCatalogDefault, applyModelCatalog, catalogServerModel, with an optional CatalogMatching so a driver maps its slugs to catalog families. Provider-specific branches leave the generic code: Codex's family matching and update-required models move to codexModelCatalog.ts, and Claude's catalog resolves from its ProviderCatalog entry. The server's ModelManifest module provides the port (layerModelCatalog), and its layerTest provides both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a669827 commit 3637b65

14 files changed

Lines changed: 579 additions & 449 deletions

‎apps/server/src/provider/ClaudeModelCatalog.test.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import { ProviderInstanceId } from "@t3tools/contracts";
2+
import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts";
33

44
import { hasValidClaudeManifestAdapters } from "./ClaudeModelManifest.ts";
5-
import type { ModelManifestData } from "./ModelManifest.ts";
5+
import { resolveProviderCatalog, type ModelManifestData } from "./ModelManifest.ts";
66
import {
77
formatClaudeVersionUpgradeMessage,
88
normalizeClaudeCatalogEffort,
@@ -71,11 +71,17 @@ const manifest = (): ModelManifestData => ({
7171
},
7272
});
7373

74+
const CLAUDE = ProviderDriverKind.make("claudeAgent");
75+
76+
/** Resolves Claude's catalog the way the driver does: through its manifest catalog entry. */
77+
const catalogFromManifest = (data: ModelManifestData) =>
78+
resolveClaudeModelCatalog(resolveProviderCatalog(data, CLAUDE) ?? undefined);
79+
7480
describe("Claude model catalog", () => {
7581
it("resolves capacity from selected options and fixed catalog windows without guessing custom models", () => {
7682
const source = manifest();
7783
const profile = source.providers!.claudeAgent!.profiles.synthetic!;
78-
const catalog = resolveClaudeModelCatalog({
84+
const catalog = catalogFromManifest({
7985
...source,
8086
providers: {
8187
claudeAgent: {
@@ -121,7 +127,7 @@ describe("Claude model catalog", () => {
121127
});
122128

123129
it("filters models at runtime-version boundaries and derives the upgrade message", () => {
124-
const catalog = resolveClaudeModelCatalog(manifest());
130+
const catalog = catalogFromManifest(manifest());
125131
assert.deepStrictEqual(resolveClaudeModelsForVersion(catalog, "3.1.9"), []);
126132
assert.deepStrictEqual(
127133
resolveClaudeModelsForVersion(catalog, "3.2.0").map((model) => model.slug),
@@ -157,7 +163,7 @@ describe("Claude model catalog", () => {
157163
},
158164
},
159165
};
160-
const catalog = resolveClaudeModelCatalog(input);
166+
const catalog = catalogFromManifest(input);
161167
assert.strictEqual(resolveClaudeModelSlug(catalog, "synthetic"), "claude-synthetic-next");
162168
assert.strictEqual(
163169
resolveClaudeModelSlug(catalog, "claude-synthetic-next"),
@@ -195,7 +201,7 @@ describe("Claude model catalog", () => {
195201
});
196202

197203
it("appends custom models with their own descriptors and keeps bare slugs opaque", () => {
198-
const catalog = scopeClaudeModelCatalog(resolveClaudeModelCatalog(manifest()), [
204+
const catalog = scopeClaudeModelCatalog(catalogFromManifest(manifest()), [
199205
"synthetic",
200206
{
201207
slug: "claude-custom-tuned",

‎apps/server/src/provider/ClaudeModelCatalog.ts‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ import {
2121
decodeClaudeModelAdapter,
2222
decodeClaudeProfileAdapter,
2323
} from "./ClaudeModelManifest.ts";
24-
import {
25-
BUNDLED_MODEL_MANIFEST,
26-
type ModelManifestData,
27-
resolveProviderCatalog,
28-
} from "./ModelManifest.ts";
24+
import * as ModelCatalog from "@t3tools/provider-core/server/ModelCatalog";
25+
import { BUNDLED_MODEL_MANIFEST, resolveProviderCatalog } from "./ModelManifest.ts";
2926

3027
const CLAUDE = ProviderDriverKind.make("claudeAgent");
3128
const EMPTY_CAPABILITIES: ModelCapabilities = { optionDescriptors: [] };
@@ -40,8 +37,9 @@ export interface ClaudeModelCatalog {
4037
readonly models: ReadonlyArray<ClaudeCatalogModel>;
4138
}
4239

43-
function tryResolveClaudeModelCatalog(manifest: ModelManifestData): ClaudeModelCatalog | null {
44-
const resolved = resolveProviderCatalog(manifest, CLAUDE);
40+
function tryResolveClaudeModelCatalog(
41+
resolved: ModelCatalog.ProviderCatalog | undefined,
42+
): ClaudeModelCatalog | null {
4543
if (!resolved) return null;
4644

4745
const models: Array<ClaudeCatalogModel> = [];
@@ -50,7 +48,7 @@ function tryResolveClaudeModelCatalog(manifest: ModelManifestData): ClaudeModelC
5048
const adapter = decodeClaudeModelAdapter(entry.adapter ?? {});
5149
if (Option.isNone(profile) || Option.isNone(adapter)) return null;
5250
models.push({
53-
model: entry.model,
51+
model: ModelCatalog.catalogServerModel(resolved, entry),
5452
runtime: profile.value.claudeCode ?? {},
5553
compatibility: adapter.value.claudeCode ?? {},
5654
});
@@ -61,16 +59,27 @@ function tryResolveClaudeModelCatalog(manifest: ModelManifestData): ClaudeModelC
6159
};
6260
}
6361

64-
export function resolveClaudeModelCatalog(manifest: ModelManifestData): ClaudeModelCatalog {
62+
const BUNDLED_CLAUDE_PROVIDER_CATALOG =
63+
resolveProviderCatalog(BUNDLED_MODEL_MANIFEST, CLAUDE) ?? undefined;
64+
65+
/**
66+
* Claude's built-in catalog from its manifest entry, falling back to the
67+
* bundled entry when the current one is missing or has invalid adapters.
68+
*/
69+
export function resolveClaudeModelCatalog(
70+
catalog: ModelCatalog.ProviderCatalog | undefined,
71+
): ClaudeModelCatalog {
6572
return (
66-
tryResolveClaudeModelCatalog(manifest) ??
67-
tryResolveClaudeModelCatalog(BUNDLED_MODEL_MANIFEST) ?? {
73+
tryResolveClaudeModelCatalog(catalog) ??
74+
tryResolveClaudeModelCatalog(BUNDLED_CLAUDE_PROVIDER_CATALOG) ?? {
6875
models: [],
6976
}
7077
);
7178
}
7279

73-
export const BUNDLED_CLAUDE_MODEL_CATALOG = resolveClaudeModelCatalog(BUNDLED_MODEL_MANIFEST);
80+
export const BUNDLED_CLAUDE_MODEL_CATALOG = resolveClaudeModelCatalog(
81+
BUNDLED_CLAUDE_PROVIDER_CATALOG,
82+
);
7483

7584
/**
7685
* Scope the catalog to one instance's settings: custom model slugs stay opaque

‎apps/server/src/provider/Drivers/AntigravityDriver.ts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { makeAcpNativeLoggerFactory } from "@t3tools/provider-acp/server/nativeL
5252
import { ProviderDriverError } from "../Errors.ts";
5353
import { makeAntigravityProvider } from "../AntigravityProvider.ts";
5454
import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
55-
import * as ModelManifest from "../ModelManifest.ts";
55+
import * as ModelCatalog from "@t3tools/provider-core/server/ModelCatalog";
5656
import {
5757
defaultProviderContinuationIdentity,
5858
type ProviderDriver,
@@ -73,7 +73,7 @@ export type AntigravityDriverEnv =
7373
| Crypto.Crypto
7474
| FileSystem.FileSystem
7575
| IdAllocator.IdAllocatorV2
76-
| ModelManifest.ModelManifest
76+
| ModelCatalog.ModelCatalog
7777
| Path.Path
7878
| ProviderEventLoggers.ProviderEventLoggers;
7979

@@ -93,7 +93,8 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
9393
const selfInvocation = yield* resolveSelfInvocation();
9494
const installation = yield* AntigravityInstallation.AntigravityInstallation;
9595
const loggers = yield* ProviderEventLoggers.ProviderEventLoggers;
96-
const modelManifest = yield* ModelManifest.ModelManifest;
96+
const modelCatalog = yield* ModelCatalog.ModelCatalog;
97+
const currentCatalog = modelCatalog.current(DRIVER);
9798
const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
9899
const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
99100
const settings = { ...config, enabled } satisfies AntigravitySettings;
@@ -146,10 +147,8 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
146147
continuationGroupKey: continuationIdentity.continuationKey,
147148
});
148149
const classifyModels = (draft: ServerProviderDraft) =>
149-
modelManifest.current.pipe(
150-
Effect.map((manifest) =>
151-
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER)),
152-
),
150+
currentCatalog.pipe(
151+
Effect.map((catalog) => stampIdentity(ModelCatalog.applyModelCatalog(draft, catalog))),
153152
);
154153

155154
const makeRuntime = Effect.fn("AntigravityDriver.makeRuntime")(function* (
@@ -336,7 +335,7 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
336335
// and version. The response below is synthetic: only agentInfo.version
337336
// is read from it. Sessions and manual refreshes still spawn.
338337
const probe = Effect.gen(function* () {
339-
yield* modelManifest.refreshInBackground;
338+
yield* modelCatalog.refreshInBackground;
340339
if (authConfigIssue !== null) {
341340
return yield* new ProviderSetupError({
342341
instanceId,
@@ -393,9 +392,7 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
393392
}),
394393
),
395394
);
396-
const defaultModel = modelManifest.current.pipe(
397-
Effect.map((manifest) => ModelManifest.manifestDefaultModel(manifest, DRIVER)),
398-
);
395+
const defaultModel = currentCatalog.pipe(Effect.map((catalog) => catalog?.defaultChatModel));
399396
const orchestrationAdapter = yield* makeAntigravityAdapterV2({
400397
instanceId,
401398
selfInvocation,

‎apps/server/src/provider/Drivers/ClaudeDriver.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
probeClaudeWorkspaceSnapshot,
4444
} from "../ClaudeProvider.ts";
4545
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
46-
import * as ModelManifest from "../ModelManifest.ts";
46+
import * as ModelCatalog from "@t3tools/provider-core/server/ModelCatalog";
4747
import { resolveClaudeModelCatalog } from "../ClaudeModelCatalog.ts";
4848
import {
4949
defaultProviderContinuationIdentity,
@@ -100,7 +100,7 @@ export type ClaudeDriverEnv =
100100
| Crypto.Crypto
101101
| FileSystem.FileSystem
102102
| HttpClient.HttpClient
103-
| ModelManifest.ModelManifest
103+
| ModelCatalog.ModelCatalog
104104
| Path.Path
105105
| ProviderEventLoggers.ProviderEventLoggers
106106
| ServerConfig.ServerConfig;
@@ -122,8 +122,10 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
122122
const httpClient = yield* HttpClient.HttpClient;
123123
const resetCreditCoordinator = yield* ResetCreditCoordinator.ResetCreditCoordinator;
124124
const host = yield* ProviderHost;
125-
const modelManifest = yield* ModelManifest.ModelManifest;
126-
const modelCatalog = modelManifest.current.pipe(Effect.map(resolveClaudeModelCatalog));
125+
const catalogService = yield* ModelCatalog.ModelCatalog;
126+
const modelCatalog = catalogService
127+
.current(DRIVER_KIND)
128+
.pipe(Effect.map(resolveClaudeModelCatalog));
127129
const processEnv = mergeProviderInstanceEnvironment(environment);
128130
const fallbackContinuationIdentity = defaultProviderContinuationIdentity({
129131
driverKind: DRIVER_KIND,
@@ -208,16 +210,16 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
208210

209211
// Start the TTL-gated refresh without delaying provider readiness. The
210212
// next check observes a remote manifest after the background fetch lands.
211-
const checkProvider = modelManifest.refreshInBackground.pipe(
213+
const checkProvider = catalogService.refreshInBackground.pipe(
212214
Effect.andThen(
213-
modelManifest.current.pipe(
214-
Effect.flatMap((manifest) =>
215+
modelCatalog.pipe(
216+
Effect.flatMap((catalog) =>
215217
checkClaudeProviderStatus(
216218
effectiveConfig,
217219
() => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),
218220
processEnv,
219221
cwd,
220-
resolveClaudeModelCatalog(manifest),
222+
catalog,
221223
scopedLimitNames,
222224
(version) =>
223225
ClaudeResetCredits.readClaudeResetCredits(configDir, version).pipe(
@@ -242,10 +244,8 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
242244
streamSettings: snapshotSettings.streamSettings,
243245
haveSettingsChanged: haveProviderSnapshotSettingsChanged,
244246
initialSnapshot: (settings) =>
245-
modelManifest.current.pipe(
246-
Effect.flatMap((manifest) =>
247-
makePendingClaudeProvider(settings.provider, resolveClaudeModelCatalog(manifest)),
248-
),
247+
modelCatalog.pipe(
248+
Effect.flatMap((catalog) => makePendingClaudeProvider(settings.provider, catalog)),
249249
Effect.map(stampIdentity),
250250
),
251251
checkProvider,

‎apps/server/src/provider/Drivers/CodexDriver.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import {
4949
} from "../CodexProvider.ts";
5050
import { resolveCodexLaunchArgs } from "../codexLaunchArgs.ts";
5151
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
52-
import * as ModelManifest from "../ModelManifest.ts";
52+
import * as ModelCatalog from "@t3tools/provider-core/server/ModelCatalog";
53+
import { applyCodexModelCatalog } from "../codexModelCatalog.ts";
5354
import type { ProviderDriver, ProviderInstance } from "@t3tools/provider-core/server/driver";
5455
import { withInstanceIdentity } from "@t3tools/provider-core/server/instanceIdentity";
5556
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
@@ -114,7 +115,7 @@ export type CodexDriverEnv =
114115
| Crypto.Crypto
115116
| FileSystem.FileSystem
116117
| HttpClient.HttpClient
117-
| ModelManifest.ModelManifest
118+
| ModelCatalog.ModelCatalog
118119
| Path.Path
119120
| ProviderEventLoggers.ProviderEventLoggers
120121
| ServerConfig.ServerConfig
@@ -147,7 +148,8 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
147148
const pathService = yield* Path.Path;
148149
const httpClient = yield* HttpClient.HttpClient;
149150
const host = yield* ProviderHost;
150-
const modelManifest = yield* ModelManifest.ModelManifest;
151+
const modelCatalog = yield* ModelCatalog.ModelCatalog;
152+
const currentCatalog = modelCatalog.current(DRIVER_KIND);
151153
const processEnv = mergeProviderInstanceEnvironment(environment);
152154
const homeLayout = yield* resolveCodexHomeLayout(config);
153155
const continuationIdentity = codexContinuationIdentity(homeLayout);
@@ -218,13 +220,12 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
218220
// Kick the TTL-gated manifest refresh in the background and classify
219221
// with the in-memory manifest, so a slow or hung fetch never delays the
220222
// provider check. A refresh that lands mid-probe applies on the next one.
221-
const checkProvider = modelManifest.refreshInBackground.pipe(
223+
const checkProvider = modelCatalog.refreshInBackground.pipe(
222224
Effect.andThen(
223225
Effect.zipWith(
224226
checkCodexProviderStatus(effectiveConfig, undefined, processEnv),
225-
modelManifest.current,
226-
(draft, manifest) =>
227-
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
227+
currentCatalog,
228+
(draft, catalog) => stampIdentity(applyCodexModelCatalog(draft, catalog)),
228229
{ concurrent: true },
229230
),
230231
),
@@ -239,9 +240,8 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
239240
initialSnapshot: (settings) =>
240241
Effect.zipWith(
241242
makePendingCodexProvider(settings.provider),
242-
modelManifest.current,
243-
(draft, manifest) =>
244-
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
243+
currentCatalog,
244+
(draft, catalog) => stampIdentity(applyCodexModelCatalog(draft, catalog)),
245245
),
246246
checkProvider,
247247
enrichSnapshot: ({ settings, snapshot, publishSnapshot }) =>

0 commit comments

Comments
 (0)