@cydm/pie 2.6.3 → 2.6.5

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.
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-WG6E54WK.js";
5
- import "../../../chunks/chunk-Y4CYXJR7.js";
6
- import "../../../chunks/chunk-O2DKMLNX.js";
4
+ } from "../../../chunks/chunk-QKSK5K5N.js";
5
+ import "../../../chunks/chunk-AETQBDEG.js";
6
+ import "../../../chunks/chunk-5OXH6NUH.js";
7
7
  import "../../../chunks/chunk-XXGYUYXI.js";
8
8
  import "../../../chunks/chunk-LZQXQOPJ.js";
9
9
 
@@ -24461,6 +24461,72 @@ function redactSecrets(text, secrets) {
24461
24461
  }
24462
24462
  return sanitized;
24463
24463
  }
24464
+ function encodedSecretVariants(secrets) {
24465
+ const variants = [...secrets];
24466
+ for (const secret of secrets) {
24467
+ if (secret.length < 4) continue;
24468
+ try {
24469
+ const base642 = Buffer.from(secret, "utf-8").toString("base64");
24470
+ if (base642.length >= 4) {
24471
+ variants.push(base642);
24472
+ const base64url2 = Buffer.from(secret, "utf-8").toString("base64url");
24473
+ if (base64url2 !== base642 && base64url2.length >= 4) variants.push(base64url2);
24474
+ }
24475
+ const urlEncoded = encodeURIComponent(secret);
24476
+ if (urlEncoded !== secret && urlEncoded.length >= 4) variants.push(urlEncoded);
24477
+ } catch {
24478
+ }
24479
+ }
24480
+ return variants;
24481
+ }
24482
+ function hexSecretVariants(secrets) {
24483
+ const variants = [];
24484
+ for (const secret of secrets) {
24485
+ if (secret.length < 6) continue;
24486
+ try {
24487
+ const hex = Buffer.from(secret, "utf-8").toString("hex");
24488
+ if (hex.length >= 12) variants.push(hex);
24489
+ } catch {
24490
+ }
24491
+ }
24492
+ return variants;
24493
+ }
24494
+ var MIN_SECRET_FRAGMENT = 8;
24495
+ function redactSecretFragments(text, secrets) {
24496
+ const candidates = secrets.filter((secret) => secret.length >= MIN_SECRET_FRAGMENT);
24497
+ if (candidates.length === 0 || text.length < MIN_SECRET_FRAGMENT) return text;
24498
+ const grams = /* @__PURE__ */ new Map();
24499
+ for (const secret of candidates) {
24500
+ for (let offset = 0; offset + MIN_SECRET_FRAGMENT <= secret.length; offset++) {
24501
+ const gram = secret.slice(offset, offset + MIN_SECRET_FRAGMENT);
24502
+ const bucket = grams.get(gram);
24503
+ if (bucket) bucket.push({ secret, offset });
24504
+ else grams.set(gram, [{ secret, offset }]);
24505
+ }
24506
+ }
24507
+ let out = "";
24508
+ let index = 0;
24509
+ while (index < text.length) {
24510
+ const bucket = grams.get(text.slice(index, index + MIN_SECRET_FRAGMENT));
24511
+ let best = 0;
24512
+ if (bucket) {
24513
+ for (const { secret, offset } of bucket) {
24514
+ let length = MIN_SECRET_FRAGMENT;
24515
+ const maxLength = Math.min(secret.length - offset, text.length - index);
24516
+ while (length < maxLength && text[index + length] === secret[offset + length]) length += 1;
24517
+ if (length > best) best = length;
24518
+ }
24519
+ }
24520
+ if (best > 0) {
24521
+ out += "[redacted]";
24522
+ index += best;
24523
+ } else {
24524
+ out += text[index];
24525
+ index += 1;
24526
+ }
24527
+ }
24528
+ return out;
24529
+ }
24464
24530
  function redactLeadingSecretSuffix(text, secrets) {
24465
24531
  if (secrets.length === 0 || text.length === 0) return text;
24466
24532
  for (const secret of secrets) {
@@ -24483,13 +24549,26 @@ function redactTrailingSecretPrefix(text, secrets) {
24483
24549
  }
24484
24550
  return text;
24485
24551
  }
24552
+ function redactAllSecrets(text, secrets) {
24553
+ const encoded = encodedSecretVariants(secrets);
24554
+ const wholeVariants = [...encoded, ...hexSecretVariants(secrets)];
24555
+ return redactTrailingSecretPrefix(
24556
+ redactLeadingSecretSuffix(
24557
+ redactSecretFragments(redactSecrets(text, wholeVariants), encoded),
24558
+ secrets
24559
+ ),
24560
+ secrets
24561
+ );
24562
+ }
24486
24563
  function redactStderrTail(tail, secrets) {
24487
- return redactTrailingSecretPrefix(redactLeadingSecretSuffix(redactSecrets(tail, secrets), secrets), secrets);
24564
+ return redactAllSecrets(tail, secrets);
24488
24565
  }
24489
24566
  function sanitizeDiagnostic(text, secrets) {
24490
- const sanitized = redactLeadingSecretSuffix(redactSecrets(text, secrets), secrets);
24567
+ let sanitized = redactAllSecrets(text, secrets);
24491
24568
  if (sanitized.length > DIAGNOSTIC_TEXT_LIMIT) {
24492
- return `${sanitized.slice(0, DIAGNOSTIC_TEXT_LIMIT)}\u2026[truncated ${sanitized.length - DIAGNOSTIC_TEXT_LIMIT} chars]`;
24569
+ const omitted = sanitized.length - DIAGNOSTIC_TEXT_LIMIT;
24570
+ sanitized = redactAllSecrets(sanitized.slice(0, DIAGNOSTIC_TEXT_LIMIT), secrets);
24571
+ return `${sanitized}\u2026[truncated ${omitted} chars]`;
24493
24572
  }
24494
24573
  return sanitized;
24495
24574
  }
@@ -24589,6 +24668,17 @@ var McpServerManager = class {
24589
24668
  );
24590
24669
  }
24591
24670
  }
24671
+ const byLowercase = /* @__PURE__ */ new Map();
24672
+ for (const key of this.definitions.keys()) {
24673
+ const lower = key.toLowerCase();
24674
+ byLowercase.set(lower, [...byLowercase.get(lower) ?? [], key]);
24675
+ }
24676
+ const caseClashes = [...byLowercase.entries()].filter(([, keys]) => keys.length > 1).map(([, keys]) => keys.map((key) => `"${key}"`).join(" and "));
24677
+ if (caseClashes.length > 0) {
24678
+ throw new Error(
24679
+ `MCP server names collide case-insensitively (their cache shard files share one name on macOS/Windows): ${caseClashes.join("; ")}. Rename one of them.`
24680
+ );
24681
+ }
24592
24682
  this.cacheDir = cacheDir;
24593
24683
  this.log = log;
24594
24684
  }
@@ -7,9 +7,9 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-WG6E54WK.js";
11
- import "../../../chunks/chunk-Y4CYXJR7.js";
12
- import "../../../chunks/chunk-O2DKMLNX.js";
10
+ } from "../../../chunks/chunk-QKSK5K5N.js";
11
+ import "../../../chunks/chunk-AETQBDEG.js";
12
+ import "../../../chunks/chunk-5OXH6NUH.js";
13
13
  import {
14
14
  Type
15
15
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCliHostCapabilities
4
- } from "../../../chunks/chunk-KTSUOXA7.js";
4
+ } from "../../../chunks/chunk-TFRQE7UQ.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-WG6E54WK.js";
9
- import "../../../chunks/chunk-Y4CYXJR7.js";
10
- import "../../../chunks/chunk-O2DKMLNX.js";
8
+ } from "../../../chunks/chunk-QKSK5K5N.js";
9
+ import "../../../chunks/chunk-AETQBDEG.js";
10
+ import "../../../chunks/chunk-5OXH6NUH.js";
11
11
  import "../../../chunks/chunk-5353DEEC.js";
12
12
  import "../../../chunks/chunk-XXGYUYXI.js";
13
13
  import "../../../chunks/chunk-LZQXQOPJ.js";
@@ -8,9 +8,9 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-WG6E54WK.js";
12
- import "../../../chunks/chunk-Y4CYXJR7.js";
13
- import "../../../chunks/chunk-O2DKMLNX.js";
11
+ } from "../../../chunks/chunk-QKSK5K5N.js";
12
+ import "../../../chunks/chunk-AETQBDEG.js";
13
+ import "../../../chunks/chunk-5OXH6NUH.js";
14
14
  import "../../../chunks/chunk-XXGYUYXI.js";
15
15
  import "../../../chunks/chunk-LZQXQOPJ.js";
16
16
 
