@chen_hu_hu/pi-qq 1.6.1 → 1.6.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.6.2] - 2026-11-11
11
+
12
+ ### Changed
13
+
14
+ - While a task is running in `replyType: "full"`, `/last` now pushes the current thinking, tools, and text snapshot to the new message immediately instead of waiting for assistant text. If the stream was dead, the repush opens a new stream and resumes later output. An empty snapshot now replies with a notice instead of staying silent.
15
+ - Log files are now always written in English; the `language` setting only affects UI notifications and replies.
16
+ - Consolidated the 1.6.2 code review and repair notes into `doc/archive/delivery.1.6.2.md`; removed the temporary `doc/repair.md`.
17
+
18
+ ### Removed
19
+
20
+ - Removed `replyType: "last"`; the only modes are now `full` and `simple`. Existing `"last"` values fall back to `full` with a validation warning.
21
+
22
+ ### Fixed
23
+
24
+ - Stream rate-limit retries now advance `index` and recognize QQ `ApiError` HTTP/business codes.
25
+ - A `40054005` duplicate-`msgseq` error now opens a new stream with a fresh sequence and replays the buffered content instead of repeatedly resuming the failed stream.
26
+ - Empty attachment responses are rejected consistently.
27
+
10
28
  ## [1.6.1] - 2026-11-11
11
29
 
12
30
  ### Changed
@@ -161,7 +179,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
161
179
  - Added thinking labels, per-tool icons, model-error recovery, and idle-safe session handling.
162
180
  - Reorganized modules by bounded context and updated settings and delivery documentation.
163
181
 
164
- [Unreleased]: https://github.com/CQ-Developer/pi-qq/compare/v1.6.1...HEAD
182
+ [Unreleased]: https://github.com/CQ-Developer/pi-qq/compare/v1.6.2...HEAD
183
+ [1.6.2]: https://github.com/CQ-Developer/pi-qq/compare/v1.6.1...v1.6.2
165
184
  [1.6.1]: https://github.com/CQ-Developer/pi-qq/compare/v1.6.0...v1.6.1
166
185
  [1.6.0]: https://github.com/CQ-Developer/pi-qq/compare/v1.5.1...v1.6.0
167
186
  [1.5.1]: https://github.com/CQ-Developer/pi-qq/compare/v1.5.0...v1.5.1
package/README-zh.md CHANGED
@@ -105,7 +105,7 @@ QQ 侧命令:
105
105
  | `/stop` | 中止当前运行 |
106
106
  | `/compact` | 压缩当前上下文 |
107
107
  | `/status` | 显示会话和上下文状态 |
108
- | `/last` | 以流式推送最近完成的回复,或重新推送当前输出 |
108
+ | `/last` | 运行中重推当前输出;空闲时重推最近完成的回复 |
109
109
  | `/help` | 显示命令帮助 |
110
110
 
111
111
  ### 诊断
@@ -134,10 +134,10 @@ QQ 侧命令:
134
134
 
135
135
  | 配置项 | 默认值 | 说明 |
136
136
  | ------------- | ---------- | ------------------------------------------------------ |
137
- | `replyType` | `"full"` | 推送到 QQ 的内容粒度:`full`、`simple`、`last` |
137
+ | `replyType` | `"full"` | 推送到 QQ 的内容粒度:`full` 或 `simple` |
138
138
  | `deliverAs` | `"steer"` | 忙碌时新消息的排队方式:`steer` 或 `followUp` |
139
139
  | `fileMaxSize` | `52428800` | QQ 附件下载上限(字节,50MB) |
140
- | `language` | `"zh-cn"` | UI 和日志语言:`zh-cn` 或 `en-us` |
140
+ | `language` | `"zh-cn"` | UI 语言:`zh-cn` 或 `en-us`;日志始终为英文 |
141
141
  | `logLevel` | `"silent"` | 日志阈值:`silent`、`error`、`warn`、`info` 或 `debug` |
