pub struct Workbench { /* private fields */ }Expand description
The daemon’s workbench.
Implementations§
Source§impl Workbench
impl Workbench
Sourcepub fn new(layout: &Layout, delegations: Arc<DelegationRegistry>) -> Arc<Self> ⓘ
pub fn new(layout: &Layout, delegations: Arc<DelegationRegistry>) -> Arc<Self> ⓘ
The workbench of the instance at layout, whose delegated runs
delegations records.
Sourcepub fn register_session(
self: &Arc<Self>,
id: &str,
label: &str,
workspace: &Path,
) -> SessionHandle
pub fn register_session( self: &Arc<Self>, id: &str, label: &str, workspace: &Path, ) -> SessionHandle
Register a live session; label says who it serves.
Sourcepub fn watch(&self)
pub fn watch(&self)
The owner is watching: background approval requests wait for an
answer for the next WATCH_TTL.
Sourcepub fn attended_gate(
self: &Arc<Self>,
session: &str,
unattended: Arc<dyn ApprovalGate>,
) -> Arc<dyn ApprovalGate> ⓘ
pub fn attended_gate( self: &Arc<Self>, session: &str, unattended: Arc<dyn ApprovalGate>, ) -> Arc<dyn ApprovalGate> ⓘ
The approval gate for background jobs of session: unattended
decides, except that a request it would deny waits up to
ATTENDED_WAIT for the owner while the owner watches. It never
denies what unattended allows.
Sourcepub fn approve(&self, id: &str, approved: bool) -> Result<String, String>
pub fn approve(&self, id: &str, approved: bool) -> Result<String, String>
Answer approval request id.
Sourcepub fn snapshot(&self) -> WorkbenchSnapshot
pub fn snapshot(&self) -> WorkbenchSnapshot
Everything the workbench shows now. restorable is left for the
server, which keeps session queues.
Sourcepub fn check_worktree_unused(&self, path: &Path) -> Result<(), String>
pub fn check_worktree_unused(&self, path: &Path) -> Result<(), String>
Refuse to remove the worktree holding path while anything still
works in it (Self::worktree_users).
Sourcepub fn worktree_users(&self, path: &Path) -> Vec<String>
pub fn worktree_users(&self, path: &Path) -> Vec<String>
What still runs in the SCV worktree holding path (its top, or any
directory in it): jobs not yet finished that recorded it, and
delegated runs whose processes work inside it.
Sourcepub fn run_log(
&self,
handle: &str,
after: u64,
limit: usize,
) -> Result<RunLogPage, String>
pub fn run_log( &self, handle: &str, after: u64, limit: usize, ) -> Result<RunLogPage, String>
One page of run handle’s activity log after byte position after.
Sourcepub async fn send(
&self,
session: &str,
conversation: &str,
prompt: &str,
mode: SendMode,
) -> Result<Sent, String>
pub async fn send( &self, session: &str, conversation: &str, prompt: &str, mode: SendMode, ) -> Result<Sent, String>
Give conversation conversation of live session session the
owner’s prompt.
Sourcepub async fn deliver_to_job(
&self,
session: &str,
conversation: &str,
prompt: &str,
resume_from: Option<String>,
accepted_follow_up: Option<String>,
) -> Result<Sent, String>
pub async fn deliver_to_job( &self, session: &str, conversation: &str, prompt: &str, resume_from: Option<String>, accepted_follow_up: Option<String>, ) -> Result<Sent, String>
Give conversation conversation of live session session the owner’s
prompt, queued behind a running turn. When resume_from is
<session>/<job>, the new job’s record links back and that job records
resumed_as. A prompt that went into a running turn writes no link,
because no new job started.
Sourcepub async fn start(
&self,
session: &str,
arguments: Value,
) -> Result<String, String>
pub async fn start( &self, session: &str, arguments: Value, ) -> Result<String, String>
Start the owner’s own job in live session session with the agent
call arguments. Returns <session>/<job>.
Sourcepub async fn resume(
&self,
host: &str,
session: &str,
job: &str,
) -> Result<String, String>
pub async fn resume( &self, host: &str, session: &str, job: &str, ) -> Result<String, String>
Run interrupted job job of session again as the owner’s job in
live session host, which serves the job’s workspace. It continues
the agent’s own conversation when the agent saved one and can resume
it; otherwise it starts over, told that an earlier attempt may have
left changes. A queued follow-up has no run of its own: it uses the
conversation’s directory and worktree, continues that agent session
only after the interrupted job the run served has been resumed (and
then behind that conversation), and otherwise starts in a new
worktree of the checkout that job recorded. Each job is resumed
once, and not while an agent process of its run still goes. Returns
<host>/<new job>.
Sourcepub async fn resume_with(
&self,
host: &str,
session: &str,
job: &str,
prompt: &str,
accepted_follow_up: Option<String>,
) -> Result<String, String>
pub async fn resume_with( &self, host: &str, session: &str, job: &str, prompt: &str, accepted_follow_up: Option<String>, ) -> Result<String, String>
Self::resume with the owner’s prompt in place of the note that
the attempt was cut off. A finished job (completed, failed, declined,
or timed out) is continued this way too, still through the ledger’s
resume link, and still not a reviewed job. resume itself is unchanged:
only an interrupted job, and only with that note.
Sourcepub fn cancel(&self, session: &str, job: &str) -> Result<String, String>
pub fn cancel(&self, session: &str, job: &str) -> Result<String, String>
Stop job job of live session session.
Sourcepub fn dismiss(&self, session: &str, job: &str) -> Result<String, String>
pub fn dismiss(&self, session: &str, job: &str) -> Result<String, String>
Forget finished or interrupted job job of session.
Sourcepub fn job_record(&self, session: &str, job: &str) -> Option<JobRecord>
pub fn job_record(&self, session: &str, job: &str) -> Option<JobRecord>
The ledger record of job in session.
Sourcepub fn job_conversation(&self, session: &str, job: &str) -> Option<String>
pub fn job_conversation(&self, session: &str, job: &str) -> Option<String>
The conversation a follow-up can be given to. A job’s record names it once the job has finished; until then the run serving the job does, which is what a job on its first turn has.
Sourcepub fn job_for_run(&self, handle: &str) -> Option<(String, String)>
pub fn job_for_run(&self, handle: &str) -> Option<(String, String)>
The background job run handle is serving, when its state names one.
Sourcepub fn job_result(&self, session: &str, job: &str) -> Result<JobResult, String>
pub fn job_result(&self, session: &str, job: &str) -> Result<JobResult, String>
Job job of session as the workbench lists it, with its reply or
error once it has ended, each cut to MAX_JOB_RESULT_BYTES.
Sourcepub async fn attach_terminal(
&self,
session: &str,
conversation: &str,
cols: Option<u16>,
rows: Option<u16>,
) -> Result<AttachPage, String>
pub async fn attach_terminal( &self, session: &str, conversation: &str, cols: Option<u16>, rows: Option<u16>, ) -> Result<AttachPage, String>
Take conversation conversation of live session session over in
its agent’s own terminal for the owner, or attach to the takeover of
it already running, and return the whole screen. A second client’s
attach takes the terminal from the first, whose hold stops working.
Sourcepub async fn interrupt_and_attach(
&self,
session: &str,
conversation: &str,
cols: Option<u16>,
rows: Option<u16>,
job: Option<&str>,
) -> Result<(AttachPage, Option<String>), String>
pub async fn interrupt_and_attach( &self, session: &str, conversation: &str, cols: Option<u16>, rows: Option<u16>, job: Option<&str>, ) -> Result<(AttachPage, Option<String>), String>
Self::attach_terminal, stopping first the background job that
runs the conversation’s turn. The conversation’s lane is held for
the takeover before that job is stopped, so no other prompt starts a
turn in between, and nothing is stopped when it cannot be held: when
the agent’s terminal is not offered, a takeover of it runs or is
starting, a reviewed job holds it, it has no agent session yet, the
running turn is no background job, that job waits for the owner’s
approval (which a takeover never answers or withdraws), or as many
takeovers as may run do. Given the job the owner was told it stops,
nothing is stopped either when another job runs the turn by then. A
conversation running no turn is taken over as by attach_terminal.
Also returns SCV’s note naming the job it stopped.
Sourcepub async fn attach_io(
&self,
id: &str,
after: u64,
input: &str,
cols: Option<u16>,
rows: Option<u16>,
) -> Result<AttachPage, String>
pub async fn attach_io( &self, id: &str, after: u64, input: &str, cols: Option<u16>, rows: Option<u16>, ) -> Result<AttachPage, String>
Type input into the terminal client id is attached to, resize it,
and return what changed on its screen since generation after.
Sourcepub fn detach(&self, id: &str) -> Result<String, String>
pub fn detach(&self, id: &str) -> Result<String, String>
Stop client id watching its terminal; the agent keeps running.
Sourcepub async fn end_takeover(
&self,
session: &str,
conversation: &str,
) -> Result<(String, AttachPage), String>
pub async fn end_takeover( &self, session: &str, conversation: &str, ) -> Result<(String, AttachPage), String>
End the takeover of conversation of session: hang its terminal
up, stop its process, and give the conversation back to SCV’s
turns. Returns SCV’s note and the final screen.
Sourcepub async fn end_takeovers(&self)
pub async fn end_takeovers(&self)
End every takeover, waiting for each: the daemon is stopping, so none starts any more.
Sourcepub fn takeover_sessions(&self) -> HashSet<String>
pub fn takeover_sessions(&self) -> HashSet<String>
Sessions with a takeover still running, which count as in use.
Sourcepub fn maintain(&self) -> Maintenance
pub fn maintain(&self) -> Maintenance
Settle what processes that stopped left unfinished, and remove old records: the daemon runs this at startup and every minute.