@hfyjq/crannia 1.1.2 → 1.2.0

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.
Files changed (306) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +48 -45
  3. package/README.md +1 -1
  4. package/THIRD-PARTY-FRONTEND.md +5266 -5266
  5. package/THIRD-PARTY-PYTHON-linux.md +174 -0
  6. package/THIRD-PARTY-PYTHON.md +176 -162
  7. package/THIRD-PARTY.md +323 -316
  8. package/apps/desktop/quotes.txt +56 -56
  9. package/bus/core.py +677 -671
  10. package/bus/loaders/channel_loader.py +64 -64
  11. package/bus/loaders/provider_loader.py +4 -7
  12. package/bus/loaders/skill_loader.py +46 -27
  13. package/bus/loaders/skill_md.py +9 -9
  14. package/bus/mcp_disabled.py +4 -6
  15. package/bus/quarantine.py +10 -13
  16. package/bus/registry.py +2315 -2284
  17. package/bus/skill_state.py +124 -124
  18. package/channels/cli_channel/handler.py +3 -3
  19. package/channels/cli_channel/manifest.yaml +5 -5
  20. package/channels/dingtalk_channel/handler.py +32 -32
  21. package/channels/dingtalk_channel/manifest.yaml +12 -12
  22. package/channels/feishu_channel/handler.py +33 -33
  23. package/channels/feishu_channel/manifest.yaml +12 -12
  24. package/channels/qq_bot_channel/__init__.py +1 -1
  25. package/channels/qq_bot_channel/handler.py +24 -24
  26. package/channels/qq_bot_channel/manifest.yaml +4 -4
  27. package/channels/telegram_channel/__init__.py +1 -1
  28. package/channels/telegram_channel/handler.py +21 -21
  29. package/channels/telegram_channel/manifest.yaml +4 -4
  30. package/channels/telegram_channel/media.py +231 -231
  31. package/channels/textfmt.py +58 -58
  32. package/channels/wechat_channel/__init__.py +1 -1
  33. package/channels/wechat_channel/converter.py +1 -1
  34. package/channels/wechat_channel/handler.py +8 -8
  35. package/channels/wechat_channel/manifest.yaml +5 -5
  36. package/channels/wechat_channel/media.py +178 -178
  37. package/core/activity.py +753 -709
  38. package/core/agent_loop.py +7673 -7522
  39. package/core/allowlist.py +2 -3
  40. package/core/approval.py +34 -24
  41. package/core/approval_timeout.py +256 -228
  42. package/core/artifacts.py +3 -3
  43. package/core/attachment_gc.py +21 -0
  44. package/core/auto_review.py +2 -2
  45. package/core/browser/cdp.py +5 -2
  46. package/core/browser/discover.py +55 -19
  47. package/core/browser/session.py +4 -4
  48. package/core/cache_break_detector.py +97 -0
  49. package/core/cache_breakpoints.py +103 -0
  50. package/core/cache_policies.py +255 -0
  51. package/core/cancellation.py +3 -3
  52. package/core/channel_configs.py +3 -3
  53. package/core/channel_turns.py +13 -13
  54. package/core/child_approval.py +2 -3
  55. package/core/code_intel.py +11 -11
  56. package/core/command_policy.py +13 -7
  57. package/core/computer/annotate.py +231 -11
  58. package/core/computer/capture.py +140 -1
  59. package/core/computer/guard.py +7 -4
  60. package/core/computer/input.py +452 -26
  61. package/core/computer/session.py +563 -381
  62. package/core/computer/tools.py +2170 -928
  63. package/core/computer/uia.py +100 -1
  64. package/core/computer/watch.py +1 -1
  65. package/core/computer/win32.py +302 -7
  66. package/core/config_requirements.py +205 -205
  67. package/core/cron/runner.py +4 -4
  68. package/core/daily_log.py +2 -2
  69. package/core/dedup.py +2 -2
  70. package/core/egress_channels.py +326 -0
  71. package/core/egress_gate.py +96 -8
  72. package/core/egress_preapproved.py +59 -3
  73. package/core/endpoint.py +141 -141
  74. package/core/events.py +17 -8
  75. package/core/extension.py +2 -2
  76. package/core/file_history.py +10 -10
  77. package/core/file_tools.py +3 -3
  78. package/core/github_config.py +1 -1
  79. package/core/group_digest.py +3 -4
  80. package/core/group_minutes.py +5 -5
  81. package/core/group_reply.py +24 -0
  82. package/core/groups.py +5 -9
  83. package/core/hooks.py +15 -15
  84. package/core/i18n.py +2 -2
  85. package/core/ice/canary.py +3 -3
  86. package/core/ice/net_heuristics.py +2 -2
  87. package/core/im_routing.py +2 -2
  88. package/core/image_input.py +183 -43
  89. package/core/inbound.py +3 -3
  90. package/core/jobs.py +6 -6
  91. package/core/last_good.py +150 -150
  92. package/core/leaf_md.py +3 -3
  93. package/core/llm_errors.py +36 -27
  94. package/core/mail_config.py +2 -2
  95. package/core/memory/compressor.py +8 -8
  96. package/core/memory/manager.py +30 -45
  97. package/core/memory/session_memory.py +1 -2
  98. package/core/memory/short_term.py +4 -4
  99. package/core/memory_extract.py +1 -1
  100. package/core/memory_organize.py +8 -8
  101. package/core/memory_store.py +7 -9
  102. package/core/memory_transfer.py +2 -2
  103. package/core/model_capabilities.py +2 -2
  104. package/core/model_configs.py +219 -68
  105. package/core/model_profiles.py +333 -0
  106. package/core/modes.py +12 -11
  107. package/core/net_proxy.py +3 -3
  108. package/core/pipeline/scheduler.py +48 -43
  109. package/core/pipeline/stage.py +3 -0
  110. package/core/pipeline/stages/agent_loop.py +36 -15
  111. package/core/pipeline/stages/group_reply.py +22 -20
  112. package/core/pipeline/stages/post_process.py +7 -7
  113. package/core/pipeline/stages/pre_process.py +360 -68
  114. package/core/prompt_assembler.py +13 -4
  115. package/core/recycle.py +227 -16
  116. package/core/response_language.py +1 -1
  117. package/core/retention.py +2 -2
  118. package/core/rg.py +4 -3
  119. package/core/security.py +26 -8
  120. package/core/services.py +8 -8
  121. package/core/session_model.py +3 -5
  122. package/core/session_pool.py +35 -5
  123. package/core/session_recap.py +40 -3
  124. package/core/session_workspace.py +2 -3
  125. package/core/settings_baseline.py +2 -2
  126. package/core/settings_transfer.py +25 -1
  127. package/core/shell.py +52 -20
  128. package/core/side_call.py +3 -3
  129. package/core/skill_config.py +164 -0
  130. package/core/skill_factory.py +2 -2
  131. package/core/skill_guidance.py +2 -4
  132. package/core/skill_index.py +3 -4
  133. package/core/skill_settings.py +1 -1
  134. package/core/skill_sources.py +7 -7
  135. package/core/ssh_config.py +129 -0
  136. package/core/state_registry.py +67 -5
  137. package/core/subagent.py +28 -5
  138. package/core/subagent_defs.py +3 -3
  139. package/core/summarizer.py +4 -5
  140. package/core/tasks_notify.py +6 -6
  141. package/core/tiers.py +2 -2
  142. package/core/todos.py +1 -1
  143. package/core/token_calibrator.py +1 -4
  144. package/core/tool_outcome.py +108 -108
  145. package/core/touched_files.py +1 -1
  146. package/core/trace.py +12 -3
  147. package/core/unlock.py +4 -4
  148. package/core/update_tui.py +184 -158
  149. package/core/updater.py +5 -3
  150. package/core/version.py +14 -14
  151. package/core/vision_budget.py +235 -0
  152. package/core/web_cache.py +152 -152
  153. package/core/web_request.py +474 -0
  154. package/core/window_estimate.py +1 -1
  155. package/core/workspace.py +56 -26
  156. package/crannia_tray.py +278 -278
  157. package/licenses/GPL-3.0.txt +619 -619
  158. package/licenses/LGPL-2.1.txt +502 -502
  159. package/licenses/LGPL-3.0.txt +165 -165
  160. package/licenses/MIT-chat-on-wechat.txt +18 -18
  161. package/licenses/MIT-deepseek-harness.txt +21 -21
  162. package/licenses/Molio-LICENSE.txt +44 -44
  163. package/locales/en.json +1876 -1755
  164. package/main.py +154 -154
  165. package/mcpx/client.py +12 -1
  166. package/mcpx/manager.py +530 -522
  167. package/mcpx/servers/web_search.py +5 -13
  168. package/package.json +15 -23
  169. package/providers/anthropic/client.py +35 -33
  170. package/providers/base.py +13 -13
  171. package/providers/cache_policies.json +294 -0
  172. package/providers/cost_table.json +3779 -3779
  173. package/providers/lmstudio/client.py +2 -2
  174. package/providers/model_capabilities.json +6665 -6665
  175. package/providers/model_profiles.json +629 -0
  176. package/providers/ollama/client.py +2 -2
  177. package/providers/openai_compat.py +37 -16
  178. package/providers/openrouter/client.py +2 -2
  179. package/providers/qwen/__init__.py +1 -1
  180. package/providers/qwen/client.py +2 -2
  181. package/providers/qwen/manifest.yaml +16 -16
  182. package/providers/rate_limiter.py +2 -2
  183. package/providers/siliconflow/client.py +2 -2
  184. package/providers/validation.py +171 -171
  185. package/providers/vision_profiles.json +89 -0
  186. package/providers/window_table.json +8909 -8909
  187. package/requirements.txt +59 -51
  188. package/sbom-linux-x64.json +4580 -0
  189. package/sbom.json +4600 -4413
  190. package/skills/diagram/SKILL.md +47 -0
  191. package/skills/diagram/__init__.py +1 -0
  192. package/skills/diagram/handler.py +294 -0
  193. package/skills/diagram/layout.py +174 -0
  194. package/skills/diagram/manifest.yaml +106 -0
  195. package/skills/diagram/mermaid.py +170 -0
  196. package/skills/diagram/svg.py +223 -0
  197. package/skills/entertainment/SKILL.md +35 -35
  198. package/skills/entertainment/__init__.py +1 -1
  199. package/skills/entertainment/handler.py +91 -91
  200. package/skills/entertainment/manifest.yaml +26 -26
  201. package/skills/file_parser/GUIDANCE.md +10 -10
  202. package/skills/file_parser/handler.py +33 -11
  203. package/skills/github/SKILL.md +32 -32
  204. package/skills/github/__init__.py +1 -1
  205. package/skills/mail_parser/SKILL.md +68 -68
  206. package/skills/mail_parser/__init__.py +1 -1
  207. package/skills/mail_parser/handler.py +1 -1
  208. package/skills/media_gen/GUIDANCE.md +19 -19
  209. package/skills/media_gen/SKILL.md +43 -43
  210. package/skills/media_gen/__init__.py +1 -1
  211. package/skills/media_gen/handler.py +1 -1
  212. package/skills/media_gen/manifest.yaml +93 -93
  213. package/skills/netops/SKILL.md +45 -0
  214. package/skills/netops/__init__.py +1 -0
  215. package/skills/netops/handler.py +418 -0
  216. package/skills/netops/manifest.yaml +118 -0
  217. package/skills/office_parser/_excel_io.py +3 -3
  218. package/skills/office_parser/handler.py +2 -2
  219. package/skills/office_parser/ppt_tools.py +1 -1
  220. package/skills/office_parser/pptx_export/console_encoding.py +27 -27
  221. package/skills/office_parser/pptx_export/resource_paths.py +88 -88
  222. package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
  223. package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
  224. package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
  225. package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
  226. package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
  227. package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
  228. package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
  229. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
  230. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
  231. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
  232. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
  233. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
  234. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
  235. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
  236. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
  237. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
  238. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
  239. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
  240. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
  241. package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
  242. package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
  243. package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
  244. package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
  245. package/skills/office_parser/references/layout_library.md +816 -816
  246. package/skills/office_parser/references/ppt-master/LICENSE +21 -21
  247. package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
  248. package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
  249. package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
  250. package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
  251. package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
  252. package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
  253. package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
  254. package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
  255. package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
  256. package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
  257. package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
  258. package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
  259. package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
  260. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
  261. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
  262. package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
  263. package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
  264. package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
  265. package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
  266. package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
  267. package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
  268. package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
  269. package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
  270. package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
  271. package/skills/office_parser/references/spec_lock.md +235 -235
  272. package/skills/office_parser/soffice.py +68 -68
  273. package/skills/office_parser/word_tools.py +3 -3
  274. package/skills/ssh/SKILL.md +81 -0
  275. package/skills/ssh/__init__.py +1 -0
  276. package/skills/ssh/handler.py +609 -0
  277. package/skills/ssh/manifest.yaml +182 -0
  278. package/tui/crannia.cmd +134 -134
  279. package/tui/crannia.sh +82 -0
  280. package/tui/crannia_tui/__init__.py +1 -1
  281. package/tui/crannia_tui/app.py +240 -17
  282. package/tui/crannia_tui/app.tcss +21 -0
  283. package/tui/crannia_tui/clipboard.py +78 -10
  284. package/tui/crannia_tui/commands.py +37 -0
  285. package/tui/crannia_tui/events.py +6 -0
  286. package/tui/crannia_tui/i18n.py +164 -164
  287. package/tui/crannia_tui/locales/en.json +31 -6
  288. package/tui/crannia_tui/paths.py +4 -1
  289. package/tui/crannia_tui/profile.py +178 -169
  290. package/tui/crannia_tui/settings.py +134 -134
  291. package/tui/crannia_tui/setup.py +44 -5
  292. package/tui/crannia_tui/ui.py +156 -16
  293. package/tui/crannia_tui/update.py +393 -389
  294. package/vendor/ripgrep/COPYING.txt +3 -3
  295. package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
  296. package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
  297. package/vendor/ripgrep/README.md +30 -14
  298. package/vendor/ripgrep/UNLICENSE.txt +24 -24
  299. package/vendor/ripgrep/linux-x64/rg +0 -0
  300. package/vendor/ripgrep/package-source.json +15 -16
  301. package/web/__main__.py +12 -15
  302. package/web/server.py +8481 -8594
  303. package/web/static/img/channel-telegram.svg +1 -1
  304. package/web/static/img/channel-wechat.svg +1 -1
  305. package/web/templates/logs.html +49 -49
  306. package/web/templates/models.html +46 -46
