fix(provider-acp): Windows T3_ACP_MCP_CALL fallback calls resolve as T3 tools #42195
OpenPyseph(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/42195/headopened View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -1094,0 +1136,21 @@1136+ if (currentSegment.length === 0) return;1137+ segments.push(currentSegment);1138+ currentSegment = [];1139+ };1140+1141+ const consumePendingHeredocs = () => {1142+ while (pendingHeredocs.length > 0 && index < length) {1143+ const { delimiter, stripTabs } = pendingHeredocs.shift()!;1144+ while (index < length) {1145+ const lineEnd = command.indexOf("\n", index);1146+ const rawLine = lineEnd === -1 ? command.slice(index) : command.slice(index, lineEnd);1147+ index = lineEnd === -1 ? length : lineEnd + 1;1148+ const normalized = (stripTabs ? rawLine.replace(/^\t+/u, "") : rawLine).replace(/\r$/u, "");1149+ if (normalized === delimiter) break;1150+ }1151+ }1152+ };1153+1154+ while (index < length) {1155+ const ch = command[index]!;1156+ if (ch === " " || ch === "\t" || ch === "\r") {@@ -1094,0 +1151,21 @@1151+ }1152+ };1153+1154+ while (index < length) {1155+ const ch = command[index]!;1156+ if (ch === " " || ch === "\t" || ch === "\r") {1157+ index += 1;1158+ continue;1159+ }1160+ const continuation = isLineContinuation(command, index);1161+ if (continuation > 0) {1162+ index += continuation;1163+ continue;1164+ }1165+ if (ch === "\n") {1166+ flushSegment();1167+ index += 1;1168+ consumePendingHeredocs();1169+ continue;1170+ }1171+ if (ch === "#") {@@ -1094,0 +1230,21 @@1230+ if (stripTabs) index += 1;1231+ while (index < length && (command[index] === " " || command[index] === "\t")) index += 1;1232+ let delimiter = "";1233+ while (index < length && !/[\s;|&()]/u.test(command[index]!)) {1234+ const c = command[index]!;1235+ if (c === "'" || c === '"') {1236+ index += 1;1237+ while (index < length && command[index] !== c) {1238+ delimiter += command[index]!;1239+ index += 1;1240+ }1241+ if (index < length) index += 1;1242+ } else if (c === "\\" && index + 1 < length) {1243+ delimiter += command[index + 1]!;1244+ index += 2;1245+ } else {1246+ delimiter += c;1247+ index += 1;1248+ }1249+ }1250+ if (HEREDOC_DELIMITER.test(delimiter)) pendingHeredocs.push({ delimiter, stripTabs });@@ -1094,0 +1253,21 @@1253+ raw,1254+ value: raw,1255+ quoted: false,1256+ singleQuoted: false,1257+ start,1258+ end: index,1259+ });1260+ continue;1261+ }1262+1263+ const start = index;1264+ let value = "";1265+ let quoted = false;1266+ let allSingleQuoted = true;1267+ while (index < length) {1268+ const c = command[index]!;1269+ if (1270+ /[\s;|()]/u.test(c) ||1271+ (c === "&" && command[index - 1] !== ">" && command[index - 1] !== "<") ||1272+ (c === "$" && command[index + 1] === "(") ||1273+ (c === "<" && command[index + 1] === "<" && command[index + 2] !== "<") ||@@ -1094,0 +1253,21 @@1253+ raw,1254+ value: raw,1255+ quoted: false,1256+ singleQuoted: false,1257+ start,1258+ end: index,1259+ });1260+ continue;1261+ }1262+1263+ const start = index;1264+ let value = "";1265+ let quoted = false;1266+ let allSingleQuoted = true;1267+ while (index < length) {1268+ const c = command[index]!;1269+ if (1270+ /[\s;|()]/u.test(c) ||1271+ (c === "&" && command[index - 1] !== ">" && command[index - 1] !== "<") ||1272+ (c === "$" && command[index + 1] === "(") ||1273+ (c === "<" && command[index + 1] === "<" && command[index + 2] !== "<") ||@@ -1094,0 +1254,21 @@1254+ value: raw,1255+ quoted: false,1256+ singleQuoted: false,1257+ start,1258+ end: index,1259+ });1260+ continue;1261+ }1262+1263+ const start = index;1264+ let value = "";1265+ let quoted = false;1266+ let allSingleQuoted = true;1267+ while (index < length) {1268+ const c = command[index]!;1269+ if (1270+ /[\s;|()]/u.test(c) ||1271+ (c === "&" && command[index - 1] !== ">" && command[index - 1] !== "<") ||1272+ (c === "$" && command[index + 1] === "(") ||1273+ (c === "<" && command[index + 1] === "<" && command[index + 2] !== "<") ||1274+ isLineContinuation(command, index) > 0@@ -1094,0 +1292,21 @@1292+ if (inner === '"') {1293+ index += 1;1294+ break;1295+ }1296+ if ((inner === "\\" || inner === "`") && index + 1 < length) {1297+ const next = command[index + 1]!;1298+ if (next === '"' || next === inner) {1299+ value += next;1300+ index += 2;1301+ continue;1302+ }1303+ }1304+ value += inner;1305+ index += 1;1306+ }1307+ } else {1308+ allSingleQuoted = false;1309+ if (1310+ (c === "\\" || c === "`") &&1311+ index + 1 < length &&1312+ /[;|&\s'"()]/u.test(command[index + 1]!)@@ -1094,0 +1330,21 @@1330+ }1331+1332+ flushSegment();1333+ return segments;1334+}1335+1336+function unwrapShellWrapper(1337+ tokens: ReadonlyArray<ShellToken>,1338+ index: number,1339+ depth: number,1340+):1341+ | { readonly kind: "nested"; readonly command: string }1342+ | { readonly kind: "advance"; readonly index: number }1343+ | { readonly kind: "stop" }1344+ | undefined {1345+ const token = tokens[index]!;1346+ const isTrailingCommandArg = (argIndex: number) =>1347+ argIndex === tokens.length - 1 ||1348+ (argIndex < tokens.length - 1 &&1349+ !tokens[argIndex + 1]!.quoted &&1350+ SHELL_REDIRECTION_TOKEN.test(tokens[argIndex + 1]!.raw));@@ -1094,0 +1454,21 @@1454+ const toolToken = tokens[index + 1];1455+ if (launcher === undefined || toolToken === undefined) continue;1456+ const isLauncher =1457+ (!launcher.singleQuoted && WINDOWS_ACP_MCP_ENV_LAUNCHER.test(launcher.value)) ||1458+ WINDOWS_ACP_MCP_CMD_LAUNCHER.test(launcher.value);1459+ if (!isLauncher || !T3_MCP_TOOL_NAMES.has(toolToken.value)) continue;1460+ const argTokens: Array<ShellToken> = [];1461+ for (let argIndex = index + 2; argIndex < tokens.length; argIndex += 1) {1462+ const arg = tokens[argIndex]!;1463+ if (!arg.quoted && SHELL_REDIRECTION_TOKEN.test(arg.raw)) break;1464+ argTokens.push(arg);1465+ }1466+ const rawArg =1467+ argTokens.length === 01468+ ? undefined1469+ : command.slice(argTokens[0]!.start, argTokens.at(-1)!.end);1470+ const input =1471+ acpMcpFallbackInput(rawArg) ??1472+ (argTokens.length === 11473+ ? acpMcpFallbackInput(argTokens[0]!.value)1474+ : (acpMcpFallbackInput(argTokens[0]?.raw) ?? acpMcpFallbackInput(argTokens[0]?.value)));
Pushedd35cd54
- @@ -1441,0 +1554,21 @@1554+ expect(extractMcpToolCallIdentity(toolCall), command).toEqual(expected);1555+ }1556+1557+ for (const command of [1558+ `Get-Content "$env:T3_ACP_MCP_CALL" -Raw`,1559+ `Write-Output "T3_ACP_MCP_CALL=$env:T3_ACP_MCP_CALL"`,1560+ `Write-Output "$env:T3_ACP_MCP_CALL html_render"`,1561+ `Write-Output "run | & $env:T3_ACP_MCP_CALL html_render -"`,1562+ `Write-Host "T3_ACP_MCP_CALL html_render"`,1563+ `Get-Item $env:T3_ACP_MCP_CALL | Select-Object Name`,1564+ `Get-Content "C:\\Users\\Alice\\.t3\\userdata\\acp\\acp-mcp-call.cmd" -Raw`,1565+ `printf '%s\\n' '$T3_ACP_MCP_CALL html_render -'`,1566+ `echo "a; & $env:T3_ACP_MCP_CALL html_render -"`,1567+ `# & $env:T3_ACP_MCP_CALL html_render -`,1568+ `<#\n& $env:T3_ACP_MCP_CALL html_render -\n#>`,1569+ `@'\n& $env:T3_ACP_MCP_CALL html_render -\n'@ | Out-File notes.txt`,1570+ `cat <<'EOF'\n"$T3_ACP_MCP_CALL" html_render -\nEOF`,1571+ `cat <<'123'\n"$T3_ACP_MCP_CALL" html_render -\n123`,1572+ `echo\u00A0"$T3_ACP_MCP_CALL"\u00A0html_render\u00A0-`,1573+ `echo ^& "%T3_ACP_MCP_CALL%" html_render -`,1574+ `pwsh -Command 'Get-Content a.json | & $env:T3_ACP_MCP_CALL html_render -' '2>err.log'`,
Pushedb71e6e7
- @@ -1094,0 +1446,21 @@1446+ ) {1447+ return {1448+ kind: "nested",1449+ command: command.slice(tokens[next]!.start + 1, tokens[lastCmdIndex]!.end - 1),1450+ };1451+ }1452+ }1453+ return { kind: "advance", index: next };1454+ }1455+ if (POWERSHELL_EXE_NAME.test(token.value)) {1456+ let next = index + 1;1457+ while (next < tokens.length && !tokens[next]!.quoted && tokens[next]!.value.startsWith("-")) {1458+ const flag = tokens[next]!.value.toLowerCase();1459+ next += 1;1460+ if (flag === "-c" || flag === "-command") {1461+ if (depth === 0 && next < tokens.length && tokens[next]!.quoted) {1462+ const parts: Array<string> = [];1463+ for (let cursor = next; cursor < tokens.length; cursor += 1) {1464+ const arg = tokens[cursor]!;1465+ if (arg.redirection) {1466+ if (BARE_REDIRECTION_OPERATOR.test(arg.raw)) cursor += 1;
Pushed18b2c06
Sign in to join this conversation.
No actionable comments were generated in the recent review.
Walkthrough
The ACP runtime now recognizes Windows T3 MCP fallback invocations and returns the
t3-codeidentity. It parses supported command forms and input arguments. Tests cover recognized invocations and command forms that must not match.Changes: Windows ACP fallback recognition
packages/provider-acp/src/server/runtimeModel.tspackages/provider-acp/src/server/runtimeModel.ts,packages/provider-acp/src/server/runtimeModel.test.tst3-codeidentity. Identity extraction checks this parser before the existingacp-mcp-callpattern. Tests cover positive and negative command cases.Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)#
Possibly related PRs
Suggested labels:
bugfixSuggested reviewers:
juliusmarminge,hh36000Merge Risk:
Minimal · up to
18b2cWindows fallback calls with a spaced launcher path in cmd /s /c quoting are now recognized as t3-code tool calls. No actionable merge-blocking risk remains in this parser change.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the actual change: a Windows fix so T3_ACP_MCP_CALL fallback calls resolve as T3 tools. It matches the parser change in runtimeModel.ts and the Windows fallback objective. It is a single conventional-commit line of 9 words, within a reasonable length.
Full details: Description check
Explanation
The description follows the repository template. It has Problem, Change, Scope, and Verification sections, each with concrete content. It names the affected file and the reproduction on Windows. It gives the failing test command and the post-fix results. It also includes the model and harness credit line that the template asks for. Only minor gaps remain. The Problem section gives a reproduction on a specific nightly build. The Verification section states what was not verified (live Windows UI session), as the template requires.
Finishing Touches
Generate unit tests (beta)
a4f444c6-6806-417f-8c8c-97f91700dfc4Reviewing files that changed from the base of the PR and between b71e6e71d8c6a7cb8554f1594696874d4d8eba23 and 18b2c066e67cad28b82333b3b4bf897210b671de.
packages/provider-acp/src/server/runtimeModel.test.tspackages/provider-acp/src/server/runtimeModel.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.