本卡屬 FR-181(母卡 FR-181 母案(同清單上一張)),卡 F-1,批 2。只改 jedi-python-package。依賴:無。
主系統和 Agent 之間講話的「格式」都定在 jedi-agent-protocol 這個套件裡(路徑、欄位名、回應長什麼樣),兩邊各自 import,才不會一邊改了另一邊不知道。本案新增三個路徑(Agent 來取指令、Agent 回覆結果、Agent 來拿主系統暫存的檔)和兩種信封(指令、回覆),以及十三種「指令類型」常數(派工、重啟、升級、設定變了、換證、取消檢測、測試連線、存帳密、取檔、送檔、送 PDF、刪檔、查日誌)。原本直推用的路徑常數不刪(決策者裁直推程式留著用開關關),只在檔頭註解改成「直推預設關、長輪詢是主路徑」。這張卡是登記型檔的 owner:後面所有卡只 import、不改這個檔。做完要發版 0.3.0 推 Nexus。
extend:commands.py 加 COMMANDS_PATH="/agents/commands"、REPLIES_PATH="/agents/replies/{request_id}"、FILES_PATH="/agents/files/{request_id}"、WAIT_PARAM、COMMANDS_LIMIT=20;加 Command 信封 dataclass(kind/request_id/task_uid/payload/expires_at)與 CommandsResponse(commands: list/server_time_utc);加 Reply dataclass(status: taken|done|failed/result/reason);加 KIND_* 十三個常數(task/restart/update/config_changed/credentials_renew/detection_cancel/probe/credentials_set/fetch_file/send_file/send_pdf/delete_file/query_logs)+ REPLY_KINDS(要回答的那七個)。既有直推路徑常數(TASKS/RESTART/…)與 body dataclass 不刪(D6:直推留著用開關關),檔頭註解改成「直推預設關,長輪詢是主路徑」。__init__.py 匯出。登記型檔 owner:後面所有卡只 import 不改。發版 0.3.0 推 Nexus
repo:~/Projects/Jedicogy/module/jedi-python-package
改既有:jedi-agent-protocol/jedi_agent_protocol/commands.py
改既有:jedi-agent-protocol/jedi_agent_protocol/__init__.py
改既有:jedi-agent-protocol/pyproject.toml(0.3.0)
新開:jedi-agent-protocol/tests/test_longpoll_contract.py
jedi_agent_protocol/commands.py:加路徑常數 COMMANDS_PATH = "/agents/commands"、REPLIES_PATH = "/agents/replies/{request_id}"、FILES_PATH = "/agents/files/{request_id}"、WAIT_PARAM = "wait"、WAIT_MAX_SEC = 30、COMMANDS_LIMIT = 20。KIND_*(task/restart/update/config_changed/credentials_renew/detection_cancel/probe/credentials_set/fetch_file/send_file/send_pdf/delete_file/query_logs)+ ALL_KINDS frozenset + REPLY_KINDS(probe/credentials_set/fetch_file/send_file/send_pdf/query_logs 六個要回答的;delete_file 不回答)。TaskCommand 的 from_dict/to_dict 寫法):Command(kind, payload: dict, request_id: str|None, task_uid: str|None, expires_at: str|None)——from_dict 缺 kind 或不在 ALL_KINDS 拋 ValueError;CommandsResponse(commands: list[Command], server_time_utc: str);Reply(status: str, result: dict|None, reason: str|None),status 只准 taken/done/failed。TASKS/RESTART/…直推路徑常數與 body dataclass 不刪;檔頭 docstring 改:「直推(主系統→Agent 8443)預設關閉、留作未來可開;長輪詢 COMMANDS_PATH 是主路徑」。__init__.py 匯出新名。tests/test_longpoll_contract.py:十三個 kind 不重複;REPLY_KINDS ⊂ ALL_KINDS;Command.from_dict({}) 拋 ValueError;CommandsResponse 往返相等;Reply(status="bogus") 拋。pyproject.toml bump 0.3.0;套件 venv 跑全部 tests;poetry publish -r nexus;回寫版號與「F-2/F-3/E-1 要升」。pytest:十三個 KIND_* 不重複、REPLY_KINDS ⊂ 全部 kind、Command.from_dict 缺 kind 拋 ValueError、CommandsResponse 往返相等;poetry publish -r nexus 0.3.0 成功,回寫版號
~/Projects/Billows/Audit-Manager/compliance-manager-be/docs/features/FR-181-2611-agent-outbound-only-channel/design.md §3 決策定案(D1~D8)、§4 端到端流程兩張圖、§5 詳細設計本卡那節、§7 拆分表本卡那列;為什麼這樣定看 discussion.mdcore/plugins/_agent_commands.py(檔頭說明三個觸發點)、app/remote_agent/service/agent_command_service.py、core/plugins/_agent_config_notify.py、core/plugins/_agent_keys.py、infra/upload_file/remote_agent_adapter.py、core/plugins/remote_agent.py(plugin mount 與 handle)jedi-remote-agent/jedi_remote_agent/api/routing.py(端點表與 AUTH_AGENT)、api/routes/(心跳 route 範本)、app/service/agent_data_plane_client.py(直推出口,留著)、app/service/heartbeat_vulndb.py(_CORE_KEYS 心跳守衛);契約 jedi-agent-protocol/jedi_agent_protocol/commands.py、heartbeat.py、events.py