In agent development for DeepSeek Harness (DSH), having an Agent generate random content or simulation data is a common requirement. For such scenarios, directly calling low-level libraries in code may not be flexible enough, or difficult to integrate with DSH’s context management. xby-random-number is a DSH plugin maintained by xby-skill, aiming to provide pseudo-random and cryptographically secure random number generation capabilities.

Core Features

The plugin provides two types of random number generation capabilities, as well as basic collection operations:

  • Standard random numbers: Supports generating integers and floating-point numbers within a specified range.
  • Secure random numbers: Provides cryptographically secure token and integer generation.
  • Collection operations: Supports shuffling lists, sampling without replacement, and weighted random selection.
  • Environment configuration: Provides the set_xby_apikey method for setting an API key and automatically persisting it.

Installation and Activation

Use DSH’s command-line tool to install this plugin. After installation, the plugin is automatically persisted and remains available after restarting the process.

dsh plugin --profile web add github:xby_skill/xby-random-number

Typical Usage

The plugin exposes methods through DSH’s context. The specific logic of each feature is as follows:

  • Random integer: random_int accepts low and high parameters (inclusive bounds) and returns an integer within the range.
  • Random floating-point number: random_float accepts low and high parameters (defaults to 0.0 and 1.0) and returns a floating-point number.
  • Weighted selection: random_choices selects k elements from population, supporting the weights parameter for weighting.
  • List shuffling: random_shuffle takes a list and returns a new list with the order shuffled.
  • Sampling without replacement: random_sample selects k unique elements from population.
  • Secure token: secure_token_hex generates 32 random bytes by default and returns a hexadecimal string.
  • Secure integer: secure_random_int generates a cryptographically secure random integer less than upper_bound.

Configuration and Considerations

  • API key: Before use, you must register on the Xiaobenyang official website and obtain an API key.
  • Environment: The plugin type is module, and its dependent files include dist and cordis.patch.yml.
  • Permissions: The plugin runs with the permissions of the current DSH process. Before installation, it is recommended to review the source code to ensure compliance with security policies.

Summary

xby-random-number provides basic random number generation capabilities for DSH, covering from standard mathematical randomness to cryptographically secure token generation. For developers who need to dynamically generate data or simulate scenarios, this is a lightweight solution.

  • Source code: https://github.com/xby-skill/xby-random-number
  • Plugin directory page: https://www.skillhub.cn/plugins/xby-skill/xby-random-number