urbit/pkg/arvo/lib/hood/helm.hoon

237 lines
7.8 KiB
Plaintext
Raw Normal View History

2015-05-11 20:53:47 +03:00
:: :: ::
2017-11-29 23:40:44 +03:00
:::: /hoon/helm/hood/lib :: ::
2015-05-11 20:53:47 +03:00
:: :: ::
/? 310 :: version
2019-09-25 02:21:48 +03:00
/- sole
/+ pill
2015-05-11 20:53:47 +03:00
:: :: ::
:::: :: ::
:: :: ::
|% :: ::
2017-11-30 00:29:35 +03:00
++ part {$helm $0 pith} :: helm state
++ pith :: helm content
2018-09-13 08:48:18 +03:00
$: hoc/(map bone session) :: consoles
== ::
2017-11-30 00:29:35 +03:00
++ session ::
$: say/sole-share:sole :: console state
mud/(unit (sole-dialog:sole @ud)) :: console dialog
2019-01-30 03:25:47 +03:00
mass-timer/{way/wire nex/@da tim/@dr}
== ::
2015-05-11 20:53:47 +03:00
:: :: ::
:::: :: ::
:: :: ::
2015-05-12 03:31:37 +03:00
++ hood-reset :: reset command
2015-12-09 04:54:26 +03:00
$~ ::
2015-05-11 20:53:47 +03:00
++ helm-verb :: reset command
2015-12-09 04:54:26 +03:00
$~ ::
2015-05-12 03:31:37 +03:00
++ hood-reload :: reload command
2015-05-11 20:53:47 +03:00
(list term) ::
-- ::
:: :: ::
:::: :: ::
2016-11-17 04:42:58 +03:00
:: :: ::
2019-11-19 07:36:21 +03:00
|: $:{bowl:gall part} :: main helm work
2019-11-14 21:39:50 +03:00
=/ ost 0
=+ sez=(~(gut by hoc) ost $:session)
2019-11-19 07:36:21 +03:00
=| moz=(list card:agent:gall)
2018-01-04 05:31:22 +03:00
|%
2019-11-14 21:39:50 +03:00
++ abet
2017-11-30 00:29:35 +03:00
[(flop moz) %_(+<+.$ hoc (~(put by hoc) ost sez))]
2015-09-02 01:20:17 +03:00
::
2019-11-14 21:39:50 +03:00
++ emit
2019-11-19 07:36:21 +03:00
|= card:agent:gall
2019-11-14 21:39:50 +03:00
%_(+> moz [+< moz])
::
++ flog
|= =flog:dill
(emit %pass /di %arvo %d %flog flog)
::
2015-09-02 01:20:17 +03:00
++ emil :: return cards
2019-11-19 07:36:21 +03:00
|= (list card:agent:gall)
2015-09-02 01:20:17 +03:00
^+ +>
?~(+< +> $(+< t.+<, +> (emit i.+<)))
::
++ poke-rekey :: rotate private keys
|= des=@t
=/ sed=(unit seed:able:jael)
%+ biff
(bind (slaw %uw des) cue)
(soft seed:able:jael)
=< abet
?~ sed
~& %invalid-private-key
+>.$
?. =(our who.u.sed)
~& [%wrong-private-key-ship who.u.sed]
+>.$
2019-11-14 21:39:50 +03:00
(emit %pass / %arvo %j %rekey lyf.u.sed key.u.sed)
::
++ poke-moon :: rotate moon keys
|= sed=(unit [=ship =udiff:point:able:jael])
=< abet
?~ sed
+>.$
2019-11-14 21:39:50 +03:00
(emit %pass / %arvo %j %moon u.sed)
2015-09-02 01:20:17 +03:00
::
++ poke-mass
2018-03-19 07:18:20 +03:00
|= ~ =< abet
(emit %pass /heft %arvo %d %flog %heft ~)
2015-09-02 01:20:17 +03:00
::
++ poke-automass
|= recur=@dr
2019-01-30 03:25:47 +03:00
=. mass-timer.sez
[/helm/automass (add now recur) recur]
2019-11-14 21:39:50 +03:00
abet:(emit %pass way.mass-timer.sez %arvo %b %wait nex.mass-timer.sez)
2019-01-30 03:25:47 +03:00
::
++ poke-cancel-automass
|= ~
2019-11-14 21:39:50 +03:00
abet:(emit %pass way.mass-timer.sez %arvo %b %rest nex.mass-timer.sez)
::
2019-11-23 04:24:42 +03:00
++ poke-pack
|= ~ =< abet
(emit %pass /pack %arvo %d %flog %pack ~)
2019-02-16 12:34:38 +03:00
::
++ take-wake-automass
2019-04-13 01:48:22 +03:00
|= [way=wire error=(unit tang)]
?^ error
%- (slog u.error)
~& %helm-wake-automass-fail
abet
2019-01-30 03:25:47 +03:00
=. nex.mass-timer.sez (add now tim.mass-timer.sez)
=< abet
%- emil
2019-11-14 21:39:50 +03:00
:~ [%pass /heft %arvo %d %flog %crud %hax-heft ~]
[%pass way.mass-timer.sez %arvo %b %wait nex.mass-timer.sez]
==
::
++ poke-send-hi
2015-12-20 23:50:45 +03:00
|= {her/ship mes/(unit tape)} =< abet
2019-11-14 21:39:50 +03:00
%- emit
:* %pass /helm/hi/(scot %p her)
%agent [her %hood] %poke
%helm-hi !>(?~(mes '' (crip u.mes)))
==
2015-09-02 01:20:17 +03:00
::
::
++ poke-hi
|= mes/@t
2017-10-10 06:39:08 +03:00
~| %poke-hi-fail
?: =(%fail mes)
~& %poke-hi-fail
!!
2019-11-14 21:39:50 +03:00
abet:(flog %text "< {<src>}: {(trip mes)}")
2017-10-10 06:39:08 +03:00
::
++ poke-atom
|= ato/@
=+ len=(scow %ud (met 3 ato))
=+ gum=(scow %p (mug ato))
=< abet
2019-11-14 21:39:50 +03:00
(flog %text "< {<src>}: atom: {len} bytes, mug {gum}")
::
2015-09-02 01:20:17 +03:00
++ coup-hi
2015-12-20 23:50:45 +03:00
|= {pax/path cop/(unit tang)} =< abet
2018-03-19 07:18:20 +03:00
?> ?=({@t ~} pax)
2019-11-14 21:39:50 +03:00
(flog %text "hi {(trip i.pax)} {?~(cop "" "un")}successful")
2015-09-02 01:20:17 +03:00
::
2015-12-20 23:50:45 +03:00
++ poke-reload |=(all/(list term) (poke-reload-desk %home all))
2015-09-02 01:20:17 +03:00
++ poke-reload-desk :: reload vanes
2018-01-04 05:31:22 +03:00
|: $:{syd/desk all/(list term)} =< abet
2015-09-02 01:20:17 +03:00
%- emil
%+ turn all
2016-12-02 04:17:02 +03:00
=+ top=`path`/(scot %p our)/[syd]/(scot %da now)
2018-03-19 07:18:20 +03:00
=/ van/(list {term ~})
2016-12-03 00:41:06 +03:00
:- zus=[%zuse ~]
~(tap by dir:.^(arch %cy (welp top /sys/vane)))
2015-12-20 23:50:45 +03:00
|= nam/@tas
2016-12-03 00:41:06 +03:00
=. nam
?. =(1 (met 3 nam))
nam
=/ zaz/(list {p/knot ~})
2018-03-19 07:18:20 +03:00
(skim van |=({a/term ~} =(nam (end 3 1 a))))
?> ?=({{@ ~} ~} zaz)
2016-12-03 00:41:06 +03:00
`term`p.i.zaz
2015-09-02 01:20:17 +03:00
=+ tip=(end 3 1 nam)
=+ zus==('z' tip)
2016-12-02 04:17:02 +03:00
=+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam]))
2016-01-26 03:47:58 +03:00
=+ fil=.^(@ %cx (welp way /hoon))
2019-11-14 21:39:50 +03:00
[%pass /reload %arvo %d %flog %veer ?:(=('z' tip) %$ tip) way fil]
:: +poke-reset: send %lyra to initiate kernel upgrade
2015-09-02 01:20:17 +03:00
::
:: And reinstall %zuse and the vanes with %veer.
:: Trigger with |reset.
2017-10-19 06:50:48 +03:00
::
++ poke-reset
|= hood-reset
=< abet
%- emil
2019-11-19 07:36:21 +03:00
^- (list card:agent:gall)
=/ top=path /(scot %p our)/home/(scot %da now)/sys
=/ hun .^(@ %cx (welp top /hoon/hoon))
=/ arv .^(@ %cx (welp top /arvo/hoon))
2019-11-14 21:39:50 +03:00
:- [%pass /reset %arvo %d %flog %lyra `@t`hun `@t`arv]
2015-09-02 01:20:17 +03:00
%+ turn
(module-ova:pill top)
2019-11-14 21:39:50 +03:00
|=([=wire =flog:dill] [%pass wire %arvo %d %flog flog])
2015-09-02 01:20:17 +03:00
::
++ poke-verb :: toggle verbose
2018-03-19 07:18:20 +03:00
|= ~ =< abet
2019-11-14 21:39:50 +03:00
(flog %verb ~)
2015-09-02 01:20:17 +03:00
::
++ poke-ames-sift
|= ships=(list ship) =< abet
(emit %pass /helm %arvo %a %sift ships)
::
2019-12-03 02:54:01 +03:00
++ poke-ames-verb
|= veb=(list verb:ames) =< abet
(emit %pass /helm %arvo %a %spew veb)
::
++ poke-knob
|= [error-tag=@tas level=?(%hush %soft %loud)] =< abet
2019-11-14 21:39:50 +03:00
(emit %pass /helm %arvo %d %knob error-tag level)
2017-12-12 23:23:00 +03:00
::
2018-10-11 01:26:51 +03:00
++ poke-serve
|= [=binding:eyre =generator:eyre] =< abet
2019-11-14 21:39:50 +03:00
(emit %pass /helm/serv %arvo %e %serve binding generator)
::
++ poke
|= [=mark =vase]
?+ mark ~|([%poke-helm-bad-mark mark] !!)
%helm-hi =;(f (f !<(_+<.f vase)) poke-hi)
%helm-mass =;(f (f !<(_+<.f vase)) poke-mass)
%helm-pack =;(f (f !<(_+<.f vase)) poke-pack)
2019-11-14 21:39:50 +03:00
%helm-reload =;(f (f !<(_+<.f vase)) poke-reload)
%helm-reload-desk =;(f (f !<(_+<.f vase)) poke-reload-desk)
%helm-reset =;(f (f !<(_+<.f vase)) poke-reset)
%helm-send-hi =;(f (f !<(_+<.f vase)) poke-send-hi)
%helm-ames-sift =;(f (f !<(_+<.f vase)) poke-ames-sift)
2019-12-03 02:54:01 +03:00
%helm-ames-verb =;(f (f !<(_+<.f vase)) poke-ames-verb)
2019-11-14 21:39:50 +03:00
%helm-verb =;(f (f !<(_+<.f vase)) poke-verb)
%helm-knob =;(f (f !<(_+<.f vase)) poke-knob)
%helm-rekey =;(f (f !<(_+<.f vase)) poke-rekey)
%helm-automass =;(f (f !<(_+<.f vase)) poke-automass)
%helm-cancel-automass =;(f (f !<(_+<.f vase)) poke-cancel-automass)
%helm-moon =;(f (f !<(_+<.f vase)) poke-moon)
%helm-serve =;(f (f !<(_+<.f vase)) poke-serve)
==
::
++ take-agent
2019-11-19 07:36:21 +03:00
|= [=wire =sign:agent:gall]
2019-11-14 21:39:50 +03:00
?+ wire ~|([%helm-bad-take-agent wire -.sign] !!)
[%helm %hi *] ?> ?=(%poke-ack -.sign)
(coup-hi t.t.wire p.sign)
==
2018-10-11 01:26:51 +03:00
::
++ take-bound
|= [wir=wire success=? binding=binding:eyre] =< abet
2019-11-14 21:39:50 +03:00
(flog %text "bound: {<success>}")
::
++ take
|= [=wire =sign-arvo]
?+ wire ~|([%helm-bad-take-wire wire +<.sign-arvo] !!)
[%automass *] %+ take-wake-automass t.wire
?>(?=(%wake +<.sign-arvo) +>.sign-arvo)
[%serv *] %+ take-bound t.wire
?>(?=(%bound +<.sign-arvo) +>.sign-arvo)
==
2015-05-11 20:53:47 +03:00
--