diff --git a/app/talk-agent.hoon b/app/talk-agent.hoon index d4cfd66e7..0e0b647bb 100644 --- a/app/talk-agent.hoon +++ b/app/talk-agent.hoon @@ -32,10 +32,11 @@ $: count/@ud :: (lent grams) grams/(list telegram) :: all history locals/atlas :: presence + remotes/(map partner atlas) :: remote presences shape/config :: configuration + mirrors/(map station config) :: remote configs known/(map serial @ud) :: messages heard == :: - ::TODO do away with most of shell state, it's largely a mirror of tale..? ++ shell :: console session $: id/bone :: identifier count/@ud :: messages shown @@ -186,31 +187,37 @@ ++ ra-diff-talk-lowdown-tales ::x apply tale configs. :: - |= tals/(map knot (unit config)) + |= tals/(map knot (unit cabal)) ^+ +> ::TODO for every changed config, (sh-low-config oldconfig newconfig) :: maybe something else for new/removed tales? %= +> tales %+ roll (~(tap by tals)) - |= {t/(pair knot (unit config)) tas/_tales} + |= {t/(pair knot (unit cabal)) tas/_tales} ~& [%r-new-config-for p.t] =. tas ?~(tas tales tas) ::x start with our current tales. =+ tal=(fall (~(get by tas) p.t) *tale) ?~ q.t (~(del by tas) p.t) - (~(put by tas) p.t tal(shape u.q.t)) + (~(put by tas) p.t tal(shape loc.u.q.t, mirrors ham.u.q.t)) == :: ++ ra-diff-talk-lowdown-precs ::x apply new presence. :: - |= {man/knot pes/atlas} + |= {man/knot pes/atlas pas/(map partner atlas)} ^+ +> =+ tal=(~(get by tales) man) - ?~ tal ~&([%know-no-tale man] +>.$) - =+ new=(~(uni by pes) locals.u.tal) - ?: =(locals.u.tal new) +>.$ - =. +>.$ sh-abet:(~(sh-low-precs sh ~ cli man) locals.u.tal new) - +>.$(tales (~(put by tales) man u.tal(locals new))) + ?~ tal ~&([%low-precs-know-no-tale man] +>.$) + =+ nel=(~(uni by pes) locals.u.tal) + ::TODO make better ++sh arms for this. + =. +>.$ + ?: =(locals.u.tal nel) +>.$ + sh-abet:(~(sh-low-precs sh ~ cli man) [locals.u.tal ~] [nel ~]) + =+ ner=(~(uni by pas) remotes.u.tal) ::TODO better uni. + =. +>.$ + ?: =(remotes.u.tal ner) +>.$ + sh-abet:(~(sh-low-precs sh ~ cli man) [~ remotes.u.tal] [~ ner]) + +>.$(tales (~(put by tales) man u.tal(locals nel, remotes ner))) :: ++ ra-diff-talk-lowdown-grams ::x apply new grams @@ -811,6 +818,37 @@ ^- tape ['%' (trip p.saz)] :: + ++ sh-repo-rogue-diff + ::x calculates the difference between two maps of stations and their + ::x presence lists. + :: + |= {one/(map partner atlas) two/(map partner atlas)} + =| $= ret + $: old/(list (pair partner atlas)) + new/(list (pair partner atlas)) + cha/(list (pair partner atlas)) + == + ^+ ret + =. ret + =+ eno=(~(tap by one)) + |- ^+ ret + ?~ eno ret + =. ret $(eno t.eno) + =+ unt=(~(get by two) p.i.eno) + ?~ unt + ret(old [i.eno old.ret]) + ?: =(q.i.eno u.unt) ret + ret(cha [[p.i.eno u.unt] cha.ret]) + =. ret + =+ owt=(~(tap by two)) + |- ^+ ret + ?~ owt ret + =. ret $(owt t.owt) + ?: (~(has by one) p.i.owt) + ret + ret(new [i.owt new.ret]) + ret + :: ++ sh-repo-group-diff-here :: print atlas diff ::x prints presence notifications. :: @@ -841,13 +879,46 @@ (weld pre "set {(scow %p p.i.cha.cul)} {(sh-spaz q.i.cha.cul)}") +>.$ :: + ++ sh-repo-group-there :: update foreign + ::x updates remote presences(?) and prints changes. + :: + |= {old/(map partner atlas) new/(map partner atlas)} + =+ day=(sh-repo-rogue-diff old new) + ?: (~(has in settings.she) %quiet) + +>.$ + =. +>.$ + |- ^+ +>.^$ + ?~ old.day +>.^$ + =. +>.^$ $(old.day t.old.day) + (sh-note (weld "not " (~(ta-show ta man p.i.old.day) ~))) + =. +>.$ + |- ^+ +>.^$ + ?~ new.day +>.^$ + =. +>.^$ $(new.day t.new.day) + =. +>.^$ + (sh-note (weld "new " (~(ta-show ta man p.i.new.day) ~))) + (sh-repo-group-diff-here "--" ~ (~(tap by q.i.new.day)) ~) + =. +>.$ + |- ^+ +>.^$ + ?~ cha.day +>.^$ + =. +>.^$ $(cha.day t.cha.day) + =. +>.^$ + (sh-note (weld "for " (~(ta-show ta man p.i.cha.day) ~))) + =+ yez=(~(got by old) p.i.cha.day) + %+ sh-repo-group-diff-here "--" + (sh-repo-atlas-diff yez q.i.cha.day) + +>.$ + :: ++ sh-low-precs ::x print presence changes :: - |= {old/atlas new/atlas} + |= $: old/(pair atlas (map partner atlas)) + new/(pair atlas (map partner atlas)) + == ^+ +> - =+ dif=(sh-repo-atlas-diff old new) - (sh-repo-group-diff-here "" dif) + =+ dif=(sh-repo-atlas-diff p.old p.new) + =. +>.$ (sh-repo-group-diff-here "" dif) + (sh-repo-group-there q.old q.new) :: ++ sh-low-gram ::x renders telegram: increase gram count and print the gram. @@ -1082,17 +1153,15 @@ ++ who :: %who |= pan/(set partner) ^+ ..sh-work ::TODO clever use of =< and . take note! - ::TODO actually use the correct station. ~& [%who-ing pan] - =< (sh-fact %mor (murn (sort (~(tap by tales) ~) aor) .)) - |= {nam/knot tal/tale} - ^- (unit sole-effect) - ?. |(=(~ pan) (~(any in pan) ~(has in sources.shape.tal))) ~ - =- `[%tan rose+[", " `~]^- leaf+~(ta-full ta man [%& ~zod nam]) ~] - =< (murn (sort (~(tap by locals.tal)) aor) .) + =+ tal=(~(got by tales) man) + =< (sh-fact %mor (murn (sort (~(tap by remotes.tal) ~) aor) .)) + |= {pon/partner alt/atlas} ^- (unit sole-effect) + ?. |(=(~ pan) (~(has in pan) pon)) ~ + =- `[%tan rose+[", " `~]^- leaf+~(ta-full ta man pon) ~] + =< (murn (sort (~(tap by alt)) aor) .) |= {a/ship b/presence c/human} ^- (unit tank) ::TODO print human names. - ~& %present ?- b $gone ~ $hear `>a< diff --git a/app/talk-guardian.hoon b/app/talk-guardian.hoon index 853dab346..6923a2044 100644 --- a/app/talk-guardian.hoon +++ b/app/talk-guardian.hoon @@ -516,9 +516,9 @@ |= new/bone =. +> %- ra-emil :~ :* new %diff %talk-lowdown %tales - %- ~(gas in *(map knot (unit config))) + %- ~(gas in *(map knot (unit cabal))) %+ turn (~(tap by stories)) - |=({a/knot b/story} [a `shape.b]) + |=({a/knot b/story} [a `[shape.b mirrors.b]]) == [new %diff %talk-lowdown %glyph nak] [new %diff %talk-lowdown %names (~(run by folks) some)] @@ -679,14 +679,10 @@ [n.general %diff %talk-lowdown low] +>.$ :: - ++ pa-report-group :: update presence - ::x build a group report, containing our different presence maps, and - ::x send it to all bones. - ::x we send remote presences to facilitate federation. aka "relay" + ++ pa-remotes + ::x produces remotes, with all our local presences replaced by their + ::x versions from their stories. :: - |= vew/(set bone) - %^ pa-report vew %group - :- locals %- ~(urn by remotes) :: XX performance |= {pan/partner atl/atlas} ^- atlas ?. &(?=($& -.pan) =(our.hid p.p.pan)) atl @@ -694,6 +690,19 @@ ?~ soy atl locals.u.soy :: + ++ pa-report-group :: update presence + ::x build a group report, containing our different presence maps, and + ::x send it to all bones. + ::x we send remote presences to facilitate federation. aka "relay" + :: + |= vew/(set bone) + (pa-report vew %group locals pa-remotes) + :: + ++ pa-lowdown-precs + ::x build a presence lowdown, containing our different presence maps. + :: + (pa-inform %precs man locals pa-remotes) + :: ++ pa-report-cabal :: update config ::x a cabal report, containing our and remote configs, to all bones. :: @@ -709,7 +718,7 @@ =+ old=mirrors =. mirrors (~(put by mirrors) cuz con) ?: =(mirrors old) +>.$ - =. +>.$ (pa-inform %tales (strap man `con)) + =. +>.$ (pa-inform %tales (strap man `[con ham])) (pa-report-cabal pa-followers) :: @@ -735,7 +744,7 @@ =. +> %. pa-followers pa-report-cabal(sources.shape (~(del in sources.shape) tay)) - (pa-inform %tales (strap man `shape)) + (pa-inform %tales (strap man `[shape mirrors])) :: ++ pa-sauce :: send backward ::x turns cards into moves, reverse order, prepend to existing moves. @@ -799,7 +808,7 @@ ::x partners we gained/lost, and send out an updated cabal report. :: |= cof/config - =. +>.$ (pa-inform %tales (strap man `cof)) + =. +>.$ (pa-inform %tales (strap man `[cof mirrors])) =+ ^= dif ^- (pair (list partner) (list partner)) =+ old=`(list partner)`(~(tap in sources.shape) ~) =+ new=`(list partner)`(~(tap in sources.cof) ~) @@ -823,7 +832,7 @@ ^+ +> =/ nol (~(put by locals) her saz) ?: =(nol locals) +>.$ - =. +>.$ (pa-inform %precs man (strap her saz)) + =< pa-lowdown-precs (pa-report-group(locals nol) pa-followers) :: ++ pa-remind :: remote presence @@ -836,6 +845,7 @@ =/ buk (~(uni by remotes) rem) ::TODO drop? =. buk (~(put by buk) tay loc) ?: =(buk remotes) +>.$ + =< pa-lowdown-precs (pa-report-group(remotes buk) pa-followers) :: ++ pa-start :: start stream diff --git a/sur/talk.hoon b/sur/talk.hoon index b63fb7e5b..fe55f4a5a 100644 --- a/sur/talk.hoon +++ b/sur/talk.hoon @@ -63,9 +63,9 @@ {$names (map ship (unit human))} :: new identities ::TODO cabal, or merge its contents into tale's config :: basically we just want to merge the ship sets, right? - {$tales (map knot (unit config))} :: changed config + {$tales (map knot (unit cabal))} :: changed config ::TODO merge remote and local presences. - {$precs (pair knot atlas)} :: changed presence + {$precs (pair knot register)} :: changed presence {$grams (pair knot (pair @ud (list telegram)))} :: new grams == :: ++ speech :: narrative action