@unionschool/easy-agents 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -10
- package/bin/easy-agents.js +170 -16
- package/bin/mac-reports.js +149 -0
- package/bin/mac-service.js +119 -0
- package/bin/pair.js +79 -0
- package/bin/portable-service.js +66 -0
- package/bin/run.js +234 -0
- package/bin/tasks.js +134 -0
- package/bin/terminal.js +66 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +539 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +142 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +751 -0
- package/node_modules/ws/lib/sender.js +610 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +565 -0
- package/node_modules/ws/lib/websocket.js +1471 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +25 -2
- package/runtime/desktop_chat.py +105 -0
- package/runtime/easyagents_core/file_delivery.py +166 -0
- package/runtime/easyagents_core/git_sync.py +272 -0
- package/runtime/easyagents_core/mcp_call.py +165 -0
- package/runtime/easyagents_core/member_sync.py +128 -0
- package/runtime/easyagents_core/process_support.py +60 -0
- package/runtime/ssh_terminal.py +89 -0
- package/runtime/sync.py +17 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Present the local SSH login on a PTY. The operating system authenticates the user."""
|
|
2
|
+
import fcntl
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import pty
|
|
6
|
+
import pwd
|
|
7
|
+
import select
|
|
8
|
+
import signal
|
|
9
|
+
import socket
|
|
10
|
+
import struct
|
|
11
|
+
import sys
|
|
12
|
+
import tempfile
|
|
13
|
+
import termios
|
|
14
|
+
from contextlib import suppress
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def known_hosts():
|
|
18
|
+
lines = []
|
|
19
|
+
for path in Path('/etc/ssh').glob('ssh_host_*_key.pub'):
|
|
20
|
+
with suppress(OSError):
|
|
21
|
+
fields = path.read_text().split()
|
|
22
|
+
if len(fields) >= 2:
|
|
23
|
+
lines.append('127.0.0.1 ' + ' '.join(fields[:2]))
|
|
24
|
+
return '\n'.join(lines) + '\n' if lines else ''
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def resize(fd, cols, rows):
|
|
28
|
+
if 1 <= cols <= 1000 and 1 <= rows <= 1000:
|
|
29
|
+
fcntl.ioctl(fd, termios.TIOCSWINSZ, struct.pack('HHHH', rows, cols, 0, 0))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def login(path, cols, rows):
|
|
33
|
+
user = pwd.getpwuid(os.getuid()).pw_name
|
|
34
|
+
pid, master = pty.fork()
|
|
35
|
+
if pid == 0:
|
|
36
|
+
resize(0, cols, rows)
|
|
37
|
+
# Use only an interactive account login. Never inherit a service key or agent.
|
|
38
|
+
os.execve('/usr/bin/ssh', ['ssh', '-F', '/dev/null', '-tt', '-e', 'none',
|
|
39
|
+
'-o', 'PubkeyAuthentication=no', '-o', 'IdentityAgent=none',
|
|
40
|
+
'-o', 'PreferredAuthentications=keyboard-interactive,password',
|
|
41
|
+
'-o', 'ClearAllForwardings=yes', '-o', 'ForwardAgent=no',
|
|
42
|
+
'-o', 'ForwardX11=no', '-o', 'StrictHostKeyChecking=yes',
|
|
43
|
+
'-o', 'GlobalKnownHostsFile=/dev/null', '-o', 'UserKnownHostsFile=' + path,
|
|
44
|
+
'-o', 'ConnectTimeout=8', '-l', user, '127.0.0.1'],
|
|
45
|
+
{'PATH': '/usr/bin:/bin', 'TERM': 'xterm-256color', 'LC_ALL': 'C'})
|
|
46
|
+
try:
|
|
47
|
+
control = b''
|
|
48
|
+
while True:
|
|
49
|
+
ready, _, _ = select.select([0, 3, master], [], [])
|
|
50
|
+
for fd in ready:
|
|
51
|
+
data = os.read(fd, 32768)
|
|
52
|
+
if not data:
|
|
53
|
+
return
|
|
54
|
+
if fd == 3:
|
|
55
|
+
control += data
|
|
56
|
+
while len(control) >= 4:
|
|
57
|
+
resize(master, *struct.unpack('!HH', control[:4]))
|
|
58
|
+
control = control[4:]
|
|
59
|
+
else:
|
|
60
|
+
dest = 1 if fd == master else master
|
|
61
|
+
while data:
|
|
62
|
+
data = data[os.write(dest, data):]
|
|
63
|
+
finally:
|
|
64
|
+
os.close(master)
|
|
65
|
+
with suppress(ProcessLookupError):
|
|
66
|
+
os.kill(pid, signal.SIGKILL)
|
|
67
|
+
os.waitpid(pid, 0)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == '__main__':
|
|
71
|
+
keys = known_hosts()
|
|
72
|
+
if not keys or not os.access('/usr/bin/ssh', os.X_OK) or os.getuid() == 0:
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
if sys.argv[1:] == ['--check']:
|
|
75
|
+
with socket.create_connection(('127.0.0.1', 22), timeout=1):
|
|
76
|
+
pass
|
|
77
|
+
else:
|
|
78
|
+
def stop(*_):
|
|
79
|
+
raise SystemExit(0)
|
|
80
|
+
|
|
81
|
+
signal.signal(signal.SIGTERM, stop)
|
|
82
|
+
with tempfile.NamedTemporaryFile(mode='w') as hosts:
|
|
83
|
+
hosts.write(keys)
|
|
84
|
+
hosts.flush()
|
|
85
|
+
try:
|
|
86
|
+
login(hosts.name, int(sys.argv[1]), int(sys.argv[2]))
|
|
87
|
+
except OSError as error:
|
|
88
|
+
if error.errno != 5: # PTY EOF on Linux.
|
|
89
|
+
raise
|
package/runtime/sync.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Run the packaged member-sync implementation using only Python's standard library."""
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import signal
|
|
5
|
+
import sys
|
|
6
|
+
from threading import Event
|
|
7
|
+
|
|
8
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
9
|
+
from easyagents_core import member_sync
|
|
10
|
+
|
|
11
|
+
cancel = Event()
|
|
12
|
+
signal.signal(signal.SIGTERM, lambda *_: cancel.set())
|
|
13
|
+
request = json.load(sys.stdin)
|
|
14
|
+
result = member_sync.run(Path.cwd(), request, cancel)
|
|
15
|
+
print(json.dumps({key: getattr(result, key) for key in (
|
|
16
|
+
'status', 'reply_text', 'workspace_sync', 'failure_code', 'failure_detail'
|
|
17
|
+
) if getattr(result, key) is not None}))
|