@songtonyli/dsh-cli 0.1.70 → 0.1.72
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/@aws-sdk/core/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
- package/node_modules/@aws-sdk/eventstream-handler-node/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-websocket/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +11 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +6 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +6 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +13 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +9 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/models/CognitoIdentityServiceException.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/models/errors.js +9 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/models/SigninServiceException.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/models/errors.js +4 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/models/SSOServiceException.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/models/errors.js +4 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/models/SSOOIDCServiceException.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/models/errors.js +11 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/STSServiceException.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/errors.js +7 -0
- package/node_modules/@aws-sdk/nested-clients/package.json +4 -4
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +4 -4
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.md +3 -3
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/README.zh.md +3 -3
- package/node_modules/@deepseek-ai/dsh-experimental-auto-review/lib/index.js +20 -18
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +6 -6
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +3 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +3 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +173 -40
- package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +53 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/package.json +17 -17
|
@@ -68,7 +68,7 @@ TUI:`/login llm-cursor/cursor`。无头不会打开浏览器;导出 `CURSOR_
|
|
|
68
68
|
|
|
69
69
|
新的 Run 由 harness 历史、系统提示和 MCP 工具定义重建(`providerIdentifier: dsh`,`clientName: dsh`)。Cursor 服务端只从 `root_prompt_messages_json` 构建模型提示,从不把 `conversation_state.turns` 渲染进去,并且会丢弃其中的 `{"role":"system"}` 条目而使用自己的提示。因此适配器把系统提示作为 `<rules>` user 提示消息发布,并把每个先前轮次重放为 `user`、`assistant` 和 `tool` 提示消息,把每个历史 harness 工具调用写成 Cursor 为 MCP 工具记录的 `CallDynamicTool` 调用;轮次结构一同发送,供服务端记账。Cursor CLI 的 Run 只通过 `GetDynamicTools` 和 `CallDynamicTool` 向模型暴露 MCP 工具,因此请求上下文的应答额外带一条全局 Cursor 规则,告知模型 Cursor 内建工具在这里会返回拒绝、harness 工具以命名空间 `dsh` 中的 `CallDynamicTool` 调用,以及有哪些工具名。
|
|
70
70
|
|
|
71
|
-
文本、thinking、用量与 MCP 工具调用变成 `StreamChunk`。当 Cursor 发出模型最后一个并行调用之后的检查点,或 `toolCallSettleMs` 内没有新帧时,MCP 工具调用结束该步。若请求带有 Session 且不是压缩或标题请求,该 Run 随后挂起:适配器每五秒发送一次 `clientHeartbeat` 保持流开启。该 Session 的下一次请求在以下条件成立时恢复它:最后一条 assistant 消息之前的历史不变,且该消息之后只有待处理调用的结果以及 harness 注入的 user 角色上下文;适配器在同一条流上以 `mcpResult` 应答每个调用,把这类上下文追加到最后一个结果之后,并继续读取。任何其他请求、挂起期间死亡的 Run,或超过 `parkedRunTimeoutMs` 的 Run,都回退为新的 Run:它重放该进行中的轮次及其结果,并把一条固定的继续提示作为 Run 必需的用户消息发送;不使用 `resumeAction`,因为服务端会从该轮的用户消息重新开始而不是继续。Cursor 原生或 CLI Pi 工作区 exec(`read`、`shell`、`piRead` 及同类)以其类型化的拒绝应答,并指出应通过 `CallDynamicTool` 调用的 harness 工具,因此 Run 继续进行,模型把该拒绝当作工具结果读取;被拒绝的 exec 之后的文本开启新的文本块。Cursor 原生提问会收到类型化的拒绝:若 harness 提供 `ask_user_question` MCP 工具,拒绝会引导模型调用该工具;否则会引导模型在回复中提问。Run 随后继续。网页搜索的批准查询会被批准,因为该搜索由 Cursor 在自己那一侧执行;网页抓取的批准查询会被拒绝,并带上 `fetch` exec 所携带的原因,因为获批的抓取会作为那个被拒绝的 exec 回到这里。CLI 钩子以空的匹配响应应答。MCP-state exec 返回已通告的 `dsh` 工具。本构建无法类型化的其他 exec 以 ExecClientThrow 应答,以便 Run 继续。没有 payload 的 exec 仍使该步失败。
|
|
71
|
+
文本、thinking、用量与 MCP 工具调用变成 `StreamChunk`。当 Cursor 发出模型最后一个并行调用之后的检查点,或 `toolCallSettleMs` 内没有新帧时,MCP 工具调用结束该步。若请求带有 Session 且不是压缩或标题请求,该 Run 随后挂起:适配器每五秒发送一次 `clientHeartbeat` 保持流开启。该 Session 的下一次请求在以下条件成立时恢复它:最后一条 assistant 消息之前的历史不变,且该消息之后只有待处理调用的结果以及 harness 注入的 user 角色上下文;适配器在同一条流上以 `mcpResult` 应答每个调用,把这类上下文追加到最后一个结果之后,并继续读取。任何其他请求、挂起期间死亡的 Run,或超过 `parkedRunTimeoutMs` 的 Run,都回退为新的 Run:它重放该进行中的轮次及其结果,并把一条固定的继续提示作为 Run 必需的用户消息发送;不使用 `resumeAction`,因为服务端会从该轮的用户消息重新开始而不是继续。Cursor 原生或 CLI Pi 工作区 exec(`read`、`shell`、`piRead` 及同类)以其类型化的拒绝应答,并指出应通过 `CallDynamicTool` 调用的 harness 工具,因此 Run 继续进行,模型把该拒绝当作工具结果读取;被拒绝的 exec 之后的文本开启新的文本块。Cursor 原生提问会收到类型化的拒绝:若 harness 提供 `ask_user_question` MCP 工具,拒绝会引导模型调用该工具;否则会引导模型在回复中提问。Run 随后继续。网页搜索的批准查询会被批准,因为该搜索由 Cursor 在自己那一侧执行;网页抓取的批准查询会被拒绝,并带上 `fetch` exec 所携带的原因,因为获批的抓取会作为那个被拒绝的 exec 回到这里。CLI 钩子以空的匹配响应应答。MCP-state exec 返回已通告的 `dsh` 工具。本构建无法类型化的其他 exec 以 ExecClientThrow 应答,以便 Run 继续。没有 payload 的 exec 仍使该步失败。Cursor 上的 Kimi 模型有时把其原生工具调用标记(`<|open|>toolscall tool="CallDynamicTool" …<|close|>tools<|sep|>`)作为文本写出,Cursor 服务端不解析它,于是该轮在没有 exec 的情况下结束。适配器从第一个 `<|open|>tools` 起暂扣文本,直到其文本块结束。若该轮结束时暂扣的尾部能完整解析为命名空间 `dsh` 中、指向已通告 harness 工具的 `CallDynamicTool` 调用,该尾部就变成工具调用块并以 `tool-calls` 结束该步,下一步打开一个由历史重建的新 Run;其他暂扣文本原样流出。
|
|
72
72
|
|
|
73
73
|
`LlmAdapter` 要求的归属头出现在每一次 HTTP/2 请求上,并带有 Cursor 客户端头 `x-ghost-mode`、`x-cursor-client-version` 和 `x-cursor-client-type`。
|
|
74
74
|
|
|
@@ -101,7 +101,7 @@ TUI:`/login llm-cursor/cursor`。无头不会打开浏览器;导出 `CURSOR_
|
|
|
101
101
|
|
|
102
102
|
#### 模型看见什么
|
|
103
103
|
|
|
104
|
-
文本增量、thinking 增量、token 用量和 MCP 工具调用变成 harness 分片。模型的并行调用到齐之后,MCP 工具调用以 `tool-calls`
|
|
104
|
+
文本增量、thinking 增量、token 用量和 MCP 工具调用变成 harness 分片。模型的并行调用到齐之后,MCP 工具调用以 `tool-calls` 结束该步。结束一轮的泄漏 `CallDynamicTool` 标记被记录为它所指定的工具调用而非文本,因此后续请求把它当作普通调用重放。原生或 CLI Pi 工作区 exec 以拒绝应答且流继续。CLI 钩子或 MCP-state exec 被应答以保持 Run 开启。本构建无法类型化的其他 exec 以 ExecClientThrow 应答且流继续。没有 payload 的 exec 使该轮失败。
|
|
105
105
|
|
|
106
106
|
#### Token 影响
|
|
107
107
|
|
|
@@ -122,6 +122,7 @@ TUI:`/login llm-cursor/cursor`。无头不会打开浏览器;导出 `CURSOR_
|
|
|
122
122
|
- **CLI 控制 exec 不运行 Cursor 钩子** — 钩子帧得到空的匹配响应,MCP-state 帧列出已通告的 `dsh` 工具,其他未命名 exec 以 ExecClientThrow 应答以使 Run 继续;它们都不执行工作区工作。
|
|
123
123
|
- **挂起的 Run 只存在于一个进程中** — 它没有 journal,因此进程重启、工具结果之后的人类消息或任何历史变化都会回退为由历史重建的新 Run。
|
|
124
124
|
- **回退的 Run 以重放的提示消息加一条固定继续提示交付工具结果** — 该提示是适配器自有的文本,人类从未输入过;恢复的 Run 把注入上下文放在最后一个工具结果内部交付,而不是作为独立消息。
|
|
125
|
+
- **泄漏工具调用的恢复只匹配一种已观察到的标记** — 只恢复位于轮次末尾的 Kimi `<|open|>tools` 形式;从该标记起的文本要到其文本块结束才流出,而以完整引用某个已通告工具的标记结束的回复会运行该工具。
|
|
125
126
|
- **不支持 `GenerateOptions.stop`** — 非官方 Run 不映射停止序列。
|
|
126
127
|
- **不发送图片字节** — 该路由声明只接受文本输入,因此每张图片以 harness 的纯文本占位符到达模型,而不是作为 Cursor 选中图片。
|
|
127
128
|
- **不映射 `maxTokens`、`temperature` 和 `reasoningEffort`** — Run 没有对应字段;努力程度通过 Cursor 模型 id 后缀(如 `-high`)选择。
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
2
2
|
import { LlmAdapter, LlmError, RetryPolicySchema, ToolCallId, assertUsableApiKey, attributionHeaders, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { create, fromBinary, fromJson, toBinary, toJson } from "@bufbuild/protobuf";
|
|
5
5
|
import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { ValueSchema } from "@bufbuild/protobuf/wkt";
|
|
8
|
-
import { randomUUID } from "@deepseek-ai/dsh-util-crypto";
|
|
8
|
+
import { randomUUID as randomUUID$1 } from "@deepseek-ai/dsh-util-crypto";
|
|
9
9
|
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
10
10
|
import { MAX_TIMER_DELAY_MS, idleWatchdog, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
11
11
|
import http2 from "node:http2";
|
|
@@ -1341,7 +1341,7 @@ function buildTurnStepBytes(step) {
|
|
|
1341
1341
|
} }));
|
|
1342
1342
|
}
|
|
1343
1343
|
function createUserMessage(text, selectedContextBlob) {
|
|
1344
|
-
const messageId = randomUUID();
|
|
1344
|
+
const messageId = randomUUID$1();
|
|
1345
1345
|
const message = create(UserMessageSchema, {
|
|
1346
1346
|
text,
|
|
1347
1347
|
messageId,
|
|
@@ -1612,7 +1612,7 @@ function buildCursorRun(options) {
|
|
|
1612
1612
|
value: create(AgentConversationTurnStructureSchema, {
|
|
1613
1613
|
userMessage: storeAsBlob(toBinary(UserMessageSchema, createUserMessage(turn.userText, selectedCtxBlob)), blobStore),
|
|
1614
1614
|
steps: turn.steps.map((step) => storeAsBlob(buildTurnStepBytes(step), blobStore)),
|
|
1615
|
-
requestId: randomUUID()
|
|
1615
|
+
requestId: randomUUID$1()
|
|
1616
1616
|
})
|
|
1617
1617
|
} });
|
|
1618
1618
|
turnBlobIds.push(storeAsBlob(toBinary(ConversationTurnStructureSchema, turnStructure), blobStore));
|
|
@@ -1650,7 +1650,7 @@ function buildCursorRun(options) {
|
|
|
1650
1650
|
value: create(UserMessageActionSchema, { userMessage })
|
|
1651
1651
|
} }),
|
|
1652
1652
|
requestedModel,
|
|
1653
|
-
conversationId: options.sessionId ?? randomUUID(),
|
|
1653
|
+
conversationId: options.sessionId ?? randomUUID$1(),
|
|
1654
1654
|
mcpTools: create(McpToolsSchema, { mcpTools })
|
|
1655
1655
|
})
|
|
1656
1656
|
} })),
|
|
@@ -2037,7 +2037,7 @@ function cursorHeaders(rpcPath, accessToken, contentType) {
|
|
|
2037
2037
|
"x-ghost-mode": "true",
|
|
2038
2038
|
"x-cursor-client-version": CURSOR_CLIENT_VERSION,
|
|
2039
2039
|
"x-cursor-client-type": "cli",
|
|
2040
|
-
"x-request-id": randomUUID(),
|
|
2040
|
+
"x-request-id": randomUUID$1(),
|
|
2041
2041
|
...attributionHeaders()
|
|
2042
2042
|
};
|
|
2043
2043
|
}
|
|
@@ -2236,6 +2236,101 @@ function openConnectStream(request, connect = defaultConnect) {
|
|
|
2236
2236
|
};
|
|
2237
2237
|
}
|
|
2238
2238
|
//#endregion
|
|
2239
|
+
//#region lib/types/leaked-call.js
|
|
2240
|
+
/**
|
|
2241
|
+
* Recover harness tool calls that a Cursor model wrote as text. Kimi models on
|
|
2242
|
+
* Cursor sometimes emit their native tool-call markup
|
|
2243
|
+
* (`<|open|>toolscall tool="CallDynamicTool" index="1"<|sep|>…<|close|>tools<|sep|>`)
|
|
2244
|
+
* that Cursor's server does not parse: the markup arrives as `textDelta` and
|
|
2245
|
+
* the turn ends without an exec, so the call never runs.
|
|
2246
|
+
*
|
|
2247
|
+
* @module @deepseek-ai/dsh-llm-cursor/leaked-call
|
|
2248
|
+
*/
|
|
2249
|
+
/** Opening of leaked tool-call markup; text from its first occurrence is withheld until the turn ends. */
|
|
2250
|
+
const LEAKED_CALLS_MARKER = "<|open|>tools";
|
|
2251
|
+
/**
|
|
2252
|
+
* Where a text block stops being safe to stream: the first
|
|
2253
|
+
* {@link LEAKED_CALLS_MARKER}, or the start of a trailing partial marker.
|
|
2254
|
+
* The result never decreases as the text grows, so a caller may pass the
|
|
2255
|
+
* previous result as `from`.
|
|
2256
|
+
* @param text - text block so far.
|
|
2257
|
+
* @param from - offset already known to precede any marker.
|
|
2258
|
+
* @returns the length of the prefix that cannot belong to leaked markup.
|
|
2259
|
+
*/
|
|
2260
|
+
function leakedMarkupStart(text, from = 0) {
|
|
2261
|
+
const found = text.indexOf(LEAKED_CALLS_MARKER, from);
|
|
2262
|
+
if (found >= 0) return found;
|
|
2263
|
+
for (let start = Math.max(from, text.length - 13 + 1); start < text.length; start += 1) if ("<|open|>tools".startsWith(text.slice(start))) return start;
|
|
2264
|
+
return text.length;
|
|
2265
|
+
}
|
|
2266
|
+
const CALL_OPEN = /^(?:<\|open\|>)?call tool="([^"]*)"(?: index="\d+")?<\|sep\|>/;
|
|
2267
|
+
const ARGUMENT_OPEN = /^<\|open\|>argument key="([^"]*)" type="([^"]*)"<\|sep\|>/;
|
|
2268
|
+
const ARGUMENT_CLOSE = "<|close|>argument<|sep|>";
|
|
2269
|
+
const CALL_CLOSE = "<|close|>call<|sep|>";
|
|
2270
|
+
const CALLS_CLOSE = "<|close|>tools<|sep|>";
|
|
2271
|
+
function decodeArgument(type, raw) {
|
|
2272
|
+
if (type === "string") return { value: raw };
|
|
2273
|
+
try {
|
|
2274
|
+
return { value: JSON.parse(raw) };
|
|
2275
|
+
} catch (_notJson) {
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
function isRecord(value) {
|
|
2280
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2281
|
+
}
|
|
2282
|
+
function harnessCall(tool, args, toolNames) {
|
|
2283
|
+
if (tool !== "CallDynamicTool" || args["namespace"] !== "dsh") return void 0;
|
|
2284
|
+
const named = args["toolName"];
|
|
2285
|
+
if (typeof named !== "string") return void 0;
|
|
2286
|
+
const toolName = named.startsWith(MCP_PROMPT_TOOL_PREFIX) ? named.slice(MCP_PROMPT_TOOL_PREFIX.length) : named;
|
|
2287
|
+
const callArguments = args["arguments"] ?? {};
|
|
2288
|
+
if (!toolNames.has(toolName) || !isRecord(callArguments)) return void 0;
|
|
2289
|
+
return {
|
|
2290
|
+
toolName,
|
|
2291
|
+
arguments: callArguments
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Parse text that starts at {@link LEAKED_CALLS_MARKER} into harness tool
|
|
2296
|
+
* calls. Every call must be a complete `CallDynamicTool` call in namespace
|
|
2297
|
+
* `dsh` naming an advertised harness tool, and only whitespace may follow the
|
|
2298
|
+
* markup; anything else returns `undefined` so the caller keeps the text.
|
|
2299
|
+
* @param text - withheld text, starting at the marker.
|
|
2300
|
+
* @param toolNames - harness tool names advertised on the Run.
|
|
2301
|
+
* @returns the recovered calls in order, or `undefined`.
|
|
2302
|
+
*/
|
|
2303
|
+
function parseLeakedToolCalls(text, toolNames) {
|
|
2304
|
+
if (!text.startsWith("<|open|>tools")) return void 0;
|
|
2305
|
+
let rest = text.slice(13);
|
|
2306
|
+
const calls = [];
|
|
2307
|
+
while (true) {
|
|
2308
|
+
rest = rest.startsWith("<|sep|>") ? rest.slice(7) : rest;
|
|
2309
|
+
const call = CALL_OPEN.exec(rest);
|
|
2310
|
+
if (call === null) return void 0;
|
|
2311
|
+
rest = rest.slice(call[0].length);
|
|
2312
|
+
const args = {};
|
|
2313
|
+
let argument = ARGUMENT_OPEN.exec(rest);
|
|
2314
|
+
while (argument !== null) {
|
|
2315
|
+
rest = rest.slice(argument[0].length);
|
|
2316
|
+
const end = rest.indexOf(ARGUMENT_CLOSE);
|
|
2317
|
+
if (end < 0) return void 0;
|
|
2318
|
+
const decoded = decodeArgument(argument[2], rest.slice(0, end));
|
|
2319
|
+
if (decoded === void 0) return void 0;
|
|
2320
|
+
args[argument[1]] = decoded.value;
|
|
2321
|
+
rest = rest.slice(end + 24);
|
|
2322
|
+
argument = ARGUMENT_OPEN.exec(rest);
|
|
2323
|
+
}
|
|
2324
|
+
if (!rest.startsWith(CALL_CLOSE)) return void 0;
|
|
2325
|
+
rest = rest.slice(20);
|
|
2326
|
+
const recovered = harnessCall(call[1], args, toolNames);
|
|
2327
|
+
if (recovered === void 0) return void 0;
|
|
2328
|
+
calls.push(recovered);
|
|
2329
|
+
if (rest.startsWith(CALLS_CLOSE)) rest = rest.slice(21);
|
|
2330
|
+
if (rest.trim().length === 0) return calls;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
//#endregion
|
|
2239
2334
|
//#region lib/types/stream.js
|
|
2240
2335
|
/**
|
|
2241
2336
|
* Translate Cursor Connect Runs into harness StreamChunks, one DSH step at a time.
|
|
@@ -2784,11 +2879,40 @@ function rejectNativeQuestion(stream, query, mcpTools) {
|
|
|
2784
2879
|
})
|
|
2785
2880
|
} });
|
|
2786
2881
|
}
|
|
2787
|
-
function*
|
|
2882
|
+
function* emitThrough(state, open, end) {
|
|
2883
|
+
if (end <= open.emitted) return;
|
|
2884
|
+
if (open.index === void 0) {
|
|
2885
|
+
open.index = state.nextIndex;
|
|
2886
|
+
state.nextIndex += 1;
|
|
2887
|
+
yield {
|
|
2888
|
+
type: "block-start",
|
|
2889
|
+
index: open.index,
|
|
2890
|
+
blockType: open.type
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
const text = open.text.slice(open.emitted, end);
|
|
2894
|
+
open.emitted = end;
|
|
2895
|
+
yield open.type === "text" ? {
|
|
2896
|
+
type: "text-delta",
|
|
2897
|
+
index: open.index,
|
|
2898
|
+
text
|
|
2899
|
+
} : {
|
|
2900
|
+
type: "reasoning-delta",
|
|
2901
|
+
index: open.index,
|
|
2902
|
+
text
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
/** End the open block, first emitting any withheld text, and clear it. */
|
|
2906
|
+
function* closeOpen(state) {
|
|
2907
|
+
const open = state.open;
|
|
2788
2908
|
if (open === void 0) return;
|
|
2909
|
+
state.open = void 0;
|
|
2910
|
+
yield* emitThrough(state, open, open.text.length);
|
|
2911
|
+
const index = open.index;
|
|
2912
|
+
if (index === void 0) return;
|
|
2789
2913
|
if (open.type === "text") yield {
|
|
2790
2914
|
type: "block-end",
|
|
2791
|
-
index
|
|
2915
|
+
index,
|
|
2792
2916
|
block: {
|
|
2793
2917
|
type: "text",
|
|
2794
2918
|
text: open.text
|
|
@@ -2796,13 +2920,33 @@ function* closeOpen(open) {
|
|
|
2796
2920
|
};
|
|
2797
2921
|
else yield {
|
|
2798
2922
|
type: "block-end",
|
|
2799
|
-
index
|
|
2923
|
+
index,
|
|
2800
2924
|
block: {
|
|
2801
2925
|
type: "reasoning",
|
|
2802
2926
|
text: open.text
|
|
2803
2927
|
}
|
|
2804
2928
|
};
|
|
2805
2929
|
}
|
|
2930
|
+
/**
|
|
2931
|
+
* At turn end, replace a withheld text tail that parses as leaked harness tool
|
|
2932
|
+
* calls with tool-call blocks. The text before the markup stays a text block.
|
|
2933
|
+
* @returns the replacing chunks, or `undefined` when nothing was recovered.
|
|
2934
|
+
*/
|
|
2935
|
+
function recoverLeakedCalls(state, mcpTools) {
|
|
2936
|
+
const open = state.open;
|
|
2937
|
+
if (open?.type !== "text" || open.emitted === open.text.length) return void 0;
|
|
2938
|
+
const calls = parseLeakedToolCalls(open.text.slice(open.emitted), new Set(mcpTools.map((tool) => tool.toolName)));
|
|
2939
|
+
if (calls === void 0) return void 0;
|
|
2940
|
+
open.text = open.text.slice(0, open.emitted);
|
|
2941
|
+
const chunks = [...closeOpen(state)];
|
|
2942
|
+
for (const call of calls) {
|
|
2943
|
+
const toolCallId = `cursor-leaked-${randomUUID()}`;
|
|
2944
|
+
chunks.push(...emitToolCall(state.nextIndex, toolCallId, call.toolName, call.arguments));
|
|
2945
|
+
state.nextIndex += 1;
|
|
2946
|
+
state.toolCallIds.push(toolCallId);
|
|
2947
|
+
}
|
|
2948
|
+
return chunks;
|
|
2949
|
+
}
|
|
2806
2950
|
function* emitToolCall(index, id, name, args) {
|
|
2807
2951
|
const argumentsText = JSON.stringify(args);
|
|
2808
2952
|
yield {
|
|
@@ -2916,8 +3060,7 @@ async function* stepOnRun(run, options, inputTokens, timing, produced, sessionId
|
|
|
2916
3060
|
toolCallIds: []
|
|
2917
3061
|
};
|
|
2918
3062
|
const finish = function* (reason) {
|
|
2919
|
-
yield* closeOpen(state
|
|
2920
|
-
state.open = void 0;
|
|
3063
|
+
yield* closeOpen(state);
|
|
2921
3064
|
yield {
|
|
2922
3065
|
type: "usage",
|
|
2923
3066
|
usage: {
|
|
@@ -2959,7 +3102,7 @@ async function* stepOnRun(run, options, inputTokens, timing, produced, sessionId
|
|
|
2959
3102
|
}
|
|
2960
3103
|
if (outcome.turnEnded === true) {
|
|
2961
3104
|
run.close(false);
|
|
2962
|
-
yield* finish({ kind: "stop" });
|
|
3105
|
+
yield* finish({ kind: outcome.recoveredCalls === true ? "tool-calls" : "stop" });
|
|
2963
3106
|
return;
|
|
2964
3107
|
}
|
|
2965
3108
|
if (endsToolBatch || outcome.checkpoint === true && state.toolCallIds.length > 0) {
|
|
@@ -2994,34 +3137,28 @@ function handleServerMessage(message, run, state) {
|
|
|
2994
3137
|
if (text.length > 0) {
|
|
2995
3138
|
const type = updateCase === "textDelta" ? "text" : "reasoning";
|
|
2996
3139
|
if (state.open?.type !== type) {
|
|
2997
|
-
chunks.push(...closeOpen(state
|
|
3140
|
+
chunks.push(...closeOpen(state));
|
|
2998
3141
|
state.open = {
|
|
2999
|
-
index:
|
|
3142
|
+
index: void 0,
|
|
3000
3143
|
type,
|
|
3001
|
-
text: ""
|
|
3144
|
+
text: "",
|
|
3145
|
+
emitted: 0
|
|
3002
3146
|
};
|
|
3003
|
-
chunks.push({
|
|
3004
|
-
type: "block-start",
|
|
3005
|
-
index: state.nextIndex,
|
|
3006
|
-
blockType: type
|
|
3007
|
-
});
|
|
3008
|
-
state.nextIndex += 1;
|
|
3009
3147
|
}
|
|
3010
|
-
state.open
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
index: state.open.index,
|
|
3014
|
-
text
|
|
3015
|
-
} : {
|
|
3016
|
-
type: "reasoning-delta",
|
|
3017
|
-
index: state.open.index,
|
|
3018
|
-
text
|
|
3019
|
-
});
|
|
3148
|
+
const open = state.open;
|
|
3149
|
+
open.text += text;
|
|
3150
|
+
chunks.push(...emitThrough(state, open, type === "text" ? leakedMarkupStart(open.text, open.emitted) : open.text.length));
|
|
3020
3151
|
state.sawContent = true;
|
|
3021
3152
|
}
|
|
3022
3153
|
} else if (updateCase === "tokenDelta") state.outputTokens += message.message.value.message.value.tokens;
|
|
3023
3154
|
else if (updateCase === "turnEnded") {
|
|
3024
3155
|
if (!state.sawContent && state.open === void 0) throw new LlmError("llm-cursor: Cursor returned no content", "EMPTY_RESPONSE");
|
|
3156
|
+
const recovered = recoverLeakedCalls(state, payload.mcpTools);
|
|
3157
|
+
if (recovered !== void 0) return {
|
|
3158
|
+
chunks: [...chunks, ...recovered],
|
|
3159
|
+
turnEnded: true,
|
|
3160
|
+
recoveredCalls: true
|
|
3161
|
+
};
|
|
3025
3162
|
return {
|
|
3026
3163
|
chunks,
|
|
3027
3164
|
turnEnded: true
|
|
@@ -3044,8 +3181,7 @@ function handleServerMessage(message, run, state) {
|
|
|
3044
3181
|
if (execCase === "mcpArgs") {
|
|
3045
3182
|
const mcp = exec.message.value;
|
|
3046
3183
|
const toolCallId = mcp.toolCallId || `cursor-${exec.id}`;
|
|
3047
|
-
chunks.push(...closeOpen(state
|
|
3048
|
-
state.open = void 0;
|
|
3184
|
+
chunks.push(...closeOpen(state));
|
|
3049
3185
|
chunks.push(...emitToolCall(state.nextIndex, toolCallId, harnessToolName(mcp), decodeMcpArgsMap(mcp.args)));
|
|
3050
3186
|
state.nextIndex += 1;
|
|
3051
3187
|
state.sawContent = true;
|
|
@@ -3061,8 +3197,7 @@ function handleServerMessage(message, run, state) {
|
|
|
3061
3197
|
return {};
|
|
3062
3198
|
}
|
|
3063
3199
|
if (execCase === "executeHookArgs" && answerHook(stream, exec, exec.message.value.request)) return {};
|
|
3064
|
-
chunks.push(...closeOpen(state
|
|
3065
|
-
state.open = void 0;
|
|
3200
|
+
chunks.push(...closeOpen(state));
|
|
3066
3201
|
if (answerNativeExec(stream, exec, payload.mcpTools)) return { chunks };
|
|
3067
3202
|
rejectUnknownExec(stream, exec);
|
|
3068
3203
|
if (execCase !== void 0 || exec.$unknown !== void 0 && exec.$unknown.length > 0) return { chunks };
|
|
@@ -3075,14 +3210,12 @@ function handleServerMessage(message, run, state) {
|
|
|
3075
3210
|
return {};
|
|
3076
3211
|
}
|
|
3077
3212
|
if (query.query.case === "webFetchRequestQuery") {
|
|
3078
|
-
chunks.push(...closeOpen(state
|
|
3079
|
-
state.open = void 0;
|
|
3213
|
+
chunks.push(...closeOpen(state));
|
|
3080
3214
|
rejectNativeFetch(stream, query, payload.mcpTools);
|
|
3081
3215
|
return { chunks };
|
|
3082
3216
|
}
|
|
3083
3217
|
if (query.query.case === "askQuestionInteractionQuery") {
|
|
3084
|
-
chunks.push(...closeOpen(state
|
|
3085
|
-
state.open = void 0;
|
|
3218
|
+
chunks.push(...closeOpen(state));
|
|
3086
3219
|
rejectNativeQuestion(stream, query, payload.mcpTools);
|
|
3087
3220
|
return { chunks };
|
|
3088
3221
|
}
|
|
@@ -3685,7 +3818,7 @@ function createCursorOauthClient(deps = {}) {
|
|
|
3685
3818
|
const requestTimeoutMs = deps.requestTimeoutMs ?? 15e3;
|
|
3686
3819
|
const sleepImpl = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
3687
3820
|
const generatePkceImpl = deps.generatePkce ?? generatePkce;
|
|
3688
|
-
const randomUUIDImpl = deps.randomUUID ?? randomUUID;
|
|
3821
|
+
const randomUUIDImpl = deps.randomUUID ?? randomUUID$1;
|
|
3689
3822
|
const now = deps.now ?? Date.now;
|
|
3690
3823
|
async function generateParams() {
|
|
3691
3824
|
const { verifier, challenge } = await generatePkceImpl();
|
|
@@ -264,7 +264,59 @@ function toPiAssistant(message, onDegrade) {
|
|
|
264
264
|
* @module dsh-llm-pi-ai/catalog-supplement
|
|
265
265
|
*/
|
|
266
266
|
/** One provider route's supplemental models, keyed by model id. */
|
|
267
|
-
const SUPPLEMENT = {
|
|
267
|
+
const SUPPLEMENT = { anthropic: { "claude-haiku-5-5": {
|
|
268
|
+
id: "claude-haiku-5-5",
|
|
269
|
+
name: "Claude Haiku 5.5",
|
|
270
|
+
api: "anthropic-messages",
|
|
271
|
+
provider: "anthropic",
|
|
272
|
+
baseUrl: "https://api.anthropic.com",
|
|
273
|
+
reasoning: true,
|
|
274
|
+
input: ["text", "image"],
|
|
275
|
+
cost: {
|
|
276
|
+
input: .1,
|
|
277
|
+
output: .5,
|
|
278
|
+
cacheRead: .01,
|
|
279
|
+
cacheWrite: .125,
|
|
280
|
+
tiers: [{
|
|
281
|
+
inputTokensAbove: 1e5,
|
|
282
|
+
input: .5,
|
|
283
|
+
output: 2.5,
|
|
284
|
+
cacheRead: .05,
|
|
285
|
+
cacheWrite: .625
|
|
286
|
+
}]
|
|
287
|
+
},
|
|
288
|
+
contextWindow: 1e6,
|
|
289
|
+
maxTokens: 128e3,
|
|
290
|
+
compat: {
|
|
291
|
+
supportsMidConvoEffort: true,
|
|
292
|
+
supportsMidConvoSystemMessages: true,
|
|
293
|
+
supportsMidConvoToolChanges: true,
|
|
294
|
+
forceAdaptiveThinking: true,
|
|
295
|
+
supportsStrictTools: true
|
|
296
|
+
},
|
|
297
|
+
thinkingLevelMap: {
|
|
298
|
+
off: null,
|
|
299
|
+
xhigh: "xhigh",
|
|
300
|
+
max: "max"
|
|
301
|
+
},
|
|
302
|
+
promptCache: {
|
|
303
|
+
short: 300,
|
|
304
|
+
long: 3600
|
|
305
|
+
},
|
|
306
|
+
inputLimits: {
|
|
307
|
+
maxRequestBytes: 33554432,
|
|
308
|
+
images: {
|
|
309
|
+
maxPerRequest: 600,
|
|
310
|
+
resize: {
|
|
311
|
+
maxWidth: 2e3,
|
|
312
|
+
maxHeight: 2e3,
|
|
313
|
+
maxBytes: 4718592,
|
|
314
|
+
jpegQuality: 80
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
type: "chat"
|
|
319
|
+
} } };
|
|
268
320
|
/**
|
|
269
321
|
* Supplemental catalog models for one pi-ai provider route.
|
|
270
322
|
* @param provider - provider route key.
|
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Fri, 09 Oct 2026 18:42:20 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "26.6.
|
|
3
|
+
"version": "26.6.5",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -134,6 +134,6 @@
|
|
|
134
134
|
"undici-types": "~8.9.0"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {},
|
|
137
|
-
"typesPublisherContentHash": "
|
|
137
|
+
"typesPublisherContentHash": "3196021f34db9bcb68a729bd29ff60434d3b4c5f49619270db25e7dbd6dc651c",
|
|
138
138
|
"typeScriptVersion": "5.6"
|
|
139
139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@songtonyli/dsh-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"description": "The dsh terminal agent: an interactive TUI over the DeepSeek Harness, with its whole Node runtime bundled in one install.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
18
18
|
"@anthropic-ai/sdk": "0.129.0",
|
|
19
19
|
"@aws-sdk/client-bedrock-runtime": "3.1127.0",
|
|
20
|
-
"@aws-sdk/core": "3.978.
|
|
21
|
-
"@aws-sdk/credential-provider-env": "3.972.
|
|
22
|
-
"@aws-sdk/credential-provider-http": "3.972.
|
|
23
|
-
"@aws-sdk/credential-provider-ini": "3.973.
|
|
24
|
-
"@aws-sdk/credential-provider-login": "3.972.
|
|
25
|
-
"@aws-sdk/credential-provider-node": "3.972.
|
|
26
|
-
"@aws-sdk/credential-provider-process": "3.972.
|
|
27
|
-
"@aws-sdk/credential-provider-sso": "3.973.
|
|
28
|
-
"@aws-sdk/credential-provider-web-identity": "3.972.
|
|
29
|
-
"@aws-sdk/eventstream-handler-node": "3.972.
|
|
30
|
-
"@aws-sdk/middleware-eventstream": "3.972.
|
|
31
|
-
"@aws-sdk/middleware-websocket": "3.972.
|
|
32
|
-
"@aws-sdk/nested-clients": "3.997.
|
|
33
|
-
"@aws-sdk/signature-v4-multi-region": "3.996.
|
|
34
|
-
"@aws-sdk/token-providers": "3.
|
|
20
|
+
"@aws-sdk/core": "3.978.2",
|
|
21
|
+
"@aws-sdk/credential-provider-env": "3.972.73",
|
|
22
|
+
"@aws-sdk/credential-provider-http": "3.972.75",
|
|
23
|
+
"@aws-sdk/credential-provider-ini": "3.973.18",
|
|
24
|
+
"@aws-sdk/credential-provider-login": "3.972.80",
|
|
25
|
+
"@aws-sdk/credential-provider-node": "3.972.85",
|
|
26
|
+
"@aws-sdk/credential-provider-process": "3.972.73",
|
|
27
|
+
"@aws-sdk/credential-provider-sso": "3.973.17",
|
|
28
|
+
"@aws-sdk/credential-provider-web-identity": "3.972.79",
|
|
29
|
+
"@aws-sdk/eventstream-handler-node": "3.972.36",
|
|
30
|
+
"@aws-sdk/middleware-eventstream": "3.972.31",
|
|
31
|
+
"@aws-sdk/middleware-websocket": "3.972.55",
|
|
32
|
+
"@aws-sdk/nested-clients": "3.997.47",
|
|
33
|
+
"@aws-sdk/signature-v4-multi-region": "3.996.48",
|
|
34
|
+
"@aws-sdk/token-providers": "3.1149.0",
|
|
35
35
|
"@aws-sdk/types": "3.974.6",
|
|
36
36
|
"@aws-sdk/xml-builder": "3.972.41",
|
|
37
37
|
"@aws/lambda-invoke-store": "0.3.0",
|
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
"@types/hast": "3.0.5",
|
|
401
401
|
"@types/http-cache-semantics": "4.2.0",
|
|
402
402
|
"@types/mdast": "4.0.4",
|
|
403
|
-
"@types/node": "26.6.
|
|
403
|
+
"@types/node": "26.6.5",
|
|
404
404
|
"@types/retry": "0.12.0",
|
|
405
405
|
"@types/unist": "3.0.3",
|
|
406
406
|
"@ungap/structured-clone": "1.4.0",
|