pi-cliproxyapi-websearch
Zero-configuration native web search injection for CLIProxyAPI in Pi
Package details
Install pi-cliproxyapi-websearch from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-cliproxyapi-websearch- Package
pi-cliproxyapi-websearch- Version
0.2.0- Published
- Oct 2, 2026
- Downloads
- 825/mo · 192/wk
- Author
- hkfires
- License
- MIT
- Types
- extension
- Size
- 37 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-cliproxyapi-websearch
A native web search extension (web_search) tailored for the CLIProxyAPI provider in Pi.
Zero configuration, zero secondary authentication, no extra API keys or OAuth required — seamlessly reuses existing cliproxyapi connections and model credentials from Pi.
⚠️ Prerequisites:
- CLIProxyAPI Server: Version
v7.3.5or higher.- Pi Provider Extension: Must be paired with
@router-for-me/pi-cliproxyapi-provider.
Features
- Zero Config, No Re-authentication: Directly reuses the authenticated CLIProxyAPI credentials (BaseURL and API Key) from Pi's model runtime. No re-OAuth or manual API key configuration required.
- Dynamic Current Model / Automatic Fallback:
- By default, uses the active
cliproxyapimodel from your current session to perform searches (supportsgemini-3.8-flash-high,gpt-5.6-*,gpt-6-*,grok-*,gpt-5.5, etc.). - If the active session uses a model from another provider, the extension automatically selects an available search model from the registered
cliproxyapicatalog.
- By default, uses the active
- Isolated Sub-request Architecture: Dispatches lightweight sub-requests containing only the native
web_searchtool, completely isolated from local coding tools to prevent mixed-tool conflicts and server-side stripping issues. - Model Switching Command: Built-in
/websearch-modelslash command to inspect, configure, or reset the search model anytime. - Execution Time Display: Displays execution duration (
Took X.Xs/Elapsed X.Xs) matching Pi's shell tool conventions.
Installation
# 1. Install the CLIProxyAPI Provider extension (if not already installed)
pi install npm:@router-for-me/pi-cliproxyapi-provider
# 2. Install this search extension
pi install npm:pi-cliproxyapi-websearch
Local development or testing:
pi -e ./extensions/index.ts
Commands
| Command | Description |
|---|---|
/websearch-model |
Interactive selection: Opens a terminal selection menu (ctx.ui.select), with the top option dynamically following the current session model, followed by candidate models in alphabetical order. |
/websearch-model <model-id> |
Direct assignment: Directly configure a specific CLIProxyAPI search model (supports Tab completion). |
/websearch-model reset |
Reset to default: Restore dynamic tracking of the current session model (aliases: reset, current, auto). |
Codemode
With Codemode enabled in Pi 1.0.0, scripts can call tools.web_search({ query }) and receive an object with:
query: the trimmed search query.text: the same Markdown summary returned by a normal tool call.sources: all unique reported sources as{ url, title? }(an empty array when none are reported).
To enable Codemode in Pi, add +codemode to defaultTools in ~/.pi/agent/settings.json:
{
"defaultTools": ["+codemode"]
}
Example Codemode script:
const results = await Promise.all([
tools.web_search({ query: "Node.js release notes" }),
tools.web_search({ query: "TypeScript release notes" }),
]);
for (const result of results) {
text(result.text);
text(result.sources.map((source) => source.url));
}
The tool remains available for normal calls without Codemode; text output, progress updates, and terminal rendering are unchanged. Failed searches reject the script call rather than returning an empty success result.
Development
npm ci
npm run check # TypeScript typecheck + unit tests (Node.js native test runner)
中文说明
专为 Pi 的 CLIProxyAPI Provider 打造的原生网络搜索插件(web_search)。
零配置、零二次认证、无需额外 API Key 或 OAuth,直接复用 Pi 中已有的 cliproxyapi 连接与模型凭据。
⚠️ 前置依赖:
- CLIProxyAPI 服务端:版本需为
v7.3.5及以上。- Pi Provider 插件:必须搭配
@router-for-me/pi-cliproxyapi-provider使用。
特性
- 零配置、免二次认证:直接从 Pi 的模型运行时中复用已登录的 CLIProxyAPI 凭据(BaseURL 与 API Key),无需重新 OAuth,也无需手动配置 API Key。
- 直接使用当前模型 / 自动回退:
- 默认跟随当前会话中的
cliproxyapi模型执行搜索(支持gemini-3.8-flash-high、gpt-5.6-*、gpt-6-*、grok-*、gpt-5.5等系列)。 - 若当前会话使用的是其他 Provider 模型,插件会自动从已注册的
cliproxyapi目录中选取可用的搜索模型回退执行。
- 默认跟随当前会话中的
- 纯净子请求架构:后台发起仅包含原生
web_search的纯净轻量请求,完全剥离本地编码工具,彻底杜绝混合工具冲突与服务端剥离问题。 - 模型切换命令:内置
/websearch-model命令,随时查看、指定或重置搜索模型。 - 执行时间显示:显示执行耗时(
Took X.Xs/Elapsed X.Xs),与 Pi 的终端工具规范一致。
安装
# 1. 安装 CLIProxyAPI Provider 插件(若未安装)
pi install npm:@router-for-me/pi-cliproxyapi-provider
# 2. 安装本搜索插件
pi install npm:pi-cliproxyapi-websearch
本地开发或测试加载:
pi -e ./extensions/index.ts
命令
| 命令 | 说明 |
|---|---|
/websearch-model |
交互式选择:弹出终端选择菜单(ctx.ui.select),首项为动态跟随当前会话模型,其余候选模型按字母顺序排列,直接用方向键选择 |
/websearch-model <model-id> |
命令行直设:直接指定特定的 CLIProxyAPI 搜索模型(支持 Tab 键自动补全) |
/websearch-model reset |
重置为默认:恢复为自动跟随当前会话模型(支持 reset、current、auto) |
Codemode
在 Pi 1.0.0 中启用 Codemode 后,脚本可通过 tools.web_search({ query }) 获取结构化对象:
query:去除首尾空白后的查询。text:与普通工具调用相同的 Markdown 搜索总结。sources:返回的全部去重来源,格式为{ url, title? },无来源时为空数组。
要在 Pi 中启用 Codemode,推荐在 ~/.pi/agent/settings.json 的 defaultTools 中添加 +codemode:
{
"defaultTools": ["+codemode"]
}
Codemode 脚本示例:
const results = await Promise.all([
tools.web_search({ query: "Node.js 发布说明" }),
tools.web_search({ query: "TypeScript 发布说明" }),
]);
for (const result of results) {
text(result.text);
text(result.sources.map((source) => source.url));
}
未启用 Codemode 时仍可正常调用,文本输出、进度通知和终端展示保持不变。搜索失败时脚本调用会抛出错误,不会返回空的成功结果。
开发
npm ci
npm run check # TypeScript 类型检查 + 单元测试(Node.js 原生测试套件)