index.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Native backend of the directory-picker seam: registers `ctx.directoryPicker`
  3. * with the `native` capability, opening one native OS chooser on the host
  4. * display per pick (macOS `osascript`, Linux Zenity with a KDialog fallback;
  5. * Windows opens the modern `IFileOpenDialog` in a spawned child process — a
  6. * koffi-driven COM conversation on the child's main thread). Only viable when
  7. * the operator sits at the host's screen; remote deployments compose the
  8. * browse backend instead.
  9. * @module @deepseek-ai/dsh-host-directory-picker-native
  10. */
  11. import { DirectoryPicker } from '@deepseek-ai/dsh-host-directory-picker'
  12. import type { DirectoryPickerCapability } from '@deepseek-ai/dsh-host-directory-picker'
  13. import { pickNativeDirectory } from './native-picker.ts'
  14. export type { DirectoryPickerInternals, DirectoryPickerRunner } from './native-picker.ts'
  15. export { pickNativeDirectory } from './native-picker.ts'
  16. /** The `ctx.directoryPicker` native implementation (stable capability object per service life). */
  17. export default class NativeDirectoryPicker extends DirectoryPicker {
  18. private readonly nativeCapability: DirectoryPickerCapability = {
  19. kind: 'native',
  20. /* v8 ignore next -- pure forward to pickNativeDirectory (its spec owns behavior); invoking here opens a real chooser. */
  21. pick: signal => pickNativeDirectory(signal),
  22. }
  23. /**
  24. * The native interaction capability.
  25. * @returns the stable `native` capability object.
  26. */
  27. capability(): DirectoryPickerCapability {
  28. return this.nativeCapability
  29. }
  30. }