@@ -21,6 +21,6 @@ function tryFastPath(argv, options) {
21
21
 
22
22
  // vendor/chrome-devtools-axi/bin/chrome-devtools-axi.ts
23
23
  if (!tryFastPath(process.argv.slice(2), { version: VERSION })) {
24
- const { main } = await import("./cli-GB37NZHQ.js");
24
+ const { main } = await import("./cli-5Z4COIKQ.js");
25
25
  await main(process.argv.slice(2));
26
26
  }
@@ -1934,6 +1934,45 @@ async function waitForProcessExit(pid, timeoutMs) {
1934
1934
  }
1935
1935
  return !isProcessAlive(pid);
1936
1936
  }
1937
+ function splitCommandLine(command) {
1938
+ const tokens = [];
1939
+ let current = "";
1940
+ let quote = null;
1941
+ for (const char of command.trim()) {
1942
+ if (quote !== null) {
1943
+ if (char === quote) quote = null;
1944
+ else current += char;
1945
+ continue;
1946
+ }
1947
+ if (char === '"' || char === "'") {
1948
+ quote = char;
1949
+ continue;
1950
+ }
1951
+ if (/\s/.test(char)) {
1952
+ if (current.length > 0) {
1953
+ tokens.push(current);
1954
+ current = "";
1955
+ }
1956
+ continue;
1957
+ }
1958
+ current += char;
1959
+ }
1960
+ if (current.length > 0) tokens.push(current);
1961
+ return tokens;
1962
+ }
1963
+ function commandLineLooksLikeBridge(command) {
1964
+ const tokens = splitCommandLine(command);
1965
+ if (tokens.length === 0) return false;
1966
+ if (!/(?:^|[\\/])(node|npx|tsx)(?:\.(?:exe|cmd))?$/i.test(tokens[0])) return false;
1967
+ for (let index = 1; index < tokens.length; index++) {
1968
+ const token = tokens[index];
1969
+ if (token.startsWith("-")) continue;
1970
+ if (/(?:^|[\\/])tsx(?:\.(?:exe|cmd))?$/i.test(token)) continue;
1971
+ const base = token.split(/[\\/]/).pop() ?? token;
1972
+ return /^chrome-devtools-axi-bridge\.(?:js|mjs|cjs|ts)$/i.test(base);
1973
+ }
1974
+ return false;
1975
+ }
1937
1976
  function isBridgeProcess(pid) {
1938
1977
  if (process.platform === "win32") {
1939
1978
  try {
@@ -1947,7 +1986,7 @@ function isBridgeProcess(pid) {
1947
1986
  ],
1948
1987
  { encoding: "utf-8", timeout: 4e3 }
1949
1988
  );
1950
- return command.includes("chrome-devtools-axi-bridge");
1989
+ return commandLineLooksLikeBridge(command);
1951
1990
  } catch {
1952
1991
  return false;
1953
1992
  }
@@ -1957,7 +1996,7 @@ function isBridgeProcess(pid) {
1957
1996
  encoding: "utf-8",
1958
1997
  timeout: 1e3
1959
1998
  });
1960
- return command.includes("chrome-devtools-axi-bridge");
1999
+ return commandLineLooksLikeBridge(command);
1961
2000
  } catch {
1962
2001
  return false;
1963
2002
  }
