rho-coding-agent 3.2.0

A fast Rust agent harness with a small footprint and opinionated defaults
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
//! What the rho daemon answers over `rho-protocol`.
//!
//! `crate::daemon` is the generic transport (socket, lock, accept loop) and
//! never learns what a session is; [`DaemonHost`] is the [`Service`] it routes
//! requests to, and `app::daemon_cli` wires the two together. The host owns
//! the job registry (`jobs/`), whose records outlive the daemon, and the
//! sessions it has loaded (`sessions/`), which own the budget their
//! subagents share (`subagents.rs`). It also writes the credential store
//! those sessions read (`auth.rs`), reports and chooses that store
//! (`store.rs`), and runs the interactive logins clients start, relaying
//! each to its client (`logins.rs`). It re-executes the daemon in place on
//! `rho/daemon/restart` and once a replaced executable finds it idle
//! (`upgrade.rs`, #1713), and the daemon it re-executes continues the
//! session turns that restart interrupted (`sessions/restart_resume.rs`).

use std::{
    io,
    path::{Path, PathBuf},
    sync::{
        atomic::{AtomicU64, Ordering},
        Arc,
    },
    time::{Duration, Instant},
};

use rho_protocol::{
    AuthChooseStoreParams, AuthChooseStoreResponse, AuthKeyParams, AuthKeyResponse, AuthListParams,
    AuthListResponse, AuthLoginCancelParams, AuthLoginCancelResponse, AuthLoginParams,
    AuthLoginResponse, AuthLogoutParams, AuthLogoutResponse, BuildId, ClientInfo, ConfigGetParams,
    ConfigRegisterParams, ConfigRegisterResponse, ConfigSchema, ConfigSetParams, ConfigSetResponse,
    ConfigWatch, DaemonStatus, DetachReason, JobListResponse, LoginStream, PendingUpgrade,
    ProtocolVersion, RestartCost, RpcError, Service, SessionAnswerParams, SessionAnswerResponse,
    SessionAttachParams, SessionAttachResponse, SessionCancelParams, SessionCancelResponse,
    SessionConfigureParams, SessionConfigureResponse, SessionDeleteParams, SessionDeleteResponse,
    SessionHoldParams, SessionHoldResponse, SessionListParams, SessionListResponse,
    SessionNewParams, SessionNewResponse, SessionObserveParams, SessionPromptParams,
    SessionPromptResponse, SessionRenameParams, SessionRenameResponse, SessionSteerParams,
    SessionSteerResponse, SessionSurfaceActionParams, SessionSurfaceActionResponse,
    SessionUnsteerParams, SessionUnsteerResponse, SettingsService, Subscription,
    WorktreePruneParams, WorktreePruneResponse, PROTOCOL_VERSION,
};
use rho_providers::credentials::CredentialStoreBackend;

use crate::daemon::{DaemonLock, Ending, Executable, Shutdown};

mod auth;
mod jobs;
mod logins;
mod sessions;
mod settings;
mod store;
mod subagents;
mod upgrade;
mod wire;

use jobs::{JobRegistry, JobStore, JobSubject};
use logins::Logins;
use sessions::{worktree_stale, Prune, Sessions};
pub(super) use sessions::{DAEMON_COMMANDS, UNLOAD_IDLE_AFTER};
use upgrade::UPGRADE_CHECK_INTERVAL;
use upgrade::{Check, Upgrades, Watch};

/// How often the daemon prunes session worktrees, after the pass it runs
/// at start.
//
// Policy: once a day, as the cleanup proposal Matt approved in #1917 says.
// A pass runs git on each kept worktree, so it does not run per listing.
const WORKTREE_PRUNE_INTERVAL: Duration = Duration::from_secs(24 * 60 * 60);

/// How long after the daemon starts its first worktree pass runs.
//
// Tripwire, not measured to the millisecond: a client that starts the
// daemon, as `rho worktrees prune` can, sends its request well under a
// second after the daemon answers (each e2e prune test runs in about 1 s
// whole), so its own pass removes, and reports, what the daemon's would
// have. The daemon's pass skips sessions used within the last day, so
// waiting a minute delays nothing it would remove.
const WORKTREE_PRUNE_AFTER_START: Duration = Duration::from_secs(60);

/// How the daemon process started, which decides whether it continues the
/// turns its predecessor's restart interrupted.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum Startup {
    /// Anew: after a stop, a crash, or a restart that exited instead of
    /// re-executing, as one whose turns did not save in time does.
    Fresh,
    /// Run by its predecessor's restart in place, `rho daemon restart` or
    /// an upgrade, which handed it the daemon lock (`--exec-handoff`).
    RestartedInPlace,
}

