@code-yeongyu/senpi-ai 2026.8.18 → 2026.8.19

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 (139) hide show
  1. package/README.md +5 -3
  2. package/dist/api/anthropic-messages.d.ts +7 -1
  3. package/dist/api/anthropic-messages.d.ts.map +1 -1
  4. package/dist/api/anthropic-messages.js +21 -4
  5. package/dist/api/anthropic-messages.js.map +1 -1
  6. package/dist/api/azure-openai-responses.d.ts +2 -0
  7. package/dist/api/azure-openai-responses.d.ts.map +1 -1
  8. package/dist/api/azure-openai-responses.js +7 -1
  9. package/dist/api/azure-openai-responses.js.map +1 -1
  10. package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  11. package/dist/api/bedrock-converse-stream.js +39 -2
  12. package/dist/api/bedrock-converse-stream.js.map +1 -1
  13. package/dist/api/cursor-agent/gen/agent_pb.d.ts +22 -1
  14. package/dist/api/cursor-agent/gen/agent_pb.d.ts.map +1 -1
  15. package/dist/api/cursor-agent/gen/agent_pb.js +1 -1
  16. package/dist/api/cursor-agent/gen/agent_pb.js.map +1 -1
  17. package/dist/api/cursor-agent/reasoning-params.d.ts +20 -0
  18. package/dist/api/cursor-agent/reasoning-params.d.ts.map +1 -0
  19. package/dist/api/cursor-agent/reasoning-params.js +26 -0
  20. package/dist/api/cursor-agent/reasoning-params.js.map +1 -0
  21. package/dist/api/cursor-agent/types.d.ts +7 -1
  22. package/dist/api/cursor-agent/types.d.ts.map +1 -1
  23. package/dist/api/cursor-agent/types.js.map +1 -1
  24. package/dist/api/cursor-agent.d.ts +5 -3
  25. package/dist/api/cursor-agent.d.ts.map +1 -1
  26. package/dist/api/cursor-agent.js +82 -12
  27. package/dist/api/cursor-agent.js.map +1 -1
  28. package/dist/api/google-generative-ai.d.ts +2 -2
  29. package/dist/api/google-generative-ai.d.ts.map +1 -1
  30. package/dist/api/google-generative-ai.js +14 -11
  31. package/dist/api/google-generative-ai.js.map +1 -1
  32. package/dist/api/google-shared.d.ts +5 -2
  33. package/dist/api/google-shared.d.ts.map +1 -1
  34. package/dist/api/google-shared.js +16 -0
  35. package/dist/api/google-shared.js.map +1 -1
  36. package/dist/api/google-vertex.d.ts +2 -2
  37. package/dist/api/google-vertex.d.ts.map +1 -1
  38. package/dist/api/google-vertex.js +13 -10
  39. package/dist/api/google-vertex.js.map +1 -1
  40. package/dist/api/mistral-conversations.d.ts.map +1 -1
  41. package/dist/api/mistral-conversations.js +4 -1
  42. package/dist/api/mistral-conversations.js.map +1 -1
  43. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  44. package/dist/api/openai-codex-responses.js +4 -1
  45. package/dist/api/openai-codex-responses.js.map +1 -1
  46. package/dist/api/openai-completions.d.ts +1 -1
  47. package/dist/api/openai-completions.d.ts.map +1 -1
  48. package/dist/api/openai-completions.js +45 -29
  49. package/dist/api/openai-completions.js.map +1 -1
  50. package/dist/api/openai-responses.d.ts.map +1 -1
  51. package/dist/api/openai-responses.js +8 -1
  52. package/dist/api/openai-responses.js.map +1 -1
  53. package/dist/api/pi-messages.js +1 -1
  54. package/dist/api/pi-messages.js.map +1 -1
  55. package/dist/api/simple-options.d.ts +4 -0
  56. package/dist/api/simple-options.d.ts.map +1 -1
  57. package/dist/api/simple-options.js +18 -9
  58. package/dist/api/simple-options.js.map +1 -1
  59. package/dist/auth/oauth/device-code.d.ts +1 -0
  60. package/dist/auth/oauth/device-code.d.ts.map +1 -1
  61. package/dist/auth/oauth/device-code.js +1 -1
  62. package/dist/auth/oauth/device-code.js.map +1 -1
  63. package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  64. package/dist/auth/oauth/github-copilot.js +22 -9
  65. package/dist/auth/oauth/github-copilot.js.map +1 -1
  66. package/dist/cursor/catalog-grouping.d.ts +25 -0
  67. package/dist/cursor/catalog-grouping.d.ts.map +1 -0
  68. package/dist/cursor/catalog-grouping.js +134 -0
  69. package/dist/cursor/catalog-grouping.js.map +1 -0
  70. package/dist/cursor/cursor-variant-aliases.json +1893 -0
  71. package/dist/cursor/model-capabilities.d.ts +47 -0
  72. package/dist/cursor/model-capabilities.d.ts.map +1 -0
  73. package/dist/cursor/model-capabilities.js +208 -0
  74. package/dist/cursor/model-capabilities.js.map +1 -0
  75. package/dist/cursor/selection-descriptor.d.ts +21 -0
  76. package/dist/cursor/selection-descriptor.d.ts.map +1 -0
  77. package/dist/cursor/selection-descriptor.js +83 -0
  78. package/dist/cursor/selection-descriptor.js.map +1 -0
  79. package/dist/cursor/store-migration.d.ts +8 -0
  80. package/dist/cursor/store-migration.d.ts.map +1 -0
  81. package/dist/cursor/store-migration.js +76 -0
  82. package/dist/cursor/store-migration.js.map +1 -0
  83. package/dist/index.d.ts +5 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +4 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/model.d.ts +13 -0
  88. package/dist/model.d.ts.map +1 -1
  89. package/dist/model.js.map +1 -1
  90. package/dist/models.d.ts +6 -0
  91. package/dist/models.d.ts.map +1 -1
  92. package/dist/models.js +9 -1
  93. package/dist/models.js.map +1 -1
  94. package/dist/providers/cursor.d.ts.map +1 -1
  95. package/dist/providers/cursor.js +40 -11
  96. package/dist/providers/cursor.js.map +1 -1
  97. package/dist/providers/data/.manifest.json +1 -1
  98. package/dist/providers/data/anthropic.json +1 -1
  99. package/dist/providers/data/baseten.json +1 -1
  100. package/dist/providers/data/github-copilot.json +1 -1
  101. package/dist/providers/data/openai-codex.json +1 -1
  102. package/dist/providers/data/openai.json +1 -1
  103. package/dist/providers/data/opencode-go.json +1 -1
  104. package/dist/providers/data/opencode.json +1 -1
  105. package/dist/providers/data/openrouter.json +1 -1
  106. package/dist/providers/data/qwen-token-plan-individual.json +1 -1
  107. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  108. package/dist/providers/data/xai.json +1 -1
  109. package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  110. package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  111. package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  112. package/dist/providers/data/xiaomi.json +1 -1
  113. package/dist/providers/data/zai-coding-cn.json +1 -1
  114. package/dist/providers/data/zai.json +1 -1
  115. package/dist/providers/xai.d.ts +1 -1
  116. package/dist/providers/xai.d.ts.map +1 -1
  117. package/dist/providers/xai.js +1 -5
  118. package/dist/providers/xai.js.map +1 -1
  119. package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +1 -1
  120. package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js +21 -1
  121. package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +1 -1
  122. package/dist/tool-call-middleware/recovery-message-snapshot.d.ts.map +1 -1
  123. package/dist/tool-call-middleware/recovery-message-snapshot.js +2 -1
  124. package/dist/tool-call-middleware/recovery-message-snapshot.js.map +1 -1
  125. package/dist/types.d.ts +45 -4
  126. package/dist/types.d.ts.map +1 -1
  127. package/dist/types.js.map +1 -1
  128. package/dist/utils/overflow.d.ts.map +1 -1
  129. package/dist/utils/overflow.js +15 -0
  130. package/dist/utils/overflow.js.map +1 -1
  131. package/dist/utils/pi-user-agent.d.ts +2 -0
  132. package/dist/utils/pi-user-agent.d.ts.map +1 -1
  133. package/dist/utils/pi-user-agent.js +7 -0
  134. package/dist/utils/pi-user-agent.js.map +1 -1
  135. package/dist/utils/prompt-cache-ttl.d.ts +2 -1
  136. package/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  137. package/dist/utils/prompt-cache-ttl.js +2 -0
  138. package/dist/utils/prompt-cache-ttl.js.map +1 -1
  139. package/package.json +2 -3
