@code-yeongyu/senpi-ai 2026.8.17 → 2026.8.18-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.
- package/dist/api/cursor-agent/reasoning-params.d.ts +20 -0
- package/dist/api/cursor-agent/reasoning-params.d.ts.map +1 -0
- package/dist/api/cursor-agent/reasoning-params.js +26 -0
- package/dist/api/cursor-agent/reasoning-params.js.map +1 -0
- package/dist/api/cursor-agent/types.d.ts +7 -1
- package/dist/api/cursor-agent/types.d.ts.map +1 -1
- package/dist/api/cursor-agent/types.js.map +1 -1
- package/dist/api/cursor-agent.d.ts +4 -3
- package/dist/api/cursor-agent.d.ts.map +1 -1
- package/dist/api/cursor-agent.js +31 -10
- package/dist/api/cursor-agent.js.map +1 -1
- package/dist/cursor/catalog-grouping.d.ts +25 -0
- package/dist/cursor/catalog-grouping.d.ts.map +1 -0
- package/dist/cursor/catalog-grouping.js +134 -0
- package/dist/cursor/catalog-grouping.js.map +1 -0
- package/dist/cursor/cursor-variant-aliases.json +1893 -0
- package/dist/cursor/model-capabilities.d.ts +47 -0
- package/dist/cursor/model-capabilities.d.ts.map +1 -0
- package/dist/cursor/model-capabilities.js +208 -0
- package/dist/cursor/model-capabilities.js.map +1 -0
- package/dist/cursor/selection-descriptor.d.ts +21 -0
- package/dist/cursor/selection-descriptor.d.ts.map +1 -0
- package/dist/cursor/selection-descriptor.js +83 -0
- package/dist/cursor/selection-descriptor.js.map +1 -0
- package/dist/cursor/store-migration.d.ts +8 -0
- package/dist/cursor/store-migration.d.ts.map +1 -0
- package/dist/cursor/store-migration.js +76 -0
- package/dist/cursor/store-migration.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +13 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/models.d.ts +6 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +9 -1
- package/dist/models.js.map +1 -1
- package/dist/providers/cursor.d.ts.map +1 -1
- package/dist/providers/cursor.js +40 -11
- package/dist/providers/cursor.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +1 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js +21 -1
- package/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +1 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.d.ts.map +1 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.js +2 -1
- package/dist/tool-call-middleware/recovery-message-snapshot.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -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":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/cursor-agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,KAAK,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,CAAC,GAAG,iBAAiB,CAAC;AAE/G;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACrC,MAAM,EAAE,iBAAiB,KACrB,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAA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gB,CAAC,CAAC,CAAC;IACpG,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,uBAAuB,CAAC,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:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
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 & {
|
|
@@ -153,6 +153,7 @@ export declare function mergeCursorMcpToolCallArgs(streamed: Record<string, unkn
|
|
|
153
153
|
export declare function synthesizeCursorExecToolCall(output: AssistantMessage, stream: AssistantMessageEventStream, state: BlockState, toolCallId: string, toolName: string, args: Record<string, unknown>): void;
|
|
154
154
|
/** Exported for tests: drives one Cursor interaction update through the streaming state machine. */
|
|
155
155
|
export declare function processInteractionUpdate(update: any, output: AssistantMessage, stream: AssistantMessageEventStream, state: BlockState, usageState: UsageState): void;
|
|
156
|
+
export declare function sanitizeCursorToolSchema(schema: unknown): unknown;
|
|
156
157
|
export declare function buildMcpToolDefinitions(tools: Tool[] | undefined): McpToolDefinition[];
|
|
157
158
|
/**
|
|
158
159
|
* 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;AA0BvE,OAAO,EAIN,KAAK,kBAAkB,EAcvB,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AG,iBAAiB,EAAE,CAyBtF;AA6FD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAMvF;AAwPD,yFAAyF;AACzF,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,OAAO,EAAE,EACnB,sBAAsB,SAAqC,GACzD;IACF,sBAAsB,EAAE,OAAO,EAAE,CAAC;IAClC,oBAAoB,EAAE,OAAO,EAAE,CAAC;IAChC,oBAAoB,EAAE,OAAO,EAAE,EAAE,CAAC;CAClC,CAsBA;AA6MD,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAqG1C"}
|
package/dist/api/cursor-agent.js
CHANGED
|
@@ -28,8 +28,9 @@ import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
|
28
28
|
import { deterministicUuid } 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,
|
|
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;
|
|
@@ -459,9 +460,9 @@ export const stream = (model, context, options) => {
|
|
|
459
460
|
return stream;
|
|
460
461
|
};
|
|
461
462
|
/**
|
|
462
|
-
* `streamSimple` for Cursor:
|
|
463
|
-
*
|
|
464
|
-
*
|
|
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);
|
|
@@ -2625,6 +2626,29 @@ function toolParametersToJsonSchema(tool) {
|
|
|
2625
2626
|
return { type: "object", properties: {}, required: [] };
|
|
2626
2627
|
}
|
|
2627
2628
|
}
|
|
2629
|
+
/**
|
|
2630
|
+
* JSON-Schema composition keywords Cursor's gateway cannot carry: an
|
|
2631
|
+
* advertised tool whose inputSchema contains `oneOf`, `anyOf`, or `allOf` is
|
|
2632
|
+
* rejected upstream with a wrapped provider 400 for the WHOLE request
|
|
2633
|
+
* (zero tokens, `resource_exhausted` end-stream). MCP tools imported from
|
|
2634
|
+
* external servers routinely ship such schemas (e.g. ast-grep's `scan`).
|
|
2635
|
+
* `not` is tolerated upstream and kept. Returns a new structure; the input is
|
|
2636
|
+
* never mutated.
|
|
2637
|
+
*/
|
|
2638
|
+
const CURSOR_UNSUPPORTED_SCHEMA_KEYS = new Set(["oneOf", "anyOf", "allOf"]);
|
|
2639
|
+
export function sanitizeCursorToolSchema(schema) {
|
|
2640
|
+
if (Array.isArray(schema))
|
|
2641
|
+
return schema.map(sanitizeCursorToolSchema);
|
|
2642
|
+
if (schema === null || typeof schema !== "object")
|
|
2643
|
+
return schema;
|
|
2644
|
+
const sanitized = {};
|
|
2645
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
2646
|
+
if (CURSOR_UNSUPPORTED_SCHEMA_KEYS.has(key))
|
|
2647
|
+
continue;
|
|
2648
|
+
sanitized[key] = sanitizeCursorToolSchema(value);
|
|
2649
|
+
}
|
|
2650
|
+
return sanitized;
|
|
2651
|
+
}
|
|
2628
2652
|
export function buildMcpToolDefinitions(tools) {
|
|
2629
2653
|
if (!tools || tools.length === 0) {
|
|
2630
2654
|
return [];
|
|
@@ -2634,7 +2658,7 @@ export function buildMcpToolDefinitions(tools) {
|
|
|
2634
2658
|
return [];
|
|
2635
2659
|
}
|
|
2636
2660
|
return advertisedTools.map((tool) => {
|
|
2637
|
-
const jsonSchema = toolParametersToJsonSchema(tool);
|
|
2661
|
+
const jsonSchema = sanitizeCursorToolSchema(toolParametersToJsonSchema(tool));
|
|
2638
2662
|
const schemaValue = jsonSchema && typeof jsonSchema === "object"
|
|
2639
2663
|
? jsonSchema
|
|
2640
2664
|
: { type: "object", properties: {}, required: [] };
|
|
@@ -3096,7 +3120,8 @@ async function buildGrpcRequest(model, context, options, state) {
|
|
|
3096
3120
|
rootPromptMessagesJson,
|
|
3097
3121
|
turns,
|
|
3098
3122
|
});
|
|
3099
|
-
const
|
|
3123
|
+
const requestedModel = buildRequestedModel(model, options?.thinkingSelection);
|
|
3124
|
+
const wireModelId = requestedModel.modelId;
|
|
3100
3125
|
const cursorMaxMode = model.compat?.cursorMaxMode === true;
|
|
3101
3126
|
const modelDetails = create(ModelDetailsSchema, {
|
|
3102
3127
|
modelId: wireModelId,
|
|
@@ -3104,10 +3129,6 @@ async function buildGrpcRequest(model, context, options, state) {
|
|
|
3104
3129
|
displayName: model.name,
|
|
3105
3130
|
...(cursorMaxMode ? { maxMode: true } : undefined),
|
|
3106
3131
|
});
|
|
3107
|
-
const requestedModel = create(RequestedModelSchema, {
|
|
3108
|
-
modelId: wireModelId,
|
|
3109
|
-
maxMode: cursorMaxMode,
|
|
3110
|
-
});
|
|
3111
3132
|
const runRequest = create(AgentRunRequestSchema, {
|
|
3112
3133
|
conversationState,
|
|
3113
3134
|
action,
|