/// The daemon's job records, opened before the daemon binds its socket, so
/// a daemon that cannot keep records stops before any client reaches it.
pub(super) struct JobRecords {
    jobs: Arc<JobRegistry>,
    /// The sessions whose turn the restart that ran this daemon interrupted,
    /// which it continues; none for a [`Startup::Fresh`] daemon.
    interrupted_by_restart: Vec<rho_sdk::SessionId>,
}

impl JobRecords {
    /// Opens the records in the daemon's `state_dir`, for a daemon that
    /// started as `startup` says. Opening rewrites the records of turns an
    /// earlier daemon left open, and clears the marks of the turns a restart
    /// interrupted, so it takes the daemon lock, which guards that
    /// directory, as proof the caller holds it.
    pub(super) fn open(_held: &DaemonLock, state_dir: &Path, startup: Startup) -> io::Result<Self> {
        let store = JobStore::open(state_dir)?;
        let jobs = JobRegistry::open(store);
        // Taken at every start, so only the daemon a restart re-executed
        // continues what that restart interrupted, and only once.
        let marked = jobs.take_restart_interrupted();
        let interrupted_by_restart = match startup {
            Startup::Fresh => Vec::new(),
            Startup::RestartedInPlace => marked,
        };
        Ok(Self {
            jobs: Arc::new(jobs),
            interrupted_by_restart,
        })
    }
}

/// The daemon's protocol service.
pub(super) struct DaemonHost {
    socket: PathBuf,
    started_at: u64,
    started: Instant,
    shutdown: Shutdown,
    jobs: Arc<JobRegistry>,
    /// Shared with the logins, which refresh the sessions' options once
    /// they saved a credential.
    sessions: Arc<Sessions>,
    logins: Arc<Logins>,
    upgrades: Upgrades,
    /// Connections whose handshake the daemon accepted and that have not
    /// left: the clients a restart would disconnect.
    clients: AtomicU64,
    /// `RHO_CREDENTIAL_STORE` in the daemon's environment, parsed once at
    /// startup, which refuses a value it does not know.
    store_environment: Option<CredentialStoreBackend>,
}

impl DaemonHost {
    /// A host for the daemon of `rho_home` listening on `socket` since
    /// `started_at` (Unix seconds), keeping its jobs in `jobs`, with
    /// `store_environment` its parsed `RHO_CREDENTIAL_STORE`.
    /// `rho/daemon/stop` calls [`Self::begin_stop`], and `rho/daemon/restart`
    /// [`Self::begin_restart`], which request `shutdown`, the transport's;
    /// once the transport stopped serving, call [`Self::stop_sessions`].
    pub(super) fn new(
        JobRecords {
            jobs,
            interrupted_by_restart,
        }: JobRecords,
        rho_home: &Path,
        socket: PathBuf,
        started_at: u64,
        shutdown: Shutdown,
        store_environment: Option<CredentialStoreBackend>,
    ) -> Self {
        let sessions = Sessions::new(Arc::clone(&jobs), rho_home);
        sessions.resume_after_restart(interrupted_by_restart);
        Self {
            socket,
            started_at,
            started: Instant::now(),
            sessions,
            logins: Arc::new(Logins::new()),
            upgrades: Upgrades::default(),
            clients: AtomicU64::new(0),
            shutdown,
            jobs,
            store_environment,
        }
    }

    /// Starts the daemon's stop: refuses new sessions and prompts, detaches
    /// every attached client as `daemon_stopping`, then requests the
    /// transport's `shutdown`, which closes the connections. How every stop
    /// begins, from `rho/daemon/stop` or a signal.
    pub(super) fn begin_stop(&self) {
        self.begin(Ending::Stop);
    }

    /// Starts the daemon's restart, as [`Self::begin_stop`] starts its stop
    /// but telling clients `restarting`; the caller re-executes the daemon
    /// once its turns are stopped. The session turns it interrupts that may
    /// continue are marked for the re-executed daemon to continue (see
    /// `sessions/restart_resume.rs`).
    pub(super) fn begin_restart(&self) {
        self.begin(Ending::Restart);
    }

    fn begin(&self, ending: Ending) {
        self.shutdown.request(ending, |ending| {
            // Before any turn stops, so the registry records each turn the
            // stop interrupts as this ending leaves it.
            self.jobs.stopping_for(ending);
            self.sessions.begin_stop(match ending {
                Ending::Stop => DetachReason::DaemonStopping,
                Ending::Restart => DetachReason::Restarting,
            });
        });
    }