@@ -0,0 +1,20 @@
1
+ import { create } from "@bufbuild/protobuf";
2
+ import type { Model } from "../../model.ts";
3
+ import type { ThinkingSelection } from "../../types.ts";
4
+ import { RequestedModelSchema } from "./gen/agent_pb.ts";
5
+ /**
6
+ * Render the resolved Cursor selection into the protobuf `RequestedModel`
7
+ * fields: resolved wire id, maxMode, and ordered parameters. An absent
8
+ * selection yields the pre-grouping request shape (upstream id, no
9
+ * parameters) byte-for-byte.
10
+ */
11
+ export declare function buildRequestedModelFields(model: Model<"cursor-agent">, selection: ThinkingSelection | undefined): {
12
+ modelId: string;
13
+ maxMode: boolean;
14
+ parameters: {
15
+ id: string;
16
+ value: string;
17
+ }[];
18
+ };
19
+ export declare function buildRequestedModel(model: Model<"cursor-agent">, selection: ThinkingSelection | undefined): ReturnType<typeof create<typeof RequestedModelSchema>>;
20
+ //# sourceMappingURL=reasoning-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-params.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/reasoning-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAA4C,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEnG;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAC5B,SAAS,EAAE,iBAAiB,GAAG,SAAS,GACtC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAOpF;AAED,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,EAC5B,SAAS,EAAE,iBAAiB,GAAG,SAAS,GACtC,UAAU,CAAC,OAAO,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC,CASxD"}
@@ -0,0 +1,26 @@
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { resolveCursorSelectionDescriptor } from "../../cursor/selection-descriptor.js";
3
+ import { RequestedModel_ModelParameterbytesSchema, RequestedModelSchema } from "./gen/agent_pb.js";
4
+ /**
5
+ * Render the resolved Cursor selection into the protobuf `RequestedModel`
6
+ * fields: resolved wire id, maxMode, and ordered parameters. An absent
7
+ * selection yields the pre-grouping request shape (upstream id, no
8
+ * parameters) byte-for-byte.
9
+ */
10
+ export function buildRequestedModelFields(model, selection) {
11
+ const resolved = resolveCursorSelectionDescriptor(model, selection);
12
+ return {
13
+ modelId: resolved.modelId,
14
+ maxMode: model.compat?.cursorMaxMode === true,
15
+ parameters: resolved.parameters.map((parameter) => ({ id: parameter.id, value: parameter.value })),
16
+ };
17
+ }
18
+ export function buildRequestedModel(model, selection) {
19
+ const fields = buildRequestedModelFields(model, selection);
20
+ return create(RequestedModelSchema, {
21
+ modelId: fields.modelId,
22
+ maxMode: fields.maxMode,
23
+ parameters: fields.parameters.map((parameter) => create(RequestedModel_ModelParameterbytesSchema, { id: parameter.id, value: parameter.value })),
24
+ });
25
+ }
26
+ //# sourceMappingURL=reasoning-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoning-params.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/reasoning-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AAGxF,OAAO,EAAE,wCAAwC,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEnG;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,KAA4B,EAC5B,SAAwC;IAExC,MAAM,QAAQ,GAAG,gCAAgC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO;QACN,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI;QAC7C,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;KAClG,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAClC,KAA4B,EAC5B,SAAwC;IAExC,MAAM,MAAM,GAAG,yBAAyB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC,oBAAoB,EAAE;QACnC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAC/C,MAAM,CAAC,wCAAwC,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAC9F;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport { resolveCursorSelectionDescriptor } from \"../../cursor/selection-descriptor.ts\";\nimport type { Model } from \"../../model.ts\";\nimport type { ThinkingSelection } from \"../../types.ts\";\nimport { RequestedModel_ModelParameterbytesSchema, RequestedModelSchema } from \"./gen/agent_pb.ts\";\n\n/**\n * Render the resolved Cursor selection into the protobuf `RequestedModel`\n * fields: resolved wire id, maxMode, and ordered parameters. An absent\n * selection yields the pre-grouping request shape (upstream id, no\n * parameters) byte-for-byte.\n */\nexport function buildRequestedModelFields(\n\tmodel: Model<\"cursor-agent\">,\n\tselection: ThinkingSelection | undefined,\n): { modelId: string; maxMode: boolean; parameters: { id: string; value: string }[] } {\n\tconst resolved = resolveCursorSelectionDescriptor(model, selection);\n\treturn {\n\t\tmodelId: resolved.modelId,\n\t\tmaxMode: model.compat?.cursorMaxMode === true,\n\t\tparameters: resolved.parameters.map((parameter) => ({ id: parameter.id, value: parameter.value })),\n\t};\n}\n\nexport function buildRequestedModel(\n\tmodel: Model<\"cursor-agent\">,\n\tselection: ThinkingSelection | undefined,\n): ReturnType<typeof create<typeof RequestedModelSchema>> {\n\tconst fields = buildRequestedModelFields(model, selection);\n\treturn create(RequestedModelSchema, {\n\t\tmodelId: fields.modelId,\n\t\tmaxMode: fields.maxMode,\n\t\tparameters: fields.parameters.map((parameter) =>\n\t\t\tcreate(RequestedModel_ModelParameterbytesSchema, { id: parameter.id, value: parameter.value }),\n\t\t),\n\t});\n}\n"]}
@@ -12,7 +12,7 @@
12
12
  * Everything here is type-only over the generated protobuf shapes, so it is
