Expand description
WSH RPC handlers for the Drone pane (issue #753 Phase 1).
Commands:
listdrones→Vec<DroneDefinition>getdrone→Option<DroneDefinition>upsertdrone→DroneDefinition(echoed back, normalized)deletedrone→{ deleted: bool }rundrone→{ run_id: String }(synchronous; SSE streaming added in Phase 1 PR-4)listdroneruns→Vec<DroneRun>
Run streaming: the executor emits RunEvents over an mpsc channel.
Phase 1 of this PR drains the channel server-side and stores the
final block-state snapshot in db_drone_runs. A future commit
will tee the channel to the renderer via the existing mps event
broker so RunPanel shows live per-block status.
Structs§
- Delete
Drone Req - Delete
Resp - GetDrone
Req - List
Drones Req - Request for
listdrones, which ignores its payload. - List
Runs Req - Resolve
RunReq - What
resolvedronerunis asked to do with a run that needs attention. - Resolve
RunResp - Resume
Wait Req - What
resumedronewaitbrings to a run waiting on an event. - Resume
Wait Resp - RunDrone
Req - RunResp
Constants§
- MAX_
INPUT_ 🔒BYTES - The most a run’s input may hold, as JSON. It lives in the run’s memory and the ledger keeps only its hash and size (real-world jobs spec D11).
- MAX_
LIST_ 🔒LIMIT - Hard cap on
ListRunsReq.limit— guards against a malicious or buggy client passing e.g.i64::MAXand pulling the entire run history (DoS / memory blow-up). 200 covers any plausible UI page size with headroom; Phase 2 pagination cursor work will move this to client-driven slicing. (kimi P1 on PR #755.)
Functions§
- default_
limit 🔒 - delete_
drone_ 🔒as deletedronewith who deleted it: the log line names the connection’s label (agent:<id>for an agent), never what the request says.- get_
drone 🔒 getdrone.- graph_
ref_ 🔒of - The graph a run starts on: its hash, and the number of the saved version that has it (the newest, when the definition has not changed since its save). A drone saved before versions existed, or one whose version could not be saved, has number 0; its hash still says which graph the run had.
- insert_
run_ 🔒placeholder - Persist a
runningplaceholder row synchronously BEFORE returning. Guarantees: - launch_
loaded 🔒 launch_runfor a drone already loaded: it runs exactly this definition.- launch_
run 🔒 - Start a run of
drone_idwithtriggeras its input. With ajob_run_idthe ledger row is that job run’s; without one the run gets amanualrow of its own, started byby_agentwhen an agent fired it, else the operator. - list_
drone_ 🔒runs listdroneruns.- list_
drones 🔒 listdrones: drone definitions live in the global shared store.- note_
attention 🔒 - A run’s row follows its wait:
needs_attentionwith the reason when a step needs an answer,waitingat a Wait block,runningagain once either is over. Any other event leaves the row alone. - recorded_
as 🔒 - Who the record names for a call, taken from the connection and never from the request: the person’s window
is
operator, an agent isagent:<id>(so no agent id can read asoperator), and a connection that is neither says what it is. - register_
drone_ handlers - resolve_
drone_ 🔒run resolvedronerun: answer a run that is waiting,needs_attention, for what to do with the step that was running when AgentMux stopped.- resolve_
drone_ 🔒run_ as - The answer to a step that waits for the person, as
resolvedroneruntakes it: from the person’s proven window only. An agent’s call, and a connection that has proved nothing, is refused whatever it carries, including the output askipwould give the step. - resume_
drone_ 🔒wait_ as resumedronewaitwith the caller named as the connection says (the log line names it): the key stays what guards the wait.- run_
allowed_ 🔒for - What an agent’s own
rundronecall may start: the drones the Drone tool may fire (nothing that writes outside AgentMux, reads a Vault credential, runs a command or calls another drone), so approving a credential or a write stays the person’s. The person’s window is not asked. A drone that does not exist is left for the run to report. - run_
started_ 🔒by - The starter a run’s ledger row names, when it is not the person’s window: that window is the ledger’s own default (the operator).
- spawn_
run_ 🔒drain - Drain a run’s events on a background task; on completion, UPDATE the placeholder row in place and close the run ledger’s row.
- start_
agent_ 🔒drone_ run - Start a run an agent fires with
Dronefire: the ledger row says which agent did it (by_agentis the agent’s id), asagent:<id>like every other path, so no agent id can read as the operator. - start_
drone_ 🔒run rundrone: reads the drone definition from id_store (global), writes the run rows to mstore (per-channel).- start_
drone_ 🔒run_ as rundronewith the run’s starter named:byis who the ledger row says started it,Nonefor the person’s window (the operator). The registered handler takes it from the connection.- start_
job_ 🔒drone_ run - Start the run a job’s
droneaction asks for.job_run_idis the job run’s row in the ledger, which runs until the drone does;run_cap_usdis the job’s per-run cap, which ends the run before its next block once its Agent blocks have spent it. Returns the Drone run’s id. - upsert_
drone 🔒 upsertdronefor a save the person’s own client makes, or one no caller asked for (a template installed on the person’s say): its version is the operator’s.- upsert_
drone_ 🔒as upsertdrone: stamps the times, mints an id for a new drone, and echoes the row back. The version is saved assaved_by, which the registered handler takes from the connection (an agent’s drone is shown as that agent’s).