142
142
 
143
143
  配置在扩展加载时读取,并在每条来自已绑定用户的 QQ 消息处理前重新读取。修改后下一条消息即生效,无需重启 pi 或重新登录。未知配置项会被忽略,无效值会回退到默认值并给出提示。
@@ -150,13 +150,12 @@ QQ 侧命令:
150
150
  | -------- | ------------------------------------------------------------- |
151
151
  | `full` | 思考块、工具调用、工具结果,以及每一条 assistant 消息(默认) |
152
152
  | `simple` | 只推 assistant 消息,每条一个气泡 |
153
- | `last` | 只推 run 中最后一条 assistant 消息,在 run 结束时送出 |
154
153
 
155
154
  - `full` 是默认值,保持 pi-qq 1.5.x 的行为;该模式固定回传思考。
156
155
  - `simple` 会实时流出每一条 assistant 消息,一条消息一个气泡。
157
- - `last` 在任务运行期间不推送任何内容;运行期间执行 `/last` 会回复“任务仍在进行中”。
158
156
  - 无论哪种模式,模型错误消息都会立即以普通消息发出。
159
- - `simple` 与 `last` 不回传工具输出,但 `qq_send_media` 发送的文件仍然会送达。
157
+ - `simple` 不回传工具输出,但 `qq_send_media` 发送的文件仍然会送达。
158
+ - 任务运行中执行 `/last` 时,`full` 模式会推送当前思考、工具和文本快照;`simple` 模式只推送当前文本。
160
159
 
161
160
  ### `deliverAs`
162
161
 
@@ -171,7 +170,7 @@ QQ 侧命令:
171
170
 
172
171
  ### `language`
173
172
 
174
- UI 提示与日志的语言。
173
+ UI 提示与回复的语言。日志文件始终使用英文,不受该配置影响。
175
174
 
176
175
  - `zh-cn`(默认):简体中文。
177
176
  - `en-us`:英文。
package/README.md CHANGED
@@ -99,14 +99,14 @@ Run these in the pi terminal:
99
99
 
100
100
  QQ-side commands:
101
101
 
102
- | Command | Description |
103
- | ---------- | ------------------------------------------------------------------------ |
104
- | `/new` | Start a new pi session |
105
- | `/stop` | Abort the current run |
106
- | `/compact` | Compact the current context |
107
- | `/status` | Show session and context status |
108
- | `/last` | Push the last completed reply as a stream, or restart the current output |
109
- | `/help` | Show command help |
102
+ | Command | Description |
103
+ | ---------- | -------------------------------------------------------------------------- |
104
+ | `/new` | Start a new pi session |
105
+ | `/stop` | Abort the current run |
106
+ | `/compact` | Compact the current context |
107
+ | `/status` | Show session and context status |
108
+ | `/last` | Repush current output while running, or the last completed reply when idle |
109
+ | `/help` | Show command help |
110
110
 
111
111
  ### Diagnostics
112
112
 
@@ -132,13 +132,13 @@ Create `~/.pi/agent/pi-qq.json` to override defaults. It stores settings only; c
132
132
  }
