| 1 | from agent import AgentContext |
| 2 | from helpers.api import ApiHandler, Input, Output, Request, Response |
| 3 | from helpers import message_queue as mq |
| 4 | |
| 5 | |
| 6 | class PluginScanQueue(ApiHandler): |
| 7 | """Log the scan prompt into a chat before the scan starts.""" |
| 8 | |
| 9 | async def process(self, input: Input, request: Request) -> Output: |
| 10 | ctxid: str = input.get("context", "") |
| 11 | text: str = input.get("text", "") |
| 12 | |
| 13 | if not ctxid or not text: |
| 14 | return Response("Missing 'context' or 'text'.", 400) |
| 15 | |
| 16 | context = AgentContext.get(ctxid) |
| 17 | if context is None: |
| 18 | return Response(f"Context {ctxid} not found.", 404) |
| 19 | |
| 20 | mq.log_user_message(context, text, []) |
| 21 | |
| 22 | return {"ok": True, "context": ctxid} |