@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
|
@@ -99,7 +99,7 @@ def _acquire_turn_slot(session_key: str) -> None:
|
|
|
99
99
|
事件发送失败不许影响排队本身(观测不能阻断操作)。
|
|
100
100
|
"""
|
|
101
101
|
if not _turn_slots.acquire(blocking=False):
|
|
102
|
-
print("[sched] %s
|
|
102
|
+
print("[sched] %s queued (concurrency limit %d)" % (session_key, _MAX_CONCURRENT_TURNS))
|
|
103
103
|
try:
|
|
104
104
|
from core.events import (EVT_TURN_QUEUED,
|
|
105
105
|
TURN_QUEUED_MESSAGE, get_event_bus)
|
|
@@ -110,7 +110,7 @@ def _acquire_turn_slot(session_key: str) -> None:
|
|
|
110
110
|
limit=_MAX_CONCURRENT_TURNS,
|
|
111
111
|
message=TURN_QUEUED_MESSAGE)
|
|
112
112
|
except Exception as exc: # noqa: BLE001
|
|
113
|
-
print("[sched] turn.queued
|
|
113
|
+
print("[sched] failed to emit turn.queued event: %s: %s" % (type(exc).__name__, exc))
|
|
114
114
|
_turn_slots.acquire()
|
|
115
115
|
|
|
116
116
|
|
|
@@ -221,8 +221,8 @@ def _context_state_payload(ctx, session_key: str) -> "dict | None":
|
|
|
221
221
|
try:
|
|
222
222
|
pool.note_memory_context(session_key, _mc)
|
|
223
223
|
except Exception as e:
|
|
224
|
-
print(f"[context]
|
|
225
|
-
f"
|
|
224
|
+
print(f"[context] memory-injection reading not recorded ({type(e).__name__}: {e}) - "
|
|
225
|
+
f"panel cell stays at last turn's value")
|
|
226
226
|
|
|
227
227
|
usage = ctx.metadata.get("context_usage")
|
|
228
228
|
if not isinstance(usage, dict):
|
|
@@ -327,6 +327,9 @@ _PENDING_STORES: tuple[tuple[str, str], ...] = (
|
|
|
327
327
|
# 钩子要求人工确认(`PreToolUse` 的 `ask`)。自己一格。
|
|
328
328
|
# 漏了这一行同样坏:聊天/回执里写着要确认,而浮窗永远不出现。
|
|
329
329
|
("hook_ask", "_pending_hook_ask"),
|
|
330
|
+
# SSH 主机密钥信任(TOFU)。自己一格(一格只许一个 kind 用)-
|
|
331
|
+
# 被审批物是指纹,不是目标的授权范围。漏了同样坏。
|
|
332
|
+
("ssh_hostkey", "_pending_ssh_hostkey"),
|
|
330
333
|
)
|
|
331
334
|
|
|
332
335
|
|
|
@@ -405,6 +408,8 @@ class PipelineScheduler:
|
|
|
405
408
|
# 读者仍必须从载荷取 kind(`pend["kind"]`)—— 见
|
|
406
409
|
# `_PENDING_STORES`。
|
|
407
410
|
self._pending_egress: dict[str, dict] = {}
|
|
411
|
+
# SSH 主机密钥信任(TOFU)。自己一格(一格只许一个 kind 用)。
|
|
412
|
+
self._pending_ssh_hostkey: dict[str, dict] = {}
|
|
408
413
|
self._pending_command: dict[str, dict] = {}
|
|
409
414
|
# 兜底闸(不可逆、且自身没有审批发射点的工具)。
|
|
410
415
|
self._pending_destructive: dict[str, dict] = {}
|
|
@@ -506,7 +511,7 @@ class PipelineScheduler:
|
|
|
506
511
|
wm = get_workspace_manager()
|
|
507
512
|
except Exception as exc:
|
|
508
513
|
print(f"[pipeline] approval projection could not reach the workspace "
|
|
509
|
-
f"manager ({type(exc).__name__}: {exc})
|
|
514
|
+
f"manager ({type(exc).__name__}: {exc}) - this turn will ask again")
|
|
510
515
|
return
|
|
511
516
|
|
|
512
517
|
if wm is None:
|
|
@@ -547,7 +552,7 @@ class PipelineScheduler:
|
|
|
547
552
|
setattr(wm, name, value)
|
|
548
553
|
except Exception as exc:
|
|
549
554
|
print(f"[pipeline] projection of {name} failed "
|
|
550
|
-
f"({type(exc).__name__}: {exc})
|
|
555
|
+
f"({type(exc).__name__}: {exc}) - this turn will ask again")
|
|
551
556
|
|
|
552
557
|
# 按目标、按对话的放行。不并进上面的循环 —— 它不是标量赋值,而是
|
|
553
558
|
# 整组替换(`set_target_session`),每个 kind 调一次。
|
|
@@ -586,7 +591,7 @@ class PipelineScheduler:
|
|
|
586
591
|
wm.set_target_wildcard(kind, "*" in persisted)
|
|
587
592
|
except Exception as exc:
|
|
588
593
|
print(f"[pipeline] projection of target grants failed "
|
|
589
|
-
f"({type(exc).__name__}: {exc})
|
|
594
|
+
f"({type(exc).__name__}: {exc}) - this turn will ask again")
|
|
590
595
|
|
|
591
596
|
# ------------------------------------------------------------------
|
|
592
597
|
def pending_approval(self, session_key: str) -> dict | None:
|
|
@@ -773,8 +778,8 @@ class PipelineScheduler:
|
|
|
773
778
|
except Exception: # noqa: BLE001
|
|
774
779
|
return
|
|
775
780
|
if _AT.arm(session_key, loop, self._fire_approval_timeout):
|
|
776
|
-
print("[approval-timeout]
|
|
777
|
-
"
|
|
781
|
+
print("[approval-timeout] pending approval - in %d seconds; "
|
|
782
|
+
"settled as 'no channel to ask' (/clear or an answer cancels)"
|
|
778
783
|
% _AT.seconds(session_key))
|
|
779
784
|
|
|
780
785
|
def _fire_approval_timeout(self, session_key: str) -> None:
|
|
@@ -792,8 +797,8 @@ class PipelineScheduler:
|
|
|
792
797
|
return # 已经答过了 / 撤了
|
|
793
798
|
event = _AT.event_of(session_key)
|
|
794
799
|
if event is None:
|
|
795
|
-
print("[approval-timeout]
|
|
796
|
-
"
|
|
800
|
+
print("[approval-timeout] timer fired but event not remembered - "
|
|
801
|
+
"doing nothing (keep waiting)")
|
|
797
802
|
return
|
|
798
803
|
try:
|
|
799
804
|
evt = copy.copy(event)
|
|
@@ -801,15 +806,15 @@ class PipelineScheduler:
|
|
|
801
806
|
evt.extras["approval_timeout"] = True
|
|
802
807
|
evt._stopped = False
|
|
803
808
|
except Exception as exc: # noqa: BLE001
|
|
804
|
-
print("[approval-timeout]
|
|
809
|
+
print("[approval-timeout] failed to build timeout event (%s) - doing nothing"
|
|
805
810
|
% type(exc).__name__)
|
|
806
811
|
return
|
|
807
812
|
try:
|
|
808
813
|
asyncio.ensure_future(self.execute(evt))
|
|
809
|
-
print("[approval-timeout] %s
|
|
814
|
+
print("[approval-timeout] %s: timer fired, settled as 'no channel to ask'"
|
|
810
815
|
% session_key)
|
|
811
816
|
except Exception as exc: # noqa: BLE001
|
|
812
|
-
print("[approval-timeout]
|
|
817
|
+
print("[approval-timeout] re-entry failed (%s) - doing nothing"
|
|
813
818
|
% type(exc).__name__)
|
|
814
819
|
|
|
815
820
|
# ------------------------------------------------------------------
|
|
@@ -943,10 +948,10 @@ class PipelineScheduler:
|
|
|
943
948
|
from core import net_proxy as _np
|
|
944
949
|
_changed = _np.apply_env_policy()
|
|
945
950
|
if _changed:
|
|
946
|
-
print("[proxy]
|
|
951
|
+
print("[proxy] '%s' mode applied to env vars: %s"
|
|
947
952
|
% (_np.mode(), ", ".join(_changed)))
|
|
948
953
|
except Exception as _e: # noqa: BLE001
|
|
949
|
-
print("[proxy]
|
|
954
|
+
print("[proxy] env vars not applied (env-only SDKs follow system): "
|
|
950
955
|
"%s: %s" % (type(_e).__name__, _e))
|
|
951
956
|
#: 附件回收:后台线程 + 一天一次(`attachment_gc.maybe_prune_daily`)。
|
|
952
957
|
#: 判据是"启动是唯一不会漏的入口"(同监听器自启动那一段),
|
|
@@ -959,12 +964,12 @@ class PipelineScheduler:
|
|
|
959
964
|
try:
|
|
960
965
|
st = maybe_prune_daily()
|
|
961
966
|
if st and st.get("deleted"):
|
|
962
|
-
print("[attachments]
|
|
967
|
+
print("[attachments] reclaimed %d unreferenced attachments (%d bytes)"
|
|
963
968
|
% (st["deleted"], st["freed"]))
|
|
964
969
|
elif st and st.get("skipped"):
|
|
965
|
-
print("[attachments]
|
|
970
|
+
print("[attachments] nothing reclaimed this time (%s)" % st["skipped"])
|
|
966
971
|
except Exception as exc: # noqa: BLE001
|
|
967
|
-
print("[attachments]
|
|
972
|
+
print("[attachments] reclaim failed (does not affect the framework): %s: %s"
|
|
968
973
|
% (type(exc).__name__, exc))
|
|
969
974
|
#: 框架自己的运行目录(计划 / 工具结果 / 通道收件媒体 /
|
|
970
975
|
#: 任务日志)原来谁都不收。挂在启动这一下 ——
|
|
@@ -973,13 +978,13 @@ class PipelineScheduler:
|
|
|
973
978
|
from core.retention import prune_runtime_dirs
|
|
974
979
|
prune_runtime_dirs()
|
|
975
980
|
except Exception as exc: # noqa: BLE001
|
|
976
|
-
print("[retention]
|
|
981
|
+
print("[retention] runtime dir reclaim failed (does not affect the framework): %s: %s"
|
|
977
982
|
% (type(exc).__name__, exc))
|
|
978
983
|
|
|
979
984
|
threading.Thread(target=_gc_bg, name="attachment-gc",
|
|
980
985
|
daemon=True).start()
|
|
981
986
|
except Exception as exc: # noqa: BLE001
|
|
982
|
-
print("[attachments]
|
|
987
|
+
print("[attachments] reclaim thread not started (does not affect the framework): %s: %s"
|
|
983
988
|
% (type(exc).__name__, exc))
|
|
984
989
|
try:
|
|
985
990
|
from bus.registry import get_workspace_manager
|
|
@@ -987,7 +992,7 @@ class PipelineScheduler:
|
|
|
987
992
|
if wm is not None:
|
|
988
993
|
wm.autostart_watchers()
|
|
989
994
|
except Exception as exc: # noqa: BLE001
|
|
990
|
-
print("[scheduler]
|
|
995
|
+
print("[scheduler] listener autostart failed (does not affect framework startup): %s: %s"
|
|
991
996
|
% (type(exc).__name__, exc))
|
|
992
997
|
|
|
993
998
|
def _apply_configured_model(self) -> None:
|
|
@@ -1038,10 +1043,10 @@ class PipelineScheduler:
|
|
|
1038
1043
|
mgr._provider = inst
|
|
1039
1044
|
mgr.report_thresholds()
|
|
1040
1045
|
except Exception as exc: # noqa: BLE001
|
|
1041
|
-
print("[scheduler]
|
|
1046
|
+
print("[scheduler] memory layer model switch failed (still using old window): %s: %s"
|
|
1042
1047
|
% (type(exc).__name__, exc))
|
|
1043
1048
|
except Exception as exc: # noqa: BLE001
|
|
1044
|
-
print("[scheduler]
|
|
1049
|
+
print("[scheduler] model config load failed, using config.yaml model: %s: %s"
|
|
1045
1050
|
% (type(exc).__name__, exc))
|
|
1046
1051
|
|
|
1047
1052
|
@staticmethod
|
|
@@ -1078,7 +1083,7 @@ class PipelineScheduler:
|
|
|
1078
1083
|
return None
|
|
1079
1084
|
return _mc.instance_for(cid, fallback=None)
|
|
1080
1085
|
except Exception as exc: # noqa: BLE001
|
|
1081
|
-
print(f"[scheduler]
|
|
1086
|
+
print(f"[scheduler] group-host model resolution failed, using the process one: "
|
|
1082
1087
|
f"{type(exc).__name__}: {exc}")
|
|
1083
1088
|
return None
|
|
1084
1089
|
|
|
@@ -1121,12 +1126,12 @@ class PipelineScheduler:
|
|
|
1121
1126
|
return "", self._provider
|
|
1122
1127
|
inst = _mc.instance_for(cid, fallback=None)
|
|
1123
1128
|
if inst is None:
|
|
1124
|
-
print(f"[scheduler]
|
|
1125
|
-
f"
|
|
1129
|
+
print(f"[scheduler] frozen config '{cid}' unusable today - "
|
|
1130
|
+
f"using original model this turn (not freezing; next turn follows default)")
|
|
1126
1131
|
return "", self._provider
|
|
1127
1132
|
return cid, inst
|
|
1128
1133
|
except Exception as exc: # noqa: BLE001
|
|
1129
|
-
print("[scheduler]
|
|
1134
|
+
print("[scheduler] model resolution failed for this conversation, using process one: %s: %s"
|
|
1130
1135
|
% (type(exc).__name__, exc))
|
|
1131
1136
|
return "", self._provider
|
|
1132
1137
|
|
|
@@ -1182,7 +1187,7 @@ class PipelineScheduler:
|
|
|
1182
1187
|
decision = im_routing.route(
|
|
1183
1188
|
event, self._last_activity, self._title_of, self._session_exists)
|
|
1184
1189
|
except Exception as exc: # noqa: BLE001
|
|
1185
|
-
print("[routing]
|
|
1190
|
+
print("[routing] routing failed (falling back to default key): %s: %s"
|
|
1186
1191
|
% (type(exc).__name__, exc))
|
|
1187
1192
|
decision = None
|
|
1188
1193
|
if decision is not None and decision.kind == "ask":
|
|
@@ -1224,7 +1229,7 @@ class PipelineScheduler:
|
|
|
1224
1229
|
from core.computer import session as _cu
|
|
1225
1230
|
_cu.disarm_for(session_key, "turn_end")
|
|
1226
1231
|
except Exception as exc: # noqa: BLE001
|
|
1227
|
-
print("[computer]
|
|
1232
|
+
print("[computer] turn-end close-operation detection failed: %s: %s"
|
|
1228
1233
|
% (type(exc).__name__, exc))
|
|
1229
1234
|
_turn_slots.release()
|
|
1230
1235
|
finally:
|
|
@@ -1431,8 +1436,8 @@ class PipelineScheduler:
|
|
|
1431
1436
|
from core.dedup import default as _dedup_default
|
|
1432
1437
|
_dedup_default().release(**_ded)
|
|
1433
1438
|
except Exception as exc: # noqa: BLE001
|
|
1434
|
-
print(f"[dedup]
|
|
1435
|
-
f"
|
|
1439
|
+
print(f"[dedup] failed to claim slot ({type(exc).__name__}: {exc})"
|
|
1440
|
+
f" - a redelivery may be treated as duplicate")
|
|
1436
1441
|
|
|
1437
1442
|
# 轮末收口:还在重试的清掉(否则 `/api/status` 每 5 秒
|
|
1438
1443
|
# 把它读回来,网络恢复了红条也不消失);失败收尾的留着 ——
|
|
@@ -1441,8 +1446,8 @@ class PipelineScheduler:
|
|
|
1441
1446
|
from core import llm_retry as _lr
|
|
1442
1447
|
_lr.reset_if_retrying(session_key)
|
|
1443
1448
|
except Exception as exc: # noqa: BLE001
|
|
1444
|
-
print(f"[llm]
|
|
1445
|
-
f"
|
|
1449
|
+
print(f"[llm] retry-state cleanup failed ({type(exc).__name__}: {exc})"
|
|
1450
|
+
f" - next turn's banner may still show")
|
|
1446
1451
|
|
|
1447
1452
|
# 轮末:把 `ctx` 上的载体收回按对话的真值表
|
|
1448
1453
|
# 抽成方法是为了让测试能调用真的那份:测试若抄这 60 行
|
|
@@ -1460,9 +1465,9 @@ class PipelineScheduler:
|
|
|
1460
1465
|
try:
|
|
1461
1466
|
_ctx_state = _context_state_payload(ctx, session_key)
|
|
1462
1467
|
except Exception as exc: # noqa: BLE001
|
|
1463
|
-
print(f"[context]
|
|
1464
|
-
f"({type(exc).__name__}: {exc})
|
|
1465
|
-
f"
|
|
1468
|
+
print(f"[context] state reading failed "
|
|
1469
|
+
f"({type(exc).__name__}: {exc}) - no "
|
|
1470
|
+
f"context event this turn")
|
|
1466
1471
|
_ctx_state = None
|
|
1467
1472
|
if _ctx_state is not None:
|
|
1468
1473
|
bus.emit(EVT_CONTEXT_STATE, session_key=session_key,
|
|
@@ -1490,7 +1495,7 @@ class PipelineScheduler:
|
|
|
1490
1495
|
try:
|
|
1491
1496
|
self._sync_approval_timer(session_key)
|
|
1492
1497
|
except Exception as exc: # noqa: BLE001
|
|
1493
|
-
print("[approval-timeout]
|
|
1498
|
+
print("[approval-timeout] failed to sync timer (%s) - this turn unaffected"
|
|
1494
1499
|
% type(exc).__name__)
|
|
1495
1500
|
|
|
1496
1501
|
# 回复头只加给 IM,而且只加在被改派过的轮次 —— 前端看得见
|
|
@@ -1600,8 +1605,8 @@ class PipelineScheduler:
|
|
|
1600
1605
|
from core import steer as _steer_inbox
|
|
1601
1606
|
_steer_left = _steer_inbox.drain(session_key)
|
|
1602
1607
|
except Exception as exc: # noqa: BLE001
|
|
1603
|
-
print(f"[steer]
|
|
1604
|
-
f"
|
|
1608
|
+
print(f"[steer] turn-end drain failed ({type(exc).__name__}: {exc})"
|
|
1609
|
+
f" - no steer_leftover this turn")
|
|
1605
1610
|
# 两条出口都要有:`extras` 给 `/api/chat`,关键字参数给 SSE。
|
|
1606
1611
|
try:
|
|
1607
1612
|
event.extras["steer_leftover"] = _steer_left
|
|
@@ -1685,9 +1690,9 @@ class PipelineScheduler:
|
|
|
1685
1690
|
try:
|
|
1686
1691
|
_files = _touched_payload(session_key)
|
|
1687
1692
|
except Exception as exc: # noqa: BLE001
|
|
1688
|
-
print(f"[files]
|
|
1689
|
-
f"({type(exc).__name__}: {exc})
|
|
1690
|
-
f"
|
|
1693
|
+
print(f"[files] failed to send changed-file list "
|
|
1694
|
+
f"({type(exc).__name__}: {exc}) - no "
|
|
1695
|
+
f"changed-file event this turn")
|
|
1691
1696
|
_files = None
|
|
1692
1697
|
if _files:
|
|
1693
1698
|
bus.emit(EVT_FILES_CHANGED, session_key=session_key,
|
package/core/pipeline/stage.py
CHANGED
|
@@ -94,6 +94,9 @@ class StageContext:
|
|
|
94
94
|
pending_hook_ask: dict = field(default_factory=dict)
|
|
95
95
|
#: 出网审批(`web_fetch` / `send_email` 的目标)。
|
|
96
96
|
pending_egress: dict = field(default_factory=dict)
|
|
97
|
+
#: SSH 主机密钥信任(TOFU)。自己一格(一格只许一个 kind 用)-
|
|
98
|
+
#: 被审批物是"这个指纹",不是目标的授权范围。
|
|
99
|
+
pending_ssh_hostkey: dict = field(default_factory=dict)
|
|
97
100
|
#: 执行审批(`run_command`)。
|
|
98
101
|
#: 命令的审批只有一种档位(没有「危险档」)——
|
|
99
102
|
#: 所以这一格只装 `command` 一种 kind。但读者仍然取自载荷
|
|
@@ -84,7 +84,7 @@ class AgentLoopStage(Stage):
|
|
|
84
84
|
from core import session_workspace
|
|
85
85
|
session_workspace.pin(ctx.storage_id)
|
|
86
86
|
except Exception as _ws_exc: # noqa: BLE001
|
|
87
|
-
print(f"[workspace]
|
|
87
|
+
print(f"[workspace] cannot pin this turn's workspace dir (using default): "
|
|
88
88
|
f"{type(_ws_exc).__name__}: {_ws_exc}")
|
|
89
89
|
|
|
90
90
|
# 权限解禁:完全权限 + 设置里那个开关,本轮把剩下的阻力也拿掉
|
|
@@ -95,7 +95,7 @@ class AgentLoopStage(Stage):
|
|
|
95
95
|
from core import unlock
|
|
96
96
|
unlock.pin(ctx.session_id)
|
|
97
97
|
except Exception as _ul_exc: # noqa: BLE001
|
|
98
|
-
print(f"[unlock]
|
|
98
|
+
print(f"[unlock] cannot pin unlock state (this turn treated as NOT unlocked): "
|
|
99
99
|
f"{type(_ul_exc).__name__}: {_ul_exc}")
|
|
100
100
|
|
|
101
101
|
# ── 这一轮的所有代价旋钮都来自投入档
|
|
@@ -115,8 +115,8 @@ class AgentLoopStage(Stage):
|
|
|
115
115
|
# 免得有人改了却看不到变化(静默忽略一个用户改过的键,比拒绝更坏)。
|
|
116
116
|
_cfg_cap = ctx.config.get("tool_result_max_chars")
|
|
117
117
|
if _cfg_cap is not None and int(_cfg_cap) != tool_result_max_chars:
|
|
118
|
-
print(f"[tier] config.yaml
|
|
119
|
-
f"
|
|
118
|
+
print(f"[tier] config.yaml tool_result_max_chars={_cfg_cap} no longer takes effect - "
|
|
119
|
+
f"tier {spec.level} gives {tool_result_max_chars}")
|
|
120
120
|
|
|
121
121
|
max_turns = spec.max_turns
|
|
122
122
|
# 流式开关
|
|
@@ -146,7 +146,7 @@ class AgentLoopStage(Stage):
|
|
|
146
146
|
ctx.messages = ctx.session_pool.maybe_trim_cold_window(
|
|
147
147
|
session_key_of_ctx(ctx), ctx.messages)
|
|
148
148
|
except Exception as _win_exc: # noqa: BLE001
|
|
149
|
-
print(f"[memory]
|
|
149
|
+
print(f"[memory] cold-window trim check failed (not trimming this turn): "
|
|
150
150
|
f"{type(_win_exc).__name__}: {_win_exc}")
|
|
151
151
|
|
|
152
152
|
# 日期变化时往消息流补一条
|
|
@@ -165,9 +165,9 @@ class AgentLoopStage(Stage):
|
|
|
165
165
|
if _date_note:
|
|
166
166
|
ctx.messages.append({"role": "user", "content": _date_note,
|
|
167
167
|
"kind": "date_change"})
|
|
168
|
-
print(f"[date]
|
|
168
|
+
print(f"[date] crossed midnight - appended one message ({ctx.session_id})")
|
|
169
169
|
except Exception as _date_exc: # noqa: BLE001
|
|
170
|
-
print(f"[date]
|
|
170
|
+
print(f"[date] date check failed (no append this turn): "
|
|
171
171
|
f"{type(_date_exc).__name__}: {_date_exc}")
|
|
172
172
|
|
|
173
173
|
# 审批回答 = 把那次挂起调用的结果补上
|
|
@@ -223,7 +223,7 @@ class AgentLoopStage(Stage):
|
|
|
223
223
|
_emit=make_emitter(ctx.events, session_key_of_ctx(ctx)),
|
|
224
224
|
)
|
|
225
225
|
except Exception as _rp_exc: # noqa: BLE001
|
|
226
|
-
print(f"[approval]
|
|
226
|
+
print(f"[approval] replay failed (falling back to old receipt): "
|
|
227
227
|
f"{type(_rp_exc).__name__}: {_rp_exc}")
|
|
228
228
|
_replay_ok = False
|
|
229
229
|
# 结算结论照发:卡片要说的是"用户做了什么决定",
|
|
@@ -256,7 +256,7 @@ class AgentLoopStage(Stage):
|
|
|
256
256
|
try:
|
|
257
257
|
compacted, done = pool.compact(session_key_of_ctx(ctx), _msgs)
|
|
258
258
|
except Exception as _cexc: # noqa: BLE001
|
|
259
|
-
print(f"[compact]
|
|
259
|
+
print(f"[compact] over-length rescue failed (compression raised): "
|
|
260
260
|
f"{type(_cexc).__name__}: {_cexc}")
|
|
261
261
|
return False
|
|
262
262
|
if not done:
|
|
@@ -279,7 +279,7 @@ class AgentLoopStage(Stage):
|
|
|
279
279
|
# 一行日志,说明这一轮走的是哪条路。
|
|
280
280
|
# 没有它,两条路在日志里长得一模一样,"流式开着却看不到逐字输出"
|
|
281
281
|
# 只能靠间接证据推断。一行能说清的事,不许留着不出声。
|
|
282
|
-
print("[stream]
|
|
282
|
+
print("[stream] this turn uses streaming (settings.stream_output=true)")
|
|
283
283
|
# 走流式路径 —— 累积所有产出的状态,以最后一个作为结果
|
|
284
284
|
final_state = None
|
|
285
285
|
async for state in agent_loop_stream(
|
|
@@ -440,7 +440,7 @@ def _persist_replay(ctx) -> None:
|
|
|
440
440
|
try:
|
|
441
441
|
mm.repersist_messages(ctx.storage_id, ctx.messages)
|
|
442
442
|
except Exception as exc: # noqa: BLE001
|
|
443
|
-
print(f"[approval]
|
|
443
|
+
print(f"[approval] failed to persist replay result (next turn will read the old payload): "
|
|
444
444
|
f"{type(exc).__name__}: {exc}")
|
|
445
445
|
|
|
446
446
|
|
|
@@ -485,8 +485,8 @@ def apply_llm_error_mark(ctx) -> bool:
|
|
|
485
485
|
ctx.metadata["llm_error"] = True
|
|
486
486
|
return True
|
|
487
487
|
except Exception as exc: # noqa: BLE001
|
|
488
|
-
print(f"[llm]
|
|
489
|
-
f"
|
|
488
|
+
print(f"[llm] error-marker handling failed ({type(exc).__name__}: {exc})"
|
|
489
|
+
f" - continuing as a normal reply this turn")
|
|
490
490
|
return False
|
|
491
491
|
|
|
492
492
|
|
|
@@ -503,7 +503,8 @@ def _note_pending_call(pend: dict, msgs: list, tool_msg_index: int) -> None:
|
|
|
503
503
|
#: `scheduler._PENDING_STORES` 是同一个集合(后两张表分别用于结算与持久化)。
|
|
504
504
|
_PENDING_STORE_ATTRS = (
|
|
505
505
|
"pending_cross_zone", "pending_delete", "pending_delete_bulk",
|
|
506
|
-
"pending_egress", "
|
|
506
|
+
"pending_egress", "pending_ssh_hostkey", "pending_command",
|
|
507
|
+
"pending_destructive", "pending_plan",
|
|
507
508
|
# 提问面板(也由"没人会回答"的收尾逻辑覆盖)。
|
|
508
509
|
"pending_ask",
|
|
509
510
|
# 工作区之外写文件。
|
|
@@ -636,7 +637,7 @@ def _emit_neutralized(ctx, msgs: list, idxs: list) -> None:
|
|
|
636
637
|
bus.emit(EVT_TOOL_NEUTRALIZED, session_key=key,
|
|
637
638
|
tool=str(_name or ""))
|
|
638
639
|
except Exception as exc: # noqa: BLE001 — 观测不许弄挂这一轮
|
|
639
|
-
print(f"[approval]
|
|
640
|
+
print(f"[approval] cannot emit neutralization event ({type(exc).__name__}: {exc})")
|
|
640
641
|
|
|
641
642
|
|
|
642
643
|
def _check_cross_zone_pending(ctx: StageContext,
|
|
@@ -792,6 +793,26 @@ def _check_cross_zone_pending(ctx: StageContext,
|
|
|
792
793
|
ctx.approval_ask_counts.get(kind, 0)) + 1
|
|
793
794
|
_armed_idx = _i
|
|
794
795
|
break
|
|
796
|
+
# SSH 主机密钥信任(TOFU)- 自己一格(一格只许一个 kind 用)。
|
|
797
|
+
# 载荷带 host_key_line(known_hosts 格式):结算器要原样存下来,
|
|
798
|
+
# 重放那次调用时连接才能过严格主机密钥校验。
|
|
799
|
+
if data.get("status") == "pending_ssh_hostkey_approval":
|
|
800
|
+
pend = ctx.pending_ssh_hostkey
|
|
801
|
+
pend["active"] = True
|
|
802
|
+
pend["stage"] = "ask"
|
|
803
|
+
pend["kind"] = "ssh_hostkey"
|
|
804
|
+
pend["subject"] = data.get("subject", "")
|
|
805
|
+
pend["host_key_line"] = data.get("host_key_line", "")
|
|
806
|
+
pend["fingerprint"] = data.get("fingerprint", "")
|
|
807
|
+
pend["detail"] = data.get("detail", "")
|
|
808
|
+
pend["body"] = data.get("body", "")
|
|
809
|
+
pend["request_id"] = new_request_id("ssh_hostkey")
|
|
810
|
+
_note_pending_call(pend, msgs, _i)
|
|
811
|
+
prompt = data.get("prompt", "")
|
|
812
|
+
if prompt and not _is_web(ctx):
|
|
813
|
+
ctx.response = prompt
|
|
814
|
+
_armed_idx = _i
|
|
815
|
+
break
|
|
795
816
|
# Delete approval
|
|
796
817
|
if data.get("status") == "pending_delete_approval":
|
|
797
818
|
# 两个 kind 各有自己的格(`delete` / `delete_bulk`)。
|
|
@@ -42,22 +42,10 @@ def _log(msg: str) -> None:
|
|
|
42
42
|
print("[group] " + msg)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
#: 上 wire 的字段白名单。 `kind` / `speaker` / `avatar` 是我们给界面看的,
|
|
46
|
-
#: 不是给上游 API 的 —— 严格一点的 OpenAI 兼容端点会对未知消息字段报错。
|
|
47
|
-
#: `tool_calls` / `tool_call_id` / `reasoning_content` 必须留(它们是协议/思考回传)。
|
|
48
|
-
_WIRE_FIELDS = frozenset({
|
|
49
|
-
"role", "content", "tool_calls", "tool_call_id", "name", "reasoning_content",
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
|
|
53
45
|
def _wire_messages(messages: list[dict]) -> list[dict]:
|
|
54
|
-
"""历史副本 →
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if not isinstance(m, dict):
|
|
58
|
-
continue
|
|
59
|
-
out.append({k: v for k, v in m.items() if k in _WIRE_FIELDS})
|
|
60
|
-
return out
|
|
46
|
+
"""历史副本 → 四家成员同形的协议形状(判据在 `group_reply.normalize_history`)。"""
|
|
47
|
+
from core import group_reply as _gr
|
|
48
|
+
return _gr.normalize_history(messages)
|
|
61
49
|
|
|
62
50
|
|
|
63
51
|
@register_stage
|
|
@@ -171,6 +159,7 @@ class GroupReplyStage(Stage):
|
|
|
171
159
|
from core.tiers import current_spec
|
|
172
160
|
from core.prompt_assembler import assemble_system_prompt, model_name_of
|
|
173
161
|
from core.events import make_emitter
|
|
162
|
+
from core import model_profiles as _profiles
|
|
174
163
|
|
|
175
164
|
spec = current_spec(ctx.session_id)
|
|
176
165
|
active = get_active_tool_names(ctx.session_id)
|
|
@@ -229,8 +218,12 @@ class GroupReplyStage(Stage):
|
|
|
229
218
|
tool_result_max_chars=spec.tool_result_max_chars,
|
|
230
219
|
max_turns=spec.max_turns,
|
|
231
220
|
session_id=ctx.session_id,
|
|
232
|
-
_tools=schemas
|
|
233
|
-
|
|
221
|
+
_tools=(schemas if _profiles.accepts_tools(
|
|
222
|
+
str(getattr(item["provider"], "_provider_name", "") or ""),
|
|
223
|
+
model_name_of(item["provider"])) else []),
|
|
224
|
+
_tool_allowlist=(frozenset(allowed) if _profiles.accepts_tools(
|
|
225
|
+
str(getattr(item["provider"], "_provider_name", "") or ""),
|
|
226
|
+
model_name_of(item["provider"])) else frozenset()),
|
|
234
227
|
_system=system,
|
|
235
228
|
_emit=emit,
|
|
236
229
|
thinking=spec.thinking,
|
|
@@ -338,6 +331,9 @@ class GroupReplyStage(Stage):
|
|
|
338
331
|
"kind": "group_speaker",
|
|
339
332
|
"speaker": r["name"],
|
|
340
333
|
"avatar": r["avatar"],
|
|
334
|
+
# 记下是哪个模型说的:换模型后回看这段历史,
|
|
335
|
+
# 才知道 reasoning / 工具形状来自哪一家。
|
|
336
|
+
"model": str(r.get("model") or ""),
|
|
341
337
|
}
|
|
342
338
|
# 成员自己的产物挂在自己的回复上(没有就不设键 ——
|
|
343
339
|
# 读不到 ≠ 空)。落库走 `extra_json`,刷新后照样在。
|
|
@@ -375,6 +371,7 @@ class GroupReplyStage(Stage):
|
|
|
375
371
|
② 自动接力 —— 下一位由一次小 LLM 调用决定;
|
|
376
372
|
③ `@点名` = 只让被点的人说(显式控制,不接力)。
|
|
377
373
|
"""
|
|
374
|
+
from core import model_profiles as _profiles
|
|
378
375
|
from core import group_digest, group_reply
|
|
379
376
|
from core.session_key import session_key_of_ctx
|
|
380
377
|
from core.group_dispatch import ensure_provider
|
|
@@ -502,8 +499,12 @@ class GroupReplyStage(Stage):
|
|
|
502
499
|
tool_result_max_chars=spec.tool_result_max_chars,
|
|
503
500
|
max_turns=spec.max_turns,
|
|
504
501
|
session_id=ctx.session_id,
|
|
505
|
-
_tools=schemas
|
|
506
|
-
|
|
502
|
+
_tools=(schemas if _profiles.accepts_tools(
|
|
503
|
+
str(getattr(prov, "_provider_name", "") or ""),
|
|
504
|
+
model_name_of(prov)) else []),
|
|
505
|
+
_tool_allowlist=(frozenset(allowed) if _profiles.accepts_tools(
|
|
506
|
+
str(getattr(prov, "_provider_name", "") or ""),
|
|
507
|
+
model_name_of(prov)) else frozenset()),
|
|
507
508
|
_system=system,
|
|
508
509
|
_emit=emit,
|
|
509
510
|
thinking=spec.thinking,
|
|
@@ -566,7 +567,8 @@ class GroupReplyStage(Stage):
|
|
|
566
567
|
msg = {"role": "assistant",
|
|
567
568
|
"content": group_reply.member_reply_content(r["name"], r["content"]),
|
|
568
569
|
"kind": "group_speaker", "speaker": r["name"],
|
|
569
|
-
"avatar": r["avatar"]
|
|
570
|
+
"avatar": r["avatar"],
|
|
571
|
+
"model": str(r.get("model") or "")}
|
|
570
572
|
if r.get("artifacts"):
|
|
571
573
|
msg["artifacts"] = r["artifacts"]
|
|
572
574
|
ctx.messages.append(msg)
|
|
@@ -80,10 +80,10 @@ class PostProcessStage(Stage):
|
|
|
80
80
|
if ctx.model_config_id:
|
|
81
81
|
from core import session_model
|
|
82
82
|
if session_model.freeze(session_key, ctx.model_config_id):
|
|
83
|
-
print(f"[session_model]
|
|
84
|
-
f"'{ctx.model_config_id}'
|
|
83
|
+
print(f"[session_model] this conversation frozen to config "
|
|
84
|
+
f"'{ctx.model_config_id}' - later default changes won't affect it")
|
|
85
85
|
except Exception as exc: # noqa: BLE001
|
|
86
|
-
print(f"[session_model]
|
|
86
|
+
print(f"[session_model] freeze failed (this conversation follows the default): "
|
|
87
87
|
f"{type(exc).__name__}: {exc}")
|
|
88
88
|
|
|
89
89
|
if compressed is not None and compressed is not ctx.messages:
|
|
@@ -110,8 +110,8 @@ class PostProcessStage(Stage):
|
|
|
110
110
|
from core.plan import note_compressed
|
|
111
111
|
note_compressed(ctx.session_id)
|
|
112
112
|
except Exception as exc: # noqa: BLE001
|
|
113
|
-
print(f"[plan_reminder]
|
|
114
|
-
f"
|
|
113
|
+
print(f"[plan_reminder] failed to mark compressed ({type(exc).__name__}: {exc})"
|
|
114
|
+
f" - this conversation won't resend the plan-mode reminder")
|
|
115
115
|
# Keep pool cache in sync with potentially compressed messages
|
|
116
116
|
if session_key in pool._loaded:
|
|
117
117
|
sid = pool._loaded[session_key][0]
|
|
@@ -135,7 +135,7 @@ class PostProcessStage(Stage):
|
|
|
135
135
|
ctx.metadata["dedup_done"] = True
|
|
136
136
|
except Exception as exc: # noqa: BLE001
|
|
137
137
|
# 不阻断对话,但不许静默:落不了账的后果是"重投时再答一遍"。
|
|
138
|
-
print(f"[dedup]
|
|
139
|
-
f"
|
|
138
|
+
print(f"[dedup] failed to record ({type(exc).__name__}: {exc})"
|
|
139
|
+
f" - a redelivery of this message may be answered again")
|
|
140
140
|
|
|
141
141
|
return ctx
|