opencode-ext-connector 0.3.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.
Files changed (332) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +29 -0
  3. package/README.md +207 -0
  4. package/THIRD_PARTY_NOTICES.md +201 -0
  5. package/dist/catalog/parse-ids.d.ts +2 -0
  6. package/dist/catalog/parse-ids.js +49 -0
  7. package/dist/core/adapter.d.ts +16 -0
  8. package/dist/core/adapter.js +20 -0
  9. package/dist/core/clock.d.ts +7 -0
  10. package/dist/core/clock.js +1 -0
  11. package/dist/core/deadline.d.ts +13 -0
  12. package/dist/core/deadline.js +54 -0
  13. package/dist/core/errors.d.ts +57 -0
  14. package/dist/core/errors.js +81 -0
  15. package/dist/core/health.d.ts +22 -0
  16. package/dist/core/health.js +30 -0
  17. package/dist/core/http.d.ts +28 -0
  18. package/dist/core/http.js +1 -0
  19. package/dist/core/ids.d.ts +7 -0
  20. package/dist/core/ids.js +23 -0
  21. package/dist/core/lifecycle.d.ts +4 -0
  22. package/dist/core/lifecycle.js +16 -0
  23. package/dist/core/logger.d.ts +21 -0
  24. package/dist/core/logger.js +61 -0
  25. package/dist/core/models.d.ts +41 -0
  26. package/dist/core/models.js +59 -0
  27. package/dist/core/options.d.ts +31 -0
  28. package/dist/core/options.js +62 -0
  29. package/dist/core/process.d.ts +20 -0
  30. package/dist/core/process.js +1 -0
  31. package/dist/http/fetch-transport.d.ts +2 -0
  32. package/dist/http/fetch-transport.js +75 -0
  33. package/dist/http/package-version.d.ts +7 -0
  34. package/dist/http/package-version.js +46 -0
  35. package/dist/http/read-body.d.ts +9 -0
  36. package/dist/http/read-body.js +22 -0
  37. package/dist/index.d.ts +6 -0
  38. package/dist/index.js +5 -0
  39. package/dist/logging/logger.d.ts +4 -0
  40. package/dist/logging/logger.js +11 -0
  41. package/dist/opencode/auth-store.d.ts +19 -0
  42. package/dist/opencode/auth-store.js +107 -0
  43. package/dist/opencode/beta-api.d.ts +3 -0
  44. package/dist/opencode/beta-api.js +1 -0
  45. package/dist/opencode/catalog-bridge.d.ts +3 -0
  46. package/dist/opencode/catalog-bridge.js +85 -0
  47. package/dist/opencode/health-refresh.d.ts +16 -0
  48. package/dist/opencode/health-refresh.js +49 -0
  49. package/dist/opencode/host-options.d.ts +2 -0
  50. package/dist/opencode/host-options.js +49 -0
  51. package/dist/opencode/language-factory.d.ts +13 -0
  52. package/dist/opencode/language-factory.js +37 -0
  53. package/dist/opencode/ollama-probe.d.ts +2 -0
  54. package/dist/opencode/ollama-probe.js +15 -0
  55. package/dist/opencode/ollama-production.d.ts +4 -0
  56. package/dist/opencode/ollama-production.js +10 -0
  57. package/dist/opencode/plugin.d.ts +33 -0
  58. package/dist/opencode/plugin.js +40 -0
  59. package/dist/opencode/process-exit.d.ts +4 -0
  60. package/dist/opencode/process-exit.js +22 -0
  61. package/dist/opencode/provider-entry.d.ts +25 -0
  62. package/dist/opencode/provider-entry.js +1 -0
  63. package/dist/opencode/providers.d.ts +16 -0
  64. package/dist/opencode/providers.js +140 -0
  65. package/dist/opencode/register-integrations.d.ts +3 -0
  66. package/dist/opencode/register-integrations.js +8 -0
  67. package/dist/opencode/reload.d.ts +9 -0
  68. package/dist/opencode/reload.js +30 -0
  69. package/dist/opencode/v1-anthropic-auth.d.ts +9 -0
  70. package/dist/opencode/v1-anthropic-auth.js +55 -0
  71. package/dist/opencode/v1-catalog.d.ts +13 -0
  72. package/dist/opencode/v1-catalog.js +80 -0
  73. package/dist/opencode/v1-language.d.ts +3 -0
  74. package/dist/opencode/v1-language.js +64 -0
  75. package/dist/opencode/v1-module.d.ts +23 -0
  76. package/dist/opencode/v1-module.js +74 -0
  77. package/dist/opencode/v1-session-auth.d.ts +5 -0
  78. package/dist/opencode/v1-session-auth.js +98 -0
  79. package/dist/providers/claude/adapter.d.ts +7 -0
  80. package/dist/providers/claude/adapter.js +37 -0
  81. package/dist/providers/claude/atomic-private-file.d.ts +13 -0
  82. package/dist/providers/claude/atomic-private-file.js +94 -0
  83. package/dist/providers/claude/auth-json.d.ts +2 -0
  84. package/dist/providers/claude/auth-json.js +14 -0
  85. package/dist/providers/claude/auth.d.ts +24 -0
  86. package/dist/providers/claude/auth.js +200 -0
  87. package/dist/providers/claude/cli-version.d.ts +10 -0
  88. package/dist/providers/claude/cli-version.js +36 -0
  89. package/dist/providers/claude/compat-betas.d.ts +5 -0
  90. package/dist/providers/claude/compat-betas.js +54 -0
  91. package/dist/providers/claude/compat-config.d.ts +8 -0
  92. package/dist/providers/claude/compat-config.js +31 -0
  93. package/dist/providers/claude/compat-request.d.ts +12 -0
  94. package/dist/providers/claude/compat-request.js +151 -0
  95. package/dist/providers/claude/compat-response.d.ts +1 -0
  96. package/dist/providers/claude/compat-response.js +54 -0
  97. package/dist/providers/claude/compat-signing.d.ts +9 -0
  98. package/dist/providers/claude/compat-signing.js +24 -0
  99. package/dist/providers/claude/compat-transform.d.ts +3 -0
  100. package/dist/providers/claude/compat-transform.js +224 -0
  101. package/dist/providers/claude/credentials.d.ts +7 -0
  102. package/dist/providers/claude/credentials.js +37 -0
  103. package/dist/providers/claude/emit-stream.d.ts +2 -0
  104. package/dist/providers/claude/emit-stream.js +62 -0
  105. package/dist/providers/claude/keychain-account.d.ts +1 -0
  106. package/dist/providers/claude/keychain-account.js +14 -0
  107. package/dist/providers/claude/language-model.d.ts +8 -0
  108. package/dist/providers/claude/language-model.js +109 -0
  109. package/dist/providers/claude/models.d.ts +9 -0
  110. package/dist/providers/claude/models.js +24 -0
  111. package/dist/providers/claude/prompt.d.ts +42 -0
  112. package/dist/providers/claude/prompt.js +134 -0
  113. package/dist/providers/claude/refresh.d.ts +19 -0
  114. package/dist/providers/claude/refresh.js +85 -0
  115. package/dist/providers/claude/sse-convert.d.ts +6 -0
  116. package/dist/providers/claude/sse-convert.js +74 -0
  117. package/dist/providers/claude/sse.d.ts +71 -0
  118. package/dist/providers/claude/sse.js +123 -0
  119. package/dist/providers/claude/transform.d.ts +32 -0
  120. package/dist/providers/claude/transform.js +52 -0
  121. package/dist/providers/claude/writeback.d.ts +18 -0
  122. package/dist/providers/claude/writeback.js +140 -0
  123. package/dist/providers/command-code/adapter.d.ts +7 -0
  124. package/dist/providers/command-code/adapter.js +37 -0
  125. package/dist/providers/command-code/auth.d.ts +5 -0
  126. package/dist/providers/command-code/auth.js +88 -0
  127. package/dist/providers/command-code/cli-version.d.ts +10 -0
  128. package/dist/providers/command-code/cli-version.js +36 -0
  129. package/dist/providers/command-code/emit-stream.d.ts +2 -0
  130. package/dist/providers/command-code/emit-stream.js +226 -0
  131. package/dist/providers/command-code/errors.d.ts +33 -0
  132. package/dist/providers/command-code/errors.js +105 -0
  133. package/dist/providers/command-code/language-model.d.ts +15 -0
  134. package/dist/providers/command-code/language-model.js +203 -0
  135. package/dist/providers/command-code/models.d.ts +3 -0
  136. package/dist/providers/command-code/models.js +18 -0
  137. package/dist/providers/command-code/record-stream.d.ts +1 -0
  138. package/dist/providers/command-code/record-stream.js +61 -0
  139. package/dist/providers/command-code/request-lifecycle.d.ts +8 -0
  140. package/dist/providers/command-code/request-lifecycle.js +33 -0
  141. package/dist/providers/command-code/request.d.ts +14 -0
  142. package/dist/providers/command-code/request.js +167 -0
  143. package/dist/providers/command-code/session.d.ts +5 -0
  144. package/dist/providers/command-code/session.js +9 -0
  145. package/dist/providers/cursor/adapter.d.ts +7 -0
  146. package/dist/providers/cursor/adapter.js +37 -0
  147. package/dist/providers/cursor/auth.d.ts +6 -0
  148. package/dist/providers/cursor/auth.js +56 -0
  149. package/dist/providers/cursor/blob-store.d.ts +26 -0
  150. package/dist/providers/cursor/blob-store.js +119 -0
  151. package/dist/providers/cursor/bridge-client.d.ts +33 -0
  152. package/dist/providers/cursor/bridge-client.js +200 -0
  153. package/dist/providers/cursor/bridge-event-sanitize.d.ts +3 -0
  154. package/dist/providers/cursor/bridge-event-sanitize.js +49 -0
  155. package/dist/providers/cursor/bridge-limits.d.ts +3 -0
  156. package/dist/providers/cursor/bridge-limits.js +10 -0
  157. package/dist/providers/cursor/bridge-process.d.ts +45 -0
  158. package/dist/providers/cursor/bridge-process.js +211 -0
  159. package/dist/providers/cursor/bridge-protocol.d.ts +68 -0
  160. package/dist/providers/cursor/bridge-protocol.js +49 -0
  161. package/dist/providers/cursor/bridge-serialize.d.ts +3 -0
  162. package/dist/providers/cursor/bridge-serialize.js +53 -0
  163. package/dist/providers/cursor/bridge-wire.d.ts +3 -0
  164. package/dist/providers/cursor/bridge-wire.js +163 -0
  165. package/dist/providers/cursor/checkpoint-store.d.ts +28 -0
  166. package/dist/providers/cursor/checkpoint-store.js +94 -0
  167. package/dist/providers/cursor/connect-frame-stream.d.ts +19 -0
  168. package/dist/providers/cursor/connect-frame-stream.js +160 -0
  169. package/dist/providers/cursor/connect-frame.d.ts +31 -0
  170. package/dist/providers/cursor/connect-frame.js +121 -0
  171. package/dist/providers/cursor/credentials.d.ts +5 -0
  172. package/dist/providers/cursor/credentials.js +22 -0
  173. package/dist/providers/cursor/direct-run-types.d.ts +33 -0
  174. package/dist/providers/cursor/direct-run-types.js +1 -0
  175. package/dist/providers/cursor/direct-run.d.ts +5 -0
  176. package/dist/providers/cursor/direct-run.js +213 -0
  177. package/dist/providers/cursor/direct-runtime.d.ts +23 -0
  178. package/dist/providers/cursor/direct-runtime.js +111 -0
  179. package/dist/providers/cursor/direct-stream.d.ts +28 -0
  180. package/dist/providers/cursor/direct-stream.js +190 -0
  181. package/dist/providers/cursor/exec-reply.d.ts +13 -0
  182. package/dist/providers/cursor/exec-reply.js +102 -0
  183. package/dist/providers/cursor/h2-bridge-response.d.ts +9 -0
  184. package/dist/providers/cursor/h2-bridge-response.js +51 -0
  185. package/dist/providers/cursor/h2-bridge-session.d.ts +24 -0
  186. package/dist/providers/cursor/h2-bridge-session.js +197 -0
  187. package/dist/providers/cursor/h2-bridge.d.ts +2 -0
  188. package/dist/providers/cursor/h2-bridge.js +12865 -0
  189. package/dist/providers/cursor/http2.d.ts +18 -0
  190. package/dist/providers/cursor/http2.js +144 -0
  191. package/dist/providers/cursor/interaction-reply.d.ts +6 -0
  192. package/dist/providers/cursor/interaction-reply.js +52 -0
  193. package/dist/providers/cursor/language-generate.d.ts +2 -0
  194. package/dist/providers/cursor/language-generate.js +35 -0
  195. package/dist/providers/cursor/language-model.d.ts +13 -0
  196. package/dist/providers/cursor/language-model.js +77 -0
  197. package/dist/providers/cursor/legacy-stream.d.ts +11 -0
  198. package/dist/providers/cursor/legacy-stream.js +115 -0
  199. package/dist/providers/cursor/mcp-tools.d.ts +7 -0
  200. package/dist/providers/cursor/mcp-tools.js +15 -0
  201. package/dist/providers/cursor/models.d.ts +14 -0
  202. package/dist/providers/cursor/models.js +116 -0
  203. package/dist/providers/cursor/ndjson.d.ts +3 -0
  204. package/dist/providers/cursor/ndjson.js +100 -0
  205. package/dist/providers/cursor/prompt.d.ts +4 -0
  206. package/dist/providers/cursor/prompt.js +142 -0
  207. package/dist/providers/cursor/proto/checkpoint.d.ts +35 -0
  208. package/dist/providers/cursor/proto/checkpoint.js +114 -0
  209. package/dist/providers/cursor/proto/context.d.ts +64 -0
  210. package/dist/providers/cursor/proto/context.js +178 -0
  211. package/dist/providers/cursor/proto/errors.d.ts +16 -0
  212. package/dist/providers/cursor/proto/errors.js +26 -0
  213. package/dist/providers/cursor/proto/exec-control.d.ts +20 -0
  214. package/dist/providers/cursor/proto/exec-control.js +54 -0
  215. package/dist/providers/cursor/proto/exec.d.ts +47 -0
  216. package/dist/providers/cursor/proto/exec.js +154 -0
  217. package/dist/providers/cursor/proto/fields.d.ts +22 -0
  218. package/dist/providers/cursor/proto/fields.js +97 -0
  219. package/dist/providers/cursor/proto/interaction-query.d.ts +15 -0
  220. package/dist/providers/cursor/proto/interaction-query.js +79 -0
  221. package/dist/providers/cursor/proto/interaction-tool-update.d.ts +10 -0
  222. package/dist/providers/cursor/proto/interaction-tool-update.js +58 -0
  223. package/dist/providers/cursor/proto/interaction-turn-ended.d.ts +6 -0
  224. package/dist/providers/cursor/proto/interaction-turn-ended.js +18 -0
  225. package/dist/providers/cursor/proto/interaction.d.ts +65 -0
  226. package/dist/providers/cursor/proto/interaction.js +185 -0
  227. package/dist/providers/cursor/proto/kv.d.ts +25 -0
  228. package/dist/providers/cursor/proto/kv.js +109 -0
  229. package/dist/providers/cursor/proto/mcp-result.d.ts +40 -0
  230. package/dist/providers/cursor/proto/mcp-result.js +150 -0
  231. package/dist/providers/cursor/proto/mcp.d.ts +19 -0
  232. package/dist/providers/cursor/proto/mcp.js +78 -0
  233. package/dist/providers/cursor/proto/model.d.ts +11 -0
  234. package/dist/providers/cursor/proto/model.js +36 -0
  235. package/dist/providers/cursor/proto/output-location.d.ts +7 -0
  236. package/dist/providers/cursor/proto/output-location.js +53 -0
  237. package/dist/providers/cursor/proto/prewarm.d.ts +16 -0
  238. package/dist/providers/cursor/proto/prewarm.js +68 -0
  239. package/dist/providers/cursor/proto/request-context.d.ts +16 -0
  240. package/dist/providers/cursor/proto/request-context.js +58 -0
  241. package/dist/providers/cursor/proto/request.d.ts +44 -0
  242. package/dist/providers/cursor/proto/request.js +111 -0
  243. package/dist/providers/cursor/proto/run-request.d.ts +19 -0
  244. package/dist/providers/cursor/proto/run-request.js +68 -0
  245. package/dist/providers/cursor/proto/server.d.ts +35 -0
  246. package/dist/providers/cursor/proto/server.js +93 -0
  247. package/dist/providers/cursor/proto/unknown-field.d.ts +1 -0
  248. package/dist/providers/cursor/proto/unknown-field.js +22 -0
  249. package/dist/providers/cursor/proto-value.d.ts +3 -0
  250. package/dist/providers/cursor/proto-value.js +170 -0
  251. package/dist/providers/cursor/proto-wire.d.ts +22 -0
  252. package/dist/providers/cursor/proto-wire.js +224 -0
  253. package/dist/providers/cursor/protocol-failure.d.ts +18 -0
  254. package/dist/providers/cursor/protocol-failure.js +45 -0
  255. package/dist/providers/cursor/recovery.d.ts +48 -0
  256. package/dist/providers/cursor/recovery.js +102 -0
  257. package/dist/providers/cursor/request-blob-ownership.d.ts +15 -0
  258. package/dist/providers/cursor/request-blob-ownership.js +39 -0
  259. package/dist/providers/cursor/request-build.d.ts +18 -0
  260. package/dist/providers/cursor/request-build.js +123 -0
  261. package/dist/providers/cursor/request-history.d.ts +32 -0
  262. package/dist/providers/cursor/request-history.js +163 -0
  263. package/dist/providers/cursor/request-input.d.ts +75 -0
  264. package/dist/providers/cursor/request-input.js +123 -0
  265. package/dist/providers/cursor/run-events.d.ts +15 -0
  266. package/dist/providers/cursor/run-events.js +43 -0
  267. package/dist/providers/cursor/run-session-expiry.d.ts +15 -0
  268. package/dist/providers/cursor/run-session-expiry.js +21 -0
  269. package/dist/providers/cursor/run-session.d.ts +50 -0
  270. package/dist/providers/cursor/run-session.js +205 -0
  271. package/dist/providers/cursor/run.d.ts +9 -0
  272. package/dist/providers/cursor/run.js +151 -0
  273. package/dist/providers/cursor/runner.d.ts +1 -0
  274. package/dist/providers/cursor/runner.js +55 -0
  275. package/dist/providers/cursor/server-dispatch-types.d.ts +83 -0
  276. package/dist/providers/cursor/server-dispatch-types.js +1 -0
  277. package/dist/providers/cursor/server-dispatch.d.ts +3 -0
  278. package/dist/providers/cursor/server-dispatch.js +178 -0
  279. package/dist/providers/cursor/session-state.d.ts +21 -0
  280. package/dist/providers/cursor/session-state.js +118 -0
  281. package/dist/providers/cursor/session.d.ts +1 -0
  282. package/dist/providers/cursor/session.js +26 -0
  283. package/dist/providers/cursor/settle-cleanup.d.ts +1 -0
  284. package/dist/providers/cursor/settle-cleanup.js +11 -0
  285. package/dist/providers/cursor/stream-adapter.d.ts +17 -0
  286. package/dist/providers/cursor/stream-adapter.js +99 -0
  287. package/dist/providers/cursor/tool-continuation.d.ts +14 -0
  288. package/dist/providers/cursor/tool-continuation.js +134 -0
  289. package/dist/providers/cursor/tool-stream.d.ts +2 -0
  290. package/dist/providers/cursor/tool-stream.js +220 -0
  291. package/dist/providers/cursor/usage.d.ts +3 -0
  292. package/dist/providers/cursor/usage.js +35 -0
  293. package/dist/providers/ollama/adapter.d.ts +8 -0
  294. package/dist/providers/ollama/adapter.js +65 -0
  295. package/dist/providers/ollama/catalog-state.d.ts +17 -0
  296. package/dist/providers/ollama/catalog-state.js +40 -0
  297. package/dist/providers/ollama/cloud-catalog.d.ts +3 -0
  298. package/dist/providers/ollama/cloud-catalog.js +82 -0
  299. package/dist/providers/ollama/errors.d.ts +14 -0
  300. package/dist/providers/ollama/errors.js +19 -0
  301. package/dist/providers/ollama/generate.d.ts +2 -0
  302. package/dist/providers/ollama/generate.js +49 -0
  303. package/dist/providers/ollama/html-links.d.ts +1 -0
  304. package/dist/providers/ollama/html-links.js +30 -0
  305. package/dist/providers/ollama/http.d.ts +12 -0
  306. package/dist/providers/ollama/http.js +67 -0
  307. package/dist/providers/ollama/index.d.ts +8 -0
  308. package/dist/providers/ollama/index.js +8 -0
  309. package/dist/providers/ollama/language-model.d.ts +11 -0
  310. package/dist/providers/ollama/language-model.js +62 -0
  311. package/dist/providers/ollama/local-catalog.d.ts +3 -0
  312. package/dist/providers/ollama/local-catalog.js +38 -0
  313. package/dist/providers/ollama/ndjson.d.ts +3 -0
  314. package/dist/providers/ollama/ndjson.js +51 -0
  315. package/dist/providers/ollama/prompt.d.ts +8 -0
  316. package/dist/providers/ollama/prompt.js +141 -0
  317. package/dist/providers/ollama/protocol.d.ts +56 -0
  318. package/dist/providers/ollama/protocol.js +26 -0
  319. package/dist/providers/ollama/runtime.d.ts +11 -0
  320. package/dist/providers/ollama/runtime.js +128 -0
  321. package/dist/providers/ollama/stream.d.ts +8 -0
  322. package/dist/providers/ollama/stream.js +110 -0
  323. package/dist/sdk/command-code.d.ts +5 -0
  324. package/dist/sdk/command-code.js +6 -0
  325. package/dist/sdk/cursor.d.ts +5 -0
  326. package/dist/sdk/cursor.js +6 -0
  327. package/dist/sdk/ollama.d.ts +5 -0
  328. package/dist/sdk/ollama.js +6 -0
  329. package/dist/server.d.ts +12 -0
  330. package/dist/server.js +94 -0
  331. package/docs/README.ko.md +189 -0
  332. package/package.json +75 -0