13
13
  * safe to import from browser-reachable modules.
14
14
  */
15
- import type { StreamOptions, ToolResultMessage } from "../../types.ts";
15
+ import type { StreamOptions, ThinkingSelection, ToolResultMessage } from "../../types.ts";
16
16
  import type { DeleteArgs, DeleteResult, DiagnosticsArgs, DiagnosticsResult, GrepArgs, GrepResult, LsArgs, LsResult, McpResult, PiBashExecArgs, PiBashExecResult, PiEditExecArgs, PiEditExecResult, PiFindExecArgs, PiFindExecResult, PiGrepExecArgs, PiGrepExecResult, PiLsExecArgs, PiLsExecResult, PiReadExecArgs, PiReadExecResult, PiWriteExecArgs, PiWriteExecResult, ReadArgs, ReadResult, ShellArgs, ShellResult, WriteArgs, WriteResult } from "./gen/agent_pb.ts";
17
17
  /**
18
18
  * The three return forms an exec handler may use: a wire result with an
@@ -112,5 +112,11 @@ export interface CursorAgentOptions extends StreamOptions {
112
112
  execHandlers?: CursorExecHandlers;
113
113
  /** Receives every exec-channel tool result for transcript pairing. */
114
114
  onToolResult?: CursorToolResultHandler;
115
+ /**
116
+ * Provenance-bearing thinking selection rendered into
117
+ * `RequestedModel.parameters`; absent selections keep the representative
118
+ * variant request shape.
119
+ */
120
+ thinkingSelection?: ThinkingSelection;
115
121
  }
