omdsh-dev/dsh-tool-calculator3

@deepseek-ai/dsh-tool-calculator

DSH calculator tool

AI 분석

为 DSH 模型提供精确的数学计算辅助工具。适合需要进行高精度、确定性数值计算,避免大模型自身算术幻觉的通用任务。

패키지
@deepseek-ai/dsh-tool-calculator
버전
0.0.1
라이선스
MIT
최근 업데이트
2026. 8. 14.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:omdsh-dev/dsh-tool-calculator

一次性任务(headless)profile —— dsh run 默认使用 headless

dsh plugin --profile headless add "C:/path/to/dsh-tool-calculator"


包内 `dsh.bundle.patch`(指向 `cordis.patch.yml`)会在安装后自动把插件加入 profile 的 layer stack;插件的 `cordis.patch.yml` 以 `- insert:` 插入 `tool-calculator` 条目。插件缺失的 peer 依赖(`cordis`、`@deepseek-ai/dsh-tools`)由 profile 的 healed `profiles/node_modules` 回退安装提供。

> ⚠️ web 与 headless 是**不同 profile**:web 安装不会自动覆盖 headless;`dsh run` 默认使用 headless profile。Windows 路径使用正斜杠(`C:/...`)。

### 验证安装

```sh
dsh --profile web --dump-config | grep tool-calculator

运行验证

dsh run "使用 calculator 工具计算 1+2*3"

手动安装与旧版本兼容

仅适用于不支持 Profile Bundle 的旧快照或插件开发调试环境:

  1. 放入 monorepo:cp -r calculator ~/.dsh/source/master/packages/tools/calculator(开发调试)
  2. apps/cli/package.json"@deepseek-ai/dsh-tool-calculator": "workspace:^"tsconfig.host.json references 加 { "path": "./packages/tools/calculator" }
  3. pnpm install && pnpm run build
  4. 在 profile 用户层 patch 插入插件(~/.dsh/profiles//cordis.patch.yml):
- insert:
    - id: tool-calculator
      name: '@deepseek-ai/dsh-tool-calculator'
  1. 验证:dsh --profile --dump-config | grep tool-calculator

0806 注意:patch 是 id-targeted 语义——裸 - id: 条目会报 entry "xxx" not found,必须用 - insert: 列表包裹。

用法

安装后,agent 自动获得 calculator 工具:

calculator { expression: "15 + 27 * sqrt(9)" }  →  96

工具名满足 DeepSeek 函数名约束(≤64 字符,[A-Za-z0-9_-])。注册后自动进入 Code Mode SDK(await tools.calculator(...)),canonical 返回值为数字。

已知限制

  1. 分发链路@deepseek-ai/dsh-tools 是 DSH monorepo 私有包(未发布 npm),本插件需放入 monorepo 走 workspace 解析
  2. 三角函数使用弧度:与 Math.sin/Math.cos 一致;需要角度时写 sin(30 * PI / 180)
  3. 不支持大整数:JS number 是 IEEE 754 double,安全整数范围 ±9e15,超出有精度损失
  4. 不支持科学计数法1e5 会被词法层拒绝

测试

pnpm test

包含功能用例与攻击载荷用例(constructor.constructor 链、process.exit(0)globalThis、引号注入、分号语句等)。完整用例清单见本地维护的设计文档。

许可

MIT