cursor-opencode-provider 0.2.1 → 0.2.3

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.
@@ -27,22 +27,256 @@ export function createMessageTypes() {
27
27
  { id: 5, name: "reasoning_tokens", type: "uint32" },
28
28
  ]);
29
29
  addType(root, "Heartbeat", []);
30
- // Tool call types
31
- addType(root, "ToolCall", [
32
- { id: 1, name: "call_id", type: "string" },
30
+ // Display ToolCall (interaction_update.tool_call_*) — agent.v1 oneof, not
31
+ // {tool_name,args} strings. Args-only wrappers are enough to bridge into
32
+ // OpenCode; result payloads are ignored on decode.
33
+ addType(root, "TodoItem", [
34
+ { id: 1, name: "id", type: "string" },
35
+ { id: 2, name: "content", type: "string" },
36
+ { id: 3, name: "status", type: "int32" },
37
+ { id: 4, name: "created_at", type: "int64" },
38
+ { id: 5, name: "updated_at", type: "int64" },
39
+ { id: 6, name: "dependencies", type: "string", repeated: true },
40
+ ]);
41
+ addType(root, "UpdateTodosArgs", [
42
+ { id: 1, name: "todos", type: "TodoItem", repeated: true },
43
+ { id: 2, name: "merge", type: "bool" },
44
+ ]);
45
+ addType(root, "UpdateTodosSuccess", [
46
+ { id: 1, name: "todos", type: "TodoItem", repeated: true },
47
+ { id: 2, name: "total_count", type: "int32" },
48
+ { id: 3, name: "was_merge", type: "bool" },
49
+ ]);
50
+ addType(root, "UpdateTodosError", [{ id: 1, name: "error", type: "string" }]);
51
+ addType(root, "UpdateTodosResult", [
52
+ { id: 1, name: "success", type: "UpdateTodosSuccess" },
53
+ { id: 2, name: "error", type: "UpdateTodosError" },
54
+ ], [{ name: "result", fields: ["success", "error"] }]);
55
+ addType(root, "UpdateTodosToolCall", [
56
+ { id: 1, name: "args", type: "UpdateTodosArgs" },
57
+ { id: 2, name: "result", type: "UpdateTodosResult" },
58
+ ]);
59
+ addType(root, "ReadToolArgs", [
60
+ { id: 1, name: "path", type: "string" },
61
+ { id: 2, name: "offset", type: "int32" },
62
+ { id: 3, name: "limit", type: "int32" },
63
+ ]);
64
+ addType(root, "ReadToolCall", [{ id: 1, name: "args", type: "ReadToolArgs" }]);
65
+ addType(root, "ShellToolCall", [{ id: 1, name: "args", type: "ShellArgs" }]);
66
+ addType(root, "DeleteToolCall", [{ id: 1, name: "args", type: "DeleteArgs" }]);
67
+ addType(root, "GlobToolCall", [{ id: 1, name: "args", type: "GlobArgs" }]);
68
+ addType(root, "GrepToolCall", [{ id: 1, name: "args", type: "GrepArgs" }]);
69
+ addType(root, "EditToolArgs", [
70
+ { id: 1, name: "path", type: "string" },
71
+ { id: 6, name: "stream_content", type: "string" },
72
+ ]);
73
+ addType(root, "EditToolCall", [{ id: 1, name: "args", type: "EditToolArgs" }]);
74
+ addType(root, "LsToolCall", [{ id: 1, name: "args", type: "LsArgs" }]);
75
+ addType(root, "McpToolCall", [{ id: 1, name: "args", type: "McpArgs" }]);
76
+ addType(root, "CreatePlanArgs", [
77
+ { id: 1, name: "plan", type: "string" },
78
+ { id: 2, name: "todos", type: "TodoItem", repeated: true },
79
+ { id: 3, name: "overview", type: "string" },
80
+ { id: 4, name: "name", type: "string" },
81
+ { id: 5, name: "is_project", type: "bool" },
82
+ ]);
83
+ addType(root, "CreatePlanToolCall", [{ id: 1, name: "args", type: "CreatePlanArgs" }]);
84
+ addType(root, "WebSearchToolArgs", [
85
+ { id: 1, name: "search_term", type: "string" },
86
+ { id: 2, name: "tool_call_id", type: "string" },
87
+ ]);
88
+ addType(root, "WebSearchToolCall", [{ id: 1, name: "args", type: "WebSearchToolArgs" }]);
89
+ addType(root, "SubagentTypeUnspecified", []);
90
+ addType(root, "SubagentTypeComputerUse", []);
91
+ addType(root, "SubagentTypeCustom", [{ id: 1, name: "name", type: "string" }]);
92
+ addType(root, "SubagentTypeExplore", []);
93
+ addType(root, "SubagentTypeMediaReview", []);
94
+ addType(root, "SubagentTypeBash", []);
95
+ addType(root, "SubagentTypeBrowserUse", []);
96
+ addType(root, "SubagentTypeShell", []);
97
+ addType(root, "SubagentTypeVmSetupHelper", []);
98
+ addType(root, "SubagentTypeDebug", []);
99
+ addType(root, "SubagentTypeCursorGuide", []);
100
+ addType(root, "SubagentTypeWatchVideo", []);
101
+ addType(root, "SubagentType", [
102
+ { id: 1, name: "unspecified", type: "SubagentTypeUnspecified" },
103
+ { id: 2, name: "computer_use", type: "SubagentTypeComputerUse" },
104
+ { id: 3, name: "custom", type: "SubagentTypeCustom" },
105
+ { id: 4, name: "explore", type: "SubagentTypeExplore" },
106
+ { id: 5, name: "media_review", type: "SubagentTypeMediaReview" },
107
+ { id: 6, name: "bash", type: "SubagentTypeBash" },
108
+ { id: 7, name: "browser_use", type: "SubagentTypeBrowserUse" },
109
+ { id: 8, name: "shell", type: "SubagentTypeShell" },
110
+ { id: 9, name: "vm_setup_helper", type: "SubagentTypeVmSetupHelper" },
111
+ { id: 10, name: "debug", type: "SubagentTypeDebug" },
112
+ { id: 11, name: "cursor_guide", type: "SubagentTypeCursorGuide" },
113
+ { id: 12, name: "watch_video", type: "SubagentTypeWatchVideo" },
114
+ ], [{
115
+ name: "type",
116
+ fields: [
117
+ "unspecified", "computer_use", "custom", "explore", "media_review", "bash",
118
+ "browser_use", "shell", "vm_setup_helper", "debug", "cursor_guide", "watch_video",
119
+ ],
120
+ }]);
121
+ addType(root, "TaskToolArgs", [
122
+ { id: 1, name: "description", type: "string" },
123
+ { id: 2, name: "prompt", type: "string" },
124
+ { id: 3, name: "subagent_type", type: "SubagentType" },
125
+ { id: 4, name: "model", type: "string" },
126
+ { id: 5, name: "resume", type: "string" },
127
+ { id: 6, name: "agent_id", type: "string" },
128
+ ]);
129
+ addType(root, "TaskToolCall", [{ id: 1, name: "args", type: "TaskToolArgs" }]);
130
+ addType(root, "AskQuestionOption", [
131
+ { id: 1, name: "id", type: "string" },
132
+ { id: 2, name: "label", type: "string" },
133
+ ]);
134
+ addType(root, "AskQuestionItem", [
135
+ { id: 1, name: "id", type: "string" },
136
+ { id: 2, name: "prompt", type: "string" },
137
+ { id: 3, name: "options", type: "AskQuestionOption", repeated: true },
138
+ { id: 4, name: "allow_multiple", type: "bool" },
139
+ ]);
140
+ addType(root, "AskQuestionArgs", [
141
+ { id: 1, name: "title", type: "string" },
142
+ { id: 2, name: "questions", type: "AskQuestionItem", repeated: true },
143
+ ]);
144
+ addType(root, "AskQuestionToolCall", [{ id: 1, name: "args", type: "AskQuestionArgs" }]);
145
+ addType(root, "FetchToolArgs", [
146
+ { id: 1, name: "url", type: "string" },
147
+ { id: 2, name: "tool_call_id", type: "string" },
148
+ ]);
149
+ addType(root, "FetchToolCall", [{ id: 1, name: "args", type: "FetchToolArgs" }]);
150
+ addType(root, "WebFetchToolCall", [{ id: 1, name: "args", type: "FetchToolArgs" }]);
151
+ addType(root, "SwitchModeToolArgs", [
152
+ { id: 1, name: "target_mode_id", type: "string" },
153
+ { id: 2, name: "explanation", type: "string" },
154
+ { id: 3, name: "tool_call_id", type: "string" },
155
+ ]);
156
+ addType(root, "SwitchModeToolCall", [{ id: 1, name: "args", type: "SwitchModeToolArgs" }]);
157
+ addType(root, "PiReadToolArgs", [
158
+ { id: 1, name: "path", type: "string" },
159
+ { id: 2, name: "offset", type: "int32" },
160
+ { id: 3, name: "limit", type: "int32" },
161
+ ]);
162
+ addType(root, "PiBashToolArgs", [
163
+ { id: 1, name: "command", type: "string" },
164
+ { id: 2, name: "timeout", type: "double" },
165
+ ]);
166
+ addType(root, "PiEditReplacement", [
167
+ { id: 1, name: "old_text", type: "string" },
168
+ { id: 2, name: "new_text", type: "string" },
169
+ ]);
170
+ addType(root, "PiEditToolArgs", [
171
+ { id: 1, name: "path", type: "string" },
172
+ { id: 2, name: "edits", type: "PiEditReplacement", repeated: true },
173
+ ]);
174
+ addType(root, "PiWriteToolArgs", [
175
+ { id: 1, name: "path", type: "string" },
176
+ { id: 2, name: "content", type: "string" },
177
+ ]);
178
+ addType(root, "PiGrepToolArgs", [
179
+ { id: 1, name: "pattern", type: "string" },
180
+ { id: 2, name: "path", type: "string" },
181
+ { id: 3, name: "glob", type: "string" },
182
+ { id: 4, name: "ignore_case", type: "bool" },
183
+ { id: 5, name: "literal", type: "bool" },
184
+ { id: 6, name: "context", type: "int32" },
185
+ { id: 7, name: "limit", type: "int32" },
186
+ ]);
187
+ addType(root, "PiFindToolArgs", [
188
+ { id: 1, name: "pattern", type: "string" },
189
+ { id: 2, name: "path", type: "string" },
190
+ { id: 3, name: "limit", type: "int32" },
191
+ ]);
192
+ addType(root, "PiLsToolArgs", [
193
+ { id: 1, name: "path", type: "string" },
194
+ { id: 2, name: "limit", type: "int32" },
195
+ ]);
196
+ addType(root, "PiWriteToolCall", [{ id: 1, name: "args", type: "PiWriteToolArgs" }]);
197
+ addType(root, "PiReadToolCall", [{ id: 1, name: "args", type: "PiReadToolArgs" }]);
198
+ addType(root, "PiBashToolCall", [{ id: 1, name: "args", type: "PiBashToolArgs" }]);
199
+ addType(root, "PiEditToolCall", [{ id: 1, name: "args", type: "PiEditToolArgs" }]);
200
+ addType(root, "PiGrepToolCall", [{ id: 1, name: "args", type: "PiGrepToolArgs" }]);
201
+ addType(root, "PiFindToolCall", [{ id: 1, name: "args", type: "PiFindToolArgs" }]);
202
+ addType(root, "PiLsToolCall", [{ id: 1, name: "args", type: "PiLsToolArgs" }]);
203
+ // Display-only native tools Cursor may complete without an ExecServerMessage.
204
+ addType(root, "ReadTodosArgs", [
205
+ { id: 1, name: "todo_ids", type: "string", repeated: true },
206
+ ]);
207
+ addType(root, "ReadTodosToolCall", [{ id: 1, name: "args", type: "ReadTodosArgs" }]);
208
+ addType(root, "AwaitArgs", [
209
+ { id: 1, name: "task_id", type: "string" },
210
+ { id: 2, name: "block_until_ms", type: "uint32" },
211
+ { id: 3, name: "regex", type: "string" },
212
+ ]);
213
+ addType(root, "AwaitToolCall", [{ id: 1, name: "args", type: "AwaitArgs" }]);
214
+ addType(root, "GetMcpToolsArgs", [
215
+ { id: 1, name: "server", type: "string" },
33
216
  { id: 2, name: "tool_name", type: "string" },
34
- { id: 3, name: "args", type: "string" },
217
+ { id: 3, name: "pattern", type: "string" },
218
+ { id: 4, name: "tool_call_id", type: "string" },
219
+ ]);
220
+ addType(root, "GetMcpToolsToolCall", [{ id: 1, name: "args", type: "GetMcpToolsArgs" }]);
221
+ addType(root, "GenerateImageToolArgs", [
222
+ { id: 1, name: "description", type: "string" },
223
+ { id: 2, name: "file_path", type: "string" },
224
+ { id: 5, name: "reference_image_paths", type: "string", repeated: true },
35
225
  ]);
226
+ addType(root, "GenerateImageToolCall", [{ id: 1, name: "args", type: "GenerateImageToolArgs" }]);
227
+ addType(root, "ToolCall", [
228
+ { id: 57, name: "tool_call_id", type: "string" },
229
+ { id: 1, name: "shell_tool_call", type: "ShellToolCall" },
230
+ { id: 3, name: "delete_tool_call", type: "DeleteToolCall" },
231
+ { id: 4, name: "glob_tool_call", type: "GlobToolCall" },
232
+ { id: 5, name: "grep_tool_call", type: "GrepToolCall" },
233
+ { id: 8, name: "read_tool_call", type: "ReadToolCall" },
234
+ { id: 9, name: "update_todos_tool_call", type: "UpdateTodosToolCall" },
235
+ { id: 10, name: "read_todos_tool_call", type: "ReadTodosToolCall" },
236
+ { id: 12, name: "edit_tool_call", type: "EditToolCall" },
237
+ { id: 13, name: "ls_tool_call", type: "LsToolCall" },
238
+ { id: 15, name: "mcp_tool_call", type: "McpToolCall" },
239
+ { id: 17, name: "create_plan_tool_call", type: "CreatePlanToolCall" },
240
+ { id: 18, name: "web_search_tool_call", type: "WebSearchToolCall" },
241
+ { id: 19, name: "task_tool_call", type: "TaskToolCall" },
242
+ { id: 23, name: "ask_question_tool_call", type: "AskQuestionToolCall" },
243
+ { id: 24, name: "fetch_tool_call", type: "FetchToolCall" },
244
+ { id: 25, name: "switch_mode_tool_call", type: "SwitchModeToolCall" },
245
+ { id: 28, name: "generate_image_tool_call", type: "GenerateImageToolCall" },
246
+ { id: 37, name: "web_fetch_tool_call", type: "WebFetchToolCall" },
247
+ { id: 42, name: "await_tool_call", type: "AwaitToolCall" },
248
+ { id: 44, name: "get_mcp_tools_tool_call", type: "GetMcpToolsToolCall" },
249
+ { id: 61, name: "pi_read_tool_call", type: "PiReadToolCall" },
250
+ { id: 62, name: "pi_bash_tool_call", type: "PiBashToolCall" },
251
+ { id: 63, name: "pi_edit_tool_call", type: "PiEditToolCall" },
252
+ { id: 64, name: "pi_write_tool_call", type: "PiWriteToolCall" },
253
+ { id: 65, name: "pi_grep_tool_call", type: "PiGrepToolCall" },
254
+ { id: 66, name: "pi_find_tool_call", type: "PiFindToolCall" },
255
+ { id: 67, name: "pi_ls_tool_call", type: "PiLsToolCall" },
256
+ ], [{
257
+ name: "tool",
258
+ fields: [
259
+ "shell_tool_call", "delete_tool_call", "glob_tool_call", "grep_tool_call",
260
+ "read_tool_call", "update_todos_tool_call", "read_todos_tool_call",
261
+ "edit_tool_call", "ls_tool_call",
262
+ "mcp_tool_call", "create_plan_tool_call", "web_search_tool_call", "task_tool_call",
263
+ "ask_question_tool_call", "fetch_tool_call", "switch_mode_tool_call",
264
+ "generate_image_tool_call", "web_fetch_tool_call", "await_tool_call", "get_mcp_tools_tool_call",
265
+ "pi_read_tool_call", "pi_bash_tool_call", "pi_edit_tool_call",
266
+ "pi_write_tool_call", "pi_grep_tool_call", "pi_find_tool_call", "pi_ls_tool_call",
267
+ ],
268
+ }]);
36
269
  addType(root, "ToolCallStarted", [
37
270
  { id: 1, name: "call_id", type: "string" },
38
271
  { id: 2, name: "tool_call", type: "ToolCall" },
39
272
  { id: 3, name: "model_call_id", type: "string" },
40
273
  ]);
274
+ // agent.v1 ToolCallCompletedUpdate has no string result field — result lives
275
+ // inside the typed ToolCall variant.
41
276
  addType(root, "ToolCallCompleted", [
42
277
  { id: 1, name: "call_id", type: "string" },
43
278
  { id: 2, name: "tool_call", type: "ToolCall" },
44
279
  { id: 3, name: "model_call_id", type: "string" },
45
- { id: 4, name: "result", type: "string" },
46
280
  ]);
47
281
  addType(root, "PartialToolCall", [
48
282
  { id: 1, name: "call_id", type: "string" },
@@ -161,8 +395,12 @@ export function createMessageTypes() {
161
395
  { id: 1, name: "success", type: "WriteSuccess" },
162
396
  { id: 5, name: "error", type: "WriteError" },
163
397
  ], [{ name: "result", fields: ["success", "error"] }]);
164
- // agent.v1 PiWriteExecArgs / Result (exec #48 / #49) alternate write path
165
- // used by some Cursor models. Args are path+content; success is just output.
398
+ // agent.v1 Pi exec results. Cursor places Pi requests at ExecServerMessage
399
+ // fields #45..#51 and their corresponding ExecClientMessage results at
400
+ // #46..#52 (the result fields are deliberately offset by one).
401
+ //
402
+ // The success payloads contain additional optional truncation/diff metadata;
403
+ // OpenCode returns text, so the minimal output/error shapes are sufficient.
166
404
  addType(root, "PiWriteArgs", [
167
405
  { id: 1, name: "path", type: "string" },
168
406
  { id: 2, name: "content", type: "string" },
@@ -173,10 +411,34 @@ export function createMessageTypes() {
173
411
  addType(root, "PiWriteError", [
174
412
  { id: 1, name: "error", type: "string" },
175
413
  ]);
414
+ addType(root, "PiWriteRejected", [
415
+ { id: 1, name: "reason", type: "string" },
416
+ ]);
176
417
  addType(root, "PiWriteResult", [
177
418
  { id: 1, name: "success", type: "PiWriteSuccess" },
178
419
  { id: 2, name: "error", type: "PiWriteError" },
179
- ], [{ name: "result", fields: ["success", "error"] }]);
420
+ { id: 3, name: "rejected", type: "PiWriteRejected" },
421
+ ], [{ name: "result", fields: ["success", "error", "rejected"] }]);
422
+ addType(root, "PiOutputSuccess", [{ id: 1, name: "output", type: "string" }]);
423
+ addType(root, "PiExecError", [{ id: 1, name: "error", type: "string" }]);
424
+ addType(root, "PiExecRejected", [{ id: 1, name: "reason", type: "string" }]);
425
+ for (const resultType of [
426
+ "PiReadExecResult",
427
+ "PiBashExecResult",
428
+ "PiGrepExecResult",
429
+ "PiFindExecResult",
430
+ "PiLsExecResult",
431
+ ]) {
432
+ addType(root, resultType, [
433
+ { id: 1, name: "success", type: "PiOutputSuccess" },
434
+ { id: 2, name: "error", type: "PiExecError" },
435
+ ], [{ name: "result", fields: ["success", "error"] }]);
436
+ }
437
+ addType(root, "PiEditExecResult", [
438
+ { id: 1, name: "success", type: "PiOutputSuccess" },
439
+ { id: 2, name: "error", type: "PiExecError" },
440
+ { id: 3, name: "rejected", type: "PiExecRejected" },
441
+ ], [{ name: "result", fields: ["success", "error", "rejected"] }]);
180
442
  addType(root, "DeleteArgs", [
181
443
  { id: 1, name: "path", type: "string" },
182
444
  { id: 2, name: "tool_call_id", type: "string" },
@@ -395,6 +657,37 @@ export function createMessageTypes() {
395
657
  addType(root, "RequestContextResult", [
396
658
  { id: 1, name: "success", type: "RequestContextSuccess" },
397
659
  ]);
660
+ // Cursor probes MCP server availability before emitting an MCP-backed tool
661
+ // call. OpenCode owns those servers, so answer from the descriptors already
662
+ // advertised in RequestContext rather than surfacing this as a user tool.
663
+ addType(root, "McpStateExecArgs", [
664
+ { id: 1, name: "server_identifiers", type: "string", repeated: true },
665
+ { id: 2, name: "kick_only", type: "bool" },
666
+ ]);
667
+ addType(root, "McpInstructions", [
668
+ { id: 1, name: "server_name", type: "string" },
669
+ { id: 2, name: "instructions", type: "string" },
670
+ { id: 3, name: "server_identifier", type: "string" },
671
+ ]);
672
+ addType(root, "McpStateServer", [
673
+ { id: 1, name: "server_name", type: "string" },
674
+ { id: 2, name: "server_identifier", type: "string" },
675
+ { id: 3, name: "plugin", type: "string" },
676
+ { id: 4, name: "marketplace", type: "string" },
677
+ { id: 5, name: "tools", type: "McpFsToolDescriptor", repeated: true },
678
+ { id: 6, name: "instructions", type: "McpInstructions", repeated: true },
679
+ { id: 7, name: "status", type: "string" },
680
+ ]);
681
+ addType(root, "McpStateSuccess", [
682
+ { id: 1, name: "servers", type: "McpStateServer", repeated: true },
683
+ ]);
684
+ addType(root, "McpStateError", [{ id: 1, name: "error", type: "string" }]);
685
+ addType(root, "McpStateRejected", [{ id: 1, name: "reason", type: "string" }]);
686
+ addType(root, "McpStateExecResult", [
687
+ { id: 1, name: "success", type: "McpStateSuccess" },
688
+ { id: 2, name: "error", type: "McpStateError" },
689
+ { id: 3, name: "rejected", type: "McpStateRejected" },
690
+ ], [{ name: "result", fields: ["success", "error", "rejected"] }]);
398
691
  // ExecServerMessage — server asks us to execute a tool
399
692
  addType(root, "ExecServerMessage", [
400
693
  { id: 1, name: "id", type: "uint32" },
@@ -408,9 +701,20 @@ export function createMessageTypes() {
408
701
  { id: 10, name: "request_context_args", type: "RequestContextArgs" },
409
702
  { id: 11, name: "mcp_args", type: "McpArgs" },
410
703
  { id: 14, name: "shell_stream_args", type: "ShellArgs" },
411
- // Pi write (#48 args #49 result). Field numbers differ from classic write (#3).
704
+ { id: 36, name: "mcp_state_exec_args", type: "McpStateExecArgs" },
705
+ { id: 45, name: "pi_read_args", type: "PiReadToolArgs" },
706
+ { id: 46, name: "pi_bash_args", type: "PiBashToolArgs" },
707
+ { id: 47, name: "pi_edit_args", type: "PiEditToolArgs" },
412
708
  { id: 48, name: "pi_write_args", type: "PiWriteArgs" },
413
- ], [{ name: "args", fields: ["write_args", "delete_args", "grep_args", "read_args", "ls_args", "request_context_args", "mcp_args", "shell_stream_args", "pi_write_args"] }]);
709
+ { id: 49, name: "pi_grep_args", type: "PiGrepToolArgs" },
710
+ { id: 50, name: "pi_find_args", type: "PiFindToolArgs" },
711
+ { id: 51, name: "pi_ls_args", type: "PiLsToolArgs" },
712
+ ], [{ name: "args", fields: [
713
+ "write_args", "delete_args", "grep_args", "read_args", "ls_args",
714
+ "request_context_args", "mcp_args", "shell_stream_args", "mcp_state_exec_args",
715
+ "pi_read_args", "pi_bash_args", "pi_edit_args", "pi_write_args",
716
+ "pi_grep_args", "pi_find_args", "pi_ls_args",
717
+ ] }]);
414
718
  // ExecClientMessage — client sends tool result back
415
719
  addType(root, "ExecClientMessage", [
416
720
  { id: 1, name: "id", type: "uint32" },
@@ -424,8 +728,20 @@ export function createMessageTypes() {
424
728
  { id: 10, name: "request_context_result", type: "RequestContextResult" },
425
729
  { id: 11, name: "mcp_result", type: "McpResult" },
426
730
  { id: 14, name: "shell_stream", type: "ShellStream" },
731
+ { id: 36, name: "mcp_state_exec_result", type: "McpStateExecResult" },
732
+ { id: 46, name: "pi_read_result", type: "PiReadExecResult" },
733
+ { id: 47, name: "pi_bash_result", type: "PiBashExecResult" },
734
+ { id: 48, name: "pi_edit_result", type: "PiEditExecResult" },
427
735
  { id: 49, name: "pi_write_result", type: "PiWriteResult" },
428
- ], [{ name: "result", fields: ["write_result", "delete_result", "grep_result", "read_result", "ls_result", "request_context_result", "mcp_result", "shell_stream", "pi_write_result"] }]);
736
+ { id: 50, name: "pi_grep_result", type: "PiGrepExecResult" },
737
+ { id: 51, name: "pi_find_result", type: "PiFindExecResult" },
738
+ { id: 52, name: "pi_ls_result", type: "PiLsExecResult" },
739
+ ], [{ name: "result", fields: [
740
+ "write_result", "delete_result", "grep_result", "read_result", "ls_result",
741
+ "request_context_result", "mcp_result", "shell_stream", "mcp_state_exec_result",
742
+ "pi_read_result", "pi_bash_result", "pi_edit_result", "pi_write_result",
743
+ "pi_grep_result", "pi_find_result", "pi_ls_result",
744
+ ] }]);
429
745
  addType(root, "ExecServerControlMessage", [
430
746
  { id: 1, name: "abort", type: "ExecServerAbort" },
431
747
  ]);
@@ -556,6 +872,130 @@ export function createMessageTypes() {
556
872
  ]);
557
873
  // ── Client heartbeat ──
558
874
  addType(root, "ClientHeartbeat", []);
875
+ // ── Interaction query/response channel ──
876
+ // Cursor sends UI/integration requests outside the exec tool channel. Query
877
+ // bodies stay opaque: this headless provider only needs their id + variant
878
+ // to return a conservative typed response on the same Run stream.
879
+ addType(root, "InteractionQuery", [
880
+ { id: 1, name: "id", type: "uint32" },
881
+ { id: 2, name: "web_search_request_query", type: "bytes" },
882
+ { id: 3, name: "ask_question_interaction_query", type: "bytes" },
883
+ { id: 4, name: "switch_mode_request_query", type: "bytes" },
884
+ { id: 7, name: "create_plan_request_query", type: "bytes" },
885
+ { id: 8, name: "setup_vm_environment_args", type: "bytes" },
886
+ { id: 9, name: "web_fetch_request_query", type: "bytes" },
887
+ { id: 10, name: "pr_management_request_query", type: "bytes" },
888
+ { id: 11, name: "mcp_auth_request_query", type: "bytes" },
889
+ { id: 12, name: "generate_image_request_query", type: "bytes" },
890
+ { id: 13, name: "replace_env_args", type: "bytes" },
891
+ { id: 14, name: "connect_scm_request_query", type: "bytes" },
892
+ ], [{
893
+ name: "query",
894
+ fields: [
895
+ "web_search_request_query", "ask_question_interaction_query",
896
+ "switch_mode_request_query", "create_plan_request_query",
897
+ "setup_vm_environment_args", "web_fetch_request_query",
898
+ "pr_management_request_query", "mcp_auth_request_query",
899
+ "generate_image_request_query", "replace_env_args",
900
+ "connect_scm_request_query",
901
+ ],
902
+ }]);
903
+ addType(root, "WebSearchRequestApproved", []);
904
+ addType(root, "WebSearchRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
905
+ addType(root, "WebSearchRequestResponse", [
906
+ { id: 1, name: "approved", type: "WebSearchRequestApproved" },
907
+ { id: 2, name: "rejected", type: "WebSearchRequestRejected" },
908
+ ], [{ name: "result", fields: ["approved", "rejected"] }]);
909
+ addType(root, "AskQuestionRejected", [{ id: 1, name: "reason", type: "string" }]);
910
+ addType(root, "AskQuestionResult", [
911
+ { id: 3, name: "rejected", type: "AskQuestionRejected" },
912
+ ], [{ name: "result", fields: ["rejected"] }]);
913
+ addType(root, "AskQuestionInteractionResponse", [
914
+ { id: 1, name: "result", type: "AskQuestionResult" },
915
+ ]);
916
+ addType(root, "SwitchModeRequestApproved", []);
917
+ addType(root, "SwitchModeRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
918
+ addType(root, "SwitchModeRequestResponse", [
919
+ { id: 1, name: "approved", type: "SwitchModeRequestApproved" },
920
+ { id: 2, name: "rejected", type: "SwitchModeRequestRejected" },
921
+ ], [{ name: "result", fields: ["approved", "rejected"] }]);
922
+ addType(root, "CreatePlanSuccess", []);
923
+ addType(root, "CreatePlanError", [{ id: 1, name: "error", type: "string" }]);
924
+ addType(root, "CreatePlanResult", [
925
+ { id: 1, name: "success", type: "CreatePlanSuccess" },
926
+ { id: 2, name: "error", type: "CreatePlanError" },
927
+ { id: 3, name: "plan_uri", type: "string" },
928
+ ], [{ name: "result", fields: ["success", "error"] }]);
929
+ addType(root, "CreatePlanRequestResponse", [
930
+ { id: 1, name: "result", type: "CreatePlanResult" },
931
+ ]);
932
+ addType(root, "SetupVmEnvironmentSuccess", []);
933
+ addType(root, "SetupVmEnvironmentResult", [
934
+ { id: 1, name: "success", type: "SetupVmEnvironmentSuccess" },
935
+ ], [{ name: "result", fields: ["success"] }]);
936
+ addType(root, "WebFetchRequestApproved", []);
937
+ addType(root, "WebFetchRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
938
+ addType(root, "WebFetchRequestResponse", [
939
+ { id: 1, name: "approved", type: "WebFetchRequestApproved" },
940
+ { id: 2, name: "rejected", type: "WebFetchRequestRejected" },
941
+ ], [{ name: "result", fields: ["approved", "rejected"] }]);
942
+ addType(root, "PrManagementRejected", [{ id: 1, name: "reason", type: "string" }]);
943
+ addType(root, "PrManagementResult", [
944
+ { id: 3, name: "rejected", type: "PrManagementRejected" },
945
+ ], [{ name: "result", fields: ["rejected"] }]);
946
+ addType(root, "McpAuthRequestApproved", []);
947
+ addType(root, "McpAuthRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
948
+ addType(root, "McpAuthRequestResponse", [
949
+ { id: 1, name: "approved", type: "McpAuthRequestApproved" },
950
+ { id: 2, name: "rejected", type: "McpAuthRequestRejected" },
951
+ ], [{ name: "result", fields: ["approved", "rejected"] }]);
952
+ addType(root, "GenerateImageRequestApproved", [{ id: 1, name: "description", type: "string" }]);
953
+ addType(root, "GenerateImageRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
954
+ addType(root, "GenerateImageRequestResponse", [
955
+ { id: 1, name: "approved", type: "GenerateImageRequestApproved" },
956
+ { id: 2, name: "rejected", type: "GenerateImageRequestRejected" },
957
+ ], [{ name: "result", fields: ["approved", "rejected"] }]);
958
+ addType(root, "ReplaceEnvSuccess", []);
959
+ addType(root, "ReplaceEnvFailure", [
960
+ { id: 1, name: "error_message", type: "string" },
961
+ { id: 2, name: "setup_logs", type: "string" },
962
+ ]);
963
+ addType(root, "ReplaceEnvResult", [
964
+ { id: 1, name: "success", type: "ReplaceEnvSuccess" },
965
+ { id: 2, name: "failure", type: "ReplaceEnvFailure" },
966
+ ], [{ name: "result", fields: ["success", "failure"] }]);
967
+ addType(root, "ConnectScmRequestApproved", []);
968
+ addType(root, "ConnectScmRequestRejected", [{ id: 1, name: "reason", type: "string" }]);
969
+ addType(root, "ConnectScmRequestFailed", [{ id: 1, name: "error", type: "string" }]);
970
+ addType(root, "ConnectScmRequestResponse", [
971
+ { id: 1, name: "approved", type: "ConnectScmRequestApproved" },
972
+ { id: 2, name: "rejected", type: "ConnectScmRequestRejected" },
973
+ { id: 3, name: "failed", type: "ConnectScmRequestFailed" },
974
+ ], [{ name: "result", fields: ["approved", "rejected", "failed"] }]);
975
+ addType(root, "InteractionResponse", [
976
+ { id: 1, name: "id", type: "uint32" },
977
+ { id: 2, name: "web_search_request_response", type: "WebSearchRequestResponse" },
978
+ { id: 3, name: "ask_question_interaction_response", type: "AskQuestionInteractionResponse" },
979
+ { id: 4, name: "switch_mode_request_response", type: "SwitchModeRequestResponse" },
980
+ { id: 7, name: "create_plan_request_response", type: "CreatePlanRequestResponse" },
981
+ { id: 8, name: "setup_vm_environment_result", type: "SetupVmEnvironmentResult" },
982
+ { id: 9, name: "web_fetch_request_response", type: "WebFetchRequestResponse" },
983
+ { id: 10, name: "pr_management_result", type: "PrManagementResult" },
984
+ { id: 11, name: "mcp_auth_request_response", type: "McpAuthRequestResponse" },
985
+ { id: 12, name: "generate_image_request_response", type: "GenerateImageRequestResponse" },
986
+ { id: 13, name: "replace_env_result", type: "ReplaceEnvResult" },
987
+ { id: 14, name: "connect_scm_request_response", type: "ConnectScmRequestResponse" },
988
+ ], [{
989
+ name: "result",
990
+ fields: [
991
+ "web_search_request_response", "ask_question_interaction_response",
992
+ "switch_mode_request_response", "create_plan_request_response",
993
+ "setup_vm_environment_result", "web_fetch_request_response",
994
+ "pr_management_result", "mcp_auth_request_response",
995
+ "generate_image_request_response", "replace_env_result",
996
+ "connect_scm_request_response",
997
+ ],
998
+ }]);
559
999
  // ── KV blob store (cursor moves large payloads out-of-band via this channel) ──
560
1000
  // Server sends KvServerMessage (AgentServerMessage #4); client MUST reply with
561
1001
  // KvClientMessage (AgentClientMessage #3) on the same Run stream, echoing `id`.
@@ -590,8 +1030,9 @@ export function createMessageTypes() {
590
1030
  { id: 2, name: "exec_client_message", type: "ExecClientMessage" },
591
1031
  { id: 3, name: "kv_client_message", type: "KvClientMessage" },
592
1032
  { id: 5, name: "exec_client_control_message", type: "ExecClientControlMessage" },
1033
+ { id: 6, name: "interaction_response", type: "InteractionResponse" },
593
1034
  { id: 7, name: "client_heartbeat", type: "ClientHeartbeat" },
594
- ], [{ name: "message", fields: ["run_request", "exec_client_message", "kv_client_message", "exec_client_control_message", "client_heartbeat"] }]);
1035
+ ], [{ name: "message", fields: ["run_request", "exec_client_message", "kv_client_message", "exec_client_control_message", "interaction_response", "client_heartbeat"] }]);
595
1036
  // ── AgentServerMessage ──
596
1037
  addType(root, "AgentServerMessage", [
597
1038
  { id: 1, name: "interaction_update", type: "InteractionUpdate" },
@@ -599,7 +1040,7 @@ export function createMessageTypes() {
599
1040
  { id: 3, name: "conversation_checkpoint_update", type: "bytes" },
600
1041
  { id: 4, name: "kv_server_message", type: "KvServerMessage" },
601
1042
  { id: 5, name: "exec_server_control_message", type: "ExecServerControlMessage" },
602
- { id: 7, name: "interaction_query", type: "bytes" },
1043
+ { id: 7, name: "interaction_query", type: "InteractionQuery" },
603
1044
  ], [{ name: "message", fields: ["interaction_update", "exec_server_message", "conversation_checkpoint_update", "kv_server_message", "exec_server_control_message", "interaction_query"] }]);
604
1045
  // ── AvailableModels types ──
605
1046
  addType(root, "AvailableModelsRequest", []);
@@ -1,10 +1,20 @@
1
1
  import { type OpencodeToolDef } from "./tools.js";
2
2
  import type { ModelInfo } from "../models.js";
3
+ export type SeedHistoryMessage = {
4
+ role: "system" | "user" | "assistant";
5
+ content: string;
6
+ };
3
7
  export type RunRequestInput = {
4
8
  text: string;
5
9
  modelId: string;
6
10
  conversationId: string;
7
11
  systemPrompt?: string;
12
+ /**
13
+ * Prior chat turns for a seed ConversationStateStructure (no checkpoint).
14
+ * Used after compaction reset so Cursor sees OpenCode's compacted history
15
+ * instead of an empty conversation.
16
+ */
17
+ history?: SeedHistoryMessage[];
8
18
  /**
9
19
  * Opaque ConversationStateStructure bytes from the last
10
20
  * conversation_checkpoint_update for this conversation_id. When set, echoed
@@ -20,9 +30,29 @@ export type RunRequestInput = {
20
30
  messageId?: string;
21
31
  availableModels?: ModelInfo[];
22
32
  tools?: OpencodeToolDef[];
33
+ /** Pre-resolved descriptors (including config-backed MCP server identity). */
34
+ toolDescriptors?: Array<Record<string, unknown>>;
23
35
  /** Prebuilt RequestContext (OpenCode-sourced). */
24
36
  requestContext?: Record<string, unknown>;
25
37
  };
38
+ /**
39
+ * Seed ConversationStateStructure for the first turn (no checkpoint yet).
40
+ *
41
+ * OpenCode needs a system prompt channel; we put it in root_prompt_messages_json
42
+ * as a JSON chat message. After the first checkpoint arrives we stop inventing
43
+ * state and echo the server's opaque structure instead (CLI behavior).
44
+ *
45
+ * Compaction resets also use this seed, with `history` carrying OpenCode's
46
+ * compacted prompt turns so Cursor can summarize without the old checkpoint.
47
+ *
48
+ * We deliberately do NOT use `AgentRunRequest.custom_system_prompt` (#8): that
49
+ * field is the internal `--system-prompt` CLI override and the server rejects
50
+ * it for normal accounts.
51
+ */
52
+ export declare function buildSeedConversationState(input?: {
53
+ systemPrompt?: string;
54
+ history?: SeedHistoryMessage[];
55
+ }): Uint8Array;
26
56
  /**
27
57
  * Build an AgentClientMessage{run_request} for a conversation turn.
28
58
  *