    /// Claims the daemon idle for an upgrade, unless anything would be cut
    /// short; once claimed, the restart follows at once. Closing the job
    /// registry is the claim: no turn starts after it. It closes only if no
    /// job went in progress since the daemon was found idle, before the
    /// other checks, so a turn that began and ended meanwhile cannot leave
    /// work those checks missed. Background work and subagents both start in
    /// a turn; only a login or a settings change sent between the checks and
    /// the close escapes them, and the restart then ends it as a stop would.
    fn claim_idle(&self) -> bool {
        let Some(idle) = self.jobs.idle() else {
            return false;
        };
        self.work_outside_jobs() == 0 && self.jobs.close_if_still(idle)
    }

    /// What a restart would cut short besides jobs in progress: logins
    /// under way and sessions with work of their own. An upgrade waits for
    /// it, and a newer client is told of it, so both count it here.
    fn work_outside_jobs(&self) -> usize {
        self.logins.under_way() + self.sessions.upgrade_blockers()
    }

    /// Everything a restart would cut short, which an upgrade waits for.
    fn in_progress(&self) -> u64 {
        u64::try_from(self.jobs.in_progress() + self.work_outside_jobs()).unwrap_or(u64::MAX)
    }

    /// What a restart would cost now: what an upgrade waits for, which
    /// `status` reports pending, and the clients it would leave without a
    /// daemon they can use.
    fn restart_cost(&self) -> RestartCost {
        RestartCost {
            in_progress: self.in_progress(),
            clients: self.clients.load(Ordering::Relaxed),
        }
    }

    /// Whether the daemon's stop, or restart, has begun.
    pub(super) fn stopping(&self) -> bool {
        self.shutdown.is_requested()
    }

    /// Restarts the daemon once `executable` was replaced and nothing would
    /// be cut short, checking every [`UPGRADE_CHECK_INTERVAL`]; ends once
    /// the daemon stops.
    pub(super) async fn upgrade_when_replaced(&self, executable: &Executable) {
        let mut checks = tokio::time::interval(UPGRADE_CHECK_INTERVAL);
        checks.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
        let mut watch = Watch::default();
        loop {
            tokio::select! {
                () = self.upgrades.next_check(&mut checks) => {}
                () = self.shutdown.requested() => return,
            }
            if self.upgrades.check(executable, &mut watch).await == Check::Upgrade
                && self.claim_idle()
            {
                tracing::info!("upgrading in place");
                self.begin_restart();
                return;
            }
        }
    }

    /// Unloads each session once it sat idle for `grace`, or discards it
    /// when it saved nothing, until the daemon starts stopping (#1661).
    pub(super) async fn unload_idle_sessions(&self, grace: Duration) {
        self.sessions.unload_idle(grace).await;
    }

    /// Prunes the session worktrees [`WORKTREE_PRUNE_AFTER_START`] after
    /// the daemon starts and every [`WORKTREE_PRUNE_INTERVAL`] after that,
    /// until the daemon starts stopping.
    pub(super) async fn prune_worktrees_daily(&self) {
        let mut wait = WORKTREE_PRUNE_AFTER_START;
        loop {
            tokio::select! {
                () = tokio::time::sleep(wait) => {}
                () = self.shutdown.requested() => return,
            }
            self.sessions.prune_worktrees(Prune::Daily).await;
            wait = WORKTREE_PRUNE_INTERVAL;
        }
    }

    /// Stops the turns under way, waits for them to save, and records
    /// them interrupted; the wait's budget runs from `stop_requested`. Call
    /// once the transport stopped serving, before releasing the daemon lock.
    /// Returns whether all of it finished in time: a turn stuck past the
    /// budget still holds processes only exiting ends.
    pub(super) async fn stop_sessions(&self, stop_requested: tokio::time::Instant) -> bool {
        self.sessions.stop(stop_requested).await
    }
}

impl Service for DaemonHost {
    async fn status(&self) -> DaemonStatus {
        let in_progress = self.jobs.in_progress();
        DaemonStatus {
            pid: std::process::id(),
            version: env!("CARGO_PKG_VERSION").to_owned(),
            protocol: PROTOCOL_VERSION,
            started_at: self.started_at,
            uptime_secs: self.started.elapsed().as_secs(),
            jobs: u64::try_from(in_progress).unwrap_or(u64::MAX),
            in_progress: self.in_progress(),
            socket: self.socket.clone(),
            credential_store: store::status(self.store_environment).await,
            upgrade: self.upgrades.pending().map(|version| PendingUpgrade {
                version,
                waiting_for: self.in_progress(),
            }),
        }
    }

