import json
from pathlib import Path
p=Path("C:/Solutions/foster/hermes-home/profiles/michel/webhook_subscriptions.json")
data=json.loads(p.read_text(encoding="utf-8"))
s=data["ask-michel"]
s["prompt"]="""Foster has delegated an MCSJ support question to Michel.
Request ID: {request_id}
Question: {question}
Context: {context}
Disputed candidates: {candidates}
Screenshot requested: {need_screenshot}
Origin platform: {origin.platform}
Origin chat: {origin.chat_id}
Origin thread: {origin.thread_id}
Origin message: {origin.message_id}

Act now as Michel, Foster's Windows MCSJ backline. Search C:/Solutions/michel/knowledge/foster first and load the relevant MCSJ skills. For exact paths or labels, do not guess. If needed and available, inspect the local chestervillagenydb demo read-only unless the request explicitly authorizes a demo write. If a screenshot is requested, reuse an authentic cached/source image first, otherwise capture the demo.

MANDATORY RETURN CONTRACT:
1. Draft the concise, Telegram-ready final answer in UTF-8 at C:/MCSJAgent/foster-ask-michel/work/{request_id}.txt. Include confirmed answer/path, source or demo status, caveats, confidence, and public HTTPS proof URLs when available. Do not put secrets in this file.
2. Before your final response, run:
python C:/MCSJAgent/foster-ask-michel/publish_result.py --request-id {request_id} --answer-file C:/MCSJAgent/foster-ask-michel/work/{request_id}.txt --confidence high
Use medium/low confidence as appropriate. Add each public proof URL with --proof URL and caveats with --caveat TEXT.
3. Verify the publisher returns ok=true. Your final response must match the published answer. Never finish without publishing a completed or failed result keyed by this request ID.

State that this is a Foster delegation and include request ID {request_id}."""
tmp=p.with_suffix(".json.tmp")
tmp.write_text(json.dumps(data,ensure_ascii=False,indent=2)+"\n",encoding="utf-8")
tmp.replace(p)
print(json.dumps({"ok":True,"subscription":"ask-michel","secret_preserved":bool(s.get("secret")),"prompt_chars":len(s["prompt"])}))
