|
|
@@ -1856,16 +1856,16 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
)
|
|
|
|
|
|
if is_clarify:
|
|
|
+ from tools import clarify_gateway # type: ignore[import-not-found]
|
|
|
+
|
|
|
number_emojis = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]
|
|
|
other_emoji = "✏️"
|
|
|
choices = list(getattr(prompt, "choices", []) or [])
|
|
|
|
|
|
if emoji == other_emoji:
|
|
|
- setattr(prompt, "awaiting_text", True)
|
|
|
+ prompt.awaiting_text = True # type: ignore[assignment]
|
|
|
try:
|
|
|
- import tools.clarify_gateway as clarify_gateway
|
|
|
-
|
|
|
- clarify_gateway.mark_awaiting_text(getattr(prompt, "clarify_id"))
|
|
|
+ clarify_gateway.mark_awaiting_text(prompt.clarify_id) # type: ignore[attr-defined]
|
|
|
except Exception:
|
|
|
logger.debug("Chatto: mark_awaiting_text failed", exc_info=True)
|
|
|
try:
|
|
|
@@ -1882,14 +1882,12 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
choice = choices[idx]
|
|
|
prompt.resolved = True
|
|
|
self._clarify_prompts.pop(message_id, None)
|
|
|
- cid = getattr(prompt, "clarify_id", None)
|
|
|
+ cid = getattr(prompt, "clarify_id", None) # type: ignore[arg-type]
|
|
|
if cid is not None:
|
|
|
self._clarify_id_to_message.pop(cid, None)
|
|
|
try:
|
|
|
- import tools.clarify_gateway as clarify_gateway
|
|
|
-
|
|
|
clarify_gateway.resolve_gateway_clarify(
|
|
|
- getattr(prompt, "clarify_id"), choice
|
|
|
+ str(cid), choice
|
|
|
)
|
|
|
except Exception:
|
|
|
logger.exception("Chatto: resolve_gateway_clarify failed")
|
|
|
@@ -3018,6 +3016,31 @@ class ChattoAdapter(BasePlatformAdapter):
|
|
|
|
|
|
return SendResult(success=True, message_id=message_id)
|
|
|
|
|
|
+ async def retire_clarify_card(self, clarify_id: str, notice: str) -> None:
|
|
|
+ """Rewrite a still-live clarify card into a terminal, button-less state.
|
|
|
+
|
|
|
+ The gateway calls this whenever it ends a clarify without a click — the
|
|
|
+ wait timed out, the session was reset, or unmatched free prose superseded
|
|
|
+ the prompt — so the card stops advertising an answer path the released
|
|
|
+ clarify can no longer accept. Keyed by ``clarify_id``, so a late call
|
|
|
+ cannot touch a newer prompt; no-op once resolved.
|
|
|
+
|
|
|
+ BasePlatformAdapter override
|
|
|
+ """
|
|
|
+ message_id = self._clarify_id_to_message.pop(clarify_id, None)
|
|
|
+ if message_id is None:
|
|
|
+ return
|
|
|
+ prompt = self._clarify_prompts.get(message_id)
|
|
|
+ if prompt is None:
|
|
|
+ return
|
|
|
+ prompt.resolved = True
|
|
|
+ terminal = f"❌ {notice}"
|
|
|
+ try:
|
|
|
+ await self.edit_message(prompt.chat_id, message_id, terminal)
|
|
|
+ except Exception:
|
|
|
+ logger.debug("Chatto: retire_clarify_card edit failed", exc_info=True)
|
|
|
+ self._clarify_prompts.pop(message_id, None)
|
|
|
+
|
|
|
async def _send_exec_approval_prompt(
|
|
|
self, prompt: ExecApprovalPrompt
|
|
|
) -> SendResult:
|