116
122
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"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,cAAc,CAAC,CAAC,CAAC;IAC9F,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACvC;AAED,yDAAyD;AACzD,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACxD,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wFAAwF;IACxF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,sEAAsE;IACtE,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG","sourcesContent":["/**\n * Cursor exec-channel handler contracts.\n *\n * The Cursor agent protocol is server-driven: mid-turn, the server sends\n * `ExecServerMessage` frames asking the CLIENT to run a tool and blocks until\n * the reply arrives on the same stream. The host (coding-agent) supplies\n * these handlers; the `cursor-agent` API dispatches frames onto them, sends\n * their protobuf answers back on the wire, synthesizes already-resolved\n * `toolCall` blocks into the assistant message, and pairs each with a\n * `ToolResultMessage` delivered through {@link CursorToolResultHandler}.\n *\n * Everything here is type-only over the generated protobuf shapes, so it is\n * safe to import from browser-reachable modules.\n */\n\nimport type { StreamOptions, ToolResultMessage } from \"../../types.ts\";\nimport type {\n\tDeleteArgs,\n\tDeleteResult,\n\tDiagnosticsArgs,\n\tDiagnosticsResult,\n\tGrepArgs,\n\tGrepResult,\n\tLsArgs,\n\tLsResult,\n\tMcpResult,\n\tPiBashExecArgs,\n\tPiBashExecResult,\n\tPiEditExecArgs,\n\tPiEditExecResult,\n\tPiFindExecArgs,\n\tPiFindExecResult,\n\tPiGrepExecArgs,\n\tPiGrepExecResult,\n\tPiLsExecArgs,\n\tPiLsExecResult,\n\tPiReadExecArgs,\n\tPiReadExecResult,\n\tPiWriteExecArgs,\n\tPiWriteExecResult,\n\tReadArgs,\n\tReadResult,\n\tShellArgs,\n\tShellResult,\n\tWriteArgs,\n\tWriteResult,\n} from \"./gen/agent_pb.ts\";\n\n/**\n * The three return forms an exec handler may use: a wire result with an\n * optional transcript pairing, a bare wire result, or a bare\n * `ToolResultMessage` from which the wire result is derived.\n */\nexport type CursorExecHandlerResult<T> = { result: T; toolResult?: ToolResultMessage } | T | ToolResultMessage;\n\n/**\n * Optional rewrite of a Cursor exec-channel tool result.\n * May return a Promise. Returning `undefined` keeps the original result.\n */\nexport type CursorToolResultHandler = (\n\tresult: ToolResultMessage,\n) => ToolResultMessage | undefined | Promise<ToolResultMessage | undefined>;\n\n/**\n * Identifies the synthesized assistant block a Cursor exec call was filed\n * under, so paths that produce no handler `toolResult` can still pair one.\n */\nexport interface CursorExecPairing {\n\ttoolCallId: string;\n\ttoolName: string;\n}\n\nexport interface CursorMcpCall {\n\tname: string;\n\tproviderIdentifier: string;\n\ttoolName: string;\n\ttoolCallId: string;\n\targs: Record<string, unknown>;\n\trawArgs: Record<string, Uint8Array>;\n\t/**\n\t * The frame asks only whether this call would be permitted — it must not\n\t * run. The server sends it to resolve a smart-mode approval decision ahead\n\t * of the real invocation; executing here would fire a side-effecting tool\n\t * the user has not yet been asked about (and fire it twice once the real\n\t * call arrives).\n\t */\n\tapprovalOnly?: boolean;\n}\n\nexport interface CursorShellStreamCallbacks {\n\tonStdout(data: string): void;\n\tonStderr(data: string): void;\n}\n\n/**\n * A modern Pi exec frame plus the call id the dispatcher minted for it.\n *\n * Unlike the legacy exec args (`ReadArgs`, `ShellArgs`, ...), the Pi frames\n * carry no `tool_call_id` field: the id rides the streamed `ToolCall`\n * envelope instead. The exec channel has no access to that envelope, so the\n * dispatcher mints an id and hands it to the handler, keeping the synthesized\n * transcript block and its paired `toolResult` on the same key.\n */\nexport interface CursorPiCall<TArgs> {\n\targs: TArgs;\n\ttoolCallId: string;\n}\n\nexport interface CursorExecHandlers {\n\tread?: (args: ReadArgs) => Promise<CursorExecHandlerResult<ReadResult>>;\n\tls?: (args: LsArgs) => Promise<CursorExecHandlerResult<LsResult>>;\n\tgrep?: (args: GrepArgs) => Promise<CursorExecHandlerResult<GrepResult>>;\n\twrite?: (args: WriteArgs) => Promise<CursorExecHandlerResult<WriteResult>>;\n\tdelete?: (args: DeleteArgs) => Promise<CursorExecHandlerResult<DeleteResult>>;\n\tshell?: (args: ShellArgs) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tshellStream?: (\n\t\targs: ShellArgs,\n\t\tcallbacks: CursorShellStreamCallbacks,\n\t) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tdiagnostics?: (args: DiagnosticsArgs) => Promise<CursorExecHandlerResult<DiagnosticsResult>>;\n\tmcp?: (call: CursorMcpCall) => Promise<CursorExecHandlerResult<McpResult>>;\n\t/**\n\t * Answers \"would this MCP call be permitted\", without running it.\n\t *\n\t * `true` only when the host's policy resolves to a definite allow. A\n\t * pending prompt is `false`: it can only be answered interactively at\n\t * execution time. When no handler is registered the provider refuses,\n\t * since it cannot decide.\n\t */\n\tmcpApprovalPreflight?: (call: CursorMcpCall) => Promise<boolean>;\n\t/**\n\t * Modern Cursor CLI Pi tool frames (`ExecServerMessage` 45-51). They are a\n\t * distinct frame family from the legacy `readArgs`/`shellArgs`/... set:\n\t * different args, different result oneofs, and no `tool_call_id`.\n\t */\n\tpiRead?: (call: CursorPiCall<PiReadExecArgs>) => Promise<CursorExecHandlerResult<PiReadExecResult>>;\n\tpiBash?: (call: CursorPiCall<PiBashExecArgs>) => Promise<CursorExecHandlerResult<PiBashExecResult>>;\n\tpiEdit?: (call: CursorPiCall<PiEditExecArgs>) => Promise<CursorExecHandlerResult<PiEditExecResult>>;\n\tpiWrite?: (call: CursorPiCall<PiWriteExecArgs>) => Promise<CursorExecHandlerResult<PiWriteExecResult>>;\n\tpiGrep?: (call: CursorPiCall<PiGrepExecArgs>) => Promise<CursorExecHandlerResult<PiGrepExecResult>>;\n\tpiFind?: (call: CursorPiCall<PiFindExecArgs>) => Promise<CursorExecHandlerResult<PiFindExecResult>>;\n\tpiLs?: (call: CursorPiCall<PiLsExecArgs>) => Promise<CursorExecHandlerResult<PiLsExecResult>>;\n\tonToolResult?: CursorToolResultHandler;\n}\n\n/** Stream options accepted by the `cursor-agent` API. */\nexport interface CursorAgentOptions extends StreamOptions {\n\t/** Optional server-side system prompt override (RunRequest.customSystemPrompt). */\n\tcustomSystemPrompt?: string;\n\t/** Conversation id override; defaults to `sessionId`, else a random UUID per stream. */\n\tconversationId?: string;\n\t/** Cursor exec/MCP tool handlers supplied by the host. */\n\texecHandlers?: CursorExecHandlers;\n\t/** Receives every exec-channel tool result for transcript pairing. */\n\tonToolResult?: CursorToolResultHandler;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG","sourcesContent":["/**\n * Cursor exec-channel handler contracts.\n *\n * The Cursor agent protocol is server-driven: mid-turn, the server sends\n * `ExecServerMessage` frames asking the CLIENT to run a tool and blocks until\n * the reply arrives on the same stream. The host (coding-agent) supplies\n * these handlers; the `cursor-agent` API dispatches frames onto them, sends\n * their protobuf answers back on the wire, synthesizes already-resolved\n * `toolCall` blocks into the assistant message, and pairs each with a\n * `ToolResultMessage` delivered through {@link CursorToolResultHandler}.\n *\n * Everything here is type-only over the generated protobuf shapes, so it is\n * safe to import from browser-reachable modules.\n */\n\nimport type { StreamOptions, ThinkingSelection, ToolResultMessage } from \"../../types.ts\";\nimport type {\n\tDeleteArgs,\n\tDeleteResult,\n\tDiagnosticsArgs,\n\tDiagnosticsResult,\n\tGrepArgs,\n\tGrepResult,\n\tLsArgs,\n\tLsResult,\n\tMcpResult,\n\tPiBashExecArgs,\n\tPiBashExecResult,\n\tPiEditExecArgs,\n\tPiEditExecResult,\n\tPiFindExecArgs,\n\tPiFindExecResult,\n\tPiGrepExecArgs,\n\tPiGrepExecResult,\n\tPiLsExecArgs,\n\tPiLsExecResult,\n\tPiReadExecArgs,\n\tPiReadExecResult,\n\tPiWriteExecArgs,\n\tPiWriteExecResult,\n\tReadArgs,\n\tReadResult,\n\tShellArgs,\n\tShellResult,\n\tWriteArgs,\n\tWriteResult,\n} from \"./gen/agent_pb.ts\";\n\n/**\n * The three return forms an exec handler may use: a wire result with an\n * optional transcript pairing, a bare wire result, or a bare\n * `ToolResultMessage` from which the wire result is derived.\n */\nexport type CursorExecHandlerResult<T> = { result: T; toolResult?: ToolResultMessage } | T | ToolResultMessage;\n\n/**\n * Optional rewrite of a Cursor exec-channel tool result.\n * May return a Promise. Returning `undefined` keeps the original result.\n */\nexport type CursorToolResultHandler = (\n\tresult: ToolResultMessage,\n) => ToolResultMessage | undefined | Promise<ToolResultMessage | undefined>;\n\n/**\n * Identifies the synthesized assistant block a Cursor exec call was filed\n * under, so paths that produce no handler `toolResult` can still pair one.\n */\nexport interface CursorExecPairing {\n\ttoolCallId: string;\n\ttoolName: string;\n}\n\nexport interface CursorMcpCall {\n\tname: string;\n\tproviderIdentifier: string;\n\ttoolName: string;\n\ttoolCallId: string;\n\targs: Record<string, unknown>;\n\trawArgs: Record<string, Uint8Array>;\n\t/**\n\t * The frame asks only whether this call would be permitted — it must not\n\t * run. The server sends it to resolve a smart-mode approval decision ahead\n\t * of the real invocation; executing here would fire a side-effecting tool\n\t * the user has not yet been asked about (and fire it twice once the real\n\t * call arrives).\n\t */\n\tapprovalOnly?: boolean;\n}\n\nexport interface CursorShellStreamCallbacks {\n\tonStdout(data: string): void;\n\tonStderr(data: string): void;\n}\n\n/**\n * A modern Pi exec frame plus the call id the dispatcher minted for it.\n *\n * Unlike the legacy exec args (`ReadArgs`, `ShellArgs`, ...), the Pi frames\n * carry no `tool_call_id` field: the id rides the streamed `ToolCall`\n * envelope instead. The exec channel has no access to that envelope, so the\n * dispatcher mints an id and hands it to the handler, keeping the synthesized\n * transcript block and its paired `toolResult` on the same key.\n */\nexport interface CursorPiCall<TArgs> {\n\targs: TArgs;\n\ttoolCallId: string;\n}\n\nexport interface CursorExecHandlers {\n\tread?: (args: ReadArgs) => Promise<CursorExecHandlerResult<ReadResult>>;\n\tls?: (args: LsArgs) => Promise<CursorExecHandlerResult<LsResult>>;\n\tgrep?: (args: GrepArgs) => Promise<CursorExecHandlerResult<GrepResult>>;\n\twrite?: (args: WriteArgs) => Promise<CursorExecHandlerResult<WriteResult>>;\n\tdelete?: (args: DeleteArgs) => Promise<CursorExecHandlerResult<DeleteResult>>;\n\tshell?: (args: ShellArgs) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tshellStream?: (\n\t\targs: ShellArgs,\n\t\tcallbacks: CursorShellStreamCallbacks,\n\t) => Promise<CursorExecHandlerResult<ShellResult>>;\n\tdiagnostics?: (args: DiagnosticsArgs) => Promise<CursorExecHandlerResult<DiagnosticsResult>>;\n\tmcp?: (call: CursorMcpCall) => Promise<CursorExecHandlerResult<McpResult>>;\n\t/**\n\t * Answers \"would this MCP call be permitted\", without running it.\n\t *\n\t * `true` only when the host's policy resolves to a definite allow. A\n\t * pending prompt is `false`: it can only be answered interactively at\n\t * execution time. When no handler is registered the provider refuses,\n\t * since it cannot decide.\n\t */\n\tmcpApprovalPreflight?: (call: CursorMcpCall) => Promise<boolean>;\n\t/**\n\t * Modern Cursor CLI Pi tool frames (`ExecServerMessage` 45-51). They are a\n\t * distinct frame family from the legacy `readArgs`/`shellArgs`/... set:\n\t * different args, different result oneofs, and no `tool_call_id`.\n\t */\n\tpiRead?: (call: CursorPiCall<PiReadExecArgs>) => Promise<CursorExecHandlerResult<PiReadExecResult>>;\n\tpiBash?: (call: CursorPiCall<PiBashExecArgs>) => Promise<CursorExecHandlerResult<PiBashExecResult>>;\n\tpiEdit?: (call: CursorPiCall<PiEditExecArgs>) => Promise<CursorExecHandlerResult<PiEditExecResult>>;\n\tpiWrite?: (call: CursorPiCall<PiWriteExecArgs>) => Promise<CursorExecHandlerResult<PiWriteExecResult>>;\n\tpiGrep?: (call: CursorPiCall<PiGrepExecArgs>) => Promise<CursorExecHandlerResult<PiGrepExecResult>>;\n\tpiFind?: (call: CursorPiCall<PiFindExecArgs>) => Promise<CursorExecHandlerResult<PiFindExecResult>>;\n\tpiLs?: (call: CursorPiCall<PiLsExecArgs>) => Promise<CursorExecHandlerResult<PiLsExecResult>>;\n\tonToolResult?: CursorToolResultHandler;\n}\n\n/** Stream options accepted by the `cursor-agent` API. */\nexport interface CursorAgentOptions extends StreamOptions {\n\t/** Optional server-side system prompt override (RunRequest.customSystemPrompt). */\n\tcustomSystemPrompt?: string;\n\t/** Conversation id override; defaults to `sessionId`, else a random UUID per stream. */\n\tconversationId?: string;\n\t/** Cursor exec/MCP tool handlers supplied by the host. */\n\texecHandlers?: CursorExecHandlers;\n\t/** Receives every exec-channel tool result for transcript pairing. */\n\tonToolResult?: CursorToolResultHandler;\n\t/**\n\t * Provenance-bearing thinking selection rendered into\n\t * `RequestedModel.parameters`; absent selections keep the representative\n\t * variant request shape.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n}\n"]}
@@ -35,9 +35,9 @@ export declare function frameConnectMessage(data: Uint8Array, flags?: number): B
35
35
  export declare function mapH2TransportError(error: unknown, baseUrl: string): unknown;
