@@ -150,6 +150,12 @@ import {
150150 shouldRefreshToken ,
151151 transformRequestForCodex ,
152152} from "./lib/request/fetch-helpers.js" ;
153+ import {
154+ createDeactivatedWorkspaceError ,
155+ createUsageRequestTimeoutError ,
156+ DEACTIVATED_WORKSPACE_ERROR_CODE ,
157+ isDeactivatedWorkspaceErrorMessage ,
158+ } from "./lib/runtime-contracts.js" ;
153159import { applyFastSessionDefaults } from "./lib/request/request-transformer.js" ;
154160import {
155161 getRateLimitBackoff ,
@@ -2091,7 +2097,7 @@ while (attempted.size < Math.max(1, accountCount)) {
20912097 ...account ,
20922098 flaggedAt : Date . now ( ) ,
20932099 flaggedReason : "workspace-deactivated" ,
2094- lastError : "deactivated_workspace" ,
2100+ lastError : DEACTIVATED_WORKSPACE_ERROR_CODE ,
20952101 } ;
20962102 await withFlaggedAccountStorageTransaction ( async ( current , persist ) => {
20972103 const nextStorage : typeof current = {
@@ -2769,15 +2775,15 @@ while (attempted.size < Math.max(1, accountCount)) {
27692775 ? ( errorBody as { error ?: { message ?: string } } ) . error ?. message
27702776 : bodyText ) || `HTTP ${ response . status } ` ;
27712777 if ( isDeactivatedWorkspaceError ( errorBody , response . status ) ) {
2772- throw new Error ( "deactivated_workspace" ) ;
2778+ throw createDeactivatedWorkspaceError ( ) ;
27732779 }
27742780 throw new Error ( message ) ;
27752781 }
27762782
27772783 lastError = new Error ( "Codex response did not include quota headers" ) ;
27782784 } catch ( error ) {
27792785 lastError = error instanceof Error ? error : new Error ( String ( error ) ) ;
2780- if ( lastError . message === "deactivated_workspace" ) {
2786+ if ( isDeactivatedWorkspaceErrorMessage ( lastError . message ) ) {
27812787 throw lastError ;
27822788 }
27832789 }
@@ -3003,7 +3009,7 @@ while (attempted.size < Math.max(1, accountCount)) {
30033009 } catch ( error ) {
30043010 errors += 1 ;
30053011 const message = error instanceof Error ? error . message : String ( error ) ;
3006- if ( message === "deactivated_workspace" ) {
3012+ if ( isDeactivatedWorkspaceErrorMessage ( message ) ) {
30073013 const flaggedRecord : FlaggedAccountMetadataV1 = {
30083014 ...account ,
30093015 flaggedAt : Date . now ( ) ,
@@ -4448,19 +4454,19 @@ while (attempted.size < Math.max(1, accountCount)) {
44484454 bodyText = ( await response . text ( ) ) . slice ( 0 , usageErrorBodyMaxChars ) ;
44494455 } catch ( error ) {
44504456 if ( isAbortError ( error ) || controller . signal . aborted ) {
4451- throw new Error ( "Usage request timed out" ) ;
4457+ throw createUsageRequestTimeoutError ( ) ;
44524458 }
44534459 throw error ;
44544460 }
44554461 if ( controller . signal . aborted ) {
4456- throw new Error ( "Usage request timed out" ) ;
4462+ throw createUsageRequestTimeoutError ( ) ;
44574463 }
44584464 throw new Error ( sanitizeUsageErrorMessage ( response . status , bodyText ) ) ;
44594465 }
44604466 return ( await response . json ( ) ) as UsagePayload ;
44614467 } catch ( error ) {
44624468 if ( isAbortError ( error ) ) {
4463- throw new Error ( "Usage request timed out" ) ;
4469+ throw createUsageRequestTimeoutError ( ) ;
44644470 }
44654471 throw error ;
44664472 } finally {
0 commit comments