6
6
7
7
AGI_SOCK=/tmp/agi.sock go run agi_sshd.go
8
8
9
- ssh -NnT -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -R /tmux.sock:$(echo $TMUX | sed -e 's/,.*//g') -R /input.sock:$(mktemp -d)/input.sock user@localhost
9
+ export INPUT_SOCK="$(mktemp -d)/input.sock"; ssh -NnT -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -R /tmux.sock:$(echo $TMUX | sed -e 's/,.*//g') -R "${INPUT_SOCK}:${INPUT_SOCK}" user@localhost
10
10
11
11
12
12
gh auth refresh -h github.com -s admin:public_key
@@ -3293,6 +3293,12 @@ def make_argparse_parser(argv=None):
3293
3293
default = None ,
3294
3294
type = str ,
3295
3295
)
3296
+ parser .add_argument (
3297
+ "--client-side-input-socket-path" ,
3298
+ dest = "client_side_input_socket_path" ,
3299
+ default = None ,
3300
+ type = str ,
3301
+ )
3296
3302
parser .add_argument (
3297
3303
"--agi-name" ,
3298
3304
dest = "agi_name" ,
@@ -4128,11 +4134,13 @@ async def read_unix_socket_lines(path):
4128
4134
await writer .wait_closed ()
4129
4135
4130
4136
4131
- async def pdb_action_stream (tg , user_name , agi_name , agents , threads , pane : Optional [libtmux .Pane ] = None ):
4137
+ async def pdb_action_stream (tg , user_name , agi_name , agents , threads , pane : Optional [libtmux .Pane ] = None , input_socket_path : Optional [ str ] = None ):
4132
4138
# TODO Take ALICE_INPUT from args
4139
+ alice_input_sock = input_socket_path
4133
4140
if pane is not None :
4134
4141
alice_input = pane .window .session .show_environment ()[f"{ agi_name .upper ()} _INPUT" ]
4135
- alice_input_sock = pane .window .session .show_environment ()[f"{ agi_name .upper ()} _INPUT_SOCK" ]
4142
+ if alice_input_sock is None :
4143
+ alice_input_sock = pane .window .session .show_environment ()[f"{ agi_name .upper ()} _INPUT_SOCK" ]
4136
4144
alice_input_last_line = pane .window .session .show_environment ()[f"{ agi_name .upper ()} _INPUT_LAST_LINE" ]
4137
4145
4138
4146
if pathlib .Path (alice_input_sock ).is_socket ():
@@ -4253,6 +4261,8 @@ async def main(
4253
4261
openai_api_key : str = None ,
4254
4262
openai_base_url : Optional [str ] = None ,
4255
4263
pane : Optional [libtmux .Pane ] = None ,
4264
+ input_socket_path : Optional [str ] = None ,
4265
+ client_side_input_socket_path : Optional [str ] = None ,
4256
4266
):
4257
4267
if log is not None :
4258
4268
# logging.basicConfig(level=log)
@@ -4296,6 +4306,7 @@ async def main(
4296
4306
agents ,
4297
4307
threads ,
4298
4308
pane = pane ,
4309
+ input_socket_path = input_socket_path ,
4299
4310
)
4300
4311
4301
4312
# Waiting Event Stream and Callbacks
@@ -4450,7 +4461,7 @@ async def user_input_action_stream_queue_iterator(queue):
4450
4461
# pane.send_keys(f'', enter=True)
4451
4462
4452
4463
pane .send_keys (f'export { agi_name .upper ()} _INPUT="' + '${CALLER_PATH}/input.txt"' , enter = True )
4453
- pane .send_keys (f'export { agi_name .upper ()} _INPUT_SOCK="' + '${CALLER_PATH}/input.sock "' , enter = True )
4464
+ pane .send_keys (f'export { agi_name .upper ()} _INPUT_SOCK="{ client_side_input_socket_path } "' , enter = True )
4454
4465
pane .send_keys (f'export { agi_name .upper ()} _INPUT_LAST_LINE="' + '${CALLER_PATH}/input-last-line.txt"' , enter = True )
4455
4466
4456
4467
# TODO
@@ -4702,7 +4713,7 @@ def a_shell_for_a_ghost_send_keys(pane, send_string, erase_after=None):
4702
4713
time .sleep (0.01 )
4703
4714
4704
4715
4705
- async def tmux_test (* args , socket_path = None , input_socket_path = None , ** kwargs ):
4716
+ async def tmux_test (* args , socket_path = None , input_socket_path = None , client_side_input_socket_path : Optional [ str ] = None , ** kwargs ):
4706
4717
pane = None
4707
4718
tempdir = None
4708
4719
possible_tempdir = tempdir
@@ -4792,7 +4803,7 @@ async def tmux_test(*args, socket_path=None, input_socket_path=None, **kwargs):
4792
4803
session .set_environment (tempdir_env_var , tempdir )
4793
4804
4794
4805
session .set_environment (f"{ agi_name .upper ()} _INPUT" , str (pathlib .Path (tempdir , "input.txt" )))
4795
- session .set_environment (f"{ agi_name .upper ()} _INPUT_SOCK" , str ( input_socket_path ) )
4806
+ session .set_environment (f"{ agi_name .upper ()} _INPUT_SOCK" , client_side_input_socket_path )
4796
4807
session .set_environment (f"{ agi_name .upper ()} _INPUT_LAST_LINE" , str (pathlib .Path (tempdir , "input-last-line.txt" )))
4797
4808
4798
4809
pane .send_keys (
@@ -4946,7 +4957,7 @@ async def tmux_test(*args, socket_path=None, input_socket_path=None, **kwargs):
4946
4957
time .sleep (0.1 )
4947
4958
4948
4959
pane .send_keys (f"export { agi_name .upper ()} _INPUT=" + str (pathlib .Path (tempdir , "input.txt" )), enter = True )
4949
- pane .send_keys (f" export { agi_name .upper ()} _INPUT_SOCK=" + str ( input_socket_path ) , enter = True )
4960
+ pane .send_keys (f' export { agi_name .upper ()} _INPUT_SOCK="{ client_side_input_socket_path } "' , enter = True )
4950
4961
pane .send_keys (f"export { agi_name .upper ()} _INPUT_LAST_LINE=" + str (pathlib .Path (tempdir , "input-last-line.txt" )), enter = True )
4951
4962
pane .send_keys (f'rm -fv ${ agi_name .upper ()} _INPUT_SOCK' , enter = True )
4952
4963
pane .send_keys (f'ln -s ${ agi_name .upper ()} _INPUT_SOCK' , enter = True )
@@ -4955,7 +4966,7 @@ async def tmux_test(*args, socket_path=None, input_socket_path=None, **kwargs):
4955
4966
4956
4967
pane .send_keys (f'set +x' , enter = True )
4957
4968
4958
- await main (* args , pane = pane , ** kwargs )
4969
+ await main (* args , pane = pane , input_socket_path = input_socket_path , client_side_input_socket_path = client_side_input_socket_path , ** kwargs )
4959
4970
finally :
4960
4971
with contextlib .suppress (Exception ):
4961
4972
if pane is not None :
@@ -4977,7 +4988,7 @@ async def lifespan_logging(app):
4977
4988
app = FastAPI (lifespan = lifespan_logging )
4978
4989
4979
4990
4980
- def run_tmux_attach (socket_path , input_socket_path ):
4991
+ def run_tmux_attach (socket_path , input_socket_path , client_side_input_socket_path ):
4981
4992
cmd = [
4982
4993
sys .executable ,
4983
4994
"-u" ,
@@ -4986,6 +4997,8 @@ def run_tmux_attach(socket_path, input_socket_path):
4986
4997
socket_path ,
4987
4998
"--input-socket-path" ,
4988
4999
input_socket_path ,
5000
+ "--client-side-input-socket-path" ,
5001
+ client_side_input_socket_path ,
4989
5002
"--agi-name" ,
4990
5003
# TODO Something secure here, scitt URN and lookup for PS1?
4991
5004
f"alice{ str (uuid .uuid4 ()).split ('-' )[4 ]} " ,
@@ -5016,11 +5029,12 @@ async def connect_and_read(socket_path: str, sleep_time: float = 0.1):
5016
5029
class RequestConnectTMUX (BaseModel ):
5017
5030
socket_tmux_path : str = Field (alias = "tmux.sock" )
5018
5031
socket_input_path : str = Field (alias = "input.sock" )
5032
+ socket_client_side_input_path : str = Field (alias = "client-side-input.sock" )
5019
5033
5020
5034
5021
5035
@app .post ("/connect/tmux" )
5022
5036
async def connect (request_connect_tmux : RequestConnectTMUX , background_tasks : BackgroundTasks ):
5023
- background_tasks .add_task (run_tmux_attach , request_connect_tmux .socket_tmux_path , request_connect_tmux .socket_input_path )
5037
+ background_tasks .add_task (run_tmux_attach , request_connect_tmux .socket_tmux_path , request_connect_tmux .socket_input_path , request_connect_tmux . socket_client_side_input_path )
5024
5038
return {
5025
5039
"connected" : True ,
5026
5040
}
0 commit comments