@@ -191,8 +191,7 @@ class MemoryManager:
191
191
  if "max_messages" in short_term_cfg:
192
192
  _dead.append("short_term.max_messages")
193
193
  if _dead:
194
- print(f"[memory] config 里 {'、'.join(_dead)} 已不再读取"
195
- f"(这些键已没有消费者)")
194
+ print(f"[memory] config keys no longer read: {', '.join(_dead)}")
196
195
 
197
196
  # Sliding window: hard cap on in-memory message count.
198
197
  # This is a safety net — compression should normally keep the list
@@ -293,8 +292,7 @@ class MemoryManager:
293
292
  return _mc.instance_for(cid, fallback=self._provider)
294
293
  except Exception as exc: # noqa: BLE001
295
294
  # 出声但不换口径:读不到就沿用开机那条(老行为一个字节不变)。
296
- print(f"[memory] 取会话模型失败(沿用进程默认):"
297
- f"{type(exc).__name__}: {exc}")
295
+ print(f"[memory] session model lookup failed (using process default): {type(exc).__name__}: {exc}")
298
296
  return self._provider
299
297
 
300
298
  def _non_history_cost(self, session_id: str) -> Tuple[str, list]:
@@ -444,19 +442,18 @@ class MemoryManager:
444
442
  """打印 `describe_thresholds()` —— 启动时调一次。"""
