MCPcopy Create free account
hub / github.com/agent0ai/agent-zero / send

Method send

plugins/_code_execution/helpers/tty_session.py:122–144  ·  view source on GitHub ↗
(self, data: str | bytes)

Source from the content-addressed store, hash-verified

120 self._pty_master_ref = None
121
122 async def send(self, data: str | bytes):
123 if self._proc is None:
124 raise RuntimeError("TTYSpawn is not started")
125 if not _IS_WIN:
126 master = (
127 self._pty_master_ref.get("fd")
128 if self._pty_master_ref is not None
129 else self._pty_master
130 )
131 if master is None:
132 raise RuntimeError("TTYSpawn PTY is closed")
133 if getattr(self._proc, "returncode", None) is not None:
134 raise RuntimeError("TTYSpawn process has exited")
135 if isinstance(data, str):
136 data = data.encode(self.encoding)
137 try:
138 self._proc.stdin.write(data) # type: ignore
139 await self._proc.stdin.drain() # type: ignore
140 except OSError as e:
141 if e.errno in (errno.EBADF, errno.EIO, errno.EINVAL):
142 self._release_pty_master()
143 raise RuntimeError("TTYSpawn PTY is closed") from e
144 raise
145
146 async def sendline(self, line: str):
147 await self.send(line + "\n")

Callers 7

sendlineMethod · 0.95
connectMethod · 0.45
send_commandMethod · 0.45
startMethod · 0.45
_apply_cdp_viewportMethod · 0.45
stopMethod · 0.45
_handle_frameMethod · 0.45

Calls 5

_release_pty_masterMethod · 0.95
drainMethod · 0.80
getMethod · 0.45
encodeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected