@@ -18,9 +18,11 @@ import {
1818 WS_METHODS ,
1919 WsRpcGroup ,
2020 type VcsStatusStreamEvent ,
21+ type ModelSelection ,
2122 type OrchestrationProjectShell ,
2223 type OrchestrationV2Command ,
2324 type OrchestrationV2ProjectedTurnItem ,
25+ type OrchestrationV2ProviderThread ,
2426 type OrchestrationV2Run ,
2527 type OrchestrationV2ShellStreamItem ,
2628 type OrchestrationV2ThreadProjection ,
@@ -68,30 +70,42 @@ const auth = {
6870 sessionCookieName : "t3_session" ,
6971} ;
7072
71- const baseServerConfig : ServerConfig = {
72- ...Schema . decodeUnknownSync ( ServerConfig ) ( {
73+ const readyProvider = (
74+ instanceId : string ,
75+ driver : string ,
76+ models : ReadonlyArray < { readonly slug : string ; readonly name : string } > ,
77+ ) => ( {
78+ instanceId,
79+ driver,
80+ enabled : true ,
81+ installed : true ,
82+ version : "1.0.0" ,
83+ status : "ready" ,
84+ auth : { status : "authenticated" } ,
85+ checkedAt : "2026-03-17T19:12:28.000Z" ,
86+ models : models . map ( ( model ) => ( { ...model , isCustom : false , capabilities : null } ) ) ,
87+ } ) ;
88+ export const CODEX_PROVIDER = readyProvider ( CODEX , "codex" , [
89+ { slug : "gpt-5.4" , name : "GPT-5.4" } ,
90+ { slug : "gpt-5.5" , name : "GPT-5.5" } ,
91+ ] ) ;
92+ export const CLAUDE_PROVIDER = {
93+ ...readyProvider ( "claudeAgent" , "claudeAgent" , [
94+ { slug : "claude-opus-4-6" , name : "Claude Opus 4.6" } ,
95+ ] ) ,
96+ slashCommands : [ { name : "compact" } ] ,
97+ } ;
98+
99+ const decodeServerConfig = Schema . decodeUnknownSync ( ServerConfig ) ;
100+ const makeServerConfig = ( providers : ReadonlyArray < unknown > ) : ServerConfig => ( {
101+ ...decodeServerConfig ( {
73102 environment : descriptor ,
74103 auth,
75104 cwd : "/workspace/render" ,
76105 keybindingsConfigPath : "/workspace/.t3/keybindings.json" ,
77106 keybindings : [ ] ,
78107 issues : [ ] ,
79- providers : [
80- {
81- instanceId : CODEX ,
82- driver : "codex" ,
83- enabled : true ,
84- installed : true ,
85- version : "1.0.0" ,
86- status : "ready" ,
87- auth : { status : "authenticated" } ,
88- checkedAt : "2026-03-17T19:12:28.000Z" ,
89- models : [
90- { slug : "gpt-5.4" , name : "GPT-5.4" , isCustom : false , capabilities : null } ,
91- { slug : "gpt-5.5" , name : "GPT-5.5" , isCustom : false , capabilities : null } ,
92- ] ,
93- } ,
94- ] ,
108+ providers,
95109 availableEditors : [ ] ,
96110 observability : {
97111 logsDirectoryPath : "/workspace/.t3/logs" ,
@@ -105,7 +119,8 @@ const baseServerConfig: ServerConfig = {
105119 shellResumeCompletionMarker : true ,
106120 } ) ,
107121 keybindings : DEFAULT_RESOLVED_KEYBINDINGS ,
108- } ;
122+ } ) ;
123+ let baseServerConfig = makeServerConfig ( [ CODEX_PROVIDER ] ) ;
109124// A server only leaves threads out of the shell when it serves their families.
110125const serverConfig = ( ) : ServerConfig =>
111126 threads . some ( ( thread ) => thread . olderSettled )
@@ -171,13 +186,19 @@ export function assistantItem(
171186 } satisfies OrchestrationV2TurnItem ;
172187}
173188
174- function run ( threadId : ThreadId , id : RunId , ordinal : number , userMessageId : string ) {
189+ function run (
190+ threadId : ThreadId ,
191+ id : RunId ,
192+ ordinal : number ,
193+ userMessageId : string ,
194+ modelSelection : ModelSelection = MODEL ,
195+ ) {
175196 return {
176197 id,
177198 threadId,
178199 ordinal,
179- providerInstanceId : CODEX ,
180- modelSelection : MODEL ,
200+ providerInstanceId : modelSelection . instanceId ,
201+ modelSelection,
181202 providerThreadId : null ,
182203 userMessageId : MessageId . make ( userMessageId ) ,
183204 rootNodeId : null ,
@@ -198,18 +219,26 @@ export interface FakeThread {
198219 readonly olderSettled ?: true ;
199220 readonly id : ThreadId ;
200221 readonly title : string ;
222+ /** Defaults to GPT-5.4 on Codex. */
223+ readonly modelSelection ?: ModelSelection ;
224+ /** The first is the thread's active provider thread. */
225+ readonly providerThreads ?: ReadonlyArray < OrchestrationV2ProviderThread > ;
201226 readonly runs : ReadonlyArray < OrchestrationV2Run > ;
202227 readonly items : ReadonlyArray < OrchestrationV2TurnItem > ;
203228}
204229
205230/** A thread of `turns` user prompts, each answered in markdown with a list and inline code. */
206- export function threadWithHistory ( name : string , turns : number ) : FakeThread {
231+ export function threadWithHistory (
232+ name : string ,
233+ turns : number ,
234+ modelSelection : ModelSelection = MODEL ,
235+ ) : FakeThread {
207236 const id = ThreadId . make ( name ) ;
208237 const runs : OrchestrationV2Run [ ] = [ ] ;
209238 const items : OrchestrationV2TurnItem [ ] = [ ] ;
210239 for ( let turn = 0 ; turn < turns ; turn ++ ) {
211240 const runId = RunId . make ( `${ name } -run-${ turn } ` ) ;
212- runs . push ( run ( id , runId , turn + 1 , `${ name } -user-${ turn } ` ) ) ;
241+ runs . push ( run ( id , runId , turn + 1 , `${ name } -user-${ turn } ` , modelSelection ) ) ;
213242 items . push (
214243 userItem ( id , runId , `${ name } -user-${ turn } ` , turn * 2 , `${ name } : question ${ turn } ` ) ,
215244 assistantItem (
@@ -222,22 +251,23 @@ export function threadWithHistory(name: string, turns: number): FakeThread {
222251 ) ,
223252 ) ;
224253 }
225- return { id, title : `Thread ${ name } ` , runs, items } ;
254+ return { id, title : `Thread ${ name } ` , modelSelection , runs, items } ;
226255}
227256
228257function shellOf ( thread : FakeThread ) : OrchestrationV2ThreadShell {
229258 const latest = thread . runs . at ( - 1 ) ;
259+ const modelSelection = thread . modelSelection ?? MODEL ;
230260 return {
231261 id : thread . id ,
232262 projectId : PROJECT_ID ,
233263 title : thread . title ,
234- providerInstanceId : CODEX ,
235- modelSelection : MODEL ,
264+ providerInstanceId : modelSelection . instanceId ,
265+ modelSelection,
236266 runtimeMode : "full-access" ,
237267 interactionMode : "default" ,
238268 branch : "main" ,
239269 worktreePath : null ,
240- activeProviderThreadId : null ,
270+ activeProviderThreadId : thread . providerThreads ?. [ 0 ] ?. id ?? null ,
241271 lineage : {
242272 rootThreadId : thread . sideChatOf ?? thread . id ,
243273 parentThreadId : thread . sideChatOf ?? null ,
@@ -289,7 +319,7 @@ function projectionOf(thread: FakeThread): OrchestrationV2ThreadProjection {
289319 interactionMode : shell . interactionMode ,
290320 branch : shell . branch ,
291321 worktreePath : shell . worktreePath ,
292- activeProviderThreadId : null ,
322+ activeProviderThreadId : shell . activeProviderThreadId ,
293323 lineage : shell . lineage ,
294324 forkedFrom : null ,
295325 createdBy : "user" ,
@@ -307,7 +337,7 @@ function projectionOf(thread: FakeThread): OrchestrationV2ThreadProjection {
307337 nodes : [ ] ,
308338 subagents : [ ] ,
309339 providerSessions : [ ] ,
310- providerThreads : [ ] ,
340+ providerThreads : [ ... ( thread . providerThreads ?? [ ] ) ] ,
311341 providerTurns : [ ] ,
312342 runtimeRequests : [ ] ,
313343 messages : [ ] ,
@@ -465,9 +495,10 @@ const encodedDescriptor = Schema.encodeSync(ExecutionEnvironmentDescriptor)(
465495/** Serves the environment's HTTP API and these threads until disposed. */
466496export function installFakeEnvironment (
467497 fixtures : ReadonlyArray < FakeThread > ,
468- options ?: { readonly acceptCommands ?: boolean } ,
498+ options ?: { readonly acceptCommands ?: boolean ; readonly providers ?: ReadonlyArray < unknown > } ,
469499) : Disposable {
470500 threads = fixtures ;
501+ baseServerConfig = makeServerConfig ( options ?. providers ?? [ CODEX_PROVIDER ] ) ;
471502 dispatched = [ ] ;
472503 acceptCommands = options ?. acceptCommands === true ;
473504 globalThis . fetch = async ( input , init ) => {
@@ -491,6 +522,7 @@ export function installFakeEnvironment(
491522 [ Symbol . dispose ] : ( ) => {
492523 globalThis . fetch = realFetch ;
493524 threads = [ ] ;
525+ baseServerConfig = makeServerConfig ( [ CODEX_PROVIDER ] ) ;
494526 dispatched = [ ] ;
495527 acceptCommands = false ;
496528 } ,
0 commit comments