mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 00:13:12 +03:00
Add -get-dudes
to %garden
- expose running agents
Allow an interface to scry for running agents from core functionality, through `%garden` desk.
This commit is contained in:
parent
1f76be7f4b
commit
2a778a5963
53
pkg/garden/ted/get-dudes.hoon
Normal file
53
pkg/garden/ted/get-dudes.hoon
Normal file
@ -0,0 +1,53 @@
|
||||
/- spider
|
||||
/+ *strandio
|
||||
::
|
||||
=, strand=strand:spider
|
||||
::
|
||||
:: send on /spider/garden/json/get-dudes/json
|
||||
::
|
||||
|%
|
||||
++ buds :: get agents currently running
|
||||
|= p=@tas
|
||||
=/ m (strand ,(list @tas))
|
||||
^- form:m
|
||||
?. =(%base p)
|
||||
;< q=(list @tas) bind:m (suds p)
|
||||
(pure:m q)
|
||||
;< q=(list @tas) bind:m duds
|
||||
=| r=(list (list @tas))
|
||||
|- ^- form:m
|
||||
=* loop $
|
||||
?~ q (pure:m (zing r))
|
||||
;< t=(list @tas) bind:m (suds i.q)
|
||||
loop(q t.q, r [t r])
|
||||
::
|
||||
++ suds :: clean %ge scry
|
||||
|= p=@tas
|
||||
=/ m (strand ,(list @tas))
|
||||
^- form:m
|
||||
;< q=(set [@tas ?]) bind:m
|
||||
(scry (set ,[@tas ?]) /ge/(scot %tas p))
|
||||
%- pure:m
|
||||
(murn ~(tap in q) |=([@tas ?] ?.(+.+< ~ `-.+<)))
|
||||
::
|
||||
++ duds :: get desks
|
||||
=/ m (strand ,(list @tas))
|
||||
^- form:m
|
||||
;< p=(set @tas) bind:m (scry (set ,@tas) /cd/base)
|
||||
(pure:m ~(tap in p))
|
||||
--
|
||||
::
|
||||
^- thread:spider
|
||||
|= jon=vase
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
=, bowl
|
||||
?~ know=!<((unit json) jon)
|
||||
(pure:m !>(`json`[%s 'invalid-request']))
|
||||
?. ?=([%s @] u.know)
|
||||
(pure:m !>(`json`[%s 'invalid-request']))
|
||||
=, format
|
||||
;< breh=(list @tas) bind:m (buds (so:dejs u.know))
|
||||
%- pure:m
|
||||
!>(`json`(frond:enjs 'buds' a/(turn breh |=(@tas s/+<))))
|
Loading…
Reference in New Issue
Block a user