445
443
  r = self.describe_thresholds()
446
444
  print(f"[threshold] context_window {r['context_window']['value']:,} "
447
- f"(来源: {r['context_window']['source']},"
445
+ f"(source: {r['context_window']['source']}, "
448
446
  f"model={r['context_window'].get('model', '?')})")
449
- print(f"[threshold] 压缩阈值 "
447
+ print(f"[threshold] compression threshold "
450
448
  f"{r['compression_threshold']['value']:,} "
451
- f"= window × {r['compression_threshold']['ratio']}")
452
- print(f"[threshold] 装载上限(balanced) "
453
- f"{r['history_ceiling_balanced']['value']:,} ← 只约束恢复,"
454
- f"不约束压缩:两者不在同一条链上")
449
+ f"= window x {r['compression_threshold']['ratio']}")
450
+ print(f"[threshold] history loading ceiling (balanced) "
451
+ f"{r['history_ceiling_balanced']['value']:,}")
455
452
  nh = r["non_history_measured"]
456
- print(f"[threshold] 非历史实际开销 {nh['value']:,} "
457
- f"({nh['raw']:,} x factor {nh['factor']:.4f} —— "
458
- f"工具 {nh['tool_tokens']:,} [{nh['tool_count']} 个] + "
459
- f"系统 {nh['system_tokens']:,}) ← 这三部分都进压缩闸门")
453
+ print(f"[threshold] non-history actual cost {nh['value']:,} "
454
+ f"({nh['raw']:,} x factor {nh['factor']:.4f} - "
455
+ f"tools {nh['tool_tokens']:,} [{nh['tool_count']}] + "
456
+ f"system {nh['system_tokens']:,})")
460
457
 