@@ -1983,15 +2022,17 @@ async function judgeRecordedBridge(pidInfo, sessionName) {
1983
2022
  if (probe.identity === "own") {
1984
2023
  if (probe.reportedPid !== void 0) {
1985
2024
  if (probe.reportedPid === pidInfo.pid) {
2025
+ const verified = isBridgeProcess(pidInfo.pid);
1986
2026
  return {
1987
- terminate: true,
1988
- killProcessGroup: isBridgeProcess(pidInfo.pid),
2027
+ terminate: verified,
2028
+ killProcessGroup: verified,
1989
2029
  targetPid: pidInfo.pid
1990
2030
  };
1991
2031
  }
2032
+ const reportedIsBridge = isBridgeProcess(probe.reportedPid);
1992
2033
  return {
1993
- terminate: true,
1994
- killProcessGroup: isBridgeProcess(probe.reportedPid),
2034
+ terminate: reportedIsBridge,
2035
+ killProcessGroup: reportedIsBridge,
1995
2036
  targetPid: probe.reportedPid
1996
2037
  };
1997
2038
  }
@@ -1755,6 +1755,7 @@ var NodeHttpClient = class {
1755
1755
  let done = false;
1756
1756
  let error = null;
1757
1757
  let waiting = null;
1758
+ let consumerClosed = false;
1758
1759
  const wake = (value) => {
1759
1760
  if (!waiting) return;
1760
1761
  const w = waiting;
@@ -1840,6 +1841,7 @@ var NodeHttpClient = class {
1840
1841
  failStream(requestTimeoutError ?? new Error("SSE stream aborted"));
1841
1842
  });
1842
1843
  res.on("close", () => {
1844
+ if (consumerClosed) return;
1843
1845
  if (!done || !res.complete) {
1844
1846
  failStream(requestTimeoutError ?? new Error("SSE stream closed before end"));
1845
1847
  }
@@ -1865,6 +1867,7 @@ var NodeHttpClient = class {
1865
1867
  void waitResult;
1866
1868
  }
1867
1869
  } finally {
1870
+ consumerClosed = true;
1868
1871
  if (signal && abortHandler) {
1869
1872
  signal.removeEventListener("abort", abortHandler);
1870
1873
  }
@@ -2524,9 +2527,19 @@ var FileSystemGateway = class {
2524
2527
  const recursive = options?.recursive ?? true;
2525
2528
  const platform = detectPlatform();
2526
2529
  if (platform === "puerts" && typeof CS !== "undefined") {
2527
- if (CS.System.IO.Directory.Exists(path)) {
2530
+ if (!CS.System.IO.Directory.Exists(path)) {
2531
+ return;
2532
+ }
2533
+ if (typeof CS.System.IO.Directory.Delete === "function") {
2528
2534
  CS.System.IO.Directory.Delete(path, recursive);
2535
+ return;
2529
2536
  }
2537
+ const info = new CS.System.IO.DirectoryInfo(path);
2538
+ if (info && typeof info.Delete === "function") {
2539
+ info.Delete(recursive);
2540
+ return;
2541
+ }
2542
+ deletePuertsDirectoryByEnumeration(path, recursive);
2530
2543
  return;
2531
2544
  }
2532
2545
  const fs = nodeRequire("fs");
@@ -2549,9 +2562,20 @@ var FileSystemGateway = class {
2549
2562
  throw new Error(`Directory not found: ${source}`);
2550
2563
  }
2551
2564
  if (CS.System.IO.Directory.Exists(destination)) {
2552
- throw new Error(`Move target already exists: ${destination}`);
2565
+ const destinationFiles = Array.from(CS.System.IO.Directory.GetFiles(destination) ?? []);
2566
+ const destinationDirs = Array.from(CS.System.IO.Directory.GetDirectories(destination) ?? []);
2567
+ const isEmpty = destinationFiles.length === 0 && destinationDirs.length === 0;
2568
+ if (!isEmpty) {
2569
+ throw new Error(`Move target already exists: ${destination}`);
2570
+ }
2571
+ movePuertsDirectoryContents(source, destination);
2572
+ return;
2573
+ }
2574
+ if (typeof CS.System.IO.Directory.Move === "function") {
2575
+ CS.System.IO.Directory.Move(source, destination);
2576
+ } else {
2577
+ new CS.System.IO.DirectoryInfo(source).MoveTo(destination);
2553
2578
  }
2554
- CS.System.IO.Directory.Move(source, destination);
2555
2579
  return;
2556
2580
  }
2557
2581
  const fs = nodeRequire("fs");
@@ -2671,6 +2695,83 @@ var FileSystemGateway = class {
2671
2695
  return this.config;
2672
2696
  }
2673
2697
  };
2698
+ function movePuertsDirectoryContents(source, destination) {
2699
+ const directory = CS.System.IO.Directory;
2700
+ const file = CS.System.IO.File;
2701
+ if (typeof directory.GetFiles !== "function" || typeof directory.GetDirectories !== "function" || typeof directory.CreateDirectory !== "function" || typeof file.Copy !== "function") {
2702
+ throw new Error(
2703
+ `Host filesystem binding cannot move onto existing directory '${destination}': directory enumeration/copy is unavailable`
2704
+ );
2705
+ }
2706
+ if (isPuertsReparsePoint(source) || isPuertsReparsePoint(destination)) {
2707
+ throw new Error(
2708
+ `Refusing to move '${source}' through a reparse point (symlink/junction); resolve the link or delete it first`
2709
+ );
2710
+ }
2711
+ directory.CreateDirectory(destination);
2712
+ for (const entry of Array.from(directory.GetFiles(source) ?? [])) {
2713
+ const name = String(entry).replace(/\\/g, "/").split("/").pop();
2714
+ file.Copy(String(entry), `${destination}/${name}`, true);
2715
+ }
2716
+ for (const subdir of Array.from(directory.GetDirectories(source) ?? [])) {
2717
+ const name = String(subdir).replace(/\\/g, "/").split("/").pop();
2718
+ if (isPuertsReparsePoint(String(subdir))) continue;
2719
+ movePuertsDirectoryContents(String(subdir), `${destination}/${name}`);
2720
+ }
2721
+ for (const entry of Array.from(directory.GetFiles(source) ?? [])) {
2722
+ try {
2723
+ file.Delete(String(entry));
2724
+ } catch {
2725
+ }
2726
+ }
2727
+ }
2728
+ var warnedMissingPuertsGetAttributes = false;
2729
+ function isPuertsReparsePoint(path) {
2730
+ const file = CS.System.IO.File;
2731
+ if (typeof file.GetAttributes !== "function") {
2732
+ if (!warnedMissingPuertsGetAttributes) {
2733
+ warnedMissingPuertsGetAttributes = true;
2734
+ try {
2735
+ console.warn(
2736
+ "[platform] File.GetAttributes is unbound on this host; directory symlink checks are disabled (move/delete follow links)"
2737
+ );
2738
+ } catch {
2739
+ }
2740
+ }
2741
+ return false;
2742
+ }
2743
+ try {
2744
+ const attrs = file.GetAttributes(path);
2745
+ const raw = typeof attrs === "number" ? attrs : attrs.value__;
2746
+ const value = typeof raw === "number" ? raw : Number(raw);
2747
+ if (!Number.isFinite(value)) return false;
2748
+ return (value & 1024) !== 0;
2749
+ } catch {
2750
+ return false;
2751
+ }
2752
+ }
2753
+ function deletePuertsDirectoryByEnumeration(path, recursive) {
2754
+ const directory = CS.System.IO.Directory;
2755
+ const file = CS.System.IO.File;
2756
+ if (typeof directory.GetFiles !== "function" || typeof file.Delete !== "function") {
2757
+ throw new Error(
2758
+ `Host filesystem binding cannot delete directory '${path}': Directory.Delete and enumeration are unavailable`
2759
+ );
2760
+ }
2761
+ if (isPuertsReparsePoint(path)) {
2762
+ throw new Error(
2763
+ `Refusing to delete '${path}' through a reparse point (symlink/junction); resolve the link or delete it directly`
2764
+ );
2765
+ }
2766
+ const files = Array.from(directory.GetFiles(path) ?? []);
2767
+ for (const entry of files) file.Delete(entry);
2768
+ if (!recursive) return;
2769
+ const subdirs = Array.from(directory.GetDirectories(path) ?? []);
2770
+ for (const subdir of subdirs) {
2771
+ if (isPuertsReparsePoint(String(subdir))) continue;
2772
+ deletePuertsDirectoryByEnumeration(String(subdir), true);
2773
+ }
2774
+ }
2674
2775
 
2675
2776
  // ../../packages/platform/src/index.ts
2676
2777
  var fileSystemInstance = null;
@@ -3223,6 +3324,7 @@ var DEFAULT_OPENAI_COMPAT_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
3223
3324
  var DEFAULT_OPENAI_COMPAT_FIRST_BYTE_TIMEOUT_MS = 3 * 60 * 1e3;
3224
3325
  var OPENAI_COMPAT_FIRST_BYTE_MAX_ESCALATION_STEPS = 3;
3225
3326
  var openAICompatFirstByteTimeoutsByEndpoint = /* @__PURE__ */ new Map();
3327
+ var OPENAI_COMPAT_MAX_DUPLICATE_TOOL_CALLS = 3;
3226
3328
  var OPENAI_COMPAT_PROTOCOL_ERROR_CODE = "provider_response_protocol_error";
3227
3329
  var OpenAICompatProtocolError = class extends Error {
3228
3330
  code = OPENAI_COMPAT_PROTOCOL_ERROR_CODE;
@@ -3679,6 +3781,53 @@ var streamOpenAICompletions = (model, context, options) => {
3679
3781
  });
3680
3782
  }
3681
3783
  }
3784
+ const knownToolNames = new Set((context.tools ?? []).map((tool) => tool.name));
3785
+ const droppedToolCallBlocks = /* @__PURE__ */ new Set();
3786
+ const unknownNameSamples = [];
3787
+ if (knownToolNames.size > 0) {
3788
+ for (let i = toolCallEntries.length - 1; i >= 0; i--) {
3789
+ const entry = toolCallEntries[i];
3790
+ if (entry.block.name.trim() && !knownToolNames.has(entry.block.name)) {
3791
+ if (unknownNameSamples.length < 3) unknownNameSamples.push(JSON.stringify(entry.block.name));
3792
+ droppedToolCallBlocks.add(entry.block);
3793
+ toolCallEntries.splice(i, 1);
3794
+ }
3795
+ }
3796
+ }
3797
+ const emittedCallCounts = /* @__PURE__ */ new Map();
3798
+ const excessDuplicateEntries = /* @__PURE__ */ new Set();
3799
+ for (const entry of toolCallEntries) {
3800
+ const key = `${entry.block.name}
3801
+ ${entry.partialArgs}`;
3802
+ const seen = (emittedCallCounts.get(key) ?? 0) + 1;
3803
+ emittedCallCounts.set(key, seen);
3804
+ if (seen > OPENAI_COMPAT_MAX_DUPLICATE_TOOL_CALLS) excessDuplicateEntries.add(entry);
3805
+ }
3806
+ if (excessDuplicateEntries.size > 0) {
3807
+ for (let i = toolCallEntries.length - 1; i >= 0; i--) {
3808
+ if (excessDuplicateEntries.has(toolCallEntries[i])) {
3809
+ droppedToolCallBlocks.add(toolCallEntries[i].block);
3810
+ toolCallEntries.splice(i, 1);
3811
+ }
3812
+ }
3813
+ }
3814
+ if (droppedToolCallBlocks.size > 0) {
3815
+ const unknownCount = droppedToolCallBlocks.size - excessDuplicateEntries.size;
3816
+ output.content = output.content.filter(
3817
+ (block) => block.type !== "toolCall" || !droppedToolCallBlocks.has(block)
3818
+ );
3819
+ const reasons = [];
3820
+ if (unknownCount > 0) {
3821
+ reasons.push(`${unknownCount} named tools that are not part of this request (samples: ${unknownNameSamples.join(", ")})`);
3822
+ }
3823
+ if (excessDuplicateEntries.size > 0) {
3824
+ reasons.push(`${excessDuplicateEntries.size} were exact duplicates of an earlier call in the same message`);
3825
+ }
3826
+ output.content.push({
3827
+ type: "text",
3828
+ text: `[dropped ${droppedToolCallBlocks.size} tool call${droppedToolCallBlocks.size === 1 ? "" : "s"}: ${reasons.join("; ")}. Re-issue only the intended calls.]`
3829
+ });
3830
+ }
3682
3831
  for (const { block, partialArgs, contentIndex } of toolCallEntries) {
3683
3832
  if (!block.name.trim()) {
3684
3833
  throw createProtocolError("OpenAI-compatible stream returned a tool call without a function name.");
@@ -3686,8 +3835,11 @@ var streamOpenAICompletions = (model, context, options) => {
3686
3835
  block.arguments = parseFinalToolArguments(partialArgs, block.name);
3687
3836
  stream.push({ type: "toolcall_end", contentIndex, toolCall: block, partial: output });
3688
3837
  }
3689
- if (output.stopReason !== "error" && output.stopReason !== "aborted" && output.content.some((block) => block.type === "toolCall")) {
3838
+ const hasToolCallBlocks = output.content.some((block) => block.type === "toolCall");
3839
+ if (output.stopReason !== "error" && output.stopReason !== "aborted" && hasToolCallBlocks) {
3690
3840
  output.stopReason = "toolUse";
3841
+ } else if (output.stopReason === "toolUse" && !hasToolCallBlocks) {
3842
+ output.stopReason = "stop";
3691
3843
  }
3692
3844
  if (options?.signal?.aborted) {
3693
3845
  throw new Error("Request was aborted");
@@ -3,7 +3,7 @@ import {
3
3
  EventStream,
4
4
  streamSimple,
5
5
  validateToolArguments
6
- } from "./chunk-O2DKMLNX.js";
6
+ } from "./chunk-5OXH6NUH.js";
7
7
 
8
8
  // ../../packages/agent-core/src/agent-loop.ts
9
9
  function createLoopErrorMessage(error, config, signal) {
@@ -986,7 +986,7 @@ var Agent = class {
986
986
  message: event.message,
987
987
  toolResults: event.toolResults
988
988
  });
989
- } else if (hasToolCalls || stopReason === "toolUse") {
989
+ } else if (hasToolCalls) {
990
990
  this.updateStatusSnapshot({
991
991
  phase: "responding",
992
992
  turnState: "continuing",