Bundle
xby-random-number
提供伪随机和加密安全的随机数生成功能,包括整数、浮点数、加权选择、列表洗牌和安全令牌生成。
- Source
- xby-skill
- License
- MIT
- Updated
- Updated 2 days ago
Readme
# xby-random-number
DeepSeek Harness (DSH) 的插件:随机数生成工具
提供伪随机和加密安全的随机数生成功能,包括整数、浮点数、加权选择、列表洗牌和安全令牌生成。
## 功能
- **set_xby_apikey** — 在聊天中设置 API 密钥(自动持久化,重启有效)
- **random_int** — Generate a random integer between low and high (inclusive).
Args:
low: Lower bound (inclusive)
high: Upper bound (inclusive)
Returns:
Random integer between low and high
- **random_float** — Generate a random float between low and high.
Args:
low: Lower bound (default 0.0)
high: Upper bound (default 1.0)
Returns:
Random float between low and high
- **random_choices** — Choose k items from population with replacement, optionally weighted.
Args:
population: List of items to choose from
k: Number of items to choose (default 1)
weights: Optional weights for each item (default None for equal weights)
Returns:
List of k chosen items
- **random_shuffle** — Return a new list with items in random order.
Args:
items: List of items to shuffle
Returns:
New list with items in random order
- **random_sample** — Choose k unique items from population without replacement.
Args:
population: List of items to choose from
k: Number of items to choose
Returns:
List of k unique chosen items
- **secure_token_hex** — Generate a secure random hex token.
Args:
nbytes: Number of random bytes to generate (default 32)
Returns:
Hex string containing 2*nbytes characters
- **secure_random_int** — Generate a secure random integer below upper_bound.
Args:
upper_bound: Upper bound (exclusive)
Returns:
Random integer in range [0, upper_bound)
## 安装
### 方式一:从 GitHub 直接安装(推荐)
```bash
# 格式: dsh plugin --profile <profile> add github:<owner>/<repo>
dsh plugin --profile web add github:xby_skill/xby-random-number
```
### 方式二:从本地目录安装(开发模式)
```bash
# 仅用于本地开发调试
dsh plugin --profile web add /absolute/path/to/xby-random-number
```
### 方式三:通过 cordis.patch.yml 开发调试
```bash
dsh web --profile web --patch /absolute/path/to/dsh-ocr-plugin/cordis.patch.yml
```
## 配置
### 获取 API 密钥
前往 [小笨羊官网](https://xiaobenyang.com) 注册并获取 API 密钥。
Install
dsh plugin --profile web add github:xby-skill/xby-random-number
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install xby-random-number from the hub
- This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.