@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.
- package/LICENSE +201 -201
- package/NOTICE +48 -45
- package/README.md +1 -1
- package/THIRD-PARTY-FRONTEND.md +5266 -5266
- package/THIRD-PARTY-PYTHON-linux.md +174 -0
- package/THIRD-PARTY-PYTHON.md +176 -162
- package/THIRD-PARTY.md +323 -316
- package/apps/desktop/quotes.txt +56 -56
- package/bus/core.py +677 -671
- package/bus/loaders/channel_loader.py +64 -64
- package/bus/loaders/provider_loader.py +4 -7
- package/bus/loaders/skill_loader.py +46 -27
- package/bus/loaders/skill_md.py +9 -9
- package/bus/mcp_disabled.py +4 -6
- package/bus/quarantine.py +10 -13
- package/bus/registry.py +2315 -2284
- package/bus/skill_state.py +124 -124
- package/channels/cli_channel/handler.py +3 -3
- package/channels/cli_channel/manifest.yaml +5 -5
- package/channels/dingtalk_channel/handler.py +32 -32
- package/channels/dingtalk_channel/manifest.yaml +12 -12
- package/channels/feishu_channel/handler.py +33 -33
- package/channels/feishu_channel/manifest.yaml +12 -12
- package/channels/qq_bot_channel/__init__.py +1 -1
- package/channels/qq_bot_channel/handler.py +24 -24
- package/channels/qq_bot_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/__init__.py +1 -1
- package/channels/telegram_channel/handler.py +21 -21
- package/channels/telegram_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/media.py +231 -231
- package/channels/textfmt.py +58 -58
- package/channels/wechat_channel/__init__.py +1 -1
- package/channels/wechat_channel/converter.py +1 -1
- package/channels/wechat_channel/handler.py +8 -8
- package/channels/wechat_channel/manifest.yaml +5 -5
- package/channels/wechat_channel/media.py +178 -178
- package/core/activity.py +753 -709
- package/core/agent_loop.py +7673 -7522
- package/core/allowlist.py +2 -3
- package/core/approval.py +34 -24
- package/core/approval_timeout.py +256 -228
- package/core/artifacts.py +3 -3
- package/core/attachment_gc.py +21 -0
- package/core/auto_review.py +2 -2
- package/core/browser/cdp.py +5 -2
- package/core/browser/discover.py +55 -19
- package/core/browser/session.py +4 -4
- package/core/cache_break_detector.py +97 -0
- package/core/cache_breakpoints.py +103 -0
- package/core/cache_policies.py +255 -0
- package/core/cancellation.py +3 -3
- package/core/channel_configs.py +3 -3
- package/core/channel_turns.py +13 -13
- package/core/child_approval.py +2 -3
- package/core/code_intel.py +11 -11
- package/core/command_policy.py +13 -7
- package/core/computer/annotate.py +231 -11
- package/core/computer/capture.py +140 -1
- package/core/computer/guard.py +7 -4
- package/core/computer/input.py +452 -26
- package/core/computer/session.py +563 -381
- package/core/computer/tools.py +2170 -928
- package/core/computer/uia.py +100 -1
- package/core/computer/watch.py +1 -1
- package/core/computer/win32.py +302 -7
- package/core/config_requirements.py +205 -205
- package/core/cron/runner.py +4 -4
- package/core/daily_log.py +2 -2
- package/core/dedup.py +2 -2
- package/core/egress_channels.py +326 -0
- package/core/egress_gate.py +96 -8
- package/core/egress_preapproved.py +59 -3
- package/core/endpoint.py +141 -141
- package/core/events.py +17 -8
- package/core/extension.py +2 -2
- package/core/file_history.py +10 -10
- package/core/file_tools.py +3 -3
- package/core/github_config.py +1 -1
- package/core/group_digest.py +3 -4
- package/core/group_minutes.py +5 -5
- package/core/group_reply.py +24 -0
- package/core/groups.py +5 -9
- package/core/hooks.py +15 -15
- package/core/i18n.py +2 -2
- package/core/ice/canary.py +3 -3
- package/core/ice/net_heuristics.py +2 -2
- package/core/im_routing.py +2 -2
- package/core/image_input.py +183 -43
- package/core/inbound.py +3 -3
- package/core/jobs.py +6 -6
- package/core/last_good.py +150 -150
- package/core/leaf_md.py +3 -3
- package/core/llm_errors.py +36 -27
- package/core/mail_config.py +2 -2
- package/core/memory/compressor.py +8 -8
- package/core/memory/manager.py +30 -45
- package/core/memory/session_memory.py +1 -2
- package/core/memory/short_term.py +4 -4
- package/core/memory_extract.py +1 -1
- package/core/memory_organize.py +8 -8
- package/core/memory_store.py +7 -9
- package/core/memory_transfer.py +2 -2
- package/core/model_capabilities.py +2 -2
- package/core/model_configs.py +219 -68
- package/core/model_profiles.py +333 -0
- package/core/modes.py +12 -11
- package/core/net_proxy.py +3 -3
- package/core/pipeline/scheduler.py +48 -43
- package/core/pipeline/stage.py +3 -0
- package/core/pipeline/stages/agent_loop.py +36 -15
- package/core/pipeline/stages/group_reply.py +22 -20
- package/core/pipeline/stages/post_process.py +7 -7
- package/core/pipeline/stages/pre_process.py +360 -68
- package/core/prompt_assembler.py +13 -4
- package/core/recycle.py +227 -16
- package/core/response_language.py +1 -1
- package/core/retention.py +2 -2
- package/core/rg.py +4 -3
- package/core/security.py +26 -8
- package/core/services.py +8 -8
- package/core/session_model.py +3 -5
- package/core/session_pool.py +35 -5
- package/core/session_recap.py +40 -3
- package/core/session_workspace.py +2 -3
- package/core/settings_baseline.py +2 -2
- package/core/settings_transfer.py +25 -1
- package/core/shell.py +52 -20
- package/core/side_call.py +3 -3
- package/core/skill_config.py +164 -0
- package/core/skill_factory.py +2 -2
- package/core/skill_guidance.py +2 -4
- package/core/skill_index.py +3 -4
- package/core/skill_settings.py +1 -1
- package/core/skill_sources.py +7 -7
- package/core/ssh_config.py +129 -0
- package/core/state_registry.py +67 -5
- package/core/subagent.py +28 -5
- package/core/subagent_defs.py +3 -3
- package/core/summarizer.py +4 -5
- package/core/tasks_notify.py +6 -6
- package/core/tiers.py +2 -2
- package/core/todos.py +1 -1
- package/core/token_calibrator.py +1 -4
- package/core/tool_outcome.py +108 -108
- package/core/touched_files.py +1 -1
- package/core/trace.py +12 -3
- package/core/unlock.py +4 -4
- package/core/update_tui.py +184 -158
- package/core/updater.py +5 -3
- package/core/version.py +14 -14
- package/core/vision_budget.py +235 -0
- package/core/web_cache.py +152 -152
- package/core/web_request.py +474 -0
- package/core/window_estimate.py +1 -1
- package/core/workspace.py +56 -26
- package/crannia_tray.py +278 -278
- package/licenses/GPL-3.0.txt +619 -619
- package/licenses/LGPL-2.1.txt +502 -502
- package/licenses/LGPL-3.0.txt +165 -165
- package/licenses/MIT-chat-on-wechat.txt +18 -18
- package/licenses/MIT-deepseek-harness.txt +21 -21
- package/licenses/Molio-LICENSE.txt +44 -44
- package/locales/en.json +1876 -1755
- package/main.py +154 -154
- package/mcpx/client.py +12 -1
- package/mcpx/manager.py +530 -522
- package/mcpx/servers/web_search.py +5 -13
- package/package.json +15 -23
- package/providers/anthropic/client.py +35 -33
- package/providers/base.py +13 -13
- package/providers/cache_policies.json +294 -0
- package/providers/cost_table.json +3779 -3779
- package/providers/lmstudio/client.py +2 -2
- package/providers/model_capabilities.json +6665 -6665
- package/providers/model_profiles.json +629 -0
- package/providers/ollama/client.py +2 -2
- package/providers/openai_compat.py +37 -16
- package/providers/openrouter/client.py +2 -2
- package/providers/qwen/__init__.py +1 -1
- package/providers/qwen/client.py +2 -2
- package/providers/qwen/manifest.yaml +16 -16
- package/providers/rate_limiter.py +2 -2
- package/providers/siliconflow/client.py +2 -2
- package/providers/validation.py +171 -171
- package/providers/vision_profiles.json +89 -0
- package/providers/window_table.json +8909 -8909
- package/requirements.txt +59 -51
- package/sbom-linux-x64.json +4580 -0
- package/sbom.json +4600 -4413
- package/skills/diagram/SKILL.md +47 -0
- package/skills/diagram/__init__.py +1 -0
- package/skills/diagram/handler.py +294 -0
- package/skills/diagram/layout.py +174 -0
- package/skills/diagram/manifest.yaml +106 -0
- package/skills/diagram/mermaid.py +170 -0
- package/skills/diagram/svg.py +223 -0
- package/skills/entertainment/SKILL.md +35 -35
- package/skills/entertainment/__init__.py +1 -1
- package/skills/entertainment/handler.py +91 -91
- package/skills/entertainment/manifest.yaml +26 -26
- package/skills/file_parser/GUIDANCE.md +10 -10
- package/skills/file_parser/handler.py +33 -11
- package/skills/github/SKILL.md +32 -32
- package/skills/github/__init__.py +1 -1
- package/skills/mail_parser/SKILL.md +68 -68
- package/skills/mail_parser/__init__.py +1 -1
- package/skills/mail_parser/handler.py +1 -1
- package/skills/media_gen/GUIDANCE.md +19 -19
- package/skills/media_gen/SKILL.md +43 -43
- package/skills/media_gen/__init__.py +1 -1
- package/skills/media_gen/handler.py +1 -1
- package/skills/media_gen/manifest.yaml +93 -93
- package/skills/netops/SKILL.md +45 -0
- package/skills/netops/__init__.py +1 -0
- package/skills/netops/handler.py +418 -0
- package/skills/netops/manifest.yaml +118 -0
- package/skills/office_parser/_excel_io.py +3 -3
- package/skills/office_parser/handler.py +2 -2
- package/skills/office_parser/ppt_tools.py +1 -1
- package/skills/office_parser/pptx_export/console_encoding.py +27 -27
- package/skills/office_parser/pptx_export/resource_paths.py +88 -88
- package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
- package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
- package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
- package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
- package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
- package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
- package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
- package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
- package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
- package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
- package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
- package/skills/office_parser/references/layout_library.md +816 -816
- package/skills/office_parser/references/ppt-master/LICENSE +21 -21
- package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
- package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
- package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
- package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
- package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
- package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
- package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
- package/skills/office_parser/references/spec_lock.md +235 -235
- package/skills/office_parser/soffice.py +68 -68
- package/skills/office_parser/word_tools.py +3 -3
- package/skills/ssh/SKILL.md +81 -0
- package/skills/ssh/__init__.py +1 -0
- package/skills/ssh/handler.py +609 -0
- package/skills/ssh/manifest.yaml +182 -0
- package/tui/crannia.cmd +134 -134
- package/tui/crannia.sh +82 -0
- package/tui/crannia_tui/__init__.py +1 -1
- package/tui/crannia_tui/app.py +240 -17
- package/tui/crannia_tui/app.tcss +21 -0
- package/tui/crannia_tui/clipboard.py +78 -10
- package/tui/crannia_tui/commands.py +37 -0
- package/tui/crannia_tui/events.py +6 -0
- package/tui/crannia_tui/i18n.py +164 -164
- package/tui/crannia_tui/locales/en.json +31 -6
- package/tui/crannia_tui/paths.py +4 -1
- package/tui/crannia_tui/profile.py +178 -169
- package/tui/crannia_tui/settings.py +134 -134
- package/tui/crannia_tui/setup.py +44 -5
- package/tui/crannia_tui/ui.py +156 -16
- package/tui/crannia_tui/update.py +393 -389
- package/vendor/ripgrep/COPYING.txt +3 -3
- package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
- package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
- package/vendor/ripgrep/README.md +30 -14
- package/vendor/ripgrep/UNLICENSE.txt +24 -24
- package/vendor/ripgrep/linux-x64/rg +0 -0
- package/vendor/ripgrep/package-source.json +15 -16
- package/web/__main__.py +12 -15
- package/web/server.py +8481 -8594
- package/web/static/img/channel-telegram.svg +1 -1
- package/web/static/img/channel-wechat.svg +1 -1
- package/web/templates/logs.html +49 -49
- package/web/templates/models.html +46 -46
package/core/memory/manager.py
CHANGED
|
@@ -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
|
|
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"
|
|
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
|
|
452
|
-
print(f"[threshold]
|
|
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]
|
|
457
|
-
f"({nh['raw']:,} x factor {nh['factor']:.4f}
|
|
458
|
-
f"
|
|
459
|
-
f"
|
|
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]
|
|
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
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
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]
|
|
64
|
+
print("[memory] marked %d old messages with framework_note" % _n)
|
|
65
65
|
except Exception as exc: # noqa: BLE001
|
|
66
|
-
print("[memory]
|
|
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]
|
|
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]
|
|
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:
|
package/core/memory_extract.py
CHANGED
|
@@ -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
|
|
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:
|
package/core/memory_organize.py
CHANGED
|
@@ -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]
|
|
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]
|
|
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
|
|
661
|
+
print("[memory] memory.organized event send failed: %s: %s"
|
|
662
662
|
% (type(exc).__name__, exc))
|
|
663
663
|
if changed:
|
|
664
|
-
_status(status, "[memory]
|
|
665
|
-
% (len(changed), "
|
|
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)")
|
package/core/memory_store.py
CHANGED
|
@@ -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]
|
|
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
|
|
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]
|
|
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]
|
|
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]
|
|
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] {'
|
|
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]
|
|
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
|
|
package/core/memory_transfer.py
CHANGED
|
@@ -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]
|
|
123
|
-
"
|
|
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]
|
|
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]
|
|
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 {}
|