@@ -0,0 +1,22 @@
1
+ // Derived from Rahularya01/pi-cursor src/auth/cli-credentials.ts.
2
+ // Licensed under MIT. See THIRD_PARTY_NOTICES.md.
3
+ function stringField(value, key) {
4
+ if (!(key in value)) {
5
+ return null;
6
+ }
7
+ const field = Reflect.get(value, key);
8
+ return typeof field === "string" && field.length > 0 ? field : null;
9
+ }
10
+ export function parseCursorCredentials(value) {
11
+ if (typeof value !== "object" || value === null) {
12
+ return null;
13
+ }
14
+ const accessToken = stringField(value, "accessToken");
15
+ if (accessToken === null) {
16
+ return null;
17
+ }
18
+ return {
19
+ accessToken,
20
+ refreshToken: stringField(value, "refreshToken"),
21
+ };
22
+ }
@@ -0,0 +1,33 @@
1
+ import type { LanguageModelV3CallOptions } from "@ai-sdk/provider";
2
+ import type { Clock } from "../../core/clock";
3
+ import type { CursorBridgeClient } from "./bridge-client";
4
+ import type { CursorCheckpointStore } from "./checkpoint-store";
5
+ import type { CursorMcpTool } from "./mcp-tools";
6
+ import type { CursorRequestBlobOwnership } from "./request-blob-ownership";
7
+ import type { CursorRunSessionRegistry } from "./run-session";
8
+ import type { CursorSessionId, CursorSessionStateStore } from "./session-state";
9
+ export type CursorDirectSetupCleanupResources = {
10
+ readonly checkpointStore: CursorCheckpointStore;
11
+ readonly ownership: CursorRequestBlobOwnership;
12
+ readonly sessionId: CursorSessionId;
13
+ readonly sessionStore: CursorSessionStateStore;
14
+ };
15
+ export type CursorDirectSetupCleanup = {
16
+ readonly releaseOwnership: () => void;
17
+ readonly invalidateCheckpoint: () => void;
18
+ readonly invalidateSession: () => void;
19
+ };
20
+ export type CursorDirectRunOptions = {
21
+ readonly bridge: CursorBridgeClient;
22
+ readonly call: LanguageModelV3CallOptions;
23
+ readonly clock: Clock;
24
+ readonly createId: () => string;
25
+ readonly createSetupCleanup?: (resources: CursorDirectSetupCleanupResources) => CursorDirectSetupCleanup;
26
+ readonly idleTimeoutMs: number;
27
+ readonly modelId: string;
28
+ readonly registry: CursorRunSessionRegistry;
29
+ readonly signal: AbortSignal;
30
+ readonly token: string;
31
+ readonly tools: readonly CursorMcpTool[];
32
+ readonly ttlMs: number;
33
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { CursorDirectRunOptions } from "./direct-run-types";
2
+ import { type CursorStreamAdapter } from "./stream-adapter";
3
+ export declare function startCursorDirectRun(options: CursorDirectRunOptions): Promise<{
4
+ readonly stream: CursorStreamAdapter["stream"];
5
+ }>;
@@ -0,0 +1,213 @@
1
+ import { OperationCancelledError } from "../../core/errors";
2
+ import { parseModelId } from "../../core/ids";
3
+ import { createCursorBlobStore } from "./blob-store";
4
+ import { createCursorCheckpointStore } from "./checkpoint-store";
5
+ import { encodeConnectFrame } from "./connect-frame";
6
+ import { consumeCursorDirectAttempt, isCursorRetryableStreamError } from "./direct-stream";
7
+ import { cursorMcpDefinitions } from "./exec-reply";
8
+ import { cursorPromptText } from "./prompt";
9
+ import { createCursorIdleWatchdog, createCursorRecoveryPlanner } from "./recovery";
10
+ import { buildCursorAgentRunRequest } from "./request-build";
11
+ import { createCursorServerDispatcher } from "./server-dispatch";
12
+ import { createCursorSessionStateStore, parseCursorSessionId } from "./session-state";
13
+ import { settleCursorCleanup } from "./settle-cleanup";
14
+ import { createCursorStreamAdapter } from "./stream-adapter";
15
+ const CURSOR_RUN_PATH = "/agent.v1.AgentService/Run";
16
+ function createLogicalRun(options) {
17
+ const sessionId = parseCursorSessionId(options.createId());
18
+ const blobStore = createCursorBlobStore({
19
+ clock: options.clock,
20
+ maxBytes: 16_777_216,
21
+ maxEntries: 1_024,
22
+ ttlMs: options.ttlMs,
23
+ });
24
+ const checkpointStore = createCursorCheckpointStore({
25
+ blobStore,
26
+ clock: options.clock,
27
+ maxBytes: 8_388_608,
28
+ maxEntries: 4,
29
+ ttlMs: options.ttlMs,
30
+ });
31
+ const sessionStore = createCursorSessionStateStore({
32
+ blobStore,
33
+ clock: options.clock,
34
+ maxKeysPerSession: 128,
35
+ maxSessions: 4,
36
+ ttlMs: options.ttlMs,
37
+ });
38
+ const placeholder = buildRequest(options, { blobStore, checkpointStore, sessionId }, "initial");
39
+ const cleanup = options.createSetupCleanup?.({
40
+ checkpointStore,
41
+ ownership: placeholder.ownership,
42
+ sessionId,
43
+ sessionStore,
44
+ }) ?? {
45
+ releaseOwnership: placeholder.ownership.release,
46
+ invalidateCheckpoint: () => checkpointStore.invalidate(sessionId),
47
+ invalidateSession: () => sessionStore.invalidate(sessionId),
48
+ };
49
+ placeholder.ownership.release();
50
+ return { adapter: createCursorStreamAdapter(), blobStore, checkpointStore, cleanup, sessionId };
51
+ }
52
+ function buildRequest(options, logical, mode) {
53
+ const common = {
54
+ conversationId: logical.sessionId,
55
+ history: [],
56
+ rootSystemPrompt: "",
57
+ mcpTools: cursorMcpDefinitions(options.tools),
58
+ modelId: parseModelId(options.modelId),
59
+ modelParameters: [],
60
+ };
61
+ return buildCursorAgentRunRequest({
62
+ blobStore: logical.blobStore,
63
+ checkpointStore: logical.checkpointStore,
64
+ createId: options.createId,
65
+ input: mode === "checkpoint"
66
+ ? {
67
+ ...common,
68
+ mode: "checkpoint",
69
+ sessionId: logical.sessionId,
70
+ action: { kind: "resume" },
71
+ }
72
+ : {
73
+ ...common,
74
+ mode: "fresh",
75
+ action: { kind: "user", text: cursorPromptText(options.call), images: [] },
76
+ },
77
+ });
78
+ }
79
+ async function openAttempt(options, logical, mode) {
80
+ const request = buildRequest(options, logical, mode);
81
+ let stream = null;
82
+ try {
83
+ stream = await options.bridge.open({
84
+ id: options.createId(),
85
+ accessToken: options.token,
86
+ path: CURSOR_RUN_PATH,
87
+ headers: { "content-type": "application/connect+proto", "connect-protocol-version": "1" },
88
+ signal: options.signal,
89
+ });
90
+ if (options.signal.aborted)
91
+ throw new OperationCancelledError("cursor-direct-stream");
92
+ await stream.write(encodeConnectFrame(request.bytes), options.signal);
93
+ if (options.signal.aborted)
94
+ throw new OperationCancelledError("cursor-direct-stream");
95
+ return options.registry.register({
96
+ sessionId: logical.sessionId,
97
+ modelId: options.modelId,
98
+ stream,
99
+ ownership: request.ownership,
100
+ dispatcher: createCursorServerDispatcher({
101
+ blobStore: logical.blobStore,
102
+ checkpointStore: logical.checkpointStore,
103
+ sessionId: logical.sessionId,
104
+ tools: options.tools,
105
+ }),
106
+ disposeStores: () => {
107
+ logical.cleanup.invalidateCheckpoint();
108
+ logical.cleanup.invalidateSession();
109
+ },
110
+ });
111
+ }
112
+ catch (error) {
113
+ try {
114
+ await settleCursorCleanup([
115
+ ...(stream === null ? [] : [stream.abort]),
116
+ request.ownership.release,
117
+ ]);
118
+ }
119
+ catch (cleanupError) {
120
+ const message = error instanceof Error ? error.message : "Cursor setup failed";
121
+ throw new AggregateError([error, cleanupError], message);
122
+ }
123
+ throw error;
124
+ }
125
+ }
126
+ async function failRun(logical, session, error) {
127
+ try {
128
+ if (session === null) {
129
+ logical.cleanup.invalidateCheckpoint();
130
+ logical.cleanup.invalidateSession();
131
+ }
132
+ else
133
+ await session.abort();
134
+ }
135
+ catch (cleanupError) {
136
+ logical.adapter.fail(new AggregateError([error, cleanupError], "Cursor recovery cleanup failed"));
137
+ return;
138
+ }
139
+ logical.adapter.fail(error);
140
+ }
141
+ export async function startCursorDirectRun(options) {
142
+ const logical = createLogicalRun(options);
143
+ const planner = createCursorRecoveryPlanner();
144
+ let session;
145
+ try {
146
+ session = await openAttempt(options, logical, "initial");
147
+ }
148
+ catch (error) {
149
+ logical.cleanup.releaseOwnership();
150
+ logical.cleanup.invalidateCheckpoint();
151
+ logical.cleanup.invalidateSession();
152
+ throw error;
153
+ }
154
+ void (async () => {
155
+ for (;;) {
156
+ const watchdog = createCursorIdleWatchdog({
157
+ clock: options.clock,
158
+ idleTimeoutMs: options.idleTimeoutMs,
159
+ parentSignal: options.signal,
160
+ });
161
+ try {
162
+ const exit = await consumeCursorDirectAttempt({
163
+ session,
164
+ signal: watchdog.signal,
165
+ watchdog,
166
+ adapter: logical.adapter,
167
+ });
168
+ watchdog.dispose();
169
+ if (exit.kind === "terminal")
170
+ await options.registry.terminate(session.identity);
171
+ else
172
+ session.touch();
173
+ logical.adapter.finish(exit.kind === "parked" ? "tool-calls" : "stop");
174
+ return;
175
+ }
176
+ catch (error) {
177
+ const idle = watchdog.expired();
178
+ watchdog.dispose();
179
+ if (options.signal.aborted) {
180
+ await failRun(logical, session, new OperationCancelledError("cursor-direct-stream"));
181
+ return;
182
+ }
183
+ const decision = planner.next({
184
+ checkpointAvailable: logical.checkpointStore.resume(logical.sessionId) !== null,
185
+ replay: logical.adapter.replayState(),
186
+ retryable: idle || isCursorRetryableStreamError(error),
187
+ });
188
+ if (decision.kind === "fail") {
189
+ try {
190
+ planner.requireRetry(decision, error);
191
+ }
192
+ catch (recoveryError) {
193
+ await failRun(logical, session, recoveryError);
194
+ }
195
+ return;
196
+ }
197
+ try {
198
+ const retireForRetry = session.retireForRetry;
199
+ if (retireForRetry === undefined)
200
+ throw new TypeError("retry retirement is unavailable");
201
+ await retireForRetry();
202
+ logical.adapter.suspendForRetry();
203
+ session = await openAttempt(options, logical, decision.mode);
204
+ }
205
+ catch (retryError) {
206
+ await failRun(logical, session, retryError);
207
+ return;
208
+ }
209
+ }
210
+ }
211
+ })();
212
+ return { stream: logical.adapter.stream };
213
+ }
@@ -0,0 +1,23 @@
1
+ import type { LanguageModelV3CallOptions, LanguageModelV3StreamPart } from "@ai-sdk/provider";
2
+ import type { Clock } from "../../core/clock";
3
+ import { type CursorBridgeClient } from "./bridge-client";
4
+ import type { CursorDirectSetupCleanup, CursorDirectSetupCleanupResources } from "./direct-run-types";
5
+ import type { CursorRunSessionBackgroundCleanupErrorHandler } from "./run-session-expiry";
6
+ export type { CursorDirectSetupCleanup, CursorDirectSetupCleanupResources, } from "./direct-run-types";
7
+ export type CursorDirectRuntimeOptions = {
8
+ readonly clock: Clock;
9
+ readonly readAccessToken: (signal: AbortSignal) => Promise<string | null>;
10
+ readonly onBackgroundCleanupError: CursorRunSessionBackgroundCleanupErrorHandler;
11
+ readonly createBridgeClient?: (signal: AbortSignal) => Promise<CursorBridgeClient>;
12
+ readonly createId?: () => string;
13
+ readonly ttlMs?: number;
14
+ readonly idleTimeoutMs?: number;
15
+ readonly createSetupCleanup?: (resources: CursorDirectSetupCleanupResources) => CursorDirectSetupCleanup;
16
+ };
17
+ export type CursorDirectRuntime = {
18
+ readonly doStream: (call: LanguageModelV3CallOptions, modelId: string) => Promise<{
19
+ readonly stream: ReadableStream<LanguageModelV3StreamPart>;
20
+ }>;
21
+ readonly dispose: () => Promise<void>;
22
+ };
23
+ export declare function createCursorDirectRuntime(options: CursorDirectRuntimeOptions): CursorDirectRuntime;
@@ -0,0 +1,111 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { AdapterError, OperationCancelledError } from "../../core/errors";
3
+ import { parseProviderId } from "../../core/ids";
4
+ import { createAsyncDisposable } from "../../core/lifecycle";
5
+ import { createCursorBridgeClient } from "./bridge-client";
6
+ import { startCursorDirectRun } from "./direct-run";
7
+ import { consumeCursorDirectSession } from "./direct-stream";
8
+ import { createCursorRunSessionRegistry } from "./run-session";
9
+ import { settleCursorCleanup } from "./settle-cleanup";
10
+ import { buildCursorToolContinuations } from "./tool-continuation";
11
+ function toolsFromCall(call) {
12
+ return (call.tools ?? [])
13
+ .filter((tool) => tool.type === "function")
14
+ .map((tool) => ({
15
+ name: tool.name,
16
+ description: tool.description ?? "",
17
+ inputSchema: tool.inputSchema,
18
+ }));
19
+ }
20
+ function cursorFailure(operation) {
21
+ return new AdapterError({
22
+ operation,
23
+ retryable: false,
24
+ cause: null,
25
+ providerId: parseProviderId("cursor"),
26
+ });
27
+ }
28
+ export function createCursorDirectRuntime(options) {
29
+ const lifecycle = new AbortController();
30
+ const createId = options.createId ?? randomUUID;
31
+ const registry = createCursorRunSessionRegistry({
32
+ clock: options.clock,
33
+ ttlMs: options.ttlMs ?? 300_000,
34
+ onBackgroundCleanupError: options.onBackgroundCleanupError,
35
+ });
36
+ let bridgeClient = null;
37
+ const bridge = () => {
38
+ bridgeClient ??=
39
+ options.createBridgeClient?.(lifecycle.signal) ??
40
+ createCursorBridgeClient({ signal: lifecycle.signal });
41
+ return bridgeClient;
42
+ };
43
+ const doStream = async (call, modelId) => {
44
+ const signal = call.abortSignal ?? new AbortController().signal;
45
+ if (signal.aborted)
46
+ throw new OperationCancelledError("cursor-direct-stream");
47
+ const resultCallIds = [];
48
+ for (let index = call.prompt.length - 1; index >= 0; index -= 1) {
49
+ const message = call.prompt[index];
50
+ if (message?.role !== "tool")
51
+ break;
52
+ resultCallIds.unshift(...message.content
53
+ .filter((part) => part.type === "tool-result")
54
+ .map((part) => part.toolCallId));
55
+ }
56
+ if (resultCallIds.length > 0) {
57
+ const existing = registry.resolveParkedCalls(resultCallIds, modelId);
58
+ const continuations = buildCursorToolContinuations(call.prompt, existing.dispatcher.parkedCalls);
59
+ await existing.writeContinuations(continuations, signal);
60
+ return { stream: await consumeCursorDirectSession({ session: existing, signal, registry }) };
61
+ }
62
+ const setup = new AbortController();
63
+ const cancel = () => {
64
+ if (!setup.signal.aborted) {
65
+ setup.abort(new OperationCancelledError("cursor-direct-stream"));
66
+ }
67
+ };
68
+ lifecycle.signal.addEventListener("abort", cancel, { once: true });
69
+ call.abortSignal?.addEventListener("abort", cancel, { once: true });
70
+ if (lifecycle.signal.aborted || signal.aborted)
71
+ cancel();
72
+ try {
73
+ const token = await options.readAccessToken(setup.signal);
74
+ if (setup.signal.aborted)
75
+ throw new OperationCancelledError("cursor-direct-stream");
76
+ if (token === null)
77
+ throw cursorFailure("cursor-auth-unavailable");
78
+ return await startCursorDirectRun({
79
+ bridge: await bridge(),
80
+ call,
81
+ clock: options.clock,
82
+ createId,
83
+ idleTimeoutMs: options.idleTimeoutMs ?? 60_000,
84
+ modelId,
85
+ registry,
86
+ signal,
87
+ token,
88
+ tools: toolsFromCall(call),
89
+ ttlMs: options.ttlMs ?? 300_000,
90
+ ...(options.createSetupCleanup === undefined
91
+ ? {}
92
+ : { createSetupCleanup: options.createSetupCleanup }),
93
+ });
94
+ }
95
+ finally {
96
+ lifecycle.signal.removeEventListener("abort", cancel);
97
+ call.abortSignal?.removeEventListener("abort", cancel);
98
+ }
99
+ };
100
+ const disposal = createAsyncDisposable(async () => {
101
+ lifecycle.abort();
102
+ await settleCursorCleanup([
103
+ registry.dispose,
104
+ async () => {
105
+ const client = await bridgeClient;
106
+ await client?.dispose();
107
+ },
108
+ ]);
109
+ });
110
+ return { doStream, dispose: disposal.dispose };
111
+ }
@@ -0,0 +1,28 @@
1
+ import type { CursorIdleWatchdog } from "./recovery";
2
+ import type { CursorRunSession, CursorRunSessionRegistry } from "./run-session";
3
+ import { type CursorStreamAdapter } from "./stream-adapter";
4
+ export { createConnectFrameStreamDecoder } from "./connect-frame-stream";
5
+ export type CursorDirectAttemptExit = {
6
+ readonly kind: "terminal";
7
+ } | {
8
+ readonly kind: "parked";
9
+ };
10
+ export declare function consumeCursorDirectAttempt(options: {
11
+ readonly session: CursorRunSession;
12
+ readonly signal: AbortSignal;
13
+ readonly watchdog: CursorIdleWatchdog;
14
+ readonly adapter: CursorStreamAdapter;
15
+ }): Promise<CursorDirectAttemptExit>;
16
+ export declare function consumeCursorDirectSession(options: {
17
+ readonly session: CursorRunSession;
18
+ readonly signal: AbortSignal;
19
+ readonly registry: CursorRunSessionRegistry;
20
+ }): Promise<CursorStreamAdapter["stream"]>;
21
+ export declare function isCursorRetryableStreamError(error: unknown): boolean;
22
+ export declare class CursorDirectStreamError extends Error {
23
+ readonly bridgeCode: string;
24
+ readonly bridgeMessage?: string | undefined;
25
+ readonly name = "CursorDirectStreamError";
26
+ readonly code = "CURSOR_DIRECT_STREAM_ERROR";
27
+ constructor(bridgeCode: string, bridgeMessage?: string | undefined);
28
+ }
@@ -0,0 +1,190 @@
1
+ import { createConnectFrameStreamDecoder, } from "./connect-frame-stream";
2
+ import { annotateCursorProtocolFailure } from "./protocol-failure";
3
+ import { createCursorStreamAdapter } from "./stream-adapter";
4
+ export { createConnectFrameStreamDecoder } from "./connect-frame-stream";
5
+ function finishConnectDecoder(decoder) {
6
+ try {
7
+ decoder.finish();
8
+ }
9
+ catch (error) {
10
+ annotateCursorProtocolFailure(error, "connect-frame");
11
+ }
12
+ }
13
+ function assertNoStranding(results, session) {
14
+ const stranded = results.find((result) => result.outcome.kind === "drift" && result.outcome.stranding);
15
+ if (stranded?.outcome.kind === "drift") {
16
+ session.dispatcher.parkedCalls.clear();
17
+ throw new CursorDirectStreamError(`stranding-drift:${stranded.outcome.detail}`);
18
+ }
19
+ }
20
+ async function applyDispatch(options) {
21
+ for (const reply of options.result.replyFrames) {
22
+ await options.session.write(reply, options.signal);
23
+ }
24
+ const outcome = options.result.outcome;
25
+ if (outcome.kind === "heartbeat") {
26
+ options.watchdog.heartbeat();
27
+ return null;
28
+ }
29
+ options.watchdog.progress();
30
+ switch (outcome.kind) {
31
+ case "text":
32
+ case "thinking":
33
+ options.adapter.emit(outcome);
34
+ return null;
35
+ case "checkpoint":
36
+ if (outcome.stored)
37
+ options.adapter.noteCheckpoint();
38
+ return null;
39
+ case "turn-ended":
40
+ return { kind: "terminal" };
41
+ case "mcp-parked":
42
+ options.adapter.emit(outcome);
43
+ options.watchdog.park();
44
+ return { kind: "parked" };
45
+ case "control":
46
+ throw new CursorDirectStreamError("server-abort");
47
+ case "drift":
48
+ if (outcome.stranding)
49
+ throw new CursorDirectStreamError("stranding-drift");
50
+ return null;
51
+ default:
52
+ return null;
53
+ }
54
+ }
55
+ export async function consumeCursorDirectAttempt(options) {
56
+ const decoder = createConnectFrameStreamDecoder();
57
+ let terminalSeen = false;
58
+ for (;;) {
59
+ const event = await options.session.stream.nextEvent(options.signal);
60
+ if (event.kind === "error")
61
+ throw new CursorDirectStreamError(event.code, event.message);
62
+ if (event.kind === "headers" && (event.status < 200 || event.status >= 300)) {
63
+ throw new CursorDirectStreamError(`http-${event.status}`);
64
+ }
65
+ if (event.kind === "trailers") {
66
+ const status = event.headers["connect-status"];
67
+ if (status !== undefined && status !== "0") {
68
+ throw new CursorDirectStreamError(`connect-status-${status}`);
69
+ }
70
+ terminalSeen = status === "0" || terminalSeen;
71
+ continue;
72
+ }
73
+ if (event.kind === "end") {
74
+ finishConnectDecoder(decoder);
75
+ if (!terminalSeen)
76
+ throw new CursorDirectStreamError("premature-end");
77
+ return { kind: "terminal" };
78
+ }
79
+ if (event.kind !== "data")
80
+ continue;
81
+ let frames;
82
+ try {
83
+ frames = decoder.push(event.payload);
84
+ }
85
+ catch (error) {
86
+ annotateCursorProtocolFailure(error, "connect-frame");
87
+ }
88
+ let results;
89
+ try {
90
+ results = frames
91
+ .filter((frame) => frame.kind === "message")
92
+ .map((frame) => options.session.dispatcher.dispatchBytes(frame.bytes));
93
+ }
94
+ catch (error) {
95
+ annotateCursorProtocolFailure(error, "server-dispatch");
96
+ }
97
+ assertNoStranding(results, options.session);
98
+ for (const [index, frame] of frames.entries()) {
99
+ if (frame.kind === "end") {
100
+ if (frame.error !== null) {
101
+ throw new CursorDirectStreamError(frame.error.code, frame.error.message);
102
+ }
103
+ terminalSeen = true;
104
+ continue;
105
+ }
106
+ const result = results.shift();
107
+ if (result === undefined)
108
+ throw new CursorDirectStreamError("missing-dispatch-result");
109
+ const exit = await applyDispatch({ ...options, result });
110
+ if (exit?.kind === "terminal") {
111
+ if (index !== frames.length - 1) {
112
+ const trailingFrame = frames.at(index + 1);
113
+ if (frames.length - index !== 2 || trailingFrame?.kind !== "end") {
114
+ throw new CursorDirectStreamError("trailing-frame-after-turn-ended");
115
+ }
116
+ if (trailingFrame.error !== null) {
117
+ throw new CursorDirectStreamError(trailingFrame.error.code, trailingFrame.error.message);
118
+ }
119
+ }
120
+ finishConnectDecoder(decoder);
121
+ return exit;
122
+ }
123
+ if (exit !== null)
124
+ return exit;
125
+ }
126
+ if (terminalSeen)
127
+ return { kind: "terminal" };
128
+ }
129
+ }
130
+ export async function consumeCursorDirectSession(options) {
131
+ const adapter = createCursorStreamAdapter();
132
+ const watchdog = {
133
+ signal: options.signal,
134
+ expired: () => false,
135
+ progress: () => undefined,
136
+ heartbeat: () => undefined,
137
+ park: () => undefined,
138
+ dispose: () => undefined,
139
+ };
140
+ void consumeCursorDirectAttempt({ ...options, watchdog, adapter }).then(async (exit) => {
141
+ if (exit.kind === "terminal")
142
+ await options.registry.terminate(options.session.identity);
143
+ else
144
+ options.session.touch();
145
+ adapter.finish(exit.kind === "parked" ? "tool-calls" : "stop");
146
+ }, async (error) => {
147
+ try {
148
+ await options.session.abort();
149
+ }
150
+ catch (cleanupError) {
151
+ adapter.fail(new AggregateError([error, cleanupError], "Cursor direct stream failure and abort cleanup failure"));
152
+ return;
153
+ }
154
+ adapter.fail(error);
155
+ });
156
+ return adapter.stream;
157
+ }
158
+ export function isCursorRetryableStreamError(error) {
159
+ if (!(error instanceof CursorDirectStreamError))
160
+ return false;
161
+ if (error.bridgeCode === "premature-end")
162
+ return true;
163
+ if ([
164
+ "stream-error",
165
+ "stream-unavailable",
166
+ "session-error",
167
+ "session-goaway",
168
+ "session-ping-error",
169
+ ].includes(error.bridgeCode))
170
+ return true;
171
+ if (error.bridgeCode.startsWith("http-")) {
172
+ const status = Number(error.bridgeCode.slice(5));
173
+ return status === 408 || status === 429 || status >= 500;
174
+ }
175
+ if (error.bridgeCode.startsWith("connect-status-")) {
176
+ return ["4", "8", "13", "14"].includes(error.bridgeCode.slice(15));
177
+ }
178
+ return false;
179
+ }
180
+ export class CursorDirectStreamError extends Error {
181
+ bridgeCode;
182
+ bridgeMessage;
183
+ name = "CursorDirectStreamError";
184
+ code = "CURSOR_DIRECT_STREAM_ERROR";
185
+ constructor(bridgeCode, bridgeMessage) {
186
+ super(bridgeMessage ?? "Cursor direct stream failed");
187
+ this.bridgeCode = bridgeCode;
188
+ this.bridgeMessage = bridgeMessage;
189
+ }
190
+ }
@@ -0,0 +1,13 @@
1
+ import type { CursorMcpTool } from "./mcp-tools";
2
+ import type { ExecServerMessage } from "./proto/exec";
3
+ import type { McpToolDefinition } from "./proto/mcp";
4
+ import { type AgentClientMessage } from "./proto/request";
5
+ export declare function cursorMcpDefinitions(tools: readonly CursorMcpTool[]): readonly McpToolDefinition[];
6
+ export declare function encodeCursorClientFrame(message: AgentClientMessage): Uint8Array;
7
+ export declare function encodeRequestContextFrame(message: Extract<ExecServerMessage, {
8
+ readonly kind: "request-context-args";
9
+ }>, tools: readonly CursorMcpTool[]): Uint8Array;
10
+ export declare function encodeNativeRejectFrame(message: Extract<ExecServerMessage, {
11
+ readonly kind: "native";
12
+ }>): Uint8Array;
13
+ export declare function cursorServerReplies(bytes: Uint8Array, tools: readonly CursorMcpTool[]): readonly Uint8Array[];