Hồi quy đã vá
-------------
F-12 Kéo–thả hoặc dán tệp vào ô chat ném NameError. R08 tách `_Input` sang
`chat_input_box.py` nhưng để `_paths_from_mime()` ở lại
`composer_widget.py`, nên hai hàm sự kiện Qt gọi một cái tên không tồn
tại. Bốn hàm dùng chung chuyển sang `composer_mime.py` — module thứ ba
là chỗ duy nhất không lặp lại được lỗi này. Đo lại: cả thả lẫn dán đều
gắn 1 tệp, khớp bản trước refactor.
F-01 Đổi provider thì bộ chọn model AI-Edit không làm gì. Hook cũ kiểm
`folder.ai_model_combo`, thuộc tính R08-T12 đã dời sang
`ai_panel.resolver`. Làm mới vô điều kiện, đúng như tab cũ: lần lấy đầu
tiên hỏng thì đổi provider chính là lúc phải thử lại.
F-07 Hàng chọn kỳ của Dashboard bị đẩy xuống dưới các thẻ số liệu. Hàng này
lọc CẢ BA thẻ con chứ không riêng biểu đồ, nên để nó nằm dưới là bắt
người dùng đọc con số trước khi thấy con số đó tính cho kỳ nào. Kèm
theo: `TokenUsageCardWidget` bị bỏ sót `setContentsMargins(0,0,0,0)`
mà hai thẻ con còn lại đã có, đẩy cả hàng thẻ lệch 9px.
`check_layout_geometry` nay khớp TỪNG BYTE với bản trước refactor.
F-11 Hai lớp khai trùng tên phương thức; Python giữ bản sau nên bản đầu là
mã chết. `co4e_tab.py::showEvent` bản đầu gọi `_narrow_guard.attach()`
và không bao giờ chạy.
Tách file (F-09)
----------------
Bốn file chạm trần 400 dòng, mỗi lần cắt ra một trách nhiệm thật:
graph_renderer.py -> graph_scene_builder.py + graph_export.py
co4e_workflow_service.py -> co4e_run_history.py
json_config_repository.py -> config_sections.py
agents_admin_tab.py -> shared/agent_kind_visuals.py
File cuối còn xoá 3 bản sao của hàm đã có trong `shared/formatters.py`,
giống hệt đến từng dòng — nay định dạng thời gian và avatar không lệch nhau
giữa các bảng Giám sát nữa.
Docstring
---------
41,6% -> 100% (3.478/3.478 định nghĩa production), kể cả module dormant và
phương thức dunder. Toàn bộ phần bổ sung viết bằng tiếng Việt; comment tiếng
Anh có sẵn giữ nguyên — dịch ngược là một đợt riêng.
Seam chưa nối dây (F-05)
------------------------
9 seam mang nhãn `SEAM · dựng <ngày>` kèm hai câu: được nối khi nào, và để
dormant thì hỏng gì. Ngày lấy từ lịch sử git, không phải hạn tự đặt. Gate O
đọc nhãn đó và nhắc khi quá 30 ngày.
859 test xanh · 4/4 cổng CASAN · 19/24 checker khớp từng byte bản cũ.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
68 lines
3.0 KiB
Python
68 lines
3.0 KiB
Python
"""🤖 Agent Core — role registry.
|
|
|
|
Cowork Local runs one engine per surface (Cowork tab, Schedule Task,
|
|
GraphRAG codebase-memory chat) rather than a hand-off pipeline between
|
|
separate agent processes. This registry gives each already-existing
|
|
behavior one of the reference role names, purely so audit-log entries
|
|
and the Monitoring Dashboard can group activity by role — it introduces
|
|
no new orchestration logic.
|
|
|
|
PLANNER — the ``update_plan`` tool call inside ``chat_agent.run_cowork``'s
|
|
loop.
|
|
REASONING — the model's streamed ``on_reasoning`` output (chat_agent /
|
|
code_agent). Deliberately NOT written to the audit log (that
|
|
would be one entry per streamed token) — the Monitoring
|
|
Dashboard's Agent Status panel instead reads live AgentWorker
|
|
state, which already reflects a run in progress.
|
|
CODE — ``code_agent.run_code``'s tool-execution loop.
|
|
KNOWLEDGE — GraphRAG's codebase-memory "Ask" (``_ask`` in
|
|
``structure_graph_view.py``).
|
|
TASK — Schedule Task's unattended ``_run_agent`` loop.
|
|
COWORK — the Cowork tab's own interactive tool-use loop — the same
|
|
engine TASK's ``cowork``-type tasks run, but ``run_cowork``'s
|
|
default role when no override is given.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Dict, NamedTuple
|
|
|
|
PLANNER = "planner"
|
|
REASONING = "reasoning"
|
|
CODE = "code"
|
|
KNOWLEDGE = "knowledge"
|
|
TASK = "task"
|
|
COWORK = "cowork"
|
|
SECURITY = "security"
|
|
HELP = "help"
|
|
|
|
|
|
class AgentRole(NamedTuple):
|
|
"""Một vai trò agent: khoá, nhãn hiển thị và prompt mặc định."""
|
|
key: str
|
|
label: str
|
|
description: str
|
|
|
|
|
|
ROLES: Dict[str, AgentRole] = {
|
|
PLANNER: AgentRole(PLANNER, "Planner Agent", "Builds/updates the step plan (update_plan)."),
|
|
REASONING: AgentRole(REASONING, "Reasoning Agent", "The model's streamed reasoning output."),
|
|
CODE: AgentRole(CODE, "Code Agent", "Sandboxed run_code tool-execution loop."),
|
|
KNOWLEDGE: AgentRole(KNOWLEDGE, "Knowledge Agent", "GraphRAG codebase-memory Ask / feature management."),
|
|
TASK: AgentRole(TASK, "Task Agent", "Schedule Task's unattended run."),
|
|
COWORK: AgentRole(COWORK, "Cowork Agent", "The Cowork tab's interactive tool-use loop."),
|
|
SECURITY: AgentRole(SECURITY, "Security Agent",
|
|
"System-management agent: Agent Security's prompt/attachment/command "
|
|
"validation (core/agent_security.py). Runs inline on the active turn's "
|
|
"provider before a request/command is allowed."),
|
|
HELP: AgentRole(HELP, "Help Agent",
|
|
"The floating in-app assistant (ui/help_agent_widget.py): answers "
|
|
"how-to-use-the-app questions only, no tools, replies in the user's "
|
|
"own language."),
|
|
}
|
|
|
|
|
|
def label_for(role_key: str) -> str:
|
|
"""Nhãn của một vai trò; khoá lạ thì trả về chính khoá, rỗng thì trả về "—"."""
|
|
role = ROLES.get(role_key)
|
|
return role.label if role else (role_key or "—")
|