@songtonyli/dsh-cli 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +12 -6
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +12 -6
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +548 -51
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +9 -13
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +9 -13
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +188 -329
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
2
|
-
import { deepEqualJson } from "@deepseek-ai/dsh-util-values";
|
|
2
|
+
import { assertNever, deepEqualJson } from "@deepseek-ai/dsh-util-values";
|
|
3
3
|
import { LlmAdapter, LlmError, RetryPolicySchema, ToolCallId, assertUsableApiKey, attributionHeaders, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { create, fromBinary, fromJson, toBinary, toJson } from "@bufbuild/protobuf";
|
|
@@ -31,6 +31,12 @@ import { promisify } from "node:util";
|
|
|
31
31
|
const NS = "llm-cursor";
|
|
32
32
|
/** Always-registered provider route this adapter owns. */
|
|
33
33
|
const PROVIDER = "cursor";
|
|
34
|
+
/**
|
|
35
|
+
* Prefix Cursor puts in front of an MCP tool's name when it shows the tool to
|
|
36
|
+
* the model: `mcp_<providerIdentifier>_<toolName>`. Replayed prompt history uses
|
|
37
|
+
* the same name, and a model that echoes it on a new call is unwrapped.
|
|
38
|
+
*/
|
|
39
|
+
const MCP_PROMPT_TOOL_PREFIX = `mcp_dsh_`;
|
|
34
40
|
/** Default credential reference resolved before a stored grant or harvest. */
|
|
35
41
|
const DEFAULT_API_KEY_ENV = "CURSOR_ACCESS_TOKEN";
|
|
36
42
|
/** Cursor PKCE login page. */
|
|
@@ -477,6 +483,66 @@ const GetUsableModelsRequestSchema = /*@__PURE__*/ messageDesc(file_agent, 123);
|
|
|
477
483
|
*/
|
|
478
484
|
const GetUsableModelsResponseSchema = /*@__PURE__*/ messageDesc(file_agent, 124);
|
|
479
485
|
/**
|
|
486
|
+
* Describes the message agent.v1.BackgroundShellSpawnResult.
|
|
487
|
+
* Use `create(BackgroundShellSpawnResultSchema)` to create a new message.
|
|
488
|
+
*/
|
|
489
|
+
const BackgroundShellSpawnResultSchema = /*@__PURE__*/ messageDesc(file_agent, 148);
|
|
490
|
+
/**
|
|
491
|
+
* Describes the message agent.v1.WriteShellStdinResult.
|
|
492
|
+
* Use `create(WriteShellStdinResultSchema)` to create a new message.
|
|
493
|
+
*/
|
|
494
|
+
const WriteShellStdinResultSchema = /*@__PURE__*/ messageDesc(file_agent, 152);
|
|
495
|
+
/**
|
|
496
|
+
* Describes the message agent.v1.WriteShellStdinError.
|
|
497
|
+
* Use `create(WriteShellStdinErrorSchema)` to create a new message.
|
|
498
|
+
*/
|
|
499
|
+
const WriteShellStdinErrorSchema = /*@__PURE__*/ messageDesc(file_agent, 154);
|
|
500
|
+
/**
|
|
501
|
+
* Describes the message agent.v1.ComputerUseResult.
|
|
502
|
+
* Use `create(ComputerUseResultSchema)` to create a new message.
|
|
503
|
+
*/
|
|
504
|
+
const ComputerUseResultSchema = /*@__PURE__*/ messageDesc(file_agent, 169);
|
|
505
|
+
/**
|
|
506
|
+
* Describes the message agent.v1.ComputerUseError.
|
|
507
|
+
* Use `create(ComputerUseErrorSchema)` to create a new message.
|
|
508
|
+
*/
|
|
509
|
+
const ComputerUseErrorSchema = /*@__PURE__*/ messageDesc(file_agent, 171);
|
|
510
|
+
/**
|
|
511
|
+
* Describes the message agent.v1.CursorRuleTypeGlobal.
|
|
512
|
+
* Use `create(CursorRuleTypeGlobalSchema)` to create a new message.
|
|
513
|
+
*/
|
|
514
|
+
const CursorRuleTypeGlobalSchema = /*@__PURE__*/ messageDesc(file_agent, 181);
|
|
515
|
+
/**
|
|
516
|
+
* Describes the message agent.v1.CursorRuleType.
|
|
517
|
+
* Use `create(CursorRuleTypeSchema)` to create a new message.
|
|
518
|
+
*/
|
|
519
|
+
const CursorRuleTypeSchema = /*@__PURE__*/ messageDesc(file_agent, 185);
|
|
520
|
+
/**
|
|
521
|
+
* Describes the message agent.v1.CursorRule.
|
|
522
|
+
* Use `create(CursorRuleSchema)` to create a new message.
|
|
523
|
+
*/
|
|
524
|
+
const CursorRuleSchema = /*@__PURE__*/ messageDesc(file_agent, 186);
|
|
525
|
+
/**
|
|
526
|
+
* Describes the message agent.v1.DeleteResult.
|
|
527
|
+
* Use `create(DeleteResultSchema)` to create a new message.
|
|
528
|
+
*/
|
|
529
|
+
const DeleteResultSchema = /*@__PURE__*/ messageDesc(file_agent, 188);
|
|
530
|
+
/**
|
|
531
|
+
* Describes the message agent.v1.DeleteRejected.
|
|
532
|
+
* Use `create(DeleteRejectedSchema)` to create a new message.
|
|
533
|
+
*/
|
|
534
|
+
const DeleteRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 194);
|
|
535
|
+
/**
|
|
536
|
+
* Describes the message agent.v1.DiagnosticsResult.
|
|
537
|
+
* Use `create(DiagnosticsResultSchema)` to create a new message.
|
|
538
|
+
*/
|
|
539
|
+
const DiagnosticsResultSchema = /*@__PURE__*/ messageDesc(file_agent, 198);
|
|
540
|
+
/**
|
|
541
|
+
* Describes the message agent.v1.DiagnosticsRejected.
|
|
542
|
+
* Use `create(DiagnosticsRejectedSchema)` to create a new message.
|
|
543
|
+
*/
|
|
544
|
+
const DiagnosticsRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 202);
|
|
545
|
+
/**
|
|
480
546
|
* Describes the message agent.v1.ExecClientThrow.
|
|
481
547
|
* Use `create(ExecClientThrowSchema)` to create a new message.
|
|
482
548
|
*/
|
|
@@ -492,6 +558,26 @@ const ExecClientControlMessageSchema = /*@__PURE__*/ messageDesc(file_agent, 240
|
|
|
492
558
|
*/
|
|
493
559
|
const ExecClientMessageSchema = /*@__PURE__*/ messageDesc(file_agent, 245);
|
|
494
560
|
/**
|
|
561
|
+
* Describes the message agent.v1.FetchResult.
|
|
562
|
+
* Use `create(FetchResultSchema)` to create a new message.
|
|
563
|
+
*/
|
|
564
|
+
const FetchResultSchema = /*@__PURE__*/ messageDesc(file_agent, 247);
|
|
565
|
+
/**
|
|
566
|
+
* Describes the message agent.v1.FetchError.
|
|
567
|
+
* Use `create(FetchErrorSchema)` to create a new message.
|
|
568
|
+
*/
|
|
569
|
+
const FetchErrorSchema = /*@__PURE__*/ messageDesc(file_agent, 249);
|
|
570
|
+
/**
|
|
571
|
+
* Describes the message agent.v1.GrepResult.
|
|
572
|
+
* Use `create(GrepResultSchema)` to create a new message.
|
|
573
|
+
*/
|
|
574
|
+
const GrepResultSchema = /*@__PURE__*/ messageDesc(file_agent, 256);
|
|
575
|
+
/**
|
|
576
|
+
* Describes the message agent.v1.GrepError.
|
|
577
|
+
* Use `create(GrepErrorSchema)` to create a new message.
|
|
578
|
+
*/
|
|
579
|
+
const GrepErrorSchema = /*@__PURE__*/ messageDesc(file_agent, 257);
|
|
580
|
+
/**
|
|
495
581
|
* Describes the message agent.v1.GetBlobResult.
|
|
496
582
|
* Use `create(GetBlobResultSchema)` to create a new message.
|
|
497
583
|
*/
|
|
@@ -507,6 +593,16 @@ const SetBlobResultSchema = /*@__PURE__*/ messageDesc(file_agent, 271);
|
|
|
507
593
|
*/
|
|
508
594
|
const KvClientMessageSchema = /*@__PURE__*/ messageDesc(file_agent, 273);
|
|
509
595
|
/**
|
|
596
|
+
* Describes the message agent.v1.LsResult.
|
|
597
|
+
* Use `create(LsResultSchema)` to create a new message.
|
|
598
|
+
*/
|
|
599
|
+
const LsResultSchema = /*@__PURE__*/ messageDesc(file_agent, 275);
|
|
600
|
+
/**
|
|
601
|
+
* Describes the message agent.v1.LsRejected.
|
|
602
|
+
* Use `create(LsRejectedSchema)` to create a new message.
|
|
603
|
+
*/
|
|
604
|
+
const LsRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 280);
|
|
605
|
+
/**
|
|
510
606
|
* Describes the message agent.v1.McpArgs.
|
|
511
607
|
* Use `create(McpArgsSchema)` to create a new message.
|
|
512
608
|
*/
|
|
@@ -527,6 +623,26 @@ const McpToolResultContentItemSchema = /*@__PURE__*/ messageDesc(file_agent, 290
|
|
|
527
623
|
*/
|
|
528
624
|
const McpSuccessSchema = /*@__PURE__*/ messageDesc(file_agent, 291);
|
|
529
625
|
/**
|
|
626
|
+
* Describes the message agent.v1.ListMcpResourcesExecResult.
|
|
627
|
+
* Use `create(ListMcpResourcesExecResultSchema)` to create a new message.
|
|
628
|
+
*/
|
|
629
|
+
const ListMcpResourcesExecResultSchema = /*@__PURE__*/ messageDesc(file_agent, 296);
|
|
630
|
+
/**
|
|
631
|
+
* Describes the message agent.v1.ListMcpResourcesRejected.
|
|
632
|
+
* Use `create(ListMcpResourcesRejectedSchema)` to create a new message.
|
|
633
|
+
*/
|
|
634
|
+
const ListMcpResourcesRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 300);
|
|
635
|
+
/**
|
|
636
|
+
* Describes the message agent.v1.ReadMcpResourceExecResult.
|
|
637
|
+
* Use `create(ReadMcpResourceExecResultSchema)` to create a new message.
|
|
638
|
+
*/
|
|
639
|
+
const ReadMcpResourceExecResultSchema = /*@__PURE__*/ messageDesc(file_agent, 302);
|
|
640
|
+
/**
|
|
641
|
+
* Describes the message agent.v1.ReadMcpResourceRejected.
|
|
642
|
+
* Use `create(ReadMcpResourceRejectedSchema)` to create a new message.
|
|
643
|
+
*/
|
|
644
|
+
const ReadMcpResourceRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 305);
|
|
645
|
+
/**
|
|
530
646
|
* Describes the message agent.v1.McpToolDefinition.
|
|
531
647
|
* Use `create(McpToolDefinitionSchema)` to create a new message.
|
|
532
648
|
*/
|
|
@@ -537,6 +653,26 @@ const McpToolDefinitionSchema = /*@__PURE__*/ messageDesc(file_agent, 307);
|
|
|
537
653
|
*/
|
|
538
654
|
const McpToolsSchema = /*@__PURE__*/ messageDesc(file_agent, 308);
|
|
539
655
|
/**
|
|
656
|
+
* Describes the message agent.v1.ReadResult.
|
|
657
|
+
* Use `create(ReadResultSchema)` to create a new message.
|
|
658
|
+
*/
|
|
659
|
+
const ReadResultSchema = /*@__PURE__*/ messageDesc(file_agent, 314);
|
|
660
|
+
/**
|
|
661
|
+
* Describes the message agent.v1.ReadRejected.
|
|
662
|
+
* Use `create(ReadRejectedSchema)` to create a new message.
|
|
663
|
+
*/
|
|
664
|
+
const ReadRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 317);
|
|
665
|
+
/**
|
|
666
|
+
* Describes the message agent.v1.RecordScreenResult.
|
|
667
|
+
* Use `create(RecordScreenResultSchema)` to create a new message.
|
|
668
|
+
*/
|
|
669
|
+
const RecordScreenResultSchema = /*@__PURE__*/ messageDesc(file_agent, 328);
|
|
670
|
+
/**
|
|
671
|
+
* Describes the message agent.v1.RecordScreenFailure.
|
|
672
|
+
* Use `create(RecordScreenFailureSchema)` to create a new message.
|
|
673
|
+
*/
|
|
674
|
+
const RecordScreenFailureSchema = /*@__PURE__*/ messageDesc(file_agent, 332);
|
|
675
|
+
/**
|
|
540
676
|
* Describes the message agent.v1.RequestContextResult.
|
|
541
677
|
* Use `create(RequestContextResultSchema)` to create a new message.
|
|
542
678
|
*/
|
|
@@ -562,6 +698,21 @@ const RequestContextSchema = /*@__PURE__*/ messageDesc(file_agent, 348);
|
|
|
562
698
|
*/
|
|
563
699
|
const SelectedContextSchema = /*@__PURE__*/ messageDesc(file_agent, 374);
|
|
564
700
|
/**
|
|
701
|
+
* Describes the message agent.v1.ShellResult.
|
|
702
|
+
* Use `create(ShellResultSchema)` to create a new message.
|
|
703
|
+
*/
|
|
704
|
+
const ShellResultSchema = /*@__PURE__*/ messageDesc(file_agent, 390);
|
|
705
|
+
/**
|
|
706
|
+
* Describes the message agent.v1.ShellStream.
|
|
707
|
+
* Use `create(ShellStreamSchema)` to create a new message.
|
|
708
|
+
*/
|
|
709
|
+
const ShellStreamSchema = /*@__PURE__*/ messageDesc(file_agent, 396);
|
|
710
|
+
/**
|
|
711
|
+
* Describes the message agent.v1.ShellRejected.
|
|
712
|
+
* Use `create(ShellRejectedSchema)` to create a new message.
|
|
713
|
+
*/
|
|
714
|
+
const ShellRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 401);
|
|
715
|
+
/**
|
|
565
716
|
* Describes the message agent.v1.WebSearchRequestResponse.
|
|
566
717
|
* Use `create(WebSearchRequestResponseSchema)` to create a new message.
|
|
567
718
|
*/
|
|
@@ -572,6 +723,16 @@ const WebSearchRequestResponseSchema = /*@__PURE__*/ messageDesc(file_agent, 447
|
|
|
572
723
|
*/
|
|
573
724
|
const WebSearchRequestResponse_ApprovedSchema = /*@__PURE__*/ messageDesc(file_agent, 448);
|
|
574
725
|
/**
|
|
726
|
+
* Describes the message agent.v1.WriteResult.
|
|
727
|
+
* Use `create(WriteResultSchema)` to create a new message.
|
|
728
|
+
*/
|
|
729
|
+
const WriteResultSchema = /*@__PURE__*/ messageDesc(file_agent, 451);
|
|
730
|
+
/**
|
|
731
|
+
* Describes the message agent.v1.WriteRejected.
|
|
732
|
+
* Use `create(WriteRejectedSchema)` to create a new message.
|
|
733
|
+
*/
|
|
734
|
+
const WriteRejectedSchema = /*@__PURE__*/ messageDesc(file_agent, 456);
|
|
735
|
+
/**
|
|
575
736
|
* @generated from enum agent.v1.AppliedAgentChange_ChangeType
|
|
576
737
|
*/
|
|
577
738
|
var AppliedAgentChange_ChangeType;
|
|
@@ -958,8 +1119,25 @@ var BugbotDeeplinkEventKind;
|
|
|
958
1119
|
/**
|
|
959
1120
|
* Rebuild one Cursor `AgentRunRequest` from harness history, system prompt, and MCP tools.
|
|
960
1121
|
*
|
|
1122
|
+
* Cursor's server builds the model prompt from `root_prompt_messages_json` and
|
|
1123
|
+
* never renders `conversation_state.turns` back into prompt messages, so this
|
|
1124
|
+
* module publishes the system prompt and every prior turn there as prompt
|
|
1125
|
+
* messages and keeps the turn structures for the server's own bookkeeping.
|
|
1126
|
+
*
|
|
961
1127
|
* @module @deepseek-ai/dsh-llm-cursor/request
|
|
962
1128
|
*/
|
|
1129
|
+
/**
|
|
1130
|
+
* User message sent after locally executed tool calls. A Run requires one user
|
|
1131
|
+
* message; the tool results themselves ride the root prompt as `tool` messages.
|
|
1132
|
+
*/
|
|
1133
|
+
const TOOL_RESULT_CONTINUATION_TEXT = "The results of your tool calls are in the tool messages above. Continue the task.";
|
|
1134
|
+
/**
|
|
1135
|
+
* Rule that tells the model Cursor's built-in tools answer with a rejection
|
|
1136
|
+
* here, so it calls the harness tools by their `mcp_dsh_` names instead.
|
|
1137
|
+
*/
|
|
1138
|
+
const NATIVE_TOOLS_RULE = `DeepSeek Harness runs this session. Cursor's built-in tools (read, write, edit, delete, ls, grep, shell, fetch, diagnostics, and the rest) are not available: calling one returns a rejection and does nothing. Use only the tools whose names start with ${MCP_PROMPT_TOOL_PREFIX}, for example ${MCP_PROMPT_TOOL_PREFIX}read instead of read.`;
|
|
1139
|
+
/** Rule path Cursor shows beside {@link NATIVE_TOOLS_RULE}. */
|
|
1140
|
+
const ADAPTER_RULE_PATH = "dsh/cursor-adapter";
|
|
963
1141
|
function textOf(message) {
|
|
964
1142
|
return message.content.map((block) => {
|
|
965
1143
|
if (block.type === "text") return block.text;
|
|
@@ -1071,14 +1249,16 @@ function createUserMessage(text, selectedContextBlob) {
|
|
|
1071
1249
|
});
|
|
1072
1250
|
}
|
|
1073
1251
|
/**
|
|
1074
|
-
* Split harness messages into
|
|
1252
|
+
* Split harness messages into Cursor turns plus the action for this Run.
|
|
1075
1253
|
*
|
|
1076
1254
|
* Consecutive user-role messages with no assistant steps between them join in
|
|
1077
1255
|
* order into one Cursor user text. A Run has a single `userMessageAction`, so
|
|
1078
1256
|
* runtime-context snapshots and skill catalogs that follow the human prompt
|
|
1079
|
-
* ride that action instead of replacing it.
|
|
1257
|
+
* ride that action instead of replacing it. History that ends in assistant
|
|
1258
|
+
* steps, normally tool calls plus their local results, carries no new user
|
|
1259
|
+
* text and becomes a `continue` action.
|
|
1080
1260
|
* @param options - assembled model request.
|
|
1081
|
-
* @returns
|
|
1261
|
+
* @returns turns to replay and the Run action.
|
|
1082
1262
|
*/
|
|
1083
1263
|
function conversationFromOptions(options) {
|
|
1084
1264
|
const messages = [...options.messages];
|
|
@@ -1138,36 +1318,152 @@ function conversationFromOptions(options) {
|
|
|
1138
1318
|
const last = turns[turns.length - 1];
|
|
1139
1319
|
if (last === void 0) return {
|
|
1140
1320
|
systemPrompt,
|
|
1141
|
-
|
|
1142
|
-
|
|
1321
|
+
turns: [],
|
|
1322
|
+
action: {
|
|
1323
|
+
kind: "userMessage",
|
|
1324
|
+
text: ""
|
|
1325
|
+
}
|
|
1143
1326
|
};
|
|
1144
1327
|
if (last.steps.length === 0) return {
|
|
1145
1328
|
systemPrompt,
|
|
1146
|
-
|
|
1147
|
-
|
|
1329
|
+
turns: turns.slice(0, -1),
|
|
1330
|
+
action: {
|
|
1331
|
+
kind: "userMessage",
|
|
1332
|
+
text: last.userText
|
|
1333
|
+
}
|
|
1148
1334
|
};
|
|
1149
1335
|
return {
|
|
1150
1336
|
systemPrompt,
|
|
1151
|
-
|
|
1152
|
-
|
|
1337
|
+
turns,
|
|
1338
|
+
action: { kind: "continue" }
|
|
1153
1339
|
};
|
|
1154
1340
|
}
|
|
1155
1341
|
/**
|
|
1342
|
+
* Rules Cursor renders inside its own system prompt when the Run asks for the
|
|
1343
|
+
* request context. Only {@link NATIVE_TOOLS_RULE} travels here: a rule carrying
|
|
1344
|
+
* the harness system prompt lost its always-apply instructions once replayed
|
|
1345
|
+
* history was present, while the `<rules>` user prompt message kept them.
|
|
1346
|
+
* @returns the adapter's global rule.
|
|
1347
|
+
*/
|
|
1348
|
+
function buildRules() {
|
|
1349
|
+
return [create(CursorRuleSchema, {
|
|
1350
|
+
fullPath: ADAPTER_RULE_PATH,
|
|
1351
|
+
content: NATIVE_TOOLS_RULE,
|
|
1352
|
+
source: 0,
|
|
1353
|
+
type: create(CursorRuleTypeSchema, { type: {
|
|
1354
|
+
case: "global",
|
|
1355
|
+
value: create(CursorRuleTypeGlobalSchema, {})
|
|
1356
|
+
} })
|
|
1357
|
+
})];
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Render the system prompt and prior turns as the prompt messages Cursor shows
|
|
1361
|
+
* the model. The system prompt becomes a `<rules>` user message because the
|
|
1362
|
+
* server discards `system` entries in favour of its own prompt. Each turn
|
|
1363
|
+
* becomes a `<user_query>` user message, assistant messages holding text and
|
|
1364
|
+
* `tool-call` parts, and `tool` messages holding the results, with MCP tools
|
|
1365
|
+
* named `mcp_dsh_<tool>` as Cursor names them. Thinking is not replayed.
|
|
1366
|
+
* @param systemPrompt - rendered harness system prompt; `''` adds no rules.
|
|
1367
|
+
* @param turns - turns to replay, oldest first.
|
|
1368
|
+
* @returns prompt messages in order.
|
|
1369
|
+
*/
|
|
1370
|
+
function buildPromptMessages(systemPrompt, turns) {
|
|
1371
|
+
const messages = [];
|
|
1372
|
+
if (systemPrompt.trim().length > 0) messages.push({
|
|
1373
|
+
role: "user",
|
|
1374
|
+
content: [{
|
|
1375
|
+
type: "text",
|
|
1376
|
+
text: `<rules>\n${systemPrompt}\n</rules>`
|
|
1377
|
+
}]
|
|
1378
|
+
});
|
|
1379
|
+
for (const turn of turns) {
|
|
1380
|
+
const query = turn.userText.trim();
|
|
1381
|
+
if (query.length > 0) messages.push({
|
|
1382
|
+
role: "user",
|
|
1383
|
+
content: [{
|
|
1384
|
+
type: "text",
|
|
1385
|
+
text: `<user_query>\n${query}\n</user_query>`
|
|
1386
|
+
}]
|
|
1387
|
+
});
|
|
1388
|
+
let assistant = [];
|
|
1389
|
+
let results = [];
|
|
1390
|
+
const flush = () => {
|
|
1391
|
+
if (assistant.length > 0) messages.push({
|
|
1392
|
+
role: "assistant",
|
|
1393
|
+
content: assistant
|
|
1394
|
+
});
|
|
1395
|
+
if (results.length > 0) messages.push({
|
|
1396
|
+
role: "tool",
|
|
1397
|
+
content: results
|
|
1398
|
+
});
|
|
1399
|
+
assistant = [];
|
|
1400
|
+
results = [];
|
|
1401
|
+
};
|
|
1402
|
+
for (const step of turn.steps) {
|
|
1403
|
+
if (step.kind === "thinking") continue;
|
|
1404
|
+
if (step.kind === "assistantText") {
|
|
1405
|
+
if (step.text.length === 0) continue;
|
|
1406
|
+
if (results.length > 0) flush();
|
|
1407
|
+
assistant.push({
|
|
1408
|
+
type: "text",
|
|
1409
|
+
text: step.text
|
|
1410
|
+
});
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1413
|
+
const toolName = `${MCP_PROMPT_TOOL_PREFIX}${step.toolName}`;
|
|
1414
|
+
assistant.push({
|
|
1415
|
+
type: "tool-call",
|
|
1416
|
+
toolCallId: step.toolCallId,
|
|
1417
|
+
toolName,
|
|
1418
|
+
args: step.arguments
|
|
1419
|
+
});
|
|
1420
|
+
if (step.result !== void 0) results.push({
|
|
1421
|
+
type: "tool-result",
|
|
1422
|
+
toolCallId: step.toolCallId,
|
|
1423
|
+
toolName,
|
|
1424
|
+
result: step.result.content,
|
|
1425
|
+
...step.result.isError ? { isError: true } : {}
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
flush();
|
|
1429
|
+
}
|
|
1430
|
+
return messages;
|
|
1431
|
+
}
|
|
1432
|
+
function estimateInputTokens(rules, promptMessages, actionText, mcpTools) {
|
|
1433
|
+
let chars = actionText.length;
|
|
1434
|
+
for (const rule of rules) chars += rule.content.length;
|
|
1435
|
+
for (const message of promptMessages) chars += JSON.stringify(message).length;
|
|
1436
|
+
for (const tool of mcpTools) chars += tool.name.length + tool.description.length + tool.inputSchema.byteLength;
|
|
1437
|
+
return Math.ceil(chars / 4);
|
|
1438
|
+
}
|
|
1439
|
+
function actionText(action) {
|
|
1440
|
+
switch (action.kind) {
|
|
1441
|
+
case "userMessage": return action.text;
|
|
1442
|
+
case "continue": return TOOL_RESULT_CONTINUATION_TEXT;
|
|
1443
|
+
/* v8 ignore next -- CursorRunAction is closed; the compiler owns exhaustiveness. */
|
|
1444
|
+
default: return assertNever(action, "CursorRunAction");
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1156
1448
|
* Encode one rebuilt Run from a harness request.
|
|
1157
1449
|
* @param options - assembled model request.
|
|
1158
1450
|
* @returns protobuf bytes and the blob store.
|
|
1159
1451
|
*/
|
|
1160
1452
|
function buildCursorRun(options) {
|
|
1161
|
-
const { systemPrompt,
|
|
1453
|
+
const { systemPrompt, turns, action } = conversationFromOptions(options);
|
|
1162
1454
|
const mcpTools = buildMcpToolDefinitions(options.tools);
|
|
1163
1455
|
const blobStore = /* @__PURE__ */ new Map();
|
|
1164
|
-
const
|
|
1456
|
+
const encoder = new TextEncoder();
|
|
1457
|
+
const systemBlobId = storeAsBlob(encoder.encode(JSON.stringify({
|
|
1165
1458
|
role: "system",
|
|
1166
1459
|
content: systemPrompt
|
|
1167
1460
|
})), blobStore);
|
|
1461
|
+
const rules = buildRules();
|
|
1462
|
+
const promptMessages = buildPromptMessages(systemPrompt, turns);
|
|
1463
|
+
const promptBlobIds = promptMessages.map((message) => storeAsBlob(encoder.encode(JSON.stringify(message)), blobStore));
|
|
1168
1464
|
const selectedCtxBlob = storeAsBlob(new Uint8Array(), blobStore);
|
|
1169
1465
|
const turnBlobIds = [];
|
|
1170
|
-
for (const turn of
|
|
1466
|
+
for (const turn of turns) {
|
|
1171
1467
|
const turnStructure = create(ConversationTurnStructureSchema, { turn: {
|
|
1172
1468
|
case: "agentConversationTurn",
|
|
1173
1469
|
value: create(AgentConversationTurnStructureSchema, {
|
|
@@ -1178,41 +1474,47 @@ function buildCursorRun(options) {
|
|
|
1178
1474
|
} });
|
|
1179
1475
|
turnBlobIds.push(storeAsBlob(toBinary(ConversationTurnStructureSchema, turnStructure), blobStore));
|
|
1180
1476
|
}
|
|
1477
|
+
const conversationState = create(ConversationStateStructureSchema, {
|
|
1478
|
+
rootPromptMessagesJson: [systemBlobId, ...promptBlobIds],
|
|
1479
|
+
turns: turnBlobIds,
|
|
1480
|
+
todos: [],
|
|
1481
|
+
pendingToolCalls: [],
|
|
1482
|
+
previousWorkspaceUris: [pathToFileURL(process.cwd()).href],
|
|
1483
|
+
mode: 1,
|
|
1484
|
+
fileStates: {},
|
|
1485
|
+
fileStatesV2: {},
|
|
1486
|
+
summaryArchives: [],
|
|
1487
|
+
turnTimings: [],
|
|
1488
|
+
subagentStates: {},
|
|
1489
|
+
selfSummaryCount: 0,
|
|
1490
|
+
readPaths: [],
|
|
1491
|
+
clientName: "dsh"
|
|
1492
|
+
});
|
|
1493
|
+
const text = actionText(action);
|
|
1494
|
+
const userMessage = createUserMessage(text, selectedCtxBlob);
|
|
1495
|
+
const requestedModel = create(RequestedModelSchema, {
|
|
1496
|
+
modelId: options.model,
|
|
1497
|
+
maxMode: false,
|
|
1498
|
+
parameters: []
|
|
1499
|
+
});
|
|
1181
1500
|
return {
|
|
1182
1501
|
requestBytes: toBinary(AgentClientMessageSchema, create(AgentClientMessageSchema, { message: {
|
|
1183
1502
|
case: "runRequest",
|
|
1184
1503
|
value: create(AgentRunRequestSchema, {
|
|
1185
|
-
conversationState
|
|
1186
|
-
rootPromptMessagesJson: [systemBlobId],
|
|
1187
|
-
turns: turnBlobIds,
|
|
1188
|
-
todos: [],
|
|
1189
|
-
pendingToolCalls: [],
|
|
1190
|
-
previousWorkspaceUris: [pathToFileURL(process.cwd()).href],
|
|
1191
|
-
mode: 1,
|
|
1192
|
-
fileStates: {},
|
|
1193
|
-
fileStatesV2: {},
|
|
1194
|
-
summaryArchives: [],
|
|
1195
|
-
turnTimings: [],
|
|
1196
|
-
subagentStates: {},
|
|
1197
|
-
selfSummaryCount: 0,
|
|
1198
|
-
readPaths: [],
|
|
1199
|
-
clientName: "dsh"
|
|
1200
|
-
}),
|
|
1504
|
+
conversationState,
|
|
1201
1505
|
action: create(ConversationActionSchema, { action: {
|
|
1202
1506
|
case: "userMessageAction",
|
|
1203
|
-
value: create(UserMessageActionSchema, { userMessage
|
|
1507
|
+
value: create(UserMessageActionSchema, { userMessage })
|
|
1204
1508
|
} }),
|
|
1205
|
-
requestedModel
|
|
1206
|
-
modelId: options.model,
|
|
1207
|
-
maxMode: false,
|
|
1208
|
-
parameters: []
|
|
1209
|
-
}),
|
|
1509
|
+
requestedModel,
|
|
1210
1510
|
conversationId: options.sessionId ?? randomUUID(),
|
|
1211
1511
|
mcpTools: create(McpToolsSchema, { mcpTools })
|
|
1212
1512
|
})
|
|
1213
1513
|
} })),
|
|
1214
1514
|
blobStore,
|
|
1215
|
-
mcpTools
|
|
1515
|
+
mcpTools,
|
|
1516
|
+
rules,
|
|
1517
|
+
inputTokenEstimate: estimateInputTokens(rules, promptMessages, text, mcpTools)
|
|
1216
1518
|
};
|
|
1217
1519
|
}
|
|
1218
1520
|
/**
|
|
@@ -1332,12 +1634,13 @@ function answerKv(stream, kv, blobStore) {
|
|
|
1332
1634
|
}
|
|
1333
1635
|
throw new LlmError("llm-cursor: unanswered Cursor KV message", "STREAM_CLOSED");
|
|
1334
1636
|
}
|
|
1335
|
-
function answerRequestContext(stream, exec,
|
|
1637
|
+
function answerRequestContext(stream, exec, payload) {
|
|
1638
|
+
const env = create(RequestContextEnvSchema, { workspacePaths: [pathToFileURL(process.cwd()).href] });
|
|
1336
1639
|
const requestContext = create(RequestContextSchema, {
|
|
1337
|
-
rules:
|
|
1338
|
-
env
|
|
1640
|
+
rules: payload.rules,
|
|
1641
|
+
env,
|
|
1339
1642
|
repositoryInfo: [],
|
|
1340
|
-
tools: mcpTools,
|
|
1643
|
+
tools: payload.mcpTools,
|
|
1341
1644
|
gitRepos: [],
|
|
1342
1645
|
projectLayouts: [],
|
|
1343
1646
|
mcpInstructions: [],
|
|
@@ -1359,14 +1662,197 @@ function answerRequestContext(stream, exec, mcpTools) {
|
|
|
1359
1662
|
})
|
|
1360
1663
|
} });
|
|
1361
1664
|
}
|
|
1362
|
-
|
|
1665
|
+
/** Harness tools that stand in for each Cursor-native exec, in preference order. */
|
|
1666
|
+
const NATIVE_TOOL_ALTERNATIVES = {
|
|
1667
|
+
readArgs: ["read"],
|
|
1668
|
+
lsArgs: ["glob"],
|
|
1669
|
+
grepArgs: ["grep"],
|
|
1670
|
+
writeArgs: ["write", "edit"],
|
|
1671
|
+
deleteArgs: ["bash", "pwsh"],
|
|
1672
|
+
shellArgs: ["bash", "pwsh"],
|
|
1673
|
+
shellStreamArgs: ["bash", "pwsh"],
|
|
1674
|
+
backgroundShellSpawnArgs: ["bash", "pwsh"],
|
|
1675
|
+
writeShellStdinArgs: ["bash", "pwsh"],
|
|
1676
|
+
fetchArgs: ["web_fetch"],
|
|
1677
|
+
diagnosticsArgs: ["lsp"],
|
|
1678
|
+
listMcpResourcesExecArgs: ["list_mcp_resources"],
|
|
1679
|
+
readMcpResourceExecArgs: ["read_mcp_resource"]
|
|
1680
|
+
};
|
|
1681
|
+
function nativeRejectionReason(execCase, mcpTools) {
|
|
1682
|
+
const offered = new Set(mcpTools.map((tool) => tool.name));
|
|
1683
|
+
const alternative = (NATIVE_TOOL_ALTERNATIVES[execCase] ?? []).find((name) => offered.has(name));
|
|
1684
|
+
const refusal = `Cursor's built-in ${execCase.replace(/Args$/, "")} tool is not available in DeepSeek Harness.`;
|
|
1685
|
+
return alternative === void 0 ? `${refusal} Use the tools whose names start with ${MCP_PROMPT_TOOL_PREFIX} instead.` : `${refusal} Call the ${MCP_PROMPT_TOOL_PREFIX}${alternative} tool instead.`;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* The typed rejection one Cursor-native exec expects, so the Run stays alive
|
|
1689
|
+
* and the model reads the reason as a tool outcome. Unknown execs, which
|
|
1690
|
+
* signal wire drift, get no reply here.
|
|
1691
|
+
*/
|
|
1692
|
+
function nativeRejection(exec, reason) {
|
|
1693
|
+
const args = exec.message;
|
|
1694
|
+
const shellRejected = (command, workingDirectory) => create(ShellRejectedSchema, {
|
|
1695
|
+
command,
|
|
1696
|
+
workingDirectory,
|
|
1697
|
+
reason,
|
|
1698
|
+
isReadonly: false
|
|
1699
|
+
});
|
|
1700
|
+
switch (args.case) {
|
|
1701
|
+
case "shellArgs": return {
|
|
1702
|
+
case: "shellResult",
|
|
1703
|
+
value: create(ShellResultSchema, { result: {
|
|
1704
|
+
case: "rejected",
|
|
1705
|
+
value: shellRejected(args.value.command, args.value.workingDirectory)
|
|
1706
|
+
} })
|
|
1707
|
+
};
|
|
1708
|
+
case "shellStreamArgs": return {
|
|
1709
|
+
case: "shellStream",
|
|
1710
|
+
value: create(ShellStreamSchema, { event: {
|
|
1711
|
+
case: "rejected",
|
|
1712
|
+
value: shellRejected(args.value.command, args.value.workingDirectory)
|
|
1713
|
+
} })
|
|
1714
|
+
};
|
|
1715
|
+
case "backgroundShellSpawnArgs": return {
|
|
1716
|
+
case: "backgroundShellSpawnResult",
|
|
1717
|
+
value: create(BackgroundShellSpawnResultSchema, { result: {
|
|
1718
|
+
case: "rejected",
|
|
1719
|
+
value: shellRejected(args.value.command, args.value.workingDirectory)
|
|
1720
|
+
} })
|
|
1721
|
+
};
|
|
1722
|
+
case "writeShellStdinArgs": return {
|
|
1723
|
+
case: "writeShellStdinResult",
|
|
1724
|
+
value: create(WriteShellStdinResultSchema, { result: {
|
|
1725
|
+
case: "error",
|
|
1726
|
+
value: create(WriteShellStdinErrorSchema, { error: reason })
|
|
1727
|
+
} })
|
|
1728
|
+
};
|
|
1729
|
+
case "writeArgs": return {
|
|
1730
|
+
case: "writeResult",
|
|
1731
|
+
value: create(WriteResultSchema, { result: {
|
|
1732
|
+
case: "rejected",
|
|
1733
|
+
value: create(WriteRejectedSchema, {
|
|
1734
|
+
path: args.value.path,
|
|
1735
|
+
reason
|
|
1736
|
+
})
|
|
1737
|
+
} })
|
|
1738
|
+
};
|
|
1739
|
+
case "deleteArgs": return {
|
|
1740
|
+
case: "deleteResult",
|
|
1741
|
+
value: create(DeleteResultSchema, { result: {
|
|
1742
|
+
case: "rejected",
|
|
1743
|
+
value: create(DeleteRejectedSchema, {
|
|
1744
|
+
path: args.value.path,
|
|
1745
|
+
reason
|
|
1746
|
+
})
|
|
1747
|
+
} })
|
|
1748
|
+
};
|
|
1749
|
+
case "grepArgs": return {
|
|
1750
|
+
case: "grepResult",
|
|
1751
|
+
value: create(GrepResultSchema, { result: {
|
|
1752
|
+
case: "error",
|
|
1753
|
+
value: create(GrepErrorSchema, { error: reason })
|
|
1754
|
+
} })
|
|
1755
|
+
};
|
|
1756
|
+
case "readArgs": return {
|
|
1757
|
+
case: "readResult",
|
|
1758
|
+
value: create(ReadResultSchema, { result: {
|
|
1759
|
+
case: "rejected",
|
|
1760
|
+
value: create(ReadRejectedSchema, {
|
|
1761
|
+
path: args.value.path,
|
|
1762
|
+
reason
|
|
1763
|
+
})
|
|
1764
|
+
} })
|
|
1765
|
+
};
|
|
1766
|
+
case "lsArgs": return {
|
|
1767
|
+
case: "lsResult",
|
|
1768
|
+
value: create(LsResultSchema, { result: {
|
|
1769
|
+
case: "rejected",
|
|
1770
|
+
value: create(LsRejectedSchema, {
|
|
1771
|
+
path: args.value.path,
|
|
1772
|
+
reason
|
|
1773
|
+
})
|
|
1774
|
+
} })
|
|
1775
|
+
};
|
|
1776
|
+
case "diagnosticsArgs": return {
|
|
1777
|
+
case: "diagnosticsResult",
|
|
1778
|
+
value: create(DiagnosticsResultSchema, { result: {
|
|
1779
|
+
case: "rejected",
|
|
1780
|
+
value: create(DiagnosticsRejectedSchema, {
|
|
1781
|
+
path: args.value.path,
|
|
1782
|
+
reason
|
|
1783
|
+
})
|
|
1784
|
+
} })
|
|
1785
|
+
};
|
|
1786
|
+
case "listMcpResourcesExecArgs": return {
|
|
1787
|
+
case: "listMcpResourcesExecResult",
|
|
1788
|
+
value: create(ListMcpResourcesExecResultSchema, { result: {
|
|
1789
|
+
case: "rejected",
|
|
1790
|
+
value: create(ListMcpResourcesRejectedSchema, { reason })
|
|
1791
|
+
} })
|
|
1792
|
+
};
|
|
1793
|
+
case "readMcpResourceExecArgs": return {
|
|
1794
|
+
case: "readMcpResourceExecResult",
|
|
1795
|
+
value: create(ReadMcpResourceExecResultSchema, { result: {
|
|
1796
|
+
case: "rejected",
|
|
1797
|
+
value: create(ReadMcpResourceRejectedSchema, {
|
|
1798
|
+
uri: args.value.uri,
|
|
1799
|
+
reason
|
|
1800
|
+
})
|
|
1801
|
+
} })
|
|
1802
|
+
};
|
|
1803
|
+
case "fetchArgs": return {
|
|
1804
|
+
case: "fetchResult",
|
|
1805
|
+
value: create(FetchResultSchema, { result: {
|
|
1806
|
+
case: "error",
|
|
1807
|
+
value: create(FetchErrorSchema, {
|
|
1808
|
+
url: args.value.url,
|
|
1809
|
+
error: reason
|
|
1810
|
+
})
|
|
1811
|
+
} })
|
|
1812
|
+
};
|
|
1813
|
+
case "recordScreenArgs": return {
|
|
1814
|
+
case: "recordScreenResult",
|
|
1815
|
+
value: create(RecordScreenResultSchema, { result: {
|
|
1816
|
+
case: "failure",
|
|
1817
|
+
value: create(RecordScreenFailureSchema, { error: reason })
|
|
1818
|
+
} })
|
|
1819
|
+
};
|
|
1820
|
+
case "computerUseArgs": return {
|
|
1821
|
+
case: "computerUseResult",
|
|
1822
|
+
value: create(ComputerUseResultSchema, { result: {
|
|
1823
|
+
case: "error",
|
|
1824
|
+
value: create(ComputerUseErrorSchema, {
|
|
1825
|
+
error: reason,
|
|
1826
|
+
actionCount: args.value.actions.length,
|
|
1827
|
+
durationMs: 0
|
|
1828
|
+
})
|
|
1829
|
+
} })
|
|
1830
|
+
};
|
|
1831
|
+
default: return;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
/** Answer a Cursor-native exec with its typed rejection; false when the exec is unknown. */
|
|
1835
|
+
function answerNativeExec(stream, exec, mcpTools) {
|
|
1836
|
+
const reply = nativeRejection(exec, nativeRejectionReason(exec.message.case ?? "", mcpTools));
|
|
1837
|
+
if (reply === void 0) return false;
|
|
1838
|
+
sendClient(stream, { message: {
|
|
1839
|
+
case: "execClientMessage",
|
|
1840
|
+
value: create(ExecClientMessageSchema, {
|
|
1841
|
+
id: exec.id,
|
|
1842
|
+
execId: exec.execId,
|
|
1843
|
+
message: reply
|
|
1844
|
+
})
|
|
1845
|
+
} });
|
|
1846
|
+
return true;
|
|
1847
|
+
}
|
|
1848
|
+
function rejectUnknownExec(stream, exec) {
|
|
1363
1849
|
sendClient(stream, { message: {
|
|
1364
1850
|
case: "execClientControlMessage",
|
|
1365
1851
|
value: create(ExecClientControlMessageSchema, { message: {
|
|
1366
1852
|
case: "throw",
|
|
1367
1853
|
value: create(ExecClientThrowSchema, {
|
|
1368
1854
|
id: exec.id,
|
|
1369
|
-
error: "This
|
|
1855
|
+
error: "This Cursor exec is not supported by DeepSeek Harness. Use the MCP tools provided instead."
|
|
1370
1856
|
})
|
|
1371
1857
|
} })
|
|
1372
1858
|
} });
|
|
@@ -1430,6 +1916,11 @@ function* emitToolCall(index, id, name, args) {
|
|
|
1430
1916
|
}
|
|
1431
1917
|
};
|
|
1432
1918
|
}
|
|
1919
|
+
/** The harness tool name behind one Cursor MCP exec; a model may echo the replayed `mcp_dsh_` form. */
|
|
1920
|
+
function harnessToolName(mcp) {
|
|
1921
|
+
const name = mcp.toolName.length > 0 ? mcp.toolName : mcp.name;
|
|
1922
|
+
return name.startsWith(MCP_PROMPT_TOOL_PREFIX) ? name.slice(MCP_PROMPT_TOOL_PREFIX.length) : name;
|
|
1923
|
+
}
|
|
1433
1924
|
function settledOnAbort$1(signal) {
|
|
1434
1925
|
return new Promise((_, reject) => {
|
|
1435
1926
|
const fail = () => {
|
|
@@ -1487,7 +1978,7 @@ async function* streamCursorRun(options, accessToken, idleTimeoutMs, openStream
|
|
|
1487
1978
|
throw error;
|
|
1488
1979
|
}
|
|
1489
1980
|
if (item.done) break;
|
|
1490
|
-
const chunks = handleServerMessage(fromBinary(AgentServerMessageSchema, item.value.payload), stream, payload
|
|
1981
|
+
const chunks = handleServerMessage(fromBinary(AgentServerMessageSchema, item.value.payload), stream, payload, {
|
|
1491
1982
|
nextIndex,
|
|
1492
1983
|
open,
|
|
1493
1984
|
outputTokens,
|
|
@@ -1503,7 +1994,7 @@ async function* streamCursorRun(options, accessToken, idleTimeoutMs, openStream
|
|
|
1503
1994
|
yield {
|
|
1504
1995
|
type: "usage",
|
|
1505
1996
|
usage: {
|
|
1506
|
-
inputTokens:
|
|
1997
|
+
inputTokens: payload.inputTokenEstimate,
|
|
1507
1998
|
outputTokens
|
|
1508
1999
|
}
|
|
1509
2000
|
};
|
|
@@ -1523,7 +2014,7 @@ async function* streamCursorRun(options, accessToken, idleTimeoutMs, openStream
|
|
|
1523
2014
|
__disposeResources(env_1);
|
|
1524
2015
|
}
|
|
1525
2016
|
}
|
|
1526
|
-
function handleServerMessage(message, stream,
|
|
2017
|
+
function handleServerMessage(message, stream, payload, state) {
|
|
1527
2018
|
const chunks = [];
|
|
1528
2019
|
let { nextIndex, open, outputTokens, sawContent } = state;
|
|
1529
2020
|
const msgCase = message.message.case;
|
|
@@ -1603,7 +2094,7 @@ function handleServerMessage(message, stream, blobStore, mcpTools, state) {
|
|
|
1603
2094
|
};
|
|
1604
2095
|
}
|
|
1605
2096
|
if (msgCase === "kvServerMessage") {
|
|
1606
|
-
answerKv(stream, message.message.value, blobStore);
|
|
2097
|
+
answerKv(stream, message.message.value, payload.blobStore);
|
|
1607
2098
|
return {
|
|
1608
2099
|
chunks,
|
|
1609
2100
|
nextIndex,
|
|
@@ -1616,7 +2107,7 @@ function handleServerMessage(message, stream, blobStore, mcpTools, state) {
|
|
|
1616
2107
|
const exec = message.message.value;
|
|
1617
2108
|
const execCase = exec.message.case;
|
|
1618
2109
|
if (execCase === "requestContextArgs") {
|
|
1619
|
-
answerRequestContext(stream, exec,
|
|
2110
|
+
answerRequestContext(stream, exec, payload);
|
|
1620
2111
|
return {
|
|
1621
2112
|
chunks,
|
|
1622
2113
|
nextIndex,
|
|
@@ -1627,10 +2118,9 @@ function handleServerMessage(message, stream, blobStore, mcpTools, state) {
|
|
|
1627
2118
|
}
|
|
1628
2119
|
if (execCase === "mcpArgs") {
|
|
1629
2120
|
const mcp = exec.message.value;
|
|
1630
|
-
const toolName = mcp.toolName.length > 0 ? mcp.toolName : mcp.name;
|
|
1631
2121
|
chunks.push(...closeOpen(open));
|
|
1632
2122
|
open = void 0;
|
|
1633
|
-
chunks.push(...emitToolCall(nextIndex, mcp.toolCallId || `cursor-${exec.id}`,
|
|
2123
|
+
chunks.push(...emitToolCall(nextIndex, mcp.toolCallId || `cursor-${exec.id}`, harnessToolName(mcp), decodeMcpArgsMap(mcp.args)));
|
|
1634
2124
|
nextIndex += 1;
|
|
1635
2125
|
sawContent = true;
|
|
1636
2126
|
return {
|
|
@@ -1645,8 +2135,15 @@ function handleServerMessage(message, stream, blobStore, mcpTools, state) {
|
|
|
1645
2135
|
}
|
|
1646
2136
|
};
|
|
1647
2137
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
2138
|
+
if (answerNativeExec(stream, exec, payload.mcpTools)) return {
|
|
2139
|
+
chunks,
|
|
2140
|
+
nextIndex,
|
|
2141
|
+
open,
|
|
2142
|
+
outputTokens,
|
|
2143
|
+
sawContent
|
|
2144
|
+
};
|
|
2145
|
+
rejectUnknownExec(stream, exec);
|
|
2146
|
+
throw new LlmError(`llm-cursor: Cursor exec "${execCase ?? "unknown"}" is not supported by this adapter`, "UNSUPPORTED_CONTENT");
|
|
1650
2147
|
}
|
|
1651
2148
|
if (msgCase === "interactionQuery") {
|
|
1652
2149
|
const query = message.message.value;
|