@hfyjq/crannia 1.1.1 → 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 -7523
- package/core/allowlist.py +2 -3
- package/core/approval.py +36 -26
- 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 +15 -15
- 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 +3 -3
- 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 +37 -28
- 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 +369 -77
- 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 -1762
- 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 +32 -7
- 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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""SSH 凭据与主机密钥的唯一读取口。
|
|
3
|
+
|
|
4
|
+
私钥路径 / 口令 / 密码都不进工具参数;回执里只出现条目名与主机。
|
|
5
|
+
|
|
6
|
+
## 两个存储
|
|
7
|
+
|
|
8
|
+
1. 凭据 —— 设置页 `skill_configs.ssh`(`config.fields` 在
|
|
9
|
+
`skills/ssh/manifest.yaml`,口令与密码是 `format: password` /
|
|
10
|
+
`x-secret: true`),外加 `CRANNIA_SSH_KEY` 环境变量作为私钥路径的兜底。
|
|
11
|
+
形状(`entries` 命名条目 + `active`,旧的单条形状也认):
|
|
12
|
+
|
|
13
|
+
{"active": "pi", "entries": {"pi": {"key_path": "...", "user": "pi",
|
|
14
|
+
"passphrase": "...", "password": "...",
|
|
15
|
+
"sudo_password": "..."}}}
|
|
16
|
+
|
|
17
|
+
2. 主机密钥 —— `data/runtime/ssh/known_hosts`,框架自己的一份。
|
|
18
|
+
决定 4(`出网权限重构-设计-2026-11-26.md §12`):不写用户的
|
|
19
|
+
`~/.ssh/known_hosts` —— 那是用户的文件,框架未经允许不该动它。
|
|
20
|
+
读的时候两份都读(用户已经手动连过的主机直接能用);写的只有自己那份。
|
|
21
|
+
|
|
22
|
+
## 优先级
|
|
23
|
+
|
|
24
|
+
设置页 > 环境变量(只对私钥路径)。读不到 = 未配置(fail-closed:
|
|
25
|
+
`skills/ssh` 的回执会给"去设置页填"的路线)。
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import json
|
|
31
|
+
import os
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Optional
|
|
34
|
+
|
|
35
|
+
__all__ = ["SCOPE", "ENV_KEY", "load", "resolve", "resolve_entry",
|
|
36
|
+
"known_hosts_path", "add_known_host"]
|
|
37
|
+
|
|
38
|
+
_SETTINGS_PATH = Path("data/settings.json")
|
|
39
|
+
SCOPE = "ssh"
|
|
40
|
+
ENV_KEY = "CRANNIA_SSH_KEY"
|
|
41
|
+
|
|
42
|
+
#: 框架自己的 known_hosts(决定 4:不碰 `~/.ssh/known_hosts`)。
|
|
43
|
+
_KNOWN_HOSTS = Path("data/runtime/ssh/known_hosts")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def load(path: Optional[Path] = None) -> dict:
|
|
47
|
+
p = path or _SETTINGS_PATH
|
|
48
|
+
try:
|
|
49
|
+
if not p.exists():
|
|
50
|
+
return {}
|
|
51
|
+
raw = json.loads(p.read_text(encoding="utf-8"))
|
|
52
|
+
except Exception as exc: # noqa: BLE001
|
|
53
|
+
print("[ssh] cannot read settings (%s) - treated as unconfigured" % type(exc).__name__)
|
|
54
|
+
return {}
|
|
55
|
+
cfg = (raw.get("skill_configs") or {}).get(SCOPE) or {}
|
|
56
|
+
return cfg if isinstance(cfg, dict) else {}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def resolve_entry(key_name: str = "") -> dict:
|
|
60
|
+
"""选中的那一条凭据,原样返回(含 `name` / `source`)。没有就空 dict。
|
|
61
|
+
|
|
62
|
+
`key_name` 命中 `entries` 里的名字;不填用 `active` 或第一条。
|
|
63
|
+
旧形状(顶层的 `key_path`)当一条名叫 `default` 的条目。
|
|
64
|
+
环境变量只在私钥路径上兜底 —— 密码类的东西不走环境变量
|
|
65
|
+
(它们会出现在进程环境里,比设置页更不该躺在那儿)。
|
|
66
|
+
"""
|
|
67
|
+
cfg = load()
|
|
68
|
+
entries = cfg.get("entries")
|
|
69
|
+
chosen: dict = {}
|
|
70
|
+
source = ""
|
|
71
|
+
if isinstance(entries, dict) and entries:
|
|
72
|
+
name = str(key_name or cfg.get("active") or "").strip()
|
|
73
|
+
if name and name in entries and isinstance(entries[name], dict):
|
|
74
|
+
chosen = dict(entries[name])
|
|
75
|
+
source = name
|
|
76
|
+
else:
|
|
77
|
+
first_name, first_val = next(iter(entries.items()))
|
|
78
|
+
if isinstance(first_val, dict):
|
|
79
|
+
chosen, source = dict(first_val), str(first_name)
|
|
80
|
+
elif cfg.get("key_path"):
|
|
81
|
+
# 旧的单条形状
|
|
82
|
+
chosen, source = dict(cfg), "default"
|
|
83
|
+
if not chosen:
|
|
84
|
+
env = os.environ.get(ENV_KEY, "").strip()
|
|
85
|
+
if env:
|
|
86
|
+
chosen, source = {"key_path": env}, "env"
|
|
87
|
+
if chosen:
|
|
88
|
+
chosen["name"] = source or "default"
|
|
89
|
+
chosen["source"] = source or "default"
|
|
90
|
+
return chosen
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def resolve(key_name: str = "") -> tuple[str, str, str]:
|
|
94
|
+
"""兼容旧调用:返回 `(私钥路径, 口令, 条目名)`;没有就空串。"""
|
|
95
|
+
e = resolve_entry(key_name)
|
|
96
|
+
return (str(e.get("key_path") or ""), str(e.get("passphrase") or ""),
|
|
97
|
+
str(e.get("name") or ""))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def known_hosts_path() -> Path:
|
|
101
|
+
"""框架自己的 known_hosts 路径(唯一一处)。"""
|
|
102
|
+
return _KNOWN_HOSTS
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def add_known_host(line: str) -> bool:
|
|
106
|
+
"""把一行 known_hosts 记进框架自己的表。已经在了返回 `False`(幂等)。
|
|
107
|
+
|
|
108
|
+
形状校验是窄的:`host keytype base64`,至少三段,且类型以已知前缀开头。
|
|
109
|
+
这样调用方(审批结算)就不会因为一个坏载荷把整份文件写坏 ——
|
|
110
|
+
那是"用户点了信任、下次还问"查不出因的那类故障。
|
|
111
|
+
"""
|
|
112
|
+
text = " ".join(str(line or "").split())
|
|
113
|
+
if not text or len(text) > 4096:
|
|
114
|
+
return False
|
|
115
|
+
parts = text.split(" ")
|
|
116
|
+
if len(parts) < 3:
|
|
117
|
+
return False
|
|
118
|
+
if not parts[1].startswith(("ssh-", "ecdsa-", "sk-", "rsa-")):
|
|
119
|
+
return False
|
|
120
|
+
p = _KNOWN_HOSTS
|
|
121
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
122
|
+
try:
|
|
123
|
+
if p.exists() and text in p.read_text(encoding="utf-8").splitlines():
|
|
124
|
+
return False
|
|
125
|
+
except OSError:
|
|
126
|
+
pass
|
|
127
|
+
with p.open("a", encoding="utf-8") as f:
|
|
128
|
+
f.write(text + "\n")
|
|
129
|
+
return True
|
package/core/state_registry.py
CHANGED
|
@@ -295,6 +295,13 @@ SESSION_SCOPED: Tuple[SessionState, ...] = (
|
|
|
295
295
|
"后台记忆抽取的三格(游标/节流计数/last_turn_at)+ 在飞标志。"
|
|
296
296
|
"不清:新一段对话继承上一段的节流计数(早抽或晚抽几轮)与旧游标 —— "
|
|
297
297
|
"游标靠指纹失配兜底,但 `last_turn_at` 是旧时刻(冷闸会误判『冷』)"),
|
|
298
|
+
SessionState(
|
|
299
|
+
"session_recap", "core/session_recap.py::_LAST_RECAP", "purge_session",
|
|
300
|
+
_lazy("core.session_recap", "forget"),
|
|
301
|
+
"本会话上一次给出自动回顾的时刻(防「那一轮没跑完 ⇒ 每句话都回顾」)。"
|
|
302
|
+
"不清的后果:新一段对话的 `last_turn_at` 也被清了(同一条 purge),"
|
|
303
|
+
"所以通常无害;但若不清,这一格会跟着会话键留下来,"
|
|
304
|
+
"让新对话在 `last_turn_at` 前进之前被旧时刻压住(该给回顾时不给)"),
|
|
298
305
|
# 这两条是「授权」,不是「数据」 ——
|
|
299
306
|
# `/clear` 对它们做的是回收权限,不是丢东西。
|
|
300
307
|
SessionState(
|
|
@@ -524,6 +531,12 @@ SESSION_SCOPED_BY_OTHER: Tuple[SessionState, ...] = (
|
|
|
524
531
|
SessionState(
|
|
525
532
|
"pending_egress", "core/pipeline/scheduler.py::PipelineScheduler._pending_egress",
|
|
526
533
|
"同上", note="同 pending_cross_zone(出网审批)"),
|
|
534
|
+
SessionState(
|
|
535
|
+
"pending_ssh_hostkey",
|
|
536
|
+
"core/pipeline/scheduler.py::PipelineScheduler._pending_ssh_hostkey",
|
|
537
|
+
"同上(同一套派发/结算代码)",
|
|
538
|
+
note="SSH 主机密钥信任 - 自己一格(被审批物是指纹,不是目标授权)。"
|
|
539
|
+
"不清:下一句话会被当成对上一个指纹的回答"),
|
|
527
540
|
SessionState(
|
|
528
541
|
"pending_write_outside",
|
|
529
542
|
"core/pipeline/scheduler.py::PipelineScheduler._pending_write_outside",
|
|
@@ -631,11 +644,16 @@ SESSION_SCOPED_BY_OTHER: Tuple[SessionState, ...] = (
|
|
|
631
644
|
# `_profile_only` 已删:它是"新会话只带画像、不带 facts"的两档开关,
|
|
632
645
|
# 而画像/facts 两段现在整段删除(只剩会话笔记),它没有可区分的对象了。
|
|
633
646
|
# census 会把"过期登记"报出来。
|
|
634
|
-
# SessionPool 2 格
|
|
647
|
+
# SessionPool 3 格(原 2 格 + 模型指纹缓存)
|
|
635
648
|
SessionState(
|
|
636
649
|
"_loaded", "core/session_pool.py::SessionPool._loaded",
|
|
637
650
|
"SessionPool.new_session 用新 (sid, msgs) 覆盖",
|
|
638
651
|
note="它是'这个 key 认不认识'的缓存 —— 判据不能只看它(磁盘上还有绑定表)"),
|
|
652
|
+
SessionState(
|
|
653
|
+
"_loaded_model", "core/session_pool.py::SessionPool._loaded_model",
|
|
654
|
+
"get_or_create 命中时按当前 provider 重新算指纹,不一致则连同 _loaded 一起失效",
|
|
655
|
+
note="只是 _loaded 那份消息按哪个模型窗口装载的标记,不是'这一段用什么模型'。"
|
|
656
|
+
"真正的会话模型在 core/session_model.py,两者不可混"),
|
|
639
657
|
# 这里不能再加一格 `_model_overrides`(`SessionPool` 的会话模型覆盖):
|
|
640
658
|
# 那是一条死路(`/model` 往里写、全仓没有读者),保留它就是让
|
|
641
659
|
# 「这一段用什么模型」有两个看起来都对的地方(`core/session_model.py`
|
|
@@ -873,10 +891,10 @@ PROCESS_SHARED: Tuple[ProcessState, ...] = (
|
|
|
873
891
|
ProcessState(
|
|
874
892
|
"_creds", "core/model_configs.py::_creds",
|
|
875
893
|
"`core/model_configs._LOCK` 护着(与 `_cache` **同一把锁、同一次原子写**)",
|
|
876
|
-
"★
|
|
877
|
-
"
|
|
878
|
-
"⚠️
|
|
879
|
-
"
|
|
894
|
+
"★ 模型 api 的内存镜像(D6 单文件后与 `_cache` **同一份** "
|
|
895
|
+
"`data/runtime/model_configs.json` 的 `api` 字段)。"
|
|
896
|
+
"⚠️ 内存层仍分离:条目出模块时不带 `api`(导出结构上拿不到明文)。"
|
|
897
|
+
"⚠️ 它也不是真相源。★ 与 `_cache` 一次原子写,写失败只出声、不回滚。"
|
|
880
898
|
"⚠️ 那个文件同时在 `core/security.py::DEFAULT_FORBIDDEN_PATHS` 里 ——"
|
|
881
899
|
"**改动它的落点时两处都要改**"),
|
|
882
900
|
ProcessState(
|
|
@@ -893,6 +911,12 @@ PROCESS_SHARED: Tuple[ProcessState, ...] = (
|
|
|
893
911
|
"★ 失效判据挂在 `updated_at` 上(不是「记得清」):用户改了那条配置 ⇒ 下一轮重建。"
|
|
894
912
|
"⚠️ `/clear` **不清它** —— 它是**进程级的缓存**,与哪一段对话无关"
|
|
895
913
|
"(清了只是多几次 import)"),
|
|
914
|
+
ProcessState(
|
|
915
|
+
"_SCAN_CACHE", "core/computer/input.py::_SCAN_CACHE",
|
|
916
|
+
"无锁:只在 _scan_of 里写,而两边写进去的是同一个值"
|
|
917
|
+
"(MapVirtualKey 对同一个虚拟键恒定),没有可以分叉的事实",
|
|
918
|
+
"虚拟键码到 scan code 的缓存。"
|
|
919
|
+
"/clear 不清它,它是进程级的系统常量,与哪一段对话无关。"),
|
|
896
920
|
ProcessState(
|
|
897
921
|
"_ST", "core/session_model.py::_ST",
|
|
898
922
|
"★ **无锁**:只在 `_short_term()` 里写一次(首次拿到单例后就一直命中),"
|
|
@@ -925,6 +949,17 @@ PROCESS_SHARED: Tuple[ProcessState, ...] = (
|
|
|
925
949
|
ProcessState(
|
|
926
950
|
"_declared", "core/tool_output_kind.py::_declared",
|
|
927
951
|
"装载期写入(_note_output_kind),运行期只读", "同 registered_stages"),
|
|
952
|
+
ProcessState(
|
|
953
|
+
"_DECLARED", "core/egress_channels.py::_DECLARED",
|
|
954
|
+
"装载期写入(manifest 的 egress 段 -> declare()),运行期只读",
|
|
955
|
+
"出网能力表的技能那一半(框架那一半是静态的 FRAMEWORK_CHANNELS)。"
|
|
956
|
+
"与 tool_output_kind._declared 同形同命:进程级声明,"
|
|
957
|
+
"/clear 不该碰它,也不进 purge_session"),
|
|
958
|
+
ProcessState(
|
|
959
|
+
"_ROUTE_BY_FAMILY", "core/egress_channels.py::_ROUTE_BY_FAMILY",
|
|
960
|
+
"模块导入期从 DENY_ROUTES 派生,运行期只读",
|
|
961
|
+
"派生表(不是状态)- 登记它是因为 census 按「模块级 dict」扫;"
|
|
962
|
+
"它有读者(route_of_family / deny_message)"),
|
|
928
963
|
ProcessState(
|
|
929
964
|
"_stats", "core/auto_review.py::_stats",
|
|
930
965
|
"无锁;只在 `_auto_review_gate` 那条派发路上加一笔(六个通道各在自己的线程里跑)",
|
|
@@ -1089,6 +1124,13 @@ PROCESS_SHARED: Tuple[ProcessState, ...] = (
|
|
|
1089
1124
|
"★ 与 `bus/core.py::_env_warned` **同形同命**(并发下最多重算一次字符串 ⇒ 无害)。"
|
|
1090
1125
|
"它是给回执用的一句话('为什么这台机器上用不了回收站'),"
|
|
1091
1126
|
"⚠️ 不许当成判据 —— 判据是 `available()`。`/clear` 不清它"),
|
|
1127
|
+
ProcessState(
|
|
1128
|
+
"_xdg_error", "core/recycle.py::_xdg_error",
|
|
1129
|
+
"**无锁 warn-once 字符串**:Linux 那半在 `_xdg_available()` 失败时写一次"
|
|
1130
|
+
"(同一句 `global`)",
|
|
1131
|
+
"★ 与 `_load_error` 同形同命(并发下最多重算一次字符串 ⇒ 无害)。"
|
|
1132
|
+
"它是给回执用的一句话('Linux 上为什么建不了回收站目录'),"
|
|
1133
|
+
"⚠️ 不许当成判据 —— 判据是 `available()`。`/clear` 不清它"),
|
|
1092
1134
|
# 这两格不是会话级:没有 session_id 键,而且 `/clear` 不该碰它们 ——
|
|
1093
1135
|
# 碰了就把挂在那个循环上的 MCP 连接一起掐了。所以归这边。
|
|
1094
1136
|
ProcessState(
|
|
@@ -1205,6 +1247,26 @@ PROCESS_SHARED: Tuple[ProcessState, ...] = (
|
|
|
1205
1247
|
"★ **必须是同一份**:`pre_process` 占位、`post_process` 落账、"
|
|
1206
1248
|
"调度器轮末放位 —— 分成两份就是「占位写 A、落账写 B」,两边都看不出错,"
|
|
1207
1249
|
"而平台重投照样被挡。进程级,`/clear` 不清(`core/dedup.clear()` 的注释)"),
|
|
1250
|
+
ProcessState(
|
|
1251
|
+
"_vision_warned", "core/computer/tools.py::_vision_warned",
|
|
1252
|
+
"只增不减的集合;无锁(并发最坏是多打一行控制台)",
|
|
1253
|
+
"★ 噪声抑制账本:'这个模型的视觉能力没有记录'每个模型只喊一次。"
|
|
1254
|
+
"进程级,与哪条会话无关;`/clear` 不清(清了只会多喊一遍)"),
|
|
1255
|
+
ProcessState(
|
|
1256
|
+
"_CACHE", "core/vision_budget.py::_CACHE",
|
|
1257
|
+
"★ **一把模块内锁(`_LOCK`)** —— 读与写都在锁内(`_read_json` / `_model_config`)",
|
|
1258
|
+
"★ 表文件的 (mtime, 内容) 缓存,按绝对路径键。进程级只读缓存;"
|
|
1259
|
+
"`reset_cache()` 给测试用,运行期不清"),
|
|
1260
|
+
ProcessState(
|
|
1261
|
+
"policy_cache", "core/cache_policies.py::_CACHE",
|
|
1262
|
+
"★ **一把模块内可重入锁(`_LOCK`)** —— 读与写都在锁内(`_read_table` / `_model_config`)",
|
|
1263
|
+
"★ 策略表与 config.yaml 的 (mtime, 内容) 缓存,按绝对路径键。"
|
|
1264
|
+
"进程级只读缓存;`reset_cache()` 给测试用,运行期不清"),
|
|
1265
|
+
ProcessState(
|
|
1266
|
+
"model_profile_cache", "core/model_profiles.py::_CACHE",
|
|
1267
|
+
"★ **一把模块内可重入锁(`_LOCK`)** —— 读与写都在锁内(`_read_table`)",
|
|
1268
|
+
"★ 模型能力差异表的 (mtime, 内容) 缓存,按绝对路径键。"
|
|
1269
|
+
"进程级只读缓存;`reset_cache()` 给测试用,运行期不清"),
|
|
1208
1270
|
)
|
|
1209
1271
|
|
|
1210
1272
|
|
package/core/subagent.py
CHANGED
|
@@ -346,6 +346,23 @@ def _sanitize_report(text: str) -> str:
|
|
|
346
346
|
return text
|
|
347
347
|
|
|
348
348
|
|
|
349
|
+
def _child_thinking(snapshot, provider):
|
|
350
|
+
"""子的思考档:同模型完全照父(前缀同源),跨模型才按子画像回落。"""
|
|
351
|
+
parent = tiers.current_spec(snapshot.session_id).thinking
|
|
352
|
+
child_model = str(getattr(provider, "_model", "") or "")
|
|
353
|
+
if not child_model or child_model == getattr(snapshot, "model", ""):
|
|
354
|
+
return parent
|
|
355
|
+
from core import model_profiles as _profiles
|
|
356
|
+
efforts = _profiles.resolve(
|
|
357
|
+
str(getattr(provider, "_provider_name", "") or ""),
|
|
358
|
+
child_model).thinking.get("efforts") or []
|
|
359
|
+
if parent is None or not isinstance(parent, str):
|
|
360
|
+
return parent
|
|
361
|
+
if parent in efforts:
|
|
362
|
+
return parent
|
|
363
|
+
return efforts[0] if efforts else None
|
|
364
|
+
|
|
365
|
+
|
|
349
366
|
def run_child(*, snapshot, assistant_msg: dict, task: str, provider,
|
|
350
367
|
max_turns: int, readonly_mode: bool = False,
|
|
351
368
|
emit: Callable | None = None,
|
|
@@ -446,7 +463,7 @@ def run_child(*, snapshot, assistant_msg: dict, task: str, provider,
|
|
|
446
463
|
system=snapshot.system, tools=snapshot.tools,
|
|
447
464
|
force=force, threshold=_FORCE_RATIO)
|
|
448
465
|
except Exception as exc: # noqa: BLE001 —— 压缩失败不该弄挂子这一趟
|
|
449
|
-
print(f"[subagent]
|
|
466
|
+
print(f"[subagent] context compression failed ({type(exc).__name__}: {exc})")
|
|
450
467
|
return None
|
|
451
468
|
return new if done else None
|
|
452
469
|
|
|
@@ -476,10 +493,10 @@ def run_child(*, snapshot, assistant_msg: dict, task: str, provider,
|
|
|
476
493
|
_tools=snapshot.tools,
|
|
477
494
|
_system=snapshot.system,
|
|
478
495
|
# 第四个必须同源的 —— 思考模式进提示缓存键
|
|
479
|
-
# (五项 cacheSafeParams
|
|
480
|
-
#
|
|
481
|
-
#
|
|
482
|
-
thinking=
|
|
496
|
+
# (五项 cacheSafeParams 之一)。同模型时逐字沿用父档,
|
|
497
|
+
# fork 那台机器才不白搭;跨模型时父那档可能子模型不认,
|
|
498
|
+
# 才按子画像回落(这时前缀本来就不共享,不损失缓存)。
|
|
499
|
+
thinking=_child_thinking(snapshot, provider),
|
|
483
500
|
_emit=None, # v0:子的轮次事件不进父的时间线(轮号会串)
|
|
484
501
|
# 任务级取消令牌:取消一个后台子 agent
|
|
485
502
|
# 只停它,不动父那一轮(会话级 `is_cancelled` 仍在)。
|
|
@@ -511,7 +528,13 @@ def run_child(*, snapshot, assistant_msg: dict, task: str, provider,
|
|
|
511
528
|
text = EMPTY_OUTPUT
|
|
512
529
|
# `WB5`:回父之前先"去毒"(确定性那半永远跑,见 `_sanitize_report`)
|
|
513
530
|
text = _sanitize_report(text)
|
|
531
|
+
# 回报带上实际用的模型:父拿到结果时才知道这段是谁说的,
|
|
532
|
+
# 跨模型 fork 的前缀假设也才能被外部判定(同模型才同前缀)。
|
|
533
|
+
_child_model = str(getattr(provider, "_model", "") or "")
|
|
534
|
+
_same_model = (_child_model == getattr(snapshot, "model", _child_model))
|
|
514
535
|
return {"success": True, "output": text, "tokens": tokens,
|
|
536
|
+
"model": _child_model,
|
|
537
|
+
"same_model_as_parent": _same_model,
|
|
515
538
|
"note": "子 agent 的过程、工具输出与推理都没有回传,只有上面这段话"}
|
|
516
539
|
|
|
517
540
|
|
package/core/subagent_defs.py
CHANGED
|
@@ -84,7 +84,7 @@ def agent_roots() -> list[Path]:
|
|
|
84
84
|
from core import plugin_packages
|
|
85
85
|
roots.extend(plugin_packages.agents_dirs())
|
|
86
86
|
except Exception as exc: # noqa: BLE001
|
|
87
|
-
print("[subagent]
|
|
87
|
+
print("[subagent] read plugin packs failed: %s: %s" % (type(exc).__name__, exc))
|
|
88
88
|
out: list[Path] = []
|
|
89
89
|
seen: set[str] = set()
|
|
90
90
|
for r in roots:
|
|
@@ -112,14 +112,14 @@ def _parse(path: Path) -> Optional[SubagentDef]:
|
|
|
112
112
|
import yaml
|
|
113
113
|
meta = yaml.safe_load(m.group(1))
|
|
114
114
|
except Exception: # noqa: BLE001
|
|
115
|
-
print("[subagent]
|
|
115
|
+
print("[subagent] skipping %s: frontmatter unparsable" % path)
|
|
116
116
|
return None
|
|
117
117
|
if not isinstance(meta, dict):
|
|
118
118
|
return None
|
|
119
119
|
|
|
120
120
|
name = str(meta.get("name") or path.stem).strip()
|
|
121
121
|
if not _NAME_RE.match(name):
|
|
122
|
-
print("[subagent]
|
|
122
|
+
print("[subagent] skipping %s: invalid name (%r)" % (path, name))
|
|
123
123
|
return None
|
|
124
124
|
description = str(meta.get("description") or "").strip()
|
|
125
125
|
|
package/core/summarizer.py
CHANGED
|
@@ -78,7 +78,7 @@ def load_cached(key: str) -> Optional[str]:
|
|
|
78
78
|
data = json.loads(p.read_text(encoding="utf-8"))
|
|
79
79
|
except Exception as e:
|
|
80
80
|
# 出声但继续 —— 缓存是加速器,不是正确性的一部分(判据 ②)。
|
|
81
|
-
print(f"[summarizer]
|
|
81
|
+
print(f"[summarizer] cache read failed ({type(e).__name__}: {e}) - treating as no cache")
|
|
82
82
|
return None
|
|
83
83
|
text = data.get("text") if isinstance(data, dict) else None
|
|
84
84
|
if isinstance(text, str) and text.strip():
|
|
@@ -104,7 +104,7 @@ def save_cached(key: str, text: str) -> None:
|
|
|
104
104
|
os.replace(tmp, final)
|
|
105
105
|
_evict()
|
|
106
106
|
except Exception as e:
|
|
107
|
-
print(f"[summarizer]
|
|
107
|
+
print(f"[summarizer] cache write failed ({type(e).__name__}: {e}) - not caching this time")
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
def _evict() -> None:
|
|
@@ -197,7 +197,7 @@ def iterative_summarize(
|
|
|
197
197
|
merge_batch_size, _model)
|
|
198
198
|
_hit = load_cached(_key)
|
|
199
199
|
if _hit is not None:
|
|
200
|
-
print(f"[summarizer]
|
|
200
|
+
print(f"[summarizer] cache hit ({_key[:12]}...) - 0 LLM calls")
|
|
201
201
|
return _hit
|
|
202
202
|
_result = _summarize_uncached(
|
|
203
203
|
chunks, llm_client, summary_prompt,
|
|
@@ -224,8 +224,7 @@ def _summarize_uncached(
|
|
|
224
224
|
_budget = _single_call_char_budget(llm_client)
|
|
225
225
|
_total_chars = sum(len(c.get("text", "")) for c in chunks)
|
|
226
226
|
if _budget and _total_chars <= _budget:
|
|
227
|
-
print(f"[summarizer]
|
|
228
|
-
f"—— 一次调用完成(跳过 map-reduce)")
|
|
227
|
+
print(f"[summarizer] document {_total_chars:,} chars <= single-call budget {_budget:,} - done in one call (map-reduce skipped)")
|
|
229
228
|
return _summarize_single(
|
|
230
229
|
llm_client,
|
|
231
230
|
system_prompt=summary_prompt,
|
package/core/tasks_notify.py
CHANGED
|
@@ -197,14 +197,14 @@ def _default_deliver(session: MessageSession, text: str) -> None:
|
|
|
197
197
|
from core.cron.runner import resolve_channel
|
|
198
198
|
ch = resolve_channel(session.platform)
|
|
199
199
|
if ch is None:
|
|
200
|
-
print("[tasks]
|
|
200
|
+
print("[tasks] background report not deliverable: %s channel not running" % session.platform)
|
|
201
201
|
return
|
|
202
202
|
#: 回执契约:只有 `True` 才算送达(见 `channels/base.py::send`)。
|
|
203
203
|
#: 同一条判据在 `cron/runner.py::_deliver`;两处都是"没声张的成功"的入口。
|
|
204
204
|
if asyncio.run(ch.send(session, text[:4000])) is not True:
|
|
205
|
-
print("[tasks]
|
|
205
|
+
print("[tasks] background report delivery failed: %s channel reported undelivered" % session.platform)
|
|
206
206
|
except Exception as exc: # noqa: BLE001
|
|
207
|
-
print("[tasks]
|
|
207
|
+
print("[tasks] background report delivery failed (%s: %s)"
|
|
208
208
|
% (type(exc).__name__, exc))
|
|
209
209
|
|
|
210
210
|
|
|
@@ -288,10 +288,10 @@ def _run_turn(key: str, item: dict, scheduler, deliver) -> None:
|
|
|
288
288
|
try:
|
|
289
289
|
deliver(event.session, text or "")
|
|
290
290
|
except Exception as exc: # noqa: BLE001
|
|
291
|
-
print("[tasks]
|
|
291
|
+
print("[tasks] background turn reply delivery failed (%s: %s)"
|
|
292
292
|
% (type(exc).__name__, exc))
|
|
293
293
|
except Exception as exc: # noqa: BLE001
|
|
294
|
-
print("[tasks]
|
|
294
|
+
print("[tasks] background notification turn start failed (%s: %s)"
|
|
295
295
|
% (type(exc).__name__, exc))
|
|
296
296
|
finally:
|
|
297
297
|
with _lock:
|
|
@@ -333,7 +333,7 @@ def _dispatcher() -> None:
|
|
|
333
333
|
try:
|
|
334
334
|
dispatch_once()
|
|
335
335
|
except Exception as exc: # noqa: BLE001
|
|
336
|
-
print("[tasks]
|
|
336
|
+
print("[tasks] notification dispatch failed (%s: %s)" % (type(exc).__name__, exc))
|
|
337
337
|
|
|
338
338
|
|
|
339
339
|
def install(scheduler, deliver: Optional[Callable] = None,
|
package/core/tiers.py
CHANGED
|
@@ -515,7 +515,7 @@ def current_level(session_id: str = "") -> int:
|
|
|
515
515
|
level = configured_level()
|
|
516
516
|
_frozen[key] = level
|
|
517
517
|
# 出声(一次会话一行):改档是冷启动这件事得看得见。
|
|
518
|
-
print("[tier]
|
|
518
|
+
print("[tier] effort level %d (%s) - frozen for this session" % (level, TIERS[level].name))
|
|
519
519
|
return level
|
|
520
520
|
|
|
521
521
|
|
|
@@ -594,7 +594,7 @@ def set_level(session_id: str, level: int) -> None:
|
|
|
594
594
|
key = session_id or ""
|
|
595
595
|
with _freeze_lock:
|
|
596
596
|
_frozen[key] = int(level)
|
|
597
|
-
print("[tier]
|
|
597
|
+
print("[tier] effort level -> %d (%s) - this session only, not persisted"
|
|
598
598
|
% (int(level), TIERS[int(level)].name))
|
|
599
599
|
|
|
600
600
|
|
package/core/todos.py
CHANGED
|
@@ -180,7 +180,7 @@ def todo_write(todos=None) -> dict:
|
|
|
180
180
|
|
|
181
181
|
_todos[session_id] = items
|
|
182
182
|
in_progress = sum(1 for it in items if it["status"] == "in_progress")
|
|
183
|
-
print("[todo] %d
|
|
183
|
+
print("[todo] %d items (%d in progress) session=%s"
|
|
184
184
|
% (len(items), in_progress, session_id or "-"))
|
|
185
185
|
return {
|
|
186
186
|
"success": True,
|
package/core/token_calibrator.py
CHANGED
|
@@ -141,10 +141,7 @@ class TokenCalibrator:
|
|
|
141
141
|
scheme = entry.get("scheme")
|
|
142
142
|
if scheme != self.ESTIMATOR_SCHEME:
|
|
143
143
|
print(
|
|
144
|
-
f"[calibrator]
|
|
145
|
-
f"({entry.get('samples')} 个, ema={entry.get('ema')}, "
|
|
146
|
-
f"scheme={scheme!r} != {self.ESTIMATOR_SCHEME}): "
|
|
147
|
-
f"估算器口径变了,旧样本是另一个量的样本"
|
|
144
|
+
f"[calibrator] discarding old samples for {self._provider} ({entry.get('samples')}, ema={entry.get('ema')}, scheme={scheme!r} != {self.ESTIMATOR_SCHEME}): estimator scheme changed, old samples measured a different quantity"
|
|
148
145
|
)
|
|
149
146
|
return False
|
|
150
147
|
self._ema = float(entry.get("ema", 1.0))
|