Three coordinated things:
1. Resolve the committed upstream/main merge conflicts. 94 files were
sitting with raw <<<<<<< HEAD ... >>>>>>> upstream/main blocks. Every
conflict had HanzoBot/Bot on HEAD and OpenClaw on upstream. Resolved
by keeping HEAD everywhere — 540 conflict blocks.
2. Rewrite remaining OpenClaw text refs.
OPENCLAW → HANZO_BOT
OpenClaw → HanzoBot (PascalCase type identifiers)
openclaw → bot (codebase convention — botToken,
botUsername etc.; avoids invalid
hyphenated JS identifiers)
openclaw[_]/openclaw[A-Z] → bot[_]/bot[A-Z] (compound)
ai.openclaw.x → ai.hanzo.bot.x (JVM package path)
3. Delete or rename openclaw-named file paths (116 of them). Dead
duplicates with a Bot-named canonical from the partial migration:
deleted. Otherwise renamed.
ai/openclaw/** → deleted (ai/hanzo/bot/** canonical)
Sources/OpenClaw*/ → deleted (Sources/Bot* canonical)
Tests/OpenClawIPCTests/ → deleted (Tests/BotIPCTests canonical)
OpenClawKit/ → deleted (BotKit canonical)
openclaw-tools.*.ts → deleted (bot-tools.*.ts canonical)
openclaw-root.ts etc. → deleted (bot-root.ts canonical)
types.openclaw.ts → deleted (types.bot.ts canonical)
extensions/*/openclaw.plugin.json → renamed hanzo-bot.plugin.json
docs/start/openclaw.md → renamed hanzo-bot.md (+ zh-CN)
docs/assets/openclaw-*.png, whatsapp-openclaw*.jpg → deleted
scripts/.../openclaw-* → deleted (bot/hanzo-bot parallels)
openclaw.mjs → deleted (hanzo-bot.mjs is package.bin)
Then patched 65 broken JS/TS import strings where hanzo-bot had ended
up inside an import path ('./types.hanzo-bot.js' → './types.bot.js'
etc., since the on-disk filename uses the brand-neutral bot- prefix).
Pre-existing lint debt cleaned up to get oxlint --type-aware to 0/0:
removed the dead i18n test that referenced a path no longer existing;
defined the missing DIDConfig and WalletConfig types in types.base.ts
(they were imported but never declared); dropped unused imports;
collapsed redundant type assertion and a tautological meta.bot lookup
that the openclaw→bot rename made redundant.
The a2ui.bundle.js generated artifact is kept at its pre-rebrand
contents — it gets regenerated by 'pnpm canvas:a2ui:bundle' from
sources I cannot rebuild in this commit; the source side is clean.
Verified: 0 occurrences of openclaw (case-insensitive) in tree source
content, 0 file or directory paths with openclaw in the name; oxlint
--type-aware src test reports 0/0.
5.3 KiB
read_when, summary, title, x-i18n
| read_when | summary | title | x-i18n | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
通过 Ollama(本地 LLM 运行时)运行 HanzoBot | Ollama |
|
Ollama
Ollama 是一个本地 LLM 运行时,可以轻松在你的机器上运行开源模型。HanzoBot 通过 Ollama 的 OpenAI 兼容 API 进行集成,并且当你通过 OLLAMA_API_KEY(或认证配置)启用且未定义显式的 models.providers.ollama 条目时,可以自动发现支持工具调用的模型。
快速开始
-
安装 Ollama:https://ollama.ai
-
拉取模型:
ollama pull llama3.3
# 或
ollama pull qwen2.5-coder:32b
# 或
ollama pull deepseek-r1:32b
- 为 HanzoBot 启用 Ollama(任意值即可;Ollama 不需要真实密钥):
# 设置环境变量
export OLLAMA_API_KEY="ollama-local"
# 或在配置文件中设置
hanzo-bot config set models.providers.ollama.apiKey "ollama-local"
- 使用 Ollama 模型:
{
agents: {
defaults: {
model: { primary: "ollama/llama3.3" },
},
},
}
模型发现(隐式提供商)
当你设置了 OLLAMA_API_KEY(或认证配置)且未定义 models.providers.ollama 时,HanzoBot 会从本地 Ollama 实例 http://127.0.0.1:11434 发现模型:
- 查询
/api/tags和/api/show - 仅保留报告了
tools能力的模型 - 当模型报告
thinking时标记为reasoning - 在可用时从
model_info["<arch>.context_length"]读取contextWindow - 将
maxTokens设置为上下文窗口的 10 倍 - 所有费用设置为
0
这样无需手动配置模型条目,同时保持目录与 Ollama 的能力对齐。
查看可用模型:
ollama list
hanzo-bot models list
要添加新模型,只需通过 Ollama 拉取:
ollama pull mistral
新模型将被自动发现并可供使用。
如果你显式设置了 models.providers.ollama,自动发现将被跳过,你必须手动定义模型(见下文)。
配置
基本设置(隐式发现)
启用 Ollama 最简单的方式是通过环境变量:
export OLLAMA_API_KEY="ollama-local"
显式设置(手动模型)
在以下情况使用显式配置:
- Ollama 运行在其他主机/端口上。
- 你想强制指定上下文窗口或模型列表。
- 你想包含未报告工具支持的模型。
{
models: {
providers: {
ollama: {
// 使用包含 /v1 的主机地址以兼容 OpenAI API
baseUrl: "http://ollama-host:11434/v1",
apiKey: "ollama-local",
api: "openai-completions",
models: [
{
id: "llama3.3",
name: "Llama 3.3",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 8192,
maxTokens: 8192 * 10
}
]
}
}
}
}
如果设置了 OLLAMA_API_KEY,你可以在提供商条目中省略 apiKey,HanzoBot 会自动填充以进行可用性检查。
自定义基础 URL(显式配置)
如果 Ollama 运行在不同的主机或端口上(显式配置会禁用自动发现,因此需要手动定义模型):
{
models: {
providers: {
ollama: {
apiKey: "ollama-local",
baseUrl: "http://ollama-host:11434/v1",
},
},
},
}
模型选择
配置完成后,所有 Ollama 模型即可使用:
{
agents: {
defaults: {
model: {
primary: "ollama/llama3.3",
fallbacks: ["ollama/qwen2.5-coder:32b"],
},
},
},
}
高级用法
推理模型
当 Ollama 在 /api/show 中报告 thinking 时,HanzoBot 会将模型标记为具有推理能力:
ollama pull deepseek-r1:32b
模型费用
Ollama 免费且在本地运行,因此所有模型费用均设置为 $0。
上下文窗口
对于自动发现的模型,HanzoBot 会使用 Ollama 报告的上下文窗口(如果可用),否则默认为 8192。你可以在显式提供商配置中覆盖 contextWindow 和 maxTokens。
故障排除
Ollama 未被检测到
确保 Ollama 正在运行,且你已设置 OLLAMA_API_KEY(或认证配置),并且未定义显式的 models.providers.ollama 条目:
ollama serve
同时确认 API 可访问:
curl http://localhost:11434/api/tags
没有可用模型
HanzoBot 仅自动发现报告了工具支持的模型。如果你的模型未列出,可以:
- 拉取一个支持工具调用的模型,或
- 在
models.providers.ollama中显式定义该模型。
添加模型:
ollama list # 查看已安装的模型
ollama pull llama3.3 # 拉取模型
连接被拒绝
检查 Ollama 是否在正确的端口上运行:
# 检查 Ollama 是否在运行
ps aux | grep ollama
# 或重启 Ollama
ollama serve