~/bend-docscommunity

swrun.bend relies on unsafe/foreign

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

12 imports
import Base
import ./json.bend as Json
import ./fs.bend as Fs
import ./act.bend as Act
import ./store.bend as Store
import ./swbase.bend as B
import ./swcreds.bend as C
import ./swlive.bend as L
import ./fs/write.bend as FsW
import ./store/base.bend as SBase
import ./store/io.bend as SIo
import ./store/seq.bend as SSeq

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 need source · line 27 · raw

@+ok:Bool -> @+msg:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def reinstruct source · line 30 · raw

@+slot:String -> String

def oauth_present source · line 33 · raw

@+j:0x0717344745a30ebad1f19045228e8f18/json.Json -> Bool

def backup_outgoing source · line 41 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/swcreds.CKind -> @+root:String -> @+cur:String -> @+email:String -> @+creds:String -> @+cfg_text:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

The outgoing account's backup, by what the live credential is.

def salvage source · line 58 · raw

@+bad:Bool -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def new_config source · line 63 · raw

@+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/json.Json

What ~/.claude.json becomes: the live one with the target's oauthAccount, or the target's whole config backup when there is no readable live one.

def live_salvage source · line 66 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+ts:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def activate_files source · line 69 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+ts:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def final_steps source · line 75 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+ts:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def transact source · line 80 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+ts:String -> @+seq_text:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @steps:0x0717344745a30ebad1f19045228e8f18/act.of(Unit) -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def archive_for_a source · line 83 · raw

@+root:String -> @+cts:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def finish_a source · line 86 · raw

@+root:String -> @+target:String -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def switch_a source · line 91 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+temail:String -> @+ts:String -> @+cts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def live_present source · line 97 · raw

@+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def classify_in source · line 100 · raw

@+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+backup:String -> @+others:List<&2, 0x0717344745a30ebad1f19045228e8f18/swcreds.Other> -> 0x0717344745a30ebad1f19045228e8f18/swcreds.CKind

def classify_b source · line 103 · raw

@+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/swcreds.CKind)

def backup_out source · line 110 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/swcreds.CKind -> @+root:String -> @+cur:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def save_b source · line 113 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/swcreds.CKind -> @+root:String -> @+cur:String -> @+ts:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def finish_b source · line 118 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/swcreds.CKind -> @+root:String -> @+target:String -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def switch_b source · line 123 · raw

@+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+temail:String -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+cur:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform5 source · line 130 · raw

@+case_a:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform4 source · line 135 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+oauth:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform7 source · line 138 · raw

@+ok:Bool -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> @+tcfg:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform6 source · line 143 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> @parsed:Result<&2, &2, String, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def tcfg_need source · line 150 · raw

@+target:String -> @+tcfg_text:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def perform3b source · line 153 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> @+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+tcreds:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform3 source · line 159 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+temail:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform2b source · line 166 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+rec:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform2 source · line 173 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+root:String -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> @+seq_text:String -> @parsed:Result<&2, &2, String, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def perform_locked source · line 181 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+target:String -> @+force:Bool -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

The switch itself, under every lock the reference takes.

def verify2 source · line 186 · raw

@+l:0x0717344745a30ebad1f19045228e8f18/swlive.Live -> @+target:String -> @+temail:String -> @+torg:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

def verify_live source · line 194 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+delay_ms:U32 -> @+target:String -> @+temail:String -> @+torg:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)

Claude Code on macOS prefers a keychain login over ~/.claude/.credentials.json, so a file-only switch can be silently undone: it rewrites oauthAccount from the keychain login. Wait opts, read ~/.claude.json again, and if it no longer names the target report live-login-overridden. The keychain is never touched; the remedy is the user's.

def do_switch2 source · line 200 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+target:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+pre:0x0717344745a30ebad1f19045228e8f18/swlive.Pre -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)

def do_switch source · line 207 · raw

@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+target:String -> @+force:Bool -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)