index.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  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, preceded by a
  7. * synthesized Alt press so the dialog activates as foreground even when a
  8. * background host spawned the child). Only viable when
  9. * the operator sits at the host's screen; remote deployments compose the
  10. * browse backend instead.
  11. * @module @deepseek-ai/dsh-host-directory-picker-native
  12. */
  13. import { DirectoryPicker } from '@deepseek-ai/dsh-host-directory-picker'
  14. import type { DirectoryPickerCapability } from '@deepseek-ai/dsh-host-directory-picker'
  15. import { pickNativeDirectory } from './native-picker.ts'
  16. export type { DirectoryPickerInternals, DirectoryPickerRunner } from './native-picker.ts'
  17. export { pickNativeDirectory } from './native-picker.ts'
  18. /** The `ctx.directoryPicker` native implementation (stable capability object per service life). */
  19. export default class NativeDirectoryPicker extends DirectoryPicker {
  20. private readonly nativeCapability: DirectoryPickerCapability = {
  21. kind: 'native',
  22. /* v8 ignore next -- pure forward to pickNativeDirectory (its spec owns behavior); invoking here opens a real chooser. */
  23. pick: signal => pickNativeDirectory(signal),
  24. }
  25. /**
  26. * The native interaction capability.
  27. * @returns the stable `native` capability object.
  28. */
  29. capability(): DirectoryPickerCapability {
  30. return this.nativeCapability
  31. }
  32. }