← 返回 Skills 市场
hardtothinkausername

deterministic-calc-skill

作者 HardToThinkAUsername · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
110
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install deterministic-calc-skill
功能描述
Provides secure, sandboxed execution of mathematical expressions and code to deliver exact computation results without model guesswork.
使用说明 (SKILL.md)

deterministic-calc Skill

核心理念: 大模型擅长预测(猜),但不擅长确定性计算。本 Skill 将确定性计算固化为代码执行,避免模型"猜"结果。


🧠 问题背景

❌ 错误用法:让模型直接计算

用户:123456789 × 987654321 = ?
模型:(开始猜)大概是 121932631...(可能错)

✅ 正确用法:模型生成代码 → 执行 → 返回

用户:123456789 × 987654321 = ?
模型:(生成代码)print(123456789 * 987654321)
执行:121932631112635269
返回:正确答案

📦 安装

npx clawhub install deterministic-calc

🛠️ 可用函数

calculate(expression)

执行数学表达式计算。

参数:

  • expression (string): 数学表达式

返回:

{
  "success": true,
  "expression": "123456789 * 987654321",
  "result": 121932631112635269
}

run_python(code)

执行 Python 代码并返回结果。

参数:

  • code (string): Python 代码

返回:

{
  "success": true,
  "stdout": "121932631112635269\
",
  "stderr": "",
  "exit_code": 0
}

run_shell(command)

执行 Shell 命令并返回结果。

参数:

  • command (string): Shell 命令

返回:

{
  "success": true,
  "stdout": "...",
  "stderr": "",
  "exit_code": 0
}

safe_eval(expression)

安全执行数学表达式(无代码注入风险)。

参数:

  • expression (string): 数学表达式

返回:

{
  "success": true,
  "result": 42
}

📝 使用示例

数学计算

from deterministic_calc import calculate

result = calculate("123456789 * 987654321")
print(result["result"])  # 121932631112635269

复杂计算

from deterministic_calc import run_python

code = """
import math
result = sum(i**2 for i in range(1000))
print(result)
"""
result = run_python(code)
print(result["stdout"])  # 332833500

Shell 命令

from deterministic_calc import run_shell

result = run_shell("ls -la /tmp")
print(result["stdout"])

⚠️ 安全说明

  • calculate()safe_eval() 是沙箱安全的
  • run_python()run_shell() 可执行任意代码,需谨慎使用
  • 生产环境建议只暴露 calculate()safe_eval()

📄 License

MIT

安全使用建议
This skill contains a safe AST-based evaluator (safe_eval) that is appropriate for deterministic math, but it also exposes run_python and run_shell which execute arbitrary code/commands on the host and file read/write functions. The README and SKILL.md acknowledge these risks, but the top-level description ('secure, sandboxed execution') is misleading. Before installing: (1) Treat run_python/run_shell as dangerous—do not enable them in production or on hosts with sensitive data. (2) If you need only deterministic math, restrict the skill's surface to safe_eval (and consider removing or disabling run_python/run_shell). (3) Run the skill in an isolated environment (container or sandbox) and limit agent permissions. (4) Review and vet the code (especially subprocess.run calls and file IO) and avoid granting the skill autonomous invocation for sensitive workflows. (5) If in doubt, ask the publisher for an explanation of their sandboxing guarantees or request a variant that lacks code/shell execution.
功能分析
Type: OpenClaw Skill Name: deterministic-calc-skill Version: 1.0.0 The skill provides high-risk capabilities including arbitrary shell command execution (run_shell), arbitrary Python code execution (run_python), and unrestricted file read/write operations in __init__.py. While these are documented as risky, they provide a massive attack surface for remote code execution and data exfiltration. Specifically, the calculate function in __init__.py dangerously falls back to run_python for any expression that fails the safe_eval check, which could be exploited to execute arbitrary code under the guise of a mathematical expression.
能力评估
Purpose & Capability
The name/description focus on safe, sandboxed deterministic computation. The code provides a safe AST-based safe_eval (expected) but also exposes run_python (subprocess.run with python3 -c) and run_shell (subprocess.run with shell=True) plus read_file/write_file APIs. Those unsandboxed capabilities exceed the minimal needs of a 'deterministic calculator' and contradict the 'secure, sandboxed' claim.
Instruction Scope
SKILL.md documents and examples include read_file, write_file, run_python and run_shell usage. While the docs warn about risk, the runtime instructions and examples explicitly show how to perform arbitrary code execution and file operations, which broaden the scope to general remote code execution and filesystem access.
Install Mechanism
No install spec or external downloads are present; the package is distributed as source files in the skill bundle. No network fetches or archive extraction are attempted by an installer.
Credentials
The skill declares no required environment variables or credentials (appropriate for a math utility). However, because it lets callers run shell commands and read/write arbitrary file paths, it can be used to access local secrets or exfiltrate data even without explicit credential requests.
Persistence & Privilege
always:false and no code attempts to modify other skills or global agent settings. The included publish.sh can initialize a git repo and run a test invocation, but that script is for publishing and not part of runtime persistence.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install deterministic-calc-skill
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /deterministic-calc-skill 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of deterministic-calc-skill: - Introduces functions for deterministic mathematical and code execution tasks, avoiding model-generated calculation errors. - Provides safe, sandboxed calculation functions: calculate(expression) and safe_eval(expression). - Adds ability to execute arbitrary Python code (run_python) and shell commands (run_shell), with safety caveats. - Includes clear API documentation, usage examples, and installation instructions. - Highlights security recommendations for safe operation in production environments.
元数据
Slug deterministic-calc-skill
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

deterministic-calc-skill 是什么?

Provides secure, sandboxed execution of mathematical expressions and code to deliver exact computation results without model guesswork. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 110 次。

如何安装 deterministic-calc-skill?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install deterministic-calc-skill」即可一键安装,无需额外配置。

deterministic-calc-skill 是免费的吗?

是的,deterministic-calc-skill 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

deterministic-calc-skill 支持哪些平台?

deterministic-calc-skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 deterministic-calc-skill?

由 HardToThinkAUsername(@hardtothinkausername)开发并维护,当前版本 v1.0.0。

💬 留言讨论