mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
155 lines
5.1 KiB
TypeScript
155 lines
5.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { CODEX_SESSION_OPTION_CATALOG } from './agent-session-option-catalog-claude-codex'
|
|
import {
|
|
applyNativeChatSessionOptionPicks,
|
|
resolveStructuredLaunchSeedOptions,
|
|
updateNativeChatSessionOptionDefaults
|
|
} from './native-chat/input/native-chat-session-option-defaults'
|
|
import type {
|
|
PersistedNativeChatSessionOptions,
|
|
SessionOptionValue
|
|
} from './native-chat/input/native-chat-session-options'
|
|
import {
|
|
applyStructuredAgentSessionOptions,
|
|
createStructuredAgentSessionOptionState,
|
|
structuredAgentSessionOptionPicks
|
|
} from './structured-agent-session-options'
|
|
|
|
function liveState(current: { model: string; effort?: string; fastMode?: boolean }) {
|
|
return applyStructuredAgentSessionOptions(
|
|
createStructuredAgentSessionOptionState('codex'),
|
|
CODEX_SESSION_OPTION_CATALOG,
|
|
{
|
|
models: [
|
|
{
|
|
id: 'account-model',
|
|
label: 'Account Model',
|
|
isDefault: true,
|
|
defaultEffort: 'medium',
|
|
efforts: [
|
|
{ value: 'medium', label: 'Medium' },
|
|
{ value: 'high', label: 'High' }
|
|
],
|
|
supportsFastMode: true
|
|
},
|
|
{
|
|
id: 'other-model',
|
|
label: 'Other Model',
|
|
isDefault: false,
|
|
defaultEffort: 'low',
|
|
efforts: [
|
|
{ value: 'low', label: 'Low' },
|
|
{ value: 'medium', label: 'Medium' }
|
|
],
|
|
supportsFastMode: true
|
|
}
|
|
],
|
|
fastModeSupport: { supported: true },
|
|
current
|
|
}
|
|
)
|
|
}
|
|
|
|
function persist(
|
|
picks: readonly { modelId: string; optionId: string; value: SessionOptionValue }[]
|
|
): PersistedNativeChatSessionOptions {
|
|
return applyNativeChatSessionOptionPicks({ persisted: undefined, agent: 'codex', picks })
|
|
}
|
|
|
|
describe('structuredAgentSessionOptionPicks', () => {
|
|
it('pins the model an effort-only pick was chosen against', () => {
|
|
const picks = structuredAgentSessionOptionPicks(liveState({ model: 'account-model' }), {
|
|
effort: 'high'
|
|
})
|
|
expect(picks).toEqual([{ modelId: 'account-model', optionId: 'effort', value: 'high' }])
|
|
// Without the model the launch resolves nothing at all, so the effort would be dead.
|
|
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
|
|
model: 'account-model',
|
|
effort: 'high'
|
|
})
|
|
})
|
|
|
|
it('remembers the effort the provider reconciled, not the one in force before', () => {
|
|
const state = liveState({ model: 'account-model', effort: 'high' })
|
|
const picks = structuredAgentSessionOptionPicks(state, {
|
|
model: 'other-model',
|
|
effort: 'low'
|
|
})
|
|
expect(picks).toEqual([
|
|
{ modelId: 'other-model', optionId: 'model', value: 'other-model' },
|
|
{ modelId: 'other-model', optionId: 'effort', value: 'low' }
|
|
])
|
|
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
|
|
model: 'other-model',
|
|
effort: 'low'
|
|
})
|
|
})
|
|
|
|
it('keeps a per-model effort so reselecting the old model restores its level', () => {
|
|
const persisted = persist([
|
|
...structuredAgentSessionOptionPicks(liveState({ model: 'account-model' }), {
|
|
effort: 'high'
|
|
}),
|
|
...structuredAgentSessionOptionPicks(liveState({ model: 'account-model', effort: 'high' }), {
|
|
model: 'other-model',
|
|
effort: 'low'
|
|
})
|
|
])
|
|
const reselected = updateNativeChatSessionOptionDefaults({
|
|
persisted,
|
|
agent: 'codex',
|
|
modelId: 'account-model',
|
|
optionId: 'model',
|
|
value: 'account-model'
|
|
})
|
|
expect(resolveStructuredLaunchSeedOptions(reselected, 'codex')).toEqual({
|
|
model: 'account-model',
|
|
effort: 'high'
|
|
})
|
|
})
|
|
|
|
it('writes nothing before the provider catalog lands', () => {
|
|
expect(
|
|
structuredAgentSessionOptionPicks(createStructuredAgentSessionOptionState('codex'), {
|
|
effort: 'high'
|
|
})
|
|
).toEqual([])
|
|
})
|
|
|
|
it('drops ids a launch cannot seed back', () => {
|
|
expect(
|
|
structuredAgentSessionOptionPicks(liveState({ model: 'account-model' }), {
|
|
permissionMode: 'plan'
|
|
})
|
|
).toEqual([])
|
|
})
|
|
|
|
it('remembers explicit Fast on and off as booleans and re-encodes the launch seed', () => {
|
|
const state = liveState({ model: 'account-model', fastMode: true })
|
|
const picks = structuredAgentSessionOptionPicks(state, { fastMode: 'false' })
|
|
expect(picks).toEqual([{ modelId: 'account-model', optionId: 'fastMode', value: false }])
|
|
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
|
|
model: 'account-model',
|
|
fastMode: 'false'
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('applyNativeChatSessionOptionPicks', () => {
|
|
it('leaves every other agent untouched', () => {
|
|
const persisted = applyNativeChatSessionOptionPicks({
|
|
persisted: { claude: { model: 'opus', valuesByModel: { opus: { effort: 'high' } } } },
|
|
agent: 'codex',
|
|
picks: [{ modelId: 'gpt-fast', optionId: 'effort', value: 'low' }]
|
|
})
|
|
expect(resolveStructuredLaunchSeedOptions(persisted, 'claude')).toEqual({
|
|
model: 'opus',
|
|
effort: 'high'
|
|
})
|
|
expect(resolveStructuredLaunchSeedOptions(persisted, 'codex')).toEqual({
|
|
model: 'gpt-fast',
|
|
effort: 'low'
|
|
})
|
|
})
|
|
})
|