133
133
  ```
134
134
 
135
- | Key | Default | Description |
136
- | ------------- | ---------- | ------------------------------------------------------------ |
137
- | `replyType` | `"full"` | How much of a run is pushed to QQ: `full`, `simple`, `last` |
138
- | `deliverAs` | `"steer"` | Queue new messages while busy: `steer` or `followUp` |
139
- | `fileMaxSize` | `52428800` | QQ attachment download limit in bytes (50MB) |
140
- | `language` | `"zh-cn"` | UI and log language: `zh-cn` or `en-us` |
141
- | `logLevel` | `"silent"` | Log threshold: `silent`, `error`, `warn`, `info`, or `debug` |
135
+ | Key | Default | Description |
136
+ | ------------- | ---------- | ------------------------------------------------------------- |
137
+ | `replyType` | `"full"` | How much of a run is pushed to QQ: `full` or `simple` |
138
+ | `deliverAs` | `"steer"` | Queue new messages while busy: `steer` or `followUp` |
139
+ | `fileMaxSize` | `52428800` | QQ attachment download limit in bytes (50MB) |
140
+ | `language` | `"zh-cn"` | UI language: `zh-cn` or `en-us`; log files are always English |
141
+ | `logLevel` | `"silent"` | Log threshold: `silent`, `error`, `warn`, `info`, or `debug` |
142
142
 
143
143
  Settings are loaded when the extension starts and re-read on every inbound QQ message from the bound user, so edits take effect on the next message without restarting pi or logging in again. Unknown keys are ignored, and invalid values fall back to defaults with a warning.
144
144
 
@@ -150,13 +150,12 @@ How much of an agent run is pushed to QQ.
150
150
  | -------- | -------------------------------------------------------------------------------- |
151
151
  | `full` | Thinking blocks, tool calls, tool results, and every assistant message (default) |
152
152
  | `simple` | Assistant messages only, one bubble each |
153
- | `last` | Only the last assistant message of the run, sent when the run ends |
154
153
 
155
154
  - `full` is the default and keeps the behaviour of pi-qq 1.5.x; thinking is always relayed in this mode.
156
155
  - `simple` streams every assistant message live, one QQ bubble per message.
157
- - `last` sends nothing while the task is running; `/last` during a running task replies that the task is still running.
158
- - Model errors are always delivered immediately as a normal message, in every mode.
159
- - Tool output is not relayed in `simple` or `last`, but files sent with `qq_send_media` are still delivered.
156
+ - Model errors are always delivered immediately as a normal message, in either mode.
157
+ - Tool output is not relayed in `simple`, but files sent with `qq_send_media` are still delivered.
158
+ - While a task is running, `/last` pushes the current thinking/tools/text snapshot in `full` mode; in `simple` mode it pushes the current text.
160
159
 
161
160
  ### `deliverAs`
162
161
 
@@ -171,7 +170,7 @@ Maximum size of an inbound attachment, in bytes (default `52428800`, 50MB). Larg
171
170
 
172
171
  ### `language`
173
172
 
174
- Language of the UI notifications and the log messages.
173
+ Language of UI notifications and replies. Log files are always written in English, regardless of this setting.
175
174
 
176
175
  - `zh-cn` (default): Simplified Chinese.
177
176
  - `en-us`: English.
@@ -0,0 +1,196 @@
1
+ # pi-qq delivery 1.6.2
2
+
3
+ > **Delivery record.** 1.6.2 makes `/last` repush the current run snapshot, hardens stream recovery, removes `replyType: "last"`, and consolidates the code-review and repair notes. See [README](../../README.md) for current user-facing behavior.
4
+ > Version: 1.6.2
5
+ > Date: 2026-11-11
6
+ > Previous: [delivery.1.6.1.md](./delivery.1.6.1.md).
7
+ > Open work: [doc/todo.md](../todo.md).
8
+
9
+ ## 1. Scope
10
+
11
+ Before 1.6.2, `/last` during a run only repushed `run.currentText`. If the run was still producing thinking or tools, the command silently did nothing. A separate long-run defect also stopped all relay output when QQ returned `40054005` (duplicate `msgseq`).
12
+
13
+ 1.6.2 covers:
14
+
15
+ - `/last` snapshot repush for `replyType: "full"`;
16
+ - separation of run content state from stream delivery;
17
+ - removal of `replyType: "last"`;
18
+ - rate-limit retry correctness;
19
+ - fresh-stream recovery for duplicate `msgseq`;
20
+ - English-only log messages;
21
+ - dead-code and duplication cleanup from the full code review;
22
+ - direct tests for the new timeline and writer boundaries.
23
+
24
+ Out of scope:
25
+
26
+ - replaying the complete run history;
27
+ - changing model/agent behavior or tool set;
28
+ - adding tool partial-output forwarding;
29
+ - docs packaging changes and optional large refactors listed in section 8.
30
+
31
+ ## 2. Observed failure
32
+
33
+ The 2026-11-11 log contained a 26-minute run that reached 221 stream bubbles. At 12:55:19 local time the next stream used a previously used `msg_seq`:
34
+
35
+ ```text
36
+ 40054005 消息被去重,请检查请求msgseq
37
+ ```
38
+
39
+ The same checkpoint `msgSeq` was retried twice, all retries were rejected, and `BubbleWriter` killed the stream. After that:
40
+
41
+ - 146 subsequent tool starts produced no relay output;
42
+ - `/last` at 13:01:44 and 13:04:21 logged `last repush ignored` with `textLength=0`;
43
+ - the first assistant text appeared at 13:09:56, after both `/last` calls;
44
+ - the final text used the normal plain-message fallback.
45
+
46
+ The `/last` calls did not fail because the text was too old; at that moment there was no `currentText` at all. The run state and the delivery writer were coupled, so `/last` could not use the thinking/tool state.
47
+
48
+ ## 3. Final decisions
49
+
50
+ | # | Question | Decision |
51
+ | --- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
52
+ | D1 | What should `/last` push during a full-mode run? | The current thinking, the active/recent tools, and the current text, without waiting for assistant text. |
53
+ | D2 | How much history should `/last` replay? | A bounded state snapshot: current active tool plus the last three finished tools, capped at five. |
54
+ | D3 | Should run state depend on the writer? | No. `RunTimeline` owns content and tool lifecycle; `RunFeedback` decides delivery. |
55
+ | D4 | What should happen on `40054005`? | Open a new stream with a fresh `msgSeq`, replay the failed buffer, and keep the existing recovery cap. |
56
+ | D5 | Should `replyType: "last"` remain? | No. Keep only `full` and `simple`; old `"last"` values fall back to `full` with a validation warning. |
57
+ | D6 | Should log files follow `language`? | No. Log messages are written directly in English; `language` only affects UI notifications and replies. |
58
+ | D7 | Should `/last` fail silently when there is no content? | No. Reply with `commands.last.empty`. |
59
+
60
+ ## 4. `/last` snapshot
61
+
62
+ `repushCurrent()` now builds a `RepushResult` instead of returning a bare boolean:
63
+
64
+ ```ts
65
+ type RepushResult =
66
+ | { ok: true; thinkingLength: number; toolCount: number; textLength: number }
67
+ | { ok: false; reason: "no-run" | "empty" };
68
+ ```
69
+
70
+ Full-mode snapshot order:
71
+
72
+ 1. current thinking;
73
+ 2. current active tool and recent finished tools in start order;
74
+ 3. current assistant text.
75
+
76
+ `BubbleWriter.restartSnapshot()` accepts structured blocks and:
77
+
78
+ - closes an open code fence;
79
+ - rotates the old stream;
80
+ - updates the target `openid` / `msgId`;
81
+ - resets `streamDead`, pending resume, block and fence state;
82
+ - pushes thinking/tool/text blocks to the new stream.
83
+
84
+ `simple` mode uses a text-only snapshot. `last` mode no longer exists.
85
+
86
+ After a repush:
87
+
88
+ - `thinkingSentLen` / `resultSentLen` are not reset; they continue tracking processed content;
89
+ - deferred thinking/text are cleared because the snapshot already includes them;
90
+ - an active tool result and subsequent assistant deltas continue on the new stream.
91
+
92
+ ## 5. Stream reliability
93
+
94
+ ### 5.1 Rate-limit retries
95
+
96
+ `AppendStream.sendWithRetry()` now:
97
+
98
+ - advances `index` before a rate-limit retry, matching `qqbot-nodejs`'s `StreamSession`;
99
+ - recognizes `status`, `httpStatus`, `code`, `err_code`, `bizCode`, and message text for 429/50002.
100
+
101
+ ### 5.2 Duplicate `msgseq`
102
+
103
+ `BubbleWriter.handleStreamError()` detects `40054005` / duplicate-`msgseq` messages. Instead of resuming the same checkpoint, it opens a fresh stream with:
104
+
105
+ - no old `msgSeq` (the new stream generates one);
106
+ - `index: 0`;
107
+ - the failed buffer preserved.
108
+
109
+ Other stream errors keep the existing resume semantics. The recovery-attempt cap still applies.
110
+
111
+ ## 6. Implementation
112
+
113
+ | File | Change |
114
+ | ------------------------------------- | --------------------------------------------------------------------------------------------- |
115
+ | `src/relay/run-timeline.ts` (new) | `RunTimeline`, tool state, snapshot selection, diagnostics |
116
+ | `src/relay/run-stream-relay.ts` | Uses `RunTimeline`; `advanceTools()`; `RepushResult`; removes last-mode delivery and fallback |
117
+ | `src/relay/bubble-writer.ts` | `RepushBlock`, `restartSnapshot()`, fresh-stream recovery, options-based push API |
118
+ | `src/relay/stream-session.ts` | Rate-limit index advance, API status fields, optional fresh `msgSeq` resume |
119
+ | `src/relay/reply-policy.ts` | Removes `relayTextLive`, `deliverLastAtEnd`, and last policy |
120
+ | `src/infra/reply-type.ts` | Only `full` and `simple` |
121
+ | `src/qq/inbound-command.ts` | `/last` consumes `InboundPushResult`; empty snapshot notice |
122
+ | `src/qq/media-tool.ts` | Shared send/result helper; removes test-only `isActive` |
123
+ | `src/infra/file-logger.ts` | Writes direct English messages; `msgKey` lookup only |
124
+ | `src/infra/log-message-keys.ts` (new) | Stable English message-to-key map |
125
+ | `src/infra/i18n.ts` | UI strings only; log translations and localization removed |
126
+
127
+ ## 7. Verification
128
+
129
+ Automated:
130
+
131
+ - **234 tests** across 22 files.
132
+ - `npm run lint`, `npm run typecheck`, `npm run format:check`, and `npm pack --dry-run` pass.
133
+ - New tests cover:
134
+ - thinking-only and tool-only `/last` snapshots;
135
+ - snapshot ordering and the tool window;
136
+ - writer-dead recovery;
137
+ - continuation of tool results after repush;
138
+ - `40054005` fresh-stream recovery;
139
+ - rate-limit index and `httpStatus` / `bizCode` detection;
140
+ - direct `restartSnapshot()` behavior.
141
+
142
+ Manual QQ smoke test (`pi-qq-2026-11-11.log`, local time 18:11–18:17):
143
+
144
+ - four runs covering `simple` and `full`;
145
+ - `/last` in full mode repushed 366 characters of current thinking and two tools with a new `msgId`;
146
+ - `/status` returned the expected full-mode report;
147
+ - `/stop` ended both active runs;
148
+ - no warnings, stream errors, `40054005`, or rate-limit events.
149
+
150
+ Not manually exercised:
151
+
152
+ - actual rate-limit retry;
153
+ - actual `40054005` recovery;
154
+ - `/last` with a dead writer;
155
+ - `/last` in `simple` mode.
156
+
157
+ These paths are covered by automated tests.
158
+
159
+ ## 8. Code review consolidation
160
+
161
+ Fixed from the review:
162
+
163
+ - rate-limit retry index and API error fields;
164
+ - duplicate-`msgseq` recovery;
165
+ - unused relay/command surface and dead translations;
166
+ - duplicated media send/result construction and text-delta handling;
167
+ - command-layer dependency on the relay `RepushResult` type;
168
+ - unnecessary `index` option in attachment saves;
169
+ - empty attachment responses;
170
+ - English-only log messages.
171
+
172
+ Deferred intentionally:
173
+
174
+ - npm package docs policy (`doc/todo.md` and archive docs) is left to the release owner;
175
+ - splitting `index.ts`, `BubbleWriter`, or the large `run-stream-relay` test file further;
176
+ - a broader `ReplyType` policy refactor beyond the two remaining modes.
177
+
178
+ No dependency cycles were found.
179
+
180
+ ## 9. Risks and limitations
181
+
182
+ | Risk | Impact | Handling |
183
+ | ------------------------------------------------------------ | -------------------------------------------------- | ----------------------------------------------------------- |
184
+ | Snapshot order differs from the original interleaving | Repush is a state snapshot, not a full transcript | Documented behavior |
185
+ | Tool window is bounded | Older tools are omitted | Active tool + last three finished tools |
186
+ | A duplicate-`msgseq` repush can create a new bubble | The old bubble remains | Only triggered by a stream failure; history is not replayed |
187
+ | `replyType: "last"` removal is breaking for configured users | Values fall back to full with a warning | Documented in the READMEs and changelog |
188
+ | Log language no longer follows `language` | Existing users may expect localized logs | Logs are stable English; UI remains localized |
189
+ | `doc/` contents are still in the current package manifest | Internal notes may ship until packaging is changed | Deferred to the release owner |
190
+
191
+ ## 10. References
192
+
193
+ - User-facing behavior: [README.md](../../README.md), [README-zh.md](../../README-zh.md).
194
+ - Previous delivery: [delivery.1.6.1.md](./delivery.1.6.1.md).
195
+ - Manual test log: `/home/chen/project/mine/pi-qq-test/.pi/pi-qq/logs/pi-qq-2026-11-11.log`.
196
+ - This record replaces the temporary `doc/repair.md` and code-review working notes.
package/index.ts CHANGED
@@ -47,20 +47,6 @@ const runFeedback = new RunFeedback({
47
47
  budget,
48
48
  getReplyType: () => activeSettings.replyType,
49
49
  onWarn: (msg) => sessionCtx?.ui.notify(`pi-qq ${msg}`, "warning"),
50
- onFallbackReply: (text) => {
51
- const bot = running?.bot;
52
- const bound = getLoginState()?.allowedOpenid;
53
- if (!bot || !bound) {
54
- log.warn("pi", "fallback reply skipped: no bot or bound user");
55
- return;
56
- }
57
- log.info("pi", "sending fallback reply", { textLength: text.length });
58
- void sendReply(bot, markdownToPlain(text), {
59
- budget,
60
- boundOpenid: bound,
61
- onWarn: (msg) => sessionCtx?.ui.notify(`pi-qq ${msg}`, "warning"),
62
- });
63
- },
64
50
  });
65
51
 
66
52
  const eventLoopDelay = monitorEventLoopDelay({ resolution: 100 });
@@ -146,7 +132,6 @@ export default function (pi: ExtensionAPI) {
146
132
 
147
133
  const getAllowedOpenid = () => getLoginState()?.allowedOpenid;
148
134
  const getDeliverAs = () => activeSettings.deliverAs;
149
- const getReplyType = () => activeSettings.replyType;
150
135
 
151
136
  const onWarn = (ctx: ExtensionContext) => (msg: string) => ctx.ui.notify(`pi-qq ${msg}`, "warning");
152
137
 
@@ -214,7 +199,6 @@ export default function (pi: ExtensionAPI) {
214
199
  getAllowedOpenid,
215
200
  reloadSettings: () => applyConfig(ctx, { dedupeError: true }),
216
201
  getDeliverAs,
217
- getReplyType,
218
202
  getFileMaxSize: () => activeSettings.fileMaxSize,
219
203
  getStatusLines,
220
204
  getLastMessage: () => runFeedback.getLastMessage(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chen_hu_hu/pi-qq",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Connect pi to QQ private chats.",
5
5
  "license": "MIT",
6
6
  "author": "CQ-Developer",
@@ -8,7 +8,7 @@ export interface InboundAttachmentLike {
8
8
  size?: number;
9
9
  }
10
10
 
11
- export interface DownloadOptions {
11
+ interface DownloadOptions {
12
12
  url: string;
13
13
  maxSize: number;
14
14
  timeoutMs: number;
@@ -19,6 +19,7 @@ export interface DownloadOptions {
19
19
  async function readBodyLimited(response: Response, limit: number, kind: string): Promise<Buffer> {
20
20
  if (!response.body) {
21
21
  const body = Buffer.from(await response.arrayBuffer());
22
+ if (body.byteLength === 0) throw new Error(t("attachments.empty", { kind }));
22
23
  if (body.byteLength > limit) {
23
24
  throw new Error(
24
25
  t("attachments.tooLarge", { kind, size: formatBytes(body.byteLength), limit: formatBytes(limit) }),
@@ -14,16 +14,15 @@ export interface SavedFile {
14
14
  path: string;
15
15
  }
16
16
 
17
- export type UploadIndex = Record<string, string>;
17
+ type UploadIndex = Record<string, string>;
18
18
 
19
- export interface SaveFilesOptions {
19
+ interface SaveFilesOptions {
20
20
  maxSize: number;
21
21
  uploadDir: string;
22
- index?: UploadIndex;
23
22
  fetchImpl?: typeof fetch;
24
23
  }
25
24
 
26
- export interface SaveFilesResult {
25
+ interface SaveFilesResult {
27
26
  files: SavedFile[];
28
27
  failures: AttachmentFailure[];
29
28
  }
@@ -189,7 +188,7 @@ export async function saveInboundFiles(
189
188
  const uploadDir = options.uploadDir;
190
189
  const limit = Math.max(1, options.maxSize);
191
190
  const fetchImpl = options.fetchImpl ?? fetch;
192
- const index = options.index ?? (await loadUploadIndex(uploadDir));
191
+ const index = await loadUploadIndex(uploadDir);
193
192
  const files: SavedFile[] = [];
194
193
  const failures: AttachmentFailure[] = [];
195
194
  const seenPaths = new Set<string>();
@@ -1,6 +1,6 @@
1
1
  import { appendFile, mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { localizeLogMessage } from "./i18n";
3
+ import { logMessageKey } from "./log-message-keys";
4
4
 
5
5
  export type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
6
6
  type LogFields = Record<string, unknown>;
@@ -93,13 +93,13 @@ function writeRecord(level: Exclude<LogLevel, "silent">, scope: string, message:
93
93
  if (!isLevelEnabled(activeLevel, level)) return;
94
94
  if (!isLogAllowed()) return;
95
95
 
96
- const localized = localizeLogMessage(message);
96
+ const msgKey = logMessageKey(message);
97
97
  const record: LogFields = {
98
98
  time: new Date().toISOString(),
99
99
  level,
100
100
  scope,
101
- ...(localized.msgKey ? { msgKey: localized.msgKey } : {}),
102
- msg: localized.msg,
101
+ ...(msgKey ? { msgKey } : {}),
102
+ msg: message,
103
103
  };
104
104
  const fields = normalizeData(data);
105
105
  if (fields) {
@@ -122,8 +122,8 @@ function writeRecord(level: Exclude<LogLevel, "silent">, scope: string, message:
122
122
  time: record.time,
123
123
  level,
124
124
  scope,
125
- ...(localized.msgKey ? { msgKey: localized.msgKey } : {}),
126
- msg: localized.msg,
125
+ ...(msgKey ? { msgKey } : {}),
126
+ msg: message,
127
127
  serializationError: stringifyError(err),
128
128
  });
129
129
  }