@tt-a1i/openpi 0.6.0 → 0.6.1
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 +13 -11
- package/SETUP.md +2 -2
- package/extensions/ai-providers/README.md +12 -6
- package/extensions/ai-providers/cursor/input-images.ts +2 -3
- package/extensions/ai-providers/cursor/proto.ts +218 -11
- package/extensions/ai-providers/cursor/protobuf.ts +12 -2
- package/extensions/ai-providers/cursor/provider.ts +276 -20
- package/extensions/ai-providers/cursor/tool-bridge.ts +68 -0
- package/extensions/ai-providers/index.ts +3 -3
- package/extensions/shared/child-session.ts +14 -0
- package/extensions/subagents/index.ts +20 -3
- package/extensions/subagents/src/agent-types.ts +5 -17
- package/extensions/subagents/src/backends/pi.ts +70 -59
- package/extensions/subagents/src/backends/tool-preview.ts +29 -0
- package/extensions/subagents/src/manager.ts +2 -71
- package/extensions/subagents/src/prompt.ts +2 -2
- package/extensions/subagents/src/runtime.ts +10 -3
- package/extensions/workflows/dashboard.ts +139 -21
- package/extensions/workflows/index.ts +62 -20
- package/extensions/workflows/progress-projection.ts +7 -1
- package/extensions/workflows/runner.ts +5 -162
- package/extensions/workflows/sandbox.ts +4 -0
- package/package.json +1 -1
- package/skills/subagents/REFERENCE.md +6 -7
- package/skills/subagents/SKILL.md +1 -1
- package/skills/workflows/REFERENCE.md +3 -1
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ OpenPI 把成熟 Coding Agent 的工作习惯做成 Pi-native 能力,但不复
|
|
|
130
130
|
| 快捷工作流 | `/btw` 旁路提问(TUI)、`/lg` 浏览 Diff(TUI)、`/pr` 查 PR、`/copy-all`、`fd`、`rg`、只读 Git 工具 |
|
|
131
131
|
| 人类决策 | `ask_user` 草稿与最终复核、parent-only `human_handoff`、Plan Ready 实施门禁 |
|
|
132
132
|
| 统一配置 | `/openpi-setup` 管理 OpenPI 自有模型、并发、Footer、输出密度与 Post-edit 偏好 |
|
|
133
|
-
| 模型授权 | `/login google-antigravity`;实验性的 `/login cursor
|
|
133
|
+
| 模型授权 | `/login google-antigravity`;实验性的 `/login cursor`(支持 Pi 工具,不执行 Cursor 原生工具) |
|
|
134
134
|
|
|
135
135
|
OpenPI 采用 [MIT License](LICENSE);第三方来源与保留声明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
|
|
136
136
|
|
|
@@ -196,23 +196,23 @@ subagent_spawn({
|
|
|
196
196
|
每个 Subagent 都是新的进程内 Pi SDK Session:
|
|
197
197
|
|
|
198
198
|
- 默认继承父会话的 Provider 与模型;用户可明确指定 Thinking Level,否则模型根据角色建议、任务难度与目标模型实际支持的档位选择;
|
|
199
|
-
-
|
|
199
|
+
- 继承父会话当前启用且允许委派的工具、Skills 和项目说明;目标目录的项目扩展按其自身 Trust 决策加载;
|
|
200
200
|
- 最多 4 个模型发起的 Subagent 并发运行,结束后自动回传;
|
|
201
201
|
- 可 `check`、`wait`、`cancel`,也可用 `subagent_send` 继续同一子会话;
|
|
202
202
|
- 输入框下方显示实时摘要,空输入时按 `↓` 聚焦,`Enter` 或 `→` 打开管理界面。
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
内置角色提供任务分工建议,普通模式下继承父会话当前启用且允许委派的工具,包括 Bash 和已启用的联网工具。角色名称本身不是只读权限边界;Plan Mode 与自定义角色的显式工具限制仍由 Harness 执行。
|
|
205
205
|
|
|
206
|
-
| `agent_type` | 适合 | 相对 effort 建议
|
|
207
|
-
| ------------- | ---------------- |
|
|
208
|
-
| `explorer` | 代码追踪与探索 | 中等,难题可提高
|
|
209
|
-
| `implementer` | 聚焦实现 | 中高,按范围与风险调整 |
|
|
210
|
-
| `reviewer` | 正确性与回归审查 | 较高
|
|
211
|
-
| `advisor` | 深度技术建议 | 较高
|
|
206
|
+
| `agent_type` | 适合 | 相对 effort 建议 |
|
|
207
|
+
| ------------- | ---------------- | ---------------- |
|
|
208
|
+
| `explorer` | 代码追踪与探索 | 中等,难题可提高 |
|
|
209
|
+
| `implementer` | 聚焦实现 | 中高,按范围与风险调整 |
|
|
210
|
+
| `reviewer` | 正确性与回归审查 | 较高 |
|
|
211
|
+
| `advisor` | 深度技术建议 | 较高 |
|
|
212
212
|
|
|
213
213
|
上述只是模型的相对选择提示,不会为内置角色写死具体档位。用户明确指定的 `reasoning_effort` 始终优先;否则模型结合任务难度,从目标模型实际支持的档位中选择。
|
|
214
214
|
|
|
215
|
-
角色可由全局 `~/.pi/agent/agents/*.md` 或受信任项目 `.pi/agents/*.md` 覆盖。模型优先级是:显式调用 > Agent Type 文件 > `/openpi-setup` 角色模型 > 父模型继承。更高优先级定义损坏时会阻断 fallback
|
|
215
|
+
角色可由全局 `~/.pi/agent/agents/*.md` 或受信任项目 `.pi/agents/*.md` 覆盖。模型优先级是:显式调用 > Agent Type 文件 > `/openpi-setup` 角色模型 > 父模型继承。更高优先级定义损坏时会阻断 fallback,而不是悄悄退回更宽松的能力。自定义角色省略 `tools` 时继承当前父工具;显式列表只能收窄,未在父会话启用的工具不会由委派自动激活。已有角色文件不会被升级覆盖;旧版 `explorer.md` 的只读列表仍然有效。工具可用性不等于文件系统沙箱;普通模式可使用绝对路径访问其他目录,目标仓库的执行 cwd 应通过 `working_dir` 指定。
|
|
216
216
|
|
|
217
217
|
<details>
|
|
218
218
|
<summary><strong>并行写文件时如何隔离 Worktree?</strong></summary>
|
|
@@ -275,7 +275,7 @@ return agent("Synthesize the verified findings", {
|
|
|
275
275
|
| `pipeline()` | 每个 item 完成上阶段后立即进入下一阶段;多阶段 fan-out 的默认选择 |
|
|
276
276
|
| `parallel()` | 并发 barrier;只在下一阶段确实需要全部结果时使用 |
|
|
277
277
|
|
|
278
|
-
Workflow 默认并发 8 个 Agent,单次最多 128 次调用;可配置到 64 和 1024。前台运行可实时查看,后台运行完成后自动回传;`/workflows` 展示阶段、Agent、Transcript、Graph
|
|
278
|
+
Workflow 默认并发 8 个 Agent,单次最多 128 次调用;可配置到 64 和 1024。前台运行可实时查看,后台运行完成后自动回传;`/workflows` 展示阶段、Agent、Transcript、Graph、用量与产物。普通子代理和 Workflow 都使用 Pi 原生传输超时与重试,不再用额外的 45 秒无可见输出计时器打断思考、排队或重试。显式取消和 Session 清理仍有界,原生 Provider 错误保留在 Child outcome 中。并发上限不代表账号的服务端速率额度;429 仍按 Pi 原生重试策略处理。
|
|
279
279
|
|
|
280
280
|
---
|
|
281
281
|
|
|
@@ -285,6 +285,8 @@ OpenPI 把一次调用拆成可以审计的生命周期,而不是把“进程
|
|
|
285
285
|
|
|
286
286
|
### Result Handoff 与派生 Graph
|
|
287
287
|
|
|
288
|
+
`agent(prompt, { working_dir: "/path/to/repository" })` 显式选择子代理工作目录;相对路径以父会话 cwd 解析,并在模型调用前验证。目标目录影响 Git、资源加载、Trust、Worktree 和 Replay 身份;只在 Prompt 中写路径不会切换 cwd。普通继承工具的内置角色不使用只读 Replay;明确配置只读工具的自定义角色仍保留原有 Replay 仓库边界。
|
|
289
|
+
|
|
288
290
|
成功调用返回同一 Run 内有效的 opaque `ref`。后续调用通过 `inputs: [previous.ref]` 显式接收上游结论;每个结论最多 16 KiB,合计最多 48 KiB,并标记为不可信数据。Artifacts 从这些引用派生只读 Graph,用来观察 lineage,不参与调度。
|
|
289
291
|
|
|
290
292
|
### Invocation Ledger
|
package/SETUP.md
CHANGED
|
@@ -16,7 +16,7 @@ Pi installs the package dependencies automatically. Restart Pi or run `/reload`
|
|
|
16
16
|
|
|
17
17
|
## fd, rg, and read-only git tools
|
|
18
18
|
|
|
19
|
-
The `file-search` extension registers `fd` and `rg` as model tools, and `git-read` registers `git_show`, `git_diff`, and `git_log` (read-only git inspection). They stay outside an ordinary parent turn until the user explicitly asks to use `fd`/`rg`/git history, or structured file search, or the model loads the `search` group through `openpi_load_tools`. Entering or restoring Plan Mode is a runtime-safety exception: it loads `search` for that Session so diff investigation can use the structured Git boundary. The gateway is shown after an explicit OpenPI-capability request, or remains visible when the user opts into adaptive discovery;
|
|
19
|
+
The `file-search` extension registers `fd` and `rg` as model tools, and `git-read` registers `git_show`, `git_diff`, and `git_log` (read-only git inspection). They stay outside an ordinary parent turn until the user explicitly asks to use `fd`/`rg`/git history, or structured file search, or the model loads the `search` group through `openpi_load_tools`. Entering or restoring Plan Mode is a runtime-safety exception: it loads `search` for that Session so diff investigation can use the structured Git boundary. The gateway is shown after an explicit OpenPI-capability request, or remains visible when the user opts into adaptive discovery; children receive these tools only when active in the parent and permitted by their role allowlist. No setup is normally needed: at startup `fd`/`rg` silently use a system-installed binary (`fd`/`fdfind` and `rg`) when available, or an existing binary in the agent's private managed bin directory (`~/.pi/agent/bin`). Only when neither exists does it download an official release binary (macOS/Linux, arm64/x64, over HTTPS) into that directory — a persistent cache that survives package updates — and show a one-time notification. If your platform is unsupported, install `fd` and `rg` with your package manager and restart Pi. The git tools require a system `git`.
|
|
20
20
|
|
|
21
21
|
While Plan Mode is active, raw Bash `git diff`, `git show`, and `git whatchanged` are refused, as are diff-generating `git log` options such as `-p`, `--stat`, `--name-only`, and `-L`. Use `git_log` to find commits and `git_diff` / `git_show` to inspect changes; the latter commands always pass `--no-ext-diff --no-textconv --no-color`, so repository-configured `diff.external` and textconv drivers are not executed. This guarantee is scoped to the Git diff-driver boundary rather than every possible hostile Git configuration; the remaining allowlisted Git investigation commands still run inside Pi's existing project Trust boundary.
|
|
22
22
|
|
|
@@ -60,7 +60,7 @@ Use the single canonical package-owned command. `/my-pi-setup` remains a compati
|
|
|
60
60
|
/openpi-setup 清除 explorer 的模型,让它继承父模型
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Capability discovery defaults to `explicit`, preserving the zero-resident OpenPI tool surface until the user asks for a capability. The case-insensitive English words `subagent` and `workflow` are reserved authorization words: entering either word is sufficient to load its capability group, and the interactive editor shows it in Claude Code-style lavender before submission, with a darker purple fallback for light themes. This makes discussion that contains either English word an intentional opt-in tradeoff; conditional and negated clauses remain inert, while Chinese capability names still require a recognized action request. `adaptive` is an explicit opt-in that keeps only `openpi_load_tools` visible and allows the model to load a useful group on its own; because this can start Subagents, Workflows, or background processes, normal permission and configured concurrency/call limits still apply. Changing the setting updates the current Session immediately, while already loaded groups remain stable for that Session. Accepted Suggestion text is classified only after it becomes real editor input. The visual feedback and runtime activation share one fail-closed intent classifier. Next-action suggestions default to off. Run `/openpi-setup` to explicitly choose an available model and reasoning level. After a fully settled main-agent run, one suggestion may appear as dim inline text on the first row of an empty editor; reserved cells at the row end keep CJK IME preedit from overwriting it. `Right` accepts it into the editor without submitting, while any other editor input dismisses it. Suggestions are ephemeral and never enter session history or model context. Workflows default to 8 concurrent agents and 128 total agent calls per run; configurable hard maxima are 64 and 1024. The large decorative header defaults off and the custom dashboard footer defaults on with a one-line plain layout (`model context |flex| git pr cwd`; `thinking`, `cache`, `cost`, and `throughput` remain opt-in metrics). Footer presets are `powerline`, `powerline-mono`, and `compact`; style can also be set independently to `plain`, `powerline`, or `powerline-mono`. Custom layouts use a 2D `footerLines` array with at most one `flex` per row for left/right alignment. Nerd Font affects powerline separator glyphs (``) and adds Codex-style outline icons to compact read, terminal, edit, search, and directory activity rows; all accompanying text remains readable without it. Footer metrics use one Codicon outline family (`` model, `` context, and `` directory) plus `⎇` for the branch. A Nerd Font containing Codicons renders them as designed; without one, the text labels remain readable even if an icon falls back to an empty box. Footer changes apply immediately in the active TUI session. Subagent results default to a compact status summary; full mode remains available as a per-user setting, and `app.tools.expand` (`Ctrl+O` by default) reveals the available child report. Ordinary `read`, `grep`, `find`, and `ls` operations render as one-line semantic activity summaries. Bash and Write/Edit default to the same activity-row projection, showing the target, running/success/failure state, and useful line or diff counts without replaying stdout or previews. Select full independently for Bash or Write/Edit to keep Pi's native rendering expanded. `app.tools.expand` temporarily restores the native arguments, output, errors, diff, timing, images, truncation notices, and full-output metadata; it never changes Session history or model context. An optional post-edit command is off by default: set one (for example `npm run format`, maximum 500 characters) and it runs once in the background after each interactive-TUI turn with successful Write/Edit operations, with failures reported as a notification. It deliberately does not guess whether arbitrary Bash commands changed files. Built-in Agent roles `explorer`, `implementer`, `reviewer`, and `advisor` are shared by `subagent_spawn.agent_type` and Workflow `agent(..., { agent_type })`; all inherit the parent model by default. `/openpi-setup` may assign a currently available Registry model to any subset; clearing one returns it to inheritance and omitted roles stay unchanged. Model precedence is explicit call > selected role-file model > setup assignment > parent inheritance; effort is explicit call > selected role > parent. A trusted project `.pi/agents/<role>.md` overrides global `~/.pi/agent/agents/<role>.md`, which overrides the complete built-in role definition; overrides are diagnosed. Role-model changes apply to the next spawn or Workflow agent call without reload. Configuration is stored privately at `~/.pi/agent/my-pi-setup.json`.
|
|
63
|
+
Capability discovery defaults to `explicit`, preserving the zero-resident OpenPI tool surface until the user asks for a capability. The case-insensitive English words `subagent` and `workflow` are reserved authorization words: entering either word is sufficient to load its capability group, and the interactive editor shows it in Claude Code-style lavender before submission, with a darker purple fallback for light themes. This makes discussion that contains either English word an intentional opt-in tradeoff; conditional and negated clauses remain inert, while Chinese capability names still require a recognized action request. `adaptive` is an explicit opt-in that keeps only `openpi_load_tools` visible and allows the model to load a useful group on its own; because this can start Subagents, Workflows, or background processes, normal permission and configured concurrency/call limits still apply. Changing the setting updates the current Session immediately, while already loaded groups remain stable for that Session. Accepted Suggestion text is classified only after it becomes real editor input. The visual feedback and runtime activation share one fail-closed intent classifier. Next-action suggestions default to off. Run `/openpi-setup` to explicitly choose an available model and reasoning level. After a fully settled main-agent run, one suggestion may appear as dim inline text on the first row of an empty editor; reserved cells at the row end keep CJK IME preedit from overwriting it. `Right` accepts it into the editor without submitting, while any other editor input dismisses it. Suggestions are ephemeral and never enter session history or model context. Workflows default to 8 concurrent agents and 128 total agent calls per run; configurable hard maxima are 64 and 1024. The large decorative header defaults off and the custom dashboard footer defaults on with a one-line plain layout (`model context |flex| git pr cwd`; `thinking`, `cache`, `cost`, and `throughput` remain opt-in metrics). Footer presets are `powerline`, `powerline-mono`, and `compact`; style can also be set independently to `plain`, `powerline`, or `powerline-mono`. Custom layouts use a 2D `footerLines` array with at most one `flex` per row for left/right alignment. Nerd Font affects powerline separator glyphs (``) and adds Codex-style outline icons to compact read, terminal, edit, search, and directory activity rows; all accompanying text remains readable without it. Footer metrics use one Codicon outline family (`` model, `` context, and `` directory) plus `⎇` for the branch. A Nerd Font containing Codicons renders them as designed; without one, the text labels remain readable even if an icon falls back to an empty box. Footer changes apply immediately in the active TUI session. Subagent results default to a compact status summary; full mode remains available as a per-user setting, and `app.tools.expand` (`Ctrl+O` by default) reveals the available child report. Ordinary `read`, `grep`, `find`, and `ls` operations render as one-line semantic activity summaries. Bash and Write/Edit default to the same activity-row projection, showing the target, running/success/failure state, and useful line or diff counts without replaying stdout or previews. Select full independently for Bash or Write/Edit to keep Pi's native rendering expanded. `app.tools.expand` temporarily restores the native arguments, output, errors, diff, timing, images, truncation notices, and full-output metadata; it never changes Session history or model context. An optional post-edit command is off by default: set one (for example `npm run format`, maximum 500 characters) and it runs once in the background after each interactive-TUI turn with successful Write/Edit operations, with failures reported as a notification. It deliberately does not guess whether arbitrary Bash commands changed files. Built-in Agent roles `explorer`, `implementer`, `reviewer`, and `advisor` are shared by `subagent_spawn.agent_type` and Workflow `agent(..., { agent_type })`; all inherit the parent model and currently active child-eligible tools by default. Explicit custom role `tools` lists narrow that surface; omitted lists inherit it. Built-in investigator roles suggest read-only work but do not impose a read-only tool boundary outside Plan Mode. Existing role files are preserved, so an old global `explorer.md` allowlist continues to exclude Bash/network tools until deliberately edited. `/openpi-setup` may assign a currently available Registry model to any subset; clearing one returns it to inheritance and omitted roles stay unchanged. Model precedence is explicit call > selected role-file model > setup assignment > parent inheritance; effort is explicit call > selected role > parent. A trusted project `.pi/agents/<role>.md` overrides global `~/.pi/agent/agents/<role>.md`, which overrides the complete built-in role definition; overrides are diagnosed. Role-model changes apply to the next spawn or Workflow agent call without reload. Configuration is stored privately at `~/.pi/agent/my-pi-setup.json`.
|
|
64
64
|
|
|
65
65
|
OpenPI Web theme defaults to `system`; `light` and `dark` are explicit canonical setup choices, and the browser consumes them from each authoritative snapshot without writing a competing local preference.
|
|
66
66
|
|
|
@@ -4,10 +4,12 @@ This extension registers two opt-in model providers backed by account OAuth:
|
|
|
4
4
|
|
|
5
5
|
- `google-antigravity` uses Google Cloud Code Assist and supports ordinary Pi
|
|
6
6
|
tool calls.
|
|
7
|
-
- `cursor` uses Cursor AgentService
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
- `cursor` uses Cursor AgentService with an experimental Pi tool bridge.
|
|
8
|
+
The active Pi tools are advertised as MCP tools. A complete invocation returns
|
|
9
|
+
to Pi for permission checks and execution; the next provider turn replays the
|
|
10
|
+
paired result. Cursor-native shell, editing, web, task, and interaction tools
|
|
11
|
+
remain unsupported and fail explicitly. The provider never executes tools
|
|
12
|
+
inside its transport or widens a child session's effective tool set.
|
|
11
13
|
|
|
12
14
|
After installing OpenPI, restart Pi or run `/reload`, then authenticate and
|
|
13
15
|
select a model:
|
|
@@ -43,8 +45,12 @@ When Cursor is selected, a supported PNG/JPEG/GIF/WebP path at the start of an
|
|
|
43
45
|
interactive prompt is converted into an actual image attachment (up to 10 MiB)
|
|
44
46
|
before the request is sent. The absolute path is not exposed to the model.
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
When Pi supplies tools, the provider directs Cursor to the advertised Pi MCP
|
|
49
|
+
catalog. Without tools it uses an explicit chat-only rule. Partial tool previews
|
|
50
|
+
and approval-only probes never execute a tool; unknown or malformed invocations
|
|
51
|
+
fail explicitly. Local HTTP/2 tests exercise a normal Pi tool lifecycle and
|
|
52
|
+
result replay, but account/model-specific compatibility still requires a live
|
|
53
|
+
smoke test. Cursor's native execution protocol is intentionally not enabled.
|
|
48
54
|
|
|
49
55
|
Cursor's token delta describes generated output only, so the provider does not
|
|
50
56
|
publish it as complete context usage. Pi 0.84.3+ can estimate an all-Cursor
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { readFile, stat } from "node:fs/promises";
|
|
2
2
|
import { basename, isAbsolute } from "node:path";
|
|
3
|
+
import type { ImageContent } from "@earendil-works/pi-ai/compat";
|
|
3
4
|
import type {
|
|
4
5
|
ExtensionContext,
|
|
5
6
|
InputEvent,
|
|
6
7
|
InputEventResult,
|
|
7
8
|
} from "@earendil-works/pi-coding-agent";
|
|
8
|
-
import type { ImageContent } from "@earendil-works/pi-ai/compat";
|
|
9
9
|
|
|
10
10
|
const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
11
11
|
|
|
@@ -58,8 +58,7 @@ function detectImageMimeType(
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Pi's TUI represents a clipboard image as a leading local path. Cursor's
|
|
61
|
-
*
|
|
62
|
-
* so convert an explicit leading image path into the same ImageContent shape
|
|
61
|
+
* provider does not execute Cursor-native read-file tools, so convert an explicit leading image path into the same ImageContent shape
|
|
63
62
|
* used by CLI/RPC attachments before the agent turn starts.
|
|
64
63
|
*/
|
|
65
64
|
export async function transformCursorImageInput(
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The field numbers and message names are vendored from
|
|
5
5
|
* oh-my-pi@eab72e88e4, packages/catalog/src/discovery/cursor-proto.ts
|
|
6
|
-
* (MIT). Only the chat, image, model-discovery, and
|
|
7
|
-
* used by this
|
|
6
|
+
* (MIT). Only the chat, image, model-discovery, and Pi MCP bridge messages
|
|
7
|
+
* used by this provider are retained. Unknown fields are skipped by
|
|
8
8
|
* the local protobuf codec so newer Cursor messages remain forward-compatible.
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -297,7 +297,8 @@ export interface ConversationStep extends ProtoMessage {
|
|
|
297
297
|
message:
|
|
298
298
|
| { case: undefined; value?: undefined }
|
|
299
299
|
| { case: "assistantMessage"; value: AssistantMessage }
|
|
300
|
-
| { case: "thinkingMessage"; value: ThinkingMessage }
|
|
300
|
+
| { case: "thinkingMessage"; value: ThinkingMessage }
|
|
301
|
+
| { case: "toolCall"; value: CursorToolCall };
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
export const ConversationStepSchema: MessageCodec<ConversationStep> =
|
|
@@ -306,6 +307,12 @@ export const ConversationStepSchema: MessageCodec<ConversationStep> =
|
|
|
306
307
|
kind: "oneof",
|
|
307
308
|
name: "message",
|
|
308
309
|
variants: [
|
|
310
|
+
{
|
|
311
|
+
no: 2,
|
|
312
|
+
name: "toolCall",
|
|
313
|
+
kind: "message",
|
|
314
|
+
T: () => CursorToolCallSchema,
|
|
315
|
+
},
|
|
309
316
|
{
|
|
310
317
|
no: 1,
|
|
311
318
|
name: "assistantMessage",
|
|
@@ -556,11 +563,77 @@ export const CursorRuleSchema: MessageCodec<CursorRule> = pb<CursorRule>(
|
|
|
556
563
|
],
|
|
557
564
|
);
|
|
558
565
|
|
|
559
|
-
|
|
560
|
-
|
|
566
|
+
export interface McpToolDefinition extends ProtoMessage {
|
|
567
|
+
name: string;
|
|
568
|
+
providerIdentifier: string;
|
|
569
|
+
toolName: string;
|
|
570
|
+
description: string;
|
|
571
|
+
inputSchema: Uint8Array;
|
|
572
|
+
inputSchemaJson?: string;
|
|
573
|
+
}
|
|
561
574
|
|
|
562
575
|
export const McpToolDefinitionSchema: MessageCodec<McpToolDefinition> =
|
|
563
|
-
pb<McpToolDefinition>("agent.v1.McpToolDefinition", [
|
|
576
|
+
pb<McpToolDefinition>("agent.v1.McpToolDefinition", [
|
|
577
|
+
{ no: 1, name: "name", kind: "string" },
|
|
578
|
+
{ no: 4, name: "providerIdentifier", kind: "string" },
|
|
579
|
+
{ no: 5, name: "toolName", kind: "string" },
|
|
580
|
+
{ no: 2, name: "description", kind: "string" },
|
|
581
|
+
{ no: 3, name: "inputSchema", kind: "bytes" },
|
|
582
|
+
{ no: 6, name: "inputSchemaJson", kind: "string", optional: true },
|
|
583
|
+
]);
|
|
584
|
+
|
|
585
|
+
export interface McpArgs extends ProtoMessage {
|
|
586
|
+
name: string;
|
|
587
|
+
args: Record<string, Uint8Array>;
|
|
588
|
+
toolCallId: string;
|
|
589
|
+
providerIdentifier: string;
|
|
590
|
+
toolName: string;
|
|
591
|
+
smartModeApprovalOnly: boolean;
|
|
592
|
+
skipApproval: boolean;
|
|
593
|
+
serverIdentifier: string;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export const McpArgsSchema: MessageCodec<McpArgs> = pb<McpArgs>(
|
|
597
|
+
"agent.v1.McpArgs",
|
|
598
|
+
[
|
|
599
|
+
{ no: 1, name: "name", kind: "string" },
|
|
600
|
+
{ no: 2, name: "args", kind: "map", K: "string", V: "bytes" },
|
|
601
|
+
{ no: 3, name: "toolCallId", kind: "string" },
|
|
602
|
+
{ no: 4, name: "providerIdentifier", kind: "string" },
|
|
603
|
+
{ no: 5, name: "toolName", kind: "string" },
|
|
604
|
+
{ no: 7, name: "smartModeApprovalOnly", kind: "bool" },
|
|
605
|
+
{ no: 8, name: "skipApproval", kind: "bool" },
|
|
606
|
+
{ no: 9, name: "serverIdentifier", kind: "string" },
|
|
607
|
+
],
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
export interface McpRejected extends ProtoMessage {
|
|
611
|
+
reason: string;
|
|
612
|
+
isReadonly: boolean;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export const McpRejectedSchema: MessageCodec<McpRejected> = pb<McpRejected>(
|
|
616
|
+
"agent.v1.McpRejected",
|
|
617
|
+
[
|
|
618
|
+
{ no: 1, name: "reason", kind: "string" },
|
|
619
|
+
{ no: 2, name: "isReadonly", kind: "bool" },
|
|
620
|
+
],
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
export interface McpToolCall extends ProtoMessage {
|
|
624
|
+
result?: McpToolResult;
|
|
625
|
+
args?: McpArgs;
|
|
626
|
+
description?: string;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export const McpToolCallSchema: MessageCodec<McpToolCall> = pb<McpToolCall>(
|
|
630
|
+
"agent.v1.McpToolCall",
|
|
631
|
+
[
|
|
632
|
+
{ no: 2, name: "result", kind: "message", T: () => McpToolResultSchema },
|
|
633
|
+
{ no: 1, name: "args", kind: "message", T: () => McpArgsSchema },
|
|
634
|
+
{ no: 3, name: "description", kind: "string", optional: true },
|
|
635
|
+
],
|
|
636
|
+
);
|
|
564
637
|
|
|
565
638
|
export interface RequestContext extends ProtoMessage {
|
|
566
639
|
rules: CursorRule[];
|
|
@@ -677,7 +750,8 @@ export interface ExecClientMessage extends ProtoMessage {
|
|
|
677
750
|
execId: string;
|
|
678
751
|
message:
|
|
679
752
|
| { case: undefined; value?: undefined }
|
|
680
|
-
| { case: "requestContextResult"; value: RequestContextResult }
|
|
753
|
+
| { case: "requestContextResult"; value: RequestContextResult }
|
|
754
|
+
| { case: "mcpResult"; value: McpResult };
|
|
681
755
|
}
|
|
682
756
|
|
|
683
757
|
export const ExecClientMessageSchema: MessageCodec<ExecClientMessage> =
|
|
@@ -688,6 +762,12 @@ export const ExecClientMessageSchema: MessageCodec<ExecClientMessage> =
|
|
|
688
762
|
kind: "oneof",
|
|
689
763
|
name: "message",
|
|
690
764
|
variants: [
|
|
765
|
+
{
|
|
766
|
+
no: 11,
|
|
767
|
+
name: "mcpResult",
|
|
768
|
+
kind: "message",
|
|
769
|
+
T: () => McpResultSchema,
|
|
770
|
+
},
|
|
691
771
|
{
|
|
692
772
|
no: 10,
|
|
693
773
|
name: "requestContextResult",
|
|
@@ -756,7 +836,8 @@ export interface ExecServerMessage extends ProtoMessage {
|
|
|
756
836
|
execId: string;
|
|
757
837
|
message:
|
|
758
838
|
| { case: undefined; value?: undefined }
|
|
759
|
-
| { case: "requestContextArgs"; value: RequestContextArgs }
|
|
839
|
+
| { case: "requestContextArgs"; value: RequestContextArgs }
|
|
840
|
+
| { case: "mcpArgs"; value: McpArgs };
|
|
760
841
|
}
|
|
761
842
|
|
|
762
843
|
export const ExecServerMessageSchema: MessageCodec<ExecServerMessage> =
|
|
@@ -767,6 +848,7 @@ export const ExecServerMessageSchema: MessageCodec<ExecServerMessage> =
|
|
|
767
848
|
kind: "oneof",
|
|
768
849
|
name: "message",
|
|
769
850
|
variants: [
|
|
851
|
+
{ no: 11, name: "mcpArgs", kind: "message", T: () => McpArgsSchema },
|
|
770
852
|
{
|
|
771
853
|
no: 10,
|
|
772
854
|
name: "requestContextArgs",
|
|
@@ -940,7 +1022,7 @@ export const InteractionUpdateSchema: MessageCodec<InteractionUpdate> =
|
|
|
940
1022
|
no: 15,
|
|
941
1023
|
name: "toolCallDelta",
|
|
942
1024
|
kind: "message",
|
|
943
|
-
T: () =>
|
|
1025
|
+
T: () => InteractionQueryPayloadSchema,
|
|
944
1026
|
},
|
|
945
1027
|
{
|
|
946
1028
|
no: 2,
|
|
@@ -988,10 +1070,57 @@ export const InteractionUpdateSchema: MessageCodec<InteractionUpdate> =
|
|
|
988
1070
|
},
|
|
989
1071
|
]);
|
|
990
1072
|
|
|
991
|
-
export interface ToolInteractionUpdate extends ProtoMessage {
|
|
1073
|
+
export interface ToolInteractionUpdate extends ProtoMessage {
|
|
1074
|
+
callId?: string;
|
|
1075
|
+
toolCall?: CursorToolCall;
|
|
1076
|
+
argsTextDelta?: string;
|
|
1077
|
+
}
|
|
992
1078
|
|
|
993
1079
|
export const ToolInteractionUpdateSchema: MessageCodec<ToolInteractionUpdate> =
|
|
994
|
-
pb<ToolInteractionUpdate>("agent.v1.ToolInteractionUpdate", [
|
|
1080
|
+
pb<ToolInteractionUpdate>("agent.v1.ToolInteractionUpdate", [
|
|
1081
|
+
{ no: 1, name: "callId", kind: "string" },
|
|
1082
|
+
{ no: 2, name: "toolCall", kind: "message", T: () => CursorToolCallSchema },
|
|
1083
|
+
{ no: 3, name: "argsTextDelta", kind: "string" },
|
|
1084
|
+
]);
|
|
1085
|
+
|
|
1086
|
+
// Only the MCP branch is supported. Unknown native tool variants remain unknown
|
|
1087
|
+
// and are rejected by the provider rather than executed outside Pi.
|
|
1088
|
+
export interface CursorToolCall extends ProtoMessage {
|
|
1089
|
+
toolCallId?: string;
|
|
1090
|
+
tool:
|
|
1091
|
+
| { case: undefined; value?: undefined }
|
|
1092
|
+
| { case: "mcpToolCall"; value: McpToolCall };
|
|
1093
|
+
}
|
|
1094
|
+
export const CursorToolCallSchema = pb<CursorToolCall>("agent.v1.ToolCall", [
|
|
1095
|
+
{ no: 57, name: "toolCallId", kind: "string", optional: true },
|
|
1096
|
+
{
|
|
1097
|
+
kind: "oneof",
|
|
1098
|
+
name: "tool",
|
|
1099
|
+
variants: [
|
|
1100
|
+
{
|
|
1101
|
+
no: 15,
|
|
1102
|
+
name: "mcpToolCall",
|
|
1103
|
+
kind: "message",
|
|
1104
|
+
T: () => McpToolCallSchema,
|
|
1105
|
+
},
|
|
1106
|
+
],
|
|
1107
|
+
},
|
|
1108
|
+
]);
|
|
1109
|
+
|
|
1110
|
+
export interface McpResult extends ProtoMessage {
|
|
1111
|
+
result:
|
|
1112
|
+
| { case: undefined; value?: undefined }
|
|
1113
|
+
| { case: "rejected"; value: McpRejected };
|
|
1114
|
+
}
|
|
1115
|
+
export const McpResultSchema = pb<McpResult>("agent.v1.McpResult", [
|
|
1116
|
+
{
|
|
1117
|
+
kind: "oneof",
|
|
1118
|
+
name: "result",
|
|
1119
|
+
variants: [
|
|
1120
|
+
{ no: 3, name: "rejected", kind: "message", T: () => McpRejectedSchema },
|
|
1121
|
+
],
|
|
1122
|
+
},
|
|
1123
|
+
]);
|
|
995
1124
|
|
|
996
1125
|
export interface TextDeltaUpdate extends ProtoMessage {
|
|
997
1126
|
text: string;
|
|
@@ -1062,3 +1191,81 @@ export const GetUsableModelsResponseSchema: MessageCodec<GetUsableModelsResponse
|
|
|
1062
1191
|
repeat: true,
|
|
1063
1192
|
},
|
|
1064
1193
|
]);
|
|
1194
|
+
|
|
1195
|
+
export interface McpSuccess extends ProtoMessage {
|
|
1196
|
+
content: McpToolResultContentItem[];
|
|
1197
|
+
isError: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
export const McpSuccessSchema: MessageCodec<McpSuccess> = pb<McpSuccess>(
|
|
1201
|
+
"agent.v1.McpSuccess",
|
|
1202
|
+
[
|
|
1203
|
+
{
|
|
1204
|
+
no: 1,
|
|
1205
|
+
name: "content",
|
|
1206
|
+
kind: "message",
|
|
1207
|
+
T: () => McpToolResultContentItemSchema,
|
|
1208
|
+
repeat: true,
|
|
1209
|
+
},
|
|
1210
|
+
{ no: 2, name: "isError", kind: "bool" },
|
|
1211
|
+
],
|
|
1212
|
+
);
|
|
1213
|
+
|
|
1214
|
+
export interface McpTextContent extends ProtoMessage {
|
|
1215
|
+
text: string;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
export const McpTextContentSchema: MessageCodec<McpTextContent> =
|
|
1219
|
+
pb<McpTextContent>("agent.v1.McpTextContent", [
|
|
1220
|
+
{ no: 1, name: "text", kind: "string" },
|
|
1221
|
+
]);
|
|
1222
|
+
|
|
1223
|
+
export interface McpImageContent extends ProtoMessage {
|
|
1224
|
+
data: Uint8Array;
|
|
1225
|
+
mimeType: string;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
export const McpImageContentSchema: MessageCodec<McpImageContent> =
|
|
1229
|
+
pb<McpImageContent>("agent.v1.McpImageContent", [
|
|
1230
|
+
{ no: 1, name: "data", kind: "bytes" },
|
|
1231
|
+
{ no: 2, name: "mimeType", kind: "string" },
|
|
1232
|
+
]);
|
|
1233
|
+
|
|
1234
|
+
export interface McpToolResultContentItem extends ProtoMessage {
|
|
1235
|
+
content:
|
|
1236
|
+
| { case: undefined; value?: undefined }
|
|
1237
|
+
| { case: "text"; value: McpTextContent }
|
|
1238
|
+
| { case: "image"; value: McpImageContent };
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export const McpToolResultContentItemSchema: MessageCodec<McpToolResultContentItem> =
|
|
1242
|
+
pb<McpToolResultContentItem>("agent.v1.McpToolResultContentItem", [
|
|
1243
|
+
{
|
|
1244
|
+
kind: "oneof",
|
|
1245
|
+
name: "content",
|
|
1246
|
+
variants: [
|
|
1247
|
+
{ no: 1, name: "text", kind: "message", T: () => McpTextContentSchema },
|
|
1248
|
+
{
|
|
1249
|
+
no: 2,
|
|
1250
|
+
name: "image",
|
|
1251
|
+
kind: "message",
|
|
1252
|
+
T: () => McpImageContentSchema,
|
|
1253
|
+
},
|
|
1254
|
+
],
|
|
1255
|
+
},
|
|
1256
|
+
]);
|
|
1257
|
+
|
|
1258
|
+
export interface McpToolResult extends ProtoMessage {
|
|
1259
|
+
result:
|
|
1260
|
+
| { case: undefined; value?: undefined }
|
|
1261
|
+
| { case: "success"; value: McpSuccess };
|
|
1262
|
+
}
|
|
1263
|
+
export const McpToolResultSchema = pb<McpToolResult>("agent.v1.McpToolResult", [
|
|
1264
|
+
{
|
|
1265
|
+
kind: "oneof",
|
|
1266
|
+
name: "result",
|
|
1267
|
+
variants: [
|
|
1268
|
+
{ no: 1, name: "success", kind: "message", T: () => McpSuccessSchema },
|
|
1269
|
+
],
|
|
1270
|
+
},
|
|
1271
|
+
]);
|
|
@@ -472,7 +472,12 @@ function compileMapField(desc: MapFieldDesc): CompiledField {
|
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
-
target
|
|
475
|
+
Object.defineProperty(target, entryKey, {
|
|
476
|
+
value: entryValue,
|
|
477
|
+
enumerable: true,
|
|
478
|
+
configurable: true,
|
|
479
|
+
writable: true,
|
|
480
|
+
});
|
|
476
481
|
},
|
|
477
482
|
toJson(message, output) {
|
|
478
483
|
const input = Reflect.get(message, name);
|
|
@@ -1143,7 +1148,12 @@ function readJsonStruct(reader: Reader): { [key: string]: JsonValue } {
|
|
|
1143
1148
|
entryReader.skip(entryWire);
|
|
1144
1149
|
}
|
|
1145
1150
|
}
|
|
1146
|
-
output
|
|
1151
|
+
Object.defineProperty(output, entryKey, {
|
|
1152
|
+
value: entryVal,
|
|
1153
|
+
enumerable: true,
|
|
1154
|
+
configurable: true,
|
|
1155
|
+
writable: true,
|
|
1156
|
+
});
|
|
1147
1157
|
} else {
|
|
1148
1158
|
reader.skip(wireType);
|
|
1149
1159
|
}
|