36
36
  export declare const stream: StreamFunction<"cursor-agent", CursorAgentOptions>;
37
37
  /**
38
- * `streamSimple` for Cursor: reasoning/thinking is managed server-side per
39
- * model (there is no client thinking knob on the Run request), so the simple
40
- * options map through unchanged.
38
+ * `streamSimple` for Cursor: an explicit thinking selection (`options.thinkingSelection`)
39
+ * is rendered into `RequestedModel.parameters`; reasoning output itself streams back as
40
+ * `ThinkingContent` regardless of the selection.
41
41
  */
42
42
  export declare const streamSimple: StreamFunction<"cursor-agent", SimpleStreamOptions>;
43
43
  export type ToolCallState = ToolCall & {
@@ -80,6 +80,7 @@ export interface BlockState {
80
80
  }
81
81
  export interface UsageState {
82
82
  sawTokenDelta: boolean;
83
+ sawTurnEndedUsage: boolean;
83
84
  }
84
85
  /** Exported for tests: drives one Cursor server message through the stream (exec waits mark the stream busy). */
85
86
  export declare function handleServerMessage(msg: AgentServerMessage, output: AssistantMessage, stream: AssistantMessageEventStream, state: BlockState, blobStore: Map<string, Uint8Array>, h2Request: http2.ClientHttp2Stream, execHandlers: CursorExecHandlers | undefined, onToolResult: CursorToolResultHandler | undefined, usageState: UsageState, requestContextTools: McpToolDefinition[], onConversationCheckpoint?: (checkpoint: ConversationStateStructure) => void): Promise<void>;
@@ -153,6 +154,7 @@ export declare function mergeCursorMcpToolCallArgs(streamed: Record<string, unkn
153
154
  export declare function synthesizeCursorExecToolCall(output: AssistantMessage, stream: AssistantMessageEventStream, state: BlockState, toolCallId: string, toolName: string, args: Record<string, unknown>): void;
154
155
  /** Exported for tests: drives one Cursor interaction update through the streaming state machine. */
155
156
  export declare function processInteractionUpdate(update: any, output: AssistantMessage, stream: AssistantMessageEventStream, state: BlockState, usageState: UsageState): void;
157
+ export declare function sanitizeCursorToolSchema(schema: unknown): unknown;
156
158
  export declare function buildMcpToolDefinitions(tools: Tool[] | undefined): McpToolDefinition[];
157
159
  /**
158
160
  * Build one Cursor system-message JSON blob per system prompt. When no system
@@ -1 +1 @@
1
- {"version":3,"file":"cursor-agent.d.ts","sourceRoot":"","sources":["../../src/api/cursor-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAIpC,OAAO,KAAK,EAEX,gBAAgB,EAGhB,OAAO,EAEP,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,eAAe,EACf,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGN,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AA0B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terministicUuid } from "./cursor-agent/deterministic-id.js";
29
29
  import { armExecHeartbeat } from "./cursor-agent/exec-lifecycle.js";
30
30
  import { buildMcpStateResult, buildNeutralHookResult, buildPiBashError, buildPiBashResult, buildPiEditError, buildPiEditRejected, buildPiEditResult, buildPiFindError, buildPiFindResult, buildPiGrepError, buildPiGrepResult, buildPiLsError, buildPiLsResult, buildPiReadError, buildPiReadResult, buildPiWriteError, buildPiWriteRejected, buildPiWriteResult, } from "./cursor-agent/exec-modern.js";
31
- import { AgentClientMessageSchema, AgentConversationTurnStructureSchema, AgentRunRequestSchema, AgentServerMessageSchema, AgentStoreConflictErrorSchema, AgentStoreConflictResultSchema, AssistantMessageSchema, BackgroundShellSpawnResultSchema, CanvasDiagnosticsErrorSchema, CanvasDiagnosticsResultSchema, ClientHeartbeatSchema, ComputerUseErrorSchema, ComputerUseResultSchema, ConversationActionSchema, ConversationSearchErrorSchema, ConversationSearchResultSchema, ConversationStateStructureSchema, ConversationStepSchema, ConversationTurnStructureSchema, DeleteErrorSchema, DeleteRejectedSchema, DeleteResultSchema, DeleteSuccessSchema, DiagnosticsErrorSchema, DiagnosticsRejectedSchema, DiagnosticsResultSchema, DiagnosticsSuccessSchema, ExecClientControlMessageSchema, ExecClientHeartbeatSchema, ExecClientMessageSchema, ExecClientStreamCloseSchema, ExecClientThrowSchema, FetchErrorSchema, FetchResultSchema, ForceBackgroundShellResultSchema, ForceBackgroundShellStatus, ForceBackgroundSubagentResultSchema, ForceBackgroundSubagentStatus, GetBlobResultSchema, GetUsableModelsRequestSchema, GetUsableModelsResponseSchema, GrepContentMatchSchema, GrepContentResultSchema, GrepCountResultSchema, GrepErrorSchema, GrepFileCountSchema, GrepFileMatchSchema, GrepFilesResultSchema, GrepResultSchema, GrepSuccessSchema, GrepUnionResultSchema, KvClientMessageSchema, ListMcpResourcesExecResultSchema, ListMcpResourcesSuccessSchema, LsDirectoryTreeNode_FileSchema, LsDirectoryTreeNodeSchema, LsErrorSchema, LsRejectedSchema, LsResultSchema, LsSuccessSchema, McpAllowlistPrecheckResultSchema, McpApprovedSchema, McpArgsSchema, McpErrorSchema, McpImageContentSchema, McpRejectedSchema, McpResultSchema, McpSuccessSchema, McpTextContentSchema, McpToolCallSchema, McpToolDefinitionSchema, McpToolErrorSchema, McpToolNotFoundSchema, McpToolResultContentItemSchema, McpToolResultSchema, ModelDetailsSchema, ReadErrorSchema, ReadMcpResourceExecResultSchema, ReadMcpResourceNotFoundSchema, ReadRejectedSchema, ReadResultSchema, ReadSuccessSchema, RecordScreenFailureSchema, RecordScreenResultSchema, RequestContextResultSchema, RequestContextSchema, RequestContextSuccessSchema, RequestedModelSchema, ResumeActionSchema, SelectedContextSchema, SelectedImageSchema, SetBlobResultSchema, ShellAllowlistPrecheckResultSchema, ShellFailureSchema, ShellRejectedSchema, ShellResultSchema, ShellStreamExitSchema, ShellStreamSchema, ShellStreamStartSchema, ShellStreamStderrSchema, ShellStreamStdoutSchema, ShellSuccessSchema, SmartModeClassifierErrorSchema, SmartModeClassifierResultSchema, SubagentAwaitNotFoundSchema, SubagentAwaitResultSchema, SubagentErrorSchema, SubagentResultSchema, ToolCallSchema, UserMessageActionSchema, UserMessageSchema, WebFetchAllowlistPrecheckResultSchema, WriteErrorSchema, WriteRejectedSchema, WriteResultSchema, WriteShellStdinErrorSchema, WriteShellStdinResultSchema, WriteSuccessSchema, } from "./cursor-agent/gen/agent_pb.js";
31
+ import { AgentClientMessageSchema, AgentConversationTurnStructureSchema, AgentRunRequestSchema, AgentServerMessageSchema, AgentStoreConflictErrorSchema, AgentStoreConflictResultSchema, AssistantMessageSchema, BackgroundShellSpawnResultSchema, CanvasDiagnosticsErrorSchema, CanvasDiagnosticsResultSchema, ClientHeartbeatSchema, ComputerUseErrorSchema, ComputerUseResultSchema, ConversationActionSchema, ConversationSearchErrorSchema, ConversationSearchResultSchema, ConversationStateStructureSchema, ConversationStepSchema, ConversationTurnStructureSchema, DeleteErrorSchema, DeleteRejectedSchema, DeleteResultSchema, DeleteSuccessSchema, DiagnosticsErrorSchema, DiagnosticsRejectedSchema, DiagnosticsResultSchema, DiagnosticsSuccessSchema, ExecClientControlMessageSchema, ExecClientHeartbeatSchema, ExecClientMessageSchema, ExecClientStreamCloseSchema, ExecClientThrowSchema, FetchErrorSchema, FetchResultSchema, ForceBackgroundShellResultSchema, ForceBackgroundShellStatus, ForceBackgroundSubagentResultSchema, ForceBackgroundSubagentStatus, GetBlobResultSchema, GetUsableModelsRequestSchema, GetUsableModelsResponseSchema, GrepContentMatchSchema, GrepContentResultSchema, GrepCountResultSchema, GrepErrorSchema, GrepFileCountSchema, GrepFileMatchSchema, GrepFilesResultSchema, GrepResultSchema, GrepSuccessSchema, GrepUnionResultSchema, KvClientMessageSchema, ListMcpResourcesExecResultSchema, ListMcpResourcesSuccessSchema, LsDirectoryTreeNode_FileSchema, LsDirectoryTreeNodeSchema, LsErrorSchema, LsRejectedSchema, LsResultSchema, LsSuccessSchema, McpAllowlistPrecheckResultSchema, McpApprovedSchema, McpArgsSchema, McpErrorSchema, McpImageContentSchema, McpRejectedSchema, McpResultSchema, McpSuccessSchema, McpTextContentSchema, McpToolCallSchema, McpToolDefinitionSchema, McpToolErrorSchema, McpToolNotFoundSchema, McpToolResultContentItemSchema, McpToolResultSchema, ModelDetailsSchema, ReadErrorSchema, ReadMcpResourceExecResultSchema, ReadMcpResourceNotFoundSchema, ReadRejectedSchema, ReadResultSchema, ReadSuccessSchema, RecordScreenFailureSchema, RecordScreenResultSchema, RequestContextResultSchema, RequestContextSchema, RequestContextSuccessSchema, ResumeActionSchema, SelectedContextSchema, SelectedImageSchema, SetBlobResultSchema, ShellAllowlistPrecheckResultSchema, ShellFailureSchema, ShellRejectedSchema, ShellResultSchema, ShellStreamExitSchema, ShellStreamSchema, ShellStreamStartSchema, ShellStreamStderrSchema, ShellStreamStdoutSchema, ShellSuccessSchema, SmartModeClassifierErrorSchema, SmartModeClassifierResultSchema, SubagentAwaitNotFoundSchema, SubagentAwaitResultSchema, SubagentErrorSchema, SubagentResultSchema, ToolCallSchema, UserMessageActionSchema, UserMessageSchema, WebFetchAllowlistPrecheckResultSchema, WriteErrorSchema, WriteRejectedSchema, WriteResultSchema, WriteShellStdinErrorSchema, WriteShellStdinResultSchema, WriteSuccessSchema, } from "./cursor-agent/gen/agent_pb.js";
32
32
  import { composeShellCommand, omitUndefinedArgs, piLimit, piLsPath, piReadArgs, piTimeout, } from "./cursor-agent/pi-args.js";
33
+ import { buildRequestedModel } from "./cursor-agent/reasoning-params.js";
33
34
  export const CURSOR_API_URL = "https://api2.cursor.sh";
34
35
  export const CURSOR_CLIENT_VERSION = "cli-2026.07.23-e383d2b";
35
36
  const EXEC_HEARTBEAT_INTERVAL_MS = 3000;
@@ -287,7 +288,7 @@ export const stream = (model, context, options) => {
287
288
  let currentThinkingBlock = null;
288
289
  let currentToolCall = null;
289
290
  const resolvedMcpToolCallIds = new Set();
290
- usageState = { sawTokenDelta: false };
291
+ usageState = { sawTokenDelta: false, sawTurnEndedUsage: false };
291
292
  const state = {
292
293
  get currentTextBlock() {
293
294
  return currentTextBlock;
@@ -459,9 +460,9 @@ export const stream = (model, context, options) => {
459
460
  return stream;
460
461
  };
461
462
  /**
462
- * `streamSimple` for Cursor: reasoning/thinking is managed server-side per
463
- * model (there is no client thinking knob on the Run request), so the simple
464
- * options map through unchanged.
463
+ * `streamSimple` for Cursor: an explicit thinking selection (`options.thinkingSelection`)
464
+ * is rendered into `RequestedModel.parameters`; reasoning output itself streams back as
465
+ * `ThinkingContent` regardless of the selection.
465
466
  */
466
467
  export const streamSimple = (model, context, options) => {
467
468
  return stream(model, context, options);
@@ -487,6 +488,7 @@ export async function handleServerMessage(msg, output, stream, state, blobStore,
487
488
  await stream.trackLocalWork(handleExecServerMessage(msg.message.value, h2Request, execHandlers, onToolResult, requestContextTools, output, stream, state));
488
489
  }
489
490
  else if (msgCase === "conversationCheckpointUpdate") {
491
+ applyCheckpointTokenDetails(msg.message.value, output, usageState);
490
492
  onConversationCheckpoint?.(msg.message.value);
491
493
  }
492
494
  }
@@ -2587,14 +2589,62 @@ export function processInteractionUpdate(update, output, stream, state, usageSta
2587
2589
  }
2588
2590
  else if (updateCase === "turnEnded") {
2589
2591
  output.stopReason = "stop";
2592
+ applyBilledTurnEndedUsage(update.message.value, output, usageState);
2590
2593
  }
2591
2594
  else if (updateCase === "tokenDelta") {
2592
2595
  const tokenDelta = update.message.value;
2593
2596
  usageState.sawTokenDelta = true;
2594
2597
  output.usage.output += tokenDelta.tokens || 0;
2595
- output.usage.totalTokens = output.usage.input + output.usage.output;
2598
+ output.usage.totalTokens =
2599
+ output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
2596
2600
  }
2597
2601
  }
2602
+ /**
2603
+ * Cursor's production schema (cursor-agent 2026.08.11) carries the billed
2604
+ * token split on `turnEnded`: 1 input, 2 output, 3 cache read, 4 cache write,
2605
+ * 5 reasoning (optional int64). Live probes against api2.cursor.sh show
2606
+ * input_tokens is cache-INCLUSIVE (turn 1: input 21357 ≈ cacheWrite 21354;
2607
+ * turn 2: input 17989 ≈ cacheRead 17575 + cacheWrite 411), so the uncached
2608
+ * remainder is backed out for senpi's exclusive `usage.input`. The billed
2609
+ * split is authoritative for context accounting; the tokenDelta-accumulated
2610
+ * output is kept only when the server omits the billed output field.
2611
+ * Reasoning tokens are deliberately not folded into output: no other field of
2612
+ * `Usage` represents them and double counting against the billed output must
2613
+ * be avoided.
2614
+ */
2615
+ function applyBilledTurnEndedUsage(update, output, usageState) {
2616
+ const { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens } = update;
2617
+ if (inputTokens === undefined &&
2618
+ outputTokens === undefined &&
2619
+ cacheReadTokens === undefined &&
2620
+ cacheWriteTokens === undefined) {
2621
+ return;
2622
+ }
2623
+ usageState.sawTurnEndedUsage = true;
2624
+ const usage = output.usage;
2625
+ usage.cacheRead = Number(cacheReadTokens ?? 0n);
2626
+ usage.cacheWrite = Number(cacheWriteTokens ?? 0n);
2627
+ usage.input = Math.max(0, Number(inputTokens ?? 0n) - usage.cacheRead - usage.cacheWrite);
2628
+ if (outputTokens !== undefined) {
2629
+ usage.output = Number(outputTokens);
2630
+ }
2631
+ usage.totalTokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
2632
+ }
2633
+ /**
2634
+ * A checkpoint's `tokenDetails.usedTokens` is the server's live conversation
2635
+ * size, sent mid-turn. It feeds context accounting while the turn streams,
2636
+ * but never overrides the billed turnEnded split once that arrived.
2637
+ */
2638
+ function applyCheckpointTokenDetails(checkpoint, output, usageState) {
2639
+ if (usageState.sawTurnEndedUsage)
2640
+ return;
2641
+ const usedTokens = checkpoint.tokenDetails?.usedTokens ?? 0;
2642
+ if (usedTokens <= 0)
2643
+ return;
2644
+ const usage = output.usage;
2645
+ usage.input = Math.max(0, usedTokens - usage.output - usage.cacheRead - usage.cacheWrite);
2646
+ usage.totalTokens = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
2647
+ }
2598
2648
  function createBlobId(data) {
2599
2649
  return new Uint8Array(createHash("sha256").update(data).digest());
2600
2650
  }
@@ -2625,6 +2675,29 @@ function toolParametersToJsonSchema(tool) {
2625
2675
  return { type: "object", properties: {}, required: [] };
2626
2676
  }
2627
2677
  }
