Reacting to events
Cmdop inverts the usual webhook: instead of calling your endpoint, you arm the machine to watch for a condition — a file change, a repository change, a time — and act when it becomes true. The machine already sits next to the thing you care about. To observe rather than react, stream the agent’s output directly.
Cmdop turns this around from what you may expect. Rather than Cmdop calling out to your endpoint, you arm the machine to watch for a condition and act when it becomes true. The machine already sits next to the thing you care about — the file, the repository, the service — so it is the better place to notice.
Arm a watch
Ask for it in an ordinary request, the same way you would schedule work:
await client.machines.ask(
machine_id,
"Watch the deploy log for a failure line, and when one appears "
"summarize the last 50 lines and tell me which service it was.",
).collect()A watch can fire on a time, on an event — a file change, a repository change, a signal arriving from elsewhere — or on a combination of those, so “when A and B are both true” is one watch rather than glue code you maintain.
When it fires, it runs as a fresh turn in its session, exactly like a schedule does. Ask in the same conversation to list a session’s watches or delete one.
Watches are per session and depend on the machine’s agent running, with the same caveats as Schedules.
Consume events from your own code
To observe rather than react, take the stream directly. machines.ask() yields
frames as the agent works, so a program can act on progress instead of waiting
for the end:
async for frame in client.machines.ask(machine_id, "Run the migration."):
if frame.type == "event":
handle(frame.payload)
elif frame.type == "done":
report(frame.success, frame.text)See Streaming for the frame types and error handling.
For anything that happened while your process was not attached, read the session’s durable history instead of trying to keep a connection alive — see Sessions.
Push into a chat instead
If the destination is a human rather than a program, a messenger bot is the shipped path: results arrive in Telegram, Slack, or Discord. Set it up under Server → Bots in the web console.
Related
Common questions
Does Cmdop call my webhook endpoint?
No. Cmdop’s event model is inverted: you arm a machine to watch for a condition near the files, repository, or service it owns, and it acts when that condition becomes true.
How do I react to agent progress from code?
Stream machines.ask() and handle frames as they arrive. Use the durable
session history for anything that happened while your process was not attached.
Are watches global?
No. Watches belong to the session that created them and depend on the machine’s agent running, with the same operational caveats as schedules.