from cosmon_agent_sdk import Client, Confirmation, Question, TextChunk, ToolCall
def answer(q: Question) -> str:
return input(f"{q.prompt} {q.options or ''}\n> ")
def approve(c: Confirmation) -> bool:
return input(f"{c.summary} [y/N] ").strip().lower() == "y"
with Client(on_question=answer, on_confirm=approve) as client:
with client.session(agent="nexus") as chat: # one conversation across turns
while (prompt := input("\nyou> ").strip()) not in ("/quit", ""):
for event in chat.run(prompt):
if isinstance(event, TextChunk):
print(event.text, end="", flush=True)
elif isinstance(event, ToolCall) and not event.finished:
print(f"\n▶ {event.summary}")