461
458
  # ------------------------------------------------------------------
462
459
  # Session lifecycle
@@ -528,8 +525,7 @@ class MemoryManager:
528
525
  self._token_total[new_sid] = self.short_term.get_token_total(new_sid)
529
526
  self._saved_count[new_sid] = n
530
527
  self._pending_memory_inject[new_sid] = True
531
- print(f"[memory] 分出线程 {new_sid[:14]}…"
532
- f"(从 {str(src_sid)[:14]}… 复制 {n} 条,keep={keep})")
528
+ print(f"[memory] forked thread {new_sid[:14]}... (from {str(src_sid)[:14]}..., copied {n} messages, keep={keep})")
533
529
  return new_sid
534
530
 
535
531
  def load_session(
@@ -847,8 +843,7 @@ class MemoryManager:
847
843
  except Exception as e:
848
844
  # 不能静默:裸 `except: pass` 会让"数失败"与"本来就没东西"
849
845
  # 看起来完全一样。
850
- print(f"[memory] /clear 数旧线程失败 for {old_session_id!r}: "
851
- f"{type(e).__name__}: {e}")
846
+ print(f"[memory] /clear thread count failed for {old_session_id!r}: {type(e).__name__}: {e}")
852
847
  purged = -1
853
848
  # 会话笔记:归档,不销毁(判据:「`/clear` = 这段对话及其派生物;
854
849
  # 清 ≠ 删」)。
@@ -870,13 +865,11 @@ class MemoryManager:
870
865
  from core.attachment_gc import prune as _gc_attach
871
866
  _st = _gc_attach()
872
867
  if _st.get("deleted"):
873
- print(f"[attachments] 回收 {_st['deleted']} 个未被引用的附件"
874
- f"({_st['freed']} 字节)")
868
+ print(f"[attachments] reclaimed {_st['deleted']} unreferenced attachments ({_st['freed']} bytes)")
875
869
  elif _st.get("skipped") == "db_unreadable":
876
- print("[attachments] 库读不到 ⇒ 本次一个都没删")
870
+ print("[attachments] DB unreadable => nothing deleted this time")
877
871
  except Exception as _gc_exc: # noqa: BLE001
878
- print(f"[attachments] 回收失败(不影响会话):"
879
- f"{type(_gc_exc).__name__}: {_gc_exc}")
872
+ print(f"[attachments] reclaim failed (does not affect session): {type(_gc_exc).__name__}: {_gc_exc}")
880
873
  # 改前留档也趁这一下顺手剪
881
874
  # (同一条"顺手剪、不新起线程"的形状)。
882
875
  # 它用的是另一把旋钮(`file_history_days`)—— 那些是
@@ -885,8 +878,7 @@ class MemoryManager:
885
878
  from core.file_history import prune as _prune_fh
886
879
  _prune_fh()
887
880
  except Exception as _fh_exc: # noqa: BLE001
888
- print(f"[file_history] /clear 顺手剪失败(不影响会话):"
889
- f"{type(_fh_exc).__name__}: {_fh_exc}")
881
+ print(f"[file_history] /clear trim failed (does not affect session): {type(_fh_exc).__name__}: {_fh_exc}")
890
882
 
891
883
  # 总是铸一个新的。
892
884
  # 通道键与存储 id 是两件事:`bind_session` 把通道键挪到新线程上,
@@ -1029,7 +1021,7 @@ class MemoryManager:
1029
1021
  payload_blocked=blocked)