    fn hello(&self, client: &ClientInfo) {
        self.clients.fetch_add(1, Ordering::Relaxed);
        self.upgrades.heard(client);
    }

    fn left(&self) {
        self.clients.fetch_sub(1, Ordering::Relaxed);
    }

    fn refused_newer(&self, client: ProtocolVersion) -> RestartCost {
        let cost = self.restart_cost();
        // That client stops this daemon when the restart is free, so the
        // log says whether it may.
        tracing::info!(
            %client,
            in_progress = cost.in_progress,
            clients = cost.clients,
            may_replace = cost.is_free(),
            "refused a client of a newer protocol"
        );
        cost
    }

    fn skewed(&self, client: &ClientInfo, build: &BuildId) -> RestartCost {
        let cost = self.restart_cost();
        tracing::info!(
            client = %client.name,
            version = %client.version,
            %build,
            in_progress = cost.in_progress,
            clients = cost.clients,
            "accepted a client of another build"
        );
        cost
    }

    async fn stop(&self) {
        tracing::info!("stop requested");
        self.begin_stop();
    }

    async fn restart(&self) {
        tracing::info!("restart requested");
        self.begin_restart();
    }

    async fn new_session(&self, params: SessionNewParams) -> Result<SessionNewResponse, RpcError> {
        self.sessions.open_new(params).await
    }

    async fn prompt_session(
        &self,
        params: SessionPromptParams,
    ) -> Result<SessionPromptResponse, RpcError> {
        self.sessions.prompt(params).await
    }

    async fn cancel_session(
        &self,
        params: SessionCancelParams,
    ) -> Result<SessionCancelResponse, RpcError> {
        self.sessions.cancel(params).await
    }

    async fn steer_session(
        &self,
        params: SessionSteerParams,
    ) -> Result<SessionSteerResponse, RpcError> {
        self.sessions.steer(params).await
    }

    async fn unsteer_session(
        &self,
        params: SessionUnsteerParams,
    ) -> Result<SessionUnsteerResponse, RpcError> {
        self.sessions.unsteer(params).await
    }

    async fn answer_session(
        &self,
        params: SessionAnswerParams,
    ) -> Result<SessionAnswerResponse, RpcError> {
        self.sessions.answer(params).await
    }

    async fn surface_action(
        &self,
        params: SessionSurfaceActionParams,
    ) -> Result<SessionSurfaceActionResponse, RpcError> {
        self.sessions.surface_action(params).await
    }

    async fn hold_session(
        &self,
        params: SessionHoldParams,
    ) -> Result<SessionHoldResponse, RpcError> {
        self.sessions.hold(params).await
    }

    async fn session_processes(
        &self,
        params: rho_protocol::SessionProcessesParams,
    ) -> Result<rho_protocol::SessionProcessesResponse, RpcError> {
        self.sessions.processes(params).await
    }

    async fn list_session_background(
        &self,
    ) -> Result<rho_protocol::SessionBackgroundListResponse, RpcError> {
        Ok(self.sessions.background_list())
    }

    async fn session_background_stop(
        &self,
        params: rho_protocol::SessionBackgroundStopParams,
    ) -> Result<rho_protocol::SessionBackgroundStopResponse, RpcError> {
        self.sessions.background_stop(params).await
    }

    async fn session_mcp(
        &self,
        params: rho_protocol::SessionMcpParams,
    ) -> Result<rho_protocol::SessionMcpInventory, RpcError> {
        self.sessions.mcp(params).await
    }

    async fn session_mcp_catalog(
        &self,
        params: rho_protocol::SessionMcpCatalogParams,
    ) -> Result<rho_protocol::SessionMcpCatalog, RpcError> {
        self.sessions.mcp_catalog(params).await
    }

    async fn session_mcp_resource(
        &self,
        params: rho_protocol::SessionMcpResourceParams,
    ) -> Result<rho_protocol::SessionMcpResourceResponse, RpcError> {
        self.sessions.mcp_resource(params).await
    }

    async fn session_mcp_complete(
        &self,
        params: rho_protocol::SessionMcpCompleteParams,
    ) -> Result<rho_protocol::SessionMcpCompleteResponse, RpcError> {
        self.sessions.mcp_complete(params).await
    }

    async fn inspect_session(
        &self,
        params: rho_protocol::SessionInspectParams,
    ) -> Result<rho_protocol::SessionInspectResponse, RpcError> {
        self.sessions.inspect(params).await
    }

    async fn configure_session(
        &self,
        params: SessionConfigureParams,
    ) -> Result<SessionConfigureResponse, RpcError> {
        self.sessions.configure(params).await
    }

