okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
f479db5
main
1"""Opt-in: a real ssh target end to end. Needs key auth and python3 remotely. 2 3python3 test/manual/remote_ssh.py [user@host] 4 5Exercises staging, kernel boot, tool calls, relay, degradation is NOT tested 6here (that needs a broken target), and control-master reuse across calls. 7""" 8 9import asyncio 10import os 11import sys 12from pathlib import Path 13 14ROOT = Path (__file__ ).resolve ().parents [2 ] 15sys .path .insert (0 ,str (ROOT / "priv" / "python" )) 16from albedo_api import PythonApi # noqa: E402 17from albedo_capture import Capture # noqa: E402 18from albedo_plugins import remote # noqa: E402 19 20 21async def main (host :str )-> int : 22loop = asyncio .get_running_loop () 23 24async def daemon_host (method ,args ): 25return [{"relay" :True ,"method" :method }] 26 27api = PythonApi ( 28loop , 29daemon_host , 30RuntimeError , 31Capture , 3265536 , 33lambda event :None , 34lambda close :None , 35lambda cls :None , 362 , 37 ["run" ,"files" ,"work" ,"skills" ,"remote" ], 38 ) 39remote .setup (api ) 40rem_mod = remote .Remote () 41rem = await rem_mod .connect (host = host ) 42"connected:" ,repr (rem )) 43tools = await rem .tools () 44"remote tools:" ,tools ["names" ]) 45 46# the local-run shape: sync call, sync state, one await for completion 47job = rem .run ("uname" ,"-s" ) 48"mid-run tail:" ,repr (job .tail ()),"poll:" ,job .poll ()) 49await job 50"run:" ,job .tail ().strip (),"exit:" ,job .poll ()) 51 52listing = await rem .files .ls ("." ) 53"files.ls entries:" ,len (listing )) 54relay = await rem .work .list () 55"relay answer:" ,relay [0 ]) 56 57import time 58 59started = time .monotonic () 60again = rem .run ("true" ) 61await again 62f"second call over the control socket: { time . monotonic () - started :.2f } s" ) 63 64await rem .close () 65"closed:" ,rem .closed ) 66return 0 67 68 69if __name__ == "__main__" : 70target = ( 71sys .argv [1 ]if len (sys .argv )> 1 else os .environ .get ("ALBEDO_SSH" ,"localhost" ) 72 ) 73raise SystemExit (asyncio .run (main (target )))