@openclaw-china/dingtalk 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5845,6 +5845,8 @@ async function* streamFromGateway(params) {
5845
5845
  const reader = response.body.getReader();
5846
5846
  const decoder = new TextDecoder();
5847
5847
  let buffer = "";
5848
+ let lastChunkTime = null;
5849
+ const TASK_BOUNDARY_THRESHOLD_MS = 1e3;
5848
5850
  while (true) {
5849
5851
  const { done: readDone, value } = await reader.read();
5850
5852
  if (readDone) break;
@@ -5857,9 +5859,18 @@ async function* streamFromGateway(params) {
5857
5859
  if (data === "[DONE]") return;
5858
5860
  try {
5859
5861
  const chunk = JSON.parse(data);
5860
- const content = chunk?.choices?.[0]?.delta?.content;
5862
+ const choice = chunk?.choices?.[0];
5863
+ const content = choice?.delta?.content;
5861
5864
  if (typeof content === "string" && content) {
5865
+ const now = Date.now();
5866
+ if (lastChunkTime !== null) {
5867
+ const timeSinceLastChunk = now - lastChunkTime;
5868
+ if (timeSinceLastChunk > TASK_BOUNDARY_THRESHOLD_MS) {
5869
+ yield "\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n";
5870
+ }
5871
+ }
5862
5872
  yield content;
5873
+ lastChunkTime = now;
5863
5874
  }
5864
5875
  } catch {
5865
5876
  continue;