pi-openai-toolkit 0.15.1 → 0.17.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.
- package/README.md +60 -68
- package/README.zh.md +58 -66
- package/docs/configuration.md +9 -3
- package/docs/internals.md +31 -6
- package/package.json +11 -9
- package/src/auto-mode/classifier.ts +161 -165
- package/src/auto-mode/extension.ts +691 -661
- package/src/auto-mode/model-selection-guard.ts +52 -0
- package/src/auto-mode/reviewer.ts +325 -335
- package/src/auto-mode/transcript.ts +135 -133
- package/src/compaction-projection.ts +35 -31
- package/src/context-management/manual-compact.ts +433 -0
- package/src/context-management/tools.ts +11 -2
- package/src/context-management/window-manager.ts +35 -9
- package/src/extension-runtime.ts +64 -30
- package/src/payload-rewrite.ts +34 -64
- package/src/pi-context-hook.ts +117 -116
- package/src/remote-v2-client.ts +108 -33
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-openai-toolkit
|
|
2
2
|
|
|
3
|
-
Add Codex context windows, Responses compaction, hosted tools, and
|
|
3
|
+
Add Codex context windows, Responses compaction, hosted tools, and tool-call review to Pi.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/pi-openai-toolkit)
|
|
6
6
|
[](LICENSE)
|
|
@@ -11,39 +11,37 @@ Add Codex context windows, Responses compaction, hosted tools, and reviewed tool
|
|
|
11
11
|
|
|
12
12
|
| Feature | Use it to |
|
|
13
13
|
| --- | --- |
|
|
14
|
-
| Codex Remote Context |
|
|
15
|
-
| Remote Compaction v2 | Continue
|
|
16
|
-
| Web Search
|
|
17
|
-
| Image generation |
|
|
18
|
-
| Tool-call review |
|
|
14
|
+
| Codex Remote Context | Start new windows with the adapted Codex protocol and retrieve earlier work through `history`. |
|
|
15
|
+
| Remote Compaction v2 | Continue Responses sessions with encrypted server checkpoints. |
|
|
16
|
+
| Web Search | Choose local `pi-web-access`, Responses `web_search`, or experimental CPA `web_run` per model. |
|
|
17
|
+
| Image generation | Generate or edit images with the hosted Responses image tool. |
|
|
18
|
+
| Tool-call review | Have a reviewer model approve selected calls through Toolkit's approval gate. |
|
|
19
19
|
|
|
20
|
-
The package uses Pi's existing
|
|
20
|
+
The package uses Pi's existing models, authentication, and sessions. It does not add a provider or model.
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
24
|
-
Requires Pi 0.
|
|
24
|
+
Requires Pi 0.87.0+ and Node.js 22.19.0+.
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
pi install npm:pi-openai-toolkit
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Without a config file, Remote Compaction v2 is enabled for eligible models, Remote Context windows are off, search is unmanaged, image generation is disabled, and Auto Mode is unavailable. These defaults do not verify backend support.
|
|
33
|
-
|
|
34
|
-
The only Toolkit config file is:
|
|
30
|
+
Add `--local` for a project-local installation. Toolkit configuration is global in either case:
|
|
35
31
|
|
|
36
32
|
`~/.pi/agent/extensions/pi-openai-toolkit/config.json`
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
Create the file and parent directory if needed. Merge the Toolkit examples below into an existing **schema v2** config; do not replace unrelated settings. For an unversioned legacy config, run `/toolkit-config migration-preview` first. See the [migration guide](docs/configuration.md#legacy-compatibility-and-migration).
|
|
35
|
+
|
|
36
|
+
By default, eligible models use Remote Compaction v2. Remote Context windows, image generation, and Auto Mode are off; search is unmanaged. Backend support is still required.
|
|
39
37
|
|
|
40
38
|
## Quick start: enable Remote Context
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
For search, images, or tool-call review only, skip to [Common tasks](#common-tasks).
|
|
43
41
|
|
|
44
42
|
### Use Pi's built-in Codex provider
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
Sign in to Pi's `openai-codex` provider, then add this Toolkit config:
|
|
47
45
|
|
|
48
46
|
```json
|
|
49
47
|
{
|
|
@@ -54,19 +52,24 @@ You must already be signed in to Pi's built-in `openai-codex` provider. Create o
|
|
|
54
52
|
}
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
Start Pi with a model from your
|
|
55
|
+
Start Pi with a model ID from your Codex catalog:
|
|
58
56
|
|
|
59
57
|
```bash
|
|
60
58
|
pi --model openai-codex/<model-id>
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
Look for `new_context`, `get_context_remaining`, `history`, and `notes`. Their presence confirms activation, not backend compatibility. Earlier windows stay accessible through `history` without being loaded into every request.
|
|
64
62
|
|
|
65
63
|
### Use a compatible gateway
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
The gateway must support `openai-responses` and the Codex Remote Context protocol. Ordinary chat support is not enough.
|
|
66
|
+
|
|
67
|
+
If your model is already registered in `~/.pi/agent/models.json`, skip the registration example.
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>Register a gateway model in Pi</summary>
|
|
71
|
+
|
|
72
|
+
Merge this into Pi's models file. Replace the provider name, URL, key variable, model ID, and limits with your setup; the numbers are examples.
|
|
70
73
|
|
|
71
74
|
```json
|
|
72
75
|
{
|
|
@@ -88,19 +91,23 @@ If `~/.pi/agent/models.json` already registers a compatible model, skip registra
|
|
|
88
91
|
}
|
|
89
92
|
```
|
|
90
93
|
|
|
91
|
-
Set the
|
|
94
|
+
Set the key in PowerShell:
|
|
92
95
|
|
|
93
96
|
```powershell
|
|
94
97
|
$env:MY_GATEWAY_KEY = "replace-with-your-gateway-key"
|
|
95
98
|
```
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
Or in a POSIX shell:
|
|
98
101
|
|
|
99
102
|
```bash
|
|
100
103
|
export MY_GATEWAY_KEY="replace-with-your-gateway-key"
|
|
101
104
|
```
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
Start Pi from the same terminal.
|
|
107
|
+
|
|
108
|
+
</details>
|
|
109
|
+
|
|
110
|
+
Add the exact registered `provider/model-id` to Toolkit's config:
|
|
104
111
|
|
|
105
112
|
```json
|
|
106
113
|
{
|
|
@@ -118,23 +125,23 @@ Use the same terminal to start Pi. In the Toolkit config, make the key exactly m
|
|
|
118
125
|
pi --model my-gateway/gpt-5.6-luna
|
|
119
126
|
```
|
|
120
127
|
|
|
121
|
-
Check for
|
|
122
|
-
|
|
123
|
-
Earlier windows remain retrievable through `history`, but are not all automatically inserted into the current context.
|
|
128
|
+
Check for the same context tools listed above. If they are missing, use `/toolkit-config` and check the notification, model key, API, credentials, and URL.
|
|
124
129
|
|
|
125
130
|
## Common tasks
|
|
126
131
|
|
|
127
|
-
###
|
|
132
|
+
### Save work and switch windows with `/compact`
|
|
128
133
|
|
|
129
|
-
|
|
134
|
+
In an active Remote Context session, run `/compact` to save work to notes and enter a new window without a conversation summary. You can append instructions to the command.
|
|
130
135
|
|
|
131
|
-
`context.remoteCompaction.
|
|
136
|
+
To use a separate checkpoint model, set `context.remoteCompaction.model` under `defaults` or an exact model override. It must support Remote Context on the same backend/account; leaving it unset uses the current model. Toolkit restores your original model and thinking level before continuing. See [context settings and requirements](docs/configuration.md#context).
|
|
132
137
|
|
|
133
|
-
|
|
138
|
+
### Use server-side compaction
|
|
139
|
+
|
|
140
|
+
Set `context.mode` to `"remote-compaction"` (the default) for encrypted Responses checkpoints, or `"pi"` to leave context management to Pi. Advanced input and fallback options are in the [configuration reference](docs/configuration.md#context).
|
|
134
141
|
|
|
135
142
|
### Choose a Web Search route
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
Set a default route and override it for individual models:
|
|
138
145
|
|
|
139
146
|
```json
|
|
140
147
|
{
|
|
@@ -150,16 +157,18 @@ Configure a global default and exact model overrides:
|
|
|
150
157
|
}
|
|
151
158
|
```
|
|
152
159
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
| Route | Behavior |
|
|
161
|
+
| --- | --- |
|
|
162
|
+
| `unmanaged` | Leave search to Pi and other extensions. |
|
|
163
|
+
| `local` | Keep the existing local `pi-web-access` tools. |
|
|
164
|
+
| `hosted` | Use Responses `web_search` with source annotations. |
|
|
165
|
+
| `standalone-alpha` | Use experimental `web_run` on a CPA/Codex gateway that supports `/alpha/search`. |
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
Toolkit does not fall back between routes. See [search configuration](docs/configuration.md#web-search) for backend requirements.
|
|
159
168
|
|
|
160
169
|
### Generate an image
|
|
161
170
|
|
|
162
|
-
|
|
171
|
+
Requires a Responses session and may incur provider charges. Enable it with an image model your provider supports:
|
|
163
172
|
|
|
164
173
|
```json
|
|
165
174
|
{
|
|
@@ -168,19 +177,17 @@ Image generation requires a Responses session and may incur provider charges. En
|
|
|
168
177
|
"imageGeneration": {
|
|
169
178
|
"enabled": true,
|
|
170
179
|
"defaultModel": "gpt-image-2.5",
|
|
171
|
-
"allowedModels": ["gpt-image-2.5"
|
|
180
|
+
"allowedModels": ["gpt-image-2.5"]
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
183
|
}
|
|
175
184
|
```
|
|
176
185
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
`openai_generate_image` accepts text-to-image requests and edits using explicitly supplied local references. Image policy cannot be overridden per session model.
|
|
186
|
+
Ask Pi to generate an image or edit explicitly supplied local references using `openai_generate_image`. The default model must be in `allowedModels`; image settings are global. See [image configuration](docs/configuration.md#images).
|
|
180
187
|
|
|
181
188
|
### Review tool calls automatically
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
Enable Auto Mode for a model and choose its reviewer:
|
|
184
191
|
|
|
185
192
|
```json
|
|
186
193
|
{
|
|
@@ -196,38 +203,23 @@ Make Auto Mode available to an exact model and choose its reviewer:
|
|
|
196
203
|
}
|
|
197
204
|
```
|
|
198
205
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
The TUI shows activation, review activity, and a footer status. Compatible Pi tool renderers also show per-call allowed, denied, blocked, or unreviewed states. If that renderer seam is unavailable, Toolkit warns once and retains the footer display. Reviewer, classifier, and circuit-breaker controls are in the [configuration reference](docs/configuration.md).
|
|
206
|
+
Turn it on with `/auto on` or `--auto`, and off with `/auto off`. By default it reviews `bash`, `write`, `edit`, and configured extra tools; `gate: "all"` reviews every call. A reviewer timeout never approves a call. See [Auto Mode settings](docs/configuration.md#auto-mode).
|
|
202
207
|
|
|
203
208
|
## Common configuration
|
|
204
209
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
| --- | --- |
|
|
209
|
-
| `
|
|
210
|
-
|
|
|
211
|
-
| `
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
| `defaults.webSearch.route` | `"unmanaged"` | Toolkit search ownership policy. |
|
|
215
|
-
| `defaults.imageGeneration.enabled` | `false` | Global image-generation switch. |
|
|
216
|
-
| `defaults.imageGeneration.defaultModel` | `"gpt-image-2.5"` | Explicit default output model. |
|
|
217
|
-
| `defaults.imageGeneration.allowedModels` | `["gpt-image-2.5"]` | Allowed output models, global only. |
|
|
218
|
-
| `defaults.autoMode.available` | `false` | Permission to engage tool review. |
|
|
219
|
-
| `defaults.autoMode.gate` | `"side-effect"` | Selected side-effect tools or `"all"`. |
|
|
220
|
-
| `defaults.autoMode.timeoutMs` | `30000` | Reviewer timeout in milliseconds. |
|
|
221
|
-
| `diagnostics.level` | `"info"` | `"debug"` enables debug artifacts. |
|
|
222
|
-
| `diagnostics.captureRequests` / `captureResponses` | `false` | Independent request/compact-response capture opt-ins. |
|
|
223
|
-
|
|
224
|
-
Use `/toolkit-config` for effective values and origins, `/toolkit-config validate` for document issues, and `/toolkit-config migration-preview` for a read-only legacy candidate. These commands require a UI and perform no network/auth lookup, tool activation, or file writes. Configuration selection does not verify backend support.
|
|
225
|
-
|
|
226
|
-
Unknown v2 policy keys and malformed values produce visible scoped errors, independent of debug mode. Each public callback or tool execution uses one immutable snapshot across its awaited helpers; later operations reread the file. Separate Pi events are not one atomic transaction. See the [complete configuration reference](docs/configuration.md) and [editor schema](config.schema.json).
|
|
210
|
+
Use `defaults` for shared settings and `models["provider/model-id"]` for exact model overrides. Toolkit reads only the global config file.
|
|
211
|
+
|
|
212
|
+
| Command | Purpose |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `/toolkit-config` | Show effective settings and their origins. |
|
|
215
|
+
| `/toolkit-config validate` | Check for configuration errors. |
|
|
216
|
+
| `/toolkit-config migration-preview` | Preview a legacy-to-v2 migration without writing files. |
|
|
217
|
+
|
|
218
|
+
These commands require Pi's interactive UI. See the [full configuration reference](docs/configuration.md), [editor schema](config.schema.json), and [implementation details](docs/internals.md).
|
|
227
219
|
|
|
228
220
|
## Development
|
|
229
221
|
|
|
230
|
-
|
|
222
|
+
After installing dependencies in the repository root:
|
|
231
223
|
|
|
232
224
|
```bash
|
|
233
225
|
npm run typecheck
|
package/README.zh.md
CHANGED
|
@@ -11,39 +11,37 @@
|
|
|
11
11
|
|
|
12
12
|
| 功能 | 用途 |
|
|
13
13
|
| --- | --- |
|
|
14
|
-
| Codex 远程上下文 |
|
|
15
|
-
| 远程压缩 v2 |
|
|
16
|
-
|
|
|
17
|
-
| 图像生成 |
|
|
18
|
-
| 工具调用审查 |
|
|
14
|
+
| Codex 远程上下文 | 通过适配的 Codex 协议切换窗口,用 `history` 找回较早的工作内容。 |
|
|
15
|
+
| 远程压缩 v2 | 使用加密的服务端检查点继续 Responses 会话。 |
|
|
16
|
+
| 联网搜索 | 按模型选择本地 `pi-web-access`、Responses `web_search` 或实验性的 CPA `web_run`。 |
|
|
17
|
+
| 图像生成 | 使用 Responses 托管生图工具生成或编辑图片。 |
|
|
18
|
+
| 工具调用审查 | 通过 Toolkit 审批门禁,让审查模型判断指定调用是否可以执行。 |
|
|
19
19
|
|
|
20
|
-
本包沿用 Pi
|
|
20
|
+
本包沿用 Pi 已有的模型、认证和会话,不新增提供商或模型。
|
|
21
21
|
|
|
22
22
|
## 安装
|
|
23
23
|
|
|
24
|
-
需要 Pi 0.
|
|
24
|
+
需要 Pi 0.87.0+ 和 Node.js 22.19.0+。
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
pi install npm:pi-openai-toolkit
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
没有配置文件时,符合条件的模型启用远程压缩 v2,远程上下文窗口关闭,搜索不由 Toolkit 管理,图像生成关闭,自动模式不可用。这些默认值不表示后端能力已经验证。
|
|
33
|
-
|
|
34
|
-
Toolkit 唯一的配置文件是:
|
|
30
|
+
加上 `--local` 可安装到当前项目。无论安装位置如何,Toolkit 都使用全局配置:
|
|
35
31
|
|
|
36
32
|
`~/.pi/agent/extensions/pi-openai-toolkit/config.json`
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
文件不存在时,创建文件及所需目录。将下方 Toolkit 示例合并到已有的**配置格式 v2** 文件,不要覆盖其他设置。无版本号的旧配置请先运行 `/toolkit-config migration-preview`,详见[迁移指南](docs/configuration.md#legacy-compatibility-and-migration)。
|
|
35
|
+
|
|
36
|
+
默认情况下,符合条件的模型启用远程压缩 v2;远程上下文窗口、生图和自动模式关闭,搜索不由 Toolkit 管理。使用相关功能仍需后端支持。
|
|
39
37
|
|
|
40
38
|
## 快速开始:启用远程上下文
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
如果只需要搜索、生图或工具调用审查,可跳到[常见用法](#常见用法)。
|
|
43
41
|
|
|
44
42
|
### 使用 Pi 内置的 Codex 提供商
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
先登录 Pi 的 `openai-codex` 提供商,再添加以下 Toolkit 配置:
|
|
47
45
|
|
|
48
46
|
```json
|
|
49
47
|
{
|
|
@@ -54,19 +52,24 @@ Toolkit 唯一的配置文件是:
|
|
|
54
52
|
}
|
|
55
53
|
```
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
使用 Codex 模型目录中的实际模型 ID 启动 Pi:
|
|
58
56
|
|
|
59
57
|
```bash
|
|
60
58
|
pi --model openai-codex/<model-id>
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
检查是否出现 `new_context`、`get_context_remaining`、`history` 和 `notes`。工具出现表示已激活,不代表后端兼容性已经验证。较早窗口可通过 `history` 检索,不会加载到每次请求中。
|
|
64
62
|
|
|
65
63
|
### 使用兼容网关
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
网关必须支持 `openai-responses` 和 Codex 远程上下文协议,仅支持普通对话还不够。
|
|
66
|
+
|
|
67
|
+
如果模型已在 `~/.pi/agent/models.json` 注册,可跳过注册示例。
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
<details>
|
|
70
|
+
<summary>在 Pi 中注册网关模型</summary>
|
|
71
|
+
|
|
72
|
+
将以下内容合并到 Pi 的模型文件。按实际情况替换提供商名称、URL、密钥变量、模型 ID 和限制值;其中的数字仅为示例。
|
|
70
73
|
|
|
71
74
|
```json
|
|
72
75
|
{
|
|
@@ -88,19 +91,23 @@ pi --model openai-codex/<model-id>
|
|
|
88
91
|
}
|
|
89
92
|
```
|
|
90
93
|
|
|
91
|
-
|
|
94
|
+
PowerShell 中设置密钥:
|
|
92
95
|
|
|
93
96
|
```powershell
|
|
94
97
|
$env:MY_GATEWAY_KEY = "replace-with-your-gateway-key"
|
|
95
98
|
```
|
|
96
99
|
|
|
97
|
-
POSIX shell
|
|
100
|
+
或使用 POSIX shell:
|
|
98
101
|
|
|
99
102
|
```bash
|
|
100
103
|
export MY_GATEWAY_KEY="replace-with-your-gateway-key"
|
|
101
104
|
```
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
在同一个终端中启动 Pi。
|
|
107
|
+
|
|
108
|
+
</details>
|
|
109
|
+
|
|
110
|
+
在 Toolkit 配置中填写已注册的精确 `提供商/模型 ID`:
|
|
104
111
|
|
|
105
112
|
```json
|
|
106
113
|
{
|
|
@@ -118,23 +125,23 @@ export MY_GATEWAY_KEY="replace-with-your-gateway-key"
|
|
|
118
125
|
pi --model my-gateway/gpt-5.6-luna
|
|
119
126
|
```
|
|
120
127
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
较早窗口仍可通过 `history` 检索,但不会全部自动加入当前上下文。
|
|
128
|
+
检查是否出现上面列出的上下文工具。如果没有,使用 `/toolkit-config`,并检查通知、模型键、API、认证和 URL。
|
|
124
129
|
|
|
125
130
|
## 常见用法
|
|
126
131
|
|
|
127
|
-
###
|
|
132
|
+
### 用 `/compact` 保存工作并切换窗口
|
|
128
133
|
|
|
129
|
-
|
|
134
|
+
远程上下文已激活时,运行 `/compact` 可将工作状态保存到 notes,再进入新窗口,不生成会话摘要。命令后可以附加要求。
|
|
130
135
|
|
|
131
|
-
`context.remoteCompaction.
|
|
136
|
+
如需独立的检查点模型,在 `defaults` 或精确模型覆盖下设置 `context.remoteCompaction.model`。目标模型须在同一后端及账号下支持远程上下文;不设置则使用当前模型。Toolkit 会在继续工作前恢复原模型和思考等级。详见[上下文配置与要求](docs/configuration.md#context)。
|
|
132
137
|
|
|
133
|
-
|
|
138
|
+
### 使用服务端压缩
|
|
139
|
+
|
|
140
|
+
将 `context.mode` 设为 `"remote-compaction"`(默认值),使用加密的 Responses 检查点;设为 `"pi"` 则由 Pi 管理上下文。高级输入和回退选项见[配置参考](docs/configuration.md#context)。
|
|
134
141
|
|
|
135
142
|
### 选择联网搜索路由
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
设置默认路由,并按模型覆盖:
|
|
138
145
|
|
|
139
146
|
```json
|
|
140
147
|
{
|
|
@@ -150,16 +157,18 @@ pi --model my-gateway/gpt-5.6-luna
|
|
|
150
157
|
}
|
|
151
158
|
```
|
|
152
159
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
| 路由 | 行为 |
|
|
161
|
+
| --- | --- |
|
|
162
|
+
| `unmanaged` | 由 Pi 和其他扩展管理搜索。 |
|
|
163
|
+
| `local` | 保留现有本地 `pi-web-access` 工具。 |
|
|
164
|
+
| `hosted` | 使用带来源标注的 Responses `web_search`。 |
|
|
165
|
+
| `standalone-alpha` | 在支持 `/alpha/search` 的 CPA/Codex 网关上使用实验性的 `web_run`。 |
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
Toolkit 不会在路由之间自动回退。后端要求见[搜索配置](docs/configuration.md#web-search)。
|
|
159
168
|
|
|
160
169
|
### 生成图片
|
|
161
170
|
|
|
162
|
-
|
|
171
|
+
需要 Responses 会话,并可能产生服务商费用。选择服务商支持的生图模型后启用:
|
|
163
172
|
|
|
164
173
|
```json
|
|
165
174
|
{
|
|
@@ -168,19 +177,17 @@ pi --model my-gateway/gpt-5.6-luna
|
|
|
168
177
|
"imageGeneration": {
|
|
169
178
|
"enabled": true,
|
|
170
179
|
"defaultModel": "gpt-image-2.5",
|
|
171
|
-
"allowedModels": ["gpt-image-2.5"
|
|
180
|
+
"allowedModels": ["gpt-image-2.5"]
|
|
172
181
|
}
|
|
173
182
|
}
|
|
174
183
|
}
|
|
175
184
|
```
|
|
176
185
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
`openai_generate_image` 支持文生图和使用明确传入的本地参考图进行编辑。生图策略不能按当前会话模型覆盖。
|
|
186
|
+
让 Pi 通过 `openai_generate_image` 生成图片,或编辑明确提供的本地参考图。默认模型必须在 `allowedModels` 中;生图设置全局生效。详见[生图配置](docs/configuration.md#images)。
|
|
180
187
|
|
|
181
188
|
### 启用工具调用自动审查
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
为模型开放自动模式,并选择审查模型:
|
|
184
191
|
|
|
185
192
|
```json
|
|
186
193
|
{
|
|
@@ -196,34 +203,19 @@ pi --model my-gateway/gpt-5.6-luna
|
|
|
196
203
|
}
|
|
197
204
|
```
|
|
198
205
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
TUI 会显示开启提示、审查活动和底部状态。兼容的 Pi 工具渲染器还会显示每次调用的允许、拒绝、阻止或未审查状态。如果渲染接口不可用,Toolkit 告警一次并保留底部显示。审查器、分类器和熔断器的高级配置见[配置参考](docs/configuration.md)。
|
|
206
|
+
使用 `/auto on` 或 `--auto` 开启,`/auto off` 关闭。默认审查 `bash`、`write`、`edit` 和额外配置的工具;`gate: "all"` 审查所有调用。审查超时不会自动放行。详见[自动模式配置](docs/configuration.md#auto-mode)。
|
|
202
207
|
|
|
203
208
|
## 常用配置
|
|
204
209
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
| --- | --- |
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
| `
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
| `defaults.webSearch.route` | `"unmanaged"` | Toolkit 搜索管理策略。 |
|
|
215
|
-
| `defaults.imageGeneration.enabled` | `false` | 全局生图开关。 |
|
|
216
|
-
| `defaults.imageGeneration.defaultModel` | `"gpt-image-2.5"` | 明确指定默认输出模型。 |
|
|
217
|
-
| `defaults.imageGeneration.allowedModels` | `["gpt-image-2.5"]` | 允许的输出模型,仅支持全局设置。 |
|
|
218
|
-
| `defaults.autoMode.available` | `false` | 是否允许开启工具审查。 |
|
|
219
|
-
| `defaults.autoMode.gate` | `"side-effect"` | 指定副作用工具,或 `"all"`。 |
|
|
220
|
-
| `defaults.autoMode.timeoutMs` | `30000` | 审查超时,单位为毫秒。 |
|
|
221
|
-
| `diagnostics.level` | `"info"` | `"debug"` 开启调试产物。 |
|
|
222
|
-
| `diagnostics.captureRequests` / `captureResponses` | `false` | 分别开启请求或压缩响应捕获。 |
|
|
223
|
-
|
|
224
|
-
使用 `/toolkit-config` 查看有效值及来源,`/toolkit-config validate` 查看文档问题,`/toolkit-config migration-preview` 预览只读的旧格式迁移候选。这些命令需要 UI,不查询网络或认证,不激活工具,也不写文件。选中配置不表示后端支持已验证。
|
|
225
|
-
|
|
226
|
-
未知 v2 策略键和畸形值会产生可见的分范围错误,不依赖调试模式。每个公开回调或工具执行及其等待的辅助操作使用同一份不可变快照,后续操作重新读取文件;独立 Pi 事件之间不保证原子事务。完整选项见[配置参考](docs/configuration.md)和[编辑器 schema](config.schema.json)。
|
|
210
|
+
`defaults` 设置通用值,`models["provider/model-id"]` 按精确模型覆盖。Toolkit 只读取全局配置文件。
|
|
211
|
+
|
|
212
|
+
| 命令 | 用途 |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| `/toolkit-config` | 查看生效设置及其来源。 |
|
|
215
|
+
| `/toolkit-config validate` | 检查配置错误。 |
|
|
216
|
+
| `/toolkit-config migration-preview` | 预览旧格式到 v2 的迁移,不写入文件。 |
|
|
217
|
+
|
|
218
|
+
这些命令需要 Pi 交互界面。完整说明见[配置参考](docs/configuration.md)、[编辑器 schema](config.schema.json)和[实现细节](docs/internals.md)。
|
|
227
219
|
|
|
228
220
|
## 开发
|
|
229
221
|
|
package/docs/configuration.md
CHANGED
|
@@ -57,7 +57,7 @@ Place `context` under `defaults` or an exact `models` entry.
|
|
|
57
57
|
| Relative field | Default | Contract |
|
|
58
58
|
| --- | --- | --- |
|
|
59
59
|
| `mode` | `"remote-compaction"` | `"pi"` relinquishes Toolkit context management; `"remote-compaction"` uses the eligible Responses checkpoint path; `"remote-windows"` selects Codex windows where supported. |
|
|
60
|
-
| `remoteCompaction.model` | `null` | Exact producer reference; `null` uses the active model.
|
|
60
|
+
| `remoteCompaction.model` | `null` | Exact producer reference; `null` uses the active model. In `remote-compaction`, it selects the synthetic checkpoint producer on the same effective base URL. In active `remote-windows`, manual `/compact` temporarily selects it for notes checkpoint duty on the same backend/account. |
|
|
61
61
|
| `remoteCompaction.inputSource` | `"legacy"` | `"legacy"` preserves session/raw-branch input; `"pi-context-hook"` opts into Pi's ordered context projection. Checkpoint provenance must match. |
|
|
62
62
|
| `remoteCompaction.allowContinuityBreak` | `false` | Allow restarting from Pi context after a foreign compaction entry. It does not make malformed opaque checkpoints replayable. |
|
|
63
63
|
| `remoteCompaction.apis` | `["openai-responses", "openai-codex-responses"]` | May narrow this set; `[]` permits no remote-compaction API. Unsupported entries are errors. |
|
|
@@ -67,7 +67,13 @@ Place `context` under `defaults` or an exact `models` entry.
|
|
|
67
67
|
| `remoteWindows.leaveManagedMode` | `"warn"` | `"compact"` also requests a close-out when retired history exceeds 80% of the next model's window and compaction can finish. Print mode remains warning-only; turn-end close-out requires a queued trim. |
|
|
68
68
|
| `remoteWindows.reminderThresholdPercent` | `5` | Integer 0-100. `0` disables both the once-per-window reminder and exhausted-window fallback. |
|
|
69
69
|
|
|
70
|
-
Native Codex eligibility derives from the actual Pi provider/API. Gateways additionally need the exact transport opt-in below. `remote-windows` retains the compaction chain for models outside window capability. A configured window model whose activation fails does not silently receive a summary fallback.
|
|
70
|
+
Native Codex eligibility derives from the actual Pi provider/API. Gateways additionally need the exact transport opt-in below. `remote-windows` retains the compaction chain for models outside window capability. A configured window model whose activation fails does not silently receive a summary fallback. Normal `new_context` keeps its persisted-notes, duplicate and cooldown gates. Synthetic Remote V2 producer/consumer identity and checkpoint provenance are unchanged. See [Toolkit internals](internals.md).
|
|
71
|
+
|
|
72
|
+
In active `remote-windows`, `/compact [instructions]` starts checkpoint duty rather than producing a summary. The selected model must authenticate to the same native backend/account or gateway credential/affinity domain, fit the projected window plus its output reserve, and retain the required permitted context tools. Invalid or unsuitable explicit targets are refused without switching to a fallback model. If Auto Mode is engaged, the target must also be eligible for its gate. The entire handoff uses the initiating context-policy snapshot; no config or global Pi defaults are rewritten.
|
|
73
|
+
|
|
74
|
+
Only a new persisted successful notes write/append after the handoff and the latest delivered user message authorizes its rollover. After the exact target marker is durable, Toolkit restores the original model/thinking before new-window inference and asks it to read the receipt first. Failure or cancellation restores an owned selection; a later user selection takes priority. Failed restoration blocks further handoff requests until selection/auth is repaired. Reload can recover selection, but does not automatically restart inference.
|
|
75
|
+
|
|
76
|
+
The SDK native compact call reports its intentional cancellation; the visible handoff is a separate agent operation. Pi's pre-hook “nothing to compact” and “already compacted” outcomes remain. Automatic threshold/overflow compaction and internal pending-trim maintenance do not initiate checkpoint duty. `nativeFallback.model` keeps its existing summary-model meaning.
|
|
71
77
|
|
|
72
78
|
---
|
|
73
79
|
|
|
@@ -124,7 +130,7 @@ Place `autoMode` under `defaults` or an exact model. `available` permits engagem
|
|
|
124
130
|
| `circuitBreaker.recentDenials` | `10` | Integer 0-100; `0` disables this limit. |
|
|
125
131
|
| `circuitBreaker.windowSize` | `50` | Integer 1-200, recent-verdict window size. |
|
|
126
132
|
|
|
127
|
-
Reviewer and classifier references are not active-session overrides. Classifier scores, denial history, and human decisions never become config entries.
|
|
133
|
+
Reviewer and classifier references are not active-session overrides. Classifier scores, denial history, and human decisions never become config entries. The reviewer and its read-only evidence calls share one cancellable deadline, including dependencies that ignore abort. Denial history resets on actual delivery of a user message, including identical queued messages, not on enqueue or an ordinary tool continuation. Pre-scores are bound to a full structured authorization fingerprint; the bounded review transcript prioritizes recent user instructions and reports omissions.
|
|
128
134
|
|
|
129
135
|
---
|
|
130
136
|
|