1030
1022
  _emit(EVT_COMPACT_PROGRESS, **payload)
1031
1023
  except Exception as exc: # noqa: BLE001
1032
- print("[memory] 压缩进度事件发不出去(不影响本轮):%s: %s"
1024
+ print("[memory] compression progress event send failed (does not affect this turn): %s: %s"
1033
1025
  % (type(exc).__name__, exc))
1034
1026
 
1035
1027
  def repersist_messages(self, session_id: str, messages: List[Dict]) -> None:
@@ -1082,7 +1074,7 @@ class MemoryManager:
1082
1074
  if summary_msg.get("kind") != "history_summary":
1083
1075
  # 压缩器给不出摘要时压根不会走到这里(那时 `was_compressed=False`)。
1084
1076
  # 真走到了就如实出声,别把一条普通消息当摘要钉进库里。
1085
- print("[memory] 压缩落库跳过:compressed[0] 不是摘要行 "
1077
+ print("[memory] compression persist skipped: compressed[0] is not a summary row "
1086
1078
  "(kind=%r)" % (summary_msg.get("kind"),))
1087
1079
  return
1088
1080
  self.short_term.append_compaction(
@@ -1132,8 +1124,7 @@ class MemoryManager:
1132
1124
  if not starts:
1133
1125
  return 0
1134
1126
  if len(starts) < n_kept:
1135
- print(f"[memory] 压缩边界:库里只有 {len(starts)} 个轮首、"
1136
- f"内存里有 {n_kept} 个 —— 保守取最早那一行(多留不丢)")
1127
+ print(f"[memory] compression boundary: DB has only {len(starts)} turn starts, memory has {n_kept} - conservatively using the earliest row (keep more, lose nothing)")
1137
1128
  return starts[0]
1138
1129
  return max(starts[len(starts) - n_kept], prev)
1139
1130
  def _apply_sliding_window(
@@ -1205,8 +1196,7 @@ class MemoryManager:
1205
1196
  break
1206
1197
  start += 1
1207
1198
  if start >= len(body):
1208
- print(f"[memory] 滑窗跳过:表尾找不到轮边界({len(messages)} 条,"
1209
- f"更愿意超限也不切坏历史)")
1199
+ print(f"[memory] trim skipped: no turn boundary found at table tail ({len(messages)} messages, preferring over-limit over cutting history)")
1210
1200
  return messages, False
1211
1201
 
1212
1202
  heads, tail = body[:keep_heads], body[start:]
@@ -1225,8 +1215,7 @@ class MemoryManager:
1225
1215
  truncated = heads + [note] + tail
1226
1216
 
1227
1217
  print(
1228
- f"[memory] 冷闸滑窗:{len(messages)} → {len(truncated)} 条"
1229
- f"(移出 {dropped} 条,max_history={self._max_history})"
1218
+ f"[memory] cold-gate trim: {len(messages)} -> {len(truncated)} messages (dropped {dropped}, max_history={self._max_history})"
1230
1219
  )
1231
1220
  return truncated, True
1232
1221
 
@@ -1263,8 +1252,7 @@ class MemoryManager:
1263
1252
  if t is None:
1264
1253
  return messages
1265
1254
  if time.time() - t <= gap_min * 60:
1266
- print(f"[memory] 滑窗跳过:会话仍热(上次活动 {int((time.time()-t)/60)} "
1267
- f"分钟前 ≤ 冷闸 {gap_min} 分钟)—— 不剪,护前缀缓存")
1255
+ print(f"[memory] trim skipped: session still hot (last activity {int((time.time()-t)/60)} min ago <= cold gate {gap_min} min) - not trimming, protecting prefix cache")
1268
1256
  return messages
1269
1257
 
1270
1258
  trimmed, was_trimmed = self._apply_sliding_window(session_id, messages)
@@ -1444,8 +1432,7 @@ class MemoryManager:
1444
1432
  try:
1445
1433
  self.short_term.bump_thread_turn(session_id)
1446
1434
  except Exception as exc: # noqa: BLE001
1447
- print(f"[memory] 线程名册计数失败(不影响本轮):"
1448
- f"{type(exc).__name__}: {exc}")
1435
+ print(f"[memory] thread roster count failed (does not affect this turn): {type(exc).__name__}: {exc}")
1449
1436
 
1450
1437
  # 轮末封印文件留档 —— 盖的是"这一轮改完之后
1451
1438
  # 这个文件长什么样"的哈希,它是回退那半边安全闸的输入
@@ -1457,8 +1444,7 @@ class MemoryManager:
1457
1444
  from core.file_history import seal_turn
1458
1445
  seal_turn(channel_key or session_id)
1459
1446
  except Exception as exc: # noqa: BLE001
1460
- print(f"[memory] 文件留档封印失败(不影响本轮):"
1461
- f"{type(exc).__name__}: {exc}")
1447
+ print(f"[memory] file archive sealing failed (does not affect this turn): {type(exc).__name__}: {exc}")
1462
1448
 
1463
1449
  # 2. Update token counter
1464
1450
  self._token_total[session_id] = (
@@ -1509,8 +1495,7 @@ class MemoryManager:
1509
1495
  if _turn_no > 0 and _turn_no % 20 == 0:
1510
1496
  self.short_term.prune_old_tool_messages()
1511
1497
  except Exception as exc: # noqa: BLE001
1512
- print(f"[memory] tool 淘汰检查失败(不影响本轮):"
1513
- f"{type(exc).__name__}: {exc}")
1498
+ print(f"[memory] tool eviction check failed (does not affect this turn): {type(exc).__name__}: {exc}")
1514
1499
 
1515
1500
  def _update_note_bg() -> None:
1516
1501
  """Background: update the session note .md file via LLM."""
@@ -1549,7 +1534,8 @@ class MemoryManager:
1549
1534
  except Exception as exc: # noqa: BLE001
1550
1535
  _open = True
1551
1536
  self._note_bg_status(
1552
- f"[memory] 笔记量闸判不动,退回每轮写:{type(exc).__name__}: {exc}")
1537
+ f"[memory] note gate undecidable; falling back to per-turn writes: "
1538
+ f"{type(exc).__name__}: {exc}")
1553
1539
 
1554
1540
  if not _open:
1555
1541
  _need = (NOTE_UPDATE_TOKENS if current_note.strip()
@@ -1638,8 +1624,7 @@ class MemoryManager:
1638
1624
  group, session_id, messages,
1639
1625
  self._provider_for(session_id), turn_no)
1640
1626
  except Exception as exc: # noqa: BLE001
1641
- print(f"[group_minutes] 触发失败(不影响本轮):"
1642
- f"{type(exc).__name__}: {exc}")
1627
+ print(f"[group_minutes] trigger failed (does not affect this turn): {type(exc).__name__}: {exc}")
1643
1628
 
1644
1629
  # 3.5. (滑窗不在这里。)
1645
1630
  # 轮末无条件剪(超 max_history 就剪)是最坏的位置:滑窗从表头
@@ -1712,7 +1697,7 @@ class MemoryManager:
1712
1697
  )
1713
1698
  except Exception as e: # noqa: BLE001 —— 闸门本身不许成为故障源
1714
1699
  self._note_bg_status(
1715
- f"[memory] 记忆巩固调度失败:{type(e).__name__}: {e}"
1700
+ f"[memory] memory organize scheduling failed: {type(e).__name__}: {e}"
1716
1701
  )
1717
1702
 
1718
1703
  # 4. 长期记忆的写入有两条路:后台 fork 抽取器(写 `memory_store`,
@@ -188,8 +188,7 @@ class SessionMemory:
188
188
  也不落半截摘要。
189
189
  """
190
190
  if not note.strip():
191
- print(f"[memory] 拒绝用空内容覆盖会话笔记 ({session_id}) —— "
192
- f"上一次的笔记保持不动")
191
+ print(f"[memory] refused to overwrite session notes with empty content ({session_id}) - previous notes left unchanged")
193
192
  return
194
193
 
195
194
  note_path = self.get_note_path(session_id)
@@ -61,9 +61,9 @@ class ShortTermMemory:
61
61
  try:
62
62
  _n = self.backfill_framework_notes()
63
63
  if _n:
64
- print("[memory] 已给 %d 条旧消息补上 framework_note 标记" % _n)
64
+ print("[memory] marked %d old messages with framework_note" % _n)
65
65
  except Exception as exc: # noqa: BLE001
66
- print("[memory] 旧消息补标记失败(不影响启动):%s: %s"
66
+ print("[memory] old message marking failed (does not affect startup): %s: %s"
67
67
  % (type(exc).__name__, exc))
68
68
 
69
69
  @staticmethod
@@ -817,7 +817,7 @@ class ShortTermMemory:
817
817
  (str(storage_id or ""),))
818
818
  self._conn.commit()
819
819
  except Exception as exc: # noqa: BLE001
820
- print(f"[memory] 清会话模型失败({type(exc).__name__}: {exc})")
820
+ print(f"[memory] clear session model failed ({type(exc).__name__}: {exc})")
821
821
 
822
822
  # ------------------------------------------------------------------
823
823
  # 会话 -> 工作目录( )
@@ -881,7 +881,7 @@ class ShortTermMemory:
881
881
  (str(storage_id or ""),))
882
882
  self._conn.commit()
883
883
  except Exception as exc: # noqa: BLE001
884
- print(f"[memory] 清会话工作目录失败({type(exc).__name__}: {exc})")
884
+ print(f"[memory] clear session workspace failed ({type(exc).__name__}: {exc})")
885
885
 
886
886
  @_serialized
887
887
  def first_user_text(self, session_id: str, limit: int = 40) -> str:
@@ -446,7 +446,7 @@ def run_extraction(*, session_id: str, messages: List[dict], provider,
446
446
  get_event_bus().emit(EVT_MEMORY_SAVED, session_key=session_id,
447
447
  count=len(saved), names=names)
448
448
  except Exception as exc: # noqa: BLE001 —— 事件发不出去不许影响抽取本身
449
- print(f"[memory] memory.saved 事件发送失败:{type(exc).__name__}: {exc}")
449
+ print(f"[memory] memory.saved event send failed: {type(exc).__name__}: {exc}")
450
450
  _status(status, f"[memory] 后台抽取完成 —— 写入 {len(saved)} 条记忆:"
451
451
  f"{'、'.join(names)}")
452
452
  else:
@@ -260,7 +260,7 @@ def mark_round_done(memory_root) -> None:
260
260
  tmp.write_text(json.dumps({"last_round": time.time()}), encoding="utf-8")
261
261
  os.replace(tmp, root / STATE_FILE)
262
262
  except OSError as exc:
263
- print("[memory] 巩固:记状态失败(%s)—— 下一轮会再跑一遍" % exc)
263
+ print("[memory] consolidate: state record failed (%s) - retries next round" % exc)
264
264
 
265
265
 
266
266
  def _read_holder(d: Path) -> Tuple[Optional[int], float]:
@@ -551,10 +551,10 @@ def maybe_organize(*, session_id: str, messages: Optional[List[dict]], provider,
551
551
  if snap is None or snap.session_id != session_id:
552
552
  # 拿不到快照,fork 不出"同前缀",把互斥还回去
553
553
  release_round(memory_root)
554
- _status(status, "[memory] 巩固:没有本会话的请求快照 —— 跳过本轮")
554
+ _status(status, "[memory] organize: no request snapshot for this session - skipping this round")
555
555
  return
556
556
 
557
- _status(status, "[memory] 记忆巩固开始 —— %.1f 小时未巩固,%d 个会话待看"
557
+ _status(status, "[memory] organize started - %.1f h since last run, %d sessions to review"
558
558
  % (hours_since, len(session_ids)))
559
559
  _state["in_progress"] = True
560
560
  _spawn(target=run_organize, kwargs=dict(
@@ -625,7 +625,7 @@ def run_organize(*, session_id: str, messages: List[dict], provider,
625
625
  )
626
626
  ok = True
627
627
  except Exception as exc: # noqa: BLE001 —— 判据:best-effort,绝不把失败报成成功
628
- _status(status, "[memory] 记忆巩固失败(互斥已还,下轮重算时间闸):"
628
+ _status(status, "[memory] organize failed (mutex released; time gate recomputed next turn): "
629
629
  "%s: %s" % (type(exc).__name__, exc))
630
630
  finally:
631
631
  _state["in_progress"] = False
@@ -658,10 +658,10 @@ def run_organize(*, session_id: str, messages: List[dict], provider,
658
658
  count=len(changed), names=names,
659
659
  sessions=len(sessions))
660
660
  except Exception as exc: # noqa: BLE001 —— 事件发不出去不许影响巩固本身
661
- print("[memory] memory.organized 事件发送失败:%s: %s"
661
+ print("[memory] memory.organized event send failed: %s: %s"
662
662
  % (type(exc).__name__, exc))
663
663
  if changed:
664
- _status(status, "[memory] 记忆巩固完成 —— 改动 %d 条:%s"
665
- % (len(changed), "、".join(names)))
664
+ _status(status, "[memory] organize done - changed %d entries: %s"
665
+ % (len(changed), ", ".join(names)))
666
666
  else:
667
- _status(status, "[memory] 记忆巩固完成 —— 无改动(记忆已紧凑)")
667
+ _status(status, "[memory] organize done - no changes (memory already compact)")
@@ -252,7 +252,7 @@ def list_entries(scope: str = DEFAULT_SCOPE) -> List[Dict]:
252
252
  for p in sorted(root.glob("*.md")):
253
253
  entry = parse_entry(p)
254
254
  if entry is None:
255
- print(f"[memory_store] 跳过 {p} —— frontmatter 缺失或坏掉(不猜不救)")
255
+ print(f"[memory_store] skipped {p} - frontmatter missing or broken (not guessing or rescuing)")
256
256
  continue
257
257
  out.append(entry)
258
258
  out.sort(key=lambda e: e["slug"])
@@ -279,7 +279,7 @@ def load_tombstones() -> Dict[str, Dict]:
279
279
  tob = data.get("tombstones") or {}
280
280
  return tob if isinstance(tob, dict) else {}
281
281
  except Exception as exc:
282
- print(f"[memory_store] tombstones 读不出来({type(exc).__name__})—— 本次视为空账本")
282
+ print(f"[memory_store] tombstones unreadable ({type(exc).__name__}) - treating as empty")
283
283
  return {}
284
284
 
285
285
 
@@ -380,7 +380,7 @@ def remove_tombstone(name_or_slug: str) -> Dict:
380
380
  _save_tombstones(tob)
381
381
  except OSError as exc:
382
382
  return {"success": False, "error": f"账本写失败({exc})。"}
383
- print(f"[memory_store] 解除封条 {slug}({erased.get('name') or slug})")
383
+ print(f"[memory_store] unsealed {slug} ({erased.get('name') or slug})")
384
384
  return {"success": True, "slug": slug, "name": erased.get("name") or slug}
385
385
 
386
386
 
@@ -443,7 +443,7 @@ def delete_entry(name: str, scope: str = DEFAULT_SCOPE, *,
443
443
  except OSError as exc:
444
444
  return {"success": False,
445
445
  "error": f"删文件失败({exc})—— 账本已记,重试即可。"}
446
- print(f"[memory_store] 删除记忆 {entry['slug']}.md(已记 tombstone)")
446
+ print(f"[memory_store] deleted memory {entry['slug']}.md (tombstone recorded)")
447
447
  return {"success": True, "slug": entry["slug"], "name": entry["name"],
448
448
  "sealed": _sealed}
449
449
 
@@ -495,8 +495,7 @@ def delete_all(scope: str = DEFAULT_SCOPE, *, seal: bool | None = None) -> Dict:
495
495
  except OSError as exc:
496
496
  failed.append({"slug": e["slug"], "error": str(exc)})
497
497
  tail = f",失败 {len(failed)}" if failed else ""
498
- print(f"[memory_store] 清空记忆库:删 {len(deleted)} 条、"
499
- f"落 {len(deleted)} 条封条{tail}")
498
+ print(f"[memory_store] cleared memory store: deleted {len(deleted)}, wrote {len(deleted)} tombstones{tail}")
500
499
  return {"success": not failed, "deleted": deleted, "failed": failed,
501
500
  "count": len(deleted)}
502
501
 
@@ -594,7 +593,7 @@ def write_entry(name: str, description: str, content: str,
594
593
  except OSError as exc:
595
594
  return {"success": False, "error": f"写失败({exc})。"}
596
595
 
597
- print(f"[memory_store] {'更新' if existed else '新建'}记忆 {slug}.md")
596
+ print(f"[memory_store] {'updated' if existed else 'created'} memory {slug}.md")
598
597
  return {
599
598
  "success": True,
600
599
  "path": path.as_posix(),
@@ -662,8 +661,7 @@ def build_memory_index(scope: str = DEFAULT_SCOPE) -> str:
662
661
  lines.append(line)
663
662
  chars += len(line) + 1
664
663
  if truncated_by:
665
- print(f"[memory_store] 索引超过 {truncated_by} —— 只列了前 {len(lines)} 条"
666
- f"(该做一次「记忆巩固」把它降下来)")
664
+ print(f"[memory_store] index exceeds {truncated_by} - listing only first {len(lines)} (consider running memory consolidation to reduce it)")
667
665
 
668
666
  return sanitize_text("\n".join(lines))
669
667
 
@@ -119,8 +119,8 @@ def _snapshot_db_bytes(db_path: Path) -> bytes | None:
119
119
  src.close()
120
120
  return Path(tmp).read_bytes()
121
121
  except (sqlite3.Error, OSError) as exc:
122
- print("[memory-transfer] 快照失败(%s: %s)—— 退回直接读主库文件,"
123
- "包里的历史可能少最近那条" % (type(exc).__name__, exc))
122
+ print("[memory-transfer] snapshot failed (%s: %s) - falling back to main db file, "
123
+ "package history may miss the latest entry" % (type(exc).__name__, exc))
124
124
  try:
125
125
  return db_path.read_bytes()
126
126
  except OSError:
@@ -46,10 +46,10 @@ def _read(path: Path | None = None) -> dict:
46
46
  try:
47
47
  raw = json.loads(p.read_text(encoding="utf-8"))
48
48
  except FileNotFoundError:
49
- print("[model_capabilities] 能力表不存在(%s)—— 全部落回兜底" % p)
49
+ print("[model_capabilities] capability table missing (%s) - all fall back" % p)
50
50
  return {}
51
51
  except Exception as exc: # noqa: BLE001
52
- print("[model_capabilities] 能力表读不动(%s: %s)—— 全部落回兜底"
52
+ print("[model_capabilities] capability table unreadable (%s: %s) - all fall back"
53
53
  % (type(exc).__name__, exc))
54
54
  return {}
55
55
  return raw if isinstance(raw, dict) else {}