~/bend-docscommunity

collect.bend relies on unsafe/foreign

raw source on the hub · import cswap-bend-cli@0.1.0.0/collect.bend as Collect

16 imports
import Base
import ./urec.bend as Urec
import ./pollrow.bend as Pollrow
import ./usage/cred.bend as UCred
import ./store/io.bend as SIo
import ./store/seq.bend as SSeq
import ./store/base.bend as SBase
import ./json.bend as Json
import ./clock.bend as Clock
import ./fs.bend as Fs
import ./act.bend as Act
import ./poll.bend as Poll
import ./ustore.bend as Ustore
import ./usage.bend as Usage
import ./view.bend as View
import ./store.bend as Store

Types

type Info source · line 41 · raw

Data

One managed account with the credential its usage is read with: the live one for the active slot, the stored backup otherwise.

type St source · line 249 · raw

Data

One account with its stored row and the usage state read off them.

Definitions

def ActM source · line 30 · raw

@-A:Type -> Type

def ActM.pure source · line 33 · raw

@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)

def ActM.bind source · line 36 · raw

@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)

def id_of source · line 45 · raw

@+i:Info -> 0x0717344745a30ebad1f19045228e8f18/ustore.Id

def slot_of source · line 50 · raw

@+i:Info -> String

def read_text2 source · line 55 · raw

@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(String) -> String

def read_text source · line 63 · raw

@+path:String -> IO(String)

A file's text, "" when it cannot be read.

def live_ident source · line 66 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> IO(0x0717344745a30ebad1f19045228e8f18/store.Ident)

def active.pick source · line 69 · raw

@ok:Bool -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:0x0717344745a30ebad1f19045228e8f18/store.Ident -> Maybe<&2, String>

def active_slot source · line 76 · raw

@+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:0x0717344745a30ebad1f19045228e8f18/store.Ident -> Maybe<&2, String>

def is_active source · line 79 · raw

@m:Maybe<&2, String> -> @+slot:String -> Bool

def jstr_of source · line 86 · raw

@+rec:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+k:String -> String

def flag.of source · line 89 · raw

@m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> Bool

def rec_flag source · line 96 · raw

@+rec:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+k:String -> Bool

def info.mk source · line 99 · raw

@+n:U32 -> @+rec:0x0717344745a30ebad1f19045228e8f18/json.Json -> @active:Bool -> @+creds:String -> Info

def info.creds source · line 102 · raw

@active:Bool -> @+live:String -> @+root:String -> @+slot:String -> @+email:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(String)

def info.rec source · line 109 · raw

@m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+n:U32 -> @+active:Bool -> @+live:String -> @+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Info)

def info.one source · line 116 · raw

@+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+n:U32 -> @am:Maybe<&2, String> -> @+live:String -> @+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Info)

def infos.go source · line 119 · raw

@ns:List<&2, U32> -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+am:Maybe<&2, String> -> @+live:String -> @+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Info>)

def gather.go source · line 127 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+id:0x0717344745a30ebad1f19045228e8f18/store.Ident -> @+live:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Info>)

def gather source · line 132 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(List<&2, Info>)

Every account in sequence, with the active one (by the live ~/.claude.json identity) carrying the live credential.

def sha.of2 source · line 136 · raw

@oe:Pair(String, String) -> String

def sha.of1 source · line 140 · raw

@r:Pair(U32, Pair(String, String)) -> String

def sha.of source · line 144 · raw

@r:Result<&1, &1, Pair(U32, String), Pair(U32, Pair(String, String))> -> String

def sha256 source · line 152 · raw

@+text:String -> IO(String)

Hex sha256 of a text through shasum(1), the text on stdin (never on argv).

def fp.rt source · line 155 · raw

@+tag:String -> @+text:String -> IO(String)

def fp.pick source · line 158 · raw

@m:Maybe<&2, String> -> @+creds:String -> IO(String)

def fingerprint source · line 167 · raw

@+creds:String -> IO(String)

oauth.credential_fingerprint: the refresh token's hash, else the whole credential's.

def dead.cmp source · line 171 · raw

@+stored:String -> @struck:Maybe<&2, String> -> U32

0 none, 1 dead refresh-token lineage, 2 a strike the credential has outgrown.

def dead.go source · line 178 · raw

@has:Bool -> @struck:Maybe<&2, String> -> @+creds:String -> IO(U32)

def dead.fp source · line 185 · raw

@strikes:U32 -> @struck:Maybe<&2, String> -> @+creds:String -> IO(U32)

def dead.row source · line 188 · raw

@+r:0x0717344745a30ebad1f19045228e8f18/pollrow.Row -> @+creds:String -> IO(U32)

def dead_state source · line 193 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+creds:String -> IO(U32)

def static.cred source · line 196 · raw

@none:Bool -> Maybe<&2, String>

def static.pick source · line 203 · raw

@api:Bool -> @+creds:String -> Maybe<&2, String>

def static_of source · line 210 · raw

@+creds:String -> Maybe<&2, String>

def held_row source · line 213 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> Bool

def expired_creds source · line 216 · raw

@+creds:String -> @+now:U32 -> Bool

def expired.pick source · line 219 · raw

@on:Bool -> @+creds:String -> @+now:U32 -> Maybe<&2, String>

def expired_sentinel source · line 228 · raw

@active:Bool -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+creds:String -> @+now:U32 -> Maybe<&2, String>

An expired active token is never refreshed here (that is Claude Code's, under its own lock): it reads token_expired unless a held reading covers it.

def first source · line 231 · raw

@a:Maybe<&2, String> -> @b:Maybe<&2, String> -> Maybe<&2, String>

def dead.pick source · line 238 · raw

@dead:Bool -> Maybe<&2, String>

def dead_sentinel source · line 245 · raw

@+d:U32 -> Maybe<&2, String>

def st.mk source · line 252 · raw

@+i:Info -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+d:U32 -> @+now:U32 -> St

def row_or_null source · line 257 · raw

@m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/json.Json

def creds_of source · line 264 · raw

@+i:Info -> String

def st.row source · line 269 · raw

@+i:Info -> @+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> IO(St)

def st.of source · line 272 · raw

@+i:Info -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> IO(St)

def states source · line 275 · raw

@xs:List<&2, Info> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> IO(List<&2, St>)

def st_slot source · line 282 · raw

@+s:St -> String

def st_healed source · line 287 · raw

@+s:St -> Bool

def st_id source · line 292 · raw

@+s:St -> 0x0717344745a30ebad1f19045228e8f18/ustore.Id

def st_sentinel source · line 298 · raw

@+s:St -> Maybe<&2, String>