Skip to main content

Built-in tools for TinyChat: file I/O, shell execution, search, and workflow

Project description

tinychat-builtin-tools

TinyChat 的内置工具插件包,为 LLM 提供文件操作、Shell 执行、文件搜索和工作流管理能力。

安装

pip install -e "./packages/tinychat-builtin-tools"

本包依赖 tinychat-ai,需先安装主项目。

工具列表

文件操作

工具 说明
read_file 读取文本文件,支持 offsetlimittail 参数
write_file 写入文件,自动创建父目录
edit_file 字符串替换编辑文件,支持 replace_all 批量替换

文件系统

工具 说明
list_directory 列出目录内容,子目录以 / 后缀标识

搜索

工具 说明
glob 按文件名模式查找文件(支持递归)
grep 按正则表达式搜索文件内容,支持 include 文件过滤、ignore_casecontext 上下文行、max_count 匹配上限

Shell

工具 说明
exec_shell 执行 Shell 命令,支持 timeout 超时和 working_directory 工作目录

工作流

工具 说明
todo_list 管理待办事项列表和工作流(创建、执行、暂停、恢复、取消等)

其他

工具 说明
no_action 显式退出通道,用于 LLM 在无需工具时直接回答

Shell 安全

exec_shell 内置多层安全机制:

  • 命令白名单:仅允许预配置的命令执行,危险命令(sudorm -rf /mkfs 等)始终被拦截
  • 环境变量清理:自动过滤敏感环境变量(PATHHOME 等保留)
  • 超时控制:默认 30 秒超时,防止长时间运行

白名单配置通过 TOML 文件加载,详见 shell_security.pycommand_config.py

插件注册

工具通过 Python entry points 注册,在 pyproject.toml 中定义:

[project.entry-points."tinychat.tools"]
read_file = "tinychat_builtin_tools.files:ReadFileTool"
write_file = "tinychat_builtin_tools.files:WriteFileTool"
# ...

TinyChat 主程序启动时自动发现并加载所有已注册的工具。

项目结构

tinychat_builtin_tools/
├── __init__.py
├── files.py           # read_file, write_file, edit_file
├── fs.py              # list_directory
├── search.py          # glob, grep
├── shell.py           # exec_shell
├── shell_security.py  # 命令验证与环境变量清理
├── shell_defaults.py  # 默认安全命令白名单
├── command_config.py  # TOML 白名单配置加载
├── todos.py           # todo_list(待办事项 + 工作流)
└── no_action.py       # no_action

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinychat_builtin_tools-0.1.6.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinychat_builtin_tools-0.1.6-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file tinychat_builtin_tools-0.1.6.tar.gz.

File metadata

  • Download URL: tinychat_builtin_tools-0.1.6.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for tinychat_builtin_tools-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d0cd9b98fa3ce0828902c31730b593b9ed3a1e6f5f237aa44db8a3bda26304ce
MD5 6a2b20732c136d4e126f23adcefec9e4
BLAKE2b-256 85e8585a84b46e0d9051684456519e8e4fe05813aa9f56bb7302c6d63e32cad0

See more details on using hashes here.

File details

Details for the file tinychat_builtin_tools-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for tinychat_builtin_tools-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 47e1bce96bbc8a41a4ad8c6de4bffbc7693456e30174cee5b584b2c41b879480
MD5 0d6e0fe1c5db9c291f8a6b6d8ab330d5
BLAKE2b-256 a98d57e93c17b9b42e6982efd8cfbf92f08b6de01f7e4d898f4828791ed0eaae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page