feat(models): discover Claude models from remote manifest #9084
Mergedjuliusmarmingemerged 4 commits into
main fromrefs/pull/9084/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/provider/Drivers/ClaudeDriver.ts line 176OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -166,19 +173,4 @@166173 });167174 const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig, cwd);168175169- // Kick the TTL-gated manifest refresh in the background and classify170- // with the in-memory manifest, so a slow or hung fetch never delays the171- // provider check. A refresh that lands mid-probe applies on the next one.172- const checkProvider = modelManifest.refreshInBackground.pipe(173- Effect.andThen(174- Effect.zipWith(175- checkClaudeProviderStatus(176- effectiveConfig,177- () => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),178- processEnv,179- cwd,180- ),181- modelManifest.current,182- (draft, manifest) =>183- stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),184- { concurrent: true },176+ const checkProvider = modelManifest.refresh.pipe(packages/shared/src/model.test.ts line 149Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -148,14 +148,4 @@148148 });149149 });150150151-describe("model slug normalization", () => {152- it("preserves exact custom slugs instead of expanding provider aliases", () => {153- const claude = ProviderDriverKind.make("claudeAgent");154-155- expect(normalizeModelSlug("fable", claude)).toBe("claude-fable-5-1");156- expect(normalizeModelSlug("opus", claude)).toBe("claude-opus-5");157- expect(normalizeCustomModelSlug(" opus ")).toBe("opus");158- });159-});160-161151 describe("applyClaudePromptEffortPrefix", () => {
- apps/server/src/provider/ClaudeModelCatalog.ts line 109OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +89,21 @@89+90+export function resolveClaudeModelCatalog(manifest: ModelManifestData): ClaudeModelCatalog {91+ return (92+ tryResolveClaudeModelCatalog(manifest) ??93+ tryResolveClaudeModelCatalog(BUNDLED_MODEL_MANIFEST) ?? {94+ models: [],95+ }96+ );97+}98+99+export const BUNDLED_CLAUDE_MODEL_CATALOG = resolveClaudeModelCatalog(BUNDLED_MODEL_MANIFEST);100+101+export function resolveClaudeCatalogModel(102+ catalog: ClaudeModelCatalog,103+ slugOrAlias: string | null | undefined,104+): ClaudeCatalogModel | undefined {105+ const value = slugOrAlias?.trim();106+ if (!value) return undefined;107+ return catalog.models.find(108+ (entry) =>109+ entry.model.slug === value ||apps/server/src/provider/ModelManifest.ts lines 140 to 140Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -57,5 +93,21 @@93+}94+95+export interface ResolvedProviderCatalog {96+ readonly models: ReadonlyArray<ResolvedManifestModel>;97+ readonly defaults: {98+ readonly chat: string | undefined;99+ };100+}101+57102 const decodeManifest = Schema.decodeUnknownEffect(ModelManifestSchema);5810359104 export const BUNDLED_MODEL_MANIFEST: ModelManifestData =60105 Schema.decodeUnknownSync(ModelManifestSchema)(bundledManifestJson);61106107+/** Resolve provider-neutral model presentation and capability data. */108+export function resolveProviderCatalog(109+ manifest: ModelManifestData,110+ driverKind: ProviderDriverKind,111+): ResolvedProviderCatalog | null {112+ const catalog = manifest.providers?.[driverKind];113+ if (!catalog) return null;
- apps/server/src/provider/Drivers/ClaudeDriver.ts line 186OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -175,12 +176,11 @@175- checkClaudeProviderStatus(176- effectiveConfig,177- () => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),178- processEnv,179- cwd,180- ),181- modelManifest.current,182- (draft, manifest) =>183- stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),184- { concurrent: true },176+ const checkProvider = modelManifest.refresh.pipe(177+ Effect.flatMap((manifest) =>178+ checkClaudeProviderStatus(179+ effectiveConfig,180+ () => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),181+ processEnv,182+ cwd,183+ resolveClaudeModelCatalog(manifest),185184 ),186185 ),186+ Effect.map(stampIdentity),@@ -186,20 +179 @@186- "claude-opus-5-0": "claude-opus-5",187- "opus-4.8": "claude-opus-4-8",188- "claude-opus-4.8": "claude-opus-4-8",189- "opus-4.7": "claude-opus-4-7",190- "claude-opus-4.7": "claude-opus-4-7",191- "opus-4.6": "claude-opus-4-6",192- "claude-opus-4.6": "claude-opus-4-6",193- "claude-opus-4-6-20251117": "claude-opus-4-6",194- sonnet: "claude-sonnet-5",195- "sonnet-5": "claude-sonnet-5",196- "claude-sonnet-5.0": "claude-sonnet-5",197- "claude-sonnet-5-0": "claude-sonnet-5",198- "sonnet-4.6": "claude-sonnet-4-6",199- "claude-sonnet-4.6": "claude-sonnet-4-6",200- "claude-sonnet-4-6-20251117": "claude-sonnet-4-6",201- haiku: "claude-haiku-4-5",202- "haiku-4.5": "claude-haiku-4-5",203- "claude-haiku-4.5": "claude-haiku-4-5",204- "claude-haiku-4-5-20251001": "claude-haiku-4-5",205- },179+ [CLAUDE_DRIVER_KIND]: {},
- apps/server/src/provider/ClaudeModelManifest.ts line 26OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +6,21 @@6+ effortMap: Schema.optional(7+ Schema.Record(TrimmedNonEmptyString, Schema.NullOr(TrimmedNonEmptyString)),8+ ),9+ modelSuffixes: Schema.optional(10+ Schema.Record(11+ TrimmedNonEmptyString,12+ Schema.Record(TrimmedNonEmptyString, TrimmedNonEmptyString),13+ ),14+ ),15+ contextWindowTokens: Schema.optional(Schema.Record(TrimmedNonEmptyString, Schema.Number)),16+ fixedContextWindowTokens: Schema.optional(Schema.Number),17+});18+19+export const ClaudeProfileAdapterSchema = Schema.Struct({20+ claudeCode: Schema.optional(ClaudeCodeProfileSchema),21+});22+23+export const ClaudeModelAdapterSchema = Schema.Struct({24+ claudeCode: Schema.optional(25+ Schema.Struct({26+ minVersion: Schema.optional(TrimmedNonEmptyString),
juliusmarminge merged this0354283
juliusmarminge closed this
Sign in to join this conversation.


Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
c17d02c· PR result:38962d1· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.