Skip to main content

Module drone_handlers

Module drone_handlers 

Source
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§

DeleteDroneReq
DeleteResp
GetDroneReq
ListDronesReq
Request for listdrones, which ignores its payload.
ListRunsReq
ResolveRunReq
What resolvedronerun is asked to do with a run that needs attention.
ResolveRunResp
ResumeWaitReq
What resumedronewait brings to a run waiting on an event.
ResumeWaitResp
RunDroneReq
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::MAX and 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 🔒
deletedrone with 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 running placeholder row synchronously BEFORE returning. Guarantees:
launch_loaded 🔒
launch_run for a drone already loaded: it runs exactly this definition.
launch_run 🔒
Start a run of drone_id with trigger as its input. With a job_run_id the ledger row is that job run’s; without one the run gets a manual row of its own, started by by_agent when 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_attention with the reason when a step needs an answer, waiting at a Wait block, running again 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 is agent:<id> (so no agent id can read as operator), 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 resolvedronerun takes 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 a skip would give the step.
resume_drone_wait_as 🔒
resumedronewait with 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 rundrone call 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 Drone fire: the ledger row says which agent did it (by_agent is the agent’s id), as agent:<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 🔒
rundrone with the run’s starter named: by is who the ledger row says started it, None for the person’s window (the operator). The registered handler takes it from the connection.
start_job_drone_run 🔒
Start the run a job’s drone action asks for. job_run_id is the job run’s row in the ledger, which runs until the drone does; run_cap_usd is 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 🔒
upsertdrone for 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 as saved_by, which the registered handler takes from the connection (an agent’s drone is shown as that agent’s).