computerFailures.ts 986 B

1234567891011121314151617181920212223242526272829
  1. import {HttpError} from '../../server/errors.js'
  2. import {ComputerError} from './container.js'
  3. /** Environment/pool failures that should become tool results, not hard run kills. */
  4. export const SOFT_COMPUTER_CODES = new Set([
  5. 'computer_busy',
  6. 'computer_quota',
  7. 'computer_pool_unavailable',
  8. 'computer_image_required',
  9. 'computer_unavailable',
  10. 'computer_stop_uncertain',
  11. 'computer_owner_mismatch',
  12. 'computer_spec_invalid',
  13. 'computer_authorization_revoked',
  14. 'compose_desktop_error',
  15. 'compose_desktop_managed',
  16. ])
  17. export function softComputerFailure(error:unknown){
  18. if(error instanceof ComputerError)return true
  19. if(error instanceof HttpError)return SOFT_COMPUTER_CODES.has(error.code??'')
  20. return false
  21. }
  22. export function needsVmLease(name:string,teamToolNames:string[]=[],skillToolNames:string[]=[]){
  23. if(name.startsWith('host_'))return false
  24. if(teamToolNames.includes(name))return false
  25. return name.startsWith('computer_')||skillToolNames.includes(name)
  26. }