dsh-ohos-shell: Completing the Subprocess Runtime Environment on HarmonyOS/OpenHarmony

When using DeepSeek Harness on HarmonyOS or OpenHarmony devices, the runtime environment of child processes often encounters compatibility issues. The default shell is mksh (which does not support standard configuration files), the system lacks the /etc/shells registry, and the /tmp directory may be read-only. These issues can lead to tool call failures or configuration loss. dsh-ohos-shell aims to address these issues by providing a complete harmonybrew environment and zsh support for child processes.

dsh-ohos-shell is a plugin (bundle) for DeepSeek Harness, maintained by CyberQin. It is specifically designed for the HarmonyOS and OpenHarmony platforms, with the primary function of completing the runtime environment for child processes. This includes providing the zsh function library, setting the default shell to zsh or bash, and handling OpenHarmony-specific shell differences (such as the absence of /etc/shells, read-only /tmp, and sandbox uid issues).

Core Features

  • Inserts ohos-shell-env and ohos-shell-facts into the profile.
  • Provides HarmonyOS environment variables (PATH, SHELL, TMPDIR, HOMEBREW_*, etc.) for child processes.
  • Provides the zsh function library.
  • Changes the sidebar’s default shell to zsh or bash.
  • Handles HarmonyOS/OpenHarmony-specific shell differences (e.g., absence of /etc/shells, read-only /tmp, sandbox uid issues).

Environment Requirements

  • The device is running HarmonyOS or OpenHarmony.
  • harmonybrew is installed (with a default prefix of ~/.harmonybrew).
  • deepseek-harness is installed via harmonybrew.
  • The system provides /usr/bin/zsh.

Installation and Activation

Install via Harness’s plugin manager:

dsh plugin --profile web add dsh-ohos-shell

The plugin manager will write the package to dsh.profile.bundles. After installation, the profile’s package.json should include the "dsh-ohos-shell" dependency.

Functional Details

After installation, the plugin inserts two Host plugins into the profile:

  • ohos-shell-env: Writes environment variables into the main process’s process.env and restores them upon uninstallation.
  • ohos-shell-facts: Publishes DSH_OHOS* information via ctx.shellEnv for the model’s shell to read.

It sets the following environment variables:

  • PATH: Deduplicates and prioritizes harmonybrew at the front, following the order in ~/.zshrc.
  • SHELL: Set to the first available zsh or bash.
  • TMPDIR: Prioritizes writable directories (e.g., $HOME/.tmp) to resolve the read-only /tmp issue.
  • FPATH: Points to this package’s zsh-functions directory, completing the function library.
  • HOMEBREW_*: Sets Homebrew-related paths.
  • NODE_OPTIONS: Prepends --require when userinfo-shim.cjs exists.

Notes

  • Only effective on HarmonyOS and OpenHarmony.
  • Node’s os.userInfo() throws an error under the application sandbox uid.
  • The /tmp directory may be read-only; a writable TMPDIR must be set.
  • The model shell’s bash tool is unaffected (it fixedly executes bash -c).
  • Please review the source code and license before installation.

By fixing environment variables and shell configurations, this plugin resolves the compatibility issues of running DeepSeek Harness child processes on the HarmonyOS system. To view the source code or submit feedback, please visit its GitHub repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye