@@ -36,6 +36,8 @@ import {
3636 type TurnDiffSummary ,
3737} from "./types" ;
3838
39+ export { formatDuration , formatElapsed } from "@t3tools/shared/orchestrationTiming" ;
40+
3941export type ProviderPickerKind = ProviderDriverKind ;
4042
4143export const PROVIDER_OPTIONS : Array < {
@@ -355,32 +357,6 @@ export function workEntryIndicatesToolNeutralStatus(entry: WorkLogEntry): boolea
355357 return true ;
356358}
357359
358- export function formatDuration ( durationMs : number ) : string {
359- if ( ! Number . isFinite ( durationMs ) || durationMs < 0 ) return "0ms" ;
360- if ( durationMs < 1_000 ) return `${ Math . max ( 1 , Math . round ( durationMs ) ) } ms` ;
361- if ( durationMs < 10_000 ) {
362- const tenths = Math . round ( durationMs / 100 ) / 10 ;
363- // 9.95s+ rounds up to the next bucket — render "10s", not "10.0s".
364- return tenths >= 10 ? "10s" : `${ tenths . toFixed ( 1 ) } s` ;
365- }
366- if ( durationMs < 60_000 ) return `${ Math . round ( durationMs / 1_000 ) } s` ;
367- const minutes = Math . floor ( durationMs / 60_000 ) ;
368- const seconds = Math . round ( ( durationMs % 60_000 ) / 1_000 ) ;
369- if ( seconds === 0 ) return `${ minutes } m` ;
370- if ( seconds === 60 ) return `${ minutes + 1 } m` ;
371- return `${ minutes } m ${ seconds } s` ;
372- }
373-
374- export function formatElapsed ( startIso : string , endIso : string | undefined ) : string | null {
375- if ( ! endIso ) return null ;
376- const startedAt = Date . parse ( startIso ) ;
377- const endedAt = Date . parse ( endIso ) ;
378- if ( Number . isNaN ( startedAt ) || Number . isNaN ( endedAt ) || endedAt < startedAt ) {
379- return null ;
380- }
381- return formatDuration ( endedAt - startedAt ) ;
382- }
383-
384360type LatestTurnTiming = Pick < OrchestrationLatestTurn , "turnId" | "startedAt" | "completedAt" > ;
385361type SessionActivityState = Pick < NonNullable < Thread [ "session" ] > , "status" | "activeTurnId" > ;
386362
0 commit comments