tabby-ai-tools 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,12 @@
2
2
 
3
3
  [← 返回 README](../README.md) · [使用指南](guide.md)
4
4
 
5
+ 后续供应商设置页改版尚未实现;规划和研究资料仅保留在本地,不随插件分发。功能与发布状态以实际代码和发布说明为准。
6
+
7
+ v0.4.1 已优先加入 `provider: custom`:可选 `apiFormat: chat-completions | responses`,缺省为 Chat Completions。`apiPath` / `usesResponsesApi` 统一推理路径与工具结果格式;模型发现仍用 `/models`。`keySource: none` 仅限自定义连接,密钥服务返回空值且请求省略认证头。自定义协议加入历史指纹,既有供应商指纹不变;切换协议通过已有通用上下文导入路径处理。设置中变更协议、端点或密钥会取消并清除旧连接测试和模型列表,旧异步结果不能覆盖新状态。自定义接口不推断厂商 Thinking 参数,不硬编码模型能力。
8
+
9
+ `test/api-agent.test.js` 覆盖自定义 Chat Completions 的现有 Agent 回归、Responses 连续工具往返与恢复、协议切换、无密钥模型发现与流式回复、配置失效及原供应商指纹兼容。全部使用本地 HTTP/SSE 夹具;真实第三方服务和桌面端需另行验证。协议参考:[OpenAI Chat Completions](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)、[Responses 迁移与原生历史](https://developers.openai.com/api/docs/guides/migrate-to-responses)。
10
+
5
11
  ## 本地开发
6
12
 
7
13
  ```bash
@@ -11,7 +17,7 @@ npm test
11
17
  npm run build
12
18
  ```
13
19
 
14
- CI 使用 Node.js 20,在 Ubuntu、macOS 和 Windows 上运行类型检查、测试和构建。开发时可用 `TABBY_PLUGINS=/path/to/tabby-ai-tools tabby --debug` 加载插件。
20
+ CI 使用 Node.js 22.19.0,在 Ubuntu、macOS 和 Windows 上运行类型检查、测试和构建。开发时可用 `TABBY_PLUGINS=/path/to/tabby-ai-tools tabby --debug` 加载插件。
15
21
 
16
22
  ### 安装后的重启提示
17
23
 
@@ -54,7 +60,7 @@ powershell -ExecutionPolicy Bypass -File .\scripts\validate-windows.ps1 -Executa
54
60
 
55
61
  `test/api-agent.test.js` 使用本地 HTTP/SSE 夹具测试真实请求格式、按连接显示的测试进度、鉴权错误、取消、非 SSE 响应,以及在服务端延迟结束请求时首个正文片段已经触发视图刷新。还覆盖 API/Codex 往返迁移、分页历史导出、首次原生消息前的重启恢复和目标延迟激活。真实供应商连通性与 Tabby 桌面 UI 需单独验证。
56
62
 
57
- 模型列表测试覆盖四种供应商的 GET 鉴权、分页去重、错误脱敏、不跟随重定向、无模型配置时获取列表、刷新与配置变更失效,以及关闭连接时取消请求。实现遵循 [DeepSeek 模型列表](https://api-docs.deepseek.com/api/list-models/)与 [Claude 模型列表及分页](https://platform.claude.com/docs/en/api/models/list)的接口;不提供模型列表的端点保留手动输入模型 ID。
63
+ 模型列表测试覆盖 OpenAI、DeepSeek、GLM、Kimi API、Kimi Coding Plan、百炼 Coding Plan 与 Claude的 GET 鉴权、分页去重、错误脱敏、不跟随重定向、无模型配置时获取列表、刷新与配置变更失效,以及关闭连接时取消请求。实现遵循 [DeepSeek 模型列表](https://api-docs.deepseek.com/api/list-models/)与 [Claude 模型列表及分页](https://platform.claude.com/docs/en/api/models/list)的接口;不提供模型列表的端点保留手动输入模型 ID。
58
64
 
59
65
  可运行 `npm run smoke:context`(或 `npm run smoke:context -- /path/to/codex`)验证本机真实 Codex 的上下文导入、恢复、历史导出及目标保留。该脚本不发送 `turn/start`,并检查导入不会自动启动回合;测试线程在退出时归档,不调用模型或执行工具。
60
66
 
@@ -88,6 +94,38 @@ npm run skill:check # 检查内嵌知识与 skill 文件是否一致
88
94
 
89
95
  任务流程仅由 `/remember TASK` 开始录制,结束后设置别名,`/task1` 执行。`src/sudo-workflow.ts` 构造终端内非交互预检与保活,`src/tab-tools.ts` 管理其任务生命周期;使用假 sudo 测试预检失败和跨命令保活,不能替代真实桌面/SSH 策略验证。
90
96
 
91
- 流程身份和验收采用结构化 `TaskStep.server/dependsOn/verification/verificationCommands`。`read_tab` 仅提取连接字段白名单和会话路径;`workflow_checkpoint` 由面板路由到 `TaskMemory`,使用同终端新观察和串行发送门禁。通用规则在 bundled skill,具体流程和约束由发送时隐藏提示注入。旧库字段可选保持兼容;新录制须有完整身份及逐步验收。不将单纯读取或发送回执作为成功证明,语义验收仍由模型判断。
97
+ 流程身份和验收采用结构化 `TaskStep.server/dependsOn/verification/verificationCommands`。`read_tab` 仅提取连接字段白名单和会话路径;`workflow_checkpoint` 由面板路由到 `TaskMemory`,使用同终端新观察和串行发送门禁。通用规则在 bundled skill,具体流程和约束由发送时隐藏提示注入。旧库字段可选保持兼容;新录制须有完整身份及逐步验收。不将单纯读取或发送回执作为成功证明,语义验收仍由模型判断。`workflow_status` 与 `workflow_set_alias` 同样由面板路由:前者区分录制、别名执行、归档中、拒绝归档和写盘失败,后者仅操作本会话/目录最近完成的显式录制,禁止只读模式修改。checkpoint 返回录制模式和归档资格;写盘失败保留已验收记录供别名工具重试,不重放终端命令。发送后续目标前等待完成中的归档,避免清理录制进度。最近录制及失败重试缓冲仅在当前进程保留,重启后已落盘流程仍通过设置管理。
92
98
 
93
99
  终端接管由 `send_input` 自动处理,不再生成 `local/terminalTakeover` 请求。检测未知(SSH、无枚举接口、枚举异常)时不因检测能力缺失暂停,不盲发 Ctrl+C;已检测的无关进程需要 `foregroundTaskNeeded=false`,发送 Ctrl+C 并验证停止。保留任务所需进程、会话/所有权检查、取消与只读限制。
100
+
101
+ ## Claude Code 本机引擎(开发版)
102
+
103
+ 方案和官方依据见 [Claude Code 接入](claude-code.md)。`claude-code-profile.ts` 提供独立的内置连接与配置;`claude-code-client.ts` 负责发现、能力/登录检查和有界进程回收;`claude-code-mcp.ts` 提供单次运行的认证 loopback MCP;`claude-code-agent.ts` 将官方 CLI 适配到已有会话与面板端口。`ApiAgent.createAdapter` 是可替换推理入口,MCP 与 API 的工具调用共用验证、审批、执行前持久化和重复循环检查。不得把本机连接交给 HTTP API 或密钥服务。
104
+
105
+ `test/claude-code.test.js` 与 `test/fixtures/claude-cli.cjs` 使用真实子进程和 HTTP,所有模型输出均为夹具。新增代码不依赖 Agent SDK,也不下载或修改 Claude Code。常规验证不运行真实模型;跨平台桌面和真实订阅仍需要单独验证。
106
+
107
+ ## 默认持续执行与统一 reasoning 选择
108
+
109
+ API / Claude Code 的 active Goal 在普通文本响应结束后由 `ApiAgent` 自动续行,保持同一个 turn、原生工具和推理历史、预算累计以及停止句柄。测试覆盖超过历史 20 轮、普通响应后的继续、完成/阻塞/显式暂停、文字空转检测与预算/中断。历史默认 20 迁移为 0;主动设置的限制带 `toolRoundLimitConfigured` 标记。
110
+
111
+ `model-reasoning.ts` 为缺少服务端能力元数据的已知模型提供保守等级,模型浮窗对 API / Claude Code 统一提供第二步、默认值与手动输入。离线 HTTP / CLI 测试覆盖选中后保存、下一次推理请求中的供应商原生参数、默认值清除及保存失败回滚。不以真实模型调用作为常规验证。
112
+
113
+ Kimi/百炼 Coding Plan 的实现与验证边界见 [配置说明](coding-plans.md)。本地夹具还验证区域端点预设、保留自定义代理和密钥草稿、切换区域取消旧模型发现、两套 Kimi Key 配置、持久缓存标识、仅思考模型参数和百炼 `enable_thinking`。没有运行收费模型或证明真实套餐准入;区域的可用模型与额度须以各平台控制台为准。
114
+
115
+ ## 终端回显与重试回归
116
+
117
+ 面板不订阅 `terminalOutput.updates$`,移除了 700ms / 2,000 字符批次经 `turn/steer` 注入的路径。终端服务仍使用有界缓冲供 `read_tab` 和用户发送/继续时的一次摘要读取;重试等待只用每秒刷新的本地 UI 时钟展示已等待时长与可用的倒计时,不创建模型请求或新的后台重试循环;恢复、断线、换会话、取消和销毁面板时清理 UI 时钟。
118
+
119
+ `turn-retry.ts` 识别字符串错误类别与结构化 `httpStatusCode: 429`。本地 Codex app-server 生成的 `ErrorNotification` 仅包含 `error / willRetry / threadId / turnId`;`TurnError` 的 `message / additionalDetails` 可以包含重试时长,但没有独立截止时间字段。只解析明确的 `retry in/after N seconds/ms/minutes` 文本;缺失时显示未知。后台日志中未发给客户端的信息不会被推测或轮询数据库补齐。
120
+
121
+ `test/turn-retry.test.js` 使用真实终端缓冲和模拟后台事件,覆盖一万段高频回显、等待期合并、重试时间缺失与显式时长、重复错误合并、旧回合事件、停止失败/成功、断线与恢复、UI 时钟自动刷新与清理。`test/task-memory-panel.test.js` 覆盖第二步已发送后限流、中断、恢复读取验收并继续,不重复发送 stash 或解压。全部为本地夹具;未访问用户 Windows 现场日志、未恢复原任务,也没有真实模型压力测试或 Tabby 桌面端到端验证。
122
+
123
+ ## Optional Pi sidecar and context projections
124
+
125
+ Use Node 22.19+ (`.nvmrc` and both CI workflows pin 22.19.0). Angular 15/webpack retain TypeScript 4.9; `typescript-pi` aliases the pinned 5.9.3 compiler for `runtime/pi/tsconfig.json` in NodeNext mode. `npm run typecheck` checks both boundaries, `npm test` first builds the sidecar, and `npm run build` emits `dist/index.js` plus `dist/pi/sidecar.mjs`. Pi is a runtime npm dependency, loaded only in the external Node process. Do not import its ESM SDK into the Angular bundle or assume the host Electron Node meets its engine requirement.
126
+
127
+ `PiBackend` reuses the host's API thread/UI/tool-policy port, while `PiAdapter` delegates the complete native loop to the SDK. The pipe acknowledges persisted session setup and accepted input before inference. Host action intents/results are stored before/after execution; repeated IDs use the saved result or return unknown-state evidence. Process exit aborts pending host tool waits. No process auto-restart or whole-prompt retry is allowed. `agent/lifecycle` carries structured retry, compaction and settled events; the panel clock only displays the supplied delay.
128
+
129
+ `api-context.ts` owns immutable API request projections. Summaries record source hashes/ranges and retain whole batches from a user-turn boundary; private reasoning is not passed to the summarizer. Pi session JSONL is the authority for Pi model context, with the Tabby store used for UI, goals, journals and portable migrations. The existing structured workflow state and checkpoint enforcement stay in the host.
130
+
131
+ `test/pi-agent.test.js` uses actual local HTTP streaming fixtures, without credentials or real model calls. Validate persistence, retry-after-tool, cancellation, budget/quota, repeated compaction and raw entry retention. The isolated Linux desktop fixture additionally loaded the plugin in official Tabby 1.0.238 (Electron 43.7.0 / Node 24.21.0), rendered runtime settings and exercised the sidebar → Node 22.19 Pi → host list_tabs → verified Goal flow. It used Xvfb and no real model. Windows/macOS, SSH/PTY mutations and real-provider execution still require their actual environments. See [runtime details](pi.md) and the [unreleased change note](releases/pi-runtime.md).
package/docs/guide.md CHANGED
@@ -12,7 +12,8 @@
12
12
 
13
13
  - 本机安装 [Tabby](https://github.com/Eugeny/tabby),并能访问所选 AI 服务。操作内网服务器时,本机还需能通过 Tabby 连接目标服务器。
14
14
  - **ChatGPT 订阅/Codex 登录模式**:本机安装 Codex CLI,在本地终端执行 `codex login`,使用具备 Codex 权限的 ChatGPT 账号登录,再执行 `codex login status` 确认认证状态,无需在插件中填写 API Key。插件默认连接选 **Codex(本机登录)**;可用模型、用量和工作区权限以账号实际权益为准。见 [OpenAI 官方认证说明](https://learn.chatgpt.com/docs/auth)。CLI 需支持 `thread/goal/*`;已测试版本见[验证记录](../VALIDATION.md)。
15
- - **API 模式**:准备 OpenAI、DeepSeek、GLM 或 Claude 的 API Key,无需安装 Codex CLI。订阅登录与 API 连接是两种独立配置方式。
15
+ - **Claude 订阅/Claude Code 本机模式**:本机安装官方 Claude Code,运行 `claude auth login`,用 `claude auth status` 核对账号与认证方式。在侧栏或默认连接中选择 **Claude Code(本机登录)**;无需在插件里配置订阅凭据。API Key/云平台可能使用独立计费。完整方案、权限、恢复机制与验证限制见 [Claude Code 接入](claude-code.md)。
16
+ - **API 模式**:准备 OpenAI、DeepSeek、GLM、Kimi、百炼 Coding Plan 或 Claude 对应的 Key,无需安装 Codex CLI。订阅登录与 API 连接是两种独立配置方式。
16
17
 
17
18
  ### 安装插件
18
19
 
@@ -40,24 +41,27 @@ npm run install:tabby -- "<Tabby 插件目录路径>"
40
41
  ### 开始第一个任务
41
42
 
42
43
  1. 选择本地终端或已连接的目标服务器终端。
43
- 2. 启动 Tabby 后 AI Tools 侧栏默认自动打开,无需先进入设置;收起后可点击工具栏机器人图标重新打开。默认使用本机 Codex;使用 API 时先按下文添加连接并设为默认,或在侧栏选择连接。
44
+ 2. 启动 Tabby 后 AI Tools 侧栏默认自动打开,无需先进入设置;收起后可点击工具栏机器人图标重新打开。默认使用本机 Codex;Claude Code 可直接在连接列表选择;使用 API 时先按下文添加连接并设为默认,或在侧栏选择连接。
44
45
  3. 输入“读取当前终端的报错,先分析原因,再提出修复方案”,按 **Ctrl+Enter / Cmd+Enter** 发送。普通 Enter 换行。
45
46
  4. 在侧栏查看回复、工具结果、提问与审批,在终端核对实际输出。执行中可追加要求,也可点击 **停止**;点击 **释放** 可取回终端输入权。
46
47
 
48
+ 侧栏顶部的连接(Provider)与模型(Model)并排显示;长名称可悬停查看。状态详情等面板只滚动内容区,标题栏与关闭按钮始终保留在顶部。
49
+
47
50
  ## 基础配置
48
51
 
49
- 打开 **Settings → AI Tools**。配置自动保存;修改 API 连接参数后,在侧栏点击连接图标应用。默认连接和当前正在编辑的连接分别选择,编辑连接不会自动把它设为默认。
52
+ 打开 **Settings → AI Tools**。配置自动保存;修改连接参数后,在侧栏点击连接图标应用。默认连接和当前正在编辑的连接分别选择,编辑连接不会自动把它设为默认。
50
53
 
51
54
  | 配置 | 设置方法与作用 |
52
55
  | --- | --- |
53
- | 默认连接 | 选择本机 Codex 或已添加的 API 连接;也可在侧栏顶部切换,保留当前对话。 |
56
+ | 默认连接 | 选择本机 Codex、Claude Code 或已添加的 API 连接;也可在侧栏顶部切换,保留当前对话。 |
54
57
  | Codex CLI 可执行文件 | 默认 `codex`,也可留空自动发现;指定时只填路径或命令名,不附参数。找不到时见[启动排查](#cli-自动发现与启动排查)。 |
58
+ | Claude Code CLI/模型 | 在连接列表选择 Claude Code,填写 CLI 路径(默认 `claude`)和模型别名/ID(默认 `sonnet`)。订阅登录通过官方 CLI 完成;推理强度可选。 |
55
59
  | 固定工作目录 | 留空时读取当前本地终端目录,读取不到则使用用户主目录;可指定本机目录。远程终端目录不会自动成为本机工作目录。 |
56
- | 模型与推理强度 | Codex 模型留空时沿用 CLI 默认;侧栏点击模型摘要或使用 `/model` 选择,下一回合生效。API 模型在连接中配置。 |
60
+ | 模型与推理强度 | Codex 模型留空时沿用 CLI 默认;侧栏点击模型摘要或使用 `/model` 选择,下一回合生效。API 与 Claude Code 同样先选模型,再选推理强度;两项一起应用。 |
57
61
  | 沙箱/文件访问 | 默认为工作目录可写,可选只读或完全访问。Codex 本地工具使用其沙箱;通过 Tabby 发送的命令使用目标终端账户的实际权限。只读模式禁止终端输入及修改操作。 |
58
62
  | 审批策略 | 默认为按需询问,也可选不可信命令询问或不询问;侧栏修改在下一回合生效。定时任务使用无人值守策略,见[定时说明](scheduled-tasks.md#生命周期与权限)。 |
59
63
  | 每个目标的 token 上限 | `0` 表示不设置上限;达到预算不代表完成。API 用量依赖服务商上报,预算为软上限。 |
60
- | 启动时打开侧栏 | 默认关闭,启用后下次启动自动打开。 |
64
+ | 启动时打开侧栏 | 默认开启,已有明确关闭设置会保留;取消后下次启动不自动打开。 |
61
65
  | 界面语言 | 默认跟随 Tabby,也可独立选择。 |
62
66
  | 任务流程与偏好 | 管理显式录制、流程别名和全局/目录偏好。 |
63
67
  | 定时任务 | 查看所有目录的计划,暂停、恢复、停止或删除。 |
@@ -115,29 +119,50 @@ AI 会发现并核对各连接与终端,将每一步的实际输出作为下
115
119
  | OpenAI API | Responses | `OPENAI_API_KEY` |
116
120
  | DeepSeek | Chat Completions | `DEEPSEEK_API_KEY` |
117
121
  | GLM | Chat Completions | `ZAI_API_KEY` |
122
+ | Kimi API | Chat Completions | `MOONSHOT_API_KEY` |
123
+ | Kimi Coding Plan | Chat Completions | `KIMI_API_KEY` |
124
+ | 阿里云百炼 Coding Plan | Chat Completions | `BAILIAN_CODING_PLAN_API_KEY` |
118
125
  | Claude | Messages | `ANTHROPIC_API_KEY` |
126
+ | 自定义(OpenAI 兼容) | Chat Completions(默认)或 Responses | `CUSTOM_API_KEY` |
127
+
128
+ Kimi API、Kimi Coding Plan 和阿里云百炼 Coding Plan 提供 **中国内地/国际** 区域选择,切换会自动填入对应端点;密钥须与购买平台和套餐匹配。手动地址不会被自动覆盖。完整端点表、默认模型、思考参数与使用范围见 [Coding Plan 配置](coding-plans.md)。套餐用于个人交互式编程;无人值守定时任务应使用普通按量 API。
119
129
 
120
130
  修改环境变量后需要完全退出并重启 Tabby。API 模式当前不自动压缩上下文,长任务可用 `/new` 新建会话;用量显示请求和本地累计 tokens,不显示 Codex 订阅额度。协议和存储设计见[多模型 Agent 说明](multi-provider-agent.md)。
121
131
 
122
- 在 **Settings → AI Tools → 添加 API 连接** 配置供应商、Base URL 和模型 ID。密钥来源默认选择“直接输入”,填写 API Key 即可,该方式将密钥保存在本地 Tabby 插件配置中。也可选择环境变量。插件不访问 Vault,旧 Vault 连接需重新选择密钥来源。
132
+ 在 **Settings → AI Tools → 添加 API 连接** 配置供应商、Base URL 和模型 ID。密钥来源默认选择“直接输入”,填写 API Key 即可,该方式将密钥保存在本地 Tabby 插件配置中。也可选择环境变量;自定义接口还支持“无需密钥”。插件不访问 Vault,旧 Vault 连接需重新选择密钥来源。
123
133
 
124
134
  设置页通过连接列表切换编辑对象,一次只显示一个连接的配置。列表显示供应商、模型和默认标记,各供应商使用不同色标;编辑区标题始终保留当前连接身份,表单独立滚动。窄窗口下列表改为横向滚动。新增连接自动进入编辑,删除当前连接后切换到相邻连接;Codex 本机引擎也从列表单独选择。切换编辑对象不会改变默认连接,默认连接通过顶部选择器或编辑区的“设为默认”修改。思考模式、推理强度、上下文窗口和工具轮数上限在 **高级参数** 中展开配置。
125
135
 
126
136
  点击当前连接编辑区下方的 **测试连接** 会发送一条简短请求,实际验证密钥、模型和流式响应,并产生少量 API 用量。进度与结果显示在按钮下方,测试中可以取消,60 秒超时;HTTP 错误、错误模型或不支持 SSE 的代理会显示相应提示。
127
137
 
128
- 配置端点和密钥后,聚焦模型 ID 输入框会自动获取列表;也可点击 **获取模型** 刷新,从建议中选择或手动填写 ID。侧栏点击模型摘要或输入 `/model` 同样会自动读取当前连接的模型列表。列表不支持或获取失败时,可在选择器中手动输入模型 ID 并应用。Thinking 开关、等级与模型摘要共用一行;侧栏很窄时会自动换行。
138
+ 配置端点和密钥后,聚焦模型 ID 输入框会自动获取列表;也可点击 **获取模型** 刷新,从建议中选择或手动填写 ID。侧栏点击模型摘要或输入 `/model` 同样会自动读取当前连接的模型列表。列表不支持或获取失败时,可在选择器中手动输入模型 ID;仍会进入推理强度选择,模型与等级一起应用。所有连接统一先选模型,再选 reasoning,支持服务商默认值;API 和 Claude Code 也可手动填写模型接受的原始等级。优先显示服务端上报的能力;没有元数据时,对已知模型提供保守的官方等级选项,未知模型提供默认值和手动输入。顶部模型摘要同时显示当前 reasoning;支持的 Thinking 开关单独保留,窄侧栏会自动换行。
139
+
140
+ DeepSeek 的 Thinking 开关在顶部保留,Low / High / Max 等级统一在模型浮窗中选择。关闭 Thinking 后不发送可能将其重新打开的推理强度参数;在浮窗主动选择非空等级会重新启用 Thinking,使等级生效。点击模型摘要或 `/model` 选择模型与推理强度,侧栏中的修改会自动应用。设置页修改供应商、端点或模型后仍需点击连接图标应用配置。思考阶段显示接收进度,正文增量到达后立即刷新;实际片段到达速度取决于服务商和代理。
129
141
 
130
- DeepSeek 对话窗顶部可直接修改 Thinking 开关和 Low / High / Max 等级,下回合生效,关闭 Thinking 后不发送可能将其重新打开的推理强度参数。点击模型摘要或 `/model` 也能选择模型与推理强度,侧栏中的修改会自动应用。设置页修改供应商、端点或模型后仍需点击连接图标应用配置。思考阶段显示接收进度,正文增量到达后立即刷新;实际片段到达速度取决于服务商和代理。
142
+ API 连接的“每回合工具轮数上限”设为 **0** 时不按固定次数中止任务,新连接默认使用 0;历史默认值 20 自动迁移为不限,无需逐个修改。其他已有自定义数值保留;今后主动设置的 20 也会保留。设为 1–100 时,仅工具调用轮次计数,最后额外保留收尾请求读取结果、更新一次目标状态并给出回复,收尾阶段不再操作终端;目标未完成仍显示未完成。停止和目标 token 预算在两种模式下都生效。读取受控终端默认等待 1 秒,也支持等待最多 30 秒后读取,减少等待命令输出时的空轮询。
131
143
 
132
- API 连接的“每回合工具轮数上限”设为 **0** 时不按固定次数中止任务,新连接默认使用 0;已有连接的数值保留,旧连接如仍设为 20,可改为 0 并重新连接。设为 1–100 时,仅工具调用轮次计数,最后额外保留收尾请求读取结果、更新一次目标状态并给出回复,收尾阶段不再操作终端;目标未完成仍显示未完成。停止和目标 token 预算在两种模式下都生效。读取受控终端默认等待 1 秒,也支持等待最多 30 秒后读取,减少等待命令输出时的空轮询。
144
+ API 与 Claude Code 的 Goal 仍为 active 时,普通文本回复或阶段总结不会结束执行;运行器在同一回合内自动继续,不询问是否 Continue goal。模型核对原始要求并验证结果后须调用 `agent_goal_update(status=complete, evidence=...)`。确实缺少用户信息、凭据、额外授权或外部依赖时可标记 blocked 并说明原因;仅用户明确要求暂停时使用 paused。停止、预算、主动设置的工具轮数上限和重复无进展检测仍有效;自动续行不绕过操作审批,不重试失败的模型请求,也不会重放历史命令。定时任务仍遵守其独立的整次运行限制。
133
145
 
134
146
  API 工具循环检测始终启用,无需等到轮数上限。近期同一段操作和结果连续出现三次(包括 A→B→C→A→B→C→A→B→C)时,会拦住后续工具,让模型总结卡点,并将目标标记为受阻;同一批剩余操作也不会执行。比较终端新追加的输出,忽略参数顺序、等待时长及操作说明的变化;运行中或状态未知的进程仅因画面不变不会触发,单纯“输入已发送”的回执也不能证明没有进展。检测记录随会话保存,直接继续或重启后重放同一循环的下一条命令会在发送前拦截;新目标清空记录。检测依据实际工具调用和结果,不能保证识别命令写法不同但含义相同的方案。
135
147
 
136
148
  任务结束后,在侧栏切换 API 连接,或在 DeepSeek 等 API 和 Codex 本机登录之间切换,都会带上当前对话、转发的终端输出、工具结果和任务目标。历史会转换成目标接口可用的文本,内部推理内容不会跨模型传递,历史工具不会重新执行。切回之前的连接时继续当前对话;旧快照仍可用 `/resume` 恢复,输入 `/new` 则开始空白对话。转入 Codex 时持久化导入的历史以供显示和重启恢复,并为模型设置历史文本;导入的进行中目标等到下一次主动发送消息后才激活,切换本身不触发推理。
137
149
 
150
+ ### 自定义 OpenAI 兼容接口
151
+
152
+ 1. 添加 API 连接,供应商选择 **自定义(OpenAI 兼容)**,为不同网关或本地服务分别命名。
153
+ 2. 默认选 **Chat Completions**(请求 `/chat/completions`);服务明确支持 Responses 时再切换为 **Responses**(请求 `/responses`)。不会自动尝试另一协议,避免重复请求和计费。
154
+ 3. 填写服务提供的基础地址,例如 `https://gateway.example/v1` 或 `http://localhost:1234/v1`。保留必需的 `/v1` 或其他前缀,不附加具体请求路径。自定义连接没有默认云端地址;空地址会报错。远程地址要求 HTTPS,HTTP 仅允许 `localhost`、`127.0.0.1`、`[::1]`,不支持普通内网 IP 的 HTTP。
155
+ 4. 选择直接输入 API Key 或环境变量(默认名称 `CUSTOM_API_KEY`),使用标准 Bearer 认证;不需要认证的本地服务可选 **无需密钥**。此模式不读取原来保存的 Key,也不发送 Authorization 请求头。切回内置供应商时恢复密钥认证。
156
+ 5. 获取模型列表,或手动填写服务要求的完整模型 ID(可包含命名空间)。聚焦输入框只获取列表,不调用推理;`/models` 不可用不影响手动配置。点击 **测试连接** 才会发送简短推理并产生相应用量,该测试不证明工具能力可用。
157
+ 6. 在侧栏选择连接或设为默认;设置修改后点击连接图标应用。可以保存多个独立自定义连接。切换协议、端点或模型时保留通用对话上下文和目标,不会重放历史工具调用;相同协议可恢复原生历史。
158
+
159
+ 终端 Agent 需要服务和模型都支持 SSE 流式响应及 function tools。自定义连接复用现有文本、工具、审批、停止、目标和历史功能,不发送厂商专用 `thinking`、`enable_thinking` 或缓存参数。推理强度默认留空;填写后按协议发送 `reasoning_effort`(Chat Completions)或 `reasoning.effort`(Responses),具体值由服务决定。Chat Completions 使用 `max_tokens`,Responses 使用 `max_output_tokens`、`store: false` 和加密推理历史选项;仅兼容部分协议的网关可能拒绝这些字段。服务上报的 usage 才能计入真实 token 用量,自定义 Chat Completions 不强制发送 `stream_options`;未上报时保持未知。暂不支持自定义请求头、查询参数认证、厂商专用字段或非流式接口。
160
+
161
+ 离线 HTTP/SSE 夹具已覆盖两种协议及工具往返;未知第三方网关和真实 Tabby 桌面显示需按实际服务验证,不能因“OpenAI 兼容”而视为所有厂商能力均可用。
162
+
138
163
  ## 重复任务与操作习惯
139
164
 
140
- 用 `/remember 任务描述` 明确开始录制,插件执行任务并记录已核对的终端步骤;完成后提示是否设置别名,例如 `task1`。之后直接发送 `/task1` 执行流程。普通任务不再自动归档,也不再按相似描述自动匹配;输入框中的“不检索记忆”复选框已移除。点击 **任务流程** 或输入 `/workflows` 查看当前目录的流程,设置中可以给已有流程添加别名。
165
+ 用 `/remember 任务描述` 明确开始录制,插件执行任务并记录已核对的终端步骤;完成后提示是否设置别名,例如 `task1`。之后直接发送 `/task1` 执行流程。普通任务不再自动归档,也不再按相似描述自动匹配;输入框中的“不检索记忆”复选框已移除。点击 **任务流程** 或输入 `/workflows` 查看当前目录的流程,设置中可以给已有流程添加别名。也可以直接告诉助手“设置别名为 pm1”:助手先用 `workflow_status` 核对本会话最近录制的目标与归档状态,再用 `workflow_set_alias` 保存并回读 `/pm1`。checkpoint 成功仅表示步骤验收;录制不完整或含敏感内容时会说明无法归档的原因。普通任务不能事后保存为流程,不能为了补存而重跑已完成操作。
141
166
 
142
167
  含 sudo 的流程会提前提示在每个实际执行终端运行 `sudo -v` 或 `sudo ls`,完成认证后继续。其他终端的认证不保证共享。执行时用 `sudo -n -v` 预检,每 30 秒非交互刷新;认证失效时停止该命令并要求重新认证。详情和清理边界见[任务流程说明](task-workflows.md)。各步骤还保存服务器 IP、持久连接/服务器 ID、操作路径、前置依赖和验收证据。跨服务器也逐步执行:读取对应终端的新结果,并通过步骤确认工具验收后,才放行下一步;目标或路径不符时停止。操作偏好继续在设置页管理,`/remember` 专用于开始任务录制。
143
168
 
@@ -181,13 +206,13 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
181
206
 
182
207
  - 输入框中按 ↑ 回看当前会话已发送的消息,按 ↓ 返回较新的消息,翻到最新之后会恢复未发送的草稿。多行输入仅在首行按 ↑、末行按 ↓ 时翻历史;恢复旧会话后也可回看其中的输入。
183
208
 
184
- - 在输入框键入 `/` 可查看面板支持的命令,用上下方向键选择、Enter 执行、Esc 收起列表。普通消息的 Enter 用于换行,`Ctrl+Enter` 或 `Cmd+Enter` 发送。`/model` 打开 Codex 模型列表,选模型后再选推理强度(Thinking level),选项与默认值以该模型上报的能力为准;两项一起保存并在下一回合生效。“当前 Codex 默认”会保存列表上报的具体模型 ID,已有会话也会切换到该模型。也可输入 `/model 模型ID` 进入该模型的推理强度选择。
209
+ - 在输入框键入 `/` 可查看面板支持的命令,用上下方向键选择、Enter 执行、Esc 收起列表。普通消息的 Enter 用于换行,`Ctrl+Enter` 或 `Cmd+Enter` 发送。`/model` 打开当前连接的模型列表,选模型后再选推理强度(Thinking level);Codex 以模型上报的能力为准,API 与 Claude Code 还支持服务商默认与手动输入;两项一起保存并在下一回合生效。“当前 Codex 默认”会保存列表上报的具体模型 ID,已有会话也会切换到该模型。也可输入 `/model 模型ID` 进入该模型的推理强度选择。
185
210
 
186
211
  ## 全部功能入口
187
212
 
188
213
  | 入口 | 用途 |
189
214
  | --- | --- |
190
- | 工具栏机器人图标 | 打开/收起侧栏,从当前终端绑定自动转发;侧栏边缘可拖动调宽。 |
215
+ | 工具栏机器人图标 | 打开/收起侧栏,从当前终端绑定上下文摘要;侧栏边缘可拖动调宽。 |
191
216
  | 侧栏连接选择、连接图标 | 切换 Codex/API 连接、应用连接参数或重新连接。 |
192
217
  | 模型摘要、Thinking 控件、`/model` | 选择模型、推理强度和支持的思考模式。支持 `/model 模型ID`。 |
193
218
  | `/new` 或 `new` | 开始新会话,保留旧会话。 |
@@ -201,7 +226,7 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
201
226
  | 侧栏提问选项与审批卡片 | 回答问题、补充自由文本、处理授权。 |
202
227
  | **停止**、**释放**、**临时释放** | 中断 AI 回合、取回全部或单个终端输入权;不会自动撤销已执行命令,已提交命令可能仍运行。 |
203
228
  | **继续当前目标** | 在目标仍未完成时继续推进。 |
204
- | **详情 → 自动转发** | 查看绑定源或停止新增输出自动转发;独立的按需读屏工具仍可使用。 |
229
+ | **详情 → 终端上下文** | 查看或解除摘要源绑定;运行中不自动转发输出,AI 用 `read_tab` 按需读取。 |
205
230
  | 消息复制、**回到最新消息** | 复制文本,恢复滚动跟随。 |
206
231
  | **Settings → AI Tools** | 配置连接、模型、权限、预算、启动、语言、流程偏好和定时任务。 |
207
232
  | 在对话中请求操作 Tabby | AI 可发现连接配置、标签、分屏、设置、快捷键与插件命令;SFTP、隧道等依赖已安装提供者的实际入口,原生弹窗可能需要人工操作。 |
@@ -213,7 +238,7 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
213
238
 
214
239
  - 发送被拒绝或回合执行失败时,对话区和输入框上方会显示具体原因。用量/频率超限提示等待恢复,并在已收到额度信息时显示重置时间;上下文和预算超限给出相应处理提示。同步发送失败会恢复输入内容;自动重试期间保留执行状态,收到正常回答后清除输入框上方的错误提示。
215
240
 
216
- - **详情**(也可输入 `/status` 打开)完整显示路径、会话 ID、任务状态、查询时 Codex 上报的模型与运行状态、上下文 token 和会话累计、额度、普通用量是否可用、目标、权限、控制终端列表及自动转发说明,并保留 **刷新** 查询。各项独立读取,部分读取失败时仍显示其他信息。详情高度受限且可滚动,窄侧栏内完整信息自动换行;详情与 `/resume` 历史列表互斥。历史、输出等异常通知仍直接显示。还支持 `/new` 和 `/help`。
241
+ - **详情**(也可输入 `/status` 打开)完整显示路径、会话 ID、任务状态、查询时 Codex 上报的模型与运行状态、上下文 token 和会话累计、额度、普通用量是否可用、目标、权限、控制终端列表及终端上下文说明,并保留 **刷新** 查询。各项独立读取,部分读取失败时仍显示其他信息。详情高度受限且可滚动,窄侧栏内完整信息自动换行;详情与 `/resume` 历史列表互斥。历史、输出等异常通知仍直接显示。还支持 `/new` 和 `/help`。
217
242
 
218
243
  - 上下文摘要收到 Codex 的 token 用量通知后显示百分比;未上报时显示“上下文 —”。**详情** 显示最近一次模型请求的用量、上下文窗口大小和会话累计 token;切换会话时会清空旧会话数字,等待新通知。
219
244
 
@@ -233,7 +258,8 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
233
258
 
234
259
  ## 终端输出与远程环境
235
260
 
236
- - 从终端点击工具栏图标会绑定该终端作为自动转发源;按游标只把新片段送给 Codex。同目录有多个终端时,恢复后的 AI 面板不会猜测自动转发源,需要从目标终端再次点击工具栏图标。AI 面板可随时在 **详情 → 自动转发** 中点击 **停止自动转发**;之后也可从终端重新绑定。独立的 `tabby_tabs` 工具会监控当前窗口的所有终端标签,以便 Codex 按需读取任意标签;停止自动转发不关闭工具读取能力。
261
+ - 从终端点击工具栏图标会绑定该终端作为上下文摘要源;仅在用户发送新回合或继续目标时附带最多 6,000 字符的新增输出。执行期间的回显保留在有界终端缓冲区,不会通过 `turn/steer` 自动追加或启动模型请求;AI 必须用 `read_tab` 主动读取结果。摘要不是流程验收证据。同目录有多个终端时,恢复后的 AI 面板不会猜测摘要源,需要从目标终端再次点击工具栏图标。可在 **详情 → 终端上下文** 中点击 **解除绑定**,独立的 `tabby_tabs` 按需读取不受影响。
262
+ - 收到后台 `willRetry` 错误事件后,侧栏保持回合执行中并显示限流/重试等待和实时已等待时长,暂时禁用追加发送。后台错误文本明确提供等待时长时显示下次重试时间及倒计时;倒计时结束但尚无返回时明确显示等待后台结果,否则显示“后台未提供下次重试时间”;账号额度重置时间不等同于下次重试时间。点击 **停止** 请求取消后台回合,收到中断结果后再继续。429 可能是请求频率或用量限制,不能仅据此认定长期额度耗尽;避免反复停止并立即新建任务。CLI 只写入本地日志、没有发送事件的信息无法在面板中展示。恢复流程先核对终端结果、产物、目录和 Git 状态,再验收待确认步骤,不重放已发送的 stash、restore、apply。
237
263
 
238
264
  - 新任务启动时最多附带 6,000 字,运行中每批最多 2,000 字、每回合最多 16,000 字,超出部分留给后续回合。缓存只保留已绑定终端最近 32,768 字;缓存溢出时会明确标记截断。`new` 会丢弃旧会话的未发送终端输出。
239
265
 
@@ -287,3 +313,11 @@ NVM 优先 current,其余按 Node 版本降序。IDE 同时支持 `.vscode-ins
287
313
 
288
314
  本地安装后请在 **已安装插件** 中查看;**可用插件** 列表来自 npm 搜索,未发布到 npm 的本地包不会出现在该列表。
289
315
 
316
+
317
+ ## Pi 与上下文压缩(v0.5.0)
318
+
319
+ 在 API 连接的“Agent 运行时”中选择 Pi SDK,填写外部 Node 22.19+ 的可执行文件路径,然后从侧栏重新连接。供应商、模型、Base URL 和密钥来源沿用连接设置;Pi 不提供订阅认证。仅开放 Tabby 宿主工具,审批、只读、终端所有权、sudo 与流程 checkpoint 继续生效。
320
+
321
+ 空闲时输入 `/compact` 手动压缩。内置 API 保留原始历史,按完整工具批次投影请求;Pi 保留自己的 JSONL 原始条目和压缩边界。自动压缩默认关闭,摘要本身消耗额度并计入 Goal 预算。Pi 的重试倒计时使用 SDK 结构化事件,取消会结束独立进程,不重放整段任务。中断后先读取真实终端再继续,未知动作不会自动重放。
322
+
323
+ Pi 的使用、存储、预算和验证限制见 [Pi runtime](pi.md)。开发与 CI 使用 Node 22.19+;升级系统 Node 不会改变 Electron 内置 Node。当前已验证本地 HTTP 夹具,并在独立配置的 Linux Tabby 1.0.238(Electron 43.7.0 / Node 24.21.0)中跑通侧栏、Pi 子进程、宿主 list_tabs 与 Goal 完成;真实模型、SSH/PTY 修改操作和 macOS/Windows 桌面仍待实测。此功能从 v0.5.0 开始提供。
@@ -1,10 +1,12 @@
1
1
  # 多模型 Agent 设计与评审
2
2
 
3
+ v0.4.1 新增自定义 OpenAI 兼容连接(`provider: custom`):`apiFormat` 显式选择 Chat Completions(缺省)或 Responses,不按模型名或 URL 推断协议。复用统一 Agent 工具循环、模型发现和上下文转换,不发送厂商专用 Thinking/缓存字段。可选直接 Key、环境变量或无认证;无认证模式不发 Authorization。历史指纹为自定义连接增加协议字段,保留既有供应商指纹。切换协议时导入通用文本和目标,避免将原生工具历史发到另一协议。配置与限制见[使用指南](guide.md#自定义-openai-兼容接口)。
4
+
3
5
  状态:设计评审完成,第一版已按下述范围实现。2026-10-17。
4
6
 
5
7
  ## 产品目标
6
8
 
7
- 同一 Tabby 侧栏支持现有 Codex 登录,以及 DeepSeek、GLM、OpenAI、Claude 的商业 API。API 模式无需安装 Codex。保留流式回复、终端读取与操作、人工审批、按目录恢复历史、任务目标和停止操作。
9
+ 同一 Tabby 侧栏支持现有 Codex 登录,以及 DeepSeek、GLM、Kimi、OpenAI、Claude 的商业 API,以及 Kimi/百炼 Coding Plan。API 模式无需安装 Codex。保留流式回复、终端读取与操作、人工审批、按目录恢复历史、任务目标和停止操作。
8
10
 
9
11
  提供多个连接配置,每个配置有独立名称、供应商、Base URL、模型 ID、密钥来源和模型参数。面板选择连接后再开始会话。切换连接需要当前任务结束;API 连接之间及 API/Codex 双向切换时携带当前对话的通用文本上下文和目标,修改端点或模型也保留上下文。历史按目标配置另存快照,禁止把一个供应商的推理块直接交给另一个供应商。
10
12
 
@@ -17,7 +19,7 @@ flowchart TD
17
19
  Factory --> Native[API Agent Runtime]
18
20
  Native --> Providers[模型协议适配器]
19
21
  Providers --> OpenAI[OpenAI Responses]
20
- Providers --> Chat[DeepSeek / GLM Chat Completions]
22
+ Providers --> Chat[DeepSeek / GLM / Kimi / Bailian Chat Completions]
21
23
  Providers --> Claude[Claude Messages]
22
24
  Native --> Store[本地会话与 Goal 存储]
23
25
  Codex --> Transfer[通用上下文导入与导出]
@@ -39,9 +41,11 @@ flowchart TD
39
41
  | OpenAI API | Responses | 带类型的 SSE、function_call/output、reasoning items |
40
42
  | DeepSeek API | Chat Completions | reasoning_content 回传、分片 tool_calls、Thinking 参数 |
41
43
  | GLM API | Chat Completions | reasoning_content 回传、Thinking 参数与不同端点 |
44
+ | Kimi API / Coding Plan | Chat Completions | 独立国内/国际端点和 Key、思考模型差异、reasoning_content、会话级缓存标识 |
45
+ | 百炼 Coding Plan | Chat Completions | 国内/国际套餐端点、专用 Key、enable_thinking;不走 Responses |
42
46
  | Claude API | Messages | content blocks、tool_use/tool_result、stop_reason、thinking signature |
43
47
 
44
- 不把所有供应商简化成替换 Base URL。不硬编码最新模型名称;模型 ID 由用户配置。参数按供应商和模型显式选择,未知能力使用保守值。原始 reasoning blocks 保存在所属会话中,工具续轮时原样回传;默认 UI 不显示内部推理。
48
+ 不把所有供应商简化成替换 Base URL。Kimi 与百炼预填官方模型示例,模型 ID 仍由用户配置,不限制手动输入。参数按供应商和模型显式选择,未知能力使用保守值。原始 reasoning blocks 保存在所属会话中,工具续轮时原样回传;默认 UI 不显示内部推理。
45
49
 
46
50
  API 请求由本机 Node 网络层执行,避开浏览器 CORS 和把密钥混入页面状态的问题。支持 HTTPS、自定义端点与明确允许的本地 HTTP 测试端点;跨域重定向不携带密钥。实现必须兼容 Tabby 实际宿主 Node/Electron,不能只依赖构建机的 Node 20。
47
51
 
@@ -86,7 +90,7 @@ API 模式的“只读”禁止发送输入及操作控件;有副作用的终
86
90
 
87
91
  顶部显示供应商与模型。模型选择使用当前配置中的模型 ID;设置页允许手动填写和多个配置。
88
92
 
89
- DeepSeek 侧栏提供 Thinking 开关和 low/high/max,修改后直接更新下一回合的配置快照,无需重连。协议层持续转发正文增量及不包含原始思考文本的思考接收进度;侧栏显式刷新 Node 回调产生的变化。设置页“测试连接”使用同一配置规范化与流式协议层发送简短无工具请求,在对应卡片显示进度、结果、取消和超时。
93
+ 所有连接的模型浮窗统一先选模型,再选 reasoning。API /models 上报等级优先;缺失时使用 `model-reasoning.ts` 中已知模型的保守等级,未知模型保留默认及手动输入。手动模型 ID 同样进入第二步。模型和等级一起保存、沿已有上下文交接路径应用;选择非空等级会重新开启已关闭的 Thinking。DeepSeek 顶部保留 Thinking 开关,开关修改直接更新下一回合的配置快照,无需重连。协议层持续转发正文增量及不包含原始思考文本的思考接收进度;侧栏显式刷新 Node 回调产生的变化。设置页“测试连接”使用同一配置规范化与流式协议层发送简短无工具请求,在对应卡片显示进度、结果、取消和超时。
90
94
 
91
95
  Codex 状态保留账户额度。API 模式显示模型用量和本地累计,不伪造“5 小时额度”“普通用量”等订阅信息。未提供上下文窗口时显示未知;上次请求输入占用与已上报累计 tokens 分开,tokens 统计不等同于货币计费。预算按已上报用量在请求边界检查,是软上限;在途请求可能超出,未上报用量无法计入。第一版不自动压缩历史,长对话需新建会话。
92
96
 
@@ -136,3 +140,20 @@ Goal 由本地 Runtime 持久化。一次模型请求结束只表示回合结束
136
140
  - [GLM 思考模式](https://docs.bigmodel.cn/cn/guide/capabilities/thinking-mode):交错思考及保留式思考的历史回传要求。
137
141
  - [Claude Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/how-tool-use-works):客户端工具执行循环与 stop_reason。
138
142
  - [Claude Thinking](https://platform.claude.com/docs/en/build-with-claude/thinking):Thinking 块与签名的保留要求。
143
+
144
+ ## Claude Code 本机引擎
145
+
146
+ 开发版新增内置连接 `claude-code`,使用独立的 `claudeExecutable`、`claudeModel`、`claudeReasoningEffort`、`claudeThreads` 配置。它复用会话存储和面板事件端口,但模型循环由官方 CLI 执行,Tabby 工具经临时认证 MCP 回到原有执行器。`runtime: claude-code` 的 profile 是本机元数据,不是可发往 Anthropic HTTP API 的连接。Claude API Key 接入继续保持独立。完整研究、边界、恢复与限制见 [Claude Code 接入方案](claude-code.md)。
147
+
148
+ ## Goal continuation and effort capability sources
149
+
150
+ API and Claude Code share the same active-goal continuation loop in `api-agent.ts`. A text response is persisted and followed by a continuation prompt while the goal remains active; provider-native tool/reasoning history stays intact. Completion, a real blocker, an explicit pause, cancellation, budget exhaustion, an explicitly configured tool cap or repeated no-progress evidence ends continuation. No fixed conversational-turn cap is added. The legacy default of 20 tool rounds migrates to zero; `toolRoundLimitConfigured` preserves newly explicit 20-round limits.
151
+
152
+ Reasoning metadata from `/models` takes priority. Fallback menus use conservative documented subsets; unknown/custom models retain provider defaults and manual values. Source references (checked 2026-10-24):
153
+
154
+ - [OpenAI reasoning](https://developers.openai.com/api/docs/guides/reasoning) and [GPT-5](https://developers.openai.com/api/docs/models/gpt-5).
155
+ - [DeepSeek model metadata](https://api-docs.deepseek.com/api/list-models/).
156
+ - [GLM thinking and effort](https://docs.bigmodel.cn/cn/guide/capabilities/thinking).
157
+ - [Claude effort](https://platform.claude.com/docs/en/build-with-claude/effort) and [Claude Code model settings](https://code.claude.com/docs/en/model-config). Alias resolution and CLI support remain account and installation dependent.
158
+
159
+ Kimi 与百炼 Coding Plan 的端点、区域、模型和套餐边界见 [Coding Plan 配置](coding-plans.md)。三种新连接沿用通用 Agent 工具循环;Kimi 以持久会话 ID 作为 `prompt_cache_key`,确保工具续轮、后续回合及重启恢复稳定。客户端标识为真实产品名,不冒用已获准的其他工具。
package/docs/pi.md ADDED
@@ -0,0 +1,41 @@
1
+ # Pi runtime
2
+
3
+ Version 0.5.0 offers **Pi SDK** as an optional runtime for API connections. It uses pinned `@earendil-works/pi-coding-agent` / `pi-ai` 1.4.0 in a separate ESM Node process. Codex and Claude Code remain independent CLI connections.
4
+
5
+ ## Setup
6
+
7
+ 1. Install an external **Node 22.19.0 or newer**. Updating your shell's Node does not update Electron's embedded Node.
8
+ 2. Install or update `tabby-ai-tools` to version 0.5.0 or newer in **Settings → Plugins**, then restart Tabby. For source installations, use Node 22.19+ to run `npm ci`, `npm run build` and `npm run install:tabby -- "<Plugins Directory>"`; the installer also installs runtime dependencies.
9
+ 3. In **Settings → AI Tools**, select an API connection, choose **Agent runtime → Pi SDK**, and enter its external Node executable if `node` is absent from Tabby's PATH. Use a real Node executable, not Tabby's executable or a shell command with flags.
10
+ 4. Keep the existing provider, Base URL, model ID and key source. OpenAI uses Responses, Claude API uses Anthropic Messages, and the other presets use Chat Completions; custom connections keep their selected protocol. Kimi Coding explicitly uses `system` messages and `max_tokens`, including international and proxy endpoints, rather than relying on SDK URL detection. API billing applies; choosing Pi does not provide a ChatGPT or Claude subscription login.
11
+ 5. Connect from the sidebar. The sidebar’s **Details** panel reports external Node and host Node/Electron versions. The explicit connection test uses the real Pi process and a harmless nonce tool; it consumes model quota when requested.
12
+
13
+ Only the Tabby tools advertised by the host are available. Pi's built-in shell, filesystem tools, extensions, project context files, external skills, MCP discovery, prompt templates and cache warming are disabled. The existing Tabby skill and task context are supplied by the host. Terminal tools run serially, with the same read-only rules, approvals, terminal ownership, sudo handling and workflow checkpoints as other connections. A command being sent is not evidence that it completed.
14
+
15
+ ## Context and history
16
+
17
+ `/compact` manually summarizes an idle API or Pi conversation. It consumes model quota. For the built-in API runtime, the original messages remain intact; an independently checked summary projection cuts only at a user-turn boundary so a complete tool batch stays together. Source ranges, a source hash, retained index and summary token usage are saved. Codex and Claude Code continue managing their own native context.
18
+
19
+ For Pi, the SDK's JSONL session is the sole native model context. Compaction appends a summary with its retained entry boundary; old entries remain readable. Tabby keeps a UI transcript, goal, action journal and portable handoff rather than replacing Pi's history. Changing runtime, model, provider or protocol creates a portable handoff into a separate session. Original native histories stay on disk. Manual compaction does not acknowledge host-only input: queued corrections and interruption recovery notices remain pending until a subsequent normal prompt imports them into Pi.
20
+
21
+ Automatic compaction is **off by default**. Enable it per connection after trying manual compaction. The API runtime uses a conservative character estimate at 75% of the configured context window (not an exact tokenizer). Pi uses its own threshold/overflow handling. Summaries preserve constraints and pending checkpoints in their instructions; the host's structured workflow checks remain authoritative regardless of summary text.
22
+
23
+ ## Retries, cancellation and budgets
24
+
25
+ Pi owns its session retries, with two retries and a maximum advertised wait of 60 seconds. Provider SDK retries are disabled, preventing nested retry multiplication. The sidebar consumes structured retry delays; no client timer resends the prompt. Replies truncated by the output token limit are reported as incomplete failures, retaining partial text and reported usage; truncation does not silently restart the Goal or report success. Completion waits for `agent_settled` and process completion. A low-level `agent_end` alone is insufficient.
26
+
27
+ All Pi model requests, retry attempts and summary requests share a **100-request safety cap per invocation**. Summary usage is counted, even when compaction needs more than one request. Reported tokens count toward the current goal budget; after exhaustion, another model request or host tool cannot proceed. An already-started response may exceed the remaining budget; these are reported usage limits, not a provider billing guarantee. Retry and request limits reset for a new invocation; goal token usage persists.
28
+
29
+ The sidecar continues active goals itself using the same native session. Tabby does not wrap Pi with the API persistent-goal loop. Existing host tool limits and repeated-tool detection still apply. Stop remains available during model streaming, tool approval, compaction and backoff and terminates the owned process tree. Appended sidebar input is queued for the next host invocation after the current Pi run settles; use Stop first when a correction must interrupt current work.
30
+
31
+ ## Recovery and storage
32
+
33
+ Sessions live under the Tabby configuration directory in `tabby-agent-sessions/pi/<session-id>/`. Host UI indexes and action journals remain in the existing session store. Use the sidebar history list to resume; reported cumulative usage and the last known model input are restored with the UI history. Do not edit a Pi JSONL file or its host index while a session is active. Missing or unreadable native history stops execution rather than silently creating an empty model context.
34
+
35
+ Each Pi tool call has a stable native action ID. Before execution, Tabby durably records the intent; afterward it records the result. A duplicate returns the recorded result. An intent without a known result never executes again automatically. The private stdin/stdout bridge has no HTTP transport retries and never automatically restarts a failed process. Accepted user-input cursors are recorded in Pi history and acknowledged by the host before inference. Following a crash or lost response, the next prompt instructs the agent to read the terminal and verify actual state before continuing. This does not make arbitrary shell operations transactional or safe to replay under a new action ID.
36
+
37
+ ## Validation boundary
38
+
39
+ Local HTTP fixtures exercise the actual SDK, provider streaming, host tools, retries, cancellation, quota errors, goal continuation, persistent restart, repeated compaction and summary budgets without calling a real model. The three-platform CI matrix uses Node 22.19.0. Running those checks locally on Linux does not establish macOS/Windows or desktop Tabby results. A downloaded official Linux Tabby 1.0.238 was also exercised under Xvfb with an isolated configuration: Electron 43.7.0 / host Node 24.21.0 loaded the plugin, the sidecar used Node 22.19.0, and the sidebar completed a local-provider task through the actual `list_tabs` host bridge and goal update. Runtime settings rendered in the actual app. This covers a local desktop fixture, not SSH/PTY mutation, real-provider/subscription access, macOS or Windows end-to-end behavior. Pi remains optional pending those checks.
40
+
41
+ Upstream API reference: [Pi SDK](https://github.com/earendil-works/pi/blob/f9daca3480732d0042b1df3a6e27221f597a620d/packages/coding-agent/docs/sdk.md).
@@ -0,0 +1,3 @@
1
+ # v0.4.0 — Superseded before publication
2
+
3
+ The branch checks passed, but tag CI exposed a macOS Claude Code stdin-close race. This tag remains unchanged and was not published as a GitHub Release or npm version. Use [v0.4.1](0.4.1.md), which contains the provider features, Windows launcher correction and pipe-close fix.
@@ -0,0 +1,21 @@
1
+ # v0.4.1 — Custom OpenAI-compatible providers and continuous agent goals
2
+
3
+ Add named **Custom (OpenAI compatible)** connections for user-supplied gateways and local services. Select **Chat Completions** (default) or **Responses**, enter a Base URL and model ID, and use a direct API key, an environment variable, or explicitly choose no authentication. No-key mode omits Authorization and does not read saved credentials. Model discovery uses `/models`, with manual model entry available when discovery is unsupported.
4
+
5
+ Custom connections share streaming text, continuous function-tool rounds, approvals, stop controls, goal tracking and persistent history. Protocol changes carry portable conversation context and goals into a new session without replaying tools; existing provider fingerprints remain compatible. Generic connections omit vendor-specific Thinking/cache parameters. Changing connection parameters cancels stale model discovery and connection-test results.
6
+
7
+ API and local Claude Code agents now continue active goals after ordinary text responses. Verified completion, a real blocker, an explicit pause, cancellation, token budgets, configured limits or repeated no-progress evidence ends continuation. Legacy 20-round defaults migrate to unlimited; explicitly configured limits remain available. The model picker follows model → reasoning effort for API and Claude Code, including provider defaults and manually entered models/effort values.
8
+
9
+ Add separate **Kimi API**, **Kimi Coding Plan** and **Alibaba Cloud Coding Plan** presets with China mainland/international regions, matching keys and models, native thinking parameters, usage handling and persistent Kimi session cache keys. Requests identify this client honestly. The release also includes the local Claude Code login integration added since v0.3.2, using the official CLI and an authenticated loopback MCP bridge; Claude API access remains separate.
10
+
11
+ Both READMEs, twelve language catalogs, configuration and development guides, provider architecture/roadmap notes, bundled model instructions and generated knowledge are synchronized. The editable SVG and exported PNG show v0.4.1 settings, custom providers, reasoning selection, terminal coordination and schedules, explicitly marked as an illustration. The robot GIF and reduced-motion static fallback are preserved.
12
+
13
+ Claude Code short-lived help/auth commands tolerate stdin EPIPE and pipe errors after close, relying on the actual exit status; other pipe failures still stop the owned process. This fixes the macOS pipe-close race discovered in tag CI. The existing v0.4.0 tag is retained unchanged and is not published to npm.
14
+
15
+ Windows Claude Code batch launchers use the named CommonJS `cross-spawn` export, matching the Codex launcher. A regression test exercises `.cmd`/`.bat` launcher selection, native `.exe` selection and argument/pipe preservation even without TypeScript default-import interop.
16
+
17
+ The CLI-discovery cancellation regression allows a bounded wait for macOS kernel PID reaping while still requiring the query process to be gone.
18
+
19
+ Validation: skill bundle generation/consistency, TypeScript checking, 710 local tests (704 passed, 6 Windows-only skips), production build, Markdown rendering, image preview and `git diff --check`. The npm tarball is inspected before publication and the same archive is attached to this release. Branch and tag CI must pass on Linux, macOS and Windows before publication is considered complete.
20
+
21
+ Limitations: no paid model smoke test was run. Real third-party gateway access, Claude Code subscription inference, coding-plan admission/quota deduction and Tabby desktop/SSH end-to-end behavior remain unverified. Terminal tasks require SSE streaming and function tools. Remote endpoints require HTTPS; HTTP is limited to loopback addresses. Custom headers, query-parameter authentication, non-streaming endpoints and provider-specific custom parameters are unsupported. Custom Chat Completions uses `max_tokens`; Responses uses `max_output_tokens`, stateless storage and encrypted reasoning history options. Partial implementations may reject these fields. Usage remains unknown when the service does not report it. Kimi/Alibaba membership plans are intended for personal interactive coding; choose an appropriate ordinary API for unattended schedules. Tasks run only while Tabby is open.
@@ -0,0 +1,19 @@
1
+ # v0.5.0 — Workflow aliases, Pi runtime and context compaction
2
+
3
+ Explicit workflow recordings now expose their recording, verification and archive status. Ask the assistant to save an alias such as `/pm1` after a completed `/remember` task; `workflow_status` and `workflow_set_alias` verify the intended recording and read back the saved alias. Checkpoint success is distinguished from archival. Rejected recordings show the reason, and failed archive writes can be retried from retained verified steps without replaying terminal commands. Follow-up goals wait for an in-progress archive. Ordinary tasks cannot be saved retroactively; retry buffers are session-local and do not survive restart.
4
+
5
+ ## Runtime and recovery
6
+
7
+ - API connections can select an isolated **Pi SDK** runtime with pinned SDK 1.4.0 and an external **Node 22.19+** process. Host-advertised Tabby tools retain the existing terminal ownership, approvals, read-only rules and workflow checkpoints.
8
+ - `/compact` supports manual API/Pi context compaction with durable history and portable handoffs. Automatic compaction is opt-in. Pending input and interruption recovery notices remain pending until a normal Pi prompt imports them; truncated replies cannot complete a goal.
9
+ - High-frequency terminal output stays in the bounded local buffer and is read explicitly. Backend retry waiting shows elapsed time and a countdown only when supplied by the backend. Stop cancels the turn; recovery checks live results before confirming pending workflow steps. The plugin adds no model retry loop.
10
+
11
+ ## Documentation and artwork
12
+
13
+ Both READMEs, the guide, workflow/runtime/development documentation, bundled skill and all twelve UI catalogs reflect the current behavior. The SVG and PNG overview show example connections, verified recording, a saved alias, scheduled tasks and Pi settings; the title robot GIF and reduced-motion image are preserved. Local roadmap and research documents are excluded from source tracking and package contents.
14
+
15
+ ## Validation and limits
16
+
17
+ Local Linux / Node 22.19.0 validation passed skill bundling/checking, type checks, the full offline test suite (760 tests: 754 passed, 6 Windows-only skips), production builds and whitespace checks. The npm tarball is inspected for runtime entry points, dependencies, bilingual documentation, artwork and bundled skill. Linux/macOS/Windows CI results and the verified tarball checksum are recorded in the GitHub Release.
18
+
19
+ Offline fixtures cover workflow alias follow-up, archive failure/retry, high-frequency output, backend waiting/cancellation and API/Pi context handling. The earlier isolated Linux Tabby fixture exercise is documented in `docs/pi.md`. No paid inference or original-task replay is performed for this release. Real provider/subscription access, SSH/PTY modification workflows and macOS/Windows desktop behavior remain outside this release's verification.
@@ -0,0 +1,11 @@
1
+ # Unreleased: optional Pi runtime and context compaction
2
+
3
+ - Add an optional Pi SDK 1.4.0 backend using an external Node 22.19+ process and isolated resources. Existing Codex, Claude Code and API connections retain their authentication paths.
4
+ - Route host tools through a serial, journaled pipe bridge with approvals, read-only policies, cancellation, workflow verification, duplicate-result reuse and unknown-action recovery.
5
+ - Show structured retry/compaction states and wait for Pi settlement. Account model and summary usage against goal budgets; disable nested provider retries and cache warming.
6
+ - Add `/compact` and opt-in automatic compaction. Built-in API projections preserve raw history and entire tool batches; Pi keeps its native append-only session history.
7
+ - Add runtime/Node/compaction settings, translations, a development interface illustration and bilingual setup documentation.
8
+
9
+ Review fixes preserve unimported steering and recovery notices across manual compaction, report output-limit truncation as incomplete while keeping partial text/usage, and explicitly configure Kimi Coding compatibility for system messages and max_tokens across preset and proxy endpoints.
10
+
11
+ Validation uses local HTTP fixtures and existing regression/build checks; no real model requests are part of routine checks. An isolated Linux Tabby 1.0.238 / Electron 43.7.0 fixture additionally verified sidebar loading, runtime settings and the real host list_tabs bridge with a local simulated provider. Windows/macOS desktop, SSH/PTY mutations and real provider access remain unverified. See [Pi setup and validation boundaries](../pi.md). This note does not indicate an npm or GitHub release.
@@ -0,0 +1,3 @@
1
+ # Unreleased
2
+
3
+ Changes through workflow aliases, Pi runtime and context compaction are included in [v0.5.0](0.5.0.md). No additional unreleased changes are recorded.
@@ -5,12 +5,22 @@
5
5
  ## 录制与使用
6
6
 
7
7
  1. 输入 `/remember 构建前端项目并核对产物`,明确开始一个新任务。
8
- 2. 成功完成后,在提示中输入 `task1` 并点击 **保存别名**;也可以暂不设置,在设置页补充。
8
+ 2. 成功完成后,在提示中输入 `task1` 并点击 **保存别名**;也可以直接告诉助手“设置别名为 pm1”,或暂不设置,在设置页补充。
9
9
  3. 下次直接发送 `/task1`,Codex 或 API 后端执行对应流程。已有流程可在 **设置 → AI Tools → 任务流程与偏好** 编辑别名、任务描述和步骤,或停用、删除。
10
10
  4. `/workflows` 查看当前工作目录的流程,**填入任务** 填入别名,发送后执行。无别名的旧流程会填入 `/remember 任务描述`,供重新录制。
11
11
 
12
12
  别名按工作目录隔离,不区分大小写,可输入开头的 `/`。以英文字母开头,支持字母、数字、下划线和短横线,最多 48 字符;同目录不能重复,不能覆盖 `/model`、`/remember` 等内置命令。不支持在别名后追加参数;需更改步骤或目标时先在设置页编辑。手动编辑的流程不会被后续录制覆盖。
13
13
 
14
+ ## 查询归档状态与保存别名
15
+
16
+ 助手可调用 `tabby_tabs.workflow_status()`,区分 `recording`(录制中)、`executing_alias`(执行已有流程)、`archiving`(写盘中)、`archived`(已归档)、`archive_failed`(写盘失败)、`unavailable`(录制无法归档)、`idle`(无录制记录)和 `disabled`(功能停用)。返回最近显式录制的目标、工作目录、已验收/待验收步骤、归档资格及原因;已归档时还返回流程 ID、别名和启用状态,不返回原始终端输出。
17
+
18
+ 用户要求“设置别名为 pm1”时,助手先核对状态中的目标确实是用户所指流程,再调用 `workflow_set_alias(alias="pm1",workflowId=返回的流程ID)`。成功响应必须包含 `saved=true` 和回读的 `workflow.alias="pm1"`。同目录重名、内置命令名、错误流程 ID、其他会话/目录或未完成录制会被拒绝;只读模式不能修改别名。不会修改另一条旧流程来冒充完成。
19
+
20
+ checkpoint 成功只证明目标绑定或步骤验收成功,不保证录制可归档。包含 stdin、敏感命令、超过 1200 字符的命令、超过 24 步或单步超过 12 条验证命令等情况会标记录制不完整,checkpoint、状态查询与完成提示会给出原因。普通任务不能事后补存,也不要为补存重跑已完成操作;后续新任务可用 `/remember` 开始录制。
21
+
22
+ 临时写盘失败会保留完整的已验收录制,`workflow_set_alias` 可直接重试归档并保存别名(尚无 ID 时省略 `workflowId`),不会重新执行终端命令。新目标发送前等待尚在完成的归档,避免丢失上一任务记录。最近录制状态和失败重试缓冲只在当前进程/会话中保留;新录制、执行另一个别名、停用功能或重启会清除它们。已落盘流程在重启后仍可通过设置页管理。
23
+
14
24
  ## 服务器身份、路径与步骤验收
15
25
 
16
26
  采用“结构化流程 + 内置 skill + 每次调用的隐藏提示 + 工具门禁”。具体服务器和路径保存在本地流程文件,不写进通用 skill;skill 说明如何核实身份、执行和验收,隐藏提示只携带当前调用的流程、顺序和约束。
@@ -54,3 +64,11 @@
54
64
  只保存脱敏后的任务、步骤、目标终端标题、服务器身份与操作路径、步骤依赖、脱敏验收摘要、简短结论和次数;不保存终端原始输出、临时 tab ID、密码或交互式 stdin。存在交互输入、敏感命令、过长或未核对的步骤时不归档;恢复任务的尾段不会拼成完整流程。录制和别名解析本身不调用模型;执行任务使用所选后端。
55
65
 
56
66
  调用流程后仍需重新读取当前终端、核对主机、目录、分支与参数,不能直接重放历史工具调用。流程成功记录不等于每条命令的退出码均已验证。自动化测试使用模拟后端、临时目录和假 sudo,不请求模型、不使用真实 sudo 凭据。
67
+
68
+ ## 限流、中断与恢复
69
+
70
+ 执行中不再自动转发终端回显,模型需用 `read_tab` 主动读取结果。用户发送/继续时的有界终端摘要不能替代同终端的新观察及 `workflow_checkpoint` 验收。
71
+
72
+ 后台返回 429 且 `willRetry=true` 时,面板保持等待,显示后台明确提供的下次重试时间;未提供时如实说明,不把账号额度重置时间当作重试时间。回显继续合并在本地有界缓冲区,不追加模型消息。可点击停止取消回合;这不代表终端命令已停止,模型没有继续也不代表命令仍在执行。
73
+
74
+ 继续当前目标时保留已确认步骤和 `pendingStep`。先重新读取待验收步骤的实际终端,核对服务器、目录、产物及当前 Git 状态;如果命令已经完成,按原验收条件提交 `confirm_step`,再进行后续依赖。不因模型限流或缺少 checkpoint 而重复运行 stash、restore、apply 或整段历史。插件重启或切换会话后,内存中的录制进度可能不存在;应依实际状态重新核对,不自动重建或重放。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tabby-ai-tools",
3
- "version": "0.3.2",
4
- "description": "A persistent AI agent sidebar for Tabby with Codex, OpenAI, DeepSeek, GLM, and Claude support",
3
+ "version": "0.5.0",
4
+ "description": "A persistent AI agent sidebar for Tabby with Codex, Claude Code, OpenAI-compatible providers, DeepSeek, GLM, Kimi, and Alibaba Cloud Coding Plan support",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Hanlen/tabby-ai-tools.git"
@@ -22,7 +22,10 @@
22
22
  "openai",
23
23
  "deepseek",
24
24
  "glm",
25
- "claude"
25
+ "kimi",
26
+ "coding-plan",
27
+ "claude",
28
+ "openai-compatible"
26
29
  ],
27
30
  "main": "dist/index.js",
28
31
  "scripts": {
@@ -30,13 +33,15 @@
30
33
  "skill:check": "node scripts/bundle-tabby-skill.mjs --check",
31
34
  "skill:update": "node scripts/update-tabby-knowledge.mjs",
32
35
  "prebuild": "npm run skill:bundle",
33
- "build": "webpack --mode production",
34
- "typecheck": "tsc --noEmit",
36
+ "build": "webpack --mode production && npm run pi:build",
37
+ "typecheck": "tsc --noEmit && node node_modules/typescript-pi/bin/tsc -p runtime/pi/tsconfig.json --noEmit",
35
38
  "test": "node scripts/run-tests.cjs",
36
39
  "smoke:codex": "node scripts/smoke-codex.cjs",
37
40
  "smoke:context": "node scripts/smoke-context.cjs",
38
41
  "prepack": "npm run build",
39
- "install:tabby": "node scripts/install-local.mjs"
42
+ "install:tabby": "node scripts/install-local.mjs",
43
+ "pi:build": "node node_modules/typescript-pi/bin/tsc -p runtime/pi/tsconfig.json",
44
+ "pretest": "npm run pi:build"
40
45
  },
41
46
  "files": [
42
47
  "dist",
@@ -61,10 +66,13 @@
61
66
  "tabby-terminal": "^1.0.231-nightly.0",
62
67
  "ts-loader": "^9.5.4",
63
68
  "typescript": "^4.9.5",
69
+ "typescript-pi": "npm:typescript@5.9.3",
64
70
  "webpack": "^5.102.1",
65
71
  "webpack-cli": "^5.1.4"
66
72
  },
67
73
  "dependencies": {
74
+ "@earendil-works/pi-ai": "1.4.0",
75
+ "@earendil-works/pi-coding-agent": "1.4.0",
68
76
  "cross-spawn": "^7.0.6"
69
77
  }
70
78
  }