host-environment.mjs 643 B

12345678910
  1. import {arch,release} from 'node:os'
  2. import {HOST_SHELL} from './host-files.mjs'
  3. /** Optional metadata stays off the wire until the server advertises support. */
  4. export class HostEnvironmentReporter {
  5. constructor(home){this.home=home;this.supported=false}
  6. accept(capabilities){this.supported=capabilities?.environmentMetadata===1}
  7. reset(){this.supported=false}
  8. fields(){return this.supported?{fileTransferVersion:1,environment:{version:1,osRelease:release(),arch:arch(),shell:HOST_SHELL,homeDirectory:this.home,defaultCwd:this.home,fileRoots:[this.home],shellScope:'user',timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}:{}}
  9. }