    async fn attach_session(
        &self,
        params: SessionAttachParams,
    ) -> Result<(SessionAttachResponse, Subscription), RpcError> {
        self.sessions.attach(params).await
    }

    async fn observe_session(
        &self,
        params: SessionObserveParams,
    ) -> Result<(SessionAttachResponse, Subscription), RpcError> {
        self.sessions.observe(params).await
    }

    async fn list_sessions(
        &self,
        params: SessionListParams,
    ) -> Result<SessionListResponse, RpcError> {
        self.sessions.list(params).await
    }

    async fn rename_session(
        &self,
        params: SessionRenameParams,
    ) -> Result<SessionRenameResponse, RpcError> {
        self.sessions.rename(params).await
    }

    async fn delete_session(
        &self,
        params: SessionDeleteParams,
    ) -> Result<SessionDeleteResponse, RpcError> {
        self.sessions.delete(params).await
    }

    async fn list_jobs(&self) -> JobListResponse {
        // A drive marks its run finished before its job ends, so a job read
        // first that has ended is already in the tracker read second.
        let records = self.jobs.list();
        let undelivered = self.sessions.undelivered_workflow_runs();
        let in_use = self.sessions.worktrees_in_use(&records);
        let now = jobs::unix_now();
        JobListResponse {
            jobs: records
                .into_iter()
                .map(|record| {
                    let queue = self.sessions.subagents().queue_place(&record.id);
                    let live = match &record.subject {
                        JobSubject::Session { session } => self.sessions.session_live(session),
                        // Only the run under way: an ended run of the same
                        // session, as a workflow node that ran again has,
                        // is followed no more.
                        JobSubject::Subagent {
                            session: Some(session),
                            run: _,
                        } if record.state.in_progress() => {
                            self.sessions.subagents().feeds().live(session)
                        }
                        JobSubject::Subagent { .. } | JobSubject::Workflow { .. } => None,
                    };
                    let worktree_stale = worktree_stale(&record, &in_use, now);
                    wire::job_summary(record, queue, &undelivered, live, worktree_stale)
                })
                .collect(),
        }
    }

    async fn prune_worktrees(
        &self,
        params: WorktreePruneParams,
    ) -> Result<WorktreePruneResponse, RpcError> {
        let WorktreePruneParams { dry_run } = params;
        let prune = match dry_run {
            true => Prune::DryRun,
            false => Prune::Now,
        };
        Ok(WorktreePruneResponse {
            worktrees: self.sessions.prune_worktrees(prune).await,
        })
    }

    // A credential write changes the models every session may switch to.
    async fn save_auth_key(&self, params: AuthKeyParams) -> Result<AuthKeyResponse, RpcError> {
        let saved = auth::save_key(params).await?;
        auth::credentials_changed(&self.sessions).await;
        Ok(saved)
    }

    async fn logout_auth(&self, params: AuthLogoutParams) -> Result<AuthLogoutResponse, RpcError> {
        let logged_out = auth::logout(params).await?;
        auth::credentials_changed(&self.sessions).await;
        Ok(logged_out)
    }

    async fn list_auths(&self, params: AuthListParams) -> Result<AuthListResponse, RpcError> {
        auth::list(params).await
    }

    async fn login(
        &self,
        params: AuthLoginParams,
    ) -> Result<(AuthLoginResponse, LoginStream), RpcError> {
        self.logins.start(params, Arc::clone(&self.sessions)).await
    }

    async fn cancel_login(
        &self,
        params: AuthLoginCancelParams,
    ) -> Result<AuthLoginCancelResponse, RpcError> {
        self.logins.cancel(params)
    }

    async fn choose_store(
        &self,
        params: AuthChooseStoreParams,
    ) -> Result<AuthChooseStoreResponse, RpcError> {
        store::choose(params, self.store_environment, &self.sessions).await
    }
}

impl SettingsService for DaemonHost {
    async fn config_schema(&self) -> Result<ConfigSchema, RpcError> {
        Ok(self.sessions.settings().schema())
    }

    async fn register_config(
        &self,
        params: ConfigRegisterParams,
    ) -> Result<ConfigRegisterResponse, RpcError> {
        self.sessions.settings().register(params).await
    }

    async fn get_config(&self, params: ConfigGetParams) -> Result<ConfigWatch, RpcError> {
        self.sessions.settings().get(params).await
    }

    async fn set_config(&self, params: ConfigSetParams) -> Result<ConfigSetResponse, RpcError> {
        self.sessions.settings().set(params).await
    }
}