@chen_hu_hu/pi-qq 1.3.3 → 1.3.4

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.
@@ -143,7 +143,7 @@ export class RunFeedback {
143
143
  writer,
144
144
  };
145
145
  this.run = run;
146
- log.debug("run", "started", { msgId: run.msgId?.slice(0, 8) ?? "?" });
146
+ log.debug("run", "run started", { msgId: run.msgId?.slice(0, 8) ?? "?" });
147
147
 
148
148
  const keepTyping = () => {
149
149
  void bot.sendTyping({ scope: "c2c", targetId: run.openid }, 60).catch(() => {});
@@ -245,7 +245,7 @@ export class RunFeedback {
245
245
  if (run.currentText.trim()) this.lastCompletedText = run.currentText;
246
246
  if (!run.hadError && run.writer.hasPushed) this.recovery = null;
247
247
  this.run = null;
248
- log.debug("run", "ended", {
248
+ log.debug("run", "run ended", {
249
249
  msgId: run.msgId?.slice(0, 8) ?? "?",
250
250
  elapsedMs: Date.now() - run.startedAt,
251
251
  });
@@ -1,4 +1,8 @@
1
- export const THINKING_HEADER = "**💭 思考**\n\n";
1
+ import { t } from "../infra/i18n";
2
+
3
+ export function thinkingHeader(): string {
4
+ return `**💭 ${t("stream.thinking")}**\n\n`;
5
+ }
2
6
  const ARG_MAX_CHARS = 200;
3
7
  const RESULT_MAX_CHARS = 600;
4
8
  const RESULT_MAX_LINES = 8;
@@ -109,7 +113,7 @@ function resultText(result: unknown): string {
109
113
  export function formatToolResult(result: unknown, isError: boolean): string {
110
114
  let text = resultText(result);
111
115
  text = text.replace(/\r\n/g, "\n").replace(/\s+$/, "");
112
- if (!text) text = "(no output)";
116
+ if (!text) text = t("stream.noOutput");
113
117
  text = truncateText(text, RESULT_MAX_CHARS, RESULT_MAX_LINES);
114
118
  if (isError) text = `❌ ${text}`;
115
119
  const fence = backtickFence(text, 3);
@@ -1,4 +1,5 @@
1
1
  import { getNextMsgSeq, StreamContentType, StreamInputState } from "@tencent-connect/qqbot-nodejs/protocol";
2
+ import { t } from "../infra/i18n";
2
3
  import type {
3
4
  Credentials,
4
5
  MessageApi,
@@ -164,13 +165,11 @@ export class AppendStream {
164
165
  } catch (err) {
165
166
  const reason = err instanceof Error ? err.message : String(err);
166
167
  if (attempt >= MAX_RETRIES || !this.isRateLimitError(err)) {
167
- this.opts.onDebug?.(`frame index=${req.index} failed after ${attempt + 1} attempt(s): ${reason}`);
168
+ this.opts.onDebug?.(t("log.streamFrameFailed", { index: req.index, attempts: attempt + 1, reason }));
168
169
  throw err;
169
170
  }
170
171
  const delay = base * 2 ** attempt;
171
- this.opts.onDebug?.(
172
- `frame index=${req.index} rate limited (attempt ${attempt + 1}), retry in ${delay}ms: ${reason}`,
173
- );
172
+ this.opts.onDebug?.(t("log.streamFrameRateLimited", { index: req.index, attempt: attempt + 1, delay, reason }));
174
173
  await new Promise((r) => setTimeout(r, delay));
175
174
  }
176
175
  }