2678
+ /**
2679
+ * JSON-Schema composition keywords Cursor's gateway cannot carry: an
2680
+ * advertised tool whose inputSchema contains `oneOf`, `anyOf`, or `allOf` is
2681
+ * rejected upstream with a wrapped provider 400 for the WHOLE request
2682
+ * (zero tokens, `resource_exhausted` end-stream). MCP tools imported from
2683
+ * external servers routinely ship such schemas (e.g. ast-grep's `scan`).
2684
+ * `not` is tolerated upstream and kept. Returns a new structure; the input is
2685
+ * never mutated.
2686
+ */
2687
+ const CURSOR_UNSUPPORTED_SCHEMA_KEYS = new Set(["oneOf", "anyOf", "allOf"]);
2688
+ export function sanitizeCursorToolSchema(schema) {
2689
+ if (Array.isArray(schema))
2690
+ return schema.map(sanitizeCursorToolSchema);
2691
+ if (schema === null || typeof schema !== "object")
2692
+ return schema;
2693
+ const sanitized = {};
2694
+ for (const [key, value] of Object.entries(schema)) {
2695
+ if (CURSOR_UNSUPPORTED_SCHEMA_KEYS.has(key))
2696
+ continue;
2697
+ sanitized[key] = sanitizeCursorToolSchema(value);
2698
+ }
2699
+ return sanitized;
2700
+ }
2628
2701
  export function buildMcpToolDefinitions(tools) {
2629
2702
  if (!tools || tools.length === 0) {
2630
2703
  return [];
@@ -2634,7 +2707,7 @@ export function buildMcpToolDefinitions(tools) {
2634
2707
  return [];
2635
2708
  }
2636
2709
  return advertisedTools.map((tool) => {
2637
- const jsonSchema = toolParametersToJsonSchema(tool);
2710
+ const jsonSchema = sanitizeCursorToolSchema(toolParametersToJsonSchema(tool));
2638
2711
  const schemaValue = jsonSchema && typeof jsonSchema === "object"
2639
2712
  ? jsonSchema
2640
2713
  : { type: "object", properties: {}, required: [] };
@@ -3096,7 +3169,8 @@ async function buildGrpcRequest(model, context, options, state) {
3096
3169
  rootPromptMessagesJson,
3097
3170
  turns,
3098
3171
  });
3099
- const wireModelId = model.upstreamModelId ?? model.id;
3172
+ const requestedModel = buildRequestedModel(model, options?.thinkingSelection);
3173
+ const wireModelId = requestedModel.modelId;
3100
3174
  const cursorMaxMode = model.compat?.cursorMaxMode === true;
3101
3175
  const modelDetails = create(ModelDetailsSchema, {
3102
3176
  modelId: wireModelId,
@@ -3104,10 +3178,6 @@ async function buildGrpcRequest(model, context, options, state) {
3104
3178
  displayName: model.name,
3105
3179
  ...(cursorMaxMode ? { maxMode: true } : undefined),
3106
3180
  });
3107
- const requestedModel = create(RequestedModelSchema, {
3108
- modelId: wireModelId,
3109
- maxMode: cursorMaxMode,
3110
- });
3111
3181
  const runRequest = create(AgentRunRequestSchema, {
3112
3182
  conversationState,
3113
3183
  action,