Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/fold-agent/src/Config/ModelSelections.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DEFAULT_CODEX_MODEL_ID } from '@humanlayer/fold-codex'
import { DEFAULT_ANTHROPIC_MODEL_ID, type ModelCatalogEntry, type FoldModel } from '@humanlayer/fold-core'
import { DEFAULT_OPENCODE_MODEL_ID, GROK_BUILD_MODEL_ID } from '@humanlayer/fold-opencode'
import { DEFAULT_XAI_MODEL_ID } from '@humanlayer/fold-xai'
import { Predicate, Effect, Match } from 'effect'
import { DEFAULT_XAI_MODEL_ID, XAI_FRONTIER_MODELS } from '@humanlayer/fold-xai'
import { Effect, Match, Predicate } from 'effect'

import { agentModelsFromConfig, type AgentModelsOptions, RoleResolutionError } from './AgentModels'
import type { ConfigRole, ProfileConfig, ProfileModeName, RoleBinding, FoldConfig } from './ConfigSchema'
Expand Down Expand Up @@ -77,7 +77,7 @@ export const describeModelConfiguration = (
const defaultModels = Match.value(provider.kind).pipe(
Match.when('codex', () => [DEFAULT_OPENCODE_MODEL_ID]),
Match.when('opencode', () => [DEFAULT_OPENCODE_MODEL_ID, GROK_BUILD_MODEL_ID]),
Match.when('xai', () => ['grok-4.5', DEFAULT_XAI_MODEL_ID]),
Match.when('xai', () => XAI_FRONTIER_MODELS.map(({ modelId }) => modelId)),
Match.orElse((): ReadonlyArray<string> => []),
)
const models = [
Expand Down
2 changes: 1 addition & 1 deletion packages/fold-xai/src/XaiModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { FetchHttpClient, HttpClient } from 'effect/unstable/http'

import type { XaiAuthStore } from './AuthStore'
import { makeXaiAuth, withXaiAuth } from './XaiAuth'
import { DEFAULT_XAI_MODEL_ID } from './XaiModelCatalog'

export const XAI_API_URL = 'https://api.x.ai/v1'
export const DEFAULT_XAI_MODEL_ID = 'grok-4.6'

export type XaiModelOptions = {
readonly model?: string
Expand Down
21 changes: 21 additions & 0 deletions packages/fold-xai/src/XaiModelCatalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Schema } from 'effect'

/** Model IDs verified for xAI subscription-backed OAuth sessions. */
export const XaiFrontierModelId = Schema.Literals(['grok-4.5', 'grok-4.6'])
export type XaiFrontierModelId = typeof XaiFrontierModelId.Type

/** One model exposed to embedding hosts for validation and selection controls. */
export const XaiFrontierModel = Schema.Struct({
modelId: XaiFrontierModelId,
label: Schema.NonEmptyString,
})
export type XaiFrontierModel = typeof XaiFrontierModel.Type

/** Frontier Grok models supported by Fold's xAI OAuth transport. */
export const XAI_FRONTIER_MODELS = [
{ modelId: 'grok-4.5', label: 'Grok 4.5' },
{ modelId: 'grok-4.6', label: 'Grok 4.6' },
] as const satisfies ReadonlyArray<XaiFrontierModel>

/** The model selected when an embedding host does not provide one. */
export const DEFAULT_XAI_MODEL_ID: XaiFrontierModelId = 'grok-4.6'
1 change: 1 addition & 0 deletions packages/fold-xai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './AuthStore'
export * from './OAuthFlows'
export * from './XaiAuth'
export * from './XaiModel'
export * from './XaiModelCatalog'
15 changes: 14 additions & 1 deletion packages/fold-xai/test/Xai.vi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { readdir, rm } from 'node:fs/promises'

import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem'
import { describe, expect, it } from '@effect/vitest'
import { Effect, Option } from 'effect'
import { Effect, Option, Schema } from 'effect'

import {
buildXaiAuthorizeUrl,
DEFAULT_XAI_MODEL_ID,
makeXaiAuthStore,
XAI_FRONTIER_MODELS,
XAI_BROWSER_REDIRECT_URI,
XAI_CLIENT_ID,
xaiModel,
XaiFrontierModelId,
XaiTokenData,
} from '../src/index'

Expand Down Expand Up @@ -48,6 +50,17 @@ describe('xAI OAuth', () => {
})

describe('xaiModel', () => {
it('exports the supported frontier catalog and defaults to its newest model', () => {
expect(XAI_FRONTIER_MODELS).toEqual([
{ modelId: 'grok-4.5', label: 'Grok 4.5' },
{ modelId: 'grok-4.6', label: 'Grok 4.6' },
])
expect(XAI_FRONTIER_MODELS.at(-1)?.modelId).toBe(DEFAULT_XAI_MODEL_ID)
expect(Schema.is(XaiFrontierModelId)('grok-4.5')).toBe(true)
expect(Schema.is(XaiFrontierModelId)('grok-4.6')).toBe(true)
expect(Schema.is(XaiFrontierModelId)('grok-unverified')).toBe(false)
})

it('returns a FoldModel-compatible OpenAI snapshot', () => {
const model = xaiModel()
expect(model.activeModel).toMatchObject({
Expand Down
Loading