daemon/collect.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/daemon/collect.bend as Collect
11 imports
import Base import ../json.bend as Json import ../act.bend as Act import ../store/base.bend as SBase import ../policy/types.bend as T import ../policy/usage.bend as PU import ./config.bend as Cfg import ./gather.bend as G import ./view.bend as V import ./plan.bend as Plan import ./fetch.bend as Fetch
Definitions
def ActM source · line 18 · raw
@-A:Type -> Type
def ActM.pure source · line 21 · raw
@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
def ActM.bind source · line 24 · raw
@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)
def is_token_expired source · line 27 · raw
@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> Bool
def escalate2 source · line 34 · raw
@+h:Maybe<&2, Nat> -> @+expired:Bool -> @+thr:U32 -> Bool
def should_escalate source · line 44 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+thr:U32 -> @+ms:List<&2, String> -> Bool
Fetch every candidate too when the active account's headroom is unknown (and the token is not just expired on an idle Claude Code), or it is within 15 points of the threshold.
def fetch_pass source · line 51 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+targets:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:Maybe<&2, String> -> @+now:U32 -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def escalation source · line 57 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:String -> @+rows1:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+rows0:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def shaky source · line 60 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:String -> @+rows1:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> Bool
def second_pass source · line 63 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:String -> @+rows1:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+rows0:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def collect source · line 71 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:String -> @+rows0:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
Fetch what is due, in two passes (the active account and one candidate; then everyone when the active account is shaky), and answer the rows as they stand.
def snap_with source · line 76 · raw
@+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap
def refresh2 source · line 81 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+now:U32 -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+a:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap)
def refresh3 source · line 87 · raw
@+a:Maybe<&2, String> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+now:U32 -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap)
The snapshot with the due accounts fetched; unchanged without an active account.
def refresh source · line 95 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+now:U32 -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap)
The snapshot with the due accounts fetched; unchanged without an active account.
def some source · line 98 · raw
@+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> 0x0717344745a30ebad1f19045228e8f18/act.of(Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap>)
def refresh_opt source · line 101 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+now:U32 -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap> -> 0x0717344745a30ebad1f19045228